Skip to content
Snippets Groups Projects
Commit 71867786 authored by Tamas Gal's avatar Tamas Gal :speech_balloon:
Browse files

Add the ability for custom interpretations

parent bbeea0a0
No related branches found
No related tags found
No related merge requests found
Pipeline #10198 passed with warnings
......@@ -48,5 +48,6 @@ class GSGReader:
exclude={},
update={},
attrparser=lambda x: x,
flat=True)
flat=True,
interpretations={})
return Branch(self._fobj, gseagen_events_mapper)
......@@ -31,7 +31,8 @@ EVENTS_MAP = BranchMapper(name="events",
'n_mc_tracks': 'mc_trks'
},
attrparser=lambda a: a,
flat=True)
flat=True,
interpretations={})
SUBBRANCH_MAPS = [
BranchMapper(name="tracks",
......@@ -41,7 +42,8 @@ SUBBRANCH_MAPS = [
['trks.usr_data', 'trks.usr', 'trks.fUniqueID', 'trks.fBits'],
update={},
attrparser=_nested_mapper,
flat=False),
flat=False,
interpretations={}),
BranchMapper(name="mc_tracks",
key="mc_trks",
extra={},
......@@ -51,7 +53,8 @@ SUBBRANCH_MAPS = [
],
update={},
attrparser=_nested_mapper,
flat=False),
flat=False,
interpretations={}),
BranchMapper(name="hits",
key="hits",
extra={},
......@@ -61,7 +64,8 @@ SUBBRANCH_MAPS = [
],
update={},
attrparser=_nested_mapper,
flat=False),
flat=False,
interpretations={}),
BranchMapper(name="mc_hits",
key="mc_hits",
extra={},
......@@ -72,7 +76,8 @@ SUBBRANCH_MAPS = [
],
update={},
attrparser=_nested_mapper,
flat=False),
flat=False,
interpretations={}),
]
......
......@@ -36,7 +36,7 @@ def _unfold_indices(obj, indices):
BranchMapper = namedtuple(
"BranchMapper",
['name', 'key', 'extra', 'exclude', 'update', 'attrparser', 'flat'])
['name', 'key', 'extra', 'exclude', 'update', 'attrparser', 'flat', 'interpretations'])
class Branch:
......@@ -102,6 +102,7 @@ class Branch:
def __getkey__(self, key):
out = self._branch[self._keymap[key]].lazyarray(
interpretation=self._mapper.interpretations.get(key),
basketcache=BASKET_CACHE)
return _unfold_indices(out, self._index_chain)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment