57 m_daqGtFedId(pSet.getUntrackedParameter<
int>(
"DaqGtFedId",
FEDNumbering::MAXTriggerGTPFEDID)),
60 m_daqGtInputTag(pSet.getParameter<
edm::
InputTag>(
"DaqGtInputTag")),
61 m_muGmtInputTag(pSet.getParameter<
edm::
InputTag>(
"MuGmtInputTag")),
63 m_activeBoardsMaskGt(pSet.getParameter<unsigned
int>(
"ActiveBoardsMask")),
67 m_verbosity(pSet.getUntrackedParameter<
int>(
"Verbosity", 0)),
75 <<
"\nMask for active boards (hex format): " << std::hex
82 produces<FEDRawDataCollection>();
100 const std::vector<L1GtBoard> boardMaps = l1GtBM->
gtBoardMaps();
101 int boardMapsSize = boardMaps.size();
103 typedef std::vector<L1GtBoard>::const_iterator CItBoardMaps;
108 std::vector<L1GtBoard> gtRecordMap;
109 gtRecordMap.reserve(boardMapsSize);
111 for (
int iPos = 0; iPos < boardMapsSize; ++iPos) {
112 for (CItBoardMaps itBoard = boardMaps.begin(); itBoard != boardMaps.end(); ++itBoard) {
113 if (itBoard->gtPositionDaqRecord() == iPos) {
114 gtRecordMap.push_back(*itBoard);
124 if (!gtReadoutRecord.
isValid()) {
127 <<
"\nrequested in configuration, but not found in the event."
128 <<
"\nQuit packing this event" << std::endl;
138 std::ostringstream myCoutStream;
139 gtReadoutRecord->
print(myCoutStream);
140 LogTrace(
"L1GTDigiToRaw") <<
"\n The following L1 GT DAQ readout record will be packed.\n"
141 <<
" Some boards could be disabled before packing,"
142 <<
" see detailed board packing.\n"
143 << myCoutStream.str() <<
"\n"
166 LogDebug(
"L1GTDigiToRaw") <<
"\nActive boards before masking(hex format): " << std::hex
167 << std::setw(
sizeof(activeBoardsGtInitial) * 2) << std::setfill(
'0')
168 << activeBoardsGtInitial <<
std::dec << std::setfill(
' ')
169 <<
"Active boards after masking(hex format): " << std::hex
170 << std::setw(
sizeof(activeBoardsGt) * 2) << std::setfill(
'0') << activeBoardsGt
171 <<
std::dec << std::setfill(
' ') <<
" \n"
177 unsigned int gtDataSize = 0;
179 unsigned int headerSize = 8;
180 gtDataSize += headerSize;
182 for (CItBoardMaps itBoard = boardMaps.begin(); itBoard != boardMaps.end(); ++itBoard) {
183 if (itBoard->gtBoardType() ==
GTFE) {
184 gtDataSize += gtfeBlock.
getSize();
188 int iActiveBit = itBoard->gtBitDaqActiveBoards();
189 bool activeBoardToPack =
false;
191 int altNrBxBoardVal = -1;
193 if (iActiveBit >= 0) {
194 activeBoardToPack = activeBoardsGt & (1 << iActiveBit);
196 altNrBxBoardVal = (altNrBxBoardInitial & (1 << iActiveBit)) >> iActiveBit;
198 if (altNrBxBoardVal == 1) {
200 }
else if (altNrBxBoardVal == 0) {
205 <<
"\n\nWARNING: Wrong value altNrBxBoardVal = " << altNrBxBoardVal <<
" for board " << std::hex
206 << (itBoard->gtBoardId()) <<
std::dec <<
"\n iActiveBit = " << iActiveBit
207 <<
"\n altNrBxBoardInitial = 0x" << std::hex << altNrBxBoardInitial <<
std::dec
208 <<
"\n activeBoardsGt = 0x" << std::hex << activeBoardsGt <<
std::dec
209 <<
"\n activeBoardToPack = " << activeBoardToPack <<
"\n Set altNrBxBoardVal tentatively to "
210 << recordLength0 <<
"\n Job may crash or produce wrong results!\n\n"
222 if (activeBoardToPack) {
223 switch (itBoard->gtBoardType()) {
243 unsigned int gmtRecordSize = 136;
245 gtDataSize += gmtCollSize;
251 gtDataSize += tcsBlock.
getSize();
269 unsigned int trailerSize = 8;
270 gtDataSize += trailerSize;
274 gtRawData.
resize(gtDataSize);
278 unsigned char* ptrGt = gtRawData.
data();
279 unsigned char* ptrGtBegin = gtRawData.
data();
282 LogDebug(
"L1GTDigiToRaw") <<
"\n Size of raw data: " << gtRawData.
size() <<
"\n" << std::endl;
293 for (CItBoardMaps itBoard = gtRecordMap.begin(); itBoard != gtRecordMap.end(); ++itBoard) {
294 if (itBoard->gtBoardType() ==
GTFE) {
295 packGTFE(evSetup, ptrGt, gtfeBlock, activeBoardsGt);
298 std::ostringstream myCoutStream;
299 gtfeBlock.
print(myCoutStream);
300 LogTrace(
"L1GTDigiToRaw") << myCoutStream.str() <<
"\n" << std::endl;
310 int iActiveBit = itBoard->gtBitDaqActiveBoards();
311 bool activeBoardToPack =
false;
313 int altNrBxBoardVal = -1;
315 if (iActiveBit >= 0) {
316 activeBoardToPack = activeBoardsGt & (1 << iActiveBit);
318 altNrBxBoardVal = (altNrBxBoardInitial & (1 << iActiveBit)) >> iActiveBit;
320 if (altNrBxBoardVal == 1) {
322 }
else if (altNrBxBoardVal == 0) {
327 <<
"\n\nWARNING: Wrong value altNrBxBoardVal = " << altNrBxBoardVal <<
" for board " << std::hex
328 << (itBoard->gtBoardId()) <<
std::dec <<
"\n iActiveBit = " << iActiveBit
329 <<
"\n altNrBxBoardInitial = 0x" << std::hex << altNrBxBoardInitial <<
std::dec
330 <<
"\n activeBoardsGt = 0x" << std::hex << activeBoardsGt <<
std::dec
331 <<
"\n activeBoardToPack = " << activeBoardToPack <<
"\n Set altNrBxBoardVal tentatively to "
332 << recordLength0 <<
"\n Job may crash or produce wrong results!\n\n"
347 if (activeBoardToPack) {
349 LogDebug(
"L1GTDigiToRaw") <<
"\nBoard " << std::hex <<
"0x" << (itBoard->gtBoardId()) <<
std::dec
350 <<
"\n Number of bunch crosses in the record: " <<
m_totalBxInEvent <<
" = "
356 switch (itBoard->gtBoardType()) {
360 packFDL(evSetup, ptrGt, fdlBlock);
363 std::ostringstream myCoutStream;
364 fdlBlock.
print(myCoutStream);
365 LogTrace(
"L1GTDigiToRaw") << myCoutStream.str() <<
"\n" << std::endl;
374 LogDebug(
"L1GTDigiToRaw") <<
"\nBoard of type " << itBoard->gtBoardName() <<
" with index "
375 << itBoard->gtBoardIndex() <<
" and boardId " << std::hex << itBoard->gtBoardId()
383 packPSB(evSetup, ptrGt, psbBlock);
386 std::ostringstream myCoutStream;
387 psbBlock.
print(myCoutStream);
388 LogTrace(
"L1GTDigiToRaw") << myCoutStream.str() <<
"\n" << std::endl;
402 <<
"\nWarning: L1MuGMTReadoutCollection with input tag " <<
m_muGmtInputTag
403 <<
"\nrequested in configuration, but not found in the event."
404 <<
"\nQuit packing this event" << std::endl;
419 unsigned int gmtCollSize = 0;
421 ptrGt += gmtCollSize;
444 int triggerTypeVal = 0;
447 int lvl1IdVal =
iEvent.id().event();
450 int bxCross =
iEvent.bunchCrossing();
452 if ((bxCross & 0xFFF) == bxCross) {
453 bxCrossHw = static_cast<cms_uint16_t>(bxCross);
457 LogDebug(
"L1GTDigiToRaw") <<
"\nBunch cross number [hex] = " << std::hex << bxCross
458 <<
"\n larger than 12 bits. Set to 0! \n"
462 int bxIdVal = bxCrossHw;
473 bool moreHeadersVal =
false;
477 gtFEDHeader.
set(ptrGt, triggerTypeVal, lvl1IdVal, bxIdVal, sourceIdVal, versionVal, moreHeadersVal);
482 unsigned char* ptrGt,
486 LogDebug(
"L1GTDigiToRaw") <<
"\nPacking GTFE \n" << std::endl;
492 int nrWord64 = gtfeBlock.
getSize() / uLength;
493 std::vector<cms_uint64_t> tmpWord64;
494 tmpWord64.resize(nrWord64);
496 for (
int iWord = 0; iWord < nrWord64; ++iWord) {
497 tmpWord64[iWord] = 0x0000000000000000ULL;
501 for (
int iWord = 0; iWord < nrWord64; ++iWord) {
514 cms_uint64_t* pw = reinterpret_cast<cms_uint64_t*>(const_cast<unsigned char*>(ptrGt));
516 for (
int iWord = 0; iWord < nrWord64; ++iWord) {
517 *pw++ = tmpWord64[iWord];
520 LogTrace(
"L1GTDigiToRaw") << std::setw(4) << iWord <<
" " << std::hex << std::setfill(
'0') << std::setw(16)
521 << tmpWord64[iWord] <<
std::dec << std::setfill(
' ') << std::endl;
529 LogDebug(
"L1GTDigiToRaw") <<
"\nPacking FDL \n" << std::endl;
535 int nrWord64 = fdlBlock.
getSize() / uLength;
536 std::vector<cms_uint64_t> tmpWord64;
537 tmpWord64.resize(nrWord64);
539 for (
int iWord = 0; iWord < nrWord64; ++iWord) {
540 tmpWord64[iWord] = 0x0000000000000000ULL;
544 for (
int iWord = 0; iWord < nrWord64; ++iWord) {
570 cms_uint64_t* pw = reinterpret_cast<cms_uint64_t*>(const_cast<unsigned char*>(ptrGt));
572 for (
int iWord = 0; iWord < nrWord64; ++iWord) {
573 *pw++ = tmpWord64[iWord];
576 LogTrace(
"L1GTDigiToRaw") << std::setw(4) << iWord <<
" " << std::hex << std::setfill(
'0') << std::setw(16)
577 << tmpWord64[iWord] <<
std::dec << std::setfill(
' ') << std::endl;
585 LogDebug(
"L1GTDigiToRaw") <<
"\nPacking PSB \n" << std::endl;
591 int nrWord64 = psbBlock.
getSize() / uLength;
592 std::vector<cms_uint64_t> tmpWord64;
593 tmpWord64.resize(nrWord64);
595 for (
int iWord = 0; iWord < nrWord64; ++iWord) {
596 tmpWord64[iWord] = 0x0000000000000000ULL;
600 for (
int iWord = 0; iWord < nrWord64; ++iWord) {
614 cms_uint64_t* pw = reinterpret_cast<cms_uint64_t*>(const_cast<unsigned char*>(ptrGt));
616 for (
int iWord = 0; iWord < nrWord64; ++iWord) {
617 *pw++ = tmpWord64[iWord];
620 LogTrace(
"L1GTDigiToRaw") << std::setw(4) << iWord <<
" " << std::hex << std::setfill(
'0') << std::setw(16)
621 << tmpWord64[iWord] <<
std::dec << std::setfill(
' ') << std::endl;
629 LogDebug(
"L1GTDigiToRaw") <<
"\nPacking GMT collection \n" << std::endl;
632 unsigned gmtsize = 0;
637 gmtsize =
packGMT(gmtrr, ptrGt);
646 const unsigned SIZE = 136;
647 const unsigned boardId = 0xdd12;
648 memset(chp, 0,
SIZE);
650 unsigned*
p = (
unsigned*)chp;
657 std::vector<L1MuRegionalCand> vrc;
658 std::vector<L1MuRegionalCand>::const_iterator irc;
663 for (irc = vrc.begin(); irc != vrc.end(); irc++) {
664 *
pp++ = (*irc).getDataWord();
670 for (irc = vrc.begin(); irc != vrc.end(); irc++) {
671 *
pp++ = (*irc).getDataWord();
677 for (irc = vrc.begin(); irc != vrc.end(); irc++) {
678 *
pp++ = (*irc).getDataWord();
684 for (irc = vrc.begin(); irc != vrc.end(); irc++) {
685 *
pp++ = (*irc).getDataWord();
691 for (
int i = 0;
i < 16;
i++) {
693 *
pp++ = (
w & 0xffff00ff) | ((~
w) & 0x0000ff00);
696 std::vector<L1MuGMTExtendedCand> vgc;
697 std::vector<L1MuGMTExtendedCand>::const_iterator igc;
701 for (igc = vgc.begin(); igc != vgc.end(); igc++) {
702 *
pp++ = (*igc).getDataWord();
708 for (igc = vgc.begin(); igc != vgc.end(); igc++) {
709 *
pp++ = (*igc).getDataWord();
715 for (igc = vgc.begin(); igc != vgc.end(); igc++) {
716 *
pp++ = (*igc).getDataWord();
723 chpp = (
unsigned char*)
p;
724 for (igc = vgc.begin(); igc != vgc.end(); igc++) {
725 *chpp++ = (*igc).rank();
730 chpp = (
unsigned char*)
p;
731 for (igc = vgc.begin(); igc != vgc.end(); igc++) {
732 *chpp++ = (*igc).rank();
746 int lengthVal = dataSize / 8;
752 int evtStatusVal = 0;
760 bool moreTrailersVal =
false;
763 gtFEDTrailer.
set(ptrGt, lengthVal, crcVal, evtStatusVal, ttsBitsVal, moreTrailersVal);