Skip to content

Commit

Permalink
Preparation for getting parameter values re #7617
Browse files Browse the repository at this point in the history
Signed-off-by: Karl Palmen <karl.palmen@stfc.ac.uk>
  • Loading branch information
KarlPalmen committed Sep 18, 2013
1 parent b96fed5 commit 5e9d170
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,18 @@ namespace DataHandling
/// Add an ALFBE parameter
void addALFBEparameter(const API::ITableWorkspace_sptr & tablews, Poco::XML::Document* mDoc, Poco::XML::Element* parent, const std::string paramName);

/// Get value for XML eq attribute for parameter
std::string ConvertFullprofToXML::getXMLEqValue( const API::ITableWorkspace_sptr & tablews, const std::string name, size_t bankNumber);

// Translate a parameter name from as it appears in the table workspace to its name in the XML file
std::string getXMLParameterName( const std::string name );

/// Get row numbers of the parameters in the table workspace
void getTableRowNumbers(const API::ITableWorkspace_sptr & tablews, std::map<std::string, size_t>& parammap);

/// Place to store the row numbers
std::map<std::string, size_t> m_rowNumbers;

};


Expand Down
24 changes: 22 additions & 2 deletions Code/Mantid/Framework/DataHandling/src/ConvertFullprofToXML.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,6 @@ namespace DataHandling
// Get Output
std::string paramfile = getProperty("OutputFilename");

//vector<int> outputbankids = getProperty("Banks");

// Load with LoadFullprofResolution
auto loader = createChildAlgorithm("LoadFullprofResolution");
loader->setProperty("Filename",datafile);
Expand All @@ -100,6 +98,8 @@ namespace DataHandling

// Set up access to table workspace ParamTable
API::ITableWorkspace_sptr paramTable = loader->getProperty("OutputWorkspace");
// get the table workspace row numbers of the parameters and store them for later use
getTableRowNumbers( paramTable, m_rowNumbers);

// Set up access to Output file
std::ofstream outFile(paramfile.c_str());
Expand Down Expand Up @@ -161,9 +161,19 @@ namespace DataHandling
Element* parameterElem = mDoc->createElement("parameter");
parameterElem->setAttribute("name", getXMLParameterName(paramName));
parameterElem->setAttribute("type","fitting");

Element *formulaElem = mDoc->createElement("formula");
formulaElem->setAttribute("eq",getXMLEqValue(tablews, paramName, 1));
if(paramName != "Beta1") formulaElem->setAttribute("result-unit","TOF");
parameterElem->appendChild(formulaElem);

Element* fixedElem = mDoc->createElement("fixed");
parameterElem->appendChild(fixedElem);

parent->appendChild(parameterElem);
}


/*
* Get the XML name of a parameter given its Table Workspace name
*/
Expand All @@ -177,6 +187,16 @@ namespace DataHandling
return "?"+name;
}

/*
* Get the value string to put in the XML eq attribute of the formula element of the paramenter element
* given the name of the parameter in the table workspace.
*/
std::string ConvertFullprofToXML::getXMLEqValue( const API::ITableWorkspace_sptr & tablews, const std::string name, size_t bankNumber)
{
//API::Column_const_sptr column = tablews->getColumn( bankNumber );
return "?"+name+std::to_string(bankNumber);
}

/* This function fills in a list of the row numbers starting 0 of the parameters
in the table workspace, so one can find the position in a column of
the value of the given parameter.
Expand Down

0 comments on commit 5e9d170

Please sign in to comment.