Skip to content

Commit

Permalink
Make changes recommended by Gesner re #7617
Browse files Browse the repository at this point in the history
Corrected comments, use ManditoryValidator and use AutoPtr.

Signed-off-by: Karl Palmen <karl.palmen@stfc.ac.uk>
  • Loading branch information
KarlPalmen committed Oct 7, 2013
1 parent f050bcd commit f21c017
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace Mantid
namespace DataHandling
{

/** LoadFullprofResolution : Load Fullprof resolution (.irf) file to TableWorkspace(s)
/** ConvertFullprofToXML : Convert a fullprof resolution file to an instrument parameter file
Copyright &copy; 2013 ISIS Rutherford Appleton Laboratory & NScD Oak Ridge National Laboratory
Expand Down
27 changes: 15 additions & 12 deletions Code/Mantid/Framework/DataHandling/src/ConvertFullprofToXML.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Convert the initial fitting parameters in a Fullprof file to XML format in an [[
*WIKI*/
#include "MantidDataHandling/ConvertFullprofToXML.h"
#include "MantidDataHandling/LoadFullprofResolution.h"
#include "MantidKernel/MandatoryValidator.h"
#include "MantidAPI/FileProperty.h"
#include "MantidAPI/TableRow.h"

Expand All @@ -14,6 +15,7 @@ Convert the initial fitting parameters in a Fullprof file to XML format in an [[
#include <Poco/DOM/Document.h>
#include <Poco/DOM/DOMWriter.h>
#include <Poco/DOM/Element.h>
#include <Poco/DOM/AutoPtr.h>

#include <boost/lexical_cast.hpp>

Expand All @@ -23,6 +25,7 @@ namespace Mantid
namespace DataHandling
{
using namespace API;
using namespace Kernel;
using namespace Poco::XML;

DECLARE_ALGORITHM(ConvertFullprofToXML)
Expand Down Expand Up @@ -65,7 +68,7 @@ namespace DataHandling
"Path to an Fullprof file to load.");

// Instrument name
declareProperty("InstrumentName", "", "Name of instrument for the input file" );
declareProperty("InstrumentName", "",boost::make_shared<MandatoryValidator<std::string>>(), "Name of instrument for the input file" );

// Output file
std::vector<std::string> extso;
Expand Down Expand Up @@ -127,13 +130,13 @@ namespace DataHandling
std::string ISOdateShort = ISOdate.substr(0,19); // Remove fraction of seconds

// Create document
Poco::XML::Document* mDoc = new Document();
Element* rootElem = mDoc->createElement("parameter-file");
AutoPtr<Document> mDoc = new Document();
AutoPtr<Element> rootElem = mDoc->createElement("parameter-file");
rootElem->setAttribute("date", ISOdateShort);
mDoc->appendChild(rootElem);

// Add instrument
Element* instrumentElem = mDoc->createElement("component-link");
AutoPtr<Element> instrumentElem = mDoc->createElement("component-link");
instrumentElem->setAttribute("name",instrumentName);
rootElem->appendChild(instrumentElem);
addALFBEParameter( paramTable, mDoc, instrumentElem, "Alph0");
Expand All @@ -153,7 +156,7 @@ namespace DataHandling
const double bankNumber = column->cell<double>(0);
std::ostringstream bankName;
bankName << "bank" << bankNumber;
Element* bankElem = mDoc->createElement("component-link");
AutoPtr<Element> bankElem = mDoc->createElement("component-link");
bankElem->setAttribute("name",bankName.str());
addSigmaParameters( paramTable, mDoc, bankElem, i+1);
addGammaParameters( paramTable, mDoc, bankElem, i+1);
Expand All @@ -173,16 +176,16 @@ namespace DataHandling
*/
void ConvertFullprofToXML::addALFBEParameter(const API::ITableWorkspace_sptr & tablews, Poco::XML::Document* mDoc, Element* parent, const std::string& paramName)
{
Element* parameterElem = mDoc->createElement("parameter");
AutoPtr<Element> parameterElem = mDoc->createElement("parameter");
parameterElem->setAttribute("name", getXMLParameterName(paramName));
parameterElem->setAttribute("type","fitting");

Element *formulaElem = mDoc->createElement("formula");
AutoPtr<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");
AutoPtr<Element> fixedElem = mDoc->createElement("fixed");
parameterElem->appendChild(fixedElem);

parent->appendChild(parameterElem);
Expand All @@ -193,11 +196,11 @@ namespace DataHandling
*/
void ConvertFullprofToXML::addSigmaParameters(const API::ITableWorkspace_sptr & tablews, Poco::XML::Document* mDoc, Poco::XML::Element* parent, size_t columnIndex)
{
Element* parameterElem = mDoc->createElement("parameter");
AutoPtr<Element> parameterElem = mDoc->createElement("parameter");
parameterElem->setAttribute("name", "IkedaCarpenterPV:SigmaSquared");
parameterElem->setAttribute("type","fitting");

Element *formulaElem = mDoc->createElement("formula");
AutoPtr<Element> formulaElem = mDoc->createElement("formula");
std::string eqValue = getXMLEqValue(tablews, "Sig1", columnIndex)+"*centre^2+"+getXMLEqValue(tablews, "Sig0", columnIndex);
formulaElem->setAttribute("eq", eqValue);
formulaElem->setAttribute("unit","dSpacing");
Expand All @@ -212,11 +215,11 @@ namespace DataHandling
*/
void ConvertFullprofToXML::addGammaParameters(const API::ITableWorkspace_sptr & tablews, Poco::XML::Document* mDoc, Poco::XML::Element* parent, size_t columnIndex)
{
Element* parameterElem = mDoc->createElement("parameter");
AutoPtr<Element> parameterElem = mDoc->createElement("parameter");
parameterElem->setAttribute("name", "IkedaCarpenterPV:Gamma");
parameterElem->setAttribute("type","fitting");

Element *formulaElem = mDoc->createElement("formula");
AutoPtr<Element> formulaElem = mDoc->createElement("formula");
std::string eqValue = getXMLEqValue(tablews, "Gam1", columnIndex)+"*centre";
formulaElem->setAttribute("eq", eqValue);
formulaElem->setAttribute("unit","dSpacing");
Expand Down

0 comments on commit f21c017

Please sign in to comment.