CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
L1GTEvmDigiToRaw Class Reference

#include <L1GTEvmDigiToRaw.h>

Inheritance diagram for L1GTEvmDigiToRaw:
edm::stream::EDProducer<>

Public Member Functions

 L1GTEvmDigiToRaw (const edm::ParameterSet &)
 constructor(s) More...
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Private Member Functions

void packFDL (const edm::EventSetup &, unsigned char *, L1GtFdlWord &)
 pack FDL blocks for various bunch crosses More...
 
void packGTFE (const edm::EventSetup &, unsigned char *, L1GtfeExtWord &, cms_uint16_t activeBoardsGtValue)
 
void packHeader (unsigned char *, edm::Event &)
 block packers -------—— More...
 
void packTCS (const edm::EventSetup &evSetup, unsigned char *ptrGt, L1TcsWord &tcsBlock)
 pack the TCS block More...
 
void packTrailer (unsigned char *, unsigned char *, int)
 pack trailer word More...
 
void produce (edm::Event &, const edm::EventSetup &) override
 loop over events More...
 

Private Attributes

cms_uint16_t m_activeBoardsMaskGt
 mask for active boards More...
 
int m_bstLengthBytes
 length of BST record (in bytes) More...
 
int m_evmGtFedId
 
const edm::InputTag m_evmGtInputTag
 
const edm::EDGetTokenT< L1GlobalTriggerEvmReadoutRecordm_evmGtInputToken
 input tag for GT EVM record More...
 
const bool m_isDebugEnabled
 
const edm::ESGetToken< L1GtBoardMaps, L1GtBoardMapsRcdm_l1GtBMToken
 EventSetup Token for L1GtBoardMaps. More...
 
int m_maxBxInEvent
 
int m_minBxInEvent
 
int m_totalBxInEvent
 total Bx's in the event, obtained from GTFE block More...
 
const int m_verbosity
 verbosity level More...
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

Description: generate raw data from digis.

Implementation: <TODO: enter implementation details>

Author
: Vasile Mihai Ghete - HEPHY Vienna

Definition at line 45 of file L1GTEvmDigiToRaw.h.

Constructor & Destructor Documentation

◆ L1GTEvmDigiToRaw()

L1GTEvmDigiToRaw::L1GTEvmDigiToRaw ( const edm::ParameterSet pSet)
explicit

constructor(s)

Definition at line 52 of file L1GTEvmDigiToRaw.cc.

References TauDecayModes::dec, LogDebug, m_activeBoardsMaskGt, m_evmGtFedId, and m_evmGtInputTag.

54  m_evmGtInputToken(consumes<L1GlobalTriggerEvmReadoutRecord>(pSet.getParameter<edm::InputTag>("EvmGtInputTag"))),
55  m_evmGtInputTag(pSet.getParameter<edm::InputTag>("EvmGtInputTag")),
56  m_l1GtBMToken(esConsumes<L1GtBoardMaps, L1GtBoardMapsRcd>()),
57  m_activeBoardsMaskGt(pSet.getParameter<unsigned int>("ActiveBoardsMask")),
59  m_minBxInEvent(0),
61  m_verbosity(pSet.getUntrackedParameter<int>("Verbosity", 0)),
63 
64 {
65  LogDebug("L1GTEvmDigiToRaw") << "\nMask for active boards (hex format): " << std::hex
66  << std::setw(sizeof(m_activeBoardsMaskGt) * 2) << std::setfill('0')
67  << m_activeBoardsMaskGt << std::dec << std::setfill(' ')
68  << "\nInput tag for EVM GT record: " << m_evmGtInputTag
69  << "\nFED Id for EVM GT record: " << m_evmGtFedId << " \n"
70  << std::endl;
71 
72  //
73  produces<FEDRawDataCollection>();
74 }
bool isDebugEnabled()
const bool m_isDebugEnabled
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
int m_totalBxInEvent
total Bx&#39;s in the event, obtained from GTFE block
cms_uint16_t m_activeBoardsMaskGt
mask for active boards
const edm::InputTag m_evmGtInputTag
const int m_verbosity
verbosity level
T getUntrackedParameter(std::string const &, T const &) const
const edm::ESGetToken< L1GtBoardMaps, L1GtBoardMapsRcd > m_l1GtBMToken
EventSetup Token for L1GtBoardMaps.
const edm::EDGetTokenT< L1GlobalTriggerEvmReadoutRecord > m_evmGtInputToken
input tag for GT EVM record
#define LogDebug(id)

Member Function Documentation

◆ packFDL()

void L1GTEvmDigiToRaw::packFDL ( const edm::EventSetup evSetup,
unsigned char *  ptrGt,
L1GtFdlWord fdlBlock 
)
private

pack FDL blocks for various bunch crosses

Definition at line 520 of file L1GTEvmDigiToRaw.cc.

References TauDecayModes::dec, L1GtFdlWord::getSize(), LogDebug, LogTrace, m_isDebugEnabled, m_verbosity, L1GtFdlWord::setBoardIdWord64(), L1GtFdlWord::setBxInEventWord64(), L1GtFdlWord::setBxNrWord64(), L1GtFdlWord::setEventNrWord64(), L1GtFdlWord::setFinalORWord64(), L1GtFdlWord::setGtDecisionWordAWord64(), L1GtFdlWord::setGtDecisionWordBWord64(), L1GtFdlWord::setGtDecisionWordExtendedWord64(), L1GtFdlWord::setGtPrescaleFactorIndexAlgoWord64(), L1GtFdlWord::setGtPrescaleFactorIndexTechWord64(), L1GtFdlWord::setGtTechnicalTriggerWordWord64(), L1GtFdlWord::setLocalBxNrWord64(), L1GtFdlWord::setLumiSegmentNrWord64(), L1GtFdlWord::setNoAlgoWord64(), L1GtFdlWord::setOrbitNrWord64(), L1GtFdlWord::setPhysicsDeclaredWord64(), and L1GlobalTriggerReadoutSetup::UnitLength.

