62 m_daqGtFedId(pSet.getUntrackedParameter<int> (
64 m_daqGtInputTag(pSet.getParameter<edm::InputTag> (
"DaqGtInputTag")),
65 m_muGmtInputTag(pSet.getParameter<edm::InputTag> (
"MuGmtInputTag")),
66 m_activeBoardsMaskGt(pSet.getParameter<unsigned int> (
"ActiveBoardsMask")),
68 m_minBxInEvent(0), m_maxBxInEvent(),
69 m_verbosity(pSet.getUntrackedParameter<int> (
"Verbosity", 0)),
76 <<
"\nFED Id for DAQ GT record: " <<
m_daqGtFedId <<
" \n"
79 <<
"\nMask for active boards (hex format): " << std::hex
82 << std::dec << std::setfill(
' ') <<
" \n"
87 produces<FEDRawDataCollection> ();
126 const std::vector<L1GtBoard> boardMaps = l1GtBM->gtBoardMaps();
127 int boardMapsSize = boardMaps.size();
129 typedef std::vector<L1GtBoard>::const_iterator CItBoardMaps;
134 std::vector<L1GtBoard> gtRecordMap;
135 gtRecordMap.reserve(boardMapsSize);
137 for (
int iPos = 0; iPos < boardMapsSize; ++iPos) {
138 for (CItBoardMaps itBoard = boardMaps.begin(); itBoard
139 != boardMaps.end(); ++itBoard) {
141 if (itBoard->gtPositionDaqRecord() == iPos) {
142 gtRecordMap.push_back(*itBoard);
154 if (!gtReadoutRecord.
isValid()) {
157 <<
"\nWarning: L1GlobalTriggerReadoutRecord with input tag " <<
m_daqGtInputTag
158 <<
"\nrequested in configuration, but not found in the event."
159 <<
"\nQuit packing this event" << std::endl;
163 iEvent.
put(allFedRawData);
169 std::ostringstream myCoutStream;
170 gtReadoutRecord->print(myCoutStream);
172 <<
"\n The following L1 GT DAQ readout record will be packed.\n"
173 <<
" Some boards could be disabled before packing,"
174 <<
" see detailed board packing.\n" << myCoutStream.str() <<
"\n"
179 L1GtfeWord gtfeBlock = gtReadoutRecord->gtfeWord();
199 <<
"\nActive boards before masking(hex format): " << std::hex
200 << std::setw(
sizeof ( activeBoardsGtInitial ) * 2) << std::setfill(
'0')
201 << activeBoardsGtInitial << std::dec << std::setfill(
' ')
202 <<
"Active boards after masking(hex format): " << std::hex
203 << std::setw(
sizeof ( activeBoardsGt ) * 2) << std::setfill(
'0') << activeBoardsGt
204 << std::dec << std::setfill(
' ') <<
" \n"
210 unsigned int gtDataSize = 0;
212 unsigned int headerSize = 8;
213 gtDataSize += headerSize;
216 itBoard = boardMaps.begin();
217 itBoard != boardMaps.end(); ++itBoard) {
219 if (itBoard->gtBoardType() ==
GTFE) {
220 gtDataSize += gtfeBlock.
getSize();
225 int iActiveBit = itBoard->gtBitDaqActiveBoards();
226 bool activeBoardToPack =
false;
228 int altNrBxBoardVal = -1;
230 if (iActiveBit >= 0) {
231 activeBoardToPack = activeBoardsGt & (1 << iActiveBit);
233 altNrBxBoardVal = (altNrBxBoardInitial & ( 1 << iActiveBit )) >> iActiveBit;
235 if (altNrBxBoardVal == 1) {
237 }
else if (altNrBxBoardVal == 0) {
242 <<
"\n\nWARNING: Wrong value altNrBxBoardVal = " << altNrBxBoardVal
243 <<
" for board " << std::hex << ( itBoard->gtBoardId() ) << std::dec
244 <<
"\n iActiveBit = " << iActiveBit
245 <<
"\n altNrBxBoardInitial = 0x" << std::hex << altNrBxBoardInitial << std::dec
246 <<
"\n activeBoardsGt = 0x" << std::hex << activeBoardsGt << std::dec
247 <<
"\n activeBoardToPack = " << activeBoardToPack
248 <<
"\n Set altNrBxBoardVal tentatively to "
249 << recordLength0 <<
"\n Job may crash or produce wrong results!\n\n"
262 if (activeBoardToPack) {
264 switch (itBoard->gtBoardType()) {
284 unsigned int gmtRecordSize = 136;
286 gtDataSize += gmtCollSize;
292 gtDataSize += tcsBlock.
getSize();
312 unsigned int trailerSize = 8;
313 gtDataSize += trailerSize;
318 gtRawData.
resize(gtDataSize);
323 unsigned char* ptrGt = gtRawData.
data();
324 unsigned char* ptrGtBegin = gtRawData.
data();
327 LogDebug(
"L1GTDigiToRaw") <<
"\n Size of raw data: " << gtRawData.
size() <<
"\n"
340 itBoard = gtRecordMap.begin();
341 itBoard != gtRecordMap.end(); ++itBoard) {
343 if (itBoard->gtBoardType() ==
GTFE) {
345 packGTFE(evSetup, ptrGt, gtfeBlock, activeBoardsGt);
349 std::ostringstream myCoutStream;
350 gtfeBlock.
print(myCoutStream);
351 LogTrace(
"L1GTDigiToRaw") << myCoutStream.str() <<
"\n" << std::endl;
362 int iActiveBit = itBoard->gtBitDaqActiveBoards();
363 bool activeBoardToPack =
false;
365 int altNrBxBoardVal = -1;
367 if (iActiveBit >= 0) {
368 activeBoardToPack = activeBoardsGt & (1 << iActiveBit);
370 altNrBxBoardVal = (altNrBxBoardInitial & ( 1 << iActiveBit )) >> iActiveBit;
372 if (altNrBxBoardVal == 1) {
374 }
else if (altNrBxBoardVal == 0) {
379 <<
"\n\nWARNING: Wrong value altNrBxBoardVal = " << altNrBxBoardVal
380 <<
" for board " << std::hex << ( itBoard->gtBoardId() ) << std::dec
381 <<
"\n iActiveBit = " << iActiveBit
382 <<
"\n altNrBxBoardInitial = 0x" << std::hex << altNrBxBoardInitial << std::dec
383 <<
"\n activeBoardsGt = 0x" << std::hex << activeBoardsGt << std::dec
384 <<
"\n activeBoardToPack = " << activeBoardToPack
385 <<
"\n Set altNrBxBoardVal tentatively to "
386 << recordLength0 <<
"\n Job may crash or produce wrong results!\n\n"
402 if (activeBoardToPack) {
406 <<
"\nBoard " << std::hex <<
"0x" << ( itBoard->gtBoardId() ) << std::dec
414 switch (itBoard->gtBoardType()) {
420 L1GtFdlWord fdlBlock = gtReadoutRecord->gtFdlWord(iBxInEvent);
421 packFDL(evSetup, ptrGt, fdlBlock);
425 std::ostringstream myCoutStream;
426 fdlBlock.
print(myCoutStream);
427 LogTrace(
"L1GTDigiToRaw") << myCoutStream.str() <<
"\n" << std::endl;
438 LogDebug(
"L1GTDigiToRaw") <<
"\nBoard of type " << itBoard->gtBoardName()
439 <<
" with index " << itBoard->gtBoardIndex() <<
" and boardId "
440 << std::hex << itBoard->gtBoardId() << std::dec <<
"\n"
447 itBoard->gtBoardId(), iBxInEvent);
449 packPSB(evSetup, ptrGt, psbBlock);
453 std::ostringstream myCoutStream;
454 psbBlock.
print(myCoutStream);
455 LogTrace(
"L1GTDigiToRaw") << myCoutStream.str() <<
"\n" << std::endl;
471 <<
"\nWarning: L1MuGMTReadoutCollection with input tag "
473 <<
"\nrequested in configuration, but not found in the event."
474 <<
"\nQuit packing this event" << std::endl;
480 iEvent.
put(allFedRawData);
489 unsigned int gmtCollSize = 0;
491 ptrGt += gmtCollSize;
509 iEvent.
put(allFedRawData);
518 int triggerTypeVal = 0;
521 int lvl1IdVal = iEvent.
id().
event();
526 if ( ( bxCross & 0xFFF ) == bxCross) {
531 LogDebug(
"L1GTDigiToRaw") <<
"\nBunch cross number [hex] = " << std::hex << bxCross
532 <<
"\n larger than 12 bits. Set to 0! \n" << std::dec << std::endl;
535 int bxIdVal = bxCrossHw;
546 bool moreHeadersVal =
false;
551 ptrGt, triggerTypeVal, lvl1IdVal, bxIdVal, sourceIdVal, versionVal, moreHeadersVal);
561 LogDebug(
"L1GTDigiToRaw") <<
"\nPacking GTFE \n" << std::endl;
567 int nrWord64 = gtfeBlock.
getSize() / uLength;
568 std::vector<cms_uint64_t> tmpWord64;
569 tmpWord64.resize(nrWord64);
571 for (
int iWord = 0; iWord < nrWord64; ++iWord) {
572 tmpWord64[iWord] = 0x0000000000000000ULL;
576 for (
int iWord = 0; iWord < nrWord64; ++iWord) {
593 for (
int iWord = 0; iWord < nrWord64; ++iWord) {
595 *pw++ = tmpWord64[iWord];
599 << std::setw(4) << iWord <<
" "
600 << std::hex << std::setfill(
'0') << std::setw(16) << tmpWord64[iWord] << std::dec
615 LogDebug(
"L1GTDigiToRaw") <<
"\nPacking FDL \n" << std::endl;
621 int nrWord64 = fdlBlock.
getSize() / uLength;
622 std::vector<cms_uint64_t> tmpWord64;
623 tmpWord64.resize(nrWord64);
625 for (
int iWord = 0; iWord < nrWord64; ++iWord) {
626 tmpWord64[iWord] = 0x0000000000000000ULL;
630 for (
int iWord = 0; iWord < nrWord64; ++iWord) {
660 for (
int iWord = 0; iWord < nrWord64; ++iWord) {
662 *pw++ = tmpWord64[iWord];
667 << std::setw(4) << iWord <<
" "
668 << std::hex << std::setfill(
'0') << std::setw(16) << tmpWord64[iWord] << std::dec
681 LogDebug(
"L1GTDigiToRaw") <<
"\nPacking PSB \n" << std::endl;
687 int nrWord64 = psbBlock.
getSize() / uLength;
688 std::vector<cms_uint64_t> tmpWord64;
689 tmpWord64.resize(nrWord64);
691 for (
int iWord = 0; iWord < nrWord64; ++iWord) {
692 tmpWord64[iWord] = 0x0000000000000000ULL;
696 for (
int iWord = 0; iWord < nrWord64; ++iWord) {
714 for (
int iWord = 0; iWord < nrWord64; ++iWord) {
716 *pw++ = tmpWord64[iWord];
721 << std::setw(4) << iWord <<
" "
722 << std::hex << std::setfill(
'0') << std::setw(16) << tmpWord64[iWord] << std::dec
732 unsigned char* ptrGt,
737 LogDebug(
"L1GTDigiToRaw") <<
"\nPacking GMT collection \n" << std::endl;
740 unsigned gmtsize = 0;
746 gmtsize =
packGMT(gmtrr, ptrGt);
758 const unsigned SIZE=136;
759 const unsigned boardId=0xdd12;
762 unsigned*
p = (
unsigned*) chp;
769 std::vector<L1MuRegionalCand> vrc;
770 std::vector<L1MuRegionalCand>::const_iterator irc;
775 for(irc=vrc.begin(); irc!=vrc.end(); irc++) {
776 *pp++ = (*irc).getDataWord();
782 for(irc=vrc.begin(); irc!=vrc.end(); irc++) {
783 *pp++ = (*irc).getDataWord();
789 for(irc=vrc.begin(); irc!=vrc.end(); irc++) {
790 *pp++ = (*irc).getDataWord();
796 for(irc=vrc.begin(); irc!=vrc.end(); irc++) {
797 *pp++ = (*irc).getDataWord();
803 for(
int i=0;
i<16;
i++) {
805 *pp++ = (w&0xffff00ff) | ((~w)&0x0000ff00);
808 std::vector<L1MuGMTExtendedCand> vgc;
809 std::vector<L1MuGMTExtendedCand>::const_iterator igc;
813 for(igc=vgc.begin(); igc!=vgc.end(); igc++) {
814 *pp++ = (*igc).getDataWord();
820 for(igc=vgc.begin(); igc!=vgc.end(); igc++) {
821 *pp++ = (*igc).getDataWord();
827 for(igc=vgc.begin(); igc!=vgc.end(); igc++) {
828 *pp++ = (*igc).getDataWord();
835 chpp = (
unsigned char*) p;
836 for(igc=vgc.begin(); igc!=vgc.end(); igc++) {
837 *chpp++ = (*igc).rank();
842 chpp = (
unsigned char*) p;
843 for(igc=vgc.begin(); igc!=vgc.end(); igc++) {
844 *chpp++ = (*igc).rank();
853 return ( (w&0xffff00ff) | ((~w)&0x0000ff00) );
862 int lengthVal = dataSize / 8;
868 int evtStatusVal = 0;
876 bool moreTrailersVal =
false;
879 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
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
input tag for GT DAQ record
void setADataWord64(cms_uint64_t &word64, int iWord)
void setGtPrescaleFactorIndexTechWord64(cms_uint64_t &word64, const int iWord)
edm::InputTag m_muGmtInputTag
input tag for GMT record
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)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
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
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
T const * product() const
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)
std::vector< L1MuGMTExtendedCand > getGMTFwdCands() const
get GMT forward candidates vector
void setBxNrWord64(cms_uint64_t &word64, int iWord)
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)