CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Private Member Functions | Private Attributes | Friends
L1MuDTExtLut Class Reference

#include <L1MuDTExtLut.h>

Classes

class  LUT
 helper class for look-up tables More...
 

Public Member Functions

int getHigh (int ext_ind, int address) const
 get high_value for a given address More...
 
int getLow (int ext_ind, int address) const
 get low_value for a given address More...
 
 L1MuDTExtLut ()
 constructor More...
 
int load ()
 load extrapolation look-up tables More...
 
void print () const
 print extrapolation look-up tables More...
 
void reset ()
 reset extrapolation look-up tables More...
 
virtual ~L1MuDTExtLut ()
 destructor More...
 

Private Member Functions

template<class Archive >
void serialize (Archive &ar, const unsigned int version)
 
void setPrecision ()
 set precision for look-up tables More...
 

Private Attributes

std::vector< LUText_lut
 
unsigned short int nbit_phi
 
unsigned short int nbit_phib
 

Friends

class boost::serialization::access
 
template<typename CondSerializationT , typename Enabled >
struct cond::serialization::access
 

Detailed Description

Look-up tables for extrapolation

Date
2008/04/09 15:22:31
Revision
1.4

N. Neumeister CERN EP

Definition at line 42 of file L1MuDTExtLut.h.

Constructor & Destructor Documentation

L1MuDTExtLut::L1MuDTExtLut ( )

constructor

Definition at line 52 of file L1MuDTExtLut.cc.

References MAX_EXT.

52  {
53 
54  ext_lut.reserve(MAX_EXT);
55  setPrecision();
56  // if ( load() != 0 ) {
57  // cout << "Can not open files to load extrapolation look-up tables for DTTrackFinder!" << endl;
58  // }
59 
60  // if ( L1MuDTTFConfig::Debug(6) ) print();
61 
62 }
std::vector< LUT > ext_lut
Definition: L1MuDTExtLut.h:85
const int MAX_EXT
void setPrecision()
set precision for look-up tables
L1MuDTExtLut::~L1MuDTExtLut ( )
virtual

destructor

Definition at line 69 of file L1MuDTExtLut.cc.

69  {
70 
71  typedef vector<LUT>::iterator LI;
72  for ( LI iter = ext_lut.begin(); iter != ext_lut.end(); iter++ ) {
73  (*iter).low.clear();
74  (*iter).high.clear();
75  }
76 
77  ext_lut.clear();
78 
79 }
std::vector< LUT > ext_lut
Definition: L1MuDTExtLut.h:85

Member Function Documentation

int L1MuDTExtLut::getHigh ( int  ext_ind,
int  address 
) const

get high_value for a given address

Definition at line 265 of file L1MuDTExtLut.cc.

References MessageLogger_cfi::cerr.

Referenced by L1MuDTEUX::run().

265  {
266 
267  LUT::LUTmap::const_iterator iter = ext_lut[ext_ind].high.find(address);
268  if ( iter != ext_lut[ext_ind].high.end() ) {
269  return (*iter).second;
270  }
271  else {
272  cerr << "ExtLut::getHigh : can not find address " << address << endl;
273  return 99999;
274  }
275 }
std::vector< LUT > ext_lut
Definition: L1MuDTExtLut.h:85
int L1MuDTExtLut::getLow ( int  ext_ind,
int  address 
) const

get low_value for a given address

Definition at line 249 of file L1MuDTExtLut.cc.

References MessageLogger_cfi::cerr.

Referenced by L1MuDTEUX::run().

249  {
250 
251  LUT::LUTmap::const_iterator iter = ext_lut[ext_ind].low.find(address);
252  if ( iter != ext_lut[ext_ind].low.end() ) {
253  return (*iter).second;
254  }
255  else {
256  cerr << "ExtLut::getLow : can not find address " << address << endl;
257  return 99999;
258  }
259 }
std::vector< LUT > ext_lut
Definition: L1MuDTExtLut.h:85
int L1MuDTExtLut::load ( )

load extrapolation look-up tables

Definition at line 99 of file L1MuDTExtLut.cc.

References L1TriggerLutFile::close(), EX12, EX13, EX14, EX15, EX16, EX21, EX23, EX24, EX25, EX26, EX34, EX56, FrontierConditions_GlobalTag_cff::file, edm::FileInPath::fullPath(), L1TriggerLutFile::good(), L1MuDTExtLut::LUT::high, L1MuDTExtLut::LUT::low, MAX_EXT, L1TriggerLutFile::open(), and L1TriggerLutFile::readInteger().

