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

Functions

def main
 

Variables

tuple parser = argparse.ArgumentParser()
 

Function Documentation

def stack_spectra.main (   args)

Definition at line 6 of file stack_spectra.py.

6 
7 def main(args):
8  hists = [[util.get_tobject(args, h.lstrip("-")) for h in hlist] for hlist in args.hstack]
9  util.validate_hists(args.hstack, hists)
10  hists = [[util.resize_histo(args, h) for h in hlist] for hlist in hists]
11 
12  canvas = ROOT.TCanvas("canvas", "Canvas", 250,100,700,500)
13  hstack = ROOT.THStack()
14 
15  for i, (hlist,hnames) in enumerate(zip(hists, args.hstack)):
16  h = hlist[0]
17  if len(hlist) > 1:
18  for hadd,hname in zip(hlist[1:],hnames[1:]):
19  #if "InTime-" in hname:
20  # h.Add(hadd, 10. / 1837.)
21  if hname.startswith("-"):
22  h.Add(hadd, -1)
23  else:
24  h.Add(hadd)
25 
26  if args.area_normalize and h.Integral() > 1e-4: h.Scale(1. / h.Integral())
27  color = util.namecolors(args.names[i] if args.names else hnames[0])
28  if args.stack:
29  h.SetFillColor(color)
30  else:
31  h.SetLineColor(color)
32  h.SetLineWidth(3)
33  if args.names:
34  name = args.names[i]
35  if args.nevent_in_legend:
36  name += " (%i)" % int(h.Integral())
37  h.SetTitle(name)
38  hstack.Add(h)
39 
40  drawstr = "HIST" if args.stack else "NOSTACK HIST"
41  hstack.Draw(drawstr)
42  util.style(args, canvas, hstack)
43  if args.legend_position: legend = ROOT.gPad.BuildLegend(*(args.legend_position + [""]))
44  if args.logy:
45  canvas.SetLogy()
46 
47  box = util.draw_text(args)
48  canvas.Update()
49 
50  util.wait(args)
51  util.write(args, canvas)
def validate_hists
Definition: util.py:352
def get_tobject
Definition: util.py:47
def style
Definition: util.py:237
def write
Definition: util.py:23
auto enumerate(Iterables &&...iterables)
Range-for loop helper tracking the number of iteration.
Definition: enumerate.h:69
def namecolors
Definition: util.py:276
def wait
Definition: util.py:19
auto zip(Iterables &&...iterables)
Range-for loop helper iterating across many collections at the same time.
Definition: zip.h:295
def draw_text
Definition: util.py:62
def resize_histo
Definition: util.py:118

Variable Documentation

tuple stack_spectra.parser = argparse.ArgumentParser()

Definition at line 53 of file stack_spectra.py.