-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconfig_gen.py
160 lines (138 loc) · 3.88 KB
/
config_gen.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
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 .quantities import nanoAOD as nanoAOD
from .quantities import output as q
from code_generation.configuration import Configuration
from code_generation.modifiers import EraModifier, SampleModifier
from code_generation.rules import AppendProducer, RemoveProducer, ReplaceProducer
from code_generation.systematics import SystematicShift, SystematicShiftByQuantity
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(
# "mm",
# {
# },
# )
configuration.add_producers(
"global",
[
event.SampleFlags,
event.Lumi,
event.EventGenWeight,
event.LHEPdfWeight,
event.LHEScaleWeight,
genparticles.DYFilters,
genparticles.WFilters,
],
)
configuration.add_producers(
"mm",
[
genparticles.GenLeptonProducers,
],
)
configuration.add_outputs(
scopes,
[
getattr(q, f"LHEPdfWeight{i}") for i in range(103)
] + [
getattr(q, f"LHEScaleWeight{i}") for i in range(8)
]
)
configuration.add_outputs(
"mm",
[
q.is_data,
q.is_ttbar,
q.is_singletop,
q.is_ewk_tau,
q.is_dyjets,
q.is_wjets,
q.is_diboson,
q.is_dy_ee,
q.is_dy_mm,
q.is_dy_tt,
q.is_w_e,
q.is_w_m,
q.is_w_t,
nanoAOD.run,
q.lumi,
nanoAOD.event,
q.genweight,
q.genlep_pt_1,
q.genlep_eta_1,
q.genlep_phi_1,
q.genlep_mass_1,
q.genlep_pdgId_1,
q.genlep_p4_1,
q.genlep_pt_2,
q.genlep_eta_2,
q.genlep_phi_2,
q.genlep_mass_2,
q.genlep_pdgId_2,
q.genlep_p4_2,
q.genlepPreFSR_pt_1,
q.genlepPreFSR_eta_1,
q.genlepPreFSR_phi_1,
q.genlepPreFSR_mass_1,
q.genlepPreFSR_pdgId_1,
q.genlepPreFSR_p4_1,
q.genlepPreFSR_pt_2,
q.genlepPreFSR_eta_2,
q.genlepPreFSR_phi_2,
q.genlepPreFSR_mass_2,
q.genlepPreFSR_pdgId_2,
q.genlepPreFSR_p4_2,
q.genDressed_idx_1,
q.genDressed_idx_2,
q.genDressed_pt_1,
q.genDressed_eta_1,
q.genDressed_phi_1,
q.genDressed_mass_1,
q.genDressed_pdgId_1,
q.genDressed_p4_1,
q.genDressed_dR_1,
q.genDressed_pt_2,
q.genDressed_eta_2,
q.genDressed_phi_2,
q.genDressed_mass_2,
q.genDressed_pdgId_2,
q.genDressed_p4_2,
q.genDressed_dR_2,
q.genlep_dilepton_mass,
q.genlepPreFSR_dilepton_mass,
q.genDressed_dilepton_mass,
],
)
configuration.add_modification_rule(
"global",
RemoveProducer(
producers=[event.EventGenWeight],
samples=["data"],
),
)
#########################
# Finalize and validate the configuration
#########################
configuration.optimize()
configuration.validate()
configuration.report()
return configuration.expanded_configuration()