RE: [ROOT] TClonesArray

From: Philippe Canal (pcanal@fnal.gov)
Date: Fri Dec 24 2004 - 06:27:05 MET


> (i.e. if not implemented in a macro and interpreted by CINT as with .x) .

They are limitation in having interpreted class inherit from a compiled
class.  In particular the virtual table is not correctly updated.  Since
object that goes into a TClonesArray have to be from a class inheriting from
TObject, I suppose this was your problem.

Cheers,
Philippe.

-----Original Message-----
From: tommaso chiarusi [mailto:Tommaso.Chiarusi@bo.infn.it] 
Sent: Wednesday, December 22, 2004 5:02 AM
To: Philippe Canal
Cc: 'Root Newsgroup'
Subject: RE: [ROOT] TClonesArray

Dear Philippe,

I managed to solve my problem in a very simple way:
I create a stand alone program, implementing the class which was using the
TClonesArray in a compiled shared object.

I mean that, without changing a line, the same code does work if compiled
and used out from the ROOT working frame (i.e. if not implemented in a macro
and interpreted by CINT as with .x) .

I still not understand why... but many things happens as ROOT is executing.
Maybe some crossover of memory which I could not manage.

btw, thanks a lot!
Tommaso




On Fri, 17 Dec 2004, Philippe Canal wrote:

> Hi Tommaso,
> 
> From your description it is not clear what is going wrong.
> The first thing you should try is to replace v->UncheckedAt by v->At 
> to make sure you are really reading allocated memory.
> 
> Now there is no technical different between (strictly speaking):
> 	TClonesArray *v =  p.GettArray();
> And
> 	TClonesArray *v;
>         v =  p.GettArray();
> The difference I guess in that between the last 2 lines you have many 
> other thing going-on that may or may not affect the result (like going 
> out-of-scope, other unrelated memory over-write, etc.).
> 
> The simpliest is for you to send a very small, complete example that 
> reproduces the problem.
> 
> Cheers,
> Philippe.
> 
> -----Original Message-----
> From: owner-roottalk@pcroot.cern.ch 
> [mailto:owner-roottalk@pcroot.cern.ch]
> On Behalf Of tommaso chiarusi
> Sent: Friday, December 17, 2004 7:42 AM
> To: Root Newsgroup
> Subject: [ROOT] TClonesArray
> 
> Dear Rooters,
> Should it be stange the following?
> 
> You have a member function GetArray() which yields a pointer to 
> TClonesArray.
> 
> so, in the scope of some methods:
> 
> 	TClonesArray *v =  p.GettArray();
> 	Evento &te = *((Evento*) v->UncheckedAt(cont));
> 
> 
> It's Ok and the Evento-memory segment does exist and it is filled with 
> right things. While...
> 
> 	TClonesArray *v;
> 	v =  p.GettArray();
> 	Evento &te = *((Evento*) v->UncheckedAt(cont));
> 
> It ISN'T ok, and the Evento-memory segment is completely random.
> 
> 
> 
> What's happening?
> 
> I need to use the second case, since the TClonesArray pointer v should 
> be a private data member of a class.
> In particular I should organize such stuff as the following:
> 
> 	TClonesArray *v;  -> IN THE PRIVATE DATA MEMBER DECLARATION SCOPE
> 
> 	v =  p.GettArray(); -> IN THE CLASS CONSTRUCTOR DEFINITION
> 
> 	Evento &te = *((Evento*) v->UncheckedAt(cont)); IN A MEMBER FUNCTION
>  
> 
> Maybe I'm forgetting some stupid rule.... 
> Thanks a lot,
> 
> Tommaso.
> 
> P.S.
> 
> System
> 
> ROOT:  Version   4.00/08       9 July 2004
> OS: Linux RH-9
> gcc version 3.2.2 20030222 (Red Hat Linux 3.2.2-5)
> 
> 
> 
> --
> -----------------------
> 
> Dr. Tommaso Chiarusi
> 
> Dipartimento di Fisica
> Universita' di Bologna
> INFN. Sez. Bologna
> 
> Tel +39.051.209.5234
> Fax +39.051.209.5269
> 
> -----------------------
> 
> 
> 

--
-----------------------

Dr. Tommaso Chiarusi 

Dipartimento di Fisica
Universita' di Bologna
INFN. Sez. Bologna

Tel +39.051.209.5234
Fax +39.051.209.5269

-----------------------



This archive was generated by hypermail 2b29 : Sun Jan 02 2005 - 05:50:10 MET