mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-19 18:40:01 +02:00
badchannel segfault for multi module (#620)
* badchannels segfaults when there are no badchannels for next modules, fixed * added example badchannels * refactoring casting
This commit is contained in:
parent
3682644e15
commit
946e6aa817
6
examples/badchannel.txt
Normal file
6
examples/badchannel.txt
Normal file
@ -0,0 +1,6 @@
|
||||
0
|
||||
10, 30
|
||||
40:45 50:52
|
||||
1279
|
||||
# all bad channels are applied for all counters in deector
|
||||
|
@ -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<int>{});
|
||||
}
|
||||
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<int>{});
|
||||
}
|
||||
Parallel(&Module::setBadChannels, {static_cast<int>(imod)}, badchannels[imod]);
|
||||
}
|
||||
|
||||
} else if (pos.size() != 1) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user