From c0bfb12bd7ca1371dadb2f4e500e4624a2af5404 Mon Sep 17 00:00:00 2001 From: Antonin Portelli Date: Thu, 18 Sep 2014 17:15:56 +0100 Subject: [PATCH] XY*Data: dog is now a double --- lib/XYSampleData.cpp | 17 ++++++++++++++--- lib/XYSampleData.hpp | 1 + lib/XYStatData.cpp | 13 ++++++------- lib/XYStatData.hpp | 2 +- 4 files changed, 22 insertions(+), 11 deletions(-) diff --git a/lib/XYSampleData.cpp b/lib/XYSampleData.cpp index de4d1b6..6a4d62b 100644 --- a/lib/XYSampleData.cpp +++ b/lib/XYSampleData.cpp @@ -38,13 +38,19 @@ const DSample & SampleFitResult::getChi2(const PlaceHolder ph __unused) const double SampleFitResult::getChi2PerDof(const Index s) const { - return chi2_[s]/static_cast(nDof_); + return chi2_[s]/getNDof(); } DSample SampleFitResult::getChi2PerDof(const PlaceHolder ph __unused) const { - return chi2_/static_cast(nDof_); + return chi2_/getNDof(); } + +double SampleFitResult::getNDof(void) const +{ + return static_cast(nDof_); +} + const DoubleFunction & SampleFitResult::getModel(const Index s, const Index j) const { @@ -210,6 +216,7 @@ SampleFitResult XYSampleData::fit(Minimizer &minimizer, const DVec &init, FitResult sampleResult; SampleFitResult result; bool initChi2; + DVec initBuf = init; result.resize(nSample); result.chi2_.resize(nSample); @@ -232,7 +239,11 @@ SampleFitResult XYSampleData::fit(Minimizer &minimizer, const DVec &init, initChi2 = (s == central); // fit - sampleResult = data_.fit(minimizer, init, modelVector); + sampleResult = data_.fit(minimizer, initBuf, modelVector); + if (s == central) + { + initBuf = sampleResult; + } // store result result[s] = sampleResult; diff --git a/lib/XYSampleData.hpp b/lib/XYSampleData.hpp index 88279cc..f500994 100644 --- a/lib/XYSampleData.hpp +++ b/lib/XYSampleData.hpp @@ -46,6 +46,7 @@ public: const DSample & getChi2(const PlaceHolder ph) const; double getChi2PerDof(const Index s = central) const; DSample getChi2PerDof(const PlaceHolder ph) const; + double getNDof(void) const; const DoubleFunction & getModel(const Index s = central, const Index j = 0) const; const DoubleFunctionSample & getModel(const PlaceHolder ph, diff --git a/lib/XYStatData.cpp b/lib/XYStatData.cpp index ccd16cf..2b2f6e3 100644 --- a/lib/XYStatData.cpp +++ b/lib/XYStatData.cpp @@ -32,14 +32,14 @@ double FitResult::getChi2(void) const return chi2_; } -Index FitResult::getNDof(void) const -{ - return nDof_; -} - double FitResult::getChi2PerDof(void) const { - return chi2_/static_cast(nDof_); + return chi2_/getNDof(); +} + +double FitResult::getNDof(void) const +{ + return static_cast(nDof_); } const DoubleFunction & FitResult::getModel(const Index j) const @@ -219,7 +219,6 @@ FitResult XYStatData::fit(Minimizer &minimizer, const DVec &init, { chi2_.requestInit(); } - // initial parameters const Index nPoint = getNFitPoint(); DVec fullInit = init; diff --git a/lib/XYStatData.hpp b/lib/XYStatData.hpp index 5dff489..9c832bf 100644 --- a/lib/XYStatData.hpp +++ b/lib/XYStatData.hpp @@ -45,8 +45,8 @@ public: virtual ~FitResult(void) = default; // access double getChi2(void) const; - Index getNDof(void) const; double getChi2PerDof(void) const; + double getNDof(void) const; const DoubleFunction & getModel(const Index j = 0) const; private: double chi2_{0.0};