-
Notifications
You must be signed in to change notification settings - Fork 5
/
top_t2ws.py
387 lines (316 loc) · 12.9 KB
/
top_t2ws.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
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
#!/usr/bin/env python
"""
Thomas Klijnsma
"""
########################################
# Imports
########################################
from OptionHandler import flag_as_option
import LatestPaths
import LatestBinning
import differentials
import differentialutils
import logging
import copy
import re
import random
random.seed(1002)
from differentials.theory.theory_utils import FileFinder
from time import strftime
datestr = strftime('%b%d')
########################################
# Main
########################################
@flag_as_option
def make_theory_ctcg_files(args):
differentials.theory.ctcg_interpreter.create_all_ctcg()
top_exp_binning = [ 0., 15., 30., 45., 80., 120., 200., 350., 600. ]
def base_t2ws(args,
apply_theory_uncertainties=True,
apply_reweighting=True,
drop_last_bin=False,
do_kappat_kappag=True,
add_scaling_ttH=False,
):
decay_channel = differentialutils.get_decay_channel_tag(args)
t2ws = differentials.combine.t2ws.T2WS()
t2ws.card = LatestPaths.card.pth_ggH[decay_channel]
t2ws.model_file = 'physicsModels/CouplingModel.py'
t2ws.model_name = 'couplingModel'
if do_kappat_kappag:
t2ws.name = decay_channel + '_Top'
else:
t2ws.name = decay_channel + '_TopCtCb'
t2ws.extra_options.extend([
'--PO linearTerms=False',
'--PO splitggH=True',
])
if args.hzz:
t2ws.extra_options.append('--PO isOnlyHZZ=True' )
if args.hgg:
t2ws.extra_options.append('--PO isOnlyHgg=True' )
obs = LatestBinning.obstuple_pth_ggH[decay_channel]
# if drop_last_bin:
# obs.drop_last_bin()
# t2ws.tags.append('lastBinDropped')
t2ws.extra_options.append(
'--PO binBoundaries={0}'
.format(','.join([str(b) for b in obs.binning]))
)
# Add the theory
if do_kappat_kappag:
logging.warning('Doing variations for kappa_t / kappa_g')
coupling_variations = FileFinder(
cb=1.0, muR=1.0, muF=1.0, Q=1.0, directory=LatestPaths.theory.top.filedir
).get()
sm = [ v for v in coupling_variations if v.ct==1.0 and v.cg==0.0 ][0]
coupling_variations.pop(coupling_variations.index(sm))
t2ws.extra_options.append('--PO SM=[ct=1,cg=0,file={0}]'.format(sm.theory_file))
for variation in coupling_variations:
if variation.ct == 1.0 or variation.cg == 0.0: continue
t2ws.extra_options.append(
'--PO theory=[ct={0},cg={1},file={2}]'
.format(variation.ct, variation.cg, variation.theory_file)
)
else:
logging.warning('Doing variations for kappa_t / kappa_b')
coupling_variations = FileFinder(
cg=0.0, muR=1.0, muF=1.0, Q=1.0, directory=LatestPaths.theory.top.filedir
).get()
sm = [ v for v in coupling_variations if v.ct==1.0 and v.cb==1.0 ][0]
coupling_variations.pop(coupling_variations.index(sm))
t2ws.extra_options.append('--PO SM=[ct=1,cb=1,file={0}]'.format(sm.theory_file))
for variation in coupling_variations:
if variation.ct == 1.0 or variation.cb == 1.0: continue
t2ws.extra_options.append(
'--PO theory=[ct={0},cb={1},file={2}]'
.format(variation.ct, variation.cb, variation.theory_file)
)
if apply_reweighting:
t2ws.extra_options.append(
'--PO SMXS_of_input_ws={0}'.format(','.join([str(v) for v in obs.crosssection()]))
)
t2ws.tags.append('reweighted')
if apply_theory_uncertainties:
add_theory_uncertainties(t2ws)
if add_scaling_ttH:
t2ws.extra_options.append('--PO add_scaling_ttH=True')
t2ws.tags.append('scalingttH')
return t2ws
def add_theory_uncertainties(t2ws, uncorrelated=False):
# Theory uncertainties
correlation_matrix = 'out/scalecorrelations_Mar06/corrMat_tophighpt.txt'
theory_uncertainties = 'out/scalecorrelations_Mar06/errors_tophighpt.txt'
if uncorrelated:
correlation_matrix = LatestPaths.correlationMatrix_Yukawa_Uncorrelated # Uncorrelated
t2ws.tags.append('uncorrelatedTheoryUnc')
t2ws.extra_options.append('--PO correlationMatrix={0}'.format(correlation_matrix))
t2ws.extra_options.append('--PO theoryUncertainties={0}'.format(theory_uncertainties))
#____________________________________________________________________
@flag_as_option
def t2ws_Top_scalingttH(args):
# args = differentialutils.set_one_decay_channel(args, 'combWithHbb', asimov=True)
t2ws = base_t2ws(args, add_scaling_ttH=True)
# t2ws.card = LatestPaths.card.pth_ggH.combWithHbb
t2ws.run()
@flag_as_option
def t2ws_Top_scalingttH_floatingBRs(args):
# args = differentialutils.set_one_decay_channel(args, 'combWithHbb', asimov=True)
t2ws = base_t2ws(args, add_scaling_ttH=True)
# t2ws.card = LatestPaths.card.pth_ggH.combWithHbb
t2ws.extra_options.append('--PO freely_floating_BRs=True')
t2ws.tags.append('floatingBRs')
t2ws.run()
@flag_as_option
def t2ws_Top_scalingttH_floatingBRs_constrainedbbZZ(args):
# args = differentialutils.set_one_decay_channel(args, 'combWithHbb', asimov=True)
t2ws = base_t2ws(args, add_scaling_ttH=True)
# t2ws.card = LatestPaths.card.pth_ggH.combWithHbb
t2ws.extra_options.append('--PO freely_floating_BRs=True')
t2ws.extra_options.append('--PO constrain_ratio_bb_ZZ=True')
t2ws.tags.append('floatingBRs')
t2ws.tags.append('constrainedbbZZ')
t2ws.run()
@flag_as_option
def t2ws_Top_scalingttH_couplingdependentBRs(args):
# args = differentialutils.set_one_decay_channel(args, 'combWithHbb', asimov=True)
t2ws = base_t2ws(args, add_scaling_ttH=True)
# t2ws.card = LatestPaths.card.pth_ggH.combWithHbb
t2ws.extra_options.append('--PO BRs_kappa_dependent=True')
t2ws.tags.append('couplingdependentBRs')
t2ws.run()
#____________________________________________________________________
@flag_as_option
def t2ws_ktcg_kbinterference(args):
t2ws = base_t2ws(args, add_scaling_ttH=True)
t2ws.extra_options.append('--PO BRs_kappa_dependent=True')
t2ws.tags.append('kbinterference')
# Remove previous options
remove = lambda option: (
option.startswith('--PO SM=')
or option.startswith('--PO theory=')
or option.startswith('--PO linearTerms=')
)
t2ws.extra_options = [ option for option in t2ws.extra_options if not(remove(option)) ]
# Add the linear terms
t2ws.extra_options.append('--PO linearTerms=True')
# Add theory
coupling_variations = FileFinder(
cb=1.0, muR=1.0, muF=1.0, Q=1.0, directory=LatestPaths.theory.top.filedir
).get()
sm = [ v for v in coupling_variations if v.ct==1.0 and v.cg==0.0 ][0]
coupling_variations.pop(coupling_variations.index(sm))
t2ws.extra_options.append('--PO SM=[ct=1,cg=0,file={0}]'.format(sm.theory_file))
for variation in coupling_variations:
if variation.ct == 1.0 or variation.cg == 0.0: continue
t2ws.extra_options.append(
'--PO theory=[ct={0},cg={1},file={2}]'
.format(variation.ct, variation.cg, variation.theory_file)
)
t2ws.run()
#____________________________________________________________________
@flag_as_option
def t2ws_TopCtCb_scalingbbHttH(args):
# args = differentialutils.set_one_decay_channel(args, 'combWithHbb', asimov=True)
t2ws = base_t2ws(args, do_kappat_kappag=False)
t2ws.extra_options.append('--PO add_scaling_ttH=True')
t2ws.extra_options.append('--PO add_scaling_bbH=True')
t2ws.tags.append('scalingbbHttH')
t2ws.run()
@flag_as_option
def t2ws_TopCtCb_scalingbbHttH_couplingdependentBRs(args):
# args = differentialutils.set_one_decay_channel(args, 'combWithHbb', asimov=True)
t2ws = base_t2ws(args, do_kappat_kappag=False)
t2ws.extra_options.append('--PO add_scaling_ttH=True')
t2ws.extra_options.append('--PO add_scaling_bbH=True')
t2ws.tags.append('scalingbbHttH')
t2ws.extra_options.append('--PO BRs_kappa_dependent=True')
t2ws.tags.append('couplingdependentBRs')
t2ws.run()
@flag_as_option
def t2ws_TopCtCb_scalingbbHttH_floatingBRs(args):
# args = differentialutils.set_one_decay_channel(args, 'combWithHbb', asimov=True)
t2ws = base_t2ws(args, do_kappat_kappag=False)
t2ws.extra_options.append('--PO add_scaling_ttH=True')
t2ws.extra_options.append('--PO add_scaling_bbH=True')
t2ws.tags.append('scalingbbHttH')
t2ws.extra_options.append('--PO freely_floating_BRs=True')
t2ws.tags.append('floatingBRs')
t2ws.run()
@flag_as_option
def t2ws_TopCtCb_scalingbbHttH_floatingBRs_constrainedbbZZ(args):
# args = differentialutils.set_one_decay_channel(args, 'combWithHbb', asimov=True)
t2ws = base_t2ws(args, do_kappat_kappag=False)
t2ws.extra_options.append('--PO add_scaling_ttH=True')
t2ws.extra_options.append('--PO add_scaling_bbH=True')
t2ws.tags.append('scalingbbHttH')
t2ws.extra_options.append('--PO freely_floating_BRs=True')
t2ws.extra_options.append('--PO constrain_ratio_bb_ZZ=True')
t2ws.tags.append('floatingBRs')
t2ws.tags.append('constrainedbbZZ')
t2ws.run()
#____________________________________________________________________
@flag_as_option
def t2ws_Top_nominal(args):
t2ws = base_t2ws(args)
t2ws.card = LatestPaths.card.top.nominal[differentialutils.get_decay_channel_tag(args)]
t2ws.tags.append('noBinsDropped')
t2ws.run()
@flag_as_option
def t2ws_Top_lumiScale(args):
t2ws = base_t2ws(args)
t2ws.card = LatestPaths.card.top.nominal[differentialutils.get_decay_channel_tag(args)]
t2ws.tags.append('noBinsDropped')
t2ws.tags.append('lumiScale')
t2ws.extra_options.append('--PO lumiScale=True')
t2ws.run()
@flag_as_option
def t2ws_TopCtCb_nominal(args):
t2ws = base_t2ws(args, do_kappat_kappag=False)
t2ws.card = LatestPaths.card.top.nominal[differentialutils.get_decay_channel_tag(args)]
t2ws.tags.append('noBinsDropped')
t2ws.run()
@flag_as_option
def t2ws_TopCtCb_lumiScale(args):
t2ws = base_t2ws(args, do_kappat_kappag=False)
t2ws.card = LatestPaths.card.top.nominal[differentialutils.get_decay_channel_tag(args)]
t2ws.tags.append('noBinsDropped')
t2ws.tags.append('lumiScale')
t2ws.extra_options.append('--PO lumiScale=True')
t2ws.run()
@flag_as_option
def t2ws_Top_lastBinDroppedHgg(args):
t2ws = base_t2ws(args)
if args.combination:
t2ws.card = 'suppliedInput/combination_pth_ggH_lastBinDroppedHgg_Mar07.txt'
elif args.combWithHbb:
t2ws.card = 'suppliedInput/combWithHbb_pth_ggH_lastBinDroppedHgg_Mar07.txt'
else:
raise NotImplementedError('Use --combination or --combWithHbb')
t2ws.tags.append('lastBinDroppedHgg')
t2ws.run()
@flag_as_option
def t2ws_Top_last2BinsDropped(args):
t2ws = base_t2ws(args)
if args.combWithHbb:
t2ws.card = LatestPaths.card.top.combWithHbb_last2BinsDropped
if args.combination:
t2ws.card = LatestPaths.card.top.combination_last2BinsDropped
else:
raise NotImplementedError('Use --combination or --combWithHbb')
t2ws.tags.append('last2BinsDropped')
t2ws.run()
@flag_as_option
def t2ws_Top_BRcouplingDependency(args):
t2ws = base_t2ws(args)
t2ws.tags.append('BRcouplingDependency')
t2ws.extra_options.append('--PO FitBR=True')
# do_BR_uncertainties = False
# if do_BR_uncertainties:
# t2ws.extra_options.append('--PO DoBRUncertainties=True')
# t2ws.tags.append('withBRUnc')
t2ws.run()
#____________________________________________________________________
@flag_as_option
def t2ws_Top_unreweighted(args):
t2ws = base_t2ws(args, apply_reweighting=False)
t2ws.tags.append('nominal')
t2ws.run()
@flag_as_option
def t2ws_Top_noTheoryUnc(args):
t2ws = base_t2ws(args, apply_theory_uncertainties=False)
t2ws.tags.append('noTheoryUnc')
t2ws.run()
@flag_as_option
def t2ws_Top_uncorrelatedTheoryUnc(args):
t2ws = base_t2ws(args, apply_theory_uncertainties=False)
add_theory_uncertainties(t2ws, uncorrelated=True)
t2ws.tags.append('uncorrelatedTheoryUnc')
t2ws.run()
# @flag_as_option
# def t2ws_Top_lumiScale(args):
# t2ws = base_t2ws(args)
# t2ws.tags.append('lumiScale')
# t2ws.extra_options.append('--PO lumiScale=True')
# t2ws.run()
@flag_as_option
def t2ws_Top_profiledTotalXS(args):
t2ws = base_t2ws(args)
t2ws.tags.append('profiledTotalXS')
t2ws.extra_options.append('--PO ProfileTotalXS=True')
t2ws.run()
#____________________________________________________________________
# Not yet repeated
@flag_as_option
def t2ws_Top_fitRatioOfBRs(args):
t2ws = base_t2ws(args)
t2ws.tags.append('fitRatioOfBRs')
t2ws.extra_options.append('--PO FitRatioOfBRs=True')
t2ws.run()
@flag_as_option
def t2ws_Top_fitOnlyNormalization(args):
t2ws = base_t2ws(args)
t2ws.tags.append('fitOnlyNormalization')
add_theory_uncertainties(t2ws)
t2ws.extra_options.append('--PO FitOnlyNormalization=True')
t2ws.run()