Skip to content

Commit

Permalink
Refs #11674. Changing PoldiCalibrationProfile
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Wedel committed May 22, 2015
1 parent 5f16c29 commit 44ceec4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 29 deletions.
Expand Up @@ -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;

Expand Down
23 changes: 12 additions & 11 deletions Code/Mantid/Framework/CurveFitting/src/PoldiCalibrationProfile.cpp
@@ -1,5 +1,6 @@
#include "MantidCurveFitting/PoldiCalibrationProfile.h"
#include "MantidAPI/FunctionFactory.h"
#include <iostream>

namespace Mantid {
namespace CurveFitting {
Expand All @@ -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);

Expand All @@ -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
Expand Down
Expand Up @@ -3,6 +3,7 @@

#include <cxxtest/TestSuite.h>

#include "MantidCurveFitting/Jacobian.h"
#include "MantidCurveFitting/PoldiCalibrationProfile.h"

using namespace Mantid::CurveFitting;
Expand All @@ -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_ */

0 comments on commit 44ceec4

Please sign in to comment.