CMS 3D CMS Logo

DTDataIntegrityROSOffline.cc
Go to the documentation of this file.
1 /*
2  * \file DTDataIntegrityROSOffline.cc
3  *
4  * \author M. Zanetti (INFN Padova), S. Bolognesi (INFN Torino), G. Cerminara (INFN Torino)
5  *
6  */
7 
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  LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityROSOffline")
31  << "[DTDataIntegrityROSOffline]: Constructor" << endl;
32 
33  dduToken = consumes<DTDDUCollection>(ps.getParameter<InputTag>("dtDDULabel"));
34  ros25Token = consumes<DTROS25Collection>(ps.getParameter<InputTag>("dtROS25Label"));
37 
38  neventsFED = 0;
39 
40  // Plot quantities about SC
41  getSCInfo = ps.getUntrackedParameter<bool>("getSCInfo", false);
42 
43  fedIntegrityFolder = ps.getUntrackedParameter<string>("fedIntegrityFolder", "DT/FEDIntegrity");
44 }
45 
47  LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityROSOffline")
48  << "[DTDataIntegrityROSOffline]: Destructor. Analyzed " << neventsFED << " events" << endl;
49  LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityROSOffline")
50  << "[DTDataIntegrityROSOffline]: postEndJob called!" << endl;
51 }
52 
53 /*
54  Folder Structure (ROS Legacy):
55  - One folder for each DDU, named FEDn
56  - Inside each DDU folder the DDU histos and the ROSn folder
57  - Inside each ROS folder the ROS histos and the ROBn folder
58  - Inside each ROB folder one occupancy plot and the TimeBoxes
59  with the chosen granularity (simply change the histo name)
60 */
61 
63  edm::Run const& iRun,
64  edm::EventSetup const& iSetup) {
65  LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityROSOffline")
66  << "[DTDataIntegrityROSOffline]: postBeginJob" << endl;
67 
68  LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityROSOffline")
69  << "[DTDataIntegrityROSOffline] Get DQMStore service" << endl;
70 
71  // Loop over the DT FEDs
72 
73  LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityROSOffline")
74  << " FEDS: " << FEDIDmin << " to " << FEDIDmax << " in the RO" << endl;
75 
76  // book FED integrity histos
77  bookHistos(ibooker, FEDIDmin, FEDIDmax);
78 
79  //Legacy ROS
80 
81  // static booking of the histograms
82 
83  for (int fed = FEDIDmin; fed <= FEDIDmax; ++fed) { // loop over the FEDs in the readout
84  DTROChainCoding code;
85  code.setDDU(fed);
86  bookHistos(ibooker, string("ROS_S"), code);
87 
88  bookHistos(ibooker, string("DDU"), code);
89 
90  for (int ros = 1; ros <= nROS; ++ros) { // loop over all ROS
91  code.setROS(ros);
92  bookHistosROS25(ibooker, code);
93  }
94  }
95 }
96 
97 void DTDataIntegrityROSOffline::bookHistos(DQMStore::IBooker& ibooker, const int fedMin, const int fedMax) {
98  ibooker.setCurrentFolder("DT/EventInfo/Counters");
99  nEventMonitor = ibooker.bookFloat("nProcessedEventsDataIntegrity");
100 
101  // Standard FED integrity histos
102  ibooker.setCurrentFolder(topFolder(true));
103 
104  int nFED = (fedMax - fedMin) + 1;
105 
106  hFEDEntry = ibooker.book1D("FEDEntries", "# entries per DT FED", nFED, fedMin, fedMax + 1);
107 
108  hFEDFatal = ibooker.book1D("FEDFatal", "# fatal errors DT FED", nFED, fedMin, fedMax + 1);
109  hFEDNonFatal = ibooker.book1D("FEDNonFatal", "# NON fatal errors DT FED", nFED, fedMin, fedMax + 1);
110 
111  ibooker.setCurrentFolder(topFolder(false));
112  hTTSSummary = ibooker.book2D("TTSSummary", "Summary Status TTS", nFED, fedMin, fedMax + 1, 9, 1, 10);
113  hTTSSummary->setAxisTitle("FED", 1);
114  hTTSSummary->setBinLabel(1, "ROS PAF", 2);
115  hTTSSummary->setBinLabel(2, "DDU PAF", 2);
116  hTTSSummary->setBinLabel(3, "ROS PAF", 2);
117  hTTSSummary->setBinLabel(4, "DDU PAF", 2);
118  hTTSSummary->setBinLabel(5, "DDU Full", 2);
119  hTTSSummary->setBinLabel(6, "L1A Mism.", 2);
120  hTTSSummary->setBinLabel(7, "ROS Error", 2);
121  hTTSSummary->setBinLabel(8, "BX Mism.", 2);
122  hTTSSummary->setBinLabel(9, "DDU Logic Err.", 2);
123 
124  // bookkeeping of the histos
126  ibooker.book2D("DataCorruptionSummary", "Data Corruption Sources", nFED, fedMin, fedMax + 1, 8, 1, 9);
127  hCorruptionSummary->setAxisTitle("FED", 1);
128  hCorruptionSummary->setBinLabel(1, "Miss Ch.", 2);
129  hCorruptionSummary->setBinLabel(2, "ROS BX mism", 2);
130  hCorruptionSummary->setBinLabel(3, "DDU BX mism", 2);
131  hCorruptionSummary->setBinLabel(4, "ROS L1A mism", 2);
132  hCorruptionSummary->setBinLabel(5, "Miss Payload", 2);
133  hCorruptionSummary->setBinLabel(6, "FCRC bit", 2);
134  hCorruptionSummary->setBinLabel(7, "Header check", 2);
135  hCorruptionSummary->setBinLabel(8, "Trailer Check", 2);
136 }
137 
139  string dduID_s = to_string(code.getDDU());
140  string rosID_s = to_string(code.getROS());
141  string robID_s = to_string(code.getROB());
142  int wheel = (code.getDDUID() - 770) % 5 - 2;
143  string wheel_s = to_string(wheel);
144 
145  LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityROSOffline")
146  << " Booking histos for FED: " << code.getDDU() << " ROS: " << code.getROS() << " ROB: " << code.getROB()
147  << " folder: " << folder << endl;
148 
149  string histoType;
150  string histoName;
151  string histoTitle;
152  MonitorElement* histo = nullptr;
153 
154  // DDU Histograms
155  if (folder == "DDU") {
156  ibooker.setCurrentFolder(topFolder(false) + "FED" + dduID_s);
157 
158  histoType = "EventLength";
159  histoName = "FED" + dduID_s + "_" + histoType;
160  histoTitle = "Event Length (Bytes) FED " + dduID_s;
161  (fedHistos[histoType])[code.getDDUID()] = ibooker.book1D(histoName, histoTitle, 501, 0, 16032);
162 
163  histoType = "ROSStatus";
164  histoName = "FED" + dduID_s + "_" + histoType;
165  (fedHistos[histoType])[code.getDDUID()] = ibooker.book2D(histoName, histoName, 12, 0, 12, 12, 0, 12);
166  histo = (fedHistos[histoType])[code.getDDUID()];
167  histo->setBinLabel(1, "ch.enabled", 1);
168  histo->setBinLabel(2, "timeout", 1);
169  histo->setBinLabel(3, "ev.trailer lost", 1);
170  histo->setBinLabel(4, "opt.fiber lost", 1);
171  histo->setBinLabel(5, "tlk.prop.error", 1);
172  histo->setBinLabel(6, "tlk.pattern error", 1);
173  histo->setBinLabel(7, "tlk.sign.lost", 1);
174  histo->setBinLabel(8, "error from ROS", 1);
175  histo->setBinLabel(9, "if ROS in events", 1);
176  histo->setBinLabel(10, "Miss. Evt.", 1);
177  histo->setBinLabel(11, "Evt. ID Mismatch", 1);
178  histo->setBinLabel(12, "BX Mismatch", 1);
179 
180  histo->setBinLabel(1, "ROS 1", 2);
181  histo->setBinLabel(2, "ROS 2", 2);
182  histo->setBinLabel(3, "ROS 3", 2);
183  histo->setBinLabel(4, "ROS 4", 2);
184  histo->setBinLabel(5, "ROS 5", 2);
185  histo->setBinLabel(6, "ROS 6", 2);
186  histo->setBinLabel(7, "ROS 7", 2);
187  histo->setBinLabel(8, "ROS 8", 2);
188  histo->setBinLabel(9, "ROS 9", 2);
189  histo->setBinLabel(10, "ROS 10", 2);
190  histo->setBinLabel(11, "ROS 11", 2);
191  histo->setBinLabel(12, "ROS 12", 2);
192  }
193 
194  // ROS Histograms
195  if (folder == "ROS_S") { // The summary of the error of the ROS on the same FED
196  ibooker.setCurrentFolder(topFolder(false));
197 
198  histoType = "ROSSummary";
199  histoName = "FED" + dduID_s + "_ROSSummary";
200  string histoTitle = "Summary Wheel" + wheel_s + " (FED " + dduID_s + ")";
201 
202  ((summaryHistos[histoType])[code.getDDUID()]) = ibooker.book2D(histoName, histoTitle, 20, 0, 20, 12, 1, 13);
203  MonitorElement* histo = ((summaryHistos[histoType])[code.getDDUID()]);
204  // ROS error bins
205  histo->setBinLabel(1, "Link TimeOut", 1);
206  histo->setBinLabel(2, "Ev.Id.Mis.", 1);
207  histo->setBinLabel(3, "FIFO almost full", 1);
208  histo->setBinLabel(4, "FIFO full", 1);
209  histo->setBinLabel(5, "CEROS timeout", 1);
210  histo->setBinLabel(6, "Max. wds", 1);
211  histo->setBinLabel(7, "WO L1A FIFO", 1);
212  histo->setBinLabel(8, "TDC parity err.", 1);
213  histo->setBinLabel(9, "BX ID Mis.", 1);
214  histo->setBinLabel(10, "TXP", 1);
215  histo->setBinLabel(11, "L1A almost full", 1);
216  histo->setBinLabel(12, "Ch. blocked", 1);
217  histo->setBinLabel(13, "Ev. Id. Mis.", 1);
218  histo->setBinLabel(14, "CEROS blocked", 1);
219  // TDC error bins
220  histo->setBinLabel(15, "TDC Fatal", 1);
221  histo->setBinLabel(16, "TDC RO FIFO ov.", 1);
222  histo->setBinLabel(17, "TDC L1 buf. ov.", 1);
223  histo->setBinLabel(18, "TDC L1A FIFO ov.", 1);
224  histo->setBinLabel(19, "TDC hit err.", 1);
225  histo->setBinLabel(20, "TDC hit rej.", 1);
226 
227  histo->setBinLabel(1, "ROS1", 2);
228  histo->setBinLabel(2, "ROS2", 2);
229  histo->setBinLabel(3, "ROS3", 2);
230  histo->setBinLabel(4, "ROS4", 2);
231  histo->setBinLabel(5, "ROS5", 2);
232  histo->setBinLabel(6, "ROS6", 2);
233  histo->setBinLabel(7, "ROS7", 2);
234  histo->setBinLabel(8, "ROS8", 2);
235  histo->setBinLabel(9, "ROS9", 2);
236  histo->setBinLabel(10, "ROS10", 2);
237  histo->setBinLabel(11, "ROS11", 2);
238  histo->setBinLabel(12, "ROS12", 2);
239  }
240 
241  if (folder == "ROS") {
242  ibooker.setCurrentFolder(topFolder(false) + "FED" + dduID_s + "/" + folder + rosID_s);
243 
244  histoType = "ROSError";
245  histoName = "FED" + dduID_s + "_" + folder + rosID_s + "_ROSError";
246  histoTitle = histoName + " (ROBID error summary)";
247  (rosHistos[histoType])[code.getROSID()] = ibooker.book2D(histoName, histoTitle, 11, 0, 11, 26, 0, 26);
248 
249  MonitorElement* histo = (rosHistos[histoType])[code.getROSID()];
250  // ROS error bins
251  histo->setBinLabel(1, "Link TimeOut", 1);
252  histo->setBinLabel(2, "Ev.Id.Mis.", 1);
253  histo->setBinLabel(3, "FIFO almost full", 1);
254  histo->setBinLabel(4, "FIFO full", 1);
255  histo->setBinLabel(5, "CEROS timeout", 1);
256  histo->setBinLabel(6, "Max. wds", 1);
257  histo->setBinLabel(7, "TDC parity err.", 1);
258  histo->setBinLabel(8, "BX ID Mis.", 1);
259  histo->setBinLabel(9, "Ch. blocked", 1);
260  histo->setBinLabel(10, "Ev. Id. Mis.", 1);
261  histo->setBinLabel(11, "CEROS blocked", 1);
262 
263  histo->setBinLabel(1, "ROB0", 2);
264  histo->setBinLabel(2, "ROB1", 2);
265  histo->setBinLabel(3, "ROB2", 2);
266  histo->setBinLabel(4, "ROB3", 2);
267  histo->setBinLabel(5, "ROB4", 2);
268  histo->setBinLabel(6, "ROB5", 2);
269  histo->setBinLabel(7, "ROB6", 2);
270  histo->setBinLabel(8, "ROB7", 2);
271  histo->setBinLabel(9, "ROB8", 2);
272  histo->setBinLabel(10, "ROB9", 2);
273  histo->setBinLabel(11, "ROB10", 2);
274  histo->setBinLabel(12, "ROB11", 2);
275  histo->setBinLabel(13, "ROB12", 2);
276  histo->setBinLabel(14, "ROB13", 2);
277  histo->setBinLabel(15, "ROB14", 2);
278  histo->setBinLabel(16, "ROB15", 2);
279  histo->setBinLabel(17, "ROB16", 2);
280  histo->setBinLabel(18, "ROB17", 2);
281  histo->setBinLabel(19, "ROB18", 2);
282  histo->setBinLabel(20, "ROB19", 2);
283  histo->setBinLabel(21, "ROB20", 2);
284  histo->setBinLabel(22, "ROB21", 2);
285  histo->setBinLabel(23, "ROB22", 2);
286  histo->setBinLabel(24, "ROB23", 2);
287  histo->setBinLabel(25, "ROB24", 2);
288  histo->setBinLabel(26, "SC", 2);
289  }
290 
291  // SC Histograms
292  if (folder == "SC") {
293  // The plots are per wheel
294  ibooker.setCurrentFolder(topFolder(false) + "FED" + dduID_s);
295 
296  // SC data Size
297  histoType = "SCSizeVsROSSize";
298  histoName = "FED" + dduID_s + "_SCSizeVsROSSize";
299  histoTitle = "SC size vs SC (FED " + dduID_s + ")";
300  rosHistos[histoType][code.getSCID()] = ibooker.book2D(histoName, histoTitle, 12, 1, 13, 51, -1, 50);
301  rosHistos[histoType][code.getSCID()]->setAxisTitle("SC", 1);
302  }
303 }
304 
306  bookHistos(ibooker, string("ROS"), code);
307 }
308 
310  neventsROS++;
311 
312  LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityROSOffline")
313  << "[DTDataIntegrityROSOffline]: " << neventsROS << " events analyzed by processROS25" << endl;
314 
315  // The ID of the RO board (used to map the histos)
316  DTROChainCoding code;
317  code.setDDU(ddu);
318  code.setROS(ros);
319 
320  MonitorElement* ROSSummary = summaryHistos["ROSSummary"][code.getDDUID()];
321 
322  // Summary of all ROB errors
323  MonitorElement* ROSError = nullptr;
324  ROSError = rosHistos["ROSError"][code.getROSID()];
325 
326  if ((!ROSError)) {
327  LogError("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityROSOffline")
328  << "Trying to access non existing ME at ROSID " << code.getROSID() << std::endl;
329  return;
330  }
331 
332  // L1A ids to be checked against FED one
333  rosL1AIdsPerFED[ddu].insert(data.getROSHeader().TTCEventCounter());
334 
335  // ROS errors
336 
337  // check for TPX errors
338  if (data.getROSTrailer().TPX() != 0) {
339  LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityROSOffline")
340  << " TXP error en ROS " << code.getROS() << endl;
341  ROSSummary->Fill(9, code.getROS());
342  }
343 
344  // L1 Buffer almost full (non-critical error!)
345  if (data.getROSTrailer().l1AFifoOccupancy() > 31) {
346  ROSSummary->Fill(10, code.getROS());
347  }
348 
349  for (vector<DTROSErrorWord>::const_iterator error_it = data.getROSErrors().begin();
350  error_it != data.getROSErrors().end();
351  error_it++) { // Loop over ROS error words
352 
353  LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityROSOffline")
354  << " Error in ROS " << code.getROS() << " ROB Id " << (*error_it).robID() << " Error type "
355  << (*error_it).errorType() << endl;
356 
357  // Fill the ROSSummary (1 per FED) histo
358  ROSSummary->Fill((*error_it).errorType(), code.getROS());
359  if ((*error_it).errorType() <= 11) { // set error flag
360  eventErrorFlag = true;
361  }
362 
363  // Fill the ROB Summary (1 per ROS) histo
364  if ((*error_it).robID() != 31) {
365  ROSError->Fill((*error_it).errorType(), (*error_it).robID());
366  } else if ((*error_it).errorType() == 4) {
367  vector<int> channelBins;
368  channelsInROS((*error_it).cerosID(), channelBins);
369  vector<int>::const_iterator channelIt = channelBins.begin();
370  vector<int>::const_iterator channelEnd = channelBins.end();
371  for (; channelIt != channelEnd; ++channelIt) {
372  ROSError->Fill(4, (*channelIt));
373  }
374  }
375  }
376 
377  int ROSDebug_BunchNumber = -1;
378 
379  for (vector<DTROSDebugWord>::const_iterator debug_it = data.getROSDebugs().begin();
380  debug_it != data.getROSDebugs().end();
381  debug_it++) { // Loop over ROS debug words
382 
383  int debugROSSummary = 0;
384  int debugROSError = 0;
385  vector<int> debugBins;
386  bool hasEvIdMis = false;
387  vector<int> evIdMisBins;
388 
389  if ((*debug_it).debugType() == 0) {
390  ROSDebug_BunchNumber = (*debug_it).debugMessage();
391  } else if ((*debug_it).debugType() == 1) {
392  // not used
393  // ROSDebug_BcntResCntLow = (*debug_it).debugMessage();
394  } else if ((*debug_it).debugType() == 2) {
395  // not used
396  // ROSDebug_BcntResCntHigh = (*debug_it).debugMessage();
397  } else if ((*debug_it).debugType() == 3) {
398  if ((*debug_it).dontRead()) {
399  debugROSSummary = 11;
400  debugROSError = 8;
401  channelsInCEROS((*debug_it).cerosIdCerosStatus(), (*debug_it).dontRead(), debugBins);
402  }
403  if ((*debug_it).evIdMis()) {
404  hasEvIdMis = true;
405  channelsInCEROS((*debug_it).cerosIdCerosStatus(), (*debug_it).evIdMis(), evIdMisBins);
406  }
407  } else if ((*debug_it).debugType() == 4 && (*debug_it).cerosIdRosStatus()) {
408  debugROSSummary = 13;
409  debugROSError = 10;
410  channelsInROS((*debug_it).cerosIdRosStatus(), debugBins);
411  }
412 
413  if (debugROSSummary) {
414  ROSSummary->Fill(debugROSSummary, code.getROS());
415  vector<int>::const_iterator channelIt = debugBins.begin();
416  vector<int>::const_iterator channelEnd = debugBins.end();
417  for (; channelIt != channelEnd; ++channelIt) {
418  ROSError->Fill(debugROSError, (*channelIt));
419  }
420  }
421 
422  if (hasEvIdMis) {
423  ROSSummary->Fill(12, code.getROS());
424  vector<int>::const_iterator channelIt = evIdMisBins.begin();
425  vector<int>::const_iterator channelEnd = evIdMisBins.end();
426  for (; channelIt != channelEnd; ++channelIt) {
427  ROSError->Fill(9, (*channelIt));
428  }
429  }
430  }
431 
432  // ROB Group Header
433  // Check the BX of the ROB headers against the BX of the ROS
434  for (vector<DTROBHeader>::const_iterator rob_it = data.getROBHeaders().begin(); rob_it != data.getROBHeaders().end();
435  rob_it++) { // loop over ROB headers
436 
437  code.setROB((*rob_it).first);
438  DTROBHeaderWord robheader = (*rob_it).second;
439 
440  rosBxIdsPerFED[ddu].insert(ROSDebug_BunchNumber);
441 
442  if (robheader.bunchID() != ROSDebug_BunchNumber) {
443  // fill ROS Summary plot
444  ROSSummary->Fill(8, code.getROS());
445  eventErrorFlag = true;
446 
447  // fill ROB Summary plot for that particular ROS
448  ROSError->Fill(7, robheader.robID());
449  }
450  }
451 
452  // TDC Data
453  for (vector<DTTDCData>::const_iterator tdc_it = data.getTDCData().begin(); tdc_it != data.getTDCData().end();
454  tdc_it++) { // loop over TDC data
455 
456  DTTDCMeasurementWord tdcDatum = (*tdc_it).second;
457 
458  if (tdcDatum.PC() != 0) {
459  LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityROSOffline")
460  << " PC error in ROS " << code.getROS() << " TDC " << (*tdc_it).first << endl;
461  // fill ROS Summary plot
462  ROSSummary->Fill(7, code.getROS());
463 
464  eventErrorFlag = true;
465 
466  // fill ROB Summary plot for that particular ROS
467  ROSError->Fill(6, (*tdc_it).first);
468  }
469  }
470 
471  // TDC Error
472  for (vector<DTTDCError>::const_iterator tdc_it = data.getTDCError().begin(); tdc_it != data.getTDCError().end();
473  tdc_it++) { // loop over TDC errors
474 
475  code.setROB((*tdc_it).first);
476 
477  int tdcError_ROSSummary = 0;
478  int tdcError_ROSError = 0;
479 
480  if (((*tdc_it).second).tdcError() & 0x4000) {
481  LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityROSOffline")
482  << " ROS " << code.getROS() << " ROB " << code.getROB() << " Internal fatal Error 4000 in TDC "
483  << (*tdc_it).first << endl;
484 
485  tdcError_ROSSummary = 14;
486  tdcError_ROSError = 11;
487 
488  } else if (((*tdc_it).second).tdcError() & 0x0249) {
489  LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityROSOffline")
490  << " ROS " << code.getROS() << " ROB " << code.getROB() << " TDC FIFO overflow in TDC " << (*tdc_it).first
491  << endl;
492 
493  tdcError_ROSSummary = 15;
494  tdcError_ROSError = 12;
495 
496  } else if (((*tdc_it).second).tdcError() & 0x0492) {
497  LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityROSOffline")
498  << " ROS " << code.getROS() << " ROB " << code.getROB() << " TDC L1 buffer overflow in TDC "
499  << (*tdc_it).first << endl;
500 
501  tdcError_ROSSummary = 16;
502  tdcError_ROSError = 13;
503 
504  } else if (((*tdc_it).second).tdcError() & 0x2000) {
505  LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityROSOffline")
506  << " ROS " << code.getROS() << " ROB " << code.getROB() << " TDC L1A FIFO overflow in TDC " << (*tdc_it).first
507  << endl;
508 
509  tdcError_ROSSummary = 17;
510  tdcError_ROSError = 14;
511 
512  } else if (((*tdc_it).second).tdcError() & 0x0924) {
513  LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityROSOffline")
514  << " ROS " << code.getROS() << " ROB " << code.getROB() << " TDC hit error in TDC " << (*tdc_it).first
515  << endl;
516 
517  tdcError_ROSSummary = 18;
518  tdcError_ROSError = 15;
519 
520  } else if (((*tdc_it).second).tdcError() & 0x1000) {
521  LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityROSOffline")
522  << " ROS " << code.getROS() << " ROB " << code.getROB() << " TDC hit rejected in TDC " << (*tdc_it).first
523  << endl;
524 
525  tdcError_ROSSummary = 19;
526  tdcError_ROSError = 16;
527 
528  } else {
529  LogWarning("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityROSOffline")
530  << " TDC error code not known " << ((*tdc_it).second).tdcError() << endl;
531  }
532 
533  ROSSummary->Fill(tdcError_ROSSummary, code.getROS());
534 
535  if (tdcError_ROSSummary <= 15) {
536  eventErrorFlag = true;
537  }
538 
539  ROSError->Fill(tdcError_ROSError, (*tdc_it).first);
540  }
541 }
542 
543 void DTDataIntegrityROSOffline::processFED(DTDDUData& data, const std::vector<DTROS25Data>& rosData, int ddu) {
544  neventsFED++;
545  if (neventsFED % 1000 == 0)
546  LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityROSOffline")
547  << "[DTDataIntegrityROSOffline]: " << neventsFED << " events analyzed by processFED" << endl;
548 
549  DTROChainCoding code;
550  code.setDDU(ddu);
551  if (code.getDDUID() < FEDIDmin || code.getDDUID() > FEDIDmax)
552  return;
553 
554  hFEDEntry->Fill(code.getDDUID());
555 
556  const FEDTrailer& trailer = data.getDDUTrailer();
557  const FEDHeader& header = data.getDDUHeader();
558 
559  // check consistency of header and trailer
560  if (!header.check()) {
561  // error code 7
562  hFEDFatal->Fill(code.getDDUID());
563  hCorruptionSummary->Fill(code.getDDUID(), 7);
564  }
565 
566  if (!trailer.check()) {
567  // error code 8
568  hFEDFatal->Fill(code.getDDUID());
569  hCorruptionSummary->Fill(code.getDDUID(), 8);
570  }
571 
572  // check CRC error bit set by DAQ before sending data on SLink
573  if (data.crcErrorBit()) {
574  // error code 6
575  hFEDFatal->Fill(code.getDDUID());
576  hCorruptionSummary->Fill(code.getDDUID(), 6);
577  }
578 
579  const DTDDUSecondStatusWord& secondWord = data.getSecondStatusWord();
580 
581  //2D HISTO: ROS VS STATUS (8 BIT = 8 BIN) from 1st-2nd status words (9th BIN FROM LIST OF ROS in 2nd status word)
582  MonitorElement* hROSStatus = fedHistos["ROSStatus"][code.getDDUID()];
583  //1D HISTO: NUMBER OF ROS IN THE EVENTS from 2nd status word
584 
585  int rosList = secondWord.rosList();
586  set<int> rosPositions;
587  for (int i = 0; i < 12; i++) {
588  if (rosList & 0x1) {
589  rosPositions.insert(i);
590  //9th BIN FROM LIST OF ROS in 2nd status word
591  hROSStatus->Fill(8, i, 1);
592  }
593  rosList >>= 1;
594  }
595 
596  int channel = 0;
597  for (vector<DTDDUFirstStatusWord>::const_iterator fsw_it = data.getFirstStatusWord().begin();
598  fsw_it != data.getFirstStatusWord().end();
599  fsw_it++) {
600  // assuming association one-to-one between DDU channel and ROS
601  hROSStatus->Fill(0, channel, (*fsw_it).channelEnabled());
602  hROSStatus->Fill(1, channel, (*fsw_it).timeout());
603  hROSStatus->Fill(2, channel, (*fsw_it).eventTrailerLost());
604  hROSStatus->Fill(3, channel, (*fsw_it).opticalFiberSignalLost());
605  hROSStatus->Fill(4, channel, (*fsw_it).tlkPropagationError());
606  hROSStatus->Fill(5, channel, (*fsw_it).tlkPatternError());
607  hROSStatus->Fill(6, channel, (*fsw_it).tlkSignalLost());
608  hROSStatus->Fill(7, channel, (*fsw_it).errorFromROS());
609  // check that the enabled channel was also in the read-out
610  if ((*fsw_it).channelEnabled() == 1 && rosPositions.find(channel) == rosPositions.end()) {
611  hROSStatus->Fill(9, channel, 1);
612  // error code 1
613  hFEDFatal->Fill(code.getDDUID());
614  hCorruptionSummary->Fill(code.getDDUID(), 1);
615  }
616  channel++;
617  }
618 
619  // ---------------------------------------------------------------------
620  // cross checks between FED and ROS data
621  // check the BX ID against the ROSs
622  set<int> rosBXIds = rosBxIdsPerFED[ddu];
623  if ((rosBXIds.size() > 1 || rosBXIds.find(header.bxID()) == rosBXIds.end()) &&
624  !rosBXIds.empty()) { // in this case look for faulty ROSs
625  for (vector<DTROS25Data>::const_iterator rosControlData = rosData.begin(); rosControlData != rosData.end();
626  ++rosControlData) { // loop over the ROS data
627  for (vector<DTROSDebugWord>::const_iterator debug_it = (*rosControlData).getROSDebugs().begin();
628  debug_it != (*rosControlData).getROSDebugs().end();
629  debug_it++) { // Loop over ROS debug words
630  if ((*debug_it).debugType() == 0 && (*debug_it).debugMessage() != header.bxID()) { // check the BX
631  int ros = (*rosControlData).getROSID();
632  // fill the error bin
633  hROSStatus->Fill(11, ros - 1);
634  // error code 2
635  hFEDFatal->Fill(code.getDDUID());
636  hCorruptionSummary->Fill(code.getDDUID(), 2);
637  }
638  }
639  }
640  }
641 
642  // check the BX ID against other FEDs
643  fedBXIds.insert(header.bxID());
644  if (fedBXIds.size() != 1) {
645  LogWarning("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityROSOffline")
646  << "ERROR: FED " << ddu << " BX ID different from other feds: " << header.bxID() << endl;
647  // error code 3
648  hFEDFatal->Fill(code.getDDUID());
649  hCorruptionSummary->Fill(code.getDDUID(), 3);
650  }
651 
652  // check the L1A ID against the ROSs
653  set<int> rosL1AIds = rosL1AIdsPerFED[ddu];
654  if ((rosL1AIds.size() > 1 || rosL1AIds.find(header.lvl1ID() - 1) == rosL1AIds.end()) &&
655  !rosL1AIds.empty()) { // in this case look for faulty ROSs
656  //If L1A_ID error identify which ROS has wrong L1A
657  for (vector<DTROS25Data>::const_iterator rosControlData = rosData.begin(); rosControlData != rosData.end();
658  rosControlData++) { // loop over the ROS data
659  unsigned int ROSHeader_TTCCount =
660  ((*rosControlData).getROSHeader().TTCEventCounter() + 1) %
661  0x1000000; // fix comparison in case of last counting bin in ROS /first one in DDU
662  if (ROSHeader_TTCCount != header.lvl1ID()) {
663  int ros = (*rosControlData).getROSID();
664  hROSStatus->Fill(10, ros - 1);
665  // error code 4
666  hFEDFatal->Fill(code.getDDUID());
667  hCorruptionSummary->Fill(code.getDDUID(), 4);
668  }
669  }
670  }
671 
672  //1D HISTOS: EVENT LENGHT from trailer
673  int fedEvtLength = trailer.fragmentLength() * 8;
674  // if(fedEvtLength > 16000) fedEvtLength = 16000; // overflow bin
675  fedHistos["EventLength"][code.getDDUID()]->Fill(fedEvtLength);
676 }
677 
678 // log number of times the payload of each fed is unpacked
680 
681 // log number of times the payload of each fed is skipped (no ROS inside)
683 
684 // log number of times the payload of each fed is partially skipped (some ROS skipped)
686 
688  string folder = "DT/00-DataIntegrity/";
689 
690  return folder;
691 }
692 
693 void DTDataIntegrityROSOffline::channelsInCEROS(int cerosId, int chMask, vector<int>& channels) {
694  for (int iCh = 0; iCh < 6; ++iCh) {
695  if ((chMask >> iCh) & 0x1) {
696  channels.push_back(cerosId * 6 + iCh);
697  }
698  }
699  return;
700 }
701 
702 void DTDataIntegrityROSOffline::channelsInROS(int cerosMask, vector<int>& channels) {
703  for (int iCeros = 0; iCeros < 5; ++iCeros) {
704  if ((cerosMask >> iCeros) & 0x1) {
705  for (int iCh = 0; iCh < 6; ++iCh) {
706  channels.push_back(iCeros * 6 + iCh);
707  }
708  }
709  }
710  return;
711 }
712 
714  nevents++;
716 
717  LogTrace("DTRawToDigi|TDQM|DTMonitorModule|DTDataIntegrityROSOffline")
718  << "[DTDataIntegrityROSOffline]: preProcessEvent" << endl;
719 
720  //Legacy ROS
721  // clear the set of BXids from the ROSs
722  for (map<int, set<int> >::iterator rosBxIds = rosBxIdsPerFED.begin(); rosBxIds != rosBxIdsPerFED.end(); ++rosBxIds) {
723  (*rosBxIds).second.clear();
724  }
725 
726  fedBXIds.clear();
727 
728  for (map<int, set<int> >::iterator rosL1AIds = rosL1AIdsPerFED.begin(); rosL1AIds != rosL1AIdsPerFED.end();
729  ++rosL1AIds) {
730  (*rosL1AIds).second.clear();
731  }
732 
733  // reset the error flag
734  eventErrorFlag = false;
735 
736  // Digi collection
737  edm::Handle<DTDDUCollection> dduProduct;
738  e.getByToken(dduToken, dduProduct);
739  edm::Handle<DTROS25Collection> ros25Product;
740  e.getByToken(ros25Token, ros25Product);
741 
742  DTDDUData dduData;
743  std::vector<DTROS25Data> ros25Data;
744  if (dduProduct.isValid() && ros25Product.isValid()) {
745  for (unsigned int i = 0; i < dduProduct->size(); ++i) {
746  dduData = dduProduct->at(i);
747  ros25Data = ros25Product->at(i);
748  FEDHeader header = dduData.getDDUHeader();
749  int id = header.sourceID();
750  if (id > FEDIDmax || id < FEDIDmin)
751  continue; //SIM uses extra FEDs not monitored
752 
753  processFED(dduData, ros25Data, id);
754  for (unsigned int j = 0; j < ros25Data.size(); ++j) {
755  int rosid = j + 1;
756  processROS25(ros25Data[j], id, rosid);
757  }
758  }
759  }
760 }
761 
762 // Local Variables:
763 // show-trailing-whitespace: t
764 // truncate-lines: t
765 // End:
int getROSID() const
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
MonitorElement * bookFloat(TString const &name, FUNC onbooking=NOOP())
Definition: DQMStore.h:80
void bookHistosROS25(DQMStore::IBooker &, DTROChainCoding code)
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
void analyze(const edm::Event &e, const edm::EventSetup &c) override
int rosList() const
Definition: DTDDUWords.h:690
std::map< std::string, std::map< int, MonitorElement * > > summaryHistos
void processFED(DTDDUData &dduData, const std::vector< DTROS25Data > &rosData, int dduID)
std::string to_string(const V &value)
Definition: OMSAccess.h:71
int getROS() const
Log< level::Error, false > LogError
int getSCID() const
#define LogTrace(id)
edm::EDGetTokenT< DTROS25Collection > ros25Token
uint32_t fragmentLength() const
The length of the event fragment counted in 64-bit words including header and trailer.
Definition: FEDTrailer.cc:13
T getUntrackedParameter(std::string const &, T const &) const
void Fill(long long x)
int getROB() const
int getDDUID() const
int robID() const
Definition: DTDDUWords.h:353
edm::EDGetTokenT< DTDDUCollection > dduToken
int bunchID() const
Definition: DTDDUWords.h:355
std::map< int, std::set< int > > rosL1AIdsPerFED
int getDDU() const
virtual void setBinLabel(int bin, const std::string &label, int axis=1)
set bin label for x, y or z axis (axis=1, 2, 3 respectively)
const FEDHeader & getDDUHeader() const
Getters.
void setROB(const int &ID)
void bookHistos(DQMStore::IBooker &, const int fedMin, const int fedMax)
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
void setROS(const int &ID)
std::string topFolder(bool isFEDIntegrity) const
bool isValid() const
Definition: HandleBase.h:70
std::map< std::string, std::map< int, MonitorElement * > > fedHistos
DTDataIntegrityROSOffline(const edm::ParameterSet &ps)
void setDDU(const int &ID)
need to reset the bits before setting
HLT enums.
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
std::map< std::string, std::map< int, MonitorElement * > > rosHistos
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
void channelsInCEROS(int cerosId, int chMask, std::vector< int > &channels)
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< int, std::set< int > > rosBxIdsPerFED
bool check() const
Check that the trailer is OK.
Definition: FEDTrailer.cc:45
void processROS25(DTROS25Data &data, int dduID, int ros)
void channelsInROS(int cerosMask, std::vector< int > &channels)
Definition: Run.h:45
virtual void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)