Geant4 11.2.2
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4PrimaryParticle Class Reference

#include <G4PrimaryParticle.hh>

Public Member Functions

 G4PrimaryParticle ()
 
 G4PrimaryParticle (G4int Pcode)
 
 G4PrimaryParticle (G4int Pcode, G4double px, G4double py, G4double pz)
 
 G4PrimaryParticle (G4int Pcode, G4double px, G4double py, G4double pz, G4double E)
 
 G4PrimaryParticle (const G4ParticleDefinition *Gcode)
 
 G4PrimaryParticle (const G4ParticleDefinition *Gcode, G4double px, G4double py, G4double pz)
 
 G4PrimaryParticle (const G4ParticleDefinition *Gcode, G4double px, G4double py, G4double pz, G4double E)
 
virtual ~G4PrimaryParticle ()
 
 G4PrimaryParticle (const G4PrimaryParticle &right)
 
G4PrimaryParticleoperator= (const G4PrimaryParticle &right)
 
G4bool operator== (const G4PrimaryParticle &right) const
 
G4bool operator!= (const G4PrimaryParticle &right) const
 
void * operator new (std::size_t)
 
void operator delete (void *aPrimaryParticle)
 
void Print () const
 
G4int GetPDGcode () const
 
void SetPDGcode (G4int Pcode)
 
G4ParticleDefinitionGetG4code () const
 
void SetG4code (const G4ParticleDefinition *Gcode)
 
const G4ParticleDefinitionGetParticleDefinition () const
 
void SetParticleDefinition (const G4ParticleDefinition *pdef)
 
G4double GetMass () const
 
void SetMass (G4double mas)
 
G4double GetCharge () const
 
void SetCharge (G4double chg)
 
G4double GetKineticEnergy () const
 
void SetKineticEnergy (G4double eKin)
 
const G4ThreeVectorGetMomentumDirection () const
 
void SetMomentumDirection (const G4ThreeVector &p)
 
G4double GetTotalMomentum () const
 
void Set4Momentum (G4double px, G4double py, G4double pz, G4double E)
 
G4double GetTotalEnergy () const
 
void SetTotalEnergy (G4double eTot)
 
G4ThreeVector GetMomentum () const
 
void SetMomentum (G4double px, G4double py, G4double pz)
 
G4double GetPx () const
 
G4double GetPy () const
 
G4double GetPz () const
 
G4PrimaryParticleGetNext () const
 
void SetNext (G4PrimaryParticle *np)
 
void ClearNext ()
 
G4PrimaryParticleGetDaughter () const
 
void SetDaughter (G4PrimaryParticle *np)
 
G4int GetTrackID () const
 
void SetTrackID (G4int id)
 
G4ThreeVector GetPolarization () const
 
void SetPolarization (const G4ThreeVector &pol)
 
void SetPolarization (G4double px, G4double py, G4double pz)
 
G4double GetPolX () const
 
G4double GetPolY () const
 
G4double GetPolZ () const
 
G4double GetWeight () const
 
void SetWeight (G4double w)
 
G4double GetProperTime () const
 
void SetProperTime (G4double t)
 
G4VUserPrimaryParticleInformationGetUserInformation () const
 
void SetUserInformation (G4VUserPrimaryParticleInformation *anInfo)
 

Detailed Description

Definition at line 66 of file G4PrimaryParticle.hh.

Constructor & Destructor Documentation

◆ G4PrimaryParticle() [1/8]

G4PrimaryParticle::G4PrimaryParticle ( )

Definition at line 46 of file G4PrimaryParticle.cc.

46: direction(0., 0., 1.) {}

Referenced by operator=().

◆ G4PrimaryParticle() [2/8]

G4PrimaryParticle::G4PrimaryParticle ( G4int Pcode)

Definition at line 48 of file G4PrimaryParticle.cc.

48 : direction(0., 0., 1.), PDGcode(Pcode)
49{
51 if (G4code != nullptr) {
52 mass = G4code->GetPDGMass();
53 charge = G4code->GetPDGCharge();
54 }
55}
G4ParticleDefinition * FindParticle(G4int PDGEncoding)
static G4ParticleTable * GetParticleTable()

◆ G4PrimaryParticle() [3/8]

