actions
Loading...
Searching...
No Matches
gRunAction.h
Go to the documentation of this file.
1#pragma once
2
3// geant4
4#include "G4UserRunAction.hh"
5
6
7// gemc
8#include "gbase.h"
10#include "gstreamer.h"
11// #include "frame/gFrameDataCollection.h"
12
20constexpr const char* GRUNACTION_LOGGER = "grunaction";
21
27namespace grunaction {
34} // namespace grunaction
35
36
54class GRunAction : public GBase<GRunAction>, public G4UserRunAction {
55public:
62 GRunAction(std::shared_ptr<GOptions> gopts, std::shared_ptr<gdynamicdigitization::dRoutinesMap> digi_map);
63
72 auto get_digitization_routines_map() const -> std::shared_ptr<gdynamicdigitization::dRoutinesMap> {
73 return digitization_routines_map;
74 }
75
83 auto get_streamer_map() const -> std::shared_ptr<const gstreamer::gstreamersMap> {
84 return gstreamer_map;
85 }
86
87private:
96 G4Run* GenerateRun() override;
97
107 void BeginOfRunAction(const G4Run* run) override;
108
117 void EndOfRunAction(const G4Run* run) override;
118
122 std::shared_ptr<GOptions> goptions;
123
127 std::shared_ptr<gdynamicdigitization::dRoutinesMap> digitization_routines_map;
128
132 std::shared_ptr<const gstreamer::gstreamersMap> gstreamer_map;
133};
134
135
136
137// vector of frame data in the run (local thread, merged in GRun::Merge in the global thread)
138// std::vector<GFrameDataCollection*> frameRunData;
139
140//
141// double frameDuration = UNINITIALIZEDNUMBERQUANTITY; // frame length in nanoseconds
142// double eventDuration = UNINITIALIZEDNUMBERQUANTITY; // event duration in nanoseconds
143// int eventIndex = 0; // added to the absolute event number, increases with each run
144// int lastFrameCreated = 0; // keeping track of the last frame created
145//
146// // determine the frame ID based on event number, eventDuration, frameDuration
147// // TODO: this should be in gdata?
148// int eventFrameIndex(int eventNumber, double timeAtElectronics);
149// bool findFrameID(int fid);
150//
151// // decide whether to write or not to stream the frame based on event number, eventDuration, frameDuration and number of threads
152// // streaming the frame also deletes it from frameRunData
153// // TODO: this should be in gdata?
154// bool shouldWriteFrameID(int eventNumber, long int frameID);
155//
156// // TODO: this should be in gdata?
157// std::vector<int> formPayload(GDigitizedData* digitizedData);
158
159
160// in the constructur we had:
161
162// frameDuration = 64000;
163// eventDuration = gutilities::getG4Number(goptions->getScalarString("eventTimeSize"));
164
165// stream = gopt->getSwitch("stream");
Handles run begin/end callbacks and creates the per-thread run object.
Definition gRunAction.h:54
auto get_streamer_map() const -> std::shared_ptr< const gstreamer::gstreamersMap >
Returns the per-thread streamer map, if it has been created.
Definition gRunAction.h:83
auto get_digitization_routines_map() const -> std::shared_ptr< gdynamicdigitization::dRoutinesMap >
Returns the shared digitization routines map.
Definition gRunAction.h:72
GRunAction(std::shared_ptr< GOptions > gopts, std::shared_ptr< gdynamicdigitization::dRoutinesMap > digi_map)
Constructs the run action.
Definition gRunAction.cc:12
constexpr const char * GRUNACTION_LOGGER
Definition gRunAction.h:20
Namespace collecting helpers for the run action.
Definition gRunAction.h:27
GOptions defineOptions()
Returns the options associated with the run action.
Definition gRunAction.h:33