Robert Casties wrote: > > Hello! > > Is there any scheme explaining which objects are stored by TFile::Write() > and which have to be written by the object's ->Write()? > > I (after quite some time) found that e.g. TH1's are written > automatically and TText's aren't. > > The TFile reference says on Write(): > [...] > *-* Loop on all objects in memory (including subdirectories) > *-* A new key is created in the KEYS linked list for each object > *-* The list of keys is then saved on the file (via WriteKeys) > *-* as a single data record > [...] > > What is meant by 'all objects' in this case? > TFile::Write() writes all the objects entered into the list of objects in memory associated with this file. Assume TFile *file: the file object has a list(TList) of objects that you can find at TList *list = file->GetList(); By default, TH1 objects and TTree objects are automatically inserted in this list when these objects are created. TFile::Write scans all the objects in this list and for each object executes obj->Write. You can insert your own objects in this list if you want with a statement like file->GetList()->Add(object); and your object will be automatically saved by TFile::Write. Note that this is only convenient for objects derived from TNamed, such as TH1, TTree, TF1. Rene Brun
This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:26:19 MET