analysis.py 9.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
import re
9
10
11
12

#
# analysis and config
#
Benjamin Fischer's avatar
Benjamin Fischer committed
13
from tasks.corrections.gf_hh import HHReweigthing
14
from config.util import PrepareConfig
Peter Fackeldey's avatar
Peter Fackeldey committed
15
from utils.aci import rgb
Benjamin Fischer's avatar
Benjamin Fischer committed
16
17
from config.constants import (
    BR_HH_BBTAUTAU,
18
    BR_HH_BBWW_SL,
Benjamin Fischer's avatar
Benjamin Fischer committed
19
20
21
22
23
24
    BR_HH_BBVV_DL,
    HHres,
    HHxs,
    gfHHparams,
    gfHHparamsNoSample,
)
25
from tasks.multiclass import MulticlassConfig
Peter Fackeldey's avatar
Peter Fackeldey committed
26
27
28
import utils.aci as aci
from config.analysis import analysis

29
30

# create the analysis
Peter Fackeldey's avatar
Peter Fackeldey committed
31
32
analysis = analysis.copy(name="diHiggs_sl")
get = analysis.processes.get
33

Peter Fackeldey's avatar
Peter Fackeldey committed
34
35
36
37
# add analysis specific processes
specific_processes = []

# fmt: off
Peter Fackeldey's avatar
Peter Fackeldey committed
38
dc_others = aci.Process(name="dc_others", id=999989, label=r"Others", color=rgb(103, 179, 153), processes=[get("rare")])
Peter Fackeldey's avatar
Peter Fackeldey committed
39
40
specific_processes.append(dc_others)

Peter Fackeldey's avatar
Peter Fackeldey committed
41
dc_ttVX = aci.Process(name="dc_ttVX", id=999990, label="ttVX", processes=[get("ttV"), get("ttVV")])
Peter Fackeldey's avatar
Peter Fackeldey committed
42
43
specific_processes.append(dc_ttVX)

Peter Fackeldey's avatar
Peter Fackeldey committed
44
dc_ggHbb = aci.Process(name="dc_ggHbb", id=23412341, label="ggH(bb)", processes=[get("GluGluHToBB_M125"), get("GluGluHToTauTau_M125")])
Peter Fackeldey's avatar
Peter Fackeldey committed
45
46
specific_processes.append(dc_ggHbb)

Peter Fackeldey's avatar
Peter Fackeldey committed
47
dc_qqHbb = aci.Process(name="dc_qqHbb", id=23412351, label="qqH(bb)", processes=[get("VBFHToBB_M_125"), get("VBFHToTauTau_M125")])
Peter Fackeldey's avatar
Peter Fackeldey committed
48
49
specific_processes.append(dc_qqHbb)

Peter Fackeldey's avatar
Peter Fackeldey committed
50
dc_ZHbb = aci.Process(name="dc_ZHbb", id=23412361, label="ZH(bb)", processes=[get("ZH_DY"), get("ggZH"), get("ZHToTauTau_M125")])
Peter Fackeldey's avatar
Peter Fackeldey committed
51
52
specific_processes.append(dc_ZHbb)

Peter Fackeldey's avatar
Peter Fackeldey committed
53
plot_vv_v = aci.Process(name="plot_vv(v)", id=999991, color=rgb(82, 124, 182), label=r"Multi-boson", processes=[get("vv"), get("vvv")])
Peter Fackeldey's avatar
Peter Fackeldey committed
54
55
specific_processes.append(plot_vv_v)

56
plot_other = aci.Process(name="plot_other", id=999992, color=rgb(152, 78, 163), label=r"Other", processes=[get("rare"), get("ttV"), get("ttVV")])
Peter Fackeldey's avatar
Peter Fackeldey committed
57
58
specific_processes.append(plot_other)

Peter Fackeldey's avatar
Peter Fackeldey committed
59
class_multiboson = aci.Process(name="class_multiboson", id=3789273, label="VV(V)", processes=[get("vv"), get("vvv")])
Peter Fackeldey's avatar
Peter Fackeldey committed
60
61
specific_processes.append(class_multiboson)

Peter Fackeldey's avatar
Peter Fackeldey committed
62
class_ttVX = aci.Process(name="class_ttVX", id=3789274, label="ttVX", processes=[get("ttV"), get("ttVH"), get("ttVV")])
Peter Fackeldey's avatar
Peter Fackeldey committed
63
64
65
66
67
68
specific_processes.append(class_ttVX)

