Skip to content

Commit

Permalink
fix mypy errors; update comments
Browse files Browse the repository at this point in the history
  • Loading branch information
danielhundhausen committed Oct 22, 2024
1 parent 1347fc8 commit dbfcc6a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion menu_tools/object_performance/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def iso_vs_eff_plot(self):
return False

@property
def reference_object(self) -> Object:
def reference_object(self) -> ReferenceObject:
assert isinstance(
self._cfg["reference_object"], dict
), f"Reference object is not a dict in {self.plot_name}!"
Expand Down
23 changes: 12 additions & 11 deletions menu_tools/utils/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def eta_ranges(self) -> dict[str, tuple[float, float]]:
return _eta_ranges

@property
def cuts(self) -> Optional[dict[str, list[str]]]:
def cuts(self) -> dict[str, list[str]]:
"""Necessary interface for Object classes.
To be implemented in derived class.
Expand Down Expand Up @@ -178,12 +178,12 @@ def __init__(self, object_key: str, version: str) -> None:
super().__init__(object_key, version)

@property
def cuts(self) -> Optional[dict[str, list[str]]]:
def cuts(self) -> dict[str, list[str]]:
_cuts = {}
if "cuts" in self._object_params.keys():
_cuts = self._object_params["cuts"]
if self.eta_range != "inclusive":
# if a region other than inclusive is specified an eta cut
# if a region other than inclusive is specified, add an eta cut
eta_min = self.eta_ranges[self.eta_range][0]
eta_max = self.eta_ranges[self.eta_range][1]
global_eta_cut = (
Expand Down Expand Up @@ -216,7 +216,7 @@ def trafo(self) -> Optional[str]:
print("No transformation defined in reference object")
return None

def _get_cuts(self, event_or_object: str) -> Optional[dict[str, list[str]]]:
def _get_cuts(self, event_or_object: str) -> dict[str, list[str]]:
assert event_or_object in [
"event",
"object",
Expand All @@ -225,10 +225,10 @@ def _get_cuts(self, event_or_object: str) -> Optional[dict[str, list[str]]]:
if "cuts" in self._object_params.keys():
if event_or_object in self._object_params["cuts"].keys():
_cuts = self._object_params["cuts"][event_or_object]
else:
return None
elif self.eta_range == "inclusive":
return {}
if self.eta_range != "inclusive":
# if a region other than inclusive is specified an eta cut
# if a region other than inclusive is specified, add an eta cut
eta_min = self.eta_ranges[self.eta_range][0]
eta_max = self.eta_ranges[self.eta_range][1]
global_eta_cut = (
Expand All @@ -241,7 +241,7 @@ def _get_cuts(self, event_or_object: str) -> Optional[dict[str, list[str]]]:
return _cuts

@property
def cuts(self) -> Optional[dict[str, list[str]]]:
def cuts(self) -> dict[str, list[str]]:
"""OBJECT level cuts! I.e. individual objects that don't fulfill the
criteria are removed from the events, but the events themselves are
retained.
Expand All @@ -255,7 +255,7 @@ def cuts(self) -> Optional[dict[str, list[str]]]:
return self._get_cuts("object")

@property
def event_cuts(self) -> Optional[dict[str, list[str]]]:
def event_cuts(self) -> dict[str, list[str]]:
"""EVENT level cuts! Applied after selection of highest pT object per
event.
Is meant to provied cuts to remove *events* whose object doesn't fulfill the
Expand All @@ -282,11 +282,12 @@ def compute_selection_mask_for_cuts(
# Initialize mask with True everywhere
sel = ak.ones_like(ak_array[ak_array.fields[0]]) > 0

# If no cut are specified in object return true everywhere
# If no cut are specified in object, return True everywhere.
# That case will be `cuts = {}`.
if not cuts:
return sel

## add fake eta
## add mock eta
if "eta" not in ak_array.fields:
ak_array["eta"] = 0

Expand Down

0 comments on commit dbfcc6a

Please sign in to comment.