-
Notifications
You must be signed in to change notification settings - Fork 122
/
PoldiFitPeaks2D.h
174 lines (128 loc) · 6.07 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
162
163
164
165
166
167
168
169
170
171
172
173
174
#ifndef MANTID_SINQ_POLDICALCULATESPECTRUM2D_H_
#define MANTID_SINQ_POLDICALCULATESPECTRUM2D_H_
#include "MantidKernel/System.h"
#include "MantidSINQ/DllConfig.h"
#include "MantidAPI/Algorithm.h"
#include "MantidAPI/IFunction.h"
#include "MantidAPI/IPeakFunction.h"
#include "MantidKernel/Matrix.h"
#include "MantidDataObjects/TableWorkspace.h"
#include "MantidSINQ/PoldiUtilities/PoldiPeakCollection.h"
#include "MantidSINQ/PoldiUtilities/PoldiTimeTransformer.h"
#include "MantidSINQ/PoldiUtilities/Poldi2DFunction.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
Copyright © 2014 PSI-MSS
This file is part of Mantid.
Mantid is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
Mantid is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
File change history is stored at: <https://github.com/mantidproject/mantid>
Code Documentation is available at: <http://doxygen.mantidproject.org>
*/
class MANTID_SINQ_DLL PoldiFitPeaks2D : public API::Algorithm {
public:
PoldiFitPeaks2D();
virtual ~PoldiFitPeaks2D();
virtual const std::string name() const;
virtual int version() const;
virtual const std::string category() const;
virtual const std::string summary() const;
std::map<std::string, std::string> validateInputs();
bool checkGroups() { 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(API::IPeakFunction_sptr profileFunction,
const Kernel::V3D &hkl);
// Conversion between peak collections and functions
Poldi2DFunction_sptr
getFunctionFromPeakCollection(const PoldiPeakCollection_sptr &peakCollection);
Poldi2DFunction_sptr getFunctionIndividualPeaks(
std::string profileFunctionName,
const PoldiPeakCollection_sptr &peakCollection) const;
Poldi2DFunction_sptr
getFunctionPawley(std::string profileFunctionName,
const PoldiPeakCollection_sptr &peakCollection);
std::string
getRefinedStartingCell(const std::string &initialCell,
const std::string &crystalSystem,
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(Poldi2DFunction_sptr poldi2DFunction) const;
boost::shared_ptr<Kernel::DblMatrix> getLocalCovarianceMatrix(
const boost::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;
private:
void init();
void exec();
};
} // namespace Poldi
} // namespace Mantid
#endif /* MANTID_SINQ_POLDICALCULATESPECTRUM2D_H_ */