Mantid
Loading...
Searching...
No Matches
PeakStatisticsTools.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2018 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
9#include "MantidCrystal/DllConfig.h"
11
15
16#include "MantidKernel/V3D.h"
17
18namespace Mantid {
19namespace Crystal {
20namespace PeakStatisticsTools {
33class MANTID_CRYSTAL_DLL UniqueReflection {
34public:
35 UniqueReflection(const Kernel::V3D &hkl) : m_hkl(hkl), m_peaks() {}
36
37 const Kernel::V3D &getHKL() const { return m_hkl; }
38
39 void addPeak(const DataObjects::Peak &peak) { m_peaks.emplace_back(peak); }
40 const std::vector<DataObjects::Peak> &getPeaks() const { return m_peaks; }
41 size_t count() const { return m_peaks.size(); }
42
43 std::vector<double> getWavelengths() const;
44 std::vector<double> getIntensities() const;
45 std::vector<double> getSigmas() const;
46
47 UniqueReflection removeOutliers(double sigmaCritical = 3.0, bool weightedZ = false) const;
48 void setPeaksIntensityAndSigma(double intensity, double sigma);
49
50private:
52 std::vector<DataObjects::Peak> m_peaks;
53};
54
70class MANTID_CRYSTAL_DLL UniqueReflectionCollection {
71public:
72 UniqueReflectionCollection(const Geometry::UnitCell &cell, const std::pair<double, double> &dLimits,
74
76
77 void addObservations(const std::vector<DataObjects::Peak> &peaks);
78 UniqueReflection getReflection(const Kernel::V3D &hkl) const;
79
80 size_t getUniqueReflectionCount() const;
81 size_t getObservedUniqueReflectionCount(size_t moreThan = 0) const;
82 std::vector<Kernel::V3D> getUnobservedUniqueReflections() const;
83
84 size_t getObservedReflectionCount() const;
85
86 const std::map<Kernel::V3D, UniqueReflection> &getReflections() const;
87
88protected:
90 UniqueReflectionCollection(const std::map<Kernel::V3D, UniqueReflection> &reflections,
91 const Geometry::PointGroup_sptr &pointGroup)
92 : m_reflections(reflections), m_pointgroup(pointGroup) {}
93
94private:
95 std::map<Kernel::V3D, UniqueReflection> m_reflections;
97};
98
109class MANTID_CRYSTAL_DLL PeaksStatistics {
110public:
111 explicit PeaksStatistics(const UniqueReflectionCollection &reflections)
112 : m_measuredReflections(0), m_uniqueReflections(0), m_completeness(0.0), m_redundancy(0.0), m_rMerge(0.0),
113 m_rPim(0.0), m_meanIOverSigma(0.0), m_dspacingMin(0.0), m_dspacingMax(0.0), m_chiSquared(0.0), m_peaks() {
114 m_peaks.reserve(reflections.getObservedReflectionCount());
115 std::string equivalentIntensities = "Mean";
116 double sigmaCritical = 3.0;
117 bool weightedZ = false;
118 calculatePeaksStatistics(reflections.getReflections(), equivalentIntensities, sigmaCritical, weightedZ);
119 }
120 explicit PeaksStatistics(const UniqueReflectionCollection &reflections, std::string &equivalentIntensities,
121 double &sigmaCritical, bool &weightedZ)
122 : m_measuredReflections(0), m_uniqueReflections(0), m_completeness(0.0), m_redundancy(0.0), m_rMerge(0.0),
123 m_rPim(0.0), m_meanIOverSigma(0.0), m_dspacingMin(0.0), m_dspacingMax(0.0), m_chiSquared(0.0), m_peaks() {
124 m_peaks.reserve(reflections.getObservedReflectionCount());
125 calculatePeaksStatistics(reflections.getReflections(), equivalentIntensities, sigmaCritical, weightedZ);
126 }
127
131
135
139
142
146 double m_rMerge;
147
151 double m_rPim;
152
155
159
162
164 std::vector<DataObjects::Peak> m_peaks;
165
166private:
167 void calculatePeaksStatistics(const std::map<Kernel::V3D, UniqueReflection> &uniqueReflections,
168 std::string &equivalentIntensities, double &sigmaCritical, bool &weightedZ);
169
170 double getIOverSigmaSum(const std::vector<double> &sigmas, const std::vector<double> &intensities) const;
171 double getRMS(const std::vector<double> &data) const;
172
173 std::pair<double, double> getDSpacingLimits(const std::vector<DataObjects::Peak> &peaks) const;
174};
175
176} // namespace PeakStatisticsTools
177} // namespace Crystal
178} // namespace Mantid
double sigma
Definition: GetAllEi.cpp:156
The PeaksStatistics class is a small helper class that is used in SortHKL.
int m_measuredReflections
Total number of observed reflections - no symmetry is taken into account for this.
double m_meanIOverSigma
Average signal to noise ratio in the reflections.
double m_redundancy
Average number of observations for a unique reflection.
double m_dspacingMin
Lower d-spacing limit in the data set, sometimes referred to as upper resolution limit.
PeaksStatistics(const UniqueReflectionCollection &reflections, std::string &equivalentIntensities, double &sigmaCritical, bool &weightedZ)
double m_rPim
Precision indicating R-factor (R_{p.i.m}).
double m_completeness
Fraction of observed unique reflections in the resolution range defined by d_min and d_max.
double m_dspacingMax
Upper d-spacing limit in the data set.
PeaksStatistics(const UniqueReflectionCollection &reflections)
double m_rMerge
Merging R-factor, R_merge, sometimes also called R_sym.
This class computes all possible unique reflections within the specified d-limits,...
size_t getObservedReflectionCount() const
Number of observed reflections.
const std::map< Kernel::V3D, UniqueReflection > & getReflections() const
Returns the internally stored reflection map.
UniqueReflectionCollection(const std::map< Kernel::V3D, UniqueReflection > &reflections, const Geometry::PointGroup_sptr &pointGroup)
Alternative constructor for testing purposes, no validation is performed.
This class is a small helper for SortHKL to hold Peak-objects that belong to the same family of refle...
const std::vector< DataObjects::Peak > & getPeaks() const
Structure describing a single-crystal peak.
Definition: Peak.h:34
Class to implement unit cell of crystals.
Definition: UnitCell.h:44
Class for 3D vectors.
Definition: V3D.h:34
std::shared_ptr< ReflectionCondition > ReflectionCondition_sptr
Shared pointer to a ReflectionCondition.
std::shared_ptr< PointGroup > PointGroup_sptr
Shared pointer to a PointGroup.
Definition: PointGroup.h:67
Helper class which provides the Collimation Length for SANS instruments.