-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlimit_plot_shape.py
338 lines (265 loc) · 9.51 KB
/
limit_plot_shape.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
import array, math
def Inter(g1,g2):
xaxisrange = g1.GetXaxis().GetXmax()-g1.GetXaxis().GetXmin()
xaxismin = g1.GetXaxis().GetXmin()
inters = []
for x in range(0,10000):
xpoint = xaxismin + (float(x)/1000.0)*xaxisrange
xpoint1 = xaxismin + (float(x+1)/1000.0)*xaxisrange
Pr1 = g1.Eval(xpoint)
Pr2 = g2.Eval(xpoint)
Po1 = g1.Eval(xpoint1)
Po2 = g2.Eval(xpoint1)
if (Pr1-Pr2)*(Po1-Po2)<0:
inters.append(0.5*(xpoint+xpoint1))
return inters
def strf( x ):
return '%.3f' % x
def strf1( x ):
return '%.0f' % x
from optparse import OptionParser
parser = OptionParser()
parser.add_option('--inputFileExp', metavar='H', type='string', action='store',
default='limits_shape_exp.txt',
dest='inputFileExp',
help='Expected limits from theta')
parser.add_option('--inputFileObs', metavar='H', type='string', action='store',
default='limits_shape_obs.txt',
dest='inputFileObs',
help='Observed limits from theta')
parser.add_option('--outputName', metavar='D', type='string', action='store',
default='comb',
dest='outputName',
help='Directory to plot')
parser.add_option('--title', metavar='D', type='string', action='store',
default='narrow',
dest='title',
help='Titles to use, options are narrow, wide, kkg')
parser.add_option('--showNarrowTheory', action='store_true',
default=False,
dest='showNarrowTheory',
help='Show theory prediction for 1% width')
parser.add_option('--showWideTheory', action='store_true',
default=False,
dest='showWideTheory',
help='Show theory prediction for 3% width')
parser.add_option('--showKKGTheory', action='store_true',
default=False,
dest='showKKGTheory',
help='Show theory prediction for KK Gluon')
parser.add_option('--useLog', metavar='L', action='store_true',
default=False,
dest='useLog',
help='use log y-axis')
parser.add_option('--noTheory', metavar='T', action='store_true',
default=False,
dest='noTheory',
help='do not plot theory curves')
(options, args) = parser.parse_args()
argv = []
from ROOT import *
import ROOT
gROOT.Macro("rootlogon.C")
gROOT.LoadMacro("insertlogo.C+")
import Wprime_Functions
from Wprime_Functions import *
Cons = LoadConstants()
lumi = Cons['lumi']
xsec_wpr = Cons['xsec_wpr']
xsec_wpl = Cons['xsec_wpl']
xsec_wplr = Cons['xsec_wplr']
xsec_ttbar = Cons['xsec_ttbar']
xsec_qcd = Cons['xsec_qcd']
xsec_st = Cons['xsec_st']
nev_wpr = Cons['nev_wpr']
nev_wpl = Cons['nev_wpl']
nev_wplr = Cons['nev_wplr']
nev_ttbar = Cons['nev_ttbar']
nev_qcd = Cons['nev_qcd']
nev_st = Cons['nev_st']
import Wprime_Functions
from Wprime_Functions import *
gROOT.Macro("rootlogon.C")
gROOT.LoadMacro("insertlogo.C+")
def make_smooth_graph(h2,h3):
h2 = TGraph(h2)
h3 = TGraph(h3)
npoints = h3.GetN()
h3.Set(2*npoints+2)
for b in range(npoints+2):
x1, y1 = (ROOT.Double(), ROOT.Double())
if b == 0:
h3.GetPoint(npoints-1, x1, y1)
elif b == 1:
h2.GetPoint(npoints-b, x1, y1)
else:
h2.GetPoint(npoints-b+1, x1, y1)
h3.SetPoint(npoints+b, x1, y1)
return h3
if __name__ == "__main__":
ROOT.gROOT.Macro("rootlogon.C")
TPT = ROOT.TPaveText(.20, .22, .5, .27,"NDC")
TPT.AddText("All-Hadronic Channel")
TPT.SetFillColor(0)
TPT.SetBorderSize(0)
TPT.SetTextAlign(12)
xsec_wpr = Cons['xsec_wpr']
masses = [1000,1100,1200,1300,1400,1500,1600,1700,1800,1900,2000,2100,2200,2300,2400,2500,2600,2700,2800,2900]
x_mass = array('d')
y_limit = array('d')
y_mclimit = array('d')
y_mclimitlow68 = array('d')
y_mclimitup68 = array('d')
y_mclimitup95 = array('d')
y_mclimitlow95 = array('d')
logScale = options.useLog
f1 = file(options.inputFileExp, "r")
f2 = file(options.inputFileObs, "r")
# i = 0
for line in f1:
data = map(float,line.split())
rt_xsec = xsec_wpr[str(int(data[0]))]*Cons['kfac']/(0.676)
#print data
# data is an array along the line, has 8 entries
x_mass.append( data[0]/1000.0 ) # mass
#y_limit.append( data[1] )
y_mclimit.append( data[1]*rt_xsec )
y_mclimitlow95.append( data[2]*rt_xsec )
y_mclimitup95.append( data[3]*rt_xsec )
y_mclimitlow68.append( data[4]*rt_xsec )
y_mclimitup68.append( data[5]*rt_xsec )
# i = 0
for line in f2:
data = map(float,line.split())
rt_xsec = xsec_wpr[str(int(data[0]))]*Cons['kfac']/(0.676)
y_limit.append( data[1]*rt_xsec )
print "Limit Table"
for imass in range(0,len(x_mass)):
print "\hline"
print strf1(x_mass[imass]*1000.0) +" & "+strf(y_limit[imass])+" & "+strf(y_mclimit[imass])+" & "+strf(y_mclimitlow68[imass])+","+strf(y_mclimitup68[imass])+" & "+strf(y_mclimitlow95[imass])+","+strf(y_mclimitup95[imass])
cv = TCanvas("cv", "cv",700, 600)
#cv = TCanvas("cv", "cv")
if logScale:
cv.SetLogy(True)
cv.SetLeftMargin(.18)
cv.SetBottomMargin(.18)
g_limit = TGraph(len(x_mass), x_mass, y_limit)
g_limit.SetTitle("")
g_limit.SetMarkerStyle(0)
g_limit.SetMarkerColor(1)
g_limit.SetLineColor(1)
g_limit.SetLineWidth(3)
g_limit.SetMarkerSize(0.5) #0.5
g_limit.GetXaxis().SetTitle("M_{W'_{R}} (TeV)")
g_limit.GetYaxis().SetTitle("Upper Limit #sigma_{W'_{R}} #times B(W'_{R}#rightarrowtb) [pb]")
g_limit.Draw("alp")
g_limit.GetYaxis().SetRangeUser(0., 80.)
g_limit.GetXaxis().SetRangeUser(1.0, 2.9)
if logScale:
g_limit.SetMinimum(1.0e-2) #0.005
g_limit.SetMaximum(4000.) #10000
else:
# g_limit.SetMaximum(80.)
g_limit.SetMaximum(0.5)#20.)
g_limit.Draw("al") #uncomm later
g_mclimit = TGraph(len(x_mass), x_mass, y_mclimit)
g_mclimit.SetTitle("")
g_mclimit.SetMarkerStyle(21)
g_mclimit.SetMarkerColor(1)
g_mclimit.SetLineColor(1)
g_mclimit.SetLineStyle(2)
g_mclimit.SetLineWidth(3)
g_mclimit.SetMarkerSize(0.)
g_mclimit.GetXaxis().SetTitle("m_{Z'} (TeV/c^{2})")
g_mclimit.GetYaxis().SetTitle("Upper Limit #sigma_{W'_{R}} #times B (pb)")
g_mclimit.GetYaxis().SetTitleSize(0.03)
g_mclimit.Draw("l")
g_mclimit.GetYaxis().SetRangeUser(0., 80.)
g_mcplus = TGraph(len(x_mass), x_mass, y_mclimitup68)
g_mcminus = TGraph(len(x_mass), x_mass, y_mclimitlow68)
g_mc2plus = TGraph(len(x_mass), x_mass, y_mclimitup95)
g_mc2minus = TGraph(len(x_mass), x_mass, y_mclimitlow95)
graphWP = ROOT.TGraph()
graphWP.SetTitle("")
graphWP.SetMarkerStyle(23)
graphWP.SetMarkerColor(4)
graphWP.SetLineColor(4)
graphWP.SetLineWidth(2)
graphWP.SetMarkerSize(0.5)
q = 0
for wpmass in masses:
rt_xsec = xsec_wpr[str(int(wpmass))]*Cons['kfac']/(0.676)
graphWP.SetPoint(q, wpmass/1000. , rt_xsec )
q+=1
graphWP.SetLineWidth(3)
graphWP.SetLineColor(4 )
g_error95 = make_smooth_graph(g_mc2minus, g_mc2plus)
g_error95.SetFillColor(kYellow)
g_error95.SetLineColor(0)
g_error95.Draw("lf")
g_error95.Draw("lf")
g_error = make_smooth_graph(g_mcminus, g_mcplus)
g_error.SetFillColor( kGreen)
g_error.SetLineColor(0)
g_error.Draw("lf")
g_error.Draw("lf")
g_limit.Draw("l") #uncomm later
g_mclimit.Draw("l")
#g_limit.Draw("l") #uncomm later
graphWP.Draw("l")
legLabel = ""
if logScale:
legend = TLegend(0.47, 0.45, 0.86, 0.84, legLabel)
else:
legend = TLegend(0.47, 0.35, 0.86, 0.75, legLabel)
#legend.SetTextFont(42)
legend.AddEntry(g_limit, "Observed limit (95% CL)","l") #uncomm later
legend.AddEntry(g_mclimit, "Expected limit (95% CL)","l")
legend.AddEntry(g_error, "68% Expected", "f")
legend.AddEntry(g_error95, "95% Expected", "f")
legend.AddEntry(graphWP, "W'_{R} signal", "l")
g_limit.GetYaxis().SetTitleOffset(1.4)
legend.SetBorderSize(0)
legend.SetFillStyle(0)
legend.SetLineColor(0)
text1 = ROOT.TLatex()
text1.SetNDC()
text1.SetTextFont(42)
#text1.DrawLatex(0.2,0.84, "#scale[1.0]{CMS, L = 2.55 fb^{-1} at #sqrt{s} = 13 TeV}")
text11 = ROOT.TLatex()
text11.SetTextFont(42)
text11.SetNDC()
label = "temp"
text2 = ROOT.TLatex(3.570061, 23.08044, label)
text2.SetNDC()
text2.SetTextAlign(13)
text2.SetX(0.4) #0.32
text2.SetY(0.8) #0.87
#text2.SetW(0.5)
text2.SetTextFont(42)
#text2.SetTextSizePixels(24)
#text2.SetTextSizePixels(17)
#text2.Draw()
insertlogo(cv, 4, 11 )
legend.Draw("same")
g_limit.Draw("p same")
postpend = options.outputName
if logScale:
postpend = postpend + "_log"
if options.noTheory :
postpend = postpend + "_notheory"
TPT.Draw()
cv.RedrawAxis()
cv.SaveAs("plots/limits_theta_"+postpend+".pdf")
cv.SaveAs("plots/limits_theta_"+postpend+".gif")
cv.SaveAs("plots/limits_theta_"+postpend+".png")
cv.SaveAs("plots/limits_theta_"+postpend+".root")
obs = Inter(g_limit,graphWP)
exp = Inter(g_mclimit,graphWP)
print "intersections:"
print "Observed"
for i in range(0,len(obs)):
print str(obs[i])
print "Experimental"
for i in range(0,len(exp)):
print str(exp[i])