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