#include "RooRealVar.h" #include "RooDataSet.h" #include "RooGaussian.h" #include "RooLandau.h" #include "RooFFTConvPdf.h" #include "RooPlot.h" #include "TCanvas.h" #include "TAxis.h" #include "TH1.h" using namespace RooFit; void gexp_conv() { // S e t u p c o m p o n e n t p d f s // --------------------------------------- // Construct observable //RooRealVar t("t", "t", -10, 30); RooRealVar x("x", "x", 50, 750); RooRealVar y("y", "y", -100, 5000); // Construct gauss(t,mg,sg) RooRealVar mg("mg", "mg", 0); RooRealVar sg("sg", "sg", 2, 0.1, 10); RooGaussian gauss("gauss", "gauss", x, mg, sg); // Construct exponential(t,ml,sl) ; // Construct exponential(t,sl) ; //RooRealVar ml("ml", "mean landau", 5., -20, 20); RooRealVar sl("sl", "slope", 1, 0.1, 10); RooExponential exp("exp", "exp", x, sl); //RooExponential exp("exp", "exp", t, ml, sl); // C o n s t r u c t c o n v o l u t i o n p d f // --------------------------------------- // Set #bins to be used for FFT sampling to 10000 //x.setBins(14000, "cache"); // Construct landau (x) gauss RooFFTConvPdf gxe("gxe", "gauss (X) exponential", x, gauss, exp); // S a m p l e , f i t a n d p l o t c o n v o l u t e d p d f // ---------------------------------------------------------------------- // Sample 1000 events in x from gxlx //RooDataSet *data = lxg.generate(t, 10000); //RooDataSet *data = lxg.generate(t, 10000); //RooDataSet *data = RooDataSet::read("TD_401_388_bg417_v2_bgbgct10_scaled.dat",RooArgList(x,y)); //RooDataSet *data = RooDataSet::read("TD_401_388_bg417_v2_bgbgct10_scaled.dat",RooArgList(x)); RooDataSet *data = RooDataSet::read("test.txt",RooArgList(x,y)); // Fit gxlx to data gxe.fitTo(*data); // Plot data, landau pdf, landau (X) gauss pdf RooPlot *frame = x.frame(Title("gauss (X) exponential convolution")); data->plotOn(frame); gxe.plotOn(frame); //landau.plotOn(frame, LineStyle(kDashed)); // Draw frame on canvas new TCanvas("gxe_convolution", "gxe_convolution", 600, 600); gPad->SetLeftMargin(0.15); frame->GetYaxis()->SetTitleOffset(1.4); frame->Draw(); }