From 026a7c9f4f5a92c69238b502de3154b071cebfc1 Mon Sep 17 00:00:00 2001 From: Peter Peterson <petersonpf@ornl.gov> Date: Tue, 15 Jan 2013 09:56:07 -0500 Subject: [PATCH] Re #6346. Adding the option to pass in multiple d-spacing ranges. One for each spectrum number. Also cleaned up some bits of the code so unfocussed data doesn't get the d-ranges. --- .../AlignAndFocusPowder.h | 2 + .../src/AlignAndFocusPowder.cpp | 39 +++++++++++++++---- 2 files changed, 34 insertions(+), 7 deletions(-) diff --git a/Code/Mantid/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/AlignAndFocusPowder.h b/Code/Mantid/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/AlignAndFocusPowder.h index 48cba89c960..3a52faef064 100644 --- a/Code/Mantid/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/AlignAndFocusPowder.h +++ b/Code/Mantid/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/AlignAndFocusPowder.h @@ -91,6 +91,8 @@ namespace Mantid std::string m_instName; std::vector<double> m_params; int m_resampleX; + std::vector<double> m_dmins; + std::vector<double> m_dmaxs; bool dspace; double xmin; double xmax; diff --git a/Code/Mantid/Framework/WorkflowAlgorithms/src/AlignAndFocusPowder.cpp b/Code/Mantid/Framework/WorkflowAlgorithms/src/AlignAndFocusPowder.cpp index ca9b34f9842..cfa26cadd48 100644 --- a/Code/Mantid/Framework/WorkflowAlgorithms/src/AlignAndFocusPowder.cpp +++ b/Code/Mantid/Framework/WorkflowAlgorithms/src/AlignAndFocusPowder.cpp @@ -64,7 +64,7 @@ void AlignAndFocusPowder::init() "Optional: An OffsetsWorkspace workspace giving the detector calibration values."); declareProperty(new WorkspaceProperty<MatrixWorkspace>("MaskWorkspace","",Direction::Input, PropertyMode::Optional), "Optional: An Workspace workspace giving which detectors are masked."); - declareProperty(new ArrayProperty<double>("Params", boost::make_shared<RebinParamsValidator>()), + declareProperty(new ArrayProperty<double>("Params"/*, boost::make_shared<RebinParamsValidator>()*/), "A comma separated list of first bin boundary, width, last bin boundary. Optionally\n" "this can be followed by a comma and more widths and last boundary pairs.\n" "Negative width values indicate logarithmic binning."); @@ -72,8 +72,8 @@ void AlignAndFocusPowder::init() "Number of bins in x-axis. Non-zero value overrides \"Params\" property. Negative value means logorithmic binning."); setPropertySettings("Params", new EnabledWhenProperty("ResampleX", IS_DEFAULT)); declareProperty("Dspacing", true,"Bin in Dspace. (True is Dspace; False is TOF)"); - declareProperty("DMin", 0.0, "Minimum for Dspace axis. (Default 0.) "); - declareProperty("DMax", 0.0, "Maximum for Dspace axis. (Default 0.) "); + declareProperty(new ArrayProperty<double>("DMin", 0.0), "Minimum for Dspace axis. (Default 0.) "); + declareProperty(new ArrayProperty<double>("DMax", 0.0), "Maximum for Dspace axis. (Default 0.) "); declareProperty("TMin", 0.0, "Minimum for TOF axis. (Default 0.) "); declareProperty("TMax", 0.0, "Maximum for TOF or dspace axis. (Default 0.) "); declareProperty("PreserveEvents", true, @@ -117,8 +117,14 @@ void AlignAndFocusPowder::exec() phis = getProperty("Azimuthal"); m_params=getProperty("Params"); dspace = getProperty("DSpacing"); - double dmin = getProperty("DMin"); - double dmax = getProperty("DMax"); + 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]; LRef = getProperty("UnwrapRef"); DIFCref = getProperty("LowResRef"); minwl = getProperty("CropWavelengthMin"); @@ -133,8 +139,10 @@ void AlignAndFocusPowder::exec() } else if (m_params.size() == 1) { - if (dmax > 0) dspace = true; - else dspace=false; + if (dmax > 0.) + dspace = true; + else + dspace=false; } if (dspace) { @@ -369,6 +377,9 @@ void AlignAndFocusPowder::exec() doSortEvents(m_outputW); + if (dspace) + this->rebin(); + if (l1 > 0) { g_log.information() << "running EditInstrumentGeometry\n"; @@ -413,6 +424,20 @@ void AlignAndFocusPowder::rebin() API::IAlgorithm_sptr alg = createChildAlgorithm("ResampleX"); alg->setProperty("InputWorkspace", m_outputW); alg->setProperty("OutputWorkspace", m_outputW); + if ((!m_dmins.empty()) && (!m_dmaxs.empty())) + { + size_t numHist = m_outputW->getNumberHistograms(); + if ((numHist == m_dmins.size()) && (numHist == m_dmaxs.size())) + { + alg->setProperty("XMin", m_dmins); + alg->setProperty("XMax", m_dmaxs); + } + else + { + g_log.information() << "Number of dmin and dmax values don't match the " + << "number of workspace indices. Ignoring the parameters.\n"; + } + } alg->setProperty("NumberBins", abs(m_resampleX)); alg->setProperty("LogBinning", (m_resampleX < 0)); alg->executeAsChildAlg(); -- GitLab