CMS 3D CMS Logo

L1GtPsbWord.cc
Go to the documentation of this file.
1 
15 // this class header
17 
18 // system include files
19 #include <iomanip>
20 
21 // user include files
23 
24 // constructors
25 
26 // empty constructor, all members set to zero;
28  m_boardId = 0;
29  m_bxInEvent = 0;
30  m_bxNr = 0;
31  m_eventNr = 0;
32 
33  for (int iA = 0; iA < NumberAData; ++iA) {
34  m_aData[iA] = 0;
35  }
36 
37  for (int iB = 0; iB < NumberBData; ++iB) {
38  m_bData[iB] = 0;
39  }
40 
41  m_localBxNr = 0;
42 }
43 
44 // constructor from unpacked values;
46  int bxInEventValue,
47  cms_uint16_t bxNrValue,
48  cms_uint32_t eventNrValue,
49  cms_uint16_t aDataValue[NumberAData],
50  cms_uint16_t bDataValue[NumberBData],
51  cms_uint16_t localBxNrValue) {
52  m_boardId = boardIdValue;
53  m_bxInEvent = bxInEventValue;
54  m_bxNr = bxNrValue;
55  m_eventNr = eventNrValue;
56 
57  for (int iA = 0; iA < NumberAData; ++iA) {
58  m_aData[iA] = aDataValue[iA];
59  }
60 
61  for (int iB = 0; iB < NumberBData; ++iB) {
62  m_bData[iB] = bDataValue[iB];
63  }
64 
65  m_localBxNr = localBxNrValue;
66 }
67 
68 // destructor
70  // empty now
71 }
72 
73 // equal operator
75  if (m_boardId != result.m_boardId) {
76  return false;
77  }
78  if (m_bxInEvent != result.m_bxInEvent) {
79  return false;
80  }
81  if (m_bxNr != result.m_bxNr) {
82  return false;
83  }
84  if (m_eventNr != result.m_eventNr) {
85  return false;
86  }
87 
88  for (int iA = 0; iA < NumberAData; ++iA) {
89  if (m_aData[iA] != result.m_aData[iA]) {
90  return false;
91  }
92  }
93 
94  for (int iB = 0; iB < NumberBData; ++iB) {
95  if (m_bData[iB] != result.m_bData[iB]) {
96  return false;
97  }
98  }
99 
100  if (m_localBxNr != result.m_localBxNr) {
101  return false;
102  }
103 
104  // all members identical
105  return true;
106 }
107 
108 // unequal operator
109 bool L1GtPsbWord::operator!=(const L1GtPsbWord& result) const { return !(result == *this); }
110 
111 // methods
112 
113 // set the BoardId value from a 64-bits word, having the index iWord
114 // in the GTFE raw record
115 void L1GtPsbWord::setBoardId(const cms_uint64_t& word64, int iWord) {
116  if (iWord == BoardIdWord) {
117  m_boardId = (word64 & BoardIdMask) >> BoardIdShift;
118  }
119 }
120 
121 // set the BoardId value in a 64-bits word, having the index iWord
122 // in the GTFE raw record
123 void L1GtPsbWord::setBoardIdWord64(cms_uint64_t& word64, int iWord) {
124  if (iWord == BoardIdWord) {
125  word64 = word64 | (static_cast<cms_uint64_t>(m_boardId) << BoardIdShift);
126  }
127 }
128 
129 // set the BxInEvent value from a 64-bits word, having the index iWord
130 // in the GTFE raw record
131 void L1GtPsbWord::setBxInEvent(const cms_uint64_t& word64, int iWord) {
132  if (iWord == BxInEventWord) {
133  int baseValue = 16; // using hexadecimal values;
134  int hexBxInEvent = (word64 & BxInEventMask) >> BxInEventShift;
135  m_bxInEvent = (hexBxInEvent + baseValue / 2) % baseValue - baseValue / 2;
136  }
137 }
138 
139 // set the BxInEvent value in a 64-bits word, having the index iWord
140 // in the GTFE raw record
142  if (iWord == BxInEventWord) {
143  int baseValue = 16; // using hexadecimal values;
144  int hexBxInEvent = (m_bxInEvent + baseValue) % baseValue;
145  word64 = word64 | (static_cast<cms_uint64_t>(hexBxInEvent) << BxInEventShift);
146  }
147 }
148 
149 // set the BxNr value from a 64-bits word, having the index iWord in the GTFE raw record
150 void L1GtPsbWord::setBxNr(const cms_uint64_t& word64, int iWord) {
151  if (iWord == BxNrWord) {
152  m_bxNr = (word64 & BxNrMask) >> BxNrShift;
153  }
154 }
155 
156 // set the BxNr value in a 64-bits word, having the index iWord
157 // in the GTFE raw record
158 void L1GtPsbWord::setBxNrWord64(cms_uint64_t& word64, int iWord) {
159  if (iWord == BxNrWord) {
160  word64 = word64 | (static_cast<cms_uint64_t>(m_bxNr) << BxNrShift);
161  }
162 }
163 
164 // set the EventNr value from a 64-bits word, having the index iWord in the GTFE raw record
165 void L1GtPsbWord::setEventNr(const cms_uint64_t& word64, int iWord) {
166  if (iWord == EventNrWord) {
167  m_eventNr = (word64 & EventNrMask) >> EventNrShift;
168  }
169 }
170 
171 // set the EventNr value in a 64-bits word, having the index iWord
172 // in the GTFE raw record
173 void L1GtPsbWord::setEventNrWord64(cms_uint64_t& word64, int iWord) {
174  if (iWord == EventNrWord) {
175  word64 = word64 | (static_cast<cms_uint64_t>(m_eventNr) << EventNrShift);
176  }
177 }
178 
179 // get/set A_DATA_CH_IA
180 
181 const cms_uint16_t L1GtPsbWord::aData(int iA) const {
182  if (iA < 0 || iA > NumberAData) {
183  throw cms::Exception("aDataIndexError")
184  << "\nError: index for A_DATA array out of range. Allowed range: [0, " << NumberAData << ") " << std::endl;
185 
186  } else {
187  return m_aData[iA];
188  }
189 }
190 
191 void L1GtPsbWord::setAData(cms_uint16_t aDataVal, int iA) {
192  if (iA < 0 || iA > NumberAData) {
193  throw cms::Exception("aDataIndexError")
194  << "\nError: index for A_DATA array out of range. Allowed range: [0, " << NumberAData << ") " << std::endl;
195 
196  } else {
197  m_aData[iA] = aDataVal;
198  }
199 }
200 
201 // set the AData value from a 64-bits word, having the index iWord
202 // in the GTFE raw record
203 void L1GtPsbWord::setAData(const cms_uint64_t& word64, int iWord) {
204  int sizeW64 = sizeof(word64) * 8;
205  int nSubWords = sizeW64 / DataCHSize;
206 
207  if (iWord == ADataCH0Word) {
208  for (int i = 0; i < nSubWords; ++i) {
209  int dataShift = i * DataCHSize;
210  m_aData[i] = (word64 & (DataCHMask << dataShift)) >> dataShift;
211 
212  // LogTrace("L1GtPsbWord")
213  // << "\n A_Data_CH" << i << " = "
214  // << m_aData[i]
215  // << std::endl;
216  }
217 
218  } else if (iWord == ADataCH4Word) {
219  for (int i = 0; i < nSubWords; ++i) {
220  int dataShift = i * DataCHSize;
221  m_aData[i + nSubWords] = (word64 & (DataCHMask << dataShift)) >> dataShift;
222 
223  // LogTrace("L1GtPsbWord")
224  // << "\n A_Data_CH" << i + nSubWords << " = "
225  // << m_aData[i]
226  // << std::endl;
227  }
228  }
229 }
230 
231 // set the AData value in a 64-bits word, having the index iWord
232 // in the GTFE raw record
233 void L1GtPsbWord::setADataWord64(cms_uint64_t& word64, int iWord) {
234  int sizeW64 = sizeof(word64) * 8;
235  int nSubWords = sizeW64 / DataCHSize;
236 
237  if (iWord == ADataCH0Word) {
238  for (int i = 0; i < nSubWords; ++i) {
239  int dataShift = i * DataCHSize;
240  word64 = word64 | (static_cast<cms_uint64_t>(m_aData[i]) << dataShift);
241  }
242 
243  } else if (iWord == ADataCH4Word) {
244  for (int i = 0; i < nSubWords; ++i) {
245  int dataShift = i * DataCHSize;
246  word64 = word64 | (static_cast<cms_uint64_t>(m_aData[i + nSubWords]) << dataShift);
247  }
248  }
249 }
250 
251 // get/set B_DATA_CH_IB
252 
253 const cms_uint16_t L1GtPsbWord::bData(int iB) const {
254  if (iB < 0 || iB > NumberBData) {
255  throw cms::Exception("bDataIndexError")
256  << "\nError: index for B_DATA array out of range. Allowed range: [0, " << NumberBData << ") " << std::endl;
257 
258  } else {
259  return m_bData[iB];
260  }
261 }
262 
263 void L1GtPsbWord::setBData(cms_uint16_t bDataVal, int iB) {
264  if (iB < 0 || iB > NumberBData) {
265  throw cms::Exception("bDataIndexError")
266  << "\nError: index for B_DATA array out of range. Allowed range: [0, " << NumberBData << ") " << std::endl;
267 
268  } else {
269  m_bData[iB] = bDataVal;
270  }
271 }
272 
273 // set the BData value from a 64-bits word, having the index iWord
274 // in the GTFE raw record
275 void L1GtPsbWord::setBData(const cms_uint64_t& word64, int iWord) {
276  int sizeW64 = sizeof(word64) * 8;
277  int nSubWords = sizeW64 / DataCHSize;
278 
279  if (iWord == BDataCH0Word) {
280  for (int i = 0; i < nSubWords; ++i) {
281  int dataShift = i * DataCHSize;
282  m_bData[i] = (word64 & (DataCHMask << dataShift)) >> dataShift;
283  }
284 
285  } else if (iWord == BDataCH4Word) {
286  for (int i = 0; i < nSubWords; ++i) {
287  int dataShift = i * DataCHSize;
288  m_bData[i + nSubWords] = (word64 & (DataCHMask << dataShift)) >> dataShift;
289  }
290  }
291 }
292 
293 // set the BData value in a 64-bits word, having the index iWord
294 // in the GTFE raw record
295 void L1GtPsbWord::setBDataWord64(cms_uint64_t& word64, int iWord) {
296  int sizeW64 = sizeof(word64) * 8;
297  int nSubWords = sizeW64 / DataCHSize;
298 
299  if (iWord == BDataCH0Word) {
300  for (int i = 0; i < nSubWords; ++i) {
301  int dataShift = i * DataCHSize;
302  word64 = word64 | (static_cast<cms_uint64_t>(m_bData[i]) << dataShift);
303  }
304 
305  } else if (iWord == BDataCH4Word) {
306  for (int i = 0; i < nSubWords; ++i) {
307  int dataShift = i * DataCHSize;
308  word64 = word64 | (static_cast<cms_uint64_t>(m_bData[i + nSubWords]) << dataShift);
309  }
310  }
311 }
312 
313 // set the LocalBxNr value from a 64-bits word,
314 // having the index iWord in the GTFE raw record
315 void L1GtPsbWord::setLocalBxNr(const cms_uint64_t& word64, int iWord) {
316  if (iWord == LocalBxNrWord) {
317  m_localBxNr = (word64 & LocalBxNrMask) >> LocalBxNrShift;
318  }
319 }
320 
321 // set the LocalBxNr value in a 64-bits word, having the index iWord
322 // in the GTFE raw record
324  if (iWord == LocalBxNrWord) {
325  word64 = word64 | (static_cast<cms_uint64_t>(m_localBxNr) << LocalBxNrShift);
326  }
327 }
328 
329 // reset the content of a L1GtPsbWord
331  m_boardId = 0;
332  m_bxInEvent = 0;
333  m_bxNr = 0;
334  m_eventNr = 0;
335 
336  for (int iA = 0; iA < NumberAData; ++iA) {
337  m_aData[iA] = 0;
338  }
339 
340  for (int iB = 0; iB < NumberBData; ++iB) {
341  m_bData[iB] = 0;
342  }
343 
344  m_localBxNr = 0;
345 }
346 
347 // pretty print
348 void L1GtPsbWord::print(std::ostream& myCout) const {
349  myCout << "\n L1GtPsbWord::print \n" << std::endl;
350 
351  myCout << " Board Id: " << std::hex << " hex: " << std::setw(4) << std::setfill('0') << m_boardId
352  << std::setfill(' ') << std::dec << " dec: " << m_boardId << std::endl;
353 
354  int baseValue = 16; // using hexadecimal values;
355  int hexBxInEvent = (m_bxInEvent + baseValue) % baseValue;
356 
357  myCout << " BxInEvent: " << std::hex << " hex: "
358  << " " << std::setw(1) << hexBxInEvent << std::dec << " dec: " << m_bxInEvent << std::endl;
359 
360  myCout << " BxNr: " << std::hex << " hex: "
361  << " " << std::setw(3) << std::setfill('0') << m_bxNr << std::setfill(' ') << std::dec << " dec: " << m_bxNr
362  << std::endl;
363 
364  myCout << " EventNr: " << std::hex << " hex: "
365  << " " << std::setw(6) << std::setfill('0') << m_eventNr << std::setfill(' ') << std::dec
366  << " dec: " << m_eventNr << std::endl;
367 
368  int sizeW64 = 64;
369  int dataBlocksPerLine = sizeW64 / DataCHSize; // 4x16 bits per line
370 
371  myCout << "\n "
372  << "A_Data_CH3 "
373  << "A_Data_CH2 "
374  << "A_Data_CH1 "
375  << "A_Data_CH0 "
376  << "\n"
377  << std::hex << " hex: " << std::setfill('0');
378 
379  for (int i = 0; i < dataBlocksPerLine; ++i) {
380  int iCh = dataBlocksPerLine - (i + 1); // reverse
381  myCout << std::setw(4) << m_aData[iCh] << " ";
382  }
383 
384  myCout << "\n" << std::dec << " dec: ";
385 
386  for (int i = 0; i < dataBlocksPerLine; ++i) {
387  int iCh = dataBlocksPerLine - (i + 1); // reverse
388  myCout << std::setw(5) << m_aData[iCh] << " ";
389  }
390 
391  myCout << "\n\n "
392  << "A_Data_CH7 "
393  << "A_Data_CH6 "
394  << "A_Data_CH5 "
395  << "A_Data_CH4 "
396  << "\n"
397  << std::hex << " hex: " << std::setfill('0');
398 
399  for (int i = 0; i < dataBlocksPerLine; ++i) {
400  int iCh = dataBlocksPerLine - (i + 1); // reverse
401  myCout << std::setw(4) << m_aData[iCh + dataBlocksPerLine] << " ";
402  }
403 
404  myCout << "\n" << std::dec << " dec: ";
405 
406  for (int i = 0; i < dataBlocksPerLine; ++i) {
407  int iCh = dataBlocksPerLine - (i + 1); // reverse
408  myCout << std::setw(5) << m_aData[iCh + dataBlocksPerLine] << " ";
409  }
410 
411  myCout << std::endl;
412 
413  myCout << "\n "
414  << "B_Data_CH3 "
415  << "B_Data_CH2 "
416  << "B_Data_CH1 "
417  << "B_Data_CH0 "
418  << "\n"
419  << std::hex << " hex: " << std::setfill('0');
420 
421  for (int i = 0; i < dataBlocksPerLine; ++i) {
422  int iCh = dataBlocksPerLine - (i + 1); // reverse
423  myCout << std::setw(4) << m_bData[iCh] << " ";
424  }
425 
426  myCout << "\n" << std::dec << " dec: ";
427 
428  for (int i = 0; i < dataBlocksPerLine; ++i) {
429  int iCh = dataBlocksPerLine - (i + 1); // reverse
430  myCout << std::setw(5) << m_bData[iCh] << " ";
431  }
432 
433  myCout << "\n\n "
434  << "B_Data_CH7 "
435  << "B_Data_CH6 "
436  << "B_Data_CH5 "
437  << "B_Data_CH4 "
438  << "\n"
439  << std::hex << " hex: " << std::setfill('0');
440 
441  for (int i = 0; i < dataBlocksPerLine; ++i) {
442  int iCh = dataBlocksPerLine - (i + 1); // reverse
443  myCout << std::setw(4) << m_bData[iCh + dataBlocksPerLine] << " ";
444  }
445 
446  myCout << "\n" << std::dec << " dec: ";
447 
448  for (int i = 0; i < dataBlocksPerLine; ++i) {
449  int iCh = dataBlocksPerLine - (i + 1); // reverse
450  myCout << std::setw(5) << m_bData[iCh + dataBlocksPerLine] << " ";
451  }
452 
453  myCout << "\n" << std::endl;
454 
455  myCout << " LocalBxNr: " << std::hex << " hex: "
456  << " " << std::setw(3) << std::setfill('0') << m_localBxNr << std::setfill(' ') << std::dec
457  << " dec: " << m_localBxNr << std::endl;
458 }
459 
460 // static class members
461 const int L1GtPsbWord::NumberAData;
462 const int L1GtPsbWord::NumberBData;
static const int LocalBxNrWord
Definition: L1GtPsbWord.h:203
static const int BoardIdShift
Definition: L1GtPsbWord.h:181
void setEventNrWord64(cms_uint64_t &word64, int iWord)
Definition: L1GtPsbWord.cc:173
void reset()
reset the content of a L1GtPsbWord
Definition: L1GtPsbWord.cc:330
static const int BDataCH0Word
Definition: L1GtPsbWord.h:197
const cms_uint16_t aData(int iA) const
get/set A_DATA_CH_IA
Definition: L1GtPsbWord.cc:181
static const cms_uint64_t BoardIdMask
Definition: L1GtPsbWord.h:175
cms_uint16_t m_localBxNr
Definition: L1GtPsbWord.h:223
static const int EventNrWord
Definition: L1GtPsbWord.h:172
void setBData(cms_uint16_t bDataVal, int iB)
Definition: L1GtPsbWord.cc:263
static const cms_uint64_t LocalBxNrMask
Definition: L1GtPsbWord.h:204
void setBxNrWord64(cms_uint64_t &word64, int iWord)
Definition: L1GtPsbWord.cc:158
static const int BoardIdWord
Definition: L1GtPsbWord.h:169
bool operator!=(const L1GtPsbWord &) const
unequal operator
Definition: L1GtPsbWord.cc:109
static const cms_uint64_t BxInEventMask
Definition: L1GtPsbWord.h:176
const cms_uint16_t bData(int iB) const
get/set B_DATA_CH_IB
Definition: L1GtPsbWord.cc:253
cms_uint16_t m_bData[NumberBData]
Definition: L1GtPsbWord.h:221
static const int BxInEventShift
Definition: L1GtPsbWord.h:182
void setBxInEventWord64(cms_uint64_t &word64, int iWord)
Definition: L1GtPsbWord.cc:141
void setEventNr(cms_uint32_t eventNrValue)
Definition: L1GtPsbWord.h:99
static const int DataCHSize
Definition: L1GtPsbWord.h:187
void setBxNr(cms_uint16_t bxNrValue)
Definition: L1GtPsbWord.h:86
void setADataWord64(cms_uint64_t &word64, int iWord)
Definition: L1GtPsbWord.cc:233
void print(std::ostream &myCout) const
pretty print
Definition: L1GtPsbWord.cc:348
void setBoardId(cms_uint16_t boardIdValue)
Definition: L1GtPsbWord.h:60
cms_uint32_t m_eventNr
Definition: L1GtPsbWord.h:217
void setLocalBxNrWord64(cms_uint64_t &word64, int iWord)
Definition: L1GtPsbWord.cc:323
bool operator==(const L1GtPsbWord &) const
equal operator
Definition: L1GtPsbWord.cc:74
void setBxInEvent(int bxInEventValue)
Definition: L1GtPsbWord.h:73
virtual ~L1GtPsbWord()
destructor
Definition: L1GtPsbWord.cc:69
unsigned short cms_uint16_t
Definition: typedefs.h:13
cms_uint16_t m_bxNr
Definition: L1GtPsbWord.h:216
void setBDataWord64(cms_uint64_t &word64, int iWord)
Definition: L1GtPsbWord.cc:295
unsigned int cms_uint32_t
Definition: typedefs.h:15
L1GtPsbWord()
constructors
Definition: L1GtPsbWord.cc:27
static const int LocalBxNrShift
Definition: L1GtPsbWord.h:205
static const int BxInEventWord
Definition: L1GtPsbWord.h:170
static const int NumberBData
Definition: L1GtPsbWord.h:32
static const cms_uint64_t EventNrMask
Definition: L1GtPsbWord.h:178
static const int ADataCH0Word
Definition: L1GtPsbWord.h:191
static const int EventNrShift
Definition: L1GtPsbWord.h:184
static const int BDataCH4Word
Definition: L1GtPsbWord.h:200
static const int BxNrWord
Definition: L1GtPsbWord.h:171
static const int NumberAData
Definition: L1GtPsbWord.h:31
void setLocalBxNr(cms_uint16_t localBxNrValue)
Definition: L1GtPsbWord.h:136
static const cms_uint64_t BxNrMask
Definition: L1GtPsbWord.h:177
unsigned long long cms_uint64_t
Definition: typedefs.h:17
cms_uint16_t m_boardId
Definition: L1GtPsbWord.h:210
cms_uint16_t m_aData[NumberAData]
Definition: L1GtPsbWord.h:219
void setAData(cms_uint16_t aDataVal, int iA)
Definition: L1GtPsbWord.cc:191
void setBoardIdWord64(cms_uint64_t &word64, int iWord)
Definition: L1GtPsbWord.cc:123
static const int ADataCH4Word
Definition: L1GtPsbWord.h:194
static const int BxNrShift
Definition: L1GtPsbWord.h:183