12#include <boost/math/special_functions/round.hpp>
23#include <gsl/gsl_eigen.h>
24#include <gsl/gsl_matrix.h>
25#include <gsl/gsl_vector.h>
50 double radius,
const bool useOnePercentBackgroundCorrection)
51 : m_UBinv(
std::move(UBinv)), m_radius(radius),
maxOrder(0), crossterm(false),
52 m_useOnePercentBackgroundCorrection(useOnePercentBackgroundCorrection) {
53 for (
size_t it = 0; it != peak_q_list.size(); ++it) {
54 int64_t hkl_key =
getHklKey(peak_q_list[it].second);
56 m_peak_qs[hkl_key] = peak_q_list[it].second;
84 std::vector<V3D>
const &hkl_list, std::vector<V3D>
const &mnp_list,
Kernel::DblMatrix UBinv,
85 Kernel::DblMatrix ModHKL,
double radius_m,
double radius_s,
int MaxO,
const bool CrossT,
86 const bool useOnePercentBackgroundCorrection)
87 : m_UBinv(
std::move(UBinv)), m_ModHKL(
std::move(ModHKL)), m_radius(radius_m), s_radius(radius_s),
maxOrder(MaxO),
88 crossterm(CrossT), m_useOnePercentBackgroundCorrection(useOnePercentBackgroundCorrection) {
89 for (
size_t it = 0; it != peak_q_list.size(); ++it) {
91 getHklMnpKey(boost::math::iround<double>(hkl_list[it][0]), boost::math::iround<double>(hkl_list[it][1]),
92 boost::math::iround<double>(hkl_list[it][2]), boost::math::iround<double>(mnp_list[it][0]),
93 boost::math::iround<double>(mnp_list[it][1]), boost::math::iround<double>(mnp_list[it][2]));
95 m_peak_qs[hklmnp_key] = peak_q_list[it].second;
119 for (
const auto &event_q : event_qs)
122 for (
const auto &event_q : event_qs)
126std::pair<std::shared_ptr<const Geometry::PeakShape>, std::tuple<double, double, double>>
134 return std::make_pair(std::make_shared<NoShape>(), make_tuple(0., 0., 0.));
136 const auto &events = *result;
138 return std::make_pair(std::make_shared<NoShape>(), make_tuple(0., 0., 0.));
143 std::array<V3D, 3> eigen_vectors;
144 std::array<double, 3> eigen_values;
147 std::array<double, 3> sigmas;
148 for (
int i = 0; i < 3; i++) {
149 sigmas[i] = sqrt(eigen_values[i]);
153 std::any_of(sigmas.cbegin(), sigmas.cend(), [](
const double sigma) { return std::isnan(sigma) || sigma <= 0; });
156 return std::make_pair(std::make_shared<NoShape>(), make_tuple(0., 0., 0.));
158 const auto max_sigma = *std::max_element(sigmas.begin(), sigmas.end());
160 return std::make_pair(std::make_shared<NoShape>(), make_tuple(0., 0., 0.));
163 auto const &r1 = std::get<0>(rValues), r2 = std::get<1>(rValues), r3 = std::get<2>(rValues);
167 for (
int i = 0; i < 3; i++) {
168 abcBackgroundOuterRadii[i] = r3 * sigmas[i];
169 abcBackgroundInnerRadii[i] = r2 * sigmas[i];
170 peakRadii[i] = r1 * sigmas[i];
174 abcBackgroundInnerRadii, abcBackgroundOuterRadii);
176 if (!isPeakOnDetector)
177 return std::make_pair(std::make_shared<NoShape>(), make_tuple(0.0, 0.0, 0.));
179 const auto backgrd =
numInEllipsoidBkg(events, eigen_vectors, abcBackgroundOuterRadii, abcBackgroundInnerRadii,
182 const auto peak =
numInEllipsoid(events, eigen_vectors, peakRadii);
183 const auto ratio = pow(r1, 3) / (pow(r3, 3) - pow(r2, 3));
185 inti = peak.first - ratio * backgrd.first;
186 sigi = sqrt(peak.second + ratio * ratio * backgrd.second);
189 const auto total = (core.first + peak.first) - ratio * backgrd.first;
190 const auto frac = std::min(1.0, std::abs(inti / total));
192 const auto df_ds_core = (1 - frac) / peak.first;
193 const auto df_ds_peak = frac / peak.first;
194 const auto fracError = sqrt(peak.first * pow(df_ds_core, 2) + core.first * pow(df_ds_peak, 2));
197 const auto shape = std::make_shared<const PeakShapeEllipsoid>(eigen_vectors, peakRadii, abcBackgroundInnerRadii,
199 "IntegrateEllipsoidsTwoStep");
201 return std::make_pair(shape, std::make_tuple(frac, fracError, max_sigma));
204std::shared_ptr<const Geometry::PeakShape>
206 const std::tuple<double, double, double> &libPeak,
const V3D ¢er,
double &inti,
214 return std::make_shared<NoShape>();
216 const auto &events = *result;
218 const auto &directions = shape->directions();
219 auto abcBackgroundInnerRadii = shape->abcRadiiBackgroundInner();
220 auto abcBackgroundOuterRadii = shape->abcRadiiBackgroundOuter();
221 auto abcRadii = shape->abcRadii();
223 const auto max_sigma = std::get<2>(libPeak);
227 abcBackgroundInnerRadii, abcBackgroundOuterRadii);
229 if (!isPeakOnDetector)
232 const double r1 = std::get<0>(rValues), r2 = std::get<1>(rValues), r3 = std::get<2>(rValues);
235 std::pair<double, double> backgrd =
numInEllipsoidBkg(events, directions, abcBackgroundOuterRadii,
237 std::pair<double, double> peak_w_back =
numInEllipsoid(events, directions, abcRadii);
238 double ratio = pow(r1, 3) / (pow(r3, 3) - pow(r2, 3));
240 const auto frac = std::get<0>(libPeak);
241 const auto fracError = std::get<1>(libPeak);
243 inti = peak_w_back.first - ratio * backgrd.first;
246 sigi = sigi / pow(inti, 2);
247 sigi += pow((fracError / frac), 2);
250 sigi = sqrt(sigi) * inti;
253 for (
size_t i = 0; i < abcRadii.size(); ++i) {
255 abcBackgroundInnerRadii[i] *= frac;
256 abcBackgroundOuterRadii[i] *= frac;
259 return std::make_shared<const PeakShapeEllipsoid>(shape->directions(), abcRadii, abcBackgroundInnerRadii,
261 "IntegrateEllipsoidsTwoStep");
265 bool forceSpherical,
double sphericityTol) {
271 const auto &events = *result;
278 std::array<V3D, 3> eigen_vectors;
279 std::array<double, 3> eigen_values;
282 std::array<double, 3> sigmas;
283 for (
int i = 0; i < 3; i++) {
284 sigmas[i] = sqrt(eigen_values[i]);
287 const auto max_sigma = *std::max_element(sigmas.begin(), sigmas.end());
288 const auto min_sigma = *std::min_element(sigmas.begin(), sigmas.end());
293 auto const &r1 = std::get<0>(rValues), r2 = std::get<1>(rValues), r3 = std::get<2>(rValues);
296 if (forceSpherical) {
298 if ((max_sigma - min_sigma) / max_sigma > sphericityTol)
300 for (
int i = 0; i < 3; i++) {
301 abcBackgroundOuterRadii[i] = r3 * max_sigma;
302 abcBackgroundInnerRadii[i] = r2 * max_sigma;
303 peakRadii[i] = r1 * max_sigma;
306 for (
int i = 0; i < 3; i++) {
307 abcBackgroundOuterRadii[i] = r3 * sigmas[i];
308 abcBackgroundInnerRadii[i] = r2 * sigmas[i];
309 peakRadii[i] = r1 * sigmas[i];
314 std::pair<double, double> backgrd =
numInEllipsoidBkg(events, eigen_vectors, abcBackgroundOuterRadii,
317 std::pair<double, double> peak_w_back =
numInEllipsoid(events, eigen_vectors, peakRadii);
319 double ratio = pow(r1, 3) / (pow(r3, 3) - pow(r2, 3));
320 auto inti = peak_w_back.first - ratio * backgrd.first;
321 auto sigi = sqrt(peak_w_back.second + ratio * ratio * backgrd.second);
339 if (pos->second.size() < 3)
342 return &(pos->second);
346 const std::vector<V3D> &E1Vecs,
const V3D &peak_q,
354 const auto &r1 = std::get<0>(radii);
355 auto &r2 = std::get<1>(radii);
356 auto &r3 = std::get<2>(radii);
357 auto h3 = 1.0 -
detectorQ(E1Vecs, peak_q, bkgOuterRadii);
359 auto m3 = std::sqrt(1.0 - (std::acos(1.0 - h3) - (1.0 - h3) * std::sqrt(2.0 * h3 - h3 * h3)) / M_PI);
360 auto h1 = 1.0 -
detectorQ(E1Vecs, peak_q, axesRadii);
367 auto h2 = 1.0 -
detectorQ(E1Vecs, peak_q, bkgInnerRadii);
369 auto m2 = std::sqrt(1.0 - (std::acos(1.0 - h2) - (1.0 - h2) * std::sqrt(2.0 * h2 - h2 * h2)) / M_PI);
414 double peak_radius,
double back_inner_radius,
double back_outer_radius,
422 return std::make_shared<NoShape>();
427 return std::make_shared<NoShape>();
430 const std::vector<std::pair<std::pair<double, double>,
V3D>> &some_events = pos->second;
432 if (some_events.size() < 3)
434 return std::make_shared<NoShape>();
440 std::array<V3D, 3> eigen_vectors;
441 std::array<double, 3> eigen_values;
444 std::array<double, 3> sigmas;
445 for (
int i = 0; i < 3; i++) {
446 sigmas[i] = sqrt(eigen_values[i]);
450 std::any_of(sigmas.cbegin(), sigmas.cend(), [](
const double sigma) { return std::isnan(sigma) || sigma <= 0; });
454 return std::make_shared<NoShape>();
457 return ellipseIntegrateEvents(E1Vec, peak_q, some_events, eigen_vectors, sigmas, specify_size, peak_radius,
458 back_inner_radius, back_outer_radius, axes_radii, inti, sigi);
463 V3D const &mnp,
bool specify_size,
double peak_radius,
464 double back_inner_radius,
double back_outer_radius,
469 int64_t hkl_key =
getHklMnpKey(boost::math::iround<double>(hkl[0]), boost::math::iround<double>(hkl[1]),
470 boost::math::iround<double>(hkl[2]), boost::math::iround<double>(mnp[0]),
471 boost::math::iround<double>(mnp[1]), boost::math::iround<double>(mnp[2]));
474 return std::make_shared<NoShape>();
479 return std::make_shared<NoShape>();
482 const std::vector<std::pair<std::pair<double, double>,
V3D>> &some_events = pos->second;
484 if (some_events.size() < 3)
486 return std::make_shared<NoShape>();
490 if (hkl_key % 1000 == 0)
495 std::array<V3D, 3> eigen_vectors;
496 std::array<double, 3> eigen_values;
499 std::array<double, 3> sigmas;
500 for (
int i = 0; i < 3; i++)
501 sigmas[i] = sqrt(eigen_values[i]);
504 std::any_of(sigmas.cbegin(), sigmas.cend(), [](
const double sigma) { return std::isnan(sigma) || sigma <= 0; });
508 return std::make_shared<NoShape>();
511 return ellipseIntegrateEvents(E1Vec, peak_q, some_events, eigen_vectors, sigmas, specify_size, peak_radius,
512 back_inner_radius, back_outer_radius, axes_radii, inti, sigi);
527std::pair<double, double>
532 std::pair<double, double>
count(0, 0);
533 for (
const auto &event : events) {
535 for (
size_t k = 0; k < 3; k++) {
536 double comp =
event.second.scalar_prod(directions[k]) / sizes[k];
540 count.first +=
event.first.first;
541 count.second +=
event.first.second;
565 std::vector<std::pair<std::pair<double, double>,
V3D>>
const &events,
568 std::pair<double, double>
count(0, 0);
569 std::vector<std::pair<double, double>> eventVec;
570 for (
const auto &event : events) {
573 for (
size_t k = 0; k < 3; k++) {
574 double comp =
event.second.scalar_prod(directions[k]) / sizes[k];
576 comp =
event.second.scalar_prod(directions[k]) / sizesIn[k];
577 sumIn += comp * comp;
579 if (sum <= 1 && sumIn >= 1)
580 eventVec.emplace_back(event.first);
583 auto endIndex = eventVec.size();
584 if (useOnePercentBackgroundCorrection) {
586 std::sort(eventVec.begin(), eventVec.end(),
587 [](
const std::pair<double, double> &a,
const std::pair<double, double> &b) { return a.first < b.first; });
588 endIndex =
static_cast<size_t>(0.99 *
static_cast<double>(endIndex));
591 for (
size_t k = 0; k < endIndex; ++k) {
592 count.first += eventVec[k].first;
593 count.second += eventVec[k].second;
629 for (
int row = 0; row < 3; row++) {
630 for (
int col = 0; col < 3; col++) {
633 for (
const auto &event : events) {
634 if (event.second.norm() <= radius) {
635 totalCounts +=
event.first.first;
636 sum +=
event.first.first *
event.second[row] *
event.second[col];
640 matrix[row][col] = sum / (totalCounts - 1);
642 matrix[row][col] = sum;
656 std::array<double, 3> &eigen_values) {
657 constexpr unsigned int size = 3;
659 gsl_matrix *matrix = gsl_matrix_alloc(size, size);
660 gsl_vector *eigen_val = gsl_vector_alloc(size);
661 gsl_matrix *eigen_vec = gsl_matrix_alloc(size, size);
662 gsl_eigen_symmv_workspace *wkspace = gsl_eigen_symmv_alloc(size);
665 for (
size_t row = 0; row < size; row++)
666 for (
size_t col = 0; col < size; col++) {
667 gsl_matrix_set(matrix, row, col, cov_matrix[row][col]);
670 gsl_eigen_symmv(matrix, eigen_val, eigen_vec, wkspace);
673 for (
size_t col = 0; col < size; col++) {
675 V3D(gsl_matrix_get(eigen_vec, 0, col), gsl_matrix_get(eigen_vec, 1, col), gsl_matrix_get(eigen_vec, 2, col));
676 eigen_values[col] = gsl_vector_get(eigen_val, col);
679 gsl_matrix_free(matrix);
680 gsl_vector_free(eigen_val);
681 gsl_matrix_free(eigen_vec);
682 gsl_eigen_symmv_free(wkspace);
696 if (h != 0 || k != 0 || l != 0)
697 key = 1000000000000 * h + 100000000 * k + 10000 * l;
715 if (h != 0 || k != 0 || l != 0 ||
m != 0 ||
n != 0 || p != 0)
716 key = 1000000000000 * h + 100000000 * k + 10000 * l + 100 *
m + 10 *
n + p;
728 int h = boost::math::iround<double>(hkl[0]);
729 int k = boost::math::iround<double>(hkl[1]);
730 int l = boost::math::iround<double>(hkl[2]);
745 int h = boost::math::iround<double>(hkl[0]);
746 int k = boost::math::iround<double>(hkl[1]);
747 int l = boost::math::iround<double>(hkl[2]);
751 if (modvec1 !=
V3D(0, 0, 0))
756 hkl1[0] -= order * modvec1[0];
757 hkl1[1] -= order * modvec1[1];
758 hkl1[2] -= order * modvec1[2];
760 int h = boost::math::iround<double>(hkl1[0]);
761 int k = boost::math::iround<double>(hkl1[1]);
762 int l = boost::math::iround<double>(hkl1[2]);
766 if (modvec2 !=
V3D(0, 0, 0))
771 hkl1[0] -= order * modvec2[0];
772 hkl1[1] -= order * modvec2[1];
773 hkl1[2] -= order * modvec2[2];
775 int h = boost::math::iround<double>(hkl1[0]);
776 int k = boost::math::iround<double>(hkl1[1]);
777 int l = boost::math::iround<double>(hkl1[2]);
781 if (modvec3 !=
V3D(0, 0, 0))
786 hkl1[0] -= order * modvec3[0];
787 hkl1[1] -= order * modvec3[1];
788 hkl1[2] -= order * modvec3[2];
790 int h = boost::math::iround<double>(hkl1[0]);
791 int k = boost::math::iround<double>(hkl1[1]);
792 int l = boost::math::iround<double>(hkl1[2]);
798 if (modvec1 ==
V3D(0, 0, 0))
801 if (modvec2 ==
V3D(0, 0, 0))
804 if (modvec3 ==
V3D(0, 0, 0))
806 for (
int m = -maxOrder1;
m <= maxOrder1;
m++)
807 for (
int n = -maxOrder2;
n <= maxOrder2;
n++)
808 for (
int p = -maxOrder3; p <= maxOrder3; p++) {
809 if (
m == 0 &&
n == 0 && p == 0)
815 int h = boost::math::iround<double>(hkl1[0]);
816 int k = boost::math::iround<double>(hkl1[1]);
817 int l = boost::math::iround<double>(hkl1[2]);
833 int h = boost::math::iround<double>(hkl[0]);
834 int k = boost::math::iround<double>(hkl[1]);
835 int l = boost::math::iround<double>(hkl[2]);
854 int h = boost::math::iround<double>(hkl[0]);
855 int k = boost::math::iround<double>(hkl[1]);
856 int l = boost::math::iround<double>(hkl[2]);
860 if (modvec1 !=
V3D(0, 0, 0))
865 hkl1[0] -= order * modvec1[0];
866 hkl1[1] -= order * modvec1[1];
867 hkl1[2] -= order * modvec1[2];
869 int h = boost::math::iround<double>(hkl1[0]);
870 int k = boost::math::iround<double>(hkl1[1]);
871 int l = boost::math::iround<double>(hkl1[2]);
875 if (modvec2 !=
V3D(0, 0, 0))
880 hkl1[0] -= order * modvec2[0];
881 hkl1[1] -= order * modvec2[1];
882 hkl1[2] -= order * modvec2[2];
884 int h = boost::math::iround<double>(hkl1[0]);
885 int k = boost::math::iround<double>(hkl1[1]);
886 int l = boost::math::iround<double>(hkl1[2]);
890 if (modvec3 !=
V3D(0, 0, 0))
895 hkl1[0] -= order * modvec3[0];
896 hkl1[1] -= order * modvec3[1];
897 hkl1[2] -= order * modvec3[2];
899 int h = boost::math::iround<double>(hkl1[0]);
900 int k = boost::math::iround<double>(hkl1[1]);
901 int l = boost::math::iround<double>(hkl1[2]);
907 if (modvec1 ==
V3D(0, 0, 0))
910 if (modvec2 ==
V3D(0, 0, 0))
913 if (modvec3 ==
V3D(0, 0, 0))
915 for (
int m = -maxOrder1;
m <= maxOrder1;
m++)
916 for (
int n = -maxOrder2;
n <= maxOrder2;
n++)
917 for (
int p = -maxOrder3; p <= maxOrder3; p++) {
918 if (
m == 0 &&
n == 0 && p == 0)
924 int h = boost::math::iround<double>(hkl1[0]);
925 int k = boost::math::iround<double>(hkl1[1]);
926 int l = boost::math::iround<double>(hkl1[2]);
960 if (!peak_it->second.nullVector()) {
962 event_Q.second = event_Q.second -
m_UBinv * peak_it->second;
964 event_Q.second = event_Q.second - peak_it->second;
965 if (event_Q.second.norm() <
m_radius) {
997 auto peak_it =
m_peak_qs.find(hklmnp_key);
999 if (!peak_it->second.nullVector()) {
1001 event_Q.second = event_Q.second -
m_UBinv * peak_it->second;
1003 event_Q.second = event_Q.second - peak_it->second;
1005 if (hklmnp_key % 10000 == 0) {
1006 if (event_Q.second.norm() <
m_radius)
1008 }
else if (event_Q.second.norm() <
s_radius) {
1054 std::vector<std::pair<std::pair<double, double>,
Kernel::V3D>>
const &ev_list,
1056 std::array<double, 3>
const &sigmas,
bool specify_size,
double peak_radius,
1057 double back_inner_radius,
double back_outer_radius,
1067 double max_sigma = sigmas[0];
1068 for (
int i = 1; i < 3; i++) {
1069 if (sigmas[i] > max_sigma) {
1070 max_sigma = sigmas[i];
1075 r1 = peak_radius / max_sigma;
1076 r2 = back_inner_radius / max_sigma;
1077 r3 = back_outer_radius / max_sigma;
1081 r3 = r2 * 1.25992105;
1089 r1 = r3 * 0.79370053f;
1097 for (
int i = 0; i < 3; i++) {
1098 abcBackgroundOuterRadii[i] = r3 * sigmas[i];
1099 abcBackgroundInnerRadii[i] = r2 * sigmas[i];
1100 abcRadii[i] = r1 * sigmas[i];
1101 axes_radii[i] = r1 * sigmas[i];
1104 if (!E1Vec.empty()) {
1105 double h3 = 1.0 -
detectorQ(E1Vec, peak_q, abcBackgroundOuterRadii);
1107 double m3 = std::sqrt(1.0 - (std::acos(1.0 - h3) - (1.0 - h3) * std::sqrt(2.0 * h3 - h3 * h3)) / M_PI);
1108 double h1 = 1.0 -
detectorQ(E1Vec, peak_q, axes_radii);
1111 return std::make_shared<const PeakShapeEllipsoid>(directions, abcRadii, abcBackgroundInnerRadii,
1113 "IntegrateEllipsoids");
1116 double h2 = 1.0 -
detectorQ(E1Vec, peak_q, abcBackgroundInnerRadii);
1118 double m2 = std::sqrt(1.0 - (std::acos(1.0 - h2) - (1.0 - h2) * std::sqrt(2.0 * h2 - h2 * h2)) / M_PI);
1123 std::pair<double, double> backgrd =
numInEllipsoidBkg(ev_list, directions, abcBackgroundOuterRadii,
1126 std::pair<double, double> peak_w_back =
numInEllipsoid(ev_list, directions, axes_radii);
1128 double ratio = pow(r1, 3) / (pow(r3, 3) - pow(r2, 3));
1130 inti = peak_w_back.first - ratio * backgrd.first;
1131 sigi = sqrt(peak_w_back.second + ratio * ratio * backgrd.second);
1134 return std::make_shared<const PeakShapeEllipsoid>(directions, abcRadii, abcBackgroundInnerRadii,
1136 "IntegrateEllipsoids");
1152 for (
const auto &
E1 : E1Vec) {
1154 double quot0 = distv.
norm() / *(std::min_element(r.begin(), r.end()));
1170 double max_sigma)
const {
1171 double r1 = 0, r2 = 0, r3 = 0;
1176 r3 = r2 * 1.25992105;
1184 r1 = r3 * 0.79370053f;
1196 return std::make_tuple(r1, r2, r3);
static bool ValidIndex(const Kernel::V3D &hkl, double tolerance)
Check is hkl is within tolerance of integer (h,k,l) non-zero values.
constexpr double scalar_prod(const V3D &v) const noexcept
Calculates the cross product.
double norm() const noexcept
int64_t getHklKey2(Mantid::Kernel::V3D const &hkl)
Form a map key for the specified q_vector.
Integrate3DEvents(const std::vector< std::pair< std::pair< double, double >, Mantid::Kernel::V3D > > &peak_q_list, Kernel::DblMatrix UBinv, double radius, const bool useOnePercentBackgroundCorrection=true)
Construct object to store events around peaks and integrate peaks.
double detectorQ(const std::vector< Kernel::V3D > &E1Vec, const Mantid::Kernel::V3D &QLabFrame, const DataObjects::PeakEllipsoidExtent &r)
Compute if a particular Q falls on the edge of a detector.
static int64_t getHklMnpKey(int h, int k, int l, int m, int n, int p)
Form a map key as 10^12*h + 10^6*k + l from the integers h,k,l.
Kernel::DblMatrix m_ModHKL
Kernel::DblMatrix m_UBinv
EventListMap m_event_lists
bool correctForDetectorEdges(std::tuple< double, double, double > &radii, const std::vector< Mantid::Kernel::V3D > &E1Vecs, const Mantid::Kernel::V3D &peak_q, const DataObjects::PeakEllipsoidExtent &axesRadii, const DataObjects::PeakEllipsoidExtent &bkgInnerRadii, const DataObjects::PeakEllipsoidExtent &bkgOuterRadii)
void addEvent(std::pair< std::pair< double, double >, Mantid::Kernel::V3D > event_Q, bool hkl_integ)
Add an event to the vector of events for the closest h,k,l.
std::pair< std::shared_ptr< const Mantid::Geometry::PeakShape >, std::tuple< double, double, double > > integrateStrongPeak(const IntegrationParameters ¶ms, const Kernel::V3D &peak_q, double &inti, double &sigi)
Find the net integrated intensity of a peak, using ellipsoidal volumes.
static void makeCovarianceMatrix(std::vector< std::pair< std::pair< double, double >, Mantid::Kernel::V3D > > const &events, Kernel::DblMatrix &matrix, double radius)
Calculate the 3x3 covariance matrix of a list of Q-vectors at 0,0,0.
std::shared_ptr< const Mantid::Geometry::PeakShape > ellipseIntegrateEvents(const std::vector< Kernel::V3D > &E1Vec, Mantid::Kernel::V3D const &peak_q, bool specify_size, double peak_radius, double back_inner_radius, double back_outer_radius, DataObjects::PeakEllipsoidExtent &axes_radii, double &inti, double &sigi)
Find the net integrated intensity of a peak, using ellipsoidal volumes.
void addModEvent(std::pair< std::pair< double, double >, Mantid::Kernel::V3D > event_Q, bool hkl_integ)
Add an event to the appropriate vector of events for the closest h,k,l, if it is within the required ...
std::shared_ptr< const Mantid::Geometry::PeakShape > ellipseIntegrateModEvents(const std::vector< Kernel::V3D > &E1Vec, Mantid::Kernel::V3D const &peak_q, Mantid::Kernel::V3D const &hkl, Mantid::Kernel::V3D const &mnp, bool specify_size, double peak_radius, double back_inner_radius, double back_outer_radius, DataObjects::PeakEllipsoidExtent &axes_radii, double &inti, double &sigi)
Find the net integrated intensity of a modulated peak, using ellipsoidal volumes.
std::shared_ptr< const Geometry::PeakShape > integrateWeakPeak(const IntegrationParameters ¶ms, Mantid::DataObjects::PeakShapeEllipsoid_const_sptr shape, const std::tuple< double, double, double > &libPeak, const Mantid::Kernel::V3D &peak_q, double &inti, double &sigi)
std::tuple< double, double, double > calculateRadiusFactors(const IntegrationParameters ¶ms, double max_sigma) const
Calculate the radius to use for each axis of the ellipsoid from the parameters provided.
double estimateSignalToNoiseRatio(const IntegrationParameters ¶ms, const Mantid::Kernel::V3D ¢er, bool forceSpherical=false, double sphericityTol=0.02)
static int64_t getHklKey(int h, int k, int l)
Form a map key as 10^12*h + 10^6*k + l from the integers h, k, l.
static std::pair< double, double > numInEllipsoidBkg(std::vector< std::pair< std::pair< double, double >, Mantid::Kernel::V3D > > const &events, DataObjects::PeakEllipsoidFrame const &directions, DataObjects::PeakEllipsoidExtent const &sizes, DataObjects::PeakEllipsoidExtent const &sizesIn, const bool useOnePercentBackgroundCorrection)
Calculate the number of events in an ellipsoid centered at 0,0,0.
void addEvents(std::vector< std::pair< std::pair< double, double >, Mantid::Kernel::V3D > > const &event_qs, bool hkl_integ)
Add event Q's to lists of events near peaks.
static void getEigenVectors(Kernel::DblMatrix const &cov_matrix, std::array< Mantid::Kernel::V3D, 3 > &eigen_vectors, DataObjects::PeakEllipsoidExtent &eigen_values)
Calculate the eigen vectors of a 3x3 real symmetric matrix.
static std::pair< double, double > numInEllipsoid(std::vector< std::pair< std::pair< double, double >, Mantid::Kernel::V3D > > const &events, DataObjects::PeakEllipsoidFrame const &directions, DataObjects::PeakEllipsoidExtent const &sizes)
Calculate the number of events in an ellipsoid centered at 0,0,0.
const bool m_useOnePercentBackgroundCorrection
int64_t getHklMnpKey2(Mantid::Kernel::V3D const &hkl)
Form a map key for the specified q_vector.
const std::vector< std::pair< std::pair< double, double >, Mantid::Kernel::V3D > > * getEvents(const Mantid::Kernel::V3D &peak_q)
Get a list of events for a given Q.
std::complex< double > MANTID_API_DLL E1(std::complex< double > z)
Integral for Gamma.
std::array< Kernel::V3D, PEAK_ELLIPSOID_DIMS > PeakEllipsoidFrame
std::array< double, PEAK_ELLIPSOID_DIMS > PeakEllipsoidExtent
std::shared_ptr< const PeakShapeEllipsoid > PeakShapeEllipsoid_const_sptr
std::shared_ptr< const PeakShape > PeakShape_const_sptr
double backgroundOuterRadius
double backgroundInnerRadius
std::vector< Kernel::V3D > E1Vectors