17using namespace Kernel;
22 "The name of the input workspace.");
24 "The name under which to store the output workspace.");
26 auto mustBePositive = std::make_shared<BoundedValidator<int>>();
27 mustBePositive->setLower(0);
28 declareProperty(
"WorkspaceIndex", -1, mustBePositive,
"The workspace index number of the spectrum to extract.");
34 const int indexToExtract =
getProperty(
"WorkspaceIndex");
35 const size_t numHist = inputWorkspace->getNumberHistograms();
36 if (
static_cast<size_t>(indexToExtract) >= numHist) {
42 cropper->setProperty(
"InputWorkspace", inputWorkspace);
43 cropper->setProperty(
"StartWorkspaceIndex", indexToExtract);
44 cropper->setProperty(
"EndWorkspaceIndex", indexToExtract);
45 cropper->executeAsChildAlg();
47 setProperty<MatrixWorkspace_sptr>(
"OutputWorkspace", cropper->getProperty(
"OutputWorkspace"));
#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.
A property class for workspaces.
Exception for index errors.
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
@ Input
An input workspace.
@ Output
An output workspace.