Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef L1GlobalTrigger_L1TcsWord_h
0002 #define L1GlobalTrigger_L1TcsWord_h
0003 
0004 /**
0005  * \class L1TcsWord
0006  * 
0007  * 
0008  * Description: L1 Global Trigger - TCS 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 declaration
0029 class L1TcsWord {
0030 public:
0031   /// constructors
0032   L1TcsWord();  // empty constructor, all members set to zero;
0033 
0034   /// constructor from unpacked values;
0035   L1TcsWord(cms_uint16_t boardIdValue,
0036             cms_uint16_t bxNrValue,
0037             cms_uint16_t daqNrValue,
0038             cms_uint16_t triggerTypeValue,
0039             cms_uint16_t statusValue,
0040             cms_uint16_t luminositySegmentNrValue,
0041             cms_uint32_t partRunNrValue,
0042             cms_uint32_t assignedPartitionsValue,
0043             cms_uint32_t partTrigNrValue,
0044             cms_uint32_t eventNrValue,
0045             cms_uint64_t orbitNrValue);
0046 
0047   /// destructor
0048   virtual ~L1TcsWord();
0049 
0050   /// equal operator
0051   bool operator==(const L1TcsWord&) const;
0052 
0053   /// unequal operator
0054   bool operator!=(const L1TcsWord&) const;
0055 
0056 public:
0057   /// get/set board ID
0058 
0059   /// get BoardId value
0060   inline const cms_uint16_t boardId() const { return m_boardId; }
0061 
0062   /// set BoardId from a BoardId value
0063   void setBoardId(const cms_uint16_t boardIdValue) { m_boardId = boardIdValue; }
0064 
0065   /// set the BoardId value from a 64-bits word
0066   void setBoardId(const cms_uint64_t& word64);
0067 
0068   /// set the BoardId value in a 64-bits word, having the index iWord
0069   /// in the GTFE raw record
0070   void setBoardIdWord64(cms_uint64_t& word64, int iWord);
0071 
0072   /// get/set bunch cross number as counted in the TCS chip
0073   inline const cms_uint16_t bxNr() const { return m_bxNr; }
0074 
0075   void setBxNr(const cms_uint16_t bxNrValue) { m_bxNr = bxNrValue; }
0076 
0077   /// set the BxNr value from a 64-bits word
0078   void setBxNr(const cms_uint64_t& word64);
0079 
0080   /// set the BxNr value in a 64-bits word, having the index iWord
0081   /// in the GTFE EVM raw record
0082   void setBxNrWord64(cms_uint64_t& word64, int iWord);
0083 
0084   /// get/set number of DAQ partition to which the L1A has been sent
0085   inline const cms_uint16_t daqNr() const { return m_daqNr; }
0086 
0087   void setDaqNr(const cms_uint16_t daqNrValue) { m_daqNr = daqNrValue; }
0088 
0089   /// set the DaqNr value from a 64-bits word
0090   void setDaqNr(const cms_uint64_t& word64);
0091 
0092   /// set the DaqNr value in a 64-bits word, having the index iWord
0093   /// in the GTFE EVM raw record
0094   void setDaqNrWord64(cms_uint64_t& word64, int iWord);
0095 
0096   /// get/set trigger type, identical with event type in CMS header
0097   inline const cms_uint16_t triggerType() const { return m_triggerType; }
0098 
0099   void setTriggerType(const cms_uint16_t triggerTypeValue) { m_triggerType = triggerTypeValue; }
0100 
0101   /// set the TriggerType value from a 64-bits word
0102   void setTriggerType(const cms_uint64_t& word64);
0103 
0104   /// set the TriggerType value in a 64-bits word, having the index iWord
0105   /// in the GTFE EVM raw record
0106   void setTriggerTypeWord64(cms_uint64_t& word64, int iWord);
0107 
0108   /// get/set status: 0000 = normal rate; 1000 = low rate = warning
0109   inline const cms_uint16_t status() const { return m_status; }
0110 
0111   void setStatus(const cms_uint16_t statusValue) { m_status = statusValue; }
0112 
0113   /// set the Status value from a 64-bits word
0114   void setStatus(const cms_uint64_t& word64);
0115 
0116   /// set the Status value in a 64-bits word, having the index iWord
0117   /// in the GTFE EVM raw record
0118   void setStatusWord64(cms_uint64_t& word64, int iWord);
0119 
0120   /// get/set luminosity segment number
0121   inline const cms_uint16_t luminositySegmentNr() const { return m_luminositySegmentNr; }
0122 
0123   void setLuminositySegmentNr(const cms_uint16_t luminositySegmentNrValue) {
0124     m_luminositySegmentNr = luminositySegmentNrValue;
0125   }
0126 
0127   /// set the luminosity segment number value from a 64-bits word
0128   void setLuminositySegmentNr(const cms_uint64_t& word64);
0129 
0130   /// set the luminosity segment number value in a 64-bits word,
0131   /// having the index iWord in the GTFE EVM raw record
0132   void setLuminositySegmentNrWord64(cms_uint64_t& word64, int iWord);
0133 
0134   /// get/set partition run number
0135   inline const cms_uint32_t partRunNr() const { return m_partRunNr; }
0136 
0137   void setPartRunNr(const cms_uint32_t partRunNrValue) { m_partRunNr = partRunNrValue; }
0138 
0139   /// set the PartRunNr value from a 64-bits word
0140   void setPartRunNr(const cms_uint64_t& word64);
0141 
0142   /// set the PartRunNr value in a 64-bits word, having the index iWord
0143   /// in the GTFE EVM raw record
0144   void setPartRunNrWord64(cms_uint64_t& word64, int iWord);
0145 
0146   /// get/set assigned partition: bit "i" correspond to detector partition "i"
0147   inline const cms_uint32_t assignedPartitions() const { return m_assignedPartitions; }
0148 
0149   void setAssignedPartitions(const cms_uint32_t assignedPartitionsValue) {
0150     m_assignedPartitions = assignedPartitionsValue;
0151   }
0152 
0153   /// set the AssignedPartitions value from a 64-bits word
0154   void setAssignedPartitions(const cms_uint64_t& word64);
0155 
0156   /// set the AssignedPartitions value in a 64-bits word, having the index iWord
0157   /// in the GTFE EVM raw record
0158   void setAssignedPartitionsWord64(cms_uint64_t& word64, int iWord);
0159 
0160   /// get/set total number of L1A sent since start of the run to this DAQ partition
0161   inline const cms_uint32_t partTrigNr() const { return m_partTrigNr; }
0162 
0163   void setPartTrigNr(const cms_uint32_t partTrigNrValue) { m_partTrigNr = partTrigNrValue; }
0164 
0165   /// set the PartTrigNr value from a 64-bits word
0166   void setPartTrigNr(const cms_uint64_t& word64);
0167 
0168   /// set the PartTrigNr value in a 64-bits word, having the index iWord
0169   /// in the GTFE EVM raw record
0170   void setPartTrigNrWord64(cms_uint64_t& word64, int iWord);
0171 
0172   /// get/set event number since last L1 reset generated in TCS chip
0173   inline const cms_uint32_t eventNr() const { return m_eventNr; }
0174 
0175   void setEventNr(const cms_uint32_t eventNrValue) { m_eventNr = eventNrValue; }
0176 
0177   /// set the EventNr value from a 64-bits word
0178   void setEventNr(const cms_uint64_t& word64);
0179 
0180   /// set the EventNr value in a 64-bits word, having the index iWord
0181   /// in the GTFE EVM raw record
0182   void setEventNrWord64(cms_uint64_t& word64, int iWord);
0183 
0184   /// get/set orbit number since start of run
0185   inline const cms_uint64_t orbitNr() const { return m_orbitNr; }
0186 
0187   void setOrbitNr(const cms_uint64_t orbitNrValue) { m_orbitNr = orbitNrValue; }
0188 
0189   /// set the OrbitNr value from a 64-bits word
0190   void setOrbitNrFrom(const cms_uint64_t& word64);
0191 
0192   /// set the OrbitNr value in a 64-bits word, having the index iWord
0193   /// in the GTFE EVM raw record
0194   void setOrbitNrWord64(cms_uint64_t& word64, int iWord);
0195 
0196   /// get the size of the TCS block in GT EVM record (in multiple of 8 bits)
0197   inline const unsigned int getSize() const {
0198     int unitLengthBits = L1GlobalTriggerReadoutSetup::UnitLength;
0199 
0200     return BlockSize * unitLengthBits;
0201   }
0202 
0203 public:
0204   /// reset the content of a L1TcsWord
0205   void reset();
0206 
0207   /// pretty print the content of a L1TcsWord
0208   void print(std::ostream& myCout) const;
0209 
0210   /// unpack TCS
0211   /// tcsPtr pointer to the beginning of the TCS block in the raw data
0212   void unpack(const unsigned char* tcsPtr);
0213 
0214 private:
0215   // block description in the raw GT record
0216 
0217   // block size in 64bits words (BlockSize * 64 bits)
0218   static const int BlockSize;
0219 
0220   // word 0
0221 
0222   // index of the word in the TCS block containig the variable
0223   static const int BoardIdWord;
0224   static const int BxNrWord;
0225   static const int DaqNrWord;
0226   static const int TriggerTypeWord;
0227   static const int StatusWord;
0228   static const int LuminositySegmentNrWord;
0229 
0230   // mask to get the 64-bit-value from the corresponding word in the TCS block
0231   static const cms_uint64_t BoardIdMask;
0232   static const cms_uint64_t BxNrMask;
0233   static const cms_uint64_t DaqNrMask;
0234   static const cms_uint64_t TriggerTypeMask;
0235   static const cms_uint64_t StatusMask;
0236   static const cms_uint64_t LuminositySegmentNrMask;
0237 
0238   // shift to the right to get the value from the "64-bit-value"
0239   static const int BoardIdShift;
0240   static const int BxNrShift;
0241   static const int DaqNrShift;
0242   static const int TriggerTypeShift;
0243   static const int StatusShift;
0244   static const int LuminositySegmentNrShift;
0245 
0246   // word 1
0247 
0248   static const int PartRunNrWord;
0249   static const int AssignedPartitionsWord;
0250 
0251   static const cms_uint64_t PartRunNrMask;
0252   static const cms_uint64_t AssignedPartitionsMask;
0253 
0254   static const int PartRunNrShift;
0255   static const int AssignedPartitionsShift;
0256 
0257   // word 2
0258 
0259   static const int PartTrigNrWord;
0260   static const int EventNrWord;
0261 
0262   static const cms_uint64_t PartTrigNrMask;
0263   static const cms_uint64_t EventNrMask;
0264 
0265   static const int PartTrigNrShift;
0266   static const int EventNrShift;
0267 
0268   // word 3
0269 
0270   static const int OrbitNrWord;
0271 
0272   static const cms_uint64_t OrbitNrMask;
0273 
0274   static const int OrbitNrShift;
0275 
0276   // word 4
0277 
0278   // empty
0279 
0280 private:
0281   /// board identifier
0282   cms_uint16_t m_boardId;
0283 
0284   /// bunch cross number as counted in the TCS chip
0285   cms_uint16_t m_bxNr;
0286 
0287   /// number of DAQ partition to which the L1A has been sent
0288   cms_uint16_t m_daqNr;
0289 
0290   /// trigger type, identical with event type in CMS header (event type)
0291   cms_uint16_t m_triggerType;
0292 
0293   /// 0000 = normal rate; 1000 = low rate = warning
0294   cms_uint16_t m_status;
0295 
0296   /// luminosity segment number
0297   cms_uint16_t m_luminositySegmentNr;
0298 
0299   //
0300 
0301   /// partition run number
0302   cms_uint32_t m_partRunNr;
0303 
0304   /// bit "i" correspond to detector partition "i"
0305   /// if bit = 1, detection partition connected to actual
0306   /// DAQ partition
0307   cms_uint32_t m_assignedPartitions;
0308 
0309   //
0310 
0311   /// total number of L1A sent since start of the run
0312   /// to this DAQ partition
0313   cms_uint32_t m_partTrigNr;
0314 
0315   /// event number since last L1 reset generated in TCS chip
0316   cms_uint32_t m_eventNr;
0317 
0318   //
0319 
0320   /// orbit number since start of run (48 bits, in fact)
0321   cms_uint64_t m_orbitNr;
0322 
0323   //
0324   // empty word
0325 };
0326 
0327 #endif /*L1GlobalTrigger_L1TcsWord_h*/