RE: [ROOT] Problem in TStreamerInfo for old class version

From: Philippe Canal (pcanal@fnal.gov)
Date: Wed Aug 04 2004 - 21:06:55 MEST


Hi Ruben,

The crash itself in your example was due to the missing initialization in
the class NaVertex and NaDigit1D (the default constructor needs to set
the pointer to 0).

The real problem (unable to read the objects of type NaDigit1D in your
old files) was due to the fact that (for a reason I do not know) the
TStreamerInfo for the version number 2 of NaDigit1D is not saved in the
file even-though some object of that version are saved.

To fix the problem I create a file that contain just the TStreamerInfo
needed and loaded this file before reading the real file.

Using the file bootstrap.C (listed below) I did (with your tar file):

	$ root -q -b -l bootstrap.C+
	$ root
	root [0] f = new TFile("bootstrap.root");
	root [1] .x readTree.C

I.e. once bootstrap.root is generated, just load it in any ROOT 
session that needs to read the old file.

Also I you have write access to the file, you can fix it by
just doing
	root [] .L bootstrap.C+
	root [] f = TFile::Open("mybadfile.root","UPDATE");
	root [] fix(f); 

Cheers,
Philippe.

#include "TObject.h"
#include "TROOT.h"
#include "TClass.h"
#include "TStreamerInfo.h"
#include "TFile.h"

class TArrayI;
class NaDigit1D : public TObject {
  // This is the actually member layout of the NaDigit1D version 2
 public:
   NaDigit1D() : fTracks(0) {};
 protected:
  Int_t fI;             // Value of the digit
  Int_t fCluster;       // Number of the Cluster to which it is attached
  TArrayI* fTracks;     // Optional array of references on track
  //
  ClassDef(NaDigit1D,2) // Base class for 1Dim digits
};


void bootstrap() {
   TFile * f = new TFile("bootstrap.root","RECREATE");
   gROOT->GetClass("NaDigit1D")->GetStreamerInfo()->TagFile(f); 
   f->Write();
   delete f;
}

void fix(TFile* f) {
   gROOT->GetClass("NaDigit1D")->GetStreamerInfo()->TagFile(f); 
   f->Write();
}

-----Original Message-----
From: Ruben Shahoyan [mailto:shahoian@mail.cern.ch]
Sent: Monday, July 05, 2004 2:16 AM
To: Philippe Canal
Cc: roottalk@cern.ch
Subject: RE: [ROOT] Problem in TStreamerInfo for old class version


Sorry, I forgot to attach the files...
Regards,
	Ruben

-- 

On Sat, 3 Jul 2004, Ruben Shahoyan wrote:

> Hi Philippe,
> thank you. I remember the fix you did for the case when the base 
> class of the object written in non-split mode has changed. So, now
> I am using the root_v4_00_6a. I still can read my old tree in the
> root v_3.05, after I go back to old base class, but it crashes extactly
> in the v4_00_6a, which became the official version of na60..
> 
> In the attached package you can find the code necessary to reproduce the
> problem: just run "crelib" to create the library and execute the
> readTree.C macro.
> Unfortunately, the smallest data file I have is ~3MB, I put a copy of it
> on 
> /afs/cern.ch/user/s/shahoian/public/genesis_venus_noPileUp_pt7Pos_acmPos836.root
> and
> http://na60.cern.ch/www/Members/shahoian/genesis_venus_noPileUp_pt7Pos_acmPos836.root
> 
> Best regards,
> 	Ruben
> 
> 



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