I have two single-bin histograms that I’d like to calculate the efficiency from (i.e. one is numerator, one is denominator).
The histograms exist and are filled, and I try to get the efficiency like this:
def print_single_ratio(myFile, hist_name1, hist_name2): myFile.cd(); hist1 = myFile.Get(hist_name1) print hist1.GetBinContent(1) myFile.cd(); hist2 = myFile.Get(hist_name2) print hist2.GetBinContent(1) ratio = ROOT.TEfficiency(hist1, hist2) ratio.Draw() paintedgraph = ratio.GetPaintedGraph() x = ROOT.Double() y = ROOT.Double() paintedgraph.GetPoint(1, x, y) print x, y, paintedgraph.GetErrorYhigh(),paintedgraph.GetErrorYlow()
but I get the following output and error:
52.0 7706.0 Info in <TCanvas::MakeDefCanvas>: created default TCanvas with name c1 Traceback (most recent call last): File "EffCalc.py", line 18, in <module> print_single_ratio(data_file, "Event_N_after_bjet_veto_mumumu","Event_N_after_bjet_veto_mumu", my_options) File "/mnt/lustre/epp_scratch/atlas/sm442/install/MC11c_Analysis/histos/plot_utils.py", line 158, in print_single_ratio paintedgraph.GetPoint(1, x, y) ReferenceError: attempt to access a null-pointer
I’m not sure if this is more to do with TEfficiency or PyROOT, so apologies if it’s in the wrong category.