Hi Rene, Thanks for the advice abot using a friend tree but maybe I should have mentioned I need to call TTree::MakeSelector(). I saw in rootalk a solution to the problem if I was using makeclass, which I assume would still work, but I also read that I could loop on two trees at the same time in the selector file. This sounds what I want, or is more efficient to just use your reply to Bernhard below? The two trees I am trying to join have the same structure. Martin. Hi Bernhard, Yes, this is possible. Assuming a TTree *T, on which you have generated the class via T->MakeClass("TC"); I assume that the first tree is in file tree1.root, the second in tree2.root or subdirectory of tree1.root. You can do root > .L TC.C root > TC t1; root > TFile f2("tree2.root"); root > TTree *tree2 = (TTree*)f2.Get("T"); root > TC *t2 = new TC(tree2); The file TC.C can be edited to include the declaration of extern TC *t2; In the loop, you can call t2->GetEntry(ientry); Rene Brun On Tue, 7 May 2002, Rene Brun wrote: > 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