14#include "gdynamicDigitization/gdynamicdigitization_options.h"
16std::atomic<int> GDigitizedData::globalDigitizedDataCounter{0};
19 gidentity = ghit->getGID();
23 std::map<std::string, int> filteredIntObservablesMap;
24 for (
const auto& [varName, value] : intObservablesMap) {
if (validVarName(varName, which)) { filteredIntObservablesMap[varName] = value; } }
25 log->info(2,
" getting ", which,
" from intObservablesMap.");
26 return filteredIntObservablesMap;
30 std::map<std::string, double> filteredDblObservablesMap;
31 for (
const auto& [varName, value] : doubleObservablesMap) {
if (validVarName(varName, which)) { filteredDblObservablesMap[varName] = value; } }
32 log->info(2,
" getting ", which,
" from doubleObservablesMap.");
33 return filteredDblObservablesMap;
36bool GDigitizedData::validVarName(
const std::string& varName,
int which) {
39 if (which == 0) {
if (isSROVar) {
return false; } }
40 else if (which == 1) {
if (!isSROVar) {
return false; } }
45 log->info(2,
"Including int variable ", vname,
" with value ", value);
46 intObservablesMap[vname] = value;
50 log->info(2,
"double variable ", vname,
" with value ", value);
51 doubleObservablesMap[vname] = value;
56 log->info(2,
"Getting TIMEATELECTRONICS from intObservablesMap.");
61 if (intObservablesMap.find(varName) == intObservablesMap.end()) {
62 log->error(
ERR_VARIABLENOTFOUND,
"variable name <" + varName +
"> not found in GDigitizedData::intObservablesMap");
64 return intObservablesMap[varName];
68 if (doubleObservablesMap.find(varName) == doubleObservablesMap.end()) {
69 log->error(
ERR_VARIABLENOTFOUND,
"variable name <" + varName +
"> not found in GDigitizedData::doubleObservablesMap");
71 return doubleObservablesMap[varName];
75 std::string identifierString;
76 for (
size_t i = 0; i < gidentity.size() - 1; i++) { identifierString += gidentity[i].getName() +
"->" + std::to_string(gidentity[i].getValue()) +
", "; }
77 identifierString += gidentity.back().getName() +
"->" + std::to_string(gidentity.back().getValue());
78 return identifierString;
int getIntObservable(const std::string &varName)
std::map< std::string, int > getIntObservablesMap(int which) const
Returns the filtered map of integer observables.
int getTimeAtElectronics()
Gets the time at electronics.
void includeVariable(const std::string &vname, int value)
std::map< std::string, double > getDblObservablesMap(int which) const
Returns the filtered map of double observables.
GDigitizedData(const std::shared_ptr< GOptions > &gopts, const GHit *ghit)
Constructs a GDigitizedData object from a GHit.
double getDblObservable(const std::string &varName)
std::string getIdentityString() const
Returns a string representation of the hit identity.
constexpr const char * GDIGITIZED_DATA_LOGGER
Defines constants and exit codes for the GData library.
constexpr const char * TIMEATELECTRONICS
Identifier for time at electronics.
constexpr const char * CRATESTRINGID
Identifier for crate.
constexpr const char * CHANNELSTRINGID
Identifier for channel.
constexpr int ERR_VARIABLENOTFOUND
Exit code when a variable is not found.
constexpr const char * SLOTSTRINGID
Identifier for slot.
constexpr int TIMEATELECTRONICSNOTDEFINED
Default value for undefined time at electronics.
constexpr const char * CHARGEATELECTRONICS
Identifier for charge at electronics.