Referenced by produce().

520  {
521  if (m_verbosity && m_isDebugEnabled) {
522  LogDebug("L1GTEvmDigiToRaw") << "\nPacking FDL \n" << std::endl;
523  }
524 
526 
527  // initialize the required number of word64
528  int nrWord64 = fdlBlock.getSize() / uLength;
529  std::vector<cms_uint64_t> tmpWord64;
530  tmpWord64.resize(nrWord64);
531 
532  for (int iWord = 0; iWord < nrWord64; ++iWord) {
533  tmpWord64[iWord] = 0x0000000000000000ULL;
534  }
535 
536  // fill the values in the words
537  for (int iWord = 0; iWord < nrWord64; ++iWord) {
538  fdlBlock.setBoardIdWord64(tmpWord64[iWord], iWord);
539  fdlBlock.setBxInEventWord64(tmpWord64[iWord], iWord);
540  fdlBlock.setBxNrWord64(tmpWord64[iWord], iWord);
541  fdlBlock.setEventNrWord64(tmpWord64[iWord], iWord);
542 
543  fdlBlock.setGtTechnicalTriggerWordWord64(tmpWord64[iWord], iWord);
544 
545  fdlBlock.setGtDecisionWordAWord64(tmpWord64[iWord], iWord);
546  fdlBlock.setGtDecisionWordBWord64(tmpWord64[iWord], iWord);
547 
548  fdlBlock.setGtDecisionWordExtendedWord64(tmpWord64[iWord], iWord);
549 
550  fdlBlock.setPhysicsDeclaredWord64(tmpWord64[iWord], iWord);
551  fdlBlock.setGtPrescaleFactorIndexTechWord64(tmpWord64[iWord], iWord);
552  fdlBlock.setGtPrescaleFactorIndexAlgoWord64(tmpWord64[iWord], iWord);
553  fdlBlock.setNoAlgoWord64(tmpWord64[iWord], iWord);
554  fdlBlock.setFinalORWord64(tmpWord64[iWord], iWord);
555 
556  fdlBlock.setOrbitNrWord64(tmpWord64[iWord], iWord);
557  fdlBlock.setLumiSegmentNrWord64(tmpWord64[iWord], iWord);
558  fdlBlock.setLocalBxNrWord64(tmpWord64[iWord], iWord);
559  }
560 
561  // put the words in the FED record
562 
563  cms_uint64_t* pw = reinterpret_cast<cms_uint64_t*>(const_cast<unsigned char*>(ptrGt));
564 
565  for (int iWord = 0; iWord < nrWord64; ++iWord) {
566  *pw++ = tmpWord64[iWord];
567 
568  if (m_verbosity && m_isDebugEnabled) {
569  LogTrace("L1GTEvmDigiToRaw") << std::setw(4) << iWord << " " << std::hex << std::setfill('0') << std::setw(16)
570  << tmpWord64[iWord] << std::dec << std::setfill(' ') << std::endl;
571  }
572  }
573 }
const bool m_isDebugEnabled
void setNoAlgoWord64(cms_uint64_t &word64, const int iWord)
Definition: L1GtFdlWord.cc:514
void setGtDecisionWordBWord64(cms_uint64_t &word64, const int iWord)
Definition: L1GtFdlWord.cc:388
static const int UnitLength
one unit in the word is UnitLength bits
void setBoardIdWord64(cms_uint64_t &word64, const int iWord)
Definition: L1GtFdlWord.cc:179
void setLumiSegmentNrWord64(cms_uint64_t &word64, const int iWord)
Definition: L1GtFdlWord.cc:549
const int m_verbosity
verbosity level
void setOrbitNrWord64(cms_uint64_t &word64, const int iWord)
Definition: L1GtFdlWord.cc:536
void setGtTechnicalTriggerWordWord64(cms_uint64_t &word64, const int iWord)
Definition: L1GtFdlWord.cc:259
#define LogTrace(id)
void setGtPrescaleFactorIndexTechWord64(cms_uint64_t &word64, const int iWord)
Definition: L1GtFdlWord.cc:490
void setBxInEventWord64(cms_uint64_t &word64, const int iWord)
Definition: L1GtFdlWord.cc:194
void setPhysicsDeclaredWord64(cms_uint64_t &word64, const int iWord)
Definition: L1GtFdlWord.cc:477
void setEventNrWord64(cms_uint64_t &word64, const int iWord)
Definition: L1GtFdlWord.cc:218
void setBxNrWord64(cms_uint64_t &word64, const int iWord)
Definition: L1GtFdlWord.cc:207
void setGtDecisionWordExtendedWord64(cms_uint64_t &word64, const int iWord)
Definition: L1GtFdlWord.cc:446
const unsigned int getSize() const
get the size of the FDL block in GT DAQ record (in multiple of 8 bits)
Definition: L1GtFdlWord.h:271
void setLocalBxNrWord64(cms_uint64_t &word64, const int iWord)
Definition: L1GtFdlWord.cc:560
void setGtDecisionWordAWord64(cms_uint64_t &word64, const int iWord)
Definition: L1GtFdlWord.cc:361
void setFinalORWord64(cms_uint64_t &word64, const int iWord)
Definition: L1GtFdlWord.cc:525
unsigned long long cms_uint64_t
Definition: typedefs.h:17
void setGtPrescaleFactorIndexAlgoWord64(cms_uint64_t &word64, const int iWord)
Definition: L1GtFdlWord.cc:503
#define LogDebug(id)

