54 m_evmGtInputTag(pSet.getParameter<edm::
InputTag>(
"EvmGtInputTag")),
59 m_evmGtFedId(pSet.getUntrackedParameter<int>(
"EvmGtFedId",
FEDNumbering::MINTriggerGTPFEDID)),
65 m_activeBoardsMaskGt(pSet.getParameter<unsigned int>(
"ActiveBoardsMask")),
68 m_unpackBxInEvent(pSet.getParameter<int>(
"UnpackBxInEvent")),
70 m_lowSkipBxInEvent(0),
71 m_uppSkipBxInEvent(0),
79 m_bstLengthBytes(pSet.getParameter<int>(
"BstLengthBytes")),
81 m_verbosity(pSet.getUntrackedParameter<int>(
"Verbosity", 0)),
86 produces<L1GlobalTriggerEvmReadoutRecord>();
89 LogDebug(
"L1GlobalTriggerEvmRawToDigi")
92 <<
"\nMask for active boards (hex format): " << std::hex << std::setw(
sizeof(
m_activeBoardsMaskGt) * 2)
104 <<
"\nWARNING: Number of bunch crossing to be unpacked rounded to: " <<
m_unpackBxInEvent
105 <<
"\n The number must be an odd number!\n"
140 const std::vector<L1GtBoard> boardMaps = l1GtBM->gtBoardMaps();
141 int boardMapsSize = boardMaps.size();
143 typedef std::vector<L1GtBoard>::const_iterator CItBoardMaps;
148 std::vector<L1GtBoard> gtRecordMap;
149 gtRecordMap.reserve(boardMapsSize);
151 for (
int iPos = 0; iPos < boardMapsSize; ++iPos) {
152 for (CItBoardMaps itBoard = boardMaps.begin(); itBoard != boardMaps.end(); ++itBoard) {
153 if (itBoard->gtPositionEvmRecord() == iPos) {
154 gtRecordMap.push_back(*itBoard);
168 <<
"\nWarning: FEDRawDataCollection with input tag " <<
m_evmGtInputTag
169 <<
"\nrequested in configuration, but not found in the event."
170 <<
"\nQuit unpacking this event" << std::endl;
181 int gtSize = raw.
size();
184 const unsigned char* ptrGt = raw.
data();
187 const unsigned char* endPtrGt = ptrGt + gtSize;
191 LogTrace(
"L1GlobalTriggerEvmRawToDigi") <<
"\n Size of raw data: " << gtSize <<
"\n" << std::endl;
193 std::ostringstream myCoutStream;
196 LogTrace(
"L1GlobalTriggerEvmRawToDigi") <<
"\n Dump FEDRawData\n" << myCoutStream.str() <<
"\n" << std::endl;
202 if ((ptrGt + headerSize) > endPtrGt) {
203 edm::LogError(
"L1GlobalTriggerEvmRawToDigi") <<
"\nError: Pointer after header greater than end pointer."
204 <<
"\n Put empty products in the event!"
205 <<
"\n Quit unpacking this event." << std::endl;
213 FEDTrailer cmsTrailer(ptrGt + gtSize - headerSize);
221 bool gtfeUnpacked =
false;
225 int bstLengthBytes = 0;
241 LogTrace(
"L1GlobalTriggerEvmRawToDigi") <<
"\n Length of BST message (in bytes): " << bstLengthBytes <<
"\n"
245 for (CItBoardMaps itBoard = boardMaps.begin(); itBoard != boardMaps.end(); ++itBoard) {
246 if (itBoard->gtBoardType() ==
GTFE) {
248 if (itBoard->gtPositionEvmRecord() == 1) {
257 std::ostringstream myCoutStream;
259 LogTrace(
"L1GlobalTriggerEvmRawToDigi") << myCoutStream.str() <<
"\n" << std::endl;
268 <<
"\nWarning: GTFE block found in raw data does not follow header."
269 <<
"\nAssumed start position of the block is wrong!"
270 <<
"\nQuit unpacking this event" << std::endl;
284 <<
"\nWarning: no GTFE block found in raw data."
285 <<
"\nCan not find the record length (BxInEvent) and the active boards!"
286 <<
"\nQuit unpacking this event" << std::endl;
306 LogDebug(
"L1GlobalTriggerEvmRawToDigi")
307 <<
"\nActive boards before masking(hex format): " << std::hex << std::setw(
sizeof(activeBoardsGtInitial) * 2)
308 << std::setfill(
'0') << activeBoardsGtInitial <<
std::dec << std::setfill(
' ')
309 <<
"\nActive boards after masking(hex format): " << std::hex << std::setw(
sizeof(activeBoardsGt) * 2)
310 << std::setfill(
'0') << activeBoardsGt <<
std::dec << std::setfill(
' ') <<
" \n"
316 int numberGtfeBoards = 0;
317 int numberFdlBoards = 0;
318 int numberPsbBoards = 0;
319 int numberGmtBoards = 0;
320 int numberTcsBoards = 0;
321 int numberTimBoards = 0;
323 for (CItBoardMaps itBoard = boardMaps.begin(); itBoard != boardMaps.end(); ++itBoard) {
324 int iActiveBit = itBoard->gtBitEvmActiveBoards();
325 bool activeBoardToUnpack =
false;
327 if (iActiveBit >= 0) {
328 activeBoardToUnpack = activeBoardsGt & (1 << iActiveBit);
334 if (activeBoardToUnpack) {
335 switch (itBoard->gtBoardType()) {
369 LogDebug(
"L1GlobalTriggerEvmRawToDigi")
370 <<
"\nBoard of type " << itBoard->gtBoardType() <<
" not expected in record.\n"
393 std::unique_ptr<L1GlobalTriggerEvmReadoutRecord> gtReadoutRecord(
398 for (CItBoardMaps itBoard = gtRecordMap.begin(); itBoard != gtRecordMap.end(); ++itBoard) {
399 int iActiveBit = itBoard->gtBitEvmActiveBoards();
401 bool activeBoardToUnpack =
false;
402 bool activeBoardInitial =
false;
404 int altNrBxBoardVal = -1;
406 if (iActiveBit >= 0) {
407 activeBoardInitial = activeBoardsGtInitial & (1 << iActiveBit);
408 activeBoardToUnpack = activeBoardsGt & (1 << iActiveBit);
410 altNrBxBoardVal = (altNrBxBoardInitial & (1 << iActiveBit)) >> iActiveBit;
412 if (altNrBxBoardVal == 1) {
414 }
else if (altNrBxBoardVal == 0) {
419 <<
"\n\nWARNING: Wrong value altNrBxBoardVal = " << altNrBxBoardVal <<
" for board " << std::hex
420 << (itBoard->gtBoardId()) <<
std::dec <<
"\n iActiveBit = " << iActiveBit
421 <<
"\n altNrBxBoardInitial = 0x" << std::hex << altNrBxBoardInitial <<
std::dec
422 <<
"\n activeBoardsGt = 0x" << std::hex << activeBoardsGt <<
std::dec
423 <<
"\n activeBoardInitial = " << activeBoardInitial
424 <<
"\n activeBoardToUnpack = " << activeBoardToUnpack <<
"\n Set altNrBxBoardVal tentatively to "
436 LogDebug(
"L1GlobalTriggerEvmRawToDigi")
437 <<
"\nWARNING: Number of available bunch crosses for board" << (itBoard->gtBoardId())
439 <<
" ) \n is smaller than the number of bunch crosses requested to be unpacked (" <<
m_unpackBxInEvent
452 LogDebug(
"L1GlobalTriggerEvmRawToDigi")
463 LogDebug(
"L1GlobalTriggerEvmRawToDigi")
464 <<
"\nNo bxInEvent required to be unpacked from " <<
m_totalBxInEvent <<
" bunch crosses available."
496 if (!activeBoardInitial) {
498 LogDebug(
"L1GlobalTriggerEvmRawToDigi") <<
"\nBoard of type " << itBoard->gtBoardName() <<
" with index "
499 << itBoard->gtBoardIndex() <<
" not active initially in raw data.\n"
506 switch (itBoard->gtBoardType()) {
511 edm::LogError(
"L1GlobalTriggerEvmRawToDigi") <<
"\nError: Pointer after TCS "
512 <<
" greater than end pointer."
513 <<
"\n Put empty products in the event!"
514 <<
"\n Quit unpacking this event." << std::endl;
522 if (activeBoardToUnpack) {
535 std::ostringstream myCoutStream;
537 LogTrace(
"L1GlobalTriggerEvmRawToDigi") << myCoutStream.str() <<
"\n" << std::endl;
553 <<
"\nError: Pointer after FDL " << iFdl <<
" greater than end pointer."
554 <<
"\n Put empty products in the event!"
555 <<
"\n Quit unpacking this event." << std::endl;
563 if (activeBoardToUnpack) {
578 std::ostringstream myCoutStream;
580 LogTrace(
"L1GlobalTriggerEvmRawToDigi") << myCoutStream.str() <<
"\n" << std::endl;
596 LogDebug(
"L1GlobalTriggerEvmRawToDigi")
597 <<
"\nBoard of type " << itBoard->gtBoardType() <<
" not expected in record.\n"
617 if ((ptrGt + trailerSize) > endPtrGt) {
618 edm::LogError(
"L1GlobalTriggerEvmRawToDigi") <<
"\nError: Pointer after trailer "
619 <<
" greater than end pointer."
620 <<
"\n Put empty products in the event!"
621 <<
"\n Quit unpacking this event." << std::endl;
631 std::ostringstream myCoutStream;
632 gtReadoutRecord->print(myCoutStream);
633 LogTrace(
"L1GlobalTriggerEvmRawToDigi") <<
"\n The following L1 GT EVM readout record was unpacked.\n"
634 << myCoutStream.str() <<
"\n"
650 std::ostringstream myCoutStream;
655 myCoutStream << std::setw(4) << iWord <<
" " << std::hex << std::setfill(
'0') << std::setw(16) << payload[iWord]
656 <<
std::dec << std::setfill(
' ') <<
"\n"
659 myCoutStream <<
" Event_type: " << std::hex <<
" hex: "
660 <<
" " << std::setw(1) << std::setfill(
'0') << cmsHeader.
triggerType() << std::setfill(
' ')
663 myCoutStream <<
" LVL1_Id: " << std::hex <<
" hex: "
664 <<
"" << std::setw(6) << std::setfill(
'0') << cmsHeader.
lvl1ID() << std::setfill(
' ') <<
std::dec
665 <<
" dec: " << cmsHeader.
lvl1ID() << std::endl;
667 myCoutStream <<
" BX_Id: " << std::hex <<
" hex: "
668 <<
" " << std::setw(3) << std::setfill(
'0') << cmsHeader.
bxID() << std::setfill(
' ') <<
std::dec
669 <<
" dec: " << cmsHeader.
bxID() << std::endl;
671 myCoutStream <<
" Source_Id: " << std::hex <<
" hex: "
672 <<
" " << std::setw(3) << std::setfill(
'0') << cmsHeader.
sourceID() << std::setfill(
' ') <<
std::dec
673 <<
" dec: " << cmsHeader.
sourceID() << std::endl;
675 myCoutStream <<
" FOV: " << std::hex <<
" hex: "
676 <<
" " << std::setw(1) << std::setfill(
'0') << cmsHeader.
version() << std::setfill(
' ') <<
std::dec
677 <<
" dec: " << cmsHeader.
version() << std::endl;
679 myCoutStream <<
" H: " << std::hex <<
" hex: "
680 <<
" " << std::setw(1) << std::setfill(
'0') << cmsHeader.
moreHeaders() << std::setfill(
' ')
683 LogDebug(
"L1GlobalTriggerEvmRawToDigi") <<
"\n CMS Header \n" << myCoutStream.str() <<
"\n" << std::endl;
696 std::ostringstream myCoutStream;
701 myCoutStream << std::setw(4) << iWord <<
" " << std::hex << std::setfill(
'0') << std::setw(16) << payload[iWord]
702 <<
std::dec << std::setfill(
' ') <<
"\n"
705 myCoutStream <<
" Event_length: " << std::hex <<
" hex: "
706 <<
"" << std::setw(6) << std::setfill(
'0') << cmsTrailer.
fragmentLength() << std::setfill(
' ')
709 myCoutStream <<
" CRC: " << std::hex <<
" hex: "
710 <<
" " << std::setw(4) << std::setfill(
'0') << cmsTrailer.
crc() << std::setfill(
' ') <<
std::dec
711 <<
" dec: " << cmsTrailer.
crc() << std::endl;
713 myCoutStream <<
" Event_status: " << std::hex <<
" hex: "
714 <<
" " << std::setw(2) << std::setfill(
'0') << cmsTrailer.
evtStatus() << std::setfill(
' ')
717 myCoutStream <<
" TTS_bits: " << std::hex <<
" hex: "
718 <<
" " << std::setw(1) << std::setfill(
'0') << cmsTrailer.
ttsBits() << std::setfill(
' ')
721 myCoutStream <<
" More trailers: " << std::hex <<
" hex: "
722 <<
" " << std::setw(1) << std::setfill(
'0') << cmsTrailer.
moreTrailers() << std::setfill(
' ')
725 LogDebug(
"L1GlobalTriggerEvmRawToDigi") <<
"\n CMS Trailer \n" << myCoutStream.str() <<
"\n" << std::endl;
740 LogDebug(
"L1GlobalTriggerEvmRawToDigi") <<
"\nDump FED raw data.\n" << std::endl;
745 int gtWords = gtSize / uLength;
746 LogTrace(
"L1GlobalTriggerEvmRawToDigi") <<
"\nFED GT words (" << wLength <<
" bits):" << gtWords <<
"\n" << std::endl;
751 myCout << std::setw(4) <<
i <<
" " << std::hex << std::setfill(
'0') << std::setw(16) << payload[
i] <<
std::dec
752 << std::setfill(
' ') << std::endl;
int m_bstLengthBytes
length of BST record (in bytes)
int m_verbosity
verbosity level
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
void produce(edm::Event &, const edm::EventSetup &) override
int m_totalBxInEvent
number of Bx for a board, obtained from GTFE block (record length & alternative)
void produceEmptyProducts(edm::Event &)
produce empty products in case of problems
void reset()
reset the content of a L1TcsWord
static const int UnitLength
one unit in the word is UnitLength bits
const unsigned int gtBstLengthBytes() const
get / set length of BST message (in bytes) for L1 GT EVM record
void unpack(const unsigned char *fdlPtr)
uint16_t crc() const
Cyclic Redundancy Code of the event fragment including header and trailer.
const cms_uint16_t luminositySegmentNr() const
get/set luminosity segment number
bool moreTrailers() const
Log< level::Error, false > LogError
void dumpFedRawData(const unsigned char *, int, std::ostream &)
dump FED raw data
void setRecordLength(cms_uint16_t recordLengthValue)
void setLuminositySegmentNr(const cms_uint16_t luminositySegmentNrValue)
const edm::ESGetToken< L1GtBoardMaps, L1GtBoardMapsRcd > m_l1GtBMToken
EventSetup Token for L1GtBoardMaps.
const unsigned int getSize() const
get the size of the FDL block in GT DAQ record (in multiple of 8 bits)
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.
static const int WordLength
GT DAQ record organized in words of WordLength bits.
uint32_t fragmentLength() const
The length of the event fragment counted in 64-bit words including header and trailer.
cms_uint16_t m_activeBoardsMaskGt
mask for active boards
const unsigned int getSize() const
get the size of the GTFE block in GT EVM record (in multiple of 8 bits)
const cms_uint16_t recordLength() const
get/set record length for alternative 0
edm::ESGetToken< L1GtParameters, L1GtParametersRcd > m_l1GtParamToken
EventSetup Token for L1GtParameters.
void print(std::ostream &myCout) const
pretty print the content of a L1TcsWord
void setLumiSegmentNr(const cms_uint16_t &lumiSegmentNrValue)
void reset()
reset the content of a L1GtFdlWord
unsigned short cms_uint16_t
void print(std::ostream &myCout) const override
pretty print the content of a L1GtfeExtWord
void setRecordLength1(cms_uint16_t recordLengthValue)
void unpackHeader(const unsigned char *, FEDHeader &)
block unpackers
L1GtfeExtWord * m_gtfeWord
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
const cms_uint16_t activeBoards() const
get/set boards contributing to EVM respectively DAQ record
int m_recordLength1
corresponding to alternative 1 in altNrBxBoard()
void print(std::ostream &myCout) const
pretty print the content of a L1GtFdlWord
Log< level::Info, false > LogInfo
void resize(int bstSizeBytes)
resize the BST vector to get the right size of the block
int m_recordLength0
total Bx's in the event, obtained from GTFE block
const cms_uint16_t lumiSegmentNr() const
get/set luminosity segment number of the actual bx
uint8_t ttsBits() const
Current value of the Trigger Throttling System bits.
T const * product() const
L1GlobalTriggerEvmRawToDigi(const edm::ParameterSet &)
constructor(s)
void setActiveBoards(cms_uint16_t activeBoardsValue)
T const * product() const
uint8_t evtStatus() const
Event fragment status information.
const unsigned int getSize() const
get the size of the TCS block in GT EVM record (in multiple of 8 bits)
void unpack(const unsigned char *tcsPtr)
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
L1GtFdlWord * m_gtFdlWord
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
unsigned long long cms_uint64_t
Log< level::Warning, false > LogWarning
const cms_uint16_t recordLength1() const
get/set record length for alternative 1
void reset() override
reset the content of a L1GtfeExtWord
void unpackTrailer(const unsigned char *, FEDTrailer &)
unpack trailer word
void unpack(const unsigned char *gtfePtr) override
~L1GlobalTriggerEvmRawToDigi() override
destructor
edm::InputTag m_evmGtInputTag
input tags for GT EVM record