Geant4 11.2.2
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4DynamicParticle.hh
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// G4DynamicParticle
27//
28// Class description:
29//
30// A G4DynamicParticle aggregates the information to describe the dynamics
31// of a G4Particle, such as energy, momentum, polarization and proper time,
32// as well as the "particle definition", holding all the static information.
33// It contains the purely dynamic aspects of a moving particle.
34
35// History:
36// - 2 December 1995, G.Cosmo - first design, based on object model.
37// - 29 January 1996, M.Asai - first implementation.
38// - 1996 - 2007, H.Kurashige - revisions.
39// - 15 March 2019, M.Novak - log-kinetic energy value is computed only
40// on demand if its stored value is not up-to-date.
41// --------------------------------------------------------------------
42#ifndef G4DynamicParticle_hh
43#define G4DynamicParticle_hh 1
44
45#include "G4Allocator.hh"
47#include "G4Log.hh"
48#include "G4LorentzVector.hh"
50#include "G4ParticleMomentum.hh" // NOTE: means "momentum direction" not "momentum vector". It is a G4ThreeVector
51#include "G4ios.hh"
52#include "globals.hh"
53
56
57#include <cmath>
58
60class G4DecayProducts;
61
63{
64 public:
65 //- constructors
67
68 G4DynamicParticle(const G4ParticleDefinition* aParticleDefinition,
69 const G4ThreeVector& aMomentumDirection, G4double aKineticEnergy);
70 G4DynamicParticle(const G4ParticleDefinition* aParticleDefinition,
71 const G4ThreeVector& aParticleMomentum);
72 G4DynamicParticle(const G4ParticleDefinition* aParticleDefinition,
73 const G4LorentzVector& aParticleMomentum);
74 G4DynamicParticle(const G4ParticleDefinition* aParticleDefinition, G4double aTotalEnergy,
75 const G4ThreeVector& aParticleMomentum);
76 G4DynamicParticle(const G4ParticleDefinition* aParticleDefinition,
77 const G4ThreeVector& aMomentumDirection, G4double aKineticEnergy,
78 const G4double dynamicalMass);
79
81
82 //- destructor
84
85 //- operators
87 G4bool operator==(const G4DynamicParticle& right) const;
88 G4bool operator!=(const G4DynamicParticle& right) const;
89
90 //- Move constructor & operator
93
94 //- new/delete operators are oberloded to use G4Allocator
95 inline void* operator new(size_t);
96 inline void operator delete(void* aDynamicParticle);
97
98 //- Set/Get methods
99
100 // Returns the normalized direction of the momentum
101 inline const G4ThreeVector& GetMomentumDirection() const;
102
103 // Sets the normalized direction of the momentum
104 inline void SetMomentumDirection(const G4ThreeVector& aDirection);
105
106 // Sets the normalized direction of the momentum by coordinates
108
109 // Returns the current particle momentum vector
111
112 // set the current particle momentum vector
113 void SetMomentum(const G4ThreeVector& momentum);
114
115 // Returns the current particle energy-momentum 4vector
117
118 // Set the current particle energy-momentum 4vector
119 void Set4Momentum(const G4LorentzVector& momentum);
120
121 // Returns the module of the momentum vector
123
124 // Returns the total energy of the particle
125 inline G4double GetTotalEnergy() const;
126
127 // Returns the kinetic energy of a particle
129
130 // Returns:
131 // - natural logarithm of the particle kinetic energy (E_k) if E_k > 0
132 // - LOG_EKIN_MIN otherwise
134
135 // Sets the kinetic energy of a particle
136 inline void SetKineticEnergy(G4double aEnergy);
137
138 // Access Lorentz beta
139 inline G4double GetBeta() const;
140
141 // Returns the current particle proper time
142 inline G4double GetProperTime() const;
143
144 // Set the current particle Proper Time
146
147 // Set/Get polarization vector
148 inline const G4ThreeVector& GetPolarization() const;
149 inline void SetPolarization(const G4ThreeVector&);
150 inline void SetPolarization(G4double polX, G4double polY, G4double polZ);
151
152 // Set/Get dynamical mass
153 // The dynamical mass is set to PDG mass in default
154 inline G4double GetMass() const;
155 inline void SetMass(G4double mass);
156
157 // Set/Get dynamical charge
158 // The dynamical mass is set to PDG charge in default
159 inline G4double GetCharge() const;
160 inline void SetCharge(G4double charge);
161 inline void SetCharge(G4int chargeInUnitOfEplus);
162
163 // Set/Get dynamical spin
164 // The dynamical spin is set to PDG spin in default
165 inline G4double GetSpin() const;
166 inline void SetSpin(G4double spin);
167 inline void SetSpin(G4int spinInUnitOfHalfInteger);
168
169 // Set/Get dynamical MagneticMoment
170 // The dynamical mass is set to PDG MagneticMoment in default
172 inline void SetMagneticMoment(G4double magneticMoment);
173
174 // Get electron occupancy
175 // ElectronOccupancy is valid only if the particle is ion
177 inline G4int GetTotalOccupancy() const;
178 inline G4int GetOccupancy(G4int orbit) const;
179 inline void AddElectron(G4int orbit, G4int number = 1);
180 inline void RemoveElectron(G4int orbit, G4int number = 1);
181
182 // Set/Get particle definition
184 void SetDefinition(const G4ParticleDefinition* aParticleDefinition);
185
186 // Following method of GetDefinition() remains
187 // because of backward compatiblity. May be removed in future
189
190 // Set/Get pre-assigned decay channel
192 inline void SetPreAssignedDecayProducts(G4DecayProducts* aDecayProducts);
193
194 // Set/Get pre-assigned proper time when the particle will decay
197
198 // Print out information
199 // - mode 0 : default )(minimum)
200 // - mode 1 : 0 + electron occupancy
201 void DumpInfo(G4int mode = 0) const;
202
203 // Set/Get controle flag for output message
204 // - 0: Silent
205 // - 1: Warning message
206 // - 2: More
207 inline void SetVerboseLevel(G4int value);
208 inline G4int GetVerboseLevel() const;
209
211 inline void SetPDGcode(G4int c);
212
213 // Return the pointer to the corresponding G4PrimaryParticle object
214 // if this particle is a primary particle OR is defined as a
215 // pre-assigned decay product. Otherwise return nullptr.
217
218 // Return the PDG code of this particle. If the particle is known to
219 // Geant4, its PDG code defined in G4ParticleDefinition is returned.
220 // If it is unknown (i.e. PDG code in G4ParticleDefinition is 0), the
221 // PDG code defined in the corresponding primary particle or
222 // pre-assigned decay product will be returned if available.
223 // Otherwise (e.g. for geantino) returns 0.
224 inline G4int GetPDGcode() const;
225
226 protected:
229
230 private:
231 inline void ComputeBeta() const;
232
233 // The normalized momentum vector
234 G4ThreeVector theMomentumDirection;
235
236 G4ThreeVector thePolarization;
237
238 // Contains the static information of this particle
239 const G4ParticleDefinition* theParticleDefinition = nullptr;
240
241 G4ElectronOccupancy* theElectronOccupancy = nullptr;
242
243 G4DecayProducts* thePreAssignedDecayProducts = nullptr;
244
245 // This void pointer is used by G4EventManager to maintain the
246 // link between pre-assigned decay products and corresponding
247 // primary particle
248 G4PrimaryParticle* primaryParticle = nullptr;
249
250 G4double theKineticEnergy = 0.0;
251
252 mutable G4double theLogKineticEnergy = DBL_MAX;
253
254 mutable G4double theBeta = -1.0;
255
256 G4double theProperTime = 0.0;
257
258 G4double theDynamicalMass = 0.0;
259
260 G4double theDynamicalCharge = 0.0;
261
262 G4double theDynamicalSpin = 0.0;
263
264 G4double theDynamicalMagneticMoment = 0.0;
265
266 G4double thePreAssignedDecayTime = -1.0;
267
268 G4int verboseLevel = 1;
269
270 G4int thePDGcode = 0;
271};
272
273#include "G4DynamicParticle.icc"
274
275#endif
double G4double
Definition G4Types.hh:83
bool G4bool
Definition G4Types.hh:86
int G4int
Definition G4Types.hh:85
G4int GetTotalOccupancy() const
G4double GetMass() const
void SetPreAssignedDecayProducts(G4DecayProducts *aDecayProducts)
void SetPolarization(const G4ThreeVector &)
void SetCharge(G4double charge)
void SetMomentumDirection(const G4ThreeVector &aDirection)
void DumpInfo(G4int mode=0) const
G4int GetOccupancy(G4int orbit) const
void SetPDGcode(G4int c)
const G4ThreeVector & GetMomentumDirection() const
void SetProperTime(G4double)
G4bool operator==(const G4DynamicParticle &right) const
G4PrimaryParticle * GetPrimaryParticle() const
G4double GetSpin() const
G4double GetCharge() const
void SetDefinition(const G4ParticleDefinition *aParticleDefinition)
void SetSpin(G4int spinInUnitOfHalfInteger)
void SetMagneticMoment(G4double magneticMoment)
void SetPolarization(G4double polX, G4double polY, G4double polZ)
void SetMass(G4double mass)
const G4DecayProducts * GetPreAssignedDecayProducts() const
G4double GetLogKineticEnergy() const
void SetCharge(G4int chargeInUnitOfEplus)
const G4ParticleDefinition * GetParticleDefinition() const
G4ParticleDefinition * GetDefinition() const
void SetSpin(G4double spin)
void SetMomentumDirection(G4double px, G4double py, G4double pz)
G4LorentzVector Get4Momentum() const
G4double GetKineticEnergy() const
G4double GetTotalEnergy() const
G4double GetBeta() const
G4bool operator!=(const G4DynamicParticle &right) const
void Set4Momentum(const G4LorentzVector &momentum)
void SetMomentum(const G4ThreeVector &momentum)
G4int GetVerboseLevel() const
G4double GetProperTime() const
void SetPrimaryParticle(G4PrimaryParticle *p)
G4ThreeVector GetMomentum() const
void SetPreAssignedDecayProperTime(G4double)
G4DynamicParticle & operator=(const G4DynamicParticle &right)
G4double GetPreAssignedDecayProperTime() const
G4double GetMagneticMoment() const
G4double GetTotalMomentum() const
void AddElectron(G4int orbit, G4int number=1)
G4double GetElectronMass() const
const G4ThreeVector & GetPolarization() const
void RemoveElectron(G4int orbit, G4int number=1)
void SetKineticEnergy(G4double aEnergy)
G4int GetPDGcode() const
const G4ElectronOccupancy * GetElectronOccupancy() const
void SetVerboseLevel(G4int value)
#define DBL_MAX
Definition templates.hh:62