Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:53:47

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