◆ packGTFE()

void L1GTEvmDigiToRaw::packGTFE ( const edm::EventSetup evSetup,
unsigned char *  ptrGt,
L1GtfeExtWord gtfeBlock,
cms_uint16_t  activeBoardsGtValue 
)
private

pack the GTFE block gives the number of bunch crosses in the event, as well as the active boards records for inactive boards are not written in the GT EVM record

Definition at line 421 of file L1GTEvmDigiToRaw.cc.

References TauDecayModes::dec, L1GtfeExtWord::getSize(), LogDebug, LogTrace, m_bstLengthBytes, m_isDebugEnabled, m_verbosity, L1GtfeWord::setActiveBoardsWord64(), L1GtfeWord::setAltNrBxBoardWord64(), L1GtfeWord::setBoardIdWord64(), L1GtfeExtWord::setBstWord64(), L1GtfeWord::setBxNrWord64(), L1GtfeWord::setRecordLength1Word64(), L1GtfeWord::setRecordLengthWord64(), L1GtfeWord::setSetupVersionWord64(), L1GtfeWord::setTotalTriggerNrWord64(), and L1GlobalTriggerReadoutSetup::UnitLength.

Referenced by produce().

424  {
425  if (m_verbosity && m_isDebugEnabled) {
426  LogDebug("L1GTEvmDigiToRaw") << "\nPacking GTFE \n" << std::endl;
427  }
428 
430 
431  // initialize the required number of word64
432  int nrWord64 = gtfeBlock.getSize() / uLength;
433  std::vector<cms_uint64_t> tmpWord64;
434  tmpWord64.resize(nrWord64);
435 
436  for (int iWord = 0; iWord < nrWord64; ++iWord) {
437  tmpWord64[iWord] = 0x0000000000000000ULL;
438  }
439 
440  // fill the values in the words
441  for (int iWord = 0; iWord < nrWord64; ++iWord) {
442  gtfeBlock.setBoardIdWord64(tmpWord64[iWord], iWord);
443  gtfeBlock.setRecordLength1Word64(tmpWord64[iWord], iWord);
444  gtfeBlock.setRecordLengthWord64(tmpWord64[iWord], iWord);
445  gtfeBlock.setBxNrWord64(tmpWord64[iWord], iWord);
446  gtfeBlock.setSetupVersionWord64(tmpWord64[iWord], iWord);
447  gtfeBlock.setActiveBoardsWord64(tmpWord64[iWord], iWord, activeBoardsGtValue);
448  gtfeBlock.setAltNrBxBoardWord64(tmpWord64[iWord], iWord);
449  gtfeBlock.setTotalTriggerNrWord64(tmpWord64[iWord], iWord);
450 
451  for (int iBst = 0; iBst < m_bstLengthBytes; ++iBst) {
452  gtfeBlock.setBstWord64(tmpWord64[iWord], iBst, iWord);
453  }
454  }
455 
456  // put the words in the FED record
457 
458  cms_uint64_t* pw = reinterpret_cast<cms_uint64_t*>(const_cast<unsigned char*>(ptrGt));
459 
460  for (int iWord = 0; iWord < nrWord64; ++iWord) {
461  *pw++ = tmpWord64[iWord];
462 
463  if (m_verbosity && m_isDebugEnabled) {
464  LogTrace("L1GTEvmDigiToRaw") << std::setw(4) << iWord << " " << std::hex << std::setfill('0') << std::setw(16)
465  << tmpWord64[iWord] << std::dec << std::setfill(' ') << std::endl;
466  }
467  }
468 }
const bool m_isDebugEnabled
void setRecordLength1Word64(cms_uint64_t &word64, int iWord)
Definition: L1GtfeWord.cc:129
static const int UnitLength
one unit in the word is UnitLength bits
int m_bstLengthBytes
length of BST record (in bytes)
const int m_verbosity
verbosity level
void setActiveBoardsWord64(cms_uint64_t &word64, int iWord)
Definition: L1GtfeWord.cc:191
void setSetupVersionWord64(cms_uint64_t &word64, int iWord)
Definition: L1GtfeWord.cc:166
#define LogTrace(id)
void setBstWord64(cms_uint64_t &word64, int iB, const int iWord)
void setBoardIdWord64(cms_uint64_t &word64, int iWord)
Definition: L1GtfeWord.cc:116
void setAltNrBxBoardWord64(cms_uint64_t &word64, int iWord)
Definition: L1GtfeWord.cc:212
void setBxNrWord64(cms_uint64_t &word64, int iWord)
Definition: L1GtfeWord.cc:153
const unsigned int getSize() const
get the size of the GTFE block in GT EVM record (in multiple of 8 bits)
unsigned long long cms_uint64_t
Definition: typedefs.h:17
void setTotalTriggerNrWord64(cms_uint64_t &word64, int iWord)
Definition: L1GtfeWord.cc:233
void setRecordLengthWord64(cms_uint64_t &word64, int iWord)
Definition: L1GtfeWord.cc:142
#define LogDebug(id)

◆ packHeader()

void L1GTEvmDigiToRaw::packHeader ( unsigned char *  ptrGt,
edm::Event iEvent 
)
private

block packers -------——

pack header

Definition at line 380 of file L1GTEvmDigiToRaw.cc.

References TauDecayModes::dec, iEvent, LogDebug, m_evmGtFedId, m_isDebugEnabled, m_verbosity, and FEDHeader::set().

Referenced by produce().

