BayesDivide() issues

Fellow ROOT users

My latest project has been testing various electronID efficiencies, ‘cheating’ using known electronID methods and the actual generated electrons from the Monte Carlo. I have tried using BayesDivide() on the histograms I generated to get the efficiencies:

This is essentially what I’m doing:

electronGenPt->Fill();

if (!electronID_1) continue;

electronPt->Fill();

idEfficiency->BayesDivide(electronPt, electronGenPt, “w”);

No other cuts are applied at the moment.

electronGenPt and electronPt are TH1D histograms. idEfficiency is a TGraphAsymmError graph.

I keep getting the error:

Error in TGraphAsymmErrors::BayesDivide: Pass histogram has not been filled with weights = 1

Does anyone have any idea why the weights wouldn’t be one? Both histograms have the same number of bins (100). Thanks a lot guys!

Cheers!

Hi,
the statistical method of BayesDivide require weight all =1, i.e. assumes that the histogram represent counts.
Otherwise the method would require a model for the weights. This case is not supported in BayesDivide.
However, you you have weights which represents just a scaling factor, just calculate the efficiency on the unweighted histograms.

You can eventually use TH1::Divide with option “B”. In this case weighted histograms are supported

Best Regards

Lorenzo

Hi Lorenzo,

I have a similar issue:

I have data and simulation for a cosmic ray energy spectrum. As is typical in cosmic ray physics, the simulation is generated to an E^-1 spectrum (ie flat in log(energy)) and therefore needs to be weighted, event-by-event, to the cosmic ray energy spectrum, for comparison to the data. So each event is assigned a non-integer weight in the original histogram. (For example, h->Fill(param,weight).)

Now, I want to make efficiencies from two such histograms, call them hall before a cut and hpass after the cut: I want heff=hpass/hall. Additionally, I have many bins where hpass = hall, so I need correct errors for eff = 1. Now, I was obviously thinking to use the following:

TGraphAsymmErrors heff(hpass, hall,“cl=0.683 b(1,1) mode”);

which I read is the old BayesDivide option, but the documentation still seems to say that it’s going to give me incorrect errors for these weighted histos. Is that true, or has this option been updated? And if not, is there a different option that would work? The hist->Divide() options do not give correct errors for 100% efficiency, and the TEfficiency class options also claim not to support weighted histograms. (TEfficiency supports combining histos by weight, which obviously won’t work in this case. Each event has its own individual weight.)

thanks for any suggestions

Hi,
Actually the new version of TEfficiency supports now weighted histograms in the case of Bayesian statistics. The same code is also used when calling TGraphAsymmErrors::Divide.
However, I am not 100% confident of the correctness of the method and it could be that in some case the errors are not correct.
If your efficiency is not zero or 100%, it is maybe better to use the non-bayesian method (which is the same used in TH1::Divide).
I would be interested to see your two histograms. Please send them to me so I can check the method.

Best Regards

Lorenzo