[ROOT] Adding one more element to a tree

From: GENTIT Francois-Xavier DAPNIA (GENTIT@dapnia.cea.fr)
Date: Tue Sep 03 2002 - 16:19:32 MEST


  Dear Rooters,
  What is the trick to add more elements to an already existing tree?
  To try to find it myself, I have taken the example "staff.C" in the
tutorials. I have split cernstaff.dat into cernstaff1.dat and
cernsatff2.dat, cernstaff1.dat being without the last element of
cernstaff.dat, and cernstaff2.dat containing only this last element.
  I have then run "staff.C", obtaining correctly a tree of 3353 elements.
  Then I have run a script "staff2.C", which is identical with staff.C,
except for these 3 lines:

   FILE *fp = fopen("cernstaff2.dat","r");

   TFile *f = new TFile("staff.root","UPDATE");     [instead of "RECREATE"]
   TTree *tree = (TTree *)f->Get("T");        [instead of new TTree]

  But instead of obtaining a tree with 3354 elements, I obtain 2 trees, the
first T;1 one with 3353 elements, and a second one, T;2 with 1 element!!

  Thanks for your help

François-Xavier Gentit
DAPNIA/SPP CEA Saclay
http://gentit.home.cern.ch/gentit/



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