-
Notifications
You must be signed in to change notification settings - Fork 0
/
systematicsPass.py
299 lines (276 loc) · 9.24 KB
/
systematicsPass.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
bkgs = ["TTbar", "WJetsLNu", "SingleTop", "DYJets", "WZQQ", "Diboson", "EWKvjets"]
sigs = ["ggF", "VBF", "WH", "ZH", "ttH"]
samples = sigs + bkgs + ["Fake"]
#samples = sigs + bkgs
def get_systematic_dict(years):
"""
The following dictionaries have the following convention,
key [str] --> name of systematic to store in the histogram / template
value [tuple] --> (t1, t2, t3):
t1 [list]: years to process the up/down variations for (store nominal value for the other years)
t2 [list]: samples to apply systematic for (store nominal value for the other samples)
t3 [dict]:
key(s): the channels to apply the systematic for (store nominal value for the other channels)
value(s): the name of the variable in the parquet for that channel
"""
radiation = {
"pass_weight_PSFSR": ( years, sigs + ["TTbar", "WJetsLNu", "SingleTop"],
{"ele": "weight_ele_PSFSR", "mu": "weight_mu_PSFSR"},
),
"pass_weight_PSISR": ( years, sigs + ["TTbar", "WJetsLNu", "SingleTop"],
{"ele": "weight_ele_PSISR", "mu": "weight_mu_PSISR"},
),
}
COMMON_systs_correlated = {
"pass_weight_pileup_id": (
years,
sigs + bkgs,
{"ele": "weight_ele_pileupIDSF", "mu": "weight_mu_pileupIDSF"},
),
# systematics applied only on WJets & DYJets
"pass_weight_d1K_NLO": (
years,
["WJetsLNu"],
{"ele": "weight_ele_d1K_NLO", "mu": "weight_mu_d1K_NLO"},
),
"pass_weight_d2K_NLO": (
years,
["WJetsLNu"],
{"ele": "weight_ele_d2K_NLO", "mu": "weight_mu_d2K_NLO"},
),
"pass_weight_d3K_NLO": (
years,
["WJetsLNu"],
{"ele": "weight_ele_d3K_NLO", "mu": "weight_mu_d3K_NLO"},
),
"pass_weight_d1kappa_EW": (
years,
["WJetsLNu", "DYJets"],
{"ele": "weight_ele_d1kappa_EW", "mu": "weight_mu_d1kappa_EW"},
),
"pass_weight_W_d2kappa_EW": (
years,
["WJetsLNu"],
{"ele": "weight_ele_W_d2kappa_EW", "mu": "weight_mu_W_d2kappa_EW"},
),
"pass_weight_W_d3kappa_EW": (
years,
["WJetsLNu"],
{"ele": "weight_ele_W_d3kappa_EW", "mu": "weight_mu_W_d3kappa_EW"},
),
"pass_weight_Z_d2kappa_EW": (
years,
["DYJets"],
{"ele": "weight_ele_Z_d2kappa_EW", "mu": "weight_mu_Z_d2kappa_EW"},
),
"pass_weight_Z_d3kappa_EW": (
years,
["DYJets"],
{"ele": "weight_ele_Z_d3kappa_EW", "mu": "weight_mu_Z_d3kappa_EW"},
),
# systematics for electron channel
"pass_weight_ele_id": (
years,
sigs + bkgs,
{"ele": "weight_ele_id_electron"},
),
"pass_weight_ele_reco": (
years,
sigs + bkgs,
{"ele": "weight_ele_reco_electron"},
),
# systematics for muon channel
"pass_weight_mu_isolation": (
years,
sigs + bkgs,
{"mu": "weight_mu_isolation_muon"},
),
"pass_weight_mu_id": (
years,
sigs + bkgs,
{"mu": "weight_mu_id_muon"},
),
"pass_weight_mu_trigger_iso": (
years,
sigs + bkgs,
{"mu": "weight_mu_trigger_iso_muon"},
),
"pass_weight_mu_trigger_noniso": (
years,
sigs + bkgs,
{"mu": "weight_mu_trigger_noniso_muon"},
),
}
COMMON_systs_uncorrelated = {}
for year in years:
COMMON_systs_uncorrelated = {
**COMMON_systs_uncorrelated,
**{
f"pass_weight_pileup": (
[year],
sigs + bkgs,
{"ele": "weight_ele_pileup", "mu": "weight_mu_pileup"},
),
},
}
if year != "2018":
COMMON_systs_uncorrelated = {
**COMMON_systs_uncorrelated,
**{
f"pass_weight_L1Prefiring": (
[year],
sigs + bkgs,
{"ele": "weight_ele_L1Prefiring", "mu": "weight_mu_L1Prefiring"},
),
},
}
# btag syst. have a different treatment because they are not stored in the nominal
BTAG_systs_correlated = {
"pass_weight_btagSFlightCorrelated": (
years,
sigs + bkgs,
{"ele": "weight_btagSFlightCorrelated", "mu": "weight_btagSFlightCorrelated"},
),
"pass_weight_btagSFbcCorrelated": (
years,
sigs + bkgs,
{"ele": "weight_btagSFbcCorrelated", "mu": "weight_btagSFbcCorrelated"},
),
}
BTAG_systs_uncorrelated = {}
for year in years:
if "APV" in year: # all APV parquets don't have APV explicitly in the systematics
yearlabel = "2016"
else:
yearlabel = year
BTAG_systs_uncorrelated = {
**BTAG_systs_uncorrelated,
**{
f"pass_weight_btagSFlight": (
year,
sigs + bkgs,
{"ele": f"weight_btagSFlight{yearlabel}", "mu": f"weight_btagSFlight{yearlabel}"},
),
f"pass_weight_btagSFbc": (
year,
sigs + bkgs,
{"ele": f"weight_btagSFbc{yearlabel}", "mu": f"weight_btagSFbc{yearlabel}"},
),
},
}
# JEC / UES
JEC_systs_correlated = {
"pass_JES_FlavorQCD": (
years,
sigs + bkgs,
{"ele": "JES_FlavorQCD", "mu": "JES_FlavorQCD"},
),
"pass_JES_RelativeBal": (
years,
sigs + bkgs,
{"ele": "JES_RelativeBal", "mu": "JES_RelativeBal"},
),
"pass_JES_HF": (
years,
sigs + bkgs,
{"ele": "JES_HF", "mu": "JES_HF"},
),
"pass_JES_BBEC1": (
years,
sigs + bkgs,
{"ele": "JES_BBEC1", "mu": "JES_BBEC1"},
),
"pass_JES_EC2": (
years,
sigs + bkgs,
{"ele": "JES_EC2", "mu": "JES_EC2"},
),
"pass_JES_Absolute": (
years,
sigs + bkgs,
{"ele": "JES_Absolute", "mu": "JES_Absolute"},
),
}
JEC_systs_uncorrelated = {}
for year in years:
if "APV" in year: # all APV parquets don't have APV explicitly in the systematics
yearlabel = "2016"
else:
yearlabel = year
JEC_systs_uncorrelated = {
**JEC_systs_uncorrelated,
**{
"pass_JES_BBEC1_year": (
year,
sigs + bkgs,
{"ele": f"JES_BBEC1_{yearlabel}", "mu": f"JES_BBEC1_{yearlabel}"},
),
"pass_JES_RelativeSample_year": (
year,
sigs + bkgs,
{"ele": f"JES_RelativeSample_{yearlabel}", "mu": f"JES_RelativeSample_{yearlabel}"},
),
"pass_JES_EC2_year": (
year,
sigs + bkgs,
{"ele": f"JES_EC2_{yearlabel}", "mu": f"JES_EC2_{yearlabel}"},
),
"pass_JES_HF_year": (
year,
sigs + bkgs,
{"ele": f"JES_HF_{yearlabel}", "mu": f"JES_HF_{yearlabel}"},
),
"pass_JES_Absolute_year": (
year,
sigs + bkgs,
{"ele": f"JES_Absolute_{yearlabel}", "mu": f"JES_Absolute_{yearlabel}"},
),
"pass_JER_year": (
year,
sigs + bkgs,
{"ele": "JER", "mu": "JER"},
),
},
}
UES_systs = {}
for year in years:
if "APV" in year: # all APV parquets don't have APV explicitly in the systematics
yearlabel = "2016"
else:
yearlabel = year
UES_systs = {
**UES_systs,
**{
"pass_UES": (
years,
sigs + bkgs,
{"ele": "UES", "mu": "UES"},
),
},
}
TRIGGER_systs = {}
for year in years:
if "APV" in year: # all APV parquets don't have APV explicitly in the systematics
yearlabel = "2016"
else:
yearlabel = year
TRIGGER_systs = {
**TRIGGER_systs,
**{
"pass_weight_trigger": (
years,
sigs + bkgs,
{"ele": "weight_ele_trigger", },
),
},
}
SYST_DICT = {
"psrad": {**radiation},
"common": {**COMMON_systs_correlated, **COMMON_systs_uncorrelated},
"btag1": {**BTAG_systs_correlated},
"btag2": {**BTAG_systs_uncorrelated},
"JEC": {**JEC_systs_correlated, **JEC_systs_uncorrelated},
"UES_systs": {**UES_systs, },
"TRIGGER_systs": {**TRIGGER_systs, },
}
return SYST_DICT