# Convolution between Gaus and power function

Dear All
I have an alpha peak need to apply a proper fitting function, and because alpha peak is not well Gaussian peak. but rather a Gaussian + tail on the left.
I have created two fitting functions
Power for the tail range and Gaussian for the peak as follows

``````TF1 *fPower = new TF1("fPower","*TMath::Power(x,(1/))", 80,250);
fPower->SetParameters(10000, 68);
fPower->SetLineColor(kBlue);
f->Fit("fPower", "R");

TF1 *gausBi= new TF1("gausBi","gaus",200,1300);
gausBi->SetLineColor(kBlack);
f->Fit(gausBi, "R+");
``````

Next step I am trying to formulate this in one function for the full range, or what refer to convolution.
so I build this new function and called the initial parameters as follows

``````TF1 *fPower_gausBi = new TF1("fPower_gausB", "fPower+gausBi", 80, 1200);
Double_t par;
fPower->GetParameters(&par);
gausBi->GetParameters(&par);

fPower_gausB->SetParameters(par);
f->Fit(fPoisson_gausBi, "R+");
``````

But this not make fitting in two ranges that’s why I get the wrong fitting curve (Red line).

any suggestion for the convolution process ??
fit.pdf (17.2 KB)

Hi,

Why not using the cristal ball function

that is available in ROOT as

``````TF1 f1("f1","crystalball")
``````

or as `ROOT::Math::crystal_ball` https://root.cern.ch/doc/v608/group__PdfFunc.html#ga6d2dcba56ea7438dab7e47e8c06c83f6

an example is available at

https://root.cern.ch/doc/v608/CrystalBall_8C.html

Thank you for this suggestion, I tried crystalball function, but it did not work and because it is difficult to control the parameters I choose to do it manually by convolution between two functions.

thank you

Try:

``````  TF1 *fPower_gausBi = new TF1("fPower_gausB", "(x < 222.) * fPower + (x >= 222.) * gausBi", 80., 1300.);
``````

or:

``````  TF1 *fPower_gausBi = new TF1("fPower_gausB", "TMath::Min(fPower, gausBi)", 80., 1300.);
``````

BTW. A sum of two functions is NOT their “convolution”.

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