66 const bool saveLocationParams =
getProperty(
"LocationParameters");
67 const std::string filename =
getProperty(
"Filename");
75 std::map<ComponentID, std::vector<boost::tuple<std::string, std::string, std::string>>> toSave;
78 Progress prog(
this, 0.0, 0.3, params->size());
81 for (
auto const ¶msIt : params->entries()) {
84 prog.
report(
"Generating parameters");
86 const std::string pName = paramsIt.second->name();
87 const std::string pType = paramsIt.second->
type();
88 const std::string pValue = paramsIt.second->asString();
90 if (pName ==
"x" || pName ==
"y" || pName ==
"z" || pName ==
"r-position" || pName ==
"t-position" ||
91 pName ==
"p-position" || pName ==
"rotx" || pName ==
"roty" || pName ==
"rotz") {
92 g_log.
warning() <<
"The parameter name '" << pName <<
"' is reserved and has not been saved. "
93 <<
"Please contact the Mantid team for more information.";
98 if (saveLocationParams) {
100 std::istringstream pValueSS(pValue);
102 toSave[cID].emplace_back(
"x",
"double", boost::lexical_cast<std::string>(pos.
X()));
103 toSave[cID].emplace_back(
"y",
"double", boost::lexical_cast<std::string>(pos.
Y()));
104 toSave[cID].emplace_back(
"z",
"double", boost::lexical_cast<std::string>(pos.
Z()));
106 }
else if (pName ==
"rot") {
107 if (saveLocationParams) {
109 std::istringstream pValueSS(pValue);
111 toSave[cID].emplace_back(
"rotx",
"double", boost::lexical_cast<std::string>(rot.
X()));
112 toSave[cID].emplace_back(
"roty",
"double", boost::lexical_cast<std::string>(rot.
Y()));
113 toSave[cID].emplace_back(
"rotz",
"double", boost::lexical_cast<std::string>(rot.
Z()));
119 if (pType ==
"fitting") {
123 const auto &fitParam = paramsIt.second->value<
FitParameter>();
124 const std::string fpName = fitParam.
getFunction() +
":" + fitParam.getName();
125 std::stringstream fpValue;
126 fpValue <<
"<formula";
127 fpValue <<
" eq=\"" << fitParam.getFormula() <<
"\"";
128 fpValue <<
" unit=\"" << fitParam.getFormulaUnit() <<
"\"";
129 fpValue <<
" result-unit=\"" << fitParam.getResultUnit() <<
"\"";
131 toSave[cID].emplace_back(boost::make_tuple(fpName,
"fitting", fpValue.str()));
133 toSave[cID].emplace_back(boost::make_tuple(pName, pType, pValue));
138 std::ofstream file(filename.c_str(), std::ofstream::trunc);
139 file <<
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
140 file <<
"<parameter-file instrument=\"" << instrument->getName() <<
"\"";
141 file <<
" valid-from=\"" << ws->instrumentMetadata().validFromDate().toISO8601String() <<
"\">\n";
143 prog.
resetNumSteps(
static_cast<int64_t
>(toSave.size()), 0.6, 1.0);
146 for (
const auto &comp : toSave) {
149 prog.
report(
"Saving parameters");
156 file <<
" <component-link";
158 file <<
" id=\"" << cDetID <<
"\"";
159 file <<
" name=\"" << cFullName <<
"\">\n";
160 for (
const auto ¶m : comp.second) {
161 const std::string pName = param.get<0>();
162 const std::string pType = param.get<1>();
163 const std::string pValue = param.get<2>();
167 if (pType ==
"fitting") {
168 file <<
" <parameter name=\"" << pName <<
"\" type=\"fitting\" >\n";
169 file <<
" " << pValue <<
"\n";
170 file <<
" </parameter>\n";
172 file <<
" <parameter name=\"" << pName <<
"\"" << (pType ==
"string" ?
" type=\"string\"" :
"")
174 file <<
" <value val=\"" << pValue <<
"\"/>\n";
175 file <<
" </parameter>\n";
178 file <<
" </component-link>\n";
180 file <<
"</parameter-file>\n";