Sum of TF1 in ROOT6 interpretes wrong number of parameters

Dear root users,

Defining a sum of TF1 functions simply as “fpeak+ftail” works fine in root 5.34/32. However, in root 6.06/08 it only takes the parameters of the last function.

Minimal code example:

void sumTF1(){
	Double_t par[6];

	TF1 *fpeak = new TF1("fpeak","gaus",1100,1130);
	TF1 *ftail = new TF1("ftail","gaus",1100,1130);

	fpeak -> SetParameters(1,2,3);
	ftail -> SetParameters(4,5,6);

	TF1 *fsignal = new TF1("fsignal","fpeak + ftail");
	
	//Show parameters
	fsignal->GetParameters(&par[0]);
	for(int i=0;i<6;i++){ printf(" par %d of fsig : %f\n", i, par[i]); }
}

gives

Root 5.34/32

 par 0 of fsig : 1.000000
 par 1 of fsig : 2.000000
 par 2 of fsig : 3.000000
 par 3 of fsig : 4.000000
 par 4 of fsig : 5.000000
 par 5 of fsig : 6.000000

Root 6.06/08

 par 0 of fsig : 4.000000
 par 1 of fsig : 5.000000
 par 2 of fsig : 6.000000
 par 3 of fsig : 0.000000
 par 4 of fsig : 0.000000
 par 5 of fsig : 0.000000

Is this behaviour expected?
Thanks in advance,
Joan

I just ran your example with ROOT 6.13/01. I get the same result you get with 6.06.
I guess @moneta can explain this difference.

Hi,

Yes the behaviour is expected because the situation was not clear defined before when combining functions.
Now in ROOT 6.12 you have the flexibility to define the parameters of the two functions as you want , e.g. shared ( in common) or different.
For example, in your case if you want the two functions to have all different parameters you define your signal function as following:

TF1 *fsignal = new TF1("fsignal","fpeak(x,[A1],[Mean1],[Sigma1]) + ftail(x,[A2],[Mean2],[Sigma2])");

Best Regards

Lorenzo

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.