Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 //-------------------------------------------------
0002 //
0003 //   Class: L1TriggerLutFile
0004 //
0005 //   Description: Auxiliary class for
0006 //                Look-up table files
0007 //
0008 //
0009 //   $Date: 2007/02/27 11:43:59 $
0010 //   $Revision: 1.2 $
0011 //
0012 //   Author :
0013 //   N. Neumeister            CERN EP
0014 //   J. Troconiz              UAM Madrid
0015 //
0016 //--------------------------------------------------
0017 
0018 //-----------------------
0019 // This Class's Header --
0020 //-----------------------
0021 
0022 #include "CondFormats/L1TObjects/interface/L1TriggerLutFile.h"
0023 
0024 //---------------
0025 // C++ Headers --
0026 //---------------
0027 
0028 #include <iostream>
0029 
0030 //-------------------------------
0031 // Collaborating Class Headers --
0032 //-------------------------------
0033 
0034 using namespace std;
0035 
0036 // --------------------------------
0037 //       class L1TriggerLutFile
0038 //---------------------------------
0039 
0040 //----------------
0041 // Constructors --
0042 //----------------
0043 
0044 L1TriggerLutFile::L1TriggerLutFile(const string name) : m_file(name) {}
0045 
0046 L1TriggerLutFile::L1TriggerLutFile(const L1TriggerLutFile& in) : m_file(in.m_file) {}
0047 
0048 //--------------
0049 // Destructor --
0050 //--------------
0051 L1TriggerLutFile::~L1TriggerLutFile() {}
0052 
0053 //--------------
0054 // Operations --
0055 //--------------
0056 
0057 //
0058 // assignment operator
0059 //
0060 L1TriggerLutFile& L1TriggerLutFile::operator=(const L1TriggerLutFile& lut) {
0061   m_file = lut.m_file;
0062   return *this;
0063 }
0064 
0065 //
0066 // open file
0067 //
0068 int L1TriggerLutFile::open() {
0069   const char* file_name = m_file.c_str();
0070   m_fin.open(file_name, ios::in);
0071   if (!m_fin) {
0072     cout << "can not open file : " << file_name << endl;
0073     return -1;
0074   } else {
0075     return 0;
0076   }
0077 }
0078 
0079 //
0080 // read and ignore n lines from file
0081 //
0082 void L1TriggerLutFile::ignoreLines(int n) {
0083   char buf[256];
0084   for (int i = 0; i < n; i++)
0085     m_fin.getline(buf, 256);
0086 }
0087 
0088 //
0089 // read one integer from file
0090 //
0091 int L1TriggerLutFile::readInteger() {
0092   int tmp = 0;
0093   m_fin >> tmp;
0094   return tmp;
0095 }
0096 
0097 //
0098 // read one hex from file
0099 //
0100 int L1TriggerLutFile::readHex() {
0101   int tmp = 0;
0102   m_fin >> hex >> tmp;
0103   return tmp;
0104 }
0105 
0106 //
0107 // read one string from file
0108 //
0109 string L1TriggerLutFile::readString() {
0110   string tmp;
0111   m_fin >> tmp;
0112   return tmp;
0113 }