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