Mantid
Loading...
Searching...
No Matches
LeBailFunction.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2012 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
7#pragma once
8
12#include "MantidCurveFitting/DllConfig.h"
14
15namespace Mantid {
16namespace HistogramData {
17class HistogramX;
18class HistogramY;
19} // namespace HistogramData
20namespace CurveFitting {
21namespace Algorithms {
22
33class MANTID_CURVEFITTING_DLL LeBailFunction {
34public:
36 LeBailFunction(const std::string &peaktype);
37
39 virtual ~LeBailFunction();
40
42 void setProfileParameterValues(std::map<std::string, double> parammap);
43
45 void setFitProfileParameter(const std::string &paramname, double minvalue, double maxvalue);
46
48 void setPeakHeights(const std::vector<double> &inheights);
49
51 bool hasProfileParameter(const std::string &paramname);
52
55 bool isParameterValid(double maxfwhm = DBL_MAX) const;
56
58 void setPeakCentreTolerance(double peakpostol, double tofmin, double tofmax);
59
61 void addPeaks(const std::vector<std::vector<int>> &peakhkls);
62
64 void addBackgroundFunction(const std::string &backgroundtype, const unsigned int &order,
65 const std::vector<std::string> &vecparnames, const std::vector<double> &vecparvalues,
66 double startx, double endx);
67
69 size_t getNumberOfPeaks() const { return m_numPeaks; }
70
72 Mantid::HistogramData::HistogramY function(const Mantid::HistogramData::HistogramX &xvalues, bool calpeaks,
73 bool calbkgd) const;
74
76 Mantid::HistogramData::HistogramY calPeak(size_t ipk, const std::vector<double> &xvalues, size_t ySize) const;
77
79 API::IFunction_sptr getFunction();
80
82 API::IPowderDiffPeakFunction_sptr getPeak(size_t peakindex);
83
86
88 double getPeakParameter(size_t index, const std::string &parname) const;
89
91 double getPeakParameter(std::vector<int> hkl, const std::string &parname) const;
92
94 void fixPeakParameter(const std::string &paramname, double paramvalue);
95
97 void fixBackgroundParameters();
98
100 void setFixPeakHeights();
101
103 bool calculatePeaksIntensities(const std::vector<double> &vecX, const std::vector<double> &vecY,
104 std::vector<double> &vec_summedpeaks);
105
107 double getPeakMaximumValue(std::vector<int> hkl, const std::vector<double> &xvalues, size_t &ix);
108
109private:
111 void setPeakParameters(const API::IPowderDiffPeakFunction_sptr &peak, const std::map<std::string, double> &parammap,
112 double peakheight, bool setpeakheight);
113
115 double getPeakParameterValue(const API::IPowderDiffPeakFunction_sptr &peak, const std::string &parname) const;
116
118 void calculatePeakParameterValues() const;
119
121 API::IPowderDiffPeakFunction_sptr generatePeak(int h, int k, int l);
122
124 bool calculateGroupPeakIntensities(std::vector<std::pair<double, API::IPowderDiffPeakFunction_sptr>> peakgroup,
125 const std::vector<double> &vecX, const std::vector<double> &vecY,
126 std::vector<double> &vec_summedpeaks);
127
129 void groupPeaks(std::vector<std::vector<std::pair<double, API::IPowderDiffPeakFunction_sptr>>> &peakgroupvec,
130 std::vector<API::IPowderDiffPeakFunction_sptr> &outboundpeakvec, double xmin, double xmax);
131
133 std::string m_peakType;
134
137
140 std::vector<std::string> m_peakParameterNameVec;
142 std::vector<std::string> m_orderedProfileParameterNames;
143
145 std::vector<API::IPowderDiffPeakFunction_sptr> m_vecPeaks;
147 std::vector<std::pair<double, API::IPowderDiffPeakFunction_sptr>> m_dspPeakVec;
150
155
157 std::map<std::string, double> m_functionParameters;
158
160 mutable bool m_hasNewPeakValue;
161
164
165 std::vector<double> heights;
166
169 /*
170 double mL1;
171 double mL2;
172
173 mutable double Alph0, Alph1, Alph0t, Alph1t;
174 mutable double Beta0, Beta1, Beta0t, Beta1t;
175 mutable double Sig0, Sig1, Sig2, Gam0, Gam1, Gam2;
176 mutable double Dtt1, Dtt2, Dtt1t, Dtt2t, Zero, Zerot;
177
178 // void calPeakParametersForD(double dh, double& alpha, double& beta, double
179 &Tof_h, double &sigma_g2, double &gamma_l, std::map<std::string, double>&
180 parmap) const;
181 void adPeakPositionD(double dh);
182 double calCubicDSpace(double a, int h, int k, int l) const;
183 void addPeak(double d, double height);
184 mutable std::vector<double> dvalues;
186 mutable std::vector<std::map<std::string, double> > mPeakParameters;
187 */
188};
189
190using LeBailFunction_sptr = std::shared_ptr<LeBailFunction>;
191
192} // namespace Algorithms
193} // namespace CurveFitting
194} // namespace Mantid
std::map< DeltaEMode::Type, std::string > index
LeBailFunction : LeBailFunction is to calculate peak intensities in a composite function including ne...
size_t getNumberOfPeaks() const
Get number of peaks.
std::vector< std::string > m_peakParameterNameVec
Name of peak parameter names (be same as the order in IPowderDiffPeakFunction)
void calPeaksParameters()
Force to make all peaks to calculate peak parameters.
std::vector< std::pair< double, API::IPowderDiffPeakFunction_sptr > > m_dspPeakVec
Vector of pair <peak position in d-space, Peak> sortable.
Functions::BackgroundFunction_sptr m_background
Background function.
std::vector< API::IPowderDiffPeakFunction_sptr > m_vecPeaks
Vector of all peaks.
API::CompositeFunction_sptr m_compsiteFunction
Composite functions for all peaks and background.
std::vector< std::string > m_orderedProfileParameterNames
Ordered profile parameter names for search.
std::map< std::vector< int >, API::IPowderDiffPeakFunction_sptr > m_mapHKLPeak
Vector of all peak's Miller indexes.
std::map< std::string, double > m_functionParameters
Parameters.
std::shared_ptr< IPowderDiffPeakFunction > IPowderDiffPeakFunction_sptr
std::shared_ptr< IFunction > IFunction_sptr
shared pointer to the function base class
Definition IFunction.h:743
std::shared_ptr< CompositeFunction > CompositeFunction_sptr
shared pointer to the composite function base class
std::shared_ptr< LeBailFunction > LeBailFunction_sptr
std::shared_ptr< BackgroundFunction > BackgroundFunction_sptr
Helper class which provides the Collimation Length for SANS instruments.