ATLAS Offline Software
PdgToParticleHypothesis.icc
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 namespace Trk {
6 inline Trk::ParticleHypothesis
7 PdgToParticleHypothesis::convert(int pdg, double charge) const
8 {
9  bool stable, exiting;
10  return convert(pdg, stable, exiting, charge);
11 }
12 
13 inline Trk::ParticleHypothesis
14 PdgToParticleHypothesis::convert(int pdg,
15  bool& stable,
16  bool& exiting,
17  double charge) const
18 {
19 
20  int pdgCode = abs(pdg);
21 
22  stable = false;
23  exiting = false;
24 
25  Trk::ParticleHypothesis particleType;
26 
27  // try to follow number of appearance
28  switch (pdgCode) {
29  // leptons
30  case 11: { // e+/e-
31  particleType = Trk::electron;
32  stable = true;
33  exiting = false;
34  break;
35  }
36  case 13: { // mu+/mu-
37  particleType = Trk::muon;
38  stable = false;
39  exiting = false;
40  break;
41  }
42  case 12: // e neutrino
43  case 14: // mu neutrino
44  case 16: { // tau neutrino
45  particleType = Trk::nonInteracting;
46  stable = true;
47  exiting = true;
48  break;
49  }
50  case 22: { // gamma
51  particleType = Trk::photon;
52  stable = true;
53  exiting = false;
54  break;
55  }
56  case 211: { // pi+/pi-
57  particleType = Trk::pion;
58  stable = false;
59  exiting = false;
60  break;
61  }
62  case 111: { // pi0
63  particleType = Trk::pi0;
64  stable = false;
65  exiting = false;
66  break;
67  }
68  case 2212: { // proton
69  particleType = Trk::proton;
70  stable = true;
71  exiting = false;
72  break;
73  }
74  case 2112: { // neutron
75  particleType = Trk::neutron;
76  stable = true;
77  exiting = true;
78  break;
79  }
80  case 321: { // K
81  particleType = Trk::kaon;
82  stable = false;
83  exiting = false;
84  break;
85  }
86  case 130: { // K_long
87  particleType = Trk::k0;
88  stable = false;
89  exiting = false;
90  break;
91  }
92  case 310: { // K_short
93  particleType = Trk::k0;
94  stable = false;
95  exiting = false;
96  break;
97  }
98  default: { // treat mesons as pions
99  particleType = charge != 0. ? Trk::pion : Trk::pi0;
100  stable = false;
101  exiting = false;
102  }
103  }
104 
105  // and all baryons as proton hypo
106  if (pdgCode > 999 && pdgCode != 2112) {
107  particleType = charge != 0. ? Trk::proton : Trk::neutron;
108  stable = false;
109  exiting = false;
110  }
111 
112  // ignore SUSY particles for now
113  if (pdgCode > 1000000) {
114  particleType = Trk::nonInteracting;
115  stable = true;
116  exiting = true;
117  }
118 
119  return particleType;
120 }
121 
122 inline int
123 PdgToParticleHypothesis::convert(Trk::ParticleHypothesis particleHypo,
124  double charge,
125  bool dist) const
126 {
127 
128  int pdg = 0;
129 
130  switch (particleHypo) {
131  // the electron case
132  case Trk::electron: {
133  pdg = 11;
134  pdg *= charge > 0. ? -1 : 1;
135  return pdg;
136  }
137  // the muon case
138  case Trk::muon: {
139  pdg = 13;
140  pdg *= charge > 0. ? -1 : 1;
141  return pdg;
142  }
143  // the kaon case
144  case Trk::kaon: {
145  pdg = 321;
146  pdg *= charge > 0. ? 1 : -1;
147  if (charge * charge < 0.0001)
148  pdg = dist ? 130 : 310;
149  return pdg;
150  }
151  // the proton case
152  case Trk::proton: {
153  pdg = 2212;
154  pdg *= charge > 0. ? 1 : -1;
155  if (charge * charge < 0.0001)
156  pdg = dist ? 2112 : -2112;
157  return pdg;
158  }
159  // the photon case
160  case Trk::photon: {
161  pdg = 22;
162  return pdg;
163  }
164  // the neutron case
165  case Trk::neutron: {
166  pdg = 2112;
167  return pdg;
168  }
169  // the neutral pion case
170  case Trk::pi0: {
171  pdg = 111;
172  return pdg;
173  }
174  // the neutral kaon case
175  case Trk::k0: {
176  pdg = dist ? 130 : 310;
177  return pdg;
178  }
179  // the pion case - is the default
180  default: {
181  pdg = 211;
182  pdg *= charge > 0. ? 1 : -1;
183  if (charge * charge < 0.0001)
184  pdg = 111;
185  }
186  }
187 
188  return pdg;
189 }
190 }