CMS 3D CMS Logo

L1MuDTPtaLut.cc
Go to the documentation of this file.
1 //-------------------------------------------------
2 //
3 // Class: L1MuDTPtaLut
4 //
5 // Description: Look-up tables for pt assignment
6 //
7 //
8 // $Date: 2010/05/12 23:03:43 $
9 // $Revision: 1.7 $
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 <ostream>
29 #include <iomanip>
30 #include <string>
31 #include <cstdlib>
32 
33 //-------------------------------
34 // Collaborating Class Headers --
35 //-------------------------------
36 
41 
42 using namespace std;
43 
44 // --------------------------------
45 // class L1MuDTPtaLut
46 //---------------------------------
47 
48 //----------------
49 // Constructors --
50 //----------------
51 
52 L1MuDTPtaLut::L1MuDTPtaLut() : pta_lut(0), pta_threshold(MAX_PTASSMETH / 2) {
53  pta_lut.reserve(MAX_PTASSMETH);
54  pta_threshold.reserve(MAX_PTASSMETH / 2);
55  setPrecision();
56 
57  // if ( load() != 0 ) {
58  // cout << "Can not open files to load pt-assignment look-up tables for DTTrackFinder!" << endl;
59  // }
60 
61  // if ( L1MuDTTFConfig::Debug(6) ) print();
62 }
63 
64 //--------------
65 // Destructor --
66 //--------------
67 
69  vector<LUT>::iterator iter;
70  for (iter = pta_lut.begin(); iter != pta_lut.end(); iter++) {
71  (*iter).clear();
72  }
73 
74  pta_lut.clear();
75  pta_threshold.clear();
76 }
77 
78 //--------------
79 // Operations --
80 //--------------
81 
82 //
83 // reset pt-assignment look-up tables
84 //
86  pta_lut.clear();
87  pta_threshold.clear();
88 }
89 
90 //
91 // load pt-assignment look-up tables
92 //
94  // get directory name
95  string defaultPath = "L1TriggerConfig/DTTrackFinder/parameters/";
96  string pta_dir = "L1TriggerData/DTTrackFinder/Ass/";
97  string pta_str = "";
98 
99  // precision : in the look-up tables the following precision is used :
100  // phi ...12 bits (address) and pt ...5 bits
101  // now convert phi and phib to the required precision
102 
103  int sh_phi = 12 - nbit_phi;
104 
105  // loop over all pt-assignment methods
106  for (int pam = 0; pam < MAX_PTASSMETH; pam++) {
107  switch (pam) {
108  case PT12L: {
109  pta_str = "pta12l";
110  break;
111  }
112  case PT12H: {
113  pta_str = "pta12h";
114  break;
115  }
116  case PT13L: {
117  pta_str = "pta13l";
118  break;
119  }
120  case PT13H: {
121  pta_str = "pta13h";
122  break;
123  }
124  case PT14L: {
125  pta_str = "pta14l";
126  break;
127  }
128  case PT14H: {
129  pta_str = "pta14h";
130  break;
131  }
132  case PT23L: {
133  pta_str = "pta23l";
134  break;
135  }
136  case PT23H: {
137  pta_str = "pta23h";
138  break;
139  }
140  case PT24L: {
141  pta_str = "pta24l";
142  break;
143  }
144  case PT24H: {
145  pta_str = "pta24h";
146  break;
147  }
148  case PT34L: {
149  pta_str = "pta34l";
150  break;
151  }
152  case PT34H: {
153  pta_str = "pta34h";
154  break;
155  }
156  case PT12LO: {
157  pta_str = "pta12l_ovl";
158  break;
159  }
160  case PT12HO: {
161  pta_str = "pta12h_ovl";
162  break;
163  }
164  case PT13LO: {
165  pta_str = "pta13l_ovl";
166  break;
167  }
168  case PT13HO: {
169  pta_str = "pta13h_ovl";
170  break;
171  }
172  case PT14LO: {
173  pta_str = "pta14l_ovl";
174  break;
175  }
176  case PT14HO: {
177  pta_str = "pta14h_ovl";
178  break;
179  }
180  case PT23LO: {
181  pta_str = "pta23l_ovl";
182  break;
183  }
184  case PT23HO: {
185  pta_str = "pta23h_ovl";
186  break;
187  }
188  case PT24LO: {
189  pta_str = "pta24l_ovl";
190  break;
191  }
192  case PT24HO: {
193  pta_str = "pta24h_ovl";
194  break;
195  }
196  case PT34LO: {
197  pta_str = "pta34l_ovl";
198  break;
199  }
200  case PT34HO: {
201  pta_str = "pta34h_ovl";
202  break;
203  }
204  case PT15LO: {
205  pta_str = "pta15l_ovl";
206  break;
207  }
208  case PT15HO: {
209  pta_str = "pta15h_ovl";
210  break;
211  }
212  case PT25LO: {
213  pta_str = "pta25l_ovl";
214  break;
215  }
216  case PT25HO: {
217  pta_str = "pta25h_ovl";
218  break;
219  }
220  }
221 
222  // assemble file name
223  edm::FileInPath lut_f = edm::FileInPath(string(defaultPath + pta_dir + pta_str + ".lut"));
224  string pta_file = lut_f.fullPath();
225 
226  // open file
227  L1TriggerLutFile file(pta_file);
228  if (file.open() != 0)
229  return -1;
230  // if ( L1MuDTTFConfig::Debug(1) ) cout << "Reading file : "
231  // << file.getName() << endl;
232 
233  // get the right shift factor
234  int shift = sh_phi;
235  int adr_old = -2048 >> shift;
236 
237  LUT tmplut;
238 
239  int number = -1;
240  int sum_pt = 0;
241 
242  if (file.good()) {
243  int threshold = file.readInteger();
244  pta_threshold[pam / 2] = threshold;
245  }
246 
247  // read values and shift to correct precision
248  while (file.good()) {
249  int adr = (file.readInteger()) >> shift;
250  int pt = file.readInteger();
251 
252  number++;
253 
254  if (adr != adr_old) {
255  assert(number);
256  tmplut.insert(make_pair(adr_old, (sum_pt / number)));
257 
258  adr_old = adr;
259  number = 0;
260  sum_pt = 0;
261  }
262 
263  sum_pt += pt;
264 
265  if (!file.good())
266  file.close();
267  }
268 
269  file.close();
270  pta_lut.push_back(tmplut);
271  }
272  return 0;
273 }
274 
275 //
276 // print pt-assignment look-up tables
277 //
278 void L1MuDTPtaLut::print() const {
279  cout << endl;
280  cout << "L1 barrel Track Finder Pt-Assignment look-up tables :" << endl;
281  cout << "=====================================================" << endl;
282  cout << endl;
283  cout << "Precision : " << endl;
284  cout << '\t' << setw(2) << nbit_phi << " bits are used for phi " << endl;
285 
286  // loop over all pt-assignment methods
287  for (int pam = 0; pam < MAX_PTASSMETH; pam++) {
288  cout << endl;
289  cout << "Pt-Assignment Method : " << static_cast<PtAssMethod>(pam) << endl;
290  cout << "============================" << endl;
291  cout << endl;
292 
293  cout << "\t Threshold : " << getPtLutThreshold(pam / 2) << endl << endl;
294 
295  int maxbits = nbit_phi;
296 
297  cout << " address";
298  for (int i = 0; i < maxbits; i++)
299  cout << ' ';
300  cout << " value" << endl;
301  for (int i = 0; i < maxbits; i++)
302  cout << '-';
303  cout << "-------------------------" << endl;
304 
305  LUT::const_iterator iter = pta_lut[pam].begin();
306  while (iter != pta_lut[pam].end()) {
307  int address = (*iter).first;
308  int value = (*iter).second;
309 
310  DTTFBitArray<12> b_address(static_cast<unsigned>(abs(address)));
311  DTTFBitArray<5> b_value(static_cast<unsigned>(abs(value)));
312 
313  if (address < 0)
314  b_address.twoComplement();
315 
316  cout.setf(ios::right, ios::adjustfield);
317  cout << " " << setbase(10) << setw(5) << address << " (";
318  for (int i = maxbits - 1; i >= 0; i--)
319  cout << b_address[i];
320  cout << ") " << setw(3) << value << " (";
321  b_value.print();
322  cout << ")" << endl;
323 
324  iter++;
325  }
326  }
327 
328  cout << endl;
329 }
330 
331 //
332 // get pt value for a given address
333 //
334 int L1MuDTPtaLut::getPt(int pta_ind, int address) const {
335  LUT::const_iterator iter = pta_lut[pta_ind].find(address);
336  if (iter != pta_lut[pta_ind].end()) {
337  return (*iter).second;
338  } else {
339  cerr << "PtaLut::getPt : can not find address " << address << endl;
340  return 0;
341  }
342 }
343 
344 //
345 // get pt-assignment LUT threshold
346 //
347 int L1MuDTPtaLut::getPtLutThreshold(int pta_ind) const {
348  if (pta_ind >= 0 && pta_ind < MAX_PTASSMETH / 2) {
349  return pta_threshold[pta_ind];
350  } else {
351  cerr << "PtaLut::getPtLutThreshold : can not find threshold " << pta_ind << endl;
352  return 0;
353  }
354 }
355 
356 //
357 // set precision for look-up tables
358 //
PT12HO
Definition: L1MuDTAssParam.h:37
mps_fire.i
i
Definition: mps_fire.py:428
L1MuDTAssParam.h
PT14HO
Definition: L1MuDTAssParam.h:41
DiDispStaMuonMonitor_cfi.pt
pt
Definition: DiDispStaMuonMonitor_cfi.py:39
DTTFBitArray
Definition: DTTFBitArray.h:28
L1MuDTPtaLut::print
void print() const
print pt-assignment look-up tables
Definition: L1MuDTPtaLut.cc:278
PT24HO
Definition: L1MuDTAssParam.h:45
L1MuDTPtaLut.h
L1MuDTPtaLut::pta_threshold
std::vector< int > pta_threshold
Definition: L1MuDTPtaLut.h:70
L1TriggerLutFile
Definition: L1TriggerLutFile.h:37
gather_cfg.cout
cout
Definition: gather_cfg.py:144
PT14H
Definition: L1MuDTAssParam.h:29
cms::cuda::assert
assert(be >=bs)
L1MuDTPtaLut::~L1MuDTPtaLut
virtual ~L1MuDTPtaLut()
destructor
Definition: L1MuDTPtaLut.cc:68
PT34LO
Definition: L1MuDTAssParam.h:46
FileInPath.h
PT15HO
Definition: L1MuDTAssParam.h:49
edm::FileInPath
Definition: FileInPath.h:64
PT24L
Definition: L1MuDTAssParam.h:32
PT23LO
Definition: L1MuDTAssParam.h:42
contentValuesFiles.number
number
Definition: contentValuesFiles.py:53
PT23H
Definition: L1MuDTAssParam.h:31
L1MuDTPtaLut::getPtLutThreshold
int getPtLutThreshold(int pta_ind) const
get pt-assignment LUT threshold
Definition: L1MuDTPtaLut.cc:347
mps_fire.end
end
Definition: mps_fire.py:242
PT23HO
Definition: L1MuDTAssParam.h:43
L1MuDTPtaLut::pta_lut
std::vector< LUT > pta_lut
Definition: L1MuDTPtaLut.h:69
DTTFBitArray::twoComplement
DTTFBitArray< N > twoComplement() const
Definition: DTTFBitArray.h:507
L1MuDTPtaLut::load
int load()
load pt-assignment look-up tables
Definition: L1MuDTPtaLut.cc:93
PT12L
Definition: L1MuDTAssParam.h:24
L1MuDTPtaLut::getPt
int getPt(int pta_ind, int address) const
get pt-value for a given address
Definition: L1MuDTPtaLut.cc:334
PT12LO
Definition: L1MuDTAssParam.h:36
PT13LO
Definition: L1MuDTAssParam.h:38
PT24LO
Definition: L1MuDTAssParam.h:44
PT34L
Definition: L1MuDTAssParam.h:34
PT13HO
Definition: L1MuDTAssParam.h:39
FrontierConditions_GlobalTag_cff.file
file
Definition: FrontierConditions_GlobalTag_cff.py:13
L1MuDTPtaLut::reset
void reset()
reset pt-assignment look-up tables
Definition: L1MuDTPtaLut.cc:85
value
Definition: value.py:1
PT34HO
Definition: L1MuDTAssParam.h:47
PT13H
Definition: L1MuDTAssParam.h:27
L1MuDTPtaLut::L1MuDTPtaLut
L1MuDTPtaLut()
constructor
Definition: L1MuDTPtaLut.cc:52
PT13L
Definition: L1MuDTAssParam.h:26
DTTFBitArray::print
std::ostream & print(std::ostream &o=std::cout) const
Definition: DTTFBitArray.h:340
L1MuDTPtaLut::LUT
std::map< short, short, std::less< short > > LUT
Definition: L1MuDTPtaLut.h:67
DTTFBitArray.h
L1MuDTPtaLut::nbit_phi
unsigned short int nbit_phi
Definition: L1MuDTPtaLut.h:72
std
Definition: JetResolutionObject.h:76
PT23L
Definition: L1MuDTAssParam.h:30
edm::shift
static unsigned const int shift
Definition: LuminosityBlockID.cc:7
L1MuDTPtaLut::setPrecision
void setPrecision()
set precision for look-up tables
Definition: L1MuDTPtaLut.cc:359
PT12H
Definition: L1MuDTAssParam.h:25
PT34H
Definition: L1MuDTAssParam.h:35
MAX_PTASSMETH
const int MAX_PTASSMETH
Definition: L1MuDTAssParam.h:20
PT25LO
Definition: L1MuDTAssParam.h:50
PT15LO
Definition: L1MuDTAssParam.h:48
PT25HO
Definition: L1MuDTAssParam.h:51
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
PT24H
Definition: L1MuDTAssParam.h:33
remoteMonitoring_LED_IterMethod_cfg.threshold
threshold
Definition: remoteMonitoring_LED_IterMethod_cfg.py:426
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
PT14L
Definition: L1MuDTAssParam.h:28
edm::FileInPath::fullPath
std::string fullPath() const
Definition: FileInPath.cc:163
PT14LO
Definition: L1MuDTAssParam.h:40