53 : m_evmGtFedId(pSet.getUntrackedParameter<
int>(
"EvmGtFedId",
FEDNumbering::MINTriggerGTPFEDID)),
55 m_evmGtInputTag(pSet.getParameter<
edm::
InputTag>(
"EvmGtInputTag")),
56 m_activeBoardsMaskGt(pSet.getParameter<unsigned
int>(
"ActiveBoardsMask")),
60 m_verbosity(pSet.getUntrackedParameter<
int>(
"Verbosity", 0)),
64 LogDebug(
"L1GTEvmDigiToRaw") <<
"\nMask for active boards (hex format): " << std::hex
68 <<
"\nFED Id for EVM GT record: " <<
m_evmGtFedId <<
" \n"
72 produces<FEDRawDataCollection>();
91 const std::vector<L1GtBoard> boardMaps = l1GtBM->
gtBoardMaps();
92 int boardMapsSize = boardMaps.size();
94 typedef std::vector<L1GtBoard>::const_iterator CItBoardMaps;
99 std::vector<L1GtBoard> gtRecordMap;
100 gtRecordMap.reserve(boardMapsSize);
102 for (
int iPos = 0; iPos < boardMapsSize; ++iPos) {
103 for (CItBoardMaps itBoard = boardMaps.begin(); itBoard != boardMaps.end(); ++itBoard) {
104 if (itBoard->gtPositionEvmRecord() == iPos) {
105 gtRecordMap.push_back(*itBoard);
115 if (!gtReadoutRecord.
isValid()) {
116 edm::LogWarning(
"L1GTEvmDigiToRaw") <<
"\nWarning: L1GlobalTriggerEvmReadoutRecord with input tag "
118 <<
"\nrequested in configuration, but not found in the event."
119 <<
"\nQuit packing this event" << std::endl;
128 std::ostringstream myCoutStream;
129 gtReadoutRecord->
print(myCoutStream);
130 LogTrace(
"L1GTEvmDigiToRaw") <<
"\n The following L1 GT EVM readout record will be packed.\n"
131 <<
" Some boards could be disabled before packing,"
132 <<
" see detailed board packing.\n"
133 << myCoutStream.str() <<
"\n"
159 LogDebug(
"L1GTEvmDigiToRaw") <<
"\nActive boards before masking(hex format): " << std::hex
160 << std::setw(
sizeof(activeBoardsGtInitial) * 2) << std::setfill(
'0')
161 << activeBoardsGtInitial <<
std::dec << std::setfill(
' ')
162 <<
"\nActive boards after masking(hex format): " << std::hex
163 << std::setw(
sizeof(activeBoardsGt) * 2) << std::setfill(
'0') << activeBoardsGt
164 <<
std::dec << std::setfill(
' ') <<
" \n"
170 unsigned int gtDataSize = 0;
172 unsigned int headerSize = 8;
173 gtDataSize += headerSize;
175 for (CItBoardMaps itBoard = boardMaps.begin(); itBoard != boardMaps.end(); ++itBoard) {
176 if (itBoard->gtBoardType() ==
GTFE) {
177 gtDataSize += gtfeBlock.
getSize();
181 int iActiveBit = itBoard->gtBitEvmActiveBoards();
182 bool activeBoardToPack =
false;
184 int altNrBxBoardVal = -1;
186 if (iActiveBit >= 0) {
187 activeBoardToPack = activeBoardsGt & (1 << iActiveBit);
189 altNrBxBoardVal = (altNrBxBoardInitial & (1 << iActiveBit)) >> iActiveBit;
191 if (altNrBxBoardVal == 1) {
193 }
else if (altNrBxBoardVal == 0) {
198 <<
"\n\nWARNING: Wrong value altNrBxBoardVal = " << altNrBxBoardVal <<
" for board " << std::hex
199 << (itBoard->gtBoardId()) <<
std::dec <<
"\n iActiveBit = " << iActiveBit
200 <<
"\n altNrBxBoardInitial = 0x" << std::hex << altNrBxBoardInitial <<
std::dec
201 <<
"\n activeBoardsGt = 0x" << std::hex << activeBoardsGt <<
std::dec
202 <<
"\n activeBoardToPack = " << activeBoardToPack <<
"\n Set altNrBxBoardVal tentatively to "
203 << recordLength0 <<
"\n Job may crash or produce wrong results!\n\n"
214 if (activeBoardToPack) {
215 switch (itBoard->gtBoardType()) {
229 gtDataSize += tcsBlock.
getSize();
247 unsigned int trailerSize = 8;
248 gtDataSize += trailerSize;
252 gtRawData.
resize(gtDataSize);
256 unsigned char* ptrGt = gtRawData.
data();
257 unsigned char* ptrGtBegin = gtRawData.
data();
260 LogDebug(
"L1GTEvmDigiToRaw") <<
"\n Size of raw data: " << gtRawData.
size() <<
"\n" << std::endl;
271 for (CItBoardMaps itBoard = gtRecordMap.begin(); itBoard != gtRecordMap.end(); ++itBoard) {
272 if (itBoard->gtBoardType() ==
GTFE) {
273 packGTFE(evSetup, ptrGt, gtfeBlock, activeBoardsGt);
276 std::ostringstream myCoutStream;
277 gtfeBlock.
print(myCoutStream);
278 LogTrace(
"L1GTEvmDigiToRaw") << myCoutStream.str() <<
"\n" << std::endl;
288 int iActiveBit = itBoard->gtBitEvmActiveBoards();
289 bool activeBoardToPack =
false;
291 int altNrBxBoardVal = -1;
293 if (iActiveBit >= 0) {
294 activeBoardToPack = activeBoardsGt & (1 << iActiveBit);
296 altNrBxBoardVal = (altNrBxBoardInitial & (1 << iActiveBit)) >> iActiveBit;
298 if (altNrBxBoardVal == 1) {
300 }
else if (altNrBxBoardVal == 0) {
305 <<
"\n\nWARNING: Wrong value altNrBxBoardVal = " << altNrBxBoardVal <<
" for board " << std::hex
306 << (itBoard->gtBoardId()) <<
std::dec <<
"\n iActiveBit = " << iActiveBit
307 <<
"\n altNrBxBoardInitial = 0x" << std::hex << altNrBxBoardInitial <<
std::dec
308 <<
"\n activeBoardsGt = 0x" << std::hex << activeBoardsGt <<
std::dec
309 <<
"\n activeBoardToPack = " << activeBoardToPack <<
"\n Set altNrBxBoardVal tentatively to "
310 << recordLength0 <<
"\n Job may crash or produce wrong results!\n\n"
325 if (activeBoardToPack) {
327 LogDebug(
"L1GTEvmDigiToRaw") <<
"\nBoard " << std::hex <<
"0x" << (itBoard->gtBoardId()) <<
std::dec
328 <<
"\n Number of bunch crosses in the record: " <<
m_totalBxInEvent <<
" = "
334 switch (itBoard->gtBoardType()) {
337 packTCS(evSetup, ptrGt, tcsBlock);
340 std::ostringstream myCoutStream;
341 tcsBlock.
print(myCoutStream);
342 LogTrace(
"L1GTEvmDigiToRaw") << myCoutStream.str() <<
"\n" << std::endl;
351 packFDL(evSetup, ptrGt, fdlBlock);
354 std::ostringstream myCoutStream;
355 fdlBlock.
print(myCoutStream);
356 LogTrace(
"L1GTEvmDigiToRaw") << myCoutStream.str() <<
"\n" << std::endl;
384 int triggerTypeVal = 0;
387 int lvl1IdVal =
iEvent.id().event();
390 int bxCross =
iEvent.bunchCrossing();
392 if ((bxCross & 0xFFF) == bxCross) {
393 bxCrossHw = static_cast<cms_uint16_t>(bxCross);
397 LogDebug(
"L1GTEvmDigiToRaw") <<
"\nBunch cross number [hex] = " << std::hex << bxCross
398 <<
"\n larger than 12 bits. Set to 0! \n"
402 int bxIdVal = bxCrossHw;
413 bool moreHeadersVal =
false;
417 gtFEDHeader.
set(ptrGt, triggerTypeVal, lvl1IdVal, bxIdVal, sourceIdVal, versionVal, moreHeadersVal);
422 unsigned char* ptrGt,
426 LogDebug(
"L1GTEvmDigiToRaw") <<
"\nPacking GTFE \n" << std::endl;
432 int nrWord64 = gtfeBlock.
getSize() / uLength;
433 std::vector<cms_uint64_t> tmpWord64;
434 tmpWord64.resize(nrWord64);
436 for (
int iWord = 0; iWord < nrWord64; ++iWord) {
437 tmpWord64[iWord] = 0x0000000000000000ULL;
441 for (
int iWord = 0; iWord < nrWord64; ++iWord) {
458 cms_uint64_t* pw = reinterpret_cast<cms_uint64_t*>(const_cast<unsigned char*>(ptrGt));
460 for (
int iWord = 0; iWord < nrWord64; ++iWord) {
461 *pw++ = tmpWord64[iWord];
464 LogTrace(
"L1GTEvmDigiToRaw") << std::setw(4) << iWord <<
" " << std::hex << std::setfill(
'0') << std::setw(16)
465 << tmpWord64[iWord] <<
std::dec << std::setfill(
' ') << std::endl;
473 LogDebug(
"L1GTEvmDigiToRaw") <<
"\nPacking TCS \n" << std::endl;
479 int nrWord64 = tcsBlock.
getSize() / uLength;
480 std::vector<cms_uint64_t> tmpWord64;
481 tmpWord64.resize(nrWord64);
483 for (
int iWord = 0; iWord < nrWord64; ++iWord) {
484 tmpWord64[iWord] = 0x0000000000000000ULL;
488 for (
int iWord = 0; iWord < nrWord64; ++iWord) {
507 cms_uint64_t* pw = reinterpret_cast<cms_uint64_t*>(const_cast<unsigned char*>(ptrGt));
509 for (
int iWord = 0; iWord < nrWord64; ++iWord) {
510 *pw++ = tmpWord64[iWord];
513 LogTrace(
"L1GTEvmDigiToRaw") << std::setw(4) << iWord <<
" " << std::hex << std::setfill(
'0') << std::setw(16)
514 << tmpWord64[iWord] <<
std::dec << std::setfill(
' ') << std::endl;
522 LogDebug(
"L1GTEvmDigiToRaw") <<
"\nPacking FDL \n" << std::endl;
528 int nrWord64 = fdlBlock.
getSize() / uLength;
529 std::vector<cms_uint64_t> tmpWord64;
530 tmpWord64.resize(nrWord64);
532 for (
int iWord = 0; iWord < nrWord64; ++iWord) {
533 tmpWord64[iWord] = 0x0000000000000000ULL;
537 for (
int iWord = 0; iWord < nrWord64; ++iWord) {
563 cms_uint64_t* pw = reinterpret_cast<cms_uint64_t*>(const_cast<unsigned char*>(ptrGt));
565 for (
int iWord = 0; iWord < nrWord64; ++iWord) {
566 *pw++ = tmpWord64[iWord];
569 LogTrace(
"L1GTEvmDigiToRaw") << std::setw(4) << iWord <<
" " << std::hex << std::setfill(
'0') << std::setw(16)
570 << tmpWord64[iWord] <<
std::dec << std::setfill(
' ') << std::endl;
580 int lengthVal = dataSize / 8;
586 int evtStatusVal = 0;
594 bool moreTrailersVal =
false;
597 gtFEDTrailer.
set(ptrGt, lengthVal, crcVal, evtStatusVal, ttsBitsVal, moreTrailersVal);