gdata
Loading...
Searching...
No Matches
gEventDataCollection.h
Go to the documentation of this file.
1#pragma once
2
34#include "gEventHeader.h"
35#include "gDataCollection.h"
36
37// C++
38#include <map>
39#include <string>
40
41constexpr const char* GEVENTDATA_LOGGER = "gevent_data";
42
66
83class GEventDataCollection : public GBase<GEventDataCollection>
84{
85public:
96 GEventDataCollection(const std::shared_ptr<GOptions>& gopts, std::unique_ptr<GEventHeader> header)
97 : GBase(gopts, GDATAEVENTHEADER_LOGGER), gevent_header(std::move(header)) {
98 }
99
110 void addDetectorTrueInfoData(const std::string& sdName, std::unique_ptr<GTrueInfoData> data);
111
122 void addDetectorDigitizedData(const std::string& sdName, std::unique_ptr<GDigitizedData> data);
123
128 [[nodiscard]] auto getHeader() const -> const std::unique_ptr<GEventHeader>& { return gevent_header; }
129
139 [[nodiscard]] auto getDataCollectionMap() const -> const std::map<std::string, std::unique_ptr<GDataCollection>>& {
140 return gdataCollectionMap;
141 }
142
151 [[nodiscard]] auto getEventNumber() const -> int { return gevent_header->getG4LocalEvn(); }
152
167 static auto create(const std::shared_ptr<GOptions>& gopts) -> std::shared_ptr<GEventDataCollection> {
168 auto header = GEventHeader::create(gopts);
169 auto edc = std::make_shared<GEventDataCollection>(gopts, std::move(header));
170
171 auto digi_data = GDigitizedData::create(gopts);
172 auto true_data = GTrueInfoData::create(gopts);
173
174 edc->addDetectorDigitizedData("ctof", std::move(digi_data));
175 edc->addDetectorTrueInfoData("ctof", std::move(true_data));
176
177 return edc;
178 }
179
180private:
181 std::unique_ptr<GEventHeader> gevent_header;
182
184 std::map<std::string, std::unique_ptr<GDataCollection>> gdataCollectionMap;
185
187 static std::atomic<int> globalEventDataCollectionCounter;
188};
Per-sensitive-detector container that owns true and digitized hit data.
static std::unique_ptr< GDigitizedData > create(const std::shared_ptr< GOptions > &gopts)
Test/example factory: create a digitized hit with deterministic dummy data.
Event container that owns per-detector hit data for one event.
auto getEventNumber() const -> int
Convenience accessor for the event number.
static auto create(const std::shared_ptr< GOptions > &gopts) -> std::shared_ptr< GEventDataCollection >
Test/example factory: create an event collection with one dummy hit for "ctof".
GEventDataCollection(const std::shared_ptr< GOptions > &gopts, std::unique_ptr< GEventHeader > header)
Construct an event data collection with an owned header.
void addDetectorTrueInfoData(const std::string &sdName, std::unique_ptr< GTrueInfoData > data)
Append one true-hit entry to the specified detector.
void addDetectorDigitizedData(const std::string &sdName, std::unique_ptr< GDigitizedData > data)
Append one digitized-hit entry to the specified detector.
auto getDataCollectionMap() const -> const std::map< std::string, std::unique_ptr< GDataCollection > > &
Access the per-detector map for this event.
auto getHeader() const -> const std::unique_ptr< GEventHeader > &
Access the owned event header.
Minimal event metadata header: event number, thread id, and timestamp.
static std::unique_ptr< GEventHeader > create(const std::shared_ptr< GOptions > &gopts, int tid=-1)
Factory method used by examples/tests to create a header with a unique event number.
int getG4LocalEvn() const
Get the local event number.
static std::unique_ptr< GTrueInfoData > create(const std::shared_ptr< GOptions > &gopts)
Test/example factory: create a true-hit object with deterministic dummy data.
constexpr const char * GEVENTDATA_LOGGER
Defines GEventHeader metadata for an event data collection.
constexpr const char * GDATAEVENTHEADER_LOGGER
GOptions defineOptions()
Defines GOptions for the digitized-data logger domain.
auto defineOptions() -> GOptions
Aggregated options for event-level data collection.
GOptions defineOptions()
Defines GOptions for the event-header logger domain.
GOptions defineOptions()
GOptions defineOptions()
Defines GOptions for the true-data logger domain.