Mantid
|
LeBailFunction : LeBailFunction is to calculate peak intensities in a composite function including neutron peak and background functions. More...
#include <LeBailFunction.h>
Public Member Functions | |
void | addBackgroundFunction (const std::string &backgroundtype, const unsigned int &order, const std::vector< std::string > &vecparnames, const std::vector< double > &vecparvalues, double startx, double endx) |
Add background function. More... | |
void | addPeaks (std::vector< std::vector< int > > peakhkls) |
Generate peaks, and add them to this composite function. More... | |
bool | calculatePeaksIntensities (const std::vector< double > &vecX, const std::vector< double > &vecY, std::vector< double > &vec_summedpeaks) |
Calculate peak intensities by Le Bail algorithm. More... | |
Mantid::HistogramData::HistogramY | calPeak (size_t ipk, const std::vector< double > &xvalues, size_t ySize) const |
Calculate a single peak's value. More... | |
void | calPeaksParameters () |
Force to make all peaks to calculate peak parameters. More... | |
void | fixBackgroundParameters () |
Fix all background parameters. More... | |
void | fixPeakParameter (const std::string ¶mname, double paramvalue) |
Set up a parameter to be fixed. More... | |
Mantid::HistogramData::HistogramY | function (const Mantid::HistogramData::HistogramX &xvalues, bool calpeaks, bool calbkgd) const |
Calculate. More... | |
API::IFunction_sptr | getFunction () |
Return the composite function. More... | |
size_t | getNumberOfPeaks () const |
Get number of peaks. More... | |
API::IPowderDiffPeakFunction_sptr | getPeak (size_t peakindex) |
Get reference to a peak. More... | |
double | getPeakMaximumValue (std::vector< int > hkl, const std::vector< double > &xvalues, size_t &ix) |
Get the maximum value of a peak in a given set of data points. More... | |
double | getPeakParameter (size_t index, const std::string &parname) const |
Get peak parameters (calculated) More... | |
double | getPeakParameter (std::vector< int > hkl, const std::string &parname) const |
Get peak parameters (calculated) More... | |
bool | hasProfileParameter (const std::string ¶mname) |
Check whether a parameter is a profile parameter. More... | |
bool | isParameterValid (double maxfwhm=DBL_MAX) const |
Check whether the newly set parameters are correct, i.e., all peaks are physical. More... | |
LeBailFunction (const std::string &peaktype) | |
Constructor. More... | |
void | setFitProfileParameter (const std::string ¶mname, double minvalue, double maxvalue) |
Set up a parameter to fit but tied among all peaks. More... | |
void | setFixPeakHeights () |
Fix all peaks' intensity/height. More... | |
void | setPeakCentreTolerance (double peakpostol, double tofmin, double tofmax) |
Set peak position tolerance during importing/adding peaks. More... | |
void | setPeakHeights (const std::vector< double > &inheights) |
Function. More... | |
void | setProfileParameterValues (std::map< std::string, double > parammap) |
From table/map to set parameters to all peaks. More... | |
virtual | ~LeBailFunction () |
Destructor. More... | |
Private Member Functions | |
bool | calculateGroupPeakIntensities (std::vector< std::pair< double, API::IPowderDiffPeakFunction_sptr > > peakgroup, const std::vector< double > &vecX, const std::vector< double > &vecY, std::vector< double > &vec_summedpeaks) |
Calculate the peaks intensities in same group. More... | |
void | calculatePeakParameterValues () const |
Calculate all peaks' parameter value. More... | |
API::IPowderDiffPeakFunction_sptr | generatePeak (int h, int k, int l) |
Generate a peak with parameter set by. More... | |
double | getPeakParameterValue (const API::IPowderDiffPeakFunction_sptr &peak, const std::string &parname) const |
Retrieve peak's parameter. may be native or calculated. More... | |
void | groupPeaks (std::vector< std::vector< std::pair< double, API::IPowderDiffPeakFunction_sptr > > > &peakgroupvec, std::vector< API::IPowderDiffPeakFunction_sptr > &outboundpeakvec, double xmin, double xmax) |
Group close peaks together. More... | |
void | setPeakParameters (const API::IPowderDiffPeakFunction_sptr &peak, const std::map< std::string, double > ¶mmap, double peakheight, bool setpeakheight) |
Set peak parameters. More... | |
Private Attributes | |
std::vector< double > | heights |
Functions::BackgroundFunction_sptr | m_background |
Background function. More... | |
API::CompositeFunction_sptr | m_compsiteFunction |
Composite functions for all peaks and background. More... | |
std::vector< std::pair< double, API::IPowderDiffPeakFunction_sptr > > | m_dspPeakVec |
Vector of pair <peak position in d-space, Peak> sortable. More... | |
std::map< std::string, double > | m_functionParameters |
Parameters. More... | |
bool | m_hasNewPeakValue |
Has new peak values. More... | |
bool | m_isInputValue |
Has first value set up. More... | |
std::map< std::vector< int >, API::IPowderDiffPeakFunction_sptr > | m_mapHKLPeak |
Vector of all peak's Miller indexes. More... | |
double | m_maxTOFPeakCentre |
double | m_minTOFPeakCentre |
size_t | m_numPeaks |
Number of peaks. More... | |
std::vector< std::string > | m_orderedProfileParameterNames |
Ordered profile parameter names for search. More... | |
std::vector< std::string > | m_peakParameterNameVec |
Name of peak parameter names (be same as the order in IPowderDiffPeakFunction) More... | |
std::string | m_peakType |
Peak type. More... | |
std::vector< API::IPowderDiffPeakFunction_sptr > | m_vecPeaks |
Vector of all peaks. More... | |
LeBailFunction : LeBailFunction is to calculate peak intensities in a composite function including neutron peak and background functions.
Note: This is not a Mantid Fit Function, just a helper class to the algorithm
Definition at line 34 of file LeBailFunction.h.
Mantid::CurveFitting::Algorithms::LeBailFunction::LeBailFunction | ( | const std::string & | peaktype | ) |
Constructor.
Definition at line 44 of file LeBailFunction.cpp.
References Mantid::Kernel::SingletonHolder< T >::Instance(), m_compsiteFunction, m_functionParameters, m_hasNewPeakValue, m_isInputValue, m_maxTOFPeakCentre, m_minTOFPeakCentre, m_numPeaks, m_orderedProfileParameterNames, m_peakParameterNameVec, and m_peakType.
|
virtualdefault |
Destructor.
void Mantid::CurveFitting::Algorithms::LeBailFunction::addBackgroundFunction | ( | const std::string & | backgroundtype, |
const unsigned int & | order, | ||
const std::vector< std::string > & | vecparnames, | ||
const std::vector< double > & | vecparvalues, | ||
double | startx, | ||
double | endx | ||
) |
Add background function.
The supported background types are Polynomial/Linear/Flat and Chebyshev
backgroundtype | :: string, type of background, such as Polynomial, Chebyshev |
order | :: polynomial order for the background |
vecparnames | :: vector of parameter names |
vecparvalues | :: vector of parameter values from order 0. |
startx | :: background's StartX. Used by Chebyshev |
endx | :: background's EndX. Used by Chebyshev |
Definition at line 805 of file LeBailFunction.cpp.
References Mantid::API::g_log, Mantid::Kernel::Logger::information(), Mantid::Kernel::SingletonHolder< T >::Instance(), m_background, and Mantid::Kernel::Logger::warning().
void Mantid::CurveFitting::Algorithms::LeBailFunction::addPeaks | ( | std::vector< std::vector< int > > | peakhkls | ) |
Generate peaks, and add them to this composite function.
peakhkls | :: list of Miller indexes (HKL) |
Definition at line 239 of file LeBailFunction.cpp.
References Mantid::Kernel::Logger::error(), Mantid::API::g_log, generatePeak(), Mantid::Kernel::Logger::information(), m_dspPeakVec, m_isInputValue, m_mapHKLPeak, m_maxTOFPeakCentre, m_minTOFPeakCentre, m_numPeaks, and m_vecPeaks.
|
private |
Calculate the peaks intensities in same group.
Calculate peak's intensities in a group and set the calculated peak height to the corresponding peak function.
peakgroup | vector of peak-centre-dpsace value and peak function pair for peaks that are overlapped |
vecX | vector of X array |
vecY | vector for data with background removed. |
vec_summedpeaks | :: vector of summation of all peaks, i.e., output of sum_peaks |
Definition at line 367 of file LeBailFunction.cpp.
References Mantid::Kernel::Logger::debug(), Mantid::Kernel::Logger::error(), Mantid::API::g_log, Mantid::Kernel::Logger::information(), and Mantid::Kernel::Logger::warning().
Referenced by calculatePeaksIntensities().
|
private |
Calculate all peaks' parameter value.
Definition at line 214 of file LeBailFunction.cpp.
References m_hasNewPeakValue, m_numPeaks, and m_vecPeaks.
Referenced by isParameterValid().
bool Mantid::CurveFitting::Algorithms::LeBailFunction::calculatePeaksIntensities | ( | const std::vector< double > & | vecX, |
const std::vector< double > & | vecY, | ||
std::vector< double > & | vec_summedpeaks | ||
) |
Calculate peak intensities by Le Bail algorithm.
Calculate peak heights from the model to the observed data Algorithm will deal with (1) Peaks are close enough to overlap with each other The procedure will be (a) Assign peaks into groups; each group contains either (1) one peak or (2) peaks overlapped (b) Calculate peak intensities for every peak per group.
vecX | :: vector for x values |
vecY | :: vector for data with background removed |
vec_summedpeaks | output vector storing peaks' values calculated |
Return: True if all peaks' height are physical. False otherwise
Definition at line 324 of file LeBailFunction.cpp.
References calculateGroupPeakIntensities(), Mantid::Kernel::Logger::debug(), Mantid::API::g_log, and groupPeaks().
HistogramY Mantid::CurveFitting::Algorithms::LeBailFunction::calPeak | ( | size_t | ipk, |
const std::vector< double > & | xvalues, | ||
size_t | ySize | ||
) | const |
Calculate a single peak's value.
Definition at line 142 of file LeBailFunction.cpp.
References Mantid::Kernel::Logger::error(), Mantid::API::g_log, m_numPeaks, and m_vecPeaks.
void Mantid::CurveFitting::Algorithms::LeBailFunction::calPeaksParameters | ( | ) |
Force to make all peaks to calculate peak parameters.
void Mantid::CurveFitting::Algorithms::LeBailFunction::fixBackgroundParameters | ( | ) |
Fix all background parameters.
Definition at line 905 of file LeBailFunction.cpp.
References m_background.
void Mantid::CurveFitting::Algorithms::LeBailFunction::fixPeakParameter | ( | const std::string & | paramname, |
double | paramvalue | ||
) |
Set up a parameter to be fixed.
paramname | :: name of parameter |
paramvalue | :: value of parameter to be fixed to |
Definition at line 880 of file LeBailFunction.cpp.
References Mantid::Kernel::Logger::debug(), Mantid::API::g_log, m_compsiteFunction, and m_numPeaks.
HistogramY Mantid::CurveFitting::Algorithms::LeBailFunction::function | ( | const Mantid::HistogramData::HistogramX & | xvalues, |
bool | calpeaks, | ||
bool | calbkgd | ||
) | const |
Calculate.
Calculate powder diffraction pattern by Le Bail algorithm.
xvalues | :: input vector |
calpeaks | :: if true, calculate peaks |
calbkgd | :: if true, then calculate background and add to output. otherwise, assume zero background |
Definition at line 104 of file LeBailFunction.cpp.
References Mantid::API::g_log, Mantid::Kernel::Logger::information(), m_background, m_numPeaks, and m_vecPeaks.
|
private |
Generate a peak with parameter set by.
h | :: H |
k | :: K |
l | :: L |
Definition at line 296 of file LeBailFunction.cpp.
References Mantid::Kernel::SingletonHolder< T >::Instance(), m_functionParameters, m_peakParameterNameVec, and m_peakType.
Referenced by addPeaks().
API::IFunction_sptr Mantid::CurveFitting::Algorithms::LeBailFunction::getFunction | ( | ) |
Return the composite function.
Definition at line 91 of file LeBailFunction.cpp.
References m_compsiteFunction.
|
inline |
Get number of peaks.
Definition at line 70 of file LeBailFunction.h.
IPowderDiffPeakFunction_sptr Mantid::CurveFitting::Algorithms::LeBailFunction::getPeak | ( | size_t | peakindex | ) |
Get reference to a peak.
Get the reference to a peak.
Definition at line 948 of file LeBailFunction.cpp.
References Mantid::Kernel::Logger::error(), Mantid::API::g_log, m_numPeaks, and m_vecPeaks.
double Mantid::CurveFitting::Algorithms::LeBailFunction::getPeakMaximumValue | ( | std::vector< int > | hkl, |
const std::vector< double > & | xvalues, | ||
size_t & | ix | ||
) |
Get the maximum value of a peak in a given set of data points.
Definition at line 1038 of file LeBailFunction.cpp.
References Mantid::Kernel::Logger::error(), Mantid::API::g_log, and m_mapHKLPeak.
double Mantid::CurveFitting::Algorithms::LeBailFunction::getPeakParameter | ( | size_t | index, |
const std::string & | parname | ||
) | const |
Get peak parameters (calculated)
Get value of one specific peak's parameter.
Definition at line 986 of file LeBailFunction.cpp.
References Mantid::Kernel::Logger::error(), Mantid::API::g_log, getPeakParameterValue(), index, m_numPeaks, m_vecPeaks, and value.
double Mantid::CurveFitting::Algorithms::LeBailFunction::getPeakParameter | ( | std::vector< int > | hkl, |
const std::string & | parname | ||
) | const |
Get peak parameters (calculated)
Get value of one specific peak's parameter.
Definition at line 964 of file LeBailFunction.cpp.
References Mantid::Kernel::Logger::error(), Mantid::API::g_log, getPeakParameterValue(), and m_mapHKLPeak.
|
private |
Retrieve peak's parameter. may be native or calculated.
Retrieve peak's parameter.
may be native or calculated
peak | :: shared pointer to peak function |
parname | :: name of the peak parameter |
Definition at line 1006 of file LeBailFunction.cpp.
References m_orderedProfileParameterNames.
Referenced by getPeakParameter().
|
private |
Group close peaks together.
Group peaks together.
peakgroupvec | output vector containing peaks grouped together. |
outboundpeakvec | output vector containing peaks out of bound range |
xmin | : minimim x value of the data |
xmax | : maximum x value of the data Disabled argument: MatrixWorkspace_sptr dataws, size_t workspaceindex, |
Definition at line 703 of file LeBailFunction.cpp.
References Mantid::Kernel::Logger::debug(), Mantid::Kernel::Logger::error(), Mantid::API::g_log, Mantid::Kernel::Logger::information(), m_dspPeakVec, and m_numPeaks.
Referenced by calculatePeaksIntensities().
bool Mantid::CurveFitting::Algorithms::LeBailFunction::hasProfileParameter | ( | const std::string & | paramname | ) |
Check whether a parameter is a profile parameter.
paramname | :: parameter name to check with |
Definition at line 161 of file LeBailFunction.cpp.
References m_orderedProfileParameterNames.
bool Mantid::CurveFitting::Algorithms::LeBailFunction::isParameterValid | ( | double | maxfwhm = DBL_MAX | ) | const |
Check whether the newly set parameters are correct, i.e., all peaks are physical.
Check whether the newly set parameters are correct, i.e., all peaks are physical This function would be used with setParameters() and etc.
Definition at line 183 of file LeBailFunction.cpp.
References calculatePeakParameterValues(), Mantid::API::g_log, Mantid::Kernel::Logger::information(), m_hasNewPeakValue, m_numPeaks, and m_vecPeaks.
void Mantid::CurveFitting::Algorithms::LeBailFunction::setFitProfileParameter | ( | const std::string & | paramname, |
double | minvalue, | ||
double | maxvalue | ||
) |
Set up a parameter to fit but tied among all peaks.
Set up a profile parameter to fit but tied among all peaks.
paramname | :: name of parameter |
minvalue | :: lower boundary |
maxvalue | :: upper boundary |
Definition at line 855 of file LeBailFunction.cpp.
References Mantid::Kernel::Logger::debug(), Mantid::API::g_log, m_compsiteFunction, and m_numPeaks.
void Mantid::CurveFitting::Algorithms::LeBailFunction::setFixPeakHeights | ( | ) |
Fix all peaks' intensity/height.
Definition at line 915 of file LeBailFunction.cpp.
References m_dspPeakVec, and m_numPeaks.
void Mantid::CurveFitting::Algorithms::LeBailFunction::setPeakCentreTolerance | ( | double | peakpostol, |
double | tofmin, | ||
double | tofmax | ||
) |
Set peak position tolerance during importing/adding peaks.
peakpostol | :: tolerance for peak position |
tofmin | :: minimum TOF for peak position |
tofmax | :: maximum TOF for peak position |
Definition at line 229 of file LeBailFunction.cpp.
References m_maxTOFPeakCentre, and m_minTOFPeakCentre.
void Mantid::CurveFitting::Algorithms::LeBailFunction::setPeakHeights | ( | const std::vector< double > & | inheights | ) |
Function.
Reset all peaks' height.
inheights | :: list of peak heights corresponding to each peak |
Definition at line 927 of file LeBailFunction.cpp.
References UNUSED_ARG.
|
private |
Set peak parameters.
From table/map to set parameters to an individual peak.
It mostly is called by function in calculation.
peak | : ThermalNeutronBk2BkExpConvPVoigt function to have parameters' value set |
parammap | map of Parameters to set to peak |
peakheight | height of the peak |
setpeakheight | boolean as the option to set peak height or not. |
Definition at line 581 of file LeBailFunction.cpp.
References UNUSED_ARG.
void Mantid::CurveFitting::Algorithms::LeBailFunction::setProfileParameterValues | ( | std::map< std::string, double > | parammap | ) |
From table/map to set parameters to all peaks.
From a parameter name/value map to.
Request: order of parameter names in m_peakParameterNameVec must be same as the order in IPowderDiffPeakFunction.
parammap | map of Parameters to set to peak |
Definition at line 641 of file LeBailFunction.cpp.
References Mantid::Kernel::Logger::debug(), Mantid::Kernel::Logger::error(), fabs, Mantid::API::g_log, m_functionParameters, m_hasNewPeakValue, m_isInputValue, m_numPeaks, m_peakParameterNameVec, and m_vecPeaks.
|
private |
Definition at line 166 of file LeBailFunction.h.
|
private |
Background function.
Definition at line 155 of file LeBailFunction.h.
Referenced by addBackgroundFunction(), fixBackgroundParameters(), and function().
|
private |
Composite functions for all peaks and background.
Definition at line 153 of file LeBailFunction.h.
Referenced by fixPeakParameter(), getFunction(), LeBailFunction(), and setFitProfileParameter().
|
private |
Vector of pair <peak position in d-space, Peak> sortable.
Definition at line 148 of file LeBailFunction.h.
Referenced by addPeaks(), groupPeaks(), and setFixPeakHeights().
|
private |
Parameters.
Definition at line 158 of file LeBailFunction.h.
Referenced by generatePeak(), LeBailFunction(), and setProfileParameterValues().
|
mutableprivate |
Has new peak values.
Definition at line 161 of file LeBailFunction.h.
Referenced by calculatePeakParameterValues(), isParameterValid(), LeBailFunction(), and setProfileParameterValues().
|
private |
Has first value set up.
Definition at line 164 of file LeBailFunction.h.
Referenced by addPeaks(), LeBailFunction(), and setProfileParameterValues().
|
private |
Vector of all peak's Miller indexes.
Definition at line 150 of file LeBailFunction.h.
Referenced by addPeaks(), getPeakMaximumValue(), and getPeakParameter().
|
private |
Definition at line 169 of file LeBailFunction.h.
Referenced by addPeaks(), LeBailFunction(), and setPeakCentreTolerance().
|
private |
Definition at line 168 of file LeBailFunction.h.
Referenced by addPeaks(), LeBailFunction(), and setPeakCentreTolerance().
|
private |
Number of peaks.
Definition at line 137 of file LeBailFunction.h.
Referenced by addPeaks(), calculatePeakParameterValues(), calPeak(), fixPeakParameter(), function(), getPeak(), getPeakParameter(), groupPeaks(), isParameterValid(), LeBailFunction(), setFitProfileParameter(), setFixPeakHeights(), and setProfileParameterValues().
|
private |
Ordered profile parameter names for search.
Definition at line 143 of file LeBailFunction.h.
Referenced by getPeakParameterValue(), hasProfileParameter(), and LeBailFunction().
|
private |
Name of peak parameter names (be same as the order in IPowderDiffPeakFunction)
Definition at line 141 of file LeBailFunction.h.
Referenced by generatePeak(), LeBailFunction(), and setProfileParameterValues().
|
private |
Peak type.
Definition at line 134 of file LeBailFunction.h.
Referenced by generatePeak(), and LeBailFunction().
|
private |
Vector of all peaks.
Definition at line 146 of file LeBailFunction.h.
Referenced by addPeaks(), calculatePeakParameterValues(), calPeak(), function(), getPeak(), getPeakParameter(), isParameterValid(), and setProfileParameterValues().