diff --git a/Framework/Crystal/src/SCDPanelErrors.cpp b/Framework/Crystal/src/SCDPanelErrors.cpp index 9d70f6105b38ced43ba32d01aa5d8545905161c3..bc992ba2c64e795c42860f8451ffe1ddf5677eb3 100644 --- a/Framework/Crystal/src/SCDPanelErrors.cpp +++ b/Framework/Crystal/src/SCDPanelErrors.cpp @@ -165,14 +165,13 @@ void SCDPanelErrors::eval(double xshift, double yshift, double zshift, moveDetector(xshift, yshift, zshift, xrotate, yrotate, zrotate, scalex, scaley, m_bank, m_workspace); - DataObjects::PeaksWorkspace_sptr inputP = + auto inputP = boost::dynamic_pointer_cast<DataObjects::PeaksWorkspace>(m_workspace); - Geometry::Instrument_sptr inst = - boost::const_pointer_cast<Geometry::Instrument>(inputP->getInstrument()); + auto inst = inputP->getInstrument(); Geometry::OrientedLattice lattice = inputP->mutableSample().getOrientedLattice(); for (int i = 0; i < inputP->getNumberPeaks(); i++) { - DataObjects::Peak peak = inputP->getPeak(i); + const DataObjects::Peak &peak = inputP->getPeak(i); V3D hkl = V3D(boost::math::iround(peak.getH()), boost::math::iround(peak.getK()), boost::math::iround(peak.getL())); diff --git a/Framework/DataObjects/inc/MantidDataObjects/Peak.h b/Framework/DataObjects/inc/MantidDataObjects/Peak.h index ca7594d005f97bbc2c97decc53ec69c948289c84..997fbeee2ff8158d0351b0ca16035b87d55e4008 100644 --- a/Framework/DataObjects/inc/MantidDataObjects/Peak.h +++ b/Framework/DataObjects/inc/MantidDataObjects/Peak.h @@ -28,9 +28,11 @@ public: Peak(); Peak(Geometry::Instrument_const_sptr m_inst, Mantid::Kernel::V3D QLabFrame, boost::optional<double> detectorDistance = boost::optional<double>()); - Peak(Geometry::Instrument_const_sptr m_inst, Mantid::Kernel::V3D QSampleFrame, - Mantid::Kernel::Matrix<double> goniometer, - boost::optional<double> detectorDistance = boost::optional<double>()); + Peak(const Geometry::Instrument_const_sptr &m_inst, + const Mantid::Kernel::V3D &QSampleFrame, + const Mantid::Kernel::Matrix<double> &goniometer, + const boost::optional<double> &detectorDistance = + boost::optional<double>()); Peak(Geometry::Instrument_const_sptr m_inst, int m_detectorID, double m_Wavelength); Peak(Geometry::Instrument_const_sptr m_inst, int m_detectorID, @@ -77,7 +79,7 @@ public: void setL(double m_L) override; void setBankName(std::string m_bankName); void setHKL(double H, double K, double L) override; - void setHKL(Mantid::Kernel::V3D HKL) override; + void setHKL(const Mantid::Kernel::V3D &HKL) override; void resetHKL(); Mantid::Kernel::V3D getQLabFrame() const override; @@ -85,11 +87,11 @@ public: Mantid::Kernel::V3D getDetectorPosition() const override; Mantid::Kernel::V3D getDetectorPositionNoCheck() const override; - void setQSampleFrame(Mantid::Kernel::V3D QSampleFrame, - boost::optional<double> detectorDistance = + void setQSampleFrame(const Mantid::Kernel::V3D &QSampleFrame, + const boost::optional<double> &detectorDistance = boost::optional<double>()) override; - void setQLabFrame(Mantid::Kernel::V3D QLabFrame, - boost::optional<double> detectorDistance = + void setQLabFrame(const Mantid::Kernel::V3D &QLabFrame, + const boost::optional<double> &detectorDistance = boost::optional<double>()) override; void setWavelength(double wavelength) override; @@ -113,8 +115,8 @@ public: void setBinCount(double m_binCount) override; Mantid::Kernel::Matrix<double> getGoniometerMatrix() const override; - void - setGoniometerMatrix(Mantid::Kernel::Matrix<double> goniometerMatrix) override; + void setGoniometerMatrix( + const Mantid::Kernel::Matrix<double> &goniometerMatrix) override; std::string getBankName() const override; int getRow() const override; diff --git a/Framework/DataObjects/src/Peak.cpp b/Framework/DataObjects/src/Peak.cpp index 92d58b45138e604a8f6ece31ab1376ecac10299f..cf9eaf3997cabc4cf6ccb08e2d970226bbcc23bf 100644 --- a/Framework/DataObjects/src/Peak.cpp +++ b/Framework/DataObjects/src/Peak.cpp @@ -69,10 +69,10 @@ Peak::Peak(Geometry::Instrument_const_sptr m_inst, *detector. Calculated if not explicitly provided. * Used to give a valid TOF. Default 1.0 meters. */ -Peak::Peak(Geometry::Instrument_const_sptr m_inst, - Mantid::Kernel::V3D QSampleFrame, - Mantid::Kernel::Matrix<double> goniometer, - boost::optional<double> detectorDistance) +Peak::Peak(const Geometry::Instrument_const_sptr &m_inst, + const Mantid::Kernel::V3D &QSampleFrame, + const Mantid::Kernel::Matrix<double> &goniometer, + const boost::optional<double> &detectorDistance) : m_H(0), m_K(0), m_L(0), m_intensity(0), m_sigmaIntensity(0), m_binCount(0), m_GoniometerMatrix(goniometer), m_InverseGoniometerMatrix(goniometer), m_runNumber(0), m_monitorCount(0), @@ -492,8 +492,8 @@ Mantid::Kernel::V3D Peak::getQSampleFrame() const { * @param detectorDistance :: distance between the sample and the detector. * Used to give a valid TOF. You do NOT need to explicitly set this. */ -void Peak::setQSampleFrame(Mantid::Kernel::V3D QSampleFrame, - boost::optional<double> detectorDistance) { +void Peak::setQSampleFrame(const Mantid::Kernel::V3D &QSampleFrame, + const boost::optional<double> &detectorDistance) { V3D Qlab = m_GoniometerMatrix * QSampleFrame; this->setQLabFrame(Qlab, detectorDistance); } @@ -514,8 +514,8 @@ void Peak::setQSampleFrame(Mantid::Kernel::V3D QSampleFrame, *this is provided. Then we do not * ray trace to find the intersecing detector. */ -void Peak::setQLabFrame(Mantid::Kernel::V3D QLabFrame, - boost::optional<double> detectorDistance) { +void Peak::setQLabFrame(const Mantid::Kernel::V3D &QLabFrame, + const boost::optional<double> &detectorDistance) { // Clear out the detector = we can't know them m_detectorID = -1; m_det = IDetector_sptr(); @@ -743,7 +743,7 @@ void Peak::resetHKL() { * * @param HKL :: vector with x,y,z -> h,k,l */ -void Peak::setHKL(Mantid::Kernel::V3D HKL) { +void Peak::setHKL(const Mantid::Kernel::V3D &HKL) { if (m_orig_H == 0 && m_orig_K == 0 && m_orig_L == 0) { m_orig_H = m_H; m_orig_K = m_K; @@ -801,7 +801,7 @@ Mantid::Kernel::Matrix<double> Peak::getGoniometerMatrix() const { * the goniometer * @throw std::invalid_argument if matrix is not 3x3*/ void Peak::setGoniometerMatrix( - Mantid::Kernel::Matrix<double> goniometerMatrix) { + const Mantid::Kernel::Matrix<double> &goniometerMatrix) { if ((goniometerMatrix.numCols() != 3) || (goniometerMatrix.numRows() != 3)) throw std::invalid_argument( "Peak::setGoniometerMatrix(): Goniometer matrix must be 3x3."); diff --git a/Framework/Geometry/inc/MantidGeometry/Crystal/IPeak.h b/Framework/Geometry/inc/MantidGeometry/Crystal/IPeak.h index e54d48ef936434a40bc28b65baac300e05a7f7b0..67b1ea9da79047895eabda98da92494021dc5faa 100644 --- a/Framework/Geometry/inc/MantidGeometry/Crystal/IPeak.h +++ b/Framework/Geometry/inc/MantidGeometry/Crystal/IPeak.h @@ -42,7 +42,7 @@ public: 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(Mantid::Kernel::V3D HKL) = 0; + virtual void setHKL(const Mantid::Kernel::V3D &HKL) = 0; virtual Mantid::Kernel::V3D getDetectorPosition() const = 0; virtual Mantid::Kernel::V3D getDetectorPositionNoCheck() const = 0; @@ -50,10 +50,12 @@ public: virtual Mantid::Kernel::V3D getQSampleFrame() const = 0; virtual bool findDetector() = 0; - virtual void setQSampleFrame(Mantid::Kernel::V3D QSampleFrame, - boost::optional<double> detectorDistance) = 0; - virtual void setQLabFrame(Mantid::Kernel::V3D QLabFrame, - boost::optional<double> detectorDistance) = 0; + virtual void + setQSampleFrame(const Mantid::Kernel::V3D &QSampleFrame, + const boost::optional<double> &detectorDistance) = 0; + virtual void + setQLabFrame(const Mantid::Kernel::V3D &QLabFrame, + const boost::optional<double> &detectorDistance) = 0; virtual void setWavelength(double wavelength) = 0; virtual double getWavelength() const = 0; @@ -76,8 +78,8 @@ public: virtual void setBinCount(double m_BinCount) = 0; virtual Mantid::Kernel::Matrix<double> getGoniometerMatrix() const = 0; - virtual void - setGoniometerMatrix(Mantid::Kernel::Matrix<double> m_GoniometerMatrix) = 0; + virtual void setGoniometerMatrix( + const Mantid::Kernel::Matrix<double> &m_GoniometerMatrix) = 0; virtual std::string getBankName() const = 0; virtual int getRow() const = 0; diff --git a/Framework/Geometry/inc/MantidGeometry/Instrument.h b/Framework/Geometry/inc/MantidGeometry/Instrument.h index a91fc9d118f61573b4a7040f0ea70804c9a2aa50..00639c0af60e1f4a4f5db2d29b039ff3a7569209 100644 --- a/Framework/Geometry/inc/MantidGeometry/Instrument.h +++ b/Framework/Geometry/inc/MantidGeometry/Instrument.h @@ -256,7 +256,7 @@ public: private: /// Save information about a set of detectors to Nexus void saveDetectorSetInfoToNexus(::NeXus::File *file, - std::vector<detid_t> detIDs) const; + const std::vector<detid_t> &detIDs) const; /// Private copy assignment operator Instrument &operator=(const Instrument &); diff --git a/Framework/Geometry/src/Instrument.cpp b/Framework/Geometry/src/Instrument.cpp index 162e4a7da06b28b7a706c9fa9b0b14bf7d45fcdb..ed3f35541097fb048e36d1e970bd513901c2077d 100644 --- a/Framework/Geometry/src/Instrument.cpp +++ b/Framework/Geometry/src/Instrument.cpp @@ -1067,10 +1067,8 @@ void Instrument::saveNexus(::NeXus::File *file, } // Add physical detector and monitor data - std::vector<detid_t> detectorIDs; - std::vector<detid_t> detmonIDs; - detectorIDs = getDetectorIDs(true); - detmonIDs = getDetectorIDs(false); + auto detectorIDs = getDetectorIDs(true); + auto detmonIDs = getDetectorIDs(false); if (!detmonIDs.empty()) { // Add detectors group file->makeGroup("physical_detectors", "NXdetector", true); @@ -1079,8 +1077,7 @@ void Instrument::saveNexus(::NeXus::File *file, file->closeGroup(); // detectors // Create Monitor IDs vector - std::vector<IDetector_const_sptr> detmons; - detmons = getDetectors(detmonIDs); + auto detmons = getDetectors(detmonIDs); std::vector<detid_t> monitorIDs; for (size_t i = 0; i < detmonIDs.size(); i++) { if (detmons[i]->isMonitor()) @@ -1104,14 +1101,13 @@ void Instrument::saveNexus(::NeXus::File *file, * a group must be open that has only one call of this function. * @param detIDs :: the dectector IDs of the detectors belonging to the set */ -void Instrument::saveDetectorSetInfoToNexus(::NeXus::File *file, - std::vector<detid_t> detIDs) const { +void Instrument::saveDetectorSetInfoToNexus( + ::NeXus::File *file, const std::vector<detid_t> &detIDs) const { size_t nDets = detIDs.size(); if (nDets == 0) return; - std::vector<IDetector_const_sptr> detectors; - detectors = getDetectors(detIDs); + auto detectors = getDetectors(detIDs); Geometry::IComponent_const_sptr sample = getSample(); Kernel::V3D sample_pos;