From 1261c966e4ee907d1686e5ec5378ed491e2545a2 Mon Sep 17 00:00:00 2001 From: Peter Peterson <petersonpf@ornl.gov> Date: Mon, 14 Jan 2013 10:09:04 -0500 Subject: [PATCH] Re #6346. Refactoring AlignAndFocusPowder to make rebinning easier. --- .../AlignAndFocusPowder.h | 1 + .../src/AlignAndFocusPowder.cpp | 62 ++++--------------- 2 files changed, 12 insertions(+), 51 deletions(-) diff --git a/Code/Mantid/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/AlignAndFocusPowder.h b/Code/Mantid/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/AlignAndFocusPowder.h index 2449316d53b..48cba89c960 100644 --- a/Code/Mantid/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/AlignAndFocusPowder.h +++ b/Code/Mantid/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/AlignAndFocusPowder.h @@ -75,6 +75,7 @@ namespace Mantid void init(); void exec(); void loadCalFile(const std::string &calFileName); + void rebin(); 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 7c864dfacc3..3020f74a12b 100644 --- a/Code/Mantid/Framework/WorkflowAlgorithms/src/AlignAndFocusPowder.cpp +++ b/Code/Mantid/Framework/WorkflowAlgorithms/src/AlignAndFocusPowder.cpp @@ -279,30 +279,7 @@ void AlignAndFocusPowder::exec() m_outputW = maskAlg->getProperty("Workspace"); if(!dspace) - { - if (m_resampleX != 0) - { - g_log.information() << "running ResampleX(NumberBins=" << abs(m_resampleX) - << ", LogBinning=" << (m_resampleX < 0) << ")\n"; - API::IAlgorithm_sptr alg = createChildAlgorithm("ResampleX"); - alg->setProperty("InputWorkspace", m_outputW); - alg->setProperty("OutputWorkspace", m_outputW); - alg->setProperty("NumberBins", abs(m_resampleX)); - alg->setProperty("LogBinning", (m_resampleX < 0)); - alg->executeAsChildAlg(); - m_outputW = alg->getProperty("OutputWorkspace"); - } - else - { - g_log.information() << "running Rebin\n"; - API::IAlgorithm_sptr rebin1Alg = createChildAlgorithm("Rebin"); - rebin1Alg->setProperty("InputWorkspace", m_outputW); - rebin1Alg->setProperty("OutputWorkspace", m_outputW); - rebin1Alg->setProperty("Params",m_params); - rebin1Alg->executeAsChildAlg(); - m_outputW = rebin1Alg->getProperty("OutputWorkspace"); - } - } + this->rebin(); g_log.information() << "running AlignDetectors\n"; API::IAlgorithm_sptr alignAlg = createChildAlgorithm("AlignDetectors"); @@ -375,30 +352,7 @@ void AlignAndFocusPowder::exec() } if(dspace) - { - if (m_resampleX != 0) - { - g_log.information() << "running ResampleX(NumberBins=" << abs(m_resampleX) - << ", LogBinning=" << (m_resampleX < 0) << ")\n"; - API::IAlgorithm_sptr alg = createChildAlgorithm("ResampleX"); - alg->setProperty("InputWorkspace", m_outputW); - alg->setProperty("OutputWorkspace", m_outputW); - alg->setProperty("NumberBins", abs(m_resampleX)); - alg->setProperty("LogBinning", (m_resampleX < 0)); - alg->executeAsChildAlg(); - m_outputW = alg->getProperty("OutputWorkspace"); - } - else - { - g_log.information() << "running Rebin\n"; - API::IAlgorithm_sptr rebin2Alg = createChildAlgorithm("Rebin"); - rebin2Alg->setProperty("InputWorkspace", m_outputW); - rebin2Alg->setProperty("OutputWorkspace", m_outputW); - rebin2Alg->setProperty("Params",m_params); - rebin2Alg->executeAsChildAlg(); - m_outputW = rebin2Alg->getProperty("OutputWorkspace"); - } - } + this->rebin(); doSortEvents(m_outputW); @@ -441,6 +395,15 @@ void AlignAndFocusPowder::exec() m_params.erase(m_params.begin()); m_params.pop_back(); } + if (!dspace) + this->rebin(); + + // return the output workspace + setProperty("OutputWorkspace",m_outputW); +} + +void AlignAndFocusPowder::rebin() +{ if (m_resampleX != 0) { g_log.information() << "running ResampleX(NumberBins=" << abs(m_resampleX) @@ -463,9 +426,6 @@ void AlignAndFocusPowder::exec() rebin3Alg->executeAsChildAlg(); m_outputW = rebin3Alg->getProperty("OutputWorkspace"); } - - // return the output workspace - setProperty("OutputWorkspace",m_outputW); } /** -- GitLab