Mantid
Loading...
Searching...
No Matches
FindPeakBackground.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2012 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
11#include "MantidAlgorithms/DllConfig.h"
12#include "MantidHistogramData/Histogram.h"
14
15namespace Mantid {
16
17namespace HistogramData {
18class HistogramX;
19class HistogramY;
20} // namespace HistogramData
21
22namespace Algorithms {
23
26class MANTID_ALGORITHMS_DLL FindPeakBackground : public API::ParallelAlgorithm {
27public:
29 const std::string name() const override { return "FindPeakBackground"; }
31 const std::string summary() const override { return "Separates background from signal for spectra of a workspace."; }
32
34 int version() const override { return 1; }
35 const std::vector<std::string> seeAlso() const override { return {"Fit"}; }
36
38 const std::string category() const override { return "Utility\\Calculation"; }
39
41 void setSigma(const double &sigma);
42
44 void setBackgroundOrder(size_t order);
45
47 void setFitWindow(const std::vector<double> &window);
48
50 void findWindowIndex(const HistogramData::Histogram &histogram, size_t &l0, size_t &n);
51
53 int findBackground(const HistogramData::Histogram &histogram, const size_t &l0, const size_t &n,
54 std::vector<size_t> &peak_min_max_indexes, std::vector<double> &bkgd3);
55
56private:
57 std::string m_backgroundType; //< The type of background to fit
58
60 void init() override;
62 void exec() override;
63 double moment4(MantidVec &X, size_t n, double mean);
64 void estimateBackground(const HistogramData::Histogram &histogram, const size_t i_min, const size_t i_max,
65 const size_t p_min, const size_t p_max, const bool hasPeak, double &out_bg0, double &out_bg1,
66 double &out_bg2);
67
69 void processInputProperties();
70
72 void createOutputWorkspaces();
73
74 // Histogram cannot be defined due to lack of default constructor. shared_ptr
75 // will do the copy
76
78 std::vector<double> m_vecFitWindows;
89
90 struct cont_peak {
91 size_t start;
92 size_t stop;
93 double maxY;
94 };
95 struct by_len {
96 bool operator()(cont_peak const &a, cont_peak const &b) { return a.maxY > b.maxY; }
97 };
98};
99
100} // namespace Algorithms
101} // namespace Mantid
double sigma
Definition: GetAllEi.cpp:156
Base class for algorithms that can run in parallel on all MPI ranks but not in a distributed fashion.
FindPeakBackground : Calculate Zscore for a Matrix Workspace.
const std::string summary() const override
Summary of algorithms purpose.
API::MatrixWorkspace_const_sptr m_inputWS
Input workspace.
int version() const override
Algorithm's version for identification overriding a virtual method.
std::vector< double > m_vecFitWindows
fit window
const std::vector< std::string > seeAlso() const override
Function to return all of the seeAlso algorithms related to this algorithm.
const std::string category() const override
Algorithm's category for identification overriding a virtual method.
size_t m_backgroundOrder
background order: 0 for flat, 1 for linear, 2 for quadratic
const std::string name() const override
Algorithm's name for identification overriding a virtual method.
API::ITableWorkspace_sptr m_outPeakTableWS
output workspace (table of result)
std::shared_ptr< ITableWorkspace > ITableWorkspace_sptr
shared pointer to Mantid::API::ITableWorkspace
std::shared_ptr< const MatrixWorkspace > MatrixWorkspace_const_sptr
shared pointer to the matrix workspace base class (const version)
Helper class which provides the Collimation Length for SANS instruments.
bool operator()(cont_peak const &a, cont_peak const &b)