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 ()
 
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 ()
 
ProductHolderIndex indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) 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
 
typedef WorkerT< EDProducerWorkerType
 
- 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::EDProducer
CurrentProcessingContext const * currentContext () const
 
- 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

$Date$ $Revision$

Definition at line 43 of file L1GTEvmDigiToRaw.h.

Constructor & Destructor Documentation

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

constructor(s)

Definition at line 57 of file L1GTEvmDigiToRaw.cc.

References LogDebug, m_activeBoardsMaskGt, m_evmGtFedId, and m_evmGtInputTag.

57  :
58  m_evmGtFedId(pSet.getUntrackedParameter<int>("EvmGtFedId",
60  m_evmGtInputTag(pSet.getParameter<edm::InputTag>("EvmGtInputTag")),
61  m_activeBoardsMaskGt(pSet.getParameter<unsigned int>("ActiveBoardsMask")),
64  m_verbosity(pSet.getUntrackedParameter<int> ("Verbosity", 0)),
66 
67 
68 
69 {
70 
71  LogDebug("L1GTEvmDigiToRaw") << "\nMask for active boards (hex format): "
72  << std::hex << std::setw(sizeof(m_activeBoardsMaskGt)*2)
73  << std::setfill('0') << m_activeBoardsMaskGt << std::dec
74  << std::setfill(' ') << "\nInput tag for EVM GT record: "
75  << m_evmGtInputTag << "\nFED Id for EVM GT record: "
76  << m_evmGtFedId << " \n" << std::endl;
77 
78  //
79  produces<FEDRawDataCollection>();
80 
81 }
#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 84 of file L1GTEvmDigiToRaw.cc.

85 {
86 
87  // empty now
88 
89 }

Member Function Documentation

void L1GTEvmDigiToRaw::beginJob ( void  )
privatevirtual

beginning of job stuff

Reimplemented from edm::EDProducer.

Definition at line 94 of file L1GTEvmDigiToRaw.cc.

95 {
96 
97  // empty now
98 
99 }
void L1GTEvmDigiToRaw::endJob ( void  )
privatevirtual

end of job stuff

Reimplemented from edm::EDProducer.

Definition at line 736 of file L1GTEvmDigiToRaw.cc.

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

pack FDL blocks for various bunch crosses

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

638 {
639 
640  if (m_verbosity && m_isDebugEnabled) {
641  LogDebug("L1GTEvmDigiToRaw") << "\nPacking FDL \n" << std::endl;
642  }
643 
645 
646  // initialize the required number of word64
647  int nrWord64 = fdlBlock.getSize()/uLength;
648  std::vector<cms_uint64_t> tmpWord64;
649  tmpWord64.resize(nrWord64);
650 
651  for (int iWord = 0; iWord < nrWord64; ++iWord) {
652  tmpWord64[iWord] = 0x0000000000000000ULL;
653  }
654 
655  // fill the values in the words
656  for (int iWord = 0; iWord < nrWord64; ++iWord) {
657 
658  fdlBlock.setBoardIdWord64(tmpWord64[iWord], iWord);
659  fdlBlock.setBxInEventWord64(tmpWord64[iWord], iWord);
660  fdlBlock.setBxNrWord64(tmpWord64[iWord], iWord);
661  fdlBlock.setEventNrWord64(tmpWord64[iWord], iWord);
662 
663  fdlBlock.setGtTechnicalTriggerWordWord64(tmpWord64[iWord], iWord);
664 
665  fdlBlock.setGtDecisionWordAWord64(tmpWord64[iWord], iWord);
666  fdlBlock.setGtDecisionWordBWord64(tmpWord64[iWord], iWord);
667 
668  fdlBlock.setGtDecisionWordExtendedWord64(tmpWord64[iWord], iWord);
669 
670  fdlBlock.setPhysicsDeclaredWord64(tmpWord64[iWord], iWord);
671  fdlBlock.setGtPrescaleFactorIndexTechWord64(tmpWord64[iWord], iWord);
672  fdlBlock.setGtPrescaleFactorIndexAlgoWord64(tmpWord64[iWord], iWord);
673  fdlBlock.setNoAlgoWord64(tmpWord64[iWord], iWord);
674  fdlBlock.setFinalORWord64(tmpWord64[iWord], iWord);
675 
676  fdlBlock.setOrbitNrWord64(tmpWord64[iWord], iWord);
677  fdlBlock.setLumiSegmentNrWord64(tmpWord64[iWord], iWord);
678  fdlBlock.setLocalBxNrWord64(tmpWord64[iWord], iWord);
679 
680  }
681 
682  // put the words in the FED record
683 
684  cms_uint64_t* pw =
685  reinterpret_cast<cms_uint64_t*>(const_cast<unsigned char*>(ptrGt));
686 
687  for (int iWord = 0; iWord < nrWord64; ++iWord) {
688 
689  *pw++ = tmpWord64[iWord];
690 
691  if (m_verbosity && m_isDebugEnabled) {
692  LogTrace("L1GTEvmDigiToRaw")
693  << std::setw(4) << iWord << " "
694  << std::hex << std::setfill('0')
695  << std::setw(16) << tmpWord64[iWord]
696  << std::dec << std::setfill(' ')
697  << std::endl;
698  }
699  }
700 
701 }
#define LogDebug(id)
void setNoAlgoWord64(cms_uint64_t &word64, const int iWord)
Definition: L1GtFdlWord.cc:644
void setGtDecisionWordBWord64(cms_uint64_t &word64, const int iWord)
Definition: L1GtFdlWord.cc:473
static const int UnitLength
one unit in the word is UnitLength bits
void setBoardIdWord64(cms_uint64_t &word64, const int iWord)
Definition: L1GtFdlWord.cc:198
void setLumiSegmentNrWord64(cms_uint64_t &word64, const int iWord)
Definition: L1GtFdlWord.cc:702
const unsigned int getSize() const
get the size of the FDL block in GT DAQ record (in multiple of 8 bits)
Definition: L1GtFdlWord.h:394
void setOrbitNrWord64(cms_uint64_t &word64, const int iWord)
Definition: L1GtFdlWord.cc:684
void setGtTechnicalTriggerWordWord64(cms_uint64_t &word64, const int iWord)
Definition: L1GtFdlWord.cc:313
void setGtPrescaleFactorIndexTechWord64(cms_uint64_t &word64, const int iWord)
Definition: L1GtFdlWord.cc:605
void setBxInEventWord64(cms_uint64_t &word64, const int iWord)
Definition: L1GtFdlWord.cc:219
void setPhysicsDeclaredWord64(cms_uint64_t &word64, const int iWord)
Definition: L1GtFdlWord.cc:586
void setEventNrWord64(cms_uint64_t &word64, const int iWord)
Definition: L1GtFdlWord.cc:260
void setBxNrWord64(cms_uint64_t &word64, const int iWord)
Definition: L1GtFdlWord.cc:241
int m_verbosity
verbosity level
#define LogTrace(id)
void setGtDecisionWordExtendedWord64(cms_uint64_t &word64, const int iWord)
Definition: L1GtFdlWord.cc:547
void setLocalBxNrWord64(cms_uint64_t &word64, const int iWord)
Definition: L1GtFdlWord.cc:721
void setGtDecisionWordAWord64(cms_uint64_t &word64, const int iWord)
Definition: L1GtFdlWord.cc:437
void setFinalORWord64(cms_uint64_t &word64, const int iWord)
Definition: L1GtFdlWord.cc:666
unsigned long long cms_uint64_t
Definition: typedefs.h:17
void setGtPrescaleFactorIndexAlgoWord64(cms_uint64_t &word64, const int iWord)
Definition: L1GtFdlWord.cc:625
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 507 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().

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

block packers -------——

pack header

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

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

574 {
575 
576  if (m_verbosity && m_isDebugEnabled) {
577  LogDebug("L1GTEvmDigiToRaw") << "\nPacking TCS \n" << std::endl;
578  }
579 
581 
582  // initialize the required number of word64
583  int nrWord64 = tcsBlock.getSize()/uLength;
584  std::vector<cms_uint64_t> tmpWord64;
585  tmpWord64.resize(nrWord64);
586 
587  for (int iWord = 0; iWord < nrWord64; ++iWord) {
588  tmpWord64[iWord] = 0x0000000000000000ULL;
589  }
590 
591  // fill the values in the words
592  for (int iWord = 0; iWord < nrWord64; ++iWord) {
593 
594  tcsBlock.setBoardIdWord64(tmpWord64[iWord], iWord);
595  tcsBlock.setBxNrWord64(tmpWord64[iWord], iWord);
596  tcsBlock.setDaqNrWord64(tmpWord64[iWord], iWord);
597  tcsBlock.setTriggerTypeWord64(tmpWord64[iWord], iWord);
598  tcsBlock.setStatusWord64(tmpWord64[iWord], iWord);
599  tcsBlock.setLuminositySegmentNrWord64(tmpWord64[iWord], iWord);
600 
601  tcsBlock.setPartRunNrWord64(tmpWord64[iWord], iWord);
602  tcsBlock.setAssignedPartitionsWord64(tmpWord64[iWord], iWord);
603 
604  tcsBlock.setPartTrigNrWord64(tmpWord64[iWord], iWord);
605  tcsBlock.setEventNrWord64(tmpWord64[iWord], iWord);
606 
607  tcsBlock.setOrbitNrWord64(tmpWord64[iWord], iWord);
608 
609  }
610 
611  // put the words in the FED record
612 
613  cms_uint64_t* pw =
614  reinterpret_cast<cms_uint64_t*>(const_cast<unsigned char*>(ptrGt));
615 
616  for (int iWord = 0; iWord < nrWord64; ++iWord) {
617 
618  *pw++ = tmpWord64[iWord];
619 
620  if (m_verbosity && m_isDebugEnabled) {
621  LogTrace("L1GTEvmDigiToRaw")
622  << std::setw(4) << iWord << " "
623  << std::hex << std::setfill('0')
624  << std::setw(16) << tmpWord64[iWord]
625  << std::dec << std::setfill(' ')
626  << std::endl;
627  }
628  }
629 
630 
631 }
#define LogDebug(id)
void setBoardIdWord64(cms_uint64_t &word64, int iWord)
Definition: L1TcsWord.cc:158
void setBxNrWord64(cms_uint64_t &word64, int iWord)
Definition: L1TcsWord.cc:178
static const int UnitLength
one unit in the word is UnitLength bits
void setAssignedPartitionsWord64(cms_uint64_t &word64, int iWord)
Definition: L1TcsWord.cc:307
void setOrbitNrWord64(cms_uint64_t &word64, int iWord)
Definition: L1TcsWord.cc:374
void setTriggerTypeWord64(cms_uint64_t &word64, int iWord)
Definition: L1TcsWord.cc:219
void setLuminositySegmentNrWord64(cms_uint64_t &word64, int iWord)
Definition: L1TcsWord.cc:262
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:287
void setEventNrWord64(cms_uint64_t &word64, int iWord)
Definition: L1TcsWord.cc:352
void setPartRunNrWord64(cms_uint64_t &word64, int iWord)
Definition: L1TcsWord.cc:284
void setPartTrigNrWord64(cms_uint64_t &word64, int iWord)
Definition: L1TcsWord.cc:330
unsigned long long cms_uint64_t
Definition: typedefs.h:17
void setDaqNrWord64(cms_uint64_t &word64, int iWord)
Definition: L1TcsWord.cc:199
void setStatusWord64(cms_uint64_t &word64, int iWord)
Definition: L1TcsWord.cc:240
void L1GTEvmDigiToRaw::packTrailer ( unsigned char *  ptrGt,
unsigned char *  ptrGtBegin,
int  dataSize 
)
private

pack trailer word

Definition at line 705 of file L1GTEvmDigiToRaw.cc.

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

Referenced by produce().

707 {
708 
709  // TODO FIXME where from to get all numbers?
710 
711  // The length of the event fragment counted in 64-bit words including header and trailer
712  int lengthVal = dataSize/8;
713 
714  // Cyclic Redundancy Code of the event fragment including header and trailer
715  int crcVal = evf::compute_crc(ptrGtBegin, dataSize);
716 
717  // Event fragment status information
718  int evtStatusVal = 0;
719 
720  // Current value of the Trigger Throttling System bits.
721  int ttsBitsVal = 0;
722 
723  // 0 -> the current trailer word is the last one.
724  // 1-> other trailer words can follow
725  // (always 0 for ECAL)
726  bool moreTrailersVal = false;
727 
728  FEDTrailer gtFEDTrailer(ptrGt);
729  gtFEDTrailer.set(ptrGt,
730  lengthVal, crcVal, evtStatusVal, ttsBitsVal,
731  moreTrailersVal);
732 
733 }
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 103 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().

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

Member Data Documentation

cms_uint16_t L1GTEvmDigiToRaw::m_activeBoardsMaskGt
private

mask for active boards

Definition at line 96 of file L1GTEvmDigiToRaw.h.

Referenced by L1GTEvmDigiToRaw(), and produce().

int L1GTEvmDigiToRaw::m_bstLengthBytes
private

length of BST record (in bytes)

Definition at line 110 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 90 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 93 of file L1GTEvmDigiToRaw.h.

Referenced by L1GTEvmDigiToRaw(), and produce().

bool L1GTEvmDigiToRaw::m_isDebugEnabled
private

Definition at line 116 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 107 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 103 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 99 of file L1GTEvmDigiToRaw.h.

Referenced by produce().

int L1GTEvmDigiToRaw::m_verbosity
private

verbosity level

Definition at line 115 of file L1GTEvmDigiToRaw.h.

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