forked from ltikvica/WZanalysis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SystematicsManager.C
107 lines (72 loc) · 2.18 KB
/
SystematicsManager.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#include "SystematicsManager.h"
#include <iostream>
#include <fstream>
#include <sstream>
using namespace std;
// Global static pointer used to ensure a single instance of the class.
SystematicsManager * SystematicsManager::_instance = NULL;
SystematicsManager::SystematicsManager() {
SetDefaultValues();
}
void SystematicsManager::SetDefaultValues() {
values["ele_SF"] = 0.;
values["mu_SF"] = 0.;
values["ele_scale_syst"] = 0.;
values["mu_scale_syst"] = 0.;
values["PU"] = 0.;
values["JER"] = 0.;
values["JES"] = 0.;
values["pu_syst"] = 0.;
values["ZZ"] = 0.;
values["Zgamma"] = 0.;
values["WV"] = 0.;
values["WZZJets"] = 0.;
values["ZZZJets"] = 0.;
values["WWZJets"] = 0.;
values["WWWJets"] = 0.;
values["TTWJets"] = 0.;
values["TTZJets"] = 0.;
values["TTWWJets"] = 0.;
values["TTGJets"] = 0.;
values["WWGJets"] = 0.;
values["dataDriven"] = 0.;
values["MET"] = 0.;
values["UnfoldingStat"] = 0.;
}
void SystematicsManager::Setup(string filename) {
std::cout << "Systematics SETUP \n";
ifstream infile(filename.c_str());
string line;
while (std::getline(infile, line))
{
if (line[0] == '#') continue;
std::istringstream iss(line);
string key;
float value;
if ((iss >> key >> value)) {
map<string,float >::iterator it = values.find(key);
if (it == values.end()) {
std::cout << "DEFINING UNKNOWN SYSTEMATICS: "
<< key << std::endl;
continue;
}
values[key] = value;
std::cout << "\t DEF SYSTEMATIC: "
<< key << "\t:\t" << value << std::endl;
}
}
}
SystematicsManager * SystematicsManager::GetInstance(){
if (! _instance) { // Only allow one instance of class to be generated.
_instance = new SystematicsManager();
}
return _instance;
}
float SystematicsManager::GetValue(string key) {
map<string,float >::iterator it = values.find(key);
if (it == values.end()) {
std::cout << "UNKNOWN SYSTEMATICS: " << key << std::endl;
return -999;
}
return values[key];
}