Belle II Software  release-06-02-00
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 
15 namespace Belle2 {
21  namespace Simulation {
22 
30  class RunManager : public G4RunManager {
31 
32  public:
33 
39  static RunManager& Instance();
40 
45  void beginRun(int runNumber);
46 
51  void processEvent(int evtNumber);
52 
54  void endRun();
55 
60  void destroy();
61 
63  void Initialize();
64 
66  inline void addAssemblyVolume(G4AssemblyVolume* vol) { m_AssemblyVolumes.push_back(vol); }
67 
68  private:
69 
71  RunManager();
72 
75 
78 
80  virtual ~RunManager();
81 
85  std::vector<G4AssemblyVolume*> m_AssemblyVolumes;
86 
89  public: ~SingletonDestroyer()
90  {
91  // Apr.23,2012, R.Itoh
92  // Removal of Singleton Instance was temporarily turned off for parallel processing
93  // Should be re-activated after proper treatment is implemented.
94  // if (RunManager::m_instance != NULL) delete RunManager::m_instance;
95  }
96  };
97 
98  friend class SingletonDestroyer;
99  };
100 
101  } //end namespace Simulation
102 
104 } //end of namespace Belle2
105 
106 #endif /* RUNMANAGER_H_ */
Destroyer class to delete the instance of the RunManager class when the program terminates.
Definition: RunManager.h:88
The run manager controls the flow of the Geant4 program and manages the event loop(s) within a run.
Definition: RunManager.h:30
virtual ~RunManager()
The RunManager destructor.
Definition: RunManager.cc:128
RunManager(const RunManager &)
Disable/Hide the copy constructor.
void beginRun(int runNumber)
Prepares Geant4 for a new run.
Definition: RunManager.cc:48
void destroy()
Destroys the RunManager at the end of the simulation.
Definition: RunManager.cc:84
void processEvent(int evtNumber)
Process a single event in Geant4.
Definition: RunManager.cc:66
std::vector< G4AssemblyVolume * > m_AssemblyVolumes
Vector of pointers to G4AssemblyVolumes.
Definition: RunManager.h:85
RunManager & operator=(const RunManager &)
Disable/Hide the copy assignment operator.
void endRun()
Terminates a Geant4 run.
Definition: RunManager.cc:78
void Initialize()
Initialize the Kernel.
Definition: RunManager.cc:35
void addAssemblyVolume(G4AssemblyVolume *vol)
Register a G4AssemblyVolume.
Definition: RunManager.h:66
static RunManager * m_instance
Pointer that saves the instance of this class.
Definition: RunManager.h:82
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:122
Abstract base class for different kinds of events.