CMS 3D CMS Logo

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