using namespace RooFit; void LandauConvGauss() { // Observable RooRealVar t("t","t",-10,30) ; // Theoretical model RooRealVar ml("ml","mean landau",2., 1., 5.) ; RooRealVar sl("sl","sigma landau",1, 0.1, 0.5) ; RooLandau landau("lx","lx",t,ml,sl) ; // Detector response function RooRealVar mg("mg","mg",0) ; RooRealVar sg("sg","sg",2) ; RooGaussian gauss("gauss","gauss",t,mg,sg) ; TCanvas * c1 = new TCanvas("c1", "c1"); TCanvas * c2 = new TCanvas("c2", "c2"); // Define sampling frequency t.setBins(500) ; c1->cd(); // Construct convolution RooNumConvPdf model("model", "Landau convolved with a Gaussian", t, landau,gauss); RooPlot * frame = t.frame(Title("landau (x) gauss convolution")); model.plotOn(frame); landau.plotOn(frame, LineStyle(kDashed)); frame->Draw(); c2->cd(); //RooFFTConvPdf model("model","landau (X) gauss",t,landau,gauss) ; // Sample 1000 events in t from model //RooDataSet* data = model.generate(t,1000) ; RooDataSet* data = model.generate(t,10000) ; t.setBins(50); // Fit model to data model.fitTo(*data) ; // Plot data, fitted p.d.f RooPlot* frame = t.frame(Title("Sample from Convolved PDF")) ; data->plotOn(frame) ; model.plotOn(frame) ; landau.plotOn(frame,LineStyle(kDashed)) ; frame->Draw(); }