Setting Value of Fit Parameter to Depend on Another Fit Parameter Value

Hello all,

I would like to perform a fit, where the value of one of the fit parameters depends on the value of another fit parameter. For example, lets say I have a functions that has two parameters, then what I would like to do is the following:

Int_t fixedValue = 2;
fitFunction->SetParameter(0, 1.);
fitFunction->FixParameter(1, fitFunction->GetParamter(0) + fixedValue);

Basically, if I know the value of par[0], then par[1] = par[0] + fixedValue. However, this is a much more simplified version of my actual situation, so I do not want to define par[1] = par[0] + fixedValue in my user defined function, and I was wondering if I could obtain the same results by using the above block of code? Or, is there a better method to achieve what I want?

Thank you very much and any help is appreciated!

Hi @Bassam!

No, it does not work like this unfortunately. If you do fitFunction->FixParameter(1, fitFunction->GetParamter(0) + ...) it will take the value that the zeroth parameter currently has, it’s not that there two parameters are now connected.

Is what you’re doing a likelihood fit? If you want to do more complicated likelihood fits, then you should consider using RooFit. Is that an option for you?

Cheers,
Jonas

Thank you very much for your reply @Jonas! I will look into it and also try different ideas. Worst case scenario, I will resort to replacing par[1] with par[0] + fixedValue in the function definition.