gdata
Loading...
Searching...
No Matches
gEventDataCollection.h
Go to the documentation of this file.
1#pragma once
2
11#include "gEventHeader.h"
12#include "gDataCollection.h"
13
14// C++
15#include <map>
16#include <string>
17
18constexpr const char* GEVENTDATA_LOGGER = "gevent_data";
19
20namespace gevent_data {
21inline GOptions defineOptions() {
22 auto goptions = GOptions(GEVENTDATA_LOGGER);
23 goptions += gheader::defineOptions();
24 goptions += gtrue_data::defineOptions();
25 goptions += gdigi_data::defineOptions();
26 goptions += gtouchable::defineOptions();
27 return goptions;
28}
29}
30
31
32class GEventDataCollection : public GBase<GEventDataCollection> {
33public:
41 GEventDataCollection(const std::shared_ptr<GOptions>& gopts, std::unique_ptr<GEventHeader> header)
42 : GBase(gopts, GDATAHEADER_LOGGER), gheader(std::move(header)) { }
43
49 void addDetectorTrueInfoData(const std::string& sdName, std::unique_ptr<GTrueInfoData> data);
50
56 void addDetectorDigitizedData(const std::string& sdName, std::unique_ptr<GDigitizedData> data);
57
62 [[nodiscard]] inline const std::unique_ptr<GEventHeader>& getHeader() const { return gheader; }
63
68 [[nodiscard]] inline const std::map<std::string, std::unique_ptr<GDataCollection>>& getDataCollectionMap() const { return gdataCollectionMap; }
69
74 [[nodiscard]] inline int getEventNumber() const { return gheader->getG4LocalEvn(); }
75
76
77 // returning shared here as GEventDataCollection may be used by multiple streams and also collected in a runData vector
78 static std::shared_ptr<GEventDataCollection> create(const std::shared_ptr<GOptions>& gopts) {
79 auto header = GEventHeader::create(gopts);
80 auto edc = std::make_shared<GEventDataCollection>(gopts, std::move(header));
81
82 auto digi_data = GDigitizedData::create(gopts);
83 auto true_data = GTrueInfoData::create(gopts);
84
85 edc->addDetectorDigitizedData("ctof", std::move(digi_data));
86 edc->addDetectorTrueInfoData("ctof", std::move(true_data));
87
88 return edc;
89 }
90
91private:
92 std::unique_ptr<GEventHeader> gheader;
93 std::map<std::string, std::unique_ptr<GDataCollection>> gdataCollectionMap;
94
96 static std::atomic<int> globalEventDataCollectionCounter;
97
98};
static std::unique_ptr< GDigitizedData > create(const std::shared_ptr< GOptions > &gopts)
const std::map< std::string, std::unique_ptr< GDataCollection > > & getDataCollectionMap() const
Gets the map of data collections.
static std::shared_ptr< GEventDataCollection > create(const std::shared_ptr< GOptions > &gopts)
GEventDataCollection(const std::shared_ptr< GOptions > &gopts, std::unique_ptr< GEventHeader > header)
Constructs a GEventDataCollection.
void addDetectorTrueInfoData(const std::string &sdName, std::unique_ptr< GTrueInfoData > data)
Adds true hit information data for a detector.
void addDetectorDigitizedData(const std::string &sdName, std::unique_ptr< GDigitizedData > data)
Adds digitized hit data for a detector.
int getEventNumber() const
Gets the event number.
const std::unique_ptr< GEventHeader > & getHeader() const
Gets the event header.
static std::unique_ptr< GEventHeader > create(const std::shared_ptr< GOptions > &gopts, int tid=-1)
Factory method to create a GEventDataCollectionHeader with a unique event number.
static std::unique_ptr< GTrueInfoData > create(const std::shared_ptr< GOptions > &gopts)
constexpr const char * GEVENTDATA_LOGGER
constexpr const char * GDATAHEADER_LOGGER
GOptions defineOptions()
GOptions defineOptions()
GOptions defineOptions()
GOptions defineOptions()