diff --git a/Framework/Algorithms/inc/MantidAlgorithms/Stitch1D.h b/Framework/Algorithms/inc/MantidAlgorithms/Stitch1D.h index 7ca9db5475d4a05ef40ccde32b27f0a2b7c74750..beaba343583a3af651eb53148ce58ee011843c0d 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/Stitch1D.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/Stitch1D.h @@ -82,9 +82,12 @@ private: weightedMean(Mantid::API::MatrixWorkspace_sptr &inOne, Mantid::API::MatrixWorkspace_sptr &inTwo); /// Conjoin x axis - Mantid::API::MatrixWorkspace_sptr conjoinXAxis(Mantid::API::MatrixWorkspace_sptr &inWS); + Mantid::API::MatrixWorkspace_sptr + conjoinXAxis(Mantid::API::MatrixWorkspace_sptr &inOne, + Mantid::API::MatrixWorkspace_sptr &inTwo); /// Sort x axis - Mantid::API::MatrixWorkspace_sptr sortXAxis(Mantid::API::MatrixWorkspace_sptr &inWS); + Mantid::API::MatrixWorkspace_sptr + sortXAxis(Mantid::API::MatrixWorkspace_sptr &inWS); /// Find the start and end indexes boost::tuple<int, int> findStartEndIndexes(double startOverlap, double endOverlap, diff --git a/Framework/Algorithms/src/Stitch1D.cpp b/Framework/Algorithms/src/Stitch1D.cpp index 3d8dc0f93c7be6560f17cf371c537d1cb96c22fc..44df37e45a2463afb44447c5fb8f6e5be6ef7b15 100644 --- a/Framework/Algorithms/src/Stitch1D.cpp +++ b/Framework/Algorithms/src/Stitch1D.cpp @@ -1,4 +1,5 @@ #include "MantidAlgorithms/Stitch1D.h" +#include "MantidAPI/AnalysisDataService.h" #include "MantidAPI/WorkspaceProperty.h" #include "MantidAPI/MatrixWorkspace.h" #include "MantidAPI/WorkspaceFactory.h" @@ -374,11 +375,18 @@ MatrixWorkspace_sptr Stitch1D::weightedMean(MatrixWorkspace_sptr &inOne, @param inWS :: Input workspace @return A shared pointer to the resulting MatrixWorkspace */ -MatrixWorkspace_sptr Stitch1D::conjoinXAxis(MatrixWorkspace_sptr &inWS) { - auto conjoinX = this->createChildAlgortihm("ConjoinXRuns"); - conjoinX->setProperty("InputWorkspace", inWS); +MatrixWorkspace_sptr Stitch1D::conjoinXAxis(MatrixWorkspace_sptr &inOne, + MatrixWorkspace_sptr &inTwo) { + std::string in1 = "__Stitch1D_intermediate_workspace_1__"; + std::string in2 = "__Stitch1D_intermediate_workspace_2__"; + Mantid::API::AnalysisDataService::Instance().addOrReplace(in1, inOne); + Mantid::API::AnalysisDataService::Instance().addOrReplace(in2, inTwo); + auto conjoinX = this->createChildAlgorithm("ConjoinXRuns"); + conjoinX->setProperty("InputWorkspace", std::vector<std::string>{in1, in2}); conjoinX->execute(); MatrixWorkspace_sptr outWS = conjoinX->getProperty("OutputWorkspace"); + Mantid::API::AnalysisDataService::Instance().remove(in1); + Mantid::API::AnalysisDataService::Instance().remove(in2); return outWS; } @@ -387,7 +395,7 @@ MatrixWorkspace_sptr Stitch1D::conjoinXAxis(MatrixWorkspace_sptr &inWS) { @return A shared pointer to the resulting MatrixWorkspace */ MatrixWorkspace_sptr Stitch1D::sortXAxis(MatrixWorkspace_sptr &inWS) { - auto sortX = this->createChildAlgortihm("SortXAxis"); + auto sortX = this->createChildAlgorithm("SortXAxis"); sortX->setProperty("InputWorkspace", inWS); sortX->execute(); MatrixWorkspace_sptr outWS = sortX->getProperty("OutputWorkspace"); @@ -585,7 +593,8 @@ void Stitch1D::exec() { // If the input workspaces are point data ... if (!rhsWS->isHistogramData() && !lhsWS->isHistogramData()) { // Sort according to x values - overlapave = sortXAxis(conjoinXaxis(overlap1, overlap2)); + auto ws = conjoinXAxis(overlap1, overlap2); + overlapave = sortXAxis(ws); } else { g_log.error("Input workspaces must be both histograms or point data"); throw std::invalid_argument( diff --git a/Framework/Algorithms/test/Stitch1DTest.h b/Framework/Algorithms/test/Stitch1DTest.h index 14cbb5e0a9f52c004af113ff1eb35dbb293eb3ef..e7c78f3208669e833a0272795f71cdbcb2e2abb2 100644 --- a/Framework/Algorithms/test/Stitch1DTest.h +++ b/Framework/Algorithms/test/Stitch1DTest.h @@ -8,10 +8,10 @@ #include "MantidAPI/Axis.h" #include "MantidKernel/UnitFactory.h" #include "MantidDataObjects/Workspace2D.h" -#include "MantidHistogramData/HistogramX.h" -#include "MantidHistogramData/HistogramY.h" #include "MantidHistogramData/HistogramDx.h" #include "MantidHistogramData/HistogramE.h" +#include "MantidHistogramData/HistogramX.h" +#include "MantidHistogramData/HistogramY.h" #include "MantidHistogramData/LinearGenerator.h" #include <algorithm>