Back to home page

EIC code displayed by LXR

 
 

    


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

0001 
0002 #ifndef G4HepEmElectronManager_HH
0003 #define G4HepEmElectronManager_HH
0004 
0005 #include "G4HepEmMacros.hh"
0006 
0007 struct G4HepEmData;
0008 struct G4HepEmParameters;
0009 struct G4HepEmElectronData;
0010 
0011 class  G4HepEmTLData;
0012 class  G4HepEmElectronTrack;
0013 class  G4HepEmMSCTrackData;
0014 class  G4HepEmTrack;
0015 class  G4HepEmRandomEngine;
0016 
0017 /**
0018  * @file    G4HepEmElectronManager.hh
0019  * @struct  G4HepEmElectronManager
0020  * @author  M. Novak
0021  * @date    2020
0022  *
0023  * @brief The top level run-time manager for e-/e+ transport simulations.
0024  *
0025  * This manager can provide the information regarding how far a given e-/e+ particle
0026  * goes along its original direction till it's needed to be stopped again because
0027  * some physics interaction(s) needs to be performed. It is also responsible to
0028  * perform the required interaction(s) as well.
0029  *
0030  * The two methods, through wich this manager acts on the particles, are the
0031  * G4HepEmElectronManager::HowFar() and G4HepEmElectronManager::Perform(). The
0032  * first provides the information regarding how far the particle can go, along its
0033  * original direction, till its next stop due to physics interaction(s).
0034  * The second can be used to perform the corresponding physics interaction(s).
0035  * All physics interactions, relevant for HEP detector simulatios, such as
0036  * `ionisation`, `bremsstrahlung`, `Coulomb scattering` are considered for e-/e+
0037  * with `annihilation` in addition for e+, including both their continuous, discrete
0038  * and at-rest parts pespectively. The accuracy of the models, used to describe
0039  * these interactions, are also compatible to those used by HEP detector simulations.
0040  *
0041  * Each G4HepEmRunManager has its own member from this manager for e-/e+ transport.
0042  * However, a single object could alos be used and shared by all the worker run
0043  * managers since this G4HepEmElectronManager is stateless. All the state and
0044  * thread related infomation (e.g. primary/secondary tracks or the thread local
0045  * random engine) are stored in the G4HepEmTLData input argument, that is also
0046  * used to deliver the effect of the actions of this manager (i.e. written into
0047  * the tracks stored in the input G4HepEmTLData argument).
0048  */
0049 
0050 class G4HepEmElectronManager {
0051 private:
0052   G4HepEmElectronManager() = delete;
0053 
0054 public:
0055 
0056   /** Functions that provides the information regarding how far a given e-/e+ particle goes.
0057     *
0058     * This functions provides the information regarding how far a given e-/e+ particle goes
0059     * till it's needed to be stopped again because some physics interaction(s) needs to be performed.
0060     * The input/primary e-/e+ particle track is provided through the G4HepEmTLData input argument. The
0061     * The computed physics step lenght is written directly into the input track. There is no any local
0062     * (state) variable used in the computation.
0063     *
0064     * @param hepEmData pointer to the top level, global, G4HepEmData structure.
0065     * @param hepEmPars pointer to the global, G4HepEmParameters structure.
0066     * @param tlData    pointer to a worker-local, G4HepEmTLData object. The corresonding object
0067     *   is assumed to contain all the required input information in its primary G4HepEmTLData::fElectronTrack
0068     *   member. This member is also used to deliver the results of the function call, i.e. the computed physics
0069     *   step limit is written into the G4HepEmTLData::fElectronTrack (in its fGStepLength member).
0070     */
0071   static void HowFar(struct G4HepEmData* hepEmData, struct G4HepEmParameters* hepEmPars, G4HepEmTLData* tlData);
0072 
0073   /** Function that provides the information regarding how far a given e-/e+ particle goes.
0074     *
0075     * This function provides the information regarding how far a given e-/e+ particle goes
0076     * till it's needed to be stopped again because a discrete interaction needs to be performed.
0077     * The input/primary e-/e+ particle track is provided as G4HepEmElectronTrack which must have sampled
0078     * `number-of-interaction-left`. The computed physics step length is written directly into the input
0079     * track. There is no local (state) variable used in the computation.
0080     *
0081     * Note: This function does *not* involve multiple scattering!
0082     *
0083     * @param hepEmData pointer to the top level, global, G4HepEmData structure.
0084     * @param hepEmPars pointer to the global, G4HepEmParameters structure.
0085     * @param theElTrack pointer to the input information of the track. The data structure must have all entries
0086     *   `number-of-interaction-left` sampled and is also used to deliver the results of the function call, i.e.
0087     *   the computed physics step limit is written into its fPStepLength member.
0088     */
0089   G4HepEmHostDevice
0090   static void HowFarToDiscreteInteraction(struct G4HepEmData* hepEmData, struct G4HepEmParameters* hepEmPars, G4HepEmElectronTrack* theElTrack);
0091 
0092   /** Function that provides the information regarding how far a given e-/e+ particle goes.
0093     *
0094     * This function provides the information regarding how far a given e-/e+ particle goes
0095     * till it's needed to be stopped again because of a MSC step limit.
0096     * The input/primary e-/e+ particle track is provided as G4HepEmElectronTrack which must have sampled
0097     * `number-of-interaction-left`. The computed physics step length is written directly into the input
0098     * track. There is no local (state) variable used in the computation.
0099     *
0100     * Note: This function does *not* involve multiple scattering!
0101     *
0102     * @param hepEmData pointer to the top level, global, G4HepEmData structure.
0103     * @param hepEmPars pointer to the global, G4HepEmParameters structure.
0104     * @param theElTrack pointer to the input information of the track, used to deliver the results of
0105     *   the function call, i.e.the computed physics step limit is written into its fPStepLength and
0106     *   fGStepLength member.
0107     */
0108   G4HepEmHostDevice
0109   static void HowFarToMSC(struct G4HepEmData* hepEmData, struct G4HepEmParameters* hepEmPars, G4HepEmElectronTrack* theElTrack, G4HepEmRandomEngine* rnge);
0110 
0111   /** Function that provides the information regarding how far a given e-/e+ particle goes.
0112     *
0113     * This function provides the information regarding how far a given e-/e+ particle goes
0114     * till it's needed to be stopped again because some physics interaction(s) needs to be performed.
0115     * The input/primary e-/e+ particle track is provided as G4HepEmElectronTrack which must have sampled
0116     * `number-of-interaction-left`. The computed physics step length is written directly into the input
0117     * track. There is no local (state) variable used in the computation.
0118     *
0119     * @param hepEmData pointer to the top level, global, G4HepEmData structure.
0120     * @param hepEmPars pointer to the global, G4HepEmParameters structure.
0121     * @param theElTrack pointer to the input information of the track. The data structure must have all entries
0122     *   `number-of-interaction-left` sampled and is also used to deliver the results of the function call, i.e.
0123     *   the computed physics step limit is written into its fGStepLength member.
0124     */
0125   G4HepEmHostDevice
0126   static void HowFar(struct G4HepEmData* hepEmData, struct G4HepEmParameters* hepEmPars, G4HepEmElectronTrack* theElTrack, G4HepEmRandomEngine* rnge);
0127 
0128   /** Function that updates the physical step length after the geometry step.
0129     *
0130     * If MSC is active and we hit a boundary, convert the geometry step length
0131     * to a true step length.
0132     */
0133   G4HepEmHostDevice
0134   static void UpdatePStepLength(G4HepEmElectronTrack* theElTrack);
0135 
0136   /** Update the number-of-interaction-left according to the physical step length.
0137     *
0138     * @param theElTrack pointer to the input and output information of the track.
0139     */
0140   G4HepEmHostDevice
0141   static void UpdateNumIALeft(G4HepEmElectronTrack* theElTrack);
0142 
0143   /** Apply the mean energy loss along the physical step length.
0144     *
0145     * @param hepEmData pointer to the top level, global, G4HepEmData structure.
0146     * @param hepEmPars pointer to the global, G4HepEmParameters structure.
0147     * @param theElTrack pointer to the input and output information of the track.
0148     */
0149   G4HepEmHostDevice
0150   static bool ApplyMeanEnergyLoss(struct G4HepEmData* hepEmData, struct G4HepEmParameters* hepEmPars, G4HepEmElectronTrack* theElTrack);
0151 
0152   /** Sample MSC direction change and displacement.
0153     *
0154     * @param hepEmData pointer to the top level, global, G4HepEmData structure.
0155     * @param hepEmPars pointer to the global, G4HepEmParameters structure.
0156     * @param theElTrack pointer to the input and output information of the track.
0157     */
0158   G4HepEmHostDevice
0159   static void SampleMSC(struct G4HepEmData* hepEmData, struct G4HepEmParameters* hepEmPars, G4HepEmElectronTrack* theElTrack, G4HepEmRandomEngine* rnge);
0160 
0161   /** Sample loss fluctuations for the mean energy loss.
0162     *
0163     * @param hepEmData pointer to the top level, global, G4HepEmData structure.
0164     * @param hepEmPars pointer to the global, G4HepEmParameters structure.
0165     * @param theElTrack pointer to the input and output information of the track.
0166     */
0167   G4HepEmHostDevice
0168   static bool SampleLossFluctuations(struct G4HepEmData* hepEmData, struct G4HepEmParameters* hepEmPars, G4HepEmElectronTrack* theElTrack, G4HepEmRandomEngine* rnge);
0169 
0170   /** Functions that performs all continuous physics interactions for a given e-/e+ particle.
0171     *
0172     * This functions can be invoked when the particle is propagated to its post-step point to perform all
0173     * continuous physics interactions. The input/primary e-/e+ particle track is provided through as
0174     * G4HepEmElectronTrack. There is no local (state) variable used in the computation.
0175     *
0176     * @param hepEmData pointer to the top level, global, G4HepEmData structure.
0177     * @param hepEmPars pointer to the global, G4HepEmParameters structure.
0178     * @param theElTrack pointer to the input information of the track. All the results of this function call,
0179     *   i.e. the primary particle's energy updated to its post-interaction(s), are also delivered through this
0180     *   object.
0181     * @return boolean whether the particle was stopped
0182     */
0183   G4HepEmHostDevice
0184   static bool PerformContinuous(struct G4HepEmData* hepEmData, struct G4HepEmParameters* hepEmPars, G4HepEmElectronTrack* theElTrack, G4HepEmRandomEngine* rnge);
0185 
0186   /** Function to check if a delta interaction happens instead of the discrete process.
0187     *
0188     * @param hepEmData pointer to the top level, global, G4HepEmData structure.
0189     * @param hepEmPars pointer to the global, G4HepEmParameters structure.
0190     * @param theTrack pointer to the input information of the track.
0191     * @param rand number drawn at random
0192     * @return boolean whether a delta interaction happens
0193     */
0194   G4HepEmHostDevice
0195   static bool CheckDelta(struct G4HepEmData* hepEmData, G4HepEmTrack* theTrack, double rand);
0196 
0197   /** Functions that performs the discrete interaction for a given e-/e+ particle.
0198     *
0199     * @param hepEmData pointer to the top level, global, G4HepEmData structure.
0200     * @param hepEmPars pointer to the global, G4HepEmParameters structure.
0201     * @param tlData    pointer to a worker-local, G4HepEmTLData object. The corresonding object
0202     *   is assumed to contain all the required input information in its primary G4HepEmTLData::fElectronTrack
0203     *   member. All the results of this function call, i.e. the primary particle updated to its post-interaction(s)
0204     *   state as well as the possible secondary particles, are also delivered through this G4HepEmTLData.
0205     */
0206   static void PerformDiscrete(struct G4HepEmData* hepEmData, struct G4HepEmParameters* hepEmPars, G4HepEmTLData* tlData);
0207 
0208   /** Functions that performs all physics interactions for a given e-/e+ particle.
0209     *
0210     * This functions can be invoked when the particle is propagated to its post-step point to perform all
0211     * physics interactions. The input/primary e-/e+ particle track is provided through the G4HepEmTLData input
0212     * argument. The post-interaction(s) primary track and the secondary tracks are also provided through this
0213     * G4HepEmTLData input argument. There is no any local (state) variable used in the computation.
0214     *
0215     * @param hepEmData pointer to the top level, global, G4HepEmData structure.
0216     * @param hepEmPars pointer to the global, G4HepEmParameters structure.
0217     * @param tlData    pointer to a worker-local, G4HepEmTLData object. The corresonding object
0218     *   is assumed to contain all the required input information in its primary G4HepEmTLData::fElectronTrack
0219     *   member. All the results of this function call, i.e. the primary particle updated to its post-interaction(s)
0220     *   state as well as the possible secondary particles, are also delivered through this G4HepEmTLData.
0221     */
0222   static void Perform(struct G4HepEmData* hepEmData, struct G4HepEmParameters* hepEmPars, G4HepEmTLData* tlData);
0223 
0224   /// The following functions are not meant to be called directly by clients, only from tests.
0225 
0226   /**
0227     * Auxiliary function that evaluates and provides the `restricted range` for the given kinetic energy
0228     * and material-cuts combination.
0229     *
0230     * @param elData pointer to the global e-/e+ data structure that contains the corresponding `Energy Loss` related data.
0231     * @param imc    index of the ``G4HepEm`` material-cuts in which the range is required
0232     * @param ekin   kinetic energy of the e-/e+ at which the range is required
0233     * @param lekin  logarithm of the above kinetic energy
0234     * @return `Restricted range` value, interpolated at the given e-/e+ kinetic energy in the given material-cuts based on
0235     *   the corresponding (discrete) `Energy Loss` data provded as input.
0236     */
0237 
0238   G4HepEmHostDevice
0239   static double GetRestRange(const struct G4HepEmElectronData* elData, const int imc, const double ekin, const double lekin);
0240 
0241   G4HepEmHostDevice
0242   static double GetRestDEDX(const struct G4HepEmElectronData* elData, const int imc, const double ekin, const double lekin);
0243 
0244   G4HepEmHostDevice
0245   static double GetInvRange(const struct G4HepEmElectronData* elData, int imc, double range);
0246 
0247   G4HepEmHostDevice
0248   static double GetRestMacXSec(const struct G4HepEmElectronData* elData, const int imc, const double ekin,
0249                                const double lekin, bool isioni);
0250   G4HepEmHostDevice
0251   static double GetMacXSecNuclear(const struct G4HepEmElectronData* elData, const int imat, const double ekin,
0252                                   const double lekin);
0253 
0254   G4HepEmHostDevice
0255   static double GetRestMacXSecForStepping(const struct G4HepEmElectronData* elData, const int imc, double ekin,
0256                                           double lekin, bool isioni);
0257   G4HepEmHostDevice
0258   static double GetMacXSecNuclearForStepping(const struct G4HepEmElectronData* elData, const int imat, const double ekin,
0259                                              const double lekin);
0260 
0261   G4HepEmHostDevice
0262   static double GetTransportMFP(const struct G4HepEmElectronData* elData, const int im, const double ekin, const double lekin);
0263 
0264   G4HepEmHostDevice
0265   static double ComputeMacXsecAnnihilation(const double ekin, const double electronDensity);
0266 
0267   G4HepEmHostDevice
0268   static double ComputeMacXsecAnnihilationForStepping(const double ekin, const double electronDensity);
0269 
0270   G4HepEmHostDevice
0271   static void   ConvertTrueToGeometricLength(const G4HepEmData* hepEmData, G4HepEmMSCTrackData* mscData,
0272                                              double ekin, double range, int imc, bool iselectron);
0273 
0274   G4HepEmHostDevice
0275   static void   ConvertGeometricToTrueLength(G4HepEmMSCTrackData* mscData, double range, double gStepToConvert);
0276 };
0277 
0278 
0279 #endif // G4HepEmElectronManager_HH