Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
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$
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
43
44#include "G4SystemOfUnits.hh"
46#include "G4Proton.hh"
47#include "G4Neutron.hh"
48#include "G4PionPlus.hh"
49#include "G4PionMinus.hh"
50#include "G4PionZero.hh"
51#include "G4Gamma.hh"
52#include "G4KaonPlus.hh"
53#include "G4KaonMinus.hh"
54#include "G4KaonZero.hh"
55#include "G4KaonZeroLong.hh"
56#include "G4KaonZeroShort.hh"
57#include "G4AntiKaonZero.hh"
58#include "G4Lambda.hh"
59#include "G4SigmaPlus.hh"
60#include "G4SigmaZero.hh"
61#include "G4SigmaMinus.hh"
62#include "G4XiZero.hh"
63#include "G4XiMinus.hh"
64#include "G4OmegaMinus.hh"
65#include "G4Deuteron.hh"
66#include "G4Triton.hh"
67#include "G4He3.hh"
68#include "G4Alpha.hh"
69#include "G4AntiProton.hh"
70#include "G4AntiNeutron.hh"
71#include "G4AntiDeuteron.hh"
72#include "G4AntiTriton.hh"
73#include "G4AntiHe3.hh"
74#include "G4AntiAlpha.hh"
75#include "G4Deuteron.hh"
76#include "G4Diproton.hh"
77#include "G4UnboundPN.hh"
78#include "G4Dineutron.hh"
79#include "Randomize.hh"
80
82using namespace G4InuclParticleNames;
83
84
87 switch(ityp) {
88 case proton: return G4Proton::Definition(); break;
89 case neutron: return G4Neutron::Definition(); break;
90 case pionPlus: return G4PionPlus::Definition(); break;
91 case pionMinus: return G4PionMinus::Definition(); break;
92 case pionZero: return G4PionZero::Definition(); break;
93 case photon: return G4Gamma::Definition(); break;
94 case kaonPlus: return G4KaonPlus::Definition(); break;
95 case kaonMinus: return G4KaonMinus::Definition(); break;
96 case kaonZero: return G4KaonZero::Definition(); break;
97 case kaonZeroBar: return G4AntiKaonZero::Definition(); break;
98 case lambda: return G4Lambda::Definition(); break;
99 case sigmaPlus: return G4SigmaPlus::Definition(); break;
100 case sigmaZero: return G4SigmaZero::Definition(); break;
101 case sigmaMinus: return G4SigmaMinus::Definition(); break;
102 case xiZero: return G4XiZero::Definition(); break;
103 case xiMinus: return G4XiMinus::Definition(); break;
104 case omegaMinus: return G4OmegaMinus::Definition(); break;
105 // NOTE: The four light nuclei "particles" are actually G4Ions
106 case deuteron: return G4Deuteron::Definition(); break;
107 case triton: return G4Triton::Definition(); break;
108 case He3: return G4He3::Definition(); break;
109 case alpha: return G4Alpha::Definition(); break;
110 case antiProton: return G4AntiProton::Definition(); break;
111 case antiNeutron: return G4AntiNeutron::Definition(); break;
112 // NOTE: The the four light antinuclei "particles" are actually G4Ions
113 case antiDeuteron: return G4AntiDeuteron::Definition(); break;
114 case antiTriton: return G4AntiTriton::Definition(); break;
115 case antiHe3: return G4AntiHe3::Definition(); break;
116 case antiAlpha: return G4AntiAlpha::Definition(); break;
117 // NOTE: The three unbound dibaryons are local Bertini classes
118 case diproton: return G4Diproton::Definition(); break;
119 case unboundPN: return G4UnboundPN::Definition(); break;
120 case dineutron: return G4Dineutron::Definition(); break;
121 default:
122 G4cerr << " uups, unknown particle type " << ityp << G4endl;
123 }
124
125 return 0;
126}
127
128// This is the inverse mapping to makeDefinition above
129
131 if (pd == 0) return 0;
132 if (pd == G4Proton::Definition()) return proton;
133 if (pd == G4Neutron::Definition()) return neutron;
134 if (pd == G4PionPlus::Definition()) return pionPlus;
135 if (pd == G4PionMinus::Definition()) return pionMinus;
136 if (pd == G4PionZero::Definition()) return pionZero;
137 if (pd == G4Gamma::Definition()) return photon;
138 if (pd == G4KaonPlus::Definition()) return kaonPlus;
139 if (pd == G4KaonMinus::Definition()) return kaonMinus;
140 if (pd == G4KaonZero::Definition()) return kaonZero;
141 if (pd == G4AntiKaonZero::Definition()) return kaonZeroBar;
142 if (pd == G4Lambda::Definition()) return lambda;
143 if (pd == G4SigmaPlus::Definition()) return sigmaPlus;
144 if (pd == G4SigmaZero::Definition()) return sigmaZero;
145 if (pd == G4SigmaMinus::Definition()) return sigmaMinus;
146 if (pd == G4XiZero::Definition()) return xiZero;
147 if (pd == G4XiMinus::Definition()) return xiMinus;
148 if (pd == G4OmegaMinus::Definition()) return omegaMinus;
149 // NOTE: The four light nuclei "particles" are actually G4Ions
150 if (pd == G4Deuteron::Definition()) return deuteron;
151 if (pd == G4Triton::Definition()) return triton;
152 if (pd == G4He3::Definition()) return He3;
153 if (pd == G4Alpha::Definition()) return alpha;
154 if (pd == G4AntiProton::Definition()) return antiProton;
155 if (pd == G4AntiNeutron::Definition()) return antiNeutron;
156 // NOTE: The the four light antinuclei "particles" are actually G4Ions
157 if (pd == G4AntiDeuteron::Definition()) return antiDeuteron;
158 if (pd == G4AntiTriton::Definition()) return antiTriton;
159 if (pd == G4AntiHe3::Definition()) return antiHe3;
160 if (pd == G4AntiAlpha::Definition()) return antiAlpha;
161 // NOTE: The three unbound dibaryons are local Bertini classes
162 if (pd == G4Diproton::Definition()) return diproton;
163 if (pd == G4UnboundPN::Definition()) return unboundPN;
164 if (pd == G4Dineutron::Definition()) return dineutron;
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
176}
177
178
179// Overwrite data structure (avoids creating/copying temporaries)
180
183 setType(ityp);
184 setMomentum(mom);
185 setModel(model);
186}
187
190 setType(ityp);
191 setKineticEnergy(ekin);
192 setModel(model);
193}
194
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
214 return pd ? (pd->GetQuarkContent(3) - pd->GetAntiQuarkContent(3)) : 0;
215}
216
219 return pd ? pd->GetPDGMass()*MeV/GeV : 0.0; // From G4 to Bertini units
220}
221
222
223// Print particle parameters
224
225void G4InuclElementaryParticle::print(std::ostream& os) const {
227 os << G4endl << " Particle: " << getDefinition()->GetParticleName()
228 << " type " << type() << " mass " << getMass()
229 << " ekin " << getKineticEnergy();
230}
231
@ photon
@ neutron
double G4double
Definition: G4Types.hh:64
int G4int
Definition: G4Types.hh:66
#define G4endl
Definition: G4ios.hh:52
G4DLLIMPORT std::ostream G4cerr
#define G4UniformRand()
Definition: Randomize.hh:53
static G4Alpha * Definition()
Definition: G4Alpha.cc:49
static G4AntiAlpha * Definition()
Definition: G4AntiAlpha.cc:49
static G4AntiDeuteron * Definition()
static G4AntiHe3 * Definition()
Definition: G4AntiHe3.cc:50
static G4AntiKaonZero * Definition()
static G4AntiNeutron * Definition()
static G4AntiProton * Definition()
Definition: G4AntiProton.cc:51
static G4AntiTriton * Definition()
Definition: G4AntiTriton.cc:50
static G4Deuteron * Definition()
Definition: G4Deuteron.cc:50
static G4Dineutron * Definition()
Definition: G4Dineutron.cc:67
static G4Diproton * Definition()
Definition: G4Diproton.cc:67
static G4Gamma * Definition()
Definition: G4Gamma.cc:49
static G4He3 * Definition()
Definition: G4He3.cc:50
virtual void print(std::ostream &os) const
void fill(G4int ityp, Model model=DefaultModel)
G4InuclElementaryParticle & operator=(const G4InuclElementaryParticle &right)
static G4ParticleDefinition * makeDefinition(G4int ityp)
static G4double getParticleMass(G4int type)
G4ParticleDefinition * getDefinition() const
virtual void print(std::ostream &os) const
G4double getKineticEnergy() const
G4InuclParticle & operator=(const G4InuclParticle &right)
G4double getMass() const
void setKineticEnergy(G4double ekin)
void setMomentum(const G4LorentzVector &mom)
void setDefinition(G4ParticleDefinition *pd)
void setModel(Model model)
static G4KaonMinus * Definition()
Definition: G4KaonMinus.cc:54
static G4KaonPlus * Definition()
Definition: G4KaonPlus.cc:54
static G4KaonZeroLong * Definition()
static G4KaonZeroShort * Definition()
static G4KaonZero * Definition()
Definition: G4KaonZero.cc:53
static G4Lambda * Definition()
Definition: G4Lambda.cc:53
static G4Neutron * Definition()
Definition: G4Neutron.cc:54
static G4OmegaMinus * Definition()
Definition: G4OmegaMinus.cc:53
G4int GetQuarkContent(G4int flavor) const
const G4String & GetParticleName() const
G4int GetAntiQuarkContent(G4int flavor) const
static G4PionMinus * Definition()
Definition: G4PionMinus.cc:52
static G4PionPlus * Definition()
Definition: G4PionPlus.cc:52
static G4PionZero * Definition()
Definition: G4PionZero.cc:54
static G4Proton * Definition()
Definition: G4Proton.cc:49
static G4SigmaMinus * Definition()
Definition: G4SigmaMinus.cc:53
static G4SigmaPlus * Definition()
Definition: G4SigmaPlus.cc:53
static G4SigmaZero * Definition()
Definition: G4SigmaZero.cc:52
static G4Triton * Definition()
Definition: G4Triton.cc:50
static G4UnboundPN * Definition()
Definition: G4UnboundPN.cc:66
static G4XiMinus * Definition()
Definition: G4XiMinus.cc:53
static G4XiZero * Definition()
Definition: G4XiZero.cc:53