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) {
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) {
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) {
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) {
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);
const cms_uint16_t altNrBxBoard() const
get/set alternative for number of BX per board
virtual void print(std::ostream &myCout) const
pretty print the content of a L1GtfeWord
void packFDL(const edm::EventSetup &, unsigned char *, L1GtFdlWord &)
pack FDL blocks for various bunch crosses
void setEventNrWord64(cms_uint64_t &word64, int iWord)
void setRecordLength1Word64(cms_uint64_t &word64, int iWord)
void setNoAlgoWord64(cms_uint64_t &word64, const int iWord)
void setGtDecisionWordBWord64(cms_uint64_t &word64, const int iWord)
const cms_uint16_t recordLength1() const
get/set record length for alternative 1
const unsigned int getSize() const
get the size of the PSB block in GT DAQ record (in multiple of 8 bits)
const unsigned int getSize() const
get the size of the GTFE block in GT DAQ record (in multiple of 8 bits)
const edm::EDGetTokenT< L1MuGMTReadoutCollection > m_muGmtInputToken
input tag for GMT record
void print(std::ostream &myCout) const
pretty print the content of a L1GlobalTriggerReadoutRecord
static const int UnitLength
one unit in the word is UnitLength bits
void packHeader(unsigned char *, edm::Event &)
block packers -------——
T const * product() const
size_t size() const
Lenght of the data buffer in bytes.
void setBoardIdWord64(cms_uint64_t &word64, const int iWord)
void setLumiSegmentNrWord64(cms_uint64_t &word64, const int iWord)
const L1GtfeWord gtfeWord() const
get / set GTFE word (record) in the GT readout record
void setActiveBoardsWord64(cms_uint64_t &word64, int iWord)
void setBxNrWord64(cms_uint64_t &word64, int iWord)
void setSetupVersionWord64(cms_uint64_t &word64, int iWord)
const L1GtFdlWord gtFdlWord(int bxInEventValue) const
get / set FDL word (record) in the GT readout record
void setOrbitNrWord64(cms_uint64_t &word64, const int iWord)
cms_uint16_t m_activeBoardsMaskGt
mask for active boards
void setGtTechnicalTriggerWordWord64(cms_uint64_t &word64, const int iWord)
const cms_uint16_t recordLength() const
get/set record length for alternative 0
void setBxInEventWord64(cms_uint64_t &word64, int iWord)
std::vector< L1MuGMTExtendedCand > getGMTBrlCands() const
get GMT barrel candidates vector
void setADataWord64(cms_uint64_t &word64, int iWord)
void print(std::ostream &myCout) const
pretty print
void setGtPrescaleFactorIndexTechWord64(cms_uint64_t &word64, const int iWord)
static void set(unsigned char *trailer, uint32_t lenght, uint16_t crc, uint8_t evt_stat, uint8_t tts, bool moreTrailers=false)
Set all fields in the trailer.
std::vector< L1MuRegionalCand > getDTBXCands() const
get DT candidates vector
void packPSB(const edm::EventSetup &, unsigned char *, L1GtPsbWord &)
void setBxInEventWord64(cms_uint64_t &word64, const int iWord)
void setLocalBxNrWord64(cms_uint64_t &word64, int iWord)
unsigned short compute_crc(unsigned char *buffer, unsigned int bufSize)
void setPhysicsDeclaredWord64(cms_uint64_t &word64, const int iWord)
unsigned int packGMT(L1MuGMTReadoutRecord const &, unsigned char *)
pack a GMT record
const edm::InputTag m_muGmtInputTag
void setEventNrWord64(cms_uint64_t &word64, const int iWord)
void packTrailer(unsigned char *, unsigned char *, int)
pack trailer word
unsigned short cms_uint16_t
int getBxNr() const
get counters
const unsigned int getSize() const
get the size of the TCS block in GT EVM record (in multiple of 8 bits)
const edm::EDGetTokenT< L1GlobalTriggerReadoutRecord > m_daqGtInputToken
input tag for GT DAQ record
void setBxNrWord64(cms_uint64_t &word64, const int iWord)
const std::vector< L1GtBoard > & gtBoardMaps() const
get / set / print the L1 GT board map
void setBoardIdWord64(cms_uint64_t &word64, int iWord)
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
void setBDataWord64(cms_uint64_t &word64, int iWord)
std::vector< L1MuGMTExtendedCand > getGMTFwdCands() const
get GMT forward candidates vector
std::vector< L1MuRegionalCand > getBrlRPCCands() const
get barrel RPC candidates vector
std::vector< L1MuRegionalCand > getCSCCands() const
get CSC candidates vector
const edm::InputTag m_daqGtInputTag
void setAltNrBxBoardWord64(cms_uint64_t &word64, int iWord)
unsigned int packGmtCollection(unsigned char *ptrGt, L1MuGMTReadoutCollection const *digis)
pack the GMT collection using packGMT (GMT record packing)
const L1GtPsbWord gtPsbWord(cms_uint16_t boardIdValue, int bxInEventValue) const
get / set PSB word (record) in the GT readout record
void resize(size_t newsize, size_t wordsize=8)
void packGTFE(const edm::EventSetup &, unsigned char *, L1GtfeWord &, cms_uint16_t activeBoardsGtValue)
unsigned int flipPtQ(unsigned int)
void setGtDecisionWordExtendedWord64(cms_uint64_t &word64, const int iWord)
const unsigned int getSize() const
get the size of the FDL block in GT DAQ record (in multiple of 8 bits)
void setLocalBxNrWord64(cms_uint64_t &word64, const int iWord)
void setGtDecisionWordAWord64(cms_uint64_t &word64, const int iWord)
const edm::ESGetToken< L1GtBoardMaps, L1GtBoardMapsRcd > m_l1GtBMToken
EventSetup Token for L1GtBoardMaps.
void setBxNrWord64(cms_uint64_t &word64, int iWord)
void produce(edm::Event &, const edm::EventSetup &) override
loop over events
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
L1MuGMTReadoutRecord const & getRecord(int bx=0) const
int m_verbosity
verbosity level
void print(std::ostream &myCout) const
pretty print the content of a L1GtFdlWord
void setFinalORWord64(cms_uint64_t &word64, const int iWord)
std::vector< L1MuRegionalCand > getFwdRPCCands() const
get forward RPC candidates vector
unsigned long long cms_uint64_t
const cms_uint16_t activeBoards() const
get/set boards contributing to EVM respectively DAQ record
Log< level::Warning, false > LogWarning
void setTotalTriggerNrWord64(cms_uint64_t &word64, int iWord)
void setGtPrescaleFactorIndexAlgoWord64(cms_uint64_t &word64, const int iWord)
std::vector< L1MuGMTExtendedCand > getGMTCands() const
get GMT candidates vector
int m_totalBxInEvent
total Bx's in the event, obtained from GTFE block
L1GTDigiToRaw(const edm::ParameterSet &)
constructor(s)
void setBoardIdWord64(cms_uint64_t &word64, int iWord)
void setRecordLengthWord64(cms_uint64_t &word64, int iWord)