Skip to content

Commit 095c26a

Browse files
committed
remove category ids and event weights from reconstruction producers
1 parent 4af51df commit 095c26a

File tree

2 files changed

+5
-58
lines changed

2 files changed

+5
-58
lines changed

hbw/production/features.py

+1-16
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,7 @@
1010
from columnflow.util import maybe_import
1111
from columnflow.columnar_util import set_ak_column, EMPTY_FLOAT
1212

13-
from columnflow.production.categories import category_ids
14-
from hbw.production.weights import event_weights
1513
from hbw.production.prepare_objects import prepare_objects
16-
from hbw.config.categories import add_categories_production
1714
from hbw.config.variables import add_feature_variables
1815
from hbw.config.dl.variables import add_dl_variables
1916
from hbw.util import four_vec
@@ -74,8 +71,7 @@ def bb_features(self: Producer, events: ak.Array, **kwargs) -> ak.Array:
7471

7572
@producer(
7673
uses={
77-
prepare_objects, category_ids,
78-
event_weights,
74+
prepare_objects,
7975
bb_features, jj_features,
8076
"Electron.pt", "Electron.eta", "Muon.pt", "Muon.eta",
8177
"Muon.charge", "Electron.charge",
@@ -85,23 +81,15 @@ def bb_features(self: Producer, events: ak.Array, **kwargs) -> ak.Array:
8581
},
8682
produces={
8783
bb_features, jj_features,
88-
category_ids, event_weights,
8984
"ht", "n_jet", "n_electron", "n_muon", "n_deepjet", "n_fatjet", "n_hbbjet",
9085
"FatJet.tau21", "n_bjet",
9186
},
9287
)
9388
def features(self: Producer, events: ak.Array, **kwargs) -> ak.Array:
9489

95-
# add event weights
96-
if self.dataset_inst.is_mc:
97-
events = self[event_weights](events, **kwargs)
98-
9990
# add behavior and define new collections (e.g. Lepton)
10091
events = self[prepare_objects](events, **kwargs)
10192

102-
# produce (new) category ids
103-
events = self[category_ids](events, **kwargs)
104-
10593
# object padding
10694
events = set_ak_column(events, "Jet", ak.pad_none(events.Jet, 2))
10795
events = set_ak_column(events, "Bjet", ak.pad_none(events.Bjet, 2))
@@ -135,9 +123,6 @@ def features(self: Producer, events: ak.Array, **kwargs) -> ak.Array:
135123

136124
@features.init
137125
def features_init(self: Producer) -> None:
138-
# add categories to config
139-
add_categories_production(self.config_inst)
140-
141126
# add variable instances to config
142127
add_feature_variables(self.config_inst)
143128

hbw/production/ml_inputs.py

+4-42
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,11 @@
1111
from columnflow.production import Producer, producer
1212
from columnflow.util import maybe_import
1313
from columnflow.columnar_util import set_ak_column
14-
from columnflow.production.categories import category_ids
1514

16-
from hbw.production.weights import event_weights
1715
from hbw.production.prepare_objects import prepare_objects
1816
from hbw.config.ml_variables import add_ml_variables
1917
from hbw.config.dl.variables import add_dl_ml_variables
2018
from hbw.config.sl_res.variables import add_sl_res_ml_variables
21-
from hbw.config.categories import add_categories_production
2219
from hbw.util import four_vec
2320
ak = maybe_import("awkward")
2421
np = maybe_import("numpy")
@@ -31,25 +28,18 @@
3128

3229
@producer(
3330
uses={
34-
category_ids,
3531
prepare_objects,
3632
"HbbJet.msoftdrop",
3733
"Jet.btagDeepFlavB", "Bjet.btagDeepFlavB", "Lightjet.btagDeepFlavB",
3834
} | four_vec(
3935
{"Electron", "Muon", "MET", "Jet", "Bjet", "Lightjet", "HbbJet", "VBFJet"},
4036
),
41-
produces={
42-
category_ids,
43-
# other produced columns set in the init function
44-
},
37+
# produced columns set in the init function
4538
)
4639
def sl_ml_inputs(self: Producer, events: ak.Array, **kwargs) -> ak.Array:
4740
# add behavior and define new collections (e.g. Lepton)
4841
events = self[prepare_objects](events, **kwargs)
4942

