Histogram class for efficiencies?


I am wondering if it would be possible to add a class (‘TEff’ ?)
to deal with efficiency plots ?

Right now, it is a bit of effort to fill separately TH1 objects for
numerator and denominator, compute an efficiency graph using
TGraphAsymmErrors::BayesDivide(numerator, denominator)
and then call TH1::Draw for one the two histograms
(in order to set the x-Axis range and title), followed by TGraphAsymmErrors::Draw.

In my opinion, the handling of efficiency plots would be significantly simplified by a class like TEff, which would hold the numerator and denominator histograms as private data-members and provide
TEff::Fill(x,eff) // this calls denominator::Fill(x);
// numerator::Fill(x) is called only if eff > 0.5
TEff::Draw // this calls TGraphAsymmErrors::BayesDivide first,
// and then numerator::Draw + TGraphAsymmErrors::Draw

I think the implementation of TEff would actually not require very much new code - the idea would be simply to make the usage of the code already existing in ROOT more convenient to use.

N.B. The handling of efficiency plots might appear as a rather special and restricted case to you. At the moment, I am doing it quite often, however,
and it would simplify dealing with these plots significantly if a class like TEff existed.

Thank you for your consideration,



We already have

TGraphAsymmErrors(const TH1 *pass, const TH1 *total, Option_t *option)
what you request could be implemented via an option in this constructor. Comments?


Dear Rene,

thank you for pointing me to the
TGraphAsymmErrors(const TH1*, const TH1*, Option_t* = “”)

Using this constructor, the implementation of TEff::Draw would be even more simple :astonished:

I would like to keep asking for a class like TEff,
because it would allow to handle an efficiency histogram as a single object
(this would allow to create + fill a single histogram rather than two separate histogram for numerator and denominator and plot the efficiency by a simple TH1::Draw rather then drawing the numerator with option “AXIS” first and then the TGraphAsymmError on top).

For me, handling efficiency plots via a class inheriting from TH1 would have the further advantage that efficiency plots could be handled (written to file, read from file, added and drawn) in the same way then TH1Ds, TH2Ds, TProfiles,… which would allow to use the same (generic) code.
(In fact, in CMS I am using a framework which expects all classes used for plots to inherit from TH1)

Let me emphasize that I understand that the code neccessary to make the efficiency plots already exists. What I would like to ask for is to encapsulate numerator and denominator as data-members of one and the same object and make the functionality existing in TGraphAsymmError available in a class inheriting from TH1.
(TEff would be a “lean” class which implements its functionality by calling existing code - in case it is an issue of man power, I am willing to do the implementation, if you agree)



I think it will not a bad idea to have a class handling the efficiencies, which could be either constructed from 2 histograms or filled with the denominator and numerator data. This would avoid the user the need to create the two histograms.
It could have the option to be drawn using binomial errors or the bayesian method implemented in the TGraphAsymmErrors.
It would be a good occasion to improve that method which is not statistically fully correct.
In addition the class could have a Fit method to perform a correct maximum likelihood fit of the efficiencies, what currently the class TBinomialEfficiencyFitter implements. With this new class there will be no need anymore of the TBinomialEfficiencyFitter.

The name TEff I don’t like, much better TEfficiency.
Also it should probably not inherit from a TH1 but contains as data member the two histograms, one for the numerator and one for the denominator. For drawing it should draw instead as a TGraphAsymmErrors.

Best Regards