G4PrimaryParticle::G4PrimaryParticle ( G4int Pcode,
G4double px,
G4double py,
G4double pz )

Definition at line 57 of file G4PrimaryParticle.cc.

58 : direction(0., 0., 1.), PDGcode(Pcode)
59{
61 if (G4code != nullptr) {
62 mass = G4code->GetPDGMass();
63 charge = G4code->GetPDGCharge();
64 }
65 SetMomentum(px, py, pz);
66}
void SetMomentum(G4double px, G4double py, G4double pz)

◆ G4PrimaryParticle() [4/8]

G4PrimaryParticle::G4PrimaryParticle ( G4int Pcode,
G4double px,
G4double py,
G4double pz,
G4double E )

Definition at line 68 of file G4PrimaryParticle.cc.

69 : direction(0., 0., 1.), PDGcode(Pcode)
70{
72 if (G4code != nullptr) {
73 mass = G4code->GetPDGMass();
74 charge = G4code->GetPDGCharge();
75 }
76 Set4Momentum(px, py, pz, E);
77}
void Set4Momentum(G4double px, G4double py, G4double pz, G4double E)

◆ G4PrimaryParticle() [5/8]

G4PrimaryParticle::G4PrimaryParticle ( const G4ParticleDefinition * Gcode)

Definition at line 79 of file G4PrimaryParticle.cc.

80 : G4code(Gcode), direction(0., 0., 1.)
81{
82 if (G4code != nullptr) {
83 PDGcode = Gcode->GetPDGEncoding();
84 mass = G4code->GetPDGMass();
85 charge = G4code->GetPDGCharge();
86 }
87}

◆ G4PrimaryParticle() [6/8]

G4PrimaryParticle::G4PrimaryParticle ( const G4ParticleDefinition * Gcode,
G4double px,
G4double py,
G4double pz )

Definition at line 89 of file G4PrimaryParticle.cc.

91 : G4code(Gcode), direction(0., 0., 1.)
92{
93 if (G4code != nullptr) {
94 PDGcode = Gcode->GetPDGEncoding();
95 mass = G4code->GetPDGMass();
96 charge = G4code->GetPDGCharge();
97 }
98 SetMomentum(px, py, pz);
99}

◆ G4PrimaryParticle() [7/8]

G4PrimaryParticle::G4PrimaryParticle ( const G4ParticleDefinition * Gcode,
G4double px,
G4double py,
G4double pz,
G4double E )

Definition at line 101 of file G4PrimaryParticle.cc.

103 : G4code(Gcode), direction(0., 0., 1.)
104{
105 if (G4code != nullptr) {
106 PDGcode = Gcode->GetPDGEncoding();
107 mass = G4code->GetPDGMass();
108 charge = G4code->GetPDGCharge();
109 }
110 Set4Momentum(px, py, pz, E);
111}

◆ ~G4PrimaryParticle()

G4PrimaryParticle::~G4PrimaryParticle ( )
virtual

Definition at line 165 of file G4PrimaryParticle.cc.

166{
167 delete nextParticle;
168 nextParticle = nullptr;
169
170 delete daughterParticle;
171 daughterParticle = nullptr;
172
173 delete userInfo;
174 userInfo = nullptr;
175}

◆ G4PrimaryParticle() [8/8]

G4PrimaryParticle::G4PrimaryParticle ( const G4PrimaryParticle & right)

Definition at line 113 of file G4PrimaryParticle.cc.

114{
115 *this = right;
116}

Member Function Documentation

◆ ClearNext()

void G4PrimaryParticle::ClearNext ( )
inline

Definition at line 360 of file G4PrimaryParticle.hh.

361{
362 nextParticle = nullptr;
363}

Referenced by G4PrimaryVertex::~G4PrimaryVertex().

◆ GetCharge()

G4double G4PrimaryParticle::GetCharge ( ) const
inline

Definition at line 200 of file G4PrimaryParticle.hh.

201{
202 return charge;
203}

Referenced by G4PrimaryTransformer::GenerateSingleTrack(), and G4PrimaryTransformer::SetDecayProducts().

◆ GetDaughter()

G4PrimaryParticle * G4PrimaryParticle::GetDaughter ( ) const
inline

Definition at line 285 of file G4PrimaryParticle.hh.

286{
287 return daughterParticle;
288}

Referenced by G4PrimaryTransformer::GenerateSingleTrack(), and G4PrimaryTransformer::SetDecayProducts().

◆ GetG4code()

G4ParticleDefinition * G4PrimaryParticle::GetG4code ( ) const
inline

Definition at line 210 of file G4PrimaryParticle.hh.

211{
212 return const_cast<G4ParticleDefinition*>(G4code);
213}

◆ GetKineticEnergy()

G4double G4PrimaryParticle::GetKineticEnergy ( ) const
inline

Definition at line 270 of file G4PrimaryParticle.hh.

271{
272 return kinE;
273}

Referenced by G4PrimaryTransformer::GenerateSingleTrack().

◆ GetMass()

G4double G4PrimaryParticle::GetMass ( ) const
inline

Definition at line 195 of file G4PrimaryParticle.hh.

196{
197 return mass;
198}

Referenced by G4PrimaryTransformer::GenerateSingleTrack(), and G4PrimaryTransformer::SetDecayProducts().

◆ GetMomentum()

G4ThreeVector G4PrimaryParticle::GetMomentum ( ) const
inline

◆ GetMomentumDirection()

const G4ThreeVector & G4PrimaryParticle::GetMomentumDirection ( ) const
inline

Definition at line 231 of file G4PrimaryParticle.hh.

232{
233 return direction;
234}

Referenced by G4PrimaryTransformer::GenerateSingleTrack().

◆ GetNext()

◆ GetParticleDefinition()

const G4ParticleDefinition * G4PrimaryParticle::GetParticleDefinition ( ) const
inline

Definition at line 215 of file G4PrimaryParticle.hh.

216{
217 return G4code;
218}

◆ GetPDGcode()

G4int G4PrimaryParticle::GetPDGcode ( ) const
inline

Definition at line 205 of file G4PrimaryParticle.hh.

206{
207 return PDGcode;
208}

Referenced by G4PrimaryTransformer::GenerateSingleTrack(), and G4PrimaryTransformer::SetDecayProducts().

◆ GetPolarization()

G4ThreeVector G4PrimaryParticle::GetPolarization ( ) const
inline

Definition at line 295 of file G4PrimaryParticle.hh.

296{
297 return G4ThreeVector(polX, polY, polZ);
298}
CLHEP::Hep3Vector G4ThreeVector

Referenced by G4PrimaryTransformer::GenerateSingleTrack().

◆ GetPolX()

G4double G4PrimaryParticle::GetPolX ( ) const
inline

Definition at line 300 of file G4PrimaryParticle.hh.

301{
302 return polX;
303}

Referenced by G4PrimaryTransformer::GenerateSingleTrack(), and G4PrimaryTransformer::SetDecayProducts().

◆ GetPolY()

G4double G4PrimaryParticle::GetPolY ( ) const
inline

Definition at line 305 of file G4PrimaryParticle.hh.

306{
307 return polY;
308}

Referenced by G4PrimaryTransformer::GenerateSingleTrack(), and G4PrimaryTransformer::SetDecayProducts().

◆ GetPolZ()

G4double G4PrimaryParticle::GetPolZ ( ) const
inline

Definition at line 310 of file G4PrimaryParticle.hh.

311{
312 return polZ;
313}

Referenced by G4PrimaryTransformer::GenerateSingleTrack(), and G4PrimaryTransformer::SetDecayProducts().

◆ GetProperTime()

G4double G4PrimaryParticle::GetProperTime ( ) const
inline

Definition at line 330 of file G4PrimaryParticle.hh.

331{
332 return properTime;
333}

Referenced by G4PrimaryTransformer::GenerateSingleTrack(), and G4PrimaryTransformer::SetDecayProducts().

◆ GetPx()

G4double G4PrimaryParticle::GetPx ( ) const
inline

Definition at line 241 of file G4PrimaryParticle.hh.

242{
243 return GetTotalMomentum() * direction.x();
244}
double x() const

◆ GetPy()

G4double G4PrimaryParticle::GetPy ( ) const
inline

Definition at line 246 of file G4PrimaryParticle.hh.

247{
248 return GetTotalMomentum() * direction.y();
249}
double y() const

◆ GetPz()

G4double G4PrimaryParticle::GetPz ( ) const
inline

Definition at line 251 of file G4PrimaryParticle.hh.

252{
253 return GetTotalMomentum() * direction.z();
254}
double z() const

◆ GetTotalEnergy()

G4double G4PrimaryParticle::GetTotalEnergy ( ) const
inline

Definition at line 256 of file G4PrimaryParticle.hh.

257{
258 if (mass < 0.) return kinE;
259 return kinE + mass;
260}

◆ GetTotalMomentum()

G4double G4PrimaryParticle::GetTotalMomentum ( ) const
inline

Definition at line 220 of file G4PrimaryParticle.hh.

221{
222 if (mass < 0.) return kinE;
223 return std::sqrt(kinE * (kinE + 2. * mass));
224}

Referenced by GetMomentum(), GetPx(), GetPy(), GetPz(), and Print().

◆ GetTrackID()

G4int G4PrimaryParticle::GetTrackID ( ) const
inline

Definition at line 290 of file G4PrimaryParticle.hh.

291{
292 return trackID;
293}

◆ GetUserInformation()

G4VUserPrimaryParticleInformation * G4PrimaryParticle::GetUserInformation ( ) const
inline

Definition at line 340 of file G4PrimaryParticle.hh.

341{
342 return userInfo;
343}

◆ GetWeight()

G4double G4PrimaryParticle::GetWeight ( ) const
inline

Definition at line 315 of file G4PrimaryParticle.hh.

316{
317 return Weight0;
318}

Referenced by G4PrimaryTransformer::GenerateSingleTrack().

◆ operator delete()

void G4PrimaryParticle::operator delete ( void * aPrimaryParticle)
inline

Definition at line 190 of file G4PrimaryParticle.hh.

191{
192 aPrimaryParticleAllocator()->FreeSingle((G4PrimaryParticle*)aPrimaryParticle);
193}
G4PART_DLL G4Allocator< G4PrimaryParticle > *& aPrimaryParticleAllocator()

◆ operator new()

void * G4PrimaryParticle::operator new ( std::size_t )
inline

Definition at line 182 of file G4PrimaryParticle.hh.

183{
184 if (aPrimaryParticleAllocator() == nullptr) {
186 }
187 return (void*)aPrimaryParticleAllocator()->MallocSingle();
188}

◆ operator!=()

G4bool G4PrimaryParticle::operator!= ( const G4PrimaryParticle & right) const

Definition at line 160 of file G4PrimaryParticle.cc.

161{
162 return (this != &right);
163}

◆ operator=()

G4PrimaryParticle & G4PrimaryParticle::operator= ( const G4PrimaryParticle & right)

Definition at line 118 of file G4PrimaryParticle.cc.

119{
120 if (this != &right) {
121 PDGcode = right.PDGcode;
122 G4code = right.G4code;
123 direction = right.direction;
124 kinE = right.kinE;
125 delete nextParticle;
126 if (right.nextParticle == nullptr) {
127 nextParticle = nullptr;
128 }
129 else {
130 nextParticle = new G4PrimaryParticle(*right.nextParticle);
131 }
132 delete daughterParticle;
133 if (right.daughterParticle == nullptr) {
134 daughterParticle = nullptr;
135 }
136 else {
137 daughterParticle = new G4PrimaryParticle(*right.daughterParticle);
138 }
139 trackID = right.trackID;
140 mass = right.mass;
141 charge = right.charge;
142 polX = right.polX;
143 polY = right.polY;
144 polZ = right.polZ;
145 Weight0 = right.Weight0;
146 properTime = right.properTime;
147
148 // userInfo cannot be copied
149 userInfo = nullptr;
150 }
151
152 return *this;
153}

◆ operator==()

G4bool G4PrimaryParticle::operator== ( const G4PrimaryParticle & right) const

Definition at line 155 of file G4PrimaryParticle.cc.

156{
157 return (this == &right);
158}

◆ Print()

void G4PrimaryParticle::Print ( ) const

Definition at line 232 of file G4PrimaryParticle.cc.

