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