Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:58:10

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 // G4DynamicParticle
0027 //
0028 // Class description:
0029 //
0030 // A G4DynamicParticle aggregates the information to describe the dynamics
0031 // of a G4Particle, such as energy, momentum, polarization and proper time,
0032 // as well as the "particle definition", holding all the static information.
0033 // It contains the purely dynamic aspects of a moving particle.
0034 
0035 // History:
0036 // - 2 December 1995, G.Cosmo - first design, based on object model.
0037 // - 29 January 1996, M.Asai - first implementation.
0038 // - 1996 - 2007,     H.Kurashige - revisions.
0039 // - 15 March 2019,   M.Novak - log-kinetic energy value is computed only
0040 //                    on demand if its stored value is not up-to-date.
0041 // --------------------------------------------------------------------
0042 #ifndef G4DynamicParticle_hh
0043 #define G4DynamicParticle_hh 1
0044 
0045 #include "G4Allocator.hh"
0046 #include "G4ElectronOccupancy.hh"
0047 #include "G4Log.hh"
0048 #include "G4LorentzVector.hh"
0049 #include "G4ParticleDefinition.hh"
0050 #include "G4ParticleMomentum.hh"  // NOTE: means "momentum direction" not "momentum vector". It is a G4ThreeVector
0051 #include "G4ios.hh"
0052 #include "globals.hh"
0053 
0054 #include <CLHEP/Units/PhysicalConstants.h>
0055 #include <CLHEP/Units/SystemOfUnits.h>
0056 
0057 #include <cmath>
0058 
0059 class G4PrimaryParticle;
0060 class G4DecayProducts;
0061 
0062 class G4DynamicParticle
0063 {
0064   public:
0065     //- constructors
0066     G4DynamicParticle();
0067 
0068     G4DynamicParticle(const G4ParticleDefinition* aParticleDefinition,
0069                       const G4ThreeVector& aMomentumDirection, G4double aKineticEnergy);
0070     G4DynamicParticle(const G4ParticleDefinition* aParticleDefinition,
0071                       const G4ThreeVector& aParticleMomentum);
0072     G4DynamicParticle(const G4ParticleDefinition* aParticleDefinition,
0073                       const G4LorentzVector& aParticleMomentum);
0074     G4DynamicParticle(const G4ParticleDefinition* aParticleDefinition, G4double aTotalEnergy,
0075                       const G4ThreeVector& aParticleMomentum);
0076     G4DynamicParticle(const G4ParticleDefinition* aParticleDefinition,
0077                       const G4ThreeVector& aMomentumDirection, G4double aKineticEnergy,
0078                       const G4double dynamicalMass);
0079 
0080     G4DynamicParticle(const G4DynamicParticle& right);
0081 
0082     //- destructor
0083     ~G4DynamicParticle();
0084 
0085     //- operators
0086     G4DynamicParticle& operator=(const G4DynamicParticle& right);
0087     G4bool operator==(const G4DynamicParticle& right) const;
0088     G4bool operator!=(const G4DynamicParticle& right) const;
0089 
0090     //- Move constructor & operator
0091     G4DynamicParticle(G4DynamicParticle&& from);
0092     G4DynamicParticle& operator=(G4DynamicParticle&& from);
0093 
0094     //- new/delete operators are oberloded to use G4Allocator
0095     inline void* operator new(size_t);
0096     inline void operator delete(void* aDynamicParticle);
0097 
0098     //- Set/Get methods
0099 
0100     // Returns the normalized direction of the momentum
0101     inline const G4ThreeVector& GetMomentumDirection() const;
0102 
0103     // Sets the normalized direction of the momentum
0104     inline void SetMomentumDirection(const G4ThreeVector& aDirection);
0105 
0106     // Sets the normalized direction of the momentum by coordinates
0107     inline void SetMomentumDirection(G4double px, G4double py, G4double pz);
0108 
0109     // Returns the current particle momentum vector
0110     inline G4ThreeVector GetMomentum() const;
0111 
0112     // set the current particle momentum vector
0113     void SetMomentum(const G4ThreeVector& momentum);
0114 
0115     // Returns the current particle energy-momentum 4vector
0116     inline G4LorentzVector Get4Momentum() const;
0117 
0118     // Set the current particle energy-momentum 4vector
0119     void Set4Momentum(const G4LorentzVector& momentum);
0120 
0121     // Returns the module of the momentum vector
0122     inline G4double GetTotalMomentum() const;
0123 
0124     // Returns the total energy of the particle
0125     inline G4double GetTotalEnergy() const;
0126 
0127     // Returns the kinetic energy of a particle
0128     inline G4double GetKineticEnergy() const;
0129 
0130     // Returns:
0131     // - natural logarithm of the particle kinetic energy (E_k) if E_k > 0
0132     // - LOG_EKIN_MIN otherwise
0133     inline G4double GetLogKineticEnergy() const;
0134 
0135     // Sets the kinetic energy of a particle
0136     inline void SetKineticEnergy(G4double aEnergy);
0137 
0138     // Access Lorentz beta
0139     inline G4double GetBeta() const;
0140 
0141     // Returns the current particle proper time
0142     inline G4double GetProperTime() const;
0143 
0144     // Set the current particle Proper Time
0145     inline void SetProperTime(G4double);
0146 
0147     // Set/Get polarization vector
0148     inline const G4ThreeVector& GetPolarization() const;
0149     inline void SetPolarization(const G4ThreeVector&);
0150     inline void SetPolarization(G4double polX, G4double polY, G4double polZ);
0151 
0152     // Set/Get dynamical mass
0153     // The dynamical mass is set to PDG mass in default
0154     inline G4double GetMass() const;
0155     inline void SetMass(G4double mass);
0156 
0157     // Set/Get dynamical charge
0158     // The dynamical mass is set to PDG charge in default
0159     inline G4double GetCharge() const;
0160     inline void SetCharge(G4double charge);
0161     inline void SetCharge(G4int chargeInUnitOfEplus);
0162 
0163     // Set/Get dynamical spin
0164     // The dynamical spin is set to PDG spin in default
0165     inline G4double GetSpin() const;
0166     inline void SetSpin(G4double spin);
0167     inline void SetSpin(G4int spinInUnitOfHalfInteger);
0168 
0169     // Set/Get dynamical MagneticMoment
0170     // The dynamical mass is set to PDG MagneticMoment in default
0171     inline G4double GetMagneticMoment() const;
0172     inline void SetMagneticMoment(G4double magneticMoment);
0173 
0174     // Get electron occupancy
0175     // ElectronOccupancy is valid only if the particle is ion
0176     inline const G4ElectronOccupancy* GetElectronOccupancy() const;
0177     inline G4int GetTotalOccupancy() const;
0178     inline G4int GetOccupancy(G4int orbit) const;
0179     inline void AddElectron(G4int orbit, G4int number = 1);
0180     inline void RemoveElectron(G4int orbit, G4int number = 1);
0181 
0182     // Set/Get particle definition
0183     inline const G4ParticleDefinition* GetParticleDefinition() const;
0184     void SetDefinition(const G4ParticleDefinition* aParticleDefinition);
0185 
0186     // Following method of GetDefinition() remains
0187     // because of backward compatiblity. May be removed in future
0188     inline G4ParticleDefinition* GetDefinition() const;
0189 
0190     // Set/Get pre-assigned decay channel
0191     inline const G4DecayProducts* GetPreAssignedDecayProducts() const;
0192     inline void SetPreAssignedDecayProducts(G4DecayProducts* aDecayProducts);
0193 
0194     // Set/Get pre-assigned proper time when the particle will decay
0195     inline G4double GetPreAssignedDecayProperTime() const;
0196     inline void SetPreAssignedDecayProperTime(G4double);
0197 
0198     // Print out information
0199     // - mode 0 : default )(minimum)
0200     // - mode 1 : 0 + electron occupancy
0201     void DumpInfo(G4int mode = 0) const;
0202 
0203     // Set/Get controle flag for output message
0204     // - 0: Silent
0205     // - 1: Warning message
0206     // - 2: More
0207     inline void SetVerboseLevel(G4int value);
0208     inline G4int GetVerboseLevel() const;
0209 
0210     inline void SetPrimaryParticle(G4PrimaryParticle* p);
0211     inline void SetPDGcode(G4int c);
0212 
0213     // Return the pointer to the corresponding G4PrimaryParticle object
0214     // if this particle is a primary particle OR is defined as a
0215     // pre-assigned decay product. Otherwise return nullptr.
0216     inline G4PrimaryParticle* GetPrimaryParticle() const;
0217 
0218     // Return the PDG code of this particle. If the particle is known to
0219     // Geant4, its PDG code defined in G4ParticleDefinition is returned.
0220     // If it is unknown (i.e. PDG code in G4ParticleDefinition is 0), the
0221     // PDG code defined in the corresponding primary particle or
0222     // pre-assigned decay product will be returned if available.
0223     // Otherwise (e.g. for geantino) returns 0.
0224     inline G4int GetPDGcode() const;
0225 
0226   protected:
0227     void AllocateElectronOccupancy();
0228     G4double GetElectronMass() const;
0229 
0230   private:
0231     inline void ComputeBeta() const;
0232 
0233     // The normalized momentum vector
0234     G4ThreeVector theMomentumDirection;
0235 
0236     G4ThreeVector thePolarization;
0237 
0238     // Contains the static information of this particle
0239     const G4ParticleDefinition* theParticleDefinition = nullptr;
0240 
0241     G4ElectronOccupancy* theElectronOccupancy = nullptr;
0242 
0243     G4DecayProducts* thePreAssignedDecayProducts = nullptr;
0244 
0245     // This void pointer is used by G4EventManager to maintain the
0246     // link between pre-assigned decay products and corresponding
0247     // primary particle
0248     G4PrimaryParticle* primaryParticle = nullptr;
0249 
0250     G4double theKineticEnergy = 0.0;
0251 
0252     mutable G4double theLogKineticEnergy = DBL_MAX;
0253 
0254     mutable G4double theBeta = -1.0;
0255 
0256     G4double theProperTime = 0.0;
0257 
0258     G4double theDynamicalMass = 0.0;
0259 
0260     G4double theDynamicalCharge = 0.0;
0261 
0262     G4double theDynamicalSpin = 0.0;
0263 
0264     G4double theDynamicalMagneticMoment = 0.0;
0265 
0266     G4double thePreAssignedDecayTime = -1.0;
0267 
0268     G4int verboseLevel = 1;
0269 
0270     G4int thePDGcode = 0;
0271 };
0272 
0273 #include "G4DynamicParticle.icc"
0274 
0275 #endif