# Vector of TTrees

Hello,

am I correct in saying that it isn’t possible to define a vector of TTree types? Something like this:

If so, how can I achieve the same result (that is, looping over a number of different Trees)?

Thank you, and sorry if the question is silly/badly expressed.

std::vector (like the rest of C++) makes copies by default, so if you tried to push_back a TTree into a std::vector, it’d try to make a copy of the whole tree, which is probably not what you want.

The semi-ROOTish way would be to make an std::vector<TTree *> with pointers to the trees. The ROOTish way would be to use a TChain or a TObjArray, I think.

Jean-François

Thank you Jean-François,
I think TObjectArray is just what I need. I will give it a try and let you know.

MB

Thanks again, that was what I needed!