62 m_daqGtFedId(pSet.getUntrackedParameter<
int> (
66 m_daqGtInputTag(pSet.getParameter<
edm::InputTag> (
"DaqGtInputTag")),
67 m_muGmtInputTag(pSet.getParameter<
edm::InputTag> (
"MuGmtInputTag")),
68 m_activeBoardsMaskGt(pSet.getParameter<unsigned
int> (
"ActiveBoardsMask")),
70 m_minBxInEvent(0), m_maxBxInEvent(),
71 m_verbosity(pSet.getUntrackedParameter<
int> (
"Verbosity", 0)),
78 <<
"\nFED Id for DAQ GT record: " <<
m_daqGtFedId <<
" \n" 81 <<
"\nMask for active boards (hex format): " << std::hex
84 <<
std::dec << std::setfill(
' ') <<
" \n" 89 produces<FEDRawDataCollection> ();
112 const std::vector<L1GtBoard> boardMaps = l1GtBM->
gtBoardMaps();
113 int boardMapsSize = boardMaps.size();
115 typedef std::vector<L1GtBoard>::const_iterator CItBoardMaps;
120 std::vector<L1GtBoard> gtRecordMap;
121 gtRecordMap.reserve(boardMapsSize);
123 for (
int iPos = 0; iPos < boardMapsSize; ++iPos) {
124 for (CItBoardMaps itBoard = boardMaps.begin(); itBoard
125 != boardMaps.end(); ++itBoard) {
127 if (itBoard->gtPositionDaqRecord() == iPos) {
128 gtRecordMap.push_back(*itBoard);
140 if (!gtReadoutRecord.
isValid()) {
143 <<
"\nWarning: L1GlobalTriggerReadoutRecord with input tag " <<
m_daqGtInputTag 144 <<
"\nrequested in configuration, but not found in the event." 145 <<
"\nQuit packing this event" << std::endl;
155 std::ostringstream myCoutStream;
156 gtReadoutRecord->
print(myCoutStream);
158 <<
"\n The following L1 GT DAQ readout record will be packed.\n" 159 <<
" Some boards could be disabled before packing," 160 <<
" see detailed board packing.\n" << myCoutStream.str() <<
"\n" 185 <<
"\nActive boards before masking(hex format): " << std::hex
186 << std::setw(
sizeof ( activeBoardsGtInitial ) * 2) << std::setfill(
'0')
187 << activeBoardsGtInitial <<
std::dec << std::setfill(
' ')
188 <<
"Active boards after masking(hex format): " << std::hex
189 << std::setw(
sizeof ( activeBoardsGt ) * 2) << std::setfill(
'0') << activeBoardsGt
190 <<
std::dec << std::setfill(
' ') <<
" \n" 196 unsigned int gtDataSize = 0;
198 unsigned int headerSize = 8;
199 gtDataSize += headerSize;
202 itBoard = boardMaps.begin();
203 itBoard != boardMaps.end(); ++itBoard) {
205 if (itBoard->gtBoardType() ==
GTFE) {
206 gtDataSize += gtfeBlock.
getSize();
211 int iActiveBit = itBoard->gtBitDaqActiveBoards();
212 bool activeBoardToPack =
false;
214 int altNrBxBoardVal = -1;
216 if (iActiveBit >= 0) {
217 activeBoardToPack = activeBoardsGt & (1 << iActiveBit);
219 altNrBxBoardVal = (altNrBxBoardInitial & ( 1 << iActiveBit )) >> iActiveBit;
221 if (altNrBxBoardVal == 1) {
223 }
else if (altNrBxBoardVal == 0) {
228 <<
"\n\nWARNING: Wrong value altNrBxBoardVal = " << altNrBxBoardVal
229 <<
" for board " << std::hex << ( itBoard->gtBoardId() ) <<
std::dec 230 <<
"\n iActiveBit = " << iActiveBit
231 <<
"\n altNrBxBoardInitial = 0x" << std::hex << altNrBxBoardInitial <<
std::dec 232 <<
"\n activeBoardsGt = 0x" << std::hex << activeBoardsGt <<
std::dec 233 <<
"\n activeBoardToPack = " << activeBoardToPack
234 <<
"\n Set altNrBxBoardVal tentatively to " 235 << recordLength0 <<
"\n Job may crash or produce wrong results!\n\n" 248 if (activeBoardToPack) {
250 switch (itBoard->gtBoardType()) {
270 unsigned int gmtRecordSize = 136;
272 gtDataSize += gmtCollSize;
278 gtDataSize += tcsBlock.
getSize();
298 unsigned int trailerSize = 8;
299 gtDataSize += trailerSize;
304 gtRawData.
resize(gtDataSize);
309 unsigned char* ptrGt = gtRawData.
data();
310 unsigned char* ptrGtBegin = gtRawData.
data();
313 LogDebug(
"L1GTDigiToRaw") <<
"\n Size of raw data: " << gtRawData.
size() <<
"\n" 326 itBoard = gtRecordMap.begin();
327 itBoard != gtRecordMap.end(); ++itBoard) {
329 if (itBoard->gtBoardType() ==
GTFE) {
331 packGTFE(evSetup, ptrGt, gtfeBlock, activeBoardsGt);
335 std::ostringstream myCoutStream;
336 gtfeBlock.
print(myCoutStream);
337 LogTrace(
"L1GTDigiToRaw") << myCoutStream.str() <<
"\n" << std::endl;
348 int iActiveBit = itBoard->gtBitDaqActiveBoards();
349 bool activeBoardToPack =
false;
351 int altNrBxBoardVal = -1;
353 if (iActiveBit >= 0) {
354 activeBoardToPack = activeBoardsGt & (1 << iActiveBit);
356 altNrBxBoardVal = (altNrBxBoardInitial & ( 1 << iActiveBit )) >> iActiveBit;
358 if (altNrBxBoardVal == 1) {
360 }
else if (altNrBxBoardVal == 0) {
365 <<
"\n\nWARNING: Wrong value altNrBxBoardVal = " << altNrBxBoardVal
366 <<
" for board " << std::hex << ( itBoard->gtBoardId() ) <<
std::dec 367 <<
"\n iActiveBit = " << iActiveBit
368 <<
"\n altNrBxBoardInitial = 0x" << std::hex << altNrBxBoardInitial <<
std::dec 369 <<
"\n activeBoardsGt = 0x" << std::hex << activeBoardsGt <<
std::dec 370 <<
"\n activeBoardToPack = " << activeBoardToPack
371 <<
"\n Set altNrBxBoardVal tentatively to " 372 << recordLength0 <<
"\n Job may crash or produce wrong results!\n\n" 388 if (activeBoardToPack) {
392 <<
"\nBoard " << std::hex <<
"0x" << ( itBoard->gtBoardId() ) <<
std::dec 400 switch (itBoard->gtBoardType()) {
407 packFDL(evSetup, ptrGt, fdlBlock);
411 std::ostringstream myCoutStream;
412 fdlBlock.
print(myCoutStream);
413 LogTrace(
"L1GTDigiToRaw") << myCoutStream.str() <<
"\n" << std::endl;
424 LogDebug(
"L1GTDigiToRaw") <<
"\nBoard of type " << itBoard->gtBoardName()
425 <<
" with index " << itBoard->gtBoardIndex() <<
" and boardId " 426 << std::hex << itBoard->gtBoardId() <<
std::dec <<
"\n" 433 itBoard->gtBoardId(), iBxInEvent);
435 packPSB(evSetup, ptrGt, psbBlock);
439 std::ostringstream myCoutStream;
440 psbBlock.
print(myCoutStream);
441 LogTrace(
"L1GTDigiToRaw") << myCoutStream.str() <<
"\n" << std::endl;
457 <<
"\nWarning: L1MuGMTReadoutCollection with input tag " 459 <<
"\nrequested in configuration, but not found in the event." 460 <<
"\nQuit packing this event" << std::endl;
475 unsigned int gmtCollSize = 0;
477 ptrGt += gmtCollSize;
504 int triggerTypeVal = 0;
507 int lvl1IdVal = iEvent.
id().
event();
512 if ( ( bxCross & 0xFFF ) == bxCross) {
517 LogDebug(
"L1GTDigiToRaw") <<
"\nBunch cross number [hex] = " << std::hex << bxCross
518 <<
"\n larger than 12 bits. Set to 0! \n" <<
std::dec << std::endl;
521 int bxIdVal = bxCrossHw;
532 bool moreHeadersVal =
false;
537 ptrGt, triggerTypeVal, lvl1IdVal, bxIdVal, sourceIdVal, versionVal, moreHeadersVal);
547 LogDebug(
"L1GTDigiToRaw") <<
"\nPacking GTFE \n" << std::endl;
553 int nrWord64 = gtfeBlock.
getSize() / uLength;
554 std::vector<cms_uint64_t> tmpWord64;
555 tmpWord64.resize(nrWord64);
557 for (
int iWord = 0; iWord < nrWord64; ++iWord) {
558 tmpWord64[iWord] = 0x0000000000000000ULL;
562 for (
int iWord = 0; iWord < nrWord64; ++iWord) {
579 for (
int iWord = 0; iWord < nrWord64; ++iWord) {
581 *pw++ = tmpWord64[iWord];
585 << std::setw(4) << iWord <<
" " 586 << std::hex << std::setfill(
'0') << std::setw(16) << tmpWord64[iWord] <<
std::dec 601 LogDebug(
"L1GTDigiToRaw") <<
"\nPacking FDL \n" << std::endl;
607 int nrWord64 = fdlBlock.
getSize() / uLength;
608 std::vector<cms_uint64_t> tmpWord64;
609 tmpWord64.resize(nrWord64);
611 for (
int iWord = 0; iWord < nrWord64; ++iWord) {
612 tmpWord64[iWord] = 0x0000000000000000ULL;
616 for (
int iWord = 0; iWord < nrWord64; ++iWord) {
646 for (
int iWord = 0; iWord < nrWord64; ++iWord) {
648 *pw++ = tmpWord64[iWord];
653 << std::setw(4) << iWord <<
" " 654 << std::hex << std::setfill(
'0') << std::setw(16) << tmpWord64[iWord] <<
std::dec 667 LogDebug(
"L1GTDigiToRaw") <<
"\nPacking PSB \n" << std::endl;
673 int nrWord64 = psbBlock.
getSize() / uLength;
674 std::vector<cms_uint64_t> tmpWord64;
675 tmpWord64.resize(nrWord64);
677 for (
int iWord = 0; iWord < nrWord64; ++iWord) {
678 tmpWord64[iWord] = 0x0000000000000000ULL;
682 for (
int iWord = 0; iWord < nrWord64; ++iWord) {
700 for (
int iWord = 0; iWord < nrWord64; ++iWord) {
702 *pw++ = tmpWord64[iWord];
707 << std::setw(4) << iWord <<
" " 708 << std::hex << std::setfill(
'0') << std::setw(16) << tmpWord64[iWord] <<
std::dec 718 unsigned char* ptrGt,
723 LogDebug(
"L1GTDigiToRaw") <<
"\nPacking GMT collection \n" << std::endl;
726 unsigned gmtsize = 0;
732 gmtsize =
packGMT(gmtrr, ptrGt);
744 const unsigned SIZE=136;
745 const unsigned boardId=0xdd12;
748 unsigned*
p = (
unsigned*) chp;
755 std::vector<L1MuRegionalCand> vrc;
756 std::vector<L1MuRegionalCand>::const_iterator irc;
761 for(irc=vrc.begin(); irc!=vrc.end(); irc++) {
762 *pp++ = (*irc).getDataWord();
768 for(irc=vrc.begin(); irc!=vrc.end(); irc++) {
769 *pp++ = (*irc).getDataWord();
775 for(irc=vrc.begin(); irc!=vrc.end(); irc++) {
776 *pp++ = (*irc).getDataWord();
782 for(irc=vrc.begin(); irc!=vrc.end(); irc++) {
783 *pp++ = (*irc).getDataWord();
789 for(
int i=0;
i<16;
i++) {
791 *pp++ = (w&0xffff00ff) | ((~w)&0x0000ff00);
794 std::vector<L1MuGMTExtendedCand> vgc;
795 std::vector<L1MuGMTExtendedCand>::const_iterator igc;
799 for(igc=vgc.begin(); igc!=vgc.end(); igc++) {
800 *pp++ = (*igc).getDataWord();
806 for(igc=vgc.begin(); igc!=vgc.end(); igc++) {
807 *pp++ = (*igc).getDataWord();
813 for(igc=vgc.begin(); igc!=vgc.end(); igc++) {
814 *pp++ = (*igc).getDataWord();
821 chpp = (
unsigned char*) p;
822 for(igc=vgc.begin(); igc!=vgc.end(); igc++) {
823 *chpp++ = (*igc).rank();
828 chpp = (
unsigned char*) p;
829 for(igc=vgc.begin(); igc!=vgc.end(); igc++) {
830 *chpp++ = (*igc).rank();
839 return ( (w&0xffff00ff) | ((~w)&0x0000ff00) );
848 int lengthVal = dataSize / 8;
854 int evtStatusVal = 0;
862 bool moreTrailersVal =
false;
865 gtFEDTrailer.
set(ptrGt, lengthVal, crcVal, evtStatusVal, ttsBitsVal, moreTrailersVal);
EventNumber_t event() const
void packFDL(const edm::EventSetup &, unsigned char *, L1GtFdlWord &)
pack FDL blocks for various bunch crosses
void setEventNrWord64(cms_uint64_t &word64, int iWord)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
const unsigned int getSize() const
get the size of the GTFE block in GT DAQ record (in multiple of 8 bits)
std::vector< L1MuGMTExtendedCand > getGMTCands() const
get GMT candidates vector
void setRecordLength1Word64(cms_uint64_t &word64, int iWord)
void setNoAlgoWord64(cms_uint64_t &word64, const int iWord)
void print(std::ostream &myCout) const
pretty print the content of a L1GlobalTriggerReadoutRecord
void setGtDecisionWordBWord64(cms_uint64_t &word64, const int iWord)
virtual void print(std::ostream &myCout) const
pretty print the content of a L1GtfeWord
bool getByToken(EDGetToken token, Handle< PROD > &result) const
const edm::EDGetTokenT< L1MuGMTReadoutCollection > m_muGmtInputToken
input tag for GMT record
static const int UnitLength
one unit in the word is UnitLength bits
void packHeader(unsigned char *, edm::Event &)
block packers -------——
int getBxNr() const
get counters
const L1GtfeWord gtfeWord() const
get / set GTFE word (record) in the GT readout record
int bunchCrossing() const
void setBoardIdWord64(cms_uint64_t &word64, const int iWord)
void setLumiSegmentNrWord64(cms_uint64_t &word64, const int iWord)
void setActiveBoardsWord64(cms_uint64_t &word64, int iWord)
void setBxNrWord64(cms_uint64_t &word64, int iWord)
std::vector< L1MuRegionalCand > getBrlRPCCands() const
get barrel RPC candidates vector
void setSetupVersionWord64(cms_uint64_t &word64, int iWord)
const unsigned int getSize() const
get the size of the FDL block in GT DAQ record (in multiple of 8 bits)
void setOrbitNrWord64(cms_uint64_t &word64, const int iWord)
const cms_uint16_t altNrBxBoard() const
get/set alternative for number of BX per board
size_t size() const
Lenght of the data buffer in bytes.
cms_uint16_t m_activeBoardsMaskGt
mask for active boards
void setGtTechnicalTriggerWordWord64(cms_uint64_t &word64, const int iWord)
std::vector< L1MuRegionalCand > getFwdRPCCands() const
get forward RPC candidates vector
const cms_uint16_t recordLength() const
get/set record length for alternative 0
void setBxInEventWord64(cms_uint64_t &word64, int iWord)
std::vector< L1MuRegionalCand > getCSCCands() const
get CSC candidates vector
void setADataWord64(cms_uint64_t &word64, int iWord)
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.
void packPSB(const edm::EventSetup &, unsigned char *, L1GtPsbWord &)
void resize(size_t newsize)
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
const edm::EDGetTokenT< L1GlobalTriggerReadoutRecord > m_daqGtInputToken
input tag for GT DAQ record
void setBxNrWord64(cms_uint64_t &word64, const int iWord)
const L1GtPsbWord gtPsbWord(cms_uint16_t boardIdValue, int bxInEventValue) const
get / set PSB word (record) in the GT readout record
void setBoardIdWord64(cms_uint64_t &word64, int iWord)
void setBDataWord64(cms_uint64_t &word64, int iWord)
const cms_uint16_t activeBoards() const
get/set boards contributing to EVM respectively DAQ record
void print(std::ostream &myCout) const
pretty print the content of a L1GtFdlWord
void print(std::ostream &myCout) const
pretty print
std::vector< L1MuGMTExtendedCand > getGMTBrlCands() const
get GMT barrel candidates vector
const edm::InputTag m_daqGtInputTag
T const * product() const
const L1GtFdlWord gtFdlWord(int bxInEventValue) const
get / set FDL word (record) in the GT readout record
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)
std::vector< L1MuRegionalCand > getDTBXCands() const
get DT candidates vector
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)
void setLocalBxNrWord64(cms_uint64_t &word64, const int iWord)
void setGtDecisionWordAWord64(cms_uint64_t &word64, const int iWord)
const unsigned int getSize() const
get the size of the TCS block in GT EVM record (in multiple of 8 bits)
std::vector< L1MuGMTExtendedCand > getGMTFwdCands() const
get GMT forward candidates vector
const std::vector< L1GtBoard > & gtBoardMaps() const
get / set / print the L1 GT board map
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.
int m_verbosity
verbosity level
L1MuGMTReadoutRecord const & getRecord(int bx=0) const
void setFinalORWord64(cms_uint64_t &word64, const int iWord)
unsigned long long cms_uint64_t
void setTotalTriggerNrWord64(cms_uint64_t &word64, int iWord)
void setGtPrescaleFactorIndexAlgoWord64(cms_uint64_t &word64, const int iWord)
const cms_uint16_t recordLength1() const
get/set record length for alternative 1
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)
const unsigned int getSize() const
get the size of the PSB block in GT DAQ record (in multiple of 8 bits)