Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef L1GCTINTERNHTMISS_H
0002 #define L1GCTINTERNHTMISS_H
0003 
0004 /*! 
0005  * \class L1GctInternHtMiss
0006  * \brief L1 GCT internal Ht Miss component(s) Ht_x and/or Ht_y 
0007  * 
0008  * \author Robert Frazier
0009  * \date March 2009
0010  */
0011 
0012 // C++ headers
0013 #include <ostream>
0014 #include <cstdint>
0015 
0016 class L1GctInternHtMiss {
0017 public:
0018   /// Enum for the variants of Internal HtMiss.
0019   enum L1GctInternHtMissType { nulltype, miss_htx, miss_hty, miss_htx_and_hty, jf_miss_htx_and_hty };
0020 
0021   enum numberOfBits {
0022     // TODO - tidy up all these enums.
0023     // These numbers of bits are needed to specify data sizes in the emulator
0024     // Other masks are below in the private section.
0025     kJetMissHtNBits = 12,
0026     kMissHxAndHyNBits = 14,
0027     kMissHxOrHyNBits = 16
0028   };
0029 
0030   /// default constructor (for vector initialisation etc.)
0031   L1GctInternHtMiss();
0032 
0033   /// destructor
0034   ~L1GctInternHtMiss();
0035 
0036   /* Named Constructors */
0037 
0038   /// Named ctor for making missing Ht x-component object from unpacker raw data.
0039   static L1GctInternHtMiss unpackerMissHtx(const uint16_t capBlock,
0040                                            const uint16_t capIndex,
0041                                            const int16_t bx,
0042                                            const uint32_t data);
0043 
0044   /// Named ctor for making missing Ht y-component object from unpacker raw data.
0045   static L1GctInternHtMiss unpackerMissHty(const uint16_t capBlock,
0046                                            const uint16_t capIndex,
0047                                            const int16_t bx,
0048                                            const uint32_t data);
0049 
0050   /// Named ctor for making missing Ht x & y components object from unpacker raw data (wheel input).
0051   static L1GctInternHtMiss unpackerMissHtxHty(const uint16_t capBlock,
0052                                               const uint16_t capIndex,
0053                                               const int16_t bx,
0054                                               const uint32_t data);
0055 
0056   /// Named ctor for making missing Ht x & y components object from emulator (jetFinder output).
0057   static L1GctInternHtMiss emulatorJetMissHt(const int htx, const int hty, const bool overFlow, const int16_t bx);
0058 
0059   /// Named ctor for making missing Ht x & y components object from emulator (wheel input).
0060   static L1GctInternHtMiss emulatorMissHtxHty(const int htx, const int hty, const bool overFlow, const int16_t bx);
0061 
0062   /// Named ctor for making missing Ht x component object from emulator
0063   static L1GctInternHtMiss emulatorMissHtx(const int htx, const bool overFlow, const int16_t bx);
0064 
0065   /// Named ctor for making missing Ht y component object from emulator
0066   static L1GctInternHtMiss emulatorMissHty(const int hty, const bool overFlow, const int16_t bx);
0067 
0068   /* Metadata */
0069 
0070   /// 'type' of object?
0071   L1GctInternHtMiss::L1GctInternHtMissType type() const { return type_; }
0072 
0073   /// Get capture block
0074   uint16_t capBlock() const { return capBlock_; }
0075 
0076   /// Get index within capture block
0077   uint16_t capIndex() const { return capIndex_; }
0078 
0079   /// Get BX number
0080   int16_t bx() const { return bx_; }
0081 
0082   /// Is there a valid Ht x-component stored?
0083   bool isThereHtx() const {
0084     return (type() == miss_htx || type() == miss_htx_and_hty || type() == jf_miss_htx_and_hty);
0085   }
0086 
0087   /// Is there a valid Ht y-component stored?
0088   bool isThereHty() const {
0089     return (type() == miss_hty || type() == miss_htx_and_hty || type() == jf_miss_htx_and_hty);
0090   }
0091 
0092   /* Access to the actual data */
0093 
0094   /// Get the raw data
0095   uint32_t raw() const { return data_; }
0096 
0097   /// Get Ht x-component value
0098   int16_t htx() const;
0099 
0100   /// Get Ht y-component
0101   int16_t hty() const;
0102 
0103   /// Get overflow
0104   bool overflow() const;
0105 
0106   /* Operators */
0107 
0108   /// Equality operator
0109   bool operator==(const L1GctInternHtMiss& rhs) const { return (type() == rhs.type() && raw() == rhs.raw()); }
0110 
0111   /// Inequality operator
0112   bool operator!=(const L1GctInternHtMiss& rhs) const { return !(*this == rhs); }
0113 
0114 private:
0115   /// Useful bit masks and bit shifts
0116   enum ShiftsAndMasks {
0117     kDoubleComponentHtyShift = 16,          // Bit shift for Hty in miss_htx_and_hty
0118     kSingleComponentOflowMask = (1 << 30),  // Overflow bit mask in miss_htx or miss_hty
0119     kDoubleComponentOflowMask = (1 << 15),  // Overflow bit mask in miss_htx_and_hty
0120     kSingleComponentHtMask = 0xffff,        // Ht component mask in miss_htx or miss_hty
0121     kDoubleComponentHtMask = 0x3fff,        // Ht component mask in miss_htx_and_hty
0122     kJetFinderComponentHtMask = 0x0fff,     // Ht component mask in jf_miss_htx_and_hty
0123     kSingleComponentRawMask = kSingleComponentOflowMask |
0124                               kSingleComponentHtMask,  // To mask off all the non-data bits in raw data (e.g. BC0, etc)
0125     kDoubleComponentRawMask =
0126         (kDoubleComponentHtMask << kDoubleComponentHtyShift) | kDoubleComponentOflowMask | kDoubleComponentHtMask
0127   };
0128 
0129   /* Private ctors and methods */
0130 
0131   /// Private constructor that the named ctors use.
0132   L1GctInternHtMiss(const L1GctInternHtMissType type,
0133                     const uint16_t capBlock,
0134                     const uint16_t capIndex,
0135                     const int16_t bx,
0136                     const uint32_t data);
0137 
0138   /// Converts 14-bit two's complement numbers to 16-bit two's complement (i.e. an int16_t)
0139   /*! The input is the raw bits of the 14-bit two's complement in a 16-bit unsigned number. */
0140   int16_t convert14BitTwosCompTo16Bit(const uint16_t data) const;
0141 
0142   /* Private data */
0143 
0144   /// 'Type' of the data
0145   L1GctInternHtMissType type_;
0146 
0147   // source of the data
0148   uint16_t capBlock_;
0149   uint16_t capIndex_;
0150   int16_t bx_;
0151 
0152   /// The captured raw data
0153   uint32_t data_;
0154 };
0155 
0156 // Pretty-print operator for L1GctInternHtMiss
0157 std::ostream& operator<<(std::ostream& os, const L1GctInternHtMiss& rhs);
0158 
0159 #endif