I have existing files each with a tree inside which has a lot of (about 1000) branches. My problem is that I want to add some branches to that existing tree and save it to a new file and for some branches I also want to exchange the contents. Is there a solution apart from reading all the leaves individually and write them to a new tree? I was thinking about an equivalent to the MakeClass(…) method but with additional writing capability. Or is the correct way to have a friend with the new branches? But how do I exchange the contents of existing branches…
[quote] Or is the correct way to have a friend with the new branches?[/quote]This has the advantages of ‘keeping’ the history of the ‘replaced’ branches. If you make the 2nd generation TTree be the on to which you attach the original Tree as a friend then branch name lookup with use the ‘new’ tree first (i.e. hide the branch from the old tree).
[quote]Is there a solution apart from reading all the leaves individually and write them to a new tree?[/quote]Literally the answer is no, however the method TTree::CloneTree makes it very easy. See $ROOTSYS/tutorials/tree/copytree*C for examples.