[Fwd: Re: TObject with ariable size aray.]

Rene Brun (Rene.Brun@cern.ch)
Tue, 10 Feb 1998 10:41:05 +0100


Message-ID: <34DC2FE8.30F6@mail.cern.ch>
Date: Sat, 07 Feb 1998 10:56:56 +0100
From: Rene Brun <brun@mail.cern.ch>
Organization: CERN. European Lab. for Particle Physics
X-Mailer: Mozilla 3.01Gold (X11; I; HP-UX B.10.20 9000/755)
MIME-Version: 1.0
To: Alexander Zvyagin <zvyagin@mx.ihep.su>
CC: ROOTTALK@hpsalo.cern.ch
Subject: Re: TObject with ariable size aray.
References: <009C135B.D9FECA92.145@mx.ihep.su>
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Alexander Zvyagin wrote:
>
> IHEP, Protvino, Russia, 2-FEB-1998
>
> I'd like to create TTree of EVENTs in a root-file.
> Each EVENT should has subobject of variable size array of basic type
> (Short_t, for example). Something like this:
>
> class EVENT : public TObject
> {
> public:
> // ...
> UInt_t var_length; // length of the array var.
> Short_t *var; // pointer to the array.
> // ...
> };
>
> Sure, this is incorrect. What is correct and elegant method to do such thing?
>
> I have tryed to change member function Streamer, but it looked like ROOT
> did not use my Streamer function.

rootcint cannot generate automatically the Streamer function
for classes containing pointers to basic data types.
rootcint has no way to know that your array var has a length
indicated by the data member var_length.
You can use rootcint to generate the skeleton of Streamer
and modify this function by inserting the statement
R__B.WriteFastArray(var,var_length); // in write part
R__B.ReadFastArray(var,var_length); // in read part

The automatic split mode does not work for these classes.

Rene Brun