Skip to content

Commit

Permalink
Add documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
danielhundhausen committed Oct 22, 2024
1 parent b1aaf46 commit 5b6e8c4
Showing 1 changed file with 43 additions and 8 deletions.
51 changes: 43 additions & 8 deletions menu_tools/utils/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,10 @@ def _object_params(self) -> dict:
object_parameters = defaults | id_specific
return object_parameters

@property
def match_dR(self) -> float:
return self._object_params["match_dR"]

@property
def plot_label(self) -> str:
"""Label of the object in the plots
"""
return self._object_params["label"]

def get_scaling_object(self, eta_range: str) -> str:
Expand All @@ -138,6 +136,27 @@ def eta_ranges(self) -> dict[str, tuple[float, float]]:

@property
def cuts(self) -> Optional[dict[str, list[str]]]:
"""Necessary interface for Object classes.
To be implemented in derived class.
Returns:
cut_dict: Dicitionary of the type
```
{"eta_range_1: [
"<cut string 1.1>",
"<cut string 1.2>",
...
],
"eta_range_2: [
"<cut string 2.1>",
...
],
...
}
```
where `<cut string>` are the requirements
as specified in the object config files.
"""
raise NotImplementedError(
"This method should be implemented in the derived class."
)
Expand Down Expand Up @@ -177,6 +196,10 @@ def cuts(self) -> Optional[dict[str, list[str]]]:
_cuts["inclusive"] = [global_eta_cut]
return _cuts

@property
def match_dR(self) -> float:
return self._object_params["match_dR"]


class ReferenceObject(BaseObject):
def __init__(self, object_key: str, version: str) -> None:
Expand Down Expand Up @@ -223,14 +246,25 @@ def cuts(self) -> Optional[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.
For info on the structure of the returned object see docstring of base
class.
Returns:
object_cut_dict: For info on the structure of the returned object
see docstring of base class.
"""
return self._get_cuts("object")

@property
def event_cuts(self) -> Optional[dict[str, list[str]]]:
"""EVENT level cuts! I.e. individual objects that don't fulfill the
criteria are removed from the events, but the events themselves are
retained.
"""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
criteria.
Returns:
event_cut_dict: For info on the structure of the returned object
see docstring of base class.
"""
return self._get_cuts("event")

Expand Down Expand Up @@ -284,10 +318,11 @@ def compute_selection_mask_for_object_cuts(


if __name__ == "__main__":
x = Object("tkElectron:Iso", "V29")
x = Object("caloJet:default", "V29")
print(x)
print(x.match_dR)
print(x.plot_label)
print(x.eta_ranges)
print(x.cuts)
y = Object("tkElectron:Iso", "V29")
z = ReferenceObject("jet:ht", "V29")

0 comments on commit 5b6e8c4

Please sign in to comment.