Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-06-04 06:14:13

0001 //-------------------------------------------------
0002 //
0003 //   Class: L1MuDTQualPatternLut
0004 //
0005 //   Description: Look-up tables for eta matching unit (EMU)
0006 //                stores lists of qualified patterns and
0007 //                coarse eta values
0008 //
0009 //
0010 //   $Date: 2007/03/30 07:48:02 $
0011 //   $Revision: 1.1 $
0012 //
0013 //   Author :
0014 //   N. Neumeister            CERN EP
0015 //   J. Troconiz              UAM Madrid
0016 //
0017 //--------------------------------------------------
0018 
0019 //-----------------------
0020 // This Class's Header --
0021 //-----------------------
0022 
0023 #include "CondFormats/L1TObjects/interface/L1MuDTQualPatternLut.h"
0024 
0025 //---------------
0026 // C++ Headers --
0027 //---------------
0028 
0029 #include <iostream>
0030 #include <iomanip>
0031 #include <string>
0032 
0033 //-------------------------------
0034 // Collaborating Class Headers --
0035 //-------------------------------
0036 
0037 #include "FWCore/Utilities/interface/FileInPath.h"
0038 #include "CondFormats/L1TObjects/interface/L1TriggerLutFile.h"
0039 
0040 using namespace std;
0041 
0042 // --------------------------------
0043 //       class L1MuDTQualPatternLut
0044 //---------------------------------
0045 
0046 //----------------
0047 // Constructors --
0048 //----------------
0049 
0050 L1MuDTQualPatternLut::L1MuDTQualPatternLut() {
0051   //  if ( load() != 0 ) {
0052   //    cout << "Can not open files to load eta matching look-up tables for DTTrackFinder!" << endl;
0053   //  }
0054 
0055   //  if ( L1MuDTTFConfig::Debug(6) ) print();
0056 }
0057 
0058 //--------------
0059 // Destructor --
0060 //--------------
0061 
0062 L1MuDTQualPatternLut::~L1MuDTQualPatternLut() {
0063   LUT::iterator iter = m_lut.begin();
0064   while (iter != m_lut.end()) {
0065     (*iter).second.second.clear();
0066     iter++;
0067   }
0068 
0069   m_lut.clear();
0070 }
0071 
0072 //--------------
0073 // Operations --
0074 //--------------
0075 
0076 //
0077 // reset look-up tables
0078 //
0079 void L1MuDTQualPatternLut::reset() { m_lut.clear(); }
0080 
0081 //
0082 // load look-up tables for EMU
0083 //
0084 int L1MuDTQualPatternLut::load() {
0085   // get directory name
0086   string defaultPath = "L1TriggerConfig/DTTrackFinder/parameters/";
0087   string eau_dir = "L1TriggerData/DTTrackFinder/Eau/";
0088   string emu_str = "";
0089 
0090   // loop over all sector processors
0091   for (int sp = 0; sp < 6; sp++) {
0092     switch (sp) {
0093       case 0: {
0094         emu_str = "QualPatternList_SP1";
0095         break;
0096       }
0097       case 1: {
0098         emu_str = "QualPatternList_SP2";
0099         break;
0100       }
0101       case 2: {
0102         emu_str = "QualPatternList_SP3";
0103         break;
0104       }
0105       case 3: {
0106         emu_str = "QualPatternList_SP4";
0107         break;
0108       }
0109       case 4: {
0110         emu_str = "QualPatternList_SP5";
0111         break;
0112       }
0113       case 5: {
0114         emu_str = "QualPatternList_SP6";
0115         break;
0116       }
0117     }
0118 
0119     // assemble file name
0120     edm::FileInPath lut_f = edm::FileInPath(string(defaultPath + eau_dir + emu_str + ".lut"));
0121     string emu_file = lut_f.fullPath();
0122 
0123     // open file
0124     L1TriggerLutFile file(emu_file);
0125     if (file.open() != 0)
0126       return -1;
0127     //    if ( L1MuDTTFConfig::Debug(1) ) cout << "Reading file : "
0128     //                                         << file.getName() << endl;
0129 
0130     // ignore comment lines
0131     file.ignoreLines(14);
0132 
0133     // read file
0134     while (file.good()) {
0135       int id = file.readInteger();
0136       if (!file.good())
0137         break;
0138       int eta = file.readInteger();
0139       if (!file.good())
0140         break;
0141       int num = file.readInteger();
0142       if (!file.good())
0143         break;
0144 
0145       vector<short> patternlist;
0146       for (int i = 0; i < num; i++) {
0147         int pattern = file.readInteger();
0148         patternlist.push_back(pattern);
0149       }
0150 
0151       m_lut[make_pair(sp + 1, id)] = make_pair(eta, patternlist);
0152 
0153       if (!file.good()) {
0154         file.close();
0155         break;
0156       }
0157     }
0158 
0159     file.close();
0160   }
0161 
0162   return 0;
0163 }
0164 
0165 //
0166 // print look-up tables for EMU
0167 //
0168 void L1MuDTQualPatternLut::print() const {
0169   cout << endl;
0170   cout << "L1 barrel Track Finder Qual Pattern look-up tables :" << endl;
0171   cout << "====================================================" << endl;
0172   cout << endl;
0173 
0174   int spold = 0;
0175 
0176   LUT::const_iterator iter = m_lut.begin();
0177   while (iter != m_lut.end()) {
0178     int sp = (*iter).first.first;
0179     if (sp != spold) {
0180       cout << endl;
0181       cout << "Qualified Patterns for Sector Processor " << setw(1) << sp << " :" << endl;
0182       cout << "===========================================" << endl;
0183       cout << endl;
0184       spold = sp;
0185     }
0186     cout << setw(2) << (*iter).first.second << "  " << setw(3) << (*iter).second.first << "  " << setw(5)
0187          << (*iter).second.second.size() << " : ";
0188     const vector<short>& patternlist = (*iter).second.second;
0189     vector<short>::const_iterator it;
0190     for (it = patternlist.begin(); it != patternlist.end(); it++) {
0191       cout << setw(5) << (*it) << " ";
0192     }
0193     cout << endl;
0194     iter++;
0195   }
0196 
0197   cout << endl;
0198 }
0199 
0200 //
0201 // get coarse eta value for a given sector processor [1-6] and address [1-22]
0202 //
0203 int L1MuDTQualPatternLut::getCoarseEta(int sp, int adr) const {
0204   LUT::const_iterator it = m_lut.find(make_pair(sp, adr));
0205   if (it == m_lut.end()) {
0206     cerr << "Error: L1MuDTQualPatternLut: no coarse eta found for address " << adr << endl;
0207     return 0;
0208   }
0209   return (*it).second.first;
0210 }
0211 
0212 //
0213 // get list of qualified patterns for a given sector processor [1-6] and address [1-22]
0214 //
0215 const vector<short>& L1MuDTQualPatternLut::getQualifiedPatterns(int sp, int adr) const {
0216   LUT::const_iterator it = m_lut.find(make_pair(sp, adr));
0217   if (it == m_lut.end()) {
0218     cerr << "Error: L1MuDTQualPatternLut: no pattern list found for address " << adr << endl;
0219   }
0220   return (*it).second.second;
0221 }