File indexing completed on 2025-01-18 09:14:21
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #ifndef DDG4_GEANT4RUNMANAGER_H
0014 #define DDG4_GEANT4RUNMANAGER_H 1
0015
0016
0017 #include <DDG4/Geant4Action.h>
0018
0019
0020 #include <G4RunManager.hh>
0021
0022
0023 namespace dd4hep {
0024
0025
0026 namespace sim {
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045 template <typename RUNMANAGER>
0046 class Geant4RunManager : public Geant4Action, public RUNMANAGER {
0047 public:
0048 Geant4RunManager(Geant4Context* ctxt, const std::string& nam)
0049 : Geant4Action(ctxt, nam), RUNMANAGER()
0050 {
0051 declareProperty("NumberOfThreads", m_numThreads);
0052 }
0053 virtual ~Geant4RunManager() { }
0054
0055 virtual void enableUI();
0056 private:
0057
0058 int m_numThreads;
0059 };
0060 template <> void Geant4RunManager<G4RunManager>::enableUI() {
0061 Geant4Action::enableUI();
0062 printout(WARNING,"Geant4RunManager","+++ Configured run manager of type: %s.",
0063 typeName(typeid(G4RunManager)).c_str());
0064 printout(WARNING,"Geant4Kernel","+++ Multi-threaded mode requested, "
0065 "but not supported by this compilation of Geant4.");
0066 printout(WARNING,"Geant4Kernel","+++ Falling back to single threaded mode.");
0067 m_numThreads = 0;
0068 }
0069 typedef Geant4RunManager<G4RunManager> Geant4STRunManager;
0070 }
0071 }
0072 #endif
0073
0074 #include <DDG4/Factories.h>
0075 using namespace dd4hep::sim;
0076 DD4HEP_PLUGINSVC_FACTORY(Geant4STRunManager,G4RunManager,dd4hep::sim::Geant4Action*(_ns::CT*,std::string),__LINE__)
0077
0078 #ifdef G4MULTITHREADED
0079 #include <G4MTRunManager.hh>
0080
0081
0082 namespace dd4hep {
0083
0084 namespace sim {
0085 template <> void Geant4RunManager<G4MTRunManager>::enableUI() {
0086 Geant4Action::enableUI();
0087 this->G4MTRunManager::SetNumberOfThreads(m_numThreads);
0088 printout(WARNING,"Geant4RunManager","+++ Configured run manager of type: %s with %d threads.",
0089 typeName(typeid(G4MTRunManager)).c_str(), m_numThreads);
0090 }
0091 typedef Geant4RunManager<G4MTRunManager> Geant4MTRunManager;
0092 }
0093 }
0094 DD4HEP_PLUGINSVC_FACTORY(Geant4MTRunManager,G4MTRunManager,dd4hep::sim::Geant4Action*(_ns::CT*,std::string),__LINE__)
0095 #endif
0096
0097