Skip to content

Commit

Permalink
Re #9544. Filter events while the run was paused.
Browse files Browse the repository at this point in the history
You might think that the DAS would not save events from when a run was
paused but no, that would be much to easy (for us). Therefore filter
them out if an ADARA-style pause log is present (i.e. this is SNS only).
There is a configuration property that can be set to load them as before.
  • Loading branch information
RussellTaylor committed Jun 16, 2014
1 parent 6e7c6d2 commit 89a3485
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
Expand Up @@ -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
Expand Down
29 changes: 29 additions & 0 deletions Code/Mantid/Framework/DataHandling/src/LoadEventNexus.cpp
Expand Up @@ -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
Expand All @@ -1191,6 +1194,8 @@ void LoadEventNexus::exec()
this->setProperty<IEventWorkspace_sptr>("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
{
Expand Down Expand Up @@ -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 (...)
{
Expand Down Expand Up @@ -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

0 comments on commit 89a3485

Please sign in to comment.