1 |
#include "Model.h"
|
2 |
#include<vector>
|
3 |
#include<string>
|
4 |
#include<sstream>
|
5 |
#include "RooFit.h"
|
6 |
#include "RooAbsPdf.h"
|
7 |
#include "RooProdPdf.h"
|
8 |
#include "RooPoisson.h"
|
9 |
#include "RooGaussian.h"
|
10 |
#include "RooLognormal.h"
|
11 |
#include "RooRealVar.h"
|
12 |
#include "RooConstVar.h"
|
13 |
#include "RooFormulaVar.h"
|
14 |
#include "RooArgSet.h"
|
15 |
#include "RooPolynomial.h"
|
16 |
#include "RooArgList.h"
|
17 |
#include "RooDataSet.h"
|
18 |
#include "RooNLLVar.h"
|
19 |
#include "TMath.h"
|
20 |
#include "RooRandom.h"
|
21 |
#include "RooPlot.h"
|
22 |
#include "RooGamma.h"
|
23 |
#include "RooRealVar.h"
|
24 |
#include "RooAbsReal.h"
|
25 |
#include <iostream>
|
26 |
#include <fstream>
|
27 |
#include <istream>
|
28 |
#include <cstdlib>
|
29 |
#include <cstdarg>
|
30 |
#include <cstring>
|
31 |
#include <cstdio>
|
32 |
#include"TCanvas.h"
|
33 |
#include"TFile.h"
|
34 |
#include"TH1F.h"
|
35 |
|
36 |
#include "RooStats/BayesianCalculator.h"
|
37 |
#include "RooStats/ProfileLikelihoodCalculator.h"
|
38 |
#include "RooStats/LikelihoodIntervalPlot.h"
|
39 |
#include "Model.h"
|
40 |
#include "RooStats/HybridCalculatorOriginal.h"
|
41 |
#include "RooStats/HybridResult.h"
|
42 |
#include "RooStats/HybridPlot.h"
|
43 |
#include "RooStats/ModelConfig.h"
|
44 |
#include "RooStats/FeldmanCousins.h"
|
45 |
#include "RooStats/ToyMCSampler.h"
|
46 |
#include "RooStats/PointSetInterval.h"
|
47 |
#include "RooStats/ConfidenceBelt.h"
|
48 |
#include "RooWorkspace.h"
|
49 |
#include "RooStats/HypoTestInverter.h"
|
50 |
#include "RooStats/HypoTestInverterResult.h"
|
51 |
#include "RooStats/HypoTestPlot.h"
|
52 |
|
53 |
#include "RooStats/MCMCCalculator.h"
|
54 |
#include "RooStats/MCMCInterval.h"
|
55 |
#include "RooStats/MCMCIntervalPlot.h"
|
56 |
|
57 |
|
58 |
|
59 |
using namespace std;
|
60 |
using namespace RooFit;
|
61 |
using namespace RooStats;
|
62 |
|
63 |
|
64 |
string int_to_string(int i){
|
65 |
std::stringstream out;
|
66 |
out << i;
|
67 |
return out.str();
|
68 |
|
69 |
};
|
70 |
|
71 |
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
72 |
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
73 |
Model::Model():n_channels(0),n_backgrounds(0),n_nuisances(0),range_nuisances(-1),range_POI(-1),range_n_obs(-1),use_nuisances(false),corrupted(true)
|
74 |
{
|
75 |
POI_set=0;
|
76 |
observable_set=0;
|
77 |
nuisance_set=0;
|
78 |
nuisance_prior_pdf=0;
|
79 |
POI_prior_pdf=0;
|
80 |
|
81 |
POI=0;
|
82 |
signal=0;
|
83 |
background=0;
|
84 |
observables=0;
|
85 |
nuisance_names=0;
|
86 |
nuisance_upper_limit=0;
|
87 |
nuisance_parameters=0;
|
88 |
nuisance_widths=0;
|
89 |
scaling_factors=0;
|
90 |
nuisance_priors=0;
|
91 |
sb_means=0;
|
92 |
b_means=0;
|
93 |
sb_poissons=0;
|
94 |
b_poissons=0;
|
95 |
sb_likelihood=0;
|
96 |
b_likelihood=0;
|
97 |
data=0;
|
98 |
}
|
99 |
|
100 |
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
101 |
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
102 |
Model::Model(ConfigFile* bkgConfig, ConfigFile* sigConfig, int selectChannel) {
|
103 |
|
104 |
POI_set=0;
|
105 |
observable_set=0;
|
106 |
nuisance_set=0;
|
107 |
nuisance_prior_pdf=0;
|
108 |
POI_prior_pdf=0;
|
109 |
|
110 |
POI=0;
|
111 |
signal=0;
|
112 |
background=0;
|
113 |
observables=0;
|
114 |
nuisance_names=0;
|
115 |
nuisance_upper_limit=0;
|
116 |
nuisance_parameters=0;
|
117 |
nuisance_widths=0;
|
118 |
scaling_factors=0;
|
119 |
nuisance_priors=0;
|
120 |
sb_means=0;
|
121 |
b_means=0;
|
122 |
sb_poissons=0;
|
123 |
b_poissons=0;
|
124 |
sb_likelihood=0;
|
125 |
b_likelihood=0;
|
126 |
data=0;
|
127 |
nuisance_means=0;
|
128 |
|
129 |
//store the input from the background and data file here
|
130 |
vector<double> *signal_expectation =new vector<double>;
|
131 |
vector< vector<double>* > *background_expectations =new vector< vector<double>* >;
|
132 |
vector< vector< vector<double>* >* >* systematic_uncertainties=0;
|
133 |
vector<int> *n_input=new vector<int>;
|
134 |
|
135 |
//read [definitions]
|
136 |
this->n_channels = bkgConfig->Value("definitions","n_channels");
|
137 |
this->n_backgrounds = bkgConfig->Value("definitions","n_backgrounds");
|
138 |
this->n_nuisances = bkgConfig->Value("definitions","n_nuisance");
|
139 |
this->range_nuisances= bkgConfig->Value("definitions","nuisance_range");
|
140 |
this->range_POI= bkgConfig->Value("definitions","parameter_of_interest_range");
|
141 |
this->range_n_obs= bkgConfig->Value("definitions","observation_range");
|
142 |
this->lumiScale= bkgConfig->Value("definitions","lumi_scale",1);
|
143 |
|
144 |
bool sepStatUnc = bkgConfig->Value("definitions","seperate_stat_unc",false);
|
145 |
bool sumSigUnc = bkgConfig->Value("definitions","sum_signal_unc",false);
|
146 |
|
147 |
|
148 |
if( n_channels != sigConfig->Value("definitions","n_channels") ) {
|
149 |
cout<<"n_channels don't match for background and signal!!!"<<endl;
|
150 |
exit(-1);
|
151 |
}
|
152 |
if( n_nuisances < sigConfig->Value("definitions","n_nuisance") ) {
|
153 |
cout<<"n_nuisances don't match for background and signal!!!"<<endl;
|
154 |
exit(-1);
|
155 |
}
|
156 |
|
157 |
|
158 |
if(selectChannel > 0 ) this->n_channels = 1;
|
159 |
|
160 |
//read [observation]
|
161 |
//fill the vector with the observations
|
162 |
for(int i=1;i<=n_channels;i++){
|
163 |
string value_id = (string)"n"+int_to_string(i);
|
164 |
if(selectChannel > 0 ) value_id = (string)"n"+int_to_string(selectChannel);
|
165 |
int value = bkgConfig->Value("observation",value_id.c_str());
|
166 |
// cout<<value_id.c_str()<<" "<<value<<endl;
|
167 |
n_input->push_back(int(value*lumiScale+0.5));
|
168 |
}
|
169 |
|
170 |
sumS=0;
|
171 |
//read [signal yield]
|
172 |
//fill the vector with the signal expectations
|
173 |
for(int i=1;i<=n_channels;i++){
|
174 |
string value_id = (string)"s"+int_to_string(i);
|
175 |
if(selectChannel > 0 ) value_id = (string)"s"+int_to_string(selectChannel);
|
176 |
double value = sigConfig->Value("signal_yield",value_id.c_str());
|
177 |
// cout<<value_id.c_str()<<" "<<value<<endl;
|
178 |
signal_expectation->push_back(value*lumiScale);
|
179 |
sumS += value*lumiScale;
|
180 |
}
|
181 |
|
182 |
sumB=0;
|
183 |
//read [background_yield_n]
|
184 |
//fill the vectors with the background expectations
|
185 |
for(int i=1;i<=n_backgrounds;i++){
|
186 |
string section_id = (string)"background_yield_" + int_to_string(i);
|
187 |
vector<double>* background_yield = new vector<double>;
|
188 |
for(int j=1;j<=n_channels;j++){
|
189 |
string value_id = (string)"b" + int_to_string(j);
|
190 |
if(selectChannel > 0 ) value_id = (string)"b"+int_to_string(selectChannel);
|
191 |
double value = bkgConfig->Value(section_id.c_str(),value_id.c_str());
|
192 |
// cout<<value_id.c_str()<<" "<<value<<endl;
|
193 |
background_yield->push_back(value*lumiScale);
|
194 |
sumB += value*lumiScale;
|
195 |
}
|
196 |
background_expectations->push_back(background_yield);
|
197 |
}
|
198 |
|
199 |
|
200 |
sumBerr=0;
|
201 |
//read [nuisance_n]
|
202 |
//fill the object for the systematic uncertainties
|
203 |
if(this->n_nuisances==0){
|
204 |
systematic_uncertainties=0;
|
205 |
}
|
206 |
else{
|
207 |
systematic_uncertainties=new vector< vector< vector<double>* >* >;
|
208 |
this->nuisance_names=new vector<string>;
|
209 |
this->nuisance_upper_limit=new vector<double>;
|
210 |
//read [nuisance_n]
|
211 |
vector<double>* sum_yield = new vector<double>;
|
212 |
for(int w=0;w<n_channels;w++)
|
213 |
sum_yield->push_back(0);
|
214 |
|
215 |
for(int i=1;i<=n_nuisances;i++){
|
216 |
|
217 |
string section_id = (string)"nuisance_" + int_to_string(i);
|
218 |
string name = bkgConfig->Value(section_id.c_str(),"name");
|
219 |
string name_compare = sigConfig->Value(section_id.c_str(),"name","");
|
220 |
|
221 |
if(name_compare== "") {
|
222 |
cout<<"nuisance name "<<name<<" not found, set to 0 for signal!"<<endl;
|
223 |
|
224 |
} else if( name != name_compare){
|
225 |
cout<<"nuisance names don't match for background and signal!!!"<<endl;
|
226 |
cout<<"background n"<<i<<" has name: "<< name<<endl;
|
227 |
cout<<"signal n"<<i<<" has name: "<< name_compare<<endl;
|
228 |
exit(-1);
|
229 |
}
|
230 |
|
231 |
if( !sepStatUnc || name.find("BKG_MC_") == string::npos ) {
|
232 |
|
233 |
vector< vector<double>* >* nuisance_yields=new vector<vector<double>*>;
|
234 |
vector<double>* nuisance_yield = new vector<double>;
|
235 |
for(int j=1;j<=n_channels;j++){
|
236 |
string value_id = (string)"sigma_s_" + int_to_string(j);
|
237 |
if(selectChannel > 0 ) value_id = (string)"sigma_s_"+int_to_string(selectChannel);
|
238 |
double value = sigConfig->Value(section_id.c_str(),value_id.c_str(),0);
|
239 |
if(name.find("_MC_")==string::npos)
|
240 |
nuisance_yield->push_back(value);
|
241 |
else
|
242 |
nuisance_yield->push_back(value/sqrt(lumiScale));
|
243 |
// cout<<value_id.c_str()<<" "<<value<<endl;
|
244 |
}
|
245 |
if(name.find("BKG_")==string::npos&&sumSigUnc) {
|
246 |
|
247 |
for(int j=0;j<n_channels;j++){
|
248 |
sum_yield->at(j) += pow(nuisance_yield->at(j),2);
|
249 |
}
|
250 |
} else {
|
251 |
this->nuisance_names->push_back(name);
|
252 |
//upper range for uncertainties -> (X*sigma)
|
253 |
double upper_limit= bkgConfig->Value(section_id.c_str(),"upper_limit");
|
254 |
this->nuisance_upper_limit->push_back(upper_limit);
|
255 |
|
256 |
nuisance_yields->push_back(nuisance_yield);
|
257 |
for(int k=1;k<=n_backgrounds;k++){
|
258 |
vector<double>* nuisance_yield = new vector<double>;
|
259 |
for(int j=1;j<=n_channels;j++){
|
260 |
string value_id = (string)"sigma_b" + int_to_string(k) + "_" + int_to_string(j);
|
261 |
if(selectChannel > 0 ) value_id = (string)"sigma_b" + int_to_string(k) + "_" + int_to_string(selectChannel);
|
262 |
double value = bkgConfig->Value(section_id.c_str(),value_id.c_str());
|
263 |
if(name.find("_MC_")==string::npos) {
|
264 |
nuisance_yield->push_back(value);
|
265 |
sumBerr += pow(value,2);
|
266 |
} else {
|
267 |
nuisance_yield->push_back(value/sqrt(lumiScale));
|
268 |
sumBerr += pow(value/sqrt(lumiScale),2);
|
269 |
}
|
270 |
// cout<<value_id.c_str()<<" "<<value<<endl;
|
271 |
}
|
272 |
nuisance_yields->push_back(nuisance_yield);
|
273 |
}
|
274 |
systematic_uncertainties->push_back(nuisance_yields);
|
275 |
}
|
276 |
} else {
|
277 |
for(int t=1;t<=n_channels;t++){
|
278 |
|
279 |
vector< vector<double>* >* nuisance_yields=new vector<vector<double>*>;
|
280 |
|
281 |
this->nuisance_names->push_back(name+ "_" + int_to_string(t));
|
282 |
//upper range for uncertainties -> (X*sigma)
|
283 |
double upper_limit= bkgConfig->Value(section_id.c_str(),"upper_limit");
|
284 |
this->nuisance_upper_limit->push_back(upper_limit);
|
285 |
|
286 |
vector<double>* nuisance_yield = new vector<double>;
|
287 |
for(int j=1;j<=n_channels;j++){
|
288 |
nuisance_yield->push_back(0);
|
289 |
}
|
290 |
nuisance_yields->push_back(nuisance_yield);
|
291 |
for(int k=1;k<=n_backgrounds;k++){
|
292 |
vector<double>* nuisance_yield = new vector<double>;
|
293 |
for(int j=1;j<=n_channels;j++){
|
294 |
string value_id = (string)"sigma_b" + int_to_string(k) + "_" + int_to_string(j);
|
295 |
if(selectChannel > 0 ) value_id = (string)"sigma_b" + int_to_string(k) + "_" + int_to_string(selectChannel);
|
296 |
double value = bkgConfig->Value(section_id.c_str(),value_id.c_str());
|
297 |
if(t==j) {
|
298 |
nuisance_yield->push_back(value/sqrt(lumiScale));
|
299 |
sumBerr += pow(value/sqrt(lumiScale),2);
|
300 |
} else nuisance_yield->push_back(0);
|
301 |
// cout<<value_id.c_str()<<" "<<value<<endl;
|
302 |
}
|
303 |
nuisance_yields->push_back(nuisance_yield);
|
304 |
}
|
305 |
systematic_uncertainties->push_back(nuisance_yields);
|
306 |
}
|
307 |
}
|
308 |
}
|
309 |
|
310 |
|
311 |
if(sumSigUnc) {
|
312 |
|
313 |
this->nuisance_names->push_back("SUM_SIG_UNC");
|
314 |
this->nuisance_upper_limit->push_back(5);
|
315 |
vector< vector<double>* >* nuisance_yields=new vector<vector<double>*>;
|
316 |
vector<double>* nuisance_yield = new vector<double>;
|
317 |
for(int j=0;j<n_channels;j++){
|
318 |
nuisance_yield->push_back( sqrt(sum_yield->at(j)) );
|
319 |
}
|
320 |
nuisance_yields->push_back(nuisance_yield);
|
321 |
for(int k=1;k<=n_backgrounds;k++){
|
322 |
vector<double>* nuisance_yield = new vector<double>;
|
323 |
for(int j=1;j<=n_channels;j++){
|
324 |
nuisance_yield->push_back(0);
|
325 |
}
|
326 |
nuisance_yields->push_back(nuisance_yield);
|
327 |
}
|
328 |
systematic_uncertainties->push_back(nuisance_yields);
|
329 |
}
|
330 |
|
331 |
//rescale num of nuisance parameters
|
332 |
n_nuisances = systematic_uncertainties->size();
|
333 |
|
334 |
}
|
335 |
|
336 |
check_input(n_input,signal_expectation,background_expectations,systematic_uncertainties);
|
337 |
|
338 |
if(systematic_uncertainties==0){
|
339 |
use_nuisances=false;
|
340 |
}
|
341 |
else use_nuisances=true;
|
342 |
|
343 |
create_POI();
|
344 |
create_observables();
|
345 |
create_signal_expectations(signal_expectation);
|
346 |
create_background_expectations(background_expectations);
|
347 |
create_nuisances(systematic_uncertainties);
|
348 |
create_scaling_factors(systematic_uncertainties);
|
349 |
create_POI_prior();
|
350 |
|
351 |
create_nuisance_priors();
|
352 |
create_sb_likelihood();
|
353 |
create_b_likelihood();
|
354 |
create_dataset(n_input);
|
355 |
|
356 |
create_pseudo_datasets(signal_expectation,background_expectations,systematic_uncertainties);
|
357 |
|
358 |
create_teststats();
|
359 |
|
360 |
}
|
361 |
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
362 |
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
363 |
Model::Model(std::vector<double>* signal_expectation,std::vector< std::vector<double>* >* background_expectation,std::vector< vector< vector<double>* >* >* systematic_uncertainties,std::vector<double>* nuisance_upper_limits,std::vector<int>* n_input,int nuisance_range,int POI_range,int observation_range):n_channels(signal_expectation->size()),n_backgrounds(background_expectation->size()),n_nuisances(systematic_uncertainties->size()),range_nuisances(nuisance_range),range_POI(POI_range),range_n_obs(observation_range){
|
364 |
|
365 |
POI_set=0;
|
366 |
observable_set=0;
|
367 |
nuisance_set=0;
|
368 |
nuisance_prior_pdf=0;
|
369 |
POI_prior_pdf=0;
|
370 |
|
371 |
POI=0;
|
372 |
signal=0;
|
373 |
background=0;
|
374 |
observables=0;
|
375 |
nuisance_names=0;
|
376 |
nuisance_parameters=0;
|
377 |
nuisance_widths=0;
|
378 |
scaling_factors=0;
|
379 |
nuisance_priors=0;
|
380 |
sb_means=0;
|
381 |
b_means=0;
|
382 |
sb_poissons=0;
|
383 |
b_poissons=0;
|
384 |
sb_likelihood=0;
|
385 |
b_likelihood=0;
|
386 |
data=0;
|
387 |
nuisance_means=0;
|
388 |
|
389 |
|
390 |
nuisance_upper_limit=nuisance_upper_limits;
|
391 |
|
392 |
check_input(n_input,signal_expectation,background_expectation,systematic_uncertainties);
|
393 |
if(systematic_uncertainties==0){
|
394 |
use_nuisances=false;
|
395 |
}
|
396 |
else use_nuisances=true;
|
397 |
create_POI();
|
398 |
create_observables();
|
399 |
create_signal_expectations(signal_expectation);
|
400 |
create_background_expectations(background_expectation);
|
401 |
create_nuisances(systematic_uncertainties);
|
402 |
create_scaling_factors(systematic_uncertainties);
|
403 |
create_POI_prior();
|
404 |
create_nuisance_priors();
|
405 |
create_sb_likelihood();
|
406 |
create_b_likelihood();
|
407 |
if(n_input!=0){
|
408 |
create_dataset(n_input);
|
409 |
}
|
410 |
|
411 |
|
412 |
}
|
413 |
|
414 |
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
415 |
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
416 |
Model::~Model(){
|
417 |
if(data!=0){
|
418 |
delete data;
|
419 |
}
|
420 |
// cout<<"deleted"<<endl;
|
421 |
if(b_likelihood!=0){
|
422 |
delete b_likelihood;
|
423 |
}
|
424 |
// cout<<"deleted"<<endl;
|
425 |
if(sb_likelihood!=0){
|
426 |
delete sb_likelihood;
|
427 |
}
|
428 |
// cout<<"deleted"<<endl;
|
429 |
if(b_poissons!=0){
|
430 |
for(unsigned i=0;i<b_poissons->size();i++){
|
431 |
delete b_poissons->at(i);
|
432 |
}
|
433 |
delete b_poissons;
|
434 |
}
|
435 |
// cout<<"deleted"<<endl;
|
436 |
if(sb_poissons!=0){
|
437 |
for(unsigned i=0;i<sb_poissons->size();i++){
|
438 |
delete sb_poissons->at(i);
|
439 |
}
|
440 |
delete sb_poissons;
|
441 |
}
|
442 |
// cout<<"deleted"<<endl;
|
443 |
if(b_means!=0){
|
444 |
for(unsigned i=0;i<b_means->size();i++){
|
445 |
delete b_means->at(i);
|
446 |
}
|
447 |
delete b_means;
|
448 |
}
|
449 |
// cout<<"deleted"<<endl;
|
450 |
if(sb_means!=0){
|
451 |
for(unsigned i=0;i<sb_means->size();i++){
|
452 |
delete sb_means->at(i);
|
453 |
}
|
454 |
delete sb_means;
|
455 |
}
|
456 |
// cout<<"deleted"<<endl;
|
457 |
if(nuisance_priors!=0){
|
458 |
for(unsigned i=0;i<nuisance_priors->size();i++){
|
459 |
delete nuisance_priors->at(i);
|
460 |
}
|
461 |
delete nuisance_priors;
|
462 |
}
|
463 |
// cout<<"deleted"<<endl;
|
464 |
if(scaling_factors!=0){
|
465 |
for(unsigned i=0;i<scaling_factors->size();i++){
|
466 |
for(unsigned j=0;j<scaling_factors->at(i)->size();j++){
|
467 |
for(unsigned k=0;k<scaling_factors->at(i)->at(j)->size();k++){
|
468 |
delete scaling_factors->at(i)->at(j)->at(k);
|
469 |
}
|
470 |
delete scaling_factors->at(i)->at(j);
|
471 |
}
|
472 |
delete scaling_factors->at(i);
|
473 |
}
|
474 |
delete scaling_factors;
|
475 |
}
|
476 |
// cout<<"deleted"<<endl;
|
477 |
if(nuisance_widths!=0){
|
478 |
for(unsigned i=0;i<nuisance_widths->size();i++){
|
479 |
delete nuisance_widths->at(i);
|
480 |
}
|
481 |
delete nuisance_widths;
|
482 |
}
|
483 |
// cout<<"deleted"<<endl;
|
484 |
if(nuisance_parameters!=0){
|
485 |
for(unsigned i=0;i<nuisance_parameters->size();i++){
|
486 |
delete nuisance_parameters->at(i);
|
487 |
}
|
488 |
delete nuisance_parameters;
|
489 |
}
|
490 |
// cout<<"deleted"<<endl;
|
491 |
if(observables!=0){
|
492 |
for(unsigned i=0;i<observables->size();i++){
|
493 |
delete observables->at(i);
|
494 |
}
|
495 |
delete observables;
|
496 |
}
|
497 |
// cout<<"deleted"<<endl;
|
498 |
if(background!=0){
|
499 |
for(unsigned i=0;i<background->size();i++){
|
500 |
for(unsigned j=0;j<background->at(i)->size();j++){
|
501 |
delete background->at(i)->at(j);
|
502 |
}
|
503 |
delete background->at(i);
|
504 |
}
|
505 |
delete background;
|
506 |
}
|
507 |
// cout<<"deleted"<<endl;
|
508 |
if(signal!=0){
|
509 |
for(unsigned i=0;i<signal->size();i++){
|
510 |
delete signal->at(i);
|
511 |
}
|
512 |
delete signal;
|
513 |
}
|
514 |
// cout<<"deleted"<<endl;
|
515 |
if(POI!=0){
|
516 |
delete POI;
|
517 |
}
|
518 |
// cout<<"deleted"<<endl;
|
519 |
if(POI_prior_pdf!=0){
|
520 |
delete POI_prior_pdf;
|
521 |
}
|
522 |
// cout<<"deleted"<<endl;
|
523 |
if(nuisance_prior_pdf!=0){
|
524 |
delete nuisance_prior_pdf;
|
525 |
}
|
526 |
// cout<<"deleted"<<endl;
|
527 |
if(nuisance_set!=0){
|
528 |
delete nuisance_set;
|
529 |
}
|
530 |
// cout<<"deleted"<<endl;
|
531 |
if(observable_set!=0){
|
532 |
delete observable_set;
|
533 |
}
|
534 |
// cout<<"deleted"<<endl;
|
535 |
if(POI_set!=0){
|
536 |
delete POI_set;
|
537 |
}
|
538 |
cout<<"----------------------------"<<endl;
|
539 |
cout<<endl;
|
540 |
}
|
541 |
|
542 |
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
543 |
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
544 |
bool Model::check_input(std::vector<int>* n_input,std::vector<double>* signal_expectation,std::vector< std::vector<double>* >* background_expectation,std::vector< std::vector< std::vector<double>* >* >* systematic_uncertainties){
|
545 |
|
546 |
// cout<<"Checking, if input is consistent\n"<<endl;
|
547 |
unsigned n=signal_expectation->size();
|
548 |
for(unsigned i=0;i<background_expectation->size();i++){
|
549 |
if(background_expectation->at(i)->size()!=n){
|
550 |
this->corrupted=true;
|
551 |
cout<<"ERROR: size of signal and background expectation "<<i<<" don't match"<<endl;
|
552 |
return(false);
|
553 |
}
|
554 |
}
|
555 |
if(n_input!=0){
|
556 |
if(n_input->size()!=n){
|
557 |
this->corrupted=true;
|
558 |
cout<<"ERROR: size of signal expectation and observation don't match"<<endl;
|
559 |
return(false);
|
560 |
}
|
561 |
}
|
562 |
if(systematic_uncertainties!=0){
|
563 |
for(unsigned i=0;i<systematic_uncertainties->size();i++){
|
564 |
if(systematic_uncertainties->at(i)->size()!=background_expectation->size()+1){
|
565 |
this->corrupted=true;
|
566 |
cout<<"ERROR: at "<<i<<" : systematic uncertainty matrix doesn't contain values for signal and all backgrounds"<<endl;
|
567 |
return(false);
|
568 |
}
|
569 |
for(unsigned j=0;j<systematic_uncertainties->at(i)->size();j++){
|
570 |
if(systematic_uncertainties->at(i)->at(j)->size()!=n){
|
571 |
this->corrupted=true;
|
572 |
cout<<"ERROR: size of signal expectation and systematic uncertainty matrix don't match"<<endl;
|
573 |
return(false);
|
574 |
}
|
575 |
}
|
576 |
}
|
577 |
if(nuisance_upper_limit->size() != systematic_uncertainties->size() ) {
|
578 |
this->corrupted=true;
|
579 |
cout<<"ERROR: size of nuisance upper limits and systematic uncertainties don't match"<<endl;
|
580 |
return(false);
|
581 |
}
|
582 |
}
|
583 |
|
584 |
|
585 |
cout<<"Checked, that input is consistent!\n"<<endl;
|
586 |
|
587 |
this->corrupted=false;
|
588 |
return(true);
|
589 |
}
|
590 |
// this overwrites existing dataset
|
591 |
void Model::set_dataset(RooDataSet* d){
|
592 |
delete data;
|
593 |
data=d;
|
594 |
|
595 |
}
|
596 |
|
597 |
///set nuisances to zero andconstant
|
598 |
void Model::set_nuisance_const(){
|
599 |
|
600 |
RooArgSet* nuisances=nuisance_set;
|
601 |
TIterator* it=nuisances->createIterator();
|
602 |
//RooAbsArg* nui;
|
603 |
// while((RooAbsReal*)it->Next()){
|
604 |
RooRealVar* nui;
|
605 |
while( (nui=(RooRealVar*) it->Next()) ){
|
606 |
//(RooAbsReal*)it->setVal(0);
|
607 |
RooRealVar* nui2=dynamic_cast<RooRealVar*>(nui);
|
608 |
//cout<<"nui "<<nui2<<endl;
|
609 |
nui2->setVal(0);
|
610 |
nui2->setConstant(kTRUE);
|
611 |
|
612 |
|
613 |
}
|
614 |
|
615 |
|
616 |
}
|
617 |
///set nuisances to zero andconstant
|
618 |
void Model::set_nuisance_var(){
|
619 |
|
620 |
RooArgSet* nuisances=nuisance_set;
|
621 |
TIterator* it=nuisances->createIterator();
|
622 |
RooRealVar* nui;
|
623 |
// while((RooAbsReal*)it->Next()){
|
624 |
while( (nui=(RooRealVar*)it->Next()) ){
|
625 |
//(RooAbsReal*)it->setVal(0);
|
626 |
RooRealVar* nui2=dynamic_cast<RooRealVar*>(nui);
|
627 |
//cout<<"nui "<<nui2<<endl;
|
628 |
nui2->setVal(0);
|
629 |
nui2->setConstant(kFALSE);
|
630 |
|
631 |
|
632 |
}
|
633 |
|
634 |
}
|
635 |
|
636 |
void Model::set_poi_const(double p=0){
|
637 |
RooRealVar* ss=get_POI();
|
638 |
ss->setVal(p);
|
639 |
ss->setConstant(kTRUE);
|
640 |
|
641 |
|
642 |
}
|
643 |
void Model::set_poi_var(double p=0){
|
644 |
RooRealVar* ss=get_POI();
|
645 |
ss->setVal(p);
|
646 |
ss->setConstant(kFALSE);
|
647 |
|
648 |
}
|
649 |
|
650 |
|
651 |
|
652 |
|
653 |
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
654 |
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
655 |
void Model::create_observables(){
|
656 |
// cout<<"Create observables\n"<<endl;
|
657 |
if(range_n_obs>0){
|
658 |
observables=new vector<RooRealVar*>;
|
659 |
observable_set=new RooArgSet();
|
660 |
char* name=new char[1000];
|
661 |
|
662 |
for(int i=0;i<this->n_channels;i++){
|
663 |
sprintf (name, "observation_%d",i);
|
664 |
RooRealVar* tmp_observables=new RooRealVar(name,name,0,range_n_obs);
|
665 |
observables->push_back(tmp_observables);
|
666 |
observable_set->add(*observables->at(i));
|
667 |
}
|
668 |
delete [] name;
|
669 |
}
|
670 |
else{
|
671 |
cout<<"ERROR: negative range for the observations\n"<<endl;
|
672 |
this->corrupted=true;
|
673 |
}
|
674 |
}
|
675 |
|
676 |
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
677 |
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
678 |
void Model::create_signal_expectations(std::vector<double>* signal_expectation){
|
679 |
// cout<<"Create signal expectations\n"<<endl;
|
680 |
signal=new std::vector< RooConstVar*>;
|
681 |
char* name=new char[1000];
|
682 |
|
683 |
for(int i=0;i<this->n_channels;i++){
|
684 |
sprintf (name, "signal_%d", i);
|
685 |
RooConstVar* tmp_signal=new RooConstVar(name,name,signal_expectation->at(i));
|
686 |
signal->push_back(tmp_signal);
|
687 |
}
|
688 |
delete [] name;
|
689 |
}
|
690 |
|
691 |
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
692 |
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
693 |
void Model::create_background_expectations(std::vector< std::vector<double>* >* background_expectation){
|
694 |
// cout<<"Create background expectations\n"<<endl;
|
695 |
background =new vector< vector<RooConstVar*>* >;
|
696 |
char* name=new char[1000];
|
697 |
|
698 |
for(int i=0;i<this->n_backgrounds;i++){
|
699 |
vector<RooConstVar*>* tmp_background_row=new vector<RooConstVar*>;
|
700 |
for(int j=0;j<this->n_channels;j++){
|
701 |
sprintf (name, "background_channel_%d_source_%d",j,i);
|
702 |
RooConstVar* tmp_background=new RooConstVar(name,name,background_expectation->at(i)->at(j));
|
703 |
tmp_background_row->push_back(tmp_background);
|
704 |
}
|
705 |
background->push_back(tmp_background_row);
|
706 |
}
|
707 |
delete [] name;
|
708 |
}
|
709 |
|
710 |
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
711 |
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
712 |
void Model::create_nuisances(std::vector< vector< vector<double>* >* >* systematic_uncertainties){
|
713 |
// cout<<"Create nuisance parameters\n"<<endl;
|
714 |
if(range_nuisances>0){
|
715 |
if(use_nuisances==true){
|
716 |
|
717 |
nuisance_set=new RooArgSet();
|
718 |
nuisance_parameters=new vector<RooRealVar*>;
|
719 |
nuisance_widths=new vector<RooConstVar*>;
|
720 |
char* name=new char[1000];
|
721 |
char* title=new char[1000];
|
722 |
|
723 |
for(unsigned i=0;i<systematic_uncertainties->size();i++){
|
724 |
double greatest_error=0;
|
725 |
for(unsigned j=0;j<systematic_uncertainties->at(i)->size();j++){
|
726 |
for(unsigned k=0;k<systematic_uncertainties->at(i)->at(j)->size();k++){
|
727 |
if(systematic_uncertainties->at(i)->at(j)->at(k) >greatest_error){
|
728 |
greatest_error=systematic_uncertainties->at(i)->at(j)->at(k);
|
729 |
}
|
730 |
}
|
731 |
}
|
732 |
if(nuisance_names==0){
|
733 |
sprintf (name, "sigma_%d", i);
|
734 |
sprintf (title, "sigma_%d", i);
|
735 |
}
|
736 |
else{
|
737 |
sprintf (name, "sigma_%d", i);
|
738 |
sprintf (title, "sigma_%s", this->nuisance_names->at(i).c_str());
|
739 |
}
|
740 |
RooConstVar* tmp_nuisance_width=new RooConstVar(name,title,greatest_error);
|
741 |
nuisance_widths->push_back(tmp_nuisance_width);
|
742 |
if(nuisance_names==0){
|
743 |
sprintf (name, "delta_%d", i);
|
744 |
sprintf (title, "delta_%d", i);
|
745 |
}
|
746 |
else{
|
747 |
sprintf (name, "delta_%d", i);
|
748 |
sprintf (title, "delta_%s", this->nuisance_names->at(i).c_str());
|
749 |
}
|
750 |
//RooRealVar* tmp_nuisance_parameters=new RooRealVar(name,title,0,-1*range_nuisances*nuisance_widths->at(i)->getVal(),1.0*range_nuisances*nuisance_widths->at(i)->getVal());
|
751 |
//RooRealVar* tmp_nuisance_parameters=new RooRealVar(name,title,0,-1,1.0*range_nuisances*nuisance_widths->at(i)->getVal());
|
752 |
|
753 |
double lower_limit=-1;
|
754 |
std::string line = title;
|
755 |
std::string::size_type pos=line.find("[LOGNORMAL]");
|
756 |
if(pos != std::string::npos) lower_limit=-0.9999;
|
757 |
RooRealVar* tmp_nuisance_parameters=new RooRealVar(name,title,0,lower_limit,1.0*nuisance_upper_limit->at(i)*nuisance_widths->at(i)->getVal());
|
758 |
// cout<<name<<" has upper limit "<<nuisance_upper_limit->at(i)<<endl;
|
759 |
|
760 |
nuisance_parameters->push_back(tmp_nuisance_parameters);
|
761 |
nuisance_set->add(*nuisance_parameters->at(i));
|
762 |
}
|
763 |
delete [] name;
|
764 |
delete [] title;
|
765 |
}
|
766 |
else cout<<"No systematic uncertainties specified, no nuisance parameters created\n"<<endl;
|
767 |
}
|
768 |
else{
|
769 |
cout<<"ERROR: negative range for the nuisance_parameters\n"<<endl;
|
770 |
this->corrupted=true;
|
771 |
}
|
772 |
}
|
773 |
|
774 |
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
775 |
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
776 |
void Model::create_scaling_factors(vector< vector< vector<double>* >* >* systematic_uncertainties){
|
777 |
// cout<<"Create scaling factors for nuisances\n"<<endl;
|
778 |
if(use_nuisances==true &&nuisance_parameters!=0){
|
779 |
|
780 |
scaling_factors = new vector< vector< vector<RooConstVar*>* >* >;
|
781 |
char* name=new char[1000];
|
782 |
|
783 |
for(unsigned i=0;i<nuisance_parameters->size();i++){
|
784 |
|
785 |
vector< vector<RooConstVar*>* >* tmp_scaling_factors_for_one_nuisance = new vector< vector<RooConstVar*>* >;
|
786 |
vector<RooConstVar*>* tmp_signal_scaling_for_one_nuisance = new vector<RooConstVar*>;
|
787 |
|
788 |
for(int j=0;j<this->n_channels;j++){
|
789 |
sprintf (name, "signal_scaling_factor_channel_%d_nuisance_%d", j,i);
|
790 |
RooConstVar* tmp_signal_scaling=new RooConstVar(name,name,1.0*systematic_uncertainties->at(i)->at(0)->at(j)/nuisance_widths->at(i)->getVal());
|
791 |
tmp_signal_scaling_for_one_nuisance->push_back(tmp_signal_scaling);
|
792 |
}
|
793 |
tmp_scaling_factors_for_one_nuisance->push_back(tmp_signal_scaling_for_one_nuisance);
|
794 |
|
795 |
for(unsigned j=0;j<background->size();j++){
|
796 |
|
797 |
vector<RooConstVar*>* tmp_background_scaling_for_one_nuisance_for_one_background_source = new vector<RooConstVar*>;
|
798 |
|
799 |
for(int k=0;k<this->n_channels;k++){
|
800 |
sprintf (name, "background_scaling_factor_channel_%d_source_%d_nuisance_%d",k,j,i);
|
801 |
RooConstVar* tmp_background_scaling=new RooConstVar(name,name,1.0*systematic_uncertainties->at(i)->at(j+1)->at(k)/nuisance_widths->at(i)->getVal());
|
802 |
tmp_background_scaling_for_one_nuisance_for_one_background_source->push_back(tmp_background_scaling);
|
803 |
}
|
804 |
tmp_scaling_factors_for_one_nuisance->push_back(tmp_background_scaling_for_one_nuisance_for_one_background_source);
|
805 |
}
|
806 |
scaling_factors->push_back(tmp_scaling_factors_for_one_nuisance);
|
807 |
}
|
808 |
delete [] name;
|
809 |
}
|
810 |
else{
|
811 |
if(use_nuisances==true){
|
812 |
cout<<"ERROR: systematics specified, but no nuisance parameters created yet; can't define scaling factors\n"<<endl;
|
813 |
this->corrupted=true;
|
814 |
}
|
815 |
else cout<<"No systematics_specified, no scaling factors needed\n"<<endl;
|
816 |
}
|
817 |
}
|
818 |
|
819 |
|
820 |
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
821 |
// Use this for Gaussian errors
|
822 |
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
823 |
void Model::create_nuisance_priors(){
|
824 |
//void Model::create_nuisance_priors(){
|
825 |
cout<<"Create nuisances priors\n"<<endl;
|
826 |
if(use_nuisances==true &&nuisance_parameters!=0){
|
827 |
|
828 |
nuisance_priors=new vector<RooAbsPdf*>;
|
829 |
nuisance_means=new vector<RooFormulaVar*>;
|
830 |
RooArgList* nuisance_prior_list=new RooArgList();
|
831 |
char* name=new char[1000];
|
832 |
|
833 |
for(unsigned i=0;i<nuisance_parameters->size();i++){
|
834 |
//here check if in name is gauss or logNormal
|
835 |
//cout<<(*nuiscance_parameters)[i].GetTitle()<<endl;
|
836 |
RooRealVar* dummy = nuisance_parameters->at(i);
|
837 |
//cout<<dummy->GetTitle()<<endl;
|
838 |
|
839 |
int distribution=0;
|
840 |
std::string line = dummy->GetTitle();///now find in string gauss or logNormal
|
841 |
std::string::size_type pos=line.find("[GAUSS]");
|
842 |
if(pos != std::string::npos) distribution=0;
|
843 |
pos=line.find("[LOGNORMAL]");
|
844 |
if(pos != std::string::npos) distribution=1;
|
845 |
|
846 |
if(distribution==0){
|
847 |
///using gaussian function as nuisance distribution
|
848 |
cout<<" ---> "<<line<<" using Gaussian Distribuion"<<endl;
|
849 |
sprintf (name, "nuisance_prior_%d", i);
|
850 |
RooGaussian* tmp_nuisance_priors=new RooGaussian(name,name,*nuisance_parameters->at(i),RooFit::RooConst(0),*nuisance_widths->at(i));
|
851 |
nuisance_priors->push_back(tmp_nuisance_priors);
|
852 |
nuisance_prior_list->add(*nuisance_priors->at(i));
|
853 |
}
|
854 |
else if(distribution==1){
|
855 |
///using logNormal function as nuiscance distribution
|
856 |
cout<<" ---> "<<line<<" using logNormal Distribuion"<<endl;
|
857 |
char* name2=new char[1000];
|
858 |
|
859 |
sprintf (name, "nuisance_mean_%d", i);
|
860 |
sprintf(name2,"%s+1",nuisance_parameters->at(i)->GetName());
|
861 |
RooFormulaVar* tmp_nuisance_means=new RooFormulaVar(name,name2,RooArgSet(*nuisance_parameters->at(i)));
|
862 |
nuisance_means->push_back(tmp_nuisance_means);
|
863 |
sprintf (name, "nuisance_prior_%d", i);
|
864 |
//RooLognormal* tmp_nuisance_priors=new RooLognormal(name, name,*nuisance_means->at(i), RooFit::RooConst(1), RooFit::RooConst(TMath::Exp(nuisance_widths->at(i)->getVal())));
|
865 |
//ok i have to adjust my mean parameter or each nusiance....
|
866 |
///by my handmade calculations this is mu=sigma^2
|
867 |
double new_mean=nuisance_widths->at(i)->getVal()*nuisance_widths->at(i)->getVal();
|
868 |
//and put it into the function as exponential...
|
869 |
RooLognormal* tmp_nuisance_priors=new RooLognormal(name, name,*nuisance_means->at(i), RooFit::RooConst(TMath::Exp(new_mean)), RooFit::RooConst(TMath::Exp(nuisance_widths->at(i)->getVal())));
|
870 |
//cout<<"----------------------------"<<name<<" "<<nuisance_widths->at(i)->getVal()<<" "<<TMath::Exp(nuisance_widths->at(i)->getVal())<<endl;
|
871 |
nuisance_priors->push_back(tmp_nuisance_priors);
|
872 |
nuisance_prior_list->add(*nuisance_priors->at(i));
|
873 |
|
874 |
|
875 |
}
|
876 |
}
|
877 |
nuisance_prior_pdf=new RooProdPdf("nuisance_prior_pdf","nuisance_prior_pdf",*nuisance_prior_list);
|
878 |
delete nuisance_prior_list;
|
879 |
delete [] name;
|
880 |
}
|
881 |
else{
|
882 |
if(use_nuisances==true){
|
883 |
cout<<"ERROR: systematics specified, but no nuisance parameters created yet; can't create nuisance pdfs\n"<<endl;
|
884 |
this->corrupted=true;
|
885 |
}
|
886 |
else cout<<"No systematics_specified, no nuisance_priors needed\n"<<endl;
|
887 |
}
|
888 |
|
889 |
cout<<endl;
|
890 |
|
891 |
}
|
892 |
|
893 |
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
894 |
// Use this for Gaussian errors
|
895 |
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
896 |
// void Model::create_nuisance_priors(){
|
897 |
// //void Model::create_nuisance_priors(){
|
898 |
// cout<<"Create nuisances priors\n"<<endl;
|
899 |
// if(use_nuisances==true &&nuisance_parameters!=0){
|
900 |
|
901 |
// nuisance_priors=new vector<RooAbsPdf*>;
|
902 |
// RooArgList* nuisance_prior_list=new RooArgList();
|
903 |
// char* name=new char[1000];
|
904 |
|
905 |
// for(int i=0;i<nuisance_parameters->size();i++){
|
906 |
// sprintf (name, "nuisance_prior_%d", i);
|
907 |
// RooGaussian* tmp_nuisance_priors=new RooGaussian(name,name,*nuisance_parameters->at(i),RooFit::RooConst(0),*nuisance_widths->at(i));
|
908 |
// nuisance_priors->push_back(tmp_nuisance_priors);
|
909 |
// nuisance_prior_list->add(*nuisance_priors->at(i));
|
910 |
// }
|
911 |
// nuisance_prior_pdf=new RooProdPdf("nuisance_prior_pdf","nuisance_prior_pdf",*nuisance_prior_list);
|
912 |
// delete nuisance_prior_list;
|
913 |
// delete [] name;
|
914 |
// }
|
915 |
// else{
|
916 |
// if(use_nuisances==true){
|
917 |
// cout<<"ERROR: systematics specified, but no nuisance parameters created yet; can't create nuisance pdfs\n"<<endl;
|
918 |
// this->corrupted=true;
|
919 |
// }
|
920 |
// else cout<<"No systematics_specified, no nuisance_priors needed\n"<<endl;
|
921 |
// }
|
922 |
// }
|
923 |
|
924 |
// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
925 |
// // Use this for LogNormal errors
|
926 |
// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
927 |
void Model::create_nuisance_priors_2(){
|
928 |
if(use_nuisances==true &&nuisance_parameters!=0){
|
929 |
|
930 |
nuisance_priors=new vector<RooAbsPdf*>;
|
931 |
nuisance_means=new vector<RooFormulaVar*>;
|
932 |
RooArgList* nuisance_prior_list=new RooArgList();
|
933 |
char* name=new char[1000];
|
934 |
|
935 |
for(unsigned i=0;i<nuisance_parameters->size();i++){
|
936 |
char* name2=new char[1000];
|
937 |
sprintf (name, "nuisance_mean_%d", i);
|
938 |
sprintf(name2,"%s+1",nuisance_parameters->at(i)->GetName());
|
939 |
RooFormulaVar* tmp_nuisance_means=new RooFormulaVar(name,name2,RooArgSet(*nuisance_parameters->at(i)));
|
940 |
nuisance_means->push_back(tmp_nuisance_means);
|
941 |
sprintf (name, "nuisance_prior_%d", i);
|
942 |
RooLognormal* tmp_nuisance_priors=new RooLognormal(name, name,*nuisance_means->at(i), RooFit::RooConst(1), RooFit::RooConst(TMath::Exp(nuisance_widths->at(i)->getVal())));
|
943 |
|
944 |
nuisance_priors->push_back(tmp_nuisance_priors);
|
945 |
nuisance_prior_list->add(*nuisance_priors->at(i));
|
946 |
delete [] name2;
|
947 |
}
|
948 |
nuisance_prior_pdf=new RooProdPdf("nuisance_prior_pdf","nuisance_prior_pdf",*nuisance_prior_list);
|
949 |
delete nuisance_prior_list;
|
950 |
delete [] name;
|
951 |
}
|
952 |
else{
|
953 |
if(use_nuisances==true){
|
954 |
cout<<"ERROR: systematics specified, but no nuisance parameters created yet; can't create nuisance pdfs\n"<<endl;
|
955 |
this->corrupted=true;
|
956 |
}
|
957 |
else cout<<"No systematics_specified, no nuisance_priors needed\n"<<endl;
|
958 |
}
|
959 |
}
|
960 |
|
961 |
// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
962 |
// // Use this for Gamma errors, does not work
|
963 |
// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
964 |
// void Model::create_nuisance_priors(){
|
965 |
//
|
966 |
// if(use_nuisances==true &&nuisance_parameters!=0){
|
967 |
//
|
968 |
// nuisance_priors=new vector<RooAbsPdf*>;
|
969 |
// nuisance_means=new vector<RooFormulaVar*>;
|
970 |
// RooArgList* nuisance_prior_list=new RooArgList();
|
971 |
// char* name=new char[1000];
|
972 |
// RooConstVar gamma("gamma","gamma",20);
|
973 |
//
|
974 |
// for(int i=0;i<nuisance_parameters->size();i++){
|
975 |
// char* name2=new char[1000];
|
976 |
// sprintf (name, "beta_%d", i);
|
977 |
// RooConstVar* beta=new RooConstVar(name,name,TMath::Sqrt(nuisance_widths->at(i)->getVal()*nuisance_widths->at(i)->getVal()/gamma.getVal()));
|
978 |
// sprintf(name2,"%s+beta_%d*gamma",nuisance_parameters->at(i)->GetName(),i);
|
979 |
// nuisance_parameters->at(i)->setRange(TMath::Max(-1.0,-beta->getVal()*gamma.getVal()),range_nuisances*nuisance_widths->at(i)->getVal());
|
980 |
// sprintf (name, "nuisance_mean_%d", i);
|
981 |
// RooFormulaVar* tmp_nuisance_means=new RooFormulaVar(name,name2,RooArgSet(*beta,gamma,*nuisance_parameters->at(i)));
|
982 |
// nuisance_means->push_back(tmp_nuisance_means);
|
983 |
// sprintf (name, "nuisance_prior_%d", i);
|
984 |
// RooGamma* tmp_nuisance_priors=new RooGamma(name, name,*nuisance_means->at(i),RooFit::RooConst(gamma.getVal()),RooFit::RooConst(beta->getVal()),RooFit::RooConst(0));
|
985 |
// tmp_nuisance_priors->Print();
|
986 |
// nuisance_priors->push_back(tmp_nuisance_priors);
|
987 |
// nuisance_prior_list->add(*nuisance_priors->at(i));
|
988 |
// delete [] name2;
|
989 |
// delete beta;
|
990 |
// }
|
991 |
// nuisance_prior_pdf=new RooProdPdf("nuisance_prior_pdf","nuisance_prior_pdf",*nuisance_prior_list);
|
992 |
// nuisance_prior_pdf->Print();
|
993 |
// delete nuisance_prior_list;
|
994 |
// delete [] name;
|
995 |
// }
|
996 |
// else{
|
997 |
// if(use_nuisances==true){
|
998 |
// cout<<"ERROR: systematics specified, but no nuisance parameters created yet; can't create nuisance pdfs\n"<<endl;
|
999 |
// this->corrupted=true;
|
1000 |
// }
|
1001 |
// else cout<<"No systematics_specified, no nuisance_priors needed\n"<<endl;
|
1002 |
// }
|
1003 |
// }
|
1004 |
|
1005 |
|
1006 |
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
1007 |
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
1008 |
void Model::create_POI(){
|
1009 |
if(range_POI>0){
|
1010 |
// cout<<"Create parameter of interest\n"<<endl;
|
1011 |
//POI=new RooRealVar("POI","POI",1.0*range_POI/2,0,range_POI);
|
1012 |
POI=new RooRealVar("POI","POI",1.0*range_POI/2,0,range_POI);
|
1013 |
POI_set=new RooArgSet(*POI);
|
1014 |
}
|
1015 |
else{
|
1016 |
cout<<"ERROR: negative range specified, problem with input\n"<<endl;
|
1017 |
this->corrupted=true;
|
1018 |
}
|
1019 |
}
|
1020 |
|
1021 |
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
1022 |
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
1023 |
void Model::create_POI_prior(){
|
1024 |
if(POI!=0){
|
1025 |
// cout<<"Create flat prior for the parameter of interest\n"<<endl;
|
1026 |
RooAbsPdf* tmp_POI_prior= new RooPolynomial("tmp_POI_pior","tmp_POI_pior",*POI,RooArgList(RooFit::RooConst(0)));
|
1027 |
//RooJeffreysPrior* tmp_POI_prior =new RooJeffreysPrior("jeffreys","jeffreys",*w.pdf("p"),*POI,*observable_set);
|
1028 |
//RooJeffreysPrior pi("jeffreys","jeffreys",*w.pdf("p"),*w.set("poi"),*w.set("obs"));
|
1029 |
|
1030 |
// tmp->Print();
|
1031 |
POI_prior_pdf=new RooProdPdf("POI_prior","POI_prior",RooArgList(*tmp_POI_prior));
|
1032 |
POI_prior_pdf->getVal();
|
1033 |
delete tmp_POI_prior;
|
1034 |
}
|
1035 |
else{
|
1036 |
cout<<"ERROR: no parameter of interest specified yet, can't create prior\n"<<endl;
|
1037 |
this->corrupted=true;
|
1038 |
}
|
1039 |
}
|
1040 |
|
1041 |
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
1042 |
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
1043 |
void Model::create_sb_likelihood(){
|
1044 |
if(corrupted==false){
|
1045 |
cout<<"Create sb_likelihood\n"<<endl;
|
1046 |
sb_means = new vector<RooFormulaVar*>;
|
1047 |
sb_poissons = new vector<RooPoisson*>;
|
1048 |
vector<RooArgSet*>* sb_params =new vector<RooArgSet*>;
|
1049 |
char* name=new char[1000];
|
1050 |
|
1051 |
for(int i=0;i<n_channels;i++){
|
1052 |
RooArgSet* tmp_sb_params=new RooArgSet(*POI,*signal->at(i));
|
1053 |
for(int j=0;j<n_backgrounds;j++){
|
1054 |
tmp_sb_params->add(*background->at(j)->at(i));
|
1055 |
if(use_nuisances==true){
|
1056 |
for(unsigned k=0;k<nuisance_parameters->size();k++){
|
1057 |
tmp_sb_params->add(*nuisance_parameters->at(k));
|
1058 |
tmp_sb_params->add(*scaling_factors->at(k)->at(0)->at(i));
|
1059 |
tmp_sb_params->add(*scaling_factors->at(k)->at(j+1)->at(i));
|
1060 |
}
|
1061 |
}
|
1062 |
}
|
1063 |
sb_params->push_back(tmp_sb_params);
|
1064 |
}
|
1065 |
//Poisson means and Poisson distributions
|
1066 |
stringstream* formula_string=new stringstream();
|
1067 |
for(int i=0;i<n_channels;i++){
|
1068 |
formula_string->str("");
|
1069 |
*formula_string<<"1*(";
|
1070 |
*formula_string<<"POI";
|
1071 |
*formula_string<<"*signal_"<<i;
|
1072 |
if(use_nuisances==true){
|
1073 |
for(unsigned j=0;j<nuisance_parameters->size();j++){
|
1074 |
*formula_string<<"*(1+delta_"<<j<<"*signal_scaling_factor_channel_"<<i<<"_nuisance_"<<j<<")";
|
1075 |
}
|
1076 |
}
|
1077 |
for(int k=0;k<n_backgrounds;k++){
|
1078 |
*formula_string<<"+background_channel_"<<i<<"_source_"<<k;
|
1079 |
if(use_nuisances==true){
|
1080 |
for(unsigned j=0;j<nuisance_parameters->size();j++){
|
1081 |
*formula_string<<"*(1+delta_"<<j<<"*background_scaling_factor_channel_"<<i<<"_source_"<<k<<"_nuisance_"<<j<<")";
|
1082 |
}
|
1083 |
}
|
1084 |
}
|
1085 |
*formula_string<<")";
|
1086 |
cout<<formula_string->str()<<endl;
|
1087 |
sprintf (name, "sb_mean_%d",i);
|
1088 |
RooFormulaVar* tmp_sb_means=new RooFormulaVar(name,formula_string->str().c_str(),*sb_params->at(i));
|
1089 |
sb_means->push_back(tmp_sb_means);
|
1090 |
sprintf (name, "sb_poisson_%d",i);
|
1091 |
RooPoisson* tmp_sb_poissons=new RooPoisson(name,name,*observables->at(i),*sb_means->at(i));
|
1092 |
sb_poissons->push_back(tmp_sb_poissons);
|
1093 |
}
|
1094 |
|
1095 |
RooArgList *sb_pdfs=new RooArgList();
|
1096 |
for(int i=0;i<n_channels;i++) {
|
1097 |
sb_pdfs->add(*sb_poissons->at(i));
|
1098 |
}
|
1099 |
sb_likelihood=new RooProdPdf("sb_likelihood","sb_likelihood",*sb_pdfs);
|
1100 |
|
1101 |
delete sb_pdfs;
|
1102 |
for(unsigned i=0;i<sb_params->size();i++){
|
1103 |
delete sb_params->at(i);
|
1104 |
}
|
1105 |
delete sb_params;
|
1106 |
delete formula_string;
|
1107 |
delete [] name;
|
1108 |
}
|
1109 |
}
|
1110 |
|
1111 |
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
1112 |
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
1113 |
void Model::create_b_likelihood(){
|
1114 |
|
1115 |
if(corrupted==false){
|
1116 |
cout<<"Create b_likelihood\n"<<endl;
|
1117 |
b_means = new vector<RooFormulaVar*>;
|
1118 |
b_poissons = new vector<RooPoisson*>;
|
1119 |
vector<RooArgSet*>* b_params =new vector<RooArgSet*>;
|
1120 |
char* name=new char[1000];
|
1121 |
for(int i=0;i<n_channels;i++){
|
1122 |
RooArgSet* tmp_b_params=new RooArgSet();
|
1123 |
for(int j=0;j<n_backgrounds;j++){
|
1124 |
tmp_b_params->add(*background->at(j)->at(i));
|
1125 |
if(use_nuisances==true){
|
1126 |
for(unsigned k=0;k<nuisance_parameters->size();k++){
|
1127 |
tmp_b_params->add(*nuisance_parameters->at(k));
|
1128 |
tmp_b_params->add(*scaling_factors->at(k)->at(j+1)->at(i));
|
1129 |
}
|
1130 |
}
|
1131 |
}
|
1132 |
b_params->push_back(tmp_b_params);
|
1133 |
}
|
1134 |
//Poisson means and Poisson distributions
|
1135 |
stringstream* formula_string=new stringstream();
|
1136 |
for(int i=0;i<n_channels;i++){
|
1137 |
formula_string->str("");
|
1138 |
*formula_string<<"1*(";
|
1139 |
for(int k=0;k<n_backgrounds;k++){
|
1140 |
if(k==0){
|
1141 |
*formula_string<<"background_channel_"<<i<<"_source_"<<k;
|
1142 |
}
|
1143 |
else{
|
1144 |
*formula_string<<"+background_channel_"<<i<<"_source_"<<k;
|
1145 |
}
|
1146 |
if(use_nuisances==true){
|
1147 |
for(unsigned j=0;j<nuisance_parameters->size();j++){
|
1148 |
*formula_string<<"*(1+delta_"<<j<<"*background_scaling_factor_channel_"<<i<<"_source_"<<k<<"_nuisance_"<<j<<")";
|
1149 |
}
|
1150 |
}
|
1151 |
}
|
1152 |
*formula_string<<")";
|
1153 |
sprintf (name, "b_mean_%d",i);
|
1154 |
cout<<formula_string->str()<<endl;
|
1155 |
// b_params->at(i)->Print();
|
1156 |
RooFormulaVar* tmp_b_means=new RooFormulaVar(name,formula_string->str().c_str(),*b_params->at(i));
|
1157 |
b_means->push_back(tmp_b_means);
|
1158 |
sprintf (name, "b_poisson_%d",i);
|
1159 |
RooPoisson* tmp_b_poissons=new RooPoisson(name,name,*observables->at(i),*b_means->at(i));
|
1160 |
b_poissons->push_back(tmp_b_poissons);
|
1161 |
}
|
1162 |
RooArgList *b_pdfs=new RooArgList();
|
1163 |
for(int i=0;i<n_channels;i++) {
|
1164 |
b_pdfs->add(*b_poissons->at(i));
|
1165 |
}
|
1166 |
b_likelihood=new RooProdPdf("b_likelihood","b_likelihood",*b_pdfs);
|
1167 |
delete b_pdfs;
|
1168 |
for(unsigned i=0;i<b_params->size();i++){
|
1169 |
delete b_params->at(i);
|
1170 |
}
|
1171 |
delete b_params;
|
1172 |
delete formula_string;
|
1173 |
delete [] name;
|
1174 |
}
|
1175 |
}
|
1176 |
|
1177 |
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
1178 |
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
1179 |
bool Model::create_dataset(std::vector<int>* n_input){
|
1180 |
if(corrupted==false){
|
1181 |
// cout<<"Create data from input\n"<<endl;
|
1182 |
if(int(n_input->size())!=n_channels){
|
1183 |
cout<<"ERROR: observation input doesn't match number of channels\n"<<endl;
|
1184 |
this->corrupted=true;
|
1185 |
return(false);
|
1186 |
}
|
1187 |
for(int i=0;i<n_channels;i++){
|
1188 |
observables->at(i)->setVal(n_input->at(i));
|
1189 |
}
|
1190 |
if(data!=0){
|
1191 |
delete data;
|
1192 |
}
|
1193 |
data=new RooDataSet("data","data",*observable_set);
|
1194 |
data->add(*observable_set);
|
1195 |
return (true);
|
1196 |
}
|
1197 |
|
1198 |
return(false);
|
1199 |
}
|
1200 |
|
1201 |
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
1202 |
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
1203 |
|
1204 |
bool Model::create_pseudo_datasets(std::vector<double>* signal_expectation, std::vector< std::vector<double>* >* background_expectation, std::vector< std::vector< std::vector<double>* >* >* systematic_uncertainties){
|
1205 |
|
1206 |
char* name=new char[1000];
|
1207 |
|
1208 |
pseudo_b_obs_set=new RooArgSet();
|
1209 |
pseudo_bDN_obs_set=new RooArgSet();
|
1210 |
pseudo_bUP_obs_set=new RooArgSet();
|
1211 |
pseudo_sb_obs_set=new RooArgSet();
|
1212 |
|
1213 |
for(int i=0;i<this->n_channels;i++){
|
1214 |
|
1215 |
double b = 0;
|
1216 |
double bDN = 0;
|
1217 |
double bUP = 0;
|
1218 |
double sb = signal_expectation->at(i);
|
1219 |
|
1220 |
for(int j=0;j<n_backgrounds;j++){
|
1221 |
|
1222 |
b += background_expectation->at(j)->at(i);
|
1223 |
sb += background_expectation->at(j)->at(i);
|
1224 |
|
1225 |
double uncsum2 = 0;
|
1226 |
for(unsigned k=0;k<nuisance_parameters->size();k++){
|
1227 |
|
1228 |
|
1229 |
uncsum2 += pow(systematic_uncertainties->at(k)->at(j+1)->at(i),2);
|
1230 |
}
|
1231 |
|
1232 |
bDN += background_expectation->at(j)->at(i) * (1-sqrt(uncsum2));
|
1233 |
bUP += background_expectation->at(j)->at(i) * (1+sqrt(uncsum2));
|
1234 |
|
1235 |
}
|
1236 |
|
1237 |
sprintf (name, "observation_%d",i);
|
1238 |
|
1239 |
RooRealVar* tmp_b=new RooRealVar(name,name,int(b+0.5),0,range_n_obs);
|
1240 |
tmp_b->Print();
|
1241 |
RooRealVar* tmp_bDN=new RooRealVar(name,name,int(bDN+0.5),0,range_n_obs);
|
1242 |
tmp_bDN->Print();
|
1243 |
RooRealVar* tmp_bUP=new RooRealVar(name,name,int(bUP+0.5),0,range_n_obs);
|
1244 |
tmp_bUP->Print();
|
1245 |
RooRealVar* tmp_sb=new RooRealVar(name,name,int(sb+0.5),0,range_n_obs);
|
1246 |
tmp_sb->Print();
|
1247 |
|
1248 |
|
1249 |
pseudo_b_obs_set->add(*tmp_b);
|
1250 |
pseudo_bDN_obs_set->add(*tmp_bDN);
|
1251 |
pseudo_bUP_obs_set->add(*tmp_bUP);
|
1252 |
pseudo_sb_obs_set->add(*tmp_sb);
|
1253 |
|
1254 |
|
1255 |
|
1256 |
|
1257 |
}
|
1258 |
delete [] name;
|
1259 |
|
1260 |
pseudo_data_b=new RooDataSet("pseudo_data_b","pseudo_data_b",*pseudo_b_obs_set);
|
1261 |
pseudo_data_b->add(*pseudo_b_obs_set);
|
1262 |
|
1263 |
pseudo_data_b_minusSigma=new RooDataSet("pseudo_data_b_minusSigma","pseudo_data_b_minusSigma",*pseudo_bDN_obs_set);
|
1264 |
pseudo_data_b_minusSigma->add(*pseudo_bDN_obs_set);
|
1265 |
|
1266 |
pseudo_data_b_plusSigma=new RooDataSet("pseudo_data_b_plusSigma","pseudo_data_b_plusSigma",*pseudo_bUP_obs_set);
|
1267 |
pseudo_data_b_plusSigma->add(*pseudo_bUP_obs_set);
|
1268 |
|
1269 |
pseudo_data_sb=new RooDataSet("pseudo_data_sb","pseudo_data_sb",*pseudo_sb_obs_set);
|
1270 |
pseudo_data_sb->add(*pseudo_sb_obs_set);
|
1271 |
|
1272 |
|
1273 |
return true;
|
1274 |
}
|
1275 |
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
1276 |
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
1277 |
RooRealVar* Model::get_POI(){
|
1278 |
return(this->POI);
|
1279 |
}
|
1280 |
|
1281 |
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
1282 |
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
1283 |
RooArgSet* Model::get_POI_set(){
|
1284 |
return(this->POI_set);
|
1285 |
}
|
1286 |
|
1287 |
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
1288 |
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
1289 |
RooArgSet* Model::get_observable_set(){
|
1290 |
return(this->observable_set);
|
1291 |
}
|
1292 |
|
1293 |
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
1294 |
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
1295 |
RooArgSet* Model::get_nuisance_set(){
|
1296 |
return(this->nuisance_set);
|
1297 |
}
|
1298 |
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
1299 |
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
1300 |
RooProdPdf* Model::get_POI_prior(){
|
1301 |
return(POI_prior_pdf);
|
1302 |
}
|
1303 |
|
1304 |
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
1305 |
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
1306 |
RooProdPdf* Model::get_nuisance_prior_pdf(){
|
1307 |
return(nuisance_prior_pdf);
|
1308 |
}
|
1309 |
|
1310 |
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
1311 |
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
1312 |
RooProdPdf* Model::get_sb_likelihood(){
|
1313 |
return(sb_likelihood);
|
1314 |
}
|
1315 |
|
1316 |
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
1317 |
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
1318 |
RooProdPdf* Model::get_b_likelihood(){
|
1319 |
return(this->b_likelihood);
|
1320 |
}
|
1321 |
|
1322 |
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
1323 |
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
1324 |
RooProdPdf* Model::get_complete_likelihood(){
|
1325 |
RooProdPdf* complete_likelihood=new RooProdPdf("complete_likelihood","complete_likelihood",RooArgList(*this->sb_likelihood,*this->nuisance_prior_pdf));
|
1326 |
return(complete_likelihood);
|
1327 |
}
|
1328 |
|
1329 |
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
1330 |
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
1331 |
RooDataSet* Model::get_data(){
|
1332 |
return(this->data);
|
1333 |
}
|
1334 |
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
1335 |
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
1336 |
RooDataSet* Model::get_pseudo_data_b(){
|
1337 |
return(this->pseudo_data_b);
|
1338 |
}
|
1339 |
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
1340 |
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
1341 |
RooDataSet* Model::get_pseudo_data_bDN(){
|
1342 |
return(this->pseudo_data_b_minusSigma);
|
1343 |
}
|
1344 |
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
1345 |
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
1346 |
RooDataSet* Model::get_pseudo_data_bUP(){
|
1347 |
return(this->pseudo_data_b_plusSigma);
|
1348 |
}
|
1349 |
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
1350 |
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
1351 |
RooDataSet* Model::get_pseudo_data_sb(){
|
1352 |
return(this->pseudo_data_sb);
|
1353 |
}
|
1354 |
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
1355 |
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
1356 |
void Model::set_random_seed(int i){
|
1357 |
cout<<"Setting random seed to "<<i<<endl;
|
1358 |
RooRandom::randomGenerator()->SetSeed(i);
|
1359 |
}
|
1360 |
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
1361 |
double Model::get_sum_signal(){
|
1362 |
return(this->sumS);
|
1363 |
}
|
1364 |
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
1365 |
double Model::get_sum_background(){
|
1366 |
return(this->sumB);
|
1367 |
}
|
1368 |
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
1369 |
double Model::get_total_bunc(){
|
1370 |
return(sqrt(this->sumBerr)*this->sumB);
|
1371 |
}
|
1372 |
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
1373 |
double Model::get_lumi_scale(){
|
1374 |
return(this->lumiScale);
|
1375 |
}
|
1376 |
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
1377 |
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
1378 |
void Model::Print(){
|
1379 |
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
1380 |
//Some output of the model parameters
|
1381 |
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
1382 |
cout<<"---------------------------------------------------------------------------------------------------------------------"<<endl;
|
1383 |
cout<<"Model information"<<endl;
|
1384 |
cout<<"---------------------------------------------------------------------------------------------------------------------\n\n\n"<<endl;
|
1385 |
cout<<"Number of channels: "<<this->n_channels<<"\nNumber of background sources per channel: "<<this->n_backgrounds<<"\n\n\n"<<endl;
|
1386 |
cout<<"Channel signal expectation background_expectation(s)\n"<<endl;
|
1387 |
for(int i=0;i<this->n_channels;i++){
|
1388 |
cout<<i<<" "<<this->signal->at(i)->getVal();
|
1389 |
for(int j=0;j<this->n_backgrounds;j++){
|
1390 |
cout<<" "<<this->background->at(j)->at(i)->getVal();
|
1391 |
}
|
1392 |
cout<<"\n";
|
1393 |
}
|
1394 |
|
1395 |
if(use_nuisances==true){
|
1396 |
cout<<"\n\n---------------------------------------------------------------------------------------------------------------------"<<endl;
|
1397 |
cout<<"Systematic uncertainties"<<endl;
|
1398 |
cout<<"---------------------------------------------------------------------------------------------------------------------\n\n"<<endl;
|
1399 |
for(unsigned i=0;i<this->nuisance_parameters->size();i++){
|
1400 |
if(nuisance_names) cout<<"Matrix for "<<nuisance_names->at(i).c_str()<<" uncertainty "<<"\n"<<endl;
|
1401 |
else cout<<"Matrix for uncertainty "<<i<<"\n"<<endl;
|
1402 |
cout<<" sigma_signal sigma_b\n"<<endl;
|
1403 |
for(int j=0;j<this->n_channels;j++){
|
1404 |
cout<<"Channel "<<j<<" ";
|
1405 |
for(int k=0;k<this->n_backgrounds+1;k++){
|
1406 |
cout<<this->nuisance_widths->at(i)->getVal()*this->scaling_factors->at(i)->at(k)->at(j)->getVal()<<" ";
|
1407 |
}
|
1408 |
cout<<"\n";
|
1409 |
}
|
1410 |
cout<<"\n\n";
|
1411 |
}
|
1412 |
cout<<"\n\n---------------------------------------------------------------------------------------------------------------------"<<endl;
|
1413 |
cout<<"scaling factors"<<endl;
|
1414 |
cout<<"---------------------------------------------------------------------------------------------------------------------\n\n\n"<<endl;
|
1415 |
for(unsigned i=0;i<nuisance_parameters->size();i++){
|
1416 |
if(nuisance_names) cout<<"Scaling factors for "<<nuisance_names->at(i).c_str()<<" nuisance parameter "<<"\n"<<endl;
|
1417 |
else cout<<"Scaling factors for nuisance parameter "<<i<<"\n"<<endl;
|
1418 |
cout<<"Width of nuisance distribution: "<<nuisance_widths->at(i)->getVal()<<"\n"<<endl;
|
1419 |
cout<<" signal scaling background scaling\n"<<endl;
|
1420 |
for(int j=0;j<n_channels;j++){
|
1421 |
cout<<"channel "<<j<<" "<<scaling_factors->at(i)->at(0)->at(j)->getVal();
|
1422 |
for(unsigned k=0;k<background->size();k++){
|
1423 |
cout<<" "<<scaling_factors->at(i)->at(k+1)->at(j)->getVal();
|
1424 |
}
|
1425 |
cout<<"\n"<<endl;
|
1426 |
}
|
1427 |
cout<<"\n\n\n"<<endl;
|
1428 |
}
|
1429 |
}
|
1430 |
}
|
1431 |
|
1432 |
|
1433 |
|
1434 |
void Model::test(string file){
|
1435 |
ofstream myfile;
|
1436 |
myfile.open (file.c_str(), fstream::app);
|
1437 |
myfile<<endl;
|
1438 |
myfile<<"[observation]"<<endl;
|
1439 |
char* name=new char[1000];
|
1440 |
char* hmm=new char[1000];
|
1441 |
for(int i=0;i<this->n_channels;i++){
|
1442 |
sprintf (name, "observation_%d",i);
|
1443 |
//cout<<this->data->get()->getRealValue(name)<<endl;
|
1444 |
sprintf (hmm, "n%d",i+1);
|
1445 |
myfile<<hmm<<" = "<<this->data->get()->getRealValue(name)<<endl;
|
1446 |
}
|
1447 |
myfile.close();
|
1448 |
delete [] name;
|
1449 |
}
|
1450 |
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
1451 |
|
1452 |
void Model::create_teststats() {
|
1453 |
|
1454 |
|
1455 |
RooRealVar* firstPOI = (RooRealVar*) this->get_POI_set()->first();
|
1456 |
firstPOI->setVal(1);
|
1457 |
|
1458 |
RooNLLVar* sb_nll = new RooNLLVar("sb_nll","sb_nll",*this->get_sb_likelihood(),*this->get_data());
|
1459 |
RooNLLVar* b_nll = new RooNLLVar("b_nll","b_nll",*this->get_b_likelihood(),*this->get_data());
|
1460 |
test_Data = 2*(sb_nll->getVal()-b_nll->getVal());
|
1461 |
|
1462 |
sb_nll = new RooNLLVar ("sb_nll","sb_nll",*this->get_sb_likelihood(),*this->get_pseudo_data_b());
|
1463 |
b_nll = new RooNLLVar ("b_nll","b_nll",*this->get_b_likelihood(),*this->get_pseudo_data_b());
|
1464 |
test_Bmean = 2*(sb_nll->getVal()-b_nll->getVal());
|
1465 |
|
1466 |
sb_nll = new RooNLLVar ("sb_nll","sb_nll",*this->get_sb_likelihood(),*this->get_pseudo_data_bDN());
|
1467 |
b_nll = new RooNLLVar ("b_nll","b_nll",*this->get_b_likelihood(),*this->get_pseudo_data_bDN());
|
1468 |
test_Bdown = 2*(sb_nll->getVal()-b_nll->getVal());
|
1469 |
|
1470 |
sb_nll = new RooNLLVar ("sb_nll","sb_nll",*this->get_sb_likelihood(),*this->get_pseudo_data_bUP());
|
1471 |
b_nll = new RooNLLVar ("b_nll","b_nll",*this->get_b_likelihood(),*this->get_pseudo_data_bUP());
|
1472 |
test_Bup = 2*(sb_nll->getVal()-b_nll->getVal());
|
1473 |
|
1474 |
sb_nll = new RooNLLVar ("sb_nll","sb_nll",*this->get_sb_likelihood(),*this->get_pseudo_data_sb());
|
1475 |
b_nll = new RooNLLVar ("b_nll","b_nll",*this->get_b_likelihood(),*this->get_pseudo_data_sb());
|
1476 |
test_SBmean = 2*(sb_nll->getVal()-b_nll->getVal());
|
1477 |
|
1478 |
cout<<"Test statistics for data = "<<test_Data<<endl;
|
1479 |
cout<<"Test statistics for b = "<<test_Bmean<<endl;
|
1480 |
cout<<"Test statistics for b - 1sigma = "<<test_Bdown<<endl;
|
1481 |
cout<<"Test statistics for b + 1sigma = "<<test_Bup<<endl;
|
1482 |
cout<<"Test statistics for sb = "<<test_SBmean<<endl;
|
1483 |
|
1484 |
}
|
1485 |
|
1486 |
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
1487 |
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
1488 |
//////////////////////////////////////////////// CLS LIMIT CALCULATION METHODS ///////////////////////////////////////
|
1489 |
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
1490 |
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
1491 |
|
1492 |
|
1493 |
void significance_Hybrid(Model* model,int n_toys,int random_seed=0){
|
1494 |
cout<<"///////////////////////////////////////////////////////////////////////////////////////////"<<endl;
|
1495 |
cout<<"Calculating significance with the Hybrid method"<<endl;
|
1496 |
cout<<"///////////////////////////////////////////////////////////////////////////////////////////"<<endl;
|
1497 |
|
1498 |
//set the random seed
|
1499 |
RooRandom::randomGenerator()->SetSeed(random_seed);
|
1500 |
|
1501 |
//get the calculator
|
1502 |
HybridCalculatorOriginal myhc(*model->get_data(),*model->get_sb_likelihood(),*model->get_b_likelihood());
|
1503 |
|
1504 |
//for numbercounting experiments
|
1505 |
myhc.PatchSetExtended(false);
|
1506 |
|
1507 |
//set likelihood ratio as the test statistics
|
1508 |
myhc.SetTestStatistic(1);
|
1509 |
|
1510 |
//define the systematics to be used
|
1511 |
if (model->get_nuisance_set()) {
|
1512 |
myhc.UseNuisance(true);
|
1513 |
myhc.SetNuisancePdf(*model->get_nuisance_prior_pdf());
|
1514 |
myhc.SetNuisanceParameters(*model->get_nuisance_set());
|
1515 |
} else {
|
1516 |
myhc.UseNuisance(false);
|
1517 |
}
|
1518 |
|
1519 |
//define the number of toys to be done
|
1520 |
myhc.SetNumberOfToys(n_toys);
|
1521 |
|
1522 |
//get the Hypotestresult
|
1523 |
HybridResult* hcResult = myhc.GetHypoTest();
|
1524 |
double significance = hcResult->Significance();
|
1525 |
//double CLS= hcResult->Cls();
|
1526 |
//double CLSerror= hcResult->ClsError();
|
1527 |
|
1528 |
// myhc.PrintMore("");
|
1529 |
cout <<"HybridCalculator significance:" << significance<< endl;
|
1530 |
}
|
1531 |
|
1532 |
HybridResult* UL_significance_Hybrid(Model* model,int n_toys,int random_seed=0,double sig=1){
|
1533 |
cout<<"///////////////////////////////////////////////////////////////////////////////////////////"<<endl;
|
1534 |
cout<<"Calculating significance with the Hybrid method"<<endl;
|
1535 |
cout<<"///////////////////////////////////////////////////////////////////////////////////////////"<<endl;
|
1536 |
|
1537 |
RooMsgService::instance().setGlobalKillBelow(RooFit::FATAL);
|
1538 |
|
1539 |
//set the random seed
|
1540 |
RooRandom::randomGenerator()->SetSeed(random_seed);
|
1541 |
|
1542 |
//get the calculator
|
1543 |
HybridCalculatorOriginal myhc(*model->get_data(),*model->get_sb_likelihood(),*model->get_b_likelihood());
|
1544 |
|
1545 |
//for numbercounting experiments
|
1546 |
myhc.PatchSetExtended(false);
|
1547 |
|
1548 |
//set likelihood ratio as the test statistics
|
1549 |
myhc.SetTestStatistic(1);
|
1550 |
|
1551 |
|
1552 |
//define the systematics to be used
|
1553 |
if (model->get_nuisance_set()) {
|
1554 |
myhc.UseNuisance(true);
|
1555 |
myhc.SetNuisancePdf(*model->get_nuisance_prior_pdf());
|
1556 |
myhc.SetNuisanceParameters(*model->get_nuisance_set());
|
1557 |
} else {
|
1558 |
myhc.UseNuisance(false);
|
1559 |
}
|
1560 |
|
1561 |
// myhc.UseNuisance(false);
|
1562 |
|
1563 |
|
1564 |
//RooArgSet* poi= model->get_POI_set();
|
1565 |
// poi->first()->Set(sig);
|
1566 |
RooRealVar* firstPOI = (RooRealVar*) model->get_POI_set()->first();
|
1567 |
firstPOI->setVal(sig);
|
1568 |
|
1569 |
|
1570 |
|
1571 |
double expSigmas = fabs(model->get_teststat_Bmean() - model->get_teststat_SBmean())/fabs(model->get_teststat_Bmean() - model->get_teststat_Bup());
|
1572 |
|
1573 |
cout<<"Expected Sigmas Significance from Test statistics = "<<expSigmas<<endl;
|
1574 |
|
1575 |
|
1576 |
if(! isfinite(expSigmas) || expSigmas > 5.5) {
|
1577 |
cout<<" => BIG signal: Set CLs to 0!"<<endl;
|
1578 |
return 0;
|
1579 |
}
|
1580 |
|
1581 |
|
1582 |
|
1583 |
//Test if we have a very small signal
|
1584 |
|
1585 |
myhc.SetNumberOfToys(200);
|
1586 |
HybridResult* hcResult = myhc.GetHypoTest();
|
1587 |
hcResult->SetDataTestStatistics( model->get_teststat_Bdown() );
|
1588 |
|
1589 |
if(hcResult->CLs() > 0.5) {
|
1590 |
cout<<"Small signal: Stop running toys after 200!!"<<endl;
|
1591 |
return hcResult;
|
1592 |
}
|
1593 |
|
1594 |
delete hcResult;
|
1595 |
|
1596 |
|
1597 |
//define the number of toys to be done
|
1598 |
myhc.SetNumberOfToys(n_toys);
|
1599 |
|
1600 |
return myhc.GetHypoTest();
|
1601 |
|
1602 |
// hcResult->PrintMore("");
|
1603 |
|
1604 |
// // HypoTestPlot *plot = new HypoTestPlot(*hcResult,100);
|
1605 |
// HybridPlot* plot=hcResult->GetPlot("hcPlot","p Values Plot",100);
|
1606 |
// TCanvas *c1=new TCanvas;
|
1607 |
// plot->Draw();
|
1608 |
// c1->SaveAs("hybrid_Result.eps");
|
1609 |
|
1610 |
// double significance = hcResult->Significance();
|
1611 |
// double CLS= hcResult->CLs();
|
1612 |
// double CLB= hcResult->CLb();
|
1613 |
// double CLsplusb= hcResult->CLsplusb();
|
1614 |
// double CLSerror= hcResult->CLsError();
|
1615 |
|
1616 |
|
1617 |
// // compute the mean expected significance from toys
|
1618 |
// double mean_sb_toys_test_stat = plot->GetSBmean();
|
1619 |
// hcResult->SetDataTestStatistics(mean_sb_toys_test_stat);
|
1620 |
// double toys_significance = hcResult->Significance();
|
1621 |
|
1622 |
// cout<<endl;
|
1623 |
// cout<<"POI: "<<sig<<endl;
|
1624 |
// cout <<"significance of data: " << significance<<endl;
|
1625 |
// cout <<"mean significance of toys: " << toys_significance<<endl;
|
1626 |
// cout<<"CLs: "<<CLS<<endl;
|
1627 |
// cout<<"CLb: "<<CLB<<endl;
|
1628 |
// cout<<"CLsplusb: "<<CLsplusb<<endl;
|
1629 |
// cout<<"CLserror: "<<CLSerror<<endl;
|
1630 |
|
1631 |
|
1632 |
}
|
1633 |
|
1634 |
|
1635 |
|
1636 |
|
1637 |
|
1638 |
|
1639 |
void upper_limit_Hybrid_auto_scan(Model* model,double confidence,int n_toys_per_point,double lower_scan_bound, double upper_scan_bound,int random_seed=0,bool useCLS=true,double accuracy=0.005){
|
1640 |
cout<<"///////////////////////////////////////////////////////////////////////////////////////////"<<endl;
|
1641 |
cout<<"Calculating upper limit with the Hybrid method"<<endl;
|
1642 |
cout<<"///////////////////////////////////////////////////////////////////////////////////////////"<<endl;
|
1643 |
|
1644 |
//set the random seed
|
1645 |
RooRandom::randomGenerator()->SetSeed(random_seed);
|
1646 |
|
1647 |
//get the calculator
|
1648 |
HybridCalculatorOriginal myhc(*model->get_data(),*model->get_sb_likelihood(),*model->get_b_likelihood());
|
1649 |
|
1650 |
//for numbercounting experiments
|
1651 |
myhc.PatchSetExtended(false);
|
1652 |
|
1653 |
//set likelihood ratio as the test statistics
|
1654 |
myhc.SetTestStatistic(1);
|
1655 |
|
1656 |
//define the systematics to be used
|
1657 |
if (model->get_nuisance_set()) {
|
1658 |
myhc.UseNuisance(true);
|
1659 |
myhc.SetNuisancePdf(*model->get_nuisance_prior_pdf());
|
1660 |
myhc.SetNuisanceParameters(*model->get_nuisance_set());
|
1661 |
} else {
|
1662 |
myhc.UseNuisance(false);
|
1663 |
}
|
1664 |
|
1665 |
//define the number of toys to be done
|
1666 |
myhc.SetNumberOfToys(n_toys_per_point);
|
1667 |
|
1668 |
//get the interval calculator
|
1669 |
HypoTestInverter myInverter(myhc,*model->get_POI());
|
1670 |
|
1671 |
//use the CLS method
|
1672 |
myInverter.UseCLs(useCLS);
|
1673 |
|
1674 |
//set the confidence
|
1675 |
myInverter.SetTestSize((1-confidence)*2);
|
1676 |
|
1677 |
//run the auto scan in range lower_scan_bound - upper_scan_bound with accuracy parameter accuracy
|
1678 |
myInverter.RunAutoScan(lower_scan_bound,upper_scan_bound,myInverter.Size()/2,accuracy);
|
1679 |
|
1680 |
//get the result
|
1681 |
HypoTestInverterResult* results = myInverter.GetInterval();
|
1682 |
|
1683 |
double upperLimit = results->UpperLimit();
|
1684 |
std::cout <<confidence<< "% upper limit is: " << upperLimit << std::endl;
|
1685 |
}
|
1686 |
|
1687 |
|
1688 |
|
1689 |
|
1690 |
|
1691 |
|
1692 |
|
1693 |
void upper_limit_Hybrid_fixed_scan(Model* model,double confidence,int n_toys_per_point,double lower_scan_bound, double upper_scan_bound,int n_steps,int random_seed=0,bool useCLS=true){
|
1694 |
cout<<"///////////////////////////////////////////////////////////////////////////////////////////"<<endl;
|
1695 |
cout<<"Calculating upper limit with the Hybrid method"<<endl;
|
1696 |
cout<<"///////////////////////////////////////////////////////////////////////////////////////////"<<endl;
|
1697 |
|
1698 |
//set the random seed
|
1699 |
RooRandom::randomGenerator()->SetSeed(random_seed);
|
1700 |
|
1701 |
//get the calculator
|
1702 |
HybridCalculatorOriginal myhc(*model->get_data(),*model->get_sb_likelihood(),*model->get_b_likelihood());
|
1703 |
|
1704 |
//for numbercounting experiments
|
1705 |
myhc.PatchSetExtended(false);
|
1706 |
|
1707 |
//set likelihood ratio as the test statistics
|
1708 |
myhc.SetTestStatistic(1);
|
1709 |
|
1710 |
//define the systematics to be used
|
1711 |
if (model->get_nuisance_set()) {
|
1712 |
myhc.UseNuisance(true);
|
1713 |
myhc.SetNuisancePdf(*model->get_nuisance_prior_pdf());
|
1714 |
myhc.SetNuisanceParameters(*model->get_nuisance_set());
|
1715 |
} else {
|
1716 |
myhc.UseNuisance(false);
|
1717 |
}
|
1718 |
|
1719 |
//define the number of toys to be done
|
1720 |
myhc.SetNumberOfToys(n_toys_per_point);
|
1721 |
|
1722 |
//get the interval calculator
|
1723 |
HypoTestInverter myInverter(myhc,*model->get_POI());
|
1724 |
|
1725 |
//use the CLS method
|
1726 |
myInverter.UseCLs(useCLS);
|
1727 |
|
1728 |
//set the confidence
|
1729 |
myInverter.SetTestSize((1-confidence)*2);
|
1730 |
|
1731 |
//run the fixed scan in range lower_scan_bound - upper_scan_bound with n_steps steps
|
1732 |
myInverter.RunFixedScan(n_steps,lower_scan_bound,upper_scan_bound);
|
1733 |
|
1734 |
//get the result
|
1735 |
HypoTestInverterResult* results = myInverter.GetInterval();
|
1736 |
|
1737 |
double upperLimit = results->UpperLimit();
|
1738 |
std::cout <<confidence<< "% upper limit is: " << upperLimit << std::endl;
|
1739 |
}
|
1740 |
|
1741 |
void upper_limit_Hybrid_one_point(Model* model,double value_to_run_for,int n_toys,int random_seed=0,bool useCLS=true){
|
1742 |
cout<<"///////////////////////////////////////////////////////////////////////////////////////////"<<endl;
|
1743 |
cout<<"Calculating upper limit with the Hybrid method"<<endl;
|
1744 |
cout<<"///////////////////////////////////////////////////////////////////////////////////////////"<<endl;
|
1745 |
|
1746 |
//set the random seed
|
1747 |
RooRandom::randomGenerator()->SetSeed(random_seed);
|
1748 |
|
1749 |
//get the calculator
|
1750 |
HybridCalculatorOriginal myhc(*model->get_data(),*model->get_sb_likelihood(),*model->get_b_likelihood());
|
1751 |
|
1752 |
//for numbercounting experiments
|
1753 |
myhc.PatchSetExtended(false);
|
1754 |
|
1755 |
//set likelihood ratio as the test statistics
|
1756 |
myhc.SetTestStatistic(1);
|
1757 |
|
1758 |
//define the systematics to be used
|
1759 |
if (model->get_nuisance_set()) {
|
1760 |
myhc.UseNuisance(true);
|
1761 |
myhc.SetNuisancePdf(*model->get_nuisance_prior_pdf());
|
1762 |
myhc.SetNuisanceParameters(*model->get_nuisance_set());
|
1763 |
} else {
|
1764 |
myhc.UseNuisance(false);
|
1765 |
}
|
1766 |
|
1767 |
//define the number of toys to be done
|
1768 |
myhc.SetNumberOfToys(n_toys);
|
1769 |
|
1770 |
//get the interval calculator
|
1771 |
HypoTestInverter myInverter(myhc,*model->get_POI());
|
1772 |
|
1773 |
//use the CLS method
|
1774 |
myInverter.UseCLs(useCLS);
|
1775 |
|
1776 |
//run one point
|
1777 |
myInverter.RunOnePoint(value_to_run_for);
|
1778 |
}
|
1779 |
|
1780 |
void central_interval_Hybrid_fixed_scan(Model* model,double confidence,int n_toys_per_point,double lower_scan_bound, double upper_scan_bound,int n_steps,int random_seed=0,bool useCLS=true){
|
1781 |
cout<<"///////////////////////////////////////////////////////////////////////////////////////////"<<endl;
|
1782 |
cout<<"Calculating central interval with the Hybrid method"<<endl;
|
1783 |
cout<<"///////////////////////////////////////////////////////////////////////////////////////////"<<endl;
|
1784 |
|
1785 |
//set the random seed
|
1786 |
RooRandom::randomGenerator()->SetSeed(random_seed);
|
1787 |
|
1788 |
//get the calculator
|
1789 |
HybridCalculatorOriginal myhc(*model->get_data(),*model->get_sb_likelihood(),*model->get_b_likelihood());
|
1790 |
|
1791 |
//for numbercounting experiments
|
1792 |
myhc.PatchSetExtended(false);
|
1793 |
|
1794 |
//set likelihood ratio as the test statistics
|
1795 |
myhc.SetTestStatistic(1);
|
1796 |
|
1797 |
//define the systematics to be used
|
1798 |
if (model->get_nuisance_set()) {
|
1799 |
myhc.UseNuisance(true);
|
1800 |
myhc.SetNuisancePdf(*model->get_nuisance_prior_pdf());
|
1801 |
myhc.SetNuisanceParameters(*model->get_nuisance_set());
|
1802 |
} else {
|
1803 |
myhc.UseNuisance(false);
|
1804 |
}
|
1805 |
|
1806 |
//define the number of toys to be done
|
1807 |
myhc.SetNumberOfToys(n_toys_per_point);
|
1808 |
|
1809 |
//get the interval calculator
|
1810 |
HypoTestInverter myInverter(myhc,*model->get_POI());
|
1811 |
|
1812 |
//use the CLS method
|
1813 |
myInverter.UseCLs(useCLS);
|
1814 |
|
1815 |
//set the confidence
|
1816 |
myInverter.SetTestSize(1-confidence);
|
1817 |
|
1818 |
//run the auto fixed in range lower_scan_bound - upper_scan_bound with n_steps steps
|
1819 |
myInverter.RunFixedScan(n_steps,lower_scan_bound,upper_scan_bound);
|
1820 |
|
1821 |
|
1822 |
//get the result
|
1823 |
HypoTestInverterResult* results = myInverter.GetInterval();
|
1824 |
|
1825 |
double upperLimit = results->UpperLimit();
|
1826 |
double lowerLimit = results->LowerLimit();
|
1827 |
std::cout <<confidence<<"% interval is: " << lowerLimit<<" , "<< upperLimit << std::endl;
|
1828 |
}
|
1829 |
|
1830 |
void central_interval_Hybrid_auto_scan(Model* model,double confidence,int n_toys_per_point,double lower_scan_bound, double upper_scan_bound,int random_seed=0,bool useCLS=true,double accuracy=0.005){
|
1831 |
cout<<"///////////////////////////////////////////////////////////////////////////////////////////"<<endl;
|
1832 |
cout<<"Calculating central interval with the Hybrid method"<<endl;
|
1833 |
cout<<"///////////////////////////////////////////////////////////////////////////////////////////"<<endl;
|
1834 |
|
1835 |
//set the random seed
|
1836 |
RooRandom::randomGenerator()->SetSeed(random_seed);
|
1837 |
|
1838 |
//get the HybridCalculatorOriginal
|
1839 |
HybridCalculatorOriginal myhc(*model->get_data(),*model->get_sb_likelihood(),*model->get_b_likelihood());
|
1840 |
|
1841 |
//for numbercounting experiments
|
1842 |
myhc.PatchSetExtended(false);
|
1843 |
|
1844 |
//set likelihood ratio as the test statistics
|
1845 |
myhc.SetTestStatistic(1);
|
1846 |
|
1847 |
// define the systematics to be used
|
1848 |
if (model->get_nuisance_set()) {
|
1849 |
myhc.UseNuisance(true);
|
1850 |
myhc.SetNuisancePdf(*model->get_nuisance_prior_pdf());
|
1851 |
myhc.SetNuisanceParameters(*model->get_nuisance_set());
|
1852 |
} else {
|
1853 |
myhc.UseNuisance(false);
|
1854 |
}
|
1855 |
|
1856 |
//define the number of toys to be done
|
1857 |
myhc.SetNumberOfToys(n_toys_per_point);
|
1858 |
|
1859 |
//get the interval calculator
|
1860 |
HypoTestInverter myInverter(myhc,*model->get_POI());
|
1861 |
|
1862 |
//use the CLS method
|
1863 |
myInverter.UseCLs(useCLS);
|
1864 |
|
1865 |
//set the confidence
|
1866 |
myInverter.SetTestSize(1-confidence);
|
1867 |
//scan the values for X to find the interval
|
1868 |
//requires the search range and the desired accuracy
|
1869 |
myInverter.RunAutoScan(lower_scan_bound,upper_scan_bound,myInverter.Size(),accuracy);
|
1870 |
//get the result
|
1871 |
HypoTestInverterResult* results = myInverter.GetInterval();
|
1872 |
|
1873 |
double upperLimit = results->UpperLimit();
|
1874 |
double lowerLimit = results->LowerLimit();
|
1875 |
std::cout <<confidence<<"% interval is: " << lowerLimit<<" , "<< upperLimit << std::endl;
|
1876 |
|
1877 |
}
|
1878 |
|
1879 |
|
1880 |
|
1881 |
HypoTestResult* significance_Profile_Likelihood(Model* model){
|
1882 |
cout<<"///////////////////////////////////////////////////////////////////////////////////////////"<<endl;
|
1883 |
cout<<"Calculating significance with the Profile Likelihood method"<<endl;
|
1884 |
cout<<"///////////////////////////////////////////////////////////////////////////////////////////"<<endl;
|
1885 |
|
1886 |
|
1887 |
// //define paramsOfInterest
|
1888 |
RooArgSet *paramsOfInterest=new RooArgSet("paramsOfInterest");
|
1889 |
paramsOfInterest->addClone(*model->get_POI()); //clone because we need s for complete likelihood
|
1890 |
|
1891 |
//get the calculator
|
1892 |
ProfileLikelihoodCalculator plc(*model->get_data(),*model->get_complete_likelihood(), *paramsOfInterest);
|
1893 |
|
1894 |
//define null hypothesis
|
1895 |
paramsOfInterest->setRealValue(model->get_POI()->GetName(),0);
|
1896 |
plc.SetNullParameters(*paramsOfInterest);
|
1897 |
|
1898 |
//get the hypotest
|
1899 |
// HypoTestResult* lrhypo=plc.GetHypoTest();
|
1900 |
// double significance=lrhypo->Significance();
|
1901 |
// cout<<"Profile Likelihood significance is: "<<significance<<endl;
|
1902 |
|
1903 |
|
1904 |
return plc.GetHypoTest();
|
1905 |
}
|
1906 |
|
1907 |
|
1908 |
|
1909 |
|
1910 |
|
1911 |
|
1912 |
int main(int argc, char* argv[]){
|
1913 |
|
1914 |
if (argc<=1){
|
1915 |
std::cerr<<"Error: Expected configs!"<<std::endl;
|
1916 |
exit(1);
|
1917 |
} else if (argc==2){
|
1918 |
std::cerr<<"Error: Expected background AND min 1 signal config!"<<std::endl;
|
1919 |
exit(1);
|
1920 |
}
|
1921 |
|
1922 |
|
1923 |
bool writePlots = true;
|
1924 |
|
1925 |
string bkgFileName=argv[1];
|
1926 |
std::cout << "opening background and data config file: "<<bkgFileName<<"\n"<<std::endl;
|
1927 |
cout<<"----------------------------\n"<<endl;
|
1928 |
//open the config file
|
1929 |
ConfigFile* bkgConfig = new ConfigFile(bkgFileName);
|
1930 |
|
1931 |
int n_toys = bkgConfig->Value("definitions","n_toys");
|
1932 |
bool use_seperate_channels = bkgConfig->Value("definitions","use_seperate_channels",0);
|
1933 |
int n_sep_channels = 1;
|
1934 |
if(use_seperate_channels) n_sep_channels = bkgConfig->Value("definitions","n_channels");
|
1935 |
|
1936 |
for (int file=2; file<argc; ++file){
|
1937 |
|
1938 |
string fileName=argv[file];
|
1939 |
std::cout << "opening scan signal "<<file-1<<" from "<<argc-2<<": "<<fileName<<"\n"<<std::endl;
|
1940 |
|
1941 |
|
1942 |
for (int iChannnel=0; iChannnel<n_sep_channels; ++iChannnel){
|
1943 |
|
1944 |
if(use_seperate_channels) std::cout << "Use seperated channels, now channel "<<iChannnel+1<<"/"<<n_sep_channels<<".\n"<<std::endl;
|
1945 |
|
1946 |
ConfigFile* sigConfig = new ConfigFile(fileName);
|
1947 |
|
1948 |
Model* model = 0;
|
1949 |
if(use_seperate_channels) model = new Model(bkgConfig, sigConfig, iChannnel+1);
|
1950 |
else model = new Model(bkgConfig, sigConfig);
|
1951 |
|
1952 |
// model->Print();
|
1953 |
|
1954 |
|
1955 |
|
1956 |
// HypoTestResult* plcResult = significance_Profile_Likelihood(model);
|
1957 |
|
1958 |
// if(plcResult) {
|
1959 |
// cout<<"\n ++++++++++"<<endl;
|
1960 |
// plcResult->Print();
|
1961 |
// cout<<"CL_s_Error: "<<plcResult->CLsError()<<endl;
|
1962 |
// cout<<"plc significance: "<<plcResult->Significance()<<endl;
|
1963 |
// cout<<"\n ++++++++++"<<endl;
|
1964 |
|
1965 |
// }
|
1966 |
|
1967 |
cout<<"\n ++++++++++"<<endl;
|
1968 |
if( model->get_lumi_scale() != 1) cout<<"Scale lumi with "<<model->get_lumi_scale()<<endl;
|
1969 |
cout<<"Signal= "<<model->get_sum_signal()<<endl;
|
1970 |
double soverb =model->get_sum_signal()/sqrt(model->get_sum_background());
|
1971 |
double soverberr = model->get_sum_signal()/sqrt( model->get_sum_background() + model->get_total_bunc() );
|
1972 |
cout<<"S / sqrt(B) = "<<soverb<<endl;
|
1973 |
cout<<"S / sqrt(B+unc) = "<<soverberr<<endl;
|
1974 |
|
1975 |
|
1976 |
int random_integer = rand();
|
1977 |
// random_integer = 321; //set to fixed value only for comparisions
|
1978 |
cout<<"random_integer: "<<random_integer<<endl;
|
1979 |
|
1980 |
|
1981 |
HybridResult* hcResult = UL_significance_Hybrid(model,n_toys,random_integer);
|
1982 |
|
1983 |
double obsCLs = 0;
|
1984 |
double obsCLsError = 0;
|
1985 |
double obsSignificance = 1000;
|
1986 |
double expSignificance = 1000;
|
1987 |
double estimateSignificance = 1000;
|
1988 |
double expCLs = 0;
|
1989 |
double expCLsError = 0;
|
1990 |
double expCLsRMSDN = 0;
|
1991 |
double expCLsRMSUP = 0;
|
1992 |
|
1993 |
HybridPlot* plot = 0;
|
1994 |
TCanvas *c1 = 0;
|
1995 |
|
1996 |
|
1997 |
if(hcResult) {
|
1998 |
|
1999 |
|
2000 |
vector<double> b = hcResult->GetTestStat_b();
|
2001 |
vector<double> sb = hcResult->GetTestStat_sb();
|
2002 |
|
2003 |
double max = 0;
|
2004 |
double min = 0;
|
2005 |
|
2006 |
for(unsigned int v=0;v<b.size()&&v<sb.size();v++) {
|
2007 |
if( max < b.at(v) && isfinite(b.at(v)) ) max = b.at(v);
|
2008 |
if( min > sb.at(v) && isfinite(sb.at(v)) ) min = sb.at(v);
|
2009 |
}
|
2010 |
|
2011 |
for(unsigned int v=0;v<b.size()&&v<sb.size();v++) {
|
2012 |
if(! isfinite(b.at(v))) b.at(v) = max;
|
2013 |
if(! isfinite(sb.at(v))) sb.at(v) = min;
|
2014 |
}
|
2015 |
|
2016 |
HybridResult* corrResult = new HybridResult("HybridResult",sb,b);
|
2017 |
corrResult->SetDataTestStatistics( hcResult->GetTestStat_data() );
|
2018 |
|
2019 |
|
2020 |
plot=corrResult->GetPlot("hcPlot","p Values Plot",200);
|
2021 |
c1=new TCanvas;
|
2022 |
plot->Draw();
|
2023 |
|
2024 |
|
2025 |
cout<<"\n ++++++++++"<<endl;
|
2026 |
cout<<"Get center of B and SB model from the plot: "<<endl;
|
2027 |
double sbcenter = plot->GetSBCenter();
|
2028 |
double bcenter = plot->GetBCenter();
|
2029 |
double bUP = bcenter + plot->GetBrms();
|
2030 |
double bDN = bcenter - plot->GetBrms();
|
2031 |
|
2032 |
|
2033 |
if( sbcenter==0 ) sbcenter = model->get_teststat_SBmean();
|
2034 |
if( bcenter==0 ) {
|
2035 |
bcenter = model->get_teststat_Bmean();
|
2036 |
bUP = model->get_teststat_Bup();
|
2037 |
bDN = model->get_teststat_Bdown();
|
2038 |
}
|
2039 |
|
2040 |
estimateSignificance = fabs(bcenter-sbcenter)/fabs(bcenter-bUP);
|
2041 |
|
2042 |
cout<<"SB center = "<<sbcenter<<" +/- "<<plot->GetSBrms()<<endl;
|
2043 |
cout<<"B center = "<<bcenter<<" +/- "<<plot->GetBrms()<<endl;
|
2044 |
cout<<"estimation of Significance: "<<estimateSignificance<<" sigma" <<endl;
|
2045 |
|
2046 |
corrResult->PrintMore("");
|
2047 |
cout<<" +/- "<<corrResult->CLsError()<<endl;
|
2048 |
cout<<"data significance: "<<corrResult->Significance()<< " sigma" <<endl;
|
2049 |
|
2050 |
// compute the mean expected significance from toys
|
2051 |
obsCLs = corrResult->CLs();
|
2052 |
obsCLsError = corrResult->CLsError();
|
2053 |
obsSignificance = corrResult->Significance();
|
2054 |
|
2055 |
|
2056 |
corrResult->SetDataTestStatistics(sbcenter);
|
2057 |
|
2058 |
if( corrResult->CLb() < 1 )
|
2059 |
expSignificance = corrResult->Significance();
|
2060 |
else
|
2061 |
expSignificance = 1000;
|
2062 |
|
2063 |
// cout<<"\n ++++++++++"<<endl;
|
2064 |
// cout<<"Results from mean of SB toys:"<<endl;
|
2065 |
// corrResult->PrintMore("");
|
2066 |
cout<<"Exp significance: "<<corrResult->Significance()<< " sigma" <<endl;
|
2067 |
|
2068 |
corrResult->SetDataTestStatistics(bcenter);
|
2069 |
|
2070 |
expCLs = corrResult->CLs();
|
2071 |
expCLsError = corrResult->CLsError();
|
2072 |
|
2073 |
// cout<<"\n ++++++++++"<<endl;
|
2074 |
// cout<<"Results from mean of B toys:"<<endl;
|
2075 |
// corrResult->PrintMore("");
|
2076 |
|
2077 |
cout<<"CL_s_exp: "<<expCLs<<endl;
|
2078 |
cout<<" +/- "<<expCLsError<<endl;
|
2079 |
|
2080 |
|
2081 |
corrResult->SetDataTestStatistics(bDN);
|
2082 |
|
2083 |
expCLsRMSDN = corrResult->CLs();
|
2084 |
cout<<"CL_s_expRMSdn: "<<expCLsRMSDN<<endl;
|
2085 |
cout<<" +/- "<< corrResult->CLsError()<<endl;
|
2086 |
|
2087 |
corrResult->SetDataTestStatistics(bUP);
|
2088 |
|
2089 |
expCLsRMSUP = corrResult->CLs();
|
2090 |
cout<<"CL_s_expRMSup: "<<expCLsRMSUP<<endl;
|
2091 |
cout<<" +/- "<< corrResult->CLsError()<<endl;
|
2092 |
|
2093 |
|
2094 |
cout<<"\n ++++++++++"<<endl;
|
2095 |
|
2096 |
if(writePlots) {
|
2097 |
size_t found = fileName.find_last_of("/");
|
2098 |
if(found == string::npos) found = 0;
|
2099 |
else found++;
|
2100 |
string shortFileName = fileName.substr(found,fileName.length());
|
2101 |
|
2102 |
if(use_seperate_channels) c1->SaveAs(string(shortFileName.substr(0,shortFileName.find(".dat"))+"_channel"+int_to_string(iChannnel+1)+"_Result.eps").c_str());
|
2103 |
else c1->SaveAs(string(shortFileName.substr(0,shortFileName.find(".dat"))+"_Result.eps").c_str());
|
2104 |
}
|
2105 |
|
2106 |
delete corrResult;
|
2107 |
}
|
2108 |
|
2109 |
///Write results to config
|
2110 |
|
2111 |
ostringstream otext;
|
2112 |
|
2113 |
|
2114 |
if(!use_seperate_channels || iChannnel==0) {
|
2115 |
otext <<"[results_Hybrid]\n"
|
2116 |
<<"BkgrConfig = "<<bkgFileName<<"\n"
|
2117 |
<<"n_toys = "<<n_toys<<"\n"
|
2118 |
<<"SoverB = "<<soverb<<"\n"
|
2119 |
<<"SoverBunc = "<<soverberr<<"\n"
|
2120 |
<<"SignalSum = "<<model->get_sum_signal()<<"\n"
|
2121 |
<<"BkgSum = "<<model->get_sum_background()<<"\n"
|
2122 |
<<"BkgUnc = "<<model->get_total_bunc()<<"\n";
|
2123 |
}
|
2124 |
|
2125 |
|
2126 |
if(!use_seperate_channels) {
|
2127 |
otext <<"obsCLs = "<<obsCLs<<"\n"
|
2128 |
<<"obsCLsError = "<<obsCLsError<<"\n"
|
2129 |
<<"obsSignificance = "<<obsSignificance<<"\n"
|
2130 |
<<"expCLs = "<<expCLs<<"\n"
|
2131 |
<<"expCLsError = "<<expCLsError<<"\n"
|
2132 |
<<"expSignificance = "<<expSignificance<<"\n"
|
2133 |
<<"expCLs_rmsDN = "<<expCLsRMSDN<<"\n"
|
2134 |
<<"expCLs_rmsUP = "<<expCLsRMSUP<<"\n"
|
2135 |
<<"estimateSignificance = "<<estimateSignificance<<"\n";
|
2136 |
} else {
|
2137 |
otext <<"obsCLs_ch"<<iChannnel+1<<" = "<<obsCLs<<"\n"
|
2138 |
<<"obsCLsError_ch"<<iChannnel+1<<" = "<<obsCLsError<<"\n"
|
2139 |
<<"obsSignificance_ch"<<iChannnel+1<<" = "<<obsSignificance<<"\n"
|
2140 |
<<"expCLs_ch"<<iChannnel+1<<" = "<<expCLs<<"\n"
|
2141 |
<<"expCLsError_ch"<<iChannnel+1<<" = "<<expCLsError<<"\n"
|
2142 |
<<"expSignificance_ch"<<iChannnel+1<<" = "<<expSignificance<<"\n"
|
2143 |
<<"expCLs_rmsDN_ch"<<iChannnel+1<<" = "<<expCLsRMSDN<<"\n"
|
2144 |
<<"expCLs_rmsUP_ch"<<iChannnel+1<<" = "<<expCLsRMSUP<<"\n"
|
2145 |
<<"estimateSignificance_ch"<<iChannnel+1<<" = "<<estimateSignificance<<"\n";
|
2146 |
}
|
2147 |
|
2148 |
|
2149 |
|
2150 |
time_t rawtime;
|
2151 |
struct tm * timeinfo;
|
2152 |
time ( &rawtime );
|
2153 |
timeinfo = localtime ( &rawtime );
|
2154 |
ofstream ofile;
|
2155 |
ofile.open (fileName.c_str(),ios::app);
|
2156 |
if (ofile.good())
|
2157 |
std::cout << "adding results to '"<<fileName.c_str()<<"'"<<std::endl;
|
2158 |
else if ( (ofile.rdstate() & ifstream::failbit ) != 0 )
|
2159 |
std::cerr << "ERROR opening '"<<fileName.c_str()<<"'! Does the directory exist?"<<std::endl;
|
2160 |
|
2161 |
|
2162 |
if(!use_seperate_channels || iChannnel==0) ofile << "\n"<< asctime (timeinfo) <<"\n"<< otext.str()<<"\n";
|
2163 |
else ofile << otext.str()<<"\n";
|
2164 |
|
2165 |
|
2166 |
|
2167 |
|
2168 |
ofile.close();
|
2169 |
|
2170 |
|
2171 |
|
2172 |
if(plot) delete plot;
|
2173 |
if(c1) delete c1;
|
2174 |
delete hcResult;
|
2175 |
delete sigConfig;
|
2176 |
delete model;
|
2177 |
}
|
2178 |
}
|
2179 |
|
2180 |
|
2181 |
|
2182 |
//########################
|
2183 |
|
2184 |
// vector<double> *signal_expectation = new vector<double>;
|
2185 |
// vector< vector<double>* > *background_expectation = new vector< vector<double>* >;
|
2186 |
// vector< vector< vector<double>* >* >* systematic_uncertainties= new vector< vector< vector<double>* >* >;
|
2187 |
// vector<double> *nuisance_upper_limit = new vector<double>;
|
2188 |
// vector<int> *n_input= new vector<int>;
|
2189 |
|
2190 |
// int nuisance_range=10;
|
2191 |
// int POI_range=20;
|
2192 |
// int observation_range=500;
|
2193 |
|
2194 |
|
2195 |
// // signal_expectation->push_back(1.85562);
|
2196 |
// signal_expectation->push_back(9.97288);
|
2197 |
// signal_expectation->push_back(1.33057);
|
2198 |
// signal_expectation->push_back(12.8879);
|
2199 |
|
2200 |
|
2201 |
|
2202 |
// std::vector<double>* bkg1 = new vector<double>;
|
2203 |
// // bkg1->push_back(68.0);
|
2204 |
// bkg1->push_back(38.9);
|
2205 |
// bkg1->push_back(8.0);
|
2206 |
// bkg1->push_back(5.9);
|
2207 |
// background_expectation->push_back(bkg1);
|
2208 |
|
2209 |
|
2210 |
|
2211 |
// std::vector<double>* unc1_sig = new vector<double>;
|
2212 |
// std::vector<double>* unc2_sig = new vector<double>;
|
2213 |
// std::vector<double>* unc1_bkg1 = new vector<double>;
|
2214 |
// std::vector<double>* unc2_bkg1 = new vector<double>;
|
2215 |
|
2216 |
// std::vector< std::vector<double>* >* unc_type1 = new vector< vector<double>* >;
|
2217 |
// std::vector< std::vector<double>* >* unc_type2 = new vector< vector<double>* >;
|
2218 |
|
2219 |
// // unc1_sig->push_back(0.318846/1.85562);
|
2220 |
// unc1_sig->push_back(1.55237/9.97288);
|
2221 |
// unc1_sig->push_back(0.34926/1.33057);
|
2222 |
// unc1_sig->push_back(2.2063/12.8879);
|
2223 |
|
2224 |
|
2225 |
// unc_type1->push_back(unc1_sig);
|
2226 |
|
2227 |
// // unc2_sig->push_back(0.0);
|
2228 |
// unc2_sig->push_back(0.0);
|
2229 |
// unc2_sig->push_back(0.0);
|
2230 |
// unc2_sig->push_back(0.0);
|
2231 |
|
2232 |
|
2233 |
// unc_type2->push_back(unc2_sig);
|
2234 |
|
2235 |
|
2236 |
// // unc1_bkg1->push_back(13.6/68.0);
|
2237 |
// // unc1_bkg1->push_back(8.6/38.9);
|
2238 |
// // unc1_bkg1->push_back(1.2/8.0);
|
2239 |
// // unc1_bkg1->push_back(1.4/5.9);
|
2240 |
|
2241 |
// // unc1_bkg1->push_back(0.);
|
2242 |
// unc1_bkg1->push_back(0.);
|
2243 |
// unc1_bkg1->push_back(0.);
|
2244 |
// unc1_bkg1->push_back(0.);
|
2245 |
|
2246 |
// unc_type1->push_back(unc1_bkg1);
|
2247 |
|
2248 |
|
2249 |
// // unc2_bkg1->push_back(13.6/68.0);
|
2250 |
// unc2_bkg1->push_back(8.6/38.9);
|
2251 |
// unc2_bkg1->push_back(1.2/8.0);
|
2252 |
// unc2_bkg1->push_back(1.4/5.9);
|
2253 |
|
2254 |
|
2255 |
// unc_type2->push_back(unc2_bkg1);
|
2256 |
|
2257 |
// systematic_uncertainties->push_back(unc_type1);
|
2258 |
|
2259 |
// systematic_uncertainties->push_back(unc_type2);
|
2260 |
|
2261 |
|
2262 |
// nuisance_upper_limit->push_back(5);
|
2263 |
// nuisance_upper_limit->push_back(5);
|
2264 |
|
2265 |
|
2266 |
// // n_input->push_back(65);
|
2267 |
// n_input->push_back(31);
|
2268 |
// n_input->push_back(6);
|
2269 |
// n_input->push_back(9);
|
2270 |
|
2271 |
|
2272 |
|
2273 |
// Model* test=new Model(signal_expectation,background_expectation,systematic_uncertainties,nuisance_upper_limit,n_input,nuisance_range,POI_range,observation_range);
|
2274 |
|
2275 |
// // Model* test=new Model(signal_expectation,background_expectation,systematic_uncertainties,nuisance_upper_limit,0,nuisance_range,POI_range,observation_range);
|
2276 |
|
2277 |
// test->Print();
|
2278 |
|
2279 |
|
2280 |
// // Model* test=new Model("RA7/test_60_230_COV.txt");
|
2281 |
|
2282 |
|
2283 |
// test->get_b_likelihood()->getVariables()->Print();
|
2284 |
|
2285 |
|
2286 |
// // TFile file("Model_results.root","recreate");
|
2287 |
|
2288 |
// // TH1F* hist_b_likelihood_0 = (TH1F*) test->get_b_likelihood()->createHistogram("observation_0",100);
|
2289 |
// // TH1F* hist_b_likelihood_1 = (TH1F*) test->get_b_likelihood()->createHistogram("observation_1",100);
|
2290 |
// // TH1F* hist_b_likelihood_2 = (TH1F*) test->get_b_likelihood()->createHistogram("observation_2",100);
|
2291 |
// // TH1F* hist_b_likelihood_3 = (TH1F*) test->get_b_likelihood()->createHistogram("observation_3",100);
|
2292 |
|
2293 |
// // TH1F* hist_sb_likelihood_0 = (TH1F*) test->get_sb_likelihood()->createHistogram("observation_0",100);
|
2294 |
// // TH1F* hist_sb_likelihood_1 = (TH1F*) test->get_sb_likelihood()->createHistogram("observation_1",100);
|
2295 |
// // TH1F* hist_sb_likelihood_2 = (TH1F*) test->get_sb_likelihood()->createHistogram("observation_2",100);
|
2296 |
// // TH1F* hist_sb_likelihood_3 = (TH1F*) test->get_sb_likelihood()->createHistogram("observation_3",100);
|
2297 |
|
2298 |
// // hist_b_likelihood_0->Write();
|
2299 |
// // hist_b_likelihood_1->Write();
|
2300 |
// // hist_b_likelihood_2->Write();
|
2301 |
// // hist_b_likelihood_3->Write();
|
2302 |
|
2303 |
// // hist_sb_likelihood_0->Write();
|
2304 |
// // hist_sb_likelihood_1->Write();
|
2305 |
// // hist_sb_likelihood_2->Write();
|
2306 |
// // hist_sb_likelihood_3->Write();
|
2307 |
|
2308 |
// // file.Close();
|
2309 |
|
2310 |
// // significance_Hybrid(test,5000,321);
|
2311 |
|
2312 |
|
2313 |
// UL_significance_Hybrid(test,10000,321);
|
2314 |
// // upper_limit_Hybrid_auto_scan(test,0.95,50,0.01,5);
|
2315 |
|
2316 |
|
2317 |
|
2318 |
// // systematic_uncertainties
|
2319 |
|
2320 |
// // for (int file=1; file<argc; ++file){
|
2321 |
|
2322 |
// // string fileName=argv[file];
|
2323 |
// // std::cout << "opening: "<<fileName<<std::endl;
|
2324 |
|
2325 |
// // ConfigFile config(argv[file]);
|
2326 |
|
2327 |
|
2328 |
// // Model* test=new Model(signal_expectation,background_expectation,systematic_uncertainties,n_input,nuisance_range,POI_range,observation_range);
|
2329 |
|
2330 |
|
2331 |
// // significance_Hybrid(test,1000,321);
|
2332 |
|
2333 |
|
2334 |
// // delete test;
|
2335 |
|
2336 |
// // string out="out_"+fileName;
|
2337 |
// // ofstream outfile(out.c_str());
|
2338 |
// // outfile<<"##outputfile created by Model.cc from: "<<fileName<<endl;
|
2339 |
|
2340 |
// // outfile.close();
|
2341 |
|
2342 |
// // std::cout << "##outputfile created: "<<out<<std::endl;
|
2343 |
|
2344 |
// // }
|
2345 |
|
2346 |
|
2347 |
|
2348 |
|
2349 |
|
2350 |
// // Model* test=new Model(file.c_str());
|
2351 |
// //Model* test=new Model("test_60_230.txt");
|
2352 |
// //Model* test=new Model("test_140_200.txt");
|
2353 |
// //Model* test=new Model("MultiLepton_Model_Jt200_CU_DAVIS_ML01.txt");
|
2354 |
|
2355 |
|
2356 |
// // srand((unsigned)time(0));
|
2357 |
// // int random_integer = rand();
|
2358 |
// //cout<<random_integer<<endl;
|
2359 |
// // cout<<"random_number: "<<"XXXseedXXX"<<endl;
|
2360 |
|
2361 |
// // RooRandom::randomGenerator()->SetSeed(random_integer);
|
2362 |
|
2363 |
|
2364 |
|
2365 |
|
2366 |
|
2367 |
return(0);
|
2368 |
|
2369 |
}
|