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
21namespace Mantid {
22namespace Geometry {
23class PeakShape;
24}
25namespace DataObjects {
26class PeakShapeEllipsoid;
27}
28namespace MDAlgorithms {
29
31 std::vector<Kernel::V3D> E1Vectors;
35 double peakRadius;
37};
38
55 std::unordered_map<int64_t, std::vector<std::pair<std::pair<double, double>, Mantid::Kernel::V3D>>>;
56using PeakQMap = std::unordered_map<int64_t, Mantid::Kernel::V3D>;
57
58class MANTID_MDALGORITHMS_DLL Integrate3DEvents {
59public:
61 Integrate3DEvents(const std::vector<std::pair<std::pair<double, double>, Mantid::Kernel::V3D>> &peak_q_list,
62 Kernel::DblMatrix UBinv, double radius, const bool useOnePercentBackgroundCorrection = true);
63
64 Integrate3DEvents(const std::vector<std::pair<std::pair<double, double>, Mantid::Kernel::V3D>> &peak_q_list,
65 std::vector<Mantid::Kernel::V3D> const &hkl_list, std::vector<Mantid::Kernel::V3D> const &mnp_list,
66 Kernel::DblMatrix UBinv, Kernel::DblMatrix ModHKL, double radius_m, double radius_s, int MaxO,
67 const bool CrossT, const bool useOnePercentBackgroundCorrection = true);
68
70 void addEvents(std::vector<std::pair<std::pair<double, double>, Mantid::Kernel::V3D>> const &event_qs,
71 bool hkl_integ);
72
74 std::shared_ptr<const Mantid::Geometry::PeakShape>
75 ellipseIntegrateEvents(const std::vector<Kernel::V3D> &E1Vec, Mantid::Kernel::V3D const &peak_q, bool specify_size,
76 double peak_radius, double back_inner_radius, double back_outer_radius,
77 std::vector<double> &axes_radii, double &inti, double &sigi);
78
81 std::shared_ptr<const Mantid::Geometry::PeakShape>
82 ellipseIntegrateModEvents(const std::vector<Kernel::V3D> &E1Vec, Mantid::Kernel::V3D const &peak_q,
83 Mantid::Kernel::V3D const &hkl, Mantid::Kernel::V3D const &mnp, bool specify_size,
84 double peak_radius, double back_inner_radius, double back_outer_radius,
85 std::vector<double> &axes_radii, double &inti, double &sigi);
86
88 std::pair<std::shared_ptr<const Mantid::Geometry::PeakShape>, std::tuple<double, double, double>>
89 integrateStrongPeak(const IntegrationParameters &params, const Kernel::V3D &peak_q, double &inti, double &sigi);
90
91 std::shared_ptr<const Geometry::PeakShape> integrateWeakPeak(const IntegrationParameters &params,
93 const std::tuple<double, double, double> &libPeak,
94 const Mantid::Kernel::V3D &peak_q, double &inti,
95 double &sigi);
96
97 double estimateSignalToNoiseRatio(const IntegrationParameters &params, const Mantid::Kernel::V3D &center,
98 bool forceSpherical = false, double sphericityTol = 0.02);
99
100private:
102 const std::vector<std::pair<std::pair<double, double>, Mantid::Kernel::V3D>> *
103 getEvents(const Mantid::Kernel::V3D &peak_q);
104
105 bool correctForDetectorEdges(std::tuple<double, double, double> &radii,
106 const std::vector<Mantid::Kernel::V3D> &E1Vecs, const Mantid::Kernel::V3D &peak_q,
107 const std::vector<double> &axesRadii, const std::vector<double> &bkgInnerRadii,
108 const std::vector<double> &bkgOuterRadii);
109
111 static std::pair<double, double>
112 numInEllipsoid(std::vector<std::pair<std::pair<double, double>, Mantid::Kernel::V3D>> const &events,
113 std::vector<Mantid::Kernel::V3D> const &directions, std::vector<double> const &sizes);
114
116 static std::pair<double, double>
117 numInEllipsoidBkg(std::vector<std::pair<std::pair<double, double>, Mantid::Kernel::V3D>> const &events,
118 std::vector<Mantid::Kernel::V3D> const &directions, std::vector<double> const &sizes,
119 std::vector<double> const &sizesIn, const bool useOnePercentBackgroundCorrection);
120
122 static void makeCovarianceMatrix(std::vector<std::pair<std::pair<double, double>, Mantid::Kernel::V3D>> const &events,
123 Kernel::DblMatrix &matrix, double radius);
124
126 static void getEigenVectors(Kernel::DblMatrix const &cov_matrix, std::vector<Mantid::Kernel::V3D> &eigen_vectors,
127 std::vector<double> &eigen_values);
128
130 static int64_t getHklKey(int h, int k, int l);
131
132 static int64_t getHklMnpKey(int h, int k, int l, int m, int n, int p);
133
135 int64_t getHklKey(Mantid::Kernel::V3D const &q_vector);
136 int64_t getHklMnpKey(Mantid::Kernel::V3D const &q_vector);
137 int64_t getHklKey2(Mantid::Kernel::V3D const &hkl);
138 int64_t getHklMnpKey2(Mantid::Kernel::V3D const &hkl);
139
141 void addEvent(std::pair<std::pair<double, double>, Mantid::Kernel::V3D> event_Q, bool hkl_integ);
142 void addModEvent(std::pair<std::pair<double, double>, Mantid::Kernel::V3D> event_Q, bool hkl_integ);
143
145 std::shared_ptr<const Mantid::DataObjects::PeakShapeEllipsoid>
146 ellipseIntegrateEvents(const std::vector<Kernel::V3D> &E1Vec, Kernel::V3D const &peak_q,
147 std::vector<std::pair<std::pair<double, double>, Mantid::Kernel::V3D>> const &ev_list,
148 std::vector<Mantid::Kernel::V3D> const &directions, std::vector<double> const &sigmas,
149 bool specify_size, double peak_radius, double back_inner_radius, double back_outer_radius,
150 std::vector<double> &axes_radii, double &inti, double &sigi);
151
153 double detectorQ(const std::vector<Kernel::V3D> &E1Vec, const Mantid::Kernel::V3D &QLabFrame,
154 const std::vector<double> &r);
155
156 std::tuple<double, double, double> calculateRadiusFactors(const IntegrationParameters &params,
157 double max_sigma) const;
158
159 // Private data members
160
161 PeakQMap m_peak_qs; // hashtable with peak Q-vectors
162 EventListMap m_event_lists; // hashtable with lists of events for each peak
163 Kernel::DblMatrix m_UBinv; // matrix mapping from Q to h,k,l
164 Kernel::DblMatrix m_ModHKL; // matrix mapping from Q to m,n,p
165 double m_radius; // size of sphere to use for events around a peak
166 double s_radius; // size of sphere to use for events around a peak
168 const bool crossterm;
169 const bool m_useOnePercentBackgroundCorrection =
170 true; // if one perecent culling of the background should be performed.
171};
172
173} // namespace MDAlgorithms
174
175} // namespace Mantid
double radius
Definition: Rasterize.cpp:31
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::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.