Re: [ROOT] Branches with objects and tree friends

From: cstrato (cstrato@aon.at)
Date: Tue Apr 27 2004 - 21:45:40 MEST


Dear Philippe

Thank you for your explanation. The reason why I am asking is
that I have a couple of simple objects like MyData, which
represent my data to be stored in different branches of a tree.
However, when I store 100,000 entries in this way in many trees
there is a huge memory overhead because of the inherited object
members fUniqueID and fBits, which are then stored 100,000 times
with each branch.
Is this correct, or does compression level=1 eliminate this
overhead?

Best regards
Christian

Philippe Canal wrote:
> Hi Christian,
> 
> Saving any objects in a TTree requires that you have a compiled version of the class.  We do not support the case where the class in interpreted.  Hence your
> macro can only work when compiled with ACLiC.
> 
> The advantage is derived from TObject is that you inherit some of the tools provided by the TObject interface (like Dump).  You also can store them 
> in ROOT Collection (in particular only TObjects can be stored in TClonesArray).
> 
> 
>>a, Interestingly, only the first call to CreateTrees() gives an
>>error message, but not the second call.
> 
> 
> Because the error message is issed at the time of the creation of
> the TClass object describing your class (hence only once).
> 
> 
>>b, It is not clear to me why CINT can only set the first two
>>branch addresses and than crashes?
> 
> 
> There are missing protection in this case.  We will try to improve
> the situation.
> 
> Cheers,
> Philippe.
> 
> 
> -----Original Message-----
> From: owner-roottalk@pcroot.cern.ch
> [mailto:owner-roottalk@pcroot.cern.ch]On Behalf Of cstrato
> Sent: Sunday, April 25, 2004 7:54 AM
> To: roottalk@pcroot.cern.ch
> Subject: [ROOT] Branches with objects and tree friends
> 
> 
> Dear Rooters
> 
> 1) First, I have a question regarding branches with objects, e.g.
>     tree->Branch("MyBranch", "MyData", &data, 64000, 99);
> 
> where MyData is defined as:
> 
> class MyData {
> //class MyData: public TObject {
>     protected:
>        Int_t    fID;
>        Double_t fX;
>     public:
>        MyData() {}
>        virtual ~MyData() {}
> };
> 
> With the old branch style, MyData must derive from TObject, but
> this is no longer necessary. My question is:
> Are there still advantages to derive MyClass from TObject?
> Under which circumstances would you derive an object from TObject?
> 
> 2) The enclosed macro "macroFriends.C" works fine when compiled
> with ACLiC, but with CINT I get the following output:
> root [0] .x macroFriends.C
> ------MyClass::MyClass------
> ------MyClass::CreateTrees------
> Error in <TClass::BuildRealData>: can not find any ShowMembers function 
> for MyData!
> ------MyClass::CreateTrees------
> ------MyClass::AddTree------
> ------MyClass::AddTree------
> ------MyClass::AddTree------
> ------MyClass::AddTree------
> ------MyClass::AddTree------
> ------MyClass::AddTree------
> ------MyClass::AddTree------
> ------MyClass::AddTree------
> ------MyClass::CopyTrees1------
> nfriends(fTree) = 7
> nentries(fTree) = 100
> treej[0] = TreeX0
> treej[1] = TreeX1
> treej[2] = TreeX2
> 
>   *** Break *** bus error
> Root > Function macroFriends() busy flag cleared
> Function CopyTrees1() busy flag cleared
> 
> a, Interestingly, only the first call to CreateTrees() gives an
> error message, but not the second call.
> 
> b, It is not clear to me why CINT can only set the first two
> branch addresses and than crashes?
> 
> My system: root 4.00/03 from 26 March 2004 on MacOS X 10.3.1
> 
> Thank you in advance for your help.
> 
> 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 : Sun Jan 02 2005 - 05:50:07 MET