58 m_evmGtFedId(pSet.getUntrackedParameter<int>(
"EvmGtFedId",
60 m_evmGtInputTag(pSet.getParameter<edm::InputTag>(
"EvmGtInputTag")),
61 m_activeBoardsMaskGt(pSet.getParameter<unsigned int>(
"ActiveBoardsMask")),
63 m_minBxInEvent(0), m_maxBxInEvent(),
64 m_verbosity(pSet.getUntrackedParameter<int> (
"Verbosity", 0)),
71 LogDebug(
"L1GTEvmDigiToRaw") <<
"\nMask for active boards (hex format): "
74 << std::setfill(
' ') <<
"\nInput tag for EVM GT record: "
79 produces<FEDRawDataCollection>();
118 const std::vector<L1GtBoard> boardMaps = l1GtBM->gtBoardMaps();
119 int boardMapsSize = boardMaps.size();
121 typedef std::vector<L1GtBoard>::const_iterator CItBoardMaps;
126 std::vector<L1GtBoard> gtRecordMap;
127 gtRecordMap.reserve(boardMapsSize);
129 for (
int iPos = 0; iPos < boardMapsSize; ++iPos) {
130 for (CItBoardMaps itBoard = boardMaps.begin(); itBoard
131 != boardMaps.end(); ++itBoard) {
133 if (itBoard->gtPositionEvmRecord() == iPos) {
134 gtRecordMap.push_back(*itBoard);
147 if (!gtReadoutRecord.
isValid()) {
149 <<
"\nWarning: L1GlobalTriggerEvmReadoutRecord with input tag " <<
m_evmGtInputTag
150 <<
"\nrequested in configuration, but not found in the event."
151 <<
"\nQuit packing this event" << std::endl;
154 iEvent.
put(allFedRawData);
160 std::ostringstream myCoutStream;
161 gtReadoutRecord->print(myCoutStream);
163 <<
"\n The following L1 GT EVM readout record will be packed.\n"
164 <<
" Some boards could be disabled before packing,"
165 <<
" see detailed board packing.\n"
166 << myCoutStream.str() <<
"\n"
174 boost::uint16_t recordLength0 = gtfeBlock.
recordLength();
184 boost::uint16_t activeBoardsGtInitial = gtfeBlock.
activeBoards();
185 boost::uint16_t altNrBxBoardInitial = gtfeBlock.
altNrBxBoard();
193 <<
"\nActive boards before masking(hex format): " << std::hex
194 << std::setw(
sizeof ( activeBoardsGtInitial ) * 2) << std::setfill(
'0')
195 << activeBoardsGtInitial << std::dec << std::setfill(
' ')
196 <<
"\nActive boards after masking(hex format): " << std::hex
197 << std::setw(
sizeof ( activeBoardsGt ) * 2) << std::setfill(
'0')
198 << activeBoardsGt << std::dec
199 << std::setfill(
' ') <<
" \n"
205 unsigned int gtDataSize = 0;
207 unsigned int headerSize = 8;
208 gtDataSize += headerSize;
211 itBoard = boardMaps.begin();
212 itBoard != boardMaps.end(); ++itBoard) {
214 if (itBoard->gtBoardType() ==
GTFE) {
215 gtDataSize += gtfeBlock.
getSize();
220 int iActiveBit = itBoard->gtBitEvmActiveBoards();
221 bool activeBoardToPack =
false;
223 int altNrBxBoardVal = -1;
225 if (iActiveBit >= 0) {
226 activeBoardToPack = activeBoardsGt & (1 << iActiveBit);
228 altNrBxBoardVal = (altNrBxBoardInitial & ( 1 << iActiveBit )) >> iActiveBit;
230 if (altNrBxBoardVal == 1) {
232 }
else if (altNrBxBoardVal == 0) {
237 <<
"\n\nWARNING: Wrong value altNrBxBoardVal = " << altNrBxBoardVal
238 <<
" for board " << std::hex << ( itBoard->gtBoardId() ) << std::dec
239 <<
"\n iActiveBit = " << iActiveBit
240 <<
"\n altNrBxBoardInitial = 0x" << std::hex << altNrBxBoardInitial << std::dec
241 <<
"\n activeBoardsGt = 0x" << std::hex << activeBoardsGt << std::dec
242 <<
"\n activeBoardToPack = " << activeBoardToPack
243 <<
"\n Set altNrBxBoardVal tentatively to "
244 << recordLength0 <<
"\n Job may crash or produce wrong results!\n\n"
255 if (activeBoardToPack) {
257 switch (itBoard->gtBoardType()) {
271 gtDataSize += tcsBlock.
getSize();
291 unsigned int trailerSize = 8;
292 gtDataSize += trailerSize;
296 gtRawData.
resize(gtDataSize);
300 unsigned char* ptrGt = gtRawData.
data();
301 unsigned char* ptrGtBegin = gtRawData.
data();
304 LogDebug(
"L1GTEvmDigiToRaw") <<
"\n Size of raw data: " << gtRawData.
size() <<
"\n"
317 itBoard = gtRecordMap.begin();
318 itBoard != gtRecordMap.end(); ++itBoard) {
320 if (itBoard->gtBoardType() ==
GTFE) {
322 packGTFE(evSetup, ptrGt, gtfeBlock, activeBoardsGt);
326 std::ostringstream myCoutStream;
327 gtfeBlock.
print(myCoutStream);
329 << myCoutStream.str() <<
"\n"
341 int iActiveBit = itBoard->gtBitEvmActiveBoards();
342 bool activeBoardToPack =
false;
344 int altNrBxBoardVal = -1;
346 if (iActiveBit >= 0) {
347 activeBoardToPack = activeBoardsGt & (1 << iActiveBit);
349 altNrBxBoardVal = (altNrBxBoardInitial & ( 1 << iActiveBit )) >> iActiveBit;
351 if (altNrBxBoardVal == 1) {
353 }
else if (altNrBxBoardVal == 0) {
358 <<
"\n\nWARNING: Wrong value altNrBxBoardVal = " << altNrBxBoardVal
359 <<
" for board " << std::hex << ( itBoard->gtBoardId() ) << std::dec
360 <<
"\n iActiveBit = " << iActiveBit
361 <<
"\n altNrBxBoardInitial = 0x" << std::hex << altNrBxBoardInitial << std::dec
362 <<
"\n activeBoardsGt = 0x" << std::hex << activeBoardsGt << std::dec
363 <<
"\n activeBoardToPack = " << activeBoardToPack
364 <<
"\n Set altNrBxBoardVal tentatively to "
365 << recordLength0 <<
"\n Job may crash or produce wrong results!\n\n"
380 if (activeBoardToPack) {
384 <<
"\nBoard " << std::hex <<
"0x" << ( itBoard->gtBoardId() ) << std::dec
392 switch (itBoard->gtBoardType()) {
396 L1TcsWord tcsBlock = gtReadoutRecord->tcsWord();
397 packTCS(evSetup, ptrGt, tcsBlock);
401 std::ostringstream myCoutStream;
402 tcsBlock.
print(myCoutStream);
404 << myCoutStream.str() <<
"\n"
417 L1GtFdlWord fdlBlock = gtReadoutRecord->gtFdlWord(iBxInEvent);
418 packFDL(evSetup, ptrGt, fdlBlock);
422 std::ostringstream myCoutStream;
423 fdlBlock.
print(myCoutStream);
425 << myCoutStream.str() <<
"\n"
449 iEvent.
put(allFedRawData);
461 int triggerTypeVal = 0;
464 int lvl1IdVal = iEvent.
id().
event();
468 boost::uint16_t bxCrossHw = 0;
469 if ((bxCross & 0xFFF) == bxCross) {
470 bxCrossHw =
static_cast<boost::uint16_t
> (bxCross);
476 <<
"\nBunch cross number [hex] = "
477 << std::hex << bxCross
478 <<
"\n larger than 12 bits. Set to 0! \n"
483 int bxIdVal = bxCrossHw;
494 bool moreHeadersVal =
false;
499 gtFEDHeader.
set(ptrGt,
500 triggerTypeVal, lvl1IdVal, bxIdVal, sourceIdVal, versionVal,
509 unsigned char* ptrGt,
511 boost::uint16_t activeBoardsGtValue)
515 LogDebug(
"L1GTEvmDigiToRaw") <<
"\nPacking GTFE \n" << std::endl;
521 int nrWord64 = gtfeBlock.
getSize()/uLength;
522 std::vector<boost::uint64_t> tmpWord64;
523 tmpWord64.resize(nrWord64);
525 for (
int iWord = 0; iWord < nrWord64; ++iWord) {
526 tmpWord64[iWord] = 0x0000000000000000ULL;
530 for (
int iWord = 0; iWord < nrWord64; ++iWord) {
552 for (
int iWord = 0; iWord < nrWord64; ++iWord) {
554 *pw++ = tmpWord64[iWord];
558 << std::setw(4) << iWord <<
" "
559 << std::hex << std::setfill(
'0')
560 << std::setw(16) << tmpWord64[iWord]
561 << std::dec << std::setfill(
' ')
572 unsigned char* ptrGt,
577 LogDebug(
"L1GTEvmDigiToRaw") <<
"\nPacking TCS \n" << std::endl;
583 int nrWord64 = tcsBlock.
getSize()/uLength;
584 std::vector<boost::uint64_t> tmpWord64;
585 tmpWord64.resize(nrWord64);
587 for (
int iWord = 0; iWord < nrWord64; ++iWord) {
588 tmpWord64[iWord] = 0x0000000000000000ULL;
592 for (
int iWord = 0; iWord < nrWord64; ++iWord) {
616 for (
int iWord = 0; iWord < nrWord64; ++iWord) {
618 *pw++ = tmpWord64[iWord];
622 << std::setw(4) << iWord <<
" "
623 << std::hex << std::setfill(
'0')
624 << std::setw(16) << tmpWord64[iWord]
625 << std::dec << std::setfill(
' ')
636 unsigned char* ptrGt,
641 LogDebug(
"L1GTEvmDigiToRaw") <<
"\nPacking FDL \n" << std::endl;
647 int nrWord64 = fdlBlock.
getSize()/uLength;
648 std::vector<boost::uint64_t> tmpWord64;
649 tmpWord64.resize(nrWord64);
651 for (
int iWord = 0; iWord < nrWord64; ++iWord) {
652 tmpWord64[iWord] = 0x0000000000000000ULL;
656 for (
int iWord = 0; iWord < nrWord64; ++iWord) {
687 for (
int iWord = 0; iWord < nrWord64; ++iWord) {
689 *pw++ = tmpWord64[iWord];
693 << std::setw(4) << iWord <<
" "
694 << std::hex << std::setfill(
'0')
695 << std::setw(16) << tmpWord64[iWord]
696 << std::dec << std::setfill(
' ')
706 unsigned char* ptrGtBegin,
int dataSize)
712 int lengthVal = dataSize/8;
718 int evtStatusVal = 0;
726 bool moreTrailersVal =
false;
729 gtFEDTrailer.
set(ptrGt,
730 lengthVal, crcVal, evtStatusVal, ttsBitsVal,
void setLocalBxNrWord64(boost::uint64_t &word64, const int iWord)
virtual void endJob()
end of job stuff
void setFinalORWord64(boost::uint64_t &word64, const int iWord)
EventNumber_t event() const
void setTotalTriggerNrWord64(boost::uint64_t &word64, int iWord)
void packHeader(unsigned char *, edm::Event &)
block packers -------——
void setTriggerTypeWord64(boost::uint64_t &word64, int iWord)
void setEventNrWord64(boost::uint64_t &word64, const int iWord)
void setPhysicsDeclaredWord64(boost::uint64_t &word64, const int iWord)
int m_totalBxInEvent
total Bx's in the event, obtained from GTFE block
void setBoardIdWord64(boost::uint64_t &word64, int iWord)
void setAltNrBxBoardWord64(boost::uint64_t &word64, int iWord)
void setStatusWord64(boost::uint64_t &word64, int iWord)
void setLuminositySegmentNrWord64(boost::uint64_t &word64, int iWord)
const boost::uint16_t recordLength() const
get/set record length for alternative 0
static const int UnitLength
one unit in the word is UnitLength bits
void setRecordLength1Word64(boost::uint64_t &word64, int iWord)
int m_bstLengthBytes
length of BST record (in bytes)
edm::InputTag m_evmGtInputTag
input tag for GT EVM record
int bunchCrossing() const
void setDaqNrWord64(boost::uint64_t &word64, int iWord)
void packGTFE(const edm::EventSetup &, unsigned char *, L1GtfeExtWord &, boost::uint16_t activeBoardsGtValue)
const unsigned int bstLengthBytes() const
get the size of the BST block
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.
const unsigned int getSize() const
get the size of the FDL block in GT DAQ record (in multiple of 8 bits)
size_t size() const
Lenght of the data buffer in bytes.
void setGtPrescaleFactorIndexTechWord64(boost::uint64_t &word64, const int iWord)
virtual void produce(edm::Event &, const edm::EventSetup &)
loop over events
void setSetupVersionWord64(boost::uint64_t &word64, int iWord)
const unsigned int getSize() const
get the size of the GTFE block in GT EVM record (in multiple of 8 bits)
void packTrailer(unsigned char *, unsigned char *, int)
pack trailer word
boost::uint16_t m_activeBoardsMaskGt
mask for active boards
void setGtPrescaleFactorIndexAlgoWord64(boost::uint64_t &word64, const int iWord)
void print(std::ostream &myCout) const
pretty print the content of a L1TcsWord
void setPartRunNrWord64(boost::uint64_t &word64, int iWord)
void resize(size_t newsize)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
unsigned short compute_crc(unsigned char *buffer, unsigned int bufSize)
void setGtDecisionWordBWord64(boost::uint64_t &word64, const int iWord)
void setRecordLengthWord64(boost::uint64_t &word64, int iWord)
int m_verbosity
verbosity level
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
const boost::uint16_t recordLength1() const
get/set record length for alternative 1
void setBxNrWord64(boost::uint64_t &word64, int iWord)
void print(std::ostream &myCout) const
pretty print the content of a L1GtFdlWord
void setBxInEventWord64(boost::uint64_t &word64, const int iWord)
void setBoardIdWord64(boost::uint64_t &word64, int iWord)
void setGtDecisionWordExtendedWord64(boost::uint64_t &word64, const int iWord)
void setBoardIdWord64(boost::uint64_t &word64, const int iWord)
unsigned long long uint64_t
virtual ~L1GTEvmDigiToRaw()
destructor
void setNoAlgoWord64(boost::uint64_t &word64, const int iWord)
void packTCS(const edm::EventSetup &evSetup, unsigned char *ptrGt, L1TcsWord &tcsBlock)
pack the TCS block
void setBxNrWord64(boost::uint64_t &word64, const int iWord)
void setActiveBoardsWord64(boost::uint64_t &word64, int iWord)
const unsigned int getSize() const
get the size of the TCS block in GT EVM record (in multiple of 8 bits)
void setOrbitNrWord64(boost::uint64_t &word64, const int iWord)
void setBxNrWord64(boost::uint64_t &word64, int iWord)
void setLumiSegmentNrWord64(boost::uint64_t &word64, const int iWord)
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
void setPartTrigNrWord64(boost::uint64_t &word64, int iWord)
void setOrbitNrWord64(boost::uint64_t &word64, int iWord)
const boost::uint16_t activeBoards() const
get/set boards contributing to EVM respectively DAQ record
void packFDL(const edm::EventSetup &, unsigned char *, L1GtFdlWord &)
pack FDL blocks for various bunch crosses
L1GTEvmDigiToRaw(const edm::ParameterSet &)
constructor(s)
void setGtTechnicalTriggerWordWord64(boost::uint64_t &word64, const int iWord)
void setAssignedPartitionsWord64(boost::uint64_t &word64, int iWord)
void setEventNrWord64(boost::uint64_t &word64, int iWord)
const boost::uint16_t altNrBxBoard() const
get/set alternative for number of BX per board
void setBstWord64(boost::uint64_t &word64, int iB, const int iWord)
void setGtDecisionWordAWord64(boost::uint64_t &word64, const int iWord)
virtual void beginJob()
beginning of job stuff