test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
L1MuDTQualPatternLut.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 
39 
40 using namespace std;
41 
42 // --------------------------------
43 // class L1MuDTQualPatternLut
44 //---------------------------------
45 
46 //----------------
47 // Constructors --
48 //----------------
49 
51 
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 
61 //--------------
62 // Destructor --
63 //--------------
64 
66 
67  LUT::iterator iter = m_lut.begin();
68  while ( iter != m_lut.end() ) {
69  (*iter).second.second.clear();
70  iter++;
71  }
72 
73  m_lut.clear();
74 
75 }
76 
77 
78 //--------------
79 // Operations --
80 //--------------
81 
82 //
83 // reset look-up tables
84 //
86 
87  m_lut.clear();
88 
89 }
90 
91 
92 //
93 // load look-up tables for EMU
94 //
96 
97  // get directory name
98  string defaultPath = "L1TriggerConfig/DTTrackFinder/parameters/";
99  string eau_dir = "L1TriggerData/DTTrackFinder/Eau/";
100  string emu_str = "";
101 
102  // loop over all sector processors
103  for ( int sp = 0; sp < 6; sp++ ) {
104  switch ( sp ) {
105  case 0 : { emu_str = "QualPatternList_SP1"; break; }
106  case 1 : { emu_str = "QualPatternList_SP2"; break; }
107  case 2 : { emu_str = "QualPatternList_SP3"; break; }
108  case 3 : { emu_str = "QualPatternList_SP4"; break; }
109  case 4 : { emu_str = "QualPatternList_SP5"; break; }
110  case 5 : { emu_str = "QualPatternList_SP6"; break; }
111  }
112 
113  // assemble file name
114  edm::FileInPath lut_f = edm::FileInPath(string(defaultPath + eau_dir + emu_str + ".lut"));
115  string emu_file = lut_f.fullPath();
116 
117  // open file
118  L1TriggerLutFile file(emu_file);
119  if ( file.open() != 0 ) return -1;
120  // if ( L1MuDTTFConfig::Debug(1) ) cout << "Reading file : "
121  // << file.getName() << endl;
122 
123  // ignore comment lines
124  file.ignoreLines(14);
125 
126  // read file
127  while ( file.good() ) {
128 
129  int id = file.readInteger();
130  if ( !file.good() ) break;
131  int eta = file.readInteger();
132  if ( !file.good() ) break;
133  int num = file.readInteger();
134  if ( !file.good() ) break;
135 
136  vector<short> patternlist;
137  for ( int i = 0; i < num; i++ ) {
138  int pattern = file.readInteger();
139  patternlist.push_back(pattern);
140  }
141 
142  m_lut[make_pair(sp+1,id)] = make_pair(eta,patternlist);
143 
144  if ( !file.good() ) { file.close(); break; }
145 
146  }
147 
148  file.close();
149  }
150 
151  return 0;
152 
153 }
154 
155 
156 //
157 // print look-up tables for EMU
158 //
160 
161  cout << endl;
162  cout << "L1 barrel Track Finder Qual Pattern look-up tables :" << endl;
163  cout << "====================================================" << endl;
164  cout << endl;
165 
166  int spold = 0;
167 
168  LUT::const_iterator iter = m_lut.begin();
169  while ( iter != m_lut.end() ) {
170  int sp = (*iter).first.first;
171  if ( sp != spold ) {
172  cout << endl;
173  cout << "Qualified Patterns for Sector Processor " << setw(1) << sp << " :" << endl;
174  cout << "===========================================" << endl;
175  cout << endl;
176  spold = sp;
177  }
178  cout << setw(2) << (*iter).first.second << " "
179  << setw(3) << (*iter).second.first << " "
180  << setw(5) << (*iter).second.second.size() << " : ";
181  const vector<short>& patternlist = (*iter).second.second;
182  vector<short>::const_iterator it;
183  for ( it = patternlist.begin(); it != patternlist.end(); it++ ) {
184  cout << setw(5) << (*it) << " ";
185  }
186  cout << endl;
187  iter++;
188  }
189 
190  cout << endl;
191 
192 }
193 
194 
195 //
196 // get coarse eta value for a given sector processor [1-6] and address [1-22]
197 //
198 int L1MuDTQualPatternLut::getCoarseEta(int sp, int adr) const {
199 
200  LUT::const_iterator it = m_lut.find(make_pair(sp,adr));
201  if ( it == m_lut.end() ) {
202  cerr << "Error: L1MuDTQualPatternLut: no coarse eta found for address " << adr << endl;
203  return 0;
204  }
205  return (*it).second.first;
206 
207 }
208 
209 
210 //
211 // get list of qualified patterns for a given sector processor [1-6] and address [1-22]
212 //
213 const vector<short>& L1MuDTQualPatternLut::getQualifiedPatterns(int sp, int adr) const {
214 
215  LUT::const_iterator it = m_lut.find(make_pair(sp,adr));
216  if ( it == m_lut.end() ) {
217  cerr << "Error: L1MuDTQualPatternLut: no pattern list found for address " << adr << endl;
218  }
219  return (*it).second.second;
220 
221 }
int i
Definition: DBlmapReader.cc:9
void reset()
reset look-up tables
bool good()
return status of file stream
int getCoarseEta(int sp, int adr) const
get coarse eta value for a given sector processor [1-6] and address [1-22]
void close()
close file
void ignoreLines(int n)
read and ignore n lines from file
int load()
load look-up tables
virtual ~L1MuDTQualPatternLut()
destructor
int readInteger()
read one integer from file
void print() const
print look-up tables
tuple cout
Definition: gather_cfg.py:145
Definition: sp.h:21
L1MuDTQualPatternLut()
constructor
std::string fullPath() const
Definition: FileInPath.cc:184
int open()
open file
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] ...