tfile = TFile.Open(infile) # ____________________________________________________________________________ # emtf_eff_vs_genpt_l1pt20 hname = "emtf_eff_vs_genpt_l1pt20" h1a_denom = tfile.Get(hname + "_denom") h1a_numer = tfile.Get(hname + "_numer") h1b_denom = tfile.Get(hname2026_f(hname) + "_denom") h1b_numer = tfile.Get(hname2026_f(hname) + "_numer") print h1a_denom.GetEntries(), h1a_numer.GetEntries() print h1b_denom.GetEntries(), h1b_denom.GetEntries() h1a_eff = TEfficiency(h1a_numer, h1a_denom) h1a_eff.SetStatisticOption(0) # kFCP h1a_eff.SetConfidenceLevel(0.682689492137) # one sigma h1a_eff.SetMarkerColor(632) # kRed h1a_eff.SetLineColor(632) # kRed h1a_eff.SetLineWidth(2) h1b_eff = TEfficiency(h1b_numer, h1b_denom) h1b_eff.SetStatisticOption(0) # kFCP h1b_eff.SetConfidenceLevel(0.682689492137) # one sigma h1b_eff.SetMarkerColor(600) # kBlue h1b_eff.SetLineColor(600) # kBlue h1b_eff.SetLineWidth(2) gr = h1a_eff.CreateGraph() gr.Draw("ap") frame = gr.GetHistogram() frame = frame.Clone(hname + "_frame")
hist_eff_fake_scaled.SetName(eff_fake_scaled_name) hists[eff_QMisID_name] = hist_eff_QMisID hists[eff_fake_scaled_name] = hist_eff_fake_scaled # ********************************************************************************************************************************* # 2. # The TEfficiency class handles the special cases not covered by TH1::Divide # t_efficiency = None if TEfficiency.CheckConsistency(hist_pass, hist_tot,"w"): t_efficiency = TEfficiency(hist_pass, hist_tot) t_efficiency.SetName(histname + "_TEfficiency_" + append_str) t_efficiency.SetConfidenceLevel(0.683) # Use TEfficiency, with the frequentist Clopper-Pearson confidence interval at XX% CL (set before) # (this handles the eff = 0, 1 case) # # DOES NOT SEEM TO WORK FOR WEIGHTED HISTOGRAMS --> IT REDUCES TO THE NORMAL APPROX # #t_efficiency.SetStatisticOption(TEfficiency.kFCP) # # Use TEfficiency, with the Bayesian uniform prior at XX% CL (set before) # (This is the same as the TGraphAsymmErrors below) # # In order to get the same value for efficiency as in a frequentist approach (as from TH1::Divide("B")), # the MODE should be used as an estimator. This works as long as a uniform prior is chosen. # # Please refer to the TEfficiency class docs for details: