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 
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;
54  if (getEMUHisto(h::EMU_ALL_READOUT_ERRORS, me))
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 
147 void EventProcessor::processEvent(const edm::Event& e, const edm::InputTag& inputTag)
148 {
149 
150  preProcessEvent();
151 
153  if (!e.getByLabel(inputTag, 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  /*
172  const edm::InputTag formatStatusCollectionTag("MuonCSCDCCFormatStatusDigi");
173  bool processFormatStatusDigi = true;
174  edm::Handle<CSCDCCFormatStatusDigiCollection> formatStatusColl;
175  if (!e.getByLabel(formatStatusCollectionTag, formatStatusColl)) {
176  LOG_WARN << "No product: " << formatStatusCollectionTag << " in stream";
177  processFormatStatusDigi = false;
178  }
179  */
180 
181  // run through the DCC's
183  {
184 
185  // Take a reference to this FED's data and
186  // construct the DCC data object
187  const FEDRawData& fedData = rawdata->FEDData(id);
188 
189  //if fed has data then unpack it
190  if (fedData.size() >= 32)
191  {
192 
193  eventSize += fedData.size();
194 
195  // Count in CSC Event!
196  if (!bCSCEventCounted)
197  {
199  bCSCEventCounted = true;
200  }
201 
202  // Filling in FED Entries histogram
203  if (getEMUHisto(h::EMU_FED_ENTRIES, mo)) mo->Fill(id);
204 
205  if (getEMUHisto(h::EMU_FED_BUFFER_SIZE, mo)) mo->Fill(id, log10((double)fedData.size()));
206 
207  if (getFEDHisto(h::FED_BUFFER_SIZE, id, mo)) mo->Fill(fedData.size());
208 
209  const uint16_t *data = (uint16_t *) fedData.data();
210  const size_t dataSize = fedData.size() / 2;
211  const short unsigned int* udata = (short unsigned int*) fedData.data();
212 
214  CSCDCCExaminer binChecker;
215  binChecker.crcALCT(config->getBINCHECKER_CRC_ALCT());
216  binChecker.crcTMB(config->getBINCHECKER_CRC_CLCT());
217  binChecker.crcCFEB(config->getBINCHECKER_CRC_CFEB());
218  binChecker.modeDDU(config->getBINCHECKER_MODE_DDU());
219 
220  if (config->getBINCHECKER_OUTPUT())
221  {
222  binChecker.output1().show();
223  binChecker.output2().show();
224  }
225  else
226  {
227  binChecker.output1().hide();
228  binChecker.output2().hide();
229  }
230 
231  binChecker.setMask(config->getBINCHECK_MASK());
232 
233  if (binChecker.check(data, dataSize) < 0)
234  {
235  if (getEMUHisto(h::EMU_FED_FATAL, mo)) mo->Fill(id);
236  }
237  else
238  {
239  CSCDCCFormatStatusDigi formatStatusDigi(id, config->getBINCHECK_MASK(),
240  binChecker.getMask(),
241  binChecker.errors(),
242  binChecker.errorsDetailedDDU(),
243  binChecker.errorsDetailed(),
244  binChecker.payloadDetailed(),
245  binChecker.statusDetailed());
246 
248  if (getEMUHisto(h::EMU_FED_FORMAT_ERRORS, mo))
249  {
250  uint32_t errs = binChecker.errors();
251 
252  if (errs != 0)
253  {
254  for (int i = 0; i < 29; i++)
255  {
256  if ((errs >> i) & 0x1 )
257  {
258  mo->Fill(id, i + 1);
259  }
260  }
261  }
262  else
263  {
264  mo->Fill(id, 0);
265  }
266  }
267 
268  if (processExaminer(binChecker, formatStatusDigi))
269  {
270 
272 
273  if (binChecker.warnings() != 0)
274  {
275  if (getEMUHisto(h::EMU_FED_NONFATAL, mo)) mo->Fill(id);
276  }
277 
278  if (config->getPROCESS_DDU())
279  {
280 
281  CSCDCCEventData dccData(const_cast<short unsigned int*>(udata), &binChecker);
282  const std::vector<CSCDDUEventData> & dduData = dccData.dduData();
283 
285  bool fDCC_DDU_L1A_mismatch = false;
286  bool fDCC_DDU_L1A_mismatch_with_CSC_data = false;
287  int DCC_L1A = dccData.dccHeader().getCDFEventNumber();
288  for (int ddu = 0; ddu < (int)dduData.size(); ddu++)
289  {
290  if (DCC_L1A != dduData[ddu].header().lvl1num())
291  {
292  fDCC_DDU_L1A_mismatch = true;
293  fGlobal_DCC_DDU_L1A_mismatch = true;
294  nDDUs_out_of_sync++;
295 
297  if (dduData[ddu].sizeInWords() > 24) {
298  fDCC_DDU_L1A_mismatch_with_CSC_data = true;
299  fGlobal_DCC_DDU_L1A_mismatch_with_CSC_data = true;
300  nDDUs_with_CSC_data_out_of_sync++;
301  /*
302  std::cout << "FED" << id << " L1A:" << DCC_L1A << ", ";
303  std::cout << "DDU" << (dduData[ddu].header().source_id() & 0xFF )
304  << " L1A:" << dduData[ddu].header().lvl1num() << " size:" << (dduData[ddu].sizeInWords()*2);
305  std::cout << " - L1A mismatch";
306  std::cout << std::endl;
307  */
308  }
309 
310  }
311  processDDU(dduData[ddu], binChecker);
312  }
313 
314  if (fDCC_DDU_L1A_mismatch && getEMUHisto(h::EMU_FED_DDU_L1A_MISMATCH, mo)) mo->Fill(id);
315  if (fDCC_DDU_L1A_mismatch_with_CSC_data
316  && getEMUHisto(h::EMU_FED_DDU_L1A_MISMATCH_WITH_CSC_DATA, mo)) mo->Fill(id);
317 
318  }
319 
320  }
321  else
322  {
323 
324  if (getEMUHisto(h::EMU_FED_FORMAT_FATAL, mo)) mo->Fill(id);
325 
326  }
327 
328  }
329 
330  }
331 
332  }
333 
334  if (fGlobal_DCC_DDU_L1A_mismatch && getEMUHisto(h::EMU_FED_DDU_L1A_MISMATCH_CNT, mo)) mo->Fill(nDDUs_out_of_sync);
335  if (fGlobal_DCC_DDU_L1A_mismatch && getEMUHisto(h::EMU_FED_DDU_L1A_MISMATCH_WITH_CSC_DATA_CNT, mo))
336  mo->Fill(nDDUs_with_CSC_data_out_of_sync);
337 
338  if (getEMUHisto(h::EMU_FED_STATS, mo))
339  {
340  mo->Fill(0);
341  if (fGlobal_DCC_DDU_L1A_mismatch) mo->Fill(1);
342  if (fGlobal_DCC_DDU_L1A_mismatch_with_CSC_data) mo->Fill(2);
343  }
344 
345  if (getEMUHisto(h::EMU_FED_EVENT_SIZE, mo)) mo->Fill(eventSize/1024.);
346  if (getEMUHisto(h::EMU_FED_TOTAL_CSC_NUMBER, mo)) mo->Fill(cntDMBs);
347  if (getEMUHisto(h::EMU_FED_TOTAL_CFEB_NUMBER, mo)) mo->Fill(cntCFEBs);
348  if (getEMUHisto(h::EMU_FED_TOTAL_ALCT_NUMBER, mo)) mo->Fill(cntALCTs);
349  if (getEMUHisto(h::EMU_FED_TOTAL_TMB_NUMBER, mo)) mo->Fill(cntTMBs);
350 
351 }
352 
353 #endif
354 
355 #undef ECHO_FUNCTION
356 
357 }
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.
OStream & output1(void)
void preProcessEvent()
Common Local and Global DQM function to be called before processing Event.
void modeDDU(bool enable)
virtual void Fill(float x)=0
Monitoring Object interface used to cover Root object and provide common interface to EventProcessor ...
ExaminerStatusType errors(void) const
void crcALCT(bool enable)
OStream & output2(void)
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:49
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
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
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
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:29
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)