[ROOT] how to add new branches ?

From: HP Wei (hp@rentec.com)
Date: Sat Dec 14 2002 - 02:08:21 MET


I want to create a big tree with many branches.
But I need to create one or several branches at a time.
After the following pseudo-code (for one branch at at time)
goes through i=0, then
it produces Segmentation Fault at i=1 at TBranch *br  statement.

What should I do?

---------------------------------------------
char sym[100];
char symType[100];
int N= 1000;
int M= 2000;

Open_root_file;
TTree * tree = new TTree("S", "");

for(int i=0; i<N; ++i) {
   double var;
   sprintf(sym, "field%d", i);
   sprintf(symType, "%s/D", sym);
   TBranch *br = tree->Branch(sym,  &var, symType); // Segmentation Fault
   
   for (int k=0; k<M; ++k) {
       var = 1.0;
       br.Fill();
   }
   
   br->Write();
   tree->Delete(sym);
}

tree->Write();
Save_the_root_file;

------------------------------------------------
Thanks,
HP



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