test
CMS 3D CMS Logo

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