analysis.py 10.6 KB
Newer Older
1
2
3
4
# coding: utf-8
# flake8: noqa

"""
5
Definition of the diHiggs analysis in the bbWW (SL) channel.
6
7
8
9
"""

import scinum as sn
import order as od
10
import six
11
import copy
12
import re
13
14
15
16

#
# analysis and config
#
17
18
19
import config.Run2_pp_13TeV_2016 as run_2016
import config.Run2_pp_13TeV_2017 as run_2017
import config.Run2_pp_13TeV_2018 as run_2018
Benjamin Fischer's avatar
Benjamin Fischer committed
20
from tasks.corrections.gf_hh import HHReweigthing
21
22
from config.util import PrepareConfig
from config.processes import get, rgb
Benjamin Fischer's avatar
Benjamin Fischer committed
23
24
25
26
27
28
29
30
from config.constants import (
    BR_HH_BBTAUTAU,
    BR_HH_BBVV_DL,
    HHres,
    HHxs,
    gfHHparams,
    gfHHparamsNoSample,
)
31
32

# create the analysis
33
analysis = od.Analysis("diHiggs_sl", 2)
34

35
36
analysis.set_aux("doFakeNonClosureCorrection", True)

37
# setup the config for the 2016, 2017, 2018 campaign
38
# we pass no name, so the config will have the same name as the campaign
39
40
41
config_2016 = run_2016.default_config(analysis=analysis)
config_2017 = run_2017.default_config(analysis=analysis)
config_2018 = run_2018.default_config(analysis=analysis)
42
43
44
45
46
47
48
49
50

procs = [
    od.Process(
        "dc_others",
        999989,
        label=r"Others",
        color=rgb(103, 179, 153),
        processes=[
            get("rare"),
Peter Fackeldey's avatar
Peter Fackeldey committed
51
52
53
            # get("ttVV"),
            # get("ttVH"),
            # get("ttV"),
54
55
56
            # get("vvv"),
            # get("WJetsToLNu_HT"),
            # get("wjets"),
Peter Fackeldey's avatar
black    
Peter Fackeldey committed
57
        ],
58
    ),
Peter Fackeldey's avatar
Peter Fackeldey committed
59
60
61
    od.Process(
        "dc_ttVX",
        999990,
62
        label="ttVX",
Peter Fackeldey's avatar
Peter Fackeldey committed
63
64
        processes=[get("ttV"), get("ttVV")],
    ),
Peter Fackeldey's avatar
Peter Fackeldey committed
65
66
67
    od.Process(
        "dc_ggHbb",
        23412341,
Dennis Noll's avatar
merge    
Dennis Noll committed
68
        label="ggH(bb)",
Peter Fackeldey's avatar
Peter Fackeldey committed
69
70
71
72
73
        processes=[get("GluGluHToBB_M125"), get("GluGluHToTauTau_M125")],
    ),
    od.Process(
        "dc_qqHbb",
        23412351,
Dennis Noll's avatar
merge    
Dennis Noll committed
74
        label="qqH(bb)",
Peter Fackeldey's avatar
Peter Fackeldey committed
75
76
77
78
79
        processes=[get("VBFHToBB_M_125"), get("VBFHToTauTau_M125")],
    ),
    od.Process(
        "dc_ZHbb",
        23412361,
80
        label="ZH(bb)",
Peter Fackeldey's avatar
Peter Fackeldey committed
81
82
        processes=[get("ZH_DY"), get("ggZH"), get("ZHToTauTau_M125")],
    ),
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
    od.Process(
        "plot_vv(v)",
        999991,
        color=rgb(82, 124, 182),
        label=r"Multi-boson",
        processes=[get("vv"), get("vvv")],
    ),
    od.Process(
        "plot_other",
        999992,
        color=rgb(152, 78, 163),
        label=r"Other",
        processes=[get("rare"), get("ttV"), get("ttVV"), get("ttVH")],
    ),
    od.Process(
        "class_multiboson",
        3789273,
100
        label="VV(V)",
101
102
103
104
105
        processes=[get("vv"), get("vvv")],
    ),
    od.Process(
        "class_ttVX",
        3789274,
106
        label="ttVX",
107
108
        processes=[get("ttV"), get("ttVH"), get("ttVV")],
    ),
109
110
111
112
    od.Process(
        "fakes",
        999993,
        color=rgb(137, 207, 240),
113
        label="Fakes",
114
        is_data=True,
115
        aux=dict(dynamic=True),  # content is generated on-the-fly, don't whine about no datasets
116
    ),
117
]
118
od.Process(
119
    "class_HHGluGlu_NLO",
120
    17789277,
121
    label="HH(GGF)",
122
123
124
125
126
    processes=[
        get("HH_2B2WToLNu2J_GluGlu_NLO"),
        get("HH_2B2VTo2L2Nu_GluGlu_NLO"),
        get("HH_2B2Tau_GluGlu_NLO"),
    ],
127
128
)
od.Process(
129
    "class_HHVBF_NLO",
130
    17789278,
131
    label="HH(VBF)",
132
133
134
135
136
    processes=[
        get("HH_2B2WToLNu2J_VBF_NLO"),
        get("HH_2B2VTo2L2Nu_VBF_NLO"),
        get("HH_2B2Tau_VBF_NLO"),
    ],
137
)
138
139
140
od.Process(
    "class_other",
    3789275,
141
    label="Other",
142
143
144
145
146
147
148
149
150
151
    processes=[
        get("dy"),
        get("ttV"),
        get("ttVH"),
        get("ttVV"),
        get("vv"),
        get("vvv"),
        get("rare"),
    ],
)
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
od.Process(
    "plot_H",
    23412371,
    label=r"(SM) Higgs",
    label_short="H",
    color=rgb(120, 33, 80),
    processes=[
        get("ttVH"),
        get("HZJ_HToWW_M125"),
        get("TH"),
        get("ttH"),
        get("WH"),
        get("dc_ggHbb"),
        get("dc_qqHbb"),
        get("dc_ZHbb"),
        get("GluGluHToWWToLNuQQ_M125_NNPDF31"),
        get("VBFHToWWToLNuQQ_M125_NNPDF31"),
    ],
)
od.Process(
    "plot_others",
    23412372,
    color=rgb(152, 78, 163),
    label=r"Others",
    processes=[get("dc_others"), get("ttV"), get("ttVV")],
),

