|
MARLEY (Model of Argon Reaction Low Energy Yields) v2.0.0
A Monte Carlo event generator for tens-of-MeV neutrino interactions
|
The MARLEY Event generator. More...
#include <Generator.hh>
Public Member Functions | |
| Generator () | |
| Create a Generator using default settings. | |
| void | add_reaction (std::unique_ptr< marley::Reaction > reaction) |
| Take ownership of a new Reaction. | |
| void | add_state_to_event (HepMC3::GenEvent &ev) const |
| Attach the current random number generator state to the input event as a string attribute. | |
| void | assign_run_info (HepMC3::GenEvent &event) const |
| Associates the owned GenRunInfo object with the input event. | |
| void | clear_reactions () |
| Clear the vector of Reaction objects owned by this Generator. | |
| std::shared_ptr< HepMC3::GenEvent > | create_event (bool attach_state=false) |
| Create an Event using the NeutrinoSource, Target, Reaction, and StructureDatabase objects owned by this Generator. | |
| std::shared_ptr< HepMC3::GenEvent > | create_event (int pdg_a, double KEa, int pdg_atom, const std::array< double, 3 > &dir_vec, bool attach_state=false) |
| Creates an event object for a fixed projectile species, kinetic energy, and atomic target. | |
| double | E_pdf (double E) |
| Probability density function that describes the distribution of reacting neutrino energies. | |
| void | finish_event_metadata (HepMC3::GenEvent &ev, bool attach_state=false) |
| Add final pieces of metadata (e.g., the RNG state) to an otherwise complete event. | |
| double | flux_averaged_total_xs () const |
| Computes the flux-averaged total cross section for all enabled neutrino reactions, taking target atom fractions into account as appropriate. | |
| const std::vector< std::unique_ptr< marley::Reaction > > & | get_reactions () const |
| Get a const reference to the vector of Reaction objects owned by this Generator. | |
| marley::ProjectileDirectionRotator & | get_rotator () |
| Provides access to the owned ProjectileDirectionRotator. | |
| uint_fast64_t | get_seed () const |
| Get the seed used to initialize this Generator. | |
| const marley::NeutrinoSource & | get_source () const |
| Get a const reference to the NeutrinoSource owned by this Generator. | |
| std::string | get_state_string () const |
| Get a string that represents the current internal state of this Generator. | |
| marley::StructureDatabase & | get_structure_db () |
| Get a reference to the StructureDatabase owned by this Generator. | |
| const marley::Target & | get_target () const |
| Get a const reference to the Target owned by this Generator. | |
| marley::Weighter & | get_weighter () |
| Get a non-const reference to the owned Weighter object. | |
| const marley::Weighter & | get_weighter () const |
| Get a const reference to the owned Weighter object. | |
| double | inverse_transform_sample (const marley::InterpolatingFunction &cdf, double xmin, double xmax, double bisection_tolerance=1e-12) |
| Sample from a given 1D cumulative density function cdf(x) on the interval [xmin, xmax] using bisection. | |
| double | inverse_transform_sample (const std::function< double(double)> &f, double xmin, double xmax, double bisection_tolerance=1e-12) |
| Sample from a given 1D probability density function f(x) on the interval [xmin, xmax] using an inverse transform technique. | |
| const std::string & | json_config () const |
| const std::array< double, 3 > & | neutrino_direction () |
| Gets the direction of the incident neutrinos that is used when generating events. | |
| double | rejection_sample (const std::function< double(double)> &f, double xmin, double xmax, double &fmax, double safety_factor=1.01, double max_search_tolerance=DEFAULT_REJECTION_SAMPLING_TOLERANCE_) |
| Sample from a given 1D probability density function f(x) on the interval [xmin, xmax] using a simple rejection method. | |
| void | reseed (uint_fast64_t seed) |
| Reseeds the Generator. | |
| const std::shared_ptr< HepMC3::GenRunInfo > & | run_info () const |
| double | sample_decay_time (double partial_width) |
| Sample a random decay time given a partial decay width. | |
| template<class RandomNumberDistribution> | |
| 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 operator()(std::mt19937_64&) function) @detail This template function is based on https://stackoverflow.com/a/9154394/4081973. | |
| template<class RandomNumberDistribution, typename ParamType> | |
| auto | sample_from_distribution (RandomNumberDistribution &rnd, const ParamType ¶ms) -> decltype(std::declval< RandomNumberDistribution & >().operator()(std::declval< std::mt19937_64 & >(), std::declval< const ParamType & >())) |
| Sample from an arbitrary probability distribution (defined here as any object that implements an operator()(std::mt19937_64&, const ParamType&) function) using the parameters params. | |
| marley::Reaction & | sample_reaction (double &E) |
| Sample a Reaction and an energy for the reacting neutrino. | |
| void | seed_using_state_string (const std::string &state_string) |
| Use a string to set this Generator's internal state. | |
| void | set_do_deexcitations (bool do_them) |
| Sets the value of the do_deexcitations flag. | |
| void | set_neutrino_direction (const std::array< double, 3 > &dir_vec) |
| Sets the direction of the incident neutrinos to use when generating events. | |
| void | set_run_info (const std::shared_ptr< HepMC3::GenRunInfo > &run_info) |
| void | set_source (std::unique_ptr< marley::NeutrinoSource > source) |
| Take ownership of a new NeutrinoSource, replacing any existing source owned by this Generator. | |
| void | set_target (std::unique_ptr< marley::Target > target) |
| Take ownership of a new Target, replacing any existing target owned by this Generator. | |
| void | set_up_run_info () |
| Initializes the owned GenRunInfo object that will be used to associate run metadata with the output events. | |
| void | set_weight_flux (bool should_we_weight) |
| Sets the value of the weight_flux flag. | |
| void | set_weighter (std::shared_ptr< marley::Weighter > w) |
| Replace the owned Weighter object. | |
| double | total_xs (int pdg_a, double KEa) const |
| Computes the abundance-weighted total cross section at fixed energy for all configured reactions. | |
| double | total_xs (int pdg_a, double KEa, int pdg_atom) const |
| Computes the total cross section at fixed energy for all configured reactions involving a particular target atom. | |
| double | uniform_random_double (double min, double max, bool inclusive) |
| Sample a random number uniformly on either [min, max) or [min, max]. | |
Static Public Member Functions | |
| static void | add_state_to_event (HepMC3::GenEvent &ev, const std::string &state) |
| Attach a user-supplied random number generator state string to the input event as a string attribute. | |
The MARLEY Event generator.
Definition at line 54 of file Generator.hh.
| marley::Generator::Generator | ( | ) |
Create a Generator using default settings.
Definition at line 45 of file Generator.cc.
References reseed().
| void marley::Generator::add_reaction | ( | std::unique_ptr< marley::Reaction > | reaction | ) |
Take ownership of a new Reaction.
| reaction | A pointer to the new Reaction to use |
Definition at line 479 of file Generator.cc.
| void marley::Generator::add_state_to_event | ( | HepMC3::GenEvent & | ev | ) | const |
Attach the current random number generator state to the input event as a string attribute.
Definition at line 880 of file Generator.cc.
References add_state_to_event(), and get_state_string().
Referenced by add_state_to_event(), marley::CommandHandler::cmd_generate(), and finish_event_metadata().
|
static |
Attach a user-supplied random number generator state string to the input event as a string attribute.
Definition at line 890 of file Generator.cc.
References HepMC3::GenEvent::add_attribute().
| void marley::Generator::assign_run_info | ( | HepMC3::GenEvent & | event | ) | const |
Associates the owned GenRunInfo object with the input event.
Definition at line 854 of file Generator.cc.
Referenced by finish_event_metadata().
| void marley::Generator::clear_reactions | ( | ) |
Clear the vector of Reaction objects owned by this Generator.
Definition at line 502 of file Generator.cc.
| std::shared_ptr< HepMC3::GenEvent > marley::Generator::create_event | ( | bool | attach_state = false | ) |
Create an Event using the NeutrinoSource, Target, Reaction, and StructureDatabase objects owned by this Generator.
| attach_state | Whether to attach the random number generator state to the event as a string attribute |
Definition at line 77 of file Generator.cc.
References HepMC3::GenEvent::add_attribute(), marley::Reaction::atomic_target(), marley::Reaction::create_event(), finish_event_metadata(), marley::TargetAtom::pdg(), marley::Reaction::pdg_a(), marley::NucleusDecayer::process_event(), sample_reaction(), set_up_run_info(), and marley::Reaction::total_xs().
| std::shared_ptr< HepMC3::GenEvent > marley::Generator::create_event | ( | int | pdg_a, |
| double | KEa, | ||
| int | pdg_atom, | ||
| const std::array< double, 3 > & | dir_vec, | ||
| bool | attach_state = false ) |
Creates an event object for a fixed projectile species, kinetic energy, and atomic target.
If no energetically-accessible reaction is available for the given input parameters, then a marley::Error will be thrown.
| pdg_a | The PDG code for the projectile |
| KEa | The kinetic energy of the projectile (MeV) |
| pdg_atom | The nuclear PDG code for the atomic target |
| dir_vec | Direction three-vector of the projectile |
| attach_state | Whether to attach the random number generator state to the event as a string attribute |
Definition at line 667 of file Generator.cc.
References HepMC3::GenEvent::add_attribute(), finish_event_metadata(), marley::NucleusDecayer::process_event(), marley::ProjectileDirectionRotator::process_event(), set_up_run_info(), and total_xs().
| double marley::Generator::E_pdf | ( | double | E | ) |
Probability density function that describes the distribution of reacting neutrino energies.
This function computes the cross-section weighted neutrino flux (normalized to unity between source_->E_min and source_->E_max) including cross-section contributions from all Reactions owned by this Generator. For the distribution of incident neutrino energies, use marley::NeutrinoSource::pdf()
| E | Total energy of the reacting neutrino |
Definition at line 335 of file Generator.cc.
Referenced by sample_reaction().
| void marley::Generator::finish_event_metadata | ( | HepMC3::GenEvent & | ev, |
| bool | attach_state = false ) |
Add final pieces of metadata (e.g., the RNG state) to an otherwise complete event.
| attach_state | Whether to attach the random number generator state to the event as a string attribute |
Definition at line 827 of file Generator.cc.
References HepMC3::GenEvent::add_attribute(), add_state_to_event(), and assign_run_info().
Referenced by marley::CommandHandler::cmd_decay(), create_event(), and create_event().
| double marley::Generator::flux_averaged_total_xs | ( | ) | const |
Computes the flux-averaged total cross section for all enabled neutrino reactions, taking target atom fractions into account as appropriate.
If flux weighting is disabled (via a call to set_weight_flux()) then this function will return zero
Definition at line 587 of file Generator.cc.
Referenced by set_up_run_info().
|
inline |
Get a const reference to the vector of Reaction objects owned by this Generator.
Definition at line 468 of file Generator.hh.
Referenced by marley::StrengthVariationWeightCalculator::create_instances(), and marley::StrengthVariationWeightCalculator::ensure_initialized().
|
inline |
Provides access to the owned ProjectileDirectionRotator.
Definition at line 287 of file Generator.hh.
|
inline |
Get the seed used to initialize this Generator.
Definition at line 465 of file Generator.hh.
| const marley::NeutrinoSource & marley::Generator::get_source | ( | ) | const |
Get a const reference to the NeutrinoSource owned by this Generator.
Throws a marley::Error if this Generator does not own a NeutrinoSource object.
Definition at line 449 of file Generator.cc.
| std::string marley::Generator::get_state_string | ( | ) | const |
Get a string that represents the current internal state of this Generator.
Definition at line 168 of file Generator.cc.
Referenced by add_state_to_event().
| marley::StructureDatabase & marley::Generator::get_structure_db | ( | ) |
Get a reference to the StructureDatabase owned by this Generator.
Definition at line 510 of file Generator.cc.
Referenced by marley::CommandHandler::cmd_decay(), marley::DiscreteNuclearReaction::create_event(), and marley::NucleusDecayer::process_event().
| const marley::Target & marley::Generator::get_target | ( | ) | const |
Get a const reference to the Target owned by this Generator.
Throws a marley::Error if this Generator does not own a Target object.
Definition at line 455 of file Generator.cc.
|
inline |
Get a non-const reference to the owned Weighter object.
Definition at line 317 of file Generator.hh.
|
inline |
Get a const reference to the owned Weighter object.
Definition at line 313 of file Generator.hh.
| double marley::Generator::inverse_transform_sample | ( | const marley::InterpolatingFunction & | cdf, |
| double | xmin, | ||
| double | xmax, | ||
| double | bisection_tolerance = 1e-12 ) |
Sample from a given 1D cumulative density function cdf(x) on the interval [xmin, xmax] using bisection.
| cdf | Cumulative density function to use for sampling |
| xmin | Lower bound of the sampling interval |
| xmax | Upper bound of the sampling interval |
Definition at line 552 of file Generator.cc.
References marley::InterpolatingFunction::evaluate(), and uniform_random_double().
Referenced by inverse_transform_sample().
| double marley::Generator::inverse_transform_sample | ( | const std::function< double(double)> & | f, |
| double | xmin, | ||
| double | xmax, | ||
| double | bisection_tolerance = 1e-12 ) |
Sample from a given 1D probability density function f(x) on the interval [xmin, xmax] using an inverse transform technique.
| f | Probability density function to use for sampling |
| xmin | Lower bound of the sampling interval |
| xmax | Upper bound of the sampling interval |
Definition at line 536 of file Generator.cc.
References inverse_transform_sample().
|
inline |
Definition at line 290 of file Generator.hh.
|
inline |
Gets the direction of the incident neutrinos that is used when generating events.
Definition at line 470 of file Generator.hh.
| double marley::Generator::rejection_sample | ( | const std::function< double(double)> & | f, |
| double | xmin, | ||
| double | xmax, | ||
| double & | fmax, | ||
| double | safety_factor = 1.01, | ||
| double | max_search_tolerance = DEFAULT_REJECTION_SAMPLING_TOLERANCE_ ) |
Sample from a given 1D probability density function f(x) on the interval [xmin, xmax] using a simple rejection method.
| f | Probability density function to use for sampling |
| xmin | Lower bound of the sampling interval |
| xmax | Upper bound of the sampling interval |
| max_search_tolerance | Tolerance to use when finding the maximum of f(x) using Brent's method |
The rejection method used by this function consists of the following steps:
Note that f(x) does not need to be normalized, but its range must be nonnegative. In the first step, an iterative method (Brent's method) is used to find the maximum of f(x). The iterations will continue until two successive iterations agree within max_search_tolerance on the location of the maximum of f(x). To avoid problems with functions that yield double values that are small compared to a typical value of max_search_tolerance (say, max_search_tolerance = 1e-8, while many neutrino cross sections of interest for MARLEY are less than 1e-40 cm^2), MARLEY normalizes all probability density functions to unity before using rejection sampling.
Definition at line 281 of file Generator.cc.
References uniform_random_double().
Referenced by marley::ElectronReaction::create_event(), marley::DiscreteNuclearReaction::sample_cos_theta_c_cm(), marley::NeutrinoSource::sample_incident_neutrino(), and sample_reaction().
| void marley::Generator::reseed | ( | uint_fast64_t | seed | ) |
Reseeds the Generator.
Definition at line 156 of file Generator.cc.
Referenced by Generator().
|
inline |
Definition at line 292 of file Generator.hh.
| double marley::Generator::sample_decay_time | ( | double | partial_width | ) |
Sample a random decay time given a partial decay width.
| partial_width | Partial decay width (MeV) for the decay process of interest |
Definition at line 859 of file Generator.cc.
References uniform_random_double().
|
inline |
Sample from an arbitrary probability distribution (defined here as any object that implements an operator()(std::mt19937_64&) function) @detail This template function is based on https://stackoverflow.com/a/9154394/4081973.
Definition at line 193 of file Generator.hh.
Referenced by marley::CommandHandler::cmd_decay(), marley::ContinuumNuclearReaction::create_event(), marley::DiscreteNuclearReaction::create_event(), marley::HauserFeshbachDecay::sample_exit_channel(), and marley::Level::sample_gamma().
|
inline |
Sample from an arbitrary probability distribution (defined here as any object that implements an operator()(std::mt19937_64&, const ParamType&) function) using the parameters params.
Definition at line 205 of file Generator.hh.
| marley::Reaction & marley::Generator::sample_reaction | ( | double & | E | ) |
Sample a Reaction and an energy for the reacting neutrino.
| [out] | E | Total energy of the neutrino undergoing the reaction |
Definition at line 390 of file Generator.cc.
References E_pdf(), and rejection_sample().
Referenced by create_event().
| void marley::Generator::seed_using_state_string | ( | const std::string & | state_string | ) |
Use a string to set this Generator's internal state.
This function is typically used to restore a Generator to a state saved using get_state_string().
Definition at line 148 of file Generator.cc.
|
inline |
Sets the value of the do_deexcitations flag.
This should almost always be true. Use only if you know what you are doing.
Definition at line 473 of file Generator.hh.
| void marley::Generator::set_neutrino_direction | ( | const std::array< double, 3 > & | dir_vec | ) |
Sets the direction of the incident neutrinos to use when generating events.
| dir_vec | Vector that points in the direction of the incident neutrinos |
Definition at line 516 of file Generator.cc.
|
inline |
Definition at line 298 of file Generator.hh.
| void marley::Generator::set_source | ( | std::unique_ptr< marley::NeutrinoSource > | source | ) |
Take ownership of a new NeutrinoSource, replacing any existing source owned by this Generator.
| source | A pointer to the new NeutrinoSource to use |
Definition at line 461 of file Generator.cc.
| void marley::Generator::set_target | ( | std::unique_ptr< marley::Target > | target | ) |
Take ownership of a new Target, replacing any existing target owned by this Generator.
| source | A pointer to the new Target to use |
Definition at line 612 of file Generator.cc.
| void marley::Generator::set_up_run_info | ( | ) |
Initializes the owned GenRunInfo object that will be used to associate run metadata with the output events.
Definition at line 769 of file Generator.cc.
References flux_averaged_total_xs().
Referenced by marley::CommandHandler::cmd_decay(), create_event(), and create_event().
| void marley::Generator::set_weight_flux | ( | bool | should_we_weight | ) |
Sets the value of the weight_flux flag.
This is potentially dangerous. Use only if you know what you are doing.
Definition at line 532 of file Generator.cc.
|
inline |
Replace the owned Weighter object.
Definition at line 320 of file Generator.hh.
Referenced by marley::OutputFile::merge_reweight_provenance_weights().
| double marley::Generator::total_xs | ( | int | pdg_a, |
| double | KEa ) const |
Computes the abundance-weighted total cross section at fixed energy for all configured reactions.
Atom fractions in the owned Target are used to perform the weighting by nuclide abundance
| pdg_a | The PDG code for the projectile |
| KEa | The kinetic energy of the projectile (MeV) |
Definition at line 740 of file Generator.cc.
| double marley::Generator::total_xs | ( | int | pdg_a, |
| double | KEa, | ||
| int | pdg_atom ) const |
Computes the total cross section at fixed energy for all configured reactions involving a particular target atom.
Atom fractions in the owned Target are ignored by this function.
| pdg_a | The PDG code for the projectile |
| KEa | The kinetic energy of the projectile (MeV) |
| pdg_atom | The nuclear PDG code for the atomic target |
Definition at line 629 of file Generator.cc.
References total_xs().
Referenced by marley::CommandHandler::cmd_xsec(), create_event(), and total_xs().
| double marley::Generator::uniform_random_double | ( | double | min, |
| double | max, | ||
| bool | inclusive ) |
Sample a random number uniformly on either [min, max) or [min, max].
| min | Lower bound of the sampling interval |
| max | Upper bound of the sampling interval |
| inclusive | Whether the upper bound should be included (true) or excluded (false) from the possible sampling outcomes |
Definition at line 235 of file Generator.cc.
Referenced by marley::CommandHandler::cmd_decay(), marley::ContinuumNuclearReaction::create_event(), marley::DiscreteNuclearReaction::create_event(), marley::ElectronReaction::create_event(), marley::DecayScheme::do_cascade(), inverse_transform_sample(), marley::ExitChannel::prepare_products(), rejection_sample(), and sample_decay_time().