CMS 3D CMS Logo

L1MuCSCPtLut.cc
Go to the documentation of this file.
3 #include <sstream>
4 #include <iostream>
5 #include <cerrno>
6 
8  //edm::LogInfo( "L1-O2O: L1MuCSCPtLut" ) <<" Reading from DBS";
9 
10  // the ptLUT returned by the OMDS query will have a structure like number"\n"number"\n"
11  // e.g., 32896\n32896\n32896\n32896\n and so on
12  // remove the \n separator to write the pt_lut[1<<21] line-by-line
13  for (size_t pos = ptLUT.find("\\n"); pos != std::string::npos; pos = ptLUT.find("\\n", pos)) {
14  ptLUT[pos] = ' ';
15  ptLUT[pos + 1] = '\n';
16  }
17 
18  unsigned long length = 1 << 21; //length of the ptLUT file
19 
20  std::stringstream file(ptLUT);
21  if (file.fail())
22  throw cms::Exception("Cannot open the ptLUT") << "L1MuCSCPtLut cannot open "
23  << "ptLUT from DBS (errno=" << errno << ")" << std::endl;
24 
25  // filling the ptLUT
26  unsigned int address = 0;
27  for (address = 0; !file.eof() && address < length; address++) {
28  char buff[1024];
29  file.getline(buff, 1024);
30  int ptOutput = atoi(buff);
31 
32  // uncomment if you want to see line-by-line
33  //edm::LogInfo( "L1-O2O: L1MuCSCPtLut" ) << "writing line "
34  // << ptOutput;
35 
36  // Warning: this may throw non-cms like exception
37  pt_lut[address] = ptOutput;
38  }
39 
40  if (address != length)
41  throw cms::Exception("Incorrect LUT size")
42  << "L1MuCSCPtLut read " << address << " words from DBS instead of expected " << length << std::endl;
43 }
const ap_uint< BITSPT > ptLUT[2251]
Definition: TPSLUTs.h:18
void readFromDBS(std::string &ptLUT)
Definition: L1MuCSCPtLut.cc:7
unsigned short pt_lut[1<< 21]
Definition: L1MuCSCPtLut.h:13