gdata
Loading...
Searching...
No Matches
gEventDataCollection.h
Go to the documentation of this file.
1#pragma once
2
34#include "gEventHeader.h"
35
36// C++
37#include <map>
38#include <string>
39#include <vector>
40
41constexpr const char* GEVENTDATA_LOGGER = "gevent_data";
42
56{
58 std::string name;
59
61 int pid = 0;
62
64 int type = 1;
65
67 int multiplicity = 1;
68
70 double p = 0;
71
73 double theta = 0;
74
76 double phi = 0;
77
79 double vx = 0;
80
82 double vy = 0;
83
85 double vz = 0;
86};
87
91using GGeneratedParticleBank = std::vector<GGeneratedParticleData>;
92
93namespace gevent_data {
94
115
116} // namespace gevent_data
117
145class GEventDataCollection : public GBase<GEventDataCollection>
146{
147public:
157 GEventDataCollection(const std::shared_ptr<GOptions>& gopts, std::unique_ptr<GEventHeader> header)
158 : GBase(gopts, GEVENTDATA_LOGGER), gevent_header(std::move(header)) {
159 }
160
171 void addDetectorTrueInfoData(const std::string& sdName, std::unique_ptr<GTrueInfoData> data);
172
183 void addDetectorDigitizedData(const std::string& sdName, std::unique_ptr<GDigitizedData> data);
184
190 [[nodiscard]] auto getHeader() const -> const std::unique_ptr<GEventHeader>& { return gevent_header; }
191
200 [[nodiscard]] auto getDataCollectionMap() const
201 -> const std::map<std::string, std::unique_ptr<GDataCollection>>& {
202 return gdataCollectionMap;
203 }
204
214 generated_particles = std::move(particles);
215 }
216
226 generated_tracked_particles = std::move(particles);
227 }
228
234 [[nodiscard]] const GGeneratedParticleBank& getGeneratedParticles() const { return generated_particles; }
235
242 return generated_tracked_particles;
243 }
244
253 [[nodiscard]] auto getEventNumber() const -> int { return gevent_header->getG4LocalEvn(); }
254
269 static auto create(const std::shared_ptr<GOptions>& gopts) -> std::shared_ptr<GEventDataCollection> {
270 auto header = GEventHeader::create(gopts);
271 auto edc = std::make_shared<GEventDataCollection>(gopts, std::move(header));
272
273 auto digi_data = GDigitizedData::create(gopts);
274 auto true_data = GTrueInfoData::create(gopts);
275
276 edc->addDetectorDigitizedData("ctof", std::move(digi_data));
277 edc->addDetectorTrueInfoData("ctof", std::move(true_data));
278
279 return edc;
280 }
281
282private:
284 std::unique_ptr<GEventHeader> gevent_header;
285
287 std::map<std::string, std::unique_ptr<GDataCollection>> gdataCollectionMap;
288
290 GGeneratedParticleBank generated_particles;
291
293 GGeneratedParticleBank generated_tracked_particles;
294
296 static std::atomic<int> globalEventDataCollectionCounter;
297};
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.
const GGeneratedParticleBank & getGeneratedParticles() const
Returns the full generated-particle bank.
void setGeneratedTrackedParticles(GGeneratedParticleBank particles)
Stores the Geant4-tracked generated-particle bank for this event.
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.
const GGeneratedParticleBank & getGeneratedTrackedParticles() const
Returns the Geant4-tracked generated-particle bank.
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.
void setGeneratedParticles(GGeneratedParticleBank particles)
Stores the full generated-particle bank 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
std::vector< GGeneratedParticleData > GGeneratedParticleBank
Event-local generated-particle bank.
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.
Serialization record for one generated particle in event output.
std::string name
Particle name when known, otherwise a source-format identifier.
double theta
Polar angle in GEMC internal angular units.
double vy
Vertex y coordinate in GEMC internal length units.
double p
Momentum magnitude in GEMC internal units.
double phi
Azimuthal angle in GEMC internal angular units.
double vx
Vertex x coordinate in GEMC internal length units.
int type
Generator source type. For Lund input, type == 1 means Geant4-propagated.
int multiplicity
Number of copies represented by this row.
double vz
Vertex z coordinate in GEMC internal length units.
int pid
PDG id or source particle id.