-
Notifications
You must be signed in to change notification settings - Fork 122
/
PoldiFitPeaks2D.h
161 lines (122 loc) · 5.67 KB
/
PoldiFitPeaks2D.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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
// 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 "MantidAPI/IFunction.h"
#include "MantidAPI/IPeakFunction.h"
#include "MantidGeometry/Crystal/PointGroup.h"
#include "MantidKernel/System.h"
#include "MantidSINQ/DllConfig.h"
#include "MantidKernel/Matrix.h"
#include "MantidDataObjects/TableWorkspace.h"
#include "MantidSINQ/PoldiUtilities/Poldi2DFunction.h"
#include "MantidSINQ/PoldiUtilities/PoldiPeakCollection.h"
#include "MantidSINQ/PoldiUtilities/PoldiTimeTransformer.h"
namespace Mantid {
namespace Poldi {
/** PoldiFitPeaks2D
An Algorithm to fit a POLDI 2D-spectrum from a given table containing POLDI
peak data. A MatrixWorkspace containing a proper POLDI instrument definition
is required
to determine output workspace dimensions etc.
In order to use the algorithm for calculating a theoretical spectrum,
the MaximumIterations property can be set to 0.
@author Michael Wedel, Paul Scherrer Institut - SINQ
@date 16/05/2014
*/
class MANTID_SINQ_DLL PoldiFitPeaks2D : public API::Algorithm {
public:
const std::string name() const override;
int version() const override;
const std::vector<std::string> seeAlso() const override {
return {"PoldiFitPeaks1D"};
}
const std::string category() const override;
const std::string summary() const override;
std::map<std::string, std::string> validateInputs() override;
bool checkGroups() override { return false; }
protected:
// Workspace handling
std::vector<PoldiPeakCollection_sptr> getPeakCollectionsFromInput() const;
PoldiPeakCollection_sptr
getPeakCollection(const DataObjects::TableWorkspace_sptr &peakTable) const;
// Peak integration and transformations
std::vector<PoldiPeakCollection_sptr> getNormalizedPeakCollections(
const std::vector<PoldiPeakCollection_sptr> &peakCollections) const;
PoldiPeakCollection_sptr getIntegratedPeakCollection(
const PoldiPeakCollection_sptr &rawPeakCollection) const;
PoldiPeakCollection_sptr getNormalizedPeakCollection(
const PoldiPeakCollection_sptr &peakCollection) const;
std::vector<PoldiPeakCollection_sptr>
getCountPeakCollections(const API::IFunction_sptr &fitFunction);
PoldiPeakCollection_sptr
getCountPeakCollection(const PoldiPeakCollection_sptr &peakCollection) const;
// Conversion between peaks and functions
PoldiPeak_sptr
getPeakFromPeakFunction(const API::IPeakFunction_sptr &profileFunction,
const Kernel::V3D &hkl);
// Conversion between peak collections and functions
Poldi2DFunction_sptr
getFunctionFromPeakCollection(const PoldiPeakCollection_sptr &peakCollection);
Poldi2DFunction_sptr getFunctionIndividualPeaks(
const std::string &profileFunctionName,
const PoldiPeakCollection_sptr &peakCollection) const;
Poldi2DFunction_sptr
getFunctionPawley(const std::string &profileFunctionName,
const PoldiPeakCollection_sptr &peakCollection);
std::string getLatticeSystemFromPointGroup(
const Geometry::PointGroup_sptr &pointGroup) const;
std::string
getRefinedStartingCell(const std::string &initialCell,
const std::string &latticeSystem,
const PoldiPeakCollection_sptr &peakCollection);
std::string getUserSpecifiedTies(const API::IFunction_sptr &poldiFn);
PoldiPeakCollection_sptr
getPeakCollectionFromFunction(const API::IFunction_sptr &fitFunction);
void assignMillerIndices(const PoldiPeakCollection_sptr &from,
PoldiPeakCollection_sptr &to) const;
void assignCrystalData(PoldiPeakCollection_sptr &normalizedPeakCollection,
const PoldiPeakCollection_sptr &peakCollection) const;
// Extraction of 1D spectrum and cell
API::MatrixWorkspace_sptr
get1DSpectrum(const API::IFunction_sptr &fitFunction,
const API::MatrixWorkspace_sptr &workspace) const;
API::MatrixWorkspace_sptr
getQSpectrum(const API::FunctionDomain1D &domain,
const API::FunctionValues &values) const;
API::ITableWorkspace_sptr
getRefinedCellParameters(const API::IFunction_sptr &fitFunction) const;
// Interacting with Fit
API::IAlgorithm_sptr calculateSpectrum(
const std::vector<PoldiPeakCollection_sptr> &peakCollections,
const API::MatrixWorkspace_sptr &matrixWorkspace);
API::MatrixWorkspace_sptr
getWorkspace(const API::IAlgorithm_sptr &fitAlgorithm) const;
API::IFunction_sptr
getFunction(const API::IAlgorithm_sptr &fitAlgorithm) const;
void addBackgroundTerms(const Poldi2DFunction_sptr &poldi2DFunction) const;
std::shared_ptr<Kernel::DblMatrix> getLocalCovarianceMatrix(
const std::shared_ptr<const Kernel::DblMatrix> &covarianceMatrix,
size_t parameterOffset, size_t nParams) const;
// Poldi instrument book-keeping
void setPoldiInstrument(const PoldiInstrumentAdapter_sptr &instrument);
void setTimeTransformerFromInstrument(
const PoldiInstrumentAdapter_sptr &poldiInstrument);
void
setTimeTransformer(const PoldiTimeTransformer_sptr &poldiTimeTransformer);
void setDeltaTFromWorkspace(const API::MatrixWorkspace_sptr &matrixWorkspace);
void setDeltaT(double newDeltaT);
bool isValidDeltaT(double deltaT) const;
PoldiInstrumentAdapter_sptr m_poldiInstrument;
PoldiTimeTransformer_sptr m_timeTransformer;
double m_deltaT{0.0};
private:
void init() override;
void exec() override;
};
} // namespace Poldi
} // namespace Mantid