From 237ee60c7d6af0951b05a693932194460d6cd14c Mon Sep 17 00:00:00 2001 From: rkansal47 Date: Thu, 9 Nov 2023 11:39:37 -0600 Subject: [PATCH] ruff fixes --- pyproject.toml | 1 + src/HH4b/processors/GenSelection.py | 15 +++++---------- src/HH4b/processors/bbbbSkimmer.py | 4 +--- src/HH4b/processors/matchingSkimmer.py | 4 +--- 4 files changed, 8 insertions(+), 16 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 03779e57..0f207628 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -144,6 +144,7 @@ ignore = [ "F811", # redefinition of unused variable "PGH001", # eval "RET503", + "RET504", # unnecessary assignment before return "RET505", # unnecessary else after return statement ] isort.required-imports = ["from __future__ import annotations"] diff --git a/src/HH4b/processors/GenSelection.py b/src/HH4b/processors/GenSelection.py index c9f507fc..69e22183 100644 --- a/src/HH4b/processors/GenSelection.py +++ b/src/HH4b/processors/GenSelection.py @@ -7,7 +7,6 @@ import awkward as ak import numpy as np -from coffea.analysis_tools import PackedSelection from coffea.nanoevents.methods.base import NanoEventsArray from coffea.nanoevents.methods.nanoaod import FatJetArray, JetArray @@ -42,9 +41,7 @@ def gen_selection_HHbbbb( events: NanoEventsArray, jets: JetArray, fatjets: FatJetArray, - selection: PackedSelection, - cutflow: dict, - signGenWeights: ak.Array, + selection_args: list, skim_vars: dict, ): """Gets HH, bb 4-vectors""" @@ -64,7 +61,7 @@ def gen_selection_HHbbbb( has_4b = ak.sum(ak.flatten(is_bb, axis=2), axis=1) == 4 # only select events with 4 b's - add_selection("has_bbbb", has_4b, selection, cutflow, False, signGenWeights) + add_selection("has_bbbb", has_4b, *selection_args) # children 4-vector bs = ak.flatten(higgs_children[is_bb], axis=2) @@ -144,9 +141,7 @@ def gen_selection_Hbb( events: NanoEventsArray, jets: JetArray, # noqa: ARG001 fatjets: FatJetArray, - selection: PackedSelection, - cutflow: dict, - signGenWeights: ak.Array, + selection_args: list, # noqa: ARG001 skim_vars: dict, ): """Gets H, bb, 4-vectors + Higgs children information""" @@ -165,10 +160,10 @@ def gen_selection_Hbb( GenbVars = {f"Genb{key}": pad_val(bs[var], 4, axis=1) for (var, key) in skim_vars.items()} # match fatjets to bb - bs_unflat = higgs_children[is_bb] + # bs_unflat = higgs_children[is_bb] + # num_b_matched = ak.sum(fatjets.metric_table(bs_unflat) < 0.8, axis=2) b_h1 = higgs_children[is_bb][:, 0] b_h2 = higgs_children[is_bb][:, 1] - num_b_matched = ak.sum(fatjets.metric_table(bs_unflat) < 0.8, axis=2) matched_to_higgs = fatjets.metric_table(higgs) < 0.8 is_fatjet_matched = ak.any(matched_to_higgs, axis=2) diff --git a/src/HH4b/processors/bbbbSkimmer.py b/src/HH4b/processors/bbbbSkimmer.py index a77b2335..1dcd5be1 100644 --- a/src/HH4b/processors/bbbbSkimmer.py +++ b/src/HH4b/processors/bbbbSkimmer.py @@ -229,9 +229,7 @@ def process(self, events: ak.Array): genVars = {} for d in gen_selection_dict: if d in dataset: - vars_dict = gen_selection_dict[d]( - events, jets, fatjets, selection, cutflow, gen_weights, P4 - ) + vars_dict = gen_selection_dict[d](events, jets, fatjets, selection_args, P4) genVars = {**genVars, **vars_dict} # Jet variables diff --git a/src/HH4b/processors/matchingSkimmer.py b/src/HH4b/processors/matchingSkimmer.py index ca32cd32..790c211f 100644 --- a/src/HH4b/processors/matchingSkimmer.py +++ b/src/HH4b/processors/matchingSkimmer.py @@ -229,9 +229,7 @@ def process(self, events: ak.Array): # gen variables for d in gen_selection_dict: if d in dataset: - vars_dict = gen_selection_dict[d]( - events, jets, fatjets, selection, cutflow, gen_weights, P4 - ) + vars_dict = gen_selection_dict[d](events, jets, fatjets, selection_args, P4) skimmed_events = {**skimmed_events, **vars_dict} ak4GenJetVars = {}