CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC2/src/DataFormats/L1GlobalCaloTrigger/interface/L1GctInternHtMiss.h

Go to the documentation of this file.
00001 #ifndef L1GCTINTERNHTMISS_H
00002 #define L1GCTINTERNHTMISS_H
00003 
00004 
00013 // C++ headers
00014 #include <ostream>
00015 #include <stdint.h>
00016 
00017 class L1GctInternHtMiss
00018 {
00019 
00020  public:
00021 
00023   enum L1GctInternHtMissType{ nulltype,
00024                               miss_htx,
00025                               miss_hty,
00026                               miss_htx_and_hty,
00027                               jf_miss_htx_and_hty };
00028 
00029   enum numberOfBits {
00030     // TODO - tidy up all these enums.
00031     // These numbers of bits are needed to specify data sizes in the emulator
00032     // Other masks are below in the private section.
00033     kJetMissHtNBits   = 12,
00034     kMissHxAndHyNBits = 14,
00035     kMissHxOrHyNBits  = 16
00036   };
00037 
00039   L1GctInternHtMiss();
00040 
00042   ~L1GctInternHtMiss();
00043 
00044  
00045   /* Named Constructors */
00046 
00048   static L1GctInternHtMiss unpackerMissHtx(const uint16_t capBlock,
00049                                            const uint16_t capIndex,
00050                                            const int16_t bx,
00051                                            const uint32_t data);
00052 
00054   static L1GctInternHtMiss unpackerMissHty(const uint16_t capBlock,
00055                                            const uint16_t capIndex,
00056                                            const int16_t bx,
00057                                            const uint32_t data);
00058 
00060   static L1GctInternHtMiss unpackerMissHtxHty(const uint16_t capBlock,
00061                                               const uint16_t capIndex,
00062                                               const int16_t bx,
00063                                               const uint32_t data);
00064 
00065 
00067   static L1GctInternHtMiss emulatorJetMissHt(const int htx,
00068                                              const int hty,
00069                                              const bool overFlow,
00070                                              const int16_t bx);
00071 
00073   static L1GctInternHtMiss emulatorMissHtxHty(const int htx,
00074                                               const int hty,
00075                                               const bool overFlow,
00076                                               const int16_t bx);
00077 
00079   static L1GctInternHtMiss emulatorMissHtx(const int htx,
00080                                            const bool overFlow,
00081                                            const int16_t bx);
00082 
00084   static L1GctInternHtMiss emulatorMissHty(const int hty,
00085                                            const bool overFlow,
00086                                            const int16_t bx);
00087 
00088 
00089   /* Metadata */
00090 
00092   L1GctInternHtMiss::L1GctInternHtMissType type() const { return type_; }
00093 
00095   uint16_t capBlock() const { return capBlock_; }
00096 
00098   uint16_t capIndex() const { return capIndex_; }
00099 
00101   int16_t bx() const { return bx_; }
00102 
00104   bool isThereHtx() const { return (type() == miss_htx || type() == miss_htx_and_hty || type() == jf_miss_htx_and_hty); }
00105 
00107   bool isThereHty() const { return (type() == miss_hty || type() == miss_htx_and_hty || type() == jf_miss_htx_and_hty); }
00108 
00109 
00110   /* Access to the actual data */
00111 
00113   uint32_t raw() const { return data_; }
00114 
00116   int16_t htx() const;
00117 
00119   int16_t hty() const;
00120 
00122   bool overflow() const;
00123 
00124 
00125   /* Operators */
00126 
00128   bool operator==(const L1GctInternHtMiss& rhs) const { return (type() == rhs.type() && raw() == rhs.raw()); }
00129   
00131   bool operator!=(const L1GctInternHtMiss& rhs) const { return !(*this == rhs); }  
00132 
00133 
00134  private:
00135 
00137   enum ShiftsAndMasks { kDoubleComponentHtyShift  = 16,        // Bit shift for Hty in miss_htx_and_hty
00138                         kSingleComponentOflowMask = (1 << 30), // Overflow bit mask in miss_htx or miss_hty
00139                         kDoubleComponentOflowMask = (1 << 15), // Overflow bit mask in miss_htx_and_hty
00140                         kSingleComponentHtMask    = 0xffff,    // Ht component mask in miss_htx or miss_hty
00141                         kDoubleComponentHtMask    = 0x3fff,    // Ht component mask in miss_htx_and_hty
00142                         kJetFinderComponentHtMask = 0x0fff,    // Ht component mask in jf_miss_htx_and_hty
00143                         kSingleComponentRawMask   = kSingleComponentOflowMask | kSingleComponentHtMask,    // To mask off all the non-data bits in raw data (e.g. BC0, etc)
00144                         kDoubleComponentRawMask   = (kDoubleComponentHtMask << kDoubleComponentHtyShift) |
00145                                                      kDoubleComponentOflowMask | kDoubleComponentHtMask };  
00146 
00147   /* Private ctors and methods */
00148 
00150   L1GctInternHtMiss(const L1GctInternHtMissType type,
00151                     const uint16_t capBlock,
00152                     const uint16_t capIndex,
00153                     const int16_t bx,
00154                     const uint32_t data);
00155 
00157 
00158   int16_t convert14BitTwosCompTo16Bit(const uint16_t data) const;
00159 
00160 
00161   /* Private data */
00162 
00164   L1GctInternHtMissType type_;
00165 
00166   // source of the data
00167   uint16_t capBlock_;
00168   uint16_t capIndex_;
00169   int16_t bx_;
00170 
00172   uint32_t data_;  
00173 };
00174 
00175 // Pretty-print operator for L1GctInternHtMiss
00176 std::ostream& operator<<(std::ostream& os, const L1GctInternHtMiss& rhs);
00177 
00178 #endif