ATLAS Offline Software
PixelConditionsDataStringUtils.h
Go to the documentation of this file.
1 #ifndef PixelConditionsData_StringUtils
2 #define PixelConditionsData_StringUtils
3 
4 #include <vector>
5 #include <string>
6 #include <cctype> //for std::tolower
7 
8 
10 
11  //for PixelConfigCondAlg
12  template <class T = std::string>
13  T
14  fromString(const std::string & s){
15  return s;
16  }
17 
18  template<>
19  inline float
20  fromString(const std::string &s){
21  return std::stof(s);
22  }
23 
24  template <>
25  inline double
26  fromString(const std::string & s){
27  return std::stod(s);
28  }
29 
30  template <>
31  inline int
32  fromString(const std::string & s){
33  return std::stoi(s);
34  }
35 
36  template<>
37  inline bool
38  fromString(const std::string & s){
39  std::string v=s;
40  for (char & c: v) c = std::tolower(c);
41  if (v.find("false")!=std::string::npos) return false;
42  if (v.find("true")!=std::string::npos) return true;
43  throw("bad conversion");
44  }
45 
46  std::vector<std::string>
47  getParameterString(const std::string& varName, const std::vector<std::string>& buffer);
48 
49  template <class T>
50  std::vector<T>
51  getParameter(const std::string& varName, const std::vector<std::string>& buffer){
52  const std::vector<std::string> & varString = getParameterString(varName, buffer);
53  std::vector<T> result;
54  for (const auto & var : varString) {
55  result.emplace_back(fromString<T>(var));
56  }
57  return result;
58  }
59 }
60 #endif
beamspotnt.var
var
Definition: bin/beamspotnt.py:1394
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
get_generator_info.result
result
Definition: get_generator_info.py:21
PixelConditionsData::getParameter
std::vector< T > getParameter(const std::string &varName, const std::vector< std::string > &buffer)
Definition: PixelConditionsDataStringUtils.h:51
createCoolChannelIdFile.buffer
buffer
Definition: createCoolChannelIdFile.py:12
PixelAthClusterMonAlgCfg.varName
string varName
end cluster ToT and charge
Definition: PixelAthClusterMonAlgCfg.py:125
tolower
void tolower(std::string &s)
Definition: AthenaSummarySvc.cxx:111
PixelConditionsData::fromString
T fromString(const std::string &s)
Definition: PixelConditionsDataStringUtils.h:14
PixelConditionsData::getParameterString
std::vector< std::string > getParameterString(const std::string &varName, const std::vector< std::string > &buffer)
Definition: PixelConditionsDataStringUtils.cxx:13
PixelConditionsData
Definition: PixelConditionsDataStringUtils.h:9
python.PyAthena.v
v
Definition: PyAthena.py:154
python.compressB64.c
def c
Definition: compressB64.py:93