Geant4  10.01.p02
G4InuclElementaryParticle.cc
Go to the documentation of this file.
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 // $Id: G4InuclElementaryParticle.cc 69638 2013-05-09 04:26:00Z mkelsey $
27 // Geant4 tag: $Name: $
28 //
29 // 20100428 M. Kelsey -- Use G4InuclParticleNames enums instead of numbers,
30 // add Omega and antinucleons.
31 // 20100429 M. Kelsey -- Change "case gamma:" to "case photon:"
32 // 20100923 M. Kelsey -- Drop "uups" message when converting G4PartDef to code
33 // 20101029 M. Kelsey -- Add instantiation of new particles, antiparticles
34 // 20110214 M. Kelsey -- Drop unused "generation"
35 // 20110307 M. Kelsey -- Add random K0 mixing if K0S/K0L passed to type()
36 // 20110321 M. Kelsey -- Fix getStrangeness to return int
37 // 20110801 M. Kelsey -- Add fill() functions to replicate ctors, allowing
38 // reuse of objects as buffers; c.f. G4InuclNuclei.
39 // 20110922 M. Kelsey -- Add stream argument to printParticle() => print()
40 // 20120608 M. Kelsey -- Fix variable-name "shadowing" compiler warnings.
41 // 20130508 D. Wright -- Add lepton construction, use wrapper header
42 // 20140310 M. Kelsey -- Fix constness in G4PD* passing
43 
45 
46 #include "G4SystemOfUnits.hh"
47 #include "G4ParticleDefinition.hh"
48 #include "G4ParticleTypes.hh"
49 #include "G4Diproton.hh"
50 #include "G4UnboundPN.hh"
51 #include "G4Dineutron.hh"
52 #include "Randomize.hh"
53 
54 #include "G4InuclParticleNames.hh"
55 using namespace G4InuclParticleNames;
56 
57 
60  switch(ityp) {
61  case proton: return G4Proton::Definition(); break;
62  case neutron: return G4Neutron::Definition(); break;
63  case pionPlus: return G4PionPlus::Definition(); break;
64  case pionMinus: return G4PionMinus::Definition(); break;
65  case pionZero: return G4PionZero::Definition(); break;
66  case photon: return G4Gamma::Definition(); break;
67  case kaonPlus: return G4KaonPlus::Definition(); break;
68  case kaonMinus: return G4KaonMinus::Definition(); break;
69  case kaonZero: return G4KaonZero::Definition(); break;
70  case kaonZeroBar: return G4AntiKaonZero::Definition(); break;
71  case lambda: return G4Lambda::Definition(); break;
72  case sigmaPlus: return G4SigmaPlus::Definition(); break;
73  case sigmaZero: return G4SigmaZero::Definition(); break;
74  case sigmaMinus: return G4SigmaMinus::Definition(); break;
75  case xiZero: return G4XiZero::Definition(); break;
76  case xiMinus: return G4XiMinus::Definition(); break;
77  case omegaMinus: return G4OmegaMinus::Definition(); break;
78  // NOTE: The four light nuclei "particles" are actually G4Ions
79  case deuteron: return G4Deuteron::Definition(); break;
80  case triton: return G4Triton::Definition(); break;
81  case He3: return G4He3::Definition(); break;
82  case alpha: return G4Alpha::Definition(); break;
83  case antiProton: return G4AntiProton::Definition(); break;
84  case antiNeutron: return G4AntiNeutron::Definition(); break;
85  // NOTE: The the four light antinuclei "particles" are actually G4Ions
86  case antiDeuteron: return G4AntiDeuteron::Definition(); break;
87  case antiTriton: return G4AntiTriton::Definition(); break;
88  case antiHe3: return G4AntiHe3::Definition(); break;
89  case antiAlpha: return G4AntiAlpha::Definition(); break;
90  // NOTE: The three unbound dibaryons are local Bertini classes
91  case diproton: return G4Diproton::Definition(); break;
92  case unboundPN: return G4UnboundPN::Definition(); break;
93  case dineutron: return G4Dineutron::Definition(); break;
94  // Leptons are included for muon capture and future tau/neutrino physics
95  case electron: return G4Electron::Definition(); break;
96  case positron: return G4Positron::Definition(); break;
97  case electronNu: return G4NeutrinoE::Definition(); break;
98  case antiElectronNu: return G4AntiNeutrinoE::Definition(); break;
99  case muonMinus: return G4MuonMinus::Definition(); break;
100  case muonPlus: return G4MuonPlus::Definition(); break;
101  case muonNu: return G4NeutrinoMu::Definition(); break;
102  case antiMuonNu: return G4AntiNeutrinoMu::Definition(); break;
103  case tauMinus: return G4TauMinus::Definition(); break;
104  case tauPlus: return G4TauPlus::Definition(); break;
105  case tauNu: return G4NeutrinoTau::Definition(); break;
106  case antiTauNu: return G4AntiNeutrinoTau::Definition(); break;
107  default:
108  G4cerr << "G4InuclElementaryParticle::makeDefinition: unknown particle type "
109  << ityp << G4endl;
110  }
111 
112  return 0;
113 }
114 
115 // This is the inverse mapping to makeDefinition above
116 
118  if (pd == 0) return 0;
119  if (pd == G4Proton::Definition()) return proton;
120  if (pd == G4Neutron::Definition()) return neutron;
121  if (pd == G4PionPlus::Definition()) return pionPlus;
122  if (pd == G4PionMinus::Definition()) return pionMinus;
123  if (pd == G4PionZero::Definition()) return pionZero;
124  if (pd == G4Gamma::Definition()) return photon;
125  if (pd == G4KaonPlus::Definition()) return kaonPlus;
126  if (pd == G4KaonMinus::Definition()) return kaonMinus;
127  if (pd == G4KaonZero::Definition()) return kaonZero;
128  if (pd == G4AntiKaonZero::Definition()) return kaonZeroBar;
129  if (pd == G4Lambda::Definition()) return lambda;
130  if (pd == G4SigmaPlus::Definition()) return sigmaPlus;
131  if (pd == G4SigmaZero::Definition()) return sigmaZero;
132  if (pd == G4SigmaMinus::Definition()) return sigmaMinus;
133  if (pd == G4XiZero::Definition()) return xiZero;
134  if (pd == G4XiMinus::Definition()) return xiMinus;
135  if (pd == G4OmegaMinus::Definition()) return omegaMinus;
136  // NOTE: The four light nuclei "particles" are actually G4Ions
137  if (pd == G4Deuteron::Definition()) return deuteron;
138  if (pd == G4Triton::Definition()) return triton;
139  if (pd == G4He3::Definition()) return He3;
140  if (pd == G4Alpha::Definition()) return alpha;
141  if (pd == G4AntiProton::Definition()) return antiProton;
142  if (pd == G4AntiNeutron::Definition()) return antiNeutron;
143  // NOTE: The the four light antinuclei "particles" are actually G4Ions
144  if (pd == G4AntiDeuteron::Definition()) return antiDeuteron;
145  if (pd == G4AntiTriton::Definition()) return antiTriton;
146  if (pd == G4AntiHe3::Definition()) return antiHe3;
147  if (pd == G4AntiAlpha::Definition()) return antiAlpha;
148  // NOTE: The three unbound dibaryons are local Bertini classes
149  if (pd == G4Diproton::Definition()) return diproton;
150  if (pd == G4UnboundPN::Definition()) return unboundPN;
151  if (pd == G4Dineutron::Definition()) return dineutron;
152 
153  if (pd == G4Electron::Definition()) return electron;
154  if (pd == G4Positron::Definition()) return positron;
155  if (pd == G4NeutrinoE::Definition()) return electronNu;
156  if (pd == G4AntiNeutrinoE::Definition()) return antiElectronNu;
157  if (pd == G4MuonMinus::Definition()) return muonMinus;
158  if (pd == G4MuonPlus::Definition()) return muonPlus;
159  if (pd == G4NeutrinoMu::Definition()) return muonNu;
160  if (pd == G4AntiNeutrinoMu::Definition()) return antiMuonNu;
161  if (pd == G4TauMinus::Definition()) return tauMinus;
162  if (pd == G4TauPlus::Definition()) return tauPlus;
163  if (pd == G4NeutrinoTau::Definition()) return tauNu;
164  if (pd == G4AntiNeutrinoTau::Definition()) return antiTauNu;
165 
166  // Weak neutral kaons must be mixed back to strong (strangeness states)
168  return ((G4UniformRand() > 0.5) ? kaonZero : kaonZeroBar);
169  }
170 
171  return 0; // Unknown objects return zero (e.g., nuclei)
172 }
173 
175  setDefinition(makeDefinition(ityp));
176 }
177 
178 
179 // Overwrite data structure (avoids creating/copying temporaries)
180 
182  G4InuclParticle::Model model) {
183  setType(ityp);
184  setMomentum(mom);
185  setModel(model);
186 }
187 
189  G4InuclParticle::Model model) {
190  setType(ityp);
191  setKineticEnergy(ekin);
192  setModel(model);
193 }
194 
196  const G4ParticleDefinition* pd,
197  G4InuclParticle::Model model) {
198  setDefinition(pd);
199  setMomentum(mom);
200  setModel(model);
201 }
202 
203 
204 // Assignment operator for use with std::sort()
208  return *this;
209 }
210 
211 
213  const G4ParticleDefinition* pd = makeDefinition(ityp);
214  return pd ? (pd->GetQuarkContent(3) - pd->GetAntiQuarkContent(3)) : 0;
215 }
216 
218  const G4ParticleDefinition* pd = makeDefinition(ityp);
219  return pd ? pd->GetPDGMass()*MeV/GeV : 0.0; // From G4 to Bertini units
220 }
221 
222 
223 // Print particle parameters
224 
225 void G4InuclElementaryParticle::print(std::ostream& os) const {
227  os << G4endl << " Particle: " << getDefinition()->GetParticleName()
228  << " type " << type() << " mass " << getMass()
229  << " ekin " << getKineticEnergy();
230 }
231 
static G4SigmaZero * Definition()
Definition: G4SigmaZero.cc:53
static G4KaonMinus * Definition()
Definition: G4KaonMinus.cc:54
static const double MeV
Definition: G4SIunits.hh:193
static G4PionPlus * Definition()
Definition: G4PionPlus.cc:52
static G4Triton * Definition()
Definition: G4Triton.cc:50
static G4XiMinus * Definition()
Definition: G4XiMinus.cc:53
static G4KaonZero * Definition()
Definition: G4KaonZero.cc:53
static G4AntiHe3 * Definition()
Definition: G4AntiHe3.cc:50
static G4AntiKaonZero * Definition()
static G4Alpha * Definition()
Definition: G4Alpha.cc:49
static const G4ParticleDefinition * makeDefinition(G4int ityp)
static G4MuonMinus * Definition()
Definition: G4MuonMinus.cc:52
static G4SigmaPlus * Definition()
Definition: G4SigmaPlus.cc:53
G4int GetAntiQuarkContent(G4int flavor) const
static G4Electron * Definition()
Definition: G4Electron.cc:49
static G4double getParticleMass(G4int type)
static G4Diproton * Definition()
Definition: G4Diproton.cc:68
static G4Positron * Definition()
Definition: G4Positron.cc:49
int G4int
Definition: G4Types.hh:78
static G4KaonPlus * Definition()
Definition: G4KaonPlus.cc:54
G4InuclElementaryParticle & operator=(const G4InuclElementaryParticle &right)
static G4Proton * Definition()
Definition: G4Proton.cc:49
static G4TauMinus * Definition()
Definition: G4TauMinus.cc:54
static G4AntiTriton * Definition()
Definition: G4AntiTriton.cc:50
static G4Deuteron * Definition()
Definition: G4Deuteron.cc:50
static G4AntiNeutrinoE * Definition()
static G4SigmaMinus * Definition()
Definition: G4SigmaMinus.cc:53
#define G4UniformRand()
Definition: Randomize.hh:93
virtual void print(std::ostream &os) const
static G4TauPlus * Definition()
Definition: G4TauPlus.cc:54
static G4MuonPlus * Definition()
Definition: G4MuonPlus.cc:52
G4int GetQuarkContent(G4int flavor) const
static G4AntiProton * Definition()
Definition: G4AntiProton.cc:51
static G4Lambda * Definition()
Definition: G4Lambda.cc:53
static const double GeV
Definition: G4SIunits.hh:196
static G4NeutrinoTau * Definition()
static G4PionZero * Definition()
Definition: G4PionZero.cc:55
static G4KaonZeroLong * Definition()
static G4AntiNeutrinoTau * Definition()
static G4NeutrinoMu * Definition()
Definition: G4NeutrinoMu.cc:49
static G4AntiAlpha * Definition()
Definition: G4AntiAlpha.cc:49
static G4AntiNeutrinoMu * Definition()
static G4Dineutron * Definition()
Definition: G4Dineutron.cc:68
static G4OmegaMinus * Definition()
Definition: G4OmegaMinus.cc:53
G4double GetPDGMass() const
static G4PionMinus * Definition()
Definition: G4PionMinus.cc:52
static G4KaonZeroShort * Definition()
static G4Neutron * Definition()
Definition: G4Neutron.cc:54
void fill(G4int ityp, Model model=DefaultModel)
G4InuclParticle & operator=(const G4InuclParticle &right)
static G4XiZero * Definition()
Definition: G4XiZero.cc:53
#define G4endl
Definition: G4ios.hh:61
static G4He3 * Definition()
Definition: G4He3.cc:50
static G4NeutrinoE * Definition()
Definition: G4NeutrinoE.cc:49
double G4double
Definition: G4Types.hh:76
static G4AntiNeutron * Definition()
virtual void print(std::ostream &os) const
static G4AntiDeuteron * Definition()
static G4Gamma * Definition()
Definition: G4Gamma.cc:49
static G4UnboundPN * Definition()
Definition: G4UnboundPN.cc:67
G4GLOB_DLL std::ostream G4cerr
CLHEP::HepLorentzVector G4LorentzVector