How to add records in TFile

From: A.V. Daniel (daniel@nucax2.phy.vanderbilt.edu)
Date: Thu Mar 02 2000 - 17:32:56 MET


Hi Rooters,

Who can help me? I well know how to add new
records to the old file using C++ or fortran.
But how to do the similar using ROOT. I checked
the next code to write a simple TTree (Thanks
to Rene Brun who explained my error, it works now).
But I could not find description how to reopen
old file and to add new records in the same TTree.
May be it's very simple but I am not experience
with ROOT. Thanks in advance.

Andrei


void test2()
{
   int i,j;
   struct {
     unsigned short s_buf[8192];
   } cbuf;

   TFile *ff = new TFile("ff.dat", "NEW", "Test of root file");

   TTree *T = new TTree("T", "List of arrays");

   TBranch *B = T->Branch("B", &cbuf, "s_buf[8192]/s");

   for(i = 0; i < 10; ++i)
   {
      cbuf.s_buf[0] = i;
      cbuf.s_buf[100] = i+10;
      T->Fill();
   }

   T->Write();  // <=========== new line (From Rene Brun)
   T->MakeClass("test4");

   ff->Close();

}


-- 



*******************************************************
* Andrei V. Daniel
* Department of Physics & Astronomy, P.O. Box 1807-B 
* Vanderbilt University             Tel: (615) 322 2646
* Nashville, TN 37235, USA          Fax: (615) 343 7263
*******************************************************



This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:20 MET