-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathplot_dijetMC.py
353 lines (312 loc) · 25.1 KB
/
plot_dijetMC.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
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
### Tony Tong
### this file is used for dijet MC studies,
### particularly, testing reweighting assumptions
import ROOT, rootlogon
import argparse
import array
import copy
import glob
import helpers
import os
import sys
import time
import config as CONF
import numpy as np
ROOT.gROOT.SetBatch(True)
from ROOT import *
ROOT.gROOT.LoadMacro("AtlasStyle.C")
ROOT.gROOT.LoadMacro("AtlasLabels.C")
SetAtlasStyle()
def options():
parser = argparse.ArgumentParser()
parser.add_argument("--inputdir", default=CONF.workdir)
return parser.parse_args()
def main():
ops = options()
inputdir = ops.inputdir
global inputpath
inputpath = CONF.inputpath + inputdir + "/"
global outputpath
outputpath = CONF.inputpath + inputdir + "/" + "Plot/DijetMC/"
if not os.path.exists(outputpath):
os.makedirs(outputpath)
##starndard plots
# ##paper plot
# ##compare the trackjet distribution before reweighting
# for histname in ["leadHCand_trk0_Pt", "leadHCand_trk1_Pt", "sublHCand_trk0_Pt", "sublHCand_trk1_Pt"]:
# DrawMulticomparison([
# {"file":"signal_QCD/hist-MiniNTuple.root", "path":"TwoTag_split_Incl" + "/" + histname, "leg":"2bs SB"},
# {"file":"signal_QCD/hist-MiniNTuple.root", "path":"NoTag_Incl" + "/" + histname, "leg":"NoTag"},
# {"file":"signal_QCD/hist-MiniNTuple.root", "path":"OneTag_lead_Incl" + "/" + histname, "leg":"OneTag on leadH"},
# {"file":"signal_QCD/hist-MiniNTuple.root", "path":"OneTag_subl_Incl" + "/" + histname, "leg":"OneTag on sublH"},
# # {"file":"signal_QCD/hist-MiniNTuple.root", "path":"OneTag_lead_lead_Incl" + "/" + histname, "leg":"OneTag lead on lead"},
# # {"file":"signal_QCD/hist-MiniNTuple.root", "path":"OneTag_lead_subl_Incl" + "/" + histname, "leg":"OneTag lead on subl"},
# # {"file":"signal_QCD/hist-MiniNTuple.root", "path":"OneTag_subl_lead_Incl" + "/" + histname, "leg":"OneTag subl on lead"},
# # {"file":"signal_QCD/hist-MiniNTuple.root", "path":"OneTag_subl_subl_Incl" + "/" + histname, "leg":"OneTag subl on subl"},
# # {"file":"signal_QCD/hist-MiniNTuple.root", "path":"TwoTag_split_lead_lead_Incl" + "/" + histname, "leg":"2bs lead + lead"},
# # {"file":"signal_QCD/hist-MiniNTuple.root", "path":"TwoTag_split_lead_subl_Incl" + "/" + histname, "leg":"2bs lead + subl"},
# # {"file":"signal_QCD/hist-MiniNTuple.root", "path":"TwoTag_split_subl_lead_Incl" + "/" + histname, "leg":"2bs subl + lead"},
# # {"file":"signal_QCD/hist-MiniNTuple.root", "path":"TwoTag_split_subl_subl_Incl" + "/" + histname, "leg":"2bs subl + subl"},
# #{"file":"signal_QCD/hist-MiniNTuple.root", "path":"TwoTag_split_Sideband" + "/" + histname, "leg":"2bs SB"},
# ], keyword=histname, Xrange=[0, 600], norm=True, prename="MC_2bs", Rebin=10, Logy=1)
# ##compare reweighting in QCD MC
# for histname in ["leadHCand_Pt_m", "sublHCand_Pt_m"]:
# DrawMulticomparison([
# {"file":"../Moriond_bkg_5/signal_QCD/hist-MiniNTuple.root", "path":"TwoTag_split_Incl/" + histname, "leg":"2bs;"},
# {"file":"../Moriond_bkg_5/signal_QCD/hist-MiniNTuple.root", "path":"OneTag_Incl/" + histname, "leg":"1b;"},
# {"file":"../Moriond_bkg_5/signal_QCD/hist-MiniNTuple.root", "path":"NoTag_2Trk_split_Incl/" + histname, "leg":"1b reweighted bkg;"},
# #{"file":"../Moriond_bkgeta_5/signal_QCD/hist-MiniNTuple.root", "path":"NoTag_2Trk_split_Incl/" + histname, "leg":"1b reweighted bkgeta;"},
# #{"file":"../Moriond_bkgdr_5/signal_QCD/hist-MiniNTuple.root", "path":"NoTag_2Trk_split_Incl/" + histname, "leg":"1b reweighted bkgdr;"},
# #{"file":"../Moriond_bkgtrk_5/signal_QCD/hist-MiniNTuple.root", "path":"NoTag_2Trk_split_Incl/" + histname, "leg":"1b reweighted bkgtrk;"},
# #{"file":"../Moriond_bkgsb_5/signal_QCD/hist-MiniNTuple.root", "path":"NoTag_2Trk_split_Incl/" + histname, "leg":"1b reweighted bkgsb;"},
# #{"file":"../Moriond_j0pT-alltrk-fin_5/signal_QCD/hist-MiniNTuple.root", "path":"NoTag_2Trk_split_Incl/" + histname, "leg":"1b reweighted alltrk;"},
# #{"file":"../Moriond_j0pT-leadtrk-fin_5/signal_QCD/hist-MiniNTuple.root", "path":"NoTag_2Trk_split_Incl/" + histname, "leg":"1b reweighted leadtrk;"},
# #{"file":"../Moriond_j0pT-subltrk-fin_5/signal_QCD/hist-MiniNTuple.root", "path":"NoTag_2Trk_split_Incl/" + histname, "leg":"1b reweighted subltrk;"},
# ], keyword=histname, norm=True, Xrange=[250, 1000], Rebin=5, Logy=1, prename="Dijet_Incl")
# for histname in ["leadHCand_trk0_Pt", "sublHCand_trk0_Pt", "leadHCand_trk1_Pt", "sublHCand_trk1_Pt"]:
# DrawMulticomparison([
# {"file":"../Moriond_bkg_5/signal_QCD/hist-MiniNTuple.root", "path":"TwoTag_split_Incl/" + histname, "leg":"2bs;"},
# {"file":"../Moriond_bkg_5/signal_QCD/hist-MiniNTuple.root", "path":"OneTag_Incl/" + histname, "leg":"1b;"},
# {"file":"../Moriond_bkg_5/signal_QCD/hist-MiniNTuple.root", "path":"NoTag_2Trk_split_Incl/" + histname, "leg":"1b reweighted bkg;"},
# #{"file":"../Moriond_bkgeta_5/signal_QCD/hist-MiniNTuple.root", "path":"NoTag_2Trk_split_Incl/" + histname, "leg":"1b reweighted bkgeta;"},
# #{"file":"../Moriond_bkgdr_5/signal_QCD/hist-MiniNTuple.root", "path":"NoTag_2Trk_split_Incl/" + histname, "leg":"1b reweighted bkgdr;"},
# #{"file":"../Moriond_bkgtrk_5/signal_QCD/hist-MiniNTuple.root", "path":"NoTag_2Trk_split_Incl/" + histname, "leg":"1b reweighted bkgtrk;"},
# #{"file":"../Moriond_bkgsb_5/signal_QCD/hist-MiniNTuple.root", "path":"NoTag_2Trk_split_Incl/" + histname, "leg":"1b reweighted bkgsb;"},
# #{"file":"../Moriond_j0pT-alltrk-fin_5/signal_QCD/hist-MiniNTuple.root", "path":"NoTag_2Trk_split_Incl/" + histname, "leg":"1b reweighted alltrk;"},
# #{"file":"../Moriond_j0pT-leadtrk-fin_5/signal_QCD/hist-MiniNTuple.root", "path":"NoTag_2Trk_split_Incl/" + histname, "leg":"1b reweighted leadtrk;"},
# #{"file":"../Moriond_j0pT-subltrk-fin_5/signal_QCD/hist-MiniNTuple.root", "path":"NoTag_2Trk_split_Incl/" + histname, "leg":"1b reweighted subltrk;"},
# ], keyword=histname, norm=True, Xrange=[0, 1000], Rebin=5, Logy=1, prename="Dijet_Incl")
# for histname in ["mHH_l"]:
# for region in ["Signal", "Sideband", "Control", "Incl"]:
# DrawMulticomparison([
# {"file":"../Moriond_bkg_5/signal_QCD/hist-MiniNTuple.root", "path":"TwoTag_split_" + region + "/" + histname, "leg":"2bs;"},
# {"file":"../Moriond_bkg_5/signal_QCD/hist-MiniNTuple.root", "path":"OneTag_" + region + "/" + histname, "leg":"1b;"},
# {"file":"../Moriond_bkg_5/signal_QCD/hist-MiniNTuple.root", "path":"NoTag_2Trk_split_" + region + "/" + histname, "leg":"1b reweighted bkg;"},
# #{"file":"../Moriond_bkgeta_5/signal_QCD/hist-MiniNTuple.root", "path":"NoTag_2Trk_split_" + region + "/" + histname, "leg":"1b reweighted bkgeta;"},
# #{"file":"../Moriond_bkgdr_5/signal_QCD/hist-MiniNTuple.root", "path":"NoTag_2Trk_split_" + region + "/" + histname, "leg":"1b reweighted bkgdr;"},
# #{"file":"../Moriond_bkgtrk_5/signal_QCD/hist-MiniNTuple.root", "path":"NoTag_2Trk_split_" + region + "/" + histname, "leg":"1b reweighted bkgtrk;"},
# #{"file":"../Moriond_bkgsb_5/signal_QCD/hist-MiniNTuple.root", "path":"NoTag_2Trk_split_" + region + "/" + histname, "leg":"1b reweighted bkgsb;"},
# #{"file":"../Moriond_j0pT-alltrk-fin_5/signal_QCD/hist-MiniNTuple.root", "path":"NoTag_2Trk_split_" + region + "/" + histname, "leg":"1b reweighted alltrk;"},
# #{"file":"../Moriond_j0pT-leadtrk-fin_5/signal_QCD/hist-MiniNTuple.root", "path":"NoTag_2Trk_split_" + region + "/" + histname, "leg":"1b reweighted leadtrk;"},
# #{"file":"../Moriond_j0pT-subltrk-fin_5/signal_QCD/hist-MiniNTuple.root", "path":"NoTag_2Trk_split_" + region + "/" + histname, "leg":"1b reweighted subltrk;"},
# ], keyword=histname, norm=True, Xrange=[500, 3500], prename="Dijet_" + region, Rebin=10, Logy=1)
# ##compare reweighting in BQCD MC
# for histname in ["leadHCand_Pt_m", "sublHCand_Pt_m", "leadHCand_trk0_Pt", "sublHCand_trk0_Pt", "leadHCand_trk1_Pt", "sublHCand_trk1_Pt"]:
# DrawMulticomparison([
# {"file":"../Moriond_bkg_5/signal_BQCD_200/hist-MiniNTuple.root", "path":"TwoTag_split_Incl/" + histname, "leg":"2bs;"},
# {"file":"../Moriond_bkg_5/signal_BQCD_200/hist-MiniNTuple.root", "path":"OneTag_Incl/" + histname, "leg":"1b;"},
# {"file":"../Moriond_bkg_5/signal_BQCD_200/hist-MiniNTuple.root", "path":"NoTag_2Trk_split_Incl/" + histname, "leg":"1b reweighted bkg;"},
# #{"file":"../Moriond_bkgeta_5/signal_BQCD_200/hist-MiniNTuple.root", "path":"NoTag_2Trk_split_Incl/" + histname, "leg":"1b reweighted bkgeta;"},
# #{"file":"../Moriond_bkgdr_5/signal_BQCD_200/hist-MiniNTuple.root", "path":"NoTag_2Trk_split_Incl/" + histname, "leg":"1b reweighted bkgdr;"},
# {"file":"../Moriond_bkgtrk_5/signal_BQCD_200/hist-MiniNTuple.root", "path":"NoTag_2Trk_split_Incl/" + histname, "leg":"1b reweighted bkgtrk;"},
# #{"file":"../Moriond_bkgsb_5/signal_BQCD_200/hist-MiniNTuple.root", "path":"NoTag_2Trk_split_Incl/" + histname, "leg":"1b reweighted bkgsb;"},
# {"file":"../Moriond_j0pT-alltrk-fin_5/signal_BQCD_200/hist-MiniNTuple.root", "path":"NoTag_2Trk_split_Incl/" + histname, "leg":"1b reweighted alltrk;"},
# #{"file":"../Moriond_j0pT-leadtrk-fin_5/signal_BQCD_200/hist-MiniNTuple.root", "path":"NoTag_2Trk_split_Incl/" + histname, "leg":"1b reweighted leadtrk;"},
# #{"file":"../Moriond_j0pT-subltrk-fin_5/signal_BQCD_200/hist-MiniNTuple.root", "path":"NoTag_2Trk_split_Incl/" + histname, "leg":"1b reweighted subltrk;"},
# ], keyword=histname, norm=True, Xrange=[0, 1000], prename="BQCD", Rebin=5, Logy=1)
# for histname in ["mHH_l"]:
# for region in ["Signal", "Sideband", "Control", "Incl"]:
# DrawMulticomparison([
# {"file":"../Moriond_bkg_5/signal_BQCD_200/hist-MiniNTuple.root", "path":"TwoTag_split_" + region + "/" + histname, "leg":"2bs;"},
# {"file":"../Moriond_bkg_5/signal_BQCD_200/hist-MiniNTuple.root", "path":"OneTag_" + region + "/" + histname, "leg":"1b;"},
# {"file":"../Moriond_bkg_5/signal_BQCD_200/hist-MiniNTuple.root", "path":"NoTag_2Trk_split_" + region + "/" + histname, "leg":"1b reweighted bkg;"},
# #{"file":"../Moriond_bkgeta_5/signal_BQCD_200/hist-MiniNTuple.root", "path":"NoTag_2Trk_split_" + region + "/" + histname, "leg":"1b reweighted bkgeta;"},
# #{"file":"../Moriond_bkgdr_5/signal_BQCD_200/hist-MiniNTuple.root", "path":"NoTag_2Trk_split_" + region + "/" + histname, "leg":"1b reweighted bkgdr;"},
# {"file":"../Moriond_bkgtrk_5/signal_BQCD_200/hist-MiniNTuple.root", "path":"NoTag_2Trk_split_" + region + "/" + histname, "leg":"1b reweighted bkgtrk;"},
# #{"file":"../Moriond_bkgsb_5/signal_BQCD_200/hist-MiniNTuple.root", "path":"NoTag_2Trk_split_" + region + "/" + histname, "leg":"1b reweighted bkgsb;"},
# {"file":"../Moriond_j0pT-alltrk-fin_5/signal_BQCD_200/hist-MiniNTuple.root", "path":"NoTag_2Trk_split_" + region + "/" + histname, "leg":"1b reweighted alltrk;"},
# #{"file":"../Moriond_j0pT-leadtrk-fin_5/signal_BQCD_200/hist-MiniNTuple.root", "path":"NoTag_2Trk_split_" + region + "/" + histname, "leg":"1b reweighted leadtrk;"},
# #{"file":"../Moriond_j0pT-subltrk-fin_5/signal_BQCD_200/hist-MiniNTuple.root", "path":"NoTag_2Trk_split_" + region + "/" + histname, "leg":"1b reweighted subltrk;"},
# ], keyword=histname, norm=True, Xrange=[500, 3500], prename="BQCD_" + region, Rebin=10, Logy=1)
# ##for QCD mHH shape study; this is comparing to data
# for histname in ["mHH_l", "mHH_pole"]:
# for tag in ["TwoTag_split", "ThreeTag", "FourTag"]:
# for region in ["Signal", "Sideband", "Control"]:
# DrawMulticomparison([
# #{"file":"../Moriond/sum_Moriond.root", "path":("qcd_" if "Signal" not in region else "qcd_est_")+ tag + "_" + region + "_" + histname, "leg":"Data;"},
# #{"file":"../Moriond/sum_Moriond.root", "path":"qcd_est_" + tag + "_" + region + "_" + histname, "leg":"no reweight;"},
# {"file":"../Moriond_bkg_9/sum_Moriond_bkg_9.root", "path":"qcd_est_" + tag + "_" + region + "_" + histname, "leg":"reweight bkg;"},
# #{"file":"../Moriond_bkgeta_5/sum_Moriond_bkgeta_5.root", "path":"qcd_est_" + tag + "_" + region + "_" + histname, "leg":"reweight bkgeta;"},
# #{"file":"../Moriond_bkgdr_5/sum_Moriond_bkgdr_5.root", "path":"qcd_est_" + tag + "_" + region + "_" + histname, "leg":"reweight bkgdr;"},
# #{"file":"../Moriond_bkgsb_5/sum_Moriond_bkgsb_5.root", "path":"qcd_est_" + tag + "_" + region + "_" + histname, "leg":"reweight bkgsb;"},
# #{"file":"../Moriond_bkgtrk_5/sum_Moriond_bkgtrk_5.root", "path":"qcd_est_" + tag + "_" + region + "_" + histname, "leg":"reweight bkgtrk;"},
# {"file":"../Moriond_j0pT-alltrk-fin_5/sum_Moriond_j0pT-alltrk-fin_5.root", "path":"qcd_est_" + tag + "_" + region + "_" + histname, "leg":"reweight alltrk;"},
# #{"file":"../Moriond_j0pT-leadtrk-fin_5/sum_Moriond_j0pT-leadtrk-fin_5.root", "path":"qcd_est_" + tag + "_" + region + "_" + histname, "leg":"reweight leadtrk;"},
# #{"file":"../Moriond_j0pT-subltrk-fin_5/sum_Moriond_j0pT-subltrk-fin_5.root", "path":"qcd_est_" + tag + "_" + region + "_" + histname, "leg":"reweight subltrk;"},
# ], keyword=histname, norm=False, Xrange=[500, 3500], prename="Data_" + tag + "_" + region, Rebin=10, Logy=1)
for histname in ["totalbkg_hh", "qcd_hh"]:
for tag in ["TwoTag_split", "ThreeTag", "FourTag"]:
for region in ["Signal"]:
DrawMulticomparison([
{"file":"../Moriond_bkg_9/Limitinput/Moriond_bkg_9_limit_" + tag + ".root", "path":histname, "leg":"reweight bkg;"},
{"file":"../Moriond_j0pT-alltrk-fin_5/Limitinput/Moriond_j0pT-alltrk-fin_5_limit_" + tag + ".root", "path":histname, "leg":"reweight alltrk;"},
], keyword=histname, norm=False, Xrange=[500, 3500], prename="Reweight_" + tag + "_" + region, Logy=1)
# for histname in ["leadHCand_trk0_Pt", "leadHCand_trk1_Pt", "sublHCand_trk0_Pt", "sublHCand_trk1_Pt"]:
# for tag in ["TwoTag_split", "ThreeTag", "FourTag"]:
# for region in ["Signal", "Sideband", "Control"]:
# DrawMulticomparison([
# {"file":"../Moriond/sum_Moriond.root", "path":("qcd_" if "Signal" not in region else "qcd_est_")+ tag + "_" + region + "_" + histname, "leg":"Data;"},
# {"file":"../Moriond/sum_Moriond.root", "path":"qcd_est_" + tag + "_" + region + "_" + histname, "leg":"no reweight;"},
# {"file":"../Moriond_bkg_5/sum_Moriond_bkg_5.root", "path":"qcd_est_" + tag + "_" + region + "_" + histname, "leg":"reweight bkg;"},
# {"file":"../Moriond_bkgeta_5/sum_Moriond_bkgeta_5.root", "path":"qcd_est_" + tag + "_" + region + "_" + histname, "leg":"reweight bkgeta;"},
# {"file":"../Moriond_bkgdr_5/sum_Moriond_bkgdr_5.root", "path":"qcd_est_" + tag + "_" + region + "_" + histname, "leg":"reweight bkgdr;"},
# {"file":"../Moriond_bkgsb_5/sum_Moriond_bkgsb_5.root", "path":"qcd_est_" + tag + "_" + region + "_" + histname, "leg":"reweight bkgsb;"},
# {"file":"../Moriond_bkgtrk_5/sum_Moriond_bkgtrk_5.root", "path":"qcd_est_" + tag + "_" + region + "_" + histname, "leg":"reweight bkgtrk;"},
# {"file":"../Moriond_j0pT-alltrk-fin_5/sum_Moriond_j0pT-alltrk-fin_5.root", "path":"qcd_est_" + tag + "_" + region + "_" + histname, "leg":"reweight alltrk;"},
# {"file":"../Moriond_j0pT-leadtrk-fin_5/sum_Moriond_j0pT-leadtrk-fin_5.root", "path":"qcd_est_" + tag + "_" + region + "_" + histname, "leg":"reweight leadtrk;"},
# {"file":"../Moriond_j0pT-subltrk-fin_5/sum_Moriond_j0pT-subltrk-fin_5.root", "path":"qcd_est_" + tag + "_" + region + "_" + histname, "leg":"reweight subltrk;"},
# ], keyword=histname, Xrange=[0, 600], norm=True, prename="Data_" + tag + "_" + region, Rebin=5, Logy=1)
# # # ##for QCD mHH shape study
# for histname in ["mHH_l"]:
# DrawMulticomparison([
# #{"file":"../Moriond_bkg_5/signal_QCD/hist-MiniNTuple.root", "path":"NoTag_Sideband/" + histname, "leg":"0b;"},
# {"file":"../Moriond_bkg_5/signal_QCD/hist-MiniNTuple.root", "path":"TwoTag_split_Sideband/" + histname, "leg":"2bs;"},
# {"file":"../Moriond_bkg_5/signal_QCD/hist-MiniNTuple.root", "path":"OneTag_Sideband/" + histname, "leg":"1b;"},
# #{"file":"../Moriond_bkg_5/signal_QCD/hist-MiniNTuple.root", "path":"TwoTag_Sideband/" + histname, "leg":"2b;"},
# {"file":"../Moriond_bkg_5/signal_QCD/hist-MiniNTuple.root", "path":"NoTag_2Trk_split_Sideband/" + histname, "leg":"1b; reweighted bkg"},
# {"file":"../Moriond_j0pT-alltrk-fin_5/signal_QCD/hist-MiniNTuple.root", "path":"NoTag_2Trk_split_Sideband/" + histname, "leg":"1b; reweighted alltrk"},
# #{"file":"../Moriond_bkg_5/signal_QCD/hist-MiniNTuple.root", "path":"ThreeTag_Sideband/" + histname, "leg":"3b;"},
# #{"file":"../Moriond_bkg_5/signal_QCD/hist-MiniNTuple.root", "path":"FourTag_Sideband/" + histname, "leg":"4b;"},
# ], keyword=histname, prename="MC", norm=True, Xrange=[500, 3500], Rebin=10, Logy=1)
# for histname in ["mHH_l"]:
# DrawMulticomparison([
# #{"file":"../Moriond/sum_Moriond.root", "path":"qcd_NoTag_Sideband_" + histname, "leg":"0b;"},
# {"file":"../Moriond/sum_Moriond.root", "path":"qcd_TwoTag_split_Sideband_" + histname, "leg":"2bs;"},
# {"file":"../Moriond/sum_Moriond.root", "path":"qcd_OneTag_Sideband_" + histname, "leg":"1b;"},
# {"file":"../Moriond/sum_Moriond.root", "path":"qcd_TwoTag_Sideband_" + histname, "leg":"2b;"},
# #{"file":"../Moriond/sum_Moriond.root", "path":"qcd_ThreeTag_Sideband_" + histname, "leg":"3b;"},
# #{"file":"../Moriond/sum_Moriond.root", "path":"qcd_FourTag_Sideband_" + histname, "leg":"4b;"},
# ], keyword=histname, prename="Data", norm=True, Xrange=[500, 3500], Rebin=10, Logy=1)
def DrawMulticomparison(inputlst, keyword="", prename="", Xrange=[0, 0], Yrange=[0, 0], norm=True, Logy=0, Rebin=1):
#print inputdir
tempname = "directcompare" + "_" + keyword + ("" if Logy == 0 else "_" + str(Logy))
canv = ROOT.TCanvas(tempname, tempname, 800, 800)
# two pad
pad0 = ROOT.TPad("pad0", "pad0", 0.0, 0.31, 1., 1.)
pad0.SetRightMargin(0.05)
pad0.SetBottomMargin(0.0001)
pad0.SetFrameFillColor(0)
pad0.SetFrameBorderMode(0)
pad0.SetFrameFillColor(0)
pad0.SetBorderMode(0)
pad0.SetBorderSize(0)
pad1 = ROOT.TPad("pad1", "pad1", 0.0, 0.0, 1., 0.30)
pad1.SetRightMargin(0.05)
pad1.SetBottomMargin(0.38)
pad1.SetTopMargin(0.0001)
pad1.SetFrameFillColor(0)
pad1.SetFillStyle(0) # transparent
pad1.SetFrameBorderMode(0)
pad1.SetFrameFillColor(0)
pad1.SetBorderMode(0)
pad1.SetBorderSize(0)
#top pad
canv.cd()
pad0.SetLogy(Logy)
pad0.Draw()
pad0.cd()
xleg, yleg = 0.5, 0.6
legend = ROOT.TLegend(xleg, yleg, xleg+0.2, yleg+0.3)
counter = 0
maxbincontent = (0.05 if Logy ==0 else 10)
temphst_lst = []
graph_lst = []
tempratio_lst = []
for i, dic in enumerate(inputlst):
#print dic["file"], dic["path"] ##?????
refroot = ROOT.TFile.Open(inputpath + dic["file"])
temphst_lst.append(refroot.Get(dic["path"]).Clone())
tempratio_lst.append(refroot.Get(dic["path"]).Clone(dic["path"] + "_ratio"))
temphst_lst[i].SetDirectory(0) #otherwise the hist lives in the current open file
tempratio_lst[i].SetDirectory(0) #otherwise the hist lives in the current open file
if Rebin != 1:
temphst_lst[i].Rebin(Rebin)
tempratio_lst[i].Rebin(Rebin)
if norm:
if Xrange != [0, 0]:
temphst_lst[i].Scale(temphst_lst[0].Integral(temphst_lst[0].GetXaxis().FindBin(Xrange[0]), temphst_lst[0].GetXaxis().FindBin(Xrange[1] + 1))/temphst_lst[i].Integral(temphst_lst[0].GetXaxis().FindBin(Xrange[0]), temphst_lst[0].GetXaxis().FindBin(Xrange[1] + 1)))
else:
temphst_lst[i].Scale(temphst_lst[0].Integral(0, temphst_lst[0].GetXaxis().GetNbins()+1)/temphst_lst[i].Integral(0, temphst_lst[i].GetXaxis().GetNbins()+1))
for j in range(1, temphst_lst[0].GetNbinsX()+1):
try:
tempratio_lst[i].SetBinContent(j, temphst_lst[i].GetBinContent(j) / temphst_lst[0].GetBinContent(j))
tempratio_lst[i].SetBinError(j, helpers.ratioerror(\
temphst_lst[i].GetBinContent(j), temphst_lst[0].GetBinContent(j), \
temphst_lst[i].GetBinError(j), temphst_lst[0].GetBinError(j)))
except ZeroDivisionError:
pass
#print "Divide by zero! Check bin content in", canv.GetName()
maxbincontent = max(maxbincontent, temphst_lst[i].GetMaximum())
#graph_lst.append(helpers.TH1toTAsym(temphst_lst[i], efficiency=False))
temphst_lst[i].SetLineColor(1 if i == 0 else CONF.clr_lst[i])
#temphst_lst[i].SetLineStyle(1 + i)
temphst_lst[i].SetMarkerStyle(20 + i)
temphst_lst[i].SetMarkerColor(1 if i == 0 else CONF.clr_lst[i])
temphst_lst[i].SetMarkerSize(1)
temphst_lst[i].SetMaximum(maxbincontent * (1.5 if Logy == 0 else 150))
temphst_lst[i].SetMinimum(0.001 if Logy == 0 else 0.02)
if Xrange != [0, 0]:
#print Xrange
temphst_lst[i].GetXaxis().SetRangeUser(Xrange[0], Xrange[1])
chi2 = temphst_lst[i].Chi2Test(temphst_lst[0], "QU CHI2/NDF")
#legend.AddEntry(temphst_lst[i], dic["leg"] + " KS: " + str(('%.3g' % temphst_lst[i].KolmogorovTest(temphst_lst[0], "QU"))), "pl")
legend.AddEntry(temphst_lst[i], dic["leg"] + " chi2: " + str(('%.3g' % (chi2))), "pl")
temphst_lst[i].Draw("EP" if i==0 else "hist same")
refroot.Close()
legend.SetBorderSize(0)
legend.SetMargin(0.3)
legend.SetTextSize(0.04)
legend.Draw()
# draw watermarks
xatlas, yatlas = 0.28, 0.87
atlas = ROOT.TLatex(xatlas, yatlas, "ATLAS Internal")
hh4b = ROOT.TLatex(xatlas, yatlas-0.06, "Simulations")
lumi = ROOT.TLatex(xatlas, yatlas-0.12, "MC #sqrt{s} = 13 TeV")
info = ROOT.TLatex(xatlas, yatlas-0.06, keyword.replace("data_est_", "").replace("_mHH_l", "").replace("_", " "))
watermarks = [atlas, info]
for wm in watermarks:
wm.SetTextAlign(22)
wm.SetTextSize(0.04)
wm.SetTextFont(42)
wm.SetNDC()
wm.Draw()
#bottom pad
canv.cd()
pad1.Draw()
pad1.cd()
for i, dic in enumerate(inputlst):
tempratio_lst[i].SetLineColor(1 if i == 0 else CONF.clr_lst[i])
#tempratio_lst[i].SetLineStyle(1 + i)
tempratio_lst[i].SetMarkerStyle(20 + i)
tempratio_lst[i].SetMarkerColor(1 if i == 0 else CONF.clr_lst[i])
tempratio_lst[i].SetMarkerSize(1)
tempratio_lst[i].GetYaxis().SetTitleFont(43)
tempratio_lst[i].GetYaxis().SetTitleSize(28)
tempratio_lst[i].GetYaxis().SetLabelFont(43)
tempratio_lst[i].GetYaxis().SetLabelSize(28)
tempratio_lst[i].GetYaxis().SetTitle("ratio to ref")
tempratio_lst[i].GetYaxis().SetRangeUser(0.6, 1.5) #set range for ratio plot
tempratio_lst[i].GetYaxis().SetNdivisions(405)
tempratio_lst[i].GetXaxis().SetTitleFont(43)
tempratio_lst[i].GetXaxis().SetTitleOffset(3.5)
tempratio_lst[i].GetXaxis().SetTitleSize(28)
tempratio_lst[i].GetXaxis().SetLabelFont(43)
tempratio_lst[i].GetXaxis().SetLabelSize(28)
if Xrange != [0, 0]:
tempratio_lst[i].GetXaxis().SetRangeUser(Xrange[0], Xrange[1])
if i > 0:
tempratio_lst[i].Draw("ep" if i == 1 else "ep same")
# draw the ratio 1 line
line = ROOT.TLine(Xrange[0], 1.0, Xrange[1], 1.0)
line.SetLineStyle(1)
line.Draw()
#save and clean up
canv.SaveAs(outputpath + (prename + "_" if prename is not "" else "") + canv.GetName() + ".pdf")
pad0.Close()
pad1.Close()
canv.Close()
del(tempratio_lst)
del(temphst_lst)
del(graph_lst)
if __name__ == "__main__":
main()