Skip to content

Commit 6f8e7e0

Browse files
committed
updated doxygen for gdata
1 parent 6dcb20c commit 6f8e7e0

18 files changed

Lines changed: 1263 additions & 257 deletions

gdata/event/gEventDataCollection.cc

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,47 @@
11
/**
2-
* \file gEventDataCollection.cc
3-
* \brief Implementation of the GEventDataCollection class.
2+
* \file gEventDataCollection.cc
3+
* \brief Implementation of the \ref GEventDataCollection class.
44
*
55
* \details
6-
* Event collections own per-hit objects for each sensitive detector and provide
7-
* a simple API to append hit data during event processing.
6+
* An event collection owns per-hit objects for each sensitive detector and provides
7+
* the append API used during event processing.
8+
*
9+
* Key behaviors:
10+
* - Detector entries are created on demand when first referenced by name.
11+
* - Hit objects are owned via \c std::unique_ptr and are moved into the collection.
12+
* - The class does not enforce policies such as "truth and digitized hit counts must match";
13+
* such validation is typically performed by upstream logic or examples/tests.
814
*/
915

1016
#include "gEventDataCollection.h"
1117

1218
/// Counter used by examples/tests (not currently used in create()).
19+
///
20+
/// \details
21+
/// This exists as a convenience hook for potential future example factories.
22+
/// Current example behavior uses \ref GEventHeader::create() as the event counter.
1323
std::atomic<int> GEventDataCollection::globalEventDataCollectionCounter{1};
1424

1525
/// Counter used by \ref GEventHeader::create() to generate unique event numbers in examples/tests.
1626
std::atomic<int> GEventHeader::globalEventHeaderCounter{1};
1727

1828
void GEventDataCollection::addDetectorTrueInfoData(const std::string& sdName, std::unique_ptr<GTrueInfoData> data) {
1929
// Create detector entry if it does not exist.
30+
//
31+
// This makes the API robust for detectors appearing only in certain events.
2032
if (gdataCollectionMap.find(sdName) == gdataCollectionMap.end()) {
2133
gdataCollectionMap[sdName] = std::make_unique<GDataCollection>();
2234
}
2335

2436
// Event-level: store a new hit entry (ownership transferred).
37+
//
38+
// After std::move(data), the caller relinquishes ownership and should not use 'data'.
2539
gdataCollectionMap[sdName]->addTrueInfoData(std::move(data));
2640
log->info(2, "GEventDataCollection: added new detector TrueInfoData for ", sdName);
2741
}
2842

