Nesting in TTree/TClonesArray/TObjArray

From: Christian Holm Christensen (cholm@hehi03.nbi.dk)
Date: Thu Mar 09 2000 - 16:11:11 MET


Hi all, 

I'm currently trying to write event information from BRAHMS (both
GEANT and raw) into a ROOT TTree, and have come across some oddities,
at least to me they are. I know that the TTree class is described in
the HOWTOs, but none of them really address the question of nesting
(TClones/TObj)Arrays.  

Let me outline the data structure I'm trying to write:

  "Event #" BrEvent (simple data members)
    |
    +-"Header" BrEventHeader (simple data members + table)
    |   |
    |   \ "Trigger Words" BrTriggerWordTable  (a table)
    |       |
    |       < "Word" BrTriggerWord   (simple data members)
    |
    +-"FS" BrEventNode   (a table)
    |   |
    |   +-"FFS" BrEventNode (a table)
    |   |    |
    |   |    +- "Detector 1" (a table)
    |   |    |     |
    |   |    |     < "Data" (simple objects of class 1)
    |   |    |    
    |   |    +- "Detector 2" (a table)
    |   |    |     |
    |   |    |     < "Data" (simple objects of class 2)
    ...  

This gives a nesting level of 5. My original inclination was to have
something like:

  "Event #" (TTree)
    |
    +-"Header" (TBranch)
    |   |
    |   \ "TriggerWords" (TClonesArray)
    |       |
    |       < "Word" (class BrWord : public TObject)
    |
    +-"FS" (TBranch)
    |    |
    |    +-"FFS" (TClonesArray or perhaps a TBranch?)
    |    |   |
    |    |   +-"Detector 1" (TClonesArray)
    |    |   |   |
    |    |   |   < "Data" (class BrData1 : public TObject
    |    |   |
    |    |   +-"Detector 2" (TClonesArray)
    |    |   |   |
    |    |   |   < "Data" (class BrData2 : public TObject
    |    |   |
    ... 

But I guess it's still not possible to have a TBranch containg a
TClonesArray, that again contains a TClonesArray, and so on to any
desired depth? What is the rationale for this and is there any plans
for changing this? 

So I thought I could do something like: 

  "Event #" (TTree)
    |
    +-"Header" (TBranch)
    |   |
    |   \ "TriggerWords" (TClonesArray)
    |       |
    |       < "Word" (class BrWord : public TObject)
    |
    +-"FS" (TBranch)
    |    |
    |    +-"FFS" (TClonesArray)
    |    |   |
    |    |   +-"Detector 1" (TObjArray)
    |    |   |   |
    |    |   |   < "Data" (class BrData1 : public TObject
    |    |   |
    |    |   +-"Detector 2" (TObjArray)
    |    |   |   |
    |    |   |   < "Data" (class BrData2 : public TObject
    |    |   |
    ... 

But it seems that you can't store a TClonesArray of a class containing
a TObjArray. In fact, I believe you can't store a TClonesArray with
complex (classes, etc) members at all, at least not at that level. Is
this true? And again, if so, is there any plans to change this? Can
you at all store a TObjArray with nested TObjArrays or the like? 

I guess a solutuin would be to have 

  "Event #" (TTree)
    |
    +-"Header" (TBranch)
    |   |
    |   \ "TriggerWords" (TClonesArray)
    |       |
    |       < "Word" (class BrWord : public TObject)
    |
    +-"FFS" (TBranch)
    |   |
    |   +-"Detector 1" (TClonesArray)
    |   |   |
    |   |   < "Data" (class BrData1 : public TObject
    |   |
    |   +-"Detector 2" (TClonesArray)
    |   |   |
    |   |   < "Data" (class BrData2 : public TObject
    |   |
    ... 

But I'm not happy with that solution, as it means loss of data (the
fact that "FFS" is part of "FS"). 

Please let me know if you have any thoughts on this, and thanks for
your time. 

Cheers, 

Christian  -----------------------------------------------------------
Holm Christensen                             Phone:  (+45) 35 35 96 91 
  Sankt Hansgade 23, 1. th.                  Office: (+45) 353  25 305 
  DK-2200 Copenhagen N                       Web:    www.nbi.dk/~cholm    
  Denmark                                    Email:       cholm@nbi.dk



This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:21 MET