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 
23 
24 #include <cmath>
25 #include <fstream>
26 #include <map>
27 #include <string>
28 #include <vector>
29 
30 using namespace std;
31 using namespace edm;
32 
34  LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask") << "[DTDataIntegrityTask]: Constructor" << endl;
35 
36  fedToken = consumes<DTuROSFEDDataCollection>(ps.getUntrackedParameter<InputTag>("dtFEDlabel"));
39 
40  neventsFED = 0;
41  neventsuROS = 0;
42 
43  fedIntegrityFolder = ps.getUntrackedParameter<string>("fedIntegrityFolder", "DT/FEDIntegrity");
44  nLinksForFatal = ps.getUntrackedParameter<int>("nLinksForFatal", 15); //per wheel
45 
46  string processingMode = ps.getUntrackedParameter<string>("processingMode", "Online");
47 
48  // processing mode flag to select plots to be produced and basedirs CB vedi se farlo meglio...
49  if (processingMode == "Online") {
50  mode = 0;
51  } else if (processingMode == "SM") {
52  mode = 1;
53  } else if (processingMode == "Offline") {
54  mode = 2;
55  } else if (processingMode == "HLT") {
56  mode = 3;
57  } else {
58  throw cms::Exception("MissingParameter") << "[DTDataIntegrityTask]: processingMode :" << processingMode
59  << " invalid! Must be Online, SM, Offline or HLT !" << endl;
60  }
61 }
62 
64  LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
65  << "[DTDataIntegrityTask]: Destructor. Analyzed " << neventsFED << " events" << endl;
66  LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
67  << "[DTDataIntegrityTask]: postEndJob called!" << endl;
68 }
69 
70 /*
71  Folder Structure uROS:
72  - 3 uROS Summary plots: Wheel-1/-2 (FED1369), Wheel0 (FED1370), Wheel+1/+2 (FED1371)
73  - One folder for each FED
74  - Inside each FED folder the uROSStatus histos, FED histos
75  - One folder for each wheel and the corresponding ROSn folders
76  - Inside each ROS folder the TDC and ROS errors histos, 24 Links/plot
77 */
78 
80  edm::Run const& iRun,
81  edm::EventSetup const& iSetup) {
82  LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask") << "[DTDataIntegrityTask]: postBeginJob" << endl;
83 
84  LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
85  << "[DTDataIntegrityTask] Get DQMStore service" << endl;
86 
87  // Loop over the DT FEDs
88 
89  LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
90  << " FEDS: " << FEDIDmin << " to " << FEDIDmax << " in the RO" << endl;
91 
92  // book FED integrity histos
93  bookHistos(ibooker, FEDIDmin, FEDIDmax);
94 
95  // static booking of the histograms
96 
97  if (mode == 0 || mode == 2) {
98  for (int fed = FEDIDmin; fed <= FEDIDmax; ++fed) { // loop over the FEDs in the readout
99 
100  bookHistos(ibooker, string("FED"), fed);
101 
102  bookHistos(ibooker, string("CRATE"), fed);
103 
104  for (int uRos = 1; uRos <= NuROS; ++uRos) { // loop over all ROS
105  bookHistosuROS(ibooker, fed, uRos);
106  }
107  }
108 
109  for (int wheel = -2; wheel < 3; ++wheel) {
110  for (int ros = 1; ros <= NuROS; ++ros) { // loop over all ROS
111  bookHistosROS(ibooker, wheel, ros);
112  }
113  }
114 
115  } //Not in HLT or SM mode
116 }
117 
118 void DTDataIntegrityTask::bookHistos(DQMStore::IBooker& ibooker, const int fedMin, const int fedMax) {
119  ibooker.setCurrentFolder("DT/EventInfo/Counters");
120  nEventMonitor = ibooker.bookFloat("nProcessedEventsDataIntegrity");
121 
122  // Standard FED integrity histos
123  ibooker.setCurrentFolder(topFolder(true));
124 
125  int nFED = (fedMax - fedMin) + 1;
126 
127  hFEDEntry = ibooker.book1D("FEDEntries", "# entries per DT FED", nFED, fedMin, fedMax + 1);
128  hFEDFatal = ibooker.book1D("FEDFatal", "# fatal errors DT FED", nFED, fedMin, fedMax + 1);
129 
130  if (mode == 1)
131  return; // to avoid duplication in FEDIntegrity_EvF folder
132 
133  string histoType = "ROSSummary";
134  for (int wheel = -2; wheel < 3; ++wheel) {
135  string wheel_s = to_string(wheel);
136  string histoName = "ROSSummary_W" + wheel_s;
137  string fed_s = to_string(FEDIDmin + 1); //3 FEDs from 2018 onwards
138  if (wheel < 0)
139  fed_s = to_string(FEDIDmin);
140  else if (wheel > 0)
141  fed_s = to_string(FEDIDmax);
142  string histoTitle = "Summary Wheel" + wheel_s + " (FED " + fed_s + ")";
143 
144  ((summaryHistos[histoType])[wheel]) = ibooker.book2D(histoName, histoTitle, 11, 0, 11, 12, 1, 13);
145  MonitorElement* histo = ((summaryHistos[histoType])[wheel]);
146  histo->setBinLabel(1, "Error 1", 1);
147  histo->setBinLabel(2, "Error 2", 1);
148  histo->setBinLabel(3, "Error 3", 1);
149  histo->setBinLabel(4, "Error 4", 1);
150  histo->setBinLabel(5, "Not OKflag", 1);
151  // TDC error bins
152  histo->setBinLabel(6, "TDC Fatal", 1);
153  histo->setBinLabel(7, "TDC RO FIFO ov.", 1);
154  histo->setBinLabel(8, "TDC L1 buf. ov.", 1);
155  histo->setBinLabel(9, "TDC L1A FIFO ov.", 1);
156  histo->setBinLabel(10, "TDC hit err.", 1);
157  histo->setBinLabel(11, "TDC hit rej.", 1);
158 
159  histo->setBinLabel(1, "Sector1", 2);
160  histo->setBinLabel(2, "Sector2", 2);
161  histo->setBinLabel(3, "Sector3", 2);
162  histo->setBinLabel(4, "Sector4", 2);
163  histo->setBinLabel(5, "Sector5", 2);
164  histo->setBinLabel(6, "Sector6", 2);
165  histo->setBinLabel(7, "Sector7", 2);
166  histo->setBinLabel(8, "Sector8", 2);
167  histo->setBinLabel(9, "Sector9", 2);
168  histo->setBinLabel(10, "Sector10", 2);
169  histo->setBinLabel(11, "Sector11", 2);
170  histo->setBinLabel(12, "Sector12", 2);
171  }
172 }
173 
174 void DTDataIntegrityTask::bookHistos(DQMStore::IBooker& ibooker, string folder, const int fed) {
175  string wheel = "ZERO";
176  if (fed == FEDIDmin)
177  wheel = "NEG";
178  else if (fed == FEDIDmax)
179  wheel = "POS";
180  string fed_s = to_string(fed);
181  LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
182  << " Booking histos for FED: " << fed_s << " folder: " << folder << endl;
183 
184  string histoType;
185  string histoName;
186  string histoTitle;
187  MonitorElement* histo = nullptr;
188 
189  // Crate (old DDU) Histograms
190  if (folder == "CRATE") {
191  ibooker.setCurrentFolder(topFolder(false) + "FED" + fed_s);
192 
193  histoType = "EventLength";
194  histoName = "FED" + fed_s + "_" + histoType;
195  histoTitle = "Event Length (Bytes) FED " + fed_s;
196  (fedHistos[histoType])[fed] = ibooker.book1D(histoName, histoTitle, 501, 0, 30000);
197 
198  if (mode == 3 || mode == 1)
199  return; //Avoid duplication of Info in FEDIntegrity_EvF
200 
201  histoType = "uROSStatus";
202  histoName = "FED" + fed_s + "_" + histoType;
203  (fedHistos[histoType])[fed] = ibooker.book2D(histoName, histoName, 12, 0, 12, 12, 1, 13);
204  histo = (fedHistos[histoType])[fed];
205  // only placeholders for the moment
206  histo->setBinLabel(1, "Error G 1", 1);
207  histo->setBinLabel(2, "Error G 2", 1);
208  histo->setBinLabel(3, "Error G 3", 1);
209  histo->setBinLabel(4, "Error G 4", 1);
210  histo->setBinLabel(5, "Error G 5", 1);
211  histo->setBinLabel(6, "Error G 6", 1);
212  histo->setBinLabel(7, "Error G 7", 1);
213  histo->setBinLabel(8, "Error G 8", 1);
214  histo->setBinLabel(9, "Error G 9", 1);
215  histo->setBinLabel(10, "Error G 10", 1);
216  histo->setBinLabel(11, "Error G 11", 1);
217  histo->setBinLabel(12, "Error G 12", 1);
218 
219  histo->setBinLabel(1, "uROS 1", 2);
220  histo->setBinLabel(2, "uROS 2", 2);
221  histo->setBinLabel(3, "uROS 3", 2);
222  histo->setBinLabel(4, "uROS 4", 2);
223  histo->setBinLabel(5, "uROS 5", 2);
224  histo->setBinLabel(6, "uROS 6", 2);
225  histo->setBinLabel(7, "uROS 7", 2);
226  histo->setBinLabel(8, "uROS 8", 2);
227  histo->setBinLabel(9, "uROS 9", 2);
228  histo->setBinLabel(10, "uROS 10", 2);
229  histo->setBinLabel(11, "uROS 11", 2);
230  histo->setBinLabel(12, "uROS 12", 2);
231 
232  if (mode == 0) { //Info for Online only
233 
234  histoType = "FEDAvgEvLengthvsLumi";
235  histoName = "FED" + fed_s + "_" + histoType;
236  histoTitle = "Avg Event Length (Bytes) vs LumiSec FED " + fed_s;
237  (fedTimeHistos[histoType])[fed] = new DTTimeEvolutionHisto(ibooker, histoName, histoTitle, 200, 10, true, 0);
238 
239  //Not used for the moment due to wrong coding from AMC13
240  /*
241  histoType = "TTSValues";
242  histoName = "FED" + fed_s + "_" + histoType;
243  (fedHistos[histoType])[fed] = ibooker.book1D(histoName, histoName, 6, 0, 6);
244  histo = (fedHistos[histoType])[fed];
245  histo->setBinLabel(1, "Ready", 1);
246  histo->setBinLabel(2, "Overflow Warning ", 1);
247  histo->setBinLabel(3, "Busy", 1);
248  histo->setBinLabel(4, "Sync lost", 1);
249  histo->setBinLabel(5, "Error", 1);
250  histo->setBinLabel(6, "Unknown", 1);
251  */
252  histoType = "uROSList";
253  histoName = "FED" + fed_s + "_" + histoType;
254  histoTitle = "# of uROS in the FED payload (FED" + fed_s + ")";
255  (fedHistos[histoType])[fed] = ibooker.book1D(histoName, histoTitle, 13, 0, 13);
256 
257  histoType = "BXID";
258  histoName = "FED" + fed_s + "_BXID";
259  histoTitle = "Distrib. BX ID (FED" + fed_s + ")";
260  (fedHistos[histoType])[fed] = ibooker.book1D(histoName, histoTitle, 3600, 0, 3600);
261  } // mode == 0 for Online only
262  }
263 
264  // uROS Histograms
265  if (folder == "FED") { // The summary of the error of the ROS on the same FED
266  ibooker.setCurrentFolder(topFolder(false));
267 
268  if (mode == 3 || mode == 1)
269  return; //Avoid duplication of Info in FEDIntegrity_EvF
270 
271  histoType = "uROSSummary";
272  histoName = "FED" + fed_s + "_uROSSummary";
273  string histoTitle = "Summary Wheel" + wheel + " (FED " + fed_s + ")";
274 
275  ((summaryHistos[histoType])[fed]) = ibooker.book2D(histoName, histoTitle, 12, 0, 12, 12, 1, 13);
276  MonitorElement* histo = ((summaryHistos[histoType])[fed]);
277  // ROS error bins
278  // Placeholders for Global Errors for the moment
279  histo->setBinLabel(1, "Error G 1", 1);
280  histo->setBinLabel(2, "Error G 2", 1);
281  histo->setBinLabel(3, "Error G 3", 1);
282  histo->setBinLabel(4, "Error G 4", 1);
283  histo->setBinLabel(5, "Error G 5", 1);
284  histo->setBinLabel(6, "Error G 6", 1);
285  histo->setBinLabel(7, "Error G 7", 1);
286  histo->setBinLabel(8, "Error G 8", 1);
287  histo->setBinLabel(9, "Error G 9", 1);
288  histo->setBinLabel(10, "Error G 10", 1);
289  histo->setBinLabel(11, "Error G 11", 1);
290  histo->setBinLabel(12, "Error G 12", 1);
291 
292  histo->setBinLabel(1, "uROS1", 2);
293  histo->setBinLabel(2, "uROS2", 2);
294  histo->setBinLabel(3, "uROS3", 2);
295  histo->setBinLabel(4, "uROS4", 2);
296  histo->setBinLabel(5, "uROS5", 2);
297  histo->setBinLabel(6, "uROS6", 2);
298  histo->setBinLabel(7, "uROS7", 2);
299  histo->setBinLabel(8, "uROS8", 2);
300  histo->setBinLabel(9, "uROS9", 2);
301  histo->setBinLabel(10, "uROS10", 2);
302  histo->setBinLabel(11, "uROS11", 2);
303  histo->setBinLabel(12, "uROS12", 2);
304  }
305 }
306 
307 void DTDataIntegrityTask::bookHistosROS(DQMStore::IBooker& ibooker, const int wheel, const int ros) {
308  string wheel_s = to_string(wheel);
309  string ros_s = to_string(ros);
310  ibooker.setCurrentFolder(topFolder(false) + "Wheel" + wheel_s + "/Sector" + ros_s);
311 
312  string histoType = "ROSError";
313  int linkDown = 0;
314  string linkDown_s = to_string(linkDown);
315  int linkUp = linkDown + 24;
316  string linkUp_s = to_string(linkUp);
317  string histoName = "W" + wheel_s + "_" + "Sector" + ros_s + "_" + histoType;
318  string histoTitle = histoName + " (Channel " + linkDown_s + "-" + linkUp_s + " error summary)";
319  unsigned int keyHisto = (uROSError)*1000 + (wheel + 2) * 100 + (ros - 1);
320  if (mode < 1) // Online only
321  urosHistos[keyHisto] = ibooker.book2D(histoName, histoTitle, 11, 0, 11, 25, 0, 25);
322  else if (mode > 1)
323  urosHistos[keyHisto] = ibooker.book2D(histoName, histoTitle, 5, 0, 5, 25, 0, 25);
324 
326  // uROS error bins
327  // Placeholders for the moment
328  histo->setBinLabel(1, "Error 1", 1);
329  histo->setBinLabel(2, "Error 2", 1);
330  histo->setBinLabel(3, "Error 3", 1);
331  histo->setBinLabel(4, "Error 4", 1);
332  histo->setBinLabel(5, "Not OKFlag", 1);
333  if (mode < 1) { //Online only
334  // TDC error bins
335  histo->setBinLabel(6, "TDC Fatal", 1);
336  histo->setBinLabel(7, "TDC RO FIFO ov.", 1);
337  histo->setBinLabel(8, "TDC L1 buf. ov.", 1);
338  histo->setBinLabel(9, "TDC L1A FIFO ov.", 1);
339  histo->setBinLabel(10, "TDC hit err.", 1);
340  histo->setBinLabel(11, "TDC hit rej.", 1);
341  }
342  for (int link = linkDown; link < linkUp; ++link) {
343  int sector = ros;
344 
345  int station = int(link / 6) + 1;
346  if (link == 18)
347  station = 3;
348 
349  int rob = link % 6;
350  if (link == 18)
351  rob = 6;
352  else if (link > 18)
353  rob = rob - 1;
354 
355  //Sector 4 exceptions
356  if (ros == 4) {
357  if (link > 18 && link < 22)
358  rob = rob + 2;
359  else if (link == 22 || link == 23) {
360  sector = 13;
361  rob = rob - 1;
362  }
363  }
364 
365  //Sector 9 exceptions
366  if (ros == 9 && (link == 22 || link == 23)) {
367  sector = 13;
368  rob = rob - 3;
369  }
370 
371  //Sector 10 exceptions
372  if (ros == 10) {
373  if (link > 18 && link < 22)
374  sector = 14;
375  else if (link == 22 || link == 23)
376  rob = rob - 3;
377  }
378 
379  //Sector 11 exceptions
380  if (ros == 11 && (link == 22 || link == 23)) {
381  sector = 4;
382  rob = rob - 3;
383  }
384 
385  string sector_s = to_string(sector);
386  string st_s = to_string(station);
387  string rob_s = to_string(rob);
388  histo->setBinLabel(link + 1, "S" + sector_s + " MB" + st_s + " ROB" + rob_s, 2);
389  }
390 
391  int link25 = linkUp;
392  string label25[12] = {"S1 MB4 ROB5",
393  "S2 MB4 ROB5",
394  "S3 MB4 ROB5",
395  "S13 MB4 ROB4",
396  "S5 MB4 ROB5",
397  "S6 MB4 ROB5",
398  "S7 MB4 ROB5",
399  "S8 MB4 ROB5",
400  "S10 MB4 ROB3",
401  "S10 MB4 ROB2",
402  "S14 MB4 ROB3",
403  "S12 MB4 ROB5"};
404  histo->setBinLabel(link25 + 1, label25[ros - 1], 2);
405 
406  if (mode > 1)
407  return;
408 
409  histoType = "TDCError";
410  linkDown = 0;
411  linkDown_s = to_string(linkDown);
412  linkUp = linkDown + 24;
413  linkUp_s = to_string(linkUp);
414  histoName = "W" + wheel_s + "_" + "Sector" + ros_s + "_" + histoType;
415  histoTitle = histoName + " (Channel " + linkDown_s + "-" + linkUp_s + " error summary)";
416  keyHisto = (TDCError)*1000 + (wheel + 2) * 100 + (ros - 1);
417  urosHistos[keyHisto] = ibooker.book2D(histoName, histoTitle, 24, 0, 24, 25, 0, 25);
419  // TDC error bins
420  histo->setBinLabel(1, "Fatal", 1);
421  histo->setBinLabel(2, "RO FIFO ov.", 1);
422  histo->setBinLabel(3, "L1 buf. ov.", 1);
423  histo->setBinLabel(4, "L1A FIFO ov.", 1);
424  histo->setBinLabel(5, "hit err.", 1);
425  histo->setBinLabel(6, "hit rej.", 1);
426  histo->setBinLabel(7, "Fatal", 1);
427  histo->setBinLabel(8, "RO FIFO ov.", 1);
428  histo->setBinLabel(9, "L1 buf. ov.", 1);
429  histo->setBinLabel(10, "L1A FIFO ov.", 1);
430  histo->setBinLabel(11, "hit err.", 1);
431  histo->setBinLabel(12, "hit rej.", 1);
432  histo->setBinLabel(13, "Fatal", 1);
433  histo->setBinLabel(14, "RO FIFO ov.", 1);
434  histo->setBinLabel(15, "L1 buf. ov.", 1);
435  histo->setBinLabel(16, "L1A FIFO ov.", 1);
436  histo->setBinLabel(17, "hit err.", 1);
437  histo->setBinLabel(18, "hit rej.", 1);
438  histo->setBinLabel(19, "Fatal", 1);
439  histo->setBinLabel(20, "RO FIFO ov.", 1);
440  histo->setBinLabel(21, "L1 buf. ov.", 1);
441  histo->setBinLabel(22, "L1A FIFO ov.", 1);
442  histo->setBinLabel(23, "hit err.", 1);
443  histo->setBinLabel(24, "hit rej.", 1);
444 
445  for (int link = linkDown; link < linkUp; ++link) {
446  int sector = ros;
447 
448  int station = int(link / 6) + 1;
449  if (link == 18)
450  station = 3;
451 
452  int rob = link % 6;
453  if (link == 18)
454  rob = 6;
455  else if (link > 18)
456  rob = rob - 1;
457 
458  //Sector 4 exceptions
459  if (ros == 4) {
460  if (link > 18 && link < 22)
461  rob = rob + 2;
462  else if (link == 22 || link == 23) {
463  sector = 13;
464  rob = rob - 1;
465  }
466  }
467 
468  //Sector 9 exceptions
469  if (ros == 9 && (link == 22 || link == 23))
470  rob = rob - 3;
471 
472  //Sector 10 exceptions
473  if (ros == 10) {
474  if (link > 18 && link < 22)
475  sector = 14;
476  else if (link == 22 || link == 23)
477  rob = rob - 3;
478  }
479 
480  //Sector 11 exceptions
481  if (ros == 11 && (link == 22 || link == 23)) {
482  sector = 4;
483  rob = rob - 3;
484  }
485 
486  string sector_s = to_string(sector);
487  string st_s = to_string(station);
488  string rob_s = to_string(rob);
489  histo->setBinLabel(link + 1, "S" + sector_s + " MB" + st_s + " ROB" + rob_s, 2);
490  }
491 
492  link25 = linkUp;
493  histo->setBinLabel(link25 + 1, label25[ros - 1], 2);
494 
495 } //bookHistosROS
496 
497 void DTDataIntegrityTask::bookHistosuROS(DQMStore::IBooker& ibooker, const int fed, const int uRos) {
498  string fed_s = to_string(fed);
499  string uRos_s = to_string(uRos);
500  ibooker.setCurrentFolder(topFolder(false) + "FED" + fed_s + "/uROS" + uRos_s);
501 
502  if (mode >= 1)
503  return;
504 
505  string histoType = "uROSEventLength";
506  string histoName = "FED" + fed_s + "_uROS" + uRos_s + "_" + "EventLength";
507  string histoTitle = "Event Length (Bytes) FED " + fed_s + " uROS" + uRos_s;
508  unsigned int keyHisto = (uROSEventLength)*1000 + (fed - FEDIDmin) * 100 + (uRos - 1);
509  urosHistos[keyHisto] = ibooker.book1D(histoName, histoTitle, 101, 0, 5000);
510 
511  histoType = "uROSAvgEventLengthvsLumi";
512  histoName = "FED" + fed_s + "_ROS" + uRos_s + "AvgEventLengthvsLumi";
513  histoTitle = "Event Length (Bytes) FED " + fed_s + " ROS" + uRos_s;
514  keyHisto = (fed - FEDIDmin) * 100 + (uRos - 1);
515  urosTimeHistos[keyHisto] = new DTTimeEvolutionHisto(ibooker, histoName, histoTitle, 200, 10, true, 0);
516 
517  histoType = "TTSValues";
518  histoName = "FED" + fed_s + "_" + "uROS" + uRos_s + "_" + histoType;
519  keyHisto = TTSValues * 1000 + (fed - FEDIDmin) * 100 + (uRos - 1);
520  urosHistos[keyHisto] = ibooker.book1D(histoName, histoName, 4, 1, 5);
522  histo->setBinLabel(1, "Overflow Warning ", 1);
523  histo->setBinLabel(2, "Busy", 1);
524  histo->setBinLabel(3, "Ready", 1);
525  histo->setBinLabel(4, "Unknown", 1);
526 }
527 
529  neventsuROS++;
530 
531  LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
532  << "[DTDataIntegrityTask]: " << neventsuROS << " events analyzed by processuROS" << endl;
533 
534  if (mode == 3) // || mode == 1)
535  return; //Avoid duplication of Info in FEDIntegrity_EvF
536 
537  MonitorElement* uROSSummary = nullptr;
538  MonitorElement* uROSStatus = nullptr;
539 
540  unsigned int slotMap = (data.getboardId()) & 0xF;
541  if (slotMap == 0)
542  return; //prevention for Simulation empty uROS data
543  unsigned int ros = theROS(slotMap, 0); //first sector correspondign to link 0
544  int ddu = theDDU(fed, slotMap, 0, false);
545  int wheel = (ddu - 770) % 5 - 2;
546  int sector4 = 3; //Asymmetry in mapping
547 
548  MonitorElement* ROSSummary = nullptr;
549  ROSSummary = summaryHistos["ROSSummary"][wheel];
550 
551  // Summary of all Link errors
552  MonitorElement* uROSError0 = nullptr;
553  MonitorElement* uROSError1 = nullptr;
554  MonitorElement* uROSError2 = nullptr;
555  MonitorElement* uROSErrorS4 = nullptr;
556 
557  if (mode <= 2) {
558  if (uRos > 2) { //sectors 1-12
559  if (mode != 1) {
560  uROSSummary = summaryHistos["uROSSummary"][fed];
561  uROSStatus = fedHistos["uROSStatus"][fed];
562  if (!uROSSummary) {
563  LogError("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
564  << "Trying to access non existing ME at FED " << fed << std::endl;
565  return;
566  }
567 
568  uROSError0 = urosHistos[(uROSError)*1000 + (wheel + 2) * 100 + (ros - 1)]; //links 0-23
569  uROSError1 = urosHistos[(uROSError)*1000 + (wheel + 2) * 100 + (ros)]; //links 24-47
570  uROSError2 = urosHistos[(uROSError)*1000 + (wheel + 2) * 100 + (ros + 1)]; //links 48-71
571  uROSErrorS4 = urosHistos[(uROSError)*1000 + (wheel + 2) * 100 + 3];
572 
573  if ((!uROSError2) || (!uROSError1) || (!uROSError0)) {
574  LogError("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
575  << "Trying to access non existing ME at uROS " << uRos << std::endl;
576  return;
577  }
578  }
579 
580  // uROS errors
581  for (unsigned int link = 0; link < 72; ++link) {
582  for (unsigned int flag = 0; flag < 5; ++flag) {
583  if ((data.getokxflag(link) >> flag) & 0x1) { // Undefined Flag 1-4 64bits word for each MTP (12 channels)
584  int value = flag;
585 
586  if (flag == 0)
587  value = 5; //move it to the 5th bin
588 
589  if (value > 0) {
590  if (link < 24) {
591  errorX[value - 1][ros - 1][wheel + 2] += 1;
592  if (mode != 1)
593  uROSError0->Fill(value - 1, link); //bins start at 0 despite labeling
594  } else if (link < 48) {
595  if ((link == 46 || link == 57) && ros == 10)
596  errorX[value - 1][sector4][wheel + 2] += 1;
597  else
598  errorX[value - 1][ros][wheel + 2] += 1;
599  if (mode != 1) {
600  if ((link == 46 || link == 57) && ros == 10)
601  uROSErrorS4->Fill(value - 1, link - 24);
602  else
603  uROSError1->Fill(value - 1, link - 24);
604  }
605  } else if (link < 72) {
606  errorX[value - 1][ros + 1][wheel + 2] += 1;
607  if (mode != 1)
608  uROSError2->Fill(value - 1, link - 48);
609  }
610  } //value>0
611  } //flag value
612  } //loop on flags
613  } //loop on links
614  } //uROS>2
615 
616  else { //uRos<3 25th Channel slot
617 
618  for (unsigned int link = 0; link < 12; ++link) {
619  for (unsigned int flag = 0; flag < 5; ++flag) {
620  if ((data.getokxflag(link) >> flag) & 0x1) { // Undefined Flag 1-4 64bits word for each MTP (12 channels)
621  int value = flag;
622  int ch25 = 24;
623  int sector = link + 1;
624  if (flag == 0)
625  value = 5; //move it to the 5th bin
626 
627  if (value > 0) {
628  if (mode != 1) {
629  if (sector == 9)
630  sector = 10;
631  unsigned int keyHisto =
632  (uROSError)*1000 + (wheel + 2) * 100 + abs(sector - 1); //ros -1 = link in this case
633  uROSError0 = urosHistos[keyHisto];
634  if (!uROSError0) {
635  LogError("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
636  << "Trying to access non existing ME at uROS " << uRos << std::endl;
637  return;
638  }
639  }
640  errorX[value - 1][sector - 1][wheel + 2] += 1; // ros-1=link in this case
641  if (mode != 1)
642  uROSError0->Fill(value - 1, ch25); //bins start at 0 despite labeling, this is the old SC
643  }
644  } //flag values
645  } //loop on flags
646  } //loop on links
647  } //else uRos<3
648 
649  } //mode<=2
650 
651  if (mode != 1) {
652  // Fill the ROSSummary (1 per wheel) histo
653  for (unsigned int iros = ros - 1; iros < (ros + 2); ++iros) {
654  for (unsigned int bin = 0; bin < 5; ++bin) {
655  if (errorX[bin][iros][wheel + 2] != 0) {
656  ROSSummary->Fill(bin, iros + 1, errorX[bin][iros][wheel + 2]); //bins start at 1
657  }
658  }
659  }
660 
661  // Global Errors for uROS
662  for (unsigned int flag = 4; flag < 16; ++flag) {
663  if ((data.getuserWord() >> flag) & 0x1) {
664  uROSSummary->Fill(flag - 4, uRos);
665  uROSStatus->Fill(flag - 4, uRos); //duplicated info?
666  }
667  }
668  }
669 
670  // ROS error
671  for (unsigned int icounter = 0; icounter < data.geterrors().size(); ++icounter) {
672  int link = data.geterrorROBID(icounter);
673  int tdc = data.geterrorTDCID(icounter);
674  int error = data.geterror(icounter);
675  int tdcError_ROSSummary = 0;
676  int tdcError_ROSError = 0;
677  int tdcError_TDCHisto = 0;
678 
679  if (error & 0x4000) {
680  LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
681  << " ROS " << uRos << " ROB " << link << " Internal fatal Error 4000 in TDC " << error << endl;
682 
683  tdcError_ROSSummary = 5;
684  tdcError_ROSError = 5;
685  tdcError_TDCHisto = 0;
686 
687  } else if (error & 0x0249) {
688  LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
689  << " ROS " << uRos << " ROB " << link << " TDC FIFO overflow in TDC " << error << endl;
690 
691  tdcError_ROSSummary = 6;
692  tdcError_ROSError = 6;
693  tdcError_TDCHisto = 1;
694 
695  } else if (error & 0x0492) {
696  LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
697  << " ROS " << uRos << " ROB " << link << " TDC L1 buffer overflow in TDC " << error << endl;
698 
699  tdcError_ROSSummary = 7;
700  tdcError_ROSError = 7;
701  tdcError_TDCHisto = 2;
702 
703  } else if (error & 0x2000) {
704  LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
705  << " ROS " << uRos << " ROB " << link << " TDC L1A FIFO overflow in TDC " << error << endl;
706 
707  tdcError_ROSSummary = 8;
708  tdcError_ROSError = 8;
709  tdcError_TDCHisto = 3;
710 
711  } else if (error & 0x0924) {
712  LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
713  << " uROS " << uRos << " ROB " << link << " TDC hit error in TDC " << error << endl;
714 
715  tdcError_ROSSummary = 9;
716  tdcError_ROSError = 9;
717  tdcError_TDCHisto = 4;
718 
719  } else if (error & 0x1000) {
720  LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
721  << " uROS " << uRos << " ROB " << link << " TDC hit rejected in TDC " << error << endl;
722 
723  tdcError_ROSSummary = 10;
724  tdcError_ROSError = 10;
725  tdcError_TDCHisto = 5;
726 
727  } else {
728  LogWarning("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
729  << " TDC error code not known " << error << endl;
730  }
731 
732  if (uRos < 3) {
733  int sector = link + 1;
734  if (tdcError_ROSSummary == 5)
735  errorX[5][link][wheel + 2] += 1;
736  if (mode != 1) {
737  if (sector == 9)
738  sector = 10;
739  ROSSummary->Fill(tdcError_ROSSummary, sector - 1); //link 0 = ROS 1
740  int ch25 = 24;
741  if (mode <= 2) {
742  urosHistos[(uROSError)*1000 + (wheel + 2) * 100 + (sector - 1)]->Fill(tdcError_ROSError, ch25);
743  if (mode < 1)
744  urosHistos[(TDCError)*1000 + (wheel + 2) * 100 + (sector - 1)]->Fill(tdcError_TDCHisto + 6 * tdc,
745  ch25); // ros-1=link in this case
746  } //mode <= 2
747  } //mode!=1
748  } //uRos<3
749  else { //uRos>2
750  if (link < 24) {
751  if (tdcError_ROSSummary == 5)
752  errorX[5][ros - 1][wheel + 2] += 1;
753  if (mode != 1)
754  ROSSummary->Fill(tdcError_ROSSummary, ros);
755  } else if (link < 48) {
756  if (tdcError_ROSSummary == 5) {
757  if ((link == 46 || link == 57) && ros == 10)
758  errorX[5][sector4][wheel + 2] += 1;
759  else
760  errorX[5][ros][wheel + 2] += 1;
761  }
762  if (mode != 1) {
763  if ((link == 46 || link == 57) && ros == 10)
764  ROSSummary->Fill(tdcError_ROSSummary, sector4);
765  else
766  ROSSummary->Fill(tdcError_ROSSummary, ros + 1);
767  }
768  } else if (link < 72) {
769  if (tdcError_ROSSummary == 5)
770  errorX[5][ros + 1][wheel + 2] += 1;
771  if (mode != 1)
772  ROSSummary->Fill(tdcError_ROSSummary, ros + 2);
773  }
774 
775  if (mode <= 2 && mode != 1) {
776  if (link < 24)
777  uROSError0->Fill(tdcError_ROSError, link);
778  else if (link < 48)
779  if ((link == 46 || link == 57) && ros == 10)
780  uROSError1->Fill(tdcError_ROSError, sector4);
781  else
782  uROSError1->Fill(tdcError_ROSError, link - 24);
783  else if (link < 72)
784  uROSError2->Fill(tdcError_ROSError, link - 48);
785 
786  if (mode < 1) {
787  if (link < 24)
788  urosHistos[(TDCError)*1000 + (wheel + 2) * 100 + (ros - 1)]->Fill(tdcError_TDCHisto + 6 * tdc, link);
789  else if (link < 48)
790  urosHistos[(TDCError)*1000 + (wheel + 2) * 100 + (ros)]->Fill(tdcError_TDCHisto + 6 * tdc, link - 24);
791  else if (link < 72)
792  urosHistos[(TDCError)*1000 + (wheel + 2) * 100 + (ros + 1)]->Fill(tdcError_TDCHisto + 6 * tdc, link - 48);
793 
794  } //mode<1
795  } //mode<=2 && mode != 1
796  } //uROS>2
797  } //loop on errors
798 
799  // 1D histograms for TTS values per uROS
800  if (mode < 1) {
801  int ttsCodeValue = -1;
802  int value = (data.getuserWord() & 0xF);
803  switch (value) {
804  case 1: { //warning overflow
805  ttsCodeValue = 1;
806  break;
807  }
808  case 4: { //busy
809  ttsCodeValue = 2;
810  break;
811  }
812  case 8: { //ready
813  ttsCodeValue = 3;
814  break;
815  }
816  default: {
817  LogError("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
818  << "[DTDataIntegrityTask] FED User control: wrong TTS value " << value << " in FED " << fed << " uROS "
819  << uRos << endl;
820  ttsCodeValue = 4;
821  }
822  }
823 
824  urosHistos[TTSValues * 1000 + (fed - FEDIDmin) * 100 + (uRos - 1)]->Fill(ttsCodeValue);
825 
826  // Plot the event length //NOHLT
827  int uRosEventLength = (data.gettrailer() & 0xFFFFF) * 8;
828  urosTimeHistos[(fed - FEDIDmin) * 100 + (uRos - 1)]->accumulateValueTimeSlot(uRosEventLength);
829 
830  if (uRosEventLength > 5000)
831  uRosEventLength = 5000;
832  urosHistos[uROSEventLength * 1000 + (fed - FEDIDmin) * 100 + (uRos - 1)]->Fill(uRosEventLength);
833  }
834 }
835 
837  neventsFED++;
838  if (neventsFED % 1000 == 0)
839  LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
840  << "[DTDataIntegrityTask]: " << neventsFED << " events analyzed by processFED" << endl;
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  nEventsLS = 0;
947  return std::shared_ptr<dtdi::Void>();
948 }
949 
951  int lumiBlock = ls.id().luminosityBlock();
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  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 
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 }
1049 
1050 // Local Variables:
1051 // show-trailing-whitespace: t
1052 // truncate-lines: t
1053 // End:
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)
std::string to_string(const V &value)
Definition: OMSAccess.h:77
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
#define LogTrace(id)
static const int DOCESLOTS
T getUntrackedParameter(std::string const &, T const &) const
std::shared_ptr< dtdi::Void > globalBeginLuminosityBlock(const edm::LuminosityBlock &ls, const edm::EventSetup &es) const override
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)
HLT enums.
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
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