[ROOT] TClonesArray object member vs pointer member

From: Christian Holm Christensen (cholm@hehi03.nbi.dk)
Date: Mon Jul 23 2001 - 17:27:55 MEST


Hi ROOT'ers, 

I'm experiencing something a bit odd.  I have a class Foo, not unlike
Event from the test directory, but with the difference that the
TClonesArray member is not a pointer but an object.  When I put this 
class on a branch, the objects (of class Bar) I put in the
TClonesArray is no longer visible in the TTreeViewer.  I can get them
out using a loop, but scanning, drawing, and so on gives nothing.  

I'm using a checkout of ROOT as of today on a Redhat 6.2 machine. 

I've read through the relevant documentation (TTree class
documentation; chapter 12 in the users guide) and searched for recent
mails on this on the roottalk archive.  However, I came up empty
handed. 

So my question is this: Is it really the intention that a TClonesArray
object member should behave differently from a TClonesArray object
pointer?  

I believe it makes sense to have a TClonesArray object rather than a
pointer, since one really doesn't wan't to delete the TClonesArray, so
you keep your "event" class and just clear it everytime you have a new
event. 

> I've attached a Tar-ball with a small example.  

Well, that failed, since the roottalk list server has an upper limit
of 40k characters (thanks Fons), so instead you can find it at 

  http://cholm.home.cern.ch/cholm/root/foobar-1.0.0.tar.gz  

(No links, so write the full address).

To try it out in different modes (using TBranch/TBronch and/or
object/pointer member), do: 

1) Unpack 

     gzip -dc foobar-1.0.0.tar.gz | tar -xvf - 

2) Try out using TBronch and a pointer member:

     ./configure --enable-reference --enable-bronch 
     make 
     ./foo 
     ./bar 

   This looks fine 

3) Try out using TBronch and an object member: 

     make clean 
     ./configure --disable-reference --enable-bronch 
     make 
     ./foo 
     ./bar 

   Does not look so good 

4) Try out using TBranch and an object member: 

     make clean 
     ./configure --disable-reference --disable-bronch 
     make 
     ./foo 
     ./bar 

   Looks terrible. 

5) Try out using TBranch and a pointer member: 

     make clean 
     ./configure --enable-reference --disable-bronch 
     make 
     ./foo 
     ./bar 

  Looks ok. 


BTW, this small example also shows how to use GNU Autotools with ROOT
for your project. 


Yours, 

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 01 2002 - 17:50:52 MET