CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CSCDCCExaminer.h
Go to the documentation of this file.
1 #ifndef CSCDCCExaminer_h
2 #define CSCDCCExaminer_h
3 #include <set>
4 #include <map>
5 #include <vector>
6 #include <string>
7 #include <iostream>
8 
10 
12 public:
13  const uint16_t nERRORS, nWARNINGS, nPAYLOADS, nSTATUSES;
14 
15 private:
18  bool fERROR [29];//[nERRORS];
19  bool fWARNING[5]; //[nWARNINGS];
20 
21  std::set<CSCIdType> fCHAMB_ERR[29]; // Set of chambers which contain particular error
22  std::set<CSCIdType> fCHAMB_WRN[5]; // Set of chambers which contain particular warning
23  std::map<CSCIdType,ExaminerStatusType> bCHAMB_ERR; // chamber <=> errors in bits
24  std::map<CSCIdType,ExaminerStatusType> bCHAMB_WRN; // chamber <=> errors in bits
25  std::map<CSCIdType,ExaminerStatusType> bCHAMB_PAYLOAD; //
26  std::map<CSCIdType,ExaminerStatusType> bCHAMB_STATUS; //
27  std::map<DDUIdType,ExaminerStatusType> bDDU_ERR; // ddu <-> errors in bits
28  std::map<DDUIdType,ExaminerStatusType> bDDU_WRN; // ddu <-> errors in bits
29 
30  class OStream : public std::ostream {
31  private:
32  class buffer : public std::streambuf{};
34  std::streambuf *stream;
35  std::streambuf *null;
36  std::string name;
37 
38  public:
39  void show(void){ rdbuf(stream); }
40  void hide(void){ rdbuf(null); }
41  void sign(std::string nm) { name=nm; }
42  void sign(const char *nm){ name=nm; }
43 
44  void redirect(std::ostream &str){
45  stream = str.rdbuf(); tie(&str);
46  if( rdbuf() != null ) rdbuf(stream);
47  }
48 
49  template<class T> std::ostream& operator<<(const T& val){
50  return (*(std::ostream*)this)<<name<<val;
51  }
52 
53  OStream(void):std::ostream(std::cout.rdbuf()),buff(),stream(std::cout.rdbuf()),null(&buff),name(""){}
54  OStream(std::ostream &str):std::ostream(str.rdbuf()),buff(),stream(str.rdbuf()),null(&buff),name(""){}
55  };
56 
58 
59  CSCIdType currentChamber; // ( (CrateNumber<<4) + DMBslot ) specifies chamber
60 
61  const uint16_t *buf_2, *buf_1, *buf0, *buf1, *buf2;
62  uint16_t tmpbuf[16];
63 
74 
75  bool uniqueALCT, uniqueTMB; // Do not merge two DMBs if Trailer of the first and Header of the second are lost
76 
77  bool DAV_ALCT; // ...
78  bool DAV_TMB; // Check if DAV bits lie
79  int DAV_CFEB; // ...
80  int DAV_DMB; // ...
81  int DMB_Active, nDMBs; // ...
82 
83 public:
84  uint32_t cntDDU_Headers;
85  uint32_t cntDDU_Trailers;
86  std::map<CSCIdType,uint32_t> cntCHAMB_Headers;
87  std::map<CSCIdType,uint32_t> cntCHAMB_Trailers;
88 
89 private:
90  void clear();
91  void zeroCounts();
93  void checkDAVs();
95 
96  inline int scanbuf(const uint16_t* &buf, int32_t length, uint16_t sig, uint16_t mask=0xFFFF);
97 
99  uint32_t DDU_WordCount;
102 
105  uint32_t ALCT_WordCount;
107  uint32_t ALCT_ZSE;
108  uint32_t nWG_round_up;
109 
111  uint32_t TMB_WordCount;
113  uint32_t TMB_Tbins;
114  uint32_t TMB_WordsRPC;
116 
120 
122  uint32_t ALCT_CRC;
124  uint32_t TMB_CRC;
126  uint32_t CFEB_CRC;
127 
131 
132  //int headerDAV_Active; // Obsolete since 16.09.05
133 
134  // data blocks:
135  std::map<DDUIdType,const uint16_t*> dduBuffers; // < DDUsourceID, pointer >
136  std::map<DDUIdType,std::map<CSCIdType,const uint16_t*> > dmbBuffers; // < DDUsourceID, < DMBid, pointer > >
137  std::map<DDUIdType,uint32_t> dduOffsets; // < DDUsourceID, pointer_offset >
138  std::map<DDUIdType,std::map<CSCIdType,uint32_t> > dmbOffsets; // < DDUsourceID, < DMBid, pointer_offset > >
139  std::map<DDUIdType,uint32_t> dduSize; // < DDUsourceID, block_size >
140  std::map<DDUIdType,std::map<CSCIdType,uint32_t> > dmbSize; // < DDUsourceID, < DMBid, block_size > >
141  const uint16_t *buffer_start;
142 
143 public:
144  OStream& output1(void){ return cout; }
145  OStream& output2(void){ return cerr; }
146 
147  int32_t check(const uint16_t* &buffer, int32_t length);
148 
151 
152  ExaminerStatusType errors (void) const { return bERROR; }
153  ExaminerStatusType warnings(void) const { return bWARNING; }
154 
155  const char* errName(int num) const { if(num>=0&&num<nERRORS) return sERROR[num]; else return ""; }
156  const char* wrnName(int num) const { if(num>=0&&num<nWARNINGS) return sWARNING[num]; else return ""; }
157 
158  const char* errorName (int num) const { if(num>=0&&num<nERRORS) return sERROR_[num]; else return ""; }
159  const char* warningName(int num) const { if(num>=0&&num<nWARNINGS) return sWARNING_[num]; else return ""; }
160 
161  const char* payloadName(int num) const { if(num>=0&&num<nPAYLOADS) return sDMBExpectedPayload[num]; else return ""; }
162  const char* statusName (int num) const { if(num>=0&&num<nSTATUSES) return sDMBEventStaus [num]; else return ""; }
163 
164  bool error (int num) const { if(num>=0&&num<nERRORS) return fERROR [num]; else return 0; }
165  bool warning(int num) const { if(num>=0&&num<nWARNINGS) return fWARNING[num]; else return 0; }
166 
167  std::set<CSCIdType> chambersWithError (int num) const { if(num>=0&&num<nERRORS) return fCHAMB_ERR[num]; else return std::set<int>(); }
168  std::set<CSCIdType> chambersWithWarning(int num) const { if(num>=0&&num<nWARNINGS) return fCHAMB_WRN[num]; else return std::set<int>(); }
169 
171  std::map<CSCIdType,ExaminerStatusType>::const_iterator item = bCHAMB_PAYLOAD.find(chamber);
172  if( item != bCHAMB_PAYLOAD.end() ) return item->second; else return 0;
173  }
174 
176  std::map<CSCIdType,ExaminerStatusType>::const_iterator item = bCHAMB_STATUS.find(chamber);
177  if( item != bCHAMB_STATUS.end() ) return item->second; else return 0;
178  }
179 
181  std::map<CSCIdType,ExaminerStatusType>::const_iterator item = bCHAMB_ERR.find(chamber);
183 
184  // for(item =bCHAMB_ERR.begin() ; item !=bCHAMB_ERR.end() ; item++)
185  //std::cout << " Ex-errors: " << std::hex << (*item).second << std::dec << std::endl;
186 
187  item = bCHAMB_ERR.find(chamber);
188  if( item != bCHAMB_ERR.end() ) return item->second; else return 0;
189  }
190 
192  std::map<CSCIdType,ExaminerStatusType>::const_iterator item = bCHAMB_WRN.find(chamber);
193  if( item != bCHAMB_WRN.end() ) return item->second; else return 0;
194  }
195 
197  std::map<DDUIdType,ExaminerStatusType>::const_iterator item = bDDU_ERR.find(dduSourceID);
198  if( item != bDDU_ERR.end() ) return item->second; else return 0;
199  }
201  std::map<DDUIdType,ExaminerStatusType>::const_iterator item = bDDU_WRN.find(dduSourceID);
202  if( item != bDDU_WRN.end() ) return item->second; else return 0;
203  }
204  std::vector<DDUIdType> listOfDDUs(void) const {
205  std::vector<DDUIdType> DDUs;
206  std::map<DDUIdType,ExaminerStatusType>::const_iterator item = bDDU_ERR.begin();
207  while( item != bDDU_ERR.end() ){ DDUs.push_back(item->first); item++; }
208  return DDUs;
209  }
210 
211  std::map<DDUIdType,ExaminerStatusType> errorsDetailedDDU (void) const { return bDDU_ERR; }
212 
213  std::map<CSCIdType,ExaminerStatusType> errorsDetailed (void) const { return bCHAMB_ERR; }
214  std::map<CSCIdType,ExaminerStatusType> warningsDetailed(void) const { return bCHAMB_WRN; }
215  std::map<CSCIdType,ExaminerStatusType> payloadDetailed (void) const { return bCHAMB_PAYLOAD; }
216  std::map<CSCIdType,ExaminerStatusType> statusDetailed (void) const { return bCHAMB_STATUS; }
217 
218 
219 
220  void crcALCT(bool enable);
221  void crcTMB (bool enable);
222  void crcCFEB(bool enable);
223 
224  void modeDDU(bool enable);
225 
226  DDUIdType dduSourceID(void){ return sourceID; }
227 
228  std::map<DDUIdType,const uint16_t*> DDU_block(void) const { return dduBuffers; }
229  std::map<DDUIdType,std::map<CSCIdType,const uint16_t*> > DMB_block(void) const { return dmbBuffers; }
230 
231  std::map<DDUIdType,uint32_t> DDU_ptrOffsets(void) const { return dduOffsets; }
232  std::map<DDUIdType,std::map<CSCIdType,uint32_t> > DMB_ptrOffsets(void) const { return dmbOffsets; }
233 
234  std::map<DDUIdType,uint32_t> DDU_size(void) const { return dduSize; }
235  std::map<DDUIdType,std::map<CSCIdType,uint32_t> > DMB_size(void) const { return dmbSize; }
236 
237  CSCDCCExaminer(ExaminerMaskType mask=0x1);
239 };
240 
241 #endif
uint32_t DDU_WordsSinceLastHeader
uint32_t TMB_WordCount
const uint16_t nSTATUSES
const uint16_t * buf0
const uint16_t * buffer_start
void crcCFEB(bool enable)
const char * errorName(int num) const
uint32_t CFEB_SampleWordCount
bool warning(int num) const
std::map< CSCIdType, ExaminerStatusType > bCHAMB_ERR
std::set< CSCIdType > fCHAMB_ERR[29]
std::streambuf * stream
std::ostream & operator<<(const T &val)
OStream & output1(void)
const uint16_t * buf2
std::vector< DDUIdType > listOfDDUs(void) const
int scanbuf(const uint16_t *&buf, int32_t length, uint16_t sig, uint16_t mask=0xFFFF)
int32_t CSCIdType
void modeDDU(bool enable)
uint32_t ALCT_WordsSinceLastHeader
const uint16_t * buf1
uint32_t ALCT_WordCount
ExaminerStatusType errorsForChamber(CSCIdType chamber) const
const uint16_t nERRORS
ExaminerStatusType statusForChamber(CSCIdType chamber) const
std::map< DDUIdType, uint32_t > dduSize
uint32_t DDU_WordsSinceLastTrailer
DDUIdType dduSourceID(void)
uint32_t cntDDU_Headers
void redirect(std::ostream &str)
ExaminerStatusType errors(void) const
void crcALCT(bool enable)
OStream & output2(void)
const char * errName(int num) const
uint32_t ALCT_WordsExpected
std::map< CSCIdType, uint32_t > cntCHAMB_Trailers
std::vector< const char * > sERROR
std::map< DDUIdType, std::map< CSCIdType, const uint16_t * > > DMB_block(void) const
std::set< CSCIdType > chambersWithError(int num) const
ExaminerStatusType warnings(void) const
uint32_t TMB_Firmware_Revision
CSCIdType currentChamber
std::map< CSCIdType, ExaminerStatusType > bCHAMB_PAYLOAD
std::map< CSCIdType, uint32_t > cntCHAMB_Headers
std::set< CSCIdType > chambersWithWarning(int num) const
uint32_t nWG_round_up
check zero suppression mode
std::map< DDUIdType, std::map< CSCIdType, uint32_t > > DMB_ptrOffsets(void) const
const uint16_t nWARNINGS
std::map< CSCIdType, ExaminerStatusType > errorsDetailed(void) const
std::map< DDUIdType, std::map< CSCIdType, uint32_t > > dmbOffsets
std::vector< const char * > sDMBExpectedPayload
std::vector< const char * > sWARNING_
ExaminerStatusType payloadForChamber(CSCIdType chamber) const
std::set< CSCIdType > fCHAMB_WRN[5]
uint32_t DDU_WordMismatch_Occurrences
std::map< DDUIdType, ExaminerStatusType > bDDU_ERR
uint32_t CFEB_SampleCount
void crcTMB(bool enable)
const char * statusName(int num) const
std::map< DDUIdType, std::map< CSCIdType, uint32_t > > DMB_size(void) const
uint32_t TMB_WordsRPC
uint32_t TMB_Tbins
std::map< DDUIdType, uint32_t > DDU_ptrOffsets(void) const
ExaminerStatusType errorsForDDU(DDUIdType dduSourceID) const
uint32_t TMB_WordsExpected
std::map< CSCIdType, ExaminerStatusType > statusDetailed(void) const
std::map< DDUIdType, uint32_t > DDU_size(void) const
const uint16_t * buf_2
const uint16_t * buf_1
std::map< DDUIdType, const uint16_t * > DDU_block(void) const
const uint16_t nPAYLOADS
uint32_t CFEB_BSampleCount
ExaminerMaskType getMask() const
std::map< CSCIdType, ExaminerStatusType > bCHAMB_WRN
uint32_t TMB_WordsSinceLastHeader
to decode if zero suppression enabled
std::map< CSCIdType, ExaminerStatusType > warningsDetailed(void) const
void sign(const char *nm)
ExaminerStatusType bERROR
CSCDCCExaminer(ExaminerMaskType mask=0x1)
uint16_t tmpbuf[16]
ExaminerStatusType warningsForDDU(DDUIdType dduSourceID) const
void checkTriggerHeadersAndTrailers()
const char * warningName(int num) const
uint32_t ExaminerStatusType
std::vector< const char * > sWARNING
const char * payloadName(int num) const
DDUIdType sourceID
long long int num
Definition: procUtils.cc:71
std::map< DDUIdType, std::map< CSCIdType, const uint16_t * > > dmbBuffers
ExaminerStatusType warningsForChamber(CSCIdType chamber) const
uint32_t ALCT_WordsSinceLastHeaderZeroSuppressed
void sign(std::string nm)
std::map< CSCIdType, ExaminerStatusType > bCHAMB_STATUS
int32_t check(const uint16_t *&buffer, int32_t length)
const char * wrnName(int num) const
int16_t DDUIdType
std::map< CSCIdType, ExaminerStatusType > payloadDetailed(void) const
uint32_t DDU_WordCount
ExaminerMaskType examinerMask
std::map< DDUIdType, const uint16_t * > dduBuffers
void checkDAVs()
checks DAV_ALCT, DAV_TMB, and DAV_CFEB
ExaminerStatusType bWARNING
std::map< DDUIdType, std::map< CSCIdType, uint32_t > > dmbSize
std::map< DDUIdType, ExaminerStatusType > errorsDetailedDDU(void) const
std::vector< const char * > sDMBEventStaus
std::map< DDUIdType, uint32_t > dduOffsets
bool error(int num) const
uint32_t ExaminerMaskType
long double T
OStream(std::ostream &str)
void setMask(ExaminerMaskType mask)
std::streambuf * null
std::vector< const char * > sERROR_
std::map< DDUIdType, ExaminerStatusType > bDDU_WRN
uint32_t cntDDU_Trailers