Bayeux  3.4.1
Core Foundation library for SuperNEMO
primary_event_bias.h
Go to the documentation of this file.
1 /* Author(s) : Francois Mauger <mauger@lpccaen.in2p3.fr>
3  * Creation date: 2014-11-21
4  * Last modified: 2014-12-17
5  *
6  * License:
7  *
8  * Description:
9  *
10  * An algorithm that implements some biasing techniques at primary event generation
11  *
12  */
13 
14 #ifndef MCTOOLS_BIASING_PRIMARY_EVENT_BIAS_H
15 #define MCTOOLS_BIASING_PRIMARY_EVENT_BIAS_H 1
16 
17 // Standard library:
18 #include <string>
19 #include <map>
20 #include <set>
21 
22 // Third party:
23 // - Bayeux/datatools :
24 #include <datatools/bit_mask.h>
25 #include <datatools/properties.h>
26 #include <datatools/i_tree_dump.h>
27 // - Bayeux/geomtools :
28 #include <geomtools/utils.h>
29 
30 // This project:
32 
33 namespace genbb {
34  // Forward declarations:
35  class primary_event;
36  class primary_particle;
37 }
38 
39 namespace geomtools {
40  // Forward declaration:
41  class manager;
42 }
43 
44 namespace mctools {
45 
46  namespace biasing {
47 
48  // Forward declaration:
49  class primary_generator;
50 
54  {
55  public:
56 
58  static const std::string & killed_event_label();
59 
61  static const std::string & truncated_event_label();
62 
64  static const std::string & normal_event_label();
65 
67  static const std::string & biased_event_status_key();
68 
70  static const std::string & master_particle_flag();
71 
73  static const std::string & dont_track_this_particle_flag();
74 
78  BIAS_NONE = 1,
82  };
83 
87  BES_NORMAL = 1,
90  };
91 
93  struct biasing_info {
94  public:
96  biasing_info();
97 
99  void reset();
100 
102  bool is_normal() const;
103 
105  bool is_truncated() const;
106 
108  bool is_killed() const;
109 
112 
115 
116  public:
118  };
119 
121  struct stat_record
122  {
123  stat_record();
124  void reset();
125  public:
130  };
131 
133  const stat_record & get_stats() const;
134 
136  void reset_stats();
137 
139  bool has_stats_store() const;
140 
142  void set_stats_store(const std::string &);
143 
146  {
148  // std::list<point_of_interest> associated_pois; //!< Associated points of interest
149  };
150 
151  static const int DEFAULT_PARTICLE_RANK = 0;
152  static const int INVALID_PARTICLE_RANK = -1;
153  static const int ANY_PARTICLE_RANK = 0x7FFFFFFF;
154 
156  // typedef std::map<std::string, point_of_interest> poi_dict_type;
157  typedef std::map<std::string, poi_entry_type> poi_dict_type;
158 
161 
163  virtual ~primary_event_bias();
164 
167 
169  bool is_initialized() const;
170 
172  void initialize_simple();
173 
175  void initialize(const datatools::properties & config_);
176 
178  void reset();
179 
182 
185 
187  bool is_using_no_bias() const;
188 
190  bool is_using_master_particle() const;
191 
193  bool is_using_all_particles() const;
194 
196  void add_particle_by_label(const std::string &);
197 
199  void add_particle_by_type(int id_);
200 
201  // /// Add the identifier of the master particle
202  // void add_particle_by_pdg_code(int code_);
203 
205  void set_particle_minimum_energy(double kemin_);
206 
208  void set_particle_maximum_energy(double kemax_);
209 
211  void set_master_particle_rank(int rank_);
212 
215 
217  void set_total_minimum_energy(double);
218 
220  void set_total_maximum_energy(double);
221 
223  void set_mapping_name(const std::string &);
224 
226  const std::string & get_mapping_name() const;
227 
230 
233 
235  void add_point_of_interest(const std::string & poi_name_, const point_of_interest & poi_);
236 
238  bool has_point_of_interest(const std::string & poi_name_) const;
239 
241  const poi_entry_type & get_point_of_interest(const std::string & poi_name_) const;
242 
244  poi_entry_type & grab_point_of_interest(const std::string & poi_name_);
245 
247  void process(const geomtools::vector_3d & vertex_,
248  genbb::primary_event & event_,
249  biasing_info & info_);
250 
252  virtual void tree_dump(std::ostream & out_ = std::clog,
253  const std::string & title_ = "",
254  const std::string & indent_ = "",
255  bool inherit_ = false) const;
256 
258  void draw(const geomtools::vector_3d & vertex_,
259  genbb::primary_event & event_) const;
260 
262  void store_stats();
263 
264  protected:
265 
267  void _set_default();
268 
271  std::vector<genbb::primary_particle *> &) const;
272 
275  const geomtools::vector_3d &) const;
276 
277  private:
278 
279  bool _initialized_;
280  datatools::logger::priority _logging_;
281  const geomtools::manager * _geom_mgr_;
282  std::string _mapping_name_;
283  bias_mode_type _bias_mode_;
284  std::set<int> _particle_types_;
285  double _particle_min_energy_;
286  double _particle_max_energy_;
287  double _total_min_energy_;
288  double _total_max_energy_;
289  int _master_particle_rank_;
290  bool _track_only_master_particle_;
291  poi_dict_type _pois_;
292  stat_record _stats_;
293  std::string _stats_store_;
294 
295  };
296 
297  } // namespace biasing
298 
299 } // namespace mctools
300 
302 #include <datatools/ocd_macros.h>
304 
305 #endif // MCTOOLS_BIASING_PRIMARY_EVENT_BIAS_H
306 
307 // Local Variables: --
308 // mode: c++ --
309 // c-file-style: "gnu" --
310 // tab-width: 2 --
311 // End: --
static const std::string & master_particle_flag()
Return the property flag to tag the master particle.
priority
Priority levels for logging from most to least critical.
Definition: logger.h:82
void store_stats()
Saev the statistics record.
void process(const geomtools::vector_3d &vertex_, genbb::primary_event &event_, biasing_info &info_)
Bias the primary event.
bool is_truncated() const
Check truncated status.
Definition: base_step_hit.h:32
void initialize(const datatools::properties &config_)
Initialization.
const poi_entry_type & get_point_of_interest(const std::string &poi_name_) const
Return a non mutable reference to a point of interest.
void add_point_of_interest(const std::string &poi_name_, const point_of_interest &poi_)
Add a point of interest.
void set_mapping_name(const std::string &)
Set the mapping name.
bool is_normal() const
Check normal status.
An interface with utilities for printable objects.
Definition: i_tree_dump.h:36
bias_mode_type
Biasing modes.
Definition: primary_event_bias.h:76
void _make_candidate_particles(genbb::primary_event &, std::vector< genbb::primary_particle * > &) const
Build the list of candidate primary particles.
Bias based on some criteria applied to all candidate particles in the event.
Definition: primary_event_bias.h:80
int normal_counts
Definition: primary_event_bias.h:129
void set_particle_maximum_energy(double kemax_)
Set the maximum kinetic energy of the master particle.
biased_event_status _status_
Biasing status associated to the event.
Definition: primary_event_bias.h:117
virtual void tree_dump(std::ostream &out_=std::clog, const std::string &title_="", const std::string &indent_="", bool inherit_=false) const
Smart print.
Undefined status.
Definition: primary_event_bias.h:86
void reset_stats()
Reset the embedded statistics record.
Bias based on some criteria applied only to the master particle in the event.
Definition: primary_event_bias.h:79
Normal status (event is preserved as is and tracked)
Definition: primary_event_bias.h:87
void add_particle_by_label(const std::string &)
Add the identifier of the master particle.
bool is_initialized() const
Check initialization flag.
point_of_interest poi
Point of interest.
Definition: primary_event_bias.h:147
static const std::string & truncated_event_label()
Return the label for a truncated event (some particles are not tracked)
void set_geometry_manager(const geomtools::manager &)
Set the geometry manager.
void set_track_only_master_particle(bool)
Set the track only flag of the master particle.
void draw(const geomtools::vector_3d &vertex_, genbb::primary_event &event_) const
Draw.
bool has_point_of_interest(const std::string &poi_name_) const
Check point of interest.
Default bias mode.
Definition: primary_event_bias.h:81
poi_entry_type & grab_point_of_interest(const std::string &poi_name_)
Return a mutable reference to a point of interest.
std::map< std::string, poi_entry_type > poi_dict_type
Dictionary of points of interest.
Definition: primary_event_bias.h:157
void set_bias_mode(bias_mode_type)
Set the bias mode.
void set_stats_store(const std::string &)
Set the filename of a file used to record statistics record.
int truncated_counts
Definition: primary_event_bias.h:128
static const int INVALID_PARTICLE_RANK
Definition: primary_event_bias.h:152
static const std::string & killed_event_label()
Return the label for a killed event (not tracked at all)
int total_counts
Definition: primary_event_bias.h:126
DOCD_CLASS_DECLARATION(my::algo)
Declaration of the OCD support for the my::algo class.
bool _validate_particle_direction(const genbb::primary_particle &, const geomtools::vector_3d &) const
Validate a particle with respect to its direction and the list of PoIs.
const stat_record & get_stats() const
Return the embedded statistics record.
primary_event_bias()
Default constructor.
void set_total_maximum_energy(double)
Set the total maximum kinetic energy.
static const int ANY_PARTICLE_RANK
Definition: primary_event_bias.h:153
bool is_using_master_particle() const
Check mode for using a master particle.
const std::string & get_mapping_name() const
Return the mapping name.
void _set_default()
Set default attribute values.
bool is_using_all_particles() const
Check mode for using all particles.
static const std::string & normal_event_label()
Return the label for a normal event (all particles are tracked)
Top-level namespace of the Bayeux/genbb_help module library.
Definition: alpha_decay.h:51
biased_event_status
Status of a biased primary event.
Definition: primary_event_bias.h:85
bool has_stats_store() const
Check if a store file is used to record statistics record.
virtual ~primary_event_bias()
Destructor.
No bias.
Definition: primary_event_bias.h:78
static const int DEFAULT_PARTICLE_RANK
Definition: primary_event_bias.h:151
void set_particle_minimum_energy(double kemin_)
Set the minimum kinetic energy of the master particle.
CLHEP::Hep3Vector vector_3d
Alias for the CLHEP 3D-vector class.
Definition: clhep.h:63
A point of interest (POI) in the geometry.
Definition: point_of_interest.h:73
Biasing algorithm used at primary event generation.
Definition: primary_event_bias.h:52
Event should be killed (not tracked at all)
Definition: primary_event_bias.h:89
bool is_killed() const
Check killed status.
A primary event from a Monte-Carlo generator.
Definition: primary_event.h:60
Geometry manager for virtual geometry modelling. Main geometry manager for the modelisation of variou...
Definition: manager.h:70
void add_particle_by_type(int id_)
Add the identifier of the master particle.
datatools::logger::priority get_logging() const
Return the logging priority threshold.
static const std::string & biased_event_status_key()
Return the property key for a normal event.
bool is_using_no_bias() const
Check no bias mode.
Normal status (event is preserved but some particles are not tracked)
Definition: primary_event_bias.h:88
void set_total_minimum_energy(double)
Set the total minimum kinetic energy.
Dictionary of points of interest.
Definition: primary_event_bias.h:145
int killed_counts
Definition: primary_event_bias.h:127
void initialize_simple()
Initialization.
Biasing information associated to a biased primary event.
Definition: primary_event_bias.h:93
bias_mode_type get_bias_mode() const
Return the bias mode.
void set_logging(datatools::logger::priority)
Set the logging priority threshold.
void set_master_particle_rank(int rank_)
Set the rank of the master particle.
Undefined bias.
Definition: primary_event_bias.h:77
void set_status(biased_event_status)
Set the status.
A primary particle generated by a Monte Carlo generator process.
Definition: primary_particle.h:61
Record counters.
Definition: primary_event_bias.h:121
static const std::string & dont_track_this_particle_flag()
Return the property flag to skip the tracking of a particle.
biased_event_status get_status() const
Return the status.
Top-level namespace of the Bayeux/geomtools module library.
Definition: electromagnetic_field_manager.h:39
A dictionary of arbitrary properties.
Definition: properties.h:125