Hi all,
I having some trouble understanding TRef’s. I have a TTree where I loop over the events and try to apply some cuts on. The tree has branches with subbranches containing the actual information eg. branch Electron has a subbranch Electron.Phi that contains the phi values of the electrons in that specific event. I access the values with a TTreeReader and a TTreeReaderArray for each subbranch I need to apply a cut to.
However, one of the subbranches has as datatype TRef which, as I understand it, should point to a different object in the tree. Because of the problem background I know that the reference should be too a different branch called Particle which contains information on truth level of the objects in the other branches.
Here is an example snippet of how I go about it.
TTree *tree = nullptr;
_file0->GetObject("Delphes",tree);
TTreeReader reader(tree);
TTreeReaderArray<TRef> Electron_Ref(reader, "Electron.Particle");
TTreeReaderArray<Int_t>; Particle_PID(reader, "Particle.PID");
TTreeReaderArray<Int_t> Particle_Status(reader, "Particle.Status");
TTreeReaderArray<Int_t> Particle_M1(reader, "Particle.M1");
while (reader.Next()){
// Get the TRef object.
TRef refObj = Electron_Ref[0];
// Get the pointer of the object the TRef object is referencing to.
TObject * pObj = refObj.GetObject();
// Use this pointer to get the values from subbranches defined above.
}
Could someone help me? Please let me know if any of the above is unclear. Any advice would be very helpful!
Cheers
_ROOT Version: 6.14/06
_Platform: macOS
_Compiler: ROOT macro