Skip to content

Commit

Permalink
cutflow
Browse files Browse the repository at this point in the history
  • Loading branch information
kleinboe committed Nov 26, 2024
1 parent 15f2fa3 commit 219c47f
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 32 deletions.
6 changes: 6 additions & 0 deletions hbw/config/variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,12 @@ def add_feature_variables(config: od.Config) -> None:
binning=(40, 0, 5),
x_title=r"$\Delta R(j_{1},j_{2})$",
)
config.add_variable(
name="L1NNscore",
binning=(20, -1., 1),
x_title=r"L1NNscore",
unit="a.u.",
)

# FatJet features
for i in range(2):
Expand Down
65 changes: 34 additions & 31 deletions hbw/production/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,18 +71,20 @@ def bb_features(self: Producer, events: ak.Array, **kwargs) -> ak.Array:
@producer(
uses={
prepare_objects,
bb_features, jj_features,
"Electron.pt", "Electron.eta", "Muon.pt", "Muon.eta",
"Muon.charge", "Electron.charge",
"Jet.pt", "Jet.eta", "Jet.btagDeepFlavB", "Jet.btagPNetB",
"Bjet.pt",
"HbbJet.pt",
"FatJet.pt", "FatJet.tau1", "FatJet.tau2",
#bb_features, jj_features,
#"Electron.pt", "Electron.eta", "Muon.pt", "Muon.eta",
#"Muon.charge", "Electron.charge",
#"Jet.pt", "Jet.eta", "Jet.btagDeepFlavB", "Jet.btagPNetB",
#"Bjet.pt",
#"HbbJet.pt",
# "FatJet.pt", "FatJet.tau1", "FatJet.tau2",
"L1NNscore",
},
produces={
bb_features, jj_features,
"ht", "n_jet", "n_electron", "n_muon", "n_deepjet", "n_fatjet", "n_hbbjet",
"FatJet.tau21", "n_bjet",
#bb_features, jj_features,
#"ht", "n_jet", "n_electron", "n_muon", "n_deepjet", "n_fatjet", "n_hbbjet",
#"FatJet.tau21", "n_bjet",
"L1NNscore",
},
)
def features(self: Producer, events: ak.Array, **kwargs) -> ak.Array:
Expand All @@ -91,34 +93,35 @@ def features(self: Producer, events: ak.Array, **kwargs) -> ak.Array:
events = self[prepare_objects](events, **kwargs)

# object padding
events = set_ak_column(events, "Jet", ak.pad_none(events.Jet, 2))
events = set_ak_column(events, "Bjet", ak.pad_none(events.Bjet, 2))
events = set_ak_column(events, "FatJet", ak.pad_none(events.FatJet, 1))
events = set_ak_column(events, "HbbJet", ak.pad_none(events.HbbJet, 1))
#events = set_ak_column(events, "Jet", ak.pad_none(events.Jet, 2))
#events = set_ak_column(events, "Bjet", ak.pad_none(events.Bjet, 2))
#events = set_ak_column(events, "FatJet", ak.pad_none(events.FatJet, 1))
#events = set_ak_column(events, "HbbJet", ak.pad_none(events.HbbJet, 1))

# ht and number of objects (safe for None entries)
events = set_ak_column_f32(events, "ht", ak.sum(events.Jet.pt, axis=1))
events = set_ak_column(events, "n_jet", ak.sum(events.Jet.pt > 0, axis=1))
events = set_ak_column(events, "n_bjet", ak.sum(events.Bjet.pt > 0, axis=1))
events = set_ak_column(events, "n_electron", ak.sum(events.Electron.pt > 0, axis=1))
events = set_ak_column(events, "n_muon", ak.sum(events.Muon.pt > 0, axis=1))
wp_med_deepjet = self.config_inst.x.btag_working_points.deepjet.medium
events = set_ak_column(events, "n_deepjet", ak.sum(events.Jet.btagDeepFlavB > wp_med_deepjet, axis=1))
wp_med_particlenet = self.config_inst.x.btag_working_points.particlenet.medium
events = set_ak_column(events, "n_particlenet", ak.sum(events.Jet.btagPNetB > wp_med_particlenet, axis=1))
events = set_ak_column(events, "n_fatjet", ak.sum(events.FatJet.pt > 0, axis=1))
events = set_ak_column(events, "n_hbbjet", ak.sum(events.HbbJet.pt > 0, axis=1))
#events = set_ak_column_f32(events, "ht", ak.sum(events.Jet.pt, axis=1))
#events = set_ak_column(events, "n_jet", ak.sum(events.Jet.pt > 0, axis=1))
#events = set_ak_column(events, "n_bjet", ak.sum(events.Bjet.pt > 0, axis=1))
#events = set_ak_column(events, "n_electron", ak.sum(events.Electron.pt > 0, axis=1))
#events = set_ak_column(events, "n_muon", ak.sum(events.Muon.pt > 0, axis=1))
#wp_med_deepjet = self.config_inst.x.btag_working_points.deepjet.medium
#events = set_ak_column(events, "n_deepjet", ak.sum(events.Jet.btagDeepFlavB > wp_med_deepjet, axis=1))
#wp_med_particlenet = self.config_inst.x.btag_working_points.particlenet.medium
#events = set_ak_column(events, "n_particlenet", ak.sum(events.Jet.btagPNetB > wp_med_particlenet, axis=1))
#events = set_ak_column(events, "n_fatjet", ak.sum(events.FatJet.pt > 0, axis=1))
#events = set_ak_column(events, "n_hbbjet", ak.sum(events.HbbJet.pt > 0, axis=1))

# Subjettiness
events = set_ak_column_f32(events, "FatJet.tau21", events.FatJet.tau2 / events.FatJet.tau1)
#events = set_ak_column_f32(events, "FatJet.tau21", events.FatJet.tau2 / events.FatJet.tau1)

# bb and jj features
events = self[bb_features](events, **kwargs)
events = self[jj_features](events, **kwargs)

#events = self[bb_features](events, **kwargs)
#events = self[jj_features](events, **kwargs)
# TOPO
events = set_ak_column(events, "L1NNscore", events.L1NNscore)
# undo object padding (remove None entries)
for obj in ["Jet", "Bjet", "FatJet"]:
events = set_ak_column(events, obj, events[obj][~ak.is_none(events[obj], axis=1)])
#for obj in ["Jet", "Bjet", "FatJet"]:
# events = set_ak_column(events, obj, events[obj][~ak.is_none(events[obj], axis=1)])

return events

Expand Down
1 change: 0 additions & 1 deletion hbw/selection/nn_trigger.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ def NN_trigger_inference(

# returning the inference results
events = set_ak_column(events, "L1NNscore", predictions)
__import__("IPython").embed()
return events


Expand Down

0 comments on commit 219c47f

Please sign in to comment.