-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathyukawa_t2ws.py
436 lines (357 loc) · 14 KB
/
yukawa_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
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
#!/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 random
random.seed(1002)
from differentials.theory.theory_utils import FileFinder
from time import strftime
datestr = strftime('%b%d')
########################################
# Main
########################################
yukawa_exp_binning = [ 0., 15., 30., 45., 80., 120. ]
@flag_as_option
def make_theory_files_Yukawa(args):
interp = differentials.theory.kappabkappac_interpreter.KappabKappacInterpreter()
interp.dump_gluon_induced()
interp.dump_quark_induced()
interp.dump_quark_induced_scaled()
interp.dump_summed_quark_gluon_induced()
def base_t2ws(args, apply_theory_uncertainties=True, apply_reweighting=True):
t2ws = differentials.combine.t2ws.T2WS()
decay_channel = differentialutils.get_decay_channel_tag(args, allow_default=True)
t2ws.card = LatestPaths.card.yukawa[decay_channel]
t2ws.model_file = 'physicsModels/CouplingModel.py'
t2ws.model_name = 'couplingModel'
t2ws.name = decay_channel + '_Yukawa'
t2ws.extra_options.extend([
'--PO linearTerms=True',
'--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.obs_pth_ggH
obs.drop_bins_up_to_value(yukawa_exp_binning[-1]+1.0)
t2ws.extra_options.append(
'--PO binBoundaries={0}'
.format(','.join([str(b) for b in obs.binning]))
)
add_theory(t2ws)
if apply_reweighting:
crosssections = obs.crosssection()
crosssections_str = ','.join([str(v) for v in crosssections])
t2ws.extra_options.append('--PO SMXS_of_input_ws={0}'.format(crosssections_str))
t2ws.tags.append('reweighted')
else:
t2ws.tags.append('unreweighted')
if apply_theory_uncertainties:
add_theory_uncertainties(t2ws)
return t2ws
def base_t2ws_fitOnlyTotalXS(args, apply_theory_uncertainties=True, apply_reweighting=False):
t2ws = differentials.combine.t2ws.T2WS()
decay_channel = differentialutils.get_decay_channel_tag(args, allow_default=True)
t2ws.card = LatestPaths.card.inclusive[decay_channel]
t2ws.model_file = 'physicsModels/CouplingModel.py'
t2ws.model_name = 'couplingModel'
t2ws.name = decay_channel + '_Yukawa'
t2ws.extra_options.extend([
'--PO linearTerms=True',
'--PO splitggH=True',
'--PO FitOnlyTotalXS=True'
])
if args.hzz:
t2ws.extra_options.append('--PO isOnlyHZZ=True' )
if args.hgg:
t2ws.extra_options.append('--PO isOnlyHgg=True' )
add_theory(t2ws)
if apply_reweighting:
logging.warning('Not sure if applying the reweighting is a good thing for the incl.')
obs = LatestBinning.obs_pth_ggH
obs.drop_bins_up_to_value(yukawa_exp_binning[-1]+1.0)
inc_smxs = obs.inclusive_crosssection()
t2ws.extra_options.append('--PO SMXS_of_input_ws={0}'.format(inc_smxs))
t2ws.tags.append('reweighted')
else:
t2ws.tags.append('unreweighted')
if apply_theory_uncertainties:
# 0.0795 based on theory_uncertainty_on_inclusive_xs_yukawa (crosschecks.py)
t2ws.extra_options.append('--PO inc_xs_uncertainty={0}'.format(0.079528392665))
return t2ws
def add_theory(t2ws):
coupling_variations = FileFinder(
muR=1.0, muF=1.0, Q=1.0, directory=LatestPaths.theory.yukawa.filedir
).get()
sm = [ v for v in coupling_variations if v.kappab==1.0 and v.kappac==1.0 ][0]
coupling_variations.pop(coupling_variations.index(sm))
t2ws.extra_options.append('--PO SM=[kappab=1.0,kappac=1.0,file={0}]'.format(sm.theory_file))
for variation in random.sample(coupling_variations, 7):
if variation.kappab == 0.0 and variation.kappac == 0.0: continue
t2ws.extra_options.append(
'--PO theory=[kappab={0},kappac={1},file={2}]'
.format(variation.kappab, variation.kappac, variation.theory_file)
)
def add_theory_uncertainties(t2ws, uncorrelated=False):
# Theory uncertainties
correlation_matrix = LatestPaths.theory.yukawa.correlation_matrix
theory_uncertainties = LatestPaths.theory.yukawa.uncertainties
if uncorrelated:
correlation_matrix = LatestPaths.theory.yukawa.correlation_matrix_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_Yukawa_NOTscalingbbH(args):
t2ws = base_t2ws(args)
t2ws.run()
@flag_as_option
def t2ws_Yukawa_NOTscalingbbH_floatingBRs(args):
t2ws = base_t2ws(args)
t2ws.extra_options.append('--PO freely_floating_BRs=True')
t2ws.tags.append('floatingBRs')
t2ws.run()
@flag_as_option
def t2ws_Yukawa_NOTscalingbbH_couplingdependentBRs(args):
t2ws = base_t2ws(args)
t2ws.extra_options.append('--PO BRs_kappa_dependent=True')
t2ws.tags.append('couplingdependentBRs')
t2ws.run()
#____________________________________________________________________
import traceback
def try_call_function_with_args(fn, args):
try:
fn(args)
except Exception as exc:
print traceback.format_exc()
print exc
pass
@flag_as_option
def all_t2ws_Yukawa(args_original):
args = copy.deepcopy(args_original)
for decay_channel in ['hgg', 'hzz', 'combination']:
set_decay_channel(args, decay_channel)
# t2ws_Yukawa_nominal(args)
try_call_function_with_args(t2ws_Yukawa_nominal, args)
set_decay_channel(args, 'combination')
fns = [
t2ws_Yukawa_noTheoryUnc,
t2ws_Yukawa_uncorrelatedTheoryUnc,
t2ws_Yukawa_lumiScale,
t2ws_Yukawa_profiledTotalXS,
#
# t2ws_Yukawa_BRcouplingDependency,
# t2ws_Yukawa_fitRatioOfBRs,
# t2ws_Yukawa_fitOnlyNormalization,
]
for fn in fns:
try_call_function_with_args(fn, args)
# t2ws_Yukawa_noTheoryUnc(args)
# t2ws_Yukawa_uncorrelatedTheoryUnc(args)
# t2ws_Yukawa_lumiScale(args)
# t2ws_Yukawa_BRcouplingDependency(args)
# t2ws_Yukawa_profiledTotalXS(args)
# t2ws_Yukawa_fitRatioOfBRs(args)
# t2ws_Yukawa_fitOnlyNormalization(args)
#____________________________________________________________________
@flag_as_option
def t2ws_Yukawa_nominal(args):
t2ws = base_t2ws(args)
t2ws.tags.append('nominal')
t2ws.run()
@flag_as_option
def t2ws_Yukawa_withBRuncertainties(args):
t2ws = base_t2ws(args)
t2ws.extra_options.append('--PO do_BR_uncertainties=True')
t2ws.tags.append('withBRuncertainties')
t2ws.run()
@flag_as_option
def t2ws_Yukawa_noReweighting(args):
t2ws = base_t2ws(args, apply_reweighting=False)
t2ws.tags.append('nominal')
t2ws.run()
#____________________________________________________________________
# bbH scaling is NOT necessary for kb/kc!
# @flag_as_option
# def t2ws_Yukawa_scalingbbH(args):
# # Basically nominal, but force asimov and hzz
# # args = differentialutils.set_one_decay_channel(args, 'combination', asimov=True)
# t2ws = base_t2ws(args)
# t2ws.extra_options.append('--PO add_scaling_bbH=True')
# t2ws.tags.append('scalingbbH')
# t2ws.run()
# @flag_as_option
# def t2ws_Yukawa_scalingbbH_floatingBRs(args):
# # args = differentialutils.set_one_decay_channel(args, 'combination', asimov=True)
# t2ws = base_t2ws(args)
# t2ws.extra_options.append('--PO add_scaling_bbH=True')
# t2ws.tags.append('scalingbbH')
# t2ws.extra_options.append('--PO freely_floating_BRs=True')
# t2ws.tags.append('floatingBRs')
# t2ws.run()
# @flag_as_option
# def t2ws_Yukawa_scalingbbH_couplingdependentBRs(args):
# # Basically nominal, but force asimov and hzz
# # args = differentialutils.set_one_decay_channel(args, 'combination', asimov=True)
# t2ws = base_t2ws(args)
# t2ws.extra_options.append('--PO add_scaling_bbH=True')
# t2ws.tags.append('scalingbbH')
# t2ws.extra_options.append('--PO BRs_kappa_dependent=True')
# t2ws.tags.append('couplingdependentBRs')
# t2ws.run()
#____________________________________________________________________
# Scans for Giovanni
@flag_as_option
def t2ws_Yukawa_G0A(args):
# Basically nominal, but force asimov and hzz
args = differentialutils.set_one_decay_channel(args, 'combination', asimov=True)
t2ws = base_t2ws(args)
t2ws.tags.append('G0A')
t2ws.run()
@flag_as_option
def t2ws_Yukawa_G0A_unreweighted(args):
# This is actually not interesting
args = differentialutils.set_one_decay_channel(args, 'combination', asimov=True)
t2ws = base_t2ws(args, apply_reweighting=False)
t2ws.tags.append('G0A')
t2ws.run()
@flag_as_option
def t2ws_Yukawa_G0B(args):
args = differentialutils.set_one_decay_channel(args, 'combination', asimov=True)
t2ws = base_t2ws_fitOnlyTotalXS(args)
t2ws.tags.append('G0B')
t2ws.run()
@flag_as_option
def t2ws_Yukawa_G0A_reweighted_scaledByMuTotalXS(args):
# Basically nominal, but force asimov and hzz
args = differentialutils.set_one_decay_channel(args, 'combination', asimov=True)
t2ws = base_t2ws(args)
t2ws.tags.append('G0A')
t2ws.tags.append('scaledByMuTotalXS')
t2ws.extra_options.append('--PO scale_with_mu_totalXS=True')
t2ws.run()
@flag_as_option
def t2ws_Yukawa_G0B_reweighted(args):
args = differentialutils.set_one_decay_channel(args, 'combination', asimov=True)
t2ws = base_t2ws_fitOnlyTotalXS(args, apply_reweighting=True)
t2ws.tags.append('G0B')
t2ws.run()
@flag_as_option
def t2ws_Yukawa_G1A(args):
args = differentialutils.set_one_decay_channel(args, 'combination', asimov=True)
t2ws = base_t2ws(args, apply_reweighting=False)
t2ws.tags.append('G1A')
t2ws.extra_options.append('--PO BRs_kappa_dependent=True')
t2ws.run()
@flag_as_option
def t2ws_Yukawa_G1A_unreweighted(args):
args = differentialutils.set_one_decay_channel(args, 'combination', asimov=True)
t2ws = base_t2ws(args)
t2ws.tags.append('G1A')
t2ws.extra_options.append('--PO BRs_kappa_dependent=True')
t2ws.run()
@flag_as_option
def t2ws_Yukawa_G1B_reweighted(args):
args = differentialutils.set_one_decay_channel(args, 'combination', asimov=True)
t2ws = base_t2ws_fitOnlyTotalXS(args, apply_reweighting=True)
t2ws.tags.append('G1B')
t2ws.extra_options.append('--PO BRs_kappa_dependent=True')
t2ws.run()
@flag_as_option
def t2ws_Yukawa_G1B(args):
args = differentialutils.set_one_decay_channel(args, 'combination', asimov=True)
t2ws = base_t2ws_fitOnlyTotalXS(args)
t2ws.tags.append('G1B')
t2ws.extra_options.append('--PO BRs_kappa_dependent=True')
t2ws.run()
@flag_as_option
def t2ws_Yukawa_G2A(args):
args = differentialutils.set_one_decay_channel(args, 'combination', asimov=True)
t2ws = base_t2ws(args)
t2ws.tags.append('G2A')
t2ws.extra_options.append('--PO freely_floating_BRs=True')
t2ws.run()
@flag_as_option
def t2ws_Yukawa_G1A_reweighted_noTheoryUnc(args):
args = differentialutils.set_one_decay_channel(args, 'combination', asimov=True)
t2ws = base_t2ws(args, apply_reweighting=True, apply_theory_uncertainties=False)
t2ws.tags.append('G1A')
t2ws.tags.append('noTheoryUnc')
t2ws.extra_options.append('--PO BRs_kappa_dependent=True')
t2ws.run()
@flag_as_option
def t2ws_Yukawa_G1B_reweighted_noTheoryUnc(args):
args = differentialutils.set_one_decay_channel(args, 'combination', asimov=True)
t2ws = base_t2ws_fitOnlyTotalXS(args, apply_reweighting=True, apply_theory_uncertainties=False)
t2ws.tags.append('G1B')
t2ws.tags.append('noTheoryUnc')
t2ws.extra_options.append('--PO BRs_kappa_dependent=True')
t2ws.run()
@flag_as_option
def t2ws_Yukawa_G1A_reweighted_noTheoryUnc_scaledByMuTotalXS(args):
args = differentialutils.set_one_decay_channel(args, 'combination', asimov=True)
t2ws = base_t2ws(args, apply_reweighting=True, apply_theory_uncertainties=False)
t2ws.tags.append('G1A')
t2ws.tags.append('noTheoryUnc')
t2ws.tags.append('scaledByMuTotalXS')
t2ws.extra_options.append('--PO BRs_kappa_dependent=True')
t2ws.extra_options.append('--PO scale_with_mu_totalXS=True')
t2ws.run()
#
@flag_as_option
def t2ws_Yukawa_noTheoryUnc(args):
t2ws = base_t2ws(args, apply_theory_uncertainties=False)
t2ws.tags.append('noTheoryUnc')
t2ws.run()
@flag_as_option
def t2ws_Yukawa_uncorrelatedTheoryUnc(args):
t2ws = base_t2ws(args, apply_theory_uncertainties=False)
add_theory_uncertainties(t2ws, uncorrelated=True)
t2ws.run()
@flag_as_option
def t2ws_Yukawa_lumiScale(args):
t2ws = base_t2ws(args)
t2ws.tags.append('lumiScale')
t2ws.extra_options.append('--PO lumiScale=True')
t2ws.run()
@flag_as_option
def t2ws_Yukawa_profiledTotalXS(args):
t2ws = base_t2ws(args)
t2ws.tags.append('profiledTotalXS')
t2ws.extra_options.append('--PO ProfileTotalXS=True')
t2ws.run()
# @flag_as_option
# def t2ws_Yukawa_fitOnlyNormalization(args):
# t2ws = base_t2ws(args)
# t2ws.tags.append('fitOnlyNormalization')
# add_theory_uncertainties(t2ws)
# t2ws.extra_options.append('--PO FitOnlyNormalization=True')
# t2ws.run()
@flag_as_option
def t2ws_Yukawa_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_Yukawa_fitRatioOfBRs(args):
# t2ws = base_t2ws(args)
# t2ws.tags.append('fitRatioOfBRs')
# t2ws.extra_options.append('--PO FitRatioOfBRs=True')
# t2ws.run()