Does RooFit binned likelihood fit support variable binning?

Hi! I am trying to work with binned fits in RooFit. I have to fit the background and signal distributions of some variables(e.g. pseudorapidity) to data to get an estimate of the number of background events. To get the correct estimate all events should fall in limited range. But some other variables can have outliers or long tails in the distribution.
I want to use variable binning to avoid large number of empty bins for the variables that are not limited. Does RooFit binned fit support variable binning? How to perform it if it does?

Thanks in advance!


Yes they should support variable binning, since in RooFIt the pdf’s are represented as bin densities. If you have any issues using variable bins, please let us know



Hi! I couldn;t find a way to set variable binning for the fit. I am fitting my background to data using binned likelihood fit via RooMinimizer. How do I have to create binned model with variable likelihood to perform a binned fit?


You need to create first a variable bin data set, a RooDataHist, that you can use to create a likelihood function (a RooNLLVar).
For example:

double xbins[] = {0.,1.,3.,6.,10,20};
auto h1  = new TH1D("h1","h1",5,xbins);
for (int i = 0; i < 10000; i++) h1->Fill(gRandom->Gaus(0,5));
RooRealVar x("x","x",0,20);
RooDataHist d("data","data",x,h1);

RooRealVar m("m","m",0);
RooRealVar s("s","s",3,0,100);
RooGaussian g("g","g",x,m,s);
auto nll = g.createNLL(d);

Hi! The way I do a binned fit to data:

  1. I create histograms for background and for signal. Then I add normFactor(RooRealVar) that is applied to each bin in the signal histogram and shapeFactors(also RooRealVar) for each bin in background histogram. In this way the shape of the signal distribution would stay the same during the fit but its integral would change. Background distribution has different shapeFactor in each bin thus the form and integral would change during the fit.
  2. Then I am performing binned fit to data using RooMinimizer. During the fit normFactor and shapeFactors change in such way that the signal + background histogram fits data histogram best.
  3. I derive the final background estimate as an integral over background histogram with each bin multiplied by its shapeFactor.

The object of histogram that supports the addition of normFactor and shapeFactors to histogram bins is provided in TRooFit package that is an extension for RooFit. Unfortunately it doesn’t support variable binning and I want to move to pure RooFit.
Is there such functionality in pure RooFit to perform such binned fits? All examples on the internet on this topic show only fits by functions, but not in such way by histograms.

This is more complicated, but you can implement always your binned pdf. We have normally HIstFactory for this, but it does not support variable binning


Thanks a lot! Then I probably should stay with TRooFit. Is chi square a valid parameter to evaluate fit quality? In my case chi square over Ndof is way below 1. Is it ok for such binned fit? I also wanted to ask if there are any parameters beside chi square to evaluate such binned fit?

Chi2 test is good if the bins distribution is normal. A good variant is the one proposed by Baker-Cousins for binned likelihood fits when the bin distribution is Poisson distributed,
(see TH1::Chisquare using option L.


This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.