Skip to content

Commit c379293

Browse files
committed
doxy improvement and added root rundata
1 parent 14a1884 commit c379293

28 files changed

Lines changed: 1147 additions & 940 deletions
Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,38 @@
11
/**
22
* \file gEventDataCollection.cc
3-
* \brief Implementation of \ref GEventDataCollection.
3+
* \brief Implementation of GEventDataCollection.
44
*
55
* \details
6-
* See \ref gEventDataCollection.h for the authoritative API documentation and ownership rules.
6+
* The header gEventDataCollection.h contains the authoritative API documentation, ownership rules,
7+
* and event-level semantics for this class.
78
*/
89

9-
// See header for API docs.
10-
1110
#include "gEventDataCollection.h"
1211

13-
/// Counter used by examples/tests (not currently used in create()).
14-
///
15-
/// \details
16-
/// This exists as a convenience hook for potential future example factories.
17-
/// Current example behavior uses \ref GEventHeader::create "create()" as the event counter.
12+
// Counter reserved for tests and future example helpers.
1813
std::atomic<int> GEventDataCollection::globalEventDataCollectionCounter{1};
1914

20-
/// Counter used by \ref GEventHeader::create "create()" to generate unique event numbers in examples/tests.
15+
// Counter used by GEventHeader::create() to generate unique event numbers in examples/tests.
2116
std::atomic<int> GEventHeader::globalEventHeaderCounter{1};
2217

2318
void GEventDataCollection::addDetectorTrueInfoData(const std::string& sdName, std::unique_ptr<GTrueInfoData> data) {
24-
// Create detector entry if it does not exist.
19+
// Create the detector entry on first insertion.
2520
if (gdataCollectionMap.find(sdName) == gdataCollectionMap.end()) {
2621
gdataCollectionMap[sdName] = std::make_unique<GDataCollection>();
2722
}
2823

29-
// Event-level: store a new hit entry (ownership transferred).
24+
// Event-level insertion transfers ownership of the hit-side object to the detector container.
3025
gdataCollectionMap[sdName]->addTrueInfoData(std::move(data));
3126
log->info(2, "GEventDataCollection: added new detector TrueInfoData for ", sdName);
3227
}
3328

3429
void GEventDataCollection::addDetectorDigitizedData(const std::string& sdName, std::unique_ptr<GDigitizedData> data) {
35-
// Ensure the per-detector container exists.
30+
// Create the detector entry on first insertion.
3631
if (gdataCollectionMap.find(sdName) == gdataCollectionMap.end()) {
3732
gdataCollectionMap[sdName] = std::make_unique<GDataCollection>();
3833
}
3934

40-
// Event-level: store a new hit entry (ownership transferred).
35+
// Event-level insertion transfers ownership of the hit-side object to the detector container.
4136
gdataCollectionMap[sdName]->addDigitizedData(std::move(data));
4237
log->info(2, "GEventDataCollection: added new detector DigitizedData for ", sdName);
4338
}

gdata/event/gEventDataCollection.h

Lines changed: 67 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,31 @@
22

33
/**
44
* \file gEventDataCollection.h
5-
* \brief Defines \ref GEventDataCollection, event-level aggregation of per-detector hit data.
5+
* \brief Defines GEventDataCollection, the event-level aggregation of detector hit data.
66
*
77
* \details
8-
* An event data collection groups all hit data produced during a single event.
9-
* The primary organization is:
8+
* GEventDataCollection groups all detector-local hit data produced during one event.
109
*
10+
* Primary organization:
1111
* \code
12-
* detector name (std::string) -> GDataCollection
13-
* - vector<unique_ptr<GTrueInfoData>>
14-
* - vector<unique_ptr<GDigitizedData>>
12+
* detector name (std::string) -> GDataCollection
13+
* - vector<unique_ptr<GTrueInfoData>>
14+
* - vector<unique_ptr<GDigitizedData>>
1515
* \endcode
1616
*
17-
* ## Event-level semantics
18-
* - each call to \ref GEventDataCollection::addDetectorTrueInfoData "addDetectorTrueInfoData()"
19-
* or \ref GEventDataCollection::addDetectorDigitizedData "addDetectorDigitizedData()"
20-
* appends one hit entry to the specified detector’s vectors.
21-
* - the detector entry is created on demand if it does not already exist.
17+
* Event semantics:
18+
* - each insertion appends one hit-side object to the target detector entry
19+
* - detector entries are created lazily on first use
20+
* - ownership of inserted objects is transferred to this collection
2221
*
23-
* ## Ownership
24-
* - The event collection owns all hit entries via \c std::unique_ptr.
25-
* - The caller transfers ownership when adding data (via \c std::move).
26-
*
27-
* ## Intended usage
28-
* A typical event loop will:
29-
* - create one \ref GEventDataCollection per event
30-
* - for each hit produced by simulation/digitization, push truth/digitized records into the event container
31-
* - pass the finished event container downstream (output, run integration, analysis, etc.)
22+
* Typical workflow:
23+
* - create one event container
24+
* - add truth and digitized objects as hits are produced
25+
* - pass the completed event container downstream for output, analysis, or run integration
3226
*/
3327

