CMS 3D CMS Logo

L1MuDTPhiLut Class Reference

Look-up tables for phi-assignment. More...

#include <CondFormats/L1TObjects/interface/L1MuDTPhiLut.h>

List of all members.

Public Member Functions

int getDeltaPhi (int idx, int address) const
 get delta-phi for a given address (bend-angle)
std::pair< unsigned short,
unsigned short > 
getPrecision () const
 get precision for look-up tables
 L1MuDTPhiLut ()
 constructor
int load ()
 load phi-assignment look-up tables
void print () const
 print phi-assignment look-up tables
void reset ()
 reset phi-assignment look-up tables
virtual ~L1MuDTPhiLut ()
 destructor

Private Types

typedef std::map< short, short,
std::less< short > > 
LUT

Private Member Functions

void setPrecision ()
 set precision for look-up tables

Private Attributes

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


Detailed Description

Look-up tables for phi-assignment.

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

N. Neumeister CERN EP

Definition at line 40 of file L1MuDTPhiLut.h.


Member Typedef Documentation

typedef std::map<short, short, std::less<short> > L1MuDTPhiLut::LUT [private]

Definition at line 72 of file L1MuDTPhiLut.h.


Constructor & Destructor Documentation

L1MuDTPhiLut::L1MuDTPhiLut (  ) 

constructor

Definition at line 50 of file L1MuDTPhiLut.cc.

References phi_lut, and setPrecision().

00050                            {
00051 
00052   phi_lut.reserve(2);
00053   setPrecision();
00054   //  if ( load() != 0 ) {
00055   //    cout << "Can not open files to load phi-assignment look-up tables for DTTrackFinder!" << endl;
00056   //  }
00057 
00058   //  if ( L1MuDTTFConfig::Debug(6) ) print();
00059 
00060 }

L1MuDTPhiLut::~L1MuDTPhiLut (  )  [virtual]

destructor

Definition at line 67 of file L1MuDTPhiLut.cc.

References iter, and phi_lut.

00067                             {
00068 
00069   vector<LUT>::iterator iter;
00070   for ( iter = phi_lut.begin(); iter != phi_lut.end(); iter++ ) {
00071     (*iter).clear();
00072   }
00073 
00074   phi_lut.clear();
00075 
00076 }


Member Function Documentation

int L1MuDTPhiLut::getDeltaPhi ( int  idx,
int  address 
) const

get delta-phi for a given address (bend-angle)

Definition at line 221 of file L1MuDTPhiLut.cc.

References TestMuL1L2Filter_cff::cerr, end, lat::endl(), iter, and phi_lut.

00221                                                         {
00222 
00223   LUT::const_iterator iter = phi_lut[idx].find(address);
00224   if ( iter != phi_lut[idx].end() ) {
00225     return (*iter).second;
00226   }
00227   else {
00228     cerr << "PhiLut::getDeltaPhi : can not find address " << address << endl;
00229     return 0;
00230   }
00231 
00232 }

pair< unsigned short, unsigned short > L1MuDTPhiLut::getPrecision (  )  const

get precision for look-up tables

Definition at line 249 of file L1MuDTPhiLut.cc.

References nbit_phi, and nbit_phib.

00249                                                                       {
00250 
00251   return pair<unsigned short, unsigned short>(nbit_phi,nbit_phib);
00252 
00253 }

int L1MuDTPhiLut::load (  ) 

load phi-assignment look-up tables

Definition at line 96 of file L1MuDTPhiLut.cc.

References L1TriggerLutFile::close(), file, edm::FileInPath::fullPath(), L1TriggerLutFile::good(), nbit_phi, nbit_phib, L1TriggerLutFile::open(), phi, phi_lut, and L1TriggerLutFile::readInteger().

00096                        {
00097 
00098   // get directory name
00099   string defaultPath = "L1TriggerConfig/DTTrackFinder/parameters/";
00100   string phi_dir = "L1TriggerData/DTTrackFinder/Ass/";
00101   string phi_str = "";
00102 
00103   // precision : in the look-up tables the following precision is used :
00104   // address (phib) ...10 bits, phi ... 12 bits
00105 
00106   int sh_phi  = 12 - nbit_phi;
00107   int sh_phib = 10 - nbit_phib;
00108 
00109   // loop over all phi-assignment methods
00110   for ( int idx = 0; idx < 2; idx++ ) {
00111     switch ( idx ) {
00112       case 0 : { phi_str = "phi12"; break; }
00113       case 1 : { phi_str = "phi42"; break; }
00114     }
00115 
00116     // assemble file name
00117     edm::FileInPath lut_f = edm::FileInPath(string(defaultPath + phi_dir + phi_str + ".lut"));
00118     string phi_file = lut_f.fullPath();
00119 
00120     // open file
00121     L1TriggerLutFile file(phi_file);
00122     if ( file.open() != 0 ) return -1;
00123     //    if ( L1MuDTTFConfig::Debug(1) ) cout << "Reading file : " 
00124     //                                         << file.getName() << endl; 
00125 
00126     LUT tmplut;
00127 
00128     int number = -1;
00129     int adr_old = -512 >> sh_phib;
00130     int sum_phi = 0;
00131 
00132     // read values
00133     while ( file.good() ) {
00134     
00135       int adr = (file.readInteger()) >> sh_phib;
00136       int phi =  file.readInteger();
00137       
00138       number++;
00139 
00140       if ( adr != adr_old ) {
00141         tmplut.insert(make_pair( adr_old, ((sum_phi/number) >> sh_phi) ));
00142 
00143         adr_old = adr;
00144         number = 0;
00145         sum_phi  = 0;
00146       }
00147       
00148       sum_phi += phi;
00149 
00150       if ( !file.good() ) file.close();
00151 
00152     }
00153 
00154     file.close();
00155     phi_lut.push_back(tmplut);
00156   } 
00157   return 0;
00158 
00159 }

