{ using namespace RooFit; TFile *fin = new TFile("example_data.root"); TNtupleD* nt = (TNtupleD *)fin->Get("nt"); RooRealVar mass("mass","mass",0.,2.); RooDataSet data("data","data",nt,RooArgSet(mass)); RooRealVar mu("mu","mu",1.0,0.5,1.5); RooRealVar sigma("sigma","sigma",0.05,0.001,0.15); RooGaussian gaus("gaus","gaus",mass,mu,sigma); RooRealVar slope("slope","slope",-0.3,-10.,10.); RooPolynomial linear("linear","linear",mass,RooArgSet(slope)); RooRealVar ns("ns","ns",2000,0.,20000.); RooRealVar nb("nb","nb",8000,0.,20000.); RooAddPdf model("model","model",RooArgList(gaus,linear),RooArgList(ns,nb)); model.fitTo(data,Minos(true)); RooPlot* frame = mass.frame(); data.plotOn(frame); model.plotOn(frame); model.plotOn(frame,Components(linear),LineStyle(7),LineColor(kRed)); frame->Draw(); }