Skip to content
Snippets Groups Projects
Commit fe0c7ab5 authored by Anton Piccardo-Selg's avatar Anton Piccardo-Selg
Browse files

Refs #16705 Fix unit test

parent e1a105c7
No related merge requests found
......@@ -183,9 +183,6 @@ LoadCanSAS1D::loadEntry(Poco::XML::Node *const workspaceData,
createLogs(workspaceElem, dataWS);
// Load the sample information
createSampleInformation(workspaceElem, dataWS);
Element *titleElem = workspaceElem->getChildElement("Title");
check(titleElem, "<Title>");
dataWS->setTitle(titleElem->innerText());
......@@ -258,6 +255,9 @@ LoadCanSAS1D::loadEntry(Poco::XML::Node *const workspaceData,
// run load instrument
runLoadInstrument(instname, dataWS);
// Load the sample information
createSampleInformation(workspaceElem, dataWS);
dataWS->getAxis(0)->setUnit("MomentumTransfer");
if (isCommon)
dataWS->setYUnitLabel(yUnit);
......@@ -357,7 +357,7 @@ void LoadCanSAS1D::createLogs(const Poco::XML::Element *const sasEntry,
void LoadCanSAS1D::createSampleInformation(const Poco::XML::Element *const sasEntry,
Mantid::API::MatrixWorkspace_sptr wSpace) const {
auto sample = wSpace->mutableSample();
auto& sample = wSpace->mutableSample();
// Get the thickness information
auto sasSampleElement = sasEntry->getChildElement("SASsample");
......@@ -369,12 +369,12 @@ void LoadCanSAS1D::createSampleInformation(const Poco::XML::Element *const sasEn
}
auto sasInstrumentElement = sasEntry->getChildElement("SASinstrument");
check(sasSampleElement, "<SASinstrument>");
auto sasCollimationElement = sasEntry->getChildElement("SAScollimation");
check(sasSampleElement, "<SAScollimation>");
check(sasInstrumentElement, "<SASinstrument>");
auto sasCollimationElement = sasInstrumentElement->getChildElement("SAScollimation");
check(sasCollimationElement, "<SAScollimation>");
// Get the geometry information
auto geometryElement = sasEntry->getChildElement("name");
auto geometryElement = sasCollimationElement->getChildElement("name");
if (geometryElement) {
auto geometry = geometryElement->innerText();
auto geometryID = getGeometryID(geometry);
......@@ -382,14 +382,14 @@ void LoadCanSAS1D::createSampleInformation(const Poco::XML::Element *const sasEn
}
// Get the thickness information
auto widthElement = sasEntry->getChildElement("X");
auto widthElement = sasCollimationElement->getChildElement("X");
if (widthElement) {
double width = std::stod(widthElement->innerText());
sample.setWidth(width);
}
// Get the thickness information
auto heightElement = sasEntry->getChildElement("Y");
auto heightElement = sasCollimationElement->getChildElement("Y");
if (heightElement) {
double height = std::stod(heightElement->innerText());
sample.setHeight(height);
......
......@@ -143,7 +143,6 @@ void SaveCanSAS1D::exec() {
// are no detecors present
std::string sasInstrument;
try {
std::string sasInstrument;
createSASInstrument(sasInstrument);
}
catch (Kernel::Exception::NotFoundError &) {
......@@ -487,7 +486,7 @@ void SaveCanSAS1D::createSASSampleElement(std::string &sasSample) {
if (thickness > 0) {
std::string thicknessTag = "\n\t\t\t<thickness unit=\"mm\">";
thicknessTag += std::to_string(thickness);
thicknessTag += "<\thickness>";
thicknessTag += "</thickness>";
sasSample += thicknessTag;
}
sasSample += "\n\t\t</SASsample>";
......@@ -636,9 +635,10 @@ void SaveCanSAS1D::createSASInstrument(std::string& sasInstrument) {
std::string collimationGeometry = getProperty("Geometry");
sasCollimation += "\n\t\t\t\t<name>" + collimationGeometry + "</name>";
// Width
sasCollimation += "<X unit=\"mm\">" + std::to_string(collimationWidth) + "</X>";
sasCollimation += "\n\t\t\t\t<X unit=\"mm\">" + std::to_string(collimationWidth) + "</X>";
// Height
sasCollimation += "<Y unit=\"mm\">" + std::to_string(collimationHeight) + "</Y>";
sasCollimation += "\n\t\t\t\t<Y unit=\"mm\">" + std::to_string(collimationHeight) + "</Y>";
sasCollimation += "\n\t\t\t</SAScollimation>";
}
sasInstrument += sasCollimation;
......
......@@ -232,7 +232,7 @@ public:
TS_ASSERT_DELTA(ws2d->dataE(0).back(), 0, tolerance);
// Check that sample information is correct
auto sample = ws2d->sample();
auto& sample = ws2d->sample();
TS_ASSERT(sample.getGeometryFlag() == 1);
TS_ASSERT(sample.getHeight() == 1.0);
TS_ASSERT(sample.getWidth() == 2.0);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment