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)
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::vector<V3D> eigen_vectors;
144 std::vector<double> eigen_values;
147 std::vector<double> sigmas(3);
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 &r1 = std::get<0>(rValues), r2 = std::get<1>(rValues), r3 = std::get<2>(rValues);
165 std::vector<double> abcBackgroundOuterRadii, abcBackgroundInnerRadii;
166 std::vector<double> peakRadii;
167 for (
int i = 0; i < 3; i++) {
168 abcBackgroundOuterRadii.emplace_back(r3 * sigmas[i]);
169 abcBackgroundInnerRadii.emplace_back(r2 * sigmas[i]);
170 peakRadii.emplace_back(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::vector<V3D> eigen_vectors;
279 std::vector<double> eigen_values;
282 std::vector<double> sigmas(3);
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 &r1 = std::get<0>(rValues), r2 = std::get<1>(rValues), r3 = std::get<2>(rValues);
294 std::vector<double> abcBackgroundOuterRadii, abcBackgroundInnerRadii;
295 std::vector<double> peakRadii;
296 if (forceSpherical) {
298 if ((max_sigma - min_sigma) / max_sigma > sphericityTol)
300 for (
int i = 0; i < 3; i++) {
301 abcBackgroundOuterRadii.emplace_back(r3 * max_sigma);
302 abcBackgroundInnerRadii.emplace_back(r2 * max_sigma);
303 peakRadii.emplace_back(r1 * max_sigma);
306 for (
int i = 0; i < 3; i++) {
307 abcBackgroundOuterRadii.emplace_back(r3 * sigmas[i]);
308 abcBackgroundInnerRadii.emplace_back(r2 * sigmas[i]);
309 peakRadii.emplace_back(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,
347 const std::vector<double> &axesRadii,
348 const std::vector<double> &bkgInnerRadii,
349 const std::vector<double> &bkgOuterRadii) {
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,
415 std::vector<double> &axes_radii,
double &inti,
double &sigi) {
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::vector<V3D> eigen_vectors;
441 std::vector<double> eigen_values;
444 std::vector<double> sigmas(3);
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,
465 std::vector<double> &axes_radii,
double &inti,
double &sigi) {
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::vector<V3D> eigen_vectors;
496 std::vector<double> eigen_values;
499 std::vector<double> sigmas(3);
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>
529 std::vector<V3D>
const &directions, std::vector<double>
const &sizes) {
531 std::pair<double, double>
count(0, 0);
532 for (
const auto &event : events) {
534 for (
size_t k = 0; k < 3; k++) {
535 double comp =
event.second.scalar_prod(directions[k]) / sizes[k];
539 count.first +=
event.first.first;
540 count.second +=
event.first.second;
563std::pair<double, double>
565 std::vector<V3D>
const &directions, std::vector<double>
const &sizes,
566 std::vector<double>
const &sizesIn,
const bool useOnePercentBackgroundCorrection) {
567 std::pair<double, double>
count(0, 0);
568 std::vector<std::pair<double, double>> eventVec;
569 for (
const auto &event : events) {
572 for (
size_t k = 0; k < 3; k++) {
573 double comp =
event.second.scalar_prod(directions[k]) / sizes[k];
575 comp =
event.second.scalar_prod(directions[k]) / sizesIn[k];
576 sumIn += comp * comp;
578 if (sum <= 1 && sumIn >= 1)
579 eventVec.emplace_back(event.first);
582 auto endIndex = eventVec.size();
583 if (useOnePercentBackgroundCorrection) {
585 std::sort(eventVec.begin(), eventVec.end(),
586 [](
const std::pair<double, double> &a,
const std::pair<double, double> &b) { return a.first < b.first; });
587 endIndex =
static_cast<size_t>(0.99 *
static_cast<double>(endIndex));
590 for (
size_t k = 0; k < endIndex; ++k) {
591 count.first += eventVec[k].first;
592 count.second += eventVec[k].second;
628 for (
int row = 0; row < 3; row++) {
629 for (
int col = 0; col < 3; col++) {
632 for (
const auto &event : events) {
633 if (event.second.norm() <=
radius) {
634 totalCounts +=
event.first.first;
635 sum +=
event.first.first *
event.second[row] *
event.second[col];
639 matrix[row][col] = sum / (totalCounts - 1);
641 matrix[row][col] = sum;
655 std::vector<double> &eigen_values) {
656 unsigned int size = 3;
658 gsl_matrix *matrix = gsl_matrix_alloc(size, size);
659 gsl_vector *eigen_val = gsl_vector_alloc(size);
660 gsl_matrix *eigen_vec = gsl_matrix_alloc(size, size);
661 gsl_eigen_symmv_workspace *wkspace = gsl_eigen_symmv_alloc(size);
664 for (
size_t row = 0; row < size; row++)
665 for (
size_t col = 0; col < size; col++) {
666 gsl_matrix_set(matrix, row, col, cov_matrix[row][col]);
669 gsl_eigen_symmv(matrix, eigen_val, eigen_vec, wkspace);
672 for (
size_t col = 0; col < size; col++) {
673 eigen_vectors.emplace_back(gsl_matrix_get(eigen_vec, 0, col), gsl_matrix_get(eigen_vec, 1, col),
674 gsl_matrix_get(eigen_vec, 2, col));
675 eigen_values.emplace_back(gsl_vector_get(eigen_val, col));
678 gsl_matrix_free(matrix);
679 gsl_vector_free(eigen_val);
680 gsl_matrix_free(eigen_vec);
681 gsl_eigen_symmv_free(wkspace);
695 if (h != 0 || k != 0 || l != 0)
696 key = 1000000000000 * h + 100000000 * k + 10000 * l;
714 if (h != 0 || k != 0 || l != 0 ||
m != 0 ||
n != 0 || p != 0)
715 key = 1000000000000 * h + 100000000 * k + 10000 * l + 100 *
m + 10 *
n + p;
727 int h = boost::math::iround<double>(hkl[0]);
728 int k = boost::math::iround<double>(hkl[1]);
729 int l = boost::math::iround<double>(hkl[2]);
744 int h = boost::math::iround<double>(hkl[0]);
745 int k = boost::math::iround<double>(hkl[1]);
746 int l = boost::math::iround<double>(hkl[2]);
750 if (modvec1 !=
V3D(0, 0, 0))
755 hkl1[0] -= order * modvec1[0];
756 hkl1[1] -= order * modvec1[1];
757 hkl1[2] -= order * modvec1[2];
759 int h = boost::math::iround<double>(hkl1[0]);
760 int k = boost::math::iround<double>(hkl1[1]);
761 int l = boost::math::iround<double>(hkl1[2]);
765 if (modvec2 !=
V3D(0, 0, 0))
770 hkl1[0] -= order * modvec2[0];
771 hkl1[1] -= order * modvec2[1];
772 hkl1[2] -= order * modvec2[2];
774 int h = boost::math::iround<double>(hkl1[0]);
775 int k = boost::math::iround<double>(hkl1[1]);
776 int l = boost::math::iround<double>(hkl1[2]);
780 if (modvec3 !=
V3D(0, 0, 0))
785 hkl1[0] -= order * modvec3[0];
786 hkl1[1] -= order * modvec3[1];
787 hkl1[2] -= order * modvec3[2];
789 int h = boost::math::iround<double>(hkl1[0]);
790 int k = boost::math::iround<double>(hkl1[1]);
791 int l = boost::math::iround<double>(hkl1[2]);
797 if (modvec1 ==
V3D(0, 0, 0))
800 if (modvec2 ==
V3D(0, 0, 0))
803 if (modvec3 ==
V3D(0, 0, 0))
805 for (
int m = -maxOrder1;
m <= maxOrder1;
m++)
806 for (
int n = -maxOrder2;
n <= maxOrder2;
n++)
807 for (
int p = -maxOrder3; p <= maxOrder3; p++) {
808 if (
m == 0 &&
n == 0 && p == 0)
814 int h = boost::math::iround<double>(hkl1[0]);
815 int k = boost::math::iround<double>(hkl1[1]);
816 int l = boost::math::iround<double>(hkl1[2]);
832 int h = boost::math::iround<double>(hkl[0]);
833 int k = boost::math::iround<double>(hkl[1]);
834 int l = boost::math::iround<double>(hkl[2]);
853 int h = boost::math::iround<double>(hkl[0]);
854 int k = boost::math::iround<double>(hkl[1]);
855 int l = boost::math::iround<double>(hkl[2]);
859 if (modvec1 !=
V3D(0, 0, 0))
864 hkl1[0] -= order * modvec1[0];
865 hkl1[1] -= order * modvec1[1];
866 hkl1[2] -= order * modvec1[2];
868 int h = boost::math::iround<double>(hkl1[0]);
869 int k = boost::math::iround<double>(hkl1[1]);
870 int l = boost::math::iround<double>(hkl1[2]);
874 if (modvec2 !=
V3D(0, 0, 0))
879 hkl1[0] -= order * modvec2[0];
880 hkl1[1] -= order * modvec2[1];
881 hkl1[2] -= order * modvec2[2];
883 int h = boost::math::iround<double>(hkl1[0]);
884 int k = boost::math::iround<double>(hkl1[1]);
885 int l = boost::math::iround<double>(hkl1[2]);
889 if (modvec3 !=
V3D(0, 0, 0))
894 hkl1[0] -= order * modvec3[0];
895 hkl1[1] -= order * modvec3[1];
896 hkl1[2] -= order * modvec3[2];
898 int h = boost::math::iround<double>(hkl1[0]);
899 int k = boost::math::iround<double>(hkl1[1]);
900 int l = boost::math::iround<double>(hkl1[2]);
906 if (modvec1 ==
V3D(0, 0, 0))
909 if (modvec2 ==
V3D(0, 0, 0))
912 if (modvec3 ==
V3D(0, 0, 0))
914 for (
int m = -maxOrder1;
m <= maxOrder1;
m++)
915 for (
int n = -maxOrder2;
n <= maxOrder2;
n++)
916 for (
int p = -maxOrder3; p <= maxOrder3; p++) {
917 if (
m == 0 &&
n == 0 && p == 0)
923 int h = boost::math::iround<double>(hkl1[0]);
924 int k = boost::math::iround<double>(hkl1[1]);
925 int l = boost::math::iround<double>(hkl1[2]);
959 if (!peak_it->second.nullVector()) {
961 event_Q.second = event_Q.second -
m_UBinv * peak_it->second;
963 event_Q.second = event_Q.second - peak_it->second;
964 if (event_Q.second.norm() <
m_radius) {
996 auto peak_it =
m_peak_qs.find(hklmnp_key);
998 if (!peak_it->second.nullVector()) {
1000 event_Q.second = event_Q.second -
m_UBinv * peak_it->second;
1002 event_Q.second = event_Q.second - peak_it->second;
1004 if (hklmnp_key % 10000 == 0) {
1005 if (event_Q.second.norm() <
m_radius)
1007 }
else if (event_Q.second.norm() <
s_radius) {
1052 const std::vector<V3D> &E1Vec,
V3D const &peak_q,
1054 std::vector<V3D>
const &directions, std::vector<double>
const &sigmas,
bool specify_size,
double peak_radius,
1055 double back_inner_radius,
double back_outer_radius, std::vector<double> &axes_radii,
double &inti,
double &sigi) {
1064 double max_sigma = sigmas[0];
1065 for (
int i = 1; i < 3; i++) {
1066 if (sigmas[i] > max_sigma) {
1067 max_sigma = sigmas[i];
1072 r1 = peak_radius / max_sigma;
1073 r2 = back_inner_radius / max_sigma;
1074 r3 = back_outer_radius / max_sigma;
1079 r3 = r2 * 1.25992105;
1087 r1 = r3 * 0.79370053f;
1093 std::vector<double> abcBackgroundOuterRadii;
1094 std::vector<double> abcBackgroundInnerRadii;
1095 std::vector<double> abcRadii;
1096 for (
int i = 0; i < 3; i++) {
1097 abcBackgroundOuterRadii.emplace_back(r3 * sigmas[i]);
1098 abcBackgroundInnerRadii.emplace_back(r2 * sigmas[i]);
1099 abcRadii.emplace_back(r1 * sigmas[i]);
1100 axes_radii.emplace_back(r1 * sigmas[i]);
1103 if (!E1Vec.empty()) {
1104 double h3 = 1.0 -
detectorQ(E1Vec, peak_q, abcBackgroundOuterRadii);
1106 double m3 = std::sqrt(1.0 - (std::acos(1.0 - h3) - (1.0 - h3) * std::sqrt(2.0 * h3 - h3 * h3)) / M_PI);
1107 double h1 = 1.0 -
detectorQ(E1Vec, peak_q, axes_radii);
1110 return std::make_shared<const PeakShapeEllipsoid>(directions, abcRadii, abcBackgroundInnerRadii,
1112 "IntegrateEllipsoids");
1115 double h2 = 1.0 -
detectorQ(E1Vec, peak_q, abcBackgroundInnerRadii);
1117 double m2 = std::sqrt(1.0 - (std::acos(1.0 - h2) - (1.0 - h2) * std::sqrt(2.0 * h2 - h2 * h2)) / M_PI);
1122 std::pair<double, double> backgrd =
numInEllipsoidBkg(ev_list, directions, abcBackgroundOuterRadii,
1125 std::pair<double, double> peak_w_back =
numInEllipsoid(ev_list, directions, axes_radii);
1127 double ratio = pow(r1, 3) / (pow(r3, 3) - pow(r2, 3));
1129 inti = peak_w_back.first - ratio * backgrd.first;
1130 sigi = sqrt(peak_w_back.second + ratio * ratio * backgrd.second);
1133 return std::make_shared<const PeakShapeEllipsoid>(directions, abcRadii, abcBackgroundInnerRadii,
1135 "IntegrateEllipsoids");
1150 for (
auto &
E1 : E1Vec) {
1152 double quot0 = distv.
norm() / *(std::min_element(r.begin(), r.end()));
1168 double max_sigma)
const {
1169 double r1 = 0, r2 = 0, r3 = 0;
1174 r3 = r2 * 1.25992105;
1182 r1 = r3 * 0.79370053f;
1194 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.
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
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, std::vector< double > &axes_radii, double &inti, double &sigi)
Find the net integrated intensity of a modulated peak, using ellipsoidal volumes.
Kernel::DblMatrix m_UBinv
EventListMap m_event_lists
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, std::vector< double > &axes_radii, double &inti, double &sigi)
Find the net integrated intensity of a peak, using ellipsoidal volumes.
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.
static std::pair< double, double > numInEllipsoidBkg(std::vector< std::pair< std::pair< double, double >, Mantid::Kernel::V3D > > const &events, std::vector< Mantid::Kernel::V3D > const &directions, std::vector< double > const &sizes, std::vector< double > const &sizesIn, const bool useOnePercentBackgroundCorrection)
Calculate the number of events in an ellipsoid centered at 0,0,0.
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.
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 ...
static std::pair< double, double > numInEllipsoid(std::vector< std::pair< std::pair< double, double >, Mantid::Kernel::V3D > > const &events, std::vector< Mantid::Kernel::V3D > const &directions, std::vector< double > const &sizes)
Calculate the number of events in an ellipsoid centered at 0,0,0.
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)
double detectorQ(const std::vector< Kernel::V3D > &E1Vec, const Mantid::Kernel::V3D &QLabFrame, const std::vector< double > &r)
Compute if a particular Q falls on the edge of a detector.
bool correctForDetectorEdges(std::tuple< double, double, double > &radii, const std::vector< Mantid::Kernel::V3D > &E1Vecs, const Mantid::Kernel::V3D &peak_q, const std::vector< double > &axesRadii, const std::vector< double > &bkgInnerRadii, const std::vector< double > &bkgOuterRadii)
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 void getEigenVectors(Kernel::DblMatrix const &cov_matrix, std::vector< Mantid::Kernel::V3D > &eigen_vectors, std::vector< double > &eigen_values)
Calculate the eigen vectors of a 3x3 real symmetric matrix.
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.
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.
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::shared_ptr< const PeakShapeEllipsoid > PeakShapeEllipsoid_const_sptr
std::shared_ptr< const PeakShape > PeakShape_const_sptr
double backgroundOuterRadius
double backgroundInnerRadius
std::vector< Kernel::V3D > E1Vectors