Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:59:13

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