12#include "MantidAlgorithms/DllConfig.h"
14#include "MantidIndexing/SpectrumIndexSet.h"
19namespace HistogramData {
57 const std::string
name()
const override {
return "FindPeaks"; }
59 const std::string
summary()
const override {
return "Searches for peaks in a dataset."; }
62 int version()
const override {
return (1); }
63 const std::vector<std::string>
seeAlso()
const override {
return {
"MatchPeaks",
"FindPeaksMD",
"GeneratePeaks"}; }
65 const std::string
category()
const override {
return "Optimization\\PeakFinding"; }
67 int getIndex(
const HistogramData::HistogramX &vecX,
double x);
74 void processAlgorithmProperties();
77 void findPeaksUsingMariscotti();
80 void findPeaksGivenStartingPoints(
const std::vector<double> &peakcentres,
const std::vector<double> &fitwindows);
84 void smoothData(std::vector<HistogramData::Histogram> &histograms,
const int w,
const int g_z);
86 std::vector<HistogramData::Histogram> &smoothed,
const int &w);
87 long long computePhi(
const int &w)
const;
91 const double xmin,
const double xmax);
95 const int fitWidth,
const bool hasleftpeak,
const double leftpeakcentre,
96 const bool hasrightpeak,
const double rightpeakcentre);
104 int i_max,
double &in_bg0,
double &in_bg1,
double &in_bg2,
int i_peakmin,
int i_peakmax);
107 const int &i4,
const double &in_bg0,
const double &in_bg1,
const double &in_bg2);
115 void addNonFitRecord(
const size_t spectrum,
const double centre);
118 void createFunctions();
122 std::vector<double> &vecBkgdParamValues, std::vector<double> &vecpeakrange);
125 void estimateBackground(
const HistogramData::HistogramX &X,
const HistogramData::HistogramY &Y,
const size_t i_min,
126 const size_t i_max, std::vector<double> &vecbkgdparvalues);
129 void estimatePeakRange(
const HistogramData::HistogramX &vecX,
size_t i_centre,
size_t i_min,
size_t i_max,
130 const double &leftfwhm,
const double &rightfwhm, std::vector<double> &vecpeakrange);
133 std::string
estimatePeakParameters(
const HistogramData::HistogramX &vecX,
const HistogramData::HistogramY &vecY,
134 size_t i_min,
size_t i_max,
const std::vector<double> &vecbkgdparvalues,
135 size_t &iobscentre,
double &
height,
double &fwhm,
double &leftfwhm,
139 void generateOutputPeakParameterTable();
141 std::vector<double> getStartingPeakValues();
147 const std::vector<double> &vec_peakrange,
int minGuessFWHM,
int maxGuessFWHM,
int guessedFWHMStep,
148 int estBackResult = 0);
156 static const int g_z = 5;
161 std::unique_ptr<API::Progress> m_progress =
nullptr;
Base class for algorithms that can run in parallel on all MPI ranks but not in a distributed fashion.
This algorithm searches for peaks in a dataset.
const std::vector< std::string > seeAlso() const override
Function to return all of the seeAlso algorithms related to this algorithm.
Indexing::SpectrumIndexSet m_indexSet
list of workspace indicies to check
API::ITableWorkspace_sptr m_outPeakTableWS
Storage of the peak data.
double m_peakPositionTolerance
std::vector< size_t > m_peakRightIndexes
const std::string category() const override
Algorithm's category for identification.
const std::string summary() const override
Summary of algorithms purpose.
API::IBackgroundFunction_sptr m_backgroundFunction
bool m_useObsCentre
Start values.
std::vector< double > m_vecPeakCentre
const std::string name() const override
Algorithm's name.
void fitPeakOneStep(const API::MatrixWorkspace_sptr &input, const int spectrum, const int &i0, const int &i2, const int &i4, const double &in_bg0, const double &in_bg1, const double &in_bg2)
int m_maxGuessedPeakWidth
bool m_usePeakPositionTolerance
API::MatrixWorkspace_sptr m_dataWS
workspace to check for peaks
double m_leastMaxObsY
Minimum value of peak's observed maximum Y value.
double m_minHeight
Minimum peak height.
std::size_t m_centreIndex
API::IPeakFunction_sptr m_peakFunction
void fitPeakHighBackground(const API::MatrixWorkspace_sptr &input, const size_t spectrum, int i_centre, int i_min, int i_max, double &in_bg0, double &in_bg1, double &in_bg2, int i_peakmin, int i_peakmax)
std::size_t m_numTableParams
parameters or effective (centre, width, height)
~FindPeaks() override=default
Virtual destructor.
std::vector< double > m_vecFitWindows
std::vector< API::IFunction_sptr > m_fitFunctions
std::vector< double > getStartingBkgdValues()
bool m_highBackground
flag for find relatively weak peak in high
int version() const override
Algorithm's version.
std::vector< std::string > m_bkgdParameterNames
std::vector< std::string > m_peakParameterNames
int m_minGuessedPeakWidth
std::string m_peakFuncType
int m_stepGuessedPeakWidth
bool m_rawPeaksTable
background
std::vector< size_t > m_peakLeftIndexes
std::string m_costFunction
std::string m_backgroundType
int m_inputPeakFWHM
holder for the requested peak FWHM
std::shared_ptr< IBackgroundFunction > IBackgroundFunction_sptr
std::shared_ptr< IPeakFunction > IPeakFunction_sptr
std::shared_ptr< ITableWorkspace > ITableWorkspace_sptr
shared pointer to Mantid::API::ITableWorkspace
std::shared_ptr< const IPeakFunction > IPeakFunction_const_sptr
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
MANTID_ALGORITHMS_DLL int estimatePeakParameters(const HistogramData::Histogram &histogram, const std::pair< size_t, size_t > &peak_window, const API::IPeakFunction_sptr &peakfunction, const API::IBackgroundFunction_sptr &bkgdfunction, bool observe_peak_width, const EstimatePeakWidth peakWidthEstimateApproach, const double peakWidthPercentage, const double minPeakHeight)
Estimate peak parameters by 'observation'.
size_t getIndex(const HistogramData::HistogramX &vecx, double x)
Get an index of a value in a sorted vector.
Helper class which provides the Collimation Length for SANS instruments.