Peter Fackeldey's avatar
Peter Fackeldey committed
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
# merge signals
signals = (
    "qqHH_CV_1_C2V_1_kl_0",
    "qqHH_CV_1_C2V_1_kl_1",
    "qqHH_CV_1_C2V_1_kl_2",
    "qqHH_CV_1_C2V_2_kl_1",
    "qqHH_CV_1_5_C2V_1_kl_1",
    "qqHH_CV_0_5_C2V_1_kl_1",
    "qqHH_CV_1_C2V_0_kl_1",
    "ggHH_kl_0_kt_1",
    "ggHH_kl_1_kt_1",
    "ggHH_kl_2p45_kt_1",
    "ggHH_kl_5_kt_1",
)
for i, s in enumerate(signals):
195
196
    sl = get(f"{s}_2B2WToLNu2J")
    dl = get(f"{s}_2B2VTo2L2Nu")
197
198
199
200
201
202
    ls = dl.label_short.replace(
        r"HH$, $H \rightarrow b\bar{b}$, $H \rightarrow VV$ (DL)",
        r"HH \rightarrow b\bar{b}VV$" + "\n",
    ).replace("\n ", "\n")
    if s in ("qqHH_CV_1_C2V_1_kl_1", "ggHH_kl_1_kt_1"):
        ls = re.sub(r"\s*\(NLO\) -.+", " (NLO, SM)", ls)
203
    get("diHiggs").add_process(
Peter Fackeldey's avatar
Peter Fackeldey committed
204
205
        f"{s}_2B2V",
        1900 + i,
206
        label=dl.label.replace(" (DL)", ""),
207
        label_short=ls,
208
        processes=[sl, dl],
Peter Fackeldey's avatar
Peter Fackeldey committed
209
210
    )

211

212
for year, cfg in ("2016", config_2016), ("2017", config_2017), ("2018", config_2018):
213
    # corrections which are only used for distinct analyses
214
    cfg.aux["non_common_corrections"] = ["Fake", "VJetsCorrections"]
215
    cfg.aux["multiclass_group"] = "mergedinclusive"
216

