MARLEY (Model of Argon Reaction Low Energy Yields) v2.0.0
A Monte Carlo event generator for tens-of-MeV neutrino interactions
Loading...
Searching...
No Matches
marley::Level Class Reference

A discrete nuclear energy level. More...

#include <Level.hh>

Public Member Functions

 Level (double E, int twoJ, marley::Parity pi, double half_life)
 
marley::Gammaadd_gamma (const marley::Gamma &gamma)
 Add a new gamma-ray transition to this level.
 
marley::Gammaadd_gamma (double energy, double branching_ratio, marley::Level *end_lev=nullptr)
 Add a new gamma-ray transition to this level.
 
void clear_gammas ()
 Remove all gamma ray information from this level.
 
double energy () const
 Get the excitation energy of this level (MeV)
 
std::vector< marley::Gamma > & gammas ()
 Retrieve a reference to the vector of gamma rays owned by this level.
 
const std::vector< marley::Gamma > & gammas () const
 Retrieve a const reference to the vector of gamma rays owned by this level.
 
double half_life () const
 Get the level half-life (s)
 
bool has_gammas () const
 
marley::Parity parity () const
 Get the level parity.
 
const marley::Gammasample_gamma (marley::Generator &gen, double *prob_ptr=nullptr)
 Choose a gamma owned by this level randomly based on the relative intensities of all of the gammas.
 
void set_energy (double E)
 Set the excitation energy of this level (MeV)
 
void set_half_life (double half_life)
 Set the level half-life (s)
 
void set_parity (marley::Parity pi)
 Set the level parity.
 
void set_twoJ (int twoJ)
 Set two times the level spin.
 
std::string spin_parity_string () const
 Returns the level spin-parity as a string.
 
int twoJ () const
 Get two times the level spin.
 

Static Public Member Functions

template<typename It>
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 iterator that points to the Level's energy_ member variable.
 

Detailed Description

A discrete nuclear energy level.

Definition at line 29 of file Level.hh.

Constructor & Destructor Documentation

◆ Level()

marley::Level::Level ( double E,
int twoJ,
marley::Parity pi,
double half_life )
Parameters
Eexcitation energy of this level (MeV)
twoJtwo times the level spin
pilevel parity
half_lifehalf-life of the level (s)

Definition at line 26 of file Level.cc.

27 : energy_( E ), twoJ_( twoJ ), parity_( pi ), half_life_( half_life )
28{}
double half_life() const
Get the level half-life (s)
Definition Level.hh:144
int twoJ() const
Get two times the level spin.
Definition Level.hh:138

References half_life(), and twoJ().

Member Function Documentation

◆ add_gamma() [1/2]

marley::Gamma & marley::Level::add_gamma ( const marley::Gamma & gamma)

Add a new gamma-ray transition to this level.

Returns
a reference to the newly added gamma

Definition at line 55 of file Level.cc.

55 {
56 // Update the vector of gamma objects
57 gammas_.push_back( gamma );
58
59 // Update the distribution for sampling gammas
60 update_gamma_distribution();
61
62 // Return a reference to the newly added gamma
63 return gammas_.back();
64}

Referenced by marley::DecayScheme::read_from_stream().

◆ add_gamma() [2/2]

marley::Gamma & marley::Level::add_gamma ( double energy,
double branching_ratio,
marley::Level * end_lev = nullptr )

Add a new gamma-ray transition to this level.

Parameters
energyGamma-ray energy (MeV)
branching_ratioBranching ratio for the new gamma-ray transition
end_levPointer to the level that absorbs this gamma
Returns
a reference to the newly added gamma

Definition at line 66 of file Level.cc.

68{
69 // Update the vector of gamma objects
70 gammas_.emplace_back( energy, branching_ratio, this, end_lev );
71
72 // Update the distribution for sampling gammas
73 update_gamma_distribution();
74
75 // Return a reference to the newly added gamma
76 return gammas_.back();
77}
double energy() const
Get the excitation energy of this level (MeV)
Definition Level.hh:135

References energy().

◆ clear_gammas()

void marley::Level::clear_gammas ( )

Remove all gamma ray information from this level.

Definition at line 79 of file Level.cc.

79 {
80 gammas_.clear();
81
82 // The discrete distribution will be cleared by this command because the
83 // vector of gammas is now empty.
84 update_gamma_distribution();
85}

◆ energy()

double marley::Level::energy ( ) const
inline

Get the excitation energy of this level (MeV)

Definition at line 135 of file Level.hh.

135{ return energy_; }

Referenced by add_gamma(), marley::DecayScheme::add_level(), marley::DecayScheme::do_cascade(), marley::NucleusDecayer::process_event(), and marley::OMPWeightCalculator::weight().

◆ gammas() [1/2]

std::vector< marley::Gamma > & marley::Level::gammas ( )
inline

Retrieve a reference to the vector of gamma rays owned by this level.

Definition at line 150 of file Level.hh.

150{ return gammas_; }

