Back to home page

EIC code displayed by LXR

 
 

    


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

0001 
0002 
0003 #ifndef G4HepEmRunManager_HH
0004 #define G4HepEmRunManager_HH
0005 
0006 
0007 
0008 // forward declare
0009 struct G4HepEmData;
0010 struct G4HepEmParameters;
0011 
0012 class  G4HepEmTLData;
0013 class  G4HepEmElectronManager;
0014 class  G4HepEmGammaManager;
0015 
0016 class  G4HepEmRandomEngine;
0017 
0018 #include <vector>
0019 
0020 
0021 /**
0022  * @file    G4HepEmRunManager.hh
0023  * @class   G4HepEmRunManager
0024  * @author  M. Novak
0025  * @date    2020
0026  *
0027  * This is the top level interface to all G4HepEm functionalities.
0028  *
0029  * A master object is responsible to construct, store and initialise all global
0030  * (e.g. material, material-cut, element, configuartion parameter, etc) related
0031  * data structures used by (at run-time), and shared among all other (worker)
0032  * run managers. These need to be done only once for a given run: only once for
0033  * all (e-/e+ and gamma) particles and only by the master.
0034  * Additional data structures are aslo created by the master run manager that
0035  * are also shared between the workers. These are data, specific for a given
0036  * particle type and needs to be crated only if it's required i.e. if the
0037  * simulation of that particle needs to be done by the HepEm. These need to be
0038  * created and initialised only by the master and individually for each particle
0039  * when requested.
0040  * All the above data objects are constructed by and stored in the master run
0041  * manager and worker run managers will have only their pointer mebers to set to
0042  * these unique data objects (used as read-only at run time).
0043  * Beyond these shared data objects, each worker run-manager will have their own
0044  * instance from the G4HepEmTLData that stores worker local data.
0045  */
0046 
0047 
0048 
0049 class G4HepEmRunManager {
0050 
0051 public:
0052 
0053   G4HepEmRunManager (bool ismaster);
0054  ~G4HepEmRunManager ();
0055 
0056   static G4HepEmRunManager* GetMasterRunManager ();
0057 
0058   /**
0059    * Builds or sets (data) members of run-manager.
0060    *
0061    * For the master-RM it initialises i.e. builds:
0062    * - the `global` data structures that are shared by all run-managers i.e.
0063    *   shared by all workers, processes and particles at run-time as read-only
0064    *   data (configuration parameters, all the elememnt, material and material-
0065    *   production-cuts related data structres).
0066    * - particle specific data that are also shared by all run-managers i.e. by
0067    *   all workers (range, dE/dx tables for e-/e+, macroscopic cross sections
0068    *   and target element selectors)
0069    * For a worker-RM:
0070    * - sets all the pointer members to data that are shared among the run-managers
0071    *   to their master values.
0072    * - creates and sets the worker-local data structure for each worker and sets
0073    *   its random engine pointer to the corresponding geant4, thread local random
0074    *   engine pointer.
0075    */
0076   void Initialize (G4HepEmRandomEngine* theRNGEngine, int hepEmParticleIndx, G4HepEmParameters* hepEmPars=nullptr);
0077 
0078 
0079   /**
0080    * Clears all data structures that has been created by calling the Initialize()
0081    * method and re-sets the correspondig pointer members to null.
0082    */
0083   void Clear ();
0084 
0085   /** delete copy CTR and assigment operators */
0086   G4HepEmRunManager (const G4HepEmRunManager&) = delete;
0087   G4HepEmRunManager& operator= (const G4HepEmRunManager&) = delete;
0088 
0089  //  void SetHepEmData(struct G4HepEmData* hepEmData) { fTheG4HepEmData; }
0090 
0091   struct G4HepEmData*       GetHepEmData()         const  { return fTheG4HepEmData; }
0092   struct G4HepEmParameters* GetHepEmParameters()   const  { return fTheG4HepEmParameters; }
0093   G4HepEmTLData*            GetTheTLData()         const  { return fTheG4HepEmTLData; }
0094 
0095   void SetVerbose(int verbose) { fVerbose = verbose; }
0096 
0097 private:
0098 
0099   /**
0100    * Initialisation of all global data structures.
0101    *
0102    * Extracts EM and other configuration parameters, builds all the elememnt,
0103    * matrial and material-production-cuts related data structures shared by all
0104    * workers, all processes and all particles at run-time as read-only data. In
0105    * other words, these are the `global` data structures.
0106    * This should be invoked by the master thread and only once!
0107    */
0108   void InitializeGlobal (G4HepEmParameters* hepEmPars=nullptr);
0109 
0110 
0111 
0112 
0113 private:
0114   /** Flag to indicate the master run-manager.*/
0115   bool                           fIsMaster;
0116   /** Flags to indicate if the master has been initialized for the given particle.*/
0117   bool                           fIsInitialisedForParticle[3];
0118   /** Pointer to the master run-manager.*/
0119   static G4HepEmRunManager*      gTheG4HepEmRunManagerMaster;
0120   /**
0121    * === These data are created by the Master-RM and shared among all Worker-RMs.
0122    *
0123    * Collection of configuration parameters used at initialization and run time.
0124    */
0125   struct G4HepEmParameters*      fTheG4HepEmParameters;
0126   bool   fExternalParameters;
0127   /*
0128    * The top level data structure that stores all the data used by all processes
0129    * (e.g. material or material cuts couple related data, etc.)
0130    * The coresponding data structures are created and filled when calling the
0131    * Initialize() method
0132    */
0133   struct G4HepEmData*            fTheG4HepEmData;
0134 
0135   /*
0136    * Processes for e-/e+: this is the top level object to all e-/e+ related
0137    * interactions that can provide response to how far the particle goes till the
0138    * next interaction and what happens in that interaction.
0139    *
0140    *
0141    * === These data are created for each Worker-RM.
0142    */
0143 
0144   G4HepEmTLData*                 fTheG4HepEmTLData;
0145 
0146   // Verbosity level (only 0/1 at the moment)
0147   int fVerbose;
0148 
0149 };
0150 
0151 #endif // G4HepEmRunManager_HH