Re: [ROOT] appending leaves to a branch

From: Rene Brun (Rene.Brun@cern.ch)
Date: Tue May 07 2002 - 08:50:23 MEST


Hi Martin,

Martin Turner wrote:
> 
> Hello! does anyone know the answers to the following:
> 
> 1) Open an existing root file containing a tree with a single branch in a
> completely different file to the one it was made(easy). Then add
> additional variables to this branch which are simple doubles and ints
> without overwriting the original branch. If this is possible, are the
> additional variables stored at the entry number where it finished last
> time or start from scratch.
> If (1) is impossible then I may fill the tree with dummy
> leaves so that I simply update vertically.

The solution is to use Tree Friends.
  See TTree::AddFriend
       http://root.cern.ch/root/htmldoc/TTree.html#TTree:AddFriend
  See example with $ROOTSYS/tutorials/tree3.C

> 2) Could someone give an example of how to append entry's to a tree.

  TFile *f = new TFile("myexistingfile.root","update");
  TTree *T = (TTree*)f->Get("myTree");
  T->SetBranchAddress(....

  your loop with
  T->Fill();

  T->Write();

Rene Brun

> 
> Thanks in advance
> Martin.



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:50:52 MET