gdata
Loading...
Searching...
No Matches
gEventDataCollection.h
Go to the documentation of this file.
1#pragma once
2
36#include "gEventHeader.h"
37
38// C++
39#include <map>
40#include <string>
41#include <vector>
42
43constexpr const char* GEVENTDATA_LOGGER = "gevent_data";
44
58{
60 std::string name;
61
63 int pid = 0;
64
66 int type = 1;
67
69 int multiplicity = 1;
70
72 double p = 0;
73
75 double theta = 0;
76
78 double phi = 0;
79
81 double vx = 0;
82
84 double vy = 0;
85
87 double vz = 0;
88};
89
93using GGeneratedParticleBank = std::vector<GGeneratedParticleData>;
94
99{
100 int pid = 0;
101 int tid = 0;
102 int mtid = 0;
103 double trackE = 0;
104 double px = 0;
105 double py = 0;
106 double pz = 0;
107 double vx = 0;
108 double vy = 0;
109 double vz = 0;
110};
111
112using GAncestorBank = std::vector<GAncestorData>;
113
114namespace gevent_data {
115
136
137} // namespace gevent_data
138
167class GEventDataCollection : public GBase<GEventDataCollection>
168{
169public:
179 GEventDataCollection(const std::shared_ptr<GOptions>& gopts, std::unique_ptr<GEventHeader> header)
180 : GBase(gopts, GEVENTDATA_LOGGER), gevent_header(std::move(header)) {
181 }
182
193 void addDetectorTrueInfoData(const std::string& sdName, std::unique_ptr<GTrueInfoData> data);
194
205 void addDetectorDigitizedData(const std::string& sdName, std::unique_ptr<GDigitizedData> data);
206
212 [[nodiscard]] auto getHeader() const -> const std::unique_ptr<GEventHeader>& { return gevent_header; }
213
222 [[nodiscard]] auto getDataCollectionMap() const
223 -> const std::map<std::string, std::unique_ptr<GDataCollection>>& {
224 return gdataCollectionMap;
225 }
226
236 generated_particles = std::move(particles);
237 }
238
248 generated_tracked_particles = std::move(particles);
249 }
250
256 [[nodiscard]] const GGeneratedParticleBank& getGeneratedParticles() const { return generated_particles; }
257
264 return generated_tracked_particles;
265 }
266
268 void setAncestors(GAncestorBank ancestors) {
269 ancestor_particles = std::move(ancestors);
270 ancestor_bank_enabled = true;
271 }
272
274 [[nodiscard]] const GAncestorBank& getAncestors() const { return ancestor_particles; }
275
277 [[nodiscard]] bool hasAncestorBank() const { return ancestor_bank_enabled; }
278
287 [[nodiscard]] auto getEventNumber() const -> int { return gevent_header->getG4LocalEvn(); }
288
303 static auto create(const std::shared_ptr<GOptions>& gopts) -> std::shared_ptr<GEventDataCollection> {
304 auto header = GEventHeader::create(gopts);
305 auto edc = std::make_shared<GEventDataCollection>(gopts, std::move(header));
306
307 auto digi_data = GDigitizedData::create(gopts);
308 auto true_data = GTrueInfoData::create(gopts);
309
310 edc->addDetectorDigitizedData("ctof", std::move(digi_data));
311 edc->addDetectorTrueInfoData("ctof", std::move(true_data));
312
313 return edc;
314 }
315
316private:
318 std::unique_ptr<GEventHeader> gevent_header;
319
321 std::map<std::string, std::unique_ptr<GDataCollection>> gdataCollectionMap;
322
324 GGeneratedParticleBank generated_particles;
325
327 GGeneratedParticleBank generated_tracked_particles;
328
330 GAncestorBank ancestor_particles;
331 bool ancestor_bank_enabled = false;
332
334 static std::atomic<int> globalEventDataCollectionCounter;
335};
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.
void setAncestors(GAncestorBank ancestors)
Stores the initial states of hit-producing tracks and their ancestors.
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.
const GAncestorBank & getAncestors() const
Returns the event-local ancestor bank.
bool hasAncestorBank() const
Reports whether ancestor output was requested for this event.
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.
std::vector< GAncestorData > GAncestorBank
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.
Initial state of one hit-producing track or one of its ancestors.
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.