56 m_evmGtFedId(pSet.getUntrackedParameter<int>(
"EvmGtFedId",
58 m_evmGtInputTag(pSet.getParameter<edm::InputTag>(
"EvmGtInputTag")),
59 m_activeBoardsMaskGt(pSet.getParameter<unsigned int>(
"ActiveBoardsMask")),
61 m_minBxInEvent(0), m_maxBxInEvent(),
62 m_verbosity(pSet.getUntrackedParameter<int> (
"Verbosity", 0)),
69 LogDebug(
"L1GTEvmDigiToRaw") <<
"\nMask for active boards (hex format): "
72 << std::setfill(
' ') <<
"\nInput tag for EVM GT record: "
77 produces<FEDRawDataCollection>();
116 const std::vector<L1GtBoard> boardMaps = l1GtBM->gtBoardMaps();
117 int boardMapsSize = boardMaps.size();
119 typedef std::vector<L1GtBoard>::const_iterator CItBoardMaps;
124 std::vector<L1GtBoard> gtRecordMap;
125 gtRecordMap.reserve(boardMapsSize);
127 for (
int iPos = 0; iPos < boardMapsSize; ++iPos) {
128 for (CItBoardMaps itBoard = boardMaps.begin(); itBoard
129 != boardMaps.end(); ++itBoard) {
131 if (itBoard->gtPositionEvmRecord() == iPos) {
132 gtRecordMap.push_back(*itBoard);
145 if (!gtReadoutRecord.
isValid()) {
147 <<
"\nWarning: L1GlobalTriggerEvmReadoutRecord with input tag " <<
m_evmGtInputTag
148 <<
"\nrequested in configuration, but not found in the event."
149 <<
"\nQuit packing this event" << std::endl;
152 iEvent.
put(allFedRawData);
158 std::ostringstream myCoutStream;
159 gtReadoutRecord->print(myCoutStream);
161 <<
"\n The following L1 GT EVM readout record will be packed.\n"
162 <<
" Some boards could be disabled before packing,"
163 <<
" see detailed board packing.\n"
164 << myCoutStream.str() <<
"\n"
191 <<
"\nActive boards before masking(hex format): " << std::hex
192 << std::setw(
sizeof ( activeBoardsGtInitial ) * 2) << std::setfill(
'0')
193 << activeBoardsGtInitial << std::dec << std::setfill(
' ')
194 <<
"\nActive boards after masking(hex format): " << std::hex
195 << std::setw(
sizeof ( activeBoardsGt ) * 2) << std::setfill(
'0')
196 << activeBoardsGt << std::dec
197 << std::setfill(
' ') <<
" \n"
203 unsigned int gtDataSize = 0;
205 unsigned int headerSize = 8;
206 gtDataSize += headerSize;
209 itBoard = boardMaps.begin();
210 itBoard != boardMaps.end(); ++itBoard) {
212 if (itBoard->gtBoardType() ==
GTFE) {
213 gtDataSize += gtfeBlock.
getSize();
218 int iActiveBit = itBoard->gtBitEvmActiveBoards();
219 bool activeBoardToPack =
false;
221 int altNrBxBoardVal = -1;
223 if (iActiveBit >= 0) {
224 activeBoardToPack = activeBoardsGt & (1 << iActiveBit);
226 altNrBxBoardVal = (altNrBxBoardInitial & ( 1 << iActiveBit )) >> iActiveBit;
228 if (altNrBxBoardVal == 1) {
230 }
else if (altNrBxBoardVal == 0) {
235 <<
"\n\nWARNING: Wrong value altNrBxBoardVal = " << altNrBxBoardVal
236 <<
" for board " << std::hex << ( itBoard->gtBoardId() ) << std::dec
237 <<
"\n iActiveBit = " << iActiveBit
238 <<
"\n altNrBxBoardInitial = 0x" << std::hex << altNrBxBoardInitial << std::dec
239 <<
"\n activeBoardsGt = 0x" << std::hex << activeBoardsGt << std::dec
240 <<
"\n activeBoardToPack = " << activeBoardToPack
241 <<
"\n Set altNrBxBoardVal tentatively to "
242 << recordLength0 <<
"\n Job may crash or produce wrong results!\n\n"
253 if (activeBoardToPack) {
255 switch (itBoard->gtBoardType()) {
269 gtDataSize += tcsBlock.
getSize();
289 unsigned int trailerSize = 8;
290 gtDataSize += trailerSize;
294 gtRawData.
resize(gtDataSize);
298 unsigned char* ptrGt = gtRawData.
data();
299 unsigned char* ptrGtBegin = gtRawData.
data();
302 LogDebug(
"L1GTEvmDigiToRaw") <<
"\n Size of raw data: " << gtRawData.
size() <<
"\n"
315 itBoard = gtRecordMap.begin();
316 itBoard != gtRecordMap.end(); ++itBoard) {
318 if (itBoard->gtBoardType() ==
GTFE) {
320 packGTFE(evSetup, ptrGt, gtfeBlock, activeBoardsGt);
324 std::ostringstream myCoutStream;
325 gtfeBlock.
print(myCoutStream);
327 << myCoutStream.str() <<
"\n"
339 int iActiveBit = itBoard->gtBitEvmActiveBoards();
340 bool activeBoardToPack =
false;
342 int altNrBxBoardVal = -1;
344 if (iActiveBit >= 0) {
345 activeBoardToPack = activeBoardsGt & (1 << iActiveBit);
347 altNrBxBoardVal = (altNrBxBoardInitial & ( 1 << iActiveBit )) >> iActiveBit;
349 if (altNrBxBoardVal == 1) {
351 }
else if (altNrBxBoardVal == 0) {
356 <<
"\n\nWARNING: Wrong value altNrBxBoardVal = " << altNrBxBoardVal
357 <<
" for board " << std::hex << ( itBoard->gtBoardId() ) << std::dec
358 <<
"\n iActiveBit = " << iActiveBit
359 <<
"\n altNrBxBoardInitial = 0x" << std::hex << altNrBxBoardInitial << std::dec
360 <<
"\n activeBoardsGt = 0x" << std::hex << activeBoardsGt << std::dec
361 <<
"\n activeBoardToPack = " << activeBoardToPack
362 <<
"\n Set altNrBxBoardVal tentatively to "
363 << recordLength0 <<
"\n Job may crash or produce wrong results!\n\n"
378 if (activeBoardToPack) {
382 <<
"\nBoard " << std::hex <<
"0x" << ( itBoard->gtBoardId() ) << std::dec
390 switch (itBoard->gtBoardType()) {
394 L1TcsWord tcsBlock = gtReadoutRecord->tcsWord();
395 packTCS(evSetup, ptrGt, tcsBlock);
399 std::ostringstream myCoutStream;
400 tcsBlock.
print(myCoutStream);
402 << myCoutStream.str() <<
"\n"
415 L1GtFdlWord fdlBlock = gtReadoutRecord->gtFdlWord(iBxInEvent);
416 packFDL(evSetup, ptrGt, fdlBlock);
420 std::ostringstream myCoutStream;
421 fdlBlock.
print(myCoutStream);
423 << myCoutStream.str() <<
"\n"
447 iEvent.
put(allFedRawData);
459 int triggerTypeVal = 0;
462 int lvl1IdVal = iEvent.
id().
event();
467 if ((bxCross & 0xFFF) == bxCross) {
474 <<
"\nBunch cross number [hex] = "
475 << std::hex << bxCross
476 <<
"\n larger than 12 bits. Set to 0! \n"
481 int bxIdVal = bxCrossHw;
492 bool moreHeadersVal =
false;
497 gtFEDHeader.
set(ptrGt,
498 triggerTypeVal, lvl1IdVal, bxIdVal, sourceIdVal, versionVal,
507 unsigned char* ptrGt,
513 LogDebug(
"L1GTEvmDigiToRaw") <<
"\nPacking GTFE \n" << std::endl;
519 int nrWord64 = gtfeBlock.
getSize()/uLength;
520 std::vector<cms_uint64_t> tmpWord64;
521 tmpWord64.resize(nrWord64);
523 for (
int iWord = 0; iWord < nrWord64; ++iWord) {
524 tmpWord64[iWord] = 0x0000000000000000ULL;
528 for (
int iWord = 0; iWord < nrWord64; ++iWord) {
548 reinterpret_cast<cms_uint64_t*
>(
const_cast<unsigned char*
>(ptrGt));
550 for (
int iWord = 0; iWord < nrWord64; ++iWord) {
552 *pw++ = tmpWord64[iWord];
556 << std::setw(4) << iWord <<
" "
557 << std::hex << std::setfill(
'0')
558 << std::setw(16) << tmpWord64[iWord]
559 << std::dec << std::setfill(
' ')
570 unsigned char* ptrGt,
575 LogDebug(
"L1GTEvmDigiToRaw") <<
"\nPacking TCS \n" << std::endl;
581 int nrWord64 = tcsBlock.
getSize()/uLength;
582 std::vector<cms_uint64_t> tmpWord64;
583 tmpWord64.resize(nrWord64);
585 for (
int iWord = 0; iWord < nrWord64; ++iWord) {
586 tmpWord64[iWord] = 0x0000000000000000ULL;
590 for (
int iWord = 0; iWord < nrWord64; ++iWord) {
612 reinterpret_cast<cms_uint64_t*
>(
const_cast<unsigned char*
>(ptrGt));
614 for (
int iWord = 0; iWord < nrWord64; ++iWord) {
616 *pw++ = tmpWord64[iWord];
620 << std::setw(4) << iWord <<
" "
621 << std::hex << std::setfill(
'0')
622 << std::setw(16) << tmpWord64[iWord]
623 << std::dec << std::setfill(
' ')
634 unsigned char* ptrGt,
639 LogDebug(
"L1GTEvmDigiToRaw") <<
"\nPacking FDL \n" << std::endl;
645 int nrWord64 = fdlBlock.
getSize()/uLength;
646 std::vector<cms_uint64_t> tmpWord64;
647 tmpWord64.resize(nrWord64);
649 for (
int iWord = 0; iWord < nrWord64; ++iWord) {
650 tmpWord64[iWord] = 0x0000000000000000ULL;
654 for (
int iWord = 0; iWord < nrWord64; ++iWord) {
683 reinterpret_cast<cms_uint64_t*
>(
const_cast<unsigned char*
>(ptrGt));
685 for (
int iWord = 0; iWord < nrWord64; ++iWord) {
687 *pw++ = tmpWord64[iWord];
691 << std::setw(4) << iWord <<
" "
692 << std::hex << std::setfill(
'0')
693 << std::setw(16) << tmpWord64[iWord]
694 << std::dec << std::setfill(
' ')
704 unsigned char* ptrGtBegin,
int dataSize)
710 int lengthVal = dataSize/8;
716 int evtStatusVal = 0;
724 bool moreTrailersVal =
false;
727 gtFEDTrailer.
set(ptrGt,
728 lengthVal, crcVal, evtStatusVal, ttsBitsVal,
virtual void endJob()
end of job stuff
EventNumber_t event() const
void packHeader(unsigned char *, edm::Event &)
block packers -------——
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)
static const int UnitLength
one unit in the word is UnitLength bits
cms_uint16_t m_activeBoardsMaskGt
mask for active boards
int m_bstLengthBytes
length of BST record (in bytes)
edm::InputTag m_evmGtInputTag
input tag for GT EVM 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)
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)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
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
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
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)
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)
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
void setRecordLengthWord64(cms_uint64_t &word64, int iWord)
void setStatusWord64(cms_uint64_t &word64, int iWord)
virtual void beginJob()
beginning of job stuff