217
218
219
220
221
222
223
224
225
226
227
228
229
230
    # categories and files used for the sync of yields
    # fmt: off
    cfg.aux["sync_yield"] = {
        "category": "(all_(boosted|resolved_1b|resolved_2b)_sr_prompt_dnn_node_class_HH.+_NLO|all_(boosted|resolved_1b|resolved_2b)_sr_prompt_dnn_node_H|all_(boosted|resolved)_sr_prompt_dnn_node_tt|all_(boosted|resolved)_sr_prompt_dnn_node_wjets|all_incl_sr_prompt$)",
        "paths": {"TLL": "/net/scratch/cms/dihiggs/sync/tll_sl_2016.json"},
        "lut": {
            "all_incl_sr_prompt": "total",
            "all_resolved_1b_sr_prompt_dnn_node_H": "H_resolved_1b",
            "all_resolved_2b_sr_prompt_dnn_node_H": "H_resolved_2b",
            "all_boosted_sr_prompt_dnn_node_H": "H_boosted",
            "all_resolved_sr_prompt_dnn_node_tt": "TT_resolved",
            "all_boosted_sr_prompt_dnn_node_tt": "TT_boosted",
            "all_resolved_sr_prompt_dnn_node_wjets": "W_resolved",
            "all_boosted_sr_prompt_dnn_node_wjets": "W_boosted",
231
        }
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
    }
    # fmt: on
    #
    # process groups
    #
    cfg.set_aux(
        "process_groups",
        {
            # just defines the grouping during plotting/inference
            "plotting": [
                "tt",
                "dy",
                "st",
                "fakes",
                # "QCD",
                "wjets",
                "plot_vv(v)",
                "plot_others",
                "plot_H",
251
                "qqHH_CV_1_C2V_1_kl_1_2B2V",
252
253
                "ggHH_kl_1_kt_1_2B2V",  # "qqHH_CV_1_C2V_1_kl_1_2B2WToLNu2J",  # "ggHH_kl_1_kt_1_2B2WToLNu2J",  # "ggHH_kl_1_kt_1_2B2VTo2L2Nu",  # "GluGluToHHTo2B2VTo2L2Nu_node_SM",
                "data",
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
    cfg.set_aux(
        "multiclass_groups",
        {
            "mergedinclusive": {
                "class_HHGluGlu_NLO": {"groups": ["signal", "constrain", "fit"]},
                "class_HHVBF_NLO": {"groups": ["signal", "constrain", "fit"]},
                "tt": {"groups": ["background", "constrain"]},
                "st": {"groups": ["background"]},
                "wjets": {"groups": ["background"]},
                "H": {"groups": ["background"]},
                "class_other": {"groups": ["background"]},
            },
            "ggfttbar": {
                "ggHH_kl_1_kt_1_2B2WToLNu2J": {"groups": ["signal", "constrain", "fit"]},
                "tt": {"groups": ["background", "constrain"]},
            },
        },
    )

    cfg.set_aux(
        "btag_sf_shifts",
        [
            "lf",
            "lfstats1",
            "lfstats2",
            "hf",
            "hfstats1",
            "hfstats2",
            "cferr1",
            "cferr2",
        ],
    )

    cfg.set_aux(
        "sync",
        {
            "lookup_set": {
                ("mu", "m"),
                ("ee", "ee"),
                ("emu", "em"),
                ("mumu", "mm"),
                ("min_dhi_jet", "min_dphi_jet"),
                ("vbf_tag", "VBF_tag"),
                ("electron", "ele"),
                ("muon", "mu"),
                ("jet", "ak4Jet"),
                ("fat", "ak8Jet"),
                ("weight_gen_weight", "MC_weight"),
                ("weight_pileup", "PU_weight"),
                ("weight_trigger_electron_sf", "weight_trigger_el_sf"),
                ("weight_trigger_muon_sf", "weight_trigger_mu_sf"),
            },
            "categories": ["is_all_incl_sr_prompt"],
            "eventnr": "eventnr",
            "int_vars": ["eventnr", "dataset_id"],
        },
    )
    PrepareConfig(
        cfg,
        channels=[],  # leave empty: otherwise we can not access single lepton triggers anymore
        # defines which datasets we will use
        processes=[
            "data",
            "HH_2B2WToLNu2J",
            "HH_2B2VTo2L2Nu",
            "HH_2B2Tau",
            "H",
            "tt",
            "dy_lep_10To50",
            "dy_lep_50ToInf",
            "dy_lep_nj",
            "vv",
            "st",
            "WJetsToLNu",
            "WnJetsToLNu",
            "WJetsToLNu_HT",
Benjamin Fischer's avatar
Benjamin Fischer committed
334
335
            # "WBJetsToLNu_Wpt",
            # "WJetsToLNu_BGenFilter_Wpt",
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
            "ttV",
            "ttVV",
            "ttVH",
            "vvv",
            "rare",
            "QCD",
        ],
        skip_process=lambda process: process.name.endswith(HHres["resonance"]),
        ignore_datasets=[
            # "TTToHadronic",
            # "THQ_ctcvcp_4f_Hincl",
        ],  # , "ZH_HToBB_ZToLL_M125", "TTWW"],
        allowed_exclusive_processes=[
            "wjets_lep",
            "dy_50to",
        ],
    )

    HHReweigthing.update_config(
        config=cfg,
Benjamin Fischer's avatar
Benjamin Fischer committed
356
357
358
359
        root_processes={
            "HH_2B2VTo2L2Nu_GluGlu": BR_HH_BBVV_DL,
            "HH_2B2Tau_GluGlu": BR_HH_BBTAUTAU,
        },
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
        benchmarks=(
            [dict(kl=x) for x in HHxs["gf_nnlo_ftapprox"].keys()]
            + [
                dict(
                    name=f"BM12_{i}",
                    **{k: gfHHparams[k][i] for k in gfHHparams.dtype.names},
                )
                for i in range(1, len(gfHHparams))  # skip first, since SM := kl=1
            ]
            + [
                dict(
                    name="BM12_8a" if i == 0 else f"BM7_{i}",
                    **{k: gfHHparamsNoSample[k][i] for k in gfHHparamsNoSample.dtype.names},
                )
                for i in range(len(gfHHparamsNoSample))
            ]
        ),
377
    )
Benjamin Fischer's avatar
Benjamin Fischer committed
378

379
    from .categories import setup_categories
380

381
    setup_categories(cfg)
382

383
    from .variables import setup_variables
384

385
    setup_variables(cfg)
386

387
388
389
    #
    # other configurations
    #
390

391
    cfg.set_aux("signal_process", "diHiggs")