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

From: Rene Brun (Rene.Brun@cern.ch)
Date: Tue Feb 10 1998 - 10:41:05 MET



attached mail follows:


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



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:34:29 MET