Loading [MathJax]/extensions/tex2jax.js
ROOT
6.06/09
Reference Guide
ROOT Home Page
Main Page
Related Pages
User's Classes
Namespaces
All Classes
Files
Release Notes
File List
File Members
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Modules
Pages
roofit
roostats
src
ProposalHelper.cxx
Go to the documentation of this file.
1
// @(#)root/roostats:$Id$
2
// Authors: Kevin Belasco 7/22/2009
3
// Authors: Kyle Cranmer 7/22/2009
4
/*************************************************************************
5
* Copyright (C) 1995-2008, Rene Brun and Fons Rademakers. *
6
* All rights reserved. *
7
* *
8
* For the licensing terms see $ROOTSYS/LICENSE. *
9
* For the list of contributors see $ROOTSYS/README/CREDITS. *
10
*************************************************************************/
11
12
////////////////////////////////////////////////////////////////////////////////
13
14
/*
15
BEGIN_HTML
16
END_HTML
17
*/
18
//_________________________________________________
19
20
#ifndef ROOT_Rtypes
21
#include "
Rtypes.h
"
22
#endif
23
#ifndef RooStats_ProposalHelper
24
#include "
RooStats/ProposalHelper.h
"
25
#endif
26
#ifndef ROOSTATS_PdfProposal
27
#include "
RooStats/PdfProposal.h
"
28
#endif
29
#ifndef RooStats_RooStatsUtils
30
#include "
RooStats/RooStatsUtils.h
"
31
#endif
32
#ifndef ROO_ARG_SET
33
#include "
RooArgSet.h
"
34
#endif
35
#ifndef ROO_DATA_SET
36
#include "
RooDataSet.h
"
37
#endif
38
#ifndef ROO_ABS_PDF
39
#include "
RooAbsPdf.h
"
40
#endif
41
#ifndef ROO_ADD_PDF
42
#include "
RooAddPdf.h
"
43
#endif
44
#ifndef ROO_KEYS_PDF
45
#include "
RooNDKeysPdf.h
"
46
#endif
47
#ifndef ROO_UNIFORM
48
#include "
RooUniform.h
"
49
#endif
50
#ifndef ROO_MSG_SERVICE
51
#include "
RooMsgService.h
"
52
#endif
53
#ifndef ROO_REAL_VAR
54
#include "
RooRealVar.h
"
55
#endif
56
#ifndef ROOT_TIterator
57
#include "
TIterator.h
"
58
#endif
59
#ifndef ROO_MULTI_VAR_GAUSSIAN
60
#include "
RooMultiVarGaussian.h
"
61
#endif
62
#ifndef ROO_CONST_VAR
63
#include "
RooConstVar.h
"
64
#endif
65
#ifndef ROOT_TString
66
#include "
TString.h
"
67
#endif
68
69
#include <map>
70
71
ClassImp
(
RooStats::ProposalHelper
);
72
73
using namespace
RooFit
;
74
using namespace
RooStats
;
75
using namespace
std
;
76
77
//static const Double_t DEFAULT_UNI_FRAC = 0.10;
78
static
const
Double_t
DEFAULT_CLUES_FRAC
= 0.20;
79
//static const Double_t SIGMA_RANGE_DIVISOR = 6;
80
static
const
Double_t
SIGMA_RANGE_DIVISOR
= 5;
81
//static const Int_t DEFAULT_CACHE_SIZE = 100;
82
//static const Option_t* CLUES_OPTIONS = "a";
83
84
ProposalHelper::ProposalHelper()
85
{
86
fPdfProp =
new
PdfProposal
();
87
fVars =
NULL
;
88
fOwnsPdfProp =
kTRUE
;
89
fOwnsPdf =
kFALSE
;
90
fOwnsCluesPdf =
kFALSE
;
91
fOwnsVars =
kFALSE
;
92
fUseUpdates =
kFALSE
;
93
fPdf =
NULL
;
94
fSigmaRangeDivisor =
SIGMA_RANGE_DIVISOR
;
95
fCluesPdf =
NULL
;
96
fUniformPdf =
NULL
;
97
fClues =
NULL
;
98
fCovMatrix =
NULL
;
99
fCluesFrac = -1;
100
fUniFrac = -1;
101
fCacheSize = -1;
102
fCluesOptions =
NULL
;
103
}
104
105
ProposalFunction
* ProposalHelper::GetProposalFunction()
106
{
107
if
(fPdf ==
NULL
)
108
CreatePdf();
109
// kbelasco: check here for memory leaks: does RooAddPdf make copies or
110
// take ownership of components, coeffs
111
RooArgList
* components =
new
RooArgList
();
112
RooArgList
* coeffs =
new
RooArgList
();
113
if
(fCluesPdf ==
NULL
)
114
CreateCluesPdf();
115
if
(fCluesPdf !=
NULL
) {
116
if
(fCluesFrac < 0)
117
fCluesFrac =
DEFAULT_CLUES_FRAC
;
118
printf
(
"added clues from dataset %s with fraction %g\n"
,
119
fClues->GetName(), fCluesFrac);
120
components->
add
(*fCluesPdf);
121
coeffs->
add
(
RooConst
(fCluesFrac));
122
}
123
if
(fUniFrac > 0.) {
124
CreateUniformPdf();
125
components->
add
(*fUniformPdf);
126
coeffs->
add
(
RooConst
(fUniFrac));
127
}
128
components->
add
(*fPdf);
129
RooAddPdf
* addPdf =
new
RooAddPdf
(
"proposalFunction"
,
"Proposal Density"
,
130
*components, *coeffs);
131
fPdfProp->SetPdf(*addPdf);
132
fPdfProp->SetOwnsPdf(
kTRUE
);
133
if
(fCacheSize > 0)
134
fPdfProp->SetCacheSize(fCacheSize);
135
fOwnsPdfProp =
kFALSE
;
136
return
fPdfProp;
137
}
138
139
void
ProposalHelper::CreatePdf()
140
{
141
// kbelasco: check here for memory leaks:
142
// does RooMultiVarGaussian make copies of xVec and muVec?
143
// or should we delete them?
144
if
(fVars ==
NULL
) {
145
coutE
(
InputArguments
) <<
"ProposalHelper::CreatePdf(): "
<<
146
"Variables to create proposal function for are not set."
<< endl;
147
return
;
148
}
149
RooArgList
* xVec =
new
RooArgList
();
150
RooArgList
* muVec =
new
RooArgList
();
151
TIterator
* it = fVars->createIterator();
152
RooRealVar
*
r
;
153
RooRealVar
* clone;
154
while
((r = (
RooRealVar
*)it->
Next
()) !=
NULL
) {
155
xVec->
add
(*r);
156
TString
cloneName =
TString::Format
(
"%s%s"
,
"mu__"
, r->
GetName
());
157
clone = (
RooRealVar
*)r->
clone
(cloneName.
Data
());
158
muVec->
add
(*clone);
159
if
(fUseUpdates)
160
fPdfProp->AddMapping(*clone, *r);
161
}
162
if
(fCovMatrix ==
NULL
)
163
CreateCovMatrix(*xVec);
164
fPdf =
new
RooMultiVarGaussian
(
"mvg"
,
"MVG Proposal"
, *xVec, *muVec,
165
*fCovMatrix);
166
delete
xVec;
167
delete
muVec;
168
delete
it;
169
}
170
171
void
ProposalHelper::CreateCovMatrix(
RooArgList
& xVec)
172
{
173
Int_t
size = xVec.
getSize
();
174
fCovMatrix =
new
TMatrixDSym
(size);
175
RooRealVar
*
r
;
176
for
(
Int_t
i = 0; i < size; i++) {
177
r = (
RooRealVar
*)xVec.
at
(i);
178
Double_t
range = r->
getMax
() - r->
getMin
();
179
(*fCovMatrix)(i,i) = range / fSigmaRangeDivisor;
180
}
181
}
182
183
void
ProposalHelper::CreateCluesPdf()
184
{
185
if
(fClues !=
NULL
) {
186
if
(fCluesOptions ==
NULL
)
187
fCluesPdf =
new
RooNDKeysPdf
(
"cluesPdf"
,
"Clues PDF"
, *fVars, *fClues);
188
else
189
fCluesPdf =
new
RooNDKeysPdf
(
"cluesPdf"
,
"Clues PDF"
, *fVars, *fClues,
190
fCluesOptions);
191
}
192
}
193
194
void
ProposalHelper::CreateUniformPdf()
195
{
196
fUniformPdf =
new
RooUniform
(
"uniform"
,
"Uniform Proposal PDF"
,
197
RooArgSet
(*fVars));
198
}
RooAddPdf
Definition:
RooAddPdf.h:29
RooStats::ProposalFunction
ProposalFunction is an interface for all proposal functions that would be used with a Markov Chain Mo...
Definition:
ProposalFunction.h:51
coutE
#define coutE(a)
Definition:
RooMsgService.h:35
RooAbsCollection::add
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE)
Add the specified argument to list.
Definition:
RooAbsCollection.cxx:454
RooArgSet.h
Rtypes.h
DEFAULT_CLUES_FRAC
static const Double_t DEFAULT_CLUES_FRAC
Definition:
ProposalHelper.cxx:78
RooArgSet
Definition:
RooArgSet.h:26
RooRealVar.h
TString
Basic string class.
Definition:
TString.h:137
RooMsgService.h
RooAbsRealLValue::getMin
virtual Double_t getMin(const char *name=0) const
Definition:
RooAbsRealLValue.h:73
Int_t
int Int_t
Definition:
RtypesCore.h:41
kFALSE
const Bool_t kFALSE
Definition:
Rtypes.h:92
std
STL namespace.
TIterator
Iterator abstract base class.
Definition:
TIterator.h:32
RooNDKeysPdf.h
TString::Data
const char * Data() const
Definition:
TString.h:349
RooUniform.h
TString::Format
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString...
Definition:
TString.cxx:2334
RooFit
Definition:
RooCFunction1Binding.h:26
RooStatsUtils.h
RooAbsPdf.h
TIterator.h
PdfProposal.h
RooRealVar
Definition:
RooRealVar.h:37
TString.h
RooConstVar.h
r
ROOT::R::TRInterface & r
Definition:
Object.C:4
RooMultiVarGaussian.h
RooAddPdf.h
TNamed::GetName
virtual const char * GetName() const
Returns name of object.
Definition:
TNamed.h:51
RooStats::ProposalHelper
Definition:
ProposalHelper.h:44
SIGMA_RANGE_DIVISOR
static const Double_t SIGMA_RANGE_DIVISOR
Definition:
ProposalHelper.cxx:80
RooUniform
Definition:
RooUniform.h:24
RooNDKeysPdf
Definition:
RooNDKeysPdf.h:45
ClassImp
ClassImp(RooStats::ProposalHelper)
RooMultiVarGaussian
Definition:
RooMultiVarGaussian.h:31
RooStats
Namespace for the RooStats classes.
Definition:
Asimov.h:20
RooArgList::at
RooAbsArg * at(Int_t idx) const
Definition:
RooArgList.h:84
Double_t
double Double_t
Definition:
RtypesCore.h:55
TMatrixDSym
TMatrixTSym< Double_t > TMatrixDSym
Definition:
TMatrixDSymfwd.h:24
printf
ClassImp(TMCParticle) void TMCParticle printf(": p=(%7.3f,%7.3f,%9.3f) ;", fPx, fPy, fPz)
RooStats::PdfProposal
PdfProposal is a concrete implementation of the ProposalFunction interface.
Definition:
PdfProposal.h:85
RooDataSet.h
RooAbsRealLValue::getMax
virtual Double_t getMax(const char *name=0) const
Definition:
RooAbsRealLValue.h:74
RooRealVar::clone
virtual TObject * clone(const char *newname) const
Definition:
RooRealVar.h:48
RooFit::RooConst
RooConstVar & RooConst(Double_t val)
Definition:
RooGlobalFunc.cxx:337
TIterator::Next
virtual TObject * Next()=0
NULL
#define NULL
Definition:
Rtypes.h:82
RooArgList
Definition:
RooArgList.h:21
RooFit::InputArguments
Definition:
RooGlobalFunc.h:58
RooAbsCollection::getSize
Int_t getSize() const
Definition:
RooAbsCollection.h:106
ProposalHelper.h
kTRUE
const Bool_t kTRUE
Definition:
Rtypes.h:91