14 const std::string& digitization,
15 const std::string& gidentityString,
16 const std::vector<double>& dimensions,
21 detectorDimensions(dimensions),
36 for (
auto& gid : identity) {
41 const std::string& idName = identifier[0];
42 int idValue = std::stoi(identifier[1]);
44 gidentity.emplace_back(idName, idValue);
52 const std::string& digitization,
53 const std::string& gidentityString,
54 const std::vector<double>& dimensions,
59 detectorDimensions(dimensions),
74 for (
auto& gid : identity) {
79 const std::string& idName = identifier[0];
80 int idValue = std::stoi(identifier[1]);
82 gidentity.emplace_back(idName, idValue);
91 if (this->gidentity.size() != that.gidentity.size()) {
92 log->debug(
NORMAL,
"Touchable sizes are different");
98 log->debug(
NORMAL,
" + Touchable comparison: ");
99 for (
size_t i = 0; i < this->gidentity.size(); ++i) {
100 bool equal = ( this->gidentity[i].getValue() == that.gidentity[i].getValue() );
101 std::string comparisonResult = equal ?
" ✅" :
" ❌";
102 log->debug(
NORMAL,
" ← %1 → %2%3", this->gidentity[i], that.gidentity[i], comparisonResult);
103 if (!equal) {
return false; }
106 bool typeComparison =
false;
110 switch (this->gType) {
112 typeComparison = this->stepTimeAtElectronicsIndex == that.stepTimeAtElectronicsIndex;
113 result = typeComparison ?
" ✅" :
" ❌";
115 NORMAL,
" Touchable type is readout. Time cell comparison: %1 %2 result:%3",
116 this->stepTimeAtElectronicsIndex.value_or(-1), that.stepTimeAtElectronicsIndex.value_or(-1),
120 typeComparison = this->trackId == that.trackId;
121 result = typeComparison ?
" ✅" :
" ❌";
123 NORMAL,
" Touchable type is flux. Track id comparison: %1 %2 result:%3", this->trackId,
124 that.trackId, result);
127 typeComparison = this->trackId == that.trackId;
128 result = typeComparison ?
" ✅" :
" ❌";
130 NORMAL,
" Touchable type is gPhotonDetector. Track id comparison: %1 %2 result:%3",
131 this->trackId, that.trackId, result);
134 typeComparison =
true;
136 NORMAL,
" Touchable type is dosimeter. No additional comparison needed, returning true ✅");
140 typeComparison = this->pid == that.pid;
141 result = typeComparison ?
" ✅" :
" ❌";
143 NORMAL,
" Touchable type is flux. Track id comparison: %1 %2 result:%3", this->trackId,
144 that.trackId, result);
148 typeComparison =
true;
151 " Touchable type is integral_counter. No additional comparison needed, returning true ✅");
154 return typeComparison;
162 key.reserve(gidentity.size() * 8 + 12);
163 for (
const auto& gid : gidentity) {
164 key += std::to_string(gid.getValue());
170 key += stepTimeAtElectronicsIndex ? std::to_string(*stepTimeAtElectronicsIndex) :
"unset";
173 case gPhotonDetector: key +=
't'; key += std::to_string(trackId);
break;
183 stream <<
" GTouchable: ";
186 if (gid.getName() !=
gtouchable.gidentity.back().getName()) { stream <<
", "; }
193 ", time cell index: " <<
195 ? std::to_string(*
gtouchable.stepTimeAtElectronicsIndex)
220 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.
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.
constexpr char FLUXNAME[]
Digitization type name for flux-like detectors.
constexpr char COUNTERNAME[]
Digitization type name for simple particle counters.
constexpr char GPHOTON_DETECTORNAME[]
Digitization type name for optical-photon flux detectors.
constexpr char DOSIMETERNAME[]
Digitization type name for dosimeters.
vector< string > getStringVectorFromStringWithDelimiter(const string &input, const string &x)
GIdentifier(const std::string &n, int v)
Constructs a GIdentifier.