Commit bb9915dd authored by Martyn Gigg's avatar Martyn Gigg
Browse files

Use IObject::distance to compute virtual peak position

For some peaks not on a detector the intersection code
can given false positives that not intersection is
possible due to precision issues. In our case we only
need the distance to any intersection point on the surface
regardless of whether it is an entry/exit/undefined type
of track.
Refs #26690
parent a17486d2
......@@ -203,7 +203,8 @@ predictPeaks(Algorithm *const alg, const std::vector<double> &hOffsets,
std::unique_ptr<IPeak> peak;
try {
peak = inputPeaks.createPeak(qLab);
} catch (std::invalid_argument &) {
} catch (...) {
// If we can't create a valid peak we have no choice but to skip it
......@@ -9,6 +9,7 @@
#include "MantidGeometry/Instrument/RectangularDetector.h"
#include "MantidGeometry/Instrument/ReferenceFrame.h"
#include "MantidGeometry/Objects/InstrumentRayTracer.h"
#include "MantidGeometry/Surfaces/LineIntersectVisit.h"
#include "MantidKernel/ConfigService.h"
#include "MantidKernel/Exception.h"
#include "MantidKernel/Strings.h"
......@@ -629,12 +630,11 @@ V3D Peak::getVirtualDetectorPosition(const V3D &detectorDir) const {
if (!component) {
return detectorDir; // the best idea we have is just the direction
const auto object =
boost::dynamic_pointer_cast<const ObjComponent>(component);
Geometry::Track track(samplePos, detectorDir);
return track.back().exitPoint;
const auto distance =
object->shape()->distance(Geometry::Track(samplePos, detectorDir));
return detectorDir * distance;
/** After creating a peak using the Q in the lab frame,
......@@ -262,7 +262,7 @@ int MeshObject2D::interceptSurface(Geometry::Track &ut) const {
* Compute the distance to the first point of intersection with the mesh
* @param track Track defining start/direction
* @param ut Track defining start/direction
* @return The distance to the object
* @throws std::runtime_error if no intersection was found
Supports Markdown
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