-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add known forth for 2D vector ElementLinks
- Loading branch information
Showing
4 changed files
with
94 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# BSD 3-Clause License; see https://github.com/scikit-hep/uproot5/blob/main/LICENSE | ||
|
||
""" | ||
This module defines known forth code for types it is known a priori. | ||
""" | ||
from __future__ import annotations | ||
|
||
|
||
def known_forth_of(branch): | ||
from uproot.interpretation.known_forth.atlas.element_link import ( | ||
vector_vector_element_link, | ||
) | ||
|
||
if ( | ||
# len(branch.branches) == 0 # don't understand why this goes nuts | ||
# and branch.has_member("fClassName") | ||
branch.has_member("fClassName") | ||
): | ||
typename = branch.member("fClassName").replace(" ", "") | ||
if typename.startswith("vector<vector<ElementLink<DataVector<xAOD::"): | ||
return vector_vector_element_link |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# BSD 3-Clause License; see https://github.com/scikit-hep/uproot5/blob/main/LICENSE | ||
|
||
""" | ||
This module defines ATLAS specific known forth code | ||
""" |
57 changes: 57 additions & 0 deletions
57
src/uproot/interpretation/known_forth/atlas/element_link.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# BSD 3-Clause License; see https://github.com/scikit-hep/uproot5/blob/main/LICENSE | ||
|
||
""" | ||
This module defines known forth code for some ElementLink data types in ATLAS (D)AODs | ||
""" | ||
|
||
# TODO: delay import? | ||
from __future__ import annotations | ||
|
||
from awkward.forms import ListOffsetForm, NumpyForm, RecordForm | ||
|
||
vector_vector_element_link = ( | ||
""" | ||
input stream | ||
input byteoffsets | ||
input bytestops | ||
output node1-offsets int64 | ||
output node2-offsets int64 | ||
output node3-data uint32 | ||
output node4-data uint32 | ||
0 node1-offsets <- stack | ||
0 node2-offsets <- stack | ||
0 do | ||
byteoffsets I-> stack | ||
stream seek | ||
6 stream skip | ||
stream !I-> stack | ||
dup node1-offsets +<- stack | ||
0 do | ||
stream !I-> stack | ||
dup node2-offsets +<- stack | ||
0 do | ||
20 stream skip | ||
stream !I-> node3-data | ||
stream !I-> node4-data | ||
loop | ||
loop | ||
loop | ||
""", | ||
ListOffsetForm( | ||
"i64", | ||
ListOffsetForm( | ||
"i64", | ||
RecordForm( | ||
[ | ||
NumpyForm("uint32", form_key="node3"), | ||
NumpyForm("uint32", form_key="node4"), | ||
], | ||
["m_persKey", "m_persIndex"], | ||
), | ||
form_key="node2", | ||
), | ||
form_key="node1", | ||
), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters