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 {
15
16namespace API { // forward declare
17class ISpectrum;
18class SpectrumInfo;
19} // namespace API
20
21namespace DataObjects { // forward declare
22class RebinnedOutput;
23using RebinnedOutput_sptr = std::shared_ptr<RebinnedOutput>;
24using RebinnedOutput_const_sptr = std::shared_ptr<const RebinnedOutput>;
25} // namespace DataObjects
26
27namespace Algorithms {
28
31
55class MANTID_ALGORITHMS_DLL SumSpectra : public API::Algorithm {
56public:
58 const std::string name() const override { return "SumSpectra"; }
60 const std::string summary() const override {
61 return "The SumSpectra algorithm adds the data values in each time bin "
62 "across a range of spectra; the output workspace has a single "
63 "spectrum. If the input is an EventWorkspace, the output is also an "
64 "EventWorkspace; otherwise it will be a Workspace2D.";
65 }
66
68 int version() const override { return (1); }
69 const std::vector<std::string> seeAlso() const override { return {"SumNeighbours"}; }
71 const std::string category() const override { return "Transforms\\Grouping"; }
73 std::map<std::string, std::string> validateInputs() override;
74
75private:
77 void doFractionalSum(RebinnedOutput_const_sptr const &, RebinnedOutput_sptr const &, API::Progress &, size_t &);
78 void doFractionalWeightedSum(RebinnedOutput_const_sptr const &, RebinnedOutput_sptr const &, API::Progress &,
79 size_t &);
81 void doSimpleSum(API::MatrixWorkspace_const_sptr const &, API::ISpectrum &, API::Progress &, size_t &);
82 void doSimpleWeightedSum(API::MatrixWorkspace_const_sptr const &, API::ISpectrum &, API::Progress &, size_t &);
83
84 // Overridden Algorithm methods
85 void init() override;
86 void exec() override;
87 void execEvent(const API::MatrixWorkspace_sptr &outputWorkspace, API::Progress &progress, size_t &numZeros);
88 specnum_t getOutputSpecNo(const API::MatrixWorkspace_const_sptr &localworkspace);
89
90 API::MatrixWorkspace_sptr replaceSpecialValues();
91 size_t determineIndices(API::SpectrumInfo const &, const size_t numberOfSpectra);
92
94 specnum_t m_outSpecNum{0};
96 bool m_keepMonitors{false};
98 size_t m_numberOfSpectra{0};
100 size_t m_yLength{0};
102 std::set<size_t> m_indices;
103
104 // if calculating additional workspace with specially weighted averages is
105 // necessary
106 bool m_calculateWeightedSum{false};
107 bool m_multiplyByNumSpec{true};
108};
109
110} // namespace Algorithms
111} // namespace Mantid
Base class from which all concrete algorithm classes should be derived.
Definition Algorithm.h:76
A "spectrum" is an object that holds the data for a particular spectrum, in particular:
Definition ISpectrum.h:38
Helper class for reporting progress from algorithms.
Definition Progress.h:25
API::SpectrumInfo is an intermediate step towards a SpectrumInfo that is part of Instrument-2....
Takes a workspace as input and sums all of the spectra within it maintaining the existing bin structu...
Definition SumSpectra.h:55
const std::string category() const override
Algorithm's category for identification overriding a virtual method.
Definition SumSpectra.h:71
const std::string name() const override
Algorithm's name for identification overriding a virtual method.
Definition SumSpectra.h:58
const std::vector< std::string > seeAlso() const override
Function to return all of the seeAlso algorithms related to this algorithm.
Definition SumSpectra.h:69
const std::string summary() const override
Summary of algorithms purpose.
Definition SumSpectra.h:60
int version() const override
Algorithm's version for identification overriding a virtual method.
Definition SumSpectra.h:68
std::set< size_t > m_indices
Set of indices to sum.
Definition SumSpectra.h:102
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 RebinnedOutput > RebinnedOutput_const_sptr
shared pointer to a const RebinnedOutput
Definition SumSpectra.h:24
std::shared_ptr< RebinnedOutput > RebinnedOutput_sptr
shared pointer to the RebinnedOutput class
Definition SumSpectra.h:23
Helper class which provides the Collimation Length for SANS instruments.
int32_t specnum_t
Typedef for a spectrum Number.
Definition IDTypes.h:14