Hi Colin, The issue is that (most likely) the ROOT file you produce is indeed incorrect. In the code provided, the MVertex class does not initialize the value of its data member 'ntrack'. This value is then used in a statement like: new((*track)[ntrack++]) MTrack(q,p,px,py,pz,chi2); Since ntrack is not initialize, it can start at any random value. The consquence is that the element of the TClonesArray below this random value might not be initialized. On the platform I tried you program on, this lead to a core dump of the testMDST software. Once I fixed the problem, it ran fine and the Linux/Debug program did not fail. The fixed method is: MVertex::MVertex(double x, double y, double z, double chi2) : TObject(), primary(0), x(x), y(y), z(z), chi2(chi2), ntrack(0) { track = new TClonesArray("MTrack",100); } Cheers, Philippe. -----Original Message----- From: owner-roottalk@pcroot.cern.ch [mailto:owner-roottalk@pcroot.cern.ch]On Behalf Of Colin Bernet Sent: Monday, July 22, 2002 9:43 AM To: roottalk@pcroot.cern.ch Subject: [ROOT] Error in <TBuffer::ReadClass>: got wrong class: TObject Hello, dear rooters. First of all, sorry for this long mail... I created a tree containing (as usual) vectors of tracks and vertices. This tree has one single branch for an MEvent object : class MEvent : public TObject { public: int number; vector<MVertex> vertex; vector<MTrack> track; MEvent(); // ... ClassDef(MEvent,1) }; As you can see, I would like to use STL vectors to store vertices and tracks. Everything seems to work fine, except I get the following error message at the first TTree::GetEntry(int) Error in <TBuffer::ReadClass>: got wrong class: TObject Does anybody know what could be the cause of this message ? In case you need it, my code can be found in /afs/cern.ch/user/c/cbernet/public/MDST Tree is created and filled or chained and read in MDST class. Linux/testMDST produced the tree Linux/Debug reads the tree and produces the error message. executables are in /afs/cern.ch/user/c/cbernet/public/MDST/Linux I also have a question : At the beginning, my LinkDef was : #ifdef __CINT__ #pragma link off all globals; #pragma link off all classes; #pragma link off all functions; #pragma link C++ class MTrack; #pragma link C++ class MVertex; #pragma link C++ class MEvent; #pragma link C++ class MDST; #endif Then the tree was filled but the vectors of tracks and vertices were empty at reading stage. Wandering on the root web site, I found out that appending "+" at the end of the class names in the LinkDef solves this problem. Is this the normal behaviour ? is it related to the "wrong class" error message ? I tried with root 3.00/06 and 3.03/07. thanks a lot if you can help me. Colin
This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:51:00 MET