# TH1F Divide, efficiency = 1 gives zero error

Good evening,
I’m doing a division between two TH1F to estimate an efficiency:

``````h_TrigEfficiency_15->Divide(h_passedTrigger15_NUM, h_passedTrigger15_DEN, 1, 1, "B");
``````

These are binned histograms, and each bin has the name of a trigger.
There is a problem in the cases in which the division is 1, and it gives error 0.

On ROOT site I found this:

## [◆ ]Divide() [2/3]

[Bool_t]TH1::Divide ( const [TH1]* h1,const [TH1] * h2,[Double_t]c1 = `1`,[Double_t]c2 = `1`,[Option_t]* option = `""`)

Replace contents of this histogram by the division of h1 by h2.

`this = c1*h1/(c2*h2)`

If errors are defined (see [TH1::Sumw2]), errors are also recalculated Note that if h1 or h2 have Sumw2 set, Sumw2 is automatically called for this if not already set. The resulting errors are calculated assuming uncorrelated histograms. However, if option =“B” is specified, Binomial errors are computed. In this case c1 and c2 do not make real sense and they are ignored.

IMPORTANT NOTE: If you intend to use the errors of this histogram later you should call Sumw2 before making this operation. This is particularly important if you fit the histogram after [TH1::Divide]

Please note also that in the binomial case errors are calculated using standard binomial statistics, which means when b1 = b2, the error is zero. If you prefer to have efficiency errors not going to zero when the efficiency is 1, you must use the function [TGraphAsymmErrors::BayesDivide], which will return an asymmetric and non-zero lower error for the case b1=b2.

The function return kFALSE if the divide operation failed

Reimplemented in [TProfile], [TProfile2D], and [TProfile3D].

Definition at line [2947] of file [TH1.cxx].

So I tried to use TGraphAsymmErrors and BayesDivide. BayesDivide doesn’t exist for TH1F and I cant’ make a binned TGraphAsymmErrors as I make a TH1F. Any suggestion to fix this?

Hi Bernardo,

Welcome to the ROOT community!

If I understand correctly, and please correct me if I am wrong, the problem is that when calculating an efficiency by dividing two histograms, when the efficiency is 1, the error is 0.
This makes physical sense, since the uncertainty cannot be other than 0 since at most the efficiency is 1, by definition: am I perhaps misunderstanding the issue?

I add in the loop @moneta and @jonas , in case they have more insights.

Best,
D

Hello,

When using `TH1::Divide` the uncertainty in the division of the two histogram is computed using the normal approximation. In this case when the efficiency=1 , the uncertainty is zero.
If you want to compute frequentist or bayesian intervals on the efficiency, you should use the
`TEfficiency` class. In this case you will get a full confidence interval computation in the efficiency using your preferred statistical method. See the TEfficiency documentation.

Best regards

Lorenzo

Thanks for all the replies. In fact I hadn’t explained myself well and my question wasn’t clear. What I was actually looking for is exactly what TEfficiency does.

Thanks everyone for the clarifications
​Bernardo

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