# content is generated on-the-fly, don't whine about no datasets [dynamic]
fakes = aci.Process(name="fakes", id=999993, color=rgb(137, 207, 240), label="Fakes", is_data=True, aux=dict(dynamic=True))
specific_processes.append(fakes)

Peter Fackeldey's avatar
Peter Fackeldey committed
69
class_HHGluGlu_NLO = aci.Process(name="class_HHGluGlu_NLO", id=17789277, label="HH(GGF)", processes=[get("HH_2B2WToLNu2J_GluGlu_NLO"), get("HH_2B2VTo2L2Nu_GluGlu_NLO"), get("HH_2B2Tau_GluGlu_NLO")])
Peter Fackeldey's avatar
Peter Fackeldey committed
70
71
specific_processes.append(class_HHGluGlu_NLO)
    
Peter Fackeldey's avatar
Peter Fackeldey committed
72
class_HHVBF_NLO = aci.Process(name="class_HHVBF_NLO", id=17789278, label="HH(VBF)", processes=[get("HH_2B2WToLNu2J_VBF_NLO"), get("HH_2B2VTo2L2Nu_VBF_NLO"), get("HH_2B2Tau_VBF_NLO")])
Peter Fackeldey's avatar
Peter Fackeldey committed
73
74
specific_processes.append(class_HHVBF_NLO)

75
class_other = aci.Process(name="class_other", id=3789275, label="Other", processes=[get("dy"), get("ttV"), get("ttVV"), get("vv"), get("vvv"), get("rare")])
Peter Fackeldey's avatar
Peter Fackeldey committed
76
77
specific_processes.append(class_other)

Peter Fackeldey's avatar
Peter Fackeldey committed
78
plot_H = aci.Process(name="plot_H", id=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"), dc_ggHbb, dc_qqHbb, dc_ZHbb, get("GluGluHToWWToLNuQQ_M125_NNPDF31"), get("VBFHToWWToLNuQQ_M125_NNPDF31")])
Peter Fackeldey's avatar
Peter Fackeldey committed
79
80
specific_processes.append(plot_H)

Peter Fackeldey's avatar
Peter Fackeldey committed
81
plot_others = aci.Process(name="plot_others", id=23412372, color=rgb(152, 78, 163), label=r"Others", processes=[dc_others, get("ttV"), get("ttVV")])
Peter Fackeldey's avatar
Peter Fackeldey committed
82
83
84
specific_processes.append(plot_others)

# fmt: on
85

Peter Fackeldey's avatar
Peter Fackeldey committed
86
# merge signals
Peter Fackeldey's avatar
Peter Fackeldey committed
87
specific_signals = []
Peter Fackeldey's avatar
Peter Fackeldey committed
88
89
90
91
92
93
94
95
96
97
98
99
100
101
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):
102
103
    sl = get(f"{s}_2B2WToLNu2J")
    dl = get(f"{s}_2B2VTo2L2Nu")
104
105
106
107
108
109
    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)
Peter Fackeldey's avatar
Peter Fackeldey committed
110
    p = aci.Process(
Peter Fackeldey's avatar
Peter Fackeldey committed
111
112
113
114
115
        name=f"{s}_2B2V",
        id=1900 + i,
        label=dl.label.replace(" (DL)", ""),
        label_short=ls,
        processes=[sl, dl],
Peter Fackeldey's avatar
Peter Fackeldey committed
116
    )
Peter Fackeldey's avatar
Peter Fackeldey committed
117
118
119
120
121
122
    # add to parent
    get("diHiggs").processes.add(p)
    specific_signals.append(p)

# add all processes now
analysis.processes.extend(specific_processes + specific_signals)
Peter Fackeldey's avatar
Peter Fackeldey committed
123

Peter Fackeldey's avatar
Peter Fackeldey committed
124
125
126
# corrections which are only used for distinct analyses
analysis.aux["non_common_corrections"] = ["Fake", "VJetsCorrections"]
analysis.aux["doFakeNonClosureCorrection"] = True
127

Peter Fackeldey's avatar
Peter Fackeldey committed
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# categories and files used for the sync of yields
# fmt: off
analysis.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",
142
    }
