9 #include <simulation/kernel/RunManager.h>
10 #include <simulation/kernel/RandomEngine.h>
11 #include <framework/logging/Logger.h>
13 #include <framework/pcore/ProcHandler.h>
15 #include <CLHEP/Random/Random.h>
17 #include <G4LogicalVolumeStore.hh>
18 #include <G4PhysicalVolumeStore.hh>
19 #include <G4SolidStore.hh>
20 #include <G4RegionStore.hh>
21 #include <G4GeometryManager.hh>
25 using namespace Belle2::Simulation;
31 if (!m_instance) m_instance =
new RunManager();
35 void RunManager::Initialize()
40 SetGeometryToBeOptimized(
true);
44 G4RunManager::Initialize();
48 void RunManager::beginRun(
int runNumber)
53 if (ConfirmBeamOnCondition()) {
55 SetRunIDCounter(runNumber);
58 ConstructScoringWorlds();
61 B2FATAL(
"The Geant4 kernel was not initialized properly ! The method 'ConfirmBeamOnCondition()' failed. ");
66 void RunManager::processEvent(
int evtNumber)
69 currentEvent = GenerateEvent(evtNumber);
70 eventManager->ProcessOneEvent(currentEvent);
71 AnalyzeEvent(currentEvent);
73 StackPreviousEvent(currentEvent);
78 void RunManager::endRun()
84 void RunManager::destroy()
86 if (m_instance ==
nullptr)
return;
88 for (G4AssemblyVolume* assemblyVolume : m_AssemblyVolumes)
delete assemblyVolume;
89 m_AssemblyVolumes.clear();
91 if (ProcHandler::parallelProcessingUsed() and !ProcHandler::isOutputProcess()) {
101 G4LogicalVolumeStore::GetInstance()->clear();
102 G4PhysicalVolumeStore::GetInstance()->clear();
103 G4SolidStore::GetInstance()->clear();
104 G4RegionStore::GetInstance()->clear();
107 G4GeometryManager::GetInstance()->OpenGeometry();
114 m_instance =
nullptr;
122 RunManager::RunManager() : G4RunManager()
Interface class to make Geant4 use the Belle2 RandomGenerator.
The run manager controls the flow of the Geant4 program and manages the event loop(s) within a run.
virtual ~RunManager()
The RunManager destructor.
std::vector< G4AssemblyVolume * > m_AssemblyVolumes
Vector of pointers to G4AssemblyVolumes.
Abstract base class for different kinds of events.