Creating a 'symlink' inside a ROOT TFile

Is it possible to create something akin to a symlink inside a TFile? What I want is to have one object in the file but refer to it from multiple places in my structure of TDirectorys. I can sort of make this work by using a TRef but I heard these are dangerous?? At the very least they have the annoying behaviour that I have to load the object they refer to into memory before the TRef will point to the object.

Is there a better way?


I’ll let @pcanal comment on this

TRef is indeed an implementation of this kind of link.

You can automate the loading of the pointee using the “action on demand” described at ROOT: TRef Class Reference.

If the objects are in a TTree, calling TTree::BranchRef will also enable to automatic loading of the referenced branch. (See also TRefTable which is part of the implementation).

1 Like

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