Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-06-30 23:17:20

0001 #ifndef SimG4Core_RunManagerMT_H
0002 #define SimG4Core_RunManagerMT_H
0003 
0004 #include "FWCore/Framework/interface/Event.h"
0005 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0006 
0007 #include "SimG4Core/Geometry/interface/SensitiveDetectorCatalog.h"
0008 
0009 #include "SimG4Core/Notification/interface/SimActivityRegistry.h"
0010 
0011 #include <memory>
0012 
0013 class PrimaryTransformer;
0014 class Generator;
0015 class PhysicsList;
0016 class CustomUIsession;
0017 
0018 class SimWatcher;
0019 class SimProducer;
0020 class G4SimEvent;
0021 
0022 class RunAction;
0023 
0024 class DDCompactView;
0025 
0026 namespace cms {
0027   class DDCompactView;
0028 }
0029 
0030 class DDDWorld;
0031 
0032 class G4MTRunManagerKernel;
0033 class G4Run;
0034 class G4Event;
0035 class G4StateManager;
0036 class RunAction;
0037 
0038 class SimRunInterface;
0039 
0040 namespace HepPDT {
0041   class ParticleDataTable;
0042 }
0043 
0044 /**
0045  * RunManagerMT should be constructed in a newly spanned thread
0046  * (acting as the Geant4 master thread), and there should be exactly
0047  * one instance of it. 
0048  */
0049 class RunManagerMTWorker;
0050 
0051 class RunManagerMT {
0052   friend class RunManagerMTWorker;
0053 
0054 public:
0055   explicit RunManagerMT(edm::ParameterSet const&);
0056   ~RunManagerMT();
0057 
0058   void initG4(const DDCompactView*, const cms::DDCompactView*, const HepPDT::ParticleDataTable*);
0059 
0060   void initializeUserActions();
0061 
0062   void stopG4();
0063 
0064   void Connect(RunAction*);
0065 
0066   // Keep this to keep ExceptionHandler to compile, probably removed
0067   // later (or functionality moved to RunManagerMTWorker).
0068   //  inline void abortRun(bool softAbort = false) {}
0069 
0070   inline const DDDWorld& world() const { return *m_world; }
0071 
0072   inline const SensitiveDetectorCatalog& catalog() const { return m_catalog; }
0073 
0074   inline const std::vector<std::string>& G4Commands() const { return m_G4Commands; }
0075 
0076   // In order to share the physics list with the worker threads, we
0077   // need a non-const pointer. Thread-safety is handled inside Geant4.
0078   inline PhysicsList* physicsListForWorker() const { return m_physicsList.get(); }
0079 
0080 private:
0081   void terminateRun();
0082 
0083   G4MTRunManagerKernel* m_kernel;
0084 
0085   CustomUIsession* m_UIsession;
0086   std::unique_ptr<PhysicsList> m_physicsList;
0087   bool m_managerInitialized;
0088   bool m_runTerminated;
0089   RunAction* m_userRunAction;
0090   G4Run* m_currentRun;
0091   G4StateManager* m_stateManager;
0092 
0093   std::unique_ptr<SimRunInterface> m_runInterface;
0094 
0095   const std::string m_PhysicsTablesDir;
0096   bool m_StorePhysicsTables;
0097   bool m_RestorePhysicsTables;
0098   bool m_check;
0099   edm::ParameterSet m_pPhysics;
0100   edm::ParameterSet m_pRunAction;
0101   edm::ParameterSet m_g4overlap;
0102   std::vector<std::string> m_G4Commands;
0103   edm::ParameterSet m_p;
0104 
0105   std::unique_ptr<DDDWorld> m_world;
0106   SimActivityRegistry m_registry;
0107   SensitiveDetectorCatalog m_catalog;
0108 };
0109 
0110 #endif