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
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
|
#include "DQM/L1TMonitorClient/interface/L1TTestsSummary.h"
#include "FWCore/ServiceRegistry/interface/Service.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "DQMServices/Core/interface/DQMStore.h"
#include <cstdio>
#include <sstream>
#include <cmath>
#include <vector>
#include <TMath.h>
#include <climits>
#include <TFile.h>
#include <TDirectory.h>
#include <TProfile.h>
using namespace std;
using namespace edm;
//____________________________________________________________________________
// Function: L1TTestsSummary
// Description: This is the constructor, basic variable initialization
// Inputs:
// * const edm::ParameterSet& ps = Parameter for this analyzer
//____________________________________________________________________________
L1TTestsSummary::L1TTestsSummary(const edm::ParameterSet &ps) {
if (mVerbose) {
cout << "[L1TTestsSummary:] Called constructor" << endl;
}
// Get parameters
mParameters = ps;
mVerbose = ps.getUntrackedParameter<bool>("verbose", true);
mMonitorL1TRate = ps.getUntrackedParameter<bool>("MonitorL1TRate", true);
mMonitorL1TSync = ps.getUntrackedParameter<bool>("MonitorL1TSync", true);
mMonitorL1TOccupancy = ps.getUntrackedParameter<bool>("MonitorL1TOccupancy", true);
mL1TRatePath = ps.getUntrackedParameter<string>("L1TRatePath", "L1T/L1TRate/Certification/");
mL1TSyncPath = ps.getUntrackedParameter<string>("L1TSyncPath", "L1T/L1TSync/Certification/");
mL1TOccupancyPath = ps.getUntrackedParameter<string>("L1TOccupancyPath", "L1T/L1TOccupancy/Certification/");
}
//____________________________________________________________________________
// Function: ~L1TTestsSummary
// Description: This is the destructor, basic variable deletion
//____________________________________________________________________________
L1TTestsSummary::~L1TTestsSummary() {
if (mVerbose) {
cout << "[L1TTestsSummary:] Called destructor" << endl;
}
}
//____________________________________________________________________________
// Function: beginRun
// Description: This is will be run at the begining of each run
// Inputs:
// * const Run& r = Run information
// * const EventSetup& context = Event Setup information
//____________________________________________________________________________
void L1TTestsSummary::book(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter) {
if (mVerbose) {
cout << "[L1TTestsSummary:] Called beginRun" << endl;
}
int maxLS = 2500;
if (mMonitorL1TRate) {
if (mVerbose) {
cout << "[L1TTestsSummary:] Initializing L1TRate Module Monitoring" << endl;
}
igetter.setCurrentFolder(mL1TRatePath);
vector<string> histToMonitor = igetter.getMEs();
int histLines = histToMonitor.size() + 1;
ibooker.setCurrentFolder("L1T/L1TTestsSummary/");
mL1TRateMonitor = ibooker.book2D(
"RateQualitySummary", "L1T Rates Monitor Summary", maxLS, +0.5, double(maxLS) + 0.5, histLines, 0, histLines);
mL1TRateMonitor->setAxisTitle("Lumi Section", 1);
mL1TRateMonitor->setBinLabel(1, "Summary", 2);
for (unsigned int i = 0; i < histToMonitor.size(); i++) {
string name = igetter.get(mL1TRatePath + histToMonitor[i])->getTH1()->GetName();
mL1TRateMonitor->setBinLabel(i + 2, name, 2);
}
}
if (mMonitorL1TSync) {
if (mVerbose) {
cout << "[L1TTestsSummary:] Initializing L1TSync Module Monitoring" << endl;
}
igetter.setCurrentFolder(mL1TSyncPath);
vector<string> histToMonitor = igetter.getMEs();
int histLines = histToMonitor.size() + 1;
ibooker.setCurrentFolder("L1T/L1TTestsSummary/");
mL1TSyncMonitor = ibooker.book2D("SyncQualitySummary",
"L1T Synchronization Monitor Summary",
maxLS,
0.5,
double(maxLS) + 0.5,
histLines,
0,
histLines);
mL1TSyncMonitor->setAxisTitle("Lumi Section", 1);
mL1TSyncMonitor->setBinLabel(1, "Summary", 2);
for (unsigned int i = 0; i < histToMonitor.size(); i++) {
string name = igetter.get(mL1TSyncPath + histToMonitor[i])->getTH1()->GetName();
mL1TSyncMonitor->setBinLabel(i + 2, name, 2);
}
}
if (mMonitorL1TOccupancy) {
if (mVerbose) {
cout << "[L1TTestsSummary:] Initializing L1TOccupancy Module Monitoring" << endl;
}
igetter.setCurrentFolder(mL1TOccupancyPath);
vector<string> histToMonitor = igetter.getMEs();
int histLines = histToMonitor.size() + 1;
ibooker.setCurrentFolder("L1T/L1TTestsSummary/");
mL1TOccupancyMonitor = ibooker.book2D(
"OccupancySummary", "L1T Occupancy Monitor Summary", maxLS, +0.5, double(maxLS) + 0.5, histLines, 0, histLines);
mL1TOccupancyMonitor->setAxisTitle("Lumi Section", 1);
mL1TOccupancyMonitor->setBinLabel(1, "Summary", 2);
for (unsigned int i = 0; i < histToMonitor.size(); i++) {
string name = igetter.get(mL1TOccupancyPath + histToMonitor[i])->getTH1()->GetName();
mL1TOccupancyMonitor->setBinLabel(i + 2, name, 2);
}
}
//-> Making the summary of summaries
int testsToMonitor = 1;
if (mMonitorL1TRate) {
testsToMonitor++;
}
if (mMonitorL1TSync) {
testsToMonitor++;
}
if (mMonitorL1TOccupancy) {
testsToMonitor++;
}
// Creating
ibooker.setCurrentFolder("L1T/L1TTestsSummary/");
mL1TSummary = ibooker.book2D(
"L1TQualitySummary", "L1 Tests Summary", maxLS, +0.5, double(maxLS) + 0.5, testsToMonitor, 0, testsToMonitor);
mL1TSummary->setAxisTitle("Lumi Section", 1);
mL1TSummary->setBinLabel(1, "L1T Summary", 2);
int it = 2;
if (mMonitorL1TRate) {
mL1TSummary->setBinLabel(it, "Rates", 2);
binYRate = it;
it++;
}
if (mMonitorL1TSync) {
mL1TSummary->setBinLabel(it, "Synchronization", 2);
binYSync = it;
it++;
}
if (mMonitorL1TOccupancy) {
mL1TSummary->setBinLabel(it, "Occupancy", 2);
binYOccpancy = it;
}
}
//____________________________________________________________________________
// Function: endRun
// Description: This is will be run at the end of each run
// Inputs:
// * const Run& r = Run information
// * const EventSetup& context = Event Setup information
//____________________________________________________________________________
void L1TTestsSummary::dqmEndJob(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter) {
book(ibooker, igetter);
if (mVerbose) {
cout << "[L1TTestsSummary:] Called endRun()" << endl;
}
if (mMonitorL1TRate) {
updateL1TRateMonitor(ibooker, igetter);
}
if (mMonitorL1TSync) {
updateL1TSyncMonitor(ibooker, igetter);
}
if (mMonitorL1TOccupancy) {
updateL1TOccupancyMonitor(ibooker, igetter);
}
updateL1TSummary(ibooker, igetter);
}
//____________________________________________________________________________
// Function: endLuminosityBlock
// Description: This is will be run at the end of each luminosity block
// Inputs:
// * const LuminosityBlock& lumiSeg = Luminosity Block information
// * const EventSetup& context = Event Setup information
//____________________________________________________________________________
void L1TTestsSummary::dqmEndLuminosityBlock(DQMStore::IBooker &ibooker,
DQMStore::IGetter &igetter,
const edm::LuminosityBlock &lumiSeg,
const edm::EventSetup &c) {
int eventLS = lumiSeg.id().luminosityBlock();
book(ibooker, igetter);
mProcessedLS.push_back(eventLS);
if (mVerbose) {
cout << "[L1TTestsSummary:] Called endLuminosityBlock()" << endl;
cout << "[L1TTestsSummary:] Lumisection: " << eventLS << endl;
}
if (mMonitorL1TRate) {
updateL1TRateMonitor(ibooker, igetter);
}
if (mMonitorL1TSync) {
updateL1TSyncMonitor(ibooker, igetter);
}
if (mMonitorL1TOccupancy) {
updateL1TOccupancyMonitor(ibooker, igetter);
}
updateL1TSummary(ibooker, igetter);
}
//____________________________________________________________________________
// Function: updateL1TRateMonitor
// Description:
//____________________________________________________________________________
void L1TTestsSummary::updateL1TRateMonitor(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter) {
igetter.setCurrentFolder(mL1TRatePath);
vector<string> histToMonitor = igetter.getMEs();
for (unsigned int i = 0; i < histToMonitor.size(); i++) {
MonitorElement *me = igetter.get(mL1TRatePath + histToMonitor[i]);
if (mVerbose) {
cout << "[L1TTestsSummary:] Found ME: " << me->getTH1()->GetName() << endl;
}
const QReport *myQReport = me->getQReport("L1TRateTest"); //get QReport associated to your ME
if (myQReport) {
float qtresult = myQReport->getQTresult(); // get QT result value
int qtstatus = myQReport->getStatus(); // get QT status value (see table below)
const string &qtmessage = myQReport->getMessage(); // get the whole QT result message
vector<DQMChannel> qtBadChannels = myQReport->getBadChannels();
if (mVerbose) {
cout << "[L1TTestsSummary:] Found QReport for ME: " << me->getTH1()->GetName() << endl;
cout << "[L1TTestsSummary:] Result=" << qtresult << " status=" << qtstatus << " message=" << qtmessage << endl;
cout << "[L1TTestsSummary:] Bad Channels size=" << qtBadChannels.size() << endl;
}
for (unsigned int i = 0; i < mProcessedLS.size() - 1; i++) {
int binx = mL1TRateMonitor->getTH2F()->GetXaxis()->FindBin(mProcessedLS[i]);
int biny = mL1TRateMonitor->getTH2F()->GetYaxis()->FindBin(me->getTH1()->GetName());
mL1TRateMonitor->setBinContent(binx, biny, 100);
}
for (unsigned int a = 0; a < qtBadChannels.size(); a++) {
for (unsigned int b = 0; b < mProcessedLS.size() - 1; b++) {
// Converting bin to value
double valueBinBad = me->getTH1()->GetBinCenter(qtBadChannels[a].getBin());
if (valueBinBad == (mProcessedLS[b])) {
int binx = mL1TRateMonitor->getTH2F()->GetXaxis()->FindBin(valueBinBad);
int biny = mL1TRateMonitor->getTH2F()->GetYaxis()->FindBin(me->getTH1()->GetName());
mL1TRateMonitor->setBinContent(binx, biny, 300);
}
}
}
}
}
//-> Filling the summaries
int nBinX = mL1TRateMonitor->getTH2F()->GetXaxis()->GetNbins();
int nBinY = mL1TRateMonitor->getTH2F()->GetYaxis()->GetNbins();
for (int binx = 1; binx <= nBinX; binx++) {
int GlobalStatus = 0;
for (int biny = 2; biny <= nBinY; biny++) {
double flag = mL1TRateMonitor->getBinContent(binx, biny);
if (GlobalStatus < flag) {
GlobalStatus = flag;
}
}
// NOTE: Assumes mL1TSummary has same size then mL1TRateMonitor
mL1TRateMonitor->setBinContent(binx, 1, GlobalStatus);
mL1TSummary->setBinContent(binx, binYRate, GlobalStatus);
}
}
//____________________________________________________________________________
// Function: updateL1TSyncMonitor
// Description:
// Note: Values certified by L1TRates are always about currentLS-1 since we
// use rate averages from the previous LS from GT
//____________________________________________________________________________
void L1TTestsSummary::updateL1TSyncMonitor(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter) {
igetter.setCurrentFolder(mL1TSyncPath);
vector<string> histToMonitor = igetter.getMEs();
for (unsigned int i = 0; i < histToMonitor.size(); i++) {
MonitorElement *me = igetter.get(mL1TSyncPath + histToMonitor[i]);
if (mVerbose) {
cout << "[L1TTestsSummary:] Found ME: " << me->getTH1()->GetName() << endl;
}
const QReport *myQReport = me->getQReport("L1TSyncTest"); //get QReport associated to your ME
if (myQReport) {
float qtresult = myQReport->getQTresult(); // get QT result value
int qtstatus = myQReport->getStatus(); // get QT status value (see table below)
const string &qtmessage = myQReport->getMessage(); // get the whole QT result message
vector<DQMChannel> qtBadChannels = myQReport->getBadChannels();
if (mVerbose) {
cout << "[L1TTestsSummary:] Found QReport for ME: " << me->getTH1()->GetName() << endl;
cout << "[L1TTestsSummary:] Result=" << qtresult << " status=" << qtstatus << " message=" << qtmessage << endl;
cout << "[L1TTestsSummary:] Bad Channels size=" << qtBadChannels.size() << endl;
}
for (unsigned int i = 0; i < mProcessedLS.size(); i++) {
int binx = mL1TSyncMonitor->getTH2F()->GetXaxis()->FindBin(mProcessedLS[i]);
int biny = mL1TSyncMonitor->getTH2F()->GetYaxis()->FindBin(me->getTH1()->GetName());
mL1TSyncMonitor->setBinContent(binx, biny, 100);
}
for (unsigned int a = 0; a < qtBadChannels.size(); a++) {
for (unsigned int b = 0; b < mProcessedLS.size(); b++) {
// Converting bin to value
double valueBinBad = me->getTH1()->GetBinCenter(qtBadChannels[a].getBin());
if (valueBinBad == mProcessedLS[b]) {
int binx = mL1TSyncMonitor->getTH2F()->GetXaxis()->FindBin(valueBinBad);
int biny = mL1TSyncMonitor->getTH2F()->GetYaxis()->FindBin(me->getTH1()->GetName());
mL1TSyncMonitor->setBinContent(binx, biny, 300);
}
}
}
}
}
//-> Filling the summaries
int nBinX = mL1TSyncMonitor->getTH2F()->GetXaxis()->GetNbins();
int nBinY = mL1TSyncMonitor->getTH2F()->GetYaxis()->GetNbins();
for (int binx = 1; binx <= nBinX; binx++) {
int GlobalStatus = 0;
for (int biny = 2; biny <= nBinY; biny++) {
double flag = mL1TSyncMonitor->getBinContent(binx, biny);
if (GlobalStatus < flag) {
GlobalStatus = flag;
}
}
// NOTE: Assumes mL1TSummary has same size then mL1TSyncMonitor
mL1TSyncMonitor->setBinContent(binx, 1, GlobalStatus);
mL1TSummary->setBinContent(binx, binYSync, GlobalStatus);
}
}
//____________________________________________________________________________
// Function: updateL1TOccupancyMonitor
// Description:
//____________________________________________________________________________
void L1TTestsSummary::updateL1TOccupancyMonitor(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter) {
igetter.setCurrentFolder(mL1TOccupancyPath);
vector<string> histToMonitor = igetter.getMEs();
for (unsigned int i = 0; i < histToMonitor.size(); i++) {
MonitorElement *me = igetter.get(mL1TOccupancyPath + histToMonitor[i]);
if (mVerbose) {
cout << "[L1TTestsSummary:] Found ME: " << me->getTH1()->GetName() << endl;
}
const QReport *myQReport = me->getQReport("L1TOccupancyTest"); //get QReport associated to your ME
if (myQReport) {
float qtresult = myQReport->getQTresult(); // get QT result value
int qtstatus = myQReport->getStatus(); // get QT status value (see table below)
const string &qtmessage = myQReport->getMessage(); // get the whole QT result message
vector<DQMChannel> qtBadChannels = myQReport->getBadChannels();
if (mVerbose) {
cout << "[L1TTestsSummary:] Found QReport for ME: " << me->getTH1()->GetName() << endl;
cout << "[L1TTestsSummary:] Result=" << qtresult << " status=" << qtstatus << " message=" << qtmessage << endl;
cout << "[L1TTestsSummary:] Bad Channels size=" << qtBadChannels.size() << endl;
}
for (unsigned int i = 0; i < mProcessedLS.size(); i++) {
int binx = mL1TOccupancyMonitor->getTH2F()->GetXaxis()->FindBin(mProcessedLS[i]);
int biny = mL1TOccupancyMonitor->getTH2F()->GetYaxis()->FindBin(me->getTH1()->GetName());
mL1TOccupancyMonitor->setBinContent(binx, biny, 100);
}
for (unsigned int a = 0; a < qtBadChannels.size(); a++) {
for (unsigned int b = 0; b < mProcessedLS.size(); b++) {
// Converting bin to value
double valueBinBad = me->getTH1()->GetBinCenter(qtBadChannels[a].getBin());
if (valueBinBad == mProcessedLS[b]) {
int binx = mL1TOccupancyMonitor->getTH2F()->GetXaxis()->FindBin(valueBinBad);
int biny = mL1TOccupancyMonitor->getTH2F()->GetYaxis()->FindBin(me->getTH1()->GetName());
mL1TOccupancyMonitor->setBinContent(binx, biny, 300);
}
}
}
}
}
//-> Filling the summaries
int nBinX = mL1TOccupancyMonitor->getTH2F()->GetXaxis()->GetNbins();
int nBinY = mL1TOccupancyMonitor->getTH2F()->GetYaxis()->GetNbins();
for (int binx = 1; binx <= nBinX; binx++) {
int GlobalStatus = 0;
for (int biny = 2; biny <= nBinY; biny++) {
double flag = mL1TOccupancyMonitor->getBinContent(binx, biny);
if (GlobalStatus < flag) {
GlobalStatus = flag;
}
}
// NOTE: Assumes mL1TSummary has same size then mL1TOccupancyMonitor
mL1TOccupancyMonitor->setBinContent(binx, 1, GlobalStatus);
mL1TSummary->setBinContent(binx, binYOccpancy, GlobalStatus);
}
}
//____________________________________________________________________________
// Function: updateL1TOccupancyMonitor
// Description:
//____________________________________________________________________________
void L1TTestsSummary::updateL1TSummary(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter) {
int nBinX = mL1TSummary->getTH2F()->GetXaxis()->GetNbins();
for (int binx = 1; binx <= nBinX; binx++) {
int GlobalStatus = 0;
if (mMonitorL1TRate) {
if (mL1TSummary->getBinContent(binx, binYRate) > GlobalStatus) {
GlobalStatus = mL1TSummary->getBinContent(binx, binYRate);
}
}
if (mMonitorL1TSync) {
if (mL1TSummary->getBinContent(binx, binYSync) > GlobalStatus) {
GlobalStatus = mL1TSummary->getBinContent(binx, binYSync);
}
}
if (mMonitorL1TOccupancy) {
if (mL1TSummary->getBinContent(binx, binYOccpancy) > GlobalStatus) {
GlobalStatus = mL1TSummary->getBinContent(binx, binYOccpancy);
}
}
mL1TSummary->setBinContent(binx, 1, GlobalStatus);
}
}
//define this as a plug-in
DEFINE_FWK_MODULE(L1TTestsSummary);
|