380  {
381  // TODO FIXME where from to get all numbers?
382 
383  // Event Trigger type identifier
384  int triggerTypeVal = 0;
385 
386  // Level-1 event number generated by the TTC system
387  int lvl1IdVal = iEvent.id().event();
388 
389  // The bunch crossing number
390  int bxCross = iEvent.bunchCrossing();
391  cms_uint16_t bxCrossHw = 0;
392  if ((bxCross & 0xFFF) == bxCross) {
393  bxCrossHw = static_cast<cms_uint16_t>(bxCross);
394  } else {
395  bxCrossHw = 0; // Bx number too large, set to 0!
396  if (m_verbosity && m_isDebugEnabled) {
397  LogDebug("L1GTEvmDigiToRaw") << "\nBunch cross number [hex] = " << std::hex << bxCross
398  << "\n larger than 12 bits. Set to 0! \n"
399  << std::dec << std::endl;
400  }
401  }
402  int bxIdVal = bxCrossHw;
403 
404  // Identifier of the FED
405  int sourceIdVal = m_evmGtFedId;
406 
407  // Version identifier of the FED data format
408  int versionVal = 0;
409 
410  // 0 -> the current header word is the last one.
411  // 1-> other header words can follow
412  // (always 1 for ECAL)
413  bool moreHeadersVal = false;
414 
415  FEDHeader gtFEDHeader(ptrGt);
416 
417  gtFEDHeader.set(ptrGt, triggerTypeVal, lvl1IdVal, bxIdVal, sourceIdVal, versionVal, moreHeadersVal);
418 }
const bool m_isDebugEnabled
const int m_verbosity
verbosity level
int iEvent
Definition: GenABIO.cc:224
unsigned short cms_uint16_t
Definition: typedefs.h:13
#define LogDebug(id)

◆ packTCS()

void L1GTEvmDigiToRaw::packTCS ( const edm::EventSetup evSetup,
unsigned char *  ptrGt,
L1TcsWord tcsBlock 
)
private

pack the TCS block

Definition at line 471 of file L1GTEvmDigiToRaw.cc.

References TauDecayModes::dec, L1TcsWord::getSize(), LogDebug, LogTrace, m_isDebugEnabled, m_verbosity, L1TcsWord::setAssignedPartitionsWord64(), L1TcsWord::setBoardIdWord64(), L1TcsWord::setBxNrWord64(), L1TcsWord::setDaqNrWord64(), L1TcsWord::setEventNrWord64(), L1TcsWord::setLuminositySegmentNrWord64(), L1TcsWord::setOrbitNrWord64(), L1TcsWord::setPartRunNrWord64(), L1TcsWord::setPartTrigNrWord64(), L1TcsWord::setStatusWord64(), L1TcsWord::setTriggerTypeWord64(), and L1GlobalTriggerReadoutSetup::UnitLength.

Referenced by produce().

471  {
472  if (m_verbosity && m_isDebugEnabled) {
473  LogDebug("L1GTEvmDigiToRaw") << "\nPacking TCS \n" << std::endl;
474  }
475 
477 
478  // initialize the required number of word64
479  int nrWord64 = tcsBlock.getSize() / uLength;
480  std::vector<cms_uint64_t> tmpWord64;
481  tmpWord64.resize(nrWord64);
482 
483  for (int iWord = 0; iWord < nrWord64; ++iWord) {
484  tmpWord64[iWord] = 0x0000000000000000ULL;
485  }
486 
487  // fill the values in the words
488  for (int iWord = 0; iWord < nrWord64; ++iWord) {
489  tcsBlock.setBoardIdWord64(tmpWord64[iWord], iWord);
490  tcsBlock.setBxNrWord64(tmpWord64[iWord], iWord);
491  tcsBlock.setDaqNrWord64(tmpWord64[iWord], iWord);
492  tcsBlock.setTriggerTypeWord64(tmpWord64[iWord], iWord);
493  tcsBlock.setStatusWord64(tmpWord64[iWord], iWord);
494  tcsBlock.setLuminositySegmentNrWord64(tmpWord64[iWord], iWord);
495 
496  tcsBlock.setPartRunNrWord64(tmpWord64[iWord], iWord);
497  tcsBlock.setAssignedPartitionsWord64(tmpWord64[iWord], iWord);
498 
499  tcsBlock.setPartTrigNrWord64(tmpWord64[iWord], iWord);
500  tcsBlock.setEventNrWord64(tmpWord64[iWord], iWord);
501 
502  tcsBlock.setOrbitNrWord64(tmpWord64[iWord], iWord);
503  }
504 
505  // put the words in the FED record
506 
507  cms_uint64_t* pw = reinterpret_cast<cms_uint64_t*>(const_cast<unsigned char*>(ptrGt));
508 
509  for (int iWord = 0; iWord < nrWord64; ++iWord) {
510  *pw++ = tmpWord64[iWord];
511 
512  if (m_verbosity && m_isDebugEnabled) {
513  LogTrace("L1GTEvmDigiToRaw") << std::setw(4) << iWord << " " << std::hex << std::setfill('0') << std::setw(16)
514  << tmpWord64[iWord] << std::dec << std::setfill(' ') << std::endl;
515  }
516  }
517 }
const bool m_isDebugEnabled
void setBoardIdWord64(cms_uint64_t &word64, int iWord)
Definition: L1TcsWord.cc:134
void setBxNrWord64(cms_uint64_t &word64, int iWord)
Definition: L1TcsWord.cc:145
static const int UnitLength
one unit in the word is UnitLength bits
const int m_verbosity
verbosity level
void setAssignedPartitionsWord64(cms_uint64_t &word64, int iWord)
Definition: L1TcsWord.cc:217
void setOrbitNrWord64(cms_uint64_t &word64, int iWord)
Definition: L1TcsWord.cc:252
#define LogTrace(id)
void setTriggerTypeWord64(cms_uint64_t &word64, int iWord)
Definition: L1TcsWord.cc:169
const unsigned int getSize() const
get the size of the TCS block in GT EVM record (in multiple of 8 bits)
Definition: L1TcsWord.h:197
void setLuminositySegmentNrWord64(cms_uint64_t &word64, int iWord)
Definition: L1TcsWord.cc:193
void setEventNrWord64(cms_uint64_t &word64, int iWord)
Definition: L1TcsWord.cc:241
void setPartRunNrWord64(cms_uint64_t &word64, int iWord)
Definition: L1TcsWord.cc:204
void setPartTrigNrWord64(cms_uint64_t &word64, int iWord)
Definition: L1TcsWord.cc:230
unsigned long long cms_uint64_t
Definition: typedefs.h:17
void setDaqNrWord64(cms_uint64_t &word64, int iWord)
Definition: L1TcsWord.cc:156
void setStatusWord64(cms_uint64_t &word64, int iWord)
Definition: L1TcsWord.cc:180
#define LogDebug(id)

