From 01d90b8ba2b3990f8889d446913f558a3d9ea090 Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Thu, 19 Mar 2026 17:08:17 +0100 Subject: [PATCH] fix getdacindex and getdacname for normal detectors to throw if random index that doesnt fit to the detector --- slsDetectorSoftware/src/Detector.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/slsDetectorSoftware/src/Detector.cpp b/slsDetectorSoftware/src/Detector.cpp index bcdce87ca..089e2e7b0 100644 --- a/slsDetectorSoftware/src/Detector.cpp +++ b/slsDetectorSoftware/src/Detector.cpp @@ -2400,7 +2400,13 @@ defs::dacIndex Detector::getDacIndex(const std::string &name) const { throw RuntimeError("Dac name not found"); return static_cast(it - names.begin()); } - return StringTo(name); + auto retval = StringTo(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); }