Hello Fellow Rooters,
When plotting histograms, it’s easy to make cuts on ntuple data. However, extracting a subset of ntuple data is surprisingly more complex and one basically has to loop over all the data.
The workman-like code attached extracts a 2-dimensional plot from a 3-D plot along the plane (X==3 && Y==3). Two questions occurred to me while working on it:
Is there a way to improve the code and achieve the same goal more efficiently/elegantly?
If I wish to extract the 'i’th X-value from my nTuple “test_bench”, the code goes something like:
This seems somewhat odd to me. I first point to the ‘leaf’ where the data is stored, then I point to the ‘branch’, then I point to the ‘entry’. I would have expected that the proper order would have been: ‘Branch’->‘Leaf’->‘Entry’. Can someone kindly explain?
There are several ways to extract data from an ntuple. The new recommended way is to use the RData frame, which is the most efficient since it provides code optimised for your machine, using all your available cores and it provides for you the event loop.
See https://root.cern/doc/master/classROOT_1_1RDataFrame.html
Concerning your questions about TLeaf and TBranch, maybe @pcanal can answer for you