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
std::vector< ConsumesInfoconsumesInfo () const
 
 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
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) 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
 
edm::EDGetTokenT
< L1GlobalTriggerEvmReadoutRecord
m_evmGtInputToken
 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 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
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
int m_verbosity
verbosity level
edm::EDGetTokenT< L1GlobalTriggerEvmReadoutRecord > m_evmGtInputToken
input tag for GT EVM record
L1GTEvmDigiToRaw::~L1GTEvmDigiToRaw ( )
virtual

destructor

Definition at line 83 of file L1GTEvmDigiToRaw.cc.

84 {
85 
86  // empty now
87 
88 }

Member Function Documentation

void L1GTEvmDigiToRaw::beginJob ( void  )
privatevirtual

beginning of job stuff

Reimplemented from edm::EDProducer.

Definition at line 93 of file L1GTEvmDigiToRaw.cc.

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

end of job stuff

Reimplemented from edm::EDProducer.

Definition at line 735 of file L1GTEvmDigiToRaw.cc.

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

pack FDL blocks for various bunch crosses

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

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

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

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

pack the TCS block

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

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

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

Referenced by produce().

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

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

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

edm::InputTag L1GTEvmDigiToRaw::m_evmGtInputTag
private

Definition at line 93 of file L1GTEvmDigiToRaw.h.

Referenced by L1GTEvmDigiToRaw(), and produce().

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

input tag for GT EVM record

Definition at line 92 of file L1GTEvmDigiToRaw.h.

Referenced by 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().