From a0623f37df9c44f1d879f7fa04cdb714e53cc6ba Mon Sep 17 00:00:00 2001 From: Roman Tolchenov Date: Fri, 6 Mar 2015 13:39:42 +0000 Subject: [PATCH] Re #11131. Correction for a case of h0 == 0. --- .../Framework/API/inc/MantidAPI/IPeakFunction.h | 2 +- .../inc/MantidCurveFitting/PeakParametersNumeric.h | 1 + .../CurveFitting/src/PeakParametersNumeric.cpp | 14 ++++++++++++-- .../CurveFitting/test/PeakParametersNumericTest.h | 2 -- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/Code/Mantid/Framework/API/inc/MantidAPI/IPeakFunction.h b/Code/Mantid/Framework/API/inc/MantidAPI/IPeakFunction.h index 306029e845e1..fa88c3ddf5e2 100644 --- a/Code/Mantid/Framework/API/inc/MantidAPI/IPeakFunction.h +++ b/Code/Mantid/Framework/API/inc/MantidAPI/IPeakFunction.h @@ -71,7 +71,7 @@ class MANTID_API_DLL IPeakFunction : public IFunctionWithLocation { const size_t nData) = 0; /// Get name of parameter that is associated to centre. - std::string getCentreParameterName() const; + virtual std::string getCentreParameterName() const; protected: /// Defines the area around the centre where the peak values are to be diff --git a/Code/Mantid/Framework/CurveFitting/inc/MantidCurveFitting/PeakParametersNumeric.h b/Code/Mantid/Framework/CurveFitting/inc/MantidCurveFitting/PeakParametersNumeric.h index 1a6819f18087..9b1d7e6349db 100644 --- a/Code/Mantid/Framework/CurveFitting/inc/MantidCurveFitting/PeakParametersNumeric.h +++ b/Code/Mantid/Framework/CurveFitting/inc/MantidCurveFitting/PeakParametersNumeric.h @@ -56,6 +56,7 @@ class DLLExport PeakParametersNumeric : public API::IPeakFunction { virtual void setParameter(size_t, const double &value, bool explicitlySet = true); using API::IPeakFunction::setParameter; + std::string getCentreParameterName() const; /// Get boundaries for an interval within which the peak has /// significant values. The interval must contain the maximum diff --git a/Code/Mantid/Framework/CurveFitting/src/PeakParametersNumeric.cpp b/Code/Mantid/Framework/CurveFitting/src/PeakParametersNumeric.cpp index e596643ed063..48032ecb6711 100644 --- a/Code/Mantid/Framework/CurveFitting/src/PeakParametersNumeric.cpp +++ b/Code/Mantid/Framework/CurveFitting/src/PeakParametersNumeric.cpp @@ -55,7 +55,7 @@ double PeakParametersNumeric::height() const { void PeakParametersNumeric::setHeight(const double h) { double h0 = height(); if (h0 == 0.0) { - setParameter(m_heightIndex, 1e-6); + setParameter(m_heightIndex, 1.0); h0 = height(); } double parValue = getParameter(m_heightIndex); @@ -96,7 +96,11 @@ double PeakParametersNumeric::fwhm() const { /// @param w :: New value for the width. void PeakParametersNumeric::setFwhm(const double w) { const double c = centre(); - const double h = height(); + double h = height(); + if (h == 0.0) { + setHeight(1.0); + h = 1.0; + } double wOld = fwhm(); double factor = w / wOld; for (size_t i = 0; i < m_widthIndices.size(); ++i) { @@ -251,5 +255,11 @@ void PeakParametersNumeric::updateCache() const { } } +/// Override the base class implementation +std::string PeakParametersNumeric::getCentreParameterName() const +{ + return parameterName(m_centreIndex); +} + } // namespace CurveFitting } // namespace Mantid diff --git a/Code/Mantid/Framework/CurveFitting/test/PeakParametersNumericTest.h b/Code/Mantid/Framework/CurveFitting/test/PeakParametersNumericTest.h index db7adc54c83e..14835469feae 100644 --- a/Code/Mantid/Framework/CurveFitting/test/PeakParametersNumericTest.h +++ b/Code/Mantid/Framework/CurveFitting/test/PeakParametersNumericTest.h @@ -228,13 +228,11 @@ class PeakParametersNumericTest : public CxxTest::TestSuite { TS_ASSERT_DELTA(fun.centre(), -1.0, tol); TS_ASSERT_DELTA(fun.height(), 1.0, tol); TS_ASSERT_DELTA(fun.fwhm(), 0.4027, tol); - std::cerr << fun.intensity() << std::endl; fun.setHeight(10.0); TS_ASSERT_DELTA(fun.centre(), -1.0, tol); TS_ASSERT_DELTA(fun.height(), 10.0, tol); TS_ASSERT_DELTA(fun.fwhm(), 0.4027, tol); - std::cerr << fun.intensity() << std::endl; fun.setFwhm(1.0); TS_ASSERT_DELTA(fun.centre(), -1.0, tol);