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