diff --git a/Framework/DataHandling/src/LoadCanSAS1D.cpp b/Framework/DataHandling/src/LoadCanSAS1D.cpp index aef4e70f724b3fc0414a18b3cf9acb9fa33e6201..c6dd8995fffb1b49157966c5340b2a05082e3641 100644 --- a/Framework/DataHandling/src/LoadCanSAS1D.cpp +++ b/Framework/DataHandling/src/LoadCanSAS1D.cpp @@ -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); diff --git a/Framework/DataHandling/src/SaveCanSAS1D.cpp b/Framework/DataHandling/src/SaveCanSAS1D.cpp index 58980acbd32ddd1680393fcb3cfcf7b6c396025c..1eefe34d11e19cbe7df9b81c98e8730d5ae9a9e6 100644 --- a/Framework/DataHandling/src/SaveCanSAS1D.cpp +++ b/Framework/DataHandling/src/SaveCanSAS1D.cpp @@ -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; diff --git a/Framework/DataHandling/test/SaveCanSAS1dTest.h b/Framework/DataHandling/test/SaveCanSAS1dTest.h index 0d517d238902584ddcbfb5f746f6fd73c768cf91..e01d254b3c2fe497c88e4f624232a0ba5c9bd82d 100644 --- a/Framework/DataHandling/test/SaveCanSAS1dTest.h +++ b/Framework/DataHandling/test/SaveCanSAS1dTest.h @@ -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);