CMS 3D CMS Logo

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;
122  uint32_t ALCT_ZSE;
123  uint32_t nWG_round_up;
124 
126  uint32_t TMB_WordCount;
128  uint32_t TMB_Tbins;
129  uint32_t TMB_WordsRPC;
130  uint32_t TMB_WordsGEM;
133 
137 
139  uint32_t ALCT_CRC;
141  uint32_t TMB_CRC;
143  uint32_t CFEB_CRC;
144 
148 
149  //int headerDAV_Active; // Obsolete since 16.09.05
150 
151  // data blocks:
152  std::map<DDUIdType, const uint16_t*> dduBuffers; // < DDUsourceID, pointer >
153  std::map<DDUIdType, std::map<CSCIdType, const uint16_t*> > dmbBuffers; // < DDUsourceID, < DMBid, pointer > >
154  std::map<DDUIdType, uint32_t> dduOffsets; // < DDUsourceID, pointer_offset >
155  std::map<DDUIdType, std::map<CSCIdType, uint32_t> > dmbOffsets; // < DDUsourceID, < DMBid, pointer_offset > >
156  std::map<DDUIdType, uint32_t> dduSize; // < DDUsourceID, block_size >
157  std::map<DDUIdType, std::map<CSCIdType, uint32_t> > dmbSize; // < DDUsourceID, < DMBid, block_size > >
158  const uint16_t* buffer_start;
159 
160 public:
161 #ifdef LOCAL_UNPACK
162  OStream& output1(void) { return COUT; }
163  OStream& output2(void) { return CERR; }
164 #endif
165 
166  int32_t check(const uint16_t*& buffer, int32_t length);
167 
170 
171  ExaminerStatusType errors(void) const { return bSUM_ERROR; }
172  ExaminerStatusType warnings(void) const { return bSUM_WARNING; }
173 
174  const char* errName(int num) const {
175  if (num >= 0 && num < nERRORS)
176  return sERROR[num];
177  else
178  return "";
179  }
180  const char* wrnName(int num) const {
181  if (num >= 0 && num < nWARNINGS)
182  return sWARNING[num];
183  else
184  return "";
185  }
186 
187  const char* errorName(int num) const {
188  if (num >= 0 && num < nERRORS)
189  return sERROR_[num];
190  else
191  return "";
192  }
193  const char* warningName(int num) const {
194  if (num >= 0 && num < nWARNINGS)
195  return sWARNING_[num];
196  else
197  return "";
198  }
199 
200  const char* payloadName(int num) const {
201  if (num >= 0 && num < nPAYLOADS)
202  return sDMBExpectedPayload[num];
203  else
204  return "";
205  }
206  const char* statusName(int num) const {
207  if (num >= 0 && num < nSTATUSES)
208  return sDMBEventStaus[num];
209  else
210  return "";
211  }
212 
213  bool error(int num) const {
214  if (num >= 0 && num < nERRORS)
215  return fSUM_ERROR[num];
216  else
217  return false;
218  }
219  bool warning(int num) const {
220  if (num >= 0 && num < nWARNINGS)
221  return fSUM_WARNING[num];
222  else
223  return false;
224  }
225 
226  std::set<CSCIdType> chambersWithError(int num) const {
227  if (num >= 0 && num < nERRORS)
228  return fCHAMB_ERR[num];
229  else
230  return std::set<int>();
231  }
232  std::set<CSCIdType> chambersWithWarning(int num) const {
233  if (num >= 0 && num < nWARNINGS)
234  return fCHAMB_WRN[num];
235  else
236  return std::set<int>();
237  }
238 
240  std::map<CSCIdType, ExaminerStatusType>::const_iterator item = bCHAMB_PAYLOAD.find(chamber);
241  if (item != bCHAMB_PAYLOAD.end())
242  return item->second;
243  else
244  return 0;
245  }
246 
248  std::map<CSCIdType, ExaminerStatusType>::const_iterator item = bCHAMB_STATUS.find(chamber);
249  if (item != bCHAMB_STATUS.end())
250  return item->second;
251  else
252  return 0;
253  }
254 
256  std::map<CSCIdType, ExaminerStatusType>::const_iterator item = bCHAMB_ERR.find(chamber);
258 
259  // for(item =bCHAMB_ERR.begin() ; item !=bCHAMB_ERR.end() ; item++)
260  //std::cout << " Ex-errors: " << std::hex << (*item).second << std::dec << std::endl;
261 
262  item = bCHAMB_ERR.find(chamber);
263  if (item != bCHAMB_ERR.end())
264  return item->second;
265  else
266  return 0;
267  }
268 
270  std::map<CSCIdType, ExaminerStatusType>::const_iterator item = bCHAMB_WRN.find(chamber);
271  if (item != bCHAMB_WRN.end())
272  return item->second;
273  else
274  return 0;
275  }
276 
278  std::map<DDUIdType, ExaminerStatusType>::const_iterator item = bDDU_ERR.find(dduSourceID);
279  if (item != bDDU_ERR.end())
280  return item->second;
281  else
282  return 0;
283  }
285  std::map<DDUIdType, ExaminerStatusType>::const_iterator item = bDDU_WRN.find(dduSourceID);
286  if (item != bDDU_WRN.end())
287  return item->second;
288  else
289  return 0;
290  }
291  std::vector<DDUIdType> listOfDDUs(void) const {
292  std::vector<DDUIdType> DDUs;
293  std::map<DDUIdType, ExaminerStatusType>::const_iterator item = bDDU_ERR.begin();
294  while (item != bDDU_ERR.end()) {
295  DDUs.push_back(item->first);
296  item++;
297  }
298  return DDUs;
299  }
300 
301  std::map<DDUIdType, ExaminerStatusType> errorsDetailedDDU(void) const { return bDDU_ERR; }
302 
303  std::map<CSCIdType, ExaminerStatusType> errorsDetailed(void) const { return bCHAMB_ERR; }
304  std::map<CSCIdType, ExaminerStatusType> warningsDetailed(void) const { return bCHAMB_WRN; }
305  std::map<CSCIdType, ExaminerStatusType> payloadDetailed(void) const { return bCHAMB_PAYLOAD; }
306  std::map<CSCIdType, ExaminerStatusType> statusDetailed(void) const { return bCHAMB_STATUS; }
307 
308  void crcALCT(bool enable);
309  void crcTMB(bool enable);
310  void crcCFEB(bool enable);
311 
312  void modeDDU(bool enable);
313 
314  bool isDDUmode() { return modeDDUonly; };
315 
316  DDUIdType dduSourceID(void) { return sourceID; }
317 
318  std::map<DDUIdType, const uint16_t*> DDU_block(void) const { return dduBuffers; }
319  std::map<DDUIdType, std::map<CSCIdType, const uint16_t*> > DMB_block(void) const { return dmbBuffers; }
320 
321  std::map<DDUIdType, uint32_t> DDU_ptrOffsets(void) const { return dduOffsets; }
322  std::map<DDUIdType, std::map<CSCIdType, uint32_t> > DMB_ptrOffsets(void) const { return dmbOffsets; }
323 
324  std::map<DDUIdType, uint32_t> DDU_size(void) const { return dduSize; }
325  std::map<DDUIdType, std::map<CSCIdType, uint32_t> > DMB_size(void) const { return dmbSize; }
326 
329 };
330 
331 #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 > statusDetailed(void) const
std::map< CSCIdType, ExaminerStatusType > bCHAMB_ERR
void crcCFEB(bool enable)
std::map< DDUIdType, ExaminerStatusType > bDDU_ERR
uint32_t CFEB_SampleWordCount
std::map< DDUIdType, std::map< CSCIdType, uint32_t > > DMB_ptrOffsets(void) 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
std::map< DDUIdType, uint32_t > DDU_ptrOffsets(void) const
const char * statusName(int num) const
std::set< CSCIdType > chambersWithError(int num) const
const uint16_t * buf2
int scanbuf(const uint16_t *&buf, int32_t length, uint16_t sig, uint16_t mask=0xFFFF)
int32_t CSCIdType
ExaminerStatusType errorsForChamber(CSCIdType chamber) const
void modeDDU(bool enable)
uint32_t ALCT_WordsSinceLastHeader
const uint16_t * buf1
ExaminerStatusType bSUM_WARNING
uint32_t ALCT_WordCount
ExaminerStatusType warningsForChamber(CSCIdType chamber) const
ExaminerStatusType warningsForDDU(DDUIdType dduSourceID) const
ExaminerStatusType errorsForDDU(DDUIdType dduSourceID) const
const uint16_t nERRORS
ExaminerMaskType getMask() const
std::vector< DDUIdType > listOfDDUs(void) const
const char * payloadName(int num) const
uint32_t TMB_WordsGEM
ExaminerStatusType statusForChamber(CSCIdType chamber) const
bool warning(int num) const
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
void crcALCT(bool enable)
uint32_t ALCT_WordsExpected
std::vector< const char * > sERROR
std::map< DDUIdType, std::map< CSCIdType, const uint16_t * > > DMB_block(void) const
std::map< DDUIdType, const uint16_t * > dduBuffers
uint32_t TMB_Firmware_Revision
CSCIdType currentChamber
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_
std::set< CSCIdType > fCHAMB_WRN[5]
uint32_t ALCT_ZSE
number of ALCT words before anode raw data
bool fSUM_ERROR[29]
uint32_t DDU_WordMismatch_Occurrences
std::map< CSCIdType, ExaminerStatusType > payloadDetailed(void) const
uint32_t CFEB_SampleCount
std::map< DDUIdType, std::map< CSCIdType, uint32_t > > DMB_size(void) const
void crcTMB(bool enable)
std::set< CSCIdType > chambersWithWarning(int num) const
ExaminerStatusType bSUM_ERROR
std::map< CSCIdType, ExaminerStatusType > bCHAMB_WRN
const char * errName(int num) const
uint32_t TMB_WordsRPC
uint32_t TMB_Tbins
uint32_t TMB_WordsExpected
#define COUT
enable
Messages.
Definition: DiMuonV_cfg.py:93
const uint16_t * buf_2
const uint16_t * buf_1
const uint16_t nPAYLOADS
uint32_t CFEB_BSampleCount
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]
std::map< DDUIdType, uint32_t > DDU_size(void) 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
DDUIdType sourceID
std::map< CSCIdType, ExaminerStatusType > errorsDetailed(void) const
const char * wrnName(int num) const
uint32_t ALCT_WordsSinceLastHeaderZeroSuppressed
int32_t check(const uint16_t *&buffer, int32_t length)
int16_t DDUIdType
uint32_t DDU_WordCount
std::map< CSCIdType, ExaminerStatusType > bCHAMB_STATUS
ExaminerMaskType examinerMask
uint32_t ALCT_WordsBeforeRaw
ExaminerStatusType errors(void) const
void checkDAVs()
checks DAV_ALCT, DAV_TMB, and DAV_CFEB
ExaminerStatusType bWARNING
bool error(int num) const
ExaminerStatusType warnings(void) const
std::map< DDUIdType, ExaminerStatusType > errorsDetailedDDU(void) const
std::vector< const char * > sDMBEventStaus
std::map< CSCIdType, ExaminerStatusType > warningsDetailed(void) const
#define str(s)
uint32_t ExaminerMaskType
long double T
std::map< DDUIdType, std::map< CSCIdType, const uint16_t * > > dmbBuffers
void setMask(ExaminerMaskType mask)
ExaminerStatusType payloadForChamber(CSCIdType chamber) const
std::vector< const char * > sERROR_
std::map< CSCIdType, uint32_t > cntCHAMB_Headers
uint32_t cntDDU_Trailers
const char * errorName(int num) const