diff --git a/src/classes/PFitter.cpp b/src/classes/PFitter.cpp index f0394e5a..0c8a3968 100644 --- a/src/classes/PFitter.cpp +++ b/src/classes/PFitter.cpp @@ -2171,15 +2171,22 @@ Bool_t PFitter::ExecuteSave(Bool_t firstSave) // calculate expected chisq std::vector param; + std::vector err; Double_t totalExpectedChisq = 0.0; std::vector expectedchisqPerRun; std::vector ndfPerHisto; - for (UInt_t i=0; iCalcExpectedChiSquare(param, totalExpectedChisq, expectedchisqPerRun); + Bool_t ok; + PDoubleVector par_r = ParamRound(param, err, ok); + if (!ok) + par_r = param; + fFitterFcn->CalcExpectedChiSquare(par_r, totalExpectedChisq, expectedchisqPerRun); // calculate chisq per run std::vector chisqPerRun; @@ -2905,6 +2912,46 @@ Double_t PFitter::MilliTime() return ((Double_t)now.tv_sec * 1.0e6 + (Double_t)now.tv_usec)/1.0e3; } +//-------------------------------------------------------------------------- +// ParamRound (private) +//-------------------------------------------------------------------------- +/** + *

Rounds the parameter vector value according to the given error estimate, + * so that the msr-file value and the fitter result are consistent with each + * other. This means that musrfit -c, and musrfit -e -t should give essentially + * the same values of expected chisq (up to small rounding values). + * + * @param par parameter value vector + * @param err error value vector + * @param ok true if size of par and err are identically, otherwise false. + * + * @return rounded parameter value vector, compatible with the msr-file output. + */ +PDoubleVector PFitter::ParamRound(const PDoubleVector &par, const PDoubleVector &err, Bool_t &ok) +{ + PDoubleVector par_r; + + par_r.resize(par.size()); + ok = true; + + if (par.size() != err.size()) { + // error msg + ok = false; + return par_r; + } + + int exp; + double dval; + for (unsigned int i=0; i