13 #include "G4GenericMessenger.hh"
14 #include "G4LogicalVolumeStore.hh"
15 #include "G4EventManager.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), _simAgainKilledEv(
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) {
75 CCOUT(DEEPDEB) <<
"Discarded at generation: " << _ggsGeneratorAction->
GetNDiscarded() <<
" (total: " << _nDiscardedEvsInKilledEvs <<
")" <<
ENDL;
77 if (_simAgainKilledEv) {
79 CCOUT(DEEPDEB) <<
"Will be simulated again." <<
ENDL;
83 COUT(DEEPDEB) <<
"Finished simulating event " << i_event <<
ENDL;
84 if(_ggsGeneratorAction) {
87 CCOUT(DEEPDEB) <<
"Killed: " << _nKilledEvs <<
ENDL;
89 _nDiscardedEvsInKilledEvs = 0;
91 if (_simAgainKilledEv) {
92 static bool printDone =
false;
94 COUT(WARNING) <<
"Request to re-simulate an event which has not been flagged as killed. Ignoring." <<
ENDL;
95 CCOUT(WARNING) <<
"This message will be printed only once." <<
ENDL;
100 _isCurrEvKilled =
false;
101 _simAgainKilledEv =
false;
104 TerminateEventLoop();
110 static const std::string routineName(
"GGSRunManager::PrintLogVols");
111 G4LogicalVolumeStore *logVolStore = G4LogicalVolumeStore::GetInstance();
113 COUT(INFO) <<
"Logical volumes in current geometry:" <<
ENDL;
114 for (G4LogicalVolumeStore::const_iterator iter = logVolStore->begin(); iter != logVolStore->end(); iter++) {
115 CCOUT(INFO) <<
" * " << (*iter)->GetName() <<
ENDL;
122 static const std::string routineName(
"GGSRunManager::KillEvent");
123 if (!_isCurrEvKilled) {
124 COUT(DEEPDEB) <<
"Kill event" << std::endl;
125 G4EventManager::GetEventManager()->AbortCurrentEvent();
126 _isCurrEvKilled =
true;
128 if (_ggsGeneratorAction)
129 _nDiscardedEvsInKilledEvs += _ggsGeneratorAction->
GetNDiscarded();
136 _simAgainKilledEv =
true;
142 return _isCurrEvKilled;
~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.