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 
12 
13 #include <memory>
14 #include <unordered_map>
15 #include <string>
16 
17 namespace edm {
18  class ParameterSet;
19  class Event;
20  class EventSetup;
21  class ConsumesCollector;
22  class HepMCProduct;
23 } // namespace edm
24 
25 class Generator;
26 class RunManagerMT;
27 
28 class G4Event;
29 class G4SimEvent;
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 G4Field;
40 
44 
45 class SimWatcher;
46 class SimProducer;
47 
49 public:
50  explicit RunManagerMTWorker(const edm::ParameterSet& iConfig, edm::ConsumesCollector&& iC);
52 
53  void beginRun(const edm::EventSetup&);
54  void endRun();
55 
56  std::unique_ptr<G4SimEvent> produce(const edm::Event& inpevt,
57  const edm::EventSetup& es,
58  RunManagerMT& runManagerMaster);
59 
60  void abortEvent();
61  void abortRun(bool softAbort = false);
62 
63  inline G4SimEvent* simEvent() { return m_simEvent; }
64 
65  void Connect(RunAction*);
66  void Connect(EventAction*);
67  void Connect(TrackingAction*);
68  void Connect(SteppingAction*);
69 
71  std::vector<SensitiveTkDetector*>& sensTkDetectors();
72  std::vector<SensitiveCaloDetector*>& sensCaloDetectors();
73  std::vector<std::shared_ptr<SimProducer>>& producers();
74 
75  void initializeG4(RunManagerMT* runManagerMaster, const edm::EventSetup& es);
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 
88  inline int getThreadIndex() const { return m_thread_index; }
89 
95  const MagneticField* m_pMagField{nullptr};
96 
97  bool m_nonBeam{false};
98  bool m_pUseMagneticField{true};
99  bool m_hasWatchers{false};
100  bool m_LHCTransport{false};
101  bool m_dumpMF{false};
102 
103  const int m_thread_index{-1};
105 
114 
115  struct TLSData;
116  TLSData* m_tls{nullptr};
117 
120  std::unique_ptr<CMSSteppingVerbose> m_sVerbose;
121  std::unordered_map<std::string, std::unique_ptr<SensitiveDetectorMakerBase>> m_sdMakers;
122 };
123 
124 #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
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)
std::unique_ptr< G4SimEvent > produce(const edm::Event &inpevt, const edm::EventSetup &es, RunManagerMT &runManagerMaster)
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 *)