How do I provide parameters in TF1 that constructed from TF1Convolution

Hi ROOTers,
I have the following issue.

I have a histogram which I want to fit with the convolution of two functions. Here is my code.

    //Signal function
    TF1* fit = new TF1( "fit", OutputVoltage, 3.8e-6, 15e-6, 8 );
        fit->SetParNames( "t_{0}",
                          "#alpha_{1}", "#tau_{1}",
                          "V_{0}" );

        fit->SetParameter( 0, T0 );
        fit->SetParLimits( 0, 0., 5e-6 );

        fit->SetParameter( 1, ALPHA1 );
        fit->SetParLimits( 1, 0., 1. );
        fit->SetParameter( 2, DECAY_TIME1 );
        fit->SetParLimits( 2, 0.3e-6, 1.3e-6 );

        fit->SetParameter( 3, ALPHA2 );
        fit->SetParLimits( 3, 0., 1. );
        fit->SetParameter( 4, DECAY_TIME2 );
        fit->SetParLimits( 4, 1.3e-6, 3e-6 );

        fit->SetParameter( 5, DECAY_TIME3 );
        fit->SetParLimits( 5, 6e-6, 30e-6 );

        fit->SetParameter( 6, RISING_TIME );
        fit->SetParLimits( 6, 1e-9, 500e-9 );

        fit->SetParameter( 7, 2 );
        fit->SetParLimits( 7, 0., 1000. );

    //Fit histogram with non-convoluted signal function
    //to set the initial parameters
    h->Fit( fit, "R" );

    //Resolution function
    TF1* res = new TF1( "res", "gaus" );
        res->SetParameters( 1e6, 0., 50e-9 );

    //Create convolution of signal with gaussian
    TF1Convolution* f_conv = new TF1Convolution( fit, res, 3e-6, 13e-6, kTRUE );
        f_conv->SetRange( 3e-6, 13e-6 );
        f_conv->SetNofPointsFFT( 1000 );

    //This is the final function to fit histo with
    TF1* func_conv = new TF1( "f", *f_conv, 3e-6, 11e-6, f_conv->GetNpar() ); 
        func_conv->SetLineColor( kBlue );
        //I THINK that the order of parameters is the following: first parameters of the 1st function
        //then parameters of the 2nd function
                                    fit->GetParameter( 0 ),
                                    fit->GetParameter( 1 ),
                                    fit->GetParameter( 2 ),
                                    fit->GetParameter( 3 ),
                                    fit->GetParameter( 4 ),
                                    fit->GetParameter( 5 ),
                                    fit->GetParameter( 6 ),
                                    fit->GetParameter( 7 ),
                                    res->GetParameter( 0 ),
                                    res->GetParameter( 1 ),
                                    res->GetParameter( 2 )

    h->Fit( func_conv, "R" );

    func_conv->Draw( "same" );

After the execution of the above code I see the following picture in the terminal

I have a question here: why the parameters the 1st function remain unchanged (exculded the p0)?
I think that I am missing something.

Thanks in advance


I think the issue with changing the 1st parameter was somehow connected with the function ranges. Now ranges are OK and non of the parameters of the 1st function in convolution are changing.

ROOT Version: 6.16/00
Platform: Ubuntu 16.04
Compiler: Not Provided


When creating the TF1Convolution the TF1 objects used to build it are copied so ;after when doing a fit their parameter will not be touched. Only the parameter of the TF1 built using TF1COnvolution, the function “fit” in your case will have the fit parameter values.
If you need to propagate those parameter back you need to copy by hand.

Best regards


I don’t understand. In function that built using TF1Convolution only 3 of 11 parameters are changing while fitting. Check the picture. Function “fit” doesn’t using TF1Convolution at all.


It seems like it matters if I provide *f_conv or f_conv in TF1 constructor.


Your log output indicates that your fit failed. This could explained why the fitting changes only a dubsteps of the parameters. You should understand why there is a failure in fitting, maybe because of wrong initial parameter values ?

Anyway, if you are having still problems, please upload also your code (and data if needed) so we can reproduce your problem



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