Skip to content

Commit

Permalink
Add HACK for TrackerHT rate plots
Browse files Browse the repository at this point in the history
  • Loading branch information
artlbv committed Mar 3, 2024
1 parent 11787e7 commit 65bebc0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
4 changes: 2 additions & 2 deletions menu_tools/caching/merge_arrays.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import awkward as ak

version = "V32nano"
sample = "DYLL_M50"
version = "V33nano"
sample = "MinBias"
# sample = "Hgg"
pattern = f"cache/{version}/{version}_{sample}_%s.parquet"
objects = ["L1EGbarrel","L1EGendcap"]
Expand Down
5 changes: 4 additions & 1 deletion menu_tools/rate_plots/plotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ def __init__(self, cfg, data, offline_pt: bool):
self.data = data
self.offline_pt = offline_pt

## Overwrite outdir
self._outdir = os.path.join("outputs", self.cfg.version, "object_performance", "rates")

@property
def _online_offline(self):
if self.offline_pt:
Expand Down Expand Up @@ -214,7 +217,7 @@ def _load_cached_arrays(self):
# Apply scalings if so configured
if self.apply_offline_conversion:
arr = scalings.add_offline_pt(arr, self.object)
arr["pt"] = scalings.get_pt_branch(arr)
arr["pt"] = scalings.get_pt_branch(arr, str(self.object))

return arr

Expand Down
11 changes: 8 additions & 3 deletions menu_tools/utils/scalings.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,28 @@ def load_scaling_params(obj: Object, eta_range: str) -> tuple[float, float]:
return scaling_params["slope"], scaling_params["offset"]


def get_pt_branch(arr: ak.Array) -> ak.Array:
def get_pt_branch(arr: ak.Array, obj_name: str) -> ak.Array:
if "pt" in arr.fields:
pt_orig = arr.pt
elif "et" in arr.fields:
pt_orig = arr.et
elif "" in arr.fields:
pt_orig = arr[""]
### HACK
elif "L1TrackHT:MHT" in obj_name:
pt_orig = arr["mht"]
elif "L1TrackHT:HT" in obj_name:
pt_orig = arr["ht"]
else:
raise RuntimeError("Unknown pt branch!")
raise RuntimeError(f"Unknown pt branch for {obj_name}! in fields", arr.fields)
return pt_orig


def add_offline_pt(arr: ak.Array, obj: Object) -> ak.Array:
"""
Add offline pt to filed called `offline_pt` and return array
"""
pt_orig = get_pt_branch(arr)
pt_orig = get_pt_branch(arr, str(obj))
new_pt = ak.zeros_like(pt_orig)

if len(obj.eta_ranges) == 1 and list(obj.eta_ranges)[0] == "inclusive":
Expand Down

0 comments on commit 65bebc0

Please sign in to comment.