GGS(GenericGEANT4Simulation)Software
2.99.0
|
Class with additional functionalities for run managers. More...
#include <GGSRunManagerExtensions.h>
Public Member Functions | |
GGSRunManagerExtensions () | |
Constructor. | |
virtual | ~GGSRunManagerExtensions ()=default |
Destructor. More... | |
int | GetNKilledEvents () |
Getter method for number of killed events. More... | |
void | KillEvent () |
Kills the current event. More... | |
void | SimulateAgainKilledEvent () |
Simulates again a killed event. More... | |
bool | IsCurrentEventKilled () |
Getter method for killed event flag. More... | |
const std::string & | GetRandomStateAtBeginOfEvent () |
Getter method for random engine state at the beginning of the current event. More... | |
void | SetGGSGeneratorAction (G4VUserPrimaryGeneratorAction *userAction) |
Replacement of the SetUserAction method. More... | |
int | GetNDiscardedEvents () |
Getter method for number of discarded events. More... | |
const std::string & | RngStateRestoredFrom () |
The random engine state file for this event. More... | |
Protected Member Functions | |
void | BeginOfEventProcessing () |
Method for storing the random engine state and resetting the internal flags at the beginning event generation. More... | |
void | BeginOfEventSimulation () |
Reset the internal flags at the beginning of event simulation. More... | |
void | DumpStatus (G4int eventID) |
Prints the status of the random number generator. More... | |
bool | IsKilledAndToBeSimulatedAgain (const G4Event *ev) |
Checks if the event has been killed and has to be re-simulated. More... | |
void | PrintLogVols () |
Print a list of logical volumes in current geometries. | |
void | HandleEventRngStateFile (int runID, int eventID) |
Handles the read/write operations to/from the random generator state file for each event. More... | |
Class with additional functionalities for run managers.
This class is meant to be used to extend the interfaces of standard G4 run managers with additional GGS functionalities. The class has a virtual destructor to make it possible to obtain the GGSRunManagerExtensions interface from a a G4RunManager pointer with a dynamic_cast.
Definition at line 28 of file GGSRunManagerExtensions.h.
|
virtualdefault |
Destructor.
Declared only to make it possible to recover the GGSRunManagerExtensions interface from a G4RunManager pointer.
|
protected |
Method for storing the random engine state and resetting the internal flags at the beginning event generation.
To be called in derived classes before generating the event, i.e. before calling the GenerateEvent method of the run manager class. Do not call again if the primaries are re-generated.
Definition at line 47 of file GGSRunManagerExtensions.cpp.
|
protected |
Reset the internal flags at the beginning of event simulation.
To be called in derived classes before starting to process an event, i.e. before calling G4EventManager::ProcessOneEvent.
Definition at line 54 of file GGSRunManagerExtensions.cpp.
|
protected |
Prints the status of the random number generator.
To be called after generating the event and before starting to simulate it
eventID | The ID of the event |
Definition at line 59 of file GGSRunManagerExtensions.cpp.
int GGSRunManagerExtensions::GetNDiscardedEvents | ( | ) |
Getter method for number of discarded events.
This method returns the number of discarded events. Discarded events are events which are generated but not simulated because they do not fulfill the acceptance criterion defined by the geometry. The counter is reset every time an event is successfully generated inside acceptance and simulated (i.e. not killed). This method will always return 0 if the particle generator does not inherit from GGSGeneratorAction.
Definition at line 136 of file GGSRunManagerExtensions.cpp.
|
inline |
Getter method for number of killed events.
This method returns the number of killed events since the last non-killed one.
Definition at line 46 of file GGSRunManagerExtensions.h.
|
inline |
Getter method for random engine state at the beginning of the current event.
Definition at line 83 of file GGSRunManagerExtensions.h.
|
protected |
Handles the read/write operations to/from the random generator state file for each event.
This routine reads and writes the random generator state files for each event, effectively restoring the state from file or dumping the current state to file. Read and write behavior can be toggled by the /GGS/random/saveEventRngStateToFile and /GGS/random/readEventRngStateFromFile datacard commands (notice that when reading from file is enabled then dumping to file will be automatically disabled). The path and base file name can be set by means of /GGS/random/eventRngStateFilePath and /GGS/random/eventRngStateFileBase, respectively. The effective file name for each event is built by appending the run::evt#.rndm suffix to the base name, and then using the path to obtain the absolute file name.
If the file format is bad then a fatal G4Exception is thrown.
runID | The ID of the current run. |
eventID | The ID of the current event. |
Definition at line 153 of file GGSRunManagerExtensions.cpp.
|
inline |
Getter method for killed event flag.
This method returns true if SetEventAsKilled has been called during current event.
Definition at line 77 of file GGSRunManagerExtensions.h.
|
protected |
Checks if the event has been killed and has to be re-simulated.
ev | the current event. |
Definition at line 94 of file GGSRunManagerExtensions.cpp.
void GGSRunManagerExtensions::KillEvent | ( | ) |
Kills the current event.
This method can be called by user actions to kill an event. The difference between this method and G4EventManager::AbortCurrentEvent is that calling KillEvent and then SimulateAgainKilledEvent it is possible to simulate a new event without increasing the number of simulated events. In other words, when using KillEvent and SimulateAgainKilledEvent killed events won't contribute to the count of total simulated events.
Definition at line 35 of file GGSRunManagerExtensions.cpp.
|
inline |
The random engine state file for this event.
Returns the name of the file from which the random engine state for the current event has been restored.
Definition at line 124 of file GGSRunManagerExtensions.h.
void GGSRunManagerExtensions::SetGGSGeneratorAction | ( | G4VUserPrimaryGeneratorAction * | userAction | ) |
Replacement of the SetUserAction method.
This version checks whether the generator action inherits from GGSGeneratorAction and then registers it in the parent G4RunManager. The GGSGeneratorAction can then be retrieved by means of the GetGGSGeneratorAction method.
Note: use this method to register a generator action inheriting from GGSGeneratorAction (instead of the standard SetUserAction method) to take advantage of the mechanism to avoid dynamic_cast described in GetGGSGeneratorAction; that mechanism will not work if SetUserAction is used to register the generator action in the run manager, but all other functionalities will not be affected.
userAction | The user defined primary generator action. |
Definition at line 129 of file GGSRunManagerExtensions.cpp.
|
inline |
Simulates again a killed event.
This method must be called by user actions after killing an event if the killed event has to be re-generated and re-simulated. The method #SetEventAsKilled must be called before, in order to enable re-generation and simulation, otherwise a warning message is displayed and the event is not re-generated and simulated.
Definition at line 68 of file GGSRunManagerExtensions.h.