1 |
#! /usr/bin/env python2
|
2 |
# -*- coding: utf-8 -*-
|
3 |
import ROOT
|
4 |
ROOT.gSystem.Load("libTreeObjects.so")
|
5 |
import argparse
|
6 |
from multiplot import *
|
7 |
from treeFunctions import *
|
8 |
import Styles
|
9 |
import ratios
|
10 |
Styles.tdrStyle()
|
11 |
import os
|
12 |
|
13 |
import ConfigParser
|
14 |
axisConf = ConfigParser.SafeConfigParser()
|
15 |
axisConf.read("axis.cfg")
|
16 |
|
17 |
if __name__ == "__main__":
|
18 |
arguments = argparse.ArgumentParser( description="Simple EWK" )
|
19 |
arguments.add_argument( "--plot", default="photon.pt" )
|
20 |
arguments.add_argument( "--input", default="slimEWK_V01.12_tree.root" )
|
21 |
arguments.add_argument( "--savePrefix", default="new" )
|
22 |
opts = arguments.parse_args()
|
23 |
|
24 |
ROOT.gROOT.SetBatch()
|
25 |
|
26 |
slimFileName = opts.input.replace( os.path.basename(opts.input), "slim"+os.path.basename(opts.input))
|
27 |
|
28 |
genE = Dataset( opts.input, "susyTree", "Max$(abs(genElectron.eta)) < 1.4442 && @genElectron.size() > 0", "e_{gen}", 1 )
|
29 |
recE = Dataset( slimFileName, "photonElectronTree", "photon.genInformation==1", "e", 2 )
|
30 |
gamma = Dataset( slimFileName, "photonTree", "photon.genInformation==1", "#gamma", 3 )
|
31 |
|
32 |
multihisto = Multihisto()
|
33 |
|
34 |
label, unit = readAxisConf( opts.plot, axisConf)
|
35 |
|
36 |
histForRatio = {}
|
37 |
|
38 |
for dataset in [genE, recE, gamma]:
|
39 |
if dataset.label == "e_{gen}":
|
40 |
try:
|
41 |
plot = opts.plot.replace("photon","genElectron")
|
42 |
except:
|
43 |
plot = opts.plot
|
44 |
else:
|
45 |
plot = opts.plot
|
46 |
|
47 |
hist = createHistoFromTree( dataset.tree, plot, "weight*(%s)"%(dataset.additionalCut), firstBin=10, lastBin=200 )
|
48 |
hist.SetTitle(";%s%s;Entries"%(label,unit))
|
49 |
hist.SetLineColor( dataset.color )
|
50 |
hist.SetLineWidth(2)
|
51 |
multihisto.addHisto( hist, dataset.label )
|
52 |
histForRatio[dataset.label] = hist
|
53 |
|
54 |
can = ROOT.TCanvas()
|
55 |
|
56 |
hPad = ROOT.TPad("hPad", "Histogram", 0, 0, 1, 1)
|
57 |
#hPad = ROOT.TPad("hPad", "Histogram", 0, 0.2, 1, 1)
|
58 |
hPad.cd()
|
59 |
multihisto.Draw("hist")
|
60 |
|
61 |
ratioPad = ROOT.TPad("ratioPad", "Ratio", 0, 0, 1, 0.2)
|
62 |
ratioPad.cd()
|
63 |
ratioPad.SetLogy(0)
|
64 |
ratioGraph = ratios.RatioGraph(histForRatio["e"], histForRatio["e_{gen}"])
|
65 |
ratioGraph.draw(ROOT.gPad, yMin=0.5, yMax=1.5, adaptiveBinning=False, errors="x")
|
66 |
ratioGraph.hAxis.SetYTitle( "e/e_{gen}")
|
67 |
ratioGraph.graph.Draw("same p")
|
68 |
|
69 |
can.cd()
|
70 |
hPad.Draw()
|
71 |
#ratioPad.Draw()
|
72 |
can.SaveAs("plots/%s_%s_%s.pdf"%(opts.input[0:5],opts.plot.replace(".",""),opts.savePrefix))
|
73 |
del can
|
74 |
|