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
|
/*
* \file DQMFEDIntegrityClient.cc
* \author M. Marienfeld
* Last Update:
*
* Description: Summing up FED entries from all subdetectors.
*
*/
#include <string>
#include <vector>
#include "FWCore/Framework/interface/one/EDAnalyzer.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "DQMServices/Core/interface/DQMStore.h"
#include "FWCore/ServiceRegistry/interface/Service.h"
//
// class declaration
//
class DQMFEDIntegrityClient : public edm::one::EDAnalyzer<edm::one::WatchRuns, edm::one::WatchLuminosityBlocks> {
public:
typedef dqm::legacy::DQMStore DQMStore;
typedef dqm::legacy::MonitorElement MonitorElement;
DQMFEDIntegrityClient(const edm::ParameterSet&);
~DQMFEDIntegrityClient() override = default;
protected:
void beginJob() override;
void beginRun(const edm::Run& r, const edm::EventSetup& c) override;
/// Analyze
void analyze(const edm::Event& e, const edm::EventSetup& c) override;
void beginLuminosityBlock(const edm::LuminosityBlock& l, const edm::EventSetup& c) override;
void endLuminosityBlock(const edm::LuminosityBlock& l, const edm::EventSetup& c) override;
void endRun(const edm::Run& r, const edm::EventSetup& c) override;
void endJob() override;
private:
void initialize();
void fillHistograms();
edm::ParameterSet parameters_;
DQMStore* dbe_;
// ---------- member data ----------
int NBINS;
float XMIN, XMAX;
float SummaryContent[10];
MonitorElement* FedEntries;
MonitorElement* FedFatal;
MonitorElement* FedNonFatal;
MonitorElement* reportSummary;
MonitorElement* reportSummaryContent[10];
MonitorElement* reportSummaryMap;
bool fillInEventloop;
bool fillOnEndRun;
bool fillOnEndJob;
bool fillOnEndLumi;
std::string moduleName;
std::string fedFolderName;
};
// -----------------------------
// constructors and destructor
// -----------------------------
DQMFEDIntegrityClient::DQMFEDIntegrityClient(const edm::ParameterSet& ps) {
parameters_ = ps;
initialize();
fillInEventloop = ps.getUntrackedParameter<bool>("fillInEventloop", false);
fillOnEndRun = ps.getUntrackedParameter<bool>("fillOnEndRun", false);
fillOnEndJob = ps.getUntrackedParameter<bool>("fillOnEndJob", false);
fillOnEndLumi = ps.getUntrackedParameter<bool>("fillOnEndLumi", true);
moduleName = ps.getUntrackedParameter<std::string>("moduleName", "FED");
fedFolderName = ps.getUntrackedParameter<std::string>("fedFolderName", "FEDIntegrity");
}
void DQMFEDIntegrityClient::initialize() {
// get back-end interface
dbe_ = edm::Service<DQMStore>().operator->();
}
void DQMFEDIntegrityClient::beginJob() {
NBINS = 850;
XMIN = 0.;
XMAX = 850.;
dbe_ = edm::Service<DQMStore>().operator->();
// ----------------------------------------------------------------------------------
std::string currentFolder = moduleName + "/" + fedFolderName;
dbe_->setCurrentFolder(currentFolder);
FedEntries = dbe_->book1D("FedEntries", "FED Entries", NBINS, XMIN, XMAX);
FedFatal = dbe_->book1D("FedFatal", "FED Fatal Errors", NBINS, XMIN, XMAX);
FedNonFatal = dbe_->book1D("FedNonFatal", "FED Non Fatal Errors", NBINS, XMIN, XMAX);
FedEntries->setAxisTitle("", 1);
FedFatal->setAxisTitle("", 1);
FedNonFatal->setAxisTitle("", 1);
FedEntries->setAxisTitle("", 2);
FedFatal->setAxisTitle("", 2);
FedNonFatal->setAxisTitle("", 2);
FedEntries->setBinLabel(11, "PIXEL", 1);
FedEntries->setBinLabel(221, "SIST", 1);
FedEntries->setBinLabel(606, "EE", 1);
FedEntries->setBinLabel(628, "EB", 1);
FedEntries->setBinLabel(651, "EE", 1);
FedEntries->setBinLabel(550, "ES", 1);
FedEntries->setBinLabel(716, "HCAL", 1);
FedEntries->setBinLabel(754, "CSC", 1);
FedEntries->setBinLabel(772, "DT", 1);
FedEntries->setBinLabel(791, "RPC", 1);
FedEntries->setBinLabel(804, "L1T", 1);
FedFatal->setBinLabel(11, "PIXEL", 1);
FedFatal->setBinLabel(221, "SIST", 1);
FedFatal->setBinLabel(606, "EE", 1);
FedFatal->setBinLabel(628, "EB", 1);
FedFatal->setBinLabel(651, "EE", 1);
FedFatal->setBinLabel(550, "ES", 1);
FedFatal->setBinLabel(716, "HCAL", 1);
FedFatal->setBinLabel(754, "CSC", 1);
FedFatal->setBinLabel(772, "DT", 1);
FedFatal->setBinLabel(791, "RPC", 1);
FedFatal->setBinLabel(804, "L1T", 1);
FedNonFatal->setBinLabel(11, "PIXEL", 1);
FedNonFatal->setBinLabel(221, "SIST", 1);
FedNonFatal->setBinLabel(606, "EE", 1);
FedNonFatal->setBinLabel(628, "EB", 1);
FedNonFatal->setBinLabel(651, "EE", 1);
FedNonFatal->setBinLabel(550, "ES", 1);
FedNonFatal->setBinLabel(716, "HCAL", 1);
FedNonFatal->setBinLabel(754, "CSC", 1);
FedNonFatal->setBinLabel(772, "DT", 1);
FedNonFatal->setBinLabel(791, "RPC", 1);
FedNonFatal->setBinLabel(804, "L1T", 1);
//-----------------------------------------------------------------------------------
currentFolder = moduleName + "/EventInfo";
dbe_->setCurrentFolder(currentFolder);
reportSummary = dbe_->bookFloat("reportSummary");
int nSubsystems = 10;
if (reportSummary)
reportSummary->Fill(1.);
currentFolder = moduleName + "/EventInfo/reportSummaryContents";
dbe_->setCurrentFolder(currentFolder);
reportSummaryContent[0] = dbe_->bookFloat("CSC FEDs");
reportSummaryContent[1] = dbe_->bookFloat("DT FEDs");
reportSummaryContent[2] = dbe_->bookFloat("EB FEDs");
reportSummaryContent[3] = dbe_->bookFloat("EE FEDs");
reportSummaryContent[4] = dbe_->bookFloat("ES FEDs");
reportSummaryContent[5] = dbe_->bookFloat("Hcal FEDs");
reportSummaryContent[6] = dbe_->bookFloat("L1T FEDs");
reportSummaryContent[7] = dbe_->bookFloat("Pixel FEDs");
reportSummaryContent[8] = dbe_->bookFloat("RPC FEDs");
reportSummaryContent[9] = dbe_->bookFloat("SiStrip FEDs");
// initialize reportSummaryContents to 1
for (int i = 0; i < nSubsystems; ++i) {
SummaryContent[i] = 1.;
reportSummaryContent[i]->Fill(1.);
}
currentFolder = moduleName + "/EventInfo";
dbe_->setCurrentFolder(currentFolder);
reportSummaryMap = dbe_->book2D("reportSummaryMap", "FED Report Summary Map", 1, 1, 2, 10, 1, 11);
reportSummaryMap->setAxisTitle("", 1);
reportSummaryMap->setAxisTitle("", 2);
reportSummaryMap->setBinLabel(1, " ", 1);
reportSummaryMap->setBinLabel(10, "CSC", 2);
reportSummaryMap->setBinLabel(9, "DT", 2);
reportSummaryMap->setBinLabel(8, "EB", 2);
reportSummaryMap->setBinLabel(7, "EE", 2);
reportSummaryMap->setBinLabel(6, "ES", 2);
reportSummaryMap->setBinLabel(5, "Hcal", 2);
reportSummaryMap->setBinLabel(4, "L1T", 2);
reportSummaryMap->setBinLabel(3, "Pixel", 2);
reportSummaryMap->setBinLabel(2, "RPC", 2);
reportSummaryMap->setBinLabel(1, "SiStrip", 2);
}
void DQMFEDIntegrityClient::beginRun(const edm::Run& r, const edm::EventSetup& context) {}
void DQMFEDIntegrityClient::analyze(const edm::Event& e, const edm::EventSetup& context) {
if (fillInEventloop)
fillHistograms();
}
void DQMFEDIntegrityClient::beginLuminosityBlock(const edm::LuminosityBlock& l, const edm::EventSetup& c) {}
void DQMFEDIntegrityClient::endLuminosityBlock(const edm::LuminosityBlock& lumiBlock, const edm::EventSetup& context) {
if (fillOnEndLumi)
fillHistograms();
}
void DQMFEDIntegrityClient::fillHistograms() {
// FED Entries
std::vector<std::string> entries;
entries.push_back("CSC/" + fedFolderName + "/FEDEntries");
entries.push_back("DT/" + fedFolderName + "/FEDEntries");
entries.push_back("EcalBarrel/" + fedFolderName + "/FEDEntries");
entries.push_back("EcalEndcap/" + fedFolderName + "/FEDEntries");
entries.push_back("EcalPreshower/" + fedFolderName + "/FEDEntries");
entries.push_back("Hcal/" + fedFolderName + "/FEDEntries");
entries.push_back("L1T/" + fedFolderName + "/FEDEntries");
entries.push_back("Pixel/" + fedFolderName + "/FEDEntries");
entries.push_back("RPC/" + fedFolderName + "/FEDEntries");
entries.push_back("SiStrip/" + fedFolderName + "/FEDEntries");
for (auto ent = entries.begin(); ent != entries.end(); ++ent) {
if (!(dbe_->get(*ent))) {
continue;
}
MonitorElement* me = dbe_->get(*ent);
if (TH1F* rootHisto = me->getTH1F()) {
int Nbins = me->getNbinsX();
float entry = 0.;
int xmin = (int)rootHisto->GetXaxis()->GetXmin();
if (*ent == "L1T/" + fedFolderName + "/FEDEntries")
xmin = xmin + 800;
if (*ent == "DT/" + fedFolderName + "/FEDEntries")
xmin = 770; //Real DT FEDIDs are 1369-1371
for (int bin = 1; bin <= Nbins; ++bin) {
int id = xmin + bin;
entry = rootHisto->GetBinContent(bin);
if (entry > 0.)
FedEntries->setBinContent(id, entry);
}
}
}
// FED Fatal
int nSubsystems = 10;
std::vector<std::string> fatal;
fatal.push_back("CSC/" + fedFolderName + "/FEDFatal");
fatal.push_back("DT/" + fedFolderName + "/FEDFatal");
fatal.push_back("EcalBarrel/" + fedFolderName + "/FEDFatal");
fatal.push_back("EcalEndcap/" + fedFolderName + "/FEDFatal");
fatal.push_back("EcalPreshower/" + fedFolderName + "/FEDFatal");
fatal.push_back("Hcal/" + fedFolderName + "/FEDFatal");
fatal.push_back("L1T/" + fedFolderName + "/FEDFatal");
fatal.push_back("Pixel/" + fedFolderName + "/FEDFatal");
fatal.push_back("RPC/" + fedFolderName + "/FEDFatal");
fatal.push_back("SiStrip/" + fedFolderName + "/FEDFatal");
int k = 0, count = 0;
float sum = 0.;
auto ent = entries.begin();
for (auto fat = fatal.begin(); fat != fatal.end(); ++fat) {
if (!(dbe_->get(*fat))) {
reportSummaryContent[k]->Fill(-1);
reportSummaryMap->setBinContent(1, nSubsystems - k, -1);
k++;
ent++;
continue;
}
MonitorElement* me = dbe_->get(*fat);
MonitorElement* meNorm = dbe_->get(*ent);
float entry = 0.;
float norm = 0.;
if (TH1F* rootHisto = me->getTH1F()) {
if (TH1F* rootHistoNorm = meNorm->getTH1F()) {
int Nbins = me->getNbinsX();
int xmin = (int)rootHisto->GetXaxis()->GetXmin();
if (*fat == "L1T/" + fedFolderName + "/FEDFatal")
xmin = xmin + 800;
if (*fat == "DT/" + fedFolderName + "/FEDFatal")
xmin = 770; //Real DT FED IDs are 1369-1371
float binentry = 0.;
for (int bin = 1; bin <= Nbins; ++bin) {
int id = xmin + bin;
binentry = rootHisto->GetBinContent(bin);
entry += binentry;
norm += rootHistoNorm->GetBinContent(bin);
FedFatal->setBinContent(id, binentry);
}
}
}
if (norm > 0)
SummaryContent[k] = 1.0 - entry / norm;
reportSummaryContent[k]->Fill(SummaryContent[k]);
if ((k == 2 || k == 3) // for EE and EB only show yellow when more than 1% errors.
&& SummaryContent[k] >= 0.95 && SummaryContent[k] < 0.99)
SummaryContent[k] = 0.949;
reportSummaryMap->setBinContent(1, nSubsystems - k, SummaryContent[k]);
sum = sum + SummaryContent[k];
k++;
ent++;
count++;
}
if (count > 0)
reportSummary->Fill(sum / (float)count);
// FED Non Fatal
std::vector<std::string> nonfatal;
nonfatal.push_back("CSC/" + fedFolderName + "/FEDNonFatal");
nonfatal.push_back("DT/" + fedFolderName + "/FEDNonFatal");
nonfatal.push_back("EcalBarrel/" + fedFolderName + "/FEDNonFatal");
nonfatal.push_back("EcalEndcap/" + fedFolderName + "/FEDNonFatal");
nonfatal.push_back("EcalPreshower/" + fedFolderName + "/FEDNonFatal");
nonfatal.push_back("Hcal/" + fedFolderName + "/FEDNonFatal");
nonfatal.push_back("L1T/" + fedFolderName + "/FEDNonFatal");
nonfatal.push_back("Pixel/" + fedFolderName + "/FEDNonFatal");
nonfatal.push_back("RPC/" + fedFolderName + "/FEDNonFatal");
nonfatal.push_back("SiStrip/" + fedFolderName + "/FEDNonFatal");
for (auto non = nonfatal.begin(); non != nonfatal.end(); ++non) {
if (!(dbe_->get(*non))) {
continue;
}
MonitorElement* me = dbe_->get(*non);
if (TH1F* rootHisto = me->getTH1F()) {
int Nbins = me->getNbinsX();
float entry = 0.;
int xmin = (int)rootHisto->GetXaxis()->GetXmin();
if (*non == "L1T/" + fedFolderName + "/FEDNonFatal")
xmin = xmin + 800;
for (int bin = 1; bin <= Nbins; ++bin) {
int id = xmin + bin;
entry = rootHisto->GetBinContent(bin);
if (entry > 0.)
FedNonFatal->setBinContent(id, entry);
}
}
}
}
void DQMFEDIntegrityClient::endRun(const edm::Run& r, const edm::EventSetup& context) {
if (fillOnEndRun)
fillHistograms();
}
void DQMFEDIntegrityClient::endJob() {
if (fillOnEndJob)
fillHistograms();
}
#include "FWCore/PluginManager/interface/ModuleDef.h"
#include "FWCore/Framework/interface/MakerMacros.h"
DEFINE_FWK_MODULE(DQMFEDIntegrityClient);
|