34-
#include "gEventHeader.h"
3528
#include "gDataCollection.h"
29+
#include "gEventHeader.h"
3630

3731
// C++
3832
#include <map>
@@ -41,18 +35,18 @@
4135
constexpr const char* GEVENTDATA_LOGGER = "gevent_data";
4236

4337
namespace gevent_data {
38+
4439
/**
45-
* \brief Aggregated options for event-level data collection.
40+
* \brief Aggregates the option groups needed by event-level data containers.
4641
*
4742
* \details
48-
* Combines options from:
49-
* - event header
50-
* - true/digitized data
51-
* - touchable (for identity creation in examples)
43+
* The returned bundle includes:
44+
* - event-header options
45+
* - true-data options
46+
* - digitized-data options
47+
* - touchable-related options used by example identity creation
5248
*
53-
* This provides a single "options bundle" for event-level examples/applications.
54-
*
55-
* \return Composite options group rooted at \ref GEVENTDATA_LOGGER.
49+
* \return Composite options group rooted at \c GEVENTDATA_LOGGER.
5650
*/
5751
inline auto defineOptions() -> GOptions {
5852
auto goptions = GOptions(GEVENTDATA_LOGGER);
@@ -62,77 +56,76 @@ inline auto defineOptions() -> GOptions {
6256
goptions += gtouchable::defineOptions();
6357
return goptions;
6458
}
59+
6560
} // namespace gevent_data
6661

6762
/**
68-
* \brief Event container that owns per-detector hit data for one event.
63+
* \brief Owns all detector-local data for one event.
6964
*
7065
* \details
71-
* The container is built around a map from sensitive detector name to \ref GDataCollection.
72-
* Each detector collection stores per-hit truth and digitized objects.
66+
* The object combines:
67+
* - one owned GEventHeader describing the event
68+
* - one map of detector names to GDataCollection instances
7369
*
74-
* The header (\ref GEventHeader) stores identifying metadata such as:
75-
* - local event number
76-
* - thread ID label
77-
* - timestamp string
70+
* Each detector entry can contain:
71+
* - zero or more truth objects
72+
* - zero or more digitized objects
7873
*
79-
* \note
80-
* This class intentionally does not enforce invariants such as "truth hits must equal digitized hits".
81-
* If an application requires such invariants, it should validate them at a higher level.
74+
* The class does not enforce structural invariants such as matching truth and digitized counts.
75+
* Applications that require such guarantees should validate them at a higher level.
8276
*/
8377
class GEventDataCollection : public GBase<GEventDataCollection>
8478
{
8579
public:
8680
/**
87-
* \brief Construct an event data collection with an owned header.
81+
* \brief Constructs an event data collection with an owned header.
8882
*
8983
* \details
90-
* Ownership:
91-
* - \p header is moved into this object and is owned exclusively.
84+
* Ownership of \p header is transferred to the collection.
9285
*
93-
* \param gopts Shared options object used to configure logging and behavior.
94-
* \param header Owned event header.
86+
* \param gopts Shared options used to configure logging and related behavior.
87+
* \param header Owned event header.
9588
*/
9689
GEventDataCollection(const std::shared_ptr<GOptions>& gopts, std::unique_ptr<GEventHeader> header)
9790
: GBase(gopts, GDATAEVENTHEADER_LOGGER), gevent_header(std::move(header)) {
9891
}
9992

10093
/**
101-
* \brief Append one true-hit entry to the specified detector.
94+
* \brief Appends one truth object to the specified detector entry.
10295
*
10396
* \details
104-
* - If \p sdName is new, a per-detector \ref GDataCollection is created automatically.
105-
* - Ownership of \p data is transferred to this event container.
97+
* If the detector key does not exist yet, a new GDataCollection is created automatically.
98+
* Ownership of \p data is transferred to the target detector entry.
10699
*
107-
* \param sdName Sensitive detector name (map key).
108-
* \param data True-hit object; ownership is transferred to this collection.
100+
* \param sdName Sensitive detector name used as the map key.
101+
* \param data Truth object to store.
109102
*/
110103
void addDetectorTrueInfoData(const std::string& sdName, std::unique_ptr<GTrueInfoData> data);
111104

112105
/**
113-
* \brief Append one digitized-hit entry to the specified detector.
106+
* \brief Appends one digitized object to the specified detector entry.
114107
*
115108
* \details
116-
* - If \p sdName is new, a per-detector \ref GDataCollection is created automatically.
117-
* - Ownership of \p data is transferred to this event container.
109+
* If the detector key does not exist yet, a new GDataCollection is created automatically.
110+
* Ownership of \p data is transferred to the target detector entry.
118111
*
119-
* \param sdName Sensitive detector name (map key).
120-
* \param data Digitized-hit object; ownership is transferred to this collection.
112+
* \param sdName Sensitive detector name used as the map key.
113+
* \param data Digitized object to store.
121114
*/
122115
void addDetectorDigitizedData(const std::string& sdName, std::unique_ptr<GDigitizedData> data);
123116

124117
/**
125-
* \brief Access the owned event header.
126-
* \return Const reference to the header unique_ptr.
118+
* \brief Returns read-only access to the owned event header.
119+
*
120+
* \return Const reference to the owned event-header pointer.
127121
*/
128122
[[nodiscard]] auto getHeader() const -> const std::unique_ptr<GEventHeader>& { return gevent_header; }
129123

130124
/**
131-
* \brief Access the per-detector map for this event.
125+
* \brief Returns read-only access to the detector map for this event.
132126
*
133127
* \details
134-
* Key: sensitive detector name.
135-
* Value: per-detector \ref GDataCollection containing per-hit entries.
128+
* Keys are sensitive detector names and values are per-detector GDataCollection instances.
136129
*
137130
* \return Const reference to the detector map.
138131
*/
@@ -141,28 +134,28 @@ class GEventDataCollection : public GBase<GEventDataCollection>
141134
}
142135

143136
/**
144-
* \brief Convenience accessor for the event number.
137+
* \brief Returns the event number stored in the owned header.
145138
*
146139
* \details
147-
* Equivalent to \ref GEventHeader::getG4LocalEvn "getG4LocalEvn()" on the owned header.
140+
* This is a convenience wrapper around the header accessor.
148141
*
149-
* \return Event number stored in the header.
142+
* \return Event number.
150143
*/
151144
[[nodiscard]] auto getEventNumber() const -> int { return gevent_header->getG4LocalEvn(); }
152145

153146
/**
154-
* \brief Test/example factory: create an event collection with one dummy hit for "ctof".
147+
* \brief Creates a minimal example event containing one detector entry and one hit pair.
155148
*
156149
* \details
157-
* This method exists to support examples/tests. It:
158-
* - creates a new \ref GEventHeader via \ref GEventHeader::create "create()"
159-
* - constructs an event data collection
160-
* - inserts one \ref GDigitizedData and one \ref GTrueInfoData entry under detector "ctof"
161-
*
162-
* This provides a minimal "event contains something" baseline for examples.
150+
* This helper is intended for examples and tests.
151+
* It creates:
152+
* - a fresh GEventHeader
153+
* - a new event container
154+
* - one digitized object under detector \c ctof
155+
* - one truth object under detector \c ctof
163156
*
164157
* \param gopts Shared options.
165-
* \return Shared pointer to the created event data collection.
158+
* \return Shared pointer to the created event collection.
166159
*/
167160
static auto create(const std::shared_ptr<GOptions>& gopts) -> std::shared_ptr<GEventDataCollection> {
168161
auto header = GEventHeader::create(gopts);
@@ -178,11 +171,12 @@ class GEventDataCollection : public GBase<GEventDataCollection>
178171
}
179172

180173
private:
181-
std::unique_ptr<GEventHeader> gevent_header; ///< Owned event header.
174+
/// Owned event header describing this event.
175+
std::unique_ptr<GEventHeader> gevent_header;
182176

183177
/// Per-detector data map keyed by sensitive detector name.
184178
std::map<std::string, std::unique_ptr<GDataCollection>> gdataCollectionMap;
185179

186-
/// Static thread-safe event counter - used for testing/examples only.
180+
/// Static thread-safe counter reserved for tests or future example helpers.
187181
static std::atomic<int> globalEventDataCollectionCounter;
188-
};
182+
};

0 commit comments

Comments
 (0)