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
15#include <span>
16
17namespace Mantid {
18namespace HistogramData {
19class HistogramX;
20class HistogramY;
21} // namespace HistogramData
22namespace CurveFitting {
23namespace Algorithms {
24
35class MANTID_CURVEFITTING_DLL LeBailFunction {
36public:
38 LeBailFunction(const std::string &peaktype);
39
41 virtual ~LeBailFunction();
42
44 void setProfileParameterValues(std::map<std::string, double> parammap);
45
47 void setFitProfileParameter(const std::string &paramname, double minvalue, double maxvalue);
48
50 void setPeakHeights(const std::vector<double> &inheights);
51
53 bool hasProfileParameter(const std::string &paramname);
54
57 bool isParameterValid(double maxfwhm = DBL_MAX) const;
58
60 void setPeakCentreTolerance(double peakpostol, double tofmin, double tofmax);
61
63 void addPeaks(const std::vector<std::vector<int>> &peakhkls);
64
66 void addBackgroundFunction(const std::string &backgroundtype, const unsigned int &order,
67 const std::vector<std::string> &vecparnames, const std::vector<double> &vecparvalues,
68 double startx, double endx);
69
71 size_t getNumberOfPeaks() const { return m_numPeaks; }
72
74 Mantid::HistogramData::HistogramY function(const Mantid::HistogramData::HistogramX &xvalues, bool calpeaks,
75 bool calbkgd) const;
76
78 Mantid::HistogramData::HistogramY calPeak(size_t ipk, std::span<double const> xvalues, size_t ySize) const;
79
81 API::IFunction_sptr getFunction();
82
84 API::IPowderDiffPeakFunction_sptr getPeak(size_t peakindex);
85
88
90 double getPeakParameter(size_t index, const std::string &parname) const;
91
93 double getPeakParameter(std::vector<int> hkl, const std::string &parname) const;
94
96 void fixPeakParameter(const std::string &paramname, double paramvalue);
97
99 void fixBackgroundParameters();
100
102 void setFixPeakHeights();
103
105 bool calculatePeaksIntensities(std::span<double const> vecX, std::span<double const> vecY,
106 std::vector<double> &vec_summedpeaks);
107
109 double getPeakMaximumValue(std::vector<int> hkl, const std::vector<double> &xvalues, size_t &ix);
110
111private:
113 void setPeakParameters(const API::IPowderDiffPeakFunction_sptr &peak, const std::map<std::string, double> &parammap,
114 double peakheight, bool setpeakheight);
115
117 double getPeakParameterValue(const API::IPowderDiffPeakFunction_sptr &peak, const std::string &parname) const;
118
120 void calculatePeakParameterValues() const;
121
123 API::IPowderDiffPeakFunction_sptr generatePeak(int h, int k, int l);
124
126 bool calculateGroupPeakIntensities(std::vector<std::pair<double, API::IPowderDiffPeakFunction_sptr>> peakgroup,
127 std::span<double const> vecX, std::span<double const> vecY,
128 std::vector<double> &vec_summedpeaks);
129
131 void groupPeaks(std::vector<std::vector<std::pair<double, API::IPowderDiffPeakFunction_sptr>>> &peakgroupvec,
132 std::vector<API::IPowderDiffPeakFunction_sptr> &outboundpeakvec, double xmin, double xmax);
133
135 std::string m_peakType;
136
139
142 std::vector<std::string> m_peakParameterNameVec;
144 std::vector<std::string> m_orderedProfileParameterNames;
145
147 std::vector<API::IPowderDiffPeakFunction_sptr> m_vecPeaks;
149 std::vector<std::pair<double, API::IPowderDiffPeakFunction_sptr>> m_dspPeakVec;
152
157
159 std::map<std::string, double> m_functionParameters;
160
162 mutable bool m_hasNewPeakValue;
163
166
167 std::vector<double> heights;
168
171 /*
172 double mL1;
173 double mL2;
174
175 mutable double Alph0, Alph1, Alph0t, Alph1t;
176 mutable double Beta0, Beta1, Beta0t, Beta1t;
177 mutable double Sig0, Sig1, Sig2, Gam0, Gam1, Gam2;
178 mutable double Dtt1, Dtt2, Dtt1t, Dtt2t, Zero, Zerot;
179
180 // void calPeakParametersForD(double dh, double& alpha, double& beta, double
181 &Tof_h, double &sigma_g2, double &gamma_l, std::map<std::string, double>&
182 parmap) const;
183 void adPeakPositionD(double dh);
184 double calCubicDSpace(double a, int h, int k, int l) const;
185 void addPeak(double d, double height);
186 mutable std::vector<double> dvalues;
188 mutable std::vector<std::map<std::string, double> > mPeakParameters;
189 */
190};
191
192using LeBailFunction_sptr = std::shared_ptr<LeBailFunction>;
193
194} // namespace Algorithms
195} // namespace CurveFitting
196} // 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:748
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.