CMS 3D CMS Logo

L1GlobaTriggerEvmRawToDigi.cc
Go to the documentation of this file.
1 
15 // this class header
17 
18 // system include files
19 #include <iostream>
20 #include <iomanip>
21 #include <algorithm>
22 
23 // user include files
26 
31 
36 
39 
42 
45 
48 
49 // constructor(s)
51  :
52 
53  // input tag for EVM GT record
54  m_evmGtInputTag(pSet.getParameter<edm::InputTag>("EvmGtInputTag")),
55 
56  // FED Id for GT EVM record
57  // default value defined in DataFormats/FEDRawData/src/FEDNumbering.cc
58  // default value: assume the EVM record is the first GT record
59  m_evmGtFedId(pSet.getUntrackedParameter<int>("EvmGtFedId", FEDNumbering::MINTriggerGTPFEDID)),
60 
62  m_l1GtBMToken(esConsumes<L1GtBoardMaps, L1GtBoardMapsRcd>()),
63 
64  // mask for active boards
65  m_activeBoardsMaskGt(pSet.getParameter<unsigned int>("ActiveBoardsMask")),
66 
67  // number of bunch crossing to be unpacked
68  m_unpackBxInEvent(pSet.getParameter<int>("UnpackBxInEvent")),
69 
70  m_lowSkipBxInEvent(0),
71  m_uppSkipBxInEvent(0),
72 
73  m_recordLength0(0),
74  m_recordLength1(0),
75 
76  m_totalBxInEvent(0),
77 
78  // length of BST record (in bytes)
79  m_bstLengthBytes(pSet.getParameter<int>("BstLengthBytes")),
80 
81  m_verbosity(pSet.getUntrackedParameter<int>("Verbosity", 0)),
82 
83  m_isDebugEnabled(edm::isDebugEnabled())
84 
85 {
86  produces<L1GlobalTriggerEvmReadoutRecord>();
87 
89  LogDebug("L1GlobalTriggerEvmRawToDigi")
90  << "\nInput tag for EVM GT record: " << m_evmGtInputTag
91  << "\nFED Id for EVM GT record: " << m_evmGtFedId
92  << "\nMask for active boards (hex format): " << std::hex << std::setw(sizeof(m_activeBoardsMaskGt) * 2)
93  << std::setfill('0') << m_activeBoardsMaskGt << std::dec << std::setfill(' ')
94  << "\nNumber of bunch crossing to be unpacked: " << m_unpackBxInEvent
95  << "\nLength of BST message [bytes]: " << m_bstLengthBytes << "\n"
96  << std::endl;
97  }
98 
99  if ((m_unpackBxInEvent > 0) && ((m_unpackBxInEvent % 2) == 0)) {
101 
102  if (m_verbosity) {
103  edm::LogInfo("L1GlobalTriggerEvmRawToDigi")
104  << "\nWARNING: Number of bunch crossing to be unpacked rounded to: " << m_unpackBxInEvent
105  << "\n The number must be an odd number!\n"
106  << std::endl;
107  }
108  }
109 
110  // create GTFE, TCS, FDL cards once per analyzer
111  // content will be reset whenever needed
112 
113  m_gtfeWord = new L1GtfeExtWord();
114  m_tcsWord = new L1TcsWord();
115  m_gtFdlWord = new L1GtFdlWord();
116  consumes<FEDRawDataCollection>(m_evmGtInputTag);
117 
119  if (m_bstLengthBytes < 0) {
120  m_l1GtParamToken = esConsumes<L1GtParameters, L1GtParametersRcd>();
121  }
122 }
123 
124 // destructor
126  delete m_gtfeWord;
127  delete m_tcsWord;
128  delete m_gtFdlWord;
129 }
130 
131 // member functions
132 
133 // method called to produce the data
135  // get records from EventSetup
136 
137  // board maps
139 
140  const std::vector<L1GtBoard> boardMaps = l1GtBM->gtBoardMaps();
141  int boardMapsSize = boardMaps.size();
142 
143  typedef std::vector<L1GtBoard>::const_iterator CItBoardMaps;
144 
145  // create an ordered vector for the GT EVM record
146  // header (pos 0 in record) and trailer (last position in record)
147  // not included, as they are not in board list
148  std::vector<L1GtBoard> gtRecordMap;
149  gtRecordMap.reserve(boardMapsSize);
150 
151  for (int iPos = 0; iPos < boardMapsSize; ++iPos) {
152  for (CItBoardMaps itBoard = boardMaps.begin(); itBoard != boardMaps.end(); ++itBoard) {
153  if (itBoard->gtPositionEvmRecord() == iPos) {
154  gtRecordMap.push_back(*itBoard);
155  break;
156  }
157  }
158  }
159 
160  // raw collection
161 
163  iEvent.getByLabel(m_evmGtInputTag, fedHandle);
164 
165  if (!fedHandle.isValid()) {
166  if (m_verbosity) {
167  edm::LogWarning("L1GlobalTriggerEvmRawToDigi")
168  << "\nWarning: FEDRawDataCollection with input tag " << m_evmGtInputTag
169  << "\nrequested in configuration, but not found in the event."
170  << "\nQuit unpacking this event" << std::endl;
171  }
172 
174 
175  return;
176  }
177 
178  // retrieve data for Global Trigger EVM FED
179  const FEDRawData& raw = (fedHandle.product())->FEDData(m_evmGtFedId);
180 
181  int gtSize = raw.size();
182 
183  // get a const pointer to the beginning of the data buffer
184  const unsigned char* ptrGt = raw.data();
185 
186  // get a const pointer to the end of the data buffer
187  const unsigned char* endPtrGt = ptrGt + gtSize;
188 
189  //
190  if (m_verbosity && m_isDebugEnabled) {
191  LogTrace("L1GlobalTriggerEvmRawToDigi") << "\n Size of raw data: " << gtSize << "\n" << std::endl;
192 
193  std::ostringstream myCoutStream;
194  dumpFedRawData(ptrGt, gtSize, myCoutStream);
195 
196  LogTrace("L1GlobalTriggerEvmRawToDigi") << "\n Dump FEDRawData\n" << myCoutStream.str() << "\n" << std::endl;
197  }
198 
199  // unpack header
200  int headerSize = 8;
201 
202  if ((ptrGt + headerSize) > endPtrGt) {
203  edm::LogError("L1GlobalTriggerEvmRawToDigi") << "\nError: Pointer after header greater than end pointer."
204  << "\n Put empty products in the event!"
205  << "\n Quit unpacking this event." << std::endl;
206 
208 
209  return;
210  }
211 
212  FEDHeader cmsHeader(ptrGt);
213  FEDTrailer cmsTrailer(ptrGt + gtSize - headerSize);
214 
215  unpackHeader(ptrGt, cmsHeader);
216  ptrGt += headerSize; // advance with header size
217 
218  // unpack first GTFE to find the length of the record and the active boards
219  // here GTFE assumed immediately after the header
220 
221  bool gtfeUnpacked = false;
222 
223  // get the length of the BST message from parameter set or from event setup
224 
225  int bstLengthBytes = 0;
226 
227  if (m_bstLengthBytes < 0) {
228  // length from event setup // TODO cache it, if too slow
229 
231  const L1GtParameters* m_l1GtPar = l1GtPar.product();
232 
233  bstLengthBytes = static_cast<int>(m_l1GtPar->gtBstLengthBytes());
234 
235  } else {
236  // length from parameter set
237  bstLengthBytes = m_bstLengthBytes;
238  }
239 
240  if (m_verbosity) {
241  LogTrace("L1GlobalTriggerEvmRawToDigi") << "\n Length of BST message (in bytes): " << bstLengthBytes << "\n"
242  << std::endl;
243  }
244 
245  for (CItBoardMaps itBoard = boardMaps.begin(); itBoard != boardMaps.end(); ++itBoard) {
246  if (itBoard->gtBoardType() == GTFE) {
247  // unpack GTFE
248  if (itBoard->gtPositionEvmRecord() == 1) {
249  // resize to the right size before unapacking
250  m_gtfeWord->resize(bstLengthBytes);
251 
252  m_gtfeWord->unpack(ptrGt);
253  ptrGt += m_gtfeWord->getSize(); // advance with GTFE block size
254  gtfeUnpacked = true;
255 
256  if (m_verbosity && m_isDebugEnabled) {
257  std::ostringstream myCoutStream;
258  m_gtfeWord->print(myCoutStream);
259  LogTrace("L1GlobalTriggerEvmRawToDigi") << myCoutStream.str() << "\n" << std::endl;
260  }
261 
262  // break the loop - GTFE was found
263  break;
264 
265  } else {
266  if (m_verbosity) {
267  edm::LogWarning("L1GlobalTriggerEvmRawToDigi")
268  << "\nWarning: GTFE block found in raw data does not follow header."
269  << "\nAssumed start position of the block is wrong!"
270  << "\nQuit unpacking this event" << std::endl;
271  }
272 
274 
275  return;
276  }
277  }
278  }
279 
280  // quit if no GTFE found
281  if (!gtfeUnpacked) {
282  if (m_verbosity) {
283  edm::LogWarning("L1GlobalTriggerEvmRawToDigi")
284  << "\nWarning: no GTFE block found in raw data."
285  << "\nCan not find the record length (BxInEvent) and the active boards!"
286  << "\nQuit unpacking this event" << std::endl;
287  }
288 
290 
291  return;
292  }
293 
294  // life normal here, GTFE found
295 
296  // get list of active blocks
297  // blocks not active are not written to the record
298  cms_uint16_t activeBoardsGtInitial = m_gtfeWord->activeBoards();
299  cms_uint16_t altNrBxBoardInitial = m_gtfeWord->altNrBxBoard();
300 
301  // mask some boards, if needed
302  cms_uint16_t activeBoardsGt = activeBoardsGtInitial & m_activeBoardsMaskGt;
303  m_gtfeWord->setActiveBoards(activeBoardsGt);
304 
305  if (m_verbosity) {
306  LogDebug("L1GlobalTriggerEvmRawToDigi")
307  << "\nActive boards before masking(hex format): " << std::hex << std::setw(sizeof(activeBoardsGtInitial) * 2)
308  << std::setfill('0') << activeBoardsGtInitial << std::dec << std::setfill(' ')
309  << "\nActive boards after masking(hex format): " << std::hex << std::setw(sizeof(activeBoardsGt) * 2)
310  << std::setfill('0') << activeBoardsGt << std::dec << std::setfill(' ') << " \n"
311  << std::endl;
312  }
313 
314  // loop over other blocks in the raw record, count them if they are active
315 
316  int numberGtfeBoards = 0;
317  int numberFdlBoards = 0;
318  int numberPsbBoards = 0;
319  int numberGmtBoards = 0;
320  int numberTcsBoards = 0;
321  int numberTimBoards = 0;
322 
323  for (CItBoardMaps itBoard = boardMaps.begin(); itBoard != boardMaps.end(); ++itBoard) {
324  int iActiveBit = itBoard->gtBitEvmActiveBoards();
325  bool activeBoardToUnpack = false;
326 
327  if (iActiveBit >= 0) {
328  activeBoardToUnpack = activeBoardsGt & (1 << iActiveBit);
329  } else {
330  // board not in the ActiveBoards for the record
331  continue;
332  }
333 
334  if (activeBoardToUnpack) {
335  switch (itBoard->gtBoardType()) {
336  case GTFE: {
337  numberGtfeBoards++;
338  }
339 
340  break;
341  case FDL: {
342  numberFdlBoards++;
343  }
344 
345  break;
346  case PSB: {
347  numberPsbBoards++;
348  }
349 
350  break;
351  case GMT: {
352  numberGmtBoards++;
353  }
354 
355  break;
356  case TCS: {
357  numberTcsBoards++;
358  }
359 
360  break;
361  case TIM: {
362  numberTimBoards++;
363  }
364 
365  break;
366  default: {
367  // do nothing, all blocks are given in GtBoardType enum
368  if (m_verbosity) {
369  LogDebug("L1GlobalTriggerEvmRawToDigi")
370  << "\nBoard of type " << itBoard->gtBoardType() << " not expected in record.\n"
371  << std::endl;
372  }
373 
374  }
375 
376  break;
377  }
378  }
379  }
380 
381  // produce the L1GlobalTriggerEvmReadoutRecord now, after we found how many
382  // BxInEvent the record has and how many boards are active
383  //LogDebug("L1GlobalTriggerEvmRawToDigi")
384  //<< "\nL1GlobalTriggerEvmRawToDigi: producing L1GlobalTriggerEvmReadoutRecord\n"
385  //<< std::endl;
386 
387  // get number of Bx in the event from GTFE block corresponding to alternative 0 and 1 in
390 
391  int maxBxInEvent = std::max(m_recordLength0, m_recordLength1);
392 
393  std::unique_ptr<L1GlobalTriggerEvmReadoutRecord> gtReadoutRecord(
394  new L1GlobalTriggerEvmReadoutRecord(maxBxInEvent, numberFdlBoards));
395 
396  // ... then unpack modules other than GTFE, if requested
397 
398  for (CItBoardMaps itBoard = gtRecordMap.begin(); itBoard != gtRecordMap.end(); ++itBoard) {
399  int iActiveBit = itBoard->gtBitEvmActiveBoards();
400 
401  bool activeBoardToUnpack = false;
402  bool activeBoardInitial = false;
403 
404  int altNrBxBoardVal = -1;
405 
406  if (iActiveBit >= 0) {
407  activeBoardInitial = activeBoardsGtInitial & (1 << iActiveBit);
408  activeBoardToUnpack = activeBoardsGt & (1 << iActiveBit);
409 
410  altNrBxBoardVal = (altNrBxBoardInitial & (1 << iActiveBit)) >> iActiveBit;
411 
412  if (altNrBxBoardVal == 1) {
414  } else if (altNrBxBoardVal == 0) {
416  } else {
417  if (m_verbosity) {
418  edm::LogWarning("L1GlobalTriggerEvmRawToDigi")
419  << "\n\nWARNING: Wrong value altNrBxBoardVal = " << altNrBxBoardVal << " for board " << std::hex
420  << (itBoard->gtBoardId()) << std::dec << "\n iActiveBit = " << iActiveBit
421  << "\n altNrBxBoardInitial = 0x" << std::hex << altNrBxBoardInitial << std::dec
422  << "\n activeBoardsGt = 0x" << std::hex << activeBoardsGt << std::dec
423  << "\n activeBoardInitial = " << activeBoardInitial
424  << "\n activeBoardToUnpack = " << activeBoardToUnpack << "\n Set altNrBxBoardVal tentatively to "
425  << m_recordLength0 << "\n Job may crash or produce wrong results!\n\n"
426  << std::endl;
427  }
428 
430  }
431 
432  // number of BX required to be unpacked
433 
435  if (m_verbosity) {
436  LogDebug("L1GlobalTriggerEvmRawToDigi")
437  << "\nWARNING: Number of available bunch crosses for board" << (itBoard->gtBoardId())
438  << " in the record ( " << m_totalBxInEvent
439  << " ) \n is smaller than the number of bunch crosses requested to be unpacked (" << m_unpackBxInEvent
440  << " )!!! \n Unpacking only " << m_totalBxInEvent << " bunch crosses.\n"
441  << std::endl;
442  }
443 
444  m_lowSkipBxInEvent = 0;
446 
447  } else if (m_unpackBxInEvent < 0) {
448  m_lowSkipBxInEvent = 0;
450 
451  if (m_verbosity) {
452  LogDebug("L1GlobalTriggerEvmRawToDigi")
453  << "\nUnpacking all " << m_totalBxInEvent << " bunch crosses available."
454  << "\n"
455  << std::endl;
456  }
457 
458  } else if (m_unpackBxInEvent == 0) {
461 
462  if (m_verbosity) {
463  LogDebug("L1GlobalTriggerEvmRawToDigi")
464  << "\nNo bxInEvent required to be unpacked from " << m_totalBxInEvent << " bunch crosses available."
465  << "\n"
466  << std::endl;
467  }
468 
469  // change RecordLength
470  // cast int to cms_uint16_t (there are normally 3 or 5 BxInEvent)
471  m_gtfeWord->setRecordLength(static_cast<cms_uint16_t>(m_unpackBxInEvent));
472  m_gtfeWord->setRecordLength1(static_cast<cms_uint16_t>(m_unpackBxInEvent));
473 
474  } else {
477 
478  if (m_verbosity) {
479  LogDebug("L1GlobalTriggerEvmRawToDigi") << "\nUnpacking " << m_unpackBxInEvent << " bunch crosses from "
480  << m_totalBxInEvent << " bunch crosses available."
481  << "\n"
482  << std::endl;
483  }
484 
485  // change RecordLength
486  // cast int to cms_uint16_t (there are normally 3 or 5 BxInEvent)
487  m_gtfeWord->setRecordLength(static_cast<cms_uint16_t>(m_unpackBxInEvent));
488  m_gtfeWord->setRecordLength1(static_cast<cms_uint16_t>(m_unpackBxInEvent));
489  }
490 
491  } else {
492  // board not in the ActiveBoards for the record
493  continue;
494  }
495 
496  if (!activeBoardInitial) {
497  if (m_verbosity) {
498  LogDebug("L1GlobalTriggerEvmRawToDigi") << "\nBoard of type " << itBoard->gtBoardName() << " with index "
499  << itBoard->gtBoardIndex() << " not active initially in raw data.\n"
500  << std::endl;
501  }
502  continue;
503  }
504 
505  // active board initially, could unpack it
506  switch (itBoard->gtBoardType()) {
507  case TCS: {
508  // if pointer after TCS payload is greater than pointer at
509  // the end of GT payload, produce empty products and quit unpacking
510  if ((ptrGt + m_tcsWord->getSize()) > endPtrGt) {
511  edm::LogError("L1GlobalTriggerEvmRawToDigi") << "\nError: Pointer after TCS "
512  << " greater than end pointer."
513  << "\n Put empty products in the event!"
514  << "\n Quit unpacking this event." << std::endl;
515 
517 
518  return;
519  }
520 
521  // unpack only if requested, otherwise skip it
522  if (activeBoardToUnpack) {
523  m_tcsWord->unpack(ptrGt);
524 
525  // add 1 to the GT luminosity number to use the same convention as
526  // offline, where LS number starts with 1;
527  // in GT hardware, LS starts with 0
530 
531  // add TCS block to GT EVM readout record
532  gtReadoutRecord->setTcsWord(*m_tcsWord);
533 
534  if (m_verbosity && m_isDebugEnabled) {
535  std::ostringstream myCoutStream;
536  m_tcsWord->print(myCoutStream);
537  LogTrace("L1GlobalTriggerEvmRawToDigi") << myCoutStream.str() << "\n" << std::endl;
538  }
539 
540  // ... and reset it
541  m_tcsWord->reset();
542  }
543 
544  ptrGt += m_tcsWord->getSize(); // advance with TCS block size
545 
546  } break;
547  case FDL: {
548  for (int iFdl = 0; iFdl < m_totalBxInEvent; ++iFdl) {
549  // if pointer after FDL payload is greater than pointer at
550  // the end of GT payload, produce empty products and quit unpacking
551  if ((ptrGt + m_gtFdlWord->getSize()) > endPtrGt) {
552  edm::LogError("L1GlobalTriggerEvmRawToDigi")
553  << "\nError: Pointer after FDL " << iFdl << " greater than end pointer."
554  << "\n Put empty products in the event!"
555  << "\n Quit unpacking this event." << std::endl;
556 
558 
559  return;
560  }
561 
562  // unpack only if requested, otherwise skip it
563  if (activeBoardToUnpack) {
564  // unpack only bxInEvent requested, otherwise skip it
565  if ((iFdl >= m_lowSkipBxInEvent) && (iFdl < m_uppSkipBxInEvent)) {
566  m_gtFdlWord->unpack(ptrGt);
567 
568  // add 1 to the GT luminosity number to use the same convention as
569  // offline, where LS number starts with 1;
570  // in GT hardware, LS starts with 0
571  cms_uint16_t lsNr = m_gtFdlWord->lumiSegmentNr() + 1;
573 
574  // add FDL block to GT readout record
575  gtReadoutRecord->setGtFdlWord(*m_gtFdlWord);
576 
577  if (m_verbosity && m_isDebugEnabled) {
578  std::ostringstream myCoutStream;
579  m_gtFdlWord->print(myCoutStream);
580  LogTrace("L1GlobalTriggerEvmRawToDigi") << myCoutStream.str() << "\n" << std::endl;
581  }
582 
583  // ... and reset it
584  m_gtFdlWord->reset();
585  }
586  }
587 
588  ptrGt += m_gtFdlWord->getSize(); // advance with FDL block size
589  }
590  }
591 
592  break;
593  default: {
594  // do nothing, all blocks are given in GtBoardType enum
595  if (m_verbosity) {
596  LogDebug("L1GlobalTriggerEvmRawToDigi")
597  << "\nBoard of type " << itBoard->gtBoardType() << " not expected in record.\n"
598  << std::endl;
599  }
600  } break;
601  }
602  }
603 
604  // add GTFE block to GT readout record, after updating active boards and record length
605 
606  gtReadoutRecord->setGtfeWord(*m_gtfeWord);
607 
608  // ... and reset it
609  m_gtfeWord->reset();
610 
611  // unpack trailer
612 
613  int trailerSize = 8;
614 
615  // if pointer after trailer is greater than pointer at
616  // the end of GT payload, produce empty products and quit unpacking
617  if ((ptrGt + trailerSize) > endPtrGt) {
618  edm::LogError("L1GlobalTriggerEvmRawToDigi") << "\nError: Pointer after trailer "
619  << " greater than end pointer."
620  << "\n Put empty products in the event!"
621  << "\n Quit unpacking this event." << std::endl;
622 
624 
625  return;
626  }
627 
628  unpackTrailer(ptrGt, cmsTrailer);
629 
630  if (m_verbosity && m_isDebugEnabled) {
631  std::ostringstream myCoutStream;
632  gtReadoutRecord->print(myCoutStream);
633  LogTrace("L1GlobalTriggerEvmRawToDigi") << "\n The following L1 GT EVM readout record was unpacked.\n"
634  << myCoutStream.str() << "\n"
635  << std::endl;
636  }
637 
638  // put records into event
639  iEvent.put(std::move(gtReadoutRecord));
640 }
641 
642 // unpack header
643 void L1GlobalTriggerEvmRawToDigi::unpackHeader(const unsigned char* gtPtr, FEDHeader& cmsHeader) {
644  // TODO if needed in another format
645 
646  // print the header info
647  if (edm::isDebugEnabled()) {
648  const cms_uint64_t* payload = reinterpret_cast<cms_uint64_t*>(const_cast<unsigned char*>(gtPtr));
649 
650  std::ostringstream myCoutStream;
651 
652  // one word only
653  int iWord = 0;
654 
655  myCoutStream << std::setw(4) << iWord << " " << std::hex << std::setfill('0') << std::setw(16) << payload[iWord]
656  << std::dec << std::setfill(' ') << "\n"
657  << std::endl;
658 
659  myCoutStream << " Event_type: " << std::hex << " hex: "
660  << " " << std::setw(1) << std::setfill('0') << cmsHeader.triggerType() << std::setfill(' ')
661  << std::dec << " dec: " << cmsHeader.triggerType() << std::endl;
662 
663  myCoutStream << " LVL1_Id: " << std::hex << " hex: "
664  << "" << std::setw(6) << std::setfill('0') << cmsHeader.lvl1ID() << std::setfill(' ') << std::dec
665  << " dec: " << cmsHeader.lvl1ID() << std::endl;
666 
667  myCoutStream << " BX_Id: " << std::hex << " hex: "
668  << " " << std::setw(3) << std::setfill('0') << cmsHeader.bxID() << std::setfill(' ') << std::dec
669  << " dec: " << cmsHeader.bxID() << std::endl;
670 
671  myCoutStream << " Source_Id: " << std::hex << " hex: "
672  << " " << std::setw(3) << std::setfill('0') << cmsHeader.sourceID() << std::setfill(' ') << std::dec
673  << " dec: " << cmsHeader.sourceID() << std::endl;
674 
675  myCoutStream << " FOV: " << std::hex << " hex: "
676  << " " << std::setw(1) << std::setfill('0') << cmsHeader.version() << std::setfill(' ') << std::dec
677  << " dec: " << cmsHeader.version() << std::endl;
678 
679  myCoutStream << " H: " << std::hex << " hex: "
680  << " " << std::setw(1) << std::setfill('0') << cmsHeader.moreHeaders() << std::setfill(' ')
681  << std::dec << " dec: " << cmsHeader.moreHeaders() << std::endl;
682 
683  LogDebug("L1GlobalTriggerEvmRawToDigi") << "\n CMS Header \n" << myCoutStream.str() << "\n" << std::endl;
684  }
685 }
686 
687 // unpack trailer word
688 // trPtr pointer to the beginning of trailer obtained from gtPtr
689 void L1GlobalTriggerEvmRawToDigi::unpackTrailer(const unsigned char* trlPtr, FEDTrailer& cmsTrailer) {
690  // TODO if needed in another format
691 
692  // print the trailer info
693  if (m_verbosity && m_isDebugEnabled) {
694  const cms_uint64_t* payload = reinterpret_cast<cms_uint64_t*>(const_cast<unsigned char*>(trlPtr));
695 
696  std::ostringstream myCoutStream;
697 
698  // one word only
699  int iWord = 0;
700 
701  myCoutStream << std::setw(4) << iWord << " " << std::hex << std::setfill('0') << std::setw(16) << payload[iWord]
702  << std::dec << std::setfill(' ') << "\n"
703  << std::endl;
704 
705  myCoutStream << " Event_length: " << std::hex << " hex: "
706  << "" << std::setw(6) << std::setfill('0') << cmsTrailer.fragmentLength() << std::setfill(' ')
707  << std::dec << " dec: " << cmsTrailer.fragmentLength() << std::endl;
708 
709  myCoutStream << " CRC: " << std::hex << " hex: "
710  << " " << std::setw(4) << std::setfill('0') << cmsTrailer.crc() << std::setfill(' ') << std::dec
711  << " dec: " << cmsTrailer.crc() << std::endl;
712 
713  myCoutStream << " Event_status: " << std::hex << " hex: "
714  << " " << std::setw(2) << std::setfill('0') << cmsTrailer.evtStatus() << std::setfill(' ')
715  << std::dec << " dec: " << cmsTrailer.evtStatus() << std::endl;
716 
717  myCoutStream << " TTS_bits: " << std::hex << " hex: "
718  << " " << std::setw(1) << std::setfill('0') << cmsTrailer.ttsBits() << std::setfill(' ')
719  << std::dec << " dec: " << cmsTrailer.ttsBits() << std::endl;
720 
721  myCoutStream << " More trailers: " << std::hex << " hex: "
722  << " " << std::setw(1) << std::setfill('0') << cmsTrailer.moreTrailers() << std::setfill(' ')
723  << std::dec << " dec: " << cmsTrailer.moreTrailers() << std::endl;
724 
725  LogDebug("L1GlobalTriggerEvmRawToDigi") << "\n CMS Trailer \n" << myCoutStream.str() << "\n" << std::endl;
726  }
727 }
728 
729 // produce empty products in case of problems
731  std::unique_ptr<L1GlobalTriggerEvmReadoutRecord> gtReadoutRecord(new L1GlobalTriggerEvmReadoutRecord());
732 
733  // put empty records into event
734 
735  iEvent.put(std::move(gtReadoutRecord));
736 }
737 
738 // dump FED raw data
739 void L1GlobalTriggerEvmRawToDigi::dumpFedRawData(const unsigned char* gtPtr, int gtSize, std::ostream& myCout) {
740  LogDebug("L1GlobalTriggerEvmRawToDigi") << "\nDump FED raw data.\n" << std::endl;
741 
744 
745  int gtWords = gtSize / uLength;
746  LogTrace("L1GlobalTriggerEvmRawToDigi") << "\nFED GT words (" << wLength << " bits):" << gtWords << "\n" << std::endl;
747 
748  const cms_uint64_t* payload = reinterpret_cast<cms_uint64_t*>(const_cast<unsigned char*>(gtPtr));
749 
750  for (unsigned int i = 0; i < gtSize / sizeof(cms_uint64_t); i++) {
751  myCout << std::setw(4) << i << " " << std::hex << std::setfill('0') << std::setw(16) << payload[i] << std::dec
752  << std::setfill(' ') << std::endl;
753  }
754 }
755 
756 // static class members
L1GlobalTriggerReadoutSetup::WordLength
static const int WordLength
GT DAQ record organized in words of WordLength bits.
Definition: L1GlobalTriggerReadoutSetup.h:53
FEDNumbering.h
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
GTFE
Definition: L1GtDefinitions.h:28
L1GtfeExtWord::reset
void reset() override
reset the content of a L1GtfeExtWord
Definition: L1GtfeExtWord.cc:428
L1GtfeWord::activeBoards
const cms_uint16_t activeBoards() const
get/set boards contributing to EVM respectively DAQ record
Definition: L1GtfeWord.h:119
L1GlobalTriggerEvmRawToDigi::m_recordLength1
int m_recordLength1
corresponding to alternative 1 in altNrBxBoard()
Definition: L1GlobalTriggerEvmRawToDigi.h:112
L1GlobalTriggerEvmRawToDigi::m_uppSkipBxInEvent
int m_uppSkipBxInEvent
Definition: L1GlobalTriggerEvmRawToDigi.h:104
L1GtfeExtWord::unpack
void unpack(const unsigned char *gtfePtr) override
Definition: L1GtfeExtWord.cc:481
mps_fire.i
i
Definition: mps_fire.py:428
L1GlobalTriggerReadoutSetup::UnitLength
static const int UnitLength
one unit in the word is UnitLength bits
Definition: L1GlobalTriggerReadoutSetup.h:56
L1GtParameters::gtBstLengthBytes
const unsigned int gtBstLengthBytes() const
get / set length of BST message (in bytes) for L1 GT EVM record
Definition: L1GtParameters.h:68
MessageLogger.h
edm::Handle::product
T const * product() const
Definition: Handle.h:70
PSB
Definition: L1GtDefinitions.h:28
FEDHeader::moreHeaders
bool moreHeaders() const
Definition: FEDHeader.cc:23
ESHandle.h
L1TcsWord::setLuminositySegmentNr
void setLuminositySegmentNr(const cms_uint16_t luminositySegmentNrValue)
Definition: L1TcsWord.h:123
TCS
Definition: L1GtDefinitions.h:28
edm
HLT enums.
Definition: AlignableModifier.h:19
L1GtfeExtWord.h
L1TcsWord
Definition: L1TcsWord.h:29
L1GtParameters
Definition: L1GtParameters.h:33
L1GlobalTriggerEvmRawToDigi::m_unpackBxInEvent
int m_unpackBxInEvent
Definition: L1GlobalTriggerEvmRawToDigi.h:96
L1TcsWord::unpack
void unpack(const unsigned char *tcsPtr)
Definition: L1TcsWord.cc:339
L1GlobalTriggerEvmRawToDigi::m_totalBxInEvent
int m_totalBxInEvent
number of Bx for a board, obtained from GTFE block (record length & alternative)
Definition: L1GlobalTriggerEvmRawToDigi.h:115
FEDTrailer::crc
uint16_t crc() const
Cyclic Redundancy Code of the event fragment including header and trailer.
Definition: FEDTrailer.cc:15
L1TcsWord::print
void print(std::ostream &myCout) const
pretty print the content of a L1TcsWord
Definition: L1TcsWord.cc:274
L1GlobalTriggerEvmRawToDigi::m_evmGtFedId
int m_evmGtFedId
Definition: L1GlobalTriggerEvmRawToDigi.h:84
L1GtBoardMaps
Definition: L1GtBoardMaps.h:33
L1GtfeWord::setRecordLength
void setRecordLength(cms_uint16_t recordLengthValue)
Definition: L1GtfeWord.h:84
L1GlobalTriggerEvmRawToDigi::L1GlobalTriggerEvmRawToDigi
L1GlobalTriggerEvmRawToDigi(const edm::ParameterSet &)
constructor(s)
Definition: L1GlobaTriggerEvmRawToDigi.cc:50
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89287
FEDHeader::version
uint8_t version() const
Version identifier of the FED data format.
Definition: FEDHeader.cc:21
L1GtfeWord::setRecordLength1
void setRecordLength1(cms_uint16_t recordLengthValue)
Definition: L1GtfeWord.h:73
FDL
Definition: L1GtDefinitions.h:28
L1TcsWord::reset
void reset()
reset the content of a L1TcsWord
Definition: L1TcsWord.cc:259
FEDTrailer::evtStatus
uint8_t evtStatus() const
Event fragment status information.
Definition: FEDTrailer.cc:17
FEDHeader::lvl1ID
uint32_t lvl1ID() const
Level-1 event number generated by the TTC system.
Definition: FEDHeader.cc:15
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
edm::Handle
Definition: AssociativeIterator.h:50
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
L1GlobalTriggerEvmRawToDigi::m_activeBoardsMaskGt
cms_uint16_t m_activeBoardsMaskGt
mask for active boards
Definition: L1GlobalTriggerEvmRawToDigi.h:93
L1GtFdlWord::unpack
void unpack(const unsigned char *fdlPtr)
Definition: L1GtFdlWord.cc:689
FEDRawData::data
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:24
FEDRawData
Definition: FEDRawData.h:19
FEDNumbering
Definition: FEDNumbering.h:17
L1TcsWord.h
L1GlobalTriggerEvmRawToDigi::m_l1GtParamToken
edm::ESGetToken< L1GtParameters, L1GtParametersRcd > m_l1GtParamToken
EventSetup Token for L1GtParameters.
Definition: L1GlobalTriggerEvmRawToDigi.h:90
L1GtfeWord::recordLength
const cms_uint16_t recordLength() const
get/set record length for alternative 0
Definition: L1GtfeWord.h:82
L1GlobalTriggerEvmRawToDigi::m_recordLength0
int m_recordLength0
total Bx's in the event, obtained from GTFE block
Definition: L1GlobalTriggerEvmRawToDigi.h:109
L1GlobalTriggerEvmRawToDigi::m_gtFdlWord
L1GtFdlWord * m_gtFdlWord
Definition: L1GlobalTriggerEvmRawToDigi.h:77
L1GlobalTriggerEvmReadoutRecord.h
L1GlobalTriggerEvmReadoutRecord
Definition: L1GlobalTriggerEvmReadoutRecord.h:36
L1GlobalTriggerEvmRawToDigi::unpackTrailer
void unpackTrailer(const unsigned char *, FEDTrailer &)
unpack trailer word
Definition: L1GlobaTriggerEvmRawToDigi.cc:689
edm::ESHandle
Definition: DTSurvey.h:22
L1GtfeWord::setActiveBoards
void setActiveBoards(cms_uint16_t activeBoardsValue)
Definition: L1GtfeWord.h:121
L1GlobalTriggerEvmRawToDigi::m_gtfeWord
L1GtfeExtWord * m_gtfeWord
Definition: L1GlobalTriggerEvmRawToDigi.h:75
L1GtFdlWord.h
jets_cff.payload
payload
Definition: jets_cff.py:32
TIM
Definition: L1GtDefinitions.h:28
L1TcsWord::getSize
const unsigned int getSize() const
get the size of the TCS block in GT EVM record (in multiple of 8 bits)
Definition: L1TcsWord.h:197
L1GtFdlWord::setLumiSegmentNr
void setLumiSegmentNr(const cms_uint16_t &lumiSegmentNrValue)
Definition: L1GtFdlWord.h:249
L1GlobalTriggerEvmRawToDigi::produceEmptyProducts
void produceEmptyProducts(edm::Event &)
produce empty products in case of problems
Definition: L1GlobaTriggerEvmRawToDigi.cc:730
L1GlobalTriggerEvmRawToDigi::m_l1GtBMToken
const edm::ESGetToken< L1GtBoardMaps, L1GtBoardMapsRcd > m_l1GtBMToken
EventSetup Token for L1GtBoardMaps.
Definition: L1GlobalTriggerEvmRawToDigi.h:87
L1GtfeExtWord::resize
void resize(int bstSizeBytes)
resize the BST vector to get the right size of the block
Definition: L1GtfeExtWord.cc:425
L1GtBoard.h
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:223
MessageDrop.h
edm::ParameterSet
Definition: ParameterSet.h:47
FEDTrailer
Definition: FEDTrailer.h:14
L1GlobalTriggerReadoutSetup.h
L1GtFdlWord::reset
void reset()
reset the content of a L1GtFdlWord
Definition: L1GtFdlWord.cc:567
FEDHeader::triggerType
uint8_t triggerType() const
Event Trigger type identifier.
Definition: FEDHeader.cc:13
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
L1GlobalTriggerEvmRawToDigi::m_isDebugEnabled
bool m_isDebugEnabled
Definition: L1GlobalTriggerEvmRawToDigi.h:123
L1GlobalTriggerEvmRawToDigi::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: L1GlobaTriggerEvmRawToDigi.cc:134
L1GtFdlWord
Definition: L1GtFdlWord.h:29
createfilelist.int
int
Definition: createfilelist.py:10
L1GlobalTriggerEvmRawToDigi::m_tcsWord
L1TcsWord * m_tcsWord
Definition: L1GlobalTriggerEvmRawToDigi.h:76
iEvent
int iEvent
Definition: GenABIO.cc:224
L1GtfeExtWord::print
void print(std::ostream &myCout) const override
pretty print the content of a L1GtfeExtWord
Definition: L1GtfeExtWord.cc:434
FEDTrailer::moreTrailers
bool moreTrailers() const
Definition: FEDTrailer.cc:21
L1GtFwd.h
FEDRawDataCollection.h
edm::EventSetup::getHandle
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:148
cms_uint64_t
unsigned long long cms_uint64_t
Definition: typedefs.h:17
GMT
Definition: L1GtDefinitions.h:28
L1GlobalTriggerEvmRawToDigi.h
cms_uint16_t
unsigned short cms_uint16_t
Definition: typedefs.h:13
edm::EventSetup
Definition: EventSetup.h:57
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
L1GlobalTriggerEvmRawToDigi::m_lowSkipBxInEvent
int m_lowSkipBxInEvent
Definition: L1GlobalTriggerEvmRawToDigi.h:100
L1GtFdlWord::lumiSegmentNr
const cms_uint16_t lumiSegmentNr() const
get/set luminosity segment number of the actual bx
Definition: L1GtFdlWord.h:247
L1GtfeWord.h
FEDRawData::size
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:45
L1GtfeExtWord
Definition: L1GtfeExtWord.h:31
FEDHeader::bxID
uint16_t bxID() const
The bunch crossing number.
Definition: FEDHeader.cc:17
InputTag.h
L1GlobalTriggerEvmRawToDigi::~L1GlobalTriggerEvmRawToDigi
~L1GlobalTriggerEvmRawToDigi() override
destructor
Definition: L1GlobaTriggerEvmRawToDigi.cc:125
L1GlobalTriggerEvmRawToDigi::unpackHeader
void unpackHeader(const unsigned char *, FEDHeader &)
block unpackers
Definition: L1GlobaTriggerEvmRawToDigi.cc:643
L1TcsWord::luminositySegmentNr
const cms_uint16_t luminositySegmentNr() const
get/set luminosity segment number
Definition: L1TcsWord.h:121
eostools.move
def move(src, dest)
Definition: eostools.py:511
L1GlobalTriggerEvmRawToDigi::m_verbosity
int m_verbosity
verbosity level
Definition: L1GlobalTriggerEvmRawToDigi.h:122
L1GlobalTriggerEvmRawToDigi::dumpFedRawData
void dumpFedRawData(const unsigned char *, int, std::ostream &)
dump FED raw data
Definition: L1GlobaTriggerEvmRawToDigi.cc:739
L1GlobalTriggerEvmRawToDigi::m_evmGtInputTag
edm::InputTag m_evmGtInputTag
input tags for GT EVM record
Definition: L1GlobalTriggerEvmRawToDigi.h:80
L1GtfeWord::recordLength1
const cms_uint16_t recordLength1() const
get/set record length for alternative 1
Definition: L1GtfeWord.h:71
L1GlobalTriggerEvmRawToDigi::m_bstLengthBytes
int m_bstLengthBytes
length of BST record (in bytes)
Definition: L1GlobalTriggerEvmRawToDigi.h:118
L1GtfeExtWord::getSize
const unsigned int getSize() const
get the size of the GTFE block in GT EVM record (in multiple of 8 bits)
Definition: L1GtfeExtWord.cc:402
L1GtFdlWord::getSize
const unsigned int getSize() const
get the size of the FDL block in GT DAQ record (in multiple of 8 bits)
Definition: L1GtFdlWord.h:271
L1GtFdlWord::print
void print(std::ostream &myCout) const
pretty print the content of a L1GtFdlWord
Definition: L1GtFdlWord.cc:595
EventSetup.h
FEDHeader::sourceID
uint16_t sourceID() const
Identifier of the FED.
Definition: FEDHeader.cc:19
L1GtBoardMaps::gtBoardMaps
const std::vector< L1GtBoard > & gtBoardMaps() const
get / set / print the L1 GT board map
Definition: L1GtBoardMaps.h:43
edm::isDebugEnabled
bool isDebugEnabled()
Definition: MessageLogger.cc:12
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:224
ParameterSet.h
L1GtBoardMapsRcd
Definition: L1GtBoardMapsRcd.h:39
FEDTrailer::ttsBits
uint8_t ttsBits() const
Current value of the Trigger Throttling System bits.
Definition: FEDTrailer.cc:19
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
FEDHeader
Definition: FEDHeader.h:14
edm::Event
Definition: Event.h:73
FEDHeader.h
L1GtfeWord::altNrBxBoard
const cms_uint16_t altNrBxBoard() const
get/set alternative for number of BX per board
Definition: L1GtfeWord.h:134
TauDecayModes.dec
dec
Definition: TauDecayModes.py:143
FEDTrailer::fragmentLength
uint32_t fragmentLength() const
The length of the event fragment counted in 64-bit words including header and trailer.
Definition: FEDTrailer.cc:13
FEDTrailer.h