Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix bool branch interpretation #102

Merged
merged 2 commits into from
Sep 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/root.jl
Original file line number Diff line number Diff line change
Expand Up @@ -193,16 +193,20 @@ on type `T` and jagg type `J`.
In order to retrieve data from custom branches, user should defined more speialized
method of this function with specific `T` and `J`. See `TLorentzVector` example.
"""
function interped_data(rawdata, rawoffsets, ::Type{Bool}, ::Type{Nojagg})
# specialized case to get Vector{Bool} instead of BitVector
return map(ntoh,reinterpret(T, rawdata))
end
function interped_data(rawdata, rawoffsets, ::Type{T}, ::Type{J}) where {T, J<:JaggType}
# there are two possibility, one is the leaf is just normal leaf but the title has "[...]" in it
# magic offsets, seems to be common for a lot of types, see auto.py in uproot3
# only needs when the jaggedness comes from TLeafElements, not needed when
# the jaggedness comes from having "[]" in TLeaf's title
# the other is where we need to auto detector T bsaed on class name
# we want the fundamental type as `reinterpret` will create vector
if J == Nojagg
if J === Nojagg
return ntoh.(reinterpret(T, rawdata))
elseif J == Offsetjaggjagg # the branch is doubly jagged
elseif J === Offsetjaggjagg # the branch is doubly jagged
jagg_offset = 10
subT = eltype(eltype(T))
out = VectorOfVectors(T(), Int32[1])
Expand Down
1 change: 1 addition & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ end
tree = LazyTree(rootfile, "Events", r"Muon_(pt|eta)$")
@test sort(propertynames(tree) |> collect) == sort([:Muon_pt, :Muon_eta])
@test occursin("LazyEvent", repr(first(iterate(tree))))
@test sum(rootfile["Events/HLT_Mu3_PFJet40"]) == 443
close(rootfile)
end

Expand Down