Unverified Commit 3f6cc46c authored by Jose Borreguero's avatar Jose Borreguero Committed by GitHub
Browse files

Merge pull request #30874 from mantidproject/30857_ipeak_cleanup

Cleanup IPeak interface: remove findDetector
parents 7d3a2f10 8d7636ca
......@@ -35,6 +35,10 @@ using namespace Mantid::Kernel;
namespace Crystal {
// handy shortcuts
using Mantid::DataObjects::Peak_uptr;
using Mantid::Geometry::IPeak_uptr;
DECLARE_ALGORITHM(PredictSatellitePeaks)
/** Constructor
......@@ -358,7 +362,8 @@ void PredictSatellitePeaks::predictOffsets(
if (Qs.Z() * m_qConventionFactor <= 0)
continue;
auto peak(Peaks->createPeak(Qs, 1));
IPeak_uptr iPeak = Peaks->createPeak(Qs, 1);
Peak_uptr peak(static_cast<DataObjects::Peak *>(iPeak.release()));
peak->setGoniometerMatrix(goniometer);
......@@ -430,7 +435,8 @@ void PredictSatellitePeaks::predictOffsetsWithCrossTerms(
if (Qs.Z() * m_qConventionFactor <= 0)
continue;
auto peak(Peaks->createPeak(Qs, 1));
IPeak_uptr iPeak(Peaks->createPeak(Qs, 1));
Peak_uptr peak(static_cast<DataObjects::Peak *>(iPeak.release()));
peak->setGoniometerMatrix(goniometer);
......
......@@ -66,9 +66,6 @@ public:
std::shared_ptr<const Geometry::ReferenceFrame>
getReferenceFrame() const override;
bool findDetector() override;
bool findDetector(const Geometry::InstrumentRayTracer &) override;
void setSamplePos(double, double, double) override;
void setSamplePos(const Mantid::Kernel::V3D &) override;
......
......@@ -91,8 +91,12 @@ public:
std::shared_ptr<const Geometry::ReferenceFrame>
getReferenceFrame() const override;
/*
bool findDetector() override;
bool findDetector(const Geometry::InstrumentRayTracer &tracer) override;
*/
bool findDetector();
bool findDetector(const Geometry::InstrumentRayTracer &tracer);
void setSamplePos(double samX, double samY, double samZ) override;
void setSamplePos(const Mantid::Kernel::V3D &XYZ) override;
......@@ -166,5 +170,7 @@ private:
static Mantid::Kernel::Logger g_log;
};
using Peak_uptr = std::unique_ptr<Peak>;
} // namespace DataObjects
} // namespace Mantid
......@@ -340,32 +340,6 @@ LeanElasticPeak &LeanElasticPeak::operator=(const LeanElasticPeak &other) {
return *this;
}
/** After creating a peak using the Q in the lab frame,
* the detPos is set to the direction of the detector (but the detector is
*unknown)
*
* Using the instrument set in the peak, perform ray tracing
* to find the exact detector.
*
* @return true if the detector ID was found.
*/
bool LeanElasticPeak::findDetector() {
throw Exception::NotImplementedError(
"LeanElasticPeak has no detector information");
}
/**
* Performs the same algorithm as findDetector() but uses a pre-existing
* InstrumentRayTracer object to be able to take adavtange of its caches.
* This method should be preferred if findDetector is to be called many times
* over the same instrument.
* @return true if the detector ID was found.
*/
bool LeanElasticPeak::findDetector(const InstrumentRayTracer &) {
throw Exception::NotImplementedError(
"LeanElasticPeak has no detector information");
}
/**
Forwarding function. Exposes the detector position directly.
*/
......
......@@ -390,7 +390,9 @@ PeaksWorkspace::peakInfo(const Kernel::V3D &qFrame, bool labCoords) const {
}
try {
auto peak = createPeak(Qlab);
IPeak_uptr iPeak = createPeak(Qlab);
Peak_uptr peak(static_cast<DataObjects::Peak *>(iPeak.release()));
if (sample().hasOrientedLattice()) {
peak->setGoniometerMatrix(Gon);
......
......@@ -41,7 +41,6 @@ public:
TS_ASSERT_THROWS(p.getDetectorID(), const Exception::NotImplementedError &)
TS_ASSERT_THROWS(p.getDetector(), const Exception::NotImplementedError &)
TS_ASSERT_THROWS(p.getInstrument(), const Exception::NotImplementedError &)
TS_ASSERT_THROWS(p.findDetector(), const Exception::NotImplementedError &)
TS_ASSERT_THROWS(p.getDetectorPosition(),
const Exception::NotImplementedError &)
TS_ASSERT_THROWS(p.getDetectorPositionNoCheck(),
......
......@@ -62,9 +62,6 @@ public:
virtual Mantid::Kernel::V3D getQLabFrame() const = 0;
virtual Mantid::Kernel::V3D getQSampleFrame() const = 0;
virtual bool findDetector() = 0;
virtual bool findDetector(const InstrumentRayTracer &tracer) = 0;
virtual void setQSampleFrame(const Mantid::Kernel::V3D &QSampleFrame,
boost::optional<double> detectorDistance) = 0;
virtual void setQLabFrame(const Mantid::Kernel::V3D &QLabFrame,
......@@ -116,5 +113,7 @@ public:
virtual double getAbsorptionWeightedPathLength() const = 0;
};
using IPeak_uptr = std::unique_ptr<IPeak>;
} // namespace Geometry
} // namespace Mantid
......@@ -97,9 +97,6 @@ public:
MOCK_METHOD1(setSamplePos, void(const Mantid::Kernel::V3D &XYZ));
MOCK_CONST_METHOD0(getQLabFrame, Mantid::Kernel::V3D());
MOCK_CONST_METHOD0(getQSampleFrame, Mantid::Kernel::V3D());
MOCK_METHOD0(findDetector, bool());
MOCK_METHOD1(findDetector,
bool(const Mantid::Geometry::InstrumentRayTracer &tracer));
MOCK_METHOD2(setQSampleFrame, void(const Mantid::Kernel::V3D &QSampleFrame,
boost::optional<double> detectorDistance));
MOCK_METHOD2(setQLabFrame, void(const Mantid::Kernel::V3D &QLabFrame,
......
......@@ -99,8 +99,7 @@ void CentroidPeaksMD::integrate(typename MDEventWorkspace<MDE, nd>::sptr ws) {
// cppcheck-suppress syntaxError
PRAGMA_OMP(parallel for schedule(dynamic, 10) )
for (int i = 0; i < int(peakWS->getNumberPeaks()); ++i) {
// Get a direct ref to that peak.
IPeak &p = peakWS->getPeak(i);
Peak &p = peakWS->getPeak(i);
double detectorDistance = p.getL2();
// Get the peak center as a position in the dimensions of the workspace
......
......@@ -83,7 +83,7 @@ void CentroidPeaksMD2::integrate(typename MDEventWorkspace<MDE, nd>::sptr ws) {
PRAGMA_OMP(parallel for schedule(dynamic, 10) )
for (int i = 0; i < int(peakWS->getNumberPeaks()); ++i) {
// Get a direct ref to that peak.
IPeak &p = peakWS->getPeak(i);
Peak &p = peakWS->getPeak(i);
double detectorDistance = p.getL2();
// Get the peak center as a position in the dimensions of the workspace
......
......@@ -123,11 +123,6 @@ void export_IPeak() {
":class:`~mantid.geometry.Goniometer` rotation was NOT taken "
"out.\n"
"Note: There is no 2*pi factor used, so \\|Q| = 1/wavelength.")
.def("findDetector", (bool (IPeak::*)()) & IPeak::findDetector,
arg("self"),
"Using the :class:`~mantid.geometry.Instrument` set in the peak, "
"perform ray tracing to find "
"the exact :class:`~mantid.geometry.Detector`.")
.def("getQSampleFrame", &IPeak::getQSampleFrame, arg("self"),
"Return the Q change (of the lattice, k_i - k_f) for this peak."
"The Q is in the Sample frame: the "
......
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