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