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
97 stars 17 forks source link

[RNTuple] Filter out recursively empty structures in the schema #308

Closed Moelf closed 6 months ago

Moelf commented 6 months ago

there are many structs named :_0 and :_1 and so on, these denote the "base class" in C++, in reverse order, so if a field B has a :_0 named A, it means that in C++ the B inherent from A.

I tried to just filter out names starts with :_ but that didn't work because apparently there are genuinely anonymous base class...

notice this is slightly different than what std::tuple<> has, which are stuff like _0, _1, without the colon.

This PR implements a isvoid() to help recursively filter them out during schema building so we can read as much as data as possible.

codecov[bot] commented 6 months ago

Codecov Report

Attention: Patch coverage is 83.33333% with 5 lines in your changes are missing coverage. Please review.

Project coverage is 86.39%. Comparing base (98a84e0) to head (7e66c62). Report is 1 commits behind head on main.

Files Patch % Lines
src/RNTuple/fieldcolumn_schema.jl 86.36% 3 Missing :warning:
src/RNTuple/highlevel.jl 71.42% 2 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #308 +/- ## ========================================== + Coverage 86.32% 86.39% +0.06% ========================================== Files 18 18 Lines 2443 2447 +4 ========================================== + Hits 2109 2114 +5 + Misses 334 333 -1 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

Moelf commented 6 months ago
julia> tree = LazyTree("./test/samples/RNTuple/DAOD_TRUTH3_RC2.root", "RNT:CollectionTree");

julia> for evt in tree
           jets = evt.var"AntiKt4TruthDressedWZJetsAux:"
           truth_flavor_tags = evt.var"AntiKt4TruthDressedWZJetsAux::HadronConeExclTruthLabelID"

           println("==============")
           @show jets.pt
           @show truth_flavor_tags
           @show evt.var"TruthPhotonsAux::px"
       end
==============
jets.pt = Float32[137298.88, 118027.67, 31116.643, 28629.326, 17351.232]
truth_flavor_tags = Int32[0, 5, 0, 5, 0]
evt.var"TruthPhotonsAux::px" = Float32[-52145.84, 1060.6826, -0.9319739]
==============
jets.pt = Float32[73221.56, 31130.473, 22917.56, 21360.844, 13578.273, 10134.706, 8916.754, 7987.4453, 7619.1997, 7487.0786, 7030.038, 6868.25, 6388.838, 6133.2417, 5345.315, 5029.3926]
truth_flavor_tags = Int32[0, 5, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
evt.var"TruthPhotonsAux::px" = Float32[-6.2098184, 51.95629, 27.160927, -51.24911, 70638.18, -58.14793, 77.87332, -180.0086, -128.791, -0.016017968, -0.00028374564]
==============
jets.pt = Float32[39111.723, 24717.57, 20426.715, 11562.928, 7844.396, 6405.788, 6397.466, 5926.0474, 5513.7554]
truth_flavor_tags = Int32[0, 5, 0, 5, 0, 0, 0, 0, 0]
evt.var"TruthPhotonsAux::px" = Float32[-96.77242, -47.759464, -33791.34, 453.31308, 161.04024, -4.3567376, -43.031048]
==============
jets.pt = Float32[21375.896, 12145.5205, 6971.521, 6268.643, 5900.698, 5274.742, 5182.696]
truth_flavor_tags = Int32[0, 0, 5, 0, 4, 0, 0]
evt.var"TruthPhotonsAux::px" = Float32[14796.121, -25.23317, 119.10051, 9.732789]
==============
jets.pt = Float32[50275.066, 42447.902, 27796.326, 17693.484, 11105.502, 10537.192, 8902.598, 6842.048, 6522.262, 6387.5513, 5966.507, 5794.2974, 5443.37, 5434.6426, 5432.8296, 5260.1396, 5013.1274]
truth_flavor_tags = Int32[5, 5, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0]
evt.var"TruthPhotonsAux::px" = Float32[-89.77318, -127.08815, 138.97107, 96.51122, -3987.3398, -21359.723, 0.0028186112, 153.41467]
==============
jets.pt = Float32[72226.09, 49919.684, 35297.17]
truth_flavor_tags = Int32[0, 5, 0]
evt.var"TruthPhotonsAux::px" = Float32[56.596363, -18.088055, 67673.58, 0.82155985, -4.6714697, -29.82198, -301.00183]
==============
jets.pt = Float32[46919.977, 37719.016, 30329.836, 7174.5747]
truth_flavor_tags = Int32[5, 0, 5, 0]
evt.var"TruthPhotonsAux::px" = Float32[157.72008, 29887.629, 150.97502, 12.245194, 9.1611805, -52.638943]
==============
jets.pt = Float32[26557.068, 22422.715, 21753.354, 15304.675, 5571.318, 5515.6426, 5097.025]
truth_flavor_tags = Int32[5, 0, 5, 0, 0, 0, 0]
evt.var"TruthPhotonsAux::px" = Float32[-46.954937, 21670.209, 36.5389, 38.936478, -0.522815, -13.292021, 6.493229]
==============
jets.pt = Float32[68539.28, 39667.52, 36652.668, 10898.928, 9513.909, 8409.326, 7036.396, 6876.2817, 5505.337]
truth_flavor_tags = Int32[5, 5, 0, 0, 0, 0, 0, 0, 0]
evt.var"TruthPhotonsAux::px" = Float32[-18.511896, -2098.5073, -6.1538186, 566.5639]