233{
234 G4cout << "==== PDGcode " << PDGcode << " Particle name ";
235 if (G4code != nullptr) {
236 G4cout << G4code->GetParticleName() << G4endl;
237 }
238 else {
239 G4cout << " is not defined in G4." << G4endl;
240 }
241 G4cout << " Assigned charge : " << charge / eplus << G4endl;
242 G4cout << " Momentum ( " << GetTotalMomentum() * direction.x() / GeV << "[GeV/c], "
243 << GetTotalMomentum() * direction.y() / GeV << "[GeV/c], "
244 << GetTotalMomentum() * direction.z() / GeV << "[GeV/c] )" << G4endl;
245 G4cout << " kinetic Energy : " << kinE / GeV << " [GeV]" << G4endl;
246 if (mass >= 0.) {
247 G4cout << " Mass : " << mass / GeV << " [GeV]" << G4endl;
248 }
249 else {
250 G4cout << " Mass is not assigned " << G4endl;
251 }
252 G4cout << " Polarization ( " << polX << ", " << polY << ", " << polZ << " )" << G4endl;
253 G4cout << " Weight : " << Weight0 << G4endl;
254 if (properTime >= 0.0) {
255 G4cout << " PreAssigned proper decay time : " << properTime / ns << " [ns] " << G4endl;
256 }
257 if (userInfo != nullptr) {
258 userInfo->Print();
259 }
260 if (daughterParticle != nullptr) {
261 G4cout << ">>>> Daughters" << G4endl;
262 daughterParticle->Print();
263 }
264 if (nextParticle != nullptr) {
265 nextParticle->Print();
266 }
267 else {
268 G4cout << "<<<< End of link" << G4endl;
269 }
270}
#define G4endl
Definition G4ios.hh:67
G4GLOB_DLL std::ostream G4cout
const G4String & GetParticleName() const
virtual void Print() const =0

Referenced by Print(), and G4PrimaryVertex::Print().

◆ Set4Momentum()

void G4PrimaryParticle::Set4Momentum ( G4double px,
G4double py,
G4double pz,
G4double E )

Definition at line 191 of file G4PrimaryParticle.cc.

192{
193 G4double pmom = std::sqrt(px * px + py * py + pz * pz);
194 if (pmom > 0.0) {
195 direction.setX(px / pmom);
196 direction.setY(py / pmom);
197 direction.setZ(pz / pmom);
198 }
199 G4double mas2 = E * E - pmom * pmom;
200 if (mas2 >= 0.) {
201 mass = std::sqrt(mas2);
202 }
203 else {
204 if (G4code != nullptr) {
205 mass = G4code->GetPDGMass();
206 }
207 E = std::sqrt(pmom * pmom + mass * mass);
208 }
209 kinE = E - mass;
210}
double G4double
Definition G4Types.hh:83
void setY(double)
void setZ(double)
void setX(double)

Referenced by G4PrimaryParticle(), and G4PrimaryParticle().

◆ SetCharge()

void G4PrimaryParticle::SetCharge ( G4double chg)
inline

Definition at line 385 of file G4PrimaryParticle.hh.

386{
387 charge = chg;
388}

◆ SetDaughter()

void G4PrimaryParticle::SetDaughter ( G4PrimaryParticle * np)
inline

Definition at line 365 of file G4PrimaryParticle.hh.

366{
367 if (daughterParticle == nullptr) {
368 daughterParticle = np;
369 }
370 else {
371 daughterParticle->SetNext(np);
372 }
373}
void SetNext(G4PrimaryParticle *np)

Referenced by G4HEPEvtInterface::GeneratePrimaryVertex().

◆ SetG4code()

void G4PrimaryParticle::SetG4code ( const G4ParticleDefinition * Gcode)
inline

Definition at line 345 of file G4PrimaryParticle.hh.

346{
348}
void SetParticleDefinition(const G4ParticleDefinition *pdef)

◆ SetKineticEnergy()

void G4PrimaryParticle::SetKineticEnergy ( G4double eKin)
inline

Definition at line 275 of file G4PrimaryParticle.hh.

276{
277 kinE = eKin;
278}

Referenced by G4RTPrimaryGeneratorAction::GeneratePrimaries().

◆ SetMass()

void G4PrimaryParticle::SetMass ( G4double mas)
inline

Definition at line 380 of file G4PrimaryParticle.hh.

381{
382 mass = mas;
383}

Referenced by G4RTPrimaryGeneratorAction::GeneratePrimaries().

◆ SetMomentum()

