gdata
Loading...
Searching...
No Matches
gRunDataCollection.cc
Go to the documentation of this file.
1
9// See header for API docs.
10
11#include "gRunDataCollection.h"
12
13void GRunDataCollection::collectDetectorTrueInfoData(const std::string& sdName,
14 const std::unique_ptr<GTrueInfoData>& data) {
15 // Ensure the detector entry exists.
16 if (gdataCollectionMap.find(sdName) == gdataCollectionMap.end()) {
17 gdataCollectionMap[sdName] = std::make_unique<GDataCollection>();
18 }
19
20 // Integrate true-hit data into the run-level accumulator for this detector.
21 gdataCollectionMap[sdName]->collectTrueInfosData(std::make_unique<GTrueInfoData>(*data));
22 log->info(2, "GRunDataCollection: collected detector TrueInfoData for ", sdName);
23}
24
25void GRunDataCollection::collectDetectorDigitizedData(const std::string& sdName,
26 const std::unique_ptr<GDigitizedData>& data) {
27 // Ensure the detector entry exists, same as for truth data.
28 if (gdataCollectionMap.find(sdName) == gdataCollectionMap.end()) {
29 gdataCollectionMap[sdName] = std::make_unique<GDataCollection>();
30 }
31
32 // Integrate digitized-hit data into the run-level accumulator for this detector.
33 gdataCollectionMap[sdName]->collectDigitizedData(std::make_unique<GDigitizedData>(*data));
34 log->info(2, "GRunDataCollection: collected detector DigitizedData for ", sdName);
35}
36
37void GRunDataCollection::collect_event_data_collection(const std::shared_ptr<GEventDataCollection> edc) {
38 // Retrieve the detector map for the event: sdName -> per-detector collection.
39 auto& dcm = edc->getDataCollectionMap();
40
41 // Loop over sensitive detectors present in this event.
42 for (auto& [sdname, ptr] : dcm) {
43 if (!ptr) continue;
44
45 // True-hit entries for this detector in this event.
46 auto& true_infos_data = ptr->getTrueInfoData();
47 for (auto& true_info_hit : true_infos_data) {
48 collectDetectorTrueInfoData(sdname, true_info_hit);
49 }
50
51 // Digitized-hit entries for this detector in this event.
52 auto& digitized_data = ptr->getDigitizedData();
53 for (auto& digitized_data_hit : digitized_data) {
54 collectDetectorDigitizedData(sdname, digitized_data_hit);
55 }
56 }
57}
std::shared_ptr< GLogger > log
void info(int level, Args &&... args) const
void collect_event_data_collection(const std::shared_ptr< GEventDataCollection > edc)
Integrate one event data collection into this run summary.
Defines GRunDataCollection, run-level aggregation of detector data.