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  // 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 // Destructor --
59 //--------------
60 
62 
63 //--------------
64 // Operations --
65 //--------------
66 
67 //
68 // reset look-up table
69 //
70 void L1MuBMTEtaPatternLut::reset() { m_lut.clear(); }
71 
72 //
73 // load pattern look-up table for ETF
74 //
76  // get directory name
77  string defaultPath = "L1Trigger/";
78  string eau_dir = "L1TMuon/data/bmtf_luts/LUTs_Ass/";
79 
80  // assemble file name
81  edm::FileInPath lut_f = edm::FileInPath(string(defaultPath + eau_dir + "ETFPatternList.lut"));
82  string etf_file = lut_f.fullPath();
83 
84  // open file
85  L1TriggerLutFile file(etf_file);
86  if (file.open() != 0)
87  return -1;
88  // if ( L1MuDTTFConfig::Debug(1) ) cout << "Reading file : "
89  // << file.getName() << endl;
90 
91  // ignore comment lines (always at the beginning)
92  int skip2 = getIgnoredLines(file);
93  file.ignoreLines(skip2);
94 
95  // read patterns
96  while (file.good()) {
97  int id = file.readInteger();
98  if (!file.good())
99  break;
100  string pat = file.readString();
101  if (!file.good())
102  break;
103  int qual = file.readInteger();
104  if (!file.good())
105  break;
106  int eta = file.readInteger();
107  if (!file.good())
108  break;
110 
111  m_lut[pattern.id()] = pattern;
112 
113  if (!file.good()) {
114  file.close();
115  break;
116  }
117  }
118 
119  file.close();
120 
121  return 0;
122 }
123 
124 //
125 // print pattern look-up table for ETF
126 //
128  cout << endl;
129  cout << "L1 barrel Track Finder ETA Pattern look-up table :" << endl;
130  cout << "==================================================" << endl;
131  cout << endl;
132 
133  cout << "ETF Patterns : " << m_lut.size() << endl;
134  cout << "======================" << endl;
135  cout << endl;
136 
137  LUT::const_iterator iter = m_lut.begin();
138  while (iter != m_lut.end()) {
139  cout << (*iter).second << endl;
140  iter++;
141  }
142 
143  cout << endl;
144 }
145 
146 //
147 // get pattern with a given ID
148 //
150  LUT::const_iterator it = m_lut.find(id);
151  if (it == m_lut.end()) {
152  edm::LogError("L1MuBMTEtaPatternLut: fine eta not found")
153  << "Error: L1MuBMTEtaPatternLut: pattern not found : " << id << endl;
154  }
155  return (*it).second;
156 }
157 
159  if (file.open() != 0)
160  return -1;
161  int skip = 0;
162  while (file.good()) {
163  string str = file.readString();
164  if (str.find('#') == 0)
165  skip += 1;
166  //cout<<"here "<<str<<" found "<<str.find("#")<<endl;
167  if (!file.good()) {
168  file.close();
169  break;
170  }
171  }
172  file.close();
173  return skip;
174 }
L1MuBMTEtaPatternLut()
constructor
int getIgnoredLines(L1TriggerLutFile file) const
void print() const
print pattern look-up table
std::string fullPath() const
Definition: FileInPath.cc:161
int load()
load pattern look-up table
L1MuDTEtaPattern getPattern(int id) const
get pattern with a given ID
Log< level::Error, false > LogError
Definition: HeavyIon.h:7
virtual ~L1MuBMTEtaPatternLut()
destructor
#define str(s)
void reset()
reset pattern look-up table