Calculating efficiencies in RooFit


I’m looking for some practical advice on how to proceed with the following situation:

I have one RooDataSet which contains the values of a set of observables (x1,x2,x3…) per event. From this RooDataSet I now want to calculate an efficiency as a function of the observables: e(x1,x2,x3…) .
I make a second RooDataSet which contains only the events that passed a selection criterion.
So far, so good.

My question now is:
Given these two RooDataSets: One containing all events, and one containing the events passing the selection, can I obtain (and fit) the efficiency as a function of the observables in the data sets in a simple way using RooFit?

I’ve been looking at the RooEfficiency example in the tutorial package (rf701) but I don’t find it clear if I can use it or not for this case.

Of course I could just go ahead and do it all in old-school ROOT, but then I would lose the functionality of RooFit.


Hi Aras,

If you have two datasets that contain the ‘passed’ and ‘failed’ events
(this is not exactly what you have, but you might be able to find a way
to get there from your present datasets), then the rest is straightforward

RooCategory cut(“cut”,“cut”) ;
cut.defineType(“reject”,0) ;
cut.defineType(“accept”,1) ;

RooDataSet data(“data”,“data”,x,Index(cut),Import(“accept”,adata),Import(“reject”,rdata)) ;

where x is your observable and adata and rdata are the events with the accepted and rejected events respectively. The dataset that is constructed in the above code can be used in the rf701 example code.


1 Like

Hi Wouter,
many thanks for the fast reply, it really saved my day!
While I have you “on the line”, could you tell me if there is a method to remove events from an existing RooDataSet?


…on a related note, I’m also wondering if there is a way to plot the efficiency in two dimensions, i.e. is there is a way to reproduce the behaviour of the “Efficiency(cut)”-option from RooDataSet::plotOn()?