Re: [ROOT] TObjArray and I/O

From: Rene Brun (brun@pcbrun.cern.ch)
Date: Wed Sep 15 2004 - 23:18:49 MEST


Thomas,

Your question is not clear. Do you mean "can" or "cannot" ?

Any collection of objects can be written to a file
(see TCollection::Write method). You have two ways
  -single key (all objects are serialized in teh same buffer)
  -one key per object in the collection (default).

Obviously, each object in the collection must be streamable (have a 
dictionary).

See for example this session:
root [4] TObjArray a(3)
root [5] a.Add(hpx)
root [6] a.Add(hprof)
root [7] a.Add(hpxpy)
root [8] TFile f("junk.root","recreate")
root [9] a.Write("a")
(Int_t)4644
root [10] .ls
TFile**         junk.root
 TFile*         junk.root
  KEY: TH2F     a;3     py vs px
  KEY: TProfile a;2     Profile of pz versus px
  KEY: TH1F     a;1     This is the px distribution
root [11] a.Write("as",TObject::kSingleKey)
(Int_t)4381
root [12] .ls
TFile**         junk.root
 TFile*         junk.root
  KEY: TH2F     a;3     py vs px
  KEY: TProfile a;2     Profile of pz versus px
  KEY: TH1F     a;1     This is the px distribution
  KEY: TObjArray        as;1    An array of objects


Rene Brun

On Wed, 15 
Sep 
2004, Thomas Bretz wrote:

> Hi,
> 
> is it possible that a TObjArray cannot be written to a file? I cannot 
> find anything about this in the documenation...
> 
> Thomas.
> 



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