56 m_evmGtFedId(pSet.getUntrackedParameter<
int>(
"EvmGtFedId",
59 m_evmGtInputTag(pSet.getParameter<
edm::InputTag>(
"EvmGtInputTag")),
60 m_activeBoardsMaskGt(pSet.getParameter<unsigned
int>(
"ActiveBoardsMask")),
62 m_minBxInEvent(0), m_maxBxInEvent(),
63 m_verbosity(pSet.getUntrackedParameter<
int> (
"Verbosity", 0)),
70 LogDebug(
"L1GTEvmDigiToRaw") <<
"\nMask for active boards (hex format): " 73 << std::setfill(
' ') <<
"\nInput tag for EVM GT record: " 78 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
113 != boardMaps.end(); ++itBoard) {
115 if (itBoard->gtPositionEvmRecord() == iPos) {
116 gtRecordMap.push_back(*itBoard);
129 if (!gtReadoutRecord.
isValid()) {
131 <<
"\nWarning: L1GlobalTriggerEvmReadoutRecord with input tag " <<
m_evmGtInputTag 132 <<
"\nrequested in configuration, but not found in the event." 133 <<
"\nQuit packing this event" << std::endl;
142 std::ostringstream myCoutStream;
143 gtReadoutRecord->
print(myCoutStream);
145 <<
"\n The following L1 GT EVM readout record will be packed.\n" 146 <<
" Some boards could be disabled before packing," 147 <<
" see detailed board packing.\n" 148 << myCoutStream.str() <<
"\n" 175 <<
"\nActive boards before masking(hex format): " << std::hex
176 << std::setw(
sizeof ( activeBoardsGtInitial ) * 2) << std::setfill(
'0')
177 << activeBoardsGtInitial <<
std::dec << std::setfill(
' ')
178 <<
"\nActive boards after masking(hex format): " << std::hex
179 << std::setw(
sizeof ( activeBoardsGt ) * 2) << std::setfill(
'0')
181 << std::setfill(
' ') <<
" \n" 187 unsigned int gtDataSize = 0;
189 unsigned int headerSize = 8;
190 gtDataSize += headerSize;
193 itBoard = boardMaps.begin();
194 itBoard != boardMaps.end(); ++itBoard) {
196 if (itBoard->gtBoardType() ==
GTFE) {
197 gtDataSize += gtfeBlock.
getSize();
202 int iActiveBit = itBoard->gtBitEvmActiveBoards();
203 bool activeBoardToPack =
false;
205 int altNrBxBoardVal = -1;
207 if (iActiveBit >= 0) {
208 activeBoardToPack = activeBoardsGt & (1 << iActiveBit);
210 altNrBxBoardVal = (altNrBxBoardInitial & ( 1 << iActiveBit )) >> iActiveBit;
212 if (altNrBxBoardVal == 1) {
214 }
else if (altNrBxBoardVal == 0) {
219 <<
"\n\nWARNING: Wrong value altNrBxBoardVal = " << altNrBxBoardVal
220 <<
" for board " << std::hex << ( itBoard->gtBoardId() ) <<
std::dec 221 <<
"\n iActiveBit = " << iActiveBit
222 <<
"\n altNrBxBoardInitial = 0x" << std::hex << altNrBxBoardInitial <<
std::dec 223 <<
"\n activeBoardsGt = 0x" << std::hex << activeBoardsGt <<
std::dec 224 <<
"\n activeBoardToPack = " << activeBoardToPack
225 <<
"\n Set altNrBxBoardVal tentatively to " 226 << recordLength0 <<
"\n Job may crash or produce wrong results!\n\n" 237 if (activeBoardToPack) {
239 switch (itBoard->gtBoardType()) {
253 gtDataSize += tcsBlock.
getSize();
273 unsigned int trailerSize = 8;
274 gtDataSize += trailerSize;
278 gtRawData.
resize(gtDataSize);
282 unsigned char* ptrGt = gtRawData.
data();
283 unsigned char* ptrGtBegin = gtRawData.
data();
286 LogDebug(
"L1GTEvmDigiToRaw") <<
"\n Size of raw data: " << gtRawData.
size() <<
"\n" 299 itBoard = gtRecordMap.begin();
300 itBoard != gtRecordMap.end(); ++itBoard) {
302 if (itBoard->gtBoardType() ==
GTFE) {
304 packGTFE(evSetup, ptrGt, gtfeBlock, activeBoardsGt);
308 std::ostringstream myCoutStream;
309 gtfeBlock.
print(myCoutStream);
311 << myCoutStream.str() <<
"\n" 323 int iActiveBit = itBoard->gtBitEvmActiveBoards();
324 bool activeBoardToPack =
false;
326 int altNrBxBoardVal = -1;
328 if (iActiveBit >= 0) {
329 activeBoardToPack = activeBoardsGt & (1 << iActiveBit);
331 altNrBxBoardVal = (altNrBxBoardInitial & ( 1 << iActiveBit )) >> iActiveBit;
333 if (altNrBxBoardVal == 1) {
335 }
else if (altNrBxBoardVal == 0) {
340 <<
"\n\nWARNING: Wrong value altNrBxBoardVal = " << altNrBxBoardVal
341 <<
" for board " << std::hex << ( itBoard->gtBoardId() ) <<
std::dec 342 <<
"\n iActiveBit = " << iActiveBit
343 <<
"\n altNrBxBoardInitial = 0x" << std::hex << altNrBxBoardInitial <<
std::dec 344 <<
"\n activeBoardsGt = 0x" << std::hex << activeBoardsGt <<
std::dec 345 <<
"\n activeBoardToPack = " << activeBoardToPack
346 <<
"\n Set altNrBxBoardVal tentatively to " 347 << recordLength0 <<
"\n Job may crash or produce wrong results!\n\n" 362 if (activeBoardToPack) {
366 <<
"\nBoard " << std::hex <<
"0x" << ( itBoard->gtBoardId() ) <<
std::dec 374 switch (itBoard->gtBoardType()) {
379 packTCS(evSetup, ptrGt, tcsBlock);
383 std::ostringstream myCoutStream;
384 tcsBlock.
print(myCoutStream);
386 << myCoutStream.str() <<
"\n" 400 packFDL(evSetup, ptrGt, fdlBlock);
404 std::ostringstream myCoutStream;
405 fdlBlock.
print(myCoutStream);
407 << myCoutStream.str() <<
"\n" 443 int triggerTypeVal = 0;
446 int lvl1IdVal = iEvent.
id().
event();
451 if ((bxCross & 0xFFF) == bxCross) {
458 <<
"\nBunch cross number [hex] = " 459 << std::hex << bxCross
460 <<
"\n larger than 12 bits. Set to 0! \n" 465 int bxIdVal = bxCrossHw;
476 bool moreHeadersVal =
false;
481 gtFEDHeader.
set(ptrGt,
482 triggerTypeVal, lvl1IdVal, bxIdVal, sourceIdVal, versionVal,
491 unsigned char* ptrGt,
497 LogDebug(
"L1GTEvmDigiToRaw") <<
"\nPacking GTFE \n" << std::endl;
503 int nrWord64 = gtfeBlock.
getSize()/uLength;
504 std::vector<cms_uint64_t> tmpWord64;
505 tmpWord64.resize(nrWord64);
507 for (
int iWord = 0; iWord < nrWord64; ++iWord) {
508 tmpWord64[iWord] = 0x0000000000000000ULL;
512 for (
int iWord = 0; iWord < nrWord64; ++iWord) {
532 reinterpret_cast<cms_uint64_t*
>(
const_cast<unsigned char*
>(ptrGt));
534 for (
int iWord = 0; iWord < nrWord64; ++iWord) {
536 *pw++ = tmpWord64[iWord];
540 << std::setw(4) << iWord <<
" " 541 << std::hex << std::setfill(
'0')
542 << std::setw(16) << tmpWord64[iWord]
554 unsigned char* ptrGt,
559 LogDebug(
"L1GTEvmDigiToRaw") <<
"\nPacking TCS \n" << std::endl;
565 int nrWord64 = tcsBlock.
getSize()/uLength;
566 std::vector<cms_uint64_t> tmpWord64;
567 tmpWord64.resize(nrWord64);
569 for (
int iWord = 0; iWord < nrWord64; ++iWord) {
570 tmpWord64[iWord] = 0x0000000000000000ULL;
574 for (
int iWord = 0; iWord < nrWord64; ++iWord) {
596 reinterpret_cast<cms_uint64_t*
>(
const_cast<unsigned char*
>(ptrGt));
598 for (
int iWord = 0; iWord < nrWord64; ++iWord) {
600 *pw++ = tmpWord64[iWord];
604 << std::setw(4) << iWord <<
" " 605 << std::hex << std::setfill(
'0')
606 << std::setw(16) << tmpWord64[iWord]
618 unsigned char* ptrGt,
623 LogDebug(
"L1GTEvmDigiToRaw") <<
"\nPacking FDL \n" << std::endl;
629 int nrWord64 = fdlBlock.
getSize()/uLength;
630 std::vector<cms_uint64_t> tmpWord64;
631 tmpWord64.resize(nrWord64);
633 for (
int iWord = 0; iWord < nrWord64; ++iWord) {
634 tmpWord64[iWord] = 0x0000000000000000ULL;
638 for (
int iWord = 0; iWord < nrWord64; ++iWord) {
667 reinterpret_cast<cms_uint64_t*
>(
const_cast<unsigned char*
>(ptrGt));
669 for (
int iWord = 0; iWord < nrWord64; ++iWord) {
671 *pw++ = tmpWord64[iWord];
675 << std::setw(4) << iWord <<
" " 676 << std::hex << std::setfill(
'0')
677 << std::setw(16) << tmpWord64[iWord]
688 unsigned char* ptrGtBegin,
int dataSize)
694 int lengthVal = dataSize/8;
700 int evtStatusVal = 0;
708 bool moreTrailersVal =
false;
711 gtFEDTrailer.
set(ptrGt,
712 lengthVal, crcVal, evtStatusVal, ttsBitsVal,
EventNumber_t event() const
void packHeader(unsigned char *, edm::Event &)
block packers -------——
const bool m_isDebugEnabled
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
void setRecordLength1Word64(cms_uint64_t &word64, int iWord)
void setBoardIdWord64(cms_uint64_t &word64, int iWord)
void setNoAlgoWord64(cms_uint64_t &word64, const int iWord)
void setBxNrWord64(cms_uint64_t &word64, int iWord)
int m_totalBxInEvent
total Bx's in the event, obtained from GTFE block
void setGtDecisionWordBWord64(cms_uint64_t &word64, const int iWord)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
static const int UnitLength
one unit in the word is UnitLength bits
cms_uint16_t m_activeBoardsMaskGt
mask for active boards
void print(std::ostream &myCout) const override
pretty print the content of a L1GtfeExtWord
const edm::InputTag m_evmGtInputTag
const L1GtfeExtWord gtfeWord() const
get / set GTFE word (record) in the GT readout record
const L1TcsWord tcsWord() const
get / set TCS word (record) in the GT readout record
int m_bstLengthBytes
length of BST record (in bytes)
int bunchCrossing() const
void setBoardIdWord64(cms_uint64_t &word64, const int iWord)
void setLumiSegmentNrWord64(cms_uint64_t &word64, const int iWord)
const int m_verbosity
verbosity level
void setActiveBoardsWord64(cms_uint64_t &word64, int iWord)
void print(std::ostream &myCout) const
pretty print the content of a L1GlobalTriggerEvmReadoutRecord
const unsigned int bstLengthBytes() const
get the size of the BST block
void setSetupVersionWord64(cms_uint64_t &word64, int iWord)
void setAssignedPartitionsWord64(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.
void setOrbitNrWord64(cms_uint64_t &word64, int iWord)
void setGtTechnicalTriggerWordWord64(cms_uint64_t &word64, const int iWord)
void setBstWord64(cms_uint64_t &word64, int iB, const int iWord)
const unsigned int getSize() const
get the size of the GTFE block in GT EVM record (in multiple of 8 bits)
void setTriggerTypeWord64(cms_uint64_t &word64, int iWord)
void packTrailer(unsigned char *, unsigned char *, int)
pack trailer word
const cms_uint16_t recordLength() const
get/set record length for alternative 0
void setGtPrescaleFactorIndexTechWord64(cms_uint64_t &word64, const int iWord)
void print(std::ostream &myCout) const
pretty print the content of a L1TcsWord
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 resize(size_t newsize)
void setBxInEventWord64(cms_uint64_t &word64, const int iWord)
unsigned short compute_crc(unsigned char *buffer, unsigned int bufSize)
void setPhysicsDeclaredWord64(cms_uint64_t &word64, const int iWord)
void setEventNrWord64(cms_uint64_t &word64, const int iWord)
unsigned short cms_uint16_t
void packGTFE(const edm::EventSetup &, unsigned char *, L1GtfeExtWord &, cms_uint16_t activeBoardsGtValue)
void setBxNrWord64(cms_uint64_t &word64, const int iWord)
void setBoardIdWord64(cms_uint64_t &word64, int iWord)
void setLuminositySegmentNrWord64(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 setAltNrBxBoardWord64(cms_uint64_t &word64, int iWord)
void packTCS(const edm::EventSetup &evSetup, unsigned char *ptrGt, L1TcsWord &tcsBlock)
pack the TCS block
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)
void setEventNrWord64(cms_uint64_t &word64, int iWord)
void setPartRunNrWord64(cms_uint64_t &word64, int iWord)
const std::vector< L1GtBoard > & gtBoardMaps() const
get / set / print the L1 GT board map
void setBxNrWord64(cms_uint64_t &word64, int iWord)
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
void produce(edm::Event &, const edm::EventSetup &) override
loop over events
void setPartTrigNrWord64(cms_uint64_t &word64, int iWord)
void packFDL(const edm::EventSetup &, unsigned char *, L1GtFdlWord &)
pack FDL blocks for various bunch crosses
void setFinalORWord64(cms_uint64_t &word64, const int iWord)
L1GTEvmDigiToRaw(const edm::ParameterSet &)
constructor(s)
unsigned long long cms_uint64_t
void setDaqNrWord64(cms_uint64_t &word64, int iWord)
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
const L1GtFdlWord gtFdlWord(int bxInEvent) const
get / set FDL word (record) in the GT readout record
void setRecordLengthWord64(cms_uint64_t &word64, int iWord)
const edm::EDGetTokenT< L1GlobalTriggerEvmReadoutRecord > m_evmGtInputToken
input tag for GT EVM record
void setStatusWord64(cms_uint64_t &word64, int iWord)