Reading a TTree with multiple branches

Dear experts,
I have produced a Monte Carlo simulation of events, the output of the generator was a HepMC format, and I converted it into a .root file through the Delphes software, in order to be able to analyze it with ROOT.
The .root file contains a TTree with two branches: “Event”, wih leaves dealing with event properties, and “Particle”, with leaves corresponding to properties of the particles generated in the events.
In the attachment below you can find an example .root file of this kind with just 50 events and about 35k particles.
Though I worked with TTrees in the part, I always used one-branch trees, and I never encountered such structure.

My question is whether it is possible, from such TTree, to get access to the particles of a given event only (the goal would be to loop over the events, and for each event loop over the particles to perform an event-by-event analysis). In case this is possible, could you suggest me how to perform this operation?

TestTreeFromHepMC_50ev.root (1.6 MB)

Thanks in advance,
Fabio

search: HepMC
search: Delphes

TDataFrame Class Reference + Data Frame tutorials

Thanks a lot for the reference, I was indeed able to do what I needed by exploiting the TTree::MakeClass functionality.
I admit that, though finding the other thread by searching in older topics, I had failed to understand that this was the solution.
Fabio

Hi,
see also this answer for an overview of all the different ways you can read variables from TTrees. The thread also has some code snippets.

TTree::MakeClass might be an overkill or precisely what you need, depending on what actual application.

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