Re: Backward compatibility and the Event object model

From: Rene Brun (Rene.Brun@cern.ch)
Date: Wed Apr 01 1998 - 09:10:38 MEST


Laurent Aphecetche wrote:
> 
> Hi,
> 
> I've got some problem with my Event model and its evolution in time.
> 
> I used this :
> 
> Event 1
> {
>   RBHeader fHeader ;
>   Int_t    fNparticleEM ;
>   Int_t    fNparticleHADR ;
>   TOrdCollection* fParticleEM ;
>   TOrdCollection* fParticleHADR ;
> 
>  ...
> }
> 
> and produced some trees in split mode with this.
> 
> Now, I would like to use :
> 
> Event 2
> {
>   RBHeader fHeader ;
>   Int_t    fNparticleEM ;
>   Int_t    fNparticleHADR ;
>   Int_t    fNparticleGEANT ;
>   TOrdCollection* fParticleEM ;
>   TOrdCollection* fParticleHADR ;
>   TOrdCollection* fParticleGEANT ;
>  ...
> }
> 
> I used to think (naively, obviously) that reading back the type 1 trees
> would be a matter
> of dealing with the class version number in Event::Streamer. But it
> seems that this
> routine is not called at all when reading back the tree (written in
> split mode).
> 
> So how can I deal with this evolving event class ? Am I lost or is there
> a solution ?
> 
> Thanks a lot for your help.

Laurent,
When you use the split mode on your Event class, the Event::Streamer
function is not called by definition. In this case a branch is created
for each data member of the class Event.
You will be able to read your old Tree with the new class definition
if you append new data members. In your case you have introduced
a new data member "fNparticleGEANT" between old members.
When you call SetBranchAddress("event",&event), Root will loop
on the branches definition in the order stored in the Tree header
and for each branch it will assign the address of the next data member.
You can still read your old Tree with your new Event2 class definition
if instead of calling SetBranchAddress("event",.. you make an
explicit call to SetBranchAddress for the 4 existing branches.

Rene Brun



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:34:31 MET