File indexing completed on 2024-04-06 12:20:51
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021 #include "L1Trigger/L1TMuonBarrel/interface/L1MuBMLUTHandler.h"
0022
0023
0024
0025
0026
0027 #include <iostream>
0028 #include <ostream>
0029 #include <iomanip>
0030 #include <string>
0031 #include <cstdlib>
0032 #include <cstdlib> /* std::getenv */
0033
0034
0035
0036
0037
0038 #include "FWCore/ParameterSet/interface/FileInPath.h"
0039 #include "CondFormats/L1TObjects/interface/DTTFBitArray.h"
0040 #include "CondFormats/L1TObjects/interface/L1TriggerLutFile.h"
0041
0042 using namespace std;
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052 L1MuBMLUTHandler::L1MuBMLUTHandler(const L1TMuonBarrelParams &l1params) {
0053
0054 l1tbmparams = new L1TMuonBarrelParamsAllPublic(l1params);
0055 }
0056
0057
0058
0059
0060
0061 L1MuBMLUTHandler::~L1MuBMLUTHandler() { delete l1tbmparams; }
0062
0063
0064
0065
0066
0067
0068
0069
0070 void L1MuBMLUTHandler::print_pta_lut() const {
0071 int nbit_phi = l1tbmparams->get_PT_Assignment_nbits_Phi();
0072
0073 cout << endl;
0074 cout << "L1 barrel Track Finder Pt-Assignment look-up tables :" << endl;
0075 cout << "=====================================================" << endl;
0076 cout << endl;
0077 cout << "Precision : " << endl;
0078 cout << '\t' << setw(2) << nbit_phi << " bits are used for phi " << endl;
0079
0080
0081 for (int pam = 0; pam < L1MuBMLUTHandler::MAX_PTASSMETH; pam++) {
0082 cout << endl;
0083 cout << "Pt-Assignment Method : " << static_cast<L1MuBMLUTHandler::PtAssMethod>(pam) << endl;
0084 cout << "============================" << endl;
0085 cout << endl;
0086
0087 cout << "\t Threshold : " << getPtLutThreshold(pam / 2) << endl << endl;
0088
0089 int maxbits = nbit_phi;
0090 if (pam >= MAX_PTASSMETHA)
0091 maxbits = nbit_phi - 2;
0092
0093 cout << " address";
0094 for (int i = 0; i < maxbits; i++)
0095 cout << ' ';
0096 cout << " value" << endl;
0097 for (int i = 0; i < maxbits; i++)
0098 cout << '-';
0099 cout << "-------------------------" << endl;
0100 std::vector<L1TMuonBarrelParams::LUT> pta_lut = l1tbmparams->pta_lut();
0101
0102 L1TMuonBarrelParams::LUT::const_iterator iter = pta_lut[pam].begin();
0103 while (iter != pta_lut[pam].end()) {
0104 int address = (*iter).first;
0105 int value = (*iter).second;
0106
0107 DTTFBitArray<12> b_address(static_cast<unsigned>(abs(address)));
0108 DTTFBitArray<9> b_value(static_cast<unsigned>(abs(value)));
0109
0110 if (address < 0)
0111 b_address.twoComplement();
0112
0113 cout.setf(ios::right, ios::adjustfield);
0114 cout << " " << setbase(10) << setw(9) << address << " (";
0115 for (int i = maxbits - 1; i >= 0; i--)
0116 cout << b_address[i];
0117 cout << ") " << setw(3) << value << " (";
0118 b_value.print();
0119 cout << ")" << endl;
0120
0121 iter++;
0122 }
0123 }
0124
0125 cout << endl;
0126 }
0127
0128
0129
0130
0131 int L1MuBMLUTHandler::getPt(int pta_ind, int address) const {
0132 std::vector<L1TMuonBarrelParams::LUT> pta_lut = l1tbmparams->pta_lut();
0133
0134 L1TMuonBarrelParams::LUT::const_iterator iter = pta_lut[pta_ind].find(address);
0135 if (iter != pta_lut[pta_ind].end()) {
0136
0137
0138 return (*iter).second;
0139 } else {
0140 cerr << "PtaLut::getPt : can not find address " << address << endl;
0141 return 0;
0142 }
0143 }
0144
0145
0146
0147
0148 int L1MuBMLUTHandler::getPtLutThreshold(int pta_ind) const {
0149 std::vector<int> pta_threshold = l1tbmparams->pta_threshold();
0150 if (pta_ind >= 0 && pta_ind < L1MuBMLUTHandler::MAX_PTASSMETH / 2) {
0151 return pta_threshold[pta_ind];
0152 } else {
0153 cerr << "PtaLut::getPtLutThreshold : can not find threshold " << pta_ind << endl;
0154 return 0;
0155 }
0156 }
0157
0158
0159
0160
0161 int L1MuBMLUTHandler::getDeltaPhi(int idx, int address) const {
0162 std::vector<L1TMuonBarrelParams::LUT> phi_lut = l1tbmparams->phi_lut();
0163 L1TMuonBarrelParams::LUT::const_iterator iter = phi_lut[idx].find(address);
0164 if (iter != phi_lut[idx].end()) {
0165 return (*iter).second;
0166 } else {
0167 cerr << "PhiLut::getDeltaPhi : can not find address " << address << endl;
0168 return 0;
0169 }
0170 }
0171
0172
0173
0174
0175 pair<unsigned short, unsigned short> L1MuBMLUTHandler::getPrecision() const {
0176 return pair<unsigned short, unsigned short>(l1tbmparams->get_PHI_Assignment_nbits_Phi(),
0177 l1tbmparams->get_PHI_Assignment_nbits_PhiB());
0178 }
0179
0180
0181
0182 void L1MuBMLUTHandler::print_phi_lut() const {
0183 unsigned short int nbit_phi = l1tbmparams->get_PHI_Assignment_nbits_Phi();
0184 unsigned short int nbit_phib = l1tbmparams->get_PHI_Assignment_nbits_PhiB();
0185
0186 cout << endl;
0187 cout << "L1 barrel Track Finder Phi-Assignment look-up tables :" << endl;
0188 cout << "======================================================" << endl;
0189 cout << endl;
0190 cout << "Precision : " << endl;
0191 cout << '\t' << setw(2) << nbit_phi << " bits are used for phi " << endl;
0192 cout << '\t' << setw(2) << nbit_phib << " bits are used for phib " << endl;
0193
0194
0195 for (int idx = 0; idx < 2; idx++) {
0196 cout << endl;
0197 if (idx == 0)
0198 cout << "Phi-Assignment Method : "
0199 << "PHI12" << endl;
0200 if (idx == 1)
0201 cout << "Phi-Assignment Method : "
0202 << "PHI42" << endl;
0203 cout << "=============================" << endl;
0204 cout << endl;
0205
0206 cout << " address";
0207 for (int i = 0; i < nbit_phib; i++)
0208 cout << ' ';
0209 cout << " value" << endl;
0210 for (int i = 0; i < nbit_phi + nbit_phib; i++)
0211 cout << '-';
0212 cout << "----------------------" << endl;
0213 std::vector<L1TMuonBarrelParams::LUT> phi_lut = l1tbmparams->phi_lut();
0214
0215 L1TMuonBarrelParams::LUT::const_iterator iter = phi_lut[idx].begin();
0216 while (iter != phi_lut[idx].end()) {
0217 int address = (*iter).first;
0218 int value = (*iter).second;
0219
0220 DTTFBitArray<10> b_address(static_cast<unsigned>(abs(address)));
0221 DTTFBitArray<12> b_value(static_cast<unsigned>(abs(value)));
0222
0223 if (address < 0)
0224 b_address.twoComplement();
0225 if (value < 0)
0226 b_value.twoComplement();
0227
0228 cout.setf(ios::right, ios::adjustfield);
0229 cout << " " << setbase(10) << setw(5) << address << " (";
0230 for (int i = nbit_phib - 1; i >= 0; i--)
0231 cout << b_address[i];
0232 cout << ") " << setw(5) << value << " (";
0233 for (int i = nbit_phi - 1; i >= 0; i--)
0234 cout << b_value[i];
0235 cout << ") " << endl;
0236
0237 iter++;
0238 }
0239 }
0240
0241 cout << endl;
0242 }
0243
0244
0245
0246
0247 int L1MuBMLUTHandler::getLow(int ext_ind, int address) const {
0248 std::vector<L1TMuonBarrelParams::LUTParams::extLUT> ext_lut = l1tbmparams->ext_lut();
0249 L1TMuonBarrelParams::LUT::const_iterator iter = ext_lut[ext_ind].low.find(address);
0250 if (iter != ext_lut[ext_ind].low.end()) {
0251 return (*iter).second;
0252 } else {
0253 cerr << "ExtLut::getLow : can not find address " << address << endl;
0254 return 99999;
0255 }
0256 }
0257
0258
0259
0260
0261 int L1MuBMLUTHandler::getHigh(int ext_ind, int address) const {
0262 std::vector<L1TMuonBarrelParams::LUTParams::extLUT> ext_lut = l1tbmparams->ext_lut();
0263 L1TMuonBarrelParams::LUT::const_iterator iter = ext_lut[ext_ind].high.find(address);
0264 if (iter != ext_lut[ext_ind].high.end()) {
0265 return (*iter).second;
0266 } else {
0267 cerr << "ExtLut::getHigh : can not find address " << address << endl;
0268 return 99999;
0269 }
0270 }
0271
0272
0273
0274
0275 void L1MuBMLUTHandler::print_ext_lut() const {
0276 unsigned short int nbit_phi = l1tbmparams->get_PHI_Assignment_nbits_Phi();
0277 unsigned short int nbit_phib = l1tbmparams->get_PHI_Assignment_nbits_PhiB();
0278 cout << endl;
0279 cout << "L1 barrel Track Finder Extrapolation look-up tables :" << endl;
0280 cout << "=====================================================" << endl;
0281 cout << endl;
0282 cout << "Precision : " << endl;
0283 cout << '\t' << setw(2) << nbit_phi << " bits are used for phi " << endl;
0284 cout << '\t' << setw(2) << nbit_phib << " bits are used for phib " << endl;
0285
0286
0287 for (int ext = 0; ext < L1MuBMLUTHandler::MAX_EXT; ext++) {
0288 cout << endl;
0289 cout << "Extrapolation : " << static_cast<L1MuBMLUTHandler::Extrapolation>(ext) << endl;
0290 cout << "====================" << endl;
0291 cout << endl;
0292
0293 cout << " address";
0294 for (int i = 0; i < nbit_phib; i++)
0295 cout << ' ';
0296 cout << " low-value";
0297 for (int i = 0; i < nbit_phi; i++)
0298 cout << ' ';
0299 cout << " high-value " << endl;
0300 for (int i = 0; i < 2 * nbit_phi + nbit_phib; i++)
0301 cout << '-';
0302 cout << "---------------------------------" << endl;
0303 std::vector<L1TMuonBarrelParams::LUTParams::extLUT> ext_lut = l1tbmparams->ext_lut();
0304 L1TMuonBarrelParams::LUT::const_iterator iter = ext_lut[ext].low.begin();
0305 L1TMuonBarrelParams::LUT::const_iterator iter1;
0306 while (iter != ext_lut[ext].low.end()) {
0307 int address = (*iter).first;
0308 int low = (*iter).second;
0309 iter1 = ext_lut[ext].high.find(address);
0310 int high = (*iter1).second;
0311
0312 DTTFBitArray<10> b_address(static_cast<unsigned>(abs(address)));
0313 DTTFBitArray<12> b_low(static_cast<unsigned>(abs(low)));
0314 DTTFBitArray<12> b_high(static_cast<unsigned>(abs(high)));
0315
0316 if (address < 0)
0317 b_address.twoComplement();
0318 if (low < 0)
0319 b_low.twoComplement();
0320 if (high < 0)
0321 b_high.twoComplement();
0322
0323 cout.setf(ios::right, ios::adjustfield);
0324 cout << " " << setbase(10) << setw(5) << address << " (";
0325 for (int i = nbit_phib - 1; i >= 0; i--)
0326 cout << b_address[i];
0327 cout << ") " << setw(5) << low << " (";
0328 for (int i = nbit_phi - 1; i >= 0; i--)
0329 cout << b_low[i];
0330 cout << ") " << setw(5) << high << " (";
0331 for (int i = nbit_phi - 1; i >= 0; i--)
0332 cout << b_high[i];
0333 cout << ") " << endl;
0334
0335 iter++;
0336 }
0337 }
0338
0339 cout << endl;
0340 }