BayesianAnalysisToolkit
0.9.3
Main Page
Namespaces
Classes
Files
File List
File Members
models
base
BATCalculator.h
Go to the documentation of this file.
1
//
2
// Author: Kyle Cranmer, Lorenzo Moneta, Gregory Schott, Wouter Verkerke, Stefan A. Schmitz
3
4
#ifndef ROOSTATS_BATCalculator
5
#define ROOSTATS_BATCalculator
6
7
#include <TNamed.h>
8
#include <TH1D.h>
9
10
#include <RooStats/IntervalCalculator.h>
11
#include <RooStats/SimpleInterval.h>
12
#include <RooStats/ModelConfig.h>
13
#include <RooStats/MCMCInterval.h>
14
15
#include <RooArgSet.h>
16
#include <RooAbsData.h>
17
#include <RooAbsPdf.h>
18
#include <RooPlot.h>
19
#include <RooAbsReal.h>
20
21
#include "
BCRooInterface.h
"
22
23
#include <map>
24
#include <vector>
25
26
27
28
namespace
RooStats
29
{
30
31
class
BATCalculator
:
public
IntervalCalculator,
public
TNamed
32
{
33
34
public
:
35
36
// constructor
37
BATCalculator
( );
38
39
BATCalculator
( RooAbsData & data,
40
RooAbsPdf & pdf,
41
RooArgSet & POI,
42
RooAbsPdf & prior,
43
RooArgSet * params = 0,
44
bool
fillChain =
false
);
45
46
47
BATCalculator
( RooAbsData & data,
48
ModelConfig & model,
49
bool
fillChain =
false
);
50
51
52
// destructor
53
virtual
~BATCalculator
();
54
55
RooPlot *
GetPosteriorPlot1D
()
const
;
56
57
// return posterior pdf
58
RooAbsPdf *
GetPosteriorPdf1D
()
const
;
59
RooAbsPdf *
GetPosteriorPdf1D
(
const
char
* POIname)
const
;
60
61
// return SimpleInterval object: central interval (one poi only)
62
virtual
SimpleInterval *
GetInterval1D
()
const
;
63
virtual
SimpleInterval *
GetInterval1D
(
const
char
* POIname)
const
;
64
//virtual SimpleInterval * GetInterval1Dv0(const char * POIname) const;
65
// return SimpleInterval object: shortest interval (not necessarily connected, one poi only)
66
SimpleInterval *
GetShortestInterval1D
()
const
;
67
SimpleInterval *
GetShortestInterval1D
(
const
char
* POIname,
bool
& checkConnected)
const
;
68
69
// temporary solution ?
70
Double_t
GetOneSidedUperLim
();
71
72
virtual
void
SetData
( RooAbsData & data )
73
{
fData
= &data;
ClearAll
(); }
74
75
virtual
void
SetModel
(
const
ModelConfig & model );
76
77
// set the size of the test (rate of Type I error) ( Eg. 0.05 for a 95% Confidence Interval)
78
virtual
void
SetTestSize
( Double_t size )
79
{
fSize
= size;
fValidInterval
=
false
; }
80
81
// set left side tail fraction (only for 1D interval, not meaningful for shortest interval)
82
void
SetLeftSideTailFraction
(Double_t leftSideFraction );
83
84
// set the confidence level for the interval (eg. 0.95 for a 95% Confidence Interval)
85
virtual
void
SetConfidenceLevel
( Double_t cl )
86
{
SetTestSize
(1.-cl); }
87
88
// Get the size of the test
89
virtual
Double_t
Size
()
const
90
{
return
fSize
; }
91
// Get left side tail fraction (only for 1D interval, not meaningful for shortest interval)
92
double
GetLeftSideTailFraction
()
93
{
return
fLeftSideFraction
;}
94
95
// Get the Confidence level for the test
96
virtual
Double_t
ConfidenceLevel
()
const
97
{
return
1.-
fSize
; }
98
99
void
SetBrfPrecision
(
double
precision )
100
{
fBrfPrecision
= precision; }
101
102
double
GetBrfPrecision
()
103
{
return
fBrfPrecision
; }
104
105
//set number of iterations per chain
106
void
SetnMCMC
(
int
nMCMC)
107
{
_nMCMC
= nMCMC; }
108
109
//return number of iterations per chain
110
int
GetnMCMC
()
111
{
return
_nMCMC
; }
112
113
BCRooInterface
*
GetBCRooInterface
()
const
114
{
return
_myRooInterface
; }
115
116
RooStats::MarkovChain *
GetRooStatsMarkovChain
()
const
117
{
return
_myRooInterface
->
GetRooStatsMarkovChain
();}
118
119
// returns MCMCInterval object
120
virtual
MCMCInterval*
GetInterval
()
const
;
121
122
//returns if last calculated shortest interval is connected (1 poi only)
123
bool
GetConnected
()
124
{
return
fConnectedInterval
; }
125
126
// returns interval borders of shortest interval (1 poi only)
127
std::vector<double>
GetIntervalBorders1D
()
128
{
return
_intervalBorders1D
; }
129
130
//returns interval borders od the last calculated shortest interval
131
132
//set the number of histogram bins for a specific parameter
133
void
SetNumBins
(
const
char
* parname,
int
nbins);
134
135
//set the number of histogram bins for all parameters
136
void
SetNumBins
(
int
nbins);
137
138
// would be more complete if we had this -> ask BAT developers to implement this functionality (not high priority)
139
//int GetNbins(const char * parname);
140
141
void
CleanCalculatorForNewData
()
142
{
ClearAll
(); }
143
144
protected
:
145
146
void
ClearAll
()
const
;
147
148
private
:
149
150
// compute the most probable value: move to public once implemented
151
// returns a RooArgSet
152
RooArgSet *
GetMode
( RooArgSet * parameters )
const
;
153
// plan to replace the above: return a SimpleInterval integrating
154
// over all other parameters except the one specified as argument
155
156
RooAbsData *
fData
;
157
RooAbsPdf *
fPdf
;
158
const
RooArgSet
fPOI
;
159
RooAbsPdf *
fPrior
;
160
const
RooArgSet *
fparams
;
161
BCRooInterface
*
_myRooInterface
;
162
mutable
TH1D *
_posteriorTH1D
;
163
164
165
mutable
RooAbsPdf *
fProductPdf
;
166
mutable
RooAbsReal *
fLogLike
;
167
mutable
RooAbsReal *
fLikelihood
;
168
mutable
RooAbsReal *
fIntegratedLikelihood
;
169
mutable
RooAbsPdf *
fPosteriorPdf
;
170
mutable
Double_t
fLower
;
171
mutable
Double_t
fUpper
;
172
double
fBrfPrecision
;
173
mutable
Bool_t
fValidInterval
;
174
mutable
Bool_t
fValidMCMCInterval
;
175
mutable
bool
fConnectedInterval
;
176
177
int
_nMCMC
;
// number of chain elements per Markov Chain
178
double
fSize
;
// size used for the interval object
179
double
fLeftSideFraction
;
//
180
mutable
std::vector<double>
_intervalBorders1D
;
181
182
protected
:
183
184
ClassDef(
BATCalculator
,1)
// BATCalculator class
185
186
};
187
188
bool
sortbyposterior
(std::pair< Int_t,Double_t > pair1, std::pair< Int_t,Double_t > pair2);
//help function for calculating the shortest interval
189
}
190
191
#endif
Generated by
1.8.4