Mantid
Loading...
Searching...
No Matches
Functions
Mantid::CurveFitting::Functions::CrystalFieldUtils Namespace Reference

Functions

size_t buildSpectrumFunction (API::CompositeFunction &spectrum, const std::string &peakShape, const API::FunctionValues &centresAndIntensities, const std::vector< double > &xVec, const std::vector< double > &yVec, double fwhmVariation, double defaultFWHM, size_t nRequiredPeaks, bool fixAllPeaks)
 Utility functions to help set up peak functions in a Crystal Field spectrum. More...
 
size_t calculateMaxNPeaks (size_t nPeaks)
 Calculate the maximum number of peaks a spectrum can have. More...
 
size_t calculateNPeaks (const API::FunctionValues &centresAndIntensities)
 Calculate the number of visible peaks. More...
 
double calculateWidth (double x, const std::vector< double > &xVec, const std::vector< double > &yVec)
 Calculate the width of a peak cenrted at x using an interpolated value of a function tabulated at xVec points. More...
 
API::IPeakFunction_sptr createPeak (const std::string &peakShape, double centre, double intensity, const std::vector< double > &xVec, const std::vector< double > &yVec, double fwhmVariation, double defaultFWHM, bool isGood, bool fixAllPeaks)
 Create a single peak. More...
 
void ignorePeak (API::IPeakFunction &peak, double fwhm)
 Set peak's properties such that it was invisible in the spectrum. More...
 
void setPeakWidth (API::IPeakFunction &peak, double centre, const std::vector< double > &xVec, const std::vector< double > &yVec, double fwhmVariation, double defaultFWHM, bool useDefaultFWHM)
 Set the width of a peak. More...
 
void setWidthConstraint (API::IPeakFunction &peak, double fwhm, double fwhmVariation)
 Set a boundary constraint on the appropriate parameter of the peak. More...
 
void updatePeak (API::IPeakFunction &peak, double centre, double intensity, const std::vector< double > &xVec, const std::vector< double > &yVec, double fwhmVariation, bool isGood, bool fixAllPeaks)
 Update a single peak. More...
 
void updatePeakWidth (API::IPeakFunction &peak, double centre, const std::vector< double > &xVec, const std::vector< double > &yVec, double fwhmVariation)
 Update width of a peak. More...
 
size_t updateSpectrumFunction (API::CompositeFunction &spectrum, const std::string &peakShape, const FunctionValues &centresAndIntensities, size_t iFirst, const std::vector< double > &xVec, const std::vector< double > &yVec, double fwhmVariation, double defaultFWHM, bool fixAllPeaks)
 Update the peaks parameters after recalculationof the crystal field. More...
 

Function Documentation

◆ buildSpectrumFunction()

size_t Mantid::CurveFitting::Functions::CrystalFieldUtils::buildSpectrumFunction ( API::CompositeFunction spectrum,
const std::string &  peakShape,
const API::FunctionValues centresAndIntensities,
const std::vector< double > &  xVec,
const std::vector< double > &  yVec,
double  fwhmVariation,
double  defaultFWHM,
size_t  nRequiredPeaks,
bool  fixAllPeaks 
)

Utility functions to help set up peak functions in a Crystal Field spectrum.

Populates a spectrum with peaks of type given by peakShape argument.

Parameters
spectrum:: A composite function that is a collection of peaks.
peakShape:: A shape of each peak as a name of an IPeakFunction.
centresAndIntensities:: A FunctionValues object containing centres and intensities for the peaks. First nPeaks calculated values are the centres and the following nPeaks values are the intensities.
xVec:: x-values of a tabulated width function.
yVec:: y-values of a tabulated width function.
fwhmVariation:: A variation in the peak width allowed in a fit.
defaultFWHM:: A default value for the FWHM to use if xVec and yVec are empty.
nRequiredPeaks:: A number of peaks required to be created.
fixAllPeaks:: If true fix all peak parameters
Returns
:: The number of peaks that will be actually fitted.

Definition at line 173 of file CrystalFieldPeakUtils.cpp.

References Mantid::API::CompositeFunction::addFunction(), calculateMaxNPeaks(), calculateNPeaks(), createPeak(), and Mantid::API::FunctionValues::getCalculated().

Referenced by Mantid::CurveFitting::Functions::CrystalFieldFunction::buildMultiSiteSingleSpectrum(), Mantid::CurveFitting::Functions::CrystalFieldFunction::buildSingleSiteSingleSpectrum(), Mantid::CurveFitting::Functions::CrystalFieldMultiSpectrum::buildSpectrum(), Mantid::CurveFitting::Functions::CrystalFieldFunction::buildSpectrum(), and Mantid::CurveFitting::Functions::CrystalFieldSpectrum::buildTargetFunction().

