test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CSCDCCFormatStatusDigi.h
Go to the documentation of this file.
1 #ifndef CSCDCCFormatStatusDigi_CSCDCCFormatStatusDigi_h
2 #define CSCDCCFormatStatusDigi_CSCDCCFormatStatusDigi_h
3 
4 
5 /*
6  * =====================================================================================
7  *
8  * Filename: CSCDCCFormatStatusDigi.h
9  *
10  * Description: CSC DCC Format error, status and payload flags for a single DCC
11  *
12  * Version: 1.0
13  * Created: 02/12/2009 03:22:34 PM
14  * Revision: none
15  * Compiler: gcc
16  *
17  * Author: Valdas Rapsevicius (VR), valdas.rapsevicius@cern.ch,
18  * Victor Barashko (VB), victor.barashko@cern.ch
19  * Company: CERN, CH
20  *
21  * =====================================================================================
22  */
23 
24 
26 #include <set>
27 #include <map>
28 #include <algorithm>
29 #include <iosfwd>
30 
31 
33 typedef int32_t DCCIdType;
34 
36 typedef int16_t DDUIdType;
37 
39 typedef int32_t CSCIdType;
40 
42 typedef uint32_t ExaminerMaskType;
43 typedef uint32_t ExaminerStatusType;
44 
67  C_WORDS = 20,
76 };
77 
85  ALCT_DAV = 5,
86  TMB_DAV = 6,
87  CFEB1_DAV = 7,
88  CFEB2_DAV = 8,
89  CFEB3_DAV = 9,
90  CFEB4_DAV = 10,
91  CFEB5_DAV = 11
92 };
93 
119 };
120 
128 template <class TKey, class TVal>
129 bool nextInMap(uint32_t& it, TKey& key, const std::map<TKey, TVal>& m) {
130  uint32_t c = 0;
131  typename std::map<TKey, TVal>::const_iterator itr = m.begin();
132  while (itr != m.end()) {
133  if (c == it) {
134  it++;
135  key = itr->first;
136  return true;
137  }
138  itr++;
139  c++;
140  }
141  return false;
142 }
143 
149 template <class TKey, class TVal>
150 std::set<TKey> getKeysList(const std::map<TKey, TVal>& m)
151 {
152  std::set<TKey> keys;
153  typename std::map<TKey, TVal>::const_iterator itr;
154  for (itr = m.begin(); itr != m.end(); ++itr) {
155  keys.insert(itr->first);
156  }
157  return keys;
158 }
159 
165 
166  private:
167 
175 
178 
181 
184 
185  std::map<DDUIdType, ExaminerStatusType> mDDU_ERRORS;
186  std::map<CSCIdType, ExaminerStatusType> mCSC_ERRORS;
187  std::map<CSCIdType, ExaminerStatusType> mCSC_PAYLOADS;
188  std::map<CSCIdType, ExaminerStatusType> mCSC_STATUS;
189 
190  protected:
191 
193  CSCIdType makeCSCId(const uint16_t crateId, const uint16_t dmbId) const
194  { return ( (CSCIdType(crateId&0xFF)<<4) | (dmbId&0xF) ); }
195 
197  void init() {
199  fCSC_MASK = 0;
200  fDCC_MASK = 0;
201  mDDU_ERRORS.clear();
202  mCSC_ERRORS.clear();
203  mCSC_PAYLOADS.clear();
204  mCSC_STATUS.clear();
205  }
206 
207  public:
208 
220  const ExaminerMaskType fDCC_MASK_,
221  const ExaminerMaskType fCSC_MASK_,
222  const ExaminerStatusType fDDU_SUMMARY_ERRORS_,
223  const std::map<DDUIdType, ExaminerStatusType>& mDDU_ERRORS_,
224  const std::map<CSCIdType, ExaminerStatusType>& mCSC_ERRORS_,
225  const std::map<CSCIdType, ExaminerStatusType>& mCSC_PAYLOADS_,
226  const std::map<CSCIdType, ExaminerStatusType>& mCSC_STATUS_): DCCId(DCCId_)
227  {
228  init();
229  setDCCExaminerInfo(fDCC_MASK_, fCSC_MASK_, fDDU_SUMMARY_ERRORS_, mDDU_ERRORS_, mCSC_ERRORS_, mCSC_PAYLOADS_, mCSC_STATUS_);
230  }
231 
232 
233  CSCDCCFormatStatusDigi(const DCCIdType DCCId_): DCCId(DCCId_) {init();}
234 
235 
238 
239 
241  void setDCCExaminerInfo(const ExaminerMaskType fDCC_MASK_,
242  const ExaminerMaskType fCSC_MASK_,
243  const ExaminerStatusType fDDU_SUMMARY_ERRORS_,
244  const std::map<DDUIdType, ExaminerStatusType>& mDDU_ERRORS_,
245  const std::map<CSCIdType, ExaminerStatusType>& mCSC_ERRORS_,
246  const std::map<CSCIdType, ExaminerStatusType>& mCSC_PAYLOADS_,
247  const std::map<CSCIdType, ExaminerStatusType>& mCSC_STATUS_);
248 
249 #ifdef DEBUG
250 
253  void setDCCId(DCCIdType id) { DCCId = id; }
254  void setDCCMask(ExaminerMaskType mask) { fDCC_MASK = mask; }
255  void setCSCMask(ExaminerMaskType mask) { fCSC_MASK = mask; }
256  void setDDUSummaryErrors(ExaminerStatusType status) { fDDU_SUMMARY_ERRORS = status; }
257  void setDDUErrors(DDUIdType DDUId, ExaminerStatusType status ) {
258  std::map<DDUIdType,ExaminerStatusType>::const_iterator item = mDDU_ERRORS.find(DDUId);
259  if( item != mDDU_ERRORS.end() ) mDDU_ERRORS[DDUId] = status; else mDDU_ERRORS.insert(std::make_pair(DDUId, status));
260  }
261  void setCSCErrors(CSCIdType CSCId, ExaminerStatusType status ) {
262  std::map<CSCIdType,ExaminerStatusType>::const_iterator item = mCSC_ERRORS.find(CSCId);
263  if( item != mCSC_ERRORS.end() ) mCSC_ERRORS[CSCId] = status; else mCSC_ERRORS.insert(std::make_pair(CSCId, status));
264  }
265  void setCSCPayload(CSCIdType CSCId, ExaminerStatusType status ) {
266  std::map<CSCIdType,ExaminerStatusType>::const_iterator item = mCSC_PAYLOADS.find(CSCId);
267  if( item != mCSC_PAYLOADS.end() ) mCSC_PAYLOADS[CSCId] = status; else mCSC_PAYLOADS.insert(std::make_pair(CSCId, status));
268  }
269  void setCSCStatus(CSCIdType CSCId, ExaminerStatusType status ) {
270  std::map<CSCIdType,ExaminerStatusType>::const_iterator item = mCSC_STATUS.find(CSCId);
271  if( item != mCSC_STATUS.end() ) mCSC_STATUS[CSCId] = status; else mCSC_STATUS.insert(std::make_pair(CSCId, status));
272  }
273 
274 #endif
275 
281  std::set<DDUIdType> getListOfDDUs() const {
282  return getKeysList(mDDU_ERRORS);
283  }
284 
285  std::set<CSCIdType> getListOfCSCs() const {
286  return getKeysList(mCSC_PAYLOADS);
287  }
288 
289  std::set<CSCIdType> getListOfCSCsWithErrors() const {
290  return getKeysList(mCSC_ERRORS);
291  }
292 
306  bool nextCSCWithError(uint32_t& iterator, CSCIdType& CSCId) const {
307  return nextInMap(iterator, CSCId, mCSC_ERRORS);
308  }
309 
317  bool nextCSCWithStatus(uint32_t& iterator, CSCIdType& CSCId) const {
318  return nextInMap(iterator, CSCId, mCSC_STATUS);
319  }
320 
328  bool nextCSCWithPayload(uint32_t& iterator, CSCIdType& CSCId) const {
329  return nextInMap(iterator, CSCId, mCSC_PAYLOADS);
330  }
331 
343 
345  std::map<DDUIdType,ExaminerStatusType>::const_iterator item = mDDU_ERRORS.find(DDUId);
346  if( item != mDDU_ERRORS.end() ) return item->second; else return 0;
347  }
348 
349 
351  std::map<CSCIdType,ExaminerStatusType>::const_iterator item = mCSC_ERRORS.find(CSCId);
352  if( item != mCSC_ERRORS.end() ) return item->second; else return 0;
353  }
354 
355  ExaminerStatusType getCSCErrors(const uint16_t crateId, const uint16_t dmbId) const
356  { return getCSCErrors( makeCSCId(crateId, dmbId) ); }
357 
358 
360  std::map<CSCIdType,ExaminerStatusType>::const_iterator item = mCSC_PAYLOADS.find(CSCId);
361  if( item != mCSC_PAYLOADS.end() ) return item->second; else return 0;
362  }
363 
364  ExaminerStatusType getCSCPayload(const uint16_t crateId, const uint16_t dmbId) const
365  { return getCSCPayload( makeCSCId(crateId, dmbId) ); }
366 
367 
369  std::map<CSCIdType,ExaminerStatusType>::const_iterator item = mCSC_STATUS.find(CSCId);
370  if( item != mCSC_STATUS.end() ) return item->second; else return 0;
371  }
372 
373  ExaminerStatusType getCSCStatus(const uint16_t crateId, const uint16_t dmbId) const
374  { return getCSCStatus( makeCSCId(crateId, dmbId) ); }
375 
376 
377  /*
378  * Return FED/DCC Id
379  */
380  DCCIdType getDCCId() const { return DCCId; }
381 
386 
391 
396  bool getDDUSummaryFlag(const FormatErrorFlag flag) const
397  { return ( (fDDU_SUMMARY_ERRORS & ExaminerStatusType(0x1<<flag) ) != 0); }
398  bool getDDUErrorFlag(const DDUIdType DDUId, const FormatErrorFlag flag) const
399  { return ( (getDDUErrors(DDUId) & ExaminerStatusType(0x1<<flag) ) != 0); }
400 
401  bool getCSCErrorFlag(const CSCIdType CSCId, const FormatErrorFlag flag) const
402  { return ( (getCSCErrors(CSCId) & ExaminerStatusType(0x1<<flag) ) != 0); }
403 
404  bool getCSCErrorFlag(const uint16_t crateId, const uint16_t dmbId, const FormatErrorFlag flag) const
405  { return ( (getCSCErrors(crateId, dmbId) & ExaminerStatusType(0x1<<flag) ) != 0); }
406 
407  bool getCSCPayloadFlag(const CSCIdType CSCId, const CSCPayloadFlag flag) const
408  { return ( (getCSCPayload(CSCId) & ExaminerStatusType(0x1<<flag) ) != 0); }
409 
410  bool getCSCPayloadFlag(const uint16_t crateId, const uint16_t dmbId, const CSCPayloadFlag flag) const
411  { return ( (getCSCPayload(crateId,dmbId) & ExaminerStatusType(0x1<<flag) ) != 0); }
412 
413  bool getCSCStatusFlag(const CSCIdType CSCId, const CSCStatusFlag flag) const
414  { return ( (getCSCStatus(CSCId) & ExaminerStatusType(0x1<<flag) ) != 0); }
415 
416  bool getCSCStatusFlag(const uint16_t crateId, const uint16_t dmbId, const CSCStatusFlag flag) const
417  { return ( (getCSCStatus(crateId, dmbId) & ExaminerStatusType(0x1<<flag) ) != 0); }
418 
419  void print() const;
420 
421 
422 };
423 
424 
425 std::ostream & operator<<(std::ostream & o, const CSCDCCFormatStatusDigi& digi);
426 
427 #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
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
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:188
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
string key
FastSim: produces sample of signal events, overlayed with premixed minbias events.
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
tuple status
Definition: mps_update.py:57