GGS(GenericGEANT4Simulation)Software  2.99.0
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Macros
GGSRunManagerExtensions.h
1 /*
2  * GGSRunManagerExtensions.h
3  *
4  * Created on: 5 Nov 2020
5  * Author: Nicola Mori
6  */
7 
8 #ifndef GGSRUNMANAGEREXTENSIONS_H_
9 #define GGSRUNMANAGEREXTENSIONS_H_
10 
11 #include "globals.hh"
12 
14 
15 #include "G4GenericMessenger.hh"
16 #include "G4RunManager.hh"
17 #include "G4VUserPrimaryGeneratorAction.hh"
18 #include "Randomize.hh"
19 
20 #include <array>
21 
29 public:
32 
37  virtual ~GGSRunManagerExtensions() = default;
38 
46  int GetNKilledEvents() { return _nKilledEvs; }
47 
59  void KillEvent();
60 
68  void SimulateAgainKilledEvent() { _simAgainKilledEv = true; };
69 
77  bool IsCurrentEventKilled() { return _isCurrEvKilled; };
78 
83  const std::string &GetRandomStateAtBeginOfEvent() { return _stateAtBeginOfEvent; }
84 
101  void SetGGSGeneratorAction(G4VUserPrimaryGeneratorAction *userAction);
102 
115  int GetNDiscardedEvents();
116 
124  const std::string &RngStateRestoredFrom() { return _restoredFrom; }
125 
126 protected:
134  void BeginOfEventProcessing();
135 
142  void BeginOfEventSimulation();
143 
150  void DumpStatus(G4int eventID);
151 
157  bool IsKilledAndToBeSimulatedAgain(const G4Event *ev);
158 
160  void PrintLogVols();
161 
177  void HandleEventRngStateFile(int runID, int eventID);
178 
179 private:
180  int _nDiscardedEvsInKilledEvs; // Total discarded events in killed events
181  int _nKilledEvs;
182  bool _isCurrEvKilled;
183  bool _simAgainKilledEv;
184 
185  std::string _stateAtBeginOfEvent;
186  G4int _printModulo;
187  G4int _lastPrinted;
188 
189  GGSGeneratorAction *_ggsGeneratorAction;
190 
191  std::string _eventRandomFileBase, _eventRandomFilePath, _restoredFrom;
192  bool _readEventRngStateFromFile, _saveEventRngStateToFile;
193 
194  G4GenericMessenger _messenger, _randomMessenger;
195 };
196 
197 #endif /* GGSRUNMANAGEREXTENSIONS_H_ */
void PrintLogVols()
Print a list of logical volumes in current geometries.
void SetGGSGeneratorAction(G4VUserPrimaryGeneratorAction *userAction)
Replacement of the SetUserAction method.
bool IsKilledAndToBeSimulatedAgain(const G4Event *ev)
Checks if the event has been killed and has to be re-simulated.
Base class for GGS generator actions.
Class with additional functionalities for run managers.
void SimulateAgainKilledEvent()
Simulates again a killed event.
void HandleEventRngStateFile(int runID, int eventID)
Handles the read/write operations to/from the random generator state file for each event...
int GetNDiscardedEvents()
Getter method for number of discarded events.
virtual ~GGSRunManagerExtensions()=default
Destructor.
bool IsCurrentEventKilled()
Getter method for killed event flag.
void DumpStatus(G4int eventID)
Prints the status of the random number generator.
const std::string & GetRandomStateAtBeginOfEvent()
Getter method for random engine state at the beginning of the current event.
int GetNKilledEvents()
Getter method for number of killed events.
void BeginOfEventSimulation()
Reset the internal flags at the beginning of event simulation.
void BeginOfEventProcessing()
Method for storing the random engine state and resetting the internal flags at the beginning event ge...
const std::string & RngStateRestoredFrom()
The random engine state file for this event.
void KillEvent()
Kills the current event.