CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_13_patch3/src/DataFormats/L1GlobalCaloTrigger/src/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 {
00078   s << "L1GctHFBitCounts :";
00079 
00080   if (cand.empty()) {
00081     s << " empty";
00082   } else {    
00083     s << " ring1 eta+=" << cand.bitCount(0);
00084     s << " ring1 eta-=" << cand.bitCount(1);
00085     s << " ring2 eta+=" << cand.bitCount(2);
00086     s << " ring2 eta-=" << cand.bitCount(3);
00087     s << std::endl; 
00088   }
00089 
00090   s << std::hex << " cap block=" << cand.capBlock() << std::dec << " index=" << cand.capIndex() << " BX=" << cand.bx();
00091 
00092   return s;
00093 }