1

I have two root files, and am using uproot 3.12 right now.

td = uproot.open("data.root")
tc = uproot.open("cuts.root")

tc contains a few TEntryLists that provide selected events for td. Using uproot I can load tc and can see the event-lists. The methods available

tc.read
tc.classname

I do not know how to use these, and it does not seem to be documented... Since uproot uses numpy, I would expect somehow to get a bool array or index array to apply as a cut or to iterate over.

a = tc["EventList"]
a.read

returns

<bound method ROOTObject.read of <class 'uproot.rootio.TEntryList'>>

And

a.read()

returns

TypeError: read() missing 4 required positional arguments: 'source', 'cursor', 'context', and 'parent'

The following attributes are available to a TEntryList, but none seem to be an array of bools or indices that I can use to apply the event list to the tree. _fN returns a reasonable number of entries, _fFileName points to the correct file, _fTreeName is right...

a = tc["EventList"]
dir(a)

returns

 '_bases',
 '_classname',
 '_classversion',
 '_copycontext',
 '_fBlocks',
 '_fEntriesToProcess',
 '_fFileName',
 '_fLists',
 '_fN',
 '_fNBlocks',
 '_fName',
 '_fReapply',
 '_fTitle',
 '_fTreeName',
 '_fields',
 '_format1',
 '_format2',
 '_format3',
 '_hasreadobjany',
 '_int32',
 '_members',
 '_methods',
 '_postprocess',
 '_pycode',
 '_readinto',
 '_recarray',
 '_recarray_dtype',
 '_versions',
 'classname',
 'read'
bungernut
  • 43
  • 5
  • always put full error message (starting at word "Traceback") in question (not comment) as text (not screenshot). There are other useful information. – furas Sep 02 '20 at 03:04
  • find documentation for `read()` in this module - and check how to use `read()`. If it use `numpy` then maybe search in numpy documentation. Error shows you that it needs some values and you can't use it without arguments. – furas Sep 02 '20 at 03:05
  • did you try `help(tc.read)` ? it may display some information if it has docstrings in code. You can also use `uproot.__file__` to find file with source code and check `read()` in source code. – furas Sep 02 '20 at 03:08
  • In this case, the object has already been read (because it exists), so there's no reason to call that method again. This is Uproot 3; in which the data you're looking for is in attributes whose names start with "`_f`" (because they're private C++ members and this auto-generated class doesn't have any high-level accessors in Python). In Uproot 4, they're in properties named `members` and `all_members`, and can be accessed with a method named `member`—acknowledging that these can be a high-level interface, and have to be if the class has no specific behaviors defined, like this one. – Jim Pivarski Sep 02 '20 at 03:10
  • @furas here is help, but no context on what these 4 parameters are. ```Help on method read in module uproot.rootio: read(source, cursor, context, parent) method of builtins.type instance``` @JimPivarski thats a good hint, thanks – bungernut Sep 02 '20 at 03:16
  • 1
    The documentation for Uproot 3 is in https://uproot.readthedocs.io/en/latest/ . The documentation for Uproot 4 (including the `__doc__` strings that `help` accesses) are being written right now (open pull request, half done). I don't think the Uproot 3 documentation addresses `read` because you can't even get an object without it having been read first, and all of the classes that reflect C++ classes like TEntryList are generated just before reading. The Uproot 4 documentation will cover every function that doesn't start with an underscore, regardless of whether it's accessible to users. – Jim Pivarski Sep 02 '20 at 03:18
  • @JimPivarski I added all the `_f*` attributes to the question, and checked them for a useful array or iterator or anything. I do not see anything on TEntryLists in the documentation. – bungernut Sep 02 '20 at 03:40
  • There is no documentation on TEntryLists (in Uproots 3 or 4) because C++ classes like this are discovered and a corresponding Python class is auto-generated based on data in the ROOT file. Basically, Uproot doesn't know anything about the class (there are thousands of classes like this in ROOT), but it can take all the data from the ROOT file's streamer data and pass it on to you. `_fLists` sounds promising. The nice thing about Uproot 4 isolating them in `all_members` is that they don't get mixed with Uproot's internal infrastructure, such as `_pycode`. – Jim Pivarski Sep 02 '20 at 13:41

0 Answers0