-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Parameters and names #3
Comments
I see that problem in
In def add_parameter(self, param_var, param_name=None, final_name=None, **kwds):
""" Add fit parameter
Args:
param_var (list or ROOT.RooRealVar): Initialisation of the parameter as list or ROOT object
param_name (:obj:`str`): Name of the parameter within the object (Not within ROOT namespace!)
final_name (:obj:`str`, optional): Name if the parameter within PDF and ROOT namespace
**kwds: create_roo_variable keywords
Returns:
ROOT.RooRealVar reference to fit parameter
"""
if final_name is None:
assert param_name is not None, "Please specify a parameter name"
name = self.name + '_' + param_name
else:
name = final_name
roo_param = create_roo_variable(param_var, name=name, **kwds)
self.parameters[param_name] = roo_param
self.parameter_names[param_name] = name
self.__setattr__(param_name, roo_param)
return self.parameters[param_name] By changing that as follows: def add_parameter(self, param_var, param_name=None, final_name=None, **kwds):
""" Add fit parameter
Args:
param_var (list or ROOT.RooRealVar): Initialisation of the parameter as list or ROOT object
param_name (:obj:`str`): Name of the parameter within the object (Not within ROOT namespace!)
final_name (:obj:`str`, optional): Name if the parameter within PDF and ROOT namespace
**kwds: create_roo_variable keywords
Returns:
ROOT.RooRealVar reference to fit parameter
"""
if final_name is None:
assert param_name is not None, "Please specify a parameter name"
name = self.name + '_' + param_name
else:
name = final_name
roo_param = create_roo_variable(param_var, name=name, **kwds)
self.parameters[name] = roo_param
self.parameter_names[name] = roo_param.GetName()
self.__setattr__(name, roo_param)
return self.parameters[name] everything works fine again. There's also a second fix in there: I suppose that In general, the whole naming thing seems to be a bit confusing to me and is not yet much documented (especially when giving the name in the tuple, it's not very clear what takes precedence). I also don't quite understand why don't enforce the name of the parameter to always be the same of the RooRealVar internal name (or vice-versa), I don't see any use case there and it was very confusing to me at first. |
Hi Kilian, sorry for the late reply, this is a bug in AddPdf, so in this case you would need to extract the parameters from the constituents. |
Yes, sorry I also saw in the meantime that it works as far as the fitting is concerned and that just If you don't have the time I could also take another look at this in the next weeks. |
One of the main reasons I do not want to use your suggestion is, that I would like a Gauss to always have a 'mean' not a 'gauss1_mean' or so... for saving parameters and so on. |
Hmm, but I only see 3 options (but might overlook something):
I also think that keeping keys/names that are different from the names of the ROOT objects (as in |
#5 might do the trick.
I see the point, but imagine you want to save parameters to a file, there you would describe a Gauss of course with a 'mean' and 'sigma' not some other names.. |
Hi Simon,
it seems like that if you add 2 pdfs of the same type, the parameters will overwrite each other, even if you assign them different names:
MWE (updated):
returns
I think I looked in the code a while ago and you were checking only for the dictionary keys, not for the names of theRooFit
objects and therefore overwrite themean
parameter.Perhaps I'll create a PR for this later if I find the time, just wanted to report this, because it seems to be important to fix this fast.
Cheers,
Kilian
The text was updated successfully, but these errors were encountered: