24 #include "marley/GammaStrengthFunctionModel.hh"
25 #include "marley/NeutrinoSource.hh"
26 #include "marley/NuclearReaction.hh"
27 #include "marley/LevelDensityModel.hh"
28 #include "marley/OpticalModel.hh"
29 #include "marley/Parity.hh"
30 #include "marley/ProjectileDirectionRotator.hh"
31 #include "marley/RotationMatrix.hh"
32 #include "marley/StructureDatabase.hh"
33 #include "marley/Target.hh"
34 #include "marley/marley_utils.hh"
38 class ChebyshevInterpolatingFunction;
58 inline uint_fast64_t
get_seed()
const;
61 void reseed(uint_fast64_t seed);
90 double xmin,
double xmax,
double& fmax,
double safety_factor = 1.01,
91 double max_search_tolerance = DEFAULT_REJECTION_SAMPLING_TOLERANCE_);
101 double xmin,
double xmax,
double bisection_tolerance = 1e-12);
110 double xmin,
double xmax,
double bisection_tolerance = 1e-12);
118 inline const std::vector< std::unique_ptr<marley::Reaction> >&
123 void add_reaction(std::unique_ptr<marley::Reaction> reaction);
142 double E_pdf(
double E);
153 void set_source(std::unique_ptr<marley::NeutrinoSource> source);
158 void set_target(std::unique_ptr<marley::Target> target);
171 template <
class RandomNumberDistribution>
173 -> decltype( std::declval<RandomNumberDistribution&>().
operator()(
174 std::declval<std::mt19937_64&>()) )
176 return rnd(rand_gen_);
183 template <
class RandomNumberDistribution,
typename ParamType>
185 const ParamType& params) -> decltype(
186 std::declval<RandomNumberDistribution&>().
operator()(
187 std::declval<std::mt19937_64&>(), std::declval<const ParamType&>() ) )
189 return rnd(rand_gen_, params);
234 double total_xs(
int pdg_a,
double KEa,
int pdg_atom)
const;
247 double total_xs(
int pdg_a,
double KEa)
const;
261 const std::array<double, 3>& dir_vec );
276 void normalize_E_pdf();
286 std::mt19937_64 rand_gen_;
289 static constexpr
double DEFAULT_REJECTION_SAMPLING_TOLERANCE_ = 1e-8;
295 std::unique_ptr<marley::NeutrinoSource> source_;
299 std::unique_ptr<marley::Target> target_;
303 std::unique_ptr<marley::StructureDatabase> structure_db_;
306 std::vector< std::unique_ptr<marley::Reaction> > reactions_;
312 std::vector<double> total_xs_values_;
315 std::discrete_distribution<size_t> r_index_dist_;
321 bool weight_flux_ =
true;
334 double E_PDF_MAX_DEFAULT_ = marley_utils::UNKNOWN_MAX;
340 inline void set_default_E_pdf_max(
double def_max ) {
341 E_PDF_MAX_DEFAULT_ = def_max;
347 bool dont_normalize_E_pdf_ =
false;
357 bool do_deexcitations_ =
true;
378 double total_xs(
int pdg_a,
double KEa,
int pdg_atom,
379 std::vector<size_t>* index_vec, std::vector<double>* xsec_vec)
const;
385 inline const std::vector<std::unique_ptr<marley::Reaction> >&
389 {
return rotator_.projectile_direction(); }
392 { do_deexcitations_ = do_them; }
Approximate representation of a 1D continuous function.
Definition: ChebyshevInterpolatingFunction.hh:29
Container for ingoing and outgoing momentum 4-vectors from a reaction.
Definition: Event.hh:66
The MARLEY Event generator.
Definition: Generator.hh:42
uint_fast64_t get_seed() const
Get the seed used to initialize this Generator.
Definition: Generator.hh:383
marley::Event create_event()
Create an Event using the NeutrinoSource, Target, Reaction, and StructureDatabase objects owned by th...
Definition: Generator.cc:67
const std::array< double, 3 > & neutrino_direction()
Gets the direction of the incident neutrinos that is used when generating events.
Definition: Generator.hh:388
void clear_reactions()
Clear the vector of Reaction objects owned by this Generator.
Definition: Generator.cc:428
void set_source(std::unique_ptr< marley::NeutrinoSource > source)
Take ownership of a new NeutrinoSource, replacing any existing source owned by this Generator.
Definition: Generator.cc:388
double uniform_random_double(double min, double max, bool inclusive)
Sample a random number uniformly on either [min, max) or [min, max].
Definition: Generator.cc:173
marley::StructureDatabase & get_structure_db()
Get a reference to the StructureDatabase owned by this Generator.
Definition: Generator.cc:436
const marley::NeutrinoSource & get_source() const
Get a const reference to the NeutrinoSource owned by this Generator.
Definition: Generator.cc:376
double E_pdf(double E)
Probability density function that describes the distribution of reacting neutrino energies.
Definition: Generator.cc:267
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 bisectio...
Definition: Generator.cc:478
void seed_using_state_string(const std::string &state_string)
Use a string to set this Generator's internal state.
Definition: Generator.cc:91
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 ...
Definition: Generator.cc:555
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 ...
Definition: Generator.cc:219
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 oper...
Definition: Generator.hh:184
void set_weight_flux(bool should_we_weight)
Sets the value of the weight_flux flag.
Definition: Generator.cc:458
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.
Definition: Generator.hh:386
void reseed(uint_fast64_t seed)
Reseeds the Generator.
Definition: Generator.cc:99
Generator()
Create a Generator using default settings.
Definition: Generator.cc:35
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:172
marley::Reaction & sample_reaction(double &E)
Sample a Reaction and an energy for the reacting neutrino.
Definition: Generator.cc:322
marley::ProjectileDirectionRotator & get_rotator()
Provides access to the owned ProjectileDirectionRotator.
Definition: Generator.hh:264
void set_target(std::unique_ptr< marley::Target > target)
Take ownership of a new Target, replacing any existing target owned by this Generator.
Definition: Generator.cc:538
double flux_averaged_total_xs() const
Computes the flux-averaged total cross section for all enabled neutrino reactions,...
Definition: Generator.cc:513
void add_reaction(std::unique_ptr< marley::Reaction > reaction)
Take ownership of a new Reaction.
Definition: Generator.cc:406
const marley::Target & get_target() const
Get a const reference to the Target owned by this Generator.
Definition: Generator.cc:382
void set_neutrino_direction(const std::array< double, 3 > &dir_vec)
Sets the direction of the incident neutrinos to use when generating events.
Definition: Generator.cc:442
std::string get_state_string() const
Get a string that represents the current internal state of this Generator.
Definition: Generator.cc:110
void set_do_deexcitations(bool do_them)
Sets the value of the do_deexcitations flag.
Definition: Generator.hh:391
Definition: JSONConfig.hh:29
Abstract base class for all objects that describe the incident neutrino energy distribution.
Definition: NeutrinoSource.hh:38
If needed, rotates the coordinate system of an Event so that the projectile 3-momentum lies along a d...
Definition: ProjectileDirectionRotator.hh:27
Abstract base class that represents a two-two scattering reaction.
Definition: Reaction.hh:38
Container for nuclear structure information organized by nuclide.
Definition: StructureDatabase.hh:39
Description of a macroscopic target for scattering reactions.
Definition: Target.hh:32