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 numberFdlBoards = 0;
318 for (CItBoardMaps itBoard = boardMaps.begin(); itBoard != boardMaps.end(); ++itBoard) {
319 int iActiveBit = itBoard->gtBitEvmActiveBoards();
320 bool activeBoardToUnpack =
false;
322 if (iActiveBit >= 0) {
323 activeBoardToUnpack = activeBoardsGt & (1 << iActiveBit);
329 if (activeBoardToUnpack) {
330 switch (itBoard->gtBoardType()) {
349 LogDebug(
"L1GlobalTriggerEvmRawToDigi")
350 <<
"\nBoard of type " << itBoard->gtBoardType() <<
" not expected in record.\n" 373 std::unique_ptr<L1GlobalTriggerEvmReadoutRecord> gtReadoutRecord(
378 for (CItBoardMaps itBoard = gtRecordMap.begin(); itBoard != gtRecordMap.end(); ++itBoard) {
379 int iActiveBit = itBoard->gtBitEvmActiveBoards();
381 bool activeBoardToUnpack =
false;
382 bool activeBoardInitial =
false;
384 int altNrBxBoardVal = -1;
386 if (iActiveBit >= 0) {
387 activeBoardInitial = activeBoardsGtInitial & (1 << iActiveBit);
388 activeBoardToUnpack = activeBoardsGt & (1 << iActiveBit);
390 altNrBxBoardVal = (altNrBxBoardInitial & (1 << iActiveBit)) >> iActiveBit;
392 if (altNrBxBoardVal == 1) {
394 }
else if (altNrBxBoardVal == 0) {
399 <<
"\n\nWARNING: Wrong value altNrBxBoardVal = " << altNrBxBoardVal <<
" for board " << std::hex
400 << (itBoard->gtBoardId()) <<
std::dec <<
"\n iActiveBit = " << iActiveBit
401 <<
"\n altNrBxBoardInitial = 0x" << std::hex << altNrBxBoardInitial <<
std::dec 402 <<
"\n activeBoardsGt = 0x" << std::hex << activeBoardsGt <<
std::dec 403 <<
"\n activeBoardInitial = " << activeBoardInitial
404 <<
"\n activeBoardToUnpack = " << activeBoardToUnpack <<
"\n Set altNrBxBoardVal tentatively to " 416 LogDebug(
"L1GlobalTriggerEvmRawToDigi")
417 <<
"\nWARNING: Number of available bunch crosses for board" << (itBoard->gtBoardId())
419 <<
" ) \n is smaller than the number of bunch crosses requested to be unpacked (" <<
m_unpackBxInEvent 432 LogDebug(
"L1GlobalTriggerEvmRawToDigi")
443 LogDebug(
"L1GlobalTriggerEvmRawToDigi")
444 <<
"\nNo bxInEvent required to be unpacked from " <<
m_totalBxInEvent <<
" bunch crosses available." 476 if (!activeBoardInitial) {
478 LogDebug(
"L1GlobalTriggerEvmRawToDigi") <<
"\nBoard of type " << itBoard->gtBoardName() <<
" with index " 479 << itBoard->gtBoardIndex() <<
" not active initially in raw data.\n" 486 switch (itBoard->gtBoardType()) {
491 edm::LogError(
"L1GlobalTriggerEvmRawToDigi") <<
"\nError: Pointer after TCS " 492 <<
" greater than end pointer." 493 <<
"\n Put empty products in the event!" 494 <<
"\n Quit unpacking this event." << std::endl;
502 if (activeBoardToUnpack) {
515 std::ostringstream myCoutStream;
517 LogTrace(
"L1GlobalTriggerEvmRawToDigi") << myCoutStream.str() <<
"\n" << std::endl;
533 <<
"\nError: Pointer after FDL " << iFdl <<
" greater than end pointer." 534 <<
"\n Put empty products in the event!" 535 <<
"\n Quit unpacking this event." << std::endl;
543 if (activeBoardToUnpack) {
558 std::ostringstream myCoutStream;
560 LogTrace(
"L1GlobalTriggerEvmRawToDigi") << myCoutStream.str() <<
"\n" << std::endl;
576 LogDebug(
"L1GlobalTriggerEvmRawToDigi")
577 <<
"\nBoard of type " << itBoard->gtBoardType() <<
" not expected in record.\n" 597 if ((ptrGt + trailerSize) > endPtrGt) {
598 edm::LogError(
"L1GlobalTriggerEvmRawToDigi") <<
"\nError: Pointer after trailer " 599 <<
" greater than end pointer." 600 <<
"\n Put empty products in the event!" 601 <<
"\n Quit unpacking this event." << std::endl;
611 std::ostringstream myCoutStream;
612 gtReadoutRecord->print(myCoutStream);
613 LogTrace(
"L1GlobalTriggerEvmRawToDigi") <<
"\n The following L1 GT EVM readout record was unpacked.\n" 614 << myCoutStream.str() <<
"\n" 630 std::ostringstream myCoutStream;
635 myCoutStream << std::setw(4) << iWord <<
" " << std::hex << std::setfill(
'0') << std::setw(16) <<
payload[iWord]
636 <<
std::dec << std::setfill(
' ') <<
"\n" 639 myCoutStream <<
" Event_type: " << std::hex <<
" hex: " 640 <<
" " << std::setw(1) << std::setfill(
'0') << cmsHeader.
triggerType() << std::setfill(
' ')
643 myCoutStream <<
" LVL1_Id: " << std::hex <<
" hex: " 644 <<
"" << std::setw(6) << std::setfill(
'0') << cmsHeader.
lvl1ID() << std::setfill(
' ') <<
std::dec 645 <<
" dec: " << cmsHeader.
lvl1ID() << std::endl;
647 myCoutStream <<
" BX_Id: " << std::hex <<
" hex: " 648 <<
" " << std::setw(3) << std::setfill(
'0') << cmsHeader.
bxID() << std::setfill(
' ') <<
std::dec 649 <<
" dec: " << cmsHeader.
bxID() << std::endl;
651 myCoutStream <<
" Source_Id: " << std::hex <<
" hex: " 652 <<
" " << std::setw(3) << std::setfill(
'0') << cmsHeader.
sourceID() << std::setfill(
' ') <<
std::dec 653 <<
" dec: " << cmsHeader.
sourceID() << std::endl;
655 myCoutStream <<
" FOV: " << std::hex <<
" hex: " 656 <<
" " << std::setw(1) << std::setfill(
'0') << cmsHeader.
version() << std::setfill(
' ') <<
std::dec 657 <<
" dec: " << cmsHeader.
version() << std::endl;
659 myCoutStream <<
" H: " << std::hex <<
" hex: " 660 <<
" " << std::setw(1) << std::setfill(
'0') << cmsHeader.
moreHeaders() << std::setfill(
' ')
663 LogDebug(
"L1GlobalTriggerEvmRawToDigi") <<
"\n CMS Header \n" << myCoutStream.str() <<
"\n" << std::endl;
676 std::ostringstream myCoutStream;
681 myCoutStream << std::setw(4) << iWord <<
" " << std::hex << std::setfill(
'0') << std::setw(16) <<
payload[iWord]
682 <<
std::dec << std::setfill(
' ') <<
"\n" 685 myCoutStream <<
" Event_length: " << std::hex <<
" hex: " 686 <<
"" << std::setw(6) << std::setfill(
'0') << cmsTrailer.
fragmentLength() << std::setfill(
' ')
689 myCoutStream <<
" CRC: " << std::hex <<
" hex: " 690 <<
" " << std::setw(4) << std::setfill(
'0') << cmsTrailer.
crc() << std::setfill(
' ') <<
std::dec 691 <<
" dec: " << cmsTrailer.
crc() << std::endl;
693 myCoutStream <<
" Event_status: " << std::hex <<
" hex: " 694 <<
" " << std::setw(2) << std::setfill(
'0') << cmsTrailer.
evtStatus() << std::setfill(
' ')
697 myCoutStream <<
" TTS_bits: " << std::hex <<
" hex: " 698 <<
" " << std::setw(1) << std::setfill(
'0') << cmsTrailer.
ttsBits() << std::setfill(
' ')
701 myCoutStream <<
" More trailers: " << std::hex <<
" hex: " 702 <<
" " << std::setw(1) << std::setfill(
'0') << cmsTrailer.
moreTrailers() << std::setfill(
' ')
705 LogDebug(
"L1GlobalTriggerEvmRawToDigi") <<
"\n CMS Trailer \n" << myCoutStream.str() <<
"\n" << std::endl;
720 LogDebug(
"L1GlobalTriggerEvmRawToDigi") <<
"\nDump FED raw data.\n" << std::endl;
725 int gtWords = gtSize / uLength;
726 LogTrace(
"L1GlobalTriggerEvmRawToDigi") <<
"\nFED GT words (" << wLength <<
" bits):" << gtWords <<
"\n" << std::endl;
731 myCout << std::setw(4) <<
i <<
" " << std::hex << std::setfill(
'0') << std::setw(16) <<
payload[
i] <<
std::dec 732 << std::setfill(
' ') << std::endl;
int m_bstLengthBytes
length of BST record (in bytes)
const cms_uint16_t altNrBxBoard() const
get/set alternative for number of BX per board
int m_verbosity
verbosity level
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
const cms_uint16_t recordLength1() const
get/set record length for alternative 1
void reset()
reset the content of a L1TcsWord
uint8_t ttsBits() const
Current value of the Trigger Throttling System bits.
static const int UnitLength
one unit in the word is UnitLength bits
T const * product() const
void unpack(const unsigned char *fdlPtr)
size_t size() const
Lenght of the data buffer in bytes.
const cms_uint16_t luminositySegmentNr() const
get/set luminosity segment number
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.
static const int WordLength
GT DAQ record organized in words of WordLength bits.
cms_uint16_t m_activeBoardsMaskGt
mask for active boards
uint32_t fragmentLength() const
The length of the event fragment counted in 64-bit words including header and trailer.
const cms_uint16_t recordLength() const
get/set record length for alternative 0
T const * product() const
edm::ESGetToken< L1GtParameters, L1GtParametersRcd > m_l1GtParamToken
EventSetup Token for L1GtParameters.
void setLumiSegmentNr(const cms_uint16_t &lumiSegmentNrValue)
void reset()
reset the content of a L1GtFdlWord
uint16_t crc() const
Cyclic Redundancy Code of the event fragment including header and trailer.
unsigned short cms_uint16_t
void print(std::ostream &myCout) const override
pretty print the content of a L1GtfeExtWord
const unsigned int getSize() const
get the size of the TCS block in GT EVM record (in multiple of 8 bits)
void setRecordLength1(cms_uint16_t recordLengthValue)
const std::vector< L1GtBoard > & gtBoardMaps() const
get / set / print the L1 GT board map
void unpackHeader(const unsigned char *, FEDHeader &)
block unpackers
uint8_t evtStatus() const
Event fragment status information.
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
L1GtfeExtWord * m_gtfeWord
int m_recordLength1
corresponding to alternative 1 in altNrBxBoard()
const cms_uint16_t lumiSegmentNr() const
get/set luminosity segment number of the actual bx
Log< level::Info, false > LogInfo
void resize(int bstSizeBytes)
resize the BST vector to get the right size of the block
void print(std::ostream &myCout) const
pretty print the content of a L1TcsWord
int m_recordLength0
total Bx's in the event, obtained from GTFE block
L1GlobalTriggerEvmRawToDigi(const edm::ParameterSet &)
constructor(s)
void setActiveBoards(cms_uint16_t activeBoardsValue)
const unsigned int getSize() const
get the size of the FDL block in GT DAQ 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.
void print(std::ostream &myCout) const
pretty print the content of a L1GtFdlWord
L1GtFdlWord * m_gtFdlWord
const unsigned int getSize() const
get the size of the GTFE block in GT EVM record (in multiple of 8 bits)
unsigned long long cms_uint64_t
const cms_uint16_t activeBoards() const
get/set boards contributing to EVM respectively DAQ record
Log< level::Warning, false > LogWarning
void reset() override
reset the content of a L1GtfeExtWord
void unpackTrailer(const unsigned char *, FEDTrailer &)
unpack trailer word
const unsigned int gtBstLengthBytes() const
get / set length of BST message (in bytes) for L1 GT EVM record
void unpack(const unsigned char *gtfePtr) override
~L1GlobalTriggerEvmRawToDigi() override
destructor
bool moreTrailers() const
edm::InputTag m_evmGtInputTag
input tags for GT EVM record