SLIC  6.1.1
Simulation for the Linear Collider (SLIC) - Geant4 simulation application
RunManager.hh
Go to the documentation of this file.
1 #ifndef SLIC_RUNMANAGER_HH_
2 #define SLIC_RUNMANAGER_HH_ 1
3 
4 // geant4
5 #include "G4RunManager.hh"
6 
7 // slic
8 #include "Module.hh"
9 #include "PluginManager.hh"
10 #include "SlicApplication.hh"
11 
12 namespace slic {
18 class RunManager: public G4RunManager, public Module {
19 
20  public:
21 
25  RunManager();
26 
30  virtual ~RunManager();
31 
32  public:
33 
38  static RunManager* instance() {
39  return dynamic_cast<RunManager*>(G4RunManager::GetRunManager());
40  }
41 
45  void abortRun() {
46  //std::cout << "RunManager.abortRun - run will be aborted!!!" << std::endl;
47  log() << LOG::fatal << "Aborting run." << LOG::done;
48  m_abortRun = true;
49  // Set return code to generic error but don't override if error is already set.
50  if (SlicApplication::instance()->getReturnCode() == SlicApplication::OKAY) {
52  }
53  G4RunManager::GetRunManager()->AbortRun(false);
54  }
55 
60  void abortRun(int errorCode) {
61  log() << LOG::fatal << LOG::name << LOG::sep << "Aborting run with return code: " << errorCode << LOG::done;
62  m_abortRun = true;
63  SlicApplication::instance()->setReturnCode(errorCode);
64  G4RunManager::GetRunManager()->AbortRun(false);
65  }
66 
70  void Initialize();
71 
77 
82  bool isRunAborted();
83 
84  protected:
85 
93  void BeamOn(G4int nevent, const char* macroFile = 0, G4int nselect = -1);
94 
98  void InitializePhysics();
99 
103  void InitializeGeometry();
104 
105  private:
106 
110 };
111 }
112 
113 #endif
static SlicApplication * instance()
Base class for slic code modules that provides common functionality, such as logging to an output str...
Definition: Module.hh:25
LogStream & log()
Definition: Module.hh:99
Manages user sim plugins.
Extension of G4RunManager.
Definition: RunManager.hh:18
virtual ~RunManager()
Definition: RunManager.cc:29
void InitializeGeometry()
Definition: RunManager.cc:101
PluginManager * m_pluginManager
Definition: RunManager.hh:109
void InitializePhysics()
Definition: RunManager.cc:78
void abortRun(int errorCode)
Definition: RunManager.hh:60
void BeamOn(G4int nevent, const char *macroFile=0, G4int nselect=-1)
Definition: RunManager.cc:113
int getNumberOfEventsToRun()
Definition: RunManager.cc:154
static RunManager * instance()
Definition: RunManager.hh:38
@ fatal
Definition: LogStream.hh:33
@ name
Definition: LogStream.hh:26
@ done
Definition: LogStream.hh:26
@ sep
Definition: LogStream.hh:26