Bayeux  3.4.1
Core Foundation library for SuperNEMO
pdg_particle_tools.h
Go to the documentation of this file.
1 /* Author(s): Francois Mauger <mauger@lpccaen.in2p3.fr>
3  * Creation date: 2015-08-28
4  * Last modified: 2015-08-30
5  *
6  * License:
7  * Copyright 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  * PDF particle code
26  *
27  * History:
28  *
29  */
30 
31 #ifndef GENBB_HELP_PDG_PARTICLE_TOOLS_H
32 #define GENBB_HELP_PDG_PARTICLE_TOOLS_H
33 
34 // Standard library:
35 #include <string>
36 #include <map>
37 
38 // Third party:
39 // - Boost:
40 #include <boost/cstdint.hpp>
41 // - Bayeux/datatools:
42 #include <datatools/properties.h>
43 #include <datatools/exception.h>
44 #include <datatools/i_tree_dump.h>
45 
46 namespace genbb {
47 
48  namespace pdg {
49 
53  {
54  public:
55 
59 
60  // Leptons:
61  ELECTRON = 11,
62  POSITRON = -11,
65  MUON_MINUS = 13,
66  MUON_PLUS = -13,
69  TAU_MINUS = 15,
70  TAU_PLUS = -15,
73 
74  // Bosons:
75  GAMMA = 22,
76 
77  // Monte-Carlo
83 
84  // Mesons:
85  PION_ZERO = 111,
86  PION_PLUS = 211,
87  PION_MINUS = -211,
90  KAON_ZERO = 311,
92  KAON_PLUS = 321,
93  KAON_MINUS = -321,
94  ETA = 221,
95 
96  // Barions:
97  PROTON = 2212,
98  ANTI_PROTON = -2212,
99  NEUTRON = 2112,
100  ANTI_NEUTRON = -2112,
101  LAMBDA = 3122,
102  ANTI_LAMBDA = -3122,
103  SIGMA_PLUS = 3222,
105  SIGMA_ZERO = 3212,
107  SIGMA_MINUS = 3112,
109  XI_ZERO = 3322,
110  ANTI_XI_ZERO = -3322,
111  XI_MINUS = 3312,
112  ANTI_XI_MINUS = -3312,
113  OMEGA_MINUS = 3334,
115 
116  // Ions:
117  DEUTERON = 1000010020,
118  ANTI_DEUTERON = -1000010020,
119  TRITON = 1000010030,
120  ANTI_TRITON = -1000010030,
121  HE3 = 1000020030,
122  ANTI_HE3 = -1000020030,
123  ALPHA = 1000020040,
124  ANTI_ALPHA = -1000020040
125 
126  };
127 
129  particle();
130 
132  particle(int32_t pdg_code_,
133  const std::string & name_,
134  const std::string & latex_repr_);
135 
137  particle(int32_t pdg_code_,
138  const std::string & name_,
139  const std::string & alt_name_,
140  const std::string & latex_repr_);
141 
143  virtual ~particle();
144 
146  bool is_valid() const;
147 
149  void reset();
150 
152  int32_t get_code() const;
153 
155  particle & set_code(int32_t);
156 
158  const std::string & get_name() const;
159 
161  particle & set_name(const std::string &);
162 
164  bool has_alt_name() const;
165 
167  const std::string & get_alt_name() const;
168 
170  particle & set_alt_name(const std::string &);
171 
173  const std::string & get_latex_repr() const;
174 
176  particle & set_latex_repr(const std::string &);
177 
179  const datatools::properties & get_auxiliaries() const;
180 
183 
185  virtual void tree_dump(std::ostream & out_ = std::clog,
186  const std::string & title_ = "",
187  const std::string & indent_ = "",
188  bool inherit_ = false) const;
189 
198  static int32_t build_nuclear_code(int z_, int a_, int i_ = 0);
199 
200  private:
201 
202  int32_t _code_;
203  std::string _name_;
204  std::string _alt_name_;
205  std::string _latex_repr_;
206  datatools::properties _auxiliaries_;
207 
208  };
209 
212  {
213 
214  public:
215 
217  typedef std::map<int32_t, particle> particle_dict_type;
218 
220  particle_registry(uint32_t flags_ = 0);
221 
224 
226  void clear();
227 
229  particle & registration(const particle & part_);
230 
232  void unregistration(const std::string & name_);
233 
235  void unregistration(int32_t pdg_code_);
236 
238  bool has_particle(int32_t pdg_code_) const;
239 
241  const particle & get_particle(int32_t pdg_code_) const;
242 
244  bool has_particle_by_name(const std::string & name_) const;
245 
247  const particle & get_particle_by_name(const std::string & name_) const;
248 
250  virtual void tree_dump(std::ostream & out_ = std::clog,
251  const std::string & title_ = "",
252  const std::string & indent_ = "",
253  bool inherit_ = false) const;
254 
257 
260 
262  static const particle_registry & const_system_registry();
263 
264  private:
265 
266  particle_dict_type _records_;
267 
269  static particle_registry & _access_system_registry_();
270 
271  };
272 
273  } // end of namespace pdg
274 
275 } // end of namespace genbb
276 
277 #endif // GENBB_HELP_PDG_PARTICLE_TOOLS_H
278 
279 // Local Variables: --
280 // mode: c++ --
281 // c-file-style: "gnu" --
282 // tab-width: 2 --
283 // End: --
particle & set_alt_name(const std::string &)
Set the alternative name.
Definition: pdg_particle_tools.h:62
Definition: pdg_particle_tools.h:114
const std::string & get_name() const
Return the name.
virtual void tree_dump(std::ostream &out_=std::clog, const std::string &title_="", const std::string &indent_="", bool inherit_=false) const
Smart print.
Definition: pdg_particle_tools.h:68
Definition: pdg_particle_tools.h:98
Definition: pdg_particle_tools.h:102
void unregistration(const std::string &name_)
Unregistration of a particle record given its name.
Definition: pdg_particle_tools.h:103
void register_standard_particles()
Register standard particles.
Definition: pdg_particle_tools.h:104
particle_code
Supported PDG particle codes.
Definition: pdg_particle_tools.h:57
static const particle_registry & const_system_registry()
Access to the non mutable system singleton registry.
virtual void tree_dump(std::ostream &out_=std::clog, const std::string &title_="", const std::string &indent_="", bool inherit_=false) const
Smart print.
Definition: pdg_particle_tools.h:86
Definition: pdg_particle_tools.h:63
An interface with utilities for printable objects.
Definition: i_tree_dump.h:36
particle()
Default constructor.
Definition: pdg_particle_tools.h:82
particle & registration(const particle &part_)
Registration of a particle record.
Definition: pdg_particle_tools.h:97
bool has_particle_by_name(const std::string &name_) const
Check particle given its name.
Definition: pdg_particle_tools.h:112
Definition: pdg_particle_tools.h:79
Definition: pdg_particle_tools.h:67
void reset()
Reset.
Definition: pdg_particle_tools.h:91
Definition: pdg_particle_tools.h:101
Definition: pdg_particle_tools.h:124
bool has_particle(int32_t pdg_code_) const
Check particle.
Utility macros for exception handling.
Definition: pdg_particle_tools.h:85
Definition: pdg_particle_tools.h:106
Definition: pdg_particle_tools.h:120
Definition: pdg_particle_tools.h:92
particle & set_code(int32_t)
Set the PDG code.
Definition: pdg_particle_tools.h:110
const particle & get_particle_by_name(const std::string &name_) const
Return a registered particle given its name.
Definition: pdg_particle_tools.h:108
particle & set_name(const std::string &)
Set the name.
Definition: pdg_particle_tools.h:119
Invalid PDG code.
Definition: pdg_particle_tools.h:58
std::map< int32_t, particle > particle_dict_type
Type of dictionary of particle records.
Definition: pdg_particle_tools.h:217
Definition: pdg_particle_tools.h:117
Definition: pdg_particle_tools.h:94
virtual ~particle()
Destructor.
Definition: pdg_particle_tools.h:113
static int32_t build_nuclear_code(int z_, int a_, int i_=0)
void clear()
Clear the registry.
Definition: pdg_particle_tools.h:107
bool is_valid() const
Check validity.
Top-level namespace of the Bayeux/genbb_help module library.
Definition: alpha_decay.h:51
Definition: pdg_particle_tools.h:100
int32_t get_code() const
Return the PDG code.
Definition: pdg_particle_tools.h:69
particle_registry(uint32_t flags_=0)
Default constructor.
const particle & get_particle(int32_t pdg_code_) const
Return a registered unit.
Definition: pdg_particle_tools.h:70
datatools::properties & grab_auxiliaries()
Return a mutable reference to the embedded auxiliary properties.
The identification of a particle with its PDG code This follows the scheme from http://pdg....
Definition: pdg_particle_tools.h:52
const std::string & get_alt_name() const
Return the alternative name.
Definition: pdg_particle_tools.h:65
Definition: pdg_particle_tools.h:75
const datatools::properties & get_auxiliaries() const
Return a const reference to the embedded auxiliary properties.
Definition: pdg_particle_tools.h:105
Definition: pdg_particle_tools.h:111
Definition: pdg_particle_tools.h:88
Definition: pdg_particle_tools.h:123
Definition: pdg_particle_tools.h:109
Definition: pdg_particle_tools.h:87
Definition: pdg_particle_tools.h:64
A registry for particle entries.
Definition: pdg_particle_tools.h:211
Definition: pdg_particle_tools.h:66
Definition: pdg_particle_tools.h:78
Definition: pdg_particle_tools.h:99
Definition: pdg_particle_tools.h:72
Definition: pdg_particle_tools.h:89
particle & set_latex_repr(const std::string &)
Set the LaTeX representation.
Definition: pdg_particle_tools.h:122
Definition: pdg_particle_tools.h:90
static particle_registry & system_registry()
Access to the mutable system singleton registry.
Definition: pdg_particle_tools.h:93
const std::string & get_latex_repr() const
Return the LaTeX representation.
Definition: pdg_particle_tools.h:80
bool has_alt_name() const
Check if an alternative name is defined.
Definition: pdg_particle_tools.h:81
Definition: pdg_particle_tools.h:118
Definition: pdg_particle_tools.h:71
Definition: pdg_particle_tools.h:61
Definition: pdg_particle_tools.h:121
A dictionary of arbitrary properties.
Definition: properties.h:125