Commit fc91dd56 authored by Danny Hindson's avatar Danny Hindson
Browse files

Handle case where detector doesn't have a workspace index

The unit tests SetCrystalLocationTest, LoadEventNexusTest were failing due to
some detectors in the input nexus file not having a corresponding workspace
index. This showed up as the pixelID_to_wi_vector vector having
std::numeric_limits<size_t>::max() as the wi value
I've added check that wi<numEventLists before trying to retrieve the spectrum
for wi which is the same check that's done elsewhere in ProcessBankData.cpp

If the file BSS_11841_event.nxs had been loaded with compression on
this would have caused a crash even before my fix to the sort order
parent 51203621
......@@ -207,18 +207,21 @@ void ProcessBankData::run() { // override {
//------------ Compress Events (or set sort order) ------------------
// Do it on all the detector IDs we touched
const size_t numEventLists = outputWS.getNumberHistograms();
for (detid_t pixID = m_min_id; pixID <= m_max_id; ++pixID) {
if (usedDetIds[pixID - m_min_id]) {
// Find the the workspace index corresponding to that pixel ID
size_t wi = getWorkspaceIndexFromPixelID(pixID);
auto &el = outputWS.getSpectrum(wi);
if (compress)
el.compressEvents(alg->compressTolerance, &el);
else {
if (pulsetimesincreasing)
el.setSortOrder(DataObjects::PULSETIME_SORT);
else
el.setSortOrder(DataObjects::UNSORTED);
if (wi < numEventLists) {
auto &el = outputWS.getSpectrum(wi);
if (compress)
el.compressEvents(alg->compressTolerance, &el);
else {
if (pulsetimesincreasing)
el.setSortOrder(DataObjects::PULSETIME_SORT);
else
el.setSortOrder(DataObjects::UNSORTED);
}
}
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment