diff --git a/Project.toml b/Project.toml index af5d92b5..37cb96a1 100644 --- a/Project.toml +++ b/Project.toml @@ -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" diff --git a/src/root.jl b/src/root.jl index a65f5659..4070e288 100644 --- a/src/root.jl +++ b/src/root.jl @@ -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 @@ -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} diff --git a/src/utils.jl b/src/utils.jl index 042fe803..ef47e860 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -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] diff --git a/test/issues.jl b/test/issues.jl index 98c01bf7..7bab1231 100644 --- a/test/issues.jl +++ b/test/issues.jl @@ -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 diff --git a/test/samples/TLeafC_pr342.root b/test/samples/TLeafC_pr342.root new file mode 100644 index 00000000..59ff7757 Binary files /dev/null and b/test/samples/TLeafC_pr342.root differ