[ROOT] Problem to sum 3 large TTree

From: Andrei Daniel (daniel@suntimpx.jinr.ru)
Date: Thu Jun 08 2000 - 07:57:50 MEST


Hi Rooters!

After 3 ours of work program gave me the next message.
I used Alpha working under Digital Unix and 
ROOT version 2.23/12.
  
      Fatal in <CustomReAlloc2>: storage exhausted
aborting

I have 3 TFiles. Each file includes the same TTree created
from the different data. Now I want to sum these data and 
write result in the new TFile. What may be wrong or can be 
changed in the next part of code? Let me note that each TFile
can be read separately without errors. 
 
Thanks in advance.

Andrei

const int nx = 1408;
const int n  = nx * (nx + 1) / 2;
const int nz = 8192;

   TROOT sumofcubes ("sumofcubes","Sum Data of 3 Cubes");

   struct
   {
      unsigned short sbuf[nz];
   } buf1,buf2,buf3;
   struct
   {
      float fbuf[nz];
   } buf4;

   int i, n1, n2, ix, iy, iz;
   
   TFile *F1 = new TFile("a1.root", "read");
   TTree *Cube1 = (TTree*) F1->Get("Cube");
   Cube1->SetBranchAddress("Spectrum", buf1.sbuf);      

   TFile *F2 = new TFile("a2.root", "read");
   TTree *Cube2 = (TTree*) F2->Get("Cube");
   Cube2->SetBranchAddress("Spectrum", buf2.sbuf);

   TFile *F3 = new TFile("a3.root", "read");
   TTree *Cube3 = (TTree*) F3->Get("Cube");
   Cube3->SetBranchAddress("Spectrum", buf3.sbuf);      
   

   TFile *FOUT = new TFile("as.root","recreate");
   TTree *FCube = new TTree("FCube","SUM OF 3 Weeks");
   TBranch *Spectrum = FCube->Branch("Spectrum",buf4.fbuf,"fbuf[8192]/F");

   for(i = 0; i < n; ++i)
   {
      Cube1->GetEntry(i);
      Cube2->GetEntry(i);
      Cube3->GetEntry(i);

      for(iz = 0; iz < nz; ++iz)
      {
         buf4.fbuf[iz] = (float) buf1.sbuf[iz] 
                       + (float) buf2.sbuf[iz] 
                       + (float) buf3.sbuf[iz];
      }

      FCube->Fill();
   }

   FCube->Write();

   F1->Close();
   F2->Close();
   F3->Close();

   FOUT->Close();
}

----------------------------------------
Andrei Daniel
FLNR, JINR, Dubna 141980, Russia
Tel: (7-09621)64568  Fax: (7-09621)65083
daniel@cv.jinr.ru 



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