12#include "MantidHistogramData/HistogramMath.h"
21using namespace Kernel;
27 "The name of the workspace2D on which to perform the algorithm");
30 "An array containing a list of the indexes of the spectra to combine\n"
31 "(DetectorList and WorkspaceIndexList are ignored if this is set)");
34 "An array of detector ID's (WorkspaceIndexList is ignored if this is\n"
38 "An array of workspace indices to combine");
47 std::vector<size_t> indexList =
getProperty(
"WorkspaceIndexList");
48 std::vector<specnum_t> spectraList =
getProperty(
"SpectraList");
52 if (indexList.empty() && spectraList.empty() &&
detectorList.empty()) {
54 "DetectorList properties are all empty, no "
62 if (!spectraList.empty()) {
63 indexList = WS->getIndicesFromSpectra(spectraList);
71 if (indexList.empty()) {
76 const auto firstIndex =
static_cast<specnum_t>(indexList[0]);
77 auto &firstSpectrum = WS->getSpectrum(firstIndex);
83 auto outputHisto = firstSpectrum.histogram();
85 for (
size_t i = 0; i < indexList.size() - 1; ++i) {
87 const size_t currentIndex = indexList[i + 1];
88 auto &spec = WS->getSpectrum(currentIndex);
91 firstSpectrum.addDetectorIDs(spec.getDetectorIDs());
94 outputHisto += spec.histogram();
99 spec.setSpectrumNo(-1);
100 spec.clearDetectorIDs();
104 firstSpectrum.setHistogram(outputHisto);
#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.
void progress(double p, const std::string &msg="", double estimatedTime=0.0, int progressPrecision=0)
Sends ProgressNotification.
Helper class for reporting progress from algorithms.
A property class for workspaces.
void exec() override
Virtual method - must be overridden by concrete algorithm.
void init() override
Virtual method - must be overridden by concrete algorithm.
const std::string name() const override
Algorithm's name for identification overriding a virtual method.
Support for a property that holds an array of values.
IPropertyManager * setProperty(const std::string &name, const T &value)
Templated method to set the value of a PropertyWithValue.
void warning(const std::string &msg)
Logs at warning level.
void information(const std::string &msg)
Logs at information level.
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
int32_t specnum_t
Typedef for a spectrum Number.
@ InOut
Both an input & output workspace.
@ Output
An output workspace.