STL container splitting in TTree construction

Dear all,

concerning ttree constructions available, I am considering the possibility to configure Branch using STL containers (mainly vector and array).

In case I have one of the following container:

  • vector container;
  • array <T,n> container;
    I compared cases of type ttree.branch(“branchname”, &container, “myVar[n]/T”) in which each row is provided with n data of type T, with the case of type ttree.branch(“branchname”, &container, “x1/T:x2/T … :xn/T”) in which each row is filled with n columns corresponding to n elements of container.

In addition I wanted to compare with a construction of the type: tree.Branch( branchname, STLcollection, buffsize, splitlevel);
If I write code like this: ttree.Branch(“branchname”, &container) it does not split and it is equal to ttree.branch(“branchname”, &container, “myVar[n]/T”). Here splitlevel = 1 by default. It does not change even if I try split>1

I would like to know how to perform splitting like ttree.branch(“branchname”, &container, “x1/T:x2/T … :xn/T”) with construction like tree.Branch( branchname, STLcollection, buffsize, splitlevel)

Thank you all in advance
Best Regards

Hi Patrizio,

Thanks for the post and welcome to the ROOT Community!

Why not writing your x_i’s in individual branches, which are then automatically split?


Thank you Danilo for your prompt response.
I understand the solution you propose.

My question was in fact to know more about the chance in splitting STL containers in ttrees.

I am wondering if a STL container can be split only by means of dictionary generation of the object like in the TObject derived class case.

In addition I am asking the meaning of the “splitlevel” parameter: through examples I cannot exactly understand if it means the amount of columns from a given TObject or STL container or if it means a nesting level of the quantity per se.

Thank you again and best regards

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