CMS 3D CMS Logo

L1MuBMTQualPatternLut.cc
Go to the documentation of this file.
1 //-------------------------------------------------
2 //
3 // Class: L1MuDTQualPatternLut
4 //
5 // Description: Look-up tables for eta matching unit (EMU)
6 // stores lists of qualified patterns and
7 // coarse eta values
8 //
9 //
10 // $Date: 2007/03/30 07:48:02 $
11 // $Revision: 1.1 $
12 //
13 // Author :
14 // N. Neumeister CERN EP
15 // J. Troconiz UAM Madrid
16 //
17 //--------------------------------------------------
18 
19 //-----------------------
20 // This Class's Header --
21 //-----------------------
22 
24 
25 //---------------
26 // C++ Headers --
27 //---------------
28 
29 #include <iostream>
30 #include <iomanip>
31 #include <string>
32 
33 //-------------------------------
34 // Collaborating Class Headers --
35 //-------------------------------
36 
40 
41 using namespace std;
42 
43 // --------------------------------
44 // class L1MuDTQualPatternLut
45 //---------------------------------
46 
47 //----------------
48 // Constructors --
49 //----------------
50 
52  // if ( load() != 0 ) {
53  // cout << "Can not open files to load eta matching look-up tables for DTTrackFinder!" << endl;
54  // }
55 
56  // if ( L1MuDTTFConfig::Debug(6) ) print();
57 }
58 
59 //--------------
60 // Destructor --
61 //--------------
62 
64 
65 //--------------
66 // Operations --
67 //--------------
68 
69 //
70 // reset look-up tables
71 //
72 void L1MuBMTQualPatternLut::reset() { m_lut.clear(); }
73 
74 //
75 // load look-up tables for EMU
76 //
78  // get directory name
79  string defaultPath = "L1Trigger/"; //"L1TriggerConfig/DTTrackFinder/parameters/";
80  string eau_dir = "L1TMuon/data/bmtf_luts/LUTs_Ass/"; //"L1TriggerData/DTTrackFinder/Eau/";
81  string emu_str = "";
82 
83  // loop over all sector processors
84  for (int sp = 0; sp < 6; sp++) {
85  emu_str = "QualPatternList_SP" + std::to_string(sp + 1);
86 
87  // assemble file name
88  edm::FileInPath lut_f = edm::FileInPath(string(defaultPath + eau_dir + emu_str + ".lut"));
89  string emu_file = lut_f.fullPath();
90 
91  // open file
92  L1TriggerLutFile file(emu_file);
93  if (file.open() != 0)
94  return -1;
95  // if ( L1MuDTTFConfig::Debug(1) ) cout << "Reading file : "
96  // << file.getName() << endl;
97 
98  // ignore comment lines
99  int skip2 = getIgnoredLines(file);
100  file.ignoreLines(skip2);
101 
102  // read file
103  while (file.good()) {
104  int id = file.readInteger();
105  if (!file.good())
106  break;
107  int eta = file.readInteger();
108  if (!file.good())
109  break;
110  int num = file.readInteger();
111  if (!file.good())
112  break;
113 
114  vector<short> patternlist;
115  patternlist.reserve(num);
116 
117  for (int i = 0; i < num; i++) {
118  int pattern = file.readInteger();
119  patternlist.push_back(pattern);
120  }
121 
122  m_lut[make_pair(sp + 1, id)] = make_pair(eta, patternlist);
123 
124  if (!file.good()) {
125  file.close();
126  break;
127  }
128  }
129 
130  file.close();
131  }
132 
133  return 0;
134 }
135 
136 //
137 // print look-up tables for EMU
138 //
140  cout << endl;
141  cout << "L1 barrel Track Finder Qual Pattern look-up tables :" << endl;
142  cout << "====================================================" << endl;
143  cout << endl;
144 
145  int spold = 0;
146 
147  LUT::const_iterator iter = m_lut.begin();
148  while (iter != m_lut.end()) {
149  int sp = (*iter).first.first;
150  if (sp != spold) {
151  cout << endl;
152  cout << "Qualified Patterns for Sector Processor " << setw(1) << sp << " :" << endl;
153  cout << "===========================================" << endl;
154  cout << endl;
155  spold = sp;
156  }
157  cout << setw(2) << (*iter).first.second << " " << setw(3) << (*iter).second.first << " " << setw(5)
158  << (*iter).second.second.size() << " : ";
159  const vector<short>& patternlist = (*iter).second.second;
160  vector<short>::const_iterator it;
161  for (it = patternlist.begin(); it != patternlist.end(); it++) {
162  cout << setw(5) << (*it) << " ";
163  }
164  cout << endl;
165  iter++;
166  }
167 
168  cout << endl;
169 }
170 
171 //
172 // get coarse eta value for a given sector processor [1-6] and address [1-22]
173 //
174 int L1MuBMTQualPatternLut::getCoarseEta(int sp, int adr) const {
175  LUT::const_iterator it = m_lut.find(make_pair(sp, adr));
176  if (it == m_lut.end()) {
177  edm::LogError("L1MuBMTQualPatternLut")
178  << "Error: L1MuBMTQualPatternLut: no coarse eta found for address " << adr << endl;
179  return 0;
180  }
181  return (*it).second.first;
182 }
183 
184 //
185 // get list of qualified patterns for a given sector processor [1-6] and address [1-22]
186 //
187 const vector<short>& L1MuBMTQualPatternLut::getQualifiedPatterns(int sp, int adr) const {
188  LUT::const_iterator it = m_lut.find(make_pair(sp, adr));
189  if (it == m_lut.end()) {
190  edm::LogError("L1MuBMTQualPatternLut")
191  << "Error: L1MuBMTQualPatternLut: no pattern list found for address " << adr << endl;
192  }
193  return (*it).second.second;
194 }
195 
197  if (file.open() != 0)
198  return -1;
199  int skip = 0;
200  while (file.good()) {
201  string str = file.readString();
202  if (str.find("#") == 0)
203  skip += 1;
204  //cout<<"here "<<str<<" found "<<str.find("#")<<endl;
205  if (!file.good()) {
206  file.close();
207  break;
208  }
209  }
210  file.close();
211 
212  // skip aditional lines of comments between "---".
213  skip += 2;
214 
215  return skip;
216 }
mps_fire.i
i
Definition: mps_fire.py:355
MessageLogger.h
L1MuBMTQualPatternLut::~L1MuBMTQualPatternLut
virtual ~L1MuBMTQualPatternLut()
destructor
Definition: L1MuBMTQualPatternLut.cc:63
L1TriggerLutFile
Definition: L1TriggerLutFile.h:37
gather_cfg.cout
cout
Definition: gather_cfg.py:144
L1MuBMTQualPatternLut::load
int load()
load look-up tables
Definition: L1MuBMTQualPatternLut.cc:77
L1MuBMTQualPatternLut::getIgnoredLines
int getIgnoredLines(L1TriggerLutFile file) const
Definition: L1MuBMTQualPatternLut.cc:196
FileInPath.h
edm::FileInPath
Definition: FileInPath.h:64
optionsL1T.skip
skip
Definition: optionsL1T.py:30
PVValHelper::eta
Definition: PVValidationHelpers.h:69
str
#define str(s)
Definition: TestProcessor.cc:48
L1MuBMTQualPatternLut::print
void print() const
print look-up tables
Definition: L1MuBMTQualPatternLut.cc:139
edm::LogError
Definition: MessageLogger.h:183
L1MuBMTQualPatternLut::reset
void reset()
reset look-up tables
Definition: L1MuBMTQualPatternLut.cc:72
L1MuBMTQualPatternLut::getQualifiedPatterns
const std::vector< short > & getQualifiedPatterns(int sp, int adr) const
get list of qualified patterns for a given sector processor [1-6] and address [1-22]
Definition: L1MuBMTQualPatternLut.cc:187
FrontierConditions_GlobalTag_cff.file
file
Definition: FrontierConditions_GlobalTag_cff.py:13
topSingleLeptonDQM_PU_cfi.pattern
pattern
Definition: topSingleLeptonDQM_PU_cfi.py:39
EgammaValidation_cff.num
num
Definition: EgammaValidation_cff.py:34
L1MuBMTQualPatternLut.h
std
Definition: JetResolutionObject.h:76
L1MuBMTQualPatternLut::getCoarseEta
int getCoarseEta(int sp, int adr) const
get coarse eta value for a given sector processor [1-6] and address [1-22]
Definition: L1MuBMTQualPatternLut.cc:174
L1TriggerLutFile.h
L1MuBMTQualPatternLut::L1MuBMTQualPatternLut
L1MuBMTQualPatternLut()
constructor
Definition: L1MuBMTQualPatternLut.cc:51
edm::FileInPath::fullPath
std::string fullPath() const
Definition: FileInPath.cc:163