-
Notifications
You must be signed in to change notification settings - Fork 122
/
PoldiFitPeaks1D2.h
120 lines (86 loc) · 3.99 KB
/
PoldiFitPeaks1D2.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
// Mantid Repository : https://github.com/mantidproject/mantid
//
// Copyright © 2014 ISIS Rutherford Appleton Laboratory UKRI,
// NScD Oak Ridge National Laboratory, European Spallation Source,
// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
// SPDX - License - Identifier: GPL - 3.0 +
#pragma once
#include "MantidAPI/Algorithm.h"
#include "MantidKernel/System.h"
#include "MantidAPI/IPeakFunction.h"
#include "MantidAPI/TableRow.h"
#include "MantidAPI/WorkspaceGroup_fwd.h"
#include "MantidDataObjects/TableWorkspace.h"
#include "MantidDataObjects/Workspace2D.h"
#include "MantidSINQ/DllConfig.h"
#include "MantidSINQ/PoldiUtilities/PoldiPeakCollection.h"
namespace Mantid {
namespace Poldi {
/// Helper class for refining peaks with overlapping ranges
class MANTID_SINQ_DLL RefinedRange {
public:
RefinedRange(const PoldiPeak_sptr &peak, double fwhmMultiples);
RefinedRange(double xStart, double xEnd, std::vector<PoldiPeak_sptr> peaks);
double getWidth() const;
bool operator<(const RefinedRange &other) const;
bool overlaps(const RefinedRange &other) const;
bool overlaps(const RefinedRange &other, double fraction) const;
bool contains(const RefinedRange &other) const;
double getOverlapFraction(const RefinedRange &other) const;
void merge(const RefinedRange &other);
const std::vector<PoldiPeak_sptr> getPeaks() const { return m_peaks; }
double getXStart() const { return m_xStart; }
double getXEnd() const { return m_xEnd; }
private:
void setRangeBorders(double start, double end);
std::vector<PoldiPeak_sptr> m_peaks;
double m_xStart;
double m_xEnd;
double m_width;
};
using RefinedRange_sptr = std::shared_ptr<RefinedRange>;
bool MANTID_SINQ_DLL operator<(const RefinedRange_sptr &lhs, const RefinedRange_sptr &rhs);
/** PoldiFitPeaks1D2 :
PoldiFitPeaks1D2 fits multiple peaks to POLDI auto-correlation data.
@author Michael Wedel, Paul Scherrer Institut - SINQ
@date 17/03/2014
*/
class MANTID_SINQ_DLL PoldiFitPeaks1D2 : public API::Algorithm {
public:
PoldiFitPeaks1D2();
~PoldiFitPeaks1D2() = default;
const std::string name() const override;
/// Summary of algorithms purpose
const std::string summary() const override {
return "PoldiPeakFit1D fits peak profiles to POLDI auto-correlation data.";
}
int version() const override;
const std::vector<std::string> seeAlso() const override { return {"PoldiFitPeaks2D"}; }
const std::string category() const override;
protected:
PoldiPeakCollection_sptr fitPeaks(const PoldiPeakCollection_sptr &peaks);
int getBestChebyshevPolynomialDegree(const DataObjects::Workspace2D_sptr &dataWorkspace,
const RefinedRange_sptr &range);
PoldiPeakCollection_sptr getReducedPeakCollection(const PoldiPeakCollection_sptr &peaks) const;
bool peakIsAcceptable(const PoldiPeak_sptr &peak) const;
void setPeakFunction(const std::string &peakFunction);
PoldiPeakCollection_sptr getInitializedPeakCollection(const DataObjects::TableWorkspace_sptr &peakTable) const;
std::vector<RefinedRange_sptr> getRefinedRanges(const PoldiPeakCollection_sptr &peaks) const;
std::vector<RefinedRange_sptr> getReducedRanges(const std::vector<RefinedRange_sptr> &ranges) const;
API::IFunction_sptr getRangeProfile(const RefinedRange_sptr &range, int n) const;
API::IFunction_sptr getPeakProfile(const PoldiPeak_sptr &poldiPeak) const;
void setValuesFromProfileFunction(const PoldiPeak_sptr &poldiPeak, const API::IFunction_sptr &fittedFunction) const;
double getFwhmWidthRelation(const API::IPeakFunction_sptr &peakFunction) const;
API::IAlgorithm_sptr getFitAlgorithm(const DataObjects::Workspace2D_sptr &dataWorkspace,
const RefinedRange_sptr &range, int n);
PoldiPeakCollection_sptr m_peaks;
std::string m_profileTemplate;
API::WorkspaceGroup_sptr m_fitplots;
double m_fwhmMultiples;
double m_maxRelativeFwhm;
private:
void init() override;
void exec() override;
};
} // namespace Poldi
} // namespace Mantid