ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/kiesel/plotTree/ewkPlots.py
(Generate patch)

Comparing UserCode/kiesel/plotTree/ewkPlots.py (file contents):
Revision 1.1 by kiesel, Fri May 3 08:56:35 2013 UTC vs.
Revision 1.2 by kiesel, Wed May 15 14:20:17 2013 UTC

# Line 6 | Line 6 | 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()
# Line 14 | Line 16 | axisConf.read("axis.cfg")
16  
17   if __name__ == "__main__":
18          arguments = argparse.ArgumentParser( description="Simple EWK" )
19 <        arguments.add_argument( "--plot", default="met" )
20 <        arguments.add_argument( "--dataset", default="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 <        version = "07"
22 <        fileName = "slim%s_V01.%s_tree.root"%(opts.dataset, version )
24 >        ROOT.gROOT.SetBatch()
25  
26 <        genE = Dataset( fileName, "genElectronTree", "abs(genElectron.eta) < 1.479", "e_{gen}", 1 )
27 <        recE = Dataset( fileName, "photonElectronTree", "@genElectron.size()>0 && photon[0].pixelseed < 0", "e", 2 )
28 <        gamma = Dataset( fileName, "photonTree", "@genElectron.size()>0 && photon[0].pixelseed < 0", "#gamma", 3 )
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:
# Line 43 | Line 49 | if __name__ == "__main__":
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 <        can.cd()
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")
50        can.SaveAs("pt_%s_new.pdf"%opts.dataset)
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  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines