Skip to content

Commit

Permalink
Merge branch 'main' into rntuple_writing
Browse files Browse the repository at this point in the history
  • Loading branch information
Moelf authored Sep 13, 2024
2 parents 335e9f1 + ccd8366 commit 1d4d12c
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "UnROOT"
uuid = "3cd96dde-e98d-4713-81e9-a4a1b0235ce9"
authors = ["Tamas Gal", "Jerry Ling", "Johannes Schumann", "Nick Amin"]
version = "0.10.31"
version = "0.10.32"

[deps]
AbstractTrees = "1520ce14-60c1-5f80-bbc7-55ef81b5835c"
Expand Down
15 changes: 12 additions & 3 deletions src/root.jl
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,11 @@ function interped_data(rawdata, rawoffsets, ::Type{Bool}, ::Type{Nojagg})
# specialized case to get Vector{Bool} instead of BitVector
return map(ntoh,reinterpret(Bool, rawdata))
end
function interped_data(rawdata, rawoffsets, ::Type{String}, ::Type{Nojagg})
rawoffsets .= rawoffsets .+ 1
vov_bytes = VectorOfVectors(rawdata, rawoffsets)
return [readtype(IOBuffer(v), String) for v in vov_bytes]
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
Expand Down Expand Up @@ -481,12 +486,16 @@ function leaf_jaggtype(leaf, _jaggtype)
_fTitle = replace(leaf.fTitle, "[$(leafLen)]" => "")
# looking for more `[var]`
m = match(r"\[\D+\]", _fTitle)
_type = FixLenVector{Int(leafLen), _type}
_vtype = FixLenVector{Int(leafLen), _type}
if isnothing(m)
return _type, Nojagg
if leaf isa TLeafC
return String, Nojagg
else
return _vtype, Nojagg
end
else
#FIXME this only handles [var][fix] case
return Vector{_type}, Nooffsetjagg
return Vector{_vtype}, Nooffsetjagg
end
end
_type = _jaggtype === Nojagg ? _type : Vector{_type}
Expand Down
3 changes: 3 additions & 0 deletions src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ function parseTH(th::Dict{Symbol, Any}; raw=true)
counts = th[:fN]
nentries = th[:fEntries]
sumw2 = th[:fSumw2]
if isempty(sumw2)
sumw2 = counts
end
dimension = th[:fYaxis_fNbins]
if dimension > 1
ymin = th[:fYaxis_fXmin]
Expand Down
5 changes: 5 additions & 0 deletions test/issues.jl
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,8 @@ end
@test length(tree.PandoraPFOs_energy[1]) == 79
@test length(tree.var"PandoraPFOs_covMatrix[10]"[1]) == 790
end

@testset "PR 342 TLeafC" begin
df = LazyTree(UnROOT.samplefile("TLeafC_pr342.root"), "G4Sim")
@test all(df.Process[1:10] .== ["Radioactivation", "msc", "eIoni", "Transportation", "ionIoni", "Radioactivation", "msc", "eIoni", "ionIoni", "Radioactivation"])
end
Binary file added test/samples/TLeafC_pr342.root
Binary file not shown.

0 comments on commit 1d4d12c

Please sign in to comment.