00001 //------------------------------------------------- 00002 // 00003 // Class: L1TriggerLutFile 00004 // 00005 // Description: Auxiliary class for 00006 // Look-up table files 00007 // 00008 // 00009 // $Date: 2007/03/30 07:48:02 $ 00010 // $Revision: 1.1 $ 00011 // 00012 // Author : 00013 // N. Neumeister CERN EP 00014 // J. Troconiz UAM Madrid 00015 // 00016 //-------------------------------------------------- 00017 00018 //----------------------- 00019 // This Class's Header -- 00020 //----------------------- 00021 00022 #include "CondFormats/L1TObjects/interface/L1TriggerLutFile.h" 00023 00024 //--------------- 00025 // C++ Headers -- 00026 //--------------- 00027 00028 #include <iostream> 00029 00030 //------------------------------- 00031 // Collaborating Class Headers -- 00032 //------------------------------- 00033 00034 using namespace std; 00035 00036 // -------------------------------- 00037 // class L1TriggerLutFile 00038 //--------------------------------- 00039 00040 //---------------- 00041 // Constructors -- 00042 //---------------- 00043 00044 L1TriggerLutFile::L1TriggerLutFile(const string name) : m_file(name) {} 00045 00046 L1TriggerLutFile::L1TriggerLutFile(const L1TriggerLutFile& in) : m_file(in.m_file) {} 00047 00048 00049 //-------------- 00050 // Destructor -- 00051 //-------------- 00052 L1TriggerLutFile::~L1TriggerLutFile() {} 00053 00054 //-------------- 00055 // Operations -- 00056 //-------------- 00057 00058 // 00059 // assignment operator 00060 // 00061 L1TriggerLutFile& L1TriggerLutFile::operator=(const L1TriggerLutFile& lut) { 00062 00063 m_file = lut.m_file; 00064 return *this; 00065 00066 } 00067 00068 00069 // 00070 // open file 00071 // 00072 int L1TriggerLutFile::open() { 00073 00074 const char* file_name = m_file.c_str(); 00075 m_fin.open(file_name,ios::in); 00076 if ( !m_fin ) { 00077 cout << "can not open file : " << file_name << endl; 00078 return -1; 00079 } 00080 else { 00081 return 0; 00082 } 00083 00084 } 00085 00086 00087 // 00088 // read and ignore n lines from file 00089 // 00090 void L1TriggerLutFile::ignoreLines(int n) { 00091 00092 char buf[256]; 00093 for ( int i = 0; i < n; i++ ) m_fin.getline(buf,256); 00094 00095 } 00096 00097 00098 // 00099 // read one integer from file 00100 // 00101 int L1TriggerLutFile::readInteger() { 00102 00103 int tmp = 0; 00104 m_fin >> tmp; 00105 return tmp; 00106 00107 } 00108 00109 00110 // 00111 // read one hex from file 00112 // 00113 int L1TriggerLutFile::readHex() { 00114 00115 int tmp = 0; 00116 m_fin >> hex >> tmp; 00117 return tmp; 00118 00119 } 00120 00121 00122 // 00123 // read one string from file 00124 // 00125 string L1TriggerLutFile::readString() { 00126 00127 string tmp; 00128 m_fin >> tmp; 00129 return tmp; 00130 00131 }