diff --git a/Framework/DataHandling/inc/MantidDataHandling/FindDetectorsInShape.h b/Framework/DataHandling/inc/MantidDataHandling/FindDetectorsInShape.h index 01c3be192344b1018f6e9954fd99c980a0be6436..492bbdf0e1fd0cb7062898be783246fd38bb683d 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/FindDetectorsInShape.h +++ b/Framework/DataHandling/inc/MantidDataHandling/FindDetectorsInShape.h @@ -1,10 +1,7 @@ #ifndef MANTID_DATAHANDLING_FINDDETECTORSINSHAPE_H_ #define MANTID_DATAHANDLING_FINDDETECTORSINSHAPE_H_ -//---------------------------------------------------------------------- -// Includes -//---------------------------------------------------------------------- -#include "MantidAPI/Algorithm.h" +#include "MantidAPI/DistributedAlgorithm.h" namespace Mantid { namespace DataHandling { @@ -55,7 +52,7 @@ namespace DataHandling { File change history is stored at: <https://github.com/mantidproject/mantid>. Code Documentation is available at: <http://doxygen.mantidproject.org> */ -class DLLExport FindDetectorsInShape : public API::Algorithm { +class DLLExport FindDetectorsInShape : public API::DistributedAlgorithm { public: /// Algorithm's name for identification overriding a virtual method const std::string name() const override { return "FindDetectorsInShape"; }; diff --git a/Framework/DataHandling/inc/MantidDataHandling/MaskDetectorsInShape.h b/Framework/DataHandling/inc/MantidDataHandling/MaskDetectorsInShape.h index c16eec1b13f6ae55b94c8b3b161ccf5f523d0853..533fe235fe9d68dac7f0d8e2b51465b4280a3f23 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/MaskDetectorsInShape.h +++ b/Framework/DataHandling/inc/MantidDataHandling/MaskDetectorsInShape.h @@ -1,10 +1,7 @@ #ifndef MANTID_DATAHANDLING_MASKDETECTORSINSHAPE_H_ #define MANTID_DATAHANDLING_MASKDETECTORSINSHAPE_H_ -//---------------------------------------------------------------------- -// Includes -//---------------------------------------------------------------------- -#include "MantidAPI/Algorithm.h" +#include "MantidAPI/DistributedAlgorithm.h" namespace Mantid { namespace DataHandling { @@ -55,7 +52,7 @@ namespace DataHandling { File change history is stored at: <https://github.com/mantidproject/mantid>. Code Documentation is available at: <http://doxygen.mantidproject.org> */ -class DLLExport MaskDetectorsInShape : public API::Algorithm { +class DLLExport MaskDetectorsInShape : public API::DistributedAlgorithm { public: /// Algorithm's name for identification overriding a virtual method const std::string name() const override { return "MaskDetectorsInShape"; }; @@ -79,7 +76,7 @@ private: const bool includeMonitors); /// Calls MaskDetectors as a Child Algorithm void runMaskDetectors(API::MatrixWorkspace_sptr workspace, - const std::vector<int> detectorIds); + const std::vector<int> &detectorIds); }; } // namespace DataHandling diff --git a/Framework/DataHandling/src/MaskDetectorsInShape.cpp b/Framework/DataHandling/src/MaskDetectorsInShape.cpp index 5d35600abd839baa33c368de79410d94bc73ed0a..7818ac68eb3883a53d945e71b3d3a1500128bd68 100644 --- a/Framework/DataHandling/src/MaskDetectorsInShape.cpp +++ b/Framework/DataHandling/src/MaskDetectorsInShape.cpp @@ -1,11 +1,14 @@ -//---------------------------------------------------------------------- -// Includes -//---------------------------------------------------------------------- #include "MantidDataHandling/MaskDetectorsInShape.h" +#include "MantidDataHandling/MaskSpectra.h" +#include "MantidAPI/Algorithm.tcc" #include "MantidAPI/MatrixWorkspace.h" +#include "MantidGeometry/Instrument/DetectorInfo.h" #include "MantidKernel/ArrayProperty.h" #include "MantidKernel/MandatoryValidator.h" +#include "MantidIndexing/Conversion.h" +#include "MantidIndexing/GlobalSpectrumIndex.h" +#include "MantidIndexing/IndexInfo.h" namespace Mantid { namespace DataHandling { @@ -70,10 +73,19 @@ std::vector<int> MaskDetectorsInShape::runFindDetectorsInShape( } void MaskDetectorsInShape::runMaskDetectors( - API::MatrixWorkspace_sptr workspace, const std::vector<int> detectorIds) { - IAlgorithm_sptr alg = createChildAlgorithm("MaskDetectors", 0.85, 1.0); - alg->setProperty<std::vector<int>>("DetectorList", detectorIds); - alg->setProperty<MatrixWorkspace_sptr>("Workspace", workspace); + API::MatrixWorkspace_sptr workspace, const std::vector<int> &detectorIds) { + auto alg = createChildAlgorithm("MaskSpectra", 0.85, 1.0); + const auto &detInfo = workspace->detectorInfo(); + std::vector<size_t> detectorIndices; + for (const auto id : detectorIds) + detectorIndices.push_back(detInfo.indexOf(id)); + const auto &globalSpectrumIndices = + workspace->indexInfo().globalSpectrumIndicesFromDetectorIndices( + detectorIndices); + alg->setWorkspaceInputProperties( + "InputWorkspace", workspace, IndexType::WorkspaceIndex, + Indexing::castVector<int64_t>(globalSpectrumIndices)); + alg->setProperty("OutputWorkspace", workspace); try { if (!alg->execute()) { throw std::runtime_error( diff --git a/docs/source/development/AlgorithmMPISupport.rst b/docs/source/development/AlgorithmMPISupport.rst index 3aabbe799e45598395771eaa19b6678c7afafa4f..52b5f901369a1d192805e0ab9def5fc60b50ed07 100644 --- a/docs/source/development/AlgorithmMPISupport.rst +++ b/docs/source/development/AlgorithmMPISupport.rst @@ -476,6 +476,7 @@ FilterBadPulses all FilterByLogValue all FilterByTime all FilterEventsByLogValuePreNexus Identical see ``IFileLoader`` +FindDetectorsInShape all Fit MasterOnly, Identical see ``IFittingAlgorithm`` IFileLoader Identical implicitly adds support for many load-algorithms inheriting from this IFittingAlgorithm MasterOnly, Identical implicitly adds support for several fit-algorithms inheriting from this @@ -526,6 +527,7 @@ LoadSwans Identical see ``IFileLoader`` LoadTBL Identical see ``IFileLoader`` LoadTOFRawNexus Identical see ``IFileLoader`` MaskBins all +MaskDetectorsInShape all MaskSpectra all Minus all see ``BinaryOperation`` MoveInstrumentComponent all