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

readig lazy tree from a tdirectory #108

Closed
sgnoohc opened this issue Sep 16, 2021 · 2 comments · Fixed by #109
Closed

readig lazy tree from a tdirectory #108

sgnoohc opened this issue Sep 16, 2021 · 2 comments · Fixed by #109

Comments

@sgnoohc
Copy link

sgnoohc commented Sep 16, 2021

Could someone look into this?

input is here: http://uaf-10.t2.ucsd.edu/~phchang//julia/trackntuple.root

Thanks,
Philip

               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.6.2 (2021-07-14)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

julia> using UnROOT

julia> f = ROOTFile("trackntuple.root")
ROOTFile with 1 entry and 28 streamers.
/home/users/phchang/public_html/julia/trackntuple.root
└─ trackingNtuple (TDirectory)
   └─ tree (TTree)
      ├─ "event"
      ├─ "lumi"
      ├─ "run"
      ├─ "⋮"
      ├─ "simvtx_sourceSimIdx"
      ├─ "simvtx_daughterSimIdx"
      └─ "simpv_idx"


julia> lt = LazyTree(f, "trackingNtuple/tree", [r"pix_.*"])
┌ Warning: Can't automatically create LazyBranch for branch trackingNtuple/tree/pix_ladder. Returning a branch object
└ @ UnROOT ~/.julia/packages/UnROOT/vROjM/src/root.jl:133
ERROR: MethodError: Cannot `convert` an object of type
  UnROOT.TBranchElement_10 to an object of type
  LazyBranch
Closest candidates are:
  convert(::Type{T}, ::LinearAlgebra.Factorization) where T<:AbstractArray at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/LinearAlgebra/src/factorization.jl:58
  convert(::Type{T}, ::T) where T<:AbstractArray at abstractarray.jl:14
  convert(::Type{T}, ::T) where T at essentials.jl:205
Stacktrace:
 [1] setindex!(h::Dict{Symbol, LazyBranch}, v0::UnROOT.TBranchElement_10, key::Symbol)
   @ Base ./dict.jl:382
 [2] LazyTree(f::ROOTFile, s::String, branches::Vector{Regex})
   @ UnROOT ~/.julia/packages/UnROOT/vROjM/src/iteration.jl:252
 [3] top-level scope
   @ REPL[3]:1

(@v1.6) pkg> status UnROOT
      Status `~/.julia/environments/v1.6/Project.toml`
  [3cd96dde] UnROOT v0.6.1 `https://github.com/tamasgal/UnROOT.jl#master`

(@v1.6) pkg>
@aminnj
Copy link
Member

aminnj commented Sep 16, 2021

Luckily it was just a matter of updating the "lookup table" with two new types. Let me make a PR with a test.

@@ -365,6 +365,10 @@ function auto_T_JaggT(f::ROOTFile, branch; customstructs::Dict{String, Type})
                     UInt32
                 elseif elname == "unsigned char"
                     Char
+                elseif elname == "unsigned short"
+                    UInt16
+                elseif elname == "ulong64"
+                    UInt64
                 else
                     _type = getfield(Base, Symbol(:C, elname))
                 end

after

julia> t = LazyTree(ROOTFile("trackntuple.root"),"trackingNtuple/tree")
┌ Warning: Your tree is quite wide, with 301 branches, this will take compiler a moment.
└ @ UnROOT ~/.julia/dev/UnROOT/src/iteration.jl:244
 Row │ see_stateCcov22          ph2_subdet               sim_parentVtxId          pix_xySignifica          simhit_detId             ph2_simType              s 
     │ Vector{Float32}          Vector{UInt16}           Vector{Int32}            Vector{Vector{F          Vector{UInt32}           Vector{UInt16}           V 
─────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
 1   │ [1.94f-6, 6.59f-8, 1.36  [4, 4, 4, 4, 4, 4, 4, 4  [0, 0, 0, 0, 0, 0, 0, 0  Vector{Float32}[[18.407  [305172488, 304128016,   [0, 0, 0, 0, 0, 0, 0, 0  [ 
 2   │ [2.18f-6, 4.15f-7, 6.53  [4, 4, 4, 4, 4, 4, 4, 4  [0, 0, 0, 0, 0, 0, 0, 0  Vector{Float32}[[11.120  [305201160, 344212576,   [0, 0, 0, 0, 0, 0, 0, 0  [ 
 3   │ [8.33f-8, 7.25f-8, 4.5f  [4, 4, 4, 4, 4, 4, 4, 4  [0, 0, 0, 0, 0, 0, 0, 0  Vector{Float32}[[0.2006  [304099348, 303042580,   [0, 0, 0, 0, 0, 0, 0, 0  [ 
 4   │ [0.0514, 0.0514, 0.0229  [4, 4, 4, 4, 4, 4, 4, 4  [0, 0, 0, 0, 0, 0, 0, 0  Vector{Float32}[[26.702  [353911916, 303075352,   [0, 0, 0, 0, 0, 0, 0, 0  [ 
 5   │ [1.16f-6, 2.94f-7, 0.20  [4, 4, 4, 4, 4, 4, 4, 4  [0, 0, 0, 0, 0, 0, 0, 0  Vector{Float32}[[1.2058  [303083532, 303083532,   [0, 0, 0, 0, 0, 0, 0, 0  [ 
 6   │ [7.71f-7, 7.74f-7, 7.76  [4, 4, 4, 4, 4, 4, 4, 4  [0, 0, 0, 0, 0, 0, 0, 0  Vector{Float32}[[1.1037  [411595905, 412124345,   [0, 0, 0, 0, 0, 0, 0, 0  [ 
 7   │ [1.76f-7, 1.75f-7, 1.59  [4, 4, 4, 4, 4, 4, 4, 4  [0, 0, 0, 0, 0, 0, 0, 0  Vector{Float32}[[0.8835  [352855144, 303071256,   [0, 0, 0, 0, 0, 0, 0, 0  [ 
 8   │ [7.13f-7, 3.59f-9, 4.77  [4, 4, 4, 4, 4, 4, 4, 4  [0, 0, 0, 0, 0, 0, 0, 0  Vector{Float32}[[7.0920  [439888985, 419738749,   [0, 0, 0, 0, 0, 0, 0, 0  [ 
 9   │ [1.14f-6, 3.77f-6, 3.76  [4, 4, 4, 4, 4, 4, 4, 4  [0, 0, 0, 0, 0, 0, 0, 0  Vector{Float32}[[1.9531  [347092004, 345248788,   [0, 0, 0, 0, 0, 0, 0, 0  [ 
 10  │ [9.2f-9, 0.118, 0.118,   [4, 4, 4, 4, 4, 4, 4, 4  [0, 0, 0, 0, 0, 0, 0, 0  Vector{Float32}[[0.2538  [419963998, 352851024,   [0, 0, 0, 0, 0, 0, 0, 0  [ 
                                                                                                                                         
                                                                                                                                 294 columns and 90 rows omitted

@Moelf
Copy link
Member

Moelf commented Sep 16, 2021

I wish we can find a list of all possible names... but who knows how ROOT "stringify" them

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants