Re: [ROOT] SetName and FindObject

From: Rene Brun (Rene.Brun@cern.ch)
Date: Sun Oct 29 2000 - 22:16:30 MET


Hi Stephen,
To complement Otto's answer

Many objects (including TF1) are automatically added to some
ROOT list by their constructors. In case of TF1, they are added
to gROOT->GetListOfFunctions(). This list is automatically
searched by gROOT->FindObject.

IN the case of your example, when you call Clone, it makes
a copy of f1. This creates a new object with name "f1".
However, because this object is already in the list of functions,
it is not added at all.

Rene Brun

On Sat, 28 Oct 2000, Stephen Bailey wrote:

> 
> Hi Rooters.
> 
> Is there a way to get a pointer to an object whose name
> was set with TNamed::SetName()?  I was expecting to be
> able to use TROOT::FindObject() but that apparently doesn't
> work.  e.g.
> 
> root [0] TF1* f1 = new TF1("f1", "gaus(0)/25.07/[2]", -5, 5);
> root [1] TF1* f2 = (TF1*) f1->Clone();
> root [2] f2->SetName("f2");
> root [3] f1->GetName()
> (const char* 0x86c1fcc)"f1"
> root [4] gROOT->FindObject("f1")
> (const class TObject*)0x86c1ed8
> root [5] f2->GetName()
> (const char* 0x86ec094)"f2"
> root [6] gROOT->FindObject("f2")
> (const class TObject*)0x0
> 
> Thanks.
> 
> Stephen
> 
> 



This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:36 MET