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";
79 LogDebug(
"OscarMTMasterThread") <<
"Master thread: Initializing Geant4";
85 LogDebug(
"OscarMTMasterThread") <<
"Master thread: Stopping Geant4";
86 runManagerMaster->stopG4();
90 LogDebug(
"OscarMTMasterThread") <<
"Master thread: Breaking out of state loop";
93 <<
"Geant4 is still alive, master thread state must be set to EndRun before Destruct";
98 <<
"OscarMTMasterThread: Illegal master thread state " 106 <<
"OscarMTMasterThread: start RunManagerMT destruction";
108 <<
"Master thread: Am I unique owner of runManagerMaster? " 109 << runManagerMaster.unique();
112 runManagerMaster.reset();
113 G4PhysicalVolumeStore::Clean();
115 LogDebug(
"OscarMTMasterThread") <<
"Master thread: Reseted shared_ptr";
118 <<
"OscarMTMasterThread: Master thread is finished";
124 LogDebug(
"OscarMTMasterThread") <<
"Main thread: Signal master for initialization";
129 <<
"OscarMTMasterThread: Master thread is constructed";
150 <<
"OscarMTMasterThread: Signal master for BeginRun";
156 <<
"OscarMTMasterThread: finish BeginRun";
167 <<
"OscarMTMasterThread: Signal master for EndRun";
172 <<
"OscarMTMasterThread: finish EndRun";
180 <<
"OscarMTMasterThread::stopTread: stop main thread";
187 LogDebug(
"OscarMTMasterThread") <<
"Main thread: reseted shared_ptr";
192 <<
"OscarMTMasterThread::stopTread: stop main thread";
196 LogDebug(
"OscarMTMasterThread") <<
"Main thread: joining master thread";
199 <<
"OscarMTMasterThread::stopTread: main thread finished";
207 <<
"[SimG4Core OscarMTMasterThread]\n" 208 <<
"The Geometry configuration is changed during the job execution\n" 209 <<
"this is not allowed, the geometry must stay unchanged";
215 <<
"[SimG4Core OscarMTMasterThread]\n" 216 <<
"The MagneticField configuration is changed during the job execution\n" 217 <<
"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