Access to MC info of detector hits files using MCKinematicsReader


I am trying to get access to the MC info (MC track, pdg code of the particle, etc) of detector hits files produced by o2sim like o2sim_HitsITS.root

The tree in this file is a collection of o2::itsmft::Hit arrays. The structure has a TrackID element, however if I am not mistaken, this is not enough to identify the MC track that made the hit: the MCKinematicsReader asks for the eventID on top of the trackID to return the corresponding MC track with the information I am seeking.

How can I get the MC track information associated to a detector hit with this incomplete label?


The event ID is needed on top. In this case it’s implicitly given by the entry ID of the branch.

Do you mean the entry ID of the “ITSHit” branch? How do I access this entry ID? (a quick search of ID, identifier, and other keywords I could think of in the root user manual has not been successful, neither has a quick look at the TBranch class reference).

Well, assuming that your hits are held in branch variable hitbranch, you can determine the number of available events with hitbranch->GetEntries() and ask for the hits of event i with hitbranch->GetEntry(i). This i is then your eventID.
So you would certainly need to write some piece of code. It is not possible just in the TBrowser.

Thanks a lot!