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 MDAlgorithms {
26
28 std::vector<Kernel::V3D> E1Vectors;
32 double peakRadius;
34};
35
52 std::unordered_map<int64_t, std::vector<std::pair<std::pair<double, double>, Mantid::Kernel::V3D>>>;
53using PeakQMap = std::unordered_map<int64_t, Mantid::Kernel::V3D>;
54
55class MANTID_MDALGORITHMS_DLL Integrate3DEvents {
56public:
58 Integrate3DEvents(const std::vector<std::pair<std::pair<double, double>, Mantid::Kernel::V3D>> &peak_q_list,
59 Kernel::DblMatrix UBinv, double radius, const bool useOnePercentBackgroundCorrection = true);
60
61 Integrate3DEvents(const std::vector<std::pair<std::pair<double, double>, Mantid::Kernel::V3D>> &peak_q_list,
62 std::vector<Mantid::Kernel::V3D> const &hkl_list, std::vector<Mantid::Kernel::V3D> const &mnp_list,
63 Kernel::DblMatrix UBinv, Kernel::DblMatrix ModHKL, double radius_m, double radius_s, int MaxO,
64 const bool CrossT, const bool useOnePercentBackgroundCorrection = true);
65
67 void addEvents(std::vector<std::pair<std::pair<double, double>, Mantid::Kernel::V3D>> const &event_qs,
68 bool hkl_integ);
69
71 std::shared_ptr<const Mantid::Geometry::PeakShape>
72 ellipseIntegrateEvents(const std::vector<Kernel::V3D> &E1Vec, Mantid::Kernel::V3D const &peak_q, bool specify_size,
73 double peak_radius, double back_inner_radius, double back_outer_radius,
74 DataObjects::PeakEllipsoidExtent &axes_radii, double &inti, double &sigi);
75
78 std::shared_ptr<const Mantid::Geometry::PeakShape>
79 ellipseIntegrateModEvents(const std::vector<Kernel::V3D> &E1Vec, Mantid::Kernel::V3D const &peak_q,
80 Mantid::Kernel::V3D const &hkl, Mantid::Kernel::V3D const &mnp, bool specify_size,
81 double peak_radius, double back_inner_radius, double back_outer_radius,
82 DataObjects::PeakEllipsoidExtent &axes_radii, double &inti, double &sigi);
83
85 std::pair<std::shared_ptr<const Mantid::Geometry::PeakShape>, std::tuple<double, double, double>>
86 integrateStrongPeak(const IntegrationParameters &params, const Kernel::V3D &peak_q, double &inti, double &sigi);
87
88 std::shared_ptr<const Geometry::PeakShape> integrateWeakPeak(const IntegrationParameters &params,
90 const std::tuple<double, double, double> &libPeak,
91 const Mantid::Kernel::V3D &peak_q, double &inti,
92 double &sigi);
93
94 double estimateSignalToNoiseRatio(const IntegrationParameters &params, const Mantid::Kernel::V3D &center,
95 bool forceSpherical = false, double sphericityTol = 0.02);
96
97private:
99 const std::vector<std::pair<std::pair<double, double>, Mantid::Kernel::V3D>> *
100 getEvents(const Mantid::Kernel::V3D &peak_q);
101
102 bool correctForDetectorEdges(std::tuple<double, double, double> &radii,
103 const std::vector<Mantid::Kernel::V3D> &E1Vecs, const Mantid::Kernel::V3D &peak_q,
104 const DataObjects::PeakEllipsoidExtent &axesRadii,
105 const DataObjects::PeakEllipsoidExtent &bkgInnerRadii,
106 const DataObjects::PeakEllipsoidExtent &bkgOuterRadii);
107
109 static std::pair<double, double>
110 numInEllipsoid(std::vector<std::pair<std::pair<double, double>, Mantid::Kernel::V3D>> const &events,
112
114 static std::pair<double, double>
115 numInEllipsoidBkg(std::vector<std::pair<std::pair<double, double>, Mantid::Kernel::V3D>> const &events,
117 DataObjects::PeakEllipsoidExtent const &sizesIn, const bool useOnePercentBackgroundCorrection);
118
120 static void makeCovarianceMatrix(std::vector<std::pair<std::pair<double, double>, Mantid::Kernel::V3D>> const &events,
121 Kernel::DblMatrix &matrix, double radius);
122
124 static void getEigenVectors(Kernel::DblMatrix const &cov_matrix, std::array<Mantid::Kernel::V3D, 3> &eigen_vectors,
126
128 static int64_t getHklKey(int h, int k, int l);
129
130 static int64_t getHklMnpKey(int h, int k, int l, int m, int n, int p);
131
133 int64_t getHklKey(Mantid::Kernel::V3D const &q_vector);
134 int64_t getHklMnpKey(Mantid::Kernel::V3D const &q_vector);
135 int64_t getHklKey2(Mantid::Kernel::V3D const &hkl);
136 int64_t getHklMnpKey2(Mantid::Kernel::V3D const &hkl);
137
139 void addEvent(std::pair<std::pair<double, double>, Mantid::Kernel::V3D> event_Q, bool hkl_integ);
140 void addModEvent(std::pair<std::pair<double, double>, Mantid::Kernel::V3D> event_Q, bool hkl_integ);
141
144 ellipseIntegrateEvents(const std::vector<Kernel::V3D> &E1Vec, Kernel::V3D const &peak_q,
145 std::vector<std::pair<std::pair<double, double>, Kernel::V3D>> const &ev_list,
146 DataObjects::PeakEllipsoidFrame const &directions, std::array<double, 3> const &sigmas,
147 bool specify_size, double peak_radius, double back_inner_radius, double back_outer_radius,
148 DataObjects::PeakEllipsoidExtent &axes_radii, double &inti, double &sigi);
149
151 double detectorQ(const std::vector<Kernel::V3D> &E1Vec, const Mantid::Kernel::V3D &QLabFrame,
153
154 std::tuple<double, double, double> calculateRadiusFactors(const IntegrationParameters &params,
155 double max_sigma) const;
156
157 // Private data members
158
159 PeakQMap m_peak_qs; // hashtable with peak Q-vectors
160 EventListMap m_event_lists; // hashtable with lists of events for each peak
161 Kernel::DblMatrix m_UBinv; // matrix mapping from Q to h,k,l
162 Kernel::DblMatrix m_ModHKL; // matrix mapping from Q to m,n,p
163 double m_radius; // size of sphere to use for events around a peak
164 double s_radius; // size of sphere to use for events around a peak
166 const bool crossterm;
167 const bool m_useOnePercentBackgroundCorrection =
168 true; // if one perecent culling of the background should be performed.
169};
170
171} // namespace MDAlgorithms
172
173} // namespace Mantid
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.