From 5cdbd91a893c40e93b09bee93f2bad10f3e3f02b Mon Sep 17 00:00:00 2001 From: Andrei Savici <saviciat@ornl.gov> Date: Mon, 28 Mar 2016 13:54:25 -0400 Subject: [PATCH] Fix RefReduction. Refs #15748 Try to handle case where there is no proton charge in a particular entry. Made the error message more user friendly. In LoadEventNexus I changed the order of parameters, so that NXentryName is closer to the top --- Framework/DataHandling/src/LoadEventNexus.cpp | 10 +++++----- Framework/DataHandling/src/LoadNexusLogs.cpp | 2 +- Framework/WorkflowAlgorithms/src/RefReduction.cpp | 12 +++++++++++- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/Framework/DataHandling/src/LoadEventNexus.cpp b/Framework/DataHandling/src/LoadEventNexus.cpp index 330b3d6ae06..ca13f840d31 100644 --- a/Framework/DataHandling/src/LoadEventNexus.cpp +++ b/Framework/DataHandling/src/LoadEventNexus.cpp @@ -1074,6 +1074,11 @@ void LoadEventNexus::init() { "The name of the output EventWorkspace or WorkspaceGroup in which to " "load the EventNexus file."); + declareProperty( + make_unique<PropertyWithValue<string>>("NXentryName", "", + Direction::Input), + "Optional: Name of the NXentry to load if it's not the default."); + declareProperty(make_unique<PropertyWithValue<double>>( "FilterByTofMin", EMPTY_DBL(), Direction::Input), "Optional: To exclude events that do not fall within a range " @@ -1104,11 +1109,6 @@ void LoadEventNexus::init() { setPropertyGroup("FilterByTimeStart", grp1); setPropertyGroup("FilterByTimeStop", grp1); - declareProperty( - make_unique<PropertyWithValue<string>>("NXentryName", "", - Direction::Input), - "Optional: Name of the NXentry to load if it's not the default."); - declareProperty( make_unique<ArrayProperty<string>>("BankName", Direction::Input), "Optional: To only include events from one bank. Any bank " diff --git a/Framework/DataHandling/src/LoadNexusLogs.cpp b/Framework/DataHandling/src/LoadNexusLogs.cpp index 3e79c4ae0dc..b62af9405ae 100644 --- a/Framework/DataHandling/src/LoadNexusLogs.cpp +++ b/Framework/DataHandling/src/LoadNexusLogs.cpp @@ -121,7 +121,7 @@ void LoadNexusLogs::exec() { file.openGroup(entry_name, "NXentry"); } catch (::NeXus::Exception &) { throw std::invalid_argument("Unknown NeXus file format found in file '" + - filename + "'"); + filename + "', or '" + entry_name + "' is not a valid NXentry"); } /// Use frequency start for Monitor19 and Special1_19 logs with "No Time" for diff --git a/Framework/WorkflowAlgorithms/src/RefReduction.cpp b/Framework/WorkflowAlgorithms/src/RefReduction.cpp index 69781351212..bd4d93edcef 100644 --- a/Framework/WorkflowAlgorithms/src/RefReduction.cpp +++ b/Framework/WorkflowAlgorithms/src/RefReduction.cpp @@ -139,6 +139,10 @@ MatrixWorkspace_sptr RefReduction::processData(const std::string polarization) { m_output_message += "Processing " + polarization + '\n'; const std::string dataRun = getPropertyValue("DataRun"); IEventWorkspace_sptr evtWS = loadData(dataRun, polarization); + // wrong entry name + if (!evtWS) { + return nullptr; + } MatrixWorkspace_sptr dataWS = boost::dynamic_pointer_cast<MatrixWorkspace>(evtWS); MatrixWorkspace_sptr dataWSTof = @@ -503,7 +507,13 @@ IEventWorkspace_sptr RefReduction::loadData(const std::string dataRun, loadAlg->setProperty("Filename", path); if (polarization.compare(PolStateNone) != 0) loadAlg->setProperty("NXentryName", polarization); - loadAlg->executeAsChildAlg(); + try { + loadAlg->executeAsChildAlg(); + } catch (...) { + g_log.notice() << "Could not load polarization " << polarization; + return nullptr; + } + Workspace_sptr temp = loadAlg->getProperty("OutputWorkspace"); rawWS = boost::dynamic_pointer_cast<IEventWorkspace>(temp); if (rawWS->getNumberEvents() == 0) { -- GitLab