CMS 3D CMS Logo

trivialParser.cc
Go to the documentation of this file.
1 //#include "Calibration/EcalAlCaRecoProducers/interface/trivialParser.h"
3 #include <iostream>
4 #include <cstdlib>
5 
7  parse(configFile);
8  print("[ctor] ");
9 }
10 
11 // ------------------------------------------------------------
12 
14  if (m_config.count(name))
15  return m_config[name];
16  std::cerr << "[trivialParser] no value for " << name << " found\n";
17  return -999999.;
18 }
19 
20 // ------------------------------------------------------------
21 
23  std::ifstream input(configFile.c_str());
24  do {
25  std::string linea = getNextLine(input);
26  if (linea.empty())
27  continue;
28  std::string name(linea, 0, linea.find('=', 0));
30  std::string valuestring(linea, linea.find('=', 0) + 1, linea.size() - linea.find('=', 0) - 1);
31  eraseSpaces(valuestring);
32  double value = strtod(valuestring.c_str(), nullptr);
33  m_config[name] = value;
34  } while (!input.eof());
35 }
36 
37 // ------------------------------------------------------------
38 
40  // std::cerr << "PG prima cerca " << std::endl ;
41  std::string singleLine;
42  do {
43  getline(input, singleLine, '\n');
44  // std::cerr << "PG guardo " << singleLine << std::endl ;
45  } while ((singleLine.find('#', 0) != std::string::npos || singleLine.find('=', 0) == std::string::npos ||
46  singleLine.size() < 3) &&
47  !input.eof());
48  // std::cerr << "PG trovato " << singleLine << std::endl ;
49  return singleLine;
50 }
51 
52 // ------------------------------------------------------------
53 
55  std::cerr << "read parameters: " << std::endl;
56  for (std::map<std::string, double>::const_iterator mapIT = m_config.begin(); mapIT != m_config.end(); ++mapIT) {
57  std::cerr << prefix << mapIT->first << " = " << mapIT->second << "\n";
58  }
59 }
60 
61 // ------------------------------------------------------------
62 
64  while (word.find(' ', 0) != std::string::npos) {
65  word.erase(word.find(' ', 0), 1);
66  }
67  return;
68 }
trivialParser.h
input
static const std::string input
Definition: EdmProvDump.cc:48
trivialParser::eraseSpaces
void eraseSpaces(std::string &word)
get rid of spaces
Definition: trivialParser.cc:63
word
uint64_t word
Definition: CTPPSTotemDataFormatter.cc:29
trivialParser::getNextLine
std::string getNextLine(std::ifstream &input)
returns the next not commented line
Definition: trivialParser.cc:39
trivialParser::getVal
double getVal(std::string name)
return the value for that parameter
Definition: trivialParser.cc:13
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
trivialParser::print
void print(std::string prefix="")
print the read params
Definition: trivialParser.cc:54
beam_dqm_sourceclient-live_cfg.cerr
cerr
Definition: beam_dqm_sourceclient-live_cfg.py:17
value
Definition: value.py:1
trivialParser::parse
void parse(std::string configFile)
parse the cfg file
Definition: trivialParser.cc:22
trivialParser::trivialParser
trivialParser(std::string configFile)
ctor
Definition: trivialParser.cc:6
relativeConstraints.value
value
Definition: relativeConstraints.py:53
trivialParser::m_config
std::map< std::string, double > m_config
container for the output
Definition: trivialParser.h:21
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
ZMuMuAnalysisNtupler_cff.prefix
prefix
Definition: ZMuMuAnalysisNtupler_cff.py:14