Geant4 10.7.0
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.

47 : direction(0.,0.,1.)
48{
49}

Referenced by operator=().

◆ G4PrimaryParticle() [2/8]

G4PrimaryParticle::G4PrimaryParticle ( G4int  Pcode)

Definition at line 52 of file G4PrimaryParticle.cc.

53 : direction(0.,0.,1.), PDGcode(Pcode)
54{
56 if (G4code != nullptr)
57 {
58 mass = G4code->GetPDGMass();
59 charge = G4code->GetPDGCharge();
60 }
61}
G4double GetPDGCharge() const
G4ParticleDefinition * FindParticle(G4int PDGEncoding)
static G4ParticleTable * GetParticleTable()

◆ G4PrimaryParticle() [3/8]

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

Definition at line 64 of file G4PrimaryParticle.cc.

66 : direction(0.,0.,1.), PDGcode(Pcode)
67{
69 if (G4code != nullptr)
70 {
71 mass = G4code->GetPDGMass();
72 charge = G4code->GetPDGCharge();
73 }
74 SetMomentum( px, py, pz);
75}
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 78 of file G4PrimaryParticle.cc.

81 : direction(0.,0.,1.), PDGcode(Pcode)
82{
84 if (G4code != nullptr)
85 {
86 mass = G4code->GetPDGMass();
87 charge = G4code->GetPDGCharge();
88 }
89 Set4Momentum( px, py, pz, E);
90}
void Set4Momentum(G4double px, G4double py, G4double pz, G4double E)

◆ G4PrimaryParticle() [5/8]

G4PrimaryParticle::G4PrimaryParticle ( const G4ParticleDefinition Gcode)

Definition at line 93 of file G4PrimaryParticle.cc.

94 : G4code(Gcode), direction(0.,0.,1.)
95{
96 if (G4code != nullptr)
97 {
98 PDGcode = Gcode->GetPDGEncoding();
99 mass = G4code->GetPDGMass();
100 charge = G4code->GetPDGCharge();
101 }
102}

◆ G4PrimaryParticle() [6/8]

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

Definition at line 105 of file G4PrimaryParticle.cc.

107 : G4code(Gcode), direction(0.,0.,1.)
108{
109 if (G4code != nullptr)
110 {
111 PDGcode = Gcode->GetPDGEncoding();
112 mass = G4code->GetPDGMass();
113 charge = G4code->GetPDGCharge();
114 }
115 SetMomentum( px, py, pz);
116}

◆ G4PrimaryParticle() [7/8]

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

Definition at line 119 of file G4PrimaryParticle.cc.

121 : G4code(Gcode), direction(0.,0.,1.)
122{
123 if (G4code != nullptr)
124 {
125 PDGcode = Gcode->GetPDGEncoding();
126 mass = G4code->GetPDGMass();
127 charge = G4code->GetPDGCharge();
128 }
129 Set4Momentum( px, py, pz, E);
130}

◆ ~G4PrimaryParticle()

G4PrimaryParticle::~G4PrimaryParticle ( )
virtual

Definition at line 195 of file G4PrimaryParticle.cc.

196{
197 delete nextParticle;
198 nextParticle = nullptr;
199
200 delete daughterParticle;
201 daughterParticle = nullptr;
202
203 delete userInfo;
204 userInfo = nullptr;
205}

◆ G4PrimaryParticle() [8/8]

G4PrimaryParticle::G4PrimaryParticle ( const G4PrimaryParticle right)

Definition at line 133 of file G4PrimaryParticle.cc.

134{
135 *this = right;
136}

Member Function Documentation

◆ ClearNext()

void G4PrimaryParticle::ClearNext ( )
inline

Definition at line 397 of file G4PrimaryParticle.hh.

398{
399 nextParticle = nullptr;
400}

Referenced by G4PrimaryVertex::~G4PrimaryVertex().

◆ GetCharge()

G4double G4PrimaryParticle::GetCharge ( ) const
inline

Definition at line 212 of file G4PrimaryParticle.hh.

213{
214 return charge;
215}

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

◆ GetDaughter()

G4PrimaryParticle * G4PrimaryParticle::GetDaughter ( ) const
inline

Definition at line 310 of file G4PrimaryParticle.hh.

311{
312 return daughterParticle;
313}

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

◆ GetG4code()

G4ParticleDefinition * G4PrimaryParticle::GetG4code ( ) const
inline

Definition at line 224 of file G4PrimaryParticle.hh.

225{
226 return const_cast<G4ParticleDefinition*>(G4code);
227}

◆ GetKineticEnergy()

G4double G4PrimaryParticle::GetKineticEnergy ( ) const
inline

Definition at line 292 of file G4PrimaryParticle.hh.

293{
294 return kinE;
295}

Referenced by G4PrimaryTransformer::GenerateSingleTrack().

