Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:04:27

0001 
0002 #include "DataFormats/L1GlobalCaloTrigger/interface/L1GctHFBitCounts.h"
0003 
0004 /// set static consts
0005 //static const unsigned L1GctHFBitCounts::N_COUNTS = 4;
0006 
0007 /// default constructor (for vector initialisation etc.)
0008 L1GctHFBitCounts::L1GctHFBitCounts() : capBlock_(0), capIndex_(0), bx_(0), data_(0) {}
0009 
0010 /// destructor
0011 L1GctHFBitCounts::~L1GctHFBitCounts() {}
0012 
0013 // named ctor for unpacker
0014 L1GctHFBitCounts L1GctHFBitCounts::fromConcHFBitCounts(const uint16_t capBlock,
0015                                                        const uint16_t capIndex,
0016                                                        const int16_t bx,
0017                                                        const uint32_t data) {
0018   L1GctHFBitCounts c;
0019   c.setCapBlock(capBlock);
0020   c.setCapIndex(capIndex);
0021   c.setBx(bx);
0022   c.setData(data & 0xfff);
0023   return c;
0024 }
0025 
0026 // named ctor for GCT emulator
0027 L1GctHFBitCounts L1GctHFBitCounts::fromGctEmulator(const int16_t bx,
0028                                                    const uint16_t bitCountPosEtaRing1,
0029                                                    const uint16_t bitCountNegEtaRing1,
0030                                                    const uint16_t bitCountPosEtaRing2,
0031                                                    const uint16_t bitCountNegEtaRing2) {
0032   L1GctHFBitCounts c;
0033   c.setBx(bx);
0034   c.setBitCount(0, bitCountPosEtaRing1);
0035   c.setBitCount(1, bitCountNegEtaRing1);
0036   c.setBitCount(2, bitCountPosEtaRing2);
0037   c.setBitCount(3, bitCountNegEtaRing2);
0038   return c;
0039 }
0040 
0041 /// get a bit count
0042 ///  index : sum
0043 ///    0   :  Ring 1 Positive Rapidity HF bit count
0044 ///    1   :  Ring 1 Negative Rapidity HF bit count
0045 ///    2   :  Ring 2 Positive Rapidity HF bit count
0046 ///    3   :  Ring 2 Negative Rapidity HF bit count
0047 uint16_t L1GctHFBitCounts::bitCount(unsigned const i) const { return (data_ >> (i * 3)) & 0x7; }
0048 
0049 /// equality operator
0050 bool L1GctHFBitCounts::operator==(const L1GctHFBitCounts& c) const { return (this->raw() == c.raw()); }
0051 
0052 /// set a sum
0053 void L1GctHFBitCounts::setBitCount(unsigned i, uint16_t c) {
0054   data_ &= ~(0x7 << (i * 3));
0055   data_ |= (c & 0x7) << (i * 3);
0056 }
0057 
0058 std::ostream& operator<<(std::ostream& s, const L1GctHFBitCounts& cand) {
0059   s << "L1GctHFBitCounts :";
0060 
0061   if (cand.empty()) {
0062     s << " empty";
0063   } else {
0064     s << " ring1 eta+=" << cand.bitCount(0);
0065     s << " ring1 eta-=" << cand.bitCount(1);
0066     s << " ring2 eta+=" << cand.bitCount(2);
0067     s << " ring2 eta-=" << cand.bitCount(3);
0068     s << std::endl;
0069   }
0070 
0071   s << std::hex << " cap block=" << cand.capBlock() << std::dec << " index=" << cand.capIndex() << " BX=" << cand.bx();
0072 
0073   return s;
0074 }