diff --git a/Framework/DataObjects/inc/MantidDataObjects/BasePeak.h b/Framework/DataObjects/inc/MantidDataObjects/BasePeak.h index 68e1167512b779540f114c87c24a041b4cb641c6..7cd806d36d33e9659143b1b1192621b0e7e6530e 100644 --- a/Framework/DataObjects/inc/MantidDataObjects/BasePeak.h +++ b/Framework/DataObjects/inc/MantidDataObjects/BasePeak.h @@ -75,6 +75,10 @@ public: void setIntHKL(const Kernel::V3D &HKL) override; void setIntMNP(const Mantid::Kernel::V3D &MNP) override; + Mantid::Kernel::V3D getSamplePos() const override; + void setSamplePos(double samX, double samY, double samZ) override; + void setSamplePos(const Mantid::Kernel::V3D &XYZ) override; + double getIntensity() const override; double getSigmaIntensity() const override; double getIntensityOverSigma() const override; @@ -121,6 +125,9 @@ protected: // ki-kf for Inelastic convention; kf-ki for Crystallography convention std::string convention; + /// Cached sample position + Mantid::Kernel::V3D m_samplePos; + private: /// Name of the parent bank std::string m_bankName; diff --git a/Framework/DataObjects/inc/MantidDataObjects/LeanElasticPeak.h b/Framework/DataObjects/inc/MantidDataObjects/LeanElasticPeak.h index 70be75f466250ca230a6c7594ee2205d2bb4f6d8..decb5449d98e1615c096c1e9cdb92856fa7c35e8 100644 --- a/Framework/DataObjects/inc/MantidDataObjects/LeanElasticPeak.h +++ b/Framework/DataObjects/inc/MantidDataObjects/LeanElasticPeak.h @@ -60,9 +60,6 @@ public: std::shared_ptr<const Geometry::ReferenceFrame> getReferenceFrame() const override; - void setSamplePos(double, double, double) override; - void setSamplePos(const Mantid::Kernel::V3D &) override; - Mantid::Kernel::V3D getQLabFrame() const override; Mantid::Kernel::V3D getQSampleFrame() const override; @@ -86,7 +83,6 @@ public: void setInitialEnergy(double m_initialEnergy) override; void setFinalEnergy(double m_finalEnergy) override; - virtual Mantid::Kernel::V3D getSamplePos() const override; double getL1() const override; double getL2() const override; diff --git a/Framework/DataObjects/inc/MantidDataObjects/Peak.h b/Framework/DataObjects/inc/MantidDataObjects/Peak.h index 7aad8c7984a4babb970ace7ce8e2e95008e0b68a..3b34bfed86480245b1ddbb4ed5a4ce7fd68da0f2 100644 --- a/Framework/DataObjects/inc/MantidDataObjects/Peak.h +++ b/Framework/DataObjects/inc/MantidDataObjects/Peak.h @@ -93,9 +93,6 @@ public: 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; - Mantid::Kernel::V3D getQLabFrame() const override; Mantid::Kernel::V3D getQSampleFrame() const override; Mantid::Kernel::V3D getDetectorPosition() const; @@ -122,7 +119,6 @@ public: void setFinalEnergy(double m_finalEnergy) override; virtual Mantid::Kernel::V3D getDetPos() const; - virtual Mantid::Kernel::V3D getSamplePos() const override; double getL1() const override; double getL2() const override; @@ -155,8 +151,7 @@ private: /// Cached source position Mantid::Kernel::V3D sourcePos; - /// Cached sample position - Mantid::Kernel::V3D samplePos; + /// Cached detector position Mantid::Kernel::V3D detPos; diff --git a/Framework/DataObjects/src/BasePeak.cpp b/Framework/DataObjects/src/BasePeak.cpp index 8373a048780f227019c9cc757060b9b9f9b9a2dd..b3b4cdc98670eed99b06cd1f6954852d1479e6e2 100644 --- a/Framework/DataObjects/src/BasePeak.cpp +++ b/Framework/DataObjects/src/BasePeak.cpp @@ -31,8 +31,8 @@ namespace DataObjects { //---------------------------------------------------------------------------------------------- /** Default constructor */ BasePeak::BasePeak() - : m_H(0), m_K(0), m_L(0), m_intensity(0), m_sigmaIntensity(0), - m_binCount(0), m_absorptionWeightedPathLength(0), + : m_samplePos(V3D(0, 0, 0)), m_H(0), m_K(0), m_L(0), m_intensity(0), + m_sigmaIntensity(0), m_binCount(0), m_absorptionWeightedPathLength(0), m_GoniometerMatrix(3, 3, true), m_InverseGoniometerMatrix(3, 3, true), m_runNumber(0), m_monitorCount(0), m_row(-1), m_col(-1), m_peakNumber(0), m_intHKL(V3D(0, 0, 0)), m_intMNP(V3D(0, 0, 0)), @@ -60,10 +60,10 @@ BasePeak::BasePeak(const Mantid::Kernel::Matrix<double> &goniometer) } BasePeak::BasePeak(const BasePeak &other) - : convention(other.convention), m_bankName(other.m_bankName), - m_H(other.m_H), m_K(other.m_K), m_L(other.m_L), - m_intensity(other.m_intensity), m_sigmaIntensity(other.m_sigmaIntensity), - m_binCount(other.m_binCount), + : convention(other.convention), m_samplePos(other.m_samplePos), + m_bankName(other.m_bankName), m_H(other.m_H), m_K(other.m_K), + m_L(other.m_L), m_intensity(other.m_intensity), + m_sigmaIntensity(other.m_sigmaIntensity), m_binCount(other.m_binCount), m_absorptionWeightedPathLength(other.m_absorptionWeightedPathLength), m_GoniometerMatrix(other.m_GoniometerMatrix), m_InverseGoniometerMatrix(other.m_InverseGoniometerMatrix), @@ -192,6 +192,31 @@ void BasePeak::setIntMNP(const V3D &MNP) { m_intMNP = V3D(std::round(MNP[0]), std::round(MNP[1]), std::round(MNP[2])); } +/** Return the sample position vector */ +Mantid::Kernel::V3D BasePeak::getSamplePos() const { return m_samplePos; } + +/** Set sample position + * + * @ doubles x,y,z-> m_samplePos(x), m_samplePos(y), m_samplePos(z) + */ +void BasePeak::setSamplePos(double samX, double samY, double samZ) { + + this->m_samplePos[0] = samX; + this->m_samplePos[1] = samY; + this->m_samplePos[2] = samZ; +} + +/** Set sample position + * + * @param XYZ :: vector x,y,z-> m_samplePos(x), m_samplePos(y), m_samplePos(z) + */ +void BasePeak::setSamplePos(const Mantid::Kernel::V3D &XYZ) { + + this->m_samplePos[0] = XYZ[0]; + this->m_samplePos[1] = XYZ[1]; + this->m_samplePos[2] = XYZ[2]; +} + //---------------------------------------------------------------------------------------------- /** Return the # of counts in the bin at its peak*/ double BasePeak::getBinCount() const { return m_binCount; } diff --git a/Framework/DataObjects/src/LeanElasticPeak.cpp b/Framework/DataObjects/src/LeanElasticPeak.cpp index 6496765f1d33a5e422d83881343423d582391728..0864a4617f8de75cada6ee78991eff713acd6bdc 100644 --- a/Framework/DataObjects/src/LeanElasticPeak.cpp +++ b/Framework/DataObjects/src/LeanElasticPeak.cpp @@ -234,18 +234,6 @@ double LeanElasticPeak::getInitialEnergy() const { return getFinalEnergy(); } * elastic so always 0 */ double LeanElasticPeak::getEnergyTransfer() const { return 0.; } -/** Set sample position */ -void LeanElasticPeak::setSamplePos(double, double, double) { - throw Exception::NotImplementedError( - "LeanElasticPeak has no sample information"); -} - -/** Set sample position */ -void LeanElasticPeak::setSamplePos(const Mantid::Kernel::V3D &) { - throw Exception::NotImplementedError( - "LeanElasticPeak has no sample information"); -} - /** Set the final energy */ void LeanElasticPeak::setFinalEnergy(double) { throw Exception::NotImplementedError("Use LeanElasticPeak::setWavelength"); @@ -256,13 +244,6 @@ void LeanElasticPeak::setInitialEnergy(double) { throw Exception::NotImplementedError("Use LeanElasticPeak::setWavelength"); } -// ------------------------------------------------------------------------------------- -/** Return the sample position vector */ -Mantid::Kernel::V3D LeanElasticPeak::getSamplePos() const { - throw Exception::NotImplementedError( - "LeanElasticPeak has no sample information"); -} - // ------------------------------------------------------------------------------------- /** Return the L1 flight path length (source to sample), in meters. */ double LeanElasticPeak::getL1() const { diff --git a/Framework/DataObjects/src/Peak.cpp b/Framework/DataObjects/src/Peak.cpp index 0f6107e62b0dadce310d30b2b29e2ea99fbd67c2..c32270b7ce4099e3851f94083d82220e3934fd0a 100644 --- a/Framework/DataObjects/src/Peak.cpp +++ b/Framework/DataObjects/src/Peak.cpp @@ -155,13 +155,13 @@ Peak::Peak(const Peak &other) : BasePeak(other), m_inst(other.m_inst), m_det(other.m_det), m_detectorID(other.m_detectorID), m_initialEnergy(other.m_initialEnergy), m_finalEnergy(other.m_finalEnergy), sourcePos(other.sourcePos), - samplePos(other.samplePos), detPos(other.detPos), - m_detIDs(other.m_detIDs) {} + detPos(other.detPos), m_detIDs(other.m_detIDs) {} //---------------------------------------------------------------------------------------------- /** Constructor making a Peak from IPeak interface * - * @param ipeak :: const reference to an IPeak object + * @param ipeak :: const reference to an IPeak object though actually + * referencing a Peak object. * @return */ Peak::Peak(const Geometry::IPeak &ipeak) @@ -320,7 +320,7 @@ void Peak::setInstrument(const Geometry::Instrument_const_sptr &inst) { "instrument"); sourcePos = sourceObj->getPos(); - samplePos = sampleObj->getPos(); + m_samplePos = sampleObj->getPos(); } //---------------------------------------------------------------------------------------------- @@ -377,8 +377,8 @@ double Peak::getTOF() const { /** Calculate the scattering angle of the peak */ double Peak::getScattering() const { // The detector is at 2 theta scattering angle - V3D beamDir = samplePos - sourcePos; - V3D detDir = detPos - samplePos; + V3D beamDir = m_samplePos - sourcePos; + V3D detDir = detPos - m_samplePos; return detDir.angle(beamDir); } @@ -387,7 +387,7 @@ double Peak::getScattering() const { /** Calculate the azimuthal angle of the peak */ double Peak::getAzimuthal() const { // The detector is at 2 theta scattering angle - V3D detDir = detPos - samplePos; + V3D detDir = detPos - m_samplePos; return atan2(detDir.Y(), detDir.X()); } @@ -396,8 +396,8 @@ double Peak::getAzimuthal() const { /** Calculate the d-spacing of the peak, in 1/Angstroms */ double Peak::getDSpacing() const { // The detector is at 2 theta scattering angle - V3D beamDir = samplePos - sourcePos; - V3D detDir = detPos - samplePos; + V3D beamDir = m_samplePos - sourcePos; + V3D detDir = detPos - m_samplePos; double two_theta; try { @@ -423,10 +423,10 @@ double Peak::getDSpacing() const { * */ Mantid::Kernel::V3D Peak::getQLabFrame() const { // Normalized beam direction - V3D beamDir = samplePos - sourcePos; + V3D beamDir = m_samplePos - sourcePos; beamDir /= beamDir.norm(); // Normalized detector direction - V3D detDir = (detPos - samplePos); + V3D detDir = (detPos - m_samplePos); detDir /= detDir.norm(); // Energy in J of the neutron @@ -550,7 +550,7 @@ void Peak::setQLabFrame(const Mantid::Kernel::V3D &qLab, // Use the given detector distance to find the detector position. if (detectorDistance.is_initialized()) { - detPos = samplePos + detectorDir * detectorDistance.get(); + detPos = m_samplePos + detectorDir * detectorDistance.get(); // We do not-update the detector as by manually setting the distance the // client seems to know better. } else { @@ -576,7 +576,7 @@ V3D Peak::getVirtualDetectorPosition(const V3D &detectorDir) const { } const auto object = std::dynamic_pointer_cast<const ObjComponent>(component); const auto distance = - object->shape()->distance(Geometry::Track(samplePos, detectorDir)); + object->shape()->distance(Geometry::Track(m_samplePos, detectorDir)); return detectorDir * distance; } @@ -612,7 +612,7 @@ bool Peak::findDetector() { */ bool Peak::findDetector(const InstrumentRayTracer &tracer) { // Scattered beam direction - const V3D beam = normalize(detPos - samplePos); + const V3D beam = normalize(detPos - m_samplePos); return findDetector(beam, tracer); } @@ -680,28 +680,6 @@ double Peak::getEnergyTransfer() const { return getInitialEnergy() - getFinalEnergy(); } -/** 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]; -} - /** Set the final energy * @param m_finalEnergy :: final energy in meV */ void Peak::setFinalEnergy(double m_finalEnergy) { @@ -718,17 +696,13 @@ void Peak::setInitialEnergy(double m_initialEnergy) { /** 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(); } +double Peak::getL1() const { return (m_samplePos - sourcePos).norm(); } // ------------------------------------------------------------------------------------- /** Return the L2 flight path length (sample to detector), in meters. */ -double Peak::getL2() const { return (detPos - samplePos).norm(); } +double Peak::getL2() const { return (detPos - m_samplePos).norm(); } /** * @brief Assignement operator overload @@ -744,7 +718,7 @@ Peak &Peak::operator=(const Peak &other) { m_initialEnergy = other.m_initialEnergy; m_finalEnergy = other.m_finalEnergy; sourcePos = other.sourcePos; - samplePos = other.samplePos; + m_samplePos = other.m_samplePos; detPos = other.detPos; m_detIDs = other.m_detIDs; } diff --git a/Framework/DataObjects/test/LeanElasticPeakTest.h b/Framework/DataObjects/test/LeanElasticPeakTest.h index 2508c532ca23be1358b58beaac3e845d63b70a74..23c0e512d3642623ff45f56019d37dea21b92493 100644 --- a/Framework/DataObjects/test/LeanElasticPeakTest.h +++ b/Framework/DataObjects/test/LeanElasticPeakTest.h @@ -37,7 +37,7 @@ public: TS_ASSERT(std::isinf(p.getFinalEnergy())) TS_ASSERT_EQUALS(p.getQSampleFrame(), V3D(0, 0, 0)) TS_ASSERT_EQUALS(p.getQLabFrame(), V3D()) - TS_ASSERT_THROWS(p.getSamplePos(), const Exception::NotImplementedError &) + TS_ASSERT_EQUALS(p.getSamplePos(), V3D(0, 0, 0)) TS_ASSERT_THROWS(p.getTOF(), const Exception::NotImplementedError &) TS_ASSERT_EQUALS(p.getScattering(), 0.) TS_ASSERT_EQUALS(p.getAzimuthal(), -M_PI) diff --git a/Framework/PythonInterface/plugins/algorithms/IntegratePeaksProfileFitting.py b/Framework/PythonInterface/plugins/algorithms/IntegratePeaksProfileFitting.py index 318c8e11c8512fdc91bde8a9704a8f130c82f238..b9043d2e9b634deb6c1f59c8bf0de18c2061c3f8 100644 --- a/Framework/PythonInterface/plugins/algorithms/IntegratePeaksProfileFitting.py +++ b/Framework/PythonInterface/plugins/algorithms/IntegratePeaksProfileFitting.py @@ -260,7 +260,7 @@ class IntegratePeaksProfileFitting(PythonAlgorithm): strongPeakParamsToSend = strongPeakParams # Will allow forced weak and edge peaks to be fit using a neighboring peak profile - Y3D, goodIDX, pp_lambda, params = BVGFT.get3DPeak(peak, peaks_ws, box, padeCoefficients,qMask, + Y3D, goodIDX, pp_lambda, params = BVGFT.get3DPeak(peak, peaks_ws, box, padeCoefficients, qMask, nTheta=nTheta, nPhi=nPhi, plotResults=False, zBG=zBG,fracBoxToHistogram=1.0,bgPolyOrder=1, strongPeakParams=strongPeakParamsToSend,