%%cpp -d #include "RooRealVar.h" #include "RooDataSet.h" #include "RooGaussian.h" #include "RooConstVar.h" #include "RooExponential.h" #include "RooEffProd.h" #include "RooFormulaVar.h" #include "TCanvas.h" #include "TAxis.h" #include "RooPlot.h" using namespace RooFit; RooRealVar t("t", "t", 0, 5); RooRealVar tau("tau", "tau", -1.54, -4, -0.1); RooExponential model("model", "model", t, tau); RooFormulaVar eff("eff", "0.5*(TMath::Erf((t-1)/0.5)+1)", t); RooEffProd modelEff("modelEff", "model with efficiency", model, eff); RooPlot *frame1 = t.frame(Title("Efficiency")); eff.plotOn(frame1, LineColor(kRed)); RooPlot *frame2 = t.frame(Title("Pdf with and without efficiency")); model.plotOn(frame2, LineStyle(kDashed)); modelEff.plotOn(frame2); std::unique_ptr data{modelEff.generate(t, 10000)}; modelEff.fitTo(*data, PrintLevel(-1)); RooPlot *frame3 = t.frame(Title("Fitted pdf with efficiency")); data->plotOn(frame3); modelEff.plotOn(frame3); TCanvas *c = new TCanvas("rf703_effpdfprod", "rf703_effpdfprod", 1200, 400); c->Divide(3); c->cd(1); gPad->SetLeftMargin(0.15); frame1->GetYaxis()->SetTitleOffset(1.4); frame1->Draw(); c->cd(2); gPad->SetLeftMargin(0.15); frame2->GetYaxis()->SetTitleOffset(1.6); frame2->Draw(); c->cd(3); gPad->SetLeftMargin(0.15); frame3->GetYaxis()->SetTitleOffset(1.6); frame3->Draw(); %jsroot on gROOT->GetListOfCanvases()->Draw()