Mantid
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes | List of all members
Mantid::CurveFitting::Algorithms::LeBailFunction Class Reference

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 &paramname, 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 &paramname)
 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 &paramname, 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 > &parammap, 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_sptrm_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_sptrm_vecPeaks
 Vector of all peaks. More...
 

Detailed Description

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

Date
2013-04-26 : original LeBailFunction is not used by any other functions. And thus it is rewritten.

Definition at line 34 of file LeBailFunction.h.

Constructor & Destructor Documentation

◆ LeBailFunction()

Mantid::CurveFitting::Algorithms::LeBailFunction::LeBailFunction ( const std::string &  peaktype)

◆ ~LeBailFunction()

Mantid::CurveFitting::Algorithms::LeBailFunction::~LeBailFunction ( )
virtualdefault

Destructor.

Member Function Documentation

◆ addBackgroundFunction()

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

Parameters
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().

◆ addPeaks()

void Mantid::CurveFitting::Algorithms::LeBailFunction::addPeaks ( std::vector< std::vector< int > >  peakhkls)

Generate peaks, and add them to this composite function.

Parameters
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.

◆ calculateGroupPeakIntensities()

bool Mantid::CurveFitting::Algorithms::LeBailFunction::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 
)
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.

Parameters
peakgroupvector of peak-centre-dpsace value and peak function pair for peaks that are overlapped
vecXvector of X array
vecYvector for data with background removed.
vec_summedpeaks:: vector of summation of all peaks, i.e., output of sum_peaks
Returns
:: boolean whether the peaks' heights are physical

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().

◆ calculatePeakParameterValues()

void Mantid::CurveFitting::Algorithms::LeBailFunction::calculatePeakParameterValues ( ) const
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().

◆ calculatePeaksIntensities()

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.

Parameters
vecX:: vector for x values
vecY:: vector for data with background removed
vec_summedpeaksoutput 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().

◆ calPeak()

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.

◆ calPeaksParameters()

void Mantid::CurveFitting::Algorithms::LeBailFunction::calPeaksParameters ( )

Force to make all peaks to calculate peak parameters.

◆ fixBackgroundParameters()

void Mantid::CurveFitting::Algorithms::LeBailFunction::fixBackgroundParameters ( )

Fix all background parameters.

Definition at line 905 of file LeBailFunction.cpp.

References m_background.

◆ fixPeakParameter()

void Mantid::CurveFitting::Algorithms::LeBailFunction::fixPeakParameter ( const std::string &  paramname,
double  paramvalue 
)

Set up a parameter to be fixed.

Parameters
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.

◆ function()

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.

Parameters
xvalues:: input vector
calpeaks:: if true, calculate peaks
calbkgd:: if true, then calculate background and add to output. otherwise, assume zero background
Returns
:: output vector

Definition at line 104 of file LeBailFunction.cpp.

References Mantid::API::g_log, Mantid::Kernel::Logger::information(), m_background, m_numPeaks, and m_vecPeaks.

◆ generatePeak()

IPowderDiffPeakFunction_sptr Mantid::CurveFitting::Algorithms::LeBailFunction::generatePeak ( int  h,
int  k,
int  l 
)
private

Generate a peak with parameter set by.

Parameters
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().

◆ getFunction()

API::IFunction_sptr Mantid::CurveFitting::Algorithms::LeBailFunction::getFunction ( )

Return the composite function.

Definition at line 91 of file LeBailFunction.cpp.

References m_compsiteFunction.

◆ getNumberOfPeaks()

size_t Mantid::CurveFitting::Algorithms::LeBailFunction::getNumberOfPeaks ( ) const
inline

Get number of peaks.

Definition at line 70 of file LeBailFunction.h.

◆ getPeak()

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.

◆ getPeakMaximumValue()

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.

◆ getPeakParameter() [1/2]

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.

◆ getPeakParameter() [2/2]

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.

◆ getPeakParameterValue()

double Mantid::CurveFitting::Algorithms::LeBailFunction::getPeakParameterValue ( const API::IPowderDiffPeakFunction_sptr peak,
const std::string &  parname 
) const
private

Retrieve peak's parameter. may be native or calculated.

Retrieve peak's parameter.

may be native or calculated

Parameters
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().

◆ groupPeaks()

void Mantid::CurveFitting::Algorithms::LeBailFunction::groupPeaks ( std::vector< std::vector< std::pair< double, API::IPowderDiffPeakFunction_sptr > > > &  peakgroupvec,
std::vector< API::IPowderDiffPeakFunction_sptr > &  outboundpeakvec,
double  xmin,
double  xmax 
)
private

Group close peaks together.

Group peaks together.

Parameters
peakgroupvecoutput vector containing peaks grouped together.
outboundpeakvecoutput 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().

◆ hasProfileParameter()

bool Mantid::CurveFitting::Algorithms::LeBailFunction::hasProfileParameter ( const std::string &  paramname)

Check whether a parameter is a profile parameter.

Parameters
paramname:: parameter name to check with

Definition at line 161 of file LeBailFunction.cpp.

References m_orderedProfileParameterNames.

◆ isParameterValid()

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.

◆ setFitProfileParameter()

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.

Parameters
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.

◆ setFixPeakHeights()

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.

◆ setPeakCentreTolerance()

void Mantid::CurveFitting::Algorithms::LeBailFunction::setPeakCentreTolerance ( double  peakpostol,
double  tofmin,
double  tofmax 
)