◆ packTrailer()

void L1GTEvmDigiToRaw::packTrailer ( unsigned char *  ptrGt,
unsigned char *  ptrGtBegin,
int  dataSize 
)
private

pack trailer word

Definition at line 576 of file L1GTEvmDigiToRaw.cc.

References evf::compute_crc(), and FEDTrailer::set().

Referenced by produce().

576  {
577  // TODO FIXME where from to get all numbers?
578 
579  // The length of the event fragment counted in 64-bit words including header and trailer
580  int lengthVal = dataSize / 8;
581 
582  // Cyclic Redundancy Code of the event fragment including header and trailer
583  int crcVal = evf::compute_crc(ptrGtBegin, dataSize);
584 
585  // Event fragment status information
586  int evtStatusVal = 0;
587 
588  // Current value of the Trigger Throttling System bits.
589  int ttsBitsVal = 0;
590 
591  // 0 -> the current trailer word is the last one.
592  // 1-> other trailer words can follow
593  // (always 0 for ECAL)
594  bool moreTrailersVal = false;
595 
596  FEDTrailer gtFEDTrailer(ptrGt);
597  gtFEDTrailer.set(ptrGt, lengthVal, crcVal, evtStatusVal, ttsBitsVal, moreTrailersVal);
598 }
unsigned short compute_crc(unsigned char *buffer, unsigned int bufSize)
Definition: CRC16.h:46

◆ produce()

void L1GTEvmDigiToRaw::produce ( edm::Event iEvent,
const edm::EventSetup evSetup 
)
overrideprivate

loop over events

Definition at line 79 of file L1GTEvmDigiToRaw.cc.

References L1GtfeWord::activeBoards(), L1GtfeWord::altNrBxBoard(), L1GtfeExtWord::bstLengthBytes(), FEDRawData::data(), TauDecayModes::dec, FDL, edm::EventSetup::getHandle(), L1GtfeExtWord::getSize(), L1TcsWord::getSize(), L1GtFdlWord::getSize(), L1GtBoardMaps::gtBoardMaps(), L1GlobalTriggerEvmReadoutRecord::gtFdlWord(), GTFE, L1GlobalTriggerEvmReadoutRecord::gtfeWord(), iEvent, edm::HandleBase::isValid(), LogDebug, LogTrace, m_activeBoardsMaskGt, m_bstLengthBytes, m_evmGtFedId, m_evmGtInputTag, m_evmGtInputToken, m_isDebugEnabled, m_l1GtBMToken, m_maxBxInEvent, m_minBxInEvent, m_totalBxInEvent, m_verbosity, eostools::move(), packFDL(), packGTFE(), packHeader(), packTCS(), packTrailer(), L1GlobalTriggerEvmReadoutRecord::print(), L1GtfeExtWord::print(), L1TcsWord::print(), L1GtFdlWord::print(), L1GtfeWord::recordLength(), L1GtfeWord::recordLength1(), FEDRawData::resize(), FEDRawData::size(), TCS, L1GlobalTriggerEvmReadoutRecord::tcsWord(), and TIM.

