Adding new branch to an exsiting tree in a Chain

Hi,

I am working with data samples (root files) which are divided into several files all with the same trees in them and I need to add a branch to one of these trees and to fill it. So far, I have found the procedure to add a branch to an exisiting tree (in a older forum entry):

[quote]You can add new data to an existing Tree:

  • open the file in “Update” mode
  • get the Tree from the file
  • set the branch(es) address
  • continue your fill loop
  • save the new Tree header mytree->Write()
  • close the file

This works OK if you simply want to add new entries.
If you want to add one or more branches, you can proceeed like above
for the first 3 steps, then

  • create your new branch
  • fill ONLY this branch, making sure that you have the same number of entries
    at the end in all your branches.
  • write the header, etc
    [/quote]

Is that possible to do the same exact procedure on a Chain? If so, how does it differ from the above?

Thanks!

Andrée

You have to loop on all the files of the chain , and for each apply the recipee above.
In general it is not a good idea to add new branches to an existing Tree in a file.
We recommend the use of TTree::AddFriend, ie
-Create a new file with a parallel Tree containing the new branch(es)
-declare this new Tree to be a friend of the main Tree

Rene