I can add a branch by defining an oldtree with oldbranches (using SetBranchAddress) and defining a newtree and newbranches (using the “Branch” member function). Then I can loop over all events and use GetEntry, and Fill() in the event loop.
I think this is the standard way of adding a branch to a TTree. (If I’m wrong, please let me know.)
My question is this: Why is it not possible (or is it?) to run CopyTree before the loop to get the same structure of the old tree, and then add the branch in the event loop using the method above. In the first way I have to define every input and output branch, in the CopyTree way, I would only have to define the branch I’m going to add.
When I try the later method, my script crashes, the former works fine.