79  {
80  // define new FEDRawDataCollection
81  // it contains ALL FEDs in an event
82  std::unique_ptr<FEDRawDataCollection> allFedRawData(new FEDRawDataCollection);
83 
84  FEDRawData& gtRawData = allFedRawData->FEDData(m_evmGtFedId);
85 
86  // get records from EventSetup
87 
88  // board maps
90 
91  const std::vector<L1GtBoard> boardMaps = l1GtBM->gtBoardMaps();
92  int boardMapsSize = boardMaps.size();
93 
94  typedef std::vector<L1GtBoard>::const_iterator CItBoardMaps;
95 
96  // create an ordered vector for the GT EVM record
97  // header (pos 0 in record) and trailer (last position in record)
98  // not included, as they are not in board list
99  std::vector<L1GtBoard> gtRecordMap;
100  gtRecordMap.reserve(boardMapsSize);
101 
102  for (int iPos = 0; iPos < boardMapsSize; ++iPos) {
103  for (CItBoardMaps itBoard = boardMaps.begin(); itBoard != boardMaps.end(); ++itBoard) {
104  if (itBoard->gtPositionEvmRecord() == iPos) {
105  gtRecordMap.push_back(*itBoard);
106  break;
107  }
108  }
109  }
110 
111  // get L1GlobalTriggerEvmReadoutRecord
113  iEvent.getByToken(m_evmGtInputToken, gtReadoutRecord);
114 
115  if (!gtReadoutRecord.isValid()) {
116  edm::LogWarning("L1GTEvmDigiToRaw") << "\nWarning: L1GlobalTriggerEvmReadoutRecord with input tag "
117  << m_evmGtInputTag
118  << "\nrequested in configuration, but not found in the event."
119  << "\nQuit packing this event" << std::endl;
120 
121  // put the raw data in the event
122  iEvent.put(std::move(allFedRawData));
123 
124  return;
125  }
126 
127  if (m_verbosity && m_isDebugEnabled) {
128  std::ostringstream myCoutStream;
129  gtReadoutRecord->print(myCoutStream);
130  LogTrace("L1GTEvmDigiToRaw") << "\n The following L1 GT EVM readout record will be packed.\n"
131  << " Some boards could be disabled before packing,"
132  << " see detailed board packing.\n"
133  << myCoutStream.str() << "\n"
134  << std::endl;
135  }
136 
137  // get GTFE block
138  L1GtfeExtWord gtfeBlock = gtReadoutRecord->gtfeWord();
139 
140  // get the number of Bx in the event for alternative 0 and alternative 1
141  cms_uint16_t recordLength0 = gtfeBlock.recordLength();
142  cms_uint16_t recordLength1 = gtfeBlock.recordLength1();
143 
144  // length of BST record (in bytes)
145  m_bstLengthBytes = static_cast<int>(gtfeBlock.bstLengthBytes());
146 
147  // get list of active blocks from the GTFE block
148  // and mask some blocks, if required
149  // blocks not active are not written to the record
150 
151  cms_uint16_t activeBoardsGtInitial = gtfeBlock.activeBoards();
152  cms_uint16_t altNrBxBoardInitial = gtfeBlock.altNrBxBoard();
153 
154  // mask some boards, if needed
155 
156  cms_uint16_t activeBoardsGt = activeBoardsGtInitial & m_activeBoardsMaskGt;
157 
158  if (m_verbosity && m_isDebugEnabled) {
159  LogDebug("L1GTEvmDigiToRaw") << "\nActive boards before masking(hex format): " << std::hex
160  << std::setw(sizeof(activeBoardsGtInitial) * 2) << std::setfill('0')
161  << activeBoardsGtInitial << std::dec << std::setfill(' ')
162  << "\nActive boards after masking(hex format): " << std::hex
163  << std::setw(sizeof(activeBoardsGt) * 2) << std::setfill('0') << activeBoardsGt
164  << std::dec << std::setfill(' ') << " \n"
165  << std::endl;
166  }
167 
168  // get the size of the record
169 
170  unsigned int gtDataSize = 0;
171 
172  unsigned int headerSize = 8;
173  gtDataSize += headerSize;
174 
175  for (CItBoardMaps itBoard = boardMaps.begin(); itBoard != boardMaps.end(); ++itBoard) {
176  if (itBoard->gtBoardType() == GTFE) {
177  gtDataSize += gtfeBlock.getSize();
178  continue;
179  }
180 
181  int iActiveBit = itBoard->gtBitEvmActiveBoards();
182  bool activeBoardToPack = false;
183 
184  int altNrBxBoardVal = -1;
185 
186  if (iActiveBit >= 0) {
187  activeBoardToPack = activeBoardsGt & (1 << iActiveBit);
188 
189  altNrBxBoardVal = (altNrBxBoardInitial & (1 << iActiveBit)) >> iActiveBit;
190 
191  if (altNrBxBoardVal == 1) {
192  m_totalBxInEvent = recordLength1;
193  } else if (altNrBxBoardVal == 0) {
194  m_totalBxInEvent = recordLength0;
195  } else {
196  if (m_verbosity) {
197  edm::LogWarning("L1GTEvmDigiToRaw")
198  << "\n\nWARNING: Wrong value altNrBxBoardVal = " << altNrBxBoardVal << " for board " << std::hex
199  << (itBoard->gtBoardId()) << std::dec << "\n iActiveBit = " << iActiveBit
200  << "\n altNrBxBoardInitial = 0x" << std::hex << altNrBxBoardInitial << std::dec
201  << "\n activeBoardsGt = 0x" << std::hex << activeBoardsGt << std::dec
202  << "\n activeBoardToPack = " << activeBoardToPack << "\n Set altNrBxBoardVal tentatively to "
203  << recordLength0 << "\n Job may crash or produce wrong results!\n\n"
204  << std::endl;
205  }
206 
207  m_totalBxInEvent = recordLength0;
208  }
209  } else {
210  // board not in the ActiveBoards for the record
211  continue;
212  }
213 
214  if (activeBoardToPack) {
215  switch (itBoard->gtBoardType()) {
216  case GTFE: {
217  // size already added;
218  }
219 
220  break;
221  case FDL: {
222  L1GtFdlWord fdlBlock;
223  gtDataSize += m_totalBxInEvent * fdlBlock.getSize();
224  }
225 
226  break;
227  case TCS: {
228  L1TcsWord tcsBlock;
229  gtDataSize += tcsBlock.getSize();
230  }
231 
232  break;
233  case TIM: {
234  // not considered
235  }
236 
237  break;
238  default: {
239  // do nothing, all blocks are given in GtBoardType enum
240  }
241 
242  break;
243  }
244  }
245  }
246 
247  unsigned int trailerSize = 8;
248  gtDataSize += trailerSize;
249 
250  // resize, GT raw data record has variable length,
251  // depending on active boards (read in GTFE)
252  gtRawData.resize(gtDataSize);
253 
254  // ptrGt: pointer to the beginning of GT record in the raw data
255 
256  unsigned char* ptrGt = gtRawData.data();
257  unsigned char* ptrGtBegin = gtRawData.data();
258 
259  if (m_verbosity && m_isDebugEnabled) {
260  LogDebug("L1GTEvmDigiToRaw") << "\n Size of raw data: " << gtRawData.size() << "\n" << std::endl;
261  }
262 
263  // ------- pack boards -------
264 
265  // pack header
266  packHeader(ptrGt, iEvent);
267  ptrGt += headerSize; // advance with header size
268 
269  // loop over other blocks in the raw record, if they are active
270 
271  for (CItBoardMaps itBoard = gtRecordMap.begin(); itBoard != gtRecordMap.end(); ++itBoard) {
272  if (itBoard->gtBoardType() == GTFE) {
273  packGTFE(evSetup, ptrGt, gtfeBlock, activeBoardsGt);
274 
275  if (m_verbosity && m_isDebugEnabled) {
276  std::ostringstream myCoutStream;
277  gtfeBlock.print(myCoutStream);
278  LogTrace("L1GTEvmDigiToRaw") << myCoutStream.str() << "\n" << std::endl;
279  }
280 
281  ptrGt += gtfeBlock.getSize(); // advance with GTFE block size
282 
283  continue;
284  }
285 
286  // pack modules other than GTFE if they are active
287 
288  int iActiveBit = itBoard->gtBitEvmActiveBoards();
289  bool activeBoardToPack = false;
290 
291  int altNrBxBoardVal = -1;
292 
293  if (iActiveBit >= 0) {
294  activeBoardToPack = activeBoardsGt & (1 << iActiveBit);
295 
296  altNrBxBoardVal = (altNrBxBoardInitial & (1 << iActiveBit)) >> iActiveBit;
297 
298  if (altNrBxBoardVal == 1) {
299  m_totalBxInEvent = recordLength1;
300  } else if (altNrBxBoardVal == 0) {
301  m_totalBxInEvent = recordLength0;
302  } else {
303  if (m_verbosity) {
304  edm::LogWarning("L1GTEvmDigiToRaw")
305  << "\n\nWARNING: Wrong value altNrBxBoardVal = " << altNrBxBoardVal << " for board " << std::hex
306  << (itBoard->gtBoardId()) << std::dec << "\n iActiveBit = " << iActiveBit
307  << "\n altNrBxBoardInitial = 0x" << std::hex << altNrBxBoardInitial << std::dec
308  << "\n activeBoardsGt = 0x" << std::hex << activeBoardsGt << std::dec
309  << "\n activeBoardToPack = " << activeBoardToPack << "\n Set altNrBxBoardVal tentatively to "
310  << recordLength0 << "\n Job may crash or produce wrong results!\n\n"
311  << std::endl;
312  }
313 
314  m_totalBxInEvent = recordLength0;
315  }
316 
318  m_maxBxInEvent = (m_totalBxInEvent + 1) / 2 - 1;
319 
320  } else {
321  // board not in the ActiveBoards for the record
322  continue;
323  }
324 
325  if (activeBoardToPack) {
326  if (m_verbosity && m_isDebugEnabled) {
327  LogDebug("L1GTEvmDigiToRaw") << "\nBoard " << std::hex << "0x" << (itBoard->gtBoardId()) << std::dec
328  << "\n Number of bunch crosses in the record: " << m_totalBxInEvent << " = "
329  << "[" << m_minBxInEvent << ", " << m_maxBxInEvent << "] BX\n"
330  << std::endl;
331  }
332 
333  // active board, pack it
334  switch (itBoard->gtBoardType()) {
335  case TCS: {
336  L1TcsWord tcsBlock = gtReadoutRecord->tcsWord();
337  packTCS(evSetup, ptrGt, tcsBlock);
338 
339  if (m_verbosity && m_isDebugEnabled) {
340  std::ostringstream myCoutStream;
341  tcsBlock.print(myCoutStream);
342  LogTrace("L1GTEvmDigiToRaw") << myCoutStream.str() << "\n" << std::endl;
343  }
344 
345  ptrGt += tcsBlock.getSize(); // advance with TCS block size
346 
347  } break;
348  case FDL: {
349  for (int iBxInEvent = m_minBxInEvent; iBxInEvent <= m_maxBxInEvent; ++iBxInEvent) {
350  L1GtFdlWord fdlBlock = gtReadoutRecord->gtFdlWord(iBxInEvent);
351  packFDL(evSetup, ptrGt, fdlBlock);
352 
353  if (m_verbosity && m_isDebugEnabled) {
354  std::ostringstream myCoutStream;
355  fdlBlock.print(myCoutStream);
356  LogTrace("L1GTEvmDigiToRaw") << myCoutStream.str() << "\n" << std::endl;
357  }
358 
359  ptrGt += fdlBlock.getSize(); // advance with FDL block size
360  }
361 
362  } break;
363  default: {
364  // do nothing, all blocks are given in GtBoardType enum
365  break;
366  }
367  }
368  }
369  }
370 
371  // pack trailer
372  packTrailer(ptrGt, ptrGtBegin, gtDataSize);
373 
374  // put the raw data in the event
375 
376  iEvent.put(std::move(allFedRawData));
377 }
void packHeader(unsigned char *, edm::Event &)
block packers -------——
const bool m_isDebugEnabled
const cms_uint16_t altNrBxBoard() const
get/set alternative for number of BX per board
Definition: L1GtfeWord.h:134
void print(std::ostream &myCout) const
pretty print the content of a L1GlobalTriggerEvmReadoutRecord
int m_totalBxInEvent
total Bx&#39;s in the event, obtained from GTFE block
const cms_uint16_t recordLength1() const
get/set record length for alternative 1
Definition: L1GtfeWord.h:71
const L1GtFdlWord gtFdlWord(int bxInEvent) const
get / set FDL word (record) in the GT readout record
cms_uint16_t m_activeBoardsMaskGt
mask for active boards
const edm::InputTag m_evmGtInputTag
int m_bstLengthBytes
length of BST record (in bytes)
const L1GtfeExtWord gtfeWord() const
get / set GTFE word (record) in the GT readout record
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:45
const int m_verbosity
verbosity level
#define LogTrace(id)
const cms_uint16_t recordLength() const
get/set record length for alternative 0
Definition: L1GtfeWord.h:82
void packTrailer(unsigned char *, unsigned char *, int)
pack trailer word
int iEvent
Definition: GenABIO.cc:224
void resize(size_t newsize)
Definition: FEDRawData.cc:28
unsigned short cms_uint16_t
Definition: typedefs.h:13
void print(std::ostream &myCout) const override
pretty print the content of a L1GtfeExtWord
void packGTFE(const edm::EventSetup &, unsigned char *, L1GtfeExtWord &, cms_uint16_t activeBoardsGtValue)
const unsigned int getSize() const
get the size of the TCS block in GT EVM record (in multiple of 8 bits)
Definition: L1TcsWord.h:197
const std::vector< L1GtBoard > & gtBoardMaps() const
get / set / print the L1 GT board map
Definition: L1GtBoardMaps.h:43
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:151
void print(std::ostream &myCout) const
pretty print the content of a L1TcsWord
Definition: L1TcsWord.cc:274
void packTCS(const edm::EventSetup &evSetup, unsigned char *ptrGt, L1TcsWord &tcsBlock)
pack the TCS block
const unsigned int getSize() const
get the size of the FDL block in GT DAQ record (in multiple of 8 bits)
Definition: L1GtFdlWord.h:271
bool isValid() const
Definition: HandleBase.h:70
const L1TcsWord tcsWord() const
get / set TCS word (record) in the GT readout record
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:24
void packFDL(const edm::EventSetup &, unsigned char *, L1GtFdlWord &)
pack FDL blocks for various bunch crosses
const unsigned int bstLengthBytes() const
get the size of the BST block
Definition: L1GtfeExtWord.h:65
void print(std::ostream &myCout) const
pretty print the content of a L1GtFdlWord
Definition: L1GtFdlWord.cc:595
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 activeBoards() const
get/set boards contributing to EVM respectively DAQ record
Definition: L1GtfeWord.h:119
Log< level::Warning, false > LogWarning
const edm::ESGetToken< L1GtBoardMaps, L1GtBoardMapsRcd > m_l1GtBMToken
EventSetup Token for L1GtBoardMaps.
def move(src, dest)
Definition: eostools.py:511
const edm::EDGetTokenT< L1GlobalTriggerEvmReadoutRecord > m_evmGtInputToken
input tag for GT EVM record
#define LogDebug(id)

