Skip to content

Commit

Permalink
Move process out of file read function
Browse files Browse the repository at this point in the history
  • Loading branch information
artlbv committed Mar 4, 2024
1 parent 23299d0 commit b1ee39f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ outputs
menu_tools.egg-info
dist
ph2-menu-tools
prod_ph2-menu-tools
26 changes: 13 additions & 13 deletions menu_tools/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,19 @@ def get_branches(ntuple_path: str, tree: str, obj: str):
ntuple = glob.glob(ntuple_path)[0]
with uproot.open(ntuple) as f:
all_branches = f[tree].keys()
if "GenTree" in tree:
prefix = "Generator/"
elif "L1PhaseII" in tree:
prefix = "L1PhaseII/"
elif "Events" in tree:
prefix = ""

## nano
if tree == "Events":
obj_branches = [x.split("_")[-1] for x in all_branches if x.startswith(obj)]
## no nano
else:
obj_branches = [x.removeprefix(prefix + obj) for x in all_branches if x.startswith(prefix+obj)]
if "GenTree" in tree:
prefix = "Generator/"
elif "L1PhaseII" in tree:
prefix = "L1PhaseII/"
elif "Events" in tree:
prefix = ""

## nano
if tree == "Events":
obj_branches = [x.split("_")[-1] for x in all_branches if x.startswith(obj)]
## no nano
else:
obj_branches = [x.removeprefix(prefix + obj) for x in all_branches if x.startswith(prefix+obj)]

return obj_branches

Expand Down

0 comments on commit b1ee39f

Please sign in to comment.