All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Functions | Variables
cut_metrics Namespace Reference

Functions

def get_histos
 
def get_integral
 
def main
 

Variables

tuple parser = argparse.ArgumentParser()
 

Function Documentation

def cut_metrics.get_histos (   f,
  variable,
  cut,
  names 
)

Definition at line 6 of file cut_metrics.py.

6 
7 def get_histos(f, variable, cut, names):
8  return [f.Get(variable + "_" + n + cut) for n in names]
def get_histos
Definition: cut_metrics.py:6
def cut_metrics.get_integral (   f,
  variable,
  cut,
  names 
)

Definition at line 9 of file cut_metrics.py.

9 
10 def get_integral(f, variable, cut, names):
11  return sum([h.Integral() for h in get_histos(f, variable, cut, names)])
def get_histos
Definition: cut_metrics.py:6
def get_integral
Definition: cut_metrics.py:9
def cut_metrics.main (   args)

Definition at line 12 of file cut_metrics.py.

12 
13 def main(args):
14  f = ROOT.TFile(args.input)
15  effs = []
16  puritys = []
17 
18  signal_base = get_integral(f, args.variable, args.base_cut, args.signal_names)
19  background_base = get_integral(f, args.variable, args.base_cut, args.background_names)
20 
21  effs.append(1.)
22  puritys.append(signal_base / (signal_base + background_base))
23 
24  for cut in args.cuts:
25  this_signal = get_integral(f, args.variable, cut, args.signal_names)
26  this_background = get_integral(f, args.variable, cut, args.background_names)
27  this_eff = this_signal / signal_base
28  this_purity = this_signal / (this_signal + this_background)
29  effs.append(this_eff)
30  puritys.append(this_purity)
31 
32  effs = array('d', effs)
33  puritys = array('d', puritys)
34  xvals = array('d', range(len(effs)))
35 
36  g_eff = ROOT.TGraph(len(effs), xvals, effs)
37  g_eff.SetName("Efficiency")
38  g_eff.SetTitle("Efficiency")
39 
40  g_purity = ROOT.TGraph(len(puritys), xvals, puritys)
41  g_purity.SetName("Purity")
42  g_purity.SetTitle("Purity")
43 
44  canvas = ROOT.TCanvas("canvas", "Canvas", 250,100,700,500)
45 
46  g_eff.Draw("AL")
47  g_eff.SetLineColor(ROOT.kGreen)
48  util.style(args, g_eff)
49  for i in range(len(effs)):
50  g_eff.GetXaxis().SetBinLabel(g_eff.GetXaxis().FindBin(i), args.names[i])
51  g_purity.Draw("SAME")
52  g_purity.SetLineColor(ROOT.kRed)
53 
54  legend = ROOT.gPad.BuildLegend(0.75,0.75,0.95,0.95,"")
55  canvas.Update()
56 
57  util.wait(args)
58  util.write(args, canvas)
def get_integral
Definition: cut_metrics.py:9
def style
Definition: util.py:237
def write
Definition: util.py:23
def wait
Definition: util.py:19

Variable Documentation

tuple cut_metrics.parser = argparse.ArgumentParser()

Definition at line 60 of file cut_metrics.py.