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

Fix problem with sorting of events

The LoadEventNexus algorithm is run without compression and the events
in the Nexus file are not already sorted by pulse time, the algorithm
is incorrectly labelling them as sorted by pulse time. This change fixes
the problem by always looping through the "used" detectors even if
loading without compression
This problem was causing FilterByTime to incorrectly slice up an event
file by time. A lot of events were assigned to the last second of a run
when slicing by time
parent babf76af
......@@ -116,10 +116,9 @@ void ProcessBankData::run() { // override {
// Will we need to compress?
const bool compress = (alg->compressTolerance >= 0);
// Which detector IDs were touched? - only matters if compress is on
// Which detector IDs were touched?
std::vector<bool> usedDetIds;
if (compress)
usedDetIds.assign(m_max_id - m_min_id + 1, false);
usedDetIds.assign(m_max_id - m_min_id + 1, false);
const double TOF_MIN = alg->filter_tof_min;
const double TOF_MAX = alg->filter_tof_max;
......@@ -190,10 +189,8 @@ void ProcessBankData::run() { // override {
} else
badTofs++;
// Track all the touched wi (only necessary when compressing events,
// for thread safety)
if (compress)
usedDetIds[detId - m_min_id] = true;
// Track all the touched wi
usedDetIds[detId - m_min_id] = true;
} // valid time-of-flight
} // valid detector IDs
......@@ -210,20 +207,18 @@ void ProcessBankData::run() { // override {
//------------ Compress Events (or set sort order) ------------------
// Do it on all the detector IDs we touched
if (compress) {
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);
}
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);
}
}
}
......
......@@ -38,6 +38,7 @@ Bugfixes
- :ref:`LoadNexusLogs <algm-LoadNexusLogs>` now creates a warning message for logs that are poorly formed and the other logs are loaded. Previously it stopped loading logs at that point.
- Fixed a bug where :ref:`LoadRaw <algm-LoadRaw>` would not load all log files for raw files with an alternate data stream.
- Fixed a problem calculating default beam size in :ref:`MonteCarloAbsorption <algm-MonteCarloAbsorption>` when sample is offset from origin.
- Fixed a problem with sorting of events in :ref:`LoadEventNexus <algm-LoadEventNexus>` that was causing :ref:`FilterByTime <algm-FilterByTime>` to give incorrect results
Fit Functions
-------------
......
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