13 #include "G4EventManager.hh"
14 #include "G4GenericMessenger.hh"
15 #include "G4LogicalVolumeStore.hh"
16 #include "Randomize.hh"
24 G4Exception(
"GGSRunManager::GetRunManager()",
"GGS", FatalException,
"GGSRunManager not yet constructed.");
32 : G4RunManager(), _ggsGeneratorAction(NULL), _nDiscardedEvsInKilledEvs(0), _nKilledEvs(0), _isCurrEvKilled(false),
33 _simAgainKilledEv(false) {
35 G4Exception(
"GGSRunManager::GGSRunManager()",
"GGS", FatalException,
"GGSRunManager constructed twice.");
39 _messenger =
new G4GenericMessenger(
this,
"/GGS/");
41 _currEvSeeds[0] = _currEvSeeds[1] = 0;
54 static const std::string routineName(
"GGSRunManager::DoEventLoop");
55 InitializeEventLoop(n_event, macroFile, n_select);
56 _isCurrEvKilled =
false;
57 _simAgainKilledEv =
false;
61 for (G4int i_event = 0; i_event < n_event; i_event++) {
63 _currEvSeeds[0] = CLHEP::HepRandom::getTheSeeds()[0];
64 _currEvSeeds[1] = CLHEP::HepRandom::getTheSeeds()[1];
66 ProcessOneEvent(i_event);
72 if (_isCurrEvKilled) {
73 COUT(DEEPDEB) <<
"Event " << i_event <<
" has been killed. " <<
ENDL;
74 if (_ggsGeneratorAction) {
76 <<
" (total: " << _nDiscardedEvsInKilledEvs <<
")" <<
ENDL;
78 if (_simAgainKilledEv) {
80 CCOUT(DEEPDEB) <<
"Will be simulated again." <<
ENDL;
83 COUT(DEEPDEB) <<
"Finished simulating event " << i_event <<
ENDL;
84 if (_ggsGeneratorAction) {
88 CCOUT(DEEPDEB) <<
"Killed: " << _nKilledEvs <<
ENDL;
90 _nDiscardedEvsInKilledEvs = 0;
92 if (_simAgainKilledEv) {
93 static bool printDone =
false;
95 COUT(WARNING) <<
"Request to re-simulate an event which has not been flagged as killed. Ignoring." <<
ENDL;
96 CCOUT(WARNING) <<
"This message will be printed only once." <<
ENDL;
101 _isCurrEvKilled =
false;
102 _simAgainKilledEv =
false;
105 TerminateEventLoop();
111 static const std::string routineName(
"GGSRunManager::PrintLogVols");
112 G4LogicalVolumeStore *logVolStore = G4LogicalVolumeStore::GetInstance();
114 COUT(INFO) <<
"Logical volumes in current geometry:" <<
ENDL;
115 for (G4LogicalVolumeStore::const_iterator iter = logVolStore->begin(); iter != logVolStore->end(); iter++) {
116 CCOUT(INFO) <<
" * " << (*iter)->GetName() <<
ENDL;
123 static const std::string routineName(
"GGSRunManager::KillEvent");
124 if (!_isCurrEvKilled) {
125 COUT(DEEPDEB) <<
"Kill event" << std::endl;
126 G4EventManager::GetEventManager()->AbortCurrentEvent();
127 _isCurrEvKilled =
true;
129 if (_ggsGeneratorAction)
130 _nDiscardedEvsInKilledEvs += _ggsGeneratorAction->
GetNDiscarded();
~GGSRunManager()
Destructor.
#define COUT(level)
Smart log macro. It writes on stdout only if the specified verbosity level is lesser than the maximum...
void DoEventLoop(G4int n_event, const char *macroFile, G4int n_select)
Override of G4RunManager::DoEventLoop.
GGSRunManager()
Constructor.
void PrintLogVols()
Print a list of logical volumes in current geometries.
void SimulateAgainKilledEvent()
Simulates again a killed event.
#define CCOUT(level)
Smart log utility which prints no header at the beginning of the line.
bool IsCurrentEventKilled()
Getter method for killed event flag.
static GGSRunManager * GetRunManager()
Static getter function the run manager.
int GetNDiscardedEvents()
Getter method for number of discarded events.
void KillEvent()
Kills the current event.
unsigned int GetNDiscarded() const
Returns the number of discarded events for the current event generation.
A run manager for GGS simulations.