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