13#include "MantidAlgorithms/DllConfig.h"
18namespace HistogramData {
26size_t getIndex(
const HistogramData::HistogramX &vecx,
double x);
36 const std::string
summary()
const override {
return "Fit a single peak with checking mechanism. "; }
42 void setFittingMethod(std::string minimizer,
const std::string &costfunction);
48 void setFitWindow(
double leftwindow,
double rightwindow);
51 void setPeakRange(
double xpeakleft,
double xpeakright);
54 void setupGuessedFWHM(
double usrwidth,
int minfwhm,
int maxfwhm,
int stepsize,
bool fitwithsteppedfwhm);
56 void setFitPeakCriteria(
bool usepeakpostol,
double peakpostol);
58 std::string getDebugMessage();
67 std::map<std::string, double> getPeakError();
70 std::map<std::string, double> getBackgroundError();
73 double getFitCostFunctionValue();
80 const std::string
name()
const override {
return "FitOneSinglePeak"; }
83 int version()
const override {
return 1; }
84 const std::vector<std::string>
seeAlso()
const override {
return {
"Fit"}; }
91 bool hasSetupToFitPeak(std::string &errmsg);
95 size_t wsindex,
size_t ixmin,
size_t ixmax);
99 double checkFittedPeak(
const API::IPeakFunction_sptr &peakfunc,
double costfuncvalue, std::string &errorreason);
103 size_t wsindex,
double startx,
double endx);
107 double xmin,
double xmax);
111 double xmin,
double xmax);
119 std::vector<double> vec_xmin, std::vector<double> vec_xmax);
124 void processNStoreFitResult(
double rwp,
bool storebkgd);
129 void pop(
const std::map<std::string, double> &funcparammap,
const API::IFunction_sptr &func);
223 const std::string
name()
const override {
return "FitPeak"; }
225 const std::string
summary()
const override {
return "Fit a single peak with checking mechanism. "; }
229 const std::string
category()
const override {
return "Optimization"; }
232 void init()
override;
233 void exec()
override;
236 void processProperties();
239 void prescreenInputData();
242 void setupOutput(
const std::map<std::string, double> &m_fitErrorPeakFunc,
243 const std::map<std::string, double> &m_fitErrorBkgdFunc);
247 double startx,
double endx);
261 size_t ixmin,
size_t ixmax);
265 double xmax,
bool calmode);
269 std::vector<double> vec_xmin, std::vector<double> vec_xmax);
284 void createFunctions();
291 std::map<std::string, double> peakerrormap,
293 std::map<std::string, double> bkgderrormap);
296 std::vector<std::string> addFunctionParameterNames(
const std::vector<std::string> &funcnames);
299 std::string parseFunctionTypeFull(
const std::string &fullstring,
bool &defaultparorder);
Base class from which all concrete algorithm classes should be derived.
FitOneSinglePeak: a class to perform peak fitting on a single peak.
std::map< std::string, double > m_bestBkgdFunc
Best background parameters.
double m_finalGoodnessValue
Final goodness value (Rwp/Chi-square)
size_t m_wsIndex
Input worskpace index.
std::string m_minimizer
Minimzer.
int version() const override
Version.
double m_maxPeakX
peak right boundary (client-defined)
API::IPeakFunction_sptr m_peakFunc
Peak function.
bool m_peakRangeSet
Flag whether the peak range is set.
std::map< std::string, double > m_bkupBkgdFunc
Backed up background function parameters.
API::MatrixWorkspace_sptr m_dataWS
Input data workspace.
std::map< std::string, double > m_bkupPeakFunc
Backed up peak function parameters.
double m_peakPositionTolerance
Peak position tolerance.
std::map< std::string, double > m_fitErrorBkgdFunc
Fit error of background function.
const std::string summary() const override
Summary of algorithms purpose.
std::map< std::string, double > m_fitErrorPeakFunc
Fit error of peak function.
const std::string name() const override
Name.
const std::vector< std::string > seeAlso() const override
Function to return all of the seeAlso algorithms related to this algorithm.
bool m_peakWindowSet
Peak widnow is set up.
API::IBackgroundFunction_sptr m_bkgdFunc
Background function.
size_t i_maxFitX
index of m_maxFitX
std::map< std::string, double > m_bestPeakFunc
Best peak parameters.
std::stringstream m_sstream
String stream.
double m_userPeakCentre
Peak centre provided by user.
bool m_usePeakPositionTolerance
Flag to apply peak position tolerance.
double m_minFitX
Lower boundary of fitting range.
bool m_peakWidthSet
Flag whether the peak width is set.
std::string m_costFunction
Cost function.
double m_maxFitX
Upper boundary of fitting range.
size_t i_maxPeakX
index of m_maxPeakX
double m_minPeakX
peak left boundary (client-defined)
std::vector< double > m_vecFWHM
bool m_fitMethodSet
Flag to show whether fitting parameters are set.
size_t i_minFitX
index of m_minFitX
size_t i_minPeakX
index of m_minPeakX
FitPeak : Fit a single peak.
double fitFunctionMD(API::IFunction_sptr fitfunc, API::MatrixWorkspace_sptr dataws, size_t wsindex, std::vector< double > vec_xmin, std::vector< double > vec_xmax)
Fit a function in multi-domain.
void setupGuessedFWHM(std::vector< double > &vec_FWHM)
Set up a vector of guessed FWHM.
size_t i_maxFitX
Vector index of m_maxFitX.
std::vector< double > m_vecybkup
Backups.
std::string m_minimizer
Minimizer.
bool m_fitBkgdFirst
fitting strategy
const std::string category() const override
Algorithm's category for identification.
API::IBackgroundFunction_sptr fitBackground(API::IBackgroundFunction_sptr bkgdfunc)
Fit background with multiple domain.
double m_minFitX
Minimum fit position.
double estimatePeakHeight(API::IPeakFunction_sptr peakfunc, API::MatrixWorkspace_sptr dataws, size_t wsindex, size_t ixmin, size_t ixmax)
Estimate the peak height from a set of data containing pure peaks.
size_t i_maxPeakX
Vector index of m_maxPeakX.
double m_maxFitX
Maximum fit position.
bool m_usePeakPositionTolerance
Use peak position tolerance as a criterial for peak fit.
bool m_fitWithStepPeakWidth
Flag about guessed FWHM (pixels)
DataObjects::TableWorkspace_sptr m_peakParameterTableWS
API::MatrixWorkspace_sptr m_dataWS
Input data workspace.
double m_maxPeakX
Maximum peak position.
API::MatrixWorkspace_sptr genPurePeakWS()
Backup data.
std::vector< std::string > m_bkgdParameterNames
Background.
double checkFittedPeak(API::IPeakFunction_sptr peakfunc, double costfuncvalue, std::string &errorreason)
Check the fitted peak value to see whether it is valud.
int m_fwhmFitStep
Step width of tried FWHM.
DataObjects::TableWorkspace_sptr m_bkgdParameterTableWS
int m_maxGuessedPeakWidth
Maximum guessed peak width (pixels)
API::IBackgroundFunction_sptr m_bkgdFunc
Background function.
double m_minPeakX
Minimum peak position.
double m_peakPositionTolerance
Tolerance on peak positions as criteria.
std::map< std::string, double > m_bestPeakFunc
Best fitted peak function.
int version() const override
Algorithm's version.
double m_finalGoodnessValue
Final.
const std::string name() const override
Algorithm's name.
API::IPeakFunction_sptr m_peakFunc
Peak function.
std::string m_costFunction
double fitFunctionSD(API::IFunction_sptr fitfunc, API::MatrixWorkspace_sptr dataws, size_t wsindex, double xmin, double xmax, bool calmode)
Fit a function.
double m_bestRwp
Best Rwp ...
bool m_lightWeightOutput
Fitting result.
void makePurePeakWS(API::MatrixWorkspace_sptr purePeakWS)
Make a pure peak WS in the fit window region.
bool m_outputRawParams
output option
std::map< std::string, double > m_bkupPeakFunc
Storage map for peak function.
double fitCompositeFunction(API::IPeakFunction_sptr peakfunc, API::IBackgroundFunction_sptr bkgdfunc, API::MatrixWorkspace_sptr dataws, size_t wsindex, double startx, double endx)
Fit peak and background composite function.
std::map< std::string, double > m_bkupBkgdFunc
Storage map for background function.
std::vector< double > m_vecebkup
double m_userGuessedFWHM
User guessed FWHM.
int m_minGuessedPeakWidth
Minimum guessed peak width (pixels)
size_t i_minFitX
Vector index of m_minFitX.
std::vector< std::string > m_peakParameterNames
Peak.
const std::string summary() const override
Summary of algorithms purpose.
void pop(const std::map< std::string, double > &funcparammap, API::IFunction_sptr func)
Pop.
std::map< std::string, double > m_bestBkgdFunc
Best background function.
double m_userPeakCentre
User guessed peak centre.
size_t i_minPeakX
Vector index of m_minPeakX.
double fitPeakFunction(API::IPeakFunction_sptr peakfunc, API::MatrixWorkspace_sptr dataws, size_t wsindex, double startx, double endx)
Fit a single peak function with pure peak workspace.
void processNStoreFitResult(double rwp, bool storebkgd)
Process and store fit result.
std::shared_ptr< IBackgroundFunction > IBackgroundFunction_sptr
std::shared_ptr< IPeakFunction > IPeakFunction_sptr
std::shared_ptr< const IPeakFunction > IPeakFunction_const_sptr
std::shared_ptr< IFunction > IFunction_sptr
shared pointer to the function base class
std::shared_ptr< const IFunction > IFunction_const_sptr
shared pointer to the function base class (const version)
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
size_t getIndex(const HistogramData::HistogramX &vecx, double x)
Get an index of a value in a sorted vector.
std::shared_ptr< TableWorkspace > TableWorkspace_sptr
shared pointer to Mantid::DataObjects::TableWorkspace
Helper class which provides the Collimation Length for SANS instruments.