[ROOT] Storing Inherited Classes in TTree

From: Ben Morgan (B.Morgan@sheffield.ac.uk)
Date: Mon Jul 28 2003 - 18:16:49 MEST


Hi ROOTers,
           I've been writing a data storage class which inherits from 
TObject and two header classes:

class TRDMwpcEvent : public TObject, public TRDTimeHeader, public 
TRDSlowHeader

Neither of the 'Header' classes inherits from TObject, but they both have 
ClassDef and ClassImp defined. They also only have simple data members, 
Int_ts or Float_ts. The code for these classes compiles and builds into a 
shared library without complaint, and I can create/delete objects without 
any problem (I'm using ROOT v3.05/03 built with gcc3.2 on a RH7.3 PC).

I can also write TRDMwpcEvent objects to a TTree without any fault, but 
the real problem is that I can't read the data back in if the TTree branch 
for the object is split. i.e. using

TBranch *branch = tree->Branch("RDMwpcDataBranch","TRDMwpcEvent",&tdd,32000,0);

produces a data file I can read, but

TBranch *branch = 
tree->Branch("RDMwpcDataBranch","TRDMwpcEvent",&tdd,32000,2);

leads to a seg. fault when trying to extract data from 
the TTree to a TRDMwpcObject with GetEntry. Is there a restriction on 
inherited classes being written to TTrees, or am I missing something 
obvious? Thanks for any advice you can offer,

Ben Morgan.

-- 
-------------------------------------------------------------------------------
Mr. Ben Morgan                               Tel: 44 (0)114 22 23553 (Work)
Postgraduate Student
University of Sheffield
Department of Physics & Astronomy
Hicks Building
Hounsfield Road
Sheffield  S3 7RH
-------------------------------------------------------------------------------



This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:14 MET