[ROOT] Re: writing trees ...

From: Anton Fokin (anton.fokin@smartquant.com)
Date: Sun Mar 04 2001 - 18:02:37 MET


OK, maybe. My questions arise from my observatons. I have two functions, one
is to save trees and another to close files (each tree is written in a
separate file).

Save()

      while (TTreeEntry* TreeEntry = (TTreeEntry*) next())
        TreeEntry->GetTree()->AutoSave();

Close()

      while (TTreeEntry* TreeEntry = (TTreeEntry*) next())
        TreeEntry->GetFile()->Close();

If I do

Save()
Close()

Save takes quite a long time to write about 1.000 trees and this I can
understand. But Close takes the same time, like 10 minutes on Inspiron5000,
650MhZ. I do not have any other operations like File.Write() inbetween.

Can you comment Close() behavior? Does it write lists of keys during 10
minutes? Why does it need to do so if all the info is already saved?

Regards,
Anton


http://www.smartquant.com


----- Original Message -----
From: Rene Brun <brun@pcbrun.cern.ch>
To: Anton Fokin <anton.fokin@smartquant.com>
Cc: roottalk <roottalk@pcroot.cern.ch>; Rene Brun <Rene.Brun@cern.ch>
Sent: Sunday, March 04, 2001 4:11 PM
Subject: Re: writing trees ...


> Anton,
>
>
> On Sun, 4 Mar 2001, Anton Fokin wrote:
>
> > Rene,
> >
> > It says that THx and TTree objects are added to the current directory
list
> > of keys and saved automatically on directory close. As far as I can
trace
> > down TFile::Close() I see
> >
> > TDirecory::SaveSelf()
> >
> > which will save Tree header if it belongs to this file/directory. Am I
> > wrong?
>
> yes, you are. When you do obj.Write(), the object is written to the file
> and a key added to the list of keys of the current directory.
> When you do file.Write(), all objects in memory in gDirectory->GetList()
> are written to the file and for each a key added to the list of keys.
> When you close the file with file.Close(), only the list of keys is
> written as one single record.
>
> Rene Brun
>
> >
> > Regards,
> > Anton
> >
> > http://www.smartquant.com
> >
> >
> > ----- Original Message -----
> > From: Rene Brun <brun@pcbrun.cern.ch>
> > To: Anton Fokin <anton.fokin@smartquant.com>
> > Cc: roottalk <roottalk@pcroot.cern.ch>; Rene Brun <Rene.Brun@cern.ch>
> > Sent: Sunday, March 04, 2001 10:30 AM
> > Subject: Re: writing trees ...
> >
> >
> > > Anton,
> > > File.Close does not write the Tree header to the file. May be you
> > > mean File.Write ?
> > > There are two ways to AutoSave Trees in a file.
> > >  - User calls TTree::Autosave
> > >  - TTree::SetAutoSave(nbytes) has been called. In this case, teh Tree
> > >    header/buffers are only saved (by calling TTree::AutoSave) when
> > >    more than nbytes have been written to the file since the previous
> > >    AutoSave.
> > > When calling SetAutoSave or AutoSave, you get 2 different copies
> > > of the Tree header on the file. You can keep one copy only.
> > > At the end of your job, instead of calling File.Write(),
> > > do tree.Write(0,TObject::kOverwrite)
> > >
> > > Rene Brun
> > >
> > >
> > > On Sat, 3 Mar 2001, Anton Fokin wrote:
> > >
> > > > Hi Rene,
> > > >
> > > > if I do
> > > >
> > > > TFile File(..);
> > > >
> > > > TTree *Tree = new TTree(..);
> > > >
> > > > Tree->AutoSave();
> > > >
> > > > File.Close();
> > > >
> > > > it looks like root writes the tree twice: on AutoSave and on
> > File.Close().
> > > > Am I right?
> > > >
> > > > If so, could you prvide a check so that only modified tree will be
> > written
> > > > on AutoSave() and File.Close() ?
> > > >
> > > > Regards,
> > > > Anton
> > > >
> > > > http://www.smartquant.com
> > > >
> > > >
> > > >
> > >
> > >
> > >
> >
>
>
>



This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:38 MET