#ifndef __CINT__ #include "RooGlobalFunc.h" #endif #include "RooRealVar.h" #include "RooDataSet.h" #include "RooGaussian.h" #include "RooConstVar.h" #include "RooPolynomial.h" #include "RooAddPdf.h" #include "RooProdPdf.h" #include "RooMCStudy.h" #include "RooPlot.h" #include "TCanvas.h" #include "TAxis.h" #include "TH1.h" using namespace RooFit; void TestPulls() { double yield = 200; // Observable RooRealVar x("x","x",-10,10) ; // Signal component RooRealVar m("m","m",0,-10,10) ; RooRealVar s("s","s",2,0.1,10) ; RooGaussian g("g","g",x,m,s) ; m.setConstant(false); s.setConstant(false); RooMCStudy mcs(g,x,Silence(),FitOptions(PrintLevel(-1))) ; mcs.generateAndFit(1000,yield,true) ; RooDataSet* toySample = (RooDataSet*)mcs.genData(0); g.fitTo(*toySample); RooPlot* frame0 = x.frame(40); toySample->plotOn(frame0); g.plotOn(frame0); RooPlot* frame1 = mcs.plotParam(s,Bins(40)) ; frame1->SetTitle("Distribution of fitted s values") ; RooPlot* frame2 = mcs.plotPull(s,Bins(40),FitGauss()) ; frame1->SetTitle("Distribution of s pull values") ; TCanvas* c = new TCanvas("TestPulls","TestPulls",1200,400); c->Divide(3) ; c->cd(1) ; gPad->SetLeftMargin(0.15) ; frame0->GetYaxis()->SetTitleOffset(1.4) ; frame0->Draw() ; c->cd(2) ; gPad->SetLeftMargin(0.15) ; frame1->GetYaxis()->SetTitleOffset(1.4) ; frame1->Draw() ; c->cd(3) ; gPad->SetLeftMargin(0.15) ; frame2->GetYaxis()->SetTitleOffset(1.4) ; frame2->Draw() ; }