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>();
117 const std::vector<L1GtBoard> boardMaps = l1GtBM->
gtBoardMaps();
118 int boardMapsSize = boardMaps.size();
120 typedef std::vector<L1GtBoard>::const_iterator CItBoardMaps;
125 std::vector<L1GtBoard> gtRecordMap;
126 gtRecordMap.reserve(boardMapsSize);
128 for (
int iPos = 0; iPos < boardMapsSize; ++iPos) {
129 for (CItBoardMaps itBoard = boardMaps.begin(); itBoard
130 != boardMaps.end(); ++itBoard) {
132 if (itBoard->gtPositionEvmRecord() == iPos) {
133 gtRecordMap.push_back(*itBoard);
146 if (!gtReadoutRecord.
isValid()) {
148 <<
"\nWarning: L1GlobalTriggerEvmReadoutRecord with input tag " <<
m_evmGtInputTag 149 <<
"\nrequested in configuration, but not found in the event." 150 <<
"\nQuit packing this event" << std::endl;
159 std::ostringstream myCoutStream;
160 gtReadoutRecord->
print(myCoutStream);
162 <<
"\n The following L1 GT EVM readout record will be packed.\n" 163 <<
" Some boards could be disabled before packing," 164 <<
" see detailed board packing.\n" 165 << myCoutStream.str() <<
"\n" 192 <<
"\nActive boards before masking(hex format): " << std::hex
193 << std::setw(
sizeof ( activeBoardsGtInitial ) * 2) << std::setfill(
'0')
194 << activeBoardsGtInitial <<
std::dec << std::setfill(
' ')
195 <<
"\nActive boards after masking(hex format): " << std::hex
196 << std::setw(
sizeof ( activeBoardsGt ) * 2) << std::setfill(
'0')
198 << std::setfill(
' ') <<
" \n" 204 unsigned int gtDataSize = 0;
206 unsigned int headerSize = 8;
207 gtDataSize += headerSize;
210 itBoard = boardMaps.begin();
211 itBoard != boardMaps.end(); ++itBoard) {
213 if (itBoard->gtBoardType() ==
GTFE) {
214 gtDataSize += gtfeBlock.
getSize();
219 int iActiveBit = itBoard->gtBitEvmActiveBoards();
220 bool activeBoardToPack =
false;
222 int altNrBxBoardVal = -1;
224 if (iActiveBit >= 0) {
225 activeBoardToPack = activeBoardsGt & (1 << iActiveBit);
227 altNrBxBoardVal = (altNrBxBoardInitial & ( 1 << iActiveBit )) >> iActiveBit;
229 if (altNrBxBoardVal == 1) {
231 }
else if (altNrBxBoardVal == 0) {
236 <<
"\n\nWARNING: Wrong value altNrBxBoardVal = " << altNrBxBoardVal
237 <<
" for board " << std::hex << ( itBoard->gtBoardId() ) <<
std::dec 238 <<
"\n iActiveBit = " << iActiveBit
239 <<
"\n altNrBxBoardInitial = 0x" << std::hex << altNrBxBoardInitial <<
std::dec 240 <<
"\n activeBoardsGt = 0x" << std::hex << activeBoardsGt <<
std::dec 241 <<
"\n activeBoardToPack = " << activeBoardToPack
242 <<
"\n Set altNrBxBoardVal tentatively to " 243 << recordLength0 <<
"\n Job may crash or produce wrong results!\n\n" 254 if (activeBoardToPack) {
256 switch (itBoard->gtBoardType()) {
270 gtDataSize += tcsBlock.
getSize();
290 unsigned int trailerSize = 8;
291 gtDataSize += trailerSize;
295 gtRawData.
resize(gtDataSize);
299 unsigned char* ptrGt = gtRawData.
data();
300 unsigned char* ptrGtBegin = gtRawData.
data();
303 LogDebug(
"L1GTEvmDigiToRaw") <<
"\n Size of raw data: " << gtRawData.
size() <<
"\n" 316 itBoard = gtRecordMap.begin();
317 itBoard != gtRecordMap.end(); ++itBoard) {
319 if (itBoard->gtBoardType() ==
GTFE) {
321 packGTFE(evSetup, ptrGt, gtfeBlock, activeBoardsGt);
325 std::ostringstream myCoutStream;
326 gtfeBlock.
print(myCoutStream);
328 << myCoutStream.str() <<
"\n" 340 int iActiveBit = itBoard->gtBitEvmActiveBoards();
341 bool activeBoardToPack =
false;
343 int altNrBxBoardVal = -1;
345 if (iActiveBit >= 0) {
346 activeBoardToPack = activeBoardsGt & (1 << iActiveBit);
348 altNrBxBoardVal = (altNrBxBoardInitial & ( 1 << iActiveBit )) >> iActiveBit;
350 if (altNrBxBoardVal == 1) {
352 }
else if (altNrBxBoardVal == 0) {
357 <<
"\n\nWARNING: Wrong value altNrBxBoardVal = " << altNrBxBoardVal
358 <<
" for board " << std::hex << ( itBoard->gtBoardId() ) <<
std::dec 359 <<
"\n iActiveBit = " << iActiveBit
360 <<
"\n altNrBxBoardInitial = 0x" << std::hex << altNrBxBoardInitial <<
std::dec 361 <<
"\n activeBoardsGt = 0x" << std::hex << activeBoardsGt <<
std::dec 362 <<
"\n activeBoardToPack = " << activeBoardToPack
363 <<
"\n Set altNrBxBoardVal tentatively to " 364 << recordLength0 <<
"\n Job may crash or produce wrong results!\n\n" 379 if (activeBoardToPack) {
383 <<
"\nBoard " << std::hex <<
"0x" << ( itBoard->gtBoardId() ) <<
std::dec 391 switch (itBoard->gtBoardType()) {
396 packTCS(evSetup, ptrGt, tcsBlock);
400 std::ostringstream myCoutStream;
401 tcsBlock.
print(myCoutStream);
403 << myCoutStream.str() <<
"\n" 417 packFDL(evSetup, ptrGt, fdlBlock);
421 std::ostringstream myCoutStream;
422 fdlBlock.
print(myCoutStream);
424 << myCoutStream.str() <<
"\n" 460 int triggerTypeVal = 0;
463 int lvl1IdVal = iEvent.
id().
event();
468 if ((bxCross & 0xFFF) == bxCross) {
475 <<
"\nBunch cross number [hex] = " 476 << std::hex << bxCross
477 <<
"\n larger than 12 bits. Set to 0! \n" 482 int bxIdVal = bxCrossHw;
493 bool moreHeadersVal =
false;
498 gtFEDHeader.
set(ptrGt,
499 triggerTypeVal, lvl1IdVal, bxIdVal, sourceIdVal, versionVal,
508 unsigned char* ptrGt,
514 LogDebug(
"L1GTEvmDigiToRaw") <<
"\nPacking GTFE \n" << std::endl;
520 int nrWord64 = gtfeBlock.
getSize()/uLength;
521 std::vector<cms_uint64_t> tmpWord64;
522 tmpWord64.resize(nrWord64);
524 for (
int iWord = 0; iWord < nrWord64; ++iWord) {
525 tmpWord64[iWord] = 0x0000000000000000ULL;
529 for (
int iWord = 0; iWord < nrWord64; ++iWord) {
549 reinterpret_cast<cms_uint64_t*
>(
const_cast<unsigned char*
>(ptrGt));
551 for (
int iWord = 0; iWord < nrWord64; ++iWord) {
553 *pw++ = tmpWord64[iWord];
557 << std::setw(4) << iWord <<
" " 558 << std::hex << std::setfill(
'0')
559 << std::setw(16) << tmpWord64[iWord]
571 unsigned char* ptrGt,
576 LogDebug(
"L1GTEvmDigiToRaw") <<
"\nPacking TCS \n" << std::endl;
582 int nrWord64 = tcsBlock.
getSize()/uLength;
583 std::vector<cms_uint64_t> tmpWord64;
584 tmpWord64.resize(nrWord64);
586 for (
int iWord = 0; iWord < nrWord64; ++iWord) {
587 tmpWord64[iWord] = 0x0000000000000000ULL;
591 for (
int iWord = 0; iWord < nrWord64; ++iWord) {
613 reinterpret_cast<cms_uint64_t*
>(
const_cast<unsigned char*
>(ptrGt));
615 for (
int iWord = 0; iWord < nrWord64; ++iWord) {
617 *pw++ = tmpWord64[iWord];
621 << std::setw(4) << iWord <<
" " 622 << std::hex << std::setfill(
'0')
623 << std::setw(16) << tmpWord64[iWord]
635 unsigned char* ptrGt,
640 LogDebug(
"L1GTEvmDigiToRaw") <<
"\nPacking FDL \n" << std::endl;
646 int nrWord64 = fdlBlock.
getSize()/uLength;
647 std::vector<cms_uint64_t> tmpWord64;
648 tmpWord64.resize(nrWord64);
650 for (
int iWord = 0; iWord < nrWord64; ++iWord) {
651 tmpWord64[iWord] = 0x0000000000000000ULL;
655 for (
int iWord = 0; iWord < nrWord64; ++iWord) {
684 reinterpret_cast<cms_uint64_t*
>(
const_cast<unsigned char*
>(ptrGt));
686 for (
int iWord = 0; iWord < nrWord64; ++iWord) {
688 *pw++ = tmpWord64[iWord];
692 << std::setw(4) << iWord <<
" " 693 << std::hex << std::setfill(
'0')
694 << std::setw(16) << tmpWord64[iWord]
705 unsigned char* ptrGtBegin,
int dataSize)
711 int lengthVal = dataSize/8;
717 int evtStatusVal = 0;
725 bool moreTrailersVal =
false;
728 gtFEDTrailer.
set(ptrGt,
729 lengthVal, crcVal, evtStatusVal, ttsBitsVal,
virtual void endJob()
end of job stuff
EventNumber_t event() const
void packHeader(unsigned char *, edm::Event &)
block packers -------——
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
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)
edm::InputTag m_evmGtInputTag
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 print(std::ostream &myCout) const
pretty print the content of a L1GlobalTriggerEvmReadoutRecord
const unsigned int bstLengthBytes() const
get the size of the BST block
static void set(unsigned char *trailer, int evt_lgth, int crc, int evt_stat, int tts, bool T=false)
Set all fields in the trailer.
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.
virtual void produce(edm::Event &, const edm::EventSetup &)
loop over events
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
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)
int m_verbosity
verbosity level
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
edm::EDGetTokenT< L1GlobalTriggerEvmReadoutRecord > m_evmGtInputToken
input tag for GT EVM record
void setAltNrBxBoardWord64(cms_uint64_t &word64, int iWord)
virtual ~L1GTEvmDigiToRaw()
destructor
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.
virtual void print(std::ostream &myCout) const
pretty print the content of a L1GtfeExtWord
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)
void setStatusWord64(cms_uint64_t &word64, int iWord)
virtual void beginJob()
beginning of job stuff