-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathembedding_selection.py
284 lines (273 loc) · 8.56 KB
/
embedding_selection.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
from __future__ import annotations # needed for type annotations in > python 3.7
from typing import List
from .producers import event as event
from .producers import genparticles as genparticles
from .producers import muons as muons
from .producers import pairquantities as pairquantities
from .producers import pairselection as pairselection
from .producers import triggers as triggers
from .producers import scalefactors as scalefactors
from .producers import tagandprobe as tagandprobe
from .quantities import nanoAOD as nanoAOD
from .quantities import output as q
from .quantities import tagandprobe_output as qt
from code_generation.configuration import Configuration
from code_generation.modifiers import EraModifier
from code_generation.rules import RemoveProducer, AppendProducer
from code_generation.systematics import SystematicShift
def build_config(
era: str,
sample: str,
scopes: List[str],
shifts: List[str],
available_sample_types: List[str],
available_eras: List[str],
available_scopes: List[str],
):
configuration = Configuration(
era,
sample,
scopes,
shifts,
available_sample_types,
available_eras,
available_scopes,
)
configuration.add_config_parameters(
"global",
{
"PU_reweighting_file": EraModifier(
{
"2016": "",
"2017": "data/jsonpog-integration/POG/LUM/2017_UL/puWeights.json.gz",
"2018": "data/jsonpog-integration/POG/LUM/2018_UL/puWeights.json.gz",
}
),
"PU_reweighting_era": EraModifier(
{
"2016": "",
"2017": "Collisions17_UltraLegacy_goldenJSON",
"2018": "Collisions18_UltraLegacy_goldenJSON",
}
),
"PU_reweighting_variation": "nominal",
"golden_json_file": EraModifier(
{
"2016": "data/golden_json/Cert_271036-284044_13TeV_Legacy2016_Collisions16_JSON.txt",
"2017": "data/golden_json/Cert_294927-306462_13TeV_UL2017_Collisions17_GoldenJSON.txt",
"2018": "data/golden_json/Cert_314472-325175_13TeV_Legacy2018_Collisions18_JSON.txt",
}
),
},
)
# muon base selection:
configuration.add_config_parameters(
"global",
{
"min_muon_pt": 10.0,
"max_muon_eta": 2.4,
"max_muon_dxy": 1.00,
"max_muon_dz": 1.00,
"muon_id": "Muon_looseId",
"muon_iso_cut": 1.00,
},
)
# MuMu scope Muon selection
configuration.add_config_parameters(
["mm"],
{
"muon_index_in_pair": 0,
"second_muon_index_in_pair": 1,
"min_muon_pt": 10.0,
"max_muon_eta": 2.4,
"muon_iso_cut": 1.00,
},
)
# Muon scale factors configuration
configuration.add_config_parameters(
["mm"],
{
"muon_sf_file": EraModifier(
{
"2016": "data/jsonpog-integration/POG/MUO/2016postVFP_UL/muon_Z.json.gz",
"2017": "data/jsonpog-integration/POG/MUO/2017_UL/muon_Z.json.gz",
"2018": "data/jsonpog-integration/POG/MUO/2018_UL/muon_Z.json.gz",
}
),
"muon_id_sf_name": "NUM_MediumID_DEN_TrackerMuons",
"muon_iso_sf_name": "NUM_TightRelIso_DEN_MediumID",
"muon_sf_year_id": EraModifier(
{
"2016": "2016postVFP_UL",
"2017": "2017_UL",
"2018": "2018_UL",
}
),
"muon_sf_varation": "sf", # "sf" is nominal, "systup"/"systdown" are up/down variations
},
)
configuration.add_config_parameters(
["mm"],
{
"doublemuon_trigger": EraModifier(
{
"2018": [
{
"flagname": "trg_double_mu17_mu8",
"hlt_path": "HLT_Mu17_TrkIsoVVL_Mu8_TrkIsoVVL_DZ",
"p1_ptcut": 17,
"p2_ptcut": 8,
"p1_etacut": 2.5,
"p2_etacut": 2.5,
"p1_filterbit": 4,
"p1_trigger_particle_id": 13,
"p2_filterbit": 4,
"p2_trigger_particle_id": 13,
"max_deltaR_triggermatch": 0.4,
},
{
"flagname": "trg_double_mu17_mu8_mass8",
"hlt_path": "HLT_Mu17_TrkIsoVVL_Mu8_TrkIsoVVL_DZ_Mass8",
"p1_ptcut": 17,
"p2_ptcut": 8,
"p1_etacut": 2.5,
"p2_etacut": 2.5,
"p1_filterbit": 4,
"p1_trigger_particle_id": 13,
"p2_filterbit": 4,
"p2_trigger_particle_id": 13,
"max_deltaR_triggermatch": 0.4,
},
],
}
),
},
)
## all scopes misc settings
configuration.add_config_parameters(
scopes,
{
"deltaR_jet_veto": 0.5,
"pairselection_min_dR": 0.001,
},
)
configuration.add_producers(
"global",
[
event.SampleFlags,
event.PUweights,
event.Lumi,
muons.BaseMuons,
],
)
configuration.add_producers(
"mm",
[
muons.GoodMuons,
muons.NumberOfGoodMuons,
pairselection.MuMuPairSelection,
pairselection.GoodMuMuPairFilter,
pairselection.LVMu1,
pairselection.LVMu2,
pairquantities.MuMuPairQuantities,
genparticles.MuMuGenPairQuantities,
triggers.MuMuGenerateDoubleMuonTriggerFlags,
tagandprobe.MuonID_Medium_1,
tagandprobe.MuonID_Medium_2,
genparticles.GenMatching,
],
)
configuration.add_outputs(
"mm",
[
q.is_data,
q.is_embedding,
q.is_ttbar,
q.is_dyjets,
q.is_wjets,
q.is_diboson,
nanoAOD.run,
q.lumi,
nanoAOD.event,
q.puweight,
q.pt_1,
q.pt_2,
q.eta_1,
q.eta_2,
q.phi_1,
q.phi_2,
q.q_1,
q.q_2,
q.dxy_1,
q.dxy_2,
q.dz_1,
q.dz_2,
q.iso_1,
q.iso_2,
q.m_vis,
q.gen_pt_1,
q.gen_eta_1,
q.gen_phi_1,
q.gen_mass_1,
q.gen_pdgid_1,
q.gen_pt_2,
q.gen_eta_2,
q.gen_phi_2,
q.gen_mass_2,
q.gen_pdgid_2,
q.gen_m_vis,
q.is_global_1,
q.is_global_2,
q.gen_match_1,
q.gen_match_2,
qt.id_medium_1,
qt.id_medium_2,
triggers.MuMuGenerateDoubleMuonTriggerFlags.output_group,
],
)
configuration.add_modification_rule(
"global",
RemoveProducer(
producers=[event.PUweights],
samples=["data", "embedding"],
),
)
configuration.add_modification_rule(
"global",
AppendProducer(
producers=[event.JSONFilter],
samples=["data,embedding"],
),
)
configuration.add_modification_rule(
"global",
AppendProducer(
producers=[event.npartons],
samples=["dyjets", "wjets"],
),
)
configuration.add_modification_rule(
"mm",
RemoveProducer(
producers=[
genparticles.MuMuGenPairQuantities,
],
samples=["data", "embedding"],
),
)
configuration.add_modification_rule(
"mm",
RemoveProducer(
producers=[
genparticles.GenMatching,
],
samples=["data"],
),
)
#########################
# Finalize and validate the configuration
#########################
configuration.optimize()
configuration.validate()
configuration.report()
return configuration.expanded_configuration()