16using namespace Kernel;
33 return "Extracts unmasked spectra from a workspace and places them in a new "
43 "If given but not as a MaskWorkspace, the masking from "
44 "this workspace will be used. If given as a "
45 "MaskWorkspace, the masking is read from its Y values.");
47 "An output workspace.");
56 if (!maskedWorkspace) {
57 maskedWorkspace = inputWorkspace;
58 }
else if (inputWorkspace->getNumberHistograms() != maskedWorkspace->getNumberHistograms()) {
59 throw std::runtime_error(
"Masked workspace has a different number of spectra.");
63 std::vector<size_t> indices;
67 extract->initialize();
68 extract->setRethrows(
true);
70 extract->setProperty(
"InputWorkspace", inputWorkspace);
71 extract->setProperty(
"WorkspaceIndexList", indices);
85 for (
size_t i = 0; i < mask->getNumberHistograms(); ++i) {
86 if (mask->y(i)[0] == 0.0) {
87 indices.emplace_back(i);
91 const auto &spectrumInfo = maskedWorkspace->
spectrumInfo();
93 if (!spectrumInfo.hasDetectors(i))
95 if (!spectrumInfo.isMasked(i))
96 indices.emplace_back(i);
#define DECLARE_ALGORITHM(classname)
void declareProperty(std::unique_ptr< Kernel::Property > p, const std::string &doc="") override
Add a property to the list of managed properties.
TypedValue getProperty(const std::string &name) const override
Get the value of a property.
virtual std::shared_ptr< Algorithm > createChildAlgorithm(const std::string &name, const double startProgress=-1., const double endProgress=-1., const bool enableLogging=true, const int &version=-1)
Create a Child Algorithm.
const SpectrumInfo & spectrumInfo() const
Return a reference to the SpectrumInfo object.
Base MatrixWorkspace Abstract Class.
virtual std::size_t getNumberHistograms() const =0
Returns the number of histograms in the workspace.
A property class for workspaces.
RemoveMaskedSpectra removes all masked spectra.
int version() const override
Algorithm's version for identification.
const std::string summary() const override
Algorithm's summary for use in the GUI and help.
const std::string category() const override
Algorithm's category for identification.
void makeIndexList(std::vector< size_t > &indices, const API::MatrixWorkspace *maskedWorkspace)
Fill in a vector with spectra indices to be extracted.
void exec() override
Execute the algorithm.
void init() override
Initialize the algorithm's properties.
IPropertyManager * setProperty(const std::string &name, const T &value)
Templated method to set the value of a PropertyWithValue.
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
@ Input
An input workspace.
@ Output
An output workspace.