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,
" ← ", 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 ?
" ✅" :
" ❌";
114 log->debug(
NORMAL,
" Touchable type is readout. Time cell comparison: ",
115 this->stepTimeAtElectronicsIndex.value_or(-1),
116 " ", that.stepTimeAtElectronicsIndex.value_or(-1),
120 typeComparison = this->trackId == that.trackId;
121 result = typeComparison ?
" ✅" :
" ❌";
122 log->debug(
NORMAL,
" Touchable type is flux. Track id comparison: ", this->trackId,
" ", that.trackId,
126 typeComparison = this->trackId == that.trackId;
127 result = typeComparison ?
" ✅" :
" ❌";
128 log->debug(
NORMAL,
" Touchable type is gPhotonDetector. Track id comparison: ",
129 this->trackId,
" ", that.trackId,
" result:", result);
132 typeComparison =
true;
133 log->debug(
NORMAL,
" Touchable type is dosimeter. No additional comparison needed, returning true ✅");
137 typeComparison = this->pid == that.pid;
138 result = typeComparison ?
" ✅" :
" ❌";
139 log->debug(
NORMAL,
" Touchable type is flux. Track id comparison: ", this->trackId,
" ", that.trackId,
144 typeComparison =
true;
146 " Touchable type is integral_counter. No additional comparison needed, returning true ✅");
149 return typeComparison;
157 key.reserve(gidentity.size() * 8 + 12);
158 for (
const auto& gid : gidentity) {
159 key += std::to_string(gid.getValue());
165 key += stepTimeAtElectronicsIndex ? std::to_string(*stepTimeAtElectronicsIndex) :
"unset";
168 case gPhotonDetector: key +=
't'; key += std::to_string(trackId);
break;
178 stream <<
" GTouchable: ";
181 if (gid.getName() !=
gtouchable.gidentity.back().getName()) { stream <<
", "; }
188 ", time cell index: " <<
190 ? std::to_string(*
gtouchable.stepTimeAtElectronicsIndex)
215 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.