20#include "gdynamicDigitization/gdynamicdigitization_options.h"
23std::atomic<int> GDigitizedData::globalDigitizedDataCounter{0};
28 gidentity = ghit->
getGID();
33 std::map<std::string, int> filteredIntObservablesMap;
34 for (
const auto& [varName, value] : intObservablesMap) {
35 if (validVarName(varName, which)) { filteredIntObservablesMap[varName] = value; }
37 log->
info(2,
" getting ", which,
" from intObservablesMap.");
38 return filteredIntObservablesMap;
43 std::map<std::string, double> filteredDblObservablesMap;
44 for (
const auto& [varName, value] : doubleObservablesMap) {
45 if (validVarName(varName, which)) { filteredDblObservablesMap[varName] = value; }
47 log->
info(2,
" getting ", which,
" from doubleObservablesMap.");
48 return filteredDblObservablesMap;
51bool GDigitizedData::validVarName(
const std::string& varName,
int which) {
58 if (isSROVar) {
return false; }
61 else if (which == 1) {
62 if (!isSROVar) {
return false; }
71 log->
info(2,
"Including int variable ", vname,
" with value ", value);
72 intObservablesMap[vname] = value;
77 log->
info(2,
"Including double variable ", vname,
" with value ", value);
78 doubleObservablesMap[vname] = value;
83 if (intObservablesMap.find(vname) == intObservablesMap.end()) {
84 log->
info(2,
"Accumulating new int variable ", vname,
" with value ", value);
85 intObservablesMap[vname] = value;
88 log->
info(2,
"Accumulating int variable ", vname,
" with value ", value);
89 intObservablesMap[vname] += value;
95 if (doubleObservablesMap.find(vname) == doubleObservablesMap.end()) {
96 log->
info(2,
"Accumulating double variable ", vname,
" with value ", value);
97 doubleObservablesMap[vname] = value;
100 log->
info(2,
"Accumulating double variable ", vname,
" with value ", value);
101 doubleObservablesMap[vname] += value;
108 log->
info(2,
"Getting TIMEATELECTRONICS from intObservablesMap.");
114 if (intObservablesMap.find(varName) == intObservablesMap.end()) {
116 "variable name <" + varName +
"> not found in GDigitizedData::intObservablesMap");
118 return intObservablesMap[varName];
123 if (doubleObservablesMap.find(varName) == doubleObservablesMap.end()) {
125 "variable name <" + varName +
"> not found in GDigitizedData::doubleObservablesMap");
127 return doubleObservablesMap[varName];
132 std::string identifierString;
133 for (
size_t i = 0; i < gidentity.size() - 1; i++) {
134 identifierString += gidentity[i].getName() +
"->" + std::to_string(gidentity[i].getValue()) +
", ";
136 identifierString += gidentity.back().getName() +
"->" + std::to_string(gidentity.back().getValue());
137 return identifierString;
143 if (!data.intObservablesMap.empty()) {
144 os <<
", intObservables={";
146 for (
const auto& [name, value] : data.intObservablesMap) {
150 os << name <<
": " << value;
156 if (!data.doubleObservablesMap.empty()) {
157 os <<
", doubleObservables={";
159 for (
const auto& [name, value] : data.doubleObservablesMap) {
163 os << name <<
": " << value;
169 if (!data.arrayIntObservablesMap.empty()) {
170 os <<
", arrayIntObservables={";
171 bool firstMap =
true;
172 for (
const auto& [name, values] : data.arrayIntObservablesMap) {
177 bool firstVal =
true;
178 for (
const auto& value : values) {
191 if (!data.arrayDoubleObservablesMap.empty()) {
192 os <<
", arrayDoubleObservables={";
193 bool firstMap =
true;
194 for (
const auto& [name, values] : data.arrayDoubleObservablesMap) {
199 bool firstVal =
true;
200 for (
const auto& value : values) {
std::shared_ptr< GLogger > log
Stores digitized, electronics-level observables for one hit.
void accumulateVariable(const std::string &vname, int value)
Accumulates one integer observable into the current object.
int getIntObservable(const std::string &varName)
Returns one integer observable by key.
std::map< std::string, int > getIntObservablesMap(int which) const
Returns a filtered copy of the integer observables map.
int getTimeAtElectronics()
Returns the conventional timeAtElectronics integer observable when present.
void includeVariable(const std::string &vname, int value)
Stores or overwrites one integer observable for this hit.
std::map< std::string, double > getDblObservablesMap(int which) const
Returns a filtered copy of the floating-point observables map.
GDigitizedData(const std::shared_ptr< GOptions > &gopts, const GHit *ghit)
Constructs the object and copies the hit identity from the source hit.
double getDblObservable(const std::string &varName)
Returns one floating-point observable by key.
std::string getIdentityString() const
Builds a readable identity string from the stored hit identifiers.
std::vector< GIdentifier > getGID() const
void info(int level, Args &&... args) const
void error(int exit_code, Args &&... args) const
std::ostream & operator<<(std::ostream &os, const GDigitizedData &data)
Container for digitized observables associated with one simulated hit.
constexpr const char * GDIGITIZED_DATA_LOGGER
Logger domain name used by GDigitizedData.
Shared constants, schema keys, and error codes for the GData module.
constexpr const char * TIMEATELECTRONICS
Electronics-stage time or TDC proxy.
constexpr const char * CRATESTRINGID
Electronics crate identifier.
constexpr const char * CHANNELSTRINGID
Channel index within the slot or module.
constexpr int ERR_VARIABLENOTFOUND
Requested observable key is missing.
constexpr const char * SLOTSTRINGID
Slot index within the crate.
constexpr const char * CHARGEATELECTRONICS
Electronics-stage charge or ADC proxy.
constexpr int TIMEATELECTRONICSNOTDEFINED
Sentinel value returned when timeAtElectronics is requested but not present.