scikit-hep / root_numpy

The interface between ROOT and NumPy

Home Page:http://scikit-hep.org/root_numpy

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Traverse and attempt to convert subbranches automatically?

ivukotic opened this issue · comments

Hi,

I am trying to read variables in standard ATLAS DxAOD file. While for most of them my code works, there are branches for which it does not.
One example is xAOD::EventAuxInfo collection. I ROOT browser I can simply click on it to display it.

With root_numpy I get:
/cvmfs/sft.cern.ch/lcg/releases/LCG_85/root_numpy/4.5.1/x86_64-slc6-gcc49-opt/lib/python2.7/site-packages/root_numpy-4.5.1-py2.7-linux-x86_64.egg/root_numpy/_tree.py:372: RootNumpyUnconvertibleWarning: cannot convert leaf 'EventInfoAux.' of branch 'EventInfoAux.' with type 'xAOD::EventAuxInfo_v1' (skipping)
cache_size)

Here the simple code to reproduce it:

import root_numpy
from rootpy.tree import Tree
from rootpy.io import root_open
fi='data15_13TeV/DAOD_EXOT2.08125809._000001.pool.root.1'
myfile = root_open(fi)

t = myfile.CollectionTree
print 'Events:', t.GetEntries()
evs = root_numpy.tree2array(t)

Let me know and I will provide input file too.

Ilija

Hi @ivukotic

root_numpy doesn't yet handle nested subbranches automatically (still on the TODO list). Instead I think you should be able to access the subbranches you want through TTree.Draw()-like expressions. Try evs = root_numpy.tree2array(t, branches=['EventInfoAux.runNumber']) (sorry don't have an AOD with me now to check)

Hi,
thanks for the quick response.
I tested and your suggestion does work. Until such time when nested subbranches are supported, would it be possible to skip subbranches and process simple branches?
In this case: simple branch would be: EventInfoAux.runNumber while subbranch would be: EventInfoAux.xAOD::AuxInfoBase. It does work for all the collections where there is no subbranches.

............................................................................
Branch :EventInfoAux. *
*Entries : 6752 : BranchElement (see below) *
*............................................................................

Br 2 :EventInfoAux.xAOD::AuxInfoBase : BASE *
*Entries : 6752 : Total Size= 529349 bytes File Size = 21915 *
*Baskets : 17 : Basket Size= 104448 bytes Compression= 24.12 *
*............................................................................

*Br 3 :EventInfoAux.runNumber : UInt_t *
*Entries : 6752 : Total Size= 29278 bytes File Size = 2124 *
*Baskets : 16 : Basket Size= 5120 bytes Compression= 13.46 *

Cheers,
Ilija

Right, currently though root_numpy scans over all the supported branches at the top level but does not traverse down to supported child branches. I've been wanting to have that implemented for some time now.

It is fair to say that nobody will work on this at this stage, especially that uproot is effectively replacing root_numpy. Closing.