◆ GetMass()

G4double G4PrimaryParticle::GetMass ( ) const
inline

Definition at line 206 of file G4PrimaryParticle.hh.

207{
208 return mass;
209}

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

◆ GetMomentum()

G4ThreeVector G4PrimaryParticle::GetMomentum ( ) const
inline

◆ GetMomentumDirection()

const G4ThreeVector & G4PrimaryParticle::GetMomentumDirection ( ) const
inline

Definition at line 249 of file G4PrimaryParticle.hh.

250{
251 return direction;
252}

Referenced by G4PrimaryTransformer::GenerateSingleTrack().

◆ GetNext()

◆ GetParticleDefinition()

const G4ParticleDefinition * G4PrimaryParticle::GetParticleDefinition ( ) const
inline

Definition at line 230 of file G4PrimaryParticle.hh.

231{
232 return G4code;
233}

◆ GetPDGcode()

G4int G4PrimaryParticle::GetPDGcode ( ) const
inline

Definition at line 218 of file G4PrimaryParticle.hh.

219{
220 return PDGcode;
221}

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

◆ GetPolarization()

G4ThreeVector G4PrimaryParticle::GetPolarization ( ) const
inline

Definition at line 322 of file G4PrimaryParticle.hh.

323{
324 return G4ThreeVector(polX,polY,polZ);
325}
CLHEP::Hep3Vector G4ThreeVector

Referenced by G4PrimaryTransformer::GenerateSingleTrack().

◆ GetPolX()

G4double G4PrimaryParticle::GetPolX ( ) const
inline

Definition at line 328 of file G4PrimaryParticle.hh.

329{
330 return polX;
331}

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

◆ GetPolY()

G4double G4PrimaryParticle::GetPolY ( ) const
inline

Definition at line 334 of file G4PrimaryParticle.hh.

335{
336 return polY;
337}

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

◆ GetPolZ()

G4double G4PrimaryParticle::GetPolZ ( ) const
inline

Definition at line 340 of file G4PrimaryParticle.hh.

341{
342 return polZ;
343}

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

◆ GetProperTime()

G4double G4PrimaryParticle::GetProperTime ( ) const
inline

Definition at line 364 of file G4PrimaryParticle.hh.

365{
366 return properTime;
367}

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

◆ GetPx()

G4double G4PrimaryParticle::GetPx ( ) const
inline

Definition at line 261 of file G4PrimaryParticle.hh.

262{
263 return GetTotalMomentum()*direction.x();
264}
double x() const

◆ GetPy()

G4double G4PrimaryParticle::GetPy ( ) const
inline

Definition at line 267 of file G4PrimaryParticle.hh.

268{
269 return GetTotalMomentum()*direction.y();
270}
double y() const

◆ GetPz()

G4double G4PrimaryParticle::GetPz ( ) const
inline

Definition at line 273 of file G4PrimaryParticle.hh.

274{
275 return GetTotalMomentum()*direction.z();
276}
double z() const

◆ GetTotalEnergy()

G4double G4PrimaryParticle::GetTotalEnergy ( ) const
inline

Definition at line 278 of file G4PrimaryParticle.hh.

279{
280 if (mass<0.) return kinE;
281 else return kinE+mass;
282}

◆ GetTotalMomentum()

G4double G4PrimaryParticle::GetTotalMomentum ( ) const
inline

Definition at line 236 of file G4PrimaryParticle.hh.

237{
238 if (mass<0.) return kinE;
239 else return std::sqrt(kinE*(kinE+2.*mass));
240}

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

◆ GetTrackID()

G4int G4PrimaryParticle::GetTrackID ( ) const
inline

Definition at line 316 of file G4PrimaryParticle.hh.

317{
318 return trackID;
319}

◆ GetUserInformation()

G4VUserPrimaryParticleInformation * G4PrimaryParticle::GetUserInformation ( ) const
inline

Definition at line 378 of file G4PrimaryParticle.hh.

379{
380 return userInfo;
381}

◆ GetWeight()

G4double G4PrimaryParticle::GetWeight ( ) const
inline

Definition at line 346 of file G4PrimaryParticle.hh.

347{
348 return Weight0;
349}

Referenced by G4PrimaryTransformer::GenerateSingleTrack().

◆ operator delete()

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

Definition at line 199 of file G4PrimaryParticle.hh.

200{
202 ->FreeSingle((G4PrimaryParticle*) aPrimaryParticle);
203}
G4PART_DLL G4Allocator< G4PrimaryParticle > *& aPrimaryParticleAllocator()

◆ operator new()

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

Definition at line 189 of file G4PrimaryParticle.hh.

190{
191 if (aPrimaryParticleAllocator() == nullptr)
192 {
194 }
195 return (void*) aPrimaryParticleAllocator()->MallocSingle();
196}

