File indexing completed on 2024-04-06 12:04:27
0001
0002 #include "DataFormats/L1GlobalCaloTrigger/interface/L1GctHFBitCounts.h"
0003
0004
0005
0006
0007
0008 L1GctHFBitCounts::L1GctHFBitCounts() : capBlock_(0), capIndex_(0), bx_(0), data_(0) {}
0009
0010
0011 L1GctHFBitCounts::~L1GctHFBitCounts() {}
0012
0013
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
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
0042
0043
0044
0045
0046
0047 uint16_t L1GctHFBitCounts::bitCount(unsigned const i) const { return (data_ >> (i * 3)) & 0x7; }
0048
0049
0050 bool L1GctHFBitCounts::operator==(const L1GctHFBitCounts& c) const { return (this->raw() == c.raw()); }
0051
0052
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 }