writing/reading objects to/form a file

From: chiara zampolli <Chiara.Zampolli_at_bo.infn.it>
Date: Sun, 20 Nov 2005 14:21:35 +0000

Dear rooters,

     I am trying to write and then reading an object to (from) a file. The object is an instance of a class I have created which inherits from TObject. The class is very simple:

class AliTOFCalib: public TObject
  AliTOFCalib() {fPads= new AliTOFCalParam[npad];}   virtual ~AliTOFCalib(){delete[] fPads;}   void Browse(TBrowser *b)
    char name[10];
    for(Int_t i=0; i<18; ++i) {

      snprintf(name,sizeof(name),"Sector %2.2d\0",i);
      b->Add(new AliTOFCalSector1(&fPads[i*npad/18]),name);
  void PlotPad(Int_t n) {} // *MENU*
  Bool_t IsFolder() const { return kTRUE; }

  // AliTOFCalParam fPads[npad];
  AliTOFCalParam * fPads;

where AliTOFCalSector1 is a class I have written, similar to this one. I write it on a file:

  AliTOFCalib *tc = new AliTOFCalib();
  TFile * file = new TFile("prova.root","recreate");   tc->Write("tc");

and then when trying to read it

  AliTOFCalib *cal1 = new AliTOFCalib();   TFile *file1 = new TFile("prova.root","read");   file1->GetObject("prova",cal1);

I get:

I do not know, perhaps I do not write anything, since when I dump the file I get (the underlined line is the suspicious one...):

==> Dumping object at: 0x09f4f9c8, name=prova.root, class=TFile

fSumBuffer                    0           Sum of buffer sizes of objects 
written so far
fSum2Buffer                   0           Sum of squares of buffer sizes 
of objects written so far
_*fBytesWrite                   0           Number of bytes written to 
this file*_
fBytesRead                    1176        Number of bytes read from this 
fBEGIN                        100         First used byte in file
fEND                          874         Last used byte in file
fSeekFree                     820         Location on disk of free 
segments structure

could you help me?

Thank you a lot.

    Chiara Received on Sun Nov 20 2005 - 14:19:24 MET

This archive was generated by hypermail 2.2.0 : Tue Jan 02 2007 - 14:45:13 MET