TF1Convolution in Python

Dear experts,

I’m trying to use ‘TF1Convolution’ function in my python code, based on C++ example as following.
But, I don’t know how I should express ‘*f_conv’ in the python.
I just tried ‘f_conv’ without star, but it didn’t work.
Would you please give some comments?

Many thanks in advance.
Best regards,
Jiyoung

example:

   TF1Convolution *f_conv = new TF1Convolution("expo","gaus",-1,6,true);
   f_conv->SetRange(-1.,6.);
   f_conv->SetNofPointsFFT(1000);
   TF1   *f = new TF1("f",*f_conv, 0., 5., f_conv->GetNpar());
   f->SetParameters(1.,-0.3,0.,1.);

python:

        f_conv = TF1Convolution("expo", "gaus", -10, 10, kTRUE)
        f_conv.SetRange(-2, 2)
        f_conv.SetNofPointsFFT(1000)
        print(f_conv.GetNpar())
        fitfunction_conv = TF1("fitfunction_conv", f_conv, -2, 2, f_conv.GetNpar())

__
ROOT Version: root-6
Platform: Ubuntu16.04
Compiler: Not Provided


Dear @jikim

What error do you see when running the Python version of your code?

Enric

Dear Enric,

It doesn’t make an error message. the code, itself, is working.
But, it also did not make a fit-function (fitfunction_conv) correctly.
When I use C version of the code, I can see the convoluted function (f->Draw()).
But, in python, it show flat line on zero.

Cheers,
Jiyoung

Hi Enric,

I just found the problem.
I tried to use the exactly same fit range and values (which is used in C example), in python.
It works… ;d
Maybe my fit parameters are the problem.
I should have checked it before posting. Sorry.
It solved now, thanks!

Best regards,
Jiyoung

Hi @jikim

Good to hear it’s working now, cheers!

Enric

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