2943
void GEventDataCollection::addDetectorDigitizedData(const std::string& sdName, std::unique_ptr<GDigitizedData> data) {
44+
// Ensure the per-detector container exists.
3045
if (gdataCollectionMap.find(sdName) == gdataCollectionMap.end()) {
3146
gdataCollectionMap[sdName] = std::make_unique<GDataCollection>();
3247
}

gdata/event/gEventDataCollection.h

Lines changed: 43 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,20 @@
1414
* - vector<unique_ptr<GDigitizedData>>
1515
* \endcode
1616
*
17-
* Event-level semantics:
18-
* - each call to addDetectorTrueInfoData/addDetectorDigitizedData appends one hit entry
19-
* to the detector’s vectors.
17+
* ## Event-level semantics
18+
* - each call to \ref GEventDataCollection::addDetectorTrueInfoData() or \ref GEventDataCollection::addDetectorDigitizedData()
19+
* appends one hit entry to the specified detector’s vectors.
20+
* - the detector entry is created on demand if it does not already exist.
2021
*
21-
* Ownership:
22+
* ## Ownership
2223
* - The event collection owns all hit entries via \c std::unique_ptr.
23-
* - The caller transfers ownership when adding data.
24+
* - The caller transfers ownership when adding data (via \c std::move).
25+
*
26+
* ## Intended usage
27+
* A typical event loop will:
28+
* - create one \ref GEventDataCollection per event
29+
* - for each hit produced by simulation/digitization, push truth/digitized records into the event container
30+
* - pass the finished event container downstream (output, run integration, analysis, etc.)
2431
*/
2532

2633
#include "gEventHeader.h"
@@ -36,10 +43,13 @@ namespace gevent_data {
3643
/**
3744
* \brief Aggregated options for event-level data collection.
3845
*
46+
* \details
3947
* Combines options from:
4048
* - event header
4149
* - true/digitized data
4250
* - touchable (for identity creation in examples)
51+
*
52+
* This provides a single "options bundle" for event-level examples/applications.
4353
*/
4454
inline auto defineOptions() -> GOptions {
4555
auto goptions = GOptions(GEVENTDATA_LOGGER);
@@ -51,12 +61,28 @@ inline auto defineOptions() -> GOptions {
5161
}
5262
} // namespace gevent_data
5363

64+
/**
65+
* \brief Event container that owns per-detector hit data for one event.
66+
*
67+
* \details
68+
* The container is built around a map from sensitive detector name to \ref GDataCollection.
69+
* Each detector collection stores per-hit truth and digitized objects.
70+
*
71+
* The header (\ref GEventHeader) stores identifying metadata such as:
72+
* - local event number
73+
* - thread ID label
74+
* - timestamp string
75+
*/
5476
class GEventDataCollection : public GBase<GEventDataCollection>
5577
{
5678
public:
5779
/**
5880
* \brief Construct an event data collection with an owned header.
5981
*
82+
* \details
83+
* Ownership:
84+
* - \p header is moved into this object and is owned exclusively.
85+
*
6086
* \param gopts Shared options object used to configure logging and behavior.
6187
* \param header Owned event header.
6288
*/
@@ -67,7 +93,9 @@ class GEventDataCollection : public GBase<GEventDataCollection>
6793
/**
6894
* \brief Append one true-hit entry to the specified detector.
6995
*
70-
* If the detector name is new, the internal per-detector \ref GDataCollection is created.
96+
* \details
97+
* - If \p sdName is new, a per-detector \ref GDataCollection is created automatically.
98+
* - Ownership of \p data is transferred to this event container.
7199
*
72100
* \param sdName Sensitive detector name (map key).
73101
* \param data True-hit object; ownership is transferred to this collection.
@@ -77,6 +105,10 @@ class GEventDataCollection : public GBase<GEventDataCollection>
77105
/**
78106
* \brief Append one digitized-hit entry to the specified detector.
79107
*
108+
* \details
109+
* - If \p sdName is new, a per-detector \ref GDataCollection is created automatically.
110+
* - Ownership of \p data is transferred to this event container.
111+
*
80112
* \param sdName Sensitive detector name (map key).
81113
* \param data Digitized-hit object; ownership is transferred to this collection.
82114
*/
@@ -91,6 +123,7 @@ class GEventDataCollection : public GBase<GEventDataCollection>
91123
/**
92124
* \brief Access the per-detector map for this event.
93125
*
126+
* \details
94127
* Key: sensitive detector name.
95128
* Value: per-detector \ref GDataCollection containing per-hit entries.
96129
*
@@ -109,11 +142,14 @@ class GEventDataCollection : public GBase<GEventDataCollection>
109142
/**
110143
* \brief Test/example factory: create an event collection with one dummy hit for "ctof".
111144
*
112-
* This method supports examples/tests. It:
145+
* \details
146+
* This method exists to support examples/tests. It:
113147
* - creates a new \ref GEventHeader
114148
* - constructs an event data collection
115149
* - inserts one \ref GDigitizedData and one \ref GTrueInfoData entry under detector "ctof"
116150
*
151+
* This provides a minimal "event contains something" baseline for examples.
152+
*
117153
* \param gopts Shared options.
118154
* \return Shared pointer to the created event data collection.
119155
*/

gdata/event/gEventHeader.h

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,27 +18,47 @@
1818
* - a timestamp string (\c timeStamp)
1919
*
2020
* In production GEMC/Geant4, event number and thread ID would typically come from Geant4
21-
* (e.g. G4Event and G4Threading). In this library, \ref GEventHeader::create() provides a deterministic
22-
* generator for examples and tests.
21+
* (e.g. G4Event and G4Threading). In this library, \ref GEventHeader::create() provides a
22+
* deterministic generator for examples and tests.
23+
*
24+
* \note Time stamp is generated using the local system time at construction.
2325
*/
2426

2527
constexpr const char* GDATAEVENTHEADER_LOGGER = "event_header";
2628

2729
namespace geventheader {
2830
/**
29-
* \brief Defines GOptions for the event-header logger domain.
31+
* \brief Defines \ref GOptions for the event-header logger domain.
32+
*
33+
* \details
34+
* Event header logging can be enabled/controlled by including this in composite option bundles.
3035
*/
3136
inline GOptions defineOptions() {
3237
auto goptions = GOptions(GDATAEVENTHEADER_LOGGER);
3338
return goptions;
3439
}
3540
} // namespace geventheader
3641

42+
/**
43+
* \brief Minimal event metadata header: event number, thread id, and timestamp.
44+
*
45+
* \details
46+
* This object is typically owned by \ref GEventDataCollection as a \c std::unique_ptr.
47+
*
48+
* It is primarily used for:
49+
* - labeling events in logs/output
50+
* - reproducing the event/thread provenance for debugging
51+
*/
3752
class GEventHeader : public GBase<GEventHeader> {
3853
public:
3954
/**
4055
* \brief Construct an event header with explicit values.
4156
*
57+
* \details
58+
* The constructor:
59+
* - assigns \c timeStamp based on local time
60+
* - emits an informational log summarizing the header values
61+
*
4262
* \param gopts Shared options object used to configure logging and behavior.
4363
* \param n Local event number.
4464
* \param tid Thread ID associated with this event.
@@ -56,9 +76,13 @@ class GEventHeader : public GBase<GEventHeader> {
5676
/**
5777
* \brief Factory method used by examples/tests to create a header with a unique event number.
5878
*
79+
* \details
5980
* If \p tid is negative, a default thread ID is derived from the event number
6081
* (currently mod 8) to mimic multi-threaded execution.
6182
*
83+
* Threading notes:
84+
* - Uses an atomic counter so that concurrent calls from multiple threads produce unique event numbers.
85+
*
6286
* \param gopts Shared options.
6387
* \param tid Optional thread ID override.
6488
* \return Newly created event header.
@@ -80,6 +104,7 @@ class GEventHeader : public GBase<GEventHeader> {
80104

81105
/**
82106
* \brief Get the local event number.
107+
* \details This is "run-local" in typical Geant4 usage.
83108
* \return Event number.
84109
*/
85110
[[nodiscard]] inline int getG4LocalEvn() const { return g4localEventNumber; }
@@ -97,7 +122,12 @@ class GEventHeader : public GBase<GEventHeader> {
97122
/**
98123
* \brief Create a timestamp string using local time.
99124
*
100-
* Format: \c "Mon 01.30.2026 15:04:05" (weekday mm.dd.yyyy hh:mm:ss).
125+
* \details
126+
* Format:
127+
* \code
128+
* "Mon 01.30.2026 15:04:05"
129+
* \endcode
130+
* (weekday mm.dd.yyyy hh:mm:ss).
101131
*
102132
* \return Timestamp string.
103133
*/

0 commit comments

Comments
 (0)