◆ gammas() [2/2]

const std::vector< marley::Gamma > & marley::Level::gammas ( ) const
inline

Retrieve a const reference to the vector of gamma rays owned by this level.

Definition at line 148 of file Level.hh.

149 { return gammas_; }

◆ half_life()

double marley::Level::half_life ( ) const
inline

Get the level half-life (s)

Definition at line 144 of file Level.hh.

144{ return half_life_; }

Referenced by Level(), marley::DecayScheme::do_cascade(), and set_half_life().

◆ has_gammas()

bool marley::Level::has_gammas ( ) const
inline
Returns
true if the level owns at least one Gamma object

Definition at line 152 of file Level.hh.

152{ return !gammas_.empty(); }

◆ make_energy_iterator()

template<typename It>
marley::IteratorToPointerMember< It, double > marley::Level::make_energy_iterator ( It it)
inlinestatic

Convert an iterator that points to a marley::Level* (or a smart pointer to a marley::Level) into an iterator that points to the Level's energy_ member variable.

This function is used by the DecayScheme class to keep the vector of std::unique_ptr<marley::Level> objects that it owns sorted in order of increasing excitation energy.

Definition at line 155 of file Level.hh.

156 {
157 return marley::IteratorToPointerMember< It, double >( it,
158 &marley::Level::energy_ );
159 }

Referenced by marley::DecayScheme::level_lower_bound_index().

◆ parity()

marley::Parity marley::Level::parity ( ) const
inline

Get the level parity.

Definition at line 141 of file Level.hh.

141{ return parity_; }

Referenced by marley::DiscreteNuclearReaction::create_event(), and marley::DecayScheme::do_cascade().

◆ sample_gamma()

const marley::Gamma * marley::Level::sample_gamma ( marley::Generator & gen,
double * prob_ptr = nullptr )

Choose a gamma owned by this level randomly based on the relative intensities of all of the gammas.

Parameters
genReference to the Generator object to use for random sampling
[out]prob_ptrOptional double* that, if not nullptr, will be used to store the probability of choosing the sampled gamma
Returns
a pointer to the selected Gamma object, or nullptr if the level doesn't have any gammas

Definition at line 30 of file Level.cc.

32{
33 // Initialize the probability of sampling the gamma to zero
34 if ( prob_ptr ) *prob_ptr = 0.;
35
36 if ( gammas_.empty() ) return nullptr;
37 else {
38 // Get the index of the gamma to return by randomly sampling from the
39 // discrete distribution gamma_dist using the standard marley_utils random
40 // number generator.
41 size_t g_index = gen.sample_from_distribution( gamma_dist_ );
42
43 // If we have a non-null double* to use to store the probability of
44 // sampling this particular gamma, then do the storage here
45 if ( prob_ptr ) {
46 std::vector< double > probs = gamma_dist_.probabilities();
47 *prob_ptr = probs.at( g_index );
48 }
49
50 // Return a pointer to the corresponding gamma
51 return &( gammas_[ g_index ] );
52 }
53}
auto sample_from_distribution(RandomNumberDistribution &rnd) -> decltype(std::declval< RandomNumberDistribution & >().operator()(std::declval< std::mt19937_64 & >()))
Sample from an arbitrary probability distribution (defined here as any object that implements an oper...
Definition Generator.hh:193

References marley::Generator::sample_from_distribution().

Referenced by marley::DecayScheme::do_cascade().

◆ set_energy()

void marley::Level::set_energy ( double E)
inline

Set the excitation energy of this level (MeV)

Definition at line 136 of file Level.hh.

136{ energy_ = E; }

◆ set_half_life()

void marley::Level::set_half_life ( double half_life)
inline

Set the level half-life (s)

Definition at line 145 of file Level.hh.

146 { half_life_ = half_life; }

References half_life().

◆ set_parity()

void marley::Level::set_parity ( marley::Parity pi)
inline

Set the level parity.

Definition at line 142 of file Level.hh.

142{ parity_ = pi; }

◆ set_twoJ()

void marley::Level::set_twoJ ( int twoJ)
inline

Set two times the level spin.

Definition at line 139 of file Level.hh.

139{ twoJ_ = twoJ; }

References twoJ().

◆ spin_parity_string()

std::string marley::Level::spin_parity_string ( ) const

Returns the level spin-parity as a string.

Definition at line 87 of file Level.cc.

87 {
88 std::string str = std::to_string( twoJ_ / 2 );
89 // If 2*J is odd, then the level has half-integer spin
90 if ( twoJ_ % 2 ) str += "/2";
91 return str + parity_.to_char();
92}

◆ twoJ()

int marley::Level::twoJ ( ) const
inline

Get two times the level spin.

Definition at line 138 of file Level.hh.

138{ return twoJ_; }

Referenced by Level(), marley::DiscreteNuclearReaction::create_event(), marley::DecayScheme::do_cascade(), and set_twoJ().


The documentation for this class was generated from the following files: