Getting the status of a fit

Hi,

I want to get the status of a fit in a macro.
For this I do something like:
Int_t a=h1->Fit(…) //h1 is a histogramm

But sometimes I get a==0 but the status of the fit displayed in the fit window
says “PROBLEMS”…
One easy way to repeat this is to execute
root -l fithist.C //fithist.C from $ROOTSYS/tutorials
then I do:

root [1] Int_t a=result->Fit(“pol2”,“EL”)
FCN=2311.41 FROM MINOS STATUS=PROBLEMS 395 CALLS 537 TOTAL
EDM=9.18344e-09 STRATEGY= 1 ERROR MATRIX ACCURATE
EXT PARAMETER PARABOLIC MINOS ERRORS
NO. NAME VALUE ERROR NEGATIVE POSITIVE
1 p0 1.67396e+02 3.10162e+00 -3.52239e+00 3.55481e+00
2 p1 7.49519e+00 1.10687e+00 1.33677e+00
3 p2 -2.55591e+00 8.98743e-02 1.08404e-01

root [2] cout<<“fitresult :”<<a<<endl;
fitresult :0

How can I be shure that a fit was really successful ?

Marcus

Currently TH1::Fit returns the status of the fit by MIGRAD thats seems to be OK in your case. If a problem appears with MINOS, the information
is not available in the returned value. This could be added.
When using Minuit as a fitter, you can check gMinuit->fCstatu. This is a TString that contains the status of the fit. In your case after the fit, you can do
root > gMinuit->fCStatu
you will get something like:
(class TString)"CONVERGED " if fit is OK
or a different message otherwise.

Rene

If I do so an error happens…
I do the commands from my first example and then:

root [3] gMinuit->fCStatu
Error: Symbol gMinuit is not defined in current scope FILE:(tmpfile) LINE:1
Error: Failed to evaluate gMinuit->fCStatu*** Interpreter error recovered ***
root [4]

Is there something I should do before?

Marcus

It should be
gMinuit->fCstatu;
see TMinuit.h

Rene

Yes, gMinuit->fCstatu works - thank you!

Maybe in a later version it would be possible to get an integer back - that would be perfect…

Marcus