From b83a59bcb8518a36723e37bce08b160c40223b43 Mon Sep 17 00:00:00 2001 From: Michael Reuter <reuterma@ornl.gov> Date: Wed, 28 May 2014 08:38:11 -0400 Subject: [PATCH] Refs #9529. Dealing with vector properties. --- .../AlignAndFocusPowder.h | 5 +++ .../src/AlignAndFocusPowder.cpp | 45 +++++++++++++++---- 2 files changed, 42 insertions(+), 8 deletions(-) diff --git a/Code/Mantid/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/AlignAndFocusPowder.h b/Code/Mantid/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/AlignAndFocusPowder.h index f8e51d0604c..7206880d0c0 100644 --- a/Code/Mantid/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/AlignAndFocusPowder.h +++ b/Code/Mantid/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/AlignAndFocusPowder.h @@ -100,6 +100,11 @@ namespace Mantid const std::string &pmpname, boost::shared_ptr<Kernel::PropertyManager> pm); + double getVecPropertyFromPmOrSelf(const std::string &apname, + std::vector<double> &avec, + const std::string &pmpname, + boost::shared_ptr<Kernel::PropertyManager> pm); + API::MatrixWorkspace_sptr m_inputW; API::MatrixWorkspace_sptr m_outputW; DataObjects::EventWorkspace_sptr m_inputEW; diff --git a/Code/Mantid/Framework/WorkflowAlgorithms/src/AlignAndFocusPowder.cpp b/Code/Mantid/Framework/WorkflowAlgorithms/src/AlignAndFocusPowder.cpp index 32db807ec8e..fac6689566e 100644 --- a/Code/Mantid/Framework/WorkflowAlgorithms/src/AlignAndFocusPowder.cpp +++ b/Code/Mantid/Framework/WorkflowAlgorithms/src/AlignAndFocusPowder.cpp @@ -224,6 +224,41 @@ namespace WorkflowAlgorithms } } + //---------------------------------------------------------------------------------------------- + /** + * Function to get a vector property either from a PropertyManager or the algorithm + * properties. If both PM and algorithm properties are specified, the algorithm one wins. + * The return value is the first element in the vector if it is not empty. + * @param apname : The algorithm property to retrieve. + * @param avec : The vector to hold the property value. + * @param pmpname : The property manager property name. + * @param pm : The PropertyManager instance. + * @return : The default value of the requested property. + */ + double AlignAndFocusPowder::getVecPropertyFromPmOrSelf(const std::string &apname, + std::vector<double> &avec, + const std::string &pmpname, + boost::shared_ptr<PropertyManager> pm) + { + avec = getProperty(apname); + // Look at algorithm first + if (!avec.empty()) + { + return avec[0]; + } + // Look in property manager + if (pm && pm->existsProperty(pmpname)) + { + avec = pm->getProperty(pmpname); + if (!avec.empty()) + { + return avec[0]; + } + } + // No overrides provided. + return 0.0; + } + //---------------------------------------------------------------------------------------------- /** Executes the algorithm * @throw Exception::FileError If the grouping file cannot be opened or read successfully @@ -256,14 +291,8 @@ namespace WorkflowAlgorithms phis = getProperty("Azimuthal"); m_params=getProperty("Params"); dspace = getProperty("DSpacing"); - m_dmins = getProperty("DMin"); - m_dmaxs = getProperty("DMax"); - double dmin = 0.; - if (!m_dmins.empty()) - dmin = m_dmins[0]; - double dmax = 0.; - if (!m_dmaxs.empty()) - dmax = m_dmaxs[0]; + auto dmin = getVecPropertyFromPmOrSelf("DMin", m_dmins, "d_min", reductionManager); + auto dmax = getVecPropertyFromPmOrSelf("DMax", m_dmaxs, "d_max", reductionManager); LRef = getProperty("UnwrapRef"); DIFCref = getProperty("LowResRef"); minwl = getProperty("CropWavelengthMin"); -- GitLab