#include #include #include #include #include void convolution () { RooWorkspace w("w", kTRUE); w.factory("Landau::landau(t[-10, 30], ml[5.0, -20, 20], sl[1, 0.1, 10])"); w.factory("Gaussian::gauss(t, mg[0], sg[2, 0.1, 10])"); // Construct convoluted pdf lxg(x) = landau(x) (*) gauss(x) // RooFFTConvPdf lxg("lxg", "landau X gauss", *w.var("t"), *w.pdf("landau"), *w.pdf("gauss")); // Alternative construction method using workspace w.factory("FCONV::lxg(t, landau, gauss)"); // --- Generate a toyMC sample from composite PDF --- RooDataSet *data = w.pdf("lxg")->generate(*w.var("t"), 10000); // --- Perform fit w.pdf("lxg")->fitTo(*data); // --- Plot toy data and composite PDF overlaid --- RooPlot *frame = w.var("t")->frame(); data->plotOn(frame); w.pdf("lxg")->plotOn(frame); w.pdf("landau")->plotOn(frame, RooFit::LineStyle(kDashed)); frame->Draw(); } // convolution