Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-07-13 08:21:05

0001 
0002 #ifndef G4HepEmTrack_HH
0003 #define G4HepEmTrack_HH
0004 
0005 #include "G4HepEmMacros.hh"
0006 
0007 // A simple track structure for neutral particles.
0008 //
0009 // This object stores all the basic information (e.g. position, directin, etc)
0010 // a track needs to keep and propagate between the different component of the
0011 // simulation.
0012 // Both the G4HepEmElectronTrack and G4HepEmGammaTrack contain an instance of
0013 // this. While the G4HepEmTrack is already sufficient to store all information
0014 // for gamma particle tracks the G4HepEmElectronTrack contains additional members
0015 // speacial for charged particle tracks and their simualtion.
0016 
0017 #include "G4HepEmMath.hh"
0018 
0019 class G4HepEmTrack {
0020 
0021 public:
0022   G4HepEmHostDevice
0023   G4HepEmTrack() { ReSet(); }
0024 
0025   G4HepEmHostDevice
0026   G4HepEmTrack(const G4HepEmTrack& o) {
0027     CopyFrom(o);
0028   }
0029 
0030   G4HepEmHostDevice
0031   G4HepEmTrack& operator=(const G4HepEmTrack& o) {
0032     if (this != &o) {
0033       CopyFrom(o);
0034     }
0035     return *this;
0036   }
0037 
0038   // Position
0039   G4HepEmHostDevice
0040   void    SetPosition(double* posv) {
0041     fPosition[0] = posv[0];
0042     fPosition[1] = posv[1];
0043     fPosition[2] = posv[2];
0044   }
0045 
0046   G4HepEmHostDevice
0047   void    SetPosition(double x, double y, double z) {
0048     fPosition[0] = x;
0049     fPosition[1] = y;
0050     fPosition[2] = z;
0051   }
0052 
0053   G4HepEmHostDevice
0054   double* GetPosition() { return fPosition; }
0055 
0056   // Direction
0057   G4HepEmHostDevice
0058   void    SetDirection(double* dirv) {
0059     fDirection[0] = dirv[0];
0060     fDirection[1] = dirv[1];
0061     fDirection[2] = dirv[2];
0062   }
0063 
0064   G4HepEmHostDevice
0065   void    SetDirection(double x, double y, double z) {
0066     fDirection[0] = x;
0067     fDirection[1] = y;
0068     fDirection[2] = z;
0069   }
0070 
0071   G4HepEmHostDevice
0072   double* GetDirection() {return fDirection; }
0073 
0074   // Kinetic energy
0075   G4HepEmHostDevice
0076   void    SetEKin(double ekin)  {
0077     fEKin    = ekin;
0078     fLogEKin = 100.0;
0079   }
0080 
0081   // !!! should be used only with special caution !!!
0082   G4HepEmHostDevice
0083   void    SetLEKin(double lekin)  { fLogEKin = lekin; }
0084   G4HepEmHostDevice
0085   void    SetEKin(double ekin, double lekin)  {
0086     fEKin    = ekin;
0087     fLogEKin = lekin;
0088   }
0089 
0090 
0091 
0092   G4HepEmHostDevice
0093   double  GetEKin()    const { return fEKin; }
0094   G4HepEmHostDevice
0095   double  GetLogEKin() {
0096     if (fLogEKin > 99.0) {
0097       fLogEKin = (fEKin > 0.) ? G4HepEmLog(fEKin) : -30;
0098     }
0099     return fLogEKin;
0100   }
0101 
0102   // Charge
0103   G4HepEmHostDevice
0104   void    SetCharge(double ch) { fCharge = ch; }
0105 
0106   G4HepEmHostDevice
0107   double  GetCharge() const { return fCharge; }
0108 
0109   //Energy deposit
0110   G4HepEmHostDevice
0111   void    SetEnergyDeposit(double val) { fEDeposit  = val; }
0112   G4HepEmHostDevice
0113   void    AddEnergyDeposit(double val) { fEDeposit += val; }
0114   G4HepEmHostDevice
0115   double  GetEnergyDeposit()  const    { return fEDeposit; }
0116 
0117   G4HepEmHostDevice
0118   void    SetGStepLength(double gsl)   { fGStepLength = gsl;  }
0119   G4HepEmHostDevice
0120   double  GetGStepLength()    const    { return fGStepLength; }
0121 
0122   // Mean free paths
0123   G4HepEmHostDevice
0124   void    SetMFP(double val, int pindx) { fMFPs[pindx] = val; }
0125   G4HepEmHostDevice
0126   double  GetMFP(int pindx)   const     { return fMFPs[pindx]; }
0127   G4HepEmHostDevice
0128   double* GetMFP()                      { return fMFPs; }
0129 
0130   // Number of intercation left for the processes with mac-xsec above
0131   G4HepEmHostDevice
0132   void    SetNumIALeft(double val, int pindx) {fNumIALeft[pindx] = val; }
0133   G4HepEmHostDevice
0134   double  GetNumIALeft(int pindx) const       {return fNumIALeft[pindx]; }
0135   G4HepEmHostDevice
0136   double* GetNumIALeft()                      {return fNumIALeft; }
0137 
0138 
0139   G4HepEmHostDevice
0140   void    SetSafety(double s) { fSafety = s; }
0141   G4HepEmHostDevice
0142   double  GetSafety() const   { return fSafety; }
0143 
0144 
0145   // ID
0146   G4HepEmHostDevice
0147   void    SetID(int id) { fID = id;   }
0148   G4HepEmHostDevice
0149   int     GetID() const { return fID; }
0150 
0151   // Parent ID
0152   G4HepEmHostDevice
0153   void    SetParentID(int id) { fIDParent = id;   }
0154   G4HepEmHostDevice
0155   int     GetParentID() const { return fIDParent; }
0156 
0157   // Material-cut index
0158   G4HepEmHostDevice
0159   void    SetMCIndex(int imc) { fMCIndex = imc;  }
0160   G4HepEmHostDevice
0161   int     GetMCIndex() const { return fMCIndex; }
0162 
0163   G4HepEmHostDevice
0164   void    SetWinnerProcessIndex(int ip) { fPIndxWon = ip; }
0165   G4HepEmHostDevice
0166   int     GetWinnerProcessIndex() const { return fPIndxWon; }
0167 
0168   G4HepEmHostDevice
0169   void    SetOnBoundary(bool val)  { fOnBoundary = val;  }
0170   G4HepEmHostDevice
0171   bool    GetOnBoundary() const { return fOnBoundary; }
0172 
0173   // Reset all member values
0174   G4HepEmHostDevice
0175   void ReSet() {
0176     fPosition[0]  = 0.0;
0177     fPosition[1]  = 0.0;
0178     fPosition[2]  = 0.0;
0179 
0180     fDirection[0] = 0.0;
0181     fDirection[1] = 0.0;
0182     fDirection[2] = 0.0;
0183 
0184     fEKin         = 0.0;
0185     fLogEKin      = 100.0;
0186     fCharge       = 0.0;
0187     fEDeposit     = 0.0;
0188     // step length along the original direction
0189     fGStepLength  = 0.0;
0190 
0191     fMFPs[0]      = -1.0;
0192     fMFPs[1]      = -1.0;
0193     fMFPs[2]      = -1.0;
0194     fMFPs[3]      = -1.0;
0195 
0196     fNumIALeft[0] = -1.0;
0197     fNumIALeft[1] = -1.0;
0198     fNumIALeft[2] = -1.0;
0199     fNumIALeft[3] = -1.0;
0200 
0201     fID           =  -1;
0202     fIDParent     =  -1;
0203     fMCIndex      =  -1;
0204     fPIndxWon     =  -1;
0205     fOnBoundary   = false;
0206   }
0207 
0208   // Helper to be used inside the copy constructor and assigment operator 
0209   G4HepEmHostDevice
0210   void CopyFrom(const G4HepEmTrack& o) {
0211     fPosition[0] = o.fPosition[0];
0212     fPosition[1] = o.fPosition[1];
0213     fPosition[2] = o.fPosition[2];
0214 
0215     fDirection[0] = o.fDirection[0];
0216     fDirection[1] = o.fDirection[1];
0217     fDirection[2] = o.fDirection[2];
0218 
0219     fEKin        = o.fEKin;
0220     fLogEKin     = o.fLogEKin;
0221     fCharge      = o.fCharge;
0222     fEDeposit    = o.fEDeposit;
0223     fGStepLength = o.fGStepLength;
0224 
0225     fMFPs[0] = o.fMFPs[0];
0226     fMFPs[1] = o.fMFPs[1];
0227     fMFPs[2] = o.fMFPs[2];
0228     fMFPs[3] = o.fMFPs[3];
0229 
0230     fNumIALeft[0] = o.fNumIALeft[0];
0231     fNumIALeft[1] = o.fNumIALeft[1];
0232     fNumIALeft[2] = o.fNumIALeft[2];
0233     fNumIALeft[3] = o.fNumIALeft[3];
0234 
0235     fSafety     = o.fSafety;
0236     fID         = o.fID;
0237     fIDParent   = o.fIDParent;
0238     fMCIndex    = o.fMCIndex;
0239     fPIndxWon   = o.fPIndxWon;
0240     fOnBoundary = o.fOnBoundary;
0241   }
0242 
0243 
0244 private:
0245 
0246   double   fPosition[3];
0247   double   fDirection[3];
0248   double   fEKin;
0249   double   fLogEKin;
0250   double   fCharge;
0251   double   fEDeposit;
0252   double   fGStepLength;   // step length along the original direction (straight line)
0253   double   fMFPs[4];       // pair, compton, photo-electric, gamma-nuclear in case of photon
0254   double   fNumIALeft[4];  // ioni, brem, (e+-e- annihilation) in case of e- (e+)
0255   double   fSafety;
0256 
0257   int      fID;
0258   int      fIDParent;
0259 
0260   int      fMCIndex;
0261 
0262   int      fPIndxWon; // 0-pair, 1-compton, 2-photo-electric, 3-gamma-nuclear for photon
0263                       // 0-ioni, 1-brem,  (2-annihilation) for e- (e+)
0264   bool     fOnBoundary;
0265 };
0266 
0267 
0268 #endif // G4HepEmTrack_HH