MARLEY (Model of Argon Reaction Low Energy Yields)  v1.2.0
A Monte Carlo event generator for tens-of-MeV neutrino interactions
Level.hh
1 //
5 // This file is part of MARLEY (Model of Argon Reaction Low Energy Yields)
6 //
7 // MARLEY is free software: you can redistribute it and/or modify it under the
8 // terms of version 3 of the GNU General Public License as published by the
9 // Free Software Foundation.
10 //
11 // For the full text of the license please see COPYING or
12 // visit http://opensource.org/licenses/GPL-3.0
13 //
14 // Please respect the MCnet academic usage guidelines. See GUIDELINES
15 // or visit https://www.montecarlonet.org/GUIDELINES for details.
16 
17 #pragma once
18 #include <random>
19 
20 #include "marley/Gamma.hh"
21 #include "marley/IteratorToPointerMember.hh"
22 #include "marley/Parity.hh"
23 
24 namespace marley {
25 
26  class Generator;
27 
29  class Level {
30  public:
31 
35  Level(double E, int twoJ, marley::Parity pi);
36 
39  inline const std::vector<marley::Gamma>& gammas() const;
40 
42  inline std::vector<marley::Gamma>& gammas();
43 
45  inline double energy() const;
47  inline void set_energy(double E);
48 
50  inline int twoJ() const;
52  inline void set_twoJ(int twoJ);
53 
55  inline marley::Parity parity() const;
57  inline void set_parity(marley::Parity pi);
58 
60  inline bool has_gammas() const;
61 
64  marley::Gamma& add_gamma(const marley::Gamma& gamma);
65 
72  marley::Gamma& add_gamma(double energy, double branching_ratio,
73  marley::Level* end_lev = nullptr);
74 
76  void clear_gammas();
77 
83 
85  std::string spin_parity_string() const;
86 
93  template<typename It> inline static marley::IteratorToPointerMember<It,
94  double> make_energy_iterator(It it);
95 
96  private:
97 
98  double energy_;
99 
103  int twoJ_;
104 
105  marley::Parity parity_;
106 
108  std::vector<marley::Gamma> gammas_;
109 
112  std::discrete_distribution<size_t> gamma_dist_;
113 
116  void update_gamma_distribution();
117  };
118 
119  // Inline function definitions
120  inline double Level::energy() const { return energy_; }
121  inline void Level::set_energy(double E) { energy_ = E; }
122 
123  inline int Level::twoJ() const { return twoJ_; }
124  inline void Level::set_twoJ(int twoJ) { twoJ_ = twoJ; }
125 
126  inline marley::Parity Level::parity() const { return parity_; }
127  inline void Level::set_parity(marley::Parity pi) { parity_ = pi; }
128 
129  inline const std::vector<marley::Gamma>& Level::gammas() const
130  { return gammas_; }
131  inline std::vector<marley::Gamma>& Level::gammas() { return gammas_; }
132 
133  inline bool Level::has_gammas() const { return !gammas_.empty(); }
134 
135  template<typename It> inline marley::IteratorToPointerMember<It,
137  {
139  &marley::Level::energy_);
140  }
141 }
A gamma-ray transition between two nuclear levels.
Definition: Gamma.hh:25
The MARLEY Event generator.
Definition: Generator.hh:42
Template class that creates an iterator to a class member based on an iterator to a pointer (either b...
Definition: IteratorToPointerMember.hh:31
A discrete nuclear energy level.
Definition: Level.hh:29
void set_twoJ(int twoJ)
Set two times the level spin.
Definition: Level.hh:124
bool has_gammas() const
Definition: Level.hh:133
Level(double E, int twoJ, marley::Parity pi)
Definition: Level.cc:26
static marley::IteratorToPointerMember< It, double > make_energy_iterator(It it)
Convert an iterator that points to a marley::Level* (or a smart pointer to a marley::Level) into an i...
Definition: Level.hh:136
marley::Gamma & add_gamma(const marley::Gamma &gamma)
Add a new gamma-ray transition to this level.
Definition: Level.cc:42
const std::vector< marley::Gamma > & gammas() const
Retrieve a const reference to the vector of gamma rays owned by this level.
Definition: Level.hh:129
void set_parity(marley::Parity pi)
Set the level parity.
Definition: Level.hh:127
const marley::Gamma * sample_gamma(marley::Generator &gen)
Choose a gamma owned by this level randomly based on the relative intensities of all of the gammas.
Definition: Level.cc:29
marley::Parity parity() const
Get the level parity.
Definition: Level.hh:126
int twoJ() const
Get two times the level spin.
Definition: Level.hh:123
void clear_gammas()
Remove all gamma ray information from this level.
Definition: Level.cc:66
void set_energy(double E)
Set the excitation energy of this level (MeV)
Definition: Level.hh:121
std::string spin_parity_string() const
Returns the level spin-parity as a string.
Definition: Level.cc:74
double energy() const
Get the excitation energy of this level (MeV)
Definition: Level.hh:120
Type-safe representation of a parity value (either +1 or -1)
Definition: Parity.hh:25