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