Skip to content

Commit 9e6260a

Browse files
committed
reindenting
1 parent 2ae4337 commit 9e6260a

1 file changed

Lines changed: 87 additions & 49 deletions

File tree

gdata/gDataCollection.h

Lines changed: 87 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -16,61 +16,99 @@
1616
#include <vector>
1717

1818

19-
class GDataCollection {
19+
class GDataCollection
20+
{
2021
public:
21-
/**
22-
* \brief Constructs a GDataCollection.
23-
* \param logger Pointer to a GLogger instance.
24-
*/
25-
explicit GDataCollection(){}
22+
/**
23+
* \brief Constructs a GDataCollection.
24+
*/
25+
explicit GDataCollection() = default;
2626

27-
/**
28-
* \brief Destructor for GDataCollection.
29-
*
30-
* Smart pointers clean up automatically.
31-
*/
3227

33-
/**
34-
* \brief Adds true hit information data.
35-
* \param data Unique pointer to GTrueInfoData.
36-
*/
37-
void addTrueInfoData(std::unique_ptr<GTrueInfoData> data) {
38-
trueInfosData.push_back(std::move(data)); // taking ownership of the unique_ptr
39-
}
28+
/**
29+
* \brief Destructor for GDataCollection.
30+
*
31+
* Smart pointers clean up automatically.
32+
*/
4033

41-
/**
42-
* \brief Adds digitized hit data.
43-
* \param data Unique pointer to GDigitizedData.
44-
*/
45-
void addDigitizedData(std::unique_ptr<GDigitizedData> data) {
46-
digitizedData.push_back(std::move(data)); // taking ownership of the unique_ptr
47-
}
34+
/**
35+
* \brief Adds true hit information data.
36+
* \param data Unique pointer to GTrueInfoData.
37+
*/
38+
void addTrueInfoData(std::unique_ptr<GTrueInfoData> data) {
39+
trueInfosData.push_back(std::move(data)); // taking ownership of the unique_ptr
40+
}
4841

49-
/**
50-
* \brief Provides read-only access to the stored true hit data.
51-
*
52-
* Returns a constant reference to the internal vector of unique pointers
53-
* to GTrueInfoData objects. Ownership of the data remains with this class.
54-
* Callers may inspect the data via the pointers but must not modify or
55-
* take ownership of them.
56-
*
57-
* \return Const reference to the vector of unique_ptr<GTrueInfoData>.
58-
*/
59-
[[nodiscard]] inline const std::vector<std::unique_ptr<GTrueInfoData>>& getTrueInfoData() const { return trueInfosData; }
42+
// sum existing data
43+
void collectTrueInfosData(std::unique_ptr<GTrueInfoData> data) {
44+
// first event
45+
if (trueInfosData.empty()) {
46+
trueInfosData.push_back(std::move(data));
47+
}
48+
else {
49+
for (const auto& [varName, value] : data->getDoubleVariablesMap()) {
50+
trueInfosData.front()->accumulateVariable(varName, value);
51+
}
52+
for (const auto& [varName, value] : data->getStringVariablesMap()) {
53+
trueInfosData.front()->accumulateVariable(varName, value);
54+
}
55+
}
56+
}
6057

61-
/**
62-
* \brief Provides read-only access to the stored digitized hit data.
63-
*
64-
* Returns a constant reference to the internal vector of unique pointers
65-
* to GDigitizedData objects. Ownership of the data remains with this class.
66-
* Callers may read the data but must not modify or transfer ownership.
67-
*
68-
* \return Const reference to the vector of unique_ptr<GDigitizedData>.
69-
*/
70-
[[nodiscard]] inline const std::vector<std::unique_ptr<GDigitizedData>>& getDigitizedData() const { return digitizedData; }
58+
void collectDigitizedData(std::unique_ptr<GDigitizedData> data) {
59+
// first event
60+
if (digitizedData.empty()) {
61+
digitizedData.push_back(std::move(data));
62+
}
63+
else {
64+
// argument passed: 0: do not get SRO var
65+
for (const auto& [varName, value] : data->getIntObservablesMap(0)) {
66+
digitizedData.front()->accumulateVariable(varName, value);
67+
}
68+
for (const auto& [varName, value] : data->getDblObservablesMap(0)) {
69+
digitizedData.front()->accumulateVariable(varName, value);
70+
}
71+
}
72+
}
7173

72-
private:
73-
std::vector<std::unique_ptr<GTrueInfoData>> trueInfosData; ///< Vector of true hit data.
74-
std::vector<std::unique_ptr<GDigitizedData>> digitizedData; ///< Vector of digitized hit data.
7574

75+
/**
76+
* \brief Adds digitized hit data.
77+
* \param data Unique pointer to GDigitizedData.
78+
*/
79+
void addDigitizedData(std::unique_ptr<GDigitizedData> data) {
80+
digitizedData.push_back(std::move(data)); // taking ownership of the unique_ptr
81+
}
82+
83+
/**
84+
* \brief Provides read-only access to the stored true hit data.
85+
*
86+
* Returns a constant reference to the internal vector of unique pointers
87+
* to GTrueInfoData objects. Ownership of the data remains with this class.
88+
* Callers may inspect the data via the pointers but must not modify or
89+
* take ownership of them.
90+
*
91+
* \return Const reference to the vector of unique_ptr<GTrueInfoData>.
92+
*/
93+
[[nodiscard]] inline const std::vector<std::unique_ptr<GTrueInfoData>>& getTrueInfoData() const {
94+
return trueInfosData;
95+
}
96+
97+
/**
98+
* \brief Provides read-only access to the stored digitized hit data.
99+
*
100+
* Returns a constant reference to the internal vector of unique pointers
101+
* to GDigitizedData objects. Ownership of the data remains with this class.
102+
* Callers may read the data but must not modify or transfer ownership.
103+
*
104+
* \return Const reference to the vector of unique_ptr<GDigitizedData>.
105+
*/
106+
[[nodiscard]] inline const std::vector<std::unique_ptr<GDigitizedData>>& getDigitizedData() const {
107+
return digitizedData;
108+
}
109+
110+
private:
111+
// for event data, the array index is the hit index
112+
std::vector<std::unique_ptr<GTrueInfoData>> trueInfosData; ///< Vector of true data.
113+
std::vector<std::unique_ptr<GDigitizedData>> digitizedData; ///< Vector of digitized data.
76114
};

0 commit comments

Comments
 (0)