# Convolution of a function to a resol function with E depend

Hi,

I am trying to make a convolution using RooFFTConv between a some MC true energy distribution and some Gaussian resolution function. But I need the Gaussian width to depend on the energy.

Essentially just doing the integral below.

C(x) = integral { expo(-ax’) gaus[x’-x,sigma(x’)] dx’ }

I found an example using RooFormulaVar but testing this with just some narrow Gaussians, the width of the resulting convolved function does not seem to increase with energy.

Attached is a plot generated by the snippet of codes below. As you see the width of convolved function does not increase when the initial function is center around 10 or 90…

``````RooRealVar S1True("S1True","S1True",0,100);
RooRealVar S1Reco("S1Reco","S1Reco",0,100);
RooPlot* frame1 = w->var("S1True")->frame(Title("S1 Spectra"));

RooFormulaVar S1Sigma("S1Sigma", "sqrt(@0)", RooArgList(S1True));
RooGaussian ResFuncS1("ResFuncS1", "ResFuncS1",S1Reco,S1True,S1Sigma);
RooRealVar MeanNarrowGaus("MeanNarrowGaus","MeanNarrowGaus",10,0,100);
RooRealVar SigmaNarrowGaus("SigmaNarrowGaus","SigmaNarrowGaus",0.1,0,100);
RooGaussian NarrowGaus("NarrowGaus", "NarrowGaus",S1True,MeanNarrowGaus,SigmaNarrowGaus);
NarrowGaus.plotOn(frame1,LineColor(kRed),FillColor(0));
RooFFTConvPdf NarrowGausConvRes("NarrowGausConvRes","NarrowGausConvRes",S1Reco,NarrowGaus,ResFuncS1);
NarrowGausConvRes.plotOn(frame1,LineColor(kGreen), Name("S1True"), FillColor(0));

MeanNarrowGaus.setVal(90);
RooGaussian NarrowGaus2("NarrowGaus2", "NarrowGaus2",S1True,MeanNarrowGaus,SigmaNarrowGaus);
NarrowGaus2.plotOn(frame1,LineColor(kRed),FillColor(0));
RooFFTConvPdf NarrowGausConvRes2("NarrowGausConvRes2","NarrowGausConvRes2",S1Reco,NarrowGaus2,ResFuncS1);
NarrowGausConvRes2.plotOn(frame1,LineColor(kGreen), Name("S1True"), FillColor(0));
``````

Thanks for any help or suggestions,

I found a solution here, (but it’s a bit slow)

But the method uses RooProdPDF.createProjection method. It looks like this is done using numeric integration. This causes the codes to take ~ 3 minutes to run instead of the RooFFTConv < 10 seconds. Does anyone have experience with speeding up this creatProjection method?

Thanks,