gdata
Loading...
Searching...
No Matches
gEventDataCollection.h
Go to the documentation of this file.
1#pragma once
2
28#include "gDataCollection.h"
29#include "gEventHeader.h"
30
31// C++
32#include <map>
33#include <string>
34
35constexpr const char* GEVENTDATA_LOGGER = "gevent_data";
36
37namespace gevent_data {
38
59
60} // namespace gevent_data
61
87class GEventDataCollection : public GBase<GEventDataCollection>
88{
89public:
99 GEventDataCollection(const std::shared_ptr<GOptions>& gopts, std::unique_ptr<GEventHeader> header)
100 : GBase(gopts, GEVENTDATA_LOGGER), gevent_header(std::move(header)) {
101 }
102
113 void addDetectorTrueInfoData(const std::string& sdName, std::unique_ptr<GTrueInfoData> data);
114
125 void addDetectorDigitizedData(const std::string& sdName, std::unique_ptr<GDigitizedData> data);
126
132 [[nodiscard]] auto getHeader() const -> const std::unique_ptr<GEventHeader>& { return gevent_header; }
133
142 [[nodiscard]] auto getDataCollectionMap() const -> const std::map<std::string, std::unique_ptr<GDataCollection>>& {
143 return gdataCollectionMap;
144 }
145
154 [[nodiscard]] auto getEventNumber() const -> int { return gevent_header->getG4LocalEvn(); }
155
170 static auto create(const std::shared_ptr<GOptions>& gopts) -> std::shared_ptr<GEventDataCollection> {
171 auto header = GEventHeader::create(gopts);
172 auto edc = std::make_shared<GEventDataCollection>(gopts, std::move(header));
173
174 auto digi_data = GDigitizedData::create(gopts);
175 auto true_data = GTrueInfoData::create(gopts);
176
177 edc->addDetectorDigitizedData("ctof", std::move(digi_data));
178 edc->addDetectorTrueInfoData("ctof", std::move(true_data));
179
180 return edc;
181 }
182
183private:
185 std::unique_ptr<GEventHeader> gevent_header;
186
188 std::map<std::string, std::unique_ptr<GDataCollection>> gdataCollectionMap;
189
191 static std::atomic<int> globalEventDataCollectionCounter;
192};
Per-sensitive-detector container that owns truth and digitized data objects.
static std::unique_ptr< GDigitizedData > create(const std::shared_ptr< GOptions > &gopts)
Creates deterministic example data for tests and examples.
Owns all detector-local data for one event.
auto getEventNumber() const -> int
Returns the event number stored in the owned header.
static auto create(const std::shared_ptr< GOptions > &gopts) -> std::shared_ptr< GEventDataCollection >
Creates a minimal example event containing one detector entry and one hit pair.
GEventDataCollection(const std::shared_ptr< GOptions > &gopts, std::unique_ptr< GEventHeader > header)
Constructs an event data collection with an owned header.
void addDetectorTrueInfoData(const std::string &sdName, std::unique_ptr< GTrueInfoData > data)
Appends one truth object to the specified detector entry.
void addDetectorDigitizedData(const std::string &sdName, std::unique_ptr< GDigitizedData > data)
Appends one digitized object to the specified detector entry.
auto getDataCollectionMap() const -> const std::map< std::string, std::unique_ptr< GDataCollection > > &
Returns read-only access to the detector map for this event.
auto getHeader() const -> const std::unique_ptr< GEventHeader > &
Returns read-only access to the owned event header.
Stores minimal metadata for one event.
static std::unique_ptr< GEventHeader > create(const std::shared_ptr< GOptions > &gopts, int tid=-1)
Creates a header with a unique event number for tests and examples.
int getG4LocalEvn() const
Returns the local event number.
static std::unique_ptr< GTrueInfoData > create(const std::shared_ptr< GOptions > &gopts)
Creates deterministic example data for tests and examples.
Defines the GDataCollection class, the per-detector container of truth and digitized hit data.
constexpr const char * GEVENTDATA_LOGGER
Defines GEventHeader, the metadata header associated with one event container.
GOptions defineOptions()
Defines the options subtree used by the digitized-data logger domain.
auto defineOptions() -> GOptions
Aggregates the option groups needed by event-level data containers.
GOptions defineOptions()
Defines the options subtree used by the event-header logger domain.
GOptions defineOptions()
GOptions defineOptions()
Defines the options subtree used by the true-data logger domain.