1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
|
/** \file HLTHiggsPlotter.cc
*/
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "DataFormats/Candidate/interface/CandMatchMap.h"
#include "DataFormats/MuonReco/interface/Muon.h"
#include "DataFormats/MuonReco/interface/MuonFwd.h"
#include "DataFormats/HLTReco/interface/TriggerEvent.h"
#include "HLTHiggsPlotter.h"
#include "HLTHiggsSubAnalysis.h"
#include "EVTColContainer.h"
#include "TPRegexp.h"
#include <set>
#include <cctype>
HLTHiggsPlotter::HLTHiggsPlotter(const edm::ParameterSet &pset,
const std::string &hltPath,
const std::vector<unsigned int> &objectsType,
const unsigned int &NptPlots,
const std::vector<double> &NminOneCuts)
: _hltPath(hltPath),
_hltProcessName(pset.getParameter<std::string>("hltProcessName")),
_objectsType(std::set<unsigned int>(objectsType.begin(), objectsType.end())),
_nObjects(objectsType.size()),
_parametersEta(pset.getParameter<std::vector<double> >("parametersEta")),
_parametersPhi(pset.getParameter<std::vector<double> >("parametersPhi")),
_parametersTurnOn(pset.getParameter<std::vector<double> >("parametersTurnOn")),
_NptPlots(NptPlots),
_NminOneCuts(NminOneCuts) {
for (std::set<unsigned int>::iterator it = _objectsType.begin(); it != _objectsType.end(); ++it) {
// Some parameters extracted from the .py
std::string objStr = EVTColContainer::getTypeString(*it);
_cutMinPt[*it] = pset.getParameter<double>(std::string(objStr + "_cutMinPt").c_str());
_cutMaxEta[*it] = pset.getParameter<double>(std::string(objStr + "_cutMaxEta").c_str());
}
}
HLTHiggsPlotter::~HLTHiggsPlotter() {}
void HLTHiggsPlotter::beginJob() {}
void HLTHiggsPlotter::beginRun(const edm::Run &iRun, const edm::EventSetup &iSetup) {}
void HLTHiggsPlotter::bookHistograms(DQMStore::IBooker &ibooker, const bool &useNminOneCuts) {
for (std::set<unsigned int>::iterator it = _objectsType.begin(); it != _objectsType.end(); ++it) {
std::vector<std::string> sources(2);
sources[0] = "gen";
sources[1] = "rec";
TString maxPt;
const std::string objTypeStr = EVTColContainer::getTypeString(*it);
for (size_t i = 0; i < sources.size(); i++) {
std::string source = sources[i];
if (useNminOneCuts && *it == EVTColContainer::PFJET) {
if (source == "gen")
continue;
else {
// N-1 jet plots (dEtaqq, mqq, dPhibb, CSV1, maxCSV_jets, maxCSV_E, PFMET, pt1, pt2, pt3, pt4)
if (_NminOneCuts[0])
bookHist(source, objTypeStr, "dEtaqq", ibooker);
if (_NminOneCuts[1])
bookHist(source, objTypeStr, "mqq", ibooker);
if (_NminOneCuts[2])
bookHist(source, objTypeStr, "dPhibb", ibooker);
if (_NminOneCuts[3]) {
if (_NminOneCuts[6])
bookHist(source, objTypeStr, "maxCSV", ibooker);
else
bookHist(source, objTypeStr, "CSV1", ibooker);
}
if (_NminOneCuts[4])
bookHist(source, objTypeStr, "CSV2", ibooker);
if (_NminOneCuts[5])
bookHist(source, objTypeStr, "CSV3", ibooker);
}
}
bookHist(source, objTypeStr, "Eta", ibooker);
bookHist(source, objTypeStr, "Phi", ibooker);
for (unsigned int i = 0; i < _NptPlots; i++) {
maxPt = "MaxPt";
maxPt += i + 1;
bookHist(source, objTypeStr, maxPt.Data(), ibooker);
}
}
}
}
void HLTHiggsPlotter::analyze(const bool &isPassTrigger,
const std::string &source,
const std::vector<MatchStruct> &matches,
const unsigned int &minCandidates) {
if (!isPassTrigger) {
return;
}
std::map<unsigned int, int> countobjects;
// Initializing the count of the used object
for (std::set<unsigned int>::iterator co = _objectsType.begin(); co != _objectsType.end(); ++co) {
countobjects[*co] = 0;
}
int counttotal = 0;
const int totalobjectssize2 = _NptPlots * countobjects.size();
// Fill the histos if pass the trigger (just the two with higher pt)
for (size_t j = 0; j < matches.size(); ++j) {
// Is this object owned by this trigger? If not we are not interested...
if (_objectsType.find(matches[j].objType) == _objectsType.end()) {
continue;
}
const unsigned int objType = matches[j].objType;
const std::string objTypeStr = EVTColContainer::getTypeString(matches[j].objType);
float pt = matches[j].pt;
float eta = matches[j].eta;
float phi = matches[j].phi;
TString maxPt;
if ((unsigned)countobjects[objType] < _NptPlots) {
maxPt = "MaxPt";
maxPt += (countobjects[objType] + 1);
this->fillHist(isPassTrigger, source, objTypeStr, maxPt.Data(), pt);
// Filled the high pt ...
++(countobjects[objType]);
++counttotal;
} else {
if ((unsigned)countobjects[objType] < minCandidates) { // To get correct results for HZZ
++(countobjects[objType]);
++counttotal;
} else
continue; // Otherwise too many entries in Eta and Phi distributions
}
this->fillHist(isPassTrigger, source, objTypeStr, "Eta", eta);
this->fillHist(isPassTrigger, source, objTypeStr, "Phi", phi);
if (counttotal == totalobjectssize2) {
break;
}
}
}
void HLTHiggsPlotter::analyze(const bool &isPassTrigger,
const std::string &source,
const std::vector<MatchStruct> &matches,
std::map<std::string, bool> &nMinOne,
const float &dEtaqq,
const float &mqq,
const float &dPhibb,
const float &CSV1,
const float &CSV2,
const float &CSV3,
const bool &passAllCuts) {
if (!isPassTrigger) {
return;
}
std::map<unsigned int, int> countobjects;
// Initializing the count of the used object
for (std::set<unsigned int>::iterator co = _objectsType.begin(); co != _objectsType.end(); ++co) {
if (!(*co == EVTColContainer::PFJET && source == "gen")) // genJets are not there
countobjects[*co] = 0;
}
int counttotal = 0;
const int totalobjectssize2 = _NptPlots * countobjects.size();
// Fill the histos if pass the trigger (just the two with higher pt)
for (size_t j = 0; j < matches.size(); ++j) {
// Is this object owned by this trigger? If not we are not interested...
if (_objectsType.find(matches[j].objType) == _objectsType.end()) {
continue;
}
const unsigned int objType = matches[j].objType;
const std::string objTypeStr = EVTColContainer::getTypeString(matches[j].objType);
float pt = matches[j].pt;
float eta = matches[j].eta;
float phi = matches[j].phi;
// PFMET N-1 cut
if (objType == EVTColContainer::PFMET && _NminOneCuts[8] && !nMinOne["PFMET"])
continue;
TString maxPt;
if ((unsigned)(countobjects)[objType] < _NptPlots) {
maxPt = "MaxPt";
maxPt += (countobjects[objType] + 1);
if (objType != EVTColContainer::PFJET || nMinOne[maxPt.Data()]) {
this->fillHist(isPassTrigger, source, objTypeStr, maxPt.Data(), pt);
}
++(countobjects[objType]);
++counttotal;
} else
continue; // if not needed (minCandidates == _NptPlots if _useNminOneCuts
if (objType != EVTColContainer::PFJET || passAllCuts) {
this->fillHist(isPassTrigger, source, objTypeStr, "Eta", eta);
this->fillHist(isPassTrigger, source, objTypeStr, "Phi", phi);
}
if (counttotal == totalobjectssize2) {
break;
}
}
if (source == "rec" && _objectsType.find(EVTColContainer::PFJET) != _objectsType.end()) {
if (_NminOneCuts[0] && nMinOne["dEtaqq"]) {
this->fillHist(isPassTrigger, source, EVTColContainer::getTypeString(EVTColContainer::PFJET), "dEtaqq", dEtaqq);
}
if (_NminOneCuts[1] && nMinOne["mqq"]) {
this->fillHist(isPassTrigger, source, EVTColContainer::getTypeString(EVTColContainer::PFJET), "mqq", mqq);
}
if (_NminOneCuts[2] && nMinOne["dPhibb"]) {
this->fillHist(isPassTrigger, source, EVTColContainer::getTypeString(EVTColContainer::PFJET), "dPhibb", dPhibb);
}
if (_NminOneCuts[3]) {
std::string nameCSVplot = "CSV1";
if (_NminOneCuts[6])
nameCSVplot = "maxCSV";
if (nMinOne[nameCSVplot])
this->fillHist(
isPassTrigger, source, EVTColContainer::getTypeString(EVTColContainer::PFJET), nameCSVplot, CSV1);
}
if (_NminOneCuts[4] && nMinOne["CSV2"]) {
this->fillHist(isPassTrigger, source, EVTColContainer::getTypeString(EVTColContainer::PFJET), "CSV2", CSV2);
}
if (_NminOneCuts[5] && nMinOne["CSV3"]) {
this->fillHist(isPassTrigger, source, EVTColContainer::getTypeString(EVTColContainer::PFJET), "CSV3", CSV3);
}
}
}
void HLTHiggsPlotter::bookHist(const std::string &source,
const std::string &objType,
const std::string &variable,
DQMStore::IBooker &ibooker) {
std::string sourceUpper = source;
sourceUpper[0] = std::toupper(sourceUpper[0]);
std::string name = source + objType + variable + "_" + _hltPath;
TH1F *h = nullptr;
if (variable.find("MaxPt") != std::string::npos) {
std::string desc;
if (variable == "MaxPt1")
desc = "Leading";
else if (variable == "MaxPt2")
desc = "Next-to-Leading";
else
desc = variable.substr(5, 6) + "th Leading";
std::string title = "pT of " + desc + " " + sourceUpper + " " + objType +
" "
"where event pass the " +
_hltPath;
const size_t nBinsStandard = _parametersTurnOn.size() - 1;
size_t nBins = nBinsStandard;
float *edges = new float[nBinsStandard + 1];
for (size_t i = 0; i < nBinsStandard + 1; i++) {
edges[i] = _parametersTurnOn[i];
}
std::string jetObj = EVTColContainer::getTypeString(EVTColContainer::PFJET);
if (objType == jetObj) {
const size_t nBinsJets = 25;
nBins = nBinsJets;
delete[] edges;
edges = new float[nBinsJets + 1];
for (size_t i = 0; i < nBinsJets + 1; i++) {
edges[i] = i * 10;
}
}
if (objType == EVTColContainer::getTypeString(EVTColContainer::PFMET)) {
const size_t nBinsJets = 30;
nBins = nBinsJets;
delete[] edges;
edges = new float[nBinsJets + 1];
for (size_t i = 0; i < nBinsJets + 1; i++) {
edges[i] = i * 10;
}
}
h = new TH1F(name.c_str(), title.c_str(), nBins, edges);
delete[] edges;
} else {
if (variable == "dEtaqq") {
std::string title = "#Delta #eta_{qq} of " + sourceUpper + " " + objType;
int nBins = 20;
double min = 0;
double max = 4.8;
h = new TH1F(name.c_str(), title.c_str(), nBins, min, max);
} else if (variable == "mqq") {
std::string title = "m_{qq} of " + sourceUpper + " " + objType;
int nBins = 20;
double min = 0;
double max = 1000;
h = new TH1F(name.c_str(), title.c_str(), nBins, min, max);
} else if (variable == "dPhibb") {
std::string title = "#Delta #phi_{bb} of " + sourceUpper + " " + objType;
int nBins = 10;
double min = 0;
double max = 3.1416;
h = new TH1F(name.c_str(), title.c_str(), nBins, min, max);
} else if (variable == "CSV1") {
std::string title = "CSV1 of " + sourceUpper + " " + objType;
int nBins = 20;
double min = 0;
double max = 1;
h = new TH1F(name.c_str(), title.c_str(), nBins, min, max);
} else if (variable == "CSV2") {
std::string title = "CSV2 of " + sourceUpper + " " + objType;
int nBins = 20;
double min = 0;
double max = 1;
h = new TH1F(name.c_str(), title.c_str(), nBins, min, max);
} else if (variable == "CSV3") {
std::string title = "CSV3 of " + sourceUpper + " " + objType;
int nBins = 20;
double min = 0;
double max = 1;
h = new TH1F(name.c_str(), title.c_str(), nBins, min, max);
} else if (variable == "maxCSV") {
std::string title = "max CSV of " + sourceUpper + " " + objType;
int nBins = 20;
double min = 0;
double max = 1;
h = new TH1F(name.c_str(), title.c_str(), nBins, min, max);
} else {
std::string symbol = (variable == "Eta") ? "#eta" : "#phi";
std::string title = symbol + " of " + sourceUpper + " " + objType + " " + "where event pass the " + _hltPath;
std::vector<double> params = (variable == "Eta") ? _parametersEta : _parametersPhi;
int nBins = (int)params[0];
double min = params[1];
double max = params[2];
h = new TH1F(name.c_str(), title.c_str(), nBins, min, max);
}
}
h->Sumw2();
_elements[name] = ibooker.book1D(name.c_str(), h);
delete h;
}
void HLTHiggsPlotter::fillHist(const bool &passTrigger,
const std::string &source,
const std::string &objType,
const std::string &variable,
const float &value) {
std::string sourceUpper = source;
sourceUpper[0] = toupper(sourceUpper[0]);
std::string name = source + objType + variable + "_" + _hltPath;
_elements[name]->Fill(value);
}
|