CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
L1MuDTEtaPatternLut.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 
37 
38 using namespace std;
39 
40 // --------------------------------
41 // class L1MuDTEtaPatternLut
42 //---------------------------------
43 
44 //----------------
45 // Constructors --
46 //----------------
47 
49 
50  // if ( load() != 0 ) {
51  // cout << "Can not open files to load eta track finder look-up tables for DTTrackFinder!" << endl;
52  // }
53 
54  // if ( L1MuDTTFConfig::Debug(6) ) print();
55 
56 }
57 
58 
59 //--------------
60 // Destructor --
61 //--------------
62 
64 
65  m_lut.clear();
66 
67 }
68 
69 
70 //--------------
71 // Operations --
72 //--------------
73 
74 //
75 // reset look-up table
76 //
78 
79  m_lut.clear();
80 
81 }
82 
83 
84 //
85 // load pattern look-up table for ETF
86 //
88 
89  // get directory name
90  string defaultPath = "L1TriggerConfig/DTTrackFinder/parameters/";
91  string eau_dir = "L1TriggerData/DTTrackFinder/Eau/";
92 
93  // assemble file name
94  edm::FileInPath lut_f = edm::FileInPath(string(defaultPath + eau_dir + "ETFPatternList.lut"));
95  string etf_file = lut_f.fullPath();
96 
97  // open file
98  L1TriggerLutFile file(etf_file);
99  if ( file.open() != 0 ) return -1;
100  // if ( L1MuDTTFConfig::Debug(1) ) cout << "Reading file : "
101  // << file.getName() << endl;
102 
103  // ignore comment lines
104  file.ignoreLines(16);
105 
106  // read patterns
107  while ( file.good() ) {
108 
109  int id = file.readInteger();
110  if ( !file.good() ) break;
111  string pat = file.readString();
112  if ( !file.good() ) break;
113  int qual = file.readInteger();
114  if ( !file.good() ) break;
115  int eta = file.readInteger();
116  if ( !file.good() ) break;
117  L1MuDTEtaPattern pattern(id,pat,eta,qual);
118 
119  m_lut[pattern.id()] = pattern;
120 
121  if ( !file.good() ) { file.close(); break; }
122 
123  }
124 
125  file.close();
126 
127  return 0;
128 
129 }
130 
131 
132 //
133 // print pattern look-up table for ETF
134 //
136 
137  cout << endl;
138  cout << "L1 barrel Track Finder ETA Pattern look-up table :" << endl;
139  cout << "==================================================" << endl;
140  cout << endl;
141 
142  cout << "ETF Patterns : " << m_lut.size() << endl;
143  cout << "======================" << endl;
144  cout << endl;
145 
146  LUT::const_iterator iter = m_lut.begin();
147  while ( iter != m_lut.end() ) {
148  cout << (*iter).second << endl;
149  iter++;
150  }
151 
152  cout << endl;
153 
154 }
155 
156 
157 //
158 // get pattern with a given ID
159 //
161 
162  LUT::const_iterator it = m_lut.find(id);
163  if ( it == m_lut.end() ) {
164  cerr << "Error: L1MuDTEtaPatternLut: pattern not found : " << id << endl;
165  // return 0;
166  }
167  return (*it).second;
168 
169 }
L1MuDTEtaPatternLut()
constructor
void reset()
reset pattern look-up table
bool good()
return status of file stream
int load()
load pattern look-up table
list pattern
Definition: chain.py:104
T eta() const
L1MuDTEtaPattern getPattern(int id) const
get pattern with a given ID
int id() const
return id
void close()
close file
virtual ~L1MuDTEtaPatternLut()
destructor
void ignoreLines(int n)
read and ignore n lines from file
void print() const
print pattern look-up table
std::string readString()
read one string from file
int readInteger()
read one integer from file
tuple cout
Definition: gather_cfg.py:121
std::string fullPath() const
Definition: FileInPath.cc:165
int open()
open file