diff --git a/Code/Mantid/Framework/CurveFitting/inc/MantidCurveFitting/PoldiCalibrationProfile.h b/Code/Mantid/Framework/CurveFitting/inc/MantidCurveFitting/PoldiCalibrationProfile.h index bc3dded5a618..a5b73fa51186 100644 --- a/Code/Mantid/Framework/CurveFitting/inc/MantidCurveFitting/PoldiCalibrationProfile.h +++ b/Code/Mantid/Framework/CurveFitting/inc/MantidCurveFitting/PoldiCalibrationProfile.h @@ -47,16 +47,11 @@ class DLLExport PoldiCalibrationProfile : public Gaussian { std::string name() const { return "PoldiCalibrationProfile"; } - double centre() const; - void functionLocal(double *out, const double *xValues, const size_t nData) const; void functionDerivLocal(API::Jacobian *out, const double *xValues, const size_t nData); - // void functionDerivLocal(API::Jacobian *out, const double *xValues, const - // size_t nData); - protected: double getAbsoluteShift() const; diff --git a/Code/Mantid/Framework/CurveFitting/src/PoldiCalibrationProfile.cpp b/Code/Mantid/Framework/CurveFitting/src/PoldiCalibrationProfile.cpp index cea06bdf3c5d..accc9572904c 100644 --- a/Code/Mantid/Framework/CurveFitting/src/PoldiCalibrationProfile.cpp +++ b/Code/Mantid/Framework/CurveFitting/src/PoldiCalibrationProfile.cpp @@ -1,5 +1,6 @@ #include "MantidCurveFitting/PoldiCalibrationProfile.h" #include "MantidAPI/FunctionFactory.h" +#include namespace Mantid { namespace CurveFitting { @@ -14,7 +15,8 @@ void PoldiCalibrationProfile::functionLocal(double *out, const double *xValues, const double height = getParameter("Height"); const double peakCentre = getParameter("PeakCentre"); const double shift = getAbsoluteShift(); - const double realCentre = peakCentre + peakCentre * shift; + const double realCentre = + peakCentre * (1.0 + shift) + getAttribute("ChopperOffset").asDouble(); const double weight = pow(1 / getParameter("Sigma"), 2); @@ -30,38 +32,37 @@ void PoldiCalibrationProfile::functionDerivLocal(Jacobian *out, const double height = getParameter("Height"); const double peakCentre = getParameter("PeakCentre"); const double shift = getAbsoluteShift(); - const double realCentre = peakCentre + peakCentre * shift; + const double realCentre = + peakCentre * (1.0 + shift) + getAttribute("ChopperOffset").asDouble(); const double weight = pow(1 / getParameter("Sigma"), 2); - const double factor = getAttribute("DeltaTheta").asDouble() / 1000.0; + const double factor = getAttribute("DeltaTheta").asDouble() * 1.e-3; for (size_t i = 0; i < nData; i++) { double diff = xValues[i] - realCentre; double e = exp(-0.5 * diff * diff * weight); double b = e * height * diff * weight; out->set(i, 0, e); - out->set(i, 1, b * (1.0 + shift)); + out->set(i, 1, b * (shift + 1.0)); out->set(i, 2, -0.5 * diff * diff * height * e); // derivative with respect to weight not sigma out->set(i, 3, b * factor * peakCentre); } } -double PoldiCalibrationProfile::centre() const { - return getParameter("PeakCentre") + - getParameter("PeakCentre") * getAbsoluteShift(); -} - double PoldiCalibrationProfile::getAbsoluteShift() const { - return getParameter("Slope") * 1.e-3 * getAttribute("DeltaTheta").asDouble(); + return getParameter("Slope") * getAttribute("DeltaTheta").asDouble() * 1.e-3; } /// Initialize Gaussian parameters and declare additional parameter. void PoldiCalibrationProfile::init() { Gaussian::init(); - declareParameter("Slope"); + declareParameter("Slope", 0.0); declareAttribute("DeltaTheta", IFunction::Attribute(0.0)); + declareAttribute("ChopperOffset", IFunction::Attribute(0.0)); + + // fix(3); } } // namespace CurveFitting diff --git a/Code/Mantid/Framework/CurveFitting/test/PoldiCalibrationProfileTest.h b/Code/Mantid/Framework/CurveFitting/test/PoldiCalibrationProfileTest.h index 41193e131b43..16991b631f95 100644 --- a/Code/Mantid/Framework/CurveFitting/test/PoldiCalibrationProfileTest.h +++ b/Code/Mantid/Framework/CurveFitting/test/PoldiCalibrationProfileTest.h @@ -3,6 +3,7 @@ #include +#include "MantidCurveFitting/Jacobian.h" #include "MantidCurveFitting/PoldiCalibrationProfile.h" using namespace Mantid::CurveFitting; @@ -26,19 +27,6 @@ class PoldiCalibrationProfileTest : public CxxTest::TestSuite { TS_ASSERT_EQUALS(fn.nParams(), gaussian.nParams() + 1); } - - void testDerivatives() { - PoldiCalibrationProfile fn; - fn.initialize(); - - fn.setParameter("Height", 2.0); - fn.setParameter("PeakCentre", 1.1); - fn.setParameter("Sigma", 0.01); - fn.setParameter("Slope", 0.001); - fn.setAttribute("DeltaTheta", IFunction::Attribute(0.01)); - - - } }; #endif /* MANTID_CURVEFITTING_POLDICALIBRATIONFUNCTIONTEST_H_ */