For historical reasons, some of ROOT’s interfaces use ROOT’s own collection types such as
You (and modern ROOT code) should use
std::vector etc from the C++ Standard Library; ROOT supports these fully.
The following describes how you can access the elements in case an interface returns a ROOT collection type such as
Iteration and Element Access
ROOT collections hold pointers to
I.e. to store an object in a ROOT collection, it must inherit from
ROOT collections return pointers to
TObject; those pointers have to be cast back to the correct subclass.
You can think of a
TList as a
Element retrieval through
TObject* is often not useful;
for instance with
TTree::GetListOfBranches() you know that the elements are of type
For this purpose, ROOT offers a tool specific for range-based for loops: TRangeDynCast.