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#include "MantidKernel/System.h"
15
16namespace Mantid {
17namespace HistogramData {
18class HistogramX;
19class HistogramY;
20} // namespace HistogramData
21namespace CurveFitting {
22namespace Algorithms {
23
34class MANTID_CURVEFITTING_DLL LeBailFunction {
35public:
37 LeBailFunction(const std::string &peaktype);
38
40 virtual ~LeBailFunction();
41
43 void setProfileParameterValues(std::map<std::string, double> parammap);
44
46 void setFitProfileParameter(const std::string &paramname, double minvalue, double maxvalue);
47
49 void setPeakHeights(const std::vector<double> &inheights);
50
52 bool hasProfileParameter(const std::string &paramname);
53
56 bool isParameterValid(double maxfwhm = DBL_MAX) const;
57
59 void setPeakCentreTolerance(double peakpostol, double tofmin, double tofmax);
60
62 void addPeaks(std::vector<std::vector<int>> peakhkls);
63
65 void addBackgroundFunction(const std::string &backgroundtype, const unsigned int &order,
66 const std::vector<std::string> &vecparnames, const std::vector<double> &vecparvalues,
67 double startx, double endx);
68
70 size_t getNumberOfPeaks() const { return m_numPeaks; }
71
73 Mantid::HistogramData::HistogramY function(const Mantid::HistogramData::HistogramX &xvalues, bool calpeaks,
74 bool calbkgd) const;
75
77 Mantid::HistogramData::HistogramY calPeak(size_t ipk, const std::vector<double> &xvalues, size_t ySize) const;
78
80 API::IFunction_sptr getFunction();
81
83 API::IPowderDiffPeakFunction_sptr getPeak(size_t peakindex);
84
87
89 double getPeakParameter(size_t index, const std::string &parname) const;
90
92 double getPeakParameter(std::vector<int> hkl, const std::string &parname) const;
93
95 void fixPeakParameter(const std::string &paramname, double paramvalue);
96
98 void fixBackgroundParameters();
99
101 void setFixPeakHeights();
102
104 bool calculatePeaksIntensities(const std::vector<double> &vecX, const std::vector<double> &vecY,
105 std::vector<double> &vec_summedpeaks);
106
108 double getPeakMaximumValue(std::vector<int> hkl, const std::vector<double> &xvalues, size_t &ix);
109
110private:
112 void setPeakParameters(const API::IPowderDiffPeakFunction_sptr &peak, const std::map<std::string, double> &parammap,
113 double peakheight, bool setpeakheight);
114
116 double getPeakParameterValue(const API::IPowderDiffPeakFunction_sptr &peak, const std::string &parname) const;
117
119 void calculatePeakParameterValues() const;
120
122 API::IPowderDiffPeakFunction_sptr generatePeak(int h, int k, int l);
123
125 bool calculateGroupPeakIntensities(std::vector<std::pair<double, API::IPowderDiffPeakFunction_sptr>> peakgroup,
126 const std::vector<double> &vecX, const std::vector<double> &vecY,
127 std::vector<double> &vec_summedpeaks);
128
130 void groupPeaks(std::vector<std::vector<std::pair<double, API::IPowderDiffPeakFunction_sptr>>> &peakgroupvec,
131 std::vector<API::IPowderDiffPeakFunction_sptr> &outboundpeakvec, double xmin, double xmax);
132
134 std::string m_peakType;
135
138
141 std::vector<std::string> m_peakParameterNameVec;
143 std::vector<std::string> m_orderedProfileParameterNames;
144
146 std::vector<API::IPowderDiffPeakFunction_sptr> m_vecPeaks;
148 std::vector<std::pair<double, API::IPowderDiffPeakFunction_sptr>> m_dspPeakVec;
151
156
158 std::map<std::string, double> m_functionParameters;
159
161 mutable bool m_hasNewPeakValue;
162
165
166 std::vector<double> heights;
167
170 /*
171 double mL1;
172 double mL2;
173
174 mutable double Alph0, Alph1, Alph0t, Alph1t;
175 mutable double Beta0, Beta1, Beta0t, Beta1t;
176 mutable double Sig0, Sig1, Sig2, Gam0, Gam1, Gam2;
177 mutable double Dtt1, Dtt2, Dtt1t, Dtt2t, Zero, Zerot;
178
179 // void calPeakParametersForD(double dh, double& alpha, double& beta, double
180 &Tof_h, double &sigma_g2, double &gamma_l, std::map<std::string, double>&
181 parmap) const;
182 void adPeakPositionD(double dh);
183 double calCubicDSpace(double a, int h, int k, int l) const;
184 void addPeak(double d, double height);
185 mutable std::vector<double> dvalues;
187 mutable std::vector<std::map<std::string, double> > mPeakParameters;
188 */
189};
190
191using LeBailFunction_sptr = std::shared_ptr<LeBailFunction>;
192
193} // namespace Algorithms
194} // namespace CurveFitting
195} // namespace Mantid
std::map< DeltaEMode::Type, std::string > index
Definition: DeltaEMode.cpp:19
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:732
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.