Logo ROOT   6.10/09
Reference Guide
rf313_paramranges.C
Go to the documentation of this file.
1 /// \file
2 /// \ingroup tutorial_roofit
3 /// \notebook -js
4 /// 'MULTIDIMENSIONAL MODELS' RooFit tutorial macro #313
5 ///
6 /// Working with parametrized ranges to define non-rectangular regions
7 /// for fitting and integration
8 ///
9 /// \macro_image
10 /// \macro_output
11 /// \macro_code
12 /// \author 07/2008 - Wouter Verkerke
13 
14 
15 #include "RooRealVar.h"
16 #include "RooDataSet.h"
17 #include "RooGaussian.h"
18 #include "RooConstVar.h"
19 #include "RooPolynomial.h"
20 #include "RooProdPdf.h"
21 #include "TCanvas.h"
22 #include "TAxis.h"
23 #include "RooPlot.h"
24 using namespace RooFit ;
25 
26 
27 void rf313_paramranges()
28 {
29 
30  // C r e a t e 3 D p d f
31  // -------------------------
32 
33  // Define observable (x,y,z)
34  RooRealVar x("x","x",0,10) ;
35  RooRealVar y("y","y",0,10) ;
36  RooRealVar z("z","z",0,10) ;
37 
38  // Define 3 dimensional pdf
39  RooRealVar z0("z0","z0",-0.1,1) ;
40  RooPolynomial px("px","px",x,RooConst(0)) ;
41  RooPolynomial py("py","py",y,RooConst(0)) ;
42  RooPolynomial pz("pz","pz",z,z0) ;
43  RooProdPdf pxyz("pxyz","pxyz",RooArgSet(px,py,pz)) ;
44 
45 
46 
47  // 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 )
48  // -------------------------------------------------------------------------------------
49 
50  //
51  // R = Z[0 - 0.1*Y^2] * Y[0.1*X - 0.9*X] * X[0 - 10]
52  //
53 
54  // Construct range parametrized in "R" in y [ 0.1*x, 0.9*x ]
55  RooFormulaVar ylo("ylo","0.1*x",x) ;
56  RooFormulaVar yhi("yhi","0.9*x",x) ;
57  y.setRange("R",ylo,yhi) ;
58 
59  // Construct parametrized ranged "R" in z [ 0, 0.1*y^2 ]
60  RooFormulaVar zlo("zlo","0.0*y",y) ;
61  RooFormulaVar zhi("zhi","0.1*y*y",y) ;
62  z.setRange("R",zlo,zhi) ;
63 
64 
65 
66  // 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
67  // ----------------------------------------------------------------------------------
68 
69  // Create integral over normalized pdf model over x,y,z in "R" region
70  RooAbsReal* intPdf = pxyz.createIntegral(RooArgSet(x,y,z),RooArgSet(x,y,z),"R") ;
71 
72  // Plot value of integral as function of pdf parameter z0
73  RooPlot* frame = z0.frame(Title("Integral of pxyz over x,y,z in region R")) ;
74  intPdf->plotOn(frame) ;
75 
76 
77 
78  new TCanvas("rf313_paramranges","rf313_paramranges",600,600) ;
79  gPad->SetLeftMargin(0.15) ; frame->GetYaxis()->SetTitleOffset(1.6) ; frame->Draw() ;
80 
81  return ;
82 }
virtual void SetTitleOffset(Float_t offset=1)
Set distance between the axis and the axis title Offset is a correction factor with respect to the "s...
Definition: TAttAxis.cxx:262
virtual RooPlot * plotOn(RooPlot *frame, const RooCmdArg &arg1=RooCmdArg(), const RooCmdArg &arg2=RooCmdArg(), const RooCmdArg &arg3=RooCmdArg(), const RooCmdArg &arg4=RooCmdArg(), const RooCmdArg &arg5=RooCmdArg(), const RooCmdArg &arg6=RooCmdArg(), const RooCmdArg &arg7=RooCmdArg(), const RooCmdArg &arg8=RooCmdArg(), const RooCmdArg &arg9=RooCmdArg(), const RooCmdArg &arg10=RooCmdArg()) const
Plot (project) PDF on specified frame.
TAxis * GetYaxis() const
Definition: RooPlot.cxx:1118
RooProdPdf is an efficient implementation of a product of PDFs of the form.
Definition: RooProdPdf.h:31
RooCmdArg Title(const char *name)
Double_t x[n]
Definition: legend1.C:17
RooRealVar represents a fundamental (non-derived) real valued object.
Definition: RooRealVar.h:36
RooAbsReal * createIntegral(const RooArgSet &iset, const RooCmdArg &arg1, const RooCmdArg &arg2=RooCmdArg::none(), const RooCmdArg &arg3=RooCmdArg::none(), const RooCmdArg &arg4=RooCmdArg::none(), const RooCmdArg &arg5=RooCmdArg::none(), const RooCmdArg &arg6=RooCmdArg::none(), const RooCmdArg &arg7=RooCmdArg::none(), const RooCmdArg &arg8=RooCmdArg::none()) const
Create an object that represents the integral of the function over one or more observables listed in ...
Definition: RooAbsReal.cxx:501
A RooPlot is a plot frame and a container for graphics objects within that frame. ...
Definition: RooPlot.h:41
The Canvas class.
Definition: TCanvas.h:31
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
Definition: RooAbsReal.h:53
Double_t y[n]
Definition: legend1.C:17
you should not use this method at all Int_t Int_t z
Definition: TRolke.cxx:630
RooConstVar & RooConst(Double_t val)
#define gPad
Definition: TVirtualPad.h:284
RooPolynomial implements a polynomial p.d.f of the form By default coefficient a_0 is chosen to be 1...
Definition: RooPolynomial.h:28
virtual void Draw(Option_t *options=0)
Draw this plot and all of the elements it contains.
Definition: RooPlot.cxx:559