-
Notifications
You must be signed in to change notification settings - Fork 121
/
PoldiIndexKnownCompounds.h
170 lines (132 loc) · 6.19 KB
/
PoldiIndexKnownCompounds.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
#ifndef MANTID_SINQ_POLDIINDEXKNOWNCOMPOUNDS_H_
#define MANTID_SINQ_POLDIINDEXKNOWNCOMPOUNDS_H_
#include "MantidSINQ/DllConfig.h"
#include "MantidAPI/Algorithm.h"
#include "MantidSINQ/PoldiUtilities/PoldiPeakCollection.h"
namespace Mantid {
namespace Poldi {
/** IndexCandidatePair :
IndexCandidatePair is a small helper struct that holds a pointer
to a measured peak and a pointer to a candidate that may be a
suitable candidate for indexing. It also calculates a score
for this pair (see wiki for details).
*/
struct MANTID_SINQ_DLL IndexCandidatePair {
/// Default constructor
IndexCandidatePair()
: observed(), candidate(), positionMatch(0.0),
candidateCollectionIndex(0) {}
IndexCandidatePair(const PoldiPeak_sptr &measuredPeak,
const PoldiPeak_sptr &candidatePeak, size_t index);
/// Comparison operator, position matches are compared.
bool operator<(const IndexCandidatePair &other) const {
return positionMatch < other.positionMatch;
}
PoldiPeak_sptr observed;
PoldiPeak_sptr candidate;
double positionMatch;
size_t candidateCollectionIndex;
};
/** PoldiIndexKnownCompounds :
Algorithm that assigns Miller indices to measured peaks using
reflections of known structures present in the sample.
@author Michael Wedel, Paul Scherrer Institut - SINQ
@date 23/09/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 PoldiIndexKnownCompounds : public API::Algorithm {
public:
const std::string name() const override;
int version() const override;
const std::string category() const override;
const std::string summary() const override;
std::map<std::string, std::string> validateInputs() override;
void setMeasuredPeaks(const PoldiPeakCollection_sptr &measuredPeaks);
void setExpectedPhases(
const std::vector<PoldiPeakCollection_sptr> &expectedPhases);
void setExpectedPhaseNames(const std::vector<std::string> &phaseNames);
void initializeUnindexedPeaks();
void initializeIndexedPeaks(
const std::vector<PoldiPeakCollection_sptr> &expectedPhases);
static double fwhmToSigma(double fwhm);
static double sigmaToFwhm(double sigma);
protected:
// Workspace and name-handling
std::vector<API::Workspace_sptr>
getWorkspaces(const std::vector<std::string> &workspaceNames) const;
std::vector<PoldiPeakCollection_sptr>
getPeakCollections(const std::vector<API::Workspace_sptr> &workspaces) const;
std::vector<std::string>
getWorkspaceNames(const std::vector<API::Workspace_sptr> &workspaces) const;
// Input vector checks
std::vector<double> reshapeVector(const std::vector<double> &vector,
size_t size) const;
std::vector<double> getContributions(size_t size) const;
std::vector<double>
getNormalizedContributions(const std::vector<double> &contributions) const;
void scaleIntensityEstimates(
const std::vector<PoldiPeakCollection_sptr> &peakCollections,
const std::vector<double> &normalizedContributions) const;
void scaleIntensityEstimates(const PoldiPeakCollection_sptr &peakCollection,
double contribution) const;
void scaleToExperimentalValues(
const std::vector<PoldiPeakCollection_sptr> &peakCollections,
const PoldiPeakCollection_sptr &measuredPeaks) const;
double
getMaximumIntensity(const PoldiPeakCollection_sptr &peakCollection) const;
size_t getMaximumIntensityPeakIndex(
const PoldiPeakCollection_sptr &peakCollection) const;
std::vector<double> getTolerances(size_t size) const;
void assignFwhmEstimates(
const std::vector<PoldiPeakCollection_sptr> &peakCollections,
const std::vector<double> &tolerances) const;
void assignFwhmEstimates(const PoldiPeakCollection_sptr &peakCollection,
double tolerance) const;
// Indexing algorithm
void
indexPeaks(const PoldiPeakCollection_sptr &measured,
const std::vector<PoldiPeakCollection_sptr> &knownCompoundPeaks);
std::vector<IndexCandidatePair> getAllIndexCandidatePairs(
const PoldiPeakCollection_sptr &measured,
const std::vector<PoldiPeakCollection_sptr> &knownCompoundPeaks);
std::vector<IndexCandidatePair> getIndexCandidatePairs(
const PoldiPeak_sptr &peak,
const std::vector<PoldiPeakCollection_sptr> &candidateCollections) const;
bool isCandidate(const PoldiPeak_sptr &measuredPeak,
const PoldiPeak_sptr &possibleCandidate) const;
void collectUnindexedPeak(const PoldiPeak_sptr &unindexedPeak);
void assignCandidates(const std::vector<IndexCandidatePair> &candidates);
bool inPeakSet(const std::set<PoldiPeak_sptr> &peakSet,
const PoldiPeak_sptr &peak) const;
void assignPeakIndex(const IndexCandidatePair &candidate);
// Finalization
PoldiPeakCollection_sptr
getIntensitySortedPeakCollection(const PoldiPeakCollection_sptr &peaks) const;
void assignCrystalStructureParameters(
PoldiPeakCollection_sptr &indexedPeaks,
const PoldiPeakCollection_sptr &phasePeaks) const;
PoldiPeakCollection_sptr m_measuredPeaks;
std::vector<PoldiPeakCollection_sptr> m_expectedPhases;
std::vector<std::string> m_phaseNames;
PoldiPeakCollection_sptr m_unindexedPeaks;
std::vector<PoldiPeakCollection_sptr> m_indexedPeaks;
private:
void init() override;
void exec() override;
};
} // namespace Poldi
} // namespace Mantid
#endif /* MANTID_SINQ_POLDIINDEXKNOWNCOMPOUNDS_H_ */