◆ calculateMaxNPeaks()

size_t Mantid::CurveFitting::Functions::CrystalFieldUtils::calculateMaxNPeaks ( size_t  nPeaks)

Calculate the maximum number of peaks a spectrum can have.

Definition at line 87 of file CrystalFieldPeakUtils.cpp.

Referenced by buildSpectrumFunction(), and updateSpectrumFunction().

◆ calculateNPeaks()

size_t Mantid::CurveFitting::Functions::CrystalFieldUtils::calculateNPeaks ( const API::FunctionValues centresAndIntensities)

◆ calculateWidth()

double Mantid::CurveFitting::Functions::CrystalFieldUtils::calculateWidth ( double  x,
const std::vector< double > &  xVec,
const std::vector< double > &  yVec 
)

Calculate the width of a peak cenrted at x using an interpolated value of a function tabulated at xVec points.

Parameters
x:: Peak centre.
xVec:: x-values of a tabulated width function.
yVec:: y-values of a tabulated width function.

Definition at line 28 of file CrystalFieldPeakUtils.cpp.

References Mantid::Geometry::x.

Referenced by setPeakWidth(), and updatePeakWidth().

◆ createPeak()

API::IPeakFunction_sptr Mantid::CurveFitting::Functions::CrystalFieldUtils::createPeak ( const std::string &  peakShape,
double  centre,
double  intensity,
const std::vector< double > &  xVec,
const std::vector< double > &  yVec,
double  fwhmVariation,
double  defaultFWHM,
bool  isGood,
bool  fixAllPeaks 
)

Create a single peak.

Parameters
peakShape:: A shape of the of created peak as a name of an IPeakFunction.
centre:: Peak centre.
intensity:: Integrated intensity of the peak.
xVec:: x-values of a tabulated width function.
yVec:: y-values of a tabulated width function.
fwhmVariation:: A variation in the peak width allowed in a fit.
defaultFWHM:: A default value for the FWHM to use if xVec and yVec are empty.
isGood:: If the peak good and may have free fitting parameters.
fixAllPeaks:: If true all parameters should be fixed.

Definition at line 134 of file CrystalFieldPeakUtils.cpp.

References ignorePeak(), Mantid::Kernel::SingletonHolder< T >::Instance(), and setPeakWidth().

Referenced by buildSpectrumFunction(), and updateSpectrumFunction().

◆ ignorePeak()

void Mantid::CurveFitting::Functions::CrystalFieldUtils::ignorePeak ( API::IPeakFunction peak,
double  fwhm 
)
inline

Set peak's properties such that it was invisible in the spectrum.

Parameters
peak:: A peak function to set.
fwhm:: A width value to pass to the peak.

Definition at line 92 of file CrystalFieldPeakUtils.cpp.

References Mantid::API::IFunction::fixAll(), Mantid::API::IPeakFunction::setFwhm(), and Mantid::API::IFunctionWithLocation::setHeight().

Referenced by createPeak(), setPeakWidth(), and updatePeakWidth().

◆ setPeakWidth()

void Mantid::CurveFitting::Functions::CrystalFieldUtils::setPeakWidth ( API::IPeakFunction peak,
double  centre,
const std::vector< double > &  xVec,
const std::vector< double > &  yVec,
double  fwhmVariation,
double  defaultFWHM,
bool  useDefaultFWHM 
)

Set the width of a peak.

Parameters
peak:: A peak function to set width to.
centre:: Peak centre.
xVec:: x-values of a tabulated width function.
yVec:: y-values of a tabulated width function.
fwhmVariation:: A variation in the peak width allowed in a fit.
defaultFWHM:: A default value for the FWHM to use if xVec and yVec are empty.
useDefaultFWHM:: If true always use defaultFWHM for the width.

Definition at line 107 of file CrystalFieldPeakUtils.cpp.

References calculateWidth(), ignorePeak(), Mantid::API::IPeakFunction::setFwhm(), and setWidthConstraint().

Referenced by createPeak().

◆ setWidthConstraint()

void Mantid::CurveFitting::Functions::CrystalFieldUtils::setWidthConstraint ( API::IPeakFunction peak,
double  fwhm,
double  fwhmVariation 
)

Set a boundary constraint on the appropriate parameter of the peak.

Parameters
peak:: A peak function.
fwhm:: A width of the peak.
fwhmVariation:: A value by which the with can vary on both sides.

Definition at line 47 of file CrystalFieldPeakUtils.cpp.

