improved rounding handling to get a more consistent expected chisq after fitting compared to pure chisq estimate of musrfit. Essentially get rid of rounding issues.
This commit is contained in:
@@ -2298,18 +2298,25 @@ Bool_t PFitter::ExecuteSave(Bool_t firstSave)
|
|||||||
|
|
||||||
// calculate expected chisq
|
// calculate expected chisq
|
||||||
std::vector<Double_t> param;
|
std::vector<Double_t> param;
|
||||||
|
std::vector<Double_t> err;
|
||||||
Double_t totalExpectedChisq = 0.0;
|
Double_t totalExpectedChisq = 0.0;
|
||||||
std::vector<Double_t> expectedchisqPerRun;
|
std::vector<Double_t> expectedchisqPerRun;
|
||||||
std::vector<UInt_t> ndfPerHisto;
|
std::vector<UInt_t> ndfPerHisto;
|
||||||
|
|
||||||
for (UInt_t i=0; i<fParams.size(); i++)
|
for (UInt_t i=0; i<fParams.size(); i++) {
|
||||||
param.push_back(fParams[i].fValue);
|
param.push_back(fParams[i].fValue);
|
||||||
|
err.push_back(fParams[i].fPosError);
|
||||||
|
}
|
||||||
|
|
||||||
// CalcExpectedChiSquare handles both, chisq and mlh
|
// CalcExpectedChiSquare handles both, chisq and mlh
|
||||||
|
Bool_t ok;
|
||||||
|
PDoubleVector par_r = ParamRound(param, err, ok);
|
||||||
|
if (!ok)
|
||||||
|
par_r = param;
|
||||||
if (fDKSReady)
|
if (fDKSReady)
|
||||||
fFitterFcnDKS->CalcExpectedChiSquare(param, totalExpectedChisq, expectedchisqPerRun);
|
fFitterFcnDKS->CalcExpectedChiSquare(par_r, totalExpectedChisq, expectedchisqPerRun);
|
||||||
else
|
else
|
||||||
fFitterFcn->CalcExpectedChiSquare(param, totalExpectedChisq, expectedchisqPerRun);
|
fFitterFcn->CalcExpectedChiSquare(par_r, totalExpectedChisq, expectedchisqPerRun);
|
||||||
|
|
||||||
// calculate chisq per run
|
// calculate chisq per run
|
||||||
std::vector<Double_t> chisqPerRun;
|
std::vector<Double_t> chisqPerRun;
|
||||||
@@ -3160,6 +3167,45 @@ std::string PFitter::GetCPUInfo()
|
|||||||
return cpuInfo;
|
return cpuInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------
|
||||||
|
// ParamRound (private)
|
||||||
|
//--------------------------------------------------------------------------
|
||||||
|
/**
|
||||||
|
* <p>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<par.size(); i++) {
|
||||||
|
exp = round(log10(fabs(err[i])))-2;
|
||||||
|
dval = round(par[i]*pow(10.0, -exp))/pow(10.0, -exp);
|
||||||
|
par_r[i] = dval;
|
||||||
|
}
|
||||||
|
|
||||||
|
return par_r;
|
||||||
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------------------
|
||||||
// end
|
// end
|
||||||
//-------------------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -173,7 +173,7 @@ class PFitter
|
|||||||
|
|
||||||
// commands
|
// commands
|
||||||
Bool_t CheckCommands();
|
Bool_t CheckCommands();
|
||||||
Bool_t SetParameters();
|
Bool_t SetParameters();
|
||||||
|
|
||||||
Bool_t ExecuteContours();
|
Bool_t ExecuteContours();
|
||||||
Bool_t ExecuteFitRange(UInt_t lineNo);
|
Bool_t ExecuteFitRange(UInt_t lineNo);
|
||||||
@@ -194,6 +194,7 @@ class PFitter
|
|||||||
|
|
||||||
Double_t MilliTime();
|
Double_t MilliTime();
|
||||||
|
|
||||||
|
PDoubleVector ParamRound(const PDoubleVector &par, const PDoubleVector &err, Bool_t &ok);
|
||||||
std::string GetCPUInfo();
|
std::string GetCPUInfo();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user