Skip to content
Snippets Groups Projects
Commit 1261c966 authored by Peterson, Peter's avatar Peterson, Peter
Browse files

Re #6346. Refactoring AlignAndFocusPowder to make rebinning easier.

parent ee27be9d
No related branches found
No related tags found
No related merge requests found
...@@ -75,6 +75,7 @@ namespace Mantid ...@@ -75,6 +75,7 @@ namespace Mantid
void init(); void init();
void exec(); void exec();
void loadCalFile(const std::string &calFileName); void loadCalFile(const std::string &calFileName);
void rebin();
API::MatrixWorkspace_sptr m_inputW; API::MatrixWorkspace_sptr m_inputW;
API::MatrixWorkspace_sptr m_outputW; API::MatrixWorkspace_sptr m_outputW;
DataObjects::EventWorkspace_sptr m_inputEW; DataObjects::EventWorkspace_sptr m_inputEW;
......
...@@ -279,30 +279,7 @@ void AlignAndFocusPowder::exec() ...@@ -279,30 +279,7 @@ void AlignAndFocusPowder::exec()
m_outputW = maskAlg->getProperty("Workspace"); m_outputW = maskAlg->getProperty("Workspace");
if(!dspace) if(!dspace)
{ this->rebin();
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");
}
}
g_log.information() << "running AlignDetectors\n"; g_log.information() << "running AlignDetectors\n";
API::IAlgorithm_sptr alignAlg = createChildAlgorithm("AlignDetectors"); API::IAlgorithm_sptr alignAlg = createChildAlgorithm("AlignDetectors");
...@@ -375,30 +352,7 @@ void AlignAndFocusPowder::exec() ...@@ -375,30 +352,7 @@ void AlignAndFocusPowder::exec()
} }
if(dspace) if(dspace)
{ this->rebin();
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");
}
}
doSortEvents(m_outputW); doSortEvents(m_outputW);
...@@ -441,6 +395,15 @@ void AlignAndFocusPowder::exec() ...@@ -441,6 +395,15 @@ void AlignAndFocusPowder::exec()
m_params.erase(m_params.begin()); m_params.erase(m_params.begin());
m_params.pop_back(); m_params.pop_back();
} }
if (!dspace)
this->rebin();
// return the output workspace
setProperty("OutputWorkspace",m_outputW);
}
void AlignAndFocusPowder::rebin()
{
if (m_resampleX != 0) if (m_resampleX != 0)
{ {
g_log.information() << "running ResampleX(NumberBins=" << abs(m_resampleX) g_log.information() << "running ResampleX(NumberBins=" << abs(m_resampleX)
...@@ -463,9 +426,6 @@ void AlignAndFocusPowder::exec() ...@@ -463,9 +426,6 @@ void AlignAndFocusPowder::exec()
rebin3Alg->executeAsChildAlg(); rebin3Alg->executeAsChildAlg();
m_outputW = rebin3Alg->getProperty("OutputWorkspace"); m_outputW = rebin3Alg->getProperty("OutputWorkspace");
} }
// return the output workspace
setProperty("OutputWorkspace",m_outputW);
} }
/** /**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment