diff --git a/examples/badchannel.txt b/examples/badchannel.txt new file mode 100644 index 000000000..1de3c6eb6 --- /dev/null +++ b/examples/badchannel.txt @@ -0,0 +1,6 @@ +0 +10, 30 +40:45 50:52 +1279 +# all bad channels are applied for all counters in deector + diff --git a/slsDetectorSoftware/src/DetectorImpl.cpp b/slsDetectorSoftware/src/DetectorImpl.cpp index 3fd077cd8..bfc371e9e 100644 --- a/slsDetectorSoftware/src/DetectorImpl.cpp +++ b/slsDetectorSoftware/src/DetectorImpl.cpp @@ -1794,20 +1794,23 @@ void DetectorImpl::setBadChannels(const std::string &fname, Positions pos) { " out of bounds."); } int ch = badchannel % nchan; - int imod = badchannel / nchan; - if (imod >= (int)modules.size()) { + size_t imod = badchannel / nchan; + if (imod >= modules.size()) { throw RuntimeError("Invalid bad channel list. " + std::to_string(badchannel) + " out of bounds."); } - - if ((int)badchannels.size() != imod + 1) { + if (badchannels.size() != imod + 1) { badchannels.push_back(std::vector{}); } badchannels[imod].push_back(ch); } - for (int imod = 0; imod != (int)modules.size(); ++imod) { - Parallel(&Module::setBadChannels, {imod}, badchannels[imod]); + for (size_t imod = 0; imod != modules.size(); ++imod) { + // add empty vector if no bad channels in this module + if (badchannels.size() != imod + 1) { + badchannels.push_back(std::vector{}); + } + Parallel(&Module::setBadChannels, {static_cast(imod)}, badchannels[imod]); } } else if (pos.size() != 1) {