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