ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4InuclElementaryParticle.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4InuclElementaryParticle.cc
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 //
27 // 20100428 M. Kelsey -- Use G4InuclParticleNames enums instead of numbers,
28 // add Omega and antinucleons.
29 // 20100429 M. Kelsey -- Change "case gamma:" to "case photon:"
30 // 20100923 M. Kelsey -- Drop "uups" message when converting G4PartDef to code
31 // 20101029 M. Kelsey -- Add instantiation of new particles, antiparticles
32 // 20110214 M. Kelsey -- Drop unused "generation"
33 // 20110307 M. Kelsey -- Add random K0 mixing if K0S/K0L passed to type()
34 // 20110321 M. Kelsey -- Fix getStrangeness to return int
35 // 20110801 M. Kelsey -- Add fill() functions to replicate ctors, allowing
36 // reuse of objects as buffers; c.f. G4InuclNuclei.
37 // 20110922 M. Kelsey -- Add stream argument to printParticle() => print()
38 // 20120608 M. Kelsey -- Fix variable-name "shadowing" compiler warnings.
39 // 20130508 D. Wright -- Add lepton construction, use wrapper header
40 // 20140310 M. Kelsey -- Fix constness in G4PD* passing
41 
43 
44 #include "G4SystemOfUnits.hh"
45 #include "G4ParticleDefinition.hh"
46 #include "G4ParticleTypes.hh"
47 #include "G4Diproton.hh"
48 #include "G4UnboundPN.hh"
49 #include "G4Dineutron.hh"
50 #include "Randomize.hh"
51 
52 #include "G4InuclParticleNames.hh"
53 using namespace G4InuclParticleNames;
54 
55 
58  switch(ityp) {
59  case proton: return G4Proton::Definition(); break;
60  case neutron: return G4Neutron::Definition(); break;
61  case pionPlus: return G4PionPlus::Definition(); break;
62  case pionMinus: return G4PionMinus::Definition(); break;
63  case pionZero: return G4PionZero::Definition(); break;
64  case photon: return G4Gamma::Definition(); break;
65  case kaonPlus: return G4KaonPlus::Definition(); break;
66  case kaonMinus: return G4KaonMinus::Definition(); break;
67  case kaonZero: return G4KaonZero::Definition(); break;
68  case kaonZeroBar: return G4AntiKaonZero::Definition(); break;
69  case lambda: return G4Lambda::Definition(); break;
70  case sigmaPlus: return G4SigmaPlus::Definition(); break;
71  case sigmaZero: return G4SigmaZero::Definition(); break;
72  case sigmaMinus: return G4SigmaMinus::Definition(); break;
73  case xiZero: return G4XiZero::Definition(); break;
74  case xiMinus: return G4XiMinus::Definition(); break;
75  case omegaMinus: return G4OmegaMinus::Definition(); break;
76  // NOTE: The four light nuclei "particles" are actually G4Ions
77  case deuteron: return G4Deuteron::Definition(); break;
78  case triton: return G4Triton::Definition(); break;
79  case He3: return G4He3::Definition(); break;
80  case alpha: return G4Alpha::Definition(); break;
81  case antiProton: return G4AntiProton::Definition(); break;
82  case antiNeutron: return G4AntiNeutron::Definition(); break;
83  // NOTE: The the four light antinuclei "particles" are actually G4Ions
84  case antiDeuteron: return G4AntiDeuteron::Definition(); break;
85  case antiTriton: return G4AntiTriton::Definition(); break;
86  case antiHe3: return G4AntiHe3::Definition(); break;
87  case antiAlpha: return G4AntiAlpha::Definition(); break;
88  // NOTE: The three unbound dibaryons are local Bertini classes
89  case diproton: return G4Diproton::Definition(); break;
90  case unboundPN: return G4UnboundPN::Definition(); break;
91  case dineutron: return G4Dineutron::Definition(); break;
92  // Leptons are included for muon capture and future tau/neutrino physics
93  case electron: return G4Electron::Definition(); break;
94  case positron: return G4Positron::Definition(); break;
95  case electronNu: return G4NeutrinoE::Definition(); break;
96  case antiElectronNu: return G4AntiNeutrinoE::Definition(); break;
97  case muonMinus: return G4MuonMinus::Definition(); break;
98  case muonPlus: return G4MuonPlus::Definition(); break;
99  case muonNu: return G4NeutrinoMu::Definition(); break;
100  case antiMuonNu: return G4AntiNeutrinoMu::Definition(); break;
101  case tauMinus: return G4TauMinus::Definition(); break;
102  case tauPlus: return G4TauPlus::Definition(); break;
103  case tauNu: return G4NeutrinoTau::Definition(); break;
104  case antiTauNu: return G4AntiNeutrinoTau::Definition(); break;
105  default:
106  G4cerr << "G4InuclElementaryParticle::makeDefinition: unknown particle type "
107  << ityp << G4endl;
108  }
109 
110  return 0;
111 }
112 
113 // This is the inverse mapping to makeDefinition above
114 
116  if (pd == 0) return 0;
117  if (pd == G4Proton::Definition()) return proton;
118  if (pd == G4Neutron::Definition()) return neutron;
119  if (pd == G4PionPlus::Definition()) return pionPlus;
120  if (pd == G4PionMinus::Definition()) return pionMinus;
121  if (pd == G4PionZero::Definition()) return pionZero;
122  if (pd == G4Gamma::Definition()) return photon;
123  if (pd == G4KaonPlus::Definition()) return kaonPlus;
124  if (pd == G4KaonMinus::Definition()) return kaonMinus;
125  if (pd == G4KaonZero::Definition()) return kaonZero;
126  if (pd == G4AntiKaonZero::Definition()) return kaonZeroBar;
127  if (pd == G4Lambda::Definition()) return lambda;
128  if (pd == G4SigmaPlus::Definition()) return sigmaPlus;
129  if (pd == G4SigmaZero::Definition()) return sigmaZero;
130  if (pd == G4SigmaMinus::Definition()) return sigmaMinus;
131  if (pd == G4XiZero::Definition()) return xiZero;
132  if (pd == G4XiMinus::Definition()) return xiMinus;
133  if (pd == G4OmegaMinus::Definition()) return omegaMinus;
134  // NOTE: The four light nuclei "particles" are actually G4Ions
135  if (pd == G4Deuteron::Definition()) return deuteron;
136  if (pd == G4Triton::Definition()) return triton;
137  if (pd == G4He3::Definition()) return He3;
138  if (pd == G4Alpha::Definition()) return alpha;
139  if (pd == G4AntiProton::Definition()) return antiProton;
140  if (pd == G4AntiNeutron::Definition()) return antiNeutron;
141  // NOTE: The the four light antinuclei "particles" are actually G4Ions
142  if (pd == G4AntiDeuteron::Definition()) return antiDeuteron;
143  if (pd == G4AntiTriton::Definition()) return antiTriton;
144  if (pd == G4AntiHe3::Definition()) return antiHe3;
145  if (pd == G4AntiAlpha::Definition()) return antiAlpha;
146  // NOTE: The three unbound dibaryons are local Bertini classes
147  if (pd == G4Diproton::Definition()) return diproton;
148  if (pd == G4UnboundPN::Definition()) return unboundPN;
149  if (pd == G4Dineutron::Definition()) return dineutron;
150 
151  if (pd == G4Electron::Definition()) return electron;
152  if (pd == G4Positron::Definition()) return positron;
153  if (pd == G4NeutrinoE::Definition()) return electronNu;
154  if (pd == G4AntiNeutrinoE::Definition()) return antiElectronNu;
155  if (pd == G4MuonMinus::Definition()) return muonMinus;
156  if (pd == G4MuonPlus::Definition()) return muonPlus;
157  if (pd == G4NeutrinoMu::Definition()) return muonNu;
158  if (pd == G4AntiNeutrinoMu::Definition()) return antiMuonNu;
159  if (pd == G4TauMinus::Definition()) return tauMinus;
160  if (pd == G4TauPlus::Definition()) return tauPlus;
161  if (pd == G4NeutrinoTau::Definition()) return tauNu;
162  if (pd == G4AntiNeutrinoTau::Definition()) return antiTauNu;
163 
164  // Weak neutral kaons must be mixed back to strong (strangeness states)
166  return ((G4UniformRand() > 0.5) ? kaonZero : kaonZeroBar);
167  }
168 
169  return 0; // Unknown objects return zero (e.g., nuclei)
170 }
171 
173  setDefinition(makeDefinition(ityp));
174 }
175 
176 
177 // Overwrite data structure (avoids creating/copying temporaries)
178 
181  setType(ityp);
182  setMomentum(mom);
183  setModel(model);
184 }
185 
188  setType(ityp);
189  setKineticEnergy(ekin);
190  setModel(model);
191 }
192 
194  const G4ParticleDefinition* pd,
196  setDefinition(pd);
197  setMomentum(mom);
198  setModel(model);
199 }
200 
201 
202 // Assignment operator for use with std::sort()
206  return *this;
207 }
208 
209 
211  const G4ParticleDefinition* pd = makeDefinition(ityp);
212  return pd ? (pd->GetQuarkContent(3) - pd->GetAntiQuarkContent(3)) : 0;
213 }
214 
216  const G4ParticleDefinition* pd = makeDefinition(ityp);
217  return pd ? pd->GetPDGMass()*MeV/GeV : 0.0; // From G4 to Bertini units
218 }
219 
220 
221 // Print particle parameters
222 
223 void G4InuclElementaryParticle::print(std::ostream& os) const {
225  os << G4endl << " Particle: " << getDefinition()->GetParticleName()
226  << " type " << type() << " mass " << getMass()
227  << " ekin " << getKineticEnergy();
228 }
229