CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
L1GtfeWord.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
24 
27 
28 // constructors
29 
30 // empty constructor, all members set to zero;
32  m_boardId(0), m_recordLength1(0), m_recordLength(0), m_bxNr(0), m_setupVersion(0),
33  m_activeBoards(0), m_altNrBxBoard(0), m_totalTriggerNr(0) {
34 
35  // empty
36 
37 }
38 
39 // constructor from unpacked values;
41  cms_uint16_t boardIdValue, cms_uint16_t recordLength1Value,
42  cms_uint16_t recordLengthValue, cms_uint16_t bxNrValue,
43  cms_uint32_t setupVersionValue, cms_uint16_t activeBoardsValue,
44  cms_uint16_t altNrBxBoardValue, cms_uint32_t totalTriggerNrValue) :
45  m_boardId(boardIdValue), m_recordLength1(recordLength1Value),
46  m_recordLength(recordLengthValue), m_bxNr(bxNrValue),
47  m_setupVersion(setupVersionValue), m_activeBoards(activeBoardsValue), m_altNrBxBoard(
48  altNrBxBoardValue), m_totalTriggerNr(totalTriggerNrValue)
49 
50 {
51 
52  // empty
53 }
54 
55 // destructor
57 {
58 
59  // empty now
60 
61 }
62 
63 // equal operator
65 {
66 
67  if(m_boardId != result.m_boardId) {
68  return false;
69  }
70 
71  if(m_recordLength1 != result.m_recordLength1) {
72  return false;
73  }
74 
75  if(m_recordLength != result.m_recordLength) {
76  return false;
77  }
78 
79  if(m_bxNr != result.m_bxNr) {
80  return false;
81  }
82 
83  if(m_setupVersion != result.m_setupVersion) {
84  return false;
85  }
86 
87  if(m_activeBoards != result.m_activeBoards) {
88  return false;
89  }
90 
91  if(m_altNrBxBoard != result.m_altNrBxBoard) {
92  return false;
93  }
94 
95  if(m_totalTriggerNr != result.m_totalTriggerNr) {
96  return false;
97  }
98 
99  // all members identical
100  return true;
101 
102 }
103 
104 // unequal operator
106 {
107 
108  return !( result == *this);
109 
110 }
111 
112 // methods
113 
114 // set the BoardId value from a 64-bits word
116 {
117  m_boardId = (word64 & BoardIdMask) >> BoardIdShift;
118 }
119 
120 // set the BoardId value in a 64-bits word, having the index iWord
121 // in the GTFE raw record
123 {
124 
125  if (iWord == BoardIdWord) {
126  word64 = word64 | (static_cast<cms_uint64_t> (m_boardId) << BoardIdShift);
127  }
128 
129 }
130 
131 
132 // set the RecordLength1 value from a 64-bits word
134 {
136 }
137 
138 // set the RecordLength1 value in a 64-bits word, having the index iWord
139 // in the GTFE raw record
141 {
142 
143  if (iWord == RecordLength1Word) {
144  word64 = word64 |
145  (static_cast<cms_uint64_t> (m_recordLength1) << RecordLength1Shift);
146  }
147 
148 }
149 
150 
151 // set the RecordLength value from a 64-bits word
153 {
155 }
156 
157 // set the RecordLength value in a 64-bits word, having the index iWord
158 // in the GTFE raw record
160 {
161 
162  if (iWord == RecordLengthWord) {
163  word64 = word64 |
164  (static_cast<cms_uint64_t> (m_recordLength) << RecordLengthShift);
165  }
166 
167 }
168 
169 
170 // set the BxNr value from a 64-bits word
172 {
173  m_bxNr = (word64 & BxNrMask) >> BxNrShift;
174 }
175 
176 // set the BxNr value in a 64-bits word, having the index iWord
177 // in the GTFE raw record
178 void L1GtfeWord::setBxNrWord64(cms_uint64_t& word64, int iWord)
179 {
180 
181  if (iWord == BxNrWord) {
182  word64 = word64 | (static_cast<cms_uint64_t> (m_bxNr) << BxNrShift);
183  }
184 
185 }
186 
187 
188 // set the SetupVersion value from a 64-bits word
190 {
192 }
193 
194 // set the SetupVersion value in a 64-bits word, having the index iWord
195 // in the GTFE raw record
197 {
198 
199  if (iWord == SetupVersionWord) {
200  word64 = word64 |
201  (static_cast<cms_uint64_t> (m_setupVersion) << SetupVersionShift);
202  }
203 
204 }
205 
206 
207 // get / set BST flag: 0 or 1 - via setup version (no private member)
208 const int L1GtfeWord::bstFlag() const {
209 
210  int bstFlagValue = 0;
211  bstFlagValue = static_cast<int> (m_setupVersion & BstFlagMask);
212 
213  return bstFlagValue;
214 
215 }
216 
217 void L1GtfeWord::setBstFlag(const int bstFlagValue) {
218 
219  m_setupVersion = m_setupVersion | ( static_cast<cms_uint32_t> (bstFlagValue) & BstFlagMask );
220 
221 }
222 
223 
224 
225 // set the ActiveBoards value from a 64-bits word
227 {
229 }
230 
231 // set the ActiveBoards value in a 64-bits word, having the index iWord
232 // in the GTFE raw record
234 {
235 
236  if (iWord == ActiveBoardsWord) {
237  word64 = word64 |
238  (static_cast<cms_uint64_t> (m_activeBoards) << ActiveBoardsShift);
239  }
240 
241 }
242 
243 // set the ActiveBoards value in a 64-bits word, having the index iWord
244 // in the GTFE raw record from the value activeBoardsValue
246  cms_int16_t activeBoardsValue)
247 {
248  if (iWord == ActiveBoardsWord) {
249  word64 = word64 |
250  (static_cast<cms_uint64_t> (activeBoardsValue) << ActiveBoardsShift);
251  }
252 
253 }
254 
255 
256 
257 // set the AltNrBxBoard value from a 64-bits word
259 {
261 }
262 
263 // set the AltNrBxBoard value in a 64-bits word, having the index iWord
264 // in the GTFE raw record
266 {
267 
268  if (iWord == AltNrBxBoardWord) {
269  word64 = word64 |
270  (static_cast<cms_uint64_t> (m_altNrBxBoard) << AltNrBxBoardShift);
271  }
272 
273 }
274 
275 // set the AltNrBxBoard value in a 64-bits word, having the index iWord
276 // in the GTFE raw record from the value altNrBxBoardValue
278  cms_int16_t altNrBxBoardValue)
279 {
280  if (iWord == AltNrBxBoardWord) {
281  word64 = word64 |
282  (static_cast<cms_uint64_t> (altNrBxBoardValue) << AltNrBxBoardShift);
283  }
284 
285 }
286 
287 // set the TotalTriggerNr value from a 64-bits word
289 {
291 }
292 
293 // set the TotalTriggerNr value in a 64-bits word, having the index iWord
294 // in the GTFE raw record
296 {
297 
298  if (iWord == TotalTriggerNrWord) {
299  word64 = word64 |
301  }
302 
303 }
304 
305 
306 
307 // reset the content of a L1GtfeWord
309 {
310 
311  m_boardId = 0;
312  m_recordLength1 = 0;
313  m_recordLength = 0;
314  m_bxNr = 0;
315  m_setupVersion = 0;
316  //
317  m_activeBoards = 0;
318  m_altNrBxBoard = 0;
319  m_totalTriggerNr = 0;
320 }
321 
322 // pretty print the content of a L1GtfeWord
323 void L1GtfeWord::print(std::ostream& myCout) const
324 {
325 
326  myCout << "\n L1GtfeWord::print \n" << std::endl;
327 
328  myCout << " BoardId: "
329  << std::hex << " hex: " << " " << std::setw(2) << std::setfill('0') << m_boardId
330  << std::setfill(' ')
331  << std::dec << " dec: " << m_boardId
332  << std::endl;
333 
334  myCout << " BX for alternative 1: "
335  << std::hex << " hex: " << " " << std::setw(1) << m_recordLength1
336  << std::dec << " dec: " << m_recordLength1
337  << std::endl;
338 
339  myCout << " BX for alternative 0: "
340  << std::hex << " hex: " << " " << std::setw(1) << m_recordLength
341  << std::dec << " dec: " << m_recordLength
342  << std::endl;
343 
344  myCout << " BxNr: "
345  << std::hex << " hex: " << " " << std::setw(3) << std::setfill('0') << m_bxNr
346  << std::setfill(' ')
347  << std::dec << " dec: " << m_bxNr
348  << std::endl;
349 
350  myCout << " SetupVersion: "
351  << std::hex << " hex: " << std::setw(8) << std::setfill('0') << m_setupVersion
352  << std::setfill(' ')
353  << std::dec << " dec: " << m_setupVersion
354  << std::endl;
355 
356  //
357 
358  myCout << " ActiveBoards: "
359  << std::hex << " hex: " << " " << std::setw(4) << std::setfill('0') << m_activeBoards
360  << std::setfill(' ')
361  << std::dec << " dec: " << m_activeBoards
362  << std::endl;
363 
364  myCout << " AltNrBxBoard: "
365  << std::hex << " hex: " << " " << std::setw(4) << std::setfill('0') << m_altNrBxBoard
366  << std::setfill(' ')
367  << std::dec << " dec: " << m_altNrBxBoard
368  << std::endl;
369 
370  myCout << " TotalTriggerNr: "
371  << std::hex << " hex: " << std::setw(8) << std::setfill('0') << m_totalTriggerNr
372  << std::setfill(' ')
373  << std::dec << " dec: " << m_totalTriggerNr
374  << std::endl;
375 
376 
377 }
378 
379 // unpack GTFE
380 // gtfePtr pointer to the beginning of the GTFE block in the raw data
381 
382 void L1GtfeWord::unpack(const unsigned char* gtfePtr)
383 {
384  LogDebug("L1GtfeWord")
385  << "\nUnpacking GTFE block.\n"
386  << std::endl;
387 
388  const cms_uint64_t* payload =
389  reinterpret_cast<cms_uint64_t*>(const_cast<unsigned char*>(gtfePtr));
390 
391  setBoardId(payload[BoardIdWord]);
394  setBxNr(payload[BxNrWord]);
399 
400 
401  if ( edm::isDebugEnabled() ) {
402 
403  for (int iWord = 0; iWord < BlockSize; ++iWord) {
404  LogTrace("L1GtfeWord")
405  << std::setw(4) << iWord << " "
406  << std::hex << std::setfill('0')
407  << std::setw(16) << payload[iWord]
408  << std::dec << std::setfill(' ')
409  << std::endl;
410  }
411 
412  }
413 
414 }
415 
416 // static class members
417 
418 // block description in the raw GT record
419 
420 // block size in 64bits words
421 const int L1GtfeWord::BlockSize = 2; // 2 x 64bits
422 
423 const int L1GtfeWord::BoardIdWord = 0;
424 const int L1GtfeWord::RecordLength1Word = 0;
425 const int L1GtfeWord::RecordLengthWord = 0;
426 const int L1GtfeWord::BxNrWord = 0;
427 const int L1GtfeWord::SetupVersionWord = 0;
428 
429 const cms_uint64_t L1GtfeWord::BoardIdMask = 0xFF00000000000000ULL;
430 const cms_uint64_t L1GtfeWord::RecordLength1Mask = 0x00F0000000000000ULL;
431 const cms_uint64_t L1GtfeWord::RecordLengthMask = 0x000F000000000000ULL;
432 const cms_uint64_t L1GtfeWord::BxNrMask = 0x00000FFF00000000ULL;
433 const cms_uint64_t L1GtfeWord::SetupVersionMask = 0x00000000FFFFFFFFULL;
434 
436 
437 // shifts could be computed from masks...
438 const int L1GtfeWord::BoardIdShift = 56;
439 const int L1GtfeWord::RecordLength1Shift = 52;
440 const int L1GtfeWord::RecordLengthShift = 48;
441 const int L1GtfeWord::BxNrShift = 32;
442 const int L1GtfeWord::SetupVersionShift = 0;
443 
444 //
445 const int L1GtfeWord::ActiveBoardsWord = 1;
446 const int L1GtfeWord::AltNrBxBoardWord = 1;
447 const int L1GtfeWord::TotalTriggerNrWord = 1;
448 
449 const cms_uint64_t L1GtfeWord::ActiveBoardsMask = 0xFFFF000000000000ULL;
450 const cms_uint64_t L1GtfeWord::AltNrBxBoardMask = 0x0000FFFF00000000ULL;
451 const cms_uint64_t L1GtfeWord::TotalTriggerNrMask = 0x00000000FFFFFFFFULL;
452 
453 const int L1GtfeWord::ActiveBoardsShift = 48;
454 const int L1GtfeWord::AltNrBxBoardShift = 32;
455 const int L1GtfeWord::TotalTriggerNrShift = 0;
456 
457 
#define LogDebug(id)
short cms_int16_t
Definition: typedefs.h:12
bool operator==(const L1GtfeWord &) const
equal operator
Definition: L1GtfeWord.cc:64
bool isDebugEnabled()
bool operator!=(const L1GtfeWord &) const
unequal operator
Definition: L1GtfeWord.cc:105
void setRecordLength1Word64(cms_uint64_t &word64, int iWord)
Definition: L1GtfeWord.cc:140
void setBxNr(cms_uint16_t bxNrValue)
Definition: L1GtfeWord.h:129
static const cms_uint64_t TotalTriggerNrMask
Definition: L1GtfeWord.h:285
static const cms_uint64_t BoardIdMask
Definition: L1GtfeWord.h:263
virtual void print(std::ostream &myCout) const
pretty print the content of a L1GtfeWord
Definition: L1GtfeWord.cc:323
static const int RecordLength1Shift
Definition: L1GtfeWord.h:273
static const int ActiveBoardsWord
Definition: L1GtfeWord.h:279
static const int BlockSize
Definition: L1GtfeWord.h:255
void setActiveBoardsWord64(cms_uint64_t &word64, int iWord)
Definition: L1GtfeWord.cc:233
void setRecordLength(cms_uint16_t recordLengthValue)
Definition: L1GtfeWord.h:111
static const cms_uint64_t SetupVersionMask
Definition: L1GtfeWord.h:267
cms_uint16_t m_recordLength
record length for alternative 0
Definition: L1GtfeWord.h:301
void setSetupVersionWord64(cms_uint64_t &word64, int iWord)
Definition: L1GtfeWord.cc:196
cms_uint16_t m_boardId
board identifier
Definition: L1GtfeWord.h:295
void setAltNrBxBoard(cms_uint16_t altNrBxBoardValue)
Definition: L1GtfeWord.h:194
L1GtfeWord()
constructors
Definition: L1GtfeWord.cc:31
void setTotalTriggerNr(cms_uint32_t totalTriggerNrValue)
Definition: L1GtfeWord.h:218
virtual void reset()
reset the content of a L1GtfeWord
Definition: L1GtfeWord.cc:308
static const cms_uint64_t RecordLength1Mask
Definition: L1GtfeWord.h:264
static const cms_uint64_t RecordLengthMask
Definition: L1GtfeWord.h:265
static const int TotalTriggerNrWord
Definition: L1GtfeWord.h:281
static const cms_uint64_t AltNrBxBoardMask
Definition: L1GtfeWord.h:284
tuple result
Definition: query.py:137
static const int SetupVersionWord
Definition: L1GtfeWord.h:261
unsigned short cms_uint16_t
Definition: typedefs.h:13
static const int SetupVersionShift
Definition: L1GtfeWord.h:276
void setRecordLength1(cms_uint16_t recordLengthValue)
Definition: L1GtfeWord.h:92
void setBoardIdWord64(cms_uint64_t &word64, int iWord)
Definition: L1GtfeWord.cc:122
static const int RecordLengthShift
Definition: L1GtfeWord.h:274
unsigned int cms_uint32_t
Definition: typedefs.h:15
#define LogTrace(id)
cms_uint16_t m_activeBoards
active boards contributing to EVM respectively DAQ record
Definition: L1GtfeWord.h:308
void setBoardId(cms_uint16_t boardIdValue)
set BoardId from a BoardId value
Definition: L1GtfeWord.h:73
static const int TotalTriggerNrShift
Definition: L1GtfeWord.h:289
static const int RecordLength1Word
Definition: L1GtfeWord.h:258
static const int ActiveBoardsShift
Definition: L1GtfeWord.h:287
void setAltNrBxBoardWord64(cms_uint64_t &word64, int iWord)
Definition: L1GtfeWord.cc:265
void setActiveBoards(cms_uint16_t activeBoardsValue)
Definition: L1GtfeWord.h:170
const int bstFlag() const
get / set BST flag: 0 or 1 - via setup version (no private member)
Definition: L1GtfeWord.cc:208
static const cms_uint64_t ActiveBoardsMask
Definition: L1GtfeWord.h:283
cms_uint16_t m_bxNr
bunch cross number as counted in the GTFE board
Definition: L1GtfeWord.h:304
static const cms_uint64_t BxNrMask
Definition: L1GtfeWord.h:266
static const int RecordLengthWord
Definition: L1GtfeWord.h:259
static const int BxNrShift
Definition: L1GtfeWord.h:275
cms_uint16_t m_altNrBxBoard
Definition: L1GtfeWord.h:314
void setBxNrWord64(cms_uint64_t &word64, int iWord)
Definition: L1GtfeWord.cc:178
static const int BoardIdWord
Definition: L1GtfeWord.h:257
unsigned long long cms_uint64_t
Definition: typedefs.h:17
void setTotalTriggerNrWord64(cms_uint64_t &word64, int iWord)
Definition: L1GtfeWord.cc:295
static const int AltNrBxBoardShift
Definition: L1GtfeWord.h:288
cms_uint32_t m_totalTriggerNr
total number of L1A sent since start of run
Definition: L1GtfeWord.h:317
cms_uint32_t m_setupVersion
Definition: L1GtfeWord.h:305
void setSetupVersion(cms_uint32_t setupVersionValue)
Definition: L1GtfeWord.h:147
static const int BxNrWord
Definition: L1GtfeWord.h:260
static const int BoardIdShift
Definition: L1GtfeWord.h:272
void setBstFlag(const int)
Definition: L1GtfeWord.cc:217
static const int AltNrBxBoardWord
Definition: L1GtfeWord.h:280
cms_uint16_t m_recordLength1
record length for alternative 1
Definition: L1GtfeWord.h:298
virtual void unpack(const unsigned char *gtfePtr)
Definition: L1GtfeWord.cc:382
void setRecordLengthWord64(cms_uint64_t &word64, int iWord)
Definition: L1GtfeWord.cc:159
static const cms_uint32_t BstFlagMask
Definition: L1GtfeWord.h:269
virtual ~L1GtfeWord()
destructor
Definition: L1GtfeWord.cc:56