Rivet  1.8.0
ParticleName.hh
1 #ifndef RIVET_PARTICLENAME_HH
2 #define RIVET_PARTICLENAME_HH
3 
4 #include "Rivet/Particle.fhh"
5 #include "Rivet/Exceptions.hh"
6 
7 
8 namespace Rivet {
9 
10 
12 
13  static const PdgId ELECTRON = 11;
14  static const PdgId POSITRON = -11;
15  static const PdgId PROTON = 2212;
16  static const PdgId ANTIPROTON = -2212;
17  static const PdgId PHOTON = 22;
18  static const PdgId NEUTRON = 2112;
19  static const PdgId ANTINEUTRON = -2112;
20  static const PdgId MUON = 13;
21  static const PdgId ANTIMUON = -13;
22  static const PdgId NU_E = 12;
23  static const PdgId NU_EBAR = -12;
24  static const PdgId NU_MU = 14;
25  static const PdgId NU_MUBAR = -14;
26  static const PdgId NU_TAU = 16;
27  static const PdgId NU_TAUBAR = -16;
28  static const PdgId PIPLUS = 211;
29  static const PdgId PIMINUS = -211;
30  static const PdgId PI0 = 111;
31  static const PdgId K0L = 130;
32  static const PdgId K0S = 310;
33  static const PdgId KPLUS = 321;
34  static const PdgId KMINUS = -321;
35  static const PdgId LAMBDA = 3122;
36  static const PdgId LAMBDABAR = -3122;
37  static const PdgId XIMINUS = 3312;
38  static const PdgId XIPLUS = -3312;
39  static const PdgId OMEGAMINUS = 3334;
40  static const PdgId OMEGAPLUS = -3334;
41  static const PdgId TAU = 15;
42  static const PdgId ANTITAU = -15;
43  static const PdgId EMINUS = 11;
44  static const PdgId EPLUS = -11;
45  static const PdgId P = 2212;
46  static const PdgId PBAR = -2212;
47  static const PdgId GLUON = 21;
48  static const PdgId GAMMA = 22;
49  static const PdgId WPLUSBOSON = 24;
50  static const PdgId WMINUSBOSON = -24;
51  static const PdgId ZBOSON = 23;
52  static const PdgId HIGGS = 25;
53  static const PdgId DQUARK = 1;
54  static const PdgId UQUARK = 2;
55  static const PdgId SQUARK = 3;
56  static const PdgId CQUARK = 4;
57  static const PdgId BQUARK = 5;
58  static const PdgId TQUARK = 6;
59  static const PdgId ANY = 10000;
60  // static const PdgId PHOTOELECTRON;
61  // static const PdgId PHOTOPOSITRON;
62  // static const PdgId PHOTOMUON;
63  // static const PdgId PHOTOANTIMUON;
64  // static const PdgId PHOTOTAU;
65  // static const PdgId PHOTOANTITAU;
67 
68 
69  class ParticleNames {
70  public:
71 
72  static const std::string& particleName(PdgId pid) {
73  if (!_instance) _instance = new ParticleNames();
74  return _instance->_particleName(pid);
75  }
76 
77  static PdgId particleId(const std::string& pname) {
78  if (!_instance) _instance = new ParticleNames();
79  return _instance->_particleId(pname);
80  }
81 
82 
83  public:
84 
85  const std::string& _particleName(PdgId pid);
86 
87 
88  PdgId _particleId(const std::string& pname);
89 
90 
91  private:
92 
93  ParticleNames() {
94  _add_pid_name(ELECTRON, "ELECTRON");
95  _add_pid_name(POSITRON, "POSITRON");
96  _add_pid_name(PROTON, "PROTON");
97  _add_pid_name(ANTIPROTON, "ANTIPROTON");
98  _add_pid_name(PHOTON, "PHOTON");
99  _add_pid_name(NEUTRON, "NEUTRON");
100  _add_pid_name(ANTINEUTRON, "ANTINEUTRON");
101  _add_pid_name(MUON, "MUON");
102  _add_pid_name(ANTIMUON, "ANTIMUON");
103  _add_pid_name(NU_E, "NU_E");
104  _add_pid_name(NU_EBAR, "NU_EBAR");
105  _add_pid_name(NU_MU, "NU_MU");
106  _add_pid_name(NU_MUBAR, "NU_MUBAR");
107  _add_pid_name(NU_TAU, "NU_TAU");
108  _add_pid_name(NU_TAUBAR, "NU_TAUBAR");
109  _add_pid_name(PIPLUS, "PIPLUS");
110  _add_pid_name(PIMINUS, "PIMINUS");
111  _add_pid_name(TAU, "TAU");
112  _add_pid_name(WPLUSBOSON, "WPLUSBOSON");
113  _add_pid_name(WMINUSBOSON, "WMINUSBOSON");
114  _add_pid_name(ZBOSON, "ZBOSON");
115  _add_pid_name(HIGGS, "HIGGS");
116  _add_pid_name(ANTITAU, "ANTITAU");
117  // _add_pid_name(PHOTOELECTRON, "PHOTOELECTRON");
118  // _add_pid_name(PHOTOPOSITRON, "PHOTOPOSITRON");
119  // _add_pid_name(PHOTOMUON, "PHOTOMUON");
120  // _add_pid_name(PHOTOANTIMUON, "PHOTOANTIMUON");
121  // _add_pid_name(PHOTOTAU, "PHOTOTAU");
122  // _add_pid_name(PHOTOANTITAU, "PHOTOANTITAU");
123  _add_pid_name(ANY, "*");
124  }
125 
126  void _add_pid_name(PdgId pid, const std::string& pname) {
127  _ids_names[pid] = pname;
128  _names_ids[pname] = pid;
129  }
130 
131 
132  static ParticleNames* _instance;
133 
134  std::map<PdgId, std::string> _ids_names;
135 
136  std::map<std::string, PdgId> _names_ids;
137 
138  };
139 
140 
142  inline const std::string& toParticleName(PdgId p) {
143  return ParticleNames::particleName(p);
144  }
145 
146 
148  inline PdgId toParticleId(const std::string& pname) {
149  return ParticleNames::particleId(pname);
150  }
151 
152 
154  inline std::pair<PdgId,PdgId> make_pdgid_pair(PdgId a, PdgId b) {
155  return make_pair(a, b);
156  }
157 
158 
160  inline std::pair<PdgId,PdgId> make_pdgid_pair(const std::string& a, const std::string& b) {
161  const PdgId pa = toParticleId(a);
162  const PdgId pb = toParticleId(b);
163  return make_pair(pa, pb);
164  }
165 
166 
168  inline std::string toBeamsString(const PdgIdPair& pair) {
169  string out = "[" +
170  toParticleName(pair.first) + ", " +
171  toParticleName(pair.second) + "]";
172  return out;
173  }
174 
175 
176 }
177 
178 #endif