CMS 3D CMS Logo

CSCALCTTrailer.h
Go to the documentation of this file.
1 #ifndef CSCALCTTrailer_h
2 #define CSCALCTTrailer_h
3 
8 #include <cstring> // memcpy
9 #ifndef LOCAL_UNPACK
10 #include <atomic>
11 #endif
14 
17 
18  void setFromBuffer(unsigned short const* buf) { memcpy(this, buf, sizeInWords() * 2); }
19 
20  void setSize(int size) { frameCount = size; }
21  void setCRC(unsigned int crc) {
22  crc0 = crc & 0x7FF;
23  crc1 = (crc >> 11) & 0x7FF;
24  }
25  short unsigned int sizeInWords() const {
26  return 4;
27  }
28  unsigned crc0 : 11, zero_0 : 1, d_0 : 4;
29  unsigned crc1 : 11, zero_1 : 1, d_1 : 4;
30  unsigned e0dLine : 16;
31  unsigned frameCount : 11, reserved_3 : 1, d_3 : 4;
32 };
33 
36 
37  void setFromBuffer(unsigned short const* buf) { memcpy(this, buf, sizeInWords() * 2); }
38 
39  void setSize(int size) { frameCount = size; }
40  void setCRC(unsigned int crc) {
41  crc0 = crc & 0x7FF;
42  crc1 = (crc >> 11) & 0x7FF;
43  }
44  short unsigned int sizeInWords() const {
45  return 4;
46  }
47  unsigned e0dLine : 16;
48  unsigned crc0 : 11, zero_0 : 1, reserved_0 : 4;
49  unsigned crc1 : 11, zero_1 : 1, reserved_1 : 4;
50  unsigned frameCount : 11, reserved_3 : 1, reserved_4 : 4;
51 };
52 
54 public:
56  CSCALCTTrailer(int size, int firmVersion);
57  CSCALCTTrailer(const unsigned short* buf);
59 
60  static void setDebug(bool debugValue) { debug = debugValue; }
61 
62  unsigned short* data() {
63 #ifdef LOCAL_UNPACK
64  switch (firmwareVersion) {
65 #else
66  switch (firmwareVersion.load()) {
67 #endif
68  case 2006:
70  break;
71  case 2007:
73  break;
74  default:
75  edm::LogError("CSCALCTTrailer|CSCRawToDigi")
76  << "couldn't access data: ALCT firmware version is bad/not defined!";
77  break;
78  }
79  return theOriginalBuffer;
80  }
81 
83  static int sizeInWords() { return 4; }
84 
85  void setCRC(unsigned int crc) {
86 #ifdef LOCAL_UNPACK
87  switch (firmwareVersion) {
88 #else
89  switch (firmwareVersion.load()) {
90 #endif
91  case 2006:
92  trailer2006.setCRC(crc);
93  break;
94  case 2007:
95  trailer2007.setCRC(crc);
96  break;
97  default:
98  edm::LogError("CSCALCTTrailer|CSCRawToDigi") << "couldn't setCRC: ALCT firmware version is bad/not defined!";
99  break;
100  }
101  }
102 
103  int getCRC() {
104 #ifdef LOCAL_UNPACK
105  switch (firmwareVersion) {
106 #else
107  switch (firmwareVersion.load()) {
108 #endif
109  case 2006:
110  return ((trailer2006.crc1 & 0x7ff) << 11) | (trailer2006.crc0 & 0x7ff);
111  case 2007:
112  return ((trailer2007.crc1 & 0x7ff) << 11) | (trailer2007.crc0 & 0x7ff);
113  default:
114  edm::LogError("CSCALCTTrailer|CSCRawToDigi") << "couldn't getCRC: ALCT firmware version is bad/not defined!";
115  return 0;
116  }
117  }
118 
119  bool check() const {
120 #ifdef LOCAL_UNPACK
121  switch (firmwareVersion) {
122 #else
123  switch (firmwareVersion.load()) {
124 #endif
125  case 2006:
126  return (trailer2006.e0dLine & 0xfff) == 0xe0d;
127  case 2007:
128  return (trailer2007.e0dLine & 0xffff) == 0xde0d;
129  default:
130  edm::LogError("CSCALCTTrailer|CSCRawToDigi") << "couldn't check: ALCT firmware version is bad/not defined!";
131  return false;
132  }
133  }
134 
135  int wordCount() const {
136 #ifdef LOCAL_UNPACK
137  switch (firmwareVersion) {
138 #else
139  switch (firmwareVersion.load()) {
140 #endif
141  case 2006:
142  return trailer2006.frameCount;
143  case 2007:
144  return trailer2007.frameCount;
145  default:
146  edm::LogError("CSCALCTTrailer|CSCRawToDigi") << "couldn't wordCount: ALCT firmware version is bad/not defined!";
147  return 0;
148  }
149  }
150 
151  unsigned alctCRCCheck() const {
152 #ifdef LOCAL_UNPACK
153  switch (firmwareVersion) {
154 #else
155  switch (firmwareVersion.load()) {
156 #endif
157  case 2006:
158  return trailer2006.reserved_3;
159  case 2007:
160  return trailer2007.reserved_3;
161  default:
162  edm::LogError("CSCALCTTrailer|CSCRawToDigi") << "couldn't CRCcheck: ALCT firmware version is bad/not defined!";
163  return 0;
164  }
165  }
166 
167  unsigned FrameCount() const { return wordCount(); }
168 
171 
172 private:
173 #ifdef LOCAL_UNPACK
174  static bool debug;
175  static unsigned short int firmwareVersion;
176 #else
177  static std::atomic<bool> debug;
178  static std::atomic<unsigned short int> firmwareVersion;
179 #endif
180 
183  unsigned short int theOriginalBuffer[4];
184 };
185 
186 #endif
CSCALCTTrailer2006::setCRC
void setCRC(unsigned int crc)
Definition: CSCALCTTrailer.h:21
CSCALCTTrailer2007
Definition: CSCALCTTrailer.h:34
MessageLogger.h
CSCALCTTrailer2006
Definition: CSCALCTTrailer.h:15
CSCALCTStatusDigi.h
CSCALCTTrailer2007::reserved_1
unsigned reserved_1
Definition: CSCALCTTrailer.h:49
CSCALCTTrailer2007::reserved_3
unsigned reserved_3
Definition: CSCALCTTrailer.h:50
CSCALCTTrailer2007::setFromBuffer
void setFromBuffer(unsigned short const *buf)
Definition: CSCALCTTrailer.h:37
CSCALCTTrailer::CSCALCTTrailer
CSCALCTTrailer(const CSCALCTStatusDigi &digi)
Definition: CSCALCTTrailer.h:58
CSCALCTTrailer
Definition: CSCALCTTrailer.h:53
CSCALCTTrailer::trailer2006
CSCALCTTrailer2006 trailer2006
Definition: CSCALCTTrailer.h:181
CSCALCTTrailer2006::reserved_3
unsigned reserved_3
Definition: CSCALCTTrailer.h:31
CSCALCTTrailer::sizeInWords
static int sizeInWords()
in 16-bit frames
Definition: CSCALCTTrailer.h:83
CSCALCTTrailer::getCRC
int getCRC()
Definition: CSCALCTTrailer.h:103
CSCALCTTrailer2006::e0dLine
unsigned e0dLine
Definition: CSCALCTTrailer.h:30
CSCALCTTrailer2006::setFromBuffer
void setFromBuffer(unsigned short const *buf)
Definition: CSCALCTTrailer.h:18
CSCALCTTrailer::data
unsigned short * data()
Definition: CSCALCTTrailer.h:62
CSCALCTTrailer::alctTrailer2006
CSCALCTTrailer2006 alctTrailer2006()
Definition: CSCALCTTrailer.h:169
CSCALCTTrailer2006::d_3
unsigned d_3
Definition: CSCALCTTrailer.h:31
CSCALCTTrailer::theOriginalBuffer
unsigned short int theOriginalBuffer[4]
Definition: CSCALCTTrailer.h:183
CSCALCTTrailer::firmwareVersion
static std::atomic< unsigned short int > firmwareVersion
Definition: CSCALCTTrailer.h:178
CSCALCTTrailer2006::zero_1
unsigned zero_1
Definition: CSCALCTTrailer.h:29
CSCALCTTrailer::trailer2007
CSCALCTTrailer2007 trailer2007
Definition: CSCALCTTrailer.h:182
CSCALCTTrailer2006::zero_0
unsigned zero_0
Definition: CSCALCTTrailer.h:28
CSCALCTTrailer2006::frameCount
unsigned frameCount
Definition: CSCALCTTrailer.h:31
CSCALCTTrailer2006::d_1
unsigned d_1
Definition: CSCALCTTrailer.h:29
CSCALCTStatusDigi
Definition: CSCALCTStatusDigi.h:15
edm::LogError
Definition: MessageLogger.h:183
CSCALCTTrailer2007::reserved_4
unsigned reserved_4
Definition: CSCALCTTrailer.h:50
CSCALCTTrailer2007::zero_1
unsigned zero_1
Definition: CSCALCTTrailer.h:49
CSCALCTTrailer::check
bool check() const
Definition: CSCALCTTrailer.h:119
CSCALCTTrailer2006::crc1
unsigned crc1
Definition: CSCALCTTrailer.h:29
CSCALCTTrailer2007::crc0
unsigned crc0
Definition: CSCALCTTrailer.h:48
CSCALCTTrailer2007::sizeInWords
short unsigned int sizeInWords() const
Definition: CSCALCTTrailer.h:44
CSCALCTTrailer2007::CSCALCTTrailer2007
CSCALCTTrailer2007()
Definition: CSCALCTTrailer.cc:30
CSCALCTTrailer2007::e0dLine
unsigned e0dLine
Definition: CSCALCTTrailer.h:47
visDQMUpload.buf
buf
Definition: visDQMUpload.py:154
CSCALCTTrailer2007::setCRC
void setCRC(unsigned int crc)
Definition: CSCALCTTrailer.h:40
CSCALCTStatusDigi::trailer
const uint16_t * trailer() const
Definition: CSCALCTStatusDigi.h:25
CSCALCTTrailer2006::d_0
unsigned d_0
Definition: CSCALCTTrailer.h:28
CSCALCTTrailer::setDebug
static void setDebug(bool debugValue)
Definition: CSCALCTTrailer.h:60
CSCALCTTrailer::wordCount
int wordCount() const
Definition: CSCALCTTrailer.h:135
CSCALCTTrailer2006::CSCALCTTrailer2006
CSCALCTTrailer2006()
Definition: CSCALCTTrailer.cc:19
CSCALCTTrailer2006::setSize
void setSize(int size)
Definition: CSCALCTTrailer.h:20
CSCALCTTrailer2006::sizeInWords
short unsigned int sizeInWords() const
Definition: CSCALCTTrailer.h:25
CSCALCTTrailer2007::reserved_0
unsigned reserved_0
Definition: CSCALCTTrailer.h:48
CSCALCTTrailer2007::setSize
void setSize(int size)
Definition: CSCALCTTrailer.h:39
CSCALCTTrailer2007::frameCount
unsigned frameCount
Definition: CSCALCTTrailer.h:50
CSCALCTTrailer::setCRC
void setCRC(unsigned int crc)
Definition: CSCALCTTrailer.h:85
CSCALCTTrailer2007::zero_0
unsigned zero_0
Definition: CSCALCTTrailer.h:48
CSCALCTTrailer::alctTrailer2007
CSCALCTTrailer2007 alctTrailer2007()
Definition: CSCALCTTrailer.h:170
CSCALCTTrailer2007::crc1
unsigned crc1
Definition: CSCALCTTrailer.h:49
CSCALCTTrailer2006::crc0
unsigned crc0
Definition: CSCALCTTrailer.h:28
CSCALCTTrailer::FrameCount
unsigned FrameCount() const
Definition: CSCALCTTrailer.h:167
CSCALCTTrailer::CSCALCTTrailer
CSCALCTTrailer(int size, int firmVersion)
needed for packing
Definition: CSCALCTTrailer.cc:39
CSCALCTTrailer::alctCRCCheck
unsigned alctCRCCheck() const
Definition: CSCALCTTrailer.h:151
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443
CSCALCTTrailer::debug
static std::atomic< bool > debug
Definition: CSCALCTTrailer.h:177