TH1::Divide with binomial error


I hope this is not too simple of a question but I have looked for the solution on the forum already and could not find it. I am making an efficiency plot with very low statistics in Root Version 5.34/03. A basic synopsis of my code follows:

TH1F* hist_numerator = new TH1F("blah…
TH1F* hist_denominator = new TH1F("blah…
TH1F* hist_efficiency = new TH1F("blah…

if(passcut) hist_numerator ->Fill(Value)

hist_efficiency>Divide(hist_numerator, hist_denominator,1,1,“b”);

I would now expect to have hist_efficiency filled with the binomial errors however when I check particular bins in which I expect problematic cases the error is not what I would expect. For example if hist_numerator ->GetBinContent(bin) is 0 and hist_numerator ->GetBinContent(bin) is 1 the standard binomial error would give 0 with the confidence interval (0,0.975) however I get 0 with error 0. I realize that the error is by default symmetric so one value must be chosen. I do not think it is as simple as the minimum being chosen. For another example: numerator=1 and denominator=2 I get 0.5 \pm 0.3535 where I would expect the symmetric 0.5 \pm 0.4874.

I know the proper way to do this would be with the more complicated method like TBinomialEfficiencyFitter but my situation is complicated because I must average hundred of these distributions. I can go more into detail about my plans if it would be helpful but for now I would just like a reasonable nonzero error. Also, I am getting my expected values from so I hope these are correct.

Thank you very much,


See the TEfficiency class

Best Regards

Thank you Lorenzo,

This is exactly the class I want. I can now make efficiency plots for all units. I would now like to combine them to make one efficiency plot which represents the average/typical unit. They will not necessarily all have the same number of entries but should represent the same underlying efficiency distribution. Unless I am misreading the documentation I should be using Combine() not Add() to accomplish this. Combine is not really straight forward since it uses TGraphAsymmErrors and TCollection not TEfficiency. I can’t seem to find any examples showing the syntax of how to do this properly. Could you please provide a skeleton for how this is done?

Thank you for your time,