Re: split/non-split difference in SetAddress()

From: Valeri Fine (Faine) (fine@bnl.gov)
Date: Wed Sep 15 1999 - 21:00:31 MEST


 Hello Andy,

 Have a look at 

http://www.star.bnl.gov/STAR/html/comp_l/root/html/St_io_Maker.html

This class was developed some times ago for STAR 

http://www.rhic.bnl.gov/star/starlib/doc/www/welcome_star.html

Since later we did choose another I/O scheme this class left for the sake
of the backward compatibility so it is not well advanced. Probably it may
give you some ideas.

  With my best regards,
                               Valery

----- Original Message ----- 
From: Andy Salnikov <AASalnikov@lbl.gov>
To: Rene Brun <Rene.Brun@cern.ch>; Andrei Salnikov <salnikov@SLAC.stanford.edu>
Cc: ROOTTALK <roottalk@hpsalo.cern.ch>
Subject: Re: split/non-split difference in SetAddress()


> 
>   Hi Rene,
> 
>   I don't want to look bothering and annoying, but it seems I have to.
> As usual, I got no answer to my question, and I gonna repeat it
> literally:
> 
>   I can't really understand why is this difference in approaches, does
> it really must be like that? Can't we make the behavior more uniform
> across split and non-split branches?
> 
>   I mean that I really really would like to have GetEntry() to set the
> pointer which was passed to the branch with SetAddress(), no matter it
> is split or non-split branch.
> 
>   As for your receipt below - we really do not know the true type of the
> object when we are reading it. ROOT does know, because all the
> information is in the trees/branches. I understand that knowing the name
> of the class I can create the instance, now how can I get the name of
> the class which is in the branch? Do you have some mechanism in ROOT to
> accomplish something like this : "knowing TTree and branch name I want
> to obtain the class of the object in this branch"? Looking at the
> documentation and the code I can't seem to find the relatively easy way
> to do it, which will not depend on the details of implementation of your
> stuff, or can I?
> 
>   Cheers,
>   Andy.
> 
> ----- Original Message -----
> From: Rene Brun <Rene.Brun@cern.ch>
> To: Andrei Salnikov <salnikov@SLAC.Stanford.EDU>
> Cc: ROOTTALK <roottalk@hpsalo.cern.ch>
> Sent: Wednesday, September 15, 1999 8:36 AM
> Subject: Re: split/non-split difference in SetAddress()
> 
> 
> > Hi Andy,
> > I appreciate the fact that you have been able to understand very
> deeply
> > the way the Tree/Branch mechanism works. Your analysis is perfectly
> > correct.
> > Now back to your question.
> > You can have a perfectly symmetric mechanism between split and
> non-plit
> > mode
> > if instead of:
> >   ClassBaseA* theObjectPointer_ = 0;
> >  (ie letting Root instantiate the object itself)
> > you make yourself an instance of the object.
> > I understand your argument about schema evolution and that you do not
> > know
> > a priori (I assume at compilation time) what your current class
> derived
> > from ClassBaseA will be. However, I assume that you must have a
> > mechanism
> > at run time to find out if you have a ClassA_001 or a ClassA_00N .
> > With Root you can create an instance of an object by knowing only
> > its class name, say "ClassA__003". Proceed as follows:
> >   - Get a pointer to the Root TClass object (RTTI) for this class
> >     TClass *cl = gROOT->GetClass("ClassA_003");
> >   - Create an instance of the object with:
> >     ClassBaseA* theObjectPointer_ = (ClassBaseA*)cl->New();
> >   - Now you can set the branch address
> >       theBranch_ -> SetAddress ( (void*)(&theObjectPointer_) ) ;
> >
> > When the object already exists, Root input in split mode will not
> > destroy
> > the already existing object, theObjectPointer will always have the
> same
> > value.
> > In non-split mode, we have no choice but to delete the previous object
> > at the branch address because the new object has not the same size
> than
> > the previous object in general.
> >
> >
> > Rene Brun
> >
> 
> 
> 



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