Set peak position tolerance during importing/adding peaks.

Parameters
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.

◆ setPeakHeights()

void Mantid::CurveFitting::Algorithms::LeBailFunction::setPeakHeights ( const std::vector< double > &  inheights)

Function.

Reset all peaks' height.

Parameters
inheights:: list of peak heights corresponding to each peak

Definition at line 927 of file LeBailFunction.cpp.

References UNUSED_ARG.

◆ setPeakParameters()

void Mantid::CurveFitting::Algorithms::LeBailFunction::setPeakParameters ( const API::IPowderDiffPeakFunction_sptr peak,
const std::map< std::string, double > &  parammap,
double  peakheight,
bool  setpeakheight 
)
private

Set peak parameters.

From table/map to set parameters to an individual peak.

It mostly is called by function in calculation.

Parameters
peak: ThermalNeutronBk2BkExpConvPVoigt function to have parameters' value set
parammapmap of Parameters to set to peak
peakheightheight of the peak
setpeakheightboolean as the option to set peak height or not.

Definition at line 581 of file LeBailFunction.cpp.

References UNUSED_ARG.

◆ setProfileParameterValues()

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.

  1. store values to LeBailFunction;
  2. new values to each peak

Request: order of parameter names in m_peakParameterNameVec must be same as the order in IPowderDiffPeakFunction.

Parameters
parammapmap 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.

Member Data Documentation

◆ heights

std::vector<double> Mantid::CurveFitting::Algorithms::LeBailFunction::heights
private

Definition at line 166 of file LeBailFunction.h.

◆ m_background

Functions::BackgroundFunction_sptr Mantid::CurveFitting::Algorithms::LeBailFunction::m_background
private

Background function.

Definition at line 155 of file LeBailFunction.h.

Referenced by addBackgroundFunction(), fixBackgroundParameters(), and function().

◆ m_compsiteFunction

API::CompositeFunction_sptr Mantid::CurveFitting::Algorithms::LeBailFunction::m_compsiteFunction
private

Composite functions for all peaks and background.

Definition at line 153 of file LeBailFunction.h.

Referenced by fixPeakParameter(), getFunction(), LeBailFunction(), and setFitProfileParameter().

◆ m_dspPeakVec

std::vector<std::pair<double, API::IPowderDiffPeakFunction_sptr> > Mantid::CurveFitting::Algorithms::LeBailFunction::m_dspPeakVec
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().

◆ m_functionParameters

std::map<std::string, double> Mantid::CurveFitting::Algorithms::LeBailFunction::m_functionParameters
private

Parameters.

Definition at line 158 of file LeBailFunction.h.

Referenced by generatePeak(), LeBailFunction(), and setProfileParameterValues().

◆ m_hasNewPeakValue

bool Mantid::CurveFitting::Algorithms::LeBailFunction::m_hasNewPeakValue
mutableprivate

Has new peak values.

Definition at line 161 of file LeBailFunction.h.

Referenced by calculatePeakParameterValues(), isParameterValid(), LeBailFunction(), and setProfileParameterValues().

◆ m_isInputValue

bool Mantid::CurveFitting::Algorithms::LeBailFunction::m_isInputValue
private

Has first value set up.

Definition at line 164 of file LeBailFunction.h.

Referenced by addPeaks(), LeBailFunction(), and setProfileParameterValues().

◆ m_mapHKLPeak

std::map<std::vector<int>, API::IPowderDiffPeakFunction_sptr> Mantid::CurveFitting::Algorithms::LeBailFunction::m_mapHKLPeak
private

Vector of all peak's Miller indexes.

Definition at line 150 of file LeBailFunction.h.

Referenced by addPeaks(), getPeakMaximumValue(), and getPeakParameter().

◆ m_maxTOFPeakCentre

double Mantid::CurveFitting::Algorithms::LeBailFunction::m_maxTOFPeakCentre
private

Definition at line 169 of file LeBailFunction.h.

Referenced by addPeaks(), LeBailFunction(), and setPeakCentreTolerance().

◆ m_minTOFPeakCentre

double Mantid::CurveFitting::Algorithms::LeBailFunction::m_minTOFPeakCentre
private

Definition at line 168 of file LeBailFunction.h.

Referenced by addPeaks(), LeBailFunction(), and setPeakCentreTolerance().

◆ m_numPeaks

size_t Mantid::CurveFitting::Algorithms::LeBailFunction::m_numPeaks
private

◆ m_orderedProfileParameterNames

std::vector<std::string> Mantid::CurveFitting::Algorithms::LeBailFunction::m_orderedProfileParameterNames
private

Ordered profile parameter names for search.

Definition at line 143 of file LeBailFunction.h.

Referenced by getPeakParameterValue(), hasProfileParameter(), and LeBailFunction().

◆ m_peakParameterNameVec

std::vector<std::string> Mantid::CurveFitting::Algorithms::LeBailFunction::m_peakParameterNameVec
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().

◆ m_peakType

std::string Mantid::CurveFitting::Algorithms::LeBailFunction::m_peakType
private

Peak type.

Definition at line 134 of file LeBailFunction.h.

Referenced by generatePeak(), and LeBailFunction().

◆ m_vecPeaks

std::vector<API::IPowderDiffPeakFunction_sptr> Mantid::CurveFitting::Algorithms::LeBailFunction::m_vecPeaks
private

The documentation for this class was generated from the following files: