ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
rf803_mcstudy_addons2.C
Go to the documentation of this file.
1 /// \file
2 /// \ingroup tutorial_roofit
3 /// 'VALIDATION AND MC STUDIES' RooFit tutorial macro #803
4 ///
5 /// RooMCStudy: Using the randomizer and profile likelihood add-on models
6 ///
7 ///
8 /// \macro_code
9 /// \author 07/2008 - Wouter Verkerke
10 
11 
12 #ifndef __CINT__
13 #include "RooGlobalFunc.h"
14 #endif
15 #include "RooRealVar.h"
16 #include "RooDataSet.h"
17 #include "RooGaussian.h"
18 #include "RooConstVar.h"
19 #include "RooChebychev.h"
20 #include "RooAddPdf.h"
21 #include "RooMCStudy.h"
24 #include "RooPlot.h"
25 #include "TCanvas.h"
26 #include "TAxis.h"
27 #include "TH1.h"
28 #include "TDirectory.h"
29 
30 using namespace RooFit ;
31 
32 
33 void rf803_mcstudy_addons2()
34 {
35  // C r e a t e m o d e l
36  // -----------------------
37 
38  // Simulation of signal and background of top quark decaying into
39  // 3 jets with background
40 
41  // Observable
42  RooRealVar mjjj("mjjj","m(3jet) (GeV)",100,85.,350.) ;
43 
44  // Signal component (Gaussian)
45  RooRealVar mtop("mtop","m(top)",162) ;
46  RooRealVar wtop("wtop","m(top) resolution",15.2) ;
47  RooGaussian sig("sig","top signal",mjjj,mtop,wtop) ;
48 
49  // Background component (Chebychev)
50  RooRealVar c0("c0","Chebychev coefficient 0",-0.846,-1.,1.) ;
51  RooRealVar c1("c1","Chebychev coefficient 1", 0.112,-1.,1.) ;
52  RooRealVar c2("c2","Chebychev coefficient 2", 0.076,-1.,1.) ;
53  RooChebychev bkg("bkg","combinatorial background",mjjj,RooArgList(c0,c1,c2)) ;
54 
55  // Composite model
56  RooRealVar nsig("nsig","number of signal events",53,0,1e3) ;
57  RooRealVar nbkg("nbkg","number of background events",103,0,5e3) ;
58  RooAddPdf model("model","model",RooArgList(sig,bkg),RooArgList(nsig,nbkg)) ;
59 
60 
61 
62  // C r e a t e m a n a g e r
63  // ---------------------------
64 
65  // Configure manager to perform binned extended likelihood fits (Binned(),Extended()) on data generated
66  // with a Poisson fluctuation on Nobs (Extended())
67  RooMCStudy* mcs = new RooMCStudy(model,mjjj,Binned(),Silence(),Extended(kTRUE),
69 
70 
71 
72  // C u s t o m i z e m a n a g e r
73  // ---------------------------------
74 
75  // Add module that randomizes the summed value of nsig+nbkg
76  // sampling from a uniform distribution between 0 and 1000
77  //
78  // In general one can randomize a single parameter, or a
79  // sum of N parameters, using either a uniform or a Gaussian
80  // distribution. Multiple randomization can be executed
81  // by a single randomizer module
82 
83  RooRandomizeParamMCSModule randModule ;
84  randModule.sampleSumUniform(RooArgSet(nsig,nbkg),50,500) ;
85  mcs->addModule(randModule) ;
86 
87 
88  // Add profile likelihood calculation of significance. Redo each
89  // fit while keeping parameter nsig fixed to zero. For each toy,
90  // the difference in -log(L) of both fits is stored, as well
91  // a simple significance interpretation of the delta(-logL)
92  // using Dnll = 0.5 sigma^2
93 
94  RooDLLSignificanceMCSModule sigModule(nsig,0) ;
95  mcs->addModule(sigModule) ;
96 
97 
98 
99  // R u n m a n a g e r , m a k e p l o t s
100  // ---------------------------------------------
101 
102  // Run 1000 experiments. This configuration will generate a fair number
103  // of (harmless) MINUIT warnings due to the instability of the Chebychev polynomial fit
104  // at low statistics.
105  mcs->generateAndFit(500) ;
106 
107  // Make some plots
108  TH1* dll_vs_ngen = mcs->fitParDataSet().createHistogram("ngen,dll_nullhypo_nsig",-40,-40) ;
109  TH1* z_vs_ngen = mcs->fitParDataSet().createHistogram("ngen,significance_nullhypo_nsig",-40,-40) ;
110  TH1* errnsig_vs_ngen = mcs->fitParDataSet().createHistogram("ngen,nsigerr",-40,-40) ;
111  TH1* errnsig_vs_nsig = mcs->fitParDataSet().createHistogram("nsig,nsigerr",-40,-40) ;
112 
113 
114  // Draw plots on canvas
115  TCanvas* c = new TCanvas("rf803_mcstudy_addons2","rf802_mcstudy_addons2",800,800) ;
116  c->Divide(2,2) ;
117  c->cd(1) ; gPad->SetLeftMargin(0.15) ; dll_vs_ngen->GetYaxis()->SetTitleOffset(1.6) ; dll_vs_ngen->Draw("box") ;
118  c->cd(2) ; gPad->SetLeftMargin(0.15) ; z_vs_ngen->GetYaxis()->SetTitleOffset(1.6) ; z_vs_ngen->Draw("box") ;
119  c->cd(3) ; gPad->SetLeftMargin(0.15) ; errnsig_vs_ngen->GetYaxis()->SetTitleOffset(1.6) ; errnsig_vs_ngen->Draw("box") ;
120  c->cd(4) ; gPad->SetLeftMargin(0.15) ; errnsig_vs_nsig->GetYaxis()->SetTitleOffset(1.6) ; errnsig_vs_nsig->Draw("box") ;
121 
122 
123  // Make RooMCStudy object available on command line after
124  // macro finishes
125  gDirectory->Add(mcs) ;
126 
127 }
128 
129 
130 
131 
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:245
void sampleSumUniform(const RooArgSet &paramSet, Double_t lo, Double_t hi)
Request uniform smearing of sum of parameters in paramSet uniform smearing in range [lo...
friend class RooMCStudy
Definition: RooAbsPdf.h:286
RooMCStudy is a help class to facilitate Monte Carlo studies such as 'goodness-of-fit' studies...
Definition: RooMCStudy.h:32
RooCmdArg Binned(Bool_t flag=kTRUE)
TCanvas * c1
Definition: legend1.C:2
const RooDataSet & fitParDataSet()
Return a RooDataSet the resulting fit parameters of each toy cycle.
Definition: RooMCStudy.cxx:956
RooCmdArg PrintEvalErrors(Int_t numErrors)
RooCmdArg Extended(Bool_t flag=kTRUE)
Plain Gaussian p.d.f.
Definition: RooGaussian.h:25
void addModule(RooAbsMCStudyModule &module)
Insert given RooMCStudy add-on module to the processing chain of this MCStudy object.
Definition: RooMCStudy.cxx:438
Bool_t generateAndFit(Int_t nSamples, Int_t nEvtPerSample=0, Bool_t keepGenData=kFALSE, const char *asciiFilePat=0)
Generate and fit 'nSamples' samples of 'nEvtPerSample' events.
Definition: RooMCStudy.cxx:653
friend class RooArgSet
Definition: RooAbsArg.h:469
RooCmdArg Silence(Bool_t flag=kTRUE)
RooDLLSignificanceMCSModule is an add-on modules to RooMCStudy that calculates the significance of a ...
RooCmdArg FitOptions(const char *opts)
RooRealVar represents a fundamental (non-derived) real valued object.
Definition: RooRealVar.h:37
virtual void Draw(Option_t *option="")
Draw this histogram with options.
Definition: TH1.cxx:2878
RooRandomizeParamMCSModule is an add-on modules to RooMCStudy that allows you to randomize input gene...
TAxis * GetYaxis()
Definition: TH1.h:320
return c2
Definition: legend2.C:14
The TH1 histogram class.
Definition: TH1.h:80
TH2F * createHistogram(const RooAbsRealLValue &var1, const RooAbsRealLValue &var2, const char *cuts="", const char *name="hist") const
Create a TH2F histogram of the distribution of the specified variable using this dataset.
#define gPad
Definition: TVirtualPad.h:288
#define gDirectory
Definition: TDirectory.h:221
Chebychev polynomial p.d.f.
Definition: RooChebychev.h:25
const Bool_t kTRUE
Definition: Rtypes.h:91