Belle II Software development
RunManager.h
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9#ifndef RUNMANAGER_H_
10#define RUNMANAGER_H_
11
12#include <G4RunManager.hh>
13#include <G4AssemblyVolume.hh>
14
15namespace Belle2 {
21 class RandomEngine;
22
23 namespace Simulation {
24
32 class RunManager : public G4RunManager {
33
34 public:
35
41 static RunManager& Instance();
42
47 void beginRun(int runNumber);
48
53 void processEvent(int evtNumber);
54
56 void endRun();
57
62 void destroy();
63
65 void Initialize();
66
68 inline void addAssemblyVolume(G4AssemblyVolume* vol) { m_AssemblyVolumes.push_back(vol); }
69
70 private:
71
73 RunManager();
74
77
80
82 virtual ~RunManager();
83
87 std::vector<G4AssemblyVolume*> m_AssemblyVolumes;
88
91
94 public: ~SingletonDestroyer()
95 {
96 // Apr.23,2012, R.Itoh
97 // Removal of Singleton Instance was temporarily turned off for parallel processing
98 // Should be re-activated after proper treatment is implemented.
99 // if (RunManager::m_instance != NULL) delete RunManager::m_instance;
100 }
101 };
102
103 friend class SingletonDestroyer;
104 };
105
106 } //end namespace Simulation
107
109} //end of namespace Belle2
110
111#endif /* RUNMANAGER_H_ */
Interface class to make Geant4 use the Belle2 RandomGenerator.
Definition: RandomEngine.h:22
Destroyer class to delete the instance of the RunManager class when the program terminates.
Definition: RunManager.h:93
The run manager controls the flow of the Geant4 program and manages the event loop(s) within a run.
Definition: RunManager.h:32
virtual ~RunManager()
The RunManager destructor.
Definition: RunManager.cc:131
RunManager(const RunManager &)
Disable/Hide the copy constructor.
void beginRun(int runNumber)
Prepares Geant4 for a new run.
Definition: RunManager.cc:49
void destroy()
Destroys the RunManager at the end of the simulation.
Definition: RunManager.cc:85
void processEvent(int evtNumber)
Process a single event in Geant4.
Definition: RunManager.cc:67
std::vector< G4AssemblyVolume * > m_AssemblyVolumes
Vector of pointers to G4AssemblyVolumes.
Definition: RunManager.h:87
void endRun()
Terminates a Geant4 run.
Definition: RunManager.cc:79
void Initialize()
Initialize the Kernel.
Definition: RunManager.cc:35
void addAssemblyVolume(G4AssemblyVolume *vol)
Register a G4AssemblyVolume.
Definition: RunManager.h:68
RunManager & operator=(const RunManager &)
Disable/Hide the copy assignment operator.
RandomEngine * m_randomEngine
Pointer to RandomEngine to avoid memory leak by creating it in the constructor and deleting it in the...
Definition: RunManager.h:90
static RunManager * m_instance
Pointer that saves the instance of this class.
Definition: RunManager.h:84
static RunManager & Instance()
Static method to get a reference to the RunManager instance.
Definition: RunManager.cc:29
RunManager()
The constructor is hidden to avoid that someone creates an instance of this class.
Definition: RunManager.cc:125
Abstract base class for different kinds of events.