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 }
MessageLogger.h
pos
Definition: PixelAliasList.h:18
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
FrontierConditions_GlobalTag_cff.file
file
Definition: FrontierConditions_GlobalTag_cff.py:13
L1MuCSCPtLut.h
Exception
Definition: hltDiff.cc:245
cms::Exception
Definition: Exception.h:70
L1MuCSCPtLut::pt_lut
unsigned short pt_lut[1<< 21]
Definition: L1MuCSCPtLut.h:13
L1MuCSCPtLut::readFromDBS
void readFromDBS(std::string &ptLUT)
Definition: L1MuCSCPtLut.cc:7