eventDispenser
Loading...
Searching...
No Matches
eventDispenser.h
Go to the documentation of this file.
1#pragma once
2
3#include <gemc/gbase/gbase.h>
4#include <gemc/gdynamicDigitization/gdynamicdigitization.h>
5
6#include <chrono>
7#include <map>
8#include <memory>
9#include <optional>
10#include <vector>
11
34class EventDispenser : public GBase<EventDispenser>
35{
36public:
50 EventDispenser(const std::shared_ptr<GOptions>& gopt,
51 const std::shared_ptr<const gdynamicdigitization::dRoutinesMap>& gdynamicDigitizationMap);
52
53private:
60 int neventsToProcess;
61
63 int userRunno;
64
66 bool offscreen_screenshots = false;
67
69 int currentRunno = -1;
70
79 std::map<int, double> runWeights;
80
82 std::map<int, int> runEvents;
83
85 std::vector<int> listOfRuns;
86
88 int currentRunIndex{};
89
91 std::optional<std::chrono::steady_clock::time_point> beamOnTime;
92
109 void distributeEvents(int nevents_to_process);
110
117 void setNextRun() { currentRunIndex++; }
118
128 std::shared_ptr<const gdynamicdigitization::dRoutinesMap> gDigitizationMap;
129
130public:
140 std::map<int, int> getRunEvents() { return runEvents; }
141
154 [[nodiscard]] int getCurrentRun() const { return listOfRuns[currentRunIndex]; }
155
166 [[nodiscard]] int getTotalNumberOfEvents() const;
167
180 int processEvents();
181
187 [[nodiscard]] bool beamOnIssued() const { return beamOnTime.has_value(); }
188
196 [[nodiscard]] std::chrono::steady_clock::time_point beamOnStartTime() const { return beamOnTime.value(); }
197
207 void setNumberOfEvents(int nevts);
208
216 void resetRunContext();
217};
Distributes events among run numbers and coordinates dynamic digitization initialization.
void resetRunContext()
Force per-run digitization setup to run again on the next event batch.
bool beamOnIssued() const
Returns whether at least one /run/beamOn has been issued.
int processEvents()
Processes all runs by initializing digitization routines and dispatching events.
std::chrono::steady_clock::time_point beamOnStartTime() const
Returns the wall-clock time of the first /run/beamOn.
EventDispenser(const std::shared_ptr< GOptions > &gopt, const std::shared_ptr< const gdynamicdigitization::dRoutinesMap > &gdynamicDigitizationMap)
Constructs an EventDispenser and prepares the run event distribution.
int getCurrentRun() const
Returns the current run number from the internally stored run list.
void setNumberOfEvents(int nevts)
Sets the total number of events to process in single-run mode.
int getTotalNumberOfEvents() const
Computes the total number of events across all runs.
std::map< int, int > getRunEvents()
Returns the computed run-to-event allocation.