Giter VIP home page Giter VIP logo

Comments (11)

tamasgal avatar tamasgal commented on June 8, 2024 2

UnROOT 0.10.26 will allow you

julia> t = LazyTree(f, "sim", [r"ghost/ghost\.(.*)" => s"\1"])
 Row │ ypos             ghostID          time             stepID           fUniqueID        xmom             pd 
     │ SubArray{Float3  SubArray{Int32,  SubArray{Float3  SubArray{Int32,  SubArray{UInt32  SubArray{Float3  Su 
─────┼───────────────────────────────────────────────────────────────────────────────────────────────────────────
 1   │ [982.0, 6.83]    [110000, 11000   [3230.0, 36.4]   [0, 0]           [0, 0]           [-25.6, -29.5]   [- 
 2   │ [2590.0]         [110000]         [29.7]           [0]              [0]              [21.9]           [1 
 3   │ [258.0, -2230.   [110000, 11000   [774.0, 48.0]    [0, 0]           [0, 0]           [-44.3, 22.1]    [- 
 4   │ [-1850.0]        [110000]         [60.6]           [0]              [0]              [14.1]           [1 
 5   │ []               []               []               []               []               []               [] 
 6   │ [512.0]          [110000]         [587.0]          [0]              [0]              [-11.5]          [- 
 7   │ [-11.0]          [110000]         [40.8]           [0]              [0]              [-2.61]          [2 
 8   │ [2890.0]         [110000]         [28.7]           [0]              [0]              [-8.56]          [1 
 9   │ []               []               []               []               []               []               [] 
 10  │ [28.1]           [110000]         [41.0]           [0]              [0]              [-0.453]         [2 
 11  │ [2660.0]         [110000]         [799.0]          [0]              [0]              [-4.84]          [- 
 12  │ [12.0]           [110000]         [41.0]           [0]              [0]              [2.28]           [2 
 13  │ [33.0]           [110000]         [41.8]           [0]              [0]              [-4.04]          [2 
 14  │ [-0.84]          [110000]         [40.5]           [0]              [0]              [-5.09]          [2 
 15  │ [664.0]          [110000]         [311.0]          [0]              [0]              [-3.08]          [1 
 16  │ []               []               []               []               []               []               [] 
 17  │ [-1220.0]        [110000]         [640.0]          [0]              [0]              [7.4]            [1 
 18  │ [-2290.0, -269   [110000, 11000   [1410.0, 1410.   [0, 0, 0]        [0, 0, 0]        [0.0214, 0.01,   [2 
 19  │ [906.0]          [110000]         [8140.0]         [0]              [0]              [41.8]           [- 
 20  │ [3430.0]         [110000]         [4960.0]         [0]              [0]              [-13.3]          [- 
 21  │ []               []               []               []               []               []               [] 
 22  │ [5.71]           [110000]         [41.0]           [0]              [0]              [6.6]            [2 
 23  │ []               []               []               []               []               []               [] 
 24  │ [1330.0]         [110000]         [1250.0]         [0]              [0]              [-24.4]          [1 
 25  │ [-1050.0]        [110000]         [23.5]           [0]              [0]              [10.1]           [1 
 26  │ [-280.0, -2400   [110000, 11000   [1150.0, 39.1]   [0, 0]           [0, 0]           [0.412, -13.6]   [2 
 27  │ []               []               []               []               []               []               [] 
 28  │ [-12.8]          [110000]         [1150.0]         [0]              [0]              [10.7]           [- 
 29  │ [2770.0, 2080.   [110000, 11000   [1610.0, 20.5]   [0, 0]           [0, 0]           [20.8, -15.4]    [- 
 30  │ [262.0, -866.0   [110000, 11000   [36.3, 35.7]     [0, 0]           [0, 0]           [-17.5, 5.21]    [1 
 31  │ []               []               []               []               []               []               [] 
                                                                                              
                                                                                  7 columns and 1169 rows omitted

from unroot.jl.

TheFibonacciEffect avatar TheFibonacciEffect commented on June 8, 2024 1

Thank you so much for the timely response! Even on a saturday, I appreciate that a lot.

from unroot.jl.

tamasgal avatar tamasgal commented on June 8, 2024 1

Science never sleeps ;)

Let me know if you have other issues. The next weeks will be very busy for me though 🙈

from unroot.jl.

Moelf avatar Moelf commented on June 8, 2024 1

huh, I didn't realize but the test file is kinda of large:

 test/samples/issue323.root | Bin 0 -> 5890205 bytes

is it possible to reduce it

from unroot.jl.

TheFibonacciEffect avatar TheFibonacciEffect commented on June 8, 2024 1

@Moelf
Sorry about that, this is also a way to solve large filesizes I guess 😅
Here this file should work: https://polybox.ethz.ch/index.php/s/i6KKEMt8A7UtVM0

julia> LazyTree("./issue323_small.root", "sim", [r"ghost/ghost\.(.*)"])
 Row │ ghost_ymom                   ghost_fBits                  ghost_pdgid                  ghost_trackID                ghost_ghostID                ghost_ 
     │ SubArray{Float3              SubArray{UInt32              SubArray{Int32,              SubArray{Int32,              SubArray{Int32,              SubArr 
─────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
 1   │ [-3.08, -3.08, -3.08, -3.08  [50331648, 50331648, 503316  [-13, -13, -13, -13, -13, -  [3, 3, 3, 3, 3, 3, 3, 3, 3,  [110000, 110001, 110002, 11  [21.7, 
 2   │ [-2.92, -2.92, -2.92, -2.92  [50331648, 50331648, 503316  [211, 211, 211, 211, 211, 2  [1, 1, 1, 1, 1, 1, 1, 1, 1,  [110000, 110001, 110002, 11  [22.8, 
 3   │ [0.417, 0.417, 0.417, 0.417  [50331648, 50331648, 503316  [211, 211, 211, 211, 211, 2  [1, 1, 1, 1, 1, 1, 1, 1, 1,  [110000, 110001, 110002, 11  [21.8, 
 4   │ [-10.8, -10.8, -10.8, -10.8  [50331648, 50331648, 503316  [-14, -14, -14, -14, -14, -  [4, 4, 4, 4, 4, 4, 4, 4, 4,  [110000, 110001, 110002, 11  [10100 
 5   │ [-21.3, -21.3, -21.3, -21.3  [50331648, 50331648, 503316  [14, 14, 14, 14, 14, 14, 14  [2, 2, 2, 2, 2, 2, 2, 2, 2,  [110000, 110001, 110002, 11  [13.2, 
 6   │ [-15.2, -15.2, -15.2, -15.2  [50331648, 50331648, 503316  [211, 211, 211, 211, 211, 2  [1, 1, 1, 1, 1, 1, 1, 1, 1,  [110000, 110001, 110002, 11  [22.3, 
 7   │ [2.34, 2.34, 2.34, 2.34, 2.  [50331648, 50331648, 503316  [-14, -14, -14, -14, -14, -  [4, 4, 4, 4, 4, 4, 4, 4, 4,  [110000, 110001, 110002, 11  [1140. 
 8   │ [28.6, 28.6, 28.6, 28.6, 28  [50331648, 50331648, 503316  [14, 14, 14, 14, 14, 14, 14  [2, 2, 2, 2, 2, 2, 2, 2, 2,  [110000, 110001, 110002, 11  [20.3, 
 9   │ [9.87, 9.87, 9.87, 9.87, 9.  [50331648, 50331648, 503316  [211, 211, 211, 211, 211, 2  [1, 1, 1, 1, 1, 1, 1, 1, 1,  [110000, 110001, 110002, 11  [22.1, 
 10  │ [10.3, 10.3, 10.3, 10.3, 10  [50331648, 50331648, 503316  [14, 14, 14, 14, 14, 14, 14  [2, 2, 2, 2, 2, 2, 2, 2, 2,  [110000, 110001, 110002, 11  [10.3, 
 11  │ [-24.1, -24.1, -24.1, -24.1  [50331648, 50331648, 503316  [14, 14, 14, 14, 14, 14, 14  [2, 2, 2, 2, 2, 2, 2, 2, 2,  [110000, 110001, 110002, 11  [15.0, 
                                                                                                                                                                                                                                                                       8 columns and 113 rows omitted

Thanks again for helping me out with the issue : )

from unroot.jl.

tamasgal avatar tamasgal commented on June 8, 2024

Just a very quick answer with a workaround, to allow you to proceed with your research. You can use the array() function to load the full data into memory. Since your file is small, laziness is not really needed, but your mileage may vary ;)

Anyways this is an example:

julia> f = ROOTFile("/Users/tamasgal/Downloads/pienu00002-02.root")
ROOTFile with 2 entries and 27 streamers.
/Users/tamasgal/Downloads/pienu00002-02.root
├─ sim (TTree)
│  ├─ "info"
│  ├─ "init"
│  ├─ "track"
│  ├─ "decay"
│  ├─ "ghost"
│  ├─ "ghostface"
│  └─ "upstream"
└─ PIMCRunHeader (PIMCRunHeader)


julia> UnROOT.array(f, "sim/ghost/ghost.pdgid")
1200-element ArraysOfArrays.VectorOfVectors{Int32, Vector{Int32}, Vector{Int32}, Vector{Tuple{}}}:
 Int32[-14, 14]
 Int32[14]
 Int32[-14, 14]
 Int32[14]
 0-element view(::Vector{Int32}, 7:6) with eltype Int32
 Int32[-14]
 Int32[211]

I will have a closer look at the file. LazyTree and LazyBranch are sometimes a bit hard to use with nested data.

from unroot.jl.

tamasgal avatar tamasgal commented on June 8, 2024

OK, the first problem is that you are using the wrong path to the subbranch. I don't blame you, this is just something which is probably (read obviously) not very well documented ;)

If the structure is the following:

julia> f["sim/ghost"]
ghost
├─ ghost.fUniqueID
├─ ghost.fBits
├─ ghost.ghostID
├─ ghost.trackID
├─ ghost.stepID
├─ ghost.pdgid
├─ ghost.xpos
├─ ghost.ypos
├─ ghost.zpos
├─ ghost.time
├─ ghost.xmom
├─ ghost.ymom
└─ ghost.zmom

the path to the subbranch is "sim/ghost/ghost.pdgid". A LazyTree would then be

LazyBranch(f, "sim", ["sim/ghost/ghost.pdgid"])

or using a regex:

julia> LazyTree(f, "sim", [r"ghost/ghost\.(.*)" => s"\1"])

However (now comes the real problem), you will face the following error:

ERROR: MethodError: no method matching UInt32()

Closest candidates are:
  UInt32(::HTTP.WebSockets.Mask)
   @ HTTP ~/.julia/packages/HTTP/1EWL3/src/WebSockets.jl:62
  UInt32(::Char)
   @ Base char.jl:127
  UInt32(::Float64)
   @ Base float.jl:884
  ...

Stacktrace:
 [1] LazyBranch(f::ROOTFile, b::UnROOT.TBranchElement_10)
   @ UnROOT ~/Dev/UnROOT.jl/src/iteration.jl:124)

which is there because we never had a flat array and we use VectorOfVectors and do not cover the case for a flat array 🙈

I'll try to provide a fix asap.

from unroot.jl.

tamasgal avatar tamasgal commented on June 8, 2024

Fix on the way in #324

from unroot.jl.

TheFibonacciEffect avatar TheFibonacciEffect commented on June 8, 2024

Sure there you go:
https://polybox.ethz.ch/index.php/s/PcYbFyA5WO2Txvt

from unroot.jl.

Moelf avatar Moelf commented on June 8, 2024

@TheFibonacciEffect that file seems to be empty:

julia> LazyTree("./test/samples/issue323_small.root", "sim", [r"ghost/ghost\.(.*)"])
 Row │ ghost_ymom       ghost_fBits      ghost_pdgid      ghost_trackID    ghost_ghostID    ghost_time       ghost_xmom       ghost_xpos       ghost_zmom      
     │ SubArray{Float3  SubArray{UInt32  SubArray{Int32,  SubArray{Int32,  SubArray{Int32,  SubArray{Float3  SubArray{Float3  SubArray{Float3  SubArray{Float3 
─────┴──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
                                                                                                                                               4 columns omitted

from unroot.jl.

tamasgal avatar tamasgal commented on June 8, 2024

Oh shoot, that's my bad, I misread the file size for whatever reason (thought it's 500kB) 🙈

from unroot.jl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.