CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
L1TcsWord.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
24 
25 // forward declarations
26 
27 // constructors
28 
29 // empty constructor, all members set to zero;
31  m_boardId = 0;
32  m_bxNr = 0;
33  m_daqNr = 0;
34  m_triggerType = 0;
35  m_status = 0;
37  m_partRunNr = 0;
39  m_partTrigNr = 0;
40  m_eventNr = 0;
41  m_orbitNr = 0;
42 }
43 
44 // constructor from unpacked values;
46  cms_uint16_t bxNrValue,
47  cms_uint16_t daqNrValue,
48  cms_uint16_t triggerTypeValue,
49  cms_uint16_t statusValue,
50  cms_uint16_t luminositySegmentNrValue,
51  cms_uint32_t partRunNrValue,
52  cms_uint32_t assignedPartitionsValue,
53  cms_uint32_t partTrigNrValue,
54  cms_uint32_t eventNrValue,
55  cms_uint64_t orbitNrValue) {
56  m_boardId = boardIdValue;
57  m_bxNr = bxNrValue;
58  m_daqNr = daqNrValue;
59  m_triggerType = triggerTypeValue;
60  m_status = statusValue;
61  m_luminositySegmentNr = luminositySegmentNrValue;
62  m_partRunNr = partRunNrValue;
63  m_assignedPartitions = assignedPartitionsValue;
64  m_partTrigNr = partTrigNrValue;
65  m_eventNr = eventNrValue;
66  m_orbitNr = orbitNrValue;
67 }
68 
69 // destructor
71  // empty
72 }
73 
74 // equal operator
76  if (m_boardId != result.m_boardId) {
77  return false;
78  }
79 
80  if (m_bxNr != result.m_bxNr) {
81  return false;
82  }
83 
84  if (m_daqNr != result.m_daqNr) {
85  return false;
86  }
87 
88  if (m_triggerType != result.m_triggerType) {
89  return false;
90  }
91 
92  if (m_status != result.m_status) {
93  return false;
94  }
95 
97  return false;
98  }
99 
100  if (m_partRunNr != result.m_partRunNr) {
101  return false;
102  }
103 
105  return false;
106  }
107 
108  if (m_partTrigNr != result.m_partTrigNr) {
109  return false;
110  }
111 
112  if (m_eventNr != result.m_eventNr) {
113  return false;
114  }
115 
116  if (m_orbitNr != result.m_orbitNr) {
117  return false;
118  }
119 
120  // all members identical
121  return true;
122 }
123 
124 // unequal operator
125 bool L1TcsWord::operator!=(const L1TcsWord& result) const { return !(result == *this); }
126 
127 // methods
128 
129 // set the BoardId value from a 64-bits word
130 void L1TcsWord::setBoardId(const cms_uint64_t& word64) { m_boardId = (word64 & BoardIdMask) >> BoardIdShift; }
131 
132 // set the BoardId value in a 64-bits word, having the index iWord
133 // in the GTFE raw record
134 void L1TcsWord::setBoardIdWord64(cms_uint64_t& word64, int iWord) {
135  if (iWord == BoardIdWord) {
136  word64 = word64 | (static_cast<cms_uint64_t>(m_boardId) << BoardIdShift);
137  }
138 }
139 
140 // set the BxNr value from a 64-bits word
141 void L1TcsWord::setBxNr(const cms_uint64_t& word64) { m_bxNr = (word64 & BxNrMask) >> BxNrShift; }
142 
143 // set the BxNr value in a 64-bits word, having the index iWord
144 // in the GTFE EVM raw record
145 void L1TcsWord::setBxNrWord64(cms_uint64_t& word64, int iWord) {
146  if (iWord == BxNrWord) {
147  word64 = word64 | (static_cast<cms_uint64_t>(m_bxNr) << BxNrShift);
148  }
149 }
150 
151 // set the DaqNr value from a 64-bits word
152 void L1TcsWord::setDaqNr(const cms_uint64_t& word64) { m_daqNr = (word64 & DaqNrMask) >> DaqNrShift; }
153 
154 // set the DaqNr value in a 64-bits word, having the index iWord
155 // in the GTFE EVM raw record
156 void L1TcsWord::setDaqNrWord64(cms_uint64_t& word64, int iWord) {
157  if (iWord == DaqNrWord) {
158  word64 = word64 | (static_cast<cms_uint64_t>(m_daqNr) << DaqNrShift);
159  }
160 }
161 
162 // set the TriggerType value from a 64-bits word
165 }
166 
167 // set the TriggerType value in a 64-bits word, having the index iWord
168 // in the GTFE EVM raw record
170  if (iWord == TriggerTypeWord) {
171  word64 = word64 | (static_cast<cms_uint64_t>(m_triggerType) << TriggerTypeShift);
172  }
173 }
174 
175 // set the Status value from a 64-bits word
176 void L1TcsWord::setStatus(const cms_uint64_t& word64) { m_status = (word64 & StatusMask) >> StatusShift; }
177 
178 // set the Status value in a 64-bits word, having the index iWord
179 // in the GTFE EVM raw record
180 void L1TcsWord::setStatusWord64(cms_uint64_t& word64, int iWord) {
181  if (iWord == StatusWord) {
182  word64 = word64 | (static_cast<cms_uint64_t>(m_status) << StatusShift);
183  }
184 }
185 
186 // set the luminosity segment number value from a 64-bits word
189 }
190 
191 // set the luminosity segment number value in a 64-bits word, having the index iWord
192 // in the GTFE EVM raw record
194  if (iWord == LuminositySegmentNrWord) {
195  word64 = word64 | (static_cast<cms_uint64_t>(m_luminositySegmentNr) << LuminositySegmentNrShift);
196  }
197 }
198 
199 // set the PartRunNr value from a 64-bits word
201 
202 // set the PartRunNr value in a 64-bits word, having the index iWord
203 // in the GTFE EVM raw record
204 void L1TcsWord::setPartRunNrWord64(cms_uint64_t& word64, int iWord) {
205  if (iWord == PartRunNrWord) {
206  word64 = word64 | (static_cast<cms_uint64_t>(m_partRunNr) << PartRunNrShift);
207  }
208 }
209 
210 // set the AssignedPartitions value from a 64-bits word
213 }
214 
215 // set the AssignedPartitions value in a 64-bits word, having the index iWord
216 // in the GTFE EVM raw record
218  if (iWord == AssignedPartitionsWord) {
219  word64 = word64 | (static_cast<cms_uint64_t>(m_assignedPartitions) << AssignedPartitionsShift);
220  }
221 }
222 
223 // set the PartTrigNr value from a 64-bits word
226 }
227 
228 // set the PartTrigNr value in a 64-bits word, having the index iWord
229 // in the GTFE EVM raw record
231  if (iWord == PartTrigNrWord) {
232  word64 = word64 | (static_cast<cms_uint64_t>(m_partTrigNr) << PartTrigNrShift);
233  }
234 }
235 
236 // set the EventNr value from a 64-bits word
237 void L1TcsWord::setEventNr(const cms_uint64_t& word64) { m_eventNr = (word64 & EventNrMask) >> EventNrShift; }
238 
239 // set the EventNr value in a 64-bits word, having the index iWord
240 // in the GTFE EVM raw record
241 void L1TcsWord::setEventNrWord64(cms_uint64_t& word64, int iWord) {
242  if (iWord == EventNrWord) {
243  word64 = word64 | (static_cast<cms_uint64_t>(m_eventNr) << EventNrShift);
244  }
245 }
246 
247 // set the OrbitNr value from a 64-bits word
249 
250 // set the OrbitNr value in a 64-bits word, having the index iWord
251 // in the GTFE EVM raw record
252 void L1TcsWord::setOrbitNrWord64(cms_uint64_t& word64, int iWord) {
253  if (iWord == OrbitNrWord) {
254  word64 = word64 | (static_cast<cms_uint64_t>(m_orbitNr) << OrbitNrShift);
255  }
256 }
257 
258 // reset the content of a L1TcsWord
260  m_boardId = 0;
261  m_bxNr = 0;
262  m_daqNr = 0;
263  m_triggerType = 0;
264  m_status = 0;
266  m_partRunNr = 0;
268  m_partTrigNr = 0;
269  m_eventNr = 0;
270  m_orbitNr = 0;
271 }
272 
273 // pretty print
274 void L1TcsWord::print(std::ostream& myCout) const {
275  myCout << "\n L1TcsWord::print \n" << std::endl;
276 
277  int iWord = 0;
278 
279  myCout << "\n Word " << iWord << std::endl;
280 
281  myCout << " Board Id: " << std::hex << " hex: "
282  << " " << std::setw(4) << std::setfill('0') << m_boardId << std::setfill(' ') << std::dec
283  << " dec: " << m_boardId << std::endl;
284 
285  myCout << " BxNr: " << std::hex << " hex: "
286  << " " << std::setw(3) << std::setfill('0') << m_bxNr << std::setfill(' ') << std::dec
287  << " dec: " << m_bxNr << std::endl;
288 
289  myCout << " DaqNr: " << std::hex << " hex: "
290  << " " << std::setw(1) << m_daqNr << std::dec << " dec: " << m_daqNr << std::endl;
291 
292  myCout << " TriggerType: " << std::hex << " hex: "
293  << " " << std::setw(1) << m_triggerType << std::dec << " dec: " << m_triggerType << std::endl;
294 
295  myCout << " Status: " << std::hex << " hex: "
296  << " " << std::setw(1) << m_status << std::dec << " dec: " << m_status << std::endl;
297 
298  myCout << " LuminositySegmentNr: " << std::hex << " hex: "
299  << " " << std::setw(4) << m_luminositySegmentNr << std::dec << " dec: " << m_luminositySegmentNr
300  << std::endl;
301 
302  iWord++;
303  myCout << "\n Word " << iWord << std::endl;
304 
305  myCout << " PartRunNr: " << std::hex << " hex: "
306  << " " << std::setw(8) << std::setfill('0') << m_partRunNr << std::setfill(' ') << std::dec
307  << " dec: " << m_partRunNr << std::endl;
308 
309  myCout << " AssignedPartitions: " << std::hex << " hex: "
310  << " " << std::setw(8) << std::setfill('0') << m_assignedPartitions << std::setfill(' ') << std::dec
311  << " dec: " << m_assignedPartitions << std::endl;
312 
313  iWord++;
314  myCout << "\n Word " << iWord << std::endl;
315 
316  myCout << " PartTrigNr: " << std::hex << " hex: "
317  << " " << std::setw(8) << std::setfill('0') << m_partTrigNr << std::setfill(' ') << std::dec
318  << " dec: " << m_partTrigNr << std::endl;
319 
320  myCout << " EventNr: " << std::hex << " hex: "
321  << " " << std::setw(8) << std::setfill('0') << m_eventNr << std::setfill(' ') << std::dec
322  << " dec: " << m_eventNr << std::endl;
323 
324  iWord++;
325  myCout << "\n Word " << iWord << std::endl;
326 
327  myCout << " OrbitNr: " << std::hex << " hex: "
328  << "" << std::setw(12) << std::setfill('0') << m_orbitNr << std::setfill(' ') << std::dec
329  << " dec: " << m_orbitNr << std::endl;
330 
331  iWord++;
332  myCout << "\n Word " << iWord << std::endl;
333 
334  myCout << " Empty word " << std::endl;
335 }
336 
337 // unpack TCS
338 // tcsPtr pointer to the beginning of the TCS block in the raw data
339 void L1TcsWord::unpack(const unsigned char* tcsPtr) {
340  LogDebug("L1GtTcsWord") << "\nUnpacking TCS block.\n" << std::endl;
341 
342  const cms_uint64_t* payload = reinterpret_cast<cms_uint64_t const*>(tcsPtr);
343 
344  setBoardId(payload[BoardIdWord]);
345  setBxNr(payload[BxNrWord]);
346  setDaqNr(payload[DaqNrWord]);
348  setStatus(payload[StatusWord]);
350 
351  setPartRunNr(payload[PartRunNrWord]);
353 
354  setPartTrigNr(payload[PartTrigNrWord]);
355  setEventNr(payload[EventNrWord]);
356 
357  setOrbitNrFrom(payload[OrbitNrWord]);
358 
359  if (edm::isDebugEnabled()) {
360  for (int iWord = 0; iWord < BlockSize; ++iWord) {
361  LogTrace("L1GtTcsWord") << std::setw(4) << iWord << " " << std::hex << std::setfill('0') << std::setw(16)
362  << payload[iWord] << std::dec << std::setfill(' ') << std::endl;
363  }
364  }
365 }
366 
367 // static class members
368 
369 // block description in the raw GT record
370 
371 // block size in 64bits words (BlockSize * 64 bits)
372 const int L1TcsWord::BlockSize = 5;
373 
374 // word 0
375 
376 // index of the word in the TCS block containig the variable
377 const int L1TcsWord::BoardIdWord = 0;
378 const int L1TcsWord::BxNrWord = 0;
379 const int L1TcsWord::DaqNrWord = 0;
380 const int L1TcsWord::TriggerTypeWord = 0;
381 const int L1TcsWord::StatusWord = 0;
383 
384 // mask to get the 64-bit-value from the corresponding word in the TCS block
385 const cms_uint64_t L1TcsWord::BoardIdMask = 0xFFFF000000000000ULL;
386 const cms_uint64_t L1TcsWord::BxNrMask = 0x00000FFF00000000ULL;
387 const cms_uint64_t L1TcsWord::DaqNrMask = 0x000000000F000000ULL;
388 const cms_uint64_t L1TcsWord::TriggerTypeMask = 0x0000000000F00000ULL;
389 const cms_uint64_t L1TcsWord::StatusMask = 0x00000000000F0000ULL;
390 const cms_uint64_t L1TcsWord::LuminositySegmentNrMask = 0x000000000000FFFFULL;
391 
392 // shift to the right to get the value from the "64-bit-value"
393 const int L1TcsWord::BoardIdShift = 48;
394 const int L1TcsWord::BxNrShift = 32;
395 const int L1TcsWord::DaqNrShift = 24;
396 const int L1TcsWord::TriggerTypeShift = 20;
397 const int L1TcsWord::StatusShift = 16;
399 
400 // word 1
401 
402 const int L1TcsWord::PartRunNrWord = 1;
404 
405 const cms_uint64_t L1TcsWord::PartRunNrMask = 0xFFFFFFFF00000000ULL;
406 const cms_uint64_t L1TcsWord::AssignedPartitionsMask = 0x00000000FFFFFFFFULL;
407 
408 const int L1TcsWord::PartRunNrShift = 32;
410 
411 // word 2
412 
413 const int L1TcsWord::PartTrigNrWord = 2;
414 const int L1TcsWord::EventNrWord = 2;
415 
416 const cms_uint64_t L1TcsWord::PartTrigNrMask = 0xFFFFFFFF00000000ULL;
417 const cms_uint64_t L1TcsWord::EventNrMask = 0x00000000FFFFFFFFULL;
418 
419 const int L1TcsWord::PartTrigNrShift = 32;
420 const int L1TcsWord::EventNrShift = 0;
421 
422 // word 3
423 
424 const int L1TcsWord::OrbitNrWord = 3;
425 
426 const cms_uint64_t L1TcsWord::OrbitNrMask = 0x0000FFFFFFFFFFFFULL;
427 
428 const int L1TcsWord::OrbitNrShift = 0;
429 
430 // word 4
431 
432 // empty
cms_uint16_t m_triggerType
trigger type, identical with event type in CMS header (event type)
Definition: L1TcsWord.h:291
bool isDebugEnabled()
L1TcsWord()
constructors
Definition: L1TcsWord.cc:30
static const int OrbitNrWord
Definition: L1TcsWord.h:270
cms_uint32_t m_partRunNr
partition run number
Definition: L1TcsWord.h:302
void setBoardIdWord64(cms_uint64_t &word64, int iWord)
Definition: L1TcsWord.cc:134
static const int PartRunNrShift
Definition: L1TcsWord.h:254
void setBxNrWord64(cms_uint64_t &word64, int iWord)
Definition: L1TcsWord.cc:145
void reset()
reset the content of a L1TcsWord
Definition: L1TcsWord.cc:259
void setBxNr(const cms_uint16_t bxNrValue)
Definition: L1TcsWord.h:75
static const int OrbitNrShift
Definition: L1TcsWord.h:274
cms_uint32_t m_partTrigNr
Definition: L1TcsWord.h:313
void setAssignedPartitions(const cms_uint32_t assignedPartitionsValue)
Definition: L1TcsWord.h:149
cms_uint16_t m_bxNr
bunch cross number as counted in the TCS chip
Definition: L1TcsWord.h:285
static const int BxNrShift
Definition: L1TcsWord.h:240
void setOrbitNrFrom(const cms_uint64_t &word64)
set the OrbitNr value from a 64-bits word
Definition: L1TcsWord.cc:248
static const cms_uint64_t OrbitNrMask
Definition: L1TcsWord.h:272
static const cms_uint64_t LuminositySegmentNrMask
Definition: L1TcsWord.h:236
cms_uint16_t m_daqNr
number of DAQ partition to which the L1A has been sent
Definition: L1TcsWord.h:288
void setLuminositySegmentNr(const cms_uint16_t luminositySegmentNrValue)
Definition: L1TcsWord.h:123
void setAssignedPartitionsWord64(cms_uint64_t &word64, int iWord)
Definition: L1TcsWord.cc:217
static const cms_uint64_t BxNrMask
Definition: L1TcsWord.h:232
void setOrbitNrWord64(cms_uint64_t &word64, int iWord)
Definition: L1TcsWord.cc:252
#define LogTrace(id)
static const cms_uint64_t PartTrigNrMask
Definition: L1TcsWord.h:262
static const int EventNrWord
Definition: L1TcsWord.h:260
tuple result
Definition: mps_fire.py:311
void setStatus(const cms_uint16_t statusValue)
Definition: L1TcsWord.h:111
void setTriggerTypeWord64(cms_uint64_t &word64, int iWord)
Definition: L1TcsWord.cc:169
static const int PartRunNrWord
Definition: L1TcsWord.h:248
void setPartRunNr(const cms_uint32_t partRunNrValue)
Definition: L1TcsWord.h:137
void print(std::ostream &myCout) const
pretty print the content of a L1TcsWord
Definition: L1TcsWord.cc:274
static const cms_uint64_t StatusMask
Definition: L1TcsWord.h:235
static const int LuminositySegmentNrWord
Definition: L1TcsWord.h:228
void setPartTrigNr(const cms_uint32_t partTrigNrValue)
Definition: L1TcsWord.h:163
static const int DaqNrShift
Definition: L1TcsWord.h:241
bool operator!=(const L1TcsWord &) const
unequal operator
Definition: L1TcsWord.cc:125
cms_uint32_t m_eventNr
event number since last L1 reset generated in TCS chip
Definition: L1TcsWord.h:316
cms_uint16_t m_boardId
board identifier
Definition: L1TcsWord.h:282
static const cms_uint64_t DaqNrMask
Definition: L1TcsWord.h:233
static const int PartTrigNrWord
Definition: L1TcsWord.h:259
unsigned short cms_uint16_t
Definition: typedefs.h:13
static const cms_uint64_t BoardIdMask
Definition: L1TcsWord.h:231
static const int BxNrWord
Definition: L1TcsWord.h:224
static const cms_uint64_t EventNrMask
Definition: L1TcsWord.h:263
cms_uint64_t m_orbitNr
orbit number since start of run (48 bits, in fact)
Definition: L1TcsWord.h:321
static const int LuminositySegmentNrShift
Definition: L1TcsWord.h:244
static const int PartTrigNrShift
Definition: L1TcsWord.h:265
void setLuminositySegmentNrWord64(cms_uint64_t &word64, int iWord)
Definition: L1TcsWord.cc:193
cms_uint16_t m_luminositySegmentNr
luminosity segment number
Definition: L1TcsWord.h:297
unsigned int cms_uint32_t
Definition: typedefs.h:15
static const int StatusWord
Definition: L1TcsWord.h:227
static const int AssignedPartitionsWord
Definition: L1TcsWord.h:249
static const int BoardIdShift
Definition: L1TcsWord.h:239
void setBoardId(const cms_uint16_t boardIdValue)
set BoardId from a BoardId value
Definition: L1TcsWord.h:63
static const int BoardIdWord
Definition: L1TcsWord.h:223
static const int DaqNrWord
Definition: L1TcsWord.h:225
static const cms_uint64_t PartRunNrMask
Definition: L1TcsWord.h:251
cms_uint16_t m_status
0000 = normal rate; 1000 = low rate = warning
Definition: L1TcsWord.h:294
static const int StatusShift
Definition: L1TcsWord.h:243
static const cms_uint64_t TriggerTypeMask
Definition: L1TcsWord.h:234
static const int BlockSize
Definition: L1TcsWord.h:218
void setEventNrWord64(cms_uint64_t &word64, int iWord)
Definition: L1TcsWord.cc:241
void unpack(const unsigned char *tcsPtr)
Definition: L1TcsWord.cc:339
void setPartRunNrWord64(cms_uint64_t &word64, int iWord)
Definition: L1TcsWord.cc:204
static const int EventNrShift
Definition: L1TcsWord.h:266
static const int TriggerTypeShift
Definition: L1TcsWord.h:242
cms_uint32_t m_assignedPartitions
Definition: L1TcsWord.h:307
void setPartTrigNrWord64(cms_uint64_t &word64, int iWord)
Definition: L1TcsWord.cc:230
void setTriggerType(const cms_uint16_t triggerTypeValue)
Definition: L1TcsWord.h:99
unsigned long long cms_uint64_t
Definition: typedefs.h:17
void setEventNr(const cms_uint32_t eventNrValue)
Definition: L1TcsWord.h:175
void setDaqNrWord64(cms_uint64_t &word64, int iWord)
Definition: L1TcsWord.cc:156
static const int TriggerTypeWord
Definition: L1TcsWord.h:226
void setDaqNr(const cms_uint16_t daqNrValue)
Definition: L1TcsWord.h:87
static const cms_uint64_t AssignedPartitionsMask
Definition: L1TcsWord.h:252
bool operator==(const L1TcsWord &) const
equal operator
Definition: L1TcsWord.cc:75
static const int AssignedPartitionsShift
Definition: L1TcsWord.h:255
virtual ~L1TcsWord()
destructor
Definition: L1TcsWord.cc:70
void setStatusWord64(cms_uint64_t &word64, int iWord)
Definition: L1TcsWord.cc:180
#define LogDebug(id)