◆ operator!=()

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

Definition at line 189 of file G4PrimaryParticle.cc.

190{
191 return (this!=&right);
192}

◆ operator=()

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

Definition at line 140 of file G4PrimaryParticle.cc.

141{
142 if (this != &right)
143 {
144 PDGcode = right.PDGcode;
145 G4code = right.G4code;
146 direction = right.direction;
147 kinE = right.kinE;
148 if (nextParticle != nullptr) delete nextParticle;
149 if ( right.nextParticle == nullptr )
150 {
151 nextParticle = nullptr;
152 }
153 else
154 {
155 nextParticle = new G4PrimaryParticle(*right.nextParticle);
156 }
157 if (daughterParticle != nullptr) delete daughterParticle;
158 if ( right.daughterParticle == nullptr )
159 {
160 daughterParticle = nullptr;
161 }
162 else
163 {
164 daughterParticle = new G4PrimaryParticle(*right.daughterParticle);
165 }
166 trackID = right.trackID;
167 mass = right.mass;
168 charge = right.charge;
169 polX = right.polX;
170 polY = right.polY;
171 polZ = right.polZ;
172 Weight0 = right.Weight0;
173 properTime = right.properTime;
174
175 // userInfo cannot be copied
176 userInfo = nullptr;
177 }
178
179 return *this;
180}

◆ operator==()

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

Definition at line 183 of file G4PrimaryParticle.cc.

184{
185 return (this==&right);
186}

◆ Print()

void G4PrimaryParticle::Print ( ) const

Definition at line 277 of file G4PrimaryParticle.cc.

278{
279 G4cout << "==== PDGcode " << PDGcode << " Particle name ";
280 if(G4code != nullptr)
281 {
282 G4cout << G4code->GetParticleName() << G4endl;
283 }
284 else
285 {
286 G4cout << " is not defined in G4." << G4endl;
287 }
288 G4cout << " Assigned charge : " << charge/eplus << G4endl;
289 G4cout << " Momentum ( "
290 << GetTotalMomentum()*direction.x()/GeV << "[GeV/c], "
291 << GetTotalMomentum()*direction.y()/GeV << "[GeV/c], "
292 << GetTotalMomentum()*direction.z()/GeV << "[GeV/c] )" << G4endl;
293 G4cout << " kinetic Energy : " << kinE/GeV << " [GeV]" << G4endl;
294 if(mass>=0.)
295 {
296 G4cout << " Mass : " << mass/GeV << " [GeV]" << G4endl;
297 }
298 else
299 {
300 G4cout << " Mass is not assigned " << G4endl;
301 }
302 G4cout << " Polarization ( "
303 << polX << ", "
304 << polY << ", "
305 << polZ << " )"
306 << G4endl;
307 G4cout << " Weight : " << Weight0 << G4endl;
308 if(properTime>=0.0)
309 {
310 G4cout << " PreAssigned proper decay time : "
311 << properTime/ns << " [ns] " << G4endl;
312 }
313 if(userInfo != 0) { userInfo->Print(); }
314 if(daughterParticle != nullptr)
315 {
316 G4cout << ">>>> Daughters" << G4endl;
317 daughterParticle->Print();
318 }
319 if(nextParticle != nullptr)
320 {
321 nextParticle->Print();
322 }
323 else
324 {
325 G4cout << "<<<< End of link" << G4endl;
326 }
327}
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
const G4String & GetParticleName() const
virtual void Print() const =0
#define ns
Definition: xmlparse.cc:614

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

◆ Set4Momentum()

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

Definition at line 225 of file G4PrimaryParticle.cc.

227{
228 G4double pmom = std::sqrt(px*px+py*py+pz*pz);
229 if (pmom>0.0)
230 {
231 direction.setX(px/pmom);
232 direction.setY(py/pmom);
233 direction.setZ(pz/pmom);
234 }
235 G4double mas2 = E*E - pmom*pmom;
236 if(mas2>=0.)
237 {
238 mass = std::sqrt(mas2);
239 }
240 else
241 {
242 if (G4code != nullptr)
243 {
244 mass = G4code->GetPDGMass();
245 }
246 E = std::sqrt(pmom*pmom+mass*mass);
247 }
248 kinE = E - mass;
249}
double G4double
Definition: G4Types.hh:83
void setY(double)
void setZ(double)
void setX(double)

Referenced by G4PrimaryParticle().

◆ SetCharge()

void G4PrimaryParticle::SetCharge ( G4double  chg)
inline

Definition at line 422 of file G4PrimaryParticle.hh.

423{
424 charge = chg;
425}

Referenced by G4ParticleGun::GeneratePrimaryVertex(), and G4SingleParticleSource::GeneratePrimaryVertex().

◆ SetDaughter()

