Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef L1GlobalTrigger_L1GtFdlWord_h
0002 #define L1GlobalTrigger_L1GtFdlWord_h
0003 
0004 /**
0005  * \class L1GtFdlWord
0006  *
0007  *
0008  * Description: L1 Global Trigger - FDL block 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 
0020 // user include files
0021 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutSetupFwd.h"
0022 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutSetup.h"
0023 #include "FWCore/Utilities/interface/typedefs.h"
0024 
0025 // forward declarations
0026 
0027 // class interface
0028 
0029 class L1GtFdlWord {
0030 public:
0031   /// constructors
0032   L1GtFdlWord();  // empty constructor, all members set to zero;
0033 
0034   // constructor from unpacked values;
0035   L1GtFdlWord(cms_uint16_t boardIdValue,
0036               int bxInEventValue,
0037               cms_uint16_t bxNrValue,
0038               cms_uint32_t eventNrValue,
0039               const TechnicalTriggerWord& gtTechnicalTriggerWordValue,
0040               const DecisionWord& gtDecisionWordValue,
0041               const DecisionWordExtended& gtDecisionWordExtendedValue,
0042               cms_uint16_t gtPrescaleFactorIndexTechValue,
0043               cms_uint16_t gtPrescaleFactorIndexAlgoValue,
0044               cms_uint16_t noAlgoValue,
0045               cms_uint16_t finalORValue,
0046               cms_uint32_t orbitNrValue,
0047               cms_uint16_t lumiSegmentNrValue,
0048               cms_uint16_t localBxNrValue);
0049 
0050   /// destructor
0051   virtual ~L1GtFdlWord();
0052 
0053   /// equal operator
0054   bool operator==(const L1GtFdlWord&) const;
0055 
0056   /// unequal operator
0057   bool operator!=(const L1GtFdlWord&) const;
0058 
0059 public:
0060   /// get/set board ID
0061 
0062   /// get BoardId value
0063   inline const cms_uint16_t boardId() const { return m_boardId; }
0064 
0065   /// set BoardId from a BoardId value
0066   void setBoardId(const cms_uint16_t& boardIdValue) { m_boardId = boardIdValue; }
0067 
0068   /// set the BoardId value from a 64-bits word
0069   void setBoardId(const cms_uint64_t& word64);
0070 
0071   /// set the BoardId value in a 64-bits word, having the index iWord
0072   /// in the GTFE raw record
0073   void setBoardIdWord64(cms_uint64_t& word64, const int iWord);
0074 
0075   /// get/set bunch cross in the GT event record
0076   inline const int bxInEvent() const { return m_bxInEvent; }
0077 
0078   void setBxInEvent(const int bxInEventValue) { m_bxInEvent = bxInEventValue; }
0079 
0080   /// set the BxInEvent value from a 64-bits word
0081   void setBxInEvent(const cms_uint64_t& word64);
0082 
0083   /// set the BxInEvent value in a 64-bits word, having the index iWord
0084   /// in the GTFE raw record
0085   void setBxInEventWord64(cms_uint64_t& word64, const int iWord);
0086 
0087   /// get/set BxNr - bunch cross number of the actual bx
0088   inline const cms_uint16_t bxNr() const { return m_bxNr; }
0089 
0090   void setBxNr(const cms_uint16_t& bxNrValue) { m_bxNr = bxNrValue; }
0091 
0092   /// set the BxNr value from a 64-bits word
0093   void setBxNr(const cms_uint64_t& word64);
0094 
0095   /// set the BxNr value in a 64-bits word, having the index iWord
0096   /// in the GTFE raw record
0097   void setBxNrWord64(cms_uint64_t& word64, const int iWord);
0098 
0099   /// get/set event number since last L1 reset generated in FDL
0100   inline const cms_uint32_t eventNr() const { return m_eventNr; }
0101 
0102   void setEventNr(const cms_uint32_t& eventNrValue) { m_eventNr = eventNrValue; }
0103 
0104   /// set the EventNr value from a 64-bits word
0105   void setEventNr(const cms_uint64_t& word64);
0106 
0107   /// set the EventNr value in a 64-bits word, having the index iWord
0108   /// in the GTFE raw record
0109   void setEventNrWord64(cms_uint64_t& word64, const int iWord);
0110 
0111   /// get/set technical trigger bits
0112   inline const TechnicalTriggerWord& gtTechnicalTriggerWord() const { return m_gtTechnicalTriggerWord; }
0113 
0114   void setGtTechnicalTriggerWord(const TechnicalTriggerWord& gtTechnicalTriggerWordValue) {
0115     m_gtTechnicalTriggerWord = gtTechnicalTriggerWordValue;
0116   }
0117 
0118   void printGtTechnicalTriggerWord(std::ostream& myCout) const;
0119 
0120   /// set the technical trigger bits from a 64-bits word
0121   void setGtTechnicalTriggerWord(const cms_uint64_t& word64);
0122 
0123   /// set the technical trigger bits in a 64-bits word, having the index iWord
0124   /// in the GTFE raw record
0125   void setGtTechnicalTriggerWordWord64(cms_uint64_t& word64, const int iWord);
0126 
0127   /// get/set/print algorithms bits (decision word)
0128   inline const DecisionWord& gtDecisionWord() const { return m_gtDecisionWord; }
0129 
0130   void setGtDecisionWord(const DecisionWord& gtDecisionWordValue) { m_gtDecisionWord = gtDecisionWordValue; }
0131 
0132   void printGtDecisionWord(std::ostream& myCout) const;
0133 
0134   /// set the algorithms bits from two 64-bits words
0135   /// WordA: bits 0-63
0136   void setGtDecisionWordA(const cms_uint64_t& word64);
0137 
0138   /// set the algorithms bits from two 64-bits words
0139   /// WordB: bits 64-128
0140   void setGtDecisionWordB(const cms_uint64_t& word64);
0141 
0142   /// set the algorithms bits in two 64-bits word, having the first index iWord
0143   /// in the GTFE raw record
0144   /// WordA: bits 0-63
0145   void setGtDecisionWordAWord64(cms_uint64_t& word64, const int iWord);
0146 
0147   /// set the algorithms bits in two 64-bits word, having the first index iWord
0148   /// in the GTFE raw record
0149   /// WordB: bits 64-128
0150   void setGtDecisionWordBWord64(cms_uint64_t& word64, const int iWord);
0151 
0152   /// get/set extended algorithms bits (extended decision word)
0153   inline const DecisionWordExtended& gtDecisionWordExtended() const { return m_gtDecisionWordExtended; }
0154 
0155   void setGtDecisionWordExtended(const DecisionWordExtended& gtDecisionWordExtendedValue) {
0156     m_gtDecisionWordExtended = gtDecisionWordExtendedValue;
0157   }
0158 
0159   void printGtDecisionWordExtended(std::ostream& myCout) const;
0160 
0161   /// set the extended algorithms bits from a 64-bits word
0162   void setGtDecisionWordExtended(const cms_uint64_t& word64);
0163 
0164   /// set the extended algorithms bits in a 64-bits word, having the index iWord
0165   /// in the GTFE raw record
0166   void setGtDecisionWordExtendedWord64(cms_uint64_t& word64, const int iWord);
0167 
0168   /// get/set "physics declared" bit
0169   inline const cms_uint16_t physicsDeclared() const { return m_physicsDeclared; }
0170 
0171   void setPhysicsDeclared(const cms_uint16_t& physicsDeclaredValue) { m_physicsDeclared = physicsDeclaredValue; }
0172 
0173   /// set the "physics declared" bit from a 64-bits word
0174   void setPhysicsDeclared(const cms_uint64_t& word64);
0175 
0176   /// set the "physics declared" bit bits in a 64-bits word, having the index iWord
0177   /// in the GTFE raw record
0178   void setPhysicsDeclaredWord64(cms_uint64_t& word64, const int iWord);
0179 
0180   /// get/set index of the set of prescale factors
0181 
0182   inline const cms_uint16_t gtPrescaleFactorIndexTech() const { return m_gtPrescaleFactorIndexTech; }
0183 
0184   void setGtPrescaleFactorIndexTech(const cms_uint16_t& gtPrescaleFactorIndexTechValue) {
0185     m_gtPrescaleFactorIndexTech = gtPrescaleFactorIndexTechValue;
0186   }
0187 
0188   /// set the GtPrescaleFactorIndexTech from a 64-bits word
0189   void setGtPrescaleFactorIndexTech(const cms_uint64_t& word64);
0190 
0191   /// set the GtPrescaleFactorIndexTech bits in a 64-bits word, having the index iWord
0192   /// in the GTFE raw record
0193   void setGtPrescaleFactorIndexTechWord64(cms_uint64_t& word64, const int iWord);
0194 
0195   inline const cms_uint16_t gtPrescaleFactorIndexAlgo() const { return m_gtPrescaleFactorIndexAlgo; }
0196 
0197   void setGtPrescaleFactorIndexAlgo(const cms_uint16_t& gtPrescaleFactorIndexAlgoValue) {
0198     m_gtPrescaleFactorIndexAlgo = gtPrescaleFactorIndexAlgoValue;
0199   }
0200 
0201   /// set the GtPrescaleFactorIndexAlgo from a 64-bits word
0202   void setGtPrescaleFactorIndexAlgo(const cms_uint64_t& word64);
0203 
0204   /// set the GtPrescaleFactorIndexAlgo bits in a 64-bits word, having the index iWord
0205   /// in the GTFE raw record
0206   void setGtPrescaleFactorIndexAlgoWord64(cms_uint64_t& word64, const int iWord);
0207 
0208   /// get/set NoAlgo
0209   inline const cms_uint16_t noAlgo() const { return m_noAlgo; }
0210 
0211   void setNoAlgo(const cms_uint16_t& noAlgoValue) { m_noAlgo = noAlgoValue; }
0212 
0213   /// set the NoAlgo from a 64-bits word
0214   void setNoAlgo(const cms_uint64_t& word64);
0215 
0216   /// set the NoAlgo bits in a 64-bits word, having the index iWord
0217   /// in the GTFE raw record
0218   void setNoAlgoWord64(cms_uint64_t& word64, const int iWord);
0219 
0220   /// get/set "Final OR" bits
0221   inline const cms_uint16_t finalOR() const { return m_finalOR; }
0222 
0223   void setFinalOR(const cms_uint16_t& finalORValue) { m_finalOR = finalORValue; }
0224 
0225   /// set the "Final OR" bits from a 64-bits word
0226   void setFinalOR(const cms_uint64_t& word64);
0227 
0228   /// set the "Final OR" bits in a 64-bits word, having the index iWord
0229   /// in the GTFE raw record
0230   void setFinalORWord64(cms_uint64_t& word64, const int iWord);
0231 
0232   inline const bool globalDecision() const { return static_cast<bool>(m_finalOR); }
0233 
0234   /// get/set orbit number
0235   inline const cms_uint32_t orbitNr() const { return m_orbitNr; }
0236 
0237   void setOrbitNr(const cms_uint32_t& orbitNrValue) { m_orbitNr = orbitNrValue; }
0238 
0239   /// set the orbit number bits from a 64-bits word
0240   void setOrbitNr(const cms_uint64_t& word64);
0241 
0242   /// set the orbit number bits in a 64-bits word, having the index iWord
0243   /// in the GTFE raw record
0244   void setOrbitNrWord64(cms_uint64_t& word64, const int iWord);
0245 
0246   /// get/set luminosity segment number of the actual bx
0247   inline const cms_uint16_t lumiSegmentNr() const { return m_lumiSegmentNr; }
0248 
0249   void setLumiSegmentNr(const cms_uint16_t& lumiSegmentNrValue) { m_lumiSegmentNr = lumiSegmentNrValue; }
0250 
0251   /// set the luminosity segment number bits from a 64-bits word
0252   void setLumiSegmentNr(const cms_uint64_t& word64);
0253 
0254   /// set the luminosity segment number bits in a 64-bits word, having the index iWord
0255   /// in the GTFE raw record
0256   void setLumiSegmentNrWord64(cms_uint64_t& word64, const int iWord);
0257 
0258   /// get/set local bunch cross number of the actual bx
0259   inline const cms_uint16_t localBxNr() const { return m_localBxNr; }
0260 
0261   void setLocalBxNr(const cms_uint16_t& localBxNrValue) { m_localBxNr = localBxNrValue; }
0262 
0263   /// set the local bunch cross number bits from a 64-bits word
0264   void setLocalBxNr(const cms_uint64_t& word64);
0265 
0266   /// set the local bunch cross number bits in a 64-bits word, having the index iWord
0267   /// in the GTFE raw record
0268   void setLocalBxNrWord64(cms_uint64_t& word64, const int iWord);
0269 
0270   /// get the size of the FDL block in GT DAQ record (in multiple of 8 bits)
0271   inline const unsigned int getSize() const {
0272     int unitLengthBits = L1GlobalTriggerReadoutSetup::UnitLength;
0273 
0274     return BlockSize * unitLengthBits;
0275   }
0276 
0277 public:
0278   /// reset the content of a L1GtFdlWord
0279   void reset();
0280 
0281   /// pretty print the content of a L1GtFdlWord
0282   void print(std::ostream& myCout) const;
0283 
0284   /// unpack FDL
0285   /// fdlPtr pointer to the beginning of the FDL block in the raw data
0286   void unpack(const unsigned char* fdlPtr);
0287 
0288 private:
0289   // block description in the raw GT record
0290 
0291   // block size in 64bits words (BlockSize * 64 bits)
0292   static const int BlockSize;
0293 
0294   // word 0
0295 
0296   // index of the word in the FDL block containig the variable
0297   static const int BoardIdWord;
0298   static const int BxInEventWord;
0299   static const int BxNrWord;
0300   static const int EventNrWord;
0301 
0302   // mask to get the 64-bit-value from the corresponding word in the FDL block
0303   static const cms_uint64_t BoardIdMask;
0304   static const cms_uint64_t BxInEventMask;
0305   static const cms_uint64_t BxNrMask;
0306   static const cms_uint64_t EventNrMask;
0307 
0308   // shift to the right to get the value from the "64-bit-value"
0309   static const int BoardIdShift;
0310   static const int BxInEventShift;
0311   static const int BxNrShift;
0312   static const int EventNrShift;
0313 
0314   // word 1
0315 
0316   static const int GtTechnicalTriggerWordWord;
0317   static const cms_uint64_t GtTechnicalTriggerWordMask;
0318   static const int GtTechnicalTriggerWordShift;
0319 
0320   // word 2 - WordA: bits 0-63
0321 
0322   static const int GtDecisionWordAWord;
0323   static const cms_uint64_t GtDecisionWordAMask;
0324   static const int GtDecisionWordAShift;
0325 
0326   // word 3 - WordB: bits 64-128
0327 
0328   static const int GtDecisionWordBWord;
0329   static const cms_uint64_t GtDecisionWordBMask;
0330   static const int GtDecisionWordBShift;
0331 
0332   // word 4
0333   static const int GtDecisionWordExtendedWord;
0334   static const cms_uint64_t GtDecisionWordExtendedMask;
0335   static const int GtDecisionWordExtendedShift;
0336 
0337   // word 5
0338   static const int PhysicsDeclaredWord;
0339   static const int GtPrescaleFactorIndexTechWord;
0340   static const int GtPrescaleFactorIndexAlgoWord;
0341   static const int NoAlgoWord;
0342   static const int FinalORWord;
0343 
0344   static const cms_uint64_t PhysicsDeclaredMask;
0345   static const cms_uint64_t GtPrescaleFactorIndexTechMask;
0346   static const cms_uint64_t GtPrescaleFactorIndexAlgoMask;
0347   static const cms_uint64_t NoAlgoMask;
0348   static const cms_uint64_t FinalORMask;
0349 
0350   static const int PhysicsDeclaredShift;
0351   static const int GtPrescaleFactorIndexTechShift;
0352   static const int GtPrescaleFactorIndexAlgoShift;
0353   static const int NoAlgoShift;
0354   static const int FinalORShift;
0355 
0356   // word 6
0357   static const int OrbitNrWord;
0358   static const int LumiSegmentNrWord;
0359   static const int LocalBxNrWord;
0360 
0361   static const cms_uint64_t OrbitNrMask;
0362   static const cms_uint64_t LumiSegmentNrMask;
0363   static const cms_uint64_t LocalBxNrMask;
0364 
0365   static const int OrbitNrShift;
0366   static const int LumiSegmentNrShift;
0367   static const int LocalBxNrShift;
0368 
0369 private:
0370   /// board identifier
0371   cms_uint16_t m_boardId;
0372 
0373   /// bunch cross in the GT event record
0374   int m_bxInEvent;
0375 
0376   /// bunch cross number of the actual bx
0377   cms_uint16_t m_bxNr;
0378 
0379   /// event number since last L1 reset generated in FDL
0380   cms_uint32_t m_eventNr;
0381 
0382   //
0383 
0384   /// technical trigger bits
0385   TechnicalTriggerWord m_gtTechnicalTriggerWord;
0386 
0387   /// algorithm bits
0388   DecisionWord m_gtDecisionWord;
0389 
0390   /// extended algorithm bits, in addition to 128
0391   DecisionWordExtended m_gtDecisionWordExtended;
0392 
0393   //
0394   /// set to true when physics declared
0395   cms_uint16_t m_physicsDeclared;
0396 
0397   /// index of the set of prescale factors in the DB/EventSetup
0398   /// for algorithm triggers and technical triggers
0399   cms_uint16_t m_gtPrescaleFactorIndexTech;
0400   cms_uint16_t m_gtPrescaleFactorIndexAlgo;
0401 
0402   /// true if no algorithm (from a defined group - default all) triggered
0403   cms_uint16_t m_noAlgo;
0404 
0405   /// FINOR (7:0) Final OR bits.
0406   /// FINOR(i) is connected to Partition (i);
0407   cms_uint16_t m_finalOR;
0408 
0409   //
0410 
0411   /// orbit number
0412   cms_uint32_t m_orbitNr;
0413 
0414   /// luminosity segment number
0415   cms_uint16_t m_lumiSegmentNr;
0416 
0417   /// local bunch cross number of the actual bx
0418   /// bx number at which the data were written into the ringbuffer
0419   cms_uint16_t m_localBxNr;
0420 };
0421 
0422 #endif /*L1GlobalTrigger_L1GtFdlWord_h*/