15 #include "HepPDT/ParticleDataTable.hh" 18 #include "G4PhysicalVolumeStore.hh" 21 : m_pGeoFromDD4hep(iConfig.getParameter<
bool>(
"g4GeometryDD4hepSource")),
26 m_masterCanProceed(
false),
27 m_mainCanProceed(
false),
33 edm::LogInfo(
"SimG4CoreApplication") <<
"OscarMTMasterThread: creating master thread";
41 std::unique_ptr<CustomUIsession> uiSession;
46 edm::LogVerbatim(
"SimG4CoreApplication") <<
"OscarMTMasterThread: initializing RunManagerMT";
52 runManagerMaster = std::make_shared<RunManagerMT>(iConfig);
55 LogDebug(
"SimG4CoreApplication") <<
"OscarMTMasterThread: initialization of RunManagerMT finished";
59 bool isG4Alive =
false;
63 edm::LogVerbatim(
"OscarMTMasterThread") <<
"Master thread: State loop, notify main thread";
68 edm::LogVerbatim(
"OscarMTMasterThread") <<
"Master thread: State loop, starting wait";
76 edm::LogInfo(
"OscarMTMasterThread") <<
"Master thread: Initializing Geant4";
81 LogDebug(
"OscarMTMasterThread") <<
"Master thread: Stopping Geant4";
82 runManagerMaster->stopG4();
85 LogDebug(
"OscarMTMasterThread") <<
"Master thread: Breaking out of state loop";
88 <<
"Geant4 is still alive, master thread state must be set to EndRun before Destruct";
92 <<
"OscarMTMasterThread: Illegal master thread state " <<
static_cast<int>(
m_masterThreadState);
98 edm::LogVerbatim(
"SimG4CoreApplication") <<
"OscarMTMasterThread: start RunManagerMT destruction";
99 LogDebug(
"OscarMTMasterThread") <<
"Master thread: Am I unique owner of runManagerMaster? " 100 << runManagerMaster.unique();
103 runManagerMaster.reset();
104 G4PhysicalVolumeStore::Clean();
106 LogDebug(
"OscarMTMasterThread") <<
"Master thread: Reseted shared_ptr";
108 edm::LogVerbatim(
"SimG4CoreApplication") <<
"OscarMTMasterThread: Master thread is finished";
114 LogDebug(
"OscarMTMasterThread") <<
"Main thread: Signal master for initialization";
118 edm::LogVerbatim(
"SimG4CoreApplication") <<
"OscarMTMasterThread: Master thread is constructed";
138 edm::LogVerbatim(
"SimG4CoreApplication") <<
"OscarMTMasterThread: Signal master for BeginRun";
143 edm::LogVerbatim(
"SimG4CoreApplication") <<
"OscarMTMasterThread: finish BeginRun";
153 edm::LogVerbatim(
"SimG4CoreApplication") <<
"OscarMTMasterThread: Signal master for EndRun";
157 edm::LogVerbatim(
"SimG4CoreApplication") <<
"OscarMTMasterThread: finish EndRun";
164 edm::LogVerbatim(
"SimG4CoreApplication") <<
"OscarMTMasterThread::stopTread: stop main thread";
171 LogDebug(
"OscarMTMasterThread") <<
"Main thread: reseted shared_ptr";
175 edm::LogVerbatim(
"SimG4CoreApplication") <<
"OscarMTMasterThread::stopTread: notify";
179 LogDebug(
"OscarMTMasterThread") <<
"Main thread: joining master thread";
181 edm::LogVerbatim(
"SimG4CoreApplication") <<
"OscarMTMasterThread::stopTread: main thread finished";
189 <<
"[SimG4Core OscarMTMasterThread]\n" 190 <<
"The Geometry configuration is changed during the job execution\n" 191 <<
"this is not allowed, the geometry must stay unchanged";
std::mutex m_protectMutex
std::shared_ptr< RunManagerMT > m_runManagerMaster
std::thread m_masterThread
edm::ESWatcher< IdealGeometryRecord > idealGeomRcdWatcher_
ThreadState m_masterThreadState
void beginRun(const edm::EventSetup &iSetup) const
const bool m_pGeoFromDD4hep
const cms::DDCompactView * m_pDD4hep
RunManagerMT & runManagerMaster() const
std::condition_variable m_notifyMasterCv
void readES(const edm::EventSetup &iSetup) const
const DDCompactView * m_pDD
OscarMTMasterThread(const edm::ParameterSet &iConfig)
T const * product() const
bool check(const edm::EventSetup &iSetup)
T const * product() const
const HepPDT::ParticleDataTable * m_pTable
std::condition_variable m_notifyMainCv