20#include <gemc/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 %1 from intObservablesMap.", which);
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 %1 from doubleObservablesMap.", which);
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 %1 with value %2", vname, value);
72 intObservablesMap[vname] = value;
77 log->info(2,
"Including double variable %1 with value %2", vname, value);
78 doubleObservablesMap[vname] = value;
82 log->info(2,
"Including transient variable %1 with value %2", vname, value);
83 transientVariablesMap[vname] = value;
87 return transientVariablesMap.contains(vname);
91 return transientVariablesMap.at(vname);
96 if (!intObservablesMap.contains(vname)) {
97 log->info(2,
"Accumulating new int variable %1 with value %2", vname, value);
98 intObservablesMap[vname] = value;
101 log->info(2,
"Accumulating int variable %1 with value %2", vname, value);
102 intObservablesMap[vname] += value;
108 if (!doubleObservablesMap.contains(vname)) {
109 log->info(2,
"Accumulating double variable %1 with value %2", vname, value);
110 doubleObservablesMap[vname] = value;
113 log->info(2,
"Accumulating double variable %1 with value %2", vname, value);
114 doubleObservablesMap[vname] += value;
120 if (time == intObservablesMap.end()) {
return std::nullopt; }
121 log->info(2,
"Getting TIMEATELECTRONICS from intObservablesMap.");
127 if (!intObservablesMap.contains(varName)) {
129 ERR_VARIABLENOTFOUND,
"variable name <%1> not found in GDigitizedData::intObservablesMap", varName);
131 return intObservablesMap[varName];
136 if (!doubleObservablesMap.contains(varName)) {
141 return doubleObservablesMap[varName];
149 os <<
"GDigitizedData{identity=\"" << idString <<
"\"";
151 if (!data.intObservablesMap.empty()) {
152 os <<
", intObservables={";
154 for (
const auto& [name, value] : data.intObservablesMap) {
158 os << name <<
": " << value;
164 if (!data.doubleObservablesMap.empty()) {
165 os <<
", doubleObservables={";
167 for (
const auto& [name, value] : data.doubleObservablesMap) {
171 os << name <<
": " << value;
177 if (!data.arrayIntObservablesMap.empty()) {
178 os <<
", arrayIntObservables={";
179 bool firstMap =
true;
180 for (
const auto& [name, values] : data.arrayIntObservablesMap) {
185 bool firstVal =
true;
186 for (
const auto& value : values) {
199 if (!data.arrayDoubleObservablesMap.empty()) {
200 os <<
", arrayDoubleObservables={";
201 bool firstMap =
true;
202 for (
const auto& [name, values] : data.arrayDoubleObservablesMap) {
207 bool firstVal =
true;
208 for (
const auto& value : values) {
GBase(const std::shared_ptr< GOptions > &gopt, std::string logger_name="")
std::shared_ptr< GLogger > log
void accumulateVariable(const std::string &vname, int value)
Accumulates one integer observable into the current object.
bool hasTransientVariable(const std::string &vname) const
Returns whether a transient floating-point value is present.
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.
void includeVariable(const std::string &vname, int value)
Stores or overwrites one integer observable for this hit.
std::optional< int > getTimeAtElectronics() const
Returns the conventional timeAtElectronics integer observable when present.
std::map< std::string, double > getDblObservablesMap(int which) const
Returns a filtered copy of the floating-point observables map.
double getTransientVariable(const std::string &vname) const
Returns a transient floating-point value by key.
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.
void includeTransientVariable(const std::string &vname, double value)
Stores a non-published floating-point value for post-digitization decisions.
std::vector< GIdentifier > getGID() 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)