Member Data Documentation

◆ m_activeBoardsMaskGt

cms_uint16_t L1GTEvmDigiToRaw::m_activeBoardsMaskGt
private

mask for active boards

Definition at line 86 of file L1GTEvmDigiToRaw.h.

Referenced by L1GTEvmDigiToRaw(), and produce().

◆ m_bstLengthBytes

int L1GTEvmDigiToRaw::m_bstLengthBytes
private

length of BST record (in bytes)

Definition at line 100 of file L1GTEvmDigiToRaw.h.

Referenced by packGTFE(), and produce().

◆ m_evmGtFedId

int L1GTEvmDigiToRaw::m_evmGtFedId
private

FED Id for GT EVM record default value defined in DataFormats/FEDRawData/src/FEDNumbering.cc

Definition at line 76 of file L1GTEvmDigiToRaw.h.

Referenced by L1GTEvmDigiToRaw(), packHeader(), and produce().

◆ m_evmGtInputTag

const edm::InputTag L1GTEvmDigiToRaw::m_evmGtInputTag
private

Definition at line 80 of file L1GTEvmDigiToRaw.h.

Referenced by L1GTEvmDigiToRaw(), and produce().

◆ m_evmGtInputToken

const edm::EDGetTokenT<L1GlobalTriggerEvmReadoutRecord> L1GTEvmDigiToRaw::m_evmGtInputToken
private

