CMS 3D CMS Logo

RunManagerMTWorker.h
Go to the documentation of this file.
1 #ifndef SimG4Core_Application_RunManagerMTWorker_H
2 #define SimG4Core_Application_RunManagerMTWorker_H
3 
6 
9 
13 
14 #include <memory>
15 #include <unordered_map>
16 #include <string>
17 
18 namespace edm {
19  class ParameterSet;
20  class Event;
21  class EventSetup;
22  class ConsumesCollector;
23  class HepMCProduct;
24 } // namespace edm
25 
26 class Generator;
27 class RunManagerMT;
28 
29 class G4Event;
30 class G4Run;
31 class SimTrackManager;
32 class CustomUIsession;
33 
34 class RunAction;
35 class EventAction;
36 class TrackingAction;
37 class SteppingAction;
38 class CMSSteppingVerbose;
39 class CMSSimEventManager;
40 class G4Field;
41 
45 
46 class SimWatcher;
47 class SimProducer;
48 
50 public:
51  explicit RunManagerMTWorker(const edm::ParameterSet& iConfig, edm::ConsumesCollector&& iC);
53 
54  void beginRun(const edm::EventSetup&);
55  void endRun();
56 
57  G4SimEvent* produce(const edm::Event& inpevt, const edm::EventSetup& es, RunManagerMT& runManagerMaster);
58 
59  void abortEvent();
60  void abortRun(bool softAbort = false);
61 
62  void Connect(RunAction*);
63  void Connect(EventAction*);
64  void Connect(TrackingAction*);
65  void Connect(SteppingAction*);
66 
68  std::vector<SensitiveTkDetector*>& sensTkDetectors();
69  std::vector<SensitiveCaloDetector*>& sensCaloDetectors();
70  std::vector<std::shared_ptr<SimProducer>>& producers();
71 
72  void initializeG4(RunManagerMT* runManagerMaster, const edm::EventSetup& es);
73 
74  inline G4SimEvent* simEvent() { return &m_simEvent; }
75  inline int getThreadIndex() const { return m_thread_index; }
76 
77 private:
78  void initializeTLS();
79  void initializeUserActions();
80  void initializeRun();
81  void terminateRun();
82 
83  G4Event* generateEvent(const edm::Event& inpevt);
84  void resetGenParticleId(const edm::Event& inpevt);
85 
86  void DumpMagneticField(const G4Field*, const std::string&) const;
87 
93  const MagneticField* m_pMagField{nullptr};
94 
95  bool m_nonBeam{false};
96  bool m_UseG4EventManager{true};
97  bool m_pUseMagneticField{true};
98  bool m_hasWatchers{false};
99  bool m_LHCTransport{false};
100  bool m_dumpMF{false};
101  bool m_endOfRun{false};
102 
103  const int m_thread_index{-1};
104 
112  std::vector<std::string> m_G4CommandsEndRun;
114 
115  struct TLSData;
116  TLSData* m_tls{nullptr};
117 
120  std::unique_ptr<CMSSimEventManager> m_evtManager;
121  std::unique_ptr<CMSSteppingVerbose> m_sVerbose;
122  std::unordered_map<std::string, std::unique_ptr<SensitiveDetectorMakerBase>> m_sdMakers;
123 };
124 
125 #endif
edm::ParameterSet m_pSteppingAction
CustomUIsession * m_UIsession
SimTrackManager * GetSimTrackManager()
std::unique_ptr< CMSSteppingVerbose > m_sVerbose
void beginRun(const edm::EventSetup &)
edm::EDGetTokenT< edm::HepMCProduct > m_InToken
std::vector< std::string > m_G4CommandsEndRun
G4SimEvent * produce(const edm::Event &inpevt, const edm::EventSetup &es, RunManagerMT &runManagerMaster)
std::unique_ptr< CMSSimEventManager > m_evtManager
edm::EDGetTokenT< edm::HepMCProduct > m_LHCToken
G4SimEvent * simEvent()
edm::ParameterSet m_pEventAction
edm::ParameterSet m_pRunAction
std::unordered_map< std::string, std::unique_ptr< SensitiveDetectorMakerBase > > m_sdMakers
std::vector< SensitiveTkDetector * > & sensTkDetectors()
void resetGenParticleId(const edm::Event &inpevt)
RunManagerMTWorker(const edm::ParameterSet &iConfig, edm::ConsumesCollector &&iC)
void abortRun(bool softAbort=false)
std::vector< SensitiveCaloDetector * > & sensCaloDetectors()
edm::ParameterSet m_pTrackingAction
edm::ParameterSet m_pField
G4Event * generateEvent(const edm::Event &inpevt)
std::vector< std::shared_ptr< SimProducer > > & producers()
edm::EDGetTokenT< edm::LHCTransportLinkContainer > m_theLHCTlinkToken
HLT enums.
edm::ParameterSet m_pCustomUIsession
const MagneticField * m_pMagField
void initializeG4(RunManagerMT *runManagerMaster, const edm::EventSetup &es)
edm::ParameterSet m_p
void DumpMagneticField(const G4Field *, const std::string &) const
int getThreadIndex() const
edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > m_MagField
edm::ParameterSet m_pStackingAction
void Connect(RunAction *)