void L1MuDTPhiLut::print ( void   )  const

print phi-assignment look-up tables

Definition at line 165 of file L1MuDTPhiLut.cc.

References GenMuonPlsPt100GeV_cfg::cout, end, lat::endl(), i, iter, nbit_phi, nbit_phib, phi_lut, and value.

00165                                {
00166 
00167   cout << endl;
00168   cout << "L1 barrel Track Finder Phi-Assignment look-up tables :" << endl;
00169   cout << "======================================================" << endl;
00170   cout << endl;
00171   cout << "Precision : " << endl;
00172   cout << '\t' << setw(2) << nbit_phi  << " bits are used for phi "  << endl;
00173   cout << '\t' << setw(2) << nbit_phib << " bits are used for phib " << endl;
00174 
00175   // loop over all phi-assignment methods
00176   for ( int idx = 0; idx < 2; idx++ ) { 
00177 
00178     cout << endl;
00179     if ( idx == 0 ) cout << "Phi-Assignment Method : " << "PHI12" << endl;
00180     if ( idx == 1 ) cout << "Phi-Assignment Method : " << "PHI42" << endl;    
00181     cout << "=============================" << endl;
00182     cout << endl;
00183 
00184     cout << "      address";
00185     for ( int i = 0; i < nbit_phib; i++ ) cout << ' ';
00186     cout << "    value" << endl;
00187     for ( int i = 0; i < nbit_phi + nbit_phib; i++ ) cout << '-';
00188     cout << "----------------------" << endl;
00189 
00190     LUT::const_iterator iter = phi_lut[idx].begin();
00191     while ( iter != phi_lut[idx].end() ) {
00192       int address = (*iter).first;
00193       int value   = (*iter).second;
00194 
00195 //       BitArray<10> b_address(static_cast<unsigned>(abs(address)));
00196 //       BitArray<12> b_value(static_cast<unsigned>(abs(value)));
00197 
00198 //       if ( address < 0 ) b_address.twoComplement();
00199 //       if ( value < 0 ) b_value.twoComplement();
00200 
00201 //       cout.setf(ios::right,ios::adjustfield);
00202 //       cout << " " << setbase(10) << setw(5) << address << " (";
00203 //       for ( int i = nbit_phib-1; i >= 0; i-- ) cout << b_address[i];
00204 //       cout << ")   " << setw(5) << value  << " (";
00205 //       for ( int i = nbit_phi-1; i >= 0; i-- ) cout << b_value[i];
00206 //       cout << ")  " << endl;
00207 
00208       iter++;
00209     }
00210     
00211   }
00212 
00213   cout << endl;   
00214   
00215 }

void L1MuDTPhiLut::reset ( void   ) 

reset phi-assignment look-up tables

Definition at line 86 of file L1MuDTPhiLut.cc.

References phi_lut.

00086                          {
00087 
00088   phi_lut.clear();
00089 
00090 }

void L1MuDTPhiLut::setPrecision (  )  [private]

set precision for look-up tables

Definition at line 238 of file L1MuDTPhiLut.cc.

References nbit_phi, and nbit_phib.

Referenced by L1MuDTPhiLut().

00238                                 {
00239 
00240   nbit_phi  = 12;
00241   nbit_phib = 10;
00242 
00243 }


Member Data Documentation

unsigned short int L1MuDTPhiLut::nbit_phi [private]

Definition at line 76 of file L1MuDTPhiLut.h.

Referenced by getPrecision(), load(), print(), and setPrecision().

unsigned short int L1MuDTPhiLut::nbit_phib [private]

Definition at line 77 of file L1MuDTPhiLut.h.

Referenced by getPrecision(), load(), print(), and setPrecision().

std::vector<LUT> L1MuDTPhiLut::phi_lut [private]

Definition at line 74 of file L1MuDTPhiLut.h.

Referenced by getDeltaPhi(), L1MuDTPhiLut(), load(), print(), reset(), and ~L1MuDTPhiLut().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:26:48 2009 for CMSSW by  doxygen 1.5.4