CMS 3D CMS Logo

CSCDCCFormatStatusDigi.h
Go to the documentation of this file.
1 #ifndef CSCDCCFormatStatusDigi_CSCDCCFormatStatusDigi_h
2 #define CSCDCCFormatStatusDigi_CSCDCCFormatStatusDigi_h
3 
4 /*
5  * =====================================================================================
6  *
7  * Filename: CSCDCCFormatStatusDigi.h
8  *
9  * Description: CSC DCC Format error, status and payload flags for a single DCC
10  *
11  * Version: 1.0
12  * Created: 02/12/2009 03:22:34 PM
13  * Revision: none
14  * Compiler: gcc
15  *
16  * Author: Valdas Rapsevicius (VR), valdas.rapsevicius@cern.ch,
17  * Victor Barashko (VB), victor.barashko@cern.ch
18  * Company: CERN, CH
19  *
20  * =====================================================================================
21  */
22 
24 #include <set>
25 #include <map>
26 #include <algorithm>
27 #include <iosfwd>
28 
30 typedef int32_t DCCIdType;
31 
33 typedef int16_t DDUIdType;
34 
36 typedef int32_t CSCIdType;
37 
39 typedef uint32_t ExaminerMaskType;
40 typedef uint32_t ExaminerStatusType;
41 
64  C_WORDS = 20,
73 };
74 
82  ALCT_DAV = 5,
83  TMB_DAV = 6,
84  CFEB1_DAV = 7,
85  CFEB2_DAV = 8,
86  CFEB3_DAV = 9,
87  CFEB4_DAV = 10,
88  CFEB5_DAV = 11
89 };
90 
116 };
117 
125 template <class TKey, class TVal>
126 bool nextInMap(uint32_t& it, TKey& key, const std::map<TKey, TVal>& m) {
127  uint32_t c = 0;
128  typename std::map<TKey, TVal>::const_iterator itr = m.begin();
129  while (itr != m.end()) {
130  if (c == it) {
131  it++;
132  key = itr->first;
133  return true;
134  }
135  itr++;
136  c++;
137  }
138  return false;
139 }
140 
146 template <class TKey, class TVal>
147 std::set<TKey> getKeysList(const std::map<TKey, TVal>& m) {
148  std::set<TKey> keys;
149  typename std::map<TKey, TVal>::const_iterator itr;
150  for (itr = m.begin(); itr != m.end(); ++itr) {
151  keys.insert(itr->first);
152  }
153  return keys;
154 }
155 
161 private:
168 
171 
174 
177 
178  std::map<DDUIdType, ExaminerStatusType> mDDU_ERRORS;
179  std::map<CSCIdType, ExaminerStatusType> mCSC_ERRORS;
180  std::map<CSCIdType, ExaminerStatusType> mCSC_PAYLOADS;
181  std::map<CSCIdType, ExaminerStatusType> mCSC_STATUS;
182 
183 protected:
185  CSCIdType makeCSCId(const uint16_t crateId, const uint16_t dmbId) const {
186  return ((CSCIdType(crateId & 0xFF) << 4) | (dmbId & 0xF));
187  }
188 
190  void init() {
191  fDDU_SUMMARY_ERRORS = 0;
192  fCSC_MASK = 0;
193  fDCC_MASK = 0;
194  mDDU_ERRORS.clear();
195  mCSC_ERRORS.clear();
196  mCSC_PAYLOADS.clear();
197  mCSC_STATUS.clear();
198  }
199 
200 public:
212  const ExaminerMaskType fDCC_MASK_,
213  const ExaminerMaskType fCSC_MASK_,
214  const ExaminerStatusType fDDU_SUMMARY_ERRORS_,
215  const std::map<DDUIdType, ExaminerStatusType>& mDDU_ERRORS_,
216  const std::map<CSCIdType, ExaminerStatusType>& mCSC_ERRORS_,
217  const std::map<CSCIdType, ExaminerStatusType>& mCSC_PAYLOADS_,
218  const std::map<CSCIdType, ExaminerStatusType>& mCSC_STATUS_)
219  : DCCId(DCCId_) {
220  init();
222  fDCC_MASK_, fCSC_MASK_, fDDU_SUMMARY_ERRORS_, mDDU_ERRORS_, mCSC_ERRORS_, mCSC_PAYLOADS_, mCSC_STATUS_);
223  }
224 
225  CSCDCCFormatStatusDigi(const DCCIdType DCCId_) : DCCId(DCCId_) { init(); }
226 
228  CSCDCCFormatStatusDigi() : DCCId(0) { init(); }
229 
231  void setDCCExaminerInfo(const ExaminerMaskType fDCC_MASK_,
232  const ExaminerMaskType fCSC_MASK_,
233  const ExaminerStatusType fDDU_SUMMARY_ERRORS_,
234  const std::map<DDUIdType, ExaminerStatusType>& mDDU_ERRORS_,
235  const std::map<CSCIdType, ExaminerStatusType>& mCSC_ERRORS_,
236  const std::map<CSCIdType, ExaminerStatusType>& mCSC_PAYLOADS_,
237  const std::map<CSCIdType, ExaminerStatusType>& mCSC_STATUS_);
238 
239 #ifdef DEBUG
240 
243  void setDCCId(DCCIdType id) { DCCId = id; }
244  void setDCCMask(ExaminerMaskType mask) { fDCC_MASK = mask; }
245  void setCSCMask(ExaminerMaskType mask) { fCSC_MASK = mask; }
246  void setDDUSummaryErrors(ExaminerStatusType status) { fDDU_SUMMARY_ERRORS = status; }
247  void setDDUErrors(DDUIdType DDUId, ExaminerStatusType status) {
248  std::map<DDUIdType, ExaminerStatusType>::const_iterator item = mDDU_ERRORS.find(DDUId);
249  if (item != mDDU_ERRORS.end())
250  mDDU_ERRORS[DDUId] = status;
251  else
252  mDDU_ERRORS.insert(std::make_pair(DDUId, status));
253  }
254  void setCSCErrors(CSCIdType CSCId, ExaminerStatusType status) {
255  std::map<CSCIdType, ExaminerStatusType>::const_iterator item = mCSC_ERRORS.find(CSCId);
256  if (item != mCSC_ERRORS.end())
257  mCSC_ERRORS[CSCId] = status;
258  else
259  mCSC_ERRORS.insert(std::make_pair(CSCId, status));
260  }
261  void setCSCPayload(CSCIdType CSCId, ExaminerStatusType status) {
262  std::map<CSCIdType, ExaminerStatusType>::const_iterator item = mCSC_PAYLOADS.find(CSCId);
263  if (item != mCSC_PAYLOADS.end())
264  mCSC_PAYLOADS[CSCId] = status;
265  else
266  mCSC_PAYLOADS.insert(std::make_pair(CSCId, status));
267  }
268  void setCSCStatus(CSCIdType CSCId, ExaminerStatusType status) {
269  std::map<CSCIdType, ExaminerStatusType>::const_iterator item = mCSC_STATUS.find(CSCId);
270  if (item != mCSC_STATUS.end())
271  mCSC_STATUS[CSCId] = status;
272  else
273  mCSC_STATUS.insert(std::make_pair(CSCId, status));
274  }
275 
276 #endif
277 
283  std::set<DDUIdType> getListOfDDUs() const { return getKeysList(mDDU_ERRORS); }
284 
285  std::set<CSCIdType> getListOfCSCs() const { return getKeysList(mCSC_PAYLOADS); }
286 
287  std::set<CSCIdType> getListOfCSCsWithErrors() const { return getKeysList(mCSC_ERRORS); }
288 
302  bool nextCSCWithError(uint32_t& iterator, CSCIdType& CSCId) const { return nextInMap(iterator, CSCId, mCSC_ERRORS); }
303 
311  bool nextCSCWithStatus(uint32_t& iterator, CSCIdType& CSCId) const { return nextInMap(iterator, CSCId, mCSC_STATUS); }
312 
320  bool nextCSCWithPayload(uint32_t& iterator, CSCIdType& CSCId) const {
321  return nextInMap(iterator, CSCId, mCSC_PAYLOADS);
322  }
323 
334 
336  std::map<DDUIdType, ExaminerStatusType>::const_iterator item = mDDU_ERRORS.find(DDUId);
337  if (item != mDDU_ERRORS.end())
338  return item->second;
339  else
340  return 0;
341  }
342 
344  std::map<CSCIdType, ExaminerStatusType>::const_iterator item = mCSC_ERRORS.find(CSCId);
345  if (item != mCSC_ERRORS.end())
346  return item->second;
347  else
348  return 0;
349  }
350 
351  ExaminerStatusType getCSCErrors(const uint16_t crateId, const uint16_t dmbId) const {
352  return getCSCErrors(makeCSCId(crateId, dmbId));
353  }
354 
356  std::map<CSCIdType, ExaminerStatusType>::const_iterator item = mCSC_PAYLOADS.find(CSCId);
357  if (item != mCSC_PAYLOADS.end())
358  return item->second;
359  else
360  return 0;
361  }
362 
363  ExaminerStatusType getCSCPayload(const uint16_t crateId, const uint16_t dmbId) const {
364  return getCSCPayload(makeCSCId(crateId, dmbId));
365  }
366 
368  std::map<CSCIdType, ExaminerStatusType>::const_iterator item = mCSC_STATUS.find(CSCId);
369  if (item != mCSC_STATUS.end())
370  return item->second;
371  else
372  return 0;
373  }
374 
375  ExaminerStatusType getCSCStatus(const uint16_t crateId, const uint16_t dmbId) const {
376  return getCSCStatus(makeCSCId(crateId, dmbId));
377  }
378 
379  /*
380  * Return FED/DCC Id
381  */
382  DCCIdType getDCCId() const { return DCCId; }
383 
388 
393 
399  return ((fDDU_SUMMARY_ERRORS & ExaminerStatusType(0x1 << flag)) != 0);
400  }
401  bool getDDUErrorFlag(const DDUIdType DDUId, const FormatErrorFlag flag) const {
402  return ((getDDUErrors(DDUId) & ExaminerStatusType(0x1 << flag)) != 0);
403  }
404 
405  bool getCSCErrorFlag(const CSCIdType CSCId, const FormatErrorFlag flag) const {
406  return ((getCSCErrors(CSCId) & ExaminerStatusType(0x1 << flag)) != 0);
407  }
408 
409  bool getCSCErrorFlag(const uint16_t crateId, const uint16_t dmbId, const FormatErrorFlag flag) const {
410  return ((getCSCErrors(crateId, dmbId) & ExaminerStatusType(0x1 << flag)) != 0);
411  }
412 
413  bool getCSCPayloadFlag(const CSCIdType CSCId, const CSCPayloadFlag flag) const {
414  return ((getCSCPayload(CSCId) & ExaminerStatusType(0x1 << flag)) != 0);
415  }
416 
417  bool getCSCPayloadFlag(const uint16_t crateId, const uint16_t dmbId, const CSCPayloadFlag flag) const {
418  return ((getCSCPayload(crateId, dmbId) & ExaminerStatusType(0x1 << flag)) != 0);
419  }
420 
421  bool getCSCStatusFlag(const CSCIdType CSCId, const CSCStatusFlag flag) const {
422  return ((getCSCStatus(CSCId) & ExaminerStatusType(0x1 << flag)) != 0);
423  }
424 
425  bool getCSCStatusFlag(const uint16_t crateId, const uint16_t dmbId, const CSCStatusFlag flag) const {
426  return ((getCSCStatus(crateId, dmbId) & ExaminerStatusType(0x1 << flag)) != 0);
427  }
428 
429  void print() const;
430 };
431 
432 std::ostream& operator<<(std::ostream& o, const CSCDCCFormatStatusDigi& digi);
433 
434 #endif
void print() const
Debug.
CSCDCCFormatStatusDigi()
Default constructor.
std::set< CSCIdType > getListOfCSCsWithErrors() const
int32_t CSCIdType
ExaminerMaskType getDCCMask() const
ExaminerStatusType getDDUSummaryErrors() const
std::set< DDUIdType > getListOfDDUs() const
ExaminerStatusType getCSCStatus(const CSCIdType CSCId) const
std::ostream & operator<<(std::ostream &o, const CSCDCCFormatStatusDigi &digi)
bool getCSCErrorFlag(const CSCIdType CSCId, const FormatErrorFlag flag) const
bool getDDUErrorFlag(const DDUIdType DDUId, const FormatErrorFlag flag) const
bool nextCSCWithStatus(uint32_t &iterator, CSCIdType &CSCId) const
CSC with status iteration procedure.
ExaminerStatusType getCSCErrors(const CSCIdType CSCId) const
bool getCSCPayloadFlag(const CSCIdType CSCId, const CSCPayloadFlag flag) 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...
int32_t DCCIdType
bool getDDUSummaryFlag(const FormatErrorFlag flag) const
ExaminerStatusType getCSCStatus(const uint16_t crateId, const uint16_t dmbId) const
std::map< CSCIdType, ExaminerStatusType > mCSC_ERRORS
ExaminerStatusType fDDU_SUMMARY_ERRORS
void setDCCExaminerInfo(const ExaminerMaskType fDCC_MASK_, const ExaminerMaskType fCSC_MASK_, const ExaminerStatusType fDDU_SUMMARY_ERRORS_, const std::map< DDUIdType, ExaminerStatusType > &mDDU_ERRORS_, const std::map< CSCIdType, ExaminerStatusType > &mCSC_ERRORS_, const std::map< CSCIdType, ExaminerStatusType > &mCSC_PAYLOADS_, const std::map< CSCIdType, ExaminerStatusType > &mCSC_STATUS_)
Fill internal data structures using Examiner object.
CSCDCCFormatStatusDigi(const DCCIdType DCCId_)
ExaminerStatusType getCSCPayload(const uint16_t crateId, const uint16_t dmbId) const
bool getCSCPayloadFlag(const uint16_t crateId, const uint16_t dmbId, const CSCPayloadFlag flag) const
bool getCSCErrorFlag(const uint16_t crateId, const uint16_t dmbId, const FormatErrorFlag flag) const
ExaminerStatusType getCSCErrors(const uint16_t crateId, const uint16_t dmbId) const
ExaminerStatusType getCSCPayload(const CSCIdType CSCId) const
uint32_t ExaminerStatusType
std::map< CSCIdType, ExaminerStatusType > mCSC_STATUS
bool getCSCStatusFlag(const CSCIdType CSCId, const CSCStatusFlag flag) const
int16_t DDUIdType
std::map< DDUIdType, ExaminerStatusType > mDDU_ERRORS
CSC Format Status Object.
std::map< CSCIdType, ExaminerStatusType > mCSC_PAYLOADS
CSCIdType makeCSCId(const uint16_t crateId, const uint16_t dmbId) const
Make CSCIdType from Crate and DMB IDs.
bool nextInMap(uint32_t &it, TKey &key, const std::map< TKey, TVal > &m)
Map iterator template.
std::set< TKey > getKeysList(const std::map< TKey, TVal > &m)
List of Map keys template.
CSCDCCFormatStatusDigi(const DCCIdType DCCId_, const ExaminerMaskType fDCC_MASK_, const ExaminerMaskType fCSC_MASK_, const ExaminerStatusType fDDU_SUMMARY_ERRORS_, const std::map< DDUIdType, ExaminerStatusType > &mDDU_ERRORS_, const std::map< CSCIdType, ExaminerStatusType > &mCSC_ERRORS_, const std::map< CSCIdType, ExaminerStatusType > &mCSC_PAYLOADS_, const std::map< CSCIdType, ExaminerStatusType > &mCSC_STATUS_)
Constructor.
bool nextCSCWithPayload(uint32_t &iterator, CSCIdType &CSCId) const
CSC with payload iteration procedure.
void init()
Init internal data stuctures.
bool getCSCStatusFlag(const uint16_t crateId, const uint16_t dmbId, const CSCStatusFlag flag) const
uint32_t ExaminerMaskType
std::set< CSCIdType > getListOfCSCs() const
ExaminerMaskType getCSCMask() const