Accessing leaves from branch


I am a novice in ROOT. I am using it for the first time, so my question may be naive.

I have a root file generated by Delphes. I can not access the branches and leaves in a tree. I set the command
$ TFile f=new TFile(“abc.root”,“read”);
$ .ls
$ TTree

This shows me list of all branches /leaves which are particles PT, momentums etc.

*Br 192 :Electron : Int_t Electron_ *
*Entries : 20000 : Total Size= 178247 bytes File Size = 37276 *
*Baskets : 46 : Basket Size= 64000 bytes Compression= 4.40 *

*Br 195 :Electron.PT : Float_t PT[Electron_] *
*Entries : 20000 : Total Size= 90018 bytes File Size = 15123 *
*Baskets : 46 : Basket Size= 4577 bytes Compression= 5.86 *

I want to access the PTs of the particles here. How can I do this ? I was trying with
It does not work. Any help/suggestions will be appreciated.
Saurabh Niyogi

Did you try use MakeClass? It’s create example of code that read some ROOT structures.


welcome to ROOT :slight_smile:

For your particular case, I suggest to have a look to these two notebooks:

  1. … /1/0.ipynb
  2. … /1/1.ipynb
    That show how to access a tree in C++ and Python respectively.
    To have more context, you can give a look to this course:
    In particular from slide 74 onwards of this presentation: … l_2015.pdf
    More in general, the website contains a special section dedicated to people who want to get started with ROOT:


Ok… Thanks a lot.