Duplicate names for ROOT objects in multiple class instances


This is a general question… I have a class which contains a TF1. I will create multiple instances of this class, meaning that there will exist multiple TF1 objects potentially with the same name. Since ROOT uses the name of the TF1 to identify the object, I am concerned about accessing the proper object.

I recall that there is a way in ROOT to refer to the proper version of each object even if they have identical names, but cannot locate where I read that information.

How would one handle this properly? Or am I forced to make sure that each instance has a unique name?



TF1 objects are automatically registered to gROOT->GetListOfFunctions() by the constructor. Names must be unique in this list.
If you want to have multiple TF1 with the same name, do:
TF1 *f1 = new TF1(“name”,…)
but in this case, tools like TH1::Fit(“name”,…
will not be able to locate the function.