61 m_evmGtInputTag(pSet.getParameter<edm::InputTag> (
"EvmGtInputTag")),
66 m_evmGtFedId(pSet.getUntrackedParameter<int> (
70 m_activeBoardsMaskGt(pSet.getParameter<unsigned int> (
"ActiveBoardsMask")),
73 m_unpackBxInEvent(pSet.getParameter<int> (
"UnpackBxInEvent")),
75 m_lowSkipBxInEvent(0), m_uppSkipBxInEvent(0),
77 m_recordLength0(0), m_recordLength1(0),
82 m_bstLengthBytes(pSet.getParameter<int> (
"BstLengthBytes")),
84 m_verbosity(pSet.getUntrackedParameter<int> (
"Verbosity", 0)),
90 produces<L1GlobalTriggerEvmReadoutRecord> ();
94 LogDebug(
"L1GlobalTriggerEvmRawToDigi")
97 <<
"\nMask for active boards (hex format): " << std::hex
100 << std::dec << std::setfill(
' ')
111 <<
"\nWARNING: Number of bunch crossing to be unpacked rounded to: "
152 const std::vector<L1GtBoard> boardMaps = l1GtBM->gtBoardMaps();
153 int boardMapsSize = boardMaps.size();
155 typedef std::vector<L1GtBoard>::const_iterator CItBoardMaps;
160 std::vector<L1GtBoard> gtRecordMap;
161 gtRecordMap.reserve(boardMapsSize);
163 for (
int iPos = 0; iPos < boardMapsSize; ++iPos) {
164 for (CItBoardMaps itBoard = boardMaps.begin(); itBoard != boardMaps.end(); ++itBoard) {
166 if (itBoard->gtPositionEvmRecord() == iPos) {
167 gtRecordMap.push_back(*itBoard);
182 <<
"\nWarning: FEDRawDataCollection with input tag " <<
m_evmGtInputTag
183 <<
"\nrequested in configuration, but not found in the event."
184 <<
"\nQuit unpacking this event" << std::endl;
195 int gtSize = raw.
size();
198 const unsigned char* ptrGt = raw.
data();
201 const unsigned char* endPtrGt = ptrGt + gtSize;
206 LogTrace(
"L1GlobalTriggerEvmRawToDigi") <<
"\n Size of raw data: "
207 << gtSize <<
"\n" << std::endl;
209 std::ostringstream myCoutStream;
212 LogTrace(
"L1GlobalTriggerEvmRawToDigi") <<
"\n Dump FEDRawData\n"
213 << myCoutStream.str() <<
"\n" << std::endl;
220 if ((ptrGt + headerSize) > endPtrGt) {
222 <<
"\nError: Pointer after header greater than end pointer."
223 <<
"\n Put empty products in the event!"
224 <<
"\n Quit unpacking this event." << std::endl;
232 FEDTrailer cmsTrailer(ptrGt + gtSize - headerSize);
240 bool gtfeUnpacked =
false;
244 int bstLengthBytes = 0;
261 LogTrace(
"L1GlobalTriggerEvmRawToDigi") <<
"\n Length of BST message (in bytes): "
262 << bstLengthBytes <<
"\n" << std::endl;
265 for (CItBoardMaps itBoard = boardMaps.begin(); itBoard != boardMaps.end(); ++itBoard) {
267 if (itBoard->gtBoardType() ==
GTFE) {
270 if (itBoard->gtPositionEvmRecord() == 1) {
281 std::ostringstream myCoutStream;
283 LogTrace(
"L1GlobalTriggerEvmRawToDigi") << myCoutStream.str() <<
"\n"
294 <<
"\nWarning: GTFE block found in raw data does not follow header."
295 <<
"\nAssumed start position of the block is wrong!"
296 <<
"\nQuit unpacking this event" << std::endl;
313 <<
"\nWarning: no GTFE block found in raw data."
314 <<
"\nCan not find the record length (BxInEvent) and the active boards!"
315 <<
"\nQuit unpacking this event" << std::endl;
335 LogDebug(
"L1GlobalTriggerEvmRawToDigi") <<
"\nActive boards before masking(hex format): "
336 << std::hex << std::setw(
sizeof ( activeBoardsGtInitial ) * 2) << std::setfill(
'0')
337 << activeBoardsGtInitial << std::dec << std::setfill(
' ')
338 <<
"\nActive boards after masking(hex format): " << std::hex << std::setw(
339 sizeof ( activeBoardsGt ) * 2) << std::setfill(
'0') << activeBoardsGt << std::dec
340 << std::setfill(
' ') <<
" \n" << std::endl;
345 int numberGtfeBoards = 0;
346 int numberFdlBoards = 0;
347 int numberPsbBoards = 0;
348 int numberGmtBoards = 0;
349 int numberTcsBoards = 0;
350 int numberTimBoards = 0;
352 for (CItBoardMaps itBoard = boardMaps.begin(); itBoard != boardMaps.end(); ++itBoard) {
354 int iActiveBit = itBoard->gtBitEvmActiveBoards();
355 bool activeBoardToUnpack =
false;
357 if (iActiveBit >= 0) {
358 activeBoardToUnpack = activeBoardsGt & ( 1 << iActiveBit );
364 if (activeBoardToUnpack) {
366 switch (itBoard->gtBoardType()) {
400 LogDebug(
"L1GlobalTriggerEvmRawToDigi") <<
"\nBoard of type "
401 << itBoard->gtBoardType() <<
" not expected in record.\n"
425 std::auto_ptr<L1GlobalTriggerEvmReadoutRecord> gtReadoutRecord(
430 for (CItBoardMaps itBoard = gtRecordMap.begin(); itBoard != gtRecordMap.end(); ++itBoard) {
432 int iActiveBit = itBoard->gtBitEvmActiveBoards();
434 bool activeBoardToUnpack =
false;
435 bool activeBoardInitial =
false;
437 int altNrBxBoardVal = -1;
439 if (iActiveBit >= 0) {
440 activeBoardInitial = activeBoardsGtInitial & ( 1 << iActiveBit );
441 activeBoardToUnpack = activeBoardsGt & ( 1 << iActiveBit );
443 altNrBxBoardVal = (altNrBxBoardInitial & ( 1 << iActiveBit )) >> iActiveBit;
445 if (altNrBxBoardVal == 1) {
447 }
else if (altNrBxBoardVal == 0) {
452 <<
"\n\nWARNING: Wrong value altNrBxBoardVal = " << altNrBxBoardVal
453 <<
" for board " << std::hex << ( itBoard->gtBoardId() ) << std::dec
454 <<
"\n iActiveBit = " << iActiveBit
455 <<
"\n altNrBxBoardInitial = 0x" << std::hex << altNrBxBoardInitial << std::dec
456 <<
"\n activeBoardsGt = 0x" << std::hex << activeBoardsGt << std::dec
457 <<
"\n activeBoardInitial = " << activeBoardInitial
458 <<
"\n activeBoardToUnpack = " << activeBoardToUnpack
459 <<
"\n Set altNrBxBoardVal tentatively to "
471 LogDebug(
"L1GlobalTriggerEvmRawToDigi")
472 <<
"\nWARNING: Number of available bunch crosses for board"
474 <<
" ) \n is smaller than the number of bunch crosses requested to be unpacked ("
489 <<
" bunch crosses available." <<
"\n" << std::endl;
498 LogDebug(
"L1GlobalTriggerEvmRawToDigi")
500 <<
" bunch crosses available." <<
"\n" << std::endl;
516 <<
" bunch crosses available." <<
"\n" << std::endl;
531 if (!activeBoardInitial) {
533 LogDebug(
"L1GlobalTriggerEvmRawToDigi") <<
"\nBoard of type "
534 << itBoard->gtBoardName() <<
" with index " << itBoard->gtBoardIndex()
535 <<
" not active initially in raw data.\n" << std::endl;
541 switch (itBoard->gtBoardType()) {
549 <<
"\nError: Pointer after TCS "
550 <<
" greater than end pointer."
551 <<
"\n Put empty products in the event!"
552 <<
"\n Quit unpacking this event." << std::endl;
560 if (activeBoardToUnpack) {
575 std::ostringstream myCoutStream;
577 LogTrace(
"L1GlobalTriggerEvmRawToDigi") << myCoutStream.str() <<
"\n"
596 <<
"\nError: Pointer after FDL " << iFdl
597 <<
" greater than end pointer."
598 <<
"\n Put empty products in the event!"
599 <<
"\n Quit unpacking this event." << std::endl;
607 if (activeBoardToUnpack) {
625 std::ostringstream myCoutStream;
627 LogTrace(
"L1GlobalTriggerEvmRawToDigi") << myCoutStream.str()
628 <<
"\n" << std::endl;
646 LogDebug(
"L1GlobalTriggerEvmRawToDigi") <<
"\nBoard of type "
647 << itBoard->gtBoardType() <<
" not expected in record.\n" << std::endl;
669 if ((ptrGt + trailerSize) > endPtrGt) {
671 <<
"\nError: Pointer after trailer "
672 <<
" greater than end pointer."
673 <<
"\n Put empty products in the event!"
674 <<
"\n Quit unpacking this event." << std::endl;
684 std::ostringstream myCoutStream;
685 gtReadoutRecord->print(myCoutStream);
686 LogTrace(
"L1GlobalTriggerEvmRawToDigi")
687 <<
"\n The following L1 GT EVM readout record was unpacked.\n"
688 << myCoutStream.str() <<
"\n" << std::endl;
692 iEvent.
put(gtReadoutRecord);
705 reinterpret_cast<cms_uint64_t*
> (
const_cast<unsigned char*
> (gtPtr));
707 std::ostringstream myCoutStream;
712 myCoutStream << std::setw(4) << iWord <<
" " << std::hex << std::setfill(
'0')
713 << std::setw(16) << payload[iWord] << std::dec << std::setfill(
' ') <<
"\n"
716 myCoutStream <<
" Event_type: " << std::hex <<
" hex: " <<
" " << std::setw(1)
717 << std::setfill(
'0') << cmsHeader.
triggerType() << std::setfill(
' ') << std::dec
718 <<
" dec: " << cmsHeader.
triggerType() << std::endl;
720 myCoutStream <<
" LVL1_Id: " << std::hex <<
" hex: " <<
"" << std::setw(6)
721 << std::setfill(
'0') << cmsHeader.
lvl1ID() << std::setfill(
' ') << std::dec
722 <<
" dec: " << cmsHeader.
lvl1ID() << std::endl;
724 myCoutStream <<
" BX_Id: " << std::hex <<
" hex: " <<
" " << std::setw(3)
725 << std::setfill(
'0') << cmsHeader.
bxID() << std::setfill(
' ') << std::dec
726 <<
" dec: " << cmsHeader.
bxID() << std::endl;
728 myCoutStream <<
" Source_Id: " << std::hex <<
" hex: " <<
" " << std::setw(3)
729 << std::setfill(
'0') << cmsHeader.
sourceID() << std::setfill(
' ') << std::dec
730 <<
" dec: " << cmsHeader.
sourceID() << std::endl;
732 myCoutStream <<
" FOV: " << std::hex <<
" hex: " <<
" " << std::setw(1)
733 << std::setfill(
'0') << cmsHeader.
version() << std::setfill(
' ') << std::dec
734 <<
" dec: " << cmsHeader.
version() << std::endl;
736 myCoutStream <<
" H: " << std::hex <<
" hex: " <<
" " << std::setw(1)
737 << std::setfill(
'0') << cmsHeader.
moreHeaders() << std::setfill(
' ') << std::dec
738 <<
" dec: " << cmsHeader.
moreHeaders() << std::endl;
740 LogDebug(
"L1GlobalTriggerEvmRawToDigi") <<
"\n CMS Header \n" << myCoutStream.str() <<
"\n"
757 reinterpret_cast<cms_uint64_t*
> (
const_cast<unsigned char*
> (trlPtr));
759 std::ostringstream myCoutStream;
764 myCoutStream << std::setw(4) << iWord <<
" " << std::hex << std::setfill(
'0')
765 << std::setw(16) << payload[iWord] << std::dec << std::setfill(
' ') <<
"\n"
768 myCoutStream <<
" Event_length: " << std::hex <<
" hex: " <<
"" << std::setw(6)
769 << std::setfill(
'0') << cmsTrailer.
lenght() << std::setfill(
' ') << std::dec
770 <<
" dec: " << cmsTrailer.
lenght() << std::endl;
772 myCoutStream <<
" CRC: " << std::hex <<
" hex: " <<
" " << std::setw(4)
773 << std::setfill(
'0') << cmsTrailer.
crc() << std::setfill(
' ') << std::dec
774 <<
" dec: " << cmsTrailer.
crc() << std::endl;
776 myCoutStream <<
" Event_status: " << std::hex <<
" hex: " <<
" " << std::setw(2)
777 << std::setfill(
'0') << cmsTrailer.
evtStatus() << std::setfill(
' ') << std::dec
778 <<
" dec: " << cmsTrailer.
evtStatus() << std::endl;
780 myCoutStream <<
" TTS_bits: " << std::hex <<
" hex: " <<
" " << std::setw(1)
781 << std::setfill(
'0') << cmsTrailer.
ttsBits() << std::setfill(
' ') << std::dec
782 <<
" dec: " << cmsTrailer.
ttsBits() << std::endl;
784 myCoutStream <<
" More trailers: " << std::hex <<
" hex: " <<
" " << std::setw(1)
785 << std::setfill(
'0') << cmsTrailer.
moreTrailers() << std::setfill(
' ') << std::dec
788 LogDebug(
"L1GlobalTriggerEvmRawToDigi") <<
"\n CMS Trailer \n" << myCoutStream.str()
789 <<
"\n" << std::endl;
798 std::auto_ptr<L1GlobalTriggerEvmReadoutRecord> gtReadoutRecord(
803 iEvent.
put(gtReadoutRecord);
808 const unsigned char* gtPtr,
int gtSize, std::ostream& myCout) {
810 LogDebug(
"L1GlobalTriggerEvmRawToDigi") <<
"\nDump FED raw data.\n" << std::endl;
815 int gtWords = gtSize / uLength;
816 LogTrace(
"L1GlobalTriggerEvmRawToDigi") <<
"\nFED GT words (" << wLength <<
" bits):"
817 << gtWords <<
"\n" << std::endl;
820 reinterpret_cast<cms_uint64_t*
> (
const_cast<unsigned char*
> (gtPtr));
823 myCout << std::setw(4) <<
i <<
" " << std::hex << std::setfill(
'0') << std::setw(16)
824 << payload[
i] << std::dec << std::setfill(
' ') << std::endl;
int m_bstLengthBytes
length of BST record (in bytes)
int m_verbosity
verbosity level
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
virtual void produce(edm::Event &, const edm::EventSetup &)
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
const T & max(const T &a, const T &b)
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
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
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