I would like to make a friend tree containing a custom class of composite particles where that class has a TRefArray to the particles in the original ntuple Tree.
When i tried to do this, reading back the friend tree, the TRef pointers are NULL, however filling and using the class right away works fine.
Is this possible to do this or could i be missing something to allow TRef in a friend tree to point to the original tree ?
Yes it is possible, however (even when you call TTree::BranchRef) there is no way for the TTree(s) to auto-read the branch containing the referenced objects. You will need to make sure to read explicitly the branch where the referenced objects have been stored.
[quote]Warning in TBufferFile::ReadBuffer: The file was written during several processes with an older ROOT version; the TRefTable entries might be inconsistent.[/quote]The problem might be here (i.e. file might not be able to handle it).
Also note that if the referenced object have not been referenced as the time they were written, any subsequent TRef will be ineffective (For performance reasons an object is given an ‘id’ (necessary for TRef to find them) if and only if a TRef points to them … and we do not (can not) update an existing TTree). If you are in this situation, you will have to go through cloning the input/original TTree so that the referenced object can be saved with an ‘id’.