Skip to content

Commit

Permalink
CalculateTransmission: substitute Linear by Fit
Browse files Browse the repository at this point in the history
  • Loading branch information
gesnerpassos committed Jul 22, 2013
1 parent 7b21769 commit 120bc05
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions Code/Mantid/Framework/Algorithms/src/CalculateTransmission.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ Uses the algorithm [[linear]] to fit to the calculated transmission fraction.
#include "MantidKernel/VectorHelper.h"
#include "MantidKernel/BoundedValidator.h"
#include "MantidKernel/ListValidator.h"
#include "MantidAPI/FunctionFactory.h"
#include "MantidAPI/IFunction.h"

#include <cmath>

namespace Mantid
Expand Down Expand Up @@ -308,22 +311,26 @@ API::MatrixWorkspace_sptr CalculateTransmission::fitData(API::MatrixWorkspace_sp
{
g_log.information("Fitting the experimental transmission curve");
double start = m_done;
IAlgorithm_sptr childAlg = createChildAlgorithm("Linear", start, m_done=0.9);
IAlgorithm_sptr childAlg = createChildAlgorithm("Fit", start, m_done=0.9);
auto linearBack = API::FunctionFactory::Instance().createFunction("LinearBackground");
childAlg->setProperty("Function",linearBack);
childAlg->setProperty<MatrixWorkspace_sptr>("InputWorkspace", WS);
childAlg->setProperty("Minimizer","Levenberg-MarquardtMD");
childAlg->setProperty("CreateOutput",true);
childAlg->setProperty("IgnoreInvalidData",true);
childAlg->executeAsChildAlg();

std::string fitStatus = childAlg->getProperty("FitStatus");
std::string fitStatus = childAlg->getProperty("OutputStatus");
if ( fitStatus != "success" )
{
g_log.error("Unable to successfully fit the data: " + fitStatus);
throw std::runtime_error("Unable to successfully fit the data");
}

// Only get to here if successful
offset = childAlg->getProperty("FitIntercept");
grad = childAlg->getProperty("FitSlope");

return childAlg->getProperty("OutputWorkspace");
offset = linearBack->getParameter(0);
grad = linearBack->getParameter(1);
return this->extractSpectrum(childAlg->getProperty("OutputWorkspace"),1);
}
/** Calls rebin as Child Algorithm
* @param binParams this string is passed to rebin as the "Params" property
Expand Down

0 comments on commit 120bc05

Please sign in to comment.