Re: [ROOT] TClonesArray::Add?? question

From: Rene Brun (Rene.Brun@cern.ch)
Date: Wed Aug 13 2003 - 19:04:40 MEST


Hi,

As reported by the MayNotUse function, you should not use the functions 
Add in the case of a TClonesArray, but directly the operator new with 
placement as shown in the TClonesArray class description, or the example 
in $ROOTSYS/test/Event.cxx (see AddTrack), eg:
  new(a[i])  Track(x,y,z)

Rene Brun

On Wed, 13 Aug 2003, Yiqun 
Wang wrote:

> Hi, Rooters:
> 
> I am using root cvs version, compiled on a Mandrake 9.1 (custom kernel).
> 
> I have the following questions on TClonesArray:
> 
> 1. If I do:
> 
> root [0] TClonesArray *arr = new TClonesArray("TObject", 10);
> root [1] TObject a[10];
> root [2] arr->Add(&a[0]);
> 
> I will get:
> 
> root [2] arr->Add(&a[0]);
> Warning in <TClonesArray::AddLast>: may not use this method
> root [3]
> 
> In fact, none of those "Add" functions will work. When I search the
> document (the source header file), I found out all of them are defined as:
> 
> { MayNotUse("AddLast"); }
> 
> or something similar.
> 
> I suppose that I should not add an element that way. What is the correct
> way then? Dynamically allocated the element (as in the class description)?
> Suppose that I do not want to do that, then what?
> 
> 2. In addition to find out a way of adding an element, I would suggest
> that more comments be add, an very short example in the document (class
> description).
> 
> 3. The above commands work for "TObjArray". Since "TClonesArray" inherits
> from "TObjArray", I think a little clarification (or warning) is in order.
> 
> 
> Yiqun Wang
> 
> 



This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:14 MET