CMS 3D CMS Logo

L1MuDTPtaLut Class Reference

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

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

List of all members.

Public Member Functions

int getPt (int pta_ind, int address) const
 get pt-value for a given address
int getPtLutThreshold (int pta_ind) const
 get pt-assignment LUT threshold
 L1MuDTPtaLut ()
 constructor
int load ()
 load pt-assignment look-up tables
void print () const
 print pt-assignment look-up tables
void reset ()
 reset pt-assignment look-up tables
virtual ~L1MuDTPtaLut ()
 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
std::vector< LUTpta_lut
std::vector< intpta_threshold


Detailed Description

Look-up tables for pt-assignment.

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

N. Neumeister CERN EP

Definition at line 40 of file L1MuDTPtaLut.h.


Member Typedef Documentation

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

Definition at line 72 of file L1MuDTPtaLut.h.


Constructor & Destructor Documentation

L1MuDTPtaLut::L1MuDTPtaLut (  ) 

constructor

Definition at line 51 of file L1MuDTPtaLut.cc.

References MAX_PTASSMETH, pta_lut, pta_threshold, and setPrecision().

00051                            : 
00052                   pta_lut(0), 
00053                   pta_threshold(MAX_PTASSMETH/2) {
00054 
00055   pta_lut.reserve(MAX_PTASSMETH);
00056   pta_threshold.reserve(MAX_PTASSMETH/2);
00057   setPrecision();
00058   
00059   //  if ( load() != 0 ) {
00060   //    cout << "Can not open files to load pt-assignment look-up tables for DTTrackFinder!" << endl;
00061   //  }
00062 
00063   //  if ( L1MuDTTFConfig::Debug(6) ) print();
00064   
00065 }

L1MuDTPtaLut::~L1MuDTPtaLut (  )  [virtual]

destructor

Definition at line 72 of file L1MuDTPtaLut.cc.

References iter, pta_lut, and pta_threshold.

00072                             {
00073 
00074   vector<LUT>::iterator iter;
00075   for ( iter = pta_lut.begin(); iter != pta_lut.end(); iter++ ) {
00076     (*iter).clear();
00077   }
00078 
00079   pta_lut.clear();
00080   pta_threshold.clear();
00081 
00082 }


Member Function Documentation

int L1MuDTPtaLut::getPt ( int  pta_ind,
int  address 
) const

get pt-value for a given address

Definition at line 263 of file L1MuDTPtaLut.cc.

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

00263                                                       {
00264 
00265   LUT::const_iterator iter = pta_lut[pta_ind].find(address);
00266   if ( iter != pta_lut[pta_ind].end() ) {
00267     return (*iter).second;
00268   }
00269   else {
00270     cerr << "PtaLut::getPt : can not find address " << address << endl;
00271     return 0;
00272   }
00273 
00274 }

int L1MuDTPtaLut::getPtLutThreshold ( int  pta_ind  )  const

get pt-assignment LUT threshold

Definition at line 280 of file L1MuDTPtaLut.cc.

References TestMuL1L2Filter_cff::cerr, lat::endl(), MAX_PTASSMETH, and pta_threshold.

Referenced by print().

00280                                                      {
00281 
00282   if ( pta_ind >= 0 && pta_ind < MAX_PTASSMETH/2 ) {
00283     return pta_threshold[pta_ind];
00284   }
00285   else {
00286     cerr << "PtaLut::getPtLutThreshold : can not find threshold " << pta_ind << endl;
00287     return 0;
00288   }
00289 
00290 }

int L1MuDTPtaLut::load (  ) 

load pt-assignment look-up tables

Definition at line 103 of file L1MuDTPtaLut.cc.

References L1TriggerLutFile::close(), file, edm::FileInPath::fullPath(), L1TriggerLutFile::good(), MAX_PTASSMETH, nbit_phi, L1TriggerLutFile::open(), PT12H, PT12HO, PT12L, PT12LO, PT13H, PT13HO, PT13L, PT13LO, PT14H, PT14HO, PT14L, PT14LO, PT15HO, PT15LO, PT23H, PT23HO, PT23L, PT23LO, PT24H, PT24HO, PT24L, PT24LO, PT25HO, PT25LO, PT34H, PT34HO, PT34L, PT34LO, pta_lut, pta_threshold, L1TriggerLutFile::readInteger(), and dimuonsSequences_cff::threshold.

