Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:04:28

0001 #ifndef L1GlobalTrigger_L1GtfeWord_h
0002 #define L1GlobalTrigger_L1GtfeWord_h
0003 
0004 /**
0005  * \class L1GtfeWord
0006  *
0007  *
0008  * Description: L1 Global Trigger - GTFE words in the readout record.
0009  *
0010  * Implementation:
0011  *    <TODO: enter implementation details>
0012  *
0013  * \author: Vasile Mihai Ghete - HEPHY Vienna
0014  *
0015  *
0016  */
0017 
0018 // system include files
0019 #include <iosfwd>
0020 
0021 // user include files
0022 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutSetupFwd.h"
0023 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutSetup.h"
0024 #include "FWCore/Utilities/interface/typedefs.h"
0025 
0026 // forward declarations
0027 
0028 // class interface
0029 
0030 class L1GtfeWord {
0031 public:
0032   /// constructors
0033   L1GtfeWord();  // empty constructor, all members set to zero;
0034 
0035   /// constructor from unpacked values;
0036   L1GtfeWord(cms_uint16_t boardIdValue,
0037              cms_uint16_t recordLength1Value,
0038              cms_uint16_t recordLengthValue,
0039              cms_uint16_t bxNrValue,
0040              cms_uint32_t setupVersionValue,
0041              cms_uint16_t activeBoardsValue,
0042              cms_uint16_t altNrBxBoardValue,
0043              cms_uint32_t totalTriggerNrValue);
0044 
0045   /// destructor
0046   virtual ~L1GtfeWord();
0047 
0048   /// equal operator
0049   bool operator==(const L1GtfeWord&) const;
0050 
0051   /// unequal operator
0052   bool operator!=(const L1GtfeWord&) const;
0053 
0054 public:
0055   /// get/set board ID
0056 
0057   /// get BoardId value
0058   inline const cms_uint16_t boardId() const { return m_boardId; }
0059 
0060   /// set BoardId from a BoardId value
0061   void setBoardId(cms_uint16_t boardIdValue) { m_boardId = boardIdValue; }
0062 
0063   /// set the BoardId value from a 64-bits word
0064   void setBoardId(const cms_uint64_t& word64);
0065 
0066   /// set the BoardId value in a 64-bits word, having the index iWord
0067   /// in the GTFE raw record
0068   void setBoardIdWord64(cms_uint64_t& word64, int iWord);
0069 
0070   /// get/set record length for alternative 1
0071   inline const cms_uint16_t recordLength1() const { return m_recordLength1; }
0072 
0073   void setRecordLength1(cms_uint16_t recordLengthValue) { m_recordLength1 = recordLengthValue; }
0074 
0075   void setRecordLength1(const cms_uint64_t& word64);
0076 
0077   /// set the RecordLength value in a 64-bits word, having the index iWord
0078   /// in the GTFE raw record
0079   void setRecordLength1Word64(cms_uint64_t& word64, int iWord);
0080 
0081   /// get/set record length for alternative 0
0082   inline const cms_uint16_t recordLength() const { return m_recordLength; }
0083 
0084   void setRecordLength(cms_uint16_t recordLengthValue) { m_recordLength = recordLengthValue; }
0085 
0086   void setRecordLength(const cms_uint64_t& word64);
0087 
0088   /// set the RecordLength value in a 64-bits word, having the index iWord
0089   /// in the GTFE raw record
0090   void setRecordLengthWord64(cms_uint64_t& word64, int iWord);
0091 
0092   /// get/set bunch cross number as counted in the GTFE board
0093   inline const cms_uint16_t bxNr() const { return m_bxNr; }
0094 
0095   void setBxNr(cms_uint16_t bxNrValue) { m_bxNr = bxNrValue; }
0096 
0097   void setBxNr(const cms_uint64_t& word64);
0098 
0099   /// set the BxNr value in a 64-bits word, having the index iWord
0100   /// in the GTFE raw record
0101   void setBxNrWord64(cms_uint64_t& word64, int iWord);
0102 
0103   /// get/set setup version
0104   inline const cms_uint32_t setupVersion() const { return m_setupVersion; }
0105 
0106   void setSetupVersion(cms_uint32_t setupVersionValue) { m_setupVersion = setupVersionValue; }
0107 
0108   void setSetupVersion(const cms_uint64_t& word64);
0109 
0110   /// set the SetupVersion value in a 64-bits word, having the index iWord
0111   /// in the GTFE raw record
0112   void setSetupVersionWord64(cms_uint64_t& word64, int iWord);
0113 
0114   /// get / set BST flag: 0 or 1 - via setup version (no private member)
0115   const int bstFlag() const;
0116   void setBstFlag(const int);
0117 
0118   /// get/set boards contributing to EVM respectively DAQ record
0119   inline const cms_uint16_t activeBoards() const { return m_activeBoards; }
0120 
0121   void setActiveBoards(cms_uint16_t activeBoardsValue) { m_activeBoards = activeBoardsValue; }
0122 
0123   void setActiveBoards(const cms_uint64_t& word64);
0124 
0125   /// set the ActiveBoards value in a 64-bits word, having the index iWord
0126   /// in the GTFE raw record
0127   void setActiveBoardsWord64(cms_uint64_t& word64, int iWord);
0128 
0129   /// set the ActiveBoards value in a 64-bits word, having the index iWord
0130   /// in the GTFE raw record from the value activeBoardsValue
0131   void setActiveBoardsWord64(cms_uint64_t& word64, int iWord, cms_int16_t activeBoardsValue);
0132 
0133   /// get/set alternative for number of BX per board
0134   inline const cms_uint16_t altNrBxBoard() const { return m_altNrBxBoard; }
0135 
0136   void setAltNrBxBoard(cms_uint16_t altNrBxBoardValue) { m_altNrBxBoard = altNrBxBoardValue; }
0137 
0138   void setAltNrBxBoard(const cms_uint64_t& word64);
0139 
0140   /// set the AltNrBxBoard value in a 64-bits word, having the index iWord
0141   /// in the GTFE raw record
0142   void setAltNrBxBoardWord64(cms_uint64_t& word64, int iWord);
0143 
0144   /// set the AltNrBxBoard value in a 64-bits word, having the index iWord
0145   /// in the GTFE raw record from the value altNrBxBoardValue
0146   void setAltNrBxBoardWord64(cms_uint64_t& word64, int iWord, cms_int16_t altNrBxBoardValue);
0147 
0148   /// get/set total number of L1A sent since start of run
0149   inline const cms_uint32_t totalTriggerNr() const { return m_totalTriggerNr; }
0150 
0151   void setTotalTriggerNr(cms_uint32_t totalTriggerNrValue) { m_totalTriggerNr = totalTriggerNrValue; }
0152 
0153   void setTotalTriggerNr(const cms_uint64_t& word64);
0154 
0155   /// set the TotalTriggerNr value in a 64-bits word, having the index iWord
0156   /// in the GTFE raw record
0157   void setTotalTriggerNrWord64(cms_uint64_t& word64, int iWord);
0158 
0159   /// get the size of the GTFE block in GT DAQ record (in multiple of 8 bits)
0160   inline const unsigned int getSize() const {
0161     int unitLengthBits = L1GlobalTriggerReadoutSetup::UnitLength;
0162 
0163     return BlockSize * unitLengthBits;
0164   }
0165 
0166 public:
0167   /// reset the content of a L1GtfeWord
0168   virtual void reset();
0169 
0170   /// pretty print the content of a L1GtfeWord
0171   virtual void print(std::ostream& myCout) const;
0172 
0173   /// unpack GTFE
0174   /// gtfePtr pointer to the beginning of the GTFE block in the raw data
0175   virtual void unpack(const unsigned char* gtfePtr);
0176 
0177 private:
0178   // block description in the raw GT record
0179 
0180   // block size in 64bits words
0181   static const int BlockSize;
0182 
0183   static const int BoardIdWord;
0184   static const int RecordLength1Word;
0185   static const int RecordLengthWord;
0186   static const int BxNrWord;
0187   static const int SetupVersionWord;
0188 
0189   static const cms_uint64_t BoardIdMask;
0190   static const cms_uint64_t RecordLength1Mask;
0191   static const cms_uint64_t RecordLengthMask;
0192   static const cms_uint64_t BxNrMask;
0193   static const cms_uint64_t SetupVersionMask;
0194 
0195   static const cms_uint32_t BstFlagMask;
0196 
0197   // shifts could be computed from masks...
0198   static const int BoardIdShift;
0199   static const int RecordLength1Shift;
0200   static const int RecordLengthShift;
0201   static const int BxNrShift;
0202   static const int SetupVersionShift;
0203 
0204   //
0205   static const int ActiveBoardsWord;
0206   static const int AltNrBxBoardWord;
0207   static const int TotalTriggerNrWord;
0208 
0209   static const cms_uint64_t ActiveBoardsMask;
0210   static const cms_uint64_t AltNrBxBoardMask;
0211   static const cms_uint64_t TotalTriggerNrMask;
0212 
0213   static const int ActiveBoardsShift;
0214   static const int AltNrBxBoardShift;
0215   static const int TotalTriggerNrShift;
0216 
0217 private:
0218   /// board identifier
0219   cms_uint16_t m_boardId;
0220 
0221   /// record length for alternative 1
0222   cms_uint16_t m_recordLength1;
0223 
0224   /// record length  for alternative 0
0225   cms_uint16_t m_recordLength;
0226 
0227   /// bunch cross number as counted in the GTFE board
0228   cms_uint16_t m_bxNr;
0229   cms_uint32_t m_setupVersion;
0230 
0231   /// active boards contributing to EVM respectively DAQ record
0232   cms_uint16_t m_activeBoards;
0233 
0234   /// alternative for number of BX per board
0235   ///     correlated with active boards
0236   ///     bit value is 0: take alternative 0
0237   ///     bit value is 1: take alternative 1
0238   cms_uint16_t m_altNrBxBoard;
0239 
0240   /// total number of L1A sent since start of run
0241   cms_uint32_t m_totalTriggerNr;
0242 };
0243 
0244 #endif /*L1GlobalTrigger_L1GtfeWord_h*/