60 m_evmGtInputTag(pSet.getParameter<
edm::
InputTag>(
"EvmGtInputTag")),
65 m_evmGtFedId(pSet.getUntrackedParameter<
int>(
"EvmGtFedId",
FEDNumbering::MINTriggerGTPFEDID)),
68 m_activeBoardsMaskGt(pSet.getParameter<unsigned
int>(
"ActiveBoardsMask")),
71 m_unpackBxInEvent(pSet.getParameter<
int>(
"UnpackBxInEvent")),
73 m_lowSkipBxInEvent(0),
74 m_uppSkipBxInEvent(0),
82 m_bstLengthBytes(pSet.getParameter<
int>(
"BstLengthBytes")),
84 m_verbosity(pSet.getUntrackedParameter<
int>(
"Verbosity", 0)),
89 produces<L1GlobalTriggerEvmReadoutRecord>();
92 LogDebug(
"L1GlobalTriggerEvmRawToDigi")
95 <<
"\nMask for active boards (hex format): " << std::hex << std::setw(
sizeof(
m_activeBoardsMaskGt) * 2)
107 <<
"\nWARNING: Number of bunch crossing to be unpacked rounded to: " <<
m_unpackBxInEvent
108 <<
"\n The number must be an odd number!\n"
139 const std::vector<L1GtBoard> boardMaps = l1GtBM->
gtBoardMaps();
140 int boardMapsSize = boardMaps.size();
142 typedef std::vector<L1GtBoard>::const_iterator CItBoardMaps;
147 std::vector<L1GtBoard> gtRecordMap;
148 gtRecordMap.reserve(boardMapsSize);
150 for (
int iPos = 0; iPos < boardMapsSize; ++iPos) {
151 for (CItBoardMaps itBoard = boardMaps.begin(); itBoard != boardMaps.end(); ++itBoard) {
152 if (itBoard->gtPositionEvmRecord() == iPos) {
153 gtRecordMap.push_back(*itBoard);
167 <<
"\nWarning: FEDRawDataCollection with input tag " <<
m_evmGtInputTag
168 <<
"\nrequested in configuration, but not found in the event."
169 <<
"\nQuit unpacking this event" << std::endl;
180 int gtSize = raw.
size();
183 const unsigned char* ptrGt = raw.
data();
186 const unsigned char* endPtrGt = ptrGt + gtSize;
190 LogTrace(
"L1GlobalTriggerEvmRawToDigi") <<
"\n Size of raw data: " << gtSize <<
"\n" << std::endl;
192 std::ostringstream myCoutStream;
195 LogTrace(
"L1GlobalTriggerEvmRawToDigi") <<
"\n Dump FEDRawData\n" << myCoutStream.str() <<
"\n" << std::endl;
201 if ((ptrGt + headerSize) > endPtrGt) {
202 edm::LogError(
"L1GlobalTriggerEvmRawToDigi") <<
"\nError: Pointer after header greater than end pointer."
203 <<
"\n Put empty products in the event!"
204 <<
"\n Quit unpacking this event." << std::endl;
212 FEDTrailer cmsTrailer(ptrGt + gtSize - headerSize);
220 bool gtfeUnpacked =
false;
224 int bstLengthBytes = 0;
241 LogTrace(
"L1GlobalTriggerEvmRawToDigi") <<
"\n Length of BST message (in bytes): " << bstLengthBytes <<
"\n"
245 for (CItBoardMaps itBoard = boardMaps.begin(); itBoard != boardMaps.end(); ++itBoard) {
246 if (itBoard->gtBoardType() ==
GTFE) {
248 if (itBoard->gtPositionEvmRecord() == 1) {
257 std::ostringstream myCoutStream;
259 LogTrace(
"L1GlobalTriggerEvmRawToDigi") << myCoutStream.str() <<
"\n" << std::endl;
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;
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;
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"
316 int numberGtfeBoards = 0;
317 int numberFdlBoards = 0;
318 int numberPsbBoards = 0;
319 int numberGmtBoards = 0;
320 int numberTcsBoards = 0;
321 int numberTimBoards = 0;
323 for (CItBoardMaps itBoard = boardMaps.begin(); itBoard != boardMaps.end(); ++itBoard) {
324 int iActiveBit = itBoard->gtBitEvmActiveBoards();
325 bool activeBoardToUnpack =
false;
327 if (iActiveBit >= 0) {
328 activeBoardToUnpack = activeBoardsGt & (1 << iActiveBit);
334 if (activeBoardToUnpack) {
335 switch (itBoard->gtBoardType()) {
369 LogDebug(
"L1GlobalTriggerEvmRawToDigi")
370 <<
"\nBoard of type " << itBoard->gtBoardType() <<
" not expected in record.\n"
393 std::unique_ptr<L1GlobalTriggerEvmReadoutRecord> gtReadoutRecord(
398 for (CItBoardMaps itBoard = gtRecordMap.begin(); itBoard != gtRecordMap.end(); ++itBoard) {
399 int iActiveBit = itBoard->gtBitEvmActiveBoards();
401 bool activeBoardToUnpack =
false;
402 bool activeBoardInitial =
false;
404 int altNrBxBoardVal = -1;
406 if (iActiveBit >= 0) {
407 activeBoardInitial = activeBoardsGtInitial & (1 << iActiveBit);
408 activeBoardToUnpack = activeBoardsGt & (1 << iActiveBit);
410 altNrBxBoardVal = (altNrBxBoardInitial & (1 << iActiveBit)) >> iActiveBit;
412 if (altNrBxBoardVal == 1) {
414 }
else if (altNrBxBoardVal == 0) {
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 "
436 LogDebug(
"L1GlobalTriggerEvmRawToDigi")
437 <<
"\nWARNING: Number of available bunch crosses for board" << (itBoard->gtBoardId())
439 <<
" ) \n is smaller than the number of bunch crosses requested to be unpacked (" <<
m_unpackBxInEvent
452 LogDebug(
"L1GlobalTriggerEvmRawToDigi")
463 LogDebug(
"L1GlobalTriggerEvmRawToDigi")
464 <<
"\nNo bxInEvent required to be unpacked from " <<
m_totalBxInEvent <<
" bunch crosses available."
496 if (!activeBoardInitial) {
498 LogDebug(
"L1GlobalTriggerEvmRawToDigi") <<
"\nBoard of type " << itBoard->gtBoardName() <<
" with index "
499 << itBoard->gtBoardIndex() <<
" not active initially in raw data.\n"
506 switch (itBoard->gtBoardType()) {
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;
522 if (activeBoardToUnpack) {
535 std::ostringstream myCoutStream;
537 LogTrace(
"L1GlobalTriggerEvmRawToDigi") << myCoutStream.str() <<
"\n" << std::endl;
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;
563 if (activeBoardToUnpack) {
578 std::ostringstream myCoutStream;
580 LogTrace(
"L1GlobalTriggerEvmRawToDigi") << myCoutStream.str() <<
"\n" << std::endl;
596 LogDebug(
"L1GlobalTriggerEvmRawToDigi")
597 <<
"\nBoard of type " << itBoard->gtBoardType() <<
" not expected in record.\n"
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;
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"
648 const cms_uint64_t*
payload = reinterpret_cast<cms_uint64_t*>(const_cast<unsigned char*>(gtPtr));
650 std::ostringstream myCoutStream;
655 myCoutStream << std::setw(4) << iWord <<
" " << std::hex << std::setfill(
'0') << std::setw(16) <<
payload[iWord]
656 <<
std::dec << std::setfill(
' ') <<
"\n"
659 myCoutStream <<
" Event_type: " << std::hex <<
" hex: "
660 <<
" " << std::setw(1) << std::setfill(
'0') << cmsHeader.
triggerType() << std::setfill(
' ')
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;
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;
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;
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;
679 myCoutStream <<
" H: " << std::hex <<
" hex: "
680 <<
" " << std::setw(1) << std::setfill(
'0') << cmsHeader.
moreHeaders() << std::setfill(
' ')
683 LogDebug(
"L1GlobalTriggerEvmRawToDigi") <<
"\n CMS Header \n" << myCoutStream.str() <<
"\n" << std::endl;
694 const cms_uint64_t*
payload = reinterpret_cast<cms_uint64_t*>(const_cast<unsigned char*>(trlPtr));
696 std::ostringstream myCoutStream;
701 myCoutStream << std::setw(4) << iWord <<
" " << std::hex << std::setfill(
'0') << std::setw(16) <<
payload[iWord]
702 <<
std::dec << std::setfill(
' ') <<
"\n"
705 myCoutStream <<
" Event_length: " << std::hex <<
" hex: "
706 <<
"" << std::setw(6) << std::setfill(
'0') << cmsTrailer.
fragmentLength() << std::setfill(
' ')
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;
713 myCoutStream <<
" Event_status: " << std::hex <<
" hex: "
714 <<
" " << std::setw(2) << std::setfill(
'0') << cmsTrailer.
evtStatus() << std::setfill(
' ')
717 myCoutStream <<
" TTS_bits: " << std::hex <<
" hex: "
718 <<
" " << std::setw(1) << std::setfill(
'0') << cmsTrailer.
ttsBits() << std::setfill(
' ')
721 myCoutStream <<
" More trailers: " << std::hex <<
" hex: "
722 <<
" " << std::setw(1) << std::setfill(
'0') << cmsTrailer.
moreTrailers() << std::setfill(
' ')
725 LogDebug(
"L1GlobalTriggerEvmRawToDigi") <<
"\n CMS Trailer \n" << myCoutStream.str() <<
"\n" << std::endl;
740 LogDebug(
"L1GlobalTriggerEvmRawToDigi") <<
"\nDump FED raw data.\n" << std::endl;
745 int gtWords = gtSize / uLength;
746 LogTrace(
"L1GlobalTriggerEvmRawToDigi") <<
"\nFED GT words (" << wLength <<
" bits):" << gtWords <<
"\n" << std::endl;
748 const cms_uint64_t*
payload = reinterpret_cast<cms_uint64_t*>(const_cast<unsigned char*>(gtPtr));
751 myCout << std::setw(4) <<
i <<
" " << std::hex << std::setfill(
'0') << std::setw(16) <<
payload[
i] <<
std::dec
752 << std::setfill(
' ') << std::endl;