59 m_evmGtInputTag(pSet.getParameter<edm::
InputTag> (
"EvmGtInputTag")),
64 m_evmGtFedId(pSet.getUntrackedParameter<int> (
68 m_activeBoardsMaskGt(pSet.getParameter<unsigned int> (
"ActiveBoardsMask")),
71 m_unpackBxInEvent(pSet.getParameter<int> (
"UnpackBxInEvent")),
73 m_lowSkipBxInEvent(0), m_uppSkipBxInEvent(0),
75 m_recordLength0(0), m_recordLength1(0),
80 m_bstLengthBytes(pSet.getParameter<int> (
"BstLengthBytes")),
82 m_verbosity(pSet.getUntrackedParameter<int> (
"Verbosity", 0)),
88 produces<L1GlobalTriggerEvmReadoutRecord> ();
92 LogDebug(
"L1GlobalTriggerEvmRawToDigi")
95 <<
"\nMask for active boards (hex format): " << std::hex
109 <<
"\nWARNING: Number of bunch crossing to be unpacked rounded to: "
145 const std::vector<L1GtBoard> boardMaps = l1GtBM->gtBoardMaps();
146 int boardMapsSize = boardMaps.size();
148 typedef std::vector<L1GtBoard>::const_iterator CItBoardMaps;
153 std::vector<L1GtBoard> gtRecordMap;
154 gtRecordMap.reserve(boardMapsSize);
156 for (
int iPos = 0; iPos < boardMapsSize; ++iPos) {
157 for (CItBoardMaps itBoard = boardMaps.begin(); itBoard != boardMaps.end(); ++itBoard) {
159 if (itBoard->gtPositionEvmRecord() == iPos) {
160 gtRecordMap.push_back(*itBoard);
175 <<
"\nWarning: FEDRawDataCollection with input tag " <<
m_evmGtInputTag
176 <<
"\nrequested in configuration, but not found in the event."
177 <<
"\nQuit unpacking this event" << std::endl;
188 int gtSize = raw.
size();
191 const unsigned char* ptrGt = raw.
data();
194 const unsigned char* endPtrGt = ptrGt + gtSize;
199 LogTrace(
"L1GlobalTriggerEvmRawToDigi") <<
"\n Size of raw data: "
200 << gtSize <<
"\n" << std::endl;
202 std::ostringstream myCoutStream;
205 LogTrace(
"L1GlobalTriggerEvmRawToDigi") <<
"\n Dump FEDRawData\n"
206 << myCoutStream.str() <<
"\n" << std::endl;
213 if ((ptrGt + headerSize) > endPtrGt) {
215 <<
"\nError: Pointer after header greater than end pointer."
216 <<
"\n Put empty products in the event!"
217 <<
"\n Quit unpacking this event." << std::endl;
225 FEDTrailer cmsTrailer(ptrGt + gtSize - headerSize);
233 bool gtfeUnpacked =
false;
237 int bstLengthBytes = 0;
254 LogTrace(
"L1GlobalTriggerEvmRawToDigi") <<
"\n Length of BST message (in bytes): "
255 << bstLengthBytes <<
"\n" << std::endl;
258 for (CItBoardMaps itBoard = boardMaps.begin(); itBoard != boardMaps.end(); ++itBoard) {
260 if (itBoard->gtBoardType() ==
GTFE) {
263 if (itBoard->gtPositionEvmRecord() == 1) {
274 std::ostringstream myCoutStream;
276 LogTrace(
"L1GlobalTriggerEvmRawToDigi") << myCoutStream.str() <<
"\n"
287 <<
"\nWarning: GTFE block found in raw data does not follow header."
288 <<
"\nAssumed start position of the block is wrong!"
289 <<
"\nQuit unpacking this event" << std::endl;
306 <<
"\nWarning: no GTFE block found in raw data."
307 <<
"\nCan not find the record length (BxInEvent) and the active boards!"
308 <<
"\nQuit unpacking this event" << std::endl;
328 LogDebug(
"L1GlobalTriggerEvmRawToDigi") <<
"\nActive boards before masking(hex format): "
329 << std::hex << std::setw(
sizeof ( activeBoardsGtInitial ) * 2) << std::setfill(
'0')
330 << activeBoardsGtInitial <<
std::dec << std::setfill(
' ')
331 <<
"\nActive boards after masking(hex format): " << std::hex << std::setw(
332 sizeof ( activeBoardsGt ) * 2) << std::setfill(
'0') << activeBoardsGt <<
std::dec
333 << std::setfill(
' ') <<
" \n" << std::endl;
338 int numberGtfeBoards = 0;
339 int numberFdlBoards = 0;
340 int numberPsbBoards = 0;
341 int numberGmtBoards = 0;
342 int numberTcsBoards = 0;
343 int numberTimBoards = 0;
345 for (CItBoardMaps itBoard = boardMaps.begin(); itBoard != boardMaps.end(); ++itBoard) {
347 int iActiveBit = itBoard->gtBitEvmActiveBoards();
348 bool activeBoardToUnpack =
false;
350 if (iActiveBit >= 0) {
351 activeBoardToUnpack = activeBoardsGt & ( 1 << iActiveBit );
357 if (activeBoardToUnpack) {
359 switch (itBoard->gtBoardType()) {
393 LogDebug(
"L1GlobalTriggerEvmRawToDigi") <<
"\nBoard of type "
394 << itBoard->gtBoardType() <<
" not expected in record.\n"
418 std::auto_ptr<L1GlobalTriggerEvmReadoutRecord> gtReadoutRecord(
423 for (CItBoardMaps itBoard = gtRecordMap.begin(); itBoard != gtRecordMap.end(); ++itBoard) {
425 int iActiveBit = itBoard->gtBitEvmActiveBoards();
427 bool activeBoardToUnpack =
false;
428 bool activeBoardInitial =
false;
430 int altNrBxBoardVal = -1;
432 if (iActiveBit >= 0) {
433 activeBoardInitial = activeBoardsGtInitial & ( 1 << iActiveBit );
434 activeBoardToUnpack = activeBoardsGt & ( 1 << iActiveBit );
436 altNrBxBoardVal = (altNrBxBoardInitial & ( 1 << iActiveBit )) >> iActiveBit;
438 if (altNrBxBoardVal == 1) {
440 }
else if (altNrBxBoardVal == 0) {
445 <<
"\n\nWARNING: Wrong value altNrBxBoardVal = " << altNrBxBoardVal
446 <<
" for board " << std::hex << ( itBoard->gtBoardId() ) <<
std::dec
447 <<
"\n iActiveBit = " << iActiveBit
448 <<
"\n altNrBxBoardInitial = 0x" << std::hex << altNrBxBoardInitial <<
std::dec
449 <<
"\n activeBoardsGt = 0x" << std::hex << activeBoardsGt <<
std::dec
450 <<
"\n activeBoardInitial = " << activeBoardInitial
451 <<
"\n activeBoardToUnpack = " << activeBoardToUnpack
452 <<
"\n Set altNrBxBoardVal tentatively to "
464 LogDebug(
"L1GlobalTriggerEvmRawToDigi")
465 <<
"\nWARNING: Number of available bunch crosses for board"
467 <<
" ) \n is smaller than the number of bunch crosses requested to be unpacked ("
482 <<
" bunch crosses available." <<
"\n" << std::endl;
491 LogDebug(
"L1GlobalTriggerEvmRawToDigi")
493 <<
" bunch crosses available." <<
"\n" << std::endl;
509 <<
" bunch crosses available." <<
"\n" << std::endl;
524 if (!activeBoardInitial) {
526 LogDebug(
"L1GlobalTriggerEvmRawToDigi") <<
"\nBoard of type "
527 << itBoard->gtBoardName() <<
" with index " << itBoard->gtBoardIndex()
528 <<
" not active initially in raw data.\n" << std::endl;
534 switch (itBoard->gtBoardType()) {
542 <<
"\nError: Pointer after TCS "
543 <<
" greater than end pointer."
544 <<
"\n Put empty products in the event!"
545 <<
"\n Quit unpacking this event." << std::endl;
553 if (activeBoardToUnpack) {
568 std::ostringstream myCoutStream;
570 LogTrace(
"L1GlobalTriggerEvmRawToDigi") << myCoutStream.str() <<
"\n"
589 <<
"\nError: Pointer after FDL " << iFdl
590 <<
" greater than end pointer."
591 <<
"\n Put empty products in the event!"
592 <<
"\n Quit unpacking this event." << std::endl;
600 if (activeBoardToUnpack) {
618 std::ostringstream myCoutStream;
620 LogTrace(
"L1GlobalTriggerEvmRawToDigi") << myCoutStream.str()
621 <<
"\n" << std::endl;
639 LogDebug(
"L1GlobalTriggerEvmRawToDigi") <<
"\nBoard of type "
640 << itBoard->gtBoardType() <<
" not expected in record.\n" << std::endl;
662 if ((ptrGt + trailerSize) > endPtrGt) {
664 <<
"\nError: Pointer after trailer "
665 <<
" greater than end pointer."
666 <<
"\n Put empty products in the event!"
667 <<
"\n Quit unpacking this event." << std::endl;
677 std::ostringstream myCoutStream;
678 gtReadoutRecord->print(myCoutStream);
679 LogTrace(
"L1GlobalTriggerEvmRawToDigi")
680 <<
"\n The following L1 GT EVM readout record was unpacked.\n"
681 << myCoutStream.str() <<
"\n" << std::endl;
685 iEvent.
put(gtReadoutRecord);
698 reinterpret_cast<cms_uint64_t*
> (
const_cast<unsigned char*
> (gtPtr));
700 std::ostringstream myCoutStream;
705 myCoutStream << std::setw(4) << iWord <<
" " << std::hex << std::setfill(
'0')
706 << std::setw(16) << payload[iWord] <<
std::dec << std::setfill(
' ') <<
"\n"
709 myCoutStream <<
" Event_type: " << std::hex <<
" hex: " <<
" " << std::setw(1)
711 <<
" dec: " << cmsHeader.
triggerType() << std::endl;
713 myCoutStream <<
" LVL1_Id: " << std::hex <<
" hex: " <<
"" << std::setw(6)
714 << std::setfill(
'0') << cmsHeader.
lvl1ID() << std::setfill(
' ') <<
std::dec
715 <<
" dec: " << cmsHeader.
lvl1ID() << std::endl;
717 myCoutStream <<
" BX_Id: " << std::hex <<
" hex: " <<
" " << std::setw(3)
718 << std::setfill(
'0') << cmsHeader.
bxID() << std::setfill(
' ') <<
std::dec
719 <<
" dec: " << cmsHeader.
bxID() << std::endl;
721 myCoutStream <<
" Source_Id: " << std::hex <<
" hex: " <<
" " << std::setw(3)
722 << std::setfill(
'0') << cmsHeader.
sourceID() << std::setfill(
' ') <<
std::dec
723 <<
" dec: " << cmsHeader.
sourceID() << std::endl;
725 myCoutStream <<
" FOV: " << std::hex <<
" hex: " <<
" " << std::setw(1)
726 << std::setfill(
'0') << cmsHeader.
version() << std::setfill(
' ') <<
std::dec
727 <<
" dec: " << cmsHeader.
version() << std::endl;
729 myCoutStream <<
" H: " << std::hex <<
" hex: " <<
" " << std::setw(1)
731 <<
" dec: " << cmsHeader.
moreHeaders() << std::endl;
733 LogDebug(
"L1GlobalTriggerEvmRawToDigi") <<
"\n CMS Header \n" << myCoutStream.str() <<
"\n"
750 reinterpret_cast<cms_uint64_t*
> (
const_cast<unsigned char*
> (trlPtr));
752 std::ostringstream myCoutStream;
757 myCoutStream << std::setw(4) << iWord <<
" " << std::hex << std::setfill(
'0')
758 << std::setw(16) << payload[iWord] <<
std::dec << std::setfill(
' ') <<
"\n"
761 myCoutStream <<
" Event_length: " << std::hex <<
" hex: " <<
"" << std::setw(6)
762 << std::setfill(
'0') << cmsTrailer.
lenght() << std::setfill(
' ') <<
std::dec
763 <<
" dec: " << cmsTrailer.
lenght() << std::endl;
765 myCoutStream <<
" CRC: " << std::hex <<
" hex: " <<
" " << std::setw(4)
766 << std::setfill(
'0') << cmsTrailer.
crc() << std::setfill(
' ') <<
std::dec
767 <<
" dec: " << cmsTrailer.
crc() << std::endl;
769 myCoutStream <<
" Event_status: " << std::hex <<
" hex: " <<
" " << std::setw(2)
771 <<
" dec: " << cmsTrailer.
evtStatus() << std::endl;
773 myCoutStream <<
" TTS_bits: " << std::hex <<
" hex: " <<
" " << std::setw(1)
774 << std::setfill(
'0') << cmsTrailer.
ttsBits() << std::setfill(
' ') <<
std::dec
775 <<
" dec: " << cmsTrailer.
ttsBits() << std::endl;
777 myCoutStream <<
" More trailers: " << std::hex <<
" hex: " <<
" " << std::setw(1)
781 LogDebug(
"L1GlobalTriggerEvmRawToDigi") <<
"\n CMS Trailer \n" << myCoutStream.str()
782 <<
"\n" << std::endl;
791 std::auto_ptr<L1GlobalTriggerEvmReadoutRecord> gtReadoutRecord(
796 iEvent.
put(gtReadoutRecord);
801 const unsigned char* gtPtr,
int gtSize, std::ostream& myCout) {
803 LogDebug(
"L1GlobalTriggerEvmRawToDigi") <<
"\nDump FED raw data.\n" << std::endl;
808 int gtWords = gtSize / uLength;
809 LogTrace(
"L1GlobalTriggerEvmRawToDigi") <<
"\nFED GT words (" << wLength <<
" bits):"
810 << gtWords <<
"\n" << std::endl;
813 reinterpret_cast<cms_uint64_t*
> (
const_cast<unsigned char*
> (gtPtr));
816 myCout << std::setw(4) <<
i <<
" " << std::hex << std::setfill(
'0') << std::setw(16)
817 << payload[
i] <<
std::dec << std::setfill(
' ') << std::endl;
int m_bstLengthBytes
length of BST record (in bytes)
int m_verbosity
verbosity level
virtual 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
void reset()
reset the content of a L1GtfeExtWord
int evtStatus()
Event fragment status information.
const unsigned int gtBstLengthBytes() const
get / set length of BST message (in bytes) for L1 GT EVM record
void unpack(const unsigned char *fdlPtr)
const cms_uint16_t luminositySegmentNr() const
get/set luminosity segment number
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)
virtual ~L1GlobalTriggerEvmRawToDigi()
destructor
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.
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
void print(std::ostream &myCout) const
pretty print the content of a L1TcsWord
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
virtual void unpack(const unsigned char *gtfePtr)
void setLumiSegmentNr(const cms_uint16_t &lumiSegmentNrValue)
void reset()
reset the content of a L1GtFdlWord
unsigned short cms_uint16_t
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
int ttsBits()
Current value of the Trigger Throttling System bitsAQ).
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
T const * product() const
L1GlobalTriggerEvmRawToDigi(const edm::ParameterSet &)
constructor(s)
int lenght()
The length of the event fragment counted in 64-bit words including header and trailer.
void setActiveBoards(cms_uint16_t activeBoardsValue)
T const * product() const
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.
virtual void print(std::ostream &myCout) const
pretty print the content of a L1GtfeExtWord
int crc()
Cyclic Redundancy Code of the event fragment including header and trailer.
L1GtFdlWord * m_gtFdlWord
unsigned long long cms_uint64_t
const cms_uint16_t recordLength1() const
get/set record length for alternative 1
void unpackTrailer(const unsigned char *, FEDTrailer &)
unpack trailer word
edm::InputTag m_evmGtInputTag
input tags for GT EVM record