Nested containers in root tree branch


Last time I tried to do this (5 years ago or so) it turned out to be a major head ache.
Nesting containers didn’t work in trees. What are the current limitations of nested structures as tree branches?

This question is indirectly related to Varint support and implementation



if you mean STL containers, they are fully supported by the ROOT I/O. In version 6.06 the support for the new unordered containers and forward_list has been introduced. The support for std::array and std::tuple will be present in the forthcoming ROOT 6.08.


Hi Danilo,

Thanks for the info. Here are some follow up questions:

[li]What is the status of the ROOT containers?[/li]
[li]Is there any reason to use a ROOT container over any stl? (TClonesArray might be the only thing that comes to mind).[/li]
[li]Has there been any profiling done for TClonesArray vs std::vector? In the nested case?[/li]
[li]TRef and TRefArray[/li][/ol]

It would be nice to have some general guidance on choosing a container.
[li]Should std::vector and std::map be the first choice?[/li]
[li]What if I want to use something like std::map<int, std::vector>?[/li]
[li]What if I want to use something like std::map<int, std::vector<MyClass*> >?[/li][/ul]


let me go through your questions:

  1. Do you mean the status in terms of nesting?
  2. STL and its various implementations evolved quite a lot during the years and so did its support in ROOT. In general, it does not make much sense to label ROOT or STL as “better” in absolute terms, for all use cases. In general, the “right” STL container is never a bad choice (“right” here is determined by what you need in terms of functionality from the container: do you need it contiguous in memory? Do you loop on it or randomly access it? Does it need to be ordered?)
  3. Profiling of what exactly? (De)Serialisation? I/O? Runtime behaviour when used in the context of a certain algorithm?
  4. What is exactly the question? :slight_smile:

About your three last points, I believe we addressed some of the aspects related to them above. Again, map and vector are damn good when they are needed: it depends what is the problem being solved - they cannot be labelled as “first choice” in any case I am afraid.
About the choice between “std::map<int, std::vector>” and “std::map<int, std::vector<MyClass*>>” both are supported by the ROOT I/O: what is the question you had about those?