Mantid
Loading...
Searching...
No Matches
SumSpectra.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2007 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 +
7#pragma once
8
10#include "MantidAlgorithms/DllConfig.h"
12#include <set>
13
14namespace Mantid {
15namespace Algorithms {
39class MANTID_ALGORITHMS_DLL SumSpectra : public API::ParallelAlgorithm {
40public:
42 const std::string name() const override { return "SumSpectra"; }
44 const std::string summary() const override {
45 return "The SumSpectra algorithm adds the data values in each time bin "
46 "across a range of spectra; the output workspace has a single "
47 "spectrum. If the input is an EventWorkspace, the output is also an "
48 "EventWorkspace; otherwise it will be a Workspace2D.";
49 }
50
52 int version() const override { return (1); }
53 const std::vector<std::string> seeAlso() const override { return {"SumNeighbours"}; }
55 const std::string category() const override { return "Transforms\\Grouping"; }
57 std::map<std::string, std::string> validateInputs() override;
58
59private:
61 void doFractionalSum(const API::MatrixWorkspace_sptr &outputWorkspace, API::Progress &progress, size_t &numSpectra,
62 size_t &numMasked, size_t &numZeros);
64 void doSimpleSum(const API::MatrixWorkspace_sptr &outputWorkspace, API::Progress &progress, size_t &numSpectra,
65 size_t &numMasked, size_t &numZeros);
66
67 // Overridden Algorithm methods
68 void init() override;
69 void exec() override;
70 void execEvent(const API::MatrixWorkspace_sptr &outputWorkspace, API::Progress &progress, size_t &numSpectra,
71 size_t &numMasked, size_t &numZeros);
72 specnum_t getOutputSpecNo(const API::MatrixWorkspace_const_sptr &localworkspace);
73
74 API::MatrixWorkspace_sptr replaceSpecialValues();
75 void determineIndices(const size_t numberOfSpectra);
76
78 specnum_t m_outSpecNum{0};
80 bool m_keepMonitors{false};
82 bool m_replaceSpecialValues{false};
84 size_t m_numberOfSpectra{0};
86 size_t m_yLength{0};
88 std::set<size_t> m_indices;
89
90 // if calculating additional workspace with specially weighted averages is
91 // necessary
92 bool m_calculateWeightedSum{false};
93 bool m_multiplyByNumSpec{true};
94};
95
96} // namespace Algorithms
97} // namespace Mantid
Base class for algorithms that can run in parallel on all MPI ranks but not in a distributed fashion.
Helper class for reporting progress from algorithms.
Definition: Progress.h:25
Takes a workspace as input and sums all of the spectra within it maintaining the existing bin structu...
Definition: SumSpectra.h:39
const std::string category() const override
Algorithm's category for identification overriding a virtual method.
Definition: SumSpectra.h:55
const std::string name() const override
Algorithm's name for identification overriding a virtual method.
Definition: SumSpectra.h:42
const std::vector< std::string > seeAlso() const override
Function to return all of the seeAlso algorithms related to this algorithm.
Definition: SumSpectra.h:53
const std::string summary() const override
Summary of algorithms purpose.
Definition: SumSpectra.h:44
int version() const override
Algorithm's version for identification overriding a virtual method.
Definition: SumSpectra.h:52
std::set< size_t > m_indices
Set of indices to sum.
Definition: SumSpectra.h:88
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
Helper class which provides the Collimation Length for SANS instruments.
int32_t specnum_t
Typedef for a spectrum Number.
Definition: IDTypes.h:16