Mantid
Loading...
Searching...
No Matches
SplineSmoothing.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2013 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
13#include "MantidKernel/System.h"
14
15namespace Mantid {
16namespace CurveFitting {
17namespace Algorithms {
18
26class MANTID_CURVEFITTING_DLL SplineSmoothing final : public API::Algorithm {
27public:
29
30 const std::string name() const override;
31 int version() const override;
32 const std::vector<std::string> seeAlso() const override { return {"Fit", "SplineInterpolation", "SplineBackground"}; }
33 const std::string category() const override;
35 const std::string summary() const override {
36 return "Smooths a set of spectra using a cubic spline. Optionally, this "
37 "algorithm can also calculate derivatives up to order 2 as a side "
38 "product";
39 }
40
41private:
44
45 // Overridden methods
46 void init() override;
47 void exec() override;
48
50 void smoothSpectrum(const int index);
51
53 void calculateSpectrumDerivatives(const int index, const int order);
54
57 API::MatrixWorkspace_sptr setupOutputWorkspace(const API::MatrixWorkspace_sptr &inws, const int size) const;
58
60 void convertToHistogram();
61
63 void selectSmoothingPoints(const API::MatrixWorkspace &inputWorkspace, const size_t row);
64
66 void calculateSmoothing(const API::MatrixWorkspace &inputWorkspace, API::MatrixWorkspace &outputWorkspace,
67 const size_t row) const;
68
70 void calculateDerivatives(const API::MatrixWorkspace &inputWorkspace, API::MatrixWorkspace &outputWorkspace,
71 const int order, const size_t row) const;
72
74 void addSmoothingPoints(const std::set<int> &points, const double *xs, const double *ys) const;
75
78 bool checkSmoothingAccuracy(const int start, const int end, const double *ys, const double *ysmooth) const;
79
81 void performAdditionalFitting(const API::MatrixWorkspace_sptr &ws, const int row);
82
86
88 std::shared_ptr<Functions::BSpline> m_cspline;
97};
98
99} // namespace Algorithms
100} // namespace CurveFitting
101} // namespace Mantid
IPeaksWorkspace_sptr workspace
Definition: IndexPeaks.cpp:114
std::map< DeltaEMode::Type, std::string > index
Definition: DeltaEMode.cpp:19
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:85
Base MatrixWorkspace Abstract Class.
Takes a 2D workspace and produces an output workspace containing a smoothed version of the data by se...
std::shared_ptr< Functions::BSpline > m_cspline
CubicSpline member used to perform smoothing.
API::MatrixWorkspace_sptr m_inputWorkspace
pointer to the input workspace
const int M_START_SMOOTH_POINTS
number of smoothing points to start with
const std::vector< std::string > seeAlso() const override
Function to return all of the seeAlso (these are not validated) algorithms related to this algorithm....
const std::string summary() const override
Summary of algorithms purpose.
API::MatrixWorkspace_sptr m_outputWorkspace
pointer to the smoothed output workspace
API::MatrixWorkspace_sptr m_inputWorkspacePointData
pointer to the input workspace converted to point data
API::WorkspaceGroup_sptr m_derivativeWorkspaceGroup
pointer to the output workspace group of derivatives
std::shared_ptr< WorkspaceGroup > WorkspaceGroup_sptr
shared pointer to Mantid::API::WorkspaceGroup
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
Helper class which provides the Collimation Length for SANS instruments.