More info on CloneTree

Dear ROOTers,

I want to create several trees with the same branch structure.
My idea is creating a “dummy” empty tree with all the branches defined; then every time I need a “real” tree, I “clone” the empty tree to a new tree and start filling the “cloned” tree leaving empty the “dummy” one.

To make this “copy”, I could use the copy constructor or the method “CloneTree”, but I’m not sure to have understood the warning in the documentation of TTree::CloneTree().

It seems that the problem is in the branch addresses… but maybe if I save in a file any “cloned” tree before starting a new one, all should be ok… isn’t it?

Otherwise i could use the TObject::Clone() or TObject::Copy()…

Another question correlated to this is the following: in the case of TTree::CloneTree(), TTree’s copy constructor, TObject::Clone() or TObject::Copy() is the new object created dinamically or not? (i.e. I have to delete it manually, it still exists when the calling function returns, and so on…)

Thank you

Use TTree::cloneTree with argument nentries=0.
This will make a copy of the Tree header only, but still making the correct
initialisation of the branch addresses.