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
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”);
}