CMS 3D CMS Logo

OscarMTMasterThread.h
Go to the documentation of this file.
1 #ifndef SimG4Core_OscarMTMasterThread_H
2 #define SimG4Core_OscarMTMasterThread_H
3 
6 
9 
10 #include <memory>
11 #include <thread>
12 #include <mutex>
13 #include <condition_variable>
14 
15 namespace edm {
16  class EventSetup;
17 }
18 
19 class RunManagerMT;
20 
21 class DDCompactView;
22 class MagneticField;
23 
24 namespace cms {
25  class DDCompactView;
26 }
27 
28 namespace HepPDT {
29  class ParticleDataTable;
30 }
31 
33 public:
34  explicit OscarMTMasterThread(const edm::ParameterSet& iConfig);
36 
37  void beginRun(const edm::EventSetup& iSetup) const;
38  void endRun() const;
39  void stopThread();
40 
41  inline RunManagerMT& runManagerMaster() const { return *m_runManagerMaster; }
42  inline RunManagerMT* runManagerMasterPtr() const { return m_runManagerMaster.get(); }
43 
44 private:
45  void readES(const edm::EventSetup& iSetup) const;
46 
47  enum class ThreadState { NotExist = 0, BeginRun = 1, EndRun = 2, Destruct = 3 };
48 
49  const bool m_pGeoFromDD4hep;
50 
51  std::shared_ptr<RunManagerMT> m_runManagerMaster;
52  std::thread m_masterThread;
53 
54  // ES products needed for Geant4 initialization
57  mutable const DDCompactView* m_pDD;
58  mutable const cms::DDCompactView* m_pDD4hep;
60 
63  mutable std::condition_variable m_notifyMasterCv;
64  mutable std::condition_variable m_notifyMainCv;
65 
67 
68  mutable bool m_masterCanProceed;
69  mutable bool m_mainCanProceed;
70  mutable bool m_firstRun;
71  mutable bool m_stopped;
72 };
73 
74 #endif
OscarMTMasterThread::m_notifyMasterCv
std::condition_variable m_notifyMasterCv
Definition: OscarMTMasterThread.h:63
OscarMTMasterThread::m_masterThread
std::thread m_masterThread
Definition: OscarMTMasterThread.h:52
edm::ESWatcher< IdealGeometryRecord >
OscarMTMasterThread::m_firstRun
bool m_firstRun
Definition: OscarMTMasterThread.h:70
edm
HLT enums.
Definition: AlignableModifier.h:19
OscarMTMasterThread::OscarMTMasterThread
OscarMTMasterThread(const edm::ParameterSet &iConfig)
Definition: OscarMTMasterThread.cc:22
OscarMTMasterThread::ThreadState::BeginRun
OscarMTMasterThread::endRun
void endRun() const
Definition: OscarMTMasterThread.cc:141
OscarMTMasterThread::ThreadState
ThreadState
Definition: OscarMTMasterThread.h:47
OscarMTMasterThread::ThreadState::EndRun
OscarMTMasterThread::m_masterThreadState
ThreadState m_masterThreadState
Definition: OscarMTMasterThread.h:66
DDCompactView
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:81
OscarMTMasterThread::m_mainCanProceed
bool m_mainCanProceed
Definition: OscarMTMasterThread.h:69
IdealMagneticFieldRecord.h
OscarMTMasterThread::m_runManagerMaster
std::shared_ptr< RunManagerMT > m_runManagerMaster
Definition: OscarMTMasterThread.h:51
RunManagerMT
Definition: RunManagerMT.h:55
OscarMTMasterThread::stopThread
void stopThread()
Definition: OscarMTMasterThread.cc:155
OscarMTMasterThread::idealMagRcdWatcher_
edm::ESWatcher< IdealMagneticFieldRecord > idealMagRcdWatcher_
Definition: OscarMTMasterThread.h:56
edm::ParameterSet
Definition: ParameterSet.h:47
OscarMTMasterThread::runManagerMaster
RunManagerMT & runManagerMaster() const
Definition: OscarMTMasterThread.h:41
OscarMTMasterThread::m_protectMutex
std::mutex m_protectMutex
Definition: OscarMTMasterThread.h:61
HepPDT
Definition: ParticleManager.h:17
OscarMTMasterThread::runManagerMasterPtr
RunManagerMT * runManagerMasterPtr() const
Definition: OscarMTMasterThread.h:42
OscarMTMasterThread::~OscarMTMasterThread
~OscarMTMasterThread()
Definition: OscarMTMasterThread.cc:116
mutex
static std::mutex mutex
Definition: Proxy.cc:8
OscarMTMasterThread::m_stopped
bool m_stopped
Definition: OscarMTMasterThread.h:71
IdealGeometryRecord.h
edm::EventSetup
Definition: EventSetup.h:58
OscarMTMasterThread
Definition: OscarMTMasterThread.h:32
OscarMTMasterThread::m_pDD
const DDCompactView * m_pDD
Definition: OscarMTMasterThread.h:57
OscarMTMasterThread::ThreadState::NotExist
OscarMTMasterThread::m_masterCanProceed
bool m_masterCanProceed
Definition: OscarMTMasterThread.h:68
OscarMTMasterThread::m_pGeoFromDD4hep
const bool m_pGeoFromDD4hep
Definition: OscarMTMasterThread.h:49
ESWatcher.h
cms::DDCompactView
Definition: DDCompactView.h:31
OscarMTMasterThread::m_pDD4hep
const cms::DDCompactView * m_pDD4hep
Definition: OscarMTMasterThread.h:58
OscarMTMasterThread::beginRun
void beginRun(const edm::EventSetup &iSetup) const
Definition: OscarMTMasterThread.cc:122
OscarMTMasterThread::m_pTable
const HepPDT::ParticleDataTable * m_pTable
Definition: OscarMTMasterThread.h:59
OscarMTMasterThread::readES
void readES(const edm::EventSetup &iSetup) const
Definition: OscarMTMasterThread.cc:180
EventSetup
ParameterSet.h
OscarMTMasterThread::idealGeomRcdWatcher_
edm::ESWatcher< IdealGeometryRecord > idealGeomRcdWatcher_
Definition: OscarMTMasterThread.h:55
OscarMTMasterThread::m_threadMutex
std::mutex m_threadMutex
Definition: OscarMTMasterThread.h:62
MagneticField
Definition: MagneticField.h:19
ParticleDataTable
HepPDT::ParticleDataTable ParticleDataTable
Definition: ParticleDataTable.h:8
OscarMTMasterThread::m_notifyMainCv
std::condition_variable m_notifyMainCv
Definition: OscarMTMasterThread.h:64
OscarMTMasterThread::ThreadState::Destruct
cms
Namespace of DDCMS conversion namespace.
Definition: ProducerAnalyzer.cc:21