How can i read the content of root file's tree?

There are the trees which labeled with whitespace in my root file. How can i refer to that trees in python programm?
I used the following construction:

myFile = ROOT.TFile.Open(“file.root”)
myTree = myFile.TreeName

_ROOT Version: 6.26/10
_Platform: pycharm community
Compiler: Not Provided

Hi @Fredrih ,

myFile.Get("tree name") should do the job. You can find the TFile documentation in our reference guide – all C++ methods can be called from Python as well.


Thanks a lot.
That trees cosist from values of axis X and axis Y. But program performed only information about size of branches, but not necessary information.

myfile = ROOT.TFile.Open(‘file.root’)
myTree = myfile.Get(“TreeName”)


Hi @Fredrih ,

TTree::Print outputs some general information about the TTree schema (which branches/columns are present, their type, size etc.). If you want to print the TTree contents you can use e.g. Scan instead.

Make sure to take a look at the relevant manual sections: Trees - ROOT , Dataframes - ROOT and the TTree tutorials at ROOT: Tree tutorials .


You are right. I’ve just forgot about Scan.

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