20#include "gdynamicDigitization/gdynamicdigitization_options.h"
27std::atomic<int> GDigitizedData::globalDigitizedDataCounter{0};
37 gidentity = ghit->
getGID();
45 std::map<std::string, int> filteredIntObservablesMap;
46 for (
const auto& [varName, value] : intObservablesMap) {
47 if (validVarName(varName, which)) { filteredIntObservablesMap[varName] = value; }
49 log->
info(2,
" getting ", which,
" from intObservablesMap.");
50 return filteredIntObservablesMap;
57 std::map<std::string, double> filteredDblObservablesMap;
58 for (
const auto& [varName, value] : doubleObservablesMap) {
59 if (validVarName(varName, which)) { filteredDblObservablesMap[varName] = value; }
61 log->
info(2,
" getting ", which,
" from doubleObservablesMap.");
62 return filteredDblObservablesMap;
66bool GDigitizedData::validVarName(
const std::string& varName,
int which) {
76 if (isSROVar) {
return false; }
78 else if (which == 1) {
80 if (!isSROVar) {
return false; }
88 log->
info(2,
"Including int variable ", vname,
" with value ", value);
89 intObservablesMap[vname] = value;
94 log->
info(2,
"Including double variable ", vname,
" with value ", value);
95 doubleObservablesMap[vname] = value;
100 if (intObservablesMap.find(vname) == intObservablesMap.end()) {
101 log->
info(2,
"Accumulating new int variable ", vname,
" with value ", value);
102 intObservablesMap[vname] = value;
105 log->
info(2,
"Accumulating int variable ", vname,
" with value ", value);
106 intObservablesMap[vname] += value;
112 if (doubleObservablesMap.find(vname) == doubleObservablesMap.end()) {
113 log->
info(2,
"Accumulating double variable ", vname,
" with value ", value);
114 doubleObservablesMap[vname] = value;
117 log->
info(2,
"Accumulating double variable ", vname,
" with value ", value);
118 doubleObservablesMap[vname] += value;
125 log->
info(2,
"Getting TIMEATELECTRONICS from intObservablesMap.");
131 if (intObservablesMap.find(varName) == intObservablesMap.end()) {
133 "variable name <" + varName +
"> not found in GDigitizedData::intObservablesMap");
135 return intObservablesMap[varName];
140 if (doubleObservablesMap.find(varName) == doubleObservablesMap.end()) {
142 "variable name <" + varName +
"> not found in GDigitizedData::doubleObservablesMap");
144 return doubleObservablesMap[varName];
149 std::string identifierString;
150 for (
size_t i = 0; i < gidentity.size() - 1; i++) {
151 identifierString += gidentity[i].getName() +
"->" + std::to_string(gidentity[i].getValue()) +
", ";
153 identifierString += gidentity.back().getName() +
"->" + std::to_string(gidentity.back().getValue());
154 return identifierString;
std::shared_ptr< GLogger > log
void accumulateVariable(const std::string &vname, int value)
Accumulate an integer observable (run-level integration).
int getIntObservable(const std::string &varName)
Retrieve one integer observable by name.
std::map< std::string, int > getIntObservablesMap(int which) const
Return a filtered copy of the integer observables map.
int getTimeAtElectronics()
Convenience accessor for TIMEATELECTRONICS.
void includeVariable(const std::string &vname, int value)
Store/overwrite an integer observable for this hit (event-level).
std::map< std::string, double > getDblObservablesMap(int which) const
Return a filtered copy of the double observables map.
GDigitizedData(const std::shared_ptr< GOptions > &gopts, const GHit *ghit)
Construct digitized data by copying identity from a hit.
double getDblObservable(const std::string &varName)
Retrieve one double observable by name.
std::string getIdentityString() const
Return a human-readable identity string for debugging and labeling.
std::vector< GIdentifier > getGID() const
void info(int level, Args &&... args) const
void error(int exit_code, Args &&... args) const
constexpr const char * GDIGITIZED_DATA_LOGGER
Logger domain name used by GDigitizedData (controls verbosity/category in GLogger).
Shared constants and error codes for the GData library.
constexpr const char * TIMEATELECTRONICS
Time (or TDC proxy) at electronics stage.
constexpr const char * CRATESTRINGID
Electronics crate index.
constexpr const char * CHANNELSTRINGID
Channel index within a slot/module.
constexpr int ERR_VARIABLENOTFOUND
Requested observable key is missing from an observables map.
constexpr const char * SLOTSTRINGID
Slot index within a crate (module position).
constexpr int TIMEATELECTRONICSNOTDEFINED
Sentinel value returned when TIMEATELECTRONICS is requested but not present.
constexpr const char * CHARGEATELECTRONICS
Charge (or ADC-integrated proxy) at electronics stage.