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
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 

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
 
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<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 

Detailed Description

Description: generate raw data from digis.

Implementation: <TODO: enter implementation details>

Author
: Vasile Mihai Ghete - HEPHY Vienna

Definition at line 42 of file L1GTEvmDigiToRaw.h.

Constructor & Destructor Documentation

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

constructor(s)

Definition at line 55 of file L1GTEvmDigiToRaw.cc.

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

55  :
56  m_evmGtFedId(pSet.getUntrackedParameter<int>("EvmGtFedId",
58  m_evmGtInputToken(consumes<L1GlobalTriggerEvmReadoutRecord>(pSet.getParameter<edm::InputTag>("EvmGtInputTag"))),
59  m_evmGtInputTag(pSet.getParameter<edm::InputTag>("EvmGtInputTag")),
60  m_activeBoardsMaskGt(pSet.getParameter<unsigned int>("ActiveBoardsMask")),
63  m_verbosity(pSet.getUntrackedParameter<int> ("Verbosity", 0)),
65 
66 
67 
68 {
69 
70  LogDebug("L1GTEvmDigiToRaw") << "\nMask for active boards (hex format): "
71  << std::hex << std::setw(sizeof(m_activeBoardsMaskGt)*2)
72  << std::setfill('0') << m_activeBoardsMaskGt << std::dec
73  << std::setfill(' ') << "\nInput tag for EVM GT record: "
74  << m_evmGtInputTag << "\nFED Id for EVM GT record: "
75  << m_evmGtFedId << " \n" << std::endl;
76 
77  //
78  produces<FEDRawDataCollection>();
79 
80 }
#define LogDebug(id)
T getParameter(std::string const &) const
bool isDebugEnabled()
T getUntrackedParameter(std::string const &, T const &) const
const bool m_isDebugEnabled
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
const edm::EDGetTokenT< L1GlobalTriggerEvmReadoutRecord > m_evmGtInputToken
input tag for GT EVM record

Member Function Documentation

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

pack FDL blocks for various bunch crosses

Definition at line 616 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().

620 {
621 
622  if (m_verbosity && m_isDebugEnabled) {
623  LogDebug("L1GTEvmDigiToRaw") << "\nPacking FDL \n" << std::endl;
624  }
625 
627 
628  // initialize the required number of word64
629  int nrWord64 = fdlBlock.getSize()/uLength;
630  std::vector<cms_uint64_t> tmpWord64;
631  tmpWord64.resize(nrWord64);
632 
633  for (int iWord = 0; iWord < nrWord64; ++iWord) {
634  tmpWord64[iWord] = 0x0000000000000000ULL;
635  }
636 
637  // fill the values in the words
638  for (int iWord = 0; iWord < nrWord64; ++iWord) {
639 
640  fdlBlock.setBoardIdWord64(tmpWord64[iWord], iWord);
641  fdlBlock.setBxInEventWord64(tmpWord64[iWord], iWord);
642  fdlBlock.setBxNrWord64(tmpWord64[iWord], iWord);
643  fdlBlock.setEventNrWord64(tmpWord64[iWord], iWord);
644 
645  fdlBlock.setGtTechnicalTriggerWordWord64(tmpWord64[iWord], iWord);
646 
647  fdlBlock.setGtDecisionWordAWord64(tmpWord64[iWord], iWord);
648  fdlBlock.setGtDecisionWordBWord64(tmpWord64[iWord], iWord);
649 
650  fdlBlock.setGtDecisionWordExtendedWord64(tmpWord64[iWord], iWord);
651 
652  fdlBlock.setPhysicsDeclaredWord64(tmpWord64[iWord], iWord);
653  fdlBlock.setGtPrescaleFactorIndexTechWord64(tmpWord64[iWord], iWord);
654  fdlBlock.setGtPrescaleFactorIndexAlgoWord64(tmpWord64[iWord], iWord);
655  fdlBlock.setNoAlgoWord64(tmpWord64[iWord], iWord);
656  fdlBlock.setFinalORWord64(tmpWord64[iWord], iWord);
657 
658  fdlBlock.setOrbitNrWord64(tmpWord64[iWord], iWord);
659  fdlBlock.setLumiSegmentNrWord64(tmpWord64[iWord], iWord);
660  fdlBlock.setLocalBxNrWord64(tmpWord64[iWord], iWord);
661 
662  }
663 
664  // put the words in the FED record
665 
666  cms_uint64_t* pw =
667  reinterpret_cast<cms_uint64_t*>(const_cast<unsigned char*>(ptrGt));
668 
669  for (int iWord = 0; iWord < nrWord64; ++iWord) {
670 
671  *pw++ = tmpWord64[iWord];
672 
673  if (m_verbosity && m_isDebugEnabled) {
674  LogTrace("L1GTEvmDigiToRaw")
675  << std::setw(4) << iWord << " "
676  << std::hex << std::setfill('0')
677  << std::setw(16) << tmpWord64[iWord]
678  << std::dec << std::setfill(' ')
679  << std::endl;
680  }
681  }
682 
683 }
#define LogDebug(id)
const bool m_isDebugEnabled
void setNoAlgoWord64(cms_uint64_t &word64, const int iWord)
Definition: L1GtFdlWord.cc:642
void setGtDecisionWordBWord64(cms_uint64_t &word64, const int iWord)
Definition: L1GtFdlWord.cc:471
static const int UnitLength
one unit in the word is UnitLength bits
void setBoardIdWord64(cms_uint64_t &word64, const int iWord)
Definition: L1GtFdlWord.cc:196
void setLumiSegmentNrWord64(cms_uint64_t &word64, const int iWord)
Definition: L1GtFdlWord.cc:700
const int m_verbosity
verbosity level
const unsigned int getSize() const
get the size of the FDL block in GT DAQ record (in multiple of 8 bits)
Definition: L1GtFdlWord.h:392
void setOrbitNrWord64(cms_uint64_t &word64, const int iWord)
Definition: L1GtFdlWord.cc:682
void setGtTechnicalTriggerWordWord64(cms_uint64_t &word64, const int iWord)
Definition: L1GtFdlWord.cc:311
void setGtPrescaleFactorIndexTechWord64(cms_uint64_t &word64, const int iWord)
Definition: L1GtFdlWord.cc:603
void setBxInEventWord64(cms_uint64_t &word64, const int iWord)
Definition: L1GtFdlWord.cc:217
void setPhysicsDeclaredWord64(cms_uint64_t &word64, const int iWord)
Definition: L1GtFdlWord.cc:584
void setEventNrWord64(cms_uint64_t &word64, const int iWord)
Definition: L1GtFdlWord.cc:258
void setBxNrWord64(cms_uint64_t &word64, const int iWord)
Definition: L1GtFdlWord.cc:239
#define LogTrace(id)
void setGtDecisionWordExtendedWord64(cms_uint64_t &word64, const int iWord)
Definition: L1GtFdlWord.cc:545
void setLocalBxNrWord64(cms_uint64_t &word64, const int iWord)
Definition: L1GtFdlWord.cc:719
void setGtDecisionWordAWord64(cms_uint64_t &word64, const int iWord)
Definition: L1GtFdlWord.cc:435
void setFinalORWord64(cms_uint64_t &word64, const int iWord)
Definition: L1GtFdlWord.cc:664
unsigned long long cms_uint64_t
Definition: typedefs.h:17
void setGtPrescaleFactorIndexAlgoWord64(cms_uint64_t &word64, const int iWord)
Definition: L1GtFdlWord.cc:623
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 489 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().

494 {
495 
496  if (m_verbosity && m_isDebugEnabled) {
497  LogDebug("L1GTEvmDigiToRaw") << "\nPacking GTFE \n" << std::endl;
498  }
499 
501 
502  // initialize the required number of word64
503  int nrWord64 = gtfeBlock.getSize()/uLength;
504  std::vector<cms_uint64_t> tmpWord64;
505  tmpWord64.resize(nrWord64);
506 
507  for (int iWord = 0; iWord < nrWord64; ++iWord) {
508  tmpWord64[iWord] = 0x0000000000000000ULL;
509  }
510 
511  // fill the values in the words
512  for (int iWord = 0; iWord < nrWord64; ++iWord) {
513 
514  gtfeBlock.setBoardIdWord64(tmpWord64[iWord], iWord);
515  gtfeBlock.setRecordLength1Word64(tmpWord64[iWord], iWord);
516  gtfeBlock.setRecordLengthWord64(tmpWord64[iWord], iWord);
517  gtfeBlock.setBxNrWord64(tmpWord64[iWord], iWord);
518  gtfeBlock.setSetupVersionWord64(tmpWord64[iWord], iWord);
519  gtfeBlock.setActiveBoardsWord64(tmpWord64[iWord], iWord, activeBoardsGtValue);
520  gtfeBlock.setAltNrBxBoardWord64(tmpWord64[iWord], iWord);
521  gtfeBlock.setTotalTriggerNrWord64(tmpWord64[iWord], iWord);
522 
523  for (int iBst = 0; iBst < m_bstLengthBytes; ++iBst) {
524  gtfeBlock.setBstWord64(tmpWord64[iWord], iBst, iWord);
525  }
526 
527  }
528 
529  // put the words in the FED record
530 
531  cms_uint64_t* pw =
532  reinterpret_cast<cms_uint64_t*>(const_cast<unsigned char*>(ptrGt));
533 
534  for (int iWord = 0; iWord < nrWord64; ++iWord) {
535 
536  *pw++ = tmpWord64[iWord];
537 
538  if (m_verbosity && m_isDebugEnabled) {
539  LogTrace("L1GTEvmDigiToRaw")
540  << std::setw(4) << iWord << " "
541  << std::hex << std::setfill('0')
542  << std::setw(16) << tmpWord64[iWord]
543  << std::dec << std::setfill(' ')
544  << std::endl;
545  }
546  }
547 
548 
549 }
#define LogDebug(id)
const bool m_isDebugEnabled
void setRecordLength1Word64(cms_uint64_t &word64, int iWord)
Definition: L1GtfeWord.cc:138
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:231
void setSetupVersionWord64(cms_uint64_t &word64, int iWord)
Definition: L1GtfeWord.cc:194
void setBstWord64(cms_uint64_t &word64, int iB, const int iWord)
const unsigned int getSize() const
get the size of the GTFE block in GT EVM record (in multiple of 8 bits)
void setBoardIdWord64(cms_uint64_t &word64, int iWord)
Definition: L1GtfeWord.cc:120
#define LogTrace(id)
void setAltNrBxBoardWord64(cms_uint64_t &word64, int iWord)
Definition: L1GtfeWord.cc:263
void setBxNrWord64(cms_uint64_t &word64, int iWord)
Definition: L1GtfeWord.cc:176
unsigned long long cms_uint64_t
Definition: typedefs.h:17
void setTotalTriggerNrWord64(cms_uint64_t &word64, int iWord)
Definition: L1GtfeWord.cc:293
void setRecordLengthWord64(cms_uint64_t &word64, int iWord)
Definition: L1GtfeWord.cc:157
void L1GTEvmDigiToRaw::packHeader ( unsigned char *  ptrGt,
edm::Event iEvent 
)
private

block packers -------——

pack header

Definition at line 438 of file L1GTEvmDigiToRaw.cc.

References edm::EventBase::bunchCrossing(), TauDecayModes::dec, edm::EventID::event(), edm::EventBase::id(), LogDebug, m_evmGtFedId, m_isDebugEnabled, m_verbosity, and FEDHeader::set().

Referenced by produce().

439 {
440  // TODO FIXME where from to get all numbers?
441 
442  // Event Trigger type identifier
443  int triggerTypeVal = 0;
444 
445  // Level-1 event number generated by the TTC system
446  int lvl1IdVal = iEvent.id().event();
447 
448  // The bunch crossing number
449  int bxCross = iEvent.bunchCrossing();
450  cms_uint16_t bxCrossHw = 0;
451  if ((bxCross & 0xFFF) == bxCross) {
452  bxCrossHw = static_cast<cms_uint16_t> (bxCross);
453  }
454  else {
455  bxCrossHw = 0; // Bx number too large, set to 0!
456  if (m_verbosity && m_isDebugEnabled) {
457  LogDebug("L1GTEvmDigiToRaw")
458  << "\nBunch cross number [hex] = "
459  << std::hex << bxCross
460  << "\n larger than 12 bits. Set to 0! \n"
461  << std::dec
462  << std::endl;
463  }
464  }
465  int bxIdVal = bxCrossHw;
466 
467  // Identifier of the FED
468  int sourceIdVal = m_evmGtFedId;
469 
470  // Version identifier of the FED data format
471  int versionVal = 0;
472 
473  // 0 -> the current header word is the last one.
474  // 1-> other header words can follow
475  // (always 1 for ECAL)
476  bool moreHeadersVal = false;
477 
478 
479  FEDHeader gtFEDHeader(ptrGt);
480 
481  gtFEDHeader.set(ptrGt,
482  triggerTypeVal, lvl1IdVal, bxIdVal, sourceIdVal, versionVal,
483  moreHeadersVal);
484 
485 
486 }
#define LogDebug(id)
EventNumber_t event() const
Definition: EventID.h:41
const bool m_isDebugEnabled
int bunchCrossing() const
Definition: EventBase.h:64
const int m_verbosity
verbosity level
unsigned short cms_uint16_t
Definition: typedefs.h:13
edm::EventID id() const
Definition: EventBase.h:59
void L1GTEvmDigiToRaw::packTCS ( const edm::EventSetup evSetup,
unsigned char *  ptrGt,
L1TcsWord tcsBlock 
)
private

pack the TCS block

Definition at line 552 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().

556 {
557 
558  if (m_verbosity && m_isDebugEnabled) {
559  LogDebug("L1GTEvmDigiToRaw") << "\nPacking TCS \n" << std::endl;
560  }
561 
563 
564  // initialize the required number of word64
565  int nrWord64 = tcsBlock.getSize()/uLength;
566  std::vector<cms_uint64_t> tmpWord64;
567  tmpWord64.resize(nrWord64);
568 
569  for (int iWord = 0; iWord < nrWord64; ++iWord) {
570  tmpWord64[iWord] = 0x0000000000000000ULL;
571  }
572 
573  // fill the values in the words
574  for (int iWord = 0; iWord < nrWord64; ++iWord) {
575 
576  tcsBlock.setBoardIdWord64(tmpWord64[iWord], iWord);
577  tcsBlock.setBxNrWord64(tmpWord64[iWord], iWord);
578  tcsBlock.setDaqNrWord64(tmpWord64[iWord], iWord);
579  tcsBlock.setTriggerTypeWord64(tmpWord64[iWord], iWord);
580  tcsBlock.setStatusWord64(tmpWord64[iWord], iWord);
581  tcsBlock.setLuminositySegmentNrWord64(tmpWord64[iWord], iWord);
582 
583  tcsBlock.setPartRunNrWord64(tmpWord64[iWord], iWord);
584  tcsBlock.setAssignedPartitionsWord64(tmpWord64[iWord], iWord);
585 
586  tcsBlock.setPartTrigNrWord64(tmpWord64[iWord], iWord);
587  tcsBlock.setEventNrWord64(tmpWord64[iWord], iWord);
588 
589  tcsBlock.setOrbitNrWord64(tmpWord64[iWord], iWord);
590 
591  }
592 
593  // put the words in the FED record
594 
595  cms_uint64_t* pw =
596  reinterpret_cast<cms_uint64_t*>(const_cast<unsigned char*>(ptrGt));
597 
598  for (int iWord = 0; iWord < nrWord64; ++iWord) {
599 
600  *pw++ = tmpWord64[iWord];
601 
602  if (m_verbosity && m_isDebugEnabled) {
603  LogTrace("L1GTEvmDigiToRaw")
604  << std::setw(4) << iWord << " "
605  << std::hex << std::setfill('0')
606  << std::setw(16) << tmpWord64[iWord]
607  << std::dec << std::setfill(' ')
608  << std::endl;
609  }
610  }
611 
612 
613 }
#define LogDebug(id)
const bool m_isDebugEnabled
void setBoardIdWord64(cms_uint64_t &word64, int iWord)
Definition: L1TcsWord.cc:156
void setBxNrWord64(cms_uint64_t &word64, int iWord)
Definition: L1TcsWord.cc:176
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:305
void setOrbitNrWord64(cms_uint64_t &word64, int iWord)
Definition: L1TcsWord.cc:372
void setTriggerTypeWord64(cms_uint64_t &word64, int iWord)
Definition: L1TcsWord.cc:217
void setLuminositySegmentNrWord64(cms_uint64_t &word64, int iWord)
Definition: L1TcsWord.cc:260
#define LogTrace(id)
const unsigned int getSize() const
get the size of the TCS block in GT EVM record (in multiple of 8 bits)
Definition: L1TcsWord.h:285
void setEventNrWord64(cms_uint64_t &word64, int iWord)
Definition: L1TcsWord.cc:350
void setPartRunNrWord64(cms_uint64_t &word64, int iWord)
Definition: L1TcsWord.cc:282
void setPartTrigNrWord64(cms_uint64_t &word64, int iWord)
Definition: L1TcsWord.cc:328
unsigned long long cms_uint64_t
Definition: typedefs.h:17
void setDaqNrWord64(cms_uint64_t &word64, int iWord)
Definition: L1TcsWord.cc:197
void setStatusWord64(cms_uint64_t &word64, int iWord)
Definition: L1TcsWord.cc:238
void L1GTEvmDigiToRaw::packTrailer ( unsigned char *  ptrGt,
unsigned char *  ptrGtBegin,
int  dataSize 
)
private

pack trailer word

Definition at line 687 of file L1GTEvmDigiToRaw.cc.

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

Referenced by produce().

689 {
690 
691  // TODO FIXME where from to get all numbers?
692 
693  // The length of the event fragment counted in 64-bit words including header and trailer
694  int lengthVal = dataSize/8;
695 
696  // Cyclic Redundancy Code of the event fragment including header and trailer
697  int crcVal = evf::compute_crc(ptrGtBegin, dataSize);
698 
699  // Event fragment status information
700  int evtStatusVal = 0;
701 
702  // Current value of the Trigger Throttling System bits.
703  int ttsBitsVal = 0;
704 
705  // 0 -> the current trailer word is the last one.
706  // 1-> other trailer words can follow
707  // (always 0 for ECAL)
708  bool moreTrailersVal = false;
709 
710  FEDTrailer gtFEDTrailer(ptrGt);
711  gtFEDTrailer.set(ptrGt,
712  lengthVal, crcVal, evtStatusVal, ttsBitsVal,
713  moreTrailersVal);
714 
715 }
unsigned short compute_crc(unsigned char *buffer, unsigned int bufSize)
Definition: CRC16.h:46
void L1GTEvmDigiToRaw::produce ( edm::Event iEvent,
const edm::EventSetup evSetup 
)
overrideprivate

loop over events

Definition at line 85 of file L1GTEvmDigiToRaw.cc.

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

Referenced by JSONExport.JsonExport::export(), HTMLExport.HTMLExport::export(), and HTMLExport.HTMLExportStatic::export().

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

Member Data Documentation

cms_uint16_t L1GTEvmDigiToRaw::m_activeBoardsMaskGt
private

mask for active boards

Definition at line 87 of file L1GTEvmDigiToRaw.h.

Referenced by L1GTEvmDigiToRaw(), and produce().

int L1GTEvmDigiToRaw::m_bstLengthBytes
private

length of BST record (in bytes)

Definition at line 101 of file L1GTEvmDigiToRaw.h.

Referenced by packGTFE(), and produce().

int L1GTEvmDigiToRaw::m_evmGtFedId
private

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

Definition at line 80 of file L1GTEvmDigiToRaw.h.

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

const edm::InputTag L1GTEvmDigiToRaw::m_evmGtInputTag
private

Definition at line 84 of file L1GTEvmDigiToRaw.h.

Referenced by L1GTEvmDigiToRaw(), and produce().

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

input tag for GT EVM record

Definition at line 83 of file L1GTEvmDigiToRaw.h.

Referenced by produce().

const bool L1GTEvmDigiToRaw::m_isDebugEnabled
private

Definition at line 107 of file L1GTEvmDigiToRaw.h.

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

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 98 of file L1GTEvmDigiToRaw.h.

Referenced by produce().

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 94 of file L1GTEvmDigiToRaw.h.

Referenced by produce().

int L1GTEvmDigiToRaw::m_totalBxInEvent
private

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

Definition at line 90 of file L1GTEvmDigiToRaw.h.

Referenced by produce().

const int L1GTEvmDigiToRaw::m_verbosity
private

verbosity level

Definition at line 106 of file L1GTEvmDigiToRaw.h.

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