eventDispenser
Loading...
Searching...
No Matches
EventDispenser Class Reference

Distributes events among run numbers and coordinates dynamic digitization initialization. More...

#include <eventDispenser.h>

Public Member Functions

 EventDispenser (const std::shared_ptr< GOptions > &gopt, const std::shared_ptr< const gdynamicdigitization::dRoutinesMap > &gdynamicDigitizationMap)
 Constructs an EventDispenser and prepares the run event distribution.
 
std::map< int, int > getRunEvents ()
 Returns the computed run-to-event allocation.
 
int getCurrentRun () const
 Returns the current run number from the internally stored run list.
 
int getTotalNumberOfEvents () const
 Computes the total number of events across all runs.
 
int processEvents ()
 Processes all runs by initializing digitization routines and dispatching events.
 
void setNumberOfEvents (int nevts)
 Sets the total number of events to process in single-run mode.
 
- Public Member Functions inherited from GBase< EventDispenser >
 GBase (const std::shared_ptr< GOptions > &gopt, std::string logger_name="")
 
 GBase (const std::shared_ptr< GLogger > &logger)
 
 GBase (const GBase &)=default
 
 GBase (GBase &&) noexcept=default
 
virtual ~GBase ()
 
GBaseoperator= (const GBase &)=default
 
GBaseoperator= (GBase &&) noexcept=default
 

Additional Inherited Members

- Protected Attributes inherited from GBase< EventDispenser >
std::shared_ptr< GLoggerlog
 

Detailed Description

EventDispenser provides a small orchestration layer that:

  • Interprets user configuration from GOptions (number of events, run selection, optional weight file).
  • Computes a run-to-event allocation (runEvents).
  • Iterates over the run allocation and, for each run:
    • Invokes all available GDynamicDigitization routines to load run-dependent constants and translation tables.
    • Issues Geant4 commands to execute the requested number of events for that run.
Note
The run number here refers to the simulation conditions (calibration/constants/translation-table selection), not the internal Geant4 run ID.

Definition at line 32 of file eventDispenser.h.

Constructor & Destructor Documentation

◆ EventDispenser()

EventDispenser::EventDispenser ( const std::shared_ptr< GOptions > & gopt,
const std::shared_ptr< const gdynamicdigitization::dRoutinesMap > & gdynamicDigitizationMap )

During construction, the object reads configuration from gopt and initializes its internal maps and lists. Depending on the configuration, it will either:

  • Assign all events to a single run number; or
  • Load run weights from a text file and derive a per-run event distribution.
Parameters
goptParsed module configuration (e.g. run number, number of events, optional weight file).
gdynamicDigitizationMapMap of dynamic digitization routines used to load run-dependent constants and translation tables.

Definition at line 25 of file eventDispenser.cc.

Member Function Documentation

◆ getCurrentRun()

int EventDispenser::getCurrentRun ( ) const
inline

This accessor is meaningful when a run-weight file was used and listOfRuns contains the run sequence. The index is currentRunIndex.

Warning
This method assumes listOfRuns is non-empty and currentRunIndex is within bounds.
Returns
The run number at index currentRunIndex.

Definition at line 149 of file eventDispenser.h.

◆ getRunEvents()

std::map< int, int > EventDispenser::getRunEvents ( )
inline

The allocation is prepared during construction (or after setNumberOfEvents() is called). Keys are run numbers and values are the number of events assigned to that run.

Returns
A copy of the run-to-event allocation map.

Definition at line 135 of file eventDispenser.h.

◆ getTotalNumberOfEvents()

int EventDispenser::getTotalNumberOfEvents ( ) const

This is the sum of all values in runEvents. In a correctly initialized object, it should match the user-requested event count (option -n), except for edge cases where the distribution inputs are inconsistent.

Returns
The total number of events assigned across all runs.

Definition at line 113 of file eventDispenser.cc.

◆ processEvents()

int EventDispenser::processEvents ( )

For each (runNumber, nevents) pair in runEvents, this method:

  • If the run differs from the last processed run, iterates all available digitization routines and calls their initialization hooks to load run-dependent data.
  • Issues a Geant4 command to execute nevents events for that run (currently a single /run/beamOn call per run allocation entry).
Returns
Status code (non-zero indicates success in the current implementation).

Definition at line 124 of file eventDispenser.cc.

◆ setNumberOfEvents()

void EventDispenser::setNumberOfEvents ( int nevts)

This method exists primarily for GUI-driven workflows, where the user may adjust the event count interactively. The method clears any existing distribution and assigns all events to userRunno.

Parameters
nevtsTotal number of events to assign to userRunno.

Definition at line 80 of file eventDispenser.cc.


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