59 G4String error_msg =
"Redefinition of constant or variable: " +
name;
60 G4Exception(
"G4GDMLEvaluator::DefineConstant()",
"InvalidExpression",
71 G4String error_msg =
"Redefinition of constant or variable: " +
name;
72 G4Exception(
"G4GDMLEvaluator::DefineVariable()",
"InvalidExpression",
81 std::vector<G4double> valueList)
83 const G4int size = valueList.size();
88 G4Exception(
"G4GDMLEvaluator::DefineMatrix()",
"InvalidSize",
102 if(size % coldim != 0)
104 G4String error_msg =
"Matrix '" +
name +
"' is not filled correctly!";
105 G4Exception(
"G4GDMLEvaluator::DefineMatrix()",
"InvalidSize",
109 if((size == coldim) || (coldim == 1))
111 for(
G4int i = 0; i < size; ++i)
113 std::stringstream MatrixElementNameStream;
114 MatrixElementNameStream <<
name <<
"_" << i;
120 const G4int rowdim = size / coldim;
122 for(
G4int i = 0; i < rowdim; ++i)
124 for(
G4int j = 0; j < coldim; ++j)
126 std::stringstream MatrixElementNameStream;
127 MatrixElementNameStream <<
name <<
"_" << i <<
"_" << j;
129 valueList[coldim * i + j]);
140 G4String error_msg =
"Variable '" +
name +
"' is not defined!";
141 G4Exception(
"G4GDMLEvaluator::SetVariable()",
"InvalidSetup",
152 for(std::size_t i = 0; i < variableCount; ++i)
166 std::string::size_type full = in.size();
167 std::string::size_type open = in.find(
"[", 0);
168 std::string::size_type close = in.find(
"]", 0);
175 if((open > close) || (open == std::string::npos) ||
176 (close == std::string::npos))
178 G4String error_msg =
"Bracket mismatch: " + in;
179 G4Exception(
"G4GDMLEvaluator::SolveBrackets()",
"InvalidExpression",
184 std::string::size_type begin = open;
185 std::string::size_type end = 0;
186 std::string::size_type end1 = 0;
188 out.append(in, 0, open);
194 end = in.find(
",", begin + 1);
195 end1 = in.find(
"]", begin + 1);
200 if(end == std::string::npos)
205 std::stringstream indexStream;
209 out.append(indexStream.str());
213 }
while(end < close);
220 open = in.find(
"[", begin);
221 close = in.find(
"]", begin + 1);
225 out.append(in.substr(end + 1, full - end - 1));
228 out.append(in.substr(end + 1, open - end - 1));
232 }
while(close < full);
244 if(!expression.empty())
251 G4String error_msg =
"Error in expression: " + expression;
252 G4Exception(
"G4GDMLEvaluator::Evaluate()",
"InvalidExpression",
275 "Expression '" + expression +
"' is expected to have an integer value!";
276 G4Exception(
"G4GDMLEvaluator::EvaluateInteger()",
"InvalidExpression",
288 "Constant '" +
name +
"' is not defined! It is a variable!";
289 G4Exception(
"G4GDMLEvaluator::GetConstant()",
"InvalidSetup",
294 G4String error_msg =
"Constant '" +
name +
"' is not defined!";
295 G4Exception(
"G4GDMLEvaluator::GetConstant()",
"InvalidSetup",
306 G4String error_msg =
"Variable '" +
name +
"' is not a defined!";
307 G4Exception(
"G4GDMLEvaluator::GetVariable()",
"InvalidSetup",
316 std::ostringstream os;
325 std::ostringstream os;
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
static constexpr double kelvin
static constexpr double ampere
static constexpr double candela
static constexpr double kilogram
static constexpr double mole
static constexpr double meter
static constexpr double second
G4double Evaluate(const G4String &)
void SetVariable(const G4String &, G4double)
void DefineVariable(const G4String &, G4double)
void DefineConstant(const G4String &, G4double)
void DefineMatrix(const G4String &, G4int, std::vector< G4double >)
G4double GetVariable(const G4String &)
G4bool IsVariable(const G4String &) const
G4int EvaluateInteger(const G4String &)
std::vector< G4String > variableList
G4double GetConstant(const G4String &)
G4String ConvertToString(G4int ival)
G4String SolveBrackets(const G4String &)
const char * name(G4int ptype)