Referenced by MatrixToProcess.MatrixToProcess::getProcess(), and MatrixToProcess.MatrixToProcess::listAll().

99  {
100 
101  // get directory name
102  string defaultPath = "L1TriggerConfig/DTTrackFinder/parameters/";
103  string ext_dir = "L1TriggerData/DTTrackFinder/Ext/";
104  string ext_str = "";
105 
106  // precision : in the look-up tables the following precision is used :
107  // phi ...12 bits (low, high), phib ...10 bits (address)
108  // now convert phi and phib to the required precision
109 
110  int sh_phi = 12 - nbit_phi;
111  int sh_phib = 10 - nbit_phib;
112 
113  // loop over all extrapolations
114  for ( int ext = 0; ext < MAX_EXT; ext++ ) {
115  switch (ext) {
116  case EX12 : ext_str = "ext12"; break;
117  case EX13 : ext_str = "ext13"; break;
118  case EX14 : ext_str = "ext14"; break;
119  case EX21 : ext_str = "ext21"; break;
120  case EX23 : ext_str = "ext23"; break;
121  case EX24 : ext_str = "ext24"; break;
122  case EX34 : ext_str = "ext34"; break;
123  case EX15 : ext_str = "ext15"; break;
124  case EX16 : ext_str = "ext16"; break;
125  case EX25 : ext_str = "ext25"; break;
126  case EX26 : ext_str = "ext26"; break;
127  case EX56 : ext_str = "ext56"; break;
128  }
129 
130  // assemble file name
131  edm::FileInPath lut_f = edm::FileInPath(string(defaultPath + ext_dir + ext_str + ".lut"));
132  string ext_file = lut_f.fullPath();
133 
134  // open file
135  L1TriggerLutFile file(ext_file);
136  if ( file.open() != 0 ) return -1;
137  // if ( L1MuDTTFConfig::Debug(1) ) cout << "Reading file : "
138  // << file.getName() << endl;
139 
140  LUT tmplut;
141 
142  int number = -1;
143  int adr_old = -512 >> sh_phib;
144  int sum_low = 0;
145  int sum_high = 0;
146 
147  // read values and shift to correct precision
148  while ( file.good() ) {
149 
150  int adr = ( file.readInteger() ) >> sh_phib; // address (phib)
151  int low = ( file.readInteger() ); // low value (phi)
152  int high = ( file.readInteger() ); // high value (phi)
153 
154  number++;
155 
156  if ( adr != adr_old ) {
157 
158  tmplut.low[adr_old] = sum_low >> sh_phi;
159  tmplut.high[adr_old] = sum_high >> sh_phi;
160 
161  adr_old = adr;
162  number = 0;
163  sum_low = 0;
164  sum_high = 0;
165 
166  }
167 
168  if (number == 0) sum_low = low;
169  if (number == 0) sum_high = high;
170 
171  if ( !file.good() ) file.close();
172  }
173 
174  file.close();
175  ext_lut.push_back(tmplut);
176  }
177  return 0;
178 
179 }
unsigned short int nbit_phi
Definition: L1MuDTExtLut.h:87
unsigned short int nbit_phib
Definition: L1MuDTExtLut.h:88
std::vector< LUT > ext_lut
Definition: L1MuDTExtLut.h:85
const int MAX_EXT
std::string fullPath() const
Definition: FileInPath.cc:184
std::vector< unsigned short int > LUT
Definition: DTTracoLUTs.h:32
Definition: memstream.h:15
void L1MuDTExtLut::print ( void  ) const

print extrapolation look-up tables

Definition at line 185 of file L1MuDTExtLut.cc.

References funct::abs(), gather_cfg::cout, i, MAX_EXT, and DTTFBitArray< N >::twoComplement().

Referenced by DTExtLutTester::analyze().

185  {
186 
187  cout << endl;
188  cout << "L1 barrel Track Finder Extrapolation look-up tables :" << endl;
189  cout << "=====================================================" << endl;
190  cout << endl;
191  cout << "Precision : " << endl;
192  cout << '\t' << setw(2) << nbit_phi << " bits are used for phi " << endl;
193  cout << '\t' << setw(2) << nbit_phib << " bits are used for phib " << endl;
194 
195  // loop over all extrapolations
196  for ( int ext = 0; ext < MAX_EXT; ext++ ) {
197 
198  cout << endl;
199  cout << "Extrapolation : " << static_cast<Extrapolation>(ext) << endl;
200  cout << "====================" << endl;
201  cout << endl;
202 
203  cout << " address";
204  for ( int i = 0; i < nbit_phib; i++ ) cout << ' ';
205  cout << " low-value";
206  for ( int i = 0; i < nbit_phi; i++ ) cout << ' ';
207  cout << " high-value " << endl;
208  for ( int i = 0; i < 2*nbit_phi + nbit_phib; i++ ) cout << '-';
209  cout << "---------------------------------" << endl;
210 
211  LUT::LUTmap::const_iterator iter = ext_lut[ext].low.begin();
212  LUT::LUTmap::const_iterator iter1;
213  while ( iter != ext_lut[ext].low.end() ) {
214  int address = (*iter).first;
215  int low = (*iter).second;
216  iter1 = ext_lut[ext].high.find(address);
217  int high = (*iter1).second;
218 
219  DTTFBitArray<10> b_address(static_cast<unsigned>(abs(address)));
220  DTTFBitArray<12> b_low(static_cast<unsigned>(abs(low)));
221  DTTFBitArray<12> b_high(static_cast<unsigned>(abs(high)));
222 
223  if ( address < 0 ) b_address.twoComplement();
224  if ( low < 0 ) b_low.twoComplement();
225  if ( high < 0 ) b_high.twoComplement();
226 
227  cout.setf(ios::right,ios::adjustfield);
228  cout << " " << setbase(10) << setw(5) << address << " (";
229  for ( int i = nbit_phib-1; i >= 0; i-- ) cout << b_address[i];
230  cout << ") " << setw(5) << low << " (";
231  for ( int i = nbit_phi-1; i >= 0; i-- ) cout << b_low[i];
232  cout << ") " << setw(5) << high << " (";
233  for ( int i = nbit_phi-1; i >= 0; i-- ) cout << b_high[i];
234  cout << ") " << endl;
235 
236  iter++;
237  }
238 
239  }
240 
241  cout << endl;
242 
243 }
int i
Definition: DBlmapReader.cc:9
unsigned short int nbit_phi
Definition: L1MuDTExtLut.h:87
unsigned short int nbit_phib
Definition: L1MuDTExtLut.h:88
std::vector< LUT > ext_lut
Definition: L1MuDTExtLut.h:85
const int MAX_EXT
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
Extrapolation
Definition: memstream.h:15
void L1MuDTExtLut::reset ( void  )

reset extrapolation look-up tables

Definition at line 89 of file L1MuDTExtLut.cc.

Referenced by MatrixReader.MatrixReader::__init__(), and MatrixReader.MatrixReader::showRaw().

89  {
90 
91  ext_lut.clear();
92 
93 }
std::vector< LUT > ext_lut
Definition: L1MuDTExtLut.h:85
template<class Archive >
void L1MuDTExtLut::serialize ( Archive &  ar,
const unsigned int  version 
)
private
void L1MuDTExtLut::setPrecision ( )
private

set precision for look-up tables

Definition at line 281 of file L1MuDTExtLut.cc.

281  {
282 
283  nbit_phi = 12;
284  nbit_phib = 10;
285 
286 }
unsigned short int nbit_phi
Definition: L1MuDTExtLut.h:87
unsigned short int nbit_phib
Definition: L1MuDTExtLut.h:88

Friends And Related Function Documentation

friend class boost::serialization::access
friend

Definition at line 91 of file L1MuDTExtLut.h.

template<typename CondSerializationT , typename Enabled >
friend struct cond::serialization::access
friend

Definition at line 91 of file L1MuDTExtLut.h.

Member Data Documentation

std::vector<LUT> L1MuDTExtLut::ext_lut
private

Definition at line 85 of file L1MuDTExtLut.h.

unsigned short int L1MuDTExtLut::nbit_phi
private

Definition at line 87 of file L1MuDTExtLut.h.

unsigned short int L1MuDTExtLut::nbit_phib
private

Definition at line 88 of file L1MuDTExtLut.h.