CMS 3D CMS Logo

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