Re: [ROOT] Seg.Vol. reading the class derived from abstract class

From: Rene Brun (Rene.Brun@cern.ch)
Date: Tue May 07 2002 - 18:48:58 MEST


Hi Ruben

After many iterations with you, I could identify and fix the problem
(now in CVS).
You had a special case (non-split mode) for a top level branch
being a TClonesArray and the array containing a class deriving
from an abstract class.
Thanks for reporting this problem.

Rene Brun

Ruben Shahoian wrote:
> 
> Dear Rene,
> I did set address, and as I wrote you, when I am reading the tree in the
> same root session where it was created, it works fine (btw, I am using
> different branches for reading and writing).
> I put NaPCMuon::Class()->GetStreamerInfo()->ls();  as you suggested,
> the method to initialize the branch for reading looks like:
> 
> void NaRecEvent::SetPCMuonsRead(TTree * tree)
> {
>   // Init Specified Branch for reading
>   fBrInPCMuons = tree->GetBranch(fgkBlockName[kPCMuonBL]);
> // fBrInPCMuons is the TBranch* data member of the NaRecEvent class
> 
>   if (!fBrInPCMuons) {
>     Warning("SetPCMuonsRead","No %s",fgkBlockName[kPCMuonBL]);
>     fBlockStatus[kPCMuonBL] = kBlockAbsent;
>     return;
>   }
>   Warning("SetPCMuonsRead","Found Block %s",fgkBlockName[kPCMuonBL]);
>   fBlockStatus[kPCMuonBL] = kReadWriteBlock;
>   fBrInPCMuons->SetAddress(&fPCMuons);
> // fPCMuons is TClonesArray* initialized in advance by new
> // TClonesArray("NaPCMuon",).  NaPCMuon is the class derived from the
> // mentioned abstract class
> // The full hierarchy is:
> // NaPCMuon : public NaTrack : public NaRecParticle : public TObject
> // Only NaTrack is an abstract clas
> 
>   NaPCMuon::Class()->GetStreamerInfo()->ls();
>   NaTrack::Class()->GetStreamerInfo()->ls();
>   NaRecParticle::Class()->GetStreamerInfo()->ls();
> // This is by request of Rene
> 
>   Warning("SetPCMuonsRead","Reading test Event");
>   fBrInPCMuons->GetEntry(0); // Dummy reading to create or init the space
> }
> 
> Here is the output:
> 
> Warning in <NaRecEvent::SetPCMuonsRead>: Found Block PCMuons
> 
> StreamerInfo for class: NaPCMuon, version=1
>   BASE          NaTrack         offset=  0 type= 0 NA60 Track Class
>   Float_t       fParsUncorr[6]  offset=168 type=25 ax,ay,bx,by,pfit,pcomp
> of Forward Space Track
>   Int_t         fSextantId      offset=200 type= 3 Sextant ID
>   Float_t       fSlopErr2       offset=204 type= 5 RRR
>    i= 0, NaTrack         type=  0, offset=  0, len=1, method=159434808
>    i= 1, fParsUncorr     type= 25, offset=168, len=6, method=0
>    i= 2, fSextantId      type=  3, offset=200, len=1, method=0
>    i= 3, fSlopErr2       type=  5, offset=204, len=1, method=0
> 
> StreamerInfo for class: NaTrack, version=1
>   BASE          NaRecParticle   offset=  0 type= 0 NA60 Reconstructed
> Particle Class
>   Int_t         fNClusters      offset=99999 type= 3 Number of
> contributing clusters
>   Int_t         fClusters[24]   offset=99999 type=23 Clusters Id's (in the
> station)
>    i= 0, NaRecParticle   type=  0, offset=  0, len=1, method=159232424
>    i= 1, fNClusters      type=  3, offset=99999, len=1, method=0
>    i= 2, fClusters       type= 23, offset=99999, len=24, method=0
> 
> StreamerInfo for class: NaRecParticle, version=1
>   BASE          TObject         offset=  0 type=66 Basic ROOT object
>   Float_t       fPXYZ[3]        offset= 12 type=25 Px,Py,Pz of the
> Particle
>   Float_t       fVXYZ[3]        offset= 24 type=25 x,y,z of the Particle
> beginning
>   Float_t       fMass           offset= 36 type= 5 Imposed mass
>   Float_t       fPt             offset= 40 type= 5 Particle Pt
>   Float_t       fYLab           offset= 44 type= 5 Lab Rapidity
>   Char_t        fCharge         offset= 48 type= 1 Particle charge
>   Float_t       fChi2           offset= 52 type= 5 Particle quality
>   Int_t         fNumber         offset= 56 type= 3 Index in the Particles
> list
>   Int_t         fVertexId       offset= 60 type= 3 Id of the vertex to
> which it is attached
>    i= 0, TObject         type= 66, offset=  0, len=1, method=0
>    i= 1, fPXYZ           type= 25, offset= 12, len=3, method=0
>    i= 2, fVXYZ           type= 25, offset= 24, len=3, method=0
>    i= 3, fMass           type=  5, offset= 36, len=1, method=0
>    i= 4, fPt             type=  5, offset= 40, len=1, method=0
>    i= 5, fYLab           type=  5, offset= 44, len=1, method=0
>    i= 6, fCharge         type=  1, offset= 48, len=1, method=0
>    i= 7, fChi2           type=  5, offset= 52, len=1, method=0
>    i= 8, fNumber         type=  3, offset= 56, len=1, method=0
>    i= 9, fVertexId       type=  3, offset= 60, len=1, method=0
> 
>  *** Break *** segmentation violation
> Root > Function readrec() busy flag cleared
> 
> Best reagrds,
>         Ruben
> 
> On Mon, 6 May 2002, Rene Brun wrote:
> 
> > Ruben,
> >
> > Did you set the branch address before reading your Tree?
> > I see that the TStreamerInfo object for your base class
> > has not yet been computed when you read the branch.
> > This info should be computed when you set the address.
> >
> > In case you have correctly set the address (unlikely),
> > could you add the following statement before calling GetEntry:
> >   NaPCMuon::Class()->GetStreamerInfo()->ls();
> >
> > Rene Brun
> >



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:50:52 MET