Convolution of Breit–Wigner and crystal ball function

Hello all,
I am trying to take convolution of Breit–Wigner and crystal ball function to fit phi resonance signal and polynomial of order 2 to fit background. in fitting with convolution of Breit–Wigner and crystal ball for BW I got 3 parameters like mass, width and yield and for CB I got 4 alpha, n , sigma and mean from this 7 parameters I want to extract mass, width and resolution of phi resonance. can anybody please help me how to extract this parameters.

Double_t CB(Double_t *x, Double_t *par)
    return(ROOT::Math::crystalball_pdf(x[0], par[0], par[1], par[2], par[3]));
Double_t BW(Double_t *x, Double_t *par)
    return (0.5 * par[2] * par[1] / TMath::Pi() / ((x[0] - par[0]) * (x[0] - par[0]) + 0.25 * par[1] * par[1]));

Double_t polynomial2(Double_t *x, Double_t *par)
    double poly2 = par[2] + par[1] * x[0] + par[0] * x[0] * x[0];
    return (poly2);

Double_t bwcb(Double_t *x, Double_t *par)
    Double_t bw_value = BW(x, par); 
    Double_t cb_value = CB(x, &par[3]);
    Double_t convolution = cb_value * bw_value;

    return convolution;
Double_t bwcbp(Double_t *x, Double_t *par)
    Double_t bwcb_value = bwcb(x, par);
    Double_t poly2_value = polynomial2(x, &par[6]);
    Double_t result = bwcb_value + poly2_value;

    return result;

this is function defined in my header file.
in my cxx file I am setting my parameters as below

TF1 *fitFcn = new TF1("fitfunc", CB, lowfitrange[ip], highfitrange[ip], 7);

// Set initial parameters for the fit function
fitFcn->SetParameter(0, 1.02);    // Breit-Wigner: yield
fitFcn->FixParameter(1, 0.0042);  // Breit-Wigner: mass peak
fitFcn->SetParameter(2, 3000000); // Breit-Wigner: width
fitFcn->SetParameter(0, 3);       // Crystal Ball: alpha
fitFcn->SetParameter(1, 300000);       // Crystal Ball: n
fitFcn->SetParameter(3, 1.02);    // Crystal Ball: mean
fitFcn->SetParameter(2, 0.0042);  // Crystal Ball: sigma
r = hfsig->Fit(fitFcn, "REBMS0E+"); 

Thanks in advance.

Dear Sarjeeta,

Thanks for the question and welcome to the ROOT community!

I think you are basically there. The r object you have as a result of your fit is a TResultPtr instance, that allows you to access all the information about the fit. You can learn how to use a TResultPtr instance here Fitting histograms - ROOT (r.g. r->Parameter(0) or r->ParError(0))

I hope this helps!


Hi Sarjeeta,

You seem to multiply two functions but you mention convolution ?!

Maybe this is what you are
looking for.