GetObject with same name

Dear Expert,

TGraphErrors * gr = new TGraphErrors(1);
gr->SetPoint(0, 1, 1);

gr = new TGraphErrors(1);
gr->SetPoint(0, 2, 2);

Now, is it possible I get a pointer to the first TGraphErrors at (1, 1)?


No, it is not. What is the problem of using two different pointers?

Someone generated .pdf and .C using a macro, unfortunately some objects have the same name.
When I look at the .C and try to save the TGraphErrors to a root fine, it uses one TGraphErrors pointer “gre” for all objects.
And since the name are the same, it seems not possible to write a stand alone macro to write out the root file.

if you want to save all of these graphs which have the same name and for which the same pointer variable is used, the only way to proceed is to intervene on the macro itself, for example storing the pointers in a vector which you can flush to disk at the end of the execution.


If you post the “.C” file here, we could have a look at it.

Sometime ago saving in a .C file end up with a such problem under some circumstances. But that was (should be) fixed. It would be interesting to see the macro and also know with which ROOT version that .C was generated.