Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // 26 // G4DynamicParticle 26 // G4DynamicParticle 27 // 27 // 28 // Class description: 28 // Class description: 29 // 29 // 30 // A G4DynamicParticle aggregates the informat 30 // A G4DynamicParticle aggregates the information to describe the dynamics 31 // of a G4Particle, such as energy, momentum, 31 // of a G4Particle, such as energy, momentum, polarization and proper time, 32 // as well as the "particle definition", holdi 32 // as well as the "particle definition", holding all the static information. 33 // It contains the purely dynamic aspects of a 33 // It contains the purely dynamic aspects of a moving particle. 34 34 35 // History: 35 // History: 36 // - 2 December 1995, G.Cosmo - first design, 36 // - 2 December 1995, G.Cosmo - first design, based on object model. 37 // - 29 January 1996, M.Asai - first implement 37 // - 29 January 1996, M.Asai - first implementation. 38 // - 1996 - 2007, H.Kurashige - revisions. 38 // - 1996 - 2007, H.Kurashige - revisions. 39 // - 15 March 2019, M.Novak - log-kinetic en << 39 // - 15 March 2019, M.Novak - log-kinetic energy value is computed only 40 // on demand if its stored << 40 // on demand if its stored value is not up-to-date. 41 // ------------------------------------------- 41 // -------------------------------------------------------------------- 42 #ifndef G4DynamicParticle_hh 42 #ifndef G4DynamicParticle_hh 43 #define G4DynamicParticle_hh 1 43 #define G4DynamicParticle_hh 1 44 44 45 #include "G4Allocator.hh" << 45 #include <cmath> 46 #include "G4ElectronOccupancy.hh" << 46 #include <CLHEP/Units/SystemOfUnits.h> 47 #include "G4Log.hh" << 47 #include <CLHEP/Units/PhysicalConstants.h> 48 #include "G4LorentzVector.hh" << 48 49 #include "G4ParticleDefinition.hh" << 50 #include "G4ParticleMomentum.hh" // NOTE: mea << 51 #include "G4ios.hh" << 52 #include "globals.hh" 49 #include "globals.hh" >> 50 #include "G4ios.hh" 53 51 54 #include <CLHEP/Units/PhysicalConstants.h> << 52 #include "G4ParticleDefinition.hh" 55 #include <CLHEP/Units/SystemOfUnits.h> << 53 #include "G4Allocator.hh" >> 54 #include "G4LorentzVector.hh" >> 55 #include "G4Log.hh" 56 56 57 #include <cmath> << 57 #include "G4ParticleMomentum.hh" // NOTE: means "momentum direction" not >> 58 // "momentum vector". It is a G4ThreeVector >> 59 #include "G4ElectronOccupancy.hh" 58 60 59 class G4PrimaryParticle; 61 class G4PrimaryParticle; 60 class G4DecayProducts; 62 class G4DecayProducts; 61 63 62 class G4DynamicParticle << 64 class G4DynamicParticle 63 { 65 { 64 public: 66 public: 65 //- constructors << 66 G4DynamicParticle(); << 67 67 68 G4DynamicParticle(const G4ParticleDefiniti << 68 //- constructors 69 const G4ThreeVector& aMo << 69 G4DynamicParticle(); 70 G4DynamicParticle(const G4ParticleDefiniti << 70 71 const G4ThreeVector& aPa << 71 G4DynamicParticle(const G4ParticleDefinition* aParticleDefinition, 72 G4DynamicParticle(const G4ParticleDefiniti << 72 const G4ThreeVector& aMomentumDirection, 73 const G4LorentzVector& a << 73 G4double aKineticEnergy); 74 G4DynamicParticle(const G4ParticleDefiniti << 74 G4DynamicParticle(const G4ParticleDefinition* aParticleDefinition, 75 const G4ThreeVector& aPa << 75 const G4ThreeVector& aParticleMomentum); 76 G4DynamicParticle(const G4ParticleDefiniti << 76 G4DynamicParticle(const G4ParticleDefinition* aParticleDefinition, 77 const G4ThreeVector& aMo << 77 const G4LorentzVector& aParticleMomentum); 78 const G4double dynamical << 78 G4DynamicParticle(const G4ParticleDefinition* aParticleDefinition, 79 << 79 G4double aTotalEnergy, 80 G4DynamicParticle(const G4DynamicParticle& << 80 const G4ThreeVector& aParticleMomentum); 81 << 81 G4DynamicParticle(const G4ParticleDefinition* aParticleDefinition, 82 //- destructor << 82 const G4ThreeVector& aMomentumDirection, 83 ~G4DynamicParticle(); << 83 G4double aKineticEnergy, 84 << 84 const G4double dynamicalMass); 85 //- operators << 85 86 G4DynamicParticle& operator=(const G4Dynam << 86 G4DynamicParticle(const G4DynamicParticle& right); 87 G4bool operator==(const G4DynamicParticle& << 87 88 G4bool operator!=(const G4DynamicParticle& << 88 //- destructor 89 << 89 ~G4DynamicParticle(); 90 //- Move constructor & operator << 90 91 G4DynamicParticle(G4DynamicParticle&& from << 91 //- operators 92 G4DynamicParticle& operator=(G4DynamicPart << 92 G4DynamicParticle& operator=(const G4DynamicParticle &right); 93 << 93 G4bool operator==(const G4DynamicParticle& right) const; 94 //- new/delete operators are oberloded to << 94 G4bool operator!=(const G4DynamicParticle& right) const; 95 inline void* operator new(size_t); << 95 96 inline void operator delete(void* aDynamic << 96 //- Move constructor & operator 97 << 97 G4DynamicParticle(G4DynamicParticle&& from); 98 //- Set/Get methods << 98 G4DynamicParticle& operator=(G4DynamicParticle&& from); 99 << 99 100 // Returns the normalized direction of the << 100 //- new/delete operators are oberloded to use G4Allocator 101 inline const G4ThreeVector& GetMomentumDir << 101 inline void* operator new(size_t); 102 << 102 inline void operator delete(void* aDynamicParticle); 103 // Sets the normalized direction of the mo << 103 104 inline void SetMomentumDirection(const G4T << 104 //- Set/Get methods 105 << 105 106 // Sets the normalized direction of the mo << 106 inline const G4ThreeVector& GetMomentumDirection() const; 107 inline void SetMomentumDirection(G4double << 107 // Returns the normalized direction of the momentum 108 << 108 inline void SetMomentumDirection(const G4ThreeVector& aDirection); 109 // Returns the current particle momentum v << 109 // Sets the normalized direction of the momentum 110 inline G4ThreeVector GetMomentum() const; << 110 inline void SetMomentumDirection(G4double px, G4double py, G4double pz); 111 << 111 // Sets the normalized direction of the momentum by coordinates 112 // set the current particle momentum vecto << 112 113 void SetMomentum(const G4ThreeVector& mome << 113 inline G4ThreeVector GetMomentum() const; 114 << 114 // Returns the current particle momentum vector 115 // Returns the current particle energy-mom << 115 void SetMomentum( const G4ThreeVector& momentum); 116 inline G4LorentzVector Get4Momentum() cons << 116 // set the current particle momentum vector 117 << 117 118 // Set the current particle energy-momentu << 118 inline G4LorentzVector Get4Momentum() const; 119 void Set4Momentum(const G4LorentzVector& m << 119 // Returns the current particle energy-momentum 4vector 120 << 120 void Set4Momentum( const G4LorentzVector& momentum); 121 // Returns the module of the momentum vect << 121 // Set the current particle energy-momentum 4vector 122 inline G4double GetTotalMomentum() const; << 122 123 << 123 inline G4double GetTotalMomentum() const; 124 // Returns the total energy of the particl << 124 // Returns the module of the momentum vector 125 inline G4double GetTotalEnergy() const; << 125 inline G4double GetTotalEnergy() const; 126 << 126 // Returns the total energy of the particle 127 // Returns the kinetic energy of a particl << 127 128 inline G4double GetKineticEnergy() const; << 128 inline G4double GetKineticEnergy() const; 129 << 129 // Returns the kinetic energy of a particle 130 // Returns: << 130 inline G4double GetLogKineticEnergy() const; 131 // - natural logarithm of the particle kin << 131 // Returns: 132 // - LOG_EKIN_MIN otherwise << 132 // - natural logarithm of the particle kinetic energy (E_k) if E_k > 0 133 inline G4double GetLogKineticEnergy() cons << 133 // - LOG_EKIN_MIN otherwise 134 << 134 inline void SetKineticEnergy(G4double aEnergy); 135 // Sets the kinetic energy of a particle << 135 // Sets the kinetic energy of a particle 136 inline void SetKineticEnergy(G4double aEne << 136 inline G4double GetBeta() const; 137 << 137 // Access Lorentz beta 138 // Access Lorentz beta << 138 139 inline G4double GetBeta() const; << 139 inline G4double GetProperTime() const; 140 << 140 // Returns the current particle proper time 141 // Returns the current particle proper tim << 141 inline void SetProperTime( G4double ); 142 inline G4double GetProperTime() const; << 142 // Set the current particle Proper Time 143 << 143 144 // Set the current particle Proper Time << 144 inline const G4ThreeVector& GetPolarization() const; 145 inline void SetProperTime(G4double); << 145 inline void SetPolarization(const G4ThreeVector&); 146 << 146 inline void SetPolarization(G4double polX, G4double polY, G4double polZ); 147 // Set/Get polarization vector << 147 // Set/Get polarization vector 148 inline const G4ThreeVector& GetPolarizatio << 148 149 inline void SetPolarization(const G4ThreeV << 149 inline G4double GetMass() const; 150 inline void SetPolarization(G4double polX, << 150 inline void SetMass(G4double mass); 151 << 151 // Set/Get dynamical mass 152 // Set/Get dynamical mass << 152 // The dynamical mass is set to PDG mass in default 153 // The dynamical mass is set to PDG mass i << 153 154 inline G4double GetMass() const; << 154 inline G4double GetCharge() const; 155 inline void SetMass(G4double mass); << 155 inline void SetCharge(G4double charge); 156 << 156 inline void SetCharge(G4int chargeInUnitOfEplus); 157 // Set/Get dynamical charge << 157 // Set/Get dynamical charge 158 // The dynamical mass is set to PDG charge << 158 // The dynamical mass is set to PDG charge in default 159 inline G4double GetCharge() const; << 159 160 inline void SetCharge(G4double charge); << 160 inline G4double GetSpin() const; 161 inline void SetCharge(G4int chargeInUnitOf << 161 inline void SetSpin(G4double spin); 162 << 162 inline void SetSpin(G4int spinInUnitOfHalfInteger); 163 // Set/Get dynamical spin << 163 // Set/Get dynamical spin 164 // The dynamical spin is set to PDG spin i << 164 // The dynamical spin is set to PDG spin in default 165 inline G4double GetSpin() const; << 165 166 inline void SetSpin(G4double spin); << 166 inline G4double GetMagneticMoment() const; 167 inline void SetSpin(G4int spinInUnitOfHalf << 167 inline void SetMagneticMoment(G4double magneticMoment); 168 << 168 // Set/Get dynamical MagneticMoment 169 // Set/Get dynamical MagneticMoment << 169 // The dynamical mass is set to PDG MagneticMoment in default 170 // The dynamical mass is set to PDG Magnet << 170 171 inline G4double GetMagneticMoment() const; << 171 inline const G4ElectronOccupancy* GetElectronOccupancy() const; 172 inline void SetMagneticMoment(G4double mag << 172 // Get electron occupancy 173 << 173 // ElectronOccupancy is valid only if the particle is ion 174 // Get electron occupancy << 174 inline G4int GetTotalOccupancy() const; 175 // ElectronOccupancy is valid only if the << 175 inline G4int GetOccupancy(G4int orbit) const; 176 inline const G4ElectronOccupancy* GetElect << 176 inline void AddElectron(G4int orbit, G4int number = 1); 177 inline G4int GetTotalOccupancy() const; << 177 inline void RemoveElectron(G4int orbit, G4int number = 1); 178 inline G4int GetOccupancy(G4int orbit) con << 178 179 inline void AddElectron(G4int orbit, G4int << 179 inline const G4ParticleDefinition* GetParticleDefinition() const; 180 inline void RemoveElectron(G4int orbit, G4 << 180 void SetDefinition(const G4ParticleDefinition* aParticleDefinition); 181 << 181 // Set/Get particle definition 182 // Set/Get particle definition << 182 // Following method of GetDefinition() remains 183 inline const G4ParticleDefinition* GetPart << 183 // because of backward compatiblity. May be removed in future 184 void SetDefinition(const G4ParticleDefinit << 184 inline G4ParticleDefinition* GetDefinition() const; 185 << 185 186 // Following method of GetDefinition() rem << 186 inline const G4DecayProducts* GetPreAssignedDecayProducts() const; 187 // because of backward compatiblity. May b << 187 inline void SetPreAssignedDecayProducts(G4DecayProducts* aDecayProducts); 188 inline G4ParticleDefinition* GetDefinition << 188 // Set/Get pre-assigned decay channel 189 << 189 190 // Set/Get pre-assigned decay channel << 190 inline G4double GetPreAssignedDecayProperTime() const; 191 inline const G4DecayProducts* GetPreAssign << 191 inline void SetPreAssignedDecayProperTime(G4double); 192 inline void SetPreAssignedDecayProducts(G4 << 192 // Set/Get pre-assigned proper time when the particle will decay 193 << 193 194 // Set/Get pre-assigned proper time when t << 194 void DumpInfo(G4int mode = 0) const; 195 inline G4double GetPreAssignedDecayProperT << 195 // Print out information 196 inline void SetPreAssignedDecayProperTime( << 196 // - mode 0 : default )(minimum) 197 << 197 // - mode 1 : 0 + electron occupancy 198 // Print out information << 198 199 // - mode 0 : default )(minimum) << 199 inline void SetVerboseLevel(G4int value); 200 // - mode 1 : 0 + electron occupancy << 200 inline G4int GetVerboseLevel() const; 201 void DumpInfo(G4int mode = 0) const; << 201 // Set/Get controle flag for output message 202 << 202 // - 0: Silent 203 // Set/Get controle flag for output messag << 203 // - 1: Warning message 204 // - 0: Silent << 204 // - 2: More 205 // - 1: Warning message << 205 206 // - 2: More << 206 inline void SetPrimaryParticle(G4PrimaryParticle* p); 207 inline void SetVerboseLevel(G4int value); << 207 inline void SetPDGcode(G4int c); 208 inline G4int GetVerboseLevel() const; << 208 209 << 209 inline G4PrimaryParticle* GetPrimaryParticle() const; 210 inline void SetPrimaryParticle(G4PrimaryPa << 210 // Return the pointer to the corresponding G4PrimaryParticle object 211 inline void SetPDGcode(G4int c); << 211 // if this particle is a primary particle OR is defined as a 212 << 212 // pre-assigned decay product. Otherwise return nullptr. 213 // Return the pointer to the corresponding << 213 214 // if this particle is a primary particle << 214 inline G4int GetPDGcode() const; 215 // pre-assigned decay product. Otherwise r << 215 // Return the PDG code of this particle. If the particle is known to 216 inline G4PrimaryParticle* GetPrimaryPartic << 216 // Geant4, its PDG code defined in G4ParticleDefinition is returned. 217 << 217 // If it is unknown (i.e. PDG code in G4ParticleDefinition is 0), the 218 // Return the PDG code of this particle. I << 218 // PDG code defined in the corresponding primary particle or 219 // Geant4, its PDG code defined in G4Parti << 219 // pre-assigned decay product will be returned if available. 220 // If it is unknown (i.e. PDG code in G4Pa << 220 // Otherwise (e.g. for geantino) returns 0. 221 // PDG code defined in the corresponding p << 222 // pre-assigned decay product will be retu << 223 // Otherwise (e.g. for geantino) returns 0 << 224 inline G4int GetPDGcode() const; << 225 221 226 protected: 222 protected: 227 void AllocateElectronOccupancy(); << 223 228 G4double GetElectronMass() const; << 224 void AllocateElectronOccupancy(); >> 225 G4double GetElectronMass() const; 229 226 230 private: 227 private: 231 inline void ComputeBeta() const; << 232 228 233 // The normalized momentum vector << 229 inline void ComputeBeta() const; 234 G4ThreeVector theMomentumDirection; << 235 230 236 G4ThreeVector thePolarization; << 231 G4ThreeVector theMomentumDirection; >> 232 // The normalized momentum vector 237 233 238 // Contains the static information of this << 234 G4ThreeVector thePolarization; 239 const G4ParticleDefinition* theParticleDef << 240 235 241 G4ElectronOccupancy* theElectronOccupancy << 236 const G4ParticleDefinition* theParticleDefinition = nullptr; >> 237 // Contains the static information of this particle 242 238 243 G4DecayProducts* thePreAssignedDecayProduc << 239 G4ElectronOccupancy* theElectronOccupancy = nullptr; >> 240 >> 241 G4DecayProducts* thePreAssignedDecayProducts = nullptr; 244 242 245 // This void pointer is used by G4EventMan << 243 G4PrimaryParticle* primaryParticle = nullptr; 246 // link between pre-assigned decay product << 244 // This void pointer is used by G4EventManager to maintain the 247 // primary particle << 245 // link between pre-assigned decay products and corresponding 248 G4PrimaryParticle* primaryParticle = nullp << 246 // primary particle 249 247 250 G4double theKineticEnergy = 0.0; << 248 G4double theKineticEnergy = 0.0; 251 249 252 mutable G4double theLogKineticEnergy = DBL << 250 mutable G4double theLogKineticEnergy = DBL_MAX; 253 251 254 mutable G4double theBeta = -1.0; << 252 mutable G4double theBeta = -1.0; 255 253 256 G4double theProperTime = 0.0; << 254 G4double theProperTime = 0.0; 257 255 258 G4double theDynamicalMass = 0.0; << 256 G4double theDynamicalMass = 0.0; 259 257 260 G4double theDynamicalCharge = 0.0; << 258 G4double theDynamicalCharge = 0.0; 261 259 262 G4double theDynamicalSpin = 0.0; << 260 G4double theDynamicalSpin = 0.0; 263 261 264 G4double theDynamicalMagneticMoment = 0.0; << 262 G4double theDynamicalMagneticMoment = 0.0; 265 263 266 G4double thePreAssignedDecayTime = -1.0; << 264 G4double thePreAssignedDecayTime = -1.0; 267 265 268 G4int verboseLevel = 1; << 266 G4int verboseLevel = 1; 269 267 270 G4int thePDGcode = 0; << 268 G4int thePDGcode = 0; 271 }; 269 }; 272 270 273 #include "G4DynamicParticle.icc" 271 #include "G4DynamicParticle.icc" 274 272 275 #endif 273 #endif 276 274