eventDispenser
Loading...
Searching...
No Matches
event_dispenser_example.cc
Go to the documentation of this file.
1
44
45#include "eventDispenser.h"
47#include "goptions.h"
48
49#include <map>
50#include <stdexcept>
51#include <string>
52
53const std::string plugin_name = "test_gdynamic_plugin";
54
70int main(int argc, char *argv[]) {
71 // Build the option definition set for this module and parse command-line arguments.
72 auto gopts = std::make_shared<GOptions>(argc, argv, eventDispenser::defineOptions());
73
74 // Create the global map of digitization routines.
75 // In a full simulation, this map would contain the digitization plugins needed by the detectors.
76 auto dynamicRoutinesMap = gdynamicdigitization::dynamicRoutinesMap({plugin_name}, gopts);
77
78 // Instantiate the EventDispenser with parsed options and the digitization routine map.
79 EventDispenser eventDisp(gopts, dynamicRoutinesMap);
80 if (eventDisp.beamOnIssued()) return EXIT_FAILURE;
81 try {
82 [[maybe_unused]] const auto prematureStart = eventDisp.beamOnStartTime();
83 return EXIT_FAILURE;
84 }
85 catch (const std::logic_error&) {
86 }
87
88 // Retrieve the run-to-event allocation computed during construction.
89 // This can be used by applications to report expected run statistics or validate configuration.
90 std::map<int, int> runEvents = eventDisp.getRunEvents();
91 (void)runEvents; // suppress unused-variable warnings in minimal builds
92
93 // Execute the processing loop: per-run initialization + event dispatch.
94 eventDisp.processEvents();
95 if (!eventDisp.beamOnIssued()) return EXIT_FAILURE;
96
97 return EXIT_SUCCESS;
98}
Distributes events among run numbers and coordinates dynamic digitization initialization.
Declares the EventDispenser class.
Public declaration of the Event Dispenser module command-line / configuration options.
GOptions defineOptions()
Builds and returns the complete set of options supported by the Event Dispenser module.
std::shared_ptr< const dRoutinesMap > dynamicRoutinesMap(const std::vector< std::string > &plugin_names, const std::shared_ptr< GOptions > &gopts)
const std::string plugin_name
int main(int argc, char *argv[])