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