Mantid
Loading...
Searching...
No Matches
SumSpectra.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
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 +
9#include "MantidAPI/Run.h"
20
21#include <functional>
22
23namespace Mantid::Algorithms {
24
25// Register the class into the algorithm factory
26DECLARE_ALGORITHM(SumSpectra)
27
28using namespace Kernel;
29using namespace API;
30using namespace DataObjects;
31
32namespace {
40bool validateSingleMatrixWorkspace(std::map<std::string, std::string> &validationOutput, const MatrixWorkspace &ws,
41 const int minIndex, const int maxIndex, const std::vector<int> &indices) {
42 bool success(true);
43 const auto numSpectra = static_cast<int>(ws.getNumberHistograms());
44 // check StartWorkSpaceIndex, >=0 done by validator
45 if (minIndex >= numSpectra) {
46 validationOutput["StartWorkspaceIndex"] = "Selected minimum workspace index is greater than available "
47 "spectra.";
48 success = false;
49 }
50 // check EndWorkspaceIndex in range
51 if (maxIndex != EMPTY_INT()) {
52 // check EndWorkspaceIndex in range
53 if (maxIndex >= numSpectra) {
54 validationOutput["EndWorkspaceIndex"] = "Selected maximum workspace index is greater than available "
55 "spectra.";
56 success = false;
57 // check StartWorkspaceIndex < EndWorkspaceIndex
58 }
59 }
60 // check ListOfWorkspaceIndices in range
61 if (std::any_of(indices.cbegin(), indices.cend(),
62 [numSpectra](const auto index) { return (index >= numSpectra) || (index < 0); })) {
63 validationOutput["ListOfWorkspaceIndices"] = "One or more indices out of range of available spectra.";
64 success = false;
65 }
66 return success;
67}
68
76void validateWorkspaceName(std::map<std::string, std::string> &validationOutput, const std::string &name,
77 const int minIndex, const int maxIndex, const std::vector<int> &indices) {
78 const auto &ads = AnalysisDataService::Instance();
79 if (!ads.doesExist(name))
80 return;
81 auto wsGroup = ads.retrieveWS<WorkspaceGroup>(name);
82 if (!wsGroup)
83 return;
84 size_t index = 0;
85 for (const auto &item : *wsGroup) {
86 auto matrixWs = std::dynamic_pointer_cast<MatrixWorkspace>(item);
87 if (!matrixWs) {
88 validationOutput["InputWorkspace"] = "Input group contains an invalid workspace type at item " +
89 std::to_string(index) + ". All members must be a MatrixWorkspace";
90 break;
91 }
92 if (!validateSingleMatrixWorkspace(validationOutput, *matrixWs, minIndex, maxIndex, indices)) {
93 break;
94 }
95 ++index;
96 }
97}
98} // namespace
99
104 declareProperty(std::make_unique<WorkspaceProperty<>>("InputWorkspace", "", Direction::Input,
105 std::make_shared<CommonBinsValidator>()),
106 "The workspace containing the spectra to be summed.");
107 declareProperty(std::make_unique<WorkspaceProperty<>>("OutputWorkspace", "", Direction::Output),
108 "The name of the workspace to be created as the output of the algorithm. "
109 " A workspace of this name will be created and stored in the Analysis "
110 "Data Service.");
111
112 auto mustBePositive = std::make_shared<BoundedValidator<int>>();
113 mustBePositive->setLower(0);
114 declareProperty("StartWorkspaceIndex", 0, mustBePositive, "The first Workspace index to be included in the summing");
115 declareProperty("EndWorkspaceIndex", EMPTY_INT(), mustBePositive,
116 "The last Workspace index to be included in the summing");
117
118 declareProperty(std::make_unique<Kernel::ArrayProperty<int>>("ListOfWorkspaceIndices"),
119 "A list of workspace indices as a string with ranges, for "
120 "example: 5-10,15,20-23. \n"
121 "Optional: if not specified, then the "
122 "Start/EndWorkspaceIndex fields are used alone. "
123 "If specified, the range and the list are combined (without "
124 "duplicating indices). For example, a range of 10 to 20 and "
125 "a list '12,15,26,28' gives '10-20,26,28'.");
126
127 declareProperty("IncludeMonitors", true, "Whether to include monitor spectra in the summation.");
128
129 declareProperty("WeightedSum", false,
130 "Instead of the usual spectra sum, calculate the weighted "
131 "sum. This has the form: \n"
132 ":math:`nSpectra "
133 "\\times\\Sigma(Signal_i/Error_i^2)/\\Sigma(1/Error_i^2)`\n "
134 "This property is ignored for event workspace.\n"
135 "The sums are defined for :math:`Error_i != 0` only, so the "
136 "values with zero error are dropped from the summation. To "
137 "estimate the number of dropped values see the "
138 "description. ");
139
140 declareProperty("RemoveSpecialValues", false,
141 "If enabled floating point special values such as NaN or Inf"
142 " are removed before the spectra are summed.");
143
144 declareProperty("MultiplyBySpectra", true,
145 "For unnormalized data one should multiply the weighted sum "
146 "by the number of spectra contributing to the bin.");
147 setPropertySettings("MultiplyBySpectra", std::make_unique<EnabledWhenProperty>("WeightedSum", IS_EQUAL_TO, "1"));
148
149 declareProperty("UseFractionalArea", true,
150 "Normalize the output workspace to the fractional area for "
151 "RebinnedOutput workspaces.");
152}
153
154/*
155 * Validate the input parameters
156 * @returns map with keys corresponding to properties with errors and values
157 * containing the error messages.
158 */
159std::map<std::string, std::string> SumSpectra::validateInputs() {
160 // create the map
161 std::map<std::string, std::string> validationOutput;
162
163 // Non-workspace checks
164 const int minIndex = getProperty("StartWorkspaceIndex");
165 const int maxIndex = getProperty("EndWorkspaceIndex");
166 if (minIndex > maxIndex) {
167 validationOutput["StartWorkspaceIndex"] = "Selected minimum workspace "
168 "index is greater than selected "
169 "maximum workspace index.";
170 validationOutput["EndWorkspaceIndex"] = "Selected maximum workspace index "
171 "is lower than selected minimum "
172 "workspace index.";
173 } else {
174 const std::vector<int> indices = getProperty("ListOfWorkspaceIndices");
175 if (MatrixWorkspace_const_sptr singleWs = getProperty("InputWorkspace")) {
176 validateSingleMatrixWorkspace(validationOutput, *singleWs, minIndex, maxIndex, indices);
177 } else {
178 validateWorkspaceName(validationOutput, getPropertyValue("InputWorkspace"), minIndex, maxIndex, indices);
179 }
180 }
181 return validationOutput;
182}
183
188 // Try and retrieve the optional properties
189 m_keepMonitors = getProperty("IncludeMonitors");
190 m_replaceSpecialValues = getProperty("RemoveSpecialValues");
191
192 // Get the input workspace
193 MatrixWorkspace_const_sptr localworkspace = getProperty("InputWorkspace");
194 m_numberOfSpectra = static_cast<int>(localworkspace->getNumberHistograms());
196 m_yLength = localworkspace->y(*(m_indices.begin())).size();
197
198 // determine the output spectrum number
199 m_outSpecNum = getOutputSpecNo(localworkspace);
200 g_log.information() << "Spectra remapping gives single spectra with spectra number: " << m_outSpecNum << "\n";
201
202 m_calculateWeightedSum = getProperty("WeightedSum");
203 m_multiplyByNumSpec = getProperty("MultiplyBySpectra");
204
205 // setup all of the outputs
206 MatrixWorkspace_sptr outputWorkspace = nullptr;
207 size_t numSpectra(0); // total number of processed spectra
208 size_t numMasked(0); // total number of the masked and skipped spectra
209 size_t numZeros(0); // number of spectra which have 0 value in the first
210 // column (used in special cases of evaluating how good
211 // Poissonian statistics is)
212
213 Progress progress(this, 0.0, 1.0, m_indices.size());
214 EventWorkspace_const_sptr eventW = std::dynamic_pointer_cast<const EventWorkspace>(localworkspace);
215 if (eventW) {
217 g_log.warning("Ignoring request for WeightedSum");
219 }
220 outputWorkspace = create<EventWorkspace>(*eventW, 1, eventW->binEdges(0));
221
222 execEvent(outputWorkspace, progress, numSpectra, numMasked, numZeros);
223 } else {
224 //-------Workspace 2D mode -----
225
226 // Create the 2D workspace for the output
227 outputWorkspace = API::WorkspaceFactory::Instance().create(
228 localworkspace, 1, localworkspace->x(*(m_indices.begin())).size(), m_yLength);
229
230 // This is the (only) output spectrum
231 auto &outSpec = outputWorkspace->getSpectrum(0);
232
233 // Copy over the bin boundaries
234 outSpec.setSharedX(localworkspace->sharedX(0));
235
236 // Build a new spectra map
237 outSpec.setSpectrumNo(m_outSpecNum);
238 outSpec.clearDetectorIDs();
239
240 if (localworkspace->id() == "RebinnedOutput") {
241 // this version is for a special workspace that has fractional overlap
242 // information
243 doFractionalSum(outputWorkspace, progress, numSpectra, numMasked, numZeros);
244 } else {
245 // for things where all the bins are lined up
246 doSimpleSum(outputWorkspace, progress, numSpectra, numMasked, numZeros);
247 }
248
249 // take the square root of all the accumulated squared errors - Assumes
250 // Gaussian errors
251 auto &YError = outSpec.mutableE();
252 std::transform(YError.begin(), YError.end(), YError.begin(), (double (*)(double))std::sqrt);
253 }
254
255 // set up the summing statistics
256 outputWorkspace->mutableRun().addProperty("NumAllSpectra", int(numSpectra), "", true);
257 outputWorkspace->mutableRun().addProperty("NumMaskSpectra", int(numMasked), "", true);
258 outputWorkspace->mutableRun().addProperty("NumZeroSpectra", int(numZeros), "", true);
259
260 // Assign it to the output workspace property
261 setProperty("OutputWorkspace", outputWorkspace);
262}
263
264void SumSpectra::determineIndices(const size_t numberOfSpectra) {
265 // assume that m_numberOfSpectra has been set
266 m_indices.clear();
267
268 // try the list form first
269 const std::vector<int> indices_list = getProperty("ListOfWorkspaceIndices");
270 m_indices.insert(indices_list.begin(), indices_list.end());
271
272 // add the range specified by the user
273 // this has been checked to be 0<= m_minWsInd <= maxIndex <=
274 // m_numberOfSpectra where maxIndex can be an EMPTY_INT
275 int minIndex = getProperty("StartWorkspaceIndex");
276 int maxIndex = getProperty("EndWorkspaceIndex");
277 if (isEmpty(maxIndex) && m_indices.empty()) {
278 maxIndex = static_cast<int>(numberOfSpectra - 1);
279 }
280
281 // create the indices in the range
282 if (!isEmpty(maxIndex)) {
283 for (int i = minIndex; i <= maxIndex; i++)
284 m_indices.insert(static_cast<size_t>(i));
285 }
286}
287
295 // initial value - any included spectrum will do
296 specnum_t specId = localworkspace->getSpectrum(*(m_indices.begin())).getSpectrumNo();
297
298 // the total number of spectra
299 size_t totalSpec = localworkspace->getNumberHistograms();
300
301 specnum_t temp;
302 for (const auto index : m_indices) {
303 if (index < totalSpec) {
304 temp = localworkspace->getSpectrum(index).getSpectrumNo();
305 if (temp < specId)
306 specId = temp;
307 }
308 }
309
310 return specId;
311}
312
319 // Get a copy of the input workspace
320 MatrixWorkspace_sptr wksp = getProperty("InputWorkspace");
321
323 // Skip any additional processing
324 return wksp;
325 }
326
327 auto alg = createChildAlgorithm("ReplaceSpecialValues");
328 alg->setProperty<MatrixWorkspace_sptr>("InputWorkspace", wksp);
329 std::string outName = "_" + wksp->getName() + "_clean";
330 alg->setProperty("OutputWorkspace", outName);
331 alg->setProperty("NaNValue", 0.0);
332 alg->setProperty("NaNError", 0.0);
333 alg->setProperty("InfinityValue", 0.0);
334 alg->setProperty("InfinityError", 0.0);
335 alg->executeAsChildAlg();
336 return alg->getProperty("OutputWorkspace");
337}
338
339namespace { // anonymous namespace
340// small function that normalizes the accumulated weight in a consistent fashion
341// the weights are modified in the process
342size_t applyWeight(const size_t numSpectra, HistogramData::HistogramY &y, std::vector<double> &weights,
343 const std::vector<size_t> &nZeros, const bool multiplyByNumSpec) {
344 // convert weight into proper normalization factor
345 if (multiplyByNumSpec) {
346 std::transform(weights.begin(), weights.end(), nZeros.begin(), weights.begin(),
347 [numSpectra](const double weight, const size_t nzero) {
348 if (numSpectra > nzero) {
349 return static_cast<double>(numSpectra - nzero) / weight;
350 } else {
351 return 1.;
352 }
353 });
354 } else {
355 std::transform(weights.begin(), weights.end(), nZeros.begin(), weights.begin(),
356 [numSpectra](const double weight, const size_t nzero) {
357 if (numSpectra > nzero) {
358 return 1. / weight;
359 } else {
360 return 1.;
361 }
362 });
363 }
364
365 // apply the normalization
366 y *= weights;
367
368 // the total number of bins with any zeros between all of the spectra used
369 return std::accumulate(nZeros.begin(), nZeros.end(), size_t(0));
370}
371
372// various checks on the workspace index to see if it should be included in the
373// sum if it is masked, the value of numMasked is incremented
374bool useSpectrum(const SpectrumInfo &spectrumInfo, const size_t wsIndex, const bool keepMonitors, size_t &numMasked) {
375 if (spectrumInfo.hasDetectors(wsIndex)) {
376 // Skip monitors, if the property is set to do so
377 if (!keepMonitors && spectrumInfo.isMonitor(wsIndex))
378 return false;
379 // Skip masked detectors
380 if (spectrumInfo.isMasked(wsIndex)) {
381 numMasked++;
382 return false;
383 }
384 }
385 return true;
386}
387} // anonymous namespace
388
399void SumSpectra::doSimpleSum(const MatrixWorkspace_sptr &outputWorkspace, Progress &progress, size_t &numSpectra,
400 size_t &numMasked, size_t &numZeros) {
401 // Clean workspace of any NANs or Inf values
402 auto localworkspace = replaceSpecialValues();
403
404 // Get references to the output workspaces's data vectors
405 auto &outSpec = outputWorkspace->getSpectrum(0);
406 auto &YSum = outSpec.mutableY();
407 auto &YErrorSum = outSpec.mutableE();
408
409 std::vector<double> Weight;
410 std::vector<size_t> nZeros;
411 if (m_calculateWeightedSum) {
412 Weight.assign(YSum.size(), 0.);
413 nZeros.assign(YSum.size(), 0);
414 }
415
416 const auto &spectrumInfo = localworkspace->spectrumInfo();
417 // Loop over spectra
418 for (const auto wsIndex : m_indices) {
419 if (!useSpectrum(spectrumInfo, wsIndex, m_keepMonitors, numMasked))
420 continue;
421 numSpectra++;
422
423 const auto &YValues = localworkspace->y(wsIndex);
424 const auto &YErrors = localworkspace->e(wsIndex);
425
426 if (m_calculateWeightedSum) {
427 // Retrieve the spectrum into a vector
428 for (size_t yIndex = 0; yIndex < m_yLength; ++yIndex) {
429 const double yErrorsVal = YErrors[yIndex];
430 if (std::isnormal(yErrorsVal)) { // is non-zero, nan, or infinity
431 const double errsq = yErrorsVal * yErrorsVal;
432 YErrorSum[yIndex] += errsq;
433 Weight[yIndex] += 1. / errsq;
434 YSum[yIndex] += YValues[yIndex] / errsq;
435 } else {
436 nZeros[yIndex]++;
437 }
438 }
439 } else {
440 YSum += YValues;
441 std::transform(YErrorSum.begin(), YErrorSum.end(), YErrors.begin(), YErrorSum.begin(),
442 [](const double accum, const double yerrorSpec) { return accum + yerrorSpec * yerrorSpec; });
443 }
444
445 // Map all the detectors onto the spectrum of the output
446 outSpec.addDetectorIDs(localworkspace->getSpectrum(wsIndex).getDetectorIDs());
447
448 progress.report();
449 }
450
451 if (m_calculateWeightedSum) {
452 numZeros = applyWeight(numSpectra, YSum, Weight, nZeros, m_multiplyByNumSpec);
453 } else {
454 numZeros = 0;
455 }
456}
457
468void SumSpectra::doFractionalSum(const MatrixWorkspace_sptr &outputWorkspace, Progress &progress, size_t &numSpectra,
469 size_t &numMasked, size_t &numZeros) {
470 // First, we need to clean the input workspace for nan's and inf's in order
471 // to treat the data correctly later. This will create a new private
472 // workspace that will be retrieved as mutable.
473 auto localworkspace = replaceSpecialValues();
474
475 // Transform to real workspace types
476 RebinnedOutput_sptr inWS = std::dynamic_pointer_cast<RebinnedOutput>(localworkspace);
477 RebinnedOutput_sptr outWS = std::dynamic_pointer_cast<RebinnedOutput>(outputWorkspace);
478
479 // Check finalize state prior to the sum process, at the completion
480 // the output is unfinalized
481 auto isFinalized = inWS->isFinalized();
482
483 // Get references to the output workspaces's data vectors
484 auto &outSpec = outputWorkspace->getSpectrum(0);
485 auto &YSum = outSpec.mutableY();
486 auto &YErrorSum = outSpec.mutableE();
487 auto &FracSum = outWS->dataF(0);
488
489 std::vector<double> Weight;
490 std::vector<size_t> nZeros;
491 if (m_calculateWeightedSum) {
492 Weight.assign(YSum.size(), 0);
493 nZeros.assign(YSum.size(), 0);
494 }
495
496 const auto &spectrumInfo = localworkspace->spectrumInfo();
497 // Loop over spectra
498 for (const auto wsIndex : m_indices) {
499 if (!useSpectrum(spectrumInfo, wsIndex, m_keepMonitors, numMasked))
500 continue;
501 numSpectra++;
502
503 // Retrieve the spectrum into a vector
504 const auto &YValues = localworkspace->y(wsIndex);
505 const auto &YErrors = localworkspace->e(wsIndex);
506 const auto &FracArea = inWS->readF(wsIndex);
507
508 if (m_calculateWeightedSum) {
509 for (size_t yIndex = 0; yIndex < m_yLength; ++yIndex) {
510 const double yErrorsVal = YErrors[yIndex];
511 const double fracVal = (isFinalized ? FracArea[yIndex] : 1.0);
512 if (std::isnormal(yErrorsVal)) { // is non-zero, nan, or infinity
513 const double errsq = yErrorsVal * yErrorsVal * fracVal * fracVal;
514 YErrorSum[yIndex] += errsq;
515 Weight[yIndex] += 1. / errsq;
516 YSum[yIndex] += YValues[yIndex] * fracVal / errsq;
517 } else {
518 nZeros[yIndex]++;
519 }
520 }
521 } else {
522 for (size_t yIndex = 0; yIndex < m_yLength; ++yIndex) {
523 const double fracVal = (isFinalized ? FracArea[yIndex] : 1.0);
524 YSum[yIndex] += YValues[yIndex] * fracVal;
525 YErrorSum[yIndex] += YErrors[yIndex] * YErrors[yIndex] * fracVal * fracVal;
526 }
527 }
528 // accumulation of fractional weight is the same
529 std::transform(FracSum.begin(), FracSum.end(), FracArea.begin(), FracSum.begin(), std::plus<double>());
530
531 // Map all the detectors onto the spectrum of the output
532 outSpec.addDetectorIDs(localworkspace->getSpectrum(wsIndex).getDetectorIDs());
533
534 progress.report();
535 }
536
537 if (m_calculateWeightedSum) {
538 numZeros = applyWeight(numSpectra, YSum, Weight, nZeros, m_multiplyByNumSpec);
539 } else {
540 numZeros = 0;
541 }
542
543 // Create the correct representation if using fractional area
544 auto useFractionalArea = getProperty("UseFractionalArea");
545 if (useFractionalArea) {
546 outWS->finalize();
547 }
548}
549
559void SumSpectra::execEvent(const MatrixWorkspace_sptr &outputWorkspace, Progress &progress, size_t &numSpectra,
560 size_t &numMasked, size_t &numZeros) {
561 MatrixWorkspace_const_sptr localworkspace = getProperty("InputWorkspace");
562 EventWorkspace_const_sptr inputWorkspace = std::dynamic_pointer_cast<const EventWorkspace>(localworkspace);
563
564 // Get the pointer to the output event list
565 EventWorkspace_sptr outputEventWorkspace = std::dynamic_pointer_cast<EventWorkspace>(outputWorkspace);
566 EventList &outputEL = outputEventWorkspace->getSpectrum(0);
567 outputEL.setSpectrumNo(m_outSpecNum);
568 outputEL.clearDetectorIDs();
569
570 const auto &spectrumInfo = inputWorkspace->spectrumInfo();
571 // Loop over spectra
572 for (const auto i : m_indices) {
573 if (spectrumInfo.hasDetectors(i)) {
574 // Skip monitors, if the property is set to do so
575 if (!m_keepMonitors && spectrumInfo.isMonitor(i))
576 continue;
577 // Skip masked detectors
578 if (spectrumInfo.isMasked(i)) {
579 numMasked++;
580 continue;
581 }
582 }
583 numSpectra++;
584
585 // Add the event lists with the operator
586 const EventList &inputEL = inputWorkspace->getSpectrum(i);
587 if (inputEL.empty()) {
588 ++numZeros;
589 }
590 outputEL += inputEL;
591
592 progress.report();
593 }
594}
595
596} // namespace Mantid::Algorithms
#define DECLARE_ALGORITHM(classname)
Definition: Algorithm.h:576
std::map< DeltaEMode::Type, std::string > index
Definition: DeltaEMode.cpp:19
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
std::string getPropertyValue(const std::string &name) const override
Get the value of a property as a string.
Definition: Algorithm.cpp:2026
TypedValue getProperty(const std::string &name) const override
Get the value of a property.
Definition: Algorithm.cpp:2076
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.
Definition: Algorithm.cpp:842
Kernel::Logger & g_log
Definition: Algorithm.h:451
void progress(double p, const std::string &msg="", double estimatedTime=0.0, int progressPrecision=0)
Sends ProgressNotification.
Definition: Algorithm.cpp:231
static bool isEmpty(const NumT toCheck)
checks that the value was not set by users, uses the value in empty double/int.
void clearDetectorIDs()
Clear the detector IDs set.
Definition: ISpectrum.cpp:117
void setSpectrumNo(specnum_t num)
Sets the the spectrum number of this spectrum.
Definition: ISpectrum.cpp:127
Helper class for reporting progress from algorithms.
Definition: Progress.h:25
A property class for workspaces.
size_t m_yLength
Blocksize of the input workspace.
Definition: SumSpectra.h:86
bool m_keepMonitors
Set true to keep monitors.
Definition: SumSpectra.h:80
void execEvent(const API::MatrixWorkspace_sptr &outputWorkspace, API::Progress &progress, size_t &numSpectra, size_t &numMasked, size_t &numZeros)
Executes the algorithm.
Definition: SumSpectra.cpp:559
void exec() override
Executes the algorithm.
Definition: SumSpectra.cpp:187
std::map< std::string, std::string > validateInputs() override
Cross-input validation.
Definition: SumSpectra.cpp:159
void determineIndices(const size_t numberOfSpectra)
Definition: SumSpectra.cpp:264
bool m_replaceSpecialValues
Set true to remove special values before processing.
Definition: SumSpectra.h:82
void doFractionalSum(const API::MatrixWorkspace_sptr &outputWorkspace, API::Progress &progress, size_t &numSpectra, size_t &numMasked, size_t &numZeros)
Handle logic for RebinnedOutput workspaces.
Definition: SumSpectra.cpp:468
specnum_t m_outSpecNum
The output spectrum number.
Definition: SumSpectra.h:78
specnum_t getOutputSpecNo(const API::MatrixWorkspace_const_sptr &localworkspace)
Determine the minimum spectrum No for summing.
Definition: SumSpectra.cpp:294
void init() override
Initialisation method.
Definition: SumSpectra.cpp:103
API::MatrixWorkspace_sptr replaceSpecialValues()
Calls an algorithm to replace special values within the workspace such as NaN or Inf to 0.
Definition: SumSpectra.cpp:318
size_t m_numberOfSpectra
numberOfSpectra in the input
Definition: SumSpectra.h:84
std::set< size_t > m_indices
Set of indices to sum.
Definition: SumSpectra.h:88
void doSimpleSum(const API::MatrixWorkspace_sptr &outputWorkspace, API::Progress &progress, size_t &numSpectra, size_t &numMasked, size_t &numZeros)
Handle logic for Workspace2D workspaces.
Definition: SumSpectra.cpp:399
A class for holding :
Definition: EventList.h:56
bool empty() const
Much like stl containers, returns true if there is nothing in the event list.
Definition: EventList.cpp:1158
Support for a property that holds an array of values.
Definition: ArrayProperty.h:28
IPropertyManager * setProperty(const std::string &name, const T &value)
Templated method to set the value of a PropertyWithValue.
void setPropertySettings(const std::string &name, std::unique_ptr< IPropertySettings > settings)
void warning(const std::string &msg)
Logs at warning level.
Definition: Logger.cpp:86
void information(const std::string &msg)
Logs at information level.
Definition: Logger.cpp:105
void report()
Increments the loop counter by 1, then sends the progress notification on behalf of its algorithm.
Definition: ProgressBase.h:51
static T & Instance()
Return a reference to the Singleton instance, creating it if it does not already exist Creation is do...
std::shared_ptr< const MatrixWorkspace > MatrixWorkspace_const_sptr
shared pointer to the matrix workspace base class (const version)
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
std::shared_ptr< const EventWorkspace > EventWorkspace_const_sptr
shared pointer to a const Workspace2D
std::shared_ptr< RebinnedOutput > RebinnedOutput_sptr
shared pointer to the RebinnedOutput class
std::shared_ptr< EventWorkspace > EventWorkspace_sptr
shared pointer to the EventWorkspace class
constexpr int EMPTY_INT() noexcept
Returns what we consider an "empty" integer within a property.
Definition: EmptyValues.h:25
int32_t specnum_t
Typedef for a spectrum Number.
Definition: IDTypes.h:16
std::string to_string(const wide_integer< Bits, Signed > &n)
@ Input
An input workspace.
Definition: Property.h:53
@ Output
An output workspace.
Definition: Property.h:54