void G4PrimaryParticle::SetMomentum ( G4double px,
G4double py,
G4double pz )

Definition at line 177 of file G4PrimaryParticle.cc.

178{
179 if ((mass < 0.) && (G4code != nullptr)) {
180 mass = G4code->GetPDGMass();
181 }
182 G4double pmom = std::sqrt(px * px + py * py + pz * pz);
183 if (pmom > 0.0) {
184 direction.setX(px / pmom);
185 direction.setY(py / pmom);
186 direction.setZ(pz / pmom);
187 }
188 kinE = std::sqrt(px * px + py * py + pz * pz + mass * mass) - mass;
189}

Referenced by G4PrimaryParticle(), and G4PrimaryParticle().

◆ SetMomentumDirection()

void G4PrimaryParticle::SetMomentumDirection ( const G4ThreeVector & p)
inline

Definition at line 236 of file G4PrimaryParticle.hh.

237{
238 direction = p;
239}

Referenced by G4RTPrimaryGeneratorAction::GeneratePrimaries().

◆ SetNext()

void G4PrimaryParticle::SetNext ( G4PrimaryParticle * np)
inline

Definition at line 350 of file G4PrimaryParticle.hh.

351{
352 if (nextParticle == nullptr) {
353 nextParticle = np;
354 }
355 else {
356 nextParticle->SetNext(np);
357 }
358}

Referenced by SetDaughter(), SetNext(), and G4PrimaryVertex::SetPrimary().

◆ SetParticleDefinition()

void G4PrimaryParticle::SetParticleDefinition ( const G4ParticleDefinition * pdef)

Definition at line 222 of file G4PrimaryParticle.cc.

223{
224 G4code = Gcode;
225 if (G4code != nullptr) {
226 PDGcode = Gcode->GetPDGEncoding();
227 mass = G4code->GetPDGMass();
228 charge = G4code->GetPDGCharge();
229 }
230}

Referenced by SetG4code().

◆ SetPDGcode()

void G4PrimaryParticle::SetPDGcode ( G4int Pcode)

Definition at line 212 of file G4PrimaryParticle.cc.

213{
214 PDGcode = Pcode;
216 if (G4code != nullptr) {
217 mass = G4code->GetPDGMass();
218 charge = G4code->GetPDGCharge();
219 }
220}

◆ SetPolarization() [1/2]

void G4PrimaryParticle::SetPolarization ( const G4ThreeVector & pol)
inline

Definition at line 397 of file G4PrimaryParticle.hh.

398{
399 polX = pol.x();
400 polY = pol.y();
401 polZ = pol.z();
402}

Referenced by G4RTPrimaryGeneratorAction::GeneratePrimaries().

◆ SetPolarization() [2/2]

void G4PrimaryParticle::SetPolarization ( G4double px,
G4double py,
G4double pz )
inline

Definition at line 390 of file G4PrimaryParticle.hh.

391{
392 polX = px;
393 polY = py;
394 polZ = pz;
395}

◆ SetProperTime()

void G4PrimaryParticle::SetProperTime ( G4double t)
inline

Definition at line 325 of file G4PrimaryParticle.hh.

326{
327 properTime = t;
328}

◆ SetTotalEnergy()

void G4PrimaryParticle::SetTotalEnergy ( G4double eTot)
inline

Definition at line 262 of file G4PrimaryParticle.hh.

263{
264 if (mass < 0.)
265 kinE = eTot;
266 else
267 kinE = eTot - mass;
268}

◆ SetTrackID()

void G4PrimaryParticle::SetTrackID ( G4int id)
inline

Definition at line 375 of file G4PrimaryParticle.hh.

376{
377 trackID = id;
378}

Referenced by G4PrimaryTransformer::GenerateSingleTrack().

◆ SetUserInformation()

void G4PrimaryParticle::SetUserInformation ( G4VUserPrimaryParticleInformation * anInfo)
inline

Definition at line 335 of file G4PrimaryParticle.hh.

336{
337 userInfo = anInfo;
338}

◆ SetWeight()

void G4PrimaryParticle::SetWeight ( G4double w)
inline

Definition at line 320 of file G4PrimaryParticle.hh.

321{
322 Weight0 = w;
323}

The documentation for this class was generated from the following files: