# Identifying Parameters in TF*s

I am wondering if it is possible to identify two parameters in a TF* so that when doing a fit, the two parameters are treated as a single parameter. E.g. if I have a TF1,

``TF1 f1("f1","x*+/x")``

can I after the fact set the two parameters as one? As if I had written “x*+/x”?

The reason I want to do this is that I have a big TF2 which is the sum of three two-dimensional Gaussians. It has 18 parameters (each Gaussian has an amplitude, (x,y) central value and sigma, and correlation coefficient). To make this function I first create a single 2D Gaussian using a TFormula:

``` TF2 f2_e("f2_e","/(2.0*pi***sqrt(1.0-**2))*exp( -1.0/(2*(1-**2)) * ( ((x-)/)**2 + ((y-)/)**2 - 2**(x-)*(y-)/(*) ) )",xmin,xmax,ymin,ymax); ```

Then I clone it twice, giving the clones the names “f2_mu” and “f2_pi”. Then I add them into a big TF2:

I set the parameters and parlimtis of this big TF2 and use it to fit a TH2D. I want to try the fit with the correlation coefficients all equal , , and , but I would rather not have to put in a TFormula with 17 parameters…

Jean-François

Hi,

I think the best is to create a new TF1 object using the first one, and treat the two parameter as one.
You can use the capability of create a TF1 from a functor to do this (see root.cern.ch/root/htmldoc/TF1.html#F4 )

For example, if you have

``TF1 f1("f1","x*+/x")``

You can create a new functor object:

``````struct MyFunc {

MyFunc( TF1 * f) : func(f) {}
TF1 * func;
double par;

double operator() (double *x, double *p) {
// set the parameters in f1
par = p;
par = p;
return func->EvalPar(x, par);
}

};

MyFunc myf2(f1);
TF1 * f2 = new TF1("f2",myf2, xmin, xmax, 1);  ``````