Home | News | Documentation | Download

Using PyROOT to read in a TTree without knowing tree name

Hi all:

I am trying to load in a root file using python and am having some trouble with accessing the trees in the file (I want my code to work in the general case where I don’t know the names of the trees in a file beforehand). I know that from the command line, GetListOfKeys() will return a list of TDirectoryFile objects for a given tree, but I can’t seem to come up with the command for PyROOT that will allow me to find the names of the TTrees inside the directory.

Hi,

You can also use GetListOfKeys on a TFile to get the objects that are stored inside that file, including the trees.

To find about the class of a given value, you can proceed as exemplified by this tutorial:
https://root.cern/doc/master/loopdir_8C.html

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.