rf313_paramranges.cxx

Go to the documentation of this file.
00001 //////////////////////////////////////////////////////////////////////////
00002 //
00003 // 'MULTIDIMENSIONAL MODELS' RooFit tutorial macro #313
00004 // 
00005 // Working with parameterized ranges to define non-rectangular regions
00006 // for fitting and integration
00007 //
00008 //
00009 //
00010 // 07/2008 - Wouter Verkerke 
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 "RooPolynomial.h"
00021 #include "RooProdPdf.h"
00022 #include "TCanvas.h"
00023 #include "RooPlot.h"
00024 using namespace RooFit ;
00025 
00026 
00027 class TestBasic313 : public RooFitTestUnit
00028 {
00029 public: 
00030   TestBasic313(TFile* refFile, Bool_t writeRef, Int_t verbose) : RooFitTestUnit("Integration over non-rectangular regions",refFile,writeRef,verbose) {} ;
00031   Bool_t testCode() {
00032 
00033   // C r e a t e   3 D   p d f 
00034   // -------------------------
00035 
00036   // Define observable (x,y,z)
00037   RooRealVar x("x","x",0,10) ;
00038   RooRealVar y("y","y",0,10) ;
00039   RooRealVar z("z","z",0,10) ;
00040 
00041   // Define 3 dimensional pdf
00042   RooRealVar z0("z0","z0",-0.1,1) ;
00043   RooPolynomial px("px","px",x,RooConst(0)) ;
00044   RooPolynomial py("py","py",y,RooConst(0)) ;
00045   RooPolynomial pz("pz","pz",z,z0) ;
00046   RooProdPdf pxyz("pxyz","pxyz",RooArgSet(px,py,pz)) ;
00047 
00048 
00049 
00050   // D e f i n e d   n o n - r e c t a n g u l a r   r e g i o n   R   i n   ( x , y , z ) 
00051   // -------------------------------------------------------------------------------------
00052 
00053   //
00054   // R = Z[0 - 0.1*Y^2] * Y[0.1*X - 0.9*X] * X[0 - 10]
00055   //
00056 
00057   // Construct range parameterized in "R" in y [ 0.1*x, 0.9*x ]
00058   RooFormulaVar ylo("ylo","0.1*x",x) ;
00059   RooFormulaVar yhi("yhi","0.9*x",x) ;
00060   y.setRange("R",ylo,yhi) ;
00061 
00062   // Construct parameterized ranged "R" in z [ 0, 0.1*y^2 ]
00063   RooFormulaVar zlo("zlo","0.0*y",y) ;
00064   RooFormulaVar zhi("zhi","0.1*y*y",y) ;
00065   z.setRange("R",zlo,zhi) ;
00066 
00067 
00068 
00069   // C a l c u l a t e   i n t e g r a l   o f   n o r m a l i z e d   p d f   i n   R 
00070   // ----------------------------------------------------------------------------------
00071 
00072   // Create integral over normalized pdf model over x,y,z in "R" region
00073   RooAbsReal* intPdf = pxyz.createIntegral(RooArgSet(x,y,z),RooArgSet(x,y,z),"R") ;
00074 
00075   // Plot value of integral as function of pdf parameter z0
00076   RooPlot* frame = z0.frame(Title("Integral of pxyz over x,y,z in region R")) ;
00077   intPdf->plotOn(frame) ;
00078 
00079 
00080   regPlot(frame,"rf313_plot1") ;
00081 
00082   delete intPdf ;
00083 
00084   return kTRUE;
00085   }
00086 } ;

Generated on Tue Jul 5 15:07:50 2011 for ROOT_528-00b_version by  doxygen 1.5.1