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/L1GctInternHFData.h"
0003 
0004 L1GctInternHFData::L1GctInternHFData() : type_(null), capBlock_(0), capIndex_(0), bx_(0), data_(0) {}
0005 
0006 /// destructor
0007 L1GctInternHFData::~L1GctInternHFData() {}
0008 
0009 L1GctInternHFData L1GctInternHFData::fromConcRingSums(const uint16_t capBlock,
0010                                                       const uint16_t capIndex,
0011                                                       const int16_t bx,
0012                                                       const uint32_t data) {
0013   L1GctInternHFData d;
0014   d.setType(conc_hf_ring_et_sums);
0015   d.setCapIndex(capIndex);
0016   d.setCapBlock(capBlock);
0017   d.setBx(bx);
0018   d.setData(data);
0019   return d;
0020 }
0021 
0022 L1GctInternHFData L1GctInternHFData::fromConcBitCounts(const uint16_t capBlock,
0023                                                        const uint16_t capIndex,
0024                                                        const int16_t bx,
0025                                                        const uint32_t data) {
0026   L1GctInternHFData d;
0027   d.setType(conc_hf_bit_counts);
0028   d.setCapIndex(capIndex);
0029   d.setCapBlock(capBlock);
0030   d.setBx(bx);
0031   for (unsigned i = 0; i < 4; ++i) {
0032     d.setCount(i, (data >> (6 * i)) & 0x3f);
0033   }
0034   return d;
0035 }
0036 
0037 L1GctInternHFData L1GctInternHFData::fromWheelRingSums(const uint16_t capBlock,
0038                                                        const uint16_t capIndex,
0039                                                        const int16_t bx,
0040                                                        const uint32_t data) {
0041   L1GctInternHFData d;
0042   d.setType(wheel_hf_ring_et_sums);
0043   d.setCapIndex(capIndex);
0044   d.setCapBlock(capBlock);
0045   d.setBx(bx);
0046   d.setData(data & 0xff);
0047   return d;
0048 }
0049 
0050 L1GctInternHFData L1GctInternHFData::fromWheelBitCounts(const uint16_t capBlock,
0051                                                         const uint16_t capIndex,
0052                                                         const int16_t bx,
0053                                                         const uint32_t data) {
0054   L1GctInternHFData d;
0055   d.setType(wheel_hf_bit_counts);
0056   d.setCapIndex(capIndex);
0057   d.setCapBlock(capBlock);
0058   d.setBx(bx);
0059   d.setCount(0, data & 0x3f);
0060   return d;
0061 }
0062 
0063 // get value
0064 uint16_t L1GctInternHFData::value(unsigned i) const { return (data_ >> (i * 8)) & 0xff; }
0065 
0066 /// get the et sums
0067 uint16_t L1GctInternHFData::et(unsigned i) const { return value(i); }
0068 
0069 /// get the counts
0070 uint16_t L1GctInternHFData::count(unsigned i) const { return value(i); }
0071 
0072 /// equality operator
0073 bool L1GctInternHFData::operator==(const L1GctInternHFData& c) const { return (this->raw() == c.raw()); }
0074 
0075 // set value
0076 void L1GctInternHFData::setValue(unsigned i, uint16_t val) {
0077   data_ &= ~(0xff << (i * 8));
0078   data_ |= (val & 0xff) << (i * 8);
0079 }
0080 
0081 /// set the sum
0082 void L1GctInternHFData::setEt(unsigned i, uint16_t et) { setValue(i, et); }
0083 
0084 /// set the count
0085 void L1GctInternHFData::setCount(unsigned i, uint16_t count) { setValue(i, count); }
0086 
0087 std::ostream& operator<<(std::ostream& s, const L1GctInternHFData& cand) {
0088   s << "L1GctInternHFData :";
0089 
0090   if (cand.empty()) {
0091     s << " empty";
0092   } else {
0093     if (cand.type() == L1GctInternHFData::conc_hf_ring_et_sums) {
0094       s << " type=conc_hf_ring_et_sums";
0095       s << " ring1 eta+=" << cand.et(0);
0096       s << " ring1 eta-=" << cand.et(1);
0097       s << " ring2 eta+=" << cand.et(2);
0098       s << " ring2 eta-=" << cand.et(3);
0099     } else if (cand.type() == L1GctInternHFData::conc_hf_bit_counts) {
0100       s << " type=conc_hf_bit_counts";
0101       s << " ring1 eta+=" << cand.count(0);
0102       s << " ring1 eta-=" << cand.count(1);
0103       s << " ring2 eta+=" << cand.count(2);
0104       s << " ring2 eta-=" << cand.count(3);
0105     } else if (cand.type() == L1GctInternHFData::wheel_hf_ring_et_sums) {
0106       s << " type=conc_hf_ring_et_sums";
0107       s << " Et sum=" << cand.et(0);
0108     } else if (cand.type() == L1GctInternHFData::wheel_hf_bit_counts) {
0109       s << " type=wheel_hf_bit_counts";
0110       s << " Bit count=" << cand.et(0);
0111     }
0112   }
0113   s << std::endl;
0114 
0115   s << std::hex << " cap block=" << cand.capBlock() << std::dec << " index=" << cand.capIndex() << " BX=" << cand.bx();
0116 
0117   return s;
0118 }