Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 
0002 #include "L1Trigger/GlobalCaloTrigger/interface/L1GctJetEtCalibrationLut.h"
0003 
0004 #include "CondFormats/L1TObjects/interface/L1GctJetFinderParams.h"
0005 #include "CondFormats/L1TObjects/interface/L1CaloEtScale.h"
0006 
0007 //DEFINE STATICS
0008 const int L1GctJetEtCalibrationLut::NAddress = JET_ET_CAL_LUT_ADD_BITS;
0009 const int L1GctJetEtCalibrationLut::NData = JET_ET_CAL_LUT_DAT_BITS;
0010 const unsigned L1GctJetEtCalibrationLut::JET_ENERGY_BITWIDTH = 10;
0011 
0012 L1GctJetEtCalibrationLut::L1GctJetEtCalibrationLut() : L1GctLut<NAddress, NData>() {}
0013 
0014 L1GctJetEtCalibrationLut::~L1GctJetEtCalibrationLut() {}
0015 
0016 void L1GctJetEtCalibrationLut::setFunction(const L1GctJetFinderParams* const lutfn) {
0017   m_lutFunction = lutfn;
0018   m_setupOk = (lutfn != nullptr);
0019 }
0020 
0021 void L1GctJetEtCalibrationLut::setOutputEtScale(const L1CaloEtScale* const scale) { m_outputEtScale = scale; }
0022 
0023 void L1GctJetEtCalibrationLut::setEtaBin(const unsigned eta) {
0024   static const unsigned nEtaBits = 4;
0025   static const uint8_t etaMask = static_cast<uint8_t>((1 << nEtaBits) - 1);
0026   m_etaBin = static_cast<uint8_t>(eta) & etaMask;
0027 }
0028 
0029 uint16_t L1GctJetEtCalibrationLut::value(const uint16_t lutAddress) const {
0030   static const uint16_t maxEtMask = static_cast<uint16_t>((1 << JET_ENERGY_BITWIDTH) - 1);
0031   static const uint16_t tauBitMask = static_cast<uint16_t>(1 << (JET_ENERGY_BITWIDTH));
0032   static const uint16_t ovrFlowOut = 0x3f;
0033   uint16_t jetEt = lutAddress & maxEtMask;
0034   // Check for saturation
0035   if (jetEt == maxEtMask) {
0036     return ovrFlowOut;
0037   } else {
0038     double uncoEt = static_cast<double>(jetEt) * m_outputEtScale->linearLsb();
0039     bool tauVeto = ((lutAddress & tauBitMask) == 0);
0040 
0041     double corrEt = m_lutFunction->correctedEtGeV(uncoEt, etaBin(), tauVeto);
0042     return m_outputEtScale->rank(corrEt);
0043   }
0044 }
0045 
0046 std::ostream& operator<<(std::ostream& os, const L1GctJetEtCalibrationLut& lut) {
0047   os << std::endl;
0048   os << "==================================================" << std::endl;
0049   os << "===Level-1 Trigger:  GCT Jet Et Calibration Lut===" << std::endl;
0050   os << "==================================================" << std::endl;
0051   os << "===Parameter settings for eta bin " << lut.etaBin() << "===" << std::endl;
0052   os << *lut.getFunction() << std::endl;
0053   os << "\n===Lookup table contents===\n" << std::endl;
0054   const L1GctLut<L1GctJetEtCalibrationLut::NAddress, L1GctJetEtCalibrationLut::NData>* temp = &lut;
0055   os << *temp;
0056   return os;
0057 }
0058 
0059 template class L1GctLut<L1GctJetEtCalibrationLut::NAddress, L1GctJetEtCalibrationLut::NData>;