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