10std::atomic<int> GTouchable::globalGTouchableCounter{0};
17 const std::string& digitization,
18 const std::string& gidentityString,
22 stepTimeAtElectronicsIndex(
24 detectorDimensions(dimensions) {
37 for (
auto& gid : identity) {
42 const std::string& idName = identifier[0];
43 int idValue = std::stoi(identifier[1]);
45 gidentity.emplace_back(idName, idValue);
53 const std::string& digitization,
54 const std::string& gidentityString,
55 const std::vector<double>& dimensions) :
GBase(logger),
58 stepTimeAtElectronicsIndex(
60 detectorDimensions(dimensions) {
73 for (
auto& gid : identity) {
78 const std::string& idName = identifier[0];
79 int idValue = std::stoi(identifier[1]);
81 gidentity.emplace_back(idName, idValue);
90 if (this->gidentity.size() != that.gidentity.size()) {
98 for (
size_t i = 0; i < this->gidentity.size(); ++i) {
99 bool equal = (this->gidentity[i].getValue() == that.gidentity[i].getValue());
100 std::string comparisonResult = equal ?
" ✅" :
" ❌";
101 log->
debug(
NORMAL,
" ← ", this->gidentity[i],
" → ", that.gidentity[i], comparisonResult);
102 if (!equal) {
return false; }
105 bool typeComparison =
false;
109 switch (this->gType) {
111 typeComparison = this->stepTimeAtElectronicsIndex == that.stepTimeAtElectronicsIndex;
112 result = typeComparison ?
" ✅" :
" ❌";
113 log->
debug(
NORMAL,
" Touchable type is readout. Time cell comparison: ", this->stepTimeAtElectronicsIndex,
114 " ", that.stepTimeAtElectronicsIndex,
118 typeComparison = this->trackId == that.trackId;
119 result = typeComparison ?
" ✅" :
" ❌";
120 log->
debug(
NORMAL,
" Touchable type is flux. Track id comparison: ", this->trackId,
" ", that.trackId,
124 typeComparison = this->trackId == that.trackId;
125 result = typeComparison ?
" ✅" :
" ❌";
126 log->
debug(
NORMAL,
" Touchable type is dosimeter. Track id comparison: ", this->trackId,
" ", that.trackId,
130 typeComparison =
true;
131 log->
debug(
NORMAL,
" Touchable type is particleCounter. No additional comparison needed, returning true ✅");
134 return typeComparison;
139 stream <<
" GTouchable: ";
141 stream <<
KRED << gid;
142 if (gid.getName() !=
gtouchable.gidentity.back().getName()) { stream <<
", "; }
143 else { stream <<
RST; }
148 stream <<
KGRN <<
" (readout), " <<
RST <<
" multiplier: " <<
gtouchable.eMultiplier <<
", time cell index: " <<
155 stream <<
KGRN <<
" (dosimeter), " <<
RST <<
" g4 track id: " <<
gtouchable.trackId;
158 stream <<
KGRN <<
" (particleCounter), " <<
RST <<
" g4 track id: " <<
gtouchable.trackId;
167 stream << gidentifier.idName <<
": " << gidentifier.idValue;
std::shared_ptr< GLogger > log
void debug(debug_type type, Args &&... args) const
Represents a touchable sensitive detector element used as a hit-collection discriminator.
GTouchable(const GTouchable &)=default
bool operator==(const GTouchable >ouchable) const
Compares two GTouchable instances using the module comparison semantics.
std::string getIdentityString() const
Builds a human-readable identity string from the stored identifiers.
Conventions and constants used by the gtouchable module.
#define GTOUCHABLEUNSETTIMEINDEX
Sentinel value for an unset electronics time-cell index.
#define FLUXNAME
Digitization type name for flux-like detectors.
#define DOSIMETERNAME
Digitization type name for dosimeters.
#define COUNTERNAME
Digitization type name for simple particle counters.
std::ostream & operator<<(std::ostream &stream, const GTouchable >ouchable)
@ flux
Flux-like discrimination using track id.
@ particleCounter
Identity vector only; no additional discriminating factor.
@ readout
Electronic readout with time-window discrimination (time-cell index).
@ dosimeter
Radiation digitization; discrimination using track id.
constexpr const char * TOUCHABLE_LOGGER
Logger name used by the gtouchable module.
const char * to_string(GTouchableType t)
Converts a GTouchableType value to a stable string for logging.
vector< string > getStringVectorFromStringWithDelimiter(const string &input, const string &x)
A single (name,value) identifier element used to build a touchable identity vector.