Accessing leaves from branch

Hello,

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
t=(TTree*)f->Get(“Delphes”);
$t.Print()

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
t->SetBranchAddress(“Electron.PT”,PT[Electron_]);
It does not work. Any help/suggestions will be appreciated.
Thanks,
Saurabh Niyogi

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

Hi,

welcome to ROOT :slight_smile:

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

  1. nbviewer.ipython.org/urls/indico … /1/0.ipynb
  2. nbviewer.ipython.org/urls/indico … /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:
    indico.cern.ch/event/395198/
    In particular from slide 74 onwards of this presentation: indico.cern.ch/event/395198/att … l_2015.pdf
    More in general, the website contains a special section dedicated to people who want to get started with ROOT: root.cern.ch/getting-started

Cheers,
Danilo

Ok… Thanks a lot.

Regards,