?: filling tree and filing

From: Dirk Meier (Dirk.Meier@cern.ch)
Date: Thu Feb 19 1998 - 01:24:23 MET


hello,

In an executable program linked to root I'm filling 
a "TTree* fEventTree" with events and want to 
write the fEventTree to a "TFile* fEventFile". 
As soon as I close the file it seems that fEventTree is automatically
deleted. The fEventFile is created and correctly closed, but it does not
contain fEventTree data. Then Loading the file is possible, but looking
at the data gives a segmentaion fault. 

Here is the fEventTree before filling and then after filling.

************************************************************************************
*Tree    :T         : GroupData
*
*Entries :        0 : Total  Size =         0 bytes  File  Size =
0 bytes *
*        :          : Tree compression factor =   1.00
*
************************************************************************************
*Branch  :fEvent    : fEvent
*
*Entries :        0 : BranchObject (see below)
*
*..................................................................................*
*Branch  :fNplane   : fNplane
*
*Entries :        0 : Total  Size =         0 bytes  File Size  =
0 bytes *
*Baskets :        0 : Basket Size =     64000 bytes  Compression=   1.00
*
*..................................................................................*
*Branch  :fDummy    : fDummy
*
*Entries :        0 : Total  Size =         0 bytes  File Size  =
0 bytes *
*Baskets :        0 : Basket Size =     64000 bytes  Compression=   1.00
*
*..................................................................................*
*Branch  :fUniqueID : fUniqueID
*
*Entries :        0 : Total  Size =         0 bytes  File Size  =
0 bytes *
*Baskets :        0 : Basket Size =     64000 bytes  Compression=   1.00
*
*..................................................................................*
*Branch  :fBits     : fBits
*
*Entries :        0 : Total  Size =         0 bytes  File Size  =
0 bytes *
*Baskets :        0 : Basket Size =     64000 bytes  Compression=   1.00
*
*..................................................................................*


DSession, fEventTree is setup and will be filled with fEvent 

************************************************************************************
*Tree    :T         : GroupData
*
*Entries :      500 : Total  Size =         0 bytes  File  Size =
0 bytes *
*        :          : Tree compression factor =   1.00
*
************************************************************************************
*Branch  :fEvent    : fEvent
*
*Entries :      500 : BranchObject (see below)
*
*..................................................................................*
*Branch  :fNplane   : fNplane
*
*Entries :      500 : Total  Size =         0 bytes  File Size  =
0 bytes *
*Baskets :        0 : Basket Size =     64000 bytes  Compression=   1.00
*
*..................................................................................*
*Branch  :fDummy    : fDummy
*
*Entries :      500 : Total  Size =         0 bytes  File Size  =
0 bytes *
*Baskets :        0 : Basket Size =     64000 bytes  Compression=   1.00
*
*..................................................................................*
*Branch  :fUniqueID : fUniqueID
*
*Entries :      500 : Total  Size =         0 bytes  File Size  =
0 bytes *
*Baskets :        0 : Basket Size =     64000 bytes  Compression=   1.00
*
*..................................................................................*
*Branch  :fBits     : fBits
*
*Entries :      500 : Total  Size =         0 bytes  File Size  =
0 bytes *
*Baskets :        0 : Basket Size =     64000 bytes  Compression=   1.00
*
*..................................................................................*
DSession, fEventTree->Print() was correct 
DSession, now fFile->Close()
DSession, fEventTree->Print() will give segment fault 

 *** Break *** segmentation violation

( 0)  0xc0f17d40   StackTrace__11TUnixSystemFv + 0x28
[/afs/cern.ch/na49/library/local/ROOT/hpux10aCC/root/lib/libUnix.sl]
( 1)  0xc0f167f0   DispatchSignals__11TUnixSystemF8ESignals + 0xd0
[/afs/cern.ch/na49/library/local/ROOT/hpux10aCC/root/lib/libUnix.sl]
( 2)  0xc0f153a8   SigHandler__F8ESignals + 0x28
 
... and so on...




Here is the part of the code (nearly from root's wwwpage), 
which gave the above output:

void DSession::WarmStart(){
  // this is the initialization part

  // Create a new ROOT binary machine independent file.
  // Note that this file may contain any kind of ROOT objects, histograms,
  // pictures, graphics objects, detector geometries, tracks, events, etc..
  // This file is now becoming the current directory.
  Int_t   tCompressionLevel = 1;
  fFile = new TFile("GroupData.root","RECREATE","GroupDT");
  fFile->SetCompressionLevel(tCompressionLevel);
  fEvent = new DEvent();    // declared in DSession.h as DEvent* fEvent;
  fEventTree = new TTree("T","GroupData"); 
  // decleared in DSession.h as TTree* fEventTree;
    fEventTree->SetAutoSave(1000000);  // autosave when 1 Mbyte written
  Int_t  tBufSize    = 64000;
  Int_t  tSplitLevel = 1;
  fEventTree->Branch("fEvent", "DEvent", &fEvent, tBufSize, tSplitLevel);
  fEventTree->Print();
  printf("DSession, fEventTree is setup and will be filled with fEvent \n");
}

//______________________________________________________________________________
//  
void DSession::Loop(){
  // here load rawevents from a file and fill events which are put
  // into another file

  while(NextRawEvent() == kTRUE) {
       fEventTree->Fill();  // here the tree is filled
  }
  fEventTree->Print();
  printf("DSession, fEventTree->Print() was correct \n");
  printf("DSession, now fFile->Close()\n");
  fFile->Close();
  printf("DSession, fEventTree->Print() will give segment fault \n");
  fEventTree->Print();
}


The TFile GroupData.root is generated, but looking at it gives 
segment fault:

root [1] TFile *f("GroupData.root");
root [2] f.ls();

 *** Break *** segmentation violation

( 0)  0xc0f17d40   StackTrace__11TUnixSystemFv + 0x28
[/afs/cern.ch/na49/library/local/ROOT/hpux10aCC/root/lib/libUnix.sl]
( 1)  0xc0f167f0   DispatchSignals__11TUnixSystemF8ESignals + 0xd0
[/afs/cern.ch/na49/library/local/ROOT/hpux10a


thanks for any help

Dirk



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:34:30 MET