Belle II Software  release-05-02-19
RunManager.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2010-2011 Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Andreas Moll, Guofu Cao *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #ifndef RUNMANAGER_H_
12 #define RUNMANAGER_H_
13 
14 #include <G4RunManager.hh>
15 #include <G4AssemblyVolume.hh>
16 
17 namespace Belle2 {
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 
84  static RunManager* m_instance;
87  std::vector<G4AssemblyVolume*> m_AssemblyVolumes;
88 
90  class SingletonDestroyer {
91  public: ~SingletonDestroyer()
92  {
93  // Apr.23,2012, R.Itoh
94  // Removal of Singleton Instance was temporarily turned off for parallel processing
95  // Should be re-activated after proper treatment is implemented.
96  // if (RunManager::m_instance != NULL) delete RunManager::m_instance;
97  }
98  };
99 
100  friend class SingletonDestroyer;
101  };
102 
103  } //end namespace Simulation
104 
106 } //end of namespace Belle2
107 
108 #endif /* RUNMANAGER_H_ */
Belle2::Simulation::RunManager::addAssemblyVolume
void addAssemblyVolume(G4AssemblyVolume *vol)
Register a G4AssemblyVolume.
Definition: RunManager.h:76
Belle2::Simulation::RunManager::operator=
RunManager & operator=(const RunManager &)
Disable/Hide the copy assignment operator.
Belle2::Simulation::RunManager::m_AssemblyVolumes
std::vector< G4AssemblyVolume * > m_AssemblyVolumes
Vector of pointers to G4AssemblyVolumes.
Definition: RunManager.h:95
Belle2::Simulation::RunManager::Initialize
void Initialize()
Initialize the Kernel.
Definition: RunManager.cc:37
Belle2::Simulation::RunManager::SingletonDestroyer
Destroyer class to delete the instance of the RunManager class when the program terminates.
Definition: RunManager.h:98
Belle2::Simulation::RunManager
The run manager controls the flow of the Geant4 program and manages the event loop(s) within a run.
Definition: RunManager.h:40
Belle2::Simulation::RunManager::beginRun
void beginRun(int runNumber)
Prepares Geant4 for a new run.
Definition: RunManager.cc:50
Belle2::Simulation::RunManager::RunManager
RunManager()
The constructor is hidden to avoid that someone creates an instance of this class.
Definition: RunManager.cc:124
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::Simulation::RunManager::Instance
static RunManager & Instance()
Static method to get a reference to the RunManager instance.
Definition: RunManager.cc:31
Belle2::Simulation::RunManager::processEvent
void processEvent(int evtNumber)
Process a single event in Geant4.
Definition: RunManager.cc:68
Belle2::Simulation::RunManager::endRun
void endRun()
Terminates a Geant4 run.
Definition: RunManager.cc:80
Belle2::Simulation::RunManager::m_instance
static RunManager * m_instance
Pointer that saves the instance of this class.
Definition: RunManager.h:92
Belle2::Simulation::RunManager::~RunManager
virtual ~RunManager()
The RunManager destructor.
Definition: RunManager.cc:130
Belle2::Simulation::RunManager::destroy
void destroy()
Destroys the RunManager at the end of the simulation.
Definition: RunManager.cc:86