Unverified Commit 62d1c959 authored by Gemma Guest's avatar Gemma Guest Committed by GitHub
Browse files

Merge pull request #32499 from mantidproject/32495_FixSortOrderInLoadEventNexus

Fix sort order in LoadEventNexus
parents c9a58c6f 972e88a7
......@@ -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,11 +207,12 @@ 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);
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);
if (wi < numEventLists) {
auto &el = outputWS.getSpectrum(wi);
if (compress)
el.compressEvents(alg->compressTolerance, &el);
......
......@@ -181,6 +181,19 @@ private:
TS_ASSERT_EQUALS("2010-Mar-25 16:11:51.558003540", filteredLogEndTime.toSimpleString());
}
void validate_pulse_time_sorting(EventWorkspace_sptr eventWS) {
for (size_t i = 0; i < eventWS->getNumberHistograms(); i++) {
auto eventList = eventWS->getSpectrum(i);
if (eventList.getSortType() == DataObjects::PULSETIME_SORT) {
std::vector<DateAndTime> pulsetimes;
for (auto &event : eventList.getEvents()) {
pulsetimes.emplace_back(event.pulseTime());
}
TS_ASSERT(std::is_sorted(pulsetimes.cbegin(), pulsetimes.cend()));
}
}
}
public:
void test_load_event_nexus_v20_ess() {
const std::string file = "V20_ESS_example.nxs";
......@@ -219,6 +232,8 @@ public:
TS_ASSERT_EQUALS(eventWS->getNumberEvents(), 1439);
TS_ASSERT_EQUALS(eventWS->detectorInfo().size(),
(150 * 150) + 2) // Two monitors
validate_pulse_time_sorting(eventWS);
}
void test_load_event_nexus_v20_ess_integration_2018() {
......@@ -241,6 +256,8 @@ public:
(300 * 300) + 2) // Two monitors
TS_ASSERT_DELTA(eventWS->getTofMin(), 9.815, 1.0e-3);
TS_ASSERT_DELTA(eventWS->getTofMax(), 130748.563, 1.0e-3);
validate_pulse_time_sorting(eventWS);
}
}
......
......@@ -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