Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:02:23

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 "CondFormats/L1TObjects/interface/L1MuDTEtaPatternLut.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/Utilities/interface/FileInPath.h"
0036 #include "CondFormats/L1TObjects/interface/L1TriggerLutFile.h"
0037 
0038 using namespace std;
0039 
0040 // --------------------------------
0041 //       class L1MuDTEtaPatternLut
0042 //---------------------------------
0043 
0044 //----------------
0045 // Constructors --
0046 //----------------
0047 
0048 L1MuDTEtaPatternLut::L1MuDTEtaPatternLut() {
0049   //  if ( load() != 0 ) {
0050   //    cout << "Can not open files to load eta track finder look-up tables for DTTrackFinder!" << endl;
0051   //  }
0052 
0053   //  if ( L1MuDTTFConfig::Debug(6) ) print();
0054 }
0055 
0056 //--------------
0057 // Destructor --
0058 //--------------
0059 
0060 L1MuDTEtaPatternLut::~L1MuDTEtaPatternLut() { m_lut.clear(); }
0061 
0062 //--------------
0063 // Operations --
0064 //--------------
0065 
0066 //
0067 // reset look-up table
0068 //
0069 void L1MuDTEtaPatternLut::reset() { m_lut.clear(); }
0070 
0071 //
0072 // load pattern look-up table for ETF
0073 //
0074 int L1MuDTEtaPatternLut::load() {
0075   // get directory name
0076   string defaultPath = "L1TriggerConfig/DTTrackFinder/parameters/";
0077   string eau_dir = "L1TriggerData/DTTrackFinder/Eau/";
0078 
0079   // assemble file name
0080   edm::FileInPath lut_f = edm::FileInPath(string(defaultPath + eau_dir + "ETFPatternList.lut"));
0081   string etf_file = lut_f.fullPath();
0082 
0083   // open file
0084   L1TriggerLutFile file(etf_file);
0085   if (file.open() != 0)
0086     return -1;
0087   //  if ( L1MuDTTFConfig::Debug(1) ) cout << "Reading file : "
0088   //                                       << file.getName() << endl;
0089 
0090   // ignore comment lines
0091   file.ignoreLines(16);
0092 
0093   // read patterns
0094   while (file.good()) {
0095     int id = file.readInteger();
0096     if (!file.good())
0097       break;
0098     string pat = file.readString();
0099     if (!file.good())
0100       break;
0101     int qual = file.readInteger();
0102     if (!file.good())
0103       break;
0104     int eta = file.readInteger();
0105     if (!file.good())
0106       break;
0107     L1MuDTEtaPattern pattern(id, pat, eta, qual);
0108 
0109     m_lut[pattern.id()] = pattern;
0110 
0111     if (!file.good()) {
0112       file.close();
0113       break;
0114     }
0115   }
0116 
0117   file.close();
0118 
0119   return 0;
0120 }
0121 
0122 //
0123 // print pattern look-up table for ETF
0124 //
0125 void L1MuDTEtaPatternLut::print() const {
0126   cout << endl;
0127   cout << "L1 barrel Track Finder ETA Pattern look-up table :" << endl;
0128   cout << "==================================================" << endl;
0129   cout << endl;
0130 
0131   cout << "ETF Patterns : " << m_lut.size() << endl;
0132   cout << "======================" << endl;
0133   cout << endl;
0134 
0135   LUT::const_iterator iter = m_lut.begin();
0136   while (iter != m_lut.end()) {
0137     cout << (*iter).second << endl;
0138     iter++;
0139   }
0140 
0141   cout << endl;
0142 }
0143 
0144 //
0145 // get pattern with a given ID
0146 //
0147 L1MuDTEtaPattern L1MuDTEtaPatternLut::getPattern(int id) const {
0148   LUT::const_iterator it = m_lut.find(id);
0149   if (it == m_lut.end()) {
0150     cerr << "Error: L1MuDTEtaPatternLut: pattern not found : " << id << endl;
0151     //    return 0;
0152   }
0153   return (*it).second;
0154 }