00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef __CINT__
00014 #include "RooGlobalFunc.h"
00015 #endif
00016 #include "RooRealVar.h"
00017 #include "RooDataSet.h"
00018 #include "RooGaussian.h"
00019 #include "RooConstVar.h"
00020 #include "RooPolynomial.h"
00021 #include "RooHistPdf.h"
00022 #include "TCanvas.h"
00023 #include "TAxis.h"
00024 #include "RooPlot.h"
00025 using namespace RooFit ;
00026
00027
00028 void rf706_histpdf()
00029 {
00030
00031
00032
00033 RooRealVar x("x","x",0,20) ;
00034 RooPolynomial p("p","p",x,RooArgList(RooConst(0.01),RooConst(-0.01),RooConst(0.0004))) ;
00035
00036
00037
00038
00039
00040
00041
00042 x.setBins(20) ;
00043 RooDataSet* data1 = p.generate(x,500) ;
00044
00045
00046 RooDataHist* hist1 = data1->binnedClone() ;
00047
00048
00049 RooHistPdf histpdf1("histpdf1","histpdf1",x,*hist1,0) ;
00050
00051
00052 RooPlot* frame1 = x.frame(Title("Low statistics histogram pdf"),Bins(100)) ;
00053 data1->plotOn(frame1) ;
00054 histpdf1.plotOn(frame1) ;
00055
00056
00057
00058
00059
00060
00061 x.setBins(10) ;
00062 RooDataSet* data2 = p.generate(x,100000) ;
00063
00064
00065 RooDataHist* hist2 = data2->binnedClone() ;
00066
00067
00068 RooHistPdf histpdf2("histpdf2","histpdf2",x,*hist2,2) ;
00069
00070
00071 RooPlot* frame2 = x.frame(Title("High stats histogram pdf with interpolation"),Bins(100)) ;
00072 data2->plotOn(frame2) ;
00073 histpdf2.plotOn(frame2) ;
00074
00075
00076 TCanvas* c = new TCanvas("rf706_histpdf","rf706_histpdf",800,400) ;
00077 c->Divide(2) ;
00078 c->cd(1) ; gPad->SetLeftMargin(0.15) ; frame1->GetYaxis()->SetTitleOffset(1.4) ; frame1->Draw() ;
00079 c->cd(2) ; gPad->SetLeftMargin(0.15) ; frame2->GetYaxis()->SetTitleOffset(1.8) ; frame2->Draw() ;
00080
00081
00082 }