File indexing completed on 2024-12-20 03:13:56
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/L1MuBMTEtaPatternLut.h"
0022
0023
0024
0025
0026
0027 #include <iostream>
0028 #include <iomanip>
0029 #include <string>
0030
0031
0032
0033
0034
0035 #include "FWCore/ParameterSet/interface/FileInPath.h"
0036 #include "CondFormats/L1TObjects/interface/L1TriggerLutFile.h"
0037 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0038
0039 using namespace std;
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049 L1MuBMTEtaPatternLut::L1MuBMTEtaPatternLut() {
0050
0051
0052
0053
0054
0055 }
0056
0057
0058
0059
0060
0061 L1MuBMTEtaPatternLut::~L1MuBMTEtaPatternLut() { m_lut.clear(); }
0062
0063
0064
0065
0066
0067
0068
0069
0070 void L1MuBMTEtaPatternLut::reset() { m_lut.clear(); }
0071
0072
0073
0074
0075 int L1MuBMTEtaPatternLut::load() {
0076
0077 string defaultPath = "L1Trigger/";
0078 string eau_dir = "L1TMuon/data/bmtf_luts/LUTs_Ass/";
0079
0080
0081 edm::FileInPath lut_f = edm::FileInPath(string(defaultPath + eau_dir + "ETFPatternList.lut"));
0082 const string& etf_file = lut_f.fullPath();
0083
0084
0085 L1TriggerLutFile file(etf_file);
0086 if (file.open() != 0)
0087 return -1;
0088
0089
0090
0091
0092 int skip2 = getIgnoredLines(file);
0093 file.ignoreLines(skip2);
0094
0095
0096 while (file.good()) {
0097 int id = file.readInteger();
0098 if (!file.good())
0099 break;
0100 string pat = file.readString();
0101 if (!file.good())
0102 break;
0103 int qual = file.readInteger();
0104 if (!file.good())
0105 break;
0106 int eta = file.readInteger();
0107 if (!file.good())
0108 break;
0109 L1MuDTEtaPattern pattern(id, pat, eta, qual);
0110
0111 m_lut[pattern.id()] = pattern;
0112
0113 if (!file.good()) {
0114 file.close();
0115 break;
0116 }
0117 }
0118
0119 file.close();
0120
0121 return 0;
0122 }
0123
0124
0125
0126
0127 void L1MuBMTEtaPatternLut::print() const {
0128 cout << endl;
0129 cout << "L1 barrel Track Finder ETA Pattern look-up table :" << endl;
0130 cout << "==================================================" << endl;
0131 cout << endl;
0132
0133 cout << "ETF Patterns : " << m_lut.size() << endl;
0134 cout << "======================" << endl;
0135 cout << endl;
0136
0137 LUT::const_iterator iter = m_lut.begin();
0138 while (iter != m_lut.end()) {
0139 cout << (*iter).second << endl;
0140 iter++;
0141 }
0142
0143 cout << endl;
0144 }
0145
0146
0147
0148
0149 L1MuDTEtaPattern L1MuBMTEtaPatternLut::getPattern(int id) const {
0150 LUT::const_iterator it = m_lut.find(id);
0151 if (it == m_lut.end()) {
0152 edm::LogError("L1MuBMTEtaPatternLut: fine eta not found")
0153 << "Error: L1MuBMTEtaPatternLut: pattern not found : " << id << endl;
0154 }
0155 return (*it).second;
0156 }
0157
0158 int L1MuBMTEtaPatternLut::getIgnoredLines(L1TriggerLutFile file) const {
0159 if (file.open() != 0)
0160 return -1;
0161 int skip = 0;
0162 while (file.good()) {
0163 string str = file.readString();
0164 if (str.find('#') == 0)
0165 skip += 1;
0166
0167 if (!file.good()) {
0168 file.close();
0169 break;
0170 }
0171 }
0172 file.close();
0173 return skip;
0174 }