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