GGS(GenericGEANT4Simulation)Software  2.99.0
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Macros
Public Member Functions
GGSWorkerRunManager Class Reference

Worker run manager class for GGS. More...

#include <GGSWorkerRunManager.h>

Inheritance diagram for GGSWorkerRunManager:
Inheritance graph
[legend]
Collaboration diagram for GGSWorkerRunManager:
Collaboration graph
[legend]

Public Member Functions

void DoEventLoop (G4int n_event, const char *macroFile=0, G4int n_select=-1) override
 Run the event loop. More...
 
void ProcessOneEvent (G4int i_event) override
 Process a single event. More...
 
- Public Member Functions inherited from GGSRunManagerExtensions
 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...
 

Additional Inherited Members

- Protected Member Functions inherited from GGSRunManagerExtensions
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...
 

Detailed Description

Worker run manager class for GGS.

This class extends the G4 worker run manager interface with some GGS-specific features through the GGSRunManagerExtensions interface. Due to the way the run manager instances are handled in multi-threaded Geant4, the extension interface must be queried as:

auto &rme = dynamic_cast<GGSRunManagerExtensions &>(*(G4RunManager::GetRunManager()));

Definition at line 25 of file GGSWorkerRunManager.h.

Member Function Documentation

void GGSWorkerRunManager::DoEventLoop ( G4int  n_event,
const char *  macroFile = 0,
G4int  n_select = -1 
)
override

Run the event loop.

This override is a copy-paste of the base class method and has the only purpose to bind the non-polymorphic call to ProcessOneEvent to the override defined in this class.

Parameters
n_event
macroFile
n_select

Definition at line 15 of file GGSWorkerRunManager.cpp.

15  {
16  // Implementation copy-pasted from G4 10.06.p02 with no modification, to just allow for binding the call to
17  // ProcessOneEvent to the override defined in this class.
18  TIMEMORY_AUTO_TIMER("");
19  if (!userPrimaryGeneratorAction) {
20  G4Exception("G4RunManager::GenerateEvent()", "Run0032", FatalException,
21  "G4VUserPrimaryGeneratorAction is not defined!");
22  }
23 
24  // This is the same as in the sequential case, just the for-loop indexes are
25  // different
26  InitializeEventLoop(n_event, macroFile, n_select);
27 
28  // Reset random number seeds queue
29  while (seedsQueue.size() > 0) {
30  seedsQueue.pop();
31  }
32  // for each run, worker should receive at least one set of random number seeds.
33  runIsSeeded = false;
34 
35  // Event loop
36  eventLoopOnGoing = true;
38  G4int i_event = -1;
39  nevModulo = -1;
40  currEvID = -1;
41 
42  while (eventLoopOnGoing) {
43  ProcessOneEvent(i_event);
44  if (eventLoopOnGoing) {
45  TerminateOneEvent();
46  if (runAborted) {
47  eventLoopOnGoing = false;
48  }
54  }
55  }
56 
57  TerminateEventLoop();
58 }
void ProcessOneEvent(G4int i_event) override
Process a single event.
void GGSWorkerRunManager::ProcessOneEvent ( G4int  i_event)
override

Process a single event.

This override implements some of the features of the GGSRunManagerExtensions, by saving the random engine seeds at the begin of the event generation and re-simulating killed events.

Definition at line 60 of file GGSWorkerRunManager.cpp.

60  {
61 
62  TIMEMORY_AUTO_TIMER("");
63  currentEvent = _SetupRandomNumbers(i_event);
64  // _SetupRandomNumbers will set eventLoopOnGoing to false and return nullptr if the event loop is already finished, so
65  // check before going on.
66  if (eventLoopOnGoing) {
68  userPrimaryGeneratorAction->GeneratePrimaries(currentEvent);
69  DumpStatus(currentEvent->GetEventID());
70  bool resim = true;
71  while (resim) {
73  eventManager->ProcessOneEvent(currentEvent);
74  resim = IsKilledAndToBeSimulatedAgain(currentEvent);
75  if (resim) {
76  // Create a new G4Event for this event
77  G4Event *newEvent = new G4Event(currentEvent->GetEventID());
78  delete currentEvent;
79  currentEvent = newEvent;
80  userPrimaryGeneratorAction->GeneratePrimaries(currentEvent);
81  }
82  }
83  AnalyzeEvent(currentEvent);
84  UpdateScoring();
85  if (currentEvent->GetEventID() < n_select_msg)
86  G4UImanager::GetUIpointer()->ApplyCommand(msgText);
87  }
88 }
bool IsKilledAndToBeSimulatedAgain(const G4Event *ev)
Checks if the event has been killed and has to be re-simulated.
void DumpStatus(G4int eventID)
Prints the status of the random number generator.
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...

The documentation for this class was generated from the following files: