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  if (pam >= MAX_PTASSMETHA) maxbits = nbit_phi-2;
95 
96  cout << " address";
97  for ( int i = 0; i < maxbits; i++ ) cout << ' ';
98  cout << " value" << endl;
99  for ( int i = 0; i < maxbits; i++ ) cout << '-';
100  cout << "-------------------------" << endl;
101  std::vector<L1TMuonBarrelParams::LUT> pta_lut = l1tbmparams->pta_lut();
102 
103  L1TMuonBarrelParams::LUT::const_iterator iter = pta_lut[pam].begin();
104  while ( iter != pta_lut[pam].end() ) {
105  int address = (*iter).first;
106  int value = (*iter).second;
107 
108  DTTFBitArray<12> b_address(static_cast<unsigned>(abs(address)));
109  DTTFBitArray<9> b_value(static_cast<unsigned>(abs(value)));
110 
111  if ( address < 0 ) b_address.twoComplement();
112 
113  cout.setf(ios::right,ios::adjustfield);
114  cout << " " << setbase(10) << setw(9) << address << " (";
115  for ( int i = maxbits-1; i >= 0; i-- ) cout << b_address[i];
116  cout << ") " << setw(3) << value << " (";
117  b_value.print();
118  cout << ")" << endl;
119 
120  iter++;
121  }
122 
123  }
124 
125  cout << endl;
126 
127 }
128 
129 
130 //
131 // get pt value for a given address
132 //
133 int L1MuBMLUTHandler::getPt(int pta_ind, int address) const {
134 
135  std::vector<L1TMuonBarrelParams::LUT> pta_lut = l1tbmparams->pta_lut();
136 
137  L1TMuonBarrelParams::LUT::const_iterator iter = pta_lut[pta_ind].find(address);
138  if ( iter != pta_lut[pta_ind].end() ) {
139  //std::cout<<"pta_ind "<<pta_ind<<" address "<<address<<" pt "<<(*iter).second<<std::endl;
140 
141  return (*iter).second;
142  }
143  else {
144  cerr << "PtaLut::getPt : can not find address " << address << endl;
145  return 0;
146  }
147 
148 }
149 
150 
151 //
152 // get pt-assignment LUT threshold
153 //
154 int L1MuBMLUTHandler::getPtLutThreshold(int pta_ind) const {
155 std::vector<int> pta_threshold = l1tbmparams->pta_threshold();
156  if ( pta_ind >= 0 && pta_ind < L1MuBMLUTHandler::MAX_PTASSMETH /2 ) {
157  return pta_threshold[pta_ind];
158  }
159  else {
160  cerr << "PtaLut::getPtLutThreshold : can not find threshold " << pta_ind << endl;
161  return 0;
162  }
163 
164 }
165 
166 //
167 // get delta-phi value for a given address
168 //
169 int L1MuBMLUTHandler::getDeltaPhi(int idx, int address) const {
170  std::vector<L1TMuonBarrelParams::LUT> phi_lut = l1tbmparams->phi_lut();
171  L1TMuonBarrelParams::LUT::const_iterator iter = phi_lut[idx].find(address);
172  if ( iter != phi_lut[idx].end() ) {
173  return (*iter).second;
174  }
175  else {
176  cerr << "PhiLut::getDeltaPhi : can not find address " << address << endl;
177  return 0;
178  }
179 
180 }
181 
182 //
183 // get precision for look-up tables
184 //
185 pair<unsigned short, unsigned short> L1MuBMLUTHandler::getPrecision() const {
186 
187  return pair<unsigned short, unsigned short>(l1tbmparams->get_PHI_Assignment_nbits_Phi()
188  ,l1tbmparams->get_PHI_Assignment_nbits_PhiB());
189 
190 }
191 
192 
193 
194 
195 // print phi-assignment look-up tables
196 //
198  unsigned short int nbit_phi = l1tbmparams->get_PHI_Assignment_nbits_Phi();
199  unsigned short int nbit_phib = l1tbmparams->get_PHI_Assignment_nbits_PhiB();
200 
201  cout << endl;
202  cout << "L1 barrel Track Finder Phi-Assignment look-up tables :" << endl;
203  cout << "======================================================" << endl;
204  cout << endl;
205  cout << "Precision : " << endl;
206  cout << '\t' << setw(2) << nbit_phi << " bits are used for phi " << endl;
207  cout << '\t' << setw(2) << nbit_phib << " bits are used for phib " << endl;
208 
209  // loop over all phi-assignment methods
210  for ( int idx = 0; idx < 2; idx++ ) {
211 
212  cout << endl;
213  if ( idx == 0 ) cout << "Phi-Assignment Method : " << "PHI12" << endl;
214  if ( idx == 1 ) cout << "Phi-Assignment Method : " << "PHI42" << endl;
215  cout << "=============================" << endl;
216  cout << endl;
217 
218  cout << " address";
219  for ( int i = 0; i < nbit_phib; i++ ) cout << ' ';
220  cout << " value" << endl;
221  for ( int i = 0; i < nbit_phi + nbit_phib; i++ ) cout << '-';
222  cout << "----------------------" << endl;
223  std::vector<L1TMuonBarrelParams::LUT> phi_lut = l1tbmparams->phi_lut();
224 
225  L1TMuonBarrelParams::LUT::const_iterator iter = phi_lut[idx].begin();
226  while ( iter != phi_lut[idx].end() ) {
227  int address = (*iter).first;
228  int value = (*iter).second;
229 
230  DTTFBitArray<10> b_address(static_cast<unsigned>(abs(address)));
231  DTTFBitArray<12> b_value(static_cast<unsigned>(abs(value)));
232 
233  if ( address < 0 ) b_address.twoComplement();
234  if ( value < 0 ) b_value.twoComplement();
235 
236  cout.setf(ios::right,ios::adjustfield);
237  cout << " " << setbase(10) << setw(5) << address << " (";
238  for ( int i = nbit_phib-1; i >= 0; i-- ) cout << b_address[i];
239  cout << ") " << setw(5) << value << " (";
240  for ( int i = nbit_phi-1; i >= 0; i-- ) cout << b_value[i];
241  cout << ") " << endl;
242 
243  iter++;
244  }
245 
246  }
247 
248  cout << endl;
249 
250 }
251 
252 
253 
254 //
255 // get low_value for a given address
256 //
257 int L1MuBMLUTHandler::getLow(int ext_ind, int address) const {
258 
259  std::vector<L1TMuonBarrelParams::LUTParams::extLUT> ext_lut = l1tbmparams->ext_lut();
260  L1TMuonBarrelParams::LUT::const_iterator iter = ext_lut[ext_ind].low.find(address);
261  if ( iter != ext_lut[ext_ind].low.end() ) {
262  return (*iter).second;
263  }
264  else {
265  cerr << "ExtLut::getLow : can not find address " << address << endl;
266  return 99999;
267  }
268 }
269 
270 
271 //
272 // get high_value for a given address
273 //
274 int L1MuBMLUTHandler::getHigh(int ext_ind, int address) const {
275 
276  std::vector<L1TMuonBarrelParams::LUTParams::extLUT> ext_lut = l1tbmparams->ext_lut();
277  L1TMuonBarrelParams::LUT::const_iterator iter = ext_lut[ext_ind].high.find(address);
278  if ( iter != ext_lut[ext_ind].high.end() ) {
279  return (*iter).second;
280  }
281  else {
282  cerr << "ExtLut::getHigh : can not find address " << address << endl;
283  return 99999;
284  }
285 }
286 
287 
288 //
289 // print extrapolation look-up tables
290 //
292  unsigned short int nbit_phi = l1tbmparams->get_PHI_Assignment_nbits_Phi();
293  unsigned short int nbit_phib = l1tbmparams->get_PHI_Assignment_nbits_PhiB();
294  cout << endl;
295  cout << "L1 barrel Track Finder Extrapolation look-up tables :" << endl;
296  cout << "=====================================================" << endl;
297  cout << endl;
298  cout << "Precision : " << endl;
299  cout << '\t' << setw(2) << nbit_phi << " bits are used for phi " << endl;
300  cout << '\t' << setw(2) << nbit_phib << " bits are used for phib " << endl;
301 
302  // loop over all extrapolations
303  for ( int ext = 0; ext < L1MuBMLUTHandler::MAX_EXT; ext++ ) {
304 
305  cout << endl;
306  cout << "Extrapolation : " << static_cast<L1MuBMLUTHandler::Extrapolation>(ext) << endl;
307  cout << "====================" << endl;
308  cout << endl;
309 
310  cout << " address";
311  for ( int i = 0; i < nbit_phib; i++ ) cout << ' ';
312  cout << " low-value";
313  for ( int i = 0; i < nbit_phi; i++ ) cout << ' ';
314  cout << " high-value " << endl;
315  for ( int i = 0; i < 2*nbit_phi + nbit_phib; i++ ) cout << '-';
316  cout << "---------------------------------" << endl;
317  std::vector<L1TMuonBarrelParams::LUTParams::extLUT> ext_lut = l1tbmparams->ext_lut();
318  L1TMuonBarrelParams::LUT::const_iterator iter = ext_lut[ext].low.begin();
319  L1TMuonBarrelParams::LUT::const_iterator iter1;
320  while ( iter != ext_lut[ext].low.end() ) {
321  int address = (*iter).first;
322  int low = (*iter).second;
323  iter1 = ext_lut[ext].high.find(address);
324  int high = (*iter1).second;
325 
326  DTTFBitArray<10> b_address(static_cast<unsigned>(abs(address)));
327  DTTFBitArray<12> b_low(static_cast<unsigned>(abs(low)));
328  DTTFBitArray<12> b_high(static_cast<unsigned>(abs(high)));
329 
330  if ( address < 0 ) b_address.twoComplement();
331  if ( low < 0 ) b_low.twoComplement();
332  if ( high < 0 ) b_high.twoComplement();
333 
334  cout.setf(ios::right,ios::adjustfield);
335  cout << " " << setbase(10) << setw(5) << address << " (";
336  for ( int i = nbit_phib-1; i >= 0; i-- ) cout << b_address[i];
337  cout << ") " << setw(5) << low << " (";
338  for ( int i = nbit_phi-1; i >= 0; i-- ) cout << b_low[i];
339  cout << ") " << setw(5) << high << " (";
340  for ( int i = nbit_phi-1; i >= 0; i-- ) cout << b_high[i];
341  cout << ") " << endl;
342 
343  iter++;
344  }
345 
346  }
347 
348  cout << endl;
349 
350 }
351 
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