Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-18 09:15:50

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 // G4Track
0027 //
0028 // Class description:
0029 //
0030 // This class describes the particle under tracking.
0031 // It includes information related to tracking, i.e.:
0032 //     1) current position/time of the particle,
0033 //     2) static particle information,
0034 //     3) the pointer to the physical volume where currently
0035 //        the particle exists
0036 
0037 // Author: Katsuya Amako, KEK - 1995
0038 // Revisions: Hisaya Kurashige, 1998-2011
0039 // --------------------------------------------------------------------
0040 #ifndef G4Track_hh
0041 #define G4Track_hh 1
0042 
0043 #include <cmath>  // Include from 'system'
0044 #include <map>
0045 #include <CLHEP/Units/PhysicalConstants.h>
0046 
0047 #include "globals.hh"            // Include from 'global'
0048 #include "trkdefs.hh"            // Include DLL defs...
0049 #include "G4ThreeVector.hh"      // Include from 'geometry'
0050 #include "G4LogicalVolume.hh"    // Include from 'geometry'
0051 #include "G4VPhysicalVolume.hh"  // Include from 'geometry'
0052 #include "G4Allocator.hh"        // Include from 'particle+matter'
0053 #include "G4DynamicParticle.hh"  // Include from 'particle+matter'
0054 #include "G4TrackStatus.hh"      // Include from 'tracking'
0055 #include "G4TouchableHandle.hh"  // Include from 'geometry'
0056 #include "G4VUserTrackInformation.hh"
0057 #include "G4PhysicsModelCatalog.hh"
0058 #include "G4Material.hh"
0059 
0060 class G4Step;  // Forward declaration
0061 class G4MaterialCutsCouple;
0062 class G4VAuxiliaryTrackInformation;
0063 class G4VProcess;
0064 
0065 class G4Track
0066 {
0067   public:
0068     G4Track();
0069       // Default constructor
0070     G4Track(G4DynamicParticle* apValueDynamicParticle,
0071             G4double aValueTime,
0072             const G4ThreeVector& aValuePosition);
0073       // Constructor - aValueTime is a global time
0074 
0075     G4Track(const G4Track&,G4bool copyTouchables = true);
0076       // Copy Constructor - copies members other than tracking information
0077 
0078     ~G4Track();
0079       // Destructor
0080 
0081     inline void* operator new(std::size_t);
0082       // Override "new" for "G4Allocator".
0083     inline void operator delete(void* aTrack);
0084       // Override "delete" for "G4Allocator".
0085 
0086     G4Track& operator=(const G4Track&);
0087       // Assignment operator
0088 
0089     inline G4bool operator==(const G4Track&);
0090     inline G4bool operator!=(const G4Track&);
0091       // Equality operators
0092 
0093     void CopyTrackInfo(const G4Track&, G4bool copyTouchables = true);
0094       // Copy information of the track (w/o tracking information)
0095 
0096     inline G4int GetTrackID() const;
0097     inline void SetTrackID(const G4int aValue);
0098       // Get/Set functions track ID
0099 
0100     inline G4int GetParentID() const;
0101     inline void SetParentID(const G4int aValue);
0102 
0103     inline const G4DynamicParticle* GetDynamicParticle() const;
0104       // Dynamic particle
0105 
0106     inline const G4ParticleDefinition* GetParticleDefinition() const;
0107       // Particle definition
0108     inline G4ParticleDefinition* GetDefinition() const;
0109       // Obsolete, for backwards compatibility...
0110 
0111     inline const G4ThreeVector& GetPosition() const;
0112     inline void SetPosition(const G4ThreeVector& aValue);
0113       // Position, time
0114 
0115     inline G4double GetGlobalTime() const;
0116     inline void SetGlobalTime(const G4double aValue);
0117       // Time since the event in which the track belongs is created
0118 
0119     inline G4double GetLocalTime() const;
0120     inline void SetLocalTime(const G4double aValue);
0121       // Time since the current track is created
0122 
0123     inline G4double GetProperTime() const;
0124     inline void SetProperTime(const G4double aValue);
0125       // Proper time of the current track
0126 
0127     inline G4VPhysicalVolume* GetVolume() const;
0128     inline G4VPhysicalVolume* GetNextVolume() const;
0129       // Volume, material, touchable
0130 
0131     inline G4Material* GetMaterial() const;
0132     inline G4Material* GetNextMaterial() const;
0133 
0134     inline const G4MaterialCutsCouple* GetMaterialCutsCouple() const;
0135     inline const G4MaterialCutsCouple* GetNextMaterialCutsCouple() const;
0136 
0137     inline const G4VTouchable* GetTouchable() const;
0138     inline const G4TouchableHandle& GetTouchableHandle() const;
0139     inline void SetTouchableHandle(const G4TouchableHandle& apValue);
0140 
0141     inline const G4VTouchable* GetNextTouchable() const;
0142     inline const G4TouchableHandle& GetNextTouchableHandle() const;
0143     inline void SetNextTouchableHandle(const G4TouchableHandle& apValue);
0144 
0145     inline const G4VTouchable* GetOriginTouchable() const;
0146     inline const G4TouchableHandle& GetOriginTouchableHandle() const;
0147     inline void SetOriginTouchableHandle(const G4TouchableHandle& apValue);
0148 
0149     inline G4double GetKineticEnergy() const;
0150     inline G4double GetTotalEnergy() const;
0151     inline void SetKineticEnergy(const G4double aValue);
0152       // Energy
0153 
0154     inline G4ThreeVector GetMomentum() const;
0155     inline const G4ThreeVector& GetMomentumDirection() const;
0156     inline void SetMomentumDirection(const G4ThreeVector& aValue);
0157       // Momentum
0158 
0159     inline G4double GetVelocity() const;
0160     inline void SetVelocity(G4double val);
0161       // Velocity
0162 
0163     inline G4double CalculateVelocity() const;
0164     G4double CalculateVelocityForOpticalPhoton() const;
0165 
0166     inline G4bool UseGivenVelocity() const;
0167     inline void UseGivenVelocity(G4bool val);
0168 
0169     inline const G4ThreeVector& GetPolarization() const;
0170     inline void SetPolarization(const G4ThreeVector& aValue);
0171       // Polarization
0172 
0173     inline G4TrackStatus GetTrackStatus() const;
0174     inline void SetTrackStatus(const G4TrackStatus aTrackStatus);
0175       // Track status, flags for tracking
0176 
0177     inline G4bool IsBelowThreshold() const;
0178     inline void SetBelowThresholdFlag(G4bool value = true);
0179       // The flag of "BelowThreshold" is set to true
0180       // If this track energy is below threshold energy
0181       // in this material is determined by the range cut value
0182 
0183     inline G4bool IsGoodForTracking() const;
0184     inline void SetGoodForTrackingFlag(G4bool value = true);
0185       // The flag of "GoodForTracking" is set by processes
0186       // if this track should be tracked
0187       // even if the energy is below threshold
0188 
0189     inline G4double GetTrackLength() const;
0190     inline void AddTrackLength(const G4double aValue);
0191       // Accumulated track length
0192 
0193     inline const G4Step* GetStep() const;
0194     inline void SetStep(const G4Step* aValue);
0195       // Step information
0196 
0197     inline G4int GetCurrentStepNumber() const;
0198     inline void IncrementCurrentStepNumber();
0199 
0200     inline G4double GetStepLength() const;
0201     inline void SetStepLength(G4double value);
0202       // Before the end of the AlongStepDoIt() loop, StepLength keeps
0203       // the initial value which is determined by the shortest geometrical Step
0204       // proposed by a physics process. After finishing the AlongStepDoIt(),
0205       // it will be set equal to 'StepLength' in G4Step
0206 
0207     inline const G4ThreeVector& GetVertexPosition() const;
0208     inline void SetVertexPosition(const G4ThreeVector& aValue);
0209       // Vertex (where this track was created) information
0210 
0211     inline const G4ThreeVector& GetVertexMomentumDirection() const;
0212     inline void SetVertexMomentumDirection(const G4ThreeVector& aValue);
0213 
0214     inline G4double GetVertexKineticEnergy() const;
0215     inline void SetVertexKineticEnergy(const G4double aValue);
0216 
0217     inline const G4LogicalVolume* GetLogicalVolumeAtVertex() const;
0218     inline void SetLogicalVolumeAtVertex(const G4LogicalVolume*);
0219 
0220     inline const G4VProcess* GetCreatorProcess() const;
0221     inline void SetCreatorProcess(const G4VProcess* aValue);
0222 
0223     inline void SetCreatorModelID(const G4int id);
0224     inline G4int GetCreatorModelID() const;  
0225     inline G4int GetCreatorModelIndex() const;
0226     inline const G4String GetCreatorModelName() const;
0227       // Identification of the physics model that created the track:
0228       // each of the three information (ID, index, name) is unique
0229       // (the model ID and its name are supposed to be used in Geant4
0230       // code, whereas the index is meant for plotting in user code)
0231 
0232     inline const G4ParticleDefinition* GetParentResonanceDef() const;
0233     inline void SetParentResonanceDef(const G4ParticleDefinition* parent);
0234     inline G4int GetParentResonanceID() const;
0235     inline void SetParentResonanceID(const G4int parentID );
0236     inline G4bool HasParentResonance() const;
0237     inline G4int GetParentResonancePDGEncoding() const;
0238     inline G4String GetParentResonanceName() const;
0239     inline G4double GetParentResonanceMass() const;
0240       // Because short-lived resonances (e.g. omega, phi, rho, delta, etc.)
0241       // do not have corresponding track objects, if the track is produced
0242       // by a resonance parent, these methods allow to get/set information
0243       // regarding this short-lived parent.
0244       // The ID is a unique (integer) identifier for each resonance (which
0245       // corresponds to the rounded integer of the mass of the resonance
0246       // in keV), which allows to know if two (or more) tracks originated
0247       // from the same parent resonance: this should not be confused with
0248       // the parent-track-ID (fParentID) which corresponds to its closest
0249       // ancestor which is not a short-lived resonance (and therefore has
0250       // a corresponding track object).
0251       // In the case of a track non originating from a resonance parent,
0252       // the above "Get" methods return, respectively: nullptr, 0, false,
0253       // 0, "", 0.
0254   
0255     inline G4double GetWeight() const;
0256     inline void SetWeight(G4double aValue);
0257       // Track weight; methods for manipulating a weight for this track
0258 
0259     inline G4VUserTrackInformation* GetUserInformation() const;
0260     inline void SetUserInformation(G4VUserTrackInformation* aValue) const;
0261       // User information
0262 
0263     void SetAuxiliaryTrackInformation(G4int id,
0264                                       G4VAuxiliaryTrackInformation* info) const;
0265     G4VAuxiliaryTrackInformation* GetAuxiliaryTrackInformation(G4int id) const;
0266     inline std::map<G4int, G4VAuxiliaryTrackInformation*>*
0267            GetAuxiliaryTrackInformationMap() const;
0268 
0269     void RemoveAuxiliaryTrackInformation(G4int id);
0270     void RemoveAuxiliaryTrackInformation(G4String& name);
0271       // Note: G4VAuxiliaryTrackInformation object itself is *NOT* deleted
0272 
0273   private:
0274 
0275     void ClearAuxiliaryTrackInformation();
0276 
0277     // Member data
0278 
0279     G4ThreeVector fPosition;
0280       // Current positon
0281     G4double fGlobalTime = 0.0;
0282       // Time since the event is created
0283     G4double fLocalTime = 0.0;
0284       // Time since the track is created
0285     G4double fTrackLength = 0.0;
0286       // Accumulated track length
0287  
0288     G4double fVelocity = 0.0;
0289 
0290     G4TouchableHandle fpTouchable;
0291     G4TouchableHandle fpNextTouchable;
0292     G4TouchableHandle fpOriginTouchable;
0293       // Touchable Handle
0294 
0295     G4DynamicParticle* fpDynamicParticle = nullptr;
0296     mutable G4TrackStatus fTrackStatus = fAlive;
0297 
0298     G4double fStepLength = 0.0;
0299       // Before the end of the AlongStepDoIt loop, this keeps the initial
0300       // Step length which is determined by the shortest geometrical Step
0301       // proposed by a physics process. After finishing the AlongStepDoIt,
0302       // this will be set equal to 'StepLength' in G4Step.
0303 
0304     G4double fWeight = 1.0;
0305       // This is a weight for this track
0306 
0307     const G4Step* fpStep = nullptr;
0308 
0309     G4ThreeVector fVtxPosition;
0310       // (x,y,z) of the vertex
0311     G4ThreeVector fVtxMomentumDirection;
0312       // Momentum direction at the vertex
0313     G4double fVtxKineticEnergy = 0.0;
0314       // Kinetic energy at the vertex
0315     const G4LogicalVolume* fpLVAtVertex = nullptr;
0316       // Logical Volume at the vertex
0317     const G4VProcess* fpCreatorProcess = nullptr;
0318       // Process which created the track
0319 
0320     mutable G4VUserTrackInformation* fpUserInformation = nullptr;
0321 
0322     mutable G4Material* prev_mat = nullptr;
0323     mutable G4MaterialPropertyVector* groupvel = nullptr;
0324     mutable G4double prev_velocity = 0.0;
0325     mutable G4double prev_momentum = 0.0;
0326       // cached values for CalculateVelocity
0327 
0328     mutable std::map<G4int, G4VAuxiliaryTrackInformation*>*
0329             fpAuxiliaryTrackInformationMap = nullptr;
0330 
0331     G4int fCurrentStepNumber = 0;
0332       // Total steps number up to now
0333 
0334     G4int fCreatorModelID = -1;
0335       // ID of the physics model which created the track
0336 
0337     const G4ParticleDefinition* fParentResonanceDef = nullptr;
0338       // Pointer to the particle definition of a short-lived resonance,
0339       // in the case that the track is produced by a resonance parent
0340       // (which does not have a corresponding track object)
0341     G4int fParentResonanceID = 0;
0342       // Unique ID for the parent resonance, in the case that the track
0343       // is produced by a resonance parent, else 0
0344 
0345     G4int fParentID = 0;
0346     G4int fTrackID = 0;
0347 
0348     G4bool fBelowThreshold = false;
0349       // This flag is set to true if this track energy is below
0350       // threshold energy in this material determined by the range cut value
0351     G4bool fGoodForTracking = false;
0352       // This flag is set by processes if this track should be tracked
0353       // even if the energy is below threshold
0354 
0355     G4bool is_OpticalPhoton = false;
0356 
0357     G4bool useGivenVelocity = false;
0358       // do not calculate velocity and just use current fVelocity
0359       // if this flag is set
0360 
0361     G4bool fCopyTouchables = true;
0362 };
0363 
0364 #include "G4Track.icc"
0365 
0366 #endif