CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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:
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
HepPDT::ParticleDataTable ParticleDataTable
std::shared_ptr< RunManagerMT > m_runManagerMaster
static std::mutex mutex
Definition: Proxy.cc:8
edm::ESGetToken< cms::DDCompactView, IdealGeometryRecord > m_DD4hep
edm::ESGetToken< DDCompactView, IdealGeometryRecord > m_DDD
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:81
ThreadState m_masterThreadState
void beginRun(const edm::EventSetup &iSetup) const
const cms::DDCompactView * m_pDD4hep
RunManagerMT & runManagerMaster() const
std::condition_variable m_notifyMasterCv
RunManagerMT * runManagerMasterPtr() const
OscarMTMasterThread(const edm::ParameterSet &iConfig)
edm::ESGetToken< HepPDT::ParticleDataTable, PDTRecord > m_PDT
const DDCompactView * m_pDDD
void callConsumes(edm::ConsumesCollector &&iC) const
const HepPDT::ParticleDataTable * m_pTable
std::condition_variable m_notifyMainCv