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

Comparing UserCode/kiesel/plotTree/ewkFakeRate.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 < Styles.tdrStyle()
9 > style = Styles.tdrStyle()
10 > style.SetOptLogy(0)
11 > ROOT.TGaxis.SetMaxDigits(3)
12 > import os
13  
14   import ConfigParser
15   axisConf = ConfigParser.SafeConfigParser()
# Line 31 | Line 34 | def divideDatasets( d1, d2, label, unit
34                  hist.SetLineWidth(2)
35                  ratioHists.append( hist )
36  
37 <        ratioHists[0].Divide( ratioHists[1] )
37 >        #ratioHists[0].Divide( ratioHists[1] ) # normal division
38 >        ratioHists[0].Divide( ratioHists[0], ratioHists[1], 1, 1, "B" ) # division using bayes theorem
39          ratioHists[0].SetTitle(";%s%s;%s/%s"%(label,unit,d1.label,d2.label))
40          return ratioHists[0]
41  
42  
43 < if True:
43 > if __name__ == "__main__":
44          arguments = argparse.ArgumentParser( description="Simple EWK" )
45          arguments.add_argument( "--plot", default="photon.pt" )
46 <        arguments.add_argument( "--dataset", default="EWK" )
46 >        arguments.add_argument( "--input", default="EWK_V01.12_tree.root" )
47 >        arguments.add_argument( "--savePrefix", default="new" )
48          opts = arguments.parse_args()
49  
50 <        version = "07"
51 <        fileName = "slim%s_V01.%s_tree.root"%(opts.dataset, version )
50 >        ROOT.gROOT.SetBatch()
51 >        import re
52 >        # dataset name is from beginning till first '_'
53 >        slimFileName = opts.input.replace( os.path.basename(opts.input), "slim"+os.path.basename(opts.input))
54 >        dataset = re.match("slim([^_]*)_.*", slimFileName ).groups()[0]
55  
56 <        genE = Dataset( fileName, "genElectronTree", "abs(genElectron.eta) < 1.479", "e_{gen}", 3 )
57 <        recE = Dataset( fileName, "photonElectronTree", "@genElectron.size()>0 && photon[0].pixelseed < 0", "e", 2 )
58 <        gamma = Dataset( fileName, "photonTree", "@genElectron.size()>0 && photon[0].pixelseed < 0", "#gamma", 1 )
56 >
57 >        genE = Dataset( slimFileName, "genElectronTree", "1", "e_{gen}", 3 )
58 >        genE_with_match = Dataset( slimFileName, "genElectronTree", "genElectron.phi > 4", "e_{gen, match}", 1 )
59 >        gamma = Dataset( slimFileName, "photonTree", "1", "#gamma", 1 )
60 >        gamma_with_match = Dataset( slimFileName, "photonTree", "photon.genInformation == 1", "#gamma_{match}", 1 )
61  
62          label, unit = readAxisConf( opts.plot, axisConf )
63 <        h = divideDatasets( gamma, recE, label, unit )
63 >        e_match_e_reco = divideDatasets( gamma_with_match, genE, label, unit )
64 >        e_match = divideDatasets( genE_with_match, gamma, label, unit )
65  
66  
67          can = ROOT.TCanvas()
68          can.cd()
69          can.SetLogy(0)
70  
71 +        datasetLabel = ROOT.TPaveText(.4,.9,.6,.98, "ndc")
72 +        datasetLabel.SetFillColor(0)
73 +        datasetLabel.SetBorderSize(0)
74 +        datasetLabel.AddText( dataset )
75 +
76 +
77 +        e_match_e_reco.GetYaxis().SetTitle("#varepsilon_{match}#upointf_{e_{gen}#rightarrow#gamma}")
78 +        e_match_e_reco.Draw("e")
79 +        datasetLabel.Draw()
80 +        can.SaveAs("plots/%sEfficiencyFakeRate.pdf"%dataset)
81 +        e_match.GetYaxis().SetTitle("#varepsilon_{match}")
82 +        e_match.Draw("e")
83 +        datasetLabel.Draw()
84 +        can.SaveAs("plots/%sEfficiency.pdf"%dataset)
85 +
86 +        h = e_match_e_reco.Clone("fakerate")
87 +        h.GetYaxis().SetTitle("f_{e_{gen}#rightarrow #gamma}")
88 +
89 +        h.Divide( e_match )
90 +        #h = divideDatasets( gamma, recE, label, unit )
91 +
92 +
93          yutaro = h.Clone("yutaro")
94 <        yutaro.SetBinContent(1,0.0196)
95 <        yutaro.SetBinError(1,0.0004)
96 <        yutaro.SetBinContent(2,0.0198)
97 <        yutaro.SetBinError(2,0.0006)
98 <        yutaro.SetBinContent(3,0.0202)
99 <        yutaro.SetBinError(3,0.0002)
100 <        yutaro.SetBinContent(4,0.0180)
101 <        yutaro.SetBinError(4,0.0004)
102 <        yutaro.SetBinContent(5,0.0162)
103 <        yutaro.SetBinError(5,0.0006)
104 <        yutaro.SetBinContent(6,0.0148)
105 <        yutaro.SetBinError(6,0.0010)
94 >        yutaro.SetBinContent(1,0.0131)
95 >        yutaro.SetBinError  (1,0.0004)
96 >        yutaro.SetBinContent(2,0.0146)
97 >        yutaro.SetBinError  (2,0.0002)
98 >        yutaro.SetBinContent(3,0.0148)
99 >        yutaro.SetBinError  (3,0.0001)
100 >        yutaro.SetBinContent(4,0.0111)
101 >        yutaro.SetBinError  (4,0.0002)
102 >        yutaro.SetBinContent(5,0.0111)
103 >        yutaro.SetBinError  (5,0.0004)
104 >        yutaro.SetBinContent(6,0.0085)
105 >        yutaro.SetBinError  (6,0.0005)
106          yutaro.SetLineColor(2)
107          yutaro.SetMarkerColor(2)
108  
# Line 78 | Line 111 | if True:
111          h.Draw("e")
112          yutaro.Draw("same e0")
113  
114 <        can.SaveAs("pt_fake_new.pdf")
114 >        leg = myLegend(.5,.70,.95,.92)
115 >        leg.AddEntry( h, h.GetYaxis().GetTitle(), "lp")
116 >        leg.AddEntry( yutaro, "Yutaro's f_{e#rightarrow#gamma}", "lp" )
117 >        leg.SetBorderSize(1)
118 >        leg.Draw()
119 >
120 >        datasetLabel.Draw()
121 >
122 >
123 >        saveName = "%s_%s_%s_%s"%(h.GetYaxis().GetTitle(),dataset,opts.plot,opts.savePrefix)
124 >        saveName = saveName.replace("/","VS")
125 >        saveName = saveName.replace(" ","_")
126 >        unallowedCharacters = ["{","}","(",")","#","|","."]
127 >        for char in unallowedCharacters:
128 >                saveName = saveName.replace( char, "" )
129 >
130 >        can.SaveAs("plots/%s.pdf"%saveName)
131 >
132 >

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines