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 "RooProdPdf.h"
00020 #include "RooAddPdf.h"
00021 #include "RooPolynomial.h"
00022 #include "TCanvas.h"
00023 #include "RooPlot.h"
00024 using namespace RooFit ;
00025
00026
00027 class TestBasic311 : public RooFitTestUnit
00028 {
00029 public:
00030 TestBasic311(TFile* refFile, Bool_t writeRef, Int_t verbose) : RooFitTestUnit("Data and p.d.f projection in sub range",refFile,writeRef,verbose) {} ;
00031 Bool_t testCode() {
00032
00033
00034
00035
00036
00037 RooRealVar x("x","x",-5,5) ;
00038 RooRealVar y("y","y",-5,5) ;
00039 RooRealVar z("z","z",-5,5) ;
00040
00041
00042 RooGaussian gx("gx","gx",x,RooConst(0),RooConst(1)) ;
00043 RooGaussian gy("gy","gy",y,RooConst(0),RooConst(1)) ;
00044 RooGaussian gz("gz","gz",z,RooConst(0),RooConst(1)) ;
00045 RooProdPdf sig("sig","sig",RooArgSet(gx,gy,gz)) ;
00046
00047
00048 RooPolynomial px("px","px",x,RooArgSet(RooConst(-0.1),RooConst(0.004))) ;
00049 RooPolynomial py("py","py",y,RooArgSet(RooConst(0.1),RooConst(-0.004))) ;
00050 RooPolynomial pz("pz","pz",z) ;
00051 RooProdPdf bkg("bkg","bkg",RooArgSet(px,py,pz)) ;
00052
00053
00054 RooRealVar fsig("fsig","signal fraction",0.1,0.,1.) ;
00055 RooAddPdf model("model","model",RooArgList(sig,bkg),fsig) ;
00056
00057 RooDataSet* data = model.generate(RooArgSet(x,y,z),20000) ;
00058
00059
00060
00061
00062
00063
00064
00065 RooPlot* frame = x.frame(Title("Projection of 3D data and pdf on X"),Bins(40)) ;
00066 data->plotOn(frame) ;
00067 model.plotOn(frame) ;
00068
00069
00070
00071
00072
00073
00074
00075 y.setRange("sigRegion",-1,1) ;
00076 z.setRange("sigRegion",-1,1) ;
00077
00078
00079 RooPlot* frame2 = x.frame(Title("Same projection on X in signal range of (Y,Z)"),Bins(40)) ;
00080
00081
00082
00083
00084 data->plotOn(frame2,CutRange("sigRegion")) ;
00085
00086
00087 model.plotOn(frame2,ProjectionRange("sigRegion")) ;
00088
00089
00090 regPlot(frame,"rf311_plot1") ;
00091 regPlot(frame2,"rf312_plot2") ;
00092
00093 delete data ;
00094
00095 return kTRUE ;
00096 }
00097 } ;