CMS 3D CMS Logo

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