21#include <gsl/gsl_sf_erf.h>
24namespace HistogramData {
29namespace CurveFitting {
70 const std::string
name()
const override {
return "LeBailFit"; }
72 const std::string
summary()
const override {
return "Do LeBail Fit to a spectrum of powder diffraction data. "; }
75 int version()
const override {
return 1; }
76 const std::vector<std::string>
seeAlso()
const override {
return {
"CreateLeBailFitInput",
"FitPowderDiffPeaks"}; }
79 const std::string
category()
const override {
return "Diffraction\\Fitting"; }
88 void processInputProperties();
92 void execPatternCalculation();
95 void execRefineBackground();
99 void createLeBailFunction();
105 void processInputBackground();
110 std::vector<double> &allpeaksvalues);
114 void parseInstrumentParametersTable();
117 void parseBraggPeaksParametersTable();
121 std::vector<std::string> &bkgdparnames, std::vector<double> &bkgdorderparams);
124 void exportBraggPeakParameterToTable();
127 void exportInstrumentParameterToTable(std::map<std::string, Parameter> parammap);
130 void createOutputDataWorkspace();
134 void execRandomWalkMinimizer(
size_t maxcycles, std::map<std::string, Parameter> ¶mmap);
137 void doMarkovChain(
const std::map<std::string, Parameter> ¶mmap,
const Mantid::HistogramData::HistogramX &vecX,
138 const Mantid::HistogramData::HistogramY &vecPurePeak,
const std::vector<double> &vecBkgd,
142 void setupBuiltInRandomWalkStrategy();
147 void addParameterToMCMinimize(std::vector<std::string> &parnamesforMC,
const std::string &parname);
150 bool calculateDiffractionPattern(
const Mantid::HistogramData::HistogramX &vecX,
151 const Mantid::HistogramData::HistogramY &vecY,
bool inputraw,
bool outputwithbkgd,
152 const Mantid::HistogramData::HistogramY &vecBkgd, std::vector<double> &values,
159 bool proposeNewValues(
const std::vector<std::string> &mcgroup,
Kernel::Rfactor r,
160 std::map<std::string, Parameter> &curparammap, std::map<std::string, Parameter> &newparammap,
164 double limitProposedValueInBound(
const Parameter ¶m,
double newvalue,
double direction,
int choice);
167 void bookKeepBestMCResult(std::map<std::string, Parameter> parammap,
const std::vector<double> &bkgddata,
171 void applyParameterValues(std::map<std::string, Parameter> &srcparammap,
172 std::map<std::string, Parameter> &tgtparammap);
175 void storeBackgroundParameters(std::vector<double> &bkgdparamvec);
179 void recoverBackgroundParameters(
const std::vector<double> &bkgdparamvec);
182 void proposeNewBackgroundValues();
211 std::map<std::string, double> convertToDoubleMap(std::map<std::string, Parameter> &inmap);
268 enum { RANDOMWALK, DRUNKENWALK } m_walkStyle;
289void writeRfactorsToFile(std::vector<double> vecX, std::vector<Kernel::Rfactor> vecR,
const std::string &filename);
Base class from which all concrete algorithm classes should be derived.
std::string mMinimizer
Minimizer.
std::vector< std::pair< std::vector< int >, double > > m_inputPeakInfoVec
Input Bragg peak information for future processing;.
Functions::BackgroundFunction_sptr m_backgroundFunction
Background function.
bool m_tolerateInputDupHKL2Peaks
Flag to allow peaks with duplicated (HKL)^2 in input .hkl file.
std::map< std::string, double > m_origFuncParameters
Input function parameters that are stored for reference.
bool m_inputParameterPhysical
Flag to show whether the input profile parameters are physical to all peaks.
const std::string category() const override
Algorithm's category for identification overriding a virtual method.
FunctionMode m_fitMode
Fit mode.
std::map< std::string, Parameter > m_funcParameters
Function parameters updated by fit.
LeBailFunction_sptr m_lebailFunction
Le Bail Function (Composite)
std::vector< double > m_backgroundParameters
Background polynomials.
std::vector< double > m_bkgdParameterBuffer
std::vector< std::string > m_bkgdParameterNames
std::vector< double > m_bestBkgdParams
int mPeakRadius
Peak Radius.
double m_indicatePeakHeight
const std::string summary() const override
Summary of algorithms purpose.
int version() const override
Algorithm's version for identification overriding a virtual method.
double m_dampingFactor
Damping factor.
double m_minimumPeakHeight
Minimum height of a peak to be counted in smoothing background.
DataObjects::Workspace2D_sptr m_outputWS
std::map< int, std::vector< std::string > > m_MCGroups
bool m_useAnnealing
Flag to use Annealing Simulation (i.e., use automatic adjusted temperature)
const std::vector< std::string > seeAlso() const override
Function to return all of the seeAlso (these are not validated) algorithms related to this algorithm....
API::MatrixWorkspace_sptr m_dataWS
Instance data.
size_t m_numMinimizeSteps
Number of minimization steps. For both MC and regular.
double m_lebailFitChi2
Fit Chi^2.
std::map< std::string, Parameter > m_bestParameters
DataObjects::TableWorkspace_sptr parameterWS
std::vector< double > m_bestBackgroundData
double m_Temperature
Monte Carlo temperature.
std::vector< std::string > m_backgroundParameterNames
std::string m_backgroundType
Background type.
std::string m_peakType
============================= =========================== ///
const std::string name() const override
Algorithm's name for identification overriding a virtual method.
std::vector< double > m_bkgdParameterStepVec
size_t m_numberBkgdParameters
bool calculatePeaksIntensities(API::MatrixWorkspace_sptr dataws, size_t workspaceindex, bool zerobackground, std::vector< double > &allpeaksvalues)
Calcualte peak heights from model to data.
DataObjects::TableWorkspace_sptr reflectionWS
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
std::shared_ptr< LeBailFunction > LeBailFunction_sptr
void writeRfactorsToFile(std::vector< double > vecX, std::vector< Kernel::Rfactor > vecR, const std::string &filename)
Write a set of (XY) data to a column file.
std::shared_ptr< BackgroundFunction > BackgroundFunction_sptr
std::shared_ptr< Workspace2D > Workspace2D_sptr
shared pointer to Mantid::DataObjects::Workspace2D
std::shared_ptr< TableWorkspace > TableWorkspace_sptr
shared pointer to Mantid::DataObjects::TableWorkspace
Helper class which provides the Collimation Length for SANS instruments.
LeBailFit : Algorithm to do Le Bail Fit.
R factor for powder data analysis.