62 m_daqGtFedId(pSet.getUntrackedParameter<int> (
66 m_daqGtInputTag(pSet.getParameter<edm::InputTag> (
"DaqGtInputTag")),
67 m_muGmtInputTag(pSet.getParameter<edm::InputTag> (
"MuGmtInputTag")),
68 m_activeBoardsMaskGt(pSet.getParameter<unsigned int> (
"ActiveBoardsMask")),
70 m_minBxInEvent(0), m_maxBxInEvent(),
71 m_verbosity(pSet.getUntrackedParameter<int> (
"Verbosity", 0)),
78 <<
"\nFED Id for DAQ GT record: " <<
m_daqGtFedId <<
" \n"
81 <<
"\nMask for active boards (hex format): " << std::hex
84 <<
std::dec << std::setfill(
' ') <<
" \n"
89 produces<FEDRawDataCollection> ();
128 const std::vector<L1GtBoard> boardMaps = l1GtBM->gtBoardMaps();
129 int boardMapsSize = boardMaps.size();
131 typedef std::vector<L1GtBoard>::const_iterator CItBoardMaps;
136 std::vector<L1GtBoard> gtRecordMap;
137 gtRecordMap.reserve(boardMapsSize);
139 for (
int iPos = 0; iPos < boardMapsSize; ++iPos) {
140 for (CItBoardMaps itBoard = boardMaps.begin(); itBoard
141 != boardMaps.end(); ++itBoard) {
143 if (itBoard->gtPositionDaqRecord() == iPos) {
144 gtRecordMap.push_back(*itBoard);
156 if (!gtReadoutRecord.
isValid()) {
159 <<
"\nWarning: L1GlobalTriggerReadoutRecord with input tag " <<
m_daqGtInputTag
160 <<
"\nrequested in configuration, but not found in the event."
161 <<
"\nQuit packing this event" << std::endl;
165 iEvent.
put(allFedRawData);
171 std::ostringstream myCoutStream;
172 gtReadoutRecord->print(myCoutStream);
174 <<
"\n The following L1 GT DAQ readout record will be packed.\n"
175 <<
" Some boards could be disabled before packing,"
176 <<
" see detailed board packing.\n" << myCoutStream.str() <<
"\n"
181 L1GtfeWord gtfeBlock = gtReadoutRecord->gtfeWord();
201 <<
"\nActive boards before masking(hex format): " << std::hex
202 << std::setw(
sizeof ( activeBoardsGtInitial ) * 2) << std::setfill(
'0')
203 << activeBoardsGtInitial <<
std::dec << std::setfill(
' ')
204 <<
"Active boards after masking(hex format): " << std::hex
205 << std::setw(
sizeof ( activeBoardsGt ) * 2) << std::setfill(
'0') << activeBoardsGt
206 <<
std::dec << std::setfill(
' ') <<
" \n"
212 unsigned int gtDataSize = 0;
214 unsigned int headerSize = 8;
215 gtDataSize += headerSize;
218 itBoard = boardMaps.begin();
219 itBoard != boardMaps.end(); ++itBoard) {
221 if (itBoard->gtBoardType() ==
GTFE) {
222 gtDataSize += gtfeBlock.
getSize();
227 int iActiveBit = itBoard->gtBitDaqActiveBoards();
228 bool activeBoardToPack =
false;
230 int altNrBxBoardVal = -1;
232 if (iActiveBit >= 0) {
233 activeBoardToPack = activeBoardsGt & (1 << iActiveBit);
235 altNrBxBoardVal = (altNrBxBoardInitial & ( 1 << iActiveBit )) >> iActiveBit;
237 if (altNrBxBoardVal == 1) {
239 }
else if (altNrBxBoardVal == 0) {
244 <<
"\n\nWARNING: Wrong value altNrBxBoardVal = " << altNrBxBoardVal
245 <<
" for board " << std::hex << ( itBoard->gtBoardId() ) <<
std::dec
246 <<
"\n iActiveBit = " << iActiveBit
247 <<
"\n altNrBxBoardInitial = 0x" << std::hex << altNrBxBoardInitial <<
std::dec
248 <<
"\n activeBoardsGt = 0x" << std::hex << activeBoardsGt <<
std::dec
249 <<
"\n activeBoardToPack = " << activeBoardToPack
250 <<
"\n Set altNrBxBoardVal tentatively to "
251 << recordLength0 <<
"\n Job may crash or produce wrong results!\n\n"
264 if (activeBoardToPack) {
266 switch (itBoard->gtBoardType()) {
286 unsigned int gmtRecordSize = 136;
288 gtDataSize += gmtCollSize;
294 gtDataSize += tcsBlock.
getSize();
314 unsigned int trailerSize = 8;
315 gtDataSize += trailerSize;
320 gtRawData.
resize(gtDataSize);
325 unsigned char* ptrGt = gtRawData.
data();
326 unsigned char* ptrGtBegin = gtRawData.
data();
329 LogDebug(
"L1GTDigiToRaw") <<
"\n Size of raw data: " << gtRawData.
size() <<
"\n"
342 itBoard = gtRecordMap.begin();
343 itBoard != gtRecordMap.end(); ++itBoard) {
345 if (itBoard->gtBoardType() ==
GTFE) {
347 packGTFE(evSetup, ptrGt, gtfeBlock, activeBoardsGt);
351 std::ostringstream myCoutStream;
352 gtfeBlock.
print(myCoutStream);
353 LogTrace(
"L1GTDigiToRaw") << myCoutStream.str() <<
"\n" << std::endl;
364 int iActiveBit = itBoard->gtBitDaqActiveBoards();
365 bool activeBoardToPack =
false;
367 int altNrBxBoardVal = -1;
369 if (iActiveBit >= 0) {
370 activeBoardToPack = activeBoardsGt & (1 << iActiveBit);
372 altNrBxBoardVal = (altNrBxBoardInitial & ( 1 << iActiveBit )) >> iActiveBit;
374 if (altNrBxBoardVal == 1) {
376 }
else if (altNrBxBoardVal == 0) {
381 <<
"\n\nWARNING: Wrong value altNrBxBoardVal = " << altNrBxBoardVal
382 <<
" for board " << std::hex << ( itBoard->gtBoardId() ) <<
std::dec
383 <<
"\n iActiveBit = " << iActiveBit
384 <<
"\n altNrBxBoardInitial = 0x" << std::hex << altNrBxBoardInitial <<
std::dec
385 <<
"\n activeBoardsGt = 0x" << std::hex << activeBoardsGt <<
std::dec
386 <<
"\n activeBoardToPack = " << activeBoardToPack
387 <<
"\n Set altNrBxBoardVal tentatively to "
388 << recordLength0 <<
"\n Job may crash or produce wrong results!\n\n"
404 if (activeBoardToPack) {
408 <<
"\nBoard " << std::hex <<
"0x" << ( itBoard->gtBoardId() ) <<
std::dec
416 switch (itBoard->gtBoardType()) {
422 L1GtFdlWord fdlBlock = gtReadoutRecord->gtFdlWord(iBxInEvent);
423 packFDL(evSetup, ptrGt, fdlBlock);
427 std::ostringstream myCoutStream;
428 fdlBlock.
print(myCoutStream);
429 LogTrace(
"L1GTDigiToRaw") << myCoutStream.str() <<
"\n" << std::endl;
440 LogDebug(
"L1GTDigiToRaw") <<
"\nBoard of type " << itBoard->gtBoardName()
441 <<
" with index " << itBoard->gtBoardIndex() <<
" and boardId "
442 << std::hex << itBoard->gtBoardId() <<
std::dec <<
"\n"
449 itBoard->gtBoardId(), iBxInEvent);
451 packPSB(evSetup, ptrGt, psbBlock);
455 std::ostringstream myCoutStream;
456 psbBlock.
print(myCoutStream);
457 LogTrace(
"L1GTDigiToRaw") << myCoutStream.str() <<
"\n" << std::endl;
473 <<
"\nWarning: L1MuGMTReadoutCollection with input tag "
475 <<
"\nrequested in configuration, but not found in the event."
476 <<
"\nQuit packing this event" << std::endl;
482 iEvent.
put(allFedRawData);
491 unsigned int gmtCollSize = 0;
493 ptrGt += gmtCollSize;
511 iEvent.
put(allFedRawData);
520 int triggerTypeVal = 0;
523 int lvl1IdVal = iEvent.
id().
event();
528 if ( ( bxCross & 0xFFF ) == bxCross) {
533 LogDebug(
"L1GTDigiToRaw") <<
"\nBunch cross number [hex] = " << std::hex << bxCross
534 <<
"\n larger than 12 bits. Set to 0! \n" <<
std::dec << std::endl;
537 int bxIdVal = bxCrossHw;
548 bool moreHeadersVal =
false;
553 ptrGt, triggerTypeVal, lvl1IdVal, bxIdVal, sourceIdVal, versionVal, moreHeadersVal);
563 LogDebug(
"L1GTDigiToRaw") <<
"\nPacking GTFE \n" << std::endl;
569 int nrWord64 = gtfeBlock.
getSize() / uLength;
570 std::vector<cms_uint64_t> tmpWord64;
571 tmpWord64.resize(nrWord64);
573 for (
int iWord = 0; iWord < nrWord64; ++iWord) {
574 tmpWord64[iWord] = 0x0000000000000000ULL;
578 for (
int iWord = 0; iWord < nrWord64; ++iWord) {
595 for (
int iWord = 0; iWord < nrWord64; ++iWord) {
597 *pw++ = tmpWord64[iWord];
601 << std::setw(4) << iWord <<
" "
602 << std::hex << std::setfill(
'0') << std::setw(16) << tmpWord64[iWord] <<
std::dec
617 LogDebug(
"L1GTDigiToRaw") <<
"\nPacking FDL \n" << std::endl;
623 int nrWord64 = fdlBlock.
getSize() / uLength;
624 std::vector<cms_uint64_t> tmpWord64;
625 tmpWord64.resize(nrWord64);
627 for (
int iWord = 0; iWord < nrWord64; ++iWord) {
628 tmpWord64[iWord] = 0x0000000000000000ULL;
632 for (
int iWord = 0; iWord < nrWord64; ++iWord) {
662 for (
int iWord = 0; iWord < nrWord64; ++iWord) {
664 *pw++ = tmpWord64[iWord];
669 << std::setw(4) << iWord <<
" "
670 << std::hex << std::setfill(
'0') << std::setw(16) << tmpWord64[iWord] <<
std::dec
683 LogDebug(
"L1GTDigiToRaw") <<
"\nPacking PSB \n" << std::endl;
689 int nrWord64 = psbBlock.
getSize() / uLength;
690 std::vector<cms_uint64_t> tmpWord64;
691 tmpWord64.resize(nrWord64);
693 for (
int iWord = 0; iWord < nrWord64; ++iWord) {
694 tmpWord64[iWord] = 0x0000000000000000ULL;
698 for (
int iWord = 0; iWord < nrWord64; ++iWord) {
716 for (
int iWord = 0; iWord < nrWord64; ++iWord) {
718 *pw++ = tmpWord64[iWord];
723 << std::setw(4) << iWord <<
" "
724 << std::hex << std::setfill(
'0') << std::setw(16) << tmpWord64[iWord] <<
std::dec
734 unsigned char* ptrGt,
739 LogDebug(
"L1GTDigiToRaw") <<
"\nPacking GMT collection \n" << std::endl;
742 unsigned gmtsize = 0;
748 gmtsize =
packGMT(gmtrr, ptrGt);
760 const unsigned SIZE=136;
761 const unsigned boardId=0xdd12;
764 unsigned*
p = (
unsigned*) chp;
771 std::vector<L1MuRegionalCand> vrc;
772 std::vector<L1MuRegionalCand>::const_iterator irc;
777 for(irc=vrc.begin(); irc!=vrc.end(); irc++) {
778 *pp++ = (*irc).getDataWord();
784 for(irc=vrc.begin(); irc!=vrc.end(); irc++) {
785 *pp++ = (*irc).getDataWord();
791 for(irc=vrc.begin(); irc!=vrc.end(); irc++) {
792 *pp++ = (*irc).getDataWord();
798 for(irc=vrc.begin(); irc!=vrc.end(); irc++) {
799 *pp++ = (*irc).getDataWord();
805 for(
int i=0;
i<16;
i++) {
807 *pp++ = (w&0xffff00ff) | ((~w)&0x0000ff00);
810 std::vector<L1MuGMTExtendedCand> vgc;
811 std::vector<L1MuGMTExtendedCand>::const_iterator igc;
815 for(igc=vgc.begin(); igc!=vgc.end(); igc++) {
816 *pp++ = (*igc).getDataWord();
822 for(igc=vgc.begin(); igc!=vgc.end(); igc++) {
823 *pp++ = (*igc).getDataWord();
829 for(igc=vgc.begin(); igc!=vgc.end(); igc++) {
830 *pp++ = (*igc).getDataWord();
837 chpp = (
unsigned char*) p;
838 for(igc=vgc.begin(); igc!=vgc.end(); igc++) {
839 *chpp++ = (*igc).rank();
844 chpp = (
unsigned char*) p;
845 for(igc=vgc.begin(); igc!=vgc.end(); igc++) {
846 *chpp++ = (*igc).rank();
855 return ( (w&0xffff00ff) | ((~w)&0x0000ff00) );
864 int lengthVal = dataSize / 8;
870 int evtStatusVal = 0;
878 bool moreTrailersVal =
false;
881 gtFEDTrailer.
set(ptrGt, lengthVal, crcVal, evtStatusVal, ttsBitsVal, moreTrailersVal);
EventNumber_t event() const
void packFDL(const edm::EventSetup &, unsigned char *, L1GtFdlWord &)
pack FDL blocks for various bunch crosses
void setEventNrWord64(cms_uint64_t &word64, int iWord)
const unsigned int getSize() const
get the size of the GTFE block in GT DAQ record (in multiple of 8 bits)
std::vector< L1MuGMTExtendedCand > getGMTCands() const
get GMT candidates vector
void setRecordLength1Word64(cms_uint64_t &word64, int iWord)
void setNoAlgoWord64(cms_uint64_t &word64, const int iWord)
virtual void beginJob()
beginning of job stuff
void setGtDecisionWordBWord64(cms_uint64_t &word64, const int iWord)
virtual void print(std::ostream &myCout) const
pretty print the content of a L1GtfeWord
bool getByToken(EDGetToken token, Handle< PROD > &result) const
static const int UnitLength
one unit in the word is UnitLength bits
void packHeader(unsigned char *, edm::Event &)
block packers -------——
int getBxNr() const
get counters
int bunchCrossing() const
void setBoardIdWord64(cms_uint64_t &word64, const int iWord)
void setLumiSegmentNrWord64(cms_uint64_t &word64, const int iWord)
void setActiveBoardsWord64(cms_uint64_t &word64, int iWord)
void setBxNrWord64(cms_uint64_t &word64, int iWord)
static void set(unsigned char *trailer, int evt_lgth, int crc, int evt_stat, int tts, bool T=false)
Set all fields in the trailer.
std::vector< L1MuRegionalCand > getBrlRPCCands() const
get barrel RPC candidates vector
void setSetupVersionWord64(cms_uint64_t &word64, int iWord)
const unsigned int getSize() const
get the size of the FDL block in GT DAQ record (in multiple of 8 bits)
void setOrbitNrWord64(cms_uint64_t &word64, const int iWord)
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.
cms_uint16_t m_activeBoardsMaskGt
mask for active boards
void setGtTechnicalTriggerWordWord64(cms_uint64_t &word64, const int iWord)
std::vector< L1MuRegionalCand > getFwdRPCCands() const
get forward RPC candidates vector
const cms_uint16_t recordLength() const
get/set record length for alternative 0
void setBxInEventWord64(cms_uint64_t &word64, int iWord)
std::vector< L1MuRegionalCand > getCSCCands() const
get CSC candidates vector
edm::InputTag m_daqGtInputTag
void setADataWord64(cms_uint64_t &word64, int iWord)
void setGtPrescaleFactorIndexTechWord64(cms_uint64_t &word64, const int iWord)
edm::InputTag m_muGmtInputTag
void packPSB(const edm::EventSetup &, unsigned char *, L1GtPsbWord &)
void resize(size_t newsize)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
void setBxInEventWord64(cms_uint64_t &word64, const int iWord)
void setLocalBxNrWord64(cms_uint64_t &word64, int iWord)
unsigned short compute_crc(unsigned char *buffer, unsigned int bufSize)
void setPhysicsDeclaredWord64(cms_uint64_t &word64, const int iWord)
unsigned int packGMT(L1MuGMTReadoutRecord const &, unsigned char *)
pack a GMT record
void setEventNrWord64(cms_uint64_t &word64, const int iWord)
void packTrailer(unsigned char *, unsigned char *, int)
pack trailer word
unsigned short cms_uint16_t
void setBxNrWord64(cms_uint64_t &word64, const int iWord)
virtual void endJob()
end of job stuff
void setBoardIdWord64(cms_uint64_t &word64, int iWord)
void setBDataWord64(cms_uint64_t &word64, int iWord)
virtual ~L1GTDigiToRaw()
destructor
const cms_uint16_t activeBoards() const
get/set boards contributing to EVM respectively DAQ record
void print(std::ostream &myCout) const
pretty print the content of a L1GtFdlWord
void print(std::ostream &myCout) const
pretty print
std::vector< L1MuGMTExtendedCand > getGMTBrlCands() const
get GMT barrel candidates vector
T const * product() const
void setAltNrBxBoardWord64(cms_uint64_t &word64, int iWord)
unsigned int packGmtCollection(unsigned char *ptrGt, L1MuGMTReadoutCollection const *digis)
pack the GMT collection using packGMT (GMT record packing)
std::vector< L1MuRegionalCand > getDTBXCands() const
get DT candidates vector
void packGTFE(const edm::EventSetup &, unsigned char *, L1GtfeWord &, cms_uint16_t activeBoardsGtValue)
unsigned int flipPtQ(unsigned int)
void setGtDecisionWordExtendedWord64(cms_uint64_t &word64, const int iWord)
void setLocalBxNrWord64(cms_uint64_t &word64, const int iWord)
void setGtDecisionWordAWord64(cms_uint64_t &word64, const int iWord)
const unsigned int getSize() const
get the size of the TCS block in GT EVM record (in multiple of 8 bits)
edm::EDGetTokenT< L1GlobalTriggerReadoutRecord > m_daqGtInputToken
input tag for GT DAQ record
std::vector< L1MuGMTExtendedCand > getGMTFwdCands() const
get GMT forward candidates vector
void setBxNrWord64(cms_uint64_t &word64, int iWord)
edm::EDGetTokenT< L1MuGMTReadoutCollection > m_muGmtInputToken
input tag for GMT record
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
int m_verbosity
verbosity level
L1MuGMTReadoutRecord const & getRecord(int bx=0) const
void setFinalORWord64(cms_uint64_t &word64, const int iWord)
unsigned long long cms_uint64_t
void setTotalTriggerNrWord64(cms_uint64_t &word64, int iWord)
void setGtPrescaleFactorIndexAlgoWord64(cms_uint64_t &word64, const int iWord)
virtual void produce(edm::Event &, const edm::EventSetup &)
loop over events
const cms_uint16_t recordLength1() const
get/set record length for alternative 1
int m_totalBxInEvent
total Bx's in the event, obtained from GTFE block
L1GTDigiToRaw(const edm::ParameterSet &)
constructor(s)
void setBoardIdWord64(cms_uint64_t &word64, int iWord)
void setRecordLengthWord64(cms_uint64_t &word64, int iWord)
const unsigned int getSize() const
get the size of the PSB block in GT DAQ record (in multiple of 8 bits)