CMS 3D CMS Logo

L1MuBMTEtaPatternLut.cc
Go to the documentation of this file.
1 //-------------------------------------------------
2 //
3 // Class: L1MuDTEtaPatternLut
4 //
5 // Description: Look-up table for eta track finder
6 //
7 //
8 // $Date: 2007/03/30 07:48:02 $
9 // $Revision: 1.1 $
10 //
11 // Author :
12 // N. Neumeister CERN EP
13 // J. Troconiz UAM Madrid
14 //
15 //--------------------------------------------------
16 
17 //-----------------------
18 // This Class's Header --
19 //-----------------------
20 
22 
23 //---------------
24 // C++ Headers --
25 //---------------
26 
27 #include <iostream>
28 #include <iomanip>
29 #include <string>
30 
31 //-------------------------------
32 // Collaborating Class Headers --
33 //-------------------------------
34 
38 
39 using namespace std;
40 
41 // --------------------------------
42 // class L1MuDTEtaPatternLut
43 //---------------------------------
44 
45 //----------------
46 // Constructors --
47 //----------------
48 
50 
51  // if ( load() != 0 ) {
52  // cout << "Can not open files to load eta track finder look-up tables for DTTrackFinder!" << endl;
53  // }
54 
55  // if ( L1MuDTTFConfig::Debug(6) ) print();
56 
57 }
58 
59 
60 //--------------
61 // Destructor --
62 //--------------
63 
65 
66  m_lut.clear();
67 
68 }
69 
70 
71 //--------------
72 // Operations --
73 //--------------
74 
75 //
76 // reset look-up table
77 //
79 
80  m_lut.clear();
81 
82 }
83 
84 
85 //
86 // load pattern look-up table for ETF
87 //
89 
90  // get directory name
91  string defaultPath = "L1Trigger/";
92  string eau_dir = "L1TMuon/data/bmtf_luts/LUTs_Ass/";
93 
94  // assemble file name
95  edm::FileInPath lut_f = edm::FileInPath(string(defaultPath + eau_dir + "ETFPatternList.lut"));
96  string etf_file = lut_f.fullPath();
97 
98  // open file
99  L1TriggerLutFile file(etf_file);
100  if ( file.open() != 0 ) return -1;
101  // if ( L1MuDTTFConfig::Debug(1) ) cout << "Reading file : "
102  // << file.getName() << endl;
103 
104  // ignore comment lines (always at the beginning)
105  int skip2=getIgnoredLines(file);
106  file.ignoreLines(skip2);
107 
108  // read patterns
109  while ( file.good() ) {
110 
111  int id = file.readInteger();
112  if ( !file.good() ) break;
113  string pat = file.readString();
114  if ( !file.good() ) break;
115  int qual = file.readInteger();
116  if ( !file.good() ) break;
117  int eta = file.readInteger();
118  if ( !file.good() ) break;
119  L1MuDTEtaPattern pattern(id,pat,eta,qual);
120 
121  m_lut[pattern.id()] = pattern;
122 
123  if ( !file.good() ) { file.close(); break; }
124 
125  }
126 
127  file.close();
128 
129  return 0;
130 
131 }
132 
133 
134 //
135 // print pattern look-up table for ETF
136 //
138 
139  cout << endl;
140  cout << "L1 barrel Track Finder ETA Pattern look-up table :" << endl;
141  cout << "==================================================" << endl;
142  cout << endl;
143 
144  cout << "ETF Patterns : " << m_lut.size() << endl;
145  cout << "======================" << endl;
146  cout << endl;
147 
148  LUT::const_iterator iter = m_lut.begin();
149  while ( iter != m_lut.end() ) {
150  cout << (*iter).second << endl;
151  iter++;
152  }
153 
154  cout << endl;
155 
156 }
157 
158 
159 //
160 // get pattern with a given ID
161 //
163 
164  LUT::const_iterator it = m_lut.find(id);
165  if ( it == m_lut.end() ) {
166  edm::LogError ("L1MuBMTEtaPatternLut: fine eta not found") << "Error: L1MuBMTEtaPatternLut: pattern not found : " << id << endl;
167  }
168  return (*it).second;
169 
170 }
171 
173  if ( file.open() != 0 ) return -1;
174  int skip=0;
175  while ( file.good() ) {
176 
177  string str=file.readString();
178  if (str.find("#")==0) skip+=1;
179  //cout<<"here "<<str<<" found "<<str.find("#")<<endl;
180  if ( !file.good() ) { file.close(); break; }
181  }
182  file.close();
183  return skip;
184 }
L1MuBMTEtaPatternLut()
constructor
int load()
load pattern look-up table
L1MuDTEtaPattern getPattern(int id) const
get pattern with a given ID
bool good()
return status of file stream
Definition: HeavyIon.h:7
virtual ~L1MuBMTEtaPatternLut()
destructor
int id() const
return id
void close()
close file
void ignoreLines(int n)
read and ignore n lines from file
int getIgnoredLines(L1TriggerLutFile file) const
void print() const
print pattern look-up table
std::string readString()
read one string from file
int readInteger()
read one integer from file
std::string fullPath() const
Definition: FileInPath.cc:197
#define str(s)
void reset()
reset pattern look-up table
int open()
open file