Issue extracting data from nested TBranchElement

Hi Everyone,

I am trying to extract data from a ROOT file and I am unable to retrieve the data contained in the leaves of one of the subbranches. For reference, here is screen shot of the TBrowser output of the branch/leaf structure of the Events tree:

Specifically, I need to extract the data in the leaves contained on the p4Polar_ branch, which is nested in the following structure of the Events tree:


Here is an example of my current code in Python:

file_name = 'C89598B9-A372-9643-AB96-A5B71DED9151.root'
file = ROOT.TFile.Open(file_name, "READ")
tree = file.Events
reco_gen = tree.GetBranch("recoGenParticles_genParticles__HLT.obj") 

(The main branch,recoGenParticles_genParticles__HLT, cannot be accessed using tree.GetBranch("recoGenParticles_genParticles__HLT"), but the above code works.) When printing the reco_gen branch, I receive the following output:

*Br    2 :recoGenParticles_genParticles__HLT.obj : vector<reco::GenParticle> *
*Entries :9800 : Total  Size= 2676780697 bytes  File Size  = 237433712 *
*Baskets :     3985 : Basket Size=     822272 bytes  Compression=  11.27     *

Through trying different solutions of extracting the data, I’ve determined that the reco_gen branch is an instance of the TBranchElement class, so I can’t use GetEntries() in a for loop to iterate through the data.

I’m unsure how to access the data in the leaves on the recoGenParticles_genParticles__HLT./recoGenParticles_genParticles__HLT.obj/m_state/p4Polar_ branch. Any information or suggestions are greatly appreciated. Please let me know if you need any more information or have any questions.

Thank you,


ROOT Version: 6.30/02
Platform: macOS 11.7.10
Compiler: Apple clang version 13.0.0 (clang-1300.0.29.30)

Hi @sbutalla,
thank you for posting on the ROOT forum!
Have you tried to access the leaf with .Get, i.e. file.Get('path/to/leaf')?