No Matches
Go to the documentation of this file.
1// Mantid Repository :
3// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
14using namespace Mantid;
15using namespace Algorithms;
18void SpectrumAlgorithm::declareWorkspaceIndexSetProperties(const std::string &indexMinPropertyName,
19 const std::string &indexMaxPropertyName,
20 const std::string &indexRangePropertyName) {
21 m_indexMinPropertyName = indexMinPropertyName;
22 m_indexMaxPropertyName = indexMaxPropertyName;
23 m_indexRangePropertyName = indexRangePropertyName;
24 auto mustBePositive = std::make_shared<Kernel::BoundedValidator<int>>();
25 mustBePositive->setLower(0);
26 // TODO: The names and descriptions of these properties are temporary and for
27 // now follow the old naming from the algorithm ChangeBinOffset, to not break
28 // its interface. This will be changed once a decision on a generic and
29 // uniform interface has been made. We keep it for now, to avoid breaking that
30 // algorithms interface twice.
31 declareProperty(m_indexMinPropertyName, 0, mustBePositive, "The first Workspace index to be included in the summing");
33 "The last Workspace index to be included in the summing");
36 "A list of workspace indices as a string with ranges, for "
37 "example: 5-10,15,20-23. \n"
38 "Optional: if not specified, then the "
39 "Start/EndWorkspaceIndex fields are used alone. "
40 "If specified, the range and the list are combined (without "
41 "duplicating indices). For example, a range of 10 to 20 and "
42 "a list '12,15,26,28' gives '10-20,26,28'.");
53 auto numberOfSpectra = workspace.getNumberHistograms();
56 return {numberOfSpectra};
60 std::vector<size_t> indices_list = getProperty(m_indexRangePropertyName);
62 if (indices_list.empty()) {
63 if (isEmpty(max))
64 return {numberOfSpectra};
65 else
66 return {min, max, numberOfSpectra};
67 }
69 // Add range to index list if given.
70 if (!isEmpty(max)) {
71 for (int i = min; i <= max; i++)
72 indices_list.emplace_back(i);
73 }
74 return {indices_list, numberOfSpectra};
82 workspace.clearMRU();
IPeaksWorkspace_sptr workspace
Definition: IndexPeaks.cpp:114
void declareProperty(std::unique_ptr< Kernel::Property > p, const std::string &doc="") override
Add a property to the list of managed properties.
Definition: Algorithm.cpp:1913
bool existsProperty(const std::string &name) const override
Checks whether the named property is already in the list of managed property.
Definition: Algorithm.cpp:2008
TypedValue getProperty(const std::string &name) const override
Get the value of a property.
Definition: Algorithm.cpp:2076
static bool isEmpty(const NumT toCheck)
checks that the value was not set by users, uses the value in empty double/int.
Base MatrixWorkspace Abstract Class.
void declareWorkspaceIndexSetProperties(const std::string &indexMinPropertyName="IndexMin", const std::string &indexMaxPropertyName="IndexMax", const std::string &indexRangePropertyName="WorkspaceIndexList")
Declare standard properties for defining ranges/lists of spectra.
void ifEventWorkspaceClearMRU(const WS &workspace)
Templated function used as 'compile-time conditional', together with specialization.
Kernel::IndexSet getWorkspaceIndexSet(const API::MatrixWorkspace &workspace) const
Returns a validated IndexSet refering to spectra in workspace.
This class is intended to fulfill the design specified in <
Support for a property that holds an array of values.
Definition: ArrayProperty.h:28
IndexSet is a container that can be used to define and access a subset of elements in a larger contai...
Definition: IndexSet.h:26
Helper class which provides the Collimation Length for SANS instruments.
constexpr int EMPTY_INT() noexcept
Returns what we consider an "empty" integer within a property.
Definition: EmptyValues.h:25