void G4PrimaryParticle::SetDaughter ( G4PrimaryParticle np)
inline

Definition at line 403 of file G4PrimaryParticle.hh.

404{
405 if(daughterParticle == nullptr) { daughterParticle = np; }
406 else { daughterParticle->SetNext(np); }
407}
void SetNext(G4PrimaryParticle *np)

Referenced by G4HEPEvtInterface::GeneratePrimaryVertex().

◆ SetG4code()

void G4PrimaryParticle::SetG4code ( const G4ParticleDefinition Gcode)
inline

Definition at line 384 of file G4PrimaryParticle.hh.

385{
387}
void SetParticleDefinition(const G4ParticleDefinition *pdef)

◆ SetKineticEnergy()

void G4PrimaryParticle::SetKineticEnergy ( G4double  eKin)
inline

◆ SetMass()

◆ SetMomentum()

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

Definition at line 208 of file G4PrimaryParticle.cc.

209{
210 if ((mass<0.)&&(G4code!=0))
211 {
212 mass = G4code->GetPDGMass();
213 }
214 G4double pmom = std::sqrt(px*px+py*py+pz*pz);
215 if (pmom>0.0)
216 {
217 direction.setX(px/pmom);
218 direction.setY(py/pmom);
219 direction.setZ(pz/pmom);
220 }
221 kinE = std::sqrt(px*px+py*py+pz*pz+mass*mass)-mass;
222}

Referenced by G4PrimaryParticle(), and G4HEPEvtInterface::GeneratePrimaryVertex().

◆ SetMomentumDirection()

void G4PrimaryParticle::SetMomentumDirection ( const G4ThreeVector p)
inline

◆ SetNext()

void G4PrimaryParticle::SetNext ( G4PrimaryParticle np)
inline

Definition at line 390 of file G4PrimaryParticle.hh.

391{
392 if (nextParticle == nullptr) { nextParticle = np; }
393 else { nextParticle->SetNext(np); }
394}

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

◆ SetParticleDefinition()

void G4PrimaryParticle::SetParticleDefinition ( const G4ParticleDefinition pdef)

Definition at line 265 of file G4PrimaryParticle.cc.

266{
267 G4code = Gcode;
268 if (G4code != nullptr)
269 {
270 PDGcode = Gcode->GetPDGEncoding();
271 mass = G4code->GetPDGMass();
272 charge = G4code->GetPDGCharge();
273 }
274}

Referenced by SetG4code().

◆ SetPDGcode()

void G4PrimaryParticle::SetPDGcode ( G4int  Pcode)

Definition at line 252 of file G4PrimaryParticle.cc.

253{
254 PDGcode = Pcode;
256 if (G4code != nullptr)
257 {
258 mass = G4code->GetPDGMass();
259 charge = G4code->GetPDGCharge();
260 }
261}

◆ SetPolarization() [1/2]

void G4PrimaryParticle::SetPolarization ( const G4ThreeVector pol)
inline

Definition at line 436 of file G4PrimaryParticle.hh.

437{
438 polX = pol.x();
439 polY = pol.y();
440 polZ = pol.z();
441}

Referenced by G4RTPrimaryGeneratorAction::GeneratePrimaries(), G4ParticleGun::GeneratePrimaryVertex(), G4SingleParticleSource::GeneratePrimaryVertex(), and G4RayShooter::Shoot().

◆ SetPolarization() [2/2]

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

Definition at line 428 of file G4PrimaryParticle.hh.

429{
430 polX = px;
431 polY = py;
432 polZ = pz;
433}

◆ SetProperTime()

void G4PrimaryParticle::SetProperTime ( G4double  t)
inline

Definition at line 358 of file G4PrimaryParticle.hh.

359{
360 properTime = t;
361}

◆ SetTotalEnergy()

void G4PrimaryParticle::SetTotalEnergy ( G4double  eTot)
inline

Definition at line 285 of file G4PrimaryParticle.hh.

286{
287 if (mass<0.) kinE = eTot;
288 else kinE = eTot - mass;
289}

◆ SetTrackID()

void G4PrimaryParticle::SetTrackID ( G4int  id)
inline

Definition at line 410 of file G4PrimaryParticle.hh.

411{
412 trackID = id;
413}

Referenced by G4PrimaryTransformer::GenerateSingleTrack().

◆ SetUserInformation()

void G4PrimaryParticle::SetUserInformation ( G4VUserPrimaryParticleInformation anInfo)
inline

Definition at line 370 of file G4PrimaryParticle.hh.

372{
373 userInfo = anInfo;
374}

◆ SetWeight()

void G4PrimaryParticle::SetWeight ( G4double  w)
inline

Definition at line 352 of file G4PrimaryParticle.hh.

353{
354 Weight0 = w;
355}

Referenced by G4SingleParticleSource::GeneratePrimaryVertex().


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