ATLAS Offline Software
Functions
PixelConditionsData Namespace Reference

Functions

template<class T = std::string>
fromString (const std::string &s)
 
template<>
float fromString (const std::string &s)
 
std::vector< std::string > getParameterString (const std::string &varName, const std::vector< std::string > &buffer)
 
template<class T >
std::vector< T > getParameter (const std::string &varName, const std::vector< std::string > &buffer)
 

Function Documentation

◆ fromString() [1/2]

template<class T = std::string>
T PixelConditionsData::fromString ( const std::string &  s)

Definition at line 14 of file PixelConditionsDataStringUtils.h.

14  {
15  return s;
16  }

◆ fromString() [2/2]

template<>
bool PixelConditionsData::fromString ( const std::string &  s)
inline

Definition at line 20 of file PixelConditionsDataStringUtils.h.

20  {
21  return std::stof(s);
22  }

◆ getParameter()

template<class T >
std::vector<T> PixelConditionsData::getParameter ( const std::string &  varName,
const std::vector< std::string > &  buffer 
)

Definition at line 51 of file PixelConditionsDataStringUtils.h.

51  {
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  }

◆ getParameterString()

std::vector< std::string > PixelConditionsData::getParameterString ( const std::string &  varName,
const std::vector< std::string > &  buffer 
)

Definition at line 13 of file PixelConditionsDataStringUtils.cxx.

13  {
14  std::string sParam = "";
15  std::string sMessage = "";
16 
17  for (size_t i=0; i<buffer.size(); i++) {
18  if (buffer[i].find(varName.c_str())!=std::string::npos) {
19  std::istringstream iss(buffer[i]);
20  std::string s;
21  bool chkParam = false;
22  bool chkMessage = false;
23  while (iss >> s) {
24  if (s.find("{{")!=std::string::npos) {
25  sParam += s.substr(2,s.length());
26  chkParam = true;
27  }
28  else if (s.find("},")!=std::string::npos) {
29  sParam += s.substr(0,s.length()-2);
30  sParam += ",";
31  }
32  else if (s.find("}}")!=std::string::npos) {
33  sParam += s.substr(0,s.length()-2);
34  chkParam = false;
35  chkMessage = true;
36  }
37  else if (s.find("{")!=std::string::npos && s.find("}")!=std::string::npos) {
38  sParam += s.substr(1,s.length()-1);
39  }
40  else if (s.find("{")!=std::string::npos) {
41  sParam += s.substr(1,s.length());
42  chkParam = true;
43  }
44  else if (s.find("}")!=std::string::npos) {
45  sParam += s.substr(0,s.length()-1);
46  chkParam = false;
47  chkMessage = true;
48  }
49  else if (chkParam==true) {
50  sParam += s;
51  }
52  else if (chkMessage==true) {
53  sMessage += " " + s;
54  }
55  }
56  }
57  }
58  if (sParam.empty()) {
59  throw std::runtime_error ("PixelConfigCondAlg::getParameterString() Input variable " + varName + " was not found. " );
60  }
61 
62  std::vector<std::string> vParam;
63  int offset = 0;
64  for (;;) {
65  auto pos = sParam.find(",",offset);
66  if (pos==std::string::npos) {
67  vParam.push_back(sParam.substr(offset,pos));
68  break;
69  }
70  vParam.push_back(sParam.substr(offset,pos-offset));
71  offset = pos + 1;
72  }
73 
74  std::vector<std::string> vvParam;
75  for (const auto & param : vParam) {
76  if (param.find("\"")!=std::string::npos) {
77  if (vParam.size()==1) {
78  vvParam.push_back(param.substr(1,param.length()-3));
79  } else {
80  vvParam.push_back(param.substr(1,param.length()-2));
81  }
82  } else {
83  vvParam.push_back(param);
84  }
85  }
86  return vvParam;
87  }
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
find
std::string find(const std::string &s)
return a remapped string
Definition: hcg.cxx:135
createCoolChannelIdFile.buffer
buffer
Definition: createCoolChannelIdFile.py:12
lumiFormat.i
int i
Definition: lumiFormat.py:92
PixelAthClusterMonAlgCfg.varName
string varName
end cluster ToT and charge
Definition: PixelAthClusterMonAlgCfg.py:117
PixelConditionsData::getParameterString
std::vector< std::string > getParameterString(const std::string &varName, const std::vector< std::string > &buffer)
Definition: PixelConditionsDataStringUtils.cxx:13
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
convertTimingResiduals.offset
offset
Definition: convertTimingResiduals.py:71