File indexing completed on 2024-04-06 12:02:23
0001 #include "CondFormats/L1TObjects/interface/L1MuCSCPtLut.h"
0002 #include <FWCore/MessageLogger/interface/MessageLogger.h>
0003 #include <sstream>
0004 #include <iostream>
0005 #include <cerrno>
0006
0007 void L1MuCSCPtLut::readFromDBS(std::string& ptLUT) {
0008
0009
0010
0011
0012
0013 for (size_t pos = ptLUT.find("\\n"); pos != std::string::npos; pos = ptLUT.find("\\n", pos)) {
0014 ptLUT[pos] = ' ';
0015 ptLUT[pos + 1] = '\n';
0016 }
0017
0018 unsigned long length = 1 << 21;
0019
0020 std::stringstream file(ptLUT);
0021 if (file.fail())
0022 throw cms::Exception("Cannot open the ptLUT") << "L1MuCSCPtLut cannot open "
0023 << "ptLUT from DBS (errno=" << errno << ")" << std::endl;
0024
0025
0026 unsigned int address = 0;
0027 for (address = 0; !file.eof() && address < length; address++) {
0028 char buff[1024];
0029 file.getline(buff, 1024);
0030 int ptOutput = atoi(buff);
0031
0032
0033
0034
0035
0036
0037 pt_lut[address] = ptOutput;
0038 }
0039
0040 if (address != length)
0041 throw cms::Exception("Incorrect LUT size")
0042 << "L1MuCSCPtLut read " << address << " words from DBS instead of expected " << length << std::endl;
0043 }