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/ganalysis/gAnalysisAccumulator.h>
5#include <gemc/gdynamicDigitization/gdynamicdigitization.h>
6
7#include <chrono>
8#include <map>
9#include <memory>
10#include <optional>
11#include <vector>
12
17
35class EventDispenser : public GBase<EventDispenser>
36{
37public:
52 EventDispenser(const std::shared_ptr<GOptions>& gopt,
53 const std::shared_ptr<const gdynamicdigitization::dRoutinesMap>& gdynamicDigitizationMap,
54 std::shared_ptr<GAnalysisAccumulator> analysisAccumulator = nullptr);
55
56private:
61
63 int neventsToProcess;
64
66 int userRunno;
67
69 bool offscreen_screenshots = false;
70
72 int currentRunno = -1;
73
75
80
82 std::map<int, double> runWeights;
83
85 std::map<int, int> runEvents;
86
88 std::vector<int> listOfRuns;
89
91 int currentRunIndex{};
92
94 std::optional<std::chrono::steady_clock::time_point> beamOnTime;
95
97
112 void distributeEvents(int nevents_to_process);
113
120 void setNextRun() { currentRunIndex++; }
121
131 std::shared_ptr<const gdynamicdigitization::dRoutinesMap> gDigitizationMap;
132
134 std::shared_ptr<GAnalysisAccumulator> analysisAccumulator;
135
136public:
146 std::map<int, int> getRunEvents() { return runEvents; }
147
160 [[nodiscard]] int getCurrentRun() const { return listOfRuns[currentRunIndex]; }
161
172 [[nodiscard]] int getTotalNumberOfEvents() const;
173
186 int processEvents();
187
193 [[nodiscard]] bool beamOnIssued() const { return beamOnTime.has_value(); }
194
202 [[nodiscard]] std::chrono::steady_clock::time_point beamOnStartTime() const { return beamOnTime.value(); }
203
213 void setNumberOfEvents(int nevts);
214
222 void resetRunContext();
223};
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.
int getCurrentRun() const
Returns the current run number from the internally stored run list.
EventDispenser(const std::shared_ptr< GOptions > &gopt, const std::shared_ptr< const gdynamicdigitization::dRoutinesMap > &gdynamicDigitizationMap, std::shared_ptr< GAnalysisAccumulator > analysisAccumulator=nullptr)
Constructs an EventDispenser and prepares the run event distribution.
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.
GBase(const std::shared_ptr< GOptions > &gopt, std::string logger_name="")