File indexing completed on 2024-09-11 04:32:28
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #include "DQM/DTMonitorModule/interface/DTDataIntegrityTask.h"
0014 #include "DQM/DTMonitorModule/interface/DTTimeEvolutionHisto.h"
0015 #include "FWCore/ServiceRegistry/interface/Service.h"
0016 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0017 #include "DataFormats/FEDRawData/interface/FEDNumbering.h"
0018 #include "FWCore/Utilities/interface/Exception.h"
0019
0020 #include <cmath>
0021 #include <fstream>
0022 #include <map>
0023 #include <string>
0024 #include <vector>
0025
0026 using namespace std;
0027 using namespace edm;
0028
0029 DTDataIntegrityTask::DTDataIntegrityTask(const edm::ParameterSet& ps)
0030 : nevents(0), FEDIDmin(FEDNumbering::MINDTUROSFEDID), FEDIDmax(FEDNumbering::MAXDTUROSFEDID) {
0031 LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask") << "[DTDataIntegrityTask]: Constructor" << endl;
0032
0033 fedToken = consumes<DTuROSFEDDataCollection>(ps.getUntrackedParameter<InputTag>("dtFEDlabel"));
0034
0035 #ifdef EDM_ML_DEBUG
0036 neventsFED = 0;
0037 neventsuROS = 0;
0038 #endif
0039
0040 fedIntegrityFolder = ps.getUntrackedParameter<string>("fedIntegrityFolder", "DT/FEDIntegrity");
0041 nLinksForFatal = ps.getUntrackedParameter<int>("nLinksForFatal", 15);
0042
0043 string processingMode = ps.getUntrackedParameter<string>("processingMode", "Online");
0044
0045
0046 if (processingMode == "Online") {
0047 mode = 0;
0048 } else if (processingMode == "SM") {
0049 mode = 1;
0050 } else if (processingMode == "Offline") {
0051 mode = 2;
0052 } else if (processingMode == "HLT") {
0053 mode = 3;
0054 } else {
0055 throw cms::Exception("MissingParameter") << "[DTDataIntegrityTask]: processingMode :" << processingMode
0056 << " invalid! Must be Online, SM, Offline or HLT !" << endl;
0057 }
0058 }
0059
0060 DTDataIntegrityTask::~DTDataIntegrityTask() {
0061 #ifdef EDM_ML_DEBUG
0062 LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
0063 << "[DTDataIntegrityTask]: Destructor. Analyzed " << neventsFED << " events" << endl;
0064 LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
0065 << "[DTDataIntegrityTask]: postEndJob called!" << endl;
0066 #endif
0067 }
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078 void DTDataIntegrityTask::bookHistograms(DQMStore::IBooker& ibooker,
0079 edm::Run const& iRun,
0080 edm::EventSetup const& iSetup) {
0081 LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask") << "[DTDataIntegrityTask]: postBeginJob" << endl;
0082
0083 LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
0084 << "[DTDataIntegrityTask] Get DQMStore service" << endl;
0085
0086
0087
0088 LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
0089 << " FEDS: " << FEDIDmin << " to " << FEDIDmax << " in the RO" << endl;
0090
0091
0092 bookHistos(ibooker, FEDIDmin, FEDIDmax);
0093
0094
0095
0096 if (mode == 0 || mode == 2) {
0097 for (int fed = FEDIDmin; fed <= FEDIDmax; ++fed) {
0098
0099 bookHistos(ibooker, string("FED"), fed);
0100
0101 bookHistos(ibooker, string("CRATE"), fed);
0102
0103 for (int uRos = 1; uRos <= NuROS; ++uRos) {
0104 bookHistosuROS(ibooker, fed, uRos);
0105 }
0106 }
0107
0108 for (int wheel = -2; wheel < 3; ++wheel) {
0109 for (int ros = 1; ros <= NuROS; ++ros) {
0110 bookHistosROS(ibooker, wheel, ros);
0111 }
0112 }
0113
0114 }
0115 }
0116
0117 void DTDataIntegrityTask::bookHistos(DQMStore::IBooker& ibooker, const int fedMin, const int fedMax) {
0118 ibooker.setCurrentFolder("DT/EventInfo/Counters");
0119 nEventMonitor = ibooker.bookFloat("nProcessedEventsDataIntegrity");
0120
0121
0122 ibooker.setCurrentFolder(topFolder(true));
0123
0124 int nFED = (fedMax - fedMin) + 1;
0125
0126 hFEDEntry = ibooker.book1D("FEDEntries", "# entries per DT FED", nFED, fedMin, fedMax + 1);
0127 hFEDFatal = ibooker.book1D("FEDFatal", "# fatal errors DT FED", nFED, fedMin, fedMax + 1);
0128
0129 if (mode == 1)
0130 return;
0131
0132 string histoType = "ROSSummary";
0133 for (int wheel = -2; wheel < 3; ++wheel) {
0134 string wheel_s = to_string(wheel);
0135 string histoName = "ROSSummary_W" + wheel_s;
0136 string fed_s = to_string(FEDIDmin + 1);
0137 if (wheel < 0)
0138 fed_s = to_string(FEDIDmin);
0139 else if (wheel > 0)
0140 fed_s = to_string(FEDIDmax);
0141 string histoTitle = "Summary Wheel" + wheel_s + " (FED " + fed_s + ")";
0142
0143 ((summaryHistos[histoType])[wheel]) = ibooker.book2D(histoName, histoTitle, 11, 0, 11, 12, 1, 13);
0144 MonitorElement* histo = ((summaryHistos[histoType])[wheel]);
0145 histo->setBinLabel(1, "Error 1", 1);
0146 histo->setBinLabel(2, "Error 2", 1);
0147 histo->setBinLabel(3, "Error 3", 1);
0148 histo->setBinLabel(4, "Error 4", 1);
0149 histo->setBinLabel(5, "Not OKflag", 1);
0150
0151 histo->setBinLabel(6, "TDC Fatal", 1);
0152 histo->setBinLabel(7, "TDC RO FIFO ov.", 1);
0153 histo->setBinLabel(8, "TDC L1 buf. ov.", 1);
0154 histo->setBinLabel(9, "TDC L1A FIFO ov.", 1);
0155 histo->setBinLabel(10, "TDC hit err.", 1);
0156 histo->setBinLabel(11, "TDC hit rej.", 1);
0157
0158 histo->setBinLabel(1, "Sector1", 2);
0159 histo->setBinLabel(2, "Sector2", 2);
0160 histo->setBinLabel(3, "Sector3", 2);
0161 histo->setBinLabel(4, "Sector4", 2);
0162 histo->setBinLabel(5, "Sector5", 2);
0163 histo->setBinLabel(6, "Sector6", 2);
0164 histo->setBinLabel(7, "Sector7", 2);
0165 histo->setBinLabel(8, "Sector8", 2);
0166 histo->setBinLabel(9, "Sector9", 2);
0167 histo->setBinLabel(10, "Sector10", 2);
0168 histo->setBinLabel(11, "Sector11", 2);
0169 histo->setBinLabel(12, "Sector12", 2);
0170 }
0171 }
0172
0173 void DTDataIntegrityTask::bookHistos(DQMStore::IBooker& ibooker, string folder, const int fed) {
0174 string wheel = "ZERO";
0175 if (fed == FEDIDmin)
0176 wheel = "NEG";
0177 else if (fed == FEDIDmax)
0178 wheel = "POS";
0179 string fed_s = to_string(fed);
0180 LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
0181 << " Booking histos for FED: " << fed_s << " folder: " << folder << endl;
0182
0183 string histoType;
0184 string histoName;
0185 string histoTitle;
0186 MonitorElement* histo = nullptr;
0187
0188
0189 if (folder == "CRATE") {
0190 ibooker.setCurrentFolder(topFolder(false) + "FED" + fed_s);
0191
0192 histoType = "EventLength";
0193 histoName = "FED" + fed_s + "_" + histoType;
0194 histoTitle = "Event Length (Bytes) FED " + fed_s;
0195 (fedHistos[histoType])[fed] = ibooker.book1D(histoName, histoTitle, 501, 0, 30000);
0196
0197 if (mode == 3 || mode == 1)
0198 return;
0199
0200 histoType = "uROSStatus";
0201 histoName = "FED" + fed_s + "_" + histoType;
0202 (fedHistos[histoType])[fed] = ibooker.book2D(histoName, histoName, 12, 0, 12, 12, 1, 13);
0203 histo = (fedHistos[histoType])[fed];
0204
0205 histo->setBinLabel(1, "Error G 1", 1);
0206 histo->setBinLabel(2, "Error G 2", 1);
0207 histo->setBinLabel(3, "Error G 3", 1);
0208 histo->setBinLabel(4, "Error G 4", 1);
0209 histo->setBinLabel(5, "Error G 5", 1);
0210 histo->setBinLabel(6, "Error G 6", 1);
0211 histo->setBinLabel(7, "Error G 7", 1);
0212 histo->setBinLabel(8, "Error G 8", 1);
0213 histo->setBinLabel(9, "Error G 9", 1);
0214 histo->setBinLabel(10, "Error G 10", 1);
0215 histo->setBinLabel(11, "Error G 11", 1);
0216 histo->setBinLabel(12, "Error G 12", 1);
0217
0218 histo->setBinLabel(1, "uROS 1", 2);
0219 histo->setBinLabel(2, "uROS 2", 2);
0220 histo->setBinLabel(3, "uROS 3", 2);
0221 histo->setBinLabel(4, "uROS 4", 2);
0222 histo->setBinLabel(5, "uROS 5", 2);
0223 histo->setBinLabel(6, "uROS 6", 2);
0224 histo->setBinLabel(7, "uROS 7", 2);
0225 histo->setBinLabel(8, "uROS 8", 2);
0226 histo->setBinLabel(9, "uROS 9", 2);
0227 histo->setBinLabel(10, "uROS 10", 2);
0228 histo->setBinLabel(11, "uROS 11", 2);
0229 histo->setBinLabel(12, "uROS 12", 2);
0230
0231 if (mode == 0) {
0232
0233 histoType = "FEDAvgEvLengthvsLumi";
0234 histoName = "FED" + fed_s + "_" + histoType;
0235 histoTitle = "Avg Event Length (Bytes) vs LumiSec FED " + fed_s;
0236 (fedTimeHistos[histoType])[fed] = new DTTimeEvolutionHisto(ibooker, histoName, histoTitle, 200, 10, true, 0);
0237
0238
0239
0240
0241
0242
0243
0244
0245
0246
0247
0248
0249
0250
0251 histoType = "uROSList";
0252 histoName = "FED" + fed_s + "_" + histoType;
0253 histoTitle = "# of uROS in the FED payload (FED" + fed_s + ")";
0254 (fedHistos[histoType])[fed] = ibooker.book1D(histoName, histoTitle, 13, 0, 13);
0255
0256 histoType = "BXID";
0257 histoName = "FED" + fed_s + "_BXID";
0258 histoTitle = "Distrib. BX ID (FED" + fed_s + ")";
0259 (fedHistos[histoType])[fed] = ibooker.book1D(histoName, histoTitle, 3600, 0, 3600);
0260 }
0261 }
0262
0263
0264 if (folder == "FED") {
0265 ibooker.setCurrentFolder(topFolder(false));
0266
0267 if (mode == 3 || mode == 1)
0268 return;
0269
0270 histoType = "uROSSummary";
0271 histoName = "FED" + fed_s + "_uROSSummary";
0272 string histoTitle = "Summary Wheel" + wheel + " (FED " + fed_s + ")";
0273
0274 ((summaryHistos[histoType])[fed]) = ibooker.book2D(histoName, histoTitle, 12, 0, 12, 12, 1, 13);
0275 MonitorElement* histo = ((summaryHistos[histoType])[fed]);
0276
0277
0278 histo->setBinLabel(1, "Error G 1", 1);
0279 histo->setBinLabel(2, "Error G 2", 1);
0280 histo->setBinLabel(3, "Error G 3", 1);
0281 histo->setBinLabel(4, "Error G 4", 1);
0282 histo->setBinLabel(5, "Error G 5", 1);
0283 histo->setBinLabel(6, "Error G 6", 1);
0284 histo->setBinLabel(7, "Error G 7", 1);
0285 histo->setBinLabel(8, "Error G 8", 1);
0286 histo->setBinLabel(9, "Error G 9", 1);
0287 histo->setBinLabel(10, "Error G 10", 1);
0288 histo->setBinLabel(11, "Error G 11", 1);
0289 histo->setBinLabel(12, "Error G 12", 1);
0290
0291 histo->setBinLabel(1, "uROS1", 2);
0292 histo->setBinLabel(2, "uROS2", 2);
0293 histo->setBinLabel(3, "uROS3", 2);
0294 histo->setBinLabel(4, "uROS4", 2);
0295 histo->setBinLabel(5, "uROS5", 2);
0296 histo->setBinLabel(6, "uROS6", 2);
0297 histo->setBinLabel(7, "uROS7", 2);
0298 histo->setBinLabel(8, "uROS8", 2);
0299 histo->setBinLabel(9, "uROS9", 2);
0300 histo->setBinLabel(10, "uROS10", 2);
0301 histo->setBinLabel(11, "uROS11", 2);
0302 histo->setBinLabel(12, "uROS12", 2);
0303 }
0304 }
0305
0306 void DTDataIntegrityTask::bookHistosROS(DQMStore::IBooker& ibooker, const int wheel, const int ros) {
0307 string wheel_s = to_string(wheel);
0308 string ros_s = to_string(ros);
0309 ibooker.setCurrentFolder(topFolder(false) + "Wheel" + wheel_s + "/Sector" + ros_s);
0310
0311 string histoType = "ROSError";
0312 int linkDown = 0;
0313 string linkDown_s = to_string(linkDown);
0314 int linkUp = linkDown + 24;
0315 string linkUp_s = to_string(linkUp);
0316 string histoName = "W" + wheel_s + "_" + "Sector" + ros_s + "_" + histoType;
0317 string histoTitle = histoName + " (Channel " + linkDown_s + "-" + linkUp_s + " error summary)";
0318 unsigned int keyHisto = (uROSError) * 1000 + (wheel + 2) * 100 + (ros - 1);
0319 if (mode < 1)
0320 urosHistos[keyHisto] = ibooker.book2D(histoName, histoTitle, 11, 0, 11, 25, 0, 25);
0321 else if (mode > 1)
0322 urosHistos[keyHisto] = ibooker.book2D(histoName, histoTitle, 5, 0, 5, 25, 0, 25);
0323
0324 MonitorElement* histo = urosHistos[keyHisto];
0325
0326
0327 histo->setBinLabel(1, "Error 1", 1);
0328 histo->setBinLabel(2, "Error 2", 1);
0329 histo->setBinLabel(3, "Error 3", 1);
0330 histo->setBinLabel(4, "Error 4", 1);
0331 histo->setBinLabel(5, "Not OKFlag", 1);
0332 if (mode < 1) {
0333
0334 histo->setBinLabel(6, "TDC Fatal", 1);
0335 histo->setBinLabel(7, "TDC RO FIFO ov.", 1);
0336 histo->setBinLabel(8, "TDC L1 buf. ov.", 1);
0337 histo->setBinLabel(9, "TDC L1A FIFO ov.", 1);
0338 histo->setBinLabel(10, "TDC hit err.", 1);
0339 histo->setBinLabel(11, "TDC hit rej.", 1);
0340 }
0341 for (int link = linkDown; link < linkUp; ++link) {
0342 int sector = ros;
0343
0344 int station = int(link / 6) + 1;
0345 if (link == 18)
0346 station = 3;
0347
0348 int rob = link % 6;
0349 if (link == 18)
0350 rob = 6;
0351 else if (link > 18)
0352 rob = rob - 1;
0353
0354
0355 if (ros == 4) {
0356 if (link > 18 && link < 22)
0357 rob = rob + 2;
0358 else if (link == 22 || link == 23) {
0359 sector = 13;
0360 rob = rob - 1;
0361 }
0362 }
0363
0364
0365 if (ros == 9 && (link == 22 || link == 23)) {
0366 sector = 13;
0367 rob = rob - 3;
0368 }
0369
0370
0371 if (ros == 10) {
0372 if (link > 18 && link < 22)
0373 sector = 14;
0374 else if (link == 22 || link == 23)
0375 rob = rob - 3;
0376 }
0377
0378
0379 if (ros == 11 && (link == 22 || link == 23)) {
0380 sector = 4;
0381 rob = rob - 3;
0382 }
0383
0384 string sector_s = to_string(sector);
0385 string st_s = to_string(station);
0386 string rob_s = to_string(rob);
0387 histo->setBinLabel(link + 1, "S" + sector_s + " MB" + st_s + " ROB" + rob_s, 2);
0388 }
0389
0390 int link25 = linkUp;
0391 string label25[12] = {"S1 MB4 ROB5",
0392 "S2 MB4 ROB5",
0393 "S3 MB4 ROB5",
0394 "S13 MB4 ROB4",
0395 "S5 MB4 ROB5",
0396 "S6 MB4 ROB5",
0397 "S7 MB4 ROB5",
0398 "S8 MB4 ROB5",
0399 "S10 MB4 ROB3",
0400 "S10 MB4 ROB2",
0401 "S14 MB4 ROB3",
0402 "S12 MB4 ROB5"};
0403 histo->setBinLabel(link25 + 1, label25[ros - 1], 2);
0404
0405 if (mode > 1)
0406 return;
0407
0408 histoType = "TDCError";
0409 linkDown = 0;
0410 linkDown_s = to_string(linkDown);
0411 linkUp = linkDown + 24;
0412 linkUp_s = to_string(linkUp);
0413 histoName = "W" + wheel_s + "_" + "Sector" + ros_s + "_" + histoType;
0414 histoTitle = histoName + " (Channel " + linkDown_s + "-" + linkUp_s + " error summary)";
0415 keyHisto = (TDCError) * 1000 + (wheel + 2) * 100 + (ros - 1);
0416 urosHistos[keyHisto] = ibooker.book2D(histoName, histoTitle, 24, 0, 24, 25, 0, 25);
0417 histo = urosHistos[keyHisto];
0418
0419 histo->setBinLabel(1, "Fatal", 1);
0420 histo->setBinLabel(2, "RO FIFO ov.", 1);
0421 histo->setBinLabel(3, "L1 buf. ov.", 1);
0422 histo->setBinLabel(4, "L1A FIFO ov.", 1);
0423 histo->setBinLabel(5, "hit err.", 1);
0424 histo->setBinLabel(6, "hit rej.", 1);
0425 histo->setBinLabel(7, "Fatal", 1);
0426 histo->setBinLabel(8, "RO FIFO ov.", 1);
0427 histo->setBinLabel(9, "L1 buf. ov.", 1);
0428 histo->setBinLabel(10, "L1A FIFO ov.", 1);
0429 histo->setBinLabel(11, "hit err.", 1);
0430 histo->setBinLabel(12, "hit rej.", 1);
0431 histo->setBinLabel(13, "Fatal", 1);
0432 histo->setBinLabel(14, "RO FIFO ov.", 1);
0433 histo->setBinLabel(15, "L1 buf. ov.", 1);
0434 histo->setBinLabel(16, "L1A FIFO ov.", 1);
0435 histo->setBinLabel(17, "hit err.", 1);
0436 histo->setBinLabel(18, "hit rej.", 1);
0437 histo->setBinLabel(19, "Fatal", 1);
0438 histo->setBinLabel(20, "RO FIFO ov.", 1);
0439 histo->setBinLabel(21, "L1 buf. ov.", 1);
0440 histo->setBinLabel(22, "L1A FIFO ov.", 1);
0441 histo->setBinLabel(23, "hit err.", 1);
0442 histo->setBinLabel(24, "hit rej.", 1);
0443
0444 for (int link = linkDown; link < linkUp; ++link) {
0445 int sector = ros;
0446
0447 int station = int(link / 6) + 1;
0448 if (link == 18)
0449 station = 3;
0450
0451 int rob = link % 6;
0452 if (link == 18)
0453 rob = 6;
0454 else if (link > 18)
0455 rob = rob - 1;
0456
0457
0458 if (ros == 4) {
0459 if (link > 18 && link < 22)
0460 rob = rob + 2;
0461 else if (link == 22 || link == 23) {
0462 sector = 13;
0463 rob = rob - 1;
0464 }
0465 }
0466
0467
0468 if (ros == 9 && (link == 22 || link == 23))
0469 rob = rob - 3;
0470
0471
0472 if (ros == 10) {
0473 if (link > 18 && link < 22)
0474 sector = 14;
0475 else if (link == 22 || link == 23)
0476 rob = rob - 3;
0477 }
0478
0479
0480 if (ros == 11 && (link == 22 || link == 23)) {
0481 sector = 4;
0482 rob = rob - 3;
0483 }
0484
0485 string sector_s = to_string(sector);
0486 string st_s = to_string(station);
0487 string rob_s = to_string(rob);
0488 histo->setBinLabel(link + 1, "S" + sector_s + " MB" + st_s + " ROB" + rob_s, 2);
0489 }
0490
0491 link25 = linkUp;
0492 histo->setBinLabel(link25 + 1, label25[ros - 1], 2);
0493
0494 }
0495
0496 void DTDataIntegrityTask::bookHistosuROS(DQMStore::IBooker& ibooker, const int fed, const int uRos) {
0497 string fed_s = to_string(fed);
0498 string uRos_s = to_string(uRos);
0499 ibooker.setCurrentFolder(topFolder(false) + "FED" + fed_s + "/uROS" + uRos_s);
0500
0501 if (mode >= 1)
0502 return;
0503
0504 string histoType = "uROSEventLength";
0505 string histoName = "FED" + fed_s + "_uROS" + uRos_s + "_" + "EventLength";
0506 string histoTitle = "Event Length (Bytes) FED " + fed_s + " uROS" + uRos_s;
0507 unsigned int keyHisto = (uROSEventLength) * 1000 + (fed - FEDIDmin) * 100 + (uRos - 1);
0508 urosHistos[keyHisto] = ibooker.book1D(histoName, histoTitle, 101, 0, 5000);
0509
0510 histoType = "uROSAvgEventLengthvsLumi";
0511 histoName = "FED" + fed_s + "_ROS" + uRos_s + "AvgEventLengthvsLumi";
0512 histoTitle = "Event Length (Bytes) FED " + fed_s + " ROS" + uRos_s;
0513 keyHisto = (fed - FEDIDmin) * 100 + (uRos - 1);
0514 urosTimeHistos[keyHisto] = new DTTimeEvolutionHisto(ibooker, histoName, histoTitle, 200, 10, true, 0);
0515
0516 histoType = "TTSValues";
0517 histoName = "FED" + fed_s + "_" + "uROS" + uRos_s + "_" + histoType;
0518 keyHisto = TTSValues * 1000 + (fed - FEDIDmin) * 100 + (uRos - 1);
0519 urosHistos[keyHisto] = ibooker.book1D(histoName, histoName, 4, 1, 5);
0520 MonitorElement* histo = urosHistos[keyHisto];
0521 histo->setBinLabel(1, "Overflow Warning ", 1);
0522 histo->setBinLabel(2, "Busy", 1);
0523 histo->setBinLabel(3, "Ready", 1);
0524 histo->setBinLabel(4, "Unknown", 1);
0525 }
0526
0527 void DTDataIntegrityTask::processuROS(DTuROSROSData& data, int fed, int uRos) {
0528 #ifdef EDM_ML_DEBUG
0529 neventsuROS++;
0530
0531 LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
0532 << "[DTDataIntegrityTask]: " << neventsuROS << " events analyzed by processuROS" << endl;
0533 #endif
0534
0535 if (mode == 3)
0536 return;
0537
0538 MonitorElement* uROSSummary = nullptr;
0539 MonitorElement* uROSStatus = nullptr;
0540
0541 unsigned int slotMap = (data.getboardId()) & 0xF;
0542 if (slotMap == 0)
0543 return;
0544 unsigned int ros = theROS(slotMap, 0);
0545 int ddu = theDDU(fed, slotMap, 0, false);
0546 int wheel = (ddu - 770) % 5 - 2;
0547 int sector4 = 3;
0548
0549 MonitorElement* ROSSummary = nullptr;
0550 ROSSummary = summaryHistos["ROSSummary"][wheel];
0551
0552
0553 MonitorElement* uROSError0 = nullptr;
0554 MonitorElement* uROSError1 = nullptr;
0555 MonitorElement* uROSError2 = nullptr;
0556 MonitorElement* uROSErrorS4 = nullptr;
0557
0558 if (mode <= 2) {
0559 if (uRos > 2) {
0560 if (mode != 1) {
0561 uROSSummary = summaryHistos["uROSSummary"][fed];
0562 uROSStatus = fedHistos["uROSStatus"][fed];
0563 if (!uROSSummary) {
0564 LogError("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
0565 << "Trying to access non existing ME at FED " << fed << std::endl;
0566 return;
0567 }
0568
0569 uROSError0 = urosHistos[(uROSError) * 1000 + (wheel + 2) * 100 + (ros - 1)];
0570 uROSError1 = urosHistos[(uROSError) * 1000 + (wheel + 2) * 100 + (ros)];
0571 uROSError2 = urosHistos[(uROSError) * 1000 + (wheel + 2) * 100 + (ros + 1)];
0572 uROSErrorS4 = urosHistos[(uROSError) * 1000 + (wheel + 2) * 100 + 3];
0573
0574 if ((!uROSError2) || (!uROSError1) || (!uROSError0)) {
0575 LogError("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
0576 << "Trying to access non existing ME at uROS " << uRos << std::endl;
0577 return;
0578 }
0579 }
0580
0581
0582 for (unsigned int link = 0; link < 72; ++link) {
0583 for (unsigned int flag = 0; flag < 5; ++flag) {
0584 if ((data.getokxflag(link) >> flag) & 0x1) {
0585
0586 int value = flag != 0 ? flag : 5;
0587 if (link < 24) {
0588 errorX[value - 1][ros - 1][wheel + 2] += 1;
0589 if (mode != 1)
0590 uROSError0->Fill(value - 1, link);
0591 } else if (link < 48) {
0592 if ((link == 46 || link == 57) && ros == 10)
0593 errorX[value - 1][sector4][wheel + 2] += 1;
0594 else
0595 errorX[value - 1][ros][wheel + 2] += 1;
0596 if (mode != 1) {
0597 if ((link == 46 || link == 57) && ros == 10)
0598 uROSErrorS4->Fill(value - 1, link - 24);
0599 else
0600 uROSError1->Fill(value - 1, link - 24);
0601 }
0602 } else if (link < 72) {
0603 errorX[value - 1][ros + 1][wheel + 2] += 1;
0604 if (mode != 1)
0605 uROSError2->Fill(value - 1, link - 48);
0606 }
0607 }
0608 }
0609 }
0610 }
0611
0612 else {
0613
0614 for (unsigned int link = 0; link < 12; ++link) {
0615 for (unsigned int flag = 0; flag < 5; ++flag) {
0616 if ((data.getokxflag(link) >> flag) & 0x1) {
0617 int value = flag;
0618 int ch25 = 24;
0619 int sector = link + 1;
0620 if (flag == 0)
0621 value = 5;
0622
0623 if (value > 0) {
0624 if (mode != 1) {
0625 if (sector == 9)
0626 sector = 10;
0627 unsigned int keyHisto =
0628 (uROSError) * 1000 + (wheel + 2) * 100 + abs(sector - 1);
0629 uROSError0 = urosHistos[keyHisto];
0630 if (!uROSError0) {
0631 LogError("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
0632 << "Trying to access non existing ME at uROS " << uRos << std::endl;
0633 return;
0634 }
0635 }
0636 errorX[value - 1][sector - 1][wheel + 2] += 1;
0637 if (mode != 1)
0638 uROSError0->Fill(value - 1, ch25);
0639 }
0640 }
0641 }
0642 }
0643 }
0644
0645 if (mode != 1) {
0646
0647 for (unsigned int flag = 4; flag < 16; ++flag) {
0648 if ((data.getuserWord() >> flag) & 0x1) {
0649 uROSSummary->Fill(flag - 4, uRos);
0650 uROSStatus->Fill(flag - 4, uRos);
0651 }
0652 }
0653 }
0654
0655 }
0656
0657 if (mode != 1) {
0658
0659 for (unsigned int iros = ros - 1; iros < (ros + 2); ++iros) {
0660 for (unsigned int bin = 0; bin < 5; ++bin) {
0661 if (errorX[bin][iros][wheel + 2] != 0) {
0662 ROSSummary->Fill(bin, iros + 1, errorX[bin][iros][wheel + 2]);
0663 }
0664 }
0665 }
0666 }
0667
0668
0669 for (unsigned int icounter = 0; icounter < data.geterrors().size(); ++icounter) {
0670 int link = data.geterrorROBID(icounter);
0671 int tdc = data.geterrorTDCID(icounter);
0672 int error = data.geterror(icounter);
0673 int tdcError_ROSSummary = 0;
0674 int tdcError_ROSError = 0;
0675 int tdcError_TDCHisto = 0;
0676
0677 if (error & 0x4000) {
0678 LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
0679 << " ROS " << uRos << " ROB " << link << " Internal fatal Error 4000 in TDC " << error << endl;
0680
0681 tdcError_ROSSummary = 5;
0682 tdcError_ROSError = 5;
0683 tdcError_TDCHisto = 0;
0684
0685 } else if (error & 0x0249) {
0686 LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
0687 << " ROS " << uRos << " ROB " << link << " TDC FIFO overflow in TDC " << error << endl;
0688
0689 tdcError_ROSSummary = 6;
0690 tdcError_ROSError = 6;
0691 tdcError_TDCHisto = 1;
0692
0693 } else if (error & 0x0492) {
0694 LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
0695 << " ROS " << uRos << " ROB " << link << " TDC L1 buffer overflow in TDC " << error << endl;
0696
0697 tdcError_ROSSummary = 7;
0698 tdcError_ROSError = 7;
0699 tdcError_TDCHisto = 2;
0700
0701 } else if (error & 0x2000) {
0702 LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
0703 << " ROS " << uRos << " ROB " << link << " TDC L1A FIFO overflow in TDC " << error << endl;
0704
0705 tdcError_ROSSummary = 8;
0706 tdcError_ROSError = 8;
0707 tdcError_TDCHisto = 3;
0708
0709 } else if (error & 0x0924) {
0710 LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
0711 << " uROS " << uRos << " ROB " << link << " TDC hit error in TDC " << error << endl;
0712
0713 tdcError_ROSSummary = 9;
0714 tdcError_ROSError = 9;
0715 tdcError_TDCHisto = 4;
0716
0717 } else if (error & 0x1000) {
0718 LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
0719 << " uROS " << uRos << " ROB " << link << " TDC hit rejected in TDC " << error << endl;
0720
0721 tdcError_ROSSummary = 10;
0722 tdcError_ROSError = 10;
0723 tdcError_TDCHisto = 5;
0724
0725 } else {
0726 LogWarning("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
0727 << " TDC error code not known " << error << endl;
0728 }
0729
0730 if (uRos < 3) {
0731 int sector = link + 1;
0732 if (tdcError_ROSSummary == 5)
0733 errorX[5][link][wheel + 2] += 1;
0734 if (mode != 1) {
0735 if (sector == 9)
0736 sector = 10;
0737 ROSSummary->Fill(tdcError_ROSSummary, sector - 1);
0738 int ch25 = 24;
0739 if (mode <= 2) {
0740 urosHistos[(uROSError) * 1000 + (wheel + 2) * 100 + (sector - 1)]->Fill(tdcError_ROSError, ch25);
0741 if (mode < 1)
0742 urosHistos[(TDCError) * 1000 + (wheel + 2) * 100 + (sector - 1)]->Fill(tdcError_TDCHisto + 6 * tdc,
0743 ch25);
0744 }
0745 }
0746 }
0747 else {
0748 if (link < 24) {
0749 if (tdcError_ROSSummary == 5)
0750 errorX[5][ros - 1][wheel + 2] += 1;
0751 if (mode != 1)
0752 ROSSummary->Fill(tdcError_ROSSummary, ros);
0753 } else if (link < 48) {
0754 if (tdcError_ROSSummary == 5) {
0755 if ((link == 46 || link == 57) && ros == 10)
0756 errorX[5][sector4][wheel + 2] += 1;
0757 else
0758 errorX[5][ros][wheel + 2] += 1;
0759 }
0760 if (mode != 1) {
0761 if ((link == 46 || link == 57) && ros == 10)
0762 ROSSummary->Fill(tdcError_ROSSummary, sector4);
0763 else
0764 ROSSummary->Fill(tdcError_ROSSummary, ros + 1);
0765 }
0766 } else if (link < 72) {
0767 if (tdcError_ROSSummary == 5)
0768 errorX[5][ros + 1][wheel + 2] += 1;
0769 if (mode != 1)
0770 ROSSummary->Fill(tdcError_ROSSummary, ros + 2);
0771 }
0772
0773 if (mode <= 2 && mode != 1) {
0774 if (link < 24)
0775 uROSError0->Fill(tdcError_ROSError, link);
0776 else if (link < 48)
0777 if ((link == 46 || link == 57) && ros == 10)
0778 uROSError1->Fill(tdcError_ROSError, sector4);
0779 else
0780 uROSError1->Fill(tdcError_ROSError, link - 24);
0781 else if (link < 72)
0782 uROSError2->Fill(tdcError_ROSError, link - 48);
0783
0784 if (mode < 1) {
0785 if (link < 24)
0786 urosHistos[(TDCError) * 1000 + (wheel + 2) * 100 + (ros - 1)]->Fill(tdcError_TDCHisto + 6 * tdc, link);
0787 else if (link < 48)
0788 urosHistos[(TDCError) * 1000 + (wheel + 2) * 100 + (ros)]->Fill(tdcError_TDCHisto + 6 * tdc, link - 24);
0789 else if (link < 72)
0790 urosHistos[(TDCError) * 1000 + (wheel + 2) * 100 + (ros + 1)]->Fill(tdcError_TDCHisto + 6 * tdc, link - 48);
0791
0792 }
0793 }
0794 }
0795 }
0796
0797
0798 if (mode < 1) {
0799 int ttsCodeValue = -1;
0800 int value = (data.getuserWord() & 0xF);
0801 switch (value) {
0802 case 1: {
0803 ttsCodeValue = 1;
0804 break;
0805 }
0806 case 4: {
0807 ttsCodeValue = 2;
0808 break;
0809 }
0810 case 8: {
0811 ttsCodeValue = 3;
0812 break;
0813 }
0814 default: {
0815 LogError("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
0816 << "[DTDataIntegrityTask] FED User control: wrong TTS value " << value << " in FED " << fed << " uROS "
0817 << uRos << endl;
0818 ttsCodeValue = 4;
0819 }
0820 }
0821
0822 urosHistos[TTSValues * 1000 + (fed - FEDIDmin) * 100 + (uRos - 1)]->Fill(ttsCodeValue);
0823
0824
0825 int uRosEventLength = (data.gettrailer() & 0xFFFFF) * 8;
0826 urosTimeHistos[(fed - FEDIDmin) * 100 + (uRos - 1)]->accumulateValueTimeSlot(uRosEventLength);
0827
0828 if (uRosEventLength > 5000)
0829 uRosEventLength = 5000;
0830 urosHistos[uROSEventLength * 1000 + (fed - FEDIDmin) * 100 + (uRos - 1)]->Fill(uRosEventLength);
0831 }
0832 }
0833
0834 void DTDataIntegrityTask::processFED(DTuROSFEDData& data, int fed) {
0835 #ifdef EDM_ML_DEBUG
0836 neventsFED++;
0837 if (neventsFED % 1000 == 0)
0838 LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
0839 << "[DTDataIntegrityTask]: " << neventsFED << " events analyzed by processFED" << endl;
0840 #endif
0841
0842 if (fed < FEDIDmin || fed > FEDIDmax)
0843 return;
0844
0845 hFEDEntry->Fill(fed);
0846
0847 if (mode == 3)
0848 return;
0849
0850 if (mode != 1) {
0851
0852 int fedEvtLength = data.getevtlgth() * 8;
0853
0854 fedHistos["EventLength"][fed]->Fill(fedEvtLength);
0855
0856 if (mode == 0) {
0857 fedTimeHistos["FEDAvgEvLengthvsLumi"][fed]->accumulateValueTimeSlot(fedEvtLength);
0858
0859
0860 fedHistos["BXID"][fed]->Fill(data.getBXId());
0861
0862
0863 fedHistos["uROSList"][fed]->Fill(data.getnslots());
0864 }
0865
0866 }
0867
0868
0869
0870
0871
0872
0873
0874
0875
0876
0877
0878
0879
0880
0881
0882
0883
0884
0885
0886
0887
0888
0889
0890
0891
0892
0893
0894
0895
0896
0897
0898
0899
0900
0901
0902
0903
0904
0905
0906
0907 int wheel = 0;
0908 if (fed == FEDIDmin)
0909 wheel = -2;
0910 else if (fed == FEDIDmax)
0911 wheel = 1;
0912
0913 float sumTDC = 0., sumNotOKFlag = 0.;
0914 for (int ros = 0; ros < 12; ros++) {
0915 sumNotOKFlag += errorX[4][ros][wheel + 2];
0916 sumTDC += errorX[5][ros][wheel + 2];
0917 }
0918
0919 if (wheel != 0) {
0920 wheel += 1;
0921 for (int ros = 0; ros < 12; ros++) {
0922 sumNotOKFlag += errorX[4][ros][wheel + 2];
0923 sumTDC += errorX[5][ros][wheel + 2];
0924 }
0925 }
0926
0927
0928 sumNotOKFlag = sumNotOKFlag / ((wheel != 0) ? 2. : 1.);
0929 sumTDC = sumTDC / ((wheel != 0) ? 2. : 1.);
0930
0931 if (sumNotOKFlag > nLinksForFatal || sumTDC > nLinksForFatal)
0932 hFEDFatal->Fill(fed);
0933 }
0934
0935 std::string DTDataIntegrityTask::topFolder(bool isFEDIntegrity) const {
0936 string folder = isFEDIntegrity ? fedIntegrityFolder : "DT/00-DataIntegrity/";
0937
0938 if (mode == 0)
0939 folder = "DT/00-DataIntegrity/";
0940
0941 return folder;
0942 }
0943
0944 std::shared_ptr<dtdi::LumiCache> DTDataIntegrityTask::globalBeginLuminosityBlock(const edm::LuminosityBlock& ls,
0945 const edm::EventSetup& es) const {
0946 return std::make_shared<dtdi::LumiCache>();
0947 }
0948
0949 void DTDataIntegrityTask::globalEndLuminosityBlock(const edm::LuminosityBlock& ls, const edm::EventSetup& es) {
0950 int lumiBlock = ls.id().luminosityBlock();
0951 const auto nEventsLS = luminosityBlockCache(ls.index())->nEventsLS;
0952
0953 map<string, map<int, DTTimeEvolutionHisto*> >::iterator fedIt = fedTimeHistos.begin();
0954 map<string, map<int, DTTimeEvolutionHisto*> >::iterator fedEnd = fedTimeHistos.end();
0955 for (; fedIt != fedEnd; ++fedIt) {
0956 map<int, DTTimeEvolutionHisto*>::iterator histoIt = fedIt->second.begin();
0957 map<int, DTTimeEvolutionHisto*>::iterator histoEnd = fedIt->second.end();
0958 for (; histoIt != histoEnd; ++histoIt) {
0959 histoIt->second->updateTimeSlot(lumiBlock, nEventsLS);
0960 }
0961 }
0962
0963 map<unsigned int, DTTimeEvolutionHisto*>::iterator urosIt = urosTimeHistos.begin();
0964 map<unsigned int, DTTimeEvolutionHisto*>::iterator urosEnd = urosTimeHistos.end();
0965 for (; urosIt != urosEnd; ++urosIt) {
0966 urosIt->second->updateTimeSlot(lumiBlock, nEventsLS);
0967 }
0968 }
0969
0970 void DTDataIntegrityTask::analyze(const edm::Event& e, const edm::EventSetup& c) {
0971 nevents++;
0972 nEventMonitor->Fill(nevents);
0973 luminosityBlockCache(e.getLuminosityBlock().index())->nEventsLS++;
0974
0975
0976 fill(&errorX[0][0][0], &errorX[0][0][0] + 360, 0);
0977
0978 LogTrace("DTRawToDigi|TDQM|DTMonitorModule|DTDataIntegrityTask") << "[DTDataIntegrityTask]: preProcessEvent" << endl;
0979
0980
0981 edm::Handle<DTuROSFEDDataCollection> fedCol;
0982 e.getByToken(fedToken, fedCol);
0983 DTuROSFEDData fedData;
0984 DTuROSROSData urosData;
0985
0986 if (fedCol.isValid()) {
0987 for (unsigned int j = 0; j < fedCol->size(); ++j) {
0988 fedData = fedCol->at(j);
0989 int fed = fedData.getfed();
0990 if (fed > FEDIDmax || fed < FEDIDmin) {
0991 LogError("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
0992 << "[DTDataIntegrityTask]: analyze, FED ID " << fed << " not expected." << endl;
0993 continue;
0994 }
0995
0996 if (mode == 3)
0997 continue;
0998
0999 for (int slot = 1; slot <= DOCESLOTS; ++slot) {
1000 urosData = fedData.getuROS(slot);
1001 if (fedData.getslotsize(slot) == 0 || urosData.getslot() == -1)
1002 continue;
1003 processuROS(urosData, fed, slot);
1004 }
1005 processFED(fedData, fed);
1006 }
1007 }
1008 }
1009
1010
1011 int DTDataIntegrityTask::theDDU(int crate, int slot, int link, bool tenDDU) {
1012 int ros = theROS(slot, link);
1013
1014 int ddu = 772;
1015
1016
1017
1018 if (crate == FEDNumbering::MINDTUROSFEDID) {
1019 if (slot < 7)
1020 ddu = 770;
1021 else
1022 ddu = 771;
1023 }
1024
1025 if (crate == (FEDNumbering::MINDTUROSFEDID + 1)) {
1026 ddu = 772;
1027 }
1028
1029 if (crate == FEDNumbering::MAXDTUROSFEDID) {
1030 if (slot < 7)
1031 ddu = 773;
1032 else
1033 ddu = 774;
1034 }
1035
1036 if (ros > 6 && tenDDU && ddu < 775)
1037 ddu += 5;
1038
1039 return ddu;
1040 }
1041
1042 int DTDataIntegrityTask::theROS(int slot, int link) {
1043 if (slot % 6 == 5)
1044 return link + 1;
1045
1046 int ros = (link / 24) + 3 * (slot % 6) - 2;
1047 return ros;
1048 }