Re: TClonesArray

From: Fons Rademakers <Fons.Rademakers_at_cern.ch>
Date: Fri, 3 Jul 2009 11:39:16 +0200


Of course you can use them! :-) I just forgot we implemented them a while back. That should also solve your problem, I guess, as now you know how to copy TClonesArrays in your copy ctor etc.

Cheers, Fons.

Roman Lietava wrote:
> Thank you, Fons.
> I am confused.
> What are the methods I found at:
> http://root.cern.ch/root/html/src/TClonesArray.cxx.html#gv6UBD
> which are called
> TClonesArray::TClonesArray(const TClonesArray& tc): TObjArray(tc)
> {
> // Copy ctor.
> ...
> }
> TClonesArray& TClonesArray::operator=(const TClonesArray& tc)
> {
> // Assignment operator.
> ...
> }
> ?
> Why I cannot use them ?
> Roman.
>
> On Thu, 2 Jul 2009, Fons Rademakers wrote:
>

>> Hi Roman,
>>
>>     as clonesarrays are generally large objects we don't have assignment 
>> and copy ctors for them. If you really want to copy or assign objects 
>> containing TClonesArrays, you will have to loop over these arrays yourself 
>> and copy the information. If you use a pointer to a clones array you can 
>> use the TObject::Clone() method:
>>
>> TClonesArray *b = (TClonesArray*)a->Clone()
>>
>> Cheers, Fons.
>>
>>
>>
>>  > Can you show me or point me to example how
>>  > to use TClonesArray in copy constructor and
>>  > in assignemnt operator, please?
>>  > Thanks,
>>  > Roman.
>>  >
>>  > E.g.:
>>  >
>>  > class item{
>>  > };
>>  >
>>  >
>>  > class myclass{
>>  > TClonesArray array; // array of item objects
>>  > } ;
>>  >
>>  > myclass::myclass(const myclass &class ){
>>  > }
>>  >
>>  > myclass& myclass::operator=(const myclass &class)
>>  > {
>>  >  if(this!=&class){
>>  >  }
>>  > }
>>
>>

>
-- 
Org:    CERN, European Laboratory for Particle Physics.
Mail:   1211 Geneve 23, Switzerland
E-Mail: Fons.Rademakers_at_cern.ch              Phone: +41 22 7679248
WWW:    http://fons.rademakers.org           Fax:   +41 22 7669640
Received on Fri Jul 03 2009 - 11:39:21 CEST

This archive was generated by hypermail 2.2.0 : Fri Jul 03 2009 - 17:50:02 CEST