1 |
nowak |
1.1 |
import ROOT
|
2 |
|
|
import sys, re, math
|
3 |
|
|
sys.path.append("/afs/naf.desy.de/user/n/nowaf/UserCode/nowaf/PythonScripts/")
|
4 |
|
|
import definitions as Def
|
5 |
|
|
import styles as Style
|
6 |
|
|
import FakeHelper as FH
|
7 |
|
|
import MakeRealTauEst_cff as RT
|
8 |
|
|
from array import array
|
9 |
|
|
|
10 |
|
|
if __name__ == "__main__":
|
11 |
|
|
|
12 |
|
|
Def.SetGlobalStyles()
|
13 |
|
|
|
14 |
|
|
fileDir = "/scratch/hh/lustre/cms/user/nowaf/2011Data/VersionII/Plots/Data_fakes_xiv/"
|
15 |
|
|
fileName = "_Fakes_xiv"
|
16 |
|
|
|
17 |
|
|
Type = "Loose3Jet" ## Loose, Tight, ""
|
18 |
|
|
|
19 |
|
|
saveToEPS = True
|
20 |
|
|
saveToPS = False
|
21 |
|
|
saveName = "plots/Data_HPS" + Type + fileName
|
22 |
|
|
|
23 |
|
|
staticRebin = 1
|
24 |
|
|
dynamicRebin = True
|
25 |
|
|
|
26 |
|
|
TrigList = []
|
27 |
|
|
#TrigList.append( 30 )
|
28 |
|
|
#TrigList.append( 60 )
|
29 |
|
|
#TrigList.append( 80 )
|
30 |
|
|
#TrigList.append( 110 )
|
31 |
|
|
#TrigList.append( 150 )
|
32 |
|
|
#TrigList.append( 190 )
|
33 |
|
|
#TrigList.append( 240 )
|
34 |
|
|
TrigList.append( 300 )
|
35 |
|
|
TrigList.append( 370 )
|
36 |
|
|
|
37 |
|
|
histDict = {}
|
38 |
|
|
histDict[ "JetPtJPT" ] = "JetTauPtJPT"
|
39 |
|
|
histDict[ "JetEtaJPT" ] = "JetTauEtaJPT"
|
40 |
|
|
histDict[ "JetEtaJPTPt20" ] = "JetTauEtaJPTPt20"
|
41 |
|
|
histDict[ "JetEtaJPTPt40" ] = "JetTauEtaJPTPt40"
|
42 |
|
|
histDict[ "JetEtaJPTPt60" ] = "JetTauEtaJPTPt60"
|
43 |
|
|
histDict[ "JetEtaJPTPt80" ] = "JetTauEtaJPTPt80"
|
44 |
|
|
histDict[ "JetEtaJPTPt100" ] = "JetTauEtaJPTPt100"
|
45 |
|
|
histDict[ "JetEtaJPTPt200" ] = "JetTauEtaJPTPt200"
|
46 |
|
|
histDict[ "JetEtaJPTPt500" ] = "JetTauEtaJPTPt500"
|
47 |
|
|
histDict[ "JetEtaJPTPtInf" ] = "JetTauEtaJPTPtInf"
|
48 |
|
|
|
49 |
|
|
################################################################
|
50 |
|
|
allHistsDict = {}
|
51 |
|
|
rootfile = ROOT.TFile.Open( fileDir + "Data" + fileName + ".root" )
|
52 |
|
|
for trig in TrigList:
|
53 |
|
|
allHistsDict[ trig ] = {}
|
54 |
|
|
dirname = "FakeRateDiJets" + Type + str( trig ) + "/"
|
55 |
|
|
for hist in histDict.keys():
|
56 |
|
|
allHistsDict[ trig ][ hist ] = rootfile.Get( dirname + hist )
|
57 |
|
|
allHistsDict[ trig ][ histDict[ hist ] ] = rootfile.Get( dirname + histDict[ hist ] )
|
58 |
|
|
|
59 |
|
|
allHistsDict[ trig ][ hist ].SetDirectory( 0 )
|
60 |
|
|
allHistsDict[ trig ][ histDict[ hist ] ].SetDirectory( 0 )
|
61 |
|
|
pass
|
62 |
|
|
pass
|
63 |
|
|
rootfile.Close()
|
64 |
|
|
|
65 |
|
|
##### temporary
|
66 |
|
|
for trig in TrigList:
|
67 |
|
|
allHistsDict[ trig ][ "JetEtaJPT" ] = allHistsDict[ trig ][ "JetEtaJPTPt20" ].Clone()
|
68 |
|
|
allHistsDict[ trig ][ "JetTauEtaJPT" ] = allHistsDict[ trig ][ "JetTauEtaJPTPt20" ].Clone()
|
69 |
|
|
for hist in [ "JetEtaJPTPt40", "JetEtaJPTPt60", "JetEtaJPTPt80", "JetEtaJPTPt100",
|
70 |
|
|
"JetEtaJPTPt200", "JetEtaJPTPt500", "JetEtaJPTPtInf"]:
|
71 |
|
|
allHistsDict[ trig ][ "JetEtaJPT" ].Add( allHistsDict[ trig ][ hist ] )
|
72 |
|
|
pass
|
73 |
|
|
for hist in [ "JetTauEtaJPTPt40", "JetTauEtaJPTPt60", "JetTauEtaJPTPt80", "JetTauEtaJPTPt100",
|
74 |
|
|
"JetTauEtaJPTPt200", "JetTauEtaJPTPt500", "JetTauEtaJPTPtInf"]:
|
75 |
|
|
allHistsDict[ trig ][ "JetTauEtaJPT" ].Add( allHistsDict[ trig ][ hist ] )
|
76 |
|
|
pass
|
77 |
|
|
pass
|
78 |
|
|
|
79 |
|
|
mergeHistDict = {}
|
80 |
|
|
for hist in histDict.keys():
|
81 |
|
|
for trig in TrigList:
|
82 |
|
|
if not hist in mergeHistDict.keys():
|
83 |
|
|
mergeHistDict[ hist ] = allHistsDict[ trig ][ hist ].Clone()
|
84 |
|
|
mergeHistDict[ histDict[ hist ] ] = allHistsDict[ trig ][ histDict[ hist ] ].Clone()
|
85 |
|
|
pass
|
86 |
|
|
else:
|
87 |
|
|
mergeHistDict[ hist ].Add( allHistsDict[ trig ][ hist ] )
|
88 |
|
|
mergeHistDict[ histDict[ hist ] ].Add(allHistsDict[ trig ][ histDict[ hist ] ] )
|
89 |
|
|
pass
|
90 |
|
|
pass
|
91 |
|
|
pass
|
92 |
|
|
|
93 |
|
|
################################################################
|
94 |
|
|
lowerBinDict = {}
|
95 |
|
|
finalListDict = {}
|
96 |
|
|
graphDict = {}
|
97 |
|
|
for hist in histDict.keys():
|
98 |
|
|
if staticRebin > 0:
|
99 |
|
|
mergeHistDict[ hist ].Rebin( staticRebin )
|
100 |
|
|
mergeHistDict[ histDict[ hist ] ].Rebin( staticRebin )
|
101 |
|
|
pass
|
102 |
|
|
if dynamicRebin:
|
103 |
|
|
lowerBinDict[ hist ] = FH.getLowerBins( mergeHistDict[ hist ], nEntries = 5 )
|
104 |
|
|
lowerBinDict[ histDict[ hist ] ] = FH.getLowerBins( mergeHistDict[ histDict[ hist ] ] , nEntries = 5 )
|
105 |
|
|
finalListDict[ hist ] = FH.mergeList( [ lowerBinDict[ hist ],
|
106 |
|
|
lowerBinDict[ histDict[ hist ] ] ] )
|
107 |
|
|
obj = array( 'd' )
|
108 |
|
|
for b in finalListDict[ hist ]:
|
109 |
|
|
obj.append( b )
|
110 |
|
|
pass
|
111 |
|
|
mergeHistDict[ hist ] = \
|
112 |
|
|
mergeHistDict[ hist ].Rebin( len( finalListDict[ hist ] ) -1 , hist , obj )
|
113 |
|
|
mergeHistDict[ histDict[ hist ] ] = \
|
114 |
|
|
mergeHistDict[ histDict[ hist ] ].Rebin( len( finalListDict[ hist ] ) -1 , \
|
115 |
|
|
histDict[ hist ] , obj )
|
116 |
|
|
pass
|
117 |
|
|
graphDict[ hist ] = ROOT.TGraphAsymmErrors()
|
118 |
|
|
graphDict[ hist ].BayesDivide( mergeHistDict[ histDict[ hist ] ],
|
119 |
|
|
mergeHistDict[ hist ] )
|
120 |
|
|
graphDict[ hist ].UseCurrentStyle()
|
121 |
|
|
|
122 |
|
|
pass
|
123 |
|
|
|
124 |
|
|
#################################################################
|
125 |
|
|
cDict = {}
|
126 |
|
|
legDict = {}
|
127 |
|
|
for hist in histDict.keys():
|
128 |
|
|
cDict [ hist ] = ROOT.TCanvas( hist , hist )
|
129 |
|
|
cDict[ hist ].cd()
|
130 |
|
|
|
131 |
|
|
#mergeHistDict[ hist ].Draw( )
|
132 |
|
|
#mergeHistDict[ hist ].SetLineWidth( 2 )
|
133 |
|
|
#mergeHistDict[ histDict[ hist ] ].Draw("sames")
|
134 |
|
|
#mergeHistDict[ histDict[ hist ] ].SetLineColor( 4 )
|
135 |
|
|
#mergeHistDict[ histDict[ hist ] ].SetLineWidth( 2 )
|
136 |
|
|
|
137 |
|
|
option = "AP"
|
138 |
|
|
graphDict[ hist ].Draw( option )
|
139 |
|
|
graphDict[ hist ].GetYaxis().SetRangeUser( 10**-6, 10**-1 )
|
140 |
|
|
graphDict[ hist ].GetYaxis().SetTitle( "fake rate" )
|
141 |
|
|
##if key in xTitleDict.keys():
|
142 |
|
|
## graph[ key ][ d ].GetXaxis().SetTitle( xTitleDict[ key ] )
|
143 |
|
|
## pass
|
144 |
|
|
graphDict[ hist ].GetXaxis().SetTitle( hist )
|
145 |
|
|
##option = "sameP"
|
146 |
|
|
##pass
|
147 |
|
|
|
148 |
|
|
##legDict[ hist ] = Style.makeLegendSimple( [ graph[ key ][ dir ],
|
149 |
|
|
## graph[ key ][ dirDiJets ],
|
150 |
|
|
## graph[ key ][ dirPre ],
|
151 |
|
|
## graph[ key ][ dirInvert ]],
|
152 |
|
|
## [ "all", "dijets", "pre", "invert MHT" ],
|
153 |
|
|
## statusDict={ "all" : "Data","dijets" : "Data", "pre" : "Data",
|
154 |
|
|
## "invert MHT" : "Data" },
|
155 |
|
|
## position = "um")
|
156 |
|
|
##legDict[ key ].Draw( "same" )
|
157 |
|
|
ROOT.gPad.SetLogy()
|
158 |
|
|
cDict[ hist ].Update()
|
159 |
|
|
pass
|
160 |
|
|
|
161 |
|
|
if saveToPS:
|
162 |
|
|
Style.saveToPS( saveName, cDict )
|
163 |
|
|
if saveToEPS:
|
164 |
|
|
Style.saveToEPS( saveName, cDict )
|
165 |
|
|
pass
|
166 |
|
|
|
167 |
|
|
Def.DontQuit()
|