CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
L1MuBMLUTHandler.cc
Go to the documentation of this file.
1 //-------------------------------------------------
2 //
3 // Class: L1MuBMLUTHandler
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 // G. Flouris U. Ioannina
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 #include <stdlib.h> /* getenv */
33 
34 //-------------------------------
35 // Collaborating Class Headers --
36 //-------------------------------
37 
41 
42 
43 using namespace std;
44 
45 // --------------------------------
46 // class L1MuBMLUTHandler
47 //---------------------------------
48 
49 //----------------
50 // Constructors --
51 //----------------
52 
54  l1tbmparams = &l1params;
55 }
56 
57 
58 //--------------
59 // Destructor --
60 //--------------
61 
63 }
64 
65 
66 //--------------
67 // Operations --
68 //--------------
69 
70 //
71 // print pt-assignment look-up tables
72 //
74  int nbit_phi = l1tbmparams->get_PT_Assignment_nbits_Phi();
75 
76  cout << endl;
77  cout << "L1 barrel Track Finder Pt-Assignment look-up tables :" << endl;
78  cout << "=====================================================" << endl;
79  cout << endl;
80  cout << "Precision : " << endl;
81  cout << '\t' << setw(2) << nbit_phi << " bits are used for phi " << endl;
82 
83  // loop over all pt-assignment methods
84  for ( int pam = 0; pam < L1MuBMLUTHandler::MAX_PTASSMETH; pam++ ) {
85 
86  cout << endl;
87  cout << "Pt-Assignment Method : " << static_cast<L1MuBMLUTHandler::PtAssMethod>(pam) << endl;
88  cout << "============================" << endl;
89  cout << endl;
90 
91  cout << "\t Threshold : " << getPtLutThreshold(pam/2) << endl << endl;
92 
93  int maxbits = nbit_phi;
94 
95  cout << " address";
96  for ( int i = 0; i < maxbits; i++ ) cout << ' ';
97  cout << " value" << endl;
98  for ( int i = 0; i < maxbits; i++ ) cout << '-';
99  cout << "-------------------------" << endl;
100  std::vector<L1TMuonBarrelParams::LUT> pta_lut = l1tbmparams->pta_lut();
101 
102  L1TMuonBarrelParams::LUT::const_iterator iter = pta_lut[pam].begin();
103  while ( iter != pta_lut[pam].end() ) {
104  int address = (*iter).first;
105  int value = (*iter).second;
106 
107  DTTFBitArray<12> b_address(static_cast<unsigned>(abs(address)));
108  DTTFBitArray<9> b_value(static_cast<unsigned>(abs(value)));
109 
110  if ( address < 0 ) b_address.twoComplement();
111 
112  cout.setf(ios::right,ios::adjustfield);
113  cout << " " << setbase(10) << setw(9) << address << " (";
114  for ( int i = maxbits-1; i >= 0; i-- ) cout << b_address[i];
115  cout << ") " << setw(3) << value << " (";
116  b_value.print();
117  cout << ")" << endl;
118 
119  iter++;
120  }
121 
122  }
123 
124  cout << endl;
125 
126 }
127 
128 
129 //
130 // get pt value for a given address
131 //
132 int L1MuBMLUTHandler::getPt(int pta_ind, int address) const {
133 
134  std::vector<L1TMuonBarrelParams::LUT> pta_lut = l1tbmparams->pta_lut();
135 
136  L1TMuonBarrelParams::LUT::const_iterator iter = pta_lut[pta_ind].find(address);
137  if ( iter != pta_lut[pta_ind].end() ) {
138  //std::cout<<"pta_ind "<<pta_ind<<" address "<<address<<" pt "<<(*iter).second<<std::endl;
139 
140  return (*iter).second;
141  }
142  else {
143  cerr << "PtaLut::getPt : can not find address " << address << endl;
144  return 0;
145  }
146 
147 }
148 
149 
150 //
151 // get pt-assignment LUT threshold
152 //
153 int L1MuBMLUTHandler::getPtLutThreshold(int pta_ind) const {
154 std::vector<int> pta_threshold = l1tbmparams->pta_threshold();
155  if ( pta_ind >= 0 && pta_ind < L1MuBMLUTHandler::MAX_PTASSMETH /2 ) {
156  return pta_threshold[pta_ind];
157  }
158  else {
159  cerr << "PtaLut::getPtLutThreshold : can not find threshold " << pta_ind << endl;
160  return 0;
161  }
162 
163 }
164 
165 //
166 // get delta-phi value for a given address
167 //
168 int L1MuBMLUTHandler::getDeltaPhi(int idx, int address) const {
169  std::vector<L1TMuonBarrelParams::LUT> phi_lut = l1tbmparams->phi_lut();
170  L1TMuonBarrelParams::LUT::const_iterator iter = phi_lut[idx].find(address);
171  if ( iter != phi_lut[idx].end() ) {
172  return (*iter).second;
173  }
174  else {
175  cerr << "PhiLut::getDeltaPhi : can not find address " << address << endl;
176  return 0;
177  }
178 
179 }
180 
181 //
182 // get precision for look-up tables
183 //
184 pair<unsigned short, unsigned short> L1MuBMLUTHandler::getPrecision() const {
185 
186  return pair<unsigned short, unsigned short>(l1tbmparams->get_PHI_Assignment_nbits_Phi()
187  ,l1tbmparams->get_PHI_Assignment_nbits_PhiB());
188 
189 }
190 
191 
192 
193 
194 // print phi-assignment look-up tables
195 //
197  unsigned short int nbit_phi = l1tbmparams->get_PHI_Assignment_nbits_Phi();
198  unsigned short int nbit_phib = l1tbmparams->get_PHI_Assignment_nbits_PhiB();
199 
200  cout << endl;
201  cout << "L1 barrel Track Finder Phi-Assignment look-up tables :" << endl;
202  cout << "======================================================" << endl;
203  cout << endl;
204  cout << "Precision : " << endl;
205  cout << '\t' << setw(2) << nbit_phi << " bits are used for phi " << endl;
206  cout << '\t' << setw(2) << nbit_phib << " bits are used for phib " << endl;
207 
208  // loop over all phi-assignment methods
209  for ( int idx = 0; idx < 2; idx++ ) {
210 
211  cout << endl;
212  if ( idx == 0 ) cout << "Phi-Assignment Method : " << "PHI12" << endl;
213  if ( idx == 1 ) cout << "Phi-Assignment Method : " << "PHI42" << endl;
214  cout << "=============================" << endl;
215  cout << endl;
216 
217  cout << " address";
218  for ( int i = 0; i < nbit_phib; i++ ) cout << ' ';
219  cout << " value" << endl;
220  for ( int i = 0; i < nbit_phi + nbit_phib; i++ ) cout << '-';
221  cout << "----------------------" << endl;
222  std::vector<L1TMuonBarrelParams::LUT> phi_lut = l1tbmparams->phi_lut();
223 
224  L1TMuonBarrelParams::LUT::const_iterator iter = phi_lut[idx].begin();
225  while ( iter != phi_lut[idx].end() ) {
226  int address = (*iter).first;
227  int value = (*iter).second;
228 
229  DTTFBitArray<10> b_address(static_cast<unsigned>(abs(address)));
230  DTTFBitArray<12> b_value(static_cast<unsigned>(abs(value)));
231 
232  if ( address < 0 ) b_address.twoComplement();
233  if ( value < 0 ) b_value.twoComplement();
234 
235  cout.setf(ios::right,ios::adjustfield);
236  cout << " " << setbase(10) << setw(5) << address << " (";
237  for ( int i = nbit_phib-1; i >= 0; i-- ) cout << b_address[i];
238  cout << ") " << setw(5) << value << " (";
239  for ( int i = nbit_phi-1; i >= 0; i-- ) cout << b_value[i];
240  cout << ") " << endl;
241 
242  iter++;
243  }
244 
245  }
246 
247  cout << endl;
248 
249 }
250 
251 
252 
253 //
254 // get low_value for a given address
255 //
256 int L1MuBMLUTHandler::getLow(int ext_ind, int address) const {
257 
258  std::vector<L1TMuonBarrelParams::LUTParams::extLUT> ext_lut = l1tbmparams->ext_lut();
259  L1TMuonBarrelParams::LUT::const_iterator iter = ext_lut[ext_ind].low.find(address);
260  if ( iter != ext_lut[ext_ind].low.end() ) {
261  return (*iter).second;
262  }
263  else {
264  cerr << "ExtLut::getLow : can not find address " << address << endl;
265  return 99999;
266  }
267 }
268 
269 
270 //
271 // get high_value for a given address
272 //
273 int L1MuBMLUTHandler::getHigh(int ext_ind, int address) const {
274 
275  std::vector<L1TMuonBarrelParams::LUTParams::extLUT> ext_lut = l1tbmparams->ext_lut();
276  L1TMuonBarrelParams::LUT::const_iterator iter = ext_lut[ext_ind].high.find(address);
277  if ( iter != ext_lut[ext_ind].high.end() ) {
278  return (*iter).second;
279  }
280  else {
281  cerr << "ExtLut::getHigh : can not find address " << address << endl;
282  return 99999;
283  }
284 }
285 
286 
287 //
288 // print extrapolation look-up tables
289 //
291  unsigned short int nbit_phi = l1tbmparams->get_PHI_Assignment_nbits_Phi();
292  unsigned short int nbit_phib = l1tbmparams->get_PHI_Assignment_nbits_PhiB();
293  cout << endl;
294  cout << "L1 barrel Track Finder Extrapolation look-up tables :" << endl;
295  cout << "=====================================================" << endl;
296  cout << endl;
297  cout << "Precision : " << endl;
298  cout << '\t' << setw(2) << nbit_phi << " bits are used for phi " << endl;
299  cout << '\t' << setw(2) << nbit_phib << " bits are used for phib " << endl;
300 
301  // loop over all extrapolations
302  for ( int ext = 0; ext < L1MuBMLUTHandler::MAX_EXT; ext++ ) {
303 
304  cout << endl;
305  cout << "Extrapolation : " << static_cast<L1MuBMLUTHandler::Extrapolation>(ext) << endl;
306  cout << "====================" << endl;
307  cout << endl;
308 
309  cout << " address";
310  for ( int i = 0; i < nbit_phib; i++ ) cout << ' ';
311  cout << " low-value";
312  for ( int i = 0; i < nbit_phi; i++ ) cout << ' ';
313  cout << " high-value " << endl;
314  for ( int i = 0; i < 2*nbit_phi + nbit_phib; i++ ) cout << '-';
315  cout << "---------------------------------" << endl;
316  std::vector<L1TMuonBarrelParams::LUTParams::extLUT> ext_lut = l1tbmparams->ext_lut();
317  L1TMuonBarrelParams::LUT::const_iterator iter = ext_lut[ext].low.begin();
318  L1TMuonBarrelParams::LUT::const_iterator iter1;
319  while ( iter != ext_lut[ext].low.end() ) {
320  int address = (*iter).first;
321  int low = (*iter).second;
322  iter1 = ext_lut[ext].high.find(address);
323  int high = (*iter1).second;
324 
325  DTTFBitArray<10> b_address(static_cast<unsigned>(abs(address)));
326  DTTFBitArray<12> b_low(static_cast<unsigned>(abs(low)));
327  DTTFBitArray<12> b_high(static_cast<unsigned>(abs(high)));
328 
329  if ( address < 0 ) b_address.twoComplement();
330  if ( low < 0 ) b_low.twoComplement();
331  if ( high < 0 ) b_high.twoComplement();
332 
333  cout.setf(ios::right,ios::adjustfield);
334  cout << " " << setbase(10) << setw(5) << address << " (";
335  for ( int i = nbit_phib-1; i >= 0; i-- ) cout << b_address[i];
336  cout << ") " << setw(5) << low << " (";
337  for ( int i = nbit_phi-1; i >= 0; i-- ) cout << b_low[i];
338  cout << ") " << setw(5) << high << " (";
339  for ( int i = nbit_phi-1; i >= 0; i-- ) cout << b_high[i];
340  cout << ") " << endl;
341 
342  iter++;
343  }
344 
345  }
346 
347  cout << endl;
348 
349 }
350 
virtual ~L1MuBMLUTHandler()
destructor
int i
Definition: DBlmapReader.cc:9
std::ostream & print(std::ostream &o=std::cout) const
Definition: DTTFBitArray.h:345
int getPt(int pta_ind, int address) const
get pt-value for a given address
DTTFBitArray< N > twoComplement() const
Definition: DTTFBitArray.h:500
int getLow(int ext_ind, int address) const
get low_value for a given address
int getHigh(int ext_ind, int address) const
get high_value for a given address
const int MAX_PTASSMETH
int getPtLutThreshold(int pta_ind) const
get pt-assignment LUT threshold
L1MuBMLUTHandler(const L1TMuonBarrelParams &l1params)
constructor
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
#define end
Definition: vmac.h:37
std::pair< unsigned short, unsigned short > getPrecision() const
get precision for look-up tables
int getDeltaPhi(int idx, int address) const
get delta-phi for a given address (bend-angle)
void print_pta_lut() const
print pt-assignment look-up tables
void print_phi_lut() const
print phi-assignment look-up tables
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
tuple cout
Definition: gather_cfg.py:145
void print_ext_lut() const
print extrapolation look-up tables