60 m_daqGtFedId(pSet.getUntrackedParameter<
int>(
"DaqGtFedId",
FEDNumbering::MAXTriggerGTPFEDID)),
63 m_daqGtInputTag(pSet.getParameter<
edm::
InputTag>(
"DaqGtInputTag")),
64 m_muGmtInputTag(pSet.getParameter<
edm::
InputTag>(
"MuGmtInputTag")),
65 m_activeBoardsMaskGt(pSet.getParameter<unsigned
int>(
"ActiveBoardsMask")),
69 m_verbosity(pSet.getUntrackedParameter<
int>(
"Verbosity", 0)),
77 <<
"\nMask for active boards (hex format): " << std::hex
84 produces<FEDRawDataCollection>();
103 const std::vector<L1GtBoard> boardMaps = l1GtBM->
gtBoardMaps();
104 int boardMapsSize = boardMaps.size();
106 typedef std::vector<L1GtBoard>::const_iterator CItBoardMaps;
111 std::vector<L1GtBoard> gtRecordMap;
112 gtRecordMap.reserve(boardMapsSize);
114 for (
int iPos = 0; iPos < boardMapsSize; ++iPos) {
115 for (CItBoardMaps itBoard = boardMaps.begin(); itBoard != boardMaps.end(); ++itBoard) {
116 if (itBoard->gtPositionDaqRecord() == iPos) {
117 gtRecordMap.push_back(*itBoard);
127 if (!gtReadoutRecord.
isValid()) {
130 <<
"\nrequested in configuration, but not found in the event."
131 <<
"\nQuit packing this event" << std::endl;
141 std::ostringstream myCoutStream;
142 gtReadoutRecord->
print(myCoutStream);
143 LogTrace(
"L1GTDigiToRaw") <<
"\n The following L1 GT DAQ readout record will be packed.\n"
144 <<
" Some boards could be disabled before packing,"
145 <<
" see detailed board packing.\n"
146 << myCoutStream.str() <<
"\n"
169 LogDebug(
"L1GTDigiToRaw") <<
"\nActive boards before masking(hex format): " << std::hex
170 << std::setw(
sizeof(activeBoardsGtInitial) * 2) << std::setfill(
'0')
171 << activeBoardsGtInitial <<
std::dec << std::setfill(
' ')
172 <<
"Active boards after masking(hex format): " << std::hex
173 << std::setw(
sizeof(activeBoardsGt) * 2) << std::setfill(
'0') << activeBoardsGt
174 <<
std::dec << std::setfill(
' ') <<
" \n"
180 unsigned int gtDataSize = 0;
182 unsigned int headerSize = 8;
183 gtDataSize += headerSize;
185 for (CItBoardMaps itBoard = boardMaps.begin(); itBoard != boardMaps.end(); ++itBoard) {
186 if (itBoard->gtBoardType() ==
GTFE) {
187 gtDataSize += gtfeBlock.
getSize();
191 int iActiveBit = itBoard->gtBitDaqActiveBoards();
192 bool activeBoardToPack =
false;
194 int altNrBxBoardVal = -1;
196 if (iActiveBit >= 0) {
197 activeBoardToPack = activeBoardsGt & (1 << iActiveBit);
199 altNrBxBoardVal = (altNrBxBoardInitial & (1 << iActiveBit)) >> iActiveBit;
201 if (altNrBxBoardVal == 1) {
203 }
else if (altNrBxBoardVal == 0) {
208 <<
"\n\nWARNING: Wrong value altNrBxBoardVal = " << altNrBxBoardVal <<
" for board " << std::hex
209 << (itBoard->gtBoardId()) <<
std::dec <<
"\n iActiveBit = " << iActiveBit
210 <<
"\n altNrBxBoardInitial = 0x" << std::hex << altNrBxBoardInitial <<
std::dec
211 <<
"\n activeBoardsGt = 0x" << std::hex << activeBoardsGt <<
std::dec
212 <<
"\n activeBoardToPack = " << activeBoardToPack <<
"\n Set altNrBxBoardVal tentatively to "
213 << recordLength0 <<
"\n Job may crash or produce wrong results!\n\n"
225 if (activeBoardToPack) {
226 switch (itBoard->gtBoardType()) {
246 unsigned int gmtRecordSize = 136;
248 gtDataSize += gmtCollSize;
254 gtDataSize += tcsBlock.
getSize();
272 unsigned int trailerSize = 8;
273 gtDataSize += trailerSize;
277 gtRawData.
resize(gtDataSize);
281 unsigned char* ptrGt = gtRawData.
data();
282 unsigned char* ptrGtBegin = gtRawData.
data();
285 LogDebug(
"L1GTDigiToRaw") <<
"\n Size of raw data: " << gtRawData.
size() <<
"\n" << std::endl;
296 for (CItBoardMaps itBoard = gtRecordMap.begin(); itBoard != gtRecordMap.end(); ++itBoard) {
297 if (itBoard->gtBoardType() ==
GTFE) {
298 packGTFE(evSetup, ptrGt, gtfeBlock, activeBoardsGt);
301 std::ostringstream myCoutStream;
302 gtfeBlock.
print(myCoutStream);
303 LogTrace(
"L1GTDigiToRaw") << myCoutStream.str() <<
"\n" << std::endl;
313 int iActiveBit = itBoard->gtBitDaqActiveBoards();
314 bool activeBoardToPack =
false;
316 int altNrBxBoardVal = -1;
318 if (iActiveBit >= 0) {
319 activeBoardToPack = activeBoardsGt & (1 << iActiveBit);
321 altNrBxBoardVal = (altNrBxBoardInitial & (1 << iActiveBit)) >> iActiveBit;
323 if (altNrBxBoardVal == 1) {
325 }
else if (altNrBxBoardVal == 0) {
330 <<
"\n\nWARNING: Wrong value altNrBxBoardVal = " << altNrBxBoardVal <<
" for board " << std::hex
331 << (itBoard->gtBoardId()) <<
std::dec <<
"\n iActiveBit = " << iActiveBit
332 <<
"\n altNrBxBoardInitial = 0x" << std::hex << altNrBxBoardInitial <<
std::dec
333 <<
"\n activeBoardsGt = 0x" << std::hex << activeBoardsGt <<
std::dec
334 <<
"\n activeBoardToPack = " << activeBoardToPack <<
"\n Set altNrBxBoardVal tentatively to "
335 << recordLength0 <<
"\n Job may crash or produce wrong results!\n\n"
350 if (activeBoardToPack) {
352 LogDebug(
"L1GTDigiToRaw") <<
"\nBoard " << std::hex <<
"0x" << (itBoard->gtBoardId()) <<
std::dec
353 <<
"\n Number of bunch crosses in the record: " <<
m_totalBxInEvent <<
" = "
359 switch (itBoard->gtBoardType()) {
363 packFDL(evSetup, ptrGt, fdlBlock);
366 std::ostringstream myCoutStream;
367 fdlBlock.
print(myCoutStream);
368 LogTrace(
"L1GTDigiToRaw") << myCoutStream.str() <<
"\n" << std::endl;
377 LogDebug(
"L1GTDigiToRaw") <<
"\nBoard of type " << itBoard->gtBoardName() <<
" with index "
378 << itBoard->gtBoardIndex() <<
" and boardId " << std::hex << itBoard->gtBoardId()
386 packPSB(evSetup, ptrGt, psbBlock);
389 std::ostringstream myCoutStream;
390 psbBlock.
print(myCoutStream);
391 LogTrace(
"L1GTDigiToRaw") << myCoutStream.str() <<
"\n" << std::endl;
405 <<
"\nWarning: L1MuGMTReadoutCollection with input tag " <<
m_muGmtInputTag
406 <<
"\nrequested in configuration, but not found in the event."
407 <<
"\nQuit packing this event" << std::endl;
422 unsigned int gmtCollSize = 0;
424 ptrGt += gmtCollSize;
447 int triggerTypeVal = 0;
450 int lvl1IdVal =
iEvent.id().event();
453 int bxCross =
iEvent.bunchCrossing();
455 if ((bxCross & 0xFFF) == bxCross) {
456 bxCrossHw = static_cast<cms_uint16_t>(bxCross);
460 LogDebug(
"L1GTDigiToRaw") <<
"\nBunch cross number [hex] = " << std::hex << bxCross
461 <<
"\n larger than 12 bits. Set to 0! \n"
465 int bxIdVal = bxCrossHw;
476 bool moreHeadersVal =
false;
480 gtFEDHeader.
set(ptrGt, triggerTypeVal, lvl1IdVal, bxIdVal, sourceIdVal, versionVal, moreHeadersVal);
485 unsigned char* ptrGt,
489 LogDebug(
"L1GTDigiToRaw") <<
"\nPacking GTFE \n" << std::endl;
495 int nrWord64 = gtfeBlock.
getSize() / uLength;
496 std::vector<cms_uint64_t> tmpWord64;
497 tmpWord64.resize(nrWord64);
499 for (
int iWord = 0; iWord < nrWord64; ++iWord) {
500 tmpWord64[iWord] = 0x0000000000000000ULL;
504 for (
int iWord = 0; iWord < nrWord64; ++iWord) {
517 cms_uint64_t* pw = reinterpret_cast<cms_uint64_t*>(const_cast<unsigned char*>(ptrGt));
519 for (
int iWord = 0; iWord < nrWord64; ++iWord) {
520 *pw++ = tmpWord64[iWord];
523 LogTrace(
"L1GTDigiToRaw") << std::setw(4) << iWord <<
" " << std::hex << std::setfill(
'0') << std::setw(16)
524 << tmpWord64[iWord] <<
std::dec << std::setfill(
' ') << std::endl;
532 LogDebug(
"L1GTDigiToRaw") <<
"\nPacking FDL \n" << std::endl;
538 int nrWord64 = fdlBlock.
getSize() / uLength;
539 std::vector<cms_uint64_t> tmpWord64;
540 tmpWord64.resize(nrWord64);
542 for (
int iWord = 0; iWord < nrWord64; ++iWord) {
543 tmpWord64[iWord] = 0x0000000000000000ULL;
547 for (
int iWord = 0; iWord < nrWord64; ++iWord) {
573 cms_uint64_t* pw = reinterpret_cast<cms_uint64_t*>(const_cast<unsigned char*>(ptrGt));
575 for (
int iWord = 0; iWord < nrWord64; ++iWord) {
576 *pw++ = tmpWord64[iWord];
579 LogTrace(
"L1GTDigiToRaw") << std::setw(4) << iWord <<
" " << std::hex << std::setfill(
'0') << std::setw(16)
580 << tmpWord64[iWord] <<
std::dec << std::setfill(
' ') << std::endl;
588 LogDebug(
"L1GTDigiToRaw") <<
"\nPacking PSB \n" << std::endl;
594 int nrWord64 = psbBlock.
getSize() / uLength;
595 std::vector<cms_uint64_t> tmpWord64;
596 tmpWord64.resize(nrWord64);
598 for (
int iWord = 0; iWord < nrWord64; ++iWord) {
599 tmpWord64[iWord] = 0x0000000000000000ULL;
603 for (
int iWord = 0; iWord < nrWord64; ++iWord) {
617 cms_uint64_t* pw = reinterpret_cast<cms_uint64_t*>(const_cast<unsigned char*>(ptrGt));
619 for (
int iWord = 0; iWord < nrWord64; ++iWord) {
620 *pw++ = tmpWord64[iWord];
623 LogTrace(
"L1GTDigiToRaw") << std::setw(4) << iWord <<
" " << std::hex << std::setfill(
'0') << std::setw(16)
624 << tmpWord64[iWord] <<
std::dec << std::setfill(
' ') << std::endl;
632 LogDebug(
"L1GTDigiToRaw") <<
"\nPacking GMT collection \n" << std::endl;
635 unsigned gmtsize = 0;
640 gmtsize =
packGMT(gmtrr, ptrGt);
649 const unsigned SIZE = 136;
650 const unsigned boardId = 0xdd12;
651 memset(chp, 0,
SIZE);
653 unsigned*
p = (
unsigned*)chp;
660 std::vector<L1MuRegionalCand> vrc;
661 std::vector<L1MuRegionalCand>::const_iterator irc;
666 for (irc = vrc.begin(); irc != vrc.end(); irc++) {
667 *
pp++ = (*irc).getDataWord();
673 for (irc = vrc.begin(); irc != vrc.end(); irc++) {
674 *
pp++ = (*irc).getDataWord();
680 for (irc = vrc.begin(); irc != vrc.end(); irc++) {
681 *
pp++ = (*irc).getDataWord();
687 for (irc = vrc.begin(); irc != vrc.end(); irc++) {
688 *
pp++ = (*irc).getDataWord();
694 for (
int i = 0;
i < 16;
i++) {
696 *
pp++ = (
w & 0xffff00ff) | ((~
w) & 0x0000ff00);
699 std::vector<L1MuGMTExtendedCand> vgc;
700 std::vector<L1MuGMTExtendedCand>::const_iterator igc;
704 for (igc = vgc.begin(); igc != vgc.end(); igc++) {
705 *
pp++ = (*igc).getDataWord();
711 for (igc = vgc.begin(); igc != vgc.end(); igc++) {
712 *
pp++ = (*igc).getDataWord();
718 for (igc = vgc.begin(); igc != vgc.end(); igc++) {
719 *
pp++ = (*igc).getDataWord();
726 chpp = (
unsigned char*)
p;
727 for (igc = vgc.begin(); igc != vgc.end(); igc++) {
728 *chpp++ = (*igc).rank();
733 chpp = (
unsigned char*)
p;
734 for (igc = vgc.begin(); igc != vgc.end(); igc++) {
735 *chpp++ = (*igc).rank();
749 int lengthVal = dataSize / 8;
755 int evtStatusVal = 0;
763 bool moreTrailersVal =
false;
766 gtFEDTrailer.
set(ptrGt, lengthVal, crcVal, evtStatusVal, ttsBitsVal, moreTrailersVal);