References Mantid::API::IFunction::addConstraint(), Mantid::API::IFunction::fixParameter(), Mantid::API::IFunction::name(), and Mantid::API::IFunction::removeConstraint().

Referenced by setPeakWidth(), and updatePeakWidth().

◆ updatePeak()

void Mantid::CurveFitting::Functions::CrystalFieldUtils::updatePeak ( API::IPeakFunction peak,
double  centre,
double  intensity,
const std::vector< double > &  xVec,
const std::vector< double > &  yVec,
double  fwhmVariation,
bool  isGood,
bool  fixAllPeaks 
)

Update a single peak.

Parameters
peak:: A peak to update.
centre:: New peak centre.
intensity:: New integrated intensity.
xVec:: x-values of a tabulated width function.
yVec:: y-values of a tabulated width function.
fwhmVariation:: A variation in the peak width allowed in a fit.
isGood:: If the peak good and may have free fitting parameters.
fixAllPeaks:: If true all parameters should be fixed.

Definition at line 226 of file CrystalFieldPeakUtils.cpp.

References Mantid::API::IFunction::fixAll(), Mantid::API::IFunctionWithLocation::fixCentre(), Mantid::API::IPeakFunction::fixIntensity(), Mantid::API::IFunctionWithLocation::setCentre(), Mantid::API::IFunctionWithLocation::setHeight(), Mantid::API::IPeakFunction::setIntensity(), Mantid::API::IFunction::unfixAllDefault(), Mantid::API::IPeakFunction::unfixIntensity(), and updatePeakWidth().

Referenced by updateSpectrumFunction().

◆ updatePeakWidth()

void Mantid::CurveFitting::Functions::CrystalFieldUtils::updatePeakWidth ( API::IPeakFunction peak,
double  centre,
const std::vector< double > &  xVec,
const std::vector< double > &  yVec,
double  fwhmVariation 
)

Update width of a peak.

Parameters
peak:: A peak to update.
centre:: Peak centre.
xVec:: x-values of a tabulated width function.
yVec:: y-values of a tabulated width function.
fwhmVariation:: A variation in the peak width allowed in a fit.

Definition at line 202 of file CrystalFieldPeakUtils.cpp.

References calculateWidth(), fabs, Mantid::API::IPeakFunction::fwhm(), ignorePeak(), Mantid::API::IPeakFunction::setFwhm(), and setWidthConstraint().

Referenced by updatePeak().

◆ updateSpectrumFunction()

size_t Mantid::CurveFitting::Functions::CrystalFieldUtils::updateSpectrumFunction ( API::CompositeFunction spectrum,
const std::string &  peakShape,
const FunctionValues centresAndIntensities,
size_t  iFirst,
const std::vector< double > &  xVec,
const std::vector< double > &  yVec,
double  fwhmVariation,
double  defaultFWHM,
bool  fixAllPeaks 
)

Update the peaks parameters after recalculationof the crystal field.

Parameters
spectrum:: A composite function containings the peaks to update. May contain other functions (background) fix indices < iFirst.
peakShape:: A shape of each peak as a name of an IPeakFunction.
centresAndIntensities:: A FunctionValues object containing centres and intensities for the peaks. First nPeaks calculated values are the centres and the following nPeaks values are the intensities.
iFirst:: The first index in the composite function (spectrum) at which the peaks begin.
xVec:: x-values of a tabulated width function.
yVec:: y-values of a tabulated width function.
fwhmVariation:: A variation in the peak width allowed in a fit.
defaultFWHM:: A default value for the FWHM to use if xVec and yVec are empty.
fixAllPeaks:: If true fix all peak parameters
Returns
:: The new number of fitted peaks.

Definition at line 264 of file CrystalFieldPeakUtils.cpp.

References Mantid::API::CompositeFunction::addFunction(), calculateMaxNPeaks(), calculateNPeaks(), createPeak(), Mantid::API::IPeakFunction::fwhm(), Mantid::API::FunctionValues::getCalculated(), Mantid::API::CompositeFunction::getFunction(), Mantid::API::CompositeFunction::nFunctions(), and updatePeak().

Referenced by Mantid::CurveFitting::Functions::CrystalFieldFunction::updateMultiSiteSingleSpectrum(), Mantid::CurveFitting::Functions::CrystalFieldFunction::updateSingleSiteSingleSpectrum(), Mantid::CurveFitting::Functions::CrystalFieldMultiSpectrum::updateSpectrum(), Mantid::CurveFitting::Functions::CrystalFieldFunction::updateSpectrum(), and Mantid::CurveFitting::Functions::CrystalFieldSpectrum::updateTargetFunction().