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  ExaminerStatusType bSUM_ERROR, bSUM_WARNING; // Summary flags for errors and warnings
19  bool fERROR [29];//[nERRORS];
20  bool fWARNING[5]; //[nWARNINGS];
21  bool fSUM_ERROR [29];//[nERRORS];
22  bool fSUM_WARNING[5]; //[nWARNINGS];
23 
24  std::set<CSCIdType> fCHAMB_ERR[29]; // Set of chambers which contain particular error
25  std::set<CSCIdType> fCHAMB_WRN[5]; // Set of chambers which contain particular warning
26  std::map<CSCIdType,ExaminerStatusType> bCHAMB_ERR; // chamber <=> errors in bits
27  std::map<CSCIdType,ExaminerStatusType> bCHAMB_WRN; // chamber <=> errors in bits
28  std::map<CSCIdType,ExaminerStatusType> bCHAMB_PAYLOAD; //
29  std::map<CSCIdType,ExaminerStatusType> bCHAMB_STATUS; //
30  std::map<DDUIdType,ExaminerStatusType> bDDU_ERR; // ddu <-> errors in bits
31  std::map<DDUIdType,ExaminerStatusType> bDDU_WRN; // ddu <-> errors in bits
32 
33  class OStream : public std::ostream {
34  private:
35  class buffer : public std::streambuf{};
37  std::streambuf *stream;
38  std::streambuf *null;
40 
41  public:
42  void show(void){ rdbuf(stream); }
43  void hide(void){ rdbuf(null); }
44  void sign(std::string nm) { name=nm; }
45  void sign(const char *nm){ name=nm; }
46 
47  void redirect(std::ostream &str){
48  stream = str.rdbuf(); tie(&str);
49  if( rdbuf() != null ) rdbuf(stream);
50  }
51 
52  template<class T> std::ostream& operator<<(const T& val){
53  return (*(std::ostream*)this)<<name<<val;
54  }
55 
56  OStream(void):std::ostream(std::cout.rdbuf()),buff(),stream(std::cout.rdbuf()),null(&buff),name(""){}
57  OStream(std::ostream &str):std::ostream(str.rdbuf()),buff(),stream(str.rdbuf()),null(&buff),name(""){}
58  };
59 
61 
62  CSCIdType currentChamber; // ( (CrateNumber<<4) + DMBslot ) specifies chamber
63 
64  const uint16_t *buf_2, *buf_1, *buf0, *buf1, *buf2;
65  uint16_t tmpbuf[16];
66 
77 
78  bool uniqueALCT, uniqueTMB; // Do not merge two DMBs if Trailer of the first and Header of the second are lost
79 
80  bool DAV_ALCT; // ...
81  bool DAV_TMB; // Check if DAV bits lie
82  int DAV_CFEB; // ...
83  int DAV_DMB; // ...
84  int DMB_Active, nDMBs; // ...
85 
86 public:
87  uint32_t cntDDU_Headers;
88  uint32_t cntDDU_Trailers;
89  std::map<CSCIdType,uint32_t> cntCHAMB_Headers;
90  std::map<CSCIdType,uint32_t> cntCHAMB_Trailers;
91 
92 private:
93  void clear();
94  void zeroCounts();
95  void sync_stats();
97  void checkDAVs();
99 
100  inline int scanbuf(const uint16_t* &buf, int32_t length, uint16_t sig, uint16_t mask=0xFFFF);
101 
103  uint32_t DDU_WordCount;
106 
109  uint32_t ALCT_WordCount;
111  uint32_t ALCT_ZSE;
112  uint32_t nWG_round_up;
113 
115  uint32_t TMB_WordCount;
117  uint32_t TMB_Tbins;
118  uint32_t TMB_WordsRPC;
120 
124 
126  uint32_t ALCT_CRC;
128  uint32_t TMB_CRC;
130  uint32_t CFEB_CRC;
131 
135 
136  //int headerDAV_Active; // Obsolete since 16.09.05
137 
138  // data blocks:
139  std::map<DDUIdType,const uint16_t*> dduBuffers; // < DDUsourceID, pointer >
140  std::map<DDUIdType,std::map<CSCIdType,const uint16_t*> > dmbBuffers; // < DDUsourceID, < DMBid, pointer > >
141  std::map<DDUIdType,uint32_t> dduOffsets; // < DDUsourceID, pointer_offset >
142  std::map<DDUIdType,std::map<CSCIdType,uint32_t> > dmbOffsets; // < DDUsourceID, < DMBid, pointer_offset > >
143  std::map<DDUIdType,uint32_t> dduSize; // < DDUsourceID, block_size >
144  std::map<DDUIdType,std::map<CSCIdType,uint32_t> > dmbSize; // < DDUsourceID, < DMBid, block_size > >
145  const uint16_t *buffer_start;
146 
147 public:
148  OStream& output1(void){ return cout; }
149  OStream& output2(void){ return cerr; }
150 
151  int32_t check(const uint16_t* &buffer, int32_t length);
152 
155 
156  ExaminerStatusType errors (void) const { return bSUM_ERROR; }
157  ExaminerStatusType warnings(void) const { return bSUM_WARNING; }
158 
159  const char* errName(int num) const { if(num>=0&&num<nERRORS) return sERROR[num]; else return ""; }
160  const char* wrnName(int num) const { if(num>=0&&num<nWARNINGS) return sWARNING[num]; else return ""; }
161 
162  const char* errorName (int num) const { if(num>=0&&num<nERRORS) return sERROR_[num]; else return ""; }
163  const char* warningName(int num) const { if(num>=0&&num<nWARNINGS) return sWARNING_[num]; else return ""; }
164 
165  const char* payloadName(int num) const { if(num>=0&&num<nPAYLOADS) return sDMBExpectedPayload[num]; else return ""; }
166  const char* statusName (int num) const { if(num>=0&&num<nSTATUSES) return sDMBEventStaus [num]; else return ""; }
167 
168  bool error (int num) const { if(num>=0&&num<nERRORS) return fSUM_ERROR [num]; else return 0; }
169  bool warning(int num) const { if(num>=0&&num<nWARNINGS) return fSUM_WARNING[num]; else return 0; }
170 
171  std::set<CSCIdType> chambersWithError (int num) const { if(num>=0&&num<nERRORS) return fCHAMB_ERR[num]; else return std::set<int>(); }
172  std::set<CSCIdType> chambersWithWarning(int num) const { if(num>=0&&num<nWARNINGS) return fCHAMB_WRN[num]; else return std::set<int>(); }
173 
175  std::map<CSCIdType,ExaminerStatusType>::const_iterator item = bCHAMB_PAYLOAD.find(chamber);
176  if( item != bCHAMB_PAYLOAD.end() ) return item->second; else return 0;
177  }
178 
180  std::map<CSCIdType,ExaminerStatusType>::const_iterator item = bCHAMB_STATUS.find(chamber);
181  if( item != bCHAMB_STATUS.end() ) return item->second; else return 0;
182  }
183 
185  std::map<CSCIdType,ExaminerStatusType>::const_iterator item = bCHAMB_ERR.find(chamber);
187 
188  // for(item =bCHAMB_ERR.begin() ; item !=bCHAMB_ERR.end() ; item++)
189  //std::cout << " Ex-errors: " << std::hex << (*item).second << std::dec << std::endl;
190 
191  item = bCHAMB_ERR.find(chamber);
192  if( item != bCHAMB_ERR.end() ) return item->second; else return 0;
193  }
194 
196  std::map<CSCIdType,ExaminerStatusType>::const_iterator item = bCHAMB_WRN.find(chamber);
197  if( item != bCHAMB_WRN.end() ) return item->second; else return 0;
198  }
199 
201  std::map<DDUIdType,ExaminerStatusType>::const_iterator item = bDDU_ERR.find(dduSourceID);
202  if( item != bDDU_ERR.end() ) return item->second; else return 0;
203  }
205  std::map<DDUIdType,ExaminerStatusType>::const_iterator item = bDDU_WRN.find(dduSourceID);
206  if( item != bDDU_WRN.end() ) return item->second; else return 0;
207  }
208  std::vector<DDUIdType> listOfDDUs(void) const {
209  std::vector<DDUIdType> DDUs;
210  std::map<DDUIdType,ExaminerStatusType>::const_iterator item = bDDU_ERR.begin();
211  while( item != bDDU_ERR.end() ){ DDUs.push_back(item->first); item++; }
212  return DDUs;
213  }
214 
215  std::map<DDUIdType,ExaminerStatusType> errorsDetailedDDU (void) const { return bDDU_ERR; }
216 
217  std::map<CSCIdType,ExaminerStatusType> errorsDetailed (void) const { return bCHAMB_ERR; }
218  std::map<CSCIdType,ExaminerStatusType> warningsDetailed(void) const { return bCHAMB_WRN; }
219  std::map<CSCIdType,ExaminerStatusType> payloadDetailed (void) const { return bCHAMB_PAYLOAD; }
220  std::map<CSCIdType,ExaminerStatusType> statusDetailed (void) const { return bCHAMB_STATUS; }
221 
222 
223 
224  void crcALCT(bool enable);
225  void crcTMB (bool enable);
226  void crcCFEB(bool enable);
227 
228  void modeDDU(bool enable);
229 
230  DDUIdType dduSourceID(void){ return sourceID; }
231 
232  std::map<DDUIdType,const uint16_t*> DDU_block(void) const { return dduBuffers; }
233  std::map<DDUIdType,std::map<CSCIdType,const uint16_t*> > DMB_block(void) const { return dmbBuffers; }
234 
235  std::map<DDUIdType,uint32_t> DDU_ptrOffsets(void) const { return dduOffsets; }
236  std::map<DDUIdType,std::map<CSCIdType,uint32_t> > DMB_ptrOffsets(void) const { return dmbOffsets; }
237 
238  std::map<DDUIdType,uint32_t> DDU_size(void) const { return dduSize; }
239  std::map<DDUIdType,std::map<CSCIdType,uint32_t> > DMB_size(void) const { return dmbSize; }
240 
241  CSCDCCExaminer(ExaminerMaskType mask=0x1);
243 };
244 
245 #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
ExaminerStatusType bSUM_WARNING
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]
bool fSUM_ERROR[29]
uint32_t DDU_WordMismatch_Occurrences
std::map< DDUIdType, ExaminerStatusType > bDDU_ERR
uint32_t CFEB_SampleCount
void crcTMB(bool enable)
ExaminerStatusType bSUM_ERROR
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]
bool fSUM_WARNING[5]
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
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