TF1 function take 12 variable?

Hi all,
I using TF1 to fit my data. The function I use is Double Sided Crystall ball + 4th order poly, which means the function I use contains 12 variables. I got the following issue. However, if I remove one variable (I use 3rd order pol instead of 4th order), the fitting works ok.
Is there away to fit my data using TF1 function with more than 11 parameters?
Thanks in-advance,
Lamya

f_sigbc.SetParameters( 5000, 0.9349, 0.04, 1, 1, 1, 1, 1, 1, 1, 1, 1 )
TypeError: none of the 2 overloaded methods succeeded. Full details:
  void TF1::SetParameters(double p0, double p1, double p2 = 0, double p3 = 0, double p4 = 0, double p5 = 0, double p6 = 0, double p7 = 0, double p8 = 0, double p9 = 0, double p10 = 0) =>
    TypeError: takes at most 11 arguments (12 given)
  void TF1::SetParameters(const double* params) =>
    TypeError: takes at most 1 arguments (12 given)

Please read tips for efficient and successful posting and posting code

ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided


double params[12] = {5000, 0.9349, 0.04, 1, 1, 1, 1, 1, 1, 1, 1, 1};
f_sigbc.SetParameters(params);

Thanks @Wile_E_Coyote for your reply. I am using pyroot and I convert what you wrote as

f_sigbc = TF1("f_sigbc",DoubleSidedCB_poly, 0.5, 1.2, 12)
    par = [5000, 0.9349, 0.04, 1, 1, 1, 1, 1, 1, 1, 1, 1]
    f_sigbc.SetParameters(par);

and here what I got

 f_sigbc.SetParameters(par);
TypeError: none of the 2 overloaded methods succeeded. Full details:
  void TF1::SetParameters(double p0, double p1, double p2 = 0, double p3 = 0, double p4 = 0, double p5 = 0, double p6 = 0, double p7 = 0, double p8 = 0, double p9 = 0, double p10 = 0) =>
    TypeError: takes at least 2 arguments (1 given)
  void TF1::SetParameters(const double* params) =>
    TypeError: could not convert argument 1 (could not convert argument to buffer or nullptr)

I think I convert it wrong, Can you help me of how I can do it in pyroot?

Hi,

In PyROOT you can pass a Numpy array:

par = np.array([5000, 0.9349, 0.04, 1, 1, 1, 1, 1, 1, 1, 1, 1],dtype='float64')
f_sigbc.SetParameters(par)

Thanks so much, it works :slight_smile:

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