00103                        {
00104 
00105   // get directory name
00106   string defaultPath = "L1TriggerConfig/DTTrackFinder/parameters/";
00107   string pta_dir = "L1TriggerData/DTTrackFinder/Ass/";
00108   string pta_str = "";
00109 
00110   // precision : in the look-up tables the following precision is used :
00111   // phi ...12 bits (address) and  pt ...5 bits
00112   // now convert phi and phib to the required precision
00113 
00114   int sh_phi  = 12 - nbit_phi;
00115 
00116   // loop over all pt-assignment methods
00117   for ( int pam = 0; pam < MAX_PTASSMETH; pam++ ) { 
00118     switch ( pam ) {
00119       case PT12L  : { pta_str = "pta12l"; break; }
00120       case PT12H  : { pta_str = "pta12h"; break; }
00121       case PT13L  : { pta_str = "pta13l"; break; }
00122       case PT13H  : { pta_str = "pta13h"; break; }
00123       case PT14L  : { pta_str = "pta14l"; break; }
00124       case PT14H  : { pta_str = "pta14h"; break; }
00125       case PT23L  : { pta_str = "pta23l"; break; }
00126       case PT23H  : { pta_str = "pta23h"; break; }
00127       case PT24L  : { pta_str = "pta24l"; break; }
00128       case PT24H  : { pta_str = "pta24h"; break; }
00129       case PT34L  : { pta_str = "pta34l"; break; }
00130       case PT34H  : { pta_str = "pta34h"; break; }
00131       case PT12LO : { pta_str = "pta12l_ovl"; break; }
00132       case PT12HO : { pta_str = "pta12h_ovl"; break; }
00133       case PT13LO : { pta_str = "pta13l_ovl"; break; }
00134       case PT13HO : { pta_str = "pta13h_ovl"; break; }
00135       case PT14LO : { pta_str = "pta14l_ovl"; break; }
00136       case PT14HO : { pta_str = "pta14h_ovl"; break; }
00137       case PT23LO : { pta_str = "pta23l_ovl"; break; }
00138       case PT23HO : { pta_str = "pta23h_ovl"; break; }
00139       case PT24LO : { pta_str = "pta24l_ovl"; break; }
00140       case PT24HO : { pta_str = "pta24h_ovl"; break; }
00141       case PT34LO : { pta_str = "pta34l_ovl"; break; }
00142       case PT34HO : { pta_str = "pta34h_ovl"; break; }
00143       case PT15LO : { pta_str = "pta15l_ovl"; break; }
00144       case PT15HO : { pta_str = "pta15h_ovl"; break; }
00145       case PT25LO : { pta_str = "pta25l_ovl"; break; }
00146       case PT25HO : { pta_str = "pta25h_ovl"; break; }      
00147     }
00148 
00149     // assemble file name
00150     edm::FileInPath lut_f = edm::FileInPath(string(defaultPath + pta_dir + pta_str + ".lut"));
00151     string pta_file = lut_f.fullPath();
00152 
00153     // open file
00154     L1TriggerLutFile file(pta_file);
00155     if ( file.open() != 0 ) return -1;
00156     //    if ( L1MuDTTFConfig::Debug(1) ) cout << "Reading file : " 
00157     //                                         << file.getName() << endl; 
00158 
00159     // get the right shift factor
00160     int shift = sh_phi;
00161     int adr_old = -2048 >> shift;
00162 
00163     LUT tmplut;
00164 
00165     int number = -1;
00166     int sum_pt = 0;
00167 
00168     if ( file.good() ) {
00169       int threshold = file.readInteger();
00170       pta_threshold[pam/2] = threshold;
00171     }
00172     
00173     // read values and shift to correct precision
00174     while ( file.good() ) {
00175         
00176       int adr = (file.readInteger()) >> shift;
00177       int pt  = file.readInteger();
00178 
00179       number++;
00180       
00181       if ( adr != adr_old ) {
00182         tmplut.insert(make_pair( adr_old, (sum_pt/number) ));
00183 
00184         adr_old = adr;
00185         number = 0;
00186         sum_pt = 0;
00187       }
00188       
00189       sum_pt += pt;
00190       
00191       if ( !file.good() ) file.close();
00192       
00193     }
00194 
00195     file.close();
00196     pta_lut.push_back(tmplut);
00197   }
00198   return 0;
00199 
00200 }

void L1MuDTPtaLut::print ( void   )  const

print pt-assignment look-up tables

Definition at line 206 of file L1MuDTPtaLut.cc.

References GenMuonPlsPt100GeV_cfg::cout, end, lat::endl(), getPtLutThreshold(), i, iter, MAX_PTASSMETH, nbit_phi, pta_lut, and value.

00206                                {
00207 
00208   cout << endl;
00209   cout << "L1 barrel Track Finder Pt-Assignment look-up tables :" << endl;
00210   cout << "=====================================================" << endl;
00211   cout << endl;
00212   cout << "Precision : " << endl;
00213   cout << '\t' << setw(2) << nbit_phi  << " bits are used for phi "  << endl;
00214 
00215   // loop over all pt-assignment methods
00216   for ( int pam = 0; pam < MAX_PTASSMETH; pam++ ) {
00217  
00218     cout << endl;
00219     cout << "Pt-Assignment Method : " << static_cast<PtAssMethod>(pam) << endl;
00220     cout << "============================" << endl;
00221     cout << endl;
00222 
00223     cout << "\t Threshold : " << getPtLutThreshold(pam/2) << endl << endl;
00224 
00225     int maxbits = nbit_phi;
00226   
00227     cout << "      address";
00228     for ( int i = 0; i < maxbits; i++ ) cout << ' ';
00229     cout << "  value" << endl;
00230     for ( int i = 0; i < maxbits; i++ ) cout << '-';    
00231     cout << "-------------------------" << endl;
00232 
00233     LUT::const_iterator iter = pta_lut[pam].begin();
00234     while ( iter != pta_lut[pam].end() ) {
00235       int address = (*iter).first;
00236       int value   = (*iter).second;
00237 
00238 //       BitArray<12> b_address(static_cast<unsigned>(abs(address)));
00239 //       BitArray<5> b_value(static_cast<unsigned>(abs(value)));
00240 
00241 //       if ( address < 0 ) b_address.twoComplement();
00242 
00243 //       cout.setf(ios::right,ios::adjustfield);
00244 //       cout << " " << setbase(10) << setw(5) << address << " (";
00245 //       for ( int i = maxbits-1; i >= 0; i-- ) cout << b_address[i];  
00246 //       cout << ")   " << setw(3) << value << " (";
00247 //       b_value.print();
00248 //       cout << ")" << endl;
00249 
00250       iter++;
00251     }
00252     
00253   }
00254 
00255   cout << endl;   
00256   
00257 }

void L1MuDTPtaLut::reset ( void   ) 

reset pt-assignment look-up tables

Definition at line 92 of file L1MuDTPtaLut.cc.

References pta_lut, and pta_threshold.

00092                          {
00093 
00094   pta_lut.clear();
00095   pta_threshold.clear();
00096 
00097 }

void L1MuDTPtaLut::setPrecision (  )  [private]

set precision for look-up tables

Definition at line 296 of file L1MuDTPtaLut.cc.

References nbit_phi.

Referenced by L1MuDTPtaLut().

00296                                 {
00297 
00298   nbit_phi  = 12;  
00299 
00300 }


Member Data Documentation

unsigned short int L1MuDTPtaLut::nbit_phi [private]

Definition at line 77 of file L1MuDTPtaLut.h.

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

std::vector<LUT> L1MuDTPtaLut::pta_lut [private]

Definition at line 74 of file L1MuDTPtaLut.h.

Referenced by getPt(), L1MuDTPtaLut(), load(), print(), reset(), and ~L1MuDTPtaLut().

std::vector<int> L1MuDTPtaLut::pta_threshold [private]

Definition at line 75 of file L1MuDTPtaLut.h.

Referenced by getPtLutThreshold(), L1MuDTPtaLut(), load(), reset(), and ~L1MuDTPtaLut().


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