Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-11-15 23:40:40

0001 //-------------------------------------------------
0002 //
0003 //   Class: L1MuBMEUX
0004 //
0005 //   Description: Extrapolator
0006 //
0007 //
0008 //
0009 //   Author :
0010 //   N. Neumeister            CERN EP
0011 //
0012 //--------------------------------------------------
0013 
0014 //-----------------------
0015 // This Class's Header --
0016 //-----------------------
0017 
0018 #include "L1Trigger/L1TMuonBarrel/src/L1MuBMEUX.h"
0019 
0020 //---------------
0021 // C++ Headers --
0022 //---------------
0023 
0024 #include <iostream>
0025 
0026 //-------------------------------
0027 // Collaborating Class Headers --
0028 //-------------------------------
0029 
0030 #include "L1Trigger/L1TMuonBarrel/interface/L1MuBMTFConfig.h"
0031 #include "L1Trigger/L1TMuonBarrel/src/L1MuBMSectorProcessor.h"
0032 #include "L1Trigger/L1TMuonBarrel/src/L1MuBMSEU.h"
0033 #include "DataFormats/L1TMuon/interface/L1MuBMTrackSegPhi.h"
0034 
0035 #include "CondFormats/L1TObjects/interface/L1MuDTExtLut.h"
0036 #include "CondFormats/DataRecord/interface/L1MuDTExtLutRcd.h"
0037 #include "CondFormats/L1TObjects/interface/L1MuDTTFParameters.h"
0038 #include "CondFormats/DataRecord/interface/L1MuDTTFParametersRcd.h"
0039 #include "CondFormats/L1TObjects/interface/L1MuDTExtParam.h"
0040 #include "L1Trigger/L1TCommon/interface/BitShift.h"
0041 
0042 using namespace std;
0043 
0044 // --------------------------------
0045 //       class L1MuBMEUX
0046 //---------------------------------
0047 
0048 //----------------
0049 // Constructors --
0050 //----------------
0051 
0052 L1MuBMEUX::L1MuBMEUX(const L1MuBMSectorProcessor& sp, const L1MuBMSEU& seu, int id)
0053     : m_sp(sp),
0054       m_seu(seu),
0055       m_id(id),
0056       m_result(false),
0057       m_quality(0),
0058       m_address(15),
0059       m_start(nullptr),
0060       m_target(nullptr),
0061       theExtFilter(m_sp.config().getExtTSFilter()),
0062       nbit_phi(m_sp.config().getNbitsExtPhi()),
0063       nbit_phib(m_sp.config().getNbitsExtPhib()) {}
0064 
0065 //--------------
0066 // Destructor --
0067 //--------------
0068 
0069 L1MuBMEUX::~L1MuBMEUX() {}
0070 
0071 //--------------
0072 // Operations --
0073 //--------------
0074 
0075 //
0076 // Equal operator
0077 //
0078 bool L1MuBMEUX::operator==(const L1MuBMEUX& eux) const {
0079   if (m_id != eux.id())
0080     return false;
0081   if (m_result != eux.result())
0082     return false;
0083   if (m_quality != eux.quality())
0084     return false;
0085   if (m_address != eux.address())
0086     return false;
0087   return true;
0088 }
0089 
0090 //
0091 // run EUX
0092 //
0093 void L1MuBMEUX::run(const L1TMuonBarrelParams& bmtfParams) {
0094   pars = bmtfParams.l1mudttfparams;
0095   theExtLUTs = new L1MuBMLUTHandler(bmtfParams);  ///< ext look-up tables
0096 
0097   if (m_sp.config().Debug(4))
0098     cout << "Run EUX " << m_id << endl;
0099   if (m_sp.config().Debug(4))
0100     cout << "start :  " << *m_start << endl;
0101   if (m_sp.config().Debug(4))
0102     cout << "target : " << *m_target << endl;
0103 
0104   if (m_start == nullptr || m_target == nullptr) {
0105     if (m_sp.config().Debug(4))
0106       cout << "Error: EUX has no data loaded" << endl;
0107     delete theExtLUTs;
0108     return;
0109   }
0110 
0111   // start sector
0112   int sector_st = m_start->sector();
0113 
0114   // target sector
0115   int sector_ta = m_target->sector();
0116 
0117   // get index of look-up table
0118   int lut_idx = m_seu.ext();
0119   if (abs(m_target->wheel()) == 3) {
0120     switch (m_seu.ext()) {
0121       case EX13: {
0122         lut_idx = EX15;
0123         break;
0124       }
0125       case EX23: {
0126         lut_idx = EX25;
0127         break;
0128       }
0129       default: {
0130         lut_idx = m_seu.ext();
0131         break;
0132       }
0133     }
0134   }
0135 
0136   if (m_sp.config().Debug(5))
0137     cout << "EUX : using look-up table : " << static_cast<Extrapolation>(lut_idx) << endl;
0138 
0139   // Extrapolation TS quality filter
0140   int qcut = 0;
0141   if (m_seu.ext() == EX12)
0142     qcut = pars.get_soc_qcut_st1(m_sp.id().wheel(), m_sp.id().sector());
0143   if (m_seu.ext() == EX13)
0144     qcut = pars.get_soc_qcut_st1(m_sp.id().wheel(), m_sp.id().sector());
0145   if (m_seu.ext() == EX14)
0146     qcut = pars.get_soc_qcut_st1(m_sp.id().wheel(), m_sp.id().sector());
0147   if (m_seu.ext() == EX21)
0148     qcut = pars.get_soc_qcut_st2(m_sp.id().wheel(), m_sp.id().sector());
0149   if (m_seu.ext() == EX23)
0150     qcut = pars.get_soc_qcut_st2(m_sp.id().wheel(), m_sp.id().sector());
0151   if (m_seu.ext() == EX24)
0152     qcut = pars.get_soc_qcut_st2(m_sp.id().wheel(), m_sp.id().sector());
0153   if (m_seu.ext() == EX34)
0154     qcut = pars.get_soc_qcut_st4(m_sp.id().wheel(), m_sp.id().sector());
0155 
0156   if (m_start->quality() < qcut) {
0157     delete theExtLUTs;
0158     return;
0159   }
0160   // calculate bit shift
0161   int sh_phi = 12 - nbit_phi;
0162   int sh_phib = 10 - nbit_phib;
0163 
0164   int phi_target = m_target->phi() >> sh_phi;
0165   int phi_start = m_start->phi() >> sh_phi;
0166   int phib_start = l1t::bitShift((m_start->phib() >> sh_phib), sh_phib);
0167   if (phib_start < 0)
0168     phib_start += (1 << sh_phib) - 1;
0169 
0170   // compute difference in phi
0171   int diff = phi_target - phi_start;
0172 
0173   // get low and high values from look-up table
0174   // and add offset (30 degrees ) for extrapolation to adjacent sector
0175   int offset = -2144 >> sh_phi;
0176   offset *= sec_mod(sector_ta - sector_st);
0177   int low = theExtLUTs->getLow(lut_idx, phib_start);
0178   int high = theExtLUTs->getHigh(lut_idx, phib_start);
0179   if (low < 0)
0180     low += (1 << sh_phi) - 1;
0181   if (high < 0)
0182     high += (1 << sh_phi) - 1;
0183   low = (low >> sh_phi) + offset;
0184   high = (high >> sh_phi) + offset;
0185 
0186   int phi_offset = phi_target - offset;
0187   if ((lut_idx == EX34) || (lut_idx == EX21))
0188     phi_offset = phi_start + offset;
0189   if (phi_offset >= (1 << (nbit_phi - 1)) - 1) {
0190     delete theExtLUTs;
0191     return;
0192   }
0193   if (phi_offset < -(1 << (nbit_phi - 1)) + 1) {
0194     delete theExtLUTs;
0195     return;
0196   }
0197   // is phi-difference within the extrapolation window?
0198   bool openlut = pars.get_soc_openlut_extr(m_sp.id().wheel(), m_sp.id().sector());
0199   if ((diff >= low && diff <= high) || m_sp.config().getopenLUTs() || openlut) {
0200     m_result = true;
0201     int qual_st = m_start->quality();
0202     int qual_ta = m_target->quality();
0203     if (m_seu.ext() == EX34 || m_seu.ext() == EX21) {
0204       m_quality = (qual_st == 7) ? 0 : qual_st + 1;
0205     } else {
0206       m_quality = (qual_ta == 7) ? 0 : qual_ta + 1;
0207     }
0208     m_address = m_id;
0209   }
0210   delete theExtLUTs;
0211   if (m_sp.config().Debug(5))
0212     cout << "diff : " << low << " " << diff << " " << high << " : " << m_result << " " << endl;
0213 }
0214 
0215 //
0216 // load data into EUX
0217 //
0218 void L1MuBMEUX::load(const L1MuBMTrackSegPhi* start_ts, const L1MuBMTrackSegPhi* target_ts) {
0219   m_start = start_ts;
0220   m_target = target_ts;
0221 
0222   // in case of EX34 and EX21 exchange start and target
0223   if ((m_seu.ext() == EX34) || (m_seu.ext() == EX21)) {
0224     m_start = target_ts;
0225     m_target = start_ts;
0226   }
0227 }
0228 
0229 //
0230 // reset this EUX
0231 //
0232 
0233 void L1MuBMEUX::reset() {
0234   m_result = false;
0235   m_quality = 0;
0236   m_address = 15;
0237 
0238   m_start = nullptr;
0239   m_target = nullptr;
0240 }
0241 
0242 //
0243 // return pointer to start and target track segment
0244 //
0245 pair<const L1MuBMTrackSegPhi*, const L1MuBMTrackSegPhi*> L1MuBMEUX::ts() const {
0246   return pair<const L1MuBMTrackSegPhi*, const L1MuBMTrackSegPhi*>(m_start, m_target);
0247 }
0248 
0249 //
0250 // symmetric modulo function for sectors
0251 // output values in the range -6 to +5
0252 //
0253 int L1MuBMEUX::sec_mod(int sector) const {
0254   int new_sector = sector % 12;
0255   if (new_sector >= 6)
0256     new_sector = new_sector - 12;
0257   if (new_sector < -6)
0258     new_sector = new_sector + 12;
0259 
0260   return new_sector;
0261 }