TBackCompFitter to obtain likelihood curve

Dear all,

I’ve perform a fit to data with 4 inputs parameters (MC) using TFractionFitter. After doing that, I was trying to retrieve the log likelihood as a function of one of my parameters, specifically, my signal MC. So I added the following lines:

Int_t iNoSteps = 50;
TGraph * gr = new TGraph(iNoSteps);
unsigned int par = 3 ;
TBackCompFitter fFitter = (TBackCompFitter)TVirtualFitter::GetFitter();
double xmin = 0.0;
double xmax = 1.0;
fFitter->SetErrorDef(1);
fFitter->Scan(par,gr,xmin,xmax);
TCanvas* cv0 = new TCanvas();
graph->Draw(“APL”);

But it always appear a message of segmentation fault. I’ve also tried the other command TBackCompFitter::Contour, and it also crashes. When I use other commands it works:

cout<GetNumberTotalParameters()<<endl;
cout<GetNumberFreeParameters()<<endl;

cout<GetParError(1)<<endl;
cout<GetParameter(1)<<endl;
Double_t amin,edm,errdef;
Int_t nvpar,nparx;
fFitter->GetStats(amin,edm,errdef,nvpar,nparx);
cout<<endl;
cout<<amin<<endl;

I would like to know what is wrong with my arguments for Scan, or what do you suggest to get that function.

Many thanks in advance,

cheers,

Cesar

Hi,

The TFractionFitter class does not use internally the new ROOT::Math::Fitter (and TBackCompFitter) but the old class TFitter which is based directly on TMinuit.
In that case if you want to make a scan of the likelihood or the contour you can use either gMinuit or the TMInuit instance from ((TFitter*)TVirtualFitter::GetFitter())->GetMinuit()

For the contour you can call TMinuit::Contour and for scan you can call the command “SCAN” via TMinuit::mnexcm or you can also use in this case TVirtualFitter::ExecuteCommand(“SCAN”, args, narg);

Best Regards

Lorenzo

Hi Lorenzo,
thanks for your reply, but I have a question related with the plot of the log likelihood curve, I want to study this curve to perform a convolution with a Gaussian function to take into account systematics uncertainties.

During the fit procedure to data I used the following constraints:

fit->Constrain(2,0.01,0.99);
fit->Constrain(3,0.01,0.99);
fit->Constrain(4,0.0,0.99);//signal , parameter of interesr

fit->GetFitter()->SetParameter(0,"SB",hBcharme->Integral()*lumiratiog/sumd,0.01,0.,1.);

fit->GetFitter()->FixParameter(0);

After fitting my histograms, I called

TMinuit Mintest =( (TFitter)TVirtualFitter::GetFitter() )->GetMinuit();
Int_t ierflg =0;
Mintest->mncomd(“SCAN 3 100 0.0 1.00”,ierflg);// signal, 100points, fractions between 0 and 1
TGraph gr = (TGraph)Mintest->GetPlot();
gr->Draw(“APL”);

but the returned plot does not look like a log likelihood distribution (asymmetric parabola )

I would thank any suggestion to get this plot.

Best regards,

Cesar

I forgot to tell that in the plot does not seem to be a maximum, at least not at the fraction predicted from TFractionFitter.

thanks!!

Hi,

It should work and plot a scan of the log-likelihood function. Are you sure you have used the right parameter index and parameter range ? I think in TMinuit the parameter number starts from 1.
Are you sure also that the fit converged to a minimum ?

Lorenzo