[ROOT] troubles renaming object several times

From: Stephane Plaszczynski (plaszczy@lal.in2p3.fr)
Date: Thu Sep 04 2003 - 13:45:34 MEST


hello,

I encounter a problem when creating histograms inside an external script.
I have a function which takes as argument an histogram and create
another one in the code called "hr".

myfunc(TH1F* h1,...){

hr=new TH1F("hr",...)
}

now I call it (from another script) and change the "hr" name.
TH1F* h1=new TH1F("h1",...);
myfunc(h1,...)
hr->Setname("h1r");

this works and I got "h1" and "h1r".

But when I do it twice:
TH1F* h1=new TH1F("h1",...);
TH1F* h2=new TH1F("h2",...);
myfunc(h1,...)
hr->Setname("h1r");
myfunc(h2,...)
hr->Setname("h2r");

here I should have h1,h1r,h2,h2r but I actually got:
.ls

root [2] .ls
TROOT*          Rint    The ROOT of EVERYTHING
 OBJ: TH1F      h1       : 0 at: 0x8a1f490
 OBJ: TH1F      h2       : 0 at: 0x8a1f9a8
 OBJ: TH1F      hr       : 0 at: 0x8ab5260
 OBJ: TH1F      h2r      : 0 at: 0x8a9dce8


does any one knows what happens? (h1r actually exists but is now the
same than h2r!)

Stephane


PS: I attach the entire script (use test() function to reproduce the
problem).



This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:15 MET