fix getdacindex and getdacname for normal detectors to throw if random index that doesnt fit to the detector
Build on RHEL9 docker image / build (push) Successful in 3m32s
Build on RHEL8 docker image / build (push) Successful in 4m48s

This commit is contained in:
2026-03-19 17:08:25 +01:00
parent 601c23f1af
commit 01d90b8ba2
+12 -1
View File
@@ -2400,7 +2400,13 @@ defs::dacIndex Detector::getDacIndex(const std::string &name) const {
throw RuntimeError("Dac name not found");
return static_cast<defs::dacIndex>(it - names.begin());
}
return StringTo<defs::dacIndex>(name);
auto retval = StringTo<defs::dacIndex>(name);
auto list = getDacList();
if (std::find(list.begin(), list.end(), retval) == list.end()) {
throw RuntimeError("Dac name not found in dac list. Use 'daclist' to "
"get the list of dac names for this detector.");
}
return retval;
}
void Detector::setDacName(const defs::dacIndex i, const std::string &name) {
@@ -2410,6 +2416,11 @@ void Detector::setDacName(const defs::dacIndex i, const std::string &name) {
std::string Detector::getDacName(const defs::dacIndex i) const {
if (pimpl->isChipTestBoard())
return pimpl->getCtbDacName(i);
auto list = getDacList();
if (std::find(list.begin(), list.end(), i) == list.end()) {
throw RuntimeError("Dac index not found in dac list. Use 'daclist' to "
"get the list of dac indices for this detector.");
}
return ToString(i);
}