Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:23:15

0001 //-------------------------------------------------
0002 //
0003 //   Class: L1MuDTEtaPatternLut
0004 //
0005 //   Description: Look-up table for eta track finder
0006 //
0007 //
0008 //   $Date: 2007/03/30 07:48:02 $
0009 //   $Revision: 1.1 $
0010 //
0011 //   Author :
0012 //   N. Neumeister            CERN EP
0013 //   J. Troconiz              UAM Madrid
0014 //
0015 //--------------------------------------------------
0016 
0017 //-----------------------
0018 // This Class's Header --
0019 //-----------------------
0020 
0021 #include "L1Trigger/L1TMuonBarrel/interface/L1MuBMTEtaPatternLut.h"
0022 
0023 //---------------
0024 // C++ Headers --
0025 //---------------
0026 
0027 #include <iostream>
0028 #include <iomanip>
0029 #include <string>
0030 
0031 //-------------------------------
0032 // Collaborating Class Headers --
0033 //-------------------------------
0034 
0035 #include "FWCore/ParameterSet/interface/FileInPath.h"
0036 #include "CondFormats/L1TObjects/interface/L1TriggerLutFile.h"
0037 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0038 
0039 using namespace std;
0040 
0041 // --------------------------------
0042 //       class L1MuDTEtaPatternLut
0043 //---------------------------------
0044 
0045 //----------------
0046 // Constructors --
0047 //----------------
0048 
0049 L1MuBMTEtaPatternLut::L1MuBMTEtaPatternLut() {
0050   //  if ( load() != 0 ) {
0051   //    cout << "Can not open files to load eta track finder look-up tables for DTTrackFinder!" << endl;
0052   //  }
0053 
0054   //  if ( L1MuDTTFConfig::Debug(6) ) print();
0055 }
0056 
0057 //--------------
0058 // Destructor --
0059 //--------------
0060 
0061 L1MuBMTEtaPatternLut::~L1MuBMTEtaPatternLut() { m_lut.clear(); }
0062 
0063 //--------------
0064 // Operations --
0065 //--------------
0066 
0067 //
0068 // reset look-up table
0069 //
0070 void L1MuBMTEtaPatternLut::reset() { m_lut.clear(); }
0071 
0072 //
0073 // load pattern look-up table for ETF
0074 //
0075 int L1MuBMTEtaPatternLut::load() {
0076   // get directory name
0077   string defaultPath = "L1Trigger/";
0078   string eau_dir = "L1TMuon/data/bmtf_luts/LUTs_Ass/";
0079 
0080   // assemble file name
0081   edm::FileInPath lut_f = edm::FileInPath(string(defaultPath + eau_dir + "ETFPatternList.lut"));
0082   string etf_file = lut_f.fullPath();
0083 
0084   // open file
0085   L1TriggerLutFile file(etf_file);
0086   if (file.open() != 0)
0087     return -1;
0088   //  if ( L1MuDTTFConfig::Debug(1) ) cout << "Reading file : "
0089   //                                       << file.getName() << endl;
0090 
0091   // ignore comment lines (always at the beginning)
0092   int skip2 = getIgnoredLines(file);
0093   file.ignoreLines(skip2);
0094 
0095   // read patterns
0096   while (file.good()) {
0097     int id = file.readInteger();
0098     if (!file.good())
0099       break;
0100     string pat = file.readString();
0101     if (!file.good())
0102       break;
0103     int qual = file.readInteger();
0104     if (!file.good())
0105       break;
0106     int eta = file.readInteger();
0107     if (!file.good())
0108       break;
0109     L1MuDTEtaPattern pattern(id, pat, eta, qual);
0110 
0111     m_lut[pattern.id()] = pattern;
0112 
0113     if (!file.good()) {
0114       file.close();
0115       break;
0116     }
0117   }
0118 
0119   file.close();
0120 
0121   return 0;
0122 }
0123 
0124 //
0125 // print pattern look-up table for ETF
0126 //
0127 void L1MuBMTEtaPatternLut::print() const {
0128   cout << endl;
0129   cout << "L1 barrel Track Finder ETA Pattern look-up table :" << endl;
0130   cout << "==================================================" << endl;
0131   cout << endl;
0132 
0133   cout << "ETF Patterns : " << m_lut.size() << endl;
0134   cout << "======================" << endl;
0135   cout << endl;
0136 
0137   LUT::const_iterator iter = m_lut.begin();
0138   while (iter != m_lut.end()) {
0139     cout << (*iter).second << endl;
0140     iter++;
0141   }
0142 
0143   cout << endl;
0144 }
0145 
0146 //
0147 // get pattern with a given ID
0148 //
0149 L1MuDTEtaPattern L1MuBMTEtaPatternLut::getPattern(int id) const {
0150   LUT::const_iterator it = m_lut.find(id);
0151   if (it == m_lut.end()) {
0152     edm::LogError("L1MuBMTEtaPatternLut: fine eta not found")
0153         << "Error: L1MuBMTEtaPatternLut: pattern not found : " << id << endl;
0154   }
0155   return (*it).second;
0156 }
0157 
0158 int L1MuBMTEtaPatternLut::getIgnoredLines(L1TriggerLutFile file) const {
0159   if (file.open() != 0)
0160     return -1;
0161   int skip = 0;
0162   while (file.good()) {
0163     string str = file.readString();
0164     if (str.find('#') == 0)
0165       skip += 1;
0166     //cout<<"here "<<str<<" found "<<str.find("#")<<endl;
0167     if (!file.good()) {
0168       file.close();
0169       break;
0170     }
0171   }
0172   file.close();
0173   return skip;
0174 }