Logo ROOT   6.10/09
Reference Guide
rf310_sliceplot.C
Go to the documentation of this file.
1 /// \file
2 /// \ingroup tutorial_roofit
3 /// \notebook
4 /// 'MULTIDIMENSIONAL MODELS' RooFit tutorial macro #309
5 ///
6 /// Projecting p.d.f and data slices in discrete observables
7 ///
8 /// \macro_image
9 /// \macro_output
10 /// \macro_code
11 /// \author 07/2008 - Wouter Verkerke
12 
13 #include "RooRealVar.h"
14 #include "RooDataSet.h"
15 #include "RooGaussModel.h"
16 #include "RooDecay.h"
17 #include "RooBMixDecay.h"
18 #include "RooCategory.h"
19 #include "TCanvas.h"
20 #include "TAxis.h"
21 #include "RooPlot.h"
22 using namespace RooFit ;
23 
24 
25 void rf310_sliceplot()
26 {
27 
28 
29  // C r e a t e B d e c a y p d f w it h m i x i n g
30  // ----------------------------------------------------------
31 
32  // Decay time observables
33  RooRealVar dt("dt","dt",-20,20) ;
34 
35  // Discrete observables mixState (B0tag==B0reco?) and tagFlav (B0tag==B0(bar)?)
36  RooCategory mixState("mixState","B0/B0bar mixing state") ;
37  RooCategory tagFlav("tagFlav","Flavour of the tagged B0") ;
38 
39  // Define state labels of discrete observables
40  mixState.defineType("mixed",-1) ;
41  mixState.defineType("unmixed",1) ;
42  tagFlav.defineType("B0",1) ;
43  tagFlav.defineType("B0bar",-1) ;
44 
45  // Model parameters
46  RooRealVar dm("dm","delta m(B)",0.472,0.,1.0) ;
47  RooRealVar tau("tau","B0 decay time",1.547,1.0,2.0) ;
48  RooRealVar w("w","Flavor Mistag rate",0.03,0.0,1.0) ;
49  RooRealVar dw("dw","Flavor Mistag rate difference between B0 and B0bar",0.01) ;
50 
51  // Build a gaussian resolution model
52  RooRealVar bias1("bias1","bias1",0) ;
53  RooRealVar sigma1("sigma1","sigma1",0.01) ;
54  RooGaussModel gm1("gm1","gauss model 1",dt,bias1,sigma1) ;
55 
56  // Construct a decay pdf, smeared with single gaussian resolution model
57  RooBMixDecay bmix_gm1("bmix","decay",dt,mixState,tagFlav,tau,dm,w,dw,gm1,RooBMixDecay::DoubleSided) ;
58 
59  // Generate BMixing data with above set of event errors
60  RooDataSet *data = bmix_gm1.generate(RooArgSet(dt,tagFlav,mixState),20000) ;
61 
62 
63 
64  // P l o t f u l l d e c a y d i s t r i b u t i o n
65  // ----------------------------------------------------------
66 
67  // Create frame, plot data and pdf projection (integrated over tagFlav and mixState)
68  RooPlot* frame = dt.frame(Title("Inclusive decay distribution")) ;
69  data->plotOn(frame) ;
70  bmix_gm1.plotOn(frame) ;
71 
72 
73 
74  // P l o t d e c a y d i s t r . f o r m i x e d a n d u n m i x e d s l i c e o f m i x S t a t e
75  // ------------------------------------------------------------------------------------------------------------------
76 
77  // Create frame, plot data (mixed only)
78  RooPlot* frame2 = dt.frame(Title("Decay distribution of mixed events")) ;
79  data->plotOn(frame2,Cut("mixState==mixState::mixed")) ;
80 
81  // Position slice in mixState at "mixed" and plot slice of pdf in mixstate over data (integrated over tagFlav)
82  bmix_gm1.plotOn(frame2,Slice(mixState,"mixed")) ;
83 
84  // Create frame, plot data (unmixed only)
85  RooPlot* frame3 = dt.frame(Title("Decay distribution of unmixed events")) ;
86  data->plotOn(frame3,Cut("mixState==mixState::unmixed")) ;
87 
88  // Position slice in mixState at "unmixed" and plot slice of pdf in mixstate over data (integrated over tagFlav)
89  bmix_gm1.plotOn(frame3,Slice(mixState,"unmixed")) ;
90 
91 
92 
93  TCanvas* c = new TCanvas("rf310_sliceplot","rf310_sliceplot",1200,400) ;
94  c->Divide(3) ;
95  c->cd(1) ; gPad->SetLeftMargin(0.15) ; frame->GetYaxis()->SetTitleOffset(1.4) ; gPad->SetLogy() ; frame->Draw() ;
96  c->cd(2) ; gPad->SetLeftMargin(0.15) ; frame2->GetYaxis()->SetTitleOffset(1.4) ; gPad->SetLogy() ; frame2->Draw() ;
97  c->cd(3) ; gPad->SetLeftMargin(0.15) ; frame3->GetYaxis()->SetTitleOffset(1.4) ; gPad->SetLogy() ; frame3->Draw() ;
98 
99 
100 }
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
TAxis * GetYaxis() const
Definition: RooPlot.cxx:1118
virtual RooPlot * plotOn(RooPlot *frame, const RooCmdArg &arg1=RooCmdArg::none(), 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
Plot dataset on specified frame.
Definition: RooAbsData.cxx:552
RooCmdArg Cut(const char *cutSpec)
TVirtualPad * cd(Int_t subpadnumber=0)
Set current canvas & pad.
Definition: TCanvas.cxx:679
RooCmdArg Title(const char *name)
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t tau
Definition: TRolke.cxx:630
Class RooBMixDecay is a RooAbsAnaConvPdf implementation that describes the decay of B mesons with the...
Definition: RooBMixDecay.h:23
RooRealVar represents a fundamental (non-derived) real valued object.
Definition: RooRealVar.h:36
RooDataSet is a container class to hold unbinned data.
Definition: RooDataSet.h:29
RooCategory represents a fundamental (non-derived) discrete value object.
Definition: RooCategory.h:24
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
virtual void Divide(Int_t nx=1, Int_t ny=1, Float_t xmargin=0.01, Float_t ymargin=0.01, Int_t color=0)
Automatic pad generation by division.
Definition: TPad.cxx:1135
#define gPad
Definition: TVirtualPad.h:284
RooCmdArg Slice(const RooArgSet &sliceSet)
virtual void Draw(Option_t *options=0)
Draw this plot and all of the elements it contains.
Definition: RooPlot.cxx:559
Class RooGaussModel implements a RooResolutionModel that models a Gaussian distribution.
Definition: RooGaussModel.h:26