-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rolke.C
294 lines (228 loc) · 8.82 KB
/
Rolke.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
// Example of the usage of the TRolke class
#include <iostream>
#include "TRolke.h"
void Rolke()
{
//////////////////////////////////////////////////////////
//
// The TRolke class computes the profile likelihood
// confidence limits for 7 different model assumptions
// on systematic/statistical uncertainties
//
// Author : Jan Conrad (CERN) <jan.conrad@cern.ch> 2004
// Johan Lundberg (CERN) <johan.lundberg@cern.ch> 2009
//
// Please read TRolke.cxx and TRolke.h for more docs.
// ---------- --------
//
//////////////////////////////////////////////////////
/* variables used throughout the example */
double bm;
double tau;
//int mid;
int m;
int z;
int y;
int x;
double e;
double em;
double sde;
double sdb;
double b;
double alpha; //Confidence Level
// make TRolke objects
TRolke tr; //
double ul ; // upper limit
double ll ; // lower limit
/////////////////////////////////////////////////////////////
// Model 1 assumes:
//
// Poisson uncertainty in the background estimate
// Binomial uncertainty in the efficiency estimate
//
std::cout << std::endl<<" ======================================================== " <<std::endl;
//mid =1;
x = 5; // events in the signal region
y = 10; // events observed in the background region
tau = 2.5; // ratio between size of signal/background region
m = 100; // MC events have been produced (signal)
z = 50; // MC events have been observed (signal)
alpha=0.9; //Confidence Level
tr.SetCL(alpha);
tr.SetPoissonBkgBinomEff(x,y,z,tau,m);
tr.GetLimits(ll,ul);
std::cout << "For model 1: Poisson / Binomial" << std::endl;
std::cout << "the Profile Likelihood interval is :" << std::endl;
std::cout << "[" << ll << "," << ul << "]" << std::endl;
/////////////////////////////////////////////////////////////
// Model 2 assumes:
//
// Poisson uncertainty in the background estimate
// Gaussian uncertainty in the efficiency estimate
//
std::cout << std::endl<<" ======================================================== " <<std::endl;
//mid =2;
y = 3 ; // events observed in the background region
x = 10 ; // events in the signal region
tau = 2.5; // ratio between size of signal/background region
em = 0.9; // measured efficiency
sde = 0.05; // standard deviation of efficiency
alpha =0.95; // Confidence L evel
tr.SetCL(alpha);
tr.SetPoissonBkgGaussEff(x,y,em,tau,sde);
tr.GetLimits(ll,ul);
std::cout << "For model 2 : Poisson / Gaussian" << std::endl;
std::cout << "the Profile Likelihood interval is :" << std::endl;
std::cout << "[" << ll << "," << ul << "]" << std::endl;
/////////////////////////////////////////////////////////////
// Model 3 assumes:
//
// Gaussian uncertainty in the background estimate
// Gaussian uncertainty in the efficiency estimate
//
std::cout << std::endl<<" ======================================================== " <<std::endl;
//mid =3;
bm = 5; // expected background
x = 10; // events in the signal region
sdb = 0.5; // standard deviation in background estimate
em = 0.9; // measured efficiency
sde = 0.05; // standard deviation of efficiency
alpha =0.99; // Confidence Level
tr.SetCL(alpha);
tr.SetGaussBkgGaussEff(x,bm,em,sde,sdb);
tr.GetLimits(ll,ul);
std::cout << "For model 3 : Gaussian / Gaussian" << std::endl;
std::cout << "the Profile Likelihood interval is :" << std::endl;
std::cout << "[" << ll << "," << ul << "]" << std::endl;
std::cout << "***************************************" << std::endl;
std::cout << "* some more example's for gauss/gauss *" << std::endl;
std::cout << "* *" << std::endl;
double slow,shigh;
tr.GetSensitivity(slow,shigh);
std::cout << "sensitivity:" << std::endl;
std::cout << "[" << slow << "," << shigh << "]" << std::endl;
int outx;
tr.GetLimitsQuantile(slow,shigh,outx,0.5);
std::cout << "median limit:" << std::endl;
std::cout << "[" << slow << "," << shigh << "] @ x =" << outx <<std::endl;
tr.GetLimitsML(slow,shigh,outx);
std::cout << "ML limit:" << std::endl;
std::cout << "[" << slow << "," << shigh << "] @ x =" << outx <<std::endl;
tr.GetSensitivity(slow,shigh);
std::cout << "sensitivity:" << std::endl;
std::cout << "[" << slow << "," << shigh << "]" << std::endl;
tr.GetLimits(ll,ul);
std::cout << "the Profile Likelihood interval is :" << std::endl;
std::cout << "[" << ll << "," << ul << "]" << std::endl;
int ncrt;
tr.GetCriticalNumber(ncrt);
std::cout << "critical number: " << ncrt << std::endl;
tr.SetCLSigmas(5);
tr.GetCriticalNumber(ncrt);
std::cout << "critical number for 5 sigma: " << ncrt << std::endl;
std::cout << "***************************************" << std::endl;
/////////////////////////////////////////////////////////////
// Model 4 assumes:
//
// Poisson uncertainty in the background estimate
// known efficiency
//
std::cout << std::endl<<" ======================================================== " <<std::endl;
//mid =4;
y = 7; // events observed in the background region
x = 1; // events in the signal region
tau = 5; // ratio between size of signal/background region
e = 0.25; // efficiency
alpha =0.68; // Confidence L evel
tr.SetCL(alpha);
tr.SetPoissonBkgKnownEff(x,y,tau,e);
tr.GetLimits(ll,ul);
std::cout << "For model 4 : Poissonian / Known" << std::endl;
std::cout << "the Profile Likelihood interval is :" << std::endl;
std::cout << "[" << ll << "," << ul << "]" << std::endl;
////////////////////////////////////////////////////////
// Model 5 assumes:
//
// Gaussian uncertainty in the background estimate
// Known efficiency
//
std::cout << std::endl<<" ======================================================== " <<std::endl;
//mid =5;
bm = 0; // measured background expectation
x = 1 ; // events in the signal region
e = 0.65; // known eff
sdb = 1.0; // standard deviation of background estimate
alpha =0.799999; // Confidence Level
tr.SetCL(alpha);
tr.SetGaussBkgKnownEff(x,bm,sdb,e);
tr.GetLimits(ll,ul);
std::cout << "For model 5 : Gaussian / Known" << std::endl;
std::cout << "the Profile Likelihood interval is :" << std::endl;
std::cout << "[" << ll << "," << ul << "]" << std::endl;
////////////////////////////////////////////////////////
// Model 6 assumes:
//
// Known background
// Binomial uncertainty in the efficiency estimate
//
std::cout << std::endl<<" ======================================================== " <<std::endl;
//mid =6;
b = 10; // known background
x = 25; // events in the signal region
z = 500; // Number of observed signal MC events
m = 750; // Number of produced MC signal events
alpha =0.9; // Confidence L evel
tr.SetCL(alpha);
tr.SetKnownBkgBinomEff(x, z,m,b);
tr.GetLimits(ll,ul);
std::cout << "For model 6 : Known / Binomial" << std::endl;
std::cout << "the Profile Likelihood interval is :" << std::endl;
std::cout << "[" << ll << "," << ul << "]" << std::endl;
////////////////////////////////////////////////////////
// Model 7 assumes:
//
// Known Background
// Gaussian uncertainty in the efficiency estimate
//
std::cout << std::endl<<" ======================================================== " <<std::endl;
//mid =7;
x = 15; // events in the signal region
em = 0.77; // measured efficiency
sde = 0.15; // standard deviation of efficiency estimate
b = 10; // known background
alpha =0.95; // Confidence L evel
y = 1;
tr.SetCL(alpha);
tr.SetKnownBkgGaussEff(x,em,sde,b);
tr.GetLimits(ll,ul);
std::cout << "For model 7 : Known / Gaussian " << std::endl;
std::cout << "the Profile Likelihood interval is :" << std::endl;
std::cout << "[" << ll << "," << ul << "]" << std::endl;
////////////////////////////////////////////////////////
// Example of bounded and unbounded likelihood
// Example for Model 1
///////////////////////////////////////////////////////
bm = 0.0;
tau = 5;
//mid = 1;
m = 100;
z = 90;
y = 15;
x = 0;
alpha = 0.90;
tr.SetCL(alpha);
tr.SetPoissonBkgBinomEff(x,y,z,tau,m);
tr.SetBounding(true); //bounded
tr.GetLimits(ll,ul);
std::cout << "Example of the effect of bounded vs unbounded, For model 1" << std::endl;
std::cout << "the BOUNDED Profile Likelihood interval is :" << std::endl;
std::cout << "[" << ll << "," << ul << "]" << std::endl;
tr.SetBounding(false); //unbounded
tr.GetLimits(ll,ul);
std::cout << "the UNBOUNDED Profile Likelihood interval is :" << std::endl;
std::cout << "[" << ll << "," << ul << "]" << std::endl;
}
int main(void) {
Rolke();
return 0;
}