CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DTDataIntegrityTask.cc
Go to the documentation of this file.
1 /*
2  * \file DTDataIntegrityTask.cc
3  *
4  * $Date: 2011/03/02 11:28:32 $
5  * $Revision: 1.72 $
6  * \author M. Zanetti (INFN Padova), S. Bolognesi (INFN Torino), G. Cerminara (INFN Torino)
7  *
8  */
9 
23 
24 #include <math.h>
25 #include <fstream>
26 #include <map>
27 #include <string>
28 #include <vector>
29 
30 using namespace std;
31 using namespace edm;
32 int FirstRos=0,nevents=0,n,m;
33 const unsigned long long max_bx = 59793997824ULL;
34 #include "ROSDebugUtility.h"
35 
37 
38  // Register the methods that we want to schedule
39  // reg.watchPostEndJob(this,&DTDataIntegrityTask::postEndJob);
42 
43  LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
44  << "[DTDataIntegrityTask]: Constructor" <<endl;
45 
46  neventsDDU = 0;
47  neventsROS25 = 0;
48 
49 // //If you want info VS time histos
50 // doTimeHisto = ps.getUntrackedParameter<bool>("doTimeHisto", false);
51  // Plot quantities about SC
52  getSCInfo = ps.getUntrackedParameter<bool>("getSCInfo", false);
53 
54  fedIntegrityFolder = ps.getUntrackedParameter<string>("fedIntegrityFolder","DT/FEDIntegrity");
55 
56 string processingMode = ps.getUntrackedParameter<string>("processingMode","Online");
57 
58  // processing mode flag to select plots to be produced and basedirs CB vedi se farlo meglio...
59  if (processingMode == "Online") {
60  mode = 0;
61  } else if(processingMode == "SM") {
62  mode = 1;
63  } else if (processingMode == "Offline") {
64  mode = 2;
65  } else if (processingMode == "HLT") {
66  mode = 3;
67  } else {
68  throw cms::Exception("MissingParameter")
69  << "[DTDataIntegrityTask]: processingMode :" << processingMode
70  << " invalid! Must be Online, SM, Offline or HLT !" << endl;
71  }
72 
73 }
74 
75 
76 
78  LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
79  <<"[DTDataIntegrityTask]: Destructor. Analyzed "<< neventsDDU <<" events"<<endl;
80 }
81 
82 
83 
84 /*
85  Folder Structure:
86  - One folder for each DDU, named FEDn
87  - Inside each DDU folder the DDU histos and the ROSn folder
88  - Inside each ROS folder the ROS histos and the ROBn folder
89  - Inside each ROB folder one occupancy plot and the TimeBoxes
90  with the chosen granularity (simply change the histo name)
91 */
92 
94  LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
95  << "[DTDataIntegrityTask]: postEndJob called!" <<endl;
96 
97 // if(doTimeHisto) TimeHistos("Event_word_vs_time");
98 
99 }
100 
101 
102 void DTDataIntegrityTask::bookHistos(const int fedMin, const int fedMax) {
103  // Standard FED integrity histos
105 
106  int nFED = (fedMax - fedMin)+1;
107 
108  hFEDEntry = dbe->book1D("FEDEntries","# entries per DT FED",nFED,fedMin,fedMax+1);
109  hFEDFatal = dbe->book1D("FEDFatal","# fatal errors DT FED",nFED,fedMin,fedMax+1);
110  hFEDNonFatal = dbe->book1D("FEDNonFatal","# NON fatal errors DT FED",nFED,fedMin,fedMax+1);
111 
112 
113  dbe->setCurrentFolder(topFolder(false));
114  hTTSSummary = dbe->book2D("TTSSummary","Summary Status TTS",nFED,fedMin,fedMax+1,9,1,10);
115  hTTSSummary->setAxisTitle("FED",1);
116  hTTSSummary->setBinLabel(1,"ROS PAF",2);
117  hTTSSummary->setBinLabel(2,"DDU PAF",2);
118  hTTSSummary->setBinLabel(3,"ROS PAF",2);
119  hTTSSummary->setBinLabel(4,"DDU PAF",2);
120  hTTSSummary->setBinLabel(5,"DDU Full",2);
121  hTTSSummary->setBinLabel(6,"L1A Mism.",2);
122  hTTSSummary->setBinLabel(7,"ROS Error",2);
123  hTTSSummary->setBinLabel(8,"BX Mism.",2);
124  hTTSSummary->setBinLabel(9,"DDU Logic Err.",2);
125 
126  // bookkeeping of the
127 
128  hCorruptionSummary = dbe->book2D("DataCorruptionSummary", "Data Corruption Sources",
129  nFED,fedMin,fedMax+1, 8, 1, 9);
131  hCorruptionSummary->setBinLabel(1,"Miss Ch.",2);
132  hCorruptionSummary->setBinLabel(2,"ROS BX mism",2);
133  hCorruptionSummary->setBinLabel(3,"DDU BX mism",2);
134  hCorruptionSummary->setBinLabel(4,"ROS L1A mism",2);
135  hCorruptionSummary->setBinLabel(5,"Miss Payload",2);
136  hCorruptionSummary->setBinLabel(6,"FCRC bit",2);
137  hCorruptionSummary->setBinLabel(7,"Header check",2);
138  hCorruptionSummary->setBinLabel(8,"Triler Check",2);
139 
140 
141 }
142 
143 
144 
145 void DTDataIntegrityTask::bookHistos(string folder, DTROChainCoding code) {
146 
147  stringstream dduID_s; dduID_s << code.getDDU();
148  stringstream rosID_s; rosID_s << code.getROS();
149  stringstream robID_s; robID_s << code.getROB();
150  int wheel = (code.getDDUID() - 770)%5 - 2;
151  stringstream wheel_s; wheel_s << wheel;
152 
153  LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
154  << " Booking histos for FED: " << code.getDDU() << " ROS: " << code.getROS()
155  << " ROB: " << code.getROB() << " folder: " << folder << endl;
156 
157  string histoType;
158  string histoName;
159  string histoTitle;
160  MonitorElement* histo = 0;
161 
162  // DDU Histograms
163  if (folder == "DDU") {
164 
165  dbe->setCurrentFolder(topFolder(false) + "FED" + dduID_s.str());
166 
167  histoType = "EventLenght";
168  histoName = "FED" + dduID_s.str() + "_" + histoType;
169  histoTitle = "Event Lenght (Bytes) FED " + dduID_s.str();
170  (dduHistos[histoType])[code.getDDUID()] = dbe->book1D(histoName,histoTitle,501,0,16032);
171 
172  if(mode > 2) return;
173 
174  histoType = "ROSStatus";
175  histoName = "FED" + dduID_s.str() + "_" + histoType;
176  (dduHistos[histoType])[code.getDDUID()] = dbe->book2D(histoName,histoName,12,0,12,12,0,12);
177  histo = (dduHistos[histoType])[code.getDDUID()];
178  histo->setBinLabel(1,"ch.enabled",1);
179  histo->setBinLabel(2,"timeout",1);
180  histo->setBinLabel(3,"ev.trailer lost",1);
181  histo->setBinLabel(4,"opt.fiber lost",1);
182  histo->setBinLabel(5,"tlk.prop.error",1);
183  histo->setBinLabel(6,"tlk.pattern error",1);
184  histo->setBinLabel(7,"tlk.sign.lost",1);
185  histo->setBinLabel(8,"error from ROS",1);
186  histo->setBinLabel(9,"if ROS in events",1);
187  histo->setBinLabel(10,"Miss. Evt.",1);
188  histo->setBinLabel(11,"Evt. ID Mismatch",1);
189  histo->setBinLabel(12,"BX Mismatch",1);
190 
191  histo->setBinLabel(1,"ROS 1",2);
192  histo->setBinLabel(2,"ROS 2",2);
193  histo->setBinLabel(3,"ROS 3",2);
194  histo->setBinLabel(4,"ROS 4",2);
195  histo->setBinLabel(5,"ROS 5",2);
196  histo->setBinLabel(6,"ROS 6",2);
197  histo->setBinLabel(7,"ROS 7",2);
198  histo->setBinLabel(8,"ROS 8",2);
199  histo->setBinLabel(9,"ROS 9",2);
200  histo->setBinLabel(10,"ROS 10",2);
201  histo->setBinLabel(11,"ROS 11",2);
202  histo->setBinLabel(12,"ROS 12",2);
203 
204  if(mode > 1) return;
205 
206  histoType = "TTSValues";
207  histoName = "FED" + dduID_s.str() + "_" + histoType;
208  (dduHistos[histoType])[code.getDDUID()] = dbe->book1D(histoName,histoName,8,0,8);
209  histo = (dduHistos[histoType])[code.getDDUID()];
210  histo->setBinLabel(1,"disconnected",1);
211  histo->setBinLabel(2,"warning overflow",1);
212  histo->setBinLabel(3,"out of synch",1);
213  histo->setBinLabel(4,"busy",1);
214  histo->setBinLabel(5,"ready",1);
215  histo->setBinLabel(6,"error",1);
216  histo->setBinLabel(7,"disconnected",1);
217  histo->setBinLabel(8,"unknown",1);
218 
219  histoType = "EventType";
220  histoName = "FED" + dduID_s.str() + "_" + histoType;
221  (dduHistos[histoType])[code.getDDUID()] = dbe->book1D(histoName,histoName,2,1,3);
222  histo = (dduHistos[histoType])[code.getDDUID()];
223  histo->setBinLabel(1,"physics",1);
224  histo->setBinLabel(2,"calibration",1);
225 
226  histoType = "ROSList";
227  histoName = "FED" + dduID_s.str() + "_" + histoType;
228  histoTitle = "# of ROS in the FED payload (FED" + dduID_s.str() + ")";
229  (dduHistos[histoType])[code.getDDUID()] = dbe->book1D(histoName,histoTitle,13,0,13);
230 
231  histoType = "FIFOStatus";
232  histoName = "FED" + dduID_s.str() + "_" + histoType;
233  (dduHistos[histoType])[code.getDDUID()] = dbe->book2D(histoName,histoName,7,0,7,3,0,3);
234  histo = (dduHistos[histoType])[code.getDDUID()];
235  histo->setBinLabel(1,"Input ch1-4",1);
236  histo->setBinLabel(2,"Input ch5-8",1);
237  histo->setBinLabel(3,"Input ch9-12",1);
238  histo->setBinLabel(4,"Error/L1A ch1-4",1);
239  histo->setBinLabel(5,"Error/L1A ch5-8",1);
240  histo->setBinLabel(6,"Error/L1A ch9-12",1);
241  histo->setBinLabel(7,"Output",1);
242  histo->setBinLabel(1,"Full",2);
243  histo->setBinLabel(2,"Almost Full",2);
244  histo->setBinLabel(3,"Not Full",2);
245 
246 
247  histoType = "BXID";
248  histoName = "FED" + dduID_s.str() + "_BXID";
249  histoTitle = "Distrib. BX ID (FED" + dduID_s.str() + ")";
250  (dduHistos[histoType])[code.getDDUID()] = dbe->book1D(histoName,histoTitle,3600,0,3600);
251 
252 
253  }
254 
255  // ROS Histograms
256  if ( folder == "ROS_S" ) { // The summary of the error of the ROS on the same FED
257  dbe->setCurrentFolder(topFolder(false));
258 
259  histoType = "ROSSummary";
260  histoName = "FED" + dduID_s.str() + "_ROSSummary";
261  string histoTitle = "Summary Wheel" + wheel_s.str() + " (FED " + dduID_s.str() + ")";
262 
263  ((rosSHistos[histoType])[code.getDDUID()]) = dbe->book2D(histoName,histoTitle,20,0,20,12,1,13);
264  MonitorElement *histo = ((rosSHistos[histoType])[code.getDDUID()]);
265  // ROS error bins
266  histo ->setBinLabel(1,"Link TimeOut",1);
267  histo ->setBinLabel(2,"Ev.Id.Mis.",1);
268  histo ->setBinLabel(3,"FIFO almost full",1);
269  histo ->setBinLabel(4,"FIFO full",1);
270  histo ->setBinLabel(5,"CEROS timeout",1);
271  histo ->setBinLabel(6,"Max. wds",1);
272  histo ->setBinLabel(7,"WO L1A FIFO",1);
273  histo ->setBinLabel(8,"TDC parity err.",1);
274  histo ->setBinLabel(9,"BX ID Mis.",1);
275  histo ->setBinLabel(10,"TXP",1);
276  histo ->setBinLabel(11,"L1A almost full",1);
277  histo ->setBinLabel(12,"Ch. blocked",1);
278  histo ->setBinLabel(13,"Ev. Id. Mis.",1);
279  histo ->setBinLabel(14,"CEROS blocked",1);
280  // TDC error bins
281  histo ->setBinLabel(15,"TDC Fatal",1);
282  histo ->setBinLabel(16,"TDC RO FIFO ov.",1);
283  histo ->setBinLabel(17,"TDC L1 buf. ov.",1);
284  histo ->setBinLabel(18,"TDC L1A FIFO ov.",1);
285  histo ->setBinLabel(19,"TDC hit err.",1);
286  histo ->setBinLabel(20,"TDC hit rej.",1);
287 
288  histo ->setBinLabel(1,"ROS1",2);
289  histo ->setBinLabel(2,"ROS2",2);
290  histo ->setBinLabel(3,"ROS3",2);
291  histo ->setBinLabel(4,"ROS4",2);
292  histo ->setBinLabel(5,"ROS5",2);
293  histo ->setBinLabel(6,"ROS6",2);
294  histo ->setBinLabel(7,"ROS7",2);
295  histo ->setBinLabel(8,"ROS8",2);
296  histo ->setBinLabel(9,"ROS9",2);
297  histo ->setBinLabel(10,"ROS10",2);
298  histo ->setBinLabel(11,"ROS11",2);
299  histo ->setBinLabel(12,"ROS12",2);
300  }
301 
302  if ( folder == "ROS" ) {
303  dbe->setCurrentFolder(topFolder(false) + "FED" + dduID_s.str() + "/" + folder + rosID_s.str());
304 
305 
306  histoType = "ROSError";
307  histoName = "FED" + dduID_s.str() + "_" + folder + rosID_s.str() + "_ROSError";
308  histoTitle = histoName + " (ROBID error summary)";
309  if(mode <= 1)
310  (rosHistos[histoType])[code.getROSID()] = dbe->book2D(histoName,histoTitle,17,0,17,26,0,26);
311  else
312  (rosHistos[histoType])[code.getROSID()] = dbe->book2D(histoName,histoTitle,11,0,11,26,0,26);
313 
314  MonitorElement* histo = (rosHistos[histoType])[code.getROSID()];
315  // ROS error bins
316  histo->setBinLabel(1,"Link TimeOut",1);
317  histo->setBinLabel(2,"Ev.Id.Mis.",1);
318  histo->setBinLabel(3,"FIFO almost full",1);
319  histo->setBinLabel(4,"FIFO full",1);
320  histo->setBinLabel(5,"CEROS timeout",1);
321  histo->setBinLabel(6,"Max. wds",1);
322  histo->setBinLabel(7,"TDC parity err.",1);
323  histo->setBinLabel(8,"BX ID Mis.",1);
324  histo->setBinLabel(9,"Ch. blocked",1);
325  histo->setBinLabel(10,"Ev. Id. Mis.",1);
326  histo->setBinLabel(11,"CEROS blocked",1);
327  if(mode <= 1) {
328  // TDC error bins
329  histo->setBinLabel(12,"TDC Fatal",1);
330  histo->setBinLabel(13,"TDC RO FIFO ov.",1);
331  histo->setBinLabel(14,"TDC L1 buf. ov.",1);
332  histo->setBinLabel(15,"TDC L1A FIFO ov.",1);
333  histo->setBinLabel(16,"TDC hit err.",1);
334  histo->setBinLabel(17,"TDC hit rej.",1);
335  }
336  histo->setBinLabel(1,"ROB0",2);
337  histo->setBinLabel(2,"ROB1",2);
338  histo->setBinLabel(3,"ROB2",2);
339  histo->setBinLabel(4,"ROB3",2);
340  histo->setBinLabel(5,"ROB4",2);
341  histo->setBinLabel(6,"ROB5",2);
342  histo->setBinLabel(7,"ROB6",2);
343  histo->setBinLabel(8,"ROB7",2);
344  histo->setBinLabel(9,"ROB8",2);
345  histo->setBinLabel(10,"ROB9",2);
346  histo->setBinLabel(11,"ROB10",2);
347  histo->setBinLabel(12,"ROB11",2);
348  histo->setBinLabel(13,"ROB12",2);
349  histo->setBinLabel(14,"ROB13",2);
350  histo->setBinLabel(15,"ROB14",2);
351  histo->setBinLabel(16,"ROB15",2);
352  histo->setBinLabel(17,"ROB16",2);
353  histo->setBinLabel(18,"ROB17",2);
354  histo->setBinLabel(19,"ROB18",2);
355  histo->setBinLabel(20,"ROB19",2);
356  histo->setBinLabel(21,"ROB20",2);
357  histo->setBinLabel(22,"ROB21",2);
358  histo->setBinLabel(23,"ROB22",2);
359  histo->setBinLabel(24,"ROB23",2);
360  histo->setBinLabel(25,"ROB24",2);
361  histo->setBinLabel(26,"SC",2);
362 
363  if(mode > 1) return;
364 
365  histoType = "ROSEventLenght";
366  histoName = "FED" + dduID_s.str() + "_" + folder + rosID_s.str() + "_ROSEventLenght";
367  histoTitle = "Event Lenght (Bytes) FED " + dduID_s.str() + " ROS " + rosID_s.str();
368  (rosHistos[histoType])[code.getROSID()] = dbe->book1D(histoName,histoTitle,101,0,1616);
369 
370 
371  histoType = "TDCError";
372  histoName = "FED" + dduID_s.str() + "_" + folder + rosID_s.str() + "_TDCError";
373  histoTitle = histoName + " (ROBID error summary)";
374  (rosHistos[histoType])[code.getROSID()] = dbe->book2D(histoName,histoTitle,24,0,24,25,0,25);
375  histo = (rosHistos[histoType])[code.getROSID()];
376  // TDC error bins
377  histo->setBinLabel(1,"Fatal",1);
378  histo->setBinLabel(2,"RO FIFO ov.",1);
379  histo->setBinLabel(3,"L1 buf. ov.",1);
380  histo->setBinLabel(4,"L1A FIFO ov.",1);
381  histo->setBinLabel(5,"hit err.",1);
382  histo->setBinLabel(6,"hit rej.",1);
383  histo->setBinLabel(7,"Fatal",1);
384  histo->setBinLabel(8,"RO FIFO ov.",1);
385  histo->setBinLabel(9,"L1 buf. ov.",1);
386  histo->setBinLabel(10,"L1A FIFO ov.",1);
387  histo->setBinLabel(11,"hit err.",1);
388  histo->setBinLabel(12,"hit rej.",1);
389  histo->setBinLabel(13,"Fatal",1);
390  histo->setBinLabel(14,"RO FIFO ov.",1);
391  histo->setBinLabel(15,"L1 buf. ov.",1);
392  histo->setBinLabel(16,"L1A FIFO ov.",1);
393  histo->setBinLabel(17,"hit err.",1);
394  histo->setBinLabel(18,"hit rej.",1);
395  histo->setBinLabel(19,"Fatal",1);
396  histo->setBinLabel(20,"RO FIFO ov.",1);
397  histo->setBinLabel(21,"L1 buf. ov.",1);
398  histo->setBinLabel(22,"L1A FIFO ov.",1);
399  histo->setBinLabel(23,"hit err.",1);
400  histo->setBinLabel(24,"hit rej.",1);
401 
402  histo->setBinLabel(1,"ROB0",2);
403  histo->setBinLabel(2,"ROB1",2);
404  histo->setBinLabel(3,"ROB2",2);
405  histo->setBinLabel(4,"ROB3",2);
406  histo->setBinLabel(5,"ROB4",2);
407  histo->setBinLabel(6,"ROB5",2);
408  histo->setBinLabel(7,"ROB6",2);
409  histo->setBinLabel(8,"ROB7",2);
410  histo->setBinLabel(9,"ROB8",2);
411  histo->setBinLabel(10,"ROB9",2);
412  histo->setBinLabel(11,"ROB10",2);
413  histo->setBinLabel(12,"ROB11",2);
414  histo->setBinLabel(13,"ROB12",2);
415  histo->setBinLabel(14,"ROB13",2);
416  histo->setBinLabel(15,"ROB14",2);
417  histo->setBinLabel(16,"ROB15",2);
418  histo->setBinLabel(17,"ROB16",2);
419  histo->setBinLabel(18,"ROB17",2);
420  histo->setBinLabel(19,"ROB18",2);
421  histo->setBinLabel(20,"ROB19",2);
422  histo->setBinLabel(21,"ROB20",2);
423  histo->setBinLabel(22,"ROB21",2);
424  histo->setBinLabel(23,"ROB22",2);
425  histo->setBinLabel(24,"ROB23",2);
426  histo->setBinLabel(25,"ROB24",2);
427 
428  histoType = "ROB_mean";
429  histoName = "FED" + dduID_s.str() + "_" + "ROS" + rosID_s.str() + "_ROB_mean";
430  string fullName = topFolder(false) + "FED" + dduID_s.str() + "/" + folder + rosID_s.str()+ "/" + histoName;
431  names.insert (pair<std::string,std::string> (histoType,string(fullName)));
432  (rosHistos[histoType])[code.getROSID()] = dbe->book2D(histoName,histoName,25,0,25,100,0,100);
433  (rosHistos[histoType])[code.getROSID()]->setAxisTitle("ROB #",1);
434  (rosHistos[histoType])[code.getROSID()]->setAxisTitle("ROB wordcounts",2);
435 
436 
437 
438 // histoType = "Trigger_frequency";
439 // histoName = "FED" + dduID_s.str() + "_Trigger_frequency";
440 // (rosHistos[histoType])[code.getROSID()] = dbe->book1D(histoName,histoName,100,1,100);
441  }
442 
443 
444 // if ( folder == "TDCError") {
445 
446 // dbe->setCurrentFolder(topFolder(false) + "FED" + dduID_s.str()+"/ROS"+rosID_s.str()+"/ROB"+robID_s.str());
447 
448 // histoType = "TDCError";
449 // histoName = "FED" + dduID_s.str() + "_ROS" + rosID_s.str() + "_ROB"+robID_s.str()+"_TDCError";
450 // string histoTitle = histoName + " (TDC Errors)";
451 // (robHistos[histoType])[code.getROBID()] = dbe->book2D(histoName,histoTitle,6,0,6,4,0,4);
452 // ((robHistos[histoType])[code.getROBID()]) ->setBinLabel(1,"TDC Fatal",1);
453 // ((robHistos[histoType])[code.getROBID()]) ->setBinLabel(2,"RO FIFO ov.",1);
454 // ((robHistos[histoType])[code.getROBID()]) ->setBinLabel(3,"L1 buffer ov.",1);
455 // ((robHistos[histoType])[code.getROBID()]) ->setBinLabel(4,"L1A FIFO ov.",1);
456 // ((robHistos[histoType])[code.getROBID()]) ->setBinLabel(5,"TDC hit err.",1);
457 // ((robHistos[histoType])[code.getROBID()]) ->setBinLabel(6,"TDC hit rej.",1);
458 // ((robHistos[histoType])[code.getROBID()]) ->setBinLabel(1,"TDC0",2);
459 // ((robHistos[histoType])[code.getROBID()]) ->setBinLabel(2,"TDC1",2);
460 // ((robHistos[histoType])[code.getROBID()]) ->setBinLabel(3,"TDC2",2);
461 // ((robHistos[histoType])[code.getROBID()]) ->setBinLabel(4,"TDC3",2);
462 
463 // }
464 
465  // SC Histograms
466  if ( folder == "SC" ) {
467  // The plots are per wheel
468  dbe->setCurrentFolder(topFolder(false) + "FED" + dduID_s.str());
469 
470  // SC data Size
471  histoType = "SCSizeVsROSSize";
472  histoName = "FED" + dduID_s.str() + "_SCSizeVsROSSize";
473  histoTitle = "SC size - ROS size vs SC (FED " + dduID_s.str() + ")";
474  rosHistos[histoType][code.getSCID()] = dbe->book2D(histoName,histoTitle,12,1,13,51,-1,50);
475  rosHistos[histoType][code.getSCID()]->setAxisTitle("SC",1);
476 
477  }
478 }
479 
480 void DTDataIntegrityTask::TimeHistos(string histoType){
481 
482  if(histoType == "Event_word_vs_time"){
483 
484  for (it = names.begin(); it != names.end(); it++) {
485 
486  if ((*it).first==histoType){
487 
488  MonitorElement * h1 =dbe->get((*it).second);
489 
490  int first_bin = -1, last_bin=-1;
491  for( int bin=1; bin < h1->getNbinsX()+1; bin++ ){
492  for( int j=1; j < h1->getNbinsY(); j++ ){
493  if( h1->getBinContent(bin,j) > 0 ) {
494  if( first_bin == -1 ) { first_bin = bin; }
495  last_bin = bin;
496  }
497  }
498  }
499 
500  if( first_bin > 1 ) { first_bin -= 1; }
501  if( last_bin < h1-> getNbinsX() ){ last_bin += 1; }
502  h1->setAxisRange(0,last_bin,1);
503  }
504  }
505  }
506 }
507 
508 
509 
510 // void DTDataIntegrityTask::bookHistosFED() {
511 // bookHistos( string("ROS_S"), code);
512 
513 // }
514 
515 
517  bookHistos( string("ROS"), code);
518 // for(int robId = 0; robId != 25; ++robId) {
519 // code.setROB(robId);
520 // bookHistos( string("TDCError"), code);
521 // }
522  if(mode <= 1)
523  if(getSCInfo)
524  bookHistos( string("SC"), code);
525 }
526 
527 
529  neventsROS25++; // FIXME: implement a counter which makes sense
530 
531 // if (neventsROS25%1000 == 0)
532  LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
533  << "[DTDataIntegrityTask]: " << neventsROS25 << " events analyzed by processROS25" << endl;
534 
535  // The ID of the RO board (used to map the histos)
536  DTROChainCoding code;
537  code.setDDU(ddu);
538  code.setROS(ros);
539 
540  MonitorElement* ROSSummary = rosSHistos["ROSSummary"][code.getDDUID()];
541 
542  // Summary of all ROB errors
543  MonitorElement* ROSError = 0;
544  if(mode <= 2) ROSError = rosHistos["ROSError"][code.getROSID()];
545 
546  // L1A ids to be checked against FED one
547  rosL1AIdsPerFED[ddu].insert(data.getROSHeader().TTCEventCounter());
548 
549  // ROS errors
550 
551 
552  // check for TPX errors
553  if (data.getROSTrailer().TPX() != 0) {
554  LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask") << " TXP error en ROS "
555  << code.getROS() << endl;
556  ROSSummary->Fill(9,code.getROS());
557  }
558 
559  // L1 Buffer almost full (non-critical error!)
560  if(data.getROSTrailer().l1AFifoOccupancy() > 31) {
561  ROSSummary->Fill(10,code.getROS());
562  }
563 
564  // FIXME: what is this about???
565  if (neventsROS25 == 1) FirstRos = code.getROSID();
566  if (code.getROSID() == FirstRos) nevents++ ;
567 
568 
569  for (vector<DTROSErrorWord>::const_iterator error_it = data.getROSErrors().begin();
570  error_it != data.getROSErrors().end(); error_it++) { // Loop over ROS error words
571 
572  LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask") << " Error in ROS " << code.getROS()
573  << " ROB Id " << (*error_it).robID()
574  << " Error type " << (*error_it).errorType() << endl;
575 
576  // Fill the ROSSummary (1 per FED) histo
577  ROSSummary->Fill((*error_it).errorType(), code.getROS());
578  if((*error_it).errorType() <= 11) { // set error flag
579  eventErrorFlag = true;
580  }
581 
582  if(mode <= 2) {
583  // Fill the ROB Summary (1 per ROS) histo
584  if ((*error_it).robID() != 31) {
585  ROSError->Fill((*error_it).errorType(),(*error_it).robID());
586  }
587  else if ((*error_it).errorType() == 4) {
588  vector<int> channelBins;
589  channelsInROS((*error_it).cerosID(),channelBins);
590  vector<int>::const_iterator channelIt = channelBins.begin();
591  vector<int>::const_iterator channelEnd = channelBins.end();
592  for(;channelIt!=channelEnd;++channelIt) {
593  ROSError->Fill(4,(*channelIt));
594  }
595  }
596  }
597  }
598 
599 
600  int ROSDebug_BunchNumber = -1;
601  int ROSDebug_BcntResCntLow = 0;
602  int ROSDebug_BcntResCntHigh = 0;
603  int ROSDebug_BcntResCnt = 0;
604 
605  for (vector<DTROSDebugWord>::const_iterator debug_it = data.getROSDebugs().begin();
606  debug_it != data.getROSDebugs().end(); debug_it++) { // Loop over ROS debug words
607 
608  int debugROSSummary = 0;
609  int debugROSError = 0;
610  vector<int> debugBins;
611  bool hasEvIdMis = false;
612  vector<int> evIdMisBins;
613 
614  if ((*debug_it).debugType() == 0 ) {
615  ROSDebug_BunchNumber = (*debug_it).debugMessage();
616  } else if ((*debug_it).debugType() == 1 ) {
617  ROSDebug_BcntResCntLow = (*debug_it).debugMessage();
618  } else if ((*debug_it).debugType() == 2 ) {
619  ROSDebug_BcntResCntHigh = (*debug_it).debugMessage();
620  } else if ((*debug_it).debugType() == 3) {
621  if ((*debug_it).dontRead()){
622  debugROSSummary = 11;
623  debugROSError = 8;
624  if (mode <= 2) channelsInCEROS((*debug_it).cerosIdCerosStatus(),(*debug_it).dontRead(),debugBins);
625  } if ((*debug_it).evIdMis()){
626  hasEvIdMis = true;
627  if (mode <= 2) channelsInCEROS((*debug_it).cerosIdCerosStatus(),(*debug_it).evIdMis(),evIdMisBins);
628  }
629  } else if ((*debug_it).debugType() == 4 &&
630  (*debug_it).cerosIdRosStatus()){
631  debugROSSummary = 13;
632  debugROSError = 10;
633  if (mode <= 2) channelsInROS((*debug_it).cerosIdRosStatus(),debugBins);
634  }
635 
636  if (debugROSSummary) {
637  ROSSummary->Fill(debugROSSummary,code.getROS());
638  if (mode <= 2) {
639  vector<int>::const_iterator channelIt = debugBins.begin();
640  vector<int>::const_iterator channelEnd = debugBins.end();
641  for (;channelIt!=channelEnd;++channelIt) {
642  ROSError->Fill(debugROSError,(*channelIt));
643  }
644  }
645  }
646 
647  if (hasEvIdMis) {
648  ROSSummary->Fill(12,code.getROS());
649  if (mode <= 2) {
650  vector<int>::const_iterator channelIt = evIdMisBins.begin();
651  vector<int>::const_iterator channelEnd = evIdMisBins.end();
652  for (;channelIt!=channelEnd;++channelIt) {
653  ROSError->Fill(9,(*channelIt));
654  }
655  }
656  }
657 
658  }
659 
660  ROSDebug_BcntResCnt = (ROSDebug_BcntResCntHigh << 15) + ROSDebug_BcntResCntLow;
661  // LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
662  // << " ROS: " << code.getROS() << " ROSDebug_BunchNumber " << ROSDebug_BunchNumber
663  // << " ROSDebug_BcntResCnt " << ROSDebug_BcntResCnt << endl;
664 
665 
666  // Event words vs time
667  // FIXME: what is this doing???
668  ROSWords_t(ResetCount_unfolded,code.getROS(),ROSDebug_BcntResCnt,nevents);
669 
670  // fill hists it here
671  // histoType = "Event_word_vs_time";
672  // if (rosHistos[histoType].find(code.getROSID()) != rosHistos[histoType].end()){
673  // (rosHistos.find(histoType)->second).find(code.getROSID())->second->
674  // Fill((ResetCount_unfolded),data.getROSTrailer().EventWordCount());
675  // (rosHistos.find(histoType)->second).find(code.getROSID())->second->setAxisTitle("Time(s)",1);
676  // }
677  // else {
678  // (rosHistos.find(histoType)->second).find(code.getROSID())->second->
679  // Fill((ResetCount_unfolded),data.getROSTrailer().EventWordCount());}
680 
681 
682 
683 
684  // ROB Group Header
685  // Check the BX of the ROB headers against the BX of the ROS
686  for (vector<DTROBHeader>::const_iterator rob_it = data.getROBHeaders().begin();
687  rob_it != data.getROBHeaders().end(); rob_it++) { // loop over ROB headers
688 
689  code.setROB((*rob_it).first);
690  DTROBHeaderWord robheader = (*rob_it).second;
691 
692  rosBxIdsPerFED[ddu].insert(ROSDebug_BunchNumber);
693 
694  if (robheader.bunchID() != ROSDebug_BunchNumber) {
695  // fill ROS Summary plot
696  ROSSummary->Fill(8,code.getROS());
697  eventErrorFlag = true;
698 
699  // fill ROB Summary plot for that particular ROS
700  if(mode <= 2) ROSError->Fill(7,robheader.robID());
701  }
702  }
703 
704 
705  if(mode <= 1) { // produce only when not in HLT
706  // ROB Trailer
707  for (vector<DTROBTrailerWord>::const_iterator robt_it = data.getROBTrailers().begin();
708  robt_it != data.getROBTrailers().end(); robt_it++) { // loop over ROB trailers
709  float wCount = (*robt_it).wordCount()<100. ? (*robt_it).wordCount() : 99.9;
710  rosHistos["ROB_mean"][code.getROSID()]->Fill((*robt_it).robID(),wCount);
711  }
712 
713 // // Trigger frequency
714 // double frequency = 0;
715 // // FIXME: how is the frequency computed
716 // ROS_L1A_Frequency(code.getROS(),ROSDebug_BcntResCnt,neventsROS25,frequency,trigger_counter);
717 // rosHistos["Trigger_frequency"][code.getROSID()]->Fill(frequency);
718 
719  // Plot the event lenght //NOHLT
720  int rosEventLenght = data.getROSTrailer().EventWordCount()*4;
721  if(rosEventLenght > 1600) rosEventLenght = 1600;
722  rosHistos["ROSEventLenght"][code.getROSID()]->Fill(rosEventLenght);
723  }
724 
725 
726  // TDC Data
727  for (vector<DTTDCData>::const_iterator tdc_it = data.getTDCData().begin();
728  tdc_it != data.getTDCData().end(); tdc_it++) { // loop over TDC data
729 
730  DTTDCMeasurementWord tdcDatum = (*tdc_it).second;
731 
732  if ( tdcDatum.PC() !=0) {
733  LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
734  << " PC error in ROS " << code.getROS() << " TDC " << (*tdc_it).first << endl;
735  // fill ROS Summary plot
736  ROSSummary->Fill(7,code.getROS());
737 
738  eventErrorFlag = true;
739 
740  // fill ROB Summary plot for that particular ROS
741  if(mode <= 2) ROSError->Fill(6,(*tdc_it).first);
742  }
743  }
744 
745  // TDC Error
746  for (vector<DTTDCError>::const_iterator tdc_it = data.getTDCError().begin();
747  tdc_it != data.getTDCError().end(); tdc_it++) { // loop over TDC errors
748 
749  code.setROB((*tdc_it).first);
750 
751  int tdcError_ROSSummary = 0;
752  int tdcError_ROSError = 0;
753  int tdcError_TDCHisto = 0;
754 
755  if(((*tdc_it).second).tdcError() & 0x4000 ) {
756  LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
757  << " ROS " << code.getROS() << " ROB " << code.getROB()
758  << " Internal fatal Error 4000 in TDC " << (*tdc_it).first << endl;
759 
760  tdcError_ROSSummary = 14;
761  tdcError_ROSError = 11;
762  tdcError_TDCHisto = 0;
763 
764  } else if ( ((*tdc_it).second).tdcError() & 0x0249 ) {
765  LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
766  << " ROS " << code.getROS() << " ROB " << code.getROB()
767  << " TDC FIFO overflow in TDC " << (*tdc_it).first << endl;
768 
769  tdcError_ROSSummary = 15;
770  tdcError_ROSError = 12;
771  tdcError_TDCHisto = 1;
772 
773  } else if ( ((*tdc_it).second).tdcError() & 0x0492 ) {
774  LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
775  << " ROS " << code.getROS() << " ROB " << code.getROB()
776  << " TDC L1 buffer overflow in TDC " << (*tdc_it).first << endl;
777 
778  tdcError_ROSSummary = 16;
779  tdcError_ROSError = 13;
780  tdcError_TDCHisto = 2;
781 
782  } else if ( ((*tdc_it).second).tdcError() & 0x2000 ) {
783  LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
784  << " ROS " << code.getROS() << " ROB " << code.getROB()
785  << " TDC L1A FIFO overflow in TDC " << (*tdc_it).first << endl;
786 
787  tdcError_ROSSummary = 17;
788  tdcError_ROSError = 14;
789  tdcError_TDCHisto = 3;
790 
791  } else if ( ((*tdc_it).second).tdcError() & 0x0924 ) {
792  LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
793  << " ROS " << code.getROS() << " ROB " << code.getROB()
794  << " TDC hit error in TDC " << (*tdc_it).first << endl;
795 
796  tdcError_ROSSummary = 18;
797  tdcError_ROSError = 15;
798  tdcError_TDCHisto = 4;
799 
800  } else if ( ((*tdc_it).second).tdcError() & 0x1000 ) {
801  LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
802  << " ROS " << code.getROS() << " ROB " << code.getROB()
803  << " TDC hit rejected in TDC " << (*tdc_it).first << endl;
804 
805  tdcError_ROSSummary = 19;
806  tdcError_ROSError = 16;
807  tdcError_TDCHisto = 5;
808 
809  } else {
810  LogWarning("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
811  << " TDC error code not known " << ((*tdc_it).second).tdcError() << endl;
812  }
813 
814  ROSSummary->Fill(tdcError_ROSSummary,code.getROS());
815 
816  if(tdcError_ROSSummary <= 15) {
817  eventErrorFlag = true;
818  }
819 
820  if(mode <= 2) {
821  ROSError->Fill(tdcError_ROSError,(*tdc_it).first);
822  if(mode <= 1)
823  rosHistos["TDCError"][code.getROSID()]->Fill(tdcError_TDCHisto+6*((*tdc_it).second).tdcID(),(*tdc_it).first);
824  }
825  }
826 
827  // Read SC data
828  if (mode <= 1 && getSCInfo) {
829  // SC Data
830 
831  // NumberOf16bitWords counts the # of words + 1 subheader
832  // the SC includes the SC "private header" and the ROS header and trailer (= NumberOf16bitWords +3)
833  rosHistos["SCSizeVsROSSize"][code.getSCID()]->Fill(ros,data.getSCPrivHeader().NumberOf16bitWords()+3-data.getSCTrailer().wordCount());
834 
835  }
836 
837 
838 
839 
840 }
841 
842 void DTDataIntegrityTask::processFED(DTDDUData & data, const std::vector<DTROS25Data> & rosData, int ddu) {
843 
844  neventsDDU++;
845  if (neventsDDU%1000 == 0)
846  LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
847  << "[DTDataIntegrityTask]: " << neventsDDU << " events analyzed by processFED" << endl;
848 
849 
850  DTROChainCoding code;
851  code.setDDU(ddu);
852 
853  hFEDEntry->Fill(code.getDDUID());
854 
855  FEDTrailer trailer = data.getDDUTrailer();
856  FEDHeader header = data.getDDUHeader();
857 
858  // check consistency of header and trailer
859  if(!header.check()) {
860  // error code 7
861  hFEDFatal->Fill(code.getDDUID());
862  hCorruptionSummary->Fill(code.getDDUID(), 7);
863  }
864 
865  if(!trailer.check()) {
866  // error code 8
867  hFEDFatal->Fill(code.getDDUID());
868  hCorruptionSummary->Fill(code.getDDUID(), 8);
869  }
870 
871  // check CRC error bit set by DAQ before sending data on SLink
872  if(data.crcErrorBit()) {
873  // error code 6
874  hFEDFatal->Fill(code.getDDUID());
875  hCorruptionSummary->Fill(code.getDDUID(), 6);
876  }
877 
878  DTDDUSecondStatusWord secondWord = data.getSecondStatusWord();
879 
880  // Fill the status summary of the TTS
881 
882 
883  //1D HISTO WITH TTS VALUES form trailer (7 bins = 7 values)
884  int ttsCodeValue = -1;
885  int ttsSummaryBin = -1;
886 
887  switch(trailer.ttsBits()) {
888  case 0:{ //disconnected
889  ttsCodeValue = 0;
890  break;
891  }
892  case 1:{ //warning overflow
893  ttsCodeValue = 1;
894  if(secondWord.warningROSPAF()) { // ROS PAF
895  ttsSummaryBin = 1;
896  } else { // DDU PAF
897  ttsSummaryBin = 2;
898  }
899 
900  break;
901  }
902  case 2:{ //out of sinch
903  ttsCodeValue = 2;
904  bool knownOrigin = false;
905  if(secondWord.outOfSynchROSError()) {// ROS Error
906  ttsSummaryBin = 7;
907  knownOrigin = true;
908  }
909  if(secondWord.l1AIDError()) {// L1A Mism.
910  ttsSummaryBin = 6;
911  knownOrigin = true;
912  }
913  if(secondWord.bxIDError()) {// BX Mism.
914  ttsSummaryBin = 8;
915  knownOrigin = true;
916  }
917  if(secondWord.outputFifoFull() || secondWord.inputFifoFull() || secondWord.fifoFull()) { // DDU Full
918  ttsSummaryBin = 5;
919  knownOrigin = true;
920  }
921  if(!knownOrigin) ttsSummaryBin = 9; // Error in DDU logic
922 
923  break;
924  }
925  case 4:{ //busy
926  ttsCodeValue = 3;
927  bool knownOrigin = false;
928  if(secondWord.busyROSPAF()) { // ROS PAF
929  ttsSummaryBin = 3;
930  knownOrigin = true;
931  }
932  if(secondWord.outputFifoAlmostFull() || secondWord.inputFifoAlmostFull() || secondWord.fifoAlmostFull() ){ // DDU PAF
933  ttsSummaryBin = 4;
934  knownOrigin = true;
935  }
936  if(!knownOrigin) ttsSummaryBin = 9; // Error in DDU logic
937  break;
938  }
939  case 8:{ //ready
940  ttsCodeValue = 4;
941  break;
942  }
943  case 12:{ //error
944  ttsCodeValue = 5;
945  break;
946  }
947  case 16:{ //disconnected
948  ttsCodeValue = 6;
949  break;
950  }
951  default:{
952  LogError("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
953  <<"[DTDataIntegrityTask] DDU control: wrong TTS value "<<trailer.ttsBits()<<endl;
954  ttsCodeValue = 7;
955  }
956  }
957  if(mode <= 1) dduHistos["TTSValues"][code.getDDUID()]->Fill(ttsCodeValue);
958  if(ttsSummaryBin != -1) {
959  hTTSSummary->Fill(ddu, ttsSummaryBin);
960  }
961 
962 
963 
964 
965 
966 
967  //2D HISTO: ROS VS STATUS (8 BIT = 8 BIN) from 1st-2nd status words (9th BIN FROM LIST OF ROS in 2nd status word)
968  MonitorElement* hROSStatus = dduHistos["ROSStatus"][code.getDDUID()];
969  //1D HISTO: NUMBER OF ROS IN THE EVENTS from 2nd status word
970 
971  int rosList = secondWord.rosList();
972  set<int> rosPositions;
973  for(int i=0;i<12;i++) {
974  if(rosList & 0x1) {
975  rosPositions.insert(i);
976  //9th BIN FROM LIST OF ROS in 2nd status word
977  if(mode <= 2) hROSStatus->Fill(8,i,1);
978  }
979  rosList >>= 1;
980  }
981 
982  int channel=0;
983  for (vector<DTDDUFirstStatusWord>::const_iterator fsw_it = data.getFirstStatusWord().begin();
984  fsw_it != data.getFirstStatusWord().end(); fsw_it++) {
985  // assuming association one-to-one between DDU channel and ROS
986  if(mode <= 2) {
987  hROSStatus->Fill(0,channel,(*fsw_it).channelEnabled());
988  hROSStatus->Fill(1,channel,(*fsw_it).timeout());
989  hROSStatus->Fill(2,channel,(*fsw_it).eventTrailerLost());
990  hROSStatus->Fill(3,channel,(*fsw_it).opticalFiberSignalLost());
991  hROSStatus->Fill(4,channel,(*fsw_it).tlkPropagationError());
992  hROSStatus->Fill(5,channel,(*fsw_it).tlkPatternError());
993  hROSStatus->Fill(6,channel,(*fsw_it).tlkSignalLost());
994  hROSStatus->Fill(7,channel,(*fsw_it).errorFromROS());
995  }
996  // check that the enabled channel was also in the read-out
997  if((*fsw_it).channelEnabled() == 1 &&
998  rosPositions.find(channel) == rosPositions.end()) {
999  if(mode <= 2) hROSStatus->Fill(9,channel,1);
1000  // error code 1
1001  hFEDFatal->Fill(code.getDDUID());
1002  hCorruptionSummary->Fill(code.getDDUID(), 1);
1003  }
1004  channel++;
1005  }
1006 
1007 
1008  // ---------------------------------------------------------------------
1009  // cross checks between FED and ROS data
1010  // check the BX ID against the ROSs
1011  set<int> rosBXIds = rosBxIdsPerFED[ddu];
1012  if((rosBXIds.size() > 1 || rosBXIds.find(header.bxID()) == rosBXIds.end()) && rosBXIds.size() != 0) { // in this case look for faulty ROSs
1013  for(vector<DTROS25Data>::const_iterator rosControlData = rosData.begin();
1014  rosControlData != rosData.end(); ++rosControlData) { // loop over the ROS data
1015  for (vector<DTROSDebugWord>::const_iterator debug_it = (*rosControlData).getROSDebugs().begin();
1016  debug_it != (*rosControlData).getROSDebugs().end(); debug_it++) { // Loop over ROS debug words
1017  if ((*debug_it).debugType() == 0 && (*debug_it).debugMessage() != header.bxID()) { // check the BX
1018  int ros = (*rosControlData).getROSID();
1019  // fill the error bin
1020  if(mode <= 2) hROSStatus->Fill(11,ros-1);
1021  // error code 2
1022  hFEDFatal->Fill(code.getDDUID());
1023  hCorruptionSummary->Fill(code.getDDUID(), 2);
1024  }
1025  }
1026  }
1027  }
1028 
1029  // check the BX ID against other FEDs
1030  fedBXIds.insert(header.bxID());
1031  if(fedBXIds.size() != 1) {
1032  LogWarning("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
1033  << "ERROR: FED " << ddu << " BX ID different from other feds: " << header.bxID() << endl;
1034  // error code 3
1035  hFEDFatal->Fill(code.getDDUID());
1036  hCorruptionSummary->Fill(code.getDDUID(), 3);
1037  }
1038 
1039 
1040  // check the L1A ID against the ROSs
1041  set<int> rosL1AIds = rosL1AIdsPerFED[ddu];
1042  if((rosL1AIds.size() > 1 || rosL1AIds.find(header.lvl1ID()-1) == rosL1AIds.end()) && rosL1AIds.size() != 0) { // in this case look for faulty ROSs
1043  //If L1A_ID error identify which ROS has wrong L1A
1044  for (vector<DTROS25Data>::const_iterator rosControlData = rosData.begin();
1045  rosControlData != rosData.end(); rosControlData++) { // loop over the ROS data
1046  int ROSHeader_TTCCount = ((*rosControlData).getROSHeader().TTCEventCounter() + 1) % 0x1000000; // fix comparison in case of last counting bin in ROS /first one in DDU
1047  if( ROSHeader_TTCCount != header.lvl1ID() ) {
1048  int ros = (*rosControlData).getROSID();
1049  if(mode <= 2) hROSStatus->Fill(10,ros-1);
1050  // error code 4
1051  hFEDFatal->Fill(code.getDDUID());
1052  hCorruptionSummary->Fill(code.getDDUID(), 4);
1053  }
1054  }
1055  }
1056 
1057  //1D HISTOS: EVENT LENGHT from trailer
1058  int fedEvtLenght = trailer.lenght()*8;
1059  // if(fedEvtLenght > 16000) fedEvtLenght = 16000; // overflow bin
1060  dduHistos["EventLenght"][code.getDDUID()]->Fill(fedEvtLenght);
1061 
1062  if(mode > 1) return;
1063 
1064 
1065  // size of the list of ROS in the Read-Out
1066  dduHistos["ROSList"][code.getDDUID()]->Fill(rosPositions.size());
1067 
1068 
1069  //2D HISTO: FIFO STATUS from 2nd status word
1070  MonitorElement *hFIFOStatus = dduHistos["FIFOStatus"][code.getDDUID()];
1071  int inputFifoFull = secondWord.inputFifoFull();
1072  int inputFifoAlmostFull = secondWord.inputFifoAlmostFull();
1073  int fifoFull = secondWord.fifoFull();
1074  int fifoAlmostFull = secondWord.fifoAlmostFull();
1075  int outputFifoFull = secondWord.outputFifoFull();
1076  int outputFifoAlmostFull = secondWord.outputFifoAlmostFull();
1077  for(int i=0;i<3;i++){
1078  if(inputFifoFull & 0x1){
1079  hFIFOStatus->Fill(i,0);
1080  }
1081  if(inputFifoAlmostFull & 0x1){
1082  hFIFOStatus->Fill(i,1);
1083  }
1084  if(fifoFull & 0x1){
1085  hFIFOStatus->Fill(3+i,0);
1086  }
1087  if(fifoAlmostFull & 0x1){
1088  hFIFOStatus->Fill(3+i,1);
1089  }
1090  if(!(inputFifoFull & 0x1) && !(inputFifoAlmostFull & 0x1)){
1091  hFIFOStatus->Fill(i,2);
1092  }
1093  if(!(fifoFull & 0x1) && !(fifoAlmostFull & 0x1)){
1094  hFIFOStatus->Fill(3+i,2);
1095  }
1096  inputFifoFull >>= 1;
1097  inputFifoAlmostFull >>= 1;
1098  fifoFull >>= 1;
1099  fifoAlmostFull >>= 1;
1100  }
1101 
1102  if(outputFifoFull){
1103  hFIFOStatus->Fill(6,0);
1104  }
1105  if(outputFifoAlmostFull){
1106  hFIFOStatus->Fill(6,1);
1107  }
1108  if(!outputFifoFull && !outputFifoAlmostFull){
1109  hFIFOStatus->Fill(6,2);
1110  }
1111 
1112 
1113 
1114 
1115 
1116 
1117 
1118  //1D HISTO: EVENT TYPE from header
1119  dduHistos["EventType"][code.getDDUID()]->Fill(header.triggerType());
1120 
1121  // fill the distribution of the BX ids
1122  dduHistos["BXID"][code.getDDUID()]->Fill(header.bxID());
1123 
1124 
1125 }
1126 
1127 
1129  return eventErrorFlag;
1130 }
1131 
1132 
1133 
1134 // log number of times the payload of each fed is unpacked
1136  hFEDEntry->Fill(dduID);
1137 }
1138 
1139 
1140 
1141 // log number of times the payload of each fed is skipped (no ROS inside)
1143  hFEDFatal->Fill(dduID);
1144 }
1145 
1146 
1147 
1148 // log number of times the payload of each fed is partially skipped (some ROS skipped)
1150  hFEDNonFatal->Fill(dduID);
1151 }
1152 
1153 std::string DTDataIntegrityTask::topFolder(bool isFEDIntegrity) const {
1154 
1155  string folder = isFEDIntegrity ? fedIntegrityFolder : "DT/00-DataIntegrity";
1156 
1157  if (!isFEDIntegrity)
1158  folder += (mode==1) ? "_SM/" : (mode==3) ? "_EvF/" : "/";
1159 
1160  return folder;
1161 
1162 }
1163 
1164 void DTDataIntegrityTask::channelsInCEROS(int cerosId, int chMask, vector<int>& channels ){
1165  for (int iCh=0; iCh<6;++iCh) {
1166  if ((chMask >> iCh) & 0x1){
1167  channels.push_back(cerosId*6+iCh);
1168  }
1169  }
1170  return;
1171 }
1172 
1173 void DTDataIntegrityTask::channelsInROS(int cerosMask, vector<int>& channels){
1174  for (int iCeros=0; iCeros<5;++iCeros) {
1175  if ((cerosMask >> iCeros) & 0x1){
1176  for (int iCh=0; iCh<6;++iCh) {
1177  channels.push_back(iCeros*6+iCh);
1178  }
1179  }
1180  }
1181  return;
1182 }
1183 
1185  LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask") << "[DTDataIntegrityTask]: preProcessEvent" <<endl;
1186  // clear the set of BXids from the ROSs
1187  for(map<int, set<int> >::iterator rosBxIds = rosBxIdsPerFED.begin();
1188  rosBxIds != rosBxIdsPerFED.end(); ++rosBxIds) {
1189  (*rosBxIds).second.clear();
1190  }
1191 
1192  fedBXIds.clear();
1193 
1194  for(map<int, set<int> >::iterator rosL1AIds = rosL1AIdsPerFED.begin();
1195  rosL1AIds != rosL1AIdsPerFED.end(); ++rosL1AIds) {
1196  (*rosL1AIds).second.clear();
1197  }
1198 
1199 
1200 
1201  // reset the error flag
1202  eventErrorFlag = false;
1203 }
1204 
1205 
1206 
1208  LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask") << "[DTDataIntegrityTask]: postBeginJob" <<endl;
1209  // get the DQMStore service if needed
1211  LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask") << "[DTDataIntegrityTask] Get DQMStore service" << endl;
1212 
1213 
1214 
1215  // Loop over the DT FEDs
1216  int FEDIDmin = FEDNumbering::MINDTFEDID;
1217  int FEDIDMax = FEDNumbering::MAXDTFEDID;
1218 
1219  LogTrace("DTRawToDigi|DTDQM|DTMonitorModule|DTDataIntegrityTask")
1220  << " FEDS: " << FEDIDmin << " to " << FEDIDMax << " in the RO" << endl;
1221 
1222  // book FED integrity histos
1223  bookHistos(FEDIDmin, FEDIDMax);
1224 
1225  // static booking of the histograms
1226  for(int fed = FEDIDmin; fed <= FEDIDMax; ++fed) { // loop over the FEDs in the readout
1227  DTROChainCoding code;
1228  code.setDDU(fed);
1229 
1230  bookHistos( string("ROS_S"), code);
1231 
1232  bookHistos( string("DDU"), code);
1233 
1234  for(int ros = 1; ros <= 12; ++ros) {// loop over all ROS
1235  code.setROS(ros);
1236  bookHistosROS25(code);
1237  }
1238  }
1239 
1240 }
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:276
T getUntrackedParameter(std::string const &, T const &) const
const std::vector< DTROBHeader > & getROBHeaders() const
Definition: DTControlData.h:61
int i
Definition: DBlmapReader.cc:9
void preProcessEvent(const edm::EventID &iEvtid, const edm::Timestamp &iTime)
std::map< std::string, std::map< int, MonitorElement * > > dduHistos
int FirstRos
bool check()
Definition: FEDTrailer.cc:66
const std::vector< DTTDCData > & getTDCData() const
Definition: DTControlData.h:64
std::multimap< std::string, std::string >::iterator it
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:514
void setAxisRange(double xmin, double xmax, int axis=1)
set x-, y- or z-axis range (axis=1, 2, 3 respectively)
void processFED(DTDDUData &dduData, const std::vector< DTROS25Data > &rosData, int dduID)
int outputFifoFull() const
Definition: DTDDUWords.h:931
int PC() const
Definition: DTDDUWords.h:640
MonitorElement * hFEDNonFatal
int rosList() const
Definition: DTDDUWords.h:933
const DTLocalTriggerSectorCollectorHeaderWord & getSCPrivHeader() const
Definition: DTControlData.h:68
void ROSWords_t(double &ResetCount_unfolded, int ROS_number, int ROSDebug_BcntResCnt, int nevents)
void watchPreProcessEvent(PreProcessEvent::slot_type const &iSlot)
int l1AFifoOccupancy() const
Definition: DTDDUWords.h:275
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)
int getROS() const
tuple histo
Definition: trackerHits.py:12
double ResetCount_unfolded
int busyROSPAF() const
Definition: DTDDUWords.h:935
int l1AIDError() const
Definition: DTDDUWords.h:925
void channelsInROS(int cerosMask, std::vector< int > &channels)
MonitorElement * hFEDFatal
int getNbinsY(void) const
get # of bins in Y-axis
void Fill(long long x)
const DTLocalTriggerTrailerWord & getSCTrailer() const
Definition: DTControlData.h:69
int warningROSPAF() const
Definition: DTDDUWords.h:934
int getSCID() const
int TTCEventCounter() const
Definition: DTDDUWords.h:227
void processROS25(DTROS25Data &data, int dduID, int ros)
const std::vector< DTROSDebugWord > & getROSDebugs() const
Definition: DTControlData.h:60
const std::vector< DTDDUFirstStatusWord > & getFirstStatusWord() const
const DTROSTrailerWord & getROSTrailer() const
Definition: DTControlData.h:57
const DTROSHeaderWord & getROSHeader() const
Definition: DTControlData.h:58
int TPX() const
Definition: DTDDUWords.h:274
void bookHistosROS25(DTROChainCoding code)
int j
Definition: DBlmapReader.cc:9
int fifoFull() const
Definition: DTDDUWords.h:927
int nevents
MonitorElement * get(const std::string &path) const
get ME from full pathname (e.g. &quot;my/long/dir/my_histo&quot;)
Definition: DQMStore.cc:1265
#define LogTrace(id)
bool crcErrorBit() const
std::map< std::string, std::map< int, MonitorElement * > > rosSHistos
void TimeHistos(std::string histoType)
int getDDUID() const
const unsigned long long max_bx
const FEDTrailer & getDDUTrailer() const
int inputFifoAlmostFull() const
Definition: DTDDUWords.h:930
int ttsBits()
Current value of the Trigger Throttling System bitsAQ).
Definition: FEDTrailer.cc:34
int robID() const
Definition: DTDDUWords.h:431
int inputFifoFull() const
Definition: DTDDUWords.h:928
std::string topFolder(bool isFEDIntegrity) const
bool check()
Check that the header is OK.
Definition: FEDHeader.cc:66
const FEDHeader & getDDUHeader() const
Getters.
string fullName
MonitorElement * hFEDEntry
void setROB(const int &ID)
std::map< std::string, std::map< int, MonitorElement * > > rosHistos
int lenght()
The length of the event fragment counted in 64-bit words including header and trailer.
Definition: FEDTrailer.cc:19
int bxID()
The bunch crossing number.
Definition: FEDHeader.cc:26
void setROS(const int &ID)
void bookHistos(const int fedMin, const int fedMax)
const std::vector< DTROBTrailerWord > & getROBTrailers() const
Definition: DTControlData.h:62
int getDDU() const
int bxIDError() const
Definition: DTDDUWords.h:926
DTDataIntegrityTask(const edm::ParameterSet &ps, edm::ActivityRegistry &reg)
void channelsInCEROS(int cerosId, int chMask, std::vector< int > &channels)
double getBinContent(int binx) const
get content of bin (1-D)
int getROB() const
int outputFifoAlmostFull() const
Definition: DTDDUWords.h:932
void setDDU(const int &ID)
need to reset the bits before setting
const std::vector< DTROSErrorWord > & getROSErrors() const
Definition: DTControlData.h:59
MonitorElement * hTTSSummary
std::set< int > fedBXIds
int getNbinsX(void) const
get # of bins in X-axis
int lvl1ID()
Level-1 event number generated by the TTC system.
Definition: FEDHeader.cc:22
int fifoAlmostFull() const
Definition: DTDDUWords.h:929
MonitorElement * book2D(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY)
Book 2D histogram.
Definition: DQMStore.cc:642
int triggerType()
Event Trigger type identifier.
Definition: FEDHeader.cc:18
const std::vector< DTTDCError > & getTDCError() const
Definition: DTControlData.h:65
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:936
MonitorElement * hCorruptionSummary
int bunchID() const
Definition: DTDDUWords.h:433
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:232
void watchPostBeginJob(PostBeginJob::slot_type const &iSlot)
convenience function for attaching to signal
int getROSID() const