MARLEY (Model of Argon Reaction Low Energy Yields)
v1.2.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. More... | |
void | clear_reactions () |
Clear the vector of Reaction objects owned by this Generator. | |
marley::Event | create_event () |
Create an Event using the NeutrinoSource, Target, Reaction, and StructureDatabase objects owned by this Generator. | |
marley::Event | create_event (int pdg_a, double KEa, int pdg_atom, const std::array< double, 3 > &dir_vec) |
Creates an event object for a fixed projectile species, kinetic energy, and atomic target. More... | |
double | E_pdf (double E) |
Probability density function that describes the distribution of reacting neutrino energies. More... | |
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. More... | |
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. More... | |
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. More... | |
double | inverse_transform_sample (const marley::ChebyshevInterpolatingFunction &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. More... | |
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. More... | |
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. More... | |
void | reseed (uint_fast64_t seed) |
Reseeds the Generator. | |
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. More... | |
void | seed_using_state_string (const std::string &state_string) |
Use a string to set this Generator's internal state. More... | |
void | set_do_deexcitations (bool do_them) |
Sets the value of the do_deexcitations flag. More... | |
void | set_neutrino_direction (const std::array< double, 3 > &dir_vec) |
Sets the direction of the incident neutrinos to use when generating events. More... | |
void | set_source (std::unique_ptr< marley::NeutrinoSource > source) |
Take ownership of a new NeutrinoSource, replacing any existing source owned by this Generator. More... | |
void | set_target (std::unique_ptr< marley::Target > target) |
Take ownership of a new Target, replacing any existing target owned by this Generator. More... | |
void | set_weight_flux (bool should_we_weight) |
Sets the value of the weight_flux flag. More... | |
double | total_xs (int pdg_a, double KEa) const |
Computes the abundance-weighted total cross section at fixed energy for all configured reactions. More... | |
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. More... | |
double | uniform_random_double (double min, double max, bool inclusive) |
Sample a random number uniformly on either [min, max) or [min, max]. More... | |
The MARLEY Event generator.
void marley::Generator::add_reaction | ( | std::unique_ptr< marley::Reaction > | reaction | ) |
marley::Event marley::Generator::create_event | ( | int | pdg_a, |
double | KEa, | ||
int | pdg_atom, | ||
const std::array< double, 3 > & | dir_vec | ||
) |
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 |
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 |
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
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.
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.
double marley::Generator::inverse_transform_sample | ( | const marley::ChebyshevInterpolatingFunction & | 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 |
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 |
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.
marley::Reaction & marley::Generator::sample_reaction | ( | double & | E | ) |
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().
|
inline |
Sets the value of the do_deexcitations flag.
This should almost always be true. Use only if you know what you are doing.
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 |
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 |
void marley::Generator::set_target | ( | std::unique_ptr< marley::Target > | target | ) |
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.
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) |
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 |
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 |