Checking the possible return values of a Fit() function (in vers 4.04/02), I perused the code and found:
in TH1::Fit(…):
Int_t fitResult = 0;
if( various input errors ) {
return 0;
}
....
fitResult = hFitter->ExecuteCommand("MIGRAD",arglist,2);
// calling at the end TMinuit::mnexcm(...)
....
return fitResult;
while in TMinuit::mnexcm(…):
*-* IERFLG is now (94.5) defined the same as ICONDN in MNCOMD
*-* = 0: command executed normally
*-* 1: command is blank, ignored
*-* 2: command line unreadable, ignored
*-* 3: unknown command, ignored
*-* 4: abnormal termination (e.g., MIGRAD not converged)
*-* 9: reserved
*-* 10: END command
*-* 11: EXIT or STOP command
*-* 12: RETURN command
So TH1::Fit returns 0 on error in TH1::Fit or when the fit succeeds.
Could this be changed (e.g. negative values for err in Th1::Fit) ?
if (fitResult != 0) {
// Abnormal termination, MIGRAD might not have converged on a
// minimum.
if (!Foption.Quiet) {
Warning("Fit","Abnormal termination of minimization.");
}
}
I’m sorry now I get it I was looking only when fitResult was 0 but I missed this checks
// - Get pointer to the function by searching in the list of functions in ROOT
gF1 = f1;
hFitter->SetUserFunc(f1);
if (!f1) { Error("Fit", "Pointer to function is null"); return 0; }
if (f1->IsZombie()) { Error("Fit", "Function is zombie"); return 0; }
npar = f1->GetNpar();
if (npar <=0) { Error("Fit", "Illegal number of parameters = %d",npar); return 0; }
// - Check that function has same dimension as histogram
if (f1->GetNdim() != GetDimension()) {
Error("Fit","Function dimension:%d does not match histogram dimension:%d",f1->GetNdim(),GetDimension());
return 0;
}
if (xxmin != xxmax) f1->SetRange(xxmin,ymin,zmin,xxmax,ymax,zmax);
// - Decode list of options into Foption
Foption_t Foption;
if (!FitOptionsMake(option,Foption)) return 0;