Geant4  10.00.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 
44 
45 #include "G4SystemOfUnits.hh"
46 #include "G4ParticleDefinition.hh"
47 #include "G4ParticleTypes.hh"
48 #include "G4Diproton.hh"
49 #include "G4UnboundPN.hh"
50 #include "G4Dineutron.hh"
51 #include "Randomize.hh"
52 
53 #include "G4InuclParticleNames.hh"
54 using namespace G4InuclParticleNames;
55 
56 
59  switch(ityp) {
60  case proton: return G4Proton::Definition(); break;
61  case neutron: return G4Neutron::Definition(); break;
62  case pionPlus: return G4PionPlus::Definition(); break;
63  case pionMinus: return G4PionMinus::Definition(); break;
64  case pionZero: return G4PionZero::Definition(); break;
65  case photon: return G4Gamma::Definition(); break;
66  case kaonPlus: return G4KaonPlus::Definition(); break;
67  case kaonMinus: return G4KaonMinus::Definition(); break;
68  case kaonZero: return G4KaonZero::Definition(); break;
69  case kaonZeroBar: return G4AntiKaonZero::Definition(); break;
70  case lambda: return G4Lambda::Definition(); break;
71  case sigmaPlus: return G4SigmaPlus::Definition(); break;
72  case sigmaZero: return G4SigmaZero::Definition(); break;
73  case sigmaMinus: return G4SigmaMinus::Definition(); break;
74  case xiZero: return G4XiZero::Definition(); break;
75  case xiMinus: return G4XiMinus::Definition(); break;
76  case omegaMinus: return G4OmegaMinus::Definition(); break;
77  // NOTE: The four light nuclei "particles" are actually G4Ions
78  case deuteron: return G4Deuteron::Definition(); break;
79  case triton: return G4Triton::Definition(); break;
80  case He3: return G4He3::Definition(); break;
81  case alpha: return G4Alpha::Definition(); break;
82  case antiProton: return G4AntiProton::Definition(); break;
83  case antiNeutron: return G4AntiNeutron::Definition(); break;
84  // NOTE: The the four light antinuclei "particles" are actually G4Ions
85  case antiDeuteron: return G4AntiDeuteron::Definition(); break;
86  case antiTriton: return G4AntiTriton::Definition(); break;
87  case antiHe3: return G4AntiHe3::Definition(); break;
88  case antiAlpha: return G4AntiAlpha::Definition(); break;
89  // NOTE: The three unbound dibaryons are local Bertini classes
90  case diproton: return G4Diproton::Definition(); break;
91  case unboundPN: return G4UnboundPN::Definition(); break;
92  case dineutron: return G4Dineutron::Definition(); break;
93  // Leptons are included for muon capture and future tau/neutrino physics
94  case electron: return G4Electron::Definition(); break;
95  case positron: return G4Positron::Definition(); break;
96  case electronNu: return G4NeutrinoE::Definition(); break;
97  case antiElectronNu: return G4AntiNeutrinoE::Definition(); break;
98  case muonMinus: return G4MuonMinus::Definition(); break;
99  case muonPlus: return G4MuonPlus::Definition(); break;
100  case muonNu: return G4NeutrinoMu::Definition(); break;
101  case antiMuonNu: return G4AntiNeutrinoMu::Definition(); break;
102  case tauMinus: return G4TauMinus::Definition(); break;
103  case tauPlus: return G4TauPlus::Definition(); break;
104  case tauNu: return G4NeutrinoTau::Definition(); break;
105  case antiTauNu: return G4AntiNeutrinoTau::Definition(); break;
106  default:
107  G4cerr << "G4InuclElementaryParticle::makeDefinition: unknown particle type "
108  << ityp << G4endl;
109  }
110 
111  return 0;
112 }
113 
114 // This is the inverse mapping to makeDefinition above
115 
117  if (pd == 0) return 0;
118  if (pd == G4Proton::Definition()) return proton;
119  if (pd == G4Neutron::Definition()) return neutron;
120  if (pd == G4PionPlus::Definition()) return pionPlus;
121  if (pd == G4PionMinus::Definition()) return pionMinus;
122  if (pd == G4PionZero::Definition()) return pionZero;
123  if (pd == G4Gamma::Definition()) return photon;
124  if (pd == G4KaonPlus::Definition()) return kaonPlus;
125  if (pd == G4KaonMinus::Definition()) return kaonMinus;
126  if (pd == G4KaonZero::Definition()) return kaonZero;
127  if (pd == G4AntiKaonZero::Definition()) return kaonZeroBar;
128  if (pd == G4Lambda::Definition()) return lambda;
129  if (pd == G4SigmaPlus::Definition()) return sigmaPlus;
130  if (pd == G4SigmaZero::Definition()) return sigmaZero;
131  if (pd == G4SigmaMinus::Definition()) return sigmaMinus;
132  if (pd == G4XiZero::Definition()) return xiZero;
133  if (pd == G4XiMinus::Definition()) return xiMinus;
134  if (pd == G4OmegaMinus::Definition()) return omegaMinus;
135  // NOTE: The four light nuclei "particles" are actually G4Ions
136  if (pd == G4Deuteron::Definition()) return deuteron;
137  if (pd == G4Triton::Definition()) return triton;
138  if (pd == G4He3::Definition()) return He3;
139  if (pd == G4Alpha::Definition()) return alpha;
140  if (pd == G4AntiProton::Definition()) return antiProton;
141  if (pd == G4AntiNeutron::Definition()) return antiNeutron;
142  // NOTE: The the four light antinuclei "particles" are actually G4Ions
143  if (pd == G4AntiDeuteron::Definition()) return antiDeuteron;
144  if (pd == G4AntiTriton::Definition()) return antiTriton;
145  if (pd == G4AntiHe3::Definition()) return antiHe3;
146  if (pd == G4AntiAlpha::Definition()) return antiAlpha;
147  // NOTE: The three unbound dibaryons are local Bertini classes
148  if (pd == G4Diproton::Definition()) return diproton;
149  if (pd == G4UnboundPN::Definition()) return unboundPN;
150  if (pd == G4Dineutron::Definition()) return dineutron;
151 
152  if (pd == G4Electron::Definition()) return electron;
153  if (pd == G4Positron::Definition()) return positron;
154  if (pd == G4NeutrinoE::Definition()) return electronNu;
155  if (pd == G4AntiNeutrinoE::Definition()) return antiElectronNu;
156  if (pd == G4MuonMinus::Definition()) return muonMinus;
157  if (pd == G4MuonPlus::Definition()) return muonPlus;
158  if (pd == G4NeutrinoMu::Definition()) return muonNu;
159  if (pd == G4AntiNeutrinoMu::Definition()) return antiMuonNu;
160  if (pd == G4TauMinus::Definition()) return tauMinus;
161  if (pd == G4TauPlus::Definition()) return tauPlus;
162  if (pd == G4NeutrinoTau::Definition()) return tauNu;
163  if (pd == G4AntiNeutrinoTau::Definition()) return antiTauNu;
164 
165  // Weak neutral kaons must be mixed back to strong (strangeness states)
167  return ((G4UniformRand() > 0.5) ? kaonZero : kaonZeroBar);
168  }
169 
170  return 0; // Unknown objects return zero (e.g., nuclei)
171 }
172 
174  setDefinition(makeDefinition(ityp));
175 }
176 
177 
178 // Overwrite data structure (avoids creating/copying temporaries)
179 
181  G4InuclParticle::Model model) {
182  setType(ityp);
183  setMomentum(mom);
184  setModel(model);
185 }
186 
188  G4InuclParticle::Model model) {
189  setType(ityp);
190  setKineticEnergy(ekin);
191  setModel(model);
192 }
193 
196  G4InuclParticle::Model model) {
197  setDefinition(pd);
198  setMomentum(mom);
199  setModel(model);
200 }
201 
202 
203 // Assignment operator for use with std::sort()
207  return *this;
208 }
209 
210 
212  G4ParticleDefinition* pd = makeDefinition(ityp);
213  return pd ? (pd->GetQuarkContent(3) - pd->GetAntiQuarkContent(3)) : 0;
214 }
215 
217  G4ParticleDefinition* pd = makeDefinition(ityp);
218  return pd ? pd->GetPDGMass()*MeV/GeV : 0.0; // From G4 to Bertini units
219 }
220 
221 
222 // Print particle parameters
223 
224 void G4InuclElementaryParticle::print(std::ostream& os) const {
226  os << G4endl << " Particle: " << getDefinition()->GetParticleName()
227  << " type " << type() << " mass " << getMass()
228  << " ekin " << getKineticEnergy();
229 }
230 
static G4SigmaZero * Definition()
Definition: G4SigmaZero.cc:52
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 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:87
virtual void print(std::ostream &os) const
static G4TauPlus * Definition()
Definition: G4TauPlus.cc:54
static G4MuonPlus * Definition()
Definition: G4MuonPlus.cc:52
static G4ParticleDefinition * makeDefinition(G4int ityp)
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:54
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