Re: [ROOT] TRef question

From: Rene Brun (Rene.Brun@cern.ch)
Date: Sat Apr 20 2002 - 09:26:25 MEST


Hi Heather,

Could you send me a running small example that I can use
to test this problem? I cannot see what could be wrong with 
this simple case.
In the development version 3.03, I fixed a few problems with TRef
in some pathological cases. May be try it before sending me
an example.

Rene Brun

On Fri, 19 Apr 2002, Heather Kelly wrote:

> Hi,
> 
> I am using ROOT 3.02.07 on Windows.
> 
> I am trying to use TRef and I seem to be running into a problem.  I have a
> class like this, where I want to store a reference to another object:
> 
> class McParticle : public TObject {
> 
>   const McParticle* getMother() const { return
> (McParticle*)m_mother.GetObject(); };
> 
> private:
>   // This stores a reference to another object of type McParticle
>   TRef m_mother;
> 
> };
> 
> When I create a new ROOT file, and open it in ROOT interactively, I am able
> to retrieve the reference via the call to getMother().  However, if I
> attempt to do the same thing with a compiled program that uses ROOT,
> getMother() consistently returns null.
> 
> Clearly there is something I do not understand.
> 
> For example, suppose I have a TObjArray of McParticles, which I iterate
> over, here is an example call to retrieve the reference - which fails in
> compiled code:
> 
>     while (pRoot = (McParticle*)partIter.Next()) {
>         McParticle *momRoot = pRoot->getMother();
> 
> In this particular case, all of the McParticles are stored to the same file
> and in the same branch...
> 
> Thanks,
> Heather
> 



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