Exemplo n.º 1
0
def makeEfficiency(passed, total, title, lineColor):
    if TEfficiency.CheckConsistency(passed, total):
        efficiency = TEfficiency(passed, total)
        #title = std::regex_replace(title, std::regex("\\muCandGenEtaMuons"), "tagging efficiency");
        efficiency.SetTitle(title)
        efficiency.SetStatisticOption(6)
        #TEfficiency.EStatOption.kBUniform
        efficiency.SetPosteriorMode()
        efficiency.SetLineColor(lineColor)
        return efficiency
    else:
        print(
            "makeEfficiency TEfficiency::CheckConsistency(*ptGenPtTTMuonNom, *ptGenPtTTMuonDenom) failed"
        )
        exit(1)
Exemplo n.º 2
0
                    #
                    # 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:
                    # https://root.cern.ch/doc/master/classTEfficiency.html
                    #
		    t_efficiency.SetStatisticOption(TEfficiency.kBUniform)
                    t_efficiency.SetPosteriorMode()

                # 3.
                #
                # Calculate efficiency using TGraphAsymmErrors
                # (uses a Bayesian uniform prior beta(1,1) for the efficiency with 68% CL. It handles the errors in case eff is 0 or 1)
                #
                g_efficiency = TGraphAsymmErrors(hist_eff)
                g_efficiency.Divide(hist_pass,hist_tot,"cl=0.683 b(1,1) mode")

                # Save the efficiencies in the proper dictionaries
                #
                hists[histname + "_Efficiency_" + append_str] = hist_eff
                tefficiencies[histname + "_Efficiency_" + append_str] = t_efficiency
                graphs[histname + "_Efficiency_" + append_str + "_graph"] = g_efficiency