diff --git a/Code/Mantid/Framework/DataHandling/inc/MantidDataHandling/LoadEventNexus.h b/Code/Mantid/Framework/DataHandling/inc/MantidDataHandling/LoadEventNexus.h index 5e150a105850..843114da5d1c 100644 --- a/Code/Mantid/Framework/DataHandling/inc/MantidDataHandling/LoadEventNexus.h +++ b/Code/Mantid/Framework/DataHandling/inc/MantidDataHandling/LoadEventNexus.h @@ -223,6 +223,7 @@ namespace Mantid static void loadTimeOfFlightData(::NeXus::File& file, DataObjects::EventWorkspace_sptr WS, const std::string& binsName,size_t start_wi = 0, size_t end_wi = 0); + void filterDuringPause(API::MatrixWorkspace_sptr workspace); public: /// name of top level NXentry to use diff --git a/Code/Mantid/Framework/DataHandling/src/LoadEventNexus.cpp b/Code/Mantid/Framework/DataHandling/src/LoadEventNexus.cpp index cabc4b2b4ea5..dbdd0f6ef5ee 100644 --- a/Code/Mantid/Framework/DataHandling/src/LoadEventNexus.cpp +++ b/Code/Mantid/Framework/DataHandling/src/LoadEventNexus.cpp @@ -1166,6 +1166,9 @@ void LoadEventNexus::exec() "These events were discarded.\n"; } + // If the run was paused at any point, filter out those events (SNS only, I think) + filterDuringPause(WS); + //add filename WS->mutableRun().addProperty("Filename",m_filename); //Save output @@ -1191,6 +1194,8 @@ void LoadEventNexus::exec() this->setProperty("MonitorWorkspace", WS); // Set the internal monitor workspace pointer as well dataWS->setMonitorWorkspace(WS); + // If the run was paused at any point, filter out those events (SNS only, I think) + filterDuringPause(WS); } else { @@ -2228,6 +2233,8 @@ void LoadEventNexus::runLoadMonitors() this->setProperty("MonitorWorkspace", mons); // Set the internal monitor workspace pointer as well WS->setMonitorWorkspace(mons); + + filterDuringPause(mons); } catch (...) { @@ -2622,6 +2629,28 @@ void LoadEventNexus::loadSampleDataISIScompatibility(::NeXus::File& file, Mantid file.closeGroup(); } +void LoadEventNexus::filterDuringPause(API::MatrixWorkspace_sptr workspace) +{ + try { + if ( ( ! ConfigService::Instance().hasProperty("loadeventnexus.keeppausedevents") ) && ( WS->run().getLogData("pause")->size() > 1 ) ) + { + g_log.notice("Filtering out events when the run was marked as paused. " + "Set the loadeventnexus.keeppausedevents configuration property to override this."); + + auto filter = createChildAlgorithm("FilterByLogValue"); + filter->setProperty("InputWorkspace", workspace); + filter->setProperty("OutputWorkspace", workspace); + filter->setProperty("LogName", "pause"); + // The log value is set to 1 when the run is paused, 0 otherwise. + filter->setProperty("MinimumValue", 0.0); + filter->setProperty("MaximumValue", 0.0); + filter->setProperty("LogBoundary", "Left"); + filter->execute(); + } + } catch ( Exception::NotFoundError& ) { + // No "pause" log, just carry on + } +} } // namespace DataHandling } // namespace Mantid