CMS 3D CMS Logo

DTDataIntegrityTask.cc
Go to the documentation of this file.
1 /*
2  * \file DTDataIntegrityTask.cc
3  *
4  * Class for DT Data Integrity
5  * at Online DQM (Single Thread)
6  * expected to monitor uROS
7  * Class with MEs vs Time/LS
8  *
9  * \author Javier Fernandez (Uni. Oviedo)
10  *
11  */
12 
19 
20 #include <cmath>
21 #include <fstream>
22 #include <map>
23 #include <string>
24 #include <vector>
25 
26 using namespace std;
27 using namespace edm;
28 
30  : nevents(0), FEDIDmin(FEDNumbering::MINDTUROSFEDID), FEDIDmax(FEDNumbering::MAXDTUROSFEDID) {
31  LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask") << "[DTDataIntegrityTask]: Constructor" << endl;
32 
33  fedToken = consumes<DTuROSFEDDataCollection>(ps.getUntrackedParameter<InputTag>("dtFEDlabel"));
34 
35 #ifdef EDM_ML_DEBUG
36  neventsFED = 0;
37  neventsuROS = 0;
38 #endif
39 
40  fedIntegrityFolder = ps.getUntrackedParameter<string>("fedIntegrityFolder", "DT/FEDIntegrity");
41  nLinksForFatal = ps.getUntrackedParameter<int>("nLinksForFatal", 15); //per wheel
42 
43  string processingMode = ps.getUntrackedParameter<string>("processingMode", "Online");
44 
45  // processing mode flag to select plots to be produced and basedirs CB vedi se farlo meglio...
46  if (processingMode == "Online") {
47  mode = 0;
48  } else if (processingMode == "SM") {
49  mode = 1;
50  } else if (processingMode == "Offline") {
51  mode = 2;
52  } else if (processingMode == "HLT") {
53  mode = 3;
54  } else {
55  throw cms::Exception("MissingParameter") << "[DTDataIntegrityTask]: processingMode :" << processingMode
56  << " invalid! Must be Online, SM, Offline or HLT !" << endl;
57  }
58 }
59 
61 #ifdef EDM_ML_DEBUG
62  LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
63  << "[DTDataIntegrityTask]: Destructor. Analyzed " << neventsFED << " events" << endl;
64  LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
65  << "[DTDataIntegrityTask]: postEndJob called!" << endl;
66 #endif
67 }
68 
69 /*
70  Folder Structure uROS:
71  - 3 uROS Summary plots: Wheel-1/-2 (FED1369), Wheel0 (FED1370), Wheel+1/+2 (FED1371)
72  - One folder for each FED
73  - Inside each FED folder the uROSStatus histos, FED histos
74  - One folder for each wheel and the corresponding ROSn folders
75  - Inside each ROS folder the TDC and ROS errors histos, 24 Links/plot
76 */
77 
79  edm::Run const& iRun,
80  edm::EventSetup const& iSetup) {
81  LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask") << "[DTDataIntegrityTask]: postBeginJob" << endl;
82 
83  LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
84  << "[DTDataIntegrityTask] Get DQMStore service" << endl;
85 
86  // Loop over the DT FEDs
87 
88  LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
89  << " FEDS: " << FEDIDmin << " to " << FEDIDmax << " in the RO" << endl;
90 
91  // book FED integrity histos
92  bookHistos(ibooker, FEDIDmin, FEDIDmax);
93 
94  // static booking of the histograms
95 
96  if (mode == 0 || mode == 2) {
97  for (int fed = FEDIDmin; fed <= FEDIDmax; ++fed) { // loop over the FEDs in the readout
98 
99  bookHistos(ibooker, string("FED"), fed);
100 
101  bookHistos(ibooker, string("CRATE"), fed);
102 
103  for (int uRos = 1; uRos <= NuROS; ++uRos) { // loop over all ROS
104  bookHistosuROS(ibooker, fed, uRos);
105  }
106  }
107 
108  for (int wheel = -2; wheel < 3; ++wheel) {
109  for (int ros = 1; ros <= NuROS; ++ros) { // loop over all ROS
110  bookHistosROS(ibooker, wheel, ros);
111  }
112  }
113 
114  } //Not in HLT or SM mode
115 }
116 
117 void DTDataIntegrityTask::bookHistos(DQMStore::IBooker& ibooker, const int fedMin, const int fedMax) {
118  ibooker.setCurrentFolder("DT/EventInfo/Counters");
119  nEventMonitor = ibooker.bookFloat("nProcessedEventsDataIntegrity");
120 
121  // Standard FED integrity histos
122  ibooker.setCurrentFolder(topFolder(true));
123 
124  int nFED = (fedMax - fedMin) + 1;
125 
126  hFEDEntry = ibooker.book1D("FEDEntries", "# entries per DT FED", nFED, fedMin, fedMax + 1);
127  hFEDFatal = ibooker.book1D("FEDFatal", "# fatal errors DT FED", nFED, fedMin, fedMax + 1);
128 
129  if (mode == 1)
130  return; // to avoid duplication in FEDIntegrity_EvF folder
131 
132  string histoType = "ROSSummary";
133  for (int wheel = -2; wheel < 3; ++wheel) {
134  string wheel_s = to_string(wheel);
135  string histoName = "ROSSummary_W" + wheel_s;
136  string fed_s = to_string(FEDIDmin + 1); //3 FEDs from 2018 onwards
137  if (wheel < 0)
138  fed_s = to_string(FEDIDmin);
139  else if (wheel > 0)
140  fed_s = to_string(FEDIDmax);
141  string histoTitle = "Summary Wheel" + wheel_s + " (FED " + fed_s + ")";
142 
143  ((summaryHistos[histoType])[wheel]) = ibooker.book2D(histoName, histoTitle, 11, 0, 11, 12, 1, 13);
144  MonitorElement* histo = ((summaryHistos[histoType])[wheel]);
145  histo->setBinLabel(1, "Error 1", 1);
146  histo->setBinLabel(2, "Error 2", 1);
147  histo->setBinLabel(3, "Error 3", 1);
148  histo->setBinLabel(4, "Error 4", 1);
149  histo->setBinLabel(5, "Not OKflag", 1);
150  // TDC error bins
151  histo->setBinLabel(6, "TDC Fatal", 1);
152  histo->setBinLabel(7, "TDC RO FIFO ov.", 1);
153  histo->setBinLabel(8, "TDC L1 buf. ov.", 1);
154  histo->setBinLabel(9, "TDC L1A FIFO ov.", 1);
155  histo->setBinLabel(10, "TDC hit err.", 1);
156  histo->setBinLabel(11, "TDC hit rej.", 1);
157 
158  histo->setBinLabel(1, "Sector1", 2);
159  histo->setBinLabel(2, "Sector2", 2);
160  histo->setBinLabel(3, "Sector3", 2);
161  histo->setBinLabel(4, "Sector4", 2);
162  histo->setBinLabel(5, "Sector5", 2);
163  histo->setBinLabel(6, "Sector6", 2);
164  histo->setBinLabel(7, "Sector7", 2);
165  histo->setBinLabel(8, "Sector8", 2);
166  histo->setBinLabel(9, "Sector9", 2);
167  histo->setBinLabel(10, "Sector10", 2);
168  histo->setBinLabel(11, "Sector11", 2);
169  histo->setBinLabel(12, "Sector12", 2);
170  }
171 }
172 
173 void DTDataIntegrityTask::bookHistos(DQMStore::IBooker& ibooker, string folder, const int fed) {
174  string wheel = "ZERO";
175  if (fed == FEDIDmin)
176  wheel = "NEG";
177  else if (fed == FEDIDmax)
178  wheel = "POS";
179  string fed_s = to_string(fed);
180  LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
181  << " Booking histos for FED: " << fed_s << " folder: " << folder << endl;
182 
183  string histoType;
184  string histoName;
185  string histoTitle;
186  MonitorElement* histo = nullptr;
187 
188  // Crate (old DDU) Histograms
189  if (folder == "CRATE") {
190  ibooker.setCurrentFolder(topFolder(false) + "FED" + fed_s);
191 
192  histoType = "EventLength";
193  histoName = "FED" + fed_s + "_" + histoType;
194  histoTitle = "Event Length (Bytes) FED " + fed_s;
195  (fedHistos[histoType])[fed] = ibooker.book1D(histoName, histoTitle, 501, 0, 30000);
196 
197  if (mode == 3 || mode == 1)
198  return; //Avoid duplication of Info in FEDIntegrity_EvF
199 
200  histoType = "uROSStatus";
201  histoName = "FED" + fed_s + "_" + histoType;
202  (fedHistos[histoType])[fed] = ibooker.book2D(histoName, histoName, 12, 0, 12, 12, 1, 13);
203  histo = (fedHistos[histoType])[fed];
204  // only placeholders for the moment
205  histo->setBinLabel(1, "Error G 1", 1);
206  histo->setBinLabel(2, "Error G 2", 1);
207  histo->setBinLabel(3, "Error G 3", 1);
208  histo->setBinLabel(4, "Error G 4", 1);
209  histo->setBinLabel(5, "Error G 5", 1);
210  histo->setBinLabel(6, "Error G 6", 1);
211  histo->setBinLabel(7, "Error G 7", 1);
212  histo->setBinLabel(8, "Error G 8", 1);
213  histo->setBinLabel(9, "Error G 9", 1);
214  histo->setBinLabel(10, "Error G 10", 1);
215  histo->setBinLabel(11, "Error G 11", 1);
216  histo->setBinLabel(12, "Error G 12", 1);
217 
218  histo->setBinLabel(1, "uROS 1", 2);
219  histo->setBinLabel(2, "uROS 2", 2);
220  histo->setBinLabel(3, "uROS 3", 2);
221  histo->setBinLabel(4, "uROS 4", 2);
222  histo->setBinLabel(5, "uROS 5", 2);
223  histo->setBinLabel(6, "uROS 6", 2);
224  histo->setBinLabel(7, "uROS 7", 2);
225  histo->setBinLabel(8, "uROS 8", 2);
226  histo->setBinLabel(9, "uROS 9", 2);
227  histo->setBinLabel(10, "uROS 10", 2);
228  histo->setBinLabel(11, "uROS 11", 2);
229  histo->setBinLabel(12, "uROS 12", 2);
230 
231  if (mode == 0) { //Info for Online only
232 
233  histoType = "FEDAvgEvLengthvsLumi";
234  histoName = "FED" + fed_s + "_" + histoType;
235  histoTitle = "Avg Event Length (Bytes) vs LumiSec FED " + fed_s;
236  (fedTimeHistos[histoType])[fed] = new DTTimeEvolutionHisto(ibooker, histoName, histoTitle, 200, 10, true, 0);
237 
238  //Not used for the moment due to wrong coding from AMC13
239  /*
240  histoType = "TTSValues";
241  histoName = "FED" + fed_s + "_" + histoType;
242  (fedHistos[histoType])[fed] = ibooker.book1D(histoName, histoName, 6, 0, 6);
243  histo = (fedHistos[histoType])[fed];
244  histo->setBinLabel(1, "Ready", 1);
245  histo->setBinLabel(2, "Overflow Warning ", 1);
246  histo->setBinLabel(3, "Busy", 1);
247  histo->setBinLabel(4, "Sync lost", 1);
248  histo->setBinLabel(5, "Error", 1);
249  histo->setBinLabel(6, "Unknown", 1);
250  */
251  histoType = "uROSList";
252  histoName = "FED" + fed_s + "_" + histoType;
253  histoTitle = "# of uROS in the FED payload (FED" + fed_s + ")";
254  (fedHistos[histoType])[fed] = ibooker.book1D(histoName, histoTitle, 13, 0, 13);
255 
256  histoType = "BXID";
257  histoName = "FED" + fed_s + "_BXID";
258  histoTitle = "Distrib. BX ID (FED" + fed_s + ")";
259  (fedHistos[histoType])[fed] = ibooker.book1D(histoName, histoTitle, 3600, 0, 3600);
260  } // mode == 0 for Online only
261  }
262 
263  // uROS Histograms
264  if (folder == "FED") { // The summary of the error of the ROS on the same FED
265  ibooker.setCurrentFolder(topFolder(false));
266 
267  if (mode == 3 || mode == 1)
268  return; //Avoid duplication of Info in FEDIntegrity_EvF
269 
270  histoType = "uROSSummary";
271  histoName = "FED" + fed_s + "_uROSSummary";
272  string histoTitle = "Summary Wheel" + wheel + " (FED " + fed_s + ")";
273 
274  ((summaryHistos[histoType])[fed]) = ibooker.book2D(histoName, histoTitle, 12, 0, 12, 12, 1, 13);
275  MonitorElement* histo = ((summaryHistos[histoType])[fed]);
276  // ROS error bins
277  // Placeholders for Global Errors for the moment
278  histo->setBinLabel(1, "Error G 1", 1);
279  histo->setBinLabel(2, "Error G 2", 1);
280  histo->setBinLabel(3, "Error G 3", 1);
281  histo->setBinLabel(4, "Error G 4", 1);
282  histo->setBinLabel(5, "Error G 5", 1);
283  histo->setBinLabel(6, "Error G 6", 1);
284  histo->setBinLabel(7, "Error G 7", 1);
285  histo->setBinLabel(8, "Error G 8", 1);
286  histo->setBinLabel(9, "Error G 9", 1);
287  histo->setBinLabel(10, "Error G 10", 1);
288  histo->setBinLabel(11, "Error G 11", 1);
289  histo->setBinLabel(12, "Error G 12", 1);
290 
291  histo->setBinLabel(1, "uROS1", 2);
292  histo->setBinLabel(2, "uROS2", 2);
293  histo->setBinLabel(3, "uROS3", 2);
294  histo->setBinLabel(4, "uROS4", 2);
295  histo->setBinLabel(5, "uROS5", 2);
296  histo->setBinLabel(6, "uROS6", 2);
297  histo->setBinLabel(7, "uROS7", 2);
298  histo->setBinLabel(8, "uROS8", 2);
299  histo->setBinLabel(9, "uROS9", 2);
300  histo->setBinLabel(10, "uROS10", 2);
301  histo->setBinLabel(11, "uROS11", 2);
302  histo->setBinLabel(12, "uROS12", 2);
303  }
304 }
305 
306 void DTDataIntegrityTask::bookHistosROS(DQMStore::IBooker& ibooker, const int wheel, const int ros) {
307  string wheel_s = to_string(wheel);
308  string ros_s = to_string(ros);
309  ibooker.setCurrentFolder(topFolder(false) + "Wheel" + wheel_s + "/Sector" + ros_s);
310 
311  string histoType = "ROSError";
312  int linkDown = 0;
313  string linkDown_s = to_string(linkDown);
314  int linkUp = linkDown + 24;
315  string linkUp_s = to_string(linkUp);
316  string histoName = "W" + wheel_s + "_" + "Sector" + ros_s + "_" + histoType;
317  string histoTitle = histoName + " (Channel " + linkDown_s + "-" + linkUp_s + " error summary)";
318  unsigned int keyHisto = (uROSError)*1000 + (wheel + 2) * 100 + (ros - 1);
319  if (mode < 1) // Online only
320  urosHistos[keyHisto] = ibooker.book2D(histoName, histoTitle, 11, 0, 11, 25, 0, 25);
321  else if (mode > 1)
322  urosHistos[keyHisto] = ibooker.book2D(histoName, histoTitle, 5, 0, 5, 25, 0, 25);
323 
325  // uROS error bins
326  // Placeholders for the moment
327  histo->setBinLabel(1, "Error 1", 1);
328  histo->setBinLabel(2, "Error 2", 1);
329  histo->setBinLabel(3, "Error 3", 1);
330  histo->setBinLabel(4, "Error 4", 1);
331  histo->setBinLabel(5, "Not OKFlag", 1);
332  if (mode < 1) { //Online only
333  // TDC error bins
334  histo->setBinLabel(6, "TDC Fatal", 1);
335  histo->setBinLabel(7, "TDC RO FIFO ov.", 1);
336  histo->setBinLabel(8, "TDC L1 buf. ov.", 1);
337  histo->setBinLabel(9, "TDC L1A FIFO ov.", 1);
338  histo->setBinLabel(10, "TDC hit err.", 1);
339  histo->setBinLabel(11, "TDC hit rej.", 1);
340  }
341  for (int link = linkDown; link < linkUp; ++link) {
342  int sector = ros;
343 
344  int station = int(link / 6) + 1;
345  if (link == 18)
346  station = 3;
347 
348  int rob = link % 6;
349  if (link == 18)
350  rob = 6;
351  else if (link > 18)
352  rob = rob - 1;
353 
354  //Sector 4 exceptions
355  if (ros == 4) {
356  if (link > 18 && link < 22)
357  rob = rob + 2;
358  else if (link == 22 || link == 23) {
359  sector = 13;
360  rob = rob - 1;
361  }
362  }
363 
364  //Sector 9 exceptions
365  if (ros == 9 && (link == 22 || link == 23)) {
366  sector = 13;
367  rob = rob - 3;
368  }
369 
370  //Sector 10 exceptions
371  if (ros == 10) {
372  if (link > 18 && link < 22)
373  sector = 14;
374  else if (link == 22 || link == 23)
375  rob = rob - 3;
376  }
377 
378  //Sector 11 exceptions
379  if (ros == 11 && (link == 22 || link == 23)) {
380  sector = 4;
381  rob = rob - 3;
382  }
383 
384  string sector_s = to_string(sector);
385  string st_s = to_string(station);
386  string rob_s = to_string(rob);
387  histo->setBinLabel(link + 1, "S" + sector_s + " MB" + st_s + " ROB" + rob_s, 2);
388  }
389 
390  int link25 = linkUp;
391  string label25[12] = {"S1 MB4 ROB5",
392  "S2 MB4 ROB5",
393  "S3 MB4 ROB5",
394  "S13 MB4 ROB4",
395  "S5 MB4 ROB5",
396  "S6 MB4 ROB5",
397  "S7 MB4 ROB5",
398  "S8 MB4 ROB5",
399  "S10 MB4 ROB3",
400  "S10 MB4 ROB2",
401  "S14 MB4 ROB3",
402  "S12 MB4 ROB5"};
403  histo->setBinLabel(link25 + 1, label25[ros - 1], 2);
404 
405  if (mode > 1)
406  return;
407 
408  histoType = "TDCError";
409  linkDown = 0;
410  linkDown_s = to_string(linkDown);
411  linkUp = linkDown + 24;
412  linkUp_s = to_string(linkUp);
413  histoName = "W" + wheel_s + "_" + "Sector" + ros_s + "_" + histoType;
414  histoTitle = histoName + " (Channel " + linkDown_s + "-" + linkUp_s + " error summary)";
415  keyHisto = (TDCError)*1000 + (wheel + 2) * 100 + (ros - 1);
416  urosHistos[keyHisto] = ibooker.book2D(histoName, histoTitle, 24, 0, 24, 25, 0, 25);
418  // TDC error bins
419  histo->setBinLabel(1, "Fatal", 1);
420  histo->setBinLabel(2, "RO FIFO ov.", 1);
421  histo->setBinLabel(3, "L1 buf. ov.", 1);
422  histo->setBinLabel(4, "L1A FIFO ov.", 1);
423  histo->setBinLabel(5, "hit err.", 1);
424  histo->setBinLabel(6, "hit rej.", 1);
425  histo->setBinLabel(7, "Fatal", 1);
426  histo->setBinLabel(8, "RO FIFO ov.", 1);
427  histo->setBinLabel(9, "L1 buf. ov.", 1);
428  histo->setBinLabel(10, "L1A FIFO ov.", 1);
429  histo->setBinLabel(11, "hit err.", 1);
430  histo->setBinLabel(12, "hit rej.", 1);
431  histo->setBinLabel(13, "Fatal", 1);
432  histo->setBinLabel(14, "RO FIFO ov.", 1);
433  histo->setBinLabel(15, "L1 buf. ov.", 1);
434  histo->setBinLabel(16, "L1A FIFO ov.", 1);
435  histo->setBinLabel(17, "hit err.", 1);
436  histo->setBinLabel(18, "hit rej.", 1);
437  histo->setBinLabel(19, "Fatal", 1);
438  histo->setBinLabel(20, "RO FIFO ov.", 1);
439  histo->setBinLabel(21, "L1 buf. ov.", 1);
440  histo->setBinLabel(22, "L1A FIFO ov.", 1);
441  histo->setBinLabel(23, "hit err.", 1);
442  histo->setBinLabel(24, "hit rej.", 1);
443 
444  for (int link = linkDown; link < linkUp; ++link) {
445  int sector = ros;
446 
447  int station = int(link / 6) + 1;
448  if (link == 18)
449  station = 3;
450 
451  int rob = link % 6;
452  if (link == 18)
453  rob = 6;
454  else if (link > 18)
455  rob = rob - 1;
456 
457  //Sector 4 exceptions
458  if (ros == 4) {
459  if (link > 18 && link < 22)
460  rob = rob + 2;
461  else if (link == 22 || link == 23) {
462  sector = 13;
463  rob = rob - 1;
464  }
465  }
466 
467  //Sector 9 exceptions
468  if (ros == 9 && (link == 22 || link == 23))
469  rob = rob - 3;
470 
471  //Sector 10 exceptions
472  if (ros == 10) {
473  if (link > 18 && link < 22)
474  sector = 14;
475  else if (link == 22 || link == 23)
476  rob = rob - 3;
477  }
478 
479  //Sector 11 exceptions
480  if (ros == 11 && (link == 22 || link == 23)) {
481  sector = 4;
482  rob = rob - 3;
483  }
484 
485  string sector_s = to_string(sector);
486  string st_s = to_string(station);
487  string rob_s = to_string(rob);
488  histo->setBinLabel(link + 1, "S" + sector_s + " MB" + st_s + " ROB" + rob_s, 2);
489  }
490 
491  link25 = linkUp;
492  histo->setBinLabel(link25 + 1, label25[ros - 1], 2);
493 
494 } //bookHistosROS
495 
496 void DTDataIntegrityTask::bookHistosuROS(DQMStore::IBooker& ibooker, const int fed, const int uRos) {
497  string fed_s = to_string(fed);
498  string uRos_s = to_string(uRos);
499  ibooker.setCurrentFolder(topFolder(false) + "FED" + fed_s + "/uROS" + uRos_s);
500 
501  if (mode >= 1)
502  return;
503 
504  string histoType = "uROSEventLength";
505  string histoName = "FED" + fed_s + "_uROS" + uRos_s + "_" + "EventLength";
506  string histoTitle = "Event Length (Bytes) FED " + fed_s + " uROS" + uRos_s;
507  unsigned int keyHisto = (uROSEventLength)*1000 + (fed - FEDIDmin) * 100 + (uRos - 1);
508  urosHistos[keyHisto] = ibooker.book1D(histoName, histoTitle, 101, 0, 5000);
509 
510  histoType = "uROSAvgEventLengthvsLumi";
511  histoName = "FED" + fed_s + "_ROS" + uRos_s + "AvgEventLengthvsLumi";
512  histoTitle = "Event Length (Bytes) FED " + fed_s + " ROS" + uRos_s;
513  keyHisto = (fed - FEDIDmin) * 100 + (uRos - 1);
514  urosTimeHistos[keyHisto] = new DTTimeEvolutionHisto(ibooker, histoName, histoTitle, 200, 10, true, 0);
515 
516  histoType = "TTSValues";
517  histoName = "FED" + fed_s + "_" + "uROS" + uRos_s + "_" + histoType;
518  keyHisto = TTSValues * 1000 + (fed - FEDIDmin) * 100 + (uRos - 1);
519  urosHistos[keyHisto] = ibooker.book1D(histoName, histoName, 4, 1, 5);
521  histo->setBinLabel(1, "Overflow Warning ", 1);
522  histo->setBinLabel(2, "Busy", 1);
523  histo->setBinLabel(3, "Ready", 1);
524  histo->setBinLabel(4, "Unknown", 1);
525 }
526 
528 #ifdef EDM_ML_DEBUG
529  neventsuROS++;
530 
531  LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
532  << "[DTDataIntegrityTask]: " << neventsuROS << " events analyzed by processuROS" << endl;
533 #endif
534 
535  if (mode == 3) // || mode == 1)
536  return; //Avoid duplication of Info in FEDIntegrity_EvF
537 
538  MonitorElement* uROSSummary = nullptr;
539  MonitorElement* uROSStatus = nullptr;
540 
541  unsigned int slotMap = (data.getboardId()) & 0xF;
542  if (slotMap == 0)
543  return; //prevention for Simulation empty uROS data
544  unsigned int ros = theROS(slotMap, 0); //first sector correspondign to link 0
545  int ddu = theDDU(fed, slotMap, 0, false);
546  int wheel = (ddu - 770) % 5 - 2;
547  int sector4 = 3; //Asymmetry in mapping
548 
549  MonitorElement* ROSSummary = nullptr;
550  ROSSummary = summaryHistos["ROSSummary"][wheel];
551 
552  // Summary of all Link errors
553  MonitorElement* uROSError0 = nullptr;
554  MonitorElement* uROSError1 = nullptr;
555  MonitorElement* uROSError2 = nullptr;
556  MonitorElement* uROSErrorS4 = nullptr;
557 
558  if (mode <= 2) {
559  if (uRos > 2) { //sectors 1-12
560  if (mode != 1) {
561  uROSSummary = summaryHistos["uROSSummary"][fed];
562  uROSStatus = fedHistos["uROSStatus"][fed];
563  if (!uROSSummary) {
564  LogError("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
565  << "Trying to access non existing ME at FED " << fed << std::endl;
566  return;
567  }
568 
569  uROSError0 = urosHistos[(uROSError)*1000 + (wheel + 2) * 100 + (ros - 1)]; //links 0-23
570  uROSError1 = urosHistos[(uROSError)*1000 + (wheel + 2) * 100 + (ros)]; //links 24-47
571  uROSError2 = urosHistos[(uROSError)*1000 + (wheel + 2) * 100 + (ros + 1)]; //links 48-71
572  uROSErrorS4 = urosHistos[(uROSError)*1000 + (wheel + 2) * 100 + 3];
573 
574  if ((!uROSError2) || (!uROSError1) || (!uROSError0)) {
575  LogError("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
576  << "Trying to access non existing ME at uROS " << uRos << std::endl;
577  return;
578  }
579  }
580 
581  // uROS errors
582  for (unsigned int link = 0; link < 72; ++link) {
583  for (unsigned int flag = 0; flag < 5; ++flag) {
584  if ((data.getokxflag(link) >> flag) & 0x1) { // Undefined Flag 1-4 64bits word for each MTP (12 channels)
585 
586  int value = flag != 0 ? flag : 5; //if flag = 0 move it to the 5th bin
587  if (link < 24) {
588  errorX[value - 1][ros - 1][wheel + 2] += 1;
589  if (mode != 1)
590  uROSError0->Fill(value - 1, link); //bins start at 0 despite labeling
591  } else if (link < 48) {
592  if ((link == 46 || link == 57) && ros == 10)
593  errorX[value - 1][sector4][wheel + 2] += 1;
594  else
595  errorX[value - 1][ros][wheel + 2] += 1;
596  if (mode != 1) {
597  if ((link == 46 || link == 57) && ros == 10)
598  uROSErrorS4->Fill(value - 1, link - 24);
599  else
600  uROSError1->Fill(value - 1, link - 24);
601  }
602  } else if (link < 72) {
603  errorX[value - 1][ros + 1][wheel + 2] += 1;
604  if (mode != 1)
605  uROSError2->Fill(value - 1, link - 48);
606  }
607  } //flag value
608  } //loop on flags
609  } //loop on links
610  } //uROS>2
611 
612  else { //uRos<3 25th Channel slot
613 
614  for (unsigned int link = 0; link < 12; ++link) {
615  for (unsigned int flag = 0; flag < 5; ++flag) {
616  if ((data.getokxflag(link) >> flag) & 0x1) { // Undefined Flag 1-4 64bits word for each MTP (12 channels)
617  int value = flag;
618  int ch25 = 24;
619  int sector = link + 1;
620  if (flag == 0)
621  value = 5; //move it to the 5th bin
622 
623  if (value > 0) {
624  if (mode != 1) {
625  if (sector == 9)
626  sector = 10;
627  unsigned int keyHisto =
628  (uROSError)*1000 + (wheel + 2) * 100 + abs(sector - 1); //ros -1 = link in this case
629  uROSError0 = urosHistos[keyHisto];
630  if (!uROSError0) {
631  LogError("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
632  << "Trying to access non existing ME at uROS " << uRos << std::endl;
633  return;
634  }
635  }
636  errorX[value - 1][sector - 1][wheel + 2] += 1; // ros-1=link in this case
637  if (mode != 1)
638  uROSError0->Fill(value - 1, ch25); //bins start at 0 despite labeling, this is the old SC
639  }
640  } //flag values
641  } //loop on flags
642  } //loop on links
643  } //else uRos<3
644 
645  if (mode != 1) {
646  // Global Errors for uROS
647  for (unsigned int flag = 4; flag < 16; ++flag) {
648  if ((data.getuserWord() >> flag) & 0x1) {
649  uROSSummary->Fill(flag - 4, uRos);
650  uROSStatus->Fill(flag - 4, uRos); //duplicated info?
651  }
652  }
653  }
654 
655  } //mode<=2
656 
657  if (mode != 1) {
658  // Fill the ROSSummary (1 per wheel) histo
659  for (unsigned int iros = ros - 1; iros < (ros + 2); ++iros) {
660  for (unsigned int bin = 0; bin < 5; ++bin) {
661  if (errorX[bin][iros][wheel + 2] != 0) {
662  ROSSummary->Fill(bin, iros + 1, errorX[bin][iros][wheel + 2]); //bins start at 1
663  }
664  }
665  }
666  }
667 
668  // ROS error
669  for (unsigned int icounter = 0; icounter < data.geterrors().size(); ++icounter) {
670  int link = data.geterrorROBID(icounter);
671  int tdc = data.geterrorTDCID(icounter);
672  int error = data.geterror(icounter);
673  int tdcError_ROSSummary = 0;
674  int tdcError_ROSError = 0;
675  int tdcError_TDCHisto = 0;
676 
677  if (error & 0x4000) {
678  LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
679  << " ROS " << uRos << " ROB " << link << " Internal fatal Error 4000 in TDC " << error << endl;
680 
681  tdcError_ROSSummary = 5;
682  tdcError_ROSError = 5;
683  tdcError_TDCHisto = 0;
684 
685  } else if (error & 0x0249) {
686  LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
687  << " ROS " << uRos << " ROB " << link << " TDC FIFO overflow in TDC " << error << endl;
688 
689  tdcError_ROSSummary = 6;
690  tdcError_ROSError = 6;
691  tdcError_TDCHisto = 1;
692 
693  } else if (error & 0x0492) {
694  LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
695  << " ROS " << uRos << " ROB " << link << " TDC L1 buffer overflow in TDC " << error << endl;
696 
697  tdcError_ROSSummary = 7;
698  tdcError_ROSError = 7;
699  tdcError_TDCHisto = 2;
700 
701  } else if (error & 0x2000) {
702  LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
703  << " ROS " << uRos << " ROB " << link << " TDC L1A FIFO overflow in TDC " << error << endl;
704 
705  tdcError_ROSSummary = 8;
706  tdcError_ROSError = 8;
707  tdcError_TDCHisto = 3;
708 
709  } else if (error & 0x0924) {
710  LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
711  << " uROS " << uRos << " ROB " << link << " TDC hit error in TDC " << error << endl;
712 
713  tdcError_ROSSummary = 9;
714  tdcError_ROSError = 9;
715  tdcError_TDCHisto = 4;
716 
717  } else if (error & 0x1000) {
718  LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
719  << " uROS " << uRos << " ROB " << link << " TDC hit rejected in TDC " << error << endl;
720 
721  tdcError_ROSSummary = 10;
722  tdcError_ROSError = 10;
723  tdcError_TDCHisto = 5;
724 
725  } else {
726  LogWarning("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
727  << " TDC error code not known " << error << endl;
728  }
729 
730  if (uRos < 3) {
731  int sector = link + 1;
732  if (tdcError_ROSSummary == 5)
733  errorX[5][link][wheel + 2] += 1;
734  if (mode != 1) {
735  if (sector == 9)
736  sector = 10;
737  ROSSummary->Fill(tdcError_ROSSummary, sector - 1); //link 0 = ROS 1
738  int ch25 = 24;
739  if (mode <= 2) {
740  urosHistos[(uROSError)*1000 + (wheel + 2) * 100 + (sector - 1)]->Fill(tdcError_ROSError, ch25);
741  if (mode < 1)
742  urosHistos[(TDCError)*1000 + (wheel + 2) * 100 + (sector - 1)]->Fill(tdcError_TDCHisto + 6 * tdc,
743  ch25); // ros-1=link in this case
744  } //mode <= 2
745  } //mode!=1
746  } //uRos<3
747  else { //uRos>2
748  if (link < 24) {
749  if (tdcError_ROSSummary == 5)
750  errorX[5][ros - 1][wheel + 2] += 1;
751  if (mode != 1)
752  ROSSummary->Fill(tdcError_ROSSummary, ros);
753  } else if (link < 48) {
754  if (tdcError_ROSSummary == 5) {
755  if ((link == 46 || link == 57) && ros == 10)
756  errorX[5][sector4][wheel + 2] += 1;
757  else
758  errorX[5][ros][wheel + 2] += 1;
759  }
760  if (mode != 1) {
761  if ((link == 46 || link == 57) && ros == 10)
762  ROSSummary->Fill(tdcError_ROSSummary, sector4);
763  else
764  ROSSummary->Fill(tdcError_ROSSummary, ros + 1);
765  }
766  } else if (link < 72) {
767  if (tdcError_ROSSummary == 5)
768  errorX[5][ros + 1][wheel + 2] += 1;
769  if (mode != 1)
770  ROSSummary->Fill(tdcError_ROSSummary, ros + 2);
771  }
772 
773  if (mode <= 2 && mode != 1) {
774  if (link < 24)
775  uROSError0->Fill(tdcError_ROSError, link);
776  else if (link < 48)
777  if ((link == 46 || link == 57) && ros == 10)
778  uROSError1->Fill(tdcError_ROSError, sector4);
779  else
780  uROSError1->Fill(tdcError_ROSError, link - 24);
781  else if (link < 72)
782  uROSError2->Fill(tdcError_ROSError, link - 48);
783 
784  if (mode < 1) {
785  if (link < 24)
786  urosHistos[(TDCError)*1000 + (wheel + 2) * 100 + (ros - 1)]->Fill(tdcError_TDCHisto + 6 * tdc, link);
787  else if (link < 48)
788  urosHistos[(TDCError)*1000 + (wheel + 2) * 100 + (ros)]->Fill(tdcError_TDCHisto + 6 * tdc, link - 24);
789  else if (link < 72)
790  urosHistos[(TDCError)*1000 + (wheel + 2) * 100 + (ros + 1)]->Fill(tdcError_TDCHisto + 6 * tdc, link - 48);
791 
792  } //mode<1
793  } //mode<=2 && mode != 1
794  } //uROS>2
795  } //loop on errors
796 
797  // 1D histograms for TTS values per uROS
798  if (mode < 1) {
799  int ttsCodeValue = -1;
800  int value = (data.getuserWord() & 0xF);
801  switch (value) {
802  case 1: { //warning overflow
803  ttsCodeValue = 1;
804  break;
805  }
806  case 4: { //busy
807  ttsCodeValue = 2;
808  break;
809  }
810  case 8: { //ready
811  ttsCodeValue = 3;
812  break;
813  }
814  default: {
815  LogError("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
816  << "[DTDataIntegrityTask] FED User control: wrong TTS value " << value << " in FED " << fed << " uROS "
817  << uRos << endl;
818  ttsCodeValue = 4;
819  }
820  }
821 
822  urosHistos[TTSValues * 1000 + (fed - FEDIDmin) * 100 + (uRos - 1)]->Fill(ttsCodeValue);
823 
824  // Plot the event length //NOHLT
825  int uRosEventLength = (data.gettrailer() & 0xFFFFF) * 8;
826  urosTimeHistos[(fed - FEDIDmin) * 100 + (uRos - 1)]->accumulateValueTimeSlot(uRosEventLength);
827 
828  if (uRosEventLength > 5000)
829  uRosEventLength = 5000;
830  urosHistos[uROSEventLength * 1000 + (fed - FEDIDmin) * 100 + (uRos - 1)]->Fill(uRosEventLength);
831  }
832 }
833 
835 #ifdef EDM_ML_DEBUG
836  neventsFED++;
837  if (neventsFED % 1000 == 0)
838  LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
839  << "[DTDataIntegrityTask]: " << neventsFED << " events analyzed by processFED" << endl;
840 #endif
841 
842  if (fed < FEDIDmin || fed > FEDIDmax)
843  return;
844 
845  hFEDEntry->Fill(fed);
846 
847  if (mode == 3)
848  return; //Avoid duplication of Info in FEDIntegrity_EvF
849 
850  if (mode != 1) {
851  //1D HISTOS: EVENT LENGHT from trailer
852  int fedEvtLength = data.getevtlgth() * 8; //1 word = 8 bytes
853  // if(fedEvtLength > 16000) fedEvtLength = 16000; // overflow bin
854  fedHistos["EventLength"][fed]->Fill(fedEvtLength);
855 
856  if (mode == 0) {
857  fedTimeHistos["FEDAvgEvLengthvsLumi"][fed]->accumulateValueTimeSlot(fedEvtLength);
858 
859  // fill the distribution of the BX ids
860  fedHistos["BXID"][fed]->Fill(data.getBXId());
861 
862  // size of the list of ROS in the Read-Out
863  fedHistos["uROSList"][fed]->Fill(data.getnslots());
864  }
865 
866  } //mode != 1
867 
868  // Fill the status summary of the TTS
869 
870  //1D HISTO WITH TTS VALUES form trailer
871  //Not used for the moment due to wrong coding from AMC13
872  /*
873  int ttsCodeValue = -1;
874  int value = data.getTTS();
875  switch (value) {
876  case 0: { //ready
877  ttsCodeValue = 0;
878  break;
879  }
880  case 1: { //warning overflow
881  ttsCodeValue = 1;
882  break;
883  }
884  case 2: { //busy
885  ttsCodeValue = 2;
886  break;
887  }
888  case 4: { //synch lost
889  ttsCodeValue = 3;
890  break;
891  }
892  case 8: { //error
893  ttsCodeValue = 4;
894  break;
895  }
896  default: {
897  LogError("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
898  << "[DTDataIntegrityTask] FED TTS control: wrong TTS value " << value << " in FED " << fed << endl;
899  ttsCodeValue = 5;
900  }
901  }
902  if (mode < 1)
903  fedHistos["TTSValues"][fed]->Fill(ttsCodeValue);
904  */
905 
906  //FEDFatal definition per wheel: 5*TDCFatal/6000 + 5*NotOKFlag/1500
907  int wheel = 0;
908  if (fed == FEDIDmin)
909  wheel = -2;
910  else if (fed == FEDIDmax)
911  wheel = 1;
912 
913  float sumTDC = 0., sumNotOKFlag = 0.;
914  for (int ros = 0; ros < 12; ros++) {
915  sumNotOKFlag += errorX[4][ros][wheel + 2];
916  sumTDC += errorX[5][ros][wheel + 2];
917  }
918 
919  if (wheel != 0) { // consider both wheels for FEDs 1369 & 1371
920  wheel += 1;
921  for (int ros = 0; ros < 12; ros++) {
922  sumNotOKFlag += errorX[4][ros][wheel + 2];
923  sumTDC += errorX[5][ros][wheel + 2];
924  }
925  }
926 
927  //Divide by 2 for egde FEDs to normalize per wheel
928  sumNotOKFlag = sumNotOKFlag / ((wheel != 0) ? 2. : 1.);
929  sumTDC = sumTDC / ((wheel != 0) ? 2. : 1.);
930 
931  if (sumNotOKFlag > nLinksForFatal || sumTDC > nLinksForFatal)
932  hFEDFatal->Fill(fed);
933 }
934 
935 std::string DTDataIntegrityTask::topFolder(bool isFEDIntegrity) const {
936  string folder = isFEDIntegrity ? fedIntegrityFolder : "DT/00-DataIntegrity/";
937 
938  if (mode == 0)
939  folder = "DT/00-DataIntegrity/"; //Move everything from FEDIntegrity except for SM and HLT modes
940 
941  return folder;
942 }
943 
945  const edm::EventSetup& es) const {
946  return std::make_shared<dtdi::LumiCache>();
947 }
948 
950  int lumiBlock = ls.id().luminosityBlock();
951  const auto nEventsLS = luminosityBlockCache(ls.index())->nEventsLS;
952 
953  map<string, map<int, DTTimeEvolutionHisto*> >::iterator fedIt = fedTimeHistos.begin();
954  map<string, map<int, DTTimeEvolutionHisto*> >::iterator fedEnd = fedTimeHistos.end();
955  for (; fedIt != fedEnd; ++fedIt) {
956  map<int, DTTimeEvolutionHisto*>::iterator histoIt = fedIt->second.begin();
957  map<int, DTTimeEvolutionHisto*>::iterator histoEnd = fedIt->second.end();
958  for (; histoIt != histoEnd; ++histoIt) {
959  histoIt->second->updateTimeSlot(lumiBlock, nEventsLS);
960  }
961  }
962 
963  map<unsigned int, DTTimeEvolutionHisto*>::iterator urosIt = urosTimeHistos.begin();
964  map<unsigned int, DTTimeEvolutionHisto*>::iterator urosEnd = urosTimeHistos.end();
965  for (; urosIt != urosEnd; ++urosIt) {
966  urosIt->second->updateTimeSlot(lumiBlock, nEventsLS);
967  }
968 }
969 
971  nevents++;
973  luminosityBlockCache(e.getLuminosityBlock().index())->nEventsLS++;
974 
975  //errorX[6][12][5] = {0}; //5th is notOK flag and 6th is TDC Fatal; ros; wheel
976  fill(&errorX[0][0][0], &errorX[0][0][0] + 360, 0);
977 
978  LogTrace("DTRawToDigi|TDQM|DTMonitorModule|DTDataIntegrityTask") << "[DTDataIntegrityTask]: preProcessEvent" << endl;
979 
980  // Digi collection
982  e.getByToken(fedToken, fedCol);
983  DTuROSFEDData fedData;
984  DTuROSROSData urosData;
985 
986  if (fedCol.isValid()) {
987  for (unsigned int j = 0; j < fedCol->size(); ++j) {
988  fedData = fedCol->at(j);
989  int fed = fedData.getfed(); //argument should be void
990  if (fed > FEDIDmax || fed < FEDIDmin) {
991  LogError("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
992  << "[DTDataIntegrityTask]: analyze, FED ID " << fed << " not expected." << endl;
993  continue;
994  }
995 
996  if (mode == 3)
997  continue; //Not needed for FEDIntegrity_EvF
998 
999  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 // Conversions
1011 int DTDataIntegrityTask::theDDU(int crate, int slot, int link, bool tenDDU) {
1012  int ros = theROS(slot, link);
1013 
1014  int ddu = 772;
1015  //if (crate == 1368) { ddu = 775; }
1016  //Needed just in case this FED should be used due to fibers length
1017 
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 
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 }
void bookHistosROS(DQMStore::IBooker &, const int wheel, const int ros)
MonitorElement * bookFloat(TString const &name, FUNC onbooking=NOOP())
Definition: DQMStore.h:80
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:36
DTuROSROSData getuROS(int slot) const
void bookHistosuROS(DQMStore::IBooker &, const int fed, const int uRos)
void bookHistos(DQMStore::IBooker &, const int fedMin, const int fedMax)
edm::EDGetTokenT< DTuROSFEDDataCollection > fedToken
void globalEndLuminosityBlock(const edm::LuminosityBlock &ls, const edm::EventSetup &es) override
Log< level::Error, false > LogError
int getfed() const
void processuROS(DTuROSROSData &data, int fed, int uRos)
MonitorElement * hFEDFatal
static std::string to_string(const XMLCh *ch)
#define LogTrace(id)
static const int DOCESLOTS
T getUntrackedParameter(std::string const &, T const &) const
void Fill(long long x)
DTDataIntegrityTask(const edm::ParameterSet &ps)
std::map< std::string, std::map< int, DTTimeEvolutionHisto * > > fedTimeHistos
std::map< std::string, std::map< int, MonitorElement * > > summaryHistos
int theROS(int slot, int link)
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
std::map< unsigned int, MonitorElement * > urosHistos
void analyze(const edm::Event &e, const edm::EventSetup &c) override
int getslot() const
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
Definition: value.py:1
std::map< std::string, std::map< int, MonitorElement * > > fedHistos
MonitorElement * nEventMonitor
def ls(path, rec=False)
Definition: eostools.py:349
MonitorElement * hFEDEntry
MonitorElement * book2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
Definition: DQMStore.h:212
bool isValid() const
Definition: HandleBase.h:70
void processFED(DTuROSFEDData &data, int fed)
std::shared_ptr< dtdi::LumiCache > globalBeginLuminosityBlock(const edm::LuminosityBlock &ls, const edm::EventSetup &es) const override
HLT enums.
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
Log< level::Warning, false > LogWarning
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
std::map< unsigned int, DTTimeEvolutionHisto * > urosTimeHistos
int getslotsize(int slot) const
Definition: Run.h:45
int theDDU(int crate, int slot, int link, bool tenDDU)
std::string topFolder(bool isFEDIntegrity) const