Skip to content

Commit

Permalink
DL selection cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
mafrahm committed Aug 7, 2024
1 parent feeeb1d commit c778967
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 13 deletions.
2 changes: 1 addition & 1 deletion hbw/selection/dl_remastered.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def dl_lepton_selection(

dilepton = ak.pad_none(lepton, 2)
dilepton = dilepton[:, 0] + dilepton[:, 1]
events = set_ak_column(events, "mll", dilepton.mass)
events = set_ak_column(events, "mll", dilepton.mass, value_type=np.float32)
lepton_results.steps["DiLeptonMass81"] = ak.fill_none(dilepton.mass <= m_z.nominal - 10, False)
# lepton channel masks
lepton_results.steps["Lep_mm"] = mm_mask = (
Expand Down
16 changes: 6 additions & 10 deletions hbw/selection/jet.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ def jet_selection(
(events.Jet.jetId >= 2) # 1: loose, 2: tight, 4: isolated, 6: tight+isolated
)

electron = events.Electron[lepton_results.objects.Electron.FakeableElectron]
muon = events.Muon[lepton_results.objects.Muon.FakeableMuon]
electron = events.Electron[lepton_results.objects.Electron.LooseElectron]
muon = events.Muon[lepton_results.objects.Muon.LooseMuon]

jet_mask = (
(events.Jet.pt >= self.jet_pt) &
Expand Down Expand Up @@ -293,9 +293,9 @@ def sl_boosted_jet_selection(

# get separation info between FatJets and AK4 Jets
dr_fatjet_ak4 = events.FatJet.metric_table(ak4_jets)
events = set_ak_column(events, "FatJet.n_subjets", ak.sum(dr_fatjet_ak4 < 0.8, axis=2))
events = set_ak_column(events, "FatJet.n_separated_jets", ak.sum(dr_fatjet_ak4 > 1.2, axis=2))
events = set_ak_column(events, "FatJet.max_dr_ak4", ak.max(dr_fatjet_ak4, axis=2))
events = set_ak_column(events, "cutflow.FatJet.n_subjets", ak.sum(dr_fatjet_ak4 < 0.8, axis=2))
events = set_ak_column(events, "cutflow.FatJet.n_separated_jets", ak.sum(dr_fatjet_ak4 > 1.2, axis=2))
events = set_ak_column(events, "cutflow.FatJet.max_dr_ak4", ak.max(dr_fatjet_ak4, axis=2))

# baseline fatjet selection
fatjet_mask = (
Expand Down Expand Up @@ -400,11 +400,7 @@ def sl_boosted_jet_selection_init(self: Selector) -> None:

# add produced variables to *produces* only when requested
if self.config_inst.x("do_cutflow_features", False):
self.produces |= {"cutflow.n_fatjet", "cutflow.n_hbbjet"} | four_vec(
{"FatJet", "HbbJet"},
{"n_subjets", "n_separated_jets", "max_dr_ak4"},
skip_defaults=True,
)
self.produces |= {"cutflow.{n_fatjet,n_hbbjet}, cutflow.FatJet.{n_subjets,n_separated_jets,max_dr_ak4"}


# boosted selection for the DL channel (only one parameter needs to be changed)
Expand Down
2 changes: 1 addition & 1 deletion hbw/selection/lepton.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ def add_nlep_variables(config: od.Config) -> None:
"n_fakeable_muon",
"n_tight_electron",
"n_tight_muon",
"n_veto_tau"
"n_veto_tau",
):
config.add_variable(
name=f"cf.{var}",
Expand Down
8 changes: 7 additions & 1 deletion hbw/tasks/inspection.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,16 @@ class DumpAnalysisSummary(
description="Keys of interest to be printed in the summary",
)

@property
def keys_repr(self):
return "_".join(sorted(self.keys_of_interest))

def requires(self):
return {}

def output(self):
output = {
"dataset_summary": self.target("dataset_summary.txt"),
"dataset_summary": self.target(f"dataset_summary_{self.keys_repr}.txt"),
}
return output

Expand All @@ -52,6 +56,7 @@ def write_dataset_summary(self, outp):
"n_events": "Number of events",
"n_files": "Number of files",
"das_keys": "DAS keys",
"rucio": "Rucio DAS keys",
"process": "Process name",
"xsec": "Cross section [pb]",
"xsec_unc": "Cross section +- unc [pb]",
Expand All @@ -66,6 +71,7 @@ def write_dataset_summary(self, outp):
"n_events": dataset.n_events,
"n_files": dataset.n_files,
"das_keys": dataset.get_info("nominal").keys[0],
"rucio": "cms:" + dataset.get_info("nominal").keys[0],
"process": dataset.processes.get_first().name,
"xsec": round_sig(xsec.nominal, 4) if xsec else "0",
"xsec_unc": xsec.str("pdg", combine_uncs="all") if xsec else "0",
Expand Down

0 comments on commit c778967

Please sign in to comment.