Home | News | Documentation | Download

Unbinned 2D fit -making projections with variable bin widths

Dear Experts,

I am trying to do an unbinned 2D fit where I create the PDFs from 2D histograms, where one of the axis of the histogram has variable bins and the other axis has uniform bins. My model looks something like:

RooHistPdf rBkg1_Pdf("rBkg1_Pdf","rBkg1_Pdf",RooArgSet(rMass,rPt),RooDataHist("rBkg_hist","rBkg_hist",RooArgList(rMass,rPt),hBkg),0);
RooHistPdf rComp_Pdf("rComp_Pdf","rComp_Pdf",RooArgSet(rMass,rPt),RooDataHist("rComp_Hist","rComp_Hist",RooArgList(rMass,rPt),hComp),order);
RooRealVar f2("f2","Number of particles",0,nEntries); 

RooAddPdf Model("Model","Extended sum templates",RooArgList(rBkg1_Pdf,rComp_Pdf),
						 RooArgList( RooConst(f1),f2,));

where f1 is fixed and only f2 is a free parameter in the fit.

But I encountered the following problems:

  1. After I fit the data and make the projection in a given rPt range with uniform rMass bins and I plot only the rBkg1_Pdf component I see there is a shift, even tho f1 is fixed. You can see this in the plots below where I compared the data with the histogram (that is use for the PDF) and what I get when i plot the component from the fit.
    How can I make this component from the fit to have the same shape as the red open bullet histogram?
  2. If I look at the other projection where I have variable bins , the fit is working, but I see the normalization is off because I have variable bins. Do you have any suggestions how can I fix this?

Thanks in advance!
Alexandra

Hi,
Can you please post your running example ? It looks to me like a bug when using variable bins.

Cheers

Lorenzo

Hi Lorenzo,

You can find my macro below. I forgot to mention in my previous post that I am using ROOT 6.18/04.
check.C (7.6 KB)

Best,
Alexandra

Thank you for the code. I need however also the input files in order to run it

Lorenzo

Hi,
I’ve sent you a message with the link to the files and the code and I hope that is ok. I can’t share them here since this data is not public.

Alexandra

Hi,
I could run your code, but let me understand better the problem.
The issue is that when plotting the background component from the fit (magenta line) is not in agreement with the underlined used histogram (red dots) ?

Cheers

Lorenzo

Hello Lorenzo,

Indeed, the difference between those two is one of the problems. The magenta component should be identical to the histogram.

Alexandra

Hi,
The normalisation of the background component (magenta line) is different than the one of the background histogram (red dot) because it contains a different background fraction.
Although the number of background events is fixed in the fit, the ratio that is equal to the number of background events to the total expected events is not fixed. So this explains this normalisation difference .
The solution is to scale down the Component pdf according to the fitted fraction. In this way you eliminate the background fraction from the plot. To do that do:

 double nExp = Model.expectedEvents(RooArgSet(rMass,rPt));
 double fBkg = Bkg_Frc/nExp;

and later when plotting the background pdf use the command option Normalisation(fBkg)

 Model.plotOn(framePt,Components(rBkg_Pdf), LineColor(kMagenta),LineWidth(2),ProjectionRange("MassWindow"),Name("Background"),Normalization(fBkg)); 

Cheers

Lorenzo

Hi,

Thank you for the answer. This indeed solved the problem.

The other issue that I have is with making the projection when the bins are not uniform. The normalization doesn’t seem to be right. For the case when I have uniform bins (right plot) I get the right values, but then if I add extra new bins with different widths (left plot), the results are different in the same pT region.

Best,
Alexandra

Hi,

What is the problem with the left plot ? Note the overall scale is different, in the case of variable bins, RooFit normalise the data to display number of events/(average bin width) and in this case is 0.169482, as shown in the y axis label.
In case of fixed bins, the normalisation is number of events/bin width and this corresponds normally to the actual number of observations / bin.

Lorenzo