50-
# produce (new) category ids
51-
events = self[category_ids](events, **kwargs)
52-
5343
# object padding
5444
events = set_ak_column(events, "Lightjet", ak.pad_none(events.Lightjet, 2))
5545
events = set_ak_column(events, "Bjet", ak.pad_none(events.Bjet, 2))
@@ -202,39 +192,25 @@ def sl_ml_inputs_init(self: Producer) -> None:
202192
)
203193
self.produces |= self.ml_input_columns
204194

205-
# add categories to config
206-
add_categories_production(self.config_inst)
207-
208195
# add variable instances to config
209196
add_ml_variables(self.config_inst)
210197

211198

212199
@producer(
213200
uses={
214-
category_ids, event_weights,
215201
prepare_objects,
216202
"Electron.charge", "Muon.charge",
217203
"HbbJet.msoftdrop",
218204
"Jet.btagDeepFlavB", "Bjet.btagDeepFlavB",
219205
} | four_vec(
220206
{"Electron", "Muon", "MET", "Jet", "Bjet", "HbbJet"},
221207
),
222-
produces={
223-
category_ids, event_weights,
224-
# other produced columns set in the init function
225-
},
208+
# produced columns set in the init function
226209
)
227210
def dl_ml_inputs(self: Producer, events: ak.Array, **kwargs) -> ak.Array:
228-
# add event weights
229-
if self.dataset_inst.is_mc:
230-
events = self[event_weights](events, **kwargs)
231-
232211
# add behavior and define new collections (e.g. Lepton)
233212
events = self[prepare_objects](events, **kwargs)
234213

235-
# produce (new) category ids
236-
events = self[category_ids](events, **kwargs)
237-
238214
# object padding
239215
events = set_ak_column(events, "Bjet", ak.pad_none(events.Bjet, 2))
240216
# events = set_ak_column(events, "FatJet", ak.pad_none(events.FatJet, 1))
@@ -319,38 +295,25 @@ def dl_ml_inputs_init(self: Producer) -> None:
319295
)
320296
self.produces |= self.ml_columns
321297

322-
# add categories to config
323-
add_categories_production(self.config_inst)
324-
325298
# add variable instances to config
326299
add_dl_ml_variables(self.config_inst)
327300

328301

329302
@producer(
330303
uses={
331-
category_ids, event_weights,
332304
prepare_objects,
333305
"HbbJet.msoftdrop",
334306
"Jet.btagDeepFlavB", "Bjet.btagDeepFlavB", "Lightjet.btagDeepFlavB",
335307
} | four_vec(
336308
{"Electron", "Muon", "MET", "Jet", "Bjet", "Lightjet", "HbbJet", "VBFJet"},
337309
),
338-
produces={
339-
category_ids, event_weights,
340-
# other produced columns set in the init function
341-
},
310+
# produced columns set in the init function
342311
)
343312
def sl_res_ml_inputs(self: Producer, events: ak.Array, **kwargs) -> ak.Array:
344-
# add event weights
345-
if self.dataset_inst.is_mc:
346-
events = self[event_weights](events, **kwargs)
347313

348314
# add behavior and define new collections (e.g. Lepton)
349315
events = self[prepare_objects](events, **kwargs)
350316

351-
# produce (new) category ids
352-
events = self[category_ids](events, **kwargs)
353-
354317
# object padding
355318
events = set_ak_column(events, "Lightjet", ak.pad_none(events.Lightjet, 2))
356319
events = set_ak_column(events, "Bjet", ak.pad_none(events.Bjet, 2))
@@ -501,7 +464,6 @@ def sl_res_ml_inputs_init(self: Producer) -> None:
501464
for var in ["pt", "eta", "phi", "mass", "msoftdrop"]
502465
)
503466
self.produces |= self.ml_columns
504-
# add categories to config
505-
add_categories_production(self.config_inst)
467+
506468
# add variable instances to config
507469
add_sl_res_ml_variables(self.config_inst)

0 commit comments

Comments
 (0)