[ROOT] TNamed objects, why 'renaming' is not the same as naming ?

From: Patois Yannick (patois@ganil.fr)
Date: Mon May 28 2001 - 23:47:06 MEST


Hello rooters,

There must be something very fundamental I dont get in the naming of
root objects.
Could someone point me the doc I should read to understand why the
following is wrong ? :

// Create and fill an histogram, just for demonstration
root [0] TH1F *h1=new TH1F("h1","H1",100,-10,10);
root [1] h1->FillRandom("gaus", 2000);
// Create a function called 'f1'.
root [2] TF1 *f1=new TF1("f1","gaus")
root [3] h1->Fit("f1") // This works well
// Create a copy of f1 under the name "f2"
root [4] TF1 *f2=(TF1*)f1->Clone("f2")
root [5] f2->GetName()
(const char* 0x88bce5c)"f2" // Name is indeed f2
root [6] h1->Fit("f2")
Error in <TH1F::Fit>: Unknown function: f2
??? Function "f2" is not known, but I just defined it !

This also append when I 'rename' objects using SetName() method.

I'm sure it's something very basic I didnt get in the way ROOT works.
Any information would help, thanx :)

	Yannick



This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:47 MET