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 
10 
11 #include "HepPDT/ParticleDataTable.hh"
13 
14 #include <memory>
15 #include <thread>
16 #include <mutex>
17 #include <condition_variable>
18 
19 namespace edm {
20  class EventSetup;
21  class ConsumesCollector;
22 } // namespace edm
23 
24 class RunManagerMT;
25 
26 class DDCompactView;
27 class MagneticField;
28 
29 namespace cms {
30  class DDCompactView;
31 }
32 
33 namespace HepPDT {
34  class ParticleDataTable;
35 }
36 
38 public:
39  explicit OscarMTMasterThread(const edm::ParameterSet& iConfig);
41 
42  void beginRun(const edm::EventSetup& iSetup) const;
43  void endRun() const;
44  void stopThread();
45 
46  void callConsumes(edm::ConsumesCollector&& iC) const;
47 
48  inline RunManagerMT& runManagerMaster() const { return *m_runManagerMaster; }
49  inline RunManagerMT* runManagerMasterPtr() const { return m_runManagerMaster.get(); }
50 
51 private:
52  enum class ThreadState { NotExist = 0, BeginRun = 1, EndRun = 2, Destruct = 3 };
53 
54  const bool m_pGeoFromDD4hep;
55 
56  std::shared_ptr<RunManagerMT> m_runManagerMaster;
57  std::thread m_masterThread;
58 
59  // ES products needed for Geant4 initialization
60  mutable const DDCompactView* m_pDDD = nullptr;
61  mutable const cms::DDCompactView* m_pDD4Hep = nullptr;
62  mutable const HepPDT::ParticleDataTable* m_pTable = nullptr;
66 
67  // status flags
70  mutable std::condition_variable m_notifyMasterCv;
71  mutable std::condition_variable m_notifyMainCv;
72 
74 
75  mutable bool m_hasToken = false;
76  mutable bool m_masterCanProceed = false;
77  mutable bool m_mainCanProceed = false;
78  mutable bool m_firstRun = true;
79  mutable bool m_stopped = false;
80 };
81 
82 #endif
OscarMTMasterThread::m_hasToken
bool m_hasToken
Definition: OscarMTMasterThread.h:75
OscarMTMasterThread::m_notifyMasterCv
std::condition_variable m_notifyMasterCv
Definition: OscarMTMasterThread.h:70
OscarMTMasterThread::m_masterThread
std::thread m_masterThread
Definition: OscarMTMasterThread.h:57
OscarMTMasterThread::m_firstRun
bool m_firstRun
Definition: OscarMTMasterThread.h:78
edm
HLT enums.
Definition: AlignableModifier.h:19
OscarMTMasterThread::OscarMTMasterThread
OscarMTMasterThread(const edm::ParameterSet &iConfig)
Definition: OscarMTMasterThread.cc:12
OscarMTMasterThread::m_DDD
edm::ESGetToken< DDCompactView, IdealGeometryRecord > m_DDD
Definition: OscarMTMasterThread.h:63
OscarMTMasterThread::ThreadState::BeginRun
OscarMTMasterThread::endRun
void endRun() const
Definition: OscarMTMasterThread.cc:145
DDCompactView.h
OscarMTMasterThread::m_PDT
edm::ESGetToken< HepPDT::ParticleDataTable, PDTRecord > m_PDT
Definition: OscarMTMasterThread.h:65
OscarMTMasterThread::ThreadState
ThreadState
Definition: OscarMTMasterThread.h:52
OscarMTMasterThread::ThreadState::EndRun
OscarMTMasterThread::m_masterThreadState
ThreadState m_masterThreadState
Definition: OscarMTMasterThread.h:73
DDCompactView
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:81
OscarMTMasterThread::m_mainCanProceed
bool m_mainCanProceed
Definition: OscarMTMasterThread.h:77
OscarMTMasterThread::m_runManagerMaster
std::shared_ptr< RunManagerMT > m_runManagerMaster
Definition: OscarMTMasterThread.h:56
DDCompactView.h
RunManagerMT
Definition: RunManagerMT.h:50
OscarMTMasterThread::stopThread
void stopThread()
Definition: OscarMTMasterThread.cc:159
edm::ParameterSet
Definition: ParameterSet.h:47
OscarMTMasterThread::runManagerMaster
RunManagerMT & runManagerMaster() const
Definition: OscarMTMasterThread.h:48
OscarMTMasterThread::m_protectMutex
std::mutex m_protectMutex
Definition: OscarMTMasterThread.h:68
HepPDT
Definition: ParticleManager.h:17
OscarMTMasterThread::runManagerMasterPtr
RunManagerMT * runManagerMasterPtr() const
Definition: OscarMTMasterThread.h:49
OscarMTMasterThread::m_DD4Hep
edm::ESGetToken< cms::DDCompactView, IdealGeometryRecord > m_DD4Hep
Definition: OscarMTMasterThread.h:64
OscarMTMasterThread::~OscarMTMasterThread
~OscarMTMasterThread()
Definition: OscarMTMasterThread.cc:101
mutex
static std::mutex mutex
Definition: Proxy.cc:8
OscarMTMasterThread::m_stopped
bool m_stopped
Definition: OscarMTMasterThread.h:79
IdealGeometryRecord.h
edm::EventSetup
Definition: EventSetup.h:58
OscarMTMasterThread::m_pDD4Hep
const cms::DDCompactView * m_pDD4Hep
Definition: OscarMTMasterThread.h:61
OscarMTMasterThread
Definition: OscarMTMasterThread.h:37
edm::ESGetToken< DDCompactView, IdealGeometryRecord >
OscarMTMasterThread::ThreadState::NotExist
OscarMTMasterThread::m_masterCanProceed
bool m_masterCanProceed
Definition: OscarMTMasterThread.h:76
OscarMTMasterThread::m_pGeoFromDD4hep
const bool m_pGeoFromDD4hep
Definition: OscarMTMasterThread.h:54
OscarMTMasterThread::m_pDDD
const DDCompactView * m_pDDD
Definition: OscarMTMasterThread.h:60
ESWatcher.h
cms::DDCompactView
Definition: DDCompactView.h:31
OscarMTMasterThread::beginRun
void beginRun(const edm::EventSetup &iSetup) const
Definition: OscarMTMasterThread.cc:120
OscarMTMasterThread::m_pTable
const HepPDT::ParticleDataTable * m_pTable
Definition: OscarMTMasterThread.h:62
PDTRecord.h
EventSetup
ParameterSet.h
OscarMTMasterThread::m_threadMutex
std::mutex m_threadMutex
Definition: OscarMTMasterThread.h:69
MagneticField
Definition: MagneticField.h:19
ParticleDataTable
HepPDT::ParticleDataTable ParticleDataTable
Definition: ParticleDataTable.h:8
edm::ConsumesCollector
Definition: ConsumesCollector.h:45
OscarMTMasterThread::m_notifyMainCv
std::condition_variable m_notifyMainCv
Definition: OscarMTMasterThread.h:71
OscarMTMasterThread::ThreadState::Destruct
cms
Namespace of DDCMS conversion namespace.
Definition: ProducerAnalyzer.cc:21
OscarMTMasterThread::callConsumes
void callConsumes(edm::ConsumesCollector &&iC) const
Definition: OscarMTMasterThread.cc:107