CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CSCDQM_EventProcessor_processExaminer.cc
Go to the documentation of this file.
1 /*
2  * =====================================================================================
3  *
4  * Filename: EventProcessor.cc
5  *
6  * Description: Process Examiner output
7  *
8  * Version: 1.0
9  * Created: 10/03/2008 10:47:11 AM
10  * Revision: none
11  * Compiler: gcc
12  *
13  * Author: Valdas Rapsevicius (VR), Valdas.Rapsevicius@cern.ch
14  * Company: CERN, CH
15  *
16  * =====================================================================================
17  */
18 
19 #include "CSCDQM_EventProcessor.h"
20 
21 namespace cscdqm
22 {
23 
29 {
30 
31  bool eventAccepted = true;
32  MonitorObject* mo = 0;
33 
34  uint32_t binErrorStatus = digi.getDDUSummaryErrors();
35 
37  {
38 
39  const std::set<DDUIdType> DDUs = digi.getListOfDDUs();
40  for (std::set<DDUIdType>::const_iterator ddu_itr = DDUs.begin(); ddu_itr != DDUs.end(); ++ddu_itr)
41  {
42  ExaminerStatusType errs = digi.getDDUErrors(*ddu_itr);
43  int dduID = (*ddu_itr)&0xFF;
44  if ( ((*ddu_itr) >= FEDNumbering::MINCSCDDUFEDID) && ((*ddu_itr) <= FEDNumbering::MAXCSCDDUFEDID) )
45  {
46  // dduID = (*ddu_itr) - FEDNumbering::MINCSCDDUFEDID + 1; /// TODO: Can require DDU-RUI remapping for actual system
47  dduID = cscdqm::Utility::getRUIfromDDUId((*ddu_itr));
48  if (dduID < 0) {
49  LOG_WARN << "DDU source ID (" << (*ddu_itr) << ") is out of valid range. Remapping to DDU ID 1.";
50  dduID = 1;
51  }
52  }
53  if (errs != 0)
54  {
55  for (int i = 0; i < 29; i++)
56  {
57  if ((errs >> i) & 0x1 )
58  {
59  mo->Fill(dduID, i + 1);
60  }
61  }
62  }
63  else
64  {
65  mo->Fill(dduID, 0);
66  }
67  }
68 
69  }
70 
71  // =VB= We want to use DCC level check mask as in CSCDCCUnpacker and not DDU mask
72  // Otherwise whole DCC event could be skipped because of a single chamber error
73  unsigned long dccBinCheckMask = 0x06080016;
74 // if ((binErrorStatus & config->getDDU_BINCHECK_MASK()) > 0) {
75  if ((binErrorStatus & dccBinCheckMask) > 0)
76  {
77  eventAccepted = false;
78  }
79 
80  if (binErrorStatus != 0)
81  {
83  }
84 
87  {
88  uint32_t i = 0;
89  CSCIdType chamberID = 0;
90  while (digi.nextCSCWithPayload(i, chamberID))
91  {
92 
93  int crateID = (chamberID >> 4) & 0xFF;
94  int dmbSlot = chamberID & 0xF;
95 
96  if (crateID == 255)
97  {
98  continue;
99  }
100  if ((crateID > 60) || (dmbSlot > 10) || (crateID <= 0) || (dmbSlot <= 0) )
101  {
102  continue;
103  }
104 
105  // Check if in standby!
106  {
107  CSCDetId cid;
108  if (!config->fnGetCSCDetId(crateID, dmbSlot, cid))
109  {
110  continue;
111  }
112  }
113 
115  config->incChamberCounter(DMB_EVENTS, crateID, dmbSlot);
116  long DMBEvents = config->getChamberCounterValue(DMB_EVENTS, crateID, dmbSlot);
118  cntDMBs++;
119 
121  {
122  mo->Fill(crateID, dmbSlot);
123  }
124 
125  unsigned int cscType = 0;
126  unsigned int cscPosition = 0;
127  if (!getCSCFromMap(crateID, dmbSlot, cscType, cscPosition)) continue;
128 
129  if (cscPosition && getEMUHisto(h::EMU_CSC_REPORTING, mo))
130  {
131  mo->Fill(cscPosition, cscType);
132  }
133 
135  long payload = digi.getCSCPayload(chamberID);
136  int cfeb_dav = (payload >> 7) & 0x7F;
137  int cfeb_active = payload & 0x1F;
138  cfeb_active |= ((payload >> 14) &0x03) << 5;
139  int alct_dav = (payload >> 5) & 0x1;
140  int tmb_dav = (payload >> 6) & 0x1;
141  int cfeb_dav_num = 0;
142 
143  if (alct_dav == 0)
144  {
145  if (cscPosition && getEMUHisto(h::EMU_CSC_WO_ALCT, mo))
146  {
147  mo->Fill(cscPosition, cscType);
148  }
150  {
151  mo->Fill(crateID, dmbSlot);
152  }
153  }
154 
155  if (tmb_dav == 0)
156  {
157  if (cscPosition && getEMUHisto(h::EMU_CSC_WO_CLCT, mo))
158  {
159  mo->Fill(cscPosition, cscType);
160  }
162  {
163  mo->Fill(crateID, dmbSlot);
164  }
165  }
166 
167  if (cfeb_dav == 0)
168  {
169  if (cscPosition && getEMUHisto(h::EMU_CSC_WO_CFEB, mo))
170  {
171  mo->Fill(cscPosition, cscType);
172  }
174  {
175  mo->Fill(crateID, dmbSlot);
176  }
177  }
178 
180  for (int i=0; i<7; i++)
181  {
182  if ((cfeb_dav>>i) & 0x1) cntCFEBs++;
183  }
184 
185  if (alct_dav > 0)
186  {
187  cntALCTs++;
188  }
189 
190  if (tmb_dav > 0)
191  {
192  cntTMBs++;
193  }
194 
195 
196  MonitorObject *mof = 0, *mo1 = 0, *mo2 = 0;
197  if (getCSCHisto(h::CSC_ACTUAL_DMB_CFEB_DAV_RATE, crateID, dmbSlot, mo)
198  && getCSCHisto(h::CSC_ACTUAL_DMB_CFEB_DAV_FREQUENCY, crateID, dmbSlot, mof))
199  {
200  if (getCSCHisto(h::CSC_DMB_CFEB_DAV_UNPACKING_INEFFICIENCY, crateID, dmbSlot, mo1)
201  && getCSCHisto(h::CSC_DMB_CFEB_DAV, crateID, dmbSlot, mo2))
202  {
203  for (int i=1; i<=7; i++)
204  {
205  double actual_dav_num = mo->GetBinContent(i);
206  double unpacked_dav_num = mo2->GetBinContent(i);
207  if (actual_dav_num)
208  {
209  mo1->SetBinContent(i,1, 100.*(1-unpacked_dav_num/actual_dav_num));
210  }
211  mo1->SetEntries((int)DMBEvents);
212  }
213  }
214  for (int i=0; i<7; i++)
215  {
216  int cfeb_present = (cfeb_dav>>i) & 0x1;
217  cfeb_dav_num += cfeb_present;
218  if (cfeb_present)
219  {
220  mo->Fill(i);
221  }
222  float cfeb_entries = mo->GetBinContent(i+1);
223  mof->SetBinContent(i+1, ((float)cfeb_entries/(float)(DMBEvents)*100.0));
224  }
225  mof->SetEntries((int)DMBEvents);
226  }
227 
230  {
231  for (unsigned short i = 1; i < 7; i++)
232  {
233  float cfeb_entries = mo->GetBinContent(i);
234  mof->SetBinContent(i, ((float)cfeb_entries / (float)(DMBEvents) * 100.0));
235  }
236  mof->SetEntries((int)DMBEvents);
237 
239  && getCSCHisto(h::CSC_DMB_CFEB_DAV_MULTIPLICITY, crateID, dmbSlot, mo2))
240  {
241  for (unsigned short i = 1; i < 9; i++)
242  {
243  float actual_dav_num = mo->GetBinContent(i);
244  float unpacked_dav_num = mo2->GetBinContent(i);
245  if (actual_dav_num)
246  {
247  mo1->SetBinContent(i, 1, 100. * (1-unpacked_dav_num/actual_dav_num));
248  }
249  mo1->SetEntries((int)DMBEvents);
250  }
251  }
252  mo->Fill(cfeb_dav_num);
253  }
254 
255  if (getCSCHisto(h::CSC_DMB_CFEB_ACTIVE_VS_DAV, crateID, dmbSlot, mo)) mo->Fill(cfeb_dav, cfeb_active);
256 
258  if (getCSCHisto(h::CSC_ACTUAL_DMB_FEB_DAV_RATE, crateID, dmbSlot, mo))
259  {
260  if (getCSCHisto(h::CSC_ACTUAL_DMB_FEB_DAV_FREQUENCY, crateID, dmbSlot, mo1))
261  {
262  for (int i = 1; i < 4; i++)
263  {
264  float dav_num = mo->GetBinContent(i);
265  mo1->SetBinContent(i, ((float)dav_num / (float)(DMBEvents) * 100.0));
266  }
267  mo1->SetEntries((int)DMBEvents);
268 
269  if (getCSCHisto(h::CSC_DMB_FEB_DAV_UNPACKING_INEFFICIENCY, crateID, dmbSlot, mof)
270  && getCSCHisto(h::CSC_DMB_FEB_DAV_RATE, crateID, dmbSlot, mo2))
271  {
272  for (int i = 1; i < 4; i++)
273  {
274  float actual_dav_num = mo->GetBinContent(i);
275  float unpacked_dav_num = mo2->GetBinContent(i);
276  if (actual_dav_num)
277  {
278  mof->SetBinContent(i,1, 100. * (1 - unpacked_dav_num / actual_dav_num));
279  }
280  mof->SetEntries((int)DMBEvents);
281  mof->SetMaximum(100.0);
282  }
283  }
284  }
285 
286  if (alct_dav > 0)
287  {
288  mo->Fill(0.0);
289  }
290  if (tmb_dav > 0)
291  {
292  mo->Fill(1.0);
293  }
294  if (cfeb_dav > 0)
295  {
296  mo->Fill(2.0);
297  }
298  }
299 
300 
301  float feb_combination_dav = -1.0;
303  if (getCSCHisto(h::CSC_ACTUAL_DMB_FEB_COMBINATIONS_DAV_RATE, crateID, dmbSlot, mo))
304  {
305  if (alct_dav == 0 && tmb_dav == 0 && cfeb_dav == 0) feb_combination_dav = 0.0; // Nothing
306  if (alct_dav > 0 && tmb_dav == 0 && cfeb_dav == 0) feb_combination_dav = 1.0; // ALCT Only
307  if (alct_dav == 0 && tmb_dav > 0 && cfeb_dav == 0) feb_combination_dav = 2.0; // TMB Only
308  if (alct_dav == 0 && tmb_dav == 0 && cfeb_dav > 0) feb_combination_dav = 3.0; // CFEB Only
309  if (alct_dav == 0 && tmb_dav > 0 && cfeb_dav > 0) feb_combination_dav = 4.0; // TMB+CFEB
310  if (alct_dav > 0 && tmb_dav > 0 && cfeb_dav == 0) feb_combination_dav = 5.0; // ALCT+TMB
311  if (alct_dav > 0 && tmb_dav == 0 && cfeb_dav > 0) feb_combination_dav = 6.0; // ALCT+CFEB
312  if (alct_dav > 0 && tmb_dav > 0 && cfeb_dav > 0) feb_combination_dav = 7.0; // ALCT+TMB+CFEB
313  // mo->Fill(feb_combination_dav);
314 
316  {
317  for (int i = 1; i < 9; i++)
318  {
319  float feb_combination_dav_number = mo->GetBinContent(i);
320  mo1->SetBinContent(i, ((float)feb_combination_dav_number / (float)(DMBEvents) * 100.0));
321  }
322  mo1->SetEntries(DMBEvents);
323 
325  && getCSCHisto(h::CSC_DMB_FEB_COMBINATIONS_DAV_RATE, crateID, dmbSlot, mo2))
326  {
327  for (int i = 1; i < 9; i++)
328  {
329  float actual_dav_num = mo->GetBinContent(i);
330  float unpacked_dav_num = mo2->GetBinContent(i);
331  if (actual_dav_num)
332  {
333  mof->SetBinContent(i, 1, 100. * (1 - unpacked_dav_num / actual_dav_num));
334  }
335  mof->SetEntries((int)DMBEvents);
336  mof->SetMaximum(100.0);
337  }
338  }
339 
340  }
341  mo->Fill(feb_combination_dav);
342  }
343 
344  }
345  }
346 
349  {
350  uint32_t i = 0;
351  CSCIdType chamberID = 0;
352  while (digi.nextCSCWithStatus(i, chamberID))
353  {
354 
355  unsigned int crateID = (chamberID >> 4) & 0xFF;
356  unsigned int dmbSlot = chamberID & 0xF;
357  ExaminerStatusType chStatus = digi.getCSCStatus(chamberID);
358 
359  if (crateID == 255)
360  {
361  continue;
362  }
363  if ((crateID > 60) || (dmbSlot > 10) || (crateID <= 0) || (dmbSlot <= 0) )
364  {
365  continue;
366  }
367 
368  // Check if in standby!
369  {
370  CSCDetId cid;
371  if (!config->fnGetCSCDetId(crateID, dmbSlot, cid))
372  {
373  continue;
374  }
375  }
376 
377  unsigned int cscType = 0;
378  unsigned int cscPosition = 0;
379  if (!getCSCFromMap(crateID, dmbSlot, cscType, cscPosition)) continue;
380 
381  if (getCSCHisto(h::CSC_BINCHECK_DATAFLOW_PROBLEMS_TABLE, crateID, dmbSlot, mo))
382  {
383  for (int bit = 0; bit < binChecker.nSTATUSES; bit++)
384  {
385  if (chStatus & (1<<bit) )
386  {
387  mo->Fill(0., bit);
388  }
389  }
390  mo->SetEntries(config->getChamberCounterValue(DMB_EVENTS, crateID, dmbSlot));
391  }
392 
393 
394  int anyInputFull = chStatus & 0x3F;
395  if (anyInputFull)
396  {
397  if (cscPosition && getEMUHisto(h::EMU_CSC_DMB_INPUT_FIFO_FULL, mo))
398  {
399  mo->Fill(cscPosition, cscType);
400  }
402  {
403  mo->Fill(crateID, dmbSlot);
404  }
405  }
406 
407  int anyInputTO = (chStatus >> 7) & 0x3FFF;
408  if (anyInputTO)
409  {
410  if (cscPosition && getEMUHisto(h::EMU_CSC_DMB_INPUT_TIMEOUT, mo))
411  {
412  mo->Fill(cscPosition, cscType);
413  }
415  {
416  mo->Fill(crateID, dmbSlot);
417  }
418  }
419 
420  if (digi.getCSCStatus(chamberID) & (1 << 22))
421  {
423  {
424  mo->Fill(crateID, dmbSlot);
425  }
426 
427  if (cscPosition && getEMUHisto(h::EMU_CSC_FORMAT_WARNINGS, mo))
428  {
429  mo->Fill(cscPosition, cscType);
430  }
431 
432  }
433  }
434 
435  }
436 
439  {
440  uint32_t i = 0;
441  CSCIdType chamberID = 0;
442  while (digi.nextCSCWithError(i, chamberID))
443  {
444 
445  const unsigned int crateID = (chamberID >> 4) & 0xFF;
446  const unsigned int dmbSlot = chamberID & 0xF;
447  const ExaminerStatusType chErr = digi.getCSCErrors(chamberID);
448 
449  if ((crateID ==255) || (chErr & 0x80))
450  {
451  continue; // = Skip chamber detection if DMB header is missing (Error code 6)
452  }
453  if ((crateID > 60) || (dmbSlot > 10) || (crateID <= 0) || (dmbSlot <= 0) )
454  {
455  continue;
456  }
457 
458 
459  // Check if in standby!
460  {
461  CSCDetId cid;
462  if (!config->fnGetCSCDetId(crateID, dmbSlot, cid))
463  {
464  continue;
465  }
466  }
467 
468  if ((chErr & config->getBINCHECK_MASK()) != 0)
469  {
470  config->incChamberCounter(BAD_EVENTS, crateID , dmbSlot);
471  }
472 
473  bool isCSCError = false;
474  bool fillBC = getCSCHisto(h::CSC_BINCHECK_ERRORSTAT_TABLE, crateID, dmbSlot, mo);
475 
476  for (int bit = 5; bit < 24; bit++)
477  {
478 
479  if (chErr & (1 << bit) )
480  {
481  isCSCError = true;
482  if (fillBC)
483  {
484  mo->Fill(0., bit - 5);
485  }
486  else
487  {
488  break;
489  }
490  }
491 
492  if (fillBC)
493  {
494  mo->SetEntries(config->getChamberCounterValue(DMB_EVENTS, crateID , dmbSlot));
495  }
496 
497  }
498 
499  if (isCSCError)
500  {
501 
503  {
504  mo->Fill(crateID, dmbSlot);
505  }
506 
507  if (eventAccepted && getEMUHisto(h::EMU_DMB_UNPACKED_WITH_ERRORS, mo))
508  {
509  mo->Fill(crateID, dmbSlot);
510  }
511 
512  unsigned int cscType = 0;
513  unsigned int cscPosition = 0;
514  if (!getCSCFromMap(crateID, dmbSlot, cscType, cscPosition)) continue;
515 
516  if ( cscPosition && getEMUHisto(h::EMU_CSC_FORMAT_ERRORS, mo))
517  {
518  mo->Fill(cscPosition, cscType);
519  }
520 
521  if (eventAccepted && cscPosition && getEMUHisto(h::EMU_CSC_UNPACKED_WITH_ERRORS, mo))
522  {
523  mo->Fill(cscPosition, cscType);
524  }
525  }
526 
527  }
528  }
529 
530  return eventAccepted;
531 
532 }
533 
534 }
const uint16_t nSTATUSES
const bool getCSCFromMap(const unsigned int &crateId, const unsigned int &dmbId, unsigned int &cscType, unsigned int &cscPosition) const
Get CSC type and position from crate and dmb identifiers.
int i
Definition: DBlmapReader.cc:9
uint32_t cntCFEBs
Total Number of DMBs per event from DDU Header DAV.
void incChamberCounter(const ChamberCounterType counter, const HwId crateId, const HwId dmbId)
Increment Chamber counter by 1.
virtual void SetEntries(const double value)=0
int32_t CSCIdType
virtual void Fill(float x)=0
ExaminerStatusType getDDUSummaryErrors() const
Monitoring Object interface used to cover Root object and provide common interface to EventProcessor ...
std::set< DDUIdType > getListOfDDUs() const
ExaminerStatusType getCSCStatus(const CSCIdType CSCId) const
static int getRUIfromDDUId(unsigned ddu_id)
Get RUI Number from DDU source ID for post LS1 configuration.
bool nextCSCWithStatus(uint32_t &iterator, CSCIdType &CSCId) const
CSC with status iteration procedure.
ExaminerStatusType getCSCErrors(const CSCIdType CSCId) const
ExaminerStatusType getDDUErrors(const DDUIdType DDUId) const
bool nextCSCWithError(uint32_t &iterator, CSCIdType &CSCId) const
CSC with error iteration procedure. Usage: unsigned int i = 0; CSCIdType cscId; while (c...
const bool getCSCHisto(const HistoId &histo, const HwId &crateID, const HwId &dmbSlot, MonitorObject *&me)
Get CSC (Chamber) Level Monitoring Object.
uint32_t cntTMBs
Total Number of ALCTs per event from DMB DAV.
uint32_t cntALCTs
Total Number of CFEBs per event from DMB DAV.
virtual void SetBinContent(const int binX, const double value)=0
boost::function< bool(const unsigned int, const unsigned int, CSCDetId &) > fnGetCSCDetId
CSCDetId chamberID(const CSCDetId &cscDetId)
takes layer ID, converts to chamber ID, switching ME1A to ME11
Definition: CSCDigiToRaw.cc:31
bool processExaminer(const CSCDCCExaminer &binChecker)
ExaminerStatusType getCSCPayload(const CSCIdType CSCId) const
uint32_t ExaminerStatusType
const uint32_t getChamberCounterValue(const ChamberCounterType counter, const HwId crateId, const HwId dmbId) const
Get Chamber counter value.
void copyChamberCounterValue(const ChamberCounterType counter_from, const ChamberCounterType counter_to, const HwId crateId, const HwId dmbId)
Copy Chamber counter value from one counter to another.
#define LOG_WARN
Definition: CSCDQM_Logger.h:42
virtual double GetBinContent(const int binX)=0
CSC Format Status Object.
virtual void SetMaximum(const double d)=0
bool nextCSCWithPayload(uint32_t &iterator, CSCIdType &CSCId) const
CSC with payload iteration procedure.
const bool getEMUHisto(const HistoId &histo, MonitorObject *&me)
Get EMU (Top Level) Monitoring Object.