using namespace RooFit ; void ex7() { // Dealing with outlier events TCanvas* c = new TCanvas("c","c",900,300) ; c->Divide(3) ; // Make model RooWorkspace w("w",kTRUE) ; w.factory("Gaussian::sig(x[-10,10],mean[-10,10],sigma[0.5,0.1,10])") ; // Generate toy data RooDataSet* data = w::sig.generate(w::x,100) ; w::sig.fitTo(*data) ; // Fit to original data RooPlot* frame1 = w::x.frame(100) ; data->plotOn(frame1) ; w::sig.plotOn(frame1) ; c->cd(1) ;frame1->Draw() ; // // BLOCK 1 // // // Add outlier event // w::x=3.0 ; // data->add(w::x) ; // // // Fit data with outlier // w::sig.fitTo(*data) ; // // // Plot again // RooPlot* frame2 = w::x.frame(100) ; // data->plotOn(frame2) ; // w::sig.plotOn(frame2) ; // c->cd(2) ;frame2->Draw() ; // // BLOCK 2 // // // Add outlier term to model // w.factory("Polynomial::bkg(x)") ; // w.factory("SUM::model(fsig[0,1]*sig,bkg)") ; // // // Fit with improved model // w::model.fitTo(*data) ; // // // Plot again // RooPlot* frame3 = w::x.frame(100) ; // data->plotOn(frame3) ; // w::sig.plotOn(frame3) ; // c->cd(3) ;frame3->Draw() ; }