ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
InnerDetector
InDetConditions
PixelConditionsData
src
PixelConditionsDataStringUtils.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
PixelConditionsData/PixelConditionsDataStringUtils.h
"
6
#include <sstream>
//std::istringstream
7
#include <stdexcept>
//for std::runtime_error
8
9
10
namespace
PixelConditionsData
{
11
//
12
std::vector<std::string>
13
getParameterString
(
const
std::string& varName,
const
std::vector<std::string>& buffer){
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
}
88
89
}
PixelConditionsDataStringUtils.h
find
std::string find(const std::string &s)
return a remapped string
Definition
hcg.cxx:140
PixelConditionsData
Definition
PixelConditionsDataStringUtils.h:9
PixelConditionsData::getParameterString
std::vector< std::string > getParameterString(const std::string &varName, const std::vector< std::string > &buffer)
Definition
PixelConditionsDataStringUtils.cxx:13
Generated on
for ATLAS Offline Software by
1.17.0