[ROOT] TFolder or TDirectory?

From: cstrato@EUnet.at
Date: Sun Jan 06 2002 - 18:27:36 MET


Dear Rooters!

Maybe you can give me some advice whether to use TFolder or TDirectory
when storing large amounts of TObjects in a TFile.

As an example of the dimensions of the project, let me present a
hypothetical project, namely to store data of all CERN employees in
one root file TFile:

For every person I create one folder/directory, which should store at
least two objects, called TPerson and TWorkPackage:
1, class TPerson: public TNamed {
              fFirstName, fLastName, fAge, fGender, fAddress, etc
   }
2, class TWorkPackage: public TNamed {
              fCollaboration, fTask, etc
   }

Now I want to create a TFile with the following hierarchy:
TFile("CERN.root"):
      Departments
            Department_1
                  Group_D1
                         SubGroup_D1a
                         SubGroup_D1b
                         etc
                  Group_D2
                         SubGroup_D2a
                         SubGroup_D2b
                         etc
            Department_2
                  Group_D3
                  etc
            etc
      Collaborations
            Collaboration_1  //e.g. ALICE
                  Group_C1
                         SubGroup_C1a
                         etc
                  Group_C2
            Collaboration_2  //e.g. LHCb
                  Group_C1
                  etc
            etc
      Employees

I want to store every employee in the subgroup of his/her department,
and references to the employee in Collaboration(s) and in Employees.

At the moment I see three possibilities how to achieve this:
1, use TFolder only
2, use TDirectory only
3, use TDirectory and TFolder

1, TFolder only:
Advantages:
It is very easy to create a TFolder hierarchy and to store TObjects
The TFolder hierarchy can be converted to TTree, which should make
finding data easy.
Problems:
How can I add/delete subfolders or change their content at a later
time and store these subfolders in TFile?
It seems that I have always to write the RootFolder to TFile:
fRootFolder->Write("",TObject::kOverwrite),
since it is not possible to write only the subfolder to TFile?
If I assume 10,000 employees, then this means writing more than
20,000 TFolders to TFile every time. If something happens during
writing, I could loose all data.
Is the complete folder hierarchy with all objects read into RAM?

2, TDirectory only:
Advantages:
It is possible to add/delete/change TDirectory at any time, and
only write the subdirectory of choice to TFile.
Problems:
Does it make sense to create more than 20,000 TDirectories?
What is the overhead?
 How time-intensive is finding an object using the new function
 TDirectory::FindObjectAny()?

3, Mixture of TDirectory and TFolder:
The main hierarchies Departments, Department_1, Collaborations,
Collaboration_1, Employees would be created as TDirectory.
The subhierarchies Group and SubGroup would be created as TFolder.
This is the approach I am currently trying to implement,
although I needed to inherit TMyFolder from TFolder for this
purpose.
Does this approach make sense or is there a better way?

It would be great if I would receive suggestions, how to handle
this task best.

Thank you in advance

Best regards
Christian
----------------------------------
C.h.r.i.s.t.i.a.n  S.t.r.a.t.o.w.a
V.i.e.n.n.a,  A.u.s.t.r.i.a



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:50:37 MET