Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:19:52

0001 #include "L1Trigger/GlobalCaloTrigger/interface/L1GctJet.h"
0002 #include "L1Trigger/GlobalCaloTrigger/interface/L1GctJetEtCalibrationLut.h"
0003 
0004 #include "DataFormats/L1GlobalCaloTrigger/interface/L1GctJetCand.h"
0005 
0006 L1GctJet::L1GctJet(const uint16_t rawsum,
0007                    const unsigned eta,
0008                    const unsigned phi,
0009                    const bool overFlow,
0010                    const bool forwardJet,
0011                    const bool tauVeto,
0012                    const int16_t bx)
0013     : m_rawsum(rawsum & kRawsumMaxValue),
0014       m_id(eta, phi),
0015       m_overFlow(overFlow || (rawsum > kRawsumMaxValue)),
0016       m_forwardJet(forwardJet),
0017       m_tauVeto(tauVeto || forwardJet),
0018       m_bx(bx) {}
0019 
0020 L1GctJet::~L1GctJet() {}
0021 
0022 std::ostream& operator<<(std::ostream& os, const L1GctJet& cand) {
0023   os << "L1 Gct jet";
0024   os << " energy sum " << cand.m_rawsum;
0025   if (cand.overFlow()) {
0026     os << ", overflow bit set;";
0027   }
0028   os << " Eta " << cand.globalEta();
0029   os << " Phi " << cand.globalPhi();
0030   if (cand.isForwardJet()) {
0031     os << ", Forward jet";
0032   }
0033   if (cand.isCentralJet()) {
0034     os << ", Central jet";
0035   }
0036   if (cand.isTauJet()) {
0037     os << ", Tau jet";
0038   }
0039   if (cand.isNullJet()) {
0040     os << ", Null jet";
0041   }
0042 
0043   return os;
0044 }
0045 
0046 /// test whether two jets are the same
0047 bool L1GctJet::operator==(const L1GctJet& cand) const {
0048   bool result = true;
0049   result &= (this->rawsum() == cand.rawsum());
0050   result &= (this->overFlow() == cand.overFlow());
0051   result &= (this->isForwardJet() == cand.isForwardJet());
0052   result &= (this->tauVeto() == cand.tauVeto());
0053   result &= (this->globalEta() == cand.globalEta());
0054   result &= (this->globalPhi() == cand.globalPhi());
0055   result |= (this->isNullJet() && cand.isNullJet());
0056   return result;
0057 }
0058 
0059 /// test whether two jets are different
0060 bool L1GctJet::operator!=(const L1GctJet& cand) const {
0061   bool result = false;
0062   result |= !(this->rawsum() == cand.rawsum());
0063   result |= !(this->overFlow() == cand.overFlow());
0064   result |= !(this->isForwardJet() == cand.isForwardJet());
0065   result |= !(this->tauVeto() == cand.tauVeto());
0066   result |= !(this->globalEta() == cand.globalEta());
0067   result |= !(this->globalPhi() == cand.globalPhi());
0068   result &= !(this->isNullJet() && cand.isNullJet());
0069   return result;
0070 }
0071 
0072 void L1GctJet::setupJet(const uint16_t rawsum,
0073                         const unsigned eta,
0074                         const unsigned phi,
0075                         const bool overFlow,
0076                         const bool forwardJet,
0077                         const bool tauVeto,
0078                         const int16_t bx) {
0079   L1CaloRegionDetId temp(eta, phi);
0080   m_rawsum = rawsum & kRawsumMaxValue;
0081   m_id = temp;
0082   m_overFlow = (overFlow || rawsum > kRawsumMaxValue);
0083   m_forwardJet = forwardJet;
0084   m_tauVeto = tauVeto || forwardJet;
0085   m_bx = bx;
0086 }
0087 
0088 /// eta value as encoded in hardware at the GCT output
0089 unsigned L1GctJet::hwEta() const {
0090   // Force into 4 bits.
0091   // Count eta bins separately for central and forward jets. Set MSB to indicate the Wheel
0092   return (((m_id.rctEta() % 7) & 0x7) | (m_id.ieta() < 11 ? 0x8 : 0));
0093 }
0094 
0095 /// phi value as encoded in hardware at the GCT output
0096 unsigned L1GctJet::hwPhi() const {
0097   // Force into 5 bits.
0098   return m_id.iphi() & 0x1f;
0099 }
0100 
0101 /// Function to convert from internal format to external jet candidates at the output of the jetFinder
0102 L1GctJetCand L1GctJet::jetCand(const lutPtr lut) const {
0103   return L1GctJetCand(rank(lut), hwPhi(), hwEta(), isTauJet(), isForwardJet(), (uint16_t)0, (uint16_t)0, m_bx);
0104 }
0105 
0106 /// Function to convert from internal format to external jet candidates at the output of the jetFinder
0107 L1GctJetCand L1GctJet::jetCand(const std::vector<lutPtr>& luts) const {
0108   L1GctJetCand result;
0109   if (rctEta() < luts.size())
0110     result = jetCand(luts.at(rctEta()));
0111   return result;
0112 }
0113 
0114 /// The two separate Lut outputs
0115 uint16_t L1GctJet::rank(const lutPtr lut) const { return lutValue(lut); }
0116 
0117 unsigned L1GctJet::calibratedEt(const lutPtr lut) const { return m_rawsum; }
0118 
0119 // internal function to find the lut contents for a jet
0120 uint16_t L1GctJet::lutValue(const lutPtr lut) const {
0121   uint16_t result;
0122   if (m_overFlow) {
0123     // Set output values to maximum
0124     result = 0x3f;
0125   } else {
0126     unsigned addrBits = m_rawsum;
0127     // Set the MSB for tau jets
0128     if (!m_tauVeto && !m_forwardJet) {
0129       addrBits |= 1 << (L1GctJetEtCalibrationLut::JET_ENERGY_BITWIDTH);
0130     }
0131     uint16_t address = static_cast<uint16_t>(addrBits);
0132     result = lut->lutValue(address);
0133   }
0134   return result;
0135 }