Bayeux  3.4.1
Core Foundation library for SuperNEMO
single_particle_generator.h
Go to the documentation of this file.
1 /* Author(s) : Francois Mauger <mauger@lpccaen.in2p3.fr>
3  * Arnaud Chapon <chapon@lpccaen.in2p3.fr>
4  * Creation date: 2010-10-03
5  * Last modified: 2014-10-20
6  *
7  * License:
8  * Copyright 2007-2014 F. Mauger
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 3 of the License, or (at
13  * your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful, but
16  * WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  * General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor,
23  * Boston, MA 02110-1301, USA.
24  *
25  * Description:
26  *
27  * A generator of GENBB-like event with a single particle
28  *
29  * History:
30  *
31  */
32 
33 #ifndef GENBB_HELP_SINGLE_PARTICLE_GENERATOR_H
34 #define GENBB_HELP_SINGLE_PARTICLE_GENERATOR_H 1
35 
36 // Standard library:
37 #include <string>
38 
39 // Third party:
40 // - Boost:
41 #include <boost/scoped_ptr.hpp>
42 // - Bayeux/datatools:
43 #include <datatools/properties.h>
44 #include <datatools/units.h>
45 // - Bayeux/mygsl:
46 #include <mygsl/rng.h>
49 #include <mygsl/histogram.h>
50 // - Bayeux/geomtools:
51 #include <geomtools/utils.h>
52 
53 // This project:
54 #include <genbb_help/i_genbb.h>
55 
56 namespace genbb {
57 
60  {
61  public:
62 
63  enum mode_type {
71  };
72 
76  };
77 
83  };
84 
85  struct ion_data_type {
86  int Z;
87  int A;
88  double Estar;
89  int Q;
90  };
91 
93  std::string flavour;
94  bool antineutrino;
95  };
96 
98  double energy;
99  double probability;
101  };
102 
103  public:
104 
105  void set_direction_mode(int);
106  int get_direction_mode() const;
107  bool is_randomized_direction() const;
108  void set_randomized_direction(bool);
109  bool is_cone_direction() const;
110  void set_cone_direction(bool);
111  void set_cone_max_angle(double);
112  double get_cone_max_angle() const;
113  void set_cone_min_angle(double);
114  double get_cone_min_angle() const;
115  void set_cone_axis(const geomtools::vector_3d & axis_);
116  void set_z_direction(bool);
117  bool is_z_direction() const;
118  const geomtools::vector_3d & get_cone_axis() const;
119 
120  const std::string & get_particle_name() const;
121  void set_particle_name(const std::string &);
122  double get_particle_mass() const;
123  void set_particle_mass(double);
124 
125  virtual bool can_external_random() const;
126  const mygsl::rng & get_random() const;
128 
129  int get_mode() const;
130  void set_mode(int);
131  bool is_mode_valid() const;
132  bool is_mode_monokinetic() const;
133  bool is_mode_gaussian_energy() const;
134  bool is_mode_energy_range() const;
135  bool is_mode_multi_rays() const;
136  bool is_mode_spectrum() const;
137 
138  double get_mean_energy() const;
139  double get_sigma_energy() const;
140  void set_mean_energy(double mean_, double sigma_ = 0.0);
141 
142  double get_min_energy() const;
143  double get_max_energy() const;
144  void set_energy_range(double min_, double max_);
145 
146  // void set_energy_list(const std::vector<double> en_);
147  // void set_probability_list(const std::vector<double> prob_);
148  void add_multi_ray(double energy_, double prob_);
149 
150 
151  void set_energy_spectrum_filename(const std::string & filename_);
152 
155 
157  virtual ~single_particle_generator();
158 
160  virtual void initialize(const datatools::properties & setup_,
161  datatools::service_manager & service_manager_,
162  detail::pg_dict_type & dictionary_);
163 
165  virtual void reset();
166 
168  virtual bool has_next();
169 
171  virtual bool is_initialized() const;
172 
173  static double get_particle_mass_from_label(const std::string & particle_name_);
174 
175  static bool particle_name_is_valid(const std::string & particle_name_);
176 
177  protected:
178 
180  virtual void _load_next(primary_event & event_,
181  bool compute_classification_ = true);
182 
184  void _init_energy_spectrum();
185 
187  void _init_energy_histo_pdf();
188 
190  void _set_defaults();
191 
192  private:
193 
194  void _at_init_();
195 
196  void _at_reset_();
197 
198  private:
199 
200  bool _initialized_;
201  int _particle_type_;
202  std::string _particle_name_;
203  boost::scoped_ptr<ion_data_type> _ion_data_;
204  boost::scoped_ptr<neutrino_data_type> _neutrino_data_;
205  double _particle_mass_;
206  int _mode_;
207  double _mean_energy_;
208  double _sigma_energy_;
209  double _min_energy_;
210  double _max_energy_;
211 
212  std::vector<multi_rays_record_type> _multi_rays_records_;
213 
214  int _spectrum_mode_;
215  std::string _spectrum_interpolation_name_;
216  std::string _energy_spectrum_filename_;
217  mygsl::tabulated_function _energy_spectrum_;
219  mygsl::histogram _energy_histo_;
220  mygsl::histogram::pdf _energy_histo_pdf_;
221 
222  int _direction_mode_;
223  double _cone_max_angle_;
224  double _cone_min_angle_;
225  geomtools::vector_3d _cone_axis_;
226  unsigned long _seed_;
227  boost::scoped_ptr<mygsl::rng> _random_;
228 
230 
231  };
232 
233 } // end of namespace genbb
234 
235 /***************
236  * OCD support *
237  ***************/
238 #include <datatools/ocd_macros.h>
240 
241 #endif // GENBB_HELP_SINGLE_PARTICLE_GENERATOR_H
242 
243 // Local Variables: --
244 // mode: c++ --
245 // End: --
virtual void _load_next(primary_event &event_, bool compute_classification_=true)
Shoot the primary event.
Definition: single_particle_generator.h:79
Definition: single_particle_generator.h:69
static bool particle_name_is_valid(const std::string &particle_name_)
void set_mean_energy(double mean_, double sigma_=0.0)
Definition: single_particle_generator.h:68
GENBB particle generator abstract base class.
Definition: i_genbb.h:59
static double get_particle_mass_from_label(const std::string &particle_name_)
Definition: single_particle_generator.h:97
Definition: single_particle_generator.h:65
const std::string & get_particle_name() const
virtual void reset()
Reset.
virtual void initialize(const datatools::properties &setup_, datatools::service_manager &service_manager_, detail::pg_dict_type &dictionary_)
Main initialization interface method.
double probability
Probability of the ray.
Definition: single_particle_generator.h:99
int Z
Atomic number.
Definition: single_particle_generator.h:86
Tabulated function.
Definition: tabulated_function.h:34
Definition: single_particle_generator.h:74
std::string flavour
Neutrino flavour ("electron", "muon", "tau")
Definition: single_particle_generator.h:93
int Q
Ion charge.
Definition: single_particle_generator.h:89
void add_multi_ray(double energy_, double prob_)
Definition: single_particle_generator.h:92
DOCD_CLASS_DECLARATION(my::algo)
Declaration of the OCD support for the my::algo class.
Definition: single_particle_generator.h:85
void _set_defaults()
Set default attributes' values.
bool antineutrino
Neutrino/antineutrino flag.
Definition: single_particle_generator.h:94
virtual bool is_initialized() const
Check initialization status.
void _init_energy_spectrum()
Insitialize the energy spectrum.
virtual bool can_external_random() const
Check if the generator accepts an external PRNG.
Definition: single_particle_generator.h:75
Definition: single_particle_generator.h:81
#define GENBB_PG_REGISTRATION_INTERFACE(GENBB_CLASS_NAME)
Definition: genbb_macros.h:22
Definition: single_particle_generator.h:64
Definition: single_particle_generator.h:66
Definition: single_particle_generator.h:80
const mygsl::rng & get_random() const
double Estar
Excitation energy.
Definition: single_particle_generator.h:88
Top-level namespace of the Bayeux/genbb_help module library.
Definition: alpha_decay.h:51
spectrum_mode_type
Definition: single_particle_generator.h:73
One dimensional histogram.
Definition: histogram.h:30
Definition: single_particle_generator.h:67
CLHEP::Hep3Vector vector_3d
Alias for the CLHEP 3D-vector class.
Definition: clhep.h:63
int A
Number of nucleons.
Definition: single_particle_generator.h:87
void set_particle_name(const std::string &)
Generator for single particles with some special kinematics.
Definition: single_particle_generator.h:59
double energy
Monokinetic energy of the ray.
Definition: single_particle_generator.h:98
PDF associated to a one dimensional histogram.
Definition: histogram.h:252
A primary event from a Monte-Carlo generator.
Definition: primary_event.h:60
double cumul_probability
Cumulative probability.
Definition: single_particle_generator.h:100
Definition: single_particle_generator.h:70
void set_cone_axis(const geomtools::vector_3d &axis_)
direction_mode_type
Definition: single_particle_generator.h:78
const geomtools::vector_3d & get_cone_axis() const
Definition: single_particle_generator.h:82
void set_energy_range(double min_, double max_)
std::map< std::string, pg_entry_type > pg_dict_type
Definition: pg_tools.h:134
Von Neumann's rejection method for one dimensional PDF.
Definition: von_neumann_method.h:31
virtual ~single_particle_generator()
Destructor.
void _init_energy_histo_pdf()
Insitialize the energy PDF from an histogram.
Service management class.
Definition: service_manager.h:57
virtual bool has_next()
Check if a next primary event is available.
Pseudo random number generator.
Definition: rng.h:53
void set_energy_spectrum_filename(const std::string &filename_)
mode_type
Definition: single_particle_generator.h:63
A dictionary of arbitrary properties.
Definition: properties.h:125