ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/kiesel/plotTree/ewkFakeRate.py
Revision: 1.1
Committed: Fri May 3 08:56:35 2013 UTC (12 years ago) by kiesel
Content type: text/x-python
Branch: MAIN
Log Message:
added plotting helpers (ugly now, but only for saving)

File Contents

# Content
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 Styles.tdrStyle()
10
11 import ConfigParser
12 axisConf = ConfigParser.SafeConfigParser()
13 axisConf.read("axis.cfg")
14
15 def divideDatasets( d1, d2, label, unit ):
16 # d1, d2 are multiplot.Datasets (own definition)
17 ratioHists = []
18 for dataset in [d1, d2]:
19 if dataset.label == "e_{gen}":
20 try:
21 plot = opts.plot.replace("photon","genElectron")
22 except:
23 plot = opts.plot
24 else:
25 plot = opts.plot
26
27 yutarosBinning = [ 25, 35, 40, 50, 60, 80, 100 ]
28 hist = createHistoFromTree( dataset.tree, plot, "weight*(%s)"%(dataset.additionalCut), nBins=yutarosBinning)
29 hist.SetTitle(";%s%s;Entries"%(label,unit))
30 hist.SetLineColor( dataset.color )
31 hist.SetLineWidth(2)
32 ratioHists.append( hist )
33
34 ratioHists[0].Divide( ratioHists[1] )
35 ratioHists[0].SetTitle(";%s%s;%s/%s"%(label,unit,d1.label,d2.label))
36 return ratioHists[0]
37
38
39 if True:
40 arguments = argparse.ArgumentParser( description="Simple EWK" )
41 arguments.add_argument( "--plot", default="photon.pt" )
42 arguments.add_argument( "--dataset", default="EWK" )
43 opts = arguments.parse_args()
44
45 version = "07"
46 fileName = "slim%s_V01.%s_tree.root"%(opts.dataset, version )
47
48 genE = Dataset( fileName, "genElectronTree", "abs(genElectron.eta) < 1.479", "e_{gen}", 3 )
49 recE = Dataset( fileName, "photonElectronTree", "@genElectron.size()>0 && photon[0].pixelseed < 0", "e", 2 )
50 gamma = Dataset( fileName, "photonTree", "@genElectron.size()>0 && photon[0].pixelseed < 0", "#gamma", 1 )
51
52 label, unit = readAxisConf( opts.plot, axisConf )
53 h = divideDatasets( gamma, recE, label, unit )
54
55
56 can = ROOT.TCanvas()
57 can.cd()
58 can.SetLogy(0)
59
60 yutaro = h.Clone("yutaro")
61 yutaro.SetBinContent(1,0.0196)
62 yutaro.SetBinError(1,0.0004)
63 yutaro.SetBinContent(2,0.0198)
64 yutaro.SetBinError(2,0.0006)
65 yutaro.SetBinContent(3,0.0202)
66 yutaro.SetBinError(3,0.0002)
67 yutaro.SetBinContent(4,0.0180)
68 yutaro.SetBinError(4,0.0004)
69 yutaro.SetBinContent(5,0.0162)
70 yutaro.SetBinError(5,0.0006)
71 yutaro.SetBinContent(6,0.0148)
72 yutaro.SetBinError(6,0.0010)
73 yutaro.SetLineColor(2)
74 yutaro.SetMarkerColor(2)
75
76 h.SetMaximum(max(h.GetMaximum(),yutaro.GetMaximum())+0.002)
77 h.SetMinimum(min(h.GetMinimum(),yutaro.GetMinimum())-0.002)
78 h.Draw("e")
79 yutaro.Draw("same e0")
80
81 can.SaveAs("pt_fake_new.pdf")