60 m_daqGtInputTag(pSet.getParameter<
edm::
InputTag>(
"DaqGtInputTag")),
65 m_daqGtFedId(pSet.getUntrackedParameter<
int>(
"DaqGtFedId",
FEDNumbering::MAXTriggerGTPFEDID)),
68 m_activeBoardsMaskGt(pSet.getParameter<unsigned
int>(
"ActiveBoardsMask")),
76 m_unpackBxInEvent(pSet.getParameter<
int>(
"UnpackBxInEvent")),
81 m_lowSkipBxInEvent(0),
82 m_uppSkipBxInEvent(0),
89 m_verbosity(pSet.getUntrackedParameter<
int>(
"Verbosity", 0)),
94 produces<L1GlobalTriggerReadoutRecord>();
95 produces<L1MuGMTReadoutCollection>();
97 produces<std::vector<L1MuRegionalCand> >(
"DT");
98 produces<std::vector<L1MuRegionalCand> >(
"CSC");
99 produces<std::vector<L1MuRegionalCand> >(
"RPCb");
100 produces<std::vector<L1MuRegionalCand> >(
"RPCf");
101 produces<std::vector<L1MuGMTCand> >();
113 <<
"\nMask for active boards (hex format): " << std::hex
125 <<
"\nWARNING: Number of bunch crossing to be unpacked rounded to: " <<
m_unpackBxInEvent 126 <<
"\n The number must be an odd number!\n" 141 static const char*
const kComm1 =
142 "# input tag for GT readout collection: \n" 143 "# source = hardware record, \n" 144 "# l1GtPack = GT packer (DigiToRaw)";
146 static const char*
const kComm2 =
147 "# FED Id for GT DAQ record \n" 148 "# default value defined in DataFormats/FEDRawData/src/FEDNumbering.cc";
150 static const char*
const kComm3 =
151 "# mask for active boards (actually 16 bits) \n" 152 "# if bit is zero, the corresponding board will not be unpacked \n" 153 "# default: no board masked";
154 desc.add<
unsigned int>(
"ActiveBoardsMask", 0xFFFF)->setComment(kComm3);
155 static const char*
const kComm4 =
156 "# number of 'bunch crossing in the event' (bxInEvent) to be unpacked \n" 157 "# symmetric around L1Accept (bxInEvent = 0): \n" 158 "# 1 (bxInEvent = 0); 3 (F 0 1) (standard record); 5 (E F 0 1 2) (debug record) \n" 159 "# even numbers (except 0) 'rounded' to the nearest lower odd number \n" 160 "# negative value: unpack all available bxInEvent \n" 161 "# if more bxInEvent than available are required, unpack what exists and write a warning";
162 desc.add<
int>(
"UnpackBxInEvent", -1)->setComment(kComm4);
163 desc.addUntracked<
int>(
"Verbosity", 0);
164 descriptions.
add(
"l1GlobalTriggerRawToDigi",
desc);
183 const std::vector<L1GtBoard> boardMaps = l1GtBM->
gtBoardMaps();
184 int boardMapsSize = boardMaps.size();
186 typedef std::vector<L1GtBoard>::const_iterator CItBoardMaps;
191 std::vector<L1GtBoard> gtRecordMap;
192 gtRecordMap.reserve(boardMapsSize);
194 for (
int iPos = 0; iPos < boardMapsSize; ++iPos) {
195 for (CItBoardMaps itBoard = boardMaps.begin(); itBoard != boardMaps.end(); ++itBoard) {
196 if (itBoard->gtPositionDaqRecord() == iPos) {
197 gtRecordMap.push_back(*itBoard);
211 <<
"\nWarning: FEDRawDataCollection with input tag " <<
m_daqGtInputTag 212 <<
"\nrequested in configuration, but not found in the event." 213 <<
"\nQuit unpacking this event" << std::endl;
224 int gtSize = raw.
size();
227 const unsigned char* ptrGt = raw.
data();
230 const unsigned char* endPtrGt = ptrGt + gtSize;
234 LogTrace(
"L1GlobalTriggerRawToDigi") <<
"\n Size of raw data: " << gtSize <<
"\n" << std::endl;
236 std::ostringstream myCoutStream;
239 LogTrace(
"L1GlobalTriggerRawToDigi") <<
"\n Dump FEDRawData\n" << myCoutStream.str() <<
"\n" << std::endl;
245 if ((ptrGt + headerSize) > endPtrGt) {
253 FEDTrailer cmsTrailer(ptrGt + gtSize - headerSize);
264 edm::LogError(
"L1GlobalTriggerRawToDigi") <<
"\nError: Pointer after GTFE greater than end pointer." 265 <<
"\n Put empty products in the event!" 266 <<
"\n Quit unpacking this event." << std::endl;
273 bool gtfeUnpacked =
false;
275 for (CItBoardMaps itBoard = boardMaps.begin(); itBoard != boardMaps.end(); ++itBoard) {
276 if (itBoard->gtBoardType() ==
GTFE) {
278 if (itBoard->gtPositionDaqRecord() == 1) {
284 std::ostringstream myCoutStream;
286 LogTrace(
"L1GlobalTriggerRawToDigi") << myCoutStream.str() <<
"\n" << std::endl;
295 <<
"\nWarning: GTFE block found in raw data does not follow header." 296 <<
"\nAssumed start position of the block is wrong!" 297 <<
"\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(
"L1GlobalTriggerRawToDigi") <<
"\nActive boards before masking: 0x" << std::hex
334 << std::setw(
sizeof(activeBoardsGtInitial) * 2) << std::setfill(
'0')
335 << activeBoardsGtInitial <<
std::dec << std::setfill(
' ')
336 <<
"\nActive boards after masking: 0x" << std::hex
337 << std::setw(
sizeof(activeBoardsGt) * 2) << std::setfill(
'0') << activeBoardsGt
338 <<
std::dec << std::setfill(
' ') <<
" \n" 344 int numberGtfeBoards = 0;
345 int numberFdlBoards = 0;
346 int numberPsbBoards = 0;
347 int numberGmtBoards = 0;
348 int numberTcsBoards = 0;
349 int numberTimBoards = 0;
351 for (CItBoardMaps itBoard = boardMaps.begin(); itBoard != boardMaps.end(); ++itBoard) {
352 int iActiveBit = itBoard->gtBitDaqActiveBoards();
353 bool activeBoardToUnpack =
false;
355 if (iActiveBit >= 0) {
356 activeBoardToUnpack = activeBoardsGt & (1 << iActiveBit);
362 if (activeBoardToUnpack) {
363 switch (itBoard->gtBoardType()) {
397 LogDebug(
"L1GlobalTriggerRawToDigi")
398 <<
"\nBoard of type " << itBoard->gtBoardType() <<
" not expected in record.\n" 422 std::unique_ptr<L1GlobalTriggerReadoutRecord> gtReadoutRecord(
440 for (CItBoardMaps itBoard = gtRecordMap.begin(); itBoard != gtRecordMap.end(); ++itBoard) {
441 int iActiveBit = itBoard->gtBitDaqActiveBoards();
443 bool activeBoardToUnpack =
false;
444 bool activeBoardInitial =
false;
446 int altNrBxBoardVal = -1;
448 if (iActiveBit >= 0) {
449 activeBoardInitial = activeBoardsGtInitial & (1 << iActiveBit);
450 activeBoardToUnpack = activeBoardsGt & (1 << iActiveBit);
452 altNrBxBoardVal = (altNrBxBoardInitial & (1 << iActiveBit)) >> iActiveBit;
454 if (altNrBxBoardVal == 1) {
456 }
else if (altNrBxBoardVal == 0) {
461 <<
"\n\nWARNING: Wrong value altNrBxBoardVal = " << altNrBxBoardVal <<
" for board " << std::hex
462 << (itBoard->gtBoardId()) <<
std::dec <<
"\n iActiveBit = " << iActiveBit
463 <<
"\n altNrBxBoardInitial = 0x" << std::hex << altNrBxBoardInitial <<
std::dec 464 <<
"\n activeBoardsGt = 0x" << std::hex << activeBoardsGt <<
std::dec 465 <<
"\n activeBoardInitial = " << activeBoardInitial
466 <<
"\n activeBoardToUnpack = " << activeBoardToUnpack <<
"\n Set altNrBxBoardVal tentatively to " 478 LogDebug(
"L1GlobalTriggerRawToDigi")
479 <<
"\nWARNING: Number of available bunch crosses for board" << (itBoard->gtBoardId())
481 <<
" ) \n is smaller than the number of bunch crosses requested to be unpacked (" <<
m_unpackBxInEvent 504 LogDebug(
"L1GlobalTriggerRawToDigi")
505 <<
"\nNo bxInEvent required to be unpacked from " <<
m_totalBxInEvent <<
" bunch crosses available." 537 if (!activeBoardInitial) {
539 LogDebug(
"L1GlobalTriggerRawToDigi") <<
"\nBoard of type " << itBoard->gtBoardName() <<
" with index " 540 << itBoard->gtBoardIndex() <<
" not active initially in raw data.\n" 547 switch (itBoard->gtBoardType()) {
554 <<
"\nError: Pointer after FDL " << iFdl <<
" greater than end pointer." 555 <<
"\n Put empty products in the event!" 556 <<
"\n Quit unpacking this event." << std::endl;
564 if (activeBoardToUnpack) {
579 std::ostringstream myCoutStream;
581 LogTrace(
"L1GlobalTriggerRawToDigi") << myCoutStream.str() <<
"\n" << std::endl;
600 <<
"\nError: Pointer after PSB " << iPsb <<
" greater than end pointer." 601 <<
"\n Put empty products in the event!" 602 <<
"\n Quit unpacking this event." << std::endl;
610 if (activeBoardToUnpack) {
619 std::ostringstream myCoutStream;
621 LogTrace(
"L1GlobalTriggerRawToDigi") << myCoutStream.str() <<
"\n" << std::endl;
634 unsigned int gmtRecordSize = 136;
639 if ((ptrGt + gmtCollSize) > endPtrGt) {
640 edm::LogError(
"L1GlobalTriggerRawToDigi") <<
"\nError: Pointer after GMT " 641 <<
" greater than end pointer." 642 <<
"\n Put empty products in the event!" 643 <<
"\n Quit unpacking this event." << std::endl;
651 if (activeBoardToUnpack) {
655 ptrGt += gmtCollSize;
660 LogDebug(
"L1GlobalTriggerRawToDigi")
661 <<
"\nBoard of type " << itBoard->gtBoardType() <<
" not expected in record.\n" 681 if ((ptrGt + trailerSize) > endPtrGt) {
682 edm::LogError(
"L1GlobalTriggerRawToDigi") <<
"\nError: Pointer after trailer " 683 <<
" greater than end pointer." 684 <<
"\n Put empty products in the event!" 685 <<
"\n Quit unpacking this event." << std::endl;
696 std::ostringstream myCoutStream;
697 gtReadoutRecord->print(myCoutStream);
698 LogTrace(
"L1GlobalTriggerRawToDigi") <<
"\n The following L1 GT DAQ readout record was unpacked.\n" 699 << myCoutStream.str() <<
"\n" 717 std::ostringstream myCoutStream;
722 myCoutStream << std::setw(4) << iWord <<
" " << std::hex << std::setfill(
'0') << std::setw(16) <<
payload[iWord]
723 <<
std::dec << std::setfill(
' ') <<
"\n" 726 myCoutStream <<
" Event_type: " << std::hex <<
" hex: " 727 <<
" " << std::setw(1) << std::setfill(
'0') << cmsHeader.
triggerType() << std::setfill(
' ')
730 myCoutStream <<
" LVL1_Id: " << std::hex <<
" hex: " 731 <<
"" << std::setw(6) << std::setfill(
'0') << cmsHeader.
lvl1ID() << std::setfill(
' ') <<
std::dec 732 <<
" dec: " << cmsHeader.
lvl1ID() << std::endl;
734 myCoutStream <<
" BX_Id: " << std::hex <<
" hex: " 735 <<
" " << std::setw(3) << std::setfill(
'0') << cmsHeader.
bxID() << std::setfill(
' ') <<
std::dec 736 <<
" dec: " << cmsHeader.
bxID() << std::endl;
738 myCoutStream <<
" Source_Id: " << std::hex <<
" hex: " 739 <<
" " << std::setw(3) << std::setfill(
'0') << cmsHeader.
sourceID() << std::setfill(
' ') <<
std::dec 740 <<
" dec: " << cmsHeader.
sourceID() << std::endl;
742 myCoutStream <<
" FOV: " << std::hex <<
" hex: " 743 <<
" " << std::setw(1) << std::setfill(
'0') << cmsHeader.
version() << std::setfill(
' ') <<
std::dec 744 <<
" dec: " << cmsHeader.
version() << std::endl;
746 myCoutStream <<
" H: " << std::hex <<
" hex: " 747 <<
" " << std::setw(1) << std::setfill(
'0') << cmsHeader.
moreHeaders() << std::setfill(
' ')
750 LogDebug(
"L1GlobalTriggerRawToDigi") <<
"\n CMS Header \n" << myCoutStream.str() <<
"\n" << std::endl;
757 const unsigned char* psbPtr,
765 int psbSize = psbWord.
getSize();
766 int psbWords = psbSize / uLength;
770 for (
int iWord = 0; iWord < psbWords; ++iWord) {
784 LogTrace(
"L1GlobalTriggerRawToDigi") << std::setw(4) << iWord <<
" " << std::hex << std::setfill(
'0')
792 std::unique_ptr<L1MuGMTReadoutCollection>& gmtrc,
799 const unsigned int gmtRecordSize32 = 34;
801 std::unique_ptr<std::vector<L1MuRegionalCand> > DTCands(
new std::vector<L1MuRegionalCand>);
802 std::unique_ptr<std::vector<L1MuRegionalCand> > CSCCands(
new std::vector<L1MuRegionalCand>);
803 std::unique_ptr<std::vector<L1MuRegionalCand> > RPCbCands(
new std::vector<L1MuRegionalCand>);
804 std::unique_ptr<std::vector<L1MuRegionalCand> > RPCfCands(
new std::vector<L1MuRegionalCand>);
805 std::unique_ptr<std::vector<L1MuGMTCand> > GMTCands(
new std::vector<L1MuGMTCand>);
807 const unsigned*
p = (
const unsigned*)chp;
818 for (
int iWord = 0; iWord < 17; iWord++) {
819 LogTrace(
"L1GlobalTriggerRawToDigi") << std::setw(4) << iWord <<
" " << std::hex << std::setfill(
'0')
820 << std::setw(16) << *bp++ <<
std::dec << std::setfill(
' ') << std::endl;
830 if (((*
p) >> 15) & 1) {
838 for (
int im = 0; im < 16; im++) {
840 unsigned waux = *
p++;
841 waux = (waux & 0xffff00ff) | ((~waux) & 0x0000ff00);
844 if (im >= 4 && im < 8)
846 if (im >= 8 && im < 12)
854 DTCands->push_back(
cand);
855 if (im >= 4 && im < 8)
856 RPCbCands->push_back(
cand);
857 if (im >= 8 && im < 12)
858 CSCCands->push_back(
cand);
860 RPCfCands->push_back(
cand);
864 unsigned char* prank = (
unsigned char*)(
p + 12);
866 for (
int im = 0; im < 12; im++) {
867 unsigned waux = *
p++;
868 unsigned raux = im < 8 ? *prank++ : 0;
880 GMTCands->push_back(
cand);
887 gmtrc->addRecord(gmtrr);
891 p += gmtRecordSize32;
914 std::ostringstream myCoutStream;
919 myCoutStream << std::setw(4) << iWord <<
" " << std::hex << std::setfill(
'0') << std::setw(16) <<
payload[iWord]
920 <<
std::dec << std::setfill(
' ') <<
"\n" 923 myCoutStream <<
" Event_length: " << std::hex <<
" hex: " 924 <<
"" << std::setw(6) << std::setfill(
'0') << cmsTrailer.
fragmentLength() << std::setfill(
' ')
927 myCoutStream <<
" CRC: " << std::hex <<
" hex: " 928 <<
" " << std::setw(4) << std::setfill(
'0') << cmsTrailer.
crc() << std::setfill(
' ') <<
std::dec 929 <<
" dec: " << cmsTrailer.
crc() << std::endl;
931 myCoutStream <<
" Event_status: " << std::hex <<
" hex: " 932 <<
" " << std::setw(2) << std::setfill(
'0') << cmsTrailer.
evtStatus() << std::setfill(
' ')
935 myCoutStream <<
" TTS_bits: " << std::hex <<
" hex: " 936 <<
" " << std::setw(1) << std::setfill(
'0') << cmsTrailer.
ttsBits() << std::setfill(
' ')
939 myCoutStream <<
" More trailers: " << std::hex <<
" hex: " 940 <<
" " << std::setw(1) << std::setfill(
'0') << cmsTrailer.
moreTrailers() << std::setfill(
' ')
943 LogDebug(
"L1GlobalTriggerRawToDigi") <<
"\n CMS Trailer \n" << myCoutStream.str() <<
"\n" << std::endl;
953 std::unique_ptr<std::vector<L1MuRegionalCand> > DTCands(
new std::vector<L1MuRegionalCand>);
954 std::unique_ptr<std::vector<L1MuRegionalCand> > CSCCands(
new std::vector<L1MuRegionalCand>);
955 std::unique_ptr<std::vector<L1MuRegionalCand> > RPCbCands(
new std::vector<L1MuRegionalCand>);
956 std::unique_ptr<std::vector<L1MuRegionalCand> > RPCfCands(
new std::vector<L1MuRegionalCand>);
957 std::unique_ptr<std::vector<L1MuGMTCand> > GMTCands(
new std::vector<L1MuGMTCand>);
973 LogDebug(
"L1GlobalTriggerRawToDigi") <<
"\nDump FED raw data.\n" << std::endl;
978 int gtWords = gtSize / uLength;
979 LogTrace(
"L1GlobalTriggerRawToDigi") <<
"\nFED GT words (" << wLength <<
" bits):" << gtWords <<
"\n" << std::endl;
984 myCout << std::setw(4) <<
i <<
" " << std::hex << std::setfill(
'0') << std::setw(16) <<
payload[
i] <<
std::dec 985 << std::setfill(
' ') << std::endl;
const L1MuTriggerScales * m_TriggerScales
muon trigger scales to convert unpacked data into physical quantities
const L1MuScale * getGMTEtaScale() const
get the GMT eta scale
void setBxInEvent(int bxie)
const cms_uint16_t altNrBxBoard() const
get/set alternative for number of BX per board
virtual void print(std::ostream &myCout) const
pretty print the content of a L1GtfeWord
void reset()
reset the content of a L1GtPsbWord
const edm::ESGetToken< L1GtBoardMaps, L1GtBoardMapsRcd > m_l1GtBMToken
EventSetup Token for L1GtBoardMaps.
const cms_uint16_t recordLength1() const
get/set record length for alternative 1
const unsigned int getSize() const
get the size of the PSB block in GT DAQ record (in multiple of 8 bits)
const unsigned int getSize() const
get the size of the GTFE block in GT DAQ record (in multiple of 8 bits)
void unpackHeader(const unsigned char *, FEDHeader &)
block unpackers
cms_uint16_t m_activeBoardsMaskGt
mask for active boards
uint8_t ttsBits() const
Current value of the Trigger Throttling System bits.
void produce(edm::Event &, const edm::EventSetup &) override
static const int UnitLength
one unit in the word is UnitLength bits
void setGMTBrlCand(int nr, L1MuGMTExtendedCand const &cand)
set GMT barrel candidate
virtual float getLowEdge(unsigned packed) const =0
get the low edge of bin represented by packed
T const * product() const
int m_recordLength0
total Bx's in the event, obtained from GTFE block
void setBData(cms_uint16_t bDataVal, int iB)
~L1GlobalTriggerRawToDigi() override
destructor
void setGMTFwdCand(int nr, L1MuGMTExtendedCand const &cand)
set GMT forward candidate
void unpack(const unsigned char *fdlPtr)
size_t size() const
Lenght of the data buffer in bytes.
void setInputCand(int nr, unsigned data)
set Input muon
void unpackPSB(const edm::EventSetup &, const unsigned char *, L1GtPsbWord &)
const L1MuScale * getPhiScale() const
get the phi scale
Log< level::Error, false > LogError
void setRecordLength(cms_uint16_t recordLengthValue)
virtual float getCenter(unsigned packed) const =0
get the center of bin represented by packed
const L1MuScale * getPtScale() const
get the Pt scale
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.
const cms_uint16_t recordLength() const
get/set record length for alternative 0
const edm::ESGetToken< L1MuTriggerScales, L1MuTriggerScalesRcd > m_trigScalesToken
EventSetup Token for L1MuTriggerScales.
void setEventNr(cms_uint32_t eventNrValue)
void setBxNr(cms_uint16_t bxNrValue)
virtual void reset()
reset the content of a L1GtfeWord
const L1MuTriggerPtScale * m_TriggerPtScale
T const * product() const
void print(std::ostream &myCout) const
pretty print
void setBoardId(cms_uint16_t boardIdValue)
int m_recordLength1
corresponding to alternative 1 in altNrBxBoard()
const L1MuScale * getRegionalEtaScale(int isys) const
get the regioanl muon trigger eta scale, isys = 0(DT), 1(bRPC), 2(CSC), 3(fwdRPC) ...
void setLumiSegmentNr(const cms_uint16_t &lumiSegmentNrValue)
edm::InputTag m_daqGtInputTag
input tags for GT DAQ record
void setBxInEvent(int bxInEventValue)
int m_verbosity
verbosity level
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 setRecordLength1(cms_uint16_t recordLengthValue)
const std::vector< L1GtBoard > & gtBoardMaps() const
get / set / print the L1 GT board map
L1GlobalTriggerRawToDigi(const edm::ParameterSet &)
constructor(s)
uint8_t evtStatus() const
Event fragment status information.
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
const cms_uint16_t lumiSegmentNr() const
get/set luminosity segment number of the actual bx
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
L1GtFdlWord * m_gtFdlWord
Log< level::Info, false > LogInfo
L1GtPsbWord * m_gtPsbWord
int m_totalBxInEvent
number of Bx for a board, obtained from GTFE block (record length & alternative)
void setActiveBoards(cms_uint16_t activeBoardsValue)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void setBxNr(int bxnr)
set counters
void unpackTrailer(const unsigned char *, FEDTrailer &)
unpack trailer word
const unsigned int getSize() const
get the size of the FDL block in GT DAQ record (in multiple of 8 bits)
void unpackGMT(const unsigned char *, std::unique_ptr< L1MuGMTReadoutCollection > &, edm::Event &)
unpack the GMT record
void setLocalBxNr(cms_uint16_t localBxNrValue)
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
void setGMTCand(int nr, L1MuGMTExtendedCand const &cand)
set GMT candidate (does not store rank)
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 produceEmptyProducts(edm::Event &)
produce empty products in case of problems
const edm::ESGetToken< L1MuTriggerPtScale, L1MuTriggerPtScaleRcd > m_trigPtScaleToken
EventSetup Token for L1MuTriggerPtScale.
void setAData(cms_uint16_t aDataVal, int iA)
virtual void unpack(const unsigned char *gtfePtr)
bool moreTrailers() const
void dumpFedRawData(const unsigned char *, int, std::ostream &)
dump FED raw data