Hammer  1.0.0
Helicity Amplitude Module for Matrix Element Reweighting
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Pdg.hh
Go to the documentation of this file.
1 ///
2 /// @file Pdg.hh
3 /// @brief Hammer particle data class
4 ///
5 
6 //**** This file is a part of the HAMMER library
7 //**** Copyright (C) 2016 - 2020 The HAMMER Collaboration
8 //**** HAMMER is licensed under version 3 of the GPL; see COPYING for details
9 //**** Please note the MCnet academic guidelines; see GUIDELINES for details
10 
11 // -*- C++ -*-
12 #ifndef HAMMER_TOOLS_PDG
13 #define HAMMER_TOOLS_PDG
14 
15 #include <map>
16 #include <string>
17 #include <tuple>
18 #include <utility>
19 #include <vector>
20 
21 #include "Hammer/Tools/Pdg.fhh"
22 #include "Hammer/IndexTypes.hh"
23 
24 namespace Hammer {
25 
26  /// @brief Hammer class for dealing with particle data
27  ///
28  /// Provides PDG code information retrieval, particle masses and properties.
29  /// Organized as a singleton accessed by the `instance()` method
30  ///
31  /// @ingroup Tools
32  class PID {
33 
34  private:
35  PID();
36 
37  PID(const PID&) = delete;
38  PID& operator=(const PID&) = delete;
39  PID(PID&&) = delete;
40  PID& operator=(PID&&) = delete;
41  ~PID();
42 
43  public:
44  /// @brief convert a particle name to its PDG code.
45  /// if the name corresponds to a set of particles (e.g. "D*"),
46  /// the first is returned
47  /// @param[in] name the particle name, see the code for a list of names
48  PdgId toPdgCode(const std::string& name) const;
49 
50  /// @brief return a list of PDG codes corresponding to a particle name
51  /// E.g. "D*" returns the PDG codes for \f$ D^{*0}, D^{*+} \f$ and their conjugates
52  /// while "Pi0" returns a list with only one PDG code
53  /// @param[in] name the particle name, see the code for a list of names
54  std::vector<PdgId> toPdgList(const std::string& name) const;
55 
56  /// @brief particle mass from a PDG code
57  /// @param[in] id the PDG code
58  double getMass(PdgId id) const;
59 
60  /// @brief particle mass from a particle name
61  /// @param[in] name the particle name, see the code for a list of names
62  double getMass(const std::string& name) const;
63 
64  /// @brief set the particle mass by PDG code
65  /// @param[in] id the PDG code
66  /// @param[in] value the mass
67  void setMass(PdgId id, double value);
68 
69  /// @brief set the particle mass by particle name
70  /// @param[in] name the particle name, see the code for a list of names
71  /// @param[in] value the mass
72  void setMass(const std::string& name, double value);
73 
74  /// @brief particle width from a PDG code
75  /// @param[in] id the PDG code
76  double getWidth(PdgId id) const;
77 
78  /// @brief particle width from a particle name
79  /// @param[in] name the particle name, see the code for a list of names
80  double getWidth(const std::string& name) const;
81 
82  /// @brief set the particle width by PDG code
83  /// @param[in] id the PDG code
84  /// @param[in] value the width
85  void setWidth(PdgId id, double value);
86 
87  /// @brief set the particle width by particle name
88  /// @param[in] name the particle name, see the code for a list of names
89  /// @param[in] value the width
90  void setWidth(const std::string& name, double value);
91 
92  /// @brief return \f$ 2s+1 \f$ where s is the particle spin from a PDG code
93  /// @param[in] id the PDG code
94  size_t getSpinMultiplicity(PdgId id) const;
95 
96  /// @brief return \f$ 2s+1 \f$ where s is the particle spin from a particle name
97  /// @param[in] name the particle name, see the code for a list of names
98  size_t getSpinMultiplicity(const std::string& name) const;
99 
100  /// @brief return \f$ \prod_i (2s_i+1) \f$ where \f$ s_i \f$ is the spin of particle i
101  /// from a list of particle PDG codes
102  /// @param[in] ids the PDG codes
103  size_t getSpinMultiplicities(const std::vector<PdgId>& ids) const;
104 
105  /// @brief return \f$ \prod_i (2s_i+1) \f$ where \f$ s_i \f$ is the spin of particle i
106  /// from a list of particle names
107  /// @param[in] names the names
108  size_t getSpinMultiplicities(const std::vector<std::string>& names) const;
109 
110  /// @brief return \f$ 3*q \f$ where q is the particle electric charge from a PDG code
111  /// @param[in] id the PDG code
112  int getThreeCharge(PdgId id) const;
113 
114  /// @brief return 3 times the total electric charge from a list of particle PDG codes
115  /// @param[in] ids the PDG codes
116  int getThreeCharge(const std::vector<PdgId>& ids) const;
117 
118  /// @brief the particle lepton number from a PDG code
119  /// @param[in] id the PDG code
120  int getLeptonNumber(PdgId id) const;
121 
122  /// @brief return the total lepton number from a list of particle PDG codes
123  /// @param[in] ids the PDG codes
124  int getLeptonNumber(const std::vector<PdgId>& ids) const;
125 
126  /// @brief the particle baryon number from a PDG code
127  /// @param[in] id the PDG code
128  int getBaryonNumber(PdgId id) const;
129 
130  /// @brief return the total baryon number from a list of particle PDG codes
131  /// @param[in] ids the PDG codes
132  int getBaryonNumber(const std::vector<PdgId>& ids) const;
133 
134  /// @brief the particle lepton numbers for each flavor from a PDG code
135  /// @param[in] id the PDG code
136  /// @return the triplet \f$ (L_e, L_\mu, L_\tau) \f$
137  std::tuple<int, int, int> getLeptonFlavorNumber(PdgId id) const;
138 
139  /// @brief return the total lepton numbers for each flabor from a list of particle PDG codes
140  /// @param[in] ids the PDG codes
141  /// @return the triplet \f$ (L_e, L_\mu, L_\tau) \f$
142  std::tuple<int, int, int> getLeptonFlavorNumber(const std::vector<PdgId>& ids) const;
143 
144  /// @brief
145  /// @param[in] name
146  /// @param[in] hadOnly
147  /// @return
148  std::vector<HashId> expandToValidVertexUIDs(const std::string& name, const bool& hadOnly = false) const;
149 
150  /// @brief
151  /// @param[in] name
152  /// @return
153  std::vector<std::pair<PdgId, std::vector<PdgId>>> expandToValidVertices(const std::string& name) const;
154 
155  /// @brief get partial Widths
156  std::map<HashId, double> getPartialWidths();
157 
158  /// @brief
159  /// @return
160  static PID& instance();
161 
162  protected:
163  /// @brief
164  /// @return
165  static PID* getPIDInstance();
166 
167  /// @brief initializes the data tables
168  void init();
169 
170  /// @brief add BRs
171  void addBR(PdgId parent, const std::vector<PdgId>& daughters, const double br);
172 
173  protected:
174  enum location { nj = 1, nq3, nq2, nq1, nl, nr, n, n8, n9, n10 };
175 
176  /// @brief check whether a PDG code corresponds to a hadron
177  /// @param[in] id the PDG code
178  bool isHadron(PdgId id) const;
179 
180  public:
181  /// @brief check whether a PDG code corresponds to a meson
182  /// @param[in] id the PDG code
183  bool isMeson(PdgId id) const;
184 
185  protected:
186  /// @brief check whether a PDG code corresponds to a baryon
187  /// @param[in] id the PDG code
188  bool isBaryon(PdgId id) const;
189 
190  /// @brief check whether a PDG code corresponds to a diquark
191  /// @param[in] id the PDG code
192  bool isDiQuark(PdgId id) const;
193 
194  /// @brief check whether a PDG code corresponds to a pentaquark
195  /// @param[in] id the PDG code
196  bool isPentaquark(PdgId id) const;
197 
198  /// @brief check whether a PDG code corresponds to a charged lepton
199  /// @param[in] id the PDG code
200  bool isLepton(PdgId id) const;
201 
202  /// @brief check whether a PDG code corresponds to a neutrino
203  /// @param[in] id the PDG code
204  bool isNeutrino(PdgId id) const;
205 
206  /// @brief
207  /// @param[in] id the PDG code
208  /// @return
209  PdgId fundamentalID(PdgId id) const;
210 
211  /// @brief
212  /// @param[in] id the PDG code
213  /// @return
214  PdgId extraBits(PdgId id) const;
215 
216  /// @brief takes the absolute value of a PDG code
217  /// @param[in] id the PDG code
218  /// @return the code stripped by the sign
219  PdgId abspid(PdgId id) const;
220 
221  /// @brief extracts a digit from a PDG code
222  /// @param[in] loc digit position
223  /// @param[in] pid PDG code
224  /// @return the digit value
225  unsigned short digit(location loc, PdgId pid) const;
226 
227 
228  private:
229  static PID* _thePID;
230 
231  std::map<PdgId, double> _masses;
232 
233  std::map<PdgId, double> _widths;
234 
235  std::map<HashId, std::pair<double, PdgId>> _brs;
236 
237  std::map<std::string, std::vector<PdgId>> _names;
238 
239  public:
240  /// @name Charged leptons
241  //@{
242  static const PdgId ELECTRON = 11;
243  static const PdgId POSITRON = -ELECTRON;
244  static const PdgId EMINUS = ELECTRON;
245  static const PdgId EPLUS = POSITRON;
246  static const PdgId MUON = 13;
247  static const PdgId ANTIMUON = -MUON;
248  static const PdgId TAU = 15;
249  static const PdgId ANTITAU = -TAU;
250  //@}
251 
252  /// @name Neutrinos
253  //@{
254  static const PdgId NU_E = 12;
255  static const PdgId NU_EBAR = -NU_E;
256  static const PdgId NU_MU = 14;
257  static const PdgId NU_MUBAR = -NU_MU;
258  static const PdgId NU_TAU = 16;
259  static const PdgId NU_TAUBAR = -NU_TAU;
260  //@}
261 
262  /// @name Bosons
263  //@{
264  static const PdgId PHOTON = 22;
265  static const PdgId GAMMA = PHOTON;
266  static const PdgId WBOSON = 24;
267  //@}
268 
269  /// @name Nucleons
270  //@{
271  static const PdgId PROTON = 2212;
272  static const PdgId ANTIPROTON = -PROTON;
273  static const PdgId PBAR = ANTIPROTON;
274  static const PdgId NEUTRON = 2112;
275  static const PdgId ANTINEUTRON = -NEUTRON;
276  //@}
277 
278  /// @name Light mesons
279  //@{
280  static const PdgId PI0 = 111;
281  static const PdgId PIPLUS = 211;
282  static const PdgId PIMINUS = -PIPLUS;
283  static const PdgId RHO0 = 113;
284  static const PdgId RHOPLUS = 213;
285  static const PdgId RHOMINUS = -RHOPLUS;
286  static const PdgId K0L = 130;
287  static const PdgId K0S = 310;
288  static const PdgId KPLUS = 321;
289  static const PdgId KMINUS = -KPLUS;
290  static const PdgId ETA = 221;
291  static const PdgId ETAPRIME = 331;
292  static const PdgId PHI = 333;
293  static const PdgId OMEGA = 223;
294  //@}
295 
296  /// @name Charmonia
297  //@{
298  static const PdgId ETAC = 441;
299  static const PdgId JPSI = 443;
300  static const PdgId PSI2S = 100443;
301  //@}
302 
303  /// @name Charm mesons
304  //@{
305  static const PdgId D0 = 421;
306  static const PdgId DPLUS = 411;
307  static const PdgId DMINUS = -DPLUS;
308  static const PdgId DSTAR = 423;
309  static const PdgId DSTARPLUS = 413;
310  static const PdgId DSTARMINUS = -DSTARPLUS;
311  static const PdgId DSSD0STAR = 10421;
312  static const PdgId DSSD0STARPLUS = 10411;
314  static const PdgId DSSD1STAR = 20423;
315  static const PdgId DSSD1STARPLUS = 20413;
317  static const PdgId DSSD1 = 10423;
318  static const PdgId DSSD1PLUS = 10413;
319  static const PdgId DSSD1MINUS = -DSSD1PLUS;
320  static const PdgId DSSD2STAR = 425;
321  static const PdgId DSSD2STARPLUS = 415;
323  //@}
324  //// @name Charm strange mesons
325  //@{
326  static const PdgId DSPLUS = 431;
327  static const PdgId DSMINUS = -DSPLUS;
328  static const PdgId DSSTARPLUS = 433;
329  static const PdgId DSSTARMINUS = -DSSTARPLUS;
330  static const PdgId DSSDS0STARPLUS = 10431;
332  static const PdgId DSSDS1STARPLUS = 20433;
334  static const PdgId DSSDS1PLUS = 10433;
335  static const PdgId DSSDS1MINUS = -DSSDS1PLUS;
336  static const PdgId DSSDS2STARPLUS = 435;
338  //@}
339 
340  /// @name Bottomonia
341  //@{
342  static const PdgId ETAB = 551;
343  static const PdgId UPSILON1S = 553;
344  static const PdgId UPSILON2S = 100553;
345  static const PdgId UPSILON3S = 200553;
346  static const PdgId UPSILON4S = 300553;
347  //@}
348 
349  /// @name b mesons
350  //@{
351  static const PdgId BZERO = 511;
352  static const PdgId BPLUS = 521;
353  static const PdgId BMINUS = -BPLUS;
354  static const PdgId BS = 531;
355  static const PdgId BCPLUS = 541;
356  static const PdgId BCMINUS = -BCPLUS;
357  //@}
358 
359  /// @name Baryons
360  //@{
361  static const PdgId LAMBDA = 3122;
362  static const PdgId SIGMA0 = 3212;
363  static const PdgId SIGMAPLUS = 3222;
364  static const PdgId SIGMAMINUS = 3112;
365  static const PdgId LAMBDACPLUS = 4122;
366  static const PdgId LAMBDACMINUS = -LAMBDACPLUS;
367  static const PdgId LAMBDAB = 5122;
368  static const PdgId XI0 = 3322;
369  static const PdgId XIMINUS = 3312;
370  static const PdgId XIPLUS = -XIMINUS;
371  static const PdgId OMEGAMINUS = 3334;
372  static const PdgId OMEGAPLUS = -OMEGAMINUS;
373  //@}
374  };
375 
376 } // namespace Hammer
377 
378 #endif
static const PdgId DSSD0STARPLUS
Definition: Pdg.hh:312
static const PdgId NU_MU
Definition: Pdg.hh:256
size_t getSpinMultiplicities(const std::vector< PdgId > &ids) const
return where is the spin of particle i from a list of particle PDG codes
Definition: Pdg.cc:133
static const PdgId ELECTRON
Definition: Pdg.hh:242
static const PdgId K0L
Definition: Pdg.hh:286
static const PdgId RHOPLUS
Definition: Pdg.hh:284
static const PdgId POSITRON
Definition: Pdg.hh:243
static const PdgId D0
Definition: Pdg.hh:305
static const PdgId LAMBDACPLUS
Definition: Pdg.hh:365
static const PdgId RHO0
Definition: Pdg.hh:283
static const PdgId K0S
Definition: Pdg.hh:287
PID()
Definition: Pdg.cc:27
static const PdgId DSSD2STARPLUS
Definition: Pdg.hh:321
void init()
initializes the data tables
Definition: Pdg.cc:303
bool isMeson(PdgId id) const
check whether a PDG code corresponds to a meson
Definition: Pdg.cc:558
static const PdgId PHOTON
Definition: Pdg.hh:264
void addBR(PdgId parent, const std::vector< PdgId > &daughters, const double br)
add BRs
Definition: Pdg.cc:287
static const PdgId DSTARMINUS
Definition: Pdg.hh:310
Hammer data types declarations.
static const PdgId TAU
Definition: Pdg.hh:248
static const PdgId ANTINEUTRON
Definition: Pdg.hh:275
static const PdgId DSSDS1MINUS
Definition: Pdg.hh:335
std::vector< HashId > expandToValidVertexUIDs(const std::string &name, const bool &hadOnly=false) const
Definition: Pdg.cc:833
static const PdgId BCMINUS
Definition: Pdg.hh:356
static const PdgId ANTITAU
Definition: Pdg.hh:249
std::map< HashId, std::pair< double, PdgId > > _brs
Definition: Pdg.hh:235
static const PdgId SIGMAPLUS
Definition: Pdg.hh:363
void setWidth(PdgId id, double value)
set the particle width by PDG code
Definition: Pdg.cc:105
PdgId abspid(PdgId id) const
takes the absolute value of a PDG code
Definition: Pdg.cc:534
static const PdgId BZERO
Definition: Pdg.hh:351
static const PdgId SIGMA0
Definition: Pdg.hh:362
static const PdgId DSPLUS
Definition: Pdg.hh:326
static const PdgId WBOSON
Definition: Pdg.hh:266
static const PdgId LAMBDA
Definition: Pdg.hh:361
static const PdgId DSTARPLUS
Definition: Pdg.hh:309
static const PdgId UPSILON1S
Definition: Pdg.hh:343
std::vector< PdgId > toPdgList(const std::string &name) const
return a list of PDG codes corresponding to a particle name E.g.
Definition: Pdg.cc:52
static const PdgId ETAPRIME
Definition: Pdg.hh:291
static const PdgId ANTIMUON
Definition: Pdg.hh:247
static const PdgId JPSI
Definition: Pdg.hh:299
size_t getSpinMultiplicity(PdgId id) const
return where s is the particle spin from a PDG code
Definition: Pdg.cc:119
static const PdgId NU_EBAR
Definition: Pdg.hh:255
static const PdgId PSI2S
Definition: Pdg.hh:300
static const PdgId NEUTRON
Definition: Pdg.hh:274
std::vector< std::pair< PdgId, std::vector< PdgId > > > expandToValidVertices(const std::string &name) const
Definition: Pdg.cc:756
static const PdgId NU_TAUBAR
Definition: Pdg.hh:259
static const PdgId LAMBDACMINUS
Definition: Pdg.hh:366
static const PdgId DSSDS0STARPLUS
Definition: Pdg.hh:330
static PID * _thePID
Definition: Pdg.hh:229
std::map< PdgId, double > _widths
Definition: Pdg.hh:233
static const PdgId EPLUS
Definition: Pdg.hh:245
static const PdgId DSSD1PLUS
Definition: Pdg.hh:318
static const PdgId DSSDS1STARPLUS
Definition: Pdg.hh:332
static const PdgId SIGMAMINUS
Definition: Pdg.hh:364
static const PdgId OMEGA
Definition: Pdg.hh:293
static const PdgId DSSD0STARMINUS
Definition: Pdg.hh:313
void setMass(PdgId id, double value)
set the particle mass by PDG code
Definition: Pdg.cc:77
PdgId fundamentalID(PdgId id) const
Definition: Pdg.cc:542
int getBaryonNumber(PdgId id) const
the particle baryon number from a PDG code
Definition: Pdg.cc:232
static const PdgId ETAC
Definition: Pdg.hh:298
PID & operator=(const PID &)=delete
static const PdgId BS
Definition: Pdg.hh:354
static const PdgId NU_TAU
Definition: Pdg.hh:258
static const PdgId DSSDS1STARMINUS
Definition: Pdg.hh:333
bool isLepton(PdgId id) const
check whether a PDG code corresponds to a charged lepton
Definition: Pdg.cc:680
Pdg forward declarations.
static const PdgId BCPLUS
Definition: Pdg.hh:355
static const PdgId DSSD1MINUS
Definition: Pdg.hh:319
static const PdgId UPSILON3S
Definition: Pdg.hh:345
int getThreeCharge(PdgId id) const
return where q is the particle electric charge from a PDG code
Definition: Pdg.cc:149
static const PdgId UPSILON2S
Definition: Pdg.hh:344
static const PdgId XIPLUS
Definition: Pdg.hh:370
PdgId toPdgCode(const std::string &name) const
convert a particle name to its PDG code.
Definition: Pdg.cc:42
static const PdgId LAMBDAB
Definition: Pdg.hh:367
static const PdgId PBAR
Definition: Pdg.hh:273
static const PdgId RHOMINUS
Definition: Pdg.hh:285
static const PdgId KPLUS
Definition: Pdg.hh:288
static const PdgId DSSD1STARPLUS
Definition: Pdg.hh:315
std::map< PdgId, double > _masses
Definition: Pdg.hh:231
Hammer class for dealing with particle data.
Definition: Pdg.hh:32
static const PdgId NU_E
Definition: Pdg.hh:254
bool isDiQuark(PdgId id) const
check whether a PDG code corresponds to a diquark
Definition: Pdg.cc:632
static const PdgId ETA
Definition: Pdg.hh:290
PdgId extraBits(PdgId id) const
Definition: Pdg.cc:538
static const PdgId NU_MUBAR
Definition: Pdg.hh:257
static const PdgId MUON
Definition: Pdg.hh:246
static const PdgId DSSD1STAR
Definition: Pdg.hh:314
static const PdgId PROTON
Definition: Pdg.hh:271
static const PdgId UPSILON4S
Definition: Pdg.hh:346
static PID & instance()
Definition: Pdg.cc:283
double getWidth(PdgId id) const
particle width from a PDG code
Definition: Pdg.cc:91
static const PdgId DSSTARPLUS
Definition: Pdg.hh:328
static const PdgId DPLUS
Definition: Pdg.hh:306
static const PdgId OMEGAMINUS
Definition: Pdg.hh:371
static const PdgId DSSTARMINUS
Definition: Pdg.hh:329
static const PdgId DSSDS2STARMINUS
Definition: Pdg.hh:337
static const PdgId KMINUS
Definition: Pdg.hh:289
static const PdgId ETAB
Definition: Pdg.hh:342
static const PdgId XIMINUS
Definition: Pdg.hh:369
static const PdgId DSSD0STAR
Definition: Pdg.hh:311
static const PdgId DSSDS0STARMINUS
Definition: Pdg.hh:331
bool isBaryon(PdgId id) const
check whether a PDG code corresponds to a baryon
Definition: Pdg.cc:606
static const PdgId XI0
Definition: Pdg.hh:368
static const PdgId DSSD1STARMINUS
Definition: Pdg.hh:316
static const PdgId PHI
Definition: Pdg.hh:292
~PID()
Definition: Pdg.cc:30
static const PdgId DSSDS2STARPLUS
Definition: Pdg.hh:336
static const PdgId ANTIPROTON
Definition: Pdg.hh:272
static const PdgId DSSD2STAR
Definition: Pdg.hh:320
unsigned short digit(location loc, PdgId pid) const
extracts a digit from a PDG code
Definition: Pdg.cc:527
static const PdgId BPLUS
Definition: Pdg.hh:352
bool isHadron(PdgId id) const
check whether a PDG code corresponds to a hadron
Definition: Pdg.cc:660
int getLeptonNumber(PdgId id) const
the particle lepton number from a PDG code
Definition: Pdg.cc:215
static const PdgId GAMMA
Definition: Pdg.hh:265
static const PdgId PIPLUS
Definition: Pdg.hh:281
bool isNeutrino(PdgId id) const
check whether a PDG code corresponds to a neutrino
Definition: Pdg.cc:692
bool isPentaquark(PdgId id) const
check whether a PDG code corresponds to a pentaquark
Definition: Pdg.cc:705
static const PdgId PI0
Definition: Pdg.hh:280
static const PdgId EMINUS
Definition: Pdg.hh:244
std::tuple< int, int, int > getLeptonFlavorNumber(PdgId id) const
the particle lepton numbers for each flavor from a PDG code
Definition: Pdg.cc:249
static const PdgId BMINUS
Definition: Pdg.hh:353
static const PdgId DMINUS
Definition: Pdg.hh:307
static const PdgId DSMINUS
Definition: Pdg.hh:327
int PdgId
Definition: Pdg.fhh:17
static const PdgId DSSDS1PLUS
Definition: Pdg.hh:334
static PID * getPIDInstance()
Definition: Pdg.cc:275
static const PdgId DSTAR
Definition: Pdg.hh:308
static const PdgId DSSD1
Definition: Pdg.hh:317
static const PdgId PIMINUS
Definition: Pdg.hh:282
static const PdgId DSSD2STARMINUS
Definition: Pdg.hh:322
std::map< std::string, std::vector< PdgId > > _names
Definition: Pdg.hh:237
std::map< HashId, double > getPartialWidths()
get partial Widths
Definition: Pdg.cc:292
static const PdgId OMEGAPLUS
Definition: Pdg.hh:372
double getMass(PdgId id) const
particle mass from a PDG code
Definition: Pdg.cc:62