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