JuliaHEP / UnROOT.jl

Native Julia I/O package to work with CERN ROOT files objects (TTree and RNTuple)
https://juliahep.github.io/UnROOT.jl/
MIT License
103 stars 18 forks source link

Reading a tuple<unsigned int, string, bool, unsigned int> from a TTree #363

Open peremato opened 3 weeks ago

peremato commented 3 weeks ago

I have a problem reading the linked file. There is a TTree called polio_metadata with a branch called events___CollectionTypeInfo of type tuple<unsigned int, string, bool, unsigned int>. I am interested to get the element 1 of the tuple, which is string. But I get an error:

LazyTree(tfile,"podio_metadata",["events___CollectionTypeInfo/events___CollectionTypeInfo._1"])
ERROR: TypeError: in GenericMemory, in element type, expected Type, got a value of type Nothing
Stacktrace:
  [1] GenericMemory
    @ ./boot.jl:516 [inlined]
  [2] Vector{nothing}(::UndefInitializer, m::Int64)
    @ Core ./boot.jl:578
  [3] Vector{nothing}()
    @ Core ./boot.jl:601
  [4] LazyBranch(f::ROOTFile, b::UnROOT.TBranchElement_10)
    @ UnROOT ~/.julia/packages/UnROOT/4c5To/src/iteration.jl:123
  [5] LazyBranch(f::ROOTFile, s::String)
    @ UnROOT ~/.julia/packages/UnROOT/4c5To/src/iteration.jl:134
  [6] LazyTree(f::ROOTFile, tree::UnROOT.TTree, treepath::String, branches::Vector{String}; sink::Type{LazyTree})
    @ UnROOT ~/.julia/packages/UnROOT/4c5To/src/iteration.jl:449
  [7] LazyTree
    @ ~/.julia/packages/UnROOT/4c5To/src/iteration.jl:431 [inlined]
  [8] LazyTree(f::ROOTFile, s::String, branches::Vector{String}; kwargs::@Kwargs{})
    @ UnROOT ~/.julia/packages/UnROOT/4c5To/src/iteration.jl:392
  [9] LazyTree(f::ROOTFile, s::String, branches::Vector{String})
    @ UnROOT ~/.julia/packages/UnROOT/4c5To/src/iteration.jl:389
 [10] top-level scope
    @ REPL[25]:1

I can get element 0 without problems:

LazyTree(tfile,"podio_metadata",["events___CollectionTypeInfo/events___CollectionTypeInfo._0"])
 Row │ events___Collec                                                                                                                                         ⋯
     │ SubArray{UInt32                                                                                                                                         ⋯
─────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
 1   │ [3470328915, 140414123, 2135478584, 1822974285, 1427737228, 1424292776, 3616779153, 3455758480, 1122056138, 4183352422, 1753703688, 1293498717, 3617521 ⋯

Do you know a way out?

Moelf commented 3 weeks ago

I don't think we ever read tuples in TTree actually