CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 <tbb/concurrent_vector.h>
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 G4SimEvent;
31 class G4Run;
32 class SimTrackManager;
33 class CustomUIsession;
34 
35 class RunAction;
36 class EventAction;
37 class TrackingAction;
38 class SteppingAction;
39 class CMSSteppingVerbose;
40 class G4Field;
41 
45 
46 class SimWatcher;
47 class SimProducer;
48 
50 public:
53 
54  void beginRun(const edm::EventSetup&);
55  void endRun();
56 
57  std::unique_ptr<G4SimEvent> produce(const edm::Event& inpevt,
58  const edm::EventSetup& es,
59  RunManagerMT& runManagerMaster);
60 
61  void abortEvent();
62  void abortRun(bool softAbort = false);
63 
64  inline G4SimEvent* simEvent() { return m_simEvent; }
65 
66  void Connect(RunAction*);
67  void Connect(EventAction*);
68  void Connect(TrackingAction*);
69  void Connect(SteppingAction*);
70 
72  std::vector<SensitiveTkDetector*>& sensTkDetectors();
73  std::vector<SensitiveCaloDetector*>& sensCaloDetectors();
74  std::vector<std::shared_ptr<SimProducer>>& producers();
75 
76  void initializeG4(RunManagerMT* runManagerMaster, const edm::EventSetup& es);
77 
78 private:
79  void initializeTLS();
80  void initializeUserActions();
81  void initializeRun();
82  void terminateRun();
83 
84  G4Event* generateEvent(const edm::Event& inpevt);
85  void resetGenParticleId(const edm::Event& inpevt);
86 
87  void DumpMagneticField(const G4Field*, const std::string&) const;
88 
89  inline int getThreadIndex() const { return m_thread_index; }
90 
96  const MagneticField* m_pMagField{nullptr};
97 
98  bool m_nonBeam{false};
99  bool m_pUseMagneticField{true};
100  bool m_hasWatchers{false};
101  bool m_LHCTransport{false};
102  bool m_dumpMF{false};
103 
104  const int m_thread_index{-1};
106 
115 
116  struct TLSData;
117  TLSData* m_tls{nullptr};
118 
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
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)
int getThreadIndex() const
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
edm::ParameterSet m_pCustomUIsession
const MagneticField * m_pMagField
void initializeG4(RunManagerMT *runManagerMaster, const edm::EventSetup &es)
edm::ParameterSet m_p
edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > m_MagField
void DumpMagneticField(const G4Field *, const std::string &) const
edm::ParameterSet m_pStackingAction
void Connect(RunAction *)