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
0022
0023 #include "L1Trigger/L1TMuonBarrel/interface/L1MuBMTQualPatternLut.h"
0024
0025
0026
0027
0028
0029 #include <iostream>
0030 #include <iomanip>
0031 #include <string>
0032
0033
0034
0035
0036
0037 #include "FWCore/ParameterSet/interface/FileInPath.h"
0038 #include "CondFormats/L1TObjects/interface/L1TriggerLutFile.h"
0039 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0040
0041 using namespace std;
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051 L1MuBMTQualPatternLut::L1MuBMTQualPatternLut() {
0052
0053
0054
0055
0056
0057 }
0058
0059
0060
0061
0062
0063 L1MuBMTQualPatternLut::~L1MuBMTQualPatternLut() {}
0064
0065
0066
0067
0068
0069
0070
0071
0072 void L1MuBMTQualPatternLut::reset() { m_lut.clear(); }
0073
0074
0075
0076
0077 int L1MuBMTQualPatternLut::load() {
0078
0079 string defaultPath = "L1Trigger/";
0080 string eau_dir = "L1TMuon/data/bmtf_luts/LUTs_Ass/";
0081 string emu_str = "";
0082
0083
0084 for (int sp = 0; sp < 6; sp++) {
0085 emu_str = "QualPatternList_SP" + std::to_string(sp + 1);
0086
0087
0088 edm::FileInPath lut_f = edm::FileInPath(string(defaultPath + eau_dir + emu_str + ".lut"));
0089 string emu_file = lut_f.fullPath();
0090
0091
0092 L1TriggerLutFile file(emu_file);
0093 if (file.open() != 0)
0094 return -1;
0095
0096
0097
0098
0099 int skip2 = getIgnoredLines(file);
0100 file.ignoreLines(skip2);
0101
0102
0103 while (file.good()) {
0104 int id = file.readInteger();
0105 if (!file.good())
0106 break;
0107 int eta = file.readInteger();
0108 if (!file.good())
0109 break;
0110 int num = file.readInteger();
0111 if (!file.good())
0112 break;
0113
0114 vector<short> patternlist;
0115 patternlist.reserve(num);
0116
0117 for (int i = 0; i < num; i++) {
0118 int pattern = file.readInteger();
0119 patternlist.push_back(pattern);
0120 }
0121
0122 m_lut[make_pair(sp + 1, id)] = make_pair(eta, patternlist);
0123
0124 if (!file.good()) {
0125 file.close();
0126 break;
0127 }
0128 }
0129
0130 file.close();
0131 }
0132
0133 return 0;
0134 }
0135
0136
0137
0138
0139 void L1MuBMTQualPatternLut::print() const {
0140 cout << endl;
0141 cout << "L1 barrel Track Finder Qual Pattern look-up tables :" << endl;
0142 cout << "====================================================" << endl;
0143 cout << endl;
0144
0145 int spold = 0;
0146
0147 LUT::const_iterator iter = m_lut.begin();
0148 while (iter != m_lut.end()) {
0149 int sp = (*iter).first.first;
0150 if (sp != spold) {
0151 cout << endl;
0152 cout << "Qualified Patterns for Sector Processor " << setw(1) << sp << " :" << endl;
0153 cout << "===========================================" << endl;
0154 cout << endl;
0155 spold = sp;
0156 }
0157 cout << setw(2) << (*iter).first.second << " " << setw(3) << (*iter).second.first << " " << setw(5)
0158 << (*iter).second.second.size() << " : ";
0159 const vector<short>& patternlist = (*iter).second.second;
0160 vector<short>::const_iterator it;
0161 for (it = patternlist.begin(); it != patternlist.end(); it++) {
0162 cout << setw(5) << (*it) << " ";
0163 }
0164 cout << endl;
0165 iter++;
0166 }
0167
0168 cout << endl;
0169 }
0170
0171
0172
0173
0174 int L1MuBMTQualPatternLut::getCoarseEta(int sp, int adr) const {
0175 LUT::const_iterator it = m_lut.find(make_pair(sp, adr));
0176 if (it == m_lut.end()) {
0177 edm::LogError("L1MuBMTQualPatternLut")
0178 << "Error: L1MuBMTQualPatternLut: no coarse eta found for address " << adr << endl;
0179 return 0;
0180 }
0181 return (*it).second.first;
0182 }
0183
0184
0185
0186
0187 const vector<short>& L1MuBMTQualPatternLut::getQualifiedPatterns(int sp, int adr) const {
0188 LUT::const_iterator it = m_lut.find(make_pair(sp, adr));
0189 if (it == m_lut.end()) {
0190 edm::LogError("L1MuBMTQualPatternLut")
0191 << "Error: L1MuBMTQualPatternLut: no pattern list found for address " << adr << endl;
0192 }
0193 return (*it).second.second;
0194 }
0195
0196 int L1MuBMTQualPatternLut::getIgnoredLines(L1TriggerLutFile file) const {
0197 if (file.open() != 0)
0198 return -1;
0199 int skip = 0;
0200 while (file.good()) {
0201 string str = file.readString();
0202 if (str.find('#') == 0)
0203 skip += 1;
0204
0205 if (!file.good()) {
0206 file.close();
0207 break;
0208 }
0209 }
0210 file.close();
0211
0212
0213 skip += 2;
0214
0215 return skip;
0216 }