CMS 3D CMS Logo

L1GctHFBitCounts.cc

Go to the documentation of this file.
00001 
00002 #include "DataFormats/L1GlobalCaloTrigger/interface/L1GctHFBitCounts.h"
00003 
00005 //static const unsigned L1GctHFBitCounts::N_COUNTS = 4;
00006 
00008 L1GctHFBitCounts::L1GctHFBitCounts() :
00009   capBlock_(0),
00010   capIndex_(0),
00011   bx_(0),
00012   data_(0) 
00013 { }
00014 
00015 
00017 L1GctHFBitCounts::~L1GctHFBitCounts()
00018 { }
00019 
00020 // named ctor for unpacker
00021 L1GctHFBitCounts L1GctHFBitCounts::fromConcHFBitCounts(const uint16_t capBlock,
00022                                                        const uint16_t capIndex,
00023                                                        const int16_t bx,
00024                                                        const uint32_t data)
00025 {
00026   L1GctHFBitCounts c;
00027   c.setCapBlock(capBlock);
00028   c.setCapIndex(capIndex);
00029   c.setBx(bx);
00030   c.setData(data&0xfff);
00031   return c;
00032 }
00033 
00034 
00035 // named ctor for GCT emulator
00036 L1GctHFBitCounts L1GctHFBitCounts::fromGctEmulator(const int16_t bx,
00037                                                    const uint16_t bitCountPosEtaRing1,
00038                                                    const uint16_t bitCountNegEtaRing1,
00039                                                    const uint16_t bitCountPosEtaRing2,
00040                                                    const uint16_t bitCountNegEtaRing2)
00041 {
00042   L1GctHFBitCounts c;
00043   c.setBx(bx);
00044   c.setBitCount(0, bitCountPosEtaRing1);
00045   c.setBitCount(1, bitCountNegEtaRing1);
00046   c.setBitCount(2, bitCountPosEtaRing2);
00047   c.setBitCount(3, bitCountNegEtaRing2);
00048   return c;  
00049 }
00050 
00051  
00058 uint16_t L1GctHFBitCounts::bitCount(unsigned const i) const {
00059   return (data_>>(i*3)) & 0x7;
00060 }
00061 
00062 
00064 bool L1GctHFBitCounts::operator==(const L1GctHFBitCounts& c) const {
00065   return (this->raw() == c.raw());
00066 }
00067 
00068 
00070 void L1GctHFBitCounts::setBitCount(unsigned i, uint16_t c) {
00071   data_ &= ~(0x7<<(i*3));
00072   data_ |= (c&0x7)<<(i*3);
00073 }
00074 
00075 
00076 std::ostream& operator<<(std::ostream& s, const L1GctHFBitCounts& cand) {
00077   s << "L1GctHFBitCounts :";
00078   s << " ring1 eta+=" << cand.bitCount(0);
00079   s << " ring1 eta-=" << cand.bitCount(1);
00080   s << " ring2 eta+=" << cand.bitCount(2);
00081   s << " ring2 eta-=" << cand.bitCount(3);
00082   s << std::endl;
00083   return s;
00084 }

Generated on Tue Jun 9 17:31:10 2009 for CMSSW by  doxygen 1.5.4