CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
L1GTEvmDigiToRaw Class Reference

#include <L1GTEvmDigiToRaw.h>

Inheritance diagram for L1GTEvmDigiToRaw:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 L1GTEvmDigiToRaw (const edm::ParameterSet &)
 constructor(s) More...
 
virtual ~L1GTEvmDigiToRaw ()
 destructor More...
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Member Functions

virtual void beginJob ()
 beginning of job stuff More...
 
virtual void endJob ()
 end of job stuff More...
 
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...
 
virtual void produce (edm::Event &, const edm::EventSetup &)
 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
 
edm::InputTag m_evmGtInputTag
 input tag for GT EVM record More...
 
bool m_isDebugEnabled
 
int m_maxBxInEvent
 
int m_minBxInEvent
 
int m_totalBxInEvent
 total Bx's in the event, obtained from GTFE block More...
 
int m_verbosity
 verbosity level More...
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Description: generate raw data from digis.

Implementation: <TODO: enter implementation details>

Author
: Vasile Mihai Ghete - HEPHY Vienna

Definition at line 41 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 LogDebug, m_activeBoardsMaskGt, m_evmGtFedId, and m_evmGtInputTag.

55  :
56  m_evmGtFedId(pSet.getUntrackedParameter<int>("EvmGtFedId",
58  m_evmGtInputTag(pSet.getParameter<edm::InputTag>("EvmGtInputTag")),
59  m_activeBoardsMaskGt(pSet.getParameter<unsigned int>("ActiveBoardsMask")),
62  m_verbosity(pSet.getUntrackedParameter<int> ("Verbosity", 0)),
64 
65 
66 
67 {
68 
69  LogDebug("L1GTEvmDigiToRaw") << "\nMask for active boards (hex format): "
70  << std::hex << std::setw(sizeof(m_activeBoardsMaskGt)*2)
71  << std::setfill('0') << m_activeBoardsMaskGt << std::dec
72  << std::setfill(' ') << "\nInput tag for EVM GT record: "
73  << m_evmGtInputTag << "\nFED Id for EVM GT record: "
74  << m_evmGtFedId << " \n" << std::endl;
75 
76  //
77  produces<FEDRawDataCollection>();
78 
79 }
#define LogDebug(id)
T getParameter(std::string const &) const
bool isDebugEnabled()
T getUntrackedParameter(std::string const &, T const &) const
int m_totalBxInEvent
total Bx&#39;s in the event, obtained from GTFE block
cms_uint16_t m_activeBoardsMaskGt
mask for active boards
edm::InputTag m_evmGtInputTag
input tag for GT EVM record
int m_verbosity
verbosity level
L1GTEvmDigiToRaw::~L1GTEvmDigiToRaw ( )
virtual

destructor

Definition at line 82 of file L1GTEvmDigiToRaw.cc.

83 {
84 
85  // empty now
86 
87 }

Member Function Documentation

void L1GTEvmDigiToRaw::beginJob ( void  )
privatevirtual

beginning of job stuff

Reimplemented from edm::EDProducer.

Definition at line 92 of file L1GTEvmDigiToRaw.cc.

93 {
94 
95  // empty now
96 
97 }
void L1GTEvmDigiToRaw::endJob ( void  )
privatevirtual

end of job stuff

Reimplemented from edm::EDProducer.

Definition at line 734 of file L1GTEvmDigiToRaw.cc.

735 {
736 
737  // empty now
738 }
void L1GTEvmDigiToRaw::packFDL ( const edm::EventSetup evSetup,
unsigned char *  ptrGt,
L1GtFdlWord fdlBlock 
)
private

pack FDL blocks for various bunch crosses

Definition at line 632 of file L1GTEvmDigiToRaw.cc.

References 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().

636 {
637 
638  if (m_verbosity && m_isDebugEnabled) {
639  LogDebug("L1GTEvmDigiToRaw") << "\nPacking FDL \n" << std::endl;
640  }
641 
643 
644  // initialize the required number of word64
645  int nrWord64 = fdlBlock.getSize()/uLength;
646  std::vector<cms_uint64_t> tmpWord64;
647  tmpWord64.resize(nrWord64);
648 
649  for (int iWord = 0; iWord < nrWord64; ++iWord) {
650  tmpWord64[iWord] = 0x0000000000000000ULL;
651  }
652 
653  // fill the values in the words
654  for (int iWord = 0; iWord < nrWord64; ++iWord) {
655 
656  fdlBlock.setBoardIdWord64(tmpWord64[iWord], iWord);
657  fdlBlock.setBxInEventWord64(tmpWord64[iWord], iWord);
658  fdlBlock.setBxNrWord64(tmpWord64[iWord], iWord);
659  fdlBlock.setEventNrWord64(tmpWord64[iWord], iWord);
660 
661  fdlBlock.setGtTechnicalTriggerWordWord64(tmpWord64[iWord], iWord);
662 
663  fdlBlock.setGtDecisionWordAWord64(tmpWord64[iWord], iWord);
664  fdlBlock.setGtDecisionWordBWord64(tmpWord64[iWord], iWord);
665 
666  fdlBlock.setGtDecisionWordExtendedWord64(tmpWord64[iWord], iWord);
667 
668  fdlBlock.setPhysicsDeclaredWord64(tmpWord64[iWord], iWord);
669  fdlBlock.setGtPrescaleFactorIndexTechWord64(tmpWord64[iWord], iWord);
670  fdlBlock.setGtPrescaleFactorIndexAlgoWord64(tmpWord64[iWord], iWord);
671  fdlBlock.setNoAlgoWord64(tmpWord64[iWord], iWord);
672  fdlBlock.setFinalORWord64(tmpWord64[iWord], iWord);
673 
674  fdlBlock.setOrbitNrWord64(tmpWord64[iWord], iWord);
675  fdlBlock.setLumiSegmentNrWord64(tmpWord64[iWord], iWord);
676  fdlBlock.setLocalBxNrWord64(tmpWord64[iWord], iWord);
677 
678  }
679 
680  // put the words in the FED record
681 
682  cms_uint64_t* pw =
683  reinterpret_cast<cms_uint64_t*>(const_cast<unsigned char*>(ptrGt));
684 
685  for (int iWord = 0; iWord < nrWord64; ++iWord) {
686 
687  *pw++ = tmpWord64[iWord];
688 
689  if (m_verbosity && m_isDebugEnabled) {
690  LogTrace("L1GTEvmDigiToRaw")
691  << std::setw(4) << iWord << " "
692  << std::hex << std::setfill('0')
693  << std::setw(16) << tmpWord64[iWord]
694  << std::dec << std::setfill(' ')
695  << std::endl;
696  }
697  }
698 
699 }
#define LogDebug(id)
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 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
int m_verbosity
verbosity level
#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 505 of file L1GTEvmDigiToRaw.cc.

References 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().

510 {
511 
512  if (m_verbosity && m_isDebugEnabled) {
513  LogDebug("L1GTEvmDigiToRaw") << "\nPacking GTFE \n" << std::endl;
514  }
515 
517 
518  // initialize the required number of word64
519  int nrWord64 = gtfeBlock.getSize()/uLength;
520  std::vector<cms_uint64_t> tmpWord64;
521  tmpWord64.resize(nrWord64);
522 
523  for (int iWord = 0; iWord < nrWord64; ++iWord) {
524  tmpWord64[iWord] = 0x0000000000000000ULL;
525  }
526 
527  // fill the values in the words
528  for (int iWord = 0; iWord < nrWord64; ++iWord) {
529 
530  gtfeBlock.setBoardIdWord64(tmpWord64[iWord], iWord);
531  gtfeBlock.setRecordLength1Word64(tmpWord64[iWord], iWord);
532  gtfeBlock.setRecordLengthWord64(tmpWord64[iWord], iWord);
533  gtfeBlock.setBxNrWord64(tmpWord64[iWord], iWord);
534  gtfeBlock.setSetupVersionWord64(tmpWord64[iWord], iWord);
535  gtfeBlock.setActiveBoardsWord64(tmpWord64[iWord], iWord, activeBoardsGtValue);
536  gtfeBlock.setAltNrBxBoardWord64(tmpWord64[iWord], iWord);
537  gtfeBlock.setTotalTriggerNrWord64(tmpWord64[iWord], iWord);
538 
539  for (int iBst = 0; iBst < m_bstLengthBytes; ++iBst) {
540  gtfeBlock.setBstWord64(tmpWord64[iWord], iBst, iWord);
541  }
542 
543  }
544 
545  // put the words in the FED record
546 
547  cms_uint64_t* pw =
548  reinterpret_cast<cms_uint64_t*>(const_cast<unsigned char*>(ptrGt));
549 
550  for (int iWord = 0; iWord < nrWord64; ++iWord) {
551 
552  *pw++ = tmpWord64[iWord];
553 
554  if (m_verbosity && m_isDebugEnabled) {
555  LogTrace("L1GTEvmDigiToRaw")
556  << std::setw(4) << iWord << " "
557  << std::hex << std::setfill('0')
558  << std::setw(16) << tmpWord64[iWord]
559  << std::dec << std::setfill(' ')
560  << std::endl;
561  }
562  }
563 
564 
565 }
#define LogDebug(id)
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)
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
int m_verbosity
verbosity level
#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 454 of file L1GTEvmDigiToRaw.cc.

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

Referenced by produce().

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

pack the TCS block

Definition at line 568 of file L1GTEvmDigiToRaw.cc.

References 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().

572 {
573 
574  if (m_verbosity && m_isDebugEnabled) {
575  LogDebug("L1GTEvmDigiToRaw") << "\nPacking TCS \n" << std::endl;
576  }
577 
579 
580  // initialize the required number of word64
581  int nrWord64 = tcsBlock.getSize()/uLength;
582  std::vector<cms_uint64_t> tmpWord64;
583  tmpWord64.resize(nrWord64);
584 
585  for (int iWord = 0; iWord < nrWord64; ++iWord) {
586  tmpWord64[iWord] = 0x0000000000000000ULL;
587  }
588 
589  // fill the values in the words
590  for (int iWord = 0; iWord < nrWord64; ++iWord) {
591 
592  tcsBlock.setBoardIdWord64(tmpWord64[iWord], iWord);
593  tcsBlock.setBxNrWord64(tmpWord64[iWord], iWord);
594  tcsBlock.setDaqNrWord64(tmpWord64[iWord], iWord);
595  tcsBlock.setTriggerTypeWord64(tmpWord64[iWord], iWord);
596  tcsBlock.setStatusWord64(tmpWord64[iWord], iWord);
597  tcsBlock.setLuminositySegmentNrWord64(tmpWord64[iWord], iWord);
598 
599  tcsBlock.setPartRunNrWord64(tmpWord64[iWord], iWord);
600  tcsBlock.setAssignedPartitionsWord64(tmpWord64[iWord], iWord);
601 
602  tcsBlock.setPartTrigNrWord64(tmpWord64[iWord], iWord);
603  tcsBlock.setEventNrWord64(tmpWord64[iWord], iWord);
604 
605  tcsBlock.setOrbitNrWord64(tmpWord64[iWord], iWord);
606 
607  }
608 
609  // put the words in the FED record
610 
611  cms_uint64_t* pw =
612  reinterpret_cast<cms_uint64_t*>(const_cast<unsigned char*>(ptrGt));
613 
614  for (int iWord = 0; iWord < nrWord64; ++iWord) {
615 
616  *pw++ = tmpWord64[iWord];
617 
618  if (m_verbosity && m_isDebugEnabled) {
619  LogTrace("L1GTEvmDigiToRaw")
620  << std::setw(4) << iWord << " "
621  << std::hex << std::setfill('0')
622  << std::setw(16) << tmpWord64[iWord]
623  << std::dec << std::setfill(' ')
624  << std::endl;
625  }
626  }
627 
628 
629 }
#define LogDebug(id)
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
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
int m_verbosity
verbosity level
#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 703 of file L1GTEvmDigiToRaw.cc.

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

Referenced by produce().

705 {
706 
707  // TODO FIXME where from to get all numbers?
708 
709  // The length of the event fragment counted in 64-bit words including header and trailer
710  int lengthVal = dataSize/8;
711 
712  // Cyclic Redundancy Code of the event fragment including header and trailer
713  int crcVal = evf::compute_crc(ptrGtBegin, dataSize);
714 
715  // Event fragment status information
716  int evtStatusVal = 0;
717 
718  // Current value of the Trigger Throttling System bits.
719  int ttsBitsVal = 0;
720 
721  // 0 -> the current trailer word is the last one.
722  // 1-> other trailer words can follow
723  // (always 0 for ECAL)
724  bool moreTrailersVal = false;
725 
726  FEDTrailer gtFEDTrailer(ptrGt);
727  gtFEDTrailer.set(ptrGt,
728  lengthVal, crcVal, evtStatusVal, ttsBitsVal,
729  moreTrailersVal);
730 
731 }
unsigned short compute_crc(unsigned char *buffer, unsigned int bufSize)
Definition: CRC16.h:67
void L1GTEvmDigiToRaw::produce ( edm::Event iEvent,
const edm::EventSetup evSetup 
)
privatevirtual

loop over events

Implements edm::EDProducer.

Definition at line 101 of file L1GTEvmDigiToRaw.cc.

References L1GtfeWord::activeBoards(), L1GtfeWord::altNrBxBoard(), L1GtfeExtWord::bstLengthBytes(), FEDRawData::data(), FDL, edm::EventSetup::get(), edm::Event::getByLabel(), L1GtfeExtWord::getSize(), L1TcsWord::getSize(), L1GtFdlWord::getSize(), GTFE, edm::HandleBase::isValid(), LogDebug, LogTrace, m_activeBoardsMaskGt, m_bstLengthBytes, m_evmGtFedId, m_evmGtInputTag, m_isDebugEnabled, m_maxBxInEvent, m_minBxInEvent, m_totalBxInEvent, m_verbosity, packFDL(), packGTFE(), packHeader(), packTCS(), packTrailer(), L1GtfeExtWord::print(), L1TcsWord::print(), L1GtFdlWord::print(), edm::Event::put(), L1GtfeWord::recordLength(), L1GtfeWord::recordLength1(), FEDRawData::resize(), FEDRawData::size(), TCS, and TIM.

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

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

Member Data Documentation

cms_uint16_t L1GTEvmDigiToRaw::m_activeBoardsMaskGt
private

mask for active boards

Definition at line 94 of file L1GTEvmDigiToRaw.h.

Referenced by L1GTEvmDigiToRaw(), and produce().

int L1GTEvmDigiToRaw::m_bstLengthBytes
private

length of BST record (in bytes)

Definition at line 108 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 88 of file L1GTEvmDigiToRaw.h.

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

edm::InputTag L1GTEvmDigiToRaw::m_evmGtInputTag
private

input tag for GT EVM record

Definition at line 91 of file L1GTEvmDigiToRaw.h.

Referenced by L1GTEvmDigiToRaw(), and produce().

bool L1GTEvmDigiToRaw::m_isDebugEnabled
private

Definition at line 114 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 105 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 101 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 97 of file L1GTEvmDigiToRaw.h.

Referenced by produce().

int L1GTEvmDigiToRaw::m_verbosity
private

verbosity level

Definition at line 113 of file L1GTEvmDigiToRaw.h.

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