gdata
Loading...
Searching...
No Matches
gRunDataCollection.cc
Go to the documentation of this file.
1
12#include "gRunDataCollection.h"
13
14void GRunDataCollection::collectDetectorDigitizedData(const std::string& sdName,
15 const std::unique_ptr<GDigitizedData>& data) {
16 // Create the detector accumulator entry on first use.
17 if (gdataCollectionMap.find(sdName) == gdataCollectionMap.end()) {
18 gdataCollectionMap[sdName] = std::make_unique<GDataCollection>();
19 }
20
21 // Delegate detector-local digitized accumulation.
22 gdataCollectionMap[sdName]->collectDigitizedData(data);
23}
24
25void GRunDataCollection::collect_event_data_collection(const std::shared_ptr<GEventDataCollection> edc) {
26 // Count the integrated event once at the run-summary level.
27 grun_header->increment_events_processed();
28
29 // Detector map for this event: detector name -> per-detector event data.
30 auto& dcm = edc->getDataCollectionMap();
31
32 // Integrate the digitized hit entries present for each detector.
33 for (auto& [sdname, ptr] : dcm) {
34 if (!ptr) continue;
35
36 auto& digitized_data = ptr->getDigitizedData();
37 for (auto& digitized_data_hit : digitized_data) {
38 collectDetectorDigitizedData(sdname, digitized_data_hit);
39 }
40 }
41}
42
44 std::unique_ptr<GDigitizedData> ddata) {
45 collectDetectorDigitizedData(sdName, ddata);
46 log->info(2, *gdataCollectionMap[sdName]);
47}
48
50 // Merge run-level counters first.
51 grun_header->add_events_processed(other.get_events_processed());
52 grun_header->add_events_with_payload(other.get_events_with_payload());
53
54 const auto& other_map = other.getDataCollectionMap();
55
56 // Merge already-integrated digitized detector content from the other accumulator.
57 for (const auto& [sdName, other_data_collection] : other_map) {
58 if (!other_data_collection) {
59 continue;
60 }
61
62 const auto& other_digitized_data = other_data_collection->getDigitizedData();
63 for (const auto& digitized_data_hit : other_digitized_data) {
64 if (digitized_data_hit) {
65 collectDetectorDigitizedData(sdName, digitized_data_hit);
66 }
67 }
68 }
69}
std::shared_ptr< GLogger > log
void info(int level, Args &&... args) const
Owns and updates the run-level detector summary map.
auto getDataCollectionMap() const -> const std::map< std::string, std::unique_ptr< GDataCollection > > &
Returns read-only access to the detector summary map.
void collect_event_data_collection(const std::shared_ptr< GEventDataCollection > edc)
Integrates one event collection into the run summary.
void collect_event_data_collections(const std::string &sdName, std::unique_ptr< GDigitizedData > ddata)
Integrates one digitized object into the named detector entry.
void merge(const GRunDataCollection &other)
Merges another run accumulator into this one.
auto get_events_processed() const -> int
Returns the total processed-event count stored in the header.
auto get_events_with_payload() const -> int
Returns the number of processed events that contributed payload.
Defines GRunDataCollection, the run-level aggregation of detector data.