Trying to determine when my fit fails

I posted this in the Pyroot subforum earlier, someone suggested I cross post it here.

I’m running a bunch of fits on a data set, defaulting to a Gaussian fit. However, sometimes that default fit fails to converge, in which case I would like to run a linear fit. I can’t seem to read the status of the failed fit though.

status = fit_hist.Fit("gaus","S") print "Status1? ", status.Status() if status==1: status = fit_hist.Fit("x++","S") print status.Status()

This always returns 0, no matter the outcome of the fit. I’ve also tried the .IsValid() method as well, with similar results.

FCN=4808 FROM HESSE STATUS=FAILED 11 CALLS 55 TOTAL EDM=0 STRATEGY= 1 ERROR MATRIX UNCERTAINTY 100.0 per cent EXT PARAMETER APPROXIMATE STEP FIRST NO. NAME VALUE ERROR SIZE DERIVATIVE 1 Constant -1.52751e+03 6.75455e-01 -6.47143e+01 0.00000e+00 2 Mean 1.66445e+04 1.41421e+00 1.65371e+04 0.00000e+00 3 Sigma 3.44089e-01 3.90810e+02 -5.93897e-01 0.00000e+00 Status1? 0

Any suggestions on how to properly read out a failed fit?

The other thread is here:


I am not sure I follow.
In the other post it was rightfully pointed out that 0 corresponds to False, which in this case would be appropriate since the fit fails.
Do you have a reproducer with a failing and a succeding fit?


There has been a slight confusion in the other thread -> [url= one post[/url], orson1981 presented the output of “status.IsValid()” which I interpreted as the output of “status.Status()”.

The real problem (as demonstrated in both threads) is that “status.Status()” returns 0, which means “success” while the verbose output clearly shows that it “failed”.

I’ve recently met similar problems with the default fitter which I reported here and which are still not fixed (they may be related):