ROOT
6.10/09
Reference Guide
roofit
roofitcore
test
rf204_extrangefit.cxx
Go to the documentation of this file.
1
//////////////////////////////////////////////////////////////////////////
2
//
3
// 'ADDITION AND CONVOLUTION' RooFit tutorial macro #204
4
//
5
// Extended maximum likelihood fit with alternate range definition
6
// for observed number of events.
7
//
8
//
9
//
10
// 07/2008 - Wouter Verkerke
11
//
12
/////////////////////////////////////////////////////////////////////////
13
14
#ifndef __CINT__
15
#include "
RooGlobalFunc.h
"
16
#endif
17
#include "
RooRealVar.h
"
18
#include "
RooDataSet.h
"
19
#include "
RooGaussian.h
"
20
#include "
RooChebychev.h
"
21
#include "
RooAddPdf.h
"
22
#include "
RooExtendPdf.h
"
23
#include "
RooFitResult.h
"
24
#include "
TCanvas.h
"
25
#include "
RooPlot.h
"
26
using namespace
RooFit
;
27
28
29
class
TestBasic204 :
public
RooFitTestUnit
30
{
31
public
:
32
TestBasic204(TFile* refFile,
Bool_t
writeRef,
Int_t
verbose
) : RooFitTestUnit(
"Extended ML fit in sub range"
,refFile,writeRef,verbose) {} ;
33
Bool_t
testCode() {
34
35
// S e t u p c o m p o n e n t p d f s
36
// ---------------------------------------
37
38
// Declare observable x
39
RooRealVar
x
(
"x"
,
"x"
,0,10) ;
40
41
// Create two Gaussian PDFs g1(x,mean1,sigma) anf g2(x,mean2,sigma) and their parameters
42
RooRealVar
mean(
"mean"
,
"mean of gaussians"
,5) ;
43
RooRealVar
sigma1(
"sigma1"
,
"width of gaussians"
,0.5) ;
44
RooRealVar
sigma2(
"sigma2"
,
"width of gaussians"
,1) ;
45
46
RooGaussian
sig1(
"sig1"
,
"Signal component 1"
,
x
,mean,sigma1) ;
47
RooGaussian
sig2(
"sig2"
,
"Signal component 2"
,
x
,mean,sigma2) ;
48
49
// Build Chebychev polynomial p.d.f.
50
RooRealVar
a0(
"a0"
,
"a0"
,0.5,0.,1.) ;
51
RooRealVar
a1(
"a1"
,
"a1"
,-0.2,0.,1.) ;
52
RooChebychev
bkg(
"bkg"
,
"Background"
,
x
,
RooArgSet
(a0,a1)) ;
53
54
// Sum the signal components into a composite signal p.d.f.
55
RooRealVar
sig1frac(
"sig1frac"
,
"fraction of component 1 in signal"
,0.8,0.,1.) ;
56
RooAddPdf
sig(
"sig"
,
"Signal"
,
RooArgList
(sig1,sig2),sig1frac) ;
57
58
59
// C o n s t r u c t e x t e n d e d c o m p s wi t h r a n g e s p e c
60
// ------------------------------------------------------------------------------
61
62
// Define signal range in which events counts are to be defined
63
x
.setRange(
"signalRange"
,4,6) ;
64
65
// Associated nsig/nbkg as expected number of events with sig/bkg _in_the_range_ "signalRange"
66
RooRealVar
nsig(
"nsig"
,
"number of signal events in signalRange"
,500,0.,10000) ;
67
RooRealVar
nbkg(
"nbkg"
,
"number of background events in signalRange"
,500,0,10000) ;
68
RooExtendPdf
esig(
"esig"
,
"extended signal p.d.f"
,sig,nsig,
"signalRange"
) ;
69
RooExtendPdf
ebkg(
"ebkg"
,
"extended background p.d.f"
,bkg,nbkg,
"signalRange"
) ;
70
71
72
// S u m e x t e n d e d c o m p o n e n t s
73
// ---------------------------------------------
74
75
// Construct sum of two extended p.d.f. (no coefficients required)
76
RooAddPdf
model
(
"model"
,
"(g1+g2)+a"
,
RooArgList
(ebkg,esig)) ;
77
78
79
// S a m p l e d a t a , f i t m o d e l
80
// -------------------------------------------
81
82
// Generate 1000 events from model so that nsig,nbkg come out to numbers <<500 in fit
83
RooDataSet
*
data
=
model
.generate(
x
,1000) ;
84
85
86
// Perform unbinned extended ML fit to data
87
RooFitResult
*
r
=
model
.fitTo(*data,
Extended
(
kTRUE
),
Save
()) ;
88
89
90
regResult(r,
"rf204_result"
) ;
91
92
delete
data
;
93
return
kTRUE
;
94
}
95
} ;
RooGlobalFunc.h
RooAddPdf
RooAddPdf is an efficient implementation of a sum of PDFs of the form.
Definition:
RooAddPdf.h:29
RooArgSet
Definition:
RooArgSet.h:26
RooRealVar.h
ApplicationClassificationKeras.data
data
Definition:
ApplicationClassificationKeras.py:17
RooFitResult
Definition:
RooFitResult.h:40
Int_t
int Int_t
Definition:
RtypesCore.h:41
Bool_t
bool Bool_t
Definition:
RtypesCore.h:59
RooGaussian.h
RooFit::Extended
RooCmdArg Extended(Bool_t flag=kTRUE)
Definition:
RooGlobalFunc.cxx:154
x
Double_t x[n]
Definition:
legend1.C:17
RooFit
Definition:
RooCFunction1Binding.h:29
RooGaussian
Plain Gaussian p.d.f.
Definition:
RooGaussian.h:25
TCanvas.h
RooFitResult.h
RooRealVar
RooRealVar represents a fundamental (non-derived) real valued object.
Definition:
RooRealVar.h:36
r
TRandom2 r(17)
verbose
bool verbose
Definition:
binarySearchTime.cxx:27
RooAddPdf.h
RooExtendPdf.h
RooPlot.h
RooDataSet
RooDataSet is a container class to hold unbinned data.
Definition:
RooDataSet.h:29
RooDataSet.h
RooExtendPdf
Definition:
RooExtendPdf.h:22
RooFit::Save
RooCmdArg Save(Bool_t flag=kTRUE)
Definition:
RooGlobalFunc.cxx:184
RooChebychev.h
RooArgList
Definition:
RooArgList.h:21
ClassificationKeras.model
model
Definition:
ClassificationKeras.py:45
RooChebychev
Chebychev polynomial p.d.f.
Definition:
RooChebychev.h:25
kTRUE
const Bool_t kTRUE
Definition:
RtypesCore.h:91