Problem with ROOT::Fit::FitResult::Chi2()

Dear experts,
It seems there is a bug in ROOT::Fit::FitResult::Chi2() method in root versions 6-30-01, 6-30-02.
To show it, I am attaching the tutorial combinedFit.C with one additional line

cout<<" Chi2 = "<<result.Chi2()<<endl;

The output is:

Processing combinedFit.C...
****************************************
Minimizer is Minuit2 / Migrad
MinFCN                    =      131.104
NDf                       =          115
Edm                       =  2.11602e-08
NCalls                    =          225
Par_0                     =       5.5396   +/-   0.0354094
Par_1                     =      4.66089   +/-   0.050106
Par_2                     =   -0.0514037   +/-   0.00108539      (limited)
Par_3                     =      77.2733   +/-   3.93105         (limited)
Par_4                     =           30                         (fixed)
Par_5                     =        4.864   +/-   0.243005
 Chi2 = -1

You can see, that result.Chi2() returns -1 while it returns the correct value 131.104 in older root versions.
combinedFit.C (4.0 KB)

I guess @moneta can help.

Hi,

Thank you for reporting this issue. I have found the origin of the problem and I will submit a fix for this. As workaround use result.MinFcnValue() to get the chi2 value.

Best regards

Lorenzo

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.

This has been fixed after merging [math][fitter] Fix return chi2 when fitting user provided chi2 functions by lmoneta · Pull Request #14359 · root-project/root · GitHub