Unverified Commit a2587b55 authored by Whitfield, Ross's avatar Whitfield, Ross Committed by GitHub
Browse files

Merge pull request #30788 from rosswhitfield/FindPeaksMD_multipleGoniomters

FindPeaksMD multiple goniometers
parents 8095f069 08e33573
......@@ -519,7 +519,7 @@ void FindPeaksMD::findPeaks(typename MDEventWorkspace<MDE, nd>::sptr ws) {
// If no events from this experimental contribute to the box then skip
if (nexp > 1) {
auto *mdbox = dynamic_cast<MDBox<MDE, nd> *>(box);
typename std::vector<MDE> &events = mdbox->getEvents();
const std::vector<MDE> &events = mdbox->getEvents();
if (std::none_of(events.cbegin(), events.cend(),
[&iexp, &nexp](MDE event) {
return event.getRunIndex() == iexp ||
......@@ -527,6 +527,23 @@ void FindPeaksMD::findPeaks(typename MDEventWorkspace<MDE, nd>::sptr ws) {
}))
continue;
}
// If multiple goniometers than use the average one from the
// events in the box, that matches this runIndex, this assumes
// the events are added in same order as the goniometers
if (ei->run().getNumGoniometers() > 1) {
const std::vector<MDE> &events =
dynamic_cast<MDBox<MDE, nd> *>(box)->getEvents();
double sum = 0;
double count = 0;
for (const auto &event : events) {
if (event.getRunIndex() == iexp) {
sum += event.getGoniometerIndex();
count++;
}
}
m_goniometer = ei->mutableRun().getGoniometerMatrix(lrint(sum / count));
}
// The center of the box = Q in the lab frame
#ifndef MDBOX_TRACK_CENTROID
......
......@@ -34,6 +34,17 @@ class ConvertHFIRSCDtoMDETest(systemtesting.MantidSystemTest):
np.testing.assert_allclose(peak.getQSampleFrame(), [6.754011, 0.003572579, 1.918834], rtol=1e-05)
self.assertDelta(peak.getWavelength(), 1.488, 1e-5)
# new method using multiple goniometers, compare peak q_sample to old method
ConvertHFIRSCDtoMDETest_peaks2 = FindPeaksMD(InputWorkspace=ConvertHFIRSCDtoMDETest_Q, PeakDistanceThreshold=2.2)
self.assertEqual(ConvertHFIRSCDtoMDETest_peaks2.getNumberPeaks(), 14)
for p in range(14):
np.testing.assert_allclose(ConvertHFIRSCDtoMDETest_peaks2.getPeak(p).getQSampleFrame(),
ConvertHFIRSCDtoMDETest_peaks.getPeak(p).getQSampleFrame(),
atol=0.005,
err_msg=f"mismatch for peak {p}")
class ConvertHFIRSCDtoMDE_HB3A_Test(systemtesting.MantidSystemTest):
def requiredMemoryMB(self):
......@@ -70,6 +81,15 @@ class ConvertHFIRSCDtoMDE_HB3A_Test(systemtesting.MantidSystemTest):
np.testing.assert_allclose(peak.getQSampleFrame(), [-0.417683, 1.792265, 2.238072], rtol=1e-5)
np.testing.assert_array_equal(peak.getHKL(), [0, 0, 6])
# new method using multiple goniometers, q_sample should be the same as above method
ConvertHFIRSCDtoMDETest_peaks2 = FindPeaksMD(InputWorkspace='ConvertHFIRSCDtoMDETest_Q',
PeakDistanceThreshold=0.25,
DensityThresholdFactor=20000)
self.assertEqual(ConvertHFIRSCDtoMDETest_peaks2.getNumberPeaks(), 1)
np.testing.assert_allclose(ConvertHFIRSCDtoMDETest_peaks2.getPeak(0).getQSampleFrame(),
[-0.417683, 1.792265, 2.238072], rtol=1e-3)
def validate(self):
results = 'ConvertHFIRSCDtoMDETest_Q'
reference = 'ConvertHFIRSCDtoMDE_HB3A_Test.nxs'
......
......@@ -55,6 +55,7 @@ Improvements
- :ref:`SNSPowderReduction <algm-SNSPowderReduction>` now check if previous container is created using the same method before reusing it.
- :ref:`SCDCalibratePanels <algm-SCDCalibratePanels-v2>` now update attached UB matrix with given lattice constants (optional).
- :ref:`FilterPeaks <algm-FilterPeaks>` now can select banks in addition to filtering by values.
- :ref:`FindPeaksMD <algm-FindPeaksMD>` has been modified to make use of the multiple goniometers add to :ref:`Run <mantid.api.Run>` and `goniometerIndex` add to MDEvents.
Known Defects
#############
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment