CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CSCDQM_EventProcessor_processEvent.cc
Go to the documentation of this file.
1 /*
2  * =====================================================================================
3  *
4  * Filename: EventProcessor_processEvent.cc
5  *
6  * Description: EventProcessor Object Event entry methods
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 
28 {
29 
30  config->incNEvents();
32 
33 }
34 
35 #ifdef DQMLOCAL
36 
37 
46 void EventProcessor::processEvent(const char* data, const int32_t dataSize, const uint32_t errorStat, const int32_t nodeNumber)
47 {
48 
50 
52 
53  MonitorObject* me = 0;
55  {
56  if (errorStat != 0)
57  {
58  me->Fill(nodeNumber, 1);
59  for (unsigned int i = 0; i < 16; i++)
60  {
61  if ((errorStat >> i) & 0x1)
62  {
63  me->Fill(nodeNumber, i + 2);
64  }
65  }
66  }
67  else
68  {
69  me->Fill(nodeNumber, 0);
70  }
71  }
72 
73  bool eventDenied = false;
74  if (((uint32_t) errorStat & config->getDDU_CHECK_MASK()) > 0)
75  {
76  eventDenied = true;
77  }
78 
79  const uint16_t *tmp = reinterpret_cast<const uint16_t *>(data);
80  const uint16_t tmpSize = dataSize / sizeof(short);
81 
83  CSCDCCExaminer binChecker;
84  binChecker.crcALCT(config->getBINCHECKER_CRC_ALCT());
85  binChecker.crcTMB(config->getBINCHECKER_CRC_CLCT());
86  binChecker.crcCFEB(config->getBINCHECKER_CRC_CFEB());
87  binChecker.modeDDU(config->getBINCHECKER_MODE_DDU());
88 
89  if (config->getBINCHECKER_OUTPUT())
90  {
91  // binChecker.output1().show();
92  // binChecker.output2().show();
93  }
94  else
95  {
96  // binChecker.output1().hide();
97  // binChecker.output2().hide();
98  }
99 
100  binChecker.setMask(config->getBINCHECK_MASK());
101 
102  if (binChecker.check(tmp, tmpSize) < 0)
103  {
104 
106  const uint16_t dduTrailer[4] = { 0x8000, 0x8000, 0xFFFF, 0x8000 };
107  const uint16_t *tmp = dduTrailer;
108  binChecker.check(tmp, uint32_t(4));
109 
110  }
111 
112  CSCDCCFormatStatusDigi formatStatusDigi(nodeNumber, config->getBINCHECK_MASK(),
113  binChecker.getMask(),
114  binChecker.errors(),
115  binChecker.errorsDetailedDDU(),
116  binChecker.errorsDetailed(),
117  binChecker.payloadDetailed(),
118  binChecker.statusDetailed());
119 
120  if (processExaminer(binChecker, formatStatusDigi))
121  {
122 
124 
125  if (config->getPROCESS_DDU())
126  {
127  CSCDDUEventData dduData((short unsigned int*) tmp, &binChecker);
128  processDDU(dduData, binChecker);
129  }
130 
131  }
132 
133 }
134 
135 #endif
136 
137 #ifdef DQMGLOBAL
138 
139 
148 {
149 
150  preProcessEvent();
151 
153  if (!e.getByToken(frdtoken, rawdata))
154  {
155  LOG_WARN << "No product: " << inputTag << " in stream";
156  return;
157  }
158 
159  bCSCEventCounted = false;
160  size_t eventSize = 0;
161  cntDMBs = 0;
162  cntCFEBs = 0;
163  cntALCTs = 0;
164  cntTMBs = 0;
165  int nDDUs_out_of_sync = 0;
166  int nDDUs_with_CSC_data_out_of_sync = 0;
167  bool fGlobal_DCC_DDU_L1A_mismatch = false;
168  bool fGlobal_DCC_DDU_L1A_mismatch_with_CSC_data = false;
169  MonitorObject* mo = 0;
170 
171  // For new CSC readout layout, which wont include DCCs need to loop over DDU FED IDs. DCC IDs are included for backward compatibility with old data
172  std::vector<unsigned int> cscFEDids;
173 
174  for (unsigned int id=FEDNumbering::MINCSCFEDID;
175  id<=FEDNumbering::MAXCSCFEDID; ++id) // loop over DCCs
176  {
177  cscFEDids.push_back(id);
178  }
179 
180  for (unsigned int id=FEDNumbering::MINCSCDDUFEDID;
181  id<=FEDNumbering::MAXCSCDDUFEDID; ++id) // loop over DDUs
182  {
183  cscFEDids.push_back(id);
184  }
185 
186  // run through the FED's
187  for (unsigned int i=0; i<cscFEDids.size(); i++) // loop over all CSC FEDs (DCCs and DDUs)
188  {
189  unsigned int id = cscFEDids[i];
190  bool isDDU_FED = ((id >= FEDNumbering::MINCSCDDUFEDID) && (id <= FEDNumbering::MAXCSCDDUFEDID))?true:false;
191  // Take a reference to this FED's data and
192  // construct the DCC data object
193  const FEDRawData& fedData = rawdata->FEDData(id);
194 
195  //if fed has data then unpack it
196  if (fedData.size() >= 32)
197  {
198 
199  eventSize += fedData.size();
200 
201  // Count in CSC Event!
202  if (!bCSCEventCounted)
203  {
205  bCSCEventCounted = true;
206  }
207 
208  if ( !isDDU_FED )
209  {
210  // Filling in FED Entries histogram
211  if (getEMUHisto(h::EMU_FED_ENTRIES, mo)) mo->Fill(id);
212 
213  if (getEMUHisto(h::EMU_FED_BUFFER_SIZE, mo)) mo->Fill(id, log10((double)fedData.size()));
214 
215  if (getFEDHisto(h::FED_BUFFER_SIZE, id, mo)) mo->Fill(fedData.size());
216  }
217 
218  const uint16_t *data = (uint16_t *) fedData.data();
219  const size_t dataSize = fedData.size() / 2;
220  const short unsigned int* udata = (short unsigned int*) fedData.data();
221 
223  CSCDCCExaminer binChecker;
224  binChecker.crcALCT(config->getBINCHECKER_CRC_ALCT());
225  binChecker.crcTMB(config->getBINCHECKER_CRC_CLCT());
226  binChecker.crcCFEB(config->getBINCHECKER_CRC_CFEB());
227  binChecker.modeDDU(config->getBINCHECKER_MODE_DDU());
228 
229 
231  if ( isDDU_FED )
232  {
233  binChecker.modeDDU(true);
234  }
235 
236  if (config->getBINCHECKER_OUTPUT())
237  {
238  // binChecker.output1().show();
239  // binChecker.output2().show();
240  }
241  else
242  {
243  // binChecker.output1().hide();
244  // binChecker.output2().hide();
245  }
246 
247  binChecker.setMask(config->getBINCHECK_MASK());
248 
249 
250  if (isDDU_FED)
251  {
252  if (binChecker.check(data, dataSize) >= 0)
253  {
254 
255  CSCDCCFormatStatusDigi formatStatusDigi(id, config->getBINCHECK_MASK(),
256  binChecker.getMask(),
257  binChecker.errors(),
258  binChecker.errorsDetailedDDU(),
259  binChecker.errorsDetailed(),
260  binChecker.payloadDetailed(),
261  binChecker.statusDetailed());
262 
263  if (processExaminer(binChecker, formatStatusDigi))
264  {
265 
267 
268 
269  if (config->getPROCESS_DDU())
270  {
271 
272  CSCDDUEventData dduData(const_cast<short unsigned int*>(udata), &binChecker);
273  processDDU(dduData, binChecker);
274  }
275  }
276  }
277  }
278 
279  else
280  {
281 
282  if (binChecker.check(data, dataSize) < 0)
283  {
284  if (getEMUHisto(h::EMU_FED_FATAL, mo)) mo->Fill(id);
285  }
286  else
287  {
288 
289  CSCDCCFormatStatusDigi formatStatusDigi(id, config->getBINCHECK_MASK(),
290  binChecker.getMask(),
291  binChecker.errors(),
292  binChecker.errorsDetailedDDU(),
293  binChecker.errorsDetailed(),
294  binChecker.payloadDetailed(),
295  binChecker.statusDetailed());
296 
299  {
300  uint32_t errs = binChecker.errors();
301 
302  if (errs != 0)
303  {
304  for (int i = 0; i < 29; i++)
305  {
306  if ((errs >> i) & 0x1 )
307  {
308  mo->Fill(id, i + 1);
309  }
310  }
311  }
312  else
313  {
314  mo->Fill(id, 0);
315  }
316  }
317 
318  if (processExaminer(binChecker, formatStatusDigi))
319  {
320 
322 
323  if (binChecker.warnings() != 0)
324  {
325  if (getEMUHisto(h::EMU_FED_NONFATAL, mo)) mo->Fill(id);
326  }
327 
328  if (config->getPROCESS_DDU())
329  {
330 
331  CSCDCCEventData dccData(const_cast<short unsigned int*>(udata), &binChecker);
332  const std::vector<CSCDDUEventData> & dduData = dccData.dduData();
333 
335  bool fDCC_DDU_L1A_mismatch = false;
336  bool fDCC_DDU_L1A_mismatch_with_CSC_data = false;
337  int DCC_L1A = dccData.dccHeader().getCDFEventNumber();
338  for (int ddu = 0; ddu < (int)dduData.size(); ddu++)
339  {
340  if (DCC_L1A != dduData[ddu].header().lvl1num())
341  {
342  fDCC_DDU_L1A_mismatch = true;
343  fGlobal_DCC_DDU_L1A_mismatch = true;
344  nDDUs_out_of_sync++;
345 
347  if (dduData[ddu].sizeInWords() > 24)
348  {
349  fDCC_DDU_L1A_mismatch_with_CSC_data = true;
350  fGlobal_DCC_DDU_L1A_mismatch_with_CSC_data = true;
351  nDDUs_with_CSC_data_out_of_sync++;
352  /*
353  std::cout << "FED" << id << " L1A:" << DCC_L1A << ", ";
354  std::cout << "DDU" << (dduData[ddu].header().source_id() & 0xFF )
355  << " L1A:" << dduData[ddu].header().lvl1num() << " size:" << (dduData[ddu].sizeInWords()*2);
356  std::cout << " - L1A mismatch";
357  std::cout << std::endl;
358  */
359  }
360 
361  }
362  processDDU(dduData[ddu], binChecker);
363  }
364 
365  if (fDCC_DDU_L1A_mismatch && getEMUHisto(h::EMU_FED_DDU_L1A_MISMATCH, mo)) mo->Fill(id);
366  if (fDCC_DDU_L1A_mismatch_with_CSC_data
368 
369  }
370 
371  }
372  else
373  {
374 
375  if (getEMUHisto(h::EMU_FED_FORMAT_FATAL, mo)) mo->Fill(id);
376 
377  }
378  }
379 
380  }
381 
382  }
383 
384  }
385 
386 
387  if (fGlobal_DCC_DDU_L1A_mismatch && getEMUHisto(h::EMU_FED_DDU_L1A_MISMATCH_CNT, mo)) mo->Fill(nDDUs_out_of_sync);
388  if (fGlobal_DCC_DDU_L1A_mismatch && getEMUHisto(h::EMU_FED_DDU_L1A_MISMATCH_WITH_CSC_DATA_CNT, mo))
389  mo->Fill(nDDUs_with_CSC_data_out_of_sync);
390 
391  if (getEMUHisto(h::EMU_FED_STATS, mo))
392  {
393  mo->Fill(0);
394  if (fGlobal_DCC_DDU_L1A_mismatch) mo->Fill(1);
395  if (fGlobal_DCC_DDU_L1A_mismatch_with_CSC_data) mo->Fill(2);
396  }
397 
398  if (getEMUHisto(h::EMU_FED_EVENT_SIZE, mo)) mo->Fill(eventSize/1024.);
399  if (getEMUHisto(h::EMU_FED_TOTAL_CSC_NUMBER, mo)) mo->Fill(cntDMBs);
402  if (getEMUHisto(h::EMU_FED_TOTAL_TMB_NUMBER, mo)) mo->Fill(cntTMBs);
403 
404 }
405 
406 #endif
407 
408 #undef ECHO_FUNCTION
409 
410 }
01/20/05 A.Tumanov
void crcCFEB(bool enable)
int i
Definition: DBlmapReader.cc:9
uint32_t cntCFEBs
Total Number of DMBs per event from DDU Header DAV.
void preProcessEvent()
Common Local and Global DQM function to be called before processing Event.
void modeDDU(bool enable)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:464
virtual void Fill(float x)=0
Monitoring Object interface used to cover Root object and provide common interface to EventProcessor ...
dispatcher processEvent(e, inputTag, standby)
ExaminerStatusType errors(void) const
void crcALCT(bool enable)
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:47
ExaminerStatusType warnings(void) const
uint32_t cntTMBs
Total Number of ALCTs per event from DMB DAV.
std::map< CSCIdType, ExaminerStatusType > errorsDetailed(void) const
uint32_t cntALCTs
Total Number of CFEBs per event from DMB DAV.
void crcTMB(bool enable)
void processDDU(const CSCDDUEventData &data, const CSCDCCExaminer &binChecker)
Process DDU output and fill MOs.
bool processExaminer(const CSCDCCExaminer &binChecker)
std::map< CSCIdType, ExaminerStatusType > statusDetailed(void) const
ExaminerMaskType getMask() const
#define LOG_WARN
Definition: CSCDQM_Logger.h:42
int32_t check(const uint16_t *&buffer, int32_t length)
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
const bool getFEDHisto(const HistoId &histo, const HwId &fedID, MonitorObject *&me)
Get FED Level Monitoring Object.
std::map< CSCIdType, ExaminerStatusType > payloadDetailed(void) const
CSC Format Status Object.
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
edm::EDGetTokenT< FEDRawDataCollection > frdtoken
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:28
std::map< DDUIdType, ExaminerStatusType > errorsDetailedDDU(void) const
dictionary rawdata
Definition: lumiPlot.py:393
const bool getEMUHisto(const HistoId &histo, MonitorObject *&me)
Get EMU (Top Level) Monitoring Object.
void setMask(ExaminerMaskType mask)