Commit 4c61d864 authored by Sullivan, Brendan T's avatar Sullivan, Brendan T
Browse files

Re #24314 set optimizecrystalplacement to update peak sample pos

parent a111af00
......@@ -449,7 +449,7 @@ void OptimizeCrystalPlacement::exec() {
UBinv.Invert();
UBinv /= (2 * M_PI);
for (int i = 0; i < outPeaks->getNumberPeaks(); ++i) {
outPeaks->getPeak(i).setSamplePos(newSampPos);
int RunNum = outPeaks->getPeak(i).getRunNumber();
std::string RunNumStr = std::to_string(RunNum);
Matrix<double> GonMatrix;
......
......@@ -110,6 +110,8 @@ public:
void setBankName(std::string m_bankName);
void setHKL(double H, double K, double L) override;
void setHKL(const Mantid::Kernel::V3D &HKL) override;
void setSamplePos(double samX, double samY, double samZ) override;
void setSamplePos(const Mantid::Kernel::V3D &XYZ) override;
void resetHKL();
Mantid::Kernel::V3D getQLabFrame() const override;
......@@ -160,6 +162,7 @@ public:
int getPeakNumber() const override;
virtual Mantid::Kernel::V3D getDetPos() const override;
virtual Mantid::Kernel::V3D getSamplePos() const override;
double getL1() const override;
double getL2() const override;
......
......@@ -811,6 +811,30 @@ void Peak::setHKL(const Mantid::Kernel::V3D &HKL) {
m_L = HKL.Z();
}
/** Set sample position
*
* @ doubles x,y,z-> samplePos(x), samplePos(y), samplePos(z)
*/
void Peak::setSamplePos(double samX, double samY, double samZ) {
this->samplePos[0] = samX;
this->samplePos[1] = samY;
this->samplePos[2] = samZ;
}
/** Set sample position
*
* @param XYZ :: vector x,y,z-> samplePos(x), samplePos(y), samplePos(z)
*/
void Peak::setSamplePos(const Mantid::Kernel::V3D & XYZ) {
this->samplePos[0] = XYZ[0];
this->samplePos[1] = XYZ[1];
this->samplePos[2] = XYZ[2];
}
//----------------------------------------------------------------------------------------------
/** Return the # of counts in the bin at its peak*/
double Peak::getBinCount() const { return m_binCount; }
......@@ -923,6 +947,10 @@ void Peak::setPeakNumber(int m_peakNumber) {
/** Return the detector position vector */
Mantid::Kernel::V3D Peak::getDetPos() const { return detPos; }
// -------------------------------------------------------------------------------------
/** Return the sample position vector */
Mantid::Kernel::V3D Peak::getSamplePos() const { return samplePos; }
// -------------------------------------------------------------------------------------
/** Return the L1 flight path length (source to sample), in meters. */
double Peak::getL1() const { return (samplePos - sourcePos).norm(); }
......
......@@ -45,11 +45,14 @@ public:
virtual double getK() const = 0;
virtual double getL() const = 0;
virtual Mantid::Kernel::V3D getHKL() const = 0;
virtual Mantid::Kernel::V3D getSamplePos() const = 0;
virtual void setH(double m_H) = 0;
virtual void setK(double m_K) = 0;
virtual void setL(double m_L) = 0;
virtual void setHKL(double H, double K, double L) = 0;
virtual void setHKL(const Mantid::Kernel::V3D &HKL) = 0;
virtual void setSamplePos(double samX, double samY, double samZ) = 0;
virtual void setSamplePos(const Mantid::Kernel::V3D &XYZ) = 0;
virtual Mantid::Kernel::V3D getDetectorPosition() const = 0;
virtual Mantid::Kernel::V3D getDetectorPositionNoCheck() const = 0;
......
......@@ -87,9 +87,14 @@ void export_IPeak() {
.def("getL", &IPeak::getL, arg("self"), "Get the L index of the peak")
.def("getHKL", &IPeak::getHKL, arg("self"),
"Get HKL as a :class:`~mantid.kernel.V3D` object")
.def("getSamplePos", &IPeak::getSamplePos, arg("self"),
"Get the cached samplePos as a :class:`~mantid.kernel.V3D` object")
.def("setHKL", (void (IPeak::*)(double, double, double)) & IPeak::setHKL,
(arg("self"), arg("h"), arg("k"), arg("l")),
"Set the HKL values of this peak")
.def("setSamplePos", (void (IPeak::*)(double, double, double)) & IPeak::setSamplePos,
(arg("self"), arg("samX"), arg("samY"), arg("samZ")),
"Set the samplePos value of this peak. It does not set the instrument sample position.")
.def("setH", &IPeak::setH, (arg("self"), arg("h")),
"Get the H index of the peak")
.def("setK", &IPeak::setK, (arg("self"), arg("k")),
......
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