CMS 3D CMS Logo

DTDataIntegrityTask.cc
Go to the documentation of this file.
1 /*
2  * \file DTDataIntegrityTask.cc
3  *
4  * \author M. Zanetti (INFN Padova), S. Bolognesi (INFN Torino), G. Cerminara (INFN Torino)
5  *
6  */
7 
21 
22 #include <cmath>
23 #include <fstream>
24 #include <map>
25 #include <string>
26 #include <vector>
27 
28 using namespace std;
29 using namespace edm;
30 
32 
33  LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
34  << "[DTDataIntegrityTask]: Constructor" <<endl;
35 
36  checkUros = ps.getUntrackedParameter<bool>("checkUros",true);
37 
38  if (checkUros) {
39  fedToken = consumes<DTuROSFEDDataCollection>(ps.getParameter<InputTag>("dtFEDlabel"));
42  }
43  else { dduToken = consumes<DTDDUCollection>(ps.getParameter<InputTag>("dtDDULabel"));
44  ros25Token = consumes<DTROS25Collection>(ps.getParameter<InputTag>("dtROS25Label"));
47  }
48 
49  neventsFED = 0;
50  neventsuROS = 0;
51 
52 
53 // If you want info VS time histos
54 // doTimeHisto = ps.getUntrackedParameter<bool>("doTimeHisto", false);
55 // Plot quantities about SC
56  getSCInfo = ps.getUntrackedParameter<bool>("getSCInfo", false);
57 
58  fedIntegrityFolder = ps.getUntrackedParameter<string>("fedIntegrityFolder","DT/FEDIntegrity");
59 
60  string processingMode = ps.getUntrackedParameter<string>("processingMode","Online");
61 
62  // processing mode flag to select plots to be produced and basedirs CB vedi se farlo meglio...
63  if (processingMode == "Online") {
64  mode = 0;
65  } else if(processingMode == "SM") {
66  mode = 1;
67  } else if (processingMode == "Offline") {
68  mode = 2;
69  } else if (processingMode == "HLT") {
70  mode = 3;
71  } else {
72  throw cms::Exception("MissingParameter")
73  << "[DTDataIntegrityTask]: processingMode :" << processingMode
74  << " invalid! Must be Online, SM, Offline or HLT !" << endl;
75  }
76 
77 }
78 
79 
81  LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
82  <<"[DTDataIntegrityTask]: Destructor. Analyzed "<< neventsFED <<" events"<<endl;
83  LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
84  << "[DTDataIntegrityTask]: postEndJob called!" <<endl;
85 }
86 
87 /*
88  Folder Structure (ROS Legacy):
89  - One folder for each DDU, named FEDn
90  - Inside each DDU folder the DDU histos and the ROSn folder
91  - Inside each ROS folder the ROS histos and the ROBn folder
92  - Inside each ROB folder one occupancy plot and the TimeBoxes
93  with the chosen granularity (simply change the histo name)
94 
95  uROS (starting 2018):
96  - 3 uROS Summary plots: WheelNEG (FED1369), Wheel0 (FED1370), WheelPOS (FED1371)
97  - One folder for each FED
98  - Inside each FED folder the uROSStatus histos, FED histos and the uROSn folders
99  = Inside each uROS folder the TDC and uROS errors histos, 12 Links/plot
100 */
101 
102 void DTDataIntegrityTask::bookHistograms(DQMStore::IBooker & ibooker, edm::Run const & iRun, edm::EventSetup const & iSetup) {
103 
104  LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask") << "[DTDataIntegrityTask]: postBeginJob" <<endl;
105 
106  LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask") << "[DTDataIntegrityTask] Get DQMStore service" << endl;
107 
108  // Loop over the DT FEDs
109 
110  LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
111  << " FEDS: " << FEDIDmin << " to " << FEDIDmax << " in the RO" << endl;
112 
113  // book FED integrity histos
114  bookHistos(ibooker, FEDIDmin, FEDIDmax);
115 
116  if (checkUros){ //uROS starting on 2018
117  // static booking of the histograms
118 
119  if(mode == 0 || mode ==2){
120  for(int fed = FEDIDmin; fed <= FEDIDmax; ++fed) { // loop over the FEDs in the readout
121 
122  bookHistos(ibooker, string("FED"), fed);
123 
124  bookHistos(ibooker, string("CRATE"), fed);
125 
126  for(int uRos = 1; uRos <= NuROS; ++uRos) {// loop over all ROS
127  bookHistosuROS(ibooker,fed,uRos);
128  }
129  }
130  } //Not in HLT or SM mode
131  } //uROS
132 
133  else{ //Legacy ROS
134 
135  if(mode == 0 || mode ==2){
136  // static booking of the histograms
137 
138  for(int fed = FEDIDmin; fed <= FEDIDmax; ++fed) { // loop over the FEDs in the readout
139  DTROChainCoding code;
140  code.setDDU(fed);
141  bookHistos(ibooker, string("ROS_S"), code);
142 
143  bookHistos(ibooker, string("DDU"), code);
144 
145  for(int ros = 1; ros <= NuROS; ++ros) {// loop over all ROS
146  code.setROS(ros);
147  bookHistosROS25(ibooker, code);
148  }
149  }
150  } //Not in HLT or SM mode
151  } //Legacy ROS
152 }
153 
154 void DTDataIntegrityTask::bookHistos(DQMStore::IBooker & ibooker, const int fedMin, const int fedMax) {
155 
156  ibooker.setCurrentFolder("DT/EventInfo/Counters");
157  nEventMonitor = ibooker.bookFloat("nProcessedEventsDataIntegrity");
158 
159  // Standard FED integrity histos
160  ibooker.setCurrentFolder(topFolder(true));
161 
162  int nFED = (fedMax - fedMin)+1;
163 
164  hFEDEntry = ibooker.book1D("FEDEntries","# entries per DT FED",nFED,fedMin,fedMax+1);
165 
166  if(!checkUros){
167  hFEDFatal = ibooker.book1D("FEDFatal","# fatal errors DT FED",nFED,fedMin,fedMax+1);
168  hFEDNonFatal = ibooker.book1D("FEDNonFatal","# NON fatal errors DT FED",nFED,fedMin,fedMax+1);
169 
170  if(mode == 3 || mode ==1) return; //Avoid duplication of Info in FEDIntegrity_EvF
171 
172  ibooker.setCurrentFolder(topFolder(false));
173  hTTSSummary = ibooker.book2D("TTSSummary","Summary Status TTS",nFED,fedMin,fedMax+1,9,1,10);
174  hTTSSummary->setAxisTitle("FED",1);
175  hTTSSummary->setBinLabel(1,"ROS PAF",2);
176  hTTSSummary->setBinLabel(2,"DDU PAF",2);
177  hTTSSummary->setBinLabel(3,"ROS PAF",2);
178  hTTSSummary->setBinLabel(4,"DDU PAF",2);
179  hTTSSummary->setBinLabel(5,"DDU Full",2);
180  hTTSSummary->setBinLabel(6,"L1A Mism.",2);
181  hTTSSummary->setBinLabel(7,"ROS Error",2);
182  hTTSSummary->setBinLabel(8,"BX Mism.",2);
183  hTTSSummary->setBinLabel(9,"DDU Logic Err.",2);
184 
185  // bookkeeping of the
186  hCorruptionSummary = ibooker.book2D("DataCorruptionSummary", "Data Corruption Sources",
187  nFED,fedMin,fedMax+1, 8, 1, 9);
189  hCorruptionSummary->setBinLabel(1,"Miss Ch.",2);
190  hCorruptionSummary->setBinLabel(2,"ROS BX mism",2);
191  hCorruptionSummary->setBinLabel(3,"DDU BX mism",2);
192  hCorruptionSummary->setBinLabel(4,"ROS L1A mism",2);
193  hCorruptionSummary->setBinLabel(5,"Miss Payload",2);
194  hCorruptionSummary->setBinLabel(6,"FCRC bit",2);
195  hCorruptionSummary->setBinLabel(7,"Header check",2);
196  hCorruptionSummary->setBinLabel(8,"Trailer Check",2);
197  } //checkUros
198 }
199 
200 // ******************uROS******************** //
201 void DTDataIntegrityTask::bookHistos(DQMStore::IBooker & ibooker, string folder, const int fed){
202 
203  string wheel = "ZERO";
204  if (fed ==FEDIDmin) wheel="NEG";
205  else if(fed==FEDIDmax) wheel="POS";
206  string fed_s = to_string(fed);
207  LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
208  << " Booking histos for FED: " << fed_s
209  << " folder: " << folder << endl;
210 
211  string histoType;
212  string histoName;
213  string histoTitle;
214  MonitorElement* histo = nullptr;
215 
216  // Crate (old DDU) Histograms
217  if (folder == "CRATE") {
218 
219  ibooker.setCurrentFolder(topFolder(false) + "FED" + fed_s);
220 
221  histoType = "EventLenght";
222  histoName = "FED" + fed_s + "_" + histoType;
223  histoTitle = "Event Lenght (Bytes) FED " + fed_s;
224  (fedHistos[histoType])[fed] = ibooker.book1D(histoName,histoTitle,501,0,30000);
225 
226  if(mode == 3 || mode ==1) return; //Avoid duplication of Info in FEDIntegrity_EvF
227 
228  histoType = "uROSStatus";
229  histoName = "FED" + fed_s + "_" + histoType;
230  (fedHistos[histoType])[fed] = ibooker.book2D(histoName,histoName,12,0,12,12,1,13);
231  histo = (fedHistos[histoType])[fed];
232  // only placeholders for the moment
233  histo->setBinLabel(1,"Error G 1",1);
234  histo->setBinLabel(2,"Error G 2",1);
235  histo->setBinLabel(3,"Error G 3",1);
236  histo->setBinLabel(4,"Error G 4",1);
237  histo->setBinLabel(5,"Error G 5",1);
238  histo->setBinLabel(6,"Error G 6",1);
239  histo->setBinLabel(7,"Error G 7",1);
240  histo->setBinLabel(8,"Error G 8",1);
241  histo->setBinLabel(9,"Error G 9",1);
242  histo->setBinLabel(10,"Error G 10",1);
243  histo->setBinLabel(11,"Error G 11",1);
244  histo->setBinLabel(12,"Error G 12",1);
245 
246  histo->setBinLabel(1,"uROS 1",2);
247  histo->setBinLabel(2,"uROS 2",2);
248  histo->setBinLabel(3,"uROS 3",2);
249  histo->setBinLabel(4,"uROS 4",2);
250  histo->setBinLabel(5,"uROS 5",2);
251  histo->setBinLabel(6,"uROS 6",2);
252  histo->setBinLabel(7,"uROS 7",2);
253  histo->setBinLabel(8,"uROS 8",2);
254  histo->setBinLabel(9,"uROS 9",2);
255  histo->setBinLabel(10,"uROS 10",2);
256  histo->setBinLabel(11,"uROS 11",2);
257  histo->setBinLabel(12,"uROS 12",2);
258 
259  if(mode > 0) return; //Info for Online only
260 
261  histoType = "FEDAvgEvLenghtvsLumi";
262  histoName = "FED" + fed_s + "_" + histoType;
263  histoTitle = "Avg Event Lenght (Bytes) vs LumiSec FED " + fed_s;
264  (fedTimeHistos[histoType])[fed] = new DTTimeEvolutionHisto(ibooker,histoName,histoTitle,200,10,true,0);
265 
266  histoType = "TTSValues";
267  histoName = "FED" + fed_s + "_" + histoType;
268  (fedHistos[histoType])[fed] = ibooker.book1D(histoName,histoName,8,0,8);
269  histo = (fedHistos[histoType])[fed];
270  histo->setBinLabel(1,"Disconnected",1);
271  histo->setBinLabel(2,"Overflow Warning ",1);
272  histo->setBinLabel(3,"Out of synch",1);
273  histo->setBinLabel(4,"Busy",1);
274  histo->setBinLabel(5,"Ready",1);
275  histo->setBinLabel(6,"Error",1);
276  histo->setBinLabel(7,"Disconnected",1);
277  histo->setBinLabel(8,"Unknown",1);
278 
279  histoType = "uROSList";
280  histoName = "FED" + fed_s + "_" + histoType;
281  histoTitle = "# of uROS in the FED payload (FED" + fed_s + ")";
282  (fedHistos[histoType])[fed] = ibooker.book1D(histoName,histoTitle,13,0,13);
283 
284  histoType = "BXID";
285  histoName = "FED" + fed_s + "_BXID";
286  histoTitle = "Distrib. BX ID (FED" + fed_s + ")";
287  (fedHistos[histoType])[fed] = ibooker.book1D(histoName,histoTitle,3600,0,3600);
288 
289  }
290 
291  // uROS Histograms
292  if ( folder == "FED" ) { // The summary of the error of the ROS on the same FED
293  ibooker.setCurrentFolder(topFolder(false));
294 
295  if(mode == 3 || mode ==1) return; //Avoid duplication of Info in FEDIntegrity_EvF
296 
297  histoType = "uROSSummary";
298  histoName = "FED" + fed_s + "_uROSSummary";
299  string histoTitle = "Summary Wheel" + wheel + " (FED " + fed_s + ")";
300 
301  ((summaryHistos[histoType])[fed]) = ibooker.book2D(histoName,histoTitle,19,0,19,12,1,13);
302  MonitorElement *histo = ((summaryHistos[histoType])[fed]);
303  // ROS error bins
304  // Placeholders for Global Errors for the moment
305  histo ->setBinLabel(1,"Error G 1",1);
306  histo ->setBinLabel(2,"Error G 2",1);
307  histo ->setBinLabel(3,"Error G 3",1);
308  histo ->setBinLabel(4,"Error G 4",1);
309  histo ->setBinLabel(5,"Error G 5",1);
310  histo ->setBinLabel(6,"Error G 6",1);
311  histo ->setBinLabel(7,"Error G 7",1);
312  histo ->setBinLabel(8,"Error G 8",1);
313  histo ->setBinLabel(9,"Error G 9",1);
314  histo ->setBinLabel(10,"Error G 10",1);
315  histo ->setBinLabel(11,"Error G 11",1);
316  histo ->setBinLabel(12,"Error G 12",1);
317  histo ->setBinLabel(13,"Not OKflag",1);//it was CEROS blocked
318  // TDC error bins
319  histo ->setBinLabel(14,"TDC Fatal",1);
320  histo ->setBinLabel(15,"TDC RO FIFO ov.",1);
321  histo ->setBinLabel(16,"TDC L1 buf. ov.",1);
322  histo ->setBinLabel(17,"TDC L1A FIFO ov.",1);
323  histo ->setBinLabel(18,"TDC hit err.",1);
324  histo ->setBinLabel(19,"TDC hit rej.",1);
325 
326  histo ->setBinLabel(1,"uROS1",2);
327  histo ->setBinLabel(2,"uROS2",2);
328  histo ->setBinLabel(3,"uROS3",2);
329  histo ->setBinLabel(4,"uROS4",2);
330  histo ->setBinLabel(5,"uROS5",2);
331  histo ->setBinLabel(6,"uROS6",2);
332  histo ->setBinLabel(7,"uROS7",2);
333  histo ->setBinLabel(8,"uROS8",2);
334  histo ->setBinLabel(9,"uROS9",2);
335  histo ->setBinLabel(10,"uROS10",2);
336  histo ->setBinLabel(11,"uROS11",2);
337  histo ->setBinLabel(12,"uROS12",2);
338  }
339 
340 }
341 // ******************End uROS******************** //
342 
343 
345 
346  string dduID_s = to_string(code.getDDU());
347  string rosID_s = to_string(code.getROS());
348  string robID_s = to_string(code.getROB());
349  int wheel = (code.getDDUID() - 770)%5 - 2;
350  string wheel_s = to_string(wheel);
351 
352  LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
353  << " Booking histos for FED: " << code.getDDU() << " ROS: " << code.getROS()
354  << " ROB: " << code.getROB() << " folder: " << folder << endl;
355 
356  string histoType;
357  string histoName;
358  string histoTitle;
359  MonitorElement* histo = nullptr;
360 
361  // DDU Histograms
362  if (folder == "DDU") {
363 
364  ibooker.setCurrentFolder(topFolder(false) + "FED" + dduID_s);
365 
366  histoType = "EventLenght";
367  histoName = "FED" + dduID_s + "_" + histoType;
368  histoTitle = "Event Lenght (Bytes) FED " + dduID_s;
369  (fedHistos[histoType])[code.getDDUID()] = ibooker.book1D(histoName,histoTitle,501,0,16032);
370 
371  if(mode == 3 || mode ==1) return; //Avoid duplication of Info in FEDIntegrity_EvF
372 
373  histoType = "ROSStatus";
374  histoName = "FED" + dduID_s + "_" + histoType;
375  (fedHistos[histoType])[code.getDDUID()] = ibooker.book2D(histoName,histoName,12,0,12,12,0,12);
376  histo = (fedHistos[histoType])[code.getDDUID()];
377  histo->setBinLabel(1,"ch.enabled",1);
378  histo->setBinLabel(2,"timeout",1);
379  histo->setBinLabel(3,"ev.trailer lost",1);
380  histo->setBinLabel(4,"opt.fiber lost",1);
381  histo->setBinLabel(5,"tlk.prop.error",1);
382  histo->setBinLabel(6,"tlk.pattern error",1);
383  histo->setBinLabel(7,"tlk.sign.lost",1);
384  histo->setBinLabel(8,"error from ROS",1);
385  histo->setBinLabel(9,"if ROS in events",1);
386  histo->setBinLabel(10,"Miss. Evt.",1);
387  histo->setBinLabel(11,"Evt. ID Mismatch",1);
388  histo->setBinLabel(12,"BX Mismatch",1);
389 
390  histo->setBinLabel(1,"ROS 1",2);
391  histo->setBinLabel(2,"ROS 2",2);
392  histo->setBinLabel(3,"ROS 3",2);
393  histo->setBinLabel(4,"ROS 4",2);
394  histo->setBinLabel(5,"ROS 5",2);
395  histo->setBinLabel(6,"ROS 6",2);
396  histo->setBinLabel(7,"ROS 7",2);
397  histo->setBinLabel(8,"ROS 8",2);
398  histo->setBinLabel(9,"ROS 9",2);
399  histo->setBinLabel(10,"ROS 10",2);
400  histo->setBinLabel(11,"ROS 11",2);
401  histo->setBinLabel(12,"ROS 12",2);
402 
403  if(mode > 0) return; //Info for Online only
404 
405  histoType = "FEDAvgEvLenghtvsLumi";
406  histoName = "FED" + dduID_s + "_" + histoType;
407  histoTitle = "Avg Event Lenght (Bytes) vs LumiSec FED " + dduID_s;
408  fedTimeHistos[histoType][code.getDDUID()] = new DTTimeEvolutionHisto(ibooker,histoName,histoTitle,200,10,true,0);
409 
410  histoType = "TTSValues";
411  histoName = "FED" + dduID_s + "_" + histoType;
412  (fedHistos[histoType])[code.getDDUID()] = ibooker.book1D(histoName,histoName,8,0,8);
413  histo = (fedHistos[histoType])[code.getDDUID()];
414  histo->setBinLabel(1,"disconnected",1);
415  histo->setBinLabel(2,"warning overflow",1);
416  histo->setBinLabel(3,"out of synch",1);
417  histo->setBinLabel(4,"busy",1);
418  histo->setBinLabel(5,"ready",1);
419  histo->setBinLabel(6,"error",1);
420  histo->setBinLabel(7,"disconnected",1);
421  histo->setBinLabel(8,"unknown",1);
422 
423  histoType = "EventType";
424  histoName = "FED" + dduID_s + "_" + histoType;
425  (fedHistos[histoType])[code.getDDUID()] = ibooker.book1D(histoName,histoName,2,1,3);
426  histo = (fedHistos[histoType])[code.getDDUID()];
427  histo->setBinLabel(1,"physics",1);
428  histo->setBinLabel(2,"calibration",1);
429 
430  histoType = "ROSList";
431  histoName = "FED" + dduID_s + "_" + histoType;
432  histoTitle = "# of ROS in the FED payload (FED" + dduID_s + ")";
433  (fedHistos[histoType])[code.getDDUID()] = ibooker.book1D(histoName,histoTitle,13,0,13);
434 
435  histoType = "FIFOStatus";
436  histoName = "FED" + dduID_s + "_" + histoType;
437  (fedHistos[histoType])[code.getDDUID()] = ibooker.book2D(histoName,histoName,7,0,7,3,0,3);
438  histo = (fedHistos[histoType])[code.getDDUID()];
439  histo->setBinLabel(1,"Input ch1-4",1);
440  histo->setBinLabel(2,"Input ch5-8",1);
441  histo->setBinLabel(3,"Input ch9-12",1);
442  histo->setBinLabel(4,"Error/L1A ch1-4",1);
443  histo->setBinLabel(5,"Error/L1A ch5-8",1);
444  histo->setBinLabel(6,"Error/L1A ch9-12",1);
445  histo->setBinLabel(7,"Output",1);
446  histo->setBinLabel(1,"Full",2);
447  histo->setBinLabel(2,"Almost Full",2);
448  histo->setBinLabel(3,"Not Full",2);
449 
450  histoType = "BXID";
451  histoName = "FED" + dduID_s + "_BXID";
452  histoTitle = "Distrib. BX ID (FED" + dduID_s + ")";
453  (fedHistos[histoType])[code.getDDUID()] = ibooker.book1D(histoName,histoTitle,3600,0,3600);
454 
455  }
456 
457  // ROS Histograms
458  if ( folder == "ROS_S" ) { // The summary of the error of the ROS on the same FED
459  ibooker.setCurrentFolder(topFolder(false));
460 
461  if(mode == 3 || mode ==1) return; //Avoid duplication of Info in FEDIntegrity_EvF
462 
463  histoType = "ROSSummary";
464  histoName = "FED" + dduID_s + "_ROSSummary";
465  string histoTitle = "Summary Wheel" + wheel_s + " (FED " + dduID_s + ")";
466 
467  ((summaryHistos[histoType])[code.getDDUID()]) = ibooker.book2D(histoName,histoTitle,20,0,20,12,1,13);
468  MonitorElement *histo = ((summaryHistos[histoType])[code.getDDUID()]);
469  // ROS error bins
470  histo ->setBinLabel(1,"Link TimeOut",1);
471  histo ->setBinLabel(2,"Ev.Id.Mis.",1);
472  histo ->setBinLabel(3,"FIFO almost full",1);
473  histo ->setBinLabel(4,"FIFO full",1);
474  histo ->setBinLabel(5,"CEROS timeout",1);
475  histo ->setBinLabel(6,"Max. wds",1);
476  histo ->setBinLabel(7,"WO L1A FIFO",1);
477  histo ->setBinLabel(8,"TDC parity err.",1);
478  histo ->setBinLabel(9,"BX ID Mis.",1);
479  histo ->setBinLabel(10,"TXP",1);
480  histo ->setBinLabel(11,"L1A almost full",1);
481  histo ->setBinLabel(12,"Ch. blocked",1);
482  histo ->setBinLabel(13,"Ev. Id. Mis.",1);
483  histo ->setBinLabel(14,"CEROS blocked",1);
484  // TDC error bins
485  histo ->setBinLabel(15,"TDC Fatal",1);
486  histo ->setBinLabel(16,"TDC RO FIFO ov.",1);
487  histo ->setBinLabel(17,"TDC L1 buf. ov.",1);
488  histo ->setBinLabel(18,"TDC L1A FIFO ov.",1);
489  histo ->setBinLabel(19,"TDC hit err.",1);
490  histo ->setBinLabel(20,"TDC hit rej.",1);
491 
492  histo ->setBinLabel(1,"ROS1",2);
493  histo ->setBinLabel(2,"ROS2",2);
494  histo ->setBinLabel(3,"ROS3",2);
495  histo ->setBinLabel(4,"ROS4",2);
496  histo ->setBinLabel(5,"ROS5",2);
497  histo ->setBinLabel(6,"ROS6",2);
498  histo ->setBinLabel(7,"ROS7",2);
499  histo ->setBinLabel(8,"ROS8",2);
500  histo ->setBinLabel(9,"ROS9",2);
501  histo ->setBinLabel(10,"ROS10",2);
502  histo ->setBinLabel(11,"ROS11",2);
503  histo ->setBinLabel(12,"ROS12",2);
504  }
505 
506  if ( folder == "ROS" ) {
507  ibooker.setCurrentFolder(topFolder(false) + "FED" + dduID_s + "/" + folder + rosID_s);
508 
509  if(mode == 3 || mode ==1) return; //Avoid duplication of Info in FEDIntegrity_EvF
510 
511  histoType = "ROSError";
512  histoName = "FED" + dduID_s + "_" + folder + rosID_s + "_ROSError";
513  histoTitle = histoName + " (ROBID error summary)";
514  if(mode < 1) //Online only
515  (rosHistos[histoType])[code.getROSID()] = ibooker.book2D(histoName,histoTitle,17,0,17,26,0,26);
516  else
517  (rosHistos[histoType])[code.getROSID()] = ibooker.book2D(histoName,histoTitle,11,0,11,26,0,26);
518 
519  MonitorElement* histo = (rosHistos[histoType])[code.getROSID()];
520  // ROS error bins
521  histo->setBinLabel(1,"Link TimeOut",1);
522  histo->setBinLabel(2,"Ev.Id.Mis.",1);
523  histo->setBinLabel(3,"FIFO almost full",1);
524  histo->setBinLabel(4,"FIFO full",1);
525  histo->setBinLabel(5,"CEROS timeout",1);
526  histo->setBinLabel(6,"Max. wds",1);
527  histo->setBinLabel(7,"TDC parity err.",1);
528  histo->setBinLabel(8,"BX ID Mis.",1);
529  histo->setBinLabel(9,"Ch. blocked",1);
530  histo->setBinLabel(10,"Ev. Id. Mis.",1);
531  histo->setBinLabel(11,"CEROS blocked",1);
532  if(mode < 1) { //Online only
533  // TDC error bins
534  histo->setBinLabel(12,"TDC Fatal",1);
535  histo->setBinLabel(13,"TDC RO FIFO ov.",1);
536  histo->setBinLabel(14,"TDC L1 buf. ov.",1);
537  histo->setBinLabel(15,"TDC L1A FIFO ov.",1);
538  histo->setBinLabel(16,"TDC hit err.",1);
539  histo->setBinLabel(17,"TDC hit rej.",1);
540  }
541  histo->setBinLabel(1,"ROB0",2);
542  histo->setBinLabel(2,"ROB1",2);
543  histo->setBinLabel(3,"ROB2",2);
544  histo->setBinLabel(4,"ROB3",2);
545  histo->setBinLabel(5,"ROB4",2);
546  histo->setBinLabel(6,"ROB5",2);
547  histo->setBinLabel(7,"ROB6",2);
548  histo->setBinLabel(8,"ROB7",2);
549  histo->setBinLabel(9,"ROB8",2);
550  histo->setBinLabel(10,"ROB9",2);
551  histo->setBinLabel(11,"ROB10",2);
552  histo->setBinLabel(12,"ROB11",2);
553  histo->setBinLabel(13,"ROB12",2);
554  histo->setBinLabel(14,"ROB13",2);
555  histo->setBinLabel(15,"ROB14",2);
556  histo->setBinLabel(16,"ROB15",2);
557  histo->setBinLabel(17,"ROB16",2);
558  histo->setBinLabel(18,"ROB17",2);
559  histo->setBinLabel(19,"ROB18",2);
560  histo->setBinLabel(20,"ROB19",2);
561  histo->setBinLabel(21,"ROB20",2);
562  histo->setBinLabel(22,"ROB21",2);
563  histo->setBinLabel(23,"ROB22",2);
564  histo->setBinLabel(24,"ROB23",2);
565  histo->setBinLabel(25,"ROB24",2);
566  histo->setBinLabel(26,"SC",2);
567 
568  if(mode > 1) return;
569 
570  histoType = "ROSEventLenght";
571  histoName = "FED" + dduID_s + "_" + folder + rosID_s + "_ROSEventLenght";
572  histoTitle = "Event Lenght (Bytes) FED " + dduID_s + " ROS " + rosID_s;
573  (rosHistos[histoType])[code.getROSID()] = ibooker.book1D(histoName,histoTitle,101,0,1616);
574 
575  histoType = "ROSAvgEventLenghtvsLumi";
576  histoName = "FED" + dduID_s + "_" + folder + rosID_s + histoType;
577  histoTitle = "Event Lenght (Bytes) FED " + dduID_s + " ROS " + rosID_s;
578  rosTimeHistos[histoType][code.getROSID()] = new DTTimeEvolutionHisto(ibooker,histoName,histoTitle,200,10,true,0);
579 
580  histoType = "TDCError";
581  histoName = "FED" + dduID_s + "_" + folder + rosID_s + "_TDCError";
582  histoTitle = histoName + " (ROBID error summary)";
583  (rosHistos[histoType])[code.getROSID()] = ibooker.book2D(histoName,histoTitle,24,0,24,25,0,25);
584  histo = (rosHistos[histoType])[code.getROSID()];
585  // TDC error bins
586  histo->setBinLabel(1,"Fatal",1);
587  histo->setBinLabel(2,"RO FIFO ov.",1);
588  histo->setBinLabel(3,"L1 buf. ov.",1);
589  histo->setBinLabel(4,"L1A FIFO ov.",1);
590  histo->setBinLabel(5,"hit err.",1);
591  histo->setBinLabel(6,"hit rej.",1);
592  histo->setBinLabel(7,"Fatal",1);
593  histo->setBinLabel(8,"RO FIFO ov.",1);
594  histo->setBinLabel(9,"L1 buf. ov.",1);
595  histo->setBinLabel(10,"L1A FIFO ov.",1);
596  histo->setBinLabel(11,"hit err.",1);
597  histo->setBinLabel(12,"hit rej.",1);
598  histo->setBinLabel(13,"Fatal",1);
599  histo->setBinLabel(14,"RO FIFO ov.",1);
600  histo->setBinLabel(15,"L1 buf. ov.",1);
601  histo->setBinLabel(16,"L1A FIFO ov.",1);
602  histo->setBinLabel(17,"hit err.",1);
603  histo->setBinLabel(18,"hit rej.",1);
604  histo->setBinLabel(19,"Fatal",1);
605  histo->setBinLabel(20,"RO FIFO ov.",1);
606  histo->setBinLabel(21,"L1 buf. ov.",1);
607  histo->setBinLabel(22,"L1A FIFO ov.",1);
608  histo->setBinLabel(23,"hit err.",1);
609  histo->setBinLabel(24,"hit rej.",1);
610 
611  histo->setBinLabel(1,"ROB0",2);
612  histo->setBinLabel(2,"ROB1",2);
613  histo->setBinLabel(3,"ROB2",2);
614  histo->setBinLabel(4,"ROB3",2);
615  histo->setBinLabel(5,"ROB4",2);
616  histo->setBinLabel(6,"ROB5",2);
617  histo->setBinLabel(7,"ROB6",2);
618  histo->setBinLabel(8,"ROB7",2);
619  histo->setBinLabel(9,"ROB8",2);
620  histo->setBinLabel(10,"ROB9",2);
621  histo->setBinLabel(11,"ROB10",2);
622  histo->setBinLabel(12,"ROB11",2);
623  histo->setBinLabel(13,"ROB12",2);
624  histo->setBinLabel(14,"ROB13",2);
625  histo->setBinLabel(15,"ROB14",2);
626  histo->setBinLabel(16,"ROB15",2);
627  histo->setBinLabel(17,"ROB16",2);
628  histo->setBinLabel(18,"ROB17",2);
629  histo->setBinLabel(19,"ROB18",2);
630  histo->setBinLabel(20,"ROB19",2);
631  histo->setBinLabel(21,"ROB20",2);
632  histo->setBinLabel(22,"ROB21",2);
633  histo->setBinLabel(23,"ROB22",2);
634  histo->setBinLabel(24,"ROB23",2);
635  histo->setBinLabel(25,"ROB24",2);
636 
637  histoType = "ROB_mean";
638  histoName = "FED" + dduID_s + "_" + "ROS" + rosID_s + "_ROB_mean";
639  string fullName = topFolder(false) + "FED" + dduID_s + "/" + folder + rosID_s+ "/" + histoName;
640  names.insert (pair<std::string,std::string> (histoType,string(fullName)));
641  (rosHistos[histoType])[code.getROSID()] = ibooker.book2D(histoName,histoName,25,0,25,100,0,100);
642  (rosHistos[histoType])[code.getROSID()]->setAxisTitle("ROB #",1);
643  (rosHistos[histoType])[code.getROSID()]->setAxisTitle("ROB wordcounts",2);
644 
645  }
646 
647  // SC Histograms
648  if ( folder == "SC" ) {
649  // The plots are per wheel
650  ibooker.setCurrentFolder(topFolder(false) + "FED" + dduID_s);
651  if(mode == 3 || mode ==1) return; //Avoid duplication of Info in FEDIntegrity_EvF
652 
653  // SC data Size
654  histoType = "SCSizeVsROSSize";
655  histoName = "FED" + dduID_s + "_SCSizeVsROSSize";
656  histoTitle = "SC size vs SC (FED " + dduID_s + ")";
657  rosHistos[histoType][code.getSCID()] = ibooker.book2D(histoName,histoTitle,12,1,13,51,-1,50);
658  rosHistos[histoType][code.getSCID()]->setAxisTitle("SC",1);
659 
660  }
661 }
662 
663 
665 
666  bookHistos(ibooker, string("ROS"), code);
667 
668  if(mode < 1)
669  if(getSCInfo)
670  bookHistos(ibooker, string("SC"), code);
671 }
672 
673 // ******************uROS******************** //
674 void DTDataIntegrityTask::bookHistosuROS(DQMStore::IBooker & ibooker, const int fed, const int uRos){
675  string fed_s = to_string(fed);
676  string uRos_s = to_string(uRos);
677  ibooker.setCurrentFolder(topFolder(false) + "FED" + fed_s + "/uROS" + uRos_s);
678 
679  for (int counter=0; counter<3; counter++){
680  string counter_s = to_string(counter);
681  string histoType = "uROSError"+counter_s;
682  int linkDown = counter*24; string linkDown_s = to_string(linkDown);
683  int linkUp = linkDown+23; string linkUp_s = to_string(linkUp);
684  string histoName = "FED" + fed_s + "_" + "uROS" + uRos_s + "_"+histoType;
685  string histoTitle = histoName + " (Link " + linkDown_s +"-"+ linkUp_s + " error summary)";
686  unsigned int keyHisto = (uROSError + counter)*1000 + (fed-FEDIDmin)*100 + (uRos-1);
687  if(mode < 1) // Online only
688  urosHistos[keyHisto] = ibooker.book2D(histoName,histoTitle,11,0,11,24,0,24);
689  else
690  urosHistos[keyHisto] = ibooker.book2D(histoName,histoTitle,5,0,5,24,0,24);
691 
693  // uROS error bins
694  // Placeholders for the moment
695  histo->setBinLabel(1,"Error 1",1);
696  histo->setBinLabel(2,"Error 2",1);
697  histo->setBinLabel(3,"Error 3",1);
698  histo->setBinLabel(4,"Error 4",1);
699  histo->setBinLabel(5,"Not OKFlag",1);
700  if(mode < 1) { //Online only
701  // TDC error bins
702  histo->setBinLabel(6,"TDC Fatal",1);
703  histo->setBinLabel(7,"TDC RO FIFO ov.",1);
704  histo->setBinLabel(8,"TDC L1 buf. ov.",1);
705  histo->setBinLabel(9,"TDC L1A FIFO ov.",1);
706  histo->setBinLabel(10,"TDC hit err.",1);
707  histo->setBinLabel(11,"TDC hit rej.",1);
708  }
709  for (int link=linkDown; link < (linkUp+1); ++link){
710  string link_s = to_string(link);
711  histo->setBinLabel(link-linkDown+1,"Link"+link_s,2);
712  }
713  }
714 
715 
716  if(mode > 1) return;
717 
718  string histoType = "uROSEventLenght";
719  string histoName = "FED" + fed_s + "_uROS" + uRos_s + "_" + "EventLenght";
720  string histoTitle = "Event Lenght (Bytes) FED " + fed_s + " uROS" + uRos_s;
721  unsigned int keyHisto = (uROSEventLenght)*1000 + (fed-FEDIDmin)*100 + (uRos-1);
722  urosHistos[keyHisto] = ibooker.book1D(histoName,histoTitle,101,0,5000);
723 
724  histoType = "uROSAvgEventLenghtvsLumi";
725  histoName = "FED" + fed_s + "_uROS" + uRos_s + "AvgEventLenghtvsLumi";
726  histoTitle = "Event Lenght (Bytes) FED " + fed_s + " uROS" + uRos_s;
727  keyHisto = (fed-FEDIDmin)*100 + (uRos-1);
728  urosTimeHistos[keyHisto] = new DTTimeEvolutionHisto(ibooker,histoName,histoTitle,200,10,true,0);
729 
730  for (int counter=0; counter<3; counter++){
731  string counter_s = to_string(counter);
732  string histoType = "TDCError"+counter_s;
733  int linkDown = counter*24; string linkDown_s = to_string(linkDown);
734  int linkUp = linkDown+23; string linkUp_s = to_string(linkUp);
735  string histoName = "FED" + fed_s + "_" + "uROS" + uRos_s + "_"+histoType;
736  string histoTitle = histoName + " (Link " + linkDown_s +"-"+ linkUp_s + " error summary)";
737  keyHisto = (TDCError+counter)*1000 + (fed-FEDIDmin)*100 + (uRos-1);
738  urosHistos[keyHisto] = ibooker.book2D(histoName,histoTitle,24,0,24,24,0,24);
740  // TDC error bins
741  histo->setBinLabel(1,"Fatal",1);
742  histo->setBinLabel(2,"RO FIFO ov.",1);
743  histo->setBinLabel(3,"L1 buf. ov.",1);
744  histo->setBinLabel(4,"L1A FIFO ov.",1);
745  histo->setBinLabel(5,"hit err.",1);
746  histo->setBinLabel(6,"hit rej.",1);
747  histo->setBinLabel(7,"Fatal",1);
748  histo->setBinLabel(8,"RO FIFO ov.",1);
749  histo->setBinLabel(9,"L1 buf. ov.",1);
750  histo->setBinLabel(10,"L1A FIFO ov.",1);
751  histo->setBinLabel(11,"hit err.",1);
752  histo->setBinLabel(12,"hit rej.",1);
753  histo->setBinLabel(13,"Fatal",1);
754  histo->setBinLabel(14,"RO FIFO ov.",1);
755  histo->setBinLabel(15,"L1 buf. ov.",1);
756  histo->setBinLabel(16,"L1A FIFO ov.",1);
757  histo->setBinLabel(17,"hit err.",1);
758  histo->setBinLabel(18,"hit rej.",1);
759  histo->setBinLabel(19,"Fatal",1);
760  histo->setBinLabel(20,"RO FIFO ov.",1);
761  histo->setBinLabel(21,"L1 buf. ov.",1);
762  histo->setBinLabel(22,"L1A FIFO ov.",1);
763  histo->setBinLabel(23,"hit err.",1);
764  histo->setBinLabel(24,"hit rej.",1);
765 
766  for (int link=linkDown; link < (linkUp+1); ++link){
767  string link_s = to_string(link);
768  histo->setBinLabel(link-linkDown+1,"Link"+link_s,2);
769  }
770  }
771 
772  histoType = "TTSValues";
773  histoName = "FED" + fed_s + "_" + "uROS" + uRos_s + "_" + histoType;
774  keyHisto = TTSValues*1000 + (fed-FEDIDmin)*100 + (uRos-1);
775  urosHistos[keyHisto] = ibooker.book1D(histoName,histoName,8,0,8);
777  histo->setBinLabel(1,"Disconnected",1);
778  histo->setBinLabel(2,"Overflow Warning ",1);
779  histo->setBinLabel(3,"Out of synch",1);
780  histo->setBinLabel(4,"Busy",1);
781  histo->setBinLabel(5,"Ready",1);
782  histo->setBinLabel(6,"Error",1);
783  histo->setBinLabel(7,"Disconnected",1);
784  histo->setBinLabel(8,"Unknown",1);
785 
786 }
787 // ******************End uROS******************** //
788 
789 // ******************uROS******************** //
791 
792  neventsuROS++; // FIXME: implement a counter which makes sense
793 
794  LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
795  << "[DTDataIntegrityTask]: " << neventsuROS << " events analyzed by processuROS" << endl;
796 
797  if(mode == 3 || mode ==1) return; //Avoid duplication of Info in FEDIntegrity_EvF
798 
799  MonitorElement* uROSSummary = nullptr;
800  uROSSummary = summaryHistos["uROSSummary"][fed];
801 
802  MonitorElement* uROSStatus = nullptr;
803  uROSStatus = fedHistos["uROSStatus"][fed];
804 
805  if(!uROSSummary) {
806  LogError("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask") <<
807  "Trying to access non existing ME at FED " << fed <<
808  std::endl;
809  return;
810  }
811 
812  // Summary of all Link errors
813  MonitorElement* uROSError0 = nullptr;
814  MonitorElement* uROSError1 = nullptr;
815  MonitorElement* uROSError2 = nullptr;
816  if(mode <= 2){
817  uROSError0 = urosHistos[(uROSError+0)*1000 + (fed-FEDIDmin)*100 + (uRos-1)];
818  uROSError1 = urosHistos[(uROSError+1)*1000 + (fed-FEDIDmin)*100 + (uRos-1)];
819  uROSError2 = urosHistos[(uROSError+2)*1000 + (fed-FEDIDmin)*100 + (uRos-1)];
820 
821  if ((!uROSError2) || (!uROSError1) || (!uROSError0) ) {
822  LogError("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask") <<
823  "Trying to access non existing ME at uROS " << uRos <<
824  std::endl;
825  return;
826  }
827  }
828 
829  // uROS errors
830  int sumOKs =0 ;
831  for (unsigned int link = 0; link<72; ++link){
832  for (unsigned int flag = 0; flag<5; ++flag){
833  if((data.getokxflag(link)>>flag) & 0x1) { // Undefined Flag 1-4 64bits word for each MTP (12 channels)i
834  if (flag==0) {sumOKs+=1; // Not OK flag
835  flag=5; //move it to the 5th bin
836  }
837  if (link<24) uROSError0->Fill(flag-1,link); //bins start at 1 despite labeling
838  else if (link<48) uROSError1->Fill(flag-1,link-23);
839  else if (link<72) uROSError2->Fill(flag-1,link-47);
840  }
841  }
842  }
843 
844 
845 // Fill the ROSSummary (1 per FED) histo
846  if(sumOKs!=0) uROSSummary->Fill(12, uRos); //bins start at 1 despite labeling
847 // Need to fill bin 13 Ev ID Mismatch?
848 
849 // Global Errors for uROS
850  for (unsigned int flag = 4; flag<16; ++flag){
851  if((data.getuserWord()>>flag) & 0x1 ) {
852  uROSSummary->Fill(flag-4, uRos);
853  uROSStatus->Fill(flag-4, uRos); //duplicated info?
854  }
855  }
856 
857  // ROS error
858  for (unsigned int icounter = 0; icounter<data.geterrors().size(); ++icounter){
859  int link = data.geterrorROBID(icounter);
860  int tdc = data.geterrorTDCID(icounter);
861  int error = data.geterror(icounter);
862  int tdcError_ROSSummary = 0;
863  int tdcError_ROSError = 0;
864  int tdcError_TDCHisto = 0;
865 
866  if(error & 0x4000 ) {
867  LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
868  << " ROS " << uRos << " ROB " << link
869  << " Internal fatal Error 4000 in TDC " << error << endl;
870 
871  tdcError_ROSSummary = 13;
872  tdcError_ROSError = 5;
873  tdcError_TDCHisto = 0;
874 
875  } else if ( error & 0x0249 ) {
876  LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
877  << " ROS " << uRos << " ROB " << link
878  << " TDC FIFO overflow in TDC " << error << endl;
879 
880  tdcError_ROSSummary = 14;
881  tdcError_ROSError = 6;
882  tdcError_TDCHisto = 1;
883 
884  } else if ( error & 0x0492 ) {
885  LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
886  << " ROS " << uRos << " ROB " << link
887  << " TDC L1 buffer overflow in TDC " << error << endl;
888 
889  tdcError_ROSSummary = 15;
890  tdcError_ROSError = 7;
891  tdcError_TDCHisto = 2;
892 
893  } else if ( error & 0x2000 ) {
894  LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
895  << " ROS " << uRos << " ROB " << link
896  << " TDC L1A FIFO overflow in TDC " << error << endl;
897 
898  tdcError_ROSSummary = 16;
899  tdcError_ROSError = 8;
900  tdcError_TDCHisto = 3;
901 
902  } else if ( error & 0x0924 ) {
903  LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
904  << " uROS " << uRos << " ROB " << link
905  << " TDC hit error in TDC " << error << endl;
906 
907  tdcError_ROSSummary = 17;
908  tdcError_ROSError = 9;
909  tdcError_TDCHisto = 4;
910 
911  } else if ( error & 0x1000 ) {
912  LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
913  << " uROS " << uRos << " ROB " << link
914  << " TDC hit rejected in TDC " << error << endl;
915 
916  tdcError_ROSSummary = 18;
917  tdcError_ROSError = 10;
918  tdcError_TDCHisto = 5;
919 
920  } else {
921  LogWarning("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
922  << " TDC error code not known " << error << endl;
923  }
924 
925  uROSSummary->Fill(tdcError_ROSSummary,uRos);
926 
927  if(mode<=2){
928  if (link<24) uROSError0->Fill(tdcError_ROSError,link);
929  else if (link<48) uROSError1->Fill(tdcError_ROSError,link-23);
930  else if (link<72) uROSError2->Fill(tdcError_ROSError,link-47);
931 
932  if(mode<=1){
933  if (link<24) urosHistos[(TDCError+0)*1000 + (fed-FEDIDmin)*100 + (uRos-1)]->Fill(tdcError_TDCHisto+6*(tdc-1),link);
934  else if (link<48) urosHistos[(TDCError+1)*1000 + (fed-FEDIDmin)*100 + (uRos-1)]->Fill(tdcError_TDCHisto+6*(tdc-1),link-23);
935  else if (link<72) urosHistos[(TDCError+2)*1000 + (fed-FEDIDmin)*100 + (uRos-1)]->Fill(tdcError_TDCHisto+6*(tdc-1),link-47);
936  }
937  }
938  } //loop on errors
939 
940 
941  // 1D histograms for TTS values per uROS
942  int ttsCodeValue = -1;
943 
944  int value = (data.getuserWord() & 0xF);
945  switch(value) {
946  case 0:{ //disconnected
947  ttsCodeValue = 0;
948  break;
949  }
950  case 1:{ //warning overflow
951  ttsCodeValue = 1;
952  break;
953  }
954  case 2:{ //out of sinch
955  ttsCodeValue = 2;
956  break;
957  }
958  case 4:{ //busy
959  ttsCodeValue = 3;
960  break;
961  }
962  case 8:{ //ready
963  ttsCodeValue = 4;
964  break;
965  }
966  case 12:{ //error
967  ttsCodeValue = 5;
968  break;
969  }
970  case 15:{ //disconnected
971  ttsCodeValue = 6;
972  break;
973  }
974  default:{
975  LogError("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
976  <<"[DTDataIntegrityTask] FED User control: wrong TTS value "<< value << " in FED " << fed << " uROS "<< uRos<< endl; //FIXME
977  ttsCodeValue = 7;
978  }
979  }
980  if(mode < 1) {
981  urosHistos[TTSValues*1000 + (fed-FEDIDmin)*100 + (uRos-1)]->Fill(ttsCodeValue);
982 
983  // Plot the event lenght //NOHLT
984  int uRosEventLenght = (data.gettrailer() & 0xFFFFF)*8;
985  urosTimeHistos[(fed-FEDIDmin)*100 + (uRos-1)]->accumulateValueTimeSlot(uRosEventLenght);
986 
987  if(uRosEventLenght > 5000) uRosEventLenght = 5000;
988  urosHistos[uROSEventLenght*1000 + (fed-FEDIDmin)*100 + (uRos-1)]->Fill(uRosEventLenght);
989  }
990 
991 }
992 
993 // *****************End uROS ******************//
994 
996 
997  neventsuROS++; // FIXME: implement a counter which makes sense
998 
999  LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
1000  << "[DTDataIntegrityTask]: " << neventsuROS << " events analyzed by processROS25" << endl;
1001 
1002  // The ID of the RO board (used to map the histos)
1003  DTROChainCoding code;
1004  code.setDDU(ddu);
1005  code.setROS(ros);
1006 
1007  if(mode == 3 || mode ==1) return; //Avoid duplication of Info in FEDIntegrity_EvF
1008 
1009  MonitorElement* ROSSummary = summaryHistos["ROSSummary"][code.getDDUID()];
1010 
1011  // Summary of all ROB errors
1012  MonitorElement* ROSError = nullptr;
1013  if(mode <= 2) ROSError = rosHistos["ROSError"][code.getROSID()];
1014 
1015  if ( (mode<=2) && (!ROSError) ) {
1016  LogError("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask") <<
1017  "Trying to access non existing ME at ROSID " << code.getROSID() <<
1018  std::endl;
1019  return;
1020  }
1021 
1022  // L1A ids to be checked against FED one
1023  rosL1AIdsPerFED[ddu].insert(data.getROSHeader().TTCEventCounter());
1024 
1025  // ROS errors
1026 
1027 
1028  // check for TPX errors
1029  if (data.getROSTrailer().TPX() != 0) {
1030  LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask") << " TXP error en ROS "
1031  << code.getROS() << endl;
1032  ROSSummary->Fill(9,code.getROS());
1033  }
1034 
1035  // L1 Buffer almost full (non-critical error!)
1036  if(data.getROSTrailer().l1AFifoOccupancy() > 31) {
1037  ROSSummary->Fill(10,code.getROS());
1038  }
1039 
1040 
1041  for (vector<DTROSErrorWord>::const_iterator error_it = data.getROSErrors().begin();
1042  error_it != data.getROSErrors().end(); error_it++) { // Loop over ROS error words
1043 
1044  LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask") << " Error in ROS " << code.getROS()
1045  << " ROB Id " << (*error_it).robID()
1046  << " Error type " << (*error_it).errorType() << endl;
1047 
1048  // Fill the ROSSummary (1 per FED) histo
1049  ROSSummary->Fill((*error_it).errorType(), code.getROS());
1050  if((*error_it).errorType() <= 11) { // set error flag
1051  eventErrorFlag = true;
1052  }
1053 
1054  if(mode <= 2) {
1055  // Fill the ROB Summary (1 per ROS) histo
1056  if ((*error_it).robID() != 31) {
1057  ROSError->Fill((*error_it).errorType(),(*error_it).robID());
1058  }
1059  else if ((*error_it).errorType() == 4) {
1060  vector<int> channelBins;
1061  channelsInROS((*error_it).cerosID(),channelBins);
1062  vector<int>::const_iterator channelIt = channelBins.begin();
1063  vector<int>::const_iterator channelEnd = channelBins.end();
1064  for(;channelIt!=channelEnd;++channelIt) {
1065  ROSError->Fill(4,(*channelIt));
1066  }
1067  }
1068  }
1069  }
1070 
1071 
1072  int ROSDebug_BunchNumber = -1;
1073 
1074  for (vector<DTROSDebugWord>::const_iterator debug_it = data.getROSDebugs().begin();
1075  debug_it != data.getROSDebugs().end(); debug_it++) { // Loop over ROS debug words
1076 
1077  int debugROSSummary = 0;
1078  int debugROSError = 0;
1079  vector<int> debugBins;
1080  bool hasEvIdMis = false;
1081  vector<int> evIdMisBins;
1082 
1083  if ((*debug_it).debugType() == 0 ) {
1084  ROSDebug_BunchNumber = (*debug_it).debugMessage();
1085  } else if ((*debug_it).debugType() == 1 ) {
1086  // not used
1087  // ROSDebug_BcntResCntLow = (*debug_it).debugMessage();
1088  } else if ((*debug_it).debugType() == 2 ) {
1089  // not used
1090  // ROSDebug_BcntResCntHigh = (*debug_it).debugMessage();
1091  } else if ((*debug_it).debugType() == 3) {
1092  if ((*debug_it).dontRead()){
1093  debugROSSummary = 11;
1094  debugROSError = 8;
1095  if (mode <= 2) channelsInCEROS((*debug_it).cerosIdCerosStatus(),(*debug_it).dontRead(),debugBins);
1096  } if ((*debug_it).evIdMis()){
1097  hasEvIdMis = true;
1098  if (mode <= 2) channelsInCEROS((*debug_it).cerosIdCerosStatus(),(*debug_it).evIdMis(),evIdMisBins);
1099  }
1100  } else if ((*debug_it).debugType() == 4 &&
1101  (*debug_it).cerosIdRosStatus()){
1102  debugROSSummary = 13;
1103  debugROSError = 10;
1104  if (mode <= 2) channelsInROS((*debug_it).cerosIdRosStatus(),debugBins);
1105  }
1106 
1107  if (debugROSSummary) {
1108  ROSSummary->Fill(debugROSSummary,code.getROS());
1109  if (mode <= 2) {
1110  vector<int>::const_iterator channelIt = debugBins.begin();
1111  vector<int>::const_iterator channelEnd = debugBins.end();
1112  for (;channelIt!=channelEnd;++channelIt) {
1113  ROSError->Fill(debugROSError,(*channelIt));
1114  }
1115  }
1116  }
1117 
1118  if (hasEvIdMis) {
1119  ROSSummary->Fill(12,code.getROS());
1120  if (mode <= 2) {
1121  vector<int>::const_iterator channelIt = evIdMisBins.begin();
1122  vector<int>::const_iterator channelEnd = evIdMisBins.end();
1123  for (;channelIt!=channelEnd;++channelIt) {
1124  ROSError->Fill(9,(*channelIt));
1125  }
1126  }
1127  }
1128 
1129  }
1130 
1131  // ROB Group Header
1132  // Check the BX of the ROB headers against the BX of the ROS
1133  for (vector<DTROBHeader>::const_iterator rob_it = data.getROBHeaders().begin();
1134  rob_it != data.getROBHeaders().end(); rob_it++) { // loop over ROB headers
1135 
1136  code.setROB((*rob_it).first);
1137  DTROBHeaderWord robheader = (*rob_it).second;
1138 
1139  rosBxIdsPerFED[ddu].insert(ROSDebug_BunchNumber);
1140 
1141  if (robheader.bunchID() != ROSDebug_BunchNumber) {
1142  // fill ROS Summary plot
1143  ROSSummary->Fill(8,code.getROS());
1144  eventErrorFlag = true;
1145 
1146  // fill ROB Summary plot for that particular ROS
1147  if(mode <= 2) ROSError->Fill(7,robheader.robID());
1148  }
1149  }
1150 
1151 
1152  if(mode < 1) { // produce only when not in HLT or SM
1153  // ROB Trailer
1154  for (vector<DTROBTrailerWord>::const_iterator robt_it = data.getROBTrailers().begin();
1155  robt_it != data.getROBTrailers().end(); robt_it++) { // loop over ROB trailers
1156  float wCount = (*robt_it).wordCount()<100. ? (*robt_it).wordCount() : 99.9;
1157  rosHistos["ROB_mean"][code.getROSID()]->Fill((*robt_it).robID(),wCount);
1158  }
1159 
1160  // Plot the event lenght //NOHLT
1161  int rosEventLenght = data.getROSTrailer().EventWordCount()*4;
1162  rosTimeHistos["ROSAvgEventLenghtvsLumi"][code.getROSID()]->accumulateValueTimeSlot(rosEventLenght);
1163 
1164  if(rosEventLenght > 1600) rosEventLenght = 1600;
1165  rosHistos["ROSEventLenght"][code.getROSID()]->Fill(rosEventLenght);
1166  }
1167 
1168 
1169  // TDC Data
1170  for (vector<DTTDCData>::const_iterator tdc_it = data.getTDCData().begin();
1171  tdc_it != data.getTDCData().end(); tdc_it++) { // loop over TDC data
1172 
1173  DTTDCMeasurementWord tdcDatum = (*tdc_it).second;
1174 
1175  if ( tdcDatum.PC() !=0) {
1176  LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
1177  << " PC error in ROS " << code.getROS() << " TDC " << (*tdc_it).first << endl;
1178  // fill ROS Summary plot
1179  ROSSummary->Fill(7,code.getROS());
1180 
1181  eventErrorFlag = true;
1182 
1183  // fill ROB Summary plot for that particular ROS
1184  if(mode <= 2) ROSError->Fill(6,(*tdc_it).first);
1185  }
1186  }
1187 
1188  // TDC Error
1189  for (vector<DTTDCError>::const_iterator tdc_it = data.getTDCError().begin();
1190  tdc_it != data.getTDCError().end(); tdc_it++) { // loop over TDC errors
1191 
1192  code.setROB((*tdc_it).first);
1193 
1194  int tdcError_ROSSummary = 0;
1195  int tdcError_ROSError = 0;
1196  int tdcError_TDCHisto = 0;
1197 
1198  if(((*tdc_it).second).tdcError() & 0x4000 ) {
1199  LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
1200  << " ROS " << code.getROS() << " ROB " << code.getROB()
1201  << " Internal fatal Error 4000 in TDC " << (*tdc_it).first << endl;
1202 
1203  tdcError_ROSSummary = 14;
1204  tdcError_ROSError = 11;
1205  tdcError_TDCHisto = 0;
1206 
1207  } else if ( ((*tdc_it).second).tdcError() & 0x0249 ) {
1208  LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
1209  << " ROS " << code.getROS() << " ROB " << code.getROB()
1210  << " TDC FIFO overflow in TDC " << (*tdc_it).first << endl;
1211 
1212  tdcError_ROSSummary = 15;
1213  tdcError_ROSError = 12;
1214  tdcError_TDCHisto = 1;
1215 
1216  } else if ( ((*tdc_it).second).tdcError() & 0x0492 ) {
1217  LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
1218  << " ROS " << code.getROS() << " ROB " << code.getROB()
1219  << " TDC L1 buffer overflow in TDC " << (*tdc_it).first << endl;
1220 
1221  tdcError_ROSSummary = 16;
1222  tdcError_ROSError = 13;
1223  tdcError_TDCHisto = 2;
1224 
1225  } else if ( ((*tdc_it).second).tdcError() & 0x2000 ) {
1226  LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
1227  << " ROS " << code.getROS() << " ROB " << code.getROB()
1228  << " TDC L1A FIFO overflow in TDC " << (*tdc_it).first << endl;
1229 
1230  tdcError_ROSSummary = 17;
1231  tdcError_ROSError = 14;
1232  tdcError_TDCHisto = 3;
1233 
1234  } else if ( ((*tdc_it).second).tdcError() & 0x0924 ) {
1235  LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
1236  << " ROS " << code.getROS() << " ROB " << code.getROB()
1237  << " TDC hit error in TDC " << (*tdc_it).first << endl;
1238 
1239  tdcError_ROSSummary = 18;
1240  tdcError_ROSError = 15;
1241  tdcError_TDCHisto = 4;
1242 
1243  } else if ( ((*tdc_it).second).tdcError() & 0x1000 ) {
1244  LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
1245  << " ROS " << code.getROS() << " ROB " << code.getROB()
1246  << " TDC hit rejected in TDC " << (*tdc_it).first << endl;
1247 
1248  tdcError_ROSSummary = 19;
1249  tdcError_ROSError = 16;
1250  tdcError_TDCHisto = 5;
1251 
1252  } else {
1253  LogWarning("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
1254  << " TDC error code not known " << ((*tdc_it).second).tdcError() << endl;
1255  }
1256 
1257  ROSSummary->Fill(tdcError_ROSSummary,code.getROS());
1258 
1259  if(tdcError_ROSSummary <= 15) {
1260  eventErrorFlag = true;
1261  }
1262 
1263  if(mode <= 2) {
1264  ROSError->Fill(tdcError_ROSError,(*tdc_it).first);
1265  if(mode <= 1)
1266  rosHistos["TDCError"][code.getROSID()]->Fill(tdcError_TDCHisto+6*((*tdc_it).second).tdcID(),(*tdc_it).first);
1267  }
1268  }
1269 
1270  // Read SC data
1271  if (mode < 1 && getSCInfo) {
1272  // NumberOf16bitWords counts the # of words + 1 subheader
1273  // the SC includes the SC "private header" and the ROS header and trailer (= NumberOf16bitWords +3)
1274  rosHistos["SCSizeVsROSSize"][code.getSCID()]->Fill(ros,data.getSCTrailer().wordCount());
1275 
1276  }
1277 }
1278 
1279 // ******************uROS******************** //
1281 
1282  neventsFED++;
1283  if (neventsFED%1000 == 0)
1284  LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
1285  << "[DTDataIntegrityTask]: " << neventsFED << " events analyzed by processFED" << endl;
1286 
1287  if(fed < FEDIDmin || fed > FEDIDmax) return;
1288 
1289  hFEDEntry->Fill(fed);
1290 
1291  if(mode == 3 || mode ==1) return; //Avoid duplication of Info in FEDIntegrity_EvF
1292 
1293  //1D HISTOS: EVENT LENGHT from trailer
1294  int fedEvtLenght = data.getevtlgth()*8; //1 word = 8 bytes
1295  // if(fedEvtLenght > 16000) fedEvtLenght = 16000; // overflow bin
1296  fedHistos["EventLenght"][fed]->Fill(fedEvtLenght);
1297 
1298  if(mode > 1) return;
1299 
1300  fedTimeHistos["FEDAvgEvLenghtvsLumi"][fed]->accumulateValueTimeSlot(fedEvtLenght);
1301 
1302  // fill the distribution of the BX ids
1303  fedHistos["BXID"][fed]->Fill(data.getBXId());
1304 
1305  // size of the list of ROS in the Read-Out
1306  fedHistos["uROSList"][fed]->Fill(data.getnslots());
1307 
1308  // Fill the status summary of the TTS
1309 
1310  //1D HISTO WITH TTS VALUES form trailer (7 bins = 7 values)
1311 
1312  int ttsCodeValue = -1;
1313  int value = data.getTTS();
1314  switch(value) {
1315  case 0:{ //disconnected
1316  ttsCodeValue = 0;
1317  break;
1318  }
1319  case 1:{ //warning overflow
1320  ttsCodeValue = 1;
1321  break;
1322  }
1323  case 2:{ //out of sinch
1324  ttsCodeValue = 2;
1325  break;
1326  }
1327  case 4:{ //busy
1328  ttsCodeValue = 3;
1329  break;
1330  }
1331  case 8:{ //ready
1332  ttsCodeValue = 4;
1333  break;
1334  }
1335  case 12:{ //error
1336  ttsCodeValue = 5;
1337  break;
1338  }
1339  case 15:{ //disconnected
1340  ttsCodeValue = 6;
1341  break;
1342  }
1343  default:{
1344  LogError("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
1345  <<"[DTDataIntegrityTask] FED TTS control: wrong TTS value "<< value << " in FED "<< fed<< endl;
1346  ttsCodeValue = 7;
1347  }
1348  }
1349  if(mode < 1) fedHistos["TTSValues"][fed]->Fill(ttsCodeValue);
1350 
1351 }
1352 // *****************End uROS ******************//
1353 
1354 
1355 void DTDataIntegrityTask::processFED(DTDDUData & data, const std::vector<DTROS25Data> & rosData, int ddu) {
1356 
1357  neventsFED++;
1358  if (neventsFED%1000 == 0)
1359  LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
1360  << "[DTDataIntegrityTask]: " << neventsFED << " events analyzed by processFED" << endl;
1361 
1362 
1363  DTROChainCoding code;
1364  code.setDDU(ddu);
1365  if(code.getDDUID() < FEDIDmin || code.getDDUID() > FEDIDmax) return;
1366 
1367  hFEDEntry->Fill(code.getDDUID());
1368 
1369  FEDTrailer trailer = data.getDDUTrailer();
1370  FEDHeader header = data.getDDUHeader();
1371 
1372  // check consistency of header and trailer
1373  if(!header.check()) {
1374  // error code 7
1375  hFEDFatal->Fill(code.getDDUID());
1376  hCorruptionSummary->Fill(code.getDDUID(), 7);
1377  }
1378 
1379  if(!trailer.check()) {
1380  // error code 8
1381  hFEDFatal->Fill(code.getDDUID());
1382  hCorruptionSummary->Fill(code.getDDUID(), 8);
1383  }
1384 
1385  // check CRC error bit set by DAQ before sending data on SLink
1386  if(data.crcErrorBit()) {
1387  // error code 6
1388  hFEDFatal->Fill(code.getDDUID());
1389  hCorruptionSummary->Fill(code.getDDUID(), 6);
1390  }
1391 
1392  if(mode == 3 || mode ==1) return; //Avoid duplication of Info in FEDIntegrity_EvF
1393 
1394  const DTDDUSecondStatusWord& secondWord = data.getSecondStatusWord();
1395 
1396  // Fill the status summary of the TTS
1397 
1398  //1D HISTO WITH TTS VALUES form trailer (7 bins = 7 values)
1399  int ttsCodeValue = -1;
1400  int ttsSummaryBin = -1;
1401 
1402  switch(trailer.ttsBits()) {
1403  case 0:{ //disconnected
1404  ttsCodeValue = 0;
1405  break;
1406  }
1407  case 1:{ //warning overflow
1408  ttsCodeValue = 1;
1409  if(secondWord.warningROSPAF()) { // ROS PAF
1410  ttsSummaryBin = 1;
1411  } else { // DDU PAF
1412  ttsSummaryBin = 2;
1413  }
1414 
1415  break;
1416  }
1417  case 2:{ //out of sinch
1418  ttsCodeValue = 2;
1419  bool knownOrigin = false;
1420  if(secondWord.outOfSynchROSError()) {// ROS Error
1421  ttsSummaryBin = 7;
1422  knownOrigin = true;
1423  }
1424  if(secondWord.l1AIDError()) {// L1A Mism.
1425  ttsSummaryBin = 6;
1426  knownOrigin = true;
1427  }
1428  if(secondWord.bxIDError()) {// BX Mism.
1429  ttsSummaryBin = 8;
1430  knownOrigin = true;
1431  }
1432  if(secondWord.outputFifoFull() || secondWord.inputFifoFull() || secondWord.fifoFull()) { // DDU Full
1433  ttsSummaryBin = 5;
1434  knownOrigin = true;
1435  }
1436  if(!knownOrigin) ttsSummaryBin = 9; // Error in DDU logic
1437 
1438  break;
1439  }
1440  case 4:{ //busy
1441  ttsCodeValue = 3;
1442  bool knownOrigin = false;
1443  if(secondWord.busyROSPAF()) { // ROS PAF
1444  ttsSummaryBin = 3;
1445  knownOrigin = true;
1446  }
1447  if(secondWord.outputFifoAlmostFull() || secondWord.inputFifoAlmostFull() || secondWord.fifoAlmostFull() ){ // DDU PAF
1448  ttsSummaryBin = 4;
1449  knownOrigin = true;
1450  }
1451  if(!knownOrigin) ttsSummaryBin = 9; // Error in DDU logic
1452  break;
1453  }
1454  case 8:{ //ready
1455  ttsCodeValue = 4;
1456  break;
1457  }
1458  case 12:{ //error
1459  ttsCodeValue = 5;
1460  break;
1461  }
1462  case 16:{ //disconnected
1463  ttsCodeValue = 6;
1464  break;
1465  }
1466  default:{
1467  LogError("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
1468  <<"[DTDataIntegrityTask] DDU control: wrong TTS value "<<trailer.ttsBits()<<endl;
1469  ttsCodeValue = 7;
1470  }
1471  }
1472  if(mode < 1) fedHistos["TTSValues"][code.getDDUID()]->Fill(ttsCodeValue);
1473  if(ttsSummaryBin != -1) {
1474  hTTSSummary->Fill(ddu, ttsSummaryBin);
1475  }
1476 
1477 
1478  //2D HISTO: ROS VS STATUS (8 BIT = 8 BIN) from 1st-2nd status words (9th BIN FROM LIST OF ROS in 2nd status word)
1479  MonitorElement* hROSStatus = fedHistos["ROSStatus"][code.getDDUID()];
1480  //1D HISTO: NUMBER OF ROS IN THE EVENTS from 2nd status word
1481 
1482  int rosList = secondWord.rosList();
1483  set<int> rosPositions;
1484  for(int i=0;i<12;i++) {
1485  if(rosList & 0x1) {
1486  rosPositions.insert(i);
1487  //9th BIN FROM LIST OF ROS in 2nd status word
1488  if(mode <= 2) hROSStatus->Fill(8,i,1);
1489  }
1490  rosList >>= 1;
1491  }
1492 
1493  int channel=0;
1494  for (vector<DTDDUFirstStatusWord>::const_iterator fsw_it = data.getFirstStatusWord().begin();
1495  fsw_it != data.getFirstStatusWord().end(); fsw_it++) {
1496  // assuming association one-to-one between DDU channel and ROS
1497  if(mode <= 2) {
1498  hROSStatus->Fill(0,channel,(*fsw_it).channelEnabled());
1499  hROSStatus->Fill(1,channel,(*fsw_it).timeout());
1500  hROSStatus->Fill(2,channel,(*fsw_it).eventTrailerLost());
1501  hROSStatus->Fill(3,channel,(*fsw_it).opticalFiberSignalLost());
1502  hROSStatus->Fill(4,channel,(*fsw_it).tlkPropagationError());
1503  hROSStatus->Fill(5,channel,(*fsw_it).tlkPatternError());
1504  hROSStatus->Fill(6,channel,(*fsw_it).tlkSignalLost());
1505  hROSStatus->Fill(7,channel,(*fsw_it).errorFromROS());
1506  }
1507  // check that the enabled channel was also in the read-out
1508  if((*fsw_it).channelEnabled() == 1 &&
1509  rosPositions.find(channel) == rosPositions.end()) {
1510  if(mode <= 2) hROSStatus->Fill(9,channel,1);
1511  // error code 1
1512  hFEDFatal->Fill(code.getDDUID());
1513  hCorruptionSummary->Fill(code.getDDUID(), 1);
1514  }
1515  channel++;
1516  }
1517 
1518 
1519  // ---------------------------------------------------------------------
1520  // cross checks between FED and ROS data
1521  // check the BX ID against the ROSs
1522  set<int> rosBXIds = rosBxIdsPerFED[ddu];
1523  if((rosBXIds.size() > 1 || rosBXIds.find(header.bxID()) == rosBXIds.end()) && !rosBXIds.empty() ) { // in this case look for faulty ROSs
1524  for(vector<DTROS25Data>::const_iterator rosControlData = rosData.begin();
1525  rosControlData != rosData.end(); ++rosControlData) { // loop over the ROS data
1526  for (vector<DTROSDebugWord>::const_iterator debug_it = (*rosControlData).getROSDebugs().begin();
1527  debug_it != (*rosControlData).getROSDebugs().end(); debug_it++) { // Loop over ROS debug words
1528  if ((*debug_it).debugType() == 0 && (*debug_it).debugMessage() != header.bxID()) { // check the BX
1529  int ros = (*rosControlData).getROSID();
1530  // fill the error bin
1531  if(mode <= 2) hROSStatus->Fill(11,ros-1);
1532  // error code 2
1533  hFEDFatal->Fill(code.getDDUID());
1534  hCorruptionSummary->Fill(code.getDDUID(), 2);
1535  }
1536  }
1537  }
1538  }
1539 
1540  // check the BX ID against other FEDs
1541  fedBXIds.insert(header.bxID());
1542  if(fedBXIds.size() != 1) {
1543  LogWarning("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
1544  << "ERROR: FED " << ddu << " BX ID different from other feds: " << header.bxID() << endl;
1545  // error code 3
1546  hFEDFatal->Fill(code.getDDUID());
1547  hCorruptionSummary->Fill(code.getDDUID(), 3);
1548  }
1549 
1550 
1551  // check the L1A ID against the ROSs
1552  set<int> rosL1AIds = rosL1AIdsPerFED[ddu];
1553  if((rosL1AIds.size() > 1 || rosL1AIds.find(header.lvl1ID()-1) == rosL1AIds.end()) && !rosL1AIds.empty() ){ // in this case look for faulty ROSs
1554  //If L1A_ID error identify which ROS has wrong L1A
1555  for (vector<DTROS25Data>::const_iterator rosControlData = rosData.begin();
1556  rosControlData != rosData.end(); rosControlData++) { // loop over the ROS data
1557  unsigned int ROSHeader_TTCCount = ((*rosControlData).getROSHeader().TTCEventCounter() + 1) % 0x1000000; // fix comparison in case of last counting bin in ROS /first one in DDU
1558  if( ROSHeader_TTCCount != header.lvl1ID() ) {
1559  int ros = (*rosControlData).getROSID();
1560  if(mode <= 2) hROSStatus->Fill(10,ros-1);
1561  // error code 4
1562  hFEDFatal->Fill(code.getDDUID());
1563  hCorruptionSummary->Fill(code.getDDUID(), 4);
1564  }
1565  }
1566  }
1567 
1568  //1D HISTOS: EVENT LENGHT from trailer
1569  int fedEvtLenght = trailer.fragmentLength()*8;
1570  // if(fedEvtLenght > 16000) fedEvtLenght = 16000; // overflow bin
1571  fedHistos["EventLenght"][code.getDDUID()]->Fill(fedEvtLenght);
1572 
1573  if(mode > 1) return;
1574 
1575  fedTimeHistos["FEDAvgEvLenghtvsLumi"][code.getDDUID()]->accumulateValueTimeSlot(fedEvtLenght);
1576 
1577  // size of the list of ROS in the Read-Out
1578  fedHistos["ROSList"][code.getDDUID()]->Fill(rosPositions.size());
1579 
1580 
1581  //2D HISTO: FIFO STATUS from 2nd status word
1582  MonitorElement *hFIFOStatus = fedHistos["FIFOStatus"][code.getDDUID()];
1583  int inputFifoFull = secondWord.inputFifoFull();
1584  int inputFifoAlmostFull = secondWord.inputFifoAlmostFull();
1585  int fifoFull = secondWord.fifoFull();
1586  int fifoAlmostFull = secondWord.fifoAlmostFull();
1587  int outputFifoFull = secondWord.outputFifoFull();
1588  int outputFifoAlmostFull = secondWord.outputFifoAlmostFull();
1589  for(int i=0;i<3;i++){
1590  if(inputFifoFull & 0x1){
1591  hFIFOStatus->Fill(i,0);
1592  }
1593  if(inputFifoAlmostFull & 0x1){
1594  hFIFOStatus->Fill(i,1);
1595  }
1596  if(fifoFull & 0x1){
1597  hFIFOStatus->Fill(3+i,0);
1598  }
1599  if(fifoAlmostFull & 0x1){
1600  hFIFOStatus->Fill(3+i,1);
1601  }
1602  if(!(inputFifoFull & 0x1) && !(inputFifoAlmostFull & 0x1)){
1603  hFIFOStatus->Fill(i,2);
1604  }
1605  if(!(fifoFull & 0x1) && !(fifoAlmostFull & 0x1)){
1606  hFIFOStatus->Fill(3+i,2);
1607  }
1608  inputFifoFull >>= 1;
1609  inputFifoAlmostFull >>= 1;
1610  fifoFull >>= 1;
1611  fifoAlmostFull >>= 1;
1612  }
1613 
1614  if(outputFifoFull){
1615  hFIFOStatus->Fill(6,0);
1616  }
1617  if(outputFifoAlmostFull){
1618  hFIFOStatus->Fill(6,1);
1619  }
1620  if(!outputFifoFull && !outputFifoAlmostFull){
1621  hFIFOStatus->Fill(6,2);
1622  }
1623 
1624  //1D HISTO: EVENT TYPE from header
1625  fedHistos["EventType"][code.getDDUID()]->Fill(header.triggerType());
1626 
1627  // fill the distribution of the BX ids
1628  fedHistos["BXID"][code.getDDUID()]->Fill(header.bxID());
1629 
1630 }
1631 
1633  return eventErrorFlag;
1634 }
1635 
1636 
1637 // log number of times the payload of each fed is unpacked
1639  hFEDEntry->Fill(dduID);
1640 }
1641 
1642 
1643 
1644 // log number of times the payload of each fed is skipped (no ROS inside)
1646  hFEDFatal->Fill(dduID);
1647 }
1648 
1649 
1650 
1651 // log number of times the payload of each fed is partially skipped (some ROS skipped)
1653  hFEDNonFatal->Fill(dduID);
1654 }
1655 
1656 std::string DTDataIntegrityTask::topFolder(bool isFEDIntegrity) const {
1657 
1658  string folder = isFEDIntegrity ? fedIntegrityFolder : "DT/00-DataIntegrity/";
1659 
1660  if (mode == 0 || mode == 2)
1661  folder = "DT/00-DataIntegrity/"; //Move everything from FEDIntegrity except for SM and HLT modes
1662 
1663  return folder;
1664 
1665 }
1666 
1667 void DTDataIntegrityTask::channelsInCEROS(int cerosId, int chMask, vector<int>& channels ){
1668  for (int iCh=0; iCh<6;++iCh) {
1669  if ((chMask >> iCh) & 0x1){
1670  channels.push_back(cerosId*6+iCh);
1671  }
1672  }
1673  return;
1674 }
1675 
1676 void DTDataIntegrityTask::channelsInROS(int cerosMask, vector<int>& channels){
1677  for (int iCeros=0; iCeros<5;++iCeros) {
1678  if ((cerosMask >> iCeros) & 0x1){
1679  for (int iCh=0; iCh<6;++iCh) {
1680  channels.push_back(iCeros*6+iCh);
1681  }
1682  }
1683  }
1684  return;
1685 }
1686 
1688 
1689  nEventsLS = 0;
1690 
1691 }
1692 
1694 
1695  int lumiBlock = ls.luminosityBlock();
1696 
1697  if (checkUros){
1698  map<string, map<int, DTTimeEvolutionHisto*> >::iterator fedIt = fedTimeHistos.begin();
1699  map<string, map<int, DTTimeEvolutionHisto*> >::iterator fedEnd = fedTimeHistos.end();
1700  for(; fedIt!=fedEnd; ++fedIt) {
1701  map<int, DTTimeEvolutionHisto*>::iterator histoIt = fedIt->second.begin();
1702  map<int, DTTimeEvolutionHisto*>::iterator histoEnd = fedIt->second.end();
1703  for(; histoIt!=histoEnd; ++histoIt) {
1704  histoIt->second->updateTimeSlot(lumiBlock,nEventsLS);
1705  }
1706  }
1707 
1708  map<unsigned int, DTTimeEvolutionHisto*>::iterator urosIt = urosTimeHistos.begin();
1709  map<unsigned int, DTTimeEvolutionHisto*>::iterator urosEnd = urosTimeHistos.end();
1710  for(; urosIt!=urosEnd; ++urosIt) {
1711  urosIt->second->updateTimeSlot(lumiBlock,nEventsLS);
1712  }
1713 
1714  }//uROS starting on 2018
1715  else{
1716  map<string, map<int, DTTimeEvolutionHisto*> >::iterator dduIt = fedTimeHistos.begin();
1717  map<string, map<int, DTTimeEvolutionHisto*> >::iterator dduEnd = fedTimeHistos.end();
1718  for(; dduIt!=dduEnd; ++dduIt) {
1719  map<int, DTTimeEvolutionHisto*>::iterator histoIt = dduIt->second.begin();
1720  map<int, DTTimeEvolutionHisto*>::iterator histoEnd = dduIt->second.end();
1721  for(; histoIt!=histoEnd; ++histoIt) {
1722  histoIt->second->updateTimeSlot(lumiBlock,nEventsLS);
1723  }
1724  }
1725 
1726  map<string, map<int, DTTimeEvolutionHisto*> >::iterator rosIt = rosTimeHistos.begin();
1727  map<string, map<int, DTTimeEvolutionHisto*> >::iterator rosEnd = rosTimeHistos.end();
1728  for(; rosIt!=rosEnd; ++rosIt) {
1729  map<int, DTTimeEvolutionHisto*>::iterator histoIt = rosIt->second.begin();
1730  map<int, DTTimeEvolutionHisto*>::iterator histoEnd = rosIt->second.end();
1731  for(; histoIt!=histoEnd; ++histoIt) {
1732  histoIt->second->updateTimeSlot(lumiBlock,nEventsLS);
1733  }
1734  }
1735  }//ROS Legacy
1736 }
1737 
1739 {
1740  nevents++;
1742 
1743  nEventsLS++;
1744 
1745  LogTrace("DTRawToDigi|TDQM|DTMonitorModule|DTDataIntegrityTask") << "[DTDataIntegrityTask]: preProcessEvent" <<endl;
1746 
1747  if (checkUros){ //uROS starting on 2018
1748  // Digi collection
1750  e.getByToken(fedToken, fedCol);
1751  DTuROSFEDData fedData;
1752  DTuROSROSData urosData;
1753 
1754  if(fedCol.isValid()){
1755  for(unsigned int j=0; j <fedCol->size();++j){
1756  fedData = fedCol->at(j);
1757  int fed = fedData.getfed(); //argument should be void
1758  if (fed>FEDIDmax || fed<FEDIDmin) {
1759  LogError("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask") << "[DTDataIntegrityTask]: analyze, FED ID " << fed <<" not expected." << endl;
1760  continue;
1761  }
1762  processFED(fedData, fed);
1763 
1764  for(int slot=1; slot<=DOCESLOTS; ++slot)
1765  {
1766  urosData = fedData.getuROS(slot);
1767  if(fedData.getslotsize(slot)==0 || urosData.getslot()==-1) continue;
1768  processuROS(urosData,fed,slot);
1769  }
1770  }
1771  }
1772  } // checkUros
1773  else{ //Legacy ROS
1774  // clear the set of BXids from the ROSs
1775  for(map<int, set<int> >::iterator rosBxIds = rosBxIdsPerFED.begin(); rosBxIds != rosBxIdsPerFED.end(); ++rosBxIds) {
1776  (*rosBxIds).second.clear();
1777  }
1778 
1779  fedBXIds.clear();
1780 
1781  for(map<int, set<int> >::iterator rosL1AIds = rosL1AIdsPerFED.begin(); rosL1AIds != rosL1AIdsPerFED.end(); ++rosL1AIds) {
1782  (*rosL1AIds).second.clear();
1783  }
1784 
1785  // reset the error flag
1786  eventErrorFlag = false;
1787 
1788  // Digi collection
1789  edm::Handle<DTDDUCollection> dduProduct;
1790  e.getByToken(dduToken, dduProduct);
1791  edm::Handle<DTROS25Collection> ros25Product;
1792  e.getByToken(ros25Token, ros25Product);
1793 
1794  DTDDUData dduData;
1795  std::vector<DTROS25Data> ros25Data;
1796  if(dduProduct.isValid() && ros25Product.isValid()) {
1797  for(unsigned int i=0; i<dduProduct->size(); ++i)
1798  {
1799  dduData = dduProduct->at(i);
1800  ros25Data = ros25Product->at(i);
1801  // FIXME: passing id variable is not needed anymore - change processFED interface for next release!
1802  FEDHeader header = dduData.getDDUHeader();
1803  int id = header.sourceID();
1804  if (id>FEDIDmax || id<FEDIDmin) continue; //SIM uses extra FEDs not monitored
1805 
1806  processFED(dduData, ros25Data, id);
1807  for(unsigned int j=0; j < ros25Data.size(); ++j) {
1808  int rosid = j+1;
1809  processROS25(ros25Data[j],id,rosid);
1810  }
1811  }
1812  }
1813  }
1814 
1815 }
1816 
1817 // Local Variables:
1818 // show-trailing-whitespace: t
1819 // truncate-lines: t
1820 // End:
std::map< int, std::set< int > > rosBxIdsPerFED
std::multimap< std::string, std::string > names
std::map< int, std::set< int > > rosL1AIdsPerFED
int EventWordCount() const
Definition: DTDDUWords.h:272
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
const std::vector< DTROBHeader > & getROBHeaders() const
Definition: DTControlData.h:57
std::vector< int > geterrors() const
const std::vector< DTTDCData > & getTDCData() const
Definition: DTControlData.h:60
uint8_t triggerType() const
Event Trigger type identifier.
Definition: FEDHeader.cc:17
int outputFifoFull() const
Definition: DTDDUWords.h:901
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:519
int PC() const
Definition: DTDDUWords.h:622
MonitorElement * hFEDNonFatal
int rosList() const
Definition: DTDDUWords.h:903
int getevtlgth() const
int geterrorTDCID(int i) const
void bookHistosuROS(DQMStore::IBooker &, const int fed, const int uRos)
bool check() const
Check that the header is OK.
Definition: FEDHeader.cc:72
int l1AFifoOccupancy() const
Definition: DTDDUWords.h:271
uint16_t sourceID() const
Identifier of the FED.
Definition: FEDHeader.cc:32
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)
void bookHistos(DQMStore::IBooker &, const int fedMin, const int fedMax)
edm::EDGetTokenT< DTuROSFEDDataCollection > fedToken
bool check() const
Check that the trailer is OK.
Definition: FEDTrailer.cc:83
int getROS() const
int busyROSPAF() const
Definition: DTDDUWords.h:905
int l1AIDError() const
Definition: DTDDUWords.h:895
void processuROS(DTuROSROSData &data, int fed, int uRos)
void channelsInROS(int cerosMask, std::vector< int > &channels)
MonitorElement * hFEDFatal
uint32_t fragmentLength() const
The length of the event fragment counted in 64-bit words including header and trailer.
Definition: FEDTrailer.cc:17
static const int DOCESLOTS
void Fill(long long x)
LuminosityBlockNumber_t luminosityBlock() const
edm::EDGetTokenT< DTROS25Collection > ros25Token
const DTLocalTriggerTrailerWord & getSCTrailer() const
Definition: DTControlData.h:65
int warningROSPAF() const
Definition: DTDDUWords.h:904
int getSCID() const
DTDataIntegrityTask(const edm::ParameterSet &ps)
int TTCEventCounter() const
Definition: DTDDUWords.h:225
std::map< std::string, std::map< int, DTTimeEvolutionHisto * > > fedTimeHistos
void processROS25(DTROS25Data &data, int dduID, int ros)
const std::vector< DTROSDebugWord > & getROSDebugs() const
Definition: DTControlData.h:56
const std::vector< DTDDUFirstStatusWord > & getFirstStatusWord() const
std::map< std::string, std::map< int, MonitorElement * > > summaryHistos
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
const DTROSTrailerWord & getROSTrailer() const
Definition: DTControlData.h:53
const DTROSHeaderWord & getROSHeader() const
Definition: DTControlData.h:54
void beginLuminosityBlock(const edm::LuminosityBlock &ls, const edm::EventSetup &es) override
std::map< unsigned int, MonitorElement * > urosHistos
void analyze(const edm::Event &e, const edm::EventSetup &c) override
int TPX() const
Definition: DTDDUWords.h:270
int getBXId() const
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:118
void endLuminosityBlock(const edm::LuminosityBlock &ls, const edm::EventSetup &es) override
DTuROSROSData getuROS(int slot) const
int fifoFull() const
Definition: DTDDUWords.h:897
Definition: value.py:1
int getokxflag(int i) const
bool isValid() const
Definition: HandleBase.h:74
std::map< std::string, std::map< int, MonitorElement * > > fedHistos
#define LogTrace(id)
bool crcErrorBit() const
int getuserWord() const
int getDDUID() const
const FEDTrailer & getDDUTrailer() const
MonitorElement * nEventMonitor
int inputFifoAlmostFull() const
Definition: DTDDUWords.h:900
int robID() const
Definition: DTDDUWords.h:421
def ls(path, rec=False)
Definition: eostools.py:348
int inputFifoFull() const
Definition: DTDDUWords.h:898
std::string topFolder(bool isFEDIntegrity) const
const FEDHeader & getDDUHeader() const
Getters.
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:279
uint8_t ttsBits() const
Current value of the Trigger Throttling System bits.
Definition: FEDTrailer.cc:32
MonitorElement * hFEDEntry
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:136
void setROB(const int &ID)
std::map< std::string, std::map< int, MonitorElement * > > rosHistos
void setROS(const int &ID)
const std::vector< DTROBTrailerWord > & getROBTrailers() const
Definition: DTControlData.h:58
int getDDU() const
int bxIDError() const
Definition: DTDDUWords.h:896
long gettrailer() const
uint16_t bxID() const
The bunch crossing number.
Definition: FEDHeader.cc:27
int geterror(int i) const
int geterrorROBID(int i) const
void processFED(DTuROSFEDData &data, int fed)
void channelsInCEROS(int cerosId, int chMask, std::vector< int > &channels)
int getROB() const
int outputFifoAlmostFull() const
Definition: DTDDUWords.h:902
void setDDU(const int &ID)
need to reset the bits before setting
HLT enums.
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
void bookHistosROS25(DQMStore::IBooker &, DTROChainCoding code)
int getslotsize(int slot) const
const std::vector< DTROSErrorWord > & getROSErrors() const
Definition: DTControlData.h:55
MonitorElement * hTTSSummary
static std::atomic< unsigned int > counter
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
int getslot() const
std::map< std::string, std::map< int, DTTimeEvolutionHisto * > > rosTimeHistos
std::set< int > fedBXIds
int getTTS() const
uint32_t lvl1ID() const
Level-1 event number generated by the TTC system.
Definition: FEDHeader.cc:22
int getnslots() const
MonitorElement * bookFloat(Args &&...args)
Definition: DQMStore.h:112
int getfed() const
int fifoAlmostFull() const
Definition: DTDDUWords.h:899
const std::vector< DTTDCError > & getTDCError() const
Definition: DTControlData.h:61
void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
const DTDDUSecondStatusWord & getSecondStatusWord() const
int outOfSynchROSError() const
Definition: DTDDUWords.h:906
MonitorElement * hCorruptionSummary
std::map< unsigned int, DTTimeEvolutionHisto * > urosTimeHistos
int bunchID() const
Definition: DTDDUWords.h:423
edm::EDGetTokenT< DTDDUCollection > dduToken
Definition: Run.h:43
int getROSID() const