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
98 << std::dec << std::setfill(
' ')
109 <<
"\nWARNING: Number of bunch crossing to be unpacked rounded to: "
150 const std::vector<L1GtBoard> boardMaps = l1GtBM->gtBoardMaps();
151 int boardMapsSize = boardMaps.size();
153 typedef std::vector<L1GtBoard>::const_iterator CItBoardMaps;
158 std::vector<L1GtBoard> gtRecordMap;
159 gtRecordMap.reserve(boardMapsSize);
161 for (
int iPos = 0; iPos < boardMapsSize; ++iPos) {
162 for (CItBoardMaps itBoard = boardMaps.begin(); itBoard != boardMaps.end(); ++itBoard) {
164 if (itBoard->gtPositionEvmRecord() == iPos) {
165 gtRecordMap.push_back(*itBoard);
180 <<
"\nWarning: FEDRawDataCollection with input tag " <<
m_evmGtInputTag
181 <<
"\nrequested in configuration, but not found in the event."
182 <<
"\nQuit unpacking this event" << std::endl;
193 int gtSize = raw.
size();
196 const unsigned char* ptrGt = raw.
data();
199 const unsigned char* endPtrGt = ptrGt + gtSize;
204 LogTrace(
"L1GlobalTriggerEvmRawToDigi") <<
"\n Size of raw data: "
205 << gtSize <<
"\n" << std::endl;
207 std::ostringstream myCoutStream;
210 LogTrace(
"L1GlobalTriggerEvmRawToDigi") <<
"\n Dump FEDRawData\n"
211 << myCoutStream.str() <<
"\n" << std::endl;
218 if ((ptrGt + headerSize) > endPtrGt) {
220 <<
"\nError: Pointer after header greater than end pointer."
221 <<
"\n Put empty products in the event!"
222 <<
"\n Quit unpacking this event." << std::endl;
230 FEDTrailer cmsTrailer(ptrGt + gtSize - headerSize);
238 bool gtfeUnpacked =
false;
242 int bstLengthBytes = 0;
259 LogTrace(
"L1GlobalTriggerEvmRawToDigi") <<
"\n Length of BST message (in bytes): "
260 << bstLengthBytes <<
"\n" << std::endl;
263 for (CItBoardMaps itBoard = boardMaps.begin(); itBoard != boardMaps.end(); ++itBoard) {
265 if (itBoard->gtBoardType() ==
GTFE) {
268 if (itBoard->gtPositionEvmRecord() == 1) {
279 std::ostringstream myCoutStream;
281 LogTrace(
"L1GlobalTriggerEvmRawToDigi") << myCoutStream.str() <<
"\n"
292 <<
"\nWarning: GTFE block found in raw data does not follow header."
293 <<
"\nAssumed start position of the block is wrong!"
294 <<
"\nQuit unpacking this event" << std::endl;
311 <<
"\nWarning: no GTFE block found in raw data."
312 <<
"\nCan not find the record length (BxInEvent) and the active boards!"
313 <<
"\nQuit unpacking this event" << std::endl;
333 LogDebug(
"L1GlobalTriggerEvmRawToDigi") <<
"\nActive boards before masking(hex format): "
334 << std::hex << std::setw(
sizeof ( activeBoardsGtInitial ) * 2) << std::setfill(
'0')
335 << activeBoardsGtInitial << std::dec << std::setfill(
' ')
336 <<
"\nActive boards after masking(hex format): " << std::hex << std::setw(
337 sizeof ( activeBoardsGt ) * 2) << std::setfill(
'0') << activeBoardsGt << std::dec
338 << std::setfill(
' ') <<
" \n" << std::endl;
343 int numberGtfeBoards = 0;
344 int numberFdlBoards = 0;
345 int numberPsbBoards = 0;
346 int numberGmtBoards = 0;
347 int numberTcsBoards = 0;
348 int numberTimBoards = 0;
350 for (CItBoardMaps itBoard = boardMaps.begin(); itBoard != boardMaps.end(); ++itBoard) {
352 int iActiveBit = itBoard->gtBitEvmActiveBoards();
353 bool activeBoardToUnpack =
false;
355 if (iActiveBit >= 0) {
356 activeBoardToUnpack = activeBoardsGt & ( 1 << iActiveBit );
362 if (activeBoardToUnpack) {
364 switch (itBoard->gtBoardType()) {
398 LogDebug(
"L1GlobalTriggerEvmRawToDigi") <<
"\nBoard of type "
399 << itBoard->gtBoardType() <<
" not expected in record.\n"
423 std::auto_ptr<L1GlobalTriggerEvmReadoutRecord> gtReadoutRecord(
428 for (CItBoardMaps itBoard = gtRecordMap.begin(); itBoard != gtRecordMap.end(); ++itBoard) {
430 int iActiveBit = itBoard->gtBitEvmActiveBoards();
432 bool activeBoardToUnpack =
false;
433 bool activeBoardInitial =
false;
435 int altNrBxBoardVal = -1;
437 if (iActiveBit >= 0) {
438 activeBoardInitial = activeBoardsGtInitial & ( 1 << iActiveBit );
439 activeBoardToUnpack = activeBoardsGt & ( 1 << iActiveBit );
441 altNrBxBoardVal = (altNrBxBoardInitial & ( 1 << iActiveBit )) >> iActiveBit;
443 if (altNrBxBoardVal == 1) {
445 }
else if (altNrBxBoardVal == 0) {
450 <<
"\n\nWARNING: Wrong value altNrBxBoardVal = " << altNrBxBoardVal
451 <<
" for board " << std::hex << ( itBoard->gtBoardId() ) << std::dec
452 <<
"\n iActiveBit = " << iActiveBit
453 <<
"\n altNrBxBoardInitial = 0x" << std::hex << altNrBxBoardInitial << std::dec
454 <<
"\n activeBoardsGt = 0x" << std::hex << activeBoardsGt << std::dec
455 <<
"\n activeBoardInitial = " << activeBoardInitial
456 <<
"\n activeBoardToUnpack = " << activeBoardToUnpack
457 <<
"\n Set altNrBxBoardVal tentatively to "
469 LogDebug(
"L1GlobalTriggerEvmRawToDigi")
470 <<
"\nWARNING: Number of available bunch crosses for board"
472 <<
" ) \n is smaller than the number of bunch crosses requested to be unpacked ("
487 <<
" bunch crosses available." <<
"\n" << std::endl;
496 LogDebug(
"L1GlobalTriggerEvmRawToDigi")
498 <<
" bunch crosses available." <<
"\n" << std::endl;
514 <<
" bunch crosses available." <<
"\n" << std::endl;
529 if (!activeBoardInitial) {
531 LogDebug(
"L1GlobalTriggerEvmRawToDigi") <<
"\nBoard of type "
532 << itBoard->gtBoardName() <<
" with index " << itBoard->gtBoardIndex()
533 <<
" not active initially in raw data.\n" << std::endl;
539 switch (itBoard->gtBoardType()) {
547 <<
"\nError: Pointer after TCS "
548 <<
" greater than end pointer."
549 <<
"\n Put empty products in the event!"
550 <<
"\n Quit unpacking this event." << std::endl;
558 if (activeBoardToUnpack) {
573 std::ostringstream myCoutStream;
575 LogTrace(
"L1GlobalTriggerEvmRawToDigi") << myCoutStream.str() <<
"\n"
594 <<
"\nError: Pointer after FDL " << iFdl
595 <<
" greater than end pointer."
596 <<
"\n Put empty products in the event!"
597 <<
"\n Quit unpacking this event." << std::endl;
605 if (activeBoardToUnpack) {
623 std::ostringstream myCoutStream;
625 LogTrace(
"L1GlobalTriggerEvmRawToDigi") << myCoutStream.str()
626 <<
"\n" << std::endl;
644 LogDebug(
"L1GlobalTriggerEvmRawToDigi") <<
"\nBoard of type "
645 << itBoard->gtBoardType() <<
" not expected in record.\n" << std::endl;
667 if ((ptrGt + trailerSize) > endPtrGt) {
669 <<
"\nError: Pointer after trailer "
670 <<
" greater than end pointer."
671 <<
"\n Put empty products in the event!"
672 <<
"\n Quit unpacking this event." << std::endl;
682 std::ostringstream myCoutStream;
683 gtReadoutRecord->print(myCoutStream);
684 LogTrace(
"L1GlobalTriggerEvmRawToDigi")
685 <<
"\n The following L1 GT EVM readout record was unpacked.\n"
686 << myCoutStream.str() <<
"\n" << std::endl;
690 iEvent.
put(gtReadoutRecord);
703 reinterpret_cast<cms_uint64_t*
> (
const_cast<unsigned char*
> (gtPtr));
705 std::ostringstream myCoutStream;
710 myCoutStream << std::setw(4) << iWord <<
" " << std::hex << std::setfill(
'0')
711 << std::setw(16) << payload[iWord] << std::dec << std::setfill(
' ') <<
"\n"
714 myCoutStream <<
" Event_type: " << std::hex <<
" hex: " <<
" " << std::setw(1)
715 << std::setfill(
'0') << cmsHeader.
triggerType() << std::setfill(
' ') << std::dec
716 <<
" dec: " << cmsHeader.
triggerType() << std::endl;
718 myCoutStream <<
" LVL1_Id: " << std::hex <<
" hex: " <<
"" << std::setw(6)
719 << std::setfill(
'0') << cmsHeader.
lvl1ID() << std::setfill(
' ') << std::dec
720 <<
" dec: " << cmsHeader.
lvl1ID() << std::endl;
722 myCoutStream <<
" BX_Id: " << std::hex <<
" hex: " <<
" " << std::setw(3)
723 << std::setfill(
'0') << cmsHeader.
bxID() << std::setfill(
' ') << std::dec
724 <<
" dec: " << cmsHeader.
bxID() << std::endl;
726 myCoutStream <<
" Source_Id: " << std::hex <<
" hex: " <<
" " << std::setw(3)
727 << std::setfill(
'0') << cmsHeader.
sourceID() << std::setfill(
' ') << std::dec
728 <<
" dec: " << cmsHeader.
sourceID() << std::endl;
730 myCoutStream <<
" FOV: " << std::hex <<
" hex: " <<
" " << std::setw(1)
731 << std::setfill(
'0') << cmsHeader.
version() << std::setfill(
' ') << std::dec
732 <<
" dec: " << cmsHeader.
version() << std::endl;
734 myCoutStream <<
" H: " << std::hex <<
" hex: " <<
" " << std::setw(1)
735 << std::setfill(
'0') << cmsHeader.
moreHeaders() << std::setfill(
' ') << std::dec
736 <<
" dec: " << cmsHeader.
moreHeaders() << std::endl;
738 LogDebug(
"L1GlobalTriggerEvmRawToDigi") <<
"\n CMS Header \n" << myCoutStream.str() <<
"\n"
755 reinterpret_cast<cms_uint64_t*
> (
const_cast<unsigned char*
> (trlPtr));
757 std::ostringstream myCoutStream;
762 myCoutStream << std::setw(4) << iWord <<
" " << std::hex << std::setfill(
'0')
763 << std::setw(16) << payload[iWord] << std::dec << std::setfill(
' ') <<
"\n"
766 myCoutStream <<
" Event_length: " << std::hex <<
" hex: " <<
"" << std::setw(6)
767 << std::setfill(
'0') << cmsTrailer.
lenght() << std::setfill(
' ') << std::dec
768 <<
" dec: " << cmsTrailer.
lenght() << std::endl;
770 myCoutStream <<
" CRC: " << std::hex <<
" hex: " <<
" " << std::setw(4)
771 << std::setfill(
'0') << cmsTrailer.
crc() << std::setfill(
' ') << std::dec
772 <<
" dec: " << cmsTrailer.
crc() << std::endl;
774 myCoutStream <<
" Event_status: " << std::hex <<
" hex: " <<
" " << std::setw(2)
775 << std::setfill(
'0') << cmsTrailer.
evtStatus() << std::setfill(
' ') << std::dec
776 <<
" dec: " << cmsTrailer.
evtStatus() << std::endl;
778 myCoutStream <<
" TTS_bits: " << std::hex <<
" hex: " <<
" " << std::setw(1)
779 << std::setfill(
'0') << cmsTrailer.
ttsBits() << std::setfill(
' ') << std::dec
780 <<
" dec: " << cmsTrailer.
ttsBits() << std::endl;
782 myCoutStream <<
" More trailers: " << std::hex <<
" hex: " <<
" " << std::setw(1)
783 << std::setfill(
'0') << cmsTrailer.
moreTrailers() << std::setfill(
' ') << std::dec
786 LogDebug(
"L1GlobalTriggerEvmRawToDigi") <<
"\n CMS Trailer \n" << myCoutStream.str()
787 <<
"\n" << std::endl;
796 std::auto_ptr<L1GlobalTriggerEvmReadoutRecord> gtReadoutRecord(
801 iEvent.
put(gtReadoutRecord);
806 const unsigned char* gtPtr,
int gtSize, std::ostream& myCout) {
808 LogDebug(
"L1GlobalTriggerEvmRawToDigi") <<
"\nDump FED raw data.\n" << std::endl;
813 int gtWords = gtSize / uLength;
814 LogTrace(
"L1GlobalTriggerEvmRawToDigi") <<
"\nFED GT words (" << wLength <<
" bits):"
815 << gtWords <<
"\n" << std::endl;
818 reinterpret_cast<cms_uint64_t*
> (
const_cast<unsigned char*
> (gtPtr));
821 myCout << std::setw(4) <<
i <<
" " << std::hex << std::setfill(
'0') << std::setw(16)
822 << 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