Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:53:49

0001 #ifndef L1GlobalTrigger_L1GtPsbWord_h
0002 #define L1GlobalTrigger_L1GtPsbWord_h
0003 
0004 /**
0005  * \class L1GtPsbWord
0006  * 
0007  * 
0008  * Description: PSB block in the L1 GT 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 declaration
0029 class L1GtPsbWord {
0030 public:
0031   static const int NumberAData = 8;
0032   static const int NumberBData = 8;
0033 
0034 public:
0035   /// constructors
0036   L1GtPsbWord();  // empty constructor, all members set to zero;
0037 
0038   /// constructor from unpacked values;
0039   L1GtPsbWord(cms_uint16_t boardIdValue,
0040               int bxInEventValue,
0041               cms_uint16_t bxNrValue,
0042               cms_uint32_t eventNrValue,
0043               cms_uint16_t aDataValue[NumberAData],
0044               cms_uint16_t bDataValue[NumberBData],
0045               cms_uint16_t localBxNrValue);
0046 
0047   /// destructor
0048   virtual ~L1GtPsbWord();
0049 
0050   /// equal operator
0051   bool operator==(const L1GtPsbWord&) const;
0052 
0053   /// unequal operator
0054   bool operator!=(const L1GtPsbWord&) const;
0055 
0056 public:
0057   /// get/set board ID
0058   inline const cms_uint16_t boardId() const { return m_boardId; }
0059 
0060   void setBoardId(cms_uint16_t boardIdValue) { m_boardId = boardIdValue; }
0061 
0062   /// set the BoardId value from a 64-bits word, having the index iWord
0063   /// in the GTFE raw record
0064   void setBoardId(const cms_uint64_t& word64, int iWord);
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 bunch cross in the GT event record
0071   inline const int bxInEvent() const { return m_bxInEvent; }
0072 
0073   void setBxInEvent(int bxInEventValue) { m_bxInEvent = bxInEventValue; }
0074 
0075   /// set the BxInEvent value from a 64-bits word, having the index iWord
0076   /// in the GTFE raw record
0077   void setBxInEvent(const cms_uint64_t& word64, int iWord);
0078 
0079   /// set the BxInEvent value in a 64-bits word, having the index iWord
0080   /// in the GTFE raw record
0081   void setBxInEventWord64(cms_uint64_t& word64, int iWord);
0082 
0083   /// get/set bunch cross number of the actual bx
0084   inline const cms_uint16_t bxNr() const { return m_bxNr; }
0085 
0086   void setBxNr(cms_uint16_t bxNrValue) { m_bxNr = bxNrValue; }
0087 
0088   /// set the BxNr value from a 64-bits word, having the index iWord
0089   /// in the GTFE raw record
0090   void setBxNr(const cms_uint64_t& word64, int iWord);
0091 
0092   /// set the BxNr value in a 64-bits word, having the index iWord
0093   /// in the GTFE raw record
0094   void setBxNrWord64(cms_uint64_t& word64, int iWord);
0095 
0096   /// get/set event number since last L1 reset generated in PSB
0097   inline const cms_uint32_t eventNr() const { return m_eventNr; }
0098 
0099   void setEventNr(cms_uint32_t eventNrValue) { m_eventNr = eventNrValue; }
0100 
0101   /// set the EventNr value from a 64-bits word, having the index iWord
0102   /// in the GTFE raw record
0103   void setEventNr(const cms_uint64_t& word64, int iWord);
0104 
0105   /// set the EventNr value in a 64-bits word, having the index iWord
0106   /// in the GTFE raw record
0107   void setEventNrWord64(cms_uint64_t& word64, int iWord);
0108 
0109   /// get/set A_DATA_CH_IA
0110   const cms_uint16_t aData(int iA) const;
0111   void setAData(cms_uint16_t aDataVal, int iA);
0112 
0113   /// set the AData value from a 64-bits word, having the index iWord
0114   /// in the GTFE raw record
0115   void setAData(const cms_uint64_t& word64, int iWord);
0116 
0117   /// set the AData value in a 64-bits word, having the index iWord
0118   /// in the GTFE raw record
0119   void setADataWord64(cms_uint64_t& word64, int iWord);
0120 
0121   /// get/set B_DATA_CH_IB
0122   const cms_uint16_t bData(int iB) const;
0123   void setBData(cms_uint16_t bDataVal, int iB);
0124 
0125   /// set the BData value from a 64-bits word, having the index iWord
0126   /// in the GTFE raw record
0127   void setBData(const cms_uint64_t& word64, int iWord);
0128 
0129   /// set the BData value in a 64-bits word, having the index iWord
0130   /// in the GTFE raw record
0131   void setBDataWord64(cms_uint64_t& word64, int iWord);
0132 
0133   /// get/set local bunch cross number of the actual bx
0134   inline const cms_uint16_t localBxNr() const { return m_localBxNr; }
0135 
0136   void setLocalBxNr(cms_uint16_t localBxNrValue) { m_localBxNr = localBxNrValue; }
0137 
0138   /// set the local bunch cross number bits from a 64-bits word, having the index iWord
0139   /// in the GTFE raw record
0140   void setLocalBxNr(const cms_uint64_t& word64, int iWord);
0141 
0142   /// set the local bunch cross number bits in a 64-bits word, having the index iWord
0143   /// in the GTFE raw record
0144   void setLocalBxNrWord64(cms_uint64_t& word64, int iWord);
0145 
0146   /// get the size of the PSB block in GT DAQ record (in multiple of 8 bits)
0147   inline const unsigned int getSize() const {
0148     int unitLengthBits = L1GlobalTriggerReadoutSetup::UnitLength;
0149 
0150     return BlockSize * unitLengthBits;
0151   }
0152 
0153 public:
0154   /// reset the content of a L1GtPsbWord
0155   void reset();
0156 
0157   /// pretty print
0158   void print(std::ostream& myCout) const;
0159 
0160 private:
0161   // block description in the raw GT record
0162 
0163   // block size in 64bits words (BlockSize * 64 bits)
0164   static const int BlockSize = 6;
0165 
0166   // word 0
0167 
0168   // index of the word in the PSB block containig the variable
0169   static const int BoardIdWord = 0;
0170   static const int BxInEventWord = 0;
0171   static const int BxNrWord = 0;
0172   static const int EventNrWord = 0;
0173 
0174   // mask to get the 64-bit-value from the corresponding word in the PSB block
0175   static const cms_uint64_t BoardIdMask = 0xFFFF000000000000ULL;
0176   static const cms_uint64_t BxInEventMask = 0x0000F00000000000ULL;
0177   static const cms_uint64_t BxNrMask = 0x00000FFF00000000ULL;
0178   static const cms_uint64_t EventNrMask = 0x0000000000FFFFFFULL;
0179 
0180   // shift to the right to get the value from the "64-bit-value"
0181   static const int BoardIdShift = 48;
0182   static const int BxInEventShift = 44;
0183   static const int BxNrShift = 32;
0184   static const int EventNrShift = 0;
0185 
0186   // assume uniform size od A_Data and B_Data
0187   static const int DataCHSize = 16;  // bits
0188   static const cms_uint64_t DataCHMask = 0x000000000000FFFFULL;
0189 
0190   // word 1
0191   static const int ADataCH0Word = 1;
0192 
0193   // word 2
0194   static const int ADataCH4Word = 2;
0195 
0196   // word 3
0197   static const int BDataCH0Word = 3;
0198 
0199   // word 4
0200   static const int BDataCH4Word = 4;
0201 
0202   // word 5
0203   static const int LocalBxNrWord = 5;
0204   static const cms_uint64_t LocalBxNrMask = 0x0000000000000FFFULL;
0205   static const int LocalBxNrShift = 0;
0206 
0207 private:
0208   // first number in the comment represents number of bits
0209 
0210   cms_uint16_t m_boardId;  // 16: board identifier
0211   //
0212   int m_bxInEvent;  //  4: bunch cross in the GT event record
0213   //     one keeps 3 bx (F, 0, 1) for standard record,
0214   //               5 bx (E, F, 0, 1) for debug record
0215   //
0216   cms_uint16_t m_bxNr;     // 12: bunch cross number of the actual bx
0217   cms_uint32_t m_eventNr;  // 24: event number since last L1 reset generated in PSB
0218   //
0219   cms_uint16_t m_aData[NumberAData];  // 16: A_Data_ChX
0220   //
0221   cms_uint16_t m_bData[NumberBData];  // 16: B_Data_ChX
0222   //
0223   cms_uint16_t m_localBxNr;  // 12: local bunch cross number of the actual bx
0224                              //     bx number at which the data were written into the ringbuffer
0225 };
0226 
0227 #endif /*L1GlobalTrigger_L1GtPsbWord_h*/