14 const std::string& digitization,
15 const std::string& gidentityString,
16 const std::vector<double>& dimensions,
22 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,
61 detectorDimensions(dimensions),
76 for (
auto& gid : identity) {
81 const std::string& idName = identifier[0];
82 int idValue = std::stoi(identifier[1]);
84 gidentity.emplace_back(idName, idValue);
93 if (this->gidentity.size() != that.gidentity.size()) {
94 log->debug(
NORMAL,
"Touchable sizes are different");
100 log->debug(
NORMAL,
" + Touchable comparison: ");
101 for (
size_t i = 0; i < this->gidentity.size(); ++i) {
102 bool equal = ( this->gidentity[i].getValue() == that.gidentity[i].getValue() );
103 std::string comparisonResult = equal ?
" ✅" :
" ❌";
104 log->debug(
NORMAL,
" ← ", this->gidentity[i],
" → ", that.gidentity[i], comparisonResult);
105 if (!equal) {
return false; }
108 bool typeComparison =
false;
112 switch (this->gType) {
114 typeComparison = this->stepTimeAtElectronicsIndex == that.stepTimeAtElectronicsIndex;
115 result = typeComparison ?
" ✅" :
" ❌";
116 log->debug(
NORMAL,
" Touchable type is readout. Time cell comparison: ",
117 this->stepTimeAtElectronicsIndex,
118 " ", that.stepTimeAtElectronicsIndex,
122 typeComparison = this->trackId == that.trackId;
123 result = typeComparison ?
" ✅" :
" ❌";
124 log->debug(
NORMAL,
" Touchable type is flux. Track id comparison: ", this->trackId,
" ", that.trackId,
128 typeComparison = this->trackId == that.trackId;
129 result = typeComparison ?
" ✅" :
" ❌";
130 log->debug(
NORMAL,
" Touchable type is gPhotonDetector. Track id comparison: ",
131 this->trackId,
" ", that.trackId,
" result:", result);
134 typeComparison =
true;
135 log->debug(
NORMAL,
" Touchable type is dosimeter. No additional comparison needed, returning true ✅");
139 typeComparison = this->pid == that.pid;
140 result = typeComparison ?
" ✅" :
" ❌";
141 log->debug(
NORMAL,
" Touchable type is flux. Track id comparison: ", this->trackId,
" ", that.trackId,
146 typeComparison =
true;
148 " Touchable type is integral_counter. No additional comparison needed, returning true ✅");
151 return typeComparison;
159 key.reserve(gidentity.size() * 8 + 12);
160 for (
const auto& gid : gidentity) {
161 key += std::to_string(gid.getValue());
165 case readout: key +=
'r'; key += std::to_string(stepTimeAtElectronicsIndex);
break;
167 case gPhotonDetector: key +=
't'; key += std::to_string(trackId);
break;
177 stream <<
" GTouchable: ";
179 stream <<
KRED << gid;
180 if (gid.getName() !=
gtouchable.gidentity.back().getName()) { stream <<
", "; }
181 else { stream <<
RST; }
186 stream <<
KGRN <<
" (readout), " <<
RST <<
" multiplier: " <<
gtouchable.eMultiplier <<
187 ", time cell index: " <<
194 stream <<
KGRN <<
" (gPhotonDetector), " <<
RST <<
" g4 track id: " <<
gtouchable.trackId;
197 stream <<
KGRN <<
" (dosimeter), " <<
RST;
200 stream <<
KGRN <<
" (particle_counter), " <<
RST <<
" particle id: " <<
gtouchable.pid;
203 stream <<
KGRN <<
" (integral_counter), " <<
RST;
212 stream << gidentifier.idName <<
": " << gidentifier.idValue;
GBase(const std::shared_ptr< GOptions > &gopt, std::string logger_name="")
std::shared_ptr< GLogger > log
GTouchable(const GTouchable &)=default
bool operator==(const GTouchable >ouchable) const
Compares two GTouchable instances using the module comparison semantics.
std::string cellKey() const
Builds a compact key identifying the hit cell of this touchable.
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.
#define GPHOTON_DETECTORNAME
Digitization type name for optical-photon flux detectors.
std::ostream & operator<<(std::ostream &stream, const GTouchable >ouchable)
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)
GIdentifier(const std::string &n, int v)
Constructs a GIdentifier.