17 #include "HepPDT/ParticleDataTable.hh" 20 #include "G4PhysicalVolumeStore.hh" 23 m_pUseMagneticField(iConfig.getParameter<
bool>(
"UseMagneticField")),
26 m_masterCanProceed(
false),
27 m_mainCanProceed(
false),
35 <<
"OscarMTMasterThread: creating master thread";
43 std::unique_ptr<CustomUIsession> uiSession;
49 <<
"OscarMTMasterThread: initializing RunManagerMT";
55 runManagerMaster = std::make_shared<RunManagerMT>(iConfig);
59 <<
"OscarMTMasterThread: initialization of RunManagerMT finished";
63 bool isG4Alive =
false;
67 LogDebug(
"OscarMTMasterThread") <<
"Master thread: State loop, notify main thread";
72 LogDebug(
"OscarMTMasterThread") <<
"Master thread: State loop, starting wait";
76 LogDebug(
"OscarMTMasterThread") <<
"Master thread: Woke up, state is " 80 LogDebug(
"OscarMTMasterThread") <<
"Master thread: Initializing Geant4";
86 LogDebug(
"OscarMTMasterThread") <<
"Master thread: Stopping Geant4";
87 runManagerMaster->stopG4();
91 LogDebug(
"OscarMTMasterThread") <<
"Master thread: Breaking out of state loop";
94 <<
"Geant4 is still alive, master thread state must be set to EndRun before Destruct";
99 <<
"OscarMTMasterThread: Illegal master thread state " 107 <<
"OscarMTMasterThread: start RunManagerMT destruction";
109 <<
"Master thread: Am I unique owner of runManagerMaster? " 110 << runManagerMaster.unique();
113 runManagerMaster.reset();
114 G4PhysicalVolumeStore::Clean();
116 LogDebug(
"OscarMTMasterThread") <<
"Master thread: Reseted shared_ptr";
119 <<
"OscarMTMasterThread: Master thread is finished";
125 LogDebug(
"OscarMTMasterThread") <<
"Main thread: Signal master for initialization";
130 <<
"OscarMTMasterThread: Master thread is constructed";
151 <<
"OscarMTMasterThread: Signal master for BeginRun";
157 <<
"OscarMTMasterThread: finish BeginRun";
168 <<
"OscarMTMasterThread: Signal master for EndRun";
173 <<
"OscarMTMasterThread: finish EndRun";
181 <<
"OscarMTMasterThread::stopTread: stop main thread";
188 LogDebug(
"OscarMTMasterThread") <<
"Main thread: reseted shared_ptr";
193 <<
"OscarMTMasterThread::stopTread: stop main thread";
197 LogDebug(
"OscarMTMasterThread") <<
"Main thread: joining master thread";
200 <<
"OscarMTMasterThread::stopTread: main thread finished";
208 <<
"[SimG4Core OscarMTMasterThread]\n" 209 <<
"The Geometry configuration is changed during the job execution\n" 210 <<
"this is not allowed, the geometry must stay unchanged";
216 <<
"[SimG4Core OscarMTMasterThread]\n" 217 <<
"The MagneticField configuration is changed during the job execution\n" 218 <<
"this is not allowed, the MagneticField 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
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)
edm::ESWatcher< IdealMagneticFieldRecord > idealMagRcdWatcher_
const MagneticField * m_pMF
T const * product() const
const HepPDT::ParticleDataTable * m_pTable
std::condition_variable m_notifyMainCv
const bool m_pUseMagneticField