-
Notifications
You must be signed in to change notification settings - Fork 0
/
AnalysisCuts.cc
227 lines (190 loc) · 6.22 KB
/
AnalysisCuts.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
#include "AnalysisCuts.hh"
#include <iostream>
#include <iomanip>
// ClassImp(AnalysisCuts)
// ----------------------------------------------------------------------
AnalysisCuts::AnalysisCuts(TString name) {
for (int i = 0; i < MAXCUTS; ++i) {
fCutName[i] = TString("unused");
fDescription[i] = TString("nothing said");
fCutValue[i] = false;
fAocValue[i] = false;
fCumValue[i] = false;
fNm1Value[i] = false;
}
fNcuts = 0;
fUpdated = 0;
fAcName = name;
}
// ----------------------------------------------------------------------
AnalysisCuts::~AnalysisCuts() {
if (fUpdated == 0) {
cout << "xx> AnalysisCuts: You never called update(). All answers were wrong!" << endl;
}
}
// // ----------------------------------------------------------------------
// void AnalysisCuts::addCut(const char *name, int &location) {
// addCut(name, "no description", location);
// }
// // ----------------------------------------------------------------------
// void AnalysisCuts::addCut(const char *name, const char *description, int &location) {
// fCutName[fNcuts] = TString(name);
// fDescription[fNcuts] = TString(description);
// fCutLocation[fNcuts] = &location;
// fAocValue[fNcuts] = -1;
// fCumValue[fNcuts] = -1;
// cout << "--> Added cut " << name << " " << description << endl;
// fNcuts++;
// }
// ----------------------------------------------------------------------
void AnalysisCuts::dumpAll() {
for (int i = 0; i < fNcuts; ++i) {
cout << Form("Cut %2d: %s (%s) at %d", i, fCutName[i].Data(), fDescription[i].Data(), (fCutLocation[i]?1:0))
<< Form(" nm=%i si=%i cu=%i", (fNm1Value[i]?1:0), (fCutValue[i]?1:0), (fCumValue[i]?1:0))
<< endl;
}
}
// ----------------------------------------------------------------------
void AnalysisCuts::clear() {
for (int i = 0; i < fNcuts; ++i) {
fCutName[i] = "cleared";
fDescription[i] = "cleared";
fCutValue[i] = false;
fAocValue[i] = false;
fCumValue[i] = false;
fNm1Value[i] = false;
fCutLocation[i] = 0;
}
fNcuts = 0;
fUpdated =0;
}
// ----------------------------------------------------------------------
void AnalysisCuts::addCut(const char *name, bool &location) {
addCut(name, "no description", location);
}
// ----------------------------------------------------------------------
void AnalysisCuts::addCut(const char *name, const char *description, bool &location) {
fCutName[fNcuts] = TString(name);
fDescription[fNcuts] = TString(description);
fCutLocation[fNcuts] = &location;
fAocValue[fNcuts] = false;
fCumValue[fNcuts] = false;
fNm1Value[fNcuts] = false;
cout << "--> Added cut " << name << " " << description << endl;
fNcuts++;
}
// ----------------------------------------------------------------------
int AnalysisCuts::getIndex(const char *name) {
for (int i = 0; i < fNcuts; ++i) {
if (!strcmp(fCutName[i].Data(), name)) return i;
}
return -1;
}
// ----------------------------------------------------------------------
const char* AnalysisCuts::getName(int icut) {
if ((icut >= 0) && (icut < fNcuts)) {
return fCutName[icut].Data();
} else {
return "xx> AnalysisCuts: cut index out of range";
}
}
// ----------------------------------------------------------------------
const char* AnalysisCuts::getDescription(int icut) {
if ((icut >= 0) && (icut < fNcuts)) {
return fDescription[icut].Data();
} else {
return "xx> AnalysisCuts: cut index out of range";
}
}
// ----------------------------------------------------------------------
void AnalysisCuts::update() {
// -- Fill all cuts
for (int i = 0; i < fNcuts; ++i) {
fCutValue[i] = *(fCutLocation[i]);
}
// -- Cache derived information
for (int i = 0; i < fNcuts; ++i) {
fNm1Value[i] = true;
for (int j = 0; j < i; ++j) {
if (singleCutTrue(j) == false) {
fNm1Value[i] = false;
break;
}
}
fCumValue[i] = true;
for (int j = 0; j <= i; ++j) {
if (singleCutTrue(j) == false) {
fCumValue[i] = false;
break;
}
}
fAocValue[i] = true;
for (int j = 0; j < fNcuts; ++j) {
if (j == i) continue;
if (singleCutTrue(j) == false) {
fAocValue[i] = false;
break;
}
}
}
if (0 == fUpdated) {
cout << "Updating AnalysisCuts(" << fAcName << ") for the first time" << endl;
}
fUpdated = 1;
}
// ----------------------------------------------------------------------
bool AnalysisCuts::singleCutTrue(int icut) {
return fCutValue[icut];
}
// ----------------------------------------------------------------------
bool AnalysisCuts::cumulativeCutTrue(int icut) {
return fCumValue[icut];
}
// ----------------------------------------------------------------------
bool AnalysisCuts::nMinus1CutsTrue(int icut) {
return fNm1Value[icut];
}
// ----------------------------------------------------------------------
bool AnalysisCuts::allOtherCutsTrue(int icut) {
return fAocValue[icut];
}
// ----------------------------------------------------------------------
bool AnalysisCuts::singleCutTrue(const char *name) {
int icut = getIndex(name);
if ((icut >= 0) && (icut < fNcuts)) {
return singleCutTrue(icut);
} else {
cout << "xx> AnalysisCuts: Unknown cut " << name << endl;
return false;
}
}
// ----------------------------------------------------------------------
bool AnalysisCuts::cumulativeCutTrue(const char *name) {
int icut = getIndex(name);
if ((icut >= 0) && (icut < fNcuts)) {
return cumulativeCutTrue(icut);
} else {
cout << "xx> AnalysisCuts: Unknown cut " << name << endl;
return false;
}
}
// ----------------------------------------------------------------------
bool AnalysisCuts::nMinus1CutsTrue(const char *name) {
int icut = getIndex(name);
if ((icut >= 0) && (icut < fNcuts)) {
return nMinus1CutsTrue(icut);
} else {
cout << "xx> AnalysisCuts: Unknown cut " << name << endl;
return false;
}
}
// ----------------------------------------------------------------------
bool AnalysisCuts::allOtherCutsTrue(const char *name) {
int icut = getIndex(name);
if ((icut >= 0) && (icut < fNcuts)) {
return allOtherCutsTrue(icut);
} else {
cout << "xx> AnalysisCuts: Unknown cut " << name << endl;
return false;
}
}