test
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 #ifdef LOCAL_UNPACK
8 #include <iostream>
9 #else
10 #include <ostream>
11 #endif
12 
14 
16 public:
17  const uint16_t nERRORS, nWARNINGS, nPAYLOADS, nSTATUSES;
18 
19 private:
22  ExaminerStatusType bSUM_ERROR, bSUM_WARNING; // Summary flags for errors and warnings
23  bool fERROR [29];//[nERRORS];
24  bool fWARNING[5]; //[nWARNINGS];
25  bool fSUM_ERROR [29];//[nERRORS];
26  bool fSUM_WARNING[5]; //[nWARNINGS];
27 
28  std::set<CSCIdType> fCHAMB_ERR[29]; // Set of chambers which contain particular error
29  std::set<CSCIdType> fCHAMB_WRN[5]; // Set of chambers which contain particular warning
30  std::map<CSCIdType,ExaminerStatusType> bCHAMB_ERR; // chamber <=> errors in bits
31  std::map<CSCIdType,ExaminerStatusType> bCHAMB_WRN; // chamber <=> errors in bits
32  std::map<CSCIdType,ExaminerStatusType> bCHAMB_PAYLOAD; //
33  std::map<CSCIdType,ExaminerStatusType> bCHAMB_STATUS; //
34  std::map<DDUIdType,ExaminerStatusType> bDDU_ERR; // ddu <-> errors in bits
35  std::map<DDUIdType,ExaminerStatusType> bDDU_WRN; // ddu <-> errors in bits
36 
37 #ifdef LOCAL_UNPACK
38  class OStream : public std::ostream {
39  private:
40  class buffer : public std::streambuf{};
41  buffer buff;
42  std::streambuf *stream;
43  std::streambuf *null;
45 
46  public:
47  void show(void){ rdbuf(stream); }
48  void hide(void){ rdbuf(null); }
49  void sign(std::string nm) { name=nm; }
50  void sign(const char *nm){ name=nm; }
51 
52  void redirect(std::ostream &str){
53  stream = str.rdbuf(); tie(&str);
54  if( rdbuf() != null ) rdbuf(stream);
55  }
56 
57  template<class T> std::ostream& operator<<(const T& val){
58  return (*(std::ostream*)this)<<name<<val;
59  }
60 
61  OStream(void):std::ostream(std::cout.rdbuf()),buff(),stream(std::cout.rdbuf()),null(&buff),name(""){}
62  OStream(std::ostream &str):std::ostream(str.rdbuf()),buff(),stream(str.rdbuf()),null(&buff),name(""){}
63  };
64 
65  OStream COUT, CERR;
66 #endif
67 
68  CSCIdType currentChamber; // ( (CrateNumber<<4) + DMBslot ) specifies chamber
69 
70  const uint16_t *buf_2, *buf_1, *buf0, *buf1, *buf2;
71  uint16_t tmpbuf[16];
72 
84 
85  bool uniqueALCT, uniqueTMB; // Do not merge two DMBs if Trailer of the first and Header of the second are lost
86 
87  bool DAV_ALCT; // ...
88  bool DAV_TMB; // Check if DAV bits lie
89  int DAV_CFEB; // ...
90  int DAV_DMB; // ...
91  int DMB_Active, nDMBs; // ...
92 
93 public:
94  uint32_t cntDDU_Headers;
95  uint32_t cntDDU_Trailers;
96  std::map<CSCIdType,uint32_t> cntCHAMB_Headers;
97  std::map<CSCIdType,uint32_t> cntCHAMB_Trailers;
98 
99 private:
100  void clear();
101  void zeroCounts();
102  void sync_stats();
104  void checkDAVs();
106 
107  inline int scanbuf(const uint16_t* &buf, int32_t length, uint16_t sig, uint16_t mask=0xFFFF);
108 
110  uint32_t DDU_WordCount;
113 
116  uint32_t ALCT_WordCount;
118  uint32_t ALCT_ZSE;
119  uint32_t nWG_round_up;
120 
122  uint32_t TMB_WordCount;
124  uint32_t TMB_Tbins;
125  uint32_t TMB_WordsRPC;
128 
132 
134  uint32_t ALCT_CRC;
136  uint32_t TMB_CRC;
138  uint32_t CFEB_CRC;
139 
143 
144  //int headerDAV_Active; // Obsolete since 16.09.05
145 
146  // data blocks:
147  std::map<DDUIdType,const uint16_t*> dduBuffers; // < DDUsourceID, pointer >
148  std::map<DDUIdType,std::map<CSCIdType,const uint16_t*> > dmbBuffers; // < DDUsourceID, < DMBid, pointer > >
149  std::map<DDUIdType,uint32_t> dduOffsets; // < DDUsourceID, pointer_offset >
150  std::map<DDUIdType,std::map<CSCIdType,uint32_t> > dmbOffsets; // < DDUsourceID, < DMBid, pointer_offset > >
151  std::map<DDUIdType,uint32_t> dduSize; // < DDUsourceID, block_size >
152  std::map<DDUIdType,std::map<CSCIdType,uint32_t> > dmbSize; // < DDUsourceID, < DMBid, block_size > >
153  const uint16_t *buffer_start;
154 
155 public:
156 
157 #ifdef LOCAL_UNPACK
158  OStream& output1(void){ return COUT; }
159  OStream& output2(void){ return CERR; }
160 #endif
161 
162  int32_t check(const uint16_t* &buffer, int32_t length);
163 
166 
167  ExaminerStatusType errors (void) const { return bSUM_ERROR; }
168  ExaminerStatusType warnings(void) const { return bSUM_WARNING; }
169 
170  const char* errName(int num) const { if(num>=0&&num<nERRORS) return sERROR[num]; else return ""; }
171  const char* wrnName(int num) const { if(num>=0&&num<nWARNINGS) return sWARNING[num]; else return ""; }
172 
173  const char* errorName (int num) const { if(num>=0&&num<nERRORS) return sERROR_[num]; else return ""; }
174  const char* warningName(int num) const { if(num>=0&&num<nWARNINGS) return sWARNING_[num]; else return ""; }
175 
176  const char* payloadName(int num) const { if(num>=0&&num<nPAYLOADS) return sDMBExpectedPayload[num]; else return ""; }
177  const char* statusName (int num) const { if(num>=0&&num<nSTATUSES) return sDMBEventStaus [num]; else return ""; }
178 
179  bool error (int num) const { if(num>=0&&num<nERRORS) return fSUM_ERROR [num]; else return 0; }
180  bool warning(int num) const { if(num>=0&&num<nWARNINGS) return fSUM_WARNING[num]; else return 0; }
181 
182  std::set<CSCIdType> chambersWithError (int num) const { if(num>=0&&num<nERRORS) return fCHAMB_ERR[num]; else return std::set<int>(); }
183  std::set<CSCIdType> chambersWithWarning(int num) const { if(num>=0&&num<nWARNINGS) return fCHAMB_WRN[num]; else return std::set<int>(); }
184 
186  std::map<CSCIdType,ExaminerStatusType>::const_iterator item = bCHAMB_PAYLOAD.find(chamber);
187  if( item != bCHAMB_PAYLOAD.end() ) return item->second; else return 0;
188  }
189 
191  std::map<CSCIdType,ExaminerStatusType>::const_iterator item = bCHAMB_STATUS.find(chamber);
192  if( item != bCHAMB_STATUS.end() ) return item->second; else return 0;
193  }
194 
196  std::map<CSCIdType,ExaminerStatusType>::const_iterator item = bCHAMB_ERR.find(chamber);
198 
199  // for(item =bCHAMB_ERR.begin() ; item !=bCHAMB_ERR.end() ; item++)
200  //std::cout << " Ex-errors: " << std::hex << (*item).second << std::dec << std::endl;
201 
202  item = bCHAMB_ERR.find(chamber);
203  if( item != bCHAMB_ERR.end() ) return item->second; else return 0;
204  }
205 
207  std::map<CSCIdType,ExaminerStatusType>::const_iterator item = bCHAMB_WRN.find(chamber);
208  if( item != bCHAMB_WRN.end() ) return item->second; else return 0;
209  }
210 
212  std::map<DDUIdType,ExaminerStatusType>::const_iterator item = bDDU_ERR.find(dduSourceID);
213  if( item != bDDU_ERR.end() ) return item->second; else return 0;
214  }
216  std::map<DDUIdType,ExaminerStatusType>::const_iterator item = bDDU_WRN.find(dduSourceID);
217  if( item != bDDU_WRN.end() ) return item->second; else return 0;
218  }
219  std::vector<DDUIdType> listOfDDUs(void) const {
220  std::vector<DDUIdType> DDUs;
221  std::map<DDUIdType,ExaminerStatusType>::const_iterator item = bDDU_ERR.begin();
222  while( item != bDDU_ERR.end() ){ DDUs.push_back(item->first); item++; }
223  return DDUs;
224  }
225 
226  std::map<DDUIdType,ExaminerStatusType> errorsDetailedDDU (void) const { return bDDU_ERR; }
227 
228  std::map<CSCIdType,ExaminerStatusType> errorsDetailed (void) const { return bCHAMB_ERR; }
229  std::map<CSCIdType,ExaminerStatusType> warningsDetailed(void) const { return bCHAMB_WRN; }
230  std::map<CSCIdType,ExaminerStatusType> payloadDetailed (void) const { return bCHAMB_PAYLOAD; }
231  std::map<CSCIdType,ExaminerStatusType> statusDetailed (void) const { return bCHAMB_STATUS; }
232 
233 
234 
235  void crcALCT(bool enable);
236  void crcTMB (bool enable);
237  void crcCFEB(bool enable);
238 
239  void modeDDU(bool enable);
240 
241  bool isDDUmode() {return modeDDUonly;};
242 
243  DDUIdType dduSourceID(void){ return sourceID; }
244 
245  std::map<DDUIdType,const uint16_t*> DDU_block(void) const { return dduBuffers; }
246  std::map<DDUIdType,std::map<CSCIdType,const uint16_t*> > DMB_block(void) const { return dmbBuffers; }
247 
248  std::map<DDUIdType,uint32_t> DDU_ptrOffsets(void) const { return dduOffsets; }
249  std::map<DDUIdType,std::map<CSCIdType,uint32_t> > DMB_ptrOffsets(void) const { return dmbOffsets; }
250 
251  std::map<DDUIdType,uint32_t> DDU_size(void) const { return dduSize; }
252  std::map<DDUIdType,std::map<CSCIdType,uint32_t> > DMB_size(void) const { return dmbSize; }
253 
254  CSCDCCExaminer(ExaminerMaskType mask=0x1);
256 };
257 
258 #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]
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
double sign(double x)
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
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:187
ExaminerStatusType errors(void) const
void crcALCT(bool enable)
#define COUT
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
ExaminerStatusType bERROR
CSCDCCExaminer(ExaminerMaskType mask=0x1)
uint16_t tmpbuf[16]
uint32_t DDU_Firmware_Revision
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
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
tuple cout
Definition: gather_cfg.py:121
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
void setMask(ExaminerMaskType mask)
std::vector< const char * > sERROR_
std::map< DDUIdType, ExaminerStatusType > bDDU_WRN
uint32_t cntDDU_Trailers