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 "TCanvas.h"
00021 #include "RooPlot.h"
00022 #include "RooHist.h"
00023 using namespace RooFit ;
00024
00025 class TestBasic109 : public RooFitTestUnit
00026 {
00027 public:
00028 TestBasic109(TFile* refFile, Bool_t writeRef, Int_t verbose) : RooFitTestUnit("Calculation of chi^2 and residuals in plots",refFile,writeRef,verbose) {} ;
00029 Bool_t testCode() {
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 regValue(frame1->chiSquare(),"rf109_chi2") ;
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 regPlot(frame1,"rf109_plot1") ;
00085 regPlot(frame2,"rf109_plot2") ;
00086 regPlot(frame3,"rf109_plot3") ;
00087
00088 delete data ;
00089
00090
00091
00092 return kTRUE ;
00093 }
00094 } ;