Re: [ROOT] updating members before streaming an object

From: Rene Brun (Rene.Brun@cern.ch)
Date: Fri Sep 06 2002 - 19:03:42 MEST


Hi Christophe,

What you do should work. Could you give more details? 
Note that with TTree::Draw, you can invoke object member functions !

Rene Brun

On Thu, 29 Aug 2002, Christophe Delaere wrote:

> Hi,
> 
> I've got the following problem:
> 
> I've a class deriving from TVector3 that I want to store in a TTree.
> The class is stored and I can retrieve it.
> This is just fine.
> 
> However, for fast analysis with TTRee::Draw(), I would like to have Pt,
> eta and phi in my TTree.
> The solution I've found is to add those variables in my class, and let
> them be streamed as usual.
> The problem arises when I want to update those fields.
> I can't do it after each action during the object life, so I wanted to
> update them just before streaming the object.
> I've modified the streamer like this:
> 
> void HLGlobalTriggerCandidate::Streamer(TBuffer &R__b)
> {
>    // Stream an object of class HLGlobalTriggerCandidate.
> 
>    if (R__b.IsReading()) {
>       HLGlobalTriggerCandidate::Class()->ReadBuffer(R__b, this);
>    } else {
>       et = Pt();
>       eta = Eta();
>       phi = Phi();
>       HLGlobalTriggerCandidate::Class()->WriteBuffer(R__b, this);
>    }
> }  
> 
> ... but it doesn't work.
> et, eta and phi are not stored with the right value.
> 
> Can anybody tell me what's wrong ?
> 
> Cheers,
> Christophe.
> 
> -- 
> +-----------------------------------------------------------\|/---+
> | Christophe DELAERE            office: e253               !o o!  |
> | UCL - FYNU                    phone : 32-(0)10-473234    ! i !  |
> | chemin du cyclotron, 2        fax   : 32-(0)10-452183     `-'   |
> | 1348 Louvain-la-Neuve BELGIUM e-mail: delaere@fynu.ucl.ac.be    |
> +-----------------------------------------------------------------+
> 



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