Commit fca79c49 authored by Samuel Jackson's avatar Samuel Jackson
Browse files

Refs #18920 Fix issues from code review

parent e4923b8a
......@@ -63,6 +63,8 @@ private:
const Kernel::DblMatrix &goniometerMatrix);
private:
void logNumberOfPeaksFound(size_t allowedPeakCount) const;
/// Reflection conditions possible
std::vector<Mantid::Geometry::ReflectionCondition_sptr> m_refConds;
......
......@@ -102,10 +102,6 @@ void PredictPeaks::init() {
"checked.\n"
"Keep unchecked to use the original values");
declareProperty("PredictPeaksOutsideDetectors", false,
"Use an extended detector space (if defined for the"
" instrument) to predict peaks which do not fall onto any"
"detector. This may produce a very high number of results.");
setPropertySettings("RoundHKL", make_unique<EnabledWhenProperty>(
"HKLPeaksWorkspace", IS_NOT_DEFAULT));
......@@ -125,6 +121,11 @@ void PredictPeaks::init() {
declareProperty(make_unique<WorkspaceProperty<PeaksWorkspace>>(
"OutputWorkspace", "", Direction::Output),
"An output PeaksWorkspace.");
declareProperty("PredictPeaksOutsideDetectors", false,
"Use an extended detector space (if defined for the"
" instrument) to predict peaks which do not fall onto any"
"detector. This may produce a very high number of results.");
}
/** Execute the algorithm.
......@@ -261,7 +262,7 @@ void PredictPeaks::exec() {
bool useExtendedDetectorSpace = getProperty("PredictPeaksOutsideDetectors");
if (useExtendedDetectorSpace &&
!m_inst->getComponentByName("extended-detector-space")) {
g_log.warning() << "Attempting to find peaks outside of detectors but"
g_log.warning() << "Attempting to find peaks outside of detectors but "
"no extended detector space has been defined";
}
......@@ -273,15 +274,44 @@ void PredictPeaks::exec() {
prog.report();
}
g_log.notice() << "Out of " << allowedPeakCount
<< " allowed peaks within parameters, "
<< m_pw->getNumberPeaks()
<< " were found to hit a detector.\n";
logNumberOfPeaksFound(allowedPeakCount);
}
setProperty<PeaksWorkspace_sptr>("OutputWorkspace", m_pw);
}
/**
* Log the number of peaks found to fall on and off detectors
*
* @param allowedPeakCount :: number of candidate peaks found
*/
void PredictPeaks::logNumberOfPeaksFound(size_t allowedPeakCount) const {
const bool usingExtendedDetectorSpace =
getProperty("PredictPeaksOutsideDetectors");
const auto &peaks = m_pw->getPeaks();
size_t offDetectorPeakCount = 0;
size_t onDetectorPeakCount = 0;
for (const auto &peak : peaks) {
if (peak.getDetectorID() == -1) {
offDetectorPeakCount++;
} else {
onDetectorPeakCount++;
}
}
g_log.notice() << "Out of " << allowedPeakCount
<< " allowed peaks within parameters, " << onDetectorPeakCount
<< " were found to hit a detector ";
if (usingExtendedDetectorSpace) {
g_log.notice() << " and " << offDetectorPeakCount << " were found in "
<< "extended detector space.";
}
g_log.notice() << "\n";
}
/// Tries to set the internally stored instrument from an ExperimentInfo-object.
void PredictPeaks::setInstrumentFromInputWorkspace(
const ExperimentInfo_sptr &inWS) {
......
......@@ -381,10 +381,10 @@ public:
ComponentCreationHelper::createTestInstrumentRectangular(5, 100);
auto extendedSpaceObj =
ComponentCreationHelper::createSphere(10., V3D(0, 0, 0));
auto extendedSpace = new ObjComponent("extended-detector-space",
extendedSpaceObj, sphereInst.get());
auto extendedSpace = std::make_unique<ObjComponent>(
"extended-detector-space", extendedSpaceObj, sphereInst.get());
extendedSpace->setPos(V3D(0.0, 0.0, 0.0));
sphereInst->add(extendedSpace);
sphereInst->add(extendedSpace.release());
const auto refFrame = sphereInst->getReferenceFrame();
const auto refBeamDir = refFrame->vecPointingAlongBeam();
......@@ -458,10 +458,10 @@ public:
ComponentCreationHelper::createTestInstrumentRectangular(5, 100);
auto extendedSpaceObj =
ComponentCreationHelper::createSphere(10., V3D(0, 0, 0));
auto extendedSpace = new ObjComponent("extended-detector-space",
extendedSpaceObj, sphereInst.get());
auto extendedSpace = std::make_unique<ObjComponent>(
"extended-detector-space", extendedSpaceObj, sphereInst.get());
extendedSpace->setPos(V3D(0.0, 0.0, 0.0));
sphereInst->add(extendedSpace);
sphereInst->add(extendedSpace.release());
// test with & without extended detector space
// extended space is a sphere, so all points should fall radius*detector
......
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