diff --git a/Framework/Algorithms/src/AbsorptionCorrection.cpp b/Framework/Algorithms/src/AbsorptionCorrection.cpp index 7ab980db4e194b3611df72ea56565b3b61e036cf..f25ae11d9b5eb365130740d271c7e25e7ead8cca 100644 --- a/Framework/Algorithms/src/AbsorptionCorrection.cpp +++ b/Framework/Algorithms/src/AbsorptionCorrection.cpp @@ -8,8 +8,8 @@ #include "MantidAPI/InstrumentValidator.h" #include "MantidAPI/Sample.h" #include "MantidAPI/SpectrumInfo.h" -#include "MantidAPI/WorkspaceFactory.h" #include "MantidAPI/WorkspaceUnitValidator.h" +#include "MantidDataObjects/WorkspaceCreation.h" #include "MantidGeometry/IDetector.h" #include "MantidGeometry/Instrument.h" #include "MantidGeometry/Objects/ShapeFactory.h" @@ -32,6 +32,7 @@ using namespace Geometry; using HistogramData::interpolateLinearInplace; using namespace Kernel; using namespace Mantid::PhysicalConstants; +using namespace Mantid::DataObjects; AbsorptionCorrection::AbsorptionCorrection() : API::Algorithm(), m_inputWS(), m_sampleObject(nullptr), m_L1s(), @@ -109,8 +110,7 @@ void AbsorptionCorrection::exec() { retrieveBaseProperties(); // Create the output workspace - MatrixWorkspace_sptr correctionFactors = - WorkspaceFactory::Instance().create(m_inputWS); + MatrixWorkspace_sptr correctionFactors = create<MatrixWorkspace>(*m_inputWS); correctionFactors->setDistribution( true); // The output of this is a distribution correctionFactors->setYUnit(""); // Need to explicitly set YUnit to nothing diff --git a/Framework/Algorithms/src/ApplyDetailedBalance.cpp b/Framework/Algorithms/src/ApplyDetailedBalance.cpp index 45d66be1f2af763803e237b5416ad2486729f716..8fc540533a86c24d2647790bdd4d2e2b5862d5b2 100644 --- a/Framework/Algorithms/src/ApplyDetailedBalance.cpp +++ b/Framework/Algorithms/src/ApplyDetailedBalance.cpp @@ -6,8 +6,8 @@ // SPDX - License - Identifier: GPL - 3.0 + #include "MantidAlgorithms/ApplyDetailedBalance.h" #include "MantidAPI/Run.h" -#include "MantidAPI/WorkspaceFactory.h" #include "MantidAPI/WorkspaceUnitValidator.h" +#include "MantidDataObjects/WorkspaceCreation.h" #include "MantidKernel/CompositeValidator.h" #include "MantidKernel/ListValidator.h" #include "MantidKernel/PhysicalConstants.h" @@ -20,6 +20,7 @@ using std::string; using namespace Mantid::Kernel; using namespace Mantid::API; +using namespace Mantid::DataObjects; namespace Mantid { namespace Algorithms { @@ -57,7 +58,7 @@ void ApplyDetailedBalance::exec() { // If input and output workspaces are not the same, create a new workspace for // the output if (outputWS != inputWS) { - outputWS = API::WorkspaceFactory::Instance().create(inputWS); + outputWS = create<MatrixWorkspace>(*inputWS); } std::string Tstring = getProperty("Temperature"); diff --git a/Framework/Algorithms/src/ApplyTransmissionCorrection.cpp b/Framework/Algorithms/src/ApplyTransmissionCorrection.cpp index 142430f764cd2d0412035b108d758b2851866083..2b51542019a67a55e9219e91458e6f38f3b4d962 100644 --- a/Framework/Algorithms/src/ApplyTransmissionCorrection.cpp +++ b/Framework/Algorithms/src/ApplyTransmissionCorrection.cpp @@ -7,9 +7,10 @@ #include "MantidAlgorithms/ApplyTransmissionCorrection.h" #include "MantidAPI/HistogramValidator.h" #include "MantidAPI/SpectrumInfo.h" -#include "MantidAPI/WorkspaceFactory.h" #include "MantidAPI/WorkspaceOpOverloads.h" #include "MantidAPI/WorkspaceUnitValidator.h" +#include "MantidDataObjects/Workspace2D.h" +#include "MantidDataObjects/WorkspaceCreation.h" #include "MantidGeometry/IDetector.h" #include "MantidKernel/BoundedValidator.h" #include "MantidKernel/CompositeValidator.h" @@ -24,6 +25,7 @@ using namespace Kernel; using namespace API; using namespace Geometry; using namespace HistogramData; +using namespace DataObjects; void ApplyTransmissionCorrection::init() { auto wsValidator = boost::make_shared<CompositeValidator>(); @@ -90,7 +92,7 @@ void ApplyTransmissionCorrection::exec() { Progress progress(this, 0.0, 1.0, numHists); // Create a Workspace2D to match the intput workspace - MatrixWorkspace_sptr corrWS = WorkspaceFactory::Instance().create(inputWS); + MatrixWorkspace_sptr corrWS = create<HistoWorkspace>(*inputWS); const auto &spectrumInfo = inputWS->spectrumInfo(); @@ -137,4 +139,4 @@ void ApplyTransmissionCorrection::exec() { } } // namespace Algorithms -} // namespace Mantid +} // namespace Mantid \ No newline at end of file diff --git a/Framework/Algorithms/src/BinaryOperation.cpp b/Framework/Algorithms/src/BinaryOperation.cpp index 902e34b4527d478d1c5ef83185221e5bb9b6c74f..ae226187b58f2fc88543aadfbce4fbab127b9e1b 100644 --- a/Framework/Algorithms/src/BinaryOperation.cpp +++ b/Framework/Algorithms/src/BinaryOperation.cpp @@ -13,17 +13,20 @@ #include "MantidAPI/WorkspaceProperty.h" #include "MantidDataObjects/EventList.h" #include "MantidDataObjects/EventWorkspace.h" +#include "MantidDataObjects/Workspace2D.h" +#include "MantidDataObjects/WorkspaceCreation.h" #include "MantidDataObjects/WorkspaceSingleValue.h" #include "MantidGeometry/Instrument/ParameterMap.h" +#include "MantidHistogramData/Histogram.h" #include "MantidKernel/Timer.h" #include "MantidKernel/Unit.h" - #include <boost/make_shared.hpp> using namespace Mantid::Geometry; using namespace Mantid::API; using namespace Mantid::Kernel; using namespace Mantid::DataObjects; +using namespace Mantid::HistogramData; using std::size_t; namespace Mantid { @@ -105,7 +108,7 @@ bool BinaryOperation::handleSpecialDivideMinus() { } else if (this->name() == "Minus") { // x - workspace = x + (workspace * -1) MatrixWorkspace_sptr minusOne = - WorkspaceFactory::Instance().create("WorkspaceSingleValue", 1, 1, 1); + create<WorkspaceSingleValue>(1, Points(1)); minusOne->dataY(0)[0] = -1.0; minusOne->dataE(0)[0] = 0.0; @@ -234,7 +237,7 @@ void BinaryOperation::exec() { // (b) it has been, but it's not the correct dimensions if ((m_out != m_lhs && m_out != m_rhs) || (m_out == m_rhs && (m_lhs->size() > m_rhs->size()))) { - m_out = WorkspaceFactory::Instance().create(m_lhs); + m_out = create<HistoWorkspace>(*m_lhs); } } diff --git a/Framework/Algorithms/src/CalculateCarpenterSampleCorrection.cpp b/Framework/Algorithms/src/CalculateCarpenterSampleCorrection.cpp index f23a237bd14afb0dbbb4eb45d6fa8dd3b12d992a..64adee333fc8b708c64c343e4298db405569263e 100644 --- a/Framework/Algorithms/src/CalculateCarpenterSampleCorrection.cpp +++ b/Framework/Algorithms/src/CalculateCarpenterSampleCorrection.cpp @@ -5,13 +5,14 @@ // & Institut Laue - Langevin // SPDX - License - Identifier: GPL - 3.0 + #include "MantidAlgorithms/CalculateCarpenterSampleCorrection.h" +#include "MantidAPI/HistoWorkspace.h" #include "MantidAPI/InstrumentValidator.h" #include "MantidAPI/Sample.h" #include "MantidAPI/SpectrumInfo.h" -#include "MantidAPI/WorkspaceFactory.h" #include "MantidAPI/WorkspaceGroup.h" #include "MantidAPI/WorkspaceUnitValidator.h" #include "MantidDataObjects/EventWorkspace.h" +#include "MantidDataObjects/WorkspaceCreation.h" #include "MantidGeometry/Instrument.h" #include "MantidKernel/CompositeValidator.h" #include "MantidKernel/Material.h" @@ -23,7 +24,7 @@ namespace Algorithms { DECLARE_ALGORITHM(CalculateCarpenterSampleCorrection) // Register the class // into the algorithm // factory - +using namespace DataObjects; using namespace Kernel; using namespace API; using Mantid::DataObjects::EventWorkspace; @@ -414,8 +415,7 @@ void CalculateCarpenterSampleCorrection::calculate_ms_correction( MatrixWorkspace_sptr CalculateCarpenterSampleCorrection::createOutputWorkspace( const MatrixWorkspace_sptr &inputWksp, const std::string ylabel) const { - MatrixWorkspace_sptr outputWS = - WorkspaceFactory::Instance().create(inputWksp); + MatrixWorkspace_sptr outputWS = create<HistoWorkspace>(*inputWksp); // The algorithm computes the signal values at bin centres so they should // be treated as a distribution outputWS->setDistribution(true); diff --git a/Framework/Algorithms/src/CalculateCountRate.cpp b/Framework/Algorithms/src/CalculateCountRate.cpp index d76b56968cbbbed4dae000cb25c78093f6c46964..2ed73de1868f8326b8d9d9925aebc464dd53898f 100644 --- a/Framework/Algorithms/src/CalculateCountRate.cpp +++ b/Framework/Algorithms/src/CalculateCountRate.cpp @@ -6,6 +6,13 @@ // SPDX - License - Identifier: GPL - 3.0 + #include "MantidAlgorithms/CalculateCountRate.h" +#include "MantidAPI/AlgorithmManager.h" +#include "MantidAPI/Axis.h" +#include "MantidAPI/NumericAxis.h" +#include "MantidAPI/Run.h" +#include "MantidDataObjects/Workspace2D.h" +#include "MantidDataObjects/WorkspaceCreation.h" +#include "MantidHistogramData/Histogram.h" #include "MantidKernel/BoundedValidator.h" #include "MantidKernel/ListValidator.h" #include "MantidKernel/MandatoryValidator.h" @@ -15,15 +22,11 @@ #include "MantidKernel/UnitFactory.h" #include "MantidKernel/make_unique.h" -#include "MantidAPI/AlgorithmManager.h" -#include "MantidAPI/Axis.h" -#include "MantidAPI/NumericAxis.h" -#include "MantidAPI/Run.h" -#include "MantidAPI/WorkspaceFactory.h" - -#include "MantidDataObjects/Workspace2D.h" #include <numeric> +using namespace Mantid::DataObjects; +using namespace Mantid::HistogramData; + namespace Mantid { namespace Algorithms { @@ -621,9 +624,7 @@ void CalculateCountRate::checkAndInitVisWorkspace() { int numXBins = getProperty("XResolution"); std::string RangeUnits = getProperty("RangeUnits"); - m_visWs = boost::dynamic_pointer_cast<DataObjects::Workspace2D>( - API::WorkspaceFactory::Instance().create("Workspace2D", numTBins, - numXBins + 1, numXBins)); + m_visWs = create<Workspace2D>(numTBins, BinEdges(numXBins + 1)); m_visWs->setTitle(visWSName); double Xmax = m_XRangeMax; diff --git a/Framework/Algorithms/src/CalculateFlatBackground.cpp b/Framework/Algorithms/src/CalculateFlatBackground.cpp index e198dd19cabcc7820646e420d005d991f500ff58..f4af7be9e98e4ac4b11ceccf169bf3459abf254d 100644 --- a/Framework/Algorithms/src/CalculateFlatBackground.cpp +++ b/Framework/Algorithms/src/CalculateFlatBackground.cpp @@ -9,15 +9,17 @@ #include "MantidAPI/IFunction.h" #include "MantidAPI/MatrixWorkspace.h" #include "MantidAPI/SpectrumInfo.h" -#include "MantidAPI/WorkspaceFactory.h" #include "MantidAPI/WorkspaceOpOverloads.h" #include "MantidDataObjects/TableWorkspace.h" +#include "MantidDataObjects/Workspace2D.h" +#include "MantidDataObjects/WorkspaceCreation.h" #include "MantidGeometry/IDetector.h" #include "MantidHistogramData/Histogram.h" #include "MantidKernel/ArrayProperty.h" #include "MantidKernel/EnabledWhenProperty.h" #include "MantidKernel/ListValidator.h" #include "MantidKernel/VectorHelper.h" + #include <algorithm> #include <boost/lexical_cast.hpp> #include <climits> @@ -31,6 +33,7 @@ DECLARE_ALGORITHM(CalculateFlatBackground) using namespace Kernel; using namespace API; +using namespace DataObjects; /// Enumeration for the different operating modes. enum class Modes { LINEAR_FIT, MEAN, MOVING_AVERAGE }; @@ -168,7 +171,7 @@ void CalculateFlatBackground::exec() { // If input and output workspaces are not the same, create a new workspace for // the output if (outputWS != inputWS) { - outputWS = WorkspaceFactory::Instance().create(inputWS); + outputWS = create<MatrixWorkspace>(*inputWS); } // For logging purposes. @@ -382,8 +385,7 @@ void CalculateFlatBackground::Mean(const HistogramData::Histogram &histogram, void CalculateFlatBackground::LinearFit( const HistogramData::Histogram &histogram, double &background, double &variance, const double startX, const double endX) { - MatrixWorkspace_sptr WS = WorkspaceFactory::Instance().create( - "Workspace2D", 1, histogram.x().size(), histogram.y().size()); + MatrixWorkspace_sptr WS = create<Workspace2D>(1, histogram); WS->setHistogram(0, histogram); IAlgorithm_sptr childAlg = createChildAlgorithm("Fit"); diff --git a/Framework/Algorithms/src/CalculateTransmissionBeamSpreader.cpp b/Framework/Algorithms/src/CalculateTransmissionBeamSpreader.cpp index 865aff8b9478926b7852531b2aedf9a2e0b57adc..0e55bf577e1663f6b802c9aef644d4dc5634e328 100644 --- a/Framework/Algorithms/src/CalculateTransmissionBeamSpreader.cpp +++ b/Framework/Algorithms/src/CalculateTransmissionBeamSpreader.cpp @@ -11,10 +11,12 @@ #include "MantidAPI/CommonBinsValidator.h" #include "MantidAPI/HistogramValidator.h" #include "MantidAPI/SpectrumInfo.h" -#include "MantidAPI/WorkspaceFactory.h" #include "MantidAPI/WorkspaceOpOverloads.h" #include "MantidAPI/WorkspaceUnitValidator.h" +#include "MantidDataObjects/WorkspaceCreation.h" +#include "MantidDataObjects/WorkspaceSingleValue.h" #include "MantidGeometry/Instrument.h" +#include "MantidHistogramData/Histogram.h" #include "MantidKernel/BoundedValidator.h" #include "MantidKernel/CompositeValidator.h" #include "MantidKernel/ListValidator.h" @@ -27,6 +29,8 @@ DECLARE_ALGORITHM(CalculateTransmissionBeamSpreader) using namespace Kernel; using namespace API; +using namespace DataObjects; +using namespace HistogramData; using std::size_t; void CalculateTransmissionBeamSpreader::init() { @@ -163,7 +167,7 @@ void CalculateTransmissionBeamSpreader::exec() { // Beam spreader transmission MatrixWorkspace_sptr spreader_trans = - WorkspaceFactory::Instance().create("WorkspaceSingleValue", 1, 1, 1); + create<WorkspaceSingleValue>(1, Points(1)); spreader_trans->setYUnit(""); spreader_trans->setDistribution(true); spreader_trans->mutableX(0)[0] = 0.0; diff --git a/Framework/Algorithms/src/CalculateZscore.cpp b/Framework/Algorithms/src/CalculateZscore.cpp index 8caa61e7e4bf083601e4e3be12ccc4f3d40c3ee2..48ba9b1315f96332539d58c70b89aee7e9596196 100644 --- a/Framework/Algorithms/src/CalculateZscore.cpp +++ b/Framework/Algorithms/src/CalculateZscore.cpp @@ -5,11 +5,12 @@ // & Institut Laue - Langevin // SPDX - License - Identifier: GPL - 3.0 + #include "MantidAlgorithms/CalculateZscore.h" - #include "MantidAPI/MatrixWorkspace.h" -#include "MantidAPI/WorkspaceFactory.h" #include "MantidAPI/WorkspaceProperty.h" #include "MantidDataObjects/Workspace2D.h" +#include "MantidDataObjects/WorkspaceCreation.h" +#include "MantidHistogramData/Histogram.h" +#include "MantidHistogramData/HistogramBuilder.h" #include "MantidKernel/ArrayProperty.h" #include "MantidKernel/Statistics.h" @@ -19,6 +20,7 @@ using namespace Mantid; using namespace Mantid::API; using namespace Mantid::Kernel; using namespace Mantid::DataObjects; +using namespace Mantid::HistogramData; using namespace std; namespace Mantid { @@ -66,9 +68,11 @@ void CalculateZscore::exec() { size_t sizex = inpWS->x(0).size(); size_t sizey = inpWS->y(0).size(); - Workspace2D_sptr outWS = boost::dynamic_pointer_cast<Workspace2D>( - WorkspaceFactory::Instance().create("Workspace2D", numspec, sizex, - sizey)); + HistogramBuilder builder; + builder.setX(sizex); + builder.setY(sizey); + builder.setDistribution(inpWS->isDistribution()); + Workspace2D_sptr outWS = create<Workspace2D>(numspec, builder.build()); Progress progress(this, 0.0, 1.0, numspec); diff --git a/Framework/Algorithms/src/ChopData.cpp b/Framework/Algorithms/src/ChopData.cpp index 1f3c335c70061908c64b7c269dbcf90c0f3b9ff1..18d497604b5ea9a14124d72bcb7591cb6fffa51f 100644 --- a/Framework/Algorithms/src/ChopData.cpp +++ b/Framework/Algorithms/src/ChopData.cpp @@ -6,10 +6,12 @@ // SPDX - License - Identifier: GPL - 3.0 + #include "MantidAlgorithms/ChopData.h" #include "MantidAPI/HistogramValidator.h" +#include "MantidAPI/MatrixWorkspace.h" #include "MantidAPI/SpectraAxisValidator.h" -#include "MantidAPI/WorkspaceFactory.h" #include "MantidAPI/WorkspaceGroup.h" #include "MantidAPI/WorkspaceUnitValidator.h" +#include "MantidDataObjects/WorkspaceCreation.h" +#include "MantidHistogramData/Histogram.h" #include "MantidKernel/CompositeValidator.h" #include "MantidKernel/MultiThreaded.h" @@ -18,6 +20,8 @@ namespace Algorithms { using namespace Kernel; using namespace API; using namespace Geometry; +using namespace DataObjects; +using namespace HistogramData; DECLARE_ALGORITHM(ChopData) @@ -42,7 +46,7 @@ void ChopData::init() { void ChopData::exec() { // Get the input workspace - MatrixWorkspace_const_sptr inputWS = getProperty("InputWorkspace"); + MatrixWorkspace_sptr inputWS = getProperty("InputWorkspace"); const std::string output = getPropertyValue("OutputWorkspace"); const double step = getProperty("Step"); const int chops = getProperty("NChops"); @@ -70,9 +74,8 @@ void ChopData::exec() { // Select the spectrum that is to be used to compare the sections of the // workspace // This will generally be the monitor spectrum. - MatrixWorkspace_sptr monitorWS; - monitorWS = WorkspaceFactory::Instance().create(inputWS, 1); - monitorWS->setHistogram(0, inputWS->histogram(monitorWi)); + MatrixWorkspace_sptr monitorWS = + create<MatrixWorkspace>(*inputWS, 1, inputWS->histogram(monitorWi)); int lowest = 0; @@ -132,8 +135,7 @@ void ChopData::exec() { size_t nbins = indexHigh - indexLow; MatrixWorkspace_sptr workspace = - Mantid::API::WorkspaceFactory::Instance().create(inputWS, nHist, - nbins + 1, nbins); + create<MatrixWorkspace>(*inputWS, BinEdges(nbins + 1)); // Copy over X, Y and E data PARALLEL_FOR_IF(Kernel::threadSafe(*inputWS, *workspace)) diff --git a/Framework/Algorithms/src/CompareWorkspaces.cpp b/Framework/Algorithms/src/CompareWorkspaces.cpp index 6c37c7e6b5e095cb49f1af161415b5305013000d..e73fcac8f5cd18bbe03fb8a0c9d5bdbceeffeab9 100644 --- a/Framework/Algorithms/src/CompareWorkspaces.cpp +++ b/Framework/Algorithms/src/CompareWorkspaces.cpp @@ -14,7 +14,6 @@ #include "MantidAPI/Run.h" #include "MantidAPI/Sample.h" #include "MantidAPI/TableRow.h" -#include "MantidAPI/WorkspaceFactory.h" #include "MantidAPI/WorkspaceGroup.h" #include "MantidDataObjects/EventWorkspace.h" #include "MantidDataObjects/PeaksWorkspace.h" @@ -179,7 +178,7 @@ void CompareWorkspaces::init() { "Messages", "compare_msgs", Direction::Output), "TableWorkspace containing messages about any mismatches detected"); - m_messages = WorkspaceFactory::Instance().createTable("TableWorkspace"); + m_messages = boost::make_shared<TableWorkspace>(); m_messages->addColumn("str", "Message"); m_messages->addColumn("str", "Workspace 1"); m_messages->addColumn("str", "Workspace 2"); diff --git a/Framework/Algorithms/src/ConjoinXRuns.cpp b/Framework/Algorithms/src/ConjoinXRuns.cpp index a690c3904925d7906d2ec2e66b3f737fddbf65c8..9b0cf6147625ab617c189b1a0316bd70b164b281 100644 --- a/Framework/Algorithms/src/ConjoinXRuns.cpp +++ b/Framework/Algorithms/src/ConjoinXRuns.cpp @@ -11,12 +11,13 @@ #include "MantidAPI/Axis.h" #include "MantidAPI/MatrixWorkspace.h" #include "MantidAPI/Run.h" -#include "MantidAPI/WorkspaceFactory.h" #include "MantidAPI/WorkspaceGroup.h" #include "MantidAPI/WorkspaceHistory.h" #include "MantidAlgorithms/RunCombinationHelpers/RunCombinationHelper.h" #include "MantidAlgorithms/RunCombinationHelpers/SampleLogsBehaviour.h" +#include "MantidDataObjects/WorkspaceCreation.h" #include "MantidGeometry/Instrument.h" +#include "MantidHistogramData/Histogram.h" #include "MantidHistogramData/HistogramDx.h" #include "MantidHistogramData/HistogramE.h" #include "MantidHistogramData/HistogramX.h" @@ -36,6 +37,8 @@ namespace Algorithms { using namespace API; using namespace Kernel; using namespace RunCombinationOptions; +using namespace DataObjects; +using namespace HistogramData; namespace { static const std::string INPUT_WORKSPACE_PROPERTY = "InputWorkspaces"; @@ -425,8 +428,7 @@ void ConjoinXRuns::exec() { // now get the size of the output size_t numSpec = first->getNumberHistograms(); - m_outWS = WorkspaceFactory::Instance().create(first, numSpec, outBlockSize, - outBlockSize); + m_outWS = create<MatrixWorkspace>(*first, Points(outBlockSize)); // copy over the merged sample logs from the temp m_outWS->mutableRun() = temp->run(); diff --git a/Framework/Algorithms/src/ConvertSpectrumAxis.cpp b/Framework/Algorithms/src/ConvertSpectrumAxis.cpp index 9c60660acc4d923d649cc164c06705e8dc705c1e..77227d39bc6311bdec96f1413752f43672ce4bfc 100644 --- a/Framework/Algorithms/src/ConvertSpectrumAxis.cpp +++ b/Framework/Algorithms/src/ConvertSpectrumAxis.cpp @@ -10,8 +10,10 @@ #include "MantidAPI/Run.h" #include "MantidAPI/SpectraAxisValidator.h" #include "MantidAPI/SpectrumInfo.h" -#include "MantidAPI/WorkspaceFactory.h" +#include "MantidDataObjects/WorkspaceCreation.h" #include "MantidGeometry/Instrument.h" +#include "MantidHistogramData/Histogram.h" +#include "MantidHistogramData/HistogramBuilder.h" #include "MantidKernel/BoundedValidator.h" #include "MantidKernel/CompositeValidator.h" #include "MantidKernel/ListValidator.h" @@ -30,7 +32,8 @@ DECLARE_ALGORITHM(ConvertSpectrumAxis) using namespace Kernel; using namespace API; using namespace Geometry; - +using namespace DataObjects; +using namespace HistogramData; namespace { constexpr double rad2deg = 180. / M_PI; } @@ -151,8 +154,12 @@ void ConvertSpectrumAxis::exec() { } // Create the output workspace. Can't re-use the input one because we'll be // re-ordering the spectra. - MatrixWorkspace_sptr outputWS = WorkspaceFactory::Instance().create( - inputWS, indexMap.size(), nxBins, nBins); + HistogramBuilder builder; + builder.setX(nxBins); + builder.setY(nBins); + builder.setDistribution(inputWS->isDistribution()); + MatrixWorkspace_sptr outputWS = + create<MatrixWorkspace>(*inputWS, indexMap.size(), builder.build()); // Now set up a new, numeric axis holding the theta values corresponding to // each spectrum auto const newAxis = new NumericAxis(indexMap.size()); diff --git a/Framework/Algorithms/src/ConvertSpectrumAxis2.cpp b/Framework/Algorithms/src/ConvertSpectrumAxis2.cpp index 3c32827ff26c2401c4cf49597ef4a4769b6522e1..ac059dd9aa914764c28b4ce2bb4d2a3e5062db45 100644 --- a/Framework/Algorithms/src/ConvertSpectrumAxis2.cpp +++ b/Framework/Algorithms/src/ConvertSpectrumAxis2.cpp @@ -10,9 +10,11 @@ #include "MantidAPI/Run.h" #include "MantidAPI/SpectraAxisValidator.h" #include "MantidAPI/SpectrumInfo.h" -#include "MantidAPI/WorkspaceFactory.h" +#include "MantidDataObjects/WorkspaceCreation.h" #include "MantidGeometry/Instrument.h" #include "MantidGeometry/Instrument/DetectorInfo.h" +#include "MantidHistogramData/Histogram.h" +#include "MantidHistogramData/HistogramBuilder.h" #include "MantidKernel/BoundedValidator.h" #include "MantidKernel/CompositeValidator.h" #include "MantidKernel/ListValidator.h" @@ -32,6 +34,8 @@ DECLARE_ALGORITHM(ConvertSpectrumAxis2) using namespace Kernel; using namespace API; using namespace Geometry; +using namespace DataObjects; +using namespace HistogramData; void ConvertSpectrumAxis2::init() { // Validator for Input Workspace @@ -225,8 +229,12 @@ MatrixWorkspace_sptr ConvertSpectrumAxis2::createOutputWorkspace( NumericAxis *newAxis = nullptr; if (m_toOrder) { // Can not re-use the input one because the spectra are re-ordered. - outputWorkspace = WorkspaceFactory::Instance().create( - inputWS, m_indexMap.size(), inputWS->x(0).size(), inputWS->y(0).size()); + HistogramBuilder builder; + builder.setX(inputWS->x(0).size()); + builder.setY(inputWS->y(0).size()); + builder.setDistribution(inputWS->isDistribution()); + outputWorkspace = + create<MatrixWorkspace>(*inputWS, m_indexMap.size(), builder.build()); std::vector<double> axis; axis.reserve(m_indexMap.size()); for (const auto &it : m_indexMap) { diff --git a/Framework/Algorithms/src/ConvertTableToMatrixWorkspace.cpp b/Framework/Algorithms/src/ConvertTableToMatrixWorkspace.cpp index 80e20d161ff5908fc14e129b5c9f0fb2a7c964d0..27366c2ed18e6cff466af4221bc6d7ef469b1e11 100644 --- a/Framework/Algorithms/src/ConvertTableToMatrixWorkspace.cpp +++ b/Framework/Algorithms/src/ConvertTableToMatrixWorkspace.cpp @@ -11,7 +11,8 @@ #include "MantidAPI/Axis.h" #include "MantidAPI/ITableWorkspace.h" #include "MantidAPI/MatrixWorkspace.h" -#include "MantidAPI/WorkspaceFactory.h" +#include "MantidDataObjects/Workspace2D.h" +#include "MantidDataObjects/WorkspaceCreation.h" #include "MantidKernel/MandatoryValidator.h" #include "MantidKernel/Unit.h" #include "MantidKernel/UnitFactory.h" @@ -25,6 +26,7 @@ DECLARE_ALGORITHM(ConvertTableToMatrixWorkspace) using namespace Kernel; using namespace API; using namespace HistogramData; +using namespace DataObjects; void ConvertTableToMatrixWorkspace::init() { declareProperty(make_unique<WorkspaceProperty<API::ITableWorkspace>>( @@ -57,8 +59,7 @@ void ConvertTableToMatrixWorkspace::exec() { auto X = inputWorkspace->getColumn(columnX)->numeric_fill<>(); auto Y = inputWorkspace->getColumn(columnY)->numeric_fill<>(); - MatrixWorkspace_sptr outputWorkspace = - WorkspaceFactory::Instance().create("Workspace2D", 1, nrows, nrows); + MatrixWorkspace_sptr outputWorkspace = create<Workspace2D>(1, Points(nrows)); outputWorkspace->mutableX(0).assign(X.begin(), X.end()); outputWorkspace->mutableY(0).assign(Y.begin(), Y.end()); diff --git a/Framework/Algorithms/src/ConvertToConstantL2.cpp b/Framework/Algorithms/src/ConvertToConstantL2.cpp index 6817490d4a212da87742a5d9491b928758aa1942..c91fca9ca5336e158b879c5bf2e7f860f893997d 100644 --- a/Framework/Algorithms/src/ConvertToConstantL2.cpp +++ b/Framework/Algorithms/src/ConvertToConstantL2.cpp @@ -8,9 +8,9 @@ #include "MantidAPI/HistogramValidator.h" #include "MantidAPI/Run.h" #include "MantidAPI/SpectrumInfo.h" -#include "MantidAPI/WorkspaceFactory.h" #include "MantidAPI/WorkspaceUnitValidator.h" #include "MantidDataObjects/Workspace2D.h" +#include "MantidDataObjects/WorkspaceCreation.h" #include "MantidGeometry/Instrument/DetectorInfo.h" #include "MantidGeometry/Instrument/ParameterMap.h" #include "MantidKernel/CompositeValidator.h" @@ -27,6 +27,7 @@ namespace Algorithms { using namespace Kernel; using namespace API; using namespace Geometry; +using namespace DataObjects; // Register the class into the algorithm factory DECLARE_ALGORITHM(ConvertToConstantL2) @@ -63,7 +64,7 @@ void ConvertToConstantL2::initWorkspaces() { // If input and output workspaces are not the same, create a new workspace for // the output if (m_outputWS != this->m_inputWS) { - m_outputWS = API::WorkspaceFactory::Instance().create(m_inputWS); + m_outputWS = create<MatrixWorkspace>(*m_inputWS); } m_wavelength = getRunProperty("wavelength"); diff --git a/Framework/Algorithms/src/ConvertToMatrixWorkspace.cpp b/Framework/Algorithms/src/ConvertToMatrixWorkspace.cpp index ab3124aea545723d1e52e953099dcc146621f127..e1a58403aa5e0f4e2fac2a2000f7efc2fd0bf8bd 100644 --- a/Framework/Algorithms/src/ConvertToMatrixWorkspace.cpp +++ b/Framework/Algorithms/src/ConvertToMatrixWorkspace.cpp @@ -8,8 +8,9 @@ // Includes //---------------------------------------------------------------------- #include "MantidAlgorithms/ConvertToMatrixWorkspace.h" -#include "MantidAPI/WorkspaceFactory.h" #include "MantidDataObjects/EventWorkspace.h" +#include "MantidDataObjects/Workspace2D.h" +#include "MantidDataObjects/WorkspaceCreation.h" namespace Mantid { namespace Algorithms { @@ -51,7 +52,7 @@ void ConvertToMatrixWorkspace::exec() { // Create the output workspace. This will copy many aspects fron the input // one. - outputWorkspace = WorkspaceFactory::Instance().create(inputWorkspace); + outputWorkspace = create<Workspace2D>(*inputWorkspace); // ...but not the data, so do that here. PARALLEL_FOR_IF(Kernel::threadSafe(*inputWorkspace, *outputWorkspace)) diff --git a/Framework/Algorithms/src/ConvertUnits.cpp b/Framework/Algorithms/src/ConvertUnits.cpp index 3d949b0102a478530641f6f088977f2c26524701..c82f6f0a836e0c67c0742009dbae4ea9973aeb21 100644 --- a/Framework/Algorithms/src/ConvertUnits.cpp +++ b/Framework/Algorithms/src/ConvertUnits.cpp @@ -10,11 +10,12 @@ #include "MantidAPI/CommonBinsValidator.h" #include "MantidAPI/Run.h" #include "MantidAPI/SpectrumInfo.h" -#include "MantidAPI/WorkspaceFactory.h" #include "MantidAPI/WorkspaceUnitValidator.h" #include "MantidDataObjects/EventWorkspace.h" #include "MantidDataObjects/Workspace2D.h" +#include "MantidDataObjects/WorkspaceCreation.h" #include "MantidGeometry/Instrument.h" +#include "MantidHistogramData/Histogram.h" #include "MantidKernel/BoundedValidator.h" #include "MantidKernel/CompositeValidator.h" #include "MantidKernel/ListValidator.h" @@ -734,8 +735,7 @@ API::MatrixWorkspace_sptr ConvertUnits::removeUnphysicalBins( MantidVec::difference_type bins = X0.cend() - start; MantidVec::difference_type first = start - X0.cbegin(); - result = - WorkspaceFactory::Instance().create(workspace, numSpec, bins, bins - 1); + result = create<MatrixWorkspace>(*workspace, BinEdges(bins)); for (size_t i = 0; i < numSpec; ++i) { auto &X = workspace->x(i); @@ -765,8 +765,7 @@ API::MatrixWorkspace_sptr ConvertUnits::removeUnphysicalBins( g_log.debug() << maxBins << '\n'; // Now create an output workspace large enough for the longest 'good' // range - result = WorkspaceFactory::Instance().create(workspace, numSpec, maxBins, - maxBins - 1); + result = create<MatrixWorkspace>(*workspace, numSpec, BinEdges(maxBins)); // Next, loop again copying in the correct range for each spectrum for (int64_t j = 0; j < int64_t(numSpec); ++j) { auto edges = workspace->binEdges(j); diff --git a/Framework/Algorithms/src/CorrectKiKf.cpp b/Framework/Algorithms/src/CorrectKiKf.cpp index 19aeeb1d15e3c28b340f51dcf0701ff8a4f500c7..b716b1b811bf30d629adb7a390e17d0dd44be0cf 100644 --- a/Framework/Algorithms/src/CorrectKiKf.cpp +++ b/Framework/Algorithms/src/CorrectKiKf.cpp @@ -7,10 +7,10 @@ #include "MantidAlgorithms/CorrectKiKf.h" #include "MantidAPI/Run.h" #include "MantidAPI/SpectrumInfo.h" -#include "MantidAPI/WorkspaceFactory.h" #include "MantidAPI/WorkspaceUnitValidator.h" #include "MantidDataObjects/EventWorkspace.h" #include "MantidDataObjects/Workspace2D.h" +#include "MantidDataObjects/WorkspaceCreation.h" #include "MantidGeometry/IDetector.h" #include "MantidGeometry/Instrument/ParameterMap.h" #include "MantidKernel/BoundedValidator.h" @@ -69,7 +69,7 @@ void CorrectKiKf::exec() { // If input and output workspaces are not the same, create a new workspace for // the output if (outputWS != inputWS) { - outputWS = API::WorkspaceFactory::Instance().create(inputWS); + outputWS = create<MatrixWorkspace>(*inputWS); } const size_t size = inputWS->blocksize(); diff --git a/Framework/Algorithms/src/CorrectToFile.cpp b/Framework/Algorithms/src/CorrectToFile.cpp index 6f4eaaff87ff12a99b75ae6be972878531574eeb..97156180b6b106b12a6fd7431d3d4df73e185895 100644 --- a/Framework/Algorithms/src/CorrectToFile.cpp +++ b/Framework/Algorithms/src/CorrectToFile.cpp @@ -8,14 +8,16 @@ #include "MantidAPI/Axis.h" #include "MantidAPI/FileProperty.h" #include "MantidAPI/MatrixWorkspace.h" -#include "MantidAPI/WorkspaceFactory.h" +#include "MantidDataObjects/Workspace2D.h" +#include "MantidDataObjects/WorkspaceCreation.h" #include "MantidKernel/ListValidator.h" #include "MantidKernel/Unit.h" #include "MantidKernel/UnitFactory.h" namespace Mantid { namespace Algorithms { -using namespace Mantid::API; +using namespace API; +using namespace DataObjects; // Register the algorithm into the AlgorithmFactory DECLARE_ALGORITHM(CorrectToFile) @@ -54,9 +56,7 @@ void CorrectToFile::exec() { MatrixWorkspace_sptr rkhInput = loadInFile(getProperty("Filename")); // Only create the output workspace if it's not the same as the input one MatrixWorkspace_sptr outputWS = getProperty("OutputWorkspace"); - if (outputWS != toCorrect) { - outputWS = WorkspaceFactory::Instance().create(toCorrect); - } + outputWS = create<HistoWorkspace>(*toCorrect); const std::string operation = getProperty("WorkspaceOperation"); if (getPropertyValue("FirstColumnValue") == "SpectrumNumber") { diff --git a/Framework/Algorithms/src/CreateEPP.cpp b/Framework/Algorithms/src/CreateEPP.cpp index f2b0f25024cad4064d32046b49d2feed6c349420..23010b27a774731f7d23a0c7c51e1addffa24af8 100644 --- a/Framework/Algorithms/src/CreateEPP.cpp +++ b/Framework/Algorithms/src/CreateEPP.cpp @@ -10,8 +10,8 @@ #include "MantidAPI/InstrumentValidator.h" #include "MantidAPI/Run.h" #include "MantidAPI/SpectrumInfo.h" -#include "MantidAPI/WorkspaceFactory.h" #include "MantidAPI/WorkspaceUnitValidator.h" +#include "MantidDataObjects/TableWorkspace.h" #include "MantidKernel/BoundedValidator.h" #include "MantidKernel/CompositeValidator.h" #include "MantidKernel/UnitConversion.h" @@ -110,7 +110,7 @@ void CreateEPP::exec() { getProperty(PropertyNames::INPUT_WORKSPACE); const auto &spectrumInfo = inputWS->spectrumInfo(); API::ITableWorkspace_sptr outputWS = - API::WorkspaceFactory::Instance().createTable("TableWorkspace"); + boost::make_shared<DataObjects::TableWorkspace>(); addEPPColumns(outputWS); const double sigma = getProperty(PropertyNames::SIGMA); const size_t spectraCount = spectrumInfo.size(); diff --git a/Framework/Algorithms/src/CreateLogPropertyTable.cpp b/Framework/Algorithms/src/CreateLogPropertyTable.cpp index 1135ca795298f40105ff261ace70d23e581b24bf..b9507ea9fa8b09127b0d8854313c0e1031e1f0a7 100644 --- a/Framework/Algorithms/src/CreateLogPropertyTable.cpp +++ b/Framework/Algorithms/src/CreateLogPropertyTable.cpp @@ -10,8 +10,8 @@ #include "MantidAPI/MatrixWorkspace.h" #include "MantidAPI/Run.h" #include "MantidAPI/TableRow.h" -#include "MantidAPI/WorkspaceFactory.h" #include "MantidAPI/WorkspaceGroup.h" +#include "MantidDataObjects/TableWorkspace.h" #include "MantidKernel/ArrayProperty.h" #include "MantidKernel/ListValidator.h" #include "MantidKernel/MandatoryValidator.h" @@ -113,8 +113,7 @@ void CreateLogPropertyTable::exec() { } // Set up output table. - boost::shared_ptr<ITableWorkspace> outputTable = - WorkspaceFactory::Instance().createTable(); + auto outputTable = boost::make_shared<DataObjects::TableWorkspace>(); // One column for each property. for (const auto &propName : propNames) outputTable->addColumn("str", propName); diff --git a/Framework/Algorithms/src/CrossCorrelate.cpp b/Framework/Algorithms/src/CrossCorrelate.cpp index 5b6fc3c3d248bec3a7db2ea9890c7339bbc23260..c69a51125016c588caefa2c177f62aa43c72afac 100644 --- a/Framework/Algorithms/src/CrossCorrelate.cpp +++ b/Framework/Algorithms/src/CrossCorrelate.cpp @@ -9,13 +9,14 @@ //---------------------------------------------------------------------- #include "MantidAlgorithms/CrossCorrelate.h" #include "MantidAPI/RawCountValidator.h" -#include "MantidAPI/WorkspaceFactory.h" #include "MantidAPI/WorkspaceUnitValidator.h" +#include "MantidDataObjects/Workspace2D.h" +#include "MantidDataObjects/WorkspaceCreation.h" +#include "MantidHistogramData/Histogram.h" #include "MantidKernel/BoundedValidator.h" #include "MantidKernel/CompositeValidator.h" #include "MantidKernel/VectorHelper.h" #include <boost/iterator/counting_iterator.hpp> - #include <numeric> #include <sstream> @@ -27,6 +28,8 @@ DECLARE_ALGORITHM(CrossCorrelate) using namespace Kernel; using namespace API; +using namespace DataObjects; +using namespace HistogramData; /// Initialisation method. void CrossCorrelate::init() { @@ -145,7 +148,7 @@ void CrossCorrelate::exec() { throw std::runtime_error("Range is not valid"); MatrixWorkspace_sptr out = - WorkspaceFactory::Instance().create(inputWS, nspecs, npoints, npoints); + create<HistoWorkspace>(*inputWS, nspecs, Points(npoints)); // Calculate the mean value of the reference spectrum and associated error // squared diff --git a/Framework/Algorithms/src/DetectorEfficiencyCor.cpp b/Framework/Algorithms/src/DetectorEfficiencyCor.cpp index f64f3109f0525bba17da9682d70beb819d7e7110..eb9d456a4d41dcd44a62d7e9ef78ea86c4b229fb 100644 --- a/Framework/Algorithms/src/DetectorEfficiencyCor.cpp +++ b/Framework/Algorithms/src/DetectorEfficiencyCor.cpp @@ -10,8 +10,8 @@ #include "MantidAPI/InstrumentValidator.h" #include "MantidAPI/Run.h" #include "MantidAPI/SpectrumInfo.h" -#include "MantidAPI/WorkspaceFactory.h" #include "MantidAPI/WorkspaceUnitValidator.h" +#include "MantidDataObjects/WorkspaceCreation.h" #include "MantidGeometry/Instrument.h" #include "MantidGeometry/Instrument/DetectorInfo.h" #include "MantidGeometry/Instrument/ParameterMap.h" @@ -34,6 +34,7 @@ DECLARE_ALGORITHM(DetectorEfficiencyCor) using namespace Kernel; using namespace API; using namespace Geometry; +using namespace DataObjects; namespace { @@ -187,7 +188,7 @@ void DetectorEfficiencyCor::retrieveProperties() { // If input and output workspaces are not the same, create a new workspace for // the output if (m_outputWS != m_inputWS) { - m_outputWS = WorkspaceFactory::Instance().create(m_inputWS); + m_outputWS = create<MatrixWorkspace>(*m_inputWS); } } diff --git a/Framework/Algorithms/src/DiffractionFocussing.cpp b/Framework/Algorithms/src/DiffractionFocussing.cpp index 58f8d7d10793abc1ebdbc87dc60e502d2f12f76d..be20de7ea77766ba7731a3a00ac4eac261c5585b 100644 --- a/Framework/Algorithms/src/DiffractionFocussing.cpp +++ b/Framework/Algorithms/src/DiffractionFocussing.cpp @@ -8,7 +8,8 @@ #include "MantidAPI/Axis.h" #include "MantidAPI/FileProperty.h" #include "MantidAPI/MatrixWorkspace.h" -#include "MantidAPI/WorkspaceFactory.h" +#include "MantidDataObjects/WorkspaceCreation.h" +#include "MantidHistogramData/Histogram.h" #include "MantidIndexing/IndexInfo.h" #include "MantidKernel/Unit.h" @@ -29,6 +30,8 @@ DiffractionFocussing::DiffractionFocussing() } using namespace Kernel; +using namespace HistogramData; + using API::FileProperty; using API::MatrixWorkspace; using API::MatrixWorkspace_sptr; @@ -134,8 +137,8 @@ void DiffractionFocussing::exec() { // Create a new workspace that's the right size for the meaningful spectra and // copy them in int64_t newSize = tmpW->blocksize(); - API::MatrixWorkspace_sptr outputW = API::WorkspaceFactory::Instance().create( - tmpW, resultIndeces.size(), newSize + 1, newSize); + API::MatrixWorkspace_sptr outputW = DataObjects::create<API::MatrixWorkspace>( + *tmpW, resultIndeces.size(), BinEdges(newSize + 1)); std::vector<Indexing::SpectrumNumber> specNums; const auto &tmpIndices = tmpW->indexInfo(); diff --git a/Framework/Algorithms/src/DiffractionFocussing2.cpp b/Framework/Algorithms/src/DiffractionFocussing2.cpp index 777eb1fde1f0bc02a200705c2b0d027918e8351d..fbdb9bbf475d8f5be46a07b82993b42425217e10 100644 --- a/Framework/Algorithms/src/DiffractionFocussing2.cpp +++ b/Framework/Algorithms/src/DiffractionFocussing2.cpp @@ -670,4 +670,4 @@ size_t DiffractionFocussing2::setupGroupToWSIndices() { } } // namespace Algorithms -} // namespace Mantid +} // namespace Mantid \ No newline at end of file diff --git a/Framework/Algorithms/src/ExportTimeSeriesLog.cpp b/Framework/Algorithms/src/ExportTimeSeriesLog.cpp index dba47373726eaa697c6d7243f55883802a43a0c0..467f50b90262027872d1c57577a68d9df6f39ef8 100644 --- a/Framework/Algorithms/src/ExportTimeSeriesLog.cpp +++ b/Framework/Algorithms/src/ExportTimeSeriesLog.cpp @@ -9,13 +9,13 @@ #include "MantidAPI/FileProperty.h" #include "MantidAPI/IEventList.h" #include "MantidAPI/Run.h" -#include "MantidAPI/WorkspaceFactory.h" #include "MantidAPI/WorkspaceProperty.h" #include "MantidDataObjects/EventList.h" #include "MantidDataObjects/EventWorkspace.h" #include "MantidDataObjects/Events.h" #include "MantidDataObjects/WorkspaceCreation.h" #include "MantidGeometry/Instrument.h" +#include "MantidHistogramData/Histogram.h" #include "MantidKernel/ListValidator.h" #include "MantidKernel/System.h" #include "MantidKernel/TimeSeriesProperty.h" @@ -28,6 +28,7 @@ using namespace Mantid; using namespace Mantid::Kernel; using namespace Mantid::API; using namespace Mantid::DataObjects; +using namespace Mantid::HistogramData; using Mantid::Types::Core::DateAndTime; using namespace std; @@ -247,12 +248,7 @@ void ExportTimeSeriesLog::setupWorkspace2D( outsize = static_cast<size_t>(numentries); // Create 2D workspace - m_outWS = boost::dynamic_pointer_cast<MatrixWorkspace>( - WorkspaceFactory::Instance().create("Workspace2D", nspec, outsize, - outsize)); - if (!m_outWS) - throw runtime_error( - "Unable to create a Workspace2D casted to MatrixWorkspace."); + m_outWS = create<Workspace2D>(nspec, Points(outsize)); auto &vecX = m_outWS->mutableX(0); auto &vecY = m_outWS->mutableY(0); diff --git a/Framework/Algorithms/src/ExtractFFTSpectrum.cpp b/Framework/Algorithms/src/ExtractFFTSpectrum.cpp index 989d8c7188f712d6056eb04f28251370fa3d6480..19c58c4628a3c6405a33747f23846f2ee9383209 100644 --- a/Framework/Algorithms/src/ExtractFFTSpectrum.cpp +++ b/Framework/Algorithms/src/ExtractFFTSpectrum.cpp @@ -10,7 +10,7 @@ #include "MantidAlgorithms/ExtractFFTSpectrum.h" #include "MantidAPI/Axis.h" #include "MantidAPI/MatrixWorkspace.h" -#include "MantidAPI/WorkspaceFactory.h" +#include "MantidDataObjects/WorkspaceCreation.h" #include "MantidKernel/BoundedValidator.h" #include "MantidKernel/MultiThreaded.h" #include "MantidKernel/Unit.h" @@ -24,6 +24,7 @@ DECLARE_ALGORITHM(ExtractFFTSpectrum) using namespace Kernel; using namespace API; +using namespace DataObjects; void ExtractFFTSpectrum::init() { declareProperty( @@ -47,7 +48,7 @@ void ExtractFFTSpectrum::exec() { MatrixWorkspace_sptr inputImagWS = getProperty("InputImagWorkspace"); const int fftPart = getProperty("FFTPart"); const int numHists = static_cast<int>(inputWS->getNumberHistograms()); - MatrixWorkspace_sptr outputWS = WorkspaceFactory::Instance().create(inputWS); + MatrixWorkspace_sptr outputWS = create<MatrixWorkspace>(*inputWS); Progress prog(this, 0.0, 1.0, numHists); diff --git a/Framework/Algorithms/src/FFT.cpp b/Framework/Algorithms/src/FFT.cpp index 4cf73af92ebb65a983ef5a9a35a6fc95e9c270ce..81acadcb049ef4a02fd33fac8565714f32cd0296 100644 --- a/Framework/Algorithms/src/FFT.cpp +++ b/Framework/Algorithms/src/FFT.cpp @@ -10,7 +10,9 @@ #include "MantidAlgorithms/FFT.h" #include "MantidAPI/MatrixWorkspace.h" #include "MantidAPI/TextAxis.h" -#include "MantidAPI/WorkspaceFactory.h" +#include "MantidDataObjects/Workspace2D.h" +#include "MantidDataObjects/WorkspaceCreation.h" +#include "MantidHistogramData/Histogram.h" #include "MantidKernel/BoundedValidator.h" #include "MantidKernel/EnabledWhenProperty.h" #include "MantidKernel/EqualBinsChecker.h" @@ -36,6 +38,8 @@ DECLARE_ALGORITHM(FFT) using namespace Kernel; using namespace API; +using namespace DataObjects; +using namespace HistogramData; /// Initialisation method. Declares properties to be used in algorithm. void FFT::init() { @@ -111,7 +115,8 @@ void FFT::exec() { addPositiveOnly = true; } - m_outWS = WorkspaceFactory::Instance().create(m_inWS, nOut, nPoints, nPoints); + m_outWS = create<HistoWorkspace>(*m_inWS, nOut, Points(nPoints)); + for (int i = 0; i < nOut; ++i) m_outWS->getSpectrum(i).setDetectorID(static_cast<detid_t>(i + 1)); diff --git a/Framework/Algorithms/src/FFTDerivative.cpp b/Framework/Algorithms/src/FFTDerivative.cpp index 55d244b9e9a3e4831f9c20b715ed35b34373a666..f989a2442b3bf6e2840603cf5eed32e84d252401 100644 --- a/Framework/Algorithms/src/FFTDerivative.cpp +++ b/Framework/Algorithms/src/FFTDerivative.cpp @@ -6,7 +6,9 @@ // SPDX - License - Identifier: GPL - 3.0 + #include "MantidAlgorithms/FFTDerivative.h" #include "MantidAPI/MatrixWorkspace.h" -#include "MantidAPI/WorkspaceFactory.h" +#include "MantidDataObjects/WorkspaceCreation.h" +#include "MantidHistogramData/Histogram.h" +#include "MantidHistogramData/HistogramBuilder.h" #include "MantidKernel/BoundedValidator.h" #include <algorithm> @@ -23,6 +25,8 @@ DECLARE_ALGORITHM(FFTDerivative) using namespace Mantid::Kernel; using namespace Mantid::API; +using namespace Mantid::DataObjects; +using namespace Mantid::HistogramData; void FFTDerivative::init() { declareProperty( @@ -52,10 +56,13 @@ void FFTDerivative::execComplexFFT() { // Workspace for holding a copy of a spectrum. Each spectrum is symmetrized to // minimize // possible edge effects. + + HistogramBuilder builder; + builder.setX(nx + ny); + builder.setY(ny + ny); + builder.setDistribution(inWS->isDistribution()); MatrixWorkspace_sptr copyWS = - boost::dynamic_pointer_cast<Mantid::API::MatrixWorkspace>( - Mantid::API::WorkspaceFactory::Instance().create(inWS, 1, nx + ny, - ny + ny)); + create<MatrixWorkspace>(*inWS, 1, builder.build()); for (size_t spec = 0; spec < n; ++spec) { symmetriseSpectrum(inWS->histogram(spec), copyWS->mutableX(0), @@ -93,8 +100,7 @@ void FFTDerivative::execComplexFFT() { } if (!outWS) { - outWS = boost::dynamic_pointer_cast<Mantid::API::MatrixWorkspace>( - Mantid::API::WorkspaceFactory::Instance().create(inWS)); + outWS = create<MatrixWorkspace>(*inWS); } // Save the upper half of the inverse transform for output diff --git a/Framework/Algorithms/src/FFTSmooth.cpp b/Framework/Algorithms/src/FFTSmooth.cpp index b8a911eb23f05ec1f4fe6698de2f67f2802b553d..735e7e9a123af25c4eb79143cc864908d4a5534c 100644 --- a/Framework/Algorithms/src/FFTSmooth.cpp +++ b/Framework/Algorithms/src/FFTSmooth.cpp @@ -10,10 +10,12 @@ #include "MantidAlgorithms/FFTSmooth.h" #include "MantidAPI/MatrixWorkspace.h" #include "MantidAPI/TextAxis.h" -#include "MantidAPI/WorkspaceFactory.h" -#include "MantidKernel/Exception.h" - +#include "MantidDataObjects/Workspace2D.h" +#include "MantidDataObjects/WorkspaceCreation.h" +#include "MantidHistogramData/Histogram.h" +#include "MantidHistogramData/HistogramBuilder.h" #include "MantidKernel/BoundedValidator.h" +#include "MantidKernel/Exception.h" #include "MantidKernel/ListValidator.h" namespace Mantid { @@ -24,6 +26,8 @@ DECLARE_ALGORITHM(FFTSmooth) using namespace Kernel; using namespace API; +using namespace DataObjects; +using namespace HistogramData; /// Initialisation method. Declares properties to be used in algorithm. void FFTSmooth::init() { @@ -58,8 +62,12 @@ void FFTSmooth::exec() { // Symmetrize the input spectrum int dn = static_cast<int>(m_inWS->y(0).size()); - API::MatrixWorkspace_sptr symmWS = API::WorkspaceFactory::Instance().create( - "Workspace2D", 1, m_inWS->x(0).size() + dn, m_inWS->y(0).size() + dn); + HistogramBuilder builder; + builder.setX(m_inWS->x(0).size() + dn); + builder.setY(m_inWS->y(0).size() + dn); + builder.setDistribution(m_inWS->isDistribution()); + API::MatrixWorkspace_sptr symmWS = + create<Workspace2D>(*m_inWS, 1, builder.build()); double dx = (m_inWS->x(spec).back() - m_inWS->x(spec).front()) / static_cast<double>(m_inWS->x(spec).size() - 1); @@ -121,8 +129,11 @@ void FFTSmooth::exec() { API::MatrixWorkspace_sptr tmpWS = fft->getProperty("OutputWorkspace"); // Create output - API::MatrixWorkspace_sptr outWS = API::WorkspaceFactory::Instance().create( - m_inWS, 1, m_inWS->x(0).size(), m_inWS->y(0).size()); + builder.setX(m_inWS->x(0).size()); + builder.setY(m_inWS->y(0).size()); + builder.setDistribution(m_inWS->isDistribution()); + API::MatrixWorkspace_sptr outWS = + create<MatrixWorkspace>(*m_inWS, 1, builder.build()); dn = static_cast<int>(tmpWS->blocksize()) / 2; @@ -144,8 +155,11 @@ void FFTSmooth::truncate(int n) { if (ny == 0) ny = 1; int nx = m_unfilteredWS->isHistogramData() ? ny + 1 : ny; - m_filteredWS = - API::WorkspaceFactory::Instance().create(m_unfilteredWS, 2, nx, ny); + HistogramBuilder builder; + builder.setX(nx); + builder.setY(ny); + builder.setDistribution(m_unfilteredWS->isDistribution()); + m_filteredWS = create<MatrixWorkspace>(*m_unfilteredWS, 2, builder.build()); auto &Yr = m_unfilteredWS->y(0); auto &Yi = m_unfilteredWS->y(1); @@ -178,8 +192,11 @@ void FFTSmooth::zero(int n) { if (ny == 0) ny = 1; - m_filteredWS = - API::WorkspaceFactory::Instance().create(m_unfilteredWS, 2, mx, my); + HistogramBuilder builder; + builder.setX(mx); + builder.setY(my); + builder.setDistribution(m_unfilteredWS->isDistribution()); + m_filteredWS = create<MatrixWorkspace>(*m_unfilteredWS, 2, builder.build()); m_filteredWS->setSharedX(0, m_unfilteredWS->sharedX(0)); m_filteredWS->setSharedX(1, m_unfilteredWS->sharedX(0)); diff --git a/Framework/Algorithms/src/FilterEvents.cpp b/Framework/Algorithms/src/FilterEvents.cpp index ac90660c91d569f68e47b33444cb655d0288965f..3b9bcfccb5bd2f170cc937314a71c9e1a14346ae 100644 --- a/Framework/Algorithms/src/FilterEvents.cpp +++ b/Framework/Algorithms/src/FilterEvents.cpp @@ -10,7 +10,6 @@ #include "MantidAPI/Run.h" #include "MantidAPI/SpectrumInfo.h" #include "MantidAPI/TableRow.h" -#include "MantidAPI/WorkspaceFactory.h" #include "MantidAPI/WorkspaceGroup.h" #include "MantidAPI/WorkspaceProperty.h" #include "MantidAlgorithms/TimeAtSampleStrategyDirect.h" @@ -18,8 +17,10 @@ #include "MantidAlgorithms/TimeAtSampleStrategyIndirect.h" #include "MantidDataObjects/SplittersWorkspace.h" #include "MantidDataObjects/TableWorkspace.h" +#include "MantidDataObjects/Workspace2D.h" #include "MantidDataObjects/WorkspaceCreation.h" #include "MantidGeometry/Instrument/Goniometer.h" +#include "MantidHistogramData/Histogram.h" #include "MantidKernel/ArrayProperty.h" #include "MantidKernel/BoundedValidator.h" #include "MantidKernel/ListValidator.h" @@ -37,6 +38,7 @@ using namespace Mantid; using namespace Mantid::Kernel; using namespace Mantid::API; using namespace Mantid::DataObjects; +using namespace Mantid::HistogramData; using namespace Mantid::Geometry; using Types::Core::DateAndTime; @@ -1388,8 +1390,7 @@ void FilterEvents::createOutputWorkspacesTableSplitterCase() { void FilterEvents::setupDetectorTOFCalibration() { // Set output correction workspace and set to output const size_t numhist = m_eventWS->getNumberHistograms(); - MatrixWorkspace_sptr corrws = boost::dynamic_pointer_cast<MatrixWorkspace>( - WorkspaceFactory::Instance().create("Workspace2D", numhist, 2, 2)); + MatrixWorkspace_sptr corrws = create<Workspace2D>(numhist, Points(2)); setProperty("OutputTOFCorrectionWorkspace", corrws); // Set up the size of correction and output correction workspace diff --git a/Framework/Algorithms/src/FindCenterOfMassPosition.cpp b/Framework/Algorithms/src/FindCenterOfMassPosition.cpp index c559c288b3ba9f2ca118d0000595bb1ce7b83745..a9aedf3a9e47cab83c9c53fe6f4ca645ee44d93c 100644 --- a/Framework/Algorithms/src/FindCenterOfMassPosition.cpp +++ b/Framework/Algorithms/src/FindCenterOfMassPosition.cpp @@ -9,8 +9,8 @@ #include "MantidAPI/ITableWorkspace.h" #include "MantidAPI/SpectrumInfo.h" #include "MantidAPI/TableRow.h" -#include "MantidAPI/WorkspaceFactory.h" #include "MantidAPI/WorkspaceUnitValidator.h" +#include "MantidDataObjects/TableWorkspace.h" #include "MantidGeometry/Instrument.h" #include "MantidKernel/ArrayProperty.h" #include "MantidKernel/BoundedValidator.h" @@ -27,6 +27,7 @@ DECLARE_ALGORITHM(FindCenterOfMassPosition) using namespace Kernel; using namespace API; using namespace Geometry; +using namespace DataObjects; void FindCenterOfMassPosition::init() { auto wsValidator = boost::make_shared<CompositeValidator>(); @@ -215,7 +216,7 @@ void FindCenterOfMassPosition::exec() { setPropertyValue("OutputWorkspace", output); Mantid::API::ITableWorkspace_sptr m_result = - Mantid::API::WorkspaceFactory::Instance().createTable("TableWorkspace"); + boost::make_shared<TableWorkspace>(); m_result->addColumn("str", "Name"); m_result->addColumn("double", "Value"); diff --git a/Framework/Algorithms/src/FindCenterOfMassPosition2.cpp b/Framework/Algorithms/src/FindCenterOfMassPosition2.cpp index 5b1d804149a8a983185883649a3e68ceaf0add9e..70cbfc4a81a32ce38caa4eca928078f102bca20d 100644 --- a/Framework/Algorithms/src/FindCenterOfMassPosition2.cpp +++ b/Framework/Algorithms/src/FindCenterOfMassPosition2.cpp @@ -13,12 +13,13 @@ #include "MantidAPI/WorkspaceUnitValidator.h" #include "MantidDataObjects/EventList.h" #include "MantidDataObjects/EventWorkspace.h" +#include "MantidDataObjects/TableWorkspace.h" +#include "MantidDataObjects/WorkspaceCreation.h" #include "MantidGeometry/Instrument.h" #include "MantidKernel/ArrayProperty.h" #include "MantidKernel/BoundedValidator.h" #include "MantidKernel/CompositeValidator.h" #include "MantidKernel/PhysicalConstants.h" - namespace Mantid { namespace Algorithms { @@ -260,7 +261,7 @@ void FindCenterOfMassPosition2::exec() { setPropertyValue("OutputWorkspace", output); Mantid::API::ITableWorkspace_sptr m_result = - Mantid::API::WorkspaceFactory::Instance().createTable("TableWorkspace"); + boost::make_shared<TableWorkspace>(); m_result->addColumn("str", "Name"); m_result->addColumn("double", "Value"); diff --git a/Framework/Algorithms/src/FindEPP.cpp b/Framework/Algorithms/src/FindEPP.cpp index 7232915041ae4ba146dfe2bf71a71e5352fb8c45..0c10fc9e3c640a7825c28ea302598f11920ba340 100644 --- a/Framework/Algorithms/src/FindEPP.cpp +++ b/Framework/Algorithms/src/FindEPP.cpp @@ -6,7 +6,7 @@ // SPDX - License - Identifier: GPL - 3.0 + #include "MantidAlgorithms/FindEPP.h" #include "MantidAPI/TableRow.h" -#include "MantidAPI/WorkspaceFactory.h" +#include "MantidDataObjects/TableWorkspace.h" #include "MantidKernel/make_unique.h" #include <cmath> @@ -17,6 +17,7 @@ namespace Algorithms { using namespace Mantid::Kernel; using namespace Mantid::API; +using namespace Mantid::DataObjects; // Register the algorithm into the AlgorithmFactory DECLARE_ALGORITHM(FindEPP) @@ -189,7 +190,7 @@ void FindEPP::fitGaussian(int64_t index) { */ void FindEPP::initWorkspace() { - m_outWS = WorkspaceFactory::Instance().createTable("TableWorkspace"); + m_outWS = boost::make_shared<TableWorkspace>(); const std::vector<std::string> columns = { "PeakCentre", "PeakCentreError", "Sigma", "SigmaError", diff --git a/Framework/Algorithms/src/FindPeakBackground.cpp b/Framework/Algorithms/src/FindPeakBackground.cpp index f75351ad3ac77191ecaa2848304b12249d70c098..59e6f9681206bfa6aa6a9c942150c2c5ecf026ec 100644 --- a/Framework/Algorithms/src/FindPeakBackground.cpp +++ b/Framework/Algorithms/src/FindPeakBackground.cpp @@ -7,7 +7,6 @@ #include "MantidAlgorithms/FindPeakBackground.h" #include "MantidAPI/MatrixWorkspace.h" #include "MantidAPI/TableRow.h" -#include "MantidAPI/WorkspaceFactory.h" #include "MantidAPI/WorkspaceProperty.h" #include "MantidAlgorithms/FindPeaks.h" #include "MantidDataObjects/TableWorkspace.h" @@ -375,7 +374,7 @@ void FindPeakBackground::setFitWindow(const std::vector<double> &fitwindow) { */ void FindPeakBackground::createOutputWorkspaces() { // Set up output table workspace - m_outPeakTableWS = WorkspaceFactory::Instance().createTable("TableWorkspace"); + m_outPeakTableWS = boost::make_shared<TableWorkspace>(); m_outPeakTableWS->addColumn("int", "wksp_index"); m_outPeakTableWS->addColumn("int", "peak_min_index"); m_outPeakTableWS->addColumn("int", "peak_max_index"); diff --git a/Framework/Algorithms/src/FindPeaks.cpp b/Framework/Algorithms/src/FindPeaks.cpp index 8a49f6075c79773b8a2cff1e6d26c9a78f951ffe..4a9431b3af643c0a0dbaabf8c43561e0b4d5318a 100644 --- a/Framework/Algorithms/src/FindPeaks.cpp +++ b/Framework/Algorithms/src/FindPeaks.cpp @@ -11,8 +11,8 @@ #include "MantidAPI/FuncMinimizerFactory.h" #include "MantidAPI/FunctionFactory.h" #include "MantidAPI/TableRow.h" -#include "MantidAPI/WorkspaceFactory.h" #include "MantidAlgorithms/FitPeak.h" +#include "MantidDataObjects/TableWorkspace.h" #include "MantidDataObjects/Workspace2D.h" #include "MantidIndexing/GlobalSpectrumIndex.h" #include "MantidIndexing/IndexInfo.h" @@ -290,7 +290,7 @@ void FindPeaks::processAlgorithmProperties() { /** Generate a table workspace for output peak parameters */ void FindPeaks::generateOutputPeakParameterTable() { - m_outPeakTableWS = WorkspaceFactory::Instance().createTable("TableWorkspace"); + m_outPeakTableWS = boost::make_shared<TableWorkspace>(); m_outPeakTableWS->addColumn("int", "spectrum"); if (m_rawPeaksTable) { diff --git a/Framework/Algorithms/src/FitPeak.cpp b/Framework/Algorithms/src/FitPeak.cpp index 877df5564496721e82d128c21d6d96ceb74114aa..9031016cbec5e7e5f04e8b9230d0952060bf84f9 100644 --- a/Framework/Algorithms/src/FitPeak.cpp +++ b/Framework/Algorithms/src/FitPeak.cpp @@ -14,24 +14,27 @@ #include "MantidAPI/FunctionFactory.h" #include "MantidAPI/FunctionProperty.h" #include "MantidAPI/MatrixWorkspace.h" +#include "MantidAPI/MultiDomainFunction.h" #include "MantidAPI/TableRow.h" -#include "MantidAPI/WorkspaceFactory.h" #include "MantidAPI/WorkspaceProperty.h" #include "MantidDataObjects/TableWorkspace.h" +#include "MantidDataObjects/Workspace2D.h" +#include "MantidDataObjects/WorkspaceCreation.h" +#include "MantidHistogramData/Histogram.h" +#include "MantidHistogramData/HistogramBuilder.h" #include "MantidKernel/ArrayProperty.h" #include "MantidKernel/BoundedValidator.h" #include "MantidKernel/IValidator.h" #include "MantidKernel/ListValidator.h" #include "MantidKernel/StartsWithValidator.h" -#include "MantidAPI/MultiDomainFunction.h" - #include "boost/algorithm/string.hpp" #include "boost/algorithm/string/trim.hpp" using namespace Mantid; using namespace Mantid::API; using namespace Mantid::DataObjects; +using namespace Mantid::HistogramData; using namespace Mantid::Kernel; using Mantid::HistogramData::HistogramX; @@ -356,8 +359,11 @@ API::MatrixWorkspace_sptr FitOneSinglePeak::genFitWindowWS() { size_t ishift = i_maxFitX + 1; if (ishift >= vecY.size()) ysize = vecY.size() - i_minFitX; - MatrixWorkspace_sptr purePeakWS = - WorkspaceFactory::Instance().create("Workspace2D", 1, size, ysize); + + HistogramBuilder builder; + builder.setX(size); + builder.setY(ysize); + MatrixWorkspace_sptr purePeakWS = create<Workspace2D>(1, builder.build()); auto &vecX = m_dataWS->x(m_wsIndex); auto &vecE = m_dataWS->e(m_wsIndex); @@ -1514,9 +1520,10 @@ void FitPeak::setupOutput( size_t sizex = vecoutx.size(); size_t sizey = vecoutx.size(); - MatrixWorkspace_sptr outws = boost::dynamic_pointer_cast<MatrixWorkspace>( - WorkspaceFactory::Instance().create("Workspace2D", nspec, sizex, sizey)); - + HistogramBuilder builder; + builder.setX(sizex); + builder.setY(sizey); + MatrixWorkspace_sptr outws = create<Workspace2D>(nspec, builder.build()); // Calculate again FunctionDomain1DVector domain(vecoutx); FunctionValues values(domain); diff --git a/Framework/Algorithms/src/FitPeaks.cpp b/Framework/Algorithms/src/FitPeaks.cpp index 8cf6bd7bebae2de3d0e24e50de51c159d05596c4..e147068bcdd436c1d2ca667511c2557ab4b911a8 100644 --- a/Framework/Algorithms/src/FitPeaks.cpp +++ b/Framework/Algorithms/src/FitPeaks.cpp @@ -16,12 +16,14 @@ #include "MantidAPI/FunctionProperty.h" #include "MantidAPI/MultiDomainFunction.h" #include "MantidAPI/TableRow.h" -#include "MantidAPI/WorkspaceFactory.h" #include "MantidAPI/WorkspaceProperty.h" #include "MantidAlgorithms/FindPeakBackground.h" #include "MantidDataObjects/TableWorkspace.h" #include "MantidDataObjects/Workspace2D.h" +#include "MantidDataObjects/WorkspaceCreation.h" #include "MantidHistogramData/EstimatePolynomial.h" +#include "MantidHistogramData/Histogram.h" +#include "MantidHistogramData/HistogramBuilder.h" #include "MantidHistogramData/HistogramIterator.h" #include "MantidKernel/ArrayProperty.h" #include "MantidKernel/BoundedValidator.h" @@ -36,6 +38,7 @@ using namespace Mantid; using namespace Mantid::API; using namespace Mantid::DataObjects; +using namespace Mantid::HistogramData; using namespace Mantid::Kernel; using Mantid::HistogramData::Histogram; using namespace std; @@ -1873,8 +1876,10 @@ FitPeaks::createMatrixWorkspace(const std::vector<double> &vec_x, size_t size = vec_x.size(); size_t ysize = vec_y.size(); - MatrixWorkspace_sptr matrix_ws = - WorkspaceFactory::Instance().create("Workspace2D", 1, size, ysize); + HistogramBuilder builder; + builder.setX(std::move(size)); + builder.setY(std::move(ysize)); + MatrixWorkspace_sptr matrix_ws = create<Workspace2D>(1, builder.build()); auto &dataX = matrix_ws->mutableX(0); auto &dataY = matrix_ws->mutableY(0); @@ -1894,8 +1899,8 @@ void FitPeaks::generateOutputPeakPositionWS() { // create output workspace for peak positions: can be partial spectra to input // workspace size_t num_hist = m_stopWorkspaceIndex - m_startWorkspaceIndex + 1; - m_outputPeakPositionWorkspace = WorkspaceFactory::Instance().create( - "Workspace2D", num_hist, m_numPeaksToFit, m_numPeaksToFit); + m_outputPeakPositionWorkspace = + create<Workspace2D>(num_hist, Points(m_numPeaksToFit)); // set default for (size_t wi = 0; wi < num_hist; ++wi) { // convert to workspace index of input data workspace @@ -1973,8 +1978,7 @@ void FitPeaks::generateFittedParametersValueWorkspaces() { param_vec.emplace_back(m_bkgdFunction->parameterName(iparam)); // parameter value table - m_fittedParamTable = - WorkspaceFactory::Instance().createTable("TableWorkspace"); + m_fittedParamTable = boost::make_shared<TableWorkspace>(); setupParameterTableWorkspace(m_fittedParamTable, param_vec, true); // for error workspace @@ -1986,8 +1990,7 @@ void FitPeaks::generateFittedParametersValueWorkspaces() { m_fitErrorTable = nullptr; } else { // create table and set up parameter table - m_fitErrorTable = - WorkspaceFactory::Instance().createTable("TableWorkspace"); + m_fitErrorTable = boost::make_shared<TableWorkspace>(); setupParameterTableWorkspace(m_fitErrorTable, param_vec, false); } @@ -2008,7 +2011,7 @@ void FitPeaks::generateCalculatedPeaksWS() { } // create a wokspace with same number of input matrix workspace - m_fittedPeakWS = API::WorkspaceFactory::Instance().create(m_inputMatrixWS); + m_fittedPeakWS = create<Workspace2D>(*m_inputMatrixWS); for (size_t iws = 0; iws < m_fittedPeakWS->getNumberHistograms(); ++iws) { auto out_vecx = m_fittedPeakWS->histogram(iws).x(); auto in_vecx = m_inputMatrixWS->histogram(iws).x(); diff --git a/Framework/Algorithms/src/GenerateEventsFilter.cpp b/Framework/Algorithms/src/GenerateEventsFilter.cpp index 7170af58f509c06d2b6ce4f93b9751f3b600421e..2c87466a76c78aaa4417bcb829862d7b4a5cf90e 100644 --- a/Framework/Algorithms/src/GenerateEventsFilter.cpp +++ b/Framework/Algorithms/src/GenerateEventsFilter.cpp @@ -7,8 +7,11 @@ #include "MantidAlgorithms/GenerateEventsFilter.h" #include "MantidAPI/Run.h" #include "MantidAPI/TableRow.h" -#include "MantidAPI/WorkspaceFactory.h" #include "MantidAPI/WorkspaceProperty.h" +#include "MantidDataObjects/TableWorkspace.h" +#include "MantidDataObjects/Workspace2D.h" +#include "MantidDataObjects/WorkspaceCreation.h" +#include "MantidHistogramData/Histogram.h" #include "MantidKernel/ArrayProperty.h" #include "MantidKernel/ListValidator.h" #include "MantidKernel/VisibleWhenProperty.h" @@ -18,6 +21,8 @@ using namespace Mantid; using namespace Mantid::Kernel; using namespace Mantid::API; +using namespace Mantid::DataObjects; +using namespace Mantid::HistogramData; using Types::Core::DateAndTime; using Types::Core::time_duration; @@ -228,8 +233,7 @@ void GenerateEventsFilter::processInOutWorkspaces() { // Using default title = "Splitters"; } - m_filterInfoWS = - API::WorkspaceFactory::Instance().createTable("TableWorkspace"); + m_filterInfoWS = m_filterInfoWS = boost::make_shared<TableWorkspace>(); m_filterInfoWS->setTitle(title); m_filterInfoWS->addColumn("int", "workspacegroup"); m_filterInfoWS->addColumn("str", "title"); @@ -1755,8 +1759,7 @@ void GenerateEventsFilter::generateSplittersInMatrixWorkspace() { throw runtime_error("Logic error on splitter vectors' size. "); } - m_filterWS = - API::WorkspaceFactory::Instance().create("Workspace2D", 1, sizex, sizey); + m_filterWS = create<Workspace2D>(1, BinEdges(sizex)); auto &dataX = m_filterWS->mutableX(0); for (size_t i = 0; i < sizex; ++i) { // x is in the unit as second @@ -1788,10 +1791,8 @@ void GenerateEventsFilter::generateSplittersInMatrixWorkspaceParallel() { ++numtimes; size_t sizex = numtimes; - size_t sizey = numtimes - 1; - m_filterWS = - API::WorkspaceFactory::Instance().create("Workspace2D", 1, sizex, sizey); + m_filterWS = create<Workspace2D>(1, BinEdges(sizex)); auto &dataX = m_filterWS->mutableX(0); auto &dataY = m_filterWS->mutableY(0); diff --git a/Framework/Algorithms/src/GeneratePeaks.cpp b/Framework/Algorithms/src/GeneratePeaks.cpp index 36753d0d30b66e39f1c7fdbabc1a9b979f72dc61..4bee188f94eab06ac92477f3e28100f03dafcb57 100644 --- a/Framework/Algorithms/src/GeneratePeaks.cpp +++ b/Framework/Algorithms/src/GeneratePeaks.cpp @@ -11,9 +11,9 @@ #include "MantidAPI/FunctionValues.h" #include "MantidAPI/IBackgroundFunction.h" #include "MantidAPI/SpectraAxis.h" -#include "MantidAPI/WorkspaceFactory.h" #include "MantidAPI/WorkspaceProperty.h" #include "MantidDataObjects/WorkspaceCreation.h" +#include "MantidHistogramData/HistogramBuilder.h" #include "MantidIndexing/IndexInfo.h" #include "MantidKernel/ArrayProperty.h" #include "MantidKernel/ListValidator.h" @@ -705,10 +705,12 @@ API::MatrixWorkspace_sptr GeneratePeaks::createOutputWorkspace() { << "Both binning parameters and input workspace are given. " << "Using input worksapce to generate output workspace!\n"; - outputWS = API::WorkspaceFactory::Instance().create( - inputWS, inputWS->getNumberHistograms(), inputWS->x(0).size(), - inputWS->y(0).size()); + HistogramBuilder builder; + builder.setX(inputWS->x(0).size()); + builder.setY(inputWS->y(0).size()); + builder.setDistribution(inputWS->isDistribution()); + outputWS = create<MatrixWorkspace>(*inputWS, builder.build()); // Only copy the X-values from spectra with peaks specified in the table // workspace. for (const auto &iws : m_spectraSet) { diff --git a/Framework/Algorithms/src/GetAllEi.cpp b/Framework/Algorithms/src/GetAllEi.cpp index 4f17258bdf965bec3dc948296856c362fbb6285c..62ec476d2915eb032e00277a79d45ae6a578637e 100644 --- a/Framework/Algorithms/src/GetAllEi.cpp +++ b/Framework/Algorithms/src/GetAllEi.cpp @@ -9,8 +9,8 @@ #include "MantidAPI/HistoWorkspace.h" #include "MantidAPI/Run.h" #include "MantidAPI/SpectrumInfo.h" -#include "MantidAPI/WorkspaceFactory.h" #include "MantidDataObjects/TableWorkspace.h" +#include "MantidDataObjects/Workspace2D.h" #include "MantidDataObjects/WorkspaceCreation.h" #include "MantidGeometry/IComponent.h" #include "MantidGeometry/Instrument.h" @@ -31,7 +31,8 @@ namespace Mantid { namespace Algorithms { -using namespace HistogramData; +using namespace Mantid::DataObjects; +using namespace Mantid::HistogramData; DECLARE_ALGORITHM(GetAllEi) /// Empty default constructor @@ -383,8 +384,7 @@ void GetAllEi::exec() { std::sort(peaks.begin(), peaks.end()); // finalize output - auto result_ws = API::WorkspaceFactory::Instance().create("Workspace2D", 1, - nPeaks, nPeaks); + auto result_ws = create<Workspace2D>(1, Points(nPeaks)); HistogramX peaks_positions(peaks.size()); std::transform(peaks.cbegin(), peaks.cend(), peaks_positions.begin(), @@ -399,7 +399,7 @@ void GetAllEi::exec() { result_ws->setPoints(0, peaks_positions); - setProperty("OutputWorkspace", result_ws); + setProperty("OutputWorkspace", std::move(result_ws)); } /**Auxiliary method to print guess chopper energies in debug mode * diff --git a/Framework/Algorithms/src/GetDetOffsetsMultiPeaks.cpp b/Framework/Algorithms/src/GetDetOffsetsMultiPeaks.cpp index 50b9f629c46ab73d9e7e72b623af11d572e06759..642ae0b1d76a3fbff28a02af0274297ca497070e 100644 --- a/Framework/Algorithms/src/GetDetOffsetsMultiPeaks.cpp +++ b/Framework/Algorithms/src/GetDetOffsetsMultiPeaks.cpp @@ -14,11 +14,12 @@ #include "MantidAPI/ITableWorkspace.h" #include "MantidAPI/SpectrumInfo.h" #include "MantidAPI/TableRow.h" -#include "MantidAPI/WorkspaceFactory.h" #include "MantidAPI/WorkspaceUnitValidator.h" #include "MantidDataObjects/EventWorkspace.h" #include "MantidDataObjects/MaskWorkspace.h" #include "MantidDataObjects/OffsetsWorkspace.h" +#include "MantidDataObjects/WorkspaceCreation.h" +#include "MantidHistogramData/Histogram.h" #include "MantidKernel/ArrayProperty.h" #include "MantidKernel/ListValidator.h" #include "MantidKernel/StartsWithValidator.h" @@ -30,6 +31,9 @@ #include <sstream> +using namespace Mantid::DataObjects; +using namespace Mantid::HistogramData; + namespace Mantid { namespace Algorithms { namespace { @@ -1166,8 +1170,7 @@ void GetDetOffsetsMultiPeaks::createInformationWorkspaces() { } // Create resolution (delta(d)/d) workspace - m_resolutionWS = boost::dynamic_pointer_cast<MatrixWorkspace>( - WorkspaceFactory::Instance().create("Workspace2D", numspec, 1, 1)); + m_resolutionWS = create<Workspace2D>(numspec, Points(1)); } //---------------------------------------------------------------------------------------------- diff --git a/Framework/Algorithms/src/GetTimeSeriesLogInformation.cpp b/Framework/Algorithms/src/GetTimeSeriesLogInformation.cpp index 9a4664d2dd7303cc77edaac8aa0a4e2e610bc126..a3facbb925fe6c1114694b0abfa471d7ab5c85b3 100644 --- a/Framework/Algorithms/src/GetTimeSeriesLogInformation.cpp +++ b/Framework/Algorithms/src/GetTimeSeriesLogInformation.cpp @@ -7,11 +7,12 @@ #include "MantidAlgorithms/GetTimeSeriesLogInformation.h" #include "MantidAPI/Run.h" #include "MantidAPI/TableRow.h" -#include "MantidAPI/WorkspaceFactory.h" #include "MantidAPI/WorkspaceProperty.h" #include "MantidDataObjects/EventList.h" #include "MantidDataObjects/EventWorkspace.h" +#include "MantidDataObjects/WorkspaceCreation.h" #include "MantidGeometry/Instrument.h" +#include "MantidHistogramData/Histogram.h" #include "MantidKernel/ListValidator.h" #include "MantidKernel/TimeSeriesProperty.h" #include <algorithm> @@ -20,6 +21,7 @@ using namespace Mantid::Kernel; using namespace Mantid::API; using namespace Mantid::DataObjects; +using namespace Mantid::HistogramData; using Mantid::Types::Core::DateAndTime; using namespace std; @@ -375,9 +377,7 @@ Workspace2D_sptr GetTimeSeriesLogInformation::calDistributions( g_log.notice() << "Distribution has " << numbins << " bins. Delta T = (" << dtmin << ", " << dtmax << ")\n"; - Workspace2D_sptr distws = boost::dynamic_pointer_cast<Workspace2D>( - API::WorkspaceFactory::Instance().create("Workspace2D", 1, numbins, - numbins)); + Workspace2D_sptr distws = create<Workspace2D>(1, Points(numbins)); auto &vecDeltaT = distws->mutableX(0); auto &vecCount = distws->mutableY(0); diff --git a/Framework/Algorithms/src/He3TubeEfficiency.cpp b/Framework/Algorithms/src/He3TubeEfficiency.cpp index 1cbbf3a9a238c034d8668ef0867a0f3b62d3bbf7..e40e97fa1b3aa8cc5b77b5756759dbac3d153f3f 100644 --- a/Framework/Algorithms/src/He3TubeEfficiency.cpp +++ b/Framework/Algorithms/src/He3TubeEfficiency.cpp @@ -9,10 +9,10 @@ #include "MantidAPI/HistogramValidator.h" #include "MantidAPI/InstrumentValidator.h" #include "MantidAPI/SpectrumInfo.h" -#include "MantidAPI/WorkspaceFactory.h" #include "MantidAPI/WorkspaceUnitValidator.h" #include "MantidDataObjects/EventWorkspace.h" #include "MantidDataObjects/Workspace2D.h" +#include "MantidDataObjects/WorkspaceCreation.h" #include "MantidGeometry/Instrument.h" #include "MantidGeometry/Instrument/ParameterMap.h" #include "MantidGeometry/Objects/IObject.h" @@ -36,6 +36,7 @@ const double TOL = 1.0e-8; namespace Mantid { namespace Algorithms { +using namespace DataObjects; using namespace HistogramData; // Register the class into the algorithm factory DECLARE_ALGORITHM(He3TubeEfficiency) @@ -100,7 +101,7 @@ void He3TubeEfficiency::exec() { m_outputWS = this->getProperty("OutputWorkspace"); if (m_outputWS != m_inputWS) { - m_outputWS = API::WorkspaceFactory::Instance().create(m_inputWS); + m_outputWS = create<API::MatrixWorkspace>(*m_inputWS); } // Get the detector parameters diff --git a/Framework/Algorithms/src/HyspecScharpfCorrection.cpp b/Framework/Algorithms/src/HyspecScharpfCorrection.cpp index 2d48288635a34979746bf3934212d310a65b07dd..0585d4896e61ec5e163ffb1976b8e8e7efcd5c24 100644 --- a/Framework/Algorithms/src/HyspecScharpfCorrection.cpp +++ b/Framework/Algorithms/src/HyspecScharpfCorrection.cpp @@ -8,9 +8,9 @@ #include "MantidAPI/InstrumentValidator.h" #include "MantidAPI/Run.h" #include "MantidAPI/SpectrumInfo.h" -#include "MantidAPI/WorkspaceFactory.h" #include "MantidAPI/WorkspaceUnitValidator.h" #include "MantidDataObjects/EventWorkspace.h" +#include "MantidDataObjects/WorkspaceCreation.h" #include "MantidGeometry/Instrument.h" #include "MantidGeometry/Instrument/ReferenceFrame.h" #include "MantidKernel/BoundedValidator.h" @@ -21,6 +21,7 @@ namespace Algorithms { using Mantid::API::WorkspaceProperty; using Mantid::Kernel::Direction; +using namespace DataObjects; // Register the algorithm into the AlgorithmFactory DECLARE_ALGORITHM(HyspecScharpfCorrection) @@ -105,7 +106,7 @@ void HyspecScharpfCorrection::exec() { // If input and output workspaces are not the same, create a new workspace for // the output if (m_outputWS != m_inputWS) { - m_outputWS = API::WorkspaceFactory::Instance().create(m_inputWS); + m_outputWS = create<API::MatrixWorkspace>(*m_inputWS); } const auto &spectrumInfo = m_inputWS->spectrumInfo(); diff --git a/Framework/Algorithms/src/IQTransform.cpp b/Framework/Algorithms/src/IQTransform.cpp index 81ab760d9a6e5f53bde1f799102e212330e77022..04bad45d65b735af24cef675dda61f50eed273b1 100644 --- a/Framework/Algorithms/src/IQTransform.cpp +++ b/Framework/Algorithms/src/IQTransform.cpp @@ -12,8 +12,11 @@ #include "MantidAPI/IncreasingAxisValidator.h" #include "MantidAPI/MatrixWorkspace.h" #include "MantidAPI/RawCountValidator.h" -#include "MantidAPI/WorkspaceFactory.h" #include "MantidAPI/WorkspaceUnitValidator.h" +#include "MantidDataObjects/TableWorkspace.h" +#include "MantidDataObjects/Workspace2D.h" +#include "MantidDataObjects/WorkspaceCreation.h" +#include "MantidHistogramData/Histogram.h" #include "MantidKernel/ArrayProperty.h" #include "MantidKernel/BoundedValidator.h" #include "MantidKernel/CompositeValidator.h" @@ -21,6 +24,9 @@ #include "MantidKernel/Unit.h" #include "MantidKernel/VectorHelper.h" +using namespace Mantid::DataObjects; +using namespace Mantid::HistogramData; + namespace Mantid { namespace Algorithms { @@ -118,7 +124,7 @@ void IQTransform::exec() { // Create the output workspace const size_t length = tmpWS->blocksize(); MatrixWorkspace_sptr outputWS = - WorkspaceFactory::Instance().create(inputWS, 1, length, length); + create<MatrixWorkspace>(*inputWS, 1, Points(length)); m_label->setLabel(""); outputWS->setYUnit(""); // Copy the data over. Assume single spectrum input (output will be). diff --git a/Framework/Algorithms/src/IdentifyNoisyDetectors.cpp b/Framework/Algorithms/src/IdentifyNoisyDetectors.cpp index b74186cd1c232f950f36dc02ba14ca9c39c6ecd3..0563eebe1eac0077039826ff56bb4498209ca8bf 100644 --- a/Framework/Algorithms/src/IdentifyNoisyDetectors.cpp +++ b/Framework/Algorithms/src/IdentifyNoisyDetectors.cpp @@ -8,8 +8,9 @@ #include "MantidAPI/HistogramValidator.h" #include "MantidAPI/InstrumentValidator.h" #include "MantidAPI/SpectraAxisValidator.h" -#include "MantidAPI/WorkspaceFactory.h" #include "MantidAPI/WorkspaceUnitValidator.h" +#include "MantidDataObjects/WorkspaceCreation.h" +#include "MantidHistogramData/Histogram.h" #include "MantidKernel/CompositeValidator.h" #include <numeric> @@ -18,6 +19,7 @@ namespace Algorithms { using namespace Kernel; using namespace API; using namespace HistogramData; +using namespace DataObjects; DECLARE_ALGORITHM(IdentifyNoisyDetectors) @@ -55,10 +57,10 @@ void IdentifyNoisyDetectors::exec() { // Create the output workspace a single value for each spectra. MatrixWorkspace_sptr outputWs; - outputWs = WorkspaceFactory::Instance().create(inputWS, nHist, 1, 1); + outputWs = create<MatrixWorkspace>(*inputWS, Points(1)); MatrixWorkspace_sptr stdDevWs; - stdDevWs = WorkspaceFactory::Instance().create(outputWs); + stdDevWs = create<MatrixWorkspace>(*outputWs); progress.report("Integrating..."); diff --git a/Framework/Algorithms/src/Integration.cpp b/Framework/Algorithms/src/Integration.cpp index 760294cd2ec482eeab318d27c0be21f35ad66d74..7f3defdab3afbe5f885c09e205af5ca537192dd2 100644 --- a/Framework/Algorithms/src/Integration.cpp +++ b/Framework/Algorithms/src/Integration.cpp @@ -10,9 +10,12 @@ #include "MantidAlgorithms/Integration.h" #include "MantidAPI/NumericAxis.h" #include "MantidAPI/TextAxis.h" -#include "MantidAPI/WorkspaceFactory.h" #include "MantidDataObjects/EventWorkspace.h" #include "MantidDataObjects/RebinnedOutput.h" +#include "MantidDataObjects/TableWorkspace.h" +#include "MantidDataObjects/Workspace2D.h" +#include "MantidDataObjects/WorkspaceCreation.h" +#include "MantidHistogramData/Histogram.h" #include "MantidKernel/ArrayProperty.h" #include "MantidKernel/BoundedValidator.h" #include "MantidKernel/VectorHelper.h" @@ -29,6 +32,7 @@ DECLARE_ALGORITHM(Integration) using namespace Kernel; using namespace API; using namespace DataObjects; +using namespace HistogramData; /** Initialisation method. * @@ -156,9 +160,9 @@ void Integration::exec() { } // Create the 2D workspace (with 1 bin) for the output - MatrixWorkspace_sptr outputWorkspace = - API::WorkspaceFactory::Instance().create( - localworkspace, maxWsIndex - minWsIndex + 1, 2, 1); + + MatrixWorkspace_sptr outputWorkspace = create<Workspace2D>( + *localworkspace, maxWsIndex - minWsIndex + 1, BinEdges(2)); auto rebinned_input = boost::dynamic_pointer_cast<const RebinnedOutput>(localworkspace); auto rebinned_output = diff --git a/Framework/Algorithms/src/InterpolatingRebin.cpp b/Framework/Algorithms/src/InterpolatingRebin.cpp index 9e9bc2e607cfec36a74484d0bbb7a96e1ee8a158..8b7c1e80de316ccf05aaccdc277ff90553eab926 100644 --- a/Framework/Algorithms/src/InterpolatingRebin.cpp +++ b/Framework/Algorithms/src/InterpolatingRebin.cpp @@ -7,7 +7,10 @@ #include "MantidAlgorithms/InterpolatingRebin.h" #include "MantidAPI/Axis.h" #include "MantidAPI/MatrixWorkspace.h" -#include "MantidAPI/WorkspaceFactory.h" +#include "MantidDataObjects/TableWorkspace.h" +#include "MantidDataObjects/Workspace2D.h" +#include "MantidDataObjects/WorkspaceCreation.h" +#include "MantidHistogramData/Histogram.h" #include "MantidKernel/ArrayProperty.h" #include "MantidKernel/RebinParamsValidator.h" #include "MantidKernel/VectorHelper.h" @@ -27,6 +30,7 @@ DECLARE_ALGORITHM(InterpolatingRebin) using namespace Kernel; using namespace API; using namespace HistogramData; +using namespace DataObjects; /** Only calls its parent's (Rebin) init() * @@ -75,7 +79,7 @@ void InterpolatingRebin::exec() { const int nHists = static_cast<int>(inputW->getNumberHistograms()); // make output Workspace the same type as the input but with the new axes MatrixWorkspace_sptr outputW = - WorkspaceFactory::Instance().create(inputW, nHists, ntcnew, ntcnew - 1); + create<MatrixWorkspace>(*inputW, BinEdges(ntcnew)); // Copy over the 'vertical' axis if (inputW->axes() > 1) outputW->replaceAxis(1, inputW->getAxis(1)->clone(outputW.get())); diff --git a/Framework/Algorithms/src/MagFormFactorCorrection.cpp b/Framework/Algorithms/src/MagFormFactorCorrection.cpp index 95b1ccdea1950196a623007b084f485fa2d6731c..523c47f5e07e853ad8c3864c5d24912266d16a59 100644 --- a/Framework/Algorithms/src/MagFormFactorCorrection.cpp +++ b/Framework/Algorithms/src/MagFormFactorCorrection.cpp @@ -8,12 +8,15 @@ #include "MantidAPI/AnalysisDataService.h" #include "MantidAPI/Axis.h" #include "MantidAPI/MatrixWorkspace.h" -#include "MantidAPI/WorkspaceFactory.h" +#include "MantidDataObjects/TableWorkspace.h" +#include "MantidDataObjects/Workspace2D.h" +#include "MantidDataObjects/WorkspaceCreation.h" +#include "MantidHistogramData/Histogram.h" +#include "MantidHistogramData/HistogramBuilder.h" #include "MantidKernel/ListValidator.h" #include "MantidKernel/MagneticIon.h" #include "MantidKernel/Unit.h" #include "MantidKernel/UnitFactory.h" - using namespace Mantid::PhysicalConstants; namespace Mantid { @@ -25,6 +28,8 @@ DECLARE_ALGORITHM(MagFormFactorCorrection) using namespace Kernel; using namespace API; using namespace PhysicalConstants; +using namespace Mantid::DataObjects; +using namespace Mantid::HistogramData; void MagFormFactorCorrection::init() { declareProperty( @@ -94,8 +99,10 @@ void MagFormFactorCorrection::exec() { FF.push_back(ion.analyticalFormFactor(Qval * Qval)); } if (!ffwsStr.empty()) { - MatrixWorkspace_sptr ffws = API::WorkspaceFactory::Instance().create( - "Workspace2D", 1, Qvals.size(), FF.size()); + HistogramBuilder builder; + builder.setX(Qvals.size()); + builder.setY(FF.size()); + MatrixWorkspace_sptr ffws = create<Workspace2D>(1, builder.build()); ffws->mutableX(0).assign(Qvals.begin(), Qvals.end()); ffws->mutableY(0).assign(FF.begin(), FF.end()); ffws->getAxis(0)->unit() = diff --git a/Framework/Algorithms/src/MaxEnt.cpp b/Framework/Algorithms/src/MaxEnt.cpp index 040765573e5cc58b8c139a82e256707bf1d4a697..977c0f8d6523a20d5d2b3468f35dd3a4f1b7a7b8 100644 --- a/Framework/Algorithms/src/MaxEnt.cpp +++ b/Framework/Algorithms/src/MaxEnt.cpp @@ -8,13 +8,17 @@ #include "MantidAPI/EqualBinSizesValidator.h" #include "MantidAPI/MatrixWorkspace.h" #include "MantidAPI/TextAxis.h" -#include "MantidAPI/WorkspaceFactory.h" #include "MantidAlgorithms/MaxEnt/MaxentEntropyNegativeValues.h" #include "MantidAlgorithms/MaxEnt/MaxentEntropyPositiveValues.h" #include "MantidAlgorithms/MaxEnt/MaxentSpaceComplex.h" #include "MantidAlgorithms/MaxEnt/MaxentSpaceReal.h" #include "MantidAlgorithms/MaxEnt/MaxentTransformFourier.h" #include "MantidAlgorithms/MaxEnt/MaxentTransformMultiFourier.h" +#include "MantidDataObjects/TableWorkspace.h" +#include "MantidDataObjects/Workspace2D.h" +#include "MantidDataObjects/WorkspaceCreation.h" +#include "MantidHistogramData/Histogram.h" +#include "MantidHistogramData/HistogramBuilder.h" #include "MantidHistogramData/LinearGenerator.h" #include "MantidKernel/BoundedValidator.h" #include "MantidKernel/ListValidator.h" @@ -32,6 +36,8 @@ using Mantid::HistogramData::Points; using namespace API; using namespace Kernel; +using namespace Mantid::DataObjects; +using namespace Mantid::HistogramData; // Register the algorithm into the AlgorithmFactory DECLARE_ALGORITHM(MaxEnt) @@ -425,18 +431,19 @@ void MaxEnt::exec() { nSpecConcat = nImageSpec; nImageSpec = 1; } - outImageWS = WorkspaceFactory::Instance().create(inWS, 2 * nImageSpec, - npoints, npoints); + outImageWS = create<MatrixWorkspace>(*inWS, 2 * nImageSpec, Points(npoints)); for (size_t i = 0; i < outImageWS->getNumberHistograms(); ++i) outImageWS->getSpectrum(i).setDetectorID(static_cast<detid_t>(i + 1)); - outDataWS = WorkspaceFactory::Instance().create(inWS, 2 * nDataSpec, npointsX, - npoints); + HistogramBuilder builder; + builder.setX(npointsX); + builder.setY(npoints); + builder.setDistribution(inWS->isDistribution()); + outDataWS = create<MatrixWorkspace>(*inWS, 2 * nDataSpec, builder.build()); + for (size_t i = 0; i < outDataWS->getNumberHistograms(); ++i) outDataWS->getSpectrum(i).setDetectorID(static_cast<detid_t>(i + 1)); - outEvolChi = - WorkspaceFactory::Instance().create(inWS, nImageSpec, nIter, nIter); - outEvolTest = - WorkspaceFactory::Instance().create(inWS, nImageSpec, nIter, nIter); + outEvolChi = create<MatrixWorkspace>(*inWS, nImageSpec, Points(nIter)); + outEvolTest = create<MatrixWorkspace>(*inWS, nImageSpec, Points(nIter)); npoints = complexImage ? npoints * 2 : npoints; std::vector<size_t> iterationCounts; diff --git a/Framework/Algorithms/src/MaxMin.cpp b/Framework/Algorithms/src/MaxMin.cpp index ebaa7df2fc43c71548de9bdf01929ff5c32602d6..ef22b2fbb539666980fd6523dd775660dbe123c6 100644 --- a/Framework/Algorithms/src/MaxMin.cpp +++ b/Framework/Algorithms/src/MaxMin.cpp @@ -9,7 +9,10 @@ //---------------------------------------------------------------------- #include "MantidAlgorithms/MaxMin.h" #include "MantidAPI/HistogramValidator.h" -#include "MantidAPI/WorkspaceFactory.h" +#include "MantidDataObjects/TableWorkspace.h" +#include "MantidDataObjects/Workspace2D.h" +#include "MantidDataObjects/WorkspaceCreation.h" +#include "MantidHistogramData/Histogram.h" #include "MantidKernel/BoundedValidator.h" namespace Mantid { @@ -20,6 +23,8 @@ DECLARE_ALGORITHM(MaxMin) using namespace Kernel; using namespace API; +using namespace Mantid::DataObjects; +using namespace Mantid::HistogramData; /** Initialisation method. * @@ -89,9 +94,10 @@ void MaxMin::exec() { } // Create the 1D workspace for the output - MatrixWorkspace_sptr outputWorkspace = - API::WorkspaceFactory::Instance().create(localworkspace, - MaxSpec - MinSpec + 1, 2, 1); + MatrixWorkspace_sptr outputWorkspace; + + outputWorkspace = create<HistoWorkspace>(*localworkspace, + MaxSpec - MinSpec + 1, BinEdges(2)); Progress progress(this, 0.0, 1.0, (MaxSpec - MinSpec + 1)); PARALLEL_FOR_IF(Kernel::threadSafe(*localworkspace, *outputWorkspace)) diff --git a/Framework/Algorithms/src/ModeratorTzero.cpp b/Framework/Algorithms/src/ModeratorTzero.cpp index 79d4cc41bdf029ccaec73e5236b61d0382953fae..377bdfecad4864425258dcd1d7c67ad47db03114 100644 --- a/Framework/Algorithms/src/ModeratorTzero.cpp +++ b/Framework/Algorithms/src/ModeratorTzero.cpp @@ -8,12 +8,14 @@ #include "MantidAPI/Axis.h" #include "MantidAPI/Run.h" #include "MantidAPI/SpectrumInfo.h" -#include "MantidAPI/WorkspaceFactory.h" #include "MantidAPI/WorkspaceUnitValidator.h" #include "MantidDataObjects/EventList.h" #include "MantidDataObjects/EventWorkspace.h" +#include "MantidDataObjects/TableWorkspace.h" #include "MantidDataObjects/Workspace2D.h" +#include "MantidDataObjects/WorkspaceCreation.h" #include "MantidGeometry/muParser_Silent.h" +#include "MantidHistogramData/Histogram.h" #include "MantidKernel/ListValidator.h" #include "MantidKernel/UnitFactory.h" @@ -29,6 +31,7 @@ using namespace Mantid::Kernel; using namespace Mantid::API; using namespace Mantid::Geometry; using namespace Mantid::DataObjects; +using namespace Mantid::HistogramData; ModeratorTzero::ModeratorTzero() : Mantid::API::Algorithm(), @@ -104,7 +107,7 @@ void ModeratorTzero::exec() { // Check whether input == output to see whether a new workspace is required. if (outputWS != inputWS) { // Create new workspace for output from old - outputWS = WorkspaceFactory::Instance().create(inputWS); + outputWS = create<MatrixWorkspace>(*inputWS); } // calculate tof shift once for all neutrons if emode==Direct diff --git a/Framework/Algorithms/src/ModeratorTzeroLinear.cpp b/Framework/Algorithms/src/ModeratorTzeroLinear.cpp index a553b590e28f2f900f9f97bf6eee3a083a861f07..68c554347945cbe405d9535956711d7b0987e3ce 100644 --- a/Framework/Algorithms/src/ModeratorTzeroLinear.cpp +++ b/Framework/Algorithms/src/ModeratorTzeroLinear.cpp @@ -8,10 +8,12 @@ #include "MantidAPI/Axis.h" #include "MantidAPI/Run.h" #include "MantidAPI/SpectrumInfo.h" -#include "MantidAPI/WorkspaceFactory.h" #include "MantidAPI/WorkspaceUnitValidator.h" #include "MantidDataObjects/EventWorkspace.h" +#include "MantidDataObjects/TableWorkspace.h" #include "MantidDataObjects/Workspace2D.h" +#include "MantidDataObjects/WorkspaceCreation.h" +#include "MantidHistogramData/Histogram.h" #include "MantidKernel/PhysicalConstants.h" #include "MantidKernel/UnitFactory.h" @@ -27,6 +29,7 @@ using namespace Mantid::Kernel; using namespace Mantid::API; using namespace Mantid::Geometry; using namespace Mantid::DataObjects; +using namespace Mantid::HistogramData; // A reference to the logger is provided by the base class, it is called g_log. // It is used to print out information, warning and error messages @@ -133,7 +136,7 @@ void ModeratorTzeroLinear::exec() { // Check whether input = output to see whether a new workspace is required. if (outputWS != inputWS) { // Create new workspace for output from old - outputWS = WorkspaceFactory::Instance().create(inputWS); + outputWS = create<MatrixWorkspace>(*inputWS); } // do the shift in X diff --git a/Framework/Algorithms/src/MonitorEfficiencyCorUser.cpp b/Framework/Algorithms/src/MonitorEfficiencyCorUser.cpp index 162c886ce7f696e1c29242f195408092b6475778..15ed94613ba37ee0abb63ca9eda0476dd8095a47 100644 --- a/Framework/Algorithms/src/MonitorEfficiencyCorUser.cpp +++ b/Framework/Algorithms/src/MonitorEfficiencyCorUser.cpp @@ -9,9 +9,12 @@ #include "MantidAPI/InstrumentValidator.h" #include "MantidAPI/MatrixWorkspace.h" #include "MantidAPI/Run.h" -#include "MantidAPI/WorkspaceFactory.h" +#include "MantidDataObjects/TableWorkspace.h" +#include "MantidDataObjects/Workspace2D.h" +#include "MantidDataObjects/WorkspaceCreation.h" #include "MantidGeometry/Instrument.h" #include "MantidGeometry/muParser_Silent.h" +#include "MantidHistogramData/Histogram.h" #include "MantidHistogramData/HistogramMath.h" #include "MantidKernel/MultiThreaded.h" #include "MantidKernel/Strings.h" @@ -22,6 +25,8 @@ namespace Algorithms { using namespace Kernel; using namespace API; using namespace Geometry; +using namespace DataObjects; +using namespace HistogramData; // Register the algorithm into the AlgorithmFactory DECLARE_ALGORITHM(MonitorEfficiencyCorUser) @@ -47,7 +52,7 @@ void MonitorEfficiencyCorUser::exec() { // If input and output workspaces are not the same, create a new workspace for // the output if (m_outputWS != this->m_inputWS) { - m_outputWS = API::WorkspaceFactory::Instance().create(m_inputWS); + m_outputWS = create<MatrixWorkspace>(*m_inputWS); } m_Ei = m_inputWS->run().getPropertyValueAsType<double>("Ei"); diff --git a/Framework/Algorithms/src/MultiplyRange.cpp b/Framework/Algorithms/src/MultiplyRange.cpp index 26184591259d3cecd44733442e58a8a36ac47fb2..727d667e3d013b46d7322cb94c2e22eaeb278d6e 100644 --- a/Framework/Algorithms/src/MultiplyRange.cpp +++ b/Framework/Algorithms/src/MultiplyRange.cpp @@ -9,7 +9,10 @@ //---------------------------------------------------------------------- #include "MantidAlgorithms/MultiplyRange.h" #include "MantidAPI/MatrixWorkspace.h" -#include "MantidAPI/WorkspaceFactory.h" +#include "MantidDataObjects/TableWorkspace.h" +#include "MantidDataObjects/Workspace2D.h" +#include "MantidDataObjects/WorkspaceCreation.h" +#include "MantidHistogramData/Histogram.h" #include "MantidKernel/BoundedValidator.h" namespace Mantid { @@ -20,6 +23,8 @@ DECLARE_ALGORITHM(MultiplyRange) using namespace Kernel; using namespace API; +using namespace DataObjects; +using namespace HistogramData; void MultiplyRange::init() { // Declare an input workspace property. @@ -69,7 +74,7 @@ void MultiplyRange::exec() { // Only create the output workspace if it's different to the input one MatrixWorkspace_sptr outputWS = getProperty("OutputWorkspace"); if (outputWS != inputWS) { - outputWS = WorkspaceFactory::Instance().create(inputWS); + outputWS = create<MatrixWorkspace>(*inputWS); setProperty("OutputWorkspace", outputWS); } diff --git a/Framework/Algorithms/src/NormaliseToMonitor.cpp b/Framework/Algorithms/src/NormaliseToMonitor.cpp index 5b34e20a99c4c29949aaec6542a8207fdce57860..42548ea8bf45fe88602208c960acedb18b78f72d 100644 --- a/Framework/Algorithms/src/NormaliseToMonitor.cpp +++ b/Framework/Algorithms/src/NormaliseToMonitor.cpp @@ -10,12 +10,15 @@ #include "MantidAPI/SingleCountValidator.h" #include "MantidAPI/SpectraAxis.h" #include "MantidAPI/SpectrumInfo.h" -#include "MantidAPI/WorkspaceFactory.h" #include "MantidAPI/WorkspaceOpOverloads.h" #include "MantidDataObjects/EventWorkspace.h" +#include "MantidDataObjects/TableWorkspace.h" +#include "MantidDataObjects/Workspace2D.h" +#include "MantidDataObjects/WorkspaceCreation.h" #include "MantidGeometry/IDetector.h" #include "MantidGeometry/Instrument.h" #include "MantidGeometry/Instrument/DetectorInfo.h" +#include "MantidHistogramData/Histogram.h" #include "MantidKernel/BoundedValidator.h" #include "MantidKernel/CompositeValidator.h" #include "MantidKernel/EnabledWhenProperty.h" @@ -686,7 +689,7 @@ void NormaliseToMonitor::normaliseBinByBin( if (inputEvent) { outputWorkspace = inputWorkspace->clone(); } else - outputWorkspace = WorkspaceFactory::Instance().create(inputWorkspace); + outputWorkspace = create<MatrixWorkspace>(*inputWorkspace); } auto outputEvent = boost::dynamic_pointer_cast<EventWorkspace>(outputWorkspace); diff --git a/Framework/Algorithms/src/PDCalibration.cpp b/Framework/Algorithms/src/PDCalibration.cpp index 9bcc9e62d213ab5f7c15943882459493ef2b908c..01537c9dee95b4acafb663369f75ddfc7c20b9cf 100644 --- a/Framework/Algorithms/src/PDCalibration.cpp +++ b/Framework/Algorithms/src/PDCalibration.cpp @@ -11,15 +11,17 @@ #include "MantidAPI/MatrixWorkspace.h" #include "MantidAPI/Run.h" #include "MantidAPI/TableRow.h" -#include "MantidAPI/WorkspaceFactory.h" #include "MantidAPI/WorkspaceGroup.h" #include "MantidDataObjects/EventWorkspace.h" #include "MantidDataObjects/MaskWorkspace.h" #include "MantidDataObjects/SpecialWorkspace2D.h" #include "MantidDataObjects/TableWorkspace.h" +#include "MantidDataObjects/Workspace2D.h" +#include "MantidDataObjects/WorkspaceCreation.h" #include "MantidGeometry/IDetector.h" #include "MantidGeometry/Instrument.h" #include "MantidGeometry/Instrument/DetectorInfo.h" +#include "MantidHistogramData/Histogram.h" #include "MantidKernel/ArrayBoundedValidator.h" #include "MantidKernel/ArrayProperty.h" #include "MantidKernel/BoundedValidator.h" @@ -40,6 +42,8 @@ namespace Mantid { namespace Algorithms { +using namespace Mantid::DataObjects; +using namespace Mantid::HistogramData; using Mantid::API::FileProperty; using Mantid::API::MatrixWorkspace; using Mantid::API::MatrixWorkspace_sptr; @@ -1198,11 +1202,10 @@ PDCalibration::createTOFPeakCenterFitWindowWorkspaces( // create workspaces size_t numspec = dataws->getNumberHistograms(); size_t numpeaks = m_peaksInDspacing.size(); - MatrixWorkspace_sptr peak_pos_ws = API::WorkspaceFactory::Instance().create( - "Workspace2D", numspec, numpeaks, numpeaks); + MatrixWorkspace_sptr peak_pos_ws = + create<Workspace2D>(numspec, Points(numpeaks)); MatrixWorkspace_sptr peak_window_ws = - API::WorkspaceFactory::Instance().create("Workspace2D", numspec, - numpeaks * 2, numpeaks * 2); + create<Workspace2D>(numspec, Points(numpeaks * 2)); const int64_t NUM_HIST = static_cast<int64_t>(dataws->getNumberHistograms()); API::Progress prog(this, 0., .2, NUM_HIST); diff --git a/Framework/Algorithms/src/PDFFourierTransform.cpp b/Framework/Algorithms/src/PDFFourierTransform.cpp index d1a09b20f13376c20f344779bf83aa28340ab051..fb0665a8f2d1208d0392b8527689e282ab638d02 100644 --- a/Framework/Algorithms/src/PDFFourierTransform.cpp +++ b/Framework/Algorithms/src/PDFFourierTransform.cpp @@ -8,8 +8,10 @@ #include "MantidAPI/Axis.h" #include "MantidAPI/Run.h" #include "MantidAPI/Sample.h" -#include "MantidAPI/WorkspaceFactory.h" #include "MantidAPI/WorkspaceUnitValidator.h" +#include "MantidDataObjects/Workspace2D.h" +#include "MantidDataObjects/WorkspaceCreation.h" +#include "MantidHistogramData/Histogram.h" #include "MantidHistogramData/LinearGenerator.h" #include "MantidKernel/BoundedValidator.h" #include "MantidKernel/ListValidator.h" @@ -32,6 +34,7 @@ DECLARE_ALGORITHM(PDFFourierTransform) using namespace Mantid::Kernel; using namespace Mantid::API; +using namespace DataObjects; namespace { // anonymous namespace /// Crystalline PDF @@ -329,8 +332,7 @@ void PDFFourierTransform::exec() { bool filter = getProperty("Filter"); // create the output workspace - API::MatrixWorkspace_sptr outputWS = - WorkspaceFactory::Instance().create("Workspace2D", 1, sizer, sizer); + API::MatrixWorkspace_sptr outputWS = create<Workspace2D>(1, Points(sizer)); outputWS->getAxis(0)->unit() = UnitFactory::Instance().create("Label"); Unit_sptr unit = outputWS->getAxis(0)->unit(); boost::shared_ptr<Units::Label> label = diff --git a/Framework/Algorithms/src/PaddingAndApodization.cpp b/Framework/Algorithms/src/PaddingAndApodization.cpp index ce6422028aa9ddd02f25348cd70f01d248e55d70..9adb0bb564317a3cd01f7b877eb7cc9cc7b0ed9e 100644 --- a/Framework/Algorithms/src/PaddingAndApodization.cpp +++ b/Framework/Algorithms/src/PaddingAndApodization.cpp @@ -12,8 +12,11 @@ #include "MantidAPI/AlgorithmManager.h" #include "MantidAPI/MatrixWorkspace.h" -#include "MantidAPI/WorkspaceFactory.h" #include "MantidAPI/Workspace_fwd.h" +#include "MantidDataObjects/TableWorkspace.h" +#include "MantidDataObjects/Workspace2D.h" +#include "MantidDataObjects/WorkspaceCreation.h" +#include "MantidHistogramData/Histogram.h" #include "MantidKernel/ArrayProperty.h" #include "MantidKernel/BoundedValidator.h" #include "MantidKernel/ListValidator.h" @@ -27,6 +30,8 @@ namespace Mantid { namespace Algorithms { using namespace Kernel; +using namespace DataObjects; +using namespace HistogramData; using API::Progress; using std::size_t; @@ -72,7 +77,7 @@ void PaddingAndApodization::exec() { // Create output workspace with same dimensions as input API::MatrixWorkspace_sptr outputWS = getProperty("OutputWorkspace"); if (inputWS != outputWS) { - outputWS = API::WorkspaceFactory::Instance().create(inputWS); + outputWS = create<API::MatrixWorkspace>(*inputWS); } // Share the X values diff --git a/Framework/Algorithms/src/PointByPointVCorrection.cpp b/Framework/Algorithms/src/PointByPointVCorrection.cpp index 83580d0ff123cb2a4688b74279b44868ac25306a..604e6cb919e9830a7ee796ac15f91f144c6c6116 100644 --- a/Framework/Algorithms/src/PointByPointVCorrection.cpp +++ b/Framework/Algorithms/src/PointByPointVCorrection.cpp @@ -10,7 +10,7 @@ #include "MantidAlgorithms/PointByPointVCorrection.h" #include "MantidAPI/Axis.h" #include "MantidAPI/MatrixWorkspace.h" -#include "MantidAPI/WorkspaceFactory.h" +#include "MantidDataObjects/WorkspaceCreation.h" #include "MantidGeometry/Instrument.h" #include "MantidKernel/VectorHelper.h" @@ -26,6 +26,7 @@ DECLARE_ALGORITHM(PointByPointVCorrection) using namespace Kernel; using namespace API; +using namespace DataObjects; /// Default constructor PointByPointVCorrection::PointByPointVCorrection() : Algorithm() {} @@ -183,7 +184,7 @@ void PointByPointVCorrection::check_validity( if (out != w1 && out != w2) // Create a new workspace only if it is different // from of the input ones. { - out = API::WorkspaceFactory::Instance().create(w1); + out = create<MatrixWorkspace>(*w1); setProperty("OutputWorkspace", out); } else if (out == w2) { g_log.warning("Any masking in the output workspaces will be taken from the " diff --git a/Framework/Muon/inc/MantidMuon/CalMuonDetectorPhases.h b/Framework/Muon/inc/MantidMuon/CalMuonDetectorPhases.h index 70e10a03b3a7ded435dc971bb7f0edc749e66a87..8deac0094b854f8ec03e50a6088e45330efd26bd 100644 --- a/Framework/Muon/inc/MantidMuon/CalMuonDetectorPhases.h +++ b/Framework/Muon/inc/MantidMuon/CalMuonDetectorPhases.h @@ -57,13 +57,13 @@ private: removeExpDecay(const API::MatrixWorkspace_sptr &wsInput); /// Fit the workspace void fitWorkspace(const API::MatrixWorkspace_sptr &ws, double freq, - std::string groupName, API::ITableWorkspace_sptr &resTab, + std::string groupName, API::ITableWorkspace_sptr resTab, API::WorkspaceGroup_sptr &resGroup); /// Create the fitting function as string std::string createFittingFunction(double freq, bool fixFreq); /// Extract asymmetry and phase from fitting results - void extractDetectorInfo(const API::ITableWorkspace_sptr ¶mTab, - const API::ITableWorkspace_sptr &resultsTab, + void extractDetectorInfo(API::ITableWorkspace ¶mTab, + API::ITableWorkspace &resultsTab, const Indexing::SpectrumNumber spectrumNumber); /// Find frequency to use in sequential fit double getFrequency(const API::MatrixWorkspace_sptr &ws); diff --git a/Framework/Muon/src/CalMuonDeadTime.cpp b/Framework/Muon/src/CalMuonDeadTime.cpp index 74c277c8f3a1b5b1eee0a1390ff8f76778965b1f..978033da35fb637eef07d094def1dca58512d06f 100644 --- a/Framework/Muon/src/CalMuonDeadTime.cpp +++ b/Framework/Muon/src/CalMuonDeadTime.cpp @@ -11,7 +11,7 @@ #include "MantidAPI/MatrixWorkspace.h" #include "MantidAPI/Run.h" #include "MantidAPI/TableRow.h" -#include "MantidAPI/WorkspaceFactory.h" +#include "MantidDataObjects/TableWorkspace.h" #include "MantidKernel/ArrayProperty.h" #include "MantidKernel/PhysicalConstants.h" @@ -22,6 +22,7 @@ namespace Mantid { namespace Algorithms { using namespace Kernel; +using namespace DataObjects; // Register the class into the algorithm factory DECLARE_ALGORITHM(CalMuonDeadTime) @@ -95,8 +96,7 @@ void CalMuonDeadTime::exec() { // Do the initial setup of the ouput table-workspace - API::ITableWorkspace_sptr outTable = - API::WorkspaceFactory::Instance().createTable("TableWorkspace"); + API::ITableWorkspace_sptr outTable = boost::make_shared<TableWorkspace>(); outTable->addColumn("int", "spectrum"); outTable->addColumn("double", "dead-time"); diff --git a/Framework/Muon/src/CalMuonDetectorPhases.cpp b/Framework/Muon/src/CalMuonDetectorPhases.cpp index c88d4bf8d710a8214cbdeb8ea2bba5b7e1eb80a9..9cde6be97b3635bfb2aa0facd7d7e463e37f7442 100644 --- a/Framework/Muon/src/CalMuonDetectorPhases.cpp +++ b/Framework/Muon/src/CalMuonDetectorPhases.cpp @@ -15,8 +15,8 @@ #include "MantidAPI/MultiDomainFunction.h" #include "MantidAPI/Run.h" #include "MantidAPI/TableRow.h" -#include "MantidAPI/WorkspaceFactory.h" #include "MantidAPI/WorkspaceGroup.h" +#include "MantidDataObjects/TableWorkspace.h" #include "MantidIndexing/IndexInfo.h" #include "MantidKernel/ArrayProperty.h" #include "MantidKernel/PhysicalConstants.h" @@ -30,6 +30,7 @@ namespace Mantid { namespace Algorithms { using namespace Kernel; +using namespace DataObjects; // Register the algorithm into the AlgorithmFactory DECLARE_ALGORITHM(CalMuonDetectorPhases) @@ -127,7 +128,7 @@ void CalMuonDetectorPhases::exec() { double freq = getFrequency(tempWS); // Create the output workspaces - auto tab = API::WorkspaceFactory::Instance().createTable("TableWorkspace"); + TableWorkspace_sptr tab = boost::make_shared<TableWorkspace>(); auto group = boost::make_shared<API::WorkspaceGroup>(); // Get the name of 'DataFitted' @@ -152,7 +153,7 @@ void CalMuonDetectorPhases::exec() { */ void CalMuonDetectorPhases::fitWorkspace(const API::MatrixWorkspace_sptr &ws, double freq, std::string groupName, - API::ITableWorkspace_sptr &resTab, + API::ITableWorkspace_sptr resTab, API::WorkspaceGroup_sptr &resGroup) { int nhist = static_cast<int>(ws->getNumberHistograms()); @@ -177,8 +178,7 @@ void CalMuonDetectorPhases::fitWorkspace(const API::MatrixWorkspace_sptr &ws, [](double value) { return value == 0.; }); if (emptySpectrum) { g_log.warning("Spectrum " + std::to_string(wsIndex) + " is empty"); - auto tab = - API::WorkspaceFactory::Instance().createTable("TableWorkspace"); + TableWorkspace_sptr tab = boost::make_shared<TableWorkspace>(); tab->addColumn("str", "Name"); tab->addColumn("double", "Value"); tab->addColumn("double", "Error"); @@ -191,7 +191,7 @@ void CalMuonDetectorPhases::fitWorkspace(const API::MatrixWorkspace_sptr &ws, } } - extractDetectorInfo(tab, resTab, indexInfo.spectrumNumber(wsIndex)); + extractDetectorInfo(*tab, *resTab, indexInfo.spectrumNumber(wsIndex)); } else { auto fit = createChildAlgorithm("Fit"); @@ -217,7 +217,7 @@ void CalMuonDetectorPhases::fitWorkspace(const API::MatrixWorkspace_sptr &ws, // Now we have our fitting results stored in tab // but we need to extract the relevant information, i.e. // the detector phases (parameter 'p') and asymmetries ('A') - extractDetectorInfo(tab, resTab, indexInfo.spectrumNumber(wsIndex)); + extractDetectorInfo(*tab, *resTab, indexInfo.spectrumNumber(wsIndex)); } } } @@ -229,12 +229,11 @@ void CalMuonDetectorPhases::fitWorkspace(const API::MatrixWorkspace_sptr &ws, * @param spectrumNumber :: [input] Spectrum number */ void CalMuonDetectorPhases::extractDetectorInfo( - const API::ITableWorkspace_sptr ¶mTab, - const API::ITableWorkspace_sptr &resultsTab, + API::ITableWorkspace ¶mTab, API::ITableWorkspace &resultsTab, const Indexing::SpectrumNumber spectrumNumber) { - double asym = paramTab->Double(0, 1); - double phase = paramTab->Double(2, 1); + double asym = paramTab.Double(0, 1); + double phase = paramTab.Double(2, 1); // If asym<0, take the absolute value and add \pi to phase // f(x) = A * cos( w * x - p) = -A * cos( w * x - p - PI) if (asym < 0) { @@ -247,7 +246,7 @@ void CalMuonDetectorPhases::extractDetectorInfo( phase = phase - factor * 2. * M_PI; } // Copy parameters to new row in results table - API::TableRow row = resultsTab->appendRow(); + API::TableRow row = resultsTab.appendRow(); row << static_cast<int>(spectrumNumber) << asym << phase; } diff --git a/Framework/Muon/src/EstimateMuonAsymmetryFromCounts.cpp b/Framework/Muon/src/EstimateMuonAsymmetryFromCounts.cpp index aee33457b2058a34eabd68194196910781ce37fc..2c3ffb6429cff9058be0225ab43a2b0a5048e5ae 100644 --- a/Framework/Muon/src/EstimateMuonAsymmetryFromCounts.cpp +++ b/Framework/Muon/src/EstimateMuonAsymmetryFromCounts.cpp @@ -13,8 +13,8 @@ #include "MantidAPI/IFunction.h" #include "MantidAPI/MatrixWorkspace.h" #include "MantidAPI/Run.h" -#include "MantidAPI/WorkspaceFactory.h" #include "MantidAPI/Workspace_fwd.h" +#include "MantidDataObjects/WorkspaceCreation.h" #include "MantidKernel/ArrayProperty.h" #include "MantidKernel/PhysicalConstants.h" #include "MantidMuon/MuonAlgorithmHelper.h" @@ -26,6 +26,7 @@ namespace Mantid { namespace Algorithms { +using namespace Mantid::DataObjects; using namespace Kernel; using API::Progress; using std::size_t; @@ -121,11 +122,10 @@ void EstimateMuonAsymmetryFromCounts::exec() { // Create output workspace with same dimensions as input API::MatrixWorkspace_sptr outputWS = getProperty("OutputWorkspace"); if (inputWS != outputWS) { - outputWS = API::WorkspaceFactory::Instance().create(inputWS); + outputWS = create<API::MatrixWorkspace>(*inputWS); } bool extraData = getProperty("OutputUnNormData"); - API::MatrixWorkspace_sptr unnormWS = - API::WorkspaceFactory::Instance().create(outputWS); + API::MatrixWorkspace_sptr unnormWS = create<API::MatrixWorkspace>(*outputWS); double startX = getProperty("StartX"); double endX = getProperty("EndX"); const Mantid::API::Run &run = inputWS->run(); diff --git a/Framework/Muon/src/PhaseQuadMuon.cpp b/Framework/Muon/src/PhaseQuadMuon.cpp index b893c72cb535be74d88a50d38eca61818764c100..714e8b361ac3e8b306cbd5880aa034d56dcbe791 100644 --- a/Framework/Muon/src/PhaseQuadMuon.cpp +++ b/Framework/Muon/src/PhaseQuadMuon.cpp @@ -9,10 +9,15 @@ #include "MantidAPI/Axis.h" #include "MantidAPI/ITableWorkspace.h" #include "MantidAPI/MatrixWorkspaceValidator.h" -#include "MantidAPI/WorkspaceFactory.h" +#include "MantidDataObjects/Workspace2D.h" +#include "MantidDataObjects/WorkspaceCreation.h" +#include "MantidHistogramData/Histogram.h" #include "MantidKernel/PhysicalConstants.h" #include "MantidKernel/Unit.h" +using namespace Mantid::DataObjects; +using namespace Mantid::HistogramData; + namespace { const std::array<std::string, 2> phaseNames = {{"phase", "phi"}}; const std::array<std::string, 3> asymmNames = {{"asymmetry", "asymm", "asym"}}; @@ -291,7 +296,7 @@ PhaseQuadMuon::squash(const API::MatrixWorkspace_sptr &ws, const size_t npoints = ws->blocksize(); // Create and populate output workspace API::MatrixWorkspace_sptr ows = - API::WorkspaceFactory::Instance().create(ws, 2, npoints + 1, npoints); + create<API::MatrixWorkspace>(*ws, 2, BinEdges(npoints + 1)); // X ows->setSharedX(0, ws->sharedX(0)); diff --git a/Framework/Muon/src/PlotAsymmetryByLogValue.cpp b/Framework/Muon/src/PlotAsymmetryByLogValue.cpp index c9ba0fe357302f100a096331733bc23276401fd4..802cf1ea84e27e274907b718c657027079751537 100644 --- a/Framework/Muon/src/PlotAsymmetryByLogValue.cpp +++ b/Framework/Muon/src/PlotAsymmetryByLogValue.cpp @@ -8,15 +8,19 @@ #include <vector> #include "MantidAPI/AlgorithmManager.h" +#include "MantidAPI/FileFinder.h" #include "MantidAPI/FileProperty.h" #include "MantidAPI/Progress.h" #include "MantidAPI/Run.h" #include "MantidAPI/ScopedWorkspace.h" #include "MantidAPI/TableRow.h" #include "MantidAPI/TextAxis.h" -#include "MantidAPI/WorkspaceFactory.h" #include "MantidAPI/WorkspaceGroup.h" #include "MantidDataObjects/TableWorkspace.h" +#include "MantidDataObjects/Workspace2D.h" +#include "MantidDataObjects/WorkspaceCreation.h" +#include "MantidHistogramData/Histogram.h" +#include "MantidHistogramData/HistogramBuilder.h" #include "MantidKernel/ArrayProperty.h" #include "MantidKernel/ListValidator.h" #include "MantidKernel/MandatoryValidator.h" @@ -24,8 +28,9 @@ #include "MantidKernel/TimeSeriesProperty.h" #include "MantidMuon/PlotAsymmetryByLogValue.h" #include "Poco/File.h" -#include <MantidAPI/FileFinder.h> +using namespace Mantid::DataObjects; +using namespace Mantid::HistogramData; namespace // anonymous { @@ -186,19 +191,16 @@ void PlotAsymmetryByLogValue::exec() { // Create the 2D workspace for the output int nplots = !m_greenY.empty() ? 4 : 1; size_t npoints = m_logValue.size(); - MatrixWorkspace_sptr outWS = WorkspaceFactory::Instance().create( - "Workspace2D", - nplots, // the number of plots - npoints, // the number of data points on a plot - npoints // it's not a histogram + MatrixWorkspace_sptr outWS = create<Workspace2D>( + nplots, // the number of plots + Points(npoints) // the number of data points on a plot ); // Populate output workspace with data populateOutputWorkspace(outWS, nplots); // Assign the result to the output workspace property setProperty("OutputWorkspace", outWS); - outWS = WorkspaceFactory::Instance().create("Workspace2D", nplots + 1, - npoints, npoints); + outWS = create<Workspace2D>(nplots + 1, Points(npoints)); // Populate ws holding current results saveResultsToADS(outWS, nplots + 1); } @@ -588,8 +590,7 @@ Workspace_sptr PlotAsymmetryByLogValue::createCustomGrouping(const std::vector<int> &fwd, const std::vector<int> &bwd) { - ITableWorkspace_sptr group = - WorkspaceFactory::Instance().createTable("TableWorkspace"); + ITableWorkspace_sptr group = boost::make_shared<TableWorkspace>(); group->addColumn("vector_int", "group"); TableRow row = group->appendRow(); row << fwd; @@ -747,10 +748,12 @@ void PlotAsymmetryByLogValue::calcIntAsymmetry(MatrixWorkspace_sptr ws_red, MatrixWorkspace_sptr ws_green, double &Y, double &E) { if (!m_int) { // "Differential asymmetry" - - MatrixWorkspace_sptr tmpWS = WorkspaceFactory::Instance().create( - ws_red, 1, ws_red->x(0).size(), ws_red->y(0).size()); - + HistogramBuilder builder; + builder.setX(ws_red->x(0).size()); + builder.setY(ws_red->y(0).size()); + builder.setDistribution(ws_red->isDistribution()); + MatrixWorkspace_sptr tmpWS = + create<MatrixWorkspace>(*ws_red, 1, builder.build()); for (size_t i = 0; i < tmpWS->y(0).size(); i++) { double FNORM = ws_green->y(0)[i] + ws_red->y(0)[i]; FNORM = FNORM != 0.0 ? 1.0 / FNORM : 1.0;