-
Notifications
You must be signed in to change notification settings - Fork 17
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
Reading subbranches of jagged custom struct #23
Comments
I think this should be doable with the https://github.com/tamasgal/UnROOT.jl/blob/master/src/root.jl#L176 |
When I try this on
and I don't know how to apply the |
oops, sorry, I see it's a jagged branch of your custom type, in that case, pattern match this: |
I tried this already and I got
(Maybe as remark: I didn't mention this attempt, because I had in mind that this feature is not really ready to use from a discussion with @tamasgal some time ago 🙈 ) |
this won't work because Julia doesn't know what
|
At first I followed the reading from the online file format (example file ) and also defined a struct
|
the full information is just raw bytes, for example, if your branch is suppose to be a As of now, the above case and all the |
I assumed something like this for the custom struct (without too detailed knowledge of the inner structure of ROOT files), this was the reason why I was going for each fields/subbranch individually and not by |
say your struct is:
And our real branch is:
with the caveat, in reality you need to swap bit order, but that can be done at last step. And then the offsets will give you information about "first two |
Sorry for my sparse participation. The easiest way is probably to read the split branches. Also in uproot it's quite complicated to read the class instances... |
Back to my desk... So, to add a bit more information, if you read Problems however may arise when data is multiply jagged, which is a bit "awkward", but I have some working examples... and of course in Many other KM3NeT data, especially those created by the DAQ system have a very low split level where you really need to provide the data types and structure, however, the jaggedness should be the same to my knowledge, which means that at least the raw data should be splittable correctly. |
Just to sum up, this is where we are currently: julia> using UnROOT
julia> f = UnROOT.ROOTFile("test/samples/km3net_offline.root")
ROOTFile("test/samples/km3net_offline.root") with 2 entries and 25 streamers.
julia> array(f, "E/Evt/hits/hits.tot")
ERROR: Cannot understand fClassName: Hit.
Stacktrace:
[1] error(s::String)
@ Base ./error.jl:33
[2] autointerp_T(branch::UnROOT.TBranchElement_10, leaf::UnROOT.TLeafElement)
@ UnROOT ~/Dev/UnROOT.jl/src/root.jl:190
[3] array(f::ROOTFile, path::String; raw::Bool)
@ UnROOT ~/Dev/UnROOT.jl/src/root.jl:170
[4] array(f::ROOTFile, path::String)
@ UnROOT ~/Dev/UnROOT.jl/src/root.jl:140
[5] top-level scope
@ REPL[18]:1 and now need to get this leaf-parsing right. @8me is working on it :) |
@all-contributors please add @8me for code, tests and data |
I've put up a pull request to add @8me! 🎉 |
I try to read a
TBranchElement
which contains subbranches from a data file which has the file format like this example file. In order to get more specific, I want to read the track information atE/Evt/trks
. The track information contains the particles properties (for simulation) or the reconstructions (for measurement) per event, so this leads to a nested array structure. Taking a look at it usinguproot
(loading the given example file tofobj
) I get:I'm able to read the single fields with
UnROOT.jl
and with the
offsets
I can get the nested array structure preserved. I get stuck when I want to read this is an more efficient way and converting it to a trk struct preserving the nested array structure?!The text was updated successfully, but these errors were encountered: