Fit result of 2D histogram

Hi!

I have a short question and unfortunately I didn’t find the answer: I want to fit a THF2 with a TF2 function (2D Gaussian in my case; works fine). For TF1 I can use TFitResults to get chi square and thus evaluate the goodness. Is there anything like that for TF2?

This is the result of the fit in the terminal. I don’t know what the values for FCN and EDM mean and if they have any information.

FCN=19.7874 FROM MIGRAD STATUS=CONVERGED 240 CALLS 241 TOTAL
EDM=8.81124e-09 STRATEGY= 1 ERROR MATRIX ACCURATE
EXT PARAMETER STEP FIRST
NO. NAME VALUE ERROR SIZE DERIVATIVE
1 p0 1.00770e+00 9.69100e-02 1.59399e-04 7.73834e-04
2 p1 -1.02618e+01 1.51598e+00 1.49451e-03 -5.51613e-05
3 p2 7.75229e+00 9.37208e-01 8.94902e-04 -1.20381e-04
4 p3 -1.01909e+01 1.53129e+00 1.49246e-03 5.39552e-06
5 p4 7.75004e+00 9.54952e-01 8.95193e-04 -1.32446e-05
6 p5 6.99280e-03 7.94158e-03 1.35356e-05 -1.44214e-02

Thank you very much for your time!!!

ROOT_version: 5.32.34

Hi,

As exactly in the 1D case you can use the TFitResult class. If h2 is a pointer to your 2d- histogram (e.g. TH2F) and f2 a pointer to your 2D function (TF2) , by using the fit option S you will get returned a pointer to a TFitResult class.

auto result = h2->Fit(f2,"S");
double chiSquare = result->Chi2(); 

For the other question, FCN means the function value that is minimised and in a chi2 fit is the chi2 value. EDM is the expected distance from the minimum, and it is the criteria to judge if the minimization converged. When it becomes very small ( ~< 1.E-6) the minimisation has converged.

Best Regards

Lorenzo

1 Like

Thank you! That was what I have been looking for.

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