Peter Fackeldey's avatar
Peter Fackeldey committed
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
}
# fmt: on
#
# process groups
#
analysis.aux["process_groups"] = {
    # just defines the grouping during plotting/inference
    "plotting": [
        "tt",
        "dy",
        "st",
        "fakes",
        # "QCD",
        "wjets",
        "plot_vv(v)",
        "plot_others",
        "plot_H",
        "qqHH_CV_1_C2V_1_kl_1_2B2V",
        "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",
    ],
}
165

Peter Fackeldey's avatar
Peter Fackeldey committed
166
167
168
169
170
171
172
173
174
175
analysis.aux["btag_sf_shifts"] = [
    "lf",
    "lfstats1",
    "lfstats2",
    "hf",
    "hfstats1",
    "hfstats2",
    "cferr1",
    "cferr2",
]
176

Peter Fackeldey's avatar
Peter Fackeldey committed
177
178
analysis.aux["sync"] = {
    "lookup_set": {
179
180
181
182
183
        (b">=", b"geq"),
        (b"==", b"eq"),
        (b"<=", b"leq"),
        (b">", b"g"),
        (b"<", b"l"),
Peter Fackeldey's avatar
Peter Fackeldey committed
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
    },
    "categories": ["is_all_incl_sr_prompt"],
    "eventnr": "eventnr",
    "int_vars": ["eventnr", "dataset_id"],
}
PrepareConfig(
    analysis,
    # 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",
        # "WBJetsToLNu_Wpt",
        # "WJetsToLNu_BGenFilter_Wpt",
        "ttV",
        "ttVV",
        "ttVH",
        "vvv",
        "rare",
        # "QCD",  # -> already included in fakes process
    ],
    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",
    ],
)
226

Peter Fackeldey's avatar
Peter Fackeldey committed
227
228
229
HHReweigthing.update_config(
    config=analysis,
    root_processes={
230
        "HH_2B2WToLNu2J_GluGlu": BR_HH_BBWW_SL,
Peter Fackeldey's avatar
Peter Fackeldey committed
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
        "HH_2B2VTo2L2Nu_GluGlu": BR_HH_BBVV_DL,
        "HH_2B2Tau_GluGlu": BR_HH_BBTAUTAU,
    },
    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))
        ]
    ),
)
252
253
254
255
256
class_HHGluGlu_NLO_reweight = aci.Process(
    name="class_HHGluGlu_NLO_reweight",
    id=17789287,
    label="HH(GGF)",
    processes=[
257
258
259
260
261
262
263
        proc
        for parent_process in [
            "HH_2B2WToLNu2J_GluGlu_reweight",
            "HH_2B2VTo2L2Nu_GluGlu_reweight",
            "HH_2B2Tau_GluGlu_reweight",
        ]
        for proc in analysis.processes.get(parent_process).processes.query(".*0_0_0")
264
265
266
267
268
269
270
    ],
)
analysis.processes.extend([class_HHGluGlu_NLO_reweight])

analysis.aux["multiclass"] = MulticlassConfig(
    groups={
        "mergedinclusive": {
271
272
            "class_HHGluGlu_NLO_reweight": {"groups": ["signal", "fit", "norm"]},
            "class_HHVBF_NLO": {"groups": ["signal", "fit", "norm"]},
273
            "tt": {"groups": ["background"]},
274
275
276
277
278
279
            "st": {"groups": ["background"]},
            "wjets": {"groups": ["background"]},
            "H": {"groups": ["background"]},
            "class_other": {"groups": ["background"]},
        },
        "ggfttbar": {
280
281
            "ggHH_kl_1_kt_1_2B2WToLNu2J": {"groups": ["signal", "fit"]},
            "tt": {"groups": ["background"]},
282
283
284
        },
    },
    group="mergedinclusive",
285
    maxn=4e6,
286
287
)

Benjamin Fischer's avatar
Benjamin Fischer committed
288

Peter Fackeldey's avatar
Peter Fackeldey committed
289
from bbww_sl.config.categories import setup_categories
290

Peter Fackeldey's avatar
Peter Fackeldey committed
291
setup_categories(analysis)
292

Peter Fackeldey's avatar
Peter Fackeldey committed
293
from bbww_sl.config.variables import setup_variables
294

Peter Fackeldey's avatar
Peter Fackeldey committed
295
setup_variables(analysis)
296

Peter Fackeldey's avatar
Peter Fackeldey committed
297
298
299
#
# other configurations
#
300

Peter Fackeldey's avatar
Peter Fackeldey committed
301
analysis.aux["signal_process"] = "diHiggs"