Re: Data Structure & TTree

Rene Brun (Rene.Brun@cern.ch)
Tue, 28 Apr 1998 16:32:14 +0200


Diego Casadei wrote:
>
> Hello Rooters!
> I would like to save my data with this structure:
>
> File: event 1 --> event 2 --> ... --> event N
> / | \
> / | \
> subdet1 subdet2 subdet3
> / | \
> / | \
> count1 count2 count3
>
> Is it possible to obtain it with a TTree structure?
>
> Thanks.
>
> PS. I know, I should understand it reading the online Root
> documentation, but I admit that it is not so easy for me...
>

Yes, this is a typical Tree structure.
Your class Event has data members subdet1, subdet2, etc.
subdet1,etc should be:
- either a pointer to an object (derived from TObject). In this case
Root will create one branch for this object.
- a TClonesArray (the best). In this case the TClonesArray
references objects from the same class (count). Root will create
one branch for each data member of the count class.
If you create an Object of class Event, eg:
Event *event = new Event();
you can create the corresponding TTree with
TFile f("myfile.root","recreate");
TTree T("T","title");
T.Branch("event","Event",&event);

Examples of Tree are given in
$ROOTSYS/test/Event
ATLFast

Rene Brun