Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include "DataFormats/L1GlobalCaloTrigger/interface/L1GctInternEtSum.h"
0002 #include <cstdint>
0003 
0004 L1GctInternEtSum::L1GctInternEtSum() {}
0005 
0006 /// construct from individual quantities
0007 L1GctInternEtSum::L1GctInternEtSum(uint16_t capBlock, uint16_t capIndex, int16_t bx, uint32_t et, uint8_t oflow)
0008     : type_(null), capBlock_(capBlock), capIndex_(capIndex), bx_(bx), data_(0) {
0009   this->setEt(et);
0010   this->setOflow(oflow);
0011 }
0012 
0013 /// destructor
0014 L1GctInternEtSum::~L1GctInternEtSum() {}
0015 
0016 L1GctInternEtSum L1GctInternEtSum::fromJetTotEt(const uint16_t capBlock,
0017                                                 const uint16_t capIndex,
0018                                                 const int16_t bx,
0019                                                 const uint32_t data) {
0020   L1GctInternEtSum s;
0021   s.setEt(data & kTotEtOrHtMaxValue);
0022   s.setOflow((data >> kTotEtOrHtNBits) & 0x1);
0023   s.setCapBlock(capBlock);
0024   s.setCapIndex(capIndex);
0025   s.setBx(bx);
0026   s.setType(jet_tot_et);
0027   return s;
0028 }
0029 
0030 L1GctInternEtSum L1GctInternEtSum::fromJetTotHt(const uint16_t capBlock,
0031                                                 const uint16_t capIndex,
0032                                                 const int16_t bx,
0033                                                 const uint32_t data) {
0034   L1GctInternEtSum s;
0035   uint32_t word = data >> 16;
0036   s.setEt(word & kTotEtOrHtMaxValue);
0037   s.setOflow((word >> kTotEtOrHtNBits) & 0x1);
0038   s.setCapBlock(capBlock);
0039   s.setCapIndex(capIndex);
0040   s.setBx(bx);
0041   s.setType(jet_tot_ht);
0042   return s;
0043 }
0044 
0045 L1GctInternEtSum L1GctInternEtSum::fromJetMissEt(const uint16_t capBlock,
0046                                                  const uint16_t capIndex,
0047                                                  const int16_t bx,
0048                                                  const uint32_t data) {
0049   L1GctInternEtSum s;
0050   s.setEt(data & kJetMissEtMaxValue);
0051   s.setOflow((data >> kJetMissEtNBits) & 0x1);
0052   s.setCapBlock(capBlock);
0053   s.setCapIndex(capIndex);
0054   s.setBx(bx);
0055   s.setType(jet_miss_et);
0056   return s;
0057 }
0058 
0059 L1GctInternEtSum L1GctInternEtSum::fromTotalEtOrHt(const uint16_t capBlock,
0060                                                    const uint16_t capIndex,
0061                                                    const int16_t bx,
0062                                                    const uint32_t data) {
0063   L1GctInternEtSum s;
0064   s.setEt(data & kTotEtOrHtMaxValue);
0065   s.setOflow((data >> kTotEtOrHtNBits) & 0x1);
0066   s.setCapBlock(capBlock);
0067   s.setCapIndex(capIndex);
0068   s.setBx(bx);
0069   s.setType(total_et_or_ht);
0070   return s;
0071 }
0072 
0073 L1GctInternEtSum L1GctInternEtSum::fromMissEtxOrEty(const uint16_t capBlock,
0074                                                     const uint16_t capIndex,
0075                                                     const int16_t bx,
0076                                                     const uint32_t data) {
0077   L1GctInternEtSum s;
0078   s.setEt(data & kMissExOrEyNBits);
0079   s.setOflow(0);  // No over flow bit at the moment
0080   s.setCapBlock(capBlock);
0081   s.setCapIndex(capIndex);
0082   s.setBx(bx);
0083   s.setType(miss_etx_or_ety);
0084   return s;
0085 }
0086 
0087 /// Emulator constructors
0088 
0089 L1GctInternEtSum L1GctInternEtSum::fromEmulatorJetTotEt(unsigned totEt, bool overFlow, int16_t bx) {
0090   L1GctInternEtSum s;
0091   s.setEt(totEt & kTotEtOrHtMaxValue);
0092   if (overFlow || (totEt > kTotEtOrHtMaxValue))
0093     s.setOflow(0x1);
0094   s.setBx(bx);
0095   s.setType(jet_tot_et);
0096   return s;
0097 }
0098 
0099 L1GctInternEtSum L1GctInternEtSum::fromEmulatorJetTotHt(unsigned totHt, bool overFlow, int16_t bx) {
0100   L1GctInternEtSum s;
0101   s.setEt(totHt & kTotEtOrHtMaxValue);
0102   if (overFlow || (totHt > kTotEtOrHtMaxValue))
0103     s.setOflow(0x1);
0104   s.setBx(bx);
0105   s.setType(jet_tot_ht);
0106   return s;
0107 }
0108 
0109 L1GctInternEtSum L1GctInternEtSum::fromEmulatorJetMissEt(int missEtxOrEty, bool overFlow, int16_t bx) {
0110   L1GctInternEtSum s;
0111   s.setEt(missEtxOrEty & kJetMissEtMaxValue);
0112   if (overFlow || (missEtxOrEty >= kJetMissEtOFlowBit / 2) || (missEtxOrEty < -kJetMissEtOFlowBit / 2))
0113     s.setOflow(0x1);
0114   s.setBx(bx);
0115   s.setType(jet_miss_et);
0116   return s;
0117 }
0118 
0119 L1GctInternEtSum L1GctInternEtSum::fromEmulatorTotalEtOrHt(unsigned totEtOrHt, bool overFlow, int16_t bx) {
0120   L1GctInternEtSum s;
0121   s.setEt(totEtOrHt & kTotEtOrHtMaxValue);
0122   if (overFlow || (totEtOrHt > kTotEtOrHtMaxValue))
0123     s.setOflow(0x1);
0124   s.setBx(bx);
0125   s.setType(total_et_or_ht);
0126   return s;
0127 }
0128 
0129 L1GctInternEtSum L1GctInternEtSum::fromEmulatorMissEtxOrEty(int missEtxOrEty, bool overFlow, int16_t bx) {
0130   L1GctInternEtSum s;
0131   s.setEt(missEtxOrEty & kMissExOrEyMaxValue);
0132   if (overFlow || (missEtxOrEty >= kMissExOrEyOFlowBit / 2) || (missEtxOrEty < -kMissExOrEyOFlowBit / 2))
0133     s.setOflow(0x1);
0134   s.setBx(bx);
0135   s.setType(miss_etx_or_ety);
0136   return s;
0137 }
0138 
0139 /// equality operator
0140 bool L1GctInternEtSum::operator==(const L1GctInternEtSum& c) const { return (data_ == c.raw() && bx_ == c.bx()); }
0141 
0142 /// set value
0143 void L1GctInternEtSum::setValue(uint32_t val) {
0144   data_ &= 0x80000000;
0145   data_ |= val & 0x7ffffff;
0146 }
0147 
0148 /// set et
0149 void L1GctInternEtSum::setEt(uint32_t et) { setValue(et); }
0150 
0151 /// set count
0152 void L1GctInternEtSum::setCount(uint32_t count) { setValue(count); }
0153 
0154 /// set overflow bit
0155 void L1GctInternEtSum::setOflow(uint8_t oflow) {
0156   data_ &= 0x7ffffff;
0157   data_ |= (oflow & 0x1) << 31;
0158 }
0159 
0160 /// Pretty-print operator for L1GctInternEtSum
0161 std::ostream& operator<<(std::ostream& s, const L1GctInternEtSum& c) {
0162   s << "L1GctInternEtSum : ";
0163 
0164   if (c.type() == L1GctInternEtSum::jet_miss_et) {
0165     s << " type=jet_miss_et";
0166   } else if (c.type() == L1GctInternEtSum::jet_tot_et) {
0167     s << " type=jet_tot_et";
0168   } else if (c.type() == L1GctInternEtSum::jet_tot_ht) {
0169     s << " type=jet_tot_ht";
0170   } else if (c.type() == L1GctInternEtSum::total_et_or_ht) {
0171     s << " type=total_et_or_ht";
0172   } else if (c.type() == L1GctInternEtSum::miss_etx_or_ety) {
0173     s << " type=miss_etx_or_ety";
0174   }
0175 
0176   if (c.empty()) {
0177     s << " empty!";
0178   } else {
0179     s << " mag=" << c.et();
0180     if (c.oflow()) {
0181       s << " overflow set";
0182     }
0183   }
0184 
0185   s << " cap block=" << std::hex << c.capBlock();
0186   s << " index=" << std::dec << c.capIndex();
0187   s << " BX=" << c.bx();
0188 
0189   return s;
0190 }