input tag for GT EVM record

Definition at line 79 of file L1GTEvmDigiToRaw.h.

Referenced by produce().

◆ m_isDebugEnabled

const bool L1GTEvmDigiToRaw::m_isDebugEnabled
private

Definition at line 105 of file L1GTEvmDigiToRaw.h.

Referenced by packFDL(), packGTFE(), packHeader(), packTCS(), and produce().

◆ m_l1GtBMToken

const edm::ESGetToken<L1GtBoardMaps, L1GtBoardMapsRcd> L1GTEvmDigiToRaw::m_l1GtBMToken
private

EventSetup Token for L1GtBoardMaps.

Definition at line 83 of file L1GTEvmDigiToRaw.h.

Referenced by produce().

◆ m_maxBxInEvent

int L1GTEvmDigiToRaw::m_maxBxInEvent
private

max Bx's in the event, computed after m_totalBxInEvent is obtained from GTFE block assume symmetrical number of BX around L1Accept

Definition at line 97 of file L1GTEvmDigiToRaw.h.

Referenced by produce().

◆ m_minBxInEvent

int L1GTEvmDigiToRaw::m_minBxInEvent
private

min Bx's in the event, computed after m_totalBxInEvent is obtained from GTFE block assume symmetrical number of BX around L1Accept

Definition at line 93 of file L1GTEvmDigiToRaw.h.

Referenced by produce().

◆ m_totalBxInEvent

int L1GTEvmDigiToRaw::m_totalBxInEvent
private

total Bx's in the event, obtained from GTFE block

Definition at line 89 of file L1GTEvmDigiToRaw.h.

Referenced by produce().

◆ m_verbosity

const int L1GTEvmDigiToRaw::m_verbosity
private

verbosity level

Definition at line 104 of file L1GTEvmDigiToRaw.h.

Referenced by packFDL(), packGTFE(), packHeader(), packTCS(), and produce().