[ROOT] TRef question

From: Heather Kelly (heather@lheapop.gsfc.nasa.gov)
Date: Fri Apr 19 2002 - 23:22:52 MEST


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