Bayeux  3.4.1
Core Foundation library for SuperNEMO
primary_particle.h
Go to the documentation of this file.
1 /* Author(s): Francois Mauger <mauger@lpccaen.in2p3.fr>
3  * Creation date: 2010-04-11
4  * Last modified: 2015-06-19
5  *
6  * License:
7  * Copyright 2007-2015 F. Mauger
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 3 of the License, or (at
12  * your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful, but
15  * WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22  *
23  * Description:
24  *
25  * Primary particle for MC generators
26  *
27  */
28 
29 #ifndef GENBB_HELP_PRIMARY_PARTICLE_H
30 #define GENBB_HELP_PRIMARY_PARTICLE_H 1
31 
32 // Standard library:
33 #include <cstdlib>
34 #include <cmath>
35 #include <stdexcept>
36 #include <iostream>
37 #include <sstream>
38 #include <fstream>
39 #include <string>
40 #include <list>
41 
42 // Third party:
43 // - Boost:
44 #include <boost/cstdint.hpp>
45 // - CLHEP:
46 #include <CLHEP/Vector/LorentzVector.h>
47 // - Bayeux/datatools:
48 #include <datatools/properties.h>
49 #include <datatools/utils.h>
50 #include <datatools/units.h>
51 #include <datatools/i_tree_dump.h>
53 // - Bayeux/geomtools:
54 #include <geomtools/utils.h>
55 // - Bayeux/genbb_help:
57 
58 namespace genbb {
59 
64  {
65  public:
66 
68  static const int INVALID_GENERATION_ID = -1;
69 
76  // UNDEF = -1, //!< @deprecated Undefined particle type
79  GAMMA = 1,
80  POSITRON = 2,
81  ELECTRON = 3,
82  NEUTRINO = 4,
83  MUON_PLUS = 5,
85  PION_0 = 7,
86  PION_PLUS = 8,
89  KAON_PLUS = 11,
90  KAON_MINUS = 12,
91  NEUTRON = 13,
92  PROTON = 14,
95  ETA = 17,
96  LAMBDA = 18,
97  SIGMA_PLUS = 19,
98  SIGMA_0 = 20,
100  XI_0 = 22,
101  XI_MINUS = 23,
105  ANTI_SIGMA_MINUS = 27, // BEWARE: same as Geant4 "anti_sigma+"
106  ANTI_SIGMA_0 = 28, // BEWARE: same as Geant4 "anti_sigma0"
107  ANTI_SIGMA_PLUS = 29, // BEWARE: same as Geant4 "anti_sigma-"
108  ANTI_XI_0 = 30, // BEWARE: same as Geant4 "anti_xi0"
109  ANTI_XI_PLUS = 31, // BEWARE: same as Geant4 "anti_xi-"
110  ANTI_OMEGA_PLUS = 32, // BEWARE: same as Geant4 "anti_omega-"
111  DEUTERON = 45,
112  TRITIUM = 46,
113  TRITON = 46,
114  ALPHA = 47,
115  GEANTINO = 48,
116  HE3 = 49,
117  CERENKOV = 50, // Optical photon/scintillation/Cerenkov
118  // Additional codes:
119  NUCLEUS = 1000000000,
120  ION = 1100000000
121  };
122 
125  static const int32_t PDG_CODE_UNDEFINED = 0;
126 
128  static std::string nucleus_to_label(int z_, int a_, double excitation_energy_ = 0.0);
129 
131  static std::string ion_to_label(int z_, int a_, double excitation_energy_ = 0.0, int charge_ = 0);
132 
134  static bool label_to_ion(const std::string label_, int & z_, int & a_, double & excitation_energy_, int & charge_);
135 
137  static bool label_to_nucleus(const std::string label_, int & z_, int & a_, double & excitation_energy_);
138 
140  void reset();
141 
143  bool has_generation_id() const;
144 
146  void set_generation_id(int);
147 
149  void reset_generation_id();
150 
152  int get_generation_id() const;
153 
155  bool has_type() const;
156 
158  int get_type() const;
159 
161  void set_type(int type_);
162 
164  void set_nucleus(int z_, int a_, double excitation_energy_ = 0.0, bool pdg_ = false);
165 
167  void set_ion(int z_, int a_, double excitation_energy_ = 0.0, int charge_ = 0, bool pdg_ = false);
168 
170  void set_neutrino(const std::string & label_);
171 
173  void set_neutrino(const std::string & flavour_, bool antineutrino_);
174 
176  bool has_pdg_code() const;
177 
179  int get_pdg_code() const;
180 
182  void set_pdg_code(int);
183 
185  int fetch_pdg_code() const;
186 
188  bool has_time() const;
189 
191  double get_time() const;
192 
194  double & grab_time();
195 
197  bool needs_particle_label() const;
198 
200  bool has_particle_label() const;
201 
203  const std::string & get_particle_label() const;
204 
206  void set_particle_label(const std::string &);
207 
209  void set_time(double time_);
210 
212  void shift_time(double delta_time_);
213 
215 
223  bool is_valid() const;
224 
226  bool is_unknown() const;
227 
229  bool is_gamma() const;
230 
232  bool is_positron() const;
233 
235  bool is_electron() const;
236 
238  bool is_neutrino() const;
239 
241  bool is_alpha() const;
242 
244  bool is_deuteron() const;
245 
247  bool is_tritium() const;
248 
250  bool is_proton() const;
251 
253  bool is_neutron() const;
254 
256  bool is_muon_plus() const;
257 
259  bool is_muon_minus() const;
260 
262  bool is_pion_plus() const;
263 
265  bool is_pion_minus() const;
266 
268  bool is_pion_zero() const;
269 
271  bool is_nucleus() const;
272 
274  bool is_ion() const;
275 
277  void set_momentum(const geomtools::vector_3d & m_);
278 
280  const geomtools::vector_3d & get_momentum() const;
281 
284 
286  void compute_four_momentum(CLHEP::HepLorentzVector &) const;
287 
289  void set_vertex(const geomtools::vector_3d & v_);
290 
292  const geomtools::vector_3d & get_vertex() const;
293 
296 
298  bool has_vertex() const;
299 
301  void invalidate_vertex();
302 
304  bool charge_is_known() const;
305 
307  double get_charge() const;
308 
310  void set_mass(double);
311 
313  void reset_mass();
314 
316  double get_mass() const;
317 
319  bool mass_is_known() const;
320 
322  double get_total_energy() const;
323 
325  double get_kinetic_energy() const;
326 
328  double get_beta() const;
329 
347  const datatools::properties & get_auxiliaries() const;
348 
351 
354 
356  primary_particle(int32_t a_type,
357  double a_time,
358  const geomtools::vector_3d &);
359 
361  virtual ~primary_particle();
362 
364  virtual void
365  tree_dump(std::ostream & out_ = std::clog,
366  const std::string & title_ = "",
367  const std::string & indent_ = "",
368  bool inherit_ = false) const;
369 
371  void dump(std::ostream & out_ = std::clog,
372  const std::string & a_indent = "") const;
373 
375  static std::string particle_label_from_type(int a_type);
376 
378  static int particle_type_from_label(const std::string & a_label);
379 
380  protected:
381 
383  void _set_defaults();
384 
385  private:
386 
387  int _generation_id_;
388  int32_t _type_;
389  int32_t _pdg_code_;
390  std::string _particle_label_;
391  double _mass_;
392  double _time_;
393  geomtools::vector_3d _momentum_;
394  geomtools::vector_3d _vertex_;
395  datatools::properties _auxiliaries_;
396 
399 
400 
402 
403 
404  DR_CLASS_RTTI()
405 
406  };
407 
408 } // end of namespace genbb
409 
410 #include <boost/serialization/export.hpp>
411 BOOST_CLASS_EXPORT_KEY2(genbb::primary_particle, "genbb::primary_particle")
412 
414 
415 // Activate reflection layer for the genbb::primary_particle class :
417 
418 // Explicit class version:
419 #include <boost/serialization/version.hpp>
420 BOOST_CLASS_VERSION(genbb::primary_particle, 4)
421 
422 #endif // GENBB_HELP_PRIMARY_PARTICLE_H
423 
424 // Local Variables: --
425 // mode: c++ --
426 // End: --
#define DR_CLASS_INIT(Introspectable)
Inform Camp that class Introspectable exists and trigger the automatic registration of dedicated refl...
Definition: reflection_interface.h:149
bool is_neutrino() const
Check if the particle is a neutrino.
static bool label_to_nucleus(const std::string label_, int &z_, int &a_, double &excitation_energy_)
Build the nucleus'characteristics from a label.
Definition: primary_particle.h:102
Definition: primary_particle.h:95
Definition: primary_particle.h:97
Definition: primary_particle.h:81
static std::string particle_label_from_type(int a_type)
Return the label associated to a particle code.
Base abstract class of all serializable (and possibly introspectable) classes.
Definition: i_serializable.h:51
static std::string nucleus_to_label(int z_, int a_, double excitation_energy_=0.0)
Build the label describing a nucleus ion from Z, A, and excitation energy.
static const int INVALID_GENERATION_ID
Invalid generation Id.
Definition: primary_particle.h:68
Definition: primary_particle.h:105
bool is_electron() const
Check if the particle is an electron.
Definition: primary_particle.h:98
bool is_nucleus() const
Check if the particle is an nucleus (not the light ones: p, D, T, He3, He4)
Definition: primary_particle.h:107
void reset_generation_id()
Reset the unique generation Id.
bool is_alpha() const
Check if the particle is an alpha.
Definition: primary_particle.h:82
Definition: primary_particle.h:115
Definition: primary_particle.h:85
bool is_unknown() const
Check if the particle is of unknown type (but possibly valid for a client application)
void dump(std::ostream &out_=std::clog, const std::string &a_indent="") const
Basic print.
void set_vertex(const geomtools::vector_3d &v_)
Set the vertex of the particle (in unit of length)
const geomtools::vector_3d & get_momentum() const
Return the const momentum of the particle (in unit of energy, i.e. p x c)
Definition: primary_particle.h:117
An interface with utilities for printable objects.
Definition: i_tree_dump.h:36
Definition: primary_particle.h:93
#define DATATOOLS_SERIALIZATION_DECLARATION_ADVANCED(ClassName)
Definition: i_serializable.h:371
bool is_pion_minus() const
Check if the particle is pion-.
Definition: primary_particle.h:94
void set_ion(int z_, int a_, double excitation_energy_=0.0, int charge_=0, bool pdg_=false)
Define an ion (or neutral atom)
bool is_gamma() const
Check if the particle is a gamma.
particle_type
Extended Geant3 particle These are historical codes used in GEANT3 and original GENBB/DECAY0 library....
Definition: primary_particle.h:75
bool has_pdg_code() const
Check if the PDG code of the particle is defined.
bool is_tritium() const
Check if the particle is a tritium.
bool has_type() const
Check if the extended Geant3 type of the particle is defined.
void set_particle_label(const std::string &)
Set the identifier label of the particle (for type == PARTICLE_UNKNOWN, NUCLEUS, ION)
Definition: primary_particle.h:108
Definition: primary_particle.h:110
Definition: primary_particle.h:101
int get_type() const
Return the extended Geant3 type of the particle.
double get_total_energy() const
Return the total energy (in unit of energy)
bool is_deuteron() const
Check if the particle is a deuteron.
double get_kinetic_energy() const
Return the kinetic energy (in unit of energy)
double get_time() const
Return the creation time of the particle (in unit of time)
void set_generation_id(int)
Set the unique generation Id.
Definition: primary_particle.h:112
Definition: primary_particle.h:111
primary_particle()
Default constructor.
Definition: primary_particle.h:84
bool is_muon_plus() const
Check if the particle is muon+.
double get_charge() const
Return the charge of the particle (in unit of +e, as a real number)
bool has_vertex() const
Check if the particle has its own vertex.
void _set_defaults()
Set the default values for attributes.
geomtools::vector_3d & grab_momentum()
Return the mutable momentum of the particle (in unit of energy, i.e. p x c)
Definition: primary_particle.h:99
Definition: primary_particle.h:91
bool is_pion_zero() const
Check if the particle is pion0.
int get_generation_id() const
Return the unique generation Id.
static int particle_type_from_label(const std::string &a_label)
Return the particle code associated to a label.
Fully ionized ion (naked nucleus)
Definition: primary_particle.h:119
bool has_time() const
Check if time is defined.
double get_beta() const
Return the relativistic beta coefficient.
virtual void tree_dump(std::ostream &out_=std::clog, const std::string &title_="", const std::string &indent_="", bool inherit_=false) const
Smart print.
virtual ~primary_particle()
Destructor.
void set_neutrino(const std::string &label_)
Define a neutrino.
#define DATATOOLS_SERIALIZATION_EXT_BACKWARD_SERIAL_TAG_DECLARATION(ClassName)
Definition: i_serializable.h:180
Definition: primary_particle.h:79
Definition: primary_particle.h:104
bool is_neutron() const
Check if the particle is a neutron.
void reset()
Reset the full data structure of the particle.
Definition: primary_particle.h:83
void set_mass(double)
Set the mass of the particle (in unit of energy, i.e. m x c2)
Definition: primary_particle.h:90
void shift_time(double delta_time_)
Shift the creation time of the particle (in unit of time)
bool is_pion_plus() const
Check if the particle is pion+.
double get_mass() const
Return the mass of the particle (in unit of energy, i.e. m x c2)
geomtools::vector_3d & grab_vertex()
Return the mutable vertex of the particle (in unit of length)
Definition: primary_particle.h:87
void set_nucleus(int z_, int a_, double excitation_energy_=0.0, bool pdg_=false)
Define a nucleus, possibly in some excited state.
static bool label_to_ion(const std::string label_, int &z_, int &a_, double &excitation_energy_, int &charge_)
Build the ion's characteristics from a label.
bool is_proton() const
Check if the particle is a proton.
Definition: primary_particle.h:113
bool charge_is_known() const
Check if the charge of the particle is known.
Definition: primary_particle.h:92
#define DATATOOLS_SERIALIZATION_BACKWARD_SERIAL_TAG_SUPPORT()
Definition: i_serializable.h:174
void reset_mass()
Reset the mass of the particle.
Top-level namespace of the Bayeux/genbb_help module library.
Definition: alpha_decay.h:51
Definition: primary_particle.h:106
int get_pdg_code() const
Return the PDG code of the particle.
void set_time(double time_)
Set the creation time of the particle (in unit of time)
bool is_muon_minus() const
Check if the particle is minus-.
void set_type(int type_)
Set the extended Geant3 type of the particle and set the corresponding particle label if it is empty.
CLHEP::Hep3Vector vector_3d
Alias for the CLHEP 3D-vector class.
Definition: clhep.h:63
bool is_valid() const
Check if the description of the particle is valid.
Definition: primary_particle.h:86
Definition: primary_particle.h:96
void set_momentum(const geomtools::vector_3d &m_)
Set the momentum of the particle (in unit of energy, i.e. p x c)
const std::string & get_particle_label() const
Return the identifier label of the particle.
Definition: primary_particle.h:103
Definition: primary_particle.h:114
bool is_positron() const
Check if the particle is a positron.
datatools::properties & grab_auxiliaries()
Return a mutable reference to the auxiliary properties.
Undefined particle type.
Definition: primary_particle.h:77
bool is_ion() const
Check if the particle is an ion (not the light ones: p, D, T, He3, He4)
An ion/atom with arbitrary ionization state.
Definition: primary_particle.h:120
Definition: primary_particle.h:109
Definition: primary_particle.h:100
Definition: primary_particle.h:80
const datatools::properties & get_auxiliaries() const
bool has_particle_label() const
Check is the particle has a specific identifier label.
Definition: primary_particle.h:89
Definition: primary_particle.h:116
#define DR_CLASS_RTTI()
Declare Camp RTTI within class declaration.
Definition: reflection_interface.h:46
A valid particle but unknown from the genbb library.
Definition: primary_particle.h:78
bool needs_particle_label() const
Check is the particle should have a specific identifier label because it lacks a type or code.
Definition: primary_particle.h:88
double & grab_time()
Return mutable reference on the creation time of the particle (in unit of time)
A primary particle generated by a Monte Carlo generator process.
Definition: primary_particle.h:61
void invalidate_vertex()
Invalidate the vertex of the particle.
const geomtools::vector_3d & get_vertex() const
Return the const vertex of the particle (in unit of length)
static std::string ion_to_label(int z_, int a_, double excitation_energy_=0.0, int charge_=0)
Build the label describing an charged ion from Z, A, excitation energy and charge.
int fetch_pdg_code() const
Fetch the PDG code from the particle type/label...
void set_pdg_code(int)
Set the PDG code of the particle.
static const int32_t PDG_CODE_UNDEFINED
Definition: primary_particle.h:125
void compute_four_momentum(CLHEP::HepLorentzVector &) const
Compute the associated 4-vector (in unit of energy, i.e. p x c)
bool has_generation_id() const
Check if the particle has an unique generation Id.
bool mass_is_known() const
Check if the mass of the particle is known.
A dictionary of arbitrary properties.
Definition: properties.h:125