4 from array
import array
7 return [f.Get(variable +
"_" + n + cut)
for n
in names]
10 return sum([h.Integral()
for h
in get_histos(f, variable, cut, names)])
13 f = ROOT.TFile(args.input)
17 signal_base =
get_integral(f, args.variable, args.base_cut, args.signal_names)
18 background_base =
get_integral(f, args.variable, args.base_cut, args.background_names)
21 puritys.append(signal_base / (signal_base + background_base))
24 this_signal =
get_integral(f, args.variable, cut, args.signal_names)
25 this_background =
get_integral(f, args.variable, cut, args.background_names)
26 this_eff = this_signal / signal_base
27 this_purity = this_signal / (this_signal + this_background)
29 puritys.append(this_purity)
31 effs = array(
'd', effs)
32 puritys = array(
'd', puritys)
33 xvals = array(
'd', range(len(effs)))
35 g_eff = ROOT.TGraph(len(effs), xvals, effs)
36 g_eff.SetName(
"Efficiency")
37 g_eff.SetTitle(
"Efficiency")
39 g_purity = ROOT.TGraph(len(puritys), xvals, puritys)
40 g_purity.SetName(
"Purity")
41 g_purity.SetTitle(
"Purity")
43 canvas = ROOT.TCanvas(
"canvas",
"Canvas", 250,100,700,500)
46 g_eff.SetLineColor(ROOT.kGreen)
48 for i
in range(len(effs)):
49 g_eff.GetXaxis().SetBinLabel(g_eff.GetXaxis().FindBin(i), args.names[i])
51 g_purity.SetLineColor(ROOT.kRed)
53 legend = ROOT.gPad.BuildLegend(0.75,0.75,0.95,0.95,
"")
59 if __name__ ==
"__main__":
60 parser = argparse.ArgumentParser()
63 parser.add_argument(
"-s",
"--signal_names", type=util.comma_separated, required=
True)
64 parser.add_argument(
"-b",
"--background_names", type=util.comma_separated, required=
True)
65 parser.add_argument(
"-bc",
"--base_cut", required=
True)
66 parser.add_argument(
"-c",
"--cuts", type=util.comma_separated, required=
True)
67 parser.add_argument(
"-n",
"--names", type=util.comma_separated, required=
True)
68 parser.add_argument(
"-v",
"--variable", required=
True)
69 main(parser.parse_args())