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];
135 os <<
"GDigitizedData{identity=\"" << idString <<
"\"";
137 if (!data.intObservablesMap.empty()) {
138 os <<
", intObservables={";
140 for (
const auto& [name, value] : data.intObservablesMap) {
144 os << name <<
": " << value;
150 if (!data.doubleObservablesMap.empty()) {
151 os <<
", doubleObservables={";
153 for (
const auto& [name, value] : data.doubleObservablesMap) {
157 os << name <<
": " << value;
163 if (!data.arrayIntObservablesMap.empty()) {
164 os <<
", arrayIntObservables={";
165 bool firstMap =
true;
166 for (
const auto& [name, values] : data.arrayIntObservablesMap) {
171 bool firstVal =
true;
172 for (
const auto& value : values) {
185 if (!data.arrayDoubleObservablesMap.empty()) {
186 os <<
", arrayDoubleObservables={";
187 bool firstMap =
true;
188 for (
const auto& [name, values] : data.arrayDoubleObservablesMap) {
193 bool firstVal =
true;
194 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::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.
std::string getIdentityString(std::vector< GIdentifier > gidentity)
constexpr int TIMEATELECTRONICSNOTDEFINED
Sentinel value returned when timeAtElectronics is requested but not present.