CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_3/src/DataFormats/L1GlobalCaloTrigger/src/L1GctInternHtMiss.cc

Go to the documentation of this file.
00001 #include "DataFormats/L1GlobalCaloTrigger/interface/L1GctInternHtMiss.h"
00002 
00003 
00004 // PUBLIC METHODS
00005 
00006 // Default ctor
00007 L1GctInternHtMiss::L1GctInternHtMiss():
00008   type_(nulltype),
00009   capBlock_(0),
00010   capIndex_(0),
00011   bx_(0),
00012   data_(0)
00013 {
00014 }
00015 
00016 // Destructor
00017 L1GctInternHtMiss::~L1GctInternHtMiss() {}
00018 
00019 // Named ctor for making missing Ht x-component object from unpacker raw data.
00020 L1GctInternHtMiss L1GctInternHtMiss::unpackerMissHtx(const uint16_t capBlock,
00021                                                      const uint16_t capIndex,
00022                                                      const int16_t bx,
00023                                                      const uint32_t data)
00024 {
00025   return L1GctInternHtMiss(miss_htx, capBlock, capIndex, bx, data & kSingleComponentRawMask);
00026 }
00027 
00028 // Named ctor for making missing Ht y-component object from unpacker raw data.
00029 L1GctInternHtMiss L1GctInternHtMiss::unpackerMissHty(const uint16_t capBlock,
00030                                                      const uint16_t capIndex,
00031                                                      const int16_t bx,
00032                                                      const uint32_t data)
00033 {
00034   return L1GctInternHtMiss(miss_hty, capBlock, capIndex, bx, data & kSingleComponentRawMask);
00035 }
00036 
00037 // Named ctor for making missing Ht x & y components object from unpacker raw data.
00038 L1GctInternHtMiss L1GctInternHtMiss::unpackerMissHtxHty(const uint16_t capBlock,
00039                                                         const uint16_t capIndex,
00040                                                         const int16_t bx,
00041                                                         const uint32_t data)
00042 {
00043   return L1GctInternHtMiss(miss_htx_and_hty, capBlock, capIndex, bx, data & kDoubleComponentRawMask);
00044 }
00045 
00046 // Named ctor for making missing Ht x & y components object from unpacker raw data.
00047 L1GctInternHtMiss L1GctInternHtMiss::emulatorJetMissHt(const int htx,
00048                                                        const int hty,
00049                                                        const bool overFlow,
00050                                                        const int16_t bx)
00051 {
00052   int32_t xdata = (htx & kJetFinderComponentHtMask);
00053   int32_t ydata = (hty & kJetFinderComponentHtMask) << kDoubleComponentHtyShift;
00054   int32_t odata = 0;
00055   if (overFlow
00056       || (htx >= kJetFinderComponentHtMask/2) || (htx < -kJetFinderComponentHtMask/2)
00057       || (hty >= kJetFinderComponentHtMask/2) || (hty < -kJetFinderComponentHtMask/2) )
00058     odata = kDoubleComponentOflowMask;
00059   return L1GctInternHtMiss(jf_miss_htx_and_hty, 0, 0, bx, xdata | ydata | odata);
00060 }
00061 
00063 L1GctInternHtMiss L1GctInternHtMiss::emulatorMissHtxHty(const int htx,
00064                                                         const int hty,
00065                                                         const bool overFlow,
00066                                                         const int16_t bx)
00067 {
00068   int32_t xdata = (htx & kDoubleComponentHtMask);
00069   int32_t ydata = (hty & kDoubleComponentHtMask) << kDoubleComponentHtyShift;
00070   int32_t odata = 0;
00071   if (overFlow
00072       || (htx >= kDoubleComponentHtMask/2) || (htx < -kDoubleComponentHtMask/2)
00073       || (hty >= kDoubleComponentHtMask/2) || (hty < -kDoubleComponentHtMask/2) )
00074     odata = kDoubleComponentOflowMask;
00075   return L1GctInternHtMiss(miss_htx_and_hty, 0, 0, bx, xdata | ydata | odata);
00076 }
00077 
00079 L1GctInternHtMiss L1GctInternHtMiss::emulatorMissHtx(const int htx,
00080                                                      const bool overFlow,
00081                                                      const int16_t bx)
00082 {
00083   int32_t xdata = (htx & kSingleComponentHtMask);
00084   int32_t odata = 0;
00085   if (overFlow
00086       || (htx >= kSingleComponentHtMask/2) || (htx < -kSingleComponentHtMask/2) )
00087     odata = kSingleComponentOflowMask;
00088   return L1GctInternHtMiss(miss_htx, 0, 0, bx, xdata | odata);
00089 }
00090 
00091 
00093 L1GctInternHtMiss L1GctInternHtMiss::emulatorMissHty(const int hty,
00094                                                      const bool overFlow,
00095                                                      const int16_t bx)
00096 {
00097   int32_t ydata = (hty & kSingleComponentHtMask);
00098   int32_t odata = 0;
00099   if (overFlow
00100       || (hty >= kSingleComponentHtMask/2) || (hty < -kSingleComponentHtMask/2) )
00101     odata = kSingleComponentOflowMask;
00102   return L1GctInternHtMiss(miss_hty, 0, 0, bx, ydata | odata);
00103 }
00104 
00105 
00106 // Get Ht x-component
00107 int16_t L1GctInternHtMiss::htx() const
00108 {
00109   if(type() == miss_htx)
00110   { 
00111     return static_cast<int16_t>(raw() & kSingleComponentHtMask);
00112   }
00113   if(type() == miss_htx_and_hty)
00114   {
00115     return convert14BitTwosCompTo16Bit(raw() & kDoubleComponentHtMask);
00116   }
00117   return 0;
00118 }
00119 
00120 // Get Ht y-component
00121 int16_t L1GctInternHtMiss::hty() const
00122 {
00123   if(type() == miss_hty)
00124   {
00125     return static_cast<int16_t>(raw() & kSingleComponentHtMask);
00126   }
00127   if(type() == miss_htx_and_hty)
00128   {
00129     return convert14BitTwosCompTo16Bit((raw() >> kDoubleComponentHtyShift) & kDoubleComponentHtMask);
00130   }
00131   return 0;
00132 }
00133 
00134 // Get overflow
00135 bool L1GctInternHtMiss::overflow() const
00136 {
00137   if(type() == miss_htx || type() == miss_hty) { return (raw() & kSingleComponentOflowMask) != 0; }
00138   if(type() == miss_htx_and_hty) { return (raw() & kDoubleComponentOflowMask) != 0; }
00139   return false;
00140 }
00141 
00142 
00143 // PRIVATE METHODS
00144 
00145 L1GctInternHtMiss::L1GctInternHtMiss(const L1GctInternHtMissType type,
00146                                      const uint16_t capBlock,
00147                                      const uint16_t capIndex,
00148                                      const int16_t bx,
00149                                      const uint32_t data):
00150   type_(type),
00151   capBlock_(capBlock),
00152   capIndex_(capIndex),
00153   bx_(bx),
00154   data_(data)
00155 {
00156 }
00157 
00158 int16_t L1GctInternHtMiss::convert14BitTwosCompTo16Bit(const uint16_t data) const
00159 {
00160   // If bit 13 is high, set bits 13, 14, 15 high.
00161   if((data & 0x2000) != 0) { return static_cast<int16_t>(data | 0xe000); }
00162   
00163   // Else, bit 13 must be low, so set bits 13, 14, 15 low.
00164   return static_cast<int16_t>(data & 0x1fff);
00165 }
00166 
00167 
00168 // PRETTY PRINTOUT OPERATOR
00169 
00170 std::ostream& operator<<(std::ostream& os, const L1GctInternHtMiss& rhs)
00171 {
00172   os << " L1GctInternHtMiss:  htx=";
00173   if(rhs.isThereHtx()) { os << rhs.htx(); }
00174   else { os << "n/a"; }
00175   os << ", hty=";
00176   if(rhs.isThereHty()) { os << rhs.hty(); }
00177   else { os << "n/a"; }
00178   if (rhs.overflow()) { os << "; overflow set"; }
00179   os << "; cap block=0x" << std::hex << rhs.capBlock() << std::dec
00180      << ", index=" << rhs.capIndex()
00181      << ", BX=" << rhs.bx();
00182   return os;
00183 }