Re: ?: filling tree and filing

From: Rene Brun (Rene.Brun@cern.ch)
Date: Thu Feb 19 1998 - 09:54:05 MET


Dirk Meier wrote:
> 
> 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.
> 

When you close a Root file, all objects in memory associated
with this file are deleted. In your case, you should not close
the file or, if you close the file, you must reopen it and get
the Tree header in memory again.
Before closing a file containing a Tree, you must write the Tree
header on this file.
    file->cd(); // in case your current directory is not file
    tree->Write(); //this will write the Tree header

Look also at the discussion at URL:
  http://root.cern.ch/root/roottalk/roottalk98/0145.html

Rene Brun



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