Problems with convolutions

Dear all,

I’m trying to convolute a pdf depending on the observable t with a Gaussian resolution function, also depending on t. I’m using the v5.22.00c version of ROOT.

My pdf is a RooGenericPdf and is called myPdf_conv. When I plot it on the data generated, the pdf is not correct, because only the Gaussian resolution function part seems to be plotted, not the time function part.

If I remove the convolution from the pdf (called myPdf), then the plot looks fine. There is obviously a problem during the convolution, but I don’t know where it comes from and how to solve it.

Below is a very simple script that produces the two plots I’m talking about. Help would be very welcomed :slight_smile:

Thank you very much,
Géraldine

using namespace RooFit ;

void CONVOLUTION(){

Int_t ngen = 1000;

// OBSERVABLE
RooRealVar t(“t”,“time”,-0.15, 20. );

// PARAMETERS
RooRealVar tau(“tau”,"#tau_{s}",1.47, 0., 2.);
RooRealVar dGG(“dGG”,"#Delta//Gamma_{s}/#Gamma_{s}",0.072, -1., 2.);
RooFormulaVar dG(“dG”,“dG”,"@0/@1", RooArgList(dGG,tau));
RooFormulaVar G(“G”, “G”, “1./@0”,RooArgList(tau));
RooRealVar Phi(“Phi”,“Phi”,0.6, -TMath::Pi(), TMath::Pi());

// TIME RESOLUTION
RooRealVar time_resol_mean(“time_resol_mean”, “time_resol_mean” , 0. ) ;
RooRealVar time_resol_sigma(“time_resol_sigma”, “time_resol_sigma”, 0.039 );
RooGaussModel time_resol(“time_resol”, “time_resol” , t, time_resol_mean, time_resol_sigma) ;

// TIME PDFs’
RooFormulaVar* sinhGBasis = new RooFormulaVar(“sinhGBasis”,“sinhGBasis”,“exp(-@0*@1)sinh(0.5@0*@2)”,RooArgList(t,G,dG));
RooFormulaVar* coshGBasis = new RooFormulaVar(“coshGBasis”,“coshGBasis”,“exp(-@0*@1)cosh(0.5@0*@2)”,RooArgList(t,G,dG));
RooAbsReal* sinhConv = time_resol.convolution(sinhGBasis,&t);
RooAbsReal* coshConv = time_resol.convolution(coshGBasis,&t);
RooGenericPdf myPdf( “myPdf”, “myPdf”,"@0 - cos(@2)*@1", RooArgList(*coshGBasis, sinhGBasis, Phi));
RooGenericPdf myPdf_conv(“myPdf_conv”,“myPdf_conv”,"@0 - cos(@2)
@1", RooArgList(*coshConv, *sinhConv, Phi));

// GENERATION
RooRandom::randomGenerator()->SetSeed(0);
RooDataSet* data_WITHOUT_CONVOLUTION = myPdf.generate(t, ngen);
RooDataSet* data_WITH_CONVOLUTION = myPdf_conv.generate(t, ngen);

myPdf.fitTo(*data_WITHOUT_CONVOLUTION);
myPdf_conv.fitTo(*data_WITH_CONVOLUTION);

// PLOTS
tframe = t.frame() ;
data_WITHOUT_CONVOLUTION->plotOn(tframe, RooLinkedList());
myPdf.plotOn(tframe,RooFit::LineColor(kRed));

tframe2 = t.frame();
data_WITHOUT_CONVOLUTION->plotOn(tframe2, RooLinkedList());
myPdf_conv.plotOn(tframe2,RooFit::LineColor(kRed));
//time_resol.plotOn(tframe2,RooFit::LineColor(kGreen));
//
TCanvas* testcanvas = new TCanvas(“testcanvas”, “acceptances angles, time”, 1800, 900);
testcanvas->cd(1);
testcanvas->Divide(1,2);
testcanvas->cd(1)->SetLogy();
tframe->Draw();
testcanvas->cd(2)->SetLogy();
tframe2->Draw();
testcanvas->SaveAs(“TEST.eps”);
}

Hi Geraldine,

The problem is in the declaration of the basis functions. They should
be declared exactly as

RooFormulaVar* sinhGBasis = new RooFormulaVar(“sinhGBasis”,“exp(-@0*@1)sinh(@0@2/2)”,RooArgList(t,G,dG));
RooFormulaVar* coshGBasis = new RooFormulaVar(“coshGBasis”,“exp(-@0/@1)cosh(@0@2/2)”,RooArgList(t,G,dG));

which is different in 2 ways from yours

  1. The title is different (it is the formula specification)
  2. The formula is different (/2 instead of *0.5)

These do matter as the RooResolutionModel::convolution() method
matches the title of the basis function to a list of ‘known’ basis
function, hence the title must be an exact string match to what
is registered.

While looking into this I realized that this is poorly document and that
error checking in convolution() is almost non-existent. Both are related
to the fact that this method started out as a mostly internal RooFit method that was later discovered to be generally useful. I will update the code documentation and the error checking for the next ROOT release.

Wouter