CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_13_patch3/src/CondFormats/L1TObjects/src/L1MuDTQualPatternLut.cc

Go to the documentation of this file.
00001 //-------------------------------------------------
00002 //
00003 //   Class: L1MuDTQualPatternLut
00004 //
00005 //   Description: Look-up tables for eta matching unit (EMU)
00006 //                stores lists of qualified patterns and
00007 //                coarse eta values 
00008 //
00009 //
00010 //   $Date: 2008/04/09 15:22:31 $
00011 //   $Revision: 1.3 $
00012 //
00013 //   Author :
00014 //   N. Neumeister            CERN EP
00015 //   J. Troconiz              UAM Madrid
00016 //
00017 //--------------------------------------------------
00018 
00019 //-----------------------
00020 // This Class's Header --
00021 //-----------------------
00022 
00023 #include "CondFormats/L1TObjects/interface/L1MuDTQualPatternLut.h"
00024 
00025 //---------------
00026 // C++ Headers --
00027 //---------------
00028 
00029 #include <iostream>
00030 #include <iomanip>
00031 #include <string>
00032 
00033 //-------------------------------
00034 // Collaborating Class Headers --
00035 //-------------------------------
00036 
00037 #include "FWCore/ParameterSet/interface/FileInPath.h"
00038 #include "CondFormats/L1TObjects/interface/L1TriggerLutFile.h"
00039 
00040 using namespace std;
00041 
00042 // --------------------------------
00043 //       class L1MuDTQualPatternLut
00044 //---------------------------------
00045 
00046 //----------------
00047 // Constructors --
00048 //----------------
00049 
00050 L1MuDTQualPatternLut::L1MuDTQualPatternLut() {
00051 
00052   //  if ( load() != 0 ) {
00053   //    cout << "Can not open files to load eta matching look-up tables for DTTrackFinder!" << endl;
00054   //  }
00055 
00056   //  if ( L1MuDTTFConfig::Debug(6) ) print();
00057 
00058 }
00059 
00060 
00061 //--------------
00062 // Destructor --
00063 //--------------
00064 
00065 L1MuDTQualPatternLut::~L1MuDTQualPatternLut() {
00066 
00067   LUT::iterator iter = m_lut.begin();
00068   while ( iter != m_lut.end() ) {
00069     (*iter).second.second.clear(); 
00070     iter++;
00071   }
00072 
00073   m_lut.clear();
00074 
00075 }
00076 
00077 
00078 //--------------
00079 // Operations --
00080 //--------------
00081 
00082 //
00083 // reset look-up tables
00084 //
00085 void L1MuDTQualPatternLut::reset() {
00086 
00087   m_lut.clear();
00088 
00089 }
00090 
00091 
00092 //
00093 // load look-up tables for EMU
00094 //
00095 int L1MuDTQualPatternLut::load() {
00096 
00097   // get directory name
00098   string defaultPath = "L1TriggerConfig/DTTrackFinder/parameters/";
00099   string eau_dir = "L1TriggerData/DTTrackFinder/Eau/";
00100   string emu_str = "";
00101 
00102   // loop over all sector processors
00103   for ( int sp = 0; sp < 6; sp++ ) { 
00104     switch ( sp ) {
00105       case 0  : { emu_str = "QualPatternList_SP1"; break; }
00106       case 1  : { emu_str = "QualPatternList_SP2"; break; }
00107       case 2  : { emu_str = "QualPatternList_SP3"; break; }
00108       case 3  : { emu_str = "QualPatternList_SP4"; break; }
00109       case 4  : { emu_str = "QualPatternList_SP5"; break; }
00110       case 5  : { emu_str = "QualPatternList_SP6"; break; }
00111     }  
00112   
00113     // assemble file name
00114     edm::FileInPath lut_f = edm::FileInPath(string(defaultPath + eau_dir + emu_str + ".lut"));
00115     string emu_file = lut_f.fullPath();
00116 
00117     // open file
00118     L1TriggerLutFile file(emu_file);
00119     if ( file.open() != 0 ) return -1;
00120     //    if ( L1MuDTTFConfig::Debug(1) ) cout << "Reading file : " 
00121     //                                         << file.getName() << endl; 
00122 
00123     // ignore comment lines 
00124     file.ignoreLines(14);
00125 
00126     // read file
00127     while ( file.good() ) {
00128   
00129       int id  = file.readInteger();
00130       if ( !file.good() ) break;
00131       int eta = file.readInteger();
00132       if ( !file.good() ) break;
00133       int num = file.readInteger();
00134       if ( !file.good() ) break;
00135 
00136       vector<short> patternlist;
00137       for ( int i = 0; i < num; i++ ) {
00138         int pattern = file.readInteger();
00139         patternlist.push_back(pattern);
00140       }
00141       
00142       m_lut[make_pair(sp+1,id)] = make_pair(eta,patternlist);
00143 
00144       if ( !file.good() ) { file.close(); break; }
00145     
00146     }
00147 
00148     file.close();
00149   }  
00150     
00151   return 0;
00152 
00153 }
00154 
00155 
00156 //
00157 // print look-up tables for EMU
00158 //
00159 void L1MuDTQualPatternLut::print() const {
00160 
00161   cout << endl;
00162   cout << "L1 barrel Track Finder Qual Pattern look-up tables :" << endl;
00163   cout << "====================================================" << endl;
00164   cout << endl;
00165 
00166   int spold = 0;
00167   
00168   LUT::const_iterator iter = m_lut.begin();
00169   while ( iter != m_lut.end() ) {
00170     int sp = (*iter).first.first;
00171     if ( sp != spold ) {
00172       cout << endl;
00173       cout << "Qualified Patterns for Sector Processor " << setw(1) << sp << " :" << endl;
00174       cout << "===========================================" << endl;
00175       cout << endl;
00176       spold = sp;
00177     }
00178     cout << setw(2) << (*iter).first.second << "  "
00179          << setw(3) << (*iter).second.first << "  "
00180          << setw(5) << (*iter).second.second.size() << " : ";
00181     const vector<short>& patternlist = (*iter).second.second;
00182     vector<short>::const_iterator it;
00183     for ( it = patternlist.begin(); it != patternlist.end(); it++ ) {
00184       cout << setw(5) << (*it) << " ";
00185     }
00186     cout << endl;
00187     iter++;
00188   }
00189  
00190   cout << endl;
00191 
00192 }
00193 
00194 
00195 //
00196 // get coarse eta value for a given sector processor [1-6] and address [1-22] 
00197 //
00198 int L1MuDTQualPatternLut::getCoarseEta(int sp, int adr) const {
00199 
00200   LUT::const_iterator it = m_lut.find(make_pair(sp,adr));
00201   if ( it == m_lut.end() ) {
00202     cerr << "Error: L1MuDTQualPatternLut: no coarse eta found for address " << adr << endl;
00203     return 0;
00204   }
00205   return (*it).second.first;
00206 
00207 }
00208 
00209 
00210 //
00211 // get list of qualified patterns for a given sector processor [1-6] and address [1-22]
00212 //
00213 const vector<short>& L1MuDTQualPatternLut::getQualifiedPatterns(int sp, int adr) const {
00214 
00215   LUT::const_iterator it = m_lut.find(make_pair(sp,adr));
00216   if ( it == m_lut.end() ) {
00217     cerr << "Error: L1MuDTQualPatternLut: no pattern list found for address " << adr << endl;
00218   }
00219   return (*it).second.second;
00220 
00221 }