Mantid
Loading...
Searching...
No Matches
Integrate3DEvents.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2012 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
11#include "MantidKernel/Matrix.h"
12#include "MantidKernel/V3D.h"
13#include "MantidMDAlgorithms/DllConfig.h"
14
15#include <memory>
16
17#include <tuple>
18#include <unordered_map>
19#include <vector>
20
32namespace Mantid {
33namespace Geometry {
34class PeakShape;
35}
36namespace MDAlgorithms {
37
45 std::vector<Kernel::V3D> E1Vectors;
48 double regionRadius;
49 double peakRadius;
51};
52
69 std::unordered_map<int64_t, std::vector<std::pair<std::pair<double, double>, Mantid::Kernel::V3D>>>;
70using PeakQMap = std::unordered_map<int64_t, Mantid::Kernel::V3D>;
71
72class MANTID_MDALGORITHMS_DLL Integrate3DEvents {
73public:
75 Integrate3DEvents(const std::vector<std::pair<std::pair<double, double>, Mantid::Kernel::V3D>> &peak_q_list,
76 Kernel::DblMatrix UBinv, double radius, const bool useOnePercentBackgroundCorrection = true);
77
78 Integrate3DEvents(const std::vector<std::pair<std::pair<double, double>, Mantid::Kernel::V3D>> &peak_q_list,
79 std::vector<Mantid::Kernel::V3D> const &hkl_list, std::vector<Mantid::Kernel::V3D> const &mnp_list,
80 Kernel::DblMatrix UBinv, Kernel::DblMatrix ModHKL, double radius_m, double radius_s, int MaxO,
81 const bool CrossT, const bool useOnePercentBackgroundCorrection = true);
82
84 void addEvents(std::vector<std::pair<std::pair<double, double>, Mantid::Kernel::V3D>> const &event_qs,
85 bool hkl_integ);
86
88 std::shared_ptr<const Mantid::Geometry::PeakShape>
89 ellipseIntegrateEvents(const std::vector<Kernel::V3D> &E1Vec, Mantid::Kernel::V3D const &peak_q, bool specify_size,
90 double peak_radius, double back_inner_radius, double back_outer_radius,
91 DataObjects::PeakEllipsoidExtent &axes_radii, double &inti, double &sigi);
92
95 std::shared_ptr<const Mantid::Geometry::PeakShape>
96 ellipseIntegrateModEvents(const std::vector<Kernel::V3D> &E1Vec, Mantid::Kernel::V3D const &peak_q,
97 Mantid::Kernel::V3D const &hkl, Mantid::Kernel::V3D const &mnp, bool specify_size,
98 double peak_radius, double back_inner_radius, double back_outer_radius,
99 DataObjects::PeakEllipsoidExtent &axes_radii, double &inti, double &sigi);
100
103 std::pair<std::shared_ptr<const Mantid::Geometry::PeakShape>, std::tuple<double, double, double>>
104 integrateStrongPeak(const IntegrationParameters &params, const Kernel::V3D &peak_q, double &inti, double &sigi);
105
108 std::shared_ptr<const Geometry::PeakShape> integrateWeakPeak(const IntegrationParameters &params,
110 const std::tuple<double, double, double> &libPeak,
111 const Mantid::Kernel::V3D &peak_q, double &inti,
112 double &sigi);
113
117 void integrateUsingShape(const Mantid::DataObjects::PeakShapeEllipsoid &shape, const Mantid::Kernel::V3D &peak_q,
118 double &inti, double &sigi);
119
135 void integrateUsingShapeProfileFit(const Mantid::DataObjects::PeakShapeEllipsoid &shape,
136 const Mantid::Kernel::V3D &peak_q, bool adjustCenter, Mantid::Kernel::V3D &center,
137 double &inti, double &sigi);
138
141 double estimateSignalToNoiseRatio(const IntegrationParameters &params, const Mantid::Kernel::V3D &center,
142 bool forceSpherical = false, double sphericityTol = 0.02);
143
144private:
146 const std::vector<std::pair<std::pair<double, double>, Mantid::Kernel::V3D>> *
147 getEvents(const Mantid::Kernel::V3D &peak_q);
148
151 bool correctForDetectorEdges(std::tuple<double, double, double> &radii,
152 const std::vector<Mantid::Kernel::V3D> &E1Vecs, const Mantid::Kernel::V3D &peak_q,
153 const DataObjects::PeakEllipsoidExtent &axesRadii,
154 const DataObjects::PeakEllipsoidExtent &bkgInnerRadii,
155 const DataObjects::PeakEllipsoidExtent &bkgOuterRadii);
156
158 static std::pair<double, double>
159 numInEllipsoid(std::vector<std::pair<std::pair<double, double>, Mantid::Kernel::V3D>> const &events,
161
163 static std::pair<double, double>
164 numInEllipsoidBkg(std::vector<std::pair<std::pair<double, double>, Mantid::Kernel::V3D>> const &events,
166 DataObjects::PeakEllipsoidExtent const &sizesIn, const bool useOnePercentBackgroundCorrection);
167
169 static void makeCovarianceMatrix(std::vector<std::pair<std::pair<double, double>, Mantid::Kernel::V3D>> const &events,
170 Kernel::DblMatrix &matrix, double radius);
171
173 static void getEigenVectors(Kernel::DblMatrix const &cov_matrix, std::array<Mantid::Kernel::V3D, 3> &eigen_vectors,
175
177 static int64_t getHklKey(int h, int k, int l);
178
179 static int64_t getHklMnpKey(int h, int k, int l, int m, int n, int p);
180
182 int64_t getHklKey(Mantid::Kernel::V3D const &q_vector);
183 int64_t getHklMnpKey(Mantid::Kernel::V3D const &q_vector);
184 int64_t getHklKey2(Mantid::Kernel::V3D const &hkl);
185 int64_t getHklMnpKey2(Mantid::Kernel::V3D const &hkl);
186
188 void addEvent(std::pair<std::pair<double, double>, Mantid::Kernel::V3D> event_Q, bool hkl_integ);
189 void addModEvent(std::pair<std::pair<double, double>, Mantid::Kernel::V3D> event_Q, bool hkl_integ);
190
193 ellipseIntegrateEvents(const std::vector<Kernel::V3D> &E1Vec, Kernel::V3D const &peak_q,
194 std::vector<std::pair<std::pair<double, double>, Kernel::V3D>> const &ev_list,
195 DataObjects::PeakEllipsoidFrame const &directions, std::array<double, 3> const &sigmas,
196 bool specify_size, double peak_radius, double back_inner_radius, double back_outer_radius,
197 DataObjects::PeakEllipsoidExtent &axes_radii, double &inti, double &sigi);
198
200 double detectorQ(const std::vector<Kernel::V3D> &E1Vec, const Mantid::Kernel::V3D &QLabFrame,
202
203 std::tuple<double, double, double> calculateRadiusFactors(const IntegrationParameters &params,
204 double max_sigma) const;
205
206 // Private data members
207
208 PeakQMap m_peak_qs; // hashtable with peak Q-vectors
209 EventListMap m_event_lists; // hashtable with lists of events for each peak
210 Kernel::DblMatrix m_UBinv; // matrix mapping from Q to h,k,l
211 Kernel::DblMatrix m_ModHKL; // matrix mapping from Q to m,n,p
212 double m_radius; // size of sphere to use for events around a peak
213 double s_radius; // size of sphere to use for events around a peak
215 const bool crossterm;
216 const bool m_useOnePercentBackgroundCorrection =
217 true; // if one perecent culling of the background should be performed.
218};
219
220} // namespace MDAlgorithms
221
222} // namespace Mantid
PeakShapeEllipsoid : PeakShape representing a 3D ellipsoid.
Class for 3D vectors.
Definition V3D.h:34
This is a low-level class to construct a map with lists of events near each peak Q-vector,...
std::array< Kernel::V3D, PEAK_ELLIPSOID_DIMS > PeakEllipsoidFrame
std::array< double, PEAK_ELLIPSOID_DIMS > PeakEllipsoidExtent
std::shared_ptr< const PeakShapeEllipsoid > PeakShapeEllipsoid_const_sptr
std::unordered_map< int64_t, Mantid::Kernel::V3D > PeakQMap
std::unordered_map< int64_t, std::vector< std::pair< std::pair< double, double >, Mantid::Kernel::V3D > > > EventListMap
Helper class which provides the Collimation Length for SANS instruments.
Parameters for controlling peak integration.
double backgroundOuterRadius
Outer radius of background shell.
double peakRadius
Radius of peak ellipsoid.
bool specifySize
If true, use specified sizes; if false, use data-driven sizes.
double backgroundInnerRadius
Inner radius of background shell.
std::vector< Kernel::V3D > E1Vectors
Vectors for calculating detector edges.
double regionRadius
Radius of region to search for events.