CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
CSCDCCExaminer.h
Go to the documentation of this file.
1 #ifndef EventFilter_CSCRawToDigi_CSCDCCExaminer_h
2 #define EventFilter_CSCRawToDigi_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();
54  tie(&str);
55  if (rdbuf() != null)
56  rdbuf(stream);
57  }
58 
59  template <class T>
60  std::ostream& operator<<(const T& val) {
61  return (*(std::ostream*)this) << name << val;
62  }
63 
64  OStream(void) : std::ostream(std::cout.rdbuf()), buff(), stream(std::cout.rdbuf()), null(&buff), name("") {}
65  OStream(std::ostream& str) : std::ostream(str.rdbuf()), buff(), stream(str.rdbuf()), null(&buff), name("") {}
66  };
67 
68  OStream COUT, CERR;
69 #endif
70 
71  CSCIdType currentChamber; // ( (CrateNumber<<4) + DMBslot ) specifies chamber
72 
73  const uint16_t *buf_2, *buf_1, *buf0, *buf1, *buf2;
74  uint16_t tmpbuf[16];
75 
87 
88  bool uniqueALCT, uniqueTMB; // Do not merge two DMBs if Trailer of the first and Header of the second are lost
89 
90  bool DAV_ALCT; // ...
91  bool DAV_TMB; // Check if DAV bits lie
92  int DAV_CFEB; // ...
93  int DAV_DMB; // ...
94  int DMB_Active, nDMBs; // ...
95 
96 public:
97  uint32_t cntDDU_Headers;
98  uint32_t cntDDU_Trailers;
99  std::map<CSCIdType, uint32_t> cntCHAMB_Headers;
100  std::map<CSCIdType, uint32_t> cntCHAMB_Trailers;
101 
102 private:
103  void clear();
104  void zeroCounts();
105  void sync_stats();
107  void checkDAVs();
109 
110  inline int scanbuf(const uint16_t*& buf, int32_t length, uint16_t sig, uint16_t mask = 0xFFFF);
111 
113  uint32_t DDU_WordCount;
116 
119  uint32_t ALCT_WordCount;
121  uint32_t ALCT_ZSE;
122  uint32_t nWG_round_up;
123 
125  uint32_t TMB_WordCount;
127  uint32_t TMB_Tbins;
128  uint32_t TMB_WordsRPC;
129  uint32_t TMB_WordsGEM;
132 
136 
138  uint32_t ALCT_CRC;
140  uint32_t TMB_CRC;
142  uint32_t CFEB_CRC;
143 
147 
148  //int headerDAV_Active; // Obsolete since 16.09.05
149 
150  // data blocks:
151  std::map<DDUIdType, const uint16_t*> dduBuffers; // < DDUsourceID, pointer >
152  std::map<DDUIdType, std::map<CSCIdType, const uint16_t*> > dmbBuffers; // < DDUsourceID, < DMBid, pointer > >
153  std::map<DDUIdType, uint32_t> dduOffsets; // < DDUsourceID, pointer_offset >
154  std::map<DDUIdType, std::map<CSCIdType, uint32_t> > dmbOffsets; // < DDUsourceID, < DMBid, pointer_offset > >
155  std::map<DDUIdType, uint32_t> dduSize; // < DDUsourceID, block_size >
156  std::map<DDUIdType, std::map<CSCIdType, uint32_t> > dmbSize; // < DDUsourceID, < DMBid, block_size > >
157  const uint16_t* buffer_start;
158 
159 public:
160 #ifdef LOCAL_UNPACK
161  OStream& output1(void) { return COUT; }
162  OStream& output2(void) { return CERR; }
163 #endif
164 
165  int32_t check(const uint16_t*& buffer, int32_t length);
166 
167  void setMask(ExaminerMaskType mask) { examinerMask = mask; }
169 
170  ExaminerStatusType errors(void) const { return bSUM_ERROR; }
171  ExaminerStatusType warnings(void) const { return bSUM_WARNING; }
172 
173  const char* errName(int num) const {
174  if (num >= 0 && num < nERRORS)
175  return sERROR[num];
176  else
177  return "";
178  }
179  const char* wrnName(int num) const {
180  if (num >= 0 && num < nWARNINGS)
181  return sWARNING[num];
182  else
183  return "";
184  }
185 
186  const char* errorName(int num) const {
187  if (num >= 0 && num < nERRORS)
188  return sERROR_[num];
189  else
190  return "";
191  }
192  const char* warningName(int num) const {
193  if (num >= 0 && num < nWARNINGS)
194  return sWARNING_[num];
195  else
196  return "";
197  }
198 
199  const char* payloadName(int num) const {
200  if (num >= 0 && num < nPAYLOADS)
201  return sDMBExpectedPayload[num];
202  else
203  return "";
204  }
205  const char* statusName(int num) const {
206  if (num >= 0 && num < nSTATUSES)
207  return sDMBEventStaus[num];
208  else
209  return "";
210  }
211 
212  bool error(int num) const {
213  if (num >= 0 && num < nERRORS)
214  return fSUM_ERROR[num];
215  else
216  return false;
217  }
218  bool warning(int num) const {
219  if (num >= 0 && num < nWARNINGS)
220  return fSUM_WARNING[num];
221  else
222  return false;
223  }
224 
225  std::set<CSCIdType> chambersWithError(int num) const {
226  if (num >= 0 && num < nERRORS)
227  return fCHAMB_ERR[num];
228  else
229  return std::set<int>();
230  }
231  std::set<CSCIdType> chambersWithWarning(int num) const {
232  if (num >= 0 && num < nWARNINGS)
233  return fCHAMB_WRN[num];
234  else
235  return std::set<int>();
236  }
237 
239  std::map<CSCIdType, ExaminerStatusType>::const_iterator item = bCHAMB_PAYLOAD.find(chamber);
240  if (item != bCHAMB_PAYLOAD.end())
241  return item->second;
242  else
243  return 0;
244  }
245 
247  std::map<CSCIdType, ExaminerStatusType>::const_iterator item = bCHAMB_STATUS.find(chamber);
248  if (item != bCHAMB_STATUS.end())
249  return item->second;
250  else
251  return 0;
252  }
253 
255  std::map<CSCIdType, ExaminerStatusType>::const_iterator item = bCHAMB_ERR.find(chamber);
257 
258  // for(item =bCHAMB_ERR.begin() ; item !=bCHAMB_ERR.end() ; item++)
259  //std::cout << " Ex-errors: " << std::hex << (*item).second << std::dec << std::endl;
260 
261  item = bCHAMB_ERR.find(chamber);
262  if (item != bCHAMB_ERR.end())
263  return item->second;
264  else
265  return 0;
266  }
267 
269  std::map<CSCIdType, ExaminerStatusType>::const_iterator item = bCHAMB_WRN.find(chamber);
270  if (item != bCHAMB_WRN.end())
271  return item->second;
272  else
273  return 0;
274  }
275 
277  std::map<DDUIdType, ExaminerStatusType>::const_iterator item = bDDU_ERR.find(dduSourceID);
278  if (item != bDDU_ERR.end())
279  return item->second;
280  else
281  return 0;
282  }
284  std::map<DDUIdType, ExaminerStatusType>::const_iterator item = bDDU_WRN.find(dduSourceID);
285  if (item != bDDU_WRN.end())
286  return item->second;
287  else
288  return 0;
289  }
290  std::vector<DDUIdType> listOfDDUs(void) const {
291  std::vector<DDUIdType> DDUs;
292  std::map<DDUIdType, ExaminerStatusType>::const_iterator item = bDDU_ERR.begin();
293  while (item != bDDU_ERR.end()) {
294  DDUs.push_back(item->first);
295  item++;
296  }
297  return DDUs;
298  }
299 
300  std::map<DDUIdType, ExaminerStatusType> errorsDetailedDDU(void) const { return bDDU_ERR; }
301 
302  std::map<CSCIdType, ExaminerStatusType> errorsDetailed(void) const { return bCHAMB_ERR; }
303  std::map<CSCIdType, ExaminerStatusType> warningsDetailed(void) const { return bCHAMB_WRN; }
304  std::map<CSCIdType, ExaminerStatusType> payloadDetailed(void) const { return bCHAMB_PAYLOAD; }
305  std::map<CSCIdType, ExaminerStatusType> statusDetailed(void) const { return bCHAMB_STATUS; }
306 
307  void crcALCT(bool enable);
308  void crcTMB(bool enable);
309  void crcCFEB(bool enable);
310 
311  void modeDDU(bool enable);
312 
313  bool isDDUmode() { return modeDDUonly; };
314 
315  DDUIdType dduSourceID(void) { return sourceID; }
316 
317  std::map<DDUIdType, const uint16_t*> DDU_block(void) const { return dduBuffers; }
318  std::map<DDUIdType, std::map<CSCIdType, const uint16_t*> > DMB_block(void) const { return dmbBuffers; }
319 
320  std::map<DDUIdType, uint32_t> DDU_ptrOffsets(void) const { return dduOffsets; }
321  std::map<DDUIdType, std::map<CSCIdType, uint32_t> > DMB_ptrOffsets(void) const { return dmbOffsets; }
322 
323  std::map<DDUIdType, uint32_t> DDU_size(void) const { return dduSize; }
324  std::map<DDUIdType, std::map<CSCIdType, uint32_t> > DMB_size(void) const { return dmbSize; }
325 
326  CSCDCCExaminer(ExaminerMaskType mask = 0x1);
328 };
329 
330 #endif
uint32_t DDU_WordsSinceLastHeader
uint32_t TMB_WordCount
const uint16_t nSTATUSES
const uint16_t * buf0
const uint16_t * buffer_start
std::map< CSCIdType, ExaminerStatusType > bCHAMB_ERR
void crcCFEB(bool enable)
std::map< DDUIdType, ExaminerStatusType > bDDU_ERR
const char * errorName(int num) const
uint32_t CFEB_SampleWordCount
bool warning(int num) const
std::map< DDUIdType, ExaminerStatusType > bDDU_WRN
std::set< CSCIdType > fCHAMB_ERR[29]
std::map< DDUIdType, uint32_t > dduOffsets
std::map< DDUIdType, uint32_t > dduSize
const uint16_t * buf2
std::vector< DDUIdType > listOfDDUs(void) const
std::map< DDUIdType, uint32_t > DDU_ptrOffsets(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, std::map< CSCIdType, uint32_t > > DMB_ptrOffsets(void) const
uint32_t TMB_WordsGEM
uint32_t DDU_WordsSinceLastTrailer
DDUIdType dduSourceID(void)
std::map< CSCIdType, ExaminerStatusType > bCHAMB_PAYLOAD
uint32_t cntDDU_Headers
uint32_t T const *__restrict__ uint32_t const *__restrict__ int32_t int Histo::index_type cudaStream_t stream
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:167
ExaminerStatusType errors(void) const
void crcALCT(bool enable)
const char * errName(int num) const
uint32_t ALCT_WordsExpected
std::map< DDUIdType, uint32_t > DDU_size(void) const
std::vector< const char * > sERROR
std::set< CSCIdType > chambersWithError(int num) const
std::map< DDUIdType, const uint16_t * > dduBuffers
ExaminerStatusType warnings(void) const
uint32_t TMB_Firmware_Revision
CSCIdType currentChamber
std::set< CSCIdType > chambersWithWarning(int num) const
uint32_t nWG_round_up
check zero suppression mode
std::map< CSCIdType, uint32_t > cntCHAMB_Trailers
const uint16_t nWARNINGS
std::map< DDUIdType, std::map< CSCIdType, uint32_t > > dmbSize
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
uint32_t CFEB_SampleCount
void crcTMB(bool enable)
std::map< DDUIdType, ExaminerStatusType > errorsDetailedDDU(void) const
ExaminerStatusType bSUM_ERROR
std::map< CSCIdType, ExaminerStatusType > bCHAMB_WRN
const char * statusName(int num) const
uint32_t TMB_WordsRPC
uint32_t TMB_Tbins
ExaminerStatusType errorsForDDU(DDUIdType dduSourceID) const
uint32_t TMB_WordsExpected
#define COUT
const uint16_t * buf_2
const uint16_t * buf_1
const uint16_t nPAYLOADS
uint32_t CFEB_BSampleCount
ExaminerMaskType getMask() const
std::map< DDUIdType, std::map< CSCIdType, const uint16_t * > > DMB_block(void) const
std::map< DDUIdType, std::map< CSCIdType, uint32_t > > dmbOffsets
uint32_t TMB_WordsSinceLastHeader
to decode if zero suppression enabled
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
std::map< DDUIdType, const uint16_t * > DDU_block(void) const
uint32_t ExaminerStatusType
std::vector< const char * > sWARNING
const char * payloadName(int num) const
DDUIdType sourceID
ExaminerStatusType warningsForChamber(CSCIdType chamber) const
uint32_t ALCT_WordsSinceLastHeaderZeroSuppressed
int32_t check(const uint16_t *&buffer, int32_t length)
const char * wrnName(int num) const
int16_t DDUIdType
std::map< CSCIdType, ExaminerStatusType > warningsDetailed(void) const
uint32_t DDU_WordCount
std::map< CSCIdType, ExaminerStatusType > bCHAMB_STATUS
ExaminerMaskType examinerMask
std::map< DDUIdType, std::map< CSCIdType, uint32_t > > DMB_size(void) const
void checkDAVs()
checks DAV_ALCT, DAV_TMB, and DAV_CFEB
ExaminerStatusType bWARNING
std::map< CSCIdType, ExaminerStatusType > statusDetailed(void) const
std::map< CSCIdType, ExaminerStatusType > errorsDetailed(void) const
tuple cout
Definition: gather_cfg.py:144
std::vector< const char * > sDMBEventStaus
#define str(s)
bool error(int num) const
uint32_t ExaminerMaskType
long double T
std::map< DDUIdType, std::map< CSCIdType, const uint16_t * > > dmbBuffers
void setMask(ExaminerMaskType mask)
std::vector< const char * > sERROR_
std::map< CSCIdType, ExaminerStatusType > payloadDetailed(void) const
std::map< CSCIdType, uint32_t > cntCHAMB_Headers
uint32_t cntDDU_Trailers