Thomas, Please read my mails carefully. Read the doc of TCollection::Write and replace col.Write("Test"); by col.Write("Test",TObject::kSingleKey); By default, each element of a collection is streamed as a separate key Rene Brun On Thu, 16 Sep 2004, Thomas Bretz wrote: > Hi Rene, > > I cannot reproduce what you say... I'm using root 3.10/02 (g++ 3.3.1) > and the output of test2.C (attached) is > 1 > 1078907948 > > the output of test3.C is > 16 > 1 > 1078907948 > *** Break *** segmentation violation > > the output of test4.C is > 16 > 1 > [*] <see below> > 65536 > 0 > > Can you tell me what's wrong with this example? We have tried all three > collections as (valid!) pointers as data-members in our classes (using a > '+' in the #pragma statement). Writing the class to a file seems to > work. Reading it always results in arrays with 0 size. > > Best regards, > Thomas. > > [*] > Error in <TBuffer::ReadObject>: object tag too large, I/O buffer corrupted > Warning in <TExMap::Remove>: key 1701016576 not found at 350 > Warning in <TBuffer::CheckObject>: reference to object of unavailable > class TObj > ect, offset=1701016576 pointer will be 0 > Warning in <TExMap::Remove>: key 100 not found at 100 > Warning in <TBuffer::CheckObject>: reference to object of unavailable > class TObj > ect, offset=100 pointer will be 0 > Warning in <TExMap::Remove>: key 24 not found at 24 > Warning in <TBuffer::CheckObject>: reference to object of unavailable > class TObj > ect, offset=24 pointer will be 0 > Warning in <TExMap::Remove>: key 16777216 not found at 154 > Warning in <TBuffer::CheckObject>: reference to object of unavailable > class TObj > ect, offset=16777216 pointer will be 0 > Warning in <TExMap::Remove>: key 48 not found at 48 > Warning in <TBuffer::CheckObject>: reference to object of unavailable > class TObj > ect, offset=48 pointer will be 0 > Warning in <TExMap::Remove>: key 112 not found at 112 > Warning in <TBuffer::CheckObject>: reference to object of unavailable > class TObj > ect, offset=112 pointer will be 0 > Warning in <TExMap::Remove>: key 360 not found at 360 > Warning in <TBuffer::CheckObject>: reference to object of unavailable > class TObj > ect, offset=360 pointer will be 0 > Warning in <TExMap::Remove>: key 675365036 not found at 14 > Warning in <TBuffer::CheckObject>: reference to unavailable class > TObject, point > ers of this type will be 0 > Warning in <TExMap::Remove>: key 692994048 not found at 385 > Warning in <TBuffer::CheckObject>: reference to unavailable class > TObject, point > ers of this type will be 0 > Warning in <TExMap::Remove>: key 25625 not found at 475 > Warning in <TBuffer::CheckObject>: reference to object of unavailable > class TObj > ect, offset=25625 pointer will be 0 > Warning in <TExMap::Remove>: key 184 not found at 184 > Warning in <TBuffer::CheckObject>: reference to object of unavailable > class TObj > ect, offset=184 pointer will be 0 > Warning in <TExMap::Remove>: key 954728713 not found at 6 > Warning in <TBuffer::CheckObject>: reference to unavailable class > TObject, point > ers of this type will be 0 > Error in <TBuffer::CheckByteCount>: object of class TObjArray read too > many byte > s: 85 instead of 22 > Warning in <TBuffer::CheckByteCount>: TObjArray::Streamer() not in sync > with dat > a on file, fix Streamer() > > > Rene Brun wrote: > > 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