analysis.py 9.85 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
from config.constants import HHres, HHxs
24
25

# create the analysis
26
analysis = od.Analysis("diHiggs_sl", 2)
27

28
29
analysis.set_aux("doFakeNonClosureCorrection", True)

30
# setup the config for the 2016, 2017, 2018 campaign
31
# we pass no name, so the config will have the same name as the campaign
32
33
34
config_2016 = run_2016.default_config(analysis=analysis)
config_2017 = run_2017.default_config(analysis=analysis)
config_2018 = run_2018.default_config(analysis=analysis)
35
36
37
38
39
40
41
42
43

procs = [
    od.Process(
        "dc_others",
        999989,
        label=r"Others",
        color=rgb(103, 179, 153),
        processes=[
            get("rare"),
Peter Fackeldey's avatar
Peter Fackeldey committed
44
45
46
            # get("ttVV"),
            # get("ttVH"),
            # get("ttV"),
47
48
49
            # get("vvv"),
            # get("WJetsToLNu_HT"),
            # get("wjets"),
Peter Fackeldey's avatar
black    
Peter Fackeldey committed
50
        ],
51
    ),
Peter Fackeldey's avatar
Peter Fackeldey committed
52
53
54
    od.Process(
        "dc_ttVX",
        999990,
55
        label="ttVX",
Peter Fackeldey's avatar
Peter Fackeldey committed
56
57
        processes=[get("ttV"), get("ttVV")],
    ),
Peter Fackeldey's avatar
Peter Fackeldey committed
58
59
60
    od.Process(
        "dc_ggHbb",
        23412341,
Dennis Noll's avatar
merge    
Dennis Noll committed
61
        label="ggH(bb)",
Peter Fackeldey's avatar
Peter Fackeldey committed
62
63
64
65
66
        processes=[get("GluGluHToBB_M125"), get("GluGluHToTauTau_M125")],
    ),
    od.Process(
        "dc_qqHbb",
        23412351,
Dennis Noll's avatar
merge    
Dennis Noll committed
67
        label="qqH(bb)",
Peter Fackeldey's avatar
Peter Fackeldey committed
68
69
70
71
72
        processes=[get("VBFHToBB_M_125"), get("VBFHToTauTau_M125")],
    ),
    od.Process(
        "dc_ZHbb",
        23412361,
73
        label="ZH(bb)",
Peter Fackeldey's avatar
Peter Fackeldey committed
74
75
        processes=[get("ZH_DY"), get("ggZH"), get("ZHToTauTau_M125")],
    ),
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
    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,
93
        label="VV(V)",
94
95
96
97
98
        processes=[get("vv"), get("vvv")],
    ),
    od.Process(
        "class_ttVX",
        3789274,
99
        label="ttVX",
100
101
        processes=[get("ttV"), get("ttVH"), get("ttVV")],
    ),
102
103
104
105
    od.Process(
        "fakes",
        999993,
        color=rgb(137, 207, 240),
106
        label="Fakes",
107
        is_data=True,
108
        aux=dict(dynamic=True),  # content is generated on-the-fly, don't whine about no datasets
109
    ),
110
]
111
od.Process(
112
    "class_HHGluGlu_NLO",
113
    17789277,
114
    label="HH(GGF)",
115
116
117
118
119
    processes=[
        get("HH_2B2WToLNu2J_GluGlu_NLO"),
        get("HH_2B2VTo2L2Nu_GluGlu_NLO"),
        get("HH_2B2Tau_GluGlu_NLO"),
    ],
120
121
)
od.Process(
122
    "class_HHVBF_NLO",
123
    17789278,
124
    label="HH(VBF)",
125
126
127
128
129
    processes=[
        get("HH_2B2WToLNu2J_VBF_NLO"),
        get("HH_2B2VTo2L2Nu_VBF_NLO"),
        get("HH_2B2Tau_VBF_NLO"),
    ],
130
)
131
132
133
od.Process(
    "class_other",
    3789275,
134
    label="Other",
135
136
137
138
139
140
141
142
143
144
    processes=[
        get("dy"),
        get("ttV"),
        get("ttVH"),
        get("ttVV"),
        get("vv"),
        get("vvv"),
        get("rare"),
    ],
)
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
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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
# 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):
188
189
    sl = get(f"{s}_2B2WToLNu2J")
    dl = get(f"{s}_2B2VTo2L2Nu")
190
    get("diHiggs").add_process(
Peter Fackeldey's avatar
Peter Fackeldey committed
191
192
        f"{s}_2B2V",
        1900 + i,
193
194
195
196
197
198
        label=dl.label.replace(" (DL)", ""),
        label_short=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"),
        processes=[sl, dl],
Peter Fackeldey's avatar
Peter Fackeldey committed
199
200
    )

201

202
for year, cfg in ("2016", config_2016), ("2017", config_2017), ("2018", config_2018):
203
    cfg.aux["non_common_corrections"] = []  # corrections which are only used for distinct analyses
204
    cfg.aux["multiclass_group"] = "mergedinclusive"
205

206
207
208
209
210
211
212
213
214
215
216
217
218
219
    # 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",
220
        }
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
    }
    # 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",
240
                "qqHH_CV_1_C2V_1_kl_1_2B2V",
241
242
                "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",
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
    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
323
324
            # "WBJetsToLNu_Wpt",
            # "WJetsToLNu_BGenFilter_Wpt",
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
            "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,
        root_processes=[
            "HH_2B2WToLNu2J_GluGlu",
            "HH_2B2WToLNu2J_VBF",
            "HH_2B2VTo2L2Nu_GluGlu",
            "HH_2B2VTo2L2Nu_VBF",
        ],
        benchmarks=[dict(kl=x) for x in HHxs["gf_nnlo_ftapprox"].keys()],
    )
Benjamin Fischer's avatar
Benjamin Fischer committed
353

354
    from .categories import setup_categories
355

356
    setup_categories(cfg)
357

358
    from .variables import setup_variables
359

360
    setup_variables(cfg)
361

362
363
364
    #
    # other configurations
    #
365

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