Display fit results on plot when using TMinuit

Hi,

When I use TH1::Fit I can plot the histogram, the function I use for the fit and the associated parameters with their uncertainties. Can I do the same thing when I fit with TMinuit? (I’m using my custom-made “fcn” minimization routine, not sure if this is relevant)

Edit: I assume that I can always set the function’s parameters & uncertainties to the vales obtained by the fit (accessed by gMinuit->GetParameter and gMinuit->GetParError) and superimpose the function on the histogram. However, I do not know how to put all this information in the Stat box. There must be a simple way… :-k

Thanks.

–Christos

In case you fit a histogram directly with Minuit, you can add
the TF1 function to the histogram list of functions with:
TF1 *f1; your function with the fit parameters/errors
h->GetListOfFunctions(0->Add(f1);
When drawing the histogram, you should see teh function and teh fit parameters in the “stats” box if you have set the option via
gStyle->SetOptFit();

Note that if you use the option “U” from TH1::Fit, this should be automatic.

Rene

Hi Rene,

I do not fit the histogram directly with the TH1::Fit method, I use TMinuit, as in Ifit.C, or minexam.C.

I did try to use the GetListOfFunctions()->Add() method, as suggested, but my problem is that I do not know how to add the exact copy of the function that TMinuit used in the fit. Instead, I end up using things like gMinuit->GetParameter and gMinuit->GetParError, gMinuit->mnstat (to gain access to the fit’s results) and then TF1::SetParameter, TF1::SetParError, TF1::SetChisquare, etc (to set the functions’s parameters before I draw it on the canvas), since the “main program” and FCN do not seem to use the same set of parameters (even though I’ve made sure they are using the same function pointer). I was wondering if there was an automated way.

Thanks.

–Christos

Setting the TF1 parameters and adding the function to the histogram list of functions should be OK.
I will need a short running piece of code to understand what could be your problem

Rene