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 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  G4SimEvent* produce(const edm::Event& inpevt, const edm::EventSetup& es, RunManagerMT& runManagerMaster);
57 
58  void abortEvent();
59  void abortRun(bool softAbort = false);
60 
61  void Connect(RunAction*);
62  void Connect(EventAction*);
63  void Connect(TrackingAction*);
64  void Connect(SteppingAction*);
65 
67  std::vector<SensitiveTkDetector*>& sensTkDetectors();
68  std::vector<SensitiveCaloDetector*>& sensCaloDetectors();
69  std::vector<std::shared_ptr<SimProducer>>& producers();
70 
71  void initializeG4(RunManagerMT* runManagerMaster, const edm::EventSetup& es);
72 
73  inline G4SimEvent* simEvent() { return &m_simEvent; }
74  inline int getThreadIndex() const { return m_thread_index; }
75 
76 private:
77  void initializeTLS();
78  void initializeUserActions();
79  void initializeRun();
80  void terminateRun();
81 
82  G4Event* generateEvent(const edm::Event& inpevt);
83  void resetGenParticleId(const edm::Event& inpevt);
84 
85  void DumpMagneticField(const G4Field*, const std::string&) const;
86 
92  const MagneticField* m_pMagField{nullptr};
93 
94  bool m_nonBeam{false};
95  bool m_pUseMagneticField{true};
96  bool m_hasWatchers{false};
97  bool m_LHCTransport{false};
98  bool m_dumpMF{false};
99  bool m_endOfRun{false};
100 
101  const int m_thread_index{-1};
102 
110  std::vector<std::string> m_G4CommandsEndRun;
112 
113  struct TLSData;
114  TLSData* m_tls{nullptr};
115 
118  std::unique_ptr<CMSSteppingVerbose> m_sVerbose;
119  std::unordered_map<std::string, std::unique_ptr<SensitiveDetectorMakerBase>> m_sdMakers;
120 };
121 
122 #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)
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 *)