gdata
Loading...
Searching...
No Matches
gRunHeader.h
Go to the documentation of this file.
1#pragma once
2
3// gemc
4#include <gemc/gbase/gbase.h>
5
6// C++
7#include <string>
8
21
22constexpr const char* GDATARUNHEADER_LOGGER = "run_header";
23
24namespace grun_header {
25
35inline auto defineOptions() -> GOptions {
37 return goptions;
38}
39
40} // namespace grun_header
41
50
68class GRunHeader : public GBase<GRunHeader>
69{
70public:
82 GRunHeader(const std::shared_ptr<GOptions>& gopts, int rid, int tid = -1)
83 : GBase(gopts, GDATARUNHEADER_LOGGER), runID(rid) {
84 log->debug(CONSTRUCTOR, "GRunHeader");
85 if (tid != -1) {
86 log->info(
87 1,
88 "\n%1 Run ID: %2\n%3 Number of events processed: %4\n%5 Number of events with payload: "
89 "%6\n%7 Thread ID: %8", guts::TPOINTITEM, rid, guts::TPOINTITEM, events_processed,
90 guts::TPOINTITEM, events_with_payload, guts::TPOINTITEM, tid);
91 }
92 else {
93 log->info(
94 1,
95 "\n%1 Run ID: %2\n%3 Number of events processed: %4\n%5 Number of events with payload: %6",
96 guts::TPOINTITEM, rid, guts::TPOINTITEM, events_processed, guts::TPOINTITEM,
97 events_with_payload);
98 }
99 }
100
106 [[nodiscard]] auto getRunID() const -> int { return runID; }
107
113 [[nodiscard]] auto get_events_processed() const -> int { return events_processed; }
114
120 [[nodiscard]] auto get_events_with_payload() const -> int { return events_with_payload; }
121
128 void increment_events_processed() { events_processed++; }
129
137 void increment_events_with_payload() { events_with_payload++; }
138
144 void add_events_processed(int count) { events_processed += count; }
145
151 void add_events_with_payload(int count) { events_with_payload += count; }
152
153private:
155 int events_processed{0};
156
158 int events_with_payload{0};
159
161 int runID;
162};
GBase(const std::shared_ptr< GOptions > &gopt, std::string logger_name="")
std::shared_ptr< GLogger > log
void add_events_processed(int count)
Adds an arbitrary number of processed events to the counter.
Definition gRunHeader.h:144
GRunHeader(const std::shared_ptr< GOptions > &gopts, int rid, int tid=-1)
Constructs a run header.
Definition gRunHeader.h:82
void increment_events_processed()
Increments the processed-event counter by one.
Definition gRunHeader.h:128
void add_events_with_payload(int count)
Adds an arbitrary number of payload-producing events to the counter.
Definition gRunHeader.h:151
auto get_events_processed() const -> int
Returns the total number of processed events tracked by this header.
Definition gRunHeader.h:113
auto getRunID() const -> int
Returns the run identifier.
Definition gRunHeader.h:106
auto get_events_with_payload() const -> int
Returns the number of processed events that contributed payload.
Definition gRunHeader.h:120
void increment_events_with_payload()
Increments the payload-producing-event counter by one.
Definition gRunHeader.h:137
constexpr const char * GDATARUNHEADER_LOGGER
Definition gRunHeader.h:22
CONSTRUCTOR
auto defineOptions() -> GOptions
Defines the options subtree used by the run-header logger domain.
Definition gRunHeader.h:35
constexpr char TPOINTITEM[]