00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #ifndef __CINT__
00015 #include "RooGlobalFunc.h"
00016 #endif
00017 #include "RooRealVar.h"
00018 #include "RooDataSet.h"
00019 #include "RooGaussian.h"
00020 #include "RooConstVar.h"
00021 #include "TCanvas.h"
00022 #include "TAxis.h"
00023 #include "RooPlot.h"
00024 #include "RooHist.h"
00025 using namespace RooFit ;
00026
00027
00028 void rf109_chi2residpull()
00029 {
00030
00031
00032
00033
00034
00035 RooRealVar x("x","x",-10,10) ;
00036
00037
00038 RooRealVar sigma("sigma","sigma",3,0.1,10) ;
00039 RooRealVar mean("mean","mean",0,-10,10) ;
00040 RooGaussian gauss("gauss","gauss",x,RooConst(0),sigma) ;
00041
00042
00043 RooDataSet* data = gauss.generate(x,10000) ;
00044
00045
00046 sigma=3.15 ;
00047
00048
00049
00050
00051
00052
00053 RooPlot* frame1 = x.frame(Title("Data with distorted Gaussian pdf"),Bins(40)) ;
00054 data->plotOn(frame1,DataError(RooAbsData::SumW2)) ;
00055 gauss.plotOn(frame1) ;
00056
00057
00058
00059
00060
00061
00062
00063
00064 cout << "chi^2 = " << frame1->chiSquare() << endl ;
00065
00066
00067
00068
00069
00070
00071 RooHist* hresid = frame1->residHist() ;
00072
00073
00074 RooHist* hpull = frame1->pullHist() ;
00075
00076
00077 RooPlot* frame2 = x.frame(Title("Residual Distribution")) ;
00078 frame2->addPlotable(hresid,"P") ;
00079
00080
00081 RooPlot* frame3 = x.frame(Title("Pull Distribution")) ;
00082 frame3->addPlotable(hpull,"P") ;
00083
00084
00085
00086 TCanvas* c = new TCanvas("rf109_chi2residpull","rf109_chi2residpull",900,300) ;
00087 c->Divide(3) ;
00088 c->cd(1) ; gPad->SetLeftMargin(0.15) ; frame1->GetYaxis()->SetTitleOffset(1.6) ; frame1->Draw() ;
00089 c->cd(2) ; gPad->SetLeftMargin(0.15) ; frame2->GetYaxis()->SetTitleOffset(1.6) ; frame2->Draw() ;
00090 c->cd(3) ; gPad->SetLeftMargin(0.15) ; frame3->GetYaxis()->SetTitleOffset(1.6) ; frame3->Draw() ;
00091
00092 }