[ROOT] Classes derived from TFile or TFolder?

From: cstrato@EUnet.at
Date: Fri Jan 05 2001 - 16:20:16 MET


Dear Rooters

I would like to create a Class B which stores a list of trees, and a
Class A,
which stores a list of Class B and another list of histograms.

In this respect I have the following questions on how to deal best with
this problem:

1, I understand that TFile is stored in machine independent format,
which is great.
This means that everything in TFile can be accessed independent of the
machine type,
including class TFolder when it is stored in TFile.
Could I also use TFolder as the highest hierarchy and store different
TFiles and
histograms in TFolder? Are histograms then accessible from different
machines or
do I still need to store historgrams in TFile first, which is itself
stored in
TFolder to access the histograms?

2, Can I create class A in the following way?
ClassA: public TNamed {
   private
      TFile *fFile;
      TFolder *fFolder;
};
How can I store this class A itself in its member variable fFile or
fFolder?
Is this possible?

I would like to be able to write a simple macro
{
   ClassA *classA = new Class("NameA");
   classA->DoSomething();
}
Is it possible to code the constructor such that it opens its TFile
*fFile when it
exists and then accesses the information stored in itself, i.e. the
classA stored
earlier in fFile?

3, Would it be better to create class A in one of the following ways?
a,ClassA: public TFile {
   private
      TFolder *fFolder;
}
Would ClassA then also be machine independent?
Would this be a feasible idea?

b,ClassA: public TFolder {
   private
      TFile *fFile;
}

4, TFolder has a function TFolder::Add(TObject *obj) and the explanation
says
that "obj must be a TObject or a TFolder"
a, Does this also include classes derived from TObject such as TFile,
histograms?
b, The code of Add() is fFolders->Add(obj), however, fFolders is
TCollection, which
is an abstract base class with TCollection::Add() = 0. Does this mean
that in  the
constructor TFolder() I have to define the type of collection I want to
use?

5, Can I somewhere find a simple code fragment how to use TFolder class?

6, Is there a better way to deal with the problem described at the
beginning?
Probably, the simplest way would be to create a TFile and store the
trees and
histograms in different subdirectories. However, this is not sufficient
for me
since both ClassA and ClassB will contain additional variables and
member functions.

Thank you in advance

Best regards
Christian Stratowa
Vienna, Austria



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