CMS 3D CMS Logo

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