Back to home page

EIC code displayed by LXR

 
 

    


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

0001 
0002 #ifndef G4HepEmTLData_HH
0003 #define G4HepEmTLData_HH
0004 
0005 
0006 #include "G4HepEmElectronTrack.hh"
0007 #include "G4HepEmGammaTrack.hh"
0008 #include "G4HepEmRandomEngine.hh"
0009 
0010 #include <vector>
0011 
0012 /**
0013  * @file    G4HepEmTLData.hh
0014  * @class   G4HepEmTLData
0015  * @author  M. Novak
0016  * @date    2020
0017  *
0018  * A simple data structure to store and propagate worker local data between the components.
0019  *
0020  * Each worker `G4HepEmRunManager`-s has their own `G4HepEmTLData` object
0021  * (constructed in their `G4HepEmRunManager::Initialize()` method) that is used to store:
0022  *
0023  *   - the thread local **random engine** object pointer: to provide independent,
0024  *     unique source of random numbers for each worker when invoking the ``G4HepEm`` functions
0025  *   - **primary** \f$e^-/e^+\f$ and \f$\gamma\f$ **track** objects: to propagate primary track state
0026  *     information to/from the (state-less) `G4HepEmElectronManager`/`G4HepEmGammaManager` functions
0027  *   - **secondary** \f$e^-/e^+\f$ and \f$\gamma\f$ **track** buffers: to propagate secondary track
0028  *     information (back) from the (state-less) `G4HepEmElectronManager`/`G4HepEmGammaManager` functions
0029  *     as well as between these particle managers and the interaction functions
0030  *
0031  * @note
0032  * **All state variables** are stored in this `G4HepEmTLData` object in ``G4HepEm``.
0033  *
0034  */
0035 
0036 class G4HepEmTLData {
0037 
0038 public:
0039 
0040   G4HepEmTLData() {
0041     fRNGEngine = nullptr;
0042     fElectronSecondaryTracks.resize(2);
0043     fNumSecondaryElectronTracks = 0;
0044 
0045     fGammaSecondaryTracks.resize(2);
0046     fNumSecondaryGammaTracks = 0;
0047   }
0048 
0049  ~G4HepEmTLData() {}
0050 
0051   void SetRandomEngine(G4HepEmRandomEngine* rnge) { fRNGEngine = rnge; }
0052   G4HepEmRandomEngine* GetRNGEngine() { return fRNGEngine; }
0053 
0054   G4HepEmElectronTrack* GetPrimaryElectronTrack()   { return &fElectronTrack; }
0055   G4HepEmElectronTrack* AddSecondaryElectronTrack() {
0056     if (fNumSecondaryElectronTracks==fElectronSecondaryTracks.size()) {
0057       fElectronSecondaryTracks.resize(2*fElectronSecondaryTracks.size());
0058     }
0059     return &(fElectronSecondaryTracks[fNumSecondaryElectronTracks++]);
0060   }
0061   std::size_t GetNumSecondaryElectronTrack() { return fNumSecondaryElectronTracks; }
0062   void        ResetNumSecondaryElectronTrack() { fNumSecondaryElectronTracks = 0; }
0063   G4HepEmElectronTrack* GetSecondaryElectronTrack(int indx) { return &(fElectronSecondaryTracks[indx]); }
0064 
0065 
0066   G4HepEmGammaTrack* GetPrimaryGammaTrack()   { return &fGammaTrack; }
0067   G4HepEmGammaTrack* AddSecondaryGammaTrack() {
0068     if (fNumSecondaryGammaTracks==fGammaSecondaryTracks.size()) {
0069       fGammaSecondaryTracks.resize(2*fGammaSecondaryTracks.size());
0070     }
0071     return &(fGammaSecondaryTracks[fNumSecondaryGammaTracks++]);
0072   }
0073   std::size_t GetNumSecondaryGammaTrack() { return fNumSecondaryGammaTracks; }
0074   void        ResetNumSecondaryGammaTrack() { fNumSecondaryGammaTracks = 0; }
0075   G4HepEmGammaTrack* GetSecondaryGammaTrack(int indx) { return &(fGammaSecondaryTracks[indx]); }
0076 
0077 
0078 
0079 private:
0080 
0081   // needs to set to point to the RNG engine of the thread
0082   G4HepEmRandomEngine*               fRNGEngine;
0083 
0084   std::size_t                        fNumSecondaryElectronTracks;
0085   G4HepEmElectronTrack               fElectronTrack;
0086   std::vector<G4HepEmElectronTrack>  fElectronSecondaryTracks;
0087 
0088   std::size_t                        fNumSecondaryGammaTracks;
0089   G4HepEmGammaTrack                  fGammaTrack;
0090   std::vector<G4HepEmGammaTrack>     fGammaSecondaryTracks;
0091 
0092 };
0093 
0094 #endif // G4HepEmTLData_HH