diff --git a/.gitignore b/.gitignore index 7d9b761d440253359d89a5aba7cc921cdb4877bf..c273e6b394bcb67138260238537960713c1c1d53 100644 --- a/.gitignore +++ b/.gitignore @@ -166,6 +166,7 @@ Desktop.ini # VSCode .vscode/ +.clangd/ XDG_CACHE_HOME/ # The file that contains metadata for VSCode Workspace *.code-workspace diff --git a/CMakeLists.txt b/CMakeLists.txt index e23e0975193001e7365b3b0798cf3550511fb741..4841c27ce97940a5515f27e10676cc138523b9a6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,6 +35,10 @@ option(ENABLE_WORKBENCH "Enable Qt5-based gui & components" ON) set(CPACK_INSTALL_CMAKE_PROJECTS "${CMAKE_BINARY_DIR}" "Mantid" "ALL" "/") +# Ensure that if we are running any sanitizers the compiler options are +# known in sub targets +include(Sanitizers) + # Quick exit if we only want data targets if(DATA_TARGETS_ONLY) include(SetupDataTargets) diff --git a/Framework/API/inc/MantidAPI/Algorithm.h b/Framework/API/inc/MantidAPI/Algorithm.h index 044cb68477079e55ff46b814f0aeee8d1df304ce..b92a36024ec8a509b62f672e6b9ced601420e985 100644 --- a/Framework/API/inc/MantidAPI/Algorithm.h +++ b/Framework/API/inc/MantidAPI/Algorithm.h @@ -288,7 +288,7 @@ public: const std::string &name, const double startProgress = -1., const double endProgress = -1., const bool enableLogging = true, const int &version = -1); - void setupAsChildAlgorithm(boost::shared_ptr<Algorithm> algorithm, + void setupAsChildAlgorithm(const boost::shared_ptr<Algorithm> &algorithm, const double startProgress = -1., const double endProgress = -1., const bool enableLogging = true); diff --git a/Framework/API/inc/MantidAPI/AlgorithmFactory.h b/Framework/API/inc/MantidAPI/AlgorithmFactory.h index af81adc43d9d6397bee92a7dec26e34272363c52..0bbcea94b8ab9bad420414f6dbe55ece8ab0f456 100644 --- a/Framework/API/inc/MantidAPI/AlgorithmFactory.h +++ b/Framework/API/inc/MantidAPI/AlgorithmFactory.h @@ -129,9 +129,9 @@ private: /// Extract the name of an algorithm const std::string - extractAlgName(const boost::shared_ptr<IAlgorithm> alg) const; + extractAlgName(const boost::shared_ptr<IAlgorithm> &alg) const; /// Extract the version of an algorithm - int extractAlgVersion(const boost::shared_ptr<IAlgorithm> alg) const; + int extractAlgVersion(const boost::shared_ptr<IAlgorithm> &alg) const; /// Create an algorithm object with the specified name boost::shared_ptr<Algorithm> createAlgorithm(const std::string &name, diff --git a/Framework/API/inc/MantidAPI/AlgorithmHistory.h b/Framework/API/inc/MantidAPI/AlgorithmHistory.h index 28c95f5a2470971cfc5b2038d434fcc79407214f..9da3a963252551ad9640aa8874f7d7bedbc5b6ed 100644 --- a/Framework/API/inc/MantidAPI/AlgorithmHistory.h +++ b/Framework/API/inc/MantidAPI/AlgorithmHistory.h @@ -63,7 +63,7 @@ public: bool isdefault, const unsigned int &direction = 99); /// add a child algorithm history record to this history object - void addChildHistory(AlgorithmHistory_sptr childHist); + void addChildHistory(const AlgorithmHistory_sptr &childHist); // get functions /// get name of algorithm in history const const std::string &name() const { return m_name; } diff --git a/Framework/API/inc/MantidAPI/AlgorithmManager.h b/Framework/API/inc/MantidAPI/AlgorithmManager.h index a881c7dab3c09dc34b66deabb3fa85927b93322d..3ad91d867e6d5bf6615f76b8293db63289dc8202 100644 --- a/Framework/API/inc/MantidAPI/AlgorithmManager.h +++ b/Framework/API/inc/MantidAPI/AlgorithmManager.h @@ -17,6 +17,7 @@ #include <deque> #include <mutex> #include <string> +#include <utility> namespace Mantid { namespace API { @@ -26,7 +27,7 @@ namespace API { class AlgorithmStartingNotification : public Poco::Notification { public: AlgorithmStartingNotification(IAlgorithm_sptr alg) - : Poco::Notification(), m_alg(alg) {} + : Poco::Notification(), m_alg(std::move(alg)) {} /// Returns the algorithm that is starting IAlgorithm_sptr getAlgorithm() const { return m_alg; } diff --git a/Framework/API/inc/MantidAPI/AlgorithmObserver.h b/Framework/API/inc/MantidAPI/AlgorithmObserver.h index 699204626d874a3f7ee78ec9331ea3096ff70aa6..3de449bd9cc157cc36b618951baea51553516e93 100644 --- a/Framework/API/inc/MantidAPI/AlgorithmObserver.h +++ b/Framework/API/inc/MantidAPI/AlgorithmObserver.h @@ -23,17 +23,17 @@ Hides Poco::Notification API from the user. class MANTID_API_DLL AlgorithmObserver { public: AlgorithmObserver(); - AlgorithmObserver(IAlgorithm_const_sptr alg); + AlgorithmObserver(const IAlgorithm_const_sptr &alg); virtual ~AlgorithmObserver(); - void observeAll(IAlgorithm_const_sptr alg); - void observeProgress(IAlgorithm_const_sptr alg); + void observeAll(const IAlgorithm_const_sptr &alg); + void observeProgress(const IAlgorithm_const_sptr &alg); void observeStarting(); - void observeStart(IAlgorithm_const_sptr alg); - void observeFinish(IAlgorithm_const_sptr alg); - void observeError(IAlgorithm_const_sptr alg); + void observeStart(const IAlgorithm_const_sptr &alg); + void observeFinish(const IAlgorithm_const_sptr &alg); + void observeError(const IAlgorithm_const_sptr &alg); - void stopObserving(IAlgorithm_const_sptr alg); + void stopObserving(const IAlgorithm_const_sptr &alg); void stopObserving(const Mantid::API::IAlgorithm *alg); void stopObservingManager(); diff --git a/Framework/API/inc/MantidAPI/AlgorithmProxy.h b/Framework/API/inc/MantidAPI/AlgorithmProxy.h index face35a487563e518e31b28e781ff402517b30d6..45490f3bcb7167232b937cf1df29b8dbcb575f88 100644 --- a/Framework/API/inc/MantidAPI/AlgorithmProxy.h +++ b/Framework/API/inc/MantidAPI/AlgorithmProxy.h @@ -50,7 +50,7 @@ http://proj-gaudi.web.cern.ch/proj-gaudi/) class MANTID_API_DLL AlgorithmProxy : public IAlgorithm, public Kernel::PropertyManagerOwner { public: - AlgorithmProxy(Algorithm_sptr alg); + AlgorithmProxy(const Algorithm_sptr &alg); AlgorithmProxy(const AlgorithmProxy &) = delete; AlgorithmProxy &operator=(const AlgorithmProxy &) = delete; ~AlgorithmProxy() override; diff --git a/Framework/API/inc/MantidAPI/BoostOptionalToAlgorithmProperty.h b/Framework/API/inc/MantidAPI/BoostOptionalToAlgorithmProperty.h index 15e7c685f887d8b6d9570c094dde1ce3e7808912..39af124f01c44922a82a2e0068345fbab9dced95 100644 --- a/Framework/API/inc/MantidAPI/BoostOptionalToAlgorithmProperty.h +++ b/Framework/API/inc/MantidAPI/BoostOptionalToAlgorithmProperty.h @@ -36,8 +36,9 @@ value of type boost::optional<T> will be returned. */ template <typename T> T checkForMandatoryInstrumentDefault( - Mantid::API::Algorithm *const alg, std::string propName, - Mantid::Geometry::Instrument_const_sptr instrument, std::string idf_name) { + Mantid::API::Algorithm *const alg, const std::string &propName, + const Mantid::Geometry::Instrument_const_sptr &instrument, + const std::string &idf_name) { auto algProperty = alg->getPointerToProperty(propName); if (algProperty->isDefault()) { auto defaults = instrument->getNumberParameter(idf_name); @@ -68,8 +69,9 @@ T checkForMandatoryInstrumentDefault( */ template <typename T> boost::optional<T> checkForOptionalInstrumentDefault( - Mantid::API::Algorithm *const alg, std::string propName, - Mantid::Geometry::Instrument_const_sptr instrument, std::string idf_name) { + Mantid::API::Algorithm *const alg, const std::string &propName, + const Mantid::Geometry::Instrument_const_sptr &instrument, + const std::string &idf_name) { auto algProperty = alg->getPointerToProperty(propName); if (algProperty->isDefault()) { auto defaults = instrument->getNumberParameter(idf_name); @@ -90,12 +92,14 @@ boost::optional<T> checkForOptionalInstrumentDefault( */ template <> MANTID_API_DLL std::string checkForMandatoryInstrumentDefault( - Mantid::API::Algorithm *const alg, std::string propName, - Mantid::Geometry::Instrument_const_sptr instrument, std::string idf_name); + Mantid::API::Algorithm *const alg, const std::string &propName, + const Mantid::Geometry::Instrument_const_sptr &instrument, + const std::string &idf_name); template <> MANTID_API_DLL boost::optional<std::string> checkForOptionalInstrumentDefault( - Mantid::API::Algorithm *const alg, std::string propName, - Mantid::Geometry::Instrument_const_sptr instrument, std::string idf_name); + Mantid::API::Algorithm *const alg, const std::string &propName, + const Mantid::Geometry::Instrument_const_sptr &instrument, + const std::string &idf_name); } // namespace API } // namespace Mantid diff --git a/Framework/API/inc/MantidAPI/BoxController.h b/Framework/API/inc/MantidAPI/BoxController.h index 0a2b93a421e481b3a2efa9580f16290f6bd6bad1..9c52e87a400d197b29c6fa9a83fe45e1cb463a3b 100644 --- a/Framework/API/inc/MantidAPI/BoxController.h +++ b/Framework/API/inc/MantidAPI/BoxController.h @@ -399,7 +399,7 @@ public: IBoxControllerIO *getFileIO() { return m_fileIO.get(); } /// makes box controller file based by providing class, responsible for /// fileIO. - void setFileBacked(boost::shared_ptr<IBoxControllerIO> newFileIO, + void setFileBacked(const boost::shared_ptr<IBoxControllerIO> &newFileIO, const std::string &fileName = ""); void clearFileBacked(); //----------------------------------------------------------------------------------- diff --git a/Framework/API/inc/MantidAPI/CompositeCatalog.h b/Framework/API/inc/MantidAPI/CompositeCatalog.h index 630d9c37419e66667fd6a74e1cfcb70c13eb8dfb..b4ebf7022f981e57079ddab9bd6167edba3713b9 100644 --- a/Framework/API/inc/MantidAPI/CompositeCatalog.h +++ b/Framework/API/inc/MantidAPI/CompositeCatalog.h @@ -25,7 +25,7 @@ public: /// Constructor CompositeCatalog(); /// Adds a catalog to the list of catalogs (m_catalogs) - void add(const ICatalog_sptr catalog); + void add(const ICatalog_sptr &catalog); /// Log the user into the catalog system. CatalogSession_sptr login(const std::string &username, const std::string &password, diff --git a/Framework/API/inc/MantidAPI/CompositeDomainMD.h b/Framework/API/inc/MantidAPI/CompositeDomainMD.h index fb48245da0d522359b09568ce9582b7d08f4f767..0ef223294d2acd1febee0f5a92ee25abe798d1be 100644 --- a/Framework/API/inc/MantidAPI/CompositeDomainMD.h +++ b/Framework/API/inc/MantidAPI/CompositeDomainMD.h @@ -27,7 +27,7 @@ class FunctionDomainMD; */ class MANTID_API_DLL CompositeDomainMD : public CompositeDomain { public: - CompositeDomainMD(IMDWorkspace_const_sptr ws, size_t maxDomainSize); + CompositeDomainMD(const IMDWorkspace_const_sptr &ws, size_t maxDomainSize); ~CompositeDomainMD() override; /// Return the total number of arguments in the domain size_t size() const override { return m_totalSize; } diff --git a/Framework/API/inc/MantidAPI/CompositeFunction.h b/Framework/API/inc/MantidAPI/CompositeFunction.h index 602389ba1a056fbf0c024b85c919f2186654b6cb..d7034583b1de25f7cb6a899d8452267c94685c49 100644 --- a/Framework/API/inc/MantidAPI/CompositeFunction.h +++ b/Framework/API/inc/MantidAPI/CompositeFunction.h @@ -148,9 +148,10 @@ public: /// Remove a function void removeFunction(size_t i); /// Replace a function - void replaceFunction(size_t i, IFunction_sptr f); + void replaceFunction(size_t i, const IFunction_sptr &f); /// Replace a function - void replaceFunctionPtr(const IFunction_sptr f_old, IFunction_sptr f_new); + void replaceFunctionPtr(const IFunction_sptr &f_old, + const IFunction_sptr &f_new); /// Get the function index std::size_t functionIndex(std::size_t i) const; /// Returns the index of parameter i as it declared in its function diff --git a/Framework/API/inc/MantidAPI/DataProcessorAlgorithm.h b/Framework/API/inc/MantidAPI/DataProcessorAlgorithm.h index 49db7621c3d62e9426743b37e5e25e6513f93919..ae1dfeb7cb6b7f0949853938934b92e5ea3f6172 100644 --- a/Framework/API/inc/MantidAPI/DataProcessorAlgorithm.h +++ b/Framework/API/inc/MantidAPI/DataProcessorAlgorithm.h @@ -45,7 +45,7 @@ protected: void setPropManagerPropName(const std::string &propName); void mapPropertyName(const std::string &nameInProp, const std::string &nameInPropManager); - void copyProperty(API::Algorithm_sptr alg, const std::string &name); + void copyProperty(const API::Algorithm_sptr &alg, const std::string &name); virtual ITableWorkspace_sptr determineChunk(const std::string &filename); virtual MatrixWorkspace_sptr loadChunk(const size_t rowIndex); Workspace_sptr load(const std::string &inputData, diff --git a/Framework/API/inc/MantidAPI/DetectorSearcher.h b/Framework/API/inc/MantidAPI/DetectorSearcher.h index 22af6d76cfedd300f574c2d38addf24c8fe3396e..27c4a4f7b2c328c5b5c80250f8fccac67b62a8bc 100644 --- a/Framework/API/inc/MantidAPI/DetectorSearcher.h +++ b/Framework/API/inc/MantidAPI/DetectorSearcher.h @@ -43,7 +43,7 @@ public: using DetectorSearchResult = std::tuple<bool, size_t>; /// Create a new DetectorSearcher with the given instrument & detectors - DetectorSearcher(Geometry::Instrument_const_sptr instrument, + DetectorSearcher(const Geometry::Instrument_const_sptr &instrument, const Geometry::DetectorInfo &detInfo); /// Find a detector that intsects with the given Qlab vector DetectorSearchResult findDetectorIndex(const Kernel::V3D &q); diff --git a/Framework/API/inc/MantidAPI/EnabledWhenWorkspaceIsType.h b/Framework/API/inc/MantidAPI/EnabledWhenWorkspaceIsType.h index 30160436a5c2e304b10a1cfe5f64365f76e93414..a849731c9ff0b40f705049907931d981704495f9 100644 --- a/Framework/API/inc/MantidAPI/EnabledWhenWorkspaceIsType.h +++ b/Framework/API/inc/MantidAPI/EnabledWhenWorkspaceIsType.h @@ -6,6 +6,8 @@ // SPDX - License - Identifier: GPL - 3.0 + #pragma once +#include <utility> + #include "MantidAPI/AnalysisDataService.h" #include "MantidAPI/Workspace_fwd.h" #include "MantidKernel/DataService.h" @@ -35,7 +37,7 @@ public: */ EnabledWhenWorkspaceIsType(std::string otherPropName, bool enabledSetting = true) - : IPropertySettings(), m_otherPropName(otherPropName), + : IPropertySettings(), m_otherPropName(std::move(otherPropName)), m_enabledSetting(enabledSetting) {} //-------------------------------------------------------------------------------------------- diff --git a/Framework/API/inc/MantidAPI/ExperimentInfo.h b/Framework/API/inc/MantidAPI/ExperimentInfo.h index fd15de6045e6431a6c2a72021a6ee336c10eba30..4d3134e9e43b522603e5027801d9abed8ec84d8c 100644 --- a/Framework/API/inc/MantidAPI/ExperimentInfo.h +++ b/Framework/API/inc/MantidAPI/ExperimentInfo.h @@ -107,9 +107,9 @@ public: /// Easy access to the efixed value for this run & detector ID double getEFixed(const detid_t detID) const; /// Easy access to the efixed value for this run & optional detector - double getEFixed(const boost::shared_ptr<const Geometry::IDetector> detector = - boost::shared_ptr<const Geometry::IDetector>{ - nullptr}) const; + double + getEFixed(const boost::shared_ptr<const Geometry::IDetector> &detector = + boost::shared_ptr<const Geometry::IDetector>{nullptr}) const; /// Set the efixed value for a given detector ID void setEFixed(const detid_t detID, const double value); diff --git a/Framework/API/inc/MantidAPI/FunctionDomainGeneral.h b/Framework/API/inc/MantidAPI/FunctionDomainGeneral.h index 333bfd46ac3858233f7aa90658135e0f7a75a5e0..d87f3d7c9d5cbfb9221805de9309a5d85e039d9a 100644 --- a/Framework/API/inc/MantidAPI/FunctionDomainGeneral.h +++ b/Framework/API/inc/MantidAPI/FunctionDomainGeneral.h @@ -25,7 +25,7 @@ public: /// Get the number of columns size_t columnCount() const; /// Add a new column. All columns must have the same size. - void addColumn(boost::shared_ptr<Column> column); + void addColumn(const boost::shared_ptr<Column> &column); /// Get i-th column boost::shared_ptr<Column> getColumn(size_t i) const; diff --git a/Framework/API/inc/MantidAPI/FunctionDomainMD.h b/Framework/API/inc/MantidAPI/FunctionDomainMD.h index d1641310378773cea9a64923a39e5bb3f97782e8..43ebc9efa049ac4ea93b8f8593986d6f8fa01790 100644 --- a/Framework/API/inc/MantidAPI/FunctionDomainMD.h +++ b/Framework/API/inc/MantidAPI/FunctionDomainMD.h @@ -22,7 +22,7 @@ namespace API { class MANTID_API_DLL FunctionDomainMD : public FunctionDomain { public: /// Constructor. - FunctionDomainMD(IMDWorkspace_const_sptr ws, size_t start = 0, + FunctionDomainMD(const IMDWorkspace_const_sptr &ws, size_t start = 0, size_t length = 0); /// Destructor. ~FunctionDomainMD() override; diff --git a/Framework/API/inc/MantidAPI/FunctionFactory.h b/Framework/API/inc/MantidAPI/FunctionFactory.h index b77dd2a80be5ecedca10d20adcf74a0320b45aad..bfb3b208013176d2586d9ba89ad8d17fdf7688d7 100644 --- a/Framework/API/inc/MantidAPI/FunctionFactory.h +++ b/Framework/API/inc/MantidAPI/FunctionFactory.h @@ -90,19 +90,21 @@ private: /// Throw an exception void inputError(const std::string &str = "") const; /// Add constraints to the created function - void addConstraints(boost::shared_ptr<IFunction> fun, + void addConstraints(const boost::shared_ptr<IFunction> &fun, const Expression &expr) const; /// Add a single constraint to the created function - void addConstraint(boost::shared_ptr<IFunction> fun, + void addConstraint(const boost::shared_ptr<IFunction> &fun, const Expression &expr) const; /// Add a single constraint to the created function with non-default penalty - void addConstraint(boost::shared_ptr<IFunction> fun, + void addConstraint(const boost::shared_ptr<IFunction> &fun, const Expression &constraint_expr, const Expression &penalty_expr) const; /// Add ties to the created function - void addTies(boost::shared_ptr<IFunction> fun, const Expression &expr) const; + void addTies(const boost::shared_ptr<IFunction> &fun, + const Expression &expr) const; /// Add a tie to the created function - void addTie(boost::shared_ptr<IFunction> fun, const Expression &expr) const; + void addTie(const boost::shared_ptr<IFunction> &fun, + const Expression &expr) const; mutable std::map<std::string, std::vector<std::string>> m_cachedFunctionNames; mutable std::mutex m_mutex; diff --git a/Framework/API/inc/MantidAPI/FunctionGenerator.h b/Framework/API/inc/MantidAPI/FunctionGenerator.h index 61bdc373d3a8dc121e6b6be46e7c6267d58317de..68fafe0b7a0808c401e389862bcf5c4c854978c9 100644 --- a/Framework/API/inc/MantidAPI/FunctionGenerator.h +++ b/Framework/API/inc/MantidAPI/FunctionGenerator.h @@ -31,7 +31,7 @@ belongs to. By default if a name has the signature of a composite function class MANTID_API_DLL FunctionGenerator : public IFunction { public: /// Constructor - FunctionGenerator(IFunction_sptr source); + FunctionGenerator(const IFunction_sptr &source); /// @name Overrides implementing composition of two functions: /// m_source and m_target. diff --git a/Framework/API/inc/MantidAPI/GridDomain1D.h b/Framework/API/inc/MantidAPI/GridDomain1D.h index b0d95f18ce8b087f510fbed4db259c7e56aec05e..2ba4ac5047bc3fa24565d5901653d0825a5367cb 100644 --- a/Framework/API/inc/MantidAPI/GridDomain1D.h +++ b/Framework/API/inc/MantidAPI/GridDomain1D.h @@ -26,7 +26,8 @@ namespace API { class MANTID_API_DLL GridDomain1D : public API::GridDomain { public: /// initialize - void initialize(double &startX, double &endX, size_t &n, std::string scaling); + void initialize(double &startX, double &endX, size_t &n, + const std::string &scaling); /// number of grid point s size_t size() const override { return m_points.size(); } /// number of dimensions in the grid diff --git a/Framework/API/inc/MantidAPI/GroupingLoader.h b/Framework/API/inc/MantidAPI/GroupingLoader.h index ed18239a7e16ec493a5f21a8cc88038e357a756f..622e9090e26362b8179ab297b5003c0189549d75 100644 --- a/Framework/API/inc/MantidAPI/GroupingLoader.h +++ b/Framework/API/inc/MantidAPI/GroupingLoader.h @@ -33,7 +33,7 @@ public: ~Grouping(); /// Construct a Grouping from a table - Grouping(ITableWorkspace_sptr table); + Grouping(const ITableWorkspace_sptr &table); /// Convert to grouping table ITableWorkspace_sptr toTable() const; diff --git a/Framework/API/inc/MantidAPI/IFunction.h b/Framework/API/inc/MantidAPI/IFunction.h index 36a5f4032921a76766630fb7aac3ef7c37d05b84..327f1c190a4de2328f89d4bf41d837e4fd3f50e4 100644 --- a/Framework/API/inc/MantidAPI/IFunction.h +++ b/Framework/API/inc/MantidAPI/IFunction.h @@ -24,6 +24,8 @@ #endif #include <string> +#include <utility> + #include <vector> #ifdef _WIN32 @@ -521,7 +523,8 @@ public: /// Calculate numerical derivatives void calNumericalDeriv(const FunctionDomain &domain, Jacobian &jacobian); /// Set the covariance matrix - void setCovarianceMatrix(boost::shared_ptr<Kernel::Matrix<double>> covar); + void + setCovarianceMatrix(const boost::shared_ptr<Kernel::Matrix<double>> &covar); /// Get the covariance matrix boost::shared_ptr<const Kernel::Matrix<double>> getCovarianceMatrix() const { return m_covar; @@ -562,11 +565,11 @@ protected: /// Convert a value from one unit (inUnit) to unit defined in workspace (ws) double convertValue(double value, Kernel::Unit_sptr &outUnit, - boost::shared_ptr<const MatrixWorkspace> ws, + const boost::shared_ptr<const MatrixWorkspace> &ws, size_t wsIndex) const; void convertValue(std::vector<double> &values, Kernel::Unit_sptr &outUnit, - boost::shared_ptr<const MatrixWorkspace> ws, + const boost::shared_ptr<const MatrixWorkspace> &ws, size_t wsIndex) const; /// Override to declare function attributes @@ -635,7 +638,7 @@ using IFunction_const_sptr = boost::shared_ptr<const IFunction>; class FunctionHandler { public: /// Constructor - FunctionHandler(IFunction_sptr fun) : m_fun(fun) {} + FunctionHandler(IFunction_sptr fun) : m_fun(std::move(fun)) {} /// Virtual destructor virtual ~FunctionHandler() = default; /// abstract init method. It is called after setting handler to the function diff --git a/Framework/API/inc/MantidAPI/ITableWorkspace.h b/Framework/API/inc/MantidAPI/ITableWorkspace.h index 9beba0fae1d344a39010a446daf16a8b1f8975b3..74a11149ce6c455800b18a3cf58bfdfab475b35d 100644 --- a/Framework/API/inc/MantidAPI/ITableWorkspace.h +++ b/Framework/API/inc/MantidAPI/ITableWorkspace.h @@ -22,6 +22,7 @@ #endif #include <sstream> +#include <utility> namespace Mantid { @@ -349,7 +350,7 @@ public: } } /// Construct directly from column - ColumnVector(Column_sptr column) : m_column(column) { + ColumnVector(Column_sptr column) : m_column(std::move(column)) { if (!m_column->isType<T>()) { std::stringstream mess; mess << "Type mismatch when creating a ColumnVector<" << typeid(T).name() @@ -387,7 +388,7 @@ public: } } /// Construct directly from column - ConstColumnVector(Column_const_sptr column) : m_column(column) { + ConstColumnVector(Column_const_sptr column) : m_column(std::move(column)) { if (!m_column->isType<T>()) { std::stringstream mess; mess << "Type mismatch when creating a ColumnVector<" << typeid(T).name() diff --git a/Framework/API/inc/MantidAPI/IndexProperty.h b/Framework/API/inc/MantidAPI/IndexProperty.h index 99918f926eb21c78322fefdefe505eaa2e32ea9b..f6261fe2e2397d073874d1e06a1e97971bee2deb 100644 --- a/Framework/API/inc/MantidAPI/IndexProperty.h +++ b/Framework/API/inc/MantidAPI/IndexProperty.h @@ -32,7 +32,7 @@ public: IndexProperty(const std::string &name, const IWorkspaceProperty &workspaceProp, const IndexTypeProperty &indexTypeProp, - Kernel::IValidator_sptr validator = + const Kernel::IValidator_sptr &validator = Kernel::IValidator_sptr(new Kernel::NullValidator)); IndexProperty *clone() const override; diff --git a/Framework/API/inc/MantidAPI/JointDomain.h b/Framework/API/inc/MantidAPI/JointDomain.h index b027938aeae8f8b986652736685100b3af140d49..1fd5eb6b4ee714148c21989e09e79368b2650038 100644 --- a/Framework/API/inc/MantidAPI/JointDomain.h +++ b/Framework/API/inc/MantidAPI/JointDomain.h @@ -31,7 +31,7 @@ public: size_t getNParts() const override; /// Return i-th domain const FunctionDomain &getDomain(size_t i) const override; - void addDomain(FunctionDomain_sptr domain); + void addDomain(const FunctionDomain_sptr &domain); protected: /// Vector with member domains. diff --git a/Framework/API/inc/MantidAPI/MDGeometry.h b/Framework/API/inc/MantidAPI/MDGeometry.h index d46ecaf20003a11c9949743f713d0d9b2ce6cd48..d97cbfbe2feb2d04fc4469e99db7989ec835679d 100644 --- a/Framework/API/inc/MantidAPI/MDGeometry.h +++ b/Framework/API/inc/MantidAPI/MDGeometry.h @@ -64,7 +64,8 @@ public: std::string getGeometryXML() const; - void addDimension(boost::shared_ptr<Mantid::Geometry::IMDDimension> dim); + void + addDimension(const boost::shared_ptr<Mantid::Geometry::IMDDimension> &dim); void addDimension(Mantid::Geometry::IMDDimension *dim); // -------------------------------------------------------------------------------------------- diff --git a/Framework/API/inc/MantidAPI/MultiPeriodGroupWorker.h b/Framework/API/inc/MantidAPI/MultiPeriodGroupWorker.h index 8a68f6fa3d6d30c54bf5bebbeaf6b6dc9d70b087..e787848a1b6675d7b77e1e0f4230341089f1b385 100644 --- a/Framework/API/inc/MantidAPI/MultiPeriodGroupWorker.h +++ b/Framework/API/inc/MantidAPI/MultiPeriodGroupWorker.h @@ -52,7 +52,7 @@ private: /// Try ot add a workspace to the group of input workspaces. void tryAddInputWorkspaceToInputGroups( - Workspace_sptr ws, VecWSGroupType &vecMultiPeriodWorkspaceGroups, + const Workspace_sptr &ws, VecWSGroupType &vecMultiPeriodWorkspaceGroups, VecWSGroupType &vecWorkspaceGroups) const; /// Copy input workspace properties to spawned algorithm. diff --git a/Framework/API/inc/MantidAPI/MultipleExperimentInfos.h b/Framework/API/inc/MantidAPI/MultipleExperimentInfos.h index db9b5c2e68d088a70be46230d89ca4eb664a3675..58a11c8c6b0f89f339edfdc6db07d244ff9f3629 100644 --- a/Framework/API/inc/MantidAPI/MultipleExperimentInfos.h +++ b/Framework/API/inc/MantidAPI/MultipleExperimentInfos.h @@ -27,7 +27,7 @@ public: ExperimentInfo_const_sptr getExperimentInfo(const uint16_t runIndex) const; - uint16_t addExperimentInfo(ExperimentInfo_sptr ei); + uint16_t addExperimentInfo(const ExperimentInfo_sptr &ei); void setExperimentInfo(const uint16_t runIndex, ExperimentInfo_sptr ei); diff --git a/Framework/API/inc/MantidAPI/NotebookBuilder.h b/Framework/API/inc/MantidAPI/NotebookBuilder.h index fcd244028726bc032c2a2c5ee97a605f8de41717..5e620037130aaef9aaa1d11d1e62374883f57ebc 100644 --- a/Framework/API/inc/MantidAPI/NotebookBuilder.h +++ b/Framework/API/inc/MantidAPI/NotebookBuilder.h @@ -26,20 +26,21 @@ namespace API { class MANTID_API_DLL NotebookBuilder { public: - NotebookBuilder(boost::shared_ptr<HistoryView> view, + NotebookBuilder(const boost::shared_ptr<HistoryView> &view, std::string versionSpecificity = "old"); virtual ~NotebookBuilder() = default; /// build an ipython notebook from the history view - const std::string build(std::string ws_name, std::string ws_title, - std::string ws_comment); + const std::string build(const std::string &ws_name, + const std::string &ws_title, + const std::string &ws_comment); private: void writeHistoryToStream(std::vector<HistoryItem>::const_iterator &iter); void buildChildren(std::vector<HistoryItem>::const_iterator &iter); const std::string - buildAlgorithmString(AlgorithmHistory_const_sptr algHistory); - const std::string - buildPropertyString(Mantid::Kernel::PropertyHistory_const_sptr propHistory); + buildAlgorithmString(const AlgorithmHistory_const_sptr &algHistory); + const std::string buildPropertyString( + const Mantid::Kernel::PropertyHistory_const_sptr &propHistory); const std::vector<HistoryItem> m_historyItems; std::string m_output; diff --git a/Framework/API/inc/MantidAPI/NotebookWriter.h b/Framework/API/inc/MantidAPI/NotebookWriter.h index 039b58c2af15b15a505d03d01116b6b4e1bb483d..d9d914f17e230284a77b67f52a1d7cbf2445d598 100644 --- a/Framework/API/inc/MantidAPI/NotebookWriter.h +++ b/Framework/API/inc/MantidAPI/NotebookWriter.h @@ -24,8 +24,8 @@ class MANTID_API_DLL NotebookWriter { public: NotebookWriter(); virtual ~NotebookWriter() = default; - std::string markdownCell(std::string string_text); - std::string codeCell(std::string string_code); + std::string markdownCell(const std::string &string_text); + std::string codeCell(const std::string &string_code); std::string writeNotebook(); private: diff --git a/Framework/API/inc/MantidAPI/RemoteJobManagerFactory.h b/Framework/API/inc/MantidAPI/RemoteJobManagerFactory.h index 30a18555469505addb870aab9797395828b6dc5a..5646d0da63e9e3347c68f2594f504319bbf5c9da 100644 --- a/Framework/API/inc/MantidAPI/RemoteJobManagerFactory.h +++ b/Framework/API/inc/MantidAPI/RemoteJobManagerFactory.h @@ -47,8 +47,8 @@ public: /// alternative (lower level) create where the specific type of /// manager and base URL are directly given - IRemoteJobManager_sptr create(const std::string baseURL, - const std::string jobManagerType) const; + IRemoteJobManager_sptr create(const std::string &baseURL, + const std::string &jobManagerType) const; private: /// So that the singleton can be created (cons/destructor are private) diff --git a/Framework/API/inc/MantidAPI/Sample.h b/Framework/API/inc/MantidAPI/Sample.h index 5004a47d8e0113b9576d3e8f1797c65dd66e2cf7..dc70c2391fa669bfebce66789eef89b700e5092b 100644 --- a/Framework/API/inc/MantidAPI/Sample.h +++ b/Framework/API/inc/MantidAPI/Sample.h @@ -45,7 +45,7 @@ public: /// the number of samples std::size_t size() const; /// Adds a sample to the list - void addSample(boost::shared_ptr<Sample> childSample); + void addSample(const boost::shared_ptr<Sample> &childSample); /// Returns the name of the sample const std::string &getName() const; diff --git a/Framework/API/inc/MantidAPI/ScopedWorkspace.h b/Framework/API/inc/MantidAPI/ScopedWorkspace.h index e8e513de799d7dc4cafcf8dfe9ad4c4dd4b5b14b..00ddb510e2beb391d963c5e1405f7c180a19ba15 100644 --- a/Framework/API/inc/MantidAPI/ScopedWorkspace.h +++ b/Framework/API/inc/MantidAPI/ScopedWorkspace.h @@ -37,7 +37,7 @@ public: ScopedWorkspace(); /// Workspace constructor - ScopedWorkspace(Workspace_sptr ws); + ScopedWorkspace(const Workspace_sptr &ws); /// Destructor virtual ~ScopedWorkspace(); @@ -61,7 +61,7 @@ public: operator bool() const; /// Make ADS entry to point to the given workspace - void set(Workspace_sptr newWS); + void set(const Workspace_sptr &newWS); private: /// ADS name of the workspace diff --git a/Framework/API/inc/MantidAPI/ScriptBuilder.h b/Framework/API/inc/MantidAPI/ScriptBuilder.h index e852d99d7dac3fb5f7007fd7ea79dfdf7e24f29d..eba2f95a206f56e822ab8a9f2b44fa8c17a47cbe 100644 --- a/Framework/API/inc/MantidAPI/ScriptBuilder.h +++ b/Framework/API/inc/MantidAPI/ScriptBuilder.h @@ -31,7 +31,7 @@ namespace API { class MANTID_API_DLL ScriptBuilder { public: ScriptBuilder( - boost::shared_ptr<HistoryView> view, + const boost::shared_ptr<HistoryView> &view, std::string versionSpecificity = "old", bool appendTimestamp = false, std::vector<std::string> ignoreTheseAlgs = {}, std::vector<std::vector<std::string>> ignoreTheseAlgProperties = {}, diff --git a/Framework/API/inc/MantidAPI/SpectrumDetectorMapping.h b/Framework/API/inc/MantidAPI/SpectrumDetectorMapping.h index 2f2b218194e8b23d700802bbb083d20f75a15c55..08885eb4bc9ea62cf770966d60717cf0a2abdff3 100644 --- a/Framework/API/inc/MantidAPI/SpectrumDetectorMapping.h +++ b/Framework/API/inc/MantidAPI/SpectrumDetectorMapping.h @@ -31,7 +31,7 @@ class MANTID_API_DLL SpectrumDetectorMapping { using sdmap = std::unordered_map<specnum_t, std::set<detid_t>>; public: - explicit SpectrumDetectorMapping(MatrixWorkspace_const_sptr workspace, + explicit SpectrumDetectorMapping(const MatrixWorkspace_const_sptr &workspace, const bool useSpecNoIndex = true); SpectrumDetectorMapping( const std::vector<specnum_t> &spectrumNumbers, diff --git a/Framework/API/inc/MantidAPI/SpectrumInfo.h b/Framework/API/inc/MantidAPI/SpectrumInfo.h index e8ce651bd3492e29d913ba88806af30c0bc9e132..fc4c9bffede5a5a78483e024b32d072cb4ea619a 100644 --- a/Framework/API/inc/MantidAPI/SpectrumInfo.h +++ b/Framework/API/inc/MantidAPI/SpectrumInfo.h @@ -56,6 +56,7 @@ public: ~SpectrumInfo(); size_t size() const; + size_t detectorCount() const; const SpectrumDefinition &spectrumDefinition(const size_t index) const; const Kernel::cow_ptr<std::vector<SpectrumDefinition>> & diff --git a/Framework/API/inc/MantidAPI/SpectrumInfoItem.h b/Framework/API/inc/MantidAPI/SpectrumInfoItem.h index e98df300bdd949b486aad469a8eb64e51edeb972..15062d08639c7d74565ea733b617ff93efb156e2 100644 --- a/Framework/API/inc/MantidAPI/SpectrumInfoItem.h +++ b/Framework/API/inc/MantidAPI/SpectrumInfoItem.h @@ -59,6 +59,8 @@ public: return m_spectrumInfo->hasUniqueDetector(m_index); } + bool hasDetectors() const { return m_spectrumInfo->hasDetectors(m_index); } + const Mantid::SpectrumDefinition &spectrumDefinition() const { return m_spectrumInfo->spectrumDefinition(m_index); } diff --git a/Framework/API/inc/MantidAPI/WorkspaceHistory.h b/Framework/API/inc/MantidAPI/WorkspaceHistory.h index cc7097afbf995655e3894e46f834ecffa09e31c2..153651206cce5e7707e6db53a5578dd0ec6f6001 100644 --- a/Framework/API/inc/MantidAPI/WorkspaceHistory.h +++ b/Framework/API/inc/MantidAPI/WorkspaceHistory.h @@ -79,9 +79,9 @@ public: private: /// Recursive function to load the algorithm history tree from file - void loadNestedHistory( - ::NeXus::File *file, - AlgorithmHistory_sptr parent = boost::shared_ptr<AlgorithmHistory>()); + void loadNestedHistory(::NeXus::File *file, + const AlgorithmHistory_sptr &parent = + boost::shared_ptr<AlgorithmHistory>()); /// Parse an algorithm history string loaded from file AlgorithmHistory_sptr parseAlgorithmHistory(const std::string &rawData); /// Find the history entries at this level in the file. diff --git a/Framework/API/inc/MantidAPI/WorkspaceOpOverloads.h b/Framework/API/inc/MantidAPI/WorkspaceOpOverloads.h index 06eaa10debe52e82f781ef5dc39f76e7b8d90c64..f40c7b19dbea0f2c6a3030caa43a5c787b00dc76 100644 --- a/Framework/API/inc/MantidAPI/WorkspaceOpOverloads.h +++ b/Framework/API/inc/MantidAPI/WorkspaceOpOverloads.h @@ -22,51 +22,51 @@ DLLExport ResultType executeBinaryOperation( bool rethrow = false); } // namespace OperatorOverloads -bool MANTID_API_DLL equals(const MatrixWorkspace_sptr lhs, - const MatrixWorkspace_sptr rhs, +bool MANTID_API_DLL equals(const MatrixWorkspace_sptr &lhs, + const MatrixWorkspace_sptr &rhs, double tolerance = 0.0); // Workspace operator overloads -MatrixWorkspace_sptr MANTID_API_DLL operator+(const MatrixWorkspace_sptr lhs, - const MatrixWorkspace_sptr rhs); -MatrixWorkspace_sptr MANTID_API_DLL operator-(const MatrixWorkspace_sptr lhs, - const MatrixWorkspace_sptr rhs); -MatrixWorkspace_sptr MANTID_API_DLL operator*(const MatrixWorkspace_sptr lhs, - const MatrixWorkspace_sptr rhs); -MatrixWorkspace_sptr MANTID_API_DLL operator/(const MatrixWorkspace_sptr lhs, - const MatrixWorkspace_sptr rhs); +MatrixWorkspace_sptr MANTID_API_DLL operator+(const MatrixWorkspace_sptr &lhs, + const MatrixWorkspace_sptr &rhs); +MatrixWorkspace_sptr MANTID_API_DLL operator-(const MatrixWorkspace_sptr &lhs, + const MatrixWorkspace_sptr &rhs); +MatrixWorkspace_sptr MANTID_API_DLL operator*(const MatrixWorkspace_sptr &lhs, + const MatrixWorkspace_sptr &rhs); +MatrixWorkspace_sptr MANTID_API_DLL operator/(const MatrixWorkspace_sptr &lhs, + const MatrixWorkspace_sptr &rhs); -MatrixWorkspace_sptr MANTID_API_DLL operator+(const MatrixWorkspace_sptr lhs, +MatrixWorkspace_sptr MANTID_API_DLL operator+(const MatrixWorkspace_sptr &lhs, const double &rhsValue); -MatrixWorkspace_sptr MANTID_API_DLL operator-(const MatrixWorkspace_sptr lhs, +MatrixWorkspace_sptr MANTID_API_DLL operator-(const MatrixWorkspace_sptr &lhs, const double &rhsValue); MatrixWorkspace_sptr MANTID_API_DLL operator-(const double &lhsValue, - const MatrixWorkspace_sptr rhs); -MatrixWorkspace_sptr MANTID_API_DLL operator*(const MatrixWorkspace_sptr lhs, + const MatrixWorkspace_sptr &rhs); +MatrixWorkspace_sptr MANTID_API_DLL operator*(const MatrixWorkspace_sptr &lhs, const double &rhsValue); MatrixWorkspace_sptr MANTID_API_DLL operator*(const double &lhsValue, - const MatrixWorkspace_sptr rhs); -MatrixWorkspace_sptr MANTID_API_DLL operator/(const MatrixWorkspace_sptr lhs, + const MatrixWorkspace_sptr &rhs); +MatrixWorkspace_sptr MANTID_API_DLL operator/(const MatrixWorkspace_sptr &lhs, const double &rhsValue); MatrixWorkspace_sptr MANTID_API_DLL operator/(const double &lhsValue, - const MatrixWorkspace_sptr rhs); + const MatrixWorkspace_sptr &rhs); -MatrixWorkspace_sptr MANTID_API_DLL operator+=(const MatrixWorkspace_sptr lhs, - const MatrixWorkspace_sptr rhs); -MatrixWorkspace_sptr MANTID_API_DLL operator-=(const MatrixWorkspace_sptr lhs, - const MatrixWorkspace_sptr rhs); -MatrixWorkspace_sptr MANTID_API_DLL operator*=(const MatrixWorkspace_sptr lhs, - const MatrixWorkspace_sptr rhs); -MatrixWorkspace_sptr MANTID_API_DLL operator/=(const MatrixWorkspace_sptr lhs, - const MatrixWorkspace_sptr rhs); +MatrixWorkspace_sptr MANTID_API_DLL operator+=(const MatrixWorkspace_sptr &lhs, + const MatrixWorkspace_sptr &rhs); +MatrixWorkspace_sptr MANTID_API_DLL operator-=(const MatrixWorkspace_sptr &lhs, + const MatrixWorkspace_sptr &rhs); +MatrixWorkspace_sptr MANTID_API_DLL operator*=(const MatrixWorkspace_sptr &lhs, + const MatrixWorkspace_sptr &rhs); +MatrixWorkspace_sptr MANTID_API_DLL operator/=(const MatrixWorkspace_sptr &lhs, + const MatrixWorkspace_sptr &rhs); -MatrixWorkspace_sptr MANTID_API_DLL operator+=(const MatrixWorkspace_sptr lhs, +MatrixWorkspace_sptr MANTID_API_DLL operator+=(const MatrixWorkspace_sptr &lhs, const double &rhsValue); -MatrixWorkspace_sptr MANTID_API_DLL operator-=(const MatrixWorkspace_sptr lhs, +MatrixWorkspace_sptr MANTID_API_DLL operator-=(const MatrixWorkspace_sptr &lhs, const double &rhsValue); -MatrixWorkspace_sptr MANTID_API_DLL operator*=(const MatrixWorkspace_sptr lhs, +MatrixWorkspace_sptr MANTID_API_DLL operator*=(const MatrixWorkspace_sptr &lhs, const double &rhsValue); -MatrixWorkspace_sptr MANTID_API_DLL operator/=(const MatrixWorkspace_sptr lhs, +MatrixWorkspace_sptr MANTID_API_DLL operator/=(const MatrixWorkspace_sptr &lhs, const double &rhsValue); /** A collection of static functions for use with workspaces @@ -83,7 +83,7 @@ struct MANTID_API_DLL WorkspaceHelpers { static bool sharedXData(const MatrixWorkspace &WS); // Divides the data in a workspace by the bin width to make it a distribution // (or the reverse) - static void makeDistribution(MatrixWorkspace_sptr workspace, + static void makeDistribution(const MatrixWorkspace_sptr &workspace, const bool forwards = true); }; diff --git a/Framework/API/inc/MantidAPI/WorkspaceProperty.h b/Framework/API/inc/MantidAPI/WorkspaceProperty.h index 487b29032f5ce1506243b7834842eaeab9a76ed1..0b0a32d2c3b0fc09ee3365e5b98d8b261ac5b63c 100644 --- a/Framework/API/inc/MantidAPI/WorkspaceProperty.h +++ b/Framework/API/inc/MantidAPI/WorkspaceProperty.h @@ -59,20 +59,20 @@ public: explicit WorkspaceProperty( const std::string &name, const std::string &wsName, const unsigned int direction, - Kernel::IValidator_sptr validator = + const Kernel::IValidator_sptr &validator = Kernel::IValidator_sptr(new Kernel::NullValidator)); explicit WorkspaceProperty( const std::string &name, const std::string &wsName, const unsigned int direction, const PropertyMode::Type optional, - Kernel::IValidator_sptr validator = + const Kernel::IValidator_sptr &validator = Kernel::IValidator_sptr(new Kernel::NullValidator)); explicit WorkspaceProperty( const std::string &name, const std::string &wsName, const unsigned int direction, const PropertyMode::Type optional, const LockMode::Type locking, - Kernel::IValidator_sptr validator = + const Kernel::IValidator_sptr &validator = Kernel::IValidator_sptr(new Kernel::NullValidator)); WorkspaceProperty(const WorkspaceProperty &right); @@ -118,7 +118,8 @@ public: void setIsMasterRank(bool isMasterRank) override; private: - std::string isValidGroup(boost::shared_ptr<WorkspaceGroup> wsGroup) const; + std::string + isValidGroup(const boost::shared_ptr<WorkspaceGroup> &wsGroup) const; std::string isValidOutputWs() const; diff --git a/Framework/API/inc/MantidAPI/WorkspaceProperty.tcc b/Framework/API/inc/MantidAPI/WorkspaceProperty.tcc index b60627596e43036bb11b3859cb5d5e2f1d964a92..6908bc7a6c25efeac00301d96c1a643f119d7b95 100644 --- a/Framework/API/inc/MantidAPI/WorkspaceProperty.tcc +++ b/Framework/API/inc/MantidAPI/WorkspaceProperty.tcc @@ -29,10 +29,9 @@ namespace API { * Direction enum (i.e. 0-2) */ template <typename TYPE> -WorkspaceProperty<TYPE>::WorkspaceProperty(const std::string &name, - const std::string &wsName, - const unsigned int direction, - Kernel::IValidator_sptr validator) +WorkspaceProperty<TYPE>::WorkspaceProperty( + const std::string &name, const std::string &wsName, + const unsigned int direction, const Kernel::IValidator_sptr &validator) : Kernel::PropertyWithValue<boost::shared_ptr<TYPE>>( name, boost::shared_ptr<TYPE>(), validator, direction), m_workspaceName(wsName), m_initialWSName(wsName), @@ -51,11 +50,10 @@ WorkspaceProperty<TYPE>::WorkspaceProperty(const std::string &name, * Direction enum (i.e. 0-2) */ template <typename TYPE> -WorkspaceProperty<TYPE>::WorkspaceProperty(const std::string &name, - const std::string &wsName, - const unsigned int direction, - const PropertyMode::Type optional, - Kernel::IValidator_sptr validator) +WorkspaceProperty<TYPE>::WorkspaceProperty( + const std::string &name, const std::string &wsName, + const unsigned int direction, const PropertyMode::Type optional, + const Kernel::IValidator_sptr &validator) : Kernel::PropertyWithValue<boost::shared_ptr<TYPE>>( name, boost::shared_ptr<TYPE>(), validator, direction), m_workspaceName(wsName), m_initialWSName(wsName), m_optional(optional), @@ -78,12 +76,10 @@ WorkspaceProperty<TYPE>::WorkspaceProperty(const std::string &name, * Direction enum (i.e. 0-2) */ template <typename TYPE> -WorkspaceProperty<TYPE>::WorkspaceProperty(const std::string &name, - const std::string &wsName, - const unsigned int direction, - const PropertyMode::Type optional, - const LockMode::Type locking, - Kernel::IValidator_sptr validator) +WorkspaceProperty<TYPE>::WorkspaceProperty( + const std::string &name, const std::string &wsName, + const unsigned int direction, const PropertyMode::Type optional, + const LockMode::Type locking, const Kernel::IValidator_sptr &validator) : Kernel::PropertyWithValue<boost::shared_ptr<TYPE>>( name, boost::shared_ptr<TYPE>(), validator, direction), m_workspaceName(wsName), m_initialWSName(wsName), m_optional(optional), @@ -410,7 +406,7 @@ void WorkspaceProperty<TYPE>::setIsMasterRank(bool isMasterRank) { */ template <typename TYPE> std::string WorkspaceProperty<TYPE>::isValidGroup( - boost::shared_ptr<WorkspaceGroup> wsGroup) const { + const boost::shared_ptr<WorkspaceGroup> &wsGroup) const { g_log.debug() << " Input WorkspaceGroup found \n"; std::vector<std::string> wsGroupNames = wsGroup->getNames(); diff --git a/Framework/API/src/Algorithm.cpp b/Framework/API/src/Algorithm.cpp index 3420f7b7aff1e89c7478cedee108827c4cf2eb76..8a96b5f46197db6fb9c111209e5daba26c2e241b 100644 --- a/Framework/API/src/Algorithm.cpp +++ b/Framework/API/src/Algorithm.cpp @@ -39,6 +39,7 @@ #include <json/json.h> #include <map> +#include <utility> // Index property handling template definitions #include "MantidAPI/Algorithm.tcc" @@ -845,7 +846,7 @@ Algorithm_sptr Algorithm::createChildAlgorithm(const std::string &name, * Can also be used manually for algorithms created otherwise. This allows * running algorithms that are not declared into the factory as child * algorithms. */ -void Algorithm::setupAsChildAlgorithm(Algorithm_sptr alg, +void Algorithm::setupAsChildAlgorithm(const Algorithm_sptr &alg, const double startProgress, const double endProgress, const bool enableLogging) { @@ -1077,7 +1078,7 @@ void Algorithm::linkHistoryWithLastChild() { void Algorithm::trackAlgorithmHistory( boost::shared_ptr<AlgorithmHistory> parentHist) { enableHistoryRecordingForChild(true); - m_parentHistory = parentHist; + m_parentHistory = std::move(parentHist); } /** Check if we are tracking history for this algorithm @@ -1569,6 +1570,7 @@ void Algorithm::copyNonWorkspaceProperties(IAlgorithm *alg, int periodNum) { const auto &props = this->getProperties(); for (const auto &prop : props) { if (prop) { + auto *wsProp = dynamic_cast<IWorkspaceProperty *>(prop); // Copy the property using the string if (!wsProp) diff --git a/Framework/API/src/AlgorithmFactory.cpp b/Framework/API/src/AlgorithmFactory.cpp index 778a83eba0638eec7e82ff942bf92496be4786b7..5379a1b6dfc67d9d11645d3c62e50c4671647dea 100644 --- a/Framework/API/src/AlgorithmFactory.cpp +++ b/Framework/API/src/AlgorithmFactory.cpp @@ -406,7 +406,7 @@ void AlgorithmFactoryImpl::fillHiddenCategories( * @returns the name of the algroithm */ const std::string AlgorithmFactoryImpl::extractAlgName( - const boost::shared_ptr<IAlgorithm> alg) const { + const boost::shared_ptr<IAlgorithm> &alg) const { return alg->name(); } @@ -415,7 +415,7 @@ const std::string AlgorithmFactoryImpl::extractAlgName( * @returns the version of the algroithm */ int AlgorithmFactoryImpl::extractAlgVersion( - const boost::shared_ptr<IAlgorithm> alg) const { + const boost::shared_ptr<IAlgorithm> &alg) const { return alg->version(); } diff --git a/Framework/API/src/AlgorithmHistory.cpp b/Framework/API/src/AlgorithmHistory.cpp index 388b498f0303fd410f4c47867a1a13479214d1da..fd4208da5e549e1061a3d2c1a56aaf42c63ebaaa 100644 --- a/Framework/API/src/AlgorithmHistory.cpp +++ b/Framework/API/src/AlgorithmHistory.cpp @@ -21,6 +21,7 @@ #include <boost/uuid/uuid_generators.hpp> #include <boost/uuid/uuid_io.hpp> #include <sstream> +#include <utility> namespace Mantid { namespace API { @@ -85,7 +86,7 @@ AlgorithmHistory::AlgorithmHistory(const std::string &name, int vers, std::size_t uexeccount) : m_name(name), m_version(vers), m_executionDate(start), m_executionDuration(duration), m_execCount(uexeccount), - m_childHistories(), m_uuid(uuid) {} + m_childHistories(), m_uuid(std::move(uuid)) {} /** * Set the history properties for an algorithm pointer @@ -162,7 +163,7 @@ void AlgorithmHistory::addProperty(const std::string &name, /** Add a child algorithm history to history * @param childHist :: The child history */ -void AlgorithmHistory::addChildHistory(AlgorithmHistory_sptr childHist) { +void AlgorithmHistory::addChildHistory(const AlgorithmHistory_sptr &childHist) { // Don't copy one's own history onto oneself if (this == &(*childHist)) { return; diff --git a/Framework/API/src/AlgorithmObserver.cpp b/Framework/API/src/AlgorithmObserver.cpp index d8bd534c9201ac7aaed0004700d8bff284245144..5fb257a1a9a2b8f1353d60106fc7bceb95b87d29 100644 --- a/Framework/API/src/AlgorithmObserver.cpp +++ b/Framework/API/src/AlgorithmObserver.cpp @@ -7,8 +7,10 @@ //---------------------------------------------------------------------- // Includes //---------------------------------------------------------------------- -#include "MantidAPI/AlgorithmObserver.h" +#include <utility> + #include "MantidAPI/AlgorithmManager.h" +#include "MantidAPI/AlgorithmObserver.h" namespace Mantid { namespace API { @@ -26,13 +28,13 @@ AlgorithmObserver::AlgorithmObserver() alg. @param alg :: Algorithm to be observed */ -AlgorithmObserver::AlgorithmObserver(IAlgorithm_const_sptr alg) +AlgorithmObserver::AlgorithmObserver(const IAlgorithm_const_sptr &alg) : m_progressObserver(*this, &AlgorithmObserver::_progressHandle), m_startObserver(*this, &AlgorithmObserver::_startHandle), m_finishObserver(*this, &AlgorithmObserver::_finishHandle), m_errorObserver(*this, &AlgorithmObserver::_errorHandle), m_startingObserver(*this, &AlgorithmObserver::_startingHandle) { - observeAll(alg); + observeAll(std::move(alg)); } /// Virtual destructor @@ -41,7 +43,7 @@ AlgorithmObserver::~AlgorithmObserver() = default; /** Connect to algorithm alg and observe all its notifications @param alg :: Algorithm to be observed */ -void AlgorithmObserver::observeAll(IAlgorithm_const_sptr alg) { +void AlgorithmObserver::observeAll(const IAlgorithm_const_sptr &alg) { alg->addObserver(m_progressObserver); alg->addObserver(m_startObserver); alg->addObserver(m_finishObserver); @@ -51,7 +53,7 @@ void AlgorithmObserver::observeAll(IAlgorithm_const_sptr alg) { /** Connect to algorithm alg and observe its progress notification @param alg :: Algorithm to be observed */ -void AlgorithmObserver::observeProgress(IAlgorithm_const_sptr alg) { +void AlgorithmObserver::observeProgress(const IAlgorithm_const_sptr &alg) { alg->addObserver(m_progressObserver); } @@ -65,21 +67,21 @@ void AlgorithmObserver::observeStarting() { /** Connect to algorithm alg and observe its start notification @param alg :: Algorithm to be observed */ -void AlgorithmObserver::observeStart(IAlgorithm_const_sptr alg) { +void AlgorithmObserver::observeStart(const IAlgorithm_const_sptr &alg) { alg->addObserver(m_startObserver); } /** Connect to algorithm alg and observe its finish notification @param alg :: Algorithm to be observed */ -void AlgorithmObserver::observeFinish(IAlgorithm_const_sptr alg) { +void AlgorithmObserver::observeFinish(const IAlgorithm_const_sptr &alg) { alg->addObserver(m_finishObserver); } /** Connect to algorithm alg and observe its error notification @param alg :: Algorithm to be observed */ -void AlgorithmObserver::observeError(IAlgorithm_const_sptr alg) { +void AlgorithmObserver::observeError(const IAlgorithm_const_sptr &alg) { alg->addObserver(m_errorObserver); } @@ -87,7 +89,7 @@ void AlgorithmObserver::observeError(IAlgorithm_const_sptr alg) { inherited classes. @param alg :: Algorithm to be disconnected */ -void AlgorithmObserver::stopObserving(IAlgorithm_const_sptr alg) { +void AlgorithmObserver::stopObserving(const IAlgorithm_const_sptr &alg) { this->stopObserving(alg.get()); } diff --git a/Framework/API/src/AlgorithmProperty.cpp b/Framework/API/src/AlgorithmProperty.cpp index 31e3f471c899de26e11693896114b67c054314a7..512ae7a5bfef738a0f1db92e7eadb45b6a6d4af9 100644 --- a/Framework/API/src/AlgorithmProperty.cpp +++ b/Framework/API/src/AlgorithmProperty.cpp @@ -12,6 +12,8 @@ #include <json/value.h> +#include <utility> + namespace Mantid { namespace API { @@ -29,8 +31,8 @@ namespace API { AlgorithmProperty::AlgorithmProperty(const std::string &propName, Kernel::IValidator_sptr validator, unsigned int direction) - : Kernel::PropertyWithValue<HeldType>(propName, HeldType(), validator, - direction), + : Kernel::PropertyWithValue<HeldType>(propName, HeldType(), + std::move(validator), direction), m_algmStr() {} /** diff --git a/Framework/API/src/AlgorithmProxy.cpp b/Framework/API/src/AlgorithmProxy.cpp index 4730a275f43568c6ad7720db257256b3f65801f8..876a9b51d1b1b2504dd0b0551f8f9870860d3b5c 100644 --- a/Framework/API/src/AlgorithmProxy.cpp +++ b/Framework/API/src/AlgorithmProxy.cpp @@ -21,7 +21,7 @@ namespace Mantid { namespace API { /// Constructor -AlgorithmProxy::AlgorithmProxy(Algorithm_sptr alg) +AlgorithmProxy::AlgorithmProxy(const Algorithm_sptr &alg) : PropertyManagerOwner(), m_executeAsync(new Poco::ActiveMethod<bool, Poco::Void, AlgorithmProxy>( this, &AlgorithmProxy::executeAsyncImpl)), diff --git a/Framework/API/src/BoostOptionalToAlgorithmProperty.cpp b/Framework/API/src/BoostOptionalToAlgorithmProperty.cpp index 109e56d0a3a75da9bd287dea64304784c222b0ac..ca6898c604e185cb9f9b3252aec7145f25743c84 100644 --- a/Framework/API/src/BoostOptionalToAlgorithmProperty.cpp +++ b/Framework/API/src/BoostOptionalToAlgorithmProperty.cpp @@ -10,8 +10,9 @@ namespace Mantid { namespace API { template <> std::string checkForMandatoryInstrumentDefault( - Mantid::API::Algorithm *const alg, std::string propName, - Mantid::Geometry::Instrument_const_sptr instrument, std::string idf_name) { + Mantid::API::Algorithm *const alg, const std::string &propName, + const Mantid::Geometry::Instrument_const_sptr &instrument, + const std::string &idf_name) { auto algProperty = alg->getPointerToProperty(propName); if (algProperty->isDefault()) { auto defaults = instrument->getStringParameter(idf_name); @@ -28,8 +29,9 @@ std::string checkForMandatoryInstrumentDefault( template <> boost::optional<std::string> checkForOptionalInstrumentDefault( - Mantid::API::Algorithm *const alg, std::string propName, - Mantid::Geometry::Instrument_const_sptr instrument, std::string idf_name) { + Mantid::API::Algorithm *const alg, const std::string &propName, + const Mantid::Geometry::Instrument_const_sptr &instrument, + const std::string &idf_name) { auto algProperty = alg->getPointerToProperty(propName); if (algProperty->isDefault()) { auto defaults = instrument->getStringParameter(idf_name); diff --git a/Framework/API/src/BoxController.cpp b/Framework/API/src/BoxController.cpp index 16e8a31e11b9c626a89a522f12215322038c217c..1590696cb4cac060808f12cca60badaec360afb4 100644 --- a/Framework/API/src/BoxController.cpp +++ b/Framework/API/src/BoxController.cpp @@ -296,8 +296,9 @@ void BoxController::clearFileBacked() { *@param fileName -- if newFileIO comes without opened file, this is the file *name to open for the file based IO operations */ -void BoxController::setFileBacked(boost::shared_ptr<IBoxControllerIO> newFileIO, - const std::string &fileName) { +void BoxController::setFileBacked( + const boost::shared_ptr<IBoxControllerIO> &newFileIO, + const std::string &fileName) { if (!newFileIO->isOpened()) newFileIO->openFile(fileName, "w"); diff --git a/Framework/API/src/CatalogManager.cpp b/Framework/API/src/CatalogManager.cpp index 9dd38cd2f511a10bf38fe7cbed39b2df8417e68f..e5dd10da271aa856cf809573765d4cd6923235c0 100644 --- a/Framework/API/src/CatalogManager.cpp +++ b/Framework/API/src/CatalogManager.cpp @@ -7,6 +7,7 @@ #include "MantidAPI/CatalogManager.h" #include "MantidAPI/CatalogFactory.h" #include "MantidAPI/CompositeCatalog.h" +#include "MantidAPI/FunctionFactory.h" #include "MantidKernel/ConfigService.h" #include "MantidKernel/FacilityInfo.h" @@ -105,9 +106,10 @@ void CatalogManagerImpl::destroyCatalog(const std::string &sessionID) { std::vector<CatalogSession_sptr> CatalogManagerImpl::getActiveSessions() { std::vector<CatalogSession_sptr> sessions; sessions.reserve(m_activeCatalogs.size()); - for (const auto &activeCatalog : m_activeCatalogs) { - sessions.emplace_back(activeCatalog.first); - } + + std::transform(m_activeCatalogs.begin(), m_activeCatalogs.end(), + std::back_inserter(sessions), + [](const auto &activeCatalog) { return activeCatalog.first; }); return sessions; } diff --git a/Framework/API/src/CompositeCatalog.cpp b/Framework/API/src/CompositeCatalog.cpp index d6e50e3b97d59f19146487aa80c2b9c013bb6025..f838b719ca0c8c51905710f78fba0bcebee01ce4 100644 --- a/Framework/API/src/CompositeCatalog.cpp +++ b/Framework/API/src/CompositeCatalog.cpp @@ -16,7 +16,7 @@ CompositeCatalog::CompositeCatalog() : m_catalogs() {} * Add a catalog to the catalog container. * @param catalog :: The catalog to add to the container. */ -void CompositeCatalog::add(const ICatalog_sptr catalog) { +void CompositeCatalog::add(const ICatalog_sptr &catalog) { m_catalogs.emplace_back(catalog); } diff --git a/Framework/API/src/CompositeDomainMD.cpp b/Framework/API/src/CompositeDomainMD.cpp index 1a549852bc55e99aae1b385f5ab8168d5938b464..6762e9be597c90814b65cba3a8147223193a11fa 100644 --- a/Framework/API/src/CompositeDomainMD.cpp +++ b/Framework/API/src/CompositeDomainMD.cpp @@ -21,11 +21,18 @@ namespace API { * @param ws :: Pointer to a workspace. * @param maxDomainSize :: The maximum size each domain can have. */ -CompositeDomainMD::CompositeDomainMD(IMDWorkspace_const_sptr ws, +CompositeDomainMD::CompositeDomainMD(const IMDWorkspace_const_sptr &ws, size_t maxDomainSize) : m_iterator(ws->createIterator()) { m_totalSize = m_iterator->getDataSize(); - size_t nParts = m_totalSize / maxDomainSize + 1; + + size_t maxDomainSizeDiv = maxDomainSize + 1; + if (maxDomainSizeDiv == 0) { + throw std::runtime_error( + "Attempted to use a maximum domain size that equals 0"); + } + size_t nParts = m_totalSize / maxDomainSizeDiv; + m_domains.resize(nParts); for (size_t i = 0; i < nParts - 1; ++i) { size_t start = i * maxDomainSize; diff --git a/Framework/API/src/CompositeFunction.cpp b/Framework/API/src/CompositeFunction.cpp index ec17675164b006a70fbba23ad0879387cdbb19cf..39c4976ea00adaa57409e58eb98048ca756b2474 100644 --- a/Framework/API/src/CompositeFunction.cpp +++ b/Framework/API/src/CompositeFunction.cpp @@ -19,6 +19,7 @@ #include <boost/lexical_cast.hpp> #include <boost/shared_array.hpp> #include <sstream> +#include <utility> namespace Mantid { namespace API { @@ -468,21 +469,21 @@ void CompositeFunction::removeFunction(size_t i) { * a member of this composite function nothing happens * @param f_new :: A pointer to the new function */ -void CompositeFunction::replaceFunctionPtr(const IFunction_sptr f_old, - IFunction_sptr f_new) { +void CompositeFunction::replaceFunctionPtr(const IFunction_sptr &f_old, + const IFunction_sptr &f_new) { std::vector<IFunction_sptr>::const_iterator it = std::find(m_functions.begin(), m_functions.end(), f_old); if (it == m_functions.end()) return; std::vector<IFunction_sptr>::difference_type iFun = it - m_functions.begin(); - replaceFunction(iFun, f_new); + replaceFunction(iFun, std::move(f_new)); } /** Replace a function with a new one. The old function is deleted. * @param i :: The index of the function to replace * @param f :: A pointer to the new function */ -void CompositeFunction::replaceFunction(size_t i, IFunction_sptr f) { +void CompositeFunction::replaceFunction(size_t i, const IFunction_sptr &f) { if (i >= nFunctions()) { throw std::out_of_range("Function index (" + std::to_string(i) + ") out of range (" + std::to_string(nFunctions()) + diff --git a/Framework/API/src/DataProcessorAlgorithm.cpp b/Framework/API/src/DataProcessorAlgorithm.cpp index 4f82c06e981672c2229587c83695dd2847d28c95..ebd21763b9c7e1e444324b5317e4aff75978a652 100644 --- a/Framework/API/src/DataProcessorAlgorithm.cpp +++ b/Framework/API/src/DataProcessorAlgorithm.cpp @@ -19,6 +19,8 @@ #include "MantidKernel/System.h" #include "Poco/Path.h" #include <stdexcept> +#include <utility> + #ifdef MPI_BUILD #include <boost/mpi.hpp> #endif @@ -135,7 +137,7 @@ void GenericDataProcessorAlgorithm<Base>::mapPropertyName( */ template <class Base> void GenericDataProcessorAlgorithm<Base>::copyProperty( - API::Algorithm_sptr alg, const std::string &name) { + const API::Algorithm_sptr &alg, const std::string &name) { if (!alg->existsProperty(name)) { std::stringstream msg; msg << "Algorithm \"" << alg->name() << "\" does not have property \"" @@ -232,7 +234,7 @@ GenericDataProcessorAlgorithm<Base>::loadChunk(const size_t rowIndex) { template <class Base> Workspace_sptr GenericDataProcessorAlgorithm<Base>::assemble(Workspace_sptr partialWS) { - Workspace_sptr outputWS = partialWS; + Workspace_sptr outputWS = std::move(partialWS); #ifdef MPI_BUILD IAlgorithm_sptr gatherAlg = createChildAlgorithm("GatherWorkspaces"); gatherAlg->setLogging(true); diff --git a/Framework/API/src/DetectorSearcher.cpp b/Framework/API/src/DetectorSearcher.cpp index a183c4841f6145d61a5b2a1180e377a94dc421d2..cd25bce0e98fc5cc3caa06aef7d12a31c0394379 100644 --- a/Framework/API/src/DetectorSearcher.cpp +++ b/Framework/API/src/DetectorSearcher.cpp @@ -30,8 +30,9 @@ double getQSign() { * @param instrument :: the instrument to find detectors in * @param detInfo :: the Geometry::DetectorInfo object for this instrument */ -DetectorSearcher::DetectorSearcher(Geometry::Instrument_const_sptr instrument, - const Geometry::DetectorInfo &detInfo) +DetectorSearcher::DetectorSearcher( + const Geometry::Instrument_const_sptr &instrument, + const Geometry::DetectorInfo &detInfo) : m_usingFullRayTrace(instrument->containsRectDetectors() == Geometry::Instrument::ContainsState::Full), m_crystallography_convention(getQSign()), m_detInfo(detInfo), diff --git a/Framework/API/src/ExperimentInfo.cpp b/Framework/API/src/ExperimentInfo.cpp index 8b351649ca603cf0a2884e49ea63e6db640898cc..5310526a330bf1496b4808dd2d838595f0fa5f2b 100644 --- a/Framework/API/src/ExperimentInfo.cpp +++ b/Framework/API/src/ExperimentInfo.cpp @@ -711,7 +711,7 @@ double ExperimentInfo::getEFixed(const detid_t detID) const { * @return The current efixed value */ double ExperimentInfo::getEFixed( - const boost::shared_ptr<const Geometry::IDetector> detector) const { + const boost::shared_ptr<const Geometry::IDetector> &detector) const { populateIfNotLoaded(); Kernel::DeltaEMode::Type emode = getEMode(); if (emode == Kernel::DeltaEMode::Direct) { @@ -944,8 +944,10 @@ std::vector<std::string> ExperimentInfo::getResourceFilenames( std::vector<std::string> pathNames; if (!matchingFiles.empty()) { pathNames.reserve(matchingFiles.size()); - for (auto &elem : matchingFiles) - pathNames.emplace_back(std::move(elem.second)); + + std::transform(matchingFiles.begin(), matchingFiles.end(), + std::back_inserter(pathNames), + [](const auto &elem) { return elem.second; }); } else { pathNames.emplace_back(std::move(mostRecentFile)); } diff --git a/Framework/API/src/Expression.cpp b/Framework/API/src/Expression.cpp index 67df10cc2af04decf18d62663aed50dd0abcf56e..5308ca5283ba369cc646dd73151157d8c03bec93 100644 --- a/Framework/API/src/Expression.cpp +++ b/Framework/API/src/Expression.cpp @@ -117,8 +117,8 @@ Expression &Expression::operator=(const Expression &expr) { m_funct = expr.m_funct; m_op = expr.m_op; m_terms = expr.m_terms; - // m_expr = expr.m_expr; - // m_tokens = expr.m_tokens; + m_expr = expr.m_expr; + m_tokens = expr.m_tokens; return *this; } diff --git a/Framework/API/src/FunctionDomainGeneral.cpp b/Framework/API/src/FunctionDomainGeneral.cpp index 6be66bafb29538278b7edcbd50bc541c1b84c97d..7000ed1580f542480c395fbc9dd9c65dfdd5b42a 100644 --- a/Framework/API/src/FunctionDomainGeneral.cpp +++ b/Framework/API/src/FunctionDomainGeneral.cpp @@ -22,7 +22,7 @@ size_t FunctionDomainGeneral::size() const { size_t FunctionDomainGeneral::columnCount() const { return m_columns.size(); } /// Add a new column. All columns must have the same size. -void FunctionDomainGeneral::addColumn(boost::shared_ptr<Column> column) { +void FunctionDomainGeneral::addColumn(const boost::shared_ptr<Column> &column) { if (!column) { throw std::runtime_error( "Cannot add null column to FunctionDomainGeneral."); diff --git a/Framework/API/src/FunctionDomainMD.cpp b/Framework/API/src/FunctionDomainMD.cpp index 4dab31a2fae950f503b4be0c25e205b9831ef5c3..51cf298b927935a356f514a04d026627daa0e297 100644 --- a/Framework/API/src/FunctionDomainMD.cpp +++ b/Framework/API/src/FunctionDomainMD.cpp @@ -21,8 +21,8 @@ namespace API { * @param start :: Index of the first iterator in this domain. * @param length :: Size of this domain. If 0 use all workspace. */ -FunctionDomainMD::FunctionDomainMD(IMDWorkspace_const_sptr ws, size_t start, - size_t length) +FunctionDomainMD::FunctionDomainMD(const IMDWorkspace_const_sptr &ws, + size_t start, size_t length) : m_iterator(ws->createIterator()), m_startIndex(start), m_currentIndex(0), m_justReset(true), m_workspace(ws) { size_t dataSize = m_iterator->getDataSize(); diff --git a/Framework/API/src/FunctionFactory.cpp b/Framework/API/src/FunctionFactory.cpp index 79936f3668d00fe95f26eb3b4d28cd55201a410d..9ada8ccf36c5515052cacfa808779f896a212dad 100644 --- a/Framework/API/src/FunctionFactory.cpp +++ b/Framework/API/src/FunctionFactory.cpp @@ -271,7 +271,7 @@ void FunctionFactoryImpl::inputError(const std::string &str) const { * separated by commas ',' * and enclosed in brackets "(...)" . */ -void FunctionFactoryImpl::addConstraints(IFunction_sptr fun, +void FunctionFactoryImpl::addConstraints(const IFunction_sptr &fun, const Expression &expr) const { if (expr.name() == ",") { for (auto it = expr.begin(); it != expr.end(); ++it) { @@ -305,7 +305,7 @@ void FunctionFactoryImpl::addConstraints(IFunction_sptr fun, * @param fun :: The function * @param expr :: The constraint expression. */ -void FunctionFactoryImpl::addConstraint(boost::shared_ptr<IFunction> fun, +void FunctionFactoryImpl::addConstraint(const boost::shared_ptr<IFunction> &fun, const Expression &expr) const { auto c = std::unique_ptr<IConstraint>( ConstraintFactory::Instance().createInitialized(fun.get(), expr)); @@ -319,7 +319,7 @@ void FunctionFactoryImpl::addConstraint(boost::shared_ptr<IFunction> fun, * @param constraint_expr :: The constraint expression. * @param penalty_expr :: The penalty expression. */ -void FunctionFactoryImpl::addConstraint(boost::shared_ptr<IFunction> fun, +void FunctionFactoryImpl::addConstraint(const boost::shared_ptr<IFunction> &fun, const Expression &constraint_expr, const Expression &penalty_expr) const { auto c = std::unique_ptr<IConstraint>( @@ -335,7 +335,7 @@ void FunctionFactoryImpl::addConstraint(boost::shared_ptr<IFunction> fun, * @param expr :: The tie expression: either parName = TieString or a list * of name = string pairs */ -void FunctionFactoryImpl::addTies(IFunction_sptr fun, +void FunctionFactoryImpl::addTies(const IFunction_sptr &fun, const Expression &expr) const { if (expr.name() == "=") { addTie(fun, expr); @@ -350,7 +350,7 @@ void FunctionFactoryImpl::addTies(IFunction_sptr fun, * @param fun :: The function * @param expr :: The tie expression: parName = TieString */ -void FunctionFactoryImpl::addTie(IFunction_sptr fun, +void FunctionFactoryImpl::addTie(const IFunction_sptr &fun, const Expression &expr) const { if (expr.size() > 1) { // if size > 2 it is interpreted as setting a tie (last // expr.term) to multiple parameters, e.g diff --git a/Framework/API/src/FunctionGenerator.cpp b/Framework/API/src/FunctionGenerator.cpp index 5a601242606cc5c92d3cb8af33a8c44635af30b7..a5b08fe53618f43f57d0f0b94922293fb9be7704 100644 --- a/Framework/API/src/FunctionGenerator.cpp +++ b/Framework/API/src/FunctionGenerator.cpp @@ -4,6 +4,8 @@ // NScD Oak Ridge National Laboratory, European Spallation Source, // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + +#include <utility> + #include "MantidAPI/FunctionGenerator.h" #include "MantidAPI/IConstraint.h" #include "MantidAPI/ParameterTie.h" @@ -14,7 +16,7 @@ namespace API { using namespace Kernel; /// Constructor -FunctionGenerator::FunctionGenerator(IFunction_sptr source) +FunctionGenerator::FunctionGenerator(const IFunction_sptr &source) : m_source(source), m_dirty(true) { if (source) { m_nOwnParams = source->nParams(); @@ -27,7 +29,7 @@ void FunctionGenerator::init() {} /// Set the source function /// @param source :: New source function. void FunctionGenerator::setSource(IFunction_sptr source) const { - m_source = source; + m_source = std::move(source); } /// Set i-th parameter diff --git a/Framework/API/src/GridDomain1D.cpp b/Framework/API/src/GridDomain1D.cpp index b177e7c0d10bd43fda81d4b36062fd80c015a7de..3f076e75acaccff830558fb19ce019053d38c821 100644 --- a/Framework/API/src/GridDomain1D.cpp +++ b/Framework/API/src/GridDomain1D.cpp @@ -17,7 +17,7 @@ namespace Mantid { namespace API { void GridDomain1D::initialize(double &startX, double &endX, size_t &n, - const std::string scaling) { + const std::string &scaling) { m_points.resize(n); m_points.front() = startX; m_points.back() = endX; diff --git a/Framework/API/src/GroupingLoader.cpp b/Framework/API/src/GroupingLoader.cpp index 527ad4d151b26269239388af22713524ac675f25..d34c9b75864d048ac16a798dc72555797326c83a 100644 --- a/Framework/API/src/GroupingLoader.cpp +++ b/Framework/API/src/GroupingLoader.cpp @@ -16,6 +16,7 @@ #include <Poco/DOM/Document.h> #include <Poco/DOM/NodeList.h> #include <boost/make_shared.hpp> +#include <utility> using namespace Poco::XML; @@ -27,7 +28,7 @@ namespace API { * @param instrument :: [input] Instrument */ GroupingLoader::GroupingLoader(Geometry::Instrument_const_sptr instrument) - : m_instrument(instrument) {} + : m_instrument(std::move(instrument)) {} /** Constructor with field direction * @param instrument :: [input] Instrument @@ -35,7 +36,8 @@ GroupingLoader::GroupingLoader(Geometry::Instrument_const_sptr instrument) */ GroupingLoader::GroupingLoader(Geometry::Instrument_const_sptr instrument, const std::string &mainFieldDirection) - : m_instrument(instrument), m_mainFieldDirection(mainFieldDirection) {} + : m_instrument(std::move(instrument)), + m_mainFieldDirection(mainFieldDirection) {} //---------------------------------------------------------------------------------------------- /** Destructor @@ -248,7 +250,7 @@ boost::shared_ptr<Grouping> GroupingLoader::getDummyGrouping() { * Construct a Grouping from a table * @param table :: [input] Table to construct from */ -Grouping::Grouping(ITableWorkspace_sptr table) { +Grouping::Grouping(const ITableWorkspace_sptr &table) { for (size_t row = 0; row < table->rowCount(); ++row) { std::vector<int> detectors = table->cell<std::vector<int>>(row, 0); diff --git a/Framework/API/src/HistoryItem.cpp b/Framework/API/src/HistoryItem.cpp index 917e1d076ea490bb2f49cac713823841331d643e..34208d196c36e70196457d07265f97fc87015613 100644 --- a/Framework/API/src/HistoryItem.cpp +++ b/Framework/API/src/HistoryItem.cpp @@ -7,13 +7,15 @@ //---------------------------------------------------------------------- // Includes //---------------------------------------------------------------------- +#include <utility> + #include "MantidAPI/HistoryItem.h" namespace Mantid { namespace API { HistoryItem::HistoryItem(AlgorithmHistory_const_sptr algHist) - : m_algorithmHistory(algHist), m_unrolled(false) {} + : m_algorithmHistory(std::move(algHist)), m_unrolled(false) {} } // namespace API } // namespace Mantid diff --git a/Framework/API/src/IFunction.cpp b/Framework/API/src/IFunction.cpp index 425ca89b111463ebfe5389cb6a8ba54f668103b3..887b5dd17896885fcabad0bf52c40aa99abc9d43 100644 --- a/Framework/API/src/IFunction.cpp +++ b/Framework/API/src/IFunction.cpp @@ -38,6 +38,7 @@ #include <algorithm> #include <limits> #include <sstream> +#include <utility> namespace Mantid { namespace API { @@ -87,7 +88,7 @@ boost::shared_ptr<IFunction> IFunction::clone() const { */ void IFunction::setProgressReporter( boost::shared_ptr<Kernel::ProgressBase> reporter) { - m_progReporter = reporter; + m_progReporter = std::move(reporter); m_progReporter->setNotifyStep(0.01); } @@ -558,10 +559,11 @@ std::vector<std::string> IFunction::getParameterNames() const { * @param handler :: A new handler */ void IFunction::setHandler(std::unique_ptr<FunctionHandler> handler) { - m_handler = std::move(handler); if (handler && handler->function().get() != this) { throw std::runtime_error("Function handler points to a different function"); } + + m_handler = std::move(handler); m_handler->init(); } @@ -1241,9 +1243,10 @@ void IFunction::setMatrixWorkspace( * @param wsIndex :: workspace index * @return converted value */ -double IFunction::convertValue(double value, Kernel::Unit_sptr &outUnit, - boost::shared_ptr<const MatrixWorkspace> ws, - size_t wsIndex) const { +double +IFunction::convertValue(double value, Kernel::Unit_sptr &outUnit, + const boost::shared_ptr<const MatrixWorkspace> &ws, + size_t wsIndex) const { // only required if formula or look-up-table different from ws unit const auto &wsUnit = ws->getAxis(0)->unit(); if (outUnit->unitID() == wsUnit->unitID()) @@ -1271,7 +1274,7 @@ double IFunction::convertValue(double value, Kernel::Unit_sptr &outUnit, */ void IFunction::convertValue(std::vector<double> &values, Kernel::Unit_sptr &outUnit, - boost::shared_ptr<const MatrixWorkspace> ws, + const boost::shared_ptr<const MatrixWorkspace> &ws, size_t wsIndex) const { // only required if formula or look-up-table different from ws unit const auto &wsUnit = ws->getAxis(0)->unit(); @@ -1361,9 +1364,10 @@ IFunction_sptr IFunction::getFunction(std::size_t) const { std::vector<std::string> IFunction::getAttributeNames() const { std::vector<std::string> names; names.reserve(m_attrs.size()); - for (const auto &attr : m_attrs) { - names.emplace_back(attr.first); - } + + std::transform(m_attrs.begin(), m_attrs.end(), std::back_inserter(names), + [](const auto &attr) { return attr.first; }); + return names; } @@ -1447,7 +1451,7 @@ void IFunction::storeReadOnlyAttribute( * @param covar :: A matrix to set. */ void IFunction::setCovarianceMatrix( - boost::shared_ptr<Kernel::Matrix<double>> covar) { + const boost::shared_ptr<Kernel::Matrix<double>> &covar) { // the matrix shouldn't be empty if (!covar) { throw std::invalid_argument( diff --git a/Framework/API/src/IMDWorkspace.cpp b/Framework/API/src/IMDWorkspace.cpp index 4933089184a59665a7e9003060eb2178335b303c..4e84206a2f8bab302f14d857b61751c1cfc0a740 100644 --- a/Framework/API/src/IMDWorkspace.cpp +++ b/Framework/API/src/IMDWorkspace.cpp @@ -12,6 +12,7 @@ #include "MantidKernel/VMD.h" #include <sstream> +#include <utility> using Mantid::Kernel::VMD; @@ -53,7 +54,7 @@ std::string IMDWorkspace::getConvention() const { return m_convention; } /** @return the convention */ void IMDWorkspace::setConvention(std::string convention) { - m_convention = convention; + m_convention = std::move(convention); } //--------------------------------------------------------------------------------------------- diff --git a/Framework/API/src/IndexProperty.cpp b/Framework/API/src/IndexProperty.cpp index d3dece746261a4de72336c16fd5091ba2d86ebb0..9ea0c194546d58b1beba0c1e5d4b7cd06feb5616 100644 --- a/Framework/API/src/IndexProperty.cpp +++ b/Framework/API/src/IndexProperty.cpp @@ -4,6 +4,8 @@ // NScD Oak Ridge National Laboratory, European Spallation Source, // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + +#include <utility> + #include "MantidAPI/IndexProperty.h" #include "MantidAPI/MatrixWorkspace.h" #include "MantidIndexing/GlobalSpectrumIndex.h" @@ -16,9 +18,10 @@ namespace API { IndexProperty::IndexProperty(const std::string &name, const IWorkspaceProperty &workspaceProp, const IndexTypeProperty &indexTypeProp, - Kernel::IValidator_sptr validator) - : ArrayProperty(name, "", validator), m_workspaceProp(workspaceProp), - m_indexTypeProp(indexTypeProp), m_indices(0), m_indicesExtracted(false) {} + const Kernel::IValidator_sptr &validator) + : ArrayProperty(name, "", std::move(validator)), + m_workspaceProp(workspaceProp), m_indexTypeProp(indexTypeProp), + m_indices(0), m_indicesExtracted(false) {} IndexProperty *IndexProperty::clone() const { return new IndexProperty(*this); } diff --git a/Framework/API/src/JointDomain.cpp b/Framework/API/src/JointDomain.cpp index b77efd802930226720e2d2c256b2b20548f98ef3..f6b6490db31bf4bc277be1cfea7b35ce73b5591b 100644 --- a/Framework/API/src/JointDomain.cpp +++ b/Framework/API/src/JointDomain.cpp @@ -33,7 +33,7 @@ const FunctionDomain &JointDomain::getDomain(size_t i) const { * Add a new domain. * @param domain :: A shared pointer to a domain. */ -void JointDomain::addDomain(FunctionDomain_sptr domain) { +void JointDomain::addDomain(const FunctionDomain_sptr &domain) { m_domains.emplace_back(domain); } diff --git a/Framework/API/src/MDGeometry.cpp b/Framework/API/src/MDGeometry.cpp index 8c0291e077c1b25e1587a90fa4409abbdc76a0ed..08de2f9e6dd324482c192b15656bfacf38f9cdd7 100644 --- a/Framework/API/src/MDGeometry.cpp +++ b/Framework/API/src/MDGeometry.cpp @@ -14,6 +14,7 @@ #include <Poco/NObserver.h> #include <boost/make_shared.hpp> +#include <utility> using namespace Mantid::Kernel; using namespace Mantid::API; @@ -244,7 +245,7 @@ size_t MDGeometry::getDimensionIndexById(const std::string &id) const { /** Add a dimension * @param dim :: shared pointer to the dimension object */ void MDGeometry::addDimension( - boost::shared_ptr<Mantid::Geometry::IMDDimension> dim) { + const boost::shared_ptr<Mantid::Geometry::IMDDimension> &dim) { m_dimensions.emplace_back(dim); } @@ -382,7 +383,7 @@ void MDGeometry::setOriginalWorkspace(boost::shared_ptr<Workspace> ws, size_t index) { if (index >= m_originalWorkspaces.size()) m_originalWorkspaces.resize(index + 1); - m_originalWorkspaces[index] = ws; + m_originalWorkspaces[index] = std::move(ws); m_notificationHelper->watchForWorkspaceDeletions(); } diff --git a/Framework/API/src/MatrixWorkspace.cpp b/Framework/API/src/MatrixWorkspace.cpp index 41d8c4fe152b2954eea2687cdd00fb1c22b14d15..931023650ac4fefae7823f772d9242242ac184e0 100644 --- a/Framework/API/src/MatrixWorkspace.cpp +++ b/Framework/API/src/MatrixWorkspace.cpp @@ -1237,9 +1237,10 @@ MatrixWorkspace::maskedBinsIndices(const size_t &workspaceIndex) const { auto maskedBins = it->second; std::vector<size_t> maskedIds; maskedIds.reserve(maskedBins.size()); - for (const auto &mb : maskedBins) { - maskedIds.emplace_back(mb.first); - } + + std::transform(maskedBins.begin(), maskedBins.end(), + std::back_inserter(maskedIds), + [](const auto &mb) { return mb.first; }); return maskedIds; } @@ -1939,7 +1940,6 @@ MatrixWorkspace::findY(double value, if (std::isnan(value)) { for (int64_t i = idx.first; i < numHists; ++i) { const auto &Y = this->y(i); - // cppcheck-suppress syntaxError if (auto it = std::find_if(std::next(Y.begin(), idx.second), Y.end(), [](double v) { return std::isnan(v); }); it != Y.end()) { diff --git a/Framework/API/src/MultiPeriodGroupWorker.cpp b/Framework/API/src/MultiPeriodGroupWorker.cpp index 0631fe5d508960782034edfbcc24be48f1893ed4..19e2b1ba6e4cbfd3196b0b34d68dcc45e283acac 100644 --- a/Framework/API/src/MultiPeriodGroupWorker.cpp +++ b/Framework/API/src/MultiPeriodGroupWorker.cpp @@ -36,7 +36,7 @@ MultiPeriodGroupWorker::MultiPeriodGroupWorker( * @param vecWorkspaceGroups: Vector of non-multi period workspace groups. */ void MultiPeriodGroupWorker::tryAddInputWorkspaceToInputGroups( - Workspace_sptr ws, + const Workspace_sptr &ws, MultiPeriodGroupWorker::VecWSGroupType &vecMultiPeriodWorkspaceGroups, MultiPeriodGroupWorker::VecWSGroupType &vecWorkspaceGroups) const { WorkspaceGroup_sptr inputGroup = diff --git a/Framework/API/src/MultipleExperimentInfos.cpp b/Framework/API/src/MultipleExperimentInfos.cpp index 9906877314c69a2655beed6ec75bb9cea5d317bc..7433e6efa12965ef5f8f4c9059fcf3a5f22db27e 100644 --- a/Framework/API/src/MultipleExperimentInfos.cpp +++ b/Framework/API/src/MultipleExperimentInfos.cpp @@ -11,6 +11,7 @@ #include <boost/make_shared.hpp> #include <sstream> +#include <utility> using namespace Mantid::Kernel; using namespace Mantid::API; @@ -62,7 +63,8 @@ MultipleExperimentInfos::getExperimentInfo(const uint16_t runIndex) const { * @return the runIndex at which it was added * @throw std::runtime_error if you reach the limit of 65536 entries. */ -uint16_t MultipleExperimentInfos::addExperimentInfo(ExperimentInfo_sptr ei) { +uint16_t +MultipleExperimentInfos::addExperimentInfo(const ExperimentInfo_sptr &ei) { m_expInfos.emplace_back(ei); if (m_expInfos.size() >= static_cast<size_t>(std::numeric_limits<uint16_t>::max())) @@ -82,7 +84,7 @@ void MultipleExperimentInfos::setExperimentInfo(const uint16_t runIndex, if (size_t(runIndex) >= m_expInfos.size()) throw std::invalid_argument( "MDEventWorkspace::setExperimentInfo(): runIndex is out of range."); - m_expInfos[runIndex] = ei; + m_expInfos[runIndex] = std::move(ei); } //----------------------------------------------------------------------------------------------- diff --git a/Framework/API/src/NotebookBuilder.cpp b/Framework/API/src/NotebookBuilder.cpp index f74ac2867491e6f51fb5bd18acd070b94acfecaf..e3f2bcc48ddd6a6ccef2a1834f235bc54c08ac5e 100644 --- a/Framework/API/src/NotebookBuilder.cpp +++ b/Framework/API/src/NotebookBuilder.cpp @@ -14,6 +14,7 @@ #include "MantidKernel/Property.h" #include <boost/utility.hpp> +#include <utility> namespace Mantid { namespace API { @@ -25,10 +26,10 @@ namespace { Mantid::Kernel::Logger g_log("NotebookBuilder"); } -NotebookBuilder::NotebookBuilder(boost::shared_ptr<HistoryView> view, +NotebookBuilder::NotebookBuilder(const boost::shared_ptr<HistoryView> &view, std::string versionSpecificity) : m_historyItems(view->getAlgorithmsList()), m_output(), - m_versionSpecificity(versionSpecificity), + m_versionSpecificity(std::move(versionSpecificity)), m_nb_writer(new NotebookWriter()) {} /** @@ -39,9 +40,9 @@ NotebookBuilder::NotebookBuilder(boost::shared_ptr<HistoryView> view, * @param ws_comment :: workspace comment * @return a formatted ipython notebook string of the history */ -const std::string NotebookBuilder::build(std::string ws_name, - std::string ws_title, - std::string ws_comment) { +const std::string NotebookBuilder::build(const std::string &ws_name, + const std::string &ws_title, + const std::string &ws_comment) { // record workspace details in notebook std::string workspace_details; workspace_details = "Workspace History: " + ws_name + "\n"; @@ -109,8 +110,8 @@ void NotebookBuilder::buildChildren( * @param algHistory :: pointer to an algorithm history object * @returns std::string to run this algorithm */ -const std::string -NotebookBuilder::buildAlgorithmString(AlgorithmHistory_const_sptr algHistory) { +const std::string NotebookBuilder::buildAlgorithmString( + const AlgorithmHistory_const_sptr &algHistory) { std::ostringstream properties; const std::string name = algHistory->name(); std::string prop; @@ -159,8 +160,8 @@ NotebookBuilder::buildAlgorithmString(AlgorithmHistory_const_sptr algHistory) { * @param propHistory :: reference to a property history object * @returns std::string for this property */ -const std::string -NotebookBuilder::buildPropertyString(PropertyHistory_const_sptr propHistory) { +const std::string NotebookBuilder::buildPropertyString( + const PropertyHistory_const_sptr &propHistory) { using Mantid::Kernel::Direction; // Create a vector of all non workspace property type names diff --git a/Framework/API/src/NotebookWriter.cpp b/Framework/API/src/NotebookWriter.cpp index e61de82600f8e4fdb9fbe79aadfff6401e87aeb5..25d7e80de99609a6ab251a631dd0a8077906199e 100644 --- a/Framework/API/src/NotebookWriter.cpp +++ b/Framework/API/src/NotebookWriter.cpp @@ -4,6 +4,8 @@ // NScD Oak Ridge National Laboratory, European Spallation Source, // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + +#include <utility> + #include "MantidAPI/NotebookWriter.h" #include "MantidKernel/Logger.h" #include "MantidKernel/MantidVersion.h" @@ -34,7 +36,7 @@ void NotebookWriter::codeCell(Json::Value array_code) { cell_data["cell_type"] = "code"; cell_data["collapsed"] = false; - cell_data["input"] = array_code; + cell_data["input"] = std::move(array_code); cell_data["language"] = "python"; cell_data["metadata"] = empty; cell_data["outputs"] = Json::Value(Json::arrayValue); @@ -47,7 +49,7 @@ void NotebookWriter::codeCell(Json::Value array_code) { * * @param string_code :: string containing the python for the code cell */ -std::string NotebookWriter::codeCell(std::string string_code) { +std::string NotebookWriter::codeCell(const std::string &string_code) { Json::Value cell_data; const Json::Value empty = Json::Value(Json::ValueType::objectValue); @@ -77,7 +79,7 @@ void NotebookWriter::markdownCell(Json::Value string_array) { cell_data["cell_type"] = "markdown"; cell_data["metadata"] = empty; - cell_data["source"] = string_array; + cell_data["source"] = std::move(string_array); m_cell_buffer.append(cell_data); } @@ -87,7 +89,7 @@ void NotebookWriter::markdownCell(Json::Value string_array) { * * @param string_text :: string containing the python code for the code cell */ -std::string NotebookWriter::markdownCell(std::string string_text) { +std::string NotebookWriter::markdownCell(const std::string &string_text) { Json::Value cell_data; const Json::Value empty = Json::Value(Json::ValueType::objectValue); diff --git a/Framework/API/src/ParamFunction.cpp b/Framework/API/src/ParamFunction.cpp index b59894b305c8775e11ffa596aa3b09c0d3a61fd3..66b2b282edab56dc13d64b68a5df86d1a99562b2 100644 --- a/Framework/API/src/ParamFunction.cpp +++ b/Framework/API/src/ParamFunction.cpp @@ -150,7 +150,7 @@ double ParamFunction::getParameter(const std::string &name) const { */ bool ParamFunction::hasParameter(const std::string &name) const { return std::find(m_parameterNames.cbegin(), m_parameterNames.cend(), name) != - m_parameterNames.end(); + m_parameterNames.cend(); } /** diff --git a/Framework/API/src/ParameterTie.cpp b/Framework/API/src/ParameterTie.cpp index eddfb788399e34daa2a097335f1155d880795ef5..a3ae0083301c80f15270d9edd7d041937ddc9a3c 100644 --- a/Framework/API/src/ParameterTie.cpp +++ b/Framework/API/src/ParameterTie.cpp @@ -202,9 +202,8 @@ bool ParameterTie::isConstant() const { return m_varMap.empty(); } std::vector<ParameterReference> ParameterTie::getRHSParameters() const { std::vector<ParameterReference> out; out.reserve(m_varMap.size()); - for (auto &&varPair : m_varMap) { - out.emplace_back(varPair.second); - } + std::transform(m_varMap.begin(), m_varMap.end(), std::back_inserter(out), + [](auto &&varPair) { return varPair.second; }); return out; } diff --git a/Framework/API/src/RemoteJobManagerFactory.cpp b/Framework/API/src/RemoteJobManagerFactory.cpp index 08709cac5ca74d31426f9f98ea143ccad311b076..1231e13dde9fb50d64bb5c2bbff418c128f850c2 100644 --- a/Framework/API/src/RemoteJobManagerFactory.cpp +++ b/Framework/API/src/RemoteJobManagerFactory.cpp @@ -65,8 +65,8 @@ IRemoteJobManager_sptr RemoteJobManagerFactoryImpl::create( * the type (for example the type is not recognized). */ Mantid::API::IRemoteJobManager_sptr -RemoteJobManagerFactoryImpl::create(const std::string baseURL, - const std::string jobManagerType) const { +RemoteJobManagerFactoryImpl::create(const std::string &baseURL, + const std::string &jobManagerType) const { Mantid::API::IRemoteJobManager_sptr jm; // use the inherited/generic create method diff --git a/Framework/API/src/Sample.cpp b/Framework/API/src/Sample.cpp index 36b92ab36b62be70764b1249a2e47bdf18c4ca87..b26a1a04bafcfe80d37d1636cde7ddfa7e3900b1 100644 --- a/Framework/API/src/Sample.cpp +++ b/Framework/API/src/Sample.cpp @@ -284,7 +284,7 @@ std::size_t Sample::size() const { return m_samples.size() + 1; } * Adds a sample to the sample collection * @param childSample The child sample to be added */ -void Sample::addSample(boost::shared_ptr<Sample> childSample) { +void Sample::addSample(const boost::shared_ptr<Sample> &childSample) { m_samples.emplace_back(childSample); } diff --git a/Framework/API/src/ScopedWorkspace.cpp b/Framework/API/src/ScopedWorkspace.cpp index 177288a3f3ad39adad0e8f7dc664573ad844de7d..58a5085d27558f07c3e26bf369f540fc6d972e87 100644 --- a/Framework/API/src/ScopedWorkspace.cpp +++ b/Framework/API/src/ScopedWorkspace.cpp @@ -4,8 +4,10 @@ // NScD Oak Ridge National Laboratory, European Spallation Source, // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + -#include "MantidAPI/ScopedWorkspace.h" +#include <utility> + #include "MantidAPI/AnalysisDataService.h" +#include "MantidAPI/ScopedWorkspace.h" #include "MantidAPI/WorkspaceGroup.h" namespace Mantid { @@ -22,9 +24,9 @@ ScopedWorkspace::ScopedWorkspace() : m_name(generateUniqueName()) {} /** * Workspace constructor */ -ScopedWorkspace::ScopedWorkspace(Workspace_sptr ws) +ScopedWorkspace::ScopedWorkspace(const Workspace_sptr &ws) : m_name(generateUniqueName()) { - set(ws); + set(std::move(ws)); } //---------------------------------------------------------------------------------------------- @@ -77,7 +79,7 @@ void ScopedWorkspace::remove() { /** * Make ADS entry to point to the given workspace. */ -void ScopedWorkspace::set(Workspace_sptr newWS) { +void ScopedWorkspace::set(const Workspace_sptr &newWS) { AnalysisDataServiceImpl &ads = AnalysisDataService::Instance(); if (!newWS->getName().empty() && ads.doesExist(newWS->getName())) diff --git a/Framework/API/src/ScriptBuilder.cpp b/Framework/API/src/ScriptBuilder.cpp index 127f9380be24eb4d0249442c256941ca503db093..07d800bebdf57a329d6e3adc186deee14d2cc080 100644 --- a/Framework/API/src/ScriptBuilder.cpp +++ b/Framework/API/src/ScriptBuilder.cpp @@ -22,6 +22,7 @@ #include <boost/range/algorithm/remove_if.hpp> #include <boost/utility.hpp> #include <set> +#include <utility> namespace Mantid { namespace API { @@ -36,14 +37,15 @@ Mantid::Kernel::Logger g_log("ScriptBuilder"); const std::string COMMENT_ALG = "Comment"; ScriptBuilder::ScriptBuilder( - boost::shared_ptr<HistoryView> view, std::string versionSpecificity, + const boost::shared_ptr<HistoryView> &view, std::string versionSpecificity, bool appendTimestamp, std::vector<std::string> ignoreTheseAlgs, std::vector<std::vector<std::string>> ignoreTheseAlgProperties, bool appendExecCount) : m_historyItems(view->getAlgorithmsList()), m_output(), - m_versionSpecificity(versionSpecificity), - m_timestampCommands(appendTimestamp), m_algsToIgnore(ignoreTheseAlgs), - m_propertiesToIgnore(ignoreTheseAlgProperties), + m_versionSpecificity(std::move(versionSpecificity)), + m_timestampCommands(appendTimestamp), + m_algsToIgnore(std::move(ignoreTheseAlgs)), + m_propertiesToIgnore(std::move(ignoreTheseAlgProperties)), m_execCount(appendExecCount) {} /** diff --git a/Framework/API/src/SpectrumDetectorMapping.cpp b/Framework/API/src/SpectrumDetectorMapping.cpp index 6a1213489a939970ec232de5115c7c414f57a988..c05ed206e8dba917df65d38bf14327ece602e6f1 100644 --- a/Framework/API/src/SpectrumDetectorMapping.cpp +++ b/Framework/API/src/SpectrumDetectorMapping.cpp @@ -15,7 +15,7 @@ namespace API { * @throws std::invalid_argument if a null workspace pointer is passed in */ SpectrumDetectorMapping::SpectrumDetectorMapping( - MatrixWorkspace_const_sptr workspace, const bool useSpecNoIndex) + const MatrixWorkspace_const_sptr &workspace, const bool useSpecNoIndex) : m_indexIsSpecNo(useSpecNoIndex) { if (!workspace) { throw std::invalid_argument( diff --git a/Framework/API/src/SpectrumInfo.cpp b/Framework/API/src/SpectrumInfo.cpp index f487795992ab037ed3b570a337ae154424f2a929..8ca2b71c33da18fb765e09ccc5607c3225e4369b 100644 --- a/Framework/API/src/SpectrumInfo.cpp +++ b/Framework/API/src/SpectrumInfo.cpp @@ -33,6 +33,10 @@ SpectrumInfo::~SpectrumInfo() = default; /// Returns the size of the SpectrumInfo, i.e., the number of spectra. size_t SpectrumInfo::size() const { return m_spectrumInfo.size(); } +size_t SpectrumInfo::detectorCount() const { + return m_spectrumInfo.detectorCount(); +} + /// Returns a const reference to the SpectrumDefinition of the spectrum. const SpectrumDefinition & SpectrumInfo::spectrumDefinition(const size_t index) const { diff --git a/Framework/API/src/WorkspaceGroup.cpp b/Framework/API/src/WorkspaceGroup.cpp index a251a3b2ed37650f2ecb5dc1a92e78bc34cf3dad..3db1116e68bca7aec5af9a50d1b96f8ba1c448c0 100644 --- a/Framework/API/src/WorkspaceGroup.cpp +++ b/Framework/API/src/WorkspaceGroup.cpp @@ -191,9 +191,11 @@ std::vector<std::string> WorkspaceGroup::getNames() const { std::vector<std::string> out; std::lock_guard<std::recursive_mutex> _lock(m_mutex); out.reserve(m_workspaces.size()); - for (const auto &workspace : m_workspaces) { - out.emplace_back(workspace->getName()); - } + + std::transform(m_workspaces.begin(), m_workspaces.end(), + std::back_inserter(out), + [](const auto &ws) { return ws->getName(); }); + return out; } diff --git a/Framework/API/src/WorkspaceHistory.cpp b/Framework/API/src/WorkspaceHistory.cpp index 167409dbd6c23d9bb57748ccbc8db5c89537f4cf..dfa12b0cafccbc78c015afeb0b69a69e6521b93c 100644 --- a/Framework/API/src/WorkspaceHistory.cpp +++ b/Framework/API/src/WorkspaceHistory.cpp @@ -317,7 +317,7 @@ void WorkspaceHistory::loadNexus(::NeXus::File *file) { * the workspace history. */ void WorkspaceHistory::loadNestedHistory(::NeXus::File *file, - AlgorithmHistory_sptr parent) { + const AlgorithmHistory_sptr &parent) { // historyNumbers should be sorted by number std::set<int> historyNumbers = findHistoryEntries(file); for (auto historyNumber : historyNumbers) { diff --git a/Framework/API/src/WorkspaceOpOverloads.cpp b/Framework/API/src/WorkspaceOpOverloads.cpp index 770c1b8b9b2273dd87e29b31c7945c6d36a86f82..e640abf0cdde4500de7899c1d26178be7d609411 100644 --- a/Framework/API/src/WorkspaceOpOverloads.cpp +++ b/Framework/API/src/WorkspaceOpOverloads.cpp @@ -141,7 +141,7 @@ template MANTID_API_DLL IMDHistoWorkspace_sptr executeBinaryOperation( * @param tolerance :: acceptable difference for floating point numbers * @return bool, true if workspaces match */ -bool equals(const MatrixWorkspace_sptr lhs, const MatrixWorkspace_sptr rhs, +bool equals(const MatrixWorkspace_sptr &lhs, const MatrixWorkspace_sptr &rhs, double tolerance) { IAlgorithm_sptr alg = AlgorithmManager::Instance().createUnmanaged("CompareWorkspaces"); @@ -180,8 +180,8 @@ using OperatorOverloads::executeBinaryOperation; * @param rhs :: right hand side workspace shared pointer * @return The result in a workspace shared pointer */ -MatrixWorkspace_sptr operator+(const MatrixWorkspace_sptr lhs, - const MatrixWorkspace_sptr rhs) { +MatrixWorkspace_sptr operator+(const MatrixWorkspace_sptr &lhs, + const MatrixWorkspace_sptr &rhs) { return executeBinaryOperation<MatrixWorkspace_sptr, MatrixWorkspace_sptr, MatrixWorkspace_sptr>("Plus", lhs, rhs); } @@ -191,7 +191,7 @@ MatrixWorkspace_sptr operator+(const MatrixWorkspace_sptr lhs, * @param rhsValue :: the single value * @return The result in a workspace shared pointer */ -MatrixWorkspace_sptr operator+(const MatrixWorkspace_sptr lhs, +MatrixWorkspace_sptr operator+(const MatrixWorkspace_sptr &lhs, const double &rhsValue) { return executeBinaryOperation<MatrixWorkspace_sptr, MatrixWorkspace_sptr, MatrixWorkspace_sptr>( @@ -203,8 +203,8 @@ MatrixWorkspace_sptr operator+(const MatrixWorkspace_sptr lhs, * @param rhs :: right hand side workspace shared pointer * @return The result in a workspace shared pointer */ -MatrixWorkspace_sptr operator-(const MatrixWorkspace_sptr lhs, - const MatrixWorkspace_sptr rhs) { +MatrixWorkspace_sptr operator-(const MatrixWorkspace_sptr &lhs, + const MatrixWorkspace_sptr &rhs) { return executeBinaryOperation<MatrixWorkspace_sptr, MatrixWorkspace_sptr, MatrixWorkspace_sptr>("Minus", lhs, rhs); } @@ -214,7 +214,7 @@ MatrixWorkspace_sptr operator-(const MatrixWorkspace_sptr lhs, * @param rhsValue :: the single value * @return The result in a workspace shared pointer */ -MatrixWorkspace_sptr operator-(const MatrixWorkspace_sptr lhs, +MatrixWorkspace_sptr operator-(const MatrixWorkspace_sptr &lhs, const double &rhsValue) { return executeBinaryOperation<MatrixWorkspace_sptr, MatrixWorkspace_sptr, MatrixWorkspace_sptr>( @@ -227,7 +227,7 @@ MatrixWorkspace_sptr operator-(const MatrixWorkspace_sptr lhs, * @return The result in a workspace shared pointer */ MatrixWorkspace_sptr operator-(const double &lhsValue, - const MatrixWorkspace_sptr rhs) { + const MatrixWorkspace_sptr &rhs) { return executeBinaryOperation<MatrixWorkspace_sptr, MatrixWorkspace_sptr, MatrixWorkspace_sptr>( "Minus", createWorkspaceSingleValue(lhsValue), rhs); @@ -237,8 +237,8 @@ MatrixWorkspace_sptr operator-(const double &lhsValue, * @param rhs :: right hand side workspace shared pointer * @return The result in a workspace shared pointer */ -MatrixWorkspace_sptr operator*(const MatrixWorkspace_sptr lhs, - const MatrixWorkspace_sptr rhs) { +MatrixWorkspace_sptr operator*(const MatrixWorkspace_sptr &lhs, + const MatrixWorkspace_sptr &rhs) { return executeBinaryOperation<MatrixWorkspace_sptr, MatrixWorkspace_sptr, MatrixWorkspace_sptr>("Multiply", lhs, rhs); } @@ -248,7 +248,7 @@ MatrixWorkspace_sptr operator*(const MatrixWorkspace_sptr lhs, * @param rhsValue :: the single value * @return The result in a workspace shared pointer */ -MatrixWorkspace_sptr operator*(const MatrixWorkspace_sptr lhs, +MatrixWorkspace_sptr operator*(const MatrixWorkspace_sptr &lhs, const double &rhsValue) { return executeBinaryOperation<MatrixWorkspace_sptr, MatrixWorkspace_sptr, MatrixWorkspace_sptr>( @@ -262,7 +262,7 @@ MatrixWorkspace_sptr operator*(const MatrixWorkspace_sptr lhs, * @return The result in a workspace shared pointer */ MatrixWorkspace_sptr operator*(const double &lhsValue, - const MatrixWorkspace_sptr rhs) { + const MatrixWorkspace_sptr &rhs) { return executeBinaryOperation<MatrixWorkspace_sptr, MatrixWorkspace_sptr, MatrixWorkspace_sptr>( "Multiply", createWorkspaceSingleValue(lhsValue), rhs); @@ -273,8 +273,8 @@ MatrixWorkspace_sptr operator*(const double &lhsValue, * @param rhs :: right hand side workspace shared pointer * @return The result in a workspace shared pointer */ -MatrixWorkspace_sptr operator/(const MatrixWorkspace_sptr lhs, - const MatrixWorkspace_sptr rhs) { +MatrixWorkspace_sptr operator/(const MatrixWorkspace_sptr &lhs, + const MatrixWorkspace_sptr &rhs) { return executeBinaryOperation<MatrixWorkspace_sptr, MatrixWorkspace_sptr, MatrixWorkspace_sptr>("Divide", lhs, rhs); } @@ -284,7 +284,7 @@ MatrixWorkspace_sptr operator/(const MatrixWorkspace_sptr lhs, * @param rhsValue :: the single value * @return The result in a workspace shared pointer */ -MatrixWorkspace_sptr operator/(const MatrixWorkspace_sptr lhs, +MatrixWorkspace_sptr operator/(const MatrixWorkspace_sptr &lhs, const double &rhsValue) { return executeBinaryOperation<MatrixWorkspace_sptr, MatrixWorkspace_sptr, MatrixWorkspace_sptr>( @@ -298,7 +298,7 @@ MatrixWorkspace_sptr operator/(const MatrixWorkspace_sptr lhs, * @return The result in a workspace shared pointer */ MatrixWorkspace_sptr operator/(const double &lhsValue, - const MatrixWorkspace_sptr rhs) { + const MatrixWorkspace_sptr &rhs) { return executeBinaryOperation<MatrixWorkspace_sptr, MatrixWorkspace_sptr, MatrixWorkspace_sptr>( "Divide", createWorkspaceSingleValue(lhsValue), rhs); @@ -309,8 +309,8 @@ MatrixWorkspace_sptr operator/(const double &lhsValue, * @param rhs :: right hand side workspace shared pointer * @return The result in a workspace shared pointer */ -MatrixWorkspace_sptr operator+=(const MatrixWorkspace_sptr lhs, - const MatrixWorkspace_sptr rhs) { +MatrixWorkspace_sptr operator+=(const MatrixWorkspace_sptr &lhs, + const MatrixWorkspace_sptr &rhs) { return executeBinaryOperation<MatrixWorkspace_sptr, MatrixWorkspace_sptr, MatrixWorkspace_sptr>("Plus", lhs, rhs, true); } @@ -320,7 +320,7 @@ MatrixWorkspace_sptr operator+=(const MatrixWorkspace_sptr lhs, * @param rhsValue :: the single value * @return The result in a workspace shared pointer */ -MatrixWorkspace_sptr operator+=(const MatrixWorkspace_sptr lhs, +MatrixWorkspace_sptr operator+=(const MatrixWorkspace_sptr &lhs, const double &rhsValue) { return executeBinaryOperation<MatrixWorkspace_sptr, MatrixWorkspace_sptr, MatrixWorkspace_sptr>( @@ -332,8 +332,8 @@ MatrixWorkspace_sptr operator+=(const MatrixWorkspace_sptr lhs, * @param rhs :: right hand side workspace shared pointer * @return The result in a workspace shared pointer */ -MatrixWorkspace_sptr operator-=(const MatrixWorkspace_sptr lhs, - const MatrixWorkspace_sptr rhs) { +MatrixWorkspace_sptr operator-=(const MatrixWorkspace_sptr &lhs, + const MatrixWorkspace_sptr &rhs) { return executeBinaryOperation<MatrixWorkspace_sptr, MatrixWorkspace_sptr, MatrixWorkspace_sptr>("Minus", lhs, rhs, true); } @@ -343,7 +343,7 @@ MatrixWorkspace_sptr operator-=(const MatrixWorkspace_sptr lhs, * @param rhsValue :: the single value * @return The result in a workspace shared pointer */ -MatrixWorkspace_sptr operator-=(const MatrixWorkspace_sptr lhs, +MatrixWorkspace_sptr operator-=(const MatrixWorkspace_sptr &lhs, const double &rhsValue) { return executeBinaryOperation<MatrixWorkspace_sptr, MatrixWorkspace_sptr, MatrixWorkspace_sptr>( @@ -355,8 +355,8 @@ MatrixWorkspace_sptr operator-=(const MatrixWorkspace_sptr lhs, * @param rhs :: right hand side workspace shared pointer * @return The result in a workspace shared pointer */ -MatrixWorkspace_sptr operator*=(const MatrixWorkspace_sptr lhs, - const MatrixWorkspace_sptr rhs) { +MatrixWorkspace_sptr operator*=(const MatrixWorkspace_sptr &lhs, + const MatrixWorkspace_sptr &rhs) { return executeBinaryOperation<MatrixWorkspace_sptr, MatrixWorkspace_sptr, MatrixWorkspace_sptr>("Multiply", lhs, rhs, true); @@ -367,7 +367,7 @@ MatrixWorkspace_sptr operator*=(const MatrixWorkspace_sptr lhs, * @param rhsValue :: the single value * @return The result in a workspace shared pointer */ -MatrixWorkspace_sptr operator*=(const MatrixWorkspace_sptr lhs, +MatrixWorkspace_sptr operator*=(const MatrixWorkspace_sptr &lhs, const double &rhsValue) { return executeBinaryOperation<MatrixWorkspace_sptr, MatrixWorkspace_sptr, MatrixWorkspace_sptr>( @@ -379,8 +379,8 @@ MatrixWorkspace_sptr operator*=(const MatrixWorkspace_sptr lhs, * @param rhs :: right hand side workspace shared pointer * @return The result in a workspace shared pointer */ -MatrixWorkspace_sptr operator/=(const MatrixWorkspace_sptr lhs, - const MatrixWorkspace_sptr rhs) { +MatrixWorkspace_sptr operator/=(const MatrixWorkspace_sptr &lhs, + const MatrixWorkspace_sptr &rhs) { return executeBinaryOperation<MatrixWorkspace_sptr, MatrixWorkspace_sptr, MatrixWorkspace_sptr>("Divide", lhs, rhs, true); } @@ -390,7 +390,7 @@ MatrixWorkspace_sptr operator/=(const MatrixWorkspace_sptr lhs, * @param rhsValue :: the single value * @return The result in a workspace shared pointer */ -MatrixWorkspace_sptr operator/=(const MatrixWorkspace_sptr lhs, +MatrixWorkspace_sptr operator/=(const MatrixWorkspace_sptr &lhs, const double &rhsValue) { return executeBinaryOperation<MatrixWorkspace_sptr, MatrixWorkspace_sptr, MatrixWorkspace_sptr>( @@ -490,7 +490,7 @@ bool WorkspaceHelpers::sharedXData(const MatrixWorkspace &WS) { * @param forwards :: If true (the default) divides by bin width, if false * multiplies */ -void WorkspaceHelpers::makeDistribution(MatrixWorkspace_sptr workspace, +void WorkspaceHelpers::makeDistribution(const MatrixWorkspace_sptr &workspace, const bool forwards) { // If we're not able to get a writable reference to Y, then this is an event // workspace, which we can't operate on. diff --git a/Framework/API/test/AlgorithmFactoryTest.h b/Framework/API/test/AlgorithmFactoryTest.h index cb2bfc1dd6433704ed4b06cc95cf092e09c3789a..4dea1a5f303d1e1f3b6981985fcc5ec8b7eb8eed 100644 --- a/Framework/API/test/AlgorithmFactoryTest.h +++ b/Framework/API/test/AlgorithmFactoryTest.h @@ -186,7 +186,7 @@ public: foundAlg = ("Cat" == descItr->category) && ("ToyAlgorithm" == descItr->name) && ("Dog" == descItr->alias) && (1 == descItr->version); - descItr++; + ++descItr; } TS_ASSERT(foundAlg); diff --git a/Framework/API/test/AlgorithmHistoryTest.h b/Framework/API/test/AlgorithmHistoryTest.h index f3025039cdb106bf302337fa0f8dcd85f29f4449..735c71f5fa40df0e2f3f60991194130fb2ecb820 100644 --- a/Framework/API/test/AlgorithmHistoryTest.h +++ b/Framework/API/test/AlgorithmHistoryTest.h @@ -239,7 +239,7 @@ private: return AlgorithmHistory(&alg, execTime, 14.0, m_execCount++); } - AlgorithmHistory createFromTestAlg(std::string paramValue) { + AlgorithmHistory createFromTestAlg(const std::string ¶mValue) { Algorithm *testInput = new testalg; testInput->initialize(); testInput->setPropertyValue("arg1_param", paramValue); diff --git a/Framework/API/test/AlgorithmProxyTest.h b/Framework/API/test/AlgorithmProxyTest.h index 8dc5017571a8a8141e80adde264ebe7f4ae010a9..bff605adc012261bb356f7708ac5b2d8b8d5d7e2 100644 --- a/Framework/API/test/AlgorithmProxyTest.h +++ b/Framework/API/test/AlgorithmProxyTest.h @@ -17,6 +17,7 @@ #include <Poco/Thread.h> #include <boost/lexical_cast.hpp> +#include <utility> using namespace Mantid::API; using namespace Mantid::Kernel; @@ -121,7 +122,8 @@ public: TestProxyObserver() : AlgorithmObserver(), start(false), progress(false), finish(false) {} TestProxyObserver(IAlgorithm_const_sptr alg) - : AlgorithmObserver(alg), start(false), progress(false), finish(false) {} + : AlgorithmObserver(std::move(alg)), start(false), progress(false), + finish(false) {} void startHandle(const IAlgorithm *) override { start = true; } void progressHandle(const IAlgorithm *, double p, const std::string &msg) override { diff --git a/Framework/API/test/AlgorithmTest.h b/Framework/API/test/AlgorithmTest.h index cc5350719e3d039c446f9d0bc68fc8172a9ab8cd..e0d91c1adc03f77bef83b83464e5e92f75d51912 100644 --- a/Framework/API/test/AlgorithmTest.h +++ b/Framework/API/test/AlgorithmTest.h @@ -27,6 +27,7 @@ #include "MantidTestHelpers/FakeObjects.h" #include "PropertyManagerHelper.h" #include <map> +#include <utility> using namespace Mantid::Kernel; using namespace Mantid::API; @@ -511,8 +512,9 @@ public: /** Test of setting read and/or write locks * for various combinations of input/output workspaces. */ - void do_test_locking(std::string in1, std::string in2, std::string inout, - std::string out1, std::string out2) { + void do_test_locking(const std::string &in1, const std::string &in2, + const std::string &inout, const std::string &out1, + const std::string &out2) { for (size_t i = 0; i < 6; i++) { boost::shared_ptr<WorkspaceTester> ws = boost::make_shared<WorkspaceTester>(); @@ -586,7 +588,8 @@ public: * Make no group if blank, just 1 workspace * @return The new WorkspaceGroup object */ - Workspace_sptr makeWorkspaceGroup(std::string group1, std::string contents1) { + Workspace_sptr makeWorkspaceGroup(const std::string &group1, + std::string contents1) { auto &ads = AnalysisDataService::Instance(); if (contents1.empty()) { if (group1.empty()) @@ -614,14 +617,14 @@ public: } //------------------------------------------------------------------------ - WorkspaceGroup_sptr do_test_groups(std::string group1, std::string contents1, - std::string group2, std::string contents2, - std::string group3, std::string contents3, - bool expectFail = false, - int expectedNumber = 3) { - makeWorkspaceGroup(group1, contents1); - makeWorkspaceGroup(group2, contents2); - makeWorkspaceGroup(group3, contents3); + WorkspaceGroup_sptr + do_test_groups(const std::string &group1, std::string contents1, + const std::string &group2, std::string contents2, + const std::string &group3, std::string contents3, + bool expectFail = false, int expectedNumber = 3) { + makeWorkspaceGroup(group1, std::move(contents1)); + makeWorkspaceGroup(group2, std::move(contents2)); + makeWorkspaceGroup(group3, std::move(contents3)); StubbedWorkspaceAlgorithm alg; alg.initialize(); diff --git a/Framework/API/test/AnalysisDataServiceObserverTest.h b/Framework/API/test/AnalysisDataServiceObserverTest.h index 11240363aeb8f2b1d13fd77046b37b333a2b6f6b..46bbbee62718ee3357cdb86157f84a048bd3a140 100644 --- a/Framework/API/test/AnalysisDataServiceObserverTest.h +++ b/Framework/API/test/AnalysisDataServiceObserverTest.h @@ -109,7 +109,7 @@ public: m_mockInheritingClass = std::make_unique<FakeAnalysisDataServiceObserver>(); } - void addWorkspaceToADS(std::string name = "dummy") { + void addWorkspaceToADS(const std::string &name = "dummy") { IAlgorithm_sptr alg = Mantid::API::AlgorithmManager::Instance().createUnmanaged( "CreateSampleWorkspace"); diff --git a/Framework/API/test/ExperimentInfoTest.h b/Framework/API/test/ExperimentInfoTest.h index c7bb1f79bb94bfcdd7b0266a16541fbd3b9bafee..09cef48c58a4bb6a460faecbb51acc1fd84a5e0d 100644 --- a/Framework/API/test/ExperimentInfoTest.h +++ b/Framework/API/test/ExperimentInfoTest.h @@ -880,14 +880,14 @@ private: } Instrument_sptr - addInstrumentWithIndirectEmodeParameter(ExperimentInfo_sptr exptInfo) { + addInstrumentWithIndirectEmodeParameter(const ExperimentInfo_sptr &exptInfo) { Instrument_sptr inst = addInstrument(exptInfo); exptInfo->instrumentParameters().addString(inst.get(), "deltaE-mode", "indirect"); return inst; } - Instrument_sptr addInstrument(ExperimentInfo_sptr exptInfo) { + Instrument_sptr addInstrument(const ExperimentInfo_sptr &exptInfo) { Instrument_sptr inst = ComponentCreationHelper::createTestInstrumentCylindrical(1); exptInfo->setInstrument(inst); diff --git a/Framework/API/test/FileFinderTest.h b/Framework/API/test/FileFinderTest.h index 2d909d37393d8e7071f18331fc9e6ca7fd055a39..3c90bb3aca00b611b883ddab72207bad589f0d32 100644 --- a/Framework/API/test/FileFinderTest.h +++ b/Framework/API/test/FileFinderTest.h @@ -215,7 +215,6 @@ public: } void testGetInstrument() { - std::string name; // place to put results ConfigService::Instance().setFacility("ISIS"); ConfigService::Instance().setString("default.instrument", "HRPD"); diff --git a/Framework/API/test/FunctionFactoryTest.h b/Framework/API/test/FunctionFactoryTest.h index 520179ff17a046a69dfafe53e1134e555c2ca4c0..71f77b73cceea6c06c0e101112edae00ed9c3e96 100644 --- a/Framework/API/test/FunctionFactoryTest.h +++ b/Framework/API/test/FunctionFactoryTest.h @@ -476,7 +476,7 @@ public: TS_ASSERT(second); // test each individual function - auto testFunc = [](CompositeFunction_sptr f) { + auto testFunc = [](const CompositeFunction_sptr &f) { if (f) { TS_ASSERT_EQUALS(f->nFunctions(), 2); TS_ASSERT_EQUALS(f->getFunction(0)->name(), diff --git a/Framework/API/test/FunctionPropertyTest.h b/Framework/API/test/FunctionPropertyTest.h index 3667910809dca09da6661632275d2680d3238d13..92b15eb6192ac8e7e17e49d229e87d41521d6a63 100644 --- a/Framework/API/test/FunctionPropertyTest.h +++ b/Framework/API/test/FunctionPropertyTest.h @@ -87,7 +87,6 @@ public: void test_Assignment_By_SharedPtr() { FunctionProperty prop("fun"); - std::string error; auto fun_p = FunctionFactory::Instance().createInitialized( createTestFunctionString()); TS_ASSERT(fun_p); @@ -105,7 +104,6 @@ public: void test_Shared_Pointer() { FunctionProperty prop("fun"); - std::string error; boost::shared_ptr<FunctionPropertyTest_Function> fun_p( new FunctionPropertyTest_Function); TS_ASSERT(fun_p); diff --git a/Framework/API/test/LiveListenerFactoryTest.h b/Framework/API/test/LiveListenerFactoryTest.h index 6bcf7bf29dddd2ac1db3c6fe674a4b3ab52f6e1b..c3fa9bdc09557cdad7fca627fb9d44a034bc218f 100644 --- a/Framework/API/test/LiveListenerFactoryTest.h +++ b/Framework/API/test/LiveListenerFactoryTest.h @@ -14,6 +14,8 @@ #include <Poco/Path.h> #include <cxxtest/TestSuite.h> +#include <utility> + using namespace Mantid; using namespace Mantid::API; @@ -29,7 +31,7 @@ class MockLiveListenerInstantiator public: MockLiveListenerInstantiator( boost::shared_ptr<Mantid::API::ILiveListener> product) - : product(product) {} + : product(std::move(product)) {} boost::shared_ptr<Mantid::API::ILiveListener> createInstance() const override { diff --git a/Framework/API/test/LogManagerTest.h b/Framework/API/test/LogManagerTest.h index aa677c3e04e495f0f9d8439a6ed68a791b6dd65d..c047bd8e1e057e7196d78b95760644e810fd1ff1 100644 --- a/Framework/API/test/LogManagerTest.h +++ b/Framework/API/test/LogManagerTest.h @@ -63,7 +63,8 @@ void addTestTimeSeries(LogManager &run, const std::string &name) { } } // namespace -void addTimeSeriesEntry(LogManager &runInfo, std::string name, double val) { +void addTimeSeriesEntry(LogManager &runInfo, const std::string &name, + double val) { TimeSeriesProperty<double> *tsp; tsp = new TimeSeriesProperty<double>(name); tsp->addValue("2011-05-24T00:00:00", val); @@ -554,8 +555,7 @@ private: LogManager runInfo; const std::string name = "T_prop"; runInfo.addProperty<T>(name, value); - int result(-1); - result = runInfo.getPropertyAsIntegerValue(name); + int result = runInfo.getPropertyAsIntegerValue(name); TS_ASSERT_THROWS_NOTHING(result = runInfo.getPropertyAsIntegerValue(name)); TS_ASSERT_EQUALS(value, static_cast<T>(result)); } @@ -579,12 +579,11 @@ public: } void test_Accessing_Single_Value_From_Times_Series_A_Large_Number_Of_Times() { - double value(0.0); for (size_t i = 0; i < 20000; ++i) { - value = m_testRun.getPropertyAsSingleValue(m_propName); + // This has an observable side-effect of calling, so we don't need + // to store its return value + m_testRun.getPropertyAsSingleValue(m_propName); } - // Enure variable is used so that it is not optimised away by the compiler - value += 1.0; } LogManager m_testRun; diff --git a/Framework/API/test/MultiDomainFunctionTest.h b/Framework/API/test/MultiDomainFunctionTest.h index 3b87ef057f3de1a23c4f852345f77b9a1e2342ba..31f604a5c32308830875da2e9ddbf8e00eb70e4a 100644 --- a/Framework/API/test/MultiDomainFunctionTest.h +++ b/Framework/API/test/MultiDomainFunctionTest.h @@ -324,7 +324,6 @@ public: void test_attribute_domain_range() { multi.clearDomainIndices(); multi.setLocalAttributeValue(0, "domains", "0-2"); - return; multi.setLocalAttributeValue(1, "domains", "i"); multi.setLocalAttributeValue(2, "domains", "i"); @@ -336,7 +335,7 @@ public: const FunctionDomain1D &d0 = static_cast<const FunctionDomain1D &>(domain.getDomain(0)); for (size_t i = 0; i < 9; ++i) { - TS_ASSERT_EQUALS(values.getCalculated(i), A + B * d0[i]); + TS_ASSERT_DELTA(values.getCalculated(i), A + B * d0[i], 1e-6); } A = multi.getFunction(0)->getParameter("A") + @@ -346,7 +345,7 @@ public: const FunctionDomain1D &d1 = static_cast<const FunctionDomain1D &>(domain.getDomain(1)); for (size_t i = 9; i < 19; ++i) { - TS_ASSERT_EQUALS(values.getCalculated(i), A + B * d1[i - 9]); + TS_ASSERT_DELTA(values.getCalculated(i), A + B * d1[i - 9], 1e-6); } A = multi.getFunction(0)->getParameter("A") + @@ -356,7 +355,7 @@ public: const FunctionDomain1D &d2 = static_cast<const FunctionDomain1D &>(domain.getDomain(2)); for (size_t i = 19; i < 30; ++i) { - TS_ASSERT_EQUALS(values.getCalculated(i), A + B * d2[i - 19]); + TS_ASSERT_DELTA(values.getCalculated(i), A + B * d2[i - 19], 1e-6); } } diff --git a/Framework/API/test/MultiPeriodGroupTestBase.h b/Framework/API/test/MultiPeriodGroupTestBase.h index a164ac160814f489e12977880755bf2a977074be..6a27600bb90b7afe45c1591bf4d0722278d80375 100644 --- a/Framework/API/test/MultiPeriodGroupTestBase.h +++ b/Framework/API/test/MultiPeriodGroupTestBase.h @@ -28,7 +28,7 @@ class MultiPeriodGroupTestBase { protected: // Helper method to add multiperiod logs to make a workspacegroup look like a // real multiperiod workspace group. - void add_periods_logs(WorkspaceGroup_sptr ws) { + void add_periods_logs(const WorkspaceGroup_sptr &ws) { int nperiods = static_cast<int>(ws->size()); for (size_t i = 0; i < ws->size(); ++i) { MatrixWorkspace_sptr currentWS = @@ -45,7 +45,7 @@ protected: /// Helper to fabricate a workspace group consisting of equal sized /// matrixworkspaces. WorkspaceGroup_sptr - create_good_multiperiod_workspace_group(const std::string name) { + create_good_multiperiod_workspace_group(const std::string &name) { MatrixWorkspace_sptr a = MatrixWorkspace_sptr(new WorkspaceTester); MatrixWorkspace_sptr b = MatrixWorkspace_sptr(new WorkspaceTester); diff --git a/Framework/API/test/PeakFunctionIntegratorTest.h b/Framework/API/test/PeakFunctionIntegratorTest.h index 6c5730fc3bcec746bb14342f213384e1815d42c7..e6a3303cd4dde48305482f92f8dfd85be6222659 100644 --- a/Framework/API/test/PeakFunctionIntegratorTest.h +++ b/Framework/API/test/PeakFunctionIntegratorTest.h @@ -84,7 +84,8 @@ private: return gaussian; } - double getGaussianAnalyticalInfiniteIntegral(IPeakFunction_sptr gaussian) { + double + getGaussianAnalyticalInfiniteIntegral(const IPeakFunction_sptr &gaussian) { return gaussian->height() * gaussian->fwhm() / (2.0 * sqrt(M_LN2)) * sqrt(M_PI); } diff --git a/Framework/API/test/RunTest.h b/Framework/API/test/RunTest.h index e74db89faf05dbdb6c5a9362270d17e233e63e57..a41f319a7eae852b0a4d9b5ebdca618e2a06d844 100644 --- a/Framework/API/test/RunTest.h +++ b/Framework/API/test/RunTest.h @@ -427,7 +427,7 @@ public: TS_ASSERT_EQUALS(runCopy.getGoniometer().getNumberAxes(), 3); } - void addTimeSeriesEntry(Run &runInfo, std::string name, double val) { + void addTimeSeriesEntry(Run &runInfo, const std::string &name, double val) { TimeSeriesProperty<double> *tsp; tsp = new TimeSeriesProperty<double>(name); tsp->addValue("2011-05-24T00:00:00", val); @@ -630,12 +630,9 @@ public: } void test_Accessing_Single_Value_From_Times_Series_A_Large_Number_Of_Times() { - double value(0.0); for (size_t i = 0; i < 20000; ++i) { - value = m_testRun.getPropertyAsSingleValue(m_propName); + m_testRun.getPropertyAsSingleValue(m_propName); } - // Enure variable is used so that it is not optimised away by the compiler - value += 1.0; } Run m_testRun; diff --git a/Framework/API/test/WorkspaceGroupTest.h b/Framework/API/test/WorkspaceGroupTest.h index 953000c8b23d5f4212ed0a57c8e311ed68bf83a9..37565ec2f0125c450b9ee63d35d6096932c8e2a9 100644 --- a/Framework/API/test/WorkspaceGroupTest.h +++ b/Framework/API/test/WorkspaceGroupTest.h @@ -50,7 +50,7 @@ public: class WorkspaceGroupTest : public CxxTest::TestSuite { private: /// Helper method to add an 'nperiods' log value to each workspace in a group. - void add_periods_logs(WorkspaceGroup_sptr ws, int nperiods = -1) { + void add_periods_logs(const WorkspaceGroup_sptr &ws, int nperiods = -1) { for (size_t i = 0; i < ws->size(); ++i) { MatrixWorkspace_sptr currentWS = boost::dynamic_pointer_cast<MatrixWorkspace>(ws->getItem(i)); diff --git a/Framework/API/test/WorkspaceNearestNeighboursTest.h b/Framework/API/test/WorkspaceNearestNeighboursTest.h index 763903a9d9dcc75654b31e7e9e2d5dba44d98111..d5ec89e9485439b67fac4f776dd7ee075f22e499 100644 --- a/Framework/API/test/WorkspaceNearestNeighboursTest.h +++ b/Framework/API/test/WorkspaceNearestNeighboursTest.h @@ -59,7 +59,7 @@ private: : public Mantid::API::WorkspaceNearestNeighbours { public: ExposedNearestNeighbours(const SpectrumInfo &spectrumInfo, - const std::vector<specnum_t> spectrumNumbers, + const std::vector<specnum_t> &spectrumNumbers, bool ignoreMasked = false) : WorkspaceNearestNeighbours(8, spectrumInfo, spectrumNumbers, ignoreMasked) {} diff --git a/Framework/Algorithms/inc/MantidAlgorithms/AddSampleLog.h b/Framework/Algorithms/inc/MantidAlgorithms/AddSampleLog.h index fd2709dfec96be20c80c94a00dc98814d746a693..5f59e620a7bdc08bb02724ffd93db19a9fb84560 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/AddSampleLog.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/AddSampleLog.h @@ -76,21 +76,22 @@ private: Types::Core::DateAndTime getRunStart(API::Run &run_obj); /// get value vector of the integer TimeSeriesProperty entries - std::vector<int> getIntValues(API::MatrixWorkspace_const_sptr dataws, + std::vector<int> getIntValues(const API::MatrixWorkspace_const_sptr &dataws, int workspace_index); /// get value vector of the double TimeSeriesProperty entries - std::vector<double> getDblValues(API::MatrixWorkspace_const_sptr dataws, - int workspace_index); + std::vector<double> + getDblValues(const API::MatrixWorkspace_const_sptr &dataws, + int workspace_index); /// get the vector of times of the TimeSeriesProperty entries std::vector<Types::Core::DateAndTime> - getTimes(API::MatrixWorkspace_const_sptr dataws, int workspace_index, + getTimes(const API::MatrixWorkspace_const_sptr &dataws, int workspace_index, bool is_epoch, bool is_second, API::Run &run_obj); /// get meta data from input workspace or user input - void getMetaData(API::MatrixWorkspace_const_sptr dataws, bool &epochtime, - std::string &timeunit); + void getMetaData(const API::MatrixWorkspace_const_sptr &dataws, + bool &epochtime, std::string &timeunit); }; } // namespace Algorithms diff --git a/Framework/Algorithms/inc/MantidAlgorithms/AlignDetectors.h b/Framework/Algorithms/inc/MantidAlgorithms/AlignDetectors.h index 262863c52e947411830ed47ae158706d82e5f61c..b2dba6d8716db4b3252f7a350b47245f59f04e81 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/AlignDetectors.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/AlignDetectors.h @@ -73,9 +73,9 @@ private: void align(const ConversionFactors &converter, API::Progress &progress, DataObjects::EventWorkspace &outputWS); - void loadCalFile(API::MatrixWorkspace_sptr inputWS, + void loadCalFile(const API::MatrixWorkspace_sptr &inputWS, const std::string &filename); - void getCalibrationWS(API::MatrixWorkspace_sptr inputWS); + void getCalibrationWS(const API::MatrixWorkspace_sptr &inputWS); Mantid::API::ITableWorkspace_sptr m_calibrationWS; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/Bin2DPowderDiffraction.h b/Framework/Algorithms/inc/MantidAlgorithms/Bin2DPowderDiffraction.h index 8df86f65df339ee7a04969faf1ffe6c1d78bf2c2..5bd4f7d1bd5c6c8f3df6faa7f27c8c33f25b3342 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/Bin2DPowderDiffraction.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/Bin2DPowderDiffraction.h @@ -47,7 +47,7 @@ private: DataObjects::EventWorkspace_sptr m_inputWS; ///< Pointer to the input event workspace int m_numberOfSpectra; ///< The number of spectra in the workspace - void normalizeToBinArea(API::MatrixWorkspace_sptr outWS); + void normalizeToBinArea(const API::MatrixWorkspace_sptr &outWS); }; double calcD(double wavelength, double sintheta); diff --git a/Framework/Algorithms/inc/MantidAlgorithms/BinaryOperation.h b/Framework/Algorithms/inc/MantidAlgorithms/BinaryOperation.h index 095d6e2c18ac7f2ed3722f7ab4d53578a45ad7f7..f8598c52cdf2b22216541b3d9968a09f78db9c47 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/BinaryOperation.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/BinaryOperation.h @@ -193,7 +193,7 @@ protected: (void)ans; }; - OperandType getOperandType(const API::MatrixWorkspace_const_sptr ws); + OperandType getOperandType(const API::MatrixWorkspace_const_sptr &ws); virtual void checkRequirements(); @@ -255,8 +255,8 @@ private: void doSingleColumn(); void do2D(bool mismatchedSpectra); - void propagateBinMasks(const API::MatrixWorkspace_const_sptr rhs, - API::MatrixWorkspace_sptr out); + void propagateBinMasks(const API::MatrixWorkspace_const_sptr &rhs, + const API::MatrixWorkspace_sptr &out); /// Progress reporting std::unique_ptr<API::Progress> m_progress = nullptr; }; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/CalculateCarpenterSampleCorrection.h b/Framework/Algorithms/inc/MantidAlgorithms/CalculateCarpenterSampleCorrection.h index 3342d463b0fd87b4240ace76f93037d308cb5e03..f1be5292a6be993923b03832422a9cfcb6faa734 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/CalculateCarpenterSampleCorrection.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/CalculateCarpenterSampleCorrection.h @@ -61,10 +61,10 @@ private: API::MatrixWorkspace_sptr createOutputWorkspace(const API::MatrixWorkspace_sptr &inputWS, - const std::string) const; - void deleteWorkspace(API::MatrixWorkspace_sptr workspace); + const std::string &) const; + void deleteWorkspace(const API::MatrixWorkspace_sptr &workspace); API::MatrixWorkspace_sptr - setUncertainties(API::MatrixWorkspace_sptr workspace); + setUncertainties(const API::MatrixWorkspace_sptr &workspace); }; } // namespace Algorithms diff --git a/Framework/Algorithms/inc/MantidAlgorithms/CalculateDynamicRange.h b/Framework/Algorithms/inc/MantidAlgorithms/CalculateDynamicRange.h index 4af1002d855fe118c045ed9ca9117065836b000a..bdf3f4a5bfc4b05ce5f77be4098d99f77dfcfefa 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/CalculateDynamicRange.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/CalculateDynamicRange.h @@ -25,8 +25,8 @@ public: private: void init() override; void exec() override; - void calculateQMinMax(API::MatrixWorkspace_sptr, const std::vector<size_t> &, - const std::string &); + void calculateQMinMax(const API::MatrixWorkspace_sptr &, + const std::vector<size_t> &, const std::string &); }; } // namespace Algorithms diff --git a/Framework/Algorithms/inc/MantidAlgorithms/CalculateEfficiency.h b/Framework/Algorithms/inc/MantidAlgorithms/CalculateEfficiency.h index a781121fb442011680b1d63f3c64a13334e92f5a..b88b74a74fa40b7352af657a57d96e7a6672a7a7 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/CalculateEfficiency.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/CalculateEfficiency.h @@ -70,19 +70,19 @@ private: void exec() override; /// Sum all detectors, excluding monitors and masked detectors - void sumUnmaskedDetectors(API::MatrixWorkspace_sptr rebinnedWS, double &sum, - double &error, int &nPixels); + void sumUnmaskedDetectors(const API::MatrixWorkspace_sptr &rebinnedWS, + double &sum, double &error, int &nPixels); /// Normalize all detectors to get the relative efficiency - void normalizeDetectors(API::MatrixWorkspace_sptr rebinnedWS, - API::MatrixWorkspace_sptr outputWS, double sum, + void normalizeDetectors(const API::MatrixWorkspace_sptr &rebinnedWS, + const API::MatrixWorkspace_sptr &outputWS, double sum, double error, int nPixels, double min_eff, double max_eff); void maskComponent(API::MatrixWorkspace &ws, const std::string &componentName); - void maskEdges(API::MatrixWorkspace_sptr ws, int high, int low, int left, - int right, const std::string &componentName); + void maskEdges(const API::MatrixWorkspace_sptr &ws, int high, int low, + int left, int right, const std::string &componentName); }; } // namespace Algorithms diff --git a/Framework/Algorithms/inc/MantidAlgorithms/CalculateIqt.h b/Framework/Algorithms/inc/MantidAlgorithms/CalculateIqt.h index c2267bea170ee245cc0796c20acb6653142d1f5e..e060732d340ebfb03447639628ab3a4925add227 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/CalculateIqt.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/CalculateIqt.h @@ -28,24 +28,26 @@ private: std::map<std::string, std::string> validateInputs() override; std::string rebinParamsAsString(); API::MatrixWorkspace_sptr - monteCarloErrorCalculation(API::MatrixWorkspace_sptr sample, - API::MatrixWorkspace_sptr resolution, + monteCarloErrorCalculation(const API::MatrixWorkspace_sptr &sample, + const API::MatrixWorkspace_sptr &resolution, const std::string &rebinParams, const int seed, const bool calculateErrors, const int nIterations); - API::MatrixWorkspace_sptr rebin(API::MatrixWorkspace_sptr workspace, + API::MatrixWorkspace_sptr rebin(const API::MatrixWorkspace_sptr &workspace, const std::string ¶ms); - API::MatrixWorkspace_sptr integration(API::MatrixWorkspace_sptr workspace); API::MatrixWorkspace_sptr - convertToPointData(API::MatrixWorkspace_sptr workspace); + integration(const API::MatrixWorkspace_sptr &workspace); API::MatrixWorkspace_sptr - extractFFTSpectrum(API::MatrixWorkspace_sptr workspace); - API::MatrixWorkspace_sptr divide(API::MatrixWorkspace_sptr lhsWorkspace, - API::MatrixWorkspace_sptr rhsWorkspace); - API::MatrixWorkspace_sptr cropWorkspace(API::MatrixWorkspace_sptr workspace, - const double xMax); + convertToPointData(const API::MatrixWorkspace_sptr &workspace); API::MatrixWorkspace_sptr - replaceSpecialValues(API::MatrixWorkspace_sptr workspace); + extractFFTSpectrum(const API::MatrixWorkspace_sptr &workspace); + API::MatrixWorkspace_sptr + divide(const API::MatrixWorkspace_sptr &lhsWorkspace, + const API::MatrixWorkspace_sptr &rhsWorkspace); + API::MatrixWorkspace_sptr + cropWorkspace(const API::MatrixWorkspace_sptr &workspace, const double xMax); + API::MatrixWorkspace_sptr + replaceSpecialValues(const API::MatrixWorkspace_sptr &workspace); API::MatrixWorkspace_sptr removeInvalidData(API::MatrixWorkspace_sptr workspace); @@ -54,7 +56,7 @@ private: const std::string &rebinParams); API::MatrixWorkspace_sptr calculateIqt(API::MatrixWorkspace_sptr workspace, - API::MatrixWorkspace_sptr resolutionWorkspace, + const API::MatrixWorkspace_sptr &resolutionWorkspace, const std::string &rebinParams); API::MatrixWorkspace_sptr doSimulation(API::MatrixWorkspace_sptr sample, API::MatrixWorkspace_sptr resolution, diff --git a/Framework/Algorithms/inc/MantidAlgorithms/CalculateTransmission.h b/Framework/Algorithms/inc/MantidAlgorithms/CalculateTransmission.h index bd42d4ffaa665286b117432efb7d25420a6627ac..1a9c176f94447ceee85a412531eae1a93e600160 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/CalculateTransmission.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/CalculateTransmission.h @@ -80,27 +80,27 @@ private: void exec() override; /// Pull out a single spectrum from a 2D workspace - API::MatrixWorkspace_sptr extractSpectra(API::MatrixWorkspace_sptr ws, + API::MatrixWorkspace_sptr extractSpectra(const API::MatrixWorkspace_sptr &ws, const std::vector<size_t> &indices); /// Returns a workspace with the evaulation of the fit to the calculated /// transmission fraction - API::MatrixWorkspace_sptr fit(API::MatrixWorkspace_sptr raw, + API::MatrixWorkspace_sptr fit(const API::MatrixWorkspace_sptr &raw, const std::vector<double> &rebinParams, - const std::string fitMethod); + const std::string &fitMethod); /// Call the Linear fitting algorithm as a child algorithm - API::MatrixWorkspace_sptr fitData(API::MatrixWorkspace_sptr WS, double &grad, - double &offset); + API::MatrixWorkspace_sptr fitData(const API::MatrixWorkspace_sptr &WS, + double &grad, double &offset); /// Call the Polynomial fitting algorithm as a child algorithm - API::MatrixWorkspace_sptr fitPolynomial(API::MatrixWorkspace_sptr WS, + API::MatrixWorkspace_sptr fitPolynomial(const API::MatrixWorkspace_sptr &WS, int order, std::vector<double> &coeficients); /// Calls the rebin algorithm API::MatrixWorkspace_sptr rebin(const std::vector<double> &binParams, - API::MatrixWorkspace_sptr ws); + const API::MatrixWorkspace_sptr &ws); /// Outpus message to log if the detector at the given index is not a monitor /// in both input workspaces. - void logIfNotMonitor(API::MatrixWorkspace_sptr sampleWS, - API::MatrixWorkspace_sptr directWS, size_t index); + void logIfNotMonitor(const API::MatrixWorkspace_sptr &sampleWS, + const API::MatrixWorkspace_sptr &directWS, size_t index); }; } // namespace Algorithms diff --git a/Framework/Algorithms/inc/MantidAlgorithms/CalculateTransmissionBeamSpreader.h b/Framework/Algorithms/inc/MantidAlgorithms/CalculateTransmissionBeamSpreader.h index 1e59400328374843dea53c76bb5d4487e08f31b7..ed1123c24199e4b23405f5550a290c26533c0c3c 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/CalculateTransmissionBeamSpreader.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/CalculateTransmissionBeamSpreader.h @@ -85,12 +85,12 @@ private: void exec() override; /// Pull out a single spectrum from a 2D workspace - API::MatrixWorkspace_sptr extractSpectrum(API::MatrixWorkspace_sptr WS, + API::MatrixWorkspace_sptr extractSpectrum(const API::MatrixWorkspace_sptr &WS, const size_t index); /// Call the Linear fitting algorithm as a child algorithm - API::MatrixWorkspace_sptr fitToData(API::MatrixWorkspace_sptr WS); + API::MatrixWorkspace_sptr fitToData(const API::MatrixWorkspace_sptr &WS); /// Sum the total detector, excluding masked pixels and monitors - API::MatrixWorkspace_sptr sumSpectra(API::MatrixWorkspace_sptr WS); + API::MatrixWorkspace_sptr sumSpectra(const API::MatrixWorkspace_sptr &WS); bool logFit = false; ///< If true, will take log of transmission curve before fitting diff --git a/Framework/Algorithms/inc/MantidAlgorithms/CarpenterSampleCorrection.h b/Framework/Algorithms/inc/MantidAlgorithms/CarpenterSampleCorrection.h index a2f95dfe92304354fd27ee9afcbd40e3b9b332f8..3077f12a103e26b77a9359fcf93507127650c4af 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/CarpenterSampleCorrection.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/CarpenterSampleCorrection.h @@ -58,10 +58,10 @@ private: double coeff1, double coeff2, double coeff3, bool doAbs, bool doMS); - API::MatrixWorkspace_sptr multiply(const API::MatrixWorkspace_sptr lhsWS, - const API::MatrixWorkspace_sptr rhsWS); - API::MatrixWorkspace_sptr minus(const API::MatrixWorkspace_sptr lhsWS, - const API::MatrixWorkspace_sptr rhsWS); + API::MatrixWorkspace_sptr multiply(const API::MatrixWorkspace_sptr &lhsWS, + const API::MatrixWorkspace_sptr &rhsWS); + API::MatrixWorkspace_sptr minus(const API::MatrixWorkspace_sptr &lhsWS, + const API::MatrixWorkspace_sptr &rhsWS); }; } // namespace Algorithms diff --git a/Framework/Algorithms/inc/MantidAlgorithms/ChangeTimeZero.h b/Framework/Algorithms/inc/MantidAlgorithms/ChangeTimeZero.h index f2ce91329617827298a636d03c386c9fe8fbb174..ec2099ea8f25d8d51eec5fd3b5c8e1ecf41a8d12 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/ChangeTimeZero.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/ChangeTimeZero.h @@ -39,23 +39,24 @@ private: void exec() override; /// Create the output workspace Mantid::API::MatrixWorkspace_sptr - createOutputWS(Mantid::API::MatrixWorkspace_sptr input, double startProgress, - double stopProgress); + createOutputWS(const Mantid::API::MatrixWorkspace_sptr &input, + double startProgress, double stopProgress); /// Get the time shift - double getTimeShift(API::MatrixWorkspace_sptr ws) const; + double getTimeShift(const API::MatrixWorkspace_sptr &ws) const; /// Shift the time of the logs - void shiftTimeOfLogs(Mantid::API::MatrixWorkspace_sptr ws, double timeShift, - double startProgress, double stopProgress); + void shiftTimeOfLogs(const Mantid::API::MatrixWorkspace_sptr &ws, + double timeShift, double startProgress, + double stopProgress); /// Get the date and time of the first good frame of a workspace Mantid::Types::Core::DateAndTime - getStartTimeFromWorkspace(Mantid::API::MatrixWorkspace_sptr ws) const; + getStartTimeFromWorkspace(const Mantid::API::MatrixWorkspace_sptr &ws) const; /// Can the string be transformed to double - bool checkForDouble(std::string val) const; + bool checkForDouble(const std::string &val) const; /// Can the string be transformed to a DateTime bool checkForDateTime(const std::string &val) const; /// Time shift the log of a double series property - void shiftTimeInLogForTimeSeries(Mantid::API::MatrixWorkspace_sptr ws, + void shiftTimeInLogForTimeSeries(const Mantid::API::MatrixWorkspace_sptr &ws, Mantid::Kernel::Property *prop, double timeShift) const; /// Time shift the log of a string property @@ -63,7 +64,7 @@ private: Mantid::Kernel::PropertyWithValue<std::string> *logEntry, double timeShift) const; // Shift the time of the neutrons - void shiftTimeOfNeutrons(Mantid::API::MatrixWorkspace_sptr ws, + void shiftTimeOfNeutrons(const Mantid::API::MatrixWorkspace_sptr &ws, double timeShift, double startProgress, double stopProgress); diff --git a/Framework/Algorithms/inc/MantidAlgorithms/CompareWorkspaces.h b/Framework/Algorithms/inc/MantidAlgorithms/CompareWorkspaces.h index 67af3faa165aca2f426339ed4bed5a6b7a74e38a..107db8a58bf43e244442a0e9206bf911c0a12f58 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/CompareWorkspaces.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/CompareWorkspaces.h @@ -95,28 +95,30 @@ private: bool processGroups() override; /// Process the two groups - void processGroups(boost::shared_ptr<const API::WorkspaceGroup> groupOne, - boost::shared_ptr<const API::WorkspaceGroup> groupTwo); + void + processGroups(const boost::shared_ptr<const API::WorkspaceGroup> &groupOne, + const boost::shared_ptr<const API::WorkspaceGroup> &groupTwo); void doComparison(); void doPeaksComparison(DataObjects::PeaksWorkspace_sptr tws1, DataObjects::PeaksWorkspace_sptr tws2); - void doTableComparison(API::ITableWorkspace_const_sptr tws1, - API::ITableWorkspace_const_sptr tws2); - void doMDComparison(API::Workspace_sptr w1, API::Workspace_sptr w2); + void doTableComparison(const API::ITableWorkspace_const_sptr &tws1, + const API::ITableWorkspace_const_sptr &tws2); + void doMDComparison(const API::Workspace_sptr &w1, + const API::Workspace_sptr &w2); bool compareEventWorkspaces(const DataObjects::EventWorkspace &ews1, const DataObjects::EventWorkspace &ews2); - bool checkData(API::MatrixWorkspace_const_sptr ws1, - API::MatrixWorkspace_const_sptr ws2); - bool checkAxes(API::MatrixWorkspace_const_sptr ws1, - API::MatrixWorkspace_const_sptr ws2); - bool checkSpectraMap(API::MatrixWorkspace_const_sptr ws1, - API::MatrixWorkspace_const_sptr ws2); - bool checkInstrument(API::MatrixWorkspace_const_sptr ws1, - API::MatrixWorkspace_const_sptr ws2); - bool checkMasking(API::MatrixWorkspace_const_sptr ws1, - API::MatrixWorkspace_const_sptr ws2); + bool checkData(const API::MatrixWorkspace_const_sptr &ws1, + const API::MatrixWorkspace_const_sptr &ws2); + bool checkAxes(const API::MatrixWorkspace_const_sptr &ws1, + const API::MatrixWorkspace_const_sptr &ws2); + bool checkSpectraMap(const API::MatrixWorkspace_const_sptr &ws1, + const API::MatrixWorkspace_const_sptr &ws2); + bool checkInstrument(const API::MatrixWorkspace_const_sptr &ws1, + const API::MatrixWorkspace_const_sptr &ws2); + bool checkMasking(const API::MatrixWorkspace_const_sptr &ws1, + const API::MatrixWorkspace_const_sptr &ws2); bool checkSample(const API::Sample &sample1, const API::Sample &sample2); bool checkRunProperties(const API::Run &run1, const API::Run &run2); @@ -130,7 +132,7 @@ private: size_t &numdiffweight) const; /// Records a mismatch in the Messages workspace and sets Result to false - void recordMismatch(std::string msg, std::string ws1 = "", + void recordMismatch(const std::string &msg, std::string ws1 = "", std::string ws2 = ""); bool relErr(double x1, double x2, double errorVal) const; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/ConjoinXRuns.h b/Framework/Algorithms/inc/MantidAlgorithms/ConjoinXRuns.h index 382d9012d01b942a710d3381679a1a62343dde63..bd95f9d9988782ed3962573994b3df313135b119 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/ConjoinXRuns.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/ConjoinXRuns.h @@ -42,8 +42,8 @@ private: void init() override; void exec() override; - std::string checkLogEntry(API::MatrixWorkspace_sptr) const; - std::vector<double> getXAxis(API::MatrixWorkspace_sptr) const; + std::string checkLogEntry(const API::MatrixWorkspace_sptr &) const; + std::vector<double> getXAxis(const API::MatrixWorkspace_sptr &) const; void joinSpectrum(int64_t); /// Sample log entry name diff --git a/Framework/Algorithms/inc/MantidAlgorithms/ConvertEmptyToTof.h b/Framework/Algorithms/inc/MantidAlgorithms/ConvertEmptyToTof.h index 064281492b0f2012cd1801fc49d42f5c2ca0c51a..ddb8efc44bf35ece27d37adfcc5d33717e50dbd7 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/ConvertEmptyToTof.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/ConvertEmptyToTof.h @@ -58,7 +58,8 @@ private: bool areEqual(double, double, double); int roundUp(double); std::vector<double> makeTofAxis(int, double, size_t, double); - void setTofInWS(const std::vector<double> &, API::MatrixWorkspace_sptr); + void setTofInWS(const std::vector<double> &, + const API::MatrixWorkspace_sptr &); DataObjects::Workspace2D_sptr m_inputWS; API::MatrixWorkspace_sptr m_outputWS; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/ConvertSpectrumAxis.h b/Framework/Algorithms/inc/MantidAlgorithms/ConvertSpectrumAxis.h index 16370d79ad3d2b4897690b1e8f7bc5f0625c448c..c901152c2a8bbceaf409ec0f41fdd1c4869e49d6 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/ConvertSpectrumAxis.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/ConvertSpectrumAxis.h @@ -61,7 +61,8 @@ private: void exec() override; /// Getting Efixed double getEfixed(const Mantid::Geometry::IDetector &detector, - API::MatrixWorkspace_const_sptr inputWS, int emode) const; + const API::MatrixWorkspace_const_sptr &inputWS, + int emode) const; }; } // namespace Algorithms diff --git a/Framework/Algorithms/inc/MantidAlgorithms/ConvertToConstantL2.h b/Framework/Algorithms/inc/MantidAlgorithms/ConvertToConstantL2.h index 77ee90c93e77f18069c463f97d8133fe3b634096..0b7263119f73b4f0dae996dce28a484d827496bf 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/ConvertToConstantL2.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/ConvertToConstantL2.h @@ -51,8 +51,8 @@ private: void init() override; void exec() override; void initWorkspaces(); - double getRunProperty(std::string); - double getInstrumentProperty(std::string); + double getRunProperty(const std::string &); + double getInstrumentProperty(const std::string &); double calculateTOF(double); /// The user selected (input) workspace diff --git a/Framework/Algorithms/inc/MantidAlgorithms/ConvertUnits.h b/Framework/Algorithms/inc/MantidAlgorithms/ConvertUnits.h index 44ae9d412ba3a00bad84de8b5f52b7922bae531b..aef3ddfa017ab62fa36e41e4a8270af7d220f1f9 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/ConvertUnits.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/ConvertUnits.h @@ -69,12 +69,12 @@ public: protected: /// Reverses the workspace if X values are in descending order - void reverse(API::MatrixWorkspace_sptr WS); + void reverse(const API::MatrixWorkspace_sptr &WS); /// For conversions to energy transfer, removes bins corresponding to /// inaccessible values API::MatrixWorkspace_sptr - removeUnphysicalBins(const API::MatrixWorkspace_const_sptr workspace); + removeUnphysicalBins(const API::MatrixWorkspace_const_sptr &workspace); const std::string workspaceMethodName() const override { return "convertUnits"; @@ -87,21 +87,21 @@ protected: void init() override; void exec() override; - void setupMemberVariables(const API::MatrixWorkspace_const_sptr inputWS); + void setupMemberVariables(const API::MatrixWorkspace_const_sptr &inputWS); virtual void storeEModeOnWorkspace(API::MatrixWorkspace_sptr outputWS); API::MatrixWorkspace_sptr - setupOutputWorkspace(const API::MatrixWorkspace_const_sptr inputWS); + setupOutputWorkspace(const API::MatrixWorkspace_const_sptr &inputWS); /// Executes the main part of the algorithm that handles the conversion of the /// units API::MatrixWorkspace_sptr - executeUnitConversion(const API::MatrixWorkspace_sptr inputWS); + executeUnitConversion(const API::MatrixWorkspace_sptr &inputWS); /// Convert the workspace units according to a simple output = a * (input^b) /// relationship API::MatrixWorkspace_sptr - convertQuickly(API::MatrixWorkspace_const_sptr inputWS, const double &factor, - const double &power); + convertQuickly(const API::MatrixWorkspace_const_sptr &inputWS, + const double &factor, const double &power); /// Internal function to gather detector specific L2, theta and efixed values bool getDetectorValues(const API::SpectrumInfo &spectrumInfo, @@ -118,11 +118,11 @@ protected: // Calls Rebin as a Child Algorithm to align the bins of the output workspace API::MatrixWorkspace_sptr - alignBins(const API::MatrixWorkspace_sptr workspace); + alignBins(const API::MatrixWorkspace_sptr &workspace); const std::vector<double> - calculateRebinParams(const API::MatrixWorkspace_const_sptr workspace) const; + calculateRebinParams(const API::MatrixWorkspace_const_sptr &workspace) const; - void putBackBinWidth(const API::MatrixWorkspace_sptr outputWS); + void putBackBinWidth(const API::MatrixWorkspace_sptr &outputWS); std::size_t m_numberOfSpectra{ 0}; ///< The number of spectra in the input workspace diff --git a/Framework/Algorithms/inc/MantidAlgorithms/CorrectKiKf.h b/Framework/Algorithms/inc/MantidAlgorithms/CorrectKiKf.h index b6d92fc6624b8da2ada6db00e8d603d7fb067b84..3d802a8f70a232898e1ca7c767ec3a3145f724e0 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/CorrectKiKf.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/CorrectKiKf.h @@ -75,7 +75,7 @@ private: */ template <class T> void correctKiKfEventHelper(std::vector<T> &wevector, double efixed, - const std::string emodeStr); + const std::string &emodeStr); void getEfixedFromParameterMap(double &Efi, int64_t i, const Mantid::API::SpectrumInfo &spectrumInfo, const Mantid::Geometry::ParameterMap &pmap); diff --git a/Framework/Algorithms/inc/MantidAlgorithms/CorrectTOFAxis.h b/Framework/Algorithms/inc/MantidAlgorithms/CorrectTOFAxis.h index 487e6eeefc09854e9d260198342be2d2cbbd2ecc..cc380fc5809a251fc2e578b4d8f5cb45918a897d 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/CorrectTOFAxis.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/CorrectTOFAxis.h @@ -43,8 +43,8 @@ private: void init() override; std::map<std::string, std::string> validateInputs() override; void exec() override; - void useReferenceWorkspace(API::MatrixWorkspace_sptr outputWs); - void correctManually(API::MatrixWorkspace_sptr outputWs); + void useReferenceWorkspace(const API::MatrixWorkspace_sptr &outputWs); + void correctManually(const API::MatrixWorkspace_sptr &outputWs); double averageL2(const API::SpectrumInfo &spectrumInfo); void averageL2AndEPP(const API::SpectrumInfo &spectrumInfo, double &l2, double &epp); diff --git a/Framework/Algorithms/inc/MantidAlgorithms/CorrectToFile.h b/Framework/Algorithms/inc/MantidAlgorithms/CorrectToFile.h index b460a19d2ed7d4138bda54529641a937ae8dffa9..345a4d5f1c95aad8ebb2dd55ac9b5ebfec2f7215 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/CorrectToFile.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/CorrectToFile.h @@ -54,8 +54,9 @@ private: /// Load in the RKH file for that has the correction information API::MatrixWorkspace_sptr loadInFile(const std::string &corrFile); /// Multiply or divide the input workspace as specified by the user - void doWkspAlgebra(API::MatrixWorkspace_sptr lhs, - API::MatrixWorkspace_sptr rhs, const std::string &algName, + void doWkspAlgebra(const API::MatrixWorkspace_sptr &lhs, + const API::MatrixWorkspace_sptr &rhs, + const std::string &algName, API::MatrixWorkspace_sptr &result); }; } // namespace Algorithms diff --git a/Framework/Algorithms/inc/MantidAlgorithms/CreateFloodWorkspace.h b/Framework/Algorithms/inc/MantidAlgorithms/CreateFloodWorkspace.h index 0a6222f000c052be4e199c4c82c2722d82cb209b..5ee9bb5ebaae98f5eea734a5c109ca21b6387b32 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/CreateFloodWorkspace.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/CreateFloodWorkspace.h @@ -30,8 +30,8 @@ private: void exec() override; API::MatrixWorkspace_sptr getInputWorkspace(); std::string getBackgroundFunction(); - API::MatrixWorkspace_sptr integrate(API::MatrixWorkspace_sptr ws); - API::MatrixWorkspace_sptr transpose(API::MatrixWorkspace_sptr ws); + API::MatrixWorkspace_sptr integrate(const API::MatrixWorkspace_sptr &ws); + API::MatrixWorkspace_sptr transpose(const API::MatrixWorkspace_sptr &ws); bool shouldRemoveBackground(); void collectExcludedSpectra(); bool isExcludedSpectrum(double spec) const; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/CreateLogTimeCorrection.h b/Framework/Algorithms/inc/MantidAlgorithms/CreateLogTimeCorrection.h index 1b5ac646c72b1b09a18cd77e84d82064486061d5..3b394e4a005198b9dbf42a54f27579fb1335e6d3 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/CreateLogTimeCorrection.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/CreateLogTimeCorrection.h @@ -65,7 +65,7 @@ private: const std::vector<double> &corrections) const; /// Write correction map to a text file - void writeCorrectionToFile(const std::string filename, + void writeCorrectionToFile(const std::string &filename, const Geometry::DetectorInfo &detectorInfo, const std::vector<double> &corrections) const; }; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/CreatePSDBleedMask.h b/Framework/Algorithms/inc/MantidAlgorithms/CreatePSDBleedMask.h index 983716706a5bd137f8474349813ea5d8aaa8ab85..eef18d270f10da0133c6f46b6e8be189bf21a7e4 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/CreatePSDBleedMask.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/CreatePSDBleedMask.h @@ -53,11 +53,11 @@ private: /// Process a tube bool performBleedTest(const std::vector<int> &tubeIndices, - API::MatrixWorkspace_const_sptr inputWS, double maxRate, - int numIgnoredPixels); + const API::MatrixWorkspace_const_sptr &inputWS, + double maxRate, int numIgnoredPixels); /// Mask a tube with the given workspace indices void maskTube(const std::vector<int> &tubeIndices, - API::MatrixWorkspace_sptr workspace); + const API::MatrixWorkspace_sptr &workspace); }; } // namespace Algorithms diff --git a/Framework/Algorithms/inc/MantidAlgorithms/CreateSampleWorkspace.h b/Framework/Algorithms/inc/MantidAlgorithms/CreateSampleWorkspace.h index ca5266bb9224c437b1d7dc0732126260835930cf..31f7422b0e544e75548d900e2f0a7fa423ece1ef 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/CreateSampleWorkspace.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/CreateSampleWorkspace.h @@ -42,16 +42,18 @@ private: DataObjects::EventWorkspace_sptr createEventWorkspace(int numPixels, int numBins, int numMonitors, int numEvents, double x0, double binDelta, - Geometry::Instrument_sptr inst, + const Geometry::Instrument_sptr &inst, const std::string &functionString, bool isRandom); API::MatrixWorkspace_sptr createHistogramWorkspace(int numPixels, int numBins, int numMonitors, double x0, double binDelta, - Geometry::Instrument_sptr inst, + const Geometry::Instrument_sptr &inst, const std::string &functionString, bool isRandom); - API::MatrixWorkspace_sptr createScanningWorkspace( - int numBins, double x0, double binDelta, Geometry::Instrument_sptr inst, - const std::string &functionString, bool isRandom, int numScanPoints); + API::MatrixWorkspace_sptr + createScanningWorkspace(int numBins, double x0, double binDelta, + const Geometry::Instrument_sptr &inst, + const std::string &functionString, bool isRandom, + int numScanPoints); Geometry::Instrument_sptr createTestInstrumentRectangular( API::Progress &progress, int numBanks, int numMonitors, int pixels, double pixelSpacing, const double bankDistanceFromSample, diff --git a/Framework/Algorithms/inc/MantidAlgorithms/CreateTransmissionWorkspace.h b/Framework/Algorithms/inc/MantidAlgorithms/CreateTransmissionWorkspace.h index 5d9c55fece6d12ee925720de802f93f1fbd1fcdf..2b0f5b58f403202174edacae001f9e066299ac5b 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/CreateTransmissionWorkspace.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/CreateTransmissionWorkspace.h @@ -35,7 +35,7 @@ private: const OptionalMinMax &wavelengthMonitorBackgroundInterval, const OptionalMinMax &wavelengthMonitorIntegrationInterval, const OptionalInteger &i0MonitorIndex, - API::MatrixWorkspace_sptr firstTransmissionRun, + const API::MatrixWorkspace_sptr &firstTransmissionRun, OptionalMatrixWorkspace_sptr secondTransmissionRun, const OptionalDouble &stitchingStart, const OptionalDouble &stitchingDelta, const OptionalDouble &stitchingEnd, diff --git a/Framework/Algorithms/inc/MantidAlgorithms/CreateTransmissionWorkspace2.h b/Framework/Algorithms/inc/MantidAlgorithms/CreateTransmissionWorkspace2.h index 5bb0688750848bdde85b1f9cb4f201985f1e17af..b277f7a731506e1228c68a030bd760ab495e1f22 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/CreateTransmissionWorkspace2.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/CreateTransmissionWorkspace2.h @@ -36,15 +36,15 @@ private: /// Normalize by monitors API::MatrixWorkspace_sptr - normalizeDetectorsByMonitors(API::MatrixWorkspace_sptr IvsTOF); + normalizeDetectorsByMonitors(const API::MatrixWorkspace_sptr &IvsTOF); /// Get the run numbers of the input workspaces void getRunNumbers(); /// Get the run number of a given workspace std::string getRunNumber(std::string const &propertyName); /// Store a transition run in ADS - void setOutputTransmissionRun(int which, API::MatrixWorkspace_sptr ws); + void setOutputTransmissionRun(int which, const API::MatrixWorkspace_sptr &ws); /// Store the stitched transition workspace run in ADS - void setOutputWorkspace(API::MatrixWorkspace_sptr ws); + void setOutputWorkspace(const API::MatrixWorkspace_sptr &ws); /// Run numbers for the first/second transmission run std::string m_firstTransmissionRunNumber; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/CreateTransmissionWorkspaceAuto.h b/Framework/Algorithms/inc/MantidAlgorithms/CreateTransmissionWorkspaceAuto.h index 471625df43a38e23d90ceec5d3c588d90e6eec60..75546c2e0858a3ec1d51a7809506bc73962eb8e6 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/CreateTransmissionWorkspaceAuto.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/CreateTransmissionWorkspaceAuto.h @@ -36,7 +36,8 @@ private: void init() override; void exec() override; - template <typename T> boost::optional<T> isSet(std::string propName) const; + template <typename T> + boost::optional<T> isSet(const std::string &propName) const; }; } // namespace Algorithms diff --git a/Framework/Algorithms/inc/MantidAlgorithms/DetectorDiagnostic.h b/Framework/Algorithms/inc/MantidAlgorithms/DetectorDiagnostic.h index e0b95553eaf857d03a82d0792285cbb88ef5ac69..612883192212260bbadda9a33632d8098cb44849 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/DetectorDiagnostic.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/DetectorDiagnostic.h @@ -54,21 +54,21 @@ private: void init() override; void exec() override; /// Apply a given mask - void applyMask(API::MatrixWorkspace_sptr inputWS, - API::MatrixWorkspace_sptr maskWS); + void applyMask(const API::MatrixWorkspace_sptr &inputWS, + const API::MatrixWorkspace_sptr &maskWS); /// Perform checks on detector vanadium - API::MatrixWorkspace_sptr doDetVanTest(API::MatrixWorkspace_sptr inputWS, - int &nFails); + API::MatrixWorkspace_sptr + doDetVanTest(const API::MatrixWorkspace_sptr &inputWS, int &nFails); protected: /// Get the total counts for each spectra API::MatrixWorkspace_sptr - integrateSpectra(API::MatrixWorkspace_sptr inputWS, const int indexMin, + integrateSpectra(const API::MatrixWorkspace_sptr &inputWS, const int indexMin, const int indexMax, const double lower, const double upper, const bool outputWorkspace2D = false); DataObjects::MaskWorkspace_sptr - generateEmptyMask(API::MatrixWorkspace_const_sptr inputWS); + generateEmptyMask(const API::MatrixWorkspace_const_sptr &inputWS); /// Calculate the median of the given workspace. This assumes that the input /// workspace contains @@ -80,7 +80,8 @@ protected: API::MatrixWorkspace_sptr convertToRate(API::MatrixWorkspace_sptr workspace); /// method to check which spectra should be grouped when calculating the /// median - std::vector<std::vector<size_t>> makeMap(API::MatrixWorkspace_sptr countsWS); + std::vector<std::vector<size_t>> + makeMap(const API::MatrixWorkspace_sptr &countsWS); /// method to create the map with all spectra std::vector<std::vector<size_t>> makeInstrumentMap(const API::MatrixWorkspace &countsWS); diff --git a/Framework/Algorithms/inc/MantidAlgorithms/DetectorEfficiencyVariation.h b/Framework/Algorithms/inc/MantidAlgorithms/DetectorEfficiencyVariation.h index 45618d558710456b6ada8eb1f6813b8280169979..205ada7ea22361b0f31514d046f73933cc9fe95c 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/DetectorEfficiencyVariation.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/DetectorEfficiencyVariation.h @@ -72,8 +72,8 @@ protected: API::MatrixWorkspace_sptr &whiteBeam2, double &variation, int &minSpec, int &maxSpec); /// Apply the detector test criterion - int doDetectorTests(API::MatrixWorkspace_const_sptr counts1, - API::MatrixWorkspace_const_sptr counts2, + int doDetectorTests(const API::MatrixWorkspace_const_sptr &counts1, + const API::MatrixWorkspace_const_sptr &counts2, const double average, double variation); private: diff --git a/Framework/Algorithms/inc/MantidAlgorithms/DiffractionEventCalibrateDetectors.h b/Framework/Algorithms/inc/MantidAlgorithms/DiffractionEventCalibrateDetectors.h index 059a5714105c44fa0e900952fdd24b8af1c9c279..1bf164a22f2f4725dc88258b22b027f51b689441 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/DiffractionEventCalibrateDetectors.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/DiffractionEventCalibrateDetectors.h @@ -49,12 +49,13 @@ public: } /// Function to optimize double intensity(double x, double y, double z, double rotx, double roty, - double rotz, std::string detname, std::string inname, - std::string outname, std::string peakOpt, - std::string rb_param, std::string groupWSName); + double rotz, const std::string &detname, + const std::string &inname, const std::string &outname, + const std::string &peakOpt, const std::string &rb_param, + const std::string &groupWSName); void movedetector(double x, double y, double z, double rotx, double roty, - double rotz, std::string detname, - Mantid::DataObjects::EventWorkspace_sptr inputW); + double rotz, const std::string &detname, + const Mantid::DataObjects::EventWorkspace_sptr &inputW); private: // Overridden Algorithm methods diff --git a/Framework/Algorithms/inc/MantidAlgorithms/DiffractionFocussing.h b/Framework/Algorithms/inc/MantidAlgorithms/DiffractionFocussing.h index 8795383fb3a05c2a48ae13c7d624d3b5ed2b05f3..ffe71bb24d0e090bd83f7d0c350ce684a70ad231 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/DiffractionFocussing.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/DiffractionFocussing.h @@ -78,7 +78,7 @@ private: void calculateRebinParams(const API::MatrixWorkspace_const_sptr &workspace, double &min, double &max, double &step); std::multimap<int64_t, int64_t> - readGroupingFile(std::string groupingFileName); + readGroupingFile(const std::string &groupingFileName); }; } // namespace Algorithms diff --git a/Framework/Algorithms/inc/MantidAlgorithms/EQSANSTofStructure.h b/Framework/Algorithms/inc/MantidAlgorithms/EQSANSTofStructure.h index 65a3f8b9730479a233bd231ccad83cf10a9dcd39..3b131ab4ed52a5c9974261f237786bef68a667cb 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/EQSANSTofStructure.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/EQSANSTofStructure.h @@ -60,12 +60,12 @@ private: void exec() override; // void execEvent(Mantid::DataObjects::EventWorkspace_sptr inputWS, bool // frame_skipping); - void execEvent(Mantid::DataObjects::EventWorkspace_sptr inputWS, + void execEvent(const Mantid::DataObjects::EventWorkspace_sptr &inputWS, double threshold, double frame_offset, double tof_frame_width, double tmp_frame_width, bool frame_skipping); /// Compute TOF offset - double getTofOffset(DataObjects::EventWorkspace_const_sptr inputWS, + double getTofOffset(const DataObjects::EventWorkspace_const_sptr &inputWS, bool frame_skipping); double frame_tof0; bool flight_path_correction; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/ExportTimeSeriesLog.h b/Framework/Algorithms/inc/MantidAlgorithms/ExportTimeSeriesLog.h index 53771879bf564de1dcd993f605f5bbbf74991f6c..e2e3a903912d35914e64ec547ae4231ce9263a94 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/ExportTimeSeriesLog.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/ExportTimeSeriesLog.h @@ -58,7 +58,7 @@ private: const double &rel_start_time, size_t &i_start, const double &rel_stop_time, size_t &i_stop, const double &time_factor); - void exportLog(const std::string &logname, const std::string timeunit, + void exportLog(const std::string &logname, const std::string &timeunit, const double &starttime, const double &stoptime, const bool exportepoch, bool outputeventws, int numentries, bool cal_first_deriv); diff --git a/Framework/Algorithms/inc/MantidAlgorithms/ExtractMaskToTable.h b/Framework/Algorithms/inc/MantidAlgorithms/ExtractMaskToTable.h index 51caf074ea83d835478ade61e6f1234b5528771f..7c0173f5e99ec2fb0a521e2b91156649c7d3c82b 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/ExtractMaskToTable.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/ExtractMaskToTable.h @@ -54,11 +54,11 @@ private: /// Parse input TableWorkspace to get a list of detectors IDs of which /// detector are already masked std::vector<detid_t> - parseMaskTable(DataObjects::TableWorkspace_sptr masktablews); + parseMaskTable(const DataObjects::TableWorkspace_sptr &masktablews); /// Parse a string containing list in format (x, xx-yy, x, x, ...) to a vector /// of detid_t - std::vector<detid_t> parseStringToVector(std::string liststr); + std::vector<detid_t> parseStringToVector(const std::string &liststr); /// Extract mask from a workspace to a list of detectors std::vector<detid_t> extractMaskFromMatrixWorkspace(); @@ -67,11 +67,12 @@ private: std::vector<detid_t> extractMaskFromMaskWorkspace(); /// Copy table workspace content from one workspace to another - void copyTableWorkspaceContent(DataObjects::TableWorkspace_sptr sourceWS, - DataObjects::TableWorkspace_sptr targetWS); + void + copyTableWorkspaceContent(const DataObjects::TableWorkspace_sptr &sourceWS, + const DataObjects::TableWorkspace_sptr &targetWS); /// Add a list of spectra (detector IDs) to the output table workspace - void addToTableWorkspace(DataObjects::TableWorkspace_sptr outws, + void addToTableWorkspace(const DataObjects::TableWorkspace_sptr &outws, std::vector<detid_t> maskeddetids, double xmin, double xmax, std::vector<detid_t> prevmaskedids); }; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/FindPeaks.h b/Framework/Algorithms/inc/MantidAlgorithms/FindPeaks.h index a91db4d2de5ab05abeeb8ae2c21a69d04755af07..95f0cedf2c8b31da6635ae8100bc297ff576cba2 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/FindPeaks.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/FindPeaks.h @@ -170,8 +170,8 @@ private: /// Fit peak by calling 'FitPeak' double callFitPeak(const API::MatrixWorkspace_sptr &dataws, int wsindex, - const API::IPeakFunction_sptr peakfunction, - const API::IBackgroundFunction_sptr backgroundfunction, + const API::IPeakFunction_sptr &peakfunction, + const API::IBackgroundFunction_sptr &backgroundfunction, const std::vector<double> &vec_fitwindow, const std::vector<double> &vec_peakrange, int minGuessFWHM, int maxGuessFWHM, int guessedFWHMStep, diff --git a/Framework/Algorithms/inc/MantidAlgorithms/FitPeak.h b/Framework/Algorithms/inc/MantidAlgorithms/FitPeak.h index 2cf6b455d0cfa5bf7915d167dca9ae6065d5ae7c..692741c7a35052c6f5c57739356aac9ab3660c9b 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/FitPeak.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/FitPeak.h @@ -38,14 +38,14 @@ public: } /// Set workspaces - void setWorskpace(API::MatrixWorkspace_sptr dataws, size_t wsindex); + void setWorskpace(const API::MatrixWorkspace_sptr &dataws, size_t wsindex); /// Set fitting method - void setFittingMethod(std::string minimizer, std::string costfunction); + void setFittingMethod(std::string minimizer, const std::string &costfunction); /// Set functions - void setFunctions(API::IPeakFunction_sptr peakfunc, - API::IBackgroundFunction_sptr bkgdfunc); + void setFunctions(const API::IPeakFunction_sptr &peakfunc, + const API::IBackgroundFunction_sptr &bkgdfunc); /// Set fit range void setFitWindow(double leftwindow, double rightwindow); @@ -95,52 +95,52 @@ private: bool hasSetupToFitPeak(std::string &errmsg); /// Estimate the peak height from a set of data containing pure peaks - double estimatePeakHeight(API::IPeakFunction_const_sptr peakfunc, - API::MatrixWorkspace_sptr dataws, size_t wsindex, - size_t ixmin, size_t ixmax); + double estimatePeakHeight(const API::IPeakFunction_const_sptr &peakfunc, + const API::MatrixWorkspace_sptr &dataws, + size_t wsindex, size_t ixmin, size_t ixmax); /// Check a peak function whether it is valid comparing to user specified /// criteria - double checkFittedPeak(API::IPeakFunction_sptr peakfunc, double costfuncvalue, - std::string &errorreason); + double checkFittedPeak(const API::IPeakFunction_sptr &peakfunc, + double costfuncvalue, std::string &errorreason); /// Fit peak function (flexible) - double fitPeakFunction(API::IPeakFunction_sptr peakfunc, - API::MatrixWorkspace_sptr dataws, size_t wsindex, - double startx, double endx); + double fitPeakFunction(const API::IPeakFunction_sptr &peakfunc, + const API::MatrixWorkspace_sptr &dataws, + size_t wsindex, double startx, double endx); /// Fit function in single domain double fitFunctionSD(API::IFunction_sptr fitfunc, - API::MatrixWorkspace_sptr dataws, size_t wsindex, + const API::MatrixWorkspace_sptr &dataws, size_t wsindex, double xmin, double xmax); /// Calculate chi-square of a single domain function - double calChiSquareSD(API::IFunction_sptr fitfunc, - API::MatrixWorkspace_sptr dataws, size_t wsindex, + double calChiSquareSD(const API::IFunction_sptr &fitfunc, + const API::MatrixWorkspace_sptr &dataws, size_t wsindex, double xmin, double xmax); /// Fit peak and background composite function - double fitCompositeFunction(API::IPeakFunction_sptr peakfunc, - API::IBackgroundFunction_sptr bkgdfunc, - API::MatrixWorkspace_sptr dataws, size_t wsindex, - double startx, double endx); + double fitCompositeFunction(const API::IPeakFunction_sptr &peakfunc, + const API::IBackgroundFunction_sptr &bkgdfunc, + const API::MatrixWorkspace_sptr &dataws, + size_t wsindex, double startx, double endx); /// Fit function in multiple-domain - double fitFunctionMD(API::IFunction_sptr fitfunc, - API::MatrixWorkspace_sptr dataws, size_t wsindex, + double fitFunctionMD(const API::IFunction_sptr &fitfunc, + const API::MatrixWorkspace_sptr &dataws, size_t wsindex, std::vector<double> vec_xmin, std::vector<double> vec_xmax); /// remove background - void removeBackground(API::MatrixWorkspace_sptr purePeakWS); + void removeBackground(const API::MatrixWorkspace_sptr &purePeakWS); /// Process and store fit result void processNStoreFitResult(double rwp, bool storebkgd); /// Back up fit result - std::map<std::string, double> backup(API::IFunction_const_sptr func); + std::map<std::string, double> backup(const API::IFunction_const_sptr &func); void pop(const std::map<std::string, double> &funcparammap, - API::IFunction_sptr func); + const API::IFunction_sptr &func); /// Store function fitting error std::map<std::string, double> @@ -316,14 +316,14 @@ private: /// Generate table workspace DataObjects::TableWorkspace_sptr - genOutputTableWS(API::IPeakFunction_sptr peakfunc, + genOutputTableWS(const API::IPeakFunction_sptr &peakfunc, std::map<std::string, double> peakerrormap, - API::IBackgroundFunction_sptr bkgdfunc, + const API::IBackgroundFunction_sptr &bkgdfunc, std::map<std::string, double> bkgderrormap); /// Add function's parameter names after peak function name std::vector<std::string> - addFunctionParameterNames(std::vector<std::string> funcnames); + addFunctionParameterNames(const std::vector<std::string> &funcnames); /// Parse peak type from full peak type/parameter names string std::string parseFunctionTypeFull(const std::string &fullstring, diff --git a/Framework/Algorithms/inc/MantidAlgorithms/FitPeaks.h b/Framework/Algorithms/inc/MantidAlgorithms/FitPeaks.h index 44374d1f0733b41310d03a73c0db476d5db14098..286faf480dbb79b8440686e56a7caf196a3c8b8c 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/FitPeaks.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/FitPeaks.h @@ -43,7 +43,7 @@ public: double getParameterValue(size_t ipeak, size_t iparam) const; double getParameterError(size_t ipeak, size_t iparam) const; void setRecord(size_t ipeak, const double cost, const double peak_position, - const FitFunction fit_functions); + const FitFunction &fit_functions); void setBadRecord(size_t ipeak, const double peak_position); void setFunctionParameters(size_t ipeak, std::vector<double> ¶m_values); @@ -122,46 +122,45 @@ private: /// fit peaks in a same spectrum void fitSpectrumPeaks( size_t wi, const std::vector<double> &expected_peak_centers, - boost::shared_ptr<FitPeaksAlgorithm::PeakFitResult> fit_result); + const boost::shared_ptr<FitPeaksAlgorithm::PeakFitResult> &fit_result); /// fit background bool fitBackground(const size_t &ws_index, const std::pair<double, double> &fit_window, const double &expected_peak_pos, - API::IBackgroundFunction_sptr bkgd_func); + const API::IBackgroundFunction_sptr &bkgd_func); // Peak fitting suite - double fitIndividualPeak(size_t wi, API::IAlgorithm_sptr fitter, + double fitIndividualPeak(size_t wi, const API::IAlgorithm_sptr &fitter, const double expected_peak_center, const std::pair<double, double> &fitwindow, const bool observe_peak_params, - API::IPeakFunction_sptr peakfunction, - API::IBackgroundFunction_sptr bkgdfunc); + const API::IPeakFunction_sptr &peakfunction, + const API::IBackgroundFunction_sptr &bkgdfunc); /// Methods to fit functions (general) - double fitFunctionSD(API::IAlgorithm_sptr fit, - API::IPeakFunction_sptr peak_function, - API::IBackgroundFunction_sptr bkgd_function, - API::MatrixWorkspace_sptr dataws, size_t wsindex, + double fitFunctionSD(const API::IAlgorithm_sptr &fit, + const API::IPeakFunction_sptr &peak_function, + const API::IBackgroundFunction_sptr &bkgd_function, + const API::MatrixWorkspace_sptr &dataws, size_t wsindex, double xmin, double xmax, const double &expected_peak_center, bool observe_peak_shape, bool estimate_background); double fitFunctionMD(API::IFunction_sptr fit_function, - API::MatrixWorkspace_sptr dataws, size_t wsindex, + const API::MatrixWorkspace_sptr &dataws, size_t wsindex, std::vector<double> &vec_xmin, std::vector<double> &vec_xmax); /// fit a single peak with high background - double fitFunctionHighBackground(API::IAlgorithm_sptr fit, - const std::pair<double, double> &fit_window, - const size_t &ws_index, - const double &expected_peak_center, - bool observe_peak_shape, - API::IPeakFunction_sptr peakfunction, - API::IBackgroundFunction_sptr bkgdfunc); - - void setupParameterTableWorkspace(API::ITableWorkspace_sptr table_ws, + double fitFunctionHighBackground( + const API::IAlgorithm_sptr &fit, + const std::pair<double, double> &fit_window, const size_t &ws_index, + const double &expected_peak_center, bool observe_peak_shape, + const API::IPeakFunction_sptr &peakfunction, + const API::IBackgroundFunction_sptr &bkgdfunc); + + void setupParameterTableWorkspace(const API::ITableWorkspace_sptr &table_ws, const std::vector<std::string> ¶m_names, bool with_chi2); @@ -171,7 +170,7 @@ private: std::vector<double> &vec_e); /// Reduce background - void reduceByBackground(API::IBackgroundFunction_sptr bkgd_func, + void reduceByBackground(const API::IBackgroundFunction_sptr &bkgd_func, const std::vector<double> &vec_x, std::vector<double> &vec_y); @@ -183,7 +182,7 @@ private: /// Esitmate background by 'observation' void estimateBackground(const HistogramData::Histogram &histogram, const std::pair<double, double> &peak_window, - API::IBackgroundFunction_sptr bkgd_function); + const API::IBackgroundFunction_sptr &bkgd_function); /// estimate linear background void estimateLinearBackground(const HistogramData::Histogram &histogram, double left_window_boundary, @@ -193,12 +192,12 @@ private: /// Estimate peak parameters by 'observation' int estimatePeakParameters(const HistogramData::Histogram &histogram, const std::pair<double, double> &peak_window, - API::IPeakFunction_sptr peakfunction, - API::IBackgroundFunction_sptr bkgdfunction, + const API::IPeakFunction_sptr &peakfunction, + const API::IBackgroundFunction_sptr &bkgdfunction, bool observe_peak_width); bool decideToEstimatePeakParams(const bool firstPeakInSpectrum, - API::IPeakFunction_sptr peak_function); + const API::IPeakFunction_sptr &peak_function); /// observe peak center int observePeakCenter(const HistogramData::Histogram &histogram, @@ -215,8 +214,8 @@ private: void processSinglePeakFitResult( size_t wsindex, size_t peakindex, const double cost, const std::vector<double> &expected_peak_positions, - FitPeaksAlgorithm::FitFunction fitfunction, - boost::shared_ptr<FitPeaksAlgorithm::PeakFitResult> fit_result); + const FitPeaksAlgorithm::FitFunction &fitfunction, + const boost::shared_ptr<FitPeaksAlgorithm::PeakFitResult> &fit_result); /// calculate peak+background for fitted void calculateFittedPeaks( @@ -224,8 +223,8 @@ private: fit_results); /// Get the parameter name for peak height (I or height or etc) - std::string - getPeakHeightParameterName(API::IPeakFunction_const_sptr peak_function); + std::string getPeakHeightParameterName( + const API::IPeakFunction_const_sptr &peak_function); /// Set the workspaces and etc to output properties void processOutputs( @@ -235,7 +234,7 @@ private: /// Write result of peak fit per spectrum to output analysis workspaces void writeFitResult( size_t wi, const std::vector<double> &expected_positions, - boost::shared_ptr<FitPeaksAlgorithm::PeakFitResult> fit_result); + const boost::shared_ptr<FitPeaksAlgorithm::PeakFitResult> &fit_result); /// check whether FitPeaks supports observation on a certain peak profile's /// parameters (width!) diff --git a/Framework/Algorithms/inc/MantidAlgorithms/GenerateEventsFilter.h b/Framework/Algorithms/inc/MantidAlgorithms/GenerateEventsFilter.h index bb65b15ab66cf8f2166c511e7ce15afbe706a9c3..5326180be0858270ae48fda558b1d3caf5978f80 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/GenerateEventsFilter.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/GenerateEventsFilter.h @@ -76,7 +76,7 @@ private: void processInputTime(); void setFilterByTimeOnly(); - void setFilterByLogValue(std::string logname); + void setFilterByLogValue(const std::string &logname); void processSingleValueFilter(double minvalue, double maxvalue, bool filterincrease, bool filterdecrease); @@ -93,7 +93,7 @@ private: /// Make multiple-log-value filters in serial void makeMultipleFiltersByValues(std::map<size_t, int> indexwsindexmap, - std::vector<double> logvalueranges, + const std::vector<double> &logvalueranges, bool centre, bool filterIncrease, bool filterDecrease, Types::Core::DateAndTime startTime, @@ -101,17 +101,19 @@ private: /// Make multiple-log-value filters in serial in parallel void makeMultipleFiltersByValuesParallel( - std::map<size_t, int> indexwsindexmap, std::vector<double> logvalueranges, - bool centre, bool filterIncrease, bool filterDecrease, + const std::map<size_t, int> &indexwsindexmap, + const std::vector<double> &logvalueranges, bool centre, + bool filterIncrease, bool filterDecrease, Types::Core::DateAndTime startTime, Types::Core::DateAndTime stopTime); /// Generate event splitters for partial sample log (serial) void makeMultipleFiltersByValuesPartialLog( int istart, int iend, std::vector<Types::Core::DateAndTime> &vecSplitTime, std::vector<int> &vecSplitGroup, std::map<size_t, int> indexwsindexmap, - const std::vector<double> &logvalueranges, Types::Core::time_duration tol, - bool filterIncrease, bool filterDecrease, - Types::Core::DateAndTime startTime, Types::Core::DateAndTime stopTime); + const std::vector<double> &logvalueranges, + const Types::Core::time_duration &tol, bool filterIncrease, + bool filterDecrease, Types::Core::DateAndTime startTime, + Types::Core::DateAndTime stopTime); /// Generate event filters for integer sample log void processIntegerValueFilter(int minvalue, int maxvalue, @@ -124,7 +126,7 @@ private: /// Add a splitter void addNewTimeFilterSplitter(Types::Core::DateAndTime starttime, Types::Core::DateAndTime stoptime, int wsindex, - std::string info); + const std::string &info); /// Create a splitter and add to the vector of time splitters Types::Core::DateAndTime diff --git a/Framework/Algorithms/inc/MantidAlgorithms/GeneratePeaks.h b/Framework/Algorithms/inc/MantidAlgorithms/GeneratePeaks.h index 68e1fad7954bebd42c28aaa8659ed5fdbb06cafd..b10f8c3c6deaa673b2e50db2477f4e4630440489 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/GeneratePeaks.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/GeneratePeaks.h @@ -69,10 +69,11 @@ private: const std::map<specnum_t, std::vector<std::pair<double, API::IFunction_sptr>>> &functionmap, - API::MatrixWorkspace_sptr dataWS); + const API::MatrixWorkspace_sptr &dataWS); /// Check whether function has a certain parameter - bool hasParameter(API::IFunction_sptr function, std::string paramname); + bool hasParameter(const API::IFunction_sptr &function, + const std::string ¶mname); /// Create output workspace API::MatrixWorkspace_sptr createOutputWorkspace(); @@ -82,14 +83,15 @@ private: void createFunction(std::string &peaktype, std::string &bkgdtype); - void getSpectraSet(DataObjects::TableWorkspace_const_sptr peakParmsWS); + void getSpectraSet(const DataObjects::TableWorkspace_const_sptr &peakParmsWS); /// Get the IPeakFunction part in the input function - API::IPeakFunction_sptr getPeakFunction(API::IFunction_sptr infunction); + API::IPeakFunction_sptr + getPeakFunction(const API::IFunction_sptr &infunction); /// Add function parameter names to std::vector<std::string> - addFunctionParameterNames(std::vector<std::string> funcnames); + addFunctionParameterNames(const std::vector<std::string> &funcnames); /// Peak function API::IPeakFunction_sptr m_peakFunction; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/GetDetOffsetsMultiPeaks.h b/Framework/Algorithms/inc/MantidAlgorithms/GetDetOffsetsMultiPeaks.h index 455a940dc7bac78582519abdec29a2feaad16335..acdd85574617520b751566f61ebcc953c164bcd1 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/GetDetOffsetsMultiPeaks.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/GetDetOffsetsMultiPeaks.h @@ -80,11 +80,11 @@ private: /// Main function to calculate all detectors' offsets void calculateDetectorsOffsets(); - void - importFitWindowTableWorkspace(DataObjects::TableWorkspace_sptr windowtablews); + void importFitWindowTableWorkspace( + const DataObjects::TableWorkspace_sptr &windowtablews); /// Call Gaussian as a Child Algorithm to fit the peak in a spectrum - int fitSpectra(const int64_t wi, API::MatrixWorkspace_sptr inputW, + int fitSpectra(const int64_t wi, const API::MatrixWorkspace_sptr &inputW, const std::vector<double> &peakPositions, const std::vector<double> &fitWindows, size_t &nparams, double &minD, double &maxD, std::vector<double> &peakPosToFit, @@ -94,7 +94,7 @@ private: /// Add peak fitting and offset calculation information to information table /// workspaces per spectrum - void addInfoToReportWS(int wi, FitPeakOffsetResult offsetresult, + void addInfoToReportWS(int wi, const FitPeakOffsetResult &offsetresult, const std::vector<double> &tofitpeakpositions, const std::vector<double> &fittedpeakpositions); diff --git a/Framework/Algorithms/inc/MantidAlgorithms/GetEi.h b/Framework/Algorithms/inc/MantidAlgorithms/GetEi.h index d9733304bb1c61175a294d568ba36ee2b0f03b10..424499f333ca434da570da36447f62e1522bfa1a 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/GetEi.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/GetEi.h @@ -68,15 +68,15 @@ private: void init() override; void exec() override; - void getGeometry(API::MatrixWorkspace_const_sptr WS, specnum_t mon0Spec, - specnum_t mon1Spec, double &monitor0Dist, + void getGeometry(const API::MatrixWorkspace_const_sptr &WS, + specnum_t mon0Spec, specnum_t mon1Spec, double &monitor0Dist, double &monitor1Dist) const; - std::vector<size_t> getMonitorWsIndexs(API::MatrixWorkspace_const_sptr WS, - specnum_t specNum1, - specnum_t specNum2) const; + std::vector<size_t> + getMonitorWsIndexs(const API::MatrixWorkspace_const_sptr &WS, + specnum_t specNum1, specnum_t specNum2) const; double timeToFly(double s, double E_KE) const; - double getPeakCentre(API::MatrixWorkspace_const_sptr WS, const size_t monitIn, - const double peakTime); + double getPeakCentre(const API::MatrixWorkspace_const_sptr &WS, + const size_t monitIn, const double peakTime); void extractSpec(int wsInd, double start, double end); void getPeakEstimates(double &height, int64_t ¢reInd, double &background) const; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/GetEi2.h b/Framework/Algorithms/inc/MantidAlgorithms/GetEi2.h index 56e478e4349cdea2015c3a68e9cadba714556d44..ac6fc8d9d710a35e248f6b4c98c345b17e785c29 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/GetEi2.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/GetEi2.h @@ -84,16 +84,15 @@ private: API::MatrixWorkspace_sptr extractSpectrum(const size_t ws_index, const double start, const double end); /// Calculate peak width - double calculatePeakWidthAtHalfHeight(API::MatrixWorkspace_sptr data_ws, - const double prominence, - std::vector<double> &peak_x, - std::vector<double> &peak_y, - std::vector<double> &peak_e) const; + double calculatePeakWidthAtHalfHeight( + const API::MatrixWorkspace_sptr &data_ws, const double prominence, + std::vector<double> &peak_x, std::vector<double> &peak_y, + std::vector<double> &peak_e) const; /// Calculate the value of the first moment of the given spectrum - double calculateFirstMoment(API::MatrixWorkspace_sptr monitor_ws, + double calculateFirstMoment(const API::MatrixWorkspace_sptr &monitor_ws, const double prominence); /// Rebin the given workspace using the given parameters - API::MatrixWorkspace_sptr rebin(API::MatrixWorkspace_sptr monitor_ws, + API::MatrixWorkspace_sptr rebin(const API::MatrixWorkspace_sptr &monitor_ws, const double first, const double width, const double end); /// Integrate the point data diff --git a/Framework/Algorithms/inc/MantidAlgorithms/GetQsInQENSData.h b/Framework/Algorithms/inc/MantidAlgorithms/GetQsInQENSData.h index d552b35ae5d714b91372ca197e3012d5f38856b1..26243e70c43f716e130e70b2ad97171444df3b70 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/GetQsInQENSData.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/GetQsInQENSData.h @@ -53,7 +53,7 @@ private: void exec() override; /// Extracts Q-values from the specified matrix workspace - MantidVec extractQValues(const Mantid::API::MatrixWorkspace_sptr workspace); + MantidVec extractQValues(const Mantid::API::MatrixWorkspace_sptr &workspace); }; } // namespace Algorithms } // namespace Mantid diff --git a/Framework/Algorithms/inc/MantidAlgorithms/GetTimeSeriesLogInformation.h b/Framework/Algorithms/inc/MantidAlgorithms/GetTimeSeriesLogInformation.h index 9ab9912083ee6583456e41b6261c878521a5bf30..d271bef466daa0e90fe6014a0c9bef0ab5e5e84b 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/GetTimeSeriesLogInformation.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/GetTimeSeriesLogInformation.h @@ -89,7 +89,7 @@ private: void execQuickStatistics(); - void exportErrorLog(API::MatrixWorkspace_sptr ws, + void exportErrorLog(const API::MatrixWorkspace_sptr &ws, std::vector<Types::Core::DateAndTime> abstimevec, double dts); diff --git a/Framework/Algorithms/inc/MantidAlgorithms/He3TubeEfficiency.h b/Framework/Algorithms/inc/MantidAlgorithms/He3TubeEfficiency.h index d9dcc5139400a8a0f25ddd80919d6eb6a83b5c9b..77c6a08bdd537237e1983d03cdb81c92b9b69119 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/He3TubeEfficiency.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/He3TubeEfficiency.h @@ -94,8 +94,9 @@ private: /// Log any errors with spectra that occurred void logErrors() const; /// Retrieve the detector parameters from workspace or detector properties - double getParameter(std::string wsPropName, std::size_t currentIndex, - std::string detPropName, const Geometry::IDetector &idet); + double getParameter(const std::string &wsPropName, std::size_t currentIndex, + const std::string &detPropName, + const Geometry::IDetector &idet); /// Helper for event handling template <class T> void eventHelper(std::vector<T> &events, double expval); /// Function to calculate exponential contribution diff --git a/Framework/Algorithms/inc/MantidAlgorithms/IQTransform.h b/Framework/Algorithms/inc/MantidAlgorithms/IQTransform.h index e58b10754e764de26db396807b62ec536646a19e..6343d9f8392b6f216995ec9c7d1d4479507ea42b 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/IQTransform.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/IQTransform.h @@ -67,10 +67,11 @@ private: void exec() override; inline API::MatrixWorkspace_sptr - subtractBackgroundWS(API::MatrixWorkspace_sptr ws, - API::MatrixWorkspace_sptr background); + subtractBackgroundWS(const API::MatrixWorkspace_sptr &ws, + const API::MatrixWorkspace_sptr &background); - using TransformFunc = void (IQTransform::*)(API::MatrixWorkspace_sptr); + using TransformFunc = + void (IQTransform::*)(const API::MatrixWorkspace_sptr &); using TransformMap = std::map<std::string, TransformFunc>; TransformMap m_transforms; ///< A map of transformation name and function pointers @@ -78,16 +79,16 @@ private: boost::shared_ptr<Kernel::Units::Label> m_label; // A function for each transformation - void guinierSpheres(API::MatrixWorkspace_sptr ws); - void guinierRods(API::MatrixWorkspace_sptr ws); - void guinierSheets(API::MatrixWorkspace_sptr ws); - void zimm(API::MatrixWorkspace_sptr ws); - void debyeBueche(API::MatrixWorkspace_sptr ws); - void kratky(API::MatrixWorkspace_sptr ws); - void porod(API::MatrixWorkspace_sptr ws); - void holtzer(API::MatrixWorkspace_sptr ws); - void logLog(API::MatrixWorkspace_sptr ws); - void general(API::MatrixWorkspace_sptr ws); + void guinierSpheres(const API::MatrixWorkspace_sptr &ws); + void guinierRods(const API::MatrixWorkspace_sptr &ws); + void guinierSheets(const API::MatrixWorkspace_sptr &ws); + void zimm(const API::MatrixWorkspace_sptr &ws); + void debyeBueche(const API::MatrixWorkspace_sptr &ws); + void kratky(const API::MatrixWorkspace_sptr &ws); + void porod(const API::MatrixWorkspace_sptr &ws); + void holtzer(const API::MatrixWorkspace_sptr &ws); + void logLog(const API::MatrixWorkspace_sptr &ws); + void general(const API::MatrixWorkspace_sptr &ws); }; } // namespace Algorithms diff --git a/Framework/Algorithms/inc/MantidAlgorithms/IdentifyNoisyDetectors.h b/Framework/Algorithms/inc/MantidAlgorithms/IdentifyNoisyDetectors.h index 611e4f3f4de5da9a4ddc3d7ab0a56068081ef9a9..39b39f5bec5857b77cca4e9180cc60090fba3782 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/IdentifyNoisyDetectors.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/IdentifyNoisyDetectors.h @@ -49,8 +49,8 @@ private: void exec() override; ///< Executes the algorithm. void getStdDev(API::Progress &progress, - Mantid::API::MatrixWorkspace_sptr valid, - Mantid::API::MatrixWorkspace_sptr values); + const Mantid::API::MatrixWorkspace_sptr &valid, + const Mantid::API::MatrixWorkspace_sptr &values); }; } // namespace Algorithms } // namespace Mantid diff --git a/Framework/Algorithms/inc/MantidAlgorithms/IntegrateByComponent.h b/Framework/Algorithms/inc/MantidAlgorithms/IntegrateByComponent.h index 637e829e118822c084c902cf457849e4dc489a84..526d705d2a85e6f54f2c6eaee7279fb0759973aa 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/IntegrateByComponent.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/IntegrateByComponent.h @@ -34,11 +34,11 @@ private: void exec() override; /// method to check which spectra should be averaged - std::vector<std::vector<size_t>> makeMap(API::MatrixWorkspace_sptr countsWS, - int parents); + std::vector<std::vector<size_t>> + makeMap(const API::MatrixWorkspace_sptr &countsWS, int parents); /// method to create the map with all spectra std::vector<std::vector<size_t>> - makeInstrumentMap(API::MatrixWorkspace_sptr countsWS); + makeInstrumentMap(const API::MatrixWorkspace_sptr &countsWS); }; } // namespace Algorithms diff --git a/Framework/Algorithms/inc/MantidAlgorithms/Integration.h b/Framework/Algorithms/inc/MantidAlgorithms/Integration.h index b8265a5ed03a858160c447ef827bc9cfa780fc0e..d35d07f4742377db50ebd2cc1a0144d599ee70f0 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/Integration.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/Integration.h @@ -66,7 +66,7 @@ private: void exec() override; API::MatrixWorkspace_sptr - rangeFilterEventWorkspace(API::MatrixWorkspace_sptr workspace, + rangeFilterEventWorkspace(const API::MatrixWorkspace_sptr &workspace, double minRange, double maxRange); /// Get the input workspace diff --git a/Framework/Algorithms/inc/MantidAlgorithms/InterpolatingRebin.h b/Framework/Algorithms/inc/MantidAlgorithms/InterpolatingRebin.h index ea1e72ecefbce15186dfabaf8c8f4bc9c9094ede..fb5c7d267364d0dc7a1bbf475991b6c653c65f03 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/InterpolatingRebin.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/InterpolatingRebin.h @@ -78,9 +78,9 @@ protected: void init() override; void exec() override; - void outputYandEValues(API::MatrixWorkspace_const_sptr inputW, + void outputYandEValues(const API::MatrixWorkspace_const_sptr &inputW, const HistogramData::BinEdges &XValues_new, - API::MatrixWorkspace_sptr outputW); + const API::MatrixWorkspace_sptr &outputW); HistogramData::Histogram cubicInterpolation(const HistogramData::Histogram &oldHistogram, const HistogramData::BinEdges &xNew) const; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/MaskBinsFromTable.h b/Framework/Algorithms/inc/MantidAlgorithms/MaskBinsFromTable.h index 33628ee864ea601da3b294292d60d74f75293891..e5db169d12f3de85b4771f87f5e82c107ef697f3 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/MaskBinsFromTable.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/MaskBinsFromTable.h @@ -43,14 +43,15 @@ private: void exec() override; /// Process input Mask bin TableWorkspace. - void processMaskBinWorkspace(DataObjects::TableWorkspace_sptr masktblws, - API::MatrixWorkspace_sptr dataws); + void + processMaskBinWorkspace(const DataObjects::TableWorkspace_sptr &masktblws, + const API::MatrixWorkspace_sptr &dataws); /// Call MaskBins - void maskBins(API::MatrixWorkspace_sptr dataws); + void maskBins(const API::MatrixWorkspace_sptr &dataws); /// Convert a list of detector IDs list (string) to a list of /// spectra/workspace indexes list - std::string convertToSpectraList(API::MatrixWorkspace_sptr dataws, - std::string detidliststr); + std::string convertToSpectraList(const API::MatrixWorkspace_sptr &dataws, + const std::string &detidliststr); /// Column indexes of XMin, XMax, SpectraList, DetectorIDsList int id_xmin, id_xmax, id_spec, id_dets; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/MaxEnt.h b/Framework/Algorithms/inc/MantidAlgorithms/MaxEnt.h index 3c3e7a6ce5ea9731d32780c23f936455bdb2d58f..970b3a383e905b272c60c64e4c603216901ab70e 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/MaxEnt.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/MaxEnt.h @@ -67,7 +67,7 @@ private: /// Updates the image std::vector<double> updateImage(const std::vector<double> &image, const std::vector<double> &delta, - const std::vector<std::vector<double>> dirs); + const std::vector<std::vector<double>> &dirs); /// Populates the output workspace containing the reconstructed data void populateDataWS(API::MatrixWorkspace_const_sptr &inWS, size_t spec, diff --git a/Framework/Algorithms/inc/MantidAlgorithms/MaxEnt/MaxentTransformMultiFourier.h b/Framework/Algorithms/inc/MantidAlgorithms/MaxEnt/MaxentTransformMultiFourier.h index 1c3d348bab8f011bb842e6b842aee4d967210a81..69d1ac3e34c91faf04fc6d0ab807670faceedb15 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/MaxEnt/MaxentTransformMultiFourier.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/MaxEnt/MaxentTransformMultiFourier.h @@ -36,7 +36,7 @@ public: // Deleted default constructor MaxentTransformMultiFourier() = delete; // Constructor - MaxentTransformMultiFourier(MaxentSpaceComplex_sptr dataSpace, + MaxentTransformMultiFourier(const MaxentSpaceComplex_sptr &dataSpace, MaxentSpace_sptr imageSpace, size_t numSpec); // Transfoms form image space to data space std::vector<double> imageToData(const std::vector<double> &image) override; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/MedianDetectorTest.h b/Framework/Algorithms/inc/MantidAlgorithms/MedianDetectorTest.h index a4bb40b58ab51df96bbcc24faa52a4b5d7b95b51..e1ab2d7c02cbb80b844512d486c71fadca709df0 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/MedianDetectorTest.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/MedianDetectorTest.h @@ -76,14 +76,14 @@ private: /// Calculates the sum of solid angles of detectors for each histogram API::MatrixWorkspace_sptr getSolidAngles(int firstSpec, int lastSpec); /// Mask the outlier values to get a better median value - int maskOutliers(const std::vector<double> medianvec, - API::MatrixWorkspace_sptr countsWS, + int maskOutliers(const std::vector<double> &medianvec, + const API::MatrixWorkspace_sptr &countsWS, std::vector<std::vector<size_t>> indexmap); /// Do the tests and mask those that fail - int doDetectorTests(const API::MatrixWorkspace_sptr countsWS, - const std::vector<double> medianvec, + int doDetectorTests(const API::MatrixWorkspace_sptr &countsWS, + const std::vector<double> &medianvec, std::vector<std::vector<size_t>> indexmap, - API::MatrixWorkspace_sptr maskWS); + const API::MatrixWorkspace_sptr &maskWS); API::MatrixWorkspace_sptr m_inputWS; /// The proportion of the median value below which a detector is considered diff --git a/Framework/Algorithms/inc/MantidAlgorithms/Minus.h b/Framework/Algorithms/inc/MantidAlgorithms/Minus.h index f685724e2e73b9fdad1fa13241705898728b94fc..8dd896560879f1fcc343b22b789b7cbcab5035d7 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/Minus.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/Minus.h @@ -66,8 +66,8 @@ private: std::string checkSizeCompatibility( const API::MatrixWorkspace_const_sptr lhs, const API::MatrixWorkspace_const_sptr rhs) const override; - bool checkUnitCompatibility(const API::MatrixWorkspace_const_sptr lhs, - const API::MatrixWorkspace_const_sptr rhs) const; + bool checkUnitCompatibility(const API::MatrixWorkspace_const_sptr &lhs, + const API::MatrixWorkspace_const_sptr &rhs) const; bool checkCompatibility(const API::MatrixWorkspace_const_sptr lhs, const API::MatrixWorkspace_const_sptr rhs) const override; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/NormaliseByCurrent.h b/Framework/Algorithms/inc/MantidAlgorithms/NormaliseByCurrent.h index 017061aa36962b172a86afbe63dfd2c80214c723..3fbe4eb3e86e867ea17e1153f57257a94effeab3 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/NormaliseByCurrent.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/NormaliseByCurrent.h @@ -55,8 +55,9 @@ private: void init() override; void exec() override; // Extract the charge value from the logs. - double extractCharge(boost::shared_ptr<Mantid::API::MatrixWorkspace> inputWS, - const bool integratePCharge) const; + double + extractCharge(const boost::shared_ptr<Mantid::API::MatrixWorkspace> &inputWS, + const bool integratePCharge) const; }; } // namespace Algorithms diff --git a/Framework/Algorithms/inc/MantidAlgorithms/NormaliseByDetector.h b/Framework/Algorithms/inc/MantidAlgorithms/NormaliseByDetector.h index d7459788ebed7b6650bf07868313376d8b255ea4..6a9a6febdb011c353e63291f9525077eff5cad49 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/NormaliseByDetector.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/NormaliseByDetector.h @@ -48,16 +48,16 @@ private: /// Try to parse a function parameter and extract the correctly typed /// parameter. const Mantid::Geometry::FitParameter - tryParseFunctionParameter(Mantid::Geometry::Parameter_sptr parameter, + tryParseFunctionParameter(const Mantid::Geometry::Parameter_sptr ¶meter, const Geometry::IDetector &det); /// Block to process histograms. - boost::shared_ptr<Mantid::API::MatrixWorkspace> - processHistograms(boost::shared_ptr<Mantid::API::MatrixWorkspace> inWS); + boost::shared_ptr<Mantid::API::MatrixWorkspace> processHistograms( + const boost::shared_ptr<Mantid::API::MatrixWorkspace> &inWS); /// Process indivdual histogram. void processHistogram( size_t wsIndex, - boost::shared_ptr<const Mantid::API::MatrixWorkspace> inWS, - boost::shared_ptr<Mantid::API::MatrixWorkspace> denominatorWS, + const boost::shared_ptr<const Mantid::API::MatrixWorkspace> &inWS, + const boost::shared_ptr<Mantid::API::MatrixWorkspace> &denominatorWS, Mantid::API::Progress &prog); void init() override; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/NormaliseToMonitor.h b/Framework/Algorithms/inc/MantidAlgorithms/NormaliseToMonitor.h index ca162015c75cf861ce6e5732ada82ab71e171c73..c36d200e4f4e137d9f5eee9e94a2b716b06d4521 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/NormaliseToMonitor.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/NormaliseToMonitor.h @@ -166,7 +166,7 @@ private: mutable bool is_enabled; // auxiliary function to obtain list of monitor's ID-s (allowed_values) from a // workspace; - bool monitorIdReader(API::MatrixWorkspace_const_sptr inputWS) const; + bool monitorIdReader(const API::MatrixWorkspace_const_sptr &inputWS) const; }; } // namespace Algorithms diff --git a/Framework/Algorithms/inc/MantidAlgorithms/PDCalibration.h b/Framework/Algorithms/inc/MantidAlgorithms/PDCalibration.h index 5cfd7e9ef811464c3a55817c3add6ed448a4f41e..aa46946a5183c933090ac4b8875ef41a146e7a8f 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/PDCalibration.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/PDCalibration.h @@ -40,7 +40,7 @@ private: void exec() override; API::MatrixWorkspace_sptr loadAndBin(); API::MatrixWorkspace_sptr rebin(API::MatrixWorkspace_sptr wksp); - API::MatrixWorkspace_sptr load(const std::string filename); + API::MatrixWorkspace_sptr load(const std::string &filename); void createCalTableFromExisting(); void createCalTableNew(); void createInformationWorkspaces(); @@ -59,8 +59,9 @@ private: /// NEW: convert peak positions in dSpacing to peak centers workspace std::pair<API::MatrixWorkspace_sptr, API::MatrixWorkspace_sptr> - createTOFPeakCenterFitWindowWorkspaces(API::MatrixWorkspace_sptr dataws, - const double peakWindowMaxInDSpacing); + createTOFPeakCenterFitWindowWorkspaces( + const API::MatrixWorkspace_sptr &dataws, + const double peakWindowMaxInDSpacing); API::ITableWorkspace_sptr sortTableWorkspace(API::ITableWorkspace_sptr &table); diff --git a/Framework/Algorithms/inc/MantidAlgorithms/PaddingAndApodization.h b/Framework/Algorithms/inc/MantidAlgorithms/PaddingAndApodization.h index a047a942567a2e67895d05150804a81bfbf3cb64..748cb88668927fa071f43fadc974f6d688b24a80 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/PaddingAndApodization.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/PaddingAndApodization.h @@ -53,7 +53,7 @@ private: void init() override; void exec() override; using fptr = double (*)(const double, const double); - fptr getApodizationFunction(const std::string method); + fptr getApodizationFunction(const std::string &method); HistogramData::Histogram applyApodizationFunction(const HistogramData::Histogram &histogram, const double decayConstant, fptr function); diff --git a/Framework/Algorithms/inc/MantidAlgorithms/ParallaxCorrection.h b/Framework/Algorithms/inc/MantidAlgorithms/ParallaxCorrection.h index 6eab498ba75fe8dd80d32b4eca443a4fb38dbeec..d3d2bf817b965adad15b72e899cff4309ef3ebda 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/ParallaxCorrection.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/ParallaxCorrection.h @@ -25,8 +25,9 @@ public: private: void init() override; void exec() override; - void performCorrection(API::MatrixWorkspace_sptr, const std::vector<size_t> &, - const std::string &, const std::string &); + void performCorrection(const API::MatrixWorkspace_sptr &, + const std::vector<size_t> &, const std::string &, + const std::string &); }; } // namespace Algorithms diff --git a/Framework/Algorithms/inc/MantidAlgorithms/Plus.h b/Framework/Algorithms/inc/MantidAlgorithms/Plus.h index 3f850d029a9d0d3c6f6d768e517cf89764496b4d..c6c7a6d1b4f9f9a4477a913d24f6a96fa26b1f54 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/Plus.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/Plus.h @@ -75,8 +75,8 @@ private: API::Run &ans) const override; // Overridden event-specific operation - bool checkUnitCompatibility(const API::MatrixWorkspace_const_sptr lhs, - const API::MatrixWorkspace_const_sptr rhs) const; + bool checkUnitCompatibility(const API::MatrixWorkspace_const_sptr &lhs, + const API::MatrixWorkspace_const_sptr &rhs) const; }; } // namespace Algorithms diff --git a/Framework/Algorithms/inc/MantidAlgorithms/PolarizationCorrectionFredrikze.h b/Framework/Algorithms/inc/MantidAlgorithms/PolarizationCorrectionFredrikze.h index 92674758de7406046ad71f0c78a64074a65def45..e6586dbb8051a84ccd2389ca4279237d92925d8b 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/PolarizationCorrectionFredrikze.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/PolarizationCorrectionFredrikze.h @@ -41,9 +41,9 @@ private: boost::shared_ptr<Mantid::API::MatrixWorkspace> getEfficiencyWorkspace(const std::string &label); boost::shared_ptr<Mantid::API::WorkspaceGroup> - execPA(boost::shared_ptr<Mantid::API::WorkspaceGroup> inWS); + execPA(const boost::shared_ptr<Mantid::API::WorkspaceGroup> &inWS); boost::shared_ptr<Mantid::API::WorkspaceGroup> - execPNR(boost::shared_ptr<Mantid::API::WorkspaceGroup> inWS); + execPNR(const boost::shared_ptr<Mantid::API::WorkspaceGroup> &inWS); boost::shared_ptr<Mantid::API::MatrixWorkspace> add(boost::shared_ptr<Mantid::API::MatrixWorkspace> &lhsWS, const double &rhs); diff --git a/Framework/Algorithms/inc/MantidAlgorithms/PolarizationEfficiencyCor.h b/Framework/Algorithms/inc/MantidAlgorithms/PolarizationEfficiencyCor.h index aa9679f544639a8466595cb737fd1bdf8e172278..46d3da8102a5b0fdbca9f8ff6cbe785ffcc51ab9 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/PolarizationEfficiencyCor.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/PolarizationEfficiencyCor.h @@ -45,8 +45,9 @@ private: API::MatrixWorkspace const &inWS) const; API::MatrixWorkspace_sptr convertToHistogram(API::MatrixWorkspace_sptr efficiencies); - API::MatrixWorkspace_sptr interpolate(API::MatrixWorkspace_sptr efficiencies, - API::MatrixWorkspace_sptr inWS); + API::MatrixWorkspace_sptr + interpolate(const API::MatrixWorkspace_sptr &efficiencies, + const API::MatrixWorkspace_sptr &inWS); }; } // namespace Algorithms diff --git a/Framework/Algorithms/inc/MantidAlgorithms/Q1D2.h b/Framework/Algorithms/inc/MantidAlgorithms/Q1D2.h index 386d8278273f295c96ca8802944ead770d3a69c3..a930255c0c5f7f5daf548b1c637190a6438bdaa6 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/Q1D2.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/Q1D2.h @@ -63,13 +63,13 @@ private: // these are the steps that are run on each individual spectrum void calculateNormalization(const size_t wavStart, const size_t wsIndex, - API::MatrixWorkspace_const_sptr pixelAdj, - API::MatrixWorkspace_const_sptr wavePixelAdj, + const API::MatrixWorkspace_const_sptr &pixelAdj, + const API::MatrixWorkspace_const_sptr &wavePixelAdj, double const *const binNorms, double const *const binNormEs, HistogramData::HistogramY::iterator norm, HistogramData::HistogramY::iterator normETo2) const; - void pixelWeight(API::MatrixWorkspace_const_sptr pixelAdj, + void pixelWeight(const API::MatrixWorkspace_const_sptr &pixelAdj, const size_t wsIndex, double &weight, double &error) const; void addWaveAdj(const double *c, const double *Dc, HistogramData::HistogramY::iterator bInOut, diff --git a/Framework/Algorithms/inc/MantidAlgorithms/Q1DWeighted.h b/Framework/Algorithms/inc/MantidAlgorithms/Q1DWeighted.h index 7404e96a708c556b9920cc92904ba3cafedbebed..a542b5ee4fc74137f0c3ae7ad33764d1bc82ca4a 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/Q1DWeighted.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/Q1DWeighted.h @@ -70,12 +70,12 @@ public: private: /// Create an output workspace API::MatrixWorkspace_sptr - createOutputWorkspace(API::MatrixWorkspace_const_sptr, const size_t, + createOutputWorkspace(const API::MatrixWorkspace_const_sptr &, const size_t, const std::vector<double> &); - void bootstrap(API::MatrixWorkspace_const_sptr); - void calculate(API::MatrixWorkspace_const_sptr); - void finalize(API::MatrixWorkspace_const_sptr); + void bootstrap(const API::MatrixWorkspace_const_sptr &); + void calculate(const API::MatrixWorkspace_const_sptr &); + void finalize(const API::MatrixWorkspace_const_sptr &); std::vector<std::vector<std::vector<double>>> m_intensities; std::vector<std::vector<std::vector<double>>> m_errors; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/Qhelper.h b/Framework/Algorithms/inc/MantidAlgorithms/Qhelper.h index 53ade307e5cd607081c2e0d22875e80f7da7fbfe..30d9028be9c94cffcae53adc3909abe6684d1f43 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/Qhelper.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/Qhelper.h @@ -19,22 +19,23 @@ namespace Algorithms { */ class Qhelper { public: - void examineInput(API::MatrixWorkspace_const_sptr dataWS, - API::MatrixWorkspace_const_sptr binAdj, - API::MatrixWorkspace_const_sptr detectAdj, - API::MatrixWorkspace_const_sptr qResolution); + void examineInput(const API::MatrixWorkspace_const_sptr &dataWS, + const API::MatrixWorkspace_const_sptr &binAdj, + const API::MatrixWorkspace_const_sptr &detectAdj, + const API::MatrixWorkspace_const_sptr &qResolution); - void examineInput(API::MatrixWorkspace_const_sptr dataWS, - API::MatrixWorkspace_const_sptr binAdj, - API::MatrixWorkspace_const_sptr detectAdj); + void examineInput(const API::MatrixWorkspace_const_sptr &dataWS, + const API::MatrixWorkspace_const_sptr &binAdj, + const API::MatrixWorkspace_const_sptr &detectAdj); - size_t waveLengthCutOff(API::MatrixWorkspace_const_sptr dataWS, + size_t waveLengthCutOff(const API::MatrixWorkspace_const_sptr &dataWS, const API::SpectrumInfo &spectrumInfo, const double RCut, const double WCut, const size_t wsInd) const; - void outputParts(API::Algorithm *alg, API::MatrixWorkspace_sptr sumOfCounts, - API::MatrixWorkspace_sptr sumOfNormFactors); + void outputParts(API::Algorithm *alg, + const API::MatrixWorkspace_sptr &sumOfCounts, + const API::MatrixWorkspace_sptr &sumOfNormFactors); private: /// the experimental workspace with counts across the detector diff --git a/Framework/Algorithms/inc/MantidAlgorithms/Qxy.h b/Framework/Algorithms/inc/MantidAlgorithms/Qxy.h index f290e9fe824a963e8a292f94e866ea830072e589..49b1cef9c863c4f1c37343cc4536fcfa0292701e 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/Qxy.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/Qxy.h @@ -55,7 +55,7 @@ private: std::vector<double> logBinning(double min, double max, int num); API::MatrixWorkspace_sptr - setUpOutputWorkspace(API::MatrixWorkspace_const_sptr inputWorkspace); + setUpOutputWorkspace(const API::MatrixWorkspace_const_sptr &inputWorkspace); double getQminFromWs(const API::MatrixWorkspace &inputWorkspace); }; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/RadiusSum.h b/Framework/Algorithms/inc/MantidAlgorithms/RadiusSum.h index 0e216e6066955300b0e96d3c95e3d1f8d47d7bdd..1a10f80ca0ec3e26a07770a0962f7be7f2e01272 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/RadiusSum.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/RadiusSum.h @@ -35,13 +35,14 @@ public: } const std::string category() const override; - static bool inputWorkspaceHasInstrumentAssociated(API::MatrixWorkspace_sptr); + static bool + inputWorkspaceHasInstrumentAssociated(const API::MatrixWorkspace_sptr &); static std::vector<double> - getBoundariesOfNumericImage(API::MatrixWorkspace_sptr); + getBoundariesOfNumericImage(const API::MatrixWorkspace_sptr &); static std::vector<double> - getBoundariesOfInstrument(API::MatrixWorkspace_sptr); + getBoundariesOfInstrument(const API::MatrixWorkspace_sptr &); static void centerIsInsideLimits(const std::vector<double> ¢re, const std::vector<double> &boundaries); @@ -71,8 +72,8 @@ private: API::MatrixWorkspace_sptr inputWS; double min_radius = 0.0, max_radius = 0.0; - double getMinBinSizeForInstrument(API::MatrixWorkspace_sptr); - double getMinBinSizeForNumericImage(API::MatrixWorkspace_sptr); + double getMinBinSizeForInstrument(const API::MatrixWorkspace_sptr &); + double getMinBinSizeForNumericImage(const API::MatrixWorkspace_sptr &); /** Return the bin position for a given distance * From the input, it is defined the limits of distances as: diff --git a/Framework/Algorithms/inc/MantidAlgorithms/Rebin.h b/Framework/Algorithms/inc/MantidAlgorithms/Rebin.h index 3c2e64c67dc51e552672a943020d0a0c04104426..d46fda033bb8af861c4b9d98804629cf29a22b9e 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/Rebin.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/Rebin.h @@ -76,8 +76,8 @@ protected: void init() override; void exec() override; - void propagateMasks(API::MatrixWorkspace_const_sptr inputWS, - API::MatrixWorkspace_sptr outputWS, int hist); + void propagateMasks(const API::MatrixWorkspace_const_sptr &inputWS, + const API::MatrixWorkspace_sptr &outputWS, int hist); }; } // namespace Algorithms diff --git a/Framework/Algorithms/inc/MantidAlgorithms/ReflectometryBackgroundSubtraction.h b/Framework/Algorithms/inc/MantidAlgorithms/ReflectometryBackgroundSubtraction.h index 78d3cef28277803663ef5a14ef6717e970daab6f..c24eb84ccb91e0b76d719ac95bec1a4240d6a300 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/ReflectometryBackgroundSubtraction.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/ReflectometryBackgroundSubtraction.h @@ -27,13 +27,13 @@ public: private: void - calculateAverageSpectrumBackground(API::MatrixWorkspace_sptr inputWS, + calculateAverageSpectrumBackground(const API::MatrixWorkspace_sptr &inputWS, const std::vector<specnum_t> &spectraList); void calculatePolynomialBackground(API::MatrixWorkspace_sptr inputWS, const std::vector<double> &spectrumRanges); std::vector<double> findSpectrumRanges(const std::vector<specnum_t> &spectraList); - void calculatePixelBackground(API::MatrixWorkspace_sptr inputWS, + void calculatePixelBackground(const API::MatrixWorkspace_sptr &inputWS, const std::vector<double> &indexRanges); /** Overridden Algorithm methods **/ diff --git a/Framework/Algorithms/inc/MantidAlgorithms/ReflectometryBeamStatistics.h b/Framework/Algorithms/inc/MantidAlgorithms/ReflectometryBeamStatistics.h index 459e89e6862017df4caa023fa088f1f993a2fe18..9f995f2f39e101f43f4f4188f789e1bb9fdde718 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/ReflectometryBeamStatistics.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/ReflectometryBeamStatistics.h @@ -26,9 +26,9 @@ public: const static std::string SAMPLE_WAVINESS; const static std::string SECOND_SLIT_ANGULAR_SPREAD; }; - static double slitSeparation(Geometry::Instrument_const_sptr instrument, - const std::string &slit1Name, - const std::string &slit2Name); + static double + slitSeparation(const Geometry::Instrument_const_sptr &instrument, + const std::string &slit1Name, const std::string &slit2Name); const std::string name() const override; int version() const override; const std::string category() const override; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/ReflectometryReductionOne2.h b/Framework/Algorithms/inc/MantidAlgorithms/ReflectometryReductionOne2.h index 17cc0d6f69a41441d2768f9b289d1f72cc6f2b3c..4c720c38d542fffdd6f4f3662e1164bc79462cbf 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/ReflectometryReductionOne2.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/ReflectometryReductionOne2.h @@ -66,30 +66,30 @@ private: directBeamCorrection(Mantid::API::MatrixWorkspace_sptr detectorWS); // Performs transmission or algorithm correction Mantid::API::MatrixWorkspace_sptr - transOrAlgCorrection(Mantid::API::MatrixWorkspace_sptr detectorWS, + transOrAlgCorrection(const Mantid::API::MatrixWorkspace_sptr &detectorWS, const bool detectorWSReduced); // Performs background subtraction Mantid::API::MatrixWorkspace_sptr backgroundSubtraction(Mantid::API::MatrixWorkspace_sptr detectorWS); // Performs transmission corrections Mantid::API::MatrixWorkspace_sptr - transmissionCorrection(Mantid::API::MatrixWorkspace_sptr detectorWS, + transmissionCorrection(const Mantid::API::MatrixWorkspace_sptr &detectorWS, const bool detectorWSReduced); // Performs transmission corrections using alternative correction algorithms Mantid::API::MatrixWorkspace_sptr - algorithmicCorrection(Mantid::API::MatrixWorkspace_sptr detectorWS); + algorithmicCorrection(const Mantid::API::MatrixWorkspace_sptr &detectorWS); // Performs monitor corrections Mantid::API::MatrixWorkspace_sptr monitorCorrection(Mantid::API::MatrixWorkspace_sptr detectorWS); // convert to momentum transfer Mantid::API::MatrixWorkspace_sptr - convertToQ(Mantid::API::MatrixWorkspace_sptr inputWS); + convertToQ(const Mantid::API::MatrixWorkspace_sptr &inputWS); // Get the twoTheta width of a given detector double getDetectorTwoThetaRange(const size_t spectrumIdx); // Utility function to create name for diagnostic workspaces std::string createDebugWorkspaceName(const std::string &inputName); // Utility function to output a diagnostic workspace to the ADS - void outputDebugWorkspace(API::MatrixWorkspace_sptr ws, + void outputDebugWorkspace(const API::MatrixWorkspace_sptr &ws, const std::string &wsName, const std::string &wsSuffix, const bool debug, int &step); @@ -97,7 +97,7 @@ private: Mantid::API::MatrixWorkspace_sptr makeIvsLam(); // Do the reduction by summation in Q Mantid::API::MatrixWorkspace_sptr - sumInQ(API::MatrixWorkspace_sptr detectorWS); + sumInQ(const API::MatrixWorkspace_sptr &detectorWS); // Do the summation in Q for a single input value void sumInQProcessValue(const int inputIdx, const double twoTheta, const double bTwoTheta, @@ -106,23 +106,23 @@ private: const HistogramData::HistogramE &inputE, const std::vector<size_t> &detectors, const size_t outSpecIdx, - API::MatrixWorkspace_sptr IvsLam, + const API::MatrixWorkspace_sptr &IvsLam, std::vector<double> &outputE); // Share counts to a projected value for summation in Q void sumInQShareCounts(const double inputCounts, const double inputErr, const double bLambda, const double lambdaMin, const double lambdaMax, const size_t outSpecIdx, - API::MatrixWorkspace_sptr IvsLam, + const API::MatrixWorkspace_sptr &IvsLam, std::vector<double> &outputE); - void findWavelengthMinMax(API::MatrixWorkspace_sptr inputWS); + void findWavelengthMinMax(const API::MatrixWorkspace_sptr &inputWS); // Construct the output workspace - void findIvsLamRange(API::MatrixWorkspace_sptr detectorWS, + void findIvsLamRange(const API::MatrixWorkspace_sptr &detectorWS, const std::vector<size_t> &detectors, const double lambdaMin, const double lambdaMax, double &projectedMin, double &projectedMax); // Construct the output workspace Mantid::API::MatrixWorkspace_sptr - constructIvsLamWS(API::MatrixWorkspace_sptr detectorWS); + constructIvsLamWS(const API::MatrixWorkspace_sptr &detectorWS); // Whether summation should be done in Q or the default lambda bool summingInQ(); // Get projected coordinates onto twoThetaR @@ -132,8 +132,8 @@ private: double &lambdaTop, double &lambdaBot, const bool outerCorners = true); // Check whether two spectrum maps match - void verifySpectrumMaps(API::MatrixWorkspace_const_sptr ws1, - API::MatrixWorkspace_const_sptr ws2); + void verifySpectrumMaps(const API::MatrixWorkspace_const_sptr &ws1, + const API::MatrixWorkspace_const_sptr &ws2); // Find and cache constants void findDetectorGroups(); @@ -149,10 +149,10 @@ private: double wavelengthMax() { return m_wavelengthMax; }; size_t findIvsLamRangeMinDetector(const std::vector<size_t> &detectors); size_t findIvsLamRangeMaxDetector(const std::vector<size_t> &detectors); - double findIvsLamRangeMin(Mantid::API::MatrixWorkspace_sptr detectorWS, + double findIvsLamRangeMin(const Mantid::API::MatrixWorkspace_sptr &detectorWS, const std::vector<size_t> &detectors, const double lambda); - double findIvsLamRangeMax(Mantid::API::MatrixWorkspace_sptr detectorWS, + double findIvsLamRangeMax(const Mantid::API::MatrixWorkspace_sptr &detectorWS, const std::vector<size_t> &detectors, const double lambda); diff --git a/Framework/Algorithms/inc/MantidAlgorithms/ReflectometryReductionOneAuto2.h b/Framework/Algorithms/inc/MantidAlgorithms/ReflectometryReductionOneAuto2.h index 57a153afa8a3e379759d771474e83276f4c27ec4..e769ba96ff556e4bc69d5498504155aa40b1fee2 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/ReflectometryReductionOneAuto2.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/ReflectometryReductionOneAuto2.h @@ -47,7 +47,7 @@ private: class RebinParams { public: RebinParams(const double qMin, const bool qMinIsDefault, const double qMax, - const bool qMaxIsDefault, const boost::optional<double> qStep) + const bool qMaxIsDefault, const boost::optional<double> &qStep) : m_qMin(qMin), m_qMinIsDefault(qMinIsDefault), m_qMax(qMax), m_qMaxIsDefault(qMaxIsDefault), m_qStep(qStep){}; @@ -72,33 +72,34 @@ private: void init() override; void exec() override; std::string - getRunNumberForWorkspaceGroup(WorkspaceGroup_const_sptr workspace); + getRunNumberForWorkspaceGroup(const WorkspaceGroup_const_sptr &workspace); WorkspaceNames getOutputWorkspaceNames(); void setDefaultOutputWorkspaceNames(); /// Get the name of the detectors of interest based on processing instructions std::vector<std::string> - getDetectorNames(Mantid::API::MatrixWorkspace_sptr inputWS); + getDetectorNames(const Mantid::API::MatrixWorkspace_sptr &inputWS); /// Correct detector positions vertically Mantid::API::MatrixWorkspace_sptr correctDetectorPositions(Mantid::API::MatrixWorkspace_sptr inputWS, const double twoTheta); /// Calculate theta - double calculateTheta(Mantid::API::MatrixWorkspace_sptr inputWS); + double calculateTheta(const Mantid::API::MatrixWorkspace_sptr &inputWS); /// Find cropping and binning parameters - RebinParams getRebinParams(MatrixWorkspace_sptr inputWS, const double theta); - boost::optional<double> getQStep(MatrixWorkspace_sptr inputWS, + RebinParams getRebinParams(const MatrixWorkspace_sptr &inputWS, + const double theta); + boost::optional<double> getQStep(const MatrixWorkspace_sptr &inputWS, const double theta); /// Rebin and scale a workspace in Q Mantid::API::MatrixWorkspace_sptr - rebinAndScale(Mantid::API::MatrixWorkspace_sptr inputWS, + rebinAndScale(const Mantid::API::MatrixWorkspace_sptr &inputWS, RebinParams const ¶ms); /// Crop a workspace in Q - MatrixWorkspace_sptr cropQ(MatrixWorkspace_sptr inputWS, + MatrixWorkspace_sptr cropQ(const MatrixWorkspace_sptr &inputWS, RebinParams const ¶ms); /// Populate algorithmic correction properties void populateAlgorithmicCorrectionProperties( - Mantid::API::IAlgorithm_sptr alg, - Mantid::Geometry::Instrument_const_sptr instrument); + const Mantid::API::IAlgorithm_sptr &alg, + const Mantid::Geometry::Instrument_const_sptr &instrument); /// Get a polarization efficiencies workspace. std::tuple<API::MatrixWorkspace_sptr, std::string, std::string> getPolarizationEfficiencies(); diff --git a/Framework/Algorithms/inc/MantidAlgorithms/ReflectometryReductionOneAuto3.h b/Framework/Algorithms/inc/MantidAlgorithms/ReflectometryReductionOneAuto3.h index 61b931ff3751ea0ce503196e59b3cbb535b6658d..7c0193309122668aab971e68b207638c5c5bd2f3 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/ReflectometryReductionOneAuto3.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/ReflectometryReductionOneAuto3.h @@ -58,35 +58,37 @@ private: void init() override; void exec() override; std::string - getRunNumberForWorkspaceGroup(WorkspaceGroup_const_sptr workspace); + getRunNumberForWorkspaceGroup(const WorkspaceGroup_const_sptr &workspace); WorkspaceNames getOutputWorkspaceNames(); void setDefaultOutputWorkspaceNames(); /// Get the name of the detectors of interest based on processing instructions std::vector<std::string> - getDetectorNames(Mantid::API::MatrixWorkspace_sptr inputWS); + getDetectorNames(const Mantid::API::MatrixWorkspace_sptr &inputWS); /// Correct detector positions vertically Mantid::API::MatrixWorkspace_sptr correctDetectorPositions(Mantid::API::MatrixWorkspace_sptr inputWS, const double twoTheta); /// Calculate theta - double calculateTheta(Mantid::API::MatrixWorkspace_sptr inputWS); + double calculateTheta(const Mantid::API::MatrixWorkspace_sptr &inputWS); /// Find cropping and binning parameters - RebinParams getRebinParams(MatrixWorkspace_sptr inputWS, const double theta); - boost::optional<double> getQStep(MatrixWorkspace_sptr inputWS, + RebinParams getRebinParams(const MatrixWorkspace_sptr &inputWS, + const double theta); + boost::optional<double> getQStep(const MatrixWorkspace_sptr &inputWS, const double theta); // Optionally scale a workspace Mantid::API::MatrixWorkspace_sptr scale(Mantid::API::MatrixWorkspace_sptr inputWS); /// Rebin a workspace in Q Mantid::API::MatrixWorkspace_sptr - rebin(Mantid::API::MatrixWorkspace_sptr inputWS, const RebinParams ¶ms); + rebin(const Mantid::API::MatrixWorkspace_sptr &inputWS, + const RebinParams ¶ms); /// Optionally crop a workspace in Q MatrixWorkspace_sptr cropQ(MatrixWorkspace_sptr inputWS, const RebinParams ¶ms); /// Populate algorithmic correction properties void populateAlgorithmicCorrectionProperties( - Mantid::API::IAlgorithm_sptr alg, - Mantid::Geometry::Instrument_const_sptr instrument); + const Mantid::API::IAlgorithm_sptr &alg, + const Mantid::Geometry::Instrument_const_sptr &instrument); /// Get a polarization efficiencies workspace. std::tuple<API::MatrixWorkspace_sptr, std::string, std::string> getPolarizationEfficiencies(); diff --git a/Framework/Algorithms/inc/MantidAlgorithms/ReflectometryWorkflowBase.h b/Framework/Algorithms/inc/MantidAlgorithms/ReflectometryWorkflowBase.h index 81d13a755d15f347d9890f7dd3edbbced3ee6515..f79bd7b6713a48af8941276f98d1fb4e83e4fb1d 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/ReflectometryWorkflowBase.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/ReflectometryWorkflowBase.h @@ -44,9 +44,9 @@ public: /// Convert the input workspace to wavelength, splitting according to the /// properties provided. DetectorMonitorWorkspacePair - toLam(Mantid::API::MatrixWorkspace_sptr toConvert, + toLam(const Mantid::API::MatrixWorkspace_sptr &toConvert, const std::string &processingCommands, - const OptionalInteger monitorIndex, const MinMax &wavelengthMinMax, + const OptionalInteger &monitorIndex, const MinMax &wavelengthMinMax, const OptionalMinMax &backgroundMinMax); /// Convert the detector spectrum of the input workspace to wavelength @@ -70,12 +70,11 @@ protected: /// Get the min/max property values MinMax getMinMax(const std::string &minProperty, const std::string &maxProperty) const; - OptionalMinMax getOptionalMinMax(Mantid::API::Algorithm *const alg, - const std::string &minProperty, - const std::string &maxProperty, - Mantid::Geometry::Instrument_const_sptr inst, - std::string minIdfName, - std::string maxIdfName) const; + OptionalMinMax getOptionalMinMax( + Mantid::API::Algorithm *const alg, const std::string &minProperty, + const std::string &maxProperty, + const Mantid::Geometry::Instrument_const_sptr &inst, + const std::string &minIdfName, const std::string &maxIdfName) const; /// Get the transmission correction properties void getTransmissionRunInfo( OptionalMatrixWorkspace_sptr &firstTransmissionRun, @@ -102,7 +101,7 @@ private: /// Convert the monitor parts of the input workspace to wavelength API::MatrixWorkspace_sptr toLamMonitor(const API::MatrixWorkspace_sptr &toConvert, - const OptionalInteger monitorIndex, + const OptionalInteger &monitorIndex, const OptionalMinMax &backgroundMinMax); /// Make a unity workspace diff --git a/Framework/Algorithms/inc/MantidAlgorithms/ReflectometryWorkflowBase2.h b/Framework/Algorithms/inc/MantidAlgorithms/ReflectometryWorkflowBase2.h index 9962e1cb063bbff0ed7c498595b8b20172e31371..6b28e816c9d2eef0bc15a76b301c471e22de9571 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/ReflectometryWorkflowBase2.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/ReflectometryWorkflowBase2.h @@ -54,10 +54,10 @@ protected: std::map<std::string, std::string> validateWavelengthRanges() const; /// Convert a workspace from TOF to wavelength Mantid::API::MatrixWorkspace_sptr - convertToWavelength(Mantid::API::MatrixWorkspace_sptr inputWS); + convertToWavelength(const Mantid::API::MatrixWorkspace_sptr &inputWS); /// Crop a workspace in wavelength Mantid::API::MatrixWorkspace_sptr - cropWavelength(Mantid::API::MatrixWorkspace_sptr inputWS, + cropWavelength(const Mantid::API::MatrixWorkspace_sptr &inputWS, const bool useArgs = false, const double argMin = 0.0, const double argMax = 0.0); // Create a detector workspace from input workspace in wavelength @@ -66,43 +66,44 @@ protected: const bool convert = true, const bool sum = true); // Create a monitor workspace from input workspace in wavelength Mantid::API::MatrixWorkspace_sptr - makeMonitorWS(Mantid::API::MatrixWorkspace_sptr inputWS, + makeMonitorWS(const Mantid::API::MatrixWorkspace_sptr &inputWS, bool integratedMonitors); // Rebin detectors to monitors Mantid::API::MatrixWorkspace_sptr - rebinDetectorsToMonitors(Mantid::API::MatrixWorkspace_sptr detectorWS, - Mantid::API::MatrixWorkspace_sptr monitorWS); + rebinDetectorsToMonitors(const Mantid::API::MatrixWorkspace_sptr &detectorWS, + const Mantid::API::MatrixWorkspace_sptr &monitorWS); // Read monitor properties from instrument - void - populateMonitorProperties(Mantid::API::IAlgorithm_sptr alg, - Mantid::Geometry::Instrument_const_sptr instrument); + void populateMonitorProperties( + const Mantid::API::IAlgorithm_sptr &alg, + const Mantid::Geometry::Instrument_const_sptr &instrument); /// Populate processing instructions - std::string - findProcessingInstructions(Mantid::Geometry::Instrument_const_sptr instrument, - Mantid::API::MatrixWorkspace_sptr inputWS) const; + std::string findProcessingInstructions( + const Mantid::Geometry::Instrument_const_sptr &instrument, + const Mantid::API::MatrixWorkspace_sptr &inputWS) const; /// Populate transmission properties - bool populateTransmissionProperties(Mantid::API::IAlgorithm_sptr alg) const; + bool + populateTransmissionProperties(const Mantid::API::IAlgorithm_sptr &alg) const; /// Find theta from a named log value - double getThetaFromLogs(Mantid::API::MatrixWorkspace_sptr inputWs, + double getThetaFromLogs(const Mantid::API::MatrixWorkspace_sptr &inputWs, const std::string &logName); // Retrieve the run number from the logs of the input workspace. std::string getRunNumber(Mantid::API::MatrixWorkspace const &ws) const; - void convertProcessingInstructions(Instrument_const_sptr instrument, - MatrixWorkspace_sptr inputWS); - void convertProcessingInstructions(MatrixWorkspace_sptr inputWS); + void convertProcessingInstructions(const Instrument_const_sptr &instrument, + const MatrixWorkspace_sptr &inputWS); + void convertProcessingInstructions(const MatrixWorkspace_sptr &inputWS); std::string m_processingInstructionsWorkspaceIndex; std::string m_processingInstructions; protected: - std::string - convertToSpectrumNumber(const std::string &workspaceIndex, - Mantid::API::MatrixWorkspace_const_sptr ws) const; + std::string convertToSpectrumNumber( + const std::string &workspaceIndex, + const Mantid::API::MatrixWorkspace_const_sptr &ws) const; std::string convertProcessingInstructionsToSpectrumNumbers( const std::string &instructions, - Mantid::API::MatrixWorkspace_const_sptr ws) const; + const Mantid::API::MatrixWorkspace_const_sptr &ws) const; - void setWorkspacePropertyFromChild(Algorithm_sptr alg, + void setWorkspacePropertyFromChild(const Algorithm_sptr &alg, std::string const &propertyName); }; } // namespace Algorithms diff --git a/Framework/Algorithms/inc/MantidAlgorithms/ResetNegatives.h b/Framework/Algorithms/inc/MantidAlgorithms/ResetNegatives.h index c07cf9fd8902e86dbf103d80a6c45e1956b24f6e..f39ddda72208170fb41dcb6aaf871cb725fb3632 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/ResetNegatives.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/ResetNegatives.h @@ -30,11 +30,12 @@ public: private: void init() override; void exec() override; - void pushMinimum(API::MatrixWorkspace_const_sptr minWS, - API::MatrixWorkspace_sptr wksp, API::Progress &prog); - void changeNegatives(API::MatrixWorkspace_const_sptr minWS, + void pushMinimum(const API::MatrixWorkspace_const_sptr &minWS, + const API::MatrixWorkspace_sptr &wksp, API::Progress &prog); + void changeNegatives(const API::MatrixWorkspace_const_sptr &minWS, const double spectrumNegativeValues, - API::MatrixWorkspace_sptr wksp, API::Progress &prog); + const API::MatrixWorkspace_sptr &wksp, + API::Progress &prog); }; } // namespace Algorithms diff --git a/Framework/Algorithms/inc/MantidAlgorithms/RingProfile.h b/Framework/Algorithms/inc/MantidAlgorithms/RingProfile.h index b22d34fdca63943cc502059d1337626c5b1930c0..40d04682f612dee3e4636f4a9330105366e72938 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/RingProfile.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/RingProfile.h @@ -47,17 +47,18 @@ private: /// get the bin position for the given angle int fromAngleToBin(double angle, bool degree = true); /// validate the inputs of the algorithm for instrument based workspace - void checkInputsForSpectraWorkspace(const API::MatrixWorkspace_sptr); + void checkInputsForSpectraWorkspace(const API::MatrixWorkspace_sptr &); /// validate the inputs of the algorithm for 2d matrix based instrument - void checkInputsForNumericWorkspace(const API::MatrixWorkspace_sptr); + void checkInputsForNumericWorkspace(const API::MatrixWorkspace_sptr &); /// process ring profile for instrument based workspace - void processInstrumentRingProfile(const API::MatrixWorkspace_sptr inputWS, + void processInstrumentRingProfile(const API::MatrixWorkspace_sptr &inputWS, std::vector<double> &output_bins); /// process ring profile for image based workspace - void processNumericImageRingProfile(const API::MatrixWorkspace_sptr inputWS, + void processNumericImageRingProfile(const API::MatrixWorkspace_sptr &inputWS, std::vector<double> &output_bins); /// identify the bin position for the given pixel in the image based workspace - void getBinForPixel(const API::MatrixWorkspace_sptr, int, std::vector<int> &); + void getBinForPixel(const API::MatrixWorkspace_sptr &, int, + std::vector<int> &); //// identify the bin position for the pixel related to the given detector int getBinForPixel(const Kernel::V3D &position); /// copy of the minRadius input diff --git a/Framework/Algorithms/inc/MantidAlgorithms/RunCombinationHelpers/RunCombinationHelper.h b/Framework/Algorithms/inc/MantidAlgorithms/RunCombinationHelpers/RunCombinationHelper.h index f4ba79010032905efcc778984225c96c8cbb8cdf..5f9c62603467ef292a74ee3260a2bc4477a748e3 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/RunCombinationHelpers/RunCombinationHelper.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/RunCombinationHelpers/RunCombinationHelper.h @@ -30,9 +30,9 @@ static const std::string FAIL_BEHAVIOUR = "Fail"; class MANTID_ALGORITHMS_DLL RunCombinationHelper { public: - std::string checkCompatibility(API::MatrixWorkspace_sptr, + std::string checkCompatibility(const API::MatrixWorkspace_sptr &, bool checkNumberHistograms = false); - void setReferenceProperties(API::MatrixWorkspace_sptr); + void setReferenceProperties(const API::MatrixWorkspace_sptr &); static std::vector<std::string> unWrapGroups(const std::vector<std::string> &); std::list<API::MatrixWorkspace_sptr> diff --git a/Framework/Algorithms/inc/MantidAlgorithms/RunCombinationHelpers/SampleLogsBehaviour.h b/Framework/Algorithms/inc/MantidAlgorithms/RunCombinationHelpers/SampleLogsBehaviour.h index ef7f695bb9b2563163a724cf5efe3ba52da7bada..81a1e521e5d13da19156cec65f9c3233243e9dd1 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/RunCombinationHelpers/SampleLogsBehaviour.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/RunCombinationHelpers/SampleLogsBehaviour.h @@ -69,17 +69,18 @@ public: std::string sampleLogsFailTolerances; }; - SampleLogsBehaviour(API::MatrixWorkspace_sptr ws, Kernel::Logger &logger, + SampleLogsBehaviour(const API::MatrixWorkspace_sptr &ws, + Kernel::Logger &logger, const SampleLogNames &logEntries = {}, const ParameterName &parName = {}); /// Create and update sample logs according to instrument parameters - void mergeSampleLogs(API::MatrixWorkspace_sptr addeeWS, - API::MatrixWorkspace_sptr outWS); - void setUpdatedSampleLogs(API::MatrixWorkspace_sptr outWS); - void removeSampleLogsFromWorkspace(API::MatrixWorkspace_sptr addeeWS); - void readdSampleLogToWorkspace(API::MatrixWorkspace_sptr addeeWS); - void resetSampleLogs(API::MatrixWorkspace_sptr ws); + void mergeSampleLogs(const API::MatrixWorkspace_sptr &addeeWS, + const API::MatrixWorkspace_sptr &outWS); + void setUpdatedSampleLogs(const API::MatrixWorkspace_sptr &outWS); + void removeSampleLogsFromWorkspace(const API::MatrixWorkspace_sptr &addeeWS); + void readdSampleLogToWorkspace(const API::MatrixWorkspace_sptr &addeeWS); + void resetSampleLogs(const API::MatrixWorkspace_sptr &ws); private: Kernel::Logger &m_logger; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/SANSCollimationLengthEstimator.h b/Framework/Algorithms/inc/MantidAlgorithms/SANSCollimationLengthEstimator.h index 384b5ef152aeef38e70c1be9dc453950efa30c90..77290e6f4783f4aef90e6e05524bb7862e2e7e2f 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/SANSCollimationLengthEstimator.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/SANSCollimationLengthEstimator.h @@ -15,11 +15,12 @@ namespace Mantid { namespace Algorithms { class MANTID_ALGORITHMS_DLL SANSCollimationLengthEstimator { public: - double provideCollimationLength(Mantid::API::MatrixWorkspace_sptr workspace); + double + provideCollimationLength(const Mantid::API::MatrixWorkspace_sptr &workspace); private: double getCollimationLengthWithGuides( - Mantid::API::MatrixWorkspace_sptr inOutWS, const double L1, + const Mantid::API::MatrixWorkspace_sptr &inOutWS, const double L1, const double collimationLengthCorrection) const; double getGuideValue(Mantid::Kernel::Property *prop) const; }; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/SampleCorrections/MCAbsorptionStrategy.h b/Framework/Algorithms/inc/MantidAlgorithms/SampleCorrections/MCAbsorptionStrategy.h index 620b2eefde7be7054fedc57a6067fa268e86798c..f418bb49411b822eb7609310e82b8e07efc09d04 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/SampleCorrections/MCAbsorptionStrategy.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/SampleCorrections/MCAbsorptionStrategy.h @@ -47,7 +47,8 @@ public: Kernel::Logger &logger); void calculate(Kernel::PseudoRandomNumberGenerator &rng, const Kernel::V3D &finalPos, - Mantid::HistogramData::Points lambdas, double lambdaFixed, + const Mantid::HistogramData::Points &lambdas, + double lambdaFixed, Mantid::API::ISpectrum &attenuationFactorsSpectrum); private: diff --git a/Framework/Algorithms/inc/MantidAlgorithms/SmoothNeighbours.h b/Framework/Algorithms/inc/MantidAlgorithms/SmoothNeighbours.h index 24e1bc56b2e064d2ae831c98db533c724aa02178..3faf5a6651ce9102e482a5bfdeeda69586ce9042 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/SmoothNeighbours.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/SmoothNeighbours.h @@ -105,7 +105,7 @@ private: void setupNewInstrument(API::MatrixWorkspace &outws) const; /// Build the instrument/detector setup in workspace - void spreadPixels(API::MatrixWorkspace_sptr outws); + void spreadPixels(const API::MatrixWorkspace_sptr &outws); /// Non rectangular detector group name static const std::string NON_UNIFORM_GROUP; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/SofQWPolygon.h b/Framework/Algorithms/inc/MantidAlgorithms/SofQWPolygon.h index aaab8d15c76b8c01e1ceb72696bb5b21405c97a2..7bcad9d82b43a12c091fa675c2757554ffb7bb7f 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/SofQWPolygon.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/SofQWPolygon.h @@ -65,7 +65,7 @@ private: /// Run the algorithm void exec() override; /// Init variables cache base on the given workspace - void initCachedValues(API::MatrixWorkspace_const_sptr workspace); + void initCachedValues(const API::MatrixWorkspace_const_sptr &workspace); /// Init the theta index void initThetaCache(const API::MatrixWorkspace &workspace); diff --git a/Framework/Algorithms/inc/MantidAlgorithms/SortXAxis.h b/Framework/Algorithms/inc/MantidAlgorithms/SortXAxis.h index 138f3a768338ad0c409f79af36526fd1c7b33818..c55bd2ba79f83a12ad06d1e26d8b86708628b20f 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/SortXAxis.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/SortXAxis.h @@ -34,7 +34,7 @@ private: std::vector<std::size_t> createIndexes(const size_t); void sortIndicesByX(std::vector<std::size_t> &workspaceIndecies, - std::string order, + const std::string &order, const Mantid::API::MatrixWorkspace &inputWorkspace, unsigned int specNum); diff --git a/Framework/Algorithms/inc/MantidAlgorithms/SpecularReflectionAlgorithm.h b/Framework/Algorithms/inc/MantidAlgorithms/SpecularReflectionAlgorithm.h index 2203dc9218367fe1f487e702fb10bd4c3cb9d9e6..2a5b2f7fa4cec9b428e47cd924e6ebb1d534bd0f 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/SpecularReflectionAlgorithm.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/SpecularReflectionAlgorithm.h @@ -25,12 +25,12 @@ protected: SpecularReflectionAlgorithm() = default; /// Get the surface sample component - Mantid::Geometry::IComponent_const_sptr - getSurfaceSampleComponent(Mantid::Geometry::Instrument_const_sptr inst) const; + Mantid::Geometry::IComponent_const_sptr getSurfaceSampleComponent( + const Mantid::Geometry::Instrument_const_sptr &inst) const; /// Get the detector component Mantid::Geometry::IComponent_const_sptr - getDetectorComponent(Mantid::API::MatrixWorkspace_sptr workspace, + getDetectorComponent(const Mantid::API::MatrixWorkspace_sptr &workspace, const bool isPointDetector) const; /// Does the property have a default value. diff --git a/Framework/Algorithms/inc/MantidAlgorithms/SpecularReflectionPositionCorrect.h b/Framework/Algorithms/inc/MantidAlgorithms/SpecularReflectionPositionCorrect.h index b3801e1e06263bd960a3ab4df37a8c77dc6a89c3..06fb59bbfaf030cff78c5e1869eab2fece74ed24 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/SpecularReflectionPositionCorrect.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/SpecularReflectionPositionCorrect.h @@ -34,15 +34,15 @@ private: void exec() override; /// Correct detector positions. - void correctPosition(API::MatrixWorkspace_sptr toCorrect, + void correctPosition(const API::MatrixWorkspace_sptr &toCorrect, const double &twoThetaInDeg, - Geometry::IComponent_const_sptr sample, - Geometry::IComponent_const_sptr detector); + const Geometry::IComponent_const_sptr &sample, + const Geometry::IComponent_const_sptr &detector); /// Move detectors. - void moveDetectors(API::MatrixWorkspace_sptr toCorrect, + void moveDetectors(const API::MatrixWorkspace_sptr &toCorrect, Geometry::IComponent_const_sptr detector, - Geometry::IComponent_const_sptr sample, + const Geometry::IComponent_const_sptr &sample, const double &upOffset, const double &acrossOffset, const Mantid::Kernel::V3D &detectorPosition); }; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/Stitch1D.h b/Framework/Algorithms/inc/MantidAlgorithms/Stitch1D.h index f7d3b702ebcd76a1912ead03c884f612a42f4ec6..bd3f19787a9a214239eec539335f34557f5d5585 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/Stitch1D.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/Stitch1D.h @@ -84,7 +84,7 @@ private: /// Mask out everything but the data in the ranges, but do it inplace. void maskInPlace(int a1, int a2, Mantid::API::MatrixWorkspace_sptr &source); /// Add back in any special values - void reinsertSpecialValues(Mantid::API::MatrixWorkspace_sptr ws); + void reinsertSpecialValues(const Mantid::API::MatrixWorkspace_sptr &ws); /// Range tolerance static const double range_tolerance; /// Scaling factors diff --git a/Framework/Algorithms/inc/MantidAlgorithms/StripPeaks.h b/Framework/Algorithms/inc/MantidAlgorithms/StripPeaks.h index 90e588a8845653466cd343997093f2e4da87abf5..6e5db58f75b305c5e5e2ba6ee5660377755ae11e 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/StripPeaks.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/StripPeaks.h @@ -62,9 +62,10 @@ private: /// Execution code void exec() override; - API::ITableWorkspace_sptr findPeaks(API::MatrixWorkspace_sptr WS); - API::MatrixWorkspace_sptr removePeaks(API::MatrixWorkspace_const_sptr input, - API::ITableWorkspace_sptr peakslist); + API::ITableWorkspace_sptr findPeaks(const API::MatrixWorkspace_sptr &WS); + API::MatrixWorkspace_sptr + removePeaks(const API::MatrixWorkspace_const_sptr &input, + const API::ITableWorkspace_sptr &peakslist); double m_maxChiSq{0.0}; }; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/SumEventsByLogValue.h b/Framework/Algorithms/inc/MantidAlgorithms/SumEventsByLogValue.h index 81709e58b400e6bddf4acfb476a7774ffa0ee985..fc92892ce814bd106f8c7f4fa47e8a188bb95985 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/SumEventsByLogValue.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/SumEventsByLogValue.h @@ -55,7 +55,7 @@ private: const int maxVal, const Kernel::TimeSeriesProperty<int> *log, std::vector<int> &Y); - void addMonitorCounts(API::ITableWorkspace_sptr outputWorkspace, + void addMonitorCounts(const API::ITableWorkspace_sptr &outputWorkspace, const Kernel::TimeSeriesProperty<int> *log, const int minVal, const int maxVal); std::vector<std::pair<std::string, const Kernel::ITimeSeriesProperty *>> diff --git a/Framework/Algorithms/inc/MantidAlgorithms/SumSpectra.h b/Framework/Algorithms/inc/MantidAlgorithms/SumSpectra.h index cddb3e3e886a0f35101621c92b74bc80ed53b556..1c5e291c7b37bcded8ce6448e6a827a8ede5fbb3 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/SumSpectra.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/SumSpectra.h @@ -60,21 +60,22 @@ public: private: /// Handle logic for RebinnedOutput workspaces - void doFractionalSum(API::MatrixWorkspace_sptr outputWorkspace, + void doFractionalSum(const API::MatrixWorkspace_sptr &outputWorkspace, API::Progress &progress, size_t &numSpectra, size_t &numMasked, size_t &numZeros); /// Handle logic for Workspace2D workspaces - void doSimpleSum(API::MatrixWorkspace_sptr outputWorkspace, + void doSimpleSum(const API::MatrixWorkspace_sptr &outputWorkspace, API::Progress &progress, size_t &numSpectra, size_t &numMasked, size_t &numZeros); // Overridden Algorithm methods void init() override; void exec() override; - void execEvent(API::MatrixWorkspace_sptr outputWorkspace, + void execEvent(const API::MatrixWorkspace_sptr &outputWorkspace, API::Progress &progress, size_t &numSpectra, size_t &numMasked, size_t &numZeros); - specnum_t getOutputSpecNo(API::MatrixWorkspace_const_sptr localworkspace); + specnum_t + getOutputSpecNo(const API::MatrixWorkspace_const_sptr &localworkspace); API::MatrixWorkspace_sptr replaceSpecialValues(); void determineIndices(const size_t numberOfSpectra); diff --git a/Framework/Algorithms/inc/MantidAlgorithms/TOFSANSResolutionByPixel.h b/Framework/Algorithms/inc/MantidAlgorithms/TOFSANSResolutionByPixel.h index dc97f7594f4b6ce6c320a743b76ffddeab4c1747..7ab48b1ff4783dcc31ff3656b1a51b188136f941 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/TOFSANSResolutionByPixel.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/TOFSANSResolutionByPixel.h @@ -58,13 +58,13 @@ private: double provideDefaultLCollimationLength( Mantid::API::MatrixWorkspace_sptr inWS) const; /// Check input - void checkInput(Mantid::API::MatrixWorkspace_sptr inWS); + void checkInput(const Mantid::API::MatrixWorkspace_sptr &inWS); /// Get the moderator workspace - Mantid::API::MatrixWorkspace_sptr - getModeratorWorkspace(Mantid::API::MatrixWorkspace_sptr inputWorkspace); + Mantid::API::MatrixWorkspace_sptr getModeratorWorkspace( + const Mantid::API::MatrixWorkspace_sptr &inputWorkspace); /// Create an output workspace Mantid::API::MatrixWorkspace_sptr - setupOutputWorkspace(Mantid::API::MatrixWorkspace_sptr inputWorkspace); + setupOutputWorkspace(const Mantid::API::MatrixWorkspace_sptr &inputWorkspace); /// Wavelength resolution (constant for all wavelengths) double m_wl_resolution; }; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/TimeAtSampleStrategyDirect.h b/Framework/Algorithms/inc/MantidAlgorithms/TimeAtSampleStrategyDirect.h index 595d6efe549abb41fa73f371b929b03e3d411077..6ba3418f9a37bd195bb44c8a16d4321182cb7f5e 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/TimeAtSampleStrategyDirect.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/TimeAtSampleStrategyDirect.h @@ -23,7 +23,8 @@ class MANTID_ALGORITHMS_DLL TimeAtSampleStrategyDirect : public TimeAtSampleStrategy { public: TimeAtSampleStrategyDirect( - boost::shared_ptr<const Mantid::API::MatrixWorkspace> ws, double ei); + const boost::shared_ptr<const Mantid::API::MatrixWorkspace> &ws, + double ei); Correction calculate(const size_t &workspace_index) const override; private: diff --git a/Framework/Algorithms/inc/MantidAlgorithms/Transpose.h b/Framework/Algorithms/inc/MantidAlgorithms/Transpose.h index 00640af1f88a275ffe82bf7a9b9f65c067c22a77..db1e2c7b70fbbc935b34627e6c516dbfcce4a3f3 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/Transpose.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/Transpose.h @@ -56,9 +56,10 @@ private: void exec() override; /// Create the output workspace API::MatrixWorkspace_sptr - createOutputWorkspace(API::MatrixWorkspace_const_sptr inputWorkspace); + createOutputWorkspace(const API::MatrixWorkspace_const_sptr &inputWorkspace); /// Return the vertical axis on the workspace, throwing if it is not valid - API::Axis *getVerticalAxis(API::MatrixWorkspace_const_sptr workspace) const; + API::Axis * + getVerticalAxis(const API::MatrixWorkspace_const_sptr &workspace) const; }; } // namespace Algorithms diff --git a/Framework/Algorithms/inc/MantidAlgorithms/WienerSmooth.h b/Framework/Algorithms/inc/MantidAlgorithms/WienerSmooth.h index 49c7772d6eb25cda965922d69db556ffdb3a7e06..f7888fff4df99aaee5c4645e69ebe6f9d7c484e0 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/WienerSmooth.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/WienerSmooth.h @@ -35,7 +35,7 @@ private: std::pair<double, double> getStartEnd(const Mantid::HistogramData::HistogramX &X, bool isHistogram) const; - API::MatrixWorkspace_sptr copyInput(API::MatrixWorkspace_sptr inputWS, + API::MatrixWorkspace_sptr copyInput(const API::MatrixWorkspace_sptr &inputWS, size_t wsIndex); API::MatrixWorkspace_sptr smoothSingleSpectrum(API::MatrixWorkspace_sptr inputWS, size_t wsIndex); diff --git a/Framework/Algorithms/inc/MantidAlgorithms/XDataConverter.h b/Framework/Algorithms/inc/MantidAlgorithms/XDataConverter.h index 2f6cdc8cf15749a3ed700a7d5cb1ead32a82d844..b15e66e66bc674f306118ab2f5fa4d514c3e13a0 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/XDataConverter.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/XDataConverter.h @@ -51,11 +51,11 @@ private: /// Override exec void exec() override; - std::size_t getNewYSize(const API::MatrixWorkspace_sptr inputWS); + std::size_t getNewYSize(const API::MatrixWorkspace_sptr &inputWS); /// Set the X data on given spectra - void setXData(API::MatrixWorkspace_sptr outputWS, - const API::MatrixWorkspace_sptr inputWS, const int index); + void setXData(const API::MatrixWorkspace_sptr &outputWS, + const API::MatrixWorkspace_sptr &inputWS, const int index); /// Flag if the X data is shared bool m_sharedX; diff --git a/Framework/Algorithms/src/AddLogDerivative.cpp b/Framework/Algorithms/src/AddLogDerivative.cpp index 2e9dc599a61f3637d6b243497cb58b128f6b94aa..a30db421d6543f1f68c0f169dfa7c5e939eb632f 100644 --- a/Framework/Algorithms/src/AddLogDerivative.cpp +++ b/Framework/Algorithms/src/AddLogDerivative.cpp @@ -103,8 +103,9 @@ Mantid::Kernel::TimeSeriesProperty<double> *AddLogDerivative::makeDerivative( DateAndTime start = input->nthTime(0); std::vector<DateAndTime> timeFull; timeFull.reserve(times.size()); - for (const double time : times) - timeFull.emplace_back(start + time); + + std::transform(times.begin(), times.end(), std::back_inserter(timeFull), + [&start](const double time) { return start + time; }); // Create the TSP out of it auto out = new TimeSeriesProperty<double>(name); diff --git a/Framework/Algorithms/src/AddSampleLog.cpp b/Framework/Algorithms/src/AddSampleLog.cpp index 3227abe3460adfbd29c90f1994a791999f79311f..4f49a04355892b673ce1e94e99a3be27d8ed30b3 100644 --- a/Framework/Algorithms/src/AddSampleLog.cpp +++ b/Framework/Algorithms/src/AddSampleLog.cpp @@ -369,7 +369,7 @@ void AddSampleLog::setTimeSeriesData(Run &run_obj, * @return */ std::vector<Types::Core::DateAndTime> -AddSampleLog::getTimes(API::MatrixWorkspace_const_sptr dataws, +AddSampleLog::getTimes(const API::MatrixWorkspace_const_sptr &dataws, int workspace_index, bool is_epoch, bool is_second, API::Run &run_obj) { // get run start time @@ -421,7 +421,7 @@ Types::Core::DateAndTime AddSampleLog::getRunStart(API::Run &run_obj) { * @return */ std::vector<double> -AddSampleLog::getDblValues(API::MatrixWorkspace_const_sptr dataws, +AddSampleLog::getDblValues(const API::MatrixWorkspace_const_sptr &dataws, int workspace_index) { std::vector<double> valuevec; size_t vecsize = dataws->readY(workspace_index).size(); @@ -439,7 +439,7 @@ AddSampleLog::getDblValues(API::MatrixWorkspace_const_sptr dataws, * @return */ std::vector<int> -AddSampleLog::getIntValues(API::MatrixWorkspace_const_sptr dataws, +AddSampleLog::getIntValues(const API::MatrixWorkspace_const_sptr &dataws, int workspace_index) { std::vector<int> valuevec; size_t vecsize = dataws->readY(workspace_index).size(); @@ -455,7 +455,7 @@ AddSampleLog::getIntValues(API::MatrixWorkspace_const_sptr dataws, * @param epochtime * @param timeunit */ -void AddSampleLog::getMetaData(API::MatrixWorkspace_const_sptr dataws, +void AddSampleLog::getMetaData(const API::MatrixWorkspace_const_sptr &dataws, bool &epochtime, std::string &timeunit) { bool auto_meta = getProperty("AutoMetaData"); if (auto_meta) { diff --git a/Framework/Algorithms/src/AlignDetectors.cpp b/Framework/Algorithms/src/AlignDetectors.cpp index 60d3cea2e8c0792eb6bffe881a95a55fef964619..5df9f9c859b0d9a20e38502de988ef05935727d3 100644 --- a/Framework/Algorithms/src/AlignDetectors.cpp +++ b/Framework/Algorithms/src/AlignDetectors.cpp @@ -24,6 +24,7 @@ #include <fstream> #include <sstream> +#include <utility> using namespace Mantid::Kernel; using namespace Mantid::API; @@ -41,7 +42,7 @@ namespace { // anonymous namespace class ConversionFactors { public: - explicit ConversionFactors(ITableWorkspace_const_sptr table) + explicit ConversionFactors(const ITableWorkspace_const_sptr &table) : m_difcCol(table->getColumn("difc")), m_difaCol(table->getColumn("difa")), m_tzeroCol(table->getColumn("tzero")) { @@ -70,7 +71,7 @@ public: } private: - void generateDetidToRow(ITableWorkspace_const_sptr table) { + void generateDetidToRow(const ITableWorkspace_const_sptr &table) { ConstColumnVector<int> detIDs = table->getVector("detid"); const size_t numDets = detIDs.size(); for (size_t i = 0; i < numDets; ++i) { @@ -188,7 +189,7 @@ std::map<std::string, std::string> AlignDetectors::validateInputs() { return result; } -void AlignDetectors::loadCalFile(MatrixWorkspace_sptr inputWS, +void AlignDetectors::loadCalFile(const MatrixWorkspace_sptr &inputWS, const std::string &filename) { IAlgorithm_sptr alg = createChildAlgorithm("LoadDiffCal"); alg->setProperty("InputWorkspace", inputWS); @@ -202,7 +203,7 @@ void AlignDetectors::loadCalFile(MatrixWorkspace_sptr inputWS, m_calibrationWS = alg->getProperty("OutputCalWorkspace"); } -void AlignDetectors::getCalibrationWS(MatrixWorkspace_sptr inputWS) { +void AlignDetectors::getCalibrationWS(const MatrixWorkspace_sptr &inputWS) { m_calibrationWS = getProperty("CalibrationWorkspace"); if (m_calibrationWS) return; // nothing more to do @@ -220,14 +221,14 @@ void AlignDetectors::getCalibrationWS(MatrixWorkspace_sptr inputWS) { const std::string calFileName = getPropertyValue("CalibrationFile"); if (!calFileName.empty()) { progress(0.0, "Reading calibration file"); - loadCalFile(inputWS, calFileName); + loadCalFile(std::move(inputWS), calFileName); return; } throw std::runtime_error("Failed to determine calibration information"); } -void setXAxisUnits(API::MatrixWorkspace_sptr outputWS) { +void setXAxisUnits(const API::MatrixWorkspace_sptr &outputWS) { outputWS->getAxis(0)->unit() = UnitFactory::Instance().create("dSpacing"); } diff --git a/Framework/Algorithms/src/Bin2DPowderDiffraction.cpp b/Framework/Algorithms/src/Bin2DPowderDiffraction.cpp index 2b555c68c0f0a059288211a2d7956ac2caa9c30f..1ec74a6976e6d04afe727f5273ea7efb658cb900 100644 --- a/Framework/Algorithms/src/Bin2DPowderDiffraction.cpp +++ b/Framework/Algorithms/src/Bin2DPowderDiffraction.cpp @@ -365,7 +365,8 @@ size_t Bin2DPowderDiffraction::UnifyXBins( return max_size; } -void Bin2DPowderDiffraction::normalizeToBinArea(MatrixWorkspace_sptr outWS) { +void Bin2DPowderDiffraction::normalizeToBinArea( + const MatrixWorkspace_sptr &outWS) { NumericAxis *verticalAxis = dynamic_cast<NumericAxis *>(outWS->getAxis(1)); const std::vector<double> &yValues = verticalAxis->getValues(); auto nhist = outWS->getNumberHistograms(); diff --git a/Framework/Algorithms/src/BinaryOperation.cpp b/Framework/Algorithms/src/BinaryOperation.cpp index 62954e801bb067ef3d3f707004e305be19309015..df4143ea17c09bf4446ceb68024cdc061394f1ba 100644 --- a/Framework/Algorithms/src/BinaryOperation.cpp +++ b/Framework/Algorithms/src/BinaryOperation.cpp @@ -795,7 +795,8 @@ void BinaryOperation::do2D(bool mismatchedSpectra) { * @param out :: The result workspace */ void BinaryOperation::propagateBinMasks( - const API::MatrixWorkspace_const_sptr rhs, API::MatrixWorkspace_sptr out) { + const API::MatrixWorkspace_const_sptr &rhs, + const API::MatrixWorkspace_sptr &out) { const int64_t outHists = out->getNumberHistograms(); const int64_t rhsHists = rhs->getNumberHistograms(); for (int64_t i = 0; i < outHists; ++i) { @@ -876,7 +877,7 @@ void BinaryOperation::performEventBinaryOperation(DataObjects::EventList &lhs, * @return OperandType describing what type of workspace it will be operated as. */ OperandType -BinaryOperation::getOperandType(const API::MatrixWorkspace_const_sptr ws) { +BinaryOperation::getOperandType(const API::MatrixWorkspace_const_sptr &ws) { // An event workspace? EventWorkspace_const_sptr ews = boost::dynamic_pointer_cast<const EventWorkspace>(ws); diff --git a/Framework/Algorithms/src/CalculateCarpenterSampleCorrection.cpp b/Framework/Algorithms/src/CalculateCarpenterSampleCorrection.cpp index c0d62145aa1d349217515905cb8c8a6151453a19..7d2997186d538952750887c6f703510d5d6b2332 100644 --- a/Framework/Algorithms/src/CalculateCarpenterSampleCorrection.cpp +++ b/Framework/Algorithms/src/CalculateCarpenterSampleCorrection.cpp @@ -413,7 +413,7 @@ void CalculateCarpenterSampleCorrection::calculate_ms_correction( } MatrixWorkspace_sptr CalculateCarpenterSampleCorrection::createOutputWorkspace( - const MatrixWorkspace_sptr &inputWksp, const std::string ylabel) const { + const MatrixWorkspace_sptr &inputWksp, const std::string &ylabel) const { MatrixWorkspace_sptr outputWS = create<HistoWorkspace>(*inputWksp); // The algorithm computes the signal values at bin centres so they should // be treated as a distribution @@ -424,7 +424,7 @@ MatrixWorkspace_sptr CalculateCarpenterSampleCorrection::createOutputWorkspace( } MatrixWorkspace_sptr CalculateCarpenterSampleCorrection::setUncertainties( - MatrixWorkspace_sptr workspace) { + const MatrixWorkspace_sptr &workspace) { auto alg = this->createChildAlgorithm("SetUncertainties"); alg->initialize(); alg->setProperty("InputWorkspace", workspace); @@ -433,7 +433,7 @@ MatrixWorkspace_sptr CalculateCarpenterSampleCorrection::setUncertainties( } void CalculateCarpenterSampleCorrection::deleteWorkspace( - MatrixWorkspace_sptr workspace) { + const MatrixWorkspace_sptr &workspace) { auto alg = this->createChildAlgorithm("DeleteWorkspace"); alg->initialize(); alg->setChild(true); diff --git a/Framework/Algorithms/src/CalculateDynamicRange.cpp b/Framework/Algorithms/src/CalculateDynamicRange.cpp index f7a871d6b2cb0eaf7ec522a1db329a50fc2f9a44..c379339928254015cf5f4e413036607dd335d62f 100644 --- a/Framework/Algorithms/src/CalculateDynamicRange.cpp +++ b/Framework/Algorithms/src/CalculateDynamicRange.cpp @@ -73,9 +73,9 @@ void CalculateDynamicRange::init() { * @param indices : the list of workspace indices * @param compName : the name of the detector component */ -void CalculateDynamicRange::calculateQMinMax(MatrixWorkspace_sptr workspace, - const std::vector<size_t> &indices, - const std::string &compName = "") { +void CalculateDynamicRange::calculateQMinMax( + const MatrixWorkspace_sptr &workspace, const std::vector<size_t> &indices, + const std::string &compName = "") { const auto &spectrumInfo = workspace->spectrumInfo(); double min = std::numeric_limits<double>::max(), max = std::numeric_limits<double>::min(); @@ -146,9 +146,9 @@ void CalculateDynamicRange::exec() { } if (!dets.empty()) { detIDs.reserve(dets.size()); - for (const auto &det : dets) { - detIDs.emplace_back(det->getID()); - } + std::transform(dets.begin(), dets.end(), std::back_inserter(detIDs), + [](const auto &det) { return det->getID(); }); + const auto indices = workspace->getIndicesFromDetectorIDs(detIDs); calculateQMinMax(workspace, indices, compName); } diff --git a/Framework/Algorithms/src/CalculateEfficiency.cpp b/Framework/Algorithms/src/CalculateEfficiency.cpp index 84a379264dbaa8b6d0255e71e1590ce980faac7e..97d115ef78c156580aab0089f12d3389b9eae123 100644 --- a/Framework/Algorithms/src/CalculateEfficiency.cpp +++ b/Framework/Algorithms/src/CalculateEfficiency.cpp @@ -156,9 +156,9 @@ void CalculateEfficiency::exec() { * @param error: error on sum (counts) * @param nPixels: number of unmasked detector pixels that contributed to sum */ -void CalculateEfficiency::sumUnmaskedDetectors(MatrixWorkspace_sptr rebinnedWS, - double &sum, double &error, - int &nPixels) { +void CalculateEfficiency::sumUnmaskedDetectors( + const MatrixWorkspace_sptr &rebinnedWS, double &sum, double &error, + int &nPixels) { // Number of spectra const auto numberOfSpectra = static_cast<int>(rebinnedWS->getNumberHistograms()); @@ -200,11 +200,10 @@ void CalculateEfficiency::sumUnmaskedDetectors(MatrixWorkspace_sptr rebinnedWS, * @param nPixels: number of unmasked detector pixels that contributed to sum */ -void CalculateEfficiency::normalizeDetectors(MatrixWorkspace_sptr rebinnedWS, - MatrixWorkspace_sptr outputWS, - double sum, double error, - int nPixels, double min_eff, - double max_eff) { +void CalculateEfficiency::normalizeDetectors( + const MatrixWorkspace_sptr &rebinnedWS, + const MatrixWorkspace_sptr &outputWS, double sum, double error, int nPixels, + double min_eff, double max_eff) { // Number of spectra const size_t numberOfSpectra = rebinnedWS->getNumberHistograms(); @@ -337,7 +336,7 @@ void CalculateEfficiency::maskComponent(MatrixWorkspace &ws, * @param low :: number of rows to mask Bottom * @param componentName :: Must be a RectangularDetector */ -void CalculateEfficiency::maskEdges(MatrixWorkspace_sptr ws, int left, +void CalculateEfficiency::maskEdges(const MatrixWorkspace_sptr &ws, int left, int right, int high, int low, const std::string &componentName) { diff --git a/Framework/Algorithms/src/CalculateIqt.cpp b/Framework/Algorithms/src/CalculateIqt.cpp index ee3a5012c42545563e6f591fc888211a60a30327..6d18d84ed86bd681ed5024a77f975136b646a952 100644 --- a/Framework/Algorithms/src/CalculateIqt.cpp +++ b/Framework/Algorithms/src/CalculateIqt.cpp @@ -15,6 +15,7 @@ #include <boost/numeric/conversion/cast.hpp> #include <cmath> #include <functional> +#include <utility> using namespace Mantid::Algorithms; using namespace Mantid::API; @@ -90,7 +91,7 @@ allYValuesAtIndex(const std::vector<MatrixWorkspace_sptr> &workspaces, return yValues; } -int getWorkspaceNumberOfHistograms(MatrixWorkspace_sptr workspace) { +int getWorkspaceNumberOfHistograms(const MatrixWorkspace_sptr &workspace) { return boost::numeric_cast<int>(workspace->getNumberHistograms()); } @@ -172,7 +173,7 @@ std::string CalculateIqt::rebinParamsAsString() { } MatrixWorkspace_sptr CalculateIqt::monteCarloErrorCalculation( - MatrixWorkspace_sptr sample, MatrixWorkspace_sptr resolution, + const MatrixWorkspace_sptr &sample, const MatrixWorkspace_sptr &resolution, const std::string &rebinParams, const int seed, const bool calculateErrors, const int nIterations) { auto outputWorkspace = calculateIqt(sample, resolution, rebinParams); @@ -211,7 +212,7 @@ std::map<std::string, std::string> CalculateIqt::validateInputs() { return issues; } -MatrixWorkspace_sptr CalculateIqt::rebin(MatrixWorkspace_sptr workspace, +MatrixWorkspace_sptr CalculateIqt::rebin(const MatrixWorkspace_sptr &workspace, const std::string ¶ms) { IAlgorithm_sptr rebinAlgorithm = this->createChildAlgorithm("Rebin"); rebinAlgorithm->initialize(); @@ -222,7 +223,8 @@ MatrixWorkspace_sptr CalculateIqt::rebin(MatrixWorkspace_sptr workspace, return rebinAlgorithm->getProperty("OutputWorkspace"); } -MatrixWorkspace_sptr CalculateIqt::integration(MatrixWorkspace_sptr workspace) { +MatrixWorkspace_sptr +CalculateIqt::integration(const MatrixWorkspace_sptr &workspace) { IAlgorithm_sptr integrationAlgorithm = this->createChildAlgorithm("Integration"); integrationAlgorithm->initialize(); @@ -233,7 +235,7 @@ MatrixWorkspace_sptr CalculateIqt::integration(MatrixWorkspace_sptr workspace) { } MatrixWorkspace_sptr -CalculateIqt::convertToPointData(MatrixWorkspace_sptr workspace) { +CalculateIqt::convertToPointData(const MatrixWorkspace_sptr &workspace) { IAlgorithm_sptr pointDataAlgorithm = this->createChildAlgorithm("ConvertToPointData"); pointDataAlgorithm->initialize(); @@ -244,7 +246,7 @@ CalculateIqt::convertToPointData(MatrixWorkspace_sptr workspace) { } MatrixWorkspace_sptr -CalculateIqt::extractFFTSpectrum(MatrixWorkspace_sptr workspace) { +CalculateIqt::extractFFTSpectrum(const MatrixWorkspace_sptr &workspace) { IAlgorithm_sptr FFTAlgorithm = this->createChildAlgorithm("ExtractFFTSpectrum"); FFTAlgorithm->initialize(); @@ -255,8 +257,9 @@ CalculateIqt::extractFFTSpectrum(MatrixWorkspace_sptr workspace) { return FFTAlgorithm->getProperty("OutputWorkspace"); } -MatrixWorkspace_sptr CalculateIqt::divide(MatrixWorkspace_sptr lhsWorkspace, - MatrixWorkspace_sptr rhsWorkspace) { +MatrixWorkspace_sptr +CalculateIqt::divide(const MatrixWorkspace_sptr &lhsWorkspace, + const MatrixWorkspace_sptr &rhsWorkspace) { IAlgorithm_sptr divideAlgorithm = this->createChildAlgorithm("Divide"); divideAlgorithm->initialize(); divideAlgorithm->setProperty("LHSWorkspace", lhsWorkspace); @@ -266,8 +269,9 @@ MatrixWorkspace_sptr CalculateIqt::divide(MatrixWorkspace_sptr lhsWorkspace, return divideAlgorithm->getProperty("OutputWorkspace"); } -MatrixWorkspace_sptr CalculateIqt::cropWorkspace(MatrixWorkspace_sptr workspace, - const double xMax) { +MatrixWorkspace_sptr +CalculateIqt::cropWorkspace(const MatrixWorkspace_sptr &workspace, + const double xMax) { IAlgorithm_sptr cropAlgorithm = this->createChildAlgorithm("CropWorkspace"); cropAlgorithm->initialize(); cropAlgorithm->setProperty("InputWorkspace", workspace); @@ -278,7 +282,7 @@ MatrixWorkspace_sptr CalculateIqt::cropWorkspace(MatrixWorkspace_sptr workspace, } MatrixWorkspace_sptr -CalculateIqt::replaceSpecialValues(MatrixWorkspace_sptr workspace) { +CalculateIqt::replaceSpecialValues(const MatrixWorkspace_sptr &workspace) { IAlgorithm_sptr specialValuesAlgorithm = this->createChildAlgorithm("ReplaceSpecialValues"); specialValuesAlgorithm->initialize(); @@ -311,18 +315,19 @@ CalculateIqt::normalizedFourierTransform(MatrixWorkspace_sptr workspace, MatrixWorkspace_sptr CalculateIqt::calculateIqt(MatrixWorkspace_sptr workspace, - MatrixWorkspace_sptr resolutionWorkspace, + const MatrixWorkspace_sptr &resolutionWorkspace, const std::string &rebinParams) { workspace = normalizedFourierTransform(workspace, rebinParams); - return divide(workspace, resolutionWorkspace); + return divide(workspace, std::move(resolutionWorkspace)); } MatrixWorkspace_sptr CalculateIqt::doSimulation(MatrixWorkspace_sptr sample, MatrixWorkspace_sptr resolution, const std::string &rebinParams, MersenneTwister &mTwister) { - auto simulatedWorkspace = randomizeWorkspaceWithinError(sample, mTwister); - return calculateIqt(simulatedWorkspace, resolution, rebinParams); + auto simulatedWorkspace = + randomizeWorkspaceWithinError(std::move(sample), mTwister); + return calculateIqt(simulatedWorkspace, std::move(resolution), rebinParams); } MatrixWorkspace_sptr CalculateIqt::setErrorsToStandardDeviation( diff --git a/Framework/Algorithms/src/CalculatePlaczekSelfScattering.cpp b/Framework/Algorithms/src/CalculatePlaczekSelfScattering.cpp index a6cf141beb0d8bf0bed171f8bebccf26c20c58b4..9db3a1f2615d036badab8c2af2e4ab020c746f40 100644 --- a/Framework/Algorithms/src/CalculatePlaczekSelfScattering.cpp +++ b/Framework/Algorithms/src/CalculatePlaczekSelfScattering.cpp @@ -21,7 +21,7 @@ namespace Mantid { namespace Algorithms { std::map<std::string, std::map<std::string, double>> -getSampleSpeciesInfo(const API::MatrixWorkspace_const_sptr ws) { +getSampleSpeciesInfo(const API::MatrixWorkspace_const_sptr &ws) { // get sample information : mass, total scattering length, and concentration // of each species double totalStoich = 0.0; @@ -91,7 +91,6 @@ CalculatePlaczekSelfScattering::validateInputs() { void CalculatePlaczekSelfScattering::exec() { const API::MatrixWorkspace_sptr inWS = getProperty("InputWorkspace"); const API::MatrixWorkspace_sptr incidentWS = getProperty("IncidentSpecta"); - API::MatrixWorkspace_sptr outWS = getProperty("OutputWorkspace"); constexpr double factor = 1.0 / 1.66053906660e-27; // atomic mass unit-kilogram relationship constexpr double neutronMass = factor * 1.674927471e-27; // neutron mass @@ -99,11 +98,15 @@ void CalculatePlaczekSelfScattering::exec() { // of each species auto atomSpecies = getSampleSpeciesInfo(inWS); // calculate summation term w/ neutron mass over molecular mass ratio - double summationTerm = 0.0; - for (auto atom : atomSpecies) { - summationTerm += atom.second["concentration"] * atom.second["bSqrdBar"] * + + auto sumLambda = [&neutronMass](double sum, auto &atom) { + return sum + atom.second["concentration"] * atom.second["bSqrdBar"] * neutronMass / atom.second["mass"]; - } + }; + + double summationTerm = + std::accumulate(atomSpecies.begin(), atomSpecies.end(), 0.0, sumLambda); + // get incident spectrum and 1st derivative const MantidVec xLambda = incidentWS->readX(0); const MantidVec incident = incidentWS->readY(0); diff --git a/Framework/Algorithms/src/CalculateTransmission.cpp b/Framework/Algorithms/src/CalculateTransmission.cpp index a4534b3209f2c7b0e99310004a63eadebef37dd5..e2269b9791d5418b9ec30b5cae0413a0fe357a35 100644 --- a/Framework/Algorithms/src/CalculateTransmission.cpp +++ b/Framework/Algorithms/src/CalculateTransmission.cpp @@ -25,6 +25,7 @@ #include <boost/algorithm/string/join.hpp> #include <boost/lexical_cast.hpp> +#include <utility> namespace Mantid { namespace Algorithms { @@ -264,7 +265,7 @@ void CalculateTransmission::exec() { *execution */ API::MatrixWorkspace_sptr -CalculateTransmission::extractSpectra(API::MatrixWorkspace_sptr ws, +CalculateTransmission::extractSpectra(const API::MatrixWorkspace_sptr &ws, const std::vector<size_t> &indices) { // Compile a comma separated list of indices that we can pass to SumSpectra. std::vector<std::string> indexStrings(indices.size()); @@ -301,11 +302,11 @@ CalculateTransmission::extractSpectra(API::MatrixWorkspace_sptr ws, * execution */ API::MatrixWorkspace_sptr -CalculateTransmission::fit(API::MatrixWorkspace_sptr raw, +CalculateTransmission::fit(const API::MatrixWorkspace_sptr &raw, const std::vector<double> &rebinParams, - const std::string fitMethod) { + const std::string &fitMethod) { MatrixWorkspace_sptr output = - this->extractSpectra(raw, std::vector<size_t>(1, 0)); + this->extractSpectra(std::move(raw), std::vector<size_t>(1, 0)); Progress progress(this, m_done, 1.0, 4); progress.report("CalculateTransmission: Performing fit"); @@ -403,8 +404,8 @@ CalculateTransmission::fit(API::MatrixWorkspace_sptr raw, * @throw runtime_error if the Linear algorithm fails during execution */ API::MatrixWorkspace_sptr -CalculateTransmission::fitData(API::MatrixWorkspace_sptr WS, double &grad, - double &offset) { +CalculateTransmission::fitData(const API::MatrixWorkspace_sptr &WS, + double &grad, double &offset) { g_log.information("Fitting the experimental transmission curve"); double start = m_done; IAlgorithm_sptr childAlg = createChildAlgorithm("Fit", start, m_done + 0.9); @@ -436,7 +437,8 @@ CalculateTransmission::fitData(API::MatrixWorkspace_sptr WS, double &grad, * @param[out] coeficients of the polynomial. c[0] + c[1]x + c[2]x^2 + ... */ API::MatrixWorkspace_sptr -CalculateTransmission::fitPolynomial(API::MatrixWorkspace_sptr WS, int order, +CalculateTransmission::fitPolynomial(const API::MatrixWorkspace_sptr &WS, + int order, std::vector<double> &coeficients) { g_log.notice("Fitting the experimental transmission curve fitpolyno"); double start = m_done; @@ -473,7 +475,7 @@ CalculateTransmission::fitPolynomial(API::MatrixWorkspace_sptr WS, int order, */ API::MatrixWorkspace_sptr CalculateTransmission::rebin(const std::vector<double> &binParams, - API::MatrixWorkspace_sptr ws) { + const API::MatrixWorkspace_sptr &ws) { double start = m_done; IAlgorithm_sptr childAlg = createChildAlgorithm("Rebin", start, m_done += 0.05); @@ -493,9 +495,9 @@ CalculateTransmission::rebin(const std::vector<double> &binParams, * @param directWS :: the input direct workspace * @param index :: the index of the detector to checked */ -void CalculateTransmission::logIfNotMonitor(API::MatrixWorkspace_sptr sampleWS, - API::MatrixWorkspace_sptr directWS, - size_t index) { +void CalculateTransmission::logIfNotMonitor( + const API::MatrixWorkspace_sptr &sampleWS, + const API::MatrixWorkspace_sptr &directWS, size_t index) { const std::string message = "The detector at index " + std::to_string(index) + " is not a monitor in the "; if (!sampleWS->spectrumInfo().isMonitor(index)) diff --git a/Framework/Algorithms/src/CalculateTransmissionBeamSpreader.cpp b/Framework/Algorithms/src/CalculateTransmissionBeamSpreader.cpp index 19df98df700a5cb4e0270c17fd3b92e6e9fd60c5..2fde4715f04155e90ec6e462f9e1faf3aaac0797 100644 --- a/Framework/Algorithms/src/CalculateTransmissionBeamSpreader.cpp +++ b/Framework/Algorithms/src/CalculateTransmissionBeamSpreader.cpp @@ -240,8 +240,8 @@ void CalculateTransmissionBeamSpreader::exec() { * @param WS :: The workspace containing the spectrum to sum * @return A Workspace2D containing the sum */ -API::MatrixWorkspace_sptr -CalculateTransmissionBeamSpreader::sumSpectra(API::MatrixWorkspace_sptr WS) { +API::MatrixWorkspace_sptr CalculateTransmissionBeamSpreader::sumSpectra( + const API::MatrixWorkspace_sptr &WS) { Algorithm_sptr childAlg = createChildAlgorithm("SumSpectra"); childAlg->setProperty<MatrixWorkspace_sptr>("InputWorkspace", WS); childAlg->setProperty<bool>("IncludeMonitors", false); @@ -255,9 +255,8 @@ CalculateTransmissionBeamSpreader::sumSpectra(API::MatrixWorkspace_sptr WS) { * @param index :: The workspace index of the spectrum to extract * @return A Workspace2D containing the extracted spectrum */ -API::MatrixWorkspace_sptr -CalculateTransmissionBeamSpreader::extractSpectrum(API::MatrixWorkspace_sptr WS, - const size_t index) { +API::MatrixWorkspace_sptr CalculateTransmissionBeamSpreader::extractSpectrum( + const API::MatrixWorkspace_sptr &WS, const size_t index) { // Check that given spectra are monitors if (!WS->spectrumInfo().isMonitor(index)) { g_log.information( @@ -277,8 +276,8 @@ CalculateTransmissionBeamSpreader::extractSpectrum(API::MatrixWorkspace_sptr WS, * @param WS :: The single-spectrum workspace to fit * @return A workspace containing the fit */ -API::MatrixWorkspace_sptr -CalculateTransmissionBeamSpreader::fitToData(API::MatrixWorkspace_sptr WS) { +API::MatrixWorkspace_sptr CalculateTransmissionBeamSpreader::fitToData( + const API::MatrixWorkspace_sptr &WS) { g_log.information("Fitting the experimental transmission curve"); Algorithm_sptr childAlg = createChildAlgorithm("Linear", 0.6, 1.0); childAlg->setProperty<MatrixWorkspace_sptr>("InputWorkspace", WS); diff --git a/Framework/Algorithms/src/CarpenterSampleCorrection.cpp b/Framework/Algorithms/src/CarpenterSampleCorrection.cpp index 87e2af3caa1bd3a3e7cbbd7f530cc31ec5d78f07..404c19988b3dafda7b0afa4420f5d2d7f5df965c 100644 --- a/Framework/Algorithms/src/CarpenterSampleCorrection.cpp +++ b/Framework/Algorithms/src/CarpenterSampleCorrection.cpp @@ -131,8 +131,8 @@ WorkspaceGroup_sptr CarpenterSampleCorrection::calculateCorrection( } MatrixWorkspace_sptr -CarpenterSampleCorrection::minus(const MatrixWorkspace_sptr lhsWS, - const MatrixWorkspace_sptr rhsWS) { +CarpenterSampleCorrection::minus(const MatrixWorkspace_sptr &lhsWS, + const MatrixWorkspace_sptr &rhsWS) { auto minus = this->createChildAlgorithm("Minus", 0.5, 0.75); minus->setProperty("LHSWorkspace", lhsWS); minus->setProperty("RHSWorkspace", rhsWS); @@ -142,8 +142,8 @@ CarpenterSampleCorrection::minus(const MatrixWorkspace_sptr lhsWS, } MatrixWorkspace_sptr -CarpenterSampleCorrection::multiply(const MatrixWorkspace_sptr lhsWS, - const MatrixWorkspace_sptr rhsWS) { +CarpenterSampleCorrection::multiply(const MatrixWorkspace_sptr &lhsWS, + const MatrixWorkspace_sptr &rhsWS) { auto multiply = this->createChildAlgorithm("Multiply", 0.75, 1.0); multiply->setProperty("LHSWorkspace", lhsWS); multiply->setProperty("RHSWorkspace", rhsWS); diff --git a/Framework/Algorithms/src/ChangeBinOffset.cpp b/Framework/Algorithms/src/ChangeBinOffset.cpp index aecd1761eae3c6516cba39019e888bfdd513c73f..869acd987f53bdeffead33ced7b1d1027880a323 100644 --- a/Framework/Algorithms/src/ChangeBinOffset.cpp +++ b/Framework/Algorithms/src/ChangeBinOffset.cpp @@ -54,8 +54,8 @@ void ChangeBinOffset::exec() { this->for_each<Indices::FromProperty>( *outputW, std::make_tuple(MatrixWorkspaceAccess::x), [offset](std::vector<double> &dataX) { - for (auto &x : dataX) - x += offset; + std::transform(dataX.begin(), dataX.end(), dataX.begin(), + [offset](double x) { return x + offset; }); }); } } diff --git a/Framework/Algorithms/src/ChangeTimeZero.cpp b/Framework/Algorithms/src/ChangeTimeZero.cpp index 83a54079d4d12efc0479aa87796d96612037b09e..f8375d2062a6071b66c89b2b04e28786fd13db92 100644 --- a/Framework/Algorithms/src/ChangeTimeZero.cpp +++ b/Framework/Algorithms/src/ChangeTimeZero.cpp @@ -20,6 +20,7 @@ #include <boost/lexical_cast.hpp> #include <boost/shared_ptr.hpp> +#include <utility> namespace Mantid { namespace Algorithms { @@ -82,12 +83,11 @@ void ChangeTimeZero::exec() { // Set up remaining progress points const double progressStartShiftTimeLogs = progressStopCreateOutputWs; - double progressStopShiftTimeLogs = progressStartShiftTimeLogs; - if (boost::dynamic_pointer_cast<Mantid::API::IEventWorkspace>(out_ws)) { - progressStopShiftTimeLogs = progressStartShiftTimeLogs + 0.1; - } else { - progressStopShiftTimeLogs = 1.0; - } + + double progressStopShiftTimeLogs = + boost::dynamic_pointer_cast<Mantid::API::IEventWorkspace>(out_ws) + ? progressStartShiftTimeLogs + 0.1 + : 1.0; const double progressStartShiftNeutrons = progressStopShiftTimeLogs; const double progressStopShiftNeutrons = 1.0; @@ -112,7 +112,7 @@ void ChangeTimeZero::exec() { * @returns :: pointer to the outputworkspace */ API::MatrixWorkspace_sptr -ChangeTimeZero::createOutputWS(API::MatrixWorkspace_sptr input, +ChangeTimeZero::createOutputWS(const API::MatrixWorkspace_sptr &input, double startProgress, double stopProgress) { MatrixWorkspace_sptr output = getProperty("OutputWorkspace"); // Check whether input == output to see whether a new workspace is required. @@ -135,13 +135,13 @@ ChangeTimeZero::createOutputWS(API::MatrixWorkspace_sptr input, * @param ws :: a workspace with time stamp information * @returns A time shift in seconds */ -double ChangeTimeZero::getTimeShift(API::MatrixWorkspace_sptr ws) const { +double ChangeTimeZero::getTimeShift(const API::MatrixWorkspace_sptr &ws) const { auto timeShift = m_defaultTimeShift; // Check if we are dealing with an absolute time std::string timeOffset = getProperty("AbsoluteTimeOffset"); if (isAbsoluteTimeShift(timeOffset)) { DateAndTime desiredTime(timeOffset); - DateAndTime originalTime(getStartTimeFromWorkspace(ws)); + DateAndTime originalTime(getStartTimeFromWorkspace(std::move(ws))); timeShift = DateAndTime::secondsFromDuration(desiredTime - originalTime); } else { timeShift = getProperty("RelativeTimeOffset"); @@ -156,9 +156,9 @@ double ChangeTimeZero::getTimeShift(API::MatrixWorkspace_sptr ws) const { * @param startProgress :: start point of the progress * @param stopProgress :: end point of the progress */ -void ChangeTimeZero::shiftTimeOfLogs(Mantid::API::MatrixWorkspace_sptr ws, - double timeShift, double startProgress, - double stopProgress) { +void ChangeTimeZero::shiftTimeOfLogs( + const Mantid::API::MatrixWorkspace_sptr &ws, double timeShift, + double startProgress, double stopProgress) { // We need to change the entries for each log which can be: // 1. any time series: here we change the time values // 2. string properties: here we change the values if they are ISO8601 times @@ -184,7 +184,7 @@ void ChangeTimeZero::shiftTimeOfLogs(Mantid::API::MatrixWorkspace_sptr ws, * @param timeShift :: the time shift in seconds */ void ChangeTimeZero::shiftTimeInLogForTimeSeries( - Mantid::API::MatrixWorkspace_sptr ws, Mantid::Kernel::Property *prop, + const Mantid::API::MatrixWorkspace_sptr &ws, Mantid::Kernel::Property *prop, double timeShift) const { if (auto timeSeries = dynamic_cast<Mantid::Kernel::ITimeSeriesProperty *>(prop)) { @@ -216,9 +216,9 @@ void ChangeTimeZero::shiftTimeOfLogForStringProperty( * @param startProgress :: start point of the progress * @param stopProgress :: end point of the progress */ -void ChangeTimeZero::shiftTimeOfNeutrons(Mantid::API::MatrixWorkspace_sptr ws, - double timeShift, double startProgress, - double stopProgress) { +void ChangeTimeZero::shiftTimeOfNeutrons( + const Mantid::API::MatrixWorkspace_sptr &ws, double timeShift, + double startProgress, double stopProgress) { if (auto eventWs = boost::dynamic_pointer_cast<Mantid::API::IEventWorkspace>(ws)) { // Use the change pulse time algorithm to change the neutron time stamp @@ -237,8 +237,8 @@ void ChangeTimeZero::shiftTimeOfNeutrons(Mantid::API::MatrixWorkspace_sptr ws, * @param ws :: a workspace * @returns the date and time of the first good frame */ -DateAndTime -ChangeTimeZero::getStartTimeFromWorkspace(API::MatrixWorkspace_sptr ws) const { +DateAndTime ChangeTimeZero::getStartTimeFromWorkspace( + const API::MatrixWorkspace_sptr &ws) const { auto run = ws->run(); // Check for the first good frame in the log Mantid::Kernel::TimeSeriesProperty<double> *goodFrame = nullptr; @@ -318,7 +318,7 @@ std::map<std::string, std::string> ChangeTimeZero::validateInputs() { * @param val :: value to check * @return True if the string can be cast to double and otherwise false. */ -bool ChangeTimeZero::checkForDouble(std::string val) const { +bool ChangeTimeZero::checkForDouble(const std::string &val) const { auto isDouble = false; try { boost::lexical_cast<double>(val); diff --git a/Framework/Algorithms/src/CompareWorkspaces.cpp b/Framework/Algorithms/src/CompareWorkspaces.cpp index abeba3b054afba854555568e88629217ac4852e5..156043256c193b0c8571b16a52999a0a4764181e 100644 --- a/Framework/Algorithms/src/CompareWorkspaces.cpp +++ b/Framework/Algorithms/src/CompareWorkspaces.cpp @@ -262,8 +262,8 @@ bool CompareWorkspaces::processGroups() { * @param groupTwo */ void CompareWorkspaces::processGroups( - boost::shared_ptr<const API::WorkspaceGroup> groupOne, - boost::shared_ptr<const API::WorkspaceGroup> groupTwo) { + const boost::shared_ptr<const API::WorkspaceGroup> &groupOne, + const boost::shared_ptr<const API::WorkspaceGroup> &groupTwo) { // Check their sizes const auto totalNum = static_cast<size_t>(groupOne->getNumberOfEntries()); @@ -618,8 +618,8 @@ bool CompareWorkspaces::compareEventWorkspaces( * @retval true The data matches * @retval false The data does not matches */ -bool CompareWorkspaces::checkData(API::MatrixWorkspace_const_sptr ws1, - API::MatrixWorkspace_const_sptr ws2) { +bool CompareWorkspaces::checkData(const API::MatrixWorkspace_const_sptr &ws1, + const API::MatrixWorkspace_const_sptr &ws2) { // Cache a few things for later use const size_t numHists = ws1->getNumberHistograms(); const size_t numBins = ws1->blocksize(); @@ -712,8 +712,8 @@ bool CompareWorkspaces::checkData(API::MatrixWorkspace_const_sptr ws1, * @retval true The axes match * @retval false The axes do not match */ -bool CompareWorkspaces::checkAxes(API::MatrixWorkspace_const_sptr ws1, - API::MatrixWorkspace_const_sptr ws2) { +bool CompareWorkspaces::checkAxes(const API::MatrixWorkspace_const_sptr &ws1, + const API::MatrixWorkspace_const_sptr &ws2) { const int numAxes = ws1->axes(); if (numAxes != ws2->axes()) { @@ -790,8 +790,8 @@ bool CompareWorkspaces::checkAxes(API::MatrixWorkspace_const_sptr ws1, /// @param ws2 :: the second sp det map /// @retval true The maps match /// @retval false The maps do not match -bool CompareWorkspaces::checkSpectraMap(MatrixWorkspace_const_sptr ws1, - MatrixWorkspace_const_sptr ws2) { +bool CompareWorkspaces::checkSpectraMap(const MatrixWorkspace_const_sptr &ws1, + const MatrixWorkspace_const_sptr &ws2) { if (ws1->getNumberHistograms() != ws2->getNumberHistograms()) { recordMismatch("Number of spectra mismatch"); return false; @@ -832,8 +832,9 @@ bool CompareWorkspaces::checkSpectraMap(MatrixWorkspace_const_sptr ws1, /// @param ws2 :: the second workspace /// @retval true The instruments match /// @retval false The instruments do not match -bool CompareWorkspaces::checkInstrument(API::MatrixWorkspace_const_sptr ws1, - API::MatrixWorkspace_const_sptr ws2) { +bool CompareWorkspaces::checkInstrument( + const API::MatrixWorkspace_const_sptr &ws1, + const API::MatrixWorkspace_const_sptr &ws2) { // First check the name matches if (ws1->getInstrument()->getName() != ws2->getInstrument()->getName()) { g_log.debug() << "Instrument names: WS1 = " @@ -871,8 +872,9 @@ bool CompareWorkspaces::checkInstrument(API::MatrixWorkspace_const_sptr ws1, /// @param ws2 :: the second workspace /// @retval true The masking matches /// @retval false The masking does not match -bool CompareWorkspaces::checkMasking(API::MatrixWorkspace_const_sptr ws1, - API::MatrixWorkspace_const_sptr ws2) { +bool CompareWorkspaces::checkMasking( + const API::MatrixWorkspace_const_sptr &ws1, + const API::MatrixWorkspace_const_sptr &ws2) { const auto numHists = static_cast<int>(ws1->getNumberHistograms()); for (int i = 0; i < numHists; ++i) { @@ -1111,8 +1113,8 @@ void CompareWorkspaces::doPeaksComparison(PeaksWorkspace_sptr tws1, //------------------------------------------------------------------------------------------------ void CompareWorkspaces::doTableComparison( - API::ITableWorkspace_const_sptr tws1, - API::ITableWorkspace_const_sptr tws2) { + const API::ITableWorkspace_const_sptr &tws1, + const API::ITableWorkspace_const_sptr &tws2) { // First the easy things const auto numCols = tws1->columnCount(); if (numCols != tws2->columnCount()) { @@ -1177,7 +1179,8 @@ void CompareWorkspaces::doTableComparison( } //------------------------------------------------------------------------------------------------ -void CompareWorkspaces::doMDComparison(Workspace_sptr w1, Workspace_sptr w2) { +void CompareWorkspaces::doMDComparison(const Workspace_sptr &w1, + const Workspace_sptr &w2) { IMDWorkspace_sptr mdws1, mdws2; mdws1 = boost::dynamic_pointer_cast<IMDWorkspace>(w1); mdws2 = boost::dynamic_pointer_cast<IMDWorkspace>(w2); @@ -1204,7 +1207,7 @@ void CompareWorkspaces::doMDComparison(Workspace_sptr w1, Workspace_sptr w2) { * @param ws1 Name of first workspace being compared * @param ws2 Name of second workspace being compared */ -void CompareWorkspaces::recordMismatch(std::string msg, std::string ws1, +void CompareWorkspaces::recordMismatch(const std::string &msg, std::string ws1, std::string ws2) { // Workspace names default to the workspaces currently being compared if (ws1.empty()) { diff --git a/Framework/Algorithms/src/ConjoinXRuns.cpp b/Framework/Algorithms/src/ConjoinXRuns.cpp index 6af9ed086e1d9e74263b9372839a4b1535ac6de0..aa1ef64161227ec8ee7f330b940102d32d64689b 100644 --- a/Framework/Algorithms/src/ConjoinXRuns.cpp +++ b/Framework/Algorithms/src/ConjoinXRuns.cpp @@ -198,7 +198,7 @@ std::map<std::string, std::string> ConjoinXRuns::validateInputs() { * @return : empty if the log exists, is numeric, and matches the size of the * workspace, error message otherwise */ -std::string ConjoinXRuns::checkLogEntry(MatrixWorkspace_sptr ws) const { +std::string ConjoinXRuns::checkLogEntry(const MatrixWorkspace_sptr &ws) const { std::string result; if (!m_logEntry.empty()) { @@ -250,7 +250,8 @@ std::string ConjoinXRuns::checkLogEntry(MatrixWorkspace_sptr ws) const { * @param ws : the input workspace * @return : the x-axis to use for the output workspace */ -std::vector<double> ConjoinXRuns::getXAxis(MatrixWorkspace_sptr ws) const { +std::vector<double> +ConjoinXRuns::getXAxis(const MatrixWorkspace_sptr &ws) const { std::vector<double> axis; axis.reserve(ws->y(0).size()); @@ -403,7 +404,7 @@ void ConjoinXRuns::exec() { << ". Reason: \"" << e.what() << "\". Skipping.\n"; sampleLogsBehaviour.resetSampleLogs(temp); // remove the skipped one from the list - m_inputWS.erase(it); + it = m_inputWS.erase(it); --it; } else { throw std::invalid_argument(e); diff --git a/Framework/Algorithms/src/ConvertDiffCal.cpp b/Framework/Algorithms/src/ConvertDiffCal.cpp index 988c023d2488a7f7717c2f1a5a52af530feb8839..a8c0718a3f566b5c161565732086765b6e9f0b1d 100644 --- a/Framework/Algorithms/src/ConvertDiffCal.cpp +++ b/Framework/Algorithms/src/ConvertDiffCal.cpp @@ -69,7 +69,8 @@ void ConvertDiffCal::init() { * @param index * @return The proper detector id. */ -detid_t getDetID(OffsetsWorkspace_const_sptr offsetsWS, const size_t index) { +detid_t getDetID(const OffsetsWorkspace_const_sptr &offsetsWS, + const size_t index) { auto detIDs = offsetsWS->getSpectrum(index).getDetectorIDs(); if (detIDs.size() != 1) { std::stringstream msg; @@ -86,7 +87,8 @@ detid_t getDetID(OffsetsWorkspace_const_sptr offsetsWS, const size_t index) { * @param detid * @return The offset value or zero if not specified. */ -double getOffset(OffsetsWorkspace_const_sptr offsetsWS, const detid_t detid) { +double getOffset(const OffsetsWorkspace_const_sptr &offsetsWS, + const detid_t detid) { const double offset = offsetsWS->getValue(detid, 0.0); if (offset <= -1.) { // non-physical std::stringstream msg; @@ -104,7 +106,8 @@ double getOffset(OffsetsWorkspace_const_sptr offsetsWS, const detid_t detid) { * @param spectrumInfo * @return The offset adjusted value of DIFC */ -double calculateDIFC(OffsetsWorkspace_const_sptr offsetsWS, const size_t index, +double calculateDIFC(const OffsetsWorkspace_const_sptr &offsetsWS, + const size_t index, const Mantid::API::SpectrumInfo &spectrumInfo) { const detid_t detid = getDetID(offsetsWS, index); const double offset = getOffset(offsetsWS, detid); diff --git a/Framework/Algorithms/src/ConvertEmptyToTof.cpp b/Framework/Algorithms/src/ConvertEmptyToTof.cpp index 2a462a7bd7503969c2bfef90189716ef914d9885..70dd3af9bf6a278de0d8eed1fdd2a9983b08f7e7 100644 --- a/Framework/Algorithms/src/ConvertEmptyToTof.cpp +++ b/Framework/Algorithms/src/ConvertEmptyToTof.cpp @@ -500,7 +500,7 @@ std::vector<double> ConvertEmptyToTof::makeTofAxis(int epp, double epTof, } void ConvertEmptyToTof::setTofInWS(const std::vector<double> &tofAxis, - API::MatrixWorkspace_sptr outputWS) { + const API::MatrixWorkspace_sptr &outputWS) { const size_t numberOfSpectra = m_inputWS->getNumberHistograms(); diff --git a/Framework/Algorithms/src/ConvertSpectrumAxis.cpp b/Framework/Algorithms/src/ConvertSpectrumAxis.cpp index a3d5eda58629a8b568bbf0a36bfd2899f06a7678..4445fa6829efb517574a111caec27dd2628a7f95 100644 --- a/Framework/Algorithms/src/ConvertSpectrumAxis.cpp +++ b/Framework/Algorithms/src/ConvertSpectrumAxis.cpp @@ -186,7 +186,7 @@ void ConvertSpectrumAxis::exec() { double ConvertSpectrumAxis::getEfixed(const Mantid::Geometry::IDetector &detector, - MatrixWorkspace_const_sptr inputWS, + const MatrixWorkspace_const_sptr &inputWS, int emode) const { double efixed(0); double efixedProp = getProperty("Efixed"); diff --git a/Framework/Algorithms/src/ConvertSpectrumAxis2.cpp b/Framework/Algorithms/src/ConvertSpectrumAxis2.cpp index eaba2ca93a9f32bcf79ae8607132532aa28f0808..f224599c47acf85b47b190ed7c49cbdf9b3885c5 100644 --- a/Framework/Algorithms/src/ConvertSpectrumAxis2.cpp +++ b/Framework/Algorithms/src/ConvertSpectrumAxis2.cpp @@ -238,9 +238,10 @@ MatrixWorkspace_sptr ConvertSpectrumAxis2::createOutputWorkspace( create<MatrixWorkspace>(*inputWS, m_indexMap.size(), hist); std::vector<double> axis; axis.reserve(m_indexMap.size()); - for (const auto &it : m_indexMap) { - axis.emplace_back(it.first); - } + std::transform(m_indexMap.begin(), m_indexMap.end(), + std::back_inserter(axis), + [](const auto &it) { return it.first; }); + newAxis = std::make_unique<NumericAxis>(std::move(axis)); } else { // If there is no reordering we can simply clone. diff --git a/Framework/Algorithms/src/ConvertToConstantL2.cpp b/Framework/Algorithms/src/ConvertToConstantL2.cpp index d49e9e967504774b4d6b4b670e4468297d786376..d863ded28228c97068ed78e99a214fa2e8bd0f7e 100644 --- a/Framework/Algorithms/src/ConvertToConstantL2.cpp +++ b/Framework/Algorithms/src/ConvertToConstantL2.cpp @@ -141,7 +141,7 @@ void ConvertToConstantL2::exec() { * @s - input property name * */ -double ConvertToConstantL2::getRunProperty(std::string s) { +double ConvertToConstantL2::getRunProperty(const std::string &s) { const auto &run = m_inputWS->run(); if (!run.hasProperty(s)) { throw Exception::NotFoundError("Sample log property not found", s); @@ -160,7 +160,7 @@ double ConvertToConstantL2::getRunProperty(std::string s) { * @s - input property name * */ -double ConvertToConstantL2::getInstrumentProperty(std::string s) { +double ConvertToConstantL2::getInstrumentProperty(const std::string &s) { std::vector<std::string> prop = m_instrument->getStringParameter(s); if (prop.empty()) { const std::string mesg = "Property <" + s + "> doesn't exist!"; diff --git a/Framework/Algorithms/src/ConvertUnits.cpp b/Framework/Algorithms/src/ConvertUnits.cpp index df6cb856adb21f062998de1318052a535cc33c05..fd8d9fbe29039bdcb683ca6a7f24e4884432f50d 100644 --- a/Framework/Algorithms/src/ConvertUnits.cpp +++ b/Framework/Algorithms/src/ConvertUnits.cpp @@ -186,7 +186,7 @@ void ConvertUnits::exec() { * @return A pointer to a MatrixWorkspace_sptr that contains the converted units */ MatrixWorkspace_sptr -ConvertUnits::executeUnitConversion(const API::MatrixWorkspace_sptr inputWS) { +ConvertUnits::executeUnitConversion(const API::MatrixWorkspace_sptr &inputWS) { // A WS holding BinEdges cannot have less than 2 values, as a bin has // 2 edges, having less than 2 values would mean that the WS contains Points @@ -251,7 +251,7 @@ ConvertUnits::executeUnitConversion(const API::MatrixWorkspace_sptr inputWS) { * @param inputWS The input workspace */ void ConvertUnits::setupMemberVariables( - const API::MatrixWorkspace_const_sptr inputWS) { + const API::MatrixWorkspace_const_sptr &inputWS) { m_numberOfSpectra = inputWS->getNumberHistograms(); // In the context of this algorithm, we treat things as a distribution if // the flag is set AND the data are not dimensionless @@ -271,7 +271,7 @@ void ConvertUnits::setupMemberVariables( * @param inputWS The input workspace */ API::MatrixWorkspace_sptr ConvertUnits::setupOutputWorkspace( - const API::MatrixWorkspace_const_sptr inputWS) { + const API::MatrixWorkspace_const_sptr &inputWS) { MatrixWorkspace_sptr outputWS = getProperty("OutputWorkspace"); // If input and output workspaces are NOT the same, create a new workspace @@ -328,7 +328,7 @@ void ConvertUnits::storeEModeOnWorkspace(API::MatrixWorkspace_sptr outputWS) { * @returns A shared pointer to the output workspace */ MatrixWorkspace_sptr -ConvertUnits::convertQuickly(API::MatrixWorkspace_const_sptr inputWS, +ConvertUnits::convertQuickly(const API::MatrixWorkspace_const_sptr &inputWS, const double &factor, const double &power) { Progress prog(this, 0.2, 1.0, m_numberOfSpectra); auto numberOfSpectra_i = @@ -603,7 +603,7 @@ ConvertUnits::convertViaTOF(Kernel::Unit_const_sptr fromUnit, /// Calls Rebin as a Child Algorithm to align the bins API::MatrixWorkspace_sptr -ConvertUnits::alignBins(API::MatrixWorkspace_sptr workspace) { +ConvertUnits::alignBins(const API::MatrixWorkspace_sptr &workspace) { if (communicator().size() != 1) throw std::runtime_error( "ConvertUnits: Parallel support for aligning bins not implemented."); @@ -623,7 +623,7 @@ ConvertUnits::alignBins(API::MatrixWorkspace_sptr workspace) { /// The Rebin parameters should cover the full range of the converted unit, /// with the same number of bins const std::vector<double> ConvertUnits::calculateRebinParams( - const API::MatrixWorkspace_const_sptr workspace) const { + const API::MatrixWorkspace_const_sptr &workspace) const { const auto &spectrumInfo = workspace->spectrumInfo(); // Need to loop round and find the full range double XMin = DBL_MAX, XMax = DBL_MIN; @@ -650,7 +650,7 @@ const std::vector<double> ConvertUnits::calculateRebinParams( /** Reverses the workspace if X values are in descending order * @param WS The workspace to operate on */ -void ConvertUnits::reverse(API::MatrixWorkspace_sptr WS) { +void ConvertUnits::reverse(const API::MatrixWorkspace_sptr &WS) { EventWorkspace_sptr eventWS = boost::dynamic_pointer_cast<EventWorkspace>(WS); auto isInputEvents = static_cast<bool>(eventWS); size_t numberOfSpectra = WS->getNumberHistograms(); @@ -700,7 +700,7 @@ void ConvertUnits::reverse(API::MatrixWorkspace_sptr WS) { * @return The workspace after bins have been removed */ API::MatrixWorkspace_sptr ConvertUnits::removeUnphysicalBins( - const Mantid::API::MatrixWorkspace_const_sptr workspace) { + const Mantid::API::MatrixWorkspace_const_sptr &workspace) { MatrixWorkspace_sptr result; const auto &spectrumInfo = workspace->spectrumInfo(); @@ -786,7 +786,7 @@ API::MatrixWorkspace_sptr ConvertUnits::removeUnphysicalBins( /** Divide by the bin width if workspace is a distribution * @param outputWS The workspace to operate on */ -void ConvertUnits::putBackBinWidth(const API::MatrixWorkspace_sptr outputWS) { +void ConvertUnits::putBackBinWidth(const API::MatrixWorkspace_sptr &outputWS) { const size_t outSize = outputWS->blocksize(); for (size_t i = 0; i < m_numberOfSpectra; ++i) { diff --git a/Framework/Algorithms/src/CopyDataRange.cpp b/Framework/Algorithms/src/CopyDataRange.cpp index f7d36388c84a8458600780d3b960aaa2388b71ae..1697ef5f70d78264c65b6b1c2b41a93fc3f5a932 100644 --- a/Framework/Algorithms/src/CopyDataRange.cpp +++ b/Framework/Algorithms/src/CopyDataRange.cpp @@ -11,6 +11,7 @@ #include "MantidKernel/BoundedValidator.h" #include <algorithm> +#include <utility> using namespace Mantid::API; using namespace Mantid::Kernel; @@ -18,9 +19,9 @@ using namespace Mantid::HistogramData; namespace { -void copyDataRange(MatrixWorkspace_const_sptr inputWorkspace, - MatrixWorkspace_sptr destWorkspace, int const &specMin, - int const &specMax, int const &xMinIndex, +void copyDataRange(const MatrixWorkspace_const_sptr &inputWorkspace, + const MatrixWorkspace_sptr &destWorkspace, + int const &specMin, int const &specMax, int const &xMinIndex, int const &xMaxIndex, int yInsertionIndex, int const &xInsertionIndex) { for (auto specIndex = specMin; specIndex <= specMax; ++specIndex) { @@ -36,17 +37,18 @@ void copyDataRange(MatrixWorkspace_const_sptr inputWorkspace, } } -void copyDataRange(MatrixWorkspace_const_sptr inputWorkspace, - MatrixWorkspace_sptr destWorkspace, int const &specMin, - int const &specMax, double const &xMin, double const &xMax, - int yInsertionIndex, int const &xInsertionIndex) { +void copyDataRange(const MatrixWorkspace_const_sptr &inputWorkspace, + const MatrixWorkspace_sptr &destWorkspace, + int const &specMin, int const &specMax, double const &xMin, + double const &xMax, int yInsertionIndex, + int const &xInsertionIndex) { auto const xMinIndex = static_cast<int>(inputWorkspace->yIndexOfX(xMin, 0, 0.000001)); auto const xMaxIndex = static_cast<int>(inputWorkspace->yIndexOfX(xMax, 0, 0.000001)); - copyDataRange(inputWorkspace, destWorkspace, specMin, specMax, xMinIndex, - xMaxIndex, yInsertionIndex, xInsertionIndex); + copyDataRange(inputWorkspace, std::move(destWorkspace), specMin, specMax, + xMinIndex, xMaxIndex, yInsertionIndex, xInsertionIndex); } } // namespace diff --git a/Framework/Algorithms/src/CorelliCrossCorrelate.cpp b/Framework/Algorithms/src/CorelliCrossCorrelate.cpp index 5ee37f06a77ae99bb2a378a176af7e29262c2332..2916214366385107feb4465ffc8f55176c51b85a 100644 --- a/Framework/Algorithms/src/CorelliCrossCorrelate.cpp +++ b/Framework/Algorithms/src/CorelliCrossCorrelate.cpp @@ -157,8 +157,9 @@ void CorelliCrossCorrelate::exec() { int offset_int = getProperty("TimingOffset"); const auto offset = static_cast<int64_t>(offset_int); - for (auto &timing : tdc) - timing += offset; + + std::transform(tdc.begin(), tdc.end(), tdc.begin(), + [offset](auto timing) { return timing + offset; }); // Determine period from chopper frequency. auto motorSpeed = dynamic_cast<TimeSeriesProperty<double> *>( diff --git a/Framework/Algorithms/src/CorrectKiKf.cpp b/Framework/Algorithms/src/CorrectKiKf.cpp index 4c7d5f401a2700cb5e8a91a3181ff25b94f3dd09..c4b97099dc2fc3dc5c0859667971677049fc0ba6 100644 --- a/Framework/Algorithms/src/CorrectKiKf.cpp +++ b/Framework/Algorithms/src/CorrectKiKf.cpp @@ -220,11 +220,10 @@ void CorrectKiKf::execEvent() { PARALLEL_FOR_IF(Kernel::threadSafe(*outputWS)) for (int64_t i = 0; i < numHistograms; ++i) { PARALLEL_START_INTERUPT_REGION - - double Efi = 0; // Now get the detector object for this histogram to check if monitor // or to get Ef for indirect geometry if (emodeStr == "Indirect") { + double Efi = 0; if (efixedProp != EMPTY_DBL()) { Efi = efixedProp; // If a DetectorGroup is present should provide a value as a property @@ -279,7 +278,7 @@ void CorrectKiKf::execEvent() { template <class T> void CorrectKiKf::correctKiKfEventHelper(std::vector<T> &wevector, double efixed, - const std::string emodeStr) { + const std::string &emodeStr) { double Ei, Ef; float kioverkf; typename std::vector<T>::iterator it; diff --git a/Framework/Algorithms/src/CorrectTOFAxis.cpp b/Framework/Algorithms/src/CorrectTOFAxis.cpp index 804ec046dd07a2821332b116511fdd2d90bec2ca..c6840afcdee04eb9d86d19c62e35dc39694a7480 100644 --- a/Framework/Algorithms/src/CorrectTOFAxis.cpp +++ b/Framework/Algorithms/src/CorrectTOFAxis.cpp @@ -105,7 +105,7 @@ template <typename Map> size_t mapIndex(const int index, const Map &indexMap) { * @return A workspace index corresponding to index. */ size_t toWorkspaceIndex(const int index, const std::string &indexType, - API::MatrixWorkspace_const_sptr ws) { + const API::MatrixWorkspace_const_sptr &ws) { if (indexType == IndexTypes::DETECTOR_ID) { const auto indexMap = ws->getDetectorIDToWorkspaceIndexMap(); return mapIndex(index, indexMap); @@ -345,7 +345,8 @@ void CorrectTOFAxis::exec() { * corrected workspace. * @param outputWs The corrected workspace */ -void CorrectTOFAxis::useReferenceWorkspace(API::MatrixWorkspace_sptr outputWs) { +void CorrectTOFAxis::useReferenceWorkspace( + const API::MatrixWorkspace_sptr &outputWs) { const auto histogramCount = static_cast<int64_t>(m_referenceWs->getNumberHistograms()); PARALLEL_FOR_IF(threadSafe(*m_referenceWs, *outputWs)) @@ -377,7 +378,8 @@ void CorrectTOFAxis::useReferenceWorkspace(API::MatrixWorkspace_sptr outputWs) { * specifically, also adjusts the 'Ei' and 'wavelength' sample logs. * @param outputWs The corrected workspace */ -void CorrectTOFAxis::correctManually(API::MatrixWorkspace_sptr outputWs) { +void CorrectTOFAxis::correctManually( + const API::MatrixWorkspace_sptr &outputWs) { const auto &spectrumInfo = m_inputWs->spectrumInfo(); const double l1 = spectrumInfo.l1(); double l2 = 0; diff --git a/Framework/Algorithms/src/CorrectToFile.cpp b/Framework/Algorithms/src/CorrectToFile.cpp index a45c30bfadf39337a78ca9105230a41641145f92..8c426ffa0f5a0121d24041ff1ae316ff8b079137 100644 --- a/Framework/Algorithms/src/CorrectToFile.cpp +++ b/Framework/Algorithms/src/CorrectToFile.cpp @@ -186,8 +186,8 @@ MatrixWorkspace_sptr CorrectToFile::loadInFile(const std::string &corrFile) { * @throw NotFoundError if requested algorithm requested doesn't exist * @throw runtime_error if algorithm encounters an error */ -void CorrectToFile::doWkspAlgebra(API::MatrixWorkspace_sptr lhs, - API::MatrixWorkspace_sptr rhs, +void CorrectToFile::doWkspAlgebra(const API::MatrixWorkspace_sptr &lhs, + const API::MatrixWorkspace_sptr &rhs, const std::string &algName, API::MatrixWorkspace_sptr &result) { g_log.information() << "Initalising the algorithm " << algName << '\n'; diff --git a/Framework/Algorithms/src/CreateDummyCalFile.cpp b/Framework/Algorithms/src/CreateDummyCalFile.cpp index 5fd56a26e748e37008789383501d5c43a461ad4d..afa35e62f7bdbe3bc9c14a3b6eae47a8a534512d 100644 --- a/Framework/Algorithms/src/CreateDummyCalFile.cpp +++ b/Framework/Algorithms/src/CreateDummyCalFile.cpp @@ -110,9 +110,6 @@ void CreateDummyCalFile::exec() { std::string filename = getProperty("CalFilename"); - // Plan to overwrite file, so do not check if it exists - const bool overwrite = false; - int number = 0; Progress prog(this, 0.0, 0.8, assemblies.size()); while (!assemblies.empty()) // Travel the tree from the instrument point @@ -128,12 +125,7 @@ void CreateDummyCalFile::exec() { currentIComp); if (currentDet.get()) // Is detector { - if (overwrite) // Map will contains udet as the key - instrcalib[currentDet->getID()] = - std::make_pair(number++, top_group); - else // Map will contains the entry number as the key - instrcalib[number++] = - std::make_pair(currentDet->getID(), top_group); + instrcalib[number++] = std::make_pair(currentDet->getID(), top_group); } else // Is an assembly, push in the queue { currentchild = @@ -151,6 +143,8 @@ void CreateDummyCalFile::exec() { prog.report(); } // Write the results in a file + // Plan to overwrite file, so do not check if it exists + const bool overwrite = false; saveGroupingFile(filename, overwrite); progress(0.2); } diff --git a/Framework/Algorithms/src/CreateEPP.cpp b/Framework/Algorithms/src/CreateEPP.cpp index 285b6743a131fa0308f5f455c4d0142f35e34f9a..0efb5dc39549f1133941f5dec5dece08eeb8ed12 100644 --- a/Framework/Algorithms/src/CreateEPP.cpp +++ b/Framework/Algorithms/src/CreateEPP.cpp @@ -49,7 +49,7 @@ const static std::string STATUS("FitStatus"); * * @param ws The TableWorkspace to add the columns to. */ -void addEPPColumns(API::ITableWorkspace_sptr ws) { +void addEPPColumns(const API::ITableWorkspace_sptr &ws) { ws->addColumn("int", ColumnNames::WS_INDEX); ws->addColumn("double", ColumnNames::PEAK_CENTRE); ws->addColumn("double", ColumnNames::PEAK_CENTRE_ERR); diff --git a/Framework/Algorithms/src/CreateFloodWorkspace.cpp b/Framework/Algorithms/src/CreateFloodWorkspace.cpp index 6d281c5b536574024d7c94fb1d90bbfea6a8b6ef..c7099c8ccc6226ccfbe99f822c20cc99ac38ceee 100644 --- a/Framework/Algorithms/src/CreateFloodWorkspace.cpp +++ b/Framework/Algorithms/src/CreateFloodWorkspace.cpp @@ -129,7 +129,8 @@ std::string CreateFloodWorkspace::getBackgroundFunction() { return funMap.at(getPropertyValue(Prop::BACKGROUND)); } -MatrixWorkspace_sptr CreateFloodWorkspace::integrate(MatrixWorkspace_sptr ws) { +MatrixWorkspace_sptr +CreateFloodWorkspace::integrate(const MatrixWorkspace_sptr &ws) { auto alg = createChildAlgorithm("Integration"); alg->setProperty("InputWorkspace", ws); alg->setProperty("OutputWorkspace", "dummy"); @@ -145,7 +146,8 @@ MatrixWorkspace_sptr CreateFloodWorkspace::integrate(MatrixWorkspace_sptr ws) { return alg->getProperty("OutputWorkspace"); } -MatrixWorkspace_sptr CreateFloodWorkspace::transpose(MatrixWorkspace_sptr ws) { +MatrixWorkspace_sptr +CreateFloodWorkspace::transpose(const MatrixWorkspace_sptr &ws) { auto alg = createChildAlgorithm("Transpose"); alg->setProperty("InputWorkspace", ws); alg->setProperty("OutputWorkspace", "dummy"); diff --git a/Framework/Algorithms/src/CreateGroupingWorkspace.cpp b/Framework/Algorithms/src/CreateGroupingWorkspace.cpp index 05cfbd7ce3a6808e63216e1b539e08ea55a47a39..14db984fea74fc7e7ca82163aa94aa3494488eb7 100644 --- a/Framework/Algorithms/src/CreateGroupingWorkspace.cpp +++ b/Framework/Algorithms/src/CreateGroupingWorkspace.cpp @@ -19,6 +19,7 @@ #include <boost/algorithm/string/trim.hpp> #include <fstream> #include <queue> +#include <utility> namespace { Mantid::Kernel::Logger g_log("CreateGroupingWorkspace"); @@ -207,10 +208,9 @@ std::map<detid_t, int> readGroupingFile(const std::string &groupingFileName, * @param prog Progress reporter * @returns :: Map of detector IDs to group number */ -std::map<detid_t, int> makeGroupingByNumGroups(const std::string compName, - int numGroups, - Instrument_const_sptr inst, - Progress &prog) { +std::map<detid_t, int> +makeGroupingByNumGroups(const std::string &compName, int numGroups, + const Instrument_const_sptr &inst, Progress &prog) { std::map<detid_t, int> detIDtoGroup; // Get detectors for given instument component @@ -250,14 +250,14 @@ std::map<detid_t, int> makeGroupingByNumGroups(const std::string compName, bool groupnumber(std::string groupi, std::string groupj) { int i = 0; - std::string groupName = groupi; + std::string groupName = std::move(groupi); // Take out the "group" part of the group name and convert to an int groupName.erase( remove_if(groupName.begin(), groupName.end(), std::not_fn(::isdigit)), groupName.end()); Strings::convert(groupName, i); int j = 0; - groupName = groupj; + groupName = std::move(groupj); // Take out the "group" part of the group name and convert to an int groupName.erase( remove_if(groupName.begin(), groupName.end(), std::not_fn(::isdigit)), @@ -276,7 +276,7 @@ bool groupnumber(std::string groupi, std::string groupj) { * @returns:: map of detID to group number */ std::map<detid_t, int> makeGroupingByNames(std::string GroupNames, - Instrument_const_sptr inst, + const Instrument_const_sptr &inst, Progress &prog, bool sortnames) { // This will contain the grouping std::map<detid_t, int> detIDtoGroup; @@ -432,7 +432,6 @@ void CreateGroupingWorkspace::exec() { sortnames = true; GroupNames = ""; int maxRecurseDepth = this->getProperty("MaxRecursionDepth"); - // cppcheck-suppress syntaxError PRAGMA_OMP(parallel for schedule(dynamic, 1) ) for (int num = 0; num < 300; ++num) { diff --git a/Framework/Algorithms/src/CreateLogPropertyTable.cpp b/Framework/Algorithms/src/CreateLogPropertyTable.cpp index 7b67c9e232b3f0fbd2f740f30c5b3f687041c4af..ab9cda98e3862ba327ba05bdab86b5418123cd9f 100644 --- a/Framework/Algorithms/src/CreateLogPropertyTable.cpp +++ b/Framework/Algorithms/src/CreateLogPropertyTable.cpp @@ -195,9 +195,12 @@ retrieveMatrixWsList(const std::vector<std::string> &wsNames, // Retrieve pointers to all the child workspaces. std::vector<MatrixWorkspace_sptr> childWsList; childWsList.reserve(childNames.size()); - for (const auto &childName : childNames) { - childWsList.emplace_back(ADS.retrieveWS<MatrixWorkspace>(childName)); - } + + std::transform(childNames.begin(), childNames.end(), + std::back_inserter(childWsList), + [&ADS](const auto &childName) { + return ADS.retrieveWS<MatrixWorkspace>(childName); + }); // Deal with child workspaces according to policy. switch (groupPolicy) { diff --git a/Framework/Algorithms/src/CreateLogTimeCorrection.cpp b/Framework/Algorithms/src/CreateLogTimeCorrection.cpp index 98618d4b31c737972dfa16c4722359cf12dc0c4c..9eed0c6079e0788f992f916f424545ff9b7a7d81 100644 --- a/Framework/Algorithms/src/CreateLogTimeCorrection.cpp +++ b/Framework/Algorithms/src/CreateLogTimeCorrection.cpp @@ -149,7 +149,7 @@ TableWorkspace_sptr CreateLogTimeCorrection::generateCorrectionTable( /** Write correction map to a text file */ void CreateLogTimeCorrection::writeCorrectionToFile( - const string filename, const Geometry::DetectorInfo &detectorInfo, + const string &filename, const Geometry::DetectorInfo &detectorInfo, const std::vector<double> &corrections) const { ofstream ofile; ofile.open(filename.c_str()); diff --git a/Framework/Algorithms/src/CreatePSDBleedMask.cpp b/Framework/Algorithms/src/CreatePSDBleedMask.cpp index 66f62ba851ffddbae94c7cbaeea06835aedad295..8b1aba621f7c5bdfa0ab9d455f1c90e87e9d528c 100644 --- a/Framework/Algorithms/src/CreatePSDBleedMask.cpp +++ b/Framework/Algorithms/src/CreatePSDBleedMask.cpp @@ -201,7 +201,7 @@ void CreatePSDBleedMask::exec() { */ bool CreatePSDBleedMask::performBleedTest( const std::vector<int> &tubeIndices, - API::MatrixWorkspace_const_sptr inputWS, double maxRate, + const API::MatrixWorkspace_const_sptr &inputWS, double maxRate, int numIgnoredPixels) { // Require ordered pixels so that we can define the centre. @@ -263,7 +263,7 @@ bool CreatePSDBleedMask::performBleedTest( * @param workspace :: The workspace to accumulate the masking */ void CreatePSDBleedMask::maskTube(const std::vector<int> &tubeIndices, - API::MatrixWorkspace_sptr workspace) { + const API::MatrixWorkspace_sptr &workspace) { const double deadValue(1.0); // delete the data for (auto tubeIndice : tubeIndices) { workspace->mutableY(tubeIndice)[0] = deadValue; diff --git a/Framework/Algorithms/src/CreateSampleWorkspace.cpp b/Framework/Algorithms/src/CreateSampleWorkspace.cpp index 42352e54aceb39f1958d23c79e828be2612b1e93..300a2842a67df0f4f8795979075a0ff3345ff693 100644 --- a/Framework/Algorithms/src/CreateSampleWorkspace.cpp +++ b/Framework/Algorithms/src/CreateSampleWorkspace.cpp @@ -309,7 +309,7 @@ void CreateSampleWorkspace::addChopperParameters( */ MatrixWorkspace_sptr CreateSampleWorkspace::createHistogramWorkspace( int numPixels, int numBins, int numMonitors, double x0, double binDelta, - Geometry::Instrument_sptr inst, const std::string &functionString, + const Geometry::Instrument_sptr &inst, const std::string &functionString, bool isRandom) { BinEdges x(numBins + 1, LinearGenerator(x0, binDelta)); @@ -330,8 +330,9 @@ MatrixWorkspace_sptr CreateSampleWorkspace::createHistogramWorkspace( /** Create scanning histogram workspace */ MatrixWorkspace_sptr CreateSampleWorkspace::createScanningWorkspace( - int numBins, double x0, double binDelta, Geometry::Instrument_sptr inst, - const std::string &functionString, bool isRandom, int numScanPoints) { + int numBins, double x0, double binDelta, + const Geometry::Instrument_sptr &inst, const std::string &functionString, + bool isRandom, int numScanPoints) { auto builder = ScanningWorkspaceBuilder(inst, numScanPoints, numBins); auto angles = std::vector<double>(); @@ -359,7 +360,7 @@ MatrixWorkspace_sptr CreateSampleWorkspace::createScanningWorkspace( */ EventWorkspace_sptr CreateSampleWorkspace::createEventWorkspace( int numPixels, int numBins, int numMonitors, int numEvents, double x0, - double binDelta, Geometry::Instrument_sptr inst, + double binDelta, const Geometry::Instrument_sptr &inst, const std::string &functionString, bool isRandom) { DateAndTime run_start("2010-01-01T00:00:00"); diff --git a/Framework/Algorithms/src/CreateTransmissionWorkspace.cpp b/Framework/Algorithms/src/CreateTransmissionWorkspace.cpp index 1a51af9c5f506c85fe783215ef6542eb52917a47..a4332c2603fa162fd8a4e7fc64ecc3c7053f0e6e 100644 --- a/Framework/Algorithms/src/CreateTransmissionWorkspace.cpp +++ b/Framework/Algorithms/src/CreateTransmissionWorkspace.cpp @@ -4,8 +4,10 @@ // NScD Oak Ridge National Laboratory, European Spallation Source, // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + -#include "MantidAlgorithms/CreateTransmissionWorkspace.h" +#include <utility> + #include "MantidAPI/BoostOptionalToAlgorithmProperty.h" +#include "MantidAlgorithms/CreateTransmissionWorkspace.h" #include "MantidAPI/AnalysisDataService.h" #include "MantidAPI/WorkspaceUnitValidator.h" @@ -154,7 +156,7 @@ MatrixWorkspace_sptr CreateTransmissionWorkspace::makeTransmissionCorrection( const OptionalMinMax &wavelengthMonitorBackgroundInterval, const OptionalMinMax &wavelengthMonitorIntegrationInterval, const OptionalInteger &i0MonitorIndex, - MatrixWorkspace_sptr firstTransmissionRun, + const MatrixWorkspace_sptr &firstTransmissionRun, OptionalMatrixWorkspace_sptr secondTransmissionRun, const OptionalDouble &stitchingStart, const OptionalDouble &stitchingDelta, const OptionalDouble &stitchingEnd, @@ -163,7 +165,7 @@ MatrixWorkspace_sptr CreateTransmissionWorkspace::makeTransmissionCorrection( /*make struct of optional inputs to refactor method arguments*/ /*make a using statements defining OptionalInteger for MonitorIndex*/ auto trans1InLam = - toLam(firstTransmissionRun, processingCommands, i0MonitorIndex, + toLam(std::move(firstTransmissionRun), processingCommands, i0MonitorIndex, wavelengthInterval, wavelengthMonitorBackgroundInterval); MatrixWorkspace_sptr trans1Detector = trans1InLam.get<0>(); MatrixWorkspace_sptr trans1Monitor = trans1InLam.get<1>(); diff --git a/Framework/Algorithms/src/CreateTransmissionWorkspace2.cpp b/Framework/Algorithms/src/CreateTransmissionWorkspace2.cpp index 5010dbffc411acf4e0c3251357f0de21919d4b6d..bf6b018ee136954709a06d22ac9d7b870ace1616 100644 --- a/Framework/Algorithms/src/CreateTransmissionWorkspace2.cpp +++ b/Framework/Algorithms/src/CreateTransmissionWorkspace2.cpp @@ -183,7 +183,7 @@ void CreateTransmissionWorkspace2::exec() { * @return :: the normalized workspace in Wavelength */ MatrixWorkspace_sptr CreateTransmissionWorkspace2::normalizeDetectorsByMonitors( - const MatrixWorkspace_sptr IvsTOF) { + const MatrixWorkspace_sptr &IvsTOF) { // Detector workspace MatrixWorkspace_sptr detectorWS = makeDetectorWS(IvsTOF); @@ -249,7 +249,7 @@ CreateTransmissionWorkspace2::getRunNumber(std::string const &propertyName) { * @param ws A workspace to store. */ void CreateTransmissionWorkspace2::setOutputTransmissionRun( - int which, MatrixWorkspace_sptr ws) { + int which, const MatrixWorkspace_sptr &ws) { bool const isDebug = getProperty("Debug"); if (!isDebug) return; @@ -291,7 +291,7 @@ void CreateTransmissionWorkspace2::setOutputTransmissionRun( * be found */ void CreateTransmissionWorkspace2::setOutputWorkspace( - API::MatrixWorkspace_sptr ws) { + const API::MatrixWorkspace_sptr &ws) { // If the user provided an output name, just set the value if (!isDefault("OutputWorkspace")) { setProperty("OutputWorkspace", ws); diff --git a/Framework/Algorithms/src/CreateTransmissionWorkspaceAuto.cpp b/Framework/Algorithms/src/CreateTransmissionWorkspaceAuto.cpp index 8ada727d00476c6646852d37ac65f5d9bb51911b..132efa67800b69173914c73520fef9b296d7ae90 100644 --- a/Framework/Algorithms/src/CreateTransmissionWorkspaceAuto.cpp +++ b/Framework/Algorithms/src/CreateTransmissionWorkspaceAuto.cpp @@ -240,7 +240,7 @@ void CreateTransmissionWorkspaceAuto::exec() { template <typename T> boost::optional<T> -CreateTransmissionWorkspaceAuto::isSet(std::string propName) const { +CreateTransmissionWorkspaceAuto::isSet(const std::string &propName) const { auto algProperty = this->getPointerToProperty(propName); if (algProperty->isDefault()) { return boost::optional<T>(); diff --git a/Framework/Algorithms/src/DetectorDiagnostic.cpp b/Framework/Algorithms/src/DetectorDiagnostic.cpp index e46cd0743cea4dba5dbf07d9f8aa3c980eb9d959..816779e650d9caf470a175c147bc72aa836a483f 100644 --- a/Framework/Algorithms/src/DetectorDiagnostic.cpp +++ b/Framework/Algorithms/src/DetectorDiagnostic.cpp @@ -376,8 +376,8 @@ void DetectorDiagnostic::exec() { * @param inputWS : the workspace to mask * @param maskWS : the workspace containing the masking information */ -void DetectorDiagnostic::applyMask(API::MatrixWorkspace_sptr inputWS, - API::MatrixWorkspace_sptr maskWS) { +void DetectorDiagnostic::applyMask(const API::MatrixWorkspace_sptr &inputWS, + const API::MatrixWorkspace_sptr &maskWS) { IAlgorithm_sptr maskAlg = createChildAlgorithm("MaskDetectors"); // should set progress bar maskAlg->setProperty("Workspace", inputWS); @@ -394,7 +394,7 @@ void DetectorDiagnostic::applyMask(API::MatrixWorkspace_sptr inputWS, * @return : the resulting mask from the checks */ API::MatrixWorkspace_sptr -DetectorDiagnostic::doDetVanTest(API::MatrixWorkspace_sptr inputWS, +DetectorDiagnostic::doDetVanTest(const API::MatrixWorkspace_sptr &inputWS, int &nFails) { MatrixWorkspace_sptr localMask; @@ -483,7 +483,7 @@ DetectorDiagnostic::DetectorDiagnostic() * @returns A workspace containing the integrated counts */ MatrixWorkspace_sptr DetectorDiagnostic::integrateSpectra( - MatrixWorkspace_sptr inputWS, const int indexMin, const int indexMax, + const MatrixWorkspace_sptr &inputWS, const int indexMin, const int indexMax, const double lower, const double upper, const bool outputWorkspace2D) { g_log.debug() << "Integrating input spectra.\n"; // If the input spectra only has one bin, assume it has been integrated @@ -525,8 +525,8 @@ MatrixWorkspace_sptr DetectorDiagnostic::integrateSpectra( * @param inputWS The workspace to initialize from. The instrument is copied *from this. */ -DataObjects::MaskWorkspace_sptr -DetectorDiagnostic::generateEmptyMask(API::MatrixWorkspace_const_sptr inputWS) { +DataObjects::MaskWorkspace_sptr DetectorDiagnostic::generateEmptyMask( + const API::MatrixWorkspace_const_sptr &inputWS) { // Create a new workspace for the results, copy from the input to ensure that // we copy over the instrument and current masking auto maskWS = @@ -547,7 +547,7 @@ DetectorDiagnostic::makeInstrumentMap(const API::MatrixWorkspace &countsWS) { * */ std::vector<std::vector<size_t>> -DetectorDiagnostic::makeMap(API::MatrixWorkspace_sptr countsWS) { +DetectorDiagnostic::makeMap(const API::MatrixWorkspace_sptr &countsWS) { std::multimap<Mantid::Geometry::ComponentID, size_t> mymap; Geometry::Instrument_const_sptr instrument = countsWS->getInstrument(); diff --git a/Framework/Algorithms/src/DetectorEfficiencyVariation.cpp b/Framework/Algorithms/src/DetectorEfficiencyVariation.cpp index 6192db26833a047ddd1ec0080ed8a24c037bd02e..cba50b3442bef9daebb8d77a581afc220e176cff 100644 --- a/Framework/Algorithms/src/DetectorEfficiencyVariation.cpp +++ b/Framework/Algorithms/src/DetectorEfficiencyVariation.cpp @@ -187,8 +187,8 @@ void DetectorEfficiencyVariation::retrieveProperties( * @return number of detectors for which tests failed */ int DetectorEfficiencyVariation::doDetectorTests( - API::MatrixWorkspace_const_sptr counts1, - API::MatrixWorkspace_const_sptr counts2, const double average, + const API::MatrixWorkspace_const_sptr &counts1, + const API::MatrixWorkspace_const_sptr &counts2, const double average, double variation) { // DIAG in libISIS did this. A variation of less than 1 doesn't make sense in // this algorithm diff --git a/Framework/Algorithms/src/DiffractionEventCalibrateDetectors.cpp b/Framework/Algorithms/src/DiffractionEventCalibrateDetectors.cpp index be8054b8933e2ccc4f4deb43781d2c7123c16a0e..de4557eec625df285d7391efc920046c35d6705a 100644 --- a/Framework/Algorithms/src/DiffractionEventCalibrateDetectors.cpp +++ b/Framework/Algorithms/src/DiffractionEventCalibrateDetectors.cpp @@ -84,7 +84,7 @@ static double gsl_costFunction(const gsl_vector *v, void *params) { void DiffractionEventCalibrateDetectors::movedetector( double x, double y, double z, double rotx, double roty, double rotz, - std::string detname, EventWorkspace_sptr inputW) { + const std::string &detname, const EventWorkspace_sptr &inputW) { IAlgorithm_sptr alg1 = createChildAlgorithm("MoveInstrumentComponent"); alg1->setProperty<EventWorkspace_sptr>("Workspace", inputW); @@ -145,8 +145,9 @@ void DiffractionEventCalibrateDetectors::movedetector( double DiffractionEventCalibrateDetectors::intensity( double x, double y, double z, double rotx, double roty, double rotz, - std::string detname, std::string inname, std::string outname, - std::string peakOpt, std::string rb_param, std::string groupWSName) { + const std::string &detname, const std::string &inname, + const std::string &outname, const std::string &peakOpt, + const std::string &rb_param, const std::string &groupWSName) { EventWorkspace_sptr inputW = boost::dynamic_pointer_cast<EventWorkspace>( AnalysisDataService::Instance().retrieve(inname)); diff --git a/Framework/Algorithms/src/DiffractionFocussing.cpp b/Framework/Algorithms/src/DiffractionFocussing.cpp index 7afe73b2de87d698c371b4032961288b7bfbda32..94c575cc38c61dedb943269f0443cce7d80724b5 100644 --- a/Framework/Algorithms/src/DiffractionFocussing.cpp +++ b/Framework/Algorithms/src/DiffractionFocussing.cpp @@ -241,7 +241,7 @@ void DiffractionFocussing::calculateRebinParams( * @throws FileError if can't read the file */ std::multimap<int64_t, int64_t> -DiffractionFocussing::readGroupingFile(std::string groupingFileName) { +DiffractionFocussing::readGroupingFile(const std::string &groupingFileName) { std::ifstream grFile(groupingFileName.c_str()); if (!grFile) { g_log.error() << "Unable to open grouping file " << groupingFileName diff --git a/Framework/Algorithms/src/DiffractionFocussing2.cpp b/Framework/Algorithms/src/DiffractionFocussing2.cpp index 8c204e9af1314722ed368c1d36617d2fbda4dc55..9444e68fa4a1f5bafa614f234e02e9047297eeae 100644 --- a/Framework/Algorithms/src/DiffractionFocussing2.cpp +++ b/Framework/Algorithms/src/DiffractionFocussing2.cpp @@ -590,11 +590,10 @@ void DiffractionFocussing2::determineRebinParameters() { nGroups = group2minmax.size(); // Number of unique groups - double Xmin, Xmax, step; const int64_t xPoints = nPoints + 1; - // Iterator over all groups to create the new X vectors - for (gpit = group2minmax.begin(); gpit != group2minmax.end(); gpit++) { + for (gpit = group2minmax.begin(); gpit != group2minmax.end(); ++gpit) { + double Xmin, Xmax, step; Xmin = (gpit->second).first; Xmax = (gpit->second).second; diff --git a/Framework/Algorithms/src/EQSANSCorrectFrame.cpp b/Framework/Algorithms/src/EQSANSCorrectFrame.cpp index 58b64d47ad6e9ccb13b0de4ed246874a091bc9e1..b7cebbb4dec62beba0e4382b054a5078f1db1ed2 100644 --- a/Framework/Algorithms/src/EQSANSCorrectFrame.cpp +++ b/Framework/Algorithms/src/EQSANSCorrectFrame.cpp @@ -95,11 +95,11 @@ void EQSANSCorrectFrame::exec() { double newTOF = tof + m_framesOffsetTime; // TOF values smaller than that of the fastest neutrons have been // 'folded' by the data acquisition system. They must be shifted - double minTOF = m_minTOF * pathToPixelFactor; - if (newTOF < minTOF) + double scaledMinTOF = m_minTOF * pathToPixelFactor; + if (newTOF < scaledMinTOF) newTOF += m_frameWidth; // Events from the skipped pulse are delayed by one pulse period - if (m_isFrameSkipping && newTOF > minTOF + m_pulsePeriod) + if (m_isFrameSkipping && newTOF > scaledMinTOF + m_pulsePeriod) newTOF += m_pulsePeriod; return newTOF; } diff --git a/Framework/Algorithms/src/EQSANSTofStructure.cpp b/Framework/Algorithms/src/EQSANSTofStructure.cpp index 4f03cdac926b30d04a497a991def598ea2dcba07..b7c89f3708e672944c39092f05946a29a03f28e8 100644 --- a/Framework/Algorithms/src/EQSANSTofStructure.cpp +++ b/Framework/Algorithms/src/EQSANSTofStructure.cpp @@ -118,7 +118,7 @@ void EQSANSTofStructure::exec() { } void EQSANSTofStructure::execEvent( - Mantid::DataObjects::EventWorkspace_sptr inputWS, double threshold, + const Mantid::DataObjects::EventWorkspace_sptr &inputWS, double threshold, double frame_offset, double tof_frame_width, double tmp_frame_width, bool frame_skipping) { const size_t numHists = inputWS->getNumberHistograms(); @@ -190,8 +190,9 @@ void EQSANSTofStructure::execEvent( PARALLEL_CHECK_INTERUPT_REGION } -double EQSANSTofStructure::getTofOffset(EventWorkspace_const_sptr inputWS, - bool frame_skipping) { +double +EQSANSTofStructure::getTofOffset(const EventWorkspace_const_sptr &inputWS, + bool frame_skipping) { //# Storage for chopper information read from the logs double chopper_set_phase[4] = {0, 0, 0, 0}; double chopper_speed[4] = {0, 0, 0, 0}; diff --git a/Framework/Algorithms/src/ExportTimeSeriesLog.cpp b/Framework/Algorithms/src/ExportTimeSeriesLog.cpp index 7efca9a462b0c7fc0fece03b652cf87cef0fb43d..8b373182922ca145651ee606d0a179d342707147 100644 --- a/Framework/Algorithms/src/ExportTimeSeriesLog.cpp +++ b/Framework/Algorithms/src/ExportTimeSeriesLog.cpp @@ -131,7 +131,7 @@ void ExportTimeSeriesLog::exec() { * @param cal_first_deriv :: flag to calcualte the first derivative */ void ExportTimeSeriesLog::exportLog(const std::string &logname, - const std::string timeunit, + const std::string &timeunit, const double &starttime, const double &stoptime, const bool exportepoch, bool outputeventws, diff --git a/Framework/Algorithms/src/ExtractMaskToTable.cpp b/Framework/Algorithms/src/ExtractMaskToTable.cpp index 112ea04cd6be0ae6aa7f01125498a77c539459b9..d3fbe14f280df1eefe255a5e907734678c30a64e 100644 --- a/Framework/Algorithms/src/ExtractMaskToTable.cpp +++ b/Framework/Algorithms/src/ExtractMaskToTable.cpp @@ -124,7 +124,7 @@ void ExtractMaskToTable::exec() { * @returns :: vector of detector IDs that are masked */ std::vector<detid_t> ExtractMaskToTable::parseMaskTable( - DataObjects::TableWorkspace_sptr masktablews) { + const DataObjects::TableWorkspace_sptr &masktablews) { // Output vector std::vector<detid_t> maskeddetectorids; @@ -174,7 +174,7 @@ std::vector<detid_t> ExtractMaskToTable::parseMaskTable( * @returns :: vector genrated from input string containing the list */ std::vector<detid_t> -ExtractMaskToTable::parseStringToVector(std::string liststr) { +ExtractMaskToTable::parseStringToVector(const std::string &liststr) { std::vector<detid_t> detidvec; // Use ArrayProperty to parse the list @@ -264,7 +264,7 @@ std::vector<detid_t> ExtractMaskToTable::extractMaskFromMaskWorkspace() { * @param targetWS :: table workspace to which the content is copied; */ void ExtractMaskToTable::copyTableWorkspaceContent( - TableWorkspace_sptr sourceWS, TableWorkspace_sptr targetWS) { + const TableWorkspace_sptr &sourceWS, const TableWorkspace_sptr &targetWS) { // Compare the column names. They must be exactly the same vector<string> sourcecolnames = sourceWS->getColumnNames(); vector<string> targetcolnames = targetWS->getColumnNames(); @@ -310,7 +310,7 @@ void ExtractMaskToTable::copyTableWorkspaceContent( * @param xmax :: maximum x * @param prevmaskedids :: vector of previous masked detector IDs */ -void ExtractMaskToTable::addToTableWorkspace(TableWorkspace_sptr outws, +void ExtractMaskToTable::addToTableWorkspace(const TableWorkspace_sptr &outws, vector<detid_t> maskeddetids, double xmin, double xmax, vector<detid_t> prevmaskedids) { diff --git a/Framework/Algorithms/src/FindPeaks.cpp b/Framework/Algorithms/src/FindPeaks.cpp index 726c8055ad69f1bae83c8b749133bd7d65f41ae3..f3e7414505010263d2773512fc243ac38eb61595 100644 --- a/Framework/Algorithms/src/FindPeaks.cpp +++ b/Framework/Algorithms/src/FindPeaks.cpp @@ -1508,8 +1508,8 @@ void FindPeaks::createFunctions() { */ double FindPeaks::callFitPeak(const MatrixWorkspace_sptr &dataws, int wsindex, - const API::IPeakFunction_sptr peakfunction, - const API::IBackgroundFunction_sptr backgroundfunction, + const API::IPeakFunction_sptr &peakfunction, + const API::IBackgroundFunction_sptr &backgroundfunction, const std::vector<double> &vec_fitwindow, const std::vector<double> &vec_peakrange, int minGuessFWHM, int maxGuessFWHM, int guessedFWHMStep, diff --git a/Framework/Algorithms/src/FitPeak.cpp b/Framework/Algorithms/src/FitPeak.cpp index 7710091f923cff2128aebdab3e2b3b580a9bf8d1..98a8764daf55ae1b5fd8590e5d721425961cd5c2 100644 --- a/Framework/Algorithms/src/FitPeak.cpp +++ b/Framework/Algorithms/src/FitPeak.cpp @@ -7,7 +7,8 @@ //---------------------------------------------------------------------- // Includes //---------------------------------------------------------------------- -#include "MantidAlgorithms/FitPeak.h" +#include <utility> + #include "MantidAPI/CompositeFunction.h" #include "MantidAPI/CostFunctionFactory.h" #include "MantidAPI/FuncMinimizerFactory.h" @@ -17,6 +18,7 @@ #include "MantidAPI/MultiDomainFunction.h" #include "MantidAPI/TableRow.h" #include "MantidAPI/WorkspaceProperty.h" +#include "MantidAlgorithms/FitPeak.h" #include "MantidDataObjects/TableWorkspace.h" #include "MantidDataObjects/Workspace2D.h" #include "MantidDataObjects/WorkspaceCreation.h" @@ -62,7 +64,7 @@ FitOneSinglePeak::FitOneSinglePeak() //---------------------------------------------------------------------------------------------- /** Set workspaces */ -void FitOneSinglePeak::setWorskpace(API::MatrixWorkspace_sptr dataws, +void FitOneSinglePeak::setWorskpace(const API::MatrixWorkspace_sptr &dataws, size_t wsindex) { if (dataws) { m_dataWS = dataws; @@ -80,8 +82,8 @@ void FitOneSinglePeak::setWorskpace(API::MatrixWorkspace_sptr dataws, //---------------------------------------------------------------------------------------------- /** Set peaks */ -void FitOneSinglePeak::setFunctions(IPeakFunction_sptr peakfunc, - IBackgroundFunction_sptr bkgdfunc) { +void FitOneSinglePeak::setFunctions(const IPeakFunction_sptr &peakfunc, + const IBackgroundFunction_sptr &bkgdfunc) { if (peakfunc) m_peakFunc = peakfunc; @@ -129,8 +131,8 @@ void FitOneSinglePeak::setPeakRange(double xpeakleft, double xpeakright) { * @param costfunction :: string of the name of the cost function */ void FitOneSinglePeak::setFittingMethod(std::string minimizer, - std::string costfunction) { - m_minimizer = minimizer; + const std::string &costfunction) { + m_minimizer = std::move(minimizer); if (costfunction == "Chi-Square") { m_costFunction = "Least squares"; } else if (costfunction == "Rwp") { @@ -387,8 +389,9 @@ API::MatrixWorkspace_sptr FitOneSinglePeak::genFitWindowWS() { /** Estimate the peak height from a set of data containing pure peaks */ double FitOneSinglePeak::estimatePeakHeight( - API::IPeakFunction_const_sptr peakfunc, MatrixWorkspace_sptr dataws, - size_t wsindex, size_t ixmin, size_t ixmax) { + const API::IPeakFunction_const_sptr &peakfunc, + const MatrixWorkspace_sptr &dataws, size_t wsindex, size_t ixmin, + size_t ixmax) { // Get current peak height: from current peak centre (previously setup) double peakcentre = peakfunc->centre(); vector<double> svvec(1, peakcentre); @@ -424,7 +427,8 @@ double FitOneSinglePeak::estimatePeakHeight( /** Make a pure peak WS in the fit window region from m_background_function * @param purePeakWS :: workspace containing pure peak (w/ background removed) */ -void FitOneSinglePeak::removeBackground(MatrixWorkspace_sptr purePeakWS) { +void FitOneSinglePeak::removeBackground( + const MatrixWorkspace_sptr &purePeakWS) { // Calculate background // FIXME - This can be costly to use FunctionDomain and FunctionValue auto &vecX = purePeakWS->x(0); @@ -449,10 +453,10 @@ void FitOneSinglePeak::removeBackground(MatrixWorkspace_sptr purePeakWS) { * some fit with unphysical result. * @return :: chi-square/Rwp */ -double FitOneSinglePeak::fitPeakFunction(API::IPeakFunction_sptr peakfunc, - MatrixWorkspace_sptr dataws, - size_t wsindex, double startx, - double endx) { +double +FitOneSinglePeak::fitPeakFunction(const API::IPeakFunction_sptr &peakfunc, + const MatrixWorkspace_sptr &dataws, + size_t wsindex, double startx, double endx) { // Check validity and debug output if (!peakfunc) throw std::runtime_error( @@ -461,7 +465,8 @@ double FitOneSinglePeak::fitPeakFunction(API::IPeakFunction_sptr peakfunc, m_sstream << "Function (to fit): " << peakfunc->asString() << " From " << startx << " to " << endx << ".\n"; - double goodness = fitFunctionSD(peakfunc, dataws, wsindex, startx, endx); + double goodness = + fitFunctionSD(peakfunc, std::move(dataws), wsindex, startx, endx); return goodness; } @@ -574,7 +579,7 @@ void FitOneSinglePeak::highBkgdFit() { * @returns :: map to store function parameter's names and value */ std::map<std::string, double> -FitOneSinglePeak::backup(IFunction_const_sptr func) { +FitOneSinglePeak::backup(const IFunction_const_sptr &func) { std::map<std::string, double> funcparammap; // Set up @@ -614,7 +619,7 @@ FitOneSinglePeak::storeFunctionError(const IFunction_const_sptr &func) { /** Restore the parameters value to a function from a string/double map */ void FitOneSinglePeak::pop(const std::map<std::string, double> &funcparammap, - API::IFunction_sptr func) { + const API::IFunction_sptr &func) { std::map<std::string, double>::const_iterator miter; for (miter = funcparammap.begin(); miter != funcparammap.end(); ++miter) { string parname = miter->first; @@ -633,8 +638,8 @@ void FitOneSinglePeak::pop(const std::map<std::string, double> &funcparammap, * @param xmax * @return */ -double FitOneSinglePeak::calChiSquareSD(IFunction_sptr fitfunc, - MatrixWorkspace_sptr dataws, +double FitOneSinglePeak::calChiSquareSD(const IFunction_sptr &fitfunc, + const MatrixWorkspace_sptr &dataws, size_t wsindex, double xmin, double xmax) { // Set up sub algorithm fit @@ -675,7 +680,7 @@ double FitOneSinglePeak::calChiSquareSD(IFunction_sptr fitfunc, * return DBL_MAX */ double FitOneSinglePeak::fitFunctionSD(IFunction_sptr fitfunc, - MatrixWorkspace_sptr dataws, + const MatrixWorkspace_sptr &dataws, size_t wsindex, double xmin, double xmax) { // Set up sub algorithm fit @@ -733,8 +738,8 @@ double FitOneSinglePeak::fitFunctionSD(IFunction_sptr fitfunc, * @param vec_xmin :: minimin values of domains * @param vec_xmax :: maximim values of domains */ -double FitOneSinglePeak::fitFunctionMD(IFunction_sptr fitfunc, - MatrixWorkspace_sptr dataws, +double FitOneSinglePeak::fitFunctionMD(const IFunction_sptr &fitfunc, + const MatrixWorkspace_sptr &dataws, size_t wsindex, vector<double> vec_xmin, vector<double> vec_xmax) { // Validate @@ -823,8 +828,9 @@ double FitOneSinglePeak::fitFunctionMD(IFunction_sptr fitfunc, * @return :: Rwp/chi2 */ double FitOneSinglePeak::fitCompositeFunction( - API::IPeakFunction_sptr peakfunc, API::IBackgroundFunction_sptr bkgdfunc, - API::MatrixWorkspace_sptr dataws, size_t wsindex, double startx, + const API::IPeakFunction_sptr &peakfunc, + const API::IBackgroundFunction_sptr &bkgdfunc, + const API::MatrixWorkspace_sptr &dataws, size_t wsindex, double startx, double endx) { // Construct composit function boost::shared_ptr<CompositeFunction> compfunc = @@ -883,7 +889,7 @@ double FitOneSinglePeak::fitCompositeFunction( /** Check the fitted peak value to see whether it is valid * @return :: Rwp/chi2 */ -double FitOneSinglePeak::checkFittedPeak(IPeakFunction_sptr peakfunc, +double FitOneSinglePeak::checkFittedPeak(const IPeakFunction_sptr &peakfunc, double costfuncvalue, std::string &errorreason) { if (costfuncvalue < DBL_MAX) { @@ -1234,7 +1240,7 @@ void FitPeak::exec() { /** Add function's parameter names after peak function name */ std::vector<std::string> -FitPeak::addFunctionParameterNames(std::vector<std::string> funcnames) { +FitPeak::addFunctionParameterNames(const std::vector<std::string> &funcnames) { vector<string> vec_funcparnames; for (auto &funcname : funcnames) { @@ -1599,9 +1605,11 @@ size_t getIndex(const HistogramX &vecx, double x) { //---------------------------------------------------------------------------------------------- /** Generate table workspace */ -TableWorkspace_sptr FitPeak::genOutputTableWS( - IPeakFunction_sptr peakfunc, map<string, double> peakerrormap, - IBackgroundFunction_sptr bkgdfunc, map<string, double> bkgderrormap) { +TableWorkspace_sptr +FitPeak::genOutputTableWS(const IPeakFunction_sptr &peakfunc, + map<string, double> peakerrormap, + const IBackgroundFunction_sptr &bkgdfunc, + map<string, double> bkgderrormap) { // Empty table TableWorkspace_sptr outtablews = boost::make_shared<TableWorkspace>(); outtablews->addColumn("str", "Name"); diff --git a/Framework/Algorithms/src/FitPeaks.cpp b/Framework/Algorithms/src/FitPeaks.cpp index 3db4f98a3d2589b55507c51209d63f1ee68a445e..17a439ef3d196662fdb83562f5fc85ece8f2e052 100644 --- a/Framework/Algorithms/src/FitPeaks.cpp +++ b/Framework/Algorithms/src/FitPeaks.cpp @@ -34,6 +34,7 @@ #include "boost/algorithm/string.hpp" #include "boost/algorithm/string/trim.hpp" #include <limits> +#include <utility> using namespace Mantid; using namespace Mantid::API; @@ -148,7 +149,7 @@ double PeakFitResult::getCost(size_t ipeak) const { return m_costs[ipeak]; } /// set the peak fitting record/parameter for one peak void PeakFitResult::setRecord(size_t ipeak, const double cost, const double peak_position, - const FitFunction fit_functions) { + const FitFunction &fit_functions) { // check input if (ipeak >= m_costs.size()) throw std::runtime_error("Peak index is out of range."); @@ -1026,7 +1027,7 @@ double numberCounts(const Histogram &histogram, const double xmin, */ void FitPeaks::fitSpectrumPeaks( size_t wi, const std::vector<double> &expected_peak_centers, - boost::shared_ptr<FitPeaksAlgorithm::PeakFitResult> fit_result) { + const boost::shared_ptr<FitPeaksAlgorithm::PeakFitResult> &fit_result) { if (numberCounts(m_inputMatrixWS->histogram(wi)) <= m_minPeakHeight) { for (size_t i = 0; i < fit_result->getNumberPeaks(); ++i) fit_result->setBadRecord(i, -1.); @@ -1131,7 +1132,8 @@ void FitPeaks::fitSpectrumPeaks( * @return :: flag whether the peak width shall be observed */ bool FitPeaks::decideToEstimatePeakParams( - const bool firstPeakInSpectrum, API::IPeakFunction_sptr peak_function) { + const bool firstPeakInSpectrum, + const API::IPeakFunction_sptr &peak_function) { // should observe the peak width if the user didn't supply all of the peak // function parameters bool observe_peak_shape(m_initParamIndexes.size() != @@ -1173,8 +1175,8 @@ bool FitPeaks::decideToEstimatePeakParams( void FitPeaks::processSinglePeakFitResult( size_t wsindex, size_t peakindex, const double cost, const std::vector<double> &expected_peak_positions, - FitPeaksAlgorithm::FitFunction fitfunction, - boost::shared_ptr<FitPeaksAlgorithm::PeakFitResult> fit_result) { + const FitPeaksAlgorithm::FitFunction &fitfunction, + const boost::shared_ptr<FitPeaksAlgorithm::PeakFitResult> &fit_result) { // determine peak position tolerance double postol(DBL_MAX); bool case23(false); @@ -1403,9 +1405,9 @@ vector<double> calculateMomentsAboutMean(const Histogram &histogram, * First, algorithm FindPeakBackground will be tried; * If it fails, then a linear background estimator will be called. */ -void FitPeaks::estimateBackground(const Histogram &histogram, - const std::pair<double, double> &peak_window, - API::IBackgroundFunction_sptr bkgd_function) { +void FitPeaks::estimateBackground( + const Histogram &histogram, const std::pair<double, double> &peak_window, + const API::IBackgroundFunction_sptr &bkgd_function) { if (peak_window.first >= peak_window.second) throw std::runtime_error("Invalid peak window"); @@ -1440,8 +1442,9 @@ void FitPeaks::estimateBackground(const Histogram &histogram, */ int FitPeaks::estimatePeakParameters( const Histogram &histogram, const std::pair<double, double> &peak_window, - API::IPeakFunction_sptr peakfunction, - API::IBackgroundFunction_sptr bkgdfunction, bool observe_peak_width) { + const API::IPeakFunction_sptr &peakfunction, + const API::IBackgroundFunction_sptr &bkgdfunction, + bool observe_peak_width) { // get the range of start and stop to construct a function domain const auto &vector_x = histogram.points(); @@ -1608,7 +1611,7 @@ double FitPeaks::observePeakWidth(const Histogram &histogram, bool FitPeaks::fitBackground(const size_t &ws_index, const std::pair<double, double> &fit_window, const double &expected_peak_pos, - API::IBackgroundFunction_sptr bkgd_func) { + const API::IBackgroundFunction_sptr &bkgd_func) { // find out how to fit background const auto &points = m_inputMatrixWS->histogram(ws_index).points(); @@ -1656,12 +1659,13 @@ bool FitPeaks::fitBackground(const size_t &ws_index, //---------------------------------------------------------------------------------------------- /** Fit an individual peak */ -double FitPeaks::fitIndividualPeak(size_t wi, API::IAlgorithm_sptr fitter, - const double expected_peak_center, - const std::pair<double, double> &fitwindow, - const bool observe_peak_params, - API::IPeakFunction_sptr peakfunction, - API::IBackgroundFunction_sptr bkgdfunc) { +double +FitPeaks::fitIndividualPeak(size_t wi, const API::IAlgorithm_sptr &fitter, + const double expected_peak_center, + const std::pair<double, double> &fitwindow, + const bool observe_peak_params, + const API::IPeakFunction_sptr &peakfunction, + const API::IBackgroundFunction_sptr &bkgdfunc) { double cost(DBL_MAX); // confirm that there is something to fit @@ -1690,14 +1694,12 @@ double FitPeaks::fitIndividualPeak(size_t wi, API::IAlgorithm_sptr fitter, * This is the core fitting algorithm to deal with the simplest situation * @exception :: Fit.isExecuted is false (cannot be executed) */ -double FitPeaks::fitFunctionSD(IAlgorithm_sptr fit, - API::IPeakFunction_sptr peak_function, - API::IBackgroundFunction_sptr bkgd_function, - API::MatrixWorkspace_sptr dataws, size_t wsindex, - double xmin, double xmax, - const double &expected_peak_center, - bool observe_peak_shape, - bool estimate_background) { +double FitPeaks::fitFunctionSD( + const IAlgorithm_sptr &fit, const API::IPeakFunction_sptr &peak_function, + const API::IBackgroundFunction_sptr &bkgd_function, + const API::MatrixWorkspace_sptr &dataws, size_t wsindex, double xmin, + double xmax, const double &expected_peak_center, bool observe_peak_shape, + bool estimate_background) { std::stringstream errorid; errorid << "(WorkspaceIndex=" << wsindex << " PeakCentre=" << expected_peak_center << ")"; @@ -1769,7 +1771,6 @@ double FitPeaks::fitFunctionSD(IAlgorithm_sptr fit, errorid << ": " << e.what(); g_log.warning() << "While fitting " + errorid.str(); return DBL_MAX; // probably the wrong thing to do - throw std::runtime_error("While fitting " + errorid.str()); } // Retrieve result @@ -1784,8 +1785,8 @@ double FitPeaks::fitFunctionSD(IAlgorithm_sptr fit, //---------------------------------------------------------------------------------------------- double FitPeaks::fitFunctionMD(API::IFunction_sptr fit_function, - API::MatrixWorkspace_sptr dataws, size_t wsindex, - std::vector<double> &vec_xmin, + const API::MatrixWorkspace_sptr &dataws, + size_t wsindex, std::vector<double> &vec_xmin, std::vector<double> &vec_xmax) { // Validate if (vec_xmin.size() != vec_xmax.size()) @@ -1845,7 +1846,6 @@ double FitPeaks::fitFunctionMD(API::IFunction_sptr fit_function, double chi2 = DBL_MAX; if (fitStatus == "success") { chi2 = fit->getProperty("OutputChi2overDoF"); - fit_function = fit->getProperty("Function"); } return chi2; @@ -1854,10 +1854,10 @@ double FitPeaks::fitFunctionMD(API::IFunction_sptr fit_function, //---------------------------------------------------------------------------------------------- /// Fit peak with high background double FitPeaks::fitFunctionHighBackground( - IAlgorithm_sptr fit, const std::pair<double, double> &fit_window, + const IAlgorithm_sptr &fit, const std::pair<double, double> &fit_window, const size_t &ws_index, const double &expected_peak_center, - bool observe_peak_shape, API::IPeakFunction_sptr peakfunction, - API::IBackgroundFunction_sptr bkgdfunc) { + bool observe_peak_shape, const API::IPeakFunction_sptr &peakfunction, + const API::IBackgroundFunction_sptr &bkgdfunc) { // high background to reduce API::IBackgroundFunction_sptr high_bkgd_function(nullptr); if (m_linearBackgroundFunction) @@ -1881,9 +1881,8 @@ double FitPeaks::fitFunctionHighBackground( createMatrixWorkspace(vec_x, vec_y, vec_e); // Fit peak with background - double cost = fitFunctionSD(fit, peakfunction, bkgdfunc, reduced_bkgd_ws, 0, - vec_x.front(), vec_x.back(), expected_peak_center, - observe_peak_shape, false); + fitFunctionSD(fit, peakfunction, bkgdfunc, reduced_bkgd_ws, 0, vec_x.front(), + vec_x.back(), expected_peak_center, observe_peak_shape, false); // add the reduced background back bkgdfunc->setParameter(0, bkgdfunc->getParameter(0) + @@ -1891,9 +1890,9 @@ double FitPeaks::fitFunctionHighBackground( bkgdfunc->setParameter(1, bkgdfunc->getParameter(1) + high_bkgd_function->getParameter(1)); - cost = fitFunctionSD(fit, peakfunction, bkgdfunc, m_inputMatrixWS, ws_index, - vec_x.front(), vec_x.back(), expected_peak_center, false, - false); + double cost = fitFunctionSD(fit, peakfunction, bkgdfunc, m_inputMatrixWS, + ws_index, vec_x.front(), vec_x.back(), + expected_peak_center, false, false); return cost; } @@ -1954,7 +1953,7 @@ void FitPeaks::generateOutputPeakPositionWS() { * @param with_chi2:: flag to append chi^2 to the table */ void FitPeaks::setupParameterTableWorkspace( - API::ITableWorkspace_sptr table_ws, + const API::ITableWorkspace_sptr &table_ws, const std::vector<std::string> ¶m_names, bool with_chi2) { // add columns @@ -2063,7 +2062,7 @@ void FitPeaks::processOutputs( // optional if (m_fittedPeakWS && m_fittedParamTable) { g_log.debug("about to calcualte fitted peaks"); - calculateFittedPeaks(fit_result_vec); + calculateFittedPeaks(std::move(fit_result_vec)); setProperty(PropertyNames::OUTPUT_WKSP_MODEL, m_fittedPeakWS); } } @@ -2215,9 +2214,9 @@ void FitPeaks::getRangeData(size_t iws, * @param vec_x :: vector of X valye * @param vec_y :: (input/output) vector Y to be reduced by background function */ -void FitPeaks::reduceByBackground(API::IBackgroundFunction_sptr bkgd_func, - const std::vector<double> &vec_x, - std::vector<double> &vec_y) { +void FitPeaks::reduceByBackground( + const API::IBackgroundFunction_sptr &bkgd_func, + const std::vector<double> &vec_x, std::vector<double> &vec_y) { // calculate the background FunctionDomain1DVector vectorx(vec_x.begin(), vec_x.end()); FunctionValues vector_bkgd(vectorx); @@ -2278,7 +2277,7 @@ void FitPeaks::estimateLinearBackground(const Histogram &histogram, */ void FitPeaks::writeFitResult( size_t wi, const std::vector<double> &expected_positions, - boost::shared_ptr<FitPeaksAlgorithm::PeakFitResult> fit_result) { + const boost::shared_ptr<FitPeaksAlgorithm::PeakFitResult> &fit_result) { // convert to size_t out_wi = wi - m_startWorkspaceIndex; if (out_wi >= m_outputPeakPositionWorkspace->getNumberHistograms()) { @@ -2395,7 +2394,7 @@ void FitPeaks::writeFitResult( //---------------------------------------------------------------------------------------------- std::string FitPeaks::getPeakHeightParameterName( - API::IPeakFunction_const_sptr peak_function) { + const API::IPeakFunction_const_sptr &peak_function) { std::string height_name(""); std::vector<std::string> peak_parameters = peak_function->getParameterNames(); diff --git a/Framework/Algorithms/src/GenerateEventsFilter.cpp b/Framework/Algorithms/src/GenerateEventsFilter.cpp index 653f4cfb2c8e91df2c5fe40399845b40fd76e7ad..2e0de3025f26870196ec34f3889188d602cddaa4 100644 --- a/Framework/Algorithms/src/GenerateEventsFilter.cpp +++ b/Framework/Algorithms/src/GenerateEventsFilter.cpp @@ -18,6 +18,7 @@ #include "MantidKernel/VisibleWhenProperty.h" #include <boost/math/special_functions/round.hpp> +#include <utility> using namespace Mantid; using namespace Mantid::Kernel; @@ -455,10 +456,9 @@ void GenerateEventsFilter::setFilterByTimeOnly() { int64_t curtime_ns = m_startTime.totalNanoseconds(); int wsindex = 0; while (curtime_ns < m_stopTime.totalNanoseconds()) { - int64_t deltatime_ns; for (size_t id = 0; id < numtimeintervals; ++id) { // get next time interval value - deltatime_ns = vec_dtimens[id]; + int64_t deltatime_ns = vec_dtimens[id]; // Calculate next.time int64_t nexttime_ns = curtime_ns + deltatime_ns; bool breaklater = false; @@ -500,7 +500,7 @@ void GenerateEventsFilter::setFilterByTimeOnly() { /** Generate filters by log values. * @param logname :: name of the log to filter with */ -void GenerateEventsFilter::setFilterByLogValue(std::string logname) { +void GenerateEventsFilter::setFilterByLogValue(const std::string &logname) { // Obtain reference of sample log to filter with m_dblLog = dynamic_cast<TimeSeriesProperty<double> *>( m_dataWS->run().getProperty(logname)); @@ -830,7 +830,6 @@ void GenerateEventsFilter::makeFilterBySingleValue( // Initialize control parameters bool lastGood = false; - bool isGood = false; time_duration tol = DateAndTime::durationFromSeconds(TimeTolerance); int numgood = 0; DateAndTime lastTime, currT; @@ -843,8 +842,8 @@ void GenerateEventsFilter::makeFilterBySingleValue( currT = m_dblLog->nthTime(i); // A good value? - isGood = identifyLogEntry(i, currT, lastGood, min, max, startTime, stopTime, - filterIncrease, filterDecrease); + bool isGood = identifyLogEntry(i, currT, lastGood, min, max, startTime, + stopTime, filterIncrease, filterDecrease); if (isGood) numgood++; @@ -962,7 +961,7 @@ bool GenerateEventsFilter::identifyLogEntry( * @param stopTime :: Stop time. */ void GenerateEventsFilter::makeMultipleFiltersByValues( - map<size_t, int> indexwsindexmap, vector<double> logvalueranges, + map<size_t, int> indexwsindexmap, const vector<double> &logvalueranges, bool centre, bool filterIncrease, bool filterDecrease, DateAndTime startTime, DateAndTime stopTime) { g_log.notice("Starting method 'makeMultipleFiltersByValues'. "); @@ -994,8 +993,9 @@ void GenerateEventsFilter::makeMultipleFiltersByValues( auto iend = static_cast<int>(logsize - 1); makeMultipleFiltersByValuesPartialLog( - istart, iend, m_vecSplitterTime, m_vecSplitterGroup, indexwsindexmap, - logvalueranges, tol, filterIncrease, filterDecrease, startTime, stopTime); + istart, iend, m_vecSplitterTime, m_vecSplitterGroup, + std::move(indexwsindexmap), logvalueranges, tol, filterIncrease, + filterDecrease, startTime, stopTime); progress(1.0); } @@ -1018,9 +1018,9 @@ void GenerateEventsFilter::makeMultipleFiltersByValues( * @param stopTime :: Stop time. */ void GenerateEventsFilter::makeMultipleFiltersByValuesParallel( - map<size_t, int> indexwsindexmap, vector<double> logvalueranges, - bool centre, bool filterIncrease, bool filterDecrease, - DateAndTime startTime, DateAndTime stopTime) { + const map<size_t, int> &indexwsindexmap, + const vector<double> &logvalueranges, bool centre, bool filterIncrease, + bool filterDecrease, DateAndTime startTime, DateAndTime stopTime) { // Return if the log is empty. int logsize = m_dblLog->size(); if (logsize == 0) { @@ -1178,7 +1178,7 @@ void GenerateEventsFilter::makeMultipleFiltersByValuesParallel( void GenerateEventsFilter::makeMultipleFiltersByValuesPartialLog( int istart, int iend, std::vector<Types::Core::DateAndTime> &vecSplitTime, std::vector<int> &vecSplitGroup, map<size_t, int> indexwsindexmap, - const vector<double> &logvalueranges, time_duration tol, + const vector<double> &logvalueranges, const time_duration &tol, bool filterIncrease, bool filterDecrease, DateAndTime startTime, DateAndTime stopTime) { // Check @@ -1217,7 +1217,6 @@ void GenerateEventsFilter::makeMultipleFiltersByValuesPartialLog( double currValue = m_dblLog->nthValue(i); // Filter out by time and direction (optional) - bool intime = true; if (currTime < startTime) { // case i. Too early, do nothing createsplitter = false; @@ -1252,130 +1251,127 @@ void GenerateEventsFilter::makeMultipleFiltersByValuesPartialLog( prevDirection = direction; // Examine log value for filter - if (intime) { - // Determine whether direction is fine - bool correctdir = true; - if (filterIncrease && filterDecrease) { - // Both direction is fine + // Determine whether direction is fine + bool correctdir = true; + if (filterIncrease && filterDecrease) { + // Both direction is fine + correctdir = true; + } else { + // Filter out one direction + if (filterIncrease && direction > 0) correctdir = true; - } else { - // Filter out one direction - if (filterIncrease && direction > 0) - correctdir = true; - else if (filterDecrease && direction < 0) - correctdir = true; - else if (direction == 0) - throw runtime_error("Direction is not determined."); - else - correctdir = false; - } // END-IF-ELSE: Direction - - // Treat the log entry based on: changing direction (+ time range) - if (correctdir) { - // Check this value whether it falls into any range - size_t index = searchValue(logvalueranges, currValue); - - bool valueWithinMinMax = true; - if (index > logvalueranges.size()) { - // Out of range - valueWithinMinMax = false; - } + else if (filterDecrease && direction < 0) + correctdir = true; + else if (direction == 0) + throw runtime_error("Direction is not determined."); + else + correctdir = false; + } // END-IF-ELSE: Direction + + // Treat the log entry based on: changing direction (+ time range) + if (correctdir) { + // Check this value whether it falls into any range + size_t index = searchValue(logvalueranges, currValue); + + bool valueWithinMinMax = true; + if (index > logvalueranges.size()) { + // Out of range + valueWithinMinMax = false; + } - if (g_log.is(Logger::Priority::PRIO_DEBUG)) { - stringstream dbss; - dbss << "[DBx257] Examine Log Index " << i - << ", Value = " << currValue << ", Data Range Index = " << index - << "; " - << "Group Index = " << indexwsindexmap[index / 2] - << " (log value range vector size = " << logvalueranges.size() - << "): "; - if (index == 0) - dbss << logvalueranges[index] << ", " << logvalueranges[index + 1]; - else if (index == logvalueranges.size()) - dbss << logvalueranges[index - 1] << ", " << logvalueranges[index]; - else if (valueWithinMinMax) - dbss << logvalueranges[index - 1] << ", " << logvalueranges[index] - << ", " << logvalueranges[index + 1]; - g_log.debug(dbss.str()); - } + if (g_log.is(Logger::Priority::PRIO_DEBUG)) { + stringstream dbss; + dbss << "[DBx257] Examine Log Index " << i << ", Value = " << currValue + << ", Data Range Index = " << index << "; " + << "Group Index = " << indexwsindexmap[index / 2] + << " (log value range vector size = " << logvalueranges.size() + << "): "; + if (index == 0) + dbss << logvalueranges[index] << ", " << logvalueranges[index + 1]; + else if (index == logvalueranges.size()) + dbss << logvalueranges[index - 1] << ", " << logvalueranges[index]; + else if (valueWithinMinMax) + dbss << logvalueranges[index - 1] << ", " << logvalueranges[index] + << ", " << logvalueranges[index + 1]; + g_log.debug(dbss.str()); + } - if (valueWithinMinMax) { - if (index % 2 == 0) { - // [Situation] Falls in the interval - currindex = indexwsindexmap[index / 2]; - - if (currindex != lastindex && start.totalNanoseconds() == 0) { - // Group index is different from last and start is not set up: new - // a region! - newsplitter = true; - } else if (currindex != lastindex && start.totalNanoseconds() > 0) { - // Group index is different from last and start is set up: close - // a region and new a region + if (valueWithinMinMax) { + if (index % 2 == 0) { + // [Situation] Falls in the interval + currindex = indexwsindexmap[index / 2]; + + if (currindex != lastindex && start.totalNanoseconds() == 0) { + // Group index is different from last and start is not set up: new + // a region! + newsplitter = true; + } else if (currindex != lastindex && start.totalNanoseconds() > 0) { + // Group index is different from last and start is set up: close + // a region and new a region + stop = currTime; + createsplitter = true; + newsplitter = true; + } else if (currindex == lastindex && start.totalNanoseconds() > 0) { + // Still of the group index + if (i == iend) { + // Last entry in this section of log. Need to flag to close the + // pair stop = currTime; createsplitter = true; - newsplitter = true; - } else if (currindex == lastindex && start.totalNanoseconds() > 0) { - // Still of the group index - if (i == iend) { - // Last entry in this section of log. Need to flag to close the - // pair - stop = currTime; - createsplitter = true; - newsplitter = false; - } else { - // Do nothing - ; - } + newsplitter = false; } else { - // An impossible situation - std::stringstream errmsg; - double lastvalue = m_dblLog->nthValue(i - 1); - errmsg << "Impossible to have currindex == lastindex == " - << currindex - << ", while start is not init. Log Index = " << i - << "\t value = " << currValue << "\t, Index = " << index - << " in range " << logvalueranges[index] << ", " - << logvalueranges[index + 1] - << "; Last value = " << lastvalue; - throw std::runtime_error(errmsg.str()); + // Do nothing + ; } - } // [In-bound: Inside interval] - else { - // [Situation] Fall between interval (which is not likley happen) - currindex = -1; - g_log.warning() - << "Not likely to happen! Current value = " << currValue - << " is within value range but its index = " << index - << " has no map to group index. " - << "\n"; - if (start.totalNanoseconds() > 0) { - // Close the interval pair if it has been started. - stop = currTime; - createsplitter = true; - } - } // [In-bound: Between interval] - } else { - // Out of a range: check whether there is a splitter started + } else { + // An impossible situation + std::stringstream errmsg; + double lastvalue = m_dblLog->nthValue(i - 1); + errmsg << "Impossible to have currindex == lastindex == " + << currindex + << ", while start is not init. Log Index = " << i + << "\t value = " << currValue << "\t, Index = " << index + << " in range " << logvalueranges[index] << ", " + << logvalueranges[index + 1] + << "; Last value = " << lastvalue; + throw std::runtime_error(errmsg.str()); + } + } // [In-bound: Inside interval] + else { + // [Situation] Fall between interval (which is not likley happen) currindex = -1; + g_log.warning() << "Not likely to happen! Current value = " + << currValue + << " is within value range but its index = " << index + << " has no map to group index. " + << "\n"; if (start.totalNanoseconds() > 0) { - // End situation + // Close the interval pair if it has been started. stop = currTime; createsplitter = true; } - } // [Out-bound] - - } // [CORRECT DIRECTION] - else { - // Log Index i falls out b/c out of wrong direction + } // [In-bound: Between interval] + } else { + // Out of a range: check whether there is a splitter started currindex = -1; - - // Condition to generate a Splitter (close parenthesis) - if (!correctdir && start.totalNanoseconds() > 0) { + if (start.totalNanoseconds() > 0) { + // End situation stop = currTime; createsplitter = true; } + } // [Out-bound] + + } // [CORRECT DIRECTION] + else { + // Log Index i falls out b/c out of wrong direction + currindex = -1; + + // Condition to generate a Splitter (close parenthesis) + if (!correctdir && start.totalNanoseconds() > 0) { + stop = currTime; + createsplitter = true; } - } // ENDIF (log entry in specified time) + } // d) Create Splitter if (createsplitter) { @@ -1662,7 +1658,7 @@ int GenerateEventsFilter::determineChangingDirection(int startindex) { */ void GenerateEventsFilter::addNewTimeFilterSplitter( Types::Core::DateAndTime starttime, Types::Core::DateAndTime stoptime, - int wsindex, string info) { + int wsindex, const string &info) { if (m_forFastLog) { // For MatrixWorkspace splitter // Start of splitter diff --git a/Framework/Algorithms/src/GeneratePeaks.cpp b/Framework/Algorithms/src/GeneratePeaks.cpp index 5cdb134dad8cbfa9f465f6df97125a92eebee683..d694db8a4a7920e575acf5abe5d854f3eda04369 100644 --- a/Framework/Algorithms/src/GeneratePeaks.cpp +++ b/Framework/Algorithms/src/GeneratePeaks.cpp @@ -429,7 +429,7 @@ void GeneratePeaks::generatePeaks( const std::map<specnum_t, std::vector<std::pair<double, API::IFunction_sptr>>> &functionmap, - API::MatrixWorkspace_sptr dataWS) { + const API::MatrixWorkspace_sptr &dataWS) { // Calcualte function std::map<specnum_t, std::vector<std::pair<double, API::IFunction_sptr>>>::const_iterator @@ -627,7 +627,7 @@ void GeneratePeaks::processTableColumnNames() { * Algorithm supports multiple peaks in multiple spectra */ void GeneratePeaks::getSpectraSet( - DataObjects::TableWorkspace_const_sptr peakParmsWS) { + const DataObjects::TableWorkspace_const_sptr &peakParmsWS) { size_t numpeaks = peakParmsWS->rowCount(); API::Column_const_sptr col = peakParmsWS->getColumn("spectrum"); @@ -652,7 +652,7 @@ void GeneratePeaks::getSpectraSet( /** Get the IPeakFunction part in the input function */ API::IPeakFunction_sptr -GeneratePeaks::getPeakFunction(API::IFunction_sptr infunction) { +GeneratePeaks::getPeakFunction(const API::IFunction_sptr &infunction) { // Not a composite function API::CompositeFunction_sptr compfunc = boost::dynamic_pointer_cast<API::CompositeFunction>(infunction); @@ -678,8 +678,8 @@ GeneratePeaks::getPeakFunction(API::IFunction_sptr infunction) { //---------------------------------------------------------------------------------------------- /** Find out whether a function has a certain parameter */ -bool GeneratePeaks::hasParameter(API::IFunction_sptr function, - std::string paramname) { +bool GeneratePeaks::hasParameter(const API::IFunction_sptr &function, + const std::string ¶mname) { std::vector<std::string> parnames = function->getParameterNames(); std::vector<std::string>::iterator piter; piter = std::find(parnames.begin(), parnames.end(), paramname); @@ -793,8 +793,8 @@ GeneratePeaks::createDataWorkspace(std::vector<double> binparameters) { /** Add function's parameter names after peak function name */ -std::vector<std::string> -GeneratePeaks::addFunctionParameterNames(std::vector<std::string> funcnames) { +std::vector<std::string> GeneratePeaks::addFunctionParameterNames( + const std::vector<std::string> &funcnames) { std::vector<std::string> vec_funcparnames; for (auto &funcname : funcnames) { diff --git a/Framework/Algorithms/src/GetDetOffsetsMultiPeaks.cpp b/Framework/Algorithms/src/GetDetOffsetsMultiPeaks.cpp index 6dfb4ce07d7c669f831da820e0d5205fa716fd64..d0aae901fc3ad91d3e187ad89837cad9e9043fd7 100644 --- a/Framework/Algorithms/src/GetDetOffsetsMultiPeaks.cpp +++ b/Framework/Algorithms/src/GetDetOffsetsMultiPeaks.cpp @@ -399,7 +399,7 @@ void GetDetOffsetsMultiPeaks::processProperties() { * @throw Exception::RuntimeError If ... ... */ void GetDetOffsetsMultiPeaks::importFitWindowTableWorkspace( - TableWorkspace_sptr windowtablews) { + const TableWorkspace_sptr &windowtablews) { // Check number of columns matches number of peaks size_t numcols = windowtablews->columnCount(); size_t numpeaks = m_peakPositions.size(); @@ -721,7 +721,7 @@ void GetDetOffsetsMultiPeaks::fitPeaksOffset( // Set up GSL minimzer const gsl_multimin_fminimizer_type *T = gsl_multimin_fminimizer_nmsimplex; - gsl_multimin_fminimizer *s = nullptr; + gsl_vector *ss, *x; gsl_multimin_function minex_func; @@ -729,7 +729,6 @@ void GetDetOffsetsMultiPeaks::fitPeaksOffset( size_t nopt = 1; size_t iter = 0; int status = 0; - double size; /* Starting point */ x = gsl_vector_alloc(nopt); @@ -744,7 +743,7 @@ void GetDetOffsetsMultiPeaks::fitPeaksOffset( minex_func.f = &gsl_costFunction; minex_func.params = ¶ms; - s = gsl_multimin_fminimizer_alloc(T, nopt); + gsl_multimin_fminimizer *s = gsl_multimin_fminimizer_alloc(T, nopt); gsl_multimin_fminimizer_set(s, &minex_func, x, ss); do { @@ -753,7 +752,7 @@ void GetDetOffsetsMultiPeaks::fitPeaksOffset( if (status) break; - size = gsl_multimin_fminimizer_size(s); + double size = gsl_multimin_fminimizer_size(s); status = gsl_multimin_test_size(size, 1e-4); } while (status == GSL_CONTINUE && iter < 50); @@ -831,7 +830,7 @@ void deletePeaks(std::vector<size_t> &banned, std::vector<double> &peakPosToFit, * @return The number of peaks in range */ int GetDetOffsetsMultiPeaks::fitSpectra( - const int64_t wi, MatrixWorkspace_sptr inputW, + const int64_t wi, const MatrixWorkspace_sptr &inputW, const std::vector<double> &peakPositions, const std::vector<double> &fitWindows, size_t &nparams, double &minD, double &maxD, std::vector<double> &peakPosToFit, @@ -1178,7 +1177,7 @@ void GetDetOffsetsMultiPeaks::createInformationWorkspaces() { * (thread-safe) */ void GetDetOffsetsMultiPeaks::addInfoToReportWS( - int wi, FitPeakOffsetResult offsetresult, + int wi, const FitPeakOffsetResult &offsetresult, const std::vector<double> &tofitpeakpositions, const std::vector<double> &fittedpeakpositions) { // Offset calculation status diff --git a/Framework/Algorithms/src/GetEi.cpp b/Framework/Algorithms/src/GetEi.cpp index 4887378a71892a477d22e65b733330c2782d66c5..0484e539f0343fe4da0c48a01ef760842df84fd1 100644 --- a/Framework/Algorithms/src/GetEi.cpp +++ b/Framework/Algorithms/src/GetEi.cpp @@ -163,9 +163,9 @@ void GetEi::exec() { * passed to this function second * @throw NotFoundError if no detector is found for the detector ID given */ -void GetEi::getGeometry(API::MatrixWorkspace_const_sptr WS, specnum_t mon0Spec, - specnum_t mon1Spec, double &monitor0Dist, - double &monitor1Dist) const { +void GetEi::getGeometry(const API::MatrixWorkspace_const_sptr &WS, + specnum_t mon0Spec, specnum_t mon1Spec, + double &monitor0Dist, double &monitor1Dist) const { const IComponent_const_sptr source = WS->getInstrument()->getSource(); // retrieve a pointer to the first detector and get its distance @@ -220,7 +220,7 @@ void GetEi::getGeometry(API::MatrixWorkspace_const_sptr WS, specnum_t mon0Spec, * in the workspace */ std::vector<size_t> GetEi::getMonitorWsIndexs( - API::MatrixWorkspace_const_sptr WS, specnum_t specNum1, + const API::MatrixWorkspace_const_sptr &WS, specnum_t specNum1, specnum_t specNum2) const { // getting spectra numbers from detector IDs is // hard because the map works the other way, // getting index numbers from spectra numbers has @@ -285,7 +285,7 @@ double GetEi::timeToFly(double s, double E_KE) const { * @throw out_of_range if the peak runs off the edge of the histogram * @throw runtime_error a Child Algorithm just falls over */ -double GetEi::getPeakCentre(API::MatrixWorkspace_const_sptr WS, +double GetEi::getPeakCentre(const API::MatrixWorkspace_const_sptr &WS, const size_t monitIn, const double peakTime) { const auto ×Array = WS->x(monitIn); // we search for the peak only inside some window because there are often more diff --git a/Framework/Algorithms/src/GetEi2.cpp b/Framework/Algorithms/src/GetEi2.cpp index 794f6078f7faecf549d707226627f790c6bc26b5..205a6222d5eb9b4ae0fd15aae05e85aa9a5ea0fd 100644 --- a/Framework/Algorithms/src/GetEi2.cpp +++ b/Framework/Algorithms/src/GetEi2.cpp @@ -24,6 +24,7 @@ #include <boost/lexical_cast.hpp> #include <cmath> #include <sstream> +#include <utility> using namespace Mantid::Kernel; using namespace Mantid::API; @@ -395,7 +396,7 @@ GetEi2::extractSpectrum(size_t ws_index, const double start, const double end) { * @returns The width of the peak at half height */ double GetEi2::calculatePeakWidthAtHalfHeight( - API::MatrixWorkspace_sptr data_ws, const double prominence, + const API::MatrixWorkspace_sptr &data_ws, const double prominence, std::vector<double> &peak_x, std::vector<double> &peak_y, std::vector<double> &peak_e) const { // Use WS->points() to create a temporary vector of bin_centre values to work @@ -622,11 +623,11 @@ double GetEi2::calculatePeakWidthAtHalfHeight( * considered a "real" peak * @return The calculated first moment */ -double GetEi2::calculateFirstMoment(API::MatrixWorkspace_sptr monitor_ws, +double GetEi2::calculateFirstMoment(const API::MatrixWorkspace_sptr &monitor_ws, const double prominence) { std::vector<double> peak_x, peak_y, peak_e; - calculatePeakWidthAtHalfHeight(monitor_ws, prominence, peak_x, peak_y, - peak_e); + calculatePeakWidthAtHalfHeight(std::move(monitor_ws), prominence, peak_x, + peak_y, peak_e); // Area double area(0.0), dummy(0.0); @@ -649,9 +650,9 @@ double GetEi2::calculateFirstMoment(API::MatrixWorkspace_sptr monitor_ws, * @param end :: The maximum value for the new bin range * @returns The rebinned workspace */ -API::MatrixWorkspace_sptr GetEi2::rebin(API::MatrixWorkspace_sptr monitor_ws, - const double first, const double width, - const double end) { +API::MatrixWorkspace_sptr +GetEi2::rebin(const API::MatrixWorkspace_sptr &monitor_ws, const double first, + const double width, const double end) { IAlgorithm_sptr childAlg = createChildAlgorithm("Rebin"); childAlg->setProperty("InputWorkspace", monitor_ws); std::ostringstream binParams; diff --git a/Framework/Algorithms/src/GetQsInQENSData.cpp b/Framework/Algorithms/src/GetQsInQENSData.cpp index 090cf53942b5e49a658501c483cb0dfdf510df3e..1d70e67da631b9624a0cdcfab13f5b2ab2a2e5de 100644 --- a/Framework/Algorithms/src/GetQsInQENSData.cpp +++ b/Framework/Algorithms/src/GetQsInQENSData.cpp @@ -88,7 +88,7 @@ void GetQsInQENSData::exec() { * @return The extracted Q-values as a vector. */ MantidVec GetQsInQENSData::extractQValues( - const Mantid::API::MatrixWorkspace_sptr workspace) { + const Mantid::API::MatrixWorkspace_sptr &workspace) { size_t numSpectra = workspace->getNumberHistograms(); Axis *qAxis; diff --git a/Framework/Algorithms/src/GetTimeSeriesLogInformation.cpp b/Framework/Algorithms/src/GetTimeSeriesLogInformation.cpp index 25e22a3ce72a8deb41efb693db9d362a9be509da..531e79371687406d82ed0fec125bb6d733bd3dc1 100644 --- a/Framework/Algorithms/src/GetTimeSeriesLogInformation.cpp +++ b/Framework/Algorithms/src/GetTimeSeriesLogInformation.cpp @@ -299,7 +299,7 @@ TableWorkspace_sptr GetTimeSeriesLogInformation::generateStatisticTable() { * * This algorithm should be reconsidered how to work with it. */ -void GetTimeSeriesLogInformation::exportErrorLog(MatrixWorkspace_sptr ws, +void GetTimeSeriesLogInformation::exportErrorLog(const MatrixWorkspace_sptr &ws, vector<DateAndTime> abstimevec, double dts) { std::string outputdir = getProperty("OutputDirectory"); diff --git a/Framework/Algorithms/src/He3TubeEfficiency.cpp b/Framework/Algorithms/src/He3TubeEfficiency.cpp index 8303b71d23fa16364c4e34b159dd6335d4f0fd17..2c71546a9c36d506b20ce5311a9b17e6c7aaae60 100644 --- a/Framework/Algorithms/src/He3TubeEfficiency.cpp +++ b/Framework/Algorithms/src/He3TubeEfficiency.cpp @@ -381,9 +381,9 @@ void He3TubeEfficiency::logErrors() const { * @param idet :: the current detector * @return the value of the detector property */ -double He3TubeEfficiency::getParameter(std::string wsPropName, +double He3TubeEfficiency::getParameter(const std::string &wsPropName, std::size_t currentIndex, - std::string detPropName, + const std::string &detPropName, const Geometry::IDetector &idet) { std::vector<double> wsProp = this->getProperty(wsPropName); diff --git a/Framework/Algorithms/src/IQTransform.cpp b/Framework/Algorithms/src/IQTransform.cpp index a3418b84c13d232fe7f77380fd4bfbef29fc2c5a..4f289f16ee27a142c19425ccf7ab99008382ad10 100644 --- a/Framework/Algorithms/src/IQTransform.cpp +++ b/Framework/Algorithms/src/IQTransform.cpp @@ -7,12 +7,14 @@ //---------------------------------------------------------------------- // Includes //---------------------------------------------------------------------- -#include "MantidAlgorithms/IQTransform.h" +#include <utility> + #include "MantidAPI/Axis.h" #include "MantidAPI/IncreasingAxisValidator.h" #include "MantidAPI/MatrixWorkspace.h" #include "MantidAPI/RawCountValidator.h" #include "MantidAPI/WorkspaceUnitValidator.h" +#include "MantidAlgorithms/IQTransform.h" #include "MantidDataObjects/TableWorkspace.h" #include "MantidDataObjects/Workspace2D.h" #include "MantidDataObjects/WorkspaceCreation.h" @@ -157,11 +159,11 @@ void IQTransform::exec() { * @param background The workspace containing the background values */ API::MatrixWorkspace_sptr -IQTransform::subtractBackgroundWS(API::MatrixWorkspace_sptr ws, - API::MatrixWorkspace_sptr background) { +IQTransform::subtractBackgroundWS(const API::MatrixWorkspace_sptr &ws, + const API::MatrixWorkspace_sptr &background) { g_log.debug() << "Subtracting the workspace " << background->getName() << " from the input workspace.\n"; - return ws - background; + return std::move(ws) - background; } /** @name Available transformation functions */ @@ -172,7 +174,7 @@ IQTransform::subtractBackgroundWS(API::MatrixWorkspace_sptr ws, * @throw std::range_error if an attempt is made to take log of a negative * number */ -void IQTransform::guinierSpheres(API::MatrixWorkspace_sptr ws) { +void IQTransform::guinierSpheres(const API::MatrixWorkspace_sptr &ws) { auto &X = ws->mutableX(0); auto &Y = ws->mutableY(0); auto &E = ws->mutableE(0); @@ -192,7 +194,7 @@ void IQTransform::guinierSpheres(API::MatrixWorkspace_sptr ws) { * @throw std::range_error if an attempt is made to take log of a negative * number */ -void IQTransform::guinierRods(API::MatrixWorkspace_sptr ws) { +void IQTransform::guinierRods(const API::MatrixWorkspace_sptr &ws) { auto &X = ws->mutableX(0); auto &Y = ws->mutableY(0); auto &E = ws->mutableE(0); @@ -215,7 +217,7 @@ void IQTransform::guinierRods(API::MatrixWorkspace_sptr ws) { * @throw std::range_error if an attempt is made to take log of a negative * number */ -void IQTransform::guinierSheets(API::MatrixWorkspace_sptr ws) { +void IQTransform::guinierSheets(const API::MatrixWorkspace_sptr &ws) { auto &X = ws->mutableX(0); auto &Y = ws->mutableY(0); auto &E = ws->mutableE(0); @@ -237,7 +239,7 @@ void IQTransform::guinierSheets(API::MatrixWorkspace_sptr ws) { * The output is set to zero for negative input Y values * @param ws The workspace to be transformed */ -void IQTransform::zimm(API::MatrixWorkspace_sptr ws) { +void IQTransform::zimm(const API::MatrixWorkspace_sptr &ws) { auto &X = ws->mutableX(0); auto &Y = ws->mutableY(0); auto &E = ws->mutableE(0); @@ -261,7 +263,7 @@ void IQTransform::zimm(API::MatrixWorkspace_sptr ws) { * The output is set to zero for negative input Y values * @param ws The workspace to be transformed */ -void IQTransform::debyeBueche(API::MatrixWorkspace_sptr ws) { +void IQTransform::debyeBueche(const API::MatrixWorkspace_sptr &ws) { auto &X = ws->mutableX(0); auto &Y = ws->mutableY(0); auto &E = ws->mutableE(0); @@ -284,7 +286,7 @@ void IQTransform::debyeBueche(API::MatrixWorkspace_sptr ws) { /** Performs the Holtzer transformation: IQ v Q * @param ws The workspace to be transformed */ -void IQTransform::holtzer(API::MatrixWorkspace_sptr ws) { +void IQTransform::holtzer(const API::MatrixWorkspace_sptr &ws) { auto &X = ws->mutableX(0); auto &Y = ws->mutableY(0); auto &E = ws->mutableE(0); @@ -299,7 +301,7 @@ void IQTransform::holtzer(API::MatrixWorkspace_sptr ws) { /** Performs the Kratky transformation: IQ^2 v Q * @param ws The workspace to be transformed */ -void IQTransform::kratky(API::MatrixWorkspace_sptr ws) { +void IQTransform::kratky(const API::MatrixWorkspace_sptr &ws) { auto &X = ws->mutableX(0); auto &Y = ws->mutableY(0); auto &E = ws->mutableE(0); @@ -317,7 +319,7 @@ void IQTransform::kratky(API::MatrixWorkspace_sptr ws) { /** Performs the Porod transformation: IQ^4 v Q * @param ws The workspace to be transformed */ -void IQTransform::porod(API::MatrixWorkspace_sptr ws) { +void IQTransform::porod(const API::MatrixWorkspace_sptr &ws) { auto &X = ws->mutableX(0); auto &Y = ws->mutableY(0); auto &E = ws->mutableE(0); @@ -337,7 +339,7 @@ void IQTransform::porod(API::MatrixWorkspace_sptr ws) { * @throw std::range_error if an attempt is made to take log of a negative * number */ -void IQTransform::logLog(API::MatrixWorkspace_sptr ws) { +void IQTransform::logLog(const API::MatrixWorkspace_sptr &ws) { auto &X = ws->mutableX(0); auto &Y = ws->mutableY(0); auto &E = ws->mutableE(0); @@ -360,7 +362,7 @@ void IQTransform::logLog(API::MatrixWorkspace_sptr ws) { * @throw std::range_error if an attempt is made to take log of a negative * number */ -void IQTransform::general(API::MatrixWorkspace_sptr ws) { +void IQTransform::general(const API::MatrixWorkspace_sptr &ws) { auto &X = ws->mutableX(0); auto &Y = ws->mutableY(0); auto &E = ws->mutableE(0); diff --git a/Framework/Algorithms/src/IdentifyNoisyDetectors.cpp b/Framework/Algorithms/src/IdentifyNoisyDetectors.cpp index 68ff265fb3f7e863cd9592c93cea708af64a1b96..a60e373cc3918313aaea2ff815afff2435a2363a 100644 --- a/Framework/Algorithms/src/IdentifyNoisyDetectors.cpp +++ b/Framework/Algorithms/src/IdentifyNoisyDetectors.cpp @@ -149,8 +149,8 @@ void IdentifyNoisyDetectors::exec() { * @param values :: stddeviations of each spectra (I think) */ void IdentifyNoisyDetectors::getStdDev(API::Progress &progress, - MatrixWorkspace_sptr valid, - MatrixWorkspace_sptr values) { + const MatrixWorkspace_sptr &valid, + const MatrixWorkspace_sptr &values) { const auto nhist = static_cast<int>(valid->getNumberHistograms()); int count = 0; double mean = 0.0; diff --git a/Framework/Algorithms/src/IntegrateByComponent.cpp b/Framework/Algorithms/src/IntegrateByComponent.cpp index 23676f58d092e7829ba2225604ab27b75cf4fd17..f0da9938dff934b73e7fb7b3b3d05d9d2a26cc7c 100644 --- a/Framework/Algorithms/src/IntegrateByComponent.cpp +++ b/Framework/Algorithms/src/IntegrateByComponent.cpp @@ -158,8 +158,8 @@ void IntegrateByComponent::exec() { * @return vector of vectors, containing each spectrum that belongs to each * group */ -std::vector<std::vector<size_t>> -IntegrateByComponent::makeInstrumentMap(API::MatrixWorkspace_sptr countsWS) { +std::vector<std::vector<size_t>> IntegrateByComponent::makeInstrumentMap( + const API::MatrixWorkspace_sptr &countsWS) { std::vector<std::vector<size_t>> mymap; std::vector<size_t> single; @@ -178,7 +178,8 @@ IntegrateByComponent::makeInstrumentMap(API::MatrixWorkspace_sptr countsWS) { * group */ std::vector<std::vector<size_t>> -IntegrateByComponent::makeMap(API::MatrixWorkspace_sptr countsWS, int parents) { +IntegrateByComponent::makeMap(const API::MatrixWorkspace_sptr &countsWS, + int parents) { std::unordered_multimap<Mantid::Geometry::ComponentID, size_t> mymap; if (parents == 0) // this should not happen in this file, but if one reuses diff --git a/Framework/Algorithms/src/Integration.cpp b/Framework/Algorithms/src/Integration.cpp index 2dcdd1121383359e76b0d4d96a0e6fc92d58a952..0db822108e6a91eaaddb5bc5f53c74aa6a61dc12 100644 --- a/Framework/Algorithms/src/Integration.cpp +++ b/Framework/Algorithms/src/Integration.cpp @@ -349,9 +349,9 @@ void Integration::exec() { /** * Uses rebin to reduce event workspaces to a single bin histogram */ -API::MatrixWorkspace_sptr -Integration::rangeFilterEventWorkspace(API::MatrixWorkspace_sptr workspace, - double minRange, double maxRange) { +API::MatrixWorkspace_sptr Integration::rangeFilterEventWorkspace( + const API::MatrixWorkspace_sptr &workspace, double minRange, + double maxRange) { bool childLog = g_log.is(Logger::Priority::PRIO_DEBUG); auto childAlg = createChildAlgorithm("Rebin", 0, 0.5, childLog); childAlg->setProperty("InputWorkspace", workspace); diff --git a/Framework/Algorithms/src/InterpolatingRebin.cpp b/Framework/Algorithms/src/InterpolatingRebin.cpp index 83d372c4125570f61744b191b03a33bda85997df..05466d4790c93ac2603e41b6c27ec219a2a16e96 100644 --- a/Framework/Algorithms/src/InterpolatingRebin.cpp +++ b/Framework/Algorithms/src/InterpolatingRebin.cpp @@ -144,9 +144,9 @@ void InterpolatingRebin::exec() { * the histograms must corrospond with the number of x-values in XValues_new */ void InterpolatingRebin::outputYandEValues( - API::MatrixWorkspace_const_sptr inputW, + const API::MatrixWorkspace_const_sptr &inputW, const HistogramData::BinEdges &XValues_new, - API::MatrixWorkspace_sptr outputW) { + const API::MatrixWorkspace_sptr &outputW) { g_log.debug() << "Preparing to calculate y-values using splines and estimate errors\n"; diff --git a/Framework/Algorithms/src/MagFormFactorCorrection.cpp b/Framework/Algorithms/src/MagFormFactorCorrection.cpp index 5cd00fbdf356ede05c09d2dfbd00c3b13215d0fe..d49836999fcbb4cecfe60c19affbdf2d9764ea44 100644 --- a/Framework/Algorithms/src/MagFormFactorCorrection.cpp +++ b/Framework/Algorithms/src/MagFormFactorCorrection.cpp @@ -96,9 +96,11 @@ void MagFormFactorCorrection::exec() { // Gets the vector of form factor values std::vector<double> FF; FF.reserve(Qvals.size()); - for (double Qval : Qvals) { - FF.emplace_back(ion.analyticalFormFactor(Qval * Qval)); - } + + std::transform( + Qvals.begin(), Qvals.end(), std::back_inserter(FF), + [&ion](double qval) { return ion.analyticalFormFactor(qval * qval); }); + if (!ffwsStr.empty()) { HistogramBuilder builder; builder.setX(Qvals.size()); diff --git a/Framework/Algorithms/src/MaskBinsFromTable.cpp b/Framework/Algorithms/src/MaskBinsFromTable.cpp index 6ad76da2d7f7e597cd859eb3a8aab010e8e1ea2a..e951b48c5bf1c21f124a9448507793c0c05269f4 100644 --- a/Framework/Algorithms/src/MaskBinsFromTable.cpp +++ b/Framework/Algorithms/src/MaskBinsFromTable.cpp @@ -68,7 +68,7 @@ void MaskBinsFromTable::exec() { /** Call MaskBins * @param dataws :: MatrixWorkspace to mask bins for */ -void MaskBinsFromTable::maskBins(API::MatrixWorkspace_sptr dataws) { +void MaskBinsFromTable::maskBins(const API::MatrixWorkspace_sptr &dataws) { bool firstloop = true; API::MatrixWorkspace_sptr outputws; @@ -134,7 +134,8 @@ void MaskBinsFromTable::maskBins(API::MatrixWorkspace_sptr dataws) { * @param dataws :: MatrixWorkspace to mask */ void MaskBinsFromTable::processMaskBinWorkspace( - TableWorkspace_sptr masktblws, API::MatrixWorkspace_sptr dataws) { + const TableWorkspace_sptr &masktblws, + const API::MatrixWorkspace_sptr &dataws) { // Check input if (!masktblws) throw std::invalid_argument("Input workspace is not a table workspace."); @@ -213,8 +214,8 @@ void MaskBinsFromTable::processMaskBinWorkspace( * @return :: list of spectra/workspace index IDs in string format */ std::string -MaskBinsFromTable::convertToSpectraList(API::MatrixWorkspace_sptr dataws, - std::string detidliststr) { +MaskBinsFromTable::convertToSpectraList(const API::MatrixWorkspace_sptr &dataws, + const std::string &detidliststr) { // Use array property to get a list of detectors vector<int> detidvec; ArrayProperty<int> parser("detids", detidliststr); diff --git a/Framework/Algorithms/src/MaxEnt.cpp b/Framework/Algorithms/src/MaxEnt.cpp index 4807fa4ecb75266e580209bdb8dac7b7ac0a87ac..bfbf95127907bc20710ec00d24315ace441bd0aa 100644 --- a/Framework/Algorithms/src/MaxEnt.cpp +++ b/Framework/Algorithms/src/MaxEnt.cpp @@ -826,7 +826,7 @@ std::vector<double> MaxEnt::applyDistancePenalty( std::vector<double> MaxEnt::updateImage(const std::vector<double> &image, const std::vector<double> &delta, - const std::vector<std::vector<double>> dirs) { + const std::vector<std::vector<double>> &dirs) { if (image.empty() || dirs.empty() || (delta.size() != dirs.size())) { throw std::runtime_error("Cannot calculate new image"); diff --git a/Framework/Algorithms/src/MaxEnt/MaxentCalculator.cpp b/Framework/Algorithms/src/MaxEnt/MaxentCalculator.cpp index 412b37d2bb3e6f91ff7e86e529040c1c48953ff4..4b9603e8f2b861bd3a2d4493ef45d1b6121b79f1 100644 --- a/Framework/Algorithms/src/MaxEnt/MaxentCalculator.cpp +++ b/Framework/Algorithms/src/MaxEnt/MaxentCalculator.cpp @@ -6,6 +6,7 @@ // SPDX - License - Identifier: GPL - 3.0 + #include "MantidAlgorithms/MaxEnt/MaxentCalculator.h" #include <cmath> +#include <utility> namespace Mantid { namespace Algorithms { @@ -21,7 +22,7 @@ MaxentCalculator::MaxentCalculator(MaxentEntropy_sptr entropy, MaxentTransform_sptr transform) : m_data(), m_errors(), m_image(), m_dataCalc(), m_background(1.0), m_angle(-1.), m_chisq(-1.), m_directionsIm(), m_coeffs(), - m_entropy(entropy), m_transform(transform) {} + m_entropy(std::move(entropy)), m_transform(std::move(transform)) {} /** * Calculates the gradient of chi-square using the experimental data, calculated diff --git a/Framework/Algorithms/src/MaxEnt/MaxentTransformFourier.cpp b/Framework/Algorithms/src/MaxEnt/MaxentTransformFourier.cpp index 560af008dbe233d6b8e581080f29f37a966d1503..ed0aabea5546a4eaadc44f1c60548a702c1c728a 100644 --- a/Framework/Algorithms/src/MaxEnt/MaxentTransformFourier.cpp +++ b/Framework/Algorithms/src/MaxEnt/MaxentTransformFourier.cpp @@ -6,6 +6,8 @@ // SPDX - License - Identifier: GPL - 3.0 + #include "MantidAlgorithms/MaxEnt/MaxentTransformFourier.h" #include <boost/shared_array.hpp> +#include <utility> + #include <gsl/gsl_fft_complex.h> namespace Mantid { @@ -14,7 +16,7 @@ namespace Algorithms { /** Constructor */ MaxentTransformFourier::MaxentTransformFourier(MaxentSpace_sptr dataSpace, MaxentSpace_sptr imageSpace) - : m_dataSpace(dataSpace), m_imageSpace(imageSpace) {} + : m_dataSpace(std::move(dataSpace)), m_imageSpace(std::move(imageSpace)) {} /** * Transforms a 1D signal from image space to data space, performing an diff --git a/Framework/Algorithms/src/MaxEnt/MaxentTransformMultiFourier.cpp b/Framework/Algorithms/src/MaxEnt/MaxentTransformMultiFourier.cpp index 19dac6d580ffa24554925e7ef936d3e5fe03954c..7b9e4f392cf82279089da2617ef269244ff7731e 100644 --- a/Framework/Algorithms/src/MaxEnt/MaxentTransformMultiFourier.cpp +++ b/Framework/Algorithms/src/MaxEnt/MaxentTransformMultiFourier.cpp @@ -7,15 +7,17 @@ #include "MantidAlgorithms/MaxEnt/MaxentTransformMultiFourier.h" #include <gsl/gsl_fft_complex.h> +#include <utility> + namespace Mantid { namespace Algorithms { /** Constructor */ MaxentTransformMultiFourier::MaxentTransformMultiFourier( - MaxentSpaceComplex_sptr dataSpace, MaxentSpace_sptr imageSpace, + const MaxentSpaceComplex_sptr &dataSpace, MaxentSpace_sptr imageSpace, size_t numSpec) - : MaxentTransformFourier(dataSpace, imageSpace), m_numSpec(numSpec), - m_linearAdjustments(), m_constAdjustments() {} + : MaxentTransformFourier(dataSpace, std::move(imageSpace)), + m_numSpec(numSpec), m_linearAdjustments(), m_constAdjustments() {} /** * Transforms a 1D signal from image space to data space, performing an @@ -40,9 +42,7 @@ MaxentTransformMultiFourier::imageToData(const std::vector<double> &image) { std::vector<double> data; data.reserve(m_numSpec * dataOneSpec.size()); for (size_t s = 0; s < m_numSpec; s++) { - for (const double &data_item : dataOneSpec) { - data.emplace_back(data_item); - } + std::copy(dataOneSpec.begin(), dataOneSpec.end(), std::back_inserter(data)); } // Apply adjustments (we assume there are sufficient adjustments supplied) diff --git a/Framework/Algorithms/src/MedianDetectorTest.cpp b/Framework/Algorithms/src/MedianDetectorTest.cpp index c86b91516d201c4bea0e99e32c04ef3b1a6ac5ab..e385cbf6f9e4301f93ed55c0af35c1f9281f0152 100644 --- a/Framework/Algorithms/src/MedianDetectorTest.cpp +++ b/Framework/Algorithms/src/MedianDetectorTest.cpp @@ -238,7 +238,8 @@ API::MatrixWorkspace_sptr MedianDetectorTest::getSolidAngles(int firstSpec, * @returns The number failed. */ int MedianDetectorTest::maskOutliers( - const std::vector<double> medianvec, API::MatrixWorkspace_sptr countsWS, + const std::vector<double> &medianvec, + const API::MatrixWorkspace_sptr &countsWS, std::vector<std::vector<size_t>> indexmap) { // Fractions of the median @@ -300,10 +301,10 @@ int MedianDetectorTest::maskOutliers( * skipped. */ int MedianDetectorTest::doDetectorTests( - const API::MatrixWorkspace_sptr countsWS, - const std::vector<double> medianvec, + const API::MatrixWorkspace_sptr &countsWS, + const std::vector<double> &medianvec, std::vector<std::vector<size_t>> indexmap, - API::MatrixWorkspace_sptr maskWS) { + const API::MatrixWorkspace_sptr &maskWS) { g_log.debug("Applying the criteria to find failing detectors"); // A spectra can't fail if the statistics show its value is consistent with diff --git a/Framework/Algorithms/src/Minus.cpp b/Framework/Algorithms/src/Minus.cpp index 08319d1e2e88f92419f51f5d1734cdc1041afcfe..12999ca54492af943a544ab43cf462b8c8d49c5f 100644 --- a/Framework/Algorithms/src/Minus.cpp +++ b/Framework/Algorithms/src/Minus.cpp @@ -137,8 +137,8 @@ void Minus::checkRequirements() { * @return workspace unit compatibility flag */ bool Minus::checkUnitCompatibility( - const API::MatrixWorkspace_const_sptr lhs, - const API::MatrixWorkspace_const_sptr rhs) const { + const API::MatrixWorkspace_const_sptr &lhs, + const API::MatrixWorkspace_const_sptr &rhs) const { if (lhs->size() > 1 && rhs->size() > 1) { if (lhs->YUnit() != rhs->YUnit()) { g_log.error("The two workspaces are not compatible because they have " diff --git a/Framework/Algorithms/src/ModeratorTzero.cpp b/Framework/Algorithms/src/ModeratorTzero.cpp index 6960ca6d2d9b4c943182b2d9bc607f10da85bb22..67e1a3395f14356c10f7f78dcde053f8499ba141 100644 --- a/Framework/Algorithms/src/ModeratorTzero.cpp +++ b/Framework/Algorithms/src/ModeratorTzero.cpp @@ -354,9 +354,9 @@ void ModeratorTzero::execEvent(const std::string &emode) { evlist.mutableX() -= t0_direct; MantidVec tofs = evlist.getTofs(); - for (double &tof : tofs) { - tof -= t0_direct; - } + + std::transform(tofs.begin(), tofs.end(), tofs.begin(), + [&t0_direct](double tof) { return tof - t0_direct; }); evlist.setTofs(tofs); evlist.setSortOrder(Mantid::DataObjects::EventSortType::UNSORTED); } // end of else if(emode=="Direct") diff --git a/Framework/Algorithms/src/NormaliseByCurrent.cpp b/Framework/Algorithms/src/NormaliseByCurrent.cpp index b563a9730096cf1e5d1f148e1c127c87f6425e93..fce8815e6c6d02bcfc7a2450a5edf127c6c3abb8 100644 --- a/Framework/Algorithms/src/NormaliseByCurrent.cpp +++ b/Framework/Algorithms/src/NormaliseByCurrent.cpp @@ -45,7 +45,7 @@ void NormaliseByCurrent::init() { * workspace logs or if the values are invalid (0) */ double NormaliseByCurrent::extractCharge( - boost::shared_ptr<Mantid::API::MatrixWorkspace> inputWS, + const boost::shared_ptr<Mantid::API::MatrixWorkspace> &inputWS, const bool integratePCharge) const { // Get the good proton charge and check it's valid double charge(-1.0); diff --git a/Framework/Algorithms/src/NormaliseByDetector.cpp b/Framework/Algorithms/src/NormaliseByDetector.cpp index db0469b3fb0873be0a7e48f5adeb419c23c13fe4..a118ba7e13e61db4d457783f18513ad89b6e9750 100644 --- a/Framework/Algorithms/src/NormaliseByDetector.cpp +++ b/Framework/Algorithms/src/NormaliseByDetector.cpp @@ -73,7 +73,7 @@ void NormaliseByDetector::init() { } const Geometry::FitParameter NormaliseByDetector::tryParseFunctionParameter( - Geometry::Parameter_sptr parameter, const Geometry::IDetector &det) { + const Geometry::Parameter_sptr ¶meter, const Geometry::IDetector &det) { if (parameter == nullptr) { std::stringstream stream; stream << det.getName() @@ -99,10 +99,9 @@ normalisation routine. use. @param prog: progress reporting object. */ -void NormaliseByDetector::processHistogram(size_t wsIndex, - MatrixWorkspace_const_sptr inWS, - MatrixWorkspace_sptr denominatorWS, - Progress &prog) { +void NormaliseByDetector::processHistogram( + size_t wsIndex, const MatrixWorkspace_const_sptr &inWS, + const MatrixWorkspace_sptr &denominatorWS, Progress &prog) { const auto ¶mMap = inWS->constInstrumentParameters(); const auto &spectrumInfo = inWS->spectrumInfo(); const auto &det = spectrumInfo.detector(wsIndex); @@ -164,7 +163,7 @@ sequentially. use. */ MatrixWorkspace_sptr -NormaliseByDetector::processHistograms(MatrixWorkspace_sptr inWS) { +NormaliseByDetector::processHistograms(const MatrixWorkspace_sptr &inWS) { const size_t nHistograms = inWS->getNumberHistograms(); const auto progress_items = static_cast<size_t>(double(nHistograms) * 1.2); Progress prog(this, 0.0, 1.0, progress_items); diff --git a/Framework/Algorithms/src/NormaliseToMonitor.cpp b/Framework/Algorithms/src/NormaliseToMonitor.cpp index 5be68fb0999742662affed31fb1d9a7c2ec4aad1..bad96c37993a3e24f3bacb9263c0d2ecc818b242 100644 --- a/Framework/Algorithms/src/NormaliseToMonitor.cpp +++ b/Framework/Algorithms/src/NormaliseToMonitor.cpp @@ -102,7 +102,7 @@ void MonIDPropChanger::applyChanges(const IPropertyManager *algo, // read the monitors list from the workspace and try to do it once for any // particular ws; bool MonIDPropChanger::monitorIdReader( - MatrixWorkspace_const_sptr inputWS) const { + const MatrixWorkspace_const_sptr &inputWS) const { // no workspace if (!inputWS) return false; diff --git a/Framework/Algorithms/src/PDCalibration.cpp b/Framework/Algorithms/src/PDCalibration.cpp index 3edaa4e0f412c559ec5e5dd5dfd8bcdb9baab135..a5de2509c4725be4aa58f533c5bfa965497156f3 100644 --- a/Framework/Algorithms/src/PDCalibration.cpp +++ b/Framework/Algorithms/src/PDCalibration.cpp @@ -70,7 +70,7 @@ const auto isNonZero = [](const double value) { return value != 0.; }; /// private inner class class PDCalibration::FittedPeaks { public: - FittedPeaks(API::MatrixWorkspace_const_sptr wksp, + FittedPeaks(const API::MatrixWorkspace_const_sptr &wksp, const std::size_t wkspIndex) { this->wkspIndex = wkspIndex; @@ -108,7 +108,7 @@ public: void setPositions(const std::vector<double> &peaksInD, const std::vector<double> &peaksInDWindows, - std::function<double(double)> toTof) { + const std::function<double(double)> &toTof) { // clear out old values inDPos.clear(); inTofPos.clear(); @@ -307,7 +307,7 @@ std::map<std::string, std::string> PDCalibration::validateInputs() { namespace { -bool hasDasIDs(API::ITableWorkspace_const_sptr table) { +bool hasDasIDs(const API::ITableWorkspace_const_sptr &table) { const auto columnNames = table->getColumnNames(); return (std::find(columnNames.begin(), columnNames.end(), std::string("dasid")) != columnNames.end()); @@ -755,14 +755,13 @@ double fitDIFCtZeroDIFA(std::vector<double> &peaks, double &difc, double &t0, size_t iter = 0; // number of iterations const size_t MAX_ITER = 75 * numParams; int status = 0; - double size; do { iter++; status = gsl_multimin_fminimizer_iterate(minimizer); if (status) break; - size = gsl_multimin_fminimizer_size(minimizer); + double size = gsl_multimin_fminimizer_size(minimizer); status = gsl_multimin_test_size(size, 1e-4); } while (status == GSL_CONTINUE && iter < MAX_ITER); @@ -939,7 +938,7 @@ vector<double> PDCalibration::getTOFminmax(const double difc, const double difa, return tofminmax; } -MatrixWorkspace_sptr PDCalibration::load(const std::string filename) { +MatrixWorkspace_sptr PDCalibration::load(const std::string &filename) { // TODO this assumes that all files are event-based const double maxChunkSize = getProperty("MaxChunkSize"); const double filterBadPulses = getProperty("FilterBadPulses"); @@ -1186,7 +1185,8 @@ PDCalibration::sortTableWorkspace(API::ITableWorkspace_sptr &table) { /// NEW: convert peak positions in dSpacing to peak centers workspace std::pair<API::MatrixWorkspace_sptr, API::MatrixWorkspace_sptr> PDCalibration::createTOFPeakCenterFitWindowWorkspaces( - API::MatrixWorkspace_sptr dataws, const double peakWindowMaxInDSpacing) { + const API::MatrixWorkspace_sptr &dataws, + const double peakWindowMaxInDSpacing) { // calculate from peaks in dpsacing to peak fit window in dspacing const auto windowsInDSpacing = diff --git a/Framework/Algorithms/src/PaddingAndApodization.cpp b/Framework/Algorithms/src/PaddingAndApodization.cpp index a2975167ee49ae280e564c40c15837cde913e625..c4222210c4b5a5beaed425bdcd6808e4841971fb 100644 --- a/Framework/Algorithms/src/PaddingAndApodization.cpp +++ b/Framework/Algorithms/src/PaddingAndApodization.cpp @@ -115,7 +115,6 @@ void PaddingAndApodization::exec() { fptr apodizationFunction = getApodizationFunction(method); // Do the specified spectra only auto specLength = static_cast<int>(spectra.size()); - std::vector<double> norm(specLength, 0.0); PARALLEL_FOR_IF(Kernel::threadSafe(*inputWS, *outputWS)) for (int i = 0; i < specLength; ++i) { PARALLEL_START_INTERUPT_REGION @@ -145,7 +144,7 @@ using fptr = double (*)(const double, const double); * @param method :: [input] The name of the chosen function * @returns :: pointer to the function */ -fptr PaddingAndApodization::getApodizationFunction(const std::string method) { +fptr PaddingAndApodization::getApodizationFunction(const std::string &method) { if (method == "None") { return ApodizationFunctions::none; } else if (method == "Lorentz") { diff --git a/Framework/Algorithms/src/ParallaxCorrection.cpp b/Framework/Algorithms/src/ParallaxCorrection.cpp index 040288fdf7553a5b92695983b5e15e0c6c6e18c2..7d93a5df9d6aa57f81ac55b2784398ddbab1573c 100644 --- a/Framework/Algorithms/src/ParallaxCorrection.cpp +++ b/Framework/Algorithms/src/ParallaxCorrection.cpp @@ -104,10 +104,9 @@ void ParallaxCorrection::init() { * @param parallax : the correction formula for the bank * @param direction : the tube direction in the bank */ -void ParallaxCorrection::performCorrection(API::MatrixWorkspace_sptr outWS, - const std::vector<size_t> &indices, - const std::string ¶llax, - const std::string &direction) { +void ParallaxCorrection::performCorrection( + const API::MatrixWorkspace_sptr &outWS, const std::vector<size_t> &indices, + const std::string ¶llax, const std::string &direction) { double t; mu::Parser muParser; muParser.DefineVar("t", &t); diff --git a/Framework/Algorithms/src/PerformIndexOperations.cpp b/Framework/Algorithms/src/PerformIndexOperations.cpp index 13f8589c3e94d33d661e67c86d21c835b98806fd..9ba817654d218e7e3464a0c17d70b11871b31d34 100644 --- a/Framework/Algorithms/src/PerformIndexOperations.cpp +++ b/Framework/Algorithms/src/PerformIndexOperations.cpp @@ -10,6 +10,7 @@ #include "MantidKernel/Strings.h" #include <boost/algorithm/string.hpp> #include <boost/regex.hpp> +#include <utility> using namespace Mantid::Kernel; using namespace Mantid::API; @@ -31,7 +32,7 @@ public: if (!this->isValid()) { return toAppend; } else { - MatrixWorkspace_sptr current = this->execute(inputWS); + MatrixWorkspace_sptr current = this->execute(std::move(inputWS)); Mantid::API::AlgorithmManagerImpl &factory = Mantid::API::AlgorithmManager::Instance(); auto conjoinWorkspaceAlg = factory.create("ConjoinWorkspaces"); diff --git a/Framework/Algorithms/src/Plus.cpp b/Framework/Algorithms/src/Plus.cpp index b23ee7b1397d7275496bb7094e3d4f742081204b..94d98002c264b3e558a13eca2b56b46dad987c4d 100644 --- a/Framework/Algorithms/src/Plus.cpp +++ b/Framework/Algorithms/src/Plus.cpp @@ -145,8 +145,8 @@ void Plus::checkRequirements() { * @return workspace unit compatibility flag */ bool Plus::checkUnitCompatibility( - const API::MatrixWorkspace_const_sptr lhs, - const API::MatrixWorkspace_const_sptr rhs) const { + const API::MatrixWorkspace_const_sptr &lhs, + const API::MatrixWorkspace_const_sptr &rhs) const { if (lhs->size() > 1 && rhs->size() > 1) { if (lhs->YUnit() != rhs->YUnit()) { g_log.error("The two workspaces are not compatible because they have " diff --git a/Framework/Algorithms/src/PointByPointVCorrection.cpp b/Framework/Algorithms/src/PointByPointVCorrection.cpp index ee0591db07a0e92d28469261d5a65cf5c1114893..96fc5e9a6e90cd55431adc9efaf6b22b628852fc 100644 --- a/Framework/Algorithms/src/PointByPointVCorrection.cpp +++ b/Framework/Algorithms/src/PointByPointVCorrection.cpp @@ -125,10 +125,10 @@ void PointByPointVCorrection::exec() { // builds which caused the unit tests // to sometimes fail. Maybe this is some compiler bug to do with // using bind2nd within the parrallel macros. - for (double &rY : resultY) { - // Now result is s_i/v_i*Dlam_i*(sum_i s_i)/(sum_i S_i/v_i*Dlam_i) - rY *= factor; - } + + // Now result is s_i/v_i*Dlam_i*(sum_i s_i)/(sum_i S_i/v_i*Dlam_i) + std::transform(resultY.begin(), resultY.end(), resultY.begin(), + [&factor](double rY) { return rY * factor; }); // Finally get the normalized errors for (int j = 0; j < size - 1; j++) diff --git a/Framework/Algorithms/src/PolarizationCorrectionFredrikze.cpp b/Framework/Algorithms/src/PolarizationCorrectionFredrikze.cpp index ae19aba09686296600756d1e6c96d9c96a3222eb..12e68df35d18d8aa05e345170d69fc7d36db9fbf 100644 --- a/Framework/Algorithms/src/PolarizationCorrectionFredrikze.cpp +++ b/Framework/Algorithms/src/PolarizationCorrectionFredrikze.cpp @@ -206,7 +206,7 @@ void PolarizationCorrectionFredrikze::init() { } WorkspaceGroup_sptr -PolarizationCorrectionFredrikze::execPA(WorkspaceGroup_sptr inWS) { +PolarizationCorrectionFredrikze::execPA(const WorkspaceGroup_sptr &inWS) { size_t itemIndex = 0; MatrixWorkspace_sptr Ipp = @@ -276,7 +276,7 @@ PolarizationCorrectionFredrikze::execPA(WorkspaceGroup_sptr inWS) { } WorkspaceGroup_sptr -PolarizationCorrectionFredrikze::execPNR(WorkspaceGroup_sptr inWS) { +PolarizationCorrectionFredrikze::execPNR(const WorkspaceGroup_sptr &inWS) { size_t itemIndex = 0; MatrixWorkspace_sptr Ip = boost::dynamic_pointer_cast<MatrixWorkspace>(inWS->getItem(itemIndex++)); diff --git a/Framework/Algorithms/src/PolarizationCorrectionWildes.cpp b/Framework/Algorithms/src/PolarizationCorrectionWildes.cpp index 8547cdd06f82748820348291ab80f8f794eba15f..95cb7c112f6b7b999c5db21c7b929323d6e0b8dd 100644 --- a/Framework/Algorithms/src/PolarizationCorrectionWildes.cpp +++ b/Framework/Algorithms/src/PolarizationCorrectionWildes.cpp @@ -98,6 +98,7 @@ void fourInputsCorrectedAndErrors( Eigen::Matrix4d F1m; F1m << 1., 0., 0., 0., 0., 1., 0., 0., off1, 0., diag1, 0., 0., off1, 0., diag1; + const auto diag2 = 1. / f2; const auto off2 = (f2 - 1.) / f2; Eigen::Matrix4d F2m; @@ -357,8 +358,8 @@ double twoInputsErrorEstimate10(const double i00, const double e00, return std::sqrt(e10_I00 + e10_I11 + e10_F1 + e10_F2 + e10_P1 + e10_P2); } -Mantid::API::MatrixWorkspace_sptr -createWorkspaceWithHistory(Mantid::API::MatrixWorkspace_const_sptr inputWS) { +Mantid::API::MatrixWorkspace_sptr createWorkspaceWithHistory( + const Mantid::API::MatrixWorkspace_const_sptr &inputWS) { Mantid::API::MatrixWorkspace_sptr outputWS = Mantid::DataObjects::create<Mantid::DataObjects::Workspace2D>(*inputWS); outputWS->history().addHistory(inputWS->getHistory()); diff --git a/Framework/Algorithms/src/PolarizationEfficiencyCor.cpp b/Framework/Algorithms/src/PolarizationEfficiencyCor.cpp index 17af8f92b7768636bc1c443c4c934474fc90e3ab..fb26c987fcb8afa48ab48c626def7e27f11f8252 100644 --- a/Framework/Algorithms/src/PolarizationEfficiencyCor.cpp +++ b/Framework/Algorithms/src/PolarizationEfficiencyCor.cpp @@ -309,8 +309,8 @@ MatrixWorkspace_sptr PolarizationEfficiencyCor::convertToHistogram( //---------------------------------------------------------------------------------------------- /// Convert the efficiencies to histogram MatrixWorkspace_sptr -PolarizationEfficiencyCor::interpolate(MatrixWorkspace_sptr efficiencies, - MatrixWorkspace_sptr inWS) { +PolarizationEfficiencyCor::interpolate(const MatrixWorkspace_sptr &efficiencies, + const MatrixWorkspace_sptr &inWS) { efficiencies->setDistribution(true); auto alg = createChildAlgorithm("RebinToWorkspace"); diff --git a/Framework/Algorithms/src/Q1D2.cpp b/Framework/Algorithms/src/Q1D2.cpp index 2689b26c7d9f2269ca09483ce3fb5b891b8aad36..8a09881898619db57aaee4d2e15f9485202dbb24 100644 --- a/Framework/Algorithms/src/Q1D2.cpp +++ b/Framework/Algorithms/src/Q1D2.cpp @@ -4,7 +4,8 @@ // NScD Oak Ridge National Laboratory, European Spallation Source, // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + -#include "MantidAlgorithms/Q1D2.h" +#include <utility> + #include "MantidAPI/Axis.h" #include "MantidAPI/CommonBinsValidator.h" #include "MantidAPI/HistogramValidator.h" @@ -14,6 +15,7 @@ #include "MantidAPI/WorkspaceFactory.h" #include "MantidAPI/WorkspaceUnitValidator.h" #include "MantidAlgorithms/GravitySANSHelper.h" +#include "MantidAlgorithms/Q1D2.h" #include "MantidAlgorithms/Qhelper.h" #include "MantidDataObjects/Histogram1D.h" #include "MantidDataObjects/Workspace2D.h" @@ -409,12 +411,13 @@ Q1D2::setUpOutputWorkspace(const std::vector<double> &binParams) const { */ void Q1D2::calculateNormalization( const size_t wavStart, const size_t wsIndex, - API::MatrixWorkspace_const_sptr pixelAdj, - API::MatrixWorkspace_const_sptr wavePixelAdj, double const *const binNorms, - double const *const binNormEs, HistogramData::HistogramY::iterator norm, + const API::MatrixWorkspace_const_sptr &pixelAdj, + const API::MatrixWorkspace_const_sptr &wavePixelAdj, + double const *const binNorms, double const *const binNormEs, + HistogramData::HistogramY::iterator norm, HistogramData::HistogramY::iterator normETo2) const { double detectorAdj, detAdjErr; - pixelWeight(pixelAdj, wsIndex, detectorAdj, detAdjErr); + pixelWeight(std::move(pixelAdj), wsIndex, detectorAdj, detAdjErr); // use that the normalization array ends at the start of the error array for (auto n = norm, e = normETo2; n != normETo2; ++n, ++e) { *n = detectorAdj; @@ -444,7 +447,7 @@ void Q1D2::calculateNormalization( * @param[out] error the error on the weight, only non-zero if pixelAdj * @throw LogicError if the solid angle is tiny or negative */ -void Q1D2::pixelWeight(API::MatrixWorkspace_const_sptr pixelAdj, +void Q1D2::pixelWeight(const API::MatrixWorkspace_const_sptr &pixelAdj, const size_t wsIndex, double &weight, double &error) const { const auto &detectorInfo = m_dataWS->detectorInfo(); diff --git a/Framework/Algorithms/src/Q1DWeighted.cpp b/Framework/Algorithms/src/Q1DWeighted.cpp index a01bcbade6732348b70f589fcc08af5edc488ed1..84c54c709cd8100fd0943dc7f7bb098ed4a3de64 100644 --- a/Framework/Algorithms/src/Q1DWeighted.cpp +++ b/Framework/Algorithms/src/Q1DWeighted.cpp @@ -105,7 +105,7 @@ void Q1DWeighted::exec() { * initializes the user inputs * @param inputWS : input workspace */ -void Q1DWeighted::bootstrap(MatrixWorkspace_const_sptr inputWS) { +void Q1DWeighted::bootstrap(const MatrixWorkspace_const_sptr &inputWS) { // Get pixel size and pixel sub-division m_pixelSizeX = getProperty("PixelSizeX"); m_pixelSizeY = getProperty("PixelSizeY"); @@ -167,7 +167,7 @@ void Q1DWeighted::bootstrap(MatrixWorkspace_const_sptr inputWS) { * Performs the azimuthal averaging for each wavelength bin * @param inputWS : the input workspace */ -void Q1DWeighted::calculate(MatrixWorkspace_const_sptr inputWS) { +void Q1DWeighted::calculate(const MatrixWorkspace_const_sptr &inputWS) { // Set up the progress Progress progress(this, 0.0, 1.0, m_nSpec * m_nLambda); @@ -313,7 +313,7 @@ void Q1DWeighted::calculate(MatrixWorkspace_const_sptr inputWS) { * performs final averaging and sets the output workspaces * @param inputWS : the input workspace */ -void Q1DWeighted::finalize(MatrixWorkspace_const_sptr inputWS) { +void Q1DWeighted::finalize(const MatrixWorkspace_const_sptr &inputWS) { MatrixWorkspace_sptr outputWS = createOutputWorkspace(inputWS, m_nQ, m_qBinEdges); setProperty("OutputWorkspace", outputWS); @@ -383,7 +383,7 @@ void Q1DWeighted::finalize(MatrixWorkspace_const_sptr inputWS) { * @return output I(Q) workspace */ MatrixWorkspace_sptr -Q1DWeighted::createOutputWorkspace(MatrixWorkspace_const_sptr parent, +Q1DWeighted::createOutputWorkspace(const MatrixWorkspace_const_sptr &parent, const size_t nBins, const std::vector<double> &binEdges) { diff --git a/Framework/Algorithms/src/Qhelper.cpp b/Framework/Algorithms/src/Qhelper.cpp index 00a6d9d05cce97ac6d4c5baf57c712aed55506fe..d827741972e5227a653007d5a348e085d5982089 100644 --- a/Framework/Algorithms/src/Qhelper.cpp +++ b/Framework/Algorithms/src/Qhelper.cpp @@ -4,9 +4,11 @@ // NScD Oak Ridge National Laboratory, European Spallation Source, // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + -#include "MantidAlgorithms/Qhelper.h" +#include <utility> + #include "MantidAPI/MatrixWorkspace.h" #include "MantidAPI/SpectrumInfo.h" +#include "MantidAlgorithms/Qhelper.h" namespace Mantid { namespace Algorithms { @@ -25,13 +27,13 @@ using namespace Geometry; @param qResolution: the QResolution workspace @throw invalid_argument if the workspaces are not mututially compatible */ -void Qhelper::examineInput(API::MatrixWorkspace_const_sptr dataWS, - API::MatrixWorkspace_const_sptr binAdj, - API::MatrixWorkspace_const_sptr detectAdj, - API::MatrixWorkspace_const_sptr qResolution) { +void Qhelper::examineInput(const API::MatrixWorkspace_const_sptr &dataWS, + const API::MatrixWorkspace_const_sptr &binAdj, + const API::MatrixWorkspace_const_sptr &detectAdj, + const API::MatrixWorkspace_const_sptr &qResolution) { // Check the compatibility of dataWS, binAdj and detectAdj - examineInput(dataWS, binAdj, detectAdj); + examineInput(dataWS, std::move(binAdj), std::move(detectAdj)); // Check the compatibility of the QResolution workspace if (qResolution) { @@ -64,9 +66,9 @@ void Qhelper::examineInput(API::MatrixWorkspace_const_sptr dataWS, one bin @throw invalid_argument if the workspaces are not mututially compatible */ -void Qhelper::examineInput(API::MatrixWorkspace_const_sptr dataWS, - API::MatrixWorkspace_const_sptr binAdj, - API::MatrixWorkspace_const_sptr detectAdj) { +void Qhelper::examineInput(const API::MatrixWorkspace_const_sptr &dataWS, + const API::MatrixWorkspace_const_sptr &binAdj, + const API::MatrixWorkspace_const_sptr &detectAdj) { if (dataWS->getNumberHistograms() < 1) { throw std::invalid_argument( "Empty data workspace passed, can not continue"); @@ -152,7 +154,7 @@ void Qhelper::examineInput(API::MatrixWorkspace_const_sptr dataWS, * @param wsInd spectrum that is being analysed * @return index number of the first bin to include in the calculation */ -size_t Qhelper::waveLengthCutOff(API::MatrixWorkspace_const_sptr dataWS, +size_t Qhelper::waveLengthCutOff(const API::MatrixWorkspace_const_sptr &dataWS, const SpectrumInfo &spectrumInfo, const double RCut, const double WCut, const size_t wsInd) const { @@ -188,8 +190,8 @@ sumOfCounts/sumOfNormFactors equals the * @param sumOfNormFactors sum of normalisation factors */ void Qhelper::outputParts(API::Algorithm *alg, - API::MatrixWorkspace_sptr sumOfCounts, - API::MatrixWorkspace_sptr sumOfNormFactors) { + const API::MatrixWorkspace_sptr &sumOfCounts, + const API::MatrixWorkspace_sptr &sumOfNormFactors) { std::string baseName = alg->getPropertyValue("OutputWorkspace"); alg->declareProperty( diff --git a/Framework/Algorithms/src/Qxy.cpp b/Framework/Algorithms/src/Qxy.cpp index 91cf49b61f8b3bd7225006e313695c326d9aba17..72923aa7c0de8b9c9bbfdc35829705d07166988a 100644 --- a/Framework/Algorithms/src/Qxy.cpp +++ b/Framework/Algorithms/src/Qxy.cpp @@ -402,8 +402,8 @@ double Qxy::getQminFromWs(const API::MatrixWorkspace &inputWorkspace) { * Qx. * @return A pointer to the newly-created workspace */ -API::MatrixWorkspace_sptr -Qxy::setUpOutputWorkspace(API::MatrixWorkspace_const_sptr inputWorkspace) { +API::MatrixWorkspace_sptr Qxy::setUpOutputWorkspace( + const API::MatrixWorkspace_const_sptr &inputWorkspace) { const double max = getProperty("MaxQxy"); const double delta = getProperty("DeltaQ"); const bool log_binning = getProperty("IQxQyLogBinning"); diff --git a/Framework/Algorithms/src/RadiusSum.cpp b/Framework/Algorithms/src/RadiusSum.cpp index 3000143742d1260aa29fff73ec373b2b86da2054..1eb1c907f7253402874001b9bda592cafb2c0f50 100644 --- a/Framework/Algorithms/src/RadiusSum.cpp +++ b/Framework/Algorithms/src/RadiusSum.cpp @@ -272,7 +272,7 @@ void RadiusSum::inputValidationSanityCheck() { * @return True if it is an instrument related workspace. */ bool RadiusSum::inputWorkspaceHasInstrumentAssociated( - API::MatrixWorkspace_sptr inWS) { + const API::MatrixWorkspace_sptr &inWS) { return inWS->getAxis(1)->isSpectra(); } @@ -302,7 +302,7 @@ std::vector<double> RadiusSum::getBoundariesOfInputWorkspace() { *Xmin, Xmax, Ymin, Ymax */ std::vector<double> -RadiusSum::getBoundariesOfNumericImage(API::MatrixWorkspace_sptr inWS) { +RadiusSum::getBoundariesOfNumericImage(const API::MatrixWorkspace_sptr &inWS) { // horizontal axis @@ -359,7 +359,7 @@ RadiusSum::getBoundariesOfNumericImage(API::MatrixWorkspace_sptr inWS) { *Xmin, Xmax, Ymin, Ymax, Zmin, Zmax */ std::vector<double> -RadiusSum::getBoundariesOfInstrument(API::MatrixWorkspace_sptr inWS) { +RadiusSum::getBoundariesOfInstrument(const API::MatrixWorkspace_sptr &inWS) { // This function is implemented based in the following assumption: // - The workspace is composed by spectrum with associated spectrum No which @@ -521,7 +521,8 @@ void RadiusSum::numBinsIsReasonable() { << '\n'; } -double RadiusSum::getMinBinSizeForInstrument(API::MatrixWorkspace_sptr inWS) { +double +RadiusSum::getMinBinSizeForInstrument(const API::MatrixWorkspace_sptr &inWS) { // Assumption made: the detectors are placed one after the other, so the // minimum // reasonalbe size for the bin is the width of one detector. @@ -538,7 +539,8 @@ double RadiusSum::getMinBinSizeForInstrument(API::MatrixWorkspace_sptr inWS) { throw std::invalid_argument("Did not find any non monitor detector position"); } -double RadiusSum::getMinBinSizeForNumericImage(API::MatrixWorkspace_sptr inWS) { +double +RadiusSum::getMinBinSizeForNumericImage(const API::MatrixWorkspace_sptr &inWS) { // The pixel dimensions: // - width: image width/ number of pixels in one row // - height: image height/ number of pixels in one column diff --git a/Framework/Algorithms/src/Rebin.cpp b/Framework/Algorithms/src/Rebin.cpp index 5e8993c4a931899c18926a9f76d92a7f4ea9eda2..7343535d6f43cc138787aadb5442ed3587b7678b 100644 --- a/Framework/Algorithms/src/Rebin.cpp +++ b/Framework/Algorithms/src/Rebin.cpp @@ -309,8 +309,9 @@ void Rebin::exec() { * @param outputWS :: The output workspace * @param hist :: The index of the current histogram */ -void Rebin::propagateMasks(API::MatrixWorkspace_const_sptr inputWS, - API::MatrixWorkspace_sptr outputWS, int hist) { +void Rebin::propagateMasks(const API::MatrixWorkspace_const_sptr &inputWS, + const API::MatrixWorkspace_sptr &outputWS, + int hist) { // Not too happy with the efficiency of this way of doing it, but it's a lot // simpler to use the // existing rebin algorithm to distribute the weights than to re-implement it diff --git a/Framework/Algorithms/src/ReflectometryBackgroundSubtraction.cpp b/Framework/Algorithms/src/ReflectometryBackgroundSubtraction.cpp index 28e19f92abc2fdffd4cb7c92b3b90b22c84d276b..76639056586c9ab9dee093d3ccee69a19bac62dd 100644 --- a/Framework/Algorithms/src/ReflectometryBackgroundSubtraction.cpp +++ b/Framework/Algorithms/src/ReflectometryBackgroundSubtraction.cpp @@ -50,7 +50,8 @@ const std::string ReflectometryBackgroundSubtraction::summary() const { * background */ void ReflectometryBackgroundSubtraction::calculateAverageSpectrumBackground( - MatrixWorkspace_sptr inputWS, const std::vector<specnum_t> &spectraList) { + const MatrixWorkspace_sptr &inputWS, + const std::vector<specnum_t> &spectraList) { auto alg = this->createChildAlgorithm("GroupDetectors"); alg->setProperty("InputWorkspace", inputWS); @@ -156,7 +157,7 @@ void ReflectometryBackgroundSubtraction::calculatePolynomialBackground( * @param indexList :: the ranges of the background region */ void ReflectometryBackgroundSubtraction::calculatePixelBackground( - MatrixWorkspace_sptr inputWS, const std::vector<double> &indexList) { + const MatrixWorkspace_sptr &inputWS, const std::vector<double> &indexList) { const std::vector<int> backgroundRange{static_cast<int>(indexList.front()), static_cast<int>(indexList.back())}; diff --git a/Framework/Algorithms/src/ReflectometryBeamStatistics.cpp b/Framework/Algorithms/src/ReflectometryBeamStatistics.cpp index 38ddb2048d437c96b797b71e0a15085ed06e839d..5ccc81e765e4a1dd5a9dde6253562e8fbd92b272 100644 --- a/Framework/Algorithms/src/ReflectometryBeamStatistics.cpp +++ b/Framework/Algorithms/src/ReflectometryBeamStatistics.cpp @@ -66,8 +66,8 @@ const std::string * @return the slit gap, in meters */ double ReflectometryBeamStatistics::slitSeparation( - Geometry::Instrument_const_sptr instrument, const std::string &slit1Name, - const std::string &slit2Name) { + const Geometry::Instrument_const_sptr &instrument, + const std::string &slit1Name, const std::string &slit2Name) { auto slit1 = instrument->getComponentByName(slit1Name); auto slit2 = instrument->getComponentByName(slit2Name); return (slit1->getPos() - slit2->getPos()).norm(); diff --git a/Framework/Algorithms/src/ReflectometryReductionOne2.cpp b/Framework/Algorithms/src/ReflectometryReductionOne2.cpp index 4a30b192f8a6e961602527e4cb68fdce6134bc20..b78e1286933688d1afa5ec3399aecfc88c88a633 100644 --- a/Framework/Algorithms/src/ReflectometryReductionOne2.cpp +++ b/Framework/Algorithms/src/ReflectometryReductionOne2.cpp @@ -25,6 +25,7 @@ #include "MantidKernel/UnitFactory.h" #include <algorithm> +#include <utility> using namespace Mantid::Kernel; using namespace Mantid::API; @@ -344,7 +345,7 @@ std::string ReflectometryReductionOne2::createDebugWorkspaceName( * and is incremented after the workspace is output */ void ReflectometryReductionOne2::outputDebugWorkspace( - MatrixWorkspace_sptr ws, const std::string &wsName, + const MatrixWorkspace_sptr &ws, const std::string &wsName, const std::string &wsSuffix, const bool debug, int &step) { // Nothing to do if debug is not enabled if (debug) { @@ -503,7 +504,7 @@ MatrixWorkspace_sptr ReflectometryReductionOne2::backgroundSubtraction( * @return : corrected workspace */ MatrixWorkspace_sptr ReflectometryReductionOne2::transOrAlgCorrection( - MatrixWorkspace_sptr detectorWS, const bool detectorWSReduced) { + const MatrixWorkspace_sptr &detectorWS, const bool detectorWSReduced) { MatrixWorkspace_sptr normalized; MatrixWorkspace_sptr transRun = getProperty("FirstTransmissionRun"); @@ -526,7 +527,7 @@ MatrixWorkspace_sptr ReflectometryReductionOne2::transOrAlgCorrection( * @return :: the input workspace normalized by transmission */ MatrixWorkspace_sptr ReflectometryReductionOne2::transmissionCorrection( - MatrixWorkspace_sptr detectorWS, const bool detectorWSReduced) { + const MatrixWorkspace_sptr &detectorWS, const bool detectorWSReduced) { MatrixWorkspace_sptr transmissionWS = getProperty("FirstTransmissionRun"); auto transmissionWSName = transmissionWS->getName(); @@ -615,7 +616,7 @@ MatrixWorkspace_sptr ReflectometryReductionOne2::transmissionCorrection( * @return : corrected workspace */ MatrixWorkspace_sptr ReflectometryReductionOne2::algorithmicCorrection( - MatrixWorkspace_sptr detectorWS) { + const MatrixWorkspace_sptr &detectorWS) { const std::string corrAlgName = getProperty("CorrectionAlgorithm"); @@ -643,7 +644,7 @@ MatrixWorkspace_sptr ReflectometryReductionOne2::algorithmicCorrection( * @return : output workspace in Q */ MatrixWorkspace_sptr -ReflectometryReductionOne2::convertToQ(MatrixWorkspace_sptr inputWS) { +ReflectometryReductionOne2::convertToQ(const MatrixWorkspace_sptr &inputWS) { bool const moreThanOneDetector = inputWS->getDetector(0)->nDets() > 1; bool const shouldCorrectAngle = !(*getProperty("ThetaIn")).isDefault() && !summingInQ(); @@ -709,7 +710,7 @@ void ReflectometryReductionOne2::findDetectorGroups() { // Sort the groups by the first spectrum number in the group (to give the same // output order as GroupDetectors) std::sort(m_detectorGroups.begin(), m_detectorGroups.end(), - [](const std::vector<size_t> a, const std::vector<size_t> b) { + [](const std::vector<size_t> &a, const std::vector<size_t> &b) { return a.front() < b.front(); }); @@ -807,7 +808,7 @@ size_t ReflectometryReductionOne2::twoThetaRDetectorIdx( } void ReflectometryReductionOne2::findWavelengthMinMax( - MatrixWorkspace_sptr inputWS) { + const MatrixWorkspace_sptr &inputWS) { // Get the max/min wavelength of region of interest const double lambdaMin = getProperty("WavelengthMin"); @@ -879,8 +880,8 @@ size_t ReflectometryReductionOne2::findIvsLamRangeMaxDetector( } double ReflectometryReductionOne2::findIvsLamRangeMin( - MatrixWorkspace_sptr detectorWS, const std::vector<size_t> &detectors, - const double lambda) { + const MatrixWorkspace_sptr &detectorWS, + const std::vector<size_t> &detectors, const double lambda) { double projectedMin = 0.0; const size_t spIdx = findIvsLamRangeMinDetector(detectors); @@ -898,8 +899,8 @@ double ReflectometryReductionOne2::findIvsLamRangeMin( } double ReflectometryReductionOne2::findIvsLamRangeMax( - MatrixWorkspace_sptr detectorWS, const std::vector<size_t> &detectors, - const double lambda) { + const MatrixWorkspace_sptr &detectorWS, + const std::vector<size_t> &detectors, const double lambda) { double projectedMax = 0.0; const size_t spIdx = findIvsLamRangeMaxDetector(detectors); @@ -928,9 +929,9 @@ double ReflectometryReductionOne2::findIvsLamRangeMax( * @param projectedMax [out] : the end of the resulting projected range */ void ReflectometryReductionOne2::findIvsLamRange( - MatrixWorkspace_sptr detectorWS, const std::vector<size_t> &detectors, - const double lambdaMin, const double lambdaMax, double &projectedMin, - double &projectedMax) { + const MatrixWorkspace_sptr &detectorWS, + const std::vector<size_t> &detectors, const double lambdaMin, + const double lambdaMax, double &projectedMin, double &projectedMax) { // Get the new max and min X values of the projected (virtual) lambda range projectedMin = findIvsLamRangeMin(detectorWS, detectors, lambdaMin); @@ -952,8 +953,8 @@ void ReflectometryReductionOne2::findIvsLamRange( * * @return : a 1D workspace where y values are all zero */ -MatrixWorkspace_sptr -ReflectometryReductionOne2::constructIvsLamWS(MatrixWorkspace_sptr detectorWS) { +MatrixWorkspace_sptr ReflectometryReductionOne2::constructIvsLamWS( + const MatrixWorkspace_sptr &detectorWS) { // There is one output spectrum for each detector group const size_t numGroups = detectorGroups().size(); @@ -1001,7 +1002,7 @@ ReflectometryReductionOne2::constructIvsLamWS(MatrixWorkspace_sptr detectorWS) { * @return :: the output workspace in wavelength */ MatrixWorkspace_sptr -ReflectometryReductionOne2::sumInQ(MatrixWorkspace_sptr detectorWS) { +ReflectometryReductionOne2::sumInQ(const MatrixWorkspace_sptr &detectorWS) { // Construct the output array in virtual lambda MatrixWorkspace_sptr IvsLam = constructIvsLamWS(detectorWS); @@ -1078,7 +1079,7 @@ void ReflectometryReductionOne2::sumInQProcessValue( const int inputIdx, const double twoTheta, const double bTwoTheta, const HistogramX &inputX, const HistogramY &inputY, const HistogramE &inputE, const std::vector<size_t> &detectors, - const size_t outSpecIdx, MatrixWorkspace_sptr IvsLam, + const size_t outSpecIdx, const MatrixWorkspace_sptr &IvsLam, std::vector<double> &outputE) { // Check whether there are any counts (if not, nothing to share) @@ -1097,7 +1098,7 @@ void ReflectometryReductionOne2::sumInQProcessValue( lambdaVMin, lambdaVMax); // Share the input counts into the output array sumInQShareCounts(inputCounts, inputE[inputIdx], bLambda, lambdaVMin, - lambdaVMax, outSpecIdx, IvsLam, outputE); + lambdaVMax, outSpecIdx, std::move(IvsLam), outputE); } /** @@ -1118,7 +1119,7 @@ void ReflectometryReductionOne2::sumInQProcessValue( void ReflectometryReductionOne2::sumInQShareCounts( const double inputCounts, const double inputErr, const double bLambda, const double lambdaMin, const double lambdaMax, const size_t outSpecIdx, - MatrixWorkspace_sptr IvsLam, std::vector<double> &outputE) { + const MatrixWorkspace_sptr &IvsLam, std::vector<double> &outputE) { // Check that we have histogram data const auto &outputX = IvsLam->dataX(outSpecIdx); auto &outputY = IvsLam->dataY(outSpecIdx); @@ -1239,7 +1240,8 @@ Check whether the spectra for the given workspaces are the same. exception. Otherwise a warning is generated. */ void ReflectometryReductionOne2::verifySpectrumMaps( - MatrixWorkspace_const_sptr ws1, MatrixWorkspace_const_sptr ws2) { + const MatrixWorkspace_const_sptr &ws1, + const MatrixWorkspace_const_sptr &ws2) { bool mismatch = false; // Check that the number of histograms is the same diff --git a/Framework/Algorithms/src/ReflectometryReductionOneAuto2.cpp b/Framework/Algorithms/src/ReflectometryReductionOneAuto2.cpp index 2ee23048c2b4f470fe0e9364b375447c73537e0c..d9bfc3dae5c648098682c7c0ee5dc985e166668f 100644 --- a/Framework/Algorithms/src/ReflectometryReductionOneAuto2.cpp +++ b/Framework/Algorithms/src/ReflectometryReductionOneAuto2.cpp @@ -172,7 +172,7 @@ ReflectometryReductionOneAuto2::validateInputs() { } std::string ReflectometryReductionOneAuto2::getRunNumberForWorkspaceGroup( - WorkspaceGroup_const_sptr group) { + const WorkspaceGroup_const_sptr &group) { // Return the run number for the first child workspace if (!group) throw std::runtime_error("Invalid workspace group type"); @@ -495,8 +495,8 @@ void ReflectometryReductionOneAuto2::exec() { * @param inputWS :: the input workspace * @return :: the names of the detectors of interest */ -std::vector<std::string> -ReflectometryReductionOneAuto2::getDetectorNames(MatrixWorkspace_sptr inputWS) { +std::vector<std::string> ReflectometryReductionOneAuto2::getDetectorNames( + const MatrixWorkspace_sptr &inputWS) { std::vector<std::string> wsIndices; boost::split(wsIndices, m_processingInstructionsWorkspaceIndex, @@ -572,8 +572,8 @@ MatrixWorkspace_sptr ReflectometryReductionOneAuto2::correctDetectorPositions( * @param inputWS :: the input workspace * @return :: the angle of the detector (only the first detector is considered) */ -double -ReflectometryReductionOneAuto2::calculateTheta(MatrixWorkspace_sptr inputWS) { +double ReflectometryReductionOneAuto2::calculateTheta( + const MatrixWorkspace_sptr &inputWS) { const auto detectorsOfInterest = getDetectorNames(inputWS); @@ -600,7 +600,7 @@ ReflectometryReductionOneAuto2::calculateTheta(MatrixWorkspace_sptr inputWS) { * @param instrument :: The instrument attached to the workspace */ void ReflectometryReductionOneAuto2::populateAlgorithmicCorrectionProperties( - IAlgorithm_sptr alg, Instrument_const_sptr instrument) { + const IAlgorithm_sptr &alg, const Instrument_const_sptr &instrument) { // With algorithmic corrections, monitors should not be integrated, see below @@ -664,7 +664,7 @@ void ReflectometryReductionOneAuto2::populateAlgorithmicCorrectionProperties( } auto ReflectometryReductionOneAuto2::getRebinParams( - MatrixWorkspace_sptr inputWS, const double theta) -> RebinParams { + const MatrixWorkspace_sptr &inputWS, const double theta) -> RebinParams { bool qMinIsDefault = true, qMaxIsDefault = true; auto const qMin = getPropertyOrDefault("MomentumTransferMin", inputWS->x(0).front(), qMinIsDefault); @@ -681,7 +681,7 @@ auto ReflectometryReductionOneAuto2::getRebinParams( * @return :: the rebin step in Q, or none if it could not be found */ boost::optional<double> -ReflectometryReductionOneAuto2::getQStep(MatrixWorkspace_sptr inputWS, +ReflectometryReductionOneAuto2::getQStep(const MatrixWorkspace_sptr &inputWS, const double theta) { Property *qStepProp = getProperty("MomentumTransferStep"); double qstep; @@ -718,9 +718,8 @@ ReflectometryReductionOneAuto2::getQStep(MatrixWorkspace_sptr inputWS, * and max) * @return :: the output workspace */ -MatrixWorkspace_sptr -ReflectometryReductionOneAuto2::rebinAndScale(MatrixWorkspace_sptr inputWS, - RebinParams const ¶ms) { +MatrixWorkspace_sptr ReflectometryReductionOneAuto2::rebinAndScale( + const MatrixWorkspace_sptr &inputWS, RebinParams const ¶ms) { // Rebin IAlgorithm_sptr algRebin = createChildAlgorithm("Rebin"); algRebin->initialize(); @@ -747,7 +746,7 @@ ReflectometryReductionOneAuto2::rebinAndScale(MatrixWorkspace_sptr inputWS, } MatrixWorkspace_sptr -ReflectometryReductionOneAuto2::cropQ(MatrixWorkspace_sptr inputWS, +ReflectometryReductionOneAuto2::cropQ(const MatrixWorkspace_sptr &inputWS, RebinParams const ¶ms) { IAlgorithm_sptr algCrop = createChildAlgorithm("CropWorkspace"); algCrop->initialize(); diff --git a/Framework/Algorithms/src/ReflectometryReductionOneAuto3.cpp b/Framework/Algorithms/src/ReflectometryReductionOneAuto3.cpp index c4c447f983dc160be2b04453d4ed6db827a3c1f6..365b8b41fa14cc318b3e3180b4fefaddd4e9bae0 100644 --- a/Framework/Algorithms/src/ReflectometryReductionOneAuto3.cpp +++ b/Framework/Algorithms/src/ReflectometryReductionOneAuto3.cpp @@ -163,7 +163,7 @@ ReflectometryReductionOneAuto3::validateInputs() { } std::string ReflectometryReductionOneAuto3::getRunNumberForWorkspaceGroup( - WorkspaceGroup_const_sptr group) { + const WorkspaceGroup_const_sptr &group) { // Return the run number for the first child workspace if (!group) throw std::runtime_error("Invalid workspace group type"); @@ -471,8 +471,8 @@ void ReflectometryReductionOneAuto3::exec() { * @param inputWS :: the input workspace * @return :: the names of the detectors of interest */ -std::vector<std::string> -ReflectometryReductionOneAuto3::getDetectorNames(MatrixWorkspace_sptr inputWS) { +std::vector<std::string> ReflectometryReductionOneAuto3::getDetectorNames( + const MatrixWorkspace_sptr &inputWS) { std::vector<std::string> wsIndices; boost::split(wsIndices, m_processingInstructionsWorkspaceIndex, boost::is_any_of(":,-+")); @@ -546,8 +546,8 @@ MatrixWorkspace_sptr ReflectometryReductionOneAuto3::correctDetectorPositions( * @param inputWS :: the input workspace * @return :: the angle of the detector (only the first detector is considered) */ -double -ReflectometryReductionOneAuto3::calculateTheta(MatrixWorkspace_sptr inputWS) { +double ReflectometryReductionOneAuto3::calculateTheta( + const MatrixWorkspace_sptr &inputWS) { const auto detectorsOfInterest = getDetectorNames(inputWS); // Detectors of interest may be empty. This happens for instance when we input @@ -573,7 +573,7 @@ ReflectometryReductionOneAuto3::calculateTheta(MatrixWorkspace_sptr inputWS) { * @param instrument :: The instrument attached to the workspace */ void ReflectometryReductionOneAuto3::populateAlgorithmicCorrectionProperties( - IAlgorithm_sptr alg, Instrument_const_sptr instrument) { + const IAlgorithm_sptr &alg, const Instrument_const_sptr &instrument) { // With algorithmic corrections, monitors should not be integrated, see below const std::string correctionAlgorithm = getProperty("CorrectionAlgorithm"); @@ -635,7 +635,7 @@ void ReflectometryReductionOneAuto3::populateAlgorithmicCorrectionProperties( } auto ReflectometryReductionOneAuto3::getRebinParams( - MatrixWorkspace_sptr inputWS, const double theta) -> RebinParams { + const MatrixWorkspace_sptr &inputWS, const double theta) -> RebinParams { bool qMinIsDefault = true, qMaxIsDefault = true; auto const qMin = getPropertyOrDefault("MomentumTransferMin", inputWS->x(0).front(), qMinIsDefault); @@ -652,7 +652,7 @@ auto ReflectometryReductionOneAuto3::getRebinParams( * @return :: the rebin step in Q, or none if it could not be found */ boost::optional<double> -ReflectometryReductionOneAuto3::getQStep(MatrixWorkspace_sptr inputWS, +ReflectometryReductionOneAuto3::getQStep(const MatrixWorkspace_sptr &inputWS, const double theta) { Property *qStepProp = getProperty("MomentumTransferStep"); double qstep; @@ -690,7 +690,7 @@ ReflectometryReductionOneAuto3::getQStep(MatrixWorkspace_sptr inputWS, * @return :: the output workspace */ MatrixWorkspace_sptr -ReflectometryReductionOneAuto3::rebin(MatrixWorkspace_sptr inputWS, +ReflectometryReductionOneAuto3::rebin(const MatrixWorkspace_sptr &inputWS, const RebinParams ¶ms) { IAlgorithm_sptr algRebin = createChildAlgorithm("Rebin"); algRebin->initialize(); diff --git a/Framework/Algorithms/src/ReflectometryWorkflowBase.cpp b/Framework/Algorithms/src/ReflectometryWorkflowBase.cpp index 5712e3db69121acccbe6441ea4f428bb8c7f18d9..7753d5f99c8b0175951189386e5665bf838978bb 100644 --- a/Framework/Algorithms/src/ReflectometryWorkflowBase.cpp +++ b/Framework/Algorithms/src/ReflectometryWorkflowBase.cpp @@ -4,9 +4,11 @@ // NScD Oak Ridge National Laboratory, European Spallation Source, // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + -#include "MantidAlgorithms/ReflectometryWorkflowBase.h" +#include <utility> + #include "MantidAPI/BoostOptionalToAlgorithmProperty.h" #include "MantidAPI/WorkspaceUnitValidator.h" +#include "MantidAlgorithms/ReflectometryWorkflowBase.h" #include "MantidKernel/ArrayProperty.h" #include "MantidKernel/BoundedValidator.h" #include "MantidKernel/CompositeValidator.h" @@ -196,12 +198,12 @@ ReflectometryWorkflowBase::OptionalMinMax ReflectometryWorkflowBase::getOptionalMinMax( Mantid::API::Algorithm *const alg, const std::string &minProperty, const std::string &maxProperty, - Mantid::Geometry::Instrument_const_sptr inst, std::string minIdfName, - std::string maxIdfName) const { - const auto min = checkForOptionalInstrumentDefault<double>(alg, minProperty, - inst, minIdfName); - const auto max = checkForOptionalInstrumentDefault<double>(alg, maxProperty, - inst, maxIdfName); + const Mantid::Geometry::Instrument_const_sptr &inst, + const std::string &minIdfName, const std::string &maxIdfName) const { + const auto min = checkForOptionalInstrumentDefault<double>( + alg, minProperty, inst, std::move(minIdfName)); + const auto max = checkForOptionalInstrumentDefault<double>( + alg, maxProperty, inst, std::move(maxIdfName)); if (min.is_initialized() && max.is_initialized()) { MinMax result = getMinMax(minProperty, maxProperty); return OptionalMinMax(result); @@ -361,7 +363,7 @@ void ReflectometryWorkflowBase::getTransmissionRunInfo( * @return The cropped and corrected monitor workspace. */ MatrixWorkspace_sptr ReflectometryWorkflowBase::toLamMonitor( - const MatrixWorkspace_sptr &toConvert, const OptionalInteger monitorIndex, + const MatrixWorkspace_sptr &toConvert, const OptionalInteger &monitorIndex, const OptionalMinMax &backgroundMinMax) { // Convert Units. auto convertUnitsAlg = this->createChildAlgorithm("ConvertUnits"); @@ -473,9 +475,9 @@ ReflectometryWorkflowBase::makeUnityWorkspace(const HistogramX &x) { * @return Tuple of detector and monitor workspaces */ ReflectometryWorkflowBase::DetectorMonitorWorkspacePair -ReflectometryWorkflowBase::toLam(MatrixWorkspace_sptr toConvert, +ReflectometryWorkflowBase::toLam(const MatrixWorkspace_sptr &toConvert, const std::string &processingCommands, - const OptionalInteger monitorIndex, + const OptionalInteger &monitorIndex, const MinMax &wavelengthMinMax, const OptionalMinMax &backgroundMinMax) { // Detector Workspace Processing diff --git a/Framework/Algorithms/src/ReflectometryWorkflowBase2.cpp b/Framework/Algorithms/src/ReflectometryWorkflowBase2.cpp index a789763307e9991cfd728329c1ab7e159b56f082..5336598c54277c201e94de6cf533ae9ef8d06971 100644 --- a/Framework/Algorithms/src/ReflectometryWorkflowBase2.cpp +++ b/Framework/Algorithms/src/ReflectometryWorkflowBase2.cpp @@ -4,12 +4,14 @@ // NScD Oak Ridge National Laboratory, European Spallation Source, // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + -#include "MantidAlgorithms/ReflectometryWorkflowBase2.h" +#include <utility> + #include "MantidAPI/Axis.h" #include "MantidAPI/BoostOptionalToAlgorithmProperty.h" #include "MantidAPI/MatrixWorkspace.h" #include "MantidAPI/Run.h" #include "MantidAPI/WorkspaceUnitValidator.h" +#include "MantidAlgorithms/ReflectometryWorkflowBase2.h" #include "MantidGeometry/Instrument.h" #include "MantidIndexing/IndexInfo.h" #include "MantidKernel/ArrayProperty.h" @@ -40,16 +42,15 @@ int convertStringNumToInt(const std::string &string) { } std::string convertToWorkspaceIndex(const std::string &spectrumNumber, - MatrixWorkspace_const_sptr ws) { + const MatrixWorkspace_const_sptr &ws) { auto specNum = convertStringNumToInt(spectrumNumber); std::string wsIdx = std::to_string( ws->getIndexFromSpectrumNumber(static_cast<Mantid::specnum_t>(specNum))); return wsIdx; } -std::string -convertProcessingInstructionsToWorkspaceIndices(const std::string &instructions, - MatrixWorkspace_const_sptr ws) { +std::string convertProcessingInstructionsToWorkspaceIndices( + const std::string &instructions, const MatrixWorkspace_const_sptr &ws) { std::string converted = ""; std::string currentNumber = ""; std::string ignoreThese = "-,:+"; @@ -79,7 +80,7 @@ convertProcessingInstructionsToWorkspaceIndices(const std::string &instructions, */ std::vector<size_t> getProcessingInstructionsAsIndices(std::string const &instructions, - MatrixWorkspace_sptr workspace) { + const MatrixWorkspace_sptr &workspace) { auto instructionsInWSIndex = convertProcessingInstructionsToWorkspaceIndices(instructions, workspace); auto groups = @@ -517,8 +518,8 @@ ReflectometryWorkflowBase2::validateWavelengthRanges() const { * @param inputWS :: the workspace to convert * @return :: the workspace in wavelength */ -MatrixWorkspace_sptr -ReflectometryWorkflowBase2::convertToWavelength(MatrixWorkspace_sptr inputWS) { +MatrixWorkspace_sptr ReflectometryWorkflowBase2::convertToWavelength( + const MatrixWorkspace_sptr &inputWS) { auto convertUnitsAlg = createChildAlgorithm("ConvertUnits"); convertUnitsAlg->initialize(); @@ -541,8 +542,8 @@ ReflectometryWorkflowBase2::convertToWavelength(MatrixWorkspace_sptr inputWS) { * @return :: the cropped workspace */ MatrixWorkspace_sptr ReflectometryWorkflowBase2::cropWavelength( - MatrixWorkspace_sptr inputWS, const bool useArgs, const double argMin, - const double argMax) { + const MatrixWorkspace_sptr &inputWS, const bool useArgs, + const double argMin, const double argMax) { double wavelengthMin = 0.0; double wavelengthMax = 0.0; @@ -584,7 +585,7 @@ MatrixWorkspace_sptr ReflectometryWorkflowBase2::cropWavelength( MatrixWorkspace_sptr ReflectometryWorkflowBase2::makeDetectorWS(MatrixWorkspace_sptr inputWS, const bool convert, const bool sum) { - auto detectorWS = inputWS; + auto detectorWS = std::move(inputWS); if (sum) { // Use GroupDetectors to extract and sum the detectors of interest @@ -635,7 +636,7 @@ ReflectometryWorkflowBase2::makeDetectorWS(MatrixWorkspace_sptr inputWS, * @return :: the monitor workspace in wavelength */ MatrixWorkspace_sptr -ReflectometryWorkflowBase2::makeMonitorWS(MatrixWorkspace_sptr inputWS, +ReflectometryWorkflowBase2::makeMonitorWS(const MatrixWorkspace_sptr &inputWS, const bool integratedMonitors) { // Extract the monitor workspace @@ -697,7 +698,8 @@ ReflectometryWorkflowBase2::makeMonitorWS(MatrixWorkspace_sptr inputWS, * @return :: the rebinned detector workspace */ MatrixWorkspace_sptr ReflectometryWorkflowBase2::rebinDetectorsToMonitors( - MatrixWorkspace_sptr detectorWS, MatrixWorkspace_sptr monitorWS) { + const MatrixWorkspace_sptr &detectorWS, + const MatrixWorkspace_sptr &monitorWS) { auto rebin = createChildAlgorithm("RebinToWorkspace"); rebin->initialize(); @@ -715,7 +717,7 @@ MatrixWorkspace_sptr ReflectometryWorkflowBase2::rebinDetectorsToMonitors( * @param instrument :: the instrument attached to the workspace */ void ReflectometryWorkflowBase2::populateMonitorProperties( - IAlgorithm_sptr alg, Instrument_const_sptr instrument) { + const IAlgorithm_sptr &alg, const Instrument_const_sptr &instrument) { const auto startOverlap = checkForOptionalInstrumentDefault<double>( this, "StartOverlap", instrument, "TransRunStartOverlap"); @@ -769,7 +771,8 @@ void ReflectometryWorkflowBase2::populateMonitorProperties( * @return :: processing instructions as a string */ std::string ReflectometryWorkflowBase2::findProcessingInstructions( - Instrument_const_sptr instrument, MatrixWorkspace_sptr inputWS) const { + const Instrument_const_sptr &instrument, + const MatrixWorkspace_sptr &inputWS) const { const std::string analysisMode = getProperty("AnalysisMode"); @@ -815,7 +818,7 @@ std::string ReflectometryWorkflowBase2::findProcessingInstructions( * @return Boolean, whether or not any transmission runs were found */ bool ReflectometryWorkflowBase2::populateTransmissionProperties( - IAlgorithm_sptr alg) const { + const IAlgorithm_sptr &alg) const { bool transRunsExist = false; @@ -845,9 +848,8 @@ bool ReflectometryWorkflowBase2::populateTransmissionProperties( * @return :: the value of theta found from the logs * @throw :: NotFoundError if the log value was not found */ -double -ReflectometryWorkflowBase2::getThetaFromLogs(MatrixWorkspace_sptr inputWs, - const std::string &logName) { +double ReflectometryWorkflowBase2::getThetaFromLogs( + const MatrixWorkspace_sptr &inputWs, const std::string &logName) { double theta = -1.; const Mantid::API::Run &run = inputWs->run(); Property *logData = run.getLogData(logName); @@ -884,7 +886,7 @@ ReflectometryWorkflowBase2::getRunNumber(MatrixWorkspace const &ws) const { std::string ReflectometryWorkflowBase2::convertProcessingInstructionsToSpectrumNumbers( const std::string &instructions, - Mantid::API::MatrixWorkspace_const_sptr ws) const { + const Mantid::API::MatrixWorkspace_const_sptr &ws) const { std::string converted = ""; std::string currentNumber = ""; std::string ignoreThese = "-,:+"; @@ -905,7 +907,7 @@ ReflectometryWorkflowBase2::convertProcessingInstructionsToSpectrumNumbers( } std::string ReflectometryWorkflowBase2::convertToSpectrumNumber( const std::string &workspaceIndex, - Mantid::API::MatrixWorkspace_const_sptr ws) const { + const Mantid::API::MatrixWorkspace_const_sptr &ws) const { auto wsIndx = convertStringNumToInt(workspaceIndex); std::string specId = std::to_string( static_cast<int32_t>(ws->indexInfo().spectrumNumber(wsIndx))); @@ -913,7 +915,8 @@ std::string ReflectometryWorkflowBase2::convertToSpectrumNumber( } void ReflectometryWorkflowBase2::convertProcessingInstructions( - Instrument_const_sptr instrument, MatrixWorkspace_sptr inputWS) { + const Instrument_const_sptr &instrument, + const MatrixWorkspace_sptr &inputWS) { m_processingInstructions = getPropertyValue("ProcessingInstructions"); if (!getPointerToProperty("ProcessingInstructions")->isDefault()) { m_processingInstructionsWorkspaceIndex = @@ -921,14 +924,14 @@ void ReflectometryWorkflowBase2::convertProcessingInstructions( m_processingInstructions, inputWS); } else { m_processingInstructionsWorkspaceIndex = - findProcessingInstructions(instrument, inputWS); + findProcessingInstructions(std::move(instrument), inputWS); m_processingInstructions = convertProcessingInstructionsToSpectrumNumbers( m_processingInstructionsWorkspaceIndex, inputWS); } } void ReflectometryWorkflowBase2::convertProcessingInstructions( - MatrixWorkspace_sptr inputWS) { + const MatrixWorkspace_sptr &inputWS) { m_processingInstructions = getPropertyValue("ProcessingInstructions"); m_processingInstructionsWorkspaceIndex = convertProcessingInstructionsToWorkspaceIndices(m_processingInstructions, @@ -938,7 +941,7 @@ void ReflectometryWorkflowBase2::convertProcessingInstructions( // Create an on-the-fly property to set an output workspace from a child // algorithm, if the child has that output value set void ReflectometryWorkflowBase2::setWorkspacePropertyFromChild( - Algorithm_sptr alg, std::string const &propertyName) { + const Algorithm_sptr &alg, std::string const &propertyName) { if (alg->isDefault(propertyName)) return; diff --git a/Framework/Algorithms/src/RemovePromptPulse.cpp b/Framework/Algorithms/src/RemovePromptPulse.cpp index 07e0a8bed958896ed2ad87e2f71b76f4250ce0c1..412802216b0d4e35c37ddf646ef60bf1ddcbf3cb 100644 --- a/Framework/Algorithms/src/RemovePromptPulse.cpp +++ b/Framework/Algorithms/src/RemovePromptPulse.cpp @@ -68,7 +68,8 @@ double getMedian(const API::Run &run, const std::string &name) { return stats.median; } -void getTofRange(MatrixWorkspace_const_sptr wksp, double &tmin, double &tmax) { +void getTofRange(const MatrixWorkspace_const_sptr &wksp, double &tmin, + double &tmax) { DataObjects::EventWorkspace_const_sptr eventWksp = boost::dynamic_pointer_cast<const DataObjects::EventWorkspace>(wksp); if (eventWksp == nullptr) { diff --git a/Framework/Algorithms/src/ResampleX.cpp b/Framework/Algorithms/src/ResampleX.cpp index ddd7344106f9ddbcfa802e56387c061f70768d93..4a686c0ec29a545a4594bfc0af26f4effb60f706 100644 --- a/Framework/Algorithms/src/ResampleX.cpp +++ b/Framework/Algorithms/src/ResampleX.cpp @@ -117,8 +117,8 @@ map<string, string> ResampleX::validateInputs() { *everything * went according to plan. */ -string determineXMinMax(MatrixWorkspace_sptr inputWS, vector<double> &xmins, - vector<double> &xmaxs) { +string determineXMinMax(const MatrixWorkspace_sptr &inputWS, + vector<double> &xmins, vector<double> &xmaxs) { const size_t numSpectra = inputWS->getNumberHistograms(); // pad out the ranges by copying the first value to the rest that are needed diff --git a/Framework/Algorithms/src/ResetNegatives.cpp b/Framework/Algorithms/src/ResetNegatives.cpp index 93fda48e7f8c86687806fe3cd479dc19a125017a..88f4fedbe3ded49e42ba201063a922ee2514a379 100644 --- a/Framework/Algorithms/src/ResetNegatives.cpp +++ b/Framework/Algorithms/src/ResetNegatives.cpp @@ -141,8 +141,9 @@ inline double fixZero(const double value) { * @param wksp The workspace to modify. * @param prog The progress. */ -void ResetNegatives::pushMinimum(MatrixWorkspace_const_sptr minWS, - MatrixWorkspace_sptr wksp, Progress &prog) { +void ResetNegatives::pushMinimum(const MatrixWorkspace_const_sptr &minWS, + const MatrixWorkspace_sptr &wksp, + Progress &prog) { int64_t nHist = minWS->getNumberHistograms(); PARALLEL_FOR_IF(Kernel::threadSafe(*wksp, *minWS)) for (int64_t i = 0; i < nHist; i++) { @@ -151,9 +152,9 @@ void ResetNegatives::pushMinimum(MatrixWorkspace_const_sptr minWS, if (minValue <= 0) { minValue *= -1.; auto &y = wksp->mutableY(i); - for (double &value : y) { - value = fixZero(value + minValue); - } + std::transform(y.begin(), y.end(), y.begin(), [minValue](double value) { + return fixZero(value + minValue); + }); } prog.report(); PARALLEL_END_INTERUPT_REGION @@ -171,9 +172,9 @@ void ResetNegatives::pushMinimum(MatrixWorkspace_const_sptr minWS, * @param wksp The workspace to modify. * @param prog The progress. */ -void ResetNegatives::changeNegatives(MatrixWorkspace_const_sptr minWS, +void ResetNegatives::changeNegatives(const MatrixWorkspace_const_sptr &minWS, const double spectrumNegativeValues, - MatrixWorkspace_sptr wksp, + const MatrixWorkspace_sptr &wksp, Progress &prog) { int64_t nHist = wksp->getNumberHistograms(); PARALLEL_FOR_IF(Kernel::threadSafe(*minWS, *wksp)) diff --git a/Framework/Algorithms/src/RingProfile.cpp b/Framework/Algorithms/src/RingProfile.cpp index 83f078ed350f3833d6c3a794dad3df001e753c37..e7647dc7c8275448d1ea0d2e4e887390bbd722db 100644 --- a/Framework/Algorithms/src/RingProfile.cpp +++ b/Framework/Algorithms/src/RingProfile.cpp @@ -215,7 +215,7 @@ void RingProfile::exec() { * @param inputWS: the input workspace */ void RingProfile::checkInputsForSpectraWorkspace( - const API::MatrixWorkspace_sptr inputWS) { + const API::MatrixWorkspace_sptr &inputWS) { try { // finding the limits of the instrument const auto &spectrumInfo = inputWS->spectrumInfo(); @@ -325,7 +325,7 @@ void RingProfile::checkInputsForSpectraWorkspace( * @param inputWS: pointer to the input workspace */ void RingProfile::checkInputsForNumericWorkspace( - const API::MatrixWorkspace_sptr inputWS) { + const API::MatrixWorkspace_sptr &inputWS) { g_log.notice() << "CheckingInputs For Numeric Workspace\n"; // The Axis0 is defined by the values of readX inside the spectra of the @@ -396,7 +396,8 @@ void RingProfile::checkInputsForNumericWorkspace( *integration values */ void RingProfile::processInstrumentRingProfile( - const API::MatrixWorkspace_sptr inputWS, std::vector<double> &output_bins) { + const API::MatrixWorkspace_sptr &inputWS, + std::vector<double> &output_bins) { const auto &spectrumInfo = inputWS->spectrumInfo(); for (int i = 0; i < static_cast<int>(inputWS->getNumberHistograms()); i++) { @@ -485,7 +486,8 @@ int RingProfile::getBinForPixel(const Kernel::V3D &position) { *integration values */ void RingProfile::processNumericImageRingProfile( - const API::MatrixWorkspace_sptr inputWS, std::vector<double> &output_bins) { + const API::MatrixWorkspace_sptr &inputWS, + std::vector<double> &output_bins) { // allocate the bin positions vector std::vector<int> bin_n(inputWS->dataY(0).size(), -1); @@ -538,7 +540,7 @@ void RingProfile::processNumericImageRingProfile( * @param bins_pos: bin positions (for each column inside the spectrum, the *correspondent bin_pos) */ -void RingProfile::getBinForPixel(const API::MatrixWorkspace_sptr ws, +void RingProfile::getBinForPixel(const API::MatrixWorkspace_sptr &ws, int spectrum_index, std::vector<int> &bins_pos) { diff --git a/Framework/Algorithms/src/RunCombinationHelpers/RunCombinationHelper.cpp b/Framework/Algorithms/src/RunCombinationHelpers/RunCombinationHelper.cpp index 493c2497f9938a291544b22a0fd79d46b63ae1a3..6bc22fdb6582ac73e4c9324f4d888d1c6531f1f1 100644 --- a/Framework/Algorithms/src/RunCombinationHelpers/RunCombinationHelper.cpp +++ b/Framework/Algorithms/src/RunCombinationHelpers/RunCombinationHelper.cpp @@ -59,7 +59,8 @@ RunCombinationHelper::unWrapGroups(const std::vector<std::string> &inputs) { * to later check the compatibility of the others with the reference * @param ref : the reference workspace */ -void RunCombinationHelper::setReferenceProperties(MatrixWorkspace_sptr ref) { +void RunCombinationHelper::setReferenceProperties( + const MatrixWorkspace_sptr &ref) { m_numberSpectra = ref->getNumberHistograms(); m_numberDetectors = ref->detectorInfo().size(); m_xUnit = ref->getAxis(0)->unit()->unitID(); @@ -82,7 +83,7 @@ void RunCombinationHelper::setReferenceProperties(MatrixWorkspace_sptr ref) { * @return : empty if compatible, error message otherwises */ std::string -RunCombinationHelper::checkCompatibility(MatrixWorkspace_sptr ws, +RunCombinationHelper::checkCompatibility(const MatrixWorkspace_sptr &ws, bool checkNumberHistograms) { std::string errors; if (ws->getNumberHistograms() != m_numberSpectra && checkNumberHistograms) diff --git a/Framework/Algorithms/src/RunCombinationHelpers/SampleLogsBehaviour.cpp b/Framework/Algorithms/src/RunCombinationHelpers/SampleLogsBehaviour.cpp index 4115dbbff7378f60c99a307eb6cff523ad2aee5e..03a6bf849742076c03dbb30636c356afaaa3c0cd 100644 --- a/Framework/Algorithms/src/RunCombinationHelpers/SampleLogsBehaviour.cpp +++ b/Framework/Algorithms/src/RunCombinationHelpers/SampleLogsBehaviour.cpp @@ -91,7 +91,7 @@ const std::string SampleLogsBehaviour::SUM_DOC = * @param parName the parameter names which specify the sample log sames to * merge given be the IPF */ -SampleLogsBehaviour::SampleLogsBehaviour(MatrixWorkspace_sptr ws, +SampleLogsBehaviour::SampleLogsBehaviour(const MatrixWorkspace_sptr &ws, Logger &logger, const SampleLogNames &logEntries, const ParameterName &parName) @@ -416,8 +416,8 @@ bool SampleLogsBehaviour::setNumericValue(const std::string &item, * @param addeeWS the workspace being merged * @param outWS the workspace the others are merged into */ -void SampleLogsBehaviour::mergeSampleLogs(MatrixWorkspace_sptr addeeWS, - MatrixWorkspace_sptr outWS) { +void SampleLogsBehaviour::mergeSampleLogs(const MatrixWorkspace_sptr &addeeWS, + const MatrixWorkspace_sptr &outWS) { for (const auto &item : m_logMap) { const std::string &logName = item.first.first; @@ -625,7 +625,8 @@ bool SampleLogsBehaviour::stringPropertiesMatch( * * @param outWS the merged workspace */ -void SampleLogsBehaviour::setUpdatedSampleLogs(MatrixWorkspace_sptr outWS) { +void SampleLogsBehaviour::setUpdatedSampleLogs( + const MatrixWorkspace_sptr &outWS) { for (auto &item : m_logMap) { std::string propertyToReset = item.first.first; @@ -647,7 +648,7 @@ void SampleLogsBehaviour::setUpdatedSampleLogs(MatrixWorkspace_sptr outWS) { * @param addeeWS the workspace being merged */ void SampleLogsBehaviour::removeSampleLogsFromWorkspace( - MatrixWorkspace_sptr addeeWS) { + const MatrixWorkspace_sptr &addeeWS) { for (const auto &prop : m_addeeLogMap) { const auto &propName = prop->name(); addeeWS->mutableRun().removeProperty(propName); @@ -663,7 +664,7 @@ void SampleLogsBehaviour::removeSampleLogsFromWorkspace( * @param addeeWS the workspace being merged */ void SampleLogsBehaviour::readdSampleLogToWorkspace( - MatrixWorkspace_sptr addeeWS) { + const MatrixWorkspace_sptr &addeeWS) { for (const auto &item : m_addeeLogMap) { auto property = std::unique_ptr<Kernel::Property>(item->clone()); addeeWS->mutableRun().addProperty(std::move(property)); @@ -676,7 +677,7 @@ void SampleLogsBehaviour::readdSampleLogToWorkspace( * * @param ws the merged workspace to reset the sample logs for */ -void SampleLogsBehaviour::resetSampleLogs(MatrixWorkspace_sptr ws) { +void SampleLogsBehaviour::resetSampleLogs(const MatrixWorkspace_sptr &ws) { for (auto const &item : m_logMap) { std::string const &propertyToReset = item.first.first; diff --git a/Framework/Algorithms/src/SANSCollimationLengthEstimator.cpp b/Framework/Algorithms/src/SANSCollimationLengthEstimator.cpp index 370940870bcce904641686be08bcb4bda0efaf4d..fdf2f1b04448db1c06ff293ef4b78330fddc0c3d 100644 --- a/Framework/Algorithms/src/SANSCollimationLengthEstimator.cpp +++ b/Framework/Algorithms/src/SANSCollimationLengthEstimator.cpp @@ -22,7 +22,7 @@ Mantid::Kernel::Logger g_log("SANSCollimationLengthEstimator"); * @param val: a value as a string * @returns true if it is convertible else false */ -bool checkForDouble(std::string val) { +bool checkForDouble(const std::string &val) { auto isDouble = false; try { boost::lexical_cast<double>(val); @@ -45,7 +45,7 @@ using namespace API; * @returns the collimation length */ double SANSCollimationLengthEstimator::provideCollimationLength( - Mantid::API::MatrixWorkspace_sptr workspace) { + const Mantid::API::MatrixWorkspace_sptr &workspace) { // If the instrument does not have a correction specified then set the length // to 4 const double defaultLColim = 4.0; @@ -104,7 +104,7 @@ double SANSCollimationLengthEstimator::provideCollimationLength( * length */ double SANSCollimationLengthEstimator::getCollimationLengthWithGuides( - MatrixWorkspace_sptr inOutWS, const double L1, + const MatrixWorkspace_sptr &inOutWS, const double L1, const double collimationLengthCorrection) const { auto lCollim = L1 - collimationLengthCorrection; diff --git a/Framework/Algorithms/src/SampleCorrections/MCAbsorptionStrategy.cpp b/Framework/Algorithms/src/SampleCorrections/MCAbsorptionStrategy.cpp index 068b0e8ceb3ced189384c3cffbda5ec1660fdb48..41b007239b44cf0b732c44c1d2950b61eb512b7f 100644 --- a/Framework/Algorithms/src/SampleCorrections/MCAbsorptionStrategy.cpp +++ b/Framework/Algorithms/src/SampleCorrections/MCAbsorptionStrategy.cpp @@ -64,7 +64,7 @@ MCAbsorptionStrategy::MCAbsorptionStrategy( */ void MCAbsorptionStrategy::calculate( Kernel::PseudoRandomNumberGenerator &rng, const Kernel::V3D &finalPos, - Mantid::HistogramData::Points lambdas, double lambdaFixed, + const Mantid::HistogramData::Points &lambdas, double lambdaFixed, Mantid::API::ISpectrum &attenuationFactorsSpectrum) { const auto scatterBounds = m_scatterVol.getBoundingBox(); const auto nbins = static_cast<int>(lambdas.size()); diff --git a/Framework/Algorithms/src/SmoothData.cpp b/Framework/Algorithms/src/SmoothData.cpp index b7ed93f3449e2d373eda30e3a600e3a0f9c10728..8893838585b9463e78f63b89be388df82924a679 100644 --- a/Framework/Algorithms/src/SmoothData.cpp +++ b/Framework/Algorithms/src/SmoothData.cpp @@ -73,11 +73,12 @@ void SmoothData::exec() { int npts = nptsGroup[0]; if (groupWS) { const int group = validateSpectrumInGroup(static_cast<size_t>(i)); - if (group < 0) + if (group == -1) { npts = 3; - else - // group is never 0. We can safely subtract. + } else { + assert(group != 0); npts = nptsGroup[group - 1]; + } } if (npts >= vecSize) { g_log.error("The number of averaging points requested is larger than the " @@ -103,7 +104,7 @@ void SmoothData::exec() { // Set the output workspace to its property setProperty("OutputWorkspace", outputWorkspace); -} +} // namespace Algorithms //============================================================================= /** Verify that all the contributing detectors to a spectrum belongs to the same * group diff --git a/Framework/Algorithms/src/SmoothNeighbours.cpp b/Framework/Algorithms/src/SmoothNeighbours.cpp index 68b04181ff44a1e9448746dd3b56ba360a8a3d35..8689b4a52377abd36d7604d4d483c4c0fbd34473 100644 --- a/Framework/Algorithms/src/SmoothNeighbours.cpp +++ b/Framework/Algorithms/src/SmoothNeighbours.cpp @@ -685,7 +685,7 @@ void SmoothNeighbours::setupNewInstrument(MatrixWorkspace &outws) const { //-------------------------------------------------------------------------------------------- /** Spread the average over all the pixels */ -void SmoothNeighbours::spreadPixels(MatrixWorkspace_sptr outws) { +void SmoothNeighbours::spreadPixels(const MatrixWorkspace_sptr &outws) { // Get some stuff from the input workspace const size_t numberOfSpectra = inWS->getNumberHistograms(); diff --git a/Framework/Algorithms/src/SofQWPolygon.cpp b/Framework/Algorithms/src/SofQWPolygon.cpp index f0825ef817df61f3840884cbc3f03d078af2def5..2cbaed6f6286c7a34c6a1f7e5b2bf875b557fe3e 100644 --- a/Framework/Algorithms/src/SofQWPolygon.cpp +++ b/Framework/Algorithms/src/SofQWPolygon.cpp @@ -146,7 +146,8 @@ void SofQWPolygon::exec() { * Init variables caches * @param workspace :: Workspace pointer */ -void SofQWPolygon::initCachedValues(API::MatrixWorkspace_const_sptr workspace) { +void SofQWPolygon::initCachedValues( + const API::MatrixWorkspace_const_sptr &workspace) { m_EmodeProperties.initCachedValues(*workspace, this); // Index theta cache initThetaCache(*workspace); diff --git a/Framework/Algorithms/src/SortXAxis.cpp b/Framework/Algorithms/src/SortXAxis.cpp index 9838aba48e14f89d604ebbccf35aed3f163eab0f..e20d1ac5deb590e1c07943ecb1538b529fcd0ec4 100644 --- a/Framework/Algorithms/src/SortXAxis.cpp +++ b/Framework/Algorithms/src/SortXAxis.cpp @@ -118,7 +118,7 @@ void sortByXValue(std::vector<std::size_t> &workspaceIndicies, } void SortXAxis::sortIndicesByX( - std::vector<std::size_t> &workspaceIndicies, std::string order, + std::vector<std::size_t> &workspaceIndicies, const std::string &order, const Mantid::API::MatrixWorkspace &inputWorkspace, unsigned int specNum) { if (order == "Ascending") { sortByXValue(workspaceIndicies, inputWorkspace, specNum, diff --git a/Framework/Algorithms/src/SpecularReflectionAlgorithm.cpp b/Framework/Algorithms/src/SpecularReflectionAlgorithm.cpp index b8ccafe418699f0e3ac795e524bb5d48dba0c121..843e097cba6f8554f1af3e0ab1aa5881105a68e3 100644 --- a/Framework/Algorithms/src/SpecularReflectionAlgorithm.cpp +++ b/Framework/Algorithms/src/SpecularReflectionAlgorithm.cpp @@ -123,7 +123,7 @@ void SpecularReflectionAlgorithm::initCommonProperties() { */ Mantid::Geometry::IComponent_const_sptr SpecularReflectionAlgorithm::getSurfaceSampleComponent( - Mantid::Geometry::Instrument_const_sptr inst) const { + const Mantid::Geometry::Instrument_const_sptr &inst) const { std::string sampleComponent = "some-surface-holder"; if (!isPropertyDefault("SampleComponentName")) { sampleComponent = this->getPropertyValue("SampleComponentName"); @@ -148,7 +148,7 @@ SpecularReflectionAlgorithm::getSurfaceSampleComponent( */ boost::shared_ptr<const Mantid::Geometry::IComponent> SpecularReflectionAlgorithm::getDetectorComponent( - MatrixWorkspace_sptr workspace, const bool isPointDetector) const { + const MatrixWorkspace_sptr &workspace, const bool isPointDetector) const { boost::shared_ptr<const IComponent> searchResult; if (!isPropertyDefault("SpectrumNumbersOfDetectors")) { const std::vector<int> spectrumNumbers = diff --git a/Framework/Algorithms/src/SpecularReflectionPositionCorrect.cpp b/Framework/Algorithms/src/SpecularReflectionPositionCorrect.cpp index 8af2c852b46011c6196f1926db323f7f192f85cb..5d0e86593514e0284e78222695d28b1a47dd6878 100644 --- a/Framework/Algorithms/src/SpecularReflectionPositionCorrect.cpp +++ b/Framework/Algorithms/src/SpecularReflectionPositionCorrect.cpp @@ -138,8 +138,8 @@ void SpecularReflectionPositionCorrect::exec() { * @param detectorPosition: Actual detector or detector group position. */ void SpecularReflectionPositionCorrect::moveDetectors( - API::MatrixWorkspace_sptr toCorrect, IComponent_const_sptr detector, - IComponent_const_sptr sample, const double &upOffset, + const API::MatrixWorkspace_sptr &toCorrect, IComponent_const_sptr detector, + const IComponent_const_sptr &sample, const double &upOffset, const double &acrossOffset, const V3D &detectorPosition) { auto instrument = toCorrect->getInstrument(); const V3D samplePosition = sample->getPos(); @@ -203,8 +203,9 @@ void SpecularReflectionPositionCorrect::moveDetectors( * @param detector : Pointer to a given detector */ void SpecularReflectionPositionCorrect::correctPosition( - API::MatrixWorkspace_sptr toCorrect, const double &twoThetaInDeg, - IComponent_const_sptr sample, IComponent_const_sptr detector) { + const API::MatrixWorkspace_sptr &toCorrect, const double &twoThetaInDeg, + const IComponent_const_sptr &sample, + const IComponent_const_sptr &detector) { auto instrument = toCorrect->getInstrument(); diff --git a/Framework/Algorithms/src/Stitch1D.cpp b/Framework/Algorithms/src/Stitch1D.cpp index b0de3825d0bcdc20c302cf41875ee19e8cea8110..fc882cff79683705453c2c5e26a4fd5401192a86 100644 --- a/Framework/Algorithms/src/Stitch1D.cpp +++ b/Framework/Algorithms/src/Stitch1D.cpp @@ -644,7 +644,7 @@ void Stitch1D::exec() { /** Put special values back. * @param ws : MatrixWorkspace to resinsert special values into. */ -void Stitch1D::reinsertSpecialValues(MatrixWorkspace_sptr ws) { +void Stitch1D::reinsertSpecialValues(const MatrixWorkspace_sptr &ws) { auto histogramCount = static_cast<int>(ws->getNumberHistograms()); PARALLEL_FOR_IF(Kernel::threadSafe(*ws)) for (int i = 0; i < histogramCount; ++i) { diff --git a/Framework/Algorithms/src/Stitch1DMany.cpp b/Framework/Algorithms/src/Stitch1DMany.cpp index d89ceb8c802bc68e17b54b37eeaae9df4af7cd3e..bc582d28486ec715abf1847d4caf8f77056159a5 100644 --- a/Framework/Algorithms/src/Stitch1DMany.cpp +++ b/Framework/Algorithms/src/Stitch1DMany.cpp @@ -269,8 +269,10 @@ void Stitch1DMany::exec() { for (size_t i = 0; i < m_inputWSMatrix.front().size(); ++i) { std::vector<MatrixWorkspace_sptr> inMatrix; inMatrix.reserve(m_inputWSMatrix.size()); - for (const auto &ws : m_inputWSMatrix) - inMatrix.emplace_back(ws[i]); + + std::transform(m_inputWSMatrix.begin(), m_inputWSMatrix.end(), + std::back_inserter(inMatrix), + [i](const auto &ws) { return ws[i]; }); outName = groupName; Workspace_sptr outStitchedWS; diff --git a/Framework/Algorithms/src/StripPeaks.cpp b/Framework/Algorithms/src/StripPeaks.cpp index 18b48d1042edfa4726f72e9fc3ed3a93438715c7..cc52ce60bd926761063fb5cca0b8051a2bc34188 100644 --- a/Framework/Algorithms/src/StripPeaks.cpp +++ b/Framework/Algorithms/src/StripPeaks.cpp @@ -107,7 +107,8 @@ void StripPeaks::exec() { * @param WS :: The workspace to search * @return list of found peaks */ -API::ITableWorkspace_sptr StripPeaks::findPeaks(API::MatrixWorkspace_sptr WS) { +API::ITableWorkspace_sptr +StripPeaks::findPeaks(const API::MatrixWorkspace_sptr &WS) { g_log.debug("Calling FindPeaks as a Child Algorithm"); // Read from properties @@ -172,8 +173,8 @@ API::ITableWorkspace_sptr StripPeaks::findPeaks(API::MatrixWorkspace_sptr WS) { * @return A workspace containing the peak-subtracted data */ API::MatrixWorkspace_sptr -StripPeaks::removePeaks(API::MatrixWorkspace_const_sptr input, - API::ITableWorkspace_sptr peakslist) { +StripPeaks::removePeaks(const API::MatrixWorkspace_const_sptr &input, + const API::ITableWorkspace_sptr &peakslist) { g_log.debug("Subtracting peaks"); // Create an output workspace - same size as input one MatrixWorkspace_sptr outputWS = WorkspaceFactory::Instance().create(input); diff --git a/Framework/Algorithms/src/SumEventsByLogValue.cpp b/Framework/Algorithms/src/SumEventsByLogValue.cpp index de12e5beec5bd804e43a4572ab6cf4f1a5bd7dde..a6f0eb8f8adcddf27422379d75870015519becc7 100644 --- a/Framework/Algorithms/src/SumEventsByLogValue.cpp +++ b/Framework/Algorithms/src/SumEventsByLogValue.cpp @@ -302,9 +302,9 @@ void SumEventsByLogValue::filterEventList( * @param minVal The minimum value of the log * @param maxVal The maximum value of the log */ -void SumEventsByLogValue::addMonitorCounts(ITableWorkspace_sptr outputWorkspace, - const TimeSeriesProperty<int> *log, - const int minVal, const int maxVal) { +void SumEventsByLogValue::addMonitorCounts( + const ITableWorkspace_sptr &outputWorkspace, + const TimeSeriesProperty<int> *log, const int minVal, const int maxVal) { DataObjects::EventWorkspace_const_sptr monitorWorkspace = getProperty("MonitorWorkspace"); // If no monitor workspace was given, there's nothing to do diff --git a/Framework/Algorithms/src/SumSpectra.cpp b/Framework/Algorithms/src/SumSpectra.cpp index c08a7a0891a4dfae28920bb020ea9faf3da8e0dc..4b0e1b3edfbebb8fd0284e18bb213d8f57d7c665 100644 --- a/Framework/Algorithms/src/SumSpectra.cpp +++ b/Framework/Algorithms/src/SumSpectra.cpp @@ -324,7 +324,7 @@ void SumSpectra::determineIndices(const size_t numberOfSpectra) { * @return The minimum spectrum No for all the spectra being summed. */ specnum_t -SumSpectra::getOutputSpecNo(MatrixWorkspace_const_sptr localworkspace) { +SumSpectra::getOutputSpecNo(const MatrixWorkspace_const_sptr &localworkspace) { // initial value - any included spectrum will do specnum_t specId = localworkspace->getSpectrum(*(m_indices.begin())).getSpectrumNo(); @@ -435,7 +435,7 @@ bool useSpectrum(const SpectrumInfo &spectrumInfo, const size_t wsIndex, * @param numZeros The number of zero bins in histogram workspace or empty * spectra for event workspace. */ -void SumSpectra::doSimpleSum(MatrixWorkspace_sptr outputWorkspace, +void SumSpectra::doSimpleSum(const MatrixWorkspace_sptr &outputWorkspace, Progress &progress, size_t &numSpectra, size_t &numMasked, size_t &numZeros) { // Clean workspace of any NANs or Inf values @@ -510,7 +510,7 @@ void SumSpectra::doSimpleSum(MatrixWorkspace_sptr outputWorkspace, * @param numZeros The number of zero bins in histogram workspace or empty * spectra for event workspace. */ -void SumSpectra::doFractionalSum(MatrixWorkspace_sptr outputWorkspace, +void SumSpectra::doFractionalSum(const MatrixWorkspace_sptr &outputWorkspace, Progress &progress, size_t &numSpectra, size_t &numMasked, size_t &numZeros) { // First, we need to clean the input workspace for nan's and inf's in order @@ -608,7 +608,7 @@ void SumSpectra::doFractionalSum(MatrixWorkspace_sptr outputWorkspace, * @param numZeros The number of zero bins in histogram workspace or empty * spectra for event workspace. */ -void SumSpectra::execEvent(MatrixWorkspace_sptr outputWorkspace, +void SumSpectra::execEvent(const MatrixWorkspace_sptr &outputWorkspace, Progress &progress, size_t &numSpectra, size_t &numMasked, size_t &numZeros) { MatrixWorkspace_const_sptr localworkspace = getProperty("InputWorkspace"); diff --git a/Framework/Algorithms/src/TOFSANSResolutionByPixel.cpp b/Framework/Algorithms/src/TOFSANSResolutionByPixel.cpp index 92327c6020d2bd5e56b9fcd4d5912491445450be..a5862b2866bf8cbe9625b432190474a028c3d686 100644 --- a/Framework/Algorithms/src/TOFSANSResolutionByPixel.cpp +++ b/Framework/Algorithms/src/TOFSANSResolutionByPixel.cpp @@ -209,7 +209,7 @@ void TOFSANSResolutionByPixel::exec() { * @returns a copy of the input workspace */ MatrixWorkspace_sptr TOFSANSResolutionByPixel::setupOutputWorkspace( - MatrixWorkspace_sptr inputWorkspace) { + const MatrixWorkspace_sptr &inputWorkspace) { IAlgorithm_sptr duplicate = createChildAlgorithm("CloneWorkspace"); duplicate->initialize(); duplicate->setProperty<Workspace_sptr>("InputWorkspace", inputWorkspace); @@ -224,7 +224,7 @@ MatrixWorkspace_sptr TOFSANSResolutionByPixel::setupOutputWorkspace( * @returns the moderator workspace wiht the correct wavelength binning */ MatrixWorkspace_sptr TOFSANSResolutionByPixel::getModeratorWorkspace( - Mantid::API::MatrixWorkspace_sptr inputWorkspace) { + const Mantid::API::MatrixWorkspace_sptr &inputWorkspace) { MatrixWorkspace_sptr sigmaModerator = getProperty("SigmaModerator"); IAlgorithm_sptr rebinned = createChildAlgorithm("RebinToWorkspace"); @@ -242,7 +242,7 @@ MatrixWorkspace_sptr TOFSANSResolutionByPixel::getModeratorWorkspace( * @param inWS: the input workspace */ void TOFSANSResolutionByPixel::checkInput( - Mantid::API::MatrixWorkspace_sptr inWS) { + const Mantid::API::MatrixWorkspace_sptr &inWS) { // Make sure that input workspace has an instrument as we rely heavily on // thisa auto inst = inWS->getInstrument(); diff --git a/Framework/Algorithms/src/TimeAtSampleStrategyDirect.cpp b/Framework/Algorithms/src/TimeAtSampleStrategyDirect.cpp index 028f495e81e425191f517c7f67ab0a3f7ce9e9d2..e40755b92c351ce3e5db4d154d7e11255486f069 100644 --- a/Framework/Algorithms/src/TimeAtSampleStrategyDirect.cpp +++ b/Framework/Algorithms/src/TimeAtSampleStrategyDirect.cpp @@ -27,7 +27,7 @@ namespace Algorithms { /** Constructor */ TimeAtSampleStrategyDirect::TimeAtSampleStrategyDirect( - MatrixWorkspace_const_sptr ws, double ei) + const MatrixWorkspace_const_sptr &ws, double ei) : m_constShift(0) { // A constant among all spectra diff --git a/Framework/Algorithms/src/TimeAtSampleStrategyElastic.cpp b/Framework/Algorithms/src/TimeAtSampleStrategyElastic.cpp index 46ecee6753c3f74004984b483345e1b376684933..d8ba32fbadaee01dcd130590ad7f8a69c6ed94ef 100644 --- a/Framework/Algorithms/src/TimeAtSampleStrategyElastic.cpp +++ b/Framework/Algorithms/src/TimeAtSampleStrategyElastic.cpp @@ -4,9 +4,11 @@ // NScD Oak Ridge National Laboratory, European Spallation Source, // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + -#include "MantidAlgorithms/TimeAtSampleStrategyElastic.h" +#include <utility> + #include "MantidAPI/MatrixWorkspace.h" #include "MantidAPI/SpectrumInfo.h" +#include "MantidAlgorithms/TimeAtSampleStrategyElastic.h" #include "MantidGeometry/IComponent.h" #include "MantidGeometry/Instrument.h" #include "MantidGeometry/Instrument/ReferenceFrame.h" @@ -22,7 +24,7 @@ namespace Algorithms { */ TimeAtSampleStrategyElastic::TimeAtSampleStrategyElastic( Mantid::API::MatrixWorkspace_const_sptr ws) - : m_ws(ws), m_spectrumInfo(m_ws->spectrumInfo()), + : m_ws(std::move(ws)), m_spectrumInfo(m_ws->spectrumInfo()), m_beamDir( m_ws->getInstrument()->getReferenceFrame()->vecPointingAlongBeam()) {} diff --git a/Framework/Algorithms/src/TimeAtSampleStrategyIndirect.cpp b/Framework/Algorithms/src/TimeAtSampleStrategyIndirect.cpp index e173a5e3568f272e35b2f38f55c7eebab3ac7a2a..1084de35630bd11f226445f06e5360f189680cab 100644 --- a/Framework/Algorithms/src/TimeAtSampleStrategyIndirect.cpp +++ b/Framework/Algorithms/src/TimeAtSampleStrategyIndirect.cpp @@ -18,6 +18,7 @@ #include <boost/shared_ptr.hpp> #include <cmath> #include <sstream> +#include <utility> using namespace Mantid::Kernel; using namespace Mantid::Geometry; @@ -30,7 +31,7 @@ namespace Algorithms { */ TimeAtSampleStrategyIndirect::TimeAtSampleStrategyIndirect( MatrixWorkspace_const_sptr ws) - : m_ws(ws), m_spectrumInfo(m_ws->spectrumInfo()) {} + : m_ws(std::move(ws)), m_spectrumInfo(m_ws->spectrumInfo()) {} Correction TimeAtSampleStrategyIndirect::calculate(const size_t &workspace_index) const { diff --git a/Framework/Algorithms/src/Transpose.cpp b/Framework/Algorithms/src/Transpose.cpp index edf886f726a8df8c98cff4202b06e60dfcab2ff5..ac7f1807bb9f779a8513cf16944f97e1107261fd 100644 --- a/Framework/Algorithms/src/Transpose.cpp +++ b/Framework/Algorithms/src/Transpose.cpp @@ -98,7 +98,7 @@ void Transpose::exec() { * @return A pointer to the output workspace. */ API::MatrixWorkspace_sptr Transpose::createOutputWorkspace( - API::MatrixWorkspace_const_sptr inputWorkspace) { + const API::MatrixWorkspace_const_sptr &inputWorkspace) { Mantid::API::Axis *yAxis = getVerticalAxis(inputWorkspace); const size_t oldNhist = inputWorkspace->getNumberHistograms(); const auto &inX = inputWorkspace->x(0); @@ -138,8 +138,8 @@ API::MatrixWorkspace_sptr Transpose::createOutputWorkspace( * @param workspace :: A pointer to a workspace * @return An axis pointer for the vertical axis of the input workspace */ -API::Axis * -Transpose::getVerticalAxis(API::MatrixWorkspace_const_sptr workspace) const { +API::Axis *Transpose::getVerticalAxis( + const API::MatrixWorkspace_const_sptr &workspace) const { API::Axis *yAxis; try { yAxis = workspace->getAxis(1); diff --git a/Framework/Algorithms/src/WienerSmooth.cpp b/Framework/Algorithms/src/WienerSmooth.cpp index 3b28573c8696ebc7e067d20eeb5f8bbca21065ab..a2c56911f3b3cbb784669301468ac6abaf7b3f93 100644 --- a/Framework/Algorithms/src/WienerSmooth.cpp +++ b/Framework/Algorithms/src/WienerSmooth.cpp @@ -420,7 +420,8 @@ WienerSmooth::getStartEnd(const Mantid::HistogramData::HistogramX &X, * @return :: Workspace with the copied spectrum. */ API::MatrixWorkspace_sptr -WienerSmooth::copyInput(API::MatrixWorkspace_sptr inputWS, size_t wsIndex) { +WienerSmooth::copyInput(const API::MatrixWorkspace_sptr &inputWS, + size_t wsIndex) { auto alg = createChildAlgorithm("ExtractSingleSpectrum"); alg->initialize(); alg->setProperty("InputWorkspace", inputWS); diff --git a/Framework/Algorithms/src/WorkflowAlgorithmRunner.cpp b/Framework/Algorithms/src/WorkflowAlgorithmRunner.cpp index 5cad33ea450c240aa7224eb0f8d19e5b1f9ae399..4262dd66ef98633aad357f1077bcb83eaa302e70 100644 --- a/Framework/Algorithms/src/WorkflowAlgorithmRunner.cpp +++ b/Framework/Algorithms/src/WorkflowAlgorithmRunner.cpp @@ -59,7 +59,8 @@ std::string tidyWorkspaceName(const std::string &s) { * @throw std::runtime_error in case of errorneous entries in `table` */ template <typename MAP> -void cleanPropertyTable(ITableWorkspace_sptr table, const MAP &ioMapping) { +void cleanPropertyTable(const ITableWorkspace_sptr &table, + const MAP &ioMapping) { // Some output columns may be processed several times, but this should // not be a serious performance hit. for (const auto &ioPair : ioMapping) { diff --git a/Framework/Algorithms/src/XDataConverter.cpp b/Framework/Algorithms/src/XDataConverter.cpp index 54aacafa83cab9047cde3e17af6fa4b2dc769214..b656ca879a0962a0227f56ddbd8b16931e384341 100644 --- a/Framework/Algorithms/src/XDataConverter.cpp +++ b/Framework/Algorithms/src/XDataConverter.cpp @@ -90,7 +90,7 @@ void XDataConverter::exec() { } std::size_t -XDataConverter::getNewYSize(const API::MatrixWorkspace_sptr inputWS) { +XDataConverter::getNewYSize(const API::MatrixWorkspace_sptr &inputWS) { // this is the old behavior of MatrixWorkspace::blocksize() return inputWS->y(0).size(); } @@ -101,8 +101,8 @@ XDataConverter::getNewYSize(const API::MatrixWorkspace_sptr inputWS) { * @param inputWS :: The input workspace * @param index :: The index */ -void XDataConverter::setXData(API::MatrixWorkspace_sptr outputWS, - const API::MatrixWorkspace_sptr inputWS, +void XDataConverter::setXData(const API::MatrixWorkspace_sptr &outputWS, + const API::MatrixWorkspace_sptr &inputWS, const int index) { if (m_sharedX) { PARALLEL_CRITICAL(XDataConverter_para) { diff --git a/Framework/Algorithms/test/AddNoteTest.h b/Framework/Algorithms/test/AddNoteTest.h index 547493876e9581ef288c90c274550ad9753af0e2..57338460fd0bfd680e407c6f0869fd5290df74de 100644 --- a/Framework/Algorithms/test/AddNoteTest.h +++ b/Framework/Algorithms/test/AddNoteTest.h @@ -88,9 +88,9 @@ public: } private: - void executeAlgorithm(Mantid::API::MatrixWorkspace_sptr testWS, + void executeAlgorithm(const Mantid::API::MatrixWorkspace_sptr &testWS, const std::string &logName, const std::string &logTime, - const std::string logValue, + const std::string &logValue, const UpdateType update = Update) { Mantid::Algorithms::AddNote alg; @@ -110,11 +110,11 @@ private: } template <typename T> - void checkLogWithEntryExists(Mantid::API::MatrixWorkspace_sptr testWS, + void checkLogWithEntryExists(const Mantid::API::MatrixWorkspace_sptr &testWS, const std::string &logName, const std::string &logStartTime, const int &logEndTime, - const std::string logValue, + const std::string &logValue, const size_t position) { using Mantid::Kernel::TimeSeriesProperty; using Mantid::Types::Core::DateAndTime; diff --git a/Framework/Algorithms/test/AddSampleLogTest.h b/Framework/Algorithms/test/AddSampleLogTest.h index f929806e824ced1e1f076b7b1fb3fddb2b560e55..45d9bec83ff41af98f380b695ccc88368ed91ac5 100644 --- a/Framework/Algorithms/test/AddSampleLogTest.h +++ b/Framework/Algorithms/test/AddSampleLogTest.h @@ -170,11 +170,12 @@ public: } template <typename T> - void - ExecuteAlgorithm(MatrixWorkspace_sptr testWS, std::string LogName, - std::string LogType, std::string LogText, T expectedValue, - bool fails = false, std::string LogUnit = "", - std::string NumberType = "AutoDetect", bool throws = false) { + void ExecuteAlgorithm(const MatrixWorkspace_sptr &testWS, + const std::string &LogName, const std::string &LogType, + const std::string &LogText, T expectedValue, + bool fails = false, const std::string &LogUnit = "", + const std::string &NumberType = "AutoDetect", + bool throws = false) { // add the workspace to the ADS AnalysisDataService::Instance().addOrReplace("AddSampleLogTest_Temporary", testWS); diff --git a/Framework/Algorithms/test/AddTimeSeriesLogTest.h b/Framework/Algorithms/test/AddTimeSeriesLogTest.h index 8811ed1163c8c8e5f73751e88e6f93b964a96bdb..7a7fb480e888134123079dab752fa71926faf422 100644 --- a/Framework/Algorithms/test/AddTimeSeriesLogTest.h +++ b/Framework/Algorithms/test/AddTimeSeriesLogTest.h @@ -134,7 +134,7 @@ public: } private: - void executeAlgorithm(Mantid::API::MatrixWorkspace_sptr testWS, + void executeAlgorithm(const Mantid::API::MatrixWorkspace_sptr &testWS, const std::string &logName, const std::string &logTime, const double logValue, const LogType type = Double, const UpdateType update = Update) { @@ -157,7 +157,7 @@ private: } template <typename T> - void checkLogWithEntryExists(Mantid::API::MatrixWorkspace_sptr testWS, + void checkLogWithEntryExists(const Mantid::API::MatrixWorkspace_sptr &testWS, const std::string &logName, const std::string &logTime, const T logValue, const size_t position) { diff --git a/Framework/Algorithms/test/AnyShapeAbsorptionTest.h b/Framework/Algorithms/test/AnyShapeAbsorptionTest.h index 89f511c9ebf2443a269e06e937c7b91e30807ad2..00416e4ad487fde80e1613c6d4b4ea7b5d32e804 100644 --- a/Framework/Algorithms/test/AnyShapeAbsorptionTest.h +++ b/Framework/Algorithms/test/AnyShapeAbsorptionTest.h @@ -257,7 +257,6 @@ public: constexpr double WL_DELTA = (2.9 - WL_MIN) / static_cast<double>(NUM_VALS); // create the input workspace - const std::string IN_WS{"AbsorptionCorrection_Input"}; auto inputWS = WorkspaceCreationHelper::create2DWorkspaceBinned( 1, NUM_VALS, WL_MIN, WL_DELTA); auto testInst = diff --git a/Framework/Algorithms/test/AppendSpectraTest.h b/Framework/Algorithms/test/AppendSpectraTest.h index 1e584609848c81afcbce6a83c4d7252a3a28c15a..261eb100c1fb797034f42f05e8cd230c4d29ef16 100644 --- a/Framework/Algorithms/test/AppendSpectraTest.h +++ b/Framework/Algorithms/test/AppendSpectraTest.h @@ -432,9 +432,9 @@ private: } /** Creates a 2D workspace with 5 histograms */ - void createWorkspaceWithAxisAndLabel(const std::string outputName, + void createWorkspaceWithAxisAndLabel(const std::string &outputName, const std::string &axisType, - const std::string axisValue) { + const std::string &axisValue) { int nspec = 5; std::vector<std::string> YVals; std::vector<double> dataX; diff --git a/Framework/Algorithms/test/ApplyCalibrationTest.h b/Framework/Algorithms/test/ApplyCalibrationTest.h index c666885b977991da9672de2b0e2ac0c41591055a..fb596ef039a72c7add3b78fe715ad46eff55ef56 100644 --- a/Framework/Algorithms/test/ApplyCalibrationTest.h +++ b/Framework/Algorithms/test/ApplyCalibrationTest.h @@ -82,11 +82,9 @@ public: TS_ASSERT(appCalib.isExecuted()); const auto &spectrumInfo = ws->spectrumInfo(); - const auto &componentInfo = ws->componentInfo(); int id = spectrumInfo.detector(0).getID(); V3D newPos = spectrumInfo.position(0); - V3D scaleFactor = componentInfo.scaleFactor(0); TS_ASSERT_EQUALS(id, 1); TS_ASSERT_DELTA(newPos.X(), 1.0, 0.0001); @@ -95,7 +93,6 @@ public: id = spectrumInfo.detector(ndets - 1).getID(); newPos = spectrumInfo.position(ndets - 1); - scaleFactor = componentInfo.scaleFactor(0); TS_ASSERT_EQUALS(id, ndets); TS_ASSERT_DELTA(newPos.X(), 1.0, 0.0001); diff --git a/Framework/Algorithms/test/ApplyFloodWorkspaceTest.h b/Framework/Algorithms/test/ApplyFloodWorkspaceTest.h index aa6663deaabd64a8eda53875a22e14d0f6f1d5ff..513fa13adac8800cf9c17631ce33d53889596373 100644 --- a/Framework/Algorithms/test/ApplyFloodWorkspaceTest.h +++ b/Framework/Algorithms/test/ApplyFloodWorkspaceTest.h @@ -65,9 +65,9 @@ public: } private: - MatrixWorkspace_sptr - createFloodWorkspace(Mantid::Geometry::Instrument_const_sptr instrument, - std::string const &xUnit = "TOF") { + MatrixWorkspace_sptr createFloodWorkspace( + const Mantid::Geometry::Instrument_const_sptr &instrument, + std::string const &xUnit = "TOF") { MatrixWorkspace_sptr flood = create2DWorkspace(4, 1); flood->mutableY(0)[0] = 0.7; flood->mutableY(1)[0] = 1.0; diff --git a/Framework/Algorithms/test/Bin2DPowderDiffractionTest.h b/Framework/Algorithms/test/Bin2DPowderDiffractionTest.h index bcfff101bcac39ab2c05ed39c09d991278619a8a..d3e34e2f6d227f8fee16fb107e51dfd768b65b43 100644 --- a/Framework/Algorithms/test/Bin2DPowderDiffractionTest.h +++ b/Framework/Algorithms/test/Bin2DPowderDiffractionTest.h @@ -284,7 +284,7 @@ private: } // creates test file with bins description - void createBinFile(std::string fname) { + void createBinFile(const std::string &fname) { std::ofstream binfile; binfile.open(fname); binfile << "#dp_min #dp_max\n"; diff --git a/Framework/Algorithms/test/BinaryOperationTest.h b/Framework/Algorithms/test/BinaryOperationTest.h index b7fc31ca5216eb8cf84fb994f3a38107f23e78e0..fb694bd5b81f19abc45df13f9f5faa9cead4496f 100644 --- a/Framework/Algorithms/test/BinaryOperationTest.h +++ b/Framework/Algorithms/test/BinaryOperationTest.h @@ -7,6 +7,8 @@ #pragma once #include <cmath> +#include <utility> + #include <cxxtest/TestSuite.h> #include "MantidAPI/AnalysisDataService.h" @@ -42,8 +44,8 @@ public: /// is provided. const std::string summary() const override { return "Summary of this test."; } - std::string checkSizeCompatibility(const MatrixWorkspace_const_sptr ws1, - const MatrixWorkspace_const_sptr ws2) { + std::string checkSizeCompatibility(const MatrixWorkspace_const_sptr &ws1, + const MatrixWorkspace_const_sptr &ws2) { m_lhs = ws1; m_rhs = ws2; m_lhsBlocksize = ws1->blocksize(); @@ -297,9 +299,11 @@ public: std::vector<std::vector<int>> rhs, bool expect_throw = false) { EventWorkspace_sptr lhsWS = - WorkspaceCreationHelper::createGroupedEventWorkspace(lhs, 50, 1.0); + WorkspaceCreationHelper::createGroupedEventWorkspace(std::move(lhs), 50, + 1.0); EventWorkspace_sptr rhsWS = - WorkspaceCreationHelper::createGroupedEventWorkspace(rhs, 50, 1.0); + WorkspaceCreationHelper::createGroupedEventWorkspace(std::move(rhs), 50, + 1.0); BinaryOperation::BinaryOperationTable_sptr table; Mantid::Kernel::Timer timer1; if (expect_throw) { diff --git a/Framework/Algorithms/test/CalculateDIFCTest.h b/Framework/Algorithms/test/CalculateDIFCTest.h index 8e15a35d9c4c45f260f61cd7f2512d7d2236c908..509a4925d6572ffec033bd3d26fe837dd4b25ad5 100644 --- a/Framework/Algorithms/test/CalculateDIFCTest.h +++ b/Framework/Algorithms/test/CalculateDIFCTest.h @@ -39,8 +39,8 @@ public: TS_ASSERT(alg.isInitialized()) } - void runTest(Workspace2D_sptr inputWS, OffsetsWorkspace_sptr offsetsWS, - std::string &outWSName) { + void runTest(const Workspace2D_sptr &inputWS, + const OffsetsWorkspace_sptr &offsetsWS, std::string &outWSName) { CalculateDIFC alg; TS_ASSERT_THROWS_NOTHING(alg.initialize()) diff --git a/Framework/Algorithms/test/CalculateFlatBackgroundTest.h b/Framework/Algorithms/test/CalculateFlatBackgroundTest.h index 8fb91e7509e52aa4b8aba7f6d6ac67b0763800d7..7c65acff010c91d5b4600d49e7bbc0c1f47f6966 100644 --- a/Framework/Algorithms/test/CalculateFlatBackgroundTest.h +++ b/Framework/Algorithms/test/CalculateFlatBackgroundTest.h @@ -763,6 +763,7 @@ private: AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>( "Removed1"); for (size_t j = 0; j < spectraCount; ++j) { + // cppcheck-suppress unreadVariable const double expected = (movingAverageSpecialY(j) + (static_cast<double>(windowWidth) - 1) * movingAverageStandardY(j)) / @@ -839,7 +840,8 @@ private: } void compareSubtractedAndBackgroundWorkspaces( - MatrixWorkspace_sptr originalWS, const std::string &subtractedWSName, + const MatrixWorkspace_sptr &originalWS, + const std::string &subtractedWSName, const std::string &backgroundWSName) { const std::string minusWSName("minused"); MatrixWorkspace_sptr backgroundWS = diff --git a/Framework/Algorithms/test/CalculateIqtTest.h b/Framework/Algorithms/test/CalculateIqtTest.h index 132ac4c142c5e48ec4ea3647cc8bbaebd16b507b..c0eb3d2d8f9a70a7a80eabceb64ea2087246192d 100644 --- a/Framework/Algorithms/test/CalculateIqtTest.h +++ b/Framework/Algorithms/test/CalculateIqtTest.h @@ -54,8 +54,8 @@ Mantid::API::MatrixWorkspace_sptr setUpResolutionWorkspace() { return createWorkspace->getProperty("OutputWorkspace"); } -IAlgorithm_sptr calculateIqtAlgorithm(MatrixWorkspace_sptr sample, - MatrixWorkspace_sptr resolution, +IAlgorithm_sptr calculateIqtAlgorithm(const MatrixWorkspace_sptr &sample, + const MatrixWorkspace_sptr &resolution, const double EnergyMin = -0.5, const double EnergyMax = 0.5, const double EnergyWidth = 0.1, diff --git a/Framework/Algorithms/test/CalculateTransmissionTest.h b/Framework/Algorithms/test/CalculateTransmissionTest.h index 238ab958c5f0683bd41b4a8abc6cb8fa44ba0511..f440374c3394b48968779ce29a492e780b275fcb 100644 --- a/Framework/Algorithms/test/CalculateTransmissionTest.h +++ b/Framework/Algorithms/test/CalculateTransmissionTest.h @@ -361,10 +361,9 @@ public: auto &fitted_x = fitted->x(0); // TS_ASSERT_EQUALS(fitted_y.size(), unfitted_y.size()); - double x; for (unsigned int i = 0; i < fitted_y.size(); ++i) { - x = fitted_x[i]; //(fitted_x[i] + fitted_x[i+1])* 0.5; + double x = fitted_x[i]; //(fitted_x[i] + fitted_x[i+1])* 0.5; TS_ASSERT_DELTA(fitted_y[i], 26.6936 - 9.31494 * x + 1.11532 * x * x - 0.044502 * x * x * x, @@ -405,10 +404,9 @@ public: auto &fitted_x = fitted->x(0); // TS_ASSERT_EQUALS(fitted_y.size(), unfitted_y.size()); - double x; for (unsigned int i = 0; i < fitted_y.size(); ++i) { - x = (fitted_x[i] + fitted_x[i + 1]) * 0.5; + double x = (fitted_x[i] + fitted_x[i + 1]) * 0.5; TS_ASSERT_DELTA(fitted_y[i], 26.6936 - 9.31494 * x + 1.11532 * x * x - 0.044502 * x * x * x, diff --git a/Framework/Algorithms/test/ChainedOperatorTest.h b/Framework/Algorithms/test/ChainedOperatorTest.h index 4e51d242ecd5ef003050e00557b4f18972fa94b5..36ecc1c4749602673c2a75bb540d91fd1b61221a 100644 --- a/Framework/Algorithms/test/ChainedOperatorTest.h +++ b/Framework/Algorithms/test/ChainedOperatorTest.h @@ -70,8 +70,8 @@ public: performTest(work_in1, work_in2); } - void performTest(MatrixWorkspace_sptr work_in1, - MatrixWorkspace_sptr work_in2) { + void performTest(const MatrixWorkspace_sptr &work_in1, + const MatrixWorkspace_sptr &work_in2) { ComplexOpTest alg; std::string wsNameIn1 = "testChainedOperator_in21"; @@ -98,9 +98,9 @@ public: } private: - void checkData(const MatrixWorkspace_sptr work_in1, - const MatrixWorkspace_sptr work_in2, - const MatrixWorkspace_sptr work_out1) { + void checkData(const MatrixWorkspace_sptr &work_in1, + const MatrixWorkspace_sptr &work_in2, + const MatrixWorkspace_sptr &work_out1) { size_t ws2LoopCount = 0; if (work_in2->size() > 0) { ws2LoopCount = work_in1->size() / work_in2->size(); @@ -112,9 +112,9 @@ private: } } - void checkDataItem(const MatrixWorkspace_sptr work_in1, - const MatrixWorkspace_sptr work_in2, - const MatrixWorkspace_sptr work_out1, size_t i, + void checkDataItem(const MatrixWorkspace_sptr &work_in1, + const MatrixWorkspace_sptr &work_in2, + const MatrixWorkspace_sptr &work_out1, size_t i, size_t ws2Index) { double sig1 = work_in1->readY(i / work_in1->blocksize())[i % work_in1->blocksize()]; diff --git a/Framework/Algorithms/test/ChangeLogTimeTest.h b/Framework/Algorithms/test/ChangeLogTimeTest.h index b923e8da0f2c16989e6c56be133342f48bf1b872..e7007c0f3046126c0a3ecda4ba5ae8e8dd062fd4 100644 --- a/Framework/Algorithms/test/ChangeLogTimeTest.h +++ b/Framework/Algorithms/test/ChangeLogTimeTest.h @@ -52,7 +52,7 @@ private: * @param in_name Name of the input workspace. * @param out_name Name of the output workspace. */ - void verify(const std::string in_name, const std::string out_name) { + void verify(const std::string &in_name, const std::string &out_name) { DateAndTime start(start_str); // create a workspace to mess with diff --git a/Framework/Algorithms/test/ChangePulsetime2Test.h b/Framework/Algorithms/test/ChangePulsetime2Test.h index 383501bfa2a87b3f9a8be3077cc06aeff3e694b8..5e39d09bfcf7ca0597d0872b2ca4efc58e9f8287 100644 --- a/Framework/Algorithms/test/ChangePulsetime2Test.h +++ b/Framework/Algorithms/test/ChangePulsetime2Test.h @@ -22,8 +22,9 @@ using Mantid::Types::Core::DateAndTime; namespace { EventWorkspace_sptr -execute_change_of_pulse_times(EventWorkspace_sptr in_ws, std::string timeOffset, - std::string workspaceIndexList) { +execute_change_of_pulse_times(const EventWorkspace_sptr &in_ws, + const std::string &timeOffset, + const std::string &workspaceIndexList) { // Create and run the algorithm ChangePulsetime2 alg; alg.initialize(); @@ -53,8 +54,8 @@ public: TS_ASSERT(alg.isInitialized()) } - void do_test(std::string in_ws_name, std::string out_ws_name, - std::string WorkspaceIndexList) { + void do_test(const std::string &in_ws_name, const std::string &out_ws_name, + const std::string &WorkspaceIndexList) { ChangePulsetime2 alg; TS_ASSERT_THROWS_NOTHING(alg.initialize()) TS_ASSERT(alg.isInitialized()) diff --git a/Framework/Algorithms/test/ChangePulsetimeTest.h b/Framework/Algorithms/test/ChangePulsetimeTest.h index 6ecb5b9e5a450506fba46043b54dacadaf22fd29..22500e9fc344b6056fee0d93165acbdaf3fa5a11 100644 --- a/Framework/Algorithms/test/ChangePulsetimeTest.h +++ b/Framework/Algorithms/test/ChangePulsetimeTest.h @@ -21,8 +21,9 @@ using Mantid::Types::Core::DateAndTime; namespace { EventWorkspace_sptr -execute_change_of_pulse_times(EventWorkspace_sptr in_ws, std::string timeOffset, - std::string workspaceIndexList) { +execute_change_of_pulse_times(const EventWorkspace_sptr &in_ws, + const std::string &timeOffset, + const std::string &workspaceIndexList) { // Create and run the algorithm ChangePulsetime alg; alg.initialize(); @@ -51,8 +52,8 @@ public: TS_ASSERT(alg.isInitialized()) } - void do_test(std::string in_ws_name, std::string out_ws_name, - std::string WorkspaceIndexList) { + void do_test(const std::string &in_ws_name, const std::string &out_ws_name, + const std::string &WorkspaceIndexList) { ChangePulsetime alg; TS_ASSERT_THROWS_NOTHING(alg.initialize()) TS_ASSERT(alg.isInitialized()) diff --git a/Framework/Algorithms/test/ChangeTimeZeroTest.h b/Framework/Algorithms/test/ChangeTimeZeroTest.h index 81e7d68a053f390bbe759cb448424f0cff504930..8c69978f19eb48a2887e3dcf4bc861c1e1604fe1 100644 --- a/Framework/Algorithms/test/ChangeTimeZeroTest.h +++ b/Framework/Algorithms/test/ChangeTimeZeroTest.h @@ -9,6 +9,8 @@ #include "MantidKernel/Timer.h" #include <cxxtest/TestSuite.h> +#include <utility> + #include "MantidAPI/MatrixWorkspace.h" #include "MantidAPI/ScopedWorkspace.h" #include "MantidAPI/WorkspaceGroup.h" @@ -36,8 +38,8 @@ DateAndTime stringPropertyTime("2010-01-01T00:10:00"); enum LogType { STANDARD, NOPROTONCHARGE }; template <typename T> -void addTimeSeriesLogToWorkspace(Mantid::API::MatrixWorkspace_sptr ws, - std::string id, DateAndTime startTime, +void addTimeSeriesLogToWorkspace(const Mantid::API::MatrixWorkspace_sptr &ws, + const std::string &id, DateAndTime startTime, T defaultValue, int length) { auto timeSeries = new TimeSeriesProperty<T>(id); timeSeries->setUnits("mm"); @@ -48,15 +50,15 @@ void addTimeSeriesLogToWorkspace(Mantid::API::MatrixWorkspace_sptr ws, } template <typename T> -void addProperyWithValueToWorkspace(Mantid::API::MatrixWorkspace_sptr ws, - std::string id, T value) { +void addProperyWithValueToWorkspace(const Mantid::API::MatrixWorkspace_sptr &ws, + const std::string &id, T value) { auto propWithVal = new PropertyWithValue<T>(id, value); propWithVal->setUnits("mm"); ws->mutableRun().addProperty(propWithVal, true); } // Provide the logs for matrix workspaces -void provideLogs(LogType logType, Mantid::API::MatrixWorkspace_sptr ws, +void provideLogs(LogType logType, const Mantid::API::MatrixWorkspace_sptr &ws, DateAndTime startTime, int length) { switch (logType) { case (STANDARD): @@ -96,7 +98,7 @@ void provideLogs(LogType logType, Mantid::API::MatrixWorkspace_sptr ws, // Provides a 2D workspace with a log Mantid::API::MatrixWorkspace_sptr provideWorkspace2D(LogType logType, - std::string wsName, + const std::string &wsName, DateAndTime startTime, int length) { Workspace2D_sptr ws(new Workspace2D); @@ -140,9 +142,9 @@ provideEventWorkspace(LogType logType, DateAndTime startTime, int length) { return provideEventWorkspaceCustom(logType, startTime, length, 100, 100, 100); } -MatrixWorkspace_sptr execute_change_time(MatrixWorkspace_sptr in_ws, +MatrixWorkspace_sptr execute_change_time(const MatrixWorkspace_sptr &in_ws, double relativeTimeOffset, - std::string absolutTimeOffset) { + const std::string &absolutTimeOffset) { // Create and run the algorithm ChangeTimeZero alg; alg.initialize(); @@ -441,8 +443,9 @@ private: int m_length; // act and assert - void act_and_assert(double relativeTimeShift, std::string absoluteTimeShift, - MatrixWorkspace_sptr in_ws, + void act_and_assert(double relativeTimeShift, + const std::string &absoluteTimeShift, + const MatrixWorkspace_sptr &in_ws, bool inputEqualsOutputWorkspace) { // Create a duplicate workspace EventWorkspace_sptr duplicate_ws; @@ -484,8 +487,8 @@ private: } // perform the verification - void do_test_shift(MatrixWorkspace_sptr ws, const double timeShift, - MatrixWorkspace_sptr duplicate) const { + void do_test_shift(const MatrixWorkspace_sptr &ws, const double timeShift, + const MatrixWorkspace_sptr &duplicate) const { // Check the logs TS_ASSERT(ws); @@ -501,7 +504,7 @@ private: // Check the neutrons if (auto outWs = boost::dynamic_pointer_cast<EventWorkspace>(ws)) { - do_check_workspace(outWs, timeShift, duplicate); + do_check_workspace(outWs, timeShift, std::move(duplicate)); } } @@ -536,8 +539,8 @@ private: } // Check contents of an event workspace. We compare the time stamps to the // time stamps of the duplicate workspace - void do_check_workspace(EventWorkspace_sptr ws, double timeShift, - MatrixWorkspace_sptr duplicate) const { + void do_check_workspace(const EventWorkspace_sptr &ws, double timeShift, + const MatrixWorkspace_sptr &duplicate) const { // Get the duplicate input workspace for comparison reasons auto duplicateWs = boost::dynamic_pointer_cast<EventWorkspace>(duplicate); @@ -562,7 +565,7 @@ private: // Create comparison workspace EventWorkspace_sptr - createComparisonWorkspace(EventWorkspace_sptr inputWorkspace) { + createComparisonWorkspace(const EventWorkspace_sptr &inputWorkspace) { CloneWorkspace alg; alg.setChild(true); TS_ASSERT_THROWS_NOTHING(alg.initialize()) diff --git a/Framework/Algorithms/test/CheckWorkspacesMatchTest.h b/Framework/Algorithms/test/CheckWorkspacesMatchTest.h index 716105ed1a88be94a9142d4283e9ee6966f264c4..87630794e631474e0411e9ac6b5c6c09d79a696d 100644 --- a/Framework/Algorithms/test/CheckWorkspacesMatchTest.h +++ b/Framework/Algorithms/test/CheckWorkspacesMatchTest.h @@ -1140,7 +1140,7 @@ private: TS_ASSERT_EQUALS(matcher.getPropertyValue("Result"), expectedResult); } - void cleanupGroup(const WorkspaceGroup_sptr group) { + void cleanupGroup(const WorkspaceGroup_sptr &group) { // group->deepRemoveAll(); const std::string name = group->getName(); Mantid::API::AnalysisDataService::Instance().deepRemoveGroup(name); diff --git a/Framework/Algorithms/test/ClearCacheTest.h b/Framework/Algorithms/test/ClearCacheTest.h index 73069ee0a44b853209439068ea8668614a494a63..d6f1a2a7a2a41f1d1ea6ca178d005513dc60cff8 100644 --- a/Framework/Algorithms/test/ClearCacheTest.h +++ b/Framework/Algorithms/test/ClearCacheTest.h @@ -49,7 +49,7 @@ public: createDirectory(GeomPath); } - void createDirectory(Poco::Path path) { + void createDirectory(const Poco::Path &path) { Poco::File file(path); if (file.createDirectory()) { m_directoriesToRemove.emplace_back(file); diff --git a/Framework/Algorithms/test/ClearInstrumentParametersTest.h b/Framework/Algorithms/test/ClearInstrumentParametersTest.h index cd866bdc40acc55cf06b4e1e9da0f4c2baf688da..2e8d40202a598a925faf87f32b48d9824fab1852 100644 --- a/Framework/Algorithms/test/ClearInstrumentParametersTest.h +++ b/Framework/Algorithms/test/ClearInstrumentParametersTest.h @@ -47,21 +47,23 @@ public: TS_ASSERT_EQUALS(oldPos, m_ws->detectorInfo().position(0)); } - void setParam(std::string cName, std::string pName, std::string value) { + void setParam(const std::string &cName, const std::string &pName, + const std::string &value) { Instrument_const_sptr inst = m_ws->getInstrument(); ParameterMap ¶mMap = m_ws->instrumentParameters(); boost::shared_ptr<const IComponent> comp = inst->getComponentByName(cName); paramMap.addString(comp->getComponentID(), pName, value); } - void setParam(std::string cName, std::string pName, double value) { + void setParam(const std::string &cName, const std::string &pName, + double value) { Instrument_const_sptr inst = m_ws->getInstrument(); ParameterMap ¶mMap = m_ws->instrumentParameters(); boost::shared_ptr<const IComponent> comp = inst->getComponentByName(cName); paramMap.addDouble(comp->getComponentID(), pName, value); } - void checkEmpty(std::string cName, std::string pName) { + void checkEmpty(const std::string &cName, const std::string &pName) { Instrument_const_sptr inst = m_ws->getInstrument(); ParameterMap ¶mMap = m_ws->instrumentParameters(); boost::shared_ptr<const IComponent> comp = inst->getComponentByName(cName); diff --git a/Framework/Algorithms/test/CommutativeBinaryOperationTest.h b/Framework/Algorithms/test/CommutativeBinaryOperationTest.h index 24eb4aaa6fff32a55c8f6988f04af2ca5253a003..a7c834710b1fa98356809efef6257143045949fc 100644 --- a/Framework/Algorithms/test/CommutativeBinaryOperationTest.h +++ b/Framework/Algorithms/test/CommutativeBinaryOperationTest.h @@ -33,8 +33,8 @@ public: return "Commutative binary operation helper."; } - std::string checkSizeCompatibility(const MatrixWorkspace_const_sptr ws1, - const MatrixWorkspace_const_sptr ws2) { + std::string checkSizeCompatibility(const MatrixWorkspace_const_sptr &ws1, + const MatrixWorkspace_const_sptr &ws2) { m_lhs = ws1; m_rhs = ws2; m_lhsBlocksize = ws1->blocksize(); diff --git a/Framework/Algorithms/test/CompareWorkspacesTest.h b/Framework/Algorithms/test/CompareWorkspacesTest.h index fe15a2ed1e00a56af6781180ca8ed86131ba5669..a2d907d86fa79e55636705aa119eea1e125c192a 100644 --- a/Framework/Algorithms/test/CompareWorkspacesTest.h +++ b/Framework/Algorithms/test/CompareWorkspacesTest.h @@ -1351,7 +1351,7 @@ private: } } - void cleanupGroup(const WorkspaceGroup_sptr group) { + void cleanupGroup(const WorkspaceGroup_sptr &group) { // group->deepRemoveAll(); const std::string name = group->getName(); Mantid::API::AnalysisDataService::Instance().deepRemoveGroup(name); diff --git a/Framework/Algorithms/test/ConjoinWorkspacesTest.h b/Framework/Algorithms/test/ConjoinWorkspacesTest.h index 27d90dde12a1a75d31f0f48672e319be6f7d16fd..2485feebb729076714020c5f41df507c15974e38 100644 --- a/Framework/Algorithms/test/ConjoinWorkspacesTest.h +++ b/Framework/Algorithms/test/ConjoinWorkspacesTest.h @@ -37,7 +37,7 @@ public: : ws1Name("ConjoinWorkspacesTest_grp1"), ws2Name("ConjoinWorkspacesTest_grp2") {} - MatrixWorkspace_sptr getWSFromADS(std::string wsName) { + MatrixWorkspace_sptr getWSFromADS(const std::string &wsName) { auto out = boost::dynamic_pointer_cast<MatrixWorkspace>( AnalysisDataService::Instance().retrieve(wsName)); TS_ASSERT(out); diff --git a/Framework/Algorithms/test/ConvertAxesToRealSpaceTest.h b/Framework/Algorithms/test/ConvertAxesToRealSpaceTest.h index 3fad5cfc7c86596740a815439162c61369d4e984..56ae17def050ad508e455c8b1b11db6116f4f23d 100644 --- a/Framework/Algorithms/test/ConvertAxesToRealSpaceTest.h +++ b/Framework/Algorithms/test/ConvertAxesToRealSpaceTest.h @@ -55,10 +55,10 @@ public: do_algorithm_run(baseWSName, "phi", "signed2theta", 100, 200); } - MatrixWorkspace_sptr do_algorithm_run(std::string baseWSName, - std::string verticalAxis, - std::string horizontalAxis, int nHBins, - int nVBins) { + MatrixWorkspace_sptr do_algorithm_run(const std::string &baseWSName, + const std::string &verticalAxis, + const std::string &horizontalAxis, + int nHBins, int nVBins) { std::string inWSName(baseWSName + "_InputWS"); std::string outWSName(baseWSName + "_OutputWS"); diff --git a/Framework/Algorithms/test/ConvertAxisByFormulaTest.h b/Framework/Algorithms/test/ConvertAxisByFormulaTest.h index df3e41b59caffe07ff3707835435d78877116be6..6b55ecffeb14beef33741b690ca9bb8ef7543442 100644 --- a/Framework/Algorithms/test/ConvertAxisByFormulaTest.h +++ b/Framework/Algorithms/test/ConvertAxisByFormulaTest.h @@ -197,8 +197,9 @@ public: cleanupWorkspaces(std::vector<std::string>{inputWs}); } - bool runConvertAxisByFormula(std::string testName, std::string formula, - std::string axis, std::string &inputWs, + bool runConvertAxisByFormula(const std::string &testName, + const std::string &formula, + const std::string &axis, std::string &inputWs, std::string &resultWs) { Mantid::Algorithms::ConvertAxisByFormula alg; alg.initialize(); diff --git a/Framework/Algorithms/test/ConvertSpectrumAxis2Test.h b/Framework/Algorithms/test/ConvertSpectrumAxis2Test.h index 595e8c4b8f5d926a29955aaab0503fb764ce0bcc..78f9b1605ab800b91551c52857cc2d310665b88d 100644 --- a/Framework/Algorithms/test/ConvertSpectrumAxis2Test.h +++ b/Framework/Algorithms/test/ConvertSpectrumAxis2Test.h @@ -23,8 +23,8 @@ using namespace Mantid::HistogramData::detail; class ConvertSpectrumAxis2Test : public CxxTest::TestSuite { private: - void do_algorithm_run(std::string target, std::string inputWS, - std::string outputWS, bool startYNegative = true, + void do_algorithm_run(const std::string &target, const std::string &inputWS, + const std::string &outputWS, bool startYNegative = true, bool isHistogram = true) { auto testWS = WorkspaceCreationHelper::create2DWorkspaceWithFullInstrument( 3, 1, false, startYNegative, isHistogram); @@ -45,7 +45,7 @@ private: } void check_output_values_for_signed_theta_conversion( - std::string outputWSSignedTheta) { + const std::string &outputWSSignedTheta) { MatrixWorkspace_const_sptr outputSignedTheta; TS_ASSERT_THROWS_NOTHING( outputSignedTheta = @@ -69,8 +69,9 @@ private: TS_ASSERT_DELTA((*thetaAxis)(2), 1.1458, 0.0001); } - void check_output_values_for_theta_conversion(std::string inputWSTheta, - std::string outputWSTheta) { + void + check_output_values_for_theta_conversion(const std::string &inputWSTheta, + const std::string &outputWSTheta) { MatrixWorkspace_const_sptr input, output; TS_ASSERT_THROWS_NOTHING( input = AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>( @@ -101,8 +102,8 @@ private: const Mantid::Kernel::Exception::IndexError &); } - void clean_up_workspaces(const std::string inputWS, - const std::string outputWS) { + void clean_up_workspaces(const std::string &inputWS, + const std::string &outputWS) { AnalysisDataService::Instance().remove(inputWS); AnalysisDataService::Instance().remove(outputWS); } diff --git a/Framework/Algorithms/test/ConvertSpectrumAxisTest.h b/Framework/Algorithms/test/ConvertSpectrumAxisTest.h index 46c3ebe3539433e909e34d82020fc160d8f0f676..fcab91851b1cd6322fa37ee7400e873442b0c2f6 100644 --- a/Framework/Algorithms/test/ConvertSpectrumAxisTest.h +++ b/Framework/Algorithms/test/ConvertSpectrumAxisTest.h @@ -19,8 +19,8 @@ using namespace Mantid::HistogramData::detail; class ConvertSpectrumAxisTest : public CxxTest::TestSuite { private: - void do_algorithm_run(std::string target, std::string inputWS, - std::string outputWS) { + void do_algorithm_run(const std::string &target, const std::string &inputWS, + const std::string &outputWS) { Mantid::Algorithms::ConvertSpectrumAxis conv; conv.initialize(); diff --git a/Framework/Algorithms/test/ConvertToConstantL2Test.h b/Framework/Algorithms/test/ConvertToConstantL2Test.h index e224874b82f18d43a5cac7c59cc2346da938eacd..4937686131866414685542e4d665e7585869d3f6 100644 --- a/Framework/Algorithms/test/ConvertToConstantL2Test.h +++ b/Framework/Algorithms/test/ConvertToConstantL2Test.h @@ -58,7 +58,7 @@ public: do_test_move(inputWS); } - void do_test_move(MatrixWorkspace_sptr inputWS) { + void do_test_move(const MatrixWorkspace_sptr &inputWS) { // BEFORE - check the L2 values differ const auto &spectrumInfoInput = inputWS->spectrumInfo(); for (size_t i = 0; i < inputWS->getNumberHistograms(); i++) { @@ -169,7 +169,7 @@ private: return inputWS; } - void addSampleLogs(MatrixWorkspace_sptr inputWS) { + void addSampleLogs(const MatrixWorkspace_sptr &inputWS) { inputWS->mutableRun().addProperty( "wavelength", boost::lexical_cast<std::string>(m_wavelength)); diff --git a/Framework/Algorithms/test/ConvertToHistogramTest.h b/Framework/Algorithms/test/ConvertToHistogramTest.h index d6696e74329a7ec92fb1c4cdfd3ec74cd76b4820..a693111185bbc58238bd5aa1e6513a66e560eb30 100644 --- a/Framework/Algorithms/test/ConvertToHistogramTest.h +++ b/Framework/Algorithms/test/ConvertToHistogramTest.h @@ -110,7 +110,7 @@ public: } private: - MatrixWorkspace_sptr runAlgorithm(Workspace2D_sptr inputWS) { + MatrixWorkspace_sptr runAlgorithm(const Workspace2D_sptr &inputWS) { IAlgorithm_sptr alg(new ConvertToHistogram()); alg->initialize(); alg->setRethrows(true); diff --git a/Framework/Algorithms/test/ConvertToPointDataTest.h b/Framework/Algorithms/test/ConvertToPointDataTest.h index 6fe2a97daca71de1b9839624ebf1ed2996ca8726..10b4868b4d2bb28179ec4cdba88aee189d2e83f2 100644 --- a/Framework/Algorithms/test/ConvertToPointDataTest.h +++ b/Framework/Algorithms/test/ConvertToPointDataTest.h @@ -171,7 +171,7 @@ public: } private: - MatrixWorkspace_sptr runAlgorithm(Workspace2D_sptr inputWS) { + MatrixWorkspace_sptr runAlgorithm(const Workspace2D_sptr &inputWS) { IAlgorithm_sptr alg(new ConvertToPointData()); alg->initialize(); alg->setRethrows(true); diff --git a/Framework/Algorithms/test/ConvertUnitsTest.h b/Framework/Algorithms/test/ConvertUnitsTest.h index c8fbf020f81aa98f95131de76be56b91f662f133..ca345e3cb59181f7c47f22c8156c30b648183ecc 100644 --- a/Framework/Algorithms/test/ConvertUnitsTest.h +++ b/Framework/Algorithms/test/ConvertUnitsTest.h @@ -713,7 +713,7 @@ public: * sorting flips the direction */ void do_testExecEvent_RemainsSorted(EventSortType sortType, - std::string targetUnit) { + const std::string &targetUnit) { EventWorkspace_sptr ws = WorkspaceCreationHelper::createEventWorkspaceWithFullInstrument(1, 10, false); diff --git a/Framework/Algorithms/test/CopyDataRangeTest.h b/Framework/Algorithms/test/CopyDataRangeTest.h index b0dbf373b55819704e0977a934c3742cfbc5109d..da41285003b3912b140abe268fcc32dea7a4c98b 100644 --- a/Framework/Algorithms/test/CopyDataRangeTest.h +++ b/Framework/Algorithms/test/CopyDataRangeTest.h @@ -37,8 +37,8 @@ MatrixWorkspace_sptr getADSMatrixWorkspace(std::string const &workspaceName) { workspaceName); } -IAlgorithm_sptr setUpAlgorithm(MatrixWorkspace_sptr inputWorkspace, - MatrixWorkspace_sptr destWorkspace, +IAlgorithm_sptr setUpAlgorithm(const MatrixWorkspace_sptr &inputWorkspace, + const MatrixWorkspace_sptr &destWorkspace, int const &specMin, int const &specMax, double const &xMin, double const &xMax, int const &yInsertionIndex, @@ -68,7 +68,7 @@ IAlgorithm_sptr setUpAlgorithm(std::string const &inputName, xMax, yInsertionIndex, xInsertionIndex, outputName); } -void populateSpectrum(MatrixWorkspace_sptr workspace, +void populateSpectrum(const MatrixWorkspace_sptr &workspace, std::size_t const &spectrum, std::vector<double> const &yData, std::vector<double> const &xData, @@ -78,7 +78,7 @@ void populateSpectrum(MatrixWorkspace_sptr workspace, workspace->mutableE(spectrum) = HistogramE(eData); } -void populateWorkspace(MatrixWorkspace_sptr workspace, +void populateWorkspace(const MatrixWorkspace_sptr &workspace, std::vector<double> const &yData, std::vector<double> const &xData, std::vector<double> const &eData) { @@ -94,7 +94,7 @@ constructHistogramData(Mantid::MantidVec::const_iterator fromIterator, return histogram; } -void populateOutputWorkspace(MatrixWorkspace_sptr workspace, +void populateOutputWorkspace(const MatrixWorkspace_sptr &workspace, std::vector<double> const &yData, std::vector<double> const &eData) { std::vector<double> const xData = {2.1, 2.2, 2.3, 2.4, 2.5, 2.6}; @@ -111,8 +111,8 @@ void populateOutputWorkspace(MatrixWorkspace_sptr workspace, } } -ITableWorkspace_sptr compareWorkspaces(MatrixWorkspace_sptr workspace1, - MatrixWorkspace_sptr workspace2, +ITableWorkspace_sptr compareWorkspaces(const MatrixWorkspace_sptr &workspace1, + const MatrixWorkspace_sptr &workspace2, double tolerance = 0.000001) { auto compareAlg = AlgorithmManager::Instance().create("CompareWorkspaces"); compareAlg->setProperty("Workspace1", workspace1); diff --git a/Framework/Algorithms/test/CopyLogsTest.h b/Framework/Algorithms/test/CopyLogsTest.h index 0f2292f8ea65a4550fa19fc91d9199faae4a561a..c67a5903e17e7c01ee5d680e085aeac88ca9dec7 100644 --- a/Framework/Algorithms/test/CopyLogsTest.h +++ b/Framework/Algorithms/test/CopyLogsTest.h @@ -136,7 +136,7 @@ public: } // Run the Copy Logs algorithm - void runAlg(MatrixWorkspace_sptr in, MatrixWorkspace_sptr out, + void runAlg(const MatrixWorkspace_sptr &in, const MatrixWorkspace_sptr &out, const std::string &mode) { CopyLogs alg; TS_ASSERT_THROWS_NOTHING(alg.initialize()) @@ -149,14 +149,14 @@ public: } // Add a string sample log to the workspace - void addSampleLog(MatrixWorkspace_sptr ws, const std::string &name, + void addSampleLog(const MatrixWorkspace_sptr &ws, const std::string &name, const std::string &value) { Run &run = ws->mutableRun(); run.addLogData(new PropertyWithValue<std::string>(name, value)); } // Add a double sample log to the workspace - void addSampleLog(MatrixWorkspace_sptr ws, const std::string &name, + void addSampleLog(const MatrixWorkspace_sptr &ws, const std::string &name, const double value) { Run &run = ws->mutableRun(); run.addLogData(new PropertyWithValue<double>(name, value)); diff --git a/Framework/Algorithms/test/CorrectTOFAxisTest.h b/Framework/Algorithms/test/CorrectTOFAxisTest.h index 23ccaedf78dd4c952284c8ca0065cc05b66b3322..6f376bda675306b70e982f85493ffcea34da9383 100644 --- a/Framework/Algorithms/test/CorrectTOFAxisTest.h +++ b/Framework/Algorithms/test/CorrectTOFAxisTest.h @@ -323,7 +323,7 @@ public: } private: - static void addSampleLogs(MatrixWorkspace_sptr ws, const double TOF) { + static void addSampleLogs(const MatrixWorkspace_sptr &ws, const double TOF) { const double length = flightLengthIN4(ws); const double Ei = incidentEnergy(TOF, length); ws->mutableRun().addProperty("EI", Ei); @@ -331,8 +331,8 @@ private: ws->mutableRun().addProperty("wavelength", lambda); } - static void assertTOFShift(MatrixWorkspace_sptr shiftedWs, - MatrixWorkspace_sptr ws, const double ei, + static void assertTOFShift(const MatrixWorkspace_sptr &shiftedWs, + const MatrixWorkspace_sptr &ws, const double ei, const double wavelength, const double shift) { TS_ASSERT(shiftedWs); TS_ASSERT_EQUALS(shiftedWs->run().getPropertyAsSingleValue("EI"), ei); @@ -412,7 +412,7 @@ private: } } - static double flightLengthIN4(MatrixWorkspace_const_sptr ws) { + static double flightLengthIN4(const MatrixWorkspace_const_sptr &ws) { const double l1 = ws->spectrumInfo().l1(); const double l2 = ws->spectrumInfo().l2(1); return l1 + l2; diff --git a/Framework/Algorithms/test/CorrectToFileTest.h b/Framework/Algorithms/test/CorrectToFileTest.h index 6d052370c9b4029d540de06090e9fa4f4f4e2de4..532a0c8fdeb8f7948ed9db9e65e1a4899d01174e 100644 --- a/Framework/Algorithms/test/CorrectToFileTest.h +++ b/Framework/Algorithms/test/CorrectToFileTest.h @@ -142,7 +142,7 @@ public: AnalysisDataService::Instance().remove(data->getName()); } - MatrixWorkspace_sptr executeAlgorithm(MatrixWorkspace_sptr testInput, + MatrixWorkspace_sptr executeAlgorithm(const MatrixWorkspace_sptr &testInput, const std::string &unit, const std::string &operation, bool newWksp = true) { diff --git a/Framework/Algorithms/test/CreateEPPTest.h b/Framework/Algorithms/test/CreateEPPTest.h index 7938d581ad0cc1b15571b2a6c43796b0d217ceb8..2ed9d6e0c6da0fd7052f1a377b71532b324d381f 100644 --- a/Framework/Algorithms/test/CreateEPPTest.h +++ b/Framework/Algorithms/test/CreateEPPTest.h @@ -177,7 +177,7 @@ private: return false; } for (const auto &columnName : columnNames) { - if (std::find(names.cbegin(), names.cend(), columnName) == names.end()) { + if (std::find(names.cbegin(), names.cend(), columnName) == names.cend()) { return false; } } diff --git a/Framework/Algorithms/test/CreateGroupingWorkspaceTest.h b/Framework/Algorithms/test/CreateGroupingWorkspaceTest.h index 0dc96dc50c0922f2845b12e4aa7b1829dea98d73..79cd24af8cb0243ba5620f5d8da59a1ce06b1c4d 100644 --- a/Framework/Algorithms/test/CreateGroupingWorkspaceTest.h +++ b/Framework/Algorithms/test/CreateGroupingWorkspaceTest.h @@ -25,7 +25,7 @@ public: TS_ASSERT(alg.isInitialized()) } - void doTest(std::string outWSName) { + void doTest(const std::string &outWSName) { // Retrieve the workspace from data service. GroupingWorkspace_sptr ws; TS_ASSERT_THROWS_NOTHING( diff --git a/Framework/Algorithms/test/CreateLogPropertyTableTest.h b/Framework/Algorithms/test/CreateLogPropertyTableTest.h index 269b7bea7fd313442ded0a408620dfb70bf2d1c8..5f3639ce2f1e41e8fc02c09235e21865c7f3633c 100644 --- a/Framework/Algorithms/test/CreateLogPropertyTableTest.h +++ b/Framework/Algorithms/test/CreateLogPropertyTableTest.h @@ -110,7 +110,7 @@ public: private: void createSampleWorkspace( - std::string wsName = "__CreateLogPropertyTable__TestWorkspace", + const std::string &wsName = "__CreateLogPropertyTable__TestWorkspace", int runNumber = 12345, int64_t runStart = 3000000000) { using namespace WorkspaceCreationHelper; diff --git a/Framework/Algorithms/test/CreateSampleWorkspaceTest.h b/Framework/Algorithms/test/CreateSampleWorkspaceTest.h index 73fcede99c031b32a7a12ab8bebf97eee20c5841..3e0e5f37ba44b75122a2e3fe6972f9a8faafd78a 100644 --- a/Framework/Algorithms/test/CreateSampleWorkspaceTest.h +++ b/Framework/Algorithms/test/CreateSampleWorkspaceTest.h @@ -46,9 +46,10 @@ public: } MatrixWorkspace_sptr createSampleWorkspace( - std::string outWSName, std::string wsType = "", std::string function = "", - std::string userFunction = "", int numBanks = 2, int bankPixelWidth = 10, - int numEvents = 1000, bool isRandom = false, std::string xUnit = "TOF", + const std::string &outWSName, const std::string &wsType = "", + const std::string &function = "", const std::string &userFunction = "", + int numBanks = 2, int bankPixelWidth = 10, int numEvents = 1000, + bool isRandom = false, const std::string &xUnit = "TOF", double xMin = 0.0, double xMax = 20000.0, double binWidth = 200.0, int numScanPoints = 1) { diff --git a/Framework/Algorithms/test/CreateTransmissionWorkspace2Test.h b/Framework/Algorithms/test/CreateTransmissionWorkspace2Test.h index bde02a3160fca645785343c636d6bd255a0778b5..cda64d11d6f629869c034d9c72c01daea3ed837c 100644 --- a/Framework/Algorithms/test/CreateTransmissionWorkspace2Test.h +++ b/Framework/Algorithms/test/CreateTransmissionWorkspace2Test.h @@ -617,7 +617,7 @@ private: } } - void check_lambda_workspace(MatrixWorkspace_sptr ws) { + void check_lambda_workspace(const MatrixWorkspace_sptr &ws) { TS_ASSERT(ws); if (!ws) return; diff --git a/Framework/Algorithms/test/CreateUserDefinedBackgroundTest.h b/Framework/Algorithms/test/CreateUserDefinedBackgroundTest.h index e5f4c4b2f2f4d5a943197fb23b43e3b5df04a162..aa502c2dd8662e258191ce336b324b4b0431ade5 100644 --- a/Framework/Algorithms/test/CreateUserDefinedBackgroundTest.h +++ b/Framework/Algorithms/test/CreateUserDefinedBackgroundTest.h @@ -330,8 +330,8 @@ private: } /// Compare workspaces - bool workspacesEqual(const MatrixWorkspace_sptr lhs, - const MatrixWorkspace_sptr rhs, double tolerance, + bool workspacesEqual(const MatrixWorkspace_sptr &lhs, + const MatrixWorkspace_sptr &rhs, double tolerance, bool relativeError = false) { auto alg = Mantid::API::AlgorithmFactory::Instance().create( "CompareWorkspaces", 1); diff --git a/Framework/Algorithms/test/CropToComponentTest.h b/Framework/Algorithms/test/CropToComponentTest.h index 731380ea725ef564bb736526fe0e0a44cbf01045..1a6ae411b1fc2d86ae8ba2e44cf96141d234ff0e 100644 --- a/Framework/Algorithms/test/CropToComponentTest.h +++ b/Framework/Algorithms/test/CropToComponentTest.h @@ -242,7 +242,7 @@ private: numberOfBanks, numbersOfPixelPerBank, 2); } - void doAsssert(Mantid::API::MatrixWorkspace_sptr workspace, + void doAsssert(const Mantid::API::MatrixWorkspace_sptr &workspace, std::vector<Mantid::detid_t> &expectedIDs, size_t expectedNumberOfHistograms) { // Assert diff --git a/Framework/Algorithms/test/CropWorkspaceTest.h b/Framework/Algorithms/test/CropWorkspaceTest.h index 3fa04b6059029bbfa72a96f7ccd70d97fa1f0e1c..f5ab1f14d02305118681d59f17f93d4507e97503 100644 --- a/Framework/Algorithms/test/CropWorkspaceTest.h +++ b/Framework/Algorithms/test/CropWorkspaceTest.h @@ -103,7 +103,7 @@ public: TS_ASSERT(!crop.isExecuted()); } - void makeFakeEventWorkspace(std::string wsName) { + void makeFakeEventWorkspace(const std::string &wsName) { // Make an event workspace with 2 events in each bin. EventWorkspace_sptr test_in = WorkspaceCreationHelper::createEventWorkspace(36, 50, 50, 0.0, 2., 2); diff --git a/Framework/Algorithms/test/CrossCorrelateTest.h b/Framework/Algorithms/test/CrossCorrelateTest.h index 4904a2f1f60319aa6d7f590d7d635b6c40eb91c3..8b60401adffd881de42f2f09cbe373a713cef12e 100644 --- a/Framework/Algorithms/test/CrossCorrelateTest.h +++ b/Framework/Algorithms/test/CrossCorrelateTest.h @@ -161,7 +161,7 @@ private: // Run the algorithm and do some basic checks. Returns the output workspace. MatrixWorkspace_const_sptr - runAlgorithm(CrossCorrelate &alg, const MatrixWorkspace_const_sptr inWS) { + runAlgorithm(CrossCorrelate &alg, const MatrixWorkspace_const_sptr &inWS) { // run the algorithm TS_ASSERT_THROWS_NOTHING(alg.execute()); TS_ASSERT(alg.isExecuted()); diff --git a/Framework/Algorithms/test/CylinderAbsorptionTest.h b/Framework/Algorithms/test/CylinderAbsorptionTest.h index 0950fb2082923018c5a55e466e429fb2118b6d83..ec2b9109b2c57695a387a7f0c534b0054f3b596d 100644 --- a/Framework/Algorithms/test/CylinderAbsorptionTest.h +++ b/Framework/Algorithms/test/CylinderAbsorptionTest.h @@ -305,9 +305,9 @@ private: void configureAbsCommon(Mantid::Algorithms::CylinderAbsorption &alg, MatrixWorkspace_sptr &inputWS, const std::string &outputWSname, - std::string numberOfSlices = "2", - std::string numberOfAnnuli = "2", - std::string cylinderAxis = "0,1,0") { + const std::string &numberOfSlices = "2", + const std::string &numberOfAnnuli = "2", + const std::string &cylinderAxis = "0,1,0") { if (!alg.isInitialized()) alg.initialize(); diff --git a/Framework/Algorithms/test/DeleteWorkspacesTest.h b/Framework/Algorithms/test/DeleteWorkspacesTest.h index 70fc055b60afd4dc8962e9b449d5e9686cac1d12..99d0d42a5931169cb5a6e27fe9246e2713313696 100644 --- a/Framework/Algorithms/test/DeleteWorkspacesTest.h +++ b/Framework/Algorithms/test/DeleteWorkspacesTest.h @@ -118,7 +118,7 @@ public: TS_ASSERT_EQUALS(dataStore.size(), storeSizeAtStart); } - void createAndStoreWorkspace(std::string name, int ylength = 10) { + void createAndStoreWorkspace(const std::string &name, int ylength = 10) { using namespace Mantid::API; using namespace Mantid::DataObjects; diff --git a/Framework/Algorithms/test/DetectorEfficiencyCorTest.h b/Framework/Algorithms/test/DetectorEfficiencyCorTest.h index 4c851cdcf73b865dc4e5040cfb8d6d1820f3b7a5..9bf3cae230d0ba3431ad16f87655a3bb3e5d2150 100644 --- a/Framework/Algorithms/test/DetectorEfficiencyCorTest.h +++ b/Framework/Algorithms/test/DetectorEfficiencyCorTest.h @@ -41,7 +41,6 @@ public: WorkspaceCreationHelper::create2DWorkspaceWithFullInstrument(2, 1); dummyWS->getAxis(0)->unit() = Mantid::Kernel::UnitFactory::Instance().create("DeltaE"); - const std::string inputWS = "testInput"; Mantid::Algorithms::DetectorEfficiencyCor corrector; TS_ASSERT_THROWS_NOTHING(corrector.initialize()); diff --git a/Framework/Algorithms/test/EditInstrumentGeometryTest.h b/Framework/Algorithms/test/EditInstrumentGeometryTest.h index 0ec972211148c925a94ff9e235af63b3532334c9..25b3d79ee97257da2ed47da555a25ea43221442f 100644 --- a/Framework/Algorithms/test/EditInstrumentGeometryTest.h +++ b/Framework/Algorithms/test/EditInstrumentGeometryTest.h @@ -158,7 +158,7 @@ public: //---------------------------------------------------------------------------------------------- /** Check detector parameter */ - void checkDetectorParameters(API::MatrixWorkspace_sptr workspace, + void checkDetectorParameters(const API::MatrixWorkspace_sptr &workspace, size_t wsindex, double realr, double realtth, double realphi) { @@ -175,8 +175,8 @@ public: //---------------------------------------------------------------------------------------------- /** Check detector parameter */ - void checkDetectorID(API::MatrixWorkspace_sptr workspace, size_t wsindex, - detid_t detid) { + void checkDetectorID(const API::MatrixWorkspace_sptr &workspace, + size_t wsindex, detid_t detid) { const auto &spectrumInfo = workspace->spectrumInfo(); TS_ASSERT_EQUALS(spectrumInfo.hasUniqueDetector(wsindex), true); diff --git a/Framework/Algorithms/test/ElasticWindowTest.h b/Framework/Algorithms/test/ElasticWindowTest.h index e00979fc42d7861c6d92134c08d8502ad1aaf27a..65328ac0a40b6cb25a8b9e1d9a197392bb4ce04b 100644 --- a/Framework/Algorithms/test/ElasticWindowTest.h +++ b/Framework/Algorithms/test/ElasticWindowTest.h @@ -201,7 +201,7 @@ private: * * @param ws Workspace to test */ - void verifyQworkspace(MatrixWorkspace_sptr ws) { + void verifyQworkspace(const MatrixWorkspace_sptr &ws) { std::string unitID = ws->getAxis(0)->unit()->unitID(); TS_ASSERT_EQUALS(unitID, "MomentumTransfer"); } @@ -211,7 +211,7 @@ private: * * @param ws Workspace to test */ - void verifyQ2workspace(MatrixWorkspace_sptr ws) { + void verifyQ2workspace(const MatrixWorkspace_sptr &ws) { std::string unitID = ws->getAxis(0)->unit()->unitID(); TS_ASSERT_EQUALS(unitID, "QSquared"); } diff --git a/Framework/Algorithms/test/ExponentialTest.h b/Framework/Algorithms/test/ExponentialTest.h index 9a682293ff8893c691aa691d11eccd5acc36e48b..28eec221b8561c92bbecb9741f7882f4e5cbb823 100644 --- a/Framework/Algorithms/test/ExponentialTest.h +++ b/Framework/Algorithms/test/ExponentialTest.h @@ -98,8 +98,8 @@ public: private: // loopOrientation 0=Horizontal, 1=Vertical - void checkData(MatrixWorkspace_sptr work_in1, - MatrixWorkspace_sptr work_out1) { + void checkData(const MatrixWorkspace_sptr &work_in1, + const MatrixWorkspace_sptr &work_out1) { for (size_t i = 0; i < work_out1->size(); i++) { double sig1 = @@ -123,7 +123,7 @@ private: } } // loopOrientation 0=Horizontal, 1=Vertical - void setError(MatrixWorkspace_sptr work_in1) { + void setError(const MatrixWorkspace_sptr &work_in1) { for (size_t i = 0; i < work_in1->size(); i++) { double sig1 = diff --git a/Framework/Algorithms/test/ExtractMaskTest.h b/Framework/Algorithms/test/ExtractMaskTest.h index 638cd418e87d327e90e73938d44d6c21bb532821..33bf6460081c9f3b2e38e6fa144954add847f140 100644 --- a/Framework/Algorithms/test/ExtractMaskTest.h +++ b/Framework/Algorithms/test/ExtractMaskTest.h @@ -163,8 +163,8 @@ private: return detectorList; } - void doTest(MatrixWorkspace_const_sptr inputWS, - MaskWorkspace_const_sptr outputWS) { + void doTest(const MatrixWorkspace_const_sptr &inputWS, + const MaskWorkspace_const_sptr &outputWS) { TS_ASSERT_EQUALS(outputWS->blocksize(), 1); size_t nOutputHists(outputWS->getNumberHistograms()); TS_ASSERT_EQUALS(nOutputHists, inputWS->getNumberHistograms()); diff --git a/Framework/Algorithms/test/ExtractSingleSpectrumTest.h b/Framework/Algorithms/test/ExtractSingleSpectrumTest.h index 70c11883dcc5d1bd529baf941cb5a76839945b85..467ff4a4f5952ec7afc7dfbd460ce60be7217241 100644 --- a/Framework/Algorithms/test/ExtractSingleSpectrumTest.h +++ b/Framework/Algorithms/test/ExtractSingleSpectrumTest.h @@ -88,7 +88,7 @@ public: } private: - MatrixWorkspace_sptr runAlgorithm(MatrixWorkspace_sptr inputWS, + MatrixWorkspace_sptr runAlgorithm(const MatrixWorkspace_sptr &inputWS, const int index) { ExtractSingleSpectrum extractor; extractor.initialize(); @@ -106,8 +106,8 @@ private: return extractor.getProperty("OutputWorkspace"); } - void do_Spectrum_Tests(MatrixWorkspace_sptr outputWS, const specnum_t specID, - const detid_t detID) { + void do_Spectrum_Tests(const MatrixWorkspace_sptr &outputWS, + const specnum_t specID, const detid_t detID) { TS_ASSERT_EQUALS(outputWS->getNumberHistograms(), 1); TS_ASSERT_THROWS_NOTHING(outputWS->getSpectrum(0)); const auto &spectrum = outputWS->getSpectrum(0); diff --git a/Framework/Algorithms/test/ExtractSpectraTest.h b/Framework/Algorithms/test/ExtractSpectraTest.h index daf981ab6c9860e5505fc25857797e4a74e73775..25c661dcaea660bd067781f9f0dfbbe62e892cb0 100644 --- a/Framework/Algorithms/test/ExtractSpectraTest.h +++ b/Framework/Algorithms/test/ExtractSpectraTest.h @@ -544,7 +544,7 @@ private: } MatrixWorkspace_sptr - createInputWithDetectors(std::string workspaceType) const { + createInputWithDetectors(const std::string &workspaceType) const { MatrixWorkspace_sptr ws; // Set the type of underlying workspace diff --git a/Framework/Algorithms/test/ExtractUnmaskedSpectraTest.h b/Framework/Algorithms/test/ExtractUnmaskedSpectraTest.h index 74486994886c34ee3446c2ea31ded0f57a72d1e1..769c8d1fef74d18c71e0a4720a9e3ff48f49ff0a 100644 --- a/Framework/Algorithms/test/ExtractUnmaskedSpectraTest.h +++ b/Framework/Algorithms/test/ExtractUnmaskedSpectraTest.h @@ -133,7 +133,7 @@ private: } Mantid::API::MatrixWorkspace_sptr - createMask(Mantid::API::MatrixWorkspace_sptr inputWS) { + createMask(const Mantid::API::MatrixWorkspace_sptr &inputWS) { auto maskWS = Mantid::DataObjects::MaskWorkspace_sptr( new Mantid::DataObjects::MaskWorkspace(inputWS)); size_t n = inputWS->getNumberHistograms(); @@ -146,8 +146,8 @@ private: } Mantid::API::MatrixWorkspace_sptr - runAlgorithm(Mantid::API::MatrixWorkspace_sptr inputWS, - Mantid::API::MatrixWorkspace_sptr maskedWS = + runAlgorithm(const Mantid::API::MatrixWorkspace_sptr &inputWS, + const Mantid::API::MatrixWorkspace_sptr &maskedWS = Mantid::API::MatrixWorkspace_sptr()) { ExtractUnmaskedSpectra alg; alg.setChild(true); diff --git a/Framework/Algorithms/test/FFTSmooth2Test.h b/Framework/Algorithms/test/FFTSmooth2Test.h index 8f3ad38eead8f38cc21bc03134472c3b3628b30a..ffae4ce2e45f2d8b32393fe359b2adb78fffa89e 100644 --- a/Framework/Algorithms/test/FFTSmooth2Test.h +++ b/Framework/Algorithms/test/FFTSmooth2Test.h @@ -169,8 +169,9 @@ public: } //------------------------------------------------------------------------------------------------- - void performTest(bool event, std::string filter, std::string params, - bool AllSpectra, int WorkspaceIndex, bool inPlace = false) { + void performTest(bool event, const std::string &filter, + const std::string ¶ms, bool AllSpectra, + int WorkspaceIndex, bool inPlace = false) { MatrixWorkspace_sptr ws1, out; int numPixels = 10; int numBins = 20; @@ -276,9 +277,11 @@ public: } if (!AllSpectra) { + bool allSpectraGtZero = false; + for (int WorkspaceIndex = 0; WorkspaceIndex < 10; WorkspaceIndex++) { - performTest((event > 0), filter, params, (AllSpectra > 0), + performTest((event > 0), filter, params, allSpectraGtZero, WorkspaceIndex, (inPlace > 0)); } } else { diff --git a/Framework/Algorithms/test/FFTTest.h b/Framework/Algorithms/test/FFTTest.h index a439134be667a11608f1b5a5012cf404b690708e..904716b6be11c5c0dbe7fe5c09f5e9b75ca2a8f6 100644 --- a/Framework/Algorithms/test/FFTTest.h +++ b/Framework/Algorithms/test/FFTTest.h @@ -717,7 +717,7 @@ public: } private: - MatrixWorkspace_sptr doRebin(MatrixWorkspace_sptr inputWS, + MatrixWorkspace_sptr doRebin(const MatrixWorkspace_sptr &inputWS, const std::string ¶ms) { auto rebin = FrameworkManager::Instance().createAlgorithm("Rebin"); rebin->initialize(); @@ -729,8 +729,8 @@ private: return rebin->getProperty("OutputWorkspace"); } - MatrixWorkspace_sptr doFFT(MatrixWorkspace_sptr inputWS, const bool complex, - const bool phaseShift) { + MatrixWorkspace_sptr doFFT(const MatrixWorkspace_sptr &inputWS, + const bool complex, const bool phaseShift) { auto fft = FrameworkManager::Instance().createAlgorithm("FFT"); fft->initialize(); fft->setChild(true); @@ -747,7 +747,7 @@ private: return fft->getProperty("OutputWorkspace"); } - void doPhaseTest(MatrixWorkspace_sptr inputWS, bool complex) { + void doPhaseTest(const MatrixWorkspace_sptr &inputWS, bool complex) { // Offset the input workspace const auto offsetWS = offsetWorkspace(inputWS); @@ -803,7 +803,7 @@ private: return ws; } - MatrixWorkspace_sptr offsetWorkspace(MatrixWorkspace_sptr workspace) { + MatrixWorkspace_sptr offsetWorkspace(const MatrixWorkspace_sptr &workspace) { auto scaleX = FrameworkManager::Instance().createAlgorithm("ScaleX"); scaleX->initialize(); scaleX->setChild(true); @@ -936,7 +936,7 @@ private: return create->getProperty("OutputWorkspace"); } - MatrixWorkspace_sptr doCrop(MatrixWorkspace_sptr inputWS, double lower, + MatrixWorkspace_sptr doCrop(const MatrixWorkspace_sptr &inputWS, double lower, double higher) { auto crop = FrameworkManager::Instance().createAlgorithm("CropWorkspace"); crop->initialize(); diff --git a/Framework/Algorithms/test/FilterByLogValueTest.h b/Framework/Algorithms/test/FilterByLogValueTest.h index 19b20c56e69f2652dfaa8cd9a968737a4de97dc8..25b241d1021ec87d7bdea75383c9eb30de7dbafd 100644 --- a/Framework/Algorithms/test/FilterByLogValueTest.h +++ b/Framework/Algorithms/test/FilterByLogValueTest.h @@ -174,7 +174,7 @@ public: * @param do_in_place * @param PulseFilter :: PulseFilter parameter */ - void do_test_fake(std::string log_name, double min, double max, + void do_test_fake(const std::string &log_name, double min, double max, int seconds_kept, bool add_proton_charge = true, bool do_in_place = false, bool PulseFilter = false) { EventWorkspace_sptr ew = createInputWS(add_proton_charge); diff --git a/Framework/Algorithms/test/FilterEventsTest.h b/Framework/Algorithms/test/FilterEventsTest.h index 62120ef732583da28d48689c166db0fad142f620..b657f88b3d53ff936be937a54499a7fd232a71d4 100644 --- a/Framework/Algorithms/test/FilterEventsTest.h +++ b/Framework/Algorithms/test/FilterEventsTest.h @@ -1753,7 +1753,8 @@ public: //---------------------------------------------------------------------------------------------- /** Create the time correction table */ - TableWorkspace_sptr createTimeCorrectionTable(MatrixWorkspace_sptr inpws) { + TableWorkspace_sptr + createTimeCorrectionTable(const MatrixWorkspace_sptr &inpws) { // 1. Generate an empty table auto corrtable = boost::make_shared<TableWorkspace>(); corrtable->addColumn("int", "DetectorID"); diff --git a/Framework/Algorithms/test/FindCenterOfMassPosition2Test.h b/Framework/Algorithms/test/FindCenterOfMassPosition2Test.h index 31e925bc196f2003ad4eb837e77b7098413b16e6..b914e7e6c0ff804c0fd79d320df11ec938498118 100644 --- a/Framework/Algorithms/test/FindCenterOfMassPosition2Test.h +++ b/Framework/Algorithms/test/FindCenterOfMassPosition2Test.h @@ -58,7 +58,7 @@ public: // Set tube extrema to special values if (iy == 0 || iy == SANSInstrumentCreationHelper::nBins - 1) Y[0] = - iy % 2 ? std::nan("") : std::numeric_limits<double>::infinity(); + (iy % 2) ? std::nan("") : std::numeric_limits<double>::infinity(); E[0] = 1; } } diff --git a/Framework/Algorithms/test/FindEPPTest.h b/Framework/Algorithms/test/FindEPPTest.h index 3f9ef8197a23a46a67fa892fbdd385c2ae5fdae1..a84315c99f436a8c8650e61e64b3ee1b58265c3f 100644 --- a/Framework/Algorithms/test/FindEPPTest.h +++ b/Framework/Algorithms/test/FindEPPTest.h @@ -223,7 +223,7 @@ public: } private: - void _check_table(ITableWorkspace_sptr ws, size_t nSpectra) { + void _check_table(const ITableWorkspace_sptr &ws, size_t nSpectra) { TS_ASSERT_EQUALS(ws->rowCount(), nSpectra); TS_ASSERT_EQUALS(ws->columnCount(), 9); TS_ASSERT_EQUALS(ws->getColumnNames(), m_columnNames); diff --git a/Framework/Algorithms/test/FindPeaksTest.h b/Framework/Algorithms/test/FindPeaksTest.h index 104ea75cf06eb28e2dbee683837e64cbb4d78266..eef5f327f104d5963b1e018ecfaf27eaf46aca58 100644 --- a/Framework/Algorithms/test/FindPeaksTest.h +++ b/Framework/Algorithms/test/FindPeaksTest.h @@ -190,7 +190,7 @@ public: /** Parse a row in output parameter tableworkspace to a string/double * parameter name/value map */ - void getParameterMap(TableWorkspace_sptr tablews, size_t rowindex, + void getParameterMap(const TableWorkspace_sptr &tablews, size_t rowindex, map<string, double> ¶mmap) { parammap.clear(); diff --git a/Framework/Algorithms/test/FitPeakTest.h b/Framework/Algorithms/test/FitPeakTest.h index fda649e543a5e51936542ab6f4f092f6e42fd402..836e206fadd5cbd3fe826b594b598366076e08d3 100644 --- a/Framework/Algorithms/test/FitPeakTest.h +++ b/Framework/Algorithms/test/FitPeakTest.h @@ -358,8 +358,6 @@ public: /** Generate a workspace contains PG3_4866 5-th peak */ MatrixWorkspace_sptr gen_PG3DiamondData() { - vector<double> vecx, vecy, vece; - size_t NVectors = 1; size_t size = 53; MatrixWorkspace_sptr ws = boost::dynamic_pointer_cast<MatrixWorkspace>( diff --git a/Framework/Algorithms/test/FitPeaksTest.h b/Framework/Algorithms/test/FitPeaksTest.h index 2af2633483f38bd7589b3070747a55ffb8976901..f4849daa7e74041dc0f17b229c559538138714aa 100644 --- a/Framework/Algorithms/test/FitPeaksTest.h +++ b/Framework/Algorithms/test/FitPeaksTest.h @@ -411,7 +411,6 @@ public: // std::string input_ws_name = loadVulcanHighAngleData(); // Generate peak and background parameters - std::vector<string> peakparnames{"Mixing"}; std::vector<double> peakparvalues{0.5}; // Initialize FitPeak diff --git a/Framework/Algorithms/test/FixGSASInstrumentFileTest.h b/Framework/Algorithms/test/FixGSASInstrumentFileTest.h index 7ff6c56f089602cdbe2cd1905fc074605885e54e..7d5a650d5d2f4e34eb5b4b195c538fba408f2685 100644 --- a/Framework/Algorithms/test/FixGSASInstrumentFileTest.h +++ b/Framework/Algorithms/test/FixGSASInstrumentFileTest.h @@ -67,7 +67,7 @@ public: file.remove(); } - void createFaultFile(std::string prmfilename) { + void createFaultFile(const std::string &prmfilename) { ofstream ofile; ofile.open(prmfilename.c_str(), ios::out); ofile << " " diff --git a/Framework/Algorithms/test/GenerateEventsFilterTest.h b/Framework/Algorithms/test/GenerateEventsFilterTest.h index bd5c7d8a22c74e9ad4c7342da233926ce52387da..8c6cdc750d876bed66921e027a01c3dd8e2e1e50 100644 --- a/Framework/Algorithms/test/GenerateEventsFilterTest.h +++ b/Framework/Algorithms/test/GenerateEventsFilterTest.h @@ -1145,7 +1145,7 @@ public: * SplittingInterval objects */ size_t convertMatrixSplitterToSplitters( - API::MatrixWorkspace_const_sptr matrixws, + const API::MatrixWorkspace_const_sptr &matrixws, std::vector<Kernel::SplittingInterval> &splitters) { splitters.clear(); size_t numsplitters = 0; diff --git a/Framework/Algorithms/test/GetAllEiTest.h b/Framework/Algorithms/test/GetAllEiTest.h index d431d7d9245ebb843d3f6556dd61b018751cd18c..108f38febb734e6a6d62a0c567d79f0f7c1b6506 100644 --- a/Framework/Algorithms/test/GetAllEiTest.h +++ b/Framework/Algorithms/test/GetAllEiTest.h @@ -503,7 +503,7 @@ public: TS_ASSERT_DELTA(zeros[2], 7.85, 1.e-3); } void test_binRanges() { - std::vector<size_t> bin_min, bin_max, zeros; + std::vector<size_t> bin_min, bin_max; // Index 0 1 2 3 4 5 6 7 8 9 10 11 12 13 double debin[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 15}; std::vector<double> ebin(debin, debin + sizeof(debin) / sizeof(double)); diff --git a/Framework/Algorithms/test/GetDetOffsetsMultiPeaksTest.h b/Framework/Algorithms/test/GetDetOffsetsMultiPeaksTest.h index 6adbaedc2a78560469809db114c046e1902173e8..97c55f0ee4135394c0f9808dc7689e8c789d5dfc 100644 --- a/Framework/Algorithms/test/GetDetOffsetsMultiPeaksTest.h +++ b/Framework/Algorithms/test/GetDetOffsetsMultiPeaksTest.h @@ -430,7 +430,7 @@ public: //---------------------------------------------------------------------------------------------- /** Generate noisy data in a workspace */ - void generateNoisyData(MatrixWorkspace_sptr WS) { + void generateNoisyData(const MatrixWorkspace_sptr &WS) { auto &Y = WS->mutableY(0); Y.assign(Y.size(), static_cast<double>(rand() % 5)); diff --git a/Framework/Algorithms/test/GetEiMonDet3Test.h b/Framework/Algorithms/test/GetEiMonDet3Test.h index c5cf0ac1f5cb090ca8c5f0d351d15987ffb1b430..111ea70a6a4ae3f542210aca8e1260339f611469 100644 --- a/Framework/Algorithms/test/GetEiMonDet3Test.h +++ b/Framework/Algorithms/test/GetEiMonDet3Test.h @@ -8,6 +8,8 @@ #include <cxxtest/TestSuite.h> +#include <utility> + #include "MantidAPI/Axis.h" #include "MantidAPI/FrameworkManager.h" #include "MantidAlgorithms/ExtractSpectra2.h" @@ -157,7 +159,7 @@ public: } private: - static void attachInstrument(MatrixWorkspace_sptr targetWs) { + static void attachInstrument(const MatrixWorkspace_sptr &targetWs) { // The reference frame used by createInstrumentForWorkspaceWithDistances // is left handed with y pointing up, x along beam. @@ -170,8 +172,8 @@ private: detectorRs.emplace_back(-MONITOR_DISTANCE, 0., 0.); // Add more detectors --- these should be treated as the real ones. detectorRs.emplace_back(0., 0., DETECTOR_DISTANCE); - createInstrumentForWorkspaceWithDistances(targetWs, sampleR, sourceR, - detectorRs); + createInstrumentForWorkspaceWithDistances(std::move(targetWs), sampleR, + sourceR, detectorRs); } static MatrixWorkspace_sptr @@ -215,7 +217,8 @@ private: } // Mininum setup for GetEiMonDet3. - static void setupSimple(MatrixWorkspace_sptr ws, GetEiMonDet3 &algorithm) { + static void setupSimple(const MatrixWorkspace_sptr &ws, + GetEiMonDet3 &algorithm) { algorithm.setRethrows(true); TS_ASSERT_THROWS_NOTHING(algorithm.initialize()) TS_ASSERT(algorithm.isInitialized()) diff --git a/Framework/Algorithms/test/He3TubeEfficiencyTest.h b/Framework/Algorithms/test/He3TubeEfficiencyTest.h index 8488bb39b1e99a50be2c7b2735044cf54427e3b3..6db24d8af3fc433346fc81a4095b1ec9cd903c1a 100644 --- a/Framework/Algorithms/test/He3TubeEfficiencyTest.h +++ b/Framework/Algorithms/test/He3TubeEfficiencyTest.h @@ -30,7 +30,7 @@ using Mantid::HistogramData::Counts; using Mantid::HistogramData::CountStandardDeviations; namespace He3TubeEffeciencyHelper { -void createWorkspace2DInADS(const std::string inputWS) { +void createWorkspace2DInADS(const std::string &inputWS) { const int nspecs(4); const int nbins(5); @@ -58,7 +58,7 @@ void createWorkspace2DInADS(const std::string inputWS) { loader.execute(); } -void createEventWorkspaceInADS(const std::string inputEvWS) { +void createEventWorkspaceInADS(const std::string &inputEvWS) { EventWorkspace_sptr event = WorkspaceCreationHelper::createEventWorkspace(4, 5, 5, 0, 0.9, 3, 0); event->getAxis(0)->unit() = UnitFactory::Instance().create("Wavelength"); diff --git a/Framework/Algorithms/test/IndirectFitDataCreationHelperTest.h b/Framework/Algorithms/test/IndirectFitDataCreationHelperTest.h index a3037f1d0cecc51eecb35969c0df925a0bfb4d08..d4fc9f315599719e67e44dbdb1c9c3f21eb6eb22 100644 --- a/Framework/Algorithms/test/IndirectFitDataCreationHelperTest.h +++ b/Framework/Algorithms/test/IndirectFitDataCreationHelperTest.h @@ -24,7 +24,7 @@ std::vector<std::string> getTextAxisLabels() { std::vector<double> getNumericAxisLabels() { return {2.2, 3.3, 4.4}; } void storeWorkspaceInADS(std::string const &workspaceName, - MatrixWorkspace_sptr workspace) { + const MatrixWorkspace_sptr &workspace) { SetUpADSWithWorkspace ads(workspaceName, workspace); } diff --git a/Framework/Algorithms/test/IntegrateByComponentTest.h b/Framework/Algorithms/test/IntegrateByComponentTest.h index 83f579d6e567645a282d253832e80631b6405c0b..efb8aa33fce4686639b6525cee86823dcecce109 100644 --- a/Framework/Algorithms/test/IntegrateByComponentTest.h +++ b/Framework/Algorithms/test/IntegrateByComponentTest.h @@ -240,7 +240,7 @@ public: } private: - void ABCtestWorkspace(std::string inputWSname, bool mask) { + void ABCtestWorkspace(const std::string &inputWSname, bool mask) { int nSpectra(12); Workspace2D_sptr ws2D = WorkspaceCreationHelper::create2DWorkspaceWhereYIsWorkspaceIndex( diff --git a/Framework/Algorithms/test/IntegrationTest.h b/Framework/Algorithms/test/IntegrationTest.h index 9fa007b15c79c6de1e00059657d1091bae155cad..e99316d0e09a15906a1f0558b9652a4745136661 100644 --- a/Framework/Algorithms/test/IntegrationTest.h +++ b/Framework/Algorithms/test/IntegrationTest.h @@ -166,7 +166,7 @@ public: assertRangeWithPartialBins(input); } - void doTestEvent(std::string inName, std::string outName, + void doTestEvent(const std::string &inName, const std::string &outName, int StartWorkspaceIndex, int EndWorkspaceIndex) { int numPixels = 100; int numBins = 50; @@ -229,8 +229,8 @@ public: doTestEvent("inWS", "inWS", 10, 29); } - void doTestRebinned(const std::string RangeLower, - const std::string RangeUpper, + void doTestRebinned(const std::string &RangeLower, + const std::string &RangeUpper, const int StartWorkspaceIndex, const int EndWorkspaceIndex, const bool IncludePartialBins, const int expectedNumHists, @@ -290,7 +290,7 @@ public: doTestRebinned("-1.5", "1.75", 0, 3, true, 4, truth); } - void makeRealBinBoundariesWorkspace(const std::string inWsName) { + void makeRealBinBoundariesWorkspace(const std::string &inWsName) { const unsigned int lenX = 11, lenY = 10, lenE = lenY; Workspace_sptr wsAsWs = @@ -326,9 +326,9 @@ public: AnalysisDataService::Instance().add(inWsName, ws); } - void doTestRealBinBoundaries(const std::string inWsName, - const std::string rangeLower, - const std::string rangeUpper, + void doTestRealBinBoundaries(const std::string &inWsName, + const std::string &rangeLower, + const std::string &rangeUpper, const double expectedVal, const bool checkRanges = false, const bool IncPartialBins = false) { @@ -707,7 +707,7 @@ public: } template <typename F> - void wsBoundsTest(std::string workspace, int startIndex, int endIndex, + void wsBoundsTest(const std::string &workspace, int startIndex, int endIndex, F boundsAssert) { MatrixWorkspace_sptr input; TS_ASSERT_THROWS_NOTHING( @@ -732,8 +732,9 @@ public: } void testStartWsIndexOutOfBounds() { - auto boundsAssert = [](MatrixWorkspace_sptr, MatrixWorkspace_sptr output, - int, int endIndex) { + auto boundsAssert = [](const MatrixWorkspace_sptr &, + const MatrixWorkspace_sptr &output, int, + int endIndex) { TS_ASSERT_EQUALS(output->getNumberHistograms(), endIndex + 1); }; @@ -741,8 +742,9 @@ public: } void testStartWSIndexGreaterThanEnd() { - auto boundsAssert = [](MatrixWorkspace_sptr input, - MatrixWorkspace_sptr output, int startIndex, int) { + auto boundsAssert = [](const MatrixWorkspace_sptr &input, + const MatrixWorkspace_sptr &output, int startIndex, + int) { TS_ASSERT_EQUALS(output->getNumberHistograms(), input->getNumberHistograms() - startIndex); }; @@ -751,8 +753,8 @@ public: } void testStartWSIndexEqualsEnd() { - auto boundsAssert = [](MatrixWorkspace_sptr, MatrixWorkspace_sptr output, - int, int) { + auto boundsAssert = [](const MatrixWorkspace_sptr &, + const MatrixWorkspace_sptr &output, int, int) { TS_ASSERT_EQUALS(output->getNumberHistograms(), 1); }; @@ -780,7 +782,7 @@ public: } private: - void assertRangeWithPartialBins(Workspace_sptr input) { + void assertRangeWithPartialBins(const Workspace_sptr &input) { Integration alg; alg.setRethrows(false); TS_ASSERT_THROWS_NOTHING(alg.initialize()); diff --git a/Framework/Algorithms/test/LineProfileTest.h b/Framework/Algorithms/test/LineProfileTest.h index 1ceace8fe27a54997b72cf366a13598b8f35d3ac..61fda4391b0f455b5a6a7c34919b96f61510610f 100644 --- a/Framework/Algorithms/test/LineProfileTest.h +++ b/Framework/Algorithms/test/LineProfileTest.h @@ -568,9 +568,9 @@ public: TS_ASSERT_EQUALS(axis->getMax(), edges.back()) const auto binHeight = axis->getMax() - axis->getMin(); TS_ASSERT_EQUALS(outputWS->getNumberHistograms(), 1) - const auto &Xs = outputWS->x(0); + // cppcheck-suppress unreadVariable const std::vector<double> profilePoints{{1., 2., 3., 4.}}; - TS_ASSERT_EQUALS(Xs.rawData(), profilePoints) + TS_ASSERT_EQUALS(outputWS->x(0).rawData(), profilePoints) const auto &Ys = outputWS->y(0); const auto horizontalIntegral = (3. * 0.1 + 2. * 1. + 1. * 10.) / binHeight; for (const auto y : Ys) { @@ -584,9 +584,9 @@ public: } private: - MatrixWorkspace_sptr profileOverTwoSpectra(MatrixWorkspace_sptr inputWS, - const int start, const int end, - const std::string &mode) { + MatrixWorkspace_sptr + profileOverTwoSpectra(const MatrixWorkspace_sptr &inputWS, const int start, + const int end, const std::string &mode) { LineProfile alg; // Don't put output in ADS by default alg.setChild(true); diff --git a/Framework/Algorithms/test/MCInteractionVolumeTest.h b/Framework/Algorithms/test/MCInteractionVolumeTest.h index cb97ba7658a2c1f63234047ac78edecc8136d8a9..199fa0f9c2716b3dae098704a14c84b6a8569e32 100644 --- a/Framework/Algorithms/test/MCInteractionVolumeTest.h +++ b/Framework/Algorithms/test/MCInteractionVolumeTest.h @@ -358,7 +358,8 @@ private: Mantid::Kernel::Logger g_log{"MCInteractionVolumeTest"}; void TestGeneratedTracks(const V3D startPos, const V3D endPos, - const Track beforeScatter, const Track afterScatter, + const Track &beforeScatter, + const Track &afterScatter, const Mantid::Geometry::IObject &shape) { // check the generated tracks share the same start point (the scatter point) TS_ASSERT_EQUALS(beforeScatter.startPoint(), afterScatter.startPoint()); diff --git a/Framework/Algorithms/test/MagFormFactorCorrectionTest.h b/Framework/Algorithms/test/MagFormFactorCorrectionTest.h index 8f2cdb2d61f76124f2ce91633708e3c5b59f1871..2ec64fbbb6c507956aa771f2d5ee42746d238fc1 100644 --- a/Framework/Algorithms/test/MagFormFactorCorrectionTest.h +++ b/Framework/Algorithms/test/MagFormFactorCorrectionTest.h @@ -91,7 +91,7 @@ private: std::string formFactorWSname; // Creates a fake workspace - void createWorkspaceMag(bool isHistogram, std::string wsname) { + void createWorkspaceMag(bool isHistogram, const std::string &wsname) { const int nspecs(10); const int nbins(50); const double invfourPiSqr = 1. / (16. * M_PI * M_PI); @@ -116,8 +116,9 @@ private: } // Checks that all the workspaces are consistent (in = out*ff) - double checkWorkspaces(MatrixWorkspace_sptr in, MatrixWorkspace_sptr out, - MatrixWorkspace_sptr ff) { + double checkWorkspaces(const MatrixWorkspace_sptr &in, + const MatrixWorkspace_sptr &out, + const MatrixWorkspace_sptr &ff) { const int64_t nbins = in->blocksize(); const int64_t nspecs = in->getNumberHistograms(); double df2 = 0., df; diff --git a/Framework/Algorithms/test/MergeLogsTest.h b/Framework/Algorithms/test/MergeLogsTest.h index 535868d98a41d1bc49bb761b4aacdda2e66da9d9..624b44238ef28a8358c067a6405b66ed5853a5f1 100644 --- a/Framework/Algorithms/test/MergeLogsTest.h +++ b/Framework/Algorithms/test/MergeLogsTest.h @@ -116,7 +116,7 @@ public: return log; } - void testLogValues(MatrixWorkspace_sptr ws, const std::string &name, + void testLogValues(const MatrixWorkspace_sptr &ws, const std::string &name, const int msize, double value) { TimeSeriesProperty<double> *log = ws->run().getTimeSeriesProperty<double>(name); @@ -131,7 +131,7 @@ public: } // msize1 < msize2! - void testLogValues(MatrixWorkspace_sptr ws, const std::string &name, + void testLogValues(const MatrixWorkspace_sptr &ws, const std::string &name, const int msize1, const int msize2, const double v1, const double v2) { TimeSeriesProperty<double> *log = diff --git a/Framework/Algorithms/test/MergeRunsTest.h b/Framework/Algorithms/test/MergeRunsTest.h index a5e92fe227bdf676e322430c3e4f8ff5f308b814..8bead92a85e57b3350a4ca4aed4cb394c45ab109 100644 --- a/Framework/Algorithms/test/MergeRunsTest.h +++ b/Framework/Algorithms/test/MergeRunsTest.h @@ -40,8 +40,8 @@ private: MergeRuns merge; /// Helper method to add an 'nperiods' log value to each workspace in a group. - void add_periods_logs(WorkspaceGroup_sptr ws, bool calculateNPeriods = true, - int nperiods = -1) { + void add_periods_logs(const WorkspaceGroup_sptr &ws, + bool calculateNPeriods = true, int nperiods = -1) { if (calculateNPeriods) { nperiods = static_cast<int>(ws->size()); } @@ -268,7 +268,7 @@ private: return c; } - void do_test_treat_as_non_period_groups(WorkspaceGroup_sptr input) { + void do_test_treat_as_non_period_groups(const WorkspaceGroup_sptr &input) { MatrixWorkspace_sptr sampleInputWorkspace = boost::dynamic_pointer_cast<MatrixWorkspace>(input->getItem(0)); const double uniformSignal = sampleInputWorkspace->y(0)[0]; @@ -320,7 +320,7 @@ public: "in6", WorkspaceCreationHelper::create2DWorkspaceBinned(3, 3, 2., 2.)); } - void checkOutput(std::string wsname) { + void checkOutput(const std::string &wsname) { EventWorkspace_sptr output; TimeSeriesProperty<double> *log; int log1, log2, logTot; @@ -373,6 +373,7 @@ public: va_start(vl, num); for (int i = 0; i < num; i++) retVal.emplace_back(va_arg(vl, int)); + va_end(vl); return retVal; } @@ -874,7 +875,8 @@ public: AnalysisDataService::Instance().remove("outer"); } - void do_test_validation_throws(WorkspaceGroup_sptr a, WorkspaceGroup_sptr b) { + void do_test_validation_throws(const WorkspaceGroup_sptr &a, + const WorkspaceGroup_sptr &b) { MergeRuns alg; alg.setRethrows(true); alg.initialize(); @@ -911,7 +913,7 @@ public: do_test_validation_throws(aCorrupted, a); } - void do_test_with_multiperiod_data(WorkspaceGroup_sptr input) { + void do_test_with_multiperiod_data(const WorkspaceGroup_sptr &input) { // Extract some internal information from the nested workspaces in order to // run test asserts later. const size_t expectedNumHistograms = @@ -1356,8 +1358,8 @@ public: 3); } - void do_test_merge_two_workspaces_then_third(std::string mergeType, - std::string result) { + void do_test_merge_two_workspaces_then_third(const std::string &mergeType, + const std::string &result) { auto ws = create_group_workspace_with_sample_logs<double>( mergeType, "prop1", 1.0, 2.0, 3.0, 4.0); @@ -1391,8 +1393,8 @@ public: "1, 2, 5"); } - void do_test_merging_two_workspaces_both_already_merged(std::string mergeType, - std::string result) { + void do_test_merging_two_workspaces_both_already_merged( + const std::string &mergeType, const std::string &result) { auto ws = create_group_workspace_with_sample_logs<double>( mergeType, "prop1", 1.0, 2.0, 3.0, 4.0); diff --git a/Framework/Algorithms/test/ModeratorTzeroLinearTest.h b/Framework/Algorithms/test/ModeratorTzeroLinearTest.h index 011ea38cf3b000aee198a45936230aaf07498a09..5c07a2aba506181fe25d027cb156f6386d5f147b 100644 --- a/Framework/Algorithms/test/ModeratorTzeroLinearTest.h +++ b/Framework/Algorithms/test/ModeratorTzeroLinearTest.h @@ -26,7 +26,7 @@ using Mantid::HistogramData::LinearGenerator; using Mantid::Types::Event::TofEvent; namespace { -void addToInstrument(MatrixWorkspace_sptr testWS, +void addToInstrument(const MatrixWorkspace_sptr &testWS, const bool &add_deltaE_mode = false, const bool &add_t0_formula = false) { const double evalue(2.082); // energy corresponding to the first order Bragg diff --git a/Framework/Algorithms/test/MonteCarloAbsorptionTest.h b/Framework/Algorithms/test/MonteCarloAbsorptionTest.h index e9dde8bff9bacee37b7b2f7fd5e4364d9c128d2c..bff3d16341a5d6ef07ad65287aefc93667f8fa21 100644 --- a/Framework/Algorithms/test/MonteCarloAbsorptionTest.h +++ b/Framework/Algorithms/test/MonteCarloAbsorptionTest.h @@ -40,7 +40,7 @@ struct TestWorkspaceDescriptor { double beamHeight; }; -void addSample(Mantid::API::MatrixWorkspace_sptr ws, +void addSample(const Mantid::API::MatrixWorkspace_sptr &ws, const Environment environment, double beamWidth = 0., double beamHeight = 0.) { using namespace Mantid::API; @@ -87,7 +87,6 @@ void addSample(Mantid::API::MatrixWorkspace_sptr ws, ws->mutableSample().setShape(sampleShape); if (environment == Environment::SamplePlusContainer) { - const std::string id("container"); constexpr double containerWallThickness{0.002}; constexpr double containerInnerRadius{1.2 * sampleHeight}; constexpr double containerOuterRadius{containerInnerRadius + @@ -403,7 +402,7 @@ private: } Mantid::API::MatrixWorkspace_const_sptr - getOutputWorkspace(Mantid::API::IAlgorithm_sptr alg) { + getOutputWorkspace(const Mantid::API::IAlgorithm_sptr &alg) { using Mantid::API::MatrixWorkspace_sptr; MatrixWorkspace_sptr output = alg->getProperty("OutputWorkspace"); TS_ASSERT(output); @@ -412,8 +411,9 @@ private: return output; } - void verifyDimensions(TestWorkspaceDescriptor wsProps, - Mantid::API::MatrixWorkspace_const_sptr outputWS) { + void + verifyDimensions(TestWorkspaceDescriptor wsProps, + const Mantid::API::MatrixWorkspace_const_sptr &outputWS) { TS_ASSERT_EQUALS(wsProps.nspectra, outputWS->getNumberHistograms()); TS_ASSERT_EQUALS(wsProps.nbins, outputWS->blocksize()); } diff --git a/Framework/Algorithms/test/MultiplyDivideTest.in.h b/Framework/Algorithms/test/MultiplyDivideTest.in.h index 44f71c607c1a82d1fc1b924b24c69fd1675a1773..2a2c6270760499f02ed155b95fe6fd9c004edd1e 100644 --- a/Framework/Algorithms/test/MultiplyDivideTest.in.h +++ b/Framework/Algorithms/test/MultiplyDivideTest.in.h @@ -9,6 +9,7 @@ #include <cxxtest/TestSuite.h> #include <cmath> +#include <stdexcept> #include "MantidTestHelpers/WorkspaceCreationHelper.h" #include "MantidAlgorithms/Divide.h" @@ -602,6 +603,10 @@ public: mess << "; RHS: grouping=" << rhs_grouping << ", 2D=" << rhs2D; message = mess.str(); + if (lhs_grouping == 0 || rhs_grouping == 0){ + throw std::runtime_error("Attempted div by zero in test"); + } + int numpix = 12; std::vector< std::vector<int> > lhs(numpix/lhs_grouping), rhs(numpix/rhs_grouping); for (int i=0; i<numpix; i++) diff --git a/Framework/Algorithms/test/NormaliseByCurrentTest.h b/Framework/Algorithms/test/NormaliseByCurrentTest.h index 766db44fb1bfee8f2ec4efdc248cf14992fa73a9..6b3ca7a62904d41fa37a06cb7efc23367d82791f 100644 --- a/Framework/Algorithms/test/NormaliseByCurrentTest.h +++ b/Framework/Algorithms/test/NormaliseByCurrentTest.h @@ -9,6 +9,8 @@ #include "MantidTestHelpers/WorkspaceCreationHelper.h" #include <cxxtest/TestSuite.h> +#include <utility> + #include "MantidAPI/AnalysisDataService.h" #include "MantidAPI/Axis.h" #include "MantidAPI/WorkspaceGroup.h" @@ -25,9 +27,10 @@ using namespace Mantid::Algorithms; using namespace Mantid::DataObjects; namespace { -MatrixWorkspace_const_sptr doTest(MatrixWorkspace_sptr inWS, - std::string wsNameOut, double expectedY, - double expectedE, bool calcPcharge = false, +MatrixWorkspace_const_sptr doTest(const MatrixWorkspace_sptr &inWS, + const std::string &wsNameOut, + double expectedY, double expectedE, + bool calcPcharge = false, bool performance = false) { NormaliseByCurrent norm1; if (!norm1.isInitialized()) @@ -87,7 +90,8 @@ MatrixWorkspace_const_sptr doTest(MatrixWorkspace_sptr inWS, return output; } -MatrixWorkspace_const_sptr doTest(std::string wsNameIn, std::string wsNameOut, +MatrixWorkspace_const_sptr doTest(const std::string &wsNameIn, + const std::string &wsNameOut, const double pCharge, double expectedY, double expectedE, bool performance = false) { MatrixWorkspace_sptr inWS = @@ -99,13 +103,14 @@ MatrixWorkspace_const_sptr doTest(std::string wsNameIn, std::string wsNameOut, Mantid::Kernel::UnitFactory::Instance().create("TOF"); inWS->setYUnit("Counts"); - return doTest(inWS, wsNameOut, expectedY, expectedE, true, performance); + return doTest(inWS, std::move(wsNameOut), expectedY, expectedE, true, + performance); } /// Helper method to add necessary log values to simulate multi-period data. /// The algorithm uses these logs to determien how to normalise by the /// current. -void addMultiPeriodLogsTo(MatrixWorkspace_sptr ws, int period, +void addMultiPeriodLogsTo(const MatrixWorkspace_sptr &ws, int period, const std::string &protonCharges) { ArrayProperty<double> *chargeProp = new ArrayProperty<double>("proton_charge_by_period", protonCharges); @@ -119,7 +124,8 @@ void addMultiPeriodLogsTo(MatrixWorkspace_sptr ws, int period, ws->mutableRun().addLogData(currentPeriodProp); } -void addPChargeLogTo(MatrixWorkspace_sptr ws, const double pChargeAccum) { +void addPChargeLogTo(const MatrixWorkspace_sptr &ws, + const double pChargeAccum) { auto pchargeLog = std::make_unique<Kernel::TimeSeriesProperty<double>>("proton_charge"); diff --git a/Framework/Algorithms/test/NormaliseByDetectorTest.h b/Framework/Algorithms/test/NormaliseByDetectorTest.h index feb1b287d0433233d2b485d710807ad93c9874f9..be35738086039d1563ae01164aed81b963a18421 100644 --- a/Framework/Algorithms/test/NormaliseByDetectorTest.h +++ b/Framework/Algorithms/test/NormaliseByDetectorTest.h @@ -28,8 +28,8 @@ using ScopedFileHelper::ScopedFile; Helper function. Runs LoadParameterAlg, to get an instrument parameter definition from a file onto a workspace. */ -void apply_instrument_parameter_file_to_workspace(MatrixWorkspace_sptr ws, - const ScopedFile &file) { +void apply_instrument_parameter_file_to_workspace( + const MatrixWorkspace_sptr &ws, const ScopedFile &file) { // Load the Instrument Parameter file over the existing test workspace + // instrument. using DataHandling::LoadParameterFile; @@ -46,7 +46,7 @@ Helper method for running the algorithm and simply verifying that it runs without exception producing an output workspace.. */ MatrixWorkspace_sptr -do_test_doesnt_throw_on_execution(MatrixWorkspace_sptr inputWS, +do_test_doesnt_throw_on_execution(const MatrixWorkspace_sptr &inputWS, bool parallel = true) { NormaliseByDetector alg(parallel); alg.setRethrows(true); @@ -102,7 +102,7 @@ private: The fit function is set at the instrument level. */ MatrixWorkspace_sptr create_workspace_with_fitting_functions( - const std::string result_unit = "Wavelength") { + const std::string &result_unit = "Wavelength") { // Create a default workspace with no-fitting functions. MatrixWorkspace_sptr ws = create_workspace_with_no_fitting_functions(); const std::string instrumentName = ws->getInstrument()->getName(); @@ -228,7 +228,8 @@ private: */ MatrixWorkspace_sptr create_workspace_with_incomplete_detector_level_only_fit_functions( - MatrixWorkspace_sptr original = boost::shared_ptr<MatrixWorkspace>()) { + const MatrixWorkspace_sptr &original = + boost::shared_ptr<MatrixWorkspace>()) { MatrixWorkspace_sptr ws = original; if (original == nullptr) { // Create a default workspace with no-fitting functions. @@ -274,9 +275,8 @@ private: Helper method for running the algorithm and testing for invalid argument on execution. */ - void - do_test_throws_invalid_argument_on_execution(MatrixWorkspace_sptr inputWS, - bool parallel = false) { + void do_test_throws_invalid_argument_on_execution( + const MatrixWorkspace_sptr &inputWS, bool parallel = false) { NormaliseByDetector alg(parallel); alg.setRethrows(true); alg.initialize(); @@ -400,10 +400,11 @@ public: MatrixWorkspace_sptr inputWS = create_workspace_with_fitting_functions(); // Extract the output workspace so that we can verify the normalisation. const bool parallel = true; + const bool sequential = false; MatrixWorkspace_sptr outWS_parallel = do_test_doesnt_throw_on_execution( inputWS, parallel); // EXECUTES THE ALG IN PARALLEL. MatrixWorkspace_sptr outWS_sequential = do_test_doesnt_throw_on_execution( - inputWS, !parallel); // EXECUTES THE ALG SEQUENTIALLY. + inputWS, sequential); // EXECUTES THE ALG SEQUENTIALLY. // Output workspaces should have same number of histograms. TS_ASSERT_EQUALS(2, outWS_parallel->getNumberHistograms()); @@ -651,7 +652,7 @@ public: private: /// Helper method to run common sanity checks. - void do_basic_checks(MatrixWorkspace_sptr normalisedWS) { + void do_basic_checks(const MatrixWorkspace_sptr &normalisedWS) { TS_ASSERT(normalisedWS != nullptr); TS_ASSERT(ws->getNumberHistograms() == normalisedWS->getNumberHistograms()); TS_ASSERT(ws->x(0).size() == normalisedWS->x(0).size()); diff --git a/Framework/Algorithms/test/NormaliseToMonitorTest.h b/Framework/Algorithms/test/NormaliseToMonitorTest.h index b3a9a9c345bd44bed43f805fa52a194c9a4d69ad..1642311c5f7f475c8fed8ecf1a88e6aaf571a0c8 100644 --- a/Framework/Algorithms/test/NormaliseToMonitorTest.h +++ b/Framework/Algorithms/test/NormaliseToMonitorTest.h @@ -468,10 +468,11 @@ public: for (size_t i = 0; i < specOutInfo.size(); ++i) { const auto &yValues = outWS->histogram(i).y(); for (size_t j = 0; j < yValues.size(); ++j) { - if (specOutInfo.isMonitor(i)) + if (specOutInfo.isMonitor(i)) { TS_ASSERT_DELTA(yValues[j], 3.0, 1e-12) - else + } else { TS_ASSERT_DELTA(yValues[j], 6.0 / double(j + 1), 1e-12) + } } } } @@ -497,6 +498,7 @@ public: const auto &yValues = outWS->histogram(i).y(); for (size_t j = 0; j < yValues.size(); ++j) { if (specOutInfo.isMonitor(i)) + // cppcheck-suppress syntaxError TS_ASSERT_DELTA(yValues[j], double(j + 1) / 15.0, 1e-12) else TS_ASSERT_DELTA(yValues[j], 2.0 / 15.0, 1e-12) diff --git a/Framework/Algorithms/test/PDDetermineCharacterizationsTest.h b/Framework/Algorithms/test/PDDetermineCharacterizationsTest.h index 0f2fea3fef97ed0e109a6a0fd3395f5daa686171..f79748f75c1c2c86c4d1805a37c5486881ffd000 100644 --- a/Framework/Algorithms/test/PDDetermineCharacterizationsTest.h +++ b/Framework/Algorithms/test/PDDetermineCharacterizationsTest.h @@ -82,8 +82,8 @@ public: } } - void addRow(ITableWorkspace_sptr wksp, const double freq, const double wl, - const int bank, const std::string &van, + void addRow(const ITableWorkspace_sptr &wksp, const double freq, + const double wl, const int bank, const std::string &van, const std::string &van_back, const std::string &can, const std::string &empty_env, const std::string &empty_inst, const std::string &dmin, const std::string &dmax, @@ -209,8 +209,8 @@ public: return expectedInfo; } - void compareResult(PropertyManager_sptr expected, - PropertyManager_sptr observed) { + void compareResult(const PropertyManager_sptr &expected, + const PropertyManager_sptr &observed) { TS_ASSERT_EQUALS(expected->propertyCount(), observed->propertyCount()); const std::vector<Property *> &expectedProps = expected->getProperties(); diff --git a/Framework/Algorithms/test/PDFFourierTransformTest.h b/Framework/Algorithms/test/PDFFourierTransformTest.h index ecf820a006954bfef77e04e55e4d2cb69fa53d60..8b39d78f74853f5ff1bdf57d557305490824ba06 100644 --- a/Framework/Algorithms/test/PDFFourierTransformTest.h +++ b/Framework/Algorithms/test/PDFFourierTransformTest.h @@ -32,7 +32,7 @@ namespace { */ Mantid::API::MatrixWorkspace_sptr createWS(size_t n, double dx, const std::string &name, - const std::string unitlabel, + const std::string &unitlabel, const bool withBadValues = false) { Mantid::API::FrameworkManager::Instance(); diff --git a/Framework/Algorithms/test/ParallaxCorrectionTest.h b/Framework/Algorithms/test/ParallaxCorrectionTest.h index b6cdeb9e46e834df0385ccc3701e2cc70cdc3869..36b63cf846c3c0e61a2ce17f3353c72927beb801 100644 --- a/Framework/Algorithms/test/ParallaxCorrectionTest.h +++ b/Framework/Algorithms/test/ParallaxCorrectionTest.h @@ -27,7 +27,7 @@ using Mantid::Geometry::DetectorInfo; using Mantid::Kernel::V3D; namespace { -bool compare(MatrixWorkspace_sptr w1, MatrixWorkspace_sptr w2) { +bool compare(const MatrixWorkspace_sptr &w1, const MatrixWorkspace_sptr &w2) { CompareWorkspaces comparator; comparator.initialize(); comparator.setChild(true); diff --git a/Framework/Algorithms/test/PerformIndexOperationsTest.h b/Framework/Algorithms/test/PerformIndexOperationsTest.h index 1502a093f78138e316fc1f1012e632863c8300d6..0a0a02992723e10d9f71b4b2a3170a44fa09a214 100644 --- a/Framework/Algorithms/test/PerformIndexOperationsTest.h +++ b/Framework/Algorithms/test/PerformIndexOperationsTest.h @@ -16,7 +16,7 @@ using Mantid::Algorithms::PerformIndexOperations; using namespace Mantid::API; MatrixWorkspace_const_sptr -doExecute(MatrixWorkspace_sptr inWS, +doExecute(const MatrixWorkspace_sptr &inWS, const std::string &processingInstructions) { // Name of the output workspace. std::string outWSName("PerformIndexOperationsTest_OutputWS"); diff --git a/Framework/Algorithms/test/PlusMinusTest.in.h b/Framework/Algorithms/test/PlusMinusTest.in.h index e264d7048f50e004d1b7c1f2ce5fe0218269cec7..68a6515f889fa24b782667cd68ef98bec308a93e 100644 --- a/Framework/Algorithms/test/PlusMinusTest.in.h +++ b/Framework/Algorithms/test/PlusMinusTest.in.h @@ -392,7 +392,7 @@ public: MatrixWorkspace_sptr work_in2 = eventWS_5x10_50; // You have to specify the expected output value because in1 gets changed. performTest(work_in1,work_in2, true, false /*not event out*/, - DO_PLUS ? 4.0 : 0.0, DO_PLUS ? 2.0 : 2.0); + DO_PLUS ? 4.0 : 0.0, 2.0); } void test_Event_2D() @@ -468,7 +468,7 @@ public: MatrixWorkspace_sptr work_in1 = eventWS_5x10_50; MatrixWorkspace_sptr work_in2 = eventWS_5x10_50; MatrixWorkspace_sptr work_out = performTest(work_in1,work_in2, false /*inPlace*/, true /*outputIsEvent*/, - DO_PLUS ? 4.0 : 0.0, DO_PLUS ? 2.0 : 2.0); + DO_PLUS ? 4.0 : 0.0, 2.0); } void test_Event_Event_inPlace() @@ -477,7 +477,7 @@ public: MatrixWorkspace_sptr work_in1 = WorkspaceCreationHelper::createEventWorkspace(nHist,nBins,50,0.0,1.0,2); MatrixWorkspace_sptr work_in2 = eventWS_5x10_50; MatrixWorkspace_sptr work_out = performTest(work_in1,work_in2, true, true /*outputIsEvent*/, - DO_PLUS ? 4.0 : 0.0, DO_PLUS ? 2.0 : 2.0); + DO_PLUS ? 4.0 : 0.0, 2.0); } void test_Event_EventSingleSpectrum_fails() @@ -502,7 +502,7 @@ public: MatrixWorkspace_sptr work_in1 = WorkspaceCreationHelper::createEventWorkspace(nHist,nBins,50,0.0,1.0,2); MatrixWorkspace_sptr work_in2 = WorkspaceCreationHelper::createEventWorkspace(nHist,nBins,50,0.0,1.0,2); MatrixWorkspace_sptr work_out = performTest(work_in1,work_in2, inplace!=0, true /*outputIsEvent*/, - DO_PLUS ? 4.0 : 0.0, DO_PLUS ? 2.0 : 2.0); + DO_PLUS ? 4.0 : 0.0, 2.0); } } @@ -514,7 +514,7 @@ public: MatrixWorkspace_sptr work_in1 = WorkspaceCreationHelper::createEventWorkspace(nHist,nBins,50,0.0,1.0,2); MatrixWorkspace_sptr work_in2 = WorkspaceCreationHelper::createEventWorkspace(nHist,1,50,0.0,1.0,2); MatrixWorkspace_sptr work_out = performTest(work_in1,work_in2, inplace!=0, true /*outputIsEvent*/, - DO_PLUS ? 4.0 : 0.0, DO_PLUS ? 2.0 : 2.0); + DO_PLUS ? 4.0 : 0.0, 2.0); } } @@ -525,7 +525,7 @@ public: MatrixWorkspace_sptr work_in1 = WorkspaceCreationHelper::createEventWorkspace(5,1,50,0.0,1.0,2); MatrixWorkspace_sptr work_in2 = eventWS_5x10_50; MatrixWorkspace_sptr work_out = performTest(work_in1,work_in2, inplace!=0, true /*outputIsEvent*/, - DO_PLUS ? 4.0 : 0.0, DO_PLUS ? 2.0 : 2.0); + DO_PLUS ? 4.0 : 0.0, 2.0); } } @@ -537,7 +537,7 @@ public: MatrixWorkspace_sptr work_in1 = WorkspaceCreationHelper::createEventWorkspace(nHist,nBins,50,0.0,1.0,2); MatrixWorkspace_sptr work_in2 = WorkspaceCreationHelper::createEventWorkspace(nHist,nBins,50,0.0,1.0,2); MatrixWorkspace_sptr work_out = performTest(work_in1,work_in2, inplace!=0, true /*outputIsEvent*/, - DO_PLUS ? 4.0 : 0.0, DO_PLUS ? 2.0 : 2.0); + DO_PLUS ? 4.0 : 0.0, 2.0); } } @@ -567,7 +567,7 @@ public: TS_ASSERT( work_in2->getSpectrum(0).hasDetectorID(100) ); MatrixWorkspace_sptr work_out = performTest(work_in1,work_in2, inplace!=0, true /*outputIsEvent*/, - DO_PLUS ? 3.0 : -1.0, DO_PLUS ? 1.7320 : 1.7320); + DO_PLUS ? 3.0 : -1.0, 1.7320); //Ya, its an event workspace TS_ASSERT(work_out); diff --git a/Framework/Algorithms/test/PoissonErrorsTest.h b/Framework/Algorithms/test/PoissonErrorsTest.h index 4967c3533d84b1d3808330cb9eaa9c0b8904cdfb..1651bc0bdefa202e1839498487218acfb80a3b73 100644 --- a/Framework/Algorithms/test/PoissonErrorsTest.h +++ b/Framework/Algorithms/test/PoissonErrorsTest.h @@ -7,6 +7,8 @@ #pragma once #include <cmath> +#include <utility> + #include <cxxtest/TestSuite.h> #include "MantidAPI/AnalysisDataService.h" @@ -238,15 +240,18 @@ public: } private: - void checkData(MatrixWorkspace_sptr work_in1, MatrixWorkspace_sptr work_in2, - MatrixWorkspace_sptr work_out1) { + void checkData(const MatrixWorkspace_sptr &work_in1, + const MatrixWorkspace_sptr &work_in2, + const MatrixWorkspace_sptr &work_out1) { // default to a horizontal loop orientation - checkData(work_in1, work_in2, work_out1, 0); + checkData(std::move(work_in1), std::move(work_in2), std::move(work_out1), + 0); } // loopOrientation 0=Horizontal, 1=Vertical - void checkData(MatrixWorkspace_sptr work_in1, MatrixWorkspace_sptr work_in2, - MatrixWorkspace_sptr work_out1, int loopOrientation) { + void checkData(const MatrixWorkspace_sptr &work_in1, + const MatrixWorkspace_sptr &work_in2, + const MatrixWorkspace_sptr &work_out1, int loopOrientation) { size_t ws2LoopCount = 0; if (work_in2->size() > 0) { ws2LoopCount = work_in1->size() / work_in2->size(); @@ -267,9 +272,9 @@ private: } } - void checkDataItem(MatrixWorkspace_sptr work_in1, - MatrixWorkspace_sptr work_in2, - MatrixWorkspace_sptr work_out1, size_t i, + void checkDataItem(const MatrixWorkspace_sptr &work_in1, + const MatrixWorkspace_sptr &work_in2, + const MatrixWorkspace_sptr &work_out1, size_t i, size_t ws2Index) { // printf("I=%d\tws2Index=%d\n",i,ws2Index); double sig1 = diff --git a/Framework/Algorithms/test/PolarizationCorrectionFredrikzeTest.h b/Framework/Algorithms/test/PolarizationCorrectionFredrikzeTest.h index 4af539c20c9306d9e1ad7026f6169140b769b3c0..b558ac16662702b1aa0773d8f2bd80026b7b2376 100644 --- a/Framework/Algorithms/test/PolarizationCorrectionFredrikzeTest.h +++ b/Framework/Algorithms/test/PolarizationCorrectionFredrikzeTest.h @@ -79,7 +79,7 @@ public: return group; } - MatrixWorkspace_sptr makeEfficiencies(Workspace_sptr inWS, + MatrixWorkspace_sptr makeEfficiencies(const Workspace_sptr &inWS, const std::string &rho, const std::string &pp, const std::string &alpha = "", @@ -214,7 +214,8 @@ public: } } - void setInstrument(Workspace_sptr ws, const std::string &instrument_name) { + void setInstrument(const Workspace_sptr &ws, + const std::string &instrument_name) { auto alg = AlgorithmManager::Instance().createUnmanaged("LoadInstrument"); AnalysisDataService::Instance().addOrReplace("dummy", ws); alg->initialize(); diff --git a/Framework/Algorithms/test/Rebin2DTest.h b/Framework/Algorithms/test/Rebin2DTest.h index 3d458558e089b177118982efacd355e7f27a64e7..3326dbccec4812e03c241097a00ba6701fd0b064 100644 --- a/Framework/Algorithms/test/Rebin2DTest.h +++ b/Framework/Algorithms/test/Rebin2DTest.h @@ -76,7 +76,7 @@ MatrixWorkspace_sptr makeInputWS(const bool distribution, return ws; } -MatrixWorkspace_sptr runAlgorithm(MatrixWorkspace_sptr inputWS, +MatrixWorkspace_sptr runAlgorithm(const MatrixWorkspace_sptr &inputWS, const std::string &axis1Params, const std::string &axis2Params, const bool UseFractionalArea = false) { @@ -273,9 +273,9 @@ public: } private: - void checkData(MatrixWorkspace_const_sptr outputWS, const size_t nxvalues, - const size_t nhist, const bool dist, const bool onAxis1, - const bool small_bins = false) { + void checkData(const MatrixWorkspace_const_sptr &outputWS, + const size_t nxvalues, const size_t nhist, const bool dist, + const bool onAxis1, const bool small_bins = false) { TS_ASSERT_EQUALS(outputWS->getNumberHistograms(), nhist); TS_ASSERT_EQUALS(outputWS->isDistribution(), dist); // Axis sizes diff --git a/Framework/Algorithms/test/ReflectometryMomentumTransferTest.h b/Framework/Algorithms/test/ReflectometryMomentumTransferTest.h index f3e8e41787b8a1f06e7941a0a9e9cb33488cab64..1c79b75e5dd4d31d3fc878343669733291f93799 100644 --- a/Framework/Algorithms/test/ReflectometryMomentumTransferTest.h +++ b/Framework/Algorithms/test/ReflectometryMomentumTransferTest.h @@ -119,8 +119,7 @@ public: TS_ASSERT_EQUALS(outXs.size(), inXs.size()) TS_ASSERT(outputWS->hasDx(0)) const auto &inYs = inputWS->y(0); - const auto &outYs = outputWS->y(0); - TS_ASSERT_EQUALS(outYs.rawData(), inYs.rawData()) + TS_ASSERT_EQUALS(outputWS->y(0).rawData(), inYs.rawData()) const auto &inEs = inputWS->e(0); const auto &outEs = outputWS->e(0); TS_ASSERT_EQUALS(outEs.rawData(), inEs.rawData()) @@ -283,7 +282,7 @@ private: TS_ASSERT(!alg->isExecuted()) } - static API::Algorithm_sptr make_alg(API::MatrixWorkspace_sptr inputWS, + static API::Algorithm_sptr make_alg(const API::MatrixWorkspace_sptr &inputWS, const std::string &sumType, const std::vector<int> &foreground) { auto alg = boost::make_shared<Algorithms::ReflectometryMomentumTransfer>(); diff --git a/Framework/Algorithms/test/ReflectometryReductionOne2Test.h b/Framework/Algorithms/test/ReflectometryReductionOne2Test.h index 382dec5feae141945268d8d4082af78b40841948..e0d381d65367af75e6305dc47df6a211c8580508 100644 --- a/Framework/Algorithms/test/ReflectometryReductionOne2Test.h +++ b/Framework/Algorithms/test/ReflectometryReductionOne2Test.h @@ -964,7 +964,7 @@ private: const double wavelengthMin, const double wavelengthMax, const std::string &procInstr, - MatrixWorkspace_sptr transWS, + const MatrixWorkspace_sptr &transWS, const bool multiple_runs) { setupAlgorithm(alg, wavelengthMin, wavelengthMax, procInstr); alg.setProperty("FirstTransmissionRun", transWS); @@ -981,7 +981,7 @@ private: const double wavelengthMin, const double wavelengthMax, const std::string &procInstr, - MatrixWorkspace_sptr inputWS, + const MatrixWorkspace_sptr &inputWS, const bool integrate) { setupAlgorithm(alg, wavelengthMin, wavelengthMax, procInstr); alg.setProperty("InputWorkspace", inputWS); @@ -997,8 +997,9 @@ private: } } - void setupAlgorithmForBackgroundSubtraction(ReflectometryReductionOne2 &alg, - MatrixWorkspace_sptr inputWS) { + void + setupAlgorithmForBackgroundSubtraction(ReflectometryReductionOne2 &alg, + const MatrixWorkspace_sptr &inputWS) { setupAlgorithm(alg, 0, 5, "3"); alg.setChild(false); // required to get history alg.setProperty("InputWorkspace", inputWS); @@ -1105,7 +1106,7 @@ private: return ws; } - void checkWorkspaceHistory(MatrixWorkspace_sptr ws, + void checkWorkspaceHistory(const MatrixWorkspace_sptr &ws, std::vector<std::string> const &expected, bool const unroll = true) { auto wsHistory = ws->getHistory(); @@ -1116,19 +1117,20 @@ private: auto childHistories = lastAlgHistory->getChildHistories(); std::transform(childHistories.cbegin(), childHistories.cend(), std::back_inserter(algNames), - [](AlgorithmHistory_const_sptr childAlg) { + [](const AlgorithmHistory_const_sptr &childAlg) { return childAlg->name(); }); } else if (!unroll) { - std::transform(algHistories.cbegin(), algHistories.cend(), - std::back_inserter(algNames), - [](AlgorithmHistory_sptr alg) { return alg->name(); }); + std::transform( + algHistories.cbegin(), algHistories.cend(), + std::back_inserter(algNames), + [](const AlgorithmHistory_sptr &alg) { return alg->name(); }); } TS_ASSERT_EQUALS(algNames, expected); } void checkHistoryAlgorithmProperties( - MatrixWorkspace_sptr ws, size_t toplevelIdx, size_t childIdx, + const MatrixWorkspace_sptr &ws, size_t toplevelIdx, size_t childIdx, std::map<std::string, std::string> const &expected) { auto parentHist = ws->getHistory().getAlgorithmHistory(toplevelIdx); auto childHistories = parentHist->getChildHistories(); diff --git a/Framework/Algorithms/test/ReflectometryReductionOneAuto2Test.h b/Framework/Algorithms/test/ReflectometryReductionOneAuto2Test.h index 7c41d3fbc7bf35b28ba83de2c06a4692398423e5..38595e0e82eb20039485c8cbfea9e3543f023e0f 100644 --- a/Framework/Algorithms/test/ReflectometryReductionOneAuto2Test.h +++ b/Framework/Algorithms/test/ReflectometryReductionOneAuto2Test.h @@ -1680,9 +1680,8 @@ public: } private: - MatrixWorkspace_sptr - createFloodWorkspace(Mantid::Geometry::Instrument_const_sptr instrument, - size_t n = 4) { + MatrixWorkspace_sptr createFloodWorkspace( + const Mantid::Geometry::Instrument_const_sptr &instrument, size_t n = 4) { size_t detid = 1; auto flood = create2DWorkspace(int(n), 1); if (n == 4) { diff --git a/Framework/Algorithms/test/ReflectometryReductionOneAuto3Test.h b/Framework/Algorithms/test/ReflectometryReductionOneAuto3Test.h index 23b0201f6bf53bd95e3131456b2c1b2de82eb581..2041bcb2bf2b65226eecb16d0747376d0f861f87 100644 --- a/Framework/Algorithms/test/ReflectometryReductionOneAuto3Test.h +++ b/Framework/Algorithms/test/ReflectometryReductionOneAuto3Test.h @@ -1594,9 +1594,8 @@ public: } private: - MatrixWorkspace_sptr - createFloodWorkspace(Mantid::Geometry::Instrument_const_sptr instrument, - size_t n = 4) { + MatrixWorkspace_sptr createFloodWorkspace( + const Mantid::Geometry::Instrument_const_sptr &instrument, size_t n = 4) { size_t detid = 1; auto flood = create2DWorkspace(int(n), 1); if (n == 4) { diff --git a/Framework/Algorithms/test/ReflectometrySumInQTest.h b/Framework/Algorithms/test/ReflectometrySumInQTest.h index 0dd4fdcb4d0253625e75efdece79c551ff88b4c8..08f40af60478f3ca42e6dd8387a404ba060a8bff 100644 --- a/Framework/Algorithms/test/ReflectometrySumInQTest.h +++ b/Framework/Algorithms/test/ReflectometrySumInQTest.h @@ -29,7 +29,7 @@ public: static void destroySuite(ReflectometrySumInQTest *suite) { delete suite; } static Mantid::API::MatrixWorkspace_sptr - convertToWavelength(Mantid::API::MatrixWorkspace_sptr ws) { + convertToWavelength(const Mantid::API::MatrixWorkspace_sptr &ws) { using namespace Mantid; auto toWavelength = API::AlgorithmManager::Instance().createUnmanaged("ConvertUnits"); @@ -44,7 +44,7 @@ public: } static Mantid::API::MatrixWorkspace_sptr - detectorsOnly(Mantid::API::MatrixWorkspace_sptr ws) { + detectorsOnly(const Mantid::API::MatrixWorkspace_sptr &ws) { using namespace Mantid; auto &specturmInfo = ws->spectrumInfo(); std::vector<size_t> detectorIndices; diff --git a/Framework/Algorithms/test/RemoveLowResTOFTest.h b/Framework/Algorithms/test/RemoveLowResTOFTest.h index 5e7b3aab3fd83f01cb5446c035acc2d0dedad20c..d332578bed373a603676f13a03bbd1c1946f3f69 100644 --- a/Framework/Algorithms/test/RemoveLowResTOFTest.h +++ b/Framework/Algorithms/test/RemoveLowResTOFTest.h @@ -31,7 +31,7 @@ private: int NUMPIXELS; int NUMBINS; - void makeFakeEventWorkspace(std::string wsName) { + void makeFakeEventWorkspace(const std::string &wsName) { // Make an event workspace with 2 events in each bin. EventWorkspace_sptr test_in = WorkspaceCreationHelper::createEventWorkspace( NUMPIXELS, NUMBINS, NUMBINS, 0.0, BIN_DELTA, 2); diff --git a/Framework/Algorithms/test/RemoveMaskedSpectraTest.h b/Framework/Algorithms/test/RemoveMaskedSpectraTest.h index 9bda9c5894ae54cb149bd2d2418b1eced31a5a00..8d182e7a87aca95db1efb99421d37029b032bbf1 100644 --- a/Framework/Algorithms/test/RemoveMaskedSpectraTest.h +++ b/Framework/Algorithms/test/RemoveMaskedSpectraTest.h @@ -106,7 +106,7 @@ private: return space; } - void maskWorkspace(MatrixWorkspace_sptr ws) { + void maskWorkspace(const MatrixWorkspace_sptr &ws) { std::vector<int> spectra(3); spectra[0] = 1; spectra[1] = 3; @@ -119,8 +119,8 @@ private: } MatrixWorkspace_sptr - runAlgorithm(MatrixWorkspace_sptr inputWS, - MatrixWorkspace_sptr maskedWS = MatrixWorkspace_sptr()) { + runAlgorithm(const MatrixWorkspace_sptr &inputWS, + const MatrixWorkspace_sptr &maskedWS = MatrixWorkspace_sptr()) { // Name of the output workspace. std::string outWSName("RemoveMaskedSpectraTest_OutputWS"); diff --git a/Framework/Algorithms/test/RemovePromptPulseTest.h b/Framework/Algorithms/test/RemovePromptPulseTest.h index 83f907853a6762b4d301a83da0d8652530c1f243..e21a5651c8c481332d79589bc8c4b8b70a93e06b 100644 --- a/Framework/Algorithms/test/RemovePromptPulseTest.h +++ b/Framework/Algorithms/test/RemovePromptPulseTest.h @@ -32,7 +32,7 @@ private: std::string inWSName; std::string outWSName; - void makeFakeEventWorkspace(std::string wsName) { + void makeFakeEventWorkspace(const std::string &wsName) { // Make an event workspace with 2 events in each bin. EventWorkspace_sptr test_in = WorkspaceCreationHelper::createEventWorkspace( NUMPIXELS, NUMBINS, NUMEVENTS, 1000., BIN_DELTA, 2); diff --git a/Framework/Algorithms/test/RemoveWorkspaceHistoryTest.h b/Framework/Algorithms/test/RemoveWorkspaceHistoryTest.h index 7ca2bdcfd94cea892ce1673b944c19657b08f885..81ff558e5e32928516f89fbb1e7f8ac6df267579 100644 --- a/Framework/Algorithms/test/RemoveWorkspaceHistoryTest.h +++ b/Framework/Algorithms/test/RemoveWorkspaceHistoryTest.h @@ -64,7 +64,7 @@ private: } }; - void createWorkspace(std::string wsName) { + void createWorkspace(const std::string &wsName) { // create a fake workspace for testing boost::shared_ptr<WorkspaceTester> input = boost::make_shared<WorkspaceTester>(); diff --git a/Framework/Algorithms/test/ReplaceSpecialValuesTest.h b/Framework/Algorithms/test/ReplaceSpecialValuesTest.h index 322e88fbf98e476ddbeb2af118a1b5d7178174f8..ff1ef4fe38df6dde1db5ca7edd60c9a1fda377fd 100644 --- a/Framework/Algorithms/test/ReplaceSpecialValuesTest.h +++ b/Framework/Algorithms/test/ReplaceSpecialValuesTest.h @@ -247,8 +247,9 @@ public: AnalysisDataService::Instance().remove("InputWS"); } - void checkValues(MatrixWorkspace_sptr inputWS, MatrixWorkspace_sptr result, - bool naNCheck, bool infCheck) { + void checkValues(const MatrixWorkspace_sptr &inputWS, + const MatrixWorkspace_sptr &result, bool naNCheck, + bool infCheck) { for (size_t i = 0; i < result->getNumberHistograms(); ++i) { for (int j = 1; j < 5; ++j) { diff --git a/Framework/Algorithms/test/ResampleXTest.h b/Framework/Algorithms/test/ResampleXTest.h index 10eca45e800be2f7659d376bde8deccfee183d00..bb64a2500391e63add5f7ab23d0c17b0ca0125db 100644 --- a/Framework/Algorithms/test/ResampleXTest.h +++ b/Framework/Algorithms/test/ResampleXTest.h @@ -221,7 +221,6 @@ public: vector<double> xmins = alg.getProperty("XMin"); vector<double> xmaxs = alg.getProperty("XMax"); int nBins = alg.getProperty("NumberBins"); - double deltaBin; // Define tolerance for ASSERT_DELTA double tolerance = 1.0e-10; @@ -230,7 +229,8 @@ public: for (int yIndex = 0; yIndex < ylen; ++yIndex) { // The bin width for the current spectrum - deltaBin = (xmaxs[yIndex] - xmins[yIndex]) / static_cast<double>(nBins); + double deltaBin = + (xmaxs[yIndex] - xmins[yIndex]) / static_cast<double>(nBins); // Check the axes lengths TS_ASSERT_EQUALS(outWS->x(yIndex).size(), nBins + 1); @@ -344,7 +344,6 @@ public: vector<double> xmins = alg.getProperty("XMin"); vector<double> xmaxs = alg.getProperty("XMax"); int nBins = alg.getProperty("NumberBins"); - double deltaBin; // Define tolerance for ASSERT_DELTA double tolerance = 1.0e-10; @@ -354,7 +353,8 @@ public: for (int yIndex = 0; yIndex < ylen; ++yIndex) { // The bin width for the current spectrum - deltaBin = (xmaxs[yIndex] - xmins[yIndex]) / static_cast<double>(nBins); + double deltaBin = + (xmaxs[yIndex] - xmins[yIndex]) / static_cast<double>(nBins); // Check the axes lengths TS_ASSERT_EQUALS(outWS->x(yIndex).size(), nBins + 1); diff --git a/Framework/Algorithms/test/RingProfileTest.h b/Framework/Algorithms/test/RingProfileTest.h index 725ed7fbb384b73fa7518e28af1960f9f2493edc..3580725c7c232e49a8c2d9a46b817019a8aa22ef 100644 --- a/Framework/Algorithms/test/RingProfileTest.h +++ b/Framework/Algorithms/test/RingProfileTest.h @@ -41,12 +41,12 @@ public: // centre must be 2 or 3 values (x,y) or (x,y,z) std::vector<double> justOne(1); justOne[0] = -0.35; - // TS_ASSERT_THROWS(alg.setProperty("Centre",justOne), - // const std::invalid_argument &); + TS_ASSERT_THROWS(alg.setProperty("Centre", justOne), + const std::invalid_argument &); std::vector<double> fourInputs(4, -0.45); - // TS_ASSERT_THROWS(alg.setProperty("Centre", fourInputs), - // const std::invalid_argument &); + TS_ASSERT_THROWS(alg.setProperty("Centre", fourInputs), + const std::invalid_argument &); TS_ASSERT_THROWS_NOTHING( alg.setPropertyValue("OutputWorkspace", outWSName)); diff --git a/Framework/Algorithms/test/RunCombinationHelperTest.h b/Framework/Algorithms/test/RunCombinationHelperTest.h index f969377a6ea794d3b75619e10ec31f72c9412c8d..e2319d0eefe4615a7ed86f452a11d99cc47e104f 100644 --- a/Framework/Algorithms/test/RunCombinationHelperTest.h +++ b/Framework/Algorithms/test/RunCombinationHelperTest.h @@ -187,7 +187,7 @@ public: } private: - void setUnits(MatrixWorkspace_sptr ws) { + void setUnits(const MatrixWorkspace_sptr &ws) { ws->getAxis(0)->unit() = UnitFactory::Instance().create("TOF"); ws->getAxis(1)->unit() = UnitFactory::Instance().create("Momentum"); ws->setYUnit("Counts"); diff --git a/Framework/Algorithms/test/SANSCollimationLengthEstimatorTest.h b/Framework/Algorithms/test/SANSCollimationLengthEstimatorTest.h index a950bb69a8582eda616f6f203e5ea70c109c5748..8ee9edd6fa851d536185c2a73151e19067b511e8 100644 --- a/Framework/Algorithms/test/SANSCollimationLengthEstimatorTest.h +++ b/Framework/Algorithms/test/SANSCollimationLengthEstimatorTest.h @@ -9,6 +9,8 @@ #include "MantidAlgorithms/SANSCollimationLengthEstimator.h" #include <cxxtest/TestSuite.h> +#include <utility> + #include "MantidGeometry/Instrument.h" #include "MantidGeometry/Instrument/Detector.h" #include "MantidGeometry/Objects/CSGObject.h" @@ -71,8 +73,8 @@ createTestInstrument(const Mantid::detid_t id, * Set the instrument parameters */ void setInstrumentParametersForTOFSANS( - const Mantid::API::MatrixWorkspace_sptr ws, std::string methodType = "", - double collimationLengthCorrection = 20, + const Mantid::API::MatrixWorkspace_sptr &ws, + const std::string &methodType = "", double collimationLengthCorrection = 20, double collimationLengthIncrement = 2, double guideCutoff = 130, double numberOfGuides = 5) { auto &pmap = ws->instrumentParameters(); @@ -106,8 +108,8 @@ void setInstrumentParametersForTOFSANS( /* * Add a timer series sample log */ -void addSampleLog(Mantid::API::MatrixWorkspace_sptr workspace, - std::string sampleLogName, double value, +void addSampleLog(const Mantid::API::MatrixWorkspace_sptr &workspace, + const std::string &sampleLogName, double value, unsigned int length) { auto timeSeries = new Mantid::Kernel::TimeSeriesProperty<double>(sampleLogName); @@ -124,7 +126,7 @@ void addSampleLog(Mantid::API::MatrixWorkspace_sptr workspace, */ Mantid::API::MatrixWorkspace_sptr createTestWorkspace( const size_t nhist, const double x0, const double x1, const double dx, - std::string methodType = "", double collimationLengthCorrection = 20, + const std::string &methodType = "", double collimationLengthCorrection = 20, double collimationLengthIncrement = 2, double guideCutoff = 130, double numberOfGuides = 5, V3D sourcePosition = V3D(0.0, 0.0, -25.0), V3D samplePosition = V3D(0.0, 0.0, 0.0), @@ -142,8 +144,8 @@ Mantid::API::MatrixWorkspace_sptr createTestWorkspace( // Set the instrument parameters setInstrumentParametersForTOFSANS( - ws2d, methodType, collimationLengthCorrection, collimationLengthIncrement, - guideCutoff, numberOfGuides); + ws2d, std::move(methodType), collimationLengthCorrection, + collimationLengthIncrement, guideCutoff, numberOfGuides); // Add sample log details if (!guideLogDetails.empty()) { diff --git a/Framework/Algorithms/test/SampleLogsBehaviourTest.h b/Framework/Algorithms/test/SampleLogsBehaviourTest.h index 6feaafde477818b56b4ca77f6af31d1fe579a142..3cc82415ad85894cd16e19cfb99b924ee337d026 100644 --- a/Framework/Algorithms/test/SampleLogsBehaviourTest.h +++ b/Framework/Algorithms/test/SampleLogsBehaviourTest.h @@ -221,7 +221,7 @@ public: return ws; } - void testLogUnits(MatrixWorkspace_sptr ws) { + void testLogUnits(const MatrixWorkspace_sptr &ws) { // All units must not have changed: TS_ASSERT_EQUALS(ws->getLog("A")->units(), "A_unit") TS_ASSERT_EQUALS(ws->getLog("B")->units(), "B_unit") diff --git a/Framework/Algorithms/test/SassenaFFTTest.h b/Framework/Algorithms/test/SassenaFFTTest.h index 02725308399d37568b37fa9f3652ea1f7f16c211..575614655df6803eaef1c98dc986764b04012675 100644 --- a/Framework/Algorithms/test/SassenaFFTTest.h +++ b/Framework/Algorithms/test/SassenaFFTTest.h @@ -176,7 +176,6 @@ private: const double frErr = 1E-03; // allowed fractional error const size_t nspectra = ws->getNumberHistograms(); MantidVec yv, xv; - double factor; // remove the detailed balance condition for (size_t i = 0; i < nspectra; i++) { double goldStandard = ps2meV * (1 + static_cast<double>(i)) * @@ -186,7 +185,7 @@ private: size_t index = nbins / 2; // This position should yield ws->readX(i).at(index)==0.0 double x = ws->readX(i).at(index); - factor = exp(exponentFactor * x); + double factor = exp(exponentFactor * x); double h = yv.at(index) * exp(x); xv = ws->readX(i); MantidVec::iterator itx = xv.begin(); @@ -212,9 +211,8 @@ private: */ void Gaussian(MantidVec &xv, MantidVec &yv, const double &Heigth, const double &sigma) { - double z; for (size_t i = 0; i < xv.size(); i++) { - z = xv[i] / sigma; + double z = xv[i] / sigma; yv[i] = Heigth * exp(-z * z / 2.0); } } // void Gaussian @@ -250,12 +248,11 @@ private: xv.emplace_back(dt * static_cast<double>(j)); } - double sigma; MantidVec yv(nbins); // each spectra is a gaussian of same Height but different stdev for (size_t i = 0; i < nspectra; i++) { ws->mutableX(i) = xv; - sigma = sigma0 / (1 + static_cast<double>(i)); + double sigma = sigma0 / (1 + static_cast<double>(i)); this->Gaussian(xv, yv, Heigth, sigma); ws->mutableY(i) = yv; } diff --git a/Framework/Algorithms/test/ScaleTest.h b/Framework/Algorithms/test/ScaleTest.h index 08df28cbaef79bdc53831ab0ee166814e9da4da9..973f48ebc645eca819f5c1a5bb9843aa42906f0e 100644 --- a/Framework/Algorithms/test/ScaleTest.h +++ b/Framework/Algorithms/test/ScaleTest.h @@ -127,7 +127,7 @@ private: } } - void doTestScaleWithDx(std::string type, bool outIsIn = false) { + void doTestScaleWithDx(const std::string &type, bool outIsIn = false) { // Arrange const double xValue = 1.222; const double value = 5; diff --git a/Framework/Algorithms/test/SetInstrumentParameterTest.h b/Framework/Algorithms/test/SetInstrumentParameterTest.h index b718fba691a09e3d44024824a3e4101b07720310..7da3ec3c0c43653401003b55f3346ae955e678ca 100644 --- a/Framework/Algorithms/test/SetInstrumentParameterTest.h +++ b/Framework/Algorithms/test/SetInstrumentParameterTest.h @@ -173,10 +173,10 @@ public: } MatrixWorkspace_sptr - ExecuteAlgorithm(MatrixWorkspace_sptr testWS, std::string cmptName, - std::string detList, std::string paramName, - std::string paramValue, std::string paramType = "", - bool fails = false) { + ExecuteAlgorithm(MatrixWorkspace_sptr testWS, const std::string &cmptName, + const std::string &detList, const std::string ¶mName, + const std::string ¶mValue, + const std::string ¶mType = "", bool fails = false) { // add the workspace to the ADS AnalysisDataService::Instance().addOrReplace( "SetInstrumentParameter_Temporary", testWS); diff --git a/Framework/Algorithms/test/ShiftLogTimeTest.h b/Framework/Algorithms/test/ShiftLogTimeTest.h index b827da4744f2ff01b52a3b9a42ca2cfdd32b1043..64a2111fe9bc2436c6c01a0e780e7fbea9b3640c 100644 --- a/Framework/Algorithms/test/ShiftLogTimeTest.h +++ b/Framework/Algorithms/test/ShiftLogTimeTest.h @@ -61,7 +61,7 @@ private: * @param in_name Name of the input workspace. * @param out_name Name of the output workspace. */ - void verify(const std::string in_name, const std::string out_name, + void verify(const std::string &in_name, const std::string &out_name, const int shift) { DateAndTime start(start_str); diff --git a/Framework/Algorithms/test/SmoothNeighboursTest.h b/Framework/Algorithms/test/SmoothNeighboursTest.h index 317f8eb0442d7068020e2601ba1408d2cad2eca8..39ede25745d951215e9a66babd91ad89e57189ea 100644 --- a/Framework/Algorithms/test/SmoothNeighboursTest.h +++ b/Framework/Algorithms/test/SmoothNeighboursTest.h @@ -21,7 +21,7 @@ using namespace Mantid::Algorithms; class SmoothNeighboursTest : public CxxTest::TestSuite { public: - void doTestWithNumberOfNeighbours(std::string WeightedSum = "Flat") { + void doTestWithNumberOfNeighbours(const std::string &WeightedSum = "Flat") { MatrixWorkspace_sptr inWS = WorkspaceCreationHelper::create2DWorkspaceWithFullInstrument(100, 10); @@ -75,7 +75,7 @@ public: } void do_test_non_uniform(EventType type, double *expectedY, - std::string WeightedSum = "Parabolic", + const std::string &WeightedSum = "Parabolic", bool PreserveEvents = true, double Radius = 0.001, bool ConvertTo2D = false, int numberOfNeighbours = 8) { @@ -158,7 +158,7 @@ public: } void do_test_rectangular(EventType type, double *expectedY, - std::string WeightedSum = "Parabolic", + const std::string &WeightedSum = "Parabolic", bool PreserveEvents = true, bool ConvertTo2D = false) { // Pixels will be spaced 0.008 apart. diff --git a/Framework/Algorithms/test/SofQCommonTest.h b/Framework/Algorithms/test/SofQCommonTest.h index 46ee0e873b8545b8f652aebfcd97ef34ee11c6be..d2aae6161915092f9bd60b6a3703590489e4ae7a 100644 --- a/Framework/Algorithms/test/SofQCommonTest.h +++ b/Framework/Algorithms/test/SofQCommonTest.h @@ -257,7 +257,7 @@ private: return std::sqrt(ki * ki + kf * kf - 2. * ki * kf * std::cos(twoTheta)); } - static void setEFixed(Mantid::API::MatrixWorkspace_sptr ws, + static void setEFixed(const Mantid::API::MatrixWorkspace_sptr &ws, const std::string &component, const double eFixed) { using namespace Mantid; auto alg = API::AlgorithmManager::Instance().createUnmanaged( diff --git a/Framework/Algorithms/test/SofQWNormalisedPolygonTest.h b/Framework/Algorithms/test/SofQWNormalisedPolygonTest.h index eaa457965e3c10e72098c8f847b74959a5f1bb4f..88c965eb97bc846e232c37df3b48f81cd5eba9c1 100644 --- a/Framework/Algorithms/test/SofQWNormalisedPolygonTest.h +++ b/Framework/Algorithms/test/SofQWNormalisedPolygonTest.h @@ -236,6 +236,7 @@ public: TS_ASSERT_THROWS_NOTHING(alg.setProperty("EMode", "Indirect")) TS_ASSERT_THROWS_NOTHING(alg.setProperty("EFixed", 1.84)) const double dE{0.3}; + // cppcheck-suppress unreadVariable const std::vector<double> eBinParams{dE}; std::vector<double> expectedEBinEdges; const auto firstEdge = inWS->x(0).front(); @@ -364,9 +365,10 @@ public: * @param twoThetaRanges input table workspace * @return the algorithm object */ - IAlgorithm_sptr setUpAlg( - Mantid::API::MatrixWorkspace_sptr const inputWS, - boost::shared_ptr<Mantid::DataObjects::TableWorkspace> twoThetaRanges) { + IAlgorithm_sptr + setUpAlg(Mantid::API::MatrixWorkspace_sptr const &inputWS, + const boost::shared_ptr<Mantid::DataObjects::TableWorkspace> + &twoThetaRanges) { const std::vector<double> qBinParams{0.023}; IAlgorithm_sptr alg = AlgorithmManager::Instance().create("SofQWNormalisedPolygon"); @@ -384,7 +386,7 @@ public: * @return A pointer to the table workspace */ boost::shared_ptr<Mantid::DataObjects::TableWorkspace> - createTableWorkspace(const std::vector<std::string> dataTypes, + createTableWorkspace(const std::vector<std::string> &dataTypes, const int rowCount) { auto twoThetaRanges = boost::make_shared<TableWorkspace>(); std::vector<std::string> names = {"Detector ID", "Max two theta", diff --git a/Framework/Algorithms/test/SolidAngleTest.h b/Framework/Algorithms/test/SolidAngleTest.h index 649d35707bb3a2fd7cff740ca3ac5207a276c9ac..dc64b47dd9d8f3e508f2be42440b17c5824b4f40 100644 --- a/Framework/Algorithms/test/SolidAngleTest.h +++ b/Framework/Algorithms/test/SolidAngleTest.h @@ -213,7 +213,7 @@ public: auto spectrumInfo2 = output2D_2->spectrumInfo(); for (size_t i = 0; i < numberOfSpectra1; i++) { // all values after the start point of the second workspace should match - if (!(spectrumInfo2.isMasked(i) || spectrumInfo2.isMasked(i))) { + if (!(spectrumInfo1.isMasked(i) || spectrumInfo2.isMasked(i))) { TS_ASSERT_EQUALS(output2D_1->y(i)[0], output2D_2->y(i)[0]); } } diff --git a/Framework/Algorithms/test/SpecularReflectionAlgorithmTest.h b/Framework/Algorithms/test/SpecularReflectionAlgorithmTest.h index 740e27ac27c6ba60f10dd80db5d9db26e40bf103..45e7009a10f72edace3376620e0d9c15e88fc0a8 100644 --- a/Framework/Algorithms/test/SpecularReflectionAlgorithmTest.h +++ b/Framework/Algorithms/test/SpecularReflectionAlgorithmTest.h @@ -68,7 +68,8 @@ protected: } VerticalHorizontalOffsetType determine_vertical_and_horizontal_offsets( - MatrixWorkspace_sptr ws, std::string detectorName = "point-detector") { + const MatrixWorkspace_sptr &ws, + const std::string &detectorName = "point-detector") { auto instrument = ws->getInstrument(); const V3D pointDetector = instrument->getComponentByName(detectorName)->getPos(); diff --git a/Framework/Algorithms/test/SpecularReflectionPositionCorrectTest.h b/Framework/Algorithms/test/SpecularReflectionPositionCorrectTest.h index d2d7c5edc44f58dd61f37000c13a13d701a4b149..3f91a26dd6d820dc23b0d9a1250ef29b080285d3 100644 --- a/Framework/Algorithms/test/SpecularReflectionPositionCorrectTest.h +++ b/Framework/Algorithms/test/SpecularReflectionPositionCorrectTest.h @@ -15,6 +15,7 @@ #include "MantidKernel/V3D.h" #include "MantidTestHelpers/WorkspaceCreationHelper.h" #include <cmath> +#include <utility> using Mantid::Algorithms::SpecularReflectionPositionCorrect; using namespace Mantid::API; @@ -181,9 +182,9 @@ public: sampleToDetectorBeamOffset, 1e-6); } - void - do_test_correct_point_detector_position(std::string detectorFindProperty = "", - std::string stringValue = "") { + void do_test_correct_point_detector_position( + const std::string &detectorFindProperty = "", + const std::string &stringValue = "") { MatrixWorkspace_sptr toConvert = pointDetectorWS; const double thetaInDegrees = 10.0; // Desired theta in degrees. @@ -240,8 +241,8 @@ public: } double do_test_correct_line_detector_position( - std::vector<int> specNumbers, double thetaInDegrees, - std::string detectorName = "lineardetector", + const std::vector<int> &specNumbers, double thetaInDegrees, + const std::string &detectorName = "lineardetector", bool strictSpectrumCheck = true) { auto toConvert = this->linearDetectorWS; @@ -258,7 +259,7 @@ public: VerticalHorizontalOffsetType offsetTupleCorrected = determine_vertical_and_horizontal_offsets( - corrected, detectorName); // Positions after correction + corrected, std::move(detectorName)); // Positions after correction const double sampleToDetectorVerticalOffsetCorrected = offsetTupleCorrected.get<0>(); diff --git a/Framework/Algorithms/test/Stitch1DManyTest.h b/Framework/Algorithms/test/Stitch1DManyTest.h index 5b0252dabdc76cf51ec4aa39efc128ab8e216507..bacff25f1164adbcd032ea793de476dd7b8626e7 100644 --- a/Framework/Algorithms/test/Stitch1DManyTest.h +++ b/Framework/Algorithms/test/Stitch1DManyTest.h @@ -45,7 +45,7 @@ private: * @param outWSName :: output workspace name used if running CreateWorkspace */ void createUniformWorkspace(double xstart, double deltax, double value1, - double value2, std::string outWSName, + double value2, const std::string &outWSName, bool runAlg = false) { const int nbins = 10; @@ -108,7 +108,8 @@ private: * @param inputWSNames :: input workspaces names * @param outputWSName :: output workspace name */ - void doGroupWorkspaces(std::string inputWSNames, std::string outWSName) { + void doGroupWorkspaces(const std::string &inputWSNames, + const std::string &outWSName) { GroupWorkspaces gw; gw.initialize(); gw.setProperty("InputWorkspaces", inputWSNames); @@ -123,7 +124,7 @@ private: * @param inputWS :: the input workspace * @return vector of names of algorithm histories */ - std::vector<std::string> getHistory(MatrixWorkspace_sptr inputWS) { + std::vector<std::string> getHistory(const MatrixWorkspace_sptr &inputWS) { std::vector<std::string> histNames; auto histories = inputWS->history().getAlgorithmHistories(); for (auto &hist : histories) { diff --git a/Framework/Algorithms/test/SumOverlappingTubesTest.h b/Framework/Algorithms/test/SumOverlappingTubesTest.h index f64ce4b756266372c56920e08cf77be489884c9a..af23cd66dd389bfadb652d3b4a486ed105a7e09c 100644 --- a/Framework/Algorithms/test/SumOverlappingTubesTest.h +++ b/Framework/Algorithms/test/SumOverlappingTubesTest.h @@ -34,8 +34,8 @@ using namespace Mantid::Types::Core; namespace { MatrixWorkspace_sptr createTestScanningWS(size_t nTubes, size_t nPixelsPerTube, - std::vector<double> rotations, - std::string name = "testWS") { + const std::vector<double> &rotations, + const std::string &name = "testWS") { const auto instrument = ComponentCreationHelper::createInstrumentWithPSDTubes( nTubes, nPixelsPerTube, true); size_t nTimeIndexes = rotations.size(); @@ -131,7 +131,7 @@ public: TS_ASSERT_DELTA(yAxis->getValue(i), 0.003 * double(i), 1e-6) } - void verifySpectraHaveSameCounts(MatrixWorkspace_sptr outWS, + void verifySpectraHaveSameCounts(const MatrixWorkspace_sptr &outWS, double expectedCounts = 2.0, double expectedErrors = sqrt(2.0), bool checkErrors = true) { @@ -143,7 +143,7 @@ public: } } - void verifySpectraCountsForScan(MatrixWorkspace_sptr outWS) { + void verifySpectraCountsForScan(const MatrixWorkspace_sptr &outWS) { size_t bin = 0; for (size_t j = 0; j < N_PIXELS_PER_TUBE; ++j) { TS_ASSERT_DELTA(outWS->getSpectrum(j).y()[bin], 2.0, 1e-6) @@ -697,9 +697,8 @@ public: auto outWS = boost::dynamic_pointer_cast<Mantid::API::MatrixWorkspace>( AnalysisDataService::Instance().retrieve("outWS")); - const auto &xAxis = outWS->getAxis(0); - TS_ASSERT_EQUALS(xAxis->length(), 296) - const auto &yAxis = outWS->getAxis(1); + auto yAxis = outWS->getAxis(1); + TS_ASSERT_EQUALS(outWS->getAxis(0)->length(), 296) TS_ASSERT_EQUALS(yAxis->length(), 256) for (size_t i = 0; i < 256; i++) { @@ -735,9 +734,8 @@ public: auto outWS = boost::dynamic_pointer_cast<Mantid::API::MatrixWorkspace>( AnalysisDataService::Instance().retrieve("outWS")); - const auto &xAxis = outWS->getAxis(0); - TS_ASSERT_EQUALS(xAxis->length(), 296) - const auto &yAxis = outWS->getAxis(1); + auto yAxis = outWS->getAxis(1); + TS_ASSERT_EQUALS(outWS->getAxis(0)->length(), 296) TS_ASSERT_EQUALS(yAxis->length(), 256) for (size_t i = 0; i < 256; i++) { diff --git a/Framework/Algorithms/test/SumSpectraTest.h b/Framework/Algorithms/test/SumSpectraTest.h index 1e8066de1e9149e9ea58bad086a83d883806c6cc..664c39b90ea42fbdb745a723d4a78c058fc439cc 100644 --- a/Framework/Algorithms/test/SumSpectraTest.h +++ b/Framework/Algorithms/test/SumSpectraTest.h @@ -277,8 +277,8 @@ public: const std::runtime_error &); } - void dotestExecEvent(std::string inName, std::string outName, - std::string indices_list) { + void dotestExecEvent(const std::string &inName, const std::string &outName, + const std::string &indices_list) { int numPixels = 100; int numBins = 20; int numEvents = 20; @@ -568,7 +568,6 @@ public: testSig = std::sqrt(testSig); // Set the properties alg2.setProperty("InputWorkspace", tws); - const std::string outputSpace2 = "SumSpectraOut2"; alg2.setPropertyValue("OutputWorkspace", outName); alg2.setProperty("IncludeMonitors", false); alg2.setProperty("WeightedSum", true); diff --git a/Framework/Algorithms/test/TOFSANSResolutionByPixelTest.h b/Framework/Algorithms/test/TOFSANSResolutionByPixelTest.h index 5c5c039c30cfa9378ed5f391d20dccafa24a5f1e..38dee4681567ffd99cd9f40ca7186b98cd16e888 100644 --- a/Framework/Algorithms/test/TOFSANSResolutionByPixelTest.h +++ b/Framework/Algorithms/test/TOFSANSResolutionByPixelTest.h @@ -22,6 +22,7 @@ #include "boost/shared_ptr.hpp" #include <stdexcept> +#include <utility> using namespace Mantid::Algorithms; using Mantid::Kernel::V3D; @@ -82,8 +83,8 @@ createTestInstrument(const Mantid::detid_t id, * Set the instrument parameters */ void setInstrumentParametersForTOFSANS( - const Mantid::API::MatrixWorkspace_sptr ws, std::string methodType = "", - double collimationLengthCorrection = 20, + const Mantid::API::MatrixWorkspace_sptr &ws, + const std::string &methodType = "", double collimationLengthCorrection = 20, double collimationLengthIncrement = 2, double guideCutoff = 130, double numberOfGuides = 5) { auto &pmap = ws->instrumentParameters(); @@ -117,8 +118,8 @@ void setInstrumentParametersForTOFSANS( /* * Add a timer series sample log */ -void addSampleLog(Mantid::API::MatrixWorkspace_sptr workspace, - std::string sampleLogName, double value, +void addSampleLog(const Mantid::API::MatrixWorkspace_sptr &workspace, + const std::string &sampleLogName, double value, unsigned int length) { auto timeSeries = new Mantid::Kernel::TimeSeriesProperty<double>(sampleLogName); @@ -135,7 +136,7 @@ void addSampleLog(Mantid::API::MatrixWorkspace_sptr workspace, */ Mantid::API::MatrixWorkspace_sptr createTestWorkspace( const size_t nhist, const double x0, const double x1, const double dx, - std::string methodType = "", bool isModerator = false, + const std::string &methodType = "", bool isModerator = false, double collimationLengthCorrection = 20, double collimationLengthIncrement = 2, double guideCutoff = 130, double numberOfGuides = 5, V3D sourcePosition = V3D(0.0, 0.0, -25.0), @@ -163,8 +164,8 @@ Mantid::API::MatrixWorkspace_sptr createTestWorkspace( // Set the instrument parameters setInstrumentParametersForTOFSANS( - ws2d, methodType, collimationLengthCorrection, collimationLengthIncrement, - guideCutoff, numberOfGuides); + ws2d, std::move(methodType), collimationLengthCorrection, + collimationLengthIncrement, guideCutoff, numberOfGuides); // Add sample log details if (!guideLogDetails.empty()) { diff --git a/Framework/Algorithms/test/UnwrapMonitorTest.h b/Framework/Algorithms/test/UnwrapMonitorTest.h index 009a150a6b0960ad2fcb165fb30ebe8ea1ccd6c0..dd1193aae0da8bc5e38e149f241df72fae125dbb 100644 --- a/Framework/Algorithms/test/UnwrapMonitorTest.h +++ b/Framework/Algorithms/test/UnwrapMonitorTest.h @@ -175,7 +175,7 @@ private: // Run the algorithm and do some basic checks. Returns the output workspace. MatrixWorkspace_const_sptr - runAlgorithm(UnwrapMonitor &algo, const MatrixWorkspace_const_sptr inWS) { + runAlgorithm(UnwrapMonitor &algo, const MatrixWorkspace_const_sptr &inWS) { // run the algorithm TS_ASSERT(algo.execute()); TS_ASSERT(algo.isExecuted()); diff --git a/Framework/Algorithms/test/UnwrapSNSTest.h b/Framework/Algorithms/test/UnwrapSNSTest.h index 9afb0ca1ecf5fff37d41f6de90f77fb7af97a29b..15838fe963cf43899a1deaf80e9bc02ee88e5912 100644 --- a/Framework/Algorithms/test/UnwrapSNSTest.h +++ b/Framework/Algorithms/test/UnwrapSNSTest.h @@ -29,7 +29,7 @@ private: int NUMPIXELS; int NUMBINS; - void makeFakeEventWorkspace(std::string wsName) { + void makeFakeEventWorkspace(const std::string &wsName) { // Make an event workspace with 2 events in each bin. EventWorkspace_sptr test_in = WorkspaceCreationHelper::createEventWorkspace( NUMPIXELS, NUMBINS, NUMBINS, 0.0, BIN_DELTA, 2); diff --git a/Framework/Algorithms/test/VesuvioL1ThetaResolutionTest.h b/Framework/Algorithms/test/VesuvioL1ThetaResolutionTest.h index f0c1650de4afdf1bc4e58dfb7727455658047e7a..df7d1c9d9030d020c1cb70d4eacf8a0a0dc6fef6 100644 --- a/Framework/Algorithms/test/VesuvioL1ThetaResolutionTest.h +++ b/Framework/Algorithms/test/VesuvioL1ThetaResolutionTest.h @@ -159,7 +159,7 @@ public: } private: - void validateFullResolutionWorkspace(MatrixWorkspace_sptr ws) { + void validateFullResolutionWorkspace(const MatrixWorkspace_sptr &ws) { NumericAxis *xAxis = dynamic_cast<NumericAxis *>(ws->getAxis(0)); TS_ASSERT(xAxis); if (xAxis) { @@ -177,7 +177,7 @@ private: } } - void validateFullDistributionWorkspace(MatrixWorkspace_sptr ws, + void validateFullDistributionWorkspace(const MatrixWorkspace_sptr &ws, const std::string &label) { NumericAxis *xAxis = dynamic_cast<NumericAxis *>(ws->getAxis(0)); TS_ASSERT(xAxis); diff --git a/Framework/Algorithms/test/WienerSmoothTest.h b/Framework/Algorithms/test/WienerSmoothTest.h index ceea1b67bf7015cb1ca60b06636c4a474769e37d..621d07e59b06ab0b71d6efe333887ba9a080a2cd 100644 --- a/Framework/Algorithms/test/WienerSmoothTest.h +++ b/Framework/Algorithms/test/WienerSmoothTest.h @@ -580,7 +580,7 @@ private: } } - MatrixWorkspace_sptr runWienerSmooth(MatrixWorkspace_sptr inputWS, + MatrixWorkspace_sptr runWienerSmooth(const MatrixWorkspace_sptr &inputWS, const std::vector<int> &wsIndexList) { // Name of the output workspace. std::string outWSName("WienerSmoothTest_OutputWS"); diff --git a/Framework/Algorithms/test/WorkspaceGroupTest.h b/Framework/Algorithms/test/WorkspaceGroupTest.h index 6842062876a001a1814bab43f0c0e1c6534db808..f37adda4f3efba15d618576c4b4d94d0e6352597 100644 --- a/Framework/Algorithms/test/WorkspaceGroupTest.h +++ b/Framework/Algorithms/test/WorkspaceGroupTest.h @@ -19,6 +19,7 @@ #include <Poco/File.h> #include <fstream> +#include <utility> using namespace Mantid::API; using namespace Mantid::Kernel; @@ -30,15 +31,18 @@ using Mantid::HistogramData::CountStandardDeviations; class WorkspaceGroupTest : public CxxTest::TestSuite { private: - void checkData(MatrixWorkspace_sptr work_in1, MatrixWorkspace_sptr work_in2, - MatrixWorkspace_sptr work_out1) { + void checkData(const MatrixWorkspace_sptr &work_in1, + const MatrixWorkspace_sptr &work_in2, + const MatrixWorkspace_sptr &work_out1) { // default to a horizontal loop orientation - checkData(work_in1, work_in2, work_out1, 0); + checkData(std::move(work_in1), std::move(work_in2), std::move(work_out1), + 0); } // loopOrientation 0=Horizontal, 1=Vertical - void checkData(MatrixWorkspace_sptr work_in1, MatrixWorkspace_sptr work_in2, - MatrixWorkspace_sptr work_out1, int loopOrientation) { + void checkData(const MatrixWorkspace_sptr &work_in1, + const MatrixWorkspace_sptr &work_in2, + const MatrixWorkspace_sptr &work_out1, int loopOrientation) { if (!work_in1 || !work_in2 || !work_out1) { TSM_ASSERT("One or more empty workspace pointers.", 0); return; @@ -63,9 +67,9 @@ private: } } - void checkDataItem(MatrixWorkspace_sptr work_in1, - MatrixWorkspace_sptr work_in2, - MatrixWorkspace_sptr work_out1, size_t i, + void checkDataItem(const MatrixWorkspace_sptr &work_in1, + const MatrixWorkspace_sptr &work_in2, + const MatrixWorkspace_sptr &work_out1, size_t i, size_t ws2Index) { double sig1 = work_in1->dataY(i / work_in1->blocksize())[i % work_in1->blocksize()]; diff --git a/Framework/Beamline/inc/MantidBeamline/SpectrumInfo.h b/Framework/Beamline/inc/MantidBeamline/SpectrumInfo.h index 67e3b70e76dd3ba21e9f72f111670e0c4709c952..5b6c22de7ee0066fbf7c64d318a91362b2d77ab9 100644 --- a/Framework/Beamline/inc/MantidBeamline/SpectrumInfo.h +++ b/Framework/Beamline/inc/MantidBeamline/SpectrumInfo.h @@ -46,6 +46,7 @@ public: Kernel::cow_ptr<std::vector<SpectrumDefinition>> spectrumDefinition); size_t size() const; + size_t detectorCount() const; const SpectrumDefinition &spectrumDefinition(const size_t index) const; void setSpectrumDefinition(const size_t index, SpectrumDefinition def); diff --git a/Framework/Beamline/src/SpectrumInfo.cpp b/Framework/Beamline/src/SpectrumInfo.cpp index ceac56034cb36f6f255decefaa998c85772c11af..5906a4f48e9a92d04376ea9acf2dccf15621ffbc 100644 --- a/Framework/Beamline/src/SpectrumInfo.cpp +++ b/Framework/Beamline/src/SpectrumInfo.cpp @@ -26,6 +26,15 @@ size_t SpectrumInfo::size() const { return m_spectrumDefinition->size(); } +/// Return count of all detectors used within spectrum +size_t SpectrumInfo::detectorCount() const { + size_t count = 0; + for (const auto &spec : *m_spectrumDefinition) { + count += spec.size(); + } + return count; +} + /// Returns a const reference to the SpectrumDefinition of the spectrum. const SpectrumDefinition & SpectrumInfo::spectrumDefinition(const size_t index) const { diff --git a/Framework/Beamline/test/SpectrumInfoTest.h b/Framework/Beamline/test/SpectrumInfoTest.h index e619efa83203703b252f8ac05c21bb33d760b7b3..e4bb67fefa47e9fc79a65083f903d58e3af85452 100644 --- a/Framework/Beamline/test/SpectrumInfoTest.h +++ b/Framework/Beamline/test/SpectrumInfoTest.h @@ -107,4 +107,17 @@ public: (std::pair<size_t, size_t>(i, 0))); } } + + void test_detectorCount() { + SpectrumDefinition def1; + def1.add(1); + def1.add(2); + SpectrumDefinition def2; + def2.add(1); + SpectrumInfo info{2}; + info.setSpectrumDefinition(0, def1); + info.setSpectrumDefinition(1, def2); + TS_ASSERT_EQUALS(info.size(), 2); + TS_ASSERT_EQUALS(info.detectorCount(), 3); + } }; diff --git a/Framework/Crystal/inc/MantidCrystal/AnvredCorrection.h b/Framework/Crystal/inc/MantidCrystal/AnvredCorrection.h index c886831e0ab3ac5551d4e56ebd88ede851ed4dd8..a2bf815d0ddf5a5bedbe2d2e1052190f971f1dc7 100644 --- a/Framework/Crystal/inc/MantidCrystal/AnvredCorrection.h +++ b/Framework/Crystal/inc/MantidCrystal/AnvredCorrection.h @@ -112,11 +112,11 @@ private: void BuildLamdaWeights(); double absor_sphere(double &twoth, double &wl); void scale_init(const Geometry::IDetector &det, - Geometry::Instrument_const_sptr inst, double &L2, + const Geometry::Instrument_const_sptr &inst, double &L2, double &depth, double &pathlength, std::string &bankName); void scale_exec(std::string &bankName, double &lambda, double &depth, - Geometry::Instrument_const_sptr inst, double &pathlength, - double &value); + const Geometry::Instrument_const_sptr &inst, + double &pathlength, double &value); double m_smu; ///< linear scattering coefficient in 1/cm double m_amu; ///< linear absoprtion coefficient in 1/cm diff --git a/Framework/Crystal/inc/MantidCrystal/CentroidPeaks.h b/Framework/Crystal/inc/MantidCrystal/CentroidPeaks.h index 8aef4a4dbb9a36d1cbea07aa867b4ab33066dc5c..8743887900901e9cab780c0c3e319661a67dcab5 100644 --- a/Framework/Crystal/inc/MantidCrystal/CentroidPeaks.h +++ b/Framework/Crystal/inc/MantidCrystal/CentroidPeaks.h @@ -45,7 +45,7 @@ private: void exec() override; void integrate(); void integrateEvent(); - int findPixelID(std::string bankName, int col, int row); + int findPixelID(const std::string &bankName, int col, int row); void removeEdgePeaks(Mantid::DataObjects::PeaksWorkspace &peakWS); void sizeBanks(const std::string &bankName, int &nCols, int &nRows); Geometry::Instrument_const_sptr inst; diff --git a/Framework/Crystal/inc/MantidCrystal/ConnectedComponentLabeling.h b/Framework/Crystal/inc/MantidCrystal/ConnectedComponentLabeling.h index 4a8becae3d7f5f26e4b21a8f487da3b61af3db8f..f1eca3a25e337651c35edb51d7fb312974dcb2ac 100644 --- a/Framework/Crystal/inc/MantidCrystal/ConnectedComponentLabeling.h +++ b/Framework/Crystal/inc/MantidCrystal/ConnectedComponentLabeling.h @@ -49,8 +49,9 @@ class MANTID_CRYSTAL_DLL ConnectedComponentLabeling { public: /// Constructor - ConnectedComponentLabeling(const size_t &startId = 1, - const boost::optional<int> nThreads = boost::none); + ConnectedComponentLabeling( + const size_t &startId = 1, + const boost::optional<int> &nThreads = boost::none); /// Getter for the start label id size_t getStartLabelId() const; @@ -79,7 +80,7 @@ private: /// Calculate the disjoint element tree across the image. ConnectedComponentMappingTypes::ClusterMap - calculateDisjointTree(Mantid::API::IMDHistoWorkspace_sptr ws, + calculateDisjointTree(const Mantid::API::IMDHistoWorkspace_sptr &ws, BackgroundStrategy *const baseStrategy, Mantid::API::Progress &progress) const; diff --git a/Framework/Crystal/inc/MantidCrystal/FindSXPeaks.h b/Framework/Crystal/inc/MantidCrystal/FindSXPeaks.h index 632130b4b9287a240c839200c6b47136b3203c0f..9fe6c3a4ba0c7ec81a274ef36d4b15c751843f33 100644 --- a/Framework/Crystal/inc/MantidCrystal/FindSXPeaks.h +++ b/Framework/Crystal/inc/MantidCrystal/FindSXPeaks.h @@ -96,7 +96,7 @@ private: /// Check what x units this workspace has FindSXPeaksHelper::XAxisUnit getWorkspaceXAxisUnit( - Mantid::API::MatrixWorkspace_const_sptr workspace) const; + const Mantid::API::MatrixWorkspace_const_sptr &workspace) const; /// The value in X to start the search from double m_MinRange; diff --git a/Framework/Crystal/inc/MantidCrystal/IndexSXPeaks.h b/Framework/Crystal/inc/MantidCrystal/IndexSXPeaks.h index 2cb20904b9f2dac28c596c1d47e1f34c569d00f1..1698015e4c99d208f0af9536a9e0c1d0e81a0a5b 100644 --- a/Framework/Crystal/inc/MantidCrystal/IndexSXPeaks.h +++ b/Framework/Crystal/inc/MantidCrystal/IndexSXPeaks.h @@ -99,10 +99,10 @@ public: std::set<index> s1; std::set<index> s2; for (it1 = _hkls.begin(); it1 != _hkls.end(); - it1++) // All possible vectors for hkl on current instance + ++it1) // All possible vectors for hkl on current instance { for (it2 = rhs._hkls.begin(); it2 != rhs._hkls.end(); - it2++) // All possible vectors for hkl on other + ++it2) // All possible vectors for hkl on other { const index &index1 = *it1; const index &index2 = *it2; diff --git a/Framework/Crystal/inc/MantidCrystal/IntegratePeakTimeSlices.h b/Framework/Crystal/inc/MantidCrystal/IntegratePeakTimeSlices.h index 59da17f824f782bbc22dc69332d39a92b3812fc3..4d12afaf42927217f7f374608967d6ff83d2d576 100644 --- a/Framework/Crystal/inc/MantidCrystal/IntegratePeakTimeSlices.h +++ b/Framework/Crystal/inc/MantidCrystal/IntegratePeakTimeSlices.h @@ -271,14 +271,14 @@ private: void SetUpData(API::MatrixWorkspace_sptr &Data, API::MatrixWorkspace_const_sptr const &inpWkSpace, - boost::shared_ptr<Geometry::IComponent> comp, + const boost::shared_ptr<Geometry::IComponent> &comp, const int chanMin, const int chanMax, double CentX, double CentY, Kernel::V3D &CentNghbr, double &neighborRadius, // from CentDet double Radius, std::string &spec_idList); - bool getNeighborPixIDs(boost::shared_ptr<Geometry::IComponent> comp, + bool getNeighborPixIDs(const boost::shared_ptr<Geometry::IComponent> &comp, Kernel::V3D &Center, double &Radius, int *&ArryofID); int CalculateTimeChannelSpan(Geometry::IPeak const &peak, const double dQ, diff --git a/Framework/Crystal/inc/MantidCrystal/LoadIsawPeaks.h b/Framework/Crystal/inc/MantidCrystal/LoadIsawPeaks.h index c76fdde23948148b43cdbd12400e193bf48cec0a..a98c1ce1e658346f6694d23c61016c9396d3fb76 100644 --- a/Framework/Crystal/inc/MantidCrystal/LoadIsawPeaks.h +++ b/Framework/Crystal/inc/MantidCrystal/LoadIsawPeaks.h @@ -61,16 +61,16 @@ private: void exec() override; /// Reads first line of peaks file and returns first word of next line - std::string readHeader(Mantid::DataObjects::PeaksWorkspace_sptr outWS, + std::string readHeader(const Mantid::DataObjects::PeaksWorkspace_sptr &outWS, std::ifstream &in, double &T0); /// Read a single peak from peaks file - DataObjects::Peak readPeak(DataObjects::PeaksWorkspace_sptr outWS, + DataObjects::Peak readPeak(const DataObjects::PeaksWorkspace_sptr &outWS, std::string &lastStr, std::ifstream &in, int &seqNum, std::string bankName, double qSign); - int findPixelID(Geometry::Instrument_const_sptr inst, std::string bankName, - int col, int row); + int findPixelID(const Geometry::Instrument_const_sptr &inst, + const std::string &bankName, int col, int row); /// Read the header of a peak block section, returns first word of next line std::string readPeakBlockHeader(std::string lastStr, std::ifstream &in, @@ -78,20 +78,20 @@ private: double &phi, double &omega, double &monCount); /// Append peaks from given file to given workspace - void appendFile(Mantid::DataObjects::PeaksWorkspace_sptr outWS, - std::string filename); + void appendFile(const Mantid::DataObjects::PeaksWorkspace_sptr &outWS, + const std::string &filename); /// Compare number of peaks in given file to given workspace /// Throws std::length_error on mismatch - void checkNumberPeaks(Mantid::DataObjects::PeaksWorkspace_sptr outWS, - std::string filename); + void checkNumberPeaks(const Mantid::DataObjects::PeaksWorkspace_sptr &outWS, + const std::string &filename); /// Local cache of bank IComponents used in file std::map<std::string, boost::shared_ptr<const Geometry::IComponent>> m_banks; /// Retrieve cached bank (or load and cache for next time) boost::shared_ptr<const Geometry::IComponent> getCachedBankByName( - std::string bankname, + const std::string &bankname, const boost::shared_ptr<const Geometry::Instrument> &inst); }; diff --git a/Framework/Crystal/inc/MantidCrystal/MaskPeaksWorkspace.h b/Framework/Crystal/inc/MantidCrystal/MaskPeaksWorkspace.h index 5528d979322150004dcad129d052e1af7ac1272c..74a48aa5d575dadbae4cf83dc061f683c0d20698 100644 --- a/Framework/Crystal/inc/MantidCrystal/MaskPeaksWorkspace.h +++ b/Framework/Crystal/inc/MantidCrystal/MaskPeaksWorkspace.h @@ -48,11 +48,11 @@ private: void init() override; void exec() override; std::size_t getWkspIndex(const detid2index_map &pixel_to_wi, - Geometry::IComponent_const_sptr comp, const int x, - const int y); + const Geometry::IComponent_const_sptr &comp, + const int x, const int y); void getTofRange(double &tofMin, double &tofMax, const double tofPeak, const HistogramData::HistogramX &tof); - int findPixelID(std::string bankName, int col, int row); + int findPixelID(const std::string &bankName, int col, int row); /// Read in all the input parameters void retrieveProperties(); diff --git a/Framework/Crystal/inc/MantidCrystal/PeakHKLErrors.h b/Framework/Crystal/inc/MantidCrystal/PeakHKLErrors.h index 04a1acf43812914aef27219968773963ccd4212a..2bdf5f3d66249a07a264b36b13fde81b7671a79a 100644 --- a/Framework/Crystal/inc/MantidCrystal/PeakHKLErrors.h +++ b/Framework/Crystal/inc/MantidCrystal/PeakHKLErrors.h @@ -67,13 +67,15 @@ public: * @return The new peak with the new instrument( adjusted with the *parameters) and time adjusted. */ - static DataObjects::Peak createNewPeak(const Geometry::IPeak &peak_old, - Geometry::Instrument_sptr instrNew, - double T0, double L0); + static DataObjects::Peak + createNewPeak(const Geometry::IPeak &peak_old, + const Geometry::Instrument_sptr &instrNew, double T0, + double L0); - static void cLone(boost::shared_ptr<Geometry::ParameterMap> &pmap, - boost::shared_ptr<const Geometry::IComponent> component, - boost::shared_ptr<const Geometry::ParameterMap> &pmapSv); + static void + cLone(boost::shared_ptr<Geometry::ParameterMap> &pmap, + const boost::shared_ptr<const Geometry::IComponent> &component, + boost::shared_ptr<const Geometry::ParameterMap> &pmapSv); void getRun2MatMap(DataObjects::PeaksWorkspace_sptr &Peaks, const std::string &OptRuns, @@ -87,7 +89,7 @@ public: char axis); boost::shared_ptr<Geometry::Instrument> - getNewInstrument(DataObjects::PeaksWorkspace_sptr Peaks) const; + getNewInstrument(const DataObjects::PeaksWorkspace_sptr &Peaks) const; std::vector<std::string> getAttributeNames() const override { return {"OptRuns", "PeakWorkspaceName"}; diff --git a/Framework/Crystal/inc/MantidCrystal/PeakIntegration.h b/Framework/Crystal/inc/MantidCrystal/PeakIntegration.h index 23a6d3a115a0828fce87866319301e52d7386adb..23df95e6d247e3563d872693e27c4d3f93de56d3 100644 --- a/Framework/Crystal/inc/MantidCrystal/PeakIntegration.h +++ b/Framework/Crystal/inc/MantidCrystal/PeakIntegration.h @@ -48,8 +48,9 @@ private: void fitSpectra(const int s, double TOFPeakd, double &I, double &sigI); /// Read in all the input parameters void retrieveProperties(); - int fitneighbours(int ipeak, std::string det_name, int x0, int y0, int idet, - double qspan, DataObjects::PeaksWorkspace_sptr &Peaks, + int fitneighbours(int ipeak, const std::string &det_name, int x0, int y0, + int idet, double qspan, + DataObjects::PeaksWorkspace_sptr &Peaks, const detid2index_map &pixel_to_wi); bool m_IC = false; ///< Ikeida Carpenter fit of TOF diff --git a/Framework/Crystal/inc/MantidCrystal/SCDCalibratePanels.h b/Framework/Crystal/inc/MantidCrystal/SCDCalibratePanels.h index f9d21ad88a2cc758d584aec64a7e8f7d2208fc36..b02fd282c7118ba1b044e6b2e4d310cf95ff88cf 100644 --- a/Framework/Crystal/inc/MantidCrystal/SCDCalibratePanels.h +++ b/Framework/Crystal/inc/MantidCrystal/SCDCalibratePanels.h @@ -48,19 +48,20 @@ public: private: void saveIsawDetCal(boost::shared_ptr<Geometry::Instrument> &instrument, boost::container::flat_set<std::string> &AllBankName, - double T0, std::string filename); + double T0, const std::string &filename); /// Function to calculate U - void findU(DataObjects::PeaksWorkspace_sptr peaksWs); + void findU(const DataObjects::PeaksWorkspace_sptr &peaksWs); /// save workspaces - void saveNexus(std::string outputFile, API::MatrixWorkspace_sptr outputWS); + void saveNexus(const std::string &outputFile, + const API::MatrixWorkspace_sptr &outputWS); /// Function to optimize L1 - void findL1(int nPeaks, DataObjects::PeaksWorkspace_sptr peaksWs); + void findL1(int nPeaks, const DataObjects::PeaksWorkspace_sptr &peaksWs); /// Function to optimize L2 void findL2(boost::container::flat_set<std::string> MyBankNames, - DataObjects::PeaksWorkspace_sptr peaksWs); + const DataObjects::PeaksWorkspace_sptr &peaksWs); /// Function to optimize T0 - void findT0(int nPeaks, DataObjects::PeaksWorkspace_sptr peaksWs); + void findT0(int nPeaks, const DataObjects::PeaksWorkspace_sptr &peaksWs); void exec() override; diff --git a/Framework/Crystal/inc/MantidCrystal/SCDPanelErrors.h b/Framework/Crystal/inc/MantidCrystal/SCDPanelErrors.h index cba356c85889b3c5e9671382a70c9c792aa19a59..2419d33d087c92f0a57c832cfa3948da34aa9444 100644 --- a/Framework/Crystal/inc/MantidCrystal/SCDPanelErrors.h +++ b/Framework/Crystal/inc/MantidCrystal/SCDPanelErrors.h @@ -44,7 +44,8 @@ public: /// Move detectors with parameters void moveDetector(double x, double y, double z, double rotx, double roty, double rotz, double scalex, double scaley, - std::string detname, API::Workspace_sptr inputW) const; + std::string detname, + const API::Workspace_sptr &inputW) const; private: /// Call the appropriate load function diff --git a/Framework/Crystal/inc/MantidCrystal/SaveHKL.h b/Framework/Crystal/inc/MantidCrystal/SaveHKL.h index 411eeeda179bc3c16084edb8e0625b7ccc6a561e..cd708f0c4e04e29fd017aafec80d0871fe98ccf7 100644 --- a/Framework/Crystal/inc/MantidCrystal/SaveHKL.h +++ b/Framework/Crystal/inc/MantidCrystal/SaveHKL.h @@ -49,7 +49,7 @@ private: double spectrumCalc(double TOF, int iSpec, std::vector<std::vector<double>> time, std::vector<std::vector<double>> spectra, size_t id); - void sizeBanks(std::string bankName, int &nCols, int &nRows); + void sizeBanks(const std::string &bankName, int &nCols, int &nRows); DataObjects::PeaksWorkspace_sptr m_ws; double m_smu = 0.0; // in 1/cm diff --git a/Framework/Crystal/inc/MantidCrystal/SaveIsawPeaks.h b/Framework/Crystal/inc/MantidCrystal/SaveIsawPeaks.h index d3c853b43cd8d8c9512453d79924a9d5cfc907d6..9e0bad59d5d7d9a636a5b750ed4849b8acd379e9 100644 --- a/Framework/Crystal/inc/MantidCrystal/SaveIsawPeaks.h +++ b/Framework/Crystal/inc/MantidCrystal/SaveIsawPeaks.h @@ -48,10 +48,10 @@ private: /// Run the algorithm void exec() override; /// find position for rectangular and non-rectangular - Kernel::V3D findPixelPos(std::string bankName, int col, int row); - void sizeBanks(std::string bankName, int &NCOLS, int &NROWS, double &xsize, - double &ysize); - bool bankMasked(Geometry::IComponent_const_sptr parent, + Kernel::V3D findPixelPos(const std::string &bankName, int col, int row); + void sizeBanks(const std::string &bankName, int &NCOLS, int &NROWS, + double &xsize, double &ysize); + bool bankMasked(const Geometry::IComponent_const_sptr &parent, const Geometry::DetectorInfo &detectorInfo); void writeOffsets(std::ofstream &out, double qSign, std::vector<double> offset); diff --git a/Framework/Crystal/inc/MantidCrystal/SaveLauenorm.h b/Framework/Crystal/inc/MantidCrystal/SaveLauenorm.h index 9d2885ae95f6e4ff58f52f7ac0a9c26d1d7ae82a..b84323bcaa1fe1a9be295fd31d22b251781d7584 100644 --- a/Framework/Crystal/inc/MantidCrystal/SaveLauenorm.h +++ b/Framework/Crystal/inc/MantidCrystal/SaveLauenorm.h @@ -44,7 +44,7 @@ private: void exec() override; DataObjects::PeaksWorkspace_sptr ws; - void sizeBanks(std::string bankName, int &nCols, int &nRows); + void sizeBanks(const std::string &bankName, int &nCols, int &nRows); const std::vector<std::string> m_typeList{ "TRICLINIC", "MONOCLINIC", "ORTHORHOMBIC", "TETRAGONAL", diff --git a/Framework/Crystal/inc/MantidCrystal/SetSpecialCoordinates.h b/Framework/Crystal/inc/MantidCrystal/SetSpecialCoordinates.h index 43799f83cb34bdaca13275bc09c62a84aebca80b..274a92a1757f93be9912c3a00fe57fd43730893b 100644 --- a/Framework/Crystal/inc/MantidCrystal/SetSpecialCoordinates.h +++ b/Framework/Crystal/inc/MantidCrystal/SetSpecialCoordinates.h @@ -48,13 +48,13 @@ private: static const std::string QSampleOption(); static const std::string HKLOption(); bool writeCoordinatesToMDEventWorkspace( - Mantid::API::Workspace_sptr inWS, + const Mantid::API::Workspace_sptr &inWS, Mantid::Kernel::SpecialCoordinateSystem coordinateSystem); bool writeCoordinatesToMDHistoWorkspace( - Mantid::API::Workspace_sptr inWS, + const Mantid::API::Workspace_sptr &inWS, Mantid::Kernel::SpecialCoordinateSystem coordinateSystem); bool writeCoordinatesToPeaksWorkspace( - Mantid::API::Workspace_sptr inWS, + const Mantid::API::Workspace_sptr &inWS, Mantid::Kernel::SpecialCoordinateSystem coordinateSystem); }; diff --git a/Framework/Crystal/inc/MantidCrystal/SortHKL.h b/Framework/Crystal/inc/MantidCrystal/SortHKL.h index 1a60a9a270ee9902e0d33cd93b29758d5ae30581..afd51cc4fb28ff2dbf337855f8177ababf84e3c0 100644 --- a/Framework/Crystal/inc/MantidCrystal/SortHKL.h +++ b/Framework/Crystal/inc/MantidCrystal/SortHKL.h @@ -78,7 +78,8 @@ private: DataObjects::PeaksWorkspace_sptr getOutputPeaksWorkspace( const DataObjects::PeaksWorkspace_sptr &inputPeaksWorkspace) const; - void sortOutputPeaksByHKL(API::IPeaksWorkspace_sptr outputPeaksWorkspace); + void + sortOutputPeaksByHKL(const API::IPeaksWorkspace_sptr &outputPeaksWorkspace); /// Point Groups possible std::vector<Mantid::Geometry::PointGroup_sptr> m_pointGroups; diff --git a/Framework/Crystal/inc/MantidCrystal/StatisticsOfPeaksWorkspace.h b/Framework/Crystal/inc/MantidCrystal/StatisticsOfPeaksWorkspace.h index 8d2d3667c092605aa1dec4673cbb6ededa7c29ea..061d0bd973eb111d739c254c34c01dc7d95e327b 100644 --- a/Framework/Crystal/inc/MantidCrystal/StatisticsOfPeaksWorkspace.h +++ b/Framework/Crystal/inc/MantidCrystal/StatisticsOfPeaksWorkspace.h @@ -49,7 +49,8 @@ private: /// Run the algorithm void exec() override; /// Runs SortHKL on workspace - void doSortHKL(Mantid::API::Workspace_sptr ws, std::string runName); + void doSortHKL(const Mantid::API::Workspace_sptr &ws, + const std::string &runName); DataObjects::PeaksWorkspace_sptr ws; }; diff --git a/Framework/Crystal/src/AnvredCorrection.cpp b/Framework/Crystal/src/AnvredCorrection.cpp index 6b788c91761bce06ca7b98ae834ef7726bb9c5d1..56bfbe9f06367294df4b53777dc108359239c04b 100644 --- a/Framework/Crystal/src/AnvredCorrection.cpp +++ b/Framework/Crystal/src/AnvredCorrection.cpp @@ -522,7 +522,7 @@ void AnvredCorrection::BuildLamdaWeights() { } void AnvredCorrection::scale_init(const IDetector &det, - Instrument_const_sptr inst, double &L2, + const Instrument_const_sptr &inst, double &L2, double &depth, double &pathlength, std::string &bankName) { bankName = det.getParent()->getParent()->getName(); @@ -542,7 +542,8 @@ void AnvredCorrection::scale_init(const IDetector &det, } void AnvredCorrection::scale_exec(std::string &bankName, double &lambda, - double &depth, Instrument_const_sptr inst, + double &depth, + const Instrument_const_sptr &inst, double &pathlength, double &value) { // correct for the slant path throught the scintillator glass double mu = (9.614 * lambda) + 0.266; // mu for GS20 glass diff --git a/Framework/Crystal/src/CentroidPeaks.cpp b/Framework/Crystal/src/CentroidPeaks.cpp index 29c1b15f547420792bf7c171203fd8eb105466ec..a6dad7263f33b1ff870d6fb618b62a2756a51159 100644 --- a/Framework/Crystal/src/CentroidPeaks.cpp +++ b/Framework/Crystal/src/CentroidPeaks.cpp @@ -323,7 +323,7 @@ void CentroidPeaks::exec() { } } -int CentroidPeaks::findPixelID(std::string bankName, int col, int row) { +int CentroidPeaks::findPixelID(const std::string &bankName, int col, int row) { boost::shared_ptr<const IComponent> parent = inst->getComponentByName(bankName); if (parent->type() == "RectangularDetector") { diff --git a/Framework/Crystal/src/ConnectedComponentLabeling.cpp b/Framework/Crystal/src/ConnectedComponentLabeling.cpp index 46894fbf7fcf4e1ea3ddf18de0b3cc6931ae45c5..04ed2e230a755c6770df6477b5f7a48b77d1d678 100644 --- a/Framework/Crystal/src/ConnectedComponentLabeling.cpp +++ b/Framework/Crystal/src/ConnectedComponentLabeling.cpp @@ -4,6 +4,8 @@ // NScD Oak Ridge National Laboratory, European Spallation Source, // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + +#include <utility> + #include "MantidCrystal/ConnectedComponentLabeling.h" #include "MantidAPI/FrameworkManager.h" @@ -226,7 +228,7 @@ void memoryCheck(size_t nPoints) { * @param nThreads : Optional argument of number of threads to use. */ ConnectedComponentLabeling::ConnectedComponentLabeling( - const size_t &startId, const boost::optional<int> nThreads) + const size_t &startId, const boost::optional<int> &nThreads) : m_startId(startId), m_nThreads(nThreads) { if (m_nThreads.is_initialized() && m_nThreads.get() < 0) { throw std::invalid_argument( @@ -278,7 +280,7 @@ int ConnectedComponentLabeling::getNThreads() const { * @return : Map of label ids to clusters. */ ClusterMap ConnectedComponentLabeling::calculateDisjointTree( - IMDHistoWorkspace_sptr ws, BackgroundStrategy *const baseStrategy, + const IMDHistoWorkspace_sptr &ws, BackgroundStrategy *const baseStrategy, Progress &progress) const { std::map<size_t, boost::shared_ptr<ICluster>> clusterMap; VecElements neighbourElements(ws->getNPoints()); @@ -407,7 +409,8 @@ boost::shared_ptr<Mantid::API::IMDHistoWorkspace> ConnectedComponentLabeling::execute(IMDHistoWorkspace_sptr ws, BackgroundStrategy *const strategy, Progress &progress) const { - ClusterTuple result = executeAndFetchClusters(ws, strategy, progress); + ClusterTuple result = + executeAndFetchClusters(std::move(ws), strategy, progress); IMDHistoWorkspace_sptr outWS = result.get<0>(); // Get the workspace, but discard cluster objects. return outWS; diff --git a/Framework/Crystal/src/FindClusterFaces.cpp b/Framework/Crystal/src/FindClusterFaces.cpp index 9ee0817ae63f7037b61c3b8f105fdee99b16bac7..97fddf346f6e3c4f6699cdb3758a26235960f6e4 100644 --- a/Framework/Crystal/src/FindClusterFaces.cpp +++ b/Framework/Crystal/src/FindClusterFaces.cpp @@ -43,7 +43,7 @@ using OptionalLabelPeakIndexMap = boost::optional<LabelMap>; */ OptionalLabelPeakIndexMap createOptionalLabelFilter(size_t dimensionality, int emptyLabelId, - IPeaksWorkspace_sptr filterWorkspace, + const IPeaksWorkspace_sptr &filterWorkspace, IMDHistoWorkspace_sptr &clusterImage) { OptionalLabelPeakIndexMap optionalAllowedLabels; diff --git a/Framework/Crystal/src/FindSXPeaks.cpp b/Framework/Crystal/src/FindSXPeaks.cpp index 301be49ce7449d35a61a8ce5ae9f5a00cb155e97..c478ebbd9d5678f78e08a848d2a8ea2d192c4743 100644 --- a/Framework/Crystal/src/FindSXPeaks.cpp +++ b/Framework/Crystal/src/FindSXPeaks.cpp @@ -369,8 +369,8 @@ void FindSXPeaks::reducePeakList(const peakvector &pcv, Progress &progress) { * @param workspace :: the workspace to check x-axis units on * @return enum of type XAxisUnit with the value of TOF or DSPACING */ -XAxisUnit -FindSXPeaks::getWorkspaceXAxisUnit(MatrixWorkspace_const_sptr workspace) const { +XAxisUnit FindSXPeaks::getWorkspaceXAxisUnit( + const MatrixWorkspace_const_sptr &workspace) const { const auto xAxis = workspace->getAxis(0); const auto unitID = xAxis->unit()->unitID(); diff --git a/Framework/Crystal/src/FindUBUsingIndexedPeaks.cpp b/Framework/Crystal/src/FindUBUsingIndexedPeaks.cpp index 7cbe615d2f9b0e36060e99216d212cc8458e4cf0..4d9444bffeaf18dcaab73dcf945e89051a590007 100644 --- a/Framework/Crystal/src/FindUBUsingIndexedPeaks.cpp +++ b/Framework/Crystal/src/FindUBUsingIndexedPeaks.cpp @@ -108,9 +108,9 @@ void FindUBUsingIndexedPeaks::exec() { { // from the full list of peaks, and q_vectors.clear(); // save the UB in the sample q_vectors.reserve(n_peaks); - for (const auto &peak : peaks) { - q_vectors.emplace_back(peak.getQSampleFrame()); - } + + std::transform(peaks.begin(), peaks.end(), std::back_inserter(q_vectors), + [](const auto &peak) { return peak.getQSampleFrame(); }); int num_indexed = IndexingUtils::NumberIndexed(UB, q_vectors, tolerance); int sate_indexed = 0; diff --git a/Framework/Crystal/src/IntegratePeakTimeSlices.cpp b/Framework/Crystal/src/IntegratePeakTimeSlices.cpp index a210b733ff1706fd1edf3cff94c8c3008f87a5e1..e9d2bb3c35c511c4e69a89e76b02c3e0ef174c1f 100644 --- a/Framework/Crystal/src/IntegratePeakTimeSlices.cpp +++ b/Framework/Crystal/src/IntegratePeakTimeSlices.cpp @@ -26,6 +26,7 @@ #include "MantidHistogramData/BinEdges.h" #include <boost/math/special_functions/round.hpp> +#include <utility> using namespace Mantid::Kernel; using namespace Mantid::API; @@ -657,7 +658,7 @@ void IntegratePeakTimeSlices::exec() { * the center may be included. */ bool IntegratePeakTimeSlices::getNeighborPixIDs( - boost::shared_ptr<Geometry::IComponent> comp, Kernel::V3D &Center, + const boost::shared_ptr<Geometry::IComponent> &comp, Kernel::V3D &Center, double &Radius, int *&ArryofID) { int N = ArryofID[1]; @@ -1417,7 +1418,7 @@ void DataModeHandler::setHeightHalfWidthInfo( */ void IntegratePeakTimeSlices::SetUpData( MatrixWorkspace_sptr &Data, MatrixWorkspace_const_sptr const &inpWkSpace, - boost::shared_ptr<Geometry::IComponent> comp, const int chanMin, + const boost::shared_ptr<Geometry::IComponent> &comp, const int chanMin, const int chanMax, double CentX, double CentY, Kernel::V3D &CentNghbr, double &neighborRadius, // from CentDetspec double Radius, string &spec_idList) { @@ -1468,7 +1469,7 @@ void IntegratePeakTimeSlices::SetUpData( m_NeighborIDs[1] = 2; neighborRadius = NeighborhoodRadiusDivPeakRadius * NewRadius; CentNghbr = CentPos; - getNeighborPixIDs(comp, CentPos, neighborRadius, m_NeighborIDs); + getNeighborPixIDs(std::move(comp), CentPos, neighborRadius, m_NeighborIDs); } else // big enough neighborhood so neighborRadius -= DD; @@ -2526,7 +2527,8 @@ int IntegratePeakTimeSlices::UpdateOutputWS( m_AttributeValues->StatBaseVals(INCol) - 1; TabWS->getRef<double>(std::string("TotIntensityError"), TableRow) = SQRT(m_AttributeValues->StatBaseVals(IVariance)); - TabWS->getRef<string>(std::string("SpecIDs"), TableRow) = spec_idList; + TabWS->getRef<string>(std::string("SpecIDs"), TableRow) = + std::move(spec_idList); return newRowIndex; } diff --git a/Framework/Crystal/src/LoadIsawPeaks.cpp b/Framework/Crystal/src/LoadIsawPeaks.cpp index 4ce06b8fed3cef15135779a5355711eed86d3d73..dce2c0b5ff8dfe9e0a6cbe3422c34d0f6d8094cf 100644 --- a/Framework/Crystal/src/LoadIsawPeaks.cpp +++ b/Framework/Crystal/src/LoadIsawPeaks.cpp @@ -21,6 +21,7 @@ #include "MantidKernel/Strings.h" #include "MantidKernel/Unit.h" #include <boost/algorithm/string/trim.hpp> +#include <utility> using Mantid::Kernel::Strings::getWord; using Mantid::Kernel::Strings::readToEndOfLine; @@ -67,8 +68,7 @@ int LoadIsawPeaks::confidence(Kernel::FileDescriptor &descriptor) const { throw std::logic_error(std::string("No Version for Peaks file")); getWord(in, false); // tag - // cppcheck-suppress unreadVariable - std::string C_Facility = getWord(in, false); + getWord(in, false); // C_Facility getWord(in, false); // tag std::string C_Instrument = getWord(in, false); @@ -125,7 +125,7 @@ void LoadIsawPeaks::exec() { * @param T0 :: Time offset * @return the first word on the next line */ -std::string LoadIsawPeaks::readHeader(PeaksWorkspace_sptr outWS, +std::string LoadIsawPeaks::readHeader(const PeaksWorkspace_sptr &outWS, std::ifstream &in, double &T0) { std::string tag; std::string r = getWord(in, false); @@ -142,8 +142,7 @@ std::string LoadIsawPeaks::readHeader(PeaksWorkspace_sptr outWS, throw std::logic_error(std::string("No Version for Peaks file")); getWord(in, false); // tag - // cppcheck-suppress unreadVariable - std::string C_Facility = getWord(in, false); + getWord(in, false); // C_Facility getWord(in, false); // tag std::string C_Instrument = getWord(in, false); @@ -262,7 +261,7 @@ std::string LoadIsawPeaks::readHeader(PeaksWorkspace_sptr outWS, * @param qSign :: For inelastic this is 1; for crystallography this is -1 * @return the Peak the Peak object created */ -DataObjects::Peak LoadIsawPeaks::readPeak(PeaksWorkspace_sptr outWS, +DataObjects::Peak LoadIsawPeaks::readPeak(const PeaksWorkspace_sptr &outWS, std::string &lastStr, std::ifstream &in, int &seqNum, std::string bankName, double qSign) { @@ -341,8 +340,8 @@ DataObjects::Peak LoadIsawPeaks::readPeak(PeaksWorkspace_sptr outWS, if (!inst) throw std::runtime_error("No instrument in PeaksWorkspace!"); - int pixelID = - findPixelID(inst, bankName, static_cast<int>(col), static_cast<int>(row)); + int pixelID = findPixelID(inst, std::move(bankName), static_cast<int>(col), + static_cast<int>(row)); // Create the peak object Peak peak(outWS->getInstrument(), pixelID, wl); @@ -358,10 +357,10 @@ DataObjects::Peak LoadIsawPeaks::readPeak(PeaksWorkspace_sptr outWS, } //---------------------------------------------------------------------------------------------- -int LoadIsawPeaks::findPixelID(Instrument_const_sptr inst, std::string bankName, - int col, int row) { +int LoadIsawPeaks::findPixelID(const Instrument_const_sptr &inst, + const std::string &bankName, int col, int row) { boost::shared_ptr<const IComponent> parent = - getCachedBankByName(bankName, inst); + getCachedBankByName(std::move(bankName), inst); if (!parent) return -1; // peak not in any detector. @@ -406,7 +405,7 @@ std::string LoadIsawPeaks::readPeakBlockHeader(std::string lastStr, int &detName, double &chi, double &phi, double &omega, double &monCount) { - std::string s = lastStr; + std::string s = std::move(lastStr); if (s.length() < 1 && in.good()) // blank line { @@ -447,8 +446,8 @@ std::string LoadIsawPeaks::readPeakBlockHeader(std::string lastStr, * @param outWS :: the workspace in which to place the information * @param filename :: path to the .peaks file */ -void LoadIsawPeaks::appendFile(PeaksWorkspace_sptr outWS, - std::string filename) { +void LoadIsawPeaks::appendFile(const PeaksWorkspace_sptr &outWS, + const std::string &filename) { // HKL's are flipped by -1 because of the internal Q convention // unless Crystallography convention double qSign = -1.0; @@ -566,8 +565,8 @@ void LoadIsawPeaks::appendFile(PeaksWorkspace_sptr outWS, * @param outWS :: the workspace in which to place the information * @param filename :: path to the .peaks file */ -void LoadIsawPeaks::checkNumberPeaks(PeaksWorkspace_sptr outWS, - std::string filename) { +void LoadIsawPeaks::checkNumberPeaks(const PeaksWorkspace_sptr &outWS, + const std::string &filename) { // Open the file std::ifstream in(filename.c_str()); @@ -603,7 +602,7 @@ void LoadIsawPeaks::checkNumberPeaks(PeaksWorkspace_sptr outWS, *found) */ boost::shared_ptr<const IComponent> LoadIsawPeaks::getCachedBankByName( - std::string bankname, + const std::string &bankname, const boost::shared_ptr<const Geometry::Instrument> &inst) { if (m_banks.count(bankname) == 0) m_banks[bankname] = inst->getComponentByName(bankname); diff --git a/Framework/Crystal/src/LoadIsawSpectrum.cpp b/Framework/Crystal/src/LoadIsawSpectrum.cpp index 3e24646201ae706d86547ae61b2887bb5af42c9a..9263a6de4d3bcf7f6c75369dfc5a3839b2f6fad1 100644 --- a/Framework/Crystal/src/LoadIsawSpectrum.cpp +++ b/Framework/Crystal/src/LoadIsawSpectrum.cpp @@ -56,7 +56,6 @@ void LoadIsawSpectrum::exec() { const V3D pos = inst->getSource()->getPos() - samplePos; double l1 = pos.norm(); - std::vector<double> spec(11); std::string STRING; std::ifstream infile; std::string spectraFile = getPropertyValue("SpectraFile"); diff --git a/Framework/Crystal/src/MaskPeaksWorkspace.cpp b/Framework/Crystal/src/MaskPeaksWorkspace.cpp index 36bec054374a986571e93b0589069f1d1cdc0302..676c6abeb362528fd005d3ef84ce4008831d7855 100644 --- a/Framework/Crystal/src/MaskPeaksWorkspace.cpp +++ b/Framework/Crystal/src/MaskPeaksWorkspace.cpp @@ -200,9 +200,10 @@ void MaskPeaksWorkspace::retrieveProperties() { } } -size_t MaskPeaksWorkspace::getWkspIndex(const detid2index_map &pixel_to_wi, - Geometry::IComponent_const_sptr comp, - const int x, const int y) { +size_t +MaskPeaksWorkspace::getWkspIndex(const detid2index_map &pixel_to_wi, + const Geometry::IComponent_const_sptr &comp, + const int x, const int y) { Geometry::RectangularDetector_const_sptr det = boost::dynamic_pointer_cast<const Geometry::RectangularDetector>(comp); if (det) { @@ -270,7 +271,8 @@ void MaskPeaksWorkspace::getTofRange(double &tofMin, double &tofMax, tofMax = tofPeak + m_tofMax; } } -int MaskPeaksWorkspace::findPixelID(std::string bankName, int col, int row) { +int MaskPeaksWorkspace::findPixelID(const std::string &bankName, int col, + int row) { Geometry::Instrument_const_sptr Iptr = m_inputW->getInstrument(); boost::shared_ptr<const IComponent> parent = Iptr->getComponentByName(bankName); diff --git a/Framework/Crystal/src/PeakAlgorithmHelpers.cpp b/Framework/Crystal/src/PeakAlgorithmHelpers.cpp index 493f447ec2acf7acbbd49af508fd35849c2e8c38..684e7601304f58702079624c55c1ecc7c4ca30a7 100644 --- a/Framework/Crystal/src/PeakAlgorithmHelpers.cpp +++ b/Framework/Crystal/src/PeakAlgorithmHelpers.cpp @@ -200,12 +200,13 @@ generateOffsetVectors(const std::vector<double> &hOffsets, std::vector<MNPOffset> offsets; for (double hOffset : hOffsets) { for (double kOffset : kOffsets) { - for (double lOffset : lOffsets) { - // mnp = 0, 0, 0 as - // it's not quite clear how to interpret them as mnp indices - offsets.emplace_back( - std::make_tuple(0, 0, 0, V3D(hOffset, kOffset, lOffset))); - } + std::transform( + lOffsets.begin(), lOffsets.end(), std::back_inserter(offsets), + [&hOffset, &kOffset](double lOffset) { + // it's not quite clear how to interpret them as mnp + // indices so set to 0, 0, 0 + return std::make_tuple(0, 0, 0, V3D(hOffset, kOffset, lOffset)); + }); } } return offsets; diff --git a/Framework/Crystal/src/PeakBackground.cpp b/Framework/Crystal/src/PeakBackground.cpp index 7d5ad73b744303d9a7634270675dd2f67c7db93c..e1415c17a77e74badd4ce38bc8875f0a2c1cfd79 100644 --- a/Framework/Crystal/src/PeakBackground.cpp +++ b/Framework/Crystal/src/PeakBackground.cpp @@ -4,8 +4,10 @@ // NScD Oak Ridge National Laboratory, European Spallation Source, // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + -#include "MantidCrystal/PeakBackground.h" +#include <utility> + #include "MantidAPI/IPeaksWorkspace.h" +#include "MantidCrystal/PeakBackground.h" #include "MantidGeometry/Crystal/IPeak.h" using namespace Mantid::API; @@ -24,7 +26,7 @@ PeakBackground::PeakBackground(IPeaksWorkspace_const_sptr peaksWS, const Mantid::API::MDNormalization normalisation, const SpecialCoordinateSystem coordinates) : HardThresholdBackground(thresholdSignal, normalisation), - m_peaksWS(peaksWS), m_radiusEstimate(radiusEstimate), + m_peaksWS(std::move(peaksWS)), m_radiusEstimate(radiusEstimate), m_mdCoordinates(coordinates) { if (m_mdCoordinates == QLab) { diff --git a/Framework/Crystal/src/PeakHKLErrors.cpp b/Framework/Crystal/src/PeakHKLErrors.cpp index 2a6807dfdd0490dd0f5a3da38eb446509462104e..8d4e7eebca125e46dca243481a149e6048c35cc0 100644 --- a/Framework/Crystal/src/PeakHKLErrors.cpp +++ b/Framework/Crystal/src/PeakHKLErrors.cpp @@ -117,7 +117,7 @@ void PeakHKLErrors::setUpOptRuns() { */ void PeakHKLErrors::cLone( boost::shared_ptr<Geometry::ParameterMap> &pmap, - boost::shared_ptr<const Geometry::IComponent> component, + const boost::shared_ptr<const Geometry::IComponent> &component, boost::shared_ptr<const Geometry::ParameterMap> &pmapSv) { if (!component) return; @@ -187,7 +187,7 @@ void PeakHKLErrors::cLone( * NOTE: All the peaks in the PeaksWorkspace must use the same instrument. */ boost::shared_ptr<Geometry::Instrument> -PeakHKLErrors::getNewInstrument(PeaksWorkspace_sptr Peaks) const { +PeakHKLErrors::getNewInstrument(const PeaksWorkspace_sptr &Peaks) const { Geometry::Instrument_const_sptr instSave = Peaks->getPeak(0).getInstrument(); auto pmap = boost::make_shared<Geometry::ParameterMap>(); @@ -643,8 +643,8 @@ void PeakHKLErrors::functionDeriv1D(Jacobian *out, const double *xValues, } Peak PeakHKLErrors::createNewPeak(const Geometry::IPeak &peak_old, - Geometry::Instrument_sptr instrNew, double T0, - double L0) { + const Geometry::Instrument_sptr &instrNew, + double T0, double L0) { Geometry::Instrument_const_sptr inst = peak_old.getInstrument(); if (inst->getComponentID() != instrNew->getComponentID()) { g_log.error("All peaks must have the same instrument"); diff --git a/Framework/Crystal/src/PeakIntegration.cpp b/Framework/Crystal/src/PeakIntegration.cpp index cae56ddc0deb6b269df30b2d04920961324458ea..da992cb6dbfe2183cab67edff372121513647510 100644 --- a/Framework/Crystal/src/PeakIntegration.cpp +++ b/Framework/Crystal/src/PeakIntegration.cpp @@ -301,8 +301,8 @@ void PeakIntegration::retrieveProperties() { } } -int PeakIntegration::fitneighbours(int ipeak, std::string det_name, int x0, - int y0, int idet, double qspan, +int PeakIntegration::fitneighbours(int ipeak, const std::string &det_name, + int x0, int y0, int idet, double qspan, PeaksWorkspace_sptr &Peaks, const detid2index_map &pixel_to_wi) { UNUSED_ARG(ipeak); diff --git a/Framework/Crystal/src/SCDCalibratePanels.cpp b/Framework/Crystal/src/SCDCalibratePanels.cpp index 7eefa117a69a893c8ac810b4ff8711f56141ee51..72bdeb27f5b57cfdd9746e477579ee47aa2b7126 100644 --- a/Framework/Crystal/src/SCDCalibratePanels.cpp +++ b/Framework/Crystal/src/SCDCalibratePanels.cpp @@ -280,16 +280,16 @@ void SCDCalibratePanels::exec() { saveNexus(tofFilename, TofWksp); } -void SCDCalibratePanels::saveNexus(std::string outputFile, - MatrixWorkspace_sptr outputWS) { +void SCDCalibratePanels::saveNexus(const std::string &outputFile, + const MatrixWorkspace_sptr &outputWS) { IAlgorithm_sptr save = this->createChildAlgorithm("SaveNexus"); save->setProperty("InputWorkspace", outputWS); save->setProperty("FileName", outputFile); save->execute(); } -void SCDCalibratePanels::findL1(int nPeaks, - DataObjects::PeaksWorkspace_sptr peaksWs) { +void SCDCalibratePanels::findL1( + int nPeaks, const DataObjects::PeaksWorkspace_sptr &peaksWs) { MatrixWorkspace_sptr L1WS = boost::dynamic_pointer_cast<MatrixWorkspace>( API::WorkspaceFactory::Instance().create("Workspace2D", 1, 3 * nPeaks, 3 * nPeaks)); @@ -329,8 +329,8 @@ void SCDCalibratePanels::findL1(int nPeaks, << fitL1Status << " Chi2overDoF " << chisqL1 << "\n"; } -void SCDCalibratePanels::findT0(int nPeaks, - DataObjects::PeaksWorkspace_sptr peaksWs) { +void SCDCalibratePanels::findT0( + int nPeaks, const DataObjects::PeaksWorkspace_sptr &peaksWs) { MatrixWorkspace_sptr T0WS = boost::dynamic_pointer_cast<MatrixWorkspace>( API::WorkspaceFactory::Instance().create("Workspace2D", 1, 3 * nPeaks, 3 * nPeaks)); @@ -385,7 +385,8 @@ void SCDCalibratePanels::findT0(int nPeaks, } } -void SCDCalibratePanels::findU(DataObjects::PeaksWorkspace_sptr peaksWs) { +void SCDCalibratePanels::findU( + const DataObjects::PeaksWorkspace_sptr &peaksWs) { IAlgorithm_sptr ub_alg; try { ub_alg = createChildAlgorithm("CalculateUMatrix", -1, -1, false); @@ -442,7 +443,7 @@ void SCDCalibratePanels::findU(DataObjects::PeaksWorkspace_sptr peaksWs) { void SCDCalibratePanels::saveIsawDetCal( boost::shared_ptr<Instrument> &instrument, boost::container::flat_set<string> &AllBankName, double T0, - string filename) { + const string &filename) { // having a filename triggers doing the work if (filename.empty()) return; @@ -633,8 +634,9 @@ void SCDCalibratePanels::saveXmlFile( oss3.flush(); oss3.close(); } -void SCDCalibratePanels::findL2(boost::container::flat_set<string> MyBankNames, - DataObjects::PeaksWorkspace_sptr peaksWs) { +void SCDCalibratePanels::findL2( + boost::container::flat_set<string> MyBankNames, + const DataObjects::PeaksWorkspace_sptr &peaksWs) { bool changeSize = getProperty("ChangePanelSize"); Geometry::Instrument_const_sptr inst = peaksWs->getInstrument(); diff --git a/Framework/Crystal/src/SCDPanelErrors.cpp b/Framework/Crystal/src/SCDPanelErrors.cpp index 7c53a3b8699b55c6c480d13e122920235eb5b9c5..e22beeaeede971ed058ac9319d09721b621b5ce0 100644 --- a/Framework/Crystal/src/SCDPanelErrors.cpp +++ b/Framework/Crystal/src/SCDPanelErrors.cpp @@ -23,6 +23,7 @@ #include <cmath> #include <fstream> #include <sstream> +#include <utility> namespace Mantid { namespace Crystal { @@ -74,7 +75,7 @@ SCDPanelErrors::SCDPanelErrors() : m_setupFinished(false) { void SCDPanelErrors::moveDetector(double x, double y, double z, double rotx, double roty, double rotz, double scalex, double scaley, std::string detname, - Workspace_sptr inputW) const { + const Workspace_sptr &inputW) const { if (detname.compare("none") == 0.0) return; // CORELLI has sixteenpack under bank @@ -340,7 +341,7 @@ void SCDPanelErrors::loadWorkspace(const std::string &wsName) const { * @param ws :: The workspace to load from */ void SCDPanelErrors::loadWorkspace(boost::shared_ptr<API::Workspace> ws) const { - m_workspace = ws; + m_workspace = std::move(ws); m_setupFinished = false; } diff --git a/Framework/Crystal/src/SaveHKL.cpp b/Framework/Crystal/src/SaveHKL.cpp index 03a11e22ca418b43a9f1469511180d1f372b1b0c..c031b73732ebf8e9830976910f4f37bf6be11875 100644 --- a/Framework/Crystal/src/SaveHKL.cpp +++ b/Framework/Crystal/src/SaveHKL.cpp @@ -747,7 +747,7 @@ double SaveHKL::spectrumCalc(double TOF, int iSpec, return spect; } -void SaveHKL::sizeBanks(std::string bankName, int &nCols, int &nRows) { +void SaveHKL::sizeBanks(const std::string &bankName, int &nCols, int &nRows) { if (bankName == "None") return; boost::shared_ptr<const IComponent> parent = diff --git a/Framework/Crystal/src/SaveIsawPeaks.cpp b/Framework/Crystal/src/SaveIsawPeaks.cpp index deed32269bb1f344a758cdf66bce2024cfd04a12..82685646a586135a12c208e0ba9868c20083c7ff 100644 --- a/Framework/Crystal/src/SaveIsawPeaks.cpp +++ b/Framework/Crystal/src/SaveIsawPeaks.cpp @@ -318,7 +318,6 @@ void SaveIsawPeaks::exec() { const int run = runBankMap.first; const auto &bankMap = runBankMap.second; - bankMap_t::iterator bankMap_it; for (const auto &bankIDs : bankMap) { // Start of a new bank. const int bank = bankIDs.first; @@ -461,7 +460,7 @@ void SaveIsawPeaks::exec() { out.close(); } -bool SaveIsawPeaks::bankMasked(IComponent_const_sptr parent, +bool SaveIsawPeaks::bankMasked(const IComponent_const_sptr &parent, const Geometry::DetectorInfo &detectorInfo) { std::vector<Geometry::IComponent_const_sptr> children; auto asmb = @@ -494,7 +493,7 @@ bool SaveIsawPeaks::bankMasked(IComponent_const_sptr parent, return true; } -V3D SaveIsawPeaks::findPixelPos(std::string bankName, int col, int row) { +V3D SaveIsawPeaks::findPixelPos(const std::string &bankName, int col, int row) { auto parent = inst->getComponentByName(bankName); if (parent->type() == "RectangularDetector") { const auto RDet = @@ -524,8 +523,8 @@ V3D SaveIsawPeaks::findPixelPos(std::string bankName, int col, int row) { return first->getPos(); } } -void SaveIsawPeaks::sizeBanks(std::string bankName, int &NCOLS, int &NROWS, - double &xsize, double &ysize) { +void SaveIsawPeaks::sizeBanks(const std::string &bankName, int &NCOLS, + int &NROWS, double &xsize, double &ysize) { if (bankName == "None") return; const auto parent = inst->getComponentByName(bankName); diff --git a/Framework/Crystal/src/SaveLauenorm.cpp b/Framework/Crystal/src/SaveLauenorm.cpp index 0512f5fb3bfd714d73f9607545b3a369b443f42c..1c930b37b47e82bbb130bba2d193b2c50a359d57 100644 --- a/Framework/Crystal/src/SaveLauenorm.cpp +++ b/Framework/Crystal/src/SaveLauenorm.cpp @@ -499,7 +499,8 @@ void SaveLauenorm::exec() { out.flush(); out.close(); } -void SaveLauenorm::sizeBanks(std::string bankName, int &nCols, int &nRows) { +void SaveLauenorm::sizeBanks(const std::string &bankName, int &nCols, + int &nRows) { if (bankName == "None") return; boost::shared_ptr<const IComponent> parent = diff --git a/Framework/Crystal/src/SetSpecialCoordinates.cpp b/Framework/Crystal/src/SetSpecialCoordinates.cpp index ec7453d20440dbcf5e94dad078a783f798bc4c7a..8d661d43fecf6f6fd01882395c8902fe8d012462 100644 --- a/Framework/Crystal/src/SetSpecialCoordinates.cpp +++ b/Framework/Crystal/src/SetSpecialCoordinates.cpp @@ -93,9 +93,9 @@ void SetSpecialCoordinates::init() { } bool SetSpecialCoordinates::writeCoordinatesToMDEventWorkspace( - Workspace_sptr inWS, SpecialCoordinateSystem /*unused*/) { + const Workspace_sptr &inWS, SpecialCoordinateSystem /*unused*/) { bool written = false; - if (auto mdEventWS = boost::dynamic_pointer_cast<IMDEventWorkspace>(inWS)) { + if (boost::dynamic_pointer_cast<IMDEventWorkspace>(inWS)) { g_log.warning("SetSpecialCoordinates: This algorithm cannot set the " "special coordinate system for an MDEvent workspace any " "longer."); @@ -105,9 +105,9 @@ bool SetSpecialCoordinates::writeCoordinatesToMDEventWorkspace( } bool SetSpecialCoordinates::writeCoordinatesToMDHistoWorkspace( - Workspace_sptr inWS, SpecialCoordinateSystem /*unused*/) { + const Workspace_sptr &inWS, SpecialCoordinateSystem /*unused*/) { bool written = false; - if (auto mdHistoWS = boost::dynamic_pointer_cast<IMDHistoWorkspace>(inWS)) { + if (boost::dynamic_pointer_cast<IMDHistoWorkspace>(inWS)) { g_log.warning("SetSpecialCoordinates: This algorithm cannot set the " "special coordinate system for an MDHisto workspace any " "longer."); @@ -117,7 +117,7 @@ bool SetSpecialCoordinates::writeCoordinatesToMDHistoWorkspace( } bool SetSpecialCoordinates::writeCoordinatesToPeaksWorkspace( - Workspace_sptr inWS, SpecialCoordinateSystem coordinateSystem) { + const Workspace_sptr &inWS, SpecialCoordinateSystem coordinateSystem) { bool written = false; if (auto peaksWS = boost::dynamic_pointer_cast<IPeaksWorkspace>(inWS)) { peaksWS->setCoordinateSystem(coordinateSystem); diff --git a/Framework/Crystal/src/SortHKL.cpp b/Framework/Crystal/src/SortHKL.cpp index ead61efa5e63ad9625b9a1afab04df1b2c079f4b..c5d7122c42bcf36284ec6847ae2f79db09ca01de 100644 --- a/Framework/Crystal/src/SortHKL.cpp +++ b/Framework/Crystal/src/SortHKL.cpp @@ -412,7 +412,8 @@ PeaksWorkspace_sptr SortHKL::getOutputPeaksWorkspace( } /// Sorts the peaks in the workspace by H, K and L. -void SortHKL::sortOutputPeaksByHKL(IPeaksWorkspace_sptr outputPeaksWorkspace) { +void SortHKL::sortOutputPeaksByHKL( + const IPeaksWorkspace_sptr &outputPeaksWorkspace) { // Sort by HKL std::vector<std::pair<std::string, bool>> criteria{ {"H", true}, {"K", true}, {"L", true}}; diff --git a/Framework/Crystal/src/StatisticsOfPeaksWorkspace.cpp b/Framework/Crystal/src/StatisticsOfPeaksWorkspace.cpp index c5f46c9a5e9c0a90bca1e002e557ba1bbc761756..a93bf28a13e12ce7cd7a02ccbee524feda20e719 100644 --- a/Framework/Crystal/src/StatisticsOfPeaksWorkspace.cpp +++ b/Framework/Crystal/src/StatisticsOfPeaksWorkspace.cpp @@ -198,8 +198,8 @@ void StatisticsOfPeaksWorkspace::exec() { * @param ws :: any PeaksWorkspace * @param runName :: string to put in statistics table */ -void StatisticsOfPeaksWorkspace::doSortHKL(Mantid::API::Workspace_sptr ws, - std::string runName) { +void StatisticsOfPeaksWorkspace::doSortHKL( + const Mantid::API::Workspace_sptr &ws, const std::string &runName) { std::string pointGroup = getPropertyValue("PointGroup"); std::string latticeCentering = getPropertyValue("LatticeCentering"); std::string wkspName = getPropertyValue("OutputWorkspace"); diff --git a/Framework/Crystal/test/AnvredCorrectionTest.h b/Framework/Crystal/test/AnvredCorrectionTest.h index 399979d1d8706676e6de43bb712371615a3fe91e..ea03f23516a20d2f64c62d45b65584a9f17f8893 100644 --- a/Framework/Crystal/test/AnvredCorrectionTest.h +++ b/Framework/Crystal/test/AnvredCorrectionTest.h @@ -69,7 +69,7 @@ EventWorkspace_sptr createDiffractionEventWorkspace(int numBanks = 1, return retVal; } -void do_test_events(MatrixWorkspace_sptr workspace, bool ev, +void do_test_events(const MatrixWorkspace_sptr &workspace, bool ev, bool performance = false) { workspace->getAxis(0)->setUnit("Wavelength"); diff --git a/Framework/Crystal/test/CalculateUMatrixTest.h b/Framework/Crystal/test/CalculateUMatrixTest.h index 94648dd3234161b7135752700842239d49376ad5..49ac4859da994b80e4106e548bd12bb066a09ce8 100644 --- a/Framework/Crystal/test/CalculateUMatrixTest.h +++ b/Framework/Crystal/test/CalculateUMatrixTest.h @@ -181,7 +181,7 @@ private: return atan2(-QYUB(H, K, L), -QXUB(H, K, L)); } - void generatePeaks(std::string WSName) { + void generatePeaks(const std::string &WSName) { setupUB(); double Hpeaks[9] = {0, 1, 1, 0, -1, -1, 1, -3, -2}; diff --git a/Framework/Crystal/test/ClusterIntegrationBaseTest.h b/Framework/Crystal/test/ClusterIntegrationBaseTest.h index bb3d0b04dbc32f1ffb788547a54796cb1534b7f7..51331a53e63c47bb8c2b61b481312c5b30a1b4a5 100644 --- a/Framework/Crystal/test/ClusterIntegrationBaseTest.h +++ b/Framework/Crystal/test/ClusterIntegrationBaseTest.h @@ -50,9 +50,9 @@ protected: } // Add a fake peak to an MDEventWorkspace - void add_fake_md_peak(IMDEventWorkspace_sptr mdws, const size_t &nEvents, - const double &h, const double &k, const double &l, - const double &radius) { + void add_fake_md_peak(const IMDEventWorkspace_sptr &mdws, + const size_t &nEvents, const double &h, const double &k, + const double &l, const double &radius) { auto fakeMDEventDataAlg = AlgorithmManager::Instance().createUnmanaged("FakeMDEventData"); fakeMDEventDataAlg->setChild(true); diff --git a/Framework/Crystal/test/FilterPeaksTest.h b/Framework/Crystal/test/FilterPeaksTest.h index b20b55387dcd5a31f838e88b0f49a7b5e1fc6fb2..40bcf59a5d2a3a9dc9f141319f852f56fc4aee3e 100644 --- a/Framework/Crystal/test/FilterPeaksTest.h +++ b/Framework/Crystal/test/FilterPeaksTest.h @@ -39,7 +39,7 @@ private: /* * Helper method to run the algorithm and return the output workspace. */ - IPeaksWorkspace_sptr runAlgorithm(PeaksWorkspace_sptr inWS, + IPeaksWorkspace_sptr runAlgorithm(const PeaksWorkspace_sptr &inWS, const std::string &filterVariable, const double filterValue, const std::string &filterOperator) { diff --git a/Framework/Crystal/test/FindClusterFacesTest.h b/Framework/Crystal/test/FindClusterFacesTest.h index cd84d02fe7f719025dbabcb8ced8cc295eba02bd..86ca859c71298efbe72a3f36daad117e41965104 100644 --- a/Framework/Crystal/test/FindClusterFacesTest.h +++ b/Framework/Crystal/test/FindClusterFacesTest.h @@ -26,7 +26,7 @@ using Mantid::Crystal::FindClusterFaces; namespace { // Helper function to create a peaks workspace. -IPeaksWorkspace_sptr create_peaks_WS(Instrument_sptr inst) { +IPeaksWorkspace_sptr create_peaks_WS(const Instrument_sptr &inst) { PeaksWorkspace *pPeaksWS = new PeaksWorkspace(); pPeaksWS->setCoordinateSystem(Mantid::Kernel::HKL); IPeaksWorkspace_sptr peakWS(pPeaksWS); diff --git a/Framework/Crystal/test/FindSXPeaksTest.h b/Framework/Crystal/test/FindSXPeaksTest.h index 6c50a2ac6484a18170e5171fc33f49c6d2c89a6d..727ecad6df1ecae24f8a6542ddb878ffc62ddc9f 100644 --- a/Framework/Crystal/test/FindSXPeaksTest.h +++ b/Framework/Crystal/test/FindSXPeaksTest.h @@ -24,7 +24,7 @@ using namespace Mantid::Crystal; using namespace Mantid::DataObjects; // Helper method to overwrite spectra. -void overWriteSpectraY(size_t histo, Workspace2D_sptr workspace, +void overWriteSpectraY(size_t histo, const Workspace2D_sptr &workspace, const std::vector<double> &Yvalues) { workspace->dataY(histo) = Yvalues; @@ -32,7 +32,7 @@ void overWriteSpectraY(size_t histo, Workspace2D_sptr workspace, // Helper method to make what will be recognised as a single peak. void makeOnePeak(size_t histo, double peak_intensity, size_t at_bin, - Workspace2D_sptr workspace) { + const Workspace2D_sptr &workspace) { size_t nBins = workspace->y(0).size(); std::vector<double> peaksInY(nBins); @@ -53,7 +53,8 @@ void makeOnePeak(size_t histo, double peak_intensity, size_t at_bin, * @param startIndex :: the workspace index to start searching from * @param endIndex :: the workspace index to stop searching from */ -std::unique_ptr<FindSXPeaks> createFindSXPeaks(Workspace2D_sptr workspace) { +std::unique_ptr<FindSXPeaks> +createFindSXPeaks(const Workspace2D_sptr &workspace) { auto alg = std::make_unique<FindSXPeaks>(); alg->setRethrows(true); alg->initialize(); diff --git a/Framework/Crystal/test/IndexPeaksTest.h b/Framework/Crystal/test/IndexPeaksTest.h index c6a798a96276aa5eb7350d79deb5c7a84236f30d..296e2194246cbba945b89584fed84d3ecc0c2eea 100644 --- a/Framework/Crystal/test/IndexPeaksTest.h +++ b/Framework/Crystal/test/IndexPeaksTest.h @@ -112,7 +112,7 @@ PeaksWorkspace_sptr createTestPeaksWorkspaceWithSatellites( } std::unique_ptr<IndexPeaks> -indexPeaks(PeaksWorkspace_sptr peaksWS, +indexPeaks(const PeaksWorkspace_sptr &peaksWS, const std::unordered_map<std::string, std::string> &arguments) { auto alg = std::make_unique<IndexPeaks>(); alg->setChild(true); diff --git a/Framework/Crystal/test/IndexSXPeaksTest.h b/Framework/Crystal/test/IndexSXPeaksTest.h index d4b1d78460fe2ff83574e41f1fc51b33f1dc47e9..4adba996f3523d9cba6ba15435775a90d9625718 100644 --- a/Framework/Crystal/test/IndexSXPeaksTest.h +++ b/Framework/Crystal/test/IndexSXPeaksTest.h @@ -56,9 +56,9 @@ public: AnalysisDataService::Instance().remove("master_peaks"); } - void doTest(int nPixels, std::string peakIndexes, double a, double b, + void doTest(int nPixels, const std::string &peakIndexes, double a, double b, double c, double alpha, double beta, double gamma, - std::string searchExtents = "-20,20,-20,20,-20,20", + const std::string &searchExtents = "-20,20,-20,20,-20,20", double dTolerance = 0.01) { // Take a copy of the original peaks workspace. diff --git a/Framework/Crystal/test/IntegratePeakTimeSlicesTest.h b/Framework/Crystal/test/IntegratePeakTimeSlicesTest.h index 9b9e0ed455169371daf13c8f98e62eaaf9fb6438..9cb2a3db13146b64d6255509d328d5a70f15c667 100644 --- a/Framework/Crystal/test/IntegratePeakTimeSlicesTest.h +++ b/Framework/Crystal/test/IntegratePeakTimeSlicesTest.h @@ -238,7 +238,7 @@ private: /** * Calculates Q */ - double calcQ(RectangularDetector_const_sptr bankP, + double calcQ(const RectangularDetector_const_sptr &bankP, const DetectorInfo &detectorInfo, int row, int col, double time) { boost::shared_ptr<Detector> detP = bankP->getAtXY(col, row); diff --git a/Framework/Crystal/test/PeakClusterProjectionTest.h b/Framework/Crystal/test/PeakClusterProjectionTest.h index 2ed35dfa0d4f8f56dbec336ee757c48ce660125a..ee5af061ef4e153b039823e36ab81451df398706 100644 --- a/Framework/Crystal/test/PeakClusterProjectionTest.h +++ b/Framework/Crystal/test/PeakClusterProjectionTest.h @@ -32,7 +32,7 @@ class PeakClusterProjectionTest : public CxxTest::TestSuite { private: // Helper function to create a peaks workspace. - IPeaksWorkspace_sptr create_peaks_WS(Instrument_sptr inst) const { + IPeaksWorkspace_sptr create_peaks_WS(const Instrument_sptr &inst) const { PeaksWorkspace *pPeaksWS = new PeaksWorkspace(); pPeaksWS->setCoordinateSystem(Mantid::Kernel::HKL); IPeaksWorkspace_sptr peakWS(pPeaksWS); diff --git a/Framework/Crystal/test/PeakIntensityVsRadiusTest.h b/Framework/Crystal/test/PeakIntensityVsRadiusTest.h index 2c6884af5fd46b62be31a85243f2d98b3ff60a38..493af63e3238695960c93aa7f3eb4816517845c4 100644 --- a/Framework/Crystal/test/PeakIntensityVsRadiusTest.h +++ b/Framework/Crystal/test/PeakIntensityVsRadiusTest.h @@ -210,12 +210,12 @@ public: assertFlatAfter1(ws); } - void assertFlatAfter1(MatrixWorkspace_sptr ws) { + void assertFlatAfter1(const MatrixWorkspace_sptr &ws) { TSM_ASSERT_DELTA("After 1.0, the signal is flat", ws->y(0)[12], 1000, 1e-6); TSM_ASSERT_DELTA("After 1.0, the signal is flat", ws->y(0)[15], 1000, 1e-6) } - void assertFirstFourYValuesCloseToZero(MatrixWorkspace_sptr ws) { + void assertFirstFourYValuesCloseToZero(const MatrixWorkspace_sptr &ws) { TS_ASSERT_DELTA(ws->y(0)[0], 0, 10); TS_ASSERT_DELTA(ws->y(0)[1], 0, 10); TS_ASSERT_DELTA(ws->y(0)[2], 0, 10); diff --git a/Framework/Crystal/test/PeaksInRegionTest.h b/Framework/Crystal/test/PeaksInRegionTest.h index 70f472cbe4001dd272f9ba809e2621630be0dae8..e3bca14a6c9f2e8d90f69b80bbcf639c9c9650cb 100644 --- a/Framework/Crystal/test/PeaksInRegionTest.h +++ b/Framework/Crystal/test/PeaksInRegionTest.h @@ -31,7 +31,7 @@ private: Helper function. Creates a peaksworkspace with a single peak */ PeakWorkspaceWithExtents - createPeaksWorkspace(const std::string coordFrame, double xMinFromPeak, + createPeaksWorkspace(const std::string &coordFrame, double xMinFromPeak, double xMaxFromPeak, double yMinFromPeak, double yMaxFromPeak, double zMinFromPeak, double zMaxFromPeak) { @@ -267,7 +267,7 @@ public: -0.5); // outside zmax } - void do_test_bounds_check_extents(const std::string coordFrame, + void do_test_bounds_check_extents(const std::string &coordFrame, double xMinFromPeak, double xMaxFromPeak, double yMinFromPeak, double yMaxFromPeak, double zMinFromPeak, double zMaxFromPeak, @@ -304,14 +304,12 @@ public: double peakRadius = 0.49; // not enough for the sphere to penetrate the // bounding box. Expect failure do_test_bounds_check_extents(coordinateFrame, -wallDistanceFromPeakCenter, - 1, 1, 1, 1, 1, peakRadius, - peakRadius > wallDistanceFromPeakCenter); + 1, 1, 1, 1, 1, peakRadius, false); peakRadius = 0.51; // just enough for the sphere to penetrate the bounding // box. Expect pass. do_test_bounds_check_extents(coordinateFrame, -wallDistanceFromPeakCenter, - 1, 1, 1, 1, 1, peakRadius, - peakRadius > wallDistanceFromPeakCenter); + 1, 1, 1, 1, 1, peakRadius, true); } void test_peak_intersects_xmax_boundary_when_radius_large_enough() { @@ -320,15 +318,15 @@ public: double peakRadius = 0.49; // not enough for the sphere to penetrate the // bounding box. Expect failure - do_test_bounds_check_extents( - coordinateFrame, 1, -wallDistanceFromPeakCenter, 1, 1, 1, 1, peakRadius, - peakRadius > wallDistanceFromPeakCenter); + do_test_bounds_check_extents(coordinateFrame, 1, + -wallDistanceFromPeakCenter, 1, 1, 1, 1, + peakRadius, false); peakRadius = 0.51; // just enough for the sphere to penetrate the bounding // box. Expect pass. - do_test_bounds_check_extents( - coordinateFrame, 1, -wallDistanceFromPeakCenter, 1, 1, 1, 1, peakRadius, - peakRadius > wallDistanceFromPeakCenter); + do_test_bounds_check_extents(coordinateFrame, 1, + -wallDistanceFromPeakCenter, 1, 1, 1, 1, + peakRadius, true); } void test_peak_intersects_ymin_boundary_when_radius_large_enough() { @@ -337,15 +335,15 @@ public: double peakRadius = 0.49; // not enough for the sphere to penetrate the // bounding box. Expect failure - do_test_bounds_check_extents( - coordinateFrame, 1, 1, -wallDistanceFromPeakCenter, 1, 1, 1, peakRadius, - peakRadius > wallDistanceFromPeakCenter); + do_test_bounds_check_extents(coordinateFrame, 1, 1, + -wallDistanceFromPeakCenter, 1, 1, 1, + peakRadius, false); peakRadius = 0.51; // just enough for the sphere to penetrate the bounding // box. Expect pass. - do_test_bounds_check_extents( - coordinateFrame, 1, 1, -wallDistanceFromPeakCenter, 1, 1, 1, peakRadius, - peakRadius > wallDistanceFromPeakCenter); + do_test_bounds_check_extents(coordinateFrame, 1, 1, + -wallDistanceFromPeakCenter, 1, 1, 1, + peakRadius, true); } void test_peak_intersects_ymax_boundary_when_radius_large_enough() { @@ -356,13 +354,13 @@ public: // bounding box. Expect failure do_test_bounds_check_extents(coordinateFrame, 1, 1, 1, -wallDistanceFromPeakCenter, 1, 1, peakRadius, - peakRadius > wallDistanceFromPeakCenter); + false); peakRadius = 0.51; // just enough for the sphere to penetrate the bounding // box. Expect pass. do_test_bounds_check_extents(coordinateFrame, 1, 1, 1, -wallDistanceFromPeakCenter, 1, 1, peakRadius, - peakRadius > wallDistanceFromPeakCenter); + true); } void test_peak_intersects_zmin_boundary_when_radius_large_enough() { @@ -373,13 +371,13 @@ public: // bounding box. Expect failure do_test_bounds_check_extents(coordinateFrame, 1, 1, 1, 1, -wallDistanceFromPeakCenter, 1, peakRadius, - peakRadius > wallDistanceFromPeakCenter); + false); peakRadius = 0.51; // just enough for the sphere to penetrate the bounding // box. Expect pass. do_test_bounds_check_extents(coordinateFrame, 1, 1, 1, 1, -wallDistanceFromPeakCenter, 1, peakRadius, - peakRadius > wallDistanceFromPeakCenter); + true); } void test_peak_intersects_zmax_boundary_when_radius_large_enough() { @@ -390,13 +388,12 @@ public: // bounding box. Expect failure do_test_bounds_check_extents(coordinateFrame, 1, 1, 1, 1, 1, -wallDistanceFromPeakCenter, peakRadius, - peakRadius > wallDistanceFromPeakCenter); + false); peakRadius = 0.51; // just enough for the sphere to penetrate the bounding // box. Expect pass. do_test_bounds_check_extents(coordinateFrame, 1, 1, 1, 1, 1, - -wallDistanceFromPeakCenter, peakRadius, - peakRadius > wallDistanceFromPeakCenter); + -wallDistanceFromPeakCenter, peakRadius, true); } void test_false_intersection_when_check_peak_extents() { diff --git a/Framework/Crystal/test/PeaksOnSurfaceTest.h b/Framework/Crystal/test/PeaksOnSurfaceTest.h index 1231b76c911fc1c817cdf95ef92787290fafeac9..884e15f42c32e87a389bee198517b668a953fd15 100644 --- a/Framework/Crystal/test/PeaksOnSurfaceTest.h +++ b/Framework/Crystal/test/PeaksOnSurfaceTest.h @@ -27,7 +27,7 @@ private: Helper function. Creates a peaksworkspace with a single peak */ PeaksWorkspace_sptr - createPeaksWorkspace(const std::string coordFrame, + createPeaksWorkspace(const std::string &coordFrame, const Mantid::Kernel::V3D &peakPosition) { PeaksWorkspace_sptr ws = WorkspaceCreationHelper::createPeaksWorkspace(1); auto detectorIds = ws->getInstrument()->getDetectorIDs(); diff --git a/Framework/Crystal/test/PredictPeaksTest.h b/Framework/Crystal/test/PredictPeaksTest.h index 49527be7c592861867a09665fb761e39dc66dc07..9935199443f85d6dc90a1adc0b725c6733c659ac 100644 --- a/Framework/Crystal/test/PredictPeaksTest.h +++ b/Framework/Crystal/test/PredictPeaksTest.h @@ -20,6 +20,8 @@ #include "MantidTestHelpers/WorkspaceCreationHelper.h" #include <cxxtest/TestSuite.h> +#include <utility> + using namespace Mantid; using namespace Mantid::Crystal; using namespace Mantid::API; @@ -37,8 +39,8 @@ public: } /** Make a HKL peaks workspace */ - PeaksWorkspace_sptr getHKLpw(Instrument_sptr inst, std::vector<V3D> hkls, - detid_t detid) { + PeaksWorkspace_sptr getHKLpw(const Instrument_sptr &inst, + const std::vector<V3D> &hkls, detid_t detid) { PeaksWorkspace_sptr hklPW; if (hkls.size() > 0) { hklPW = PeaksWorkspace_sptr(new PeaksWorkspace()); @@ -51,9 +53,9 @@ public: return hklPW; } - void do_test_exec(std::string reflectionCondition, size_t expectedNumber, - std::vector<V3D> hkls, int convention = 1, - bool useExtendedDetectorSpace = false, + void do_test_exec(const std::string &reflectionCondition, + size_t expectedNumber, const std::vector<V3D> &hkls, + int convention = 1, bool useExtendedDetectorSpace = false, bool addExtendedDetectorDefinition = false, int edge = 0) { // Name of the output workspace. std::string outWSName("PredictPeaksTest_OutputWS"); @@ -78,7 +80,7 @@ public: WorkspaceCreationHelper::setOrientedLattice(inWS, 12.0, 12.0, 12.0); WorkspaceCreationHelper::setGoniometer(inWS, 0., 0., 0.); - PeaksWorkspace_sptr hklPW = getHKLpw(inst, hkls, 10000); + PeaksWorkspace_sptr hklPW = getHKLpw(inst, std::move(hkls), 10000); PredictPeaks alg; TS_ASSERT_THROWS_NOTHING(alg.initialize()) diff --git a/Framework/Crystal/test/SaveIsawUBTest.h b/Framework/Crystal/test/SaveIsawUBTest.h index 2f3394f32adf258721b14e3cd155ed25f7805944..e7cbf2bd73192d9a9382bfa6808208b3441283d0 100644 --- a/Framework/Crystal/test/SaveIsawUBTest.h +++ b/Framework/Crystal/test/SaveIsawUBTest.h @@ -90,15 +90,13 @@ public: F1.open(File1.c_str()); F2.open(File2.c_str()); - int line = 1; std::string s; - double val1, val2; - double tolerance; - if (F1.good() && F2.good()) + if (F1.good() && F2.good()) { + int line = 1; for (int row = 0; row < 5; row++) { int NNums = 3; - tolerance = .0000003; + double tolerance = .0000003; if (line > 3) { NNums = 7; tolerance = .0003; @@ -107,6 +105,7 @@ public: for (int N = 0; N < NNums; N++) { s = Mantid::Kernel::Strings::getWord(F1, false); + double val1, val2; if (!Mantid::Kernel::Strings::convert<double>(s, val1)) { stringstream message; message << "Characters on line " << line << " word " << N; @@ -128,7 +127,7 @@ public: Mantid::Kernel::Strings::readToEndOfLine(F2, true); line++; } - else { + } else { TS_ASSERT(F1.good()); TS_ASSERT(F2.good()); remove(File2.c_str()); diff --git a/Framework/Crystal/test/SetGoniometerTest.h b/Framework/Crystal/test/SetGoniometerTest.h index 7646f706be010c9c6b209b41149e5a0f3c8ee89d..1fd24eeefb748ed9d69fa6d20b6df33423a793b7 100644 --- a/Framework/Crystal/test/SetGoniometerTest.h +++ b/Framework/Crystal/test/SetGoniometerTest.h @@ -193,7 +193,7 @@ public: * @param axis0 :: string to pass * @param numExpected :: how many axes should be created (0 or 1) */ - void do_test_param(std::string axis0, size_t numExpected = 0) { + void do_test_param(const std::string &axis0, size_t numExpected = 0) { Workspace2D_sptr ws = WorkspaceCreationHelper::create2DWorkspace(10, 10); AnalysisDataService::Instance().addOrReplace("SetGoniometerTest_ws", ws); FrameworkManager::Instance().exec( diff --git a/Framework/Crystal/test/SortPeaksWorkspaceTest.h b/Framework/Crystal/test/SortPeaksWorkspaceTest.h index 5f31efbb3aeea9b94889016314430f0083e824f9..3dac4e70097fa8cf84ac11f679276c0e0ce074ca 100644 --- a/Framework/Crystal/test/SortPeaksWorkspaceTest.h +++ b/Framework/Crystal/test/SortPeaksWorkspaceTest.h @@ -25,7 +25,8 @@ private: * @param inWS : Input workspace to sort * @param columnName : Column name to sort by */ - void doExecute(IPeaksWorkspace_sptr inWS, const std::string &columnName, + void doExecute(const IPeaksWorkspace_sptr &inWS, + const std::string &columnName, const bool sortAscending = true) { std::string outWSName("SortPeaksWorkspaceTest_OutputWS"); diff --git a/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/FitPowderDiffPeaks.h b/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/FitPowderDiffPeaks.h index 382b647c796fb57f463c7c271c14dd7fd194aa04..d20969b16a4aa626ab03e055f14807804487cc4a 100644 --- a/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/FitPowderDiffPeaks.h +++ b/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/FitPowderDiffPeaks.h @@ -72,7 +72,7 @@ private: void processInputProperties(); /// Generate peaks from input table workspace - void genPeaksFromTable(DataObjects::TableWorkspace_sptr peakparamws); + void genPeaksFromTable(const DataObjects::TableWorkspace_sptr &peakparamws); /// Generate a peak Functions::BackToBackExponential_sptr @@ -86,11 +86,11 @@ private: /// Import instrument parameters from (input) table workspace void importInstrumentParameterFromTable( - DataObjects::TableWorkspace_sptr parameterWS); + const DataObjects::TableWorkspace_sptr ¶meterWS); /// Import Bragg peak table workspace void - parseBraggPeakTable(DataObjects::TableWorkspace_sptr peakws, + parseBraggPeakTable(const DataObjects::TableWorkspace_sptr &peakws, std::vector<std::map<std::string, double>> ¶mmaps, std::vector<std::map<std::string, int>> &hklmaps); @@ -108,27 +108,26 @@ private: //--------------------------------------------------------------------------- /// Fit single peak in robust mode (no hint) - bool - fitSinglePeakRobust(Functions::BackToBackExponential_sptr peak, - Functions::BackgroundFunction_sptr backgroundfunction, - double peakleftbound, double peakrightbound, - std::map<std::string, double> rightpeakparammap, - double &finalchi2); + bool fitSinglePeakRobust( + const Functions::BackToBackExponential_sptr &peak, + const Functions::BackgroundFunction_sptr &backgroundfunction, + double peakleftbound, double peakrightbound, + const std::map<std::string, double> &rightpeakparammap, + double &finalchi2); /// Fit signle peak by Monte Carlo/simulated annealing - bool - fitSinglePeakSimulatedAnnealing(Functions::BackToBackExponential_sptr peak, - std::vector<std::string> paramtodomc); + bool fitSinglePeakSimulatedAnnealing( + const Functions::BackToBackExponential_sptr &peak, + const std::vector<std::string> ¶mtodomc); /// Fit peak with confidence of the centre bool fitSinglePeakConfidentX(Functions::BackToBackExponential_sptr peak); /// Fit peak with trustful peak parameters - bool - fitSinglePeakConfident(Functions::BackToBackExponential_sptr peak, - Functions::BackgroundFunction_sptr backgroundfunction, - double leftbound, double rightbound, double &chi2, - bool &annhilatedpeak); + bool fitSinglePeakConfident( + const Functions::BackToBackExponential_sptr &peak, + const Functions::BackgroundFunction_sptr &backgroundfunction, + double leftbound, double rightbound, double &chi2, bool &annhilatedpeak); /// Fit peak with confident parameters bool fitSinglePeakConfidentY(DataObjects::Workspace2D_sptr dataws, @@ -136,33 +135,32 @@ private: double dampingfactor); /// Fit peaks with confidence in fwhm and etc. - bool - fitOverlappedPeaks(std::vector<Functions::BackToBackExponential_sptr> peaks, - Functions::BackgroundFunction_sptr backgroundfunction, - double gfwhm); + bool fitOverlappedPeaks( + std::vector<Functions::BackToBackExponential_sptr> peaks, + const Functions::BackgroundFunction_sptr &backgroundfunction, + double gfwhm); /// Fit multiple (overlapped) peaks bool doFitMultiplePeaks( - DataObjects::Workspace2D_sptr dataws, size_t wsindex, - API::CompositeFunction_sptr peaksfunc, + const DataObjects::Workspace2D_sptr &dataws, size_t wsindex, + const API::CompositeFunction_sptr &peaksfunc, std::vector<Functions::BackToBackExponential_sptr> peakfuncs, std::vector<bool> &vecfitgood, std::vector<double> &vecchi2s); /// Use Le Bail method to estimate and set the peak heights void estimatePeakHeightsLeBail( - DataObjects::Workspace2D_sptr dataws, size_t wsindex, + const DataObjects::Workspace2D_sptr &dataws, size_t wsindex, std::vector<Functions::BackToBackExponential_sptr> peaks); /// Set constraints on a group of overlapped peaks for fitting void setOverlappedPeaksConstraints( - std::vector<Functions::BackToBackExponential_sptr> peaks); + const std::vector<Functions::BackToBackExponential_sptr> &peaks); /// Fit 1 peak by 1 minimizer of 1 call of minimzer (simple version) - bool doFit1PeakSimple(DataObjects::Workspace2D_sptr dataws, - size_t workspaceindex, - Functions::BackToBackExponential_sptr peakfunction, - std::string minimzername, size_t maxiteration, - double &chi2); + bool doFit1PeakSimple( + const DataObjects::Workspace2D_sptr &dataws, size_t workspaceindex, + const Functions::BackToBackExponential_sptr &peakfunction, + const std::string &minimzername, size_t maxiteration, double &chi2); /// Fit 1 peak and background // bool doFit1PeakBackgroundSimple(DataObjects::Workspace2D_sptr dataws, @@ -172,33 +170,32 @@ private: // string minimzername, size_t maxiteration, double &chi2); /// Fit single peak with background to raw data - bool - doFit1PeakBackground(DataObjects::Workspace2D_sptr dataws, size_t wsindex, - Functions::BackToBackExponential_sptr peak, - Functions::BackgroundFunction_sptr backgroundfunction, - double &chi2); + bool doFit1PeakBackground( + const DataObjects::Workspace2D_sptr &dataws, size_t wsindex, + const Functions::BackToBackExponential_sptr &peak, + const Functions::BackgroundFunction_sptr &backgroundfunction, + double &chi2); /// Fit 1 peak by using a sequential of minimizer - bool doFit1PeakSequential(DataObjects::Workspace2D_sptr dataws, - size_t workspaceindex, - Functions::BackToBackExponential_sptr peakfunction, - std::vector<std::string> minimzernames, - std::vector<size_t> maxiterations, - std::vector<double> dampfactors, double &chi2); + bool doFit1PeakSequential( + const DataObjects::Workspace2D_sptr &dataws, size_t workspaceindex, + const Functions::BackToBackExponential_sptr &peakfunction, + std::vector<std::string> minimzernames, std::vector<size_t> maxiterations, + const std::vector<double> &dampfactors, double &chi2); /// Fit N overlapped peaks in a simple manner bool doFitNPeaksSimple( - DataObjects::Workspace2D_sptr dataws, size_t wsindex, - API::CompositeFunction_sptr peaksfunc, - std::vector<Functions::BackToBackExponential_sptr> peakfuncs, - std::string minimizername, size_t maxiteration, double &chi2); + const DataObjects::Workspace2D_sptr &dataws, size_t wsindex, + const API::CompositeFunction_sptr &peaksfunc, + const std::vector<Functions::BackToBackExponential_sptr> &peakfuncs, + const std::string &minimizername, size_t maxiteration, double &chi2); /// Store the function's parameter values to a map - void storeFunctionParameters(API::IFunction_sptr function, + void storeFunctionParameters(const API::IFunction_sptr &function, std::map<std::string, double> ¶mmaps); /// Restore the function's parameter values from a map - void restoreFunctionParameters(API::IFunction_sptr function, + void restoreFunctionParameters(const API::IFunction_sptr &function, std::map<std::string, double> parammap); /// Calculate the range to fit peak/peaks group @@ -225,7 +222,8 @@ private: void cropWorkspace(double tofmin, double tofmax); /// Parse Fit() output parameter workspace - std::string parseFitParameterWorkspace(API::ITableWorkspace_sptr paramws); + std::string + parseFitParameterWorkspace(const API::ITableWorkspace_sptr ¶mws); /// Build a partial workspace from source // DataObjects::Workspace2D_sptr @@ -240,8 +238,8 @@ private: double &chi2); /// Observe peak range with hint from right peak's properties - void observePeakRange(Functions::BackToBackExponential_sptr thispeak, - Functions::BackToBackExponential_sptr rightpeak, + void observePeakRange(const Functions::BackToBackExponential_sptr &thispeak, + const Functions::BackToBackExponential_sptr &rightpeak, double refpeakshift, double &peakleftbound, double &peakrightbound); @@ -268,12 +266,12 @@ private: bool calchi2); std::pair<bool, double> - doFitPeak(DataObjects::Workspace2D_sptr dataws, - Functions::BackToBackExponential_sptr peakfunction, + doFitPeak(const DataObjects::Workspace2D_sptr &dataws, + const Functions::BackToBackExponential_sptr &peakfunction, double guessedfwhm); /// Fit background-removed peak by Gaussian - bool doFitGaussianPeak(DataObjects::Workspace2D_sptr dataws, + bool doFitGaussianPeak(const DataObjects::Workspace2D_sptr &dataws, size_t workspaceindex, double in_center, double leftfwhm, double rightfwhm, double ¢er, double &sigma, double &height); @@ -288,28 +286,28 @@ private: Functions::BackgroundFunction_sptr background); /// Parse the fitting result - std::string parseFitResult(API::IAlgorithm_sptr fitalg, double &chi2, + std::string parseFitResult(const API::IAlgorithm_sptr &fitalg, double &chi2, bool &fitsuccess); /// Calculate a Bragg peak's centre in TOF from its Miller indices double calculatePeakCentreTOF(int h, int k, int l); /// Get parameter value from m_instrumentParameters - double getParameter(std::string parname); + double getParameter(const std::string &parname); /// Fit peaks in the same group (i.e., single peak or overlapped peaks) void fitPeaksGroup(std::vector<size_t> peakindexes); /// Build partial workspace for fitting DataObjects::Workspace2D_sptr - buildPartialWorkspace(API::MatrixWorkspace_sptr sourcews, + buildPartialWorkspace(const API::MatrixWorkspace_sptr &sourcews, size_t workspaceindex, double leftbound, double rightbound); /// Plot a single peak to output vector - void plotFunction(API::IFunction_sptr peakfunction, - Functions::BackgroundFunction_sptr background, - API::FunctionDomain1DVector domain); + void plotFunction(const API::IFunction_sptr &peakfunction, + const Functions::BackgroundFunction_sptr &background, + const API::FunctionDomain1DVector &domain); //----------------------------------------------------------------------------------------------- @@ -411,25 +409,25 @@ inline double linearInterpolateY(double x0, double xf, double y0, double yf, } /// Estimate background for a pattern in a coarse mode -void estimateBackgroundCoarse(DataObjects::Workspace2D_sptr dataws, - Functions::BackgroundFunction_sptr background, - size_t wsindexraw, size_t wsindexbkgd, - size_t wsindexpeak); +void estimateBackgroundCoarse( + const DataObjects::Workspace2D_sptr &dataws, + const Functions::BackgroundFunction_sptr &background, size_t wsindexraw, + size_t wsindexbkgd, size_t wsindexpeak); /// Estimate peak parameters; -bool observePeakParameters(DataObjects::Workspace2D_sptr dataws, size_t wsindex, - double ¢re, double &height, double &fwhm, - std::string &errmsg); +bool observePeakParameters(const DataObjects::Workspace2D_sptr &dataws, + size_t wsindex, double ¢re, double &height, + double &fwhm, std::string &errmsg); /// Find maximum value size_t findMaxValue(const std::vector<double> &Y); /// Find maximum value -size_t findMaxValue(API::MatrixWorkspace_sptr dataws, size_t wsindex, +size_t findMaxValue(const API::MatrixWorkspace_sptr &dataws, size_t wsindex, double leftbound, double rightbound); /// Get function parameter name, value and etc information in string -std::string getFunctionInfo(API::IFunction_sptr function); +std::string getFunctionInfo(const API::IFunction_sptr &function); } // namespace Algorithms } // namespace CurveFitting diff --git a/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/LeBailFit.h b/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/LeBailFit.h index a0c846385dbe8ac6d2f09350d1904a12eab57e5c..0d881f945b04203bf9be092a08c0bb5d18836f70 100644 --- a/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/LeBailFit.h +++ b/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/LeBailFit.h @@ -37,26 +37,26 @@ namespace Algorithms { struct Parameter { // Regular std::string name; - double curvalue; - double prevalue; - double minvalue; - double maxvalue; - bool fit; - double stepsize; - double fiterror; + double curvalue = 0; + double prevalue = 0; + double minvalue = 0; + double maxvalue = 0; + bool fit = false; + double stepsize = 0; + double fiterror = 0; // Monte Carlo - bool nonnegative; - double mcA0; - double mcA1; + bool nonnegative = false; + double mcA0 = 0; + double mcA1 = 0; // Monte Carlo record - double sumstepsize; - double maxabsstepsize; - double maxrecordvalue; - double minrecordvalue; - size_t numpositivemove; - size_t numnegativemove; - size_t numnomove; - int movedirection; + double sumstepsize = 0; + double maxabsstepsize = 0; + double maxrecordvalue = 0; + double minrecordvalue = 0; + size_t numpositivemove = 0; + size_t numnegativemove = 0; + size_t numnomove = 0; + int movedirection = 0; }; class MANTID_CURVEFITTING_DLL LeBailFit : public API::Algorithm { @@ -103,8 +103,8 @@ private: void createLeBailFunction(); /// Crop the workspace for better usage - API::MatrixWorkspace_sptr cropWorkspace(API::MatrixWorkspace_sptr inpws, - size_t wsindex); + API::MatrixWorkspace_sptr + cropWorkspace(const API::MatrixWorkspace_sptr &inpws, size_t wsindex); /// Process and calculate input background void processInputBackground(); @@ -123,10 +123,10 @@ private: void parseBraggPeaksParametersTable(); /// Parse content in a table workspace to vector for background parameters - void - parseBackgroundTableWorkspace(DataObjects::TableWorkspace_sptr bkgdparamws, - std::vector<std::string> &bkgdparnames, - std::vector<double> &bkgdorderparams); + void parseBackgroundTableWorkspace( + const DataObjects::TableWorkspace_sptr &bkgdparamws, + std::vector<std::string> &bkgdparnames, + std::vector<double> &bkgdorderparams); /// Create and set up output table workspace for peaks void exportBraggPeakParameterToTable(); @@ -153,12 +153,12 @@ private: /// Set up Monte Carlo random walk strategy void setupBuiltInRandomWalkStrategy(); - void - setupRandomWalkStrategyFromTable(DataObjects::TableWorkspace_sptr tablews); + void setupRandomWalkStrategyFromTable( + const DataObjects::TableWorkspace_sptr &tablews); /// Add parameter (to a vector of string/name) for MC random walk void addParameterToMCMinimize(std::vector<std::string> &parnamesforMC, - std::string parname); + const std::string &parname); /// Calculate diffraction pattern in Le Bail algorithm for MC Random walk bool calculateDiffractionPattern( @@ -171,7 +171,8 @@ private: bool acceptOrDeny(Kernel::Rfactor currR, Kernel::Rfactor newR); /// Propose new parameters - bool proposeNewValues(std::vector<std::string> mcgroup, Kernel::Rfactor r, + bool proposeNewValues(const std::vector<std::string> &mcgroup, + Kernel::Rfactor r, std::map<std::string, Parameter> &curparammap, std::map<std::string, Parameter> &newparammap, bool prevBetterRwp); @@ -308,7 +309,7 @@ private: /// Write a set of (XY) data to a column file void writeRfactorsToFile(std::vector<double> vecX, std::vector<Kernel::Rfactor> vecR, - std::string filename); + const std::string &filename); } // namespace Algorithms } // namespace CurveFitting diff --git a/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/LeBailFunction.h b/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/LeBailFunction.h index b4a9afb28203e59ec4f25681bec2313af9dff09b..754025d1c0d588d147f649f92b34db3df7f8c50a 100644 --- a/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/LeBailFunction.h +++ b/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/LeBailFunction.h @@ -34,7 +34,7 @@ it is rewritten. class MANTID_CURVEFITTING_DLL LeBailFunction { public: /// Constructor - LeBailFunction(std::string peaktype); + LeBailFunction(const std::string &peaktype); /// Destructor virtual ~LeBailFunction(); @@ -43,14 +43,14 @@ public: void setProfileParameterValues(std::map<std::string, double> parammap); /// Set up a parameter to fit but tied among all peaks - void setFitProfileParameter(std::string paramname, double minvalue, + void setFitProfileParameter(const std::string ¶mname, double minvalue, double maxvalue); /// Function - void setPeakHeights(std::vector<double> inheights); + void setPeakHeights(const std::vector<double> &inheights); /// Check whether a parameter is a profile parameter - bool hasProfileParameter(std::string paramname); + bool hasProfileParameter(const std::string ¶mname); /// Check whether the newly set parameters are correct, i.e., all peaks are /// physical @@ -63,7 +63,7 @@ public: void addPeaks(std::vector<std::vector<int>> peakhkls); /// Add background function - void addBackgroundFunction(std::string backgroundtype, + void addBackgroundFunction(const std::string &backgroundtype, const unsigned int &order, const std::vector<std::string> &vecparnames, const std::vector<double> &vecparvalues, @@ -91,13 +91,14 @@ public: void calPeaksParameters(); /// Get peak parameters (calculated) - double getPeakParameter(size_t index, std::string parname) const; + double getPeakParameter(size_t index, const std::string &parname) const; /// Get peak parameters (calculated) - double getPeakParameter(std::vector<int> hkl, std::string parname) const; + double getPeakParameter(std::vector<int> hkl, + const std::string &parname) const; /// Set up a parameter to be fixed - void fixPeakParameter(std::string paramname, double paramvalue); + void fixPeakParameter(const std::string ¶mname, double paramvalue); /// Fix all background parameters void fixBackgroundParameters(); @@ -116,13 +117,13 @@ public: private: /// Set peak parameters - void setPeakParameters(API::IPowderDiffPeakFunction_sptr peak, - std::map<std::string, double> parammap, + void setPeakParameters(const API::IPowderDiffPeakFunction_sptr &peak, + const std::map<std::string, double> ¶mmap, double peakheight, bool setpeakheight); /// Retrieve peak's parameter. may be native or calculated - double getPeakParameterValue(API::IPowderDiffPeakFunction_sptr peak, - std::string parname) const; + double getPeakParameterValue(const API::IPowderDiffPeakFunction_sptr &peak, + const std::string &parname) const; /// Calculate all peaks' parameter value void calculatePeakParameterValues() const; diff --git a/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/PlotPeakByLogValue.h b/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/PlotPeakByLogValue.h index 37df79315c5ba5367ba53740125b17756660d081..6e6e97f2d6b2739b5d9f640f618eb5c459f9beb9 100644 --- a/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/PlotPeakByLogValue.h +++ b/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/PlotPeakByLogValue.h @@ -64,7 +64,8 @@ private: void exec() override; /// Set any WorkspaceIndex attributes in the fitting function - void setWorkspaceIndexAttribute(API::IFunction_sptr fun, int wsIndex) const; + void setWorkspaceIndexAttribute(const API::IFunction_sptr &fun, + int wsIndex) const; boost::shared_ptr<Algorithm> runSingleFit(bool createFitOutput, bool outputCompositeMembers, @@ -72,7 +73,8 @@ private: const API::IFunction_sptr &ifun, const InputSpectraToFit &data); - double calculateLogValue(std::string logName, const InputSpectraToFit &data); + double calculateLogValue(const std::string &logName, + const InputSpectraToFit &data); API::ITableWorkspace_sptr createResultsTable(const std::string &logName, diff --git a/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/PlotPeakByLogValueHelper.h b/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/PlotPeakByLogValueHelper.h index 68fbe1598766d91b068c3e7a28582f6ac713a066..f83cabaeb310fa25d0154a6b7de8e7c80762ffc8 100644 --- a/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/PlotPeakByLogValueHelper.h +++ b/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/PlotPeakByLogValueHelper.h @@ -42,7 +42,7 @@ getWorkspace(const std::string &name, int period); /// Create a list of input workspace names MANTID_CURVEFITTING_DLL std::vector<InputSpectraToFit> -makeNames(std::string inputList, int default_wi, int default_spec); +makeNames(const std::string &inputList, int default_wi, int default_spec); enum SpecialIndex { NOT_SET = -1, diff --git a/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/QENSFitSequential.h b/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/QENSFitSequential.h index dc0a910b53f81ab94c0fabc29799659df0ccc26d..32f8dfa3c1c9c47b1d73b68236d989947df35f62 100644 --- a/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/QENSFitSequential.h +++ b/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/QENSFitSequential.h @@ -46,8 +46,8 @@ private: API::ITableWorkspace_sptr performFit(const std::string &input, const std::string &output); void deleteTemporaryWorkspaces(const std::string &outputBaseName); - void addAdditionalLogs(API::WorkspaceGroup_sptr resultWorkspace); - void addAdditionalLogs(API::Workspace_sptr result); + void addAdditionalLogs(const API::WorkspaceGroup_sptr &resultWorkspace); + void addAdditionalLogs(const API::Workspace_sptr &result); virtual bool throwIfElasticQConversionFails() const; virtual bool isFitParameter(const std::string ¶meterName) const; @@ -57,9 +57,9 @@ private: const std::vector<API::MatrixWorkspace_sptr> &workspaces) const; std::vector<std::size_t> getDatasetGrouping( const std::vector<API::MatrixWorkspace_sptr> &workspaces) const; - API::WorkspaceGroup_sptr - processIndirectFitParameters(API::ITableWorkspace_sptr parameterWorkspace, - const std::vector<std::size_t> &grouping); + API::WorkspaceGroup_sptr processIndirectFitParameters( + const API::ITableWorkspace_sptr ¶meterWorkspace, + const std::vector<std::size_t> &grouping); std::vector<API::MatrixWorkspace_sptr> convertInputToElasticQ( const std::vector<API::MatrixWorkspace_sptr> &workspaces) const; @@ -77,20 +77,20 @@ private: std::vector<std::string> const &spectra, std::string const &outputBaseName, std::string const &endOfSuffix); - void copyLogs(API::WorkspaceGroup_sptr resultWorkspaces, + void copyLogs(const API::WorkspaceGroup_sptr &resultWorkspaces, std::vector<API::MatrixWorkspace_sptr> const &workspaces); - void copyLogs(API::Workspace_sptr resultWorkspace, + void copyLogs(const API::Workspace_sptr &resultWorkspace, std::vector<API::MatrixWorkspace_sptr> const &workspaces); - void copyLogs(API::MatrixWorkspace_sptr resultWorkspace, - API::WorkspaceGroup_sptr resultGroup); - void copyLogs(API::MatrixWorkspace_sptr resultWorkspace, - API::Workspace_sptr resultGroup); - void extractMembers(API::WorkspaceGroup_sptr resultGroupWs, + void copyLogs(const API::MatrixWorkspace_sptr &resultWorkspace, + const API::WorkspaceGroup_sptr &resultGroup); + void copyLogs(const API::MatrixWorkspace_sptr &resultWorkspace, + const API::Workspace_sptr &resultGroup); + void extractMembers(const API::WorkspaceGroup_sptr &resultGroupWs, const std::vector<API::MatrixWorkspace_sptr> &workspaces, const std::string &outputWsName); API::IAlgorithm_sptr - extractMembersAlgorithm(API::WorkspaceGroup_sptr resultGroupWs, + extractMembersAlgorithm(const API::WorkspaceGroup_sptr &resultGroupWs, const std::string &outputWsName) const; std::string getTemporaryName() const; diff --git a/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/QENSFitSimultaneous.h b/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/QENSFitSimultaneous.h index 67075de0d749e849c84ce5ecfada6900df137aac..d6af7bbfa52c4bc7d43e5c901a58f537aab3bd4b 100644 --- a/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/QENSFitSimultaneous.h +++ b/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/QENSFitSimultaneous.h @@ -47,27 +47,27 @@ private: std::pair<API::ITableWorkspace_sptr, API::Workspace_sptr> performFit(const std::vector<API::MatrixWorkspace_sptr> &workspaces, const std::string &output); - API::WorkspaceGroup_sptr - processIndirectFitParameters(API::ITableWorkspace_sptr parameterWorkspace, - const std::vector<std::size_t> &grouping); - void copyLogs(API::WorkspaceGroup_sptr resultWorkspace, + API::WorkspaceGroup_sptr processIndirectFitParameters( + const API::ITableWorkspace_sptr ¶meterWorkspace, + const std::vector<std::size_t> &grouping); + void copyLogs(const API::WorkspaceGroup_sptr &resultWorkspace, const std::vector<API::MatrixWorkspace_sptr> &workspaces); - void copyLogs(API::MatrixWorkspace_sptr resultWorkspace, - API::WorkspaceGroup_sptr resultGroup); - void extractMembers(API::WorkspaceGroup_sptr resultGroupWs, + void copyLogs(const API::MatrixWorkspace_sptr &resultWorkspace, + const API::WorkspaceGroup_sptr &resultGroup); + void extractMembers(const API::WorkspaceGroup_sptr &resultGroupWs, const std::vector<API::MatrixWorkspace_sptr> &workspaces, const std::string &outputWsName); - void addAdditionalLogs(API::WorkspaceGroup_sptr group); - void addAdditionalLogs(API::Workspace_sptr result); + void addAdditionalLogs(const API::WorkspaceGroup_sptr &group); + void addAdditionalLogs(const API::Workspace_sptr &result); API::IAlgorithm_sptr - extractMembersAlgorithm(API::WorkspaceGroup_sptr resultGroupWs, + extractMembersAlgorithm(const API::WorkspaceGroup_sptr &resultGroupWs, const std::string &outputWsName) const; std::string getOutputBaseName() const; std::vector<std::string> getWorkspaceNames() const; std::vector<std::string> getWorkspaceIndices() const; - void renameWorkspaces(API::WorkspaceGroup_sptr outputGroup, + void renameWorkspaces(const API::WorkspaceGroup_sptr &outputGroup, std::vector<std::string> const &spectra, std::string const &outputBaseName, std::string const &endOfSuffix, diff --git a/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/QENSFitUtilities.h b/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/QENSFitUtilities.h index 33e822287227570a0bcc5b6c1cd7833ec0834292..4972f7be065693fe668557f9c998f53ec9e32ba5 100644 --- a/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/QENSFitUtilities.h +++ b/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/QENSFitUtilities.h @@ -16,7 +16,7 @@ namespace API { void renameWorkspacesInQENSFit( Algorithm *qensFit, IAlgorithm_sptr renameAlgorithm, - WorkspaceGroup_sptr outputGroup, std::string const &outputBaseName, + const WorkspaceGroup_sptr &outputGroup, std::string const &outputBaseName, std::string const &groupSuffix, std::function<std::string(std::size_t)> const &getNameSuffix); diff --git a/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/RefinePowderInstrumentParameters.h b/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/RefinePowderInstrumentParameters.h index c30d735b846aae5cb23f661b7a48ffb924f4aa11..7afd36cdd810a0b6f916552b6106acbebc453177 100644 --- a/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/RefinePowderInstrumentParameters.h +++ b/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/RefinePowderInstrumentParameters.h @@ -67,20 +67,22 @@ private: //---------------- Processing Input --------------------- /// Import instrument parameter from table (workspace) - void importParametersFromTable(DataObjects::TableWorkspace_sptr parameterWS, - std::map<std::string, double> ¶meters); + void + importParametersFromTable(const DataObjects::TableWorkspace_sptr ¶meterWS, + std::map<std::string, double> ¶meters); /// Import the Monte Carlo related parameters from table void importMonteCarloParametersFromTable( - DataObjects::TableWorkspace_sptr tablews, - std::vector<std::string> parameternames, std::vector<double> &stepsizes, - std::vector<double> &lowerbounds, std::vector<double> &upperbounds); + const DataObjects::TableWorkspace_sptr &tablews, + const std::vector<std::string> ¶meternames, + std::vector<double> &stepsizes, std::vector<double> &lowerbounds, + std::vector<double> &upperbounds); /// Generate (output) workspace of peak centers void genPeakCentersWorkspace(bool montecarlo, size_t numbestfit); /// Generate peaks from table (workspace) - void genPeaksFromTable(DataObjects::TableWorkspace_sptr peakparamws); + void genPeaksFromTable(const DataObjects::TableWorkspace_sptr &peakparamws); //--------------- Processing Output ------------------ /// Generate (output) table worksspace for instrument parameters @@ -94,12 +96,12 @@ private: void fitInstrumentParameters(); /// Calculate function's statistic - double calculateFunctionStatistic(API::IFunction_sptr func, - API::MatrixWorkspace_sptr dataws, + double calculateFunctionStatistic(const API::IFunction_sptr &func, + const API::MatrixWorkspace_sptr &dataws, size_t workspaceindex); /// Fit function to data - bool fitFunction(API::IFunction_sptr func, double &gslchi2); + bool fitFunction(const API::IFunction_sptr &func, double &gslchi2); /// Parse Fit() output parameter workspace std::string parseFitParameterWorkspace(API::ITableWorkspace_sptr paramws); @@ -108,9 +110,8 @@ private: std::string parseFitResult(API::IAlgorithm_sptr fitalg, double &chi2); /// Set up and run a monte carlo simulation to refine the peak parameters - void - refineInstrumentParametersMC(DataObjects::TableWorkspace_sptr parameterWS, - bool fit2 = false); + void refineInstrumentParametersMC( + const DataObjects::TableWorkspace_sptr ¶meterWS, bool fit2 = false); /// Core Monte Carlo random walk on parameter-space void doParameterSpaceRandomWalk(std::vector<std::string> parnames, @@ -124,8 +125,8 @@ private: void getD2TOFFuncParamNames(std::vector<std::string> &parnames); /// Calculate the value and chi2 - double calculateD2TOFFunction(API::IFunction_sptr func, - API::FunctionDomain1DVector domain, + double calculateD2TOFFunction(const API::IFunction_sptr &func, + const API::FunctionDomain1DVector &domain, API::FunctionValues &values, const Mantid::HistogramData::HistogramY &rawY, const Mantid::HistogramData::HistogramE &rawE); @@ -135,7 +136,7 @@ private: /// Calculate value n for thermal neutron peak profile void - calculateThermalNeutronSpecial(API::IFunction_sptr m_Function, + calculateThermalNeutronSpecial(const API::IFunction_sptr &m_Function, const Mantid::HistogramData::HistogramX &xVals, std::vector<double> &vec_n); diff --git a/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/RefinePowderInstrumentParameters3.h b/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/RefinePowderInstrumentParameters3.h index 22fc3367b2ee22da0bcc0c335ad3b6e595628c2f..bab383a92adf26d2cc43bea5bb075e9f2c99e6d2 100644 --- a/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/RefinePowderInstrumentParameters3.h +++ b/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/RefinePowderInstrumentParameters3.h @@ -68,11 +68,11 @@ private: /// Add parameter (to a vector of string/name) for MC random walk void addParameterToMCMinimize(std::vector<std::string> &parnamesforMC, - std::string parname, + const std::string &parname, std::map<std::string, Parameter> parammap); /// Propose new parameters - void proposeNewValues(std::vector<std::string> mcgroup, + void proposeNewValues(const std::vector<std::string> &mcgroup, std::map<std::string, Parameter> &curparammap, std::map<std::string, Parameter> &newparammap, double currchisq); @@ -88,23 +88,23 @@ private: // maxnumresults); /// Implement parameter values, calculate function and its chi square. - double calculateFunction(std::map<std::string, Parameter> parammap, + double calculateFunction(const std::map<std::string, Parameter> ¶mmap, std::vector<double> &vecY); /// Calculate Chi^2 of the a function with all parameters are fixed - double calculateFunctionError(API::IFunction_sptr function, - DataObjects::Workspace2D_sptr dataws, + double calculateFunctionError(const API::IFunction_sptr &function, + const DataObjects::Workspace2D_sptr &dataws, int wsindex); /// Fit function by non MC minimzer(s) - double fitFunction(API::IFunction_sptr function, - DataObjects::Workspace2D_sptr dataws, int wsindex, + double fitFunction(const API::IFunction_sptr &function, + const DataObjects::Workspace2D_sptr &dataws, int wsindex, bool powerfit); /// Fit function (single step) - bool doFitFunction(API::IFunction_sptr function, - DataObjects::Workspace2D_sptr dataws, int wsindex, - std::string minimizer, int numiters, double &chi2, + bool doFitFunction(const API::IFunction_sptr &function, + const DataObjects::Workspace2D_sptr &dataws, int wsindex, + const std::string &minimizer, int numiters, double &chi2, std::string &fitstatus); /// Process input properties @@ -114,11 +114,11 @@ private: void parseTableWorkspaces(); /// Parse table workspace to a map of Parameters - void parseTableWorkspace(DataObjects::TableWorkspace_sptr tablews, + void parseTableWorkspace(const DataObjects::TableWorkspace_sptr &tablews, std::map<std::string, Parameter> ¶mmap); /// Set parameter values to function from Parameter map - void setFunctionParameterValues(API::IFunction_sptr function, + void setFunctionParameterValues(const API::IFunction_sptr &function, std::map<std::string, Parameter> params); /// Update parameter values to Parameter map from fuction map @@ -127,13 +127,13 @@ private: /// Set parameter fitting setup (boundary, fix or unfix) to function from /// Parameter map - void setFunctionParameterFitSetups(API::IFunction_sptr function, + void setFunctionParameterFitSetups(const API::IFunction_sptr &function, std::map<std::string, Parameter> params); /// Construct output DataObjects::Workspace2D_sptr - genOutputWorkspace(API::FunctionDomain1DVector domain, - API::FunctionValues rawvalues); + genOutputWorkspace(const API::FunctionDomain1DVector &domain, + const API::FunctionValues &rawvalues); /// Construct an output TableWorkspace for refined peak profile parameters DataObjects::TableWorkspace_sptr @@ -143,7 +143,7 @@ private: /// Add a parameter to parameter map. If this parametere does exist, then /// replace the value of it void addOrReplace(std::map<std::string, Parameter> ¶meters, - std::string parname, double parvalue); + const std::string &parname, double parvalue); //-------- Variables ------------------------------------------------------ /// Data workspace containg peak positions @@ -189,17 +189,19 @@ void convertToDict(std::vector<std::string> strvec, std::map<std::string, size_t> &lookupdict); /// Get the index from lookup dictionary (map) -int getStringIndex(std::map<std::string, size_t> lookupdict, std::string key); +int getStringIndex(std::map<std::string, size_t> lookupdict, + const std::string &key); /// Store function parameter values to a map void storeFunctionParameterValue( - API::IFunction_sptr function, + const API::IFunction_sptr &function, std::map<std::string, std::pair<double, double>> &parvaluemap); /// Restore function parameter values to a map void restoreFunctionParameterValue( std::map<std::string, std::pair<double, double>> parvaluemap, - API::IFunction_sptr function, std::map<std::string, Parameter> ¶mmap); + const API::IFunction_sptr &function, + std::map<std::string, Parameter> ¶mmap); /// Copy parameters from source to target void duplicateParameters(std::map<std::string, Parameter> source, diff --git a/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/SplineBackground.h b/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/SplineBackground.h index dd85faa45c48b3593c1d722d64b23a86349bafa6..f88a7ee49f1d1008e7c5858cd59035c4ae9042ac 100644 --- a/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/SplineBackground.h +++ b/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/SplineBackground.h @@ -67,8 +67,8 @@ private: /// Gets the values from the fitted GSL, and creates a clone of input /// workspace with new values - API::MatrixWorkspace_sptr saveSplineOutput(const API::MatrixWorkspace_sptr ws, - const size_t spec); + API::MatrixWorkspace_sptr + saveSplineOutput(const API::MatrixWorkspace_sptr &ws, const size_t spec); /// Sets up the splines for later fitting void setupSpline(double xMin, double xMax, int numBins, int ncoeff); diff --git a/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/SplineInterpolation.h b/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/SplineInterpolation.h index f083aef2a5e86091d87bdd1417187022ddfaa438..74f9b50009991ff95a5688e5b02db5d884df66bf 100644 --- a/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/SplineInterpolation.h +++ b/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/SplineInterpolation.h @@ -50,8 +50,8 @@ private: /// setup an output workspace using meta data from inws and taking a number of /// spectra API::MatrixWorkspace_sptr - setupOutputWorkspace(API::MatrixWorkspace_sptr mws, - API::MatrixWorkspace_sptr iws) const; + setupOutputWorkspace(const API::MatrixWorkspace_sptr &mws, + const API::MatrixWorkspace_sptr &iws) const; /// convert a binned workspace to point data using ConvertToPointData API::MatrixWorkspace_sptr @@ -59,28 +59,32 @@ private: /// set the points that define the spline used for interpolation of a /// workspace - void setInterpolationPoints(API::MatrixWorkspace_const_sptr inputWorkspace, - const size_t row) const; + void + setInterpolationPoints(const API::MatrixWorkspace_const_sptr &inputWorkspace, + const size_t row) const; /// Calculate the interpolation of the input workspace against the spline and /// store it in outputWorkspace - void calculateSpline(API::MatrixWorkspace_const_sptr inputWorkspace, - API::MatrixWorkspace_sptr outputWorkspace, + void calculateSpline(const API::MatrixWorkspace_const_sptr &inputWorkspace, + const API::MatrixWorkspace_sptr &outputWorkspace, const size_t row) const; /// Calculate the derivatives of the input workspace from the spline. - void calculateDerivatives(API::MatrixWorkspace_const_sptr inputWorkspace, - API::MatrixWorkspace_sptr outputWorkspace, - const size_t order) const; + void + calculateDerivatives(const API::MatrixWorkspace_const_sptr &inputWorkspace, + const API::MatrixWorkspace_sptr &outputWorkspace, + const size_t order) const; /// Find the the interpolation range std::pair<size_t, size_t> - findInterpolationRange(API::MatrixWorkspace_const_sptr iwspt, - API::MatrixWorkspace_sptr mwspt, const size_t row); + findInterpolationRange(const API::MatrixWorkspace_const_sptr &iwspt, + const API::MatrixWorkspace_sptr &mwspt, + const size_t row); /// Extrapolates flat for the points outside the x-range - void extrapolateFlat(API::MatrixWorkspace_sptr ows, - API::MatrixWorkspace_const_sptr iwspt, const size_t row, + void extrapolateFlat(const API::MatrixWorkspace_sptr &ows, + const API::MatrixWorkspace_const_sptr &iwspt, + const size_t row, const std::pair<size_t, size_t> &indices, const bool doDerivs, std::vector<API::MatrixWorkspace_sptr> &derivs) const; diff --git a/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/SplineSmoothing.h b/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/SplineSmoothing.h index 044afc59ba7b56844f47d60a76e4a998ec210484..122244214cc8484c970af6a281c85d20607fc472 100644 --- a/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/SplineSmoothing.h +++ b/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/SplineSmoothing.h @@ -87,7 +87,8 @@ private: const double *ysmooth) const; /// Use an existing fit function to tidy smoothing - void performAdditionalFitting(API::MatrixWorkspace_sptr ws, const int row); + void performAdditionalFitting(const API::MatrixWorkspace_sptr &ws, + const int row); /// Converts histogram data to point data later processing /// convert a binned workspace to point data. Uses mean of the bins as point diff --git a/Framework/CurveFitting/inc/MantidCurveFitting/Constraints/BoundaryConstraint.h b/Framework/CurveFitting/inc/MantidCurveFitting/Constraints/BoundaryConstraint.h index 06e2bdf740111eca52ce6268d2ee7b6ca655100d..5a83c4b628ed43a92d79188b51484cda40db48e3 100644 --- a/Framework/CurveFitting/inc/MantidCurveFitting/Constraints/BoundaryConstraint.h +++ b/Framework/CurveFitting/inc/MantidCurveFitting/Constraints/BoundaryConstraint.h @@ -35,12 +35,12 @@ public: BoundaryConstraint(const std::string ¶mName); /// Constructor with boundary arguments - BoundaryConstraint(API::IFunction *fun, const std::string paramName, + BoundaryConstraint(API::IFunction *fun, const std::string ¶mName, const double lowerBound, const double upperBound, bool isDefault = false); /// Constructor with lower boundary argument - BoundaryConstraint(API::IFunction *fun, const std::string paramName, + BoundaryConstraint(API::IFunction *fun, const std::string ¶mName, const double lowerBound, bool isDefault = false); /// Initialize the constraint from an expression diff --git a/Framework/CurveFitting/inc/MantidCurveFitting/CostFunctions/CostFuncRwp.h b/Framework/CurveFitting/inc/MantidCurveFitting/CostFunctions/CostFuncRwp.h index 4b63b8d74e3b2028f3577130940b6b01c9eafda2..044d739a2ee15774a6c3c64037b46a7c2aab8e7b 100644 --- a/Framework/CurveFitting/inc/MantidCurveFitting/CostFunctions/CostFuncRwp.h +++ b/Framework/CurveFitting/inc/MantidCurveFitting/CostFunctions/CostFuncRwp.h @@ -65,12 +65,12 @@ private: getFitWeights(API::FunctionValues_sptr values) const override; /// Get weight (1/sigma) - double getWeight(API::FunctionValues_sptr values, size_t i, + double getWeight(const API::FunctionValues_sptr &values, size_t i, double sqrtW = 1.0) const; /// Calcualte sqrt(W). Final cost function = sum_i [ (obs_i - cal_i) / (sigma /// * sqrt(W))]**2 - double calSqrtW(API::FunctionValues_sptr values) const; + double calSqrtW(const API::FunctionValues_sptr &values) const; friend class CurveFitting::SeqDomain; friend class CurveFitting::ParDomain; diff --git a/Framework/CurveFitting/inc/MantidCurveFitting/Functions/ChebfunBase.h b/Framework/CurveFitting/inc/MantidCurveFitting/Functions/ChebfunBase.h index 7e0abc27ffda2a67775139ac820464a664866e92..29f6560aeef34db60eb850c3f7a7ea2507d1724f 100644 --- a/Framework/CurveFitting/inc/MantidCurveFitting/Functions/ChebfunBase.h +++ b/Framework/CurveFitting/inc/MantidCurveFitting/Functions/ChebfunBase.h @@ -149,7 +149,7 @@ private: void calcIntegrationWeights() const; /// Calculate function values at odd-valued indices of the base x-points - std::vector<double> fitOdd(ChebfunFunctionType f, + std::vector<double> fitOdd(const ChebfunFunctionType &f, std::vector<double> &p) const; /// Calculate function values at odd-valued indices of the base x-points std::vector<double> fitOdd(const API::IFunction &f, diff --git a/Framework/CurveFitting/inc/MantidCurveFitting/Functions/IkedaCarpenterPV.h b/Framework/CurveFitting/inc/MantidCurveFitting/Functions/IkedaCarpenterPV.h index fa533e4bd7576c9dcc0c3ae1e9eb6c032b2121c7..4074de02293556ab543ad486556838515f7eaa04 100644 --- a/Framework/CurveFitting/inc/MantidCurveFitting/Functions/IkedaCarpenterPV.h +++ b/Framework/CurveFitting/inc/MantidCurveFitting/Functions/IkedaCarpenterPV.h @@ -72,7 +72,7 @@ private: double &eta) const; /// constrain all parameters to be non-negative - void lowerConstraint0(std::string paramName); + void lowerConstraint0(const std::string ¶mName); }; } // namespace Functions diff --git a/Framework/CurveFitting/inc/MantidCurveFitting/Functions/PawleyFunction.h b/Framework/CurveFitting/inc/MantidCurveFitting/Functions/PawleyFunction.h index bfa8e696ab8696d993ed9d98c00091e8597e4926..04a22d80889ba4de376403386dcff7ee3edb1e88 100644 --- a/Framework/CurveFitting/inc/MantidCurveFitting/Functions/PawleyFunction.h +++ b/Framework/CurveFitting/inc/MantidCurveFitting/Functions/PawleyFunction.h @@ -134,7 +134,7 @@ public: PawleyParameterFunction_sptr getPawleyParameterFunction() const; protected: - void setPeakPositions(std::string centreName, double zeroShift, + void setPeakPositions(const std::string ¢reName, double zeroShift, const Geometry::UnitCell &cell) const; size_t calculateFunctionValues(const API::IPeakFunction_sptr &peak, diff --git a/Framework/CurveFitting/inc/MantidCurveFitting/Functions/ProcessBackground.h b/Framework/CurveFitting/inc/MantidCurveFitting/Functions/ProcessBackground.h index 84387d058d436ec698564d34519c1a95ef54e2ae..e6c9144c2403f4d540f23714ee10220f24479a65 100644 --- a/Framework/CurveFitting/inc/MantidCurveFitting/Functions/ProcessBackground.h +++ b/Framework/CurveFitting/inc/MantidCurveFitting/Functions/ProcessBackground.h @@ -22,17 +22,18 @@ namespace Functions { class RemovePeaks { public: - void setup(DataObjects::TableWorkspace_sptr peaktablews); + void setup(const DataObjects::TableWorkspace_sptr &peaktablews); DataObjects::Workspace2D_sptr - removePeaks(API::MatrixWorkspace_const_sptr dataws, int wsindex, + removePeaks(const API::MatrixWorkspace_const_sptr &dataws, int wsindex, double numfwhm); private: /// Parse peak centre and FWHM from a table workspace - void parsePeakTableWorkspace(DataObjects::TableWorkspace_sptr peaktablews, - std::vector<double> &vec_peakcentre, - std::vector<double> &vec_peakfwhm); + void + parsePeakTableWorkspace(const DataObjects::TableWorkspace_sptr &peaktablews, + std::vector<double> &vec_peakcentre, + std::vector<double> &vec_peakfwhm); /// Exclude peak regions size_t excludePeaks(std::vector<double> v_inX, std::vector<bool> &v_useX, @@ -83,15 +84,15 @@ private: /// Select background points automatically DataObjects::Workspace2D_sptr - autoBackgroundSelection(DataObjects::Workspace2D_sptr bkgdWS); + autoBackgroundSelection(const DataObjects::Workspace2D_sptr &bkgdWS); /// Create a background function from input properties BackgroundFunction_sptr - createBackgroundFunction(const std::string backgroundtype); + createBackgroundFunction(const std::string &backgroundtype); /// Filter non-background data points out and create a background workspace DataObjects::Workspace2D_sptr - filterForBackground(BackgroundFunction_sptr bkgdfunction); + filterForBackground(const BackgroundFunction_sptr &bkgdfunction); DataObjects::Workspace2D_const_sptr m_dataWS; DataObjects::Workspace2D_sptr m_outputWS; @@ -119,7 +120,7 @@ private: /// Add a certain region from a reference workspace void addRegion(); - void fitBackgroundFunction(std::string bkgdfunctiontype); + void fitBackgroundFunction(const std::string &bkgdfunctiontype); }; } // namespace Functions diff --git a/Framework/CurveFitting/inc/MantidCurveFitting/Functions/SimpleChebfun.h b/Framework/CurveFitting/inc/MantidCurveFitting/Functions/SimpleChebfun.h index 5f7a4a5a543f71d11692994f24f65fb78543b857..b8888d9eac2e6bde875b5f70448c70b4b1e6ba9f 100644 --- a/Framework/CurveFitting/inc/MantidCurveFitting/Functions/SimpleChebfun.h +++ b/Framework/CurveFitting/inc/MantidCurveFitting/Functions/SimpleChebfun.h @@ -25,7 +25,7 @@ public: /// Constructor. SimpleChebfun(size_t n, const API::IFunction &fun, double start, double end); /// Constructor. - SimpleChebfun(ChebfunFunctionType fun, double start, double end, + SimpleChebfun(const ChebfunFunctionType &fun, double start, double end, double accuracy = 0.0, size_t badSize = 10); /// Constructor. SimpleChebfun(const API::IFunction &fun, double start, double end, @@ -67,11 +67,11 @@ public: /// Integrate the function on its interval double integrate() const; /// Add a C++ function to the function - SimpleChebfun &operator+=(ChebfunFunctionType fun); + SimpleChebfun &operator+=(const ChebfunFunctionType &fun); private: /// Constructor - SimpleChebfun(ChebfunBase_sptr base); + SimpleChebfun(const ChebfunBase_sptr &base); /// Underlying base that does actual job. ChebfunBase_sptr m_base; /// Function values at the chebfun x-points. diff --git a/Framework/CurveFitting/inc/MantidCurveFitting/Functions/ThermalNeutronDtoTOFFunction.h b/Framework/CurveFitting/inc/MantidCurveFitting/Functions/ThermalNeutronDtoTOFFunction.h index 2b92d63f49a64ec1839b47c993603f2f46237bae..f9a3e219759782efce5c8be4a7cdb1bc7d6abd15 100644 --- a/Framework/CurveFitting/inc/MantidCurveFitting/Functions/ThermalNeutronDtoTOFFunction.h +++ b/Framework/CurveFitting/inc/MantidCurveFitting/Functions/ThermalNeutronDtoTOFFunction.h @@ -40,7 +40,7 @@ public: /// Calculate function values void function1D(std::vector<double> &out, - const std::vector<double> xValues) const; + const std::vector<double> &xValues) const; protected: /// overwrite IFunction base class method, which declare function parameters diff --git a/Framework/CurveFitting/inc/MantidCurveFitting/GSLFunctions.h b/Framework/CurveFitting/inc/MantidCurveFitting/GSLFunctions.h index 7729f450edc98bf0b158acce88f47172fab96736..25c64ab84184e7732b532fda0be7505110a59dd3 100644 --- a/Framework/CurveFitting/inc/MantidCurveFitting/GSLFunctions.h +++ b/Framework/CurveFitting/inc/MantidCurveFitting/GSLFunctions.h @@ -27,7 +27,7 @@ Various GSL specific functions used GSL specific minimizers /// Structure to contain least squares data and used by GSL struct GSL_FitData { /// Constructor - GSL_FitData(boost::shared_ptr<CostFunctions::CostFuncLeastSquares> cf); + GSL_FitData(const boost::shared_ptr<CostFunctions::CostFuncLeastSquares> &cf); /// Destructor ~GSL_FitData(); /// number of points to be fitted (size of X, Y and sqrtWeightData arrays) diff --git a/Framework/CurveFitting/inc/MantidCurveFitting/IMWDomainCreator.h b/Framework/CurveFitting/inc/MantidCurveFitting/IMWDomainCreator.h index 52bc6422ba7c0dfd48640896148f76464603ebfa..fb1fca9f1d183e0f57e720a0291601d5dbaa865e 100644 --- a/Framework/CurveFitting/inc/MantidCurveFitting/IMWDomainCreator.h +++ b/Framework/CurveFitting/inc/MantidCurveFitting/IMWDomainCreator.h @@ -15,6 +15,7 @@ #include <boost/weak_ptr.hpp> #include <list> +#include <utility> namespace Mantid { namespace API { @@ -53,7 +54,7 @@ public: /// Set the workspace /// @param ws :: workspace to set. void setWorkspace(boost::shared_ptr<API::MatrixWorkspace> ws) { - m_matrixWorkspace = ws; + m_matrixWorkspace = std::move(ws); } /// Set the workspace index /// @param wi :: workspace index to set. @@ -92,7 +93,7 @@ protected: const API::IFunction_sptr &function, boost::shared_ptr<API::MatrixWorkspace> &ws, const size_t wsIndex, const boost::shared_ptr<API::FunctionDomain> &domain, - boost::shared_ptr<API::FunctionValues> resultValues) const; + const boost::shared_ptr<API::FunctionValues> &resultValues) const; /// Store workspace property name std::string m_workspacePropertyName; diff --git a/Framework/CurveFitting/inc/MantidCurveFitting/SeqDomain.h b/Framework/CurveFitting/inc/MantidCurveFitting/SeqDomain.h index 8fe95df9b20ae34f15f42c4f49f93cdb155b8919..7fcffd154851a3d6e092f584083e744f6a84c5cf 100644 --- a/Framework/CurveFitting/inc/MantidCurveFitting/SeqDomain.h +++ b/Framework/CurveFitting/inc/MantidCurveFitting/SeqDomain.h @@ -38,7 +38,7 @@ public: virtual void getDomainAndValues(size_t i, API::FunctionDomain_sptr &domain, API::FunctionValues_sptr &values) const; /// Add new domain creator - void addCreator(API::IDomainCreator_sptr creator); + void addCreator(const API::IDomainCreator_sptr &creator); /// Calculate the value of an additive cost function virtual void additiveCostFunctionVal(const CostFunctions::CostFuncFitting &costFunction); diff --git a/Framework/CurveFitting/inc/MantidCurveFitting/SeqDomainSpectrumCreator.h b/Framework/CurveFitting/inc/MantidCurveFitting/SeqDomainSpectrumCreator.h index 419c8b1f2d2ec4f4cb70785921aba4b076ab6f1f..4a2d4bcc73c4391f0513474fbeb7388f1990b78b 100644 --- a/Framework/CurveFitting/inc/MantidCurveFitting/SeqDomainSpectrumCreator.h +++ b/Framework/CurveFitting/inc/MantidCurveFitting/SeqDomainSpectrumCreator.h @@ -49,7 +49,7 @@ public: protected: void setParametersFromPropertyManager(); - void setMatrixWorkspace(API::MatrixWorkspace_sptr matrixWorkspace); + void setMatrixWorkspace(const API::MatrixWorkspace_sptr &matrixWorkspace); bool histogramIsUsable(size_t i) const; diff --git a/Framework/CurveFitting/inc/MantidCurveFitting/TableWorkspaceDomainCreator.h b/Framework/CurveFitting/inc/MantidCurveFitting/TableWorkspaceDomainCreator.h index b656b1ece051dcfda721c3be6227bc887a702de4..3cb41d153268d38c2c2ade83187a4a1a2a4081f4 100644 --- a/Framework/CurveFitting/inc/MantidCurveFitting/TableWorkspaceDomainCreator.h +++ b/Framework/CurveFitting/inc/MantidCurveFitting/TableWorkspaceDomainCreator.h @@ -16,6 +16,7 @@ #include <boost/weak_ptr.hpp> #include <list> +#include <utility> namespace Mantid { namespace API { @@ -55,7 +56,9 @@ public: /// Set the workspace /// @param ws :: workspace to set. - void setWorkspace(API::ITableWorkspace_sptr ws) { m_tableWorkspace = ws; } + void setWorkspace(API::ITableWorkspace_sptr ws) { + m_tableWorkspace = std::move(ws); + } /// Set the startX and endX /// @param startX :: Start of the domain /// @param endX :: End of the domain @@ -88,7 +91,7 @@ private: /// Set all parameters void setParameters() const; /// Set the names of the X, Y and Error columns - void setXYEColumnNames(API::ITableWorkspace_sptr ws) const; + void setXYEColumnNames(const API::ITableWorkspace_sptr &ws) const; /// Creates the blank output workspace of the correct size boost::shared_ptr<API::MatrixWorkspace> createEmptyResultWS(const size_t nhistograms, const size_t nyvalues); @@ -109,9 +112,9 @@ private: const API::IFunction_sptr &function, boost::shared_ptr<API::MatrixWorkspace> &ws, const size_t wsIndex, const boost::shared_ptr<API::FunctionDomain> &domain, - boost::shared_ptr<API::FunctionValues> resultValues) const; + const boost::shared_ptr<API::FunctionValues> &resultValues) const; /// Check workspace is in the correct form - void setAndValidateWorkspace(API::Workspace_sptr ws) const; + void setAndValidateWorkspace(const API::Workspace_sptr &ws) const; /// Store workspace property name std::string m_workspacePropertyName; diff --git a/Framework/CurveFitting/src/Algorithms/ConvolutionFit.cpp b/Framework/CurveFitting/src/Algorithms/ConvolutionFit.cpp index 922def0043a672818ed576def4413b12afe5770e..0467eb66c2534f18e08e4f99a6b00cd2efaf9df9 100644 --- a/Framework/CurveFitting/src/Algorithms/ConvolutionFit.cpp +++ b/Framework/CurveFitting/src/Algorithms/ConvolutionFit.cpp @@ -27,16 +27,17 @@ #include <algorithm> #include <cmath> +#include <utility> namespace { using namespace Mantid::API; using namespace Mantid::Kernel; using Mantid::MantidVec; -std::size_t numberOfFunctions(IFunction_sptr function, +std::size_t numberOfFunctions(const IFunction_sptr &function, const std::string &functionName); -std::size_t numberOfFunctions(CompositeFunction_sptr composite, +std::size_t numberOfFunctions(const CompositeFunction_sptr &composite, const std::string &functionName) { std::size_t count = 0; for (auto i = 0u; i < composite->nFunctions(); ++i) @@ -44,7 +45,7 @@ std::size_t numberOfFunctions(CompositeFunction_sptr composite, return count; } -std::size_t numberOfFunctions(IFunction_sptr function, +std::size_t numberOfFunctions(const IFunction_sptr &function, const std::string &functionName) { const auto composite = boost::dynamic_pointer_cast<CompositeFunction>(function); @@ -53,9 +54,10 @@ std::size_t numberOfFunctions(IFunction_sptr function, return function->name() == functionName ? 1 : 0; } -bool containsFunction(IFunction_sptr function, const std::string &functionName); +bool containsFunction(const IFunction_sptr &function, + const std::string &functionName); -bool containsFunction(CompositeFunction_sptr composite, +bool containsFunction(const CompositeFunction_sptr &composite, const std::string &functionName) { for (auto i = 0u; i < composite->nFunctions(); ++i) { if (containsFunction(composite->getFunction(i), functionName)) @@ -64,7 +66,7 @@ bool containsFunction(CompositeFunction_sptr composite, return false; } -bool containsFunction(IFunction_sptr function, +bool containsFunction(const IFunction_sptr &function, const std::string &functionName) { const auto composite = boost::dynamic_pointer_cast<CompositeFunction>(function); @@ -125,7 +127,7 @@ std::vector<T, Ts...> squareRootVector(const std::vector<T, Ts...> &vec) { IFunction_sptr extractFirstBackground(IFunction_sptr function); -IFunction_sptr extractFirstBackground(CompositeFunction_sptr composite) { +IFunction_sptr extractFirstBackground(const CompositeFunction_sptr &composite) { for (auto i = 0u; i < composite->nFunctions(); ++i) { auto background = extractFirstBackground(composite->getFunction(i)); if (background) @@ -145,7 +147,7 @@ IFunction_sptr extractFirstBackground(IFunction_sptr function) { } std::string extractBackgroundType(IFunction_sptr function) { - auto background = extractFirstBackground(function); + auto background = extractFirstBackground(std::move(function)); if (!background) return "None"; @@ -164,7 +166,7 @@ std::string extractBackgroundType(IFunction_sptr function) { std::vector<std::size_t> searchForFitParameters(const std::string &suffix, - ITableWorkspace_sptr tableWorkspace) { + const ITableWorkspace_sptr &tableWorkspace) { auto indices = std::vector<std::size_t>(); for (auto i = 0u; i < tableWorkspace->columnCount(); ++i) { diff --git a/Framework/CurveFitting/src/Algorithms/EstimateFitParameters.cpp b/Framework/CurveFitting/src/Algorithms/EstimateFitParameters.cpp index 00cbc81571d621fe7b1c710ab4c0c6b8f1c6e09c..1c9273de67940701987a74ddcff37af9814db1a5 100644 --- a/Framework/CurveFitting/src/Algorithms/EstimateFitParameters.cpp +++ b/Framework/CurveFitting/src/Algorithms/EstimateFitParameters.cpp @@ -138,9 +138,8 @@ public: std::vector<GSLVector> getParams() const { std::vector<GSLVector> res; res.reserve(m_params.size()); - for (auto &it : m_params) { - res.emplace_back(it.second); - } + std::transform(m_params.begin(), m_params.end(), std::back_inserter(res), + [](const auto &it) { return it.second; }); return res; } }; @@ -383,12 +382,12 @@ void EstimateFitParameters::execConcrete() { continue; } auto constraint = func->getConstraint(i); - if (constraint == nullptr) { + if (!constraint) { func->fix(i); continue; } auto boundary = dynamic_cast<Constraints::BoundaryConstraint *>(constraint); - if (boundary == nullptr) { + if (!boundary) { throw std::runtime_error("Parameter " + func->parameterName(i) + " must have a boundary constraint. "); } diff --git a/Framework/CurveFitting/src/Algorithms/EstimatePeakErrors.cpp b/Framework/CurveFitting/src/Algorithms/EstimatePeakErrors.cpp index bcb3d9f203c734b1080c9c7977a0e3420e5d9742..6a877355610cd870d92d49b448a515f9b6231c15 100644 --- a/Framework/CurveFitting/src/Algorithms/EstimatePeakErrors.cpp +++ b/Framework/CurveFitting/src/Algorithms/EstimatePeakErrors.cpp @@ -91,7 +91,7 @@ GSLMatrix makeJacobian(IPeakFunction &peak, double ¢re, double &height, /// @param covariance :: The covariance matrix for the parameters of the peak. /// @param prefix :: A prefix for the parameter names. void calculatePeakValues(IPeakFunction &peak, ITableWorkspace &results, - const GSLMatrix covariance, + const GSLMatrix &covariance, const std::string &prefix) { double centre, height, fwhm, intensity; GSLMatrix J = makeJacobian(peak, centre, height, fwhm, intensity); diff --git a/Framework/CurveFitting/src/Algorithms/FitPowderDiffPeaks.cpp b/Framework/CurveFitting/src/Algorithms/FitPowderDiffPeaks.cpp index 16f1357a3fe5f7e00504b2b24d6c64f51a092f48..06bd9665443a40cf43cff10463e9ddb680d4d365 100644 --- a/Framework/CurveFitting/src/Algorithms/FitPowderDiffPeaks.cpp +++ b/Framework/CurveFitting/src/Algorithms/FitPowderDiffPeaks.cpp @@ -36,6 +36,8 @@ #include <fstream> #include <cmath> +#include <utility> + #include <gsl/gsl_sf_erf.h> /// Factor on FWHM for fitting a peak @@ -520,11 +522,10 @@ void FitPowderDiffPeaks::fitPeaksRobust() { /** Observe peak range with hint from right peak's properties * Assumption: the background is reasonably flat within peak range */ -void FitPowderDiffPeaks::observePeakRange(BackToBackExponential_sptr thispeak, - BackToBackExponential_sptr rightpeak, - double refpeakshift, - double &peakleftbound, - double &peakrightbound) { +void FitPowderDiffPeaks::observePeakRange( + const BackToBackExponential_sptr &thispeak, + const BackToBackExponential_sptr &rightpeak, double refpeakshift, + double &peakleftbound, double &peakrightbound) { double predictcentre = thispeak->centre(); double rightfwhm = rightpeak->fwhm(); @@ -607,9 +608,10 @@ void FitPowderDiffPeaks::observePeakRange(BackToBackExponential_sptr thispeak, * Return: chi2 ... all the other parameter should be just in peak */ bool FitPowderDiffPeaks::fitSinglePeakRobust( - BackToBackExponential_sptr peak, BackgroundFunction_sptr backgroundfunction, - double peakleftbound, double peakrightbound, - map<string, double> rightpeakparammap, double &finalchi2) { + const BackToBackExponential_sptr &peak, + const BackgroundFunction_sptr &backgroundfunction, double peakleftbound, + double peakrightbound, const map<string, double> &rightpeakparammap, + double &finalchi2) { // 1. Build partial workspace Workspace2D_sptr peakws = buildPartialWorkspace(m_dataWS, m_wsIndex, peakleftbound, peakrightbound); @@ -836,8 +838,9 @@ bool FitPowderDiffPeaks::fitSinglePeakRobust( * Note 1: in a limited range (4*FWHM) */ bool FitPowderDiffPeaks::doFit1PeakBackground( - Workspace2D_sptr dataws, size_t wsindex, BackToBackExponential_sptr peak, - BackgroundFunction_sptr backgroundfunction, double &chi2) { + const Workspace2D_sptr &dataws, size_t wsindex, + const BackToBackExponential_sptr &peak, + const BackgroundFunction_sptr &backgroundfunction, double &chi2) { // 0. Set fit parameters string minimzername("Levenberg-MarquardtMD"); double startx = peak->centre() - 3.0 * peak->fwhm(); @@ -904,7 +907,7 @@ bool FitPowderDiffPeaks::doFit1PeakBackground( /** Fit signle peak by Monte Carlo/simulated annealing */ bool FitPowderDiffPeaks::fitSinglePeakSimulatedAnnealing( - BackToBackExponential_sptr peak, vector<string> paramtodomc) { + const BackToBackExponential_sptr &peak, const vector<string> ¶mtodomc) { UNUSED_ARG(peak); UNUSED_ARG(paramtodomc); throw runtime_error("To Be Implemented Soon!"); @@ -1218,8 +1221,9 @@ void FitPowderDiffPeaks::fitPeaksWithGoodStartingValues() { * @param annhilatedpeak :: (output) annhilatedpeak */ bool FitPowderDiffPeaks::fitSinglePeakConfident( - BackToBackExponential_sptr peak, BackgroundFunction_sptr backgroundfunction, - double leftbound, double rightbound, double &chi2, bool &annhilatedpeak) { + const BackToBackExponential_sptr &peak, + const BackgroundFunction_sptr &backgroundfunction, double leftbound, + double rightbound, double &chi2, bool &annhilatedpeak) { // 1. Build the partial workspace // a) Determine boundary if necessary if (leftbound < 0 || leftbound >= peak->centre()) @@ -1518,8 +1522,8 @@ void FitPowderDiffPeaks::calculatePeakFitBoundary(size_t ileftpeak, *negative, then no constraint */ std::pair<bool, double> -FitPowderDiffPeaks::doFitPeak(Workspace2D_sptr dataws, - BackToBackExponential_sptr peakfunction, +FitPowderDiffPeaks::doFitPeak(const Workspace2D_sptr &dataws, + const BackToBackExponential_sptr &peakfunction, double guessedfwhm) { // 1. Set up boundary if (guessedfwhm > 0) { @@ -1624,7 +1628,7 @@ FitPowderDiffPeaks::doFitPeak(Workspace2D_sptr dataws, /** Store the function's parameter values to a map */ void FitPowderDiffPeaks::storeFunctionParameters( - IFunction_sptr function, std::map<string, double> ¶mmaps) { + const IFunction_sptr &function, std::map<string, double> ¶mmaps) { vector<string> paramnames = function->getParameterNames(); parammaps.clear(); for (auto ¶mname : paramnames) @@ -1635,7 +1639,7 @@ void FitPowderDiffPeaks::storeFunctionParameters( /** Restore the function's parameter values from a map */ void FitPowderDiffPeaks::restoreFunctionParameters( - IFunction_sptr function, map<string, double> parammap) { + const IFunction_sptr &function, map<string, double> parammap) { vector<string> paramnames = function->getParameterNames(); for (auto &parname : paramnames) { auto miter = parammap.find(parname); @@ -1658,8 +1662,8 @@ void FitPowderDiffPeaks::restoreFunctionParameters( * 2. chi2 */ bool FitPowderDiffPeaks::doFit1PeakSimple( - Workspace2D_sptr dataws, size_t workspaceindex, - BackToBackExponential_sptr peakfunction, string minimzername, + const Workspace2D_sptr &dataws, size_t workspaceindex, + const BackToBackExponential_sptr &peakfunction, const string &minimzername, size_t maxiteration, double &chi2) { stringstream dbss; dbss << peakfunction->asString() << '\n'; @@ -1728,9 +1732,10 @@ bool FitPowderDiffPeaks::doFit1PeakSimple( * @param chi2 :: The chi squared value (output) */ bool FitPowderDiffPeaks::doFit1PeakSequential( - Workspace2D_sptr dataws, size_t workspaceindex, - BackToBackExponential_sptr peakfunction, vector<string> minimzernames, - vector<size_t> maxiterations, vector<double> dampfactors, double &chi2) { + const Workspace2D_sptr &dataws, size_t workspaceindex, + const BackToBackExponential_sptr &peakfunction, + vector<string> minimzernames, vector<size_t> maxiterations, + const vector<double> &dampfactors, double &chi2) { // 1. Check if (minimzernames.size() != maxiterations.size() && minimzernames.size() != dampfactors.size()) { @@ -1789,11 +1794,10 @@ bool FitPowderDiffPeaks::doFit1PeakSequential( //---------------------------------------------------------------------------- /** Fit background-removed peak by Gaussian */ -bool FitPowderDiffPeaks::doFitGaussianPeak(DataObjects::Workspace2D_sptr dataws, - size_t workspaceindex, - double in_center, double leftfwhm, - double rightfwhm, double ¢er, - double &sigma, double &height) { +bool FitPowderDiffPeaks::doFitGaussianPeak( + const DataObjects::Workspace2D_sptr &dataws, size_t workspaceindex, + double in_center, double leftfwhm, double rightfwhm, double ¢er, + double &sigma, double &height) { // 1. Estimate const auto &X = dataws->x(workspaceindex); const auto &Y = dataws->y(workspaceindex); @@ -1873,7 +1877,7 @@ bool FitPowderDiffPeaks::doFitGaussianPeak(DataObjects::Workspace2D_sptr dataws, */ bool FitPowderDiffPeaks::fitOverlappedPeaks( vector<BackToBackExponential_sptr> peaks, - BackgroundFunction_sptr backgroundfunction, double gfwhm) { + const BackgroundFunction_sptr &backgroundfunction, double gfwhm) { // 1. Sort peak if necessary vector<pair<double, BackToBackExponential_sptr>> tofpeakpairs(peaks.size()); for (size_t i = 0; i < peaks.size(); ++i) @@ -1951,7 +1955,8 @@ bool FitPowderDiffPeaks::fitOverlappedPeaks( /** Fit multiple (overlapped) peaks */ bool FitPowderDiffPeaks::doFitMultiplePeaks( - Workspace2D_sptr dataws, size_t wsindex, CompositeFunction_sptr peaksfunc, + const Workspace2D_sptr &dataws, size_t wsindex, + const CompositeFunction_sptr &peaksfunc, vector<BackToBackExponential_sptr> peakfuncs, vector<bool> &vecfitgood, vector<double> &vecchi2s) { // 0. Pre-debug output @@ -2062,7 +2067,7 @@ bool FitPowderDiffPeaks::doFitMultiplePeaks( * @param peaks :: A vector of instances of BackToBackExponential function */ void FitPowderDiffPeaks::estimatePeakHeightsLeBail( - Workspace2D_sptr dataws, size_t wsindex, + const Workspace2D_sptr &dataws, size_t wsindex, vector<BackToBackExponential_sptr> peaks) { // 1. Build data structures FunctionDomain1DVector domain(dataws->x(wsindex).rawData()); @@ -2110,7 +2115,7 @@ void FitPowderDiffPeaks::estimatePeakHeightsLeBail( /** Set constraints on a group of overlapped peaks for fitting */ void FitPowderDiffPeaks::setOverlappedPeaksConstraints( - vector<BackToBackExponential_sptr> peaks) { + const vector<BackToBackExponential_sptr> &peaks) { for (const auto &thispeak : peaks) { // 1. Set constraint on X. double fwhm = thispeak->fwhm(); @@ -2128,9 +2133,10 @@ void FitPowderDiffPeaks::setOverlappedPeaksConstraints( /** Fit N overlapped peaks in a simple manner */ bool FitPowderDiffPeaks::doFitNPeaksSimple( - Workspace2D_sptr dataws, size_t wsindex, CompositeFunction_sptr peaksfunc, - vector<BackToBackExponential_sptr> peakfuncs, string minimizername, - size_t maxiteration, double &chi2) { + const Workspace2D_sptr &dataws, size_t wsindex, + const CompositeFunction_sptr &peaksfunc, + const vector<BackToBackExponential_sptr> &peakfuncs, + const string &minimizername, size_t maxiteration, double &chi2) { // 1. Debug output stringstream dbss0; dbss0 << "Starting Value: "; @@ -2190,8 +2196,9 @@ bool FitPowderDiffPeaks::doFitNPeaksSimple( //---------------------------------------------------------------------------------------------- /** Parse fit result */ -std::string FitPowderDiffPeaks::parseFitResult(API::IAlgorithm_sptr fitalg, - double &chi2, bool &fitsuccess) { +std::string +FitPowderDiffPeaks::parseFitResult(const API::IAlgorithm_sptr &fitalg, + double &chi2, bool &fitsuccess) { stringstream rss; chi2 = fitalg->getProperty("OutputChi2overDoF"); @@ -2209,7 +2216,7 @@ std::string FitPowderDiffPeaks::parseFitResult(API::IAlgorithm_sptr fitalg, /** Parse parameter workspace returned from Fit() */ std::string FitPowderDiffPeaks::parseFitParameterWorkspace( - API::ITableWorkspace_sptr paramws) { + const API::ITableWorkspace_sptr ¶mws) { // 1. Check if (!paramws) { g_log.warning() << "Input table workspace is NULL. \n"; @@ -2239,7 +2246,7 @@ std::string FitPowderDiffPeaks::parseFitParameterWorkspace( * the diffrotometer geometry parameters */ void FitPowderDiffPeaks::importInstrumentParameterFromTable( - DataObjects::TableWorkspace_sptr parameterWS) { + const DataObjects::TableWorkspace_sptr ¶meterWS) { // 1. Check column orders std::vector<std::string> colnames = parameterWS->getColumnNames(); if (colnames.size() < 2) { @@ -2284,7 +2291,7 @@ void FitPowderDiffPeaks::importInstrumentParameterFromTable( /** Import Bragg peak table workspace */ void FitPowderDiffPeaks::parseBraggPeakTable( - TableWorkspace_sptr peakws, vector<map<string, double>> ¶mmaps, + const TableWorkspace_sptr &peakws, vector<map<string, double>> ¶mmaps, vector<map<string, int>> &hklmaps) { // 1. Get columns' types and names vector<string> paramnames = peakws->getColumnNames(); @@ -2584,7 +2591,8 @@ FitPowderDiffPeaks::genPeakParametersWorkspace() { * Each peak within requirement will put into both (1) m_peaks and (2) * m_peaksmap */ -void FitPowderDiffPeaks::genPeaksFromTable(TableWorkspace_sptr peakparamws) { +void FitPowderDiffPeaks::genPeaksFromTable( + const TableWorkspace_sptr &peakparamws) { // Check and clear input and output if (!peakparamws) { stringstream errss; @@ -2729,7 +2737,7 @@ FitPowderDiffPeaks::genPeak(map<string, int> hklmap, newpeakptr->initialize(); // Check miller index (HKL) is a valid value in a miller indexes pool (hklmap) - good = getHKLFromMap(hklmap, hkl); + good = getHKLFromMap(std::move(hklmap), hkl); if (!good) { // Ignore and return return newpeakptr; @@ -2909,9 +2917,9 @@ FitPowderDiffPeaks::genPeak(map<string, int> hklmap, * @param peakfunction: function to plot * @param background: background of the peak */ -void FitPowderDiffPeaks::plotFunction(IFunction_sptr peakfunction, - BackgroundFunction_sptr background, - FunctionDomain1DVector domain) { +void FitPowderDiffPeaks::plotFunction(const IFunction_sptr &peakfunction, + const BackgroundFunction_sptr &background, + const FunctionDomain1DVector &domain) { // 1. Determine range const auto &vecX = m_dataWS->x(m_wsIndex); double x0 = domain[0]; @@ -3010,7 +3018,7 @@ void FitPowderDiffPeaks::cropWorkspace(double tofmin, double tofmax) { * Exception: throw runtime error if there is no such parameter * @param parname: parameter name to get from m_instrumentParameters */ -double FitPowderDiffPeaks::getParameter(string parname) { +double FitPowderDiffPeaks::getParameter(const string &parname) { map<string, double>::iterator mapiter; mapiter = m_instrumentParmaeters.find(parname); @@ -3033,10 +3041,9 @@ double FitPowderDiffPeaks::getParameter(string parname) { * @param leftbound: lower boundary of the source data * @param rightbound: upper boundary of the source data */ -Workspace2D_sptr -FitPowderDiffPeaks::buildPartialWorkspace(API::MatrixWorkspace_sptr sourcews, - size_t workspaceindex, - double leftbound, double rightbound) { +Workspace2D_sptr FitPowderDiffPeaks::buildPartialWorkspace( + const API::MatrixWorkspace_sptr &sourcews, size_t workspaceindex, + double leftbound, double rightbound) { // 1. Check const auto &X = sourcews->x(workspaceindex); const auto &Y = sourcews->y(workspaceindex); @@ -3093,7 +3100,7 @@ FitPowderDiffPeaks::buildPartialWorkspace(API::MatrixWorkspace_sptr sourcews, /** Get function parameter values information and returned as a string * @param function: function to have information written out */ -string getFunctionInfo(IFunction_sptr function) { +string getFunctionInfo(const IFunction_sptr &function) { stringstream outss; vector<string> parnames = function->getParameterNames(); size_t numpars = parnames.size(); @@ -3117,8 +3124,8 @@ string getFunctionInfo(IFunction_sptr function) { * @param wsindexpeak: workspace index of spectrum holding pure peak data (with * background removed) */ -void estimateBackgroundCoarse(DataObjects::Workspace2D_sptr dataws, - BackgroundFunction_sptr background, +void estimateBackgroundCoarse(const DataObjects::Workspace2D_sptr &dataws, + const BackgroundFunction_sptr &background, size_t wsindexraw, size_t wsindexbkgd, size_t wsindexpeak) { // 1. Get prepared @@ -3192,7 +3199,7 @@ void estimateBackgroundCoarse(DataObjects::Workspace2D_sptr dataws, * @param fwhm :: (output) peak FWHM * @param errmsg :: (output) error message */ -bool observePeakParameters(Workspace2D_sptr dataws, size_t wsindex, +bool observePeakParameters(const Workspace2D_sptr &dataws, size_t wsindex, double ¢re, double &height, double &fwhm, string &errmsg) { // 1. Get the value of the Max Height @@ -3306,7 +3313,7 @@ size_t findMaxValue(const std::vector<double> &Y) { * @param rightbound :: upper constraint for check * @return the index of the maximum value */ -size_t findMaxValue(MatrixWorkspace_sptr dataws, size_t wsindex, +size_t findMaxValue(const MatrixWorkspace_sptr &dataws, size_t wsindex, double leftbound, double rightbound) { const auto &X = dataws->x(wsindex); const auto &Y = dataws->y(wsindex); diff --git a/Framework/CurveFitting/src/Algorithms/IqtFit.cpp b/Framework/CurveFitting/src/Algorithms/IqtFit.cpp index a07141bd11e6ba5f4e999c81e6ab736c77ccb731..698f4868b3f1f330b45f6a417e6cf8bba1fff3d3 100644 --- a/Framework/CurveFitting/src/Algorithms/IqtFit.cpp +++ b/Framework/CurveFitting/src/Algorithms/IqtFit.cpp @@ -17,7 +17,7 @@ using namespace Mantid::API; namespace { Mantid::Kernel::Logger g_log("IqtFit"); -MatrixWorkspace_sptr cropWorkspace(MatrixWorkspace_sptr workspace, +MatrixWorkspace_sptr cropWorkspace(const MatrixWorkspace_sptr &workspace, double startX, double endX) { auto cropper = AlgorithmManager::Instance().create("CropWorkspace"); cropper->setLogging(false); @@ -30,7 +30,7 @@ MatrixWorkspace_sptr cropWorkspace(MatrixWorkspace_sptr workspace, return cropper->getProperty("OutputWorkspace"); } -MatrixWorkspace_sptr convertToHistogram(MatrixWorkspace_sptr workspace) { +MatrixWorkspace_sptr convertToHistogram(const MatrixWorkspace_sptr &workspace) { auto converter = AlgorithmManager::Instance().create("ConvertToHistogram"); converter->setLogging(false); converter->setAlwaysStoreInADS(false); @@ -43,8 +43,8 @@ MatrixWorkspace_sptr convertToHistogram(MatrixWorkspace_sptr workspace) { struct HistogramConverter { explicit HistogramConverter() : m_converted() {} - MatrixWorkspace_sptr operator()(MatrixWorkspace_sptr workspace, double startX, - double endX) const { + MatrixWorkspace_sptr operator()(const MatrixWorkspace_sptr &workspace, + double startX, double endX) const { auto it = m_converted.find(workspace.get()); if (it != m_converted.end()) return it->second; diff --git a/Framework/CurveFitting/src/Algorithms/LeBailFit.cpp b/Framework/CurveFitting/src/Algorithms/LeBailFit.cpp index e793fecd3a4f41d158b1d6c408c6ea8904ebfa07..38b2f5b3f91c4788d2956868534211255cff763c 100644 --- a/Framework/CurveFitting/src/Algorithms/LeBailFit.cpp +++ b/Framework/CurveFitting/src/Algorithms/LeBailFit.cpp @@ -763,7 +763,8 @@ void LeBailFit::createLeBailFunction() { * @param wsindex: workspace index of the data to fit against */ API::MatrixWorkspace_sptr -LeBailFit::cropWorkspace(API::MatrixWorkspace_sptr inpws, size_t wsindex) { +LeBailFit::cropWorkspace(const API::MatrixWorkspace_sptr &inpws, + size_t wsindex) { // Process input property 'FitRegion' for range of data to fit/calculate std::vector<double> fitrange = this->getProperty("FitRegion"); @@ -1143,9 +1144,9 @@ void LeBailFit::parseBraggPeaksParametersTable() { /** Parse table workspace (from Fit()) containing background parameters to a * vector */ -void LeBailFit::parseBackgroundTableWorkspace(TableWorkspace_sptr bkgdparamws, - vector<string> &bkgdparnames, - vector<double> &bkgdorderparams) { +void LeBailFit::parseBackgroundTableWorkspace( + const TableWorkspace_sptr &bkgdparamws, vector<string> &bkgdparnames, + vector<double> &bkgdorderparams) { g_log.debug() << "DB1105A Parsing background TableWorkspace.\n"; // Clear (output) map @@ -1746,7 +1747,7 @@ void LeBailFit::doMarkovChain( * @param tablews :: TableWorkspace containing the Monte Carlo setup */ void LeBailFit::setupRandomWalkStrategyFromTable( - DataObjects::TableWorkspace_sptr tablews) { + const DataObjects::TableWorkspace_sptr &tablews) { g_log.information("Set up random walk strategy from table."); // Scan the table @@ -1941,7 +1942,7 @@ void LeBailFit::setupBuiltInRandomWalkStrategy() { *list */ void LeBailFit::addParameterToMCMinimize(vector<string> &parnamesforMC, - string parname) { + const string &parname) { map<string, Parameter>::iterator pariter; pariter = m_funcParameters.find(parname); if (pariter == m_funcParameters.end()) { @@ -2094,7 +2095,7 @@ bool LeBailFit::calculateDiffractionPattern(const HistogramX &vecX, *proposed new values in * this group */ -bool LeBailFit::proposeNewValues(vector<string> mcgroup, Rfactor r, +bool LeBailFit::proposeNewValues(const vector<string> &mcgroup, Rfactor r, map<string, Parameter> &curparammap, map<string, Parameter> &newparammap, bool prevBetterRwp) { @@ -2414,7 +2415,7 @@ LeBailFit::convertToDoubleMap(std::map<std::string, Parameter> &inmap) { /** Write a set of (XY) data to a column file */ void writeRfactorsToFile(vector<double> vecX, vector<Rfactor> vecR, - string filename) { + const string &filename) { ofstream ofile; ofile.open(filename.c_str()); diff --git a/Framework/CurveFitting/src/Algorithms/LeBailFunction.cpp b/Framework/CurveFitting/src/Algorithms/LeBailFunction.cpp index 8f87924d8e51706ff5ac83a85024b8d4331fa7ff..8488fa549072ed1db630d781f2cc06a21f717be7 100644 --- a/Framework/CurveFitting/src/Algorithms/LeBailFunction.cpp +++ b/Framework/CurveFitting/src/Algorithms/LeBailFunction.cpp @@ -14,6 +14,7 @@ #include "MantidKernel/System.h" #include <sstream> +#include <utility> #include <gsl/gsl_sf_erf.h> @@ -42,7 +43,7 @@ Kernel::Logger g_log("LeBailFunction"); //---------------------------------------------------------------------------------------------- /** Constructor */ -LeBailFunction::LeBailFunction(std::string peaktype) { +LeBailFunction::LeBailFunction(const std::string &peaktype) { // Set initial values to some class variables CompositeFunction_sptr m_function(new CompositeFunction()); m_compsiteFunction = m_function; @@ -169,7 +170,7 @@ HistogramY LeBailFunction::calPeak(size_t ipk, /** Check whether a parameter is a profile parameter * @param paramname :: parameter name to check with */ -bool LeBailFunction::hasProfileParameter(std::string paramname) { +bool LeBailFunction::hasProfileParameter(const std::string ¶mname) { auto fiter = lower_bound(m_orderedProfileParameterNames.cbegin(), m_orderedProfileParameterNames.cend(), paramname); @@ -619,8 +620,8 @@ bool LeBailFunction::calculateGroupPeakIntensities( * @param peakheight: height of the peak * @param setpeakheight: boolean as the option to set peak height or not. */ -void LeBailFunction::setPeakParameters(IPowderDiffPeakFunction_sptr peak, - map<string, double> parammap, +void LeBailFunction::setPeakParameters(const IPowderDiffPeakFunction_sptr &peak, + const map<string, double> ¶mmap, double peakheight, bool setpeakheight) { UNUSED_ARG(peak); UNUSED_ARG(parammap); @@ -855,7 +856,7 @@ void LeBailFunction::groupPeaks( * @param endx :: background's EndX. Used by Chebyshev */ void LeBailFunction::addBackgroundFunction( - string backgroundtype, const unsigned int &order, + const string &backgroundtype, const unsigned int &order, const std::vector<std::string> &vecparnames, const std::vector<double> &vecparvalues, double startx, double endx) { // Check @@ -911,8 +912,8 @@ void LeBailFunction::addBackgroundFunction( * @param minvalue :: lower boundary * @param maxvalue :: upper boundary */ -void LeBailFunction::setFitProfileParameter(string paramname, double minvalue, - double maxvalue) { +void LeBailFunction::setFitProfileParameter(const string ¶mname, + double minvalue, double maxvalue) { // Make ties in composition function for (size_t ipk = 1; ipk < m_numPeaks; ++ipk) { stringstream ss1, ss2; @@ -939,7 +940,8 @@ void LeBailFunction::setFitProfileParameter(string paramname, double minvalue, * @param paramname :: name of parameter * @param paramvalue :: value of parameter to be fixed to */ -void LeBailFunction::fixPeakParameter(string paramname, double paramvalue) { +void LeBailFunction::fixPeakParameter(const string ¶mname, + double paramvalue) { for (size_t ipk = 0; ipk < m_numPeaks; ++ipk) { stringstream ss1, ss2; ss1 << "f" << ipk << "." << paramname; @@ -987,7 +989,7 @@ void LeBailFunction::setFixPeakHeights() { /** Reset all peaks' height * @param inheights :: list of peak heights corresponding to each peak */ -void LeBailFunction::setPeakHeights(std::vector<double> inheights) { +void LeBailFunction::setPeakHeights(const std::vector<double> &inheights) { UNUSED_ARG(inheights); throw runtime_error("It is not implemented properly."); /* @@ -1026,7 +1028,7 @@ IPowderDiffPeakFunction_sptr LeBailFunction::getPeak(size_t peakindex) { /** Get value of one specific peak's parameter */ double LeBailFunction::getPeakParameter(std::vector<int> hkl, - std::string parname) const { + const std::string &parname) const { // Search peak in map map<vector<int>, IPowderDiffPeakFunction_sptr>::const_iterator fiter; fiter = m_mapHKLPeak.find(hkl); @@ -1040,7 +1042,7 @@ double LeBailFunction::getPeakParameter(std::vector<int> hkl, IPowderDiffPeakFunction_sptr peak = fiter->second; - double parvalue = getPeakParameterValue(peak, parname); + double parvalue = getPeakParameterValue(peak, std::move(parname)); return parvalue; } @@ -1049,7 +1051,7 @@ double LeBailFunction::getPeakParameter(std::vector<int> hkl, /** Get value of one specific peak's parameter */ double LeBailFunction::getPeakParameter(size_t index, - std::string parname) const { + const std::string &parname) const { if (index >= m_numPeaks) { stringstream errss; errss << "getPeakParameter() tries to reach a peak with index " << index @@ -1060,7 +1062,7 @@ double LeBailFunction::getPeakParameter(size_t index, } IPowderDiffPeakFunction_sptr peak = m_vecPeaks[index]; - double value = getPeakParameterValue(peak, parname); + double value = getPeakParameterValue(peak, std::move(parname)); return value; } @@ -1070,9 +1072,9 @@ double LeBailFunction::getPeakParameter(size_t index, * @param peak :: shared pointer to peak function * @param parname :: name of the peak parameter */ -double -LeBailFunction::getPeakParameterValue(API::IPowderDiffPeakFunction_sptr peak, - std::string parname) const { +double LeBailFunction::getPeakParameterValue( + const API::IPowderDiffPeakFunction_sptr &peak, + const std::string &parname) const { // Locate the category of the parameter name auto vsiter = lower_bound(m_orderedProfileParameterNames.cbegin(), m_orderedProfileParameterNames.cend(), parname); diff --git a/Framework/CurveFitting/src/Algorithms/PlotPeakByLogValue.cpp b/Framework/CurveFitting/src/Algorithms/PlotPeakByLogValue.cpp index 844d1b3418a1b824134a251b91f5c724b4f55762..d051738dae1ea455805dea2a0b51e4fddb5c937e 100644 --- a/Framework/CurveFitting/src/Algorithms/PlotPeakByLogValue.cpp +++ b/Framework/CurveFitting/src/Algorithms/PlotPeakByLogValue.cpp @@ -431,7 +431,7 @@ boost::shared_ptr<Algorithm> PlotPeakByLogValue::runSingleFit( return fit; } -double PlotPeakByLogValue::calculateLogValue(std::string logName, +double PlotPeakByLogValue::calculateLogValue(const std::string &logName, const InputSpectraToFit &data) { double logValue = 0; if (logName.empty() || logName == "axis-1") { @@ -457,7 +457,7 @@ double PlotPeakByLogValue::calculateLogValue(std::string logName, return logValue; } -void PlotPeakByLogValue::setWorkspaceIndexAttribute(IFunction_sptr fun, +void PlotPeakByLogValue::setWorkspaceIndexAttribute(const IFunction_sptr &fun, int wsIndex) const { const std::string attName = "WorkspaceIndex"; if (fun->hasAttribute(attName)) { diff --git a/Framework/CurveFitting/src/Algorithms/PlotPeakByLogValueHelper.cpp b/Framework/CurveFitting/src/Algorithms/PlotPeakByLogValueHelper.cpp index 3382a04eaa3d10649e82e51198b365fd20d31ed2..3e92ea95565d37ae9b5bbf56f36b51fda612e20e 100644 --- a/Framework/CurveFitting/src/Algorithms/PlotPeakByLogValueHelper.cpp +++ b/Framework/CurveFitting/src/Algorithms/PlotPeakByLogValueHelper.cpp @@ -85,8 +85,8 @@ void addMatrixworkspace( const boost::optional<API::Workspace_sptr> &workspaceOptional, const boost::shared_ptr<API::MatrixWorkspace> &wsMatrix); /// Create a list of input workspace names -std::vector<InputSpectraToFit> makeNames(std::string inputList, int default_wi, - int default_spec) { +std::vector<InputSpectraToFit> makeNames(const std::string &inputList, + int default_wi, int default_spec) { std::vector<InputSpectraToFit> nameList; double start = 0; @@ -212,7 +212,6 @@ std::vector<int> getWorkspaceIndicesFromAxes(API::MatrixWorkspace &ws, } } } else { // numeric axis - spectrumNumber = SpecialIndex::NOT_SET; if (workspaceIndex >= 0) { out.clear(); } else { diff --git a/Framework/CurveFitting/src/Algorithms/QENSFitSequential.cpp b/Framework/CurveFitting/src/Algorithms/QENSFitSequential.cpp index 2af32db01fe357eaed5c235e51b8175419dec99e..2e901f05f84296d1921ab532c09759670abc5759 100644 --- a/Framework/CurveFitting/src/Algorithms/QENSFitSequential.cpp +++ b/Framework/CurveFitting/src/Algorithms/QENSFitSequential.cpp @@ -24,6 +24,7 @@ #include <sstream> #include <stdexcept> #include <unordered_map> +#include <utility> namespace { using namespace Mantid::API; @@ -39,8 +40,9 @@ MatrixWorkspace_sptr getADSMatrixWorkspace(const std::string &workspaceName) { workspaceName); } -MatrixWorkspace_sptr convertSpectrumAxis(MatrixWorkspace_sptr inputWorkspace, - const std::string &outputName) { +MatrixWorkspace_sptr +convertSpectrumAxis(const MatrixWorkspace_sptr &inputWorkspace, + const std::string &outputName) { auto convSpec = AlgorithmManager::Instance().create("ConvertSpectrumAxis"); convSpec->setLogging(false); convSpec->setProperty("InputWorkspace", inputWorkspace); @@ -53,16 +55,16 @@ MatrixWorkspace_sptr convertSpectrumAxis(MatrixWorkspace_sptr inputWorkspace, return getADSMatrixWorkspace(outputName); } -MatrixWorkspace_sptr cloneWorkspace(MatrixWorkspace_sptr inputWorkspace, +MatrixWorkspace_sptr cloneWorkspace(const MatrixWorkspace_sptr &inputWorkspace, const std::string &outputName) { Workspace_sptr workspace = inputWorkspace->clone(); AnalysisDataService::Instance().addOrReplace(outputName, workspace); return boost::dynamic_pointer_cast<MatrixWorkspace>(workspace); } -MatrixWorkspace_sptr convertToElasticQ(MatrixWorkspace_sptr inputWorkspace, - const std::string &outputName, - bool doThrow) { +MatrixWorkspace_sptr +convertToElasticQ(const MatrixWorkspace_sptr &inputWorkspace, + const std::string &outputName, bool doThrow) { auto axis = inputWorkspace->getAxis(1); if (axis->isSpectra()) return convertSpectrumAxis(inputWorkspace, outputName); @@ -80,8 +82,8 @@ struct ElasticQAppender { explicit ElasticQAppender(std::vector<MatrixWorkspace_sptr> &elasticInput) : m_elasticInput(elasticInput), m_converted() {} - void operator()(MatrixWorkspace_sptr workspace, const std::string &outputBase, - bool doThrow) { + void operator()(const MatrixWorkspace_sptr &workspace, + const std::string &outputBase, bool doThrow) { auto it = m_converted.find(workspace.get()); if (it != m_converted.end()) m_elasticInput.emplace_back(it->second); @@ -111,13 +113,13 @@ convertToElasticQ(const std::vector<MatrixWorkspace_sptr> &workspaces, return elasticInput; } -void extractFunctionNames(CompositeFunction_sptr composite, +void extractFunctionNames(const CompositeFunction_sptr &composite, std::vector<std::string> &names) { for (auto i = 0u; i < composite->nFunctions(); ++i) names.emplace_back(composite->getFunction(i)->name()); } -void extractFunctionNames(IFunction_sptr function, +void extractFunctionNames(const IFunction_sptr &function, std::vector<std::string> &names) { auto composite = boost::dynamic_pointer_cast<CompositeFunction>(function); if (composite) @@ -126,16 +128,16 @@ void extractFunctionNames(IFunction_sptr function, names.emplace_back(function->name()); } -void extractConvolvedNames(IFunction_sptr function, +void extractConvolvedNames(const IFunction_sptr &function, std::vector<std::string> &names); -void extractConvolvedNames(CompositeFunction_sptr composite, +void extractConvolvedNames(const CompositeFunction_sptr &composite, std::vector<std::string> &names) { for (auto i = 0u; i < composite->nFunctions(); ++i) extractConvolvedNames(composite->getFunction(i), names); } -void extractConvolvedNames(IFunction_sptr function, +void extractConvolvedNames(const IFunction_sptr &function, std::vector<std::string> &names) { auto composite = boost::dynamic_pointer_cast<CompositeFunction>(function); if (composite) { @@ -147,8 +149,8 @@ void extractConvolvedNames(IFunction_sptr function, } } -std::string constructInputString(MatrixWorkspace_sptr workspace, int specMin, - int specMax) { +std::string constructInputString(const MatrixWorkspace_sptr &workspace, + int specMin, int specMax) { std::ostringstream input; for (auto i = specMin; i < specMax + 1; ++i) input << workspace->getName() << ",i" << std::to_string(i) << ";"; @@ -170,9 +172,10 @@ std::vector<MatrixWorkspace_sptr> extractWorkspaces(const std::string &input) { std::vector<MatrixWorkspace_sptr> workspaces; - for (const auto &wsName : workspaceNames) { - workspaces.emplace_back(getADSMatrixWorkspace(wsName)); - } + std::transform(workspaceNames.begin(), workspaceNames.end(), + std::back_inserter(workspaces), [](const auto &wsName) { + return getADSMatrixWorkspace(wsName); + }); return workspaces; } @@ -203,14 +206,16 @@ replaceWorkspaces(const std::string &input, return newInput.str(); } -void renameWorkspace(IAlgorithm_sptr renamer, Workspace_sptr workspace, +void renameWorkspace(const IAlgorithm_sptr &renamer, + const Workspace_sptr &workspace, const std::string &newName) { renamer->setProperty("InputWorkspace", workspace); renamer->setProperty("OutputWorkspace", newName); renamer->executeAsChildAlg(); } -void deleteTemporaries(IAlgorithm_sptr deleter, const std::string &base) { +void deleteTemporaries(const IAlgorithm_sptr &deleter, + const std::string &base) { auto name = base + std::to_string(1); std::size_t i = 2; @@ -233,8 +238,8 @@ bool containsMultipleData(const std::vector<MatrixWorkspace_sptr> &workspaces) { } template <typename F, typename Renamer> -void renameWorkspacesWith(WorkspaceGroup_sptr groupWorkspace, F const &getName, - Renamer const &renamer) { +void renameWorkspacesWith(const WorkspaceGroup_sptr &groupWorkspace, + F const &getName, Renamer const &renamer) { std::unordered_map<std::string, std::size_t> nameCount; for (auto i = 0u; i < groupWorkspace->size(); ++i) { const auto name = getName(i); @@ -251,7 +256,7 @@ void renameWorkspacesWith(WorkspaceGroup_sptr groupWorkspace, F const &getName, template <typename F> void renameWorkspacesInQENSFit(Algorithm *qensFit, - IAlgorithm_sptr renameAlgorithm, + const IAlgorithm_sptr &renameAlgorithm, WorkspaceGroup_sptr outputGroup, std::string const &outputBaseName, std::string const &groupSuffix, @@ -263,8 +268,8 @@ void renameWorkspacesInQENSFit(Algorithm *qensFit, return outputBaseName + "_" + getNameSuffix(i); }; - auto renamer = [&](Workspace_sptr workspace, const std::string &name) { - renameWorkspace(renameAlgorithm, workspace, name); + auto renamer = [&](const Workspace_sptr &workspace, const std::string &name) { + renameWorkspace(renameAlgorithm, std::move(workspace), name); renamerProg.report("Renamed workspace in group."); }; renameWorkspacesWith(outputGroup, getName, renamer); @@ -541,9 +546,9 @@ void QENSFitSequential::exec() { getPropertyValue("OutputWorkspace"), resultWs); if (containsMultipleData(workspaces)) { - const auto inputString = getPropertyValue("Input"); + const auto inputStringProp = getPropertyValue("Input"); renameWorkspaces(groupWs, spectra, outputBaseName, "_Workspace", - extractWorkspaceNames(inputString)); + extractWorkspaceNames(inputStringProp)); } else { renameWorkspaces(groupWs, spectra, outputBaseName, "_Workspace"); } @@ -594,12 +599,14 @@ QENSFitSequential::getAdditionalLogNumbers() const { return logs; } -void QENSFitSequential::addAdditionalLogs(WorkspaceGroup_sptr resultWorkspace) { +void QENSFitSequential::addAdditionalLogs( + const WorkspaceGroup_sptr &resultWorkspace) { for (const auto &workspace : *resultWorkspace) addAdditionalLogs(workspace); } -void QENSFitSequential::addAdditionalLogs(Workspace_sptr resultWorkspace) { +void QENSFitSequential::addAdditionalLogs( + const Workspace_sptr &resultWorkspace) { auto logAdder = createChildAlgorithm("AddSampleLog", -1.0, -1.0, false); logAdder->setProperty("Workspace", resultWorkspace); @@ -678,7 +685,7 @@ std::vector<std::size_t> QENSFitSequential::getDatasetGrouping( } WorkspaceGroup_sptr QENSFitSequential::processIndirectFitParameters( - ITableWorkspace_sptr parameterWorkspace, + const ITableWorkspace_sptr ¶meterWorkspace, const std::vector<std::size_t> &grouping) { std::string const columnX = getProperty("LogName"); std::string const xAxisUnit = getProperty("ResultXAxisUnit"); @@ -708,8 +715,9 @@ void QENSFitSequential::renameWorkspaces( inputWorkspaceNames[i] + "_" + spectra[i] + endOfSuffix; return workspaceName; }; - return renameWorkspacesInQENSFit(this, rename, outputGroup, outputBaseName, - endOfSuffix + "s", getNameSuffix); + return renameWorkspacesInQENSFit(this, rename, std::move(outputGroup), + outputBaseName, endOfSuffix + "s", + getNameSuffix); } void QENSFitSequential::renameWorkspaces( @@ -717,8 +725,9 @@ void QENSFitSequential::renameWorkspaces( std::string const &outputBaseName, std::string const &endOfSuffix) { auto rename = createChildAlgorithm("RenameWorkspace", -1.0, -1.0, false); auto getNameSuffix = [&](std::size_t i) { return spectra[i] + endOfSuffix; }; - return renameWorkspacesInQENSFit(this, rename, outputGroup, outputBaseName, - endOfSuffix + "s", getNameSuffix); + return renameWorkspacesInQENSFit(this, rename, std::move(outputGroup), + outputBaseName, endOfSuffix + "s", + getNameSuffix); } void QENSFitSequential::renameGroupWorkspace( @@ -793,28 +802,31 @@ std::vector<MatrixWorkspace_sptr> QENSFitSequential::convertInputToElasticQ( } void QENSFitSequential::extractMembers( - WorkspaceGroup_sptr resultGroupWs, + const WorkspaceGroup_sptr &resultGroupWs, const std::vector<API::MatrixWorkspace_sptr> &workspaces, const std::string &outputWsName) { std::vector<std::string> workspaceNames; - std::transform( - workspaces.begin(), workspaces.end(), std::back_inserter(workspaceNames), - [](API::MatrixWorkspace_sptr workspace) { return workspace->getName(); }); - - auto extractAlgorithm = extractMembersAlgorithm(resultGroupWs, outputWsName); + std::transform(workspaces.begin(), workspaces.end(), + std::back_inserter(workspaceNames), + [](const API::MatrixWorkspace_sptr &workspace) { + return workspace->getName(); + }); + + auto extractAlgorithm = + extractMembersAlgorithm(std::move(resultGroupWs), outputWsName); extractAlgorithm->setProperty("InputWorkspaces", workspaceNames); extractAlgorithm->execute(); } void QENSFitSequential::copyLogs( - WorkspaceGroup_sptr resultWorkspaces, + const WorkspaceGroup_sptr &resultWorkspaces, std::vector<MatrixWorkspace_sptr> const &workspaces) { for (auto const &resultWorkspace : *resultWorkspaces) copyLogs(resultWorkspace, workspaces); } void QENSFitSequential::copyLogs( - Workspace_sptr resultWorkspace, + const Workspace_sptr &resultWorkspace, std::vector<MatrixWorkspace_sptr> const &workspaces) { auto logCopier = createChildAlgorithm("CopyLogs", -1.0, -1.0, false); logCopier->setProperty("OutputWorkspace", resultWorkspace->getName()); @@ -825,14 +837,14 @@ void QENSFitSequential::copyLogs( } } -void QENSFitSequential::copyLogs(MatrixWorkspace_sptr resultWorkspace, - WorkspaceGroup_sptr resultGroup) { +void QENSFitSequential::copyLogs(const MatrixWorkspace_sptr &resultWorkspace, + const WorkspaceGroup_sptr &resultGroup) { for (auto const &workspace : *resultGroup) copyLogs(resultWorkspace, workspace); } -void QENSFitSequential::copyLogs(MatrixWorkspace_sptr resultWorkspace, - Workspace_sptr resultGroup) { +void QENSFitSequential::copyLogs(const MatrixWorkspace_sptr &resultWorkspace, + const Workspace_sptr &resultGroup) { auto logCopier = createChildAlgorithm("CopyLogs", -1.0, -1.0, false); logCopier->setProperty("InputWorkspace", resultWorkspace); logCopier->setProperty("OutputWorkspace", resultGroup->getName()); @@ -840,7 +852,8 @@ void QENSFitSequential::copyLogs(MatrixWorkspace_sptr resultWorkspace, } IAlgorithm_sptr QENSFitSequential::extractMembersAlgorithm( - WorkspaceGroup_sptr resultGroupWs, const std::string &outputWsName) const { + const WorkspaceGroup_sptr &resultGroupWs, + const std::string &outputWsName) const { const bool convolved = getProperty("ConvolveMembers"); std::vector<std::string> convolvedMembers; IFunction_sptr function = getProperty("Function"); diff --git a/Framework/CurveFitting/src/Algorithms/QENSFitSimultaneous.cpp b/Framework/CurveFitting/src/Algorithms/QENSFitSimultaneous.cpp index bf2d04b5dcc5377a6eee205aa3da9df51acde537..fd6aed132d21060a2a8f6a7db2f3a98bdb02ceba 100644 --- a/Framework/CurveFitting/src/Algorithms/QENSFitSimultaneous.cpp +++ b/Framework/CurveFitting/src/Algorithms/QENSFitSimultaneous.cpp @@ -24,19 +24,20 @@ #include "MantidKernel/UnitFactory.h" #include <boost/algorithm/string/join.hpp> +#include <utility> namespace { Mantid::Kernel::Logger g_log("QENSFit"); using namespace Mantid::API; -void extractFunctionNames(CompositeFunction_sptr composite, +void extractFunctionNames(const CompositeFunction_sptr &composite, std::vector<std::string> &names) { for (auto i = 0u; i < composite->nFunctions(); ++i) names.emplace_back(composite->getFunction(i)->name()); } -void extractFunctionNames(IFunction_sptr function, +void extractFunctionNames(const IFunction_sptr &function, std::vector<std::string> &names) { auto composite = boost::dynamic_pointer_cast<CompositeFunction>(function); if (composite) @@ -45,16 +46,16 @@ void extractFunctionNames(IFunction_sptr function, names.emplace_back(function->name()); } -void extractConvolvedNames(IFunction_sptr function, +void extractConvolvedNames(const IFunction_sptr &function, std::vector<std::string> &names); -void extractConvolvedNames(CompositeFunction_sptr composite, +void extractConvolvedNames(const CompositeFunction_sptr &composite, std::vector<std::string> &names) { for (auto i = 0u; i < composite->nFunctions(); ++i) extractConvolvedNames(composite->getFunction(i), names); } -void extractConvolvedNames(IFunction_sptr function, +void extractConvolvedNames(const IFunction_sptr &function, std::vector<std::string> &names) { auto composite = boost::dynamic_pointer_cast<CompositeFunction>(function); if (composite) { @@ -66,7 +67,8 @@ void extractConvolvedNames(IFunction_sptr function, } } -MatrixWorkspace_sptr convertSpectrumAxis(MatrixWorkspace_sptr inputWorkspace) { +MatrixWorkspace_sptr +convertSpectrumAxis(const MatrixWorkspace_sptr &inputWorkspace) { auto convSpec = AlgorithmManager::Instance().create("ConvertSpectrumAxis"); convSpec->setLogging(false); convSpec->setChild(true); @@ -78,8 +80,8 @@ MatrixWorkspace_sptr convertSpectrumAxis(MatrixWorkspace_sptr inputWorkspace) { return convSpec->getProperty("OutputWorkspace"); } -MatrixWorkspace_sptr convertToElasticQ(MatrixWorkspace_sptr inputWorkspace, - bool doThrow) { +MatrixWorkspace_sptr +convertToElasticQ(const MatrixWorkspace_sptr &inputWorkspace, bool doThrow) { auto axis = inputWorkspace->getAxis(1); if (axis->isSpectra()) return convertSpectrumAxis(inputWorkspace); @@ -97,7 +99,7 @@ struct ElasticQAppender { explicit ElasticQAppender(std::vector<MatrixWorkspace_sptr> &elasticInput) : m_elasticInput(elasticInput), m_converted() {} - void operator()(MatrixWorkspace_sptr workspace, bool doThrow) { + void operator()(const MatrixWorkspace_sptr &workspace, bool doThrow) { auto it = m_converted.find(workspace.get()); if (it != m_converted.end()) m_elasticInput.emplace_back(it->second); @@ -130,7 +132,7 @@ std::string shortParameterName(const std::string &longName) { } void setMultiDataProperties(const IAlgorithm &qensFit, IAlgorithm &fit, - MatrixWorkspace_sptr workspace, + const MatrixWorkspace_sptr &workspace, const std::string &suffix) { fit.setProperty("InputWorkspace" + suffix, workspace); @@ -163,7 +165,7 @@ IFunction_sptr convertToSingleDomain(IFunction_sptr function) { return function; } -WorkspaceGroup_sptr makeGroup(Workspace_sptr workspace) { +WorkspaceGroup_sptr makeGroup(const Workspace_sptr &workspace) { auto group = boost::dynamic_pointer_cast<WorkspaceGroup>(workspace); if (group) return group; @@ -172,7 +174,7 @@ WorkspaceGroup_sptr makeGroup(Workspace_sptr workspace) { return group; } -ITableWorkspace_sptr transposeFitTable(ITableWorkspace_sptr table, +ITableWorkspace_sptr transposeFitTable(const ITableWorkspace_sptr &table, const IFunction &function, const std::string &yAxisType) { auto transposed = WorkspaceFactory::Instance().createTable(); @@ -496,7 +498,7 @@ QENSFitSimultaneous::performFit( } WorkspaceGroup_sptr QENSFitSimultaneous::processIndirectFitParameters( - ITableWorkspace_sptr parameterWorkspace, + const ITableWorkspace_sptr ¶meterWorkspace, const std::vector<std::size_t> &grouping) { std::string const xAxisUnit = getProperty("ResultXAxisUnit"); auto pifp = @@ -511,7 +513,7 @@ WorkspaceGroup_sptr QENSFitSimultaneous::processIndirectFitParameters( } void QENSFitSimultaneous::copyLogs( - WorkspaceGroup_sptr resultWorkspace, + const WorkspaceGroup_sptr &resultWorkspace, const std::vector<MatrixWorkspace_sptr> &workspaces) { auto logCopier = createChildAlgorithm("CopyLogs", -1.0, -1.0, false); for (auto &&result : *resultWorkspace) { @@ -525,8 +527,8 @@ void QENSFitSimultaneous::copyLogs( } } -void QENSFitSimultaneous::copyLogs(MatrixWorkspace_sptr resultWorkspace, - WorkspaceGroup_sptr resultGroup) { +void QENSFitSimultaneous::copyLogs(const MatrixWorkspace_sptr &resultWorkspace, + const WorkspaceGroup_sptr &resultGroup) { auto logCopier = createChildAlgorithm("CopyLogs", -1.0, -1.0, false); logCopier->setProperty("InputWorkspace", resultWorkspace); @@ -539,7 +541,7 @@ void QENSFitSimultaneous::copyLogs(MatrixWorkspace_sptr resultWorkspace, } void QENSFitSimultaneous::extractMembers( - WorkspaceGroup_sptr resultGroupWs, + const WorkspaceGroup_sptr &resultGroupWs, const std::vector<MatrixWorkspace_sptr> &workspaces, const std::string &outputWsName) { std::vector<std::string> workspaceNames; @@ -549,7 +551,8 @@ void QENSFitSimultaneous::extractMembers( workspaceNames.emplace_back(name); } - auto extractAlgorithm = extractMembersAlgorithm(resultGroupWs, outputWsName); + auto extractAlgorithm = + extractMembersAlgorithm(std::move(resultGroupWs), outputWsName); extractAlgorithm->setProperty("InputWorkspaces", workspaceNames); extractAlgorithm->execute(); @@ -557,12 +560,14 @@ void QENSFitSimultaneous::extractMembers( AnalysisDataService::Instance().remove(workspaceName); } -void QENSFitSimultaneous::addAdditionalLogs(API::WorkspaceGroup_sptr group) { +void QENSFitSimultaneous::addAdditionalLogs( + const API::WorkspaceGroup_sptr &group) { for (auto &&workspace : *group) addAdditionalLogs(workspace); } -void QENSFitSimultaneous::addAdditionalLogs(Workspace_sptr resultWorkspace) { +void QENSFitSimultaneous::addAdditionalLogs( + const Workspace_sptr &resultWorkspace) { auto logAdder = createChildAlgorithm("AddSampleLog", -1.0, -1.0, false); logAdder->setProperty("Workspace", resultWorkspace); @@ -585,7 +590,8 @@ void QENSFitSimultaneous::addAdditionalLogs(Workspace_sptr resultWorkspace) { } IAlgorithm_sptr QENSFitSimultaneous::extractMembersAlgorithm( - WorkspaceGroup_sptr resultGroupWs, const std::string &outputWsName) const { + const WorkspaceGroup_sptr &resultGroupWs, + const std::string &outputWsName) const { const bool convolved = getProperty("ConvolveMembers"); std::vector<std::string> convolvedMembers; IFunction_sptr function = getProperty("Function"); @@ -697,7 +703,7 @@ ITableWorkspace_sptr QENSFitSimultaneous::processParameterTable( } void QENSFitSimultaneous::renameWorkspaces( - API::WorkspaceGroup_sptr outputGroup, + const API::WorkspaceGroup_sptr &outputGroup, std::vector<std::string> const &spectra, std::string const &outputBaseName, std::string const &endOfSuffix, std::vector<std::string> const &inputWorkspaceNames) { @@ -707,8 +713,9 @@ void QENSFitSimultaneous::renameWorkspaces( inputWorkspaceNames[i] + "_" + spectra[i] + endOfSuffix; return workspaceName; }; - return renameWorkspacesInQENSFit(this, rename, outputGroup, outputBaseName, - endOfSuffix + "s", getNameSuffix); + return renameWorkspacesInQENSFit(this, rename, std::move(outputGroup), + outputBaseName, endOfSuffix + "s", + getNameSuffix); } } // namespace Algorithms diff --git a/Framework/CurveFitting/src/Algorithms/QENSFitUtilities.cpp b/Framework/CurveFitting/src/Algorithms/QENSFitUtilities.cpp index 171b3c5c71a3e115d9c8858c4208533d3bbd02f5..cee9bf1ef7245029624ce5c8956e9d801e8bd3b2 100644 --- a/Framework/CurveFitting/src/Algorithms/QENSFitUtilities.cpp +++ b/Framework/CurveFitting/src/Algorithms/QENSFitUtilities.cpp @@ -6,11 +6,13 @@ // SPDX - License - Identifier: GPL - 3.0 + #include "MantidCurveFitting/Algorithms/QENSFitUtilities.h" #include <unordered_map> +#include <utility> + namespace Mantid { namespace API { void renameWorkspacesWith( - WorkspaceGroup_sptr groupWorkspace, + const WorkspaceGroup_sptr &groupWorkspace, std::function<std::string(std::size_t)> const &getName, std::function<void(Workspace_sptr, const std::string &)> const &renamer) { std::unordered_map<std::string, std::size_t> nameCount; @@ -27,7 +29,8 @@ void renameWorkspacesWith( } } -void renameWorkspace(IAlgorithm_sptr renamer, Workspace_sptr workspace, +void renameWorkspace(const IAlgorithm_sptr &renamer, + const Workspace_sptr &workspace, const std::string &newName) { renamer->setProperty("InputWorkspace", workspace); renamer->setProperty("OutputWorkspace", newName); @@ -43,7 +46,7 @@ bool containsMultipleData(const std::vector<MatrixWorkspace_sptr> &workspaces) { void renameWorkspacesInQENSFit( Algorithm *qensFit, IAlgorithm_sptr renameAlgorithm, - WorkspaceGroup_sptr outputGroup, std::string const &outputBaseName, + const WorkspaceGroup_sptr &outputGroup, std::string const &outputBaseName, std::string const &, std::function<std::string(std::size_t)> const &getNameSuffix) { Progress renamerProg(qensFit, 0.98, 1.0, outputGroup->size() + 1); @@ -54,8 +57,8 @@ void renameWorkspacesInQENSFit( return name; }; - auto renamer = [&](Workspace_sptr workspace, const std::string &name) { - renameWorkspace(renameAlgorithm, workspace, name); + auto renamer = [&](const Workspace_sptr &workspace, const std::string &name) { + renameWorkspace(renameAlgorithm, std::move(workspace), name); renamerProg.report("Renamed workspace in group."); }; renameWorkspacesWith(outputGroup, getName, renamer); diff --git a/Framework/CurveFitting/src/Algorithms/RefinePowderInstrumentParameters.cpp b/Framework/CurveFitting/src/Algorithms/RefinePowderInstrumentParameters.cpp index 6fde7cc57b5b92f46d11242805f54a35ad1d225d..4672c0352d7b97db014456fd2da21fb784b735ff 100644 --- a/Framework/CurveFitting/src/Algorithms/RefinePowderInstrumentParameters.cpp +++ b/Framework/CurveFitting/src/Algorithms/RefinePowderInstrumentParameters.cpp @@ -34,6 +34,7 @@ #include <fstream> #include <iomanip> +#include <utility> #include <gsl/gsl_sf_erf.h> @@ -383,7 +384,7 @@ void RefinePowderInstrumentParameters::fitInstrumentParameters() { /** Fit function to data */ -bool RefinePowderInstrumentParameters::fitFunction(IFunction_sptr func, +bool RefinePowderInstrumentParameters::fitFunction(const IFunction_sptr &func, double &gslchi2) { API::IAlgorithm_sptr fitalg = createChildAlgorithm("Fit", 0.0, 0.2, true); fitalg->initialize(); @@ -417,7 +418,8 @@ bool RefinePowderInstrumentParameters::fitFunction(IFunction_sptr func, /** Calculate function's statistic */ double RefinePowderInstrumentParameters::calculateFunctionStatistic( - IFunction_sptr func, MatrixWorkspace_sptr dataws, size_t workspaceindex) { + const IFunction_sptr &func, const MatrixWorkspace_sptr &dataws, + size_t workspaceindex) { // 1. Fix all parameters of the function vector<string> funcparameters = func->getParameterNames(); size_t numparams = funcparameters.size(); @@ -456,14 +458,15 @@ double RefinePowderInstrumentParameters::calculateFunctionStatistic( /** Refine instrument parameters by Monte Carlo method */ void RefinePowderInstrumentParameters::refineInstrumentParametersMC( - TableWorkspace_sptr parameterWS, bool fit2) { + const TableWorkspace_sptr ¶meterWS, bool fit2) { // 1. Get function's parameter names getD2TOFFuncParamNames(m_PeakFunctionParameterNames); // 2. Parse parameter (table) workspace vector<double> stepsizes, lowerbounds, upperbounds; - importMonteCarloParametersFromTable(parameterWS, m_PeakFunctionParameterNames, - stepsizes, lowerbounds, upperbounds); + importMonteCarloParametersFromTable(std::move(parameterWS), + m_PeakFunctionParameterNames, stepsizes, + lowerbounds, upperbounds); stringstream dbss; for (size_t i = 0; i < m_PeakFunctionParameterNames.size(); ++i) { @@ -779,7 +782,7 @@ void RefinePowderInstrumentParameters::getD2TOFFuncParamNames( /** Calculate the function */ double RefinePowderInstrumentParameters::calculateD2TOFFunction( - API::IFunction_sptr func, API::FunctionDomain1DVector domain, + const API::IFunction_sptr &func, const API::FunctionDomain1DVector &domain, API::FunctionValues &values, const Mantid::HistogramData::HistogramY &rawY, const Mantid::HistogramData::HistogramE &rawE) { // 1. Check validity @@ -814,7 +817,7 @@ double RefinePowderInstrumentParameters::calculateD2TOFFunction( * m_Peaks are stored in a map. (HKL) is the key */ void RefinePowderInstrumentParameters::genPeaksFromTable( - DataObjects::TableWorkspace_sptr peakparamws) { + const DataObjects::TableWorkspace_sptr &peakparamws) { // 1. Check and clear input and output if (!peakparamws) { g_log.error() << "Input tableworkspace for peak parameters is invalid!\n"; @@ -902,7 +905,7 @@ void RefinePowderInstrumentParameters::genPeaksFromTable( * the diffrotometer geometry parameters */ void RefinePowderInstrumentParameters::importParametersFromTable( - DataObjects::TableWorkspace_sptr parameterWS, + const DataObjects::TableWorkspace_sptr ¶meterWS, std::map<std::string, double> ¶meters) { // 1. Check column orders std::vector<std::string> colnames = parameterWS->getColumnNames(); @@ -945,7 +948,7 @@ void RefinePowderInstrumentParameters::importParametersFromTable( * Arguments */ void RefinePowderInstrumentParameters::importMonteCarloParametersFromTable( - TableWorkspace_sptr tablews, vector<string> parameternames, + const TableWorkspace_sptr &tablews, const vector<string> ¶meternames, vector<double> &stepsizes, vector<double> &lowerbounds, vector<double> &upperbounds) { // 1. Get column information @@ -1054,7 +1057,8 @@ hkl, double lattice) /** Calculate value n for thermal neutron peak profile */ void RefinePowderInstrumentParameters::calculateThermalNeutronSpecial( - IFunction_sptr m_Function, const HistogramX &xVals, vector<double> &vec_n) { + const IFunction_sptr &m_Function, const HistogramX &xVals, + vector<double> &vec_n) { if (m_Function->name() != "ThermalNeutronDtoTOFFunction") { g_log.warning() << "Function (" << m_Function->name() << " is not ThermalNeutronDtoTOFFunction. And it is not " diff --git a/Framework/CurveFitting/src/Algorithms/RefinePowderInstrumentParameters3.cpp b/Framework/CurveFitting/src/Algorithms/RefinePowderInstrumentParameters3.cpp index e29bf935259831db9c174ae92860189605c10ee7..06e64a0c28016ec224b8e37ee6d89cb1d5cc430f 100644 --- a/Framework/CurveFitting/src/Algorithms/RefinePowderInstrumentParameters3.cpp +++ b/Framework/CurveFitting/src/Algorithms/RefinePowderInstrumentParameters3.cpp @@ -13,6 +13,7 @@ #include "MantidKernel/ListValidator.h" #include <iomanip> +#include <utility> using namespace Mantid::API; using namespace Mantid::CurveFitting; @@ -231,7 +232,7 @@ void RefinePowderInstrumentParameters3::parseTableWorkspaces() { /** Parse table workspace to a map of Parameters */ void RefinePowderInstrumentParameters3::parseTableWorkspace( - TableWorkspace_sptr tablews, map<string, Parameter> ¶mmap) { + const TableWorkspace_sptr &tablews, map<string, Parameter> ¶mmap) { // 1. Process Table column names std::vector<std::string> colnames = tablews->getColumnNames(); map<string, size_t> colnamedict; @@ -505,7 +506,7 @@ double RefinePowderInstrumentParameters3::doSimulatedAnnealing( * @param newparammap: parameters map containing new/proposed value */ void RefinePowderInstrumentParameters3::proposeNewValues( - vector<string> mcgroup, map<string, Parameter> &curparammap, + const vector<string> &mcgroup, map<string, Parameter> &curparammap, map<string, Parameter> &newparammap, double currchisq) { for (const auto ¶mname : mcgroup) { // random number between -1 and 1 @@ -652,7 +653,7 @@ void RefinePowderInstrumentParameters3::bookKeepMCResult( // 2. Record for the best parameters if (bestparammap.empty()) { // No record yet - duplicateParameters(parammap, bestparammap); + duplicateParameters(std::move(parammap), bestparammap); } else if (recordparameter) { // Replace the record } @@ -752,7 +753,7 @@ void RefinePowderInstrumentParameters3::setupRandomWalkStrategy( * @param parammap :: parammap */ void RefinePowderInstrumentParameters3::addParameterToMCMinimize( - vector<string> &parnamesforMC, string parname, + vector<string> &parnamesforMC, const string &parname, map<string, Parameter> parammap) { map<string, Parameter>::iterator pariter; pariter = parammap.find(parname); @@ -776,7 +777,7 @@ void RefinePowderInstrumentParameters3::addParameterToMCMinimize( * Return: chi^2 */ double RefinePowderInstrumentParameters3::calculateFunction( - map<string, Parameter> parammap, vector<double> &vecY) { + const map<string, Parameter> ¶mmap, vector<double> &vecY) { // 1. Implement parameter values to m_positionFunc if (!parammap.empty()) setFunctionParameterValues(m_positionFunc, parammap); @@ -823,7 +824,8 @@ double calculateFunctionChiSquare(const vector<double> &modelY, /** Calculate Chi^2 of the a function with all parameters are fixed */ double RefinePowderInstrumentParameters3::calculateFunctionError( - IFunction_sptr function, Workspace2D_sptr dataws, int wsindex) { + const IFunction_sptr &function, const Workspace2D_sptr &dataws, + int wsindex) { // 1. Record the fitting information vector<string> parnames = function->getParameterNames(); vector<bool> vecFix(parnames.size(), false); @@ -839,8 +841,8 @@ double RefinePowderInstrumentParameters3::calculateFunctionError( double chi2; string fitstatus; const std::string minimizer = "Levenberg-MarquardtMD"; - bool fitOK = - doFitFunction(function, dataws, wsindex, minimizer, 0, chi2, fitstatus); + bool fitOK = doFitFunction(function, std::move(dataws), wsindex, minimizer, 0, + chi2, fitstatus); if (!fitOK) { g_log.warning() << "Fit by " << minimizer @@ -868,10 +870,10 @@ double RefinePowderInstrumentParameters3::calculateFunctionError( * Return: double chi2 of the final (best) solution. If fitting fails, chi2 *wil be maximum double */ -double RefinePowderInstrumentParameters3::fitFunction(IFunction_sptr function, - Workspace2D_sptr dataws, - int wsindex, - bool powerfit) { +double +RefinePowderInstrumentParameters3::fitFunction(const IFunction_sptr &function, + const Workspace2D_sptr &dataws, + int wsindex, bool powerfit) { // 1. Store original map<string, pair<double, double>> start_paramvaluemap, paramvaluemap1, paramvaluemap2, paramvaluemap3; @@ -972,8 +974,8 @@ double RefinePowderInstrumentParameters3::fitFunction(IFunction_sptr function, * Minimizer: "Levenberg-MarquardtMD"/"Simplex" */ bool RefinePowderInstrumentParameters3::doFitFunction( - IFunction_sptr function, Workspace2D_sptr dataws, int wsindex, - string minimizer, int numiters, double &chi2, string &fitstatus) { + const IFunction_sptr &function, const Workspace2D_sptr &dataws, int wsindex, + const string &minimizer, int numiters, double &chi2, string &fitstatus) { // 0. Debug output stringstream outss; outss << "Fit function: " << m_positionFunc->asString() @@ -1074,7 +1076,8 @@ TableWorkspace_sptr RefinePowderInstrumentParameters3::genOutputProfileTable( * @param parvalue: double, parameter value */ void RefinePowderInstrumentParameters3::addOrReplace( - map<string, Parameter> ¶meters, string parname, double parvalue) { + map<string, Parameter> ¶meters, const string &parname, + double parvalue) { auto pariter = parameters.find(parname); if (pariter != parameters.end()) { parameters[parname].curvalue = parvalue; @@ -1090,7 +1093,7 @@ void RefinePowderInstrumentParameters3::addOrReplace( /** Construct output */ Workspace2D_sptr RefinePowderInstrumentParameters3::genOutputWorkspace( - FunctionDomain1DVector domain, FunctionValues rawvalues) { + const FunctionDomain1DVector &domain, const FunctionValues &rawvalues) { // 1. Create and set up output workspace size_t lenx = m_dataWS->x(m_wsIndex).size(); size_t leny = m_dataWS->y(m_wsIndex).size(); @@ -1138,7 +1141,7 @@ Workspace2D_sptr RefinePowderInstrumentParameters3::genOutputWorkspace( /** Set parameter values to function from Parameter map */ void RefinePowderInstrumentParameters3::setFunctionParameterValues( - IFunction_sptr function, map<string, Parameter> params) { + const IFunction_sptr &function, map<string, Parameter> params) { // 1. Prepare vector<string> funparamnames = function->getParameterNames(); @@ -1210,7 +1213,7 @@ Parameter>& params) * Parameter map */ void RefinePowderInstrumentParameters3::setFunctionParameterFitSetups( - IFunction_sptr function, map<string, Parameter> params) { + const IFunction_sptr &function, map<string, Parameter> params) { // 1. Prepare vector<string> funparamnames = m_positionFunc->getParameterNames(); @@ -1315,7 +1318,7 @@ void convertToDict(vector<string> strvec, map<string, size_t> &lookupdict) { //---------------------------------------------------------------------------------------------- /** Get the index from lookup dictionary (map) */ -int getStringIndex(map<string, size_t> lookupdict, string key) { +int getStringIndex(map<string, size_t> lookupdict, const string &key) { map<string, size_t>::iterator fiter; fiter = lookupdict.find(key); @@ -1336,7 +1339,8 @@ int getStringIndex(map<string, size_t> lookupdict, string key) { /** Store function parameter values to a map */ void storeFunctionParameterValue( - IFunction_sptr function, map<string, pair<double, double>> &parvaluemap) { + const IFunction_sptr &function, + map<string, pair<double, double>> &parvaluemap) { parvaluemap.clear(); vector<string> parnames = function->getParameterNames(); @@ -1354,8 +1358,8 @@ void storeFunctionParameterValue( * and a (string, Parameter) map */ void restoreFunctionParameterValue( - map<string, pair<double, double>> parvaluemap, IFunction_sptr function, - map<string, Parameter> ¶mmap) { + map<string, pair<double, double>> parvaluemap, + const IFunction_sptr &function, map<string, Parameter> ¶mmap) { vector<string> parnames = function->getParameterNames(); for (auto &parname : parnames) { diff --git a/Framework/CurveFitting/src/Algorithms/SplineBackground.cpp b/Framework/CurveFitting/src/Algorithms/SplineBackground.cpp index d638847df532074cf858104e004b609b74ce6b57..df09ed43a17ae3cd29846741aeb43239e0c1ef58 100644 --- a/Framework/CurveFitting/src/Algorithms/SplineBackground.cpp +++ b/Framework/CurveFitting/src/Algorithms/SplineBackground.cpp @@ -247,7 +247,7 @@ void SplineBackground::freeBSplinePointers() { * @return:: A shared pointer to the output workspace */ MatrixWorkspace_sptr -SplineBackground::saveSplineOutput(const API::MatrixWorkspace_sptr ws, +SplineBackground::saveSplineOutput(const API::MatrixWorkspace_sptr &ws, const size_t spec) { const auto &xInputVals = ws->x(spec); const auto &yInputVals = ws->y(spec); diff --git a/Framework/CurveFitting/src/Algorithms/SplineInterpolation.cpp b/Framework/CurveFitting/src/Algorithms/SplineInterpolation.cpp index 00b4d7cb584aba107f527f9b07a7f30228e47083..99c4f26e976fc4a3a9b1aa8ae04562f477f3ef8b 100644 --- a/Framework/CurveFitting/src/Algorithms/SplineInterpolation.cpp +++ b/Framework/CurveFitting/src/Algorithms/SplineInterpolation.cpp @@ -258,9 +258,9 @@ void SplineInterpolation::exec() { * @param iws :: The input workspace to interpolate * @return The pointer to the newly created workspace */ -API::MatrixWorkspace_sptr -SplineInterpolation::setupOutputWorkspace(API::MatrixWorkspace_sptr mws, - API::MatrixWorkspace_sptr iws) const { +API::MatrixWorkspace_sptr SplineInterpolation::setupOutputWorkspace( + const API::MatrixWorkspace_sptr &mws, + const API::MatrixWorkspace_sptr &iws) const { const size_t numSpec = iws->getNumberHistograms(); MatrixWorkspace_sptr outputWorkspace = WorkspaceFactory::Instance().create(mws, numSpec); @@ -300,7 +300,7 @@ SplineInterpolation::convertBinnedData(MatrixWorkspace_sptr workspace) { * @param row :: The row of spectra to use */ void SplineInterpolation::setInterpolationPoints( - MatrixWorkspace_const_sptr inputWorkspace, const size_t row) const { + const MatrixWorkspace_const_sptr &inputWorkspace, const size_t row) const { const auto &xIn = inputWorkspace->x(row); const auto &yIn = inputWorkspace->y(row); const size_t size = xIn.size(); @@ -321,8 +321,9 @@ void SplineInterpolation::setInterpolationPoints( * @param order :: The order of derivatives to calculate */ void SplineInterpolation::calculateDerivatives( - API::MatrixWorkspace_const_sptr inputWorkspace, - API::MatrixWorkspace_sptr outputWorkspace, const size_t order) const { + const API::MatrixWorkspace_const_sptr &inputWorkspace, + const API::MatrixWorkspace_sptr &outputWorkspace, + const size_t order) const { // get x and y parameters from workspaces const size_t nData = inputWorkspace->y(0).size(); const double *xValues = &(inputWorkspace->x(0)[0]); @@ -339,8 +340,8 @@ void SplineInterpolation::calculateDerivatives( * @param row :: The row of spectra to use */ void SplineInterpolation::calculateSpline( - MatrixWorkspace_const_sptr inputWorkspace, - MatrixWorkspace_sptr outputWorkspace, const size_t row) const { + const MatrixWorkspace_const_sptr &inputWorkspace, + const MatrixWorkspace_sptr &outputWorkspace, const size_t row) const { // setup input parameters const size_t nData = inputWorkspace->y(0).size(); const double *xValues = &(inputWorkspace->x(0)[0]); @@ -360,7 +361,7 @@ void SplineInterpolation::calculateSpline( * @param derivs : the vector of derivative workspaces */ void SplineInterpolation::extrapolateFlat( - MatrixWorkspace_sptr ows, MatrixWorkspace_const_sptr iwspt, + const MatrixWorkspace_sptr &ows, const MatrixWorkspace_const_sptr &iwspt, const size_t row, const std::pair<size_t, size_t> &indices, const bool doDerivs, std::vector<MatrixWorkspace_sptr> &derivs) const { @@ -393,10 +394,9 @@ void SplineInterpolation::extrapolateFlat( * @param row : the workspace index * @return : pair of indices for representing the interpolation range */ -std::pair<size_t, size_t> -SplineInterpolation::findInterpolationRange(MatrixWorkspace_const_sptr iwspt, - MatrixWorkspace_sptr mwspt, - const size_t row) { +std::pair<size_t, size_t> SplineInterpolation::findInterpolationRange( + const MatrixWorkspace_const_sptr &iwspt, const MatrixWorkspace_sptr &mwspt, + const size_t row) { auto xAxisIn = iwspt->x(row).rawData(); std::sort(xAxisIn.begin(), xAxisIn.end()); diff --git a/Framework/CurveFitting/src/Algorithms/SplineSmoothing.cpp b/Framework/CurveFitting/src/Algorithms/SplineSmoothing.cpp index b0b09aab49c9105475d7a84ed7a0d680be637207..d906ded7b5e398337bae71f9e96a37e54c1b431b 100644 --- a/Framework/CurveFitting/src/Algorithms/SplineSmoothing.cpp +++ b/Framework/CurveFitting/src/Algorithms/SplineSmoothing.cpp @@ -158,7 +158,7 @@ void SplineSmoothing::calculateSpectrumDerivatives(const int index, * @param ws :: The input workspace * @param row :: The row of spectra to use */ -void SplineSmoothing::performAdditionalFitting(MatrixWorkspace_sptr ws, +void SplineSmoothing::performAdditionalFitting(const MatrixWorkspace_sptr &ws, const int row) { // perform additional fitting of the points auto fit = createChildAlgorithm("Fit"); @@ -306,9 +306,10 @@ void SplineSmoothing::addSmoothingPoints(const std::set<int> &points, std::vector<double> breakPoints; breakPoints.reserve(num_points); // set each of the x and y points to redefine the spline - for (auto const &point : points) { - breakPoints.emplace_back(xs[point]); - } + + std::transform(points.begin(), points.end(), std::back_inserter(breakPoints), + [&xs](const auto &point) { return xs[point]; }); + m_cspline->setAttribute("BreakPoints", API::IFunction::Attribute(breakPoints)); @@ -367,7 +368,7 @@ void SplineSmoothing::selectSmoothingPoints( break; } - } else if (!incBreaks) { + } else { if (smoothPts.size() >= xs.size() - 1) { break; } diff --git a/Framework/CurveFitting/src/AugmentedLagrangianOptimizer.cpp b/Framework/CurveFitting/src/AugmentedLagrangianOptimizer.cpp index edbeff12fe177e8639e8898644ee4cafff5aab7c..2b325168c3c2d276f47fc55d6b54d42425e3d8d8 100644 --- a/Framework/CurveFitting/src/AugmentedLagrangianOptimizer.cpp +++ b/Framework/CurveFitting/src/AugmentedLagrangianOptimizer.cpp @@ -137,7 +137,7 @@ void AugmentedLagrangianOptimizer::minimize(std::vector<double> &xv) const { assert(numParameters() == xv.size()); double ICM(HUGE_VAL), minf_penalty(HUGE_VAL), rho(0.0); - double fcur(0.0), minf(HUGE_VAL), penalty(0.0); + double minf(HUGE_VAL), penalty(0.0); std::vector<double> xcur(xv), lambda(numEqualityConstraints(), 0), mu(numInequalityConstraints()); int minfIsFeasible = 0; @@ -149,7 +149,7 @@ void AugmentedLagrangianOptimizer::minimize(std::vector<double> &xv) const { if (numEqualityConstraints() > 0 || numInequalityConstraints() > 0) { double con2 = 0; - fcur = m_userfunc(numParameters(), xcur.data()); + double fcur = m_userfunc(numParameters(), xcur.data()); int feasible = 1; for (size_t i = 0; i < numEqualityConstraints(); ++i) { double hi = evaluateConstraint(m_eq, i, numParameters(), xcur.data()); @@ -177,7 +177,7 @@ void AugmentedLagrangianOptimizer::minimize(std::vector<double> &xv) const { unconstrainedOptimization(lambda, mu, rho, xcur); - fcur = m_userfunc(numParameters(), xcur.data()); + double fcur = m_userfunc(numParameters(), xcur.data()); ICM = 0.0; penalty = 0.0; int feasible = 1; diff --git a/Framework/CurveFitting/src/Constraints/BoundaryConstraint.cpp b/Framework/CurveFitting/src/Constraints/BoundaryConstraint.cpp index 348dd6e25cbf6b3a2ca3e7ee86479518ec06d7db..12b3c9ac613905c0114ad1d27d68cbe1fb2535b1 100644 --- a/Framework/CurveFitting/src/Constraints/BoundaryConstraint.cpp +++ b/Framework/CurveFitting/src/Constraints/BoundaryConstraint.cpp @@ -51,7 +51,7 @@ BoundaryConstraint::BoundaryConstraint(const std::string ¶mName) * a tie or a constraint. */ BoundaryConstraint::BoundaryConstraint(API::IFunction *fun, - const std::string paramName, + const std::string ¶mName, const double lowerBound, const double upperBound, bool isDefault) : m_penaltyFactor(getDefaultPenaltyFactor()), m_hasLowerBound(true), @@ -61,7 +61,7 @@ BoundaryConstraint::BoundaryConstraint(API::IFunction *fun, } BoundaryConstraint::BoundaryConstraint(API::IFunction *fun, - const std::string paramName, + const std::string ¶mName, const double lowerBound, bool isDefault) : m_penaltyFactor(getDefaultPenaltyFactor()), m_hasLowerBound(true), m_hasUpperBound(false), m_lowerBound(lowerBound), m_upperBound(-DBL_MAX) { diff --git a/Framework/CurveFitting/src/CostFunctions/CostFuncFitting.cpp b/Framework/CurveFitting/src/CostFunctions/CostFuncFitting.cpp index d5163767645a8f9f3b14789aa4e7c7a140e9cbda..9e8effe85843fa83c130c278c0f6ebdb2306fd01 100644 --- a/Framework/CurveFitting/src/CostFunctions/CostFuncFitting.cpp +++ b/Framework/CurveFitting/src/CostFunctions/CostFuncFitting.cpp @@ -15,6 +15,7 @@ #include <gsl/gsl_multifit_nlin.h> #include <limits> +#include <utility> namespace Mantid { namespace CurveFitting { @@ -81,9 +82,9 @@ size_t CostFuncFitting::nParams() const { void CostFuncFitting::setFittingFunction(API::IFunction_sptr function, API::FunctionDomain_sptr domain, API::FunctionValues_sptr values) { - m_function = function; - m_domain = domain; - m_values = values; + m_function = std::move(function); + m_domain = std::move(domain); + m_values = std::move(values); reset(); } @@ -127,14 +128,15 @@ void CostFuncFitting::calActiveCovarianceMatrix(GSLMatrix &covar, // construct the jacobian GSLJacobian J(*m_function, m_values->size()); size_t na = this->nParams(); // number of active parameters - assert(J.getJ()->size2 == na); + auto j = J.getJ(); + assert(j->size2 == na); covar.resize(na, na); // calculate the derivatives m_function->functionDeriv(*m_domain, J); // let the GSL to compute the covariance matrix - gsl_multifit_covar(J.getJ(), epsrel, covar.gsl()); + gsl_multifit_covar(j, epsrel, covar.gsl()); } /** Calculates covariance matrix @@ -418,9 +420,7 @@ double CostFuncFitting::valDerivHessian(bool evalDeriv, } } m_dirtyDeriv = false; - } - if (evalDeriv) { if (m_includePenalty) { size_t i = 0; for (size_t ip = 0; ip < np; ++ip) { diff --git a/Framework/CurveFitting/src/CostFunctions/CostFuncRwp.cpp b/Framework/CurveFitting/src/CostFunctions/CostFuncRwp.cpp index 6c0905074835e9c27c7a96703e45172face66def..ab616ca25b9dfe05af338ad39471bcf640cee5e2 100644 --- a/Framework/CurveFitting/src/CostFunctions/CostFuncRwp.cpp +++ b/Framework/CurveFitting/src/CostFunctions/CostFuncRwp.cpp @@ -47,7 +47,7 @@ CostFuncRwp::getFitWeights(API::FunctionValues_sptr values) const { //---------------------------------------------------------------------------------------------- /** Get weight of data point i(1/sigma) */ -double CostFuncRwp::getWeight(API::FunctionValues_sptr values, size_t i, +double CostFuncRwp::getWeight(const API::FunctionValues_sptr &values, size_t i, double sqrtW) const { return (values->getFitWeight(i) / sqrtW); } @@ -55,7 +55,7 @@ double CostFuncRwp::getWeight(API::FunctionValues_sptr values, size_t i, //---------------------------------------------------------------------------------------------- /** Get square root of normalization weight (W) */ -double CostFuncRwp::calSqrtW(API::FunctionValues_sptr values) const { +double CostFuncRwp::calSqrtW(const API::FunctionValues_sptr &values) const { double weight = 0.0; // FIXME : This might give a wrong answer in case of multiple-domain diff --git a/Framework/CurveFitting/src/FunctionDomain1DSpectrumCreator.cpp b/Framework/CurveFitting/src/FunctionDomain1DSpectrumCreator.cpp index 2db929f691489cfecf372afe1306f2372021ceb4..8be493174ac62ec966d410d82f2873a440cbae60 100644 --- a/Framework/CurveFitting/src/FunctionDomain1DSpectrumCreator.cpp +++ b/Framework/CurveFitting/src/FunctionDomain1DSpectrumCreator.cpp @@ -4,6 +4,8 @@ // NScD Oak Ridge National Laboratory, European Spallation Source, // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + +#include <utility> + #include "MantidCurveFitting/FunctionDomain1DSpectrumCreator.h" #include "MantidHistogramData/BinEdges.h" #include "MantidHistogramData/Points.h" @@ -29,7 +31,7 @@ FunctionDomain1DSpectrumCreator::FunctionDomain1DSpectrumCreator() */ void FunctionDomain1DSpectrumCreator::setMatrixWorkspace( MatrixWorkspace_sptr matrixWorkspace) { - m_matrixWorkspace = matrixWorkspace; + m_matrixWorkspace = std::move(matrixWorkspace); } /** diff --git a/Framework/CurveFitting/src/Functions/ChebfunBase.cpp b/Framework/CurveFitting/src/Functions/ChebfunBase.cpp index 4b538ddad9e4d6c16b17e6cf8408c2108965a799..989655b8989f01f1437a59a125d697d1e8a4d1e5 100644 --- a/Framework/CurveFitting/src/Functions/ChebfunBase.cpp +++ b/Framework/CurveFitting/src/Functions/ChebfunBase.cpp @@ -22,6 +22,7 @@ #include <limits> #include <numeric> #include <sstream> +#include <utility> namespace Mantid { namespace CurveFitting { @@ -465,7 +466,7 @@ ChebfunBase_sptr ChebfunBase::bestFit(double start, double end, std::vector<double> &p, std::vector<double> &a, double maxA, double tolerance, size_t maxSize) { - return bestFitTempl(start, end, f, p, a, maxA, tolerance, maxSize); + return bestFitTempl(start, end, std::move(f), p, a, maxA, tolerance, maxSize); } /// Template specialization for IFunction @@ -603,7 +604,7 @@ std::vector<double> ChebfunBase::calcP(const std::vector<double> &a) const { */ std::vector<double> ChebfunBase::fit(ChebfunFunctionType f) const { std::vector<double> res(size()); - std::transform(m_x.begin(), m_x.end(), res.begin(), f); + std::transform(m_x.begin(), m_x.end(), res.begin(), std::move(f)); return res; } @@ -626,7 +627,7 @@ std::vector<double> ChebfunBase::fit(const API::IFunction &f) const { * @param f :: Function to calculate. * @param p :: Values of function f at the even-valued indices of m_x. */ -std::vector<double> ChebfunBase::fitOdd(ChebfunFunctionType f, +std::vector<double> ChebfunBase::fitOdd(const ChebfunFunctionType &f, std::vector<double> &p) const { assert(size() == p.size() * 2 - 1); assert(size() % 2 == 1); diff --git a/Framework/CurveFitting/src/Functions/CrystalFieldFunction.cpp b/Framework/CurveFitting/src/Functions/CrystalFieldFunction.cpp index e4692b5c89273b06643ff52687436d42362613ff..f1177591bae3e842f477ab5ec1ef924061cdf94a 100644 --- a/Framework/CurveFitting/src/Functions/CrystalFieldFunction.cpp +++ b/Framework/CurveFitting/src/Functions/CrystalFieldFunction.cpp @@ -26,6 +26,7 @@ #include <boost/optional.hpp> #include <boost/regex.hpp> #include <limits> +#include <utility> namespace Mantid { namespace CurveFitting { @@ -122,7 +123,7 @@ void CrystalFieldFunction::function(const FunctionDomain &domain, /// Set the source function /// @param source :: New source function. void CrystalFieldFunction::setSource(IFunction_sptr source) const { - m_source = source; + m_source = std::move(source); } size_t CrystalFieldFunction::getNumberDomains() const { diff --git a/Framework/CurveFitting/src/Functions/CrystalFieldMagnetisation.cpp b/Framework/CurveFitting/src/Functions/CrystalFieldMagnetisation.cpp index a5d7c2427002afcf41fb09371257a61bd8519be0..6989124844d42feeea7bcbabe93646837cb2b5a4 100644 --- a/Framework/CurveFitting/src/Functions/CrystalFieldMagnetisation.cpp +++ b/Framework/CurveFitting/src/Functions/CrystalFieldMagnetisation.cpp @@ -28,7 +28,7 @@ namespace { // Does the actual calculation of the magnetisation void calculate(double *out, const double *xValues, const size_t nData, const ComplexFortranMatrix &ham, const int nre, - const DoubleFortranVector Hmag, const double T, + const DoubleFortranVector &Hmag, const double T, const double convfact, const bool iscgs) { const double beta = 1 / (PhysicalConstants::BoltzmannConstant * T); // x-data is the applied field magnitude. We need to recalculate diff --git a/Framework/CurveFitting/src/Functions/CrystalFieldMoment.cpp b/Framework/CurveFitting/src/Functions/CrystalFieldMoment.cpp index f18a27668c3ab35ff7159c5d4954446bb03dfa41..808f0725dc645df75a979f51e9d229ce683f20ad 100644 --- a/Framework/CurveFitting/src/Functions/CrystalFieldMoment.cpp +++ b/Framework/CurveFitting/src/Functions/CrystalFieldMoment.cpp @@ -28,7 +28,7 @@ namespace { // Does the actual calculation of the magnetic moment void calculate(double *out, const double *xValues, const size_t nData, const ComplexFortranMatrix &ham, const int nre, - const DoubleFortranVector Hdir, const double Hmag, + const DoubleFortranVector &Hdir, const double Hmag, const double convfact) { const double k_B = PhysicalConstants::BoltzmannConstant; DoubleFortranVector en; diff --git a/Framework/CurveFitting/src/Functions/CrystalFieldMultiSpectrum.cpp b/Framework/CurveFitting/src/Functions/CrystalFieldMultiSpectrum.cpp index 2841d4b75ba02744dde0531f394d78408982060e..2134f11c7727fd4e4624199baa65cf7eee1ab698 100644 --- a/Framework/CurveFitting/src/Functions/CrystalFieldMultiSpectrum.cpp +++ b/Framework/CurveFitting/src/Functions/CrystalFieldMultiSpectrum.cpp @@ -125,10 +125,12 @@ CrystalFieldMultiSpectrum::CrystalFieldMultiSpectrum() size_t CrystalFieldMultiSpectrum::getNumberDomains() const { if (!m_target) { buildTargetFunction(); + + if (!m_target) { + throw std::runtime_error("Failed to build target function."); + } } - if (!m_target) { - throw std::runtime_error("Failed to build target function."); - } + return m_target->getNumberDomains(); } diff --git a/Framework/CurveFitting/src/Functions/IkedaCarpenterPV.cpp b/Framework/CurveFitting/src/Functions/IkedaCarpenterPV.cpp index e6a0bd71e1c674a5d820208f77c80b9917faa24d..21e693426a71998d0951bd2ab9364de071c30374 100644 --- a/Framework/CurveFitting/src/Functions/IkedaCarpenterPV.cpp +++ b/Framework/CurveFitting/src/Functions/IkedaCarpenterPV.cpp @@ -128,7 +128,7 @@ void IkedaCarpenterPV::init() { this->lowerConstraint0("X0"); } -void IkedaCarpenterPV::lowerConstraint0(std::string paramName) { +void IkedaCarpenterPV::lowerConstraint0(const std::string ¶mName) { auto mixingConstraint = std::make_unique<BoundaryConstraint>(this, paramName, 0.0, true); mixingConstraint->setPenaltyFactor(1e9); diff --git a/Framework/CurveFitting/src/Functions/PawleyFunction.cpp b/Framework/CurveFitting/src/Functions/PawleyFunction.cpp index be54a4e856f9ef91a63ee36e5d092277c5d23a4f..1e86a37b92dcf1fd2f0c283a9990d214e46ee70d 100644 --- a/Framework/CurveFitting/src/Functions/PawleyFunction.cpp +++ b/Framework/CurveFitting/src/Functions/PawleyFunction.cpp @@ -405,7 +405,8 @@ double PawleyFunction::getTransformedCenter(double d) const { return d; } -void PawleyFunction::setPeakPositions(std::string centreName, double zeroShift, +void PawleyFunction::setPeakPositions(const std::string ¢reName, + double zeroShift, const UnitCell &cell) const { for (size_t i = 0; i < m_hkls.size(); ++i) { double centre = getTransformedCenter(cell.d(m_hkls[i])); diff --git a/Framework/CurveFitting/src/Functions/ProcessBackground.cpp b/Framework/CurveFitting/src/Functions/ProcessBackground.cpp index bbced88b361e2a919b37521efccced067662a313..cf4d6c442941cd0e8ffef66436252b251b88d4de 100644 --- a/Framework/CurveFitting/src/Functions/ProcessBackground.cpp +++ b/Framework/CurveFitting/src/Functions/ProcessBackground.cpp @@ -22,6 +22,7 @@ #include <boost/algorithm/string.hpp> #include <boost/algorithm/string/predicate.hpp> #include <boost/algorithm/string/split.hpp> +#include <utility> using namespace Mantid; @@ -583,7 +584,7 @@ void ProcessBackground::selectFromGivenFunction() { /** Select background automatically */ DataObjects::Workspace2D_sptr -ProcessBackground::autoBackgroundSelection(Workspace2D_sptr bkgdWS) { +ProcessBackground::autoBackgroundSelection(const Workspace2D_sptr &bkgdWS) { // Get background type and create bakground function BackgroundFunction_sptr bkgdfunction = createBackgroundFunction(m_bkgdType); @@ -649,7 +650,7 @@ ProcessBackground::autoBackgroundSelection(Workspace2D_sptr bkgdWS) { /** Create a background function from input properties */ BackgroundFunction_sptr -ProcessBackground::createBackgroundFunction(const string backgroundtype) { +ProcessBackground::createBackgroundFunction(const string &backgroundtype) { Functions::BackgroundFunction_sptr bkgdfunction; if (backgroundtype == "Polynomial") { @@ -679,8 +680,8 @@ ProcessBackground::createBackgroundFunction(const string backgroundtype) { //---------------------------------------------------------------------------------------------- /** Filter non-background data points out and create a background workspace */ -Workspace2D_sptr -ProcessBackground::filterForBackground(BackgroundFunction_sptr bkgdfunction) { +Workspace2D_sptr ProcessBackground::filterForBackground( + const BackgroundFunction_sptr &bkgdfunction) { double posnoisetolerance = getProperty("NoiseTolerance"); double negnoisetolerance = getProperty("NegativeNoiseTolerance"); if (isEmpty(negnoisetolerance)) @@ -751,7 +752,8 @@ ProcessBackground::filterForBackground(BackgroundFunction_sptr bkgdfunction) { //---------------------------------------------------------------------------------------------- /** Fit background function */ -void ProcessBackground::fitBackgroundFunction(std::string bkgdfunctiontype) { +void ProcessBackground::fitBackgroundFunction( + const std::string &bkgdfunctiontype) { // Get background type and create bakground function BackgroundFunction_sptr bkgdfunction = createBackgroundFunction(bkgdfunctiontype); @@ -884,9 +886,10 @@ void ProcessBackground::removePeaks() { //---------------------------------------------------------------------------------------------- /** Set up: parse peak workspace to vectors */ -void RemovePeaks::setup(TableWorkspace_sptr peaktablews) { +void RemovePeaks::setup(const TableWorkspace_sptr &peaktablews) { // Parse table workspace - parsePeakTableWorkspace(peaktablews, m_vecPeakCentre, m_vecPeakFWHM); + parsePeakTableWorkspace(std::move(peaktablews), m_vecPeakCentre, + m_vecPeakFWHM); // Check if (m_vecPeakCentre.size() != m_vecPeakFWHM.size()) @@ -900,8 +903,8 @@ void RemovePeaks::setup(TableWorkspace_sptr peaktablews) { /** Remove peaks from a input workspace */ Workspace2D_sptr -RemovePeaks::removePeaks(API::MatrixWorkspace_const_sptr dataws, int wsindex, - double numfwhm) { +RemovePeaks::removePeaks(const API::MatrixWorkspace_const_sptr &dataws, + int wsindex, double numfwhm) { // Check if (m_vecPeakCentre.empty()) throw runtime_error("RemovePeaks has not been setup yet. "); @@ -956,9 +959,9 @@ RemovePeaks::removePeaks(API::MatrixWorkspace_const_sptr dataws, int wsindex, //---------------------------------------------------------------------------------------------- /** Parse table workspace */ -void RemovePeaks::parsePeakTableWorkspace(TableWorkspace_sptr peaktablews, - vector<double> &vec_peakcentre, - vector<double> &vec_peakfwhm) { +void RemovePeaks::parsePeakTableWorkspace( + const TableWorkspace_sptr &peaktablews, vector<double> &vec_peakcentre, + vector<double> &vec_peakfwhm) { // Get peak table workspace information vector<string> colnames = peaktablews->getColumnNames(); int index_centre = -1; diff --git a/Framework/CurveFitting/src/Functions/SimpleChebfun.cpp b/Framework/CurveFitting/src/Functions/SimpleChebfun.cpp index aad46b07eaa898c9083975afa0a3d37e480344c3..bb5562a1a1263a8ce610c82f041df4b06eeef7a3 100644 --- a/Framework/CurveFitting/src/Functions/SimpleChebfun.cpp +++ b/Framework/CurveFitting/src/Functions/SimpleChebfun.cpp @@ -8,6 +8,7 @@ #include "MantidAPI/IFunction.h" #include <boost/make_shared.hpp> +#include <utility> namespace Mantid { namespace CurveFitting { @@ -27,7 +28,7 @@ SimpleChebfun::SimpleChebfun(size_t n, ChebfunFunctionType fun, double start, double end) : m_badFit(false) { m_base = boost::make_shared<ChebfunBase>(n, start, end); - m_P = m_base->fit(fun); + m_P = m_base->fit(std::move(fun)); } SimpleChebfun::SimpleChebfun(size_t n, const API::IFunction &fun, double start, @@ -49,8 +50,8 @@ SimpleChebfun::SimpleChebfun(size_t n, const API::IFunction &fun, double start, /// @param accuracy :: The accuracy of the approximation. /// @param badSize :: If automatic approxiamtion fails the base will have this /// size. -SimpleChebfun::SimpleChebfun(ChebfunFunctionType fun, double start, double end, - double accuracy, size_t badSize) +SimpleChebfun::SimpleChebfun(const ChebfunFunctionType &fun, double start, + double end, double accuracy, size_t badSize) : m_badFit(false) { m_base = ChebfunBase::bestFitAnyTolerance<ChebfunFunctionType>( start, end, fun, m_P, m_A, accuracy); @@ -84,7 +85,7 @@ SimpleChebfun::SimpleChebfun(const std::vector<double> &x, } /// Construct an empty SimpleChebfun with shared base. -SimpleChebfun::SimpleChebfun(ChebfunBase_sptr base) : m_badFit(false) { +SimpleChebfun::SimpleChebfun(const ChebfunBase_sptr &base) : m_badFit(false) { assert(base); m_base = base; m_P.resize(base->size()); @@ -169,7 +170,7 @@ double SimpleChebfun::integrate() const { return m_base->integrate(m_P); } /// Add a C++ function to the function /// @param fun :: A function to add. -SimpleChebfun &SimpleChebfun::operator+=(ChebfunFunctionType fun) { +SimpleChebfun &SimpleChebfun::operator+=(const ChebfunFunctionType &fun) { auto &x = xPoints(); for (size_t i = 0; i < x.size(); ++i) { m_P[i] += fun(x[i]); diff --git a/Framework/CurveFitting/src/Functions/TabulatedFunction.cpp b/Framework/CurveFitting/src/Functions/TabulatedFunction.cpp index a6a0ad67d4740d1b8ad32c7c123e09f8548f7ee0..f4f3d938c5ce63719fd00620d6da9993349511f0 100644 --- a/Framework/CurveFitting/src/Functions/TabulatedFunction.cpp +++ b/Framework/CurveFitting/src/Functions/TabulatedFunction.cpp @@ -18,6 +18,7 @@ #include <cmath> #include <fstream> #include <sstream> +#include <utility> namespace Mantid { namespace CurveFitting { @@ -315,7 +316,7 @@ void TabulatedFunction::loadWorkspace(const std::string &wsName) const { */ void TabulatedFunction::loadWorkspace( boost::shared_ptr<API::MatrixWorkspace> ws) const { - m_workspace = ws; + m_workspace = std::move(ws); m_setupFinished = false; } diff --git a/Framework/CurveFitting/src/Functions/ThermalNeutronDtoTOFFunction.cpp b/Framework/CurveFitting/src/Functions/ThermalNeutronDtoTOFFunction.cpp index 43e30a119cd832743aa301eb617f04f339b0f54e..89be09148de6cd15feb694229a3094b68ed377e1 100644 --- a/Framework/CurveFitting/src/Functions/ThermalNeutronDtoTOFFunction.cpp +++ b/Framework/CurveFitting/src/Functions/ThermalNeutronDtoTOFFunction.cpp @@ -67,7 +67,7 @@ void ThermalNeutronDtoTOFFunction::function1D(double *out, * xValues containing the d-space value of peaks centres */ void ThermalNeutronDtoTOFFunction::function1D( - vector<double> &out, const vector<double> xValues) const { + vector<double> &out, const vector<double> &xValues) const { double dtt1 = getParameter(0); double dtt1t = getParameter(1); double dtt2t = getParameter(2); diff --git a/Framework/CurveFitting/src/GSLFunctions.cpp b/Framework/CurveFitting/src/GSLFunctions.cpp index 9600b1f0df213d3beef80c8a699df3257c357b65..cfa30cce795b97ddccb4c621e6e038c5fa7a2cc9 100644 --- a/Framework/CurveFitting/src/GSLFunctions.cpp +++ b/Framework/CurveFitting/src/GSLFunctions.cpp @@ -163,7 +163,7 @@ int gsl_fdf(const gsl_vector *x, void *params, gsl_vector *f, gsl_matrix *J) { * @param cf :: ICostFunction */ GSL_FitData::GSL_FitData( - boost::shared_ptr<CostFunctions::CostFuncLeastSquares> cf) + const boost::shared_ptr<CostFunctions::CostFuncLeastSquares> &cf) : function(cf->getFittingFunction()), costFunction(cf) { gsl_set_error_handler_off(); // number of active parameters diff --git a/Framework/CurveFitting/src/GSLVector.cpp b/Framework/CurveFitting/src/GSLVector.cpp index 03f6450610349824e7184c228544b34e2a9e534b..87bdc8c1f11562ebacae17784617b581078fdef7 100644 --- a/Framework/CurveFitting/src/GSLVector.cpp +++ b/Framework/CurveFitting/src/GSLVector.cpp @@ -168,18 +168,16 @@ GSLVector &GSLVector::operator*=(const GSLVector &v) { /// Multiply by a number /// @param d :: The number GSLVector &GSLVector::operator*=(const double d) { - for (auto &x : m_data) { - x *= d; - } + std::transform(m_data.begin(), m_data.end(), m_data.begin(), + [d](double x) { return x * d; }); return *this; } /// Add a number /// @param d :: The number GSLVector &GSLVector::operator+=(const double d) { - for (auto &x : m_data) { - x += d; - } + std::transform(m_data.begin(), m_data.end(), m_data.begin(), + [d](double x) { return x + d; }); return *this; } diff --git a/Framework/CurveFitting/src/IMWDomainCreator.cpp b/Framework/CurveFitting/src/IMWDomainCreator.cpp index 710fcddc429b9e390dfb5e085cbf1bc6ba225836..6cbb4304fe0b8dea4e541582c411c60f0576aa04 100644 --- a/Framework/CurveFitting/src/IMWDomainCreator.cpp +++ b/Framework/CurveFitting/src/IMWDomainCreator.cpp @@ -409,7 +409,7 @@ void IMWDomainCreator::addFunctionValuesToWS( const API::IFunction_sptr &function, boost::shared_ptr<API::MatrixWorkspace> &ws, const size_t wsIndex, const boost::shared_ptr<API::FunctionDomain> &domain, - boost::shared_ptr<API::FunctionValues> resultValues) const { + const boost::shared_ptr<API::FunctionValues> &resultValues) const { const size_t nData = resultValues->size(); resultValues->zeroCalculated(); diff --git a/Framework/CurveFitting/src/MultiDomainCreator.cpp b/Framework/CurveFitting/src/MultiDomainCreator.cpp index 977cc3f0e5515924528b4b3c9fdface768991680..6e3f69ff2d8d7de395867537350733211e81b77f 100644 --- a/Framework/CurveFitting/src/MultiDomainCreator.cpp +++ b/Framework/CurveFitting/src/MultiDomainCreator.cpp @@ -15,6 +15,7 @@ #include "MantidAPI/WorkspaceProperty.h" #include "MantidKernel/Logger.h" +#include <memory> #include <sstream> #include <stdexcept> @@ -46,11 +47,12 @@ void MultiDomainCreator::createDomain( "Cannot create JointDomain: number of workspaces does not match " "the number of creators"); } - auto jointDomain = new API::JointDomain; + auto jointDomain = std::make_unique<API::JointDomain>(); API::FunctionValues_sptr values; i0 = 0; for (auto &creator : m_creators) { if (!creator) { + throw std::runtime_error("Missing domain creator"); } API::FunctionDomain_sptr domain; @@ -58,7 +60,7 @@ void MultiDomainCreator::createDomain( jointDomain->addDomain(domain); i0 += domain->size(); } - domain.reset(jointDomain); + domain.reset(jointDomain.release()); ivalues = values; } diff --git a/Framework/CurveFitting/src/SeqDomain.cpp b/Framework/CurveFitting/src/SeqDomain.cpp index f7a48a563f7cea74f07a65fc650eacb4d24fee05..e5539de7cb20c20bc668e3a84ebf2ce5eba40c35 100644 --- a/Framework/CurveFitting/src/SeqDomain.cpp +++ b/Framework/CurveFitting/src/SeqDomain.cpp @@ -50,7 +50,7 @@ void SeqDomain::getDomainAndValues(size_t i, API::FunctionDomain_sptr &domain, * Add new domain creator * @param creator :: A shared pointer to a new creator. */ -void SeqDomain::addCreator(API::IDomainCreator_sptr creator) { +void SeqDomain::addCreator(const API::IDomainCreator_sptr &creator) { m_creators.emplace_back(creator); m_domain.emplace_back(API::FunctionDomain_sptr()); m_values.emplace_back(API::FunctionValues_sptr()); diff --git a/Framework/CurveFitting/src/SeqDomainSpectrumCreator.cpp b/Framework/CurveFitting/src/SeqDomainSpectrumCreator.cpp index ba7674dd923ca5712bb74c48df7f9ea164ce7437..e93e0e1bd1a92aa83838a408356b50abe15ecced 100644 --- a/Framework/CurveFitting/src/SeqDomainSpectrumCreator.cpp +++ b/Framework/CurveFitting/src/SeqDomainSpectrumCreator.cpp @@ -208,7 +208,7 @@ void SeqDomainSpectrumCreator::setParametersFromPropertyManager() { /// Sets the MatrixWorkspace the created domain is based on. void SeqDomainSpectrumCreator::setMatrixWorkspace( - MatrixWorkspace_sptr matrixWorkspace) { + const MatrixWorkspace_sptr &matrixWorkspace) { if (!matrixWorkspace) { throw std::invalid_argument( "InputWorkspace must be a valid MatrixWorkspace."); diff --git a/Framework/CurveFitting/src/TableWorkspaceDomainCreator.cpp b/Framework/CurveFitting/src/TableWorkspaceDomainCreator.cpp index 566167061b75800fc3126c25ee09be20b077eb20..d419d2f76fb3f202187b11daea4bc157e71dd84a 100644 --- a/Framework/CurveFitting/src/TableWorkspaceDomainCreator.cpp +++ b/Framework/CurveFitting/src/TableWorkspaceDomainCreator.cpp @@ -174,8 +174,6 @@ void TableWorkspaceDomainCreator::declareDatasetProperties( "(default the highest value of x)"); if (m_domainType != Simple && !m_manager->existsProperty(m_maxSizePropertyName)) { - auto mustBePositive = boost::make_shared<BoundedValidator<int>>(); - mustBePositive->setLower(0); declareProperty( new PropertyWithValue<int>(m_maxSizePropertyName, 1, mustBePositive), "The maximum number of values per a simple domain."); @@ -463,7 +461,7 @@ void TableWorkspaceDomainCreator::addFunctionValuesToWS( const API::IFunction_sptr &function, boost::shared_ptr<API::MatrixWorkspace> &ws, const size_t wsIndex, const boost::shared_ptr<API::FunctionDomain> &domain, - boost::shared_ptr<API::FunctionValues> resultValues) const { + const boost::shared_ptr<API::FunctionValues> &resultValues) const { const size_t nData = resultValues->size(); resultValues->zeroCalculated(); @@ -728,7 +726,7 @@ void TableWorkspaceDomainCreator::setParameters() const { */ void TableWorkspaceDomainCreator::setXYEColumnNames( - API::ITableWorkspace_sptr ws) const { + const API::ITableWorkspace_sptr &ws) const { auto columnNames = ws->getColumnNames(); @@ -784,7 +782,7 @@ void TableWorkspaceDomainCreator::setXYEColumnNames( * entries. */ void TableWorkspaceDomainCreator::setAndValidateWorkspace( - API::Workspace_sptr ws) const { + const API::Workspace_sptr &ws) const { auto tableWorkspace = boost::dynamic_pointer_cast<API::ITableWorkspace>(ws); if (!tableWorkspace) { throw std::invalid_argument("InputWorkspace must be a TableWorkspace."); diff --git a/Framework/CurveFitting/test/Algorithms/ConvolutionFitSequentialTest.h b/Framework/CurveFitting/test/Algorithms/ConvolutionFitSequentialTest.h index 1ca7b820ddf4262227badf5fea5216f27a5699e5..eab6d230eaa657691c85d7d2dc2a1deacfe13448 100644 --- a/Framework/CurveFitting/test/Algorithms/ConvolutionFitSequentialTest.h +++ b/Framework/CurveFitting/test/Algorithms/ConvolutionFitSequentialTest.h @@ -328,8 +328,9 @@ public: return AnalysisDataService::Instance().retrieveWS<T>(name); } - MatrixWorkspace_sptr getMatrixWorkspace(WorkspaceGroup_const_sptr group, - std::size_t index) { + MatrixWorkspace_sptr + getMatrixWorkspace(const WorkspaceGroup_const_sptr &group, + std::size_t index) { return boost::dynamic_pointer_cast<MatrixWorkspace>(group->getItem(index)); } diff --git a/Framework/CurveFitting/test/Algorithms/FitPowderDiffPeaksTest.h b/Framework/CurveFitting/test/Algorithms/FitPowderDiffPeaksTest.h index dc71f9854a7068419ceae972090beaf758925eb5..5272a2ec933730c50354e7efaa8adfee00e4d381 100644 --- a/Framework/CurveFitting/test/Algorithms/FitPowderDiffPeaksTest.h +++ b/Framework/CurveFitting/test/Algorithms/FitPowderDiffPeaksTest.h @@ -32,7 +32,8 @@ namespace { //---------------------------------------------------------------------------------------------- /** Import data from a column data file by calling LoadAscii */ -void importDataFromColumnFile(string filename, string datawsname) { +void importDataFromColumnFile(const string &filename, + const string &datawsname) { // 1. Call LoadAscii DataHandling::LoadAscii2 loader; loader.initialize(); @@ -96,7 +97,7 @@ API::MatrixWorkspace_sptr createInputDataWorkspace(int option) { //---------------------------------------------------------------------------------------------- /** Create the Bragg peak parameters table for LaB6, PG3, Bank1 */ -void createLaB6PG3Bank1BraggPeaksTable(TableWorkspace_sptr tablews) { +void createLaB6PG3Bank1BraggPeaksTable(const TableWorkspace_sptr &tablews) { TableRow newrow0 = tablews->appendRow(); newrow0 << 6 << 3 << 1 << .6129000 << 13962.47 << 0.20687 << 0.10063 << 62.64174 << 0.00000; @@ -266,7 +267,7 @@ DataObjects::TableWorkspace_sptr createReflectionWorkspace(int option) { //---------------------------------------------------------------------------------------------- /** Add rows for input table workspace for PG3 bank1 */ -void createPG3Bank1ParameterTable(TableWorkspace_sptr tablews) { +void createPG3Bank1ParameterTable(const TableWorkspace_sptr &tablews) { TableRow newrow0 = tablews->appendRow(); newrow0 << "Alph0" << 2.708; TableRow newrow1 = tablews->appendRow(); diff --git a/Framework/CurveFitting/test/Algorithms/FitTest.h b/Framework/CurveFitting/test/Algorithms/FitTest.h index e0b16441c01ce1ca18cbb2fc6a29a384300ea5c8..48a3e74d71ce679d4ce7e2cc324b71070baebfcb 100644 --- a/Framework/CurveFitting/test/Algorithms/FitTest.h +++ b/Framework/CurveFitting/test/Algorithms/FitTest.h @@ -1029,7 +1029,6 @@ public: TS_ASSERT(alg2.isInitialized()); // create mock data to test against - const std::string wsName = "ExpDecayMockData"; const int histogramNumber = 1; const int timechannels = 20; Workspace_sptr ws = WorkspaceFactory::Instance().create( diff --git a/Framework/CurveFitting/test/Algorithms/FitTestHelpers.h b/Framework/CurveFitting/test/Algorithms/FitTestHelpers.h index 50624ce827dd18593f9bfb43f259f84324ce8cea..e1c8c657f7ee5d3054914a1d6c7c16224bcc4bf1 100644 --- a/Framework/CurveFitting/test/Algorithms/FitTestHelpers.h +++ b/Framework/CurveFitting/test/Algorithms/FitTestHelpers.h @@ -26,8 +26,8 @@ static API::MatrixWorkspace_sptr generateSmoothCurveWorkspace(); /// Run fit on a (single spectrum) matrix workspace, using the given type /// of function and minimizer option static Mantid::API::IAlgorithm_sptr -runFitAlgorithm(MatrixWorkspace_sptr dataToFit, CurveBenchmarks ctype, - const std::string minimizer = "Levenberg-MarquardtMD") { +runFitAlgorithm(const MatrixWorkspace_sptr &dataToFit, CurveBenchmarks ctype, + const std::string &minimizer = "Levenberg-MarquardtMD") { auto fit = AlgorithmManager::Instance().create("Fit"); fit->initialize(); diff --git a/Framework/CurveFitting/test/Algorithms/LeBailFitTest.h b/Framework/CurveFitting/test/Algorithms/LeBailFitTest.h index b9ce6ac8ca8c0683181f3c72aacb78352c2e401f..b43f134bd99af16ab150437afcc38ca9e24d8cd2 100644 --- a/Framework/CurveFitting/test/Algorithms/LeBailFitTest.h +++ b/Framework/CurveFitting/test/Algorithms/LeBailFitTest.h @@ -424,46 +424,6 @@ API::MatrixWorkspace_sptr generateArgSiPeak220() { return dataws; } -//---------------------------------------------------------------------------------------------- -/** Import data from a column data file - */ -void importDataFromColumnFile(std::string filename, std::string wsname) { - DataHandling::LoadAscii2 load; - load.initialize(); - - load.setProperty("FileName", filename); - load.setProperty("OutputWorkspace", wsname); - load.setProperty("Separator", "Automatic"); - load.setProperty("Unit", "TOF"); - - load.execute(); - if (!load.isExecuted()) { - stringstream errss; - errss << "Data file " << filename << " cannot be opened. "; - std::cout << errss.str() << '\n'; - throw std::runtime_error(errss.str()); - } - - MatrixWorkspace_sptr ws = boost::dynamic_pointer_cast<MatrixWorkspace>( - AnalysisDataService::Instance().retrieve(wsname)); - if (!ws) { - stringstream errss; - errss << "LoadAscii failed to generate workspace"; - std::cout << errss.str() << '\n'; - throw std::runtime_error(errss.str()); - } - - // Set error - const MantidVec &vecY = ws->readY(0); - MantidVec &vecE = ws->dataE(0); - size_t numpts = vecY.size(); - for (size_t i = 0; i < numpts; ++i) { - vecE[i] = std::max(1.0, sqrt(vecY[i])); - } - - return; -} - //---------------------------------------------------------------------------------------------- /** Create data workspace without background */ @@ -499,17 +459,9 @@ API::MatrixWorkspace_sptr createInputDataWorkspace(int option) { break; } - } else if (option == 4) { + } else { // Load from column file throw runtime_error("Using .dat file is not allowed for committing. "); - string datafilename("PG3_4862_Bank7.dat"); - string wsname("Data"); - importDataFromColumnFile(datafilename, wsname); - dataws = boost::dynamic_pointer_cast<MatrixWorkspace>( - AnalysisDataService::Instance().retrieve(wsname)); - } else { - // not supported - throw std::invalid_argument("Logic error. "); } return dataws; @@ -1295,7 +1247,7 @@ public: * Parse parameter table workspace to 2 map */ void - parseParameterTableWorkspace(DataObjects::TableWorkspace_sptr paramws, + parseParameterTableWorkspace(const DataObjects::TableWorkspace_sptr ¶mws, std::map<std::string, double> ¶mvalues, std::map<std::string, char> ¶mfitstatus) { diff --git a/Framework/CurveFitting/test/Algorithms/LeBailFunctionTest.h b/Framework/CurveFitting/test/Algorithms/LeBailFunctionTest.h index 2529fbea830587d7d99fbcda036d880ce84ba612..b8b8ab8d8a392ef556ec797d1e665d4de0a639d8 100644 --- a/Framework/CurveFitting/test/Algorithms/LeBailFunctionTest.h +++ b/Framework/CurveFitting/test/Algorithms/LeBailFunctionTest.h @@ -216,7 +216,7 @@ public: << imax111 << "-th points.\n"; // Calculate diffraction patters - auto out = lebailfunction.function(vecX, true, false); + lebailfunction.function(vecX, true, false); TS_ASSERT_THROWS_ANYTHING(lebailfunction.function(vecX, true, true)); vector<string> vecbkgdparnames(2); @@ -228,7 +228,7 @@ public: lebailfunction.addBackgroundFunction("Polynomial", 2, vecbkgdparnames, bkgdvec, vecX.front(), vecX.back()); - out = lebailfunction.function(vecX, true, true); + auto out = lebailfunction.function(vecX, true, true); double v1 = out[imax111]; double v2 = out[imax110]; @@ -428,7 +428,8 @@ public: return ws; } - void importDataFromColumnFile(std::string filename, std::vector<double> &vecX, + void importDataFromColumnFile(const std::string &filename, + std::vector<double> &vecX, std::vector<double> &vecY, std::vector<double> &vecE) { std::ifstream ins; @@ -440,7 +441,6 @@ public: if (line[0] != '#') { double x, y; std::stringstream ss; - std::string dataline(line); ss.str(line); ss >> x >> y; vecX.emplace_back(x); diff --git a/Framework/CurveFitting/test/Algorithms/PlotPeakByLogValueTest.h b/Framework/CurveFitting/test/Algorithms/PlotPeakByLogValueTest.h index 97aada54a131dd93a517d0ddf38e61a19c82c736..5376a94005d77960d582dfee9c40685925a068fa 100644 --- a/Framework/CurveFitting/test/Algorithms/PlotPeakByLogValueTest.h +++ b/Framework/CurveFitting/test/Algorithms/PlotPeakByLogValueTest.h @@ -29,6 +29,7 @@ #include "MantidTestHelpers/WorkspaceCreationHelper.h" #include <algorithm> #include <sstream> +#include <utility> using namespace Mantid; using namespace Mantid::API; @@ -67,9 +68,9 @@ DECLARE_FUNCTION(PLOTPEAKBYLOGVALUETEST_Fun) class PropertyNameIs { public: - PropertyNameIs(std::string name) : m_name(name){}; + PropertyNameIs(std::string name) : m_name(std::move(name)){}; - bool operator()(Mantid::Kernel::PropertyHistory_sptr p) { + bool operator()(const Mantid::Kernel::PropertyHistory_sptr &p) { return p->name() == m_name; } @@ -624,8 +625,6 @@ private: ws->setSharedX(1, ws->sharedX(0)); ws->setSharedX(2, ws->sharedX(0)); - std::vector<double> amps{20.0, 30.0, 25.0}; - std::vector<double> cents{0.0, 0.1, -1.0}; std::vector<double> fwhms{1.0, 1.1, 0.6}; for (size_t i = 0; i < 3; ++i) { std::string fun = "name=FlatBackground,A0=" + std::to_string(fwhms[i]); diff --git a/Framework/CurveFitting/test/Algorithms/QENSFitSequentialTest.h b/Framework/CurveFitting/test/Algorithms/QENSFitSequentialTest.h index ab36a4758d4107057bdfa60df56f86984954f2bf..b2361e2145b0842a902cde68bd98b59a85394d5b 100644 --- a/Framework/CurveFitting/test/Algorithms/QENSFitSequentialTest.h +++ b/Framework/CurveFitting/test/Algorithms/QENSFitSequentialTest.h @@ -79,8 +79,8 @@ public: } private: - std::string runConvolutionFit(MatrixWorkspace_sptr inputWorkspace, - MatrixWorkspace_sptr resolution) { + std::string runConvolutionFit(const MatrixWorkspace_sptr &inputWorkspace, + const MatrixWorkspace_sptr &resolution) { QENSFitSequential alg; TS_ASSERT_THROWS_NOTHING(alg.initialize()); @@ -207,7 +207,7 @@ private: return resolution; } - void addBinsAndCountsToWorkspace(Workspace2D_sptr workspace, + void addBinsAndCountsToWorkspace(const Workspace2D_sptr &workspace, std::size_t totalBinEdges, std::size_t totalCounts, double binValue, double countValue) const { diff --git a/Framework/CurveFitting/test/Algorithms/QENSFitSimultaneousTest.h b/Framework/CurveFitting/test/Algorithms/QENSFitSimultaneousTest.h index 1974772d73faf83d9a8b5cd6649e55409a2e2894..bb53acfbbe53e89e0575d388cf89d72e1e9f1583 100644 --- a/Framework/CurveFitting/test/Algorithms/QENSFitSimultaneousTest.h +++ b/Framework/CurveFitting/test/Algorithms/QENSFitSimultaneousTest.h @@ -8,6 +8,8 @@ #include <cxxtest/TestSuite.h> +#include <utility> + #include "MantidAPI/Axis.h" #include "MantidAPI/FrameworkManager.h" #include "MantidAPI/FunctionFactory.h" @@ -84,8 +86,8 @@ public: } private: - std::string runConvolutionFit(MatrixWorkspace_sptr inputWorkspace, - MatrixWorkspace_sptr resolution) { + std::string runConvolutionFit(const MatrixWorkspace_sptr &inputWorkspace, + const MatrixWorkspace_sptr &resolution) { QENSFitSimultaneous alg; TS_ASSERT_THROWS_NOTHING(alg.initialize()); @@ -107,12 +109,12 @@ private: std::string runMultiDatasetFit( const std::vector<Mantid::API::MatrixWorkspace_sptr> &workspaces, - IFunction_sptr function) { + const IFunction_sptr &function) { QENSFitSimultaneous alg; TS_ASSERT_THROWS_NOTHING(alg.initialize()); - alg.setProperty("Function", - createMultiDomainFunction(function, workspaces.size())); + alg.setProperty("Function", createMultiDomainFunction(std::move(function), + workspaces.size())); setMultipleInput(alg, workspaces, 0.0, 10.0); alg.setProperty("ConvolveMembers", true); alg.setProperty("Minimizer", "Levenberg-Marquardt"); @@ -197,7 +199,7 @@ private: return resolution; } - void addBinsAndCountsToWorkspace(Workspace2D_sptr workspace, + void addBinsAndCountsToWorkspace(const Workspace2D_sptr &workspace, std::size_t totalBinEdges, std::size_t totalCounts, double binValue, double countValue) const { @@ -232,7 +234,7 @@ private: } } - IFunction_sptr createMultiDomainFunction(IFunction_sptr function, + IFunction_sptr createMultiDomainFunction(const IFunction_sptr &function, std::size_t numberOfDomains) { auto multiDomainFunction = boost::make_shared<MultiDomainFunction>(); diff --git a/Framework/CurveFitting/test/Algorithms/RefinePowderInstrumentParameters3Test.h b/Framework/CurveFitting/test/Algorithms/RefinePowderInstrumentParameters3Test.h index cb863647b2fff387c1faa4f47a0dce2ded890d96..c7f8debc5a0f9b21f80fa5ba2848479d8e18e7a2 100644 --- a/Framework/CurveFitting/test/Algorithms/RefinePowderInstrumentParameters3Test.h +++ b/Framework/CurveFitting/test/Algorithms/RefinePowderInstrumentParameters3Test.h @@ -117,7 +117,7 @@ TableWorkspace_sptr generateInstrumentProfileTableBank1() { //---------------------------------------------------------------------------------------------- /** Parse Table Workspace to a map of string, double pair */ -void parseParameterTableWorkspace(TableWorkspace_sptr paramws, +void parseParameterTableWorkspace(const TableWorkspace_sptr ¶mws, map<string, double> ¶mvalues) { for (size_t irow = 0; irow < paramws->rowCount(); ++irow) { Mantid::API::TableRow row = paramws->getRow(irow); diff --git a/Framework/CurveFitting/test/Algorithms/RefinePowderInstrumentParametersTest.h b/Framework/CurveFitting/test/Algorithms/RefinePowderInstrumentParametersTest.h index fdfffc3524ed304763e8428f1fddb3c3d2dc3a12..487a1b787c4d1637629e03648415c6916b6081b4 100644 --- a/Framework/CurveFitting/test/Algorithms/RefinePowderInstrumentParametersTest.h +++ b/Framework/CurveFitting/test/Algorithms/RefinePowderInstrumentParametersTest.h @@ -327,7 +327,7 @@ public: * BETA, ... */ void - importPeakParametersFile(std::string filename, + importPeakParametersFile(const std::string &filename, std::vector<std::vector<int>> &hkls, std::vector<std::vector<double>> &peakparameters) { // 1. Open file @@ -441,7 +441,7 @@ public: * Input: a text based file * Output: a map for (parameter name, parameter value) */ - void importInstrumentTxtFile(std::string filename, + void importInstrumentTxtFile(const std::string &filename, std::map<std::string, double> ¶meters, std::map<string, vector<double>> ¶metermcs) { // 1. Open file @@ -462,14 +462,14 @@ public: while (ins.getline(line, 256)) { if (line[0] != '#') { std::string parname; - double parvalue, parmin, parmax, parstepsize; - + double parvalue; std::stringstream ss; ss.str(line); ss >> parname >> parvalue; parameters.emplace(parname, parvalue); try { + double parmin, parmax, parstepsize; ss >> parmin >> parmax >> parstepsize; vector<double> mcpars; mcpars.emplace_back(parmin); @@ -488,9 +488,9 @@ public: } /// ================= Check Output ================ /// - void - parseParameterTableWorkspace(Mantid::DataObjects::TableWorkspace_sptr paramws, - std::map<std::string, double> ¶mvalues) { + void parseParameterTableWorkspace( + const Mantid::DataObjects::TableWorkspace_sptr ¶mws, + std::map<std::string, double> ¶mvalues) { for (size_t irow = 0; irow < paramws->rowCount(); ++irow) { Mantid::API::TableRow row = paramws->getRow(irow); diff --git a/Framework/CurveFitting/test/FitMWTest.h b/Framework/CurveFitting/test/FitMWTest.h index b4c0ff6af9e7148b97dead62a86f68932a760ea6..7e170fb5a74d035901b9797dd0ccb050eb719ed6 100644 --- a/Framework/CurveFitting/test/FitMWTest.h +++ b/Framework/CurveFitting/test/FitMWTest.h @@ -63,7 +63,7 @@ API::MatrixWorkspace_sptr createTestWorkspace(const bool histogram, return ws2; } -void doTestExecPointData(API::MatrixWorkspace_sptr ws2, +void doTestExecPointData(const API::MatrixWorkspace_sptr &ws2, bool performance = false) { API::IFunction_sptr fun(new ExpDecay); fun->setParameter("Height", 1.); @@ -169,7 +169,7 @@ void doTestExecPointData(API::MatrixWorkspace_sptr ws2, TS_ASSERT_DELTA(fun->getParameter("Lifetime"), 1.0, 1e-4); } } -void doTestExecHistogramData(API::MatrixWorkspace_sptr ws2, +void doTestExecHistogramData(const API::MatrixWorkspace_sptr &ws2, bool performance = false) { API::IFunction_sptr fun(new ExpDecay); fun->setParameter("Height", 1.); @@ -497,8 +497,6 @@ public: test_Composite_Function_With_SeparateMembers_Option_On_FitMW_Outputs_Composite_Values_Plus_Each_Member() { const bool histogram = true; auto ws2 = createTestWorkspace(histogram); - const std::string inputWSName = "FitMWTest_CompositeTest"; - // AnalysisDataService::Instance().add(inputWSName, ws2); auto composite = boost::make_shared<API::CompositeFunction>(); API::IFunction_sptr expDecay(new ExpDecay); diff --git a/Framework/CurveFitting/test/FuncMinimizers/FABADAMinimizerTest.h b/Framework/CurveFitting/test/FuncMinimizers/FABADAMinimizerTest.h index 34b24d12fd5a644940986cc5d08ea932d611abf6..75543a266a9714190e91c26739fd97eba152e9ae 100644 --- a/Framework/CurveFitting/test/FuncMinimizers/FABADAMinimizerTest.h +++ b/Framework/CurveFitting/test/FuncMinimizers/FABADAMinimizerTest.h @@ -46,7 +46,7 @@ MatrixWorkspace_sptr createTestWorkspace(size_t NVectors = 2, return ws2; } -void doTestExpDecay(MatrixWorkspace_sptr ws2) { +void doTestExpDecay(const MatrixWorkspace_sptr &ws2) { Mantid::API::IFunction_sptr fun(new ExpDecay); fun->setParameter("Height", 8.); diff --git a/Framework/CurveFitting/test/FuncMinimizers/LevenbergMarquardtMDTest.h b/Framework/CurveFitting/test/FuncMinimizers/LevenbergMarquardtMDTest.h index feef3b422ef9baedd3dc5ad4057593ea6e390eb0..32e6baf1132f497965762f302a5734c5bac787c5 100644 --- a/Framework/CurveFitting/test/FuncMinimizers/LevenbergMarquardtMDTest.h +++ b/Framework/CurveFitting/test/FuncMinimizers/LevenbergMarquardtMDTest.h @@ -468,7 +468,8 @@ public: } private: - double fitBSpline(boost::shared_ptr<IFunction> bsp, std::string func) { + double fitBSpline(const boost::shared_ptr<IFunction> &bsp, + const std::string &func) { const double startx = bsp->getAttribute("StartX").asDouble(); const double endx = bsp->getAttribute("EndX").asDouble(); diff --git a/Framework/CurveFitting/test/Functions/ChebfunBaseTest.h b/Framework/CurveFitting/test/Functions/ChebfunBaseTest.h index ec23cc49c22307b29720ffa79bcb5739e6fb504b..5552bf2677df3bf6f5809ce1b0e627827a49b81b 100644 --- a/Framework/CurveFitting/test/Functions/ChebfunBaseTest.h +++ b/Framework/CurveFitting/test/Functions/ChebfunBaseTest.h @@ -10,6 +10,7 @@ #include "MantidCurveFitting/Functions/ChebfunBase.h" #include <cmath> +#include <utility> using namespace Mantid; using namespace Mantid::API; @@ -115,8 +116,8 @@ public: void test_roots_SinCos() { do_test_roots(SinCos, -M_PI, M_PI, 2, 1e-5); } private: - void do_test_eval(std::function<double(double)> fun, double start, double end, - size_t n) { + void do_test_eval(const std::function<double(double)> &fun, double start, + double end, size_t n) { ChebfunBase base(n, start, end); auto p = base.fit(fun); auto x = base.linspace(2 * n); @@ -132,7 +133,7 @@ private: x.assign(xarr, xarr + narr); ChebfunBase base(n, start, end); - auto p = base.fit(fun); + auto p = base.fit(std::move(fun)); auto y = base.evalVector(x, p); TS_ASSERT_EQUALS(y.size(), x.size()); for (size_t i = 0; i < x.size(); ++i) { @@ -147,7 +148,7 @@ private: } } - void do_test_bestFit(std::function<double(double)> fun, double start, + void do_test_bestFit(const std::function<double(double)> &fun, double start, double end, size_t expected_n) { std::vector<double> p, a; auto base = ChebfunBase::bestFit(start, end, fun, p, a); @@ -161,14 +162,15 @@ private: void do_test_integrate(std::function<double(double)> fun, double start, double end, double expected_integral) { std::vector<double> p, a; - auto base = ChebfunBase::bestFit(start, end, fun, p, a); + auto base = ChebfunBase::bestFit(start, end, std::move(fun), p, a); TS_ASSERT_DELTA(base->integrate(p), expected_integral, 1e-14); } void do_test_derivative(std::function<double(double)> fun, double start, - double end, std::function<double(double)> deriv) { + double end, + const std::function<double(double)> &deriv) { std::vector<double> p, a, dp, da; - auto base = ChebfunBase::bestFit(start, end, fun, p, a); + auto base = ChebfunBase::bestFit(start, end, std::move(fun), p, a); base->derivative(a, da); dp = base->calcP(da); auto x = base->linspace(2 * base->size()); @@ -181,7 +183,7 @@ private: void do_test_roots(std::function<double(double)> fun, double start, double end, size_t n_roots, double tol = 1e-13) { std::vector<double> p, a; - auto base = ChebfunBase::bestFit(start, end, fun, p, a); + auto base = ChebfunBase::bestFit(start, end, std::move(fun), p, a); auto roots = base->roots(a); TS_ASSERT_EQUALS(n_roots, roots.size()); for (double root : roots) { diff --git a/Framework/CurveFitting/test/Functions/ComptonPeakProfileTest.h b/Framework/CurveFitting/test/Functions/ComptonPeakProfileTest.h index 04247920fe6b37a572a9c2f9ad9f5c9c9340d5d9..26dde36728e84ed9d9850b243b84898b2b6107a6 100644 --- a/Framework/CurveFitting/test/Functions/ComptonPeakProfileTest.h +++ b/Framework/CurveFitting/test/Functions/ComptonPeakProfileTest.h @@ -31,13 +31,13 @@ public: void test_initialized_object_has_expected_attributes() { auto profile = createFunction(); static const size_t nattrs(3); - const char *expectedAttrs[nattrs] = {"WorkspaceIndex", "Mass", - "VoigtEnergyCutOff"}; TS_ASSERT_EQUALS(nattrs, profile->nAttributes()); // Test names as they are used in scripts if (profile->nAttributes() > 0) { + const char *expectedAttrs[nattrs] = {"WorkspaceIndex", "Mass", + "VoigtEnergyCutOff"}; std::unordered_set<std::string> expectedAttrSet(expectedAttrs, expectedAttrs + nattrs); std::vector<std::string> actualNames = profile->getAttributeNames(); diff --git a/Framework/CurveFitting/test/Functions/ComptonProfileTest.h b/Framework/CurveFitting/test/Functions/ComptonProfileTest.h index 2e4458bacbd7f6eb1edb2fe850e1d6a3b62a9637..cadb3838c6a86b4a9e095993dffaa2a7b2928dc2 100644 --- a/Framework/CurveFitting/test/Functions/ComptonProfileTest.h +++ b/Framework/CurveFitting/test/Functions/ComptonProfileTest.h @@ -30,12 +30,12 @@ public: void test_initialized_object_has_expected_parameters() { auto profile = createFunction(); static const size_t nparams(1); - const char *expectedParams[nparams] = {"Mass"}; TS_ASSERT_EQUALS(nparams, profile->nParams()); // Test names as they are used in scripts if (profile->nParams() > 0) { + const char *expectedParams[nparams] = {"Mass"}; std::unordered_set<std::string> expectedParamStr( expectedParams, expectedParams + nparams); std::vector<std::string> actualNames = profile->getParameterNames(); diff --git a/Framework/CurveFitting/test/Functions/ConvolutionTest.h b/Framework/CurveFitting/test/Functions/ConvolutionTest.h index a3c0ecac4f951103b1c209eae9059900eefd60b9..22e235d588f81cf1fd7be2a2f4d06e0fcc4e49a6 100644 --- a/Framework/CurveFitting/test/Functions/ConvolutionTest.h +++ b/Framework/CurveFitting/test/Functions/ConvolutionTest.h @@ -180,8 +180,7 @@ public: linear->setParameter(0, 0.1); linear->setParameter(1, 0.2); - size_t iFun = 10000; - iFun = conv.addFunction(linear); + size_t iFun = conv.addFunction(linear); TS_ASSERT_EQUALS(iFun, 0); iFun = conv.addFunction(gauss1); TS_ASSERT_EQUALS(iFun, 1); diff --git a/Framework/CurveFitting/test/Functions/GaussianComptonProfileTest.h b/Framework/CurveFitting/test/Functions/GaussianComptonProfileTest.h index c3e722502b5f1f03591bd802095a473346a0f5be..805d3b956f9de8bcf9a2b5decdd4b12d7323ebe1 100644 --- a/Framework/CurveFitting/test/Functions/GaussianComptonProfileTest.h +++ b/Framework/CurveFitting/test/Functions/GaussianComptonProfileTest.h @@ -33,12 +33,13 @@ public: void test_Initialized_Function_Has_Expected_Parameters_In_Right_Order() { Mantid::API::IFunction_sptr profile = createFunction(); static const size_t nparams(3); - const char *expectedParams[nparams] = {"Mass", "Width", "Intensity"}; auto currentNames = profile->getParameterNames(); const size_t nnames = currentNames.size(); TS_ASSERT_EQUALS(nparams, nnames); + if (nnames == nparams) { + const char *expectedParams[nparams] = {"Mass", "Width", "Intensity"}; for (size_t i = 0; i < nnames; ++i) { TS_ASSERT_EQUALS(expectedParams[i], currentNames[i]); } diff --git a/Framework/CurveFitting/test/Functions/GramCharlierComptonProfileTest.h b/Framework/CurveFitting/test/Functions/GramCharlierComptonProfileTest.h index 1ca51c7a7ca236916e227fb1d504da9f6c11a866..5a03d55af9c25b45b38d3cd347728896fa03826e 100644 --- a/Framework/CurveFitting/test/Functions/GramCharlierComptonProfileTest.h +++ b/Framework/CurveFitting/test/Functions/GramCharlierComptonProfileTest.h @@ -152,12 +152,12 @@ private: void checkDefaultParametersExist(const Mantid::API::IFunction &profile) { static const size_t nparams(3); - const char *expectedParams[nparams] = {"Mass", "Width", "FSECoeff"}; auto currentNames = profile.getParameterNames(); const size_t nnames = currentNames.size(); TS_ASSERT_LESS_THAN_EQUALS(nparams, nnames); if (nnames <= nparams) { + const char *expectedParams[nparams] = {"Mass", "Width", "FSECoeff"}; for (size_t i = 0; i < nnames; ++i) { TS_ASSERT_EQUALS(expectedParams[i], currentNames[i]); } diff --git a/Framework/CurveFitting/test/Functions/MultivariateGaussianComptonProfileTest.h b/Framework/CurveFitting/test/Functions/MultivariateGaussianComptonProfileTest.h index 6a05454222ed3e6066dab20e16dd2d59e51531cb..aa73d35207f35a8368c210c8585e6094da5efeb4 100644 --- a/Framework/CurveFitting/test/Functions/MultivariateGaussianComptonProfileTest.h +++ b/Framework/CurveFitting/test/Functions/MultivariateGaussianComptonProfileTest.h @@ -33,12 +33,12 @@ public: void test_Initialized_Function_Has_Expected_Parameters_In_Right_Order() { Mantid::API::IFunction_sptr profile = createFunction(); static const size_t nparams(5); - const char *expectedParams[nparams] = {"Mass", "Intensity", "SigmaX", - "SigmaY", "SigmaZ"}; auto currentNames = profile->getParameterNames(); const size_t nnames = currentNames.size(); TS_ASSERT_EQUALS(nparams, nnames); if (nnames == nparams) { + const char *expectedParams[nparams] = {"Mass", "Intensity", "SigmaX", + "SigmaY", "SigmaZ"}; for (size_t i = 0; i < nnames; ++i) { TS_ASSERT_EQUALS(expectedParams[i], currentNames[i]); } @@ -48,12 +48,12 @@ public: void test_Initialized_Function_Has_Expected_Attributes() { Mantid::API::IFunction_sptr profile = createFunction(); static const size_t nattrs(1); - const char *expectedAttrs[nattrs] = {"IntegrationSteps"}; TS_ASSERT_EQUALS(nattrs, profile->nAttributes()); // Test names as they are used in scripts if (profile->nAttributes() > 0) { + const char *expectedAttrs[nattrs] = {"IntegrationSteps"}; std::set<std::string> expectedAttrSet(expectedAttrs, expectedAttrs + nattrs); std::vector<std::string> actualNames = profile->getAttributeNames(); diff --git a/Framework/CurveFitting/test/Functions/ProcessBackgroundTest.h b/Framework/CurveFitting/test/Functions/ProcessBackgroundTest.h index 3811aa907ade7f87d51ca12833d7fba2f697b79d..9c5dc429d06d0dd7a6b6e4982f3171a8c4d6604b 100644 --- a/Framework/CurveFitting/test/Functions/ProcessBackgroundTest.h +++ b/Framework/CurveFitting/test/Functions/ProcessBackgroundTest.h @@ -17,6 +17,7 @@ #include "MantidKernel/MersenneTwister.h" #include <fstream> +#include <utility> using Mantid::CurveFitting::Functions::ProcessBackground; using namespace Mantid; @@ -26,7 +27,8 @@ using namespace Mantid::DataObjects; using namespace HistogramData; namespace { -Workspace2D_sptr createInputWS(std::string name, size_t sizex, size_t sizey) { +Workspace2D_sptr createInputWS(const std::string &name, size_t sizex, + size_t sizey) { Workspace2D_sptr inputWS = boost::dynamic_pointer_cast<Workspace2D>( WorkspaceFactory::Instance().create("Workspace2D", 1, sizex, sizey)); AnalysisDataService::Instance().addOrReplace(name, inputWS); @@ -294,9 +296,9 @@ public: //---------------------------------------------------------------------------------------------- /** Read column file to create a workspace2D */ - Workspace2D_sptr createWorkspace2D(std::string filename) { + Workspace2D_sptr createWorkspace2D(const std::string &filename) { // 1. Read data - auto data = importDataFromColumnFile(filename); + auto data = importDataFromColumnFile(std::move(filename)); // 2. Create workspace size_t datasize = data.x().size(); @@ -314,7 +316,7 @@ public: /** Import data from a column data file */ - Histogram importDataFromColumnFile(std::string filename) { + Histogram importDataFromColumnFile(const std::string &filename) { // 1. Open file std::ifstream ins; ins.open(filename.c_str()); diff --git a/Framework/CurveFitting/test/Functions/ProductFunctionTest.h b/Framework/CurveFitting/test/Functions/ProductFunctionTest.h index b6c4459276e2b73dd2ea4cdd03d16eb79474b8d7..8596d48dad3f5b078384f26a78c6af78bf8d393e 100644 --- a/Framework/CurveFitting/test/Functions/ProductFunctionTest.h +++ b/Framework/CurveFitting/test/Functions/ProductFunctionTest.h @@ -116,8 +116,7 @@ public: linear->setParameter(0, 0.1); linear->setParameter(1, 0.2); - size_t iFun = 100000; - iFun = prodF.addFunction(linear); + size_t iFun = prodF.addFunction(linear); TS_ASSERT_EQUALS(iFun, 0); iFun = prodF.addFunction(gauss1); TS_ASSERT_EQUALS(iFun, 1); diff --git a/Framework/CurveFitting/test/Functions/SimpleChebfunTest.h b/Framework/CurveFitting/test/Functions/SimpleChebfunTest.h index 6faf11ee57fa7479da7ae12db9137d48a03036ca..fec05d704cb2b5a6f4a7bc53e2c5fab46171025d 100644 --- a/Framework/CurveFitting/test/Functions/SimpleChebfunTest.h +++ b/Framework/CurveFitting/test/Functions/SimpleChebfunTest.h @@ -221,8 +221,8 @@ public: private: void do_test_values(const SimpleChebfun &cheb, - std::function<double(double)> fun, double accur1 = 1e-14, - double accur2 = 1e-14) { + const std::function<double(double)> &fun, + double accur1 = 1e-14, double accur2 = 1e-14) { TS_ASSERT(cheb.size() > 0); TS_ASSERT(cheb.width() > 0.0); if (cheb.isGood()) { diff --git a/Framework/CurveFitting/test/HistogramDomainCreatorTest.h b/Framework/CurveFitting/test/HistogramDomainCreatorTest.h index 75853f8cee7ca5357216c09f9430b9018cc6a256..a09450e0550a6e90852599ec757b5fc0d4a493af 100644 --- a/Framework/CurveFitting/test/HistogramDomainCreatorTest.h +++ b/Framework/CurveFitting/test/HistogramDomainCreatorTest.h @@ -463,8 +463,9 @@ private: return ws2; } - MatrixWorkspace_sptr createFitWorkspace(const size_t ny, - std::function<double(double)> fun) { + MatrixWorkspace_sptr + createFitWorkspace(const size_t ny, + const std::function<double(double)> &fun) { MatrixWorkspace_sptr ws(new WorkspaceTester); size_t nx = ny + 1; double x0 = -1.0; diff --git a/Framework/CurveFitting/test/MultiDomainCreatorTest.h b/Framework/CurveFitting/test/MultiDomainCreatorTest.h index ef6499accc9173a80385643f4c1f8606a6cbdcb7..146991f53f43eaa89eb392b6f937c8a064bacf9a 100644 --- a/Framework/CurveFitting/test/MultiDomainCreatorTest.h +++ b/Framework/CurveFitting/test/MultiDomainCreatorTest.h @@ -302,7 +302,7 @@ public: } private: - void doTestOutputSpectrum(MatrixWorkspace_sptr ws, size_t index) { + void doTestOutputSpectrum(const MatrixWorkspace_sptr &ws, size_t index) { TS_ASSERT(ws); TS_ASSERT_EQUALS(ws->getNumberHistograms(), 3); auto &data = ws->readY(0); diff --git a/Framework/CurveFitting/test/TableWorkspaceDomainCreatorTest.h b/Framework/CurveFitting/test/TableWorkspaceDomainCreatorTest.h index 5cecdb61ba482f381a559d86834b135d02e77717..743bac005d50c13b182e8e049207ffb4e01d1394 100644 --- a/Framework/CurveFitting/test/TableWorkspaceDomainCreatorTest.h +++ b/Framework/CurveFitting/test/TableWorkspaceDomainCreatorTest.h @@ -770,8 +770,8 @@ private: } boost::shared_ptr<Fit> - setupBasicFitPropertiesAlgorithm(API::IFunction_sptr fun, - API::Workspace_sptr ws, + setupBasicFitPropertiesAlgorithm(const API::IFunction_sptr &fun, + const API::Workspace_sptr &ws, bool createOutput = true) { auto fit = boost::make_shared<Fit>(); fit->initialize(); diff --git a/Framework/DataHandling/inc/MantidDataHandling/AppendGeometryToSNSNexus.h b/Framework/DataHandling/inc/MantidDataHandling/AppendGeometryToSNSNexus.h index 918e89694bb78617d293a47138ea171957785619..971696c075357790711f54d7e5cdca4262d16f48 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/AppendGeometryToSNSNexus.h +++ b/Framework/DataHandling/inc/MantidDataHandling/AppendGeometryToSNSNexus.h @@ -49,12 +49,12 @@ private: /// Run LoadInstrument as a Child Algorithm bool runLoadInstrument(const std::string &idf_filename, - API::MatrixWorkspace_sptr localWorkspace, + const API::MatrixWorkspace_sptr &localWorkspace, Algorithm *alg); /// Load logs from the NeXus file static bool runLoadNexusLogs(const std::string &nexusFileName, - API::MatrixWorkspace_sptr localWorkspace, + const API::MatrixWorkspace_sptr &localWorkspace, Algorithm *alg); /// Are we going to make a copy of the NeXus file to operate on ? diff --git a/Framework/DataHandling/inc/MantidDataHandling/BankPulseTimes.h b/Framework/DataHandling/inc/MantidDataHandling/BankPulseTimes.h index 8cdc32656f8dd9f07990182dc3e9fc78e14c7dba..5edb30b89ebc93495d86522931ac795789434154 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/BankPulseTimes.h +++ b/Framework/DataHandling/inc/MantidDataHandling/BankPulseTimes.h @@ -32,7 +32,7 @@ public: ~BankPulseTimes(); /// Equals - bool equals(size_t otherNumPulse, std::string otherStartTime); + bool equals(size_t otherNumPulse, const std::string &otherStartTime); /// String describing the start time std::string startTime; diff --git a/Framework/DataHandling/inc/MantidDataHandling/CreateSimulationWorkspace.h b/Framework/DataHandling/inc/MantidDataHandling/CreateSimulationWorkspace.h index c8129c6e205948dee0cfb1d8d443b64701dca82e..e8d09ae03001d2fc5cd7686788788a343b8043d1 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/CreateSimulationWorkspace.h +++ b/Framework/DataHandling/inc/MantidDataHandling/CreateSimulationWorkspace.h @@ -54,7 +54,7 @@ private: /// Apply any instrument adjustments from the file void adjustInstrument(const std::string &filename); /// Set start date for dummy workspace - void setStartDate(API::MatrixWorkspace_sptr workspace); + void setStartDate(const API::MatrixWorkspace_sptr &workspace); /// Pointer to a progress object boost::shared_ptr<API::Progress> m_progress; diff --git a/Framework/DataHandling/inc/MantidDataHandling/DataBlockComposite.h b/Framework/DataHandling/inc/MantidDataHandling/DataBlockComposite.h index 41a791773fed785fd958164f5f1ede95b240c363..307d7b84caf8fbac1b4ac4071009b7dacb99fe13 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/DataBlockComposite.h +++ b/Framework/DataHandling/inc/MantidDataHandling/DataBlockComposite.h @@ -33,7 +33,7 @@ public: bool operator==(const DataBlockComposite &other) const; // DataBlockComposite only mehtods - void addDataBlock(DataBlock dataBlock); + void addDataBlock(const DataBlock &dataBlock); std::vector<DataBlock> getDataBlocks(); DataBlockComposite operator+(const DataBlockComposite &other); void removeSpectra(DataBlockComposite &toRemove); diff --git a/Framework/DataHandling/inc/MantidDataHandling/DetermineChunking.h b/Framework/DataHandling/inc/MantidDataHandling/DetermineChunking.h index 8dd99ed92b0a17139baa4d0d8bbd63ea2ee83925..5df1afc8758a885cd2641bdcdca2a96043b76509 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/DetermineChunking.h +++ b/Framework/DataHandling/inc/MantidDataHandling/DetermineChunking.h @@ -57,7 +57,7 @@ public: private: void init() override; void exec() override; - std::string setTopEntryName(std::string filename); + std::string setTopEntryName(const std::string &filename); FileType getFileType(const std::string &filename); }; diff --git a/Framework/DataHandling/inc/MantidDataHandling/EventWorkspaceCollection.h b/Framework/DataHandling/inc/MantidDataHandling/EventWorkspaceCollection.h index 6b0d8bebcebed593d62dd1457ae0ab13789452c5..7e2dcfc33bbd9857fe1f0d2091b3fc1b5d1595b5 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/EventWorkspaceCollection.h +++ b/Framework/DataHandling/inc/MantidDataHandling/EventWorkspaceCollection.h @@ -59,7 +59,7 @@ public: void setThickness(const float flag); void setHeight(const float flag); void setWidth(const float flag); - void setSpectrumNumbersFromUniqueSpectra(const std::set<int> uniqueSpectra); + void setSpectrumNumbersFromUniqueSpectra(const std::set<int> &uniqueSpectra); void setSpectrumNumberForAllPeriods(const size_t spectrumNumber, const specnum_t specid); void setDetectorIdsForAllPeriods(const size_t spectrumNumber, @@ -88,8 +88,9 @@ public: void setMonitorWorkspace(const boost::shared_ptr<API::MatrixWorkspace> &monitorWS); void updateSpectraUsing(const API::SpectrumDetectorMapping &map); - void setTitle(std::string title); - void applyFilter(boost::function<void(API::MatrixWorkspace_sptr)> func); + void setTitle(const std::string &title); + void + applyFilter(const boost::function<void(API::MatrixWorkspace_sptr)> &func); virtual bool threadSafe() const; }; diff --git a/Framework/DataHandling/inc/MantidDataHandling/FilterEventsByLogValuePreNexus.h b/Framework/DataHandling/inc/MantidDataHandling/FilterEventsByLogValuePreNexus.h index e40324effba448213744cf3202f8f4a15a8779bb..9a6d5d706a6e78d9eb423b49efb50bfe7d3fd96b 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/FilterEventsByLogValuePreNexus.h +++ b/Framework/DataHandling/inc/MantidDataHandling/FilterEventsByLogValuePreNexus.h @@ -122,7 +122,7 @@ private: void readPulseidFile(const std::string &filename, const bool throwError); void runLoadInstrument(const std::string &eventfilename, - API::MatrixWorkspace_sptr localWorkspace); + const API::MatrixWorkspace_sptr &localWorkspace); void procEvents(DataObjects::EventWorkspace_sptr &workspace); @@ -133,15 +133,15 @@ private: void setProtonCharge(DataObjects::EventWorkspace_sptr &workspace); - void addToWorkspaceLog(std::string logtitle, size_t mindex); + void addToWorkspaceLog(const std::string &logtitle, size_t mindex); void processEventLogs(); /// Pad out empty pixel - size_t padOutEmptyPixels(DataObjects::EventWorkspace_sptr eventws); + size_t padOutEmptyPixels(const DataObjects::EventWorkspace_sptr &eventws); /// Set up spectrum/detector ID map inside a workspace - void setupPixelSpectrumMap(DataObjects::EventWorkspace_sptr eventws); + void setupPixelSpectrumMap(const DataObjects::EventWorkspace_sptr &eventws); /// void filterEvents(); diff --git a/Framework/DataHandling/inc/MantidDataHandling/GroupDetectors2.h b/Framework/DataHandling/inc/MantidDataHandling/GroupDetectors2.h index 91f15dbf33c7c04d5a8a9d4bbc84d2ad24948db6..fc590b50ef0a3c2305400075a71b9649e037af6f 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/GroupDetectors2.h +++ b/Framework/DataHandling/inc/MantidDataHandling/GroupDetectors2.h @@ -151,23 +151,23 @@ private: void execEvent(); /// read in the input parameters and see what findout what will be to grouped - void getGroups(API::MatrixWorkspace_const_sptr workspace, + void getGroups(const API::MatrixWorkspace_const_sptr &workspace, std::vector<int64_t> &unUsedSpec); /// gets the list of spectra _index_ _numbers_ from a file of _spectra_ /// _numbers_ void processFile(const std::string &fname, - API::MatrixWorkspace_const_sptr workspace, + const API::MatrixWorkspace_const_sptr &workspace, std::vector<int64_t> &unUsedSpec); /// gets groupings from XML file void processXMLFile(const std::string &fname, - API::MatrixWorkspace_const_sptr workspace, + const API::MatrixWorkspace_const_sptr &workspace, std::vector<int64_t> &unUsedSpec); - void - processGroupingWorkspace(DataObjects::GroupingWorkspace_const_sptr groupWS, - API::MatrixWorkspace_const_sptr workspace, - std::vector<int64_t> &unUsedSpec); - void processMatrixWorkspace(API::MatrixWorkspace_const_sptr groupWS, - API::MatrixWorkspace_const_sptr workspace, + void processGroupingWorkspace( + const DataObjects::GroupingWorkspace_const_sptr &groupWS, + const API::MatrixWorkspace_const_sptr &workspace, + std::vector<int64_t> &unUsedSpec); + void processMatrixWorkspace(const API::MatrixWorkspace_const_sptr &groupWS, + const API::MatrixWorkspace_const_sptr &workspace, std::vector<int64_t> &unUsedSpec); /// used while reading the file turns the string into an integer number (if /// possible), white space and # comments ignored @@ -193,14 +193,15 @@ private: /// Copy the and combine the histograms that the user requested from the input /// into the output workspace - size_t formGroups(API::MatrixWorkspace_const_sptr inputWS, - API::MatrixWorkspace_sptr outputWS, const double prog4Copy, - const bool keepAll, const std::set<int64_t> &unGroupedSet, + size_t formGroups(const API::MatrixWorkspace_const_sptr &inputWS, + const API::MatrixWorkspace_sptr &outputWS, + const double prog4Copy, const bool keepAll, + const std::set<int64_t> &unGroupedSet, Indexing::IndexInfo &indexInfo); /// Copy the and combine the event lists that the user requested from the /// input into the output workspace - size_t formGroupsEvent(DataObjects::EventWorkspace_const_sptr inputWS, - DataObjects::EventWorkspace_sptr outputWS, + size_t formGroupsEvent(const DataObjects::EventWorkspace_const_sptr &inputWS, + const DataObjects::EventWorkspace_sptr &outputWS, const double prog4Copy); /// Copy the ungrouped spectra from the input workspace to the output diff --git a/Framework/DataHandling/inc/MantidDataHandling/JoinISISPolarizationEfficiencies.h b/Framework/DataHandling/inc/MantidDataHandling/JoinISISPolarizationEfficiencies.h index b3b794ea2c98cbc9b292ac6beeccfb39e80bcdad..61d2de494c1f0b1c71350307947fbc38663abd61 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/JoinISISPolarizationEfficiencies.h +++ b/Framework/DataHandling/inc/MantidDataHandling/JoinISISPolarizationEfficiencies.h @@ -33,10 +33,10 @@ private: std::vector<API::MatrixWorkspace_sptr> interpolateWorkspaces( std::vector<API::MatrixWorkspace_sptr> const &workspaces); API::MatrixWorkspace_sptr - interpolatePointDataWorkspace(API::MatrixWorkspace_sptr ws, + interpolatePointDataWorkspace(const API::MatrixWorkspace_sptr &ws, size_t const maxSize); API::MatrixWorkspace_sptr - interpolateHistogramWorkspace(API::MatrixWorkspace_sptr ws, + interpolateHistogramWorkspace(const API::MatrixWorkspace_sptr &ws, size_t const maxSize); }; diff --git a/Framework/DataHandling/inc/MantidDataHandling/Load.h b/Framework/DataHandling/inc/MantidDataHandling/Load.h index dc91b538d0fa54f50531b4d574037789216fcacc..2fa6eb936de13d88971f8ba12e230c223ab37e5b 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/Load.h +++ b/Framework/DataHandling/inc/MantidDataHandling/Load.h @@ -88,7 +88,8 @@ private: API::Workspace_sptr loadFileToWs(const std::string &fileName, const std::string &wsName); /// Plus two workspaces together, "in place". - API::Workspace_sptr plusWs(API::Workspace_sptr ws1, API::Workspace_sptr ws2); + API::Workspace_sptr plusWs(API::Workspace_sptr ws1, + const API::Workspace_sptr &ws2); /// Manually group workspaces. API::WorkspaceGroup_sptr groupWsList(const std::vector<API::Workspace_sptr> &wsList); diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadAsciiStl.h b/Framework/DataHandling/inc/MantidDataHandling/LoadAsciiStl.h index 4e24a8d4f844cc7f834542e2892249e4b9793a93..d955e90fec6acf00fd7e6139351b3e02406a2b1c 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadAsciiStl.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadAsciiStl.h @@ -7,6 +7,8 @@ #pragma once #include "MantidDataHandling/LoadStl.h" #include <iosfwd> +#include <utility> + namespace Mantid { namespace Kernel { @@ -21,12 +23,12 @@ namespace DataHandling { class DLLExport LoadAsciiStl : public LoadStl { public: LoadAsciiStl(std::string filename, ScaleUnits scaleType) - : LoadStl(filename, scaleType) {} + : LoadStl(std::move(filename), scaleType) {} LoadAsciiStl(std::string filename, ScaleUnits scaleType, ReadMaterial::MaterialParameters params) - : LoadStl(filename, scaleType, params) {} + : LoadStl(std::move(filename), scaleType, std::move(params)) {} std::unique_ptr<Geometry::MeshObject> readStl() override; - static bool isAsciiSTL(std::string filename); + static bool isAsciiSTL(const std::string &filename); private: int m_lineNumber = 0; diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadBinaryStl.h b/Framework/DataHandling/inc/MantidDataHandling/LoadBinaryStl.h index 802951c614d5da26ca9c8723ffb984b3e0c73c00..c69730cd169127a3069bce82e31b3b9bebc5078f 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadBinaryStl.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadBinaryStl.h @@ -5,6 +5,10 @@ // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + #pragma once +#include <utility> + +#include <utility> + #include "MantidDataHandling/LoadStl.h" namespace Mantid { @@ -24,12 +28,13 @@ public: static constexpr uint32_t TRIANGLE_COUNT_DATA_SIZE = 4; static constexpr uint32_t VECTOR_DATA_SIZE = 12; LoadBinaryStl(std::string filename, ScaleUnits scaleType) - : LoadStl(filename, scaleType) {} + : LoadStl(std::move(std::move(filename)), scaleType) {} LoadBinaryStl(std::string filename, ScaleUnits scaleType, ReadMaterial::MaterialParameters params) - : LoadStl(filename, scaleType, params) {} + : LoadStl(std::move(std::move(filename)), scaleType, + std::move(std::move(params))) {} std::unique_ptr<Geometry::MeshObject> readStl() override; - static bool isBinarySTL(std::string filename); + static bool isBinarySTL(const std::string &filename); private: void readTriangle(Kernel::BinaryStreamReader, uint32_t &vertexCount); diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadCalFile.h b/Framework/DataHandling/inc/MantidDataHandling/LoadCalFile.h index 318a41a699557405fff23f1993c010aa1e66442a..cec536b2ac4ed02aed40d42bc6cf821dee07ff50 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadCalFile.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadCalFile.h @@ -53,10 +53,11 @@ public: getInstrument3Ways(API::Algorithm *alg); static bool instrumentIsSpecified(API::Algorithm *alg); - static void readCalFile(const std::string &calFileName, - Mantid::DataObjects::GroupingWorkspace_sptr groupWS, - Mantid::DataObjects::OffsetsWorkspace_sptr offsetsWS, - Mantid::DataObjects::MaskWorkspace_sptr maskWS); + static void + readCalFile(const std::string &calFileName, + const Mantid::DataObjects::GroupingWorkspace_sptr &groupWS, + const Mantid::DataObjects::OffsetsWorkspace_sptr &offsetsWS, + const Mantid::DataObjects::MaskWorkspace_sptr &maskWS); protected: Parallel::ExecutionMode getParallelExecutionMode( @@ -70,7 +71,7 @@ private: void exec() override; /// Checks if a detector ID is for a monitor on a given instrument - static bool idIsMonitor(Mantid::Geometry::Instrument_const_sptr inst, + static bool idIsMonitor(const Mantid::Geometry::Instrument_const_sptr &inst, int detID); }; diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadCanSAS1D.h b/Framework/DataHandling/inc/MantidDataHandling/LoadCanSAS1D.h index 885a8014233a9f6674af8feec46ac0d1fbcfa101..398a393a94fe92dce3e260d1798b73a7df21b3d3 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadCanSAS1D.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadCanSAS1D.h @@ -76,18 +76,19 @@ protected: const std::string &name) const; /// Appends the new data workspace creating a workspace group if there was /// existing data - void appendDataToOutput(API::MatrixWorkspace_sptr newWork, + void appendDataToOutput(const API::MatrixWorkspace_sptr &newWork, const std::string &newWorkName, - API::WorkspaceGroup_sptr container); + const API::WorkspaceGroup_sptr &container); /// Run LoadInstrument Child Algorithm void runLoadInstrument(const std::string &inst_name, - API::MatrixWorkspace_sptr localWorkspace); + const API::MatrixWorkspace_sptr &localWorkspace); /// Loads data into the run log void createLogs(const Poco::XML::Element *const sasEntry, - API::MatrixWorkspace_sptr wSpace) const; + const API::MatrixWorkspace_sptr &wSpace) const; /// Loads the information about hhe sample - void createSampleInformation(const Poco::XML::Element *const sasEntry, - Mantid::API::MatrixWorkspace_sptr wSpace) const; + void createSampleInformation( + const Poco::XML::Element *const sasEntry, + const Mantid::API::MatrixWorkspace_sptr &wSpace) const; }; } // namespace DataHandling } // namespace Mantid diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadDaveGrp.h b/Framework/DataHandling/inc/MantidDataHandling/LoadDaveGrp.h index 802b74dd7760a93a342a8bce34c027018e0a9711..ca091548c58af7966b865e004ef7410f80090db8 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadDaveGrp.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadDaveGrp.h @@ -102,7 +102,7 @@ private: * * @param workspace handle to the workspace to to load data into */ - void getData(API::MatrixWorkspace_sptr workspace); + void getData(const API::MatrixWorkspace_sptr &workspace); /** * Function to setup the workspace ready for data to be loaded into it @@ -118,7 +118,7 @@ private: * @param xAxis the x axis data * @param yAxis the y axis data */ - void setWorkspaceAxes(API::MatrixWorkspace_sptr workspace, + void setWorkspaceAxes(const API::MatrixWorkspace_sptr &workspace, const std::vector<double> &xAxis, const std::vector<double> &yAxis) const; diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadDetectorsGroupingFile.h b/Framework/DataHandling/inc/MantidDataHandling/LoadDetectorsGroupingFile.h index bfc0bf2d36240291ab1bb6181f3603045279724e..66ba3fca07f27f50a888ad3221bc8973d2eca4de 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadDetectorsGroupingFile.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadDetectorsGroupingFile.h @@ -107,7 +107,7 @@ class DLLExport LoadGroupXMLFile { public: LoadGroupXMLFile(); - void loadXMLFile(std::string xmlfilename); + void loadXMLFile(const std::string &xmlfilename); void setDefaultStartingGroupID(int startgroupid) { m_startGroupID = startgroupid; } @@ -167,7 +167,7 @@ private: void parseXML(); /// Get attribute value from an XML node static std::string getAttributeValueByName(Poco::XML::Node *pNode, - std::string attributename, + const std::string &attributename, bool &found); }; diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadDspacemap.h b/Framework/DataHandling/inc/MantidDataHandling/LoadDspacemap.h index d835ca613f0a9bf9f4f39eaa1bf11a3b5e7fd44a..fe0f2ea36148a5bb42f820ff13a74a54115a778b 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadDspacemap.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadDspacemap.h @@ -48,12 +48,12 @@ private: std::map<detid_t, double> &vulcan); void CalculateOffsetsFromDSpacemapFile( - const std::string DFileName, - Mantid::DataObjects::OffsetsWorkspace_sptr offsetsWS); + const std::string &DFileName, + const Mantid::DataObjects::OffsetsWorkspace_sptr &offsetsWS); void CalculateOffsetsFromVulcanFactors( std::map<detid_t, double> &vulcan, - Mantid::DataObjects::OffsetsWorkspace_sptr offsetsWS); + const Mantid::DataObjects::OffsetsWorkspace_sptr &offsetsWS); }; } // namespace DataHandling diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadEventNexus.h b/Framework/DataHandling/inc/MantidDataHandling/LoadEventNexus.h index 8dbc0304175c51ea862e97835ef585796f6aea6e..3c2c8141cb82c705f1039663f4d50bed02e735b8 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadEventNexus.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadEventNexus.h @@ -206,8 +206,8 @@ private: void createSpectraMapping( const std::string &nxsfile, const bool monitorsOnly, const std::vector<std::string> &bankNames = std::vector<std::string>()); - void deleteBanks(EventWorkspaceCollection_sptr workspace, - std::vector<std::string> bankNames); + void deleteBanks(const EventWorkspaceCollection_sptr &workspace, + const std::vector<std::string> &bankNames); bool hasEventMonitors(); void runLoadMonitors(); /// Set the filters on TOF. @@ -223,7 +223,7 @@ private: void setTopEntryName(); /// to open the nexus file with specific exception handling/message - void safeOpenFile(const std::string fname); + void safeOpenFile(const std::string &fname); /// Was the instrument loaded? bool m_instrument_loaded_correctly; diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadEventNexusIndexSetup.h b/Framework/DataHandling/inc/MantidDataHandling/LoadEventNexusIndexSetup.h index 60feb2504cbd8c7e7a14c8fba398147d1d706359..a653534a18cd997ad2d7730614b602f1d2857832 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadEventNexusIndexSetup.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadEventNexusIndexSetup.h @@ -28,7 +28,7 @@ class MANTID_DATAHANDLING_DLL LoadEventNexusIndexSetup { public: LoadEventNexusIndexSetup( API::MatrixWorkspace_const_sptr instrumentWorkspace, const int32_t min, - const int32_t max, const std::vector<int32_t> range, + const int32_t max, const std::vector<int32_t> &range, const Parallel::Communicator &communicator = Parallel::Communicator()); std::pair<int32_t, int32_t> eventIDLimits() const; diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadEventPreNexus2.h b/Framework/DataHandling/inc/MantidDataHandling/LoadEventPreNexus2.h index e6a43703b1af39036de35f41071ea712bb1526ab..cb2b3b406b9d4056fa60823408b943728cd56014 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadEventPreNexus2.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadEventPreNexus2.h @@ -188,7 +188,7 @@ private: void readPulseidFile(const std::string &filename, const bool throwError); void runLoadInstrument(const std::string &eventfilename, - API::MatrixWorkspace_sptr localWorkspace); + const API::MatrixWorkspace_sptr &localWorkspace); inline void fixPixelId(PixelType &pixel, uint32_t &period) const; @@ -202,7 +202,7 @@ private: void setProtonCharge(DataObjects::EventWorkspace_sptr &workspace); - void addToWorkspaceLog(std::string logtitle, size_t mindex); + void addToWorkspaceLog(const std::string &logtitle, size_t mindex); void processImbedLogs(); @@ -212,7 +212,7 @@ private: API::MatrixWorkspace_sptr generateEventDistribtionWorkspace(); - void createOutputWorkspace(const std::string event_filename); + void createOutputWorkspace(const std::string &event_filename); /// Processing the input properties for purpose of investigation void processInvestigationInputs(); diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadFITS.h b/Framework/DataHandling/inc/MantidDataHandling/LoadFITS.h index c4a46f6f1f89c513ef33d6d243637774e7729647..c1720745222adb9c475b30ab537c636253e3a077 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadFITS.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadFITS.h @@ -91,15 +91,16 @@ private: DataObjects::Workspace2D_sptr makeWorkspace( const FITSInfo &fileInfo, size_t &newFileNumber, std::vector<char> &buffer, API::MantidImage &imageY, - API::MantidImage &imageE, const DataObjects::Workspace2D_sptr parent, + API::MantidImage &imageE, const DataObjects::Workspace2D_sptr &parent, bool loadAsRectImg = false, int binSize = 1, double noiseThresh = false); - void addAxesInfoAndLogs(DataObjects::Workspace2D_sptr ws, bool loadAsRectImg, - const FITSInfo &fileInfo, int binSize, double cmpp); + void addAxesInfoAndLogs(const DataObjects::Workspace2D_sptr &ws, + bool loadAsRectImg, const FITSInfo &fileInfo, + int binSize, double cmpp); // Reads the data from a single FITS file into a workspace (directly, fast) void readDataToWorkspace(const FITSInfo &fileInfo, double cmpp, - DataObjects::Workspace2D_sptr ws, + const DataObjects::Workspace2D_sptr &ws, std::vector<char> &buffer); // Reads the data from a single FITS file into image objects (Y and E) that diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadFullprofResolution.h b/Framework/DataHandling/inc/MantidDataHandling/LoadFullprofResolution.h index 0719e71aeaa6df686dcc6581d09dfc254b5b210c..0796c67a633fb32f7c52e4b9ca49a60489704fe1 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadFullprofResolution.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadFullprofResolution.h @@ -51,48 +51,48 @@ public: std::map<std::string, size_t> ¶mmap); /// Put parameters into a matrix workspace - static void putParametersIntoWorkspace(const API::Column_const_sptr, - API::MatrixWorkspace_sptr ws, + static void putParametersIntoWorkspace(const API::Column_const_sptr &, + const API::MatrixWorkspace_sptr &ws, int nProf, std::string ¶meterXMLString); /// Add an Ikeda-Carpenter PV ALFBE parameter - static void addALFBEParameter(const API::Column_const_sptr, + static void addALFBEParameter(const API::Column_const_sptr &, Poco::XML::Document *mDoc, Poco::XML::Element *parent, const std::string ¶mName); /// Add set of Ikeda-Carpenter PV Sigma parameters - static void addSigmaParameters(const API::Column_const_sptr, + static void addSigmaParameters(const API::Column_const_sptr &, Poco::XML::Document *mDoc, Poco::XML::Element *parent); /// Add set of Ikeda-Carpenter PV Gamma parameters - static void addGammaParameters(const API::Column_const_sptr, + static void addGammaParameters(const API::Column_const_sptr &, Poco::XML::Document *mDoc, Poco::XML::Element *parent); /// Add set of BackToBackExponential S parameters - static void addBBX_S_Parameters(const API::Column_const_sptr, + static void addBBX_S_Parameters(const API::Column_const_sptr &, Poco::XML::Document *mDoc, Poco::XML::Element *parent); /// Add set of BackToBackExponential A parameters - static void addBBX_A_Parameters(const API::Column_const_sptr, + static void addBBX_A_Parameters(const API::Column_const_sptr &, Poco::XML::Document *mDoc, Poco::XML::Element *parent); /// Add set of BackToBackExponential B parameters - static void addBBX_B_Parameters(const API::Column_const_sptr, + static void addBBX_B_Parameters(const API::Column_const_sptr &, Poco::XML::Document *mDoc, Poco::XML::Element *parent); /// Get value for XML eq attribute for parameter - static std::string getXMLEqValue(const API::Column_const_sptr, + static std::string getXMLEqValue(const API::Column_const_sptr &, const std::string &name); /// Get value for XML eq attribute for squared parameter - static std::string getXMLSquaredEqValue(const API::Column_const_sptr column, + static std::string getXMLSquaredEqValue(const API::Column_const_sptr &column, const std::string &name); // Translate a parameter name from as it appears in the table workspace to its @@ -114,7 +114,7 @@ private: void exec() override; /// Load file to a vector of strings - void loadFile(std::string filename, std::vector<std::string> &lines); + void loadFile(const std::string &filename, std::vector<std::string> &lines); /// Get the NPROF number int getProfNumber(const std::vector<std::string> &lines); diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadGSASInstrumentFile.h b/Framework/DataHandling/inc/MantidDataHandling/LoadGSASInstrumentFile.h index bafa82c0063f7f5c2706baf268bd16a1ed64cb58..da15be2dc473984baadb9ec6a0fb53d566958b10 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadGSASInstrumentFile.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadGSASInstrumentFile.h @@ -49,7 +49,7 @@ private: void exec() override; /// Load file to a vector of strings - void loadFile(std::string filename, std::vector<std::string> &lines); + void loadFile(const std::string &filename, std::vector<std::string> &lines); /// Get Histogram type std::string getHistogramType(const std::vector<std::string> &lines); diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadGSS.h b/Framework/DataHandling/inc/MantidDataHandling/LoadGSS.h index 683863dc673ef481c00dc23af23073f0e531518f..cefa59b10e4c8305ff0a36a3a76e287513ddc6d0 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadGSS.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadGSS.h @@ -63,7 +63,7 @@ private: double convertToDouble(std::string inputstring); /// Create an instrument geometry. - void createInstrumentGeometry(API::MatrixWorkspace_sptr workspace, + void createInstrumentGeometry(const API::MatrixWorkspace_sptr &workspace, const std::string &instrumentname, const double &primaryflightpath, const std::vector<int> &detectorids, diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadHelper.h b/Framework/DataHandling/inc/MantidDataHandling/LoadHelper.h index 6d61d25ce6781085de33d93e240feeb10ad07416..e1d76e61361236dfe290af9096dcacfe1718bd56 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadHelper.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadHelper.h @@ -35,18 +35,19 @@ public: static double calculateStandardError(double in) { return sqrt(in); } double calculateEnergy(double); double calculateTOF(double, double); - double getInstrumentProperty(const API::MatrixWorkspace_sptr &, std::string); + double getInstrumentProperty(const API::MatrixWorkspace_sptr &, + const std::string &); void addNexusFieldsToWsRun(NXhandle nxfileID, API::Run &runDetails); void dumpNexusAttributes(NXhandle nxfileID, std::string &indentStr); - std::string dateTimeInIsoFormat(std::string); + std::string dateTimeInIsoFormat(const std::string &); - void moveComponent(API::MatrixWorkspace_sptr ws, + void moveComponent(const API::MatrixWorkspace_sptr &ws, const std::string &componentName, const Kernel::V3D &newPos); - void rotateComponent(API::MatrixWorkspace_sptr ws, + void rotateComponent(const API::MatrixWorkspace_sptr &ws, const std::string &componentName, const Kernel::Quat &rot); - Kernel::V3D getComponentPosition(API::MatrixWorkspace_sptr ws, + Kernel::V3D getComponentPosition(const API::MatrixWorkspace_sptr &ws, const std::string &componentName); private: diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadIDFFromNexus.h b/Framework/DataHandling/inc/MantidDataHandling/LoadIDFFromNexus.h index 5da9cae6b1aacc765959225c9767158333e48bf3..b1e0389853c021cb04d8d3dd61fa0d830bc67983 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadIDFFromNexus.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadIDFFromNexus.h @@ -59,7 +59,7 @@ public: /// Load the parameters from Nexus file if possible, else from parameter file, /// into workspace void LoadParameters(::NeXus::File *nxfile, - const API::MatrixWorkspace_sptr localWorkspace); + const API::MatrixWorkspace_sptr &localWorkspace); /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; } @@ -77,7 +77,7 @@ private: /// Load Parameter File specified by full pathname into given workspace, /// return success bool loadParameterFile(const std::string &fullPathName, - const API::MatrixWorkspace_sptr localWorkspace); + const API::MatrixWorkspace_sptr &localWorkspace); }; } // namespace DataHandling diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadILLDiffraction.h b/Framework/DataHandling/inc/MantidDataHandling/LoadILLDiffraction.h index d1f7f1456799c8c2c1e7ad5d72eaea2c10f95bfa..5e62681ceae7f0caa121214a7e2303a489327e9d 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadILLDiffraction.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadILLDiffraction.h @@ -6,6 +6,8 @@ // SPDX - License - Identifier: GPL - 3.0 + #pragma once +#include <utility> + #include "MantidAPI/IFileLoader.h" #include "MantidDataHandling/DllConfig.h" #include "MantidDataHandling/LoadHelper.h" @@ -45,7 +47,8 @@ private: std::string unit; ScannedVariables(std::string n, std::string p, std::string u) - : axis(0), scanned(0), name(n), property(p), unit(u) {} + : axis(0), scanned(0), name(std::move(n)), property(std::move(p)), + unit(std::move(u)) {} void setAxis(int a) { axis = a; } void setScanned(int s) { scanned = s; } diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadILLIndirect2.h b/Framework/DataHandling/inc/MantidDataHandling/LoadILLIndirect2.h index c495fe9c1e58107a42e3bd734e8a9d41fe756bc6..961712138804b2ffb89b6dab068706f4807b39d3 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadILLIndirect2.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadILLIndirect2.h @@ -44,7 +44,7 @@ private: void initWorkSpace(); void setInstrumentName(const NeXus::NXEntry &firstEntry, const std::string &instrumentNamePath); - void loadNexusEntriesIntoProperties(std::string nexusfilename); + void loadNexusEntriesIntoProperties(const std::string &nexusfilename); void loadDataIntoTheWorkSpace(NeXus::NXEntry &entry); void runLoadInstrument(); void moveComponent(const std::string &, double); diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadISISNexus2.h b/Framework/DataHandling/inc/MantidDataHandling/LoadISISNexus2.h index 16f8fabe5d99aa9f00398b8361500cc5588fba43..464d3ebe2a9ccabd431351d1e709cfee8b01d506 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadISISNexus2.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadISISNexus2.h @@ -129,7 +129,7 @@ private: void createPeriodLogs(int64_t period, DataObjects::Workspace2D_sptr &local_workspace); // Validate multi-period logs - void validateMultiPeriodLogs(Mantid::API::MatrixWorkspace_sptr); + void validateMultiPeriodLogs(const Mantid::API::MatrixWorkspace_sptr &); // build the list of spectra numbers to load and include in the spectra list void buildSpectraInd2SpectraNumMap(bool range_supplied, bool hasSpectraList, diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadInstrument.h b/Framework/DataHandling/inc/MantidDataHandling/LoadInstrument.h index f806e3f60e3383c0f4742907fbc2b13035d928de..af8bcd4fb77fb0e86a76188e6a1d7181b9b2fbd2 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadInstrument.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadInstrument.h @@ -82,12 +82,12 @@ private: /// Run the Child Algorithm LoadParameters void runLoadParameterFile(const boost::shared_ptr<API::MatrixWorkspace> &ws, - std::string filename); + const std::string &filename); /// Search directory for Parameter file, return full path name if found, else /// "". - std::string getFullPathParamIDF(std::string directoryName, - std::string filename); + std::string getFullPathParamIDF(const std::string &directoryName, + const std::string &filename); /// Mutex to avoid simultaneous access static std::recursive_mutex m_mutex; diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadIsawDetCal.h b/Framework/DataHandling/inc/MantidDataHandling/LoadIsawDetCal.h index c7ba4675acc8ee47c92ce410af2d2851c66a2d2d..a9692c495fc22e48163add0679c910485aae26c0 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadIsawDetCal.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadIsawDetCal.h @@ -66,15 +66,15 @@ private: /// Set the center of the supplied detector name void center(const double x, const double y, const double z, - const std::string &detname, API::Workspace_sptr ws, + const std::string &detname, const API::Workspace_sptr &ws, Geometry::ComponentInfo &componentInfo); - Geometry::Instrument_sptr getCheckInst(API::Workspace_sptr ws); + Geometry::Instrument_sptr getCheckInst(const API::Workspace_sptr &ws); std::vector<std::string> getFilenames(); void doRotation(Kernel::V3D rX, Kernel::V3D rY, Geometry::ComponentInfo &componentInfo, - boost::shared_ptr<const Geometry::IComponent> comp, + const boost::shared_ptr<const Geometry::IComponent> &comp, bool doWishCorrection = false); void applyScalings( API::Workspace_sptr &ws, diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadLog.h b/Framework/DataHandling/inc/MantidDataHandling/LoadLog.h index 4649af305d46deb3d59f6a4280f29b6f009bf168..34112bb1bc4fe64eb146ece830f5aba4cb597753 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadLog.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadLog.h @@ -114,7 +114,7 @@ private: /// Create timeseries property from .log file and adds that to sample object void loadThreeColumnLogFile(std::ifstream &logFileStream, - std::string logFileName, API::Run &run); + const std::string &logFileName, API::Run &run); /// Loads two column log file data into local workspace void loadTwoColumnLogFile(std::ifstream &logFileStream, diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadMuonNexus.h b/Framework/DataHandling/inc/MantidDataHandling/LoadMuonNexus.h index d945e813eabe981d03c4878aaceb2050483a25ac..b447ebc7abb4f9d607e76e9d37648bb6e8667062 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadMuonNexus.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadMuonNexus.h @@ -75,7 +75,7 @@ public: protected: virtual void runLoadInstrumentFromNexus(DataObjects::Workspace2D_sptr) {} void checkOptionalProperties(); - void runLoadInstrument(DataObjects::Workspace2D_sptr); + void runLoadInstrument(const DataObjects::Workspace2D_sptr &); /// The name and path of the input file std::string m_filename; diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadMuonNexus1.h b/Framework/DataHandling/inc/MantidDataHandling/LoadMuonNexus1.h index b6bd27025c9fe16edab6a9c2e114507eeb2520f2..a79a1ff9070a78daeed6b09623035444e5112c16 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadMuonNexus1.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadMuonNexus1.h @@ -84,13 +84,13 @@ protected: private: void loadData(size_t hist, specnum_t &i, specnum_t specNo, MuonNexusReader &nxload, const int64_t lengthIn, - DataObjects::Workspace2D_sptr localWorkspace); + const DataObjects::Workspace2D_sptr &localWorkspace); void runLoadMappingTable(DataObjects::Workspace2D_sptr); - void runLoadLog(DataObjects::Workspace2D_sptr); - void loadRunDetails(DataObjects::Workspace2D_sptr localWorkspace); - void addPeriodLog(DataObjects::Workspace2D_sptr localWorkspace, + void runLoadLog(const DataObjects::Workspace2D_sptr &); + void loadRunDetails(const DataObjects::Workspace2D_sptr &localWorkspace); + void addPeriodLog(const DataObjects::Workspace2D_sptr &localWorkspace, int64_t period); - void addGoodFrames(DataObjects::Workspace2D_sptr localWorkspace, + void addGoodFrames(const DataObjects::Workspace2D_sptr &localWorkspace, int64_t period, int nperiods); /// Loads dead time table for the detector @@ -104,7 +104,7 @@ private: /// Loads detector grouping information API::Workspace_sptr loadDetectorGrouping(Mantid::NeXus::NXRoot &root, - Mantid::Geometry::Instrument_const_sptr inst); + const Mantid::Geometry::Instrument_const_sptr &inst); /// Creates Detector Grouping Table using all the data from the range DataObjects::TableWorkspace_sptr diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadMuonNexus2.h b/Framework/DataHandling/inc/MantidDataHandling/LoadMuonNexus2.h index 027ca711809cdf3cc67126655002bff2b55459f2..0b43a3c127de6bde6f27095e1c3bfdb74352984c 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadMuonNexus2.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadMuonNexus2.h @@ -79,9 +79,9 @@ private: HistogramData::Histogram loadData(const Mantid::HistogramData::BinEdges &edges, const Mantid::NeXus::NXInt &counts, int period, int spec); - void loadLogs(API::MatrixWorkspace_sptr ws, Mantid::NeXus::NXEntry &entry, - int period); - void loadRunDetails(DataObjects::Workspace2D_sptr localWorkspace); + void loadLogs(const API::MatrixWorkspace_sptr &ws, + Mantid::NeXus::NXEntry &entry, int period); + void loadRunDetails(const DataObjects::Workspace2D_sptr &localWorkspace); std::map<int, std::set<int>> loadDetectorMapping(const Mantid::NeXus::NXInt &spectrumIndex); }; diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadNexusLogs.h b/Framework/DataHandling/inc/MantidDataHandling/LoadNexusLogs.h index 16888c9d70be2683a014d9f31f7c0f6fb5045936..27d649c53b28bf725932bf3f41af037c2edd2b2f 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadNexusLogs.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadNexusLogs.h @@ -62,18 +62,22 @@ private: /// Load log data from a group void loadLogs(::NeXus::File &file, const std::string &entry_name, const std::string &entry_class, - boost::shared_ptr<API::MatrixWorkspace> workspace) const; + const boost::shared_ptr<API::MatrixWorkspace> &workspace) const; /// Load an NXlog entry - void loadNXLog(::NeXus::File &file, const std::string &entry_name, - const std::string &entry_class, - boost::shared_ptr<API::MatrixWorkspace> workspace) const; + void + loadNXLog(::NeXus::File &file, const std::string &entry_name, + const std::string &entry_class, + const boost::shared_ptr<API::MatrixWorkspace> &workspace) const; /// Load an IXseblock entry - void loadSELog(::NeXus::File &file, const std::string &entry_name, - boost::shared_ptr<API::MatrixWorkspace> workspace) const; - void loadVetoPulses(::NeXus::File &file, - boost::shared_ptr<API::MatrixWorkspace> workspace) const; - void loadNPeriods(::NeXus::File &file, - boost::shared_ptr<API::MatrixWorkspace> workspace) const; + void + loadSELog(::NeXus::File &file, const std::string &entry_name, + const boost::shared_ptr<API::MatrixWorkspace> &workspace) const; + void loadVetoPulses( + ::NeXus::File &file, + const boost::shared_ptr<API::MatrixWorkspace> &workspace) const; + void + loadNPeriods(::NeXus::File &file, + const boost::shared_ptr<API::MatrixWorkspace> &workspace) const; /// Progress reporting object boost::shared_ptr<API::Progress> m_progress; diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadNexusMonitors2.h b/Framework/DataHandling/inc/MantidDataHandling/LoadNexusMonitors2.h index 069b37ed9cacad5266e600bcef2594d905362b29..f1ef867e40190d6bcd5f399daf9ed1e665e9927e 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadNexusMonitors2.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadNexusMonitors2.h @@ -82,8 +82,8 @@ private: void fixUDets(::NeXus::File &file); /// Load the logs - void runLoadLogs(const std::string filename, - API::MatrixWorkspace_sptr localWorkspace); + void runLoadLogs(const std::string &filename, + const API::MatrixWorkspace_sptr &localWorkspace); /// is it possible to open the file? bool canOpenAsNeXus(const std::string &fname); diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadNexusProcessed.h b/Framework/DataHandling/inc/MantidDataHandling/LoadNexusProcessed.h index 230499affc16be9454db1929d73d20b652bf3530..48b3d6ffa83f69b253f2d6c06d81a1f8de4b0361 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadNexusProcessed.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadNexusProcessed.h @@ -160,7 +160,7 @@ private: /// Read the bin masking information void readBinMasking(Mantid::NeXus::NXData &wksp_cls, - API::MatrixWorkspace_sptr local_workspace); + const API::MatrixWorkspace_sptr &local_workspace); /// Load a block of data into the workspace where it is assumed that the x /// bins have already been cached @@ -169,7 +169,7 @@ private: Mantid::NeXus::NXDataSetTyped<double> &farea, bool hasFArea, Mantid::NeXus::NXDouble &xErrors, bool hasXErrors, int blocksize, int nchannels, int &hist, - API::MatrixWorkspace_sptr local_workspace); + const API::MatrixWorkspace_sptr &local_workspace); /// Load a block of data into the workspace where it is assumed that the x /// bins have already been cached @@ -178,7 +178,7 @@ private: Mantid::NeXus::NXDataSetTyped<double> &farea, bool hasFArea, Mantid::NeXus::NXDouble &xErrors, bool hasXErrors, int blocksize, int nchannels, int &hist, int &wsIndex, - API::MatrixWorkspace_sptr local_workspace); + const API::MatrixWorkspace_sptr &local_workspace); /// Load a block of data into the workspace void loadBlock(Mantid::NeXus::NXDataSetTyped<double> &data, Mantid::NeXus::NXDataSetTyped<double> &errors, @@ -186,10 +186,10 @@ private: Mantid::NeXus::NXDouble &xErrors, bool hasXErrors, Mantid::NeXus::NXDouble &xbins, int blocksize, int nchannels, int &hist, int &wsIndex, - API::MatrixWorkspace_sptr local_workspace); + const API::MatrixWorkspace_sptr &local_workspace); /// Load the data from a non-spectra axis (Numeric/Text) into the workspace - void loadNonSpectraAxis(API::MatrixWorkspace_sptr local_workspace, + void loadNonSpectraAxis(const API::MatrixWorkspace_sptr &local_workspace, Mantid::NeXus::NXData &data); /// Validates the optional 'spectra to read' properties, if they have been set @@ -232,8 +232,8 @@ private: std::unique_ptr<::NeXus::File> m_nexusFile; }; /// to sort the algorithmhistory vector -bool UDlesserExecCount(Mantid::NeXus::NXClassInfo elem1, - Mantid::NeXus::NXClassInfo elem2); +bool UDlesserExecCount(const Mantid::NeXus::NXClassInfo &elem1, + const Mantid::NeXus::NXClassInfo &elem2); } // namespace DataHandling } // namespace Mantid diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadOff.h b/Framework/DataHandling/inc/MantidDataHandling/LoadOff.h index a13fc65d74938e7e8b25190268c6abcb0ea2749e..eb30b111e84a9187ccd9cb9d75aa8fa6938bb812 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadOff.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadOff.h @@ -25,7 +25,7 @@ Mantid::Kernel::Logger g_log("LoadOff"); } class DLLExport LoadOff : public MeshFileIO { public: - LoadOff(std::string filename, ScaleUnits scaleType); + LoadOff(const std::string &filename, ScaleUnits scaleType); std::unique_ptr<Geometry::MeshObject> readOFFshape(); private: diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadPDFgetNFile.h b/Framework/DataHandling/inc/MantidDataHandling/LoadPDFgetNFile.h index 4d569896a9a6e3fc8c74fbbc4643c913abffd074..315da9cc9f64a04425765649b11cec586cf09237 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadPDFgetNFile.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadPDFgetNFile.h @@ -46,7 +46,7 @@ private: int confidence(Kernel::FileDescriptor &descriptor) const override; /// Parse PDFgetN data file - void parseDataFile(std::string filename); + void parseDataFile(const std::string &filename); /// Check whether a string starts from a specified sub-string bool startsWith(const std::string &s, const std::string &header) const; @@ -70,7 +70,7 @@ private: void generateDataWorkspace(); /// Set X and Y axis unit and lebel - void setUnit(DataObjects::Workspace2D_sptr ws); + void setUnit(const DataObjects::Workspace2D_sptr &ws); void checkSameSize(const std::vector<size_t> &numptsvec, size_t numsets); }; diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadPSIMuonBin.h b/Framework/DataHandling/inc/MantidDataHandling/LoadPSIMuonBin.h index 113ec9642bf6c33d03c6c14ebe57fa42347d2f44..05e96c92574a8e8fd922c58ed046bd3ca5fd2656 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadPSIMuonBin.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadPSIMuonBin.h @@ -77,7 +77,8 @@ public: private: void init() override; void exec() override; - std::string getFormattedDateTime(std::string date, std::string time); + std::string getFormattedDateTime(const std::string &date, + const std::string &time); void assignOutputWorkspaceParticulars( DataObjects::Workspace2D_sptr &outputWorkspace); void readSingleVariables(Mantid::Kernel::BinaryStreamReader &streamReader); diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadPreNexusMonitors.h b/Framework/DataHandling/inc/MantidDataHandling/LoadPreNexusMonitors.h index 5684f3fd53453c0090a1e7b571e7473ef923c3e9..40e77ebfef29bd30e43dadd12989fcb2e67d4b79 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadPreNexusMonitors.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadPreNexusMonitors.h @@ -55,7 +55,7 @@ private: bool instrument_loaded_correctly; void runLoadInstrument(const std::string &instrument, - API::MatrixWorkspace_sptr localWorkspace); + const API::MatrixWorkspace_sptr &localWorkspace); }; } // namespace DataHandling diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadRKH.h b/Framework/DataHandling/inc/MantidDataHandling/LoadRKH.h index 79c99457f429da52a7dfd44ceb27b824abfc59f6..14fa413ddb7dc5bc09e1c9fd4f79852276a4da1d 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadRKH.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadRKH.h @@ -74,7 +74,7 @@ private: MantidVec &axis0Data); const std::string readUnit(const std::string &line); void readNumEntrys(const int nEntries, MantidVec &output); - void binCenter(const MantidVec oldBoundaries, MantidVec &toCenter) const; + void binCenter(const MantidVec &oldBoundaries, MantidVec &toCenter) const; // Remove lines from an input stream void skipLines(std::istream &strm, int nlines); diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadRaw3.h b/Framework/DataHandling/inc/MantidDataHandling/LoadRaw3.h index 71f95e5c32cff1d8d08659b3458e45a936b6c3f7..b8d7830f511bc39be6264aabf2252be16d500dbd 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadRaw3.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadRaw3.h @@ -67,18 +67,18 @@ private: /// creates output workspace, monitors excluded from this workspace void excludeMonitors(FILE *file, const int &period, const std::vector<specnum_t> &monitorList, - DataObjects::Workspace2D_sptr ws_sptr); + const DataObjects::Workspace2D_sptr &ws_sptr); /// creates output workspace whcih includes monitors void includeMonitors(FILE *file, const int64_t &period, - DataObjects::Workspace2D_sptr ws_sptr); + const DataObjects::Workspace2D_sptr &ws_sptr); /// creates two output workspaces none normal workspace and separate one for /// monitors void separateMonitors(FILE *file, const int64_t &period, const std::vector<specnum_t> &monitorList, - DataObjects::Workspace2D_sptr ws_sptr, - DataObjects::Workspace2D_sptr mws_sptr); + const DataObjects::Workspace2D_sptr &ws_sptr, + const DataObjects::Workspace2D_sptr &mws_sptr); /// skip all spectra in a period void skipPeriod(FILE *file, const int64_t &period); diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadRawHelper.h b/Framework/DataHandling/inc/MantidDataHandling/LoadRawHelper.h index bb1d04fec7a716cbedaa0cc5903ac80f7f756798..a58f0d23642f491bbd0656c1bebe2415df625bd6 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadRawHelper.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadRawHelper.h @@ -53,7 +53,7 @@ public: /// Opens Raw File FILE *openRawFile(const std::string &fileName); /// Read in run parameters Public so that LoadRaw2 can use it - void loadRunParameters(API::MatrixWorkspace_sptr localWorkspace, + void loadRunParameters(const API::MatrixWorkspace_sptr &localWorkspace, ISISRAW *const = nullptr) const; /// Returns a confidence value that this algorithm can load a file @@ -77,14 +77,15 @@ public: API::WorkspaceGroup_sptr &mongrp_sptr, const int64_t mwsSpecs, const int64_t nwsSpecs, const int64_t numberOfPeriods, const int64_t lengthIn, - std::string title, API::Algorithm *const pAlg); + const std::string &title, API::Algorithm *const pAlg); /// creates shared pointer to group workspace static API::WorkspaceGroup_sptr createGroupWorkspace(); /// creates shared pointer to workspace from parent workspace static DataObjects::Workspace2D_sptr - createWorkspace(DataObjects::Workspace2D_sptr ws_sptr, int64_t nVectors = -1, - int64_t xLengthIn = -1, int64_t yLengthIn = -1); + createWorkspace(const DataObjects::Workspace2D_sptr &ws_sptr, + int64_t nVectors = -1, int64_t xLengthIn = -1, + int64_t yLengthIn = -1); /// overloaded method to create shared pointer to workspace static DataObjects::Workspace2D_sptr @@ -94,14 +95,14 @@ public: /// sets the workspace property static void setWorkspaceProperty(const std::string &propertyName, const std::string &title, - API::WorkspaceGroup_sptr grpws_sptr, - DataObjects::Workspace2D_sptr ws_sptr, + const API::WorkspaceGroup_sptr &grpws_sptr, + const DataObjects::Workspace2D_sptr &ws_sptr, int64_t numberOfPeriods, bool bMonitor, API::Algorithm *const pAlg); /// overloaded method to set the workspace property - static void setWorkspaceProperty(DataObjects::Workspace2D_sptr ws_sptr, - API::WorkspaceGroup_sptr grpws_sptr, + static void setWorkspaceProperty(const DataObjects::Workspace2D_sptr &ws_sptr, + const API::WorkspaceGroup_sptr &grpws_sptr, const int64_t period, bool bmonitors, API::Algorithm *const pAlg); @@ -138,20 +139,20 @@ protected: getTimeChannels(const int64_t ®imes, const int64_t &lengthIn); /// loadinstrument Child Algorithm void runLoadInstrument(const std::string &fileName, - DataObjects::Workspace2D_sptr, double, double); + const DataObjects::Workspace2D_sptr &, double, double); /// loadinstrumentfromraw algorithm void runLoadInstrumentFromRaw(const std::string &fileName, - DataObjects::Workspace2D_sptr); + const DataObjects::Workspace2D_sptr &); /// loadinstrumentfromraw Child Algorithm void runLoadMappingTable(const std::string &fileName, - DataObjects::Workspace2D_sptr); + const DataObjects::Workspace2D_sptr &); /// load log algorithm - void runLoadLog(const std::string &fileName, DataObjects::Workspace2D_sptr, - double, double); + void runLoadLog(const std::string &fileName, + const DataObjects::Workspace2D_sptr &, double, double); /// Create the period specific logs void createPeriodLogs(int64_t period, - DataObjects::Workspace2D_sptr local_workspace); + const DataObjects::Workspace2D_sptr &local_workspace); /// gets the monitor spectrum list from the workspace std::vector<specnum_t> @@ -159,7 +160,7 @@ protected: /// This method sets the raw file data to workspace vectors void setWorkspaceData( - DataObjects::Workspace2D_sptr newWorkspace, + const DataObjects::Workspace2D_sptr &newWorkspace, const std::vector<boost::shared_ptr<HistogramData::HistogramX>> &timeChannelsVec, int64_t wsIndex, specnum_t nspecNum, int64_t noTimeRegimes, @@ -191,9 +192,10 @@ protected: specnum_t &normalwsSpecs, specnum_t &monitorwsSpecs); /// load the spectra - void loadSpectra(FILE *file, const int &period, const int &total_specs, - DataObjects::Workspace2D_sptr ws_sptr, - std::vector<boost::shared_ptr<HistogramData::HistogramX>>); + void loadSpectra( + FILE *file, const int &period, const int &total_specs, + const DataObjects::Workspace2D_sptr &ws_sptr, + const std::vector<boost::shared_ptr<HistogramData::HistogramX>> &); /// Has the spectrum_list property been set? bool m_list; diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadSPE.h b/Framework/DataHandling/inc/MantidDataHandling/LoadSPE.h index e0988a1b984e403fab515eb95908c775ae078579..2625e5f3a2f27d94952103d84f7c2843cc1b709f 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadSPE.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadSPE.h @@ -53,7 +53,7 @@ private: // Execution code void exec() override; - void readHistogram(FILE *speFile, API::MatrixWorkspace_sptr workspace, + void readHistogram(FILE *speFile, const API::MatrixWorkspace_sptr &workspace, size_t index); void reportFormatError(const std::string &what); diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadSampleShape.h b/Framework/DataHandling/inc/MantidDataHandling/LoadSampleShape.h index 3e6c44698d9f77b8848a2f7a632eae85f8d45020..c14c313e1f73e9bc1ee54e01690752e95f716ea6 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadSampleShape.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadSampleShape.h @@ -51,7 +51,7 @@ private: void exec() override; }; void DLLExport rotate(Geometry::MeshObject &sampleMesh, - API::MatrixWorkspace_const_sptr inputWS); + const API::MatrixWorkspace_const_sptr &inputWS); } // namespace DataHandling } // namespace Mantid \ No newline at end of file diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadSassena.h b/Framework/DataHandling/inc/MantidDataHandling/LoadSassena.h index a096ef48ae13878c266c8a73819811aa63410fbc..868bf2eaeec30b4ddc855ef3f1590450b15862ed 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadSassena.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadSassena.h @@ -62,26 +62,27 @@ public: protected: /// Add a workspace to the group and register in the analysis data service - void registerWorkspace(API::WorkspaceGroup_sptr gws, const std::string wsName, - DataObjects::Workspace2D_sptr ws, + void registerWorkspace(const API::WorkspaceGroup_sptr &gws, + const std::string &wsName, + const DataObjects::Workspace2D_sptr &ws, const std::string &description); /// Read info about one HDF5 dataset, log if error - herr_t dataSetInfo(const hid_t &h5file, const std::string setName, + herr_t dataSetInfo(const hid_t &h5file, const std::string &setName, hsize_t *dims) const; /// Read dataset data to a buffer ot type double - herr_t dataSetDouble(const hid_t &h5file, const std::string setName, + herr_t dataSetDouble(const hid_t &h5file, const std::string &setName, std::vector<double> &buf); /// Load qvectors dataset, calculate modulus of vectors HistogramData::Points loadQvectors(const hid_t &h5file, - API::WorkspaceGroup_sptr gws, + const API::WorkspaceGroup_sptr &gws, std::vector<int> &sorting_indexes); /// Load structure factor asa function of q-vector modulus - void loadFQ(const hid_t &h5file, API::WorkspaceGroup_sptr gws, - const std::string setName, const HistogramData::Points &qvmod, + void loadFQ(const hid_t &h5file, const API::WorkspaceGroup_sptr &gws, + const std::string &setName, const HistogramData::Points &qvmod, const std::vector<int> &sorting_indexes); /// Load time-dependent structure factor - void loadFQT(const hid_t &h5file, API::WorkspaceGroup_sptr gws, - const std::string setName, const HistogramData::Points &qvmod, + void loadFQT(const hid_t &h5file, const API::WorkspaceGroup_sptr &gws, + const std::string &setName, const HistogramData::Points &qvmod, const std::vector<int> &sorting_indexes); private: diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadSpice2D.h b/Framework/DataHandling/inc/MantidDataHandling/LoadSpice2D.h index d88b9cb7b75203a720af4bd415a0f6582d34be15..44282d49fa10f11bfe453f968b15056b3b50e5c2 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadSpice2D.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadSpice2D.h @@ -93,7 +93,7 @@ private: const std::string &fileName); /// Run LoadInstrument Child Algorithm void runLoadInstrument(const std::string &inst_name, - DataObjects::Workspace2D_sptr localWorkspace); + const DataObjects::Workspace2D_sptr &localWorkspace); void setInputPropertiesAsMemberProperties(); diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadSpiceAscii.h b/Framework/DataHandling/inc/MantidDataHandling/LoadSpiceAscii.h index 921e9c70de08d57b806794e619461f597f9b1009..933ba795ff60126f514a5691a8b5010ba9d8c01b 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadSpiceAscii.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadSpiceAscii.h @@ -63,13 +63,13 @@ private: const std::string &timeformat); /// Set up run start time - void setupRunStartTime(API::MatrixWorkspace_sptr runinfows, + void setupRunStartTime(const API::MatrixWorkspace_sptr &runinfows, const std::vector<std::string> &datetimeprop); /// Add property to workspace template <typename T> - void addProperty(API::MatrixWorkspace_sptr ws, const std::string &pname, - T pvalue); + void addProperty(const API::MatrixWorkspace_sptr &ws, + const std::string &pname, T pvalue); }; } // namespace DataHandling diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadSpiceXML2DDet.h b/Framework/DataHandling/inc/MantidDataHandling/LoadSpiceXML2DDet.h index d94532db83bbe5f5f348fe41cded5e335e24b5a9..16779c563688f8f2c7c01d6dd91b6ad32f42aff5 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadSpiceXML2DDet.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadSpiceXML2DDet.h @@ -96,22 +96,25 @@ private: /// Set up sample logs from table workspace loaded where SPICE data file is /// loaded - void setupSampleLogFromSpiceTable(API::MatrixWorkspace_sptr matrixws, - API::ITableWorkspace_sptr spicetablews, - int ptnumber); + void + setupSampleLogFromSpiceTable(const API::MatrixWorkspace_sptr &matrixws, + const API::ITableWorkspace_sptr &spicetablews, + int ptnumber); /// Set up sample logs in the output workspace - bool setupSampleLogs(API::MatrixWorkspace_sptr outws); + bool setupSampleLogs(const API::MatrixWorkspace_sptr &outws); /// Load instrument void loadInstrument(API::MatrixWorkspace_sptr matrixws, const std::string &idffilename); /// Get wavelength from workspace - bool getHB3AWavelength(API::MatrixWorkspace_sptr dataws, double &wavelength); + bool getHB3AWavelength(const API::MatrixWorkspace_sptr &dataws, + double &wavelength); /// Set output workspace's X-axs as lab-frame Q space - void setXtoLabQ(API::MatrixWorkspace_sptr dataws, const double &wavelength); + void setXtoLabQ(const API::MatrixWorkspace_sptr &dataws, + const double &wavelength); /// SPICE detector XML file std::string m_detXMLFileName; diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadStl.h b/Framework/DataHandling/inc/MantidDataHandling/LoadStl.h index 49241fa4bb8cd7f27626df2844e6d6370aa56a54..70f438c3e3f1dea953944c28d549a71232615ca4 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadStl.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadStl.h @@ -14,6 +14,10 @@ #include <boost/functional/hash.hpp> #include <functional> #include <unordered_set> +#include <utility> + +#include <utility> + namespace { Mantid::Kernel::Logger g_logstl("LoadStl"); } @@ -45,11 +49,12 @@ struct V3DTrueComparator { class DLLExport LoadStl : public MeshFileIO { public: LoadStl(std::string filename, ScaleUnits scaleType) - : MeshFileIO(scaleType), m_filename(filename), m_setMaterial(false) {} + : MeshFileIO(scaleType), m_filename(std::move(std::move(filename))), + m_setMaterial(false) {} LoadStl(std::string filename, ScaleUnits scaleType, ReadMaterial::MaterialParameters params) - : MeshFileIO(scaleType), m_filename(filename), m_setMaterial(true), - m_params(params) {} + : MeshFileIO(scaleType), m_filename(std::move(std::move(filename))), + m_setMaterial(true), m_params(std::move(std::move(params))) {} virtual std::unique_ptr<Geometry::MeshObject> readStl() = 0; virtual ~LoadStl() = default; diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadStlFactory.h b/Framework/DataHandling/inc/MantidDataHandling/LoadStlFactory.h index 07d00e4119f4b49ccf81dba90c03d72533eaea0a..5fa31d720d3dcbb732459b9554e0a53947eebd95 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadStlFactory.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadStlFactory.h @@ -15,7 +15,7 @@ namespace DataHandling { class MANTID_DATAHANDLING_DLL LoadStlFactory { public: - static std::unique_ptr<LoadStl> createReader(std::string filename, + static std::unique_ptr<LoadStl> createReader(const std::string &filename, ScaleUnits scaleType) { std::unique_ptr<LoadStl> reader = nullptr; if (LoadBinaryStl::isBinarySTL(filename)) { diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadTBL.h b/Framework/DataHandling/inc/MantidDataHandling/LoadTBL.h index f0735d097a4b17e2f3420d4a3800e4703a54430f..b0b805b2b947dbca71aeb88e49ac3779d1fd06d0 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadTBL.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadTBL.h @@ -52,13 +52,13 @@ private: size_t getCells(std::string line, std::vector<std::string> &cols, size_t expectedCommas, bool isOldTBL) const; /// count the number of commas in the line - size_t countCommas(std::string line) const; + size_t countCommas(const std::string &line) const; /// find all pairs of quotes in the line - size_t findQuotePairs(std::string line, + size_t findQuotePairs(const std::string &line, std::vector<std::vector<size_t>> "eBounds) const; /// Parse more complex CSV, used when the data involves commas in the data and /// quoted values - void csvParse(std::string line, std::vector<std::string> &cols, + void csvParse(const std::string &line, std::vector<std::string> &cols, std::vector<std::vector<size_t>> "eBounds, size_t expectedCommas) const; }; diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadTOFRawNexus.h b/Framework/DataHandling/inc/MantidDataHandling/LoadTOFRawNexus.h index e2275e1142d8692c3c84175dbf88699d0bdf6d82..2bced73be98aa817733b6259fb46fee170cabd58 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadTOFRawNexus.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadTOFRawNexus.h @@ -79,7 +79,8 @@ protected: Mantid::NeXus::NXEntry &entry); void loadBank(const std::string &nexusfilename, const std::string &entry_name, - const std::string &bankName, API::MatrixWorkspace_sptr WS, + const std::string &bankName, + const API::MatrixWorkspace_sptr &WS, const detid2index_map &id_to_wi); /// List of the absolute time of each pulse diff --git a/Framework/DataHandling/inc/MantidDataHandling/MaskDetectors.h b/Framework/DataHandling/inc/MantidDataHandling/MaskDetectors.h index 348d60b27da180164b5fede1104ac1fe6e76811c..bed7624a812692c2b1450e279b5ee90863542302 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/MaskDetectors.h +++ b/Framework/DataHandling/inc/MantidDataHandling/MaskDetectors.h @@ -78,41 +78,42 @@ private: /// Choose how to mask given that we have a mask workspace void - handleMaskByMaskWorkspace(const DataObjects::MaskWorkspace_const_sptr maskWs, - const API::MatrixWorkspace_const_sptr WS, + handleMaskByMaskWorkspace(const DataObjects::MaskWorkspace_const_sptr &maskWs, + const API::MatrixWorkspace_const_sptr &WS, std::vector<detid_t> &detectorList, std::vector<size_t> &indexList, const RangeInfo &rangeInfo); /// Choose how to mask given that we have a matrix workspace - void handleMaskByMatrixWorkspace(const API::MatrixWorkspace_const_sptr maskWs, - const API::MatrixWorkspace_const_sptr WS, - std::vector<detid_t> &detectorList, - std::vector<size_t> &indexList, - const RangeInfo &rangeInfo); + void + handleMaskByMatrixWorkspace(const API::MatrixWorkspace_const_sptr &maskWs, + const API::MatrixWorkspace_const_sptr &WS, + std::vector<detid_t> &detectorList, + std::vector<size_t> &indexList, + const RangeInfo &rangeInfo); - void execPeaks(DataObjects::PeaksWorkspace_sptr WS); + void execPeaks(const DataObjects::PeaksWorkspace_sptr &WS); void fillIndexListFromSpectra(std::vector<size_t> &indexList, std::vector<Indexing::SpectrumNumber> spectraList, - const API::MatrixWorkspace_sptr WS, + const API::MatrixWorkspace_sptr &WS, const RangeInfo &range_info); void appendToDetectorListFromComponentList( std::vector<detid_t> &detectorList, const std::vector<std::string> &componentList, - const API::MatrixWorkspace_const_sptr WS); - void - appendToIndexListFromWS(std::vector<size_t> &indexList, - const API::MatrixWorkspace_const_sptr maskedWorkspace, - const RangeInfo &range_info); + const API::MatrixWorkspace_const_sptr &WS); + void appendToIndexListFromWS( + std::vector<size_t> &indexList, + const API::MatrixWorkspace_const_sptr &maskedWorkspace, + const RangeInfo &range_info); void appendToDetectorListFromWS( std::vector<detid_t> &detectorList, - const API::MatrixWorkspace_const_sptr inputWs, - const API::MatrixWorkspace_const_sptr maskWs, + const API::MatrixWorkspace_const_sptr &inputWs, + const API::MatrixWorkspace_const_sptr &maskWs, const std::tuple<size_t, size_t, bool> &range_info); void appendToIndexListFromMaskWS( std::vector<size_t> &indexList, - const DataObjects::MaskWorkspace_const_sptr maskedWorkspace, + const DataObjects::MaskWorkspace_const_sptr &maskedWorkspace, const std::tuple<size_t, size_t, bool> &range_info); void extractMaskedWSDetIDs(std::vector<detid_t> &detectorList, diff --git a/Framework/DataHandling/inc/MantidDataHandling/MaskDetectorsInShape.h b/Framework/DataHandling/inc/MantidDataHandling/MaskDetectorsInShape.h index 3cfa902ea957396d54e65ac5a5c55302501313d0..470d7a07065bac5024d3115dabde625150032913 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/MaskDetectorsInShape.h +++ b/Framework/DataHandling/inc/MantidDataHandling/MaskDetectorsInShape.h @@ -58,11 +58,12 @@ private: void exec() override; // internal functions - std::vector<int> runFindDetectorsInShape(API::MatrixWorkspace_sptr workspace, - const std::string shapeXML, - const bool includeMonitors); + std::vector<int> + runFindDetectorsInShape(const API::MatrixWorkspace_sptr &workspace, + const std::string &shapeXML, + const bool includeMonitors); /// Calls MaskDetectors as a Child Algorithm - void runMaskDetectors(API::MatrixWorkspace_sptr workspace, + void runMaskDetectors(const API::MatrixWorkspace_sptr &workspace, const std::vector<int> &detectorIds); }; diff --git a/Framework/DataHandling/inc/MantidDataHandling/MeshFileIO.h b/Framework/DataHandling/inc/MantidDataHandling/MeshFileIO.h index cfaecf881b60414ed185bb25bcba592a0a795fab..836cbfa262b5f165b998d815893bc4b6cd596e03 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/MeshFileIO.h +++ b/Framework/DataHandling/inc/MantidDataHandling/MeshFileIO.h @@ -4,6 +4,10 @@ // NScD Oak Ridge National Laboratory, European Spallation Source, // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + +#include <utility> + +#include <utility> + #include "MantidGeometry/Objects/MeshObject.h" #include "MantidKernel/Logger.h" #include "MantidKernel/Matrix.h" @@ -32,7 +36,7 @@ public: boost::shared_ptr<Geometry::MeshObject> translate(boost::shared_ptr<Geometry::MeshObject> environmentMesh, - const std::vector<double> translationVector); + const std::vector<double> &translationVector); Kernel::V3D createScaledV3D(double xVal, double yVal, double zVal); @@ -40,7 +44,8 @@ protected: MeshFileIO(ScaleUnits scaleType) : m_scaleType(scaleType) {} MeshFileIO(ScaleUnits scaleType, std::vector<uint32_t> triangles, std::vector<Kernel::V3D> vertices) - : m_scaleType(scaleType), m_triangle(triangles), m_vertices(vertices) {} + : m_scaleType(scaleType), m_triangle(std::move(std::move(triangles))), + m_vertices(std::move(std::move(vertices))) {} double scaleValue(double val) { switch (m_scaleType) { case ScaleUnits::centimetres: diff --git a/Framework/DataHandling/inc/MantidDataHandling/PDLoadCharacterizations.h b/Framework/DataHandling/inc/MantidDataHandling/PDLoadCharacterizations.h index 269124451da6e5d60d1e3f70c9ab15b44103399c..0a56541102e2d0c9cf0912ec3e2820b1524aec08 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/PDLoadCharacterizations.h +++ b/Framework/DataHandling/inc/MantidDataHandling/PDLoadCharacterizations.h @@ -32,7 +32,7 @@ private: void init() override; void exec() override; std::vector<std::string> getFilenames(); - int readFocusInfo(std::ifstream &file, const std::string filename); + int readFocusInfo(std::ifstream &file, const std::string &filename); void readCharInfo(std::ifstream &file, API::ITableWorkspace_sptr &wksp, const std::string &filename, int linenum); void readVersion0(const std::string &filename, diff --git a/Framework/DataHandling/inc/MantidDataHandling/ReadMaterial.h b/Framework/DataHandling/inc/MantidDataHandling/ReadMaterial.h index 8333dba7bdaaba21336e122b020442c7c4cd2d30..5b9e50cf67c841f6f145b4e341906287fb627bd5 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/ReadMaterial.h +++ b/Framework/DataHandling/inc/MantidDataHandling/ReadMaterial.h @@ -88,7 +88,7 @@ private: */ Kernel::MaterialBuilder builder; - void setMaterial(const std::string chemicalSymbol, const int atomicNumber, + void setMaterial(const std::string &chemicalSymbol, const int atomicNumber, const int massNumber); void diff --git a/Framework/DataHandling/inc/MantidDataHandling/SampleEnvironmentSpecParser.h b/Framework/DataHandling/inc/MantidDataHandling/SampleEnvironmentSpecParser.h index c33a6590a50ccd2992d05fa3681b648fa7e1d506..78c8749ad34f366c0b06e7c4004a57b271b7595b 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/SampleEnvironmentSpecParser.h +++ b/Framework/DataHandling/inc/MantidDataHandling/SampleEnvironmentSpecParser.h @@ -55,10 +55,10 @@ private: boost::shared_ptr<Geometry::MeshObject> loadMeshFromSTL(Poco::XML::Element *stlfile) const; void LoadOptionalDoubleFromXML(Poco::XML::Element *componentElement, - std::string elementName, + const std::string &elementName, double &targetVariable) const; std::vector<double> - parseTranslationVector(std::string translationVectorStr) const; + parseTranslationVector(const std::string &translationVectorStr) const; // Members MaterialsIndex m_materials; std::string m_filepath; diff --git a/Framework/DataHandling/inc/MantidDataHandling/SaveAscii2.h b/Framework/DataHandling/inc/MantidDataHandling/SaveAscii2.h index 42390a7540bfcb0fd61674df709e044400b4195c..f8200d93c8dd6ff7825c0b7b4a031b8b5a63c218 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/SaveAscii2.h +++ b/Framework/DataHandling/inc/MantidDataHandling/SaveAscii2.h @@ -71,7 +71,7 @@ private: void init() override; /// Overwrites Algorithm method void exec() override; - void writeTableWorkspace(API::ITableWorkspace_const_sptr tws, + void writeTableWorkspace(const API::ITableWorkspace_const_sptr &tws, const std::string &filename, bool appendToFile, bool writeHeader, int prec, bool scientific, const std::string &comment); diff --git a/Framework/DataHandling/inc/MantidDataHandling/SaveCSV.h b/Framework/DataHandling/inc/MantidDataHandling/SaveCSV.h index d5cc8447598607ebd7a5f3775130bf5ff87f87e7..90f55bf118cd0c9d65a482245ca45288594bb8cd 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/SaveCSV.h +++ b/Framework/DataHandling/inc/MantidDataHandling/SaveCSV.h @@ -93,7 +93,7 @@ private: /// Saves out x errors void saveXerrors(std::ofstream &stream, - const Mantid::DataObjects::Workspace2D_sptr workspace, + const Mantid::DataObjects::Workspace2D_sptr &workspace, const size_t numberOfHist); /// The name of the file used for storing the workspace diff --git a/Framework/DataHandling/inc/MantidDataHandling/SaveCalFile.h b/Framework/DataHandling/inc/MantidDataHandling/SaveCalFile.h index 00a1032d55f1b05b373e55b4cec183a5147d0914..4517ae2f2110875514cc96bc4156c7321acda561 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/SaveCalFile.h +++ b/Framework/DataHandling/inc/MantidDataHandling/SaveCalFile.h @@ -46,9 +46,9 @@ public: } void saveCalFile(const std::string &calFileName, - Mantid::DataObjects::GroupingWorkspace_sptr groupWS, - Mantid::DataObjects::OffsetsWorkspace_sptr offsetsWS, - Mantid::DataObjects::MaskWorkspace_sptr maskWS); + const Mantid::DataObjects::GroupingWorkspace_sptr &groupWS, + const Mantid::DataObjects::OffsetsWorkspace_sptr &offsetsWS, + const Mantid::DataObjects::MaskWorkspace_sptr &maskWS); private: /// Initialise the properties diff --git a/Framework/DataHandling/inc/MantidDataHandling/SaveDetectorsGrouping.h b/Framework/DataHandling/inc/MantidDataHandling/SaveDetectorsGrouping.h index fc19656f86a96c247cb9fc298a3e9d8d350d7e89..c074c823132132df31cad6ab4b0f6f90fae5237c 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/SaveDetectorsGrouping.h +++ b/Framework/DataHandling/inc/MantidDataHandling/SaveDetectorsGrouping.h @@ -53,8 +53,8 @@ private: std::map<int, std::vector<detid_t>> &groupdetidrangemap); /// Print Grouping to XML file - void printToXML(std::map<int, std::vector<detid_t>> groupdetidrangemap, - std::string xmlfilename); + void printToXML(const std::map<int, std::vector<detid_t>> &groupdetidrangemap, + const std::string &xmlfilename); // GroupingWorkspace DataObjects::GroupingWorkspace_const_sptr mGroupWS; diff --git a/Framework/DataHandling/inc/MantidDataHandling/SaveDiffCal.h b/Framework/DataHandling/inc/MantidDataHandling/SaveDiffCal.h index 89bdadbcf618ab3bf33535e7168cacccb74d6153..31208c7163e9e419bf0a499bc6759d1b05b6d1c1 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/SaveDiffCal.h +++ b/Framework/DataHandling/inc/MantidDataHandling/SaveDiffCal.h @@ -37,8 +37,9 @@ private: void writeDoubleFieldFromTable(H5::Group &group, const std::string &name); void writeIntFieldFromTable(H5::Group &group, const std::string &name); - void writeIntFieldFromSVWS(H5::Group &group, const std::string &name, - DataObjects::SpecialWorkspace2D_const_sptr ws); + void + writeIntFieldFromSVWS(H5::Group &group, const std::string &name, + const DataObjects::SpecialWorkspace2D_const_sptr &ws); void generateDetidToIndex(); bool tableHasColumn(const std::string &ColumnName) const; diff --git a/Framework/DataHandling/inc/MantidDataHandling/SaveDiffFittingAscii.h b/Framework/DataHandling/inc/MantidDataHandling/SaveDiffFittingAscii.h index ed595087a6c93394be00c5b86d401869b8133545..3c21f96289b1ec337303fc1b647c54dbfc5786e6 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/SaveDiffFittingAscii.h +++ b/Framework/DataHandling/inc/MantidDataHandling/SaveDiffFittingAscii.h @@ -57,7 +57,7 @@ private: std::map<std::string, std::string> validateInputs() override; /// Main exec routine, called for group or individual workspace processing. - void processAll(const std::vector<API::ITableWorkspace_sptr> input_ws); + void processAll(const std::vector<API::ITableWorkspace_sptr> &input_ws); std::vector<std::string> splitList(std::string strList); @@ -67,8 +67,8 @@ private: void writeHeader(const std::vector<std::string> &columnHeadings, std::ofstream &file); - void writeData(const API::ITableWorkspace_sptr workspace, std::ofstream &file, - const size_t columnSize); + void writeData(const API::ITableWorkspace_sptr &workspace, + std::ofstream &file, const size_t columnSize); void writeVal(const std::string &val, std::ofstream &file, const bool endline); diff --git a/Framework/DataHandling/inc/MantidDataHandling/SaveDspacemap.h b/Framework/DataHandling/inc/MantidDataHandling/SaveDspacemap.h index 8a8bffd0901741cc6e348c397dc56772b6ae30f7..37581742e89b42152724fe74d9c98fff69f98b3e 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/SaveDspacemap.h +++ b/Framework/DataHandling/inc/MantidDataHandling/SaveDspacemap.h @@ -39,9 +39,9 @@ private: /// Run the algorithm void exec() override; - void - CalculateDspaceFromCal(Mantid::DataObjects::OffsetsWorkspace_sptr offsetsWS, - std::string DFileName); + void CalculateDspaceFromCal( + const Mantid::DataObjects::OffsetsWorkspace_sptr &offsetsWS, + const std::string &DFileName); }; } // namespace DataHandling diff --git a/Framework/DataHandling/inc/MantidDataHandling/SaveFITS.h b/Framework/DataHandling/inc/MantidDataHandling/SaveFITS.h index 9542b929f17b50ee990dd21e951e90c4553bddf0..9c4afe889aa51f62ada4f52cc0566480b75a3860 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/SaveFITS.h +++ b/Framework/DataHandling/inc/MantidDataHandling/SaveFITS.h @@ -36,20 +36,20 @@ private: std::map<std::string, std::string> validateInputs() override; - void saveFITSImage(const API::MatrixWorkspace_sptr img, + void saveFITSImage(const API::MatrixWorkspace_sptr &img, const std::string &filename); - void writeFITSHeaderBlock(const API::MatrixWorkspace_sptr img, + void writeFITSHeaderBlock(const API::MatrixWorkspace_sptr &img, std::ofstream &file); - void writeFITSImageMatrix(const API::MatrixWorkspace_sptr img, + void writeFITSImageMatrix(const API::MatrixWorkspace_sptr &img, std::ofstream &file); void writeFITSHeaderEntry(const std::string &hdr, std::ofstream &file); std::string makeBitDepthHeader(size_t depth) const; - void writeFITSHeaderAxesSizes(const API::MatrixWorkspace_sptr img, + void writeFITSHeaderAxesSizes(const API::MatrixWorkspace_sptr &img, std::ofstream &file); void writePaddingFITSHeaders(size_t count, std::ofstream &file); diff --git a/Framework/DataHandling/inc/MantidDataHandling/SaveFullprofResolution.h b/Framework/DataHandling/inc/MantidDataHandling/SaveFullprofResolution.h index 5dd4317b12db6decdf26f19a0fc493ba8e22662c..2ce04b6bce0901256770d5a44200a1d6385aeb9d 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/SaveFullprofResolution.h +++ b/Framework/DataHandling/inc/MantidDataHandling/SaveFullprofResolution.h @@ -57,7 +57,7 @@ private: void parseTableWorkspace(); /// Check wether a profile parameter map has the parameter - bool has_key(std::map<std::string, double> profmap, std::string key); + bool has_key(std::map<std::string, double> profmap, const std::string &key); /// Map containing the name of value of each parameter required by .irf file std::map<std::string, double> m_profileParamMap; diff --git a/Framework/DataHandling/inc/MantidDataHandling/SaveGSASInstrumentFile.h b/Framework/DataHandling/inc/MantidDataHandling/SaveGSASInstrumentFile.h index 0ac855d14a38f79832e15ecef497c1876a518cd1..a0024f2f5b488a04c6ca1c29173206c24250c426 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/SaveGSASInstrumentFile.h +++ b/Framework/DataHandling/inc/MantidDataHandling/SaveGSASInstrumentFile.h @@ -66,7 +66,7 @@ private: /// Parse profile table workspace to a map void parseProfileTableWorkspace( - API::ITableWorkspace_sptr ws, + const API::ITableWorkspace_sptr &ws, std::map<unsigned int, std::map<std::string, double>> &profilemap); /// Convert to GSAS instrument file @@ -113,7 +113,7 @@ private: const std::string ¶mname); /// Load fullprof resolution file. - void loadFullprofResolutionFile(std::string irffilename); + void loadFullprofResolutionFile(const std::string &irffilename); /// Calcualte d-space value. double calDspRange(double dtt1, double zero, double tof); diff --git a/Framework/DataHandling/inc/MantidDataHandling/SaveIsawDetCal.h b/Framework/DataHandling/inc/MantidDataHandling/SaveIsawDetCal.h index e3a928646e4c779fd26df3e789de7d2f4a5b402b..2589c5a0b3971398f99f09cdf63f9fce0f6e9044 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/SaveIsawDetCal.h +++ b/Framework/DataHandling/inc/MantidDataHandling/SaveIsawDetCal.h @@ -46,9 +46,9 @@ private: /// Run the algorithm void exec() override; /// find position for rectangular and non-rectangular - Kernel::V3D findPixelPos(std::string bankName, int col, int row); - void sizeBanks(std::string bankName, int &NCOLS, int &NROWS, double &xsize, - double &ysize); + Kernel::V3D findPixelPos(const std::string &bankName, int col, int row); + void sizeBanks(const std::string &bankName, int &NCOLS, int &NROWS, + double &xsize, double &ysize); Geometry::Instrument_const_sptr inst; }; diff --git a/Framework/DataHandling/inc/MantidDataHandling/SaveNXTomo.h b/Framework/DataHandling/inc/MantidDataHandling/SaveNXTomo.h index 8bef56681d2a08de8f7beda2377cebd929aed092..7a681a780a2138c96418980a8fa2952f7d9471f8 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/SaveNXTomo.h +++ b/Framework/DataHandling/inc/MantidDataHandling/SaveNXTomo.h @@ -87,16 +87,16 @@ private: ::NeXus::File setupFile(); /// Writes a single workspace into the file - void writeSingleWorkspace(const DataObjects::Workspace2D_sptr workspace, + void writeSingleWorkspace(const DataObjects::Workspace2D_sptr &workspace, ::NeXus::File &nxFile); /// Write various pieces of data from the workspace log with checks on the /// structure of the nexus file - void writeLogValues(const DataObjects::Workspace2D_sptr workspace, + void writeLogValues(const DataObjects::Workspace2D_sptr &workspace, ::NeXus::File &nxFile, int thisFileInd); - void writeIntensityValue(const DataObjects::Workspace2D_sptr workspace, + void writeIntensityValue(const DataObjects::Workspace2D_sptr &workspace, ::NeXus::File &nxFile, int thisFileInd); - void writeImageKeyValue(const DataObjects::Workspace2D_sptr workspace, + void writeImageKeyValue(const DataObjects::Workspace2D_sptr &workspace, ::NeXus::File &nxFile, int thisFileInd); /// Main exec routine, called for group or individual workspace processing. diff --git a/Framework/DataHandling/inc/MantidDataHandling/SaveNexusProcessed.h b/Framework/DataHandling/inc/MantidDataHandling/SaveNexusProcessed.h index 9f918dd374be63f0115a72deaa175d7bffc5d79a..89c4f0f0f537281717fd740805302f391213bf03 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/SaveNexusProcessed.h +++ b/Framework/DataHandling/inc/MantidDataHandling/SaveNexusProcessed.h @@ -74,8 +74,9 @@ protected: void exec() override; private: - void getWSIndexList(std::vector<int> &indices, - Mantid::API::MatrixWorkspace_const_sptr matrixWorkspace); + void getWSIndexList( + std::vector<int> &indices, + const Mantid::API::MatrixWorkspace_const_sptr &matrixWorkspace); template <class T> static void appendEventListData(const std::vector<T> &events, size_t offset, @@ -88,7 +89,7 @@ private: void setOtherProperties(IAlgorithm *alg, const std::string &propertyName, const std::string &propertyValue, int perioidNum) override; - void doExec(Mantid::API::Workspace_sptr inputWorkspace, + void doExec(const Mantid::API::Workspace_sptr &inputWorkspace, boost::shared_ptr<Mantid::NeXus::NexusFileIO> &nexusFile, const bool keepFile = false, boost::optional<size_t> entryNumber = boost::optional<size_t>()); diff --git a/Framework/DataHandling/inc/MantidDataHandling/SavePDFGui.h b/Framework/DataHandling/inc/MantidDataHandling/SavePDFGui.h index 8450d6896e798286e7b49855f60f4ad61ec066db..8c95297a31f7e4eb6ee34fef995387927cb75f83 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/SavePDFGui.h +++ b/Framework/DataHandling/inc/MantidDataHandling/SavePDFGui.h @@ -36,8 +36,9 @@ private: void init() override; void exec() override; void writeMetaData(std::ofstream &out, - API::MatrixWorkspace_const_sptr inputWS); - void writeWSData(std::ofstream &out, API::MatrixWorkspace_const_sptr inputWS); + const API::MatrixWorkspace_const_sptr &inputWS); + void writeWSData(std::ofstream &out, + const API::MatrixWorkspace_const_sptr &inputWS); }; } // namespace DataHandling diff --git a/Framework/DataHandling/inc/MantidDataHandling/SaveRMCProfile.h b/Framework/DataHandling/inc/MantidDataHandling/SaveRMCProfile.h index eeb3cb7e7218dc58c63cc32167c6b541e77cea80..c8c67ab28d4d6f8b48a9e08c2330854e5e0b39da 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/SaveRMCProfile.h +++ b/Framework/DataHandling/inc/MantidDataHandling/SaveRMCProfile.h @@ -36,8 +36,9 @@ private: void init() override; void exec() override; void writeMetaData(std::ofstream &out, - API::MatrixWorkspace_const_sptr inputWS); - void writeWSData(std::ofstream &out, API::MatrixWorkspace_const_sptr inputWS); + const API::MatrixWorkspace_const_sptr &inputWS); + void writeWSData(std::ofstream &out, + const API::MatrixWorkspace_const_sptr &inputWS); }; } // namespace DataHandling diff --git a/Framework/DataHandling/inc/MantidDataHandling/SaveReflectometryAscii.h b/Framework/DataHandling/inc/MantidDataHandling/SaveReflectometryAscii.h index 3bc16d6fc8034312767f5cde4e66cae11187c0bd..f809ddceca51b9438212b2f84ae448c6d4d5df70 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/SaveReflectometryAscii.h +++ b/Framework/DataHandling/inc/MantidDataHandling/SaveReflectometryAscii.h @@ -49,22 +49,22 @@ private: /// Algorithm execution for WorkspaceGroups bool processGroups() override; /// Check file validity - void checkFile(const std::string filename); + void checkFile(const std::string &filename); /// Write the data void data(); /// Print a double value to file void outputval(double val); /// Write a string value - bool writeString(bool write, std::string s); + bool writeString(bool write, const std::string &s); /// Print a string value to file - void outputval(std::string val); + void outputval(const std::string &val); /// Retrieve sample log value std::string sampleLogValue(const std::string &logName); /// Retrieve sample log unit std::string sampleLogUnit(const std::string &logName); /// Write one header line - void writeInfo(const std::string logName, - const std::string logNameFixed = ""); + void writeInfo(const std::string &logName, + const std::string &logNameFixed = ""); /// Write header void header(); /// Determine the separator diff --git a/Framework/DataHandling/inc/MantidDataHandling/SaveSPE.h b/Framework/DataHandling/inc/MantidDataHandling/SaveSPE.h index 52ff3ccbfa93054f69619816b3851ec3041d7cc2..e755e6695aa0169d528674bcb44822fb2a620fcd 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/SaveSPE.h +++ b/Framework/DataHandling/inc/MantidDataHandling/SaveSPE.h @@ -82,9 +82,9 @@ private: void writeSPEFile(FILE *outSPEFile, const API::MatrixWorkspace_const_sptr &inputWS); - void writeHists(const API::MatrixWorkspace_const_sptr WS, + void writeHists(const API::MatrixWorkspace_const_sptr &WS, FILE *const outFile); - void writeHist(const API::MatrixWorkspace_const_sptr WS, FILE *const outFile, + void writeHist(const API::MatrixWorkspace_const_sptr &WS, FILE *const outFile, const int wsIn) const; void writeMaskFlags(FILE *const outFile) const; void writeBins(const std::vector<double> &Vs, FILE *const outFile) const; diff --git a/Framework/DataHandling/inc/MantidDataHandling/SaveStl.h b/Framework/DataHandling/inc/MantidDataHandling/SaveStl.h index bfcfd68fe13c406130e0c2c96aa898d13a0fe39d..5ef1d1bac0110cc3801a65aff138e5374fdf2d4a 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/SaveStl.h +++ b/Framework/DataHandling/inc/MantidDataHandling/SaveStl.h @@ -6,6 +6,10 @@ // SPDX - License - Identifier: GPL - 3.0 + #pragma once +#include <utility> + +#include <utility> + #include "MantidDataHandling/MeshFileIO.h" #include "MantidKernel/BinaryStreamWriter.h" #include "MantidKernel/Logger.h" @@ -25,9 +29,10 @@ enum class ScaleUnits; */ class DLLExport SaveStl : public MeshFileIO { public: - SaveStl(const std::string &filename, const std::vector<uint32_t> triangle, + SaveStl(const std::string &filename, const std::vector<uint32_t> &triangle, std::vector<Kernel::V3D> vertices, ScaleUnits scaleType) - : MeshFileIO(scaleType, triangle, vertices), m_filename(filename) {} + : MeshFileIO(scaleType, triangle, std::move(std::move(vertices))), + m_filename(filename) {} void writeStl(); diff --git a/Framework/DataHandling/inc/MantidDataHandling/SaveTBL.h b/Framework/DataHandling/inc/MantidDataHandling/SaveTBL.h index dd647e3b3ac44efb80009848c8ebe19c3893301d..8e47983f277944003fedfabdbe693790772bd82f 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/SaveTBL.h +++ b/Framework/DataHandling/inc/MantidDataHandling/SaveTBL.h @@ -53,7 +53,7 @@ private: /// the separator const char m_sep; // populates the map and vector containing grouping information - void findGroups(API::ITableWorkspace_sptr ws); + void findGroups(const API::ITableWorkspace_sptr &ws); /// Map the separator options to their string equivalents std::map<int, std::vector<size_t>> m_stichgroups; std::vector<size_t> m_nogroup; diff --git a/Framework/DataHandling/inc/MantidDataHandling/SaveToSNSHistogramNexus.h b/Framework/DataHandling/inc/MantidDataHandling/SaveToSNSHistogramNexus.h index 95eac01ee17e7a692cfbbb5639a6ec61aac535bd..4d581a2352b5ce644c545fa88743735050e60d42 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/SaveToSNSHistogramNexus.h +++ b/Framework/DataHandling/inc/MantidDataHandling/SaveToSNSHistogramNexus.h @@ -95,12 +95,13 @@ private: int copy_file(const char *inFile, int nx_read_access, const char *outFile, int nx_write_access); - int WriteOutDataOrErrors(Geometry::RectangularDetector_const_sptr det, + int WriteOutDataOrErrors(const Geometry::RectangularDetector_const_sptr &det, int x_pixel_slab, const char *field_name, const char *errors_field_name, bool doErrors, - bool doBoth, int is_definition, std::string bank); + bool doBoth, int is_definition, + const std::string &bank); - int WriteDataGroup(std::string bank, int is_definition); + int WriteDataGroup(const std::string &bank, int is_definition); // // // For iterating through the HDF file... diff --git a/Framework/DataHandling/inc/MantidDataHandling/SetScalingPSD.h b/Framework/DataHandling/inc/MantidDataHandling/SetScalingPSD.h index d177bea3bfe1e32d625a10db9a15953a3c144664..55c7170d7b40f49e606b805779ef2276851848b6 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/SetScalingPSD.h +++ b/Framework/DataHandling/inc/MantidDataHandling/SetScalingPSD.h @@ -86,7 +86,8 @@ private: std::map<int, Kernel::V3D> &posMap, std::map<int, double> &scaleMap); /// read the positions of detectors defined in the raw file - void getDetPositionsFromRaw(std::string rawfile, std::vector<int> &detID, + void getDetPositionsFromRaw(const std::string &rawfile, + std::vector<int> &detID, std::vector<Kernel::V3D> &pos); }; diff --git a/Framework/DataHandling/inc/MantidDataHandling/XmlHandler.h b/Framework/DataHandling/inc/MantidDataHandling/XmlHandler.h index b40b4c2f7dceb2d217262423f89bc809e565d9a7..3042711456f481c32cba6d5c76def87301d18567 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/XmlHandler.h +++ b/Framework/DataHandling/inc/MantidDataHandling/XmlHandler.h @@ -21,7 +21,7 @@ namespace DataHandling { class MANTID_DATAHANDLING_DLL XmlHandler { public: XmlHandler() = default; - XmlHandler(std::string); + XmlHandler(const std::string &); std::map<std::string, std::string> get_metadata(const std::vector<std::string> &tags_to_ignore); diff --git a/Framework/DataHandling/src/AppendGeometryToSNSNexus.cpp b/Framework/DataHandling/src/AppendGeometryToSNSNexus.cpp index 9a5ac5075e1915679a34020f3a12e06a04a791e7..762cf3c6eccd687c8b0ee502ff1aa617a5b1e2b5 100644 --- a/Framework/DataHandling/src/AppendGeometryToSNSNexus.cpp +++ b/Framework/DataHandling/src/AppendGeometryToSNSNexus.cpp @@ -360,8 +360,8 @@ AppendGeometryToSNSNexus::getInstrumentName(const std::string &nxfilename) { */ bool AppendGeometryToSNSNexus::runLoadInstrument( - const std::string &idf_filename, API::MatrixWorkspace_sptr localWorkspace, - Algorithm *alg) { + const std::string &idf_filename, + const API::MatrixWorkspace_sptr &localWorkspace, Algorithm *alg) { IAlgorithm_sptr loadInst = createChildAlgorithm("LoadInstrument", 0, 1, true); // Execute the Child Algorithm. @@ -399,8 +399,8 @@ bool AppendGeometryToSNSNexus::runLoadInstrument( * @return true if successful. */ bool AppendGeometryToSNSNexus::runLoadNexusLogs( - const std::string &nexusFileName, API::MatrixWorkspace_sptr localWorkspace, - Algorithm *alg) { + const std::string &nexusFileName, + const API::MatrixWorkspace_sptr &localWorkspace, Algorithm *alg) { IAlgorithm_sptr loadLogs = alg->createChildAlgorithm("LoadNexusLogs", 0, 1, true); diff --git a/Framework/DataHandling/src/BankPulseTimes.cpp b/Framework/DataHandling/src/BankPulseTimes.cpp index 0340ff8d403cb5a8e7313529ea6157103f60a8d4..02e4ed4436baa0e6d38140e73dfaa9c127f8c7bd 100644 --- a/Framework/DataHandling/src/BankPulseTimes.cpp +++ b/Framework/DataHandling/src/BankPulseTimes.cpp @@ -98,7 +98,8 @@ BankPulseTimes::~BankPulseTimes() { delete[] this->pulseTimes; } * @return true if the pulse times are the same and so don't need to be * reloaded. */ -bool BankPulseTimes::equals(size_t otherNumPulse, std::string otherStartTime) { +bool BankPulseTimes::equals(size_t otherNumPulse, + const std::string &otherStartTime) { return ((this->startTime == otherStartTime) && (this->numPulses == otherNumPulse)); } diff --git a/Framework/DataHandling/src/CreateChunkingFromInstrument.cpp b/Framework/DataHandling/src/CreateChunkingFromInstrument.cpp index 95001bd039db4ad76fc1745c82a4c294e446778c..aa449170b9d58550882ee1aa65f64eff387cda65 100644 --- a/Framework/DataHandling/src/CreateChunkingFromInstrument.cpp +++ b/Framework/DataHandling/src/CreateChunkingFromInstrument.cpp @@ -216,7 +216,7 @@ bool startsWith(const string &str, const string &prefix) { * @return The correct parent name. This is an empty string if the name * isn't found. */ -string parentName(IComponent_const_sptr comp, const string &prefix) { +string parentName(const IComponent_const_sptr &comp, const string &prefix) { // handle the special case of the component has the name if (startsWith(comp->getName(), prefix)) return comp->getName(); @@ -242,7 +242,8 @@ string parentName(IComponent_const_sptr comp, const string &prefix) { * @return The correct parent name. This is an empty string if the name * isn't found. */ -string parentName(IComponent_const_sptr comp, const vector<string> &names) { +string parentName(const IComponent_const_sptr &comp, + const vector<string> &names) { // handle the special case of the component has the name for (const auto &name : names) if (name == comp->getName()) diff --git a/Framework/DataHandling/src/CreateSimulationWorkspace.cpp b/Framework/DataHandling/src/CreateSimulationWorkspace.cpp index d22473db9395b00b85b2addb7c41bf7e71eddc52..e0866c6462a1c5280972e50dc2e1c1519b170d18 100644 --- a/Framework/DataHandling/src/CreateSimulationWorkspace.cpp +++ b/Framework/DataHandling/src/CreateSimulationWorkspace.cpp @@ -38,7 +38,7 @@ struct StartAndEndTime { Mantid::Types::Core::DateAndTime endTime; }; -StartAndEndTime getStartAndEndTimesFromRawFile(std::string filename) { +StartAndEndTime getStartAndEndTimesFromRawFile(const std::string &filename) { FILE *rawFile = fopen(filename.c_str(), "rb"); if (!rawFile) throw std::runtime_error("Cannot open RAW file for reading: " + filename); @@ -58,7 +58,7 @@ StartAndEndTime getStartAndEndTimesFromRawFile(std::string filename) { } StartAndEndTime getStartAndEndTimesFromNexusFile( - std::string filename, + const std::string &filename, const Mantid::Types::Core::DateAndTime &startTimeDefault, const Mantid::Types::Core::DateAndTime &endTimeDefault) { StartAndEndTime startAndEndTime; @@ -411,7 +411,7 @@ void CreateSimulationWorkspace::adjustInstrument(const std::string &filename) { * @param workspace: dummy workspace */ void CreateSimulationWorkspace::setStartDate( - API::MatrixWorkspace_sptr workspace) { + const API::MatrixWorkspace_sptr &workspace) { const std::string detTableFile = getProperty("DetectorTableFilename"); auto hasDetTableFile = !detTableFile.empty(); auto &run = workspace->mutableRun(); diff --git a/Framework/DataHandling/src/DataBlockComposite.cpp b/Framework/DataHandling/src/DataBlockComposite.cpp index 6560c92166de8de041a708c5719142018abe619c..fe4c1e8bb4e21cc02a1bf6024bdba2ac89230569 100644 --- a/Framework/DataHandling/src/DataBlockComposite.cpp +++ b/Framework/DataHandling/src/DataBlockComposite.cpp @@ -208,9 +208,12 @@ std::vector<std::pair<int64_t, int64_t>> spectrumIDIntervals( const std::vector<Mantid::DataHandling::DataBlock> &blocks) { std::vector<std::pair<int64_t, int64_t>> intervals; intervals.reserve(blocks.size()); - for (const auto &block : blocks) { - intervals.emplace_back(block.getMinSpectrumID(), block.getMaxSpectrumID()); - } + + std::transform(blocks.begin(), blocks.end(), std::back_inserter(intervals), + [](const auto &block) { + return std::make_pair(block.getMinSpectrumID(), + block.getMaxSpectrumID()); + }); return intervals; } } // namespace @@ -253,7 +256,7 @@ std::unique_ptr<DataBlockGenerator> DataBlockComposite::getGenerator() const { return std::make_unique<DataBlockGenerator>(intervals); } -void DataBlockComposite::addDataBlock(DataBlock dataBlock) { +void DataBlockComposite::addDataBlock(const DataBlock &dataBlock) { // Set the number of periods, number of spectra and number of channel m_numberOfPeriods = dataBlock.getNumberOfPeriods(); m_numberOfChannels = dataBlock.getNumberOfChannels(); diff --git a/Framework/DataHandling/src/DetermineChunking.cpp b/Framework/DataHandling/src/DetermineChunking.cpp index bb1455036aa919f8f09287f9ab880e8ad536cc5e..fe074a28eee6d1a81f006fb22cd4b681e4691486 100644 --- a/Framework/DataHandling/src/DetermineChunking.cpp +++ b/Framework/DataHandling/src/DetermineChunking.cpp @@ -292,7 +292,7 @@ void DetermineChunking::exec() { } /// set the name of the top level NXentry m_top_entry_name -std::string DetermineChunking::setTopEntryName(std::string filename) { +std::string DetermineChunking::setTopEntryName(const std::string &filename) { std::string top_entry_name; using string_map_t = std::map<std::string, std::string>; try { diff --git a/Framework/DataHandling/src/EventWorkspaceCollection.cpp b/Framework/DataHandling/src/EventWorkspaceCollection.cpp index 860edfe1f730e8276774d32f7d852c8a442dc25a..459a890bd5be949b4bd29d62fd9c19dfbcb6085b 100644 --- a/Framework/DataHandling/src/EventWorkspaceCollection.cpp +++ b/Framework/DataHandling/src/EventWorkspaceCollection.cpp @@ -162,7 +162,7 @@ EventWorkspaceCollection::getSpectrum(const size_t index) const { return m_WsVec[0]->getSpectrum(index); } void EventWorkspaceCollection::setSpectrumNumbersFromUniqueSpectra( - const std::set<int> uniqueSpectra) { + const std::set<int> &uniqueSpectra) { // For each workspace, update all the spectrum numbers for (auto &ws : m_WsVec) { size_t counter = 0; @@ -279,14 +279,14 @@ void EventWorkspaceCollection::setWidth(const float flag) { } } -void EventWorkspaceCollection::setTitle(std::string title) { +void EventWorkspaceCollection::setTitle(const std::string &title) { for (auto &ws : m_WsVec) { ws->setTitle(title); } } void EventWorkspaceCollection::applyFilter( - boost::function<void(MatrixWorkspace_sptr)> func) { + const boost::function<void(MatrixWorkspace_sptr)> &func) { for (auto &ws : m_WsVec) { func(ws); } diff --git a/Framework/DataHandling/src/FilterEventsByLogValuePreNexus.cpp b/Framework/DataHandling/src/FilterEventsByLogValuePreNexus.cpp index 1ace0758f27de18ab26765cb1ab00903b2df1771..b1ee58199cd933414d235b1e1e19863538ef326a 100644 --- a/Framework/DataHandling/src/FilterEventsByLogValuePreNexus.cpp +++ b/Framework/DataHandling/src/FilterEventsByLogValuePreNexus.cpp @@ -671,8 +671,8 @@ void FilterEventsByLogValuePreNexus::processEventLogs() { * @param logtitle :: title of the log to be inserted to workspace * @param mindex :: index of the the series in the wrong detectors map */ -void FilterEventsByLogValuePreNexus::addToWorkspaceLog(std::string logtitle, - size_t mindex) { +void FilterEventsByLogValuePreNexus::addToWorkspaceLog( + const std::string &logtitle, size_t mindex) { // Create TimeSeriesProperty auto property = new TimeSeriesProperty<double>(logtitle); @@ -770,7 +770,8 @@ void FilterEventsByLogValuePreNexus::doStatToEventLog(size_t mindex) { * geometry */ void FilterEventsByLogValuePreNexus::runLoadInstrument( - const std::string &eventfilename, MatrixWorkspace_sptr localWorkspace) { + const std::string &eventfilename, + const MatrixWorkspace_sptr &localWorkspace) { // start by getting just the filename string instrument = Poco::Path(eventfilename).getFileName(); @@ -930,7 +931,6 @@ void FilterEventsByLogValuePreNexus::procEvents( << " threads" << " in " << numBlocks << " blocks. " << "\n"; - // cppcheck-suppress syntaxError PRAGMA_OMP( parallel for schedule(dynamic, 1) if (m_parallelProcessing) ) for (int i = 0; i < int(numThreads); i++) { @@ -954,7 +954,7 @@ void FilterEventsByLogValuePreNexus::procEvents( // value = pointer to the events vector eventVectors[i] = new EventVector_pt[m_detid_max + 1]; EventVector_pt *theseEventVectors = eventVectors[i]; - for (detid_t j = 0; j < m_detid_max + 1; j++) { + for (detid_t j = 0; j < m_detid_max + 1; ++j) { size_t wi = m_pixelToWkspindex[j]; // Save a POINTER to the vector<tofEvent> theseEventVectors[j] = &partWS->getSpectrum(wi).getEvents(); @@ -1133,15 +1133,13 @@ void FilterEventsByLogValuePreNexus::procEventsLinear( << m_maxNumEvents << "\n"; maxeventid = m_maxNumEvents + 1; - size_t numbadeventindex = 0; - int numeventswritten = 0; // Declare local statistic parameters size_t local_numErrorEvents = 0; size_t local_numBadEvents = 0; - size_t local_numWrongdetidEvents = 0; size_t local_numIgnoredEvents = 0; + size_t local_numWrongdetidEvents = 0; size_t local_numGoodEvents = 0; double local_m_shortestTof = static_cast<double>(MAX_TOF_UINT32) * TOF_CONVERSION; @@ -1161,8 +1159,6 @@ void FilterEventsByLogValuePreNexus::procEventsLinear( int64_t i_pulse = 0; for (size_t ievent = 0; ievent < current_event_buffer_size; ++ievent) { - bool iswrongdetid = false; - // Load DasEvent DasEvent &tempevent = *(event_buffer + ievent); @@ -1186,6 +1182,7 @@ void FilterEventsByLogValuePreNexus::procEventsLinear( pixelid = this->m_pixelmap[unmapped_pid]; } + bool iswrongdetid = false; // Check special/wrong pixel IDs against max Detector ID if (pixelid > static_cast<PixelType>(m_detid_max)) { // Record the wrong/special ID @@ -1367,12 +1364,6 @@ void FilterEventsByLogValuePreNexus::procEventsLinear( if (local_m_longestTof > m_longestTof) m_longestTof = local_m_longestTof; } - - if (numbadeventindex > 0) { - g_log.notice() << "Single block: Encountered " << numbadeventindex - << " bad event indexes" - << "\n"; - } } //---------------------------------------------------------------------------------------------- @@ -1558,7 +1549,7 @@ void FilterEventsByLogValuePreNexus::filterEvents() { // value = pointer to the events vector eventVectors[i] = new EventVector_pt[m_detid_max + 1]; EventVector_pt *theseEventVectors = eventVectors[i]; - for (detid_t j = 0; j < m_detid_max + 1; j++) { + for (detid_t j = 0; j < m_detid_max + 1; ++j) { size_t wi = m_pixelToWkspindex[j]; // Save a POINTER to the vector<tofEvent> if (wi != static_cast<size_t>(-1)) @@ -1737,8 +1728,6 @@ void FilterEventsByLogValuePreNexus::filterEventsLinear( << m_maxNumEvents << "\n"; maxeventid = m_maxNumEvents + 1; - size_t numbadeventindex = 0; - // Declare local statistic parameters size_t local_numErrorEvents = 0; size_t local_numBadEvents = 0; @@ -1824,8 +1813,6 @@ void FilterEventsByLogValuePreNexus::filterEventsLinear( g_log.notice() << "[DB] L1 = " << l1 << "\n"; for (size_t ievent = 0; ievent < current_event_buffer_size; ++ievent) { - bool iswrongdetid = false; - bool islogevent = false; // Load DasEvent DasEvent &tempevent = *(event_buffer + ievent); @@ -1840,6 +1827,9 @@ void FilterEventsByLogValuePreNexus::filterEventsLinear( local_numBadEvents++; continue; } else { + bool islogevent = false; + bool iswrongdetid = false; + // Covert DAS Pixel ID to Mantid Pixel ID if (pixelid == 1073741843) { // downstream monitor pixel for SNAP @@ -2107,8 +2097,6 @@ void FilterEventsByLogValuePreNexus::filterEventsLinear( m_longestTof = local_m_longestTof; } - g_log.notice() << "Encountered " << numbadeventindex << " bad event indexes" - << "\n"; } // FilterEventsLinearly //---------------------------------------------------------------------------------------------- @@ -2118,7 +2106,7 @@ void FilterEventsByLogValuePreNexus::filterEventsLinear( * We want to pad out empty pixels: monitor */ size_t FilterEventsByLogValuePreNexus::padOutEmptyPixels( - DataObjects::EventWorkspace_sptr eventws) { + const DataObjects::EventWorkspace_sptr &eventws) { const auto &detectorInfo = eventws->detectorInfo(); const auto &detIDs = detectorInfo.detectorIDs(); @@ -2158,7 +2146,7 @@ size_t FilterEventsByLogValuePreNexus::padOutEmptyPixels( * pixel-spectrum map */ void FilterEventsByLogValuePreNexus::setupPixelSpectrumMap( - DataObjects::EventWorkspace_sptr eventws) { + const DataObjects::EventWorkspace_sptr &eventws) { const auto &detectorInfo = eventws->detectorInfo(); const auto &detIDs = detectorInfo.detectorIDs(); @@ -2368,8 +2356,6 @@ void FilterEventsByLogValuePreNexus::readPulseidFile( } } - double temp; - if (m_numPulses > 0) { DateAndTime lastPulseDateTime(0, 0); this->pulsetimes.reserve(m_numPulses); @@ -2384,7 +2370,7 @@ void FilterEventsByLogValuePreNexus::readPulseidFile( else lastPulseDateTime = pulseDateTime; - temp = pulse.pCurrent; + double temp = pulse.pCurrent; this->m_protonCharge.emplace_back(temp); if (temp < 0.) this->g_log.warning("Individual proton charge < 0 being ignored"); diff --git a/Framework/DataHandling/src/GroupDetectors2.cpp b/Framework/DataHandling/src/GroupDetectors2.cpp index 82af6435fdab81ca7317cc7114e3ec811958a49a..85655ee45d91a091f8557b1146c8a514bfbee58c 100644 --- a/Framework/DataHandling/src/GroupDetectors2.cpp +++ b/Framework/DataHandling/src/GroupDetectors2.cpp @@ -311,8 +311,9 @@ void GroupDetectors2::execEvent() { * @param workspace :: the user selected input workspace * @param unUsedSpec :: spectra indexes that are not members of any group */ -void GroupDetectors2::getGroups(API::MatrixWorkspace_const_sptr workspace, - std::vector<int64_t> &unUsedSpec) { +void GroupDetectors2::getGroups( + const API::MatrixWorkspace_const_sptr &workspace, + std::vector<int64_t> &unUsedSpec) { // this is the map that we are going to fill m_GroupWsInds.clear(); @@ -454,9 +455,9 @@ void GroupDetectors2::getGroups(API::MatrixWorkspace_const_sptr workspace, * a group (so far) * @throw FileError if there's any problem with the file or its format */ -void GroupDetectors2::processFile(const std::string &fname, - API::MatrixWorkspace_const_sptr workspace, - std::vector<int64_t> &unUsedSpec) { +void GroupDetectors2::processFile( + const std::string &fname, const API::MatrixWorkspace_const_sptr &workspace, + std::vector<int64_t> &unUsedSpec) { // tring to open the file the user told us exists, skip down 20 lines to find // out what happens if we can read from it g_log.debug() << "Opening input file ... " << fname; @@ -545,9 +546,9 @@ void GroupDetectors2::processFile(const std::string &fname, * a group (so far) * @throw FileError if there's any problem with the file or its format */ -void GroupDetectors2::processXMLFile(const std::string &fname, - API::MatrixWorkspace_const_sptr workspace, - std::vector<int64_t> &unUsedSpec) { +void GroupDetectors2::processXMLFile( + const std::string &fname, const API::MatrixWorkspace_const_sptr &workspace, + std::vector<int64_t> &unUsedSpec) { // 1. Get maps for spectrum No and detector ID spec2index_map specs2index; const SpectraAxis *axis = @@ -589,9 +590,7 @@ void GroupDetectors2::processXMLFile(const std::string &fname, if (ind != detIdToWiMap.end()) { size_t wsid = ind->second; wsindexes.emplace_back(wsid); - if (unUsedSpec[wsid] != (USED)) { - unUsedSpec[wsid] = (USED); - } + unUsedSpec[wsid] = (USED); } else { g_log.error() << "Detector with ID " << detid << " is not found in instrument \n"; @@ -615,9 +614,7 @@ void GroupDetectors2::processXMLFile(const std::string &fname, if (ind != specs2index.end()) { size_t wsid = ind->second; wsindexes.emplace_back(wsid); - if (unUsedSpec[wsid] != (USED)) { - unUsedSpec[wsid] = (USED); - } + unUsedSpec[wsid] = (USED); } else { g_log.error() << "Spectrum with ID " << specNum << " is not found in instrument \n"; @@ -634,8 +631,8 @@ void GroupDetectors2::processXMLFile(const std::string &fname, * in a group (so far) */ void GroupDetectors2::processGroupingWorkspace( - GroupingWorkspace_const_sptr groupWS, - API::MatrixWorkspace_const_sptr workspace, + const GroupingWorkspace_const_sptr &groupWS, + const API::MatrixWorkspace_const_sptr &workspace, std::vector<int64_t> &unUsedSpec) { detid2index_map detIdToWiMap = workspace->getDetectorIDToWorkspaceIndexMap(); @@ -662,9 +659,7 @@ void GroupDetectors2::processGroupingWorkspace( detIdToWiMap[detectorIDs[spectrumDefinition.first]]; targetWSIndexSet.insert(targetWSIndex); // mark as used - if (unUsedSpec[targetWSIndex] != (USED)) { - unUsedSpec[targetWSIndex] = (USED); - } + unUsedSpec[targetWSIndex] = (USED); } } } @@ -688,7 +683,8 @@ void GroupDetectors2::processGroupingWorkspace( * a group (so far) */ void GroupDetectors2::processMatrixWorkspace( - MatrixWorkspace_const_sptr groupWS, MatrixWorkspace_const_sptr workspace, + const MatrixWorkspace_const_sptr &groupWS, + const MatrixWorkspace_const_sptr &workspace, std::vector<int64_t> &unUsedSpec) { detid2index_map detIdToWiMap = workspace->getDetectorIDToWorkspaceIndexMap(); @@ -700,7 +696,6 @@ void GroupDetectors2::processMatrixWorkspace( for (size_t i = 0; i < spectrumInfo.size(); ++i) { // read spectra from groupingws size_t groupid = i; - if (group2WSIndexSetmap.find(groupid) == group2WSIndexSetmap.end()) { // not found - create an empty set group2WSIndexSetmap.emplace(groupid, std::set<size_t>()); @@ -716,9 +711,7 @@ void GroupDetectors2::processMatrixWorkspace( detIdToWiMap[detectorIDs[spectrumDefinition.first]]; targetWSIndexSet.insert(targetWSIndex); // mark as used - if (unUsedSpec[targetWSIndex] != (USED)) { - unUsedSpec[targetWSIndex] = (USED); - } + unUsedSpec[targetWSIndex] = (USED); } } } @@ -939,11 +932,12 @@ double GroupDetectors2::fileReadProg( * indexing after grouping * @return number of new grouped spectra */ -size_t GroupDetectors2::formGroups(API::MatrixWorkspace_const_sptr inputWS, - API::MatrixWorkspace_sptr outputWS, - const double prog4Copy, const bool keepAll, - const std::set<int64_t> &unGroupedSet, - Indexing::IndexInfo &indexInfo) { +size_t +GroupDetectors2::formGroups(const API::MatrixWorkspace_const_sptr &inputWS, + const API::MatrixWorkspace_sptr &outputWS, + const double prog4Copy, const bool keepAll, + const std::set<int64_t> &unGroupedSet, + Indexing::IndexInfo &indexInfo) { const std::string behaviourChoice = getProperty("Behaviour"); const auto behaviour = behaviourChoice == "Sum" ? Behaviour::SUM : Behaviour::AVERAGE; @@ -1062,10 +1056,9 @@ size_t GroupDetectors2::formGroups(API::MatrixWorkspace_const_sptr inputWS, * a single spectra * @return number of new grouped spectra */ -size_t -GroupDetectors2::formGroupsEvent(DataObjects::EventWorkspace_const_sptr inputWS, - DataObjects::EventWorkspace_sptr outputWS, - const double prog4Copy) { +size_t GroupDetectors2::formGroupsEvent( + const DataObjects::EventWorkspace_const_sptr &inputWS, + const DataObjects::EventWorkspace_sptr &outputWS, const double prog4Copy) { if (inputWS->detectorInfo().isScanning()) throw std::runtime_error("GroupDetectors does not currently support " "EventWorkspaces with detector scans."); diff --git a/Framework/DataHandling/src/JoinISISPolarizationEfficiencies.cpp b/Framework/DataHandling/src/JoinISISPolarizationEfficiencies.cpp index 366841e5fe9ac1a3b680d0c7a35dd0f3fd6277a3..53b7b63f955b45373c4410082c51b345e29c6326 100644 --- a/Framework/DataHandling/src/JoinISISPolarizationEfficiencies.cpp +++ b/Framework/DataHandling/src/JoinISISPolarizationEfficiencies.cpp @@ -196,7 +196,7 @@ JoinISISPolarizationEfficiencies::interpolateWorkspaces( MatrixWorkspace_sptr JoinISISPolarizationEfficiencies::interpolatePointDataWorkspace( - MatrixWorkspace_sptr ws, size_t const maxSize) { + const MatrixWorkspace_sptr &ws, size_t const maxSize) { auto const &x = ws->x(0); auto const startX = x.front(); auto const endX = x.back(); @@ -213,7 +213,7 @@ JoinISISPolarizationEfficiencies::interpolatePointDataWorkspace( MatrixWorkspace_sptr JoinISISPolarizationEfficiencies::interpolateHistogramWorkspace( - MatrixWorkspace_sptr ws, size_t const maxSize) { + const MatrixWorkspace_sptr &ws, size_t const maxSize) { ws->setDistribution(true); auto const &x = ws->x(0); auto const dX = (x.back() - x.front()) / double(maxSize); diff --git a/Framework/DataHandling/src/Load.cpp b/Framework/DataHandling/src/Load.cpp index 9f3aca7aed9625a9b6831918867c026d19fddd60..3dccfb9b1d7d8a9ff72b2b8a7907d765e4af1078 100644 --- a/Framework/DataHandling/src/Load.cpp +++ b/Framework/DataHandling/src/Load.cpp @@ -54,7 +54,8 @@ bool isSingleFile(const std::vector<std::vector<std::string>> &fileNames) { * @returns a string containing a suggested ws name based on the given file *names. */ -std::string generateWsNameFromFileNames(std::vector<std::string> filenames) { +std::string +generateWsNameFromFileNames(const std::vector<std::string> &filenames) { std::string wsName; for (auto &filename : filenames) { @@ -678,7 +679,8 @@ API::Workspace_sptr Load::loadFileToWs(const std::string &fileName, * * @returns a pointer to the result (the first workspace). */ -API::Workspace_sptr Load::plusWs(Workspace_sptr ws1, Workspace_sptr ws2) { +API::Workspace_sptr Load::plusWs(Workspace_sptr ws1, + const Workspace_sptr &ws2) { WorkspaceGroup_sptr group1 = boost::dynamic_pointer_cast<WorkspaceGroup>(ws1); WorkspaceGroup_sptr group2 = boost::dynamic_pointer_cast<WorkspaceGroup>(ws2); diff --git a/Framework/DataHandling/src/LoadAsciiStl.cpp b/Framework/DataHandling/src/LoadAsciiStl.cpp index 5fe2fea8a012a1d639beb68c881b9fc7d682994f..6babcfa54c05091fe578325794aa6b6cc6327b3e 100644 --- a/Framework/DataHandling/src/LoadAsciiStl.cpp +++ b/Framework/DataHandling/src/LoadAsciiStl.cpp @@ -11,7 +11,7 @@ namespace Mantid { namespace DataHandling { -bool LoadAsciiStl::isAsciiSTL(std::string filename) { +bool LoadAsciiStl::isAsciiSTL(const std::string &filename) { std::ifstream file(filename.c_str()); if (!file) { // if the file cannot be read then it is not a valid asciiStl File diff --git a/Framework/DataHandling/src/LoadBBY.cpp b/Framework/DataHandling/src/LoadBBY.cpp index 3fe7461a573831b527ff2914ad46ef511bb326e9..1a35f3da47bea2bd01c6c1da30ef90b4435bdfa3 100644 --- a/Framework/DataHandling/src/LoadBBY.cpp +++ b/Framework/DataHandling/src/LoadBBY.cpp @@ -305,7 +305,7 @@ void LoadBBY::exec() { eventAssigner); } - auto getParam = [&allParams](std::string tag, double defValue) { + auto getParam = [&allParams](const std::string &tag, double defValue) { try { return std::stod(allParams[tag]); } catch (const std::invalid_argument &) { diff --git a/Framework/DataHandling/src/LoadBinaryStl.cpp b/Framework/DataHandling/src/LoadBinaryStl.cpp index 0b05cdd15ed8f743d200ac57b9a863bfa586c780..a43550ec716d1cece46d4f138e8f81eb8ebde543 100644 --- a/Framework/DataHandling/src/LoadBinaryStl.cpp +++ b/Framework/DataHandling/src/LoadBinaryStl.cpp @@ -24,7 +24,7 @@ uint32_t getNumberTriangles(Kernel::BinaryStreamReader streamReader, } } // namespace -bool LoadBinaryStl::isBinarySTL(std::string filename) { +bool LoadBinaryStl::isBinarySTL(const std::string &filename) { Poco::File stlFile = Poco::File(filename); if (!stlFile.exists()) { // if the file cannot be read then it is not a valid binary Stl File diff --git a/Framework/DataHandling/src/LoadCalFile.cpp b/Framework/DataHandling/src/LoadCalFile.cpp index c2ca3f78e0356ad67e92612459ad24452392d5c5..3062ed3fa00c59cf91a7608745425e0d82c79c7e 100644 --- a/Framework/DataHandling/src/LoadCalFile.cpp +++ b/Framework/DataHandling/src/LoadCalFile.cpp @@ -237,9 +237,9 @@ void LoadCalFile::exec() { *initialized to the right instrument. */ void LoadCalFile::readCalFile(const std::string &calFileName, - GroupingWorkspace_sptr groupWS, - OffsetsWorkspace_sptr offsetsWS, - MaskWorkspace_sptr maskWS) { + const GroupingWorkspace_sptr &groupWS, + const OffsetsWorkspace_sptr &offsetsWS, + const MaskWorkspace_sptr &maskWS) { auto doGroup = bool(groupWS); auto doOffsets = bool(offsetsWS); auto doMask = bool(maskWS); @@ -360,7 +360,7 @@ void LoadCalFile::readCalFile(const std::string &calFileName, * @param detID Detector ID to check * @return True if a monitor, false otherwise */ -bool LoadCalFile::idIsMonitor(Instrument_const_sptr inst, int detID) { +bool LoadCalFile::idIsMonitor(const Instrument_const_sptr &inst, int detID) { auto monitorList = inst->getMonitors(); auto it = std::find(monitorList.begin(), monitorList.end(), detID); return (it != monitorList.end()); diff --git a/Framework/DataHandling/src/LoadCanSAS1D.cpp b/Framework/DataHandling/src/LoadCanSAS1D.cpp index 75c723269e51eacdcd4983601e0c6cf104b32821..49edd128199eaafd36aae0fdbe5b94f3d1162951 100644 --- a/Framework/DataHandling/src/LoadCanSAS1D.cpp +++ b/Framework/DataHandling/src/LoadCanSAS1D.cpp @@ -297,9 +297,9 @@ void LoadCanSAS1D::check(const Poco::XML::Element *const toCheck, * @param[out] container the data will be added to this group * @throw ExistsError if a workspace with this name had already been added */ -void LoadCanSAS1D::appendDataToOutput(API::MatrixWorkspace_sptr newWork, - const std::string &newWorkName, - API::WorkspaceGroup_sptr container) { +void LoadCanSAS1D::appendDataToOutput( + const API::MatrixWorkspace_sptr &newWork, const std::string &newWorkName, + const API::WorkspaceGroup_sptr &container) { // the name of the property, like the workspace name must be different for // each workspace. Add "_run" at the end to stop problems with names like // "outputworkspace" @@ -317,8 +317,9 @@ void LoadCanSAS1D::appendDataToOutput(API::MatrixWorkspace_sptr newWork, * @param inst_name :: The name written in the Nexus file * @param localWorkspace :: The workspace to insert the instrument into */ -void LoadCanSAS1D::runLoadInstrument(const std::string &inst_name, - API::MatrixWorkspace_sptr localWorkspace) { +void LoadCanSAS1D::runLoadInstrument( + const std::string &inst_name, + const API::MatrixWorkspace_sptr &localWorkspace) { API::IAlgorithm_sptr loadInst = createChildAlgorithm("LoadInstrument"); @@ -342,7 +343,7 @@ void LoadCanSAS1D::runLoadInstrument(const std::string &inst_name, * @param[in] wSpace the log will be created in this workspace */ void LoadCanSAS1D::createLogs(const Poco::XML::Element *const sasEntry, - API::MatrixWorkspace_sptr wSpace) const { + const API::MatrixWorkspace_sptr &wSpace) const { API::Run &run = wSpace->mutableRun(); Element *runText = sasEntry->getChildElement("Run"); check(runText, "Run"); @@ -369,7 +370,7 @@ void LoadCanSAS1D::createLogs(const Poco::XML::Element *const sasEntry, void LoadCanSAS1D::createSampleInformation( const Poco::XML::Element *const sasEntry, - Mantid::API::MatrixWorkspace_sptr wSpace) const { + const Mantid::API::MatrixWorkspace_sptr &wSpace) const { auto &sample = wSpace->mutableSample(); // Get the thickness information diff --git a/Framework/DataHandling/src/LoadDaveGrp.cpp b/Framework/DataHandling/src/LoadDaveGrp.cpp index 6f62cd3e9e95d0500e8002eb1ff3a16637169ae6..840a1fb136d79519d7fae632caa14ddabe91dffe 100644 --- a/Framework/DataHandling/src/LoadDaveGrp.cpp +++ b/Framework/DataHandling/src/LoadDaveGrp.cpp @@ -176,7 +176,7 @@ API::MatrixWorkspace_sptr LoadDaveGrp::setupWorkspace() const { return outputWorkspace; } -void LoadDaveGrp::setWorkspaceAxes(API::MatrixWorkspace_sptr workspace, +void LoadDaveGrp::setWorkspaceAxes(const API::MatrixWorkspace_sptr &workspace, const std::vector<double> &xAxis, const std::vector<double> &yAxis) const { @@ -231,7 +231,7 @@ void LoadDaveGrp::getAxisValues(std::vector<double> &axis, } } -void LoadDaveGrp::getData(API::MatrixWorkspace_sptr workspace) { +void LoadDaveGrp::getData(const API::MatrixWorkspace_sptr &workspace) { double data_val = 0.0; double err_val = 0.0; diff --git a/Framework/DataHandling/src/LoadDetectorsGroupingFile.cpp b/Framework/DataHandling/src/LoadDetectorsGroupingFile.cpp index cf823778e64e3391505a9330bda154ad3a832d71..b2ccf757b1cea94807d4e8db93b0b10cb4f83e87 100644 --- a/Framework/DataHandling/src/LoadDetectorsGroupingFile.cpp +++ b/Framework/DataHandling/src/LoadDetectorsGroupingFile.cpp @@ -409,7 +409,7 @@ LoadGroupXMLFile::LoadGroupXMLFile() m_pDoc(), m_groupComponentsMap(), m_groupDetectorsMap(), m_groupSpectraMap(), m_startGroupID(1), m_groupNamesMap() {} -void LoadGroupXMLFile::loadXMLFile(std::string xmlfilename) { +void LoadGroupXMLFile::loadXMLFile(const std::string &xmlfilename) { this->initializeXMLParser(xmlfilename); this->parseXML(); @@ -604,9 +604,8 @@ void LoadGroupXMLFile::parseXML() { /* * Get attribute's value by name from a Node */ -std::string LoadGroupXMLFile::getAttributeValueByName(Poco::XML::Node *pNode, - std::string attributename, - bool &found) { +std::string LoadGroupXMLFile::getAttributeValueByName( + Poco::XML::Node *pNode, const std::string &attributename, bool &found) { // 1. Init Poco::AutoPtr<Poco::XML::NamedNodeMap> att = pNode->attributes(); found = false; diff --git a/Framework/DataHandling/src/LoadDiffCal.cpp b/Framework/DataHandling/src/LoadDiffCal.cpp index ff6b617b3bb62a865fd430c6ee72625c6e8a264a..a75167db988a85a08dd7744d051363411fe98ccc 100644 --- a/Framework/DataHandling/src/LoadDiffCal.cpp +++ b/Framework/DataHandling/src/LoadDiffCal.cpp @@ -132,7 +132,7 @@ bool endswith(const std::string &str, const std::string &ending) { } void setGroupWSProperty(API::Algorithm *alg, const std::string &prefix, - GroupingWorkspace_sptr wksp) { + const GroupingWorkspace_sptr &wksp) { alg->declareProperty( std::make_unique<WorkspaceProperty<DataObjects::GroupingWorkspace>>( "OutputGroupingWorkspace", prefix + "_group", Direction::Output), @@ -141,7 +141,7 @@ void setGroupWSProperty(API::Algorithm *alg, const std::string &prefix, } void setMaskWSProperty(API::Algorithm *alg, const std::string &prefix, - MaskWorkspace_sptr wksp) { + const MaskWorkspace_sptr &wksp) { alg->declareProperty( std::make_unique<WorkspaceProperty<DataObjects::MaskWorkspace>>( "OutputMaskWorkspace", prefix + "_mask", Direction::Output), @@ -150,7 +150,7 @@ void setMaskWSProperty(API::Algorithm *alg, const std::string &prefix, } void setCalWSProperty(API::Algorithm *alg, const std::string &prefix, - ITableWorkspace_sptr wksp) { + const ITableWorkspace_sptr &wksp) { alg->declareProperty( std::make_unique<WorkspaceProperty<ITableWorkspace>>( "OutputCalWorkspace", prefix + "_cal", Direction::Output), diff --git a/Framework/DataHandling/src/LoadDspacemap.cpp b/Framework/DataHandling/src/LoadDspacemap.cpp index ef2ed7bdf70a80d9c75edcf1bbc7703d5dd94c7b..6a5e8ac1596e0eaba40523dbd2684cf02addf649 100644 --- a/Framework/DataHandling/src/LoadDspacemap.cpp +++ b/Framework/DataHandling/src/LoadDspacemap.cpp @@ -95,8 +95,8 @@ void LoadDspacemap::exec() { * @param offsetsWS :: OffsetsWorkspace to be filled. */ void LoadDspacemap::CalculateOffsetsFromDSpacemapFile( - const std::string DFileName, - Mantid::DataObjects::OffsetsWorkspace_sptr offsetsWS) { + const std::string &DFileName, + const Mantid::DataObjects::OffsetsWorkspace_sptr &offsetsWS) { // Get a pointer to the instrument contained in the workspace const auto &detectorInfo = offsetsWS->detectorInfo(); @@ -150,7 +150,7 @@ const double CONSTANT = (PhysicalConstants::h * 1e10) / */ void LoadDspacemap::CalculateOffsetsFromVulcanFactors( std::map<detid_t, double> &vulcan, - Mantid::DataObjects::OffsetsWorkspace_sptr offsetsWS) { + const Mantid::DataObjects::OffsetsWorkspace_sptr &offsetsWS) { // Get a pointer to the instrument contained in the workspace // At this point, instrument VULCAN has been created? Instrument_const_sptr instrument = offsetsWS->getInstrument(); diff --git a/Framework/DataHandling/src/LoadEMU.cpp b/Framework/DataHandling/src/LoadEMU.cpp index 3389e0ab82cd6bf644eb939dcb9d5b846459d0d1..24443dec1cbed536bb6d8059bee27b62f3896c84 100644 --- a/Framework/DataHandling/src/LoadEMU.cpp +++ b/Framework/DataHandling/src/LoadEMU.cpp @@ -680,7 +680,7 @@ void LoadEMU<FD>::exec(const std::string &hdfFile, // lambda to simplify loading instrument parameters auto instr = m_localWorkspace->getInstrument(); - auto iparam = [&instr](std::string tag) { + auto iparam = [&instr](const std::string &tag) { return instr->getNumberParameter(tag)[0]; }; @@ -690,7 +690,7 @@ void LoadEMU<FD>::exec(const std::string &hdfFile, // double sampleAnalyser = iparam("SampleAnalyser"); auto endID = static_cast<detid_t>(DETECTOR_TUBES * PIXELS_PER_TUBE); - for (detid_t detID = 0; detID < endID; detID++) + for (detid_t detID = 0; detID < endID; ++detID) updateNeutronicPostions(detID, sampleAnalyser); // get the detector map from raw input to a physical detector diff --git a/Framework/DataHandling/src/LoadEventNexus.cpp b/Framework/DataHandling/src/LoadEventNexus.cpp index e19bcd8f634774dd3af4903940fa5da8ddd0382b..61db89516575f4fe66cc477f89452e79a674ad10 100644 --- a/Framework/DataHandling/src/LoadEventNexus.cpp +++ b/Framework/DataHandling/src/LoadEventNexus.cpp @@ -1177,8 +1177,8 @@ bool LoadEventNexus::runLoadInstrument<EventWorkspaceCollection_sptr>( * @param workspace :: The workspace to contain the spectra mapping * @param bankNames :: Bank names that are in Nexus file */ -void LoadEventNexus::deleteBanks(EventWorkspaceCollection_sptr workspace, - std::vector<std::string> bankNames) { +void LoadEventNexus::deleteBanks(const EventWorkspaceCollection_sptr &workspace, + const std::vector<std::string> &bankNames) { Instrument_sptr inst = boost::const_pointer_cast<Instrument>( workspace->getInstrument()->baseInstrument()); // Build a list of Rectangular Detectors @@ -1537,7 +1537,7 @@ void LoadEventNexus::loadSampleDataISIScompatibility( * * @param fname name of the nexus file to open */ -void LoadEventNexus::safeOpenFile(const std::string fname) { +void LoadEventNexus::safeOpenFile(const std::string &fname) { try { m_file = std::make_unique<::NeXus::File>(m_filename, NXACC_READ); } catch (std::runtime_error &e) { diff --git a/Framework/DataHandling/src/LoadEventNexusIndexSetup.cpp b/Framework/DataHandling/src/LoadEventNexusIndexSetup.cpp index 0e7a6f4e212d75d84ccc97997d3565474ec724d8..6a3d324202792265dac3304d609c690b890fab27 100644 --- a/Framework/DataHandling/src/LoadEventNexusIndexSetup.cpp +++ b/Framework/DataHandling/src/LoadEventNexusIndexSetup.cpp @@ -4,8 +4,10 @@ // NScD Oak Ridge National Laboratory, European Spallation Source, // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + -#include "MantidDataHandling/LoadEventNexusIndexSetup.h" +#include <utility> + #include "MantidAPI/SpectrumDetectorMapping.h" +#include "MantidDataHandling/LoadEventNexusIndexSetup.h" #include "MantidGeometry/Instrument.h" #include "MantidGeometry/Instrument/ComponentInfo.h" #include "MantidGeometry/Instrument/DetectorInfo.h" @@ -42,10 +44,10 @@ void setupConsistentSpectrumNumbers(IndexInfo &filtered, LoadEventNexusIndexSetup::LoadEventNexusIndexSetup( MatrixWorkspace_const_sptr instrumentWorkspace, const int32_t min, - const int32_t max, const std::vector<int32_t> range, + const int32_t max, const std::vector<int32_t> &range, const Parallel::Communicator &communicator) - : m_instrumentWorkspace(instrumentWorkspace), m_min(min), m_max(max), - m_range(range), m_communicator(communicator) {} + : m_instrumentWorkspace(std::move(instrumentWorkspace)), m_min(min), + m_max(max), m_range(range), m_communicator(communicator) {} std::pair<int32_t, int32_t> LoadEventNexusIndexSetup::eventIDLimits() const { return {m_min, m_max}; diff --git a/Framework/DataHandling/src/LoadEventPreNexus2.cpp b/Framework/DataHandling/src/LoadEventPreNexus2.cpp index 04eaff0ec070db6cbef202ef701c1b4259741606..447ae3efef5c428fc26df9a69020bdf5283c27c6 100644 --- a/Framework/DataHandling/src/LoadEventPreNexus2.cpp +++ b/Framework/DataHandling/src/LoadEventPreNexus2.cpp @@ -405,7 +405,7 @@ void LoadEventPreNexus2::exec() { /** Create and set up output Event Workspace */ void LoadEventPreNexus2::createOutputWorkspace( - const std::string event_filename) { + const std::string &event_filename) { // Create the output workspace localWorkspace = EventWorkspace_sptr(new EventWorkspace()); @@ -570,7 +570,7 @@ void LoadEventPreNexus2::processImbedLogs() { * @param mindex :: index of the log in pulse time ... * - mindex: index of the the series in the list */ -void LoadEventPreNexus2::addToWorkspaceLog(std::string logtitle, +void LoadEventPreNexus2::addToWorkspaceLog(const std::string &logtitle, size_t mindex) { // Create TimeSeriesProperty auto property = new TimeSeriesProperty<double>(logtitle); @@ -601,7 +601,8 @@ void LoadEventPreNexus2::addToWorkspaceLog(std::string logtitle, * geometry */ void LoadEventPreNexus2::runLoadInstrument( - const std::string &eventfilename, MatrixWorkspace_sptr localWorkspace) { + const std::string &eventfilename, + const MatrixWorkspace_sptr &localWorkspace) { // start by getting just the filename string instrument = Poco::Path(eventfilename).getFileName(); @@ -757,7 +758,6 @@ void LoadEventPreNexus2::procEvents( partWorkspaces.resize(numThreads); buffers.resize(numThreads); eventVectors = new EventVector_pt *[numThreads]; - // cppcheck-suppress syntaxError PRAGMA_OMP( parallel for if (parallelProcessing) ) for (int i = 0; i < int(numThreads); i++) { @@ -780,7 +780,7 @@ void LoadEventPreNexus2::procEvents( // value = pointer to the events vector eventVectors[i] = new EventVector_pt[detid_max + 1]; EventVector_pt *theseEventVectors = eventVectors[i]; - for (detid_t j = 0; j < detid_max + 1; j++) { + for (detid_t j = 0; j < detid_max + 1; ++j) { size_t wi = pixel_to_wkspindex[j]; // Save a POINTER to the vector<tofEvent> if (wi != static_cast<size_t>(-1)) @@ -1322,7 +1322,6 @@ void LoadEventPreNexus2::readPulseidFile(const std::string &filename, } if (num_pulses > 0) { - double temp; DateAndTime lastPulseDateTime(0, 0); this->pulsetimes.reserve(num_pulses); for (const auto &pulse : pulses) { @@ -1336,7 +1335,7 @@ void LoadEventPreNexus2::readPulseidFile(const std::string &filename, else lastPulseDateTime = pulseDateTime; - temp = pulse.pCurrent; + double temp = pulse.pCurrent; this->proton_charge.emplace_back(temp); if (temp < 0.) this->g_log.warning("Individual proton charge < 0 being ignored"); diff --git a/Framework/DataHandling/src/LoadFITS.cpp b/Framework/DataHandling/src/LoadFITS.cpp index deb8a6f3a818fd27e9459de6576b86b14c9ef23d..57f2df40ce813f0c338daed43f07fa5eca0716d4 100644 --- a/Framework/DataHandling/src/LoadFITS.cpp +++ b/Framework/DataHandling/src/LoadFITS.cpp @@ -678,7 +678,7 @@ void LoadFITS::parseHeader(FITSInfo &headerInfo) { Workspace2D_sptr LoadFITS::makeWorkspace(const FITSInfo &fileInfo, size_t &newFileNumber, std::vector<char> &buffer, MantidImage &imageY, - MantidImage &imageE, const Workspace2D_sptr parent, + MantidImage &imageE, const Workspace2D_sptr &parent, bool loadAsRectImg, int binSize, double noiseThresh) { // Create workspace (taking into account already here if rebinning is // going to happen) @@ -763,9 +763,9 @@ LoadFITS::makeWorkspace(const FITSInfo &fileInfo, size_t &newFileNumber, * @param cmpp centimeters per pixel (already taking into account * possible rebinning) */ -void LoadFITS::addAxesInfoAndLogs(Workspace2D_sptr ws, bool loadAsRectImg, - const FITSInfo &fileInfo, int binSize, - double cmpp) { +void LoadFITS::addAxesInfoAndLogs(const Workspace2D_sptr &ws, + bool loadAsRectImg, const FITSInfo &fileInfo, + int binSize, double cmpp) { // add axes size_t width = fileInfo.axisPixelLengths[0] / binSize; size_t height = fileInfo.axisPixelLengths[1] / binSize; @@ -848,7 +848,7 @@ void LoadFITS::addAxesInfoAndLogs(Workspace2D_sptr ws, bool loadAsRectImg, * @throws std::runtime_error if there are file input issues */ void LoadFITS::readDataToWorkspace(const FITSInfo &fileInfo, double cmpp, - Workspace2D_sptr ws, + const Workspace2D_sptr &ws, std::vector<char> &buffer) { const size_t bytespp = (fileInfo.bitsPerPixel / 8); const size_t len = m_pixelCount * bytespp; diff --git a/Framework/DataHandling/src/LoadFullprofResolution.cpp b/Framework/DataHandling/src/LoadFullprofResolution.cpp index 5095dcb4e6b61d95e7fbd118082070f87243be05..085341074867ca897a0942efc1d6b0687ba5d347 100644 --- a/Framework/DataHandling/src/LoadFullprofResolution.cpp +++ b/Framework/DataHandling/src/LoadFullprofResolution.cpp @@ -240,7 +240,8 @@ void LoadFullprofResolution::exec() { * @param filename :: string for name of the .irf file * @param lines :: vector of strings for each non-empty line in .irf file */ -void LoadFullprofResolution::loadFile(string filename, vector<string> &lines) { +void LoadFullprofResolution::loadFile(const string &filename, + vector<string> &lines) { string line; // the variable of type ifstream: @@ -773,8 +774,8 @@ void LoadFullprofResolution::createBankToWorkspaceMap( * stored */ void LoadFullprofResolution::putParametersIntoWorkspace( - API::Column_const_sptr column, API::MatrixWorkspace_sptr ws, int nProf, - std::string ¶meterXMLString) { + const API::Column_const_sptr &column, const API::MatrixWorkspace_sptr &ws, + int nProf, std::string ¶meterXMLString) { // Get instrument name from matrix workspace std::string instrumentName = ws->getInstrument()->getName(); @@ -833,7 +834,7 @@ void LoadFullprofResolution::putParametersIntoWorkspace( * paramName is the name of the parameter as it appears in the table workspace */ void LoadFullprofResolution::addALFBEParameter( - const API::Column_const_sptr column, Poco::XML::Document *mDoc, + const API::Column_const_sptr &column, Poco::XML::Document *mDoc, Element *parent, const std::string ¶mName) { AutoPtr<Element> parameterElem = mDoc->createElement("parameter"); parameterElem->setAttribute("name", getXMLParameterName(paramName)); @@ -856,7 +857,7 @@ void LoadFullprofResolution::addALFBEParameter( * for the bank at the given column of the table workspace */ void LoadFullprofResolution::addSigmaParameters( - const API::Column_const_sptr column, Poco::XML::Document *mDoc, + const API::Column_const_sptr &column, Poco::XML::Document *mDoc, Poco::XML::Element *parent) { AutoPtr<Element> parameterElem = mDoc->createElement("parameter"); parameterElem->setAttribute("name", "IkedaCarpenterPV:SigmaSquared"); @@ -878,7 +879,7 @@ void LoadFullprofResolution::addSigmaParameters( * for the bank at the given column of the table workspace */ void LoadFullprofResolution::addGammaParameters( - const API::Column_const_sptr column, Poco::XML::Document *mDoc, + const API::Column_const_sptr &column, Poco::XML::Document *mDoc, Poco::XML::Element *parent) { AutoPtr<Element> parameterElem = mDoc->createElement("parameter"); parameterElem->setAttribute("name", "IkedaCarpenterPV:Gamma"); @@ -899,7 +900,7 @@ void LoadFullprofResolution::addGammaParameters( * for the bank at the given column of the table workspace */ void LoadFullprofResolution::addBBX_S_Parameters( - const API::Column_const_sptr column, Poco::XML::Document *mDoc, + const API::Column_const_sptr &column, Poco::XML::Document *mDoc, Poco::XML::Element *parent) { AutoPtr<Element> parameterElem = mDoc->createElement("parameter"); parameterElem->setAttribute("name", "BackToBackExponential:S"); @@ -923,7 +924,7 @@ void LoadFullprofResolution::addBBX_S_Parameters( * for the bank at the given column of the table workspace */ void LoadFullprofResolution::addBBX_A_Parameters( - const API::Column_const_sptr column, Poco::XML::Document *mDoc, + const API::Column_const_sptr &column, Poco::XML::Document *mDoc, Poco::XML::Element *parent) { AutoPtr<Element> parameterElem = mDoc->createElement("parameter"); parameterElem->setAttribute("name", "BackToBackExponential:A"); @@ -948,7 +949,7 @@ void LoadFullprofResolution::addBBX_A_Parameters( * for the bank at the given column of the table workspace */ void LoadFullprofResolution::addBBX_B_Parameters( - const API::Column_const_sptr column, Poco::XML::Document *mDoc, + const API::Column_const_sptr &column, Poco::XML::Document *mDoc, Poco::XML::Element *parent) { AutoPtr<Element> parameterElem = mDoc->createElement("parameter"); parameterElem->setAttribute("name", "BackToBackExponential:B"); @@ -992,7 +993,7 @@ LoadFullprofResolution::getXMLParameterName(const std::string &name) { * given the name of the parameter in the table workspace. */ std::string -LoadFullprofResolution::getXMLEqValue(const API::Column_const_sptr column, +LoadFullprofResolution::getXMLEqValue(const API::Column_const_sptr &column, const std::string &name) { size_t paramNumber = LoadFullprofResolution::m_rowNumbers[name]; // API::Column_const_sptr column = tablews->getColumn( columnIndex ); @@ -1006,7 +1007,7 @@ LoadFullprofResolution::getXMLEqValue(const API::Column_const_sptr column, * given the name of the parameter in the table workspace. */ std::string LoadFullprofResolution::getXMLSquaredEqValue( - const API::Column_const_sptr column, const std::string &name) { + const API::Column_const_sptr &column, const std::string &name) { size_t paramNumber = LoadFullprofResolution::m_rowNumbers[name]; // API::Column_const_sptr column = tablews->getColumn( columnIndex ); double eqValue = column->cell<double>(paramNumber); diff --git a/Framework/DataHandling/src/LoadGSASInstrumentFile.cpp b/Framework/DataHandling/src/LoadGSASInstrumentFile.cpp index aadb1e848b522c141a1b37ac30301631168909af..e5174ebb212284c9e6c338c5620b925fcc701482 100644 --- a/Framework/DataHandling/src/LoadGSASInstrumentFile.cpp +++ b/Framework/DataHandling/src/LoadGSASInstrumentFile.cpp @@ -214,7 +214,8 @@ void LoadGSASInstrumentFile::exec() { * @param filename :: string for name of the .prm file * @param lines :: vector of strings for each non-empty line in .prm file */ -void LoadGSASInstrumentFile::loadFile(string filename, vector<string> &lines) { +void LoadGSASInstrumentFile::loadFile(const string &filename, + vector<string> &lines) { string line; // the variable of type ifstream: @@ -254,7 +255,7 @@ LoadGSASInstrumentFile::getHistogramType(const vector<string> &lines) { // We assume there is just one HTYPE line, look for it from beginning and // return its value. std::string lookFor = "INS HTYPE"; - for (size_t i = 0; i <= lines.size(); ++i) { + for (size_t i = 0; i < lines.size(); ++i) { if (lines[i].substr(0, lookFor.size()) == lookFor) { if (lines[i].size() < lookFor.size() + 7) { // line too short @@ -274,7 +275,7 @@ size_t LoadGSASInstrumentFile::getNumberOfBanks(const vector<string> &lines) { // We assume there is just one BANK line, look for it from beginning and // return its value. std::string lookFor = "INS BANK"; - for (size_t i = 0; i <= lines.size(); ++i) { + for (size_t i = 0; i < lines.size(); ++i) { if (lines[i].substr(0, lookFor.size()) == lookFor) { if (lines[i].size() < lookFor.size() + 3) { // line too short diff --git a/Framework/DataHandling/src/LoadGSS.cpp b/Framework/DataHandling/src/LoadGSS.cpp index 9f04a4b9a02f46226cb24039b33e6135a41a9758..4456422c817533eb8153a6675f21cb9e1d74e3e4 100644 --- a/Framework/DataHandling/src/LoadGSS.cpp +++ b/Framework/DataHandling/src/LoadGSS.cpp @@ -488,7 +488,7 @@ double LoadGSS::convertToDouble(std::string inputstring) { /** Create the instrument geometry with Instrument */ void LoadGSS::createInstrumentGeometry( - MatrixWorkspace_sptr workspace, const std::string &instrumentname, + const MatrixWorkspace_sptr &workspace, const std::string &instrumentname, const double &primaryflightpath, const std::vector<int> &detectorids, const std::vector<double> &totalflightpaths, const std::vector<double> &twothetas) { diff --git a/Framework/DataHandling/src/LoadHelper.cpp b/Framework/DataHandling/src/LoadHelper.cpp index 0527c865d70cf696dc02c2f3dba4e64a69c33bdf..6461e0fa1ecee7e18c16136c0dd3847c87c9d370 100644 --- a/Framework/DataHandling/src/LoadHelper.cpp +++ b/Framework/DataHandling/src/LoadHelper.cpp @@ -119,7 +119,7 @@ double LoadHelper::calculateTOF(double distance, double wavelength) { */ double LoadHelper::getInstrumentProperty(const API::MatrixWorkspace_sptr &workspace, - std::string s) { + const std::string &s) { std::vector<std::string> prop = workspace->getInstrument()->getStringParameter(s); if (prop.empty()) { @@ -509,7 +509,7 @@ void LoadHelper::dumpNexusAttributes(NXhandle nxfileID, * @param dateToParse :: date as string * @return date as required in Mantid */ -std::string LoadHelper::dateTimeInIsoFormat(std::string dateToParse) { +std::string LoadHelper::dateTimeInIsoFormat(const std::string &dateToParse) { namespace bt = boost::posix_time; // parsing format const std::locale format = std::locale( @@ -535,7 +535,7 @@ std::string LoadHelper::dateTimeInIsoFormat(std::string dateToParse) { * @param componentName The name of the component of the instrument * @param newPos New position of the component */ -void LoadHelper::moveComponent(API::MatrixWorkspace_sptr ws, +void LoadHelper::moveComponent(const API::MatrixWorkspace_sptr &ws, const std::string &componentName, const V3D &newPos) { Geometry::IComponent_const_sptr component = @@ -557,7 +557,7 @@ void LoadHelper::moveComponent(API::MatrixWorkspace_sptr ws, * @param rot Rotations defined by setting a quaternion from an angle in degrees * and an axis */ -void LoadHelper::rotateComponent(API::MatrixWorkspace_sptr ws, +void LoadHelper::rotateComponent(const API::MatrixWorkspace_sptr &ws, const std::string &componentName, const Kernel::Quat &rot) { Geometry::IComponent_const_sptr component = @@ -578,7 +578,7 @@ void LoadHelper::rotateComponent(API::MatrixWorkspace_sptr ws, * @param componentName The Name of the component of the instrument * @return The position of the component */ -V3D LoadHelper::getComponentPosition(API::MatrixWorkspace_sptr ws, +V3D LoadHelper::getComponentPosition(const API::MatrixWorkspace_sptr &ws, const std::string &componentName) { Geometry::IComponent_const_sptr component = ws->getInstrument()->getComponentByName(componentName); diff --git a/Framework/DataHandling/src/LoadIDFFromNexus.cpp b/Framework/DataHandling/src/LoadIDFFromNexus.cpp index 5d52c316f66b8d855bf5dc8f874ed61b77f05c0c..e4110c861240910b55f90ff5f918f46c64ee40c7 100644 --- a/Framework/DataHandling/src/LoadIDFFromNexus.cpp +++ b/Framework/DataHandling/src/LoadIDFFromNexus.cpp @@ -271,7 +271,7 @@ void LoadIDFFromNexus::readParameterCorrectionFile( * @throw FileError Thrown if unable to parse XML file */ void LoadIDFFromNexus::LoadParameters( - ::NeXus::File *nxfile, const MatrixWorkspace_sptr localWorkspace) { + ::NeXus::File *nxfile, const MatrixWorkspace_sptr &localWorkspace) { std::string parameterString; @@ -314,7 +314,7 @@ void LoadIDFFromNexus::LoadParameters( // given workspace, returning success. bool LoadIDFFromNexus::loadParameterFile( const std::string &fullPathName, - const MatrixWorkspace_sptr localWorkspace) { + const MatrixWorkspace_sptr &localWorkspace) { try { // load and also populate instrument parameters from this 'fallback' diff --git a/Framework/DataHandling/src/LoadILLIndirect2.cpp b/Framework/DataHandling/src/LoadILLIndirect2.cpp index c4d0b384b01989ea0e5e2fb9ff69fda60d63e527..80aa732d8839dcef9dd7d69eba521e956598ef69 100644 --- a/Framework/DataHandling/src/LoadILLIndirect2.cpp +++ b/Framework/DataHandling/src/LoadILLIndirect2.cpp @@ -271,7 +271,7 @@ void LoadILLIndirect2::loadDataIntoTheWorkSpace(NeXus::NXEntry &entry) { * @param nexusfilename */ void LoadILLIndirect2::loadNexusEntriesIntoProperties( - std::string nexusfilename) { + const std::string &nexusfilename) { API::Run &runDetails = m_localWorkspace->mutableRun(); diff --git a/Framework/DataHandling/src/LoadISISNexus2.cpp b/Framework/DataHandling/src/LoadISISNexus2.cpp index 63ccf5fb638974a4e9c6ea535d902a1c921ed43c..abebe9c0e77ed172113684b4e6c01ec485b49294 100644 --- a/Framework/DataHandling/src/LoadISISNexus2.cpp +++ b/Framework/DataHandling/src/LoadISISNexus2.cpp @@ -459,7 +459,7 @@ Check for a set of synthetic logs associated with multi-period log data. Raise warnings where necessary. */ void LoadISISNexus2::validateMultiPeriodLogs( - Mantid::API::MatrixWorkspace_sptr ws) { + const Mantid::API::MatrixWorkspace_sptr &ws) { const Run &run = ws->run(); if (!run.hasProperty("current_period")) { g_log.warning("Workspace has no current_period log."); diff --git a/Framework/DataHandling/src/LoadInstrument.cpp b/Framework/DataHandling/src/LoadInstrument.cpp index 9451dbb3183029e495432295c579bc6b8e53eb88..4274685e262fcc20afe59aec5d0192e266ee2834 100644 --- a/Framework/DataHandling/src/LoadInstrument.cpp +++ b/Framework/DataHandling/src/LoadInstrument.cpp @@ -255,7 +255,8 @@ void LoadInstrument::exec() { //----------------------------------------------------------------------------------------------------------------------- /// Run the Child Algorithm LoadInstrument (or LoadInstrumentFromRaw) void LoadInstrument::runLoadParameterFile( - const boost::shared_ptr<API::MatrixWorkspace> &ws, std::string filename) { + const boost::shared_ptr<API::MatrixWorkspace> &ws, + const std::string &filename) { g_log.debug("Loading the parameter definition..."); // First search for XML parameter file in same folder as IDF file @@ -311,8 +312,9 @@ void LoadInstrument::runLoadParameterFile( /// Search the directory for the Parameter IDF file and return full path name if /// found, else return "". // directoryName must include a final '/'. -std::string LoadInstrument::getFullPathParamIDF(std::string directoryName, - std::string filename) { +std::string +LoadInstrument::getFullPathParamIDF(const std::string &directoryName, + const std::string &filename) { Poco::Path directoryPath(directoryName); directoryPath.makeDirectory(); // Remove the path from the filename diff --git a/Framework/DataHandling/src/LoadIsawDetCal.cpp b/Framework/DataHandling/src/LoadIsawDetCal.cpp index a531b2645f3ede3199ea94772c0398b3ccbd1c4c..4c8e0c67a366277621c990efbbcf8e4be04e5b72 100644 --- a/Framework/DataHandling/src/LoadIsawDetCal.cpp +++ b/Framework/DataHandling/src/LoadIsawDetCal.cpp @@ -29,6 +29,7 @@ #include <fstream> #include <numeric> #include <sstream> +#include <utility> namespace Mantid { namespace DataHandling { @@ -74,7 +75,7 @@ std::string getBankName(const std::string &bankPart, const int idnum) { } } -std::string getInstName(API::Workspace_const_sptr wksp) { +std::string getInstName(const API::Workspace_const_sptr &wksp) { MatrixWorkspace_const_sptr matrixWksp = boost::dynamic_pointer_cast<const MatrixWorkspace>(wksp); if (matrixWksp) { @@ -352,10 +353,11 @@ void LoadIsawDetCal::exec() { * @param componentInfo :: The component info object for the workspace */ void LoadIsawDetCal::center(const double x, const double y, const double z, - const std::string &detname, API::Workspace_sptr ws, + const std::string &detname, + const API::Workspace_sptr &ws, Geometry::ComponentInfo &componentInfo) { - Instrument_sptr inst = getCheckInst(ws); + Instrument_sptr inst = getCheckInst(std::move(ws)); IComponent_const_sptr comp = inst->getComponentByName(detname); if (comp == nullptr) { @@ -378,7 +380,7 @@ void LoadIsawDetCal::center(const double x, const double y, const double z, * @throw std::runtime_error if there's any problem with the workspace or it is * not possible to get an instrument object from it */ -Instrument_sptr LoadIsawDetCal::getCheckInst(API::Workspace_sptr ws) { +Instrument_sptr LoadIsawDetCal::getCheckInst(const API::Workspace_sptr &ws) { MatrixWorkspace_sptr inputW = boost::dynamic_pointer_cast<MatrixWorkspace>(ws); PeaksWorkspace_sptr inputP = boost::dynamic_pointer_cast<PeaksWorkspace>(ws); @@ -432,7 +434,7 @@ std::vector<std::string> LoadIsawDetCal::getFilenames() { * @param doWishCorrection if true apply a special correction for WISH */ void LoadIsawDetCal::doRotation(V3D rX, V3D rY, ComponentInfo &componentInfo, - boost::shared_ptr<const IComponent> comp, + const boost::shared_ptr<const IComponent> &comp, bool doWishCorrection) { // These are the ISAW axes rX.normalize(); diff --git a/Framework/DataHandling/src/LoadLog.cpp b/Framework/DataHandling/src/LoadLog.cpp index 6f528b5b844fa1cd4f32c70bb931d7420e246193..c771655cb7074ad72a821c71a55a2f2ba7b81172 100644 --- a/Framework/DataHandling/src/LoadLog.cpp +++ b/Framework/DataHandling/src/LoadLog.cpp @@ -28,6 +28,7 @@ #include <boost/algorithm/string.hpp> #include <fstream> // used to get ifstream #include <sstream> +#include <utility> using Mantid::Types::Core::DateAndTime; @@ -202,8 +203,8 @@ void LoadLog::loadTwoColumnLogFile(std::ifstream &logFileStream, } try { - Property *log = - LogParser::createLogProperty(m_filename, stringToLower(logFileName)); + Property *log = LogParser::createLogProperty( + m_filename, stringToLower(std::move(logFileName))); if (log) { run.addLogData(log); } @@ -220,7 +221,8 @@ void LoadLog::loadTwoColumnLogFile(std::ifstream &logFileStream, * @param run :: The run information object */ void LoadLog::loadThreeColumnLogFile(std::ifstream &logFileStream, - std::string logFileName, API::Run &run) { + const std::string &logFileName, + API::Run &run) { std::string str; std::string propname; std::map<std::string, std::unique_ptr<Kernel::TimeSeriesProperty<double>>> diff --git a/Framework/DataHandling/src/LoadMuonNexus.cpp b/Framework/DataHandling/src/LoadMuonNexus.cpp index 7a7b005de06ac7b29ddb1569afb42d0beb01fd46..214b258eb14a4fd68fb99f1dff7e599ef112ccc0 100644 --- a/Framework/DataHandling/src/LoadMuonNexus.cpp +++ b/Framework/DataHandling/src/LoadMuonNexus.cpp @@ -152,7 +152,7 @@ void LoadMuonNexus::checkOptionalProperties() { /// Run the Child Algorithm LoadInstrument void LoadMuonNexus::runLoadInstrument( - DataObjects::Workspace2D_sptr localWorkspace) { + const DataObjects::Workspace2D_sptr &localWorkspace) { IAlgorithm_sptr loadInst = createChildAlgorithm("LoadInstrument"); diff --git a/Framework/DataHandling/src/LoadMuonNexus1.cpp b/Framework/DataHandling/src/LoadMuonNexus1.cpp index 86ae6243d307d52f40b57eb70f16328dd9edc175..77aac4add36dd6b1ac04b5939ccd21f36d4c1a35 100644 --- a/Framework/DataHandling/src/LoadMuonNexus1.cpp +++ b/Framework/DataHandling/src/LoadMuonNexus1.cpp @@ -448,9 +448,8 @@ void LoadMuonNexus1::loadDeadTimes(NXRoot &root) { * @param inst :: Pointer to instrument (to use if IDF needed) * @returns :: Grouping table - or tables, if per period */ -Workspace_sptr -LoadMuonNexus1::loadDetectorGrouping(NXRoot &root, - Geometry::Instrument_const_sptr inst) { +Workspace_sptr LoadMuonNexus1::loadDetectorGrouping( + NXRoot &root, const Geometry::Instrument_const_sptr &inst) { NXEntry dataEntry = root.openEntry("run/histogram_data_1"); NXInfo infoGrouping = dataEntry.getDataSetInfo("grouping"); @@ -660,9 +659,10 @@ LoadMuonNexus1::createDetectorGroupingTable(std::vector<int> specToLoad, * @param localWorkspace :: A pointer to the workspace in which the data will * be stored */ -void LoadMuonNexus1::loadData(size_t hist, specnum_t &i, specnum_t specNo, - MuonNexusReader &nxload, const int64_t lengthIn, - DataObjects::Workspace2D_sptr localWorkspace) { +void LoadMuonNexus1::loadData( + size_t hist, specnum_t &i, specnum_t specNo, MuonNexusReader &nxload, + const int64_t lengthIn, + const DataObjects::Workspace2D_sptr &localWorkspace) { // Read in a spectrum // Put it into a vector, discarding the 1st entry, which is rubbish // But note that the last (overflow) bin is kept @@ -689,7 +689,7 @@ void LoadMuonNexus1::loadData(size_t hist, specnum_t &i, specnum_t specNo, * @param localWorkspace :: The workspace details to use */ void LoadMuonNexus1::loadRunDetails( - DataObjects::Workspace2D_sptr localWorkspace) { + const DataObjects::Workspace2D_sptr &localWorkspace) { API::Run &runDetails = localWorkspace->mutableRun(); runDetails.addProperty("run_title", localWorkspace->getTitle(), true); @@ -737,7 +737,8 @@ void LoadMuonNexus1::loadRunDetails( } /// Run the LoadLog Child Algorithm -void LoadMuonNexus1::runLoadLog(DataObjects::Workspace2D_sptr localWorkspace) { +void LoadMuonNexus1::runLoadLog( + const DataObjects::Workspace2D_sptr &localWorkspace) { IAlgorithm_sptr loadLog = createChildAlgorithm("LoadMuonLog"); // Pass through the same input filename loadLog->setPropertyValue("Filename", m_filename); @@ -791,8 +792,8 @@ void LoadMuonNexus1::runLoadLog(DataObjects::Workspace2D_sptr localWorkspace) { * @param localWorkspace A workspace to add the log to. * @param period A period for this workspace. */ -void LoadMuonNexus1::addPeriodLog(DataObjects::Workspace2D_sptr localWorkspace, - int64_t period) { +void LoadMuonNexus1::addPeriodLog( + const DataObjects::Workspace2D_sptr &localWorkspace, int64_t period) { auto &run = localWorkspace->mutableRun(); ISISRunLogs runLogs(run); if (period == 0) { @@ -803,8 +804,9 @@ void LoadMuonNexus1::addPeriodLog(DataObjects::Workspace2D_sptr localWorkspace, } } -void LoadMuonNexus1::addGoodFrames(DataObjects::Workspace2D_sptr localWorkspace, - int64_t period, int nperiods) { +void LoadMuonNexus1::addGoodFrames( + const DataObjects::Workspace2D_sptr &localWorkspace, int64_t period, + int nperiods) { // Get handle to nexus file ::NeXus::File handle(m_filename, NXACC_READ); diff --git a/Framework/DataHandling/src/LoadMuonNexus2.cpp b/Framework/DataHandling/src/LoadMuonNexus2.cpp index 7238470ca9ed5fd13cc890616e8ed2b8f6e62413..d1e1ba3e54aa154699164c648b60bfefa5332301 100644 --- a/Framework/DataHandling/src/LoadMuonNexus2.cpp +++ b/Framework/DataHandling/src/LoadMuonNexus2.cpp @@ -335,8 +335,8 @@ Histogram LoadMuonNexus2::loadData(const BinEdges &edges, * @param entry :: The Nexus entry * @param period :: The period of this workspace */ -void LoadMuonNexus2::loadLogs(API::MatrixWorkspace_sptr ws, NXEntry &entry, - int period) { +void LoadMuonNexus2::loadLogs(const API::MatrixWorkspace_sptr &ws, + NXEntry &entry, int period) { // Avoid compiler warning (void)period; @@ -373,7 +373,7 @@ void LoadMuonNexus2::loadLogs(API::MatrixWorkspace_sptr ws, NXEntry &entry, * @param localWorkspace :: The workspace details to use */ void LoadMuonNexus2::loadRunDetails( - DataObjects::Workspace2D_sptr localWorkspace) { + const DataObjects::Workspace2D_sptr &localWorkspace) { API::Run &runDetails = localWorkspace->mutableRun(); runDetails.addProperty("run_title", localWorkspace->getTitle(), true); diff --git a/Framework/DataHandling/src/LoadNXSPE.cpp b/Framework/DataHandling/src/LoadNXSPE.cpp index 3835e25d6ad81e2c1813830c369207072e8d0362..d574160974ec110053d45bc50f15e4d6f149e02a 100644 --- a/Framework/DataHandling/src/LoadNXSPE.cpp +++ b/Framework/DataHandling/src/LoadNXSPE.cpp @@ -353,10 +353,13 @@ void LoadNXSPE::exec() { boost::shared_ptr<Geometry::CSGObject> LoadNXSPE::createCuboid(double dx, double dy, double dz) { + UNUSED_ARG(dx) + UNUSED_ARG(dy) + UNUSED_ARG(dz) - dx = 0.5 * std::fabs(dx); - dy = 0.5 * std::fabs(dy); - dz = 0.5 * std::fabs(dz); + // dx = 0.5 * std::fabs(dx); + // dy = 0.5 * std::fabs(dy); + // dz = 0.5 * std::fabs(dz); /* std::stringstream planeName; diff --git a/Framework/DataHandling/src/LoadNXcanSAS.cpp b/Framework/DataHandling/src/LoadNXcanSAS.cpp index c288e53514ce9debfec62f0a68348533e827a6a7..b1cc42fb7c8f0167dcb990305bd0e32ee707788c 100644 --- a/Framework/DataHandling/src/LoadNXcanSAS.cpp +++ b/Framework/DataHandling/src/LoadNXcanSAS.cpp @@ -106,7 +106,8 @@ createWorkspaceForHistogram(H5::DataSet &dataSet) { // ----- LOGS -void loadLogs(H5::Group &entry, Mantid::API::MatrixWorkspace_sptr workspace) { +void loadLogs(H5::Group &entry, + const Mantid::API::MatrixWorkspace_sptr &workspace) { auto &run = workspace->mutableRun(); // Load UserFile (optional) @@ -133,7 +134,7 @@ void loadLogs(H5::Group &entry, Mantid::API::MatrixWorkspace_sptr workspace) { } // ----- INSTRUMENT -std::string extractIdfFileOnCurrentSystem(std::string idf) { +std::string extractIdfFileOnCurrentSystem(const std::string &idf) { // If the idf is is not empty extract the last element from the file if (idf.empty()) { return ""; @@ -161,7 +162,7 @@ std::string extractIdfFileOnCurrentSystem(std::string idf) { } void loadInstrument(H5::Group &entry, - Mantid::API::MatrixWorkspace_sptr workspace) { + const Mantid::API::MatrixWorkspace_sptr &workspace) { auto instrument = entry.openGroup(sasInstrumentGroupName); // Get instrument name @@ -232,7 +233,7 @@ bool hasQDev(H5::Group &dataGroup) { } void loadData1D(H5::Group &dataGroup, - Mantid::API::MatrixWorkspace_sptr workspace) { + const Mantid::API::MatrixWorkspace_sptr &workspace) { // General workspace->setDistribution(true); @@ -268,7 +269,7 @@ void loadData1D(H5::Group &dataGroup, template <typename Functor> void read2DWorkspace(H5::DataSet &dataSet, Mantid::API::MatrixWorkspace_sptr workspace, Functor func, - H5::DataType memoryDataType) { + const H5::DataType &memoryDataType) { using namespace Mantid::DataHandling::NXcanSAS; auto dimInfo = getDataSpaceInfo(dataSet); @@ -297,8 +298,8 @@ void read2DWorkspace(H5::DataSet &dataSet, } void readQyInto2DWorkspace(H5::DataSet &dataSet, - Mantid::API::MatrixWorkspace_sptr workspace, - H5::DataType memoryDataType) { + const Mantid::API::MatrixWorkspace_sptr &workspace, + const H5::DataType &memoryDataType) { using namespace Mantid::DataHandling::NXcanSAS; // Get info about the data set @@ -342,13 +343,13 @@ void readQyInto2DWorkspace(H5::DataSet &dataSet, } void loadData2D(H5::Group &dataGroup, - Mantid::API::MatrixWorkspace_sptr workspace) { + const Mantid::API::MatrixWorkspace_sptr &workspace) { // General workspace->setDistribution(true); //----------------------------------------- // Load the I value. auto iDataSet = dataGroup.openDataSet(sasDataI); - auto iExtractor = [](Mantid::API::MatrixWorkspace_sptr ws, + auto iExtractor = [](const Mantid::API::MatrixWorkspace_sptr &ws, size_t index) -> HistogramY & { return ws->mutableY(index); }; @@ -360,7 +361,7 @@ void loadData2D(H5::Group &dataGroup, //----------------------------------------- // Load the Idev value auto eDataSet = dataGroup.openDataSet(sasDataIdev); - auto eExtractor = [](Mantid::API::MatrixWorkspace_sptr ws, + auto eExtractor = [](const Mantid::API::MatrixWorkspace_sptr &ws, size_t index) -> HistogramE & { return ws->mutableE(index); }; @@ -369,7 +370,7 @@ void loadData2D(H5::Group &dataGroup, //----------------------------------------- // Load the Qx value + units auto qxDataSet = dataGroup.openDataSet(sasDataQx); - auto qxExtractor = [](Mantid::API::MatrixWorkspace_sptr ws, + auto qxExtractor = [](const Mantid::API::MatrixWorkspace_sptr &ws, size_t index) -> HistogramX & { return ws->mutableX(index); }; @@ -384,7 +385,8 @@ void loadData2D(H5::Group &dataGroup, readQyInto2DWorkspace(qyDataSet, workspace, qyDataType); } -void loadData(H5::Group &entry, Mantid::API::MatrixWorkspace_sptr workspace) { +void loadData(H5::Group &entry, + const Mantid::API::MatrixWorkspace_sptr &workspace) { auto dataGroup = entry.openGroup(sasDataGroupName); auto dimensionality = getWorkspaceDimensionality(dataGroup); switch (dimensionality) { @@ -433,7 +435,7 @@ bool hasTransmissionEntry(H5::Group &entry, const std::string &name) { } void loadTransmissionData(H5::Group &transmission, - Mantid::API::MatrixWorkspace_sptr workspace) { + const Mantid::API::MatrixWorkspace_sptr &workspace) { //----------------------------------------- // Load T workspace->mutableY(0) = diff --git a/Framework/DataHandling/src/LoadNexusLogs.cpp b/Framework/DataHandling/src/LoadNexusLogs.cpp index 3e44d7f2aba8a9af6ac34e194aeb2bb940963164..5e328a533e060bf7c39a579f742fa008ae86e623 100644 --- a/Framework/DataHandling/src/LoadNexusLogs.cpp +++ b/Framework/DataHandling/src/LoadNexusLogs.cpp @@ -549,7 +549,7 @@ void LoadNexusLogs::exec() { */ void LoadNexusLogs::loadVetoPulses( ::NeXus::File &file, - boost::shared_ptr<API::MatrixWorkspace> workspace) const { + const boost::shared_ptr<API::MatrixWorkspace> &workspace) const { try { file.openGroup("Veto_pulse", "NXgroup"); } catch (::NeXus::Exception &) { @@ -583,7 +583,7 @@ void LoadNexusLogs::loadVetoPulses( void LoadNexusLogs::loadNPeriods( ::NeXus::File &file, - boost::shared_ptr<API::MatrixWorkspace> workspace) const { + const boost::shared_ptr<API::MatrixWorkspace> &workspace) const { int value = 1; // Default to 1-period unless try { file.openGroup("periods", "IXperiods"); @@ -648,7 +648,7 @@ void LoadNexusLogs::loadNPeriods( void LoadNexusLogs::loadLogs( ::NeXus::File &file, const std::string &entry_name, const std::string &entry_class, - boost::shared_ptr<API::MatrixWorkspace> workspace) const { + const boost::shared_ptr<API::MatrixWorkspace> &workspace) const { file.openGroup(entry_name, entry_class); std::map<std::string, std::string> entries = file.getEntries(); std::map<std::string, std::string>::const_iterator iend = entries.end(); @@ -677,7 +677,7 @@ void LoadNexusLogs::loadLogs( void LoadNexusLogs::loadNXLog( ::NeXus::File &file, const std::string &entry_name, const std::string &entry_class, - boost::shared_ptr<API::MatrixWorkspace> workspace) const { + const boost::shared_ptr<API::MatrixWorkspace> &workspace) const { g_log.debug() << "processing " << entry_name << ":" << entry_class << "\n"; file.openGroup(entry_name, entry_class); @@ -715,7 +715,7 @@ void LoadNexusLogs::loadNXLog( */ void LoadNexusLogs::loadSELog( ::NeXus::File &file, const std::string &entry_name, - boost::shared_ptr<API::MatrixWorkspace> workspace) const { + const boost::shared_ptr<API::MatrixWorkspace> &workspace) const { // Open the entry file.openGroup(entry_name, "IXseblock"); std::string propName = entry_name; diff --git a/Framework/DataHandling/src/LoadNexusMonitors2.cpp b/Framework/DataHandling/src/LoadNexusMonitors2.cpp index 494bf5036de70680747e9d2c955310c091b65bee..8abcaf1e5414537d323b58731dc580afdfe75f5e 100644 --- a/Framework/DataHandling/src/LoadNexusMonitors2.cpp +++ b/Framework/DataHandling/src/LoadNexusMonitors2.cpp @@ -47,7 +47,7 @@ DECLARE_ALGORITHM(LoadNexusMonitors2) namespace { void loadSampleDataISIScompatibilityInfo( - ::NeXus::File &file, Mantid::API::MatrixWorkspace_sptr const WS) { + ::NeXus::File &file, Mantid::API::MatrixWorkspace_sptr const &WS) { try { file.openGroup("isis_vms_compat", "IXvms"); } catch (::NeXus::Exception &) { @@ -403,8 +403,9 @@ void LoadNexusMonitors2::fixUDets(::NeXus::File &file) { } } -void LoadNexusMonitors2::runLoadLogs(const std::string filename, - API::MatrixWorkspace_sptr localWorkspace) { +void LoadNexusMonitors2::runLoadLogs( + const std::string &filename, + const API::MatrixWorkspace_sptr &localWorkspace) { // do the actual work API::IAlgorithm_sptr loadLogs = createChildAlgorithm("LoadNexusLogs"); diff --git a/Framework/DataHandling/src/LoadNexusProcessed.cpp b/Framework/DataHandling/src/LoadNexusProcessed.cpp index 270d6e2edd89b7c3203467e7f2e2aba9890524c8..beb8c91a4dc5412d098c51e5f0e088aeeba48cbc 100644 --- a/Framework/DataHandling/src/LoadNexusProcessed.cpp +++ b/Framework/DataHandling/src/LoadNexusProcessed.cpp @@ -156,7 +156,7 @@ SpectraInfo extractMappingInfo(NXEntry &mtd_entry, Logger &logger) { * @param log : Information logger object * @return True only if multiperiod. */ -bool isMultiPeriodFile(int nWorkspaceEntries, Workspace_sptr sampleWS, +bool isMultiPeriodFile(int nWorkspaceEntries, const Workspace_sptr &sampleWS, Logger &log) { bool isMultiPeriod = false; if (ExperimentInfo_sptr expInfo = @@ -1736,7 +1736,7 @@ std::map<std::string, std::string> LoadNexusProcessed::validateInputs() { * @param data :: reference to the NeXuS data for the axis */ void LoadNexusProcessed::loadNonSpectraAxis( - API::MatrixWorkspace_sptr local_workspace, NXData &data) { + const API::MatrixWorkspace_sptr &local_workspace, NXData &data) { Axis *axis = local_workspace->getAxis(1); if (axis->isNumeric()) { @@ -1773,7 +1773,7 @@ void LoadNexusProcessed::loadNonSpectraAxis( * @param elem1 :: first element in the vector * @param elem2 :: second element in the vecor */ -bool UDlesserExecCount(NXClassInfo elem1, NXClassInfo elem2) { +bool UDlesserExecCount(const NXClassInfo &elem1, const NXClassInfo &elem2) { std::string::size_type index1, index2; std::string num1, num2; // find the number after "_" in algorithm name ( eg:MantidAlogorthm_1) @@ -1859,7 +1859,7 @@ void LoadNexusProcessed::getWordsInString(const std::string &words4, * @param local_workspace :: The workspace to read into */ void LoadNexusProcessed::readBinMasking( - NXData &wksp_cls, API::MatrixWorkspace_sptr local_workspace) { + NXData &wksp_cls, const API::MatrixWorkspace_sptr &local_workspace) { if (wksp_cls.getDataSetInfo("masked_spectra").stat == NX_ERROR) { return; } @@ -1897,12 +1897,11 @@ void LoadNexusProcessed::readBinMasking( * @param hist :: The workspace index to start reading into * @param local_workspace :: A pointer to the workspace */ -void LoadNexusProcessed::loadBlock(NXDataSetTyped<double> &data, - NXDataSetTyped<double> &errors, - NXDataSetTyped<double> &farea, bool hasFArea, - NXDouble &xErrors, bool hasXErrors, - int blocksize, int nchannels, int &hist, - API::MatrixWorkspace_sptr local_workspace) { +void LoadNexusProcessed::loadBlock( + NXDataSetTyped<double> &data, NXDataSetTyped<double> &errors, + NXDataSetTyped<double> &farea, bool hasFArea, NXDouble &xErrors, + bool hasXErrors, int blocksize, int nchannels, int &hist, + const API::MatrixWorkspace_sptr &local_workspace) { data.load(blocksize, hist); errors.load(blocksize, hist); double *data_start = data(); @@ -1979,13 +1978,11 @@ void LoadNexusProcessed::loadBlock(NXDataSetTyped<double> &data, * @param local_workspace :: A pointer to the workspace */ -void LoadNexusProcessed::loadBlock(NXDataSetTyped<double> &data, - NXDataSetTyped<double> &errors, - NXDataSetTyped<double> &farea, bool hasFArea, - NXDouble &xErrors, bool hasXErrors, - int blocksize, int nchannels, int &hist, - int &wsIndex, - API::MatrixWorkspace_sptr local_workspace) { +void LoadNexusProcessed::loadBlock( + NXDataSetTyped<double> &data, NXDataSetTyped<double> &errors, + NXDataSetTyped<double> &farea, bool hasFArea, NXDouble &xErrors, + bool hasXErrors, int blocksize, int nchannels, int &hist, int &wsIndex, + const API::MatrixWorkspace_sptr &local_workspace) { data.load(blocksize, hist); errors.load(blocksize, hist); double *data_start = data(); @@ -2062,13 +2059,11 @@ void LoadNexusProcessed::loadBlock(NXDataSetTyped<double> &data, * @param wsIndex :: The workspace index to save data into * @param local_workspace :: A pointer to the workspace */ -void LoadNexusProcessed::loadBlock(NXDataSetTyped<double> &data, - NXDataSetTyped<double> &errors, - NXDataSetTyped<double> &farea, bool hasFArea, - NXDouble &xErrors, bool hasXErrors, - NXDouble &xbins, int blocksize, - int nchannels, int &hist, int &wsIndex, - API::MatrixWorkspace_sptr local_workspace) { +void LoadNexusProcessed::loadBlock( + NXDataSetTyped<double> &data, NXDataSetTyped<double> &errors, + NXDataSetTyped<double> &farea, bool hasFArea, NXDouble &xErrors, + bool hasXErrors, NXDouble &xbins, int blocksize, int nchannels, int &hist, + int &wsIndex, const API::MatrixWorkspace_sptr &local_workspace) { data.load(blocksize, hist); double *data_start = data(); double *data_end = data_start + nchannels; diff --git a/Framework/DataHandling/src/LoadOff.cpp b/Framework/DataHandling/src/LoadOff.cpp index 1ef80513f9ff17d0ebca2d6d41056671af8fe5d6..f67ce2dacaa1c14629d2ca915f350c2b6ce1ae06 100644 --- a/Framework/DataHandling/src/LoadOff.cpp +++ b/Framework/DataHandling/src/LoadOff.cpp @@ -15,7 +15,7 @@ namespace Mantid { namespace DataHandling { -LoadOff::LoadOff(std::string filename, ScaleUnits scaleType) +LoadOff::LoadOff(const std::string &filename, ScaleUnits scaleType) : MeshFileIO(scaleType) { m_file = std::ifstream(filename.c_str()); if (!m_file) { diff --git a/Framework/DataHandling/src/LoadPDFgetNFile.cpp b/Framework/DataHandling/src/LoadPDFgetNFile.cpp index 2a934c4cfb37ac4c26a19f85444d6a8d9ef97dc5..6f6fec0ad9add2cdb6b6ba94b1d07ceccca9749e 100644 --- a/Framework/DataHandling/src/LoadPDFgetNFile.cpp +++ b/Framework/DataHandling/src/LoadPDFgetNFile.cpp @@ -106,7 +106,7 @@ void LoadPDFgetNFile::exec() { * 1. a 2D vector for column data * 2. a 1D string vector for column name */ -void LoadPDFgetNFile::parseDataFile(std::string filename) { +void LoadPDFgetNFile::parseDataFile(const std::string &filename) { // 1. Open file std::ifstream ifile; ifile.open((filename.c_str())); @@ -257,7 +257,7 @@ void LoadPDFgetNFile::parseDataLine(string line) { } //---------------------------------------------------------------------------------------------- -void LoadPDFgetNFile::setUnit(Workspace2D_sptr ws) { +void LoadPDFgetNFile::setUnit(const Workspace2D_sptr &ws) { // 1. Set X string xcolname = mColumnNames[0]; diff --git a/Framework/DataHandling/src/LoadPSIMuonBin.cpp b/Framework/DataHandling/src/LoadPSIMuonBin.cpp index e720abdfb82f0e6796fa4acb6ac46f3bcbd0b20a..c0895643e2b450325011680d68cee27c632c16a2 100644 --- a/Framework/DataHandling/src/LoadPSIMuonBin.cpp +++ b/Framework/DataHandling/src/LoadPSIMuonBin.cpp @@ -234,8 +234,8 @@ void LoadPSIMuonBin::makeDeadTimeTable(const size_t &numSpec) { setProperty("DeadTimeTable", deadTimeTable); } -std::string LoadPSIMuonBin::getFormattedDateTime(std::string date, - std::string time) { +std::string LoadPSIMuonBin::getFormattedDateTime(const std::string &date, + const std::string &time) { std::string year; if (date.size() == 11) { year = date.substr(7, 4); diff --git a/Framework/DataHandling/src/LoadPreNexusMonitors.cpp b/Framework/DataHandling/src/LoadPreNexusMonitors.cpp index d674efbbbee724610fe4e1feded2defb73e9c32e..29dd9cca6fb69bdac16d481d8f35ba12b6e03f21 100644 --- a/Framework/DataHandling/src/LoadPreNexusMonitors.cpp +++ b/Framework/DataHandling/src/LoadPreNexusMonitors.cpp @@ -226,7 +226,7 @@ void LoadPreNexusMonitors::exec() { * geometry */ void LoadPreNexusMonitors::runLoadInstrument( - const std::string &instrument, MatrixWorkspace_sptr localWorkspace) { + const std::string &instrument, const MatrixWorkspace_sptr &localWorkspace) { IAlgorithm_sptr loadInst = createChildAlgorithm("LoadInstrument"); diff --git a/Framework/DataHandling/src/LoadRKH.cpp b/Framework/DataHandling/src/LoadRKH.cpp index 2e31b6cb0f8db6551f6e87828395734d33925742..dcaa1c1d5847562c917e8a894f87c3bd71be710f 100644 --- a/Framework/DataHandling/src/LoadRKH.cpp +++ b/Framework/DataHandling/src/LoadRKH.cpp @@ -585,7 +585,7 @@ void LoadRKH::skipLines(std::istream &strm, int nlines) { * @param[out] toCenter an array that is one shorter than oldBoundaries, the * values of the means of pairs of values from the input */ -void LoadRKH::binCenter(const MantidVec oldBoundaries, +void LoadRKH::binCenter(const MantidVec &oldBoundaries, MantidVec &toCenter) const { VectorHelper::convertToBinCentre(oldBoundaries, toCenter); } diff --git a/Framework/DataHandling/src/LoadRaw/isisraw.cpp b/Framework/DataHandling/src/LoadRaw/isisraw.cpp index 60ed63f04b248c1f47b97bec4858b1089fa28c07..4f583929f01245a5ec2bea5a8cde64a08f63934f 100644 --- a/Framework/DataHandling/src/LoadRaw/isisraw.cpp +++ b/Framework/DataHandling/src/LoadRaw/isisraw.cpp @@ -715,10 +715,10 @@ int ISISRAW::ioRAW(FILE *file, LOG_STRUCT *s, int len, bool from_file) { int ISISRAW::ioRAW(FILE *file, LOG_LINE *s, int len, bool from_file) { char padding[5]; memset(padding, ' ', sizeof(padding)); - int i, nbytes_rounded; + int i; for (i = 0; i < len; i++) { ioRAW(file, &(s[i].len), 1, from_file); - nbytes_rounded = 4 * (1 + (s[i].len - 1) / 4); + int nbytes_rounded = 4 * (1 + (s[i].len - 1) / 4); ioRAW(file, &(s[i].data), s[i].len, from_file); ioRAW(file, padding, nbytes_rounded - s[i].len, from_file); } @@ -731,12 +731,11 @@ int ISISRAW::ioRAW(FILE *file, char *s, int len, bool from_file) { return 0; } - size_t n; if (from_file) { - n = fread(s, sizeof(char), len, file); + size_t n = fread(s, sizeof(char), len, file); return static_cast<int>(n - len); } else { - n = fwrite(s, sizeof(char), len, file); + fwrite(s, sizeof(char), len, file); } return 0; @@ -748,12 +747,11 @@ int ISISRAW::ioRAW(FILE *file, int *s, int len, bool from_file) { return 0; } - size_t n; if (from_file) { - n = fread(s, sizeof(int), len, file); + size_t n = fread(s, sizeof(int), len, file); return static_cast<int>(n - len); } else { - n = fwrite(s, sizeof(int), len, file); + fwrite(s, sizeof(int), len, file); } return 0; @@ -765,12 +763,11 @@ int ISISRAW::ioRAW(FILE *file, uint32_t *s, int len, bool from_file) { return 0; } - size_t n; if (from_file) { - n = fread(s, sizeof(uint32_t), len, file); + size_t n = fread(s, sizeof(uint32_t), len, file); return static_cast<int>(n - len); } else { - n = fwrite(s, sizeof(uint32_t), len, file); + fwrite(s, sizeof(uint32_t), len, file); } return 0; } @@ -782,14 +779,13 @@ int ISISRAW::ioRAW(FILE *file, float *s, int len, bool from_file) { return 0; } - size_t n; if (from_file) { - n = fread(s, sizeof(float), len, file); + size_t n = fread(s, sizeof(float), len, file); vaxf_to_local(s, &len, &errcode); return static_cast<int>(n - len); } else { local_to_vaxf(s, &len, &errcode); - n = fwrite(s, sizeof(float), len, file); + fwrite(s, sizeof(float), len, file); vaxf_to_local(s, &len, &errcode); } return 0; @@ -942,6 +938,7 @@ int ISISRAW::vmstime(char *timbuf, int len, time_t time_value) { * get time in VMS format 01-JAN-1970 00:00:00 */ size_t i, n; + // cppcheck-suppress redundantAssignment struct tm *tmstruct = nullptr; #ifdef MS_VISUAL_STUDIO errno_t err = localtime_s(tmstruct, &time_value); diff --git a/Framework/DataHandling/src/LoadRaw3.cpp b/Framework/DataHandling/src/LoadRaw3.cpp index 13f5d13647f9625ab0453a0fc74b40dee68d33fe..a964ca6db5f6d4c947247cf905541e57dffdbeac 100644 --- a/Framework/DataHandling/src/LoadRaw3.cpp +++ b/Framework/DataHandling/src/LoadRaw3.cpp @@ -311,7 +311,7 @@ void LoadRaw3::exec() { */ void LoadRaw3::excludeMonitors(FILE *file, const int &period, const std::vector<specnum_t> &monitorList, - DataObjects::Workspace2D_sptr ws_sptr) { + const DataObjects::Workspace2D_sptr &ws_sptr) { int64_t histCurrent = -1; int64_t wsIndex = 0; auto histTotal = static_cast<double>(m_total_specs * m_numberOfPeriods); @@ -358,7 +358,7 @@ void LoadRaw3::excludeMonitors(FILE *file, const int &period, *@param ws_sptr :: shared pointer to workspace */ void LoadRaw3::includeMonitors(FILE *file, const int64_t &period, - DataObjects::Workspace2D_sptr ws_sptr) { + const DataObjects::Workspace2D_sptr &ws_sptr) { int64_t histCurrent = -1; int64_t wsIndex = 0; @@ -404,8 +404,8 @@ void LoadRaw3::includeMonitors(FILE *file, const int64_t &period, void LoadRaw3::separateMonitors(FILE *file, const int64_t &period, const std::vector<specnum_t> &monitorList, - DataObjects::Workspace2D_sptr ws_sptr, - DataObjects::Workspace2D_sptr mws_sptr) { + const DataObjects::Workspace2D_sptr &ws_sptr, + const DataObjects::Workspace2D_sptr &mws_sptr) { int64_t histCurrent = -1; int64_t wsIndex = 0; int64_t mwsIndex = 0; diff --git a/Framework/DataHandling/src/LoadRawHelper.cpp b/Framework/DataHandling/src/LoadRawHelper.cpp index 83682479d5d30ec5d87b9e74ec490bcea3dc4e3d..49410e7ce21bf7ac8ee03675c71922ed6d050338 100644 --- a/Framework/DataHandling/src/LoadRawHelper.cpp +++ b/Framework/DataHandling/src/LoadRawHelper.cpp @@ -216,7 +216,7 @@ void LoadRawHelper::readworkspaceParameters(specnum_t &numberOfSpectra, * @return an empty workspace of the given parameters */ DataObjects::Workspace2D_sptr -LoadRawHelper::createWorkspace(DataObjects::Workspace2D_sptr ws_sptr, +LoadRawHelper::createWorkspace(const DataObjects::Workspace2D_sptr &ws_sptr, int64_t nVectors, int64_t xLengthIn, int64_t yLengthIn) { DataObjects::Workspace2D_sptr empty; @@ -270,7 +270,7 @@ void LoadRawHelper::createMonitorWorkspace( DataObjects::Workspace2D_sptr &normalws_sptr, WorkspaceGroup_sptr &mongrp_sptr, const int64_t mwsSpecs, const int64_t nwsSpecs, const int64_t numberOfPeriods, - const int64_t lengthIn, const std::string title, + const int64_t lengthIn, const std::string &title, API::Algorithm *const pAlg) { try { // create monitor group workspace @@ -328,10 +328,10 @@ void LoadRawHelper::exec() {} * @param bmonitors :: boolean flag to name the workspaces * @param pAlg :: pointer to algorithm this method works with. */ -void LoadRawHelper::setWorkspaceProperty(DataObjects::Workspace2D_sptr ws_sptr, - WorkspaceGroup_sptr grpws_sptr, - const int64_t period, bool bmonitors, - API::Algorithm *const pAlg) { +void LoadRawHelper::setWorkspaceProperty( + const DataObjects::Workspace2D_sptr &ws_sptr, + const WorkspaceGroup_sptr &grpws_sptr, const int64_t period, bool bmonitors, + API::Algorithm *const pAlg) { if (!ws_sptr) return; if (!grpws_sptr) @@ -366,12 +366,11 @@ void LoadRawHelper::setWorkspaceProperty(DataObjects::Workspace2D_sptr ws_sptr, * workspace * @param pAlg :: pointer to algorithm this method works with. */ -void LoadRawHelper::setWorkspaceProperty(const std::string &propertyName, - const std::string &title, - WorkspaceGroup_sptr grpws_sptr, - DataObjects::Workspace2D_sptr ws_sptr, - int64_t numberOfPeriods, bool bMonitor, - API::Algorithm *const pAlg) { +void LoadRawHelper::setWorkspaceProperty( + const std::string &propertyName, const std::string &title, + const WorkspaceGroup_sptr &grpws_sptr, + const DataObjects::Workspace2D_sptr &ws_sptr, int64_t numberOfPeriods, + bool bMonitor, API::Algorithm *const pAlg) { UNUSED_ARG(bMonitor); Property *ws = pAlg->getProperty("OutputWorkspace"); if (!ws) @@ -401,7 +400,7 @@ void LoadRawHelper::setWorkspaceProperty(const std::string &propertyName, * @param binStart :: start of bin */ void LoadRawHelper::setWorkspaceData( - DataObjects::Workspace2D_sptr newWorkspace, + const DataObjects::Workspace2D_sptr &newWorkspace, const std::vector<boost::shared_ptr<HistogramData::HistogramX>> &timeChannelsVec, int64_t wsIndex, specnum_t nspecNum, int64_t noTimeRegimes, @@ -544,8 +543,9 @@ LoadRawHelper::getTimeChannels(const int64_t ®imes, /// @param progStart :: progress at start /// @param progEnd :: progress at end void LoadRawHelper::runLoadInstrument( - const std::string &fileName, DataObjects::Workspace2D_sptr localWorkspace, - double progStart, double progEnd) { + const std::string &fileName, + const DataObjects::Workspace2D_sptr &localWorkspace, double progStart, + double progEnd) { g_log.debug("Loading the instrument definition..."); m_prog = progStart; progress(m_prog, "Loading the instrument geometry..."); @@ -631,7 +631,8 @@ void LoadRawHelper::runLoadInstrument( /// @param fileName :: the raw file filename /// @param localWorkspace :: The workspace to load the instrument for void LoadRawHelper::runLoadInstrumentFromRaw( - const std::string &fileName, DataObjects::Workspace2D_sptr localWorkspace) { + const std::string &fileName, + const DataObjects::Workspace2D_sptr &localWorkspace) { IAlgorithm_sptr loadInst = createChildAlgorithm("LoadInstrumentFromRaw"); loadInst->setPropertyValue("Filename", fileName); // Set the workspace property to be the same one filled above @@ -659,7 +660,8 @@ void LoadRawHelper::runLoadInstrumentFromRaw( /// @param fileName :: the raw file filename /// @param localWorkspace :: The workspace to load the mapping table for void LoadRawHelper::runLoadMappingTable( - const std::string &fileName, DataObjects::Workspace2D_sptr localWorkspace) { + const std::string &fileName, + const DataObjects::Workspace2D_sptr &localWorkspace) { g_log.debug("Loading the spectra-detector mapping..."); progress(m_prog, "Loading the spectra-detector mapping..."); // Now determine the spectra to detector map calling Child Algorithm @@ -685,9 +687,10 @@ void LoadRawHelper::runLoadMappingTable( /// @param localWorkspace :: The workspace to load the logs for /// @param progStart :: starting progress fraction /// @param progEnd :: ending progress fraction -void LoadRawHelper::runLoadLog(const std::string &fileName, - DataObjects::Workspace2D_sptr localWorkspace, - double progStart, double progEnd) { +void LoadRawHelper::runLoadLog( + const std::string &fileName, + const DataObjects::Workspace2D_sptr &localWorkspace, double progStart, + double progEnd) { // search for the log file to load, and save their names in a set. std::list<std::string> logFiles = searchForLogFiles(fileName); @@ -773,7 +776,7 @@ std::string LoadRawHelper::extractLogName(const std::string &path) { * @param local_workspace :: workspace to add period log data to. */ void LoadRawHelper::createPeriodLogs( - int64_t period, DataObjects::Workspace2D_sptr local_workspace) { + int64_t period, const DataObjects::Workspace2D_sptr &local_workspace) { m_logCreator->addPeriodLogs(static_cast<int>(period), local_workspace->mutableRun()); } @@ -785,8 +788,9 @@ void LoadRawHelper::createPeriodLogs( * @param localWorkspace :: The workspace to attach the information to * @param rawFile :: The handle to an ISIS Raw file */ -void LoadRawHelper::loadRunParameters(API::MatrixWorkspace_sptr localWorkspace, - ISISRAW *const rawFile) const { +void LoadRawHelper::loadRunParameters( + const API::MatrixWorkspace_sptr &localWorkspace, + ISISRAW *const rawFile) const { ISISRAW &localISISRaw = [this, rawFile]() -> ISISRAW & { if (rawFile) return *rawFile; @@ -1098,8 +1102,9 @@ void LoadRawHelper::calculateWorkspacesizes( void LoadRawHelper::loadSpectra( FILE *file, const int &period, const int &total_specs, - DataObjects::Workspace2D_sptr ws_sptr, - std::vector<boost::shared_ptr<HistogramData::HistogramX>> timeChannelsVec) { + const DataObjects::Workspace2D_sptr &ws_sptr, + const std::vector<boost::shared_ptr<HistogramData::HistogramX>> + &timeChannelsVec) { double progStart = m_prog; double progEnd = 1.0; // Assume this function is called last diff --git a/Framework/DataHandling/src/LoadSPE.cpp b/Framework/DataHandling/src/LoadSPE.cpp index 11218db3a9ad05f93c688993d9468ad8d966e1f6..791b44ecdf01f8d7179d9e6c3f28ecb5b7d913ce 100644 --- a/Framework/DataHandling/src/LoadSPE.cpp +++ b/Framework/DataHandling/src/LoadSPE.cpp @@ -185,7 +185,8 @@ void LoadSPE::exec() { * @param workspace :: The output workspace * @param index :: The index of the current spectrum */ -void LoadSPE::readHistogram(FILE *speFile, API::MatrixWorkspace_sptr workspace, +void LoadSPE::readHistogram(FILE *speFile, + const API::MatrixWorkspace_sptr &workspace, size_t index) { // First, there should be a comment line char comment[100]; diff --git a/Framework/DataHandling/src/LoadSampleShape.cpp b/Framework/DataHandling/src/LoadSampleShape.cpp index 7e438fe4976fdefdc9225aad6a6772faa65aa685..1ab9f5ac533c4e64934fd78f45845e251020280d 100644 --- a/Framework/DataHandling/src/LoadSampleShape.cpp +++ b/Framework/DataHandling/src/LoadSampleShape.cpp @@ -99,7 +99,7 @@ void LoadSampleShape::exec() { * @param inputWS The workspace to get the rotation from * @returns a shared pointer to the newly rotated Shape */ -void rotate(MeshObject &sampleMesh, MatrixWorkspace_const_sptr inputWS) { +void rotate(MeshObject &sampleMesh, const MatrixWorkspace_const_sptr &inputWS) { const std::vector<double> rotationMatrix = inputWS->run().getGoniometer().getR(); sampleMesh.rotate(rotationMatrix); diff --git a/Framework/DataHandling/src/LoadSassena.cpp b/Framework/DataHandling/src/LoadSassena.cpp index 95ebc7333d7514046aa51934505d7a0d5bc5c130..0635840afa17101d9d464afeec450e8e34fe8e27 100644 --- a/Framework/DataHandling/src/LoadSassena.cpp +++ b/Framework/DataHandling/src/LoadSassena.cpp @@ -20,6 +20,8 @@ #include <hdf5_hl.h> +#include <utility> + namespace Mantid { namespace DataHandling { @@ -47,9 +49,9 @@ int LoadSassena::confidence(Kernel::NexusDescriptor &descriptor) const { * @param ws pointer to workspace to be added and registered * @param description */ -void LoadSassena::registerWorkspace(API::WorkspaceGroup_sptr gws, - const std::string wsName, - DataObjects::Workspace2D_sptr ws, +void LoadSassena::registerWorkspace(const API::WorkspaceGroup_sptr &gws, + const std::string &wsName, + const DataObjects::Workspace2D_sptr &ws, const std::string &description) { UNUSED_ARG(description); API::AnalysisDataService::Instance().add(wsName, ws); @@ -63,7 +65,7 @@ void LoadSassena::registerWorkspace(API::WorkspaceGroup_sptr gws, * @param dims storing dimensionality */ -herr_t LoadSassena::dataSetInfo(const hid_t &h5file, const std::string setName, +herr_t LoadSassena::dataSetInfo(const hid_t &h5file, const std::string &setName, hsize_t *dims) const { H5T_class_t class_id; size_t type_size; @@ -82,7 +84,7 @@ herr_t LoadSassena::dataSetInfo(const hid_t &h5file, const std::string setName, * @param buf storing dataset */ herr_t LoadSassena::dataSetDouble(const hid_t &h5file, - const std::string setName, + const std::string &setName, std::vector<double> &buf) { herr_t errorcode = H5LTread_dataset_double(h5file, setName.c_str(), buf.data()); @@ -110,7 +112,8 @@ bool compare(const mypair &left, const mypair &right) { * increasing order of momemtum transfer */ HistogramData::Points -LoadSassena::loadQvectors(const hid_t &h5file, API::WorkspaceGroup_sptr gws, +LoadSassena::loadQvectors(const hid_t &h5file, + const API::WorkspaceGroup_sptr &gws, std::vector<int> &sorting_indexes) { // store the modulus of the vector @@ -169,7 +172,8 @@ LoadSassena::loadQvectors(const hid_t &h5file, API::WorkspaceGroup_sptr gws, "MomentumTransfer"); // Set the Units this->registerWorkspace( - gws, wsName, ws, "X-axis: origin of Q-vectors; Y-axis: tip of Q-vectors"); + std::move(gws), wsName, ws, + "X-axis: origin of Q-vectors; Y-axis: tip of Q-vectors"); return HistogramData::Points(std::move(qvmod)); } @@ -184,8 +188,9 @@ LoadSassena::loadQvectors(const hid_t &h5file, API::WorkspaceGroup_sptr gws, * @param sorting_indexes permutation of qvmod indexes to render it in * increasing order of momemtum transfer */ -void LoadSassena::loadFQ(const hid_t &h5file, API::WorkspaceGroup_sptr gws, - const std::string setName, +void LoadSassena::loadFQ(const hid_t &h5file, + const API::WorkspaceGroup_sptr &gws, + const std::string &setName, const HistogramData::Points &qvmod, const std::vector<int> &sorting_indexes) { @@ -221,7 +226,7 @@ void LoadSassena::loadFQ(const hid_t &h5file, API::WorkspaceGroup_sptr gws, Kernel::UnitFactory::Instance().create("MomentumTransfer"); this->registerWorkspace( - gws, wsName, ws, + std::move(gws), wsName, ws, "X-axis: Q-vector modulus; Y-axis: intermediate structure factor"); } @@ -238,8 +243,9 @@ void LoadSassena::loadFQ(const hid_t &h5file, API::WorkspaceGroup_sptr gws, * @param sorting_indexes permutation of qvmod indexes to render it in * increasing order of momemtum transfer */ -void LoadSassena::loadFQT(const hid_t &h5file, API::WorkspaceGroup_sptr gws, - const std::string setName, +void LoadSassena::loadFQT(const hid_t &h5file, + const API::WorkspaceGroup_sptr &gws, + const std::string &setName, const HistogramData::Points &qvmod, const std::vector<int> &sorting_indexes) { diff --git a/Framework/DataHandling/src/LoadSpice2D.cpp b/Framework/DataHandling/src/LoadSpice2D.cpp index 34287f8771884a5a17f872282cc687e15f6003f2..0b71b10809625963f8b46093e64cab6cc372cc79 100644 --- a/Framework/DataHandling/src/LoadSpice2D.cpp +++ b/Framework/DataHandling/src/LoadSpice2D.cpp @@ -80,8 +80,9 @@ bool from_string(T &t, const std::string &s, * @param wavelength: wavelength value [Angstrom] * @param dwavelength: error on the wavelength [Angstrom] */ -void store_value(DataObjects::Workspace2D_sptr ws, int specID, double value, - double error, double wavelength, double dwavelength) { +void store_value(const DataObjects::Workspace2D_sptr &ws, int specID, + double value, double error, double wavelength, + double dwavelength) { auto &X = ws->mutableX(specID); auto &Y = ws->mutableY(specID); auto &E = ws->mutableE(specID); @@ -659,7 +660,7 @@ void LoadSpice2D::detectorTranslation( */ void LoadSpice2D::runLoadInstrument( const std::string &inst_name, - DataObjects::Workspace2D_sptr localWorkspace) { + const DataObjects::Workspace2D_sptr &localWorkspace) { API::IAlgorithm_sptr loadInst = createChildAlgorithm("LoadInstrument"); diff --git a/Framework/DataHandling/src/LoadSpiceAscii.cpp b/Framework/DataHandling/src/LoadSpiceAscii.cpp index a2ddfae114427b84875c396b3a2e34552d2981eb..d95e776cdeb1d5d3f0be6b480b9ef259b9312f79 100644 --- a/Framework/DataHandling/src/LoadSpiceAscii.cpp +++ b/Framework/DataHandling/src/LoadSpiceAscii.cpp @@ -436,7 +436,7 @@ LoadSpiceAscii::createRunInfoWS(std::map<std::string, std::string> runinfodict, * @param datetimeprop */ void LoadSpiceAscii::setupRunStartTime( - API::MatrixWorkspace_sptr runinfows, + const API::MatrixWorkspace_sptr &runinfows, const std::vector<std::string> &datetimeprop) { // Check if no need to process run start time if (datetimeprop.empty()) { @@ -596,7 +596,7 @@ std::string LoadSpiceAscii::processTimeString(const std::string &rawtime, * @param pvalue */ template <typename T> -void LoadSpiceAscii::addProperty(API::MatrixWorkspace_sptr ws, +void LoadSpiceAscii::addProperty(const API::MatrixWorkspace_sptr &ws, const std::string &pname, T pvalue) { ws->mutableRun().addLogData(new PropertyWithValue<T>(pname, pvalue)); } diff --git a/Framework/DataHandling/src/LoadSpiceXML2DDet.cpp b/Framework/DataHandling/src/LoadSpiceXML2DDet.cpp index 5ccd00dee3a0f1c87021638ad836b75e7ccd2d06..d1d6d36bc5cb1a99486c6cde3a45e57180ee2a8d 100644 --- a/Framework/DataHandling/src/LoadSpiceXML2DDet.cpp +++ b/Framework/DataHandling/src/LoadSpiceXML2DDet.cpp @@ -283,7 +283,8 @@ void LoadSpiceXML2DDet::processInputs() { * @param outws :: workspace to have sample logs to set up * @return */ -bool LoadSpiceXML2DDet::setupSampleLogs(API::MatrixWorkspace_sptr outws) { +bool LoadSpiceXML2DDet::setupSampleLogs( + const API::MatrixWorkspace_sptr &outws) { // With given spice scan table, 2-theta is read from there. if (m_hasScanTable) { ITableWorkspace_sptr spicetablews = getProperty("SpiceTableWorkspace"); @@ -938,8 +939,8 @@ API::MatrixWorkspace_sptr LoadSpiceXML2DDet::xmlParseDetectorNode( * @param ptnumber */ void LoadSpiceXML2DDet::setupSampleLogFromSpiceTable( - MatrixWorkspace_sptr matrixws, ITableWorkspace_sptr spicetablews, - int ptnumber) { + const MatrixWorkspace_sptr &matrixws, + const ITableWorkspace_sptr &spicetablews, int ptnumber) { size_t numrows = spicetablews->rowCount(); std::vector<std::string> colnames = spicetablews->getColumnNames(); // FIXME - Shouldn't give a better value? @@ -978,7 +979,7 @@ void LoadSpiceXML2DDet::setupSampleLogFromSpiceTable( * @param wavelength * @return */ -bool LoadSpiceXML2DDet::getHB3AWavelength(MatrixWorkspace_sptr dataws, +bool LoadSpiceXML2DDet::getHB3AWavelength(const MatrixWorkspace_sptr &dataws, double &wavelength) { bool haswavelength(false); wavelength = -1.; @@ -1043,7 +1044,7 @@ bool LoadSpiceXML2DDet::getHB3AWavelength(MatrixWorkspace_sptr dataws, * @param dataws * @param wavelength */ -void LoadSpiceXML2DDet::setXtoLabQ(API::MatrixWorkspace_sptr dataws, +void LoadSpiceXML2DDet::setXtoLabQ(const API::MatrixWorkspace_sptr &dataws, const double &wavelength) { size_t numspec = dataws->getNumberHistograms(); @@ -1075,9 +1076,7 @@ void LoadSpiceXML2DDet::loadInstrument(API::MatrixWorkspace_sptr matrixws, loadinst->setProperty("RewriteSpectraMap", Mantid::Kernel::OptionalBool(true)); loadinst->execute(); - if (loadinst->isExecuted()) - matrixws = loadinst->getProperty("Workspace"); - else + if (!loadinst->isExecuted()) g_log.error("Unable to load instrument to output workspace"); } diff --git a/Framework/DataHandling/src/LoadTBL.cpp b/Framework/DataHandling/src/LoadTBL.cpp index 5f8d2412c644d9ca236eb308f79490eeef08c1f2..32b8778f367e9e648c7ffa43de25c71e8545daca 100644 --- a/Framework/DataHandling/src/LoadTBL.cpp +++ b/Framework/DataHandling/src/LoadTBL.cpp @@ -81,7 +81,7 @@ int LoadTBL::confidence(Kernel::FileDescriptor &descriptor) const { * @param line the line to count from * @returns a size_t of how many commas were in line */ -size_t LoadTBL::countCommas(std::string line) const { +size_t LoadTBL::countCommas(const std::string &line) const { size_t found = 0; size_t pos = line.find(',', 0); if (pos != std::string::npos) { @@ -104,7 +104,7 @@ size_t LoadTBL::countCommas(std::string line) const { * @returns a size_t of how many pairs of quotes were in line */ size_t -LoadTBL::findQuotePairs(std::string line, +LoadTBL::findQuotePairs(const std::string &line, std::vector<std::vector<size_t>> "eBounds) const { size_t quoteOne = 0; size_t quoteTwo = 0; @@ -137,7 +137,7 @@ LoadTBL::findQuotePairs(std::string line, * @throws std::length_error if anything other than 17 columns (or 16 * cell-delimiting commas) is found */ -void LoadTBL::csvParse(std::string line, std::vector<std::string> &cols, +void LoadTBL::csvParse(const std::string &line, std::vector<std::string> &cols, std::vector<std::vector<size_t>> "eBounds, size_t expectedCommas) const { size_t pairID = 0; diff --git a/Framework/DataHandling/src/LoadTOFRawNexus.cpp b/Framework/DataHandling/src/LoadTOFRawNexus.cpp index 6e4674f1c1c054da97d1a59354cd7a4b0365b6e2..70e95229d386aa2235aa911d7854350fdd623fa3 100644 --- a/Framework/DataHandling/src/LoadTOFRawNexus.cpp +++ b/Framework/DataHandling/src/LoadTOFRawNexus.cpp @@ -20,6 +20,7 @@ #include <boost/algorithm/string/detail/classification.hpp> #include <boost/algorithm/string/split.hpp> +#include <utility> namespace Mantid { namespace DataHandling { @@ -267,7 +268,7 @@ namespace { // Check the numbers supplied are not in the range and erase the ones that are struct range_check { range_check(specnum_t min, specnum_t max, detid2index_map id_to_wi) - : m_min(min), m_max(max), m_id_to_wi(id_to_wi) {} + : m_min(min), m_max(max), m_id_to_wi(std::move(id_to_wi)) {} bool operator()(specnum_t x) { auto wi = static_cast<specnum_t>((m_id_to_wi)[x]); @@ -292,7 +293,7 @@ private: void LoadTOFRawNexus::loadBank(const std::string &nexusfilename, const std::string &entry_name, const std::string &bankName, - API::MatrixWorkspace_sptr WS, + const API::MatrixWorkspace_sptr &WS, const detid2index_map &id_to_wi) { g_log.debug() << "Loading bank " << bankName << '\n'; // To avoid segfaults on RHEL5/6 and Fedora diff --git a/Framework/DataHandling/src/MaskDetectors.cpp b/Framework/DataHandling/src/MaskDetectors.cpp index 6e361b54a98b2dc6e579a0515558a69a03c4817a..1661e4a4605111cc81bbb257a0248d27493cd18a 100644 --- a/Framework/DataHandling/src/MaskDetectors.cpp +++ b/Framework/DataHandling/src/MaskDetectors.cpp @@ -244,8 +244,8 @@ void MaskDetectors::exec() { * @param rangeInfo :: information about the spectrum range to use when masking */ void MaskDetectors::handleMaskByMaskWorkspace( - const MaskWorkspace_const_sptr maskWs, - const API::MatrixWorkspace_const_sptr WS, + const MaskWorkspace_const_sptr &maskWs, + const API::MatrixWorkspace_const_sptr &WS, std::vector<detid_t> &detectorList, std::vector<size_t> &indexList, const RangeInfo &rangeInfo) { @@ -280,8 +280,8 @@ void MaskDetectors::handleMaskByMaskWorkspace( * @param rangeInfo :: information about the spectrum range to use when masking */ void MaskDetectors::handleMaskByMatrixWorkspace( - const API::MatrixWorkspace_const_sptr maskWs, - const API::MatrixWorkspace_const_sptr WS, + const API::MatrixWorkspace_const_sptr &maskWs, + const API::MatrixWorkspace_const_sptr &WS, std::vector<detid_t> &detectorList, std::vector<size_t> &indexList, const RangeInfo &rangeInfo) { @@ -395,7 +395,7 @@ void MaskDetectors::extractMaskedWSDetIDs( * Peaks exec body * @param WS :: The input peaks workspace to be masked */ -void MaskDetectors::execPeaks(PeaksWorkspace_sptr WS) { +void MaskDetectors::execPeaks(const PeaksWorkspace_sptr &WS) { std::vector<detid_t> detectorList = getProperty("DetectorList"); const MatrixWorkspace_sptr prevMasking = getProperty("MaskedWorkspace"); @@ -455,7 +455,7 @@ void MaskDetectors::execPeaks(PeaksWorkspace_sptr WS) { void MaskDetectors::fillIndexListFromSpectra( std::vector<size_t> &indexList, std::vector<Indexing::SpectrumNumber> spectraList, - const API::MatrixWorkspace_sptr WS, + const API::MatrixWorkspace_sptr &WS, const std::tuple<size_t, size_t, bool> &range_info) { std::vector<size_t> tmp_index; @@ -494,7 +494,7 @@ void MaskDetectors::fillIndexListFromSpectra( * Boolean indicating if these ranges are defined */ void MaskDetectors::appendToIndexListFromWS( - std::vector<size_t> &indexList, const MatrixWorkspace_const_sptr sourceWS, + std::vector<size_t> &indexList, const MatrixWorkspace_const_sptr &sourceWS, const std::tuple<size_t, size_t, bool> &range_info) { std::vector<size_t> tmp_index; @@ -537,8 +537,8 @@ void MaskDetectors::appendToIndexListFromWS( */ void MaskDetectors::appendToDetectorListFromWS( std::vector<detid_t> &detectorList, - const MatrixWorkspace_const_sptr inputWs, - const MatrixWorkspace_const_sptr maskWs, + const MatrixWorkspace_const_sptr &inputWs, + const MatrixWorkspace_const_sptr &maskWs, const std::tuple<size_t, size_t, bool> &range_info) { const auto startIndex = std::get<0>(range_info); const auto endIndex = std::get<1>(range_info); @@ -567,7 +567,7 @@ void MaskDetectors::appendToDetectorListFromWS( */ void MaskDetectors::appendToIndexListFromMaskWS( std::vector<size_t> &indexList, - const DataObjects::MaskWorkspace_const_sptr maskedWorkspace, + const DataObjects::MaskWorkspace_const_sptr &maskedWorkspace, const std::tuple<size_t, size_t, bool> &range_info) { std::vector<size_t> tmp_index; @@ -610,7 +610,7 @@ void MaskDetectors::appendToIndexListFromMaskWS( void MaskDetectors::appendToDetectorListFromComponentList( std::vector<detid_t> &detectorList, const std::vector<std::string> &componentList, - const API::MatrixWorkspace_const_sptr WS) { + const API::MatrixWorkspace_const_sptr &WS) { const auto instrument = WS->getInstrument(); if (!instrument) { g_log.error() diff --git a/Framework/DataHandling/src/MaskDetectorsInShape.cpp b/Framework/DataHandling/src/MaskDetectorsInShape.cpp index af163e494079726a30572e4b7b58dba6ec9eac0a..08b2a090d9deccb5f9e997d58dd43ccdadf24b86 100644 --- a/Framework/DataHandling/src/MaskDetectorsInShape.cpp +++ b/Framework/DataHandling/src/MaskDetectorsInShape.cpp @@ -53,7 +53,7 @@ void MaskDetectorsInShape::exec() { /// Run the FindDetectorsInShape Child Algorithm std::vector<int> MaskDetectorsInShape::runFindDetectorsInShape( - API::MatrixWorkspace_sptr workspace, const std::string shapeXML, + const API::MatrixWorkspace_sptr &workspace, const std::string &shapeXML, const bool includeMonitors) { IAlgorithm_sptr alg = createChildAlgorithm("FindDetectorsInShape"); alg->setPropertyValue("IncludeMonitors", includeMonitors ? "1" : "0"); @@ -76,7 +76,8 @@ std::vector<int> MaskDetectorsInShape::runFindDetectorsInShape( } void MaskDetectorsInShape::runMaskDetectors( - API::MatrixWorkspace_sptr workspace, const std::vector<int> &detectorIds) { + const API::MatrixWorkspace_sptr &workspace, + const std::vector<int> &detectorIds) { auto &detectorInfo = workspace->mutableDetectorInfo(); for (const auto &id : detectorIds) detectorInfo.setMasked(detectorInfo.indexOf(id), true); diff --git a/Framework/DataHandling/src/MeshFileIO.cpp b/Framework/DataHandling/src/MeshFileIO.cpp index 6d481549fd9aa4d9bb888cf340f5df62869b2a78..6b899115961f763a04bcdd3b85edabb69d0deb27 100644 --- a/Framework/DataHandling/src/MeshFileIO.cpp +++ b/Framework/DataHandling/src/MeshFileIO.cpp @@ -88,7 +88,7 @@ Kernel::Matrix<double> MeshFileIO::generateZRotation(double zRotation) { */ boost::shared_ptr<Geometry::MeshObject> MeshFileIO::translate(boost::shared_ptr<Geometry::MeshObject> environmentMesh, - const std::vector<double> translationVector) { + const std::vector<double> &translationVector) { std::vector<double> checkVector = std::vector<double>(3, 0.0); if (translationVector != checkVector) { if (translationVector.size() != 3) { diff --git a/Framework/DataHandling/src/PDLoadCharacterizations.cpp b/Framework/DataHandling/src/PDLoadCharacterizations.cpp index 091ccc71d933bedf091be597790642dd028ba31b..6bccfcb4b5f6224e29ae90466eeefc478b456a2c 100644 --- a/Framework/DataHandling/src/PDLoadCharacterizations.cpp +++ b/Framework/DataHandling/src/PDLoadCharacterizations.cpp @@ -298,7 +298,7 @@ std::vector<std::string> PDLoadCharacterizations::getFilenames() { * @returns line number that file was read to */ int PDLoadCharacterizations::readFocusInfo(std::ifstream &file, - const std::string filename) { + const std::string &filename) { // end early if already at the end of the file if (file.eof()) return 0; diff --git a/Framework/DataHandling/src/ProcessBankData.cpp b/Framework/DataHandling/src/ProcessBankData.cpp index 323529fe143041d93bd7fb25ace369c31185b1c3..120fcf64becde776c121ddcb8baebed4e5c9d95d 100644 --- a/Framework/DataHandling/src/ProcessBankData.cpp +++ b/Framework/DataHandling/src/ProcessBankData.cpp @@ -4,9 +4,11 @@ // NScD Oak Ridge National Laboratory, European Spallation Source, // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + -#include "MantidDataHandling/ProcessBankData.h" +#include <utility> + #include "MantidDataHandling/DefaultEventLoader.h" #include "MantidDataHandling/LoadEventNexus.h" +#include "MantidDataHandling/ProcessBankData.h" using namespace Mantid::DataObjects; @@ -21,14 +23,16 @@ ProcessBankData::ProcessBankData( boost::shared_ptr<BankPulseTimes> thisBankPulseTimes, bool have_weight, boost::shared_array<float> event_weight, detid_t min_event_id, detid_t max_event_id) - : Task(), m_loader(m_loader), entry_name(entry_name), + : Task(), m_loader(m_loader), entry_name(std::move(entry_name)), pixelID_to_wi_vector(m_loader.pixelID_to_wi_vector), pixelID_to_wi_offset(m_loader.pixelID_to_wi_offset), prog(prog), - event_id(event_id), event_time_of_flight(event_time_of_flight), - numEvents(numEvents), startAt(startAt), event_index(event_index), - thisBankPulseTimes(thisBankPulseTimes), have_weight(have_weight), - event_weight(event_weight), m_min_id(min_event_id), - m_max_id(max_event_id) { + event_id(std::move(event_id)), + event_time_of_flight(std::move(event_time_of_flight)), + numEvents(numEvents), startAt(startAt), + event_index(std::move(event_index)), + thisBankPulseTimes(std::move(thisBankPulseTimes)), + have_weight(have_weight), event_weight(std::move(event_weight)), + m_min_id(min_event_id), m_max_id(max_event_id) { // Cost is approximately proportional to the number of events to process. m_cost = static_cast<double>(numEvents); } @@ -88,7 +92,7 @@ void ProcessBankData::run() { // override { // Now we pre-allocate (reserve) the vectors of events in each pixel // counted const size_t numEventLists = outputWS.getNumberHistograms(); - for (detid_t pixID = m_min_id; pixID <= m_max_id; pixID++) { + for (detid_t pixID = m_min_id; pixID <= m_max_id; ++pixID) { if (counts[pixID - m_min_id] > 0) { size_t wi = getWorkspaceIndexFromPixelID(pixID); // Find the the workspace index corresponding to that pixel ID @@ -220,7 +224,7 @@ void ProcessBankData::run() { // override { //------------ Compress Events (or set sort order) ------------------ // Do it on all the detector IDs we touched if (compress) { - for (detid_t pixID = m_min_id; pixID <= m_max_id; pixID++) { + for (detid_t pixID = m_min_id; pixID <= m_max_id; ++pixID) { if (usedDetIds[pixID - m_min_id]) { // Find the the workspace index corresponding to that pixel ID size_t wi = getWorkspaceIndexFromPixelID(pixID); diff --git a/Framework/DataHandling/src/ReadMaterial.cpp b/Framework/DataHandling/src/ReadMaterial.cpp index cf3da641202e9ec18896f7f1f64401b1431df264..b65fb49728f9292cc93344f159c4c3ed27d813af 100644 --- a/Framework/DataHandling/src/ReadMaterial.cpp +++ b/Framework/DataHandling/src/ReadMaterial.cpp @@ -79,8 +79,6 @@ ReadMaterial::validateInputs(const MaterialParameters ¶ms) { if (canCalculateMassDensity) { result["SampleMassDensity"] = "Cannot give SampleMassDensity with SampleNumberDensity set"; - result["SampleMassDensity"] = - "Cannot give SampleMassDensity with SampleNumberDensity set"; } } return result; @@ -118,7 +116,7 @@ std::unique_ptr<Kernel::Material> ReadMaterial::buildMaterial() { return std::make_unique<Kernel::Material>(builder.build()); } -void ReadMaterial::setMaterial(const std::string chemicalSymbol, +void ReadMaterial::setMaterial(const std::string &chemicalSymbol, const int atomicNumber, const int massNumber) { if (!chemicalSymbol.empty()) { builder.setFormula(chemicalSymbol); diff --git a/Framework/DataHandling/src/SampleEnvironmentSpecParser.cpp b/Framework/DataHandling/src/SampleEnvironmentSpecParser.cpp index 332c391333ceeb9aac25765abf6cb248306260ee..b3a10b949a19ce026b54559d8941e4f869a8c1d3 100644 --- a/Framework/DataHandling/src/SampleEnvironmentSpecParser.cpp +++ b/Framework/DataHandling/src/SampleEnvironmentSpecParser.cpp @@ -258,7 +258,7 @@ SampleEnvironmentSpecParser::parseContainer(Element *element) const { * @param targetVariable Value read from element attribute */ void SampleEnvironmentSpecParser::LoadOptionalDoubleFromXML( - Poco::XML::Element *componentElement, std::string attributeName, + Poco::XML::Element *componentElement, const std::string &attributeName, double &targetVariable) const { auto attributeText = componentElement->getAttribute(attributeName); @@ -279,7 +279,7 @@ void SampleEnvironmentSpecParser::LoadOptionalDoubleFromXML( * @return vector containing translations */ std::vector<double> SampleEnvironmentSpecParser::parseTranslationVector( - std::string translationVectorStr) const { + const std::string &translationVectorStr) const { std::vector<double> translationVector; diff --git a/Framework/DataHandling/src/SaveAscii2.cpp b/Framework/DataHandling/src/SaveAscii2.cpp index 3462bc44c134633c2b6017fe12f3463fba8c5b79..b4b20cc7d6e9a4f138f9ff3b48bec7da738f17b9 100644 --- a/Framework/DataHandling/src/SaveAscii2.cpp +++ b/Framework/DataHandling/src/SaveAscii2.cpp @@ -473,7 +473,7 @@ bool SaveAscii2::findElementInUnorderedStringVector( return std::find(vector.cbegin(), vector.cend(), toFind) != vector.cend(); } -void SaveAscii2::writeTableWorkspace(ITableWorkspace_const_sptr tws, +void SaveAscii2::writeTableWorkspace(const ITableWorkspace_const_sptr &tws, const std::string &filename, bool appendToFile, bool writeHeader, int prec, bool scientific, diff --git a/Framework/DataHandling/src/SaveCSV.cpp b/Framework/DataHandling/src/SaveCSV.cpp index f96198738c78e38b4b8d7c36d4ccbc27ebdc1b2b..ffe7c857944f8f5a1ac4003333d01c9ca6bd691c 100644 --- a/Framework/DataHandling/src/SaveCSV.cpp +++ b/Framework/DataHandling/src/SaveCSV.cpp @@ -184,9 +184,10 @@ void SaveCSV::exec() { outCSV_File.close(); } -void SaveCSV::saveXerrors(std::ofstream &stream, - const Mantid::DataObjects::Workspace2D_sptr workspace, - const size_t numberOfHist) { +void SaveCSV::saveXerrors( + std::ofstream &stream, + const Mantid::DataObjects::Workspace2D_sptr &workspace, + const size_t numberOfHist) { // If there isn't a dx values present in the first entry then return if (!workspace->hasDx(0)) { return; diff --git a/Framework/DataHandling/src/SaveCalFile.cpp b/Framework/DataHandling/src/SaveCalFile.cpp index 4efc4101662b6b2b89bb1946804c3422dd63b19d..ddf6721fe4b616a169974c9d214f3bf81d2499c6 100644 --- a/Framework/DataHandling/src/SaveCalFile.cpp +++ b/Framework/DataHandling/src/SaveCalFile.cpp @@ -80,9 +80,9 @@ void SaveCalFile::exec() { *(selected) if not specified. */ void SaveCalFile::saveCalFile(const std::string &calFileName, - GroupingWorkspace_sptr groupWS, - OffsetsWorkspace_sptr offsetsWS, - MaskWorkspace_sptr maskWS) { + const GroupingWorkspace_sptr &groupWS, + const OffsetsWorkspace_sptr &offsetsWS, + const MaskWorkspace_sptr &maskWS) { Instrument_const_sptr inst; bool doGroup = false; diff --git a/Framework/DataHandling/src/SaveDetectorsGrouping.cpp b/Framework/DataHandling/src/SaveDetectorsGrouping.cpp index 17feffa71b4924f55b4de1248175569752ce39a2..33f3f59cda0925b4cec88dc58809f9fcdeb1d8ab 100644 --- a/Framework/DataHandling/src/SaveDetectorsGrouping.cpp +++ b/Framework/DataHandling/src/SaveDetectorsGrouping.cpp @@ -143,8 +143,8 @@ void SaveDetectorsGrouping::convertToDetectorsRanges( } void SaveDetectorsGrouping::printToXML( - std::map<int, std::vector<detid_t>> groupdetidrangemap, - std::string xmlfilename) { + const std::map<int, std::vector<detid_t>> &groupdetidrangemap, + const std::string &xmlfilename) { // 1. Get Instrument information const auto &instrument = mGroupWS->getInstrument(); diff --git a/Framework/DataHandling/src/SaveDiffCal.cpp b/Framework/DataHandling/src/SaveDiffCal.cpp index 3e3a42fce5dfc526999ab2c2d81b13f22c9a1b2a..1911d8a18894b7cd8dbb9279dc9f9617ca1ea520 100644 --- a/Framework/DataHandling/src/SaveDiffCal.cpp +++ b/Framework/DataHandling/src/SaveDiffCal.cpp @@ -107,6 +107,7 @@ std::map<std::string, std::string> SaveDiffCal::validateInputs() { void SaveDiffCal::writeDoubleFieldFromTable(H5::Group &group, const std::string &name) { auto column = m_calibrationWS->getColumn(name); + // cppcheck-suppress compareBoolExpressionWithInt auto data = column->numeric_fill<>(m_numValues); H5Util::writeArray1D(group, name, data); } @@ -121,7 +122,7 @@ void SaveDiffCal::writeIntFieldFromTable(H5::Group &group, // TODO should flip for mask void SaveDiffCal::writeIntFieldFromSVWS( H5::Group &group, const std::string &name, - DataObjects::SpecialWorkspace2D_const_sptr ws) { + const DataObjects::SpecialWorkspace2D_const_sptr &ws) { const bool isMask = (name == "use"); // output array defaults to all one (one group, use the pixel) diff --git a/Framework/DataHandling/src/SaveDiffFittingAscii.cpp b/Framework/DataHandling/src/SaveDiffFittingAscii.cpp index cbc35b9c2138863319729b9b7b6dbc3f2f8a43bc..855f18b005d43ab8dc3b8bc6820ce4e8b37cb540 100644 --- a/Framework/DataHandling/src/SaveDiffFittingAscii.cpp +++ b/Framework/DataHandling/src/SaveDiffFittingAscii.cpp @@ -111,7 +111,7 @@ bool SaveDiffFittingAscii::processGroups() { } void SaveDiffFittingAscii::processAll( - const std::vector<API::ITableWorkspace_sptr> input_ws) { + const std::vector<API::ITableWorkspace_sptr> &input_ws) { const std::string filename = getProperty("Filename"); const std::string outMode = getProperty("OutMode"); @@ -208,7 +208,7 @@ void SaveDiffFittingAscii::writeHeader( } } -void SaveDiffFittingAscii::writeData(const API::ITableWorkspace_sptr workspace, +void SaveDiffFittingAscii::writeData(const API::ITableWorkspace_sptr &workspace, std::ofstream &file, const size_t columnSize) { diff --git a/Framework/DataHandling/src/SaveDspacemap.cpp b/Framework/DataHandling/src/SaveDspacemap.cpp index fd45f8af640a6daf74030c95012caa7ab31a0031..aec81df61090cf12ca9c730e716a1da2bb74b9dd 100644 --- a/Framework/DataHandling/src/SaveDspacemap.cpp +++ b/Framework/DataHandling/src/SaveDspacemap.cpp @@ -56,8 +56,8 @@ void SaveDspacemap::exec() { * @param offsetsWS :: OffsetsWorkspace with instrument and offsets */ void SaveDspacemap::CalculateDspaceFromCal( - Mantid::DataObjects::OffsetsWorkspace_sptr offsetsWS, - std::string DFileName) { + const Mantid::DataObjects::OffsetsWorkspace_sptr &offsetsWS, + const std::string &DFileName) { const char *filename = DFileName.c_str(); // Get a pointer to the instrument contained in the workspace Instrument_const_sptr instrument = offsetsWS->getInstrument(); @@ -87,7 +87,7 @@ void SaveDspacemap::CalculateDspaceFromCal( std::ofstream fout(filename, std::ios_base::out | std::ios_base::binary); Progress prog(this, 0.0, 1.0, maxdetID); - for (detid_t i = 0; i != maxdetID; i++) { + for (detid_t i = 0; i != maxdetID; ++i) { // Compute the factor double factor; Geometry::IDetector_const_sptr det; diff --git a/Framework/DataHandling/src/SaveFITS.cpp b/Framework/DataHandling/src/SaveFITS.cpp index df21ad55193701ee80a450466eb6a46afa9e0537..a1ed7eb99a111a11ae7f74d9ab9d25f48077de78 100644 --- a/Framework/DataHandling/src/SaveFITS.cpp +++ b/Framework/DataHandling/src/SaveFITS.cpp @@ -143,7 +143,7 @@ void SaveFITS::exec() { * @param img matrix workspace (one spectrum per row) * @param filename relative or full path, should be already checked */ -void SaveFITS::saveFITSImage(const API::MatrixWorkspace_sptr img, +void SaveFITS::saveFITSImage(const API::MatrixWorkspace_sptr &img, const std::string &filename) { std::ofstream outfile(filename, std::ofstream::binary); @@ -151,7 +151,7 @@ void SaveFITS::saveFITSImage(const API::MatrixWorkspace_sptr img, writeFITSImageMatrix(img, outfile); } -void SaveFITS::writeFITSHeaderBlock(const API::MatrixWorkspace_sptr img, +void SaveFITS::writeFITSHeaderBlock(const API::MatrixWorkspace_sptr &img, std::ofstream &file) { // minimal sequence of standard headers writeFITSHeaderEntry(g_FITSHdrFirst, file); @@ -169,7 +169,7 @@ void SaveFITS::writeFITSHeaderBlock(const API::MatrixWorkspace_sptr img, writePaddingFITSHeaders(entriesPerHDU - 9, file); } -void SaveFITS::writeFITSImageMatrix(const API::MatrixWorkspace_sptr img, +void SaveFITS::writeFITSImageMatrix(const API::MatrixWorkspace_sptr &img, std::ofstream &file) { const size_t sizeX = img->blocksize(); const size_t sizeY = img->getNumberHistograms(); @@ -213,7 +213,7 @@ void SaveFITS::writeFITSHeaderEntry(const std::string &hdr, file.write(blanks.data(), g_maxLenHdr - count); } -void SaveFITS::writeFITSHeaderAxesSizes(const API::MatrixWorkspace_sptr img, +void SaveFITS::writeFITSHeaderAxesSizes(const API::MatrixWorkspace_sptr &img, std::ofstream &file) { const std::string sizeX = std::to_string(img->blocksize()); const std::string sizeY = std::to_string(img->getNumberHistograms()); diff --git a/Framework/DataHandling/src/SaveFullprofResolution.cpp b/Framework/DataHandling/src/SaveFullprofResolution.cpp index 0b71d7030b7b0d7a445e7f3ed19a6ac8be7a9380..b0fe14c72c8aa6f8be85871ef322d92fc22b42bd 100644 --- a/Framework/DataHandling/src/SaveFullprofResolution.cpp +++ b/Framework/DataHandling/src/SaveFullprofResolution.cpp @@ -480,7 +480,7 @@ std::string SaveFullprofResolution::toProf9IrfString() { /** Check wether a profile parameter map has the parameter */ bool SaveFullprofResolution::has_key(std::map<std::string, double> profmap, - std::string key) { + const std::string &key) { map<string, double>::iterator fiter; fiter = profmap.find(key); bool exist = true; diff --git a/Framework/DataHandling/src/SaveGSASInstrumentFile.cpp b/Framework/DataHandling/src/SaveGSASInstrumentFile.cpp index 9167a981b42ca9085d05294a345ecf141ceda360..940ca4ab246527012b02f557c0ea07d04a08040e 100644 --- a/Framework/DataHandling/src/SaveGSASInstrumentFile.cpp +++ b/Framework/DataHandling/src/SaveGSASInstrumentFile.cpp @@ -505,7 +505,7 @@ void SaveGSASInstrumentFile::initConstants( /** Parse profile table workspace to a map (the new ... */ void SaveGSASInstrumentFile::parseProfileTableWorkspace( - ITableWorkspace_sptr ws, + const ITableWorkspace_sptr &ws, map<unsigned int, map<string, double>> &profilemap) { size_t numbanks = ws->columnCount() - 1; size_t numparams = ws->rowCount(); @@ -896,74 +896,74 @@ void SaveGSASInstrumentFile::writePRMSingleBank( throw runtime_error(errss.str()); } - fprintf(pFile, "INS %2d ICONS%10.3f%10.3f%10.3f %10.3f%5d%10.3f\n", + fprintf(pFile, "INS %2u ICONS%10.3f%10.3f%10.3f %10.3f%5d%10.3f\n", bankid, instC * 1.00009, 0.0, zero, 0.0, 0, 0.0); - fprintf(pFile, "INS %2dBNKPAR%10.3f%10.3f%10.3f%10.3f%10.3f%5d%5d\n", bankid, + fprintf(pFile, "INS %2uBNKPAR%10.3f%10.3f%10.3f%10.3f%10.3f%5d%5d\n", bankid, m_L2, twotheta, 0., 0., 0.2, 1, 1); - fprintf(pFile, "INS %2dBAKGD 1 4 Y 0 Y\n", bankid); - fprintf(pFile, "INS %2dI HEAD %s\n", bankid, titleline.c_str()); - fprintf(pFile, "INS %2dI ITYP%5d%10.4f%10.4f%10i\n", bankid, 0, + fprintf(pFile, "INS %2uBAKGD 1 4 Y 0 Y\n", bankid); + fprintf(pFile, "INS %2uI HEAD %s\n", bankid, titleline.c_str()); + fprintf(pFile, "INS %2uI ITYP%5d%10.4f%10.4f%10i\n", bankid, 0, mindsp * 0.001 * instC, maxtof, randint); - fprintf(pFile, "INS %2dINAME %s \n", bankid, m_instrument.c_str()); - fprintf(pFile, "INS %2dPRCF1 %5d%5d%10.5f\n", bankid, -3, 21, 0.002); - fprintf(pFile, "INS %2dPRCF11%15.6f%15.6f%15.6f%15.6f\n", bankid, 0.0, 0.0, + fprintf(pFile, "INS %2uINAME %s \n", bankid, m_instrument.c_str()); + fprintf(pFile, "INS %2uPRCF1 %5d%5d%10.5f\n", bankid, -3, 21, 0.002); + fprintf(pFile, "INS %2uPRCF11%15.6f%15.6f%15.6f%15.6f\n", bankid, 0.0, 0.0, 0.0, sig0); - fprintf(pFile, "INS %2dPRCF12%15.6f%15.6f%15.6f%15.6f\n", bankid, sig1, sig2, + fprintf(pFile, "INS %2uPRCF12%15.6f%15.6f%15.6f%15.6f\n", bankid, sig1, sig2, gam0, gam1); - fprintf(pFile, "INS %2dPRCF13%15.6f%15.6f%15.6f%15.6f\n", bankid, gam2, 0.0, + fprintf(pFile, "INS %2uPRCF13%15.6f%15.6f%15.6f%15.6f\n", bankid, gam2, 0.0, 0.0, 0.0); - fprintf(pFile, "INS %2dPRCF14%15.6f%15.6f%15.6f%15.6f\n", bankid, 0.0, 0.0, + fprintf(pFile, "INS %2uPRCF14%15.6f%15.6f%15.6f%15.6f\n", bankid, 0.0, 0.0, 0.0, 0.0); - fprintf(pFile, "INS %2dPRCF15%15.6f%15.6f%15.6f%15.6f\n", bankid, 0.0, 0.0, + fprintf(pFile, "INS %2uPRCF15%15.6f%15.6f%15.6f%15.6f\n", bankid, 0.0, 0.0, 0.0, 0.0); - fprintf(pFile, "INS %2dPRCF16%15.6f\n", bankid, 0.0); - fprintf(pFile, "INS %2dPAB3 %3d\n", bankid, 90); + fprintf(pFile, "INS %2uPRCF16%15.6f\n", bankid, 0.0); + fprintf(pFile, "INS %2uPAB3 %3d\n", bankid, 90); for (size_t k = 0; k < 90; ++k) { - fprintf(pFile, "INS %2dPAB3%2d%10.5f%10.5f%10.5f%10.5f\n", bankid, + fprintf(pFile, "INS %2uPAB3%2d%10.5f%10.5f%10.5f%10.5f\n", bankid, static_cast<int>(k) + 1, m_gdsp[k], m_gdt[k], m_galpha[k], m_gbeta[k]); } - fprintf(pFile, "INS %2dPRCF2 %5i%5i%10.5f\n", bankid, -4, 27, 0.002); - fprintf(pFile, "INS %2dPRCF21%15.6f%15.6f%15.6f%15.6f\n", bankid, 0.0, 0.0, + fprintf(pFile, "INS %2uPRCF2 %5i%5i%10.5f\n", bankid, -4, 27, 0.002); + fprintf(pFile, "INS %2uPRCF21%15.6f%15.6f%15.6f%15.6f\n", bankid, 0.0, 0.0, 0.0, sig1); - fprintf(pFile, "INS %2dPRCF22%15.6f%15.6f%15.6f%15.6f\n", bankid, sig2, gam2, + fprintf(pFile, "INS %2uPRCF22%15.6f%15.6f%15.6f%15.6f\n", bankid, sig2, gam2, 0.0, 0.0); - fprintf(pFile, "INS %2dPRCF23%15.6f%15.6f%15.6f%15.6f\n", bankid, 0.0, 0.0, + fprintf(pFile, "INS %2uPRCF23%15.6f%15.6f%15.6f%15.6f\n", bankid, 0.0, 0.0, 0.0, 0.0); - fprintf(pFile, "INS %2dPRCF24%15.6f%15.6f%15.6f%15.6f\n", bankid, 0.0, 0.0, + fprintf(pFile, "INS %2uPRCF24%15.6f%15.6f%15.6f%15.6f\n", bankid, 0.0, 0.0, 0.0, 0.0); - fprintf(pFile, "INS %2dPRCF25%15.6f%15.6f%15.6f%15.6f\n", bankid, 0.0, 0.0, + fprintf(pFile, "INS %2uPRCF25%15.6f%15.6f%15.6f%15.6f\n", bankid, 0.0, 0.0, 0.0, 0.0); - fprintf(pFile, "INS %2dPRCF26%15.6f%15.6f%15.6f%15.6f\n", bankid, 0.0, 0.0, + fprintf(pFile, "INS %2uPRCF26%15.6f%15.6f%15.6f%15.6f\n", bankid, 0.0, 0.0, 0.0, 0.0); - fprintf(pFile, "INS %2dPRCF27%15.6f%15.6f%15.6f \n", bankid, 0.0, 0.0, 0.0); + fprintf(pFile, "INS %2uPRCF27%15.6f%15.6f%15.6f \n", bankid, 0.0, 0.0, 0.0); - fprintf(pFile, "INS %2dPAB4 %3i\n", bankid, 90); + fprintf(pFile, "INS %2uPAB4 %3i\n", bankid, 90); for (size_t k = 0; k < 90; ++k) { - fprintf(pFile, "INS %2dPAB4%2d%10.5f%10.5f%10.5f%10.5f\n", bankid, + fprintf(pFile, "INS %2uPAB4%2d%10.5f%10.5f%10.5f%10.5f\n", bankid, static_cast<int>(k) + 1, m_gdsp[k], m_gdt[k], m_galpha[k], m_gbeta[k]); } - fprintf(pFile, "INS %2dPRCF3 %5i%5i%10.5f\n", bankid, -5, 21, 0.002); - fprintf(pFile, "INS %2dPRCF31%15.6f%15.6f%15.6f%15.6f\n", bankid, 0.0, 0.0, + fprintf(pFile, "INS %2uPRCF3 %5i%5i%10.5f\n", bankid, -5, 21, 0.002); + fprintf(pFile, "INS %2uPRCF31%15.6f%15.6f%15.6f%15.6f\n", bankid, 0.0, 0.0, 0.0, sig0); - fprintf(pFile, "INS %2dPRCF32%15.6f%15.6f%15.6f%15.6f\n", bankid, sig1, sig2, + fprintf(pFile, "INS %2uPRCF32%15.6f%15.6f%15.6f%15.6f\n", bankid, sig1, sig2, gam0, gam1); - fprintf(pFile, "INS %2dPRCF33%15.6f%15.6f%15.6f%15.6f\n", bankid, gam2, 0.0, + fprintf(pFile, "INS %2uPRCF33%15.6f%15.6f%15.6f%15.6f\n", bankid, gam2, 0.0, 0.0, 0.0); - fprintf(pFile, "INS %2dPRCF34%15.6f%15.6f%15.6f%15.6f\n", bankid, 0.0, 0.0, + fprintf(pFile, "INS %2uPRCF34%15.6f%15.6f%15.6f%15.6f\n", bankid, 0.0, 0.0, 0.0, 0.0); - fprintf(pFile, "INS %2dPRCF35%15.6f%15.6f%15.6f%15.6f\n", bankid, 0.0, 0.0, + fprintf(pFile, "INS %2uPRCF35%15.6f%15.6f%15.6f%15.6f\n", bankid, 0.0, 0.0, 0.0, 0.0); - fprintf(pFile, "INS %2dPRCF36%15.6f\n", bankid, 0.0); + fprintf(pFile, "INS %2uPRCF36%15.6f\n", bankid, 0.0); - fprintf(pFile, "INS %2dPAB5 %3i\n", bankid, + fprintf(pFile, "INS %2uPAB5 %3i\n", bankid, 90); // 90 means there will be 90 lines of table for (size_t k = 0; k < 90; k++) { - fprintf(pFile, "INS %2dPAB5%2d%10.5f%10.5f%10.5f%10.5f\n", bankid, + fprintf(pFile, "INS %2uPAB5%2d%10.5f%10.5f%10.5f%10.5f\n", bankid, static_cast<int>(k) + 1, m_gdsp[k], m_gdt[k], m_galpha[k], m_gbeta[k]); } @@ -1086,7 +1086,7 @@ double SaveGSASInstrumentFile::calDspRange(double dtt1, double zero, * @param irffilename */ void SaveGSASInstrumentFile::loadFullprofResolutionFile( - std::string irffilename) { + const std::string &irffilename) { IAlgorithm_sptr loadfpirf; try { loadfpirf = createChildAlgorithm("LoadFullprofResolution"); diff --git a/Framework/DataHandling/src/SaveIsawDetCal.cpp b/Framework/DataHandling/src/SaveIsawDetCal.cpp index f2bfbc93b7a90beb612656a923034381b9e86e91..87374bdf19a85da55beb4cc4ad530f38b1e1135c 100644 --- a/Framework/DataHandling/src/SaveIsawDetCal.cpp +++ b/Framework/DataHandling/src/SaveIsawDetCal.cpp @@ -227,7 +227,8 @@ void SaveIsawDetCal::exec() { out.close(); } -V3D SaveIsawDetCal::findPixelPos(std::string bankName, int col, int row) { +V3D SaveIsawDetCal::findPixelPos(const std::string &bankName, int col, + int row) { boost::shared_ptr<const IComponent> parent = inst->getComponentByName(bankName); if (parent->type() == "RectangularDetector") { @@ -261,8 +262,8 @@ V3D SaveIsawDetCal::findPixelPos(std::string bankName, int col, int row) { } } -void SaveIsawDetCal::sizeBanks(std::string bankName, int &NCOLS, int &NROWS, - double &xsize, double &ysize) { +void SaveIsawDetCal::sizeBanks(const std::string &bankName, int &NCOLS, + int &NROWS, double &xsize, double &ysize) { if (bankName == "None") return; boost::shared_ptr<const IComponent> parent = diff --git a/Framework/DataHandling/src/SaveNXTomo.cpp b/Framework/DataHandling/src/SaveNXTomo.cpp index 0a5d24977c62272815f7b054fbec240c585c5e02..435d1e504a3fea4f863fe3bbfcbb3fb68b676bd8 100644 --- a/Framework/DataHandling/src/SaveNXTomo.cpp +++ b/Framework/DataHandling/src/SaveNXTomo.cpp @@ -304,7 +304,7 @@ void SaveNXTomo::processAll() { * @param workspace the workspace to get data from * @param nxFile the nexus file to save data into */ -void SaveNXTomo::writeSingleWorkspace(const Workspace2D_sptr workspace, +void SaveNXTomo::writeSingleWorkspace(const Workspace2D_sptr &workspace, ::NeXus::File &nxFile) { try { nxFile.openPath("/entry1/tomo_entry/data"); @@ -372,7 +372,7 @@ void SaveNXTomo::writeSingleWorkspace(const Workspace2D_sptr workspace, } void SaveNXTomo::writeImageKeyValue( - const DataObjects::Workspace2D_sptr workspace, ::NeXus::File &nxFile, + const DataObjects::Workspace2D_sptr &workspace, ::NeXus::File &nxFile, int thisFileInd) { // Add ImageKey to instrument/image_key if present, use 0 if not try { @@ -401,7 +401,7 @@ void SaveNXTomo::writeImageKeyValue( nxFile.closeGroup(); } -void SaveNXTomo::writeLogValues(const DataObjects::Workspace2D_sptr workspace, +void SaveNXTomo::writeLogValues(const DataObjects::Workspace2D_sptr &workspace, ::NeXus::File &nxFile, int thisFileInd) { // Add Log information (minus special values - Rotation, ImageKey, Intensity) // Unable to add multidimensional string data, storing strings as @@ -446,7 +446,7 @@ void SaveNXTomo::writeLogValues(const DataObjects::Workspace2D_sptr workspace, } void SaveNXTomo::writeIntensityValue( - const DataObjects::Workspace2D_sptr workspace, ::NeXus::File &nxFile, + const DataObjects::Workspace2D_sptr &workspace, ::NeXus::File &nxFile, int thisFileInd) { // Add Intensity to control if present, use 1 if not try { diff --git a/Framework/DataHandling/src/SaveNXcanSAS.cpp b/Framework/DataHandling/src/SaveNXcanSAS.cpp index 094314b590c104b57f2199f5f0189fded5b4dcdf..1fdff8ad829b488b8f9b816b6e56393c937d0b29 100644 --- a/Framework/DataHandling/src/SaveNXcanSAS.cpp +++ b/Framework/DataHandling/src/SaveNXcanSAS.cpp @@ -34,6 +34,7 @@ #include <cctype> #include <functional> #include <iterator> +#include <utility> using namespace Mantid::Kernel; using namespace Mantid::Geometry; @@ -56,9 +57,9 @@ void removeSpecialCharacters(std::string &input) { input = boost::regex_replace(input, toReplace, replaceWith); } -std::string -makeCompliantName(const std::string &input, bool isStrict, - std::function<void(std::string &)> captializeStrategy) { +std::string makeCompliantName( + const std::string &input, bool isStrict, + const std::function<void(std::string &)> &captializeStrategy) { auto output = input; // Check if input is compliant if (!isCanSASCompliant(isStrict, output)) { @@ -173,7 +174,7 @@ std::vector<std::string> splitDetectorNames(std::string detectorNames) { * @return the sasEntry */ H5::Group addSasEntry(H5::H5File &file, - Mantid::API::MatrixWorkspace_sptr workspace, + const Mantid::API::MatrixWorkspace_sptr &workspace, const std::string &suffix) { using namespace Mantid::DataHandling::NXcanSAS; const std::string sasEntryName = sasEntryGroupName + suffix; @@ -201,18 +202,20 @@ H5::Group addSasEntry(H5::H5File &file, } //------- SASinstrument -std::string getInstrumentName(Mantid::API::MatrixWorkspace_sptr workspace) { +std::string +getInstrumentName(const Mantid::API::MatrixWorkspace_sptr &workspace) { auto instrument = workspace->getInstrument(); return instrument->getFullName(); } -std::string getIDF(Mantid::API::MatrixWorkspace_sptr workspace) { +std::string getIDF(const Mantid::API::MatrixWorkspace_sptr &workspace) { auto date = workspace->getWorkspaceStartDate(); auto instrumentName = getInstrumentName(workspace); return workspace->getInstrumentFilename(instrumentName, date); } -void addDetectors(H5::Group &group, Mantid::API::MatrixWorkspace_sptr workspace, +void addDetectors(H5::Group &group, + const Mantid::API::MatrixWorkspace_sptr &workspace, const std::vector<std::string> &detectorNames) { // If the group is empty then don't add anything if (!detectorNames.empty()) { @@ -256,7 +259,7 @@ void addDetectors(H5::Group &group, Mantid::API::MatrixWorkspace_sptr workspace, * @param detectorNames: the names of the detectors to store */ void addInstrument(H5::Group &group, - Mantid::API::MatrixWorkspace_sptr workspace, + const Mantid::API::MatrixWorkspace_sptr &workspace, const std::string &radiationSource, const std::vector<std::string> &detectorNames) { // Setup instrument @@ -301,7 +304,8 @@ std::string getDate() { * @param group: the sasEntry * @param workspace: the workspace which is being stored */ -void addProcess(H5::Group &group, Mantid::API::MatrixWorkspace_sptr workspace) { +void addProcess(H5::Group &group, + const Mantid::API::MatrixWorkspace_sptr &workspace) { // Setup process const std::string sasProcessNameForGroup = sasProcessGroupName; auto process = Mantid::DataHandling::H5Util::createGroupCanSAS( @@ -334,8 +338,9 @@ void addProcess(H5::Group &group, Mantid::API::MatrixWorkspace_sptr workspace) { * @param group: the sasEntry * @param workspace: the workspace which is being stored */ -void addProcess(H5::Group &group, Mantid::API::MatrixWorkspace_sptr workspace, - Mantid::API::MatrixWorkspace_sptr canWorkspace) { +void addProcess(H5::Group &group, + const Mantid::API::MatrixWorkspace_sptr &workspace, + const Mantid::API::MatrixWorkspace_sptr &canWorkspace) { // Setup process const std::string sasProcessNameForGroup = sasProcessGroupName; auto process = Mantid::DataHandling::H5Util::createGroupCanSAS( @@ -401,7 +406,7 @@ void addNoteToProcess(H5::Group &group, const std::string &firstEntryName, } WorkspaceDimensionality -getWorkspaceDimensionality(Mantid::API::MatrixWorkspace_sptr workspace) { +getWorkspaceDimensionality(const Mantid::API::MatrixWorkspace_sptr &workspace) { auto numberOfHistograms = workspace->getNumberHistograms(); WorkspaceDimensionality dimensionality(WorkspaceDimensionality::other); if (numberOfHistograms == 1) { @@ -422,7 +427,8 @@ std::string getIntensityUnitLabel(std::string intensityUnitLabel) { } } -std::string getIntensityUnit(Mantid::API::MatrixWorkspace_sptr workspace) { +std::string +getIntensityUnit(const Mantid::API::MatrixWorkspace_sptr &workspace) { auto iUnit = workspace->YUnit(); if (iUnit.empty()) { iUnit = workspace->YUnitLabel(); @@ -438,13 +444,14 @@ std::string getMomentumTransferLabel(std::string momentumTransferLabel) { } } -std::string -getUnitFromMDDimension(Mantid::Geometry::IMDDimension_const_sptr dimension) { +std::string getUnitFromMDDimension( + const Mantid::Geometry::IMDDimension_const_sptr &dimension) { const auto unitLabel = dimension->getMDUnits().getUnitLabel(); return unitLabel.ascii(); } -void addData1D(H5::Group &data, Mantid::API::MatrixWorkspace_sptr workspace) { +void addData1D(H5::Group &data, + const Mantid::API::MatrixWorkspace_sptr &workspace) { // Add attributes for @signal, @I_axes, @Q_indices, Mantid::DataHandling::H5Util::writeStrAttribute(data, sasSignal, sasDataI); Mantid::DataHandling::H5Util::writeStrAttribute(data, sasDataIAxesAttr, @@ -512,7 +519,7 @@ void addData1D(H5::Group &data, Mantid::API::MatrixWorkspace_sptr workspace) { } } -bool areAxesNumeric(Mantid::API::MatrixWorkspace_sptr workspace) { +bool areAxesNumeric(const Mantid::API::MatrixWorkspace_sptr &workspace) { const unsigned indices[] = {0, 1}; for (const auto index : indices) { auto axis = workspace->getAxis(index); @@ -527,12 +534,12 @@ class SpectrumAxisValueProvider { public: explicit SpectrumAxisValueProvider( Mantid::API::MatrixWorkspace_sptr workspace) - : m_workspace(workspace) { + : m_workspace(std::move(workspace)) { setSpectrumAxisValues(); } Mantid::MantidVec::value_type * - operator()(Mantid::API::MatrixWorkspace_sptr /*unused*/, int index) { + operator()(const Mantid::API::MatrixWorkspace_sptr & /*unused*/, int index) { auto isPointData = m_workspace->getNumberHistograms() == m_spectrumAxisValues.size(); double value = 0; @@ -566,7 +573,7 @@ private: */ template <typename T> class QxExtractor { public: - T *operator()(Mantid::API::MatrixWorkspace_sptr ws, int index) { + T *operator()(const Mantid::API::MatrixWorkspace_sptr &ws, int index) { if (ws->isHistogramData()) { qxPointData.clear(); Mantid::Kernel::VectorHelper::convertToBinCentre(ws->dataX(index), @@ -620,7 +627,8 @@ public: * . * QxN QxN ... QxN */ -void addData2D(H5::Group &data, Mantid::API::MatrixWorkspace_sptr workspace) { +void addData2D(H5::Group &data, + const Mantid::API::MatrixWorkspace_sptr &workspace) { if (!areAxesNumeric(workspace)) { std::invalid_argument("SaveNXcanSAS: The provided 2D workspace needs " "to have 2 numeric axes."); @@ -664,7 +672,7 @@ void addData2D(H5::Group &data, Mantid::API::MatrixWorkspace_sptr workspace) { iAttributes.emplace(sasUncertaintyAttr, sasDataIdev); iAttributes.emplace(sasUncertaintiesAttr, sasDataIdev); - auto iExtractor = [](Mantid::API::MatrixWorkspace_sptr ws, int index) { + auto iExtractor = [](const Mantid::API::MatrixWorkspace_sptr &ws, int index) { return ws->dataY(index).data(); }; write2DWorkspace(data, workspace, sasDataI, iExtractor, iAttributes); @@ -674,13 +682,13 @@ void addData2D(H5::Group &data, Mantid::API::MatrixWorkspace_sptr workspace) { eAttributes.insert( std::make_pair(sasUnitAttr, iUnit)); // same units as intensity - auto iDevExtractor = [](Mantid::API::MatrixWorkspace_sptr ws, int index) { - return ws->dataE(index).data(); - }; + auto iDevExtractor = [](const Mantid::API::MatrixWorkspace_sptr &ws, + int index) { return ws->dataE(index).data(); }; write2DWorkspace(data, workspace, sasDataIdev, iDevExtractor, eAttributes); } -void addData(H5::Group &group, Mantid::API::MatrixWorkspace_sptr workspace) { +void addData(H5::Group &group, + const Mantid::API::MatrixWorkspace_sptr &workspace) { const std::string sasDataName = sasDataGroupName; auto data = Mantid::DataHandling::H5Util::createGroupCanSAS( group, sasDataName, nxDataClassAttr, sasDataClassAttr); @@ -701,8 +709,8 @@ void addData(H5::Group &group, Mantid::API::MatrixWorkspace_sptr workspace) { //------- SAStransmission_spectrum void addTransmission(H5::Group &group, - Mantid::API::MatrixWorkspace_const_sptr workspace, - std::string transmissionName) { + const Mantid::API::MatrixWorkspace_const_sptr &workspace, + const std::string &transmissionName) { // Setup process const std::string sasTransmissionName = sasTransmissionSpectrumGroupName + "_" + transmissionName; @@ -856,8 +864,9 @@ std::map<std::string, std::string> SaveNXcanSAS::validateInputs() { Mantid::API::MatrixWorkspace_sptr transmissionCan = getProperty("TransmissionCan"); - auto checkTransmission = [&result](Mantid::API::MatrixWorkspace_sptr trans, - std::string propertyName) { + auto checkTransmission = [&result]( + const Mantid::API::MatrixWorkspace_sptr &trans, + const std::string &propertyName) { if (trans->getNumberHistograms() != 1) { result.emplace(propertyName, "The input workspaces for transmissions have to be 1D."); diff --git a/Framework/DataHandling/src/SaveNexusProcessed.cpp b/Framework/DataHandling/src/SaveNexusProcessed.cpp index 4e51d730bfac3d942152df0ba9e7bc8c55669631..d3f73902802631589e0b5ae833ee7f6a24010ed4 100644 --- a/Framework/DataHandling/src/SaveNexusProcessed.cpp +++ b/Framework/DataHandling/src/SaveNexusProcessed.cpp @@ -21,6 +21,7 @@ #include "MantidKernel/BoundedValidator.h" #include "MantidNexus/NexusFileIO.h" #include <boost/shared_ptr.hpp> +#include <utility> using namespace Mantid::API; @@ -168,7 +169,8 @@ void SaveNexusProcessed::init() { * @param matrixWorkspace :: pointer to a MatrixWorkspace */ void SaveNexusProcessed::getWSIndexList( - std::vector<int> &indices, MatrixWorkspace_const_sptr matrixWorkspace) { + std::vector<int> &indices, + const MatrixWorkspace_const_sptr &matrixWorkspace) { const std::vector<int> spec_list = getProperty("WorkspaceIndexList"); int spec_min = getProperty("WorkspaceIndexMin"); int spec_max = getProperty("WorkspaceIndexMax"); @@ -217,7 +219,7 @@ void SaveNexusProcessed::getWSIndexList( } void SaveNexusProcessed::doExec( - Workspace_sptr inputWorkspace, + const Workspace_sptr &inputWorkspace, boost::shared_ptr<Mantid::NeXus::NexusFileIO> &nexusFile, const bool keepFile, optional_size_t entryNumber) { // TODO: Remove? @@ -291,7 +293,8 @@ void SaveNexusProcessed::doExec( const bool append_to_file = getProperty("Append"); nexusFile->resetProgress(&prog_init); - nexusFile->openNexusWrite(filename, entryNumber, append_to_file || keepFile); + nexusFile->openNexusWrite(filename, std::move(entryNumber), + append_to_file || keepFile); // Equivalent C++ API handle ::NeXus::File cppFile(nexusFile->fileID); diff --git a/Framework/DataHandling/src/SavePDFGui.cpp b/Framework/DataHandling/src/SavePDFGui.cpp index bf84bd4dab1e1ef1319726a283e81a6133c88253..019c3242ffa8dc9f262b1e2dd58a37a95bc070c2 100644 --- a/Framework/DataHandling/src/SavePDFGui.cpp +++ b/Framework/DataHandling/src/SavePDFGui.cpp @@ -92,7 +92,7 @@ void SavePDFGui::exec() { } void SavePDFGui::writeMetaData(std::ofstream &out, - API::MatrixWorkspace_const_sptr inputWS) { + const API::MatrixWorkspace_const_sptr &inputWS) { out << "#Comment: neutron"; auto run = inputWS->run(); if (run.hasProperty("Qmin")) { @@ -120,7 +120,7 @@ void SavePDFGui::writeMetaData(std::ofstream &out, } void SavePDFGui::writeWSData(std::ofstream &out, - API::MatrixWorkspace_const_sptr inputWS) { + const API::MatrixWorkspace_const_sptr &inputWS) { const auto &x = inputWS->points(0); const auto &y = inputWS->y(0); const auto &dy = inputWS->e(0); diff --git a/Framework/DataHandling/src/SaveRMCProfile.cpp b/Framework/DataHandling/src/SaveRMCProfile.cpp index 70ca4d7f5e7d64cf5ebb674f213ef8f94e7f7476..5d545763d6efba2b2bc8cbd369f1218c72ba88ab 100644 --- a/Framework/DataHandling/src/SaveRMCProfile.cpp +++ b/Framework/DataHandling/src/SaveRMCProfile.cpp @@ -96,8 +96,8 @@ void SaveRMCProfile::exec() { out.close(); } -void SaveRMCProfile::writeMetaData(std::ofstream &out, - API::MatrixWorkspace_const_sptr inputWS) { +void SaveRMCProfile::writeMetaData( + std::ofstream &out, const API::MatrixWorkspace_const_sptr &inputWS) { const auto &y = inputWS->y(0); const std::string title = getProperty("Title"); const std::string inputType = getProperty("InputType"); @@ -107,8 +107,8 @@ void SaveRMCProfile::writeMetaData(std::ofstream &out, std::cout << "rmc " << inputType << " # " << title << std::endl; } -void SaveRMCProfile::writeWSData(std::ofstream &out, - API::MatrixWorkspace_const_sptr inputWS) { +void SaveRMCProfile::writeWSData( + std::ofstream &out, const API::MatrixWorkspace_const_sptr &inputWS) { const auto &x = inputWS->points(0); const auto &y = inputWS->y(0); for (size_t i = 0; i < x.size(); ++i) { diff --git a/Framework/DataHandling/src/SaveReflectometryAscii.cpp b/Framework/DataHandling/src/SaveReflectometryAscii.cpp index 46d5f045216381738934ed54f8b795a8cb9d2c5c..c87a19371d4ca200c562e01bb42d99e84e55e7a2 100644 --- a/Framework/DataHandling/src/SaveReflectometryAscii.cpp +++ b/Framework/DataHandling/src/SaveReflectometryAscii.cpp @@ -141,7 +141,7 @@ void SaveReflectometryAscii::separator() { * @param write :: if true, write string * @param s :: string */ -bool SaveReflectometryAscii::writeString(bool write, std::string s) { +bool SaveReflectometryAscii::writeString(bool write, const std::string &s) { if (write) { if (m_ext == "custom" || m_ext == ".txt") m_file << m_sep << s; @@ -172,7 +172,7 @@ void SaveReflectometryAscii::outputval(double val) { /** Write formatted line of data * @param val :: a string value to be written */ -void SaveReflectometryAscii::outputval(std::string val) { +void SaveReflectometryAscii::outputval(const std::string &val) { m_file << std::setw(28) << val; } @@ -201,8 +201,8 @@ std::string SaveReflectometryAscii::sampleLogUnit(const std::string &logName) { * @param logName :: the name of a SampleLog entry to get its value from * @param logNameFixed :: the name of the SampleLog entry defined by the header */ -void SaveReflectometryAscii::writeInfo(const std::string logName, - const std::string logNameFixed) { +void SaveReflectometryAscii::writeInfo(const std::string &logName, + const std::string &logNameFixed) { const std::string logValue = sampleLogValue(logName); const std::string logUnit = sampleLogUnit(logName); if (!logNameFixed.empty()) { @@ -255,7 +255,7 @@ void SaveReflectometryAscii::header() { } /// Check file -void SaveReflectometryAscii::checkFile(const std::string filename) { +void SaveReflectometryAscii::checkFile(const std::string &filename) { if (Poco::File(filename).exists()) { g_log.warning("File already exists and will be overwritten"); try { diff --git a/Framework/DataHandling/src/SaveSPE.cpp b/Framework/DataHandling/src/SaveSPE.cpp index f0641f9f0c6a0739ace24dc6adfa2b4ad137219b..9c18c1f701d28feebe03d0209ed6866fc45ef9ec 100644 --- a/Framework/DataHandling/src/SaveSPE.cpp +++ b/Framework/DataHandling/src/SaveSPE.cpp @@ -210,7 +210,7 @@ void SaveSPE::writeSPEFile(FILE *outSPEFile, * @param WS :: the workspace to be saved * @param outFile :: the file object to write to */ -void SaveSPE::writeHists(const API::MatrixWorkspace_const_sptr WS, +void SaveSPE::writeHists(const API::MatrixWorkspace_const_sptr &WS, FILE *const outFile) { // We write out values NUM_PER_LINE at a time, so will need to do extra work // if nBins isn't a factor of NUM_PER_LINE @@ -286,7 +286,7 @@ void SaveSPE::check_and_copy_spectra(const HistogramData::HistogramY &inSignal, * @param outFile :: the file object to write to * @param wsIn :: the index number of the histogram to write */ -void SaveSPE::writeHist(const API::MatrixWorkspace_const_sptr WS, +void SaveSPE::writeHist(const API::MatrixWorkspace_const_sptr &WS, FILE *const outFile, const int wsIn) const { check_and_copy_spectra(WS->y(wsIn), WS->e(wsIn), m_tSignal, m_tError); FPRINTF_WITH_EXCEPTION(outFile, "%s", Y_HEADER); diff --git a/Framework/DataHandling/src/SaveTBL.cpp b/Framework/DataHandling/src/SaveTBL.cpp index 4eff4fdf561021d1755af52a0b7a1816fbd26dfe..bc27ecab0d18a8965ce016bfb6fec9bfb9951cdb 100644 --- a/Framework/DataHandling/src/SaveTBL.cpp +++ b/Framework/DataHandling/src/SaveTBL.cpp @@ -44,7 +44,7 @@ void SaveTBL::init() { * Finds the stitch groups that need to be on the same line * @param ws : a pointer to a tableworkspace */ -void SaveTBL::findGroups(ITableWorkspace_sptr ws) { +void SaveTBL::findGroups(const ITableWorkspace_sptr &ws) { size_t rowCount = ws->rowCount(); for (size_t i = 0; i < rowCount; ++i) { TableRow row = ws->getRow(i); diff --git a/Framework/DataHandling/src/SaveToSNSHistogramNexus.cpp b/Framework/DataHandling/src/SaveToSNSHistogramNexus.cpp index 40200da9b2c12eb83d25749d11351492976b54a7..1543210a0ef79414636258d77c1b395b370cc0f4 100644 --- a/Framework/DataHandling/src/SaveToSNSHistogramNexus.cpp +++ b/Framework/DataHandling/src/SaveToSNSHistogramNexus.cpp @@ -187,9 +187,9 @@ int SaveToSNSHistogramNexus::copy_file(const char *inFile, int nx__access, * @return error code */ int SaveToSNSHistogramNexus::WriteOutDataOrErrors( - Geometry::RectangularDetector_const_sptr det, int x_pixel_slab, + const Geometry::RectangularDetector_const_sptr &det, int x_pixel_slab, const char *field_name, const char *errors_field_name, bool doErrors, - bool doBoth, int is_definition, std::string bank) { + bool doBoth, int is_definition, const std::string &bank) { int dataRank, dataDimensions[NX_MAXRANK]; int slabDimensions[NX_MAXRANK], slabStartIndices[NX_MAXRANK]; @@ -412,7 +412,7 @@ int SaveToSNSHistogramNexus::WriteOutDataOrErrors( * @param is_definition * @return error code */ -int SaveToSNSHistogramNexus::WriteDataGroup(std::string bank, +int SaveToSNSHistogramNexus::WriteDataGroup(const std::string &bank, int is_definition) { int dataType, dataRank, dataDimensions[NX_MAXRANK]; NXname name; diff --git a/Framework/DataHandling/src/SetScalingPSD.cpp b/Framework/DataHandling/src/SetScalingPSD.cpp index af5f8c78c625824806eb0aa7b970fa776170da28..c0c85e120cb29a4ee79faac5d93adca13cf915b0 100644 --- a/Framework/DataHandling/src/SetScalingPSD.cpp +++ b/Framework/DataHandling/src/SetScalingPSD.cpp @@ -293,7 +293,7 @@ void SetScalingPSD::movePos(API::MatrixWorkspace_sptr &WS, * @param detID :: Vector of detector numbers * @param pos :: V3D of detector positions corresponding to detID */ -void SetScalingPSD::getDetPositionsFromRaw(std::string rawfile, +void SetScalingPSD::getDetPositionsFromRaw(const std::string &rawfile, std::vector<int> &detID, std::vector<Kernel::V3D> &pos) { (void)rawfile; // Avoid compiler warning diff --git a/Framework/DataHandling/src/StartAndEndTimeFromNexusFileExtractor.cpp b/Framework/DataHandling/src/StartAndEndTimeFromNexusFileExtractor.cpp index a3a7281afcda34eb46217c796c5f731dac9ab840..02254b4f3e8210f30f7e9968358990bc2f53b198 100644 --- a/Framework/DataHandling/src/StartAndEndTimeFromNexusFileExtractor.cpp +++ b/Framework/DataHandling/src/StartAndEndTimeFromNexusFileExtractor.cpp @@ -24,8 +24,8 @@ namespace DataHandling { enum class NexusType { Muon, Processed, ISIS, TofRaw }; enum class TimeType : unsigned char { StartTime, EndTime }; -Mantid::Types::Core::DateAndTime handleMuonNexusFile(TimeType type, - std::string filename) { +Mantid::Types::Core::DateAndTime +handleMuonNexusFile(TimeType type, const std::string &filename) { Mantid::NeXus::NXRoot root(filename); if (type == TimeType::StartTime) { return Mantid::Types::Core::DateAndTime(root.getString("run/start_time")); @@ -35,7 +35,7 @@ Mantid::Types::Core::DateAndTime handleMuonNexusFile(TimeType type, } Mantid::Types::Core::DateAndTime -handleProcessedNexusFile(TimeType type, std::string filename) { +handleProcessedNexusFile(TimeType type, const std::string &filename) { Mantid::NeXus::NXRoot root(filename); if (type == TimeType::StartTime) { return Mantid::Types::Core::DateAndTime( @@ -46,8 +46,8 @@ handleProcessedNexusFile(TimeType type, std::string filename) { } } -Mantid::Types::Core::DateAndTime handleISISNexusFile(TimeType type, - std::string filename) { +Mantid::Types::Core::DateAndTime +handleISISNexusFile(TimeType type, const std::string &filename) { Mantid::NeXus::NXRoot root(filename); if (type == TimeType::StartTime) { return Mantid::Types::Core::DateAndTime( @@ -58,8 +58,8 @@ Mantid::Types::Core::DateAndTime handleISISNexusFile(TimeType type, } } -Mantid::Types::Core::DateAndTime handleTofRawNexusFile(TimeType type, - std::string filename) { +Mantid::Types::Core::DateAndTime +handleTofRawNexusFile(TimeType type, const std::string &filename) { Mantid::NeXus::NXRoot root(filename); if (type == TimeType::StartTime) { return Mantid::Types::Core::DateAndTime(root.getString("entry/start_time")); @@ -68,7 +68,7 @@ Mantid::Types::Core::DateAndTime handleTofRawNexusFile(TimeType type, } } -NexusType whichNexusType(std::string filename) { +NexusType whichNexusType(const std::string &filename) { std::vector<std::string> entryName; std::vector<std::string> definition; auto count = @@ -112,8 +112,8 @@ NexusType whichNexusType(std::string filename) { return nexusType; } -Mantid::Types::Core::DateAndTime extractDateAndTime(TimeType type, - std::string filename) { +Mantid::Types::Core::DateAndTime +extractDateAndTime(TimeType type, const std::string &filename) { auto fullFileName = Mantid::API::FileFinder::Instance().getFullPath(filename); // Figure out the type of the Nexus file. We need to handle them individually // since they store the datetime differently diff --git a/Framework/DataHandling/src/XmlHandler.cpp b/Framework/DataHandling/src/XmlHandler.cpp index 43346b9174de10f83b21e427faf4857cfea707e0..4c4c2ae194e54dab1ae1ee4fd2e4582ebd098d2e 100644 --- a/Framework/DataHandling/src/XmlHandler.cpp +++ b/Framework/DataHandling/src/XmlHandler.cpp @@ -23,7 +23,7 @@ namespace Mantid { namespace DataHandling { -XmlHandler::XmlHandler(std::string filename) { +XmlHandler::XmlHandler(const std::string &filename) { std::ifstream in(filename); Poco::XML::InputSource src(in); Poco::XML::DOMParser parser; diff --git a/Framework/DataHandling/test/CheckMantidVersionTest.h b/Framework/DataHandling/test/CheckMantidVersionTest.h index fe257da737d67ac0675d1454bdb1ad72186774a9..085fa054352d2e26ba6dbb02a2a6bc147facf70b 100644 --- a/Framework/DataHandling/test/CheckMantidVersionTest.h +++ b/Framework/DataHandling/test/CheckMantidVersionTest.h @@ -8,6 +8,8 @@ #include <cxxtest/TestSuite.h> +#include <utility> + #include "MantidDataHandling/CheckMantidVersion.h" using Mantid::DataHandling::CheckMantidVersion; @@ -21,8 +23,8 @@ class MockedCheckMantidVersion : public CheckMantidVersion { public: MockedCheckMantidVersion(std::string currentVersion, std::string gitHubVersion) - : CheckMantidVersion(), CurrentVersion(currentVersion), - GitHubVersion(gitHubVersion) {} + : CheckMantidVersion(), CurrentVersion(std::move(currentVersion)), + GitHubVersion(std::move(gitHubVersion)) {} std::string CurrentVersion; std::string GitHubVersion; @@ -117,8 +119,7 @@ public: std::string currentVersion = alg.PropertyManagerOwner::getProperty("CurrentVersion"); - std::string mostRecentVersion = - alg.PropertyManagerOwner::getProperty("MostRecentVersion"); + alg.PropertyManagerOwner::getProperty("MostRecentVersion"); bool isNewVersionAvailable = alg.PropertyManagerOwner::getProperty("IsNewVersionAvailable"); diff --git a/Framework/DataHandling/test/CompressEventsTest.h b/Framework/DataHandling/test/CompressEventsTest.h index 8132d6f914e9456b35d9d79e9950e677b457f522..4d5ce1d84e74e3087d627902b1cdeb27b043c8e3 100644 --- a/Framework/DataHandling/test/CompressEventsTest.h +++ b/Framework/DataHandling/test/CompressEventsTest.h @@ -37,8 +37,9 @@ public: TS_ASSERT_THROWS_NOTHING(alg.setPropertyValue("Tolerance", "0.0")); } - void doTest(std::string inputName, std::string outputName, double tolerance, - int numPixels = 50, double wallClockTolerance = 0.) { + void doTest(const std::string &inputName, const std::string &outputName, + double tolerance, int numPixels = 50, + double wallClockTolerance = 0.) { EventWorkspace_sptr input, output; EventType eventType = WEIGHTED_NOTIME; if (wallClockTolerance > 0.) diff --git a/Framework/DataHandling/test/CreateSampleShapeTest.h b/Framework/DataHandling/test/CreateSampleShapeTest.h index 0c3b29677ca4a3bc658892291b494e406f4f67d2..96d71c38a39838cdaa32874a977aae9d5feb9cad 100644 --- a/Framework/DataHandling/test/CreateSampleShapeTest.h +++ b/Framework/DataHandling/test/CreateSampleShapeTest.h @@ -83,8 +83,8 @@ public: TS_ASSERT_DELTA(2.6989, material.numberDensity(), 1e-04); } - void runStandardTest(std::string xmlShape, double x, double y, double z, - bool inside) { + void runStandardTest(const std::string &xmlShape, double x, double y, + double z, bool inside) { // Need a test workspace Mantid::API::AnalysisDataService::Instance().add( "TestWorkspace", diff --git a/Framework/DataHandling/test/CreateSimulationWorkspaceTest.h b/Framework/DataHandling/test/CreateSimulationWorkspaceTest.h index 6ed9df97dd63605c455fa568fb4813f3aca3e483..f523688c52b2171b21b7ec27a477c532d326032e 100644 --- a/Framework/DataHandling/test/CreateSimulationWorkspaceTest.h +++ b/Framework/DataHandling/test/CreateSimulationWorkspaceTest.h @@ -178,7 +178,7 @@ private: .retrieveWS<MatrixWorkspace>(m_wsName); } - void doBinCheck(Mantid::API::MatrixWorkspace_sptr outputWS, + void doBinCheck(const Mantid::API::MatrixWorkspace_sptr &outputWS, const size_t expectedSize) { TS_ASSERT_EQUALS(outputWS->readX(0).size(), expectedSize); // Check bins are correct @@ -189,7 +189,7 @@ private: } } - void doInstrumentCheck(Mantid::API::MatrixWorkspace_sptr outputWS, + void doInstrumentCheck(const Mantid::API::MatrixWorkspace_sptr &outputWS, const std::string &name, const size_t ndets) { Mantid::Geometry::Instrument_const_sptr instr = outputWS->getInstrument(); @@ -208,7 +208,7 @@ private: } void compareSimulationWorkspaceIDFWithFileIDF( - Mantid::API::MatrixWorkspace_sptr simulationWorkspace, + const Mantid::API::MatrixWorkspace_sptr &simulationWorkspace, const std::string &filename, const std::string &algorithmName) { std::string outputWSName = "outWSIDFCompareNexus"; auto alg = Mantid::API::AlgorithmManager::Instance().createUnmanaged( @@ -235,10 +235,6 @@ private: class CreateSimulationWorkspaceTestPerformance : public CxxTest::TestSuite { public: void setUp() override { - - // Starting bin, bin width, last bin - const std::string binParams("-30,3,279"); - alg.initialize(); alg.setPropertyValue("Instrument", "HET"); diff --git a/Framework/DataHandling/test/DataBlockGeneratorTest.h b/Framework/DataHandling/test/DataBlockGeneratorTest.h index c450c1ed9f7581125b91eca1fd2c70c2361c497e..8abd5cb4dc21feab966cb7d3c0acf288978542d2 100644 --- a/Framework/DataHandling/test/DataBlockGeneratorTest.h +++ b/Framework/DataHandling/test/DataBlockGeneratorTest.h @@ -96,8 +96,9 @@ public: } private: - void do_test_interval(std::vector<std::pair<int64_t, int64_t>> interval, - std::vector<int64_t> expectedOutput) { + void + do_test_interval(const std::vector<std::pair<int64_t, int64_t>> &interval, + std::vector<int64_t> expectedOutput) { Mantid::DataHandling::DataBlockGenerator generator(interval); TSM_ASSERT("Should be done", !generator.isDone()); diff --git a/Framework/DataHandling/test/DownloadFileTest.h b/Framework/DataHandling/test/DownloadFileTest.h index 10dca14ca826d41795ea13fa45a2ca3f094ec0fa..e86c96762ec53b9328f52c5e08cac926a39b24f9 100644 --- a/Framework/DataHandling/test/DownloadFileTest.h +++ b/Framework/DataHandling/test/DownloadFileTest.h @@ -73,8 +73,8 @@ public: exec_alg(url, tmpFile.path(), "http://" + url); } - void exec_alg(std::string address, std::string filename, - std::string newAddress = "") { + void exec_alg(const std::string &address, const std::string &filename, + const std::string &newAddress = "") { MockedDownloadFile alg; TS_ASSERT_THROWS_NOTHING(alg.initialize()) TS_ASSERT(alg.isInitialized()) diff --git a/Framework/DataHandling/test/DownloadInstrumentTest.h b/Framework/DataHandling/test/DownloadInstrumentTest.h index 25258805ac2646346e7bc15785a2429c6a89b2b6..5572bb93725bf144bf11f86c3c9f5e6edcd24a70 100644 --- a/Framework/DataHandling/test/DownloadInstrumentTest.h +++ b/Framework/DataHandling/test/DownloadInstrumentTest.h @@ -105,7 +105,7 @@ public: } static void destroySuite(DownloadInstrumentTest *suite) { delete suite; } - void createDirectory(Poco::Path path) { + void createDirectory(const Poco::Path &path) { Poco::File file(path); if (file.createDirectory()) { m_directoriesToRemove.emplace_back(file); @@ -190,9 +190,6 @@ public: } int runDownloadInstrument() { - // Name of the output workspace. - std::string outWSName("DownloadInstrumentTest_OutputWS"); - MockedDownloadInstrument alg; TS_ASSERT_THROWS_NOTHING(alg.initialize()) TS_ASSERT(alg.isInitialized()) diff --git a/Framework/DataHandling/test/ExtractMonitorWorkspaceTest.h b/Framework/DataHandling/test/ExtractMonitorWorkspaceTest.h index c3b35941369342675c4266fb5b204e4a2cedf6aa..520f80cc285848289c8c6511ef3c720c40f2a008 100644 --- a/Framework/DataHandling/test/ExtractMonitorWorkspaceTest.h +++ b/Framework/DataHandling/test/ExtractMonitorWorkspaceTest.h @@ -45,7 +45,8 @@ public: TS_ASSERT(!alg.isExecuted()); } - void doTest(MatrixWorkspace_sptr inws, MatrixWorkspace_sptr monws) { + void doTest(const MatrixWorkspace_sptr &inws, + const MatrixWorkspace_sptr &monws) { inws->setMonitorWorkspace(monws); TS_ASSERT_EQUALS(inws->monitorWorkspace(), monws); diff --git a/Framework/DataHandling/test/FindDetectorsInShapeTest.h b/Framework/DataHandling/test/FindDetectorsInShapeTest.h index 43386547f82c0db77a1053bfa9c1818e101e8494..0ff8b16016839ea982196c523e4df1e3bd65c6d5 100644 --- a/Framework/DataHandling/test/FindDetectorsInShapeTest.h +++ b/Framework/DataHandling/test/FindDetectorsInShapeTest.h @@ -117,7 +117,7 @@ public: runTest(xmlShape, "320,340,360,380", false); } - void runTest(std::string xmlShape, std::string expectedHits, + void runTest(const std::string &xmlShape, std::string expectedHits, bool includeMonitors = true) { Mantid::DataHandling::FindDetectorsInShape alg; TS_ASSERT_THROWS_NOTHING(alg.initialize()); diff --git a/Framework/DataHandling/test/GroupDetectors2Test.h b/Framework/DataHandling/test/GroupDetectors2Test.h index 9143e2e5ee809b4771204fba0c4d14818ecafd8d..d97897e4d44842fea9cf599b2341a8f754ef4513 100644 --- a/Framework/DataHandling/test/GroupDetectors2Test.h +++ b/Framework/DataHandling/test/GroupDetectors2Test.h @@ -560,21 +560,21 @@ public: TS_ASSERT_EQUALS(*specDet, 2); specDet = output2D1->getSpectrum(2).getDetectorIDs().begin(); TS_ASSERT_EQUALS(*specDet, 3); - specDet++; + ++specDet; TS_ASSERT_EQUALS(*specDet, 4); - specDet++; + ++specDet; TS_ASSERT_EQUALS(*specDet, 5); specDet = output2D1->getSpectrum(3).getDetectorIDs().begin(); TS_ASSERT_EQUALS(*specDet, 2); - specDet++; + ++specDet; TS_ASSERT_EQUALS(*specDet, 8); - specDet++; + ++specDet; TS_ASSERT_EQUALS(*specDet, 9); - specDet++; + ++specDet; TS_ASSERT_EQUALS(*specDet, 11); - specDet++; + ++specDet; TS_ASSERT_EQUALS(*specDet, 12); - specDet++; + ++specDet; TS_ASSERT_EQUALS(*specDet, 13); AnalysisDataService::Instance().remove(outputSpace); @@ -631,6 +631,7 @@ public: const auto &y = output->y(0); const auto &e = output->e(0); for (size_t i = 0; i < y.size(); ++i) { + // cppcheck-suppress unreadVariable const double expectedSignal = i == 0 ? 2. : (1. + 2.) / 2.; TS_ASSERT_EQUALS(y[i], expectedSignal) const double expectedError = i == 0 ? 1. : std::sqrt(2.) / 2.; @@ -659,6 +660,7 @@ public: const auto &y = output->y(0); const auto &e = output->e(0); for (size_t i = 0; i < y.size(); ++i) { + // cppcheck-suppress unreadVariable const double expectedSignal = i == 0 ? 2. : 1. + 2.; TS_ASSERT_EQUALS(y[i], expectedSignal) const double expectedError = i == 0 ? 1. : std::sqrt(2.); @@ -1122,7 +1124,7 @@ private: } Instrument_sptr instr(new Instrument); - for (detid_t i = 0; i < NHIST; i++) { + for (detid_t i = 0; i < NHIST; ++i) { Detector *d = new Detector("det", i, nullptr); d->setPos(1. + static_cast<double>(i) * 0.1, 0., 1.); instr->add(d); diff --git a/Framework/DataHandling/test/GroupDetectorsTest.h b/Framework/DataHandling/test/GroupDetectorsTest.h index 62d438f6607989152363c80844871759627d1f22..47ff0be4fca32510e463c54c48adf788896180c0 100644 --- a/Framework/DataHandling/test/GroupDetectorsTest.h +++ b/Framework/DataHandling/test/GroupDetectorsTest.h @@ -52,7 +52,7 @@ public: space2D->getSpectrum(j).setDetectorID(j); } Instrument_sptr instr(new Instrument); - for (detid_t i = 0; i < 5; i++) { + for (detid_t i = 0; i < 5; ++i) { Detector *d = new Detector("det", i, nullptr); instr->add(d); instr->markAsDetector(d); diff --git a/Framework/DataHandling/test/InstrumentRayTracerTest.h b/Framework/DataHandling/test/InstrumentRayTracerTest.h index 563241b26f2576f2501226946475c86e5f913106..7ec49b9084a3838c01638a9bc69bd99555c39016 100644 --- a/Framework/DataHandling/test/InstrumentRayTracerTest.h +++ b/Framework/DataHandling/test/InstrumentRayTracerTest.h @@ -98,9 +98,9 @@ public: } private: - void showResults(Links &results, Instrument_const_sptr inst) { + void showResults(Links &results, const Instrument_const_sptr &inst) { Links::const_iterator resultItr = results.begin(); - for (; resultItr != results.end(); resultItr++) { + for (; resultItr != results.end(); ++resultItr) { IComponent_const_sptr component = inst->getComponentByID(resultItr->componentID); std::cout << component->getName() << ", "; diff --git a/Framework/DataHandling/test/LoadAscii2Test.h b/Framework/DataHandling/test/LoadAscii2Test.h index 12d510c2a88baa134150aeb145c01d4653859116..85b348f697c9e0ebe4ea73992857223e578db3ff 100644 --- a/Framework/DataHandling/test/LoadAscii2Test.h +++ b/Framework/DataHandling/test/LoadAscii2Test.h @@ -434,7 +434,7 @@ private: return save.getPropertyValue("Filename"); } - void checkTableData(const Mantid::API::ITableWorkspace_sptr outputWS) { + void checkTableData(const Mantid::API::ITableWorkspace_sptr &outputWS) { const std::string name = "Compare_SaveAsciiWS"; auto wsToCompare = SaveAscii2Test::writeTableWS(name); @@ -590,7 +590,7 @@ private: return outputWS; } - void checkData(const Mantid::API::MatrixWorkspace_sptr outputWS, + void checkData(const Mantid::API::MatrixWorkspace_sptr &outputWS, const int cols) { TS_ASSERT_EQUALS(outputWS->getNumberHistograms(), 5); TS_ASSERT_EQUALS(outputWS->blocksize(), 4); diff --git a/Framework/DataHandling/test/LoadAsciiStlTest.h b/Framework/DataHandling/test/LoadAsciiStlTest.h index 57ebd4ec3fc8057a9b30ff78583f44a50cb84e0b..f07ca0e9dc976b26043fd8f02bad866768f6a57f 100644 --- a/Framework/DataHandling/test/LoadAsciiStlTest.h +++ b/Framework/DataHandling/test/LoadAsciiStlTest.h @@ -53,7 +53,7 @@ public: loadFailureTest("invalid_triangle.stl"); } - void loadFailureTest(const std::string filename) { + void loadFailureTest(const std::string &filename) { std::string path = FileFinder::Instance().getFullPath(filename); auto Loader = LoadAsciiStl(path, units); TS_ASSERT_THROWS_ANYTHING(Loader.readStl()); diff --git a/Framework/DataHandling/test/LoadAsciiTest.h b/Framework/DataHandling/test/LoadAsciiTest.h index f970361193ae41865c454bdc4794d1f5fef804f0..efacceca2097553fdfc39f109c69d6ec627c3b82 100644 --- a/Framework/DataHandling/test/LoadAsciiTest.h +++ b/Framework/DataHandling/test/LoadAsciiTest.h @@ -275,7 +275,7 @@ private: return outputWS; } - void checkData(const Mantid::API::MatrixWorkspace_sptr outputWS, + void checkData(const Mantid::API::MatrixWorkspace_sptr &outputWS, const bool threeColumn) { if (threeColumn) { TS_ASSERT_EQUALS(outputWS->getNumberHistograms(), 1); diff --git a/Framework/DataHandling/test/LoadDetectorsGroupingFileTest.h b/Framework/DataHandling/test/LoadDetectorsGroupingFileTest.h index e39ea1170adb1abed722e26c05ae322dd16f45c6..3ec153753df288da1f1ad1051877395e237c40e9 100644 --- a/Framework/DataHandling/test/LoadDetectorsGroupingFileTest.h +++ b/Framework/DataHandling/test/LoadDetectorsGroupingFileTest.h @@ -124,7 +124,7 @@ public: API::AnalysisDataService::Instance().remove(ws); } - ScopedFile generateAutoGroupIDGroupXMLFile(std::string xmlfilename) { + ScopedFile generateAutoGroupIDGroupXMLFile(const std::string &xmlfilename) { std::ostringstream os; os << "<?xml version=\"1.0\"?>\n"; @@ -173,7 +173,7 @@ public: API::AnalysisDataService::Instance().remove(ws); } - ScopedFile generateSpectrumIDXMLFile(std::string xmlfilename) { + ScopedFile generateSpectrumIDXMLFile(const std::string &xmlfilename) { std::ostringstream os; os << "<?xml version=\"1.0\"?>\n"; @@ -222,7 +222,7 @@ public: API::AnalysisDataService::Instance().remove(ws); } - ScopedFile generateOldSpectrumIDXMLFile(std::string xmlfilename) { + ScopedFile generateOldSpectrumIDXMLFile(const std::string &xmlfilename) { std::ostringstream os; os << "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"; diff --git a/Framework/DataHandling/test/LoadDspacemapTest.h b/Framework/DataHandling/test/LoadDspacemapTest.h index 7af2fc113de04340e09228f352af08a0039301ff..c6b72d53cd1540c8eff1463efb9a7dcb3408bad3 100644 --- a/Framework/DataHandling/test/LoadDspacemapTest.h +++ b/Framework/DataHandling/test/LoadDspacemapTest.h @@ -58,9 +58,8 @@ public: TS_ASSERT_DELTA(offsetsWS->dataY(0)[0], -0.6162, 0.0001); } - void doTestVulcan(std::string dspaceFile, std::string fileType) { - std::string outputFile = "./VULCAN_dspacemaptocal_test.cal"; - + void doTestVulcan(const std::string &dspaceFile, + const std::string &fileType) { LoadDspacemap testerDSP; TS_ASSERT_THROWS_NOTHING(testerDSP.initialize()); TS_ASSERT_THROWS_NOTHING(testerDSP.isInitialized()); diff --git a/Framework/DataHandling/test/LoadEMUauTest.h b/Framework/DataHandling/test/LoadEMUauTest.h index 29a0ca3a9d53c24e66a9bc4605bd96cf363ef8d4..53e348f516e74d0a2b898aa52edb2df77406e11f 100644 --- a/Framework/DataHandling/test/LoadEMUauTest.h +++ b/Framework/DataHandling/test/LoadEMUauTest.h @@ -82,7 +82,7 @@ public: run.getProperty("end_time")->value().find("2018-07-26T10:17:12.6") == 0) // test some data properties - auto logpm = [&run](std::string tag) { + auto logpm = [&run](const std::string &tag) { return dynamic_cast<TimeSeriesProperty<double> *>(run.getProperty(tag)) ->firstValue(); }; @@ -91,7 +91,7 @@ public: // test some instrument parameters auto instr = output->getInstrument(); - auto iparam = [&instr](std::string tag) { + auto iparam = [&instr](const std::string &tag) { return instr->getNumberParameter(tag)[0]; }; TS_ASSERT_DELTA(iparam("AnalysedV2"), 630.866, 1.0e-3); diff --git a/Framework/DataHandling/test/LoadEmptyInstrumentTest.h b/Framework/DataHandling/test/LoadEmptyInstrumentTest.h index 95f12043a6c82b64ee4a392df90169b9be3e12ea..fa8b7b2b450e96d90a0f8e1cbe656693ddc21764 100644 --- a/Framework/DataHandling/test/LoadEmptyInstrumentTest.h +++ b/Framework/DataHandling/test/LoadEmptyInstrumentTest.h @@ -38,7 +38,7 @@ public: static void destroySuite(LoadEmptyInstrumentTest *suite) { delete suite; } /// Helper that checks that each spectrum has one detector - void check_workspace_detectors(MatrixWorkspace_sptr output, + void check_workspace_detectors(const MatrixWorkspace_sptr &output, size_t numberDetectors) { TS_ASSERT_EQUALS(output->getNumberHistograms(), numberDetectors); for (size_t i = 0; i < output->getNumberHistograms(); i++) { diff --git a/Framework/DataHandling/test/LoadEventNexusTest.h b/Framework/DataHandling/test/LoadEventNexusTest.h index bfdd472c443c56e43c4af128065833e991b8b1ba..893761b6f34538fa96195443ce94400b123a2192 100644 --- a/Framework/DataHandling/test/LoadEventNexusTest.h +++ b/Framework/DataHandling/test/LoadEventNexusTest.h @@ -106,7 +106,7 @@ load_reference_workspace(const std::string &filename) { return boost::dynamic_pointer_cast<const EventWorkspace>(out); } void run_MPI_load(const Parallel::Communicator &comm, - boost::shared_ptr<std::mutex> mutex, + const boost::shared_ptr<std::mutex> &mutex, const std::string &filename) { boost::shared_ptr<const EventWorkspace> reference; boost::shared_ptr<const EventWorkspace> eventWS; @@ -736,7 +736,7 @@ public: } void doTestSingleBank(bool SingleBankPixelsOnly, bool Precount, - std::string BankName = "bank36", + const std::string &BankName = "bank36", bool willFail = false) { Mantid::API::FrameworkManager::Instance(); LoadEventNexus ld; diff --git a/Framework/DataHandling/test/LoadEventPreNexus2Test.h b/Framework/DataHandling/test/LoadEventPreNexus2Test.h index b2c80def986a4e603f7d8fd8c02964cddec39e85..795fe4a2878e38d2e7a738cc8e1bd38cebb85c33 100644 --- a/Framework/DataHandling/test/LoadEventPreNexus2Test.h +++ b/Framework/DataHandling/test/LoadEventPreNexus2Test.h @@ -69,7 +69,7 @@ public: TS_ASSERT_EQUALS(sizeof(DasEvent), 8); } - void checkWorkspace(std::string eventfile, std::string WSName, + void checkWorkspace(const std::string &eventfile, const std::string &WSName, int numpixels_with_events) { // Get the event file size struct stat filestatus; @@ -143,7 +143,7 @@ public: do_test_LoadPreNeXus_CNCS("Parallel"); } - void do_test_LoadPreNeXus_CNCS(std::string parallel) { + void do_test_LoadPreNeXus_CNCS(const std::string ¶llel) { std::string eventfile("CNCS_7860_neutron_event.dat"); eventLoader->setPropertyValue("EventFilename", eventfile); eventLoader->setPropertyValue("MappingFilename", "CNCS_TS_2008_08_18.dat"); diff --git a/Framework/DataHandling/test/LoadFullprofResolutionTest.h b/Framework/DataHandling/test/LoadFullprofResolutionTest.h index 475dc3a427abe7312a9371a8575bcaad3ac40cb0..975766df8d4eb8e165961fb282630fb24d410a89 100644 --- a/Framework/DataHandling/test/LoadFullprofResolutionTest.h +++ b/Framework/DataHandling/test/LoadFullprofResolutionTest.h @@ -747,7 +747,7 @@ public: //---------------------------------------------------------------------------------------------- /** Parse a TableWorkspace to a map */ - void parseTableWorkspace(TableWorkspace_sptr tablews, + void parseTableWorkspace(const TableWorkspace_sptr &tablews, map<string, double> ¶mmap) { parammap.clear(); @@ -766,7 +766,7 @@ public: //---------------------------------------------------------------------------------------------- /** Parse a TableWorkspace's 2nd bank to a map */ - void parseTableWorkspace2(TableWorkspace_sptr tablews, + void parseTableWorkspace2(const TableWorkspace_sptr &tablews, map<string, double> ¶mmap) { parammap.clear(); @@ -785,7 +785,7 @@ public: //---------------------------------------------------------------------------------------------- /** Generate a GEM workspace group with specified number of workspaces. */ - void load_GEM(size_t numberOfWorkspaces, std::string workspaceName) { + void load_GEM(size_t numberOfWorkspaces, const std::string &workspaceName) { LoadInstrument loaderGEM; TS_ASSERT_THROWS_NOTHING(loaderGEM.initialize()); @@ -818,7 +818,7 @@ public: //---------------------------------------------------------------------------------------------- /** Generate a 1 bank .irf file */ - void generate1BankIrfFile(string filename) { + void generate1BankIrfFile(const string &filename) { ofstream ofile; ofile.open(filename.c_str()); @@ -879,7 +879,7 @@ public: //---------------------------------------------------------------------------------------------- /** Generate a 2 bank .irf file */ - void generate2BankIrfFile(string filename) { + void generate2BankIrfFile(const string &filename) { ofstream ofile; ofile.open(filename.c_str()); @@ -977,7 +977,7 @@ public: /** Generate a 3 bank .irf file */ - void generate3BankIrfFile(string filename) { + void generate3BankIrfFile(const string &filename) { ofstream ofile; ofile.open(filename.c_str()); @@ -1116,7 +1116,7 @@ public: //---------------------------------------------------------------------------------------------- /** Generate a 1 bank .irf file for BackToBackExponential fitting function */ - void generate1BankIrfBBXFile(string filename) { + void generate1BankIrfBBXFile(const string &filename) { ofstream ofile; ofile.open(filename.c_str()); diff --git a/Framework/DataHandling/test/LoadGSASInstrumentFileTest.h b/Framework/DataHandling/test/LoadGSASInstrumentFileTest.h index 88434aeb4885b7bfa70d4cfabc8540eda72dcca6..e7e65b5ee5304332d6139900c436e704d673bf5a 100644 --- a/Framework/DataHandling/test/LoadGSASInstrumentFileTest.h +++ b/Framework/DataHandling/test/LoadGSASInstrumentFileTest.h @@ -322,7 +322,7 @@ public: //---------------------------------------------------------------------------------------------- /** Parse a TableWorkspace to a map */ - void parseTableWorkspace(TableWorkspace_sptr tablews, + void parseTableWorkspace(const TableWorkspace_sptr &tablews, map<string, double> ¶mmap) { parammap.clear(); @@ -341,7 +341,7 @@ public: //---------------------------------------------------------------------------------------------- /** Parse a TableWorkspace's 2nd bank to a map */ - void parseTableWorkspace2(TableWorkspace_sptr tablews, + void parseTableWorkspace2(const TableWorkspace_sptr &tablews, map<string, double> ¶mmap) { parammap.clear(); @@ -360,7 +360,7 @@ public: //---------------------------------------------------------------------------------------------- /** Generate a 1 bank .prm file */ - void generate1BankPrmFile(string filename) { + void generate1BankPrmFile(const string &filename) { ofstream ofile; ofile.open(filename.c_str()); @@ -402,7 +402,7 @@ public: //---------------------------------------------------------------------------------------------- /** Generate a 2 bank .irf file */ - void generate2BankPrmFile(string filename) { + void generate2BankPrmFile(const string &filename) { ofstream ofile; ofile.open(filename.c_str()); @@ -456,7 +456,7 @@ public: //---------------------------------------------------------------------------------------------- /** Generate a 1 bank .prm file */ - void generateBadHistogramTypePrmFile(string filename) { + void generateBadHistogramTypePrmFile(const string &filename) { ofstream ofile; ofile.open(filename.c_str()); @@ -497,7 +497,7 @@ public: /** Create a workspace group with specified number of workspaces. */ void createWorkspaceGroup(size_t numberOfWorkspaces, - std::string workspaceName) { + const std::string &workspaceName) { // create a workspace with some sample data WorkspaceGroup_sptr gws(new API::WorkspaceGroup); diff --git a/Framework/DataHandling/test/LoadILLDiffractionTest.h b/Framework/DataHandling/test/LoadILLDiffractionTest.h index 4f4c89268a99cb566b00fadec9fb976740e6330b..1f43b32b0c1a26a2f071fff1a27b8871c9cae268 100644 --- a/Framework/DataHandling/test/LoadILLDiffractionTest.h +++ b/Framework/DataHandling/test/LoadILLDiffractionTest.h @@ -325,7 +325,7 @@ public: TS_ASSERT_DELTA(theta, 147.55, 0.001) } - void do_test_D2B_single_file(std::string dataType) { + void do_test_D2B_single_file(const std::string &dataType) { // Test a D2B detector scan file with 25 detector positions const int NUMBER_OF_TUBES = 128; diff --git a/Framework/DataHandling/test/LoadILLReflectometryTest.h b/Framework/DataHandling/test/LoadILLReflectometryTest.h index 1b1265d21baa908d810d4c11e9c47c77ca96c275..e282244fd77ce2e225e7860a0642270d60997648 100644 --- a/Framework/DataHandling/test/LoadILLReflectometryTest.h +++ b/Framework/DataHandling/test/LoadILLReflectometryTest.h @@ -34,7 +34,7 @@ private: // Name of the default output workspace const std::string m_outWSName{"LoadILLReflectometryTest_OutputWS"}; - static void commonProperties(MatrixWorkspace_sptr output, + static void commonProperties(const MatrixWorkspace_sptr &output, const std::string &instrName) { TS_ASSERT(output->isHistogramData()) const auto &spectrumInfo = output->spectrumInfo(); @@ -59,7 +59,7 @@ private: "degree") } - static double detCounts(MatrixWorkspace_sptr output) { + static double detCounts(const MatrixWorkspace_sptr &output) { // sum of detector counts double counts{0.0}; for (size_t i = 0; i < output->getNumberHistograms(); ++i) { @@ -696,10 +696,12 @@ public: auto instrument = output->getInstrument(); auto slit1 = instrument->getComponentByName("slit2"); auto slit2 = instrument->getComponentByName("slit3"); + // cppcheck-suppress unreadVariable const double S2z = -output->run().getPropertyValueAsType<double>("Distance.S2toSample") * 1e-3; TS_ASSERT_EQUALS(slit1->getPos(), V3D(0.0, 0.0, S2z)) + // cppcheck-suppress unreadVariable const double S3z = -output->run().getPropertyValueAsType<double>("Distance.S3toSample") * 1e-3; diff --git a/Framework/DataHandling/test/LoadILLTOF2Test.h b/Framework/DataHandling/test/LoadILLTOF2Test.h index aee5df882ccf3377b57cca4ef458156ed2cd17d9..9a2b9dcd7b92b3528bf7c95fed32dce57d57c414 100644 --- a/Framework/DataHandling/test/LoadILLTOF2Test.h +++ b/Framework/DataHandling/test/LoadILLTOF2Test.h @@ -46,7 +46,7 @@ public: * The elastic peak is obtained on the fly from the sample data. */ MatrixWorkspace_sptr - loadDataFile(const std::string dataFile, const size_t numberOfHistograms, + loadDataFile(const std::string &dataFile, const size_t numberOfHistograms, const size_t numberOfMonitors, const size_t numberOfChannels, const double tofDelay, const double tofChannelWidth) { LoadILLTOF2 loader; diff --git a/Framework/DataHandling/test/LoadILLTest.h b/Framework/DataHandling/test/LoadILLTest.h index cd4ff3f0ddb7dea15927e4521f23659911f67fa7..5a70735944f9894c2c18dddeb99bcaa4a65301e2 100644 --- a/Framework/DataHandling/test/LoadILLTest.h +++ b/Framework/DataHandling/test/LoadILLTest.h @@ -27,7 +27,7 @@ public: void tearDown() override { AnalysisDataService::Instance().clear(); } - void checkLoader(std::string filename, std::string resultLoader) { + void checkLoader(const std::string &filename, std::string resultLoader) { Load alg; alg.setChild(true); alg.initialize(); diff --git a/Framework/DataHandling/test/LoadISISNexusTest.h b/Framework/DataHandling/test/LoadISISNexusTest.h index 83f8223fe7179da79d4542f4dcf5b6ca86f13d92..8179ec60a6eb7a37ff892464fbcf9c79ae8bd158 100644 --- a/Framework/DataHandling/test/LoadISISNexusTest.h +++ b/Framework/DataHandling/test/LoadISISNexusTest.h @@ -27,7 +27,7 @@ using namespace Mantid::DataHandling; class LoadISISNexusTest : public CxxTest::TestSuite { private: // Helper method to fetch the log property entry corresponding to period. - Property *fetchPeriodLog(MatrixWorkspace_sptr workspace, + Property *fetchPeriodLog(const MatrixWorkspace_sptr &workspace, int expectedPeriodNumber) { std::stringstream period_number_stream; period_number_stream << expectedPeriodNumber; @@ -38,14 +38,14 @@ private: // Helper method to fetch the log property entry corresponding to the current // period. - Property *fetchCurrentPeriodLog(MatrixWorkspace_sptr workspace) { + Property *fetchCurrentPeriodLog(const MatrixWorkspace_sptr &workspace) { Property *p = workspace->run().getLogData("current_period"); return p; } // Helper method to check that the log data contains a specific period number // entry. - void checkPeriodLogData(MatrixWorkspace_sptr workspace, + void checkPeriodLogData(const MatrixWorkspace_sptr &workspace, int expectedPeriodNumber) { Property *p = nullptr; TS_ASSERT_THROWS_NOTHING( diff --git a/Framework/DataHandling/test/LoadInstrumentTest.h b/Framework/DataHandling/test/LoadInstrumentTest.h index 4278629f6e06559dd5b7b6b074fdaf3b13f6da8c..8dd42e1c98a50c6f5b618d607fca1fa1d483eb77 100644 --- a/Framework/DataHandling/test/LoadInstrumentTest.h +++ b/Framework/DataHandling/test/LoadInstrumentTest.h @@ -418,7 +418,7 @@ public: } /// Common initialisation for Nexus loading tests - MatrixWorkspace_sptr doLoadNexus(const std::string filename) { + MatrixWorkspace_sptr doLoadNexus(const std::string &filename) { LoadInstrument nexusLoader; nexusLoader.initialize(); nexusLoader.setChild(true); @@ -860,9 +860,9 @@ private: // @param paramFilename Expected parameter file to be loaded as part of // LoadInstrument // @param par A specific parameter to check if have been loaded - void doTestParameterFileSelection(std::string filename, - std::string paramFilename, - std::string par) { + void doTestParameterFileSelection(const std::string &filename, + const std::string ¶mFilename, + const std::string &par) { InstrumentDataService::Instance().clear(); LoadInstrument loader; @@ -914,7 +914,7 @@ public: ws = WorkspaceCreationHelper::create2DWorkspace(1, 2); } - void doTest(std::string filename, size_t numTimes = 1) { + void doTest(const std::string &filename, size_t numTimes = 1) { for (size_t i = 0; i < numTimes; ++i) { // Remove any existing instruments, so each time they are loaded. InstrumentDataService::Instance().clear(); diff --git a/Framework/DataHandling/test/LoadIsawDetCalTest.h b/Framework/DataHandling/test/LoadIsawDetCalTest.h index 8274c8d9bfefda9f08bd688a0a351af069834f58..0b4d947c3555b98ed4423f7955b646d62be82aca 100644 --- a/Framework/DataHandling/test/LoadIsawDetCalTest.h +++ b/Framework/DataHandling/test/LoadIsawDetCalTest.h @@ -48,8 +48,8 @@ void loadEmptyInstrument(const std::string &filename, class LoadIsawDetCalTest : public CxxTest::TestSuite { public: - void checkPosition(IComponent_const_sptr det, const double x, const double y, - const double z) { + void checkPosition(const IComponent_const_sptr &det, const double x, + const double y, const double z) { if (det != nullptr) { const auto detPos = det->getPos(); const V3D testPos(x, y, z); @@ -59,8 +59,8 @@ public: } } - void checkRotation(IComponent_const_sptr det, const double w, const double a, - const double b, const double c) { + void checkRotation(const IComponent_const_sptr &det, const double w, + const double a, const double b, const double c) { if (det != nullptr) { const auto detRot = det->getRotation(); const Quat testRot(w, a, b, c); diff --git a/Framework/DataHandling/test/LoadLogTest.h b/Framework/DataHandling/test/LoadLogTest.h index 6e960d5315cf5f297aecf9137d73504771148ac3..58dcad0cf3c002eb32cf94408b3a5dd05cb3e8b5 100644 --- a/Framework/DataHandling/test/LoadLogTest.h +++ b/Framework/DataHandling/test/LoadLogTest.h @@ -173,8 +173,8 @@ public: TS_ASSERT(ws->run().hasProperty("str3")); } - void do_test_SNSTextFile(std::string names, std::string units, bool willFail, - bool createWorkspace = true, + void do_test_SNSTextFile(const std::string &names, const std::string &units, + bool willFail, bool createWorkspace = true, std::string expectedLastUnit = "Furlongs") { // Create an empty workspace and put it in the AnalysisDataService diff --git a/Framework/DataHandling/test/LoadMappingTableTest.h b/Framework/DataHandling/test/LoadMappingTableTest.h index 7c1fa34fb1e8192014bbb58d3fca20a13a171d81..9459270a3e8745cfc06b3a23b3a4d008ff70235e 100644 --- a/Framework/DataHandling/test/LoadMappingTableTest.h +++ b/Framework/DataHandling/test/LoadMappingTableTest.h @@ -80,7 +80,7 @@ public: detectorgroup = work1->getSpectrum(2083).getDetectorIDs(); std::set<detid_t>::const_iterator it; int pixnum = 101191; - for (it = detectorgroup.begin(); it != detectorgroup.end(); it++) + for (it = detectorgroup.begin(); it != detectorgroup.end(); ++it) TS_ASSERT_EQUALS(*it, pixnum++); AnalysisDataService::Instance().remove(outputSpace); diff --git a/Framework/DataHandling/test/LoadMaskTest.h b/Framework/DataHandling/test/LoadMaskTest.h index e574bbcd0d301387e77d6abd0cb7697b011133ba..3dff548e4ac24aa802e25bea3c80b5a9662bb8bb 100644 --- a/Framework/DataHandling/test/LoadMaskTest.h +++ b/Framework/DataHandling/test/LoadMaskTest.h @@ -515,9 +515,9 @@ public: /* * Create a masking file */ - ScopedFileHelper::ScopedFile genMaskingFile(std::string maskfilename, + ScopedFileHelper::ScopedFile genMaskingFile(const std::string &maskfilename, std::vector<int> detids, - std::vector<int> banks) { + const std::vector<int> &banks) { std::stringstream ss; // 1. Header @@ -551,8 +551,8 @@ public: * Create an ISIS format masking file */ ScopedFileHelper::ScopedFile - genISISMaskingFile(std::string maskfilename, - std::vector<specnum_t> singlespectra, + genISISMaskingFile(const std::string &maskfilename, + const std::vector<specnum_t> &singlespectra, std::vector<specnum_t> pairspectra) { std::stringstream ss; diff --git a/Framework/DataHandling/test/LoadMcStasTest.h b/Framework/DataHandling/test/LoadMcStasTest.h index c383eed70df58f93d79b847afe4da6a40bf76d9c..986f30afe83125f7cd7fa3bcb5f7a99f6cb8b380 100644 --- a/Framework/DataHandling/test/LoadMcStasTest.h +++ b/Framework/DataHandling/test/LoadMcStasTest.h @@ -164,7 +164,7 @@ public: } private: - double extractSumAndTest(MatrixWorkspace_sptr workspace, + double extractSumAndTest(const MatrixWorkspace_sptr &workspace, const double &expectedSum) { TS_ASSERT_EQUALS(workspace->getNumberHistograms(), 8192); auto sum = 0.0; @@ -175,8 +175,8 @@ private: return sum; } - boost::shared_ptr<WorkspaceGroup> load_test(std::string fileName, - std::string outputName) { + boost::shared_ptr<WorkspaceGroup> load_test(const std::string &fileName, + const std::string &outputName) { // specify name of file to load workspace from algToBeTested.setProperty("Filename", fileName); diff --git a/Framework/DataHandling/test/LoadMuonNexus2Test.h b/Framework/DataHandling/test/LoadMuonNexus2Test.h index c3ea63efbd5f875ba9e2c0c3816fe279fef58dca..4b9c1947e22e2c3a39e9dad0ebf90d0976b3a6d5 100644 --- a/Framework/DataHandling/test/LoadMuonNexus2Test.h +++ b/Framework/DataHandling/test/LoadMuonNexus2Test.h @@ -33,7 +33,7 @@ using Mantid::Types::Core::DateAndTime; class LoadMuonNexus2Test : public CxxTest::TestSuite { public: - void check_spectra_and_detectors(MatrixWorkspace_sptr output) { + void check_spectra_and_detectors(const MatrixWorkspace_sptr &output) { //---------------------------------------------------------------------- // Tests to check that spectra-detector mapping is done correctly diff --git a/Framework/DataHandling/test/LoadNXcanSASTest.h b/Framework/DataHandling/test/LoadNXcanSASTest.h index 908c0b7b2d95c8c5566e92db1dce38a4c98037ac..033734375592a3701800865d0f057eab86112f6c 100644 --- a/Framework/DataHandling/test/LoadNXcanSASTest.h +++ b/Framework/DataHandling/test/LoadNXcanSASTest.h @@ -8,6 +8,8 @@ #include <cxxtest/TestSuite.h> +#include <utility> + #include "MantidAPI/AlgorithmManager.h" #include "MantidAPI/AnalysisDataService.h" #include "MantidAPI/Axis.h" @@ -266,7 +268,7 @@ public: } private: - void removeWorkspaceFromADS(const std::string toRemove) { + void removeWorkspaceFromADS(const std::string &toRemove) { if (AnalysisDataService::Instance().doesExist(toRemove)) { AnalysisDataService::Instance().remove(toRemove); } @@ -296,10 +298,11 @@ private: return ws; } - void save_file_no_issues(MatrixWorkspace_sptr workspace, - NXcanSASTestParameters ¶meters, - MatrixWorkspace_sptr transmission = nullptr, - MatrixWorkspace_sptr transmissionCan = nullptr) { + void + save_file_no_issues(const MatrixWorkspace_sptr &workspace, + NXcanSASTestParameters ¶meters, + const MatrixWorkspace_sptr &transmission = nullptr, + const MatrixWorkspace_sptr &transmissionCan = nullptr) { auto saveAlg = AlgorithmManager::Instance().createUnmanaged("SaveNXcanSAS"); saveAlg->initialize(); saveAlg->setProperty("Filename", parameters.filename); @@ -342,7 +345,8 @@ private: } } - void do_assert_units(MatrixWorkspace_sptr wsIn, MatrixWorkspace_sptr wsOut) { + void do_assert_units(const MatrixWorkspace_sptr &wsIn, + const MatrixWorkspace_sptr &wsOut) { // Ensure that units of axis 0 are matching auto unit0In = wsIn->getAxis(0)->unit()->label().ascii(); auto unit0Out = wsOut->getAxis(0)->unit()->label().ascii(); @@ -361,8 +365,8 @@ private: TSM_ASSERT_EQUALS("Should have the same y unit", unitYIn, unitYOut); } - void do_assert_axis1_values_are_the_same(MatrixWorkspace_sptr wsIn, - MatrixWorkspace_sptr wsOut) { + void do_assert_axis1_values_are_the_same(const MatrixWorkspace_sptr &wsIn, + const MatrixWorkspace_sptr &wsOut) { if (!wsOut->getAxis(1)->isNumeric()) { return; } @@ -391,8 +395,8 @@ private: } } - void do_assert_sample_logs(MatrixWorkspace_sptr wsIn, - MatrixWorkspace_sptr wsOut) { + void do_assert_sample_logs(const MatrixWorkspace_sptr &wsIn, + const MatrixWorkspace_sptr &wsOut) { auto &runIn = wsIn->mutableRun(); auto &runOut = wsOut->mutableRun(); @@ -413,16 +417,17 @@ private: } } - void do_assert_instrument(MatrixWorkspace_sptr wsIn, - MatrixWorkspace_sptr wsOut) { - auto idfIn = getIDFfromWorkspace(wsIn); - auto idfOut = getIDFfromWorkspace(wsOut); + void do_assert_instrument(const MatrixWorkspace_sptr &wsIn, + const MatrixWorkspace_sptr &wsOut) { + auto idfIn = getIDFfromWorkspace(std::move(wsIn)); + auto idfOut = getIDFfromWorkspace(std::move(wsOut)); TSM_ASSERT_EQUALS("Should have the same instrument", idfIn, idfOut); } - void do_assert_transmission(MatrixWorkspace_sptr mainWorkspace, - MatrixWorkspace_sptr transIn, - NXcanSASTestTransmissionParameters parameters) { + void + do_assert_transmission(const MatrixWorkspace_sptr &mainWorkspace, + const MatrixWorkspace_sptr &transIn, + const NXcanSASTestTransmissionParameters ¶meters) { if (!parameters.usesTransmission || !transIn) { return; } @@ -435,32 +440,34 @@ private: AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>(transName); // Ensure that both have the same Y data - auto readDataY = [](MatrixWorkspace_sptr ws, size_t index) { + auto readDataY = [](const MatrixWorkspace_sptr &ws, size_t index) { return ws->y(index); }; do_assert_data(transIn, transOut, readDataY); // Ensure that both have the same E data - auto readDataE = [](MatrixWorkspace_sptr ws, size_t index) { + auto readDataE = [](const MatrixWorkspace_sptr &ws, size_t index) { return ws->e(index); }; do_assert_data(transIn, transOut, readDataE); // Ensure that both have the same X data - auto readDataX = [](MatrixWorkspace_sptr ws, size_t index) { + auto readDataX = [](const MatrixWorkspace_sptr &ws, size_t index) { return ws->x(index); }; do_assert_data(transIn, transOut, readDataX); } - void do_assert_load(MatrixWorkspace_sptr wsIn, MatrixWorkspace_sptr wsOut, - NXcanSASTestParameters ¶meters, - MatrixWorkspace_sptr transmission = nullptr, - MatrixWorkspace_sptr transmissionCan = nullptr, - NXcanSASTestTransmissionParameters sampleParameters = - NXcanSASTestTransmissionParameters(), - NXcanSASTestTransmissionParameters canParameters = - NXcanSASTestTransmissionParameters()) { + void + do_assert_load(const MatrixWorkspace_sptr &wsIn, + const MatrixWorkspace_sptr &wsOut, + NXcanSASTestParameters ¶meters, + const MatrixWorkspace_sptr &transmission = nullptr, + const MatrixWorkspace_sptr &transmissionCan = nullptr, + const NXcanSASTestTransmissionParameters &sampleParameters = + NXcanSASTestTransmissionParameters(), + const NXcanSASTestTransmissionParameters &canParameters = + NXcanSASTestTransmissionParameters()) { // Ensure that both have the same units do_assert_units(wsIn, wsOut); @@ -468,26 +475,26 @@ private: TSM_ASSERT("Should be a point workspace", !wsOut->isHistogramData()); // Ensure that both have the same Y data - auto readDataY = [](MatrixWorkspace_sptr ws, size_t index) { + auto readDataY = [](const MatrixWorkspace_sptr &ws, size_t index) { return ws->y(index); }; do_assert_data(wsIn, wsOut, readDataY); // Ensure that both have the same E data - auto readDataE = [](MatrixWorkspace_sptr ws, size_t index) { + auto readDataE = [](const MatrixWorkspace_sptr &ws, size_t index) { return ws->e(index); }; do_assert_data(wsIn, wsOut, readDataE); // Ensure that both have the same X data - auto readDataX = [](MatrixWorkspace_sptr ws, size_t index) { + auto readDataX = [](const MatrixWorkspace_sptr &ws, size_t index) { return ws->x(index); }; do_assert_data(wsIn, wsOut, readDataX); // If applicable, ensure that both have the same Xdev data if (parameters.hasDx) { - auto readDataDX = [](MatrixWorkspace_sptr ws, size_t index) { + auto readDataDX = [](const MatrixWorkspace_sptr &ws, size_t index) { return ws->dataDx(index); }; do_assert_data(wsIn, wsOut, readDataDX); @@ -503,8 +510,10 @@ private: do_assert_instrument(wsIn, wsOut); // Test transmission workspaces - do_assert_transmission(wsOut, transmission, sampleParameters); - do_assert_transmission(wsOut, transmissionCan, canParameters); + do_assert_transmission(wsOut, std::move(transmission), + std::move(sampleParameters)); + do_assert_transmission(wsOut, std::move(transmissionCan), + std::move(canParameters)); } }; @@ -537,7 +546,7 @@ private: NXcanSASTestParameters parameters1D; NXcanSASTestParameters parameters2D; - void save_no_assert(MatrixWorkspace_sptr ws, + void save_no_assert(const MatrixWorkspace_sptr &ws, NXcanSASTestParameters ¶meters) { auto saveAlg = AlgorithmManager::Instance().createUnmanaged("SaveNXcanSAS"); saveAlg->initialize(); diff --git a/Framework/DataHandling/test/LoadNexusLogsTest.h b/Framework/DataHandling/test/LoadNexusLogsTest.h index 579a1a79d202a533323a31565fe6c6090b22afd3..85aa8487e0ed19f07443919a42b354249279e6fd 100644 --- a/Framework/DataHandling/test/LoadNexusLogsTest.h +++ b/Framework/DataHandling/test/LoadNexusLogsTest.h @@ -272,7 +272,6 @@ public: void test_last_time_series_log_entry_equals_end_time() { LoadNexusLogs ld; - std::string outws_name = "REF_L_instrument"; ld.initialize(); ld.setPropertyValue("Filename", "REF_L_32035.nxs"); MatrixWorkspace_sptr ws = createTestWorkspace(); diff --git a/Framework/DataHandling/test/LoadNexusProcessed2Test.h b/Framework/DataHandling/test/LoadNexusProcessed2Test.h index 3ece0dffb833afdea8634199e15a8a13481f720e..b63a4ed5c8a937597c901153cf827508f57bfbeb 100644 --- a/Framework/DataHandling/test/LoadNexusProcessed2Test.h +++ b/Framework/DataHandling/test/LoadNexusProcessed2Test.h @@ -52,7 +52,7 @@ Mantid::API::MatrixWorkspace_sptr do_load_v1(const std::string &filename) { } namespace test_utility { -template <typename T> void save(const std::string filename, T &ws) { +template <typename T> void save(const std::string &filename, T &ws) { SaveNexusESS alg; alg.setChild(true); alg.setRethrows(true); diff --git a/Framework/DataHandling/test/LoadNexusProcessedTest.h b/Framework/DataHandling/test/LoadNexusProcessedTest.h index 4a1d3d41dd15f7d10f27ff5c34e2bad69032c9d2..f501fc6c6639c50127dae9f2d713d1fa8c4d1d73 100644 --- a/Framework/DataHandling/test/LoadNexusProcessedTest.h +++ b/Framework/DataHandling/test/LoadNexusProcessedTest.h @@ -1110,7 +1110,7 @@ public: } private: - void doHistoryTest(MatrixWorkspace_sptr matrix_ws) { + void doHistoryTest(const MatrixWorkspace_sptr &matrix_ws) { const WorkspaceHistory history = matrix_ws->getHistory(); int nalgs = static_cast<int>(history.size()); TS_ASSERT_EQUALS(nalgs, 4); @@ -1201,7 +1201,7 @@ private: * be present */ void doSpectrumListTests(LoadNexusProcessed &alg, - const std::vector<int> expectedSpectra) { + const std::vector<int> &expectedSpectra) { TS_ASSERT_THROWS_NOTHING(alg.execute()); TS_ASSERT(alg.isExecuted()); diff --git a/Framework/DataHandling/test/LoadPLNTest.h b/Framework/DataHandling/test/LoadPLNTest.h index ed193864a0754e4a465d4589ff5f22732a461668..80d8d067d5464e7a0d863df5fad343649d24d20c 100644 --- a/Framework/DataHandling/test/LoadPLNTest.h +++ b/Framework/DataHandling/test/LoadPLNTest.h @@ -74,7 +74,7 @@ public: run.getProperty("end_time")->value().find("2018-11-12T11:45:06.6") == 0) // test some data properties - auto logpm = [&run](std::string tag) { + auto logpm = [&run](const std::string &tag) { return dynamic_cast<TimeSeriesProperty<double> *>(run.getProperty(tag)) ->firstValue(); }; @@ -129,7 +129,7 @@ public: run.getProperty("end_time")->value().find("2018-11-12T11:45:06.6") == 0) // test some data properties - auto logpm = [&run](std::string tag) { + auto logpm = [&run](const std::string &tag) { return dynamic_cast<TimeSeriesProperty<double> *>(run.getProperty(tag)) ->firstValue(); }; diff --git a/Framework/DataHandling/test/LoadRaw3Test.h b/Framework/DataHandling/test/LoadRaw3Test.h index 9038d686ebadccc817cdc188b76c84cb1b298070..19f298d7286d2601c15d6c37b854f92a88b385bb 100644 --- a/Framework/DataHandling/test/LoadRaw3Test.h +++ b/Framework/DataHandling/test/LoadRaw3Test.h @@ -153,7 +153,7 @@ public: detectorgroup = output2D->getSpectrum(2083).getDetectorIDs(); std::set<detid_t>::const_iterator it; int pixnum = 101191; - for (it = detectorgroup.begin(); it != detectorgroup.end(); it++) + for (it = detectorgroup.begin(); it != detectorgroup.end(); ++it) TS_ASSERT_EQUALS(*it, pixnum++); AnalysisDataService::Instance().remove(outputSpace); @@ -375,7 +375,7 @@ public: wsNamevec = sptrWSGrp->getNames(); int period = 1; std::vector<std::string>::const_iterator it = wsNamevec.begin(); - for (; it != wsNamevec.end(); it++) { + for (; it != wsNamevec.end(); ++it) { std::stringstream count; count << period; std::string wsName = "multiperiod_" + count.str(); @@ -385,7 +385,7 @@ public: std::vector<std::string>::const_iterator itr1 = wsNamevec.begin(); int periodNumber = 0; const int nHistograms = 4; - for (; itr1 != wsNamevec.end(); itr1++) { + for (; itr1 != wsNamevec.end(); ++itr1) { MatrixWorkspace_sptr outsptr; TS_ASSERT_THROWS_NOTHING( outsptr = AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>( @@ -581,7 +581,7 @@ public: detectorgroup = output2D->getSpectrum(2079).getDetectorIDs(); std::set<detid_t>::const_iterator it; int pixnum = 101191; - for (it = detectorgroup.begin(); it != detectorgroup.end(); it++) + for (it = detectorgroup.begin(); it != detectorgroup.end(); ++it) TS_ASSERT_EQUALS(*it, pixnum++); // Test if filename log is found in both monitor and sata workspace @@ -626,7 +626,7 @@ public: monitorsptrWSGrp->getNames(); int period = 1; std::vector<std::string>::const_iterator it = monitorwsNamevec.begin(); - for (; it != monitorwsNamevec.end(); it++) { + for (; it != monitorwsNamevec.end(); ++it) { std::stringstream count; count << period; std::string wsName = "multiperiod_monitors_" + count.str(); @@ -634,7 +634,7 @@ public: period++; } std::vector<std::string>::const_iterator itr1 = monitorwsNamevec.begin(); - for (; itr1 != monitorwsNamevec.end(); itr1++) { + for (; itr1 != monitorwsNamevec.end(); ++itr1) { MatrixWorkspace_sptr outsptr; TS_ASSERT_THROWS_NOTHING( outsptr = AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>( @@ -674,7 +674,7 @@ public: const std::vector<std::string> wsNamevec = sptrWSGrp->getNames(); period = 1; it = wsNamevec.begin(); - for (; it != wsNamevec.end(); it++) { + for (; it != wsNamevec.end(); ++it) { std::stringstream count; count << period; std::string wsName = "multiperiod_" + count.str(); @@ -684,7 +684,7 @@ public: itr1 = wsNamevec.begin(); int periodNumber = 0; const int nHistograms = 2; - for (; itr1 != wsNamevec.end(); itr1++) { + for (; itr1 != wsNamevec.end(); ++itr1) { MatrixWorkspace_sptr outsptr; TS_ASSERT_THROWS_NOTHING( outsptr = AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>( @@ -1151,7 +1151,7 @@ public: private: /// Helper method to run common set of tests on a workspace in a multi-period /// group. - void doTestMultiPeriodWorkspace(MatrixWorkspace_sptr workspace, + void doTestMultiPeriodWorkspace(const MatrixWorkspace_sptr &workspace, const size_t &nHistograms, int expected_period) { // Check the number of histograms. @@ -1173,8 +1173,8 @@ private: } /// Check that two matrix workspaces match - std::string checkWorkspacesMatch(Workspace_sptr workspace1, - Workspace_sptr workspace2) { + std::string checkWorkspacesMatch(const Workspace_sptr &workspace1, + const Workspace_sptr &workspace2) { auto ws1 = boost::dynamic_pointer_cast<MatrixWorkspace>(workspace1); auto ws2 = boost::dynamic_pointer_cast<MatrixWorkspace>(workspace2); if (!ws1 || !ws2) { diff --git a/Framework/DataHandling/test/LoadRawBin0Test.h b/Framework/DataHandling/test/LoadRawBin0Test.h index 82884027b2e1da2778ce1b308765f65daeeb0e61..b1c314f1c7aacf32c87eeedb8302d56e5425d2a8 100644 --- a/Framework/DataHandling/test/LoadRawBin0Test.h +++ b/Framework/DataHandling/test/LoadRawBin0Test.h @@ -108,7 +108,7 @@ public: wsNamevec = sptrWSGrp->getNames(); int period = 1; std::vector<std::string>::const_iterator it = wsNamevec.begin(); - for (; it != wsNamevec.end(); it++) { + for (; it != wsNamevec.end(); ++it) { std::stringstream count; count << period; std::string wsName = "multiperiod_" + count.str(); @@ -118,7 +118,7 @@ public: std::vector<std::string>::const_iterator itr1 = wsNamevec.begin(); int periodNumber = 0; const int nHistograms = 4; - for (; itr1 != wsNamevec.end(); itr1++) { + for (; itr1 != wsNamevec.end(); ++itr1) { MatrixWorkspace_sptr outsptr; TS_ASSERT_THROWS_NOTHING( outsptr = AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>( @@ -149,7 +149,7 @@ public: private: /// Helper method to run common set of tests on a workspace in a multi-period /// group. - void doTestMultiPeriodWorkspace(MatrixWorkspace_sptr workspace, + void doTestMultiPeriodWorkspace(const MatrixWorkspace_sptr &workspace, const size_t &nHistograms, int expected_period) { // Check the number of histograms. diff --git a/Framework/DataHandling/test/LoadRawSaveNxsLoadNxsTest.h b/Framework/DataHandling/test/LoadRawSaveNxsLoadNxsTest.h index 101fc484ffa9f4c965e946c0043893d2098d3c6a..7af33edb978501176d9265d130fa18bb3d3b0302 100644 --- a/Framework/DataHandling/test/LoadRawSaveNxsLoadNxsTest.h +++ b/Framework/DataHandling/test/LoadRawSaveNxsLoadNxsTest.h @@ -72,7 +72,6 @@ public: // specify name of file to save workspace to outputFile = "testSaveLoadrawCSP.nxs"; remove(outputFile.c_str()); - std::string dataName = "spectra"; std::string title = "Workspace from Loadraw CSP78173"; saveNexusP.setPropertyValue("FileName", outputFile); outputFile = saveNexusP.getPropertyValue("Filename"); diff --git a/Framework/DataHandling/test/LoadRawSpectrum0Test.h b/Framework/DataHandling/test/LoadRawSpectrum0Test.h index 51bee7ca53f1662189004e0d7afdfa48cac367ab..96a7f376aa8c278c2d8adf6c7e1e3062d381fd90 100644 --- a/Framework/DataHandling/test/LoadRawSpectrum0Test.h +++ b/Framework/DataHandling/test/LoadRawSpectrum0Test.h @@ -110,7 +110,7 @@ public: wsNamevec = sptrWSGrp->getNames(); int period = 1; std::vector<std::string>::const_iterator it = wsNamevec.begin(); - for (; it != wsNamevec.end(); it++) { + for (; it != wsNamevec.end(); ++it) { std::stringstream count; count << period; std::string wsName = "multiperiod_" + count.str(); @@ -119,7 +119,7 @@ public: } std::vector<std::string>::const_iterator itr1 = wsNamevec.begin(); int expectedPeriod = 0; - for (; itr1 != wsNamevec.end(); itr1++) { + for (; itr1 != wsNamevec.end(); ++itr1) { MatrixWorkspace_sptr outsptr; TS_ASSERT_THROWS_NOTHING( outsptr = AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>( @@ -146,7 +146,7 @@ public: private: /// Helper method to run common set of tests on a workspace in a multi-period /// group. - void doTestMultiPeriodWorkspace(MatrixWorkspace_sptr workspace, + void doTestMultiPeriodWorkspace(const MatrixWorkspace_sptr &workspace, int expected_period) { // Check the current period property. const Mantid::API::Run &run = workspace->run(); diff --git a/Framework/DataHandling/test/LoadSampleShapeTest.h b/Framework/DataHandling/test/LoadSampleShapeTest.h index 8481575cf209f81f5ccc689236cb6a8a46cdabe9..62b10eaac5e0c7cadfe15bfee5d30b09a3dc3e5d 100644 --- a/Framework/DataHandling/test/LoadSampleShapeTest.h +++ b/Framework/DataHandling/test/LoadSampleShapeTest.h @@ -217,7 +217,7 @@ private: const MeshObject *loadMeshObject(LoadSampleShape &alg, bool outputWsSameAsInputWs, - const std::string filename) { + const std::string &filename) { alg.initialize(); alg.setPropertyValue("Filename", filename); prepareWorkspaces(alg, outputWsSameAsInputWs); @@ -226,7 +226,7 @@ private: return getMeshObject(alg); } - void loadFailureTest(LoadSampleShape &alg, const std::string filename) { + void loadFailureTest(LoadSampleShape &alg, const std::string &filename) { alg.initialize(); alg.setPropertyValue("Filename", filename); prepareWorkspaces(alg, true); @@ -276,7 +276,7 @@ private: std::unique_ptr<LoadSampleShape> alg; const int numberOfIterations = 5; - std::unique_ptr<LoadSampleShape> setupAlg(Workspace2D_sptr inputWS) { + std::unique_ptr<LoadSampleShape> setupAlg(const Workspace2D_sptr &inputWS) { auto loadAlg = std::make_unique<LoadSampleShape>(); loadAlg->initialize(); loadAlg->setChild(true); diff --git a/Framework/DataHandling/test/LoadSpice2dTest.h b/Framework/DataHandling/test/LoadSpice2dTest.h index 53d177e394c0ea58c0df6b71a611c8a022878a74..3f44d326e21df75d7b134475c5b5452cd3e88235 100644 --- a/Framework/DataHandling/test/LoadSpice2dTest.h +++ b/Framework/DataHandling/test/LoadSpice2dTest.h @@ -222,7 +222,8 @@ public: TS_ASSERT_DELTA(ws2d->x(192 + nmon)[0], 4.5, tolerance); } - void assertDetectorDistances(Mantid::DataObjects::Workspace2D_sptr ws2d) { + void + assertDetectorDistances(const Mantid::DataObjects::Workspace2D_sptr &ws2d) { Mantid::Kernel::Property *prop = ws2d->run().getProperty("sample-detector-distance"); Mantid::Kernel::PropertyWithValue<double> *sdd = diff --git a/Framework/DataHandling/test/MaskDetectorsInShapeTest.h b/Framework/DataHandling/test/MaskDetectorsInShapeTest.h index d2227555c13db7ec5a09c6c79176b0e323411318..c675b30f5b874ce8dccf40e107baf6dd619663f2 100644 --- a/Framework/DataHandling/test/MaskDetectorsInShapeTest.h +++ b/Framework/DataHandling/test/MaskDetectorsInShapeTest.h @@ -8,6 +8,8 @@ #include <cxxtest/TestSuite.h> +#include <utility> + #include "MantidAPI/AnalysisDataService.h" #include "MantidAPI/FrameworkManager.h" #include "MantidDataHandling/LoadEmptyInstrument.h" @@ -59,7 +61,7 @@ public: runTest(xmlShape, "320,340,360,380", false); } - void runTest(std::string xmlShape, std::string expectedHits, + void runTest(const std::string &xmlShape, std::string expectedHits, bool includeMonitors = true) { using namespace Mantid::API; @@ -80,21 +82,21 @@ public: MatrixWorkspace_const_sptr outWS = AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>(wsName); - checkDeadDetectors(outWS, expectedHits); + checkDeadDetectors(outWS, std::move(expectedHits)); } - void checkDeadDetectors(Mantid::API::MatrixWorkspace_const_sptr outWS, - std::string expectedHits) { + void checkDeadDetectors(const Mantid::API::MatrixWorkspace_const_sptr &outWS, + const std::string &expectedHits) { // check that the detectors have actually been marked dead std::vector<int> expectedDetectorArray = - convertStringToVector(expectedHits); + convertStringToVector(std::move(expectedHits)); const auto &detectorInfo = outWS->detectorInfo(); for (const auto detID : expectedDetectorArray) { TS_ASSERT(detectorInfo.isMasked(detectorInfo.indexOf(detID))); } } - std::vector<int> convertStringToVector(const std::string input) { + std::vector<int> convertStringToVector(const std::string &input) { Mantid::Kernel::ArrayProperty<int> arrayProp("name", input); return arrayProp(); } diff --git a/Framework/DataHandling/test/MaskDetectorsTest.h b/Framework/DataHandling/test/MaskDetectorsTest.h index 826fefab82959e6af67d138cfe4a739d95e3fa68..747f7e786ad4ab4ce7bf82ba074404283aba0d93 100644 --- a/Framework/DataHandling/test/MaskDetectorsTest.h +++ b/Framework/DataHandling/test/MaskDetectorsTest.h @@ -649,9 +649,9 @@ public: void test_MaskWithWorkspaceWithDetectorIDs() { auto &ads = AnalysisDataService::Instance(); - const std::string inputWSName("inputWS"), existingMaskName("existingMask"); const int numInputSpec(90); + const std::string inputWSName("inputWS"); setUpWS(false, inputWSName, false, numInputSpec); auto inputWS = ads.retrieveWS<MatrixWorkspace>(inputWSName); @@ -717,7 +717,7 @@ public: void test_MaskWithWorkspaceWithDetectorIDsAndWsIndexRange() { auto &ads = AnalysisDataService::Instance(); - const std::string inputWSName("inputWS"), existingMaskName("existingMask"); + const std::string inputWSName("inputWS"); const int numInputSpec(90); setUpWS(false, inputWSName, false, numInputSpec); diff --git a/Framework/DataHandling/test/MaskSpectraTest.h b/Framework/DataHandling/test/MaskSpectraTest.h index 92d3d7ce3be8d92630fdf4f634f067f17bf8c42c..3fb4c93b10e2c4ab8671f97a37ed15075e55799d 100644 --- a/Framework/DataHandling/test/MaskSpectraTest.h +++ b/Framework/DataHandling/test/MaskSpectraTest.h @@ -47,7 +47,7 @@ void checkWorkspace(const MatrixWorkspace &ws) { TS_ASSERT_EQUALS(ws.e(3)[0], 0.0); } -MatrixWorkspace_sptr runMaskSpectra(MatrixWorkspace_sptr inputWS) { +MatrixWorkspace_sptr runMaskSpectra(const MatrixWorkspace_sptr &inputWS) { MaskSpectra alg; alg.setChild(true); alg.initialize(); diff --git a/Framework/DataHandling/test/NXcanSASTestHelper.cpp b/Framework/DataHandling/test/NXcanSASTestHelper.cpp index 6504a1ae60f3cc6e088850ca9aa42930d4593314..a1a2381f0f47e6be2e550681a35cf3dbed3085ba 100644 --- a/Framework/DataHandling/test/NXcanSASTestHelper.cpp +++ b/Framework/DataHandling/test/NXcanSASTestHelper.cpp @@ -18,7 +18,8 @@ namespace NXcanSASTestHelper { -std::string concatenateStringVector(std::vector<std::string> stringVector) { +std::string +concatenateStringVector(const std::vector<std::string> &stringVector) { std::ostringstream os; for (auto &element : stringVector) { os << element; @@ -28,7 +29,8 @@ std::string concatenateStringVector(std::vector<std::string> stringVector) { return os.str(); } -std::string getIDFfromWorkspace(Mantid::API::MatrixWorkspace_sptr workspace) { +std::string +getIDFfromWorkspace(const Mantid::API::MatrixWorkspace_sptr &workspace) { auto instrument = workspace->getInstrument(); auto name = instrument->getFullName(); auto date = workspace->getWorkspaceStartDate(); @@ -36,7 +38,8 @@ std::string getIDFfromWorkspace(Mantid::API::MatrixWorkspace_sptr workspace) { } void setXValuesOn1DWorkspaceWithPointData( - Mantid::API::MatrixWorkspace_sptr workspace, double xmin, double xmax) { + const Mantid::API::MatrixWorkspace_sptr &workspace, double xmin, + double xmax) { auto &xValues = workspace->dataX(0); auto size = xValues.size(); double binWidth = (xmax - xmin) / static_cast<double>(size - 1); @@ -46,7 +49,7 @@ void setXValuesOn1DWorkspaceWithPointData( } } -void add_sample_log(Mantid::API::MatrixWorkspace_sptr workspace, +void add_sample_log(const Mantid::API::MatrixWorkspace_sptr &workspace, const std::string &logName, const std::string &logValue) { auto logAlg = Mantid::API::AlgorithmManager::Instance().createUnmanaged("AddSampleLog"); @@ -58,7 +61,7 @@ void add_sample_log(Mantid::API::MatrixWorkspace_sptr workspace, logAlg->execute(); } -void set_logs(Mantid::API::MatrixWorkspace_sptr workspace, +void set_logs(const Mantid::API::MatrixWorkspace_sptr &workspace, const std::string &runNumber, const std::string &userFile) { if (!runNumber.empty()) { add_sample_log(workspace, "run_number", runNumber); @@ -69,7 +72,7 @@ void set_logs(Mantid::API::MatrixWorkspace_sptr workspace, } } -void set_instrument(Mantid::API::MatrixWorkspace_sptr workspace, +void set_instrument(const Mantid::API::MatrixWorkspace_sptr &workspace, const std::string &instrumentName) { auto instAlg = Mantid::API::AlgorithmManager::Instance().createUnmanaged( "LoadInstrument"); @@ -205,7 +208,7 @@ provide2DWorkspace(NXcanSASTestParameters ¶meters) { return ws; } -void set2DValues(Mantid::API::MatrixWorkspace_sptr ws) { +void set2DValues(const Mantid::API::MatrixWorkspace_sptr &ws) { const auto numberOfHistograms = ws->getNumberHistograms(); for (size_t index = 0; index < numberOfHistograms; ++index) { @@ -214,7 +217,7 @@ void set2DValues(Mantid::API::MatrixWorkspace_sptr ws) { } } -void removeFile(std::string filename) { +void removeFile(const std::string &filename) { if (Poco::File(filename).exists()) Poco::File(filename).remove(); } diff --git a/Framework/DataHandling/test/NXcanSASTestHelper.h b/Framework/DataHandling/test/NXcanSASTestHelper.h index 1d8ec808ea9ee2d811cddfaf30b3aa89af02884b..aec86f5708d92f56494687531d4a9db492c41339 100644 --- a/Framework/DataHandling/test/NXcanSASTestHelper.h +++ b/Framework/DataHandling/test/NXcanSASTestHelper.h @@ -92,20 +92,23 @@ struct NXcanSASTestTransmissionParameters { bool usesTransmission; }; -std::string concatenateStringVector(std::vector<std::string> stringVector); +std::string +concatenateStringVector(const std::vector<std::string> &stringVector); -std::string getIDFfromWorkspace(Mantid::API::MatrixWorkspace_sptr workspace); +std::string +getIDFfromWorkspace(const Mantid::API::MatrixWorkspace_sptr &workspace); void setXValuesOn1DWorkspaceWithPointData( - Mantid::API::MatrixWorkspace_sptr workspace, double xmin, double xmax); + const Mantid::API::MatrixWorkspace_sptr &workspace, double xmin, + double xmax); -void add_sample_log(Mantid::API::MatrixWorkspace_sptr workspace, +void add_sample_log(const Mantid::API::MatrixWorkspace_sptr &workspace, const std::string &logName, const std::string &logValue); -void set_logs(Mantid::API::MatrixWorkspace_sptr workspace, +void set_logs(const Mantid::API::MatrixWorkspace_sptr &workspace, const std::string &runNumber, const std::string &userFile); -void set_instrument(Mantid::API::MatrixWorkspace_sptr workspace, +void set_instrument(const Mantid::API::MatrixWorkspace_sptr &workspace, const std::string &instrumentName); Mantid::API::MatrixWorkspace_sptr @@ -117,7 +120,7 @@ getTransmissionWorkspace(NXcanSASTestTransmissionParameters ¶meters); Mantid::API::MatrixWorkspace_sptr provide2DWorkspace(NXcanSASTestParameters ¶meters); -void set2DValues(Mantid::API::MatrixWorkspace_sptr ws); +void set2DValues(const Mantid::API::MatrixWorkspace_sptr &ws); -void removeFile(std::string filename); +void removeFile(const std::string &filename); } // namespace NXcanSASTestHelper \ No newline at end of file diff --git a/Framework/DataHandling/test/RenameLogTest.h b/Framework/DataHandling/test/RenameLogTest.h index 66913b9a2371cb2ec552edae83ec1293a3fe7e58..013170d6a27e6ae24312e6c0db7227ed7f1c797b 100644 --- a/Framework/DataHandling/test/RenameLogTest.h +++ b/Framework/DataHandling/test/RenameLogTest.h @@ -124,8 +124,8 @@ private: return testWS; } - void verifyLog(API::MatrixWorkspace_sptr resultWS, - const std::string logName) { + void verifyLog(const API::MatrixWorkspace_sptr &resultWS, + const std::string &logName) { Kernel::TimeSeriesProperty<double> *rp; TS_ASSERT_THROWS_NOTHING( rp = dynamic_cast<Kernel::TimeSeriesProperty<double> *>( diff --git a/Framework/DataHandling/test/SaveAscii2Test.h b/Framework/DataHandling/test/SaveAscii2Test.h index a13dba15dc31e09688656460bfef1cdfb81bccb5..d9f1c18952fa87ca84964ff883952d9bf2d615d5 100644 --- a/Framework/DataHandling/test/SaveAscii2Test.h +++ b/Framework/DataHandling/test/SaveAscii2Test.h @@ -114,7 +114,7 @@ public: } AnalysisDataService::Instance().add(m_name, wsToSave); SaveAscii2 save; - std::string filename = initSaveAscii2(save); + initSaveAscii2(save); TS_ASSERT_THROWS_NOTHING(save.setPropertyValue("WriteXError", "1")); TS_ASSERT_THROWS_ANYTHING(save.execute()); AnalysisDataService::Instance().remove(m_name); @@ -530,7 +530,7 @@ public: writeSampleWS(wsToSave, false); SaveAscii2 save; - std::string filename = initSaveAscii2(save); + initSaveAscii2(save); TS_ASSERT_THROWS_NOTHING( save.setProperty("SpectrumMetaData", "SpectrumNumber")); @@ -836,7 +836,7 @@ public: writeSampleWS(wsToSave); SaveAscii2 save; - std::string filename = initSaveAscii2(save); + initSaveAscii2(save); TS_ASSERT_THROWS_NOTHING( save.setPropertyValue("SpectrumMetaData", "NotAValidChoice")); diff --git a/Framework/DataHandling/test/SaveBankScatteringAnglesTest.h b/Framework/DataHandling/test/SaveBankScatteringAnglesTest.h index 45e667a4933e129be9f0dc8f22e59e7abc2dc5bb..ab924856da4df1c1aa5826f1d67ae087ed8a389a 100644 --- a/Framework/DataHandling/test/SaveBankScatteringAnglesTest.h +++ b/Framework/DataHandling/test/SaveBankScatteringAnglesTest.h @@ -62,9 +62,9 @@ public: std::ifstream file(tempFileName); std::string line; - int numLines = 0; if (file.is_open()) { + int numLines = 0; while (std::getline(file, line)) { numLines++; } diff --git a/Framework/DataHandling/test/SaveCSVTest.h b/Framework/DataHandling/test/SaveCSVTest.h index 894dca2524c11282984c9fcde8bfa59a40169e83..21c841e809974d36e6b9527411f1dc7f3cd5fb7e 100644 --- a/Framework/DataHandling/test/SaveCSVTest.h +++ b/Framework/DataHandling/test/SaveCSVTest.h @@ -169,7 +169,8 @@ private: Poco::File(fileName).remove(); } - void evaluateFileWithDX(std::string fileName, const size_t nSpec) const { + void evaluateFileWithDX(const std::string &fileName, + const size_t nSpec) const { std::ifstream stream(fileName.c_str()); std::istringstream dataStream; std::string line; diff --git a/Framework/DataHandling/test/SaveCalFileTest.h b/Framework/DataHandling/test/SaveCalFileTest.h index c00ec9eb1604624f1d97cc86ada45e06c5c569d5..d8ffb94aec8834a46a081466e5adeba6b079e1b5 100644 --- a/Framework/DataHandling/test/SaveCalFileTest.h +++ b/Framework/DataHandling/test/SaveCalFileTest.h @@ -51,9 +51,6 @@ public: maskWS->getSpectrum(0).clearData(); maskWS->mutableSpectrumInfo().setMasked(0, true); - // Name of the output workspace. - std::string outWSName("SaveCalFileTest_OutputWS"); - SaveCalFile alg; TS_ASSERT_THROWS_NOTHING(alg.initialize()) TS_ASSERT(alg.isInitialized()) diff --git a/Framework/DataHandling/test/SaveFullprofResolutionTest.h b/Framework/DataHandling/test/SaveFullprofResolutionTest.h index 15d97bff2199743a10b80bd1cba85ab4d4e05448..8b088df4b745ee8d900aa7c0cd3457c3184ac9ad 100644 --- a/Framework/DataHandling/test/SaveFullprofResolutionTest.h +++ b/Framework/DataHandling/test/SaveFullprofResolutionTest.h @@ -184,7 +184,7 @@ public: //---------------------------------------------------------------------------------------------- /** Find out number of lines in a text file */ - int getFileLines(std::string filename) { + int getFileLines(const std::string &filename) { ifstream infile; infile.open(filename.c_str()); @@ -206,7 +206,7 @@ public: /** Write out a TableWorkspace contain 2 banks' parameters * ISIS HRPD Data */ - void create2BankProf9Table(string workspacename) { + void create2BankProf9Table(const string &workspacename) { TableWorkspace_sptr partablews = boost::make_shared<TableWorkspace>(); partablews->addColumn("str", "Name"); partablews->addColumn("double", "Value_1"); @@ -261,7 +261,7 @@ public: * 10 * Source data is from POWGEN's bank 1 calibrated */ - void createProfile10TableWS(std::string wsname) { + void createProfile10TableWS(const std::string &wsname) { // Create a map of string/double for parameters of profile 10 std::map<std::string, double> parammap{ {"BANK", 1.}, {"Alph0", 1.88187}, {"Alph0t", 64.4102}, diff --git a/Framework/DataHandling/test/SaveGSASInstrumentFileTest.h b/Framework/DataHandling/test/SaveGSASInstrumentFileTest.h index 02ba90e4e9eb4a2e32480dbdf12af3e06e95adaf..641319f16a8906c980d4a8dab1df33863ba0040d 100644 --- a/Framework/DataHandling/test/SaveGSASInstrumentFileTest.h +++ b/Framework/DataHandling/test/SaveGSASInstrumentFileTest.h @@ -186,7 +186,7 @@ public: //---------------------------------------------------------------------------------------------- /** Load table workspace containing instrument parameters */ - void loadProfileTable(string wsname) { + void loadProfileTable(const string &wsname) { // The data befow is from Bank1 in pg60_2011B.irf auto tablews = boost::make_shared<TableWorkspace>(); @@ -266,7 +266,7 @@ public: //---------------------------------------------------------------------------------------------- /** Generate a 3 bank .irf file */ - void generate3BankIrfFile(string filename) { + void generate3BankIrfFile(const string &filename) { ofstream ofile; ofile.open(filename.c_str()); @@ -457,7 +457,8 @@ public: } // Compare 2 files - bool compare2Files(std::string filename1, std::string filename2) { + bool compare2Files(const std::string &filename1, + const std::string &filename2) { ifstream file1(filename1.c_str(), std::ifstream::in); ifstream file2(filename2.c_str(), std::ifstream::in); @@ -496,7 +497,6 @@ public: while (!file2.eof()) { getline(file2, str); - c2++; } // Reset file stream pointer diff --git a/Framework/DataHandling/test/SaveILLCosmosAsciiTest.h b/Framework/DataHandling/test/SaveILLCosmosAsciiTest.h index 0669e1eed2a76c35242eaa815c2f24466852864c..865a4120f72e304172115e8982b68abac3d42523 100644 --- a/Framework/DataHandling/test/SaveILLCosmosAsciiTest.h +++ b/Framework/DataHandling/test/SaveILLCosmosAsciiTest.h @@ -228,7 +228,8 @@ public: private: void headingsTests(std::ifstream &in, std::string &fullline, - bool propertiesLogs = false, std::string sep = "\t") { + bool propertiesLogs = false, + const std::string &sep = "\t") { getline(in, fullline); TS_ASSERT_EQUALS(fullline, "MFT"); getline(in, fullline); diff --git a/Framework/DataHandling/test/SaveNXSPETest.h b/Framework/DataHandling/test/SaveNXSPETest.h index fb569bdb7ca107e5eb7ddd0254a512d5e8c3e646..fe41ac1a3d787fad738385e1c24877e96cedbff2 100644 --- a/Framework/DataHandling/test/SaveNXSPETest.h +++ b/Framework/DataHandling/test/SaveNXSPETest.h @@ -175,7 +175,7 @@ private: boost::tuple<boost::shared_array<hsize_t>, boost::shared_array<double>, boost::shared_array<double>>; - DataHolder saveAndReloadWorkspace(const MatrixWorkspace_sptr inputWS) { + DataHolder saveAndReloadWorkspace(const MatrixWorkspace_sptr &inputWS) { SaveNXSPE saver; saver.initialize(); saver.setChild(true); diff --git a/Framework/DataHandling/test/SaveNXcanSASTest.h b/Framework/DataHandling/test/SaveNXcanSASTest.h index 7fba40a62ae0ef2820c903443c8562077660158b..46bdbabd14ebec8da4d43704c48d5307f23d798b 100644 --- a/Framework/DataHandling/test/SaveNXcanSASTest.h +++ b/Framework/DataHandling/test/SaveNXcanSASTest.h @@ -373,10 +373,10 @@ public: private: void save_file_no_issues( - Mantid::API::MatrixWorkspace_sptr workspace, + const Mantid::API::MatrixWorkspace_sptr &workspace, NXcanSASTestParameters ¶meters, - Mantid::API::MatrixWorkspace_sptr transmission = nullptr, - Mantid::API::MatrixWorkspace_sptr transmissionCan = nullptr) { + const Mantid::API::MatrixWorkspace_sptr &transmission = nullptr, + const Mantid::API::MatrixWorkspace_sptr &transmissionCan = nullptr) { auto saveAlg = Mantid::API::AlgorithmManager::Instance().createUnmanaged( "SaveNXcanSAS"); saveAlg->initialize(); @@ -472,7 +472,7 @@ private: } void do_assert_detector(H5::Group &instrument, - std::vector<std::string> detectors) { + const std::vector<std::string> &detectors) { for (auto &detector : detectors) { std::string detectorName = sasInstrumentDetectorGroupName + detector; auto detectorNameSanitized = @@ -616,7 +616,7 @@ private: void do_assert_process_note(H5::Group ¬e, const bool &hasSampleRuns, const bool &hasCanRuns, const std::string &sampleDirectRun, - const std::string canDirectRun) { + const std::string &canDirectRun) { auto numAttributes = note.getNumAttrs(); TSM_ASSERT_EQUALS("Should have 2 attributes", 2, numAttributes); diff --git a/Framework/DataHandling/test/SaveNexusESSTest.h b/Framework/DataHandling/test/SaveNexusESSTest.h index 969ec56471a22fedf93f940e1c54b11e7fb29eb9..4bbeb8a86e7a756438af1095e7f0aebc3c5b325b 100644 --- a/Framework/DataHandling/test/SaveNexusESSTest.h +++ b/Framework/DataHandling/test/SaveNexusESSTest.h @@ -33,7 +33,7 @@ using namespace Mantid::DataHandling; using namespace Mantid::API; namespace { -template <typename T> void do_execute(const std::string filename, T &ws) { +template <typename T> void do_execute(const std::string &filename, T &ws) { SaveNexusESS alg; alg.setChild(true); alg.setRethrows(true); diff --git a/Framework/DataHandling/test/SaveNexusProcessedTest.h b/Framework/DataHandling/test/SaveNexusProcessedTest.h index 955c1419f7bb2522f85dfda9f6d50481596c9488..44bf634212da801aff15160c70ee12b2ffb74efd 100644 --- a/Framework/DataHandling/test/SaveNexusProcessedTest.h +++ b/Framework/DataHandling/test/SaveNexusProcessedTest.h @@ -228,7 +228,7 @@ public: * @return */ static EventWorkspace_sptr - do_testExec_EventWorkspaces(std::string filename_root, EventType type, + do_testExec_EventWorkspaces(const std::string &filename_root, EventType type, std::string &outputFile, bool makeDifferentTypes, bool clearfiles, bool PreserveEvents = true, bool CompressNexus = false) { diff --git a/Framework/DataHandling/test/SaveOpenGenieAsciiTest.h b/Framework/DataHandling/test/SaveOpenGenieAsciiTest.h index f5c4a3daaee22902588332b904efa32d9a8e4619..cf19f1e0ba05191663bf916e2f19417fb5e05707 100644 --- a/Framework/DataHandling/test/SaveOpenGenieAsciiTest.h +++ b/Framework/DataHandling/test/SaveOpenGenieAsciiTest.h @@ -82,7 +82,7 @@ private: const std::string m_inputNexusFile{"SaveOpenGenieAsciiInput.nxs"}; std::unique_ptr<SaveOpenGenieAscii> - createAlg(MatrixWorkspace_sptr ws, const std::string &tempFilePath) { + createAlg(const MatrixWorkspace_sptr &ws, const std::string &tempFilePath) { auto alg = std::make_unique<SaveOpenGenieAscii>(); alg->initialize(); diff --git a/Framework/DataHandling/test/SavePDFGuiTest.h b/Framework/DataHandling/test/SavePDFGuiTest.h index 640d806e5c5159fe1e4bea05de68eecb6786d424..adea18d2e1b0ce8f715607b46b6a73a32e715d87 100644 --- a/Framework/DataHandling/test/SavePDFGuiTest.h +++ b/Framework/DataHandling/test/SavePDFGuiTest.h @@ -59,7 +59,7 @@ public: return n; } - bool loadWorkspace(const std::string &filename, const std::string wsName) { + bool loadWorkspace(const std::string &filename, const std::string &wsName) { LoadNexusProcessed load; load.initialize(); load.setProperty("Filename", filename); @@ -112,9 +112,6 @@ public: grpAlg->setPropertyValue("OutputWorkspace", groupName); grpAlg->execute(); - // name of the output file - const std::string outFilename("SavePDFGUIGroup.gr"); - // run the algorithm with a group SavePDFGui alg; TS_ASSERT_THROWS_NOTHING(alg.initialize()); diff --git a/Framework/DataHandling/test/SaveParameterFileTest.h b/Framework/DataHandling/test/SaveParameterFileTest.h index 503862706e651bf68bd6db02695c4e5b7816d84c..69616ee7242286f6a1717248a65d00869b484701 100644 --- a/Framework/DataHandling/test/SaveParameterFileTest.h +++ b/Framework/DataHandling/test/SaveParameterFileTest.h @@ -77,21 +77,23 @@ public: "linear ; TOF ; TOF"); } - void setParam(std::string cName, std::string pName, std::string value) { + void setParam(const std::string &cName, const std::string &pName, + const std::string &value) { Instrument_const_sptr inst = m_ws->getInstrument(); ParameterMap ¶mMap = m_ws->instrumentParameters(); boost::shared_ptr<const IComponent> comp = inst->getComponentByName(cName); paramMap.addString(comp->getComponentID(), pName, value); } - void setParam(std::string cName, std::string pName, double value) { + void setParam(const std::string &cName, const std::string &pName, + double value) { Instrument_const_sptr inst = m_ws->getInstrument(); ParameterMap ¶mMap = m_ws->instrumentParameters(); boost::shared_ptr<const IComponent> comp = inst->getComponentByName(cName); paramMap.addDouble(comp->getComponentID(), pName, value); } - void setParamByDetID(int id, std::string pName, double value) { + void setParamByDetID(int id, const std::string &pName, double value) { ParameterMap ¶mMap = m_ws->instrumentParameters(); const auto &detectorInfo = m_ws->detectorInfo(); const auto detectorIndex = detectorInfo.indexOf(id); @@ -99,7 +101,8 @@ public: paramMap.addDouble(detector.getComponentID(), pName, value); } - void setFitParam(std::string cName, std::string pName, std::string value) { + void setFitParam(const std::string &cName, const std::string &pName, + const std::string &value) { Instrument_const_sptr inst = m_ws->getInstrument(); ParameterMap ¶mMap = m_ws->instrumentParameters(); boost::shared_ptr<const IComponent> comp = inst->getComponentByName(cName); @@ -108,7 +111,8 @@ public: paramMap.add(comp.get(), param); } - void checkParam(std::string cName, std::string pName, std::string value) { + void checkParam(const std::string &cName, const std::string &pName, + std::string value) { Instrument_const_sptr inst = m_ws->getInstrument(); ParameterMap ¶mMap = m_ws->instrumentParameters(); boost::shared_ptr<const IComponent> comp = inst->getComponentByName(cName); @@ -116,7 +120,8 @@ public: TS_ASSERT_EQUALS(value, param); } - void checkParam(std::string cName, std::string pName, double value) { + void checkParam(const std::string &cName, const std::string &pName, + double value) { Instrument_const_sptr inst = m_ws->getInstrument(); ParameterMap ¶mMap = m_ws->instrumentParameters(); boost::shared_ptr<const IComponent> comp = inst->getComponentByName(cName); @@ -124,7 +129,7 @@ public: TS_ASSERT_DELTA(value, values.front(), 0.0001); } - void checkParamByDetID(int id, std::string pName, double value) { + void checkParamByDetID(int id, const std::string &pName, double value) { ParameterMap ¶mMap = m_ws->instrumentParameters(); const auto &detectorInfo = m_ws->detectorInfo(); const auto &detector = detectorInfo.detector(detectorInfo.indexOf(id)); @@ -133,7 +138,8 @@ public: TS_ASSERT_DELTA(value, pValue, 0.0001); } - void checkFitParam(std::string cName, std::string pName, std::string value) { + void checkFitParam(const std::string &cName, const std::string &pName, + const std::string &value) { Instrument_const_sptr inst = m_ws->getInstrument(); ParameterMap ¶mMap = m_ws->instrumentParameters(); boost::shared_ptr<const IComponent> comp = inst->getComponentByName(cName); @@ -150,7 +156,7 @@ public: TS_ASSERT_EQUALS(fitParam.getFormulaUnit(), values[8]); } - void loadParams(std::string filename) { + void loadParams(const std::string &filename) { LoadParameterFile loaderPF; TS_ASSERT_THROWS_NOTHING(loaderPF.initialize()); loaderPF.setPropertyValue("Filename", filename); @@ -159,7 +165,7 @@ public: TS_ASSERT(loaderPF.isExecuted()); } - void saveParams(std::string filename) { + void saveParams(const std::string &filename) { SaveParameterFile saverPF; TS_ASSERT_THROWS_NOTHING(saverPF.initialize()); saverPF.setPropertyValue("Filename", filename); diff --git a/Framework/DataHandling/test/SaveRMCProfileTest.h b/Framework/DataHandling/test/SaveRMCProfileTest.h index 5f46b3353c120b6d5ed0f13e9e2baeb1b5ac8572..89765159bfe1f60db60794c2ec88dbf8b2b5961b 100644 --- a/Framework/DataHandling/test/SaveRMCProfileTest.h +++ b/Framework/DataHandling/test/SaveRMCProfileTest.h @@ -59,7 +59,7 @@ public: return n; } - bool loadWorkspace(const std::string &filename, const std::string wsName) { + bool loadWorkspace(const std::string &filename, const std::string &wsName) { LoadNexusProcessed load; load.initialize(); load.setProperty("Filename", filename); diff --git a/Framework/DataHandling/test/SetSampleTest.h b/Framework/DataHandling/test/SetSampleTest.h index 62c3e08cf6dcc517ca29ef8bb9f117df56e847bd..8a7e80e2801fa9a8799b86215084b5e68bd0b84a 100644 --- a/Framework/DataHandling/test/SetSampleTest.h +++ b/Framework/DataHandling/test/SetSampleTest.h @@ -576,7 +576,8 @@ private: return false; } - void setTestReferenceFrame(Mantid::API::MatrixWorkspace_sptr workspace) { + void + setTestReferenceFrame(const Mantid::API::MatrixWorkspace_sptr &workspace) { using Mantid::Geometry::Instrument; using Mantid::Geometry::ReferenceFrame; // Use Z=up,Y=across,X=beam so we test it listens to the reference frame diff --git a/Framework/DataHandling/test/SetScalingPSDTest.h b/Framework/DataHandling/test/SetScalingPSDTest.h index 8494437615d762942c71e2c692636e6867dc5c03..63db0e059384b003d13116bcd19468331330692b 100644 --- a/Framework/DataHandling/test/SetScalingPSDTest.h +++ b/Framework/DataHandling/test/SetScalingPSDTest.h @@ -128,7 +128,7 @@ public: } private: - std::string createTestScalingFile(Workspace2D_sptr testWS) { + std::string createTestScalingFile(const Workspace2D_sptr &testWS) { // NOTE: The only values read by the algorithm are the number of detectors // and then from each detector line // det no., (l2,theta,phi). All other values will be set to -1 here diff --git a/Framework/DataHandling/test/UpdateInstrumentFromFileTest.h b/Framework/DataHandling/test/UpdateInstrumentFromFileTest.h index d00bc48e599920c6f1b3e393cef63b783a113b57..f7ae6029178db8ecd996a98c8491064889e306eb 100644 --- a/Framework/DataHandling/test/UpdateInstrumentFromFileTest.h +++ b/Framework/DataHandling/test/UpdateInstrumentFromFileTest.h @@ -137,7 +137,6 @@ public: void test_DAT_Extension_Without_Header_Assumes_Detector_Calibration_File_And_Fails_If_Number_Of_Columns_Incorrect() { - const std::string colNames = "spectrum,theta,t0,-,R"; const std::string contents = "plik det t0 l0 l1\n" " 3 130.4653 -0.4157 11.0050 0.6708\n" " 4 131.9319 -0.5338 11.0050 0.6545"; diff --git a/Framework/DataObjects/inc/MantidDataObjects/AffineMatrixParameter.h b/Framework/DataObjects/inc/MantidDataObjects/AffineMatrixParameter.h index cb12678d079c8fdac9dcf5c01be3c81ba43f14f1..39c06e04c2c4987d13c85199f3f12b80a29ee18f 100644 --- a/Framework/DataObjects/inc/MantidDataObjects/AffineMatrixParameter.h +++ b/Framework/DataObjects/inc/MantidDataObjects/AffineMatrixParameter.h @@ -29,7 +29,7 @@ public: bool isValid() const override; std::string toXMLString() const override; AffineMatrixParameter *clone() const override; - void setMatrix(const AffineMatrixType newMatrix); + void setMatrix(const AffineMatrixType &newMatrix); AffineMatrixParameter(size_t outD, size_t inD); AffineMatrixParameter(const AffineMatrixParameter &); AffineMatrixParameter &operator=(const AffineMatrixParameter &other); diff --git a/Framework/DataObjects/inc/MantidDataObjects/BoxControllerNeXusIO.h b/Framework/DataObjects/inc/MantidDataObjects/BoxControllerNeXusIO.h index 7c60f5c5befa1d542a8542f0a994c58a53b0caa5..1832b1dda3f5e086221ec4d0b86df0370ba7d3b1 100644 --- a/Framework/DataObjects/inc/MantidDataObjects/BoxControllerNeXusIO.h +++ b/Framework/DataObjects/inc/MantidDataObjects/BoxControllerNeXusIO.h @@ -129,7 +129,7 @@ private: // get the event type from event name static EventType TypeFromString(const std::vector<std::string> &typesSupported, - const std::string typeName); + const std::string &typeName); /// the enum, which suggests the way (currently)two possible data types are /// converted to each other enum CoordConversion { diff --git a/Framework/DataObjects/inc/MantidDataObjects/EventList.h b/Framework/DataObjects/inc/MantidDataObjects/EventList.h index a43e81ea0c950c5d45e3e9942ac8e65c6d00301c..f751a4e62955bf0061c48b416ccfc911486e43ce 100644 --- a/Framework/DataObjects/inc/MantidDataObjects/EventList.h +++ b/Framework/DataObjects/inc/MantidDataObjects/EventList.h @@ -447,7 +447,7 @@ private: const double maxX, const bool entireRange); template <class T> void convertTofHelper(std::vector<T> &events, - std::function<double(double)> func); + const std::function<double(double)> &func); template <class T> void convertTofHelper(std::vector<T> &events, const double factor, diff --git a/Framework/DataObjects/inc/MantidDataObjects/EventWorkspaceHelpers.h b/Framework/DataObjects/inc/MantidDataObjects/EventWorkspaceHelpers.h index b28ca1aab25bc87fcfb6ec0f986b4bdcfc3c631b..89d4c4fe1f736d4b3f2bfcbf95ac5d30449c1be4 100644 --- a/Framework/DataObjects/inc/MantidDataObjects/EventWorkspaceHelpers.h +++ b/Framework/DataObjects/inc/MantidDataObjects/EventWorkspaceHelpers.h @@ -20,7 +20,7 @@ namespace DataObjects { struct DLLExport EventWorkspaceHelpers { /// Converts an EventWorkspace to an equivalent Workspace2D. static API::MatrixWorkspace_sptr - convertEventTo2D(API::MatrixWorkspace_sptr inputMatrixW); + convertEventTo2D(const API::MatrixWorkspace_sptr &inputMatrixW); }; } // namespace DataObjects diff --git a/Framework/DataObjects/inc/MantidDataObjects/FakeMD.h b/Framework/DataObjects/inc/MantidDataObjects/FakeMD.h index 7f20411296476be893711eace572fe8dc2e01f74..2a3c9fdc44ef36b030237af44178b3a6726d9681 100644 --- a/Framework/DataObjects/inc/MantidDataObjects/FakeMD.h +++ b/Framework/DataObjects/inc/MantidDataObjects/FakeMD.h @@ -25,7 +25,7 @@ public: const std::vector<double> &peakParams, const int randomSeed, const bool randomizeSignal); - void fill(API::IMDEventWorkspace_sptr workspace); + void fill(const API::IMDEventWorkspace_sptr &workspace); private: void setupDetectorCache(const API::IMDEventWorkspace &workspace); diff --git a/Framework/DataObjects/inc/MantidDataObjects/FractionalRebinning.h b/Framework/DataObjects/inc/MantidDataObjects/FractionalRebinning.h index 266435f63a0eba132f77371ef883320651d318db..10f5d984973f784d655f8318ccccf53c33ea047f 100644 --- a/Framework/DataObjects/inc/MantidDataObjects/FractionalRebinning.h +++ b/Framework/DataObjects/inc/MantidDataObjects/FractionalRebinning.h @@ -42,8 +42,8 @@ getIntersectionRegion(const std::vector<double> &xAxis, /// Compute sqrt of errors and put back in bin width division if necessary MANTID_DATAOBJECTS_DLL void -normaliseOutput(API::MatrixWorkspace_sptr outputWS, - API::MatrixWorkspace_const_sptr inputWS, +normaliseOutput(const API::MatrixWorkspace_sptr &outputWS, + const API::MatrixWorkspace_const_sptr &inputWS, API::Progress *progress = nullptr); /// Rebin the input quadrilateral to to output grid diff --git a/Framework/DataObjects/inc/MantidDataObjects/GroupingWorkspace.h b/Framework/DataObjects/inc/MantidDataObjects/GroupingWorkspace.h index 065866dd4bfbd4ea1a09c33c618a0bf5968adf7e..75c6291d90146383baa3f2cb8a44cb78fcdef80f 100644 --- a/Framework/DataObjects/inc/MantidDataObjects/GroupingWorkspace.h +++ b/Framework/DataObjects/inc/MantidDataObjects/GroupingWorkspace.h @@ -25,7 +25,7 @@ namespace DataObjects { */ class DLLExport GroupingWorkspace : public SpecialWorkspace2D { public: - GroupingWorkspace(Geometry::Instrument_const_sptr inst); + GroupingWorkspace(const Geometry::Instrument_const_sptr &inst); GroupingWorkspace() = default; GroupingWorkspace(size_t numvectors); GroupingWorkspace &operator=(const GroupingWorkspace &) = delete; diff --git a/Framework/DataObjects/inc/MantidDataObjects/MDBoxFlatTree.h b/Framework/DataObjects/inc/MantidDataObjects/MDBoxFlatTree.h index 8f7cf396a7d940d772bcb0ed281d48e03ec3da39..3527cca7f74aa0e9b07966bcf89532c9d181be79 100644 --- a/Framework/DataObjects/inc/MantidDataObjects/MDBoxFlatTree.h +++ b/Framework/DataObjects/inc/MantidDataObjects/MDBoxFlatTree.h @@ -47,7 +47,7 @@ public: //--------------------------------------------------------------------------------------------------------------------- /// convert MDWS box structure into flat structure used for saving/loading on /// hdd - void initFlatStructure(API::IMDEventWorkspace_sptr pws, + void initFlatStructure(const API::IMDEventWorkspace_sptr &pws, const std::string &fileName); uint64_t restoreBoxTree(std::vector<API::IMDNode *> &Boxes, @@ -118,26 +118,28 @@ public: // save each experiment info into its own NeXus group within an existing // opened group static void saveExperimentInfos(::NeXus::File *const file, - API::IMDEventWorkspace_const_sptr ws); + const API::IMDEventWorkspace_const_sptr &ws); // load experiment infos, previously saved through the the saveExperimentInfo // function - static void - loadExperimentInfos(::NeXus::File *const file, const std::string &filename, - boost::shared_ptr<API::MultipleExperimentInfos> mei, - bool lazy = false); + static void loadExperimentInfos( + ::NeXus::File *const file, const std::string &filename, + const boost::shared_ptr<API::MultipleExperimentInfos> &mei, + bool lazy = false); - static void saveAffineTransformMatricies(::NeXus::File *const file, - API::IMDWorkspace_const_sptr ws); + static void + saveAffineTransformMatricies(::NeXus::File *const file, + const API::IMDWorkspace_const_sptr &ws); static void saveAffineTransformMatrix(::NeXus::File *const file, API::CoordTransform const *transform, - std::string entry_name); + const std::string &entry_name); static void saveWSGenericInfo(::NeXus::File *const file, - API::IMDWorkspace_const_sptr ws); + const API::IMDWorkspace_const_sptr &ws); }; template <typename T> -void saveMatrix(::NeXus::File *const file, std::string name, - Kernel::Matrix<T> &m, ::NeXus::NXnumtype type, std::string tag); +void saveMatrix(::NeXus::File *const file, const std::string &name, + Kernel::Matrix<T> &m, ::NeXus::NXnumtype type, + const std::string &tag); } // namespace DataObjects } // namespace Mantid \ No newline at end of file diff --git a/Framework/DataObjects/inc/MantidDataObjects/MDFramesToSpecialCoordinateSystem.h b/Framework/DataObjects/inc/MantidDataObjects/MDFramesToSpecialCoordinateSystem.h index 813ae7a9d2d88b674e73b2c1d1ab036c8335825a..c6e9884b53da8170e4c03ef6eeaf2d93a2e5e4bf 100644 --- a/Framework/DataObjects/inc/MantidDataObjects/MDFramesToSpecialCoordinateSystem.h +++ b/Framework/DataObjects/inc/MantidDataObjects/MDFramesToSpecialCoordinateSystem.h @@ -27,8 +27,8 @@ private: Mantid::Kernel::SpecialCoordinateSystem specialCoordinateSystem, boost::optional<Mantid::Kernel::SpecialCoordinateSystem> qFrameType) const; - bool - isUnknownFrame(Mantid::Geometry::IMDDimension_const_sptr dimension) const; + bool isUnknownFrame( + const Mantid::Geometry::IMDDimension_const_sptr &dimension) const; }; } // namespace DataObjects diff --git a/Framework/DataObjects/inc/MantidDataObjects/MDHistoWorkspace.h b/Framework/DataObjects/inc/MantidDataObjects/MDHistoWorkspace.h index 6d46b5ea36f42041cc773f0b1c70c8a1c50870e8..4271118b885f973ab3513f6bbb54c33f12dcf291 100644 --- a/Framework/DataObjects/inc/MantidDataObjects/MDHistoWorkspace.h +++ b/Framework/DataObjects/inc/MantidDataObjects/MDHistoWorkspace.h @@ -91,7 +91,8 @@ public: const Mantid::Kernel::VMD &end, Mantid::API::MDNormalization normalize) const override; - void checkWorkspaceSize(const MDHistoWorkspace &other, std::string operation); + void checkWorkspaceSize(const MDHistoWorkspace &other, + const std::string &operation); // -------------------------------------------------------------------------------------------- MDHistoWorkspace &operator+=(const MDHistoWorkspace &b); diff --git a/Framework/DataObjects/inc/MantidDataObjects/MDHistoWorkspaceIterator.h b/Framework/DataObjects/inc/MantidDataObjects/MDHistoWorkspaceIterator.h index ff5dab5ccea0f42e730d6db79dfbe7968ee5eafa..6b0bd4ee5debcad7b572334d399a0bc6bdd115de 100644 --- a/Framework/DataObjects/inc/MantidDataObjects/MDHistoWorkspaceIterator.h +++ b/Framework/DataObjects/inc/MantidDataObjects/MDHistoWorkspaceIterator.h @@ -38,7 +38,8 @@ using VecMDExtents = std::vector<MDExtentPair>; class DLLExport MDHistoWorkspaceIterator : public Mantid::API::IMDIterator { public: MDHistoWorkspaceIterator( - MDHistoWorkspace_const_sptr workspace, SkippingPolicy *skippingPolicy, + const MDHistoWorkspace_const_sptr &workspace, + SkippingPolicy *skippingPolicy, Mantid::Geometry::MDImplicitFunction *function = nullptr, size_t beginPos = 0, size_t endPos = size_t(-1)); MDHistoWorkspaceIterator( @@ -46,7 +47,7 @@ public: Mantid::Geometry::MDImplicitFunction *function = nullptr, size_t beginPos = 0, size_t endPos = size_t(-1)); MDHistoWorkspaceIterator( - MDHistoWorkspace_const_sptr workspace, + const MDHistoWorkspace_const_sptr &workspace, Mantid::Geometry::MDImplicitFunction *function = nullptr, size_t beginPos = 0, size_t endPos = size_t(-1)); MDHistoWorkspaceIterator( diff --git a/Framework/DataObjects/inc/MantidDataObjects/MaskWorkspace.h b/Framework/DataObjects/inc/MantidDataObjects/MaskWorkspace.h index 001d798283b2aaceff967da83ceda741ccb5ce58..590f0f050c5def9c2291277865ed56ba6b179a35 100644 --- a/Framework/DataObjects/inc/MantidDataObjects/MaskWorkspace.h +++ b/Framework/DataObjects/inc/MantidDataObjects/MaskWorkspace.h @@ -20,9 +20,9 @@ class DLLExport MaskWorkspace : public SpecialWorkspace2D, public: MaskWorkspace() = default; MaskWorkspace(std::size_t numvectors); - MaskWorkspace(Mantid::Geometry::Instrument_const_sptr instrument, + MaskWorkspace(const Mantid::Geometry::Instrument_const_sptr &instrument, const bool includeMonitors = false); - MaskWorkspace(const API::MatrixWorkspace_const_sptr parent); + MaskWorkspace(const API::MatrixWorkspace_const_sptr &parent); /// Returns a clone of the workspace std::unique_ptr<MaskWorkspace> clone() const { diff --git a/Framework/DataObjects/inc/MantidDataObjects/MementoTableWorkspace.h b/Framework/DataObjects/inc/MantidDataObjects/MementoTableWorkspace.h index 081f2361573c7af25db9f6f347644de1dabd9679..cc57d2f8a04c95b68097ab7e399019d196e51819 100644 --- a/Framework/DataObjects/inc/MantidDataObjects/MementoTableWorkspace.h +++ b/Framework/DataObjects/inc/MantidDataObjects/MementoTableWorkspace.h @@ -48,8 +48,8 @@ private: return new MementoTableWorkspace(); } - static bool expectedColumn(Mantid::API::Column_const_sptr expected, - Mantid::API::Column_const_sptr candidate); + static bool expectedColumn(const Mantid::API::Column_const_sptr &expected, + const Mantid::API::Column_const_sptr &candidate); }; } // namespace DataObjects } // namespace Mantid diff --git a/Framework/DataObjects/inc/MantidDataObjects/OffsetsWorkspace.h b/Framework/DataObjects/inc/MantidDataObjects/OffsetsWorkspace.h index 26094b9a5e8a02d7b971a451bfeb58ee92b5117b..9e6418697e9f63f2e6641ada3f8e9ff784e73088 100644 --- a/Framework/DataObjects/inc/MantidDataObjects/OffsetsWorkspace.h +++ b/Framework/DataObjects/inc/MantidDataObjects/OffsetsWorkspace.h @@ -24,7 +24,7 @@ namespace DataObjects { class DLLExport OffsetsWorkspace : public SpecialWorkspace2D { public: OffsetsWorkspace() = default; - OffsetsWorkspace(Geometry::Instrument_const_sptr inst); + OffsetsWorkspace(const Geometry::Instrument_const_sptr &inst); /// Returns a clone of the workspace std::unique_ptr<OffsetsWorkspace> clone() const { diff --git a/Framework/DataObjects/inc/MantidDataObjects/ReflectometryTransform.h b/Framework/DataObjects/inc/MantidDataObjects/ReflectometryTransform.h index fd2eb58b025d08bd5aa633f284911a063c28f20c..5a80a5b485e857d69f9c61d08e4e840125ac1848 100644 --- a/Framework/DataObjects/inc/MantidDataObjects/ReflectometryTransform.h +++ b/Framework/DataObjects/inc/MantidDataObjects/ReflectometryTransform.h @@ -58,29 +58,30 @@ protected: mutable std::vector<double> m_thetaWidths; boost::shared_ptr<DataObjects::MDEventWorkspace2Lean> - createMDWorkspace(Geometry::IMDDimension_sptr, Geometry::IMDDimension_sptr, - API::BoxController_sptr boxController) const; + createMDWorkspace(const Geometry::IMDDimension_sptr &, + const Geometry::IMDDimension_sptr &, + const API::BoxController_sptr &boxController) const; public: // Execute the strategy to produce a transformed, output MDWorkspace Mantid::API::IMDEventWorkspace_sptr - executeMD(Mantid::API::MatrixWorkspace_const_sptr inputWs, - Mantid::API::BoxController_sptr boxController, + executeMD(const Mantid::API::MatrixWorkspace_const_sptr &inputWs, + const Mantid::API::BoxController_sptr &boxController, Mantid::Geometry::MDFrame_uptr frame) const; // Execute the strategy to produce a transformed, output group of Matrix (2D) // Workspaces Mantid::API::MatrixWorkspace_sptr - execute(Mantid::API::MatrixWorkspace_const_sptr inputWs) const; + execute(const Mantid::API::MatrixWorkspace_const_sptr &inputWs) const; /// Execuate transformation using normalised polynomial binning Mantid::API::MatrixWorkspace_sptr executeNormPoly( const Mantid::API::MatrixWorkspace_const_sptr &inputWS, boost::shared_ptr<Mantid::DataObjects::TableWorkspace> &vertexes, - bool dumpVertexes, std::string outputDimensions) const; + bool dumpVertexes, const std::string &outputDimensions) const; - Mantid::API::IMDHistoWorkspace_sptr - executeMDNormPoly(Mantid::API::MatrixWorkspace_const_sptr inputWs) const; + Mantid::API::IMDHistoWorkspace_sptr executeMDNormPoly( + const Mantid::API::MatrixWorkspace_const_sptr &inputWs) const; virtual ~ReflectometryTransform() = default; ReflectometryTransform(const std::string &d0Label, const std::string &d0ID, double d0Min, double d0Max, const std::string &d1Label, diff --git a/Framework/DataObjects/inc/MantidDataObjects/SpecialWorkspace2D.h b/Framework/DataObjects/inc/MantidDataObjects/SpecialWorkspace2D.h index 511f05d599a54ee2fbd284b02b524771e966d0b1..a27600d5cd9fdb73ade236179c0a4c7f698f5eee 100644 --- a/Framework/DataObjects/inc/MantidDataObjects/SpecialWorkspace2D.h +++ b/Framework/DataObjects/inc/MantidDataObjects/SpecialWorkspace2D.h @@ -31,9 +31,9 @@ public: class DLLExport SpecialWorkspace2D : public Workspace2D { public: SpecialWorkspace2D() = default; - SpecialWorkspace2D(Geometry::Instrument_const_sptr inst, + SpecialWorkspace2D(const Geometry::Instrument_const_sptr &inst, const bool includeMonitors = false); - SpecialWorkspace2D(API::MatrixWorkspace_const_sptr parent); + SpecialWorkspace2D(const API::MatrixWorkspace_const_sptr &parent); /// Returns a clone of the workspace std::unique_ptr<SpecialWorkspace2D> clone() const { @@ -73,7 +73,7 @@ private: SpecialWorkspace2D *doCloneEmpty() const override { return new SpecialWorkspace2D(); } - bool isCompatible(boost::shared_ptr<const SpecialWorkspace2D> ws); + bool isCompatible(const boost::shared_ptr<const SpecialWorkspace2D> &ws); protected: /// Protected copy constructor. May be used by childs for cloning. @@ -86,9 +86,9 @@ protected: /// Return human-readable string const std::string toString() const override; - void binaryAND(boost::shared_ptr<const SpecialWorkspace2D> ws); - void binaryOR(boost::shared_ptr<const SpecialWorkspace2D> ws); - void binaryXOR(boost::shared_ptr<const SpecialWorkspace2D> ws); + void binaryAND(const boost::shared_ptr<const SpecialWorkspace2D> &ws); + void binaryOR(const boost::shared_ptr<const SpecialWorkspace2D> &ws); + void binaryXOR(const boost::shared_ptr<const SpecialWorkspace2D> &ws); void binaryNOT(); /// Map with key = detector ID, and value = workspace index. diff --git a/Framework/DataObjects/inc/MantidDataObjects/TableColumn.h b/Framework/DataObjects/inc/MantidDataObjects/TableColumn.h index 212b83118e4a1514413af057ed81528ce3c13492..3a9ab90425009e934f9872764dbed5af69a59863 100644 --- a/Framework/DataObjects/inc/MantidDataObjects/TableColumn.h +++ b/Framework/DataObjects/inc/MantidDataObjects/TableColumn.h @@ -556,7 +556,7 @@ public: /** Constructor @param c :: Shared pointer to a column */ - TableColumn_ptr(boost::shared_ptr<API::Column> c) + TableColumn_ptr(const boost::shared_ptr<API::Column> &c) : TableColumn_ptr<API::Boolean>(c) { if (!this->get()) { std::string str = "Data type of column " + c->name() + diff --git a/Framework/DataObjects/inc/MantidDataObjects/TableWorkspace.h b/Framework/DataObjects/inc/MantidDataObjects/TableWorkspace.h index 0298ac46efd0097b68f5411d952eb167ca178715..026ccd6688f9659566560ea4250493c061c4bae5 100644 --- a/Framework/DataObjects/inc/MantidDataObjects/TableWorkspace.h +++ b/Framework/DataObjects/inc/MantidDataObjects/TableWorkspace.h @@ -17,6 +17,21 @@ #include "MantidKernel/V3D.h" #include <boost/shared_ptr.hpp> #include <boost/tuple/tuple.hpp> +#include <utility> + +#include <utility> + +#include <utility> + +#include <utility> + +#include <utility> + +#include <utility> + +#include <utility> + +#include <utility> namespace Mantid { @@ -321,7 +336,7 @@ private: } } - void addColumn(boost::shared_ptr<API::Column> column); + void addColumn(const boost::shared_ptr<API::Column> &column); /** This method finds the row and column index of an integer cell value in a * table workspace @@ -339,7 +354,9 @@ private: * @param col column number of the value searched */ virtual void find(std::string value, size_t &row, size_t &col) { - findValue(value, row, col); + findValue(std::move(std::move(std::move(std::move( + std::move(std::move(std::move(std::move(value)))))))), + row, col); } /** This method finds the row and column index of an float value in a table * workspace diff --git a/Framework/DataObjects/src/AffineMatrixParameter.cpp b/Framework/DataObjects/src/AffineMatrixParameter.cpp index a4d7c95a0666ef3d4c1b8cc4ee6ae61f941222cf..5cc5b9c7b5cb928866d69678986fe7c37a431668 100644 --- a/Framework/DataObjects/src/AffineMatrixParameter.cpp +++ b/Framework/DataObjects/src/AffineMatrixParameter.cpp @@ -162,7 +162,7 @@ AffineMatrixParameter::AffineMatrixParameter(const AffineMatrixParameter &other) * * @param newMatrix : new matrix to use. */ -void AffineMatrixParameter::setMatrix(const AffineMatrixType newMatrix) { +void AffineMatrixParameter::setMatrix(const AffineMatrixType &newMatrix) { if (newMatrix.numRows() != this->m_affineMatrix.numRows()) throw std::runtime_error("setMatrix(): Number of rows must match!"); if (newMatrix.numCols() != this->m_affineMatrix.numCols()) diff --git a/Framework/DataObjects/src/BoxControllerNeXusIO.cpp b/Framework/DataObjects/src/BoxControllerNeXusIO.cpp index aec923188e338fd99e9805e07ea8284183943f51..25d6f75416e3bd7f704a4561914190c9113d53f8 100644 --- a/Framework/DataObjects/src/BoxControllerNeXusIO.cpp +++ b/Framework/DataObjects/src/BoxControllerNeXusIO.cpp @@ -48,7 +48,7 @@ BoxControllerNeXusIO::BoxControllerNeXusIO(API::BoxController *const bc) /**get event type form its string representation*/ BoxControllerNeXusIO::EventType BoxControllerNeXusIO::TypeFromString( const std::vector<std::string> &typesSupported, - const std::string typeName) { + const std::string &typeName) { auto it = std::find(typesSupported.begin(), typesSupported.end(), typeName); if (it == typesSupported.end()) throw std::invalid_argument("Unsupported event type: " + typeName + diff --git a/Framework/DataObjects/src/EventList.cpp b/Framework/DataObjects/src/EventList.cpp index 8cbaf1a19d17bb44709ab56480ad6c2e7b0d3464..918f0d08e849259247c968e22a15c7630ec892e7 100644 --- a/Framework/DataObjects/src/EventList.cpp +++ b/Framework/DataObjects/src/EventList.cpp @@ -2555,7 +2555,7 @@ void EventList::convertTof(std::function<double(double)> func, */ template <class T> void EventList::convertTofHelper(std::vector<T> &events, - std::function<double(double)> func) { + const std::function<double(double)> &func) { // iterate through all events for (auto &ev : events) ev.m_tof = func(ev.m_tof); diff --git a/Framework/DataObjects/src/EventWorkspaceHelpers.cpp b/Framework/DataObjects/src/EventWorkspaceHelpers.cpp index 54ebeea522d100788e987e1b54af4f355965f8d3..edcc382d398d66eb02bd9c5d08facbf135ee1e06 100644 --- a/Framework/DataObjects/src/EventWorkspaceHelpers.cpp +++ b/Framework/DataObjects/src/EventWorkspaceHelpers.cpp @@ -20,8 +20,8 @@ namespace DataObjects { * @param inputMatrixW :: input event workspace * @return a MatrixWorkspace_sptr */ -MatrixWorkspace_sptr -EventWorkspaceHelpers::convertEventTo2D(MatrixWorkspace_sptr inputMatrixW) { +MatrixWorkspace_sptr EventWorkspaceHelpers::convertEventTo2D( + const MatrixWorkspace_sptr &inputMatrixW) { EventWorkspace_sptr inputW = boost::dynamic_pointer_cast<EventWorkspace>(inputMatrixW); if (!inputW) diff --git a/Framework/DataObjects/src/FakeMD.cpp b/Framework/DataObjects/src/FakeMD.cpp index a47360524f4fdbd196a2480321f3a3b500135974..bd3ffa4ae22199f46953d644fb216a2845733721 100644 --- a/Framework/DataObjects/src/FakeMD.cpp +++ b/Framework/DataObjects/src/FakeMD.cpp @@ -49,7 +49,7 @@ FakeMD::FakeMD(const std::vector<double> &uniformParams, * @param workspace A pointer to MD event workspace to fill using the object * parameters */ -void FakeMD::fill(API::IMDEventWorkspace_sptr workspace) { +void FakeMD::fill(const API::IMDEventWorkspace_sptr &workspace) { setupDetectorCache(*workspace); CALL_MDEVENT_FUNCTION(this->addFakePeak, workspace) diff --git a/Framework/DataObjects/src/FractionalRebinning.cpp b/Framework/DataObjects/src/FractionalRebinning.cpp index f2b3a3057f17e6c3d99d866a7de22f40250d598c..0b5aee3aec784ae5146cafddbe061e8f30821125 100644 --- a/Framework/DataObjects/src/FractionalRebinning.cpp +++ b/Framework/DataObjects/src/FractionalRebinning.cpp @@ -495,8 +495,9 @@ void calcGeneralIntersections(const std::vector<double> &xAxis, * @param inputWS The input workspace used for testing distribution state * @param progress An optional progress object. Reported to once per bin. */ -void normaliseOutput(MatrixWorkspace_sptr outputWS, - MatrixWorkspace_const_sptr inputWS, Progress *progress) { +void normaliseOutput(const MatrixWorkspace_sptr &outputWS, + const MatrixWorkspace_const_sptr &inputWS, + Progress *progress) { const bool removeBinWidth(inputWS->isDistribution() && outputWS->id() != "RebinnedOutput"); for (size_t i = 0; i < outputWS->getNumberHistograms(); ++i) { diff --git a/Framework/DataObjects/src/GroupingWorkspace.cpp b/Framework/DataObjects/src/GroupingWorkspace.cpp index 872c9b182cd3f2160c6490ff6f294719d7b80ede..ee76a32caaa78a62e39e56d0befc47027b115131 100644 --- a/Framework/DataObjects/src/GroupingWorkspace.cpp +++ b/Framework/DataObjects/src/GroupingWorkspace.cpp @@ -4,9 +4,11 @@ // NScD Oak Ridge National Laboratory, European Spallation Source, // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + -#include "MantidDataObjects/GroupingWorkspace.h" +#include <utility> + #include "MantidAPI/SpectraAxis.h" #include "MantidAPI/WorkspaceFactory.h" +#include "MantidDataObjects/GroupingWorkspace.h" #include "MantidKernel/IPropertyManager.h" #include "MantidKernel/System.h" @@ -33,8 +35,9 @@ GroupingWorkspace::GroupingWorkspace(size_t numvectors) { * @param inst :: input instrument that is the base for this workspace * @return created GroupingWorkspace */ -GroupingWorkspace::GroupingWorkspace(Geometry::Instrument_const_sptr inst) - : SpecialWorkspace2D(inst) {} +GroupingWorkspace::GroupingWorkspace( + const Geometry::Instrument_const_sptr &inst) + : SpecialWorkspace2D(std::move(inst)) {} //---------------------------------------------------------------------------------------------- /** Fill a map with key = detector ID, value = group number diff --git a/Framework/DataObjects/src/MDBoxFlatTree.cpp b/Framework/DataObjects/src/MDBoxFlatTree.cpp index 06520cb314cdf4eefd6046fc643e9f57972224b9..7984ef15c55648e66a3bd5056ff76f7d1501e6b9 100644 --- a/Framework/DataObjects/src/MDBoxFlatTree.cpp +++ b/Framework/DataObjects/src/MDBoxFlatTree.cpp @@ -14,6 +14,8 @@ #include "MantidKernel/Strings.h" #include <Poco/File.h> +#include <utility> + using file_holder_type = std::unique_ptr<::NeXus::File>; namespace Mantid { @@ -33,7 +35,7 @@ MDBoxFlatTree::MDBoxFlatTree() : m_nDim(-1) {} * @param fileName -- the name of the file, where this structure should be *written. TODO: It is here for the case of file based workspaces */ -void MDBoxFlatTree::initFlatStructure(API::IMDEventWorkspace_sptr pws, +void MDBoxFlatTree::initFlatStructure(const API::IMDEventWorkspace_sptr &pws, const std::string &fileName) { m_bcXMLDescr = pws->getBoxController()->toXMLString(); m_FileName = fileName; @@ -353,8 +355,8 @@ void MDBoxFlatTree::loadBoxStructure(::NeXus::File *hFile, bool onlyEventInfo) { *@param ws -- the shared pointer to the workspace with experiment infos to *write. */ -void MDBoxFlatTree::saveExperimentInfos(::NeXus::File *const file, - API::IMDEventWorkspace_const_sptr ws) { +void MDBoxFlatTree::saveExperimentInfos( + ::NeXus::File *const file, const API::IMDEventWorkspace_const_sptr &ws) { std::map<std::string, std::string> entries; file->getEntries(entries); @@ -406,7 +408,8 @@ void MDBoxFlatTree::saveExperimentInfos(::NeXus::File *const file, */ void MDBoxFlatTree::loadExperimentInfos( ::NeXus::File *const file, const std::string &filename, - boost::shared_ptr<Mantid::API::MultipleExperimentInfos> mei, bool lazy) { + const boost::shared_ptr<Mantid::API::MultipleExperimentInfos> &mei, + bool lazy) { // First, find how many experimentX blocks there are std::map<std::string, std::string> entries; file->getEntries(entries); @@ -748,7 +751,7 @@ MDBoxFlatTree::createOrOpenMDWSgroup(const std::string &fileName, int &nDims, /**Save workspace generic info like dimension structure, history, title * dimensions etc.*/ void MDBoxFlatTree::saveWSGenericInfo(::NeXus::File *const file, - API::IMDWorkspace_const_sptr ws) { + const API::IMDWorkspace_const_sptr &ws) { // Write out the coordinate system file->writeData("coordinate_system", static_cast<uint32_t>(ws->getSpecialCoordinateSystem())); @@ -794,7 +797,7 @@ void MDBoxFlatTree::saveWSGenericInfo(::NeXus::File *const file, * @param ws : workspace to get matrix from */ void MDBoxFlatTree::saveAffineTransformMatricies( - ::NeXus::File *const file, API::IMDWorkspace_const_sptr ws) { + ::NeXus::File *const file, const API::IMDWorkspace_const_sptr &ws) { try { saveAffineTransformMatrix(file, ws->getTransformToOriginal(), "transform_to_orig"); @@ -816,12 +819,12 @@ void MDBoxFlatTree::saveAffineTransformMatricies( */ void MDBoxFlatTree::saveAffineTransformMatrix( ::NeXus::File *const file, API::CoordTransform const *transform, - std::string entry_name) { + const std::string &entry_name) { if (!transform) return; Kernel::Matrix<coord_t> matrix = transform->makeAffineMatrix(); g_log.debug() << "TRFM: " << matrix.str() << '\n'; - saveMatrix<coord_t>(file, entry_name, matrix, ::NeXus::FLOAT32, + saveMatrix<coord_t>(file, std::move(entry_name), matrix, ::NeXus::FLOAT32, transform->id()); } @@ -834,9 +837,9 @@ void MDBoxFlatTree::saveAffineTransformMatrix( * @param tag : id for an affine matrix conversion */ template <typename T> -void saveMatrix(::NeXus::File *const file, std::string name, +void saveMatrix(::NeXus::File *const file, const std::string &name, Kernel::Matrix<T> &m, ::NeXus::NXnumtype type, - std::string tag) { + const std::string &tag) { std::vector<T> v = m.getVector(); // Number of data points auto nPoints = static_cast<int>(v.size()); diff --git a/Framework/DataObjects/src/MDFramesToSpecialCoordinateSystem.cpp b/Framework/DataObjects/src/MDFramesToSpecialCoordinateSystem.cpp index 397258fde7584b7582662e09a478e36d1b0738fc..2f1fd3fe91c0cee5e1e1f126145c902e9af1098d 100644 --- a/Framework/DataObjects/src/MDFramesToSpecialCoordinateSystem.cpp +++ b/Framework/DataObjects/src/MDFramesToSpecialCoordinateSystem.cpp @@ -92,7 +92,7 @@ void MDFramesToSpecialCoordinateSystem::checkQCompatibility( * @returns true if the MDFrame is of UnknownFrame type. */ bool MDFramesToSpecialCoordinateSystem::isUnknownFrame( - Mantid::Geometry::IMDDimension_const_sptr dimension) const { + const Mantid::Geometry::IMDDimension_const_sptr &dimension) const { Mantid::Geometry::MDFrame_uptr replica(dimension->getMDFrame().clone()); auto isUnknown = false; if (dynamic_cast<Mantid::Geometry::UnknownFrame *>(replica.get())) { diff --git a/Framework/DataObjects/src/MDHistoWorkspace.cpp b/Framework/DataObjects/src/MDHistoWorkspace.cpp index 847ab87165e3715b1f05152851446d81d4330953..b26d2cae3ff61712a88974828c8d130bdd127ea3 100644 --- a/Framework/DataObjects/src/MDHistoWorkspace.cpp +++ b/Framework/DataObjects/src/MDHistoWorkspace.cpp @@ -737,7 +737,7 @@ MDHistoWorkspace::getBinBoundariesOnLine(const VMD &start, const VMD &end, * @throw an error if they don't match */ void MDHistoWorkspace::checkWorkspaceSize(const MDHistoWorkspace &other, - std::string operation) { + const std::string &operation) { if (other.getNumDims() != this->getNumDims()) throw std::invalid_argument("Cannot perform the " + operation + " operation on this MDHistoWorkspace. The " diff --git a/Framework/DataObjects/src/MDHistoWorkspaceIterator.cpp b/Framework/DataObjects/src/MDHistoWorkspaceIterator.cpp index 43f529b3fee1c934029768591c8aa36d7b1176f2..d93a52bb004c59e7f80947ae4840a1dae3d38fea 100644 --- a/Framework/DataObjects/src/MDHistoWorkspaceIterator.cpp +++ b/Framework/DataObjects/src/MDHistoWorkspaceIterator.cpp @@ -90,7 +90,7 @@ namespace DataObjects { * @param endPos :: end position */ MDHistoWorkspaceIterator::MDHistoWorkspaceIterator( - MDHistoWorkspace_const_sptr workspace, + const MDHistoWorkspace_const_sptr &workspace, Mantid::Geometry::MDImplicitFunction *function, size_t beginPos, size_t endPos) : m_skippingPolicy(new SkipMaskedBins(this)) { @@ -123,7 +123,8 @@ MDHistoWorkspaceIterator::MDHistoWorkspaceIterator( * @param endPos :: End position */ MDHistoWorkspaceIterator::MDHistoWorkspaceIterator( - MDHistoWorkspace_const_sptr workspace, SkippingPolicy *skippingPolicy, + const MDHistoWorkspace_const_sptr &workspace, + SkippingPolicy *skippingPolicy, Mantid::Geometry::MDImplicitFunction *function, size_t beginPos, size_t endPos) : m_skippingPolicy(skippingPolicy) { diff --git a/Framework/DataObjects/src/MaskWorkspace.cpp b/Framework/DataObjects/src/MaskWorkspace.cpp index d2a3828e70abc36fa78fd6ca9f2985152fa8367a..07944ba17974fa461c3c9e843cd23a724f9b712c 100644 --- a/Framework/DataObjects/src/MaskWorkspace.cpp +++ b/Framework/DataObjects/src/MaskWorkspace.cpp @@ -4,8 +4,10 @@ // NScD Oak Ridge National Laboratory, European Spallation Source, // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + -#include "MantidDataObjects/MaskWorkspace.h" +#include <utility> + #include "MantidAPI/WorkspaceFactory.h" +#include "MantidDataObjects/MaskWorkspace.h" #include "MantidGeometry/Instrument/DetectorInfo.h" #include "MantidKernel/IPropertyManager.h" #include "MantidKernel/System.h" @@ -51,9 +53,10 @@ MaskWorkspace::MaskWorkspace(std::size_t numvectors) { * workspace. * @return MaskWorkspace */ -MaskWorkspace::MaskWorkspace(Mantid::Geometry::Instrument_const_sptr instrument, - const bool includeMonitors) - : SpecialWorkspace2D(instrument, includeMonitors) { +MaskWorkspace::MaskWorkspace( + const Mantid::Geometry::Instrument_const_sptr &instrument, + const bool includeMonitors) + : SpecialWorkspace2D(std::move(instrument), includeMonitors) { this->clearMask(); } @@ -63,7 +66,7 @@ MaskWorkspace::MaskWorkspace(Mantid::Geometry::Instrument_const_sptr instrument, * It must have an instrument. * @return MaskWorkspace */ -MaskWorkspace::MaskWorkspace(const API::MatrixWorkspace_const_sptr parent) +MaskWorkspace::MaskWorkspace(const API::MatrixWorkspace_const_sptr &parent) : SpecialWorkspace2D(parent) { this->clearMask(); } diff --git a/Framework/DataObjects/src/MementoTableWorkspace.cpp b/Framework/DataObjects/src/MementoTableWorkspace.cpp index 6340f564daaf931deb360a419d5e6db5722fc3b2..432172802dad8cfa6f04e3cd754514dc78a3f729 100644 --- a/Framework/DataObjects/src/MementoTableWorkspace.cpp +++ b/Framework/DataObjects/src/MementoTableWorkspace.cpp @@ -22,8 +22,8 @@ Determines whether the provided column has the same name and type as expected. @return true if all expectations are met. */ bool MementoTableWorkspace::expectedColumn( - Mantid::API::Column_const_sptr expected, - Mantid::API::Column_const_sptr candidate) { + const Mantid::API::Column_const_sptr &expected, + const Mantid::API::Column_const_sptr &candidate) { if (expected->name() != candidate->name()) { return false; } else if (expected->type() != candidate->type()) { diff --git a/Framework/DataObjects/src/OffsetsWorkspace.cpp b/Framework/DataObjects/src/OffsetsWorkspace.cpp index 59ce23307836f43a6d526a7d2dfac145a9e0a6c7..c053f57c95ee98c28706255f3652fa96f109e611 100644 --- a/Framework/DataObjects/src/OffsetsWorkspace.cpp +++ b/Framework/DataObjects/src/OffsetsWorkspace.cpp @@ -4,9 +4,11 @@ // NScD Oak Ridge National Laboratory, European Spallation Source, // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + -#include "MantidDataObjects/OffsetsWorkspace.h" +#include <utility> + #include "MantidAPI/SpectraAxis.h" #include "MantidAPI/WorkspaceFactory.h" +#include "MantidDataObjects/OffsetsWorkspace.h" #include "MantidKernel/IPropertyManager.h" #include "MantidKernel/System.h" @@ -21,8 +23,8 @@ DECLARE_WORKSPACE(OffsetsWorkspace) * @param inst :: input instrument that is the base for this workspace * @return created OffsetsWorkspace */ -OffsetsWorkspace::OffsetsWorkspace(Geometry::Instrument_const_sptr inst) - : SpecialWorkspace2D(inst) {} +OffsetsWorkspace::OffsetsWorkspace(const Geometry::Instrument_const_sptr &inst) + : SpecialWorkspace2D(std::move(inst)) {} } // namespace DataObjects } // namespace Mantid diff --git a/Framework/DataObjects/src/Peak.cpp b/Framework/DataObjects/src/Peak.cpp index 26a71c49d41cb1cbf64772049d1a0639bdf48f79..a4829a2c3c936d5c8e0733813131526e0212ac31 100644 --- a/Framework/DataObjects/src/Peak.cpp +++ b/Framework/DataObjects/src/Peak.cpp @@ -20,6 +20,7 @@ #include <algorithm> #include <cctype> #include <string> +#include <utility> using namespace Mantid; using namespace Mantid::Kernel; @@ -60,7 +61,7 @@ Peak::Peak(const Geometry::Instrument_const_sptr &m_inst, m_peakShape(boost::make_shared<NoShape>()) { convention = Kernel::ConfigService::Instance().getString("Q.convention"); this->setInstrument(m_inst); - this->setQLabFrame(QLabFrame, detectorDistance); + this->setQLabFrame(QLabFrame, std::move(detectorDistance)); } //---------------------------------------------------------------------------------------------- @@ -90,7 +91,7 @@ Peak::Peak(const Geometry::Instrument_const_sptr &m_inst, throw std::invalid_argument( "Peak::ctor(): Goniometer matrix must non-singular."); this->setInstrument(m_inst); - this->setQSampleFrame(QSampleFrame, detectorDistance); + this->setQSampleFrame(QSampleFrame, std::move(detectorDistance)); } //---------------------------------------------------------------------------------------------- @@ -779,7 +780,7 @@ void Peak::setL(double m_L) { this->m_L = m_L; } /** Set the BankName of this peak * @param m_bankName :: index to set */ void Peak::setBankName(std::string m_bankName) { - this->m_bankName = m_bankName; + this->m_bankName = std::move(m_bankName); } /** Set all three H,K,L indices of the peak */ diff --git a/Framework/DataObjects/src/PeakShapeBase.cpp b/Framework/DataObjects/src/PeakShapeBase.cpp index d70e2601c6252c9fba5233b9a539b73d09df60c4..8845e3b7d64fb03190128c0d000bf684476149ee 100644 --- a/Framework/DataObjects/src/PeakShapeBase.cpp +++ b/Framework/DataObjects/src/PeakShapeBase.cpp @@ -8,12 +8,14 @@ #include "MantidKernel/SpecialCoordinateSystem.h" #include <json/json.h> +#include <utility> + namespace Mantid { namespace DataObjects { PeakShapeBase::PeakShapeBase(Kernel::SpecialCoordinateSystem frame, std::string algorithmName, int algorithmVersion) - : m_frame(frame), m_algorithmName(algorithmName), + : m_frame(frame), m_algorithmName(std::move(algorithmName)), m_algorithmVersion(algorithmVersion) {} /** diff --git a/Framework/DataObjects/src/PeakShapeEllipsoid.cpp b/Framework/DataObjects/src/PeakShapeEllipsoid.cpp index 08dadf5172e5df47a344fd33acdafbfa0bdc8ecb..07ece5fe3ccafddee39e548b8605555190eb0d1b 100644 --- a/Framework/DataObjects/src/PeakShapeEllipsoid.cpp +++ b/Framework/DataObjects/src/PeakShapeEllipsoid.cpp @@ -8,6 +8,8 @@ #include "MantidKernel/cow_ptr.h" #include <json/json.h> +#include <utility> + namespace Mantid { namespace DataObjects { @@ -18,7 +20,7 @@ PeakShapeEllipsoid::PeakShapeEllipsoid( const std::vector<double> &abcRadiiBackgroundOuter, Kernel::SpecialCoordinateSystem frame, std::string algorithmName, int algorithmVersion) - : PeakShapeBase(frame, algorithmName, algorithmVersion), + : PeakShapeBase(frame, std::move(algorithmName), algorithmVersion), m_directions(directions), m_abc_radii(abcRadii), m_abc_radiiBackgroundInner(abcRadiiBackgroundInner), m_abc_radiiBackgroundOuter(abcRadiiBackgroundOuter) { diff --git a/Framework/DataObjects/src/PeakShapeSpherical.cpp b/Framework/DataObjects/src/PeakShapeSpherical.cpp index b8c0b52801c5f3abf7dbe096ca4db4955a84307f..b81814575802d1535ca5299197e001352950a214 100644 --- a/Framework/DataObjects/src/PeakShapeSpherical.cpp +++ b/Framework/DataObjects/src/PeakShapeSpherical.cpp @@ -7,6 +7,7 @@ #include "MantidDataObjects/PeakShapeSpherical.h" #include <json/json.h> #include <stdexcept> +#include <utility> namespace Mantid { namespace DataObjects { @@ -22,7 +23,7 @@ PeakShapeSpherical::PeakShapeSpherical(const double &peakRadius, Kernel::SpecialCoordinateSystem frame, std::string algorithmName, int algorithmVersion) - : PeakShapeBase(frame, algorithmName, algorithmVersion), + : PeakShapeBase(frame, std::move(algorithmName), algorithmVersion), m_radius(peakRadius) {} /** @@ -40,7 +41,7 @@ PeakShapeSpherical::PeakShapeSpherical(const double &peakRadius, Kernel::SpecialCoordinateSystem frame, std::string algorithmName, int algorithmVersion) - : PeakShapeBase(frame, algorithmName, algorithmVersion), + : PeakShapeBase(frame, std::move(algorithmName), algorithmVersion), m_radius(peakRadius), m_backgroundInnerRadius(peakInnerRadius), m_backgroundOuterRadius(peakOuterRadius) { if (peakRadius == m_backgroundInnerRadius) { diff --git a/Framework/DataObjects/src/ReflectometryTransform.cpp b/Framework/DataObjects/src/ReflectometryTransform.cpp index 22dbfe514bdb92a206908ae5094c1a4bbd765909..ff876f436d7840effe4a666d11b67e0f4c0be90e 100644 --- a/Framework/DataObjects/src/ReflectometryTransform.cpp +++ b/Framework/DataObjects/src/ReflectometryTransform.cpp @@ -31,6 +31,7 @@ #include "MantidKernel/VectorHelper.h" #include <boost/shared_ptr.hpp> +#include <utility> using namespace Mantid::API; using namespace Mantid::Geometry; @@ -125,13 +126,13 @@ ReflectometryTransform::ReflectometryTransform( */ boost::shared_ptr<MDEventWorkspace2Lean> ReflectometryTransform::createMDWorkspace( - Mantid::Geometry::IMDDimension_sptr a, - Mantid::Geometry::IMDDimension_sptr b, - BoxController_sptr boxController) const { + const Mantid::Geometry::IMDDimension_sptr &a, + const Mantid::Geometry::IMDDimension_sptr &b, + const BoxController_sptr &boxController) const { auto ws = boost::make_shared<MDEventWorkspace2Lean>(); - ws->addDimension(a); - ws->addDimension(b); + ws->addDimension(std::move(a)); + ws->addDimension(std::move(b)); BoxController_sptr wsbc = ws->getBoxController(); // Get the box controller wsbc->setSplitInto(boxController->getSplitInto(0)); @@ -280,8 +281,8 @@ DetectorAngularCache initAngularCaches(const MatrixWorkspace *const workspace) { * @returns An MDWorkspace based on centre-point rebinning of the inputWS */ Mantid::API::IMDEventWorkspace_sptr ReflectometryTransform::executeMD( - Mantid::API::MatrixWorkspace_const_sptr inputWs, - BoxController_sptr boxController, + const Mantid::API::MatrixWorkspace_const_sptr &inputWs, + const BoxController_sptr &boxController, Mantid::Geometry::MDFrame_uptr frame) const { auto dim0 = boost::make_shared<MDHistoDimension>( m_d0Label, m_d0ID, *frame, static_cast<Mantid::coord_t>(m_d0Min), @@ -290,7 +291,7 @@ Mantid::API::IMDEventWorkspace_sptr ReflectometryTransform::executeMD( m_d1Label, m_d1ID, *frame, static_cast<Mantid::coord_t>(m_d1Min), static_cast<Mantid::coord_t>(m_d1Max), m_d1NumBins); - auto ws = createMDWorkspace(dim0, dim1, boxController); + auto ws = createMDWorkspace(dim0, dim1, std::move(boxController)); auto spectraAxis = inputWs->getAxis(1); for (size_t index = 0; index < inputWs->getNumberHistograms(); ++index) { @@ -324,7 +325,7 @@ Mantid::API::IMDEventWorkspace_sptr ReflectometryTransform::executeMD( * @return workspace group containing output matrix workspaces of ki and kf */ Mantid::API::MatrixWorkspace_sptr ReflectometryTransform::execute( - Mantid::API::MatrixWorkspace_const_sptr inputWs) const { + const Mantid::API::MatrixWorkspace_const_sptr &inputWs) const { auto ws = boost::make_shared<Mantid::DataObjects::Workspace2D>(); ws->initialize(m_d1NumBins, m_d0NumBins, @@ -380,7 +381,7 @@ Mantid::API::MatrixWorkspace_sptr ReflectometryTransform::execute( } IMDHistoWorkspace_sptr ReflectometryTransform::executeMDNormPoly( - MatrixWorkspace_const_sptr inputWs) const { + const MatrixWorkspace_const_sptr &inputWs) const { auto input_x_dim = inputWs->getXDimension(); @@ -428,7 +429,7 @@ IMDHistoWorkspace_sptr ReflectometryTransform::executeMDNormPoly( MatrixWorkspace_sptr ReflectometryTransform::executeNormPoly( const MatrixWorkspace_const_sptr &inputWS, boost::shared_ptr<Mantid::DataObjects::TableWorkspace> &vertexes, - bool dumpVertexes, std::string outputDimensions) const { + bool dumpVertexes, const std::string &outputDimensions) const { MatrixWorkspace_sptr temp = WorkspaceFactory::Instance().create( "RebinnedOutput", m_d1NumBins, m_d0NumBins + 1, m_d0NumBins); RebinnedOutput_sptr outWS = boost::static_pointer_cast<RebinnedOutput>(temp); diff --git a/Framework/DataObjects/src/SpecialWorkspace2D.cpp b/Framework/DataObjects/src/SpecialWorkspace2D.cpp index b347bdbcc43228a69811246729278d402956858b..915bffb65a17304a95fdcf0066b65ee6b51b4a0a 100644 --- a/Framework/DataObjects/src/SpecialWorkspace2D.cpp +++ b/Framework/DataObjects/src/SpecialWorkspace2D.cpp @@ -32,8 +32,8 @@ DECLARE_WORKSPACE(SpecialWorkspace2D) * @param includeMonitors :: If false the monitors are not included * @return created SpecialWorkspace2D */ -SpecialWorkspace2D::SpecialWorkspace2D(Geometry::Instrument_const_sptr inst, - const bool includeMonitors) { +SpecialWorkspace2D::SpecialWorkspace2D( + const Geometry::Instrument_const_sptr &inst, const bool includeMonitors) { // Init the Workspace2D with one spectrum per detector, in the same order. this->initialize(inst->getNumberDetectors(!includeMonitors), 1, 1); @@ -59,7 +59,8 @@ SpecialWorkspace2D::SpecialWorkspace2D(Geometry::Instrument_const_sptr inst, * @param parent :: input workspace that is the base for this workspace * @return created SpecialWorkspace2D */ -SpecialWorkspace2D::SpecialWorkspace2D(API::MatrixWorkspace_const_sptr parent) { +SpecialWorkspace2D::SpecialWorkspace2D( + const API::MatrixWorkspace_const_sptr &parent) { this->initialize(parent->getNumberHistograms(), 1, 1); API::WorkspaceFactory::Instance().initializeFromParent(*parent, *this, false); // Make the mapping, which will be used for speed later. @@ -263,7 +264,7 @@ void SpecialWorkspace2D::binaryOperation(const unsigned int operatortype) { * */ void SpecialWorkspace2D::binaryAND( - boost::shared_ptr<const SpecialWorkspace2D> ws) { + const boost::shared_ptr<const SpecialWorkspace2D> &ws) { for (size_t i = 0; i < this->getNumberHistograms(); i++) { double y1 = this->dataY(i)[0]; @@ -281,7 +282,7 @@ void SpecialWorkspace2D::binaryAND( * */ void SpecialWorkspace2D::binaryOR( - boost::shared_ptr<const SpecialWorkspace2D> ws) { + const boost::shared_ptr<const SpecialWorkspace2D> &ws) { for (size_t i = 0; i < this->getNumberHistograms(); i++) { double y1 = this->dataY(i)[0]; @@ -307,7 +308,7 @@ if (y1 < 1.0E-10 && y2 < 1.0E-10){ * */ void SpecialWorkspace2D::binaryXOR( - boost::shared_ptr<const SpecialWorkspace2D> ws) { + const boost::shared_ptr<const SpecialWorkspace2D> &ws) { for (size_t i = 0; i < this->getNumberHistograms(); i++) { double y1 = this->dataY(i)[0]; @@ -343,7 +344,7 @@ void SpecialWorkspace2D::binaryNOT() { * @ return */ bool SpecialWorkspace2D::isCompatible( - boost::shared_ptr<const SpecialWorkspace2D> ws) { + const boost::shared_ptr<const SpecialWorkspace2D> &ws) { // 1. Check number of histogram size_t numhist1 = this->getNumberHistograms(); diff --git a/Framework/DataObjects/src/TableWorkspace.cpp b/Framework/DataObjects/src/TableWorkspace.cpp index c74dcc66a590a019d47d966ba74febecb282d1de..8b871aa20e73fd593b6175fe3ba083140f4fc361 100644 --- a/Framework/DataObjects/src/TableWorkspace.cpp +++ b/Framework/DataObjects/src/TableWorkspace.cpp @@ -200,7 +200,7 @@ std::vector<std::string> TableWorkspace::getColumnNames() const { return nameList; } -void TableWorkspace::addColumn(boost::shared_ptr<API::Column> column) { +void TableWorkspace::addColumn(const boost::shared_ptr<API::Column> &column) { auto ci = std::find_if(m_columns.begin(), m_columns.end(), FindName(column->name())); if (ci != m_columns.end()) { diff --git a/Framework/DataObjects/test/AffineMatrixParameterTest.h b/Framework/DataObjects/test/AffineMatrixParameterTest.h index 74ca40581095fd1e44674a89e5da1254ec3b150c..58da4a15d11fc3ed309a41537df6a91c2b97cb57 100644 --- a/Framework/DataObjects/test/AffineMatrixParameterTest.h +++ b/Framework/DataObjects/test/AffineMatrixParameterTest.h @@ -111,7 +111,6 @@ public: } param.setMatrix(transform); - std::string result = param.toXMLString(); TSM_ASSERT_EQUALS( "Serialization of CoordTransform has not worked correctly.", "<Parameter><Type>AffineMatrixParameter</" diff --git a/Framework/DataObjects/test/EventWorkspaceTest.h b/Framework/DataObjects/test/EventWorkspaceTest.h index a0536611e9bdb116e30eb52e40d0ebc8fbed703f..24fa648b83f372c14a45593fc4dd61dc9adc6df3 100644 --- a/Framework/DataObjects/test/EventWorkspaceTest.h +++ b/Framework/DataObjects/test/EventWorkspaceTest.h @@ -421,7 +421,7 @@ public: const std::range_error &); } - void do_test_binning(EventWorkspace_sptr ws, const BinEdges &axis, + void do_test_binning(const EventWorkspace_sptr &ws, const BinEdges &axis, size_t expected_occupancy_per_bin) { MantidVec Y(NUMBINS - 1); MantidVec E(NUMBINS - 1); diff --git a/Framework/DataObjects/test/MDBoxSaveableTest.h b/Framework/DataObjects/test/MDBoxSaveableTest.h index 8a9992cb61feb1f255c966dd4441fbce62554ee2..5f298769abc70e5711e0456b4443f407998537c8 100644 --- a/Framework/DataObjects/test/MDBoxSaveableTest.h +++ b/Framework/DataObjects/test/MDBoxSaveableTest.h @@ -24,6 +24,7 @@ #include <map> #include <memory> #include <nexus/NeXusFile.hpp> +#include <utility> using namespace Mantid; using namespace Mantid::Geometry; @@ -43,7 +44,7 @@ class MDBoxSaveableTest : public CxxTest::TestSuite { /** Deletes the file created by do_saveNexus */ static std::string - do_deleteNexusFile(std::string barefilename = "MDBoxTest.nxs") { + do_deleteNexusFile(const std::string &barefilename = "MDBoxTest.nxs") { std::string filename( ConfigService::Instance().getString("defaultsave.directory") + barefilename); @@ -69,11 +70,12 @@ public: * @return ptr to the NeXus file object * */ void do_createNeXusBackedBox(MDBox<MDLeanEvent<3>, 3> &box, - BoxController_sptr bc, + const BoxController_sptr &bc, std::string barefilename = "MDBoxTest.nxs", bool goofyWeights = true) { // Create the NXS file - std::string filename = do_createNexus(goofyWeights, barefilename); + std::string filename = + do_createNexus(goofyWeights, std::move(barefilename)); // Must get ready to load in the data auto loader = boost::shared_ptr<API::IBoxControllerIO>( @@ -100,8 +102,9 @@ public: * @param barefilename :: file to save to (no path) * @return filename with full path that was saved. * */ - std::string do_createNexus(bool goofyWeights = true, - std::string barefilename = "MDBoxTest.nxs") { + std::string + do_createNexus(bool goofyWeights = true, + const std::string &barefilename = "MDBoxTest.nxs") { // Box with 1000 events evenly spread MDBox<MDLeanEvent<3>, 3> b(sc.get()); MDEventsTestHelper::feedMDBox(&b, 1, 10, 0.5, 1.0); @@ -118,7 +121,7 @@ public: auto Saver = new BoxControllerNeXusIO(sc.get()); Saver->setDataType(b.getCoordType(), b.getEventType()); - std::string filename = do_deleteNexusFile(barefilename); + std::string filename = do_deleteNexusFile(std::move(barefilename)); Saver->openFile(filename, "w"); diff --git a/Framework/DataObjects/test/MDEventWorkspaceTest.h b/Framework/DataObjects/test/MDEventWorkspaceTest.h index 3511ed772c791b9d0a54283014f87a926beae3b0..3f1d9a598ee544da4169d50e25e7a0a5d98cbcbc 100644 --- a/Framework/DataObjects/test/MDEventWorkspaceTest.h +++ b/Framework/DataObjects/test/MDEventWorkspaceTest.h @@ -40,7 +40,7 @@ class MDEventWorkspaceTest : public CxxTest::TestSuite { private: /// Helper function to return the number of masked bins in a workspace. TODO: /// move helper into test helpers - size_t getNumberMasked(Mantid::API::IMDWorkspace_sptr ws) { + size_t getNumberMasked(const Mantid::API::IMDWorkspace_sptr &ws) { auto it = ws->createIterator(nullptr); size_t numberMasked = 0; size_t counter = 0; @@ -479,7 +479,7 @@ public: TS_ASSERT_DELTA(ext[1].getMax(), ymax, 1e-4); } - void addEvent(MDEventWorkspace2Lean::sptr b, double x, double y) { + void addEvent(const MDEventWorkspace2Lean::sptr &b, double x, double y) { coord_t centers[2] = {static_cast<coord_t>(x), static_cast<coord_t>(y)}; b->addEvent(MDLeanEvent<2>(2.0, 2.0, centers)); } diff --git a/Framework/DataObjects/test/MDGridBoxTest.h b/Framework/DataObjects/test/MDGridBoxTest.h index b424ddcef7959ad0ea6082d9ccf11f87ebba99ed..500e4f3c403ab1f0988823391a33c6904370986a 100644 --- a/Framework/DataObjects/test/MDGridBoxTest.h +++ b/Framework/DataObjects/test/MDGridBoxTest.h @@ -1205,7 +1205,8 @@ public: */ void do_check_integrateSphere(MDGridBox<MDLeanEvent<2>, 2> &box, double x, double y, const double radius, - double numExpected, std::string message) { + double numExpected, + const std::string &message) { // The sphere transformation bool dimensionsUsed[2] = {true, true}; coord_t center[2] = {static_cast<coord_t>(x), static_cast<coord_t>(y)}; @@ -1336,7 +1337,8 @@ public: */ void do_check_integrateSphere3d(MDGridBox<MDLeanEvent<3>, 3> &box, double x, double y, double z, const double radius, - double numExpected, std::string message) { + double numExpected, + const std::string &message) { // The sphere transformation bool dimensionsUsed[3] = {true, true, true}; coord_t center[3] = {static_cast<coord_t>(x), static_cast<coord_t>(y), @@ -1394,7 +1396,7 @@ public: void do_check_centroidSphere(MDGridBox<MDLeanEvent<2>, 2> &box, double x, double y, const double radius, double numExpected, double xExpected, - double yExpected, std::string message) { + double yExpected, const std::string &message) { // The sphere transformation bool dimensionsUsed[2] = {true, true}; coord_t center[2] = {static_cast<coord_t>(x), static_cast<coord_t>(y)}; diff --git a/Framework/DataObjects/test/MDHistoWorkspaceIteratorTest.h b/Framework/DataObjects/test/MDHistoWorkspaceIteratorTest.h index c11dcdce2cd0e448672b75c4863c9550c5089721..37a9635c1505237544603a38c04670b66f0044c9 100644 --- a/Framework/DataObjects/test/MDHistoWorkspaceIteratorTest.h +++ b/Framework/DataObjects/test/MDHistoWorkspaceIteratorTest.h @@ -17,6 +17,8 @@ #include "MantidTestHelpers/MDEventsTestHelper.h" #include <boost/scoped_ptr.hpp> #include <cmath> +#include <utility> + #include <cxxtest/TestSuite.h> using namespace Mantid; @@ -36,7 +38,7 @@ private: class WritableHistoWorkspace : public Mantid::DataObjects::MDHistoWorkspace { public: WritableHistoWorkspace(MDHistoDimension_sptr x) - : Mantid::DataObjects::MDHistoWorkspace(x) {} + : Mantid::DataObjects::MDHistoWorkspace(std::move(x)) {} void setMaskValueAt(size_t at, bool value) { m_masks[at] = value; } }; @@ -366,8 +368,8 @@ public: } void do_test_neighbours_1d( - boost::function<std::vector<size_t>(MDHistoWorkspaceIterator *)> - findNeighbourMemberFunction) { + const boost::function<std::vector<size_t>(MDHistoWorkspaceIterator *)> + &findNeighbourMemberFunction) { const size_t nd = 1; MDHistoWorkspace_sptr ws = MDEventsTestHelper::makeFakeMDHistoWorkspace(1.0, nd, 10); diff --git a/Framework/DataObjects/test/MDHistoWorkspaceTest.h b/Framework/DataObjects/test/MDHistoWorkspaceTest.h index b61710991258ca8ae738dadedd8f35834690cbcc..4225ef8039248a2700faa4308ef0e1ed8f20c264 100644 --- a/Framework/DataObjects/test/MDHistoWorkspaceTest.h +++ b/Framework/DataObjects/test/MDHistoWorkspaceTest.h @@ -37,7 +37,7 @@ class MDHistoWorkspaceTest : public CxxTest::TestSuite { private: /// Helper function to return the number of masked bins in a workspace. TODO: /// move helper into test helpers - size_t getNumberMasked(Mantid::API::IMDWorkspace_sptr ws) { + size_t getNumberMasked(const Mantid::API::IMDWorkspace_sptr &ws) { auto it = ws->createIterator(nullptr); size_t numberMasked = 0; size_t counter = 0; @@ -93,7 +93,7 @@ public: } /** Check that a workspace has the right signal/error*/ - void checkWorkspace(MDHistoWorkspace_sptr ws, double expectedSignal, + void checkWorkspace(const MDHistoWorkspace_sptr &ws, double expectedSignal, double expectedErrorSquared, double expectedNumEvents = 1.0) { for (size_t i = 0; i < ws->getNPoints(); i++) { diff --git a/Framework/DataObjects/test/PeaksWorkspaceTest.h b/Framework/DataObjects/test/PeaksWorkspaceTest.h index 41edfbeef31db35c3698535b5dbdf9d32dfcfe83..da1044841203748e52fb814c0c1107b0a39558d7 100644 --- a/Framework/DataObjects/test/PeaksWorkspaceTest.h +++ b/Framework/DataObjects/test/PeaksWorkspaceTest.h @@ -140,9 +140,6 @@ public: } void test_Save_Unmodified_PeaksWorkspace_Nexus() { - - const std::string filename = - "test_Save_Unmodified_PeaksWorkspace_Nexus.nxs"; auto testPWS = createSaveTestPeaksWorkspace(); NexusTestHelper nexusHelper(true); nexusHelper.createFile("testSavePeaksWorkspace.nxs"); diff --git a/Framework/DataObjects/test/WeightedEventTest.h b/Framework/DataObjects/test/WeightedEventTest.h index 7c22aa630fb8a34f9bcd7dc86b2318906276a845..621d22978ef0873674d6dc30e42fcc84f6f1c172 100644 --- a/Framework/DataObjects/test/WeightedEventTest.h +++ b/Framework/DataObjects/test/WeightedEventTest.h @@ -62,6 +62,7 @@ public: // Copy constructor we = WeightedEvent(); we2 = WeightedEvent(456, 789, 2.5, 1.5 * 1.5); + // cppcheck-suppress redundantAssignment we = we2; TS_ASSERT_EQUALS(we.tof(), 456); TS_ASSERT_EQUALS(we.pulseTime(), 789); diff --git a/Framework/DataObjects/test/WorkspaceCreationTest.h b/Framework/DataObjects/test/WorkspaceCreationTest.h index 9f7e009d7cfef3888534df964cfa34b1ca58c401..fb3c4f964ddaf9e9bf671304ab8a20eaecdd4602 100644 --- a/Framework/DataObjects/test/WorkspaceCreationTest.h +++ b/Framework/DataObjects/test/WorkspaceCreationTest.h @@ -78,7 +78,7 @@ void run_create_partitioned_parent(const Parallel::Communicator &comm) { void run_create_partitioned_with_instrument( const Parallel::Communicator &comm, - boost::shared_ptr<Geometry::Instrument> instrument) { + const boost::shared_ptr<Geometry::Instrument> &instrument) { IndexInfo indices(4, Parallel::StorageMode::Distributed, comm); // should a nullptr spectrum definitions vector indicate building default // defs? diff --git a/Framework/Geometry/inc/MantidGeometry/Crystal/EdgePixel.h b/Framework/Geometry/inc/MantidGeometry/Crystal/EdgePixel.h index 00ce398a372b3daf2422c412f2f86552d1f60dc9..d3ac30bf65e1c8ea237abfb10225d2b77792fb25 100644 --- a/Framework/Geometry/inc/MantidGeometry/Crystal/EdgePixel.h +++ b/Framework/Geometry/inc/MantidGeometry/Crystal/EdgePixel.h @@ -12,9 +12,9 @@ namespace Mantid { namespace Geometry { /// Function to find peaks near detector edge -MANTID_GEOMETRY_DLL bool edgePixel(Geometry::Instrument_const_sptr inst, - std::string bankName, int col, int row, - int Edge); +MANTID_GEOMETRY_DLL bool edgePixel(const Geometry::Instrument_const_sptr &inst, + const std::string &bankName, int col, + int row, int Edge); } // namespace Geometry } // namespace Mantid diff --git a/Framework/Geometry/inc/MantidGeometry/Crystal/IndexingUtils.h b/Framework/Geometry/inc/MantidGeometry/Crystal/IndexingUtils.h index e9692b677e2ef62532df0803ca10a21ef0ed5465..1bdbb3d855840e9e54265edeab1f352779bd3967 100644 --- a/Framework/Geometry/inc/MantidGeometry/Crystal/IndexingUtils.h +++ b/Framework/Geometry/inc/MantidGeometry/Crystal/IndexingUtils.h @@ -238,8 +238,8 @@ public: /// Choose the direction in a list of directions, that is most nearly /// perpendicular to planes with the specified spacing in reciprocal space. static int SelectDirection(Kernel::V3D &best_direction, - const std::vector<Kernel::V3D> q_vectors, - const std::vector<Kernel::V3D> direction_list, + const std::vector<Kernel::V3D> &q_vectors, + const std::vector<Kernel::V3D> &direction_list, double plane_spacing, double required_tolerance); /// Get the lattice parameters for the specified orientation matrix diff --git a/Framework/Geometry/inc/MantidGeometry/Crystal/PeakTransformSelector.h b/Framework/Geometry/inc/MantidGeometry/Crystal/PeakTransformSelector.h index 16d7c98c0e7a37d840aa29e12ce684cfeff2aca4..12cfb9f9ecf42dcde44aab5ac24401342f5f7de2 100644 --- a/Framework/Geometry/inc/MantidGeometry/Crystal/PeakTransformSelector.h +++ b/Framework/Geometry/inc/MantidGeometry/Crystal/PeakTransformSelector.h @@ -21,15 +21,15 @@ public: /// Constructor PeakTransformSelector(); /// Register a candidate factory - void registerCandidate(PeakTransformFactory_sptr candidate); + void registerCandidate(const PeakTransformFactory_sptr &candidate); /// Make choice - PeakTransformFactory_sptr makeChoice(const std::string labelX, - const std::string labelY) const; + PeakTransformFactory_sptr makeChoice(const std::string &labelX, + const std::string &labelY) const; /// Make default choice PeakTransformFactory_sptr makeDefaultChoice() const; /// Has a factory capable of the requested transform. - bool hasFactoryForTransform(const std::string labelX, - const std::string labelY) const; + bool hasFactoryForTransform(const std::string &labelX, + const std::string &labelY) const; /// Get the number of registered factories size_t numberRegistered() const; diff --git a/Framework/Geometry/inc/MantidGeometry/Crystal/ReflectionGenerator.h b/Framework/Geometry/inc/MantidGeometry/Crystal/ReflectionGenerator.h index 06ac79c29864723597f2d3ddbfef4c78aed691fa..e1f62dd93cd1d823ed5f2b718583602fb4e0a9a1 100644 --- a/Framework/Geometry/inc/MantidGeometry/Crystal/ReflectionGenerator.h +++ b/Framework/Geometry/inc/MantidGeometry/Crystal/ReflectionGenerator.h @@ -105,12 +105,12 @@ public: std::vector<Kernel::V3D> getHKLs(double dMin, double dMax) const; std::vector<Kernel::V3D> getHKLs(double dMin, double dMax, - HKLFilter_const_sptr reflectionConditionFilter) const; + const HKLFilter_const_sptr &reflectionConditionFilter) const; std::vector<Kernel::V3D> getUniqueHKLs(double dMin, double dMax) const; std::vector<Kernel::V3D> getUniqueHKLs(double dMin, double dMax, - HKLFilter_const_sptr reflectionConditionFilter) const; + const HKLFilter_const_sptr &reflectionConditionFilter) const; std::vector<double> getDValues(const std::vector<Kernel::V3D> &hkls) const; std::vector<double> getFsSquared(const std::vector<Kernel::V3D> &hkls) const; diff --git a/Framework/Geometry/inc/MantidGeometry/Crystal/SpaceGroupFactory.h b/Framework/Geometry/inc/MantidGeometry/Crystal/SpaceGroupFactory.h index 8b82398ae824f4c6520f359284e7719508e06386..d0c4ffcef036fe5cb17149494d5ac4b07938fa50 100644 --- a/Framework/Geometry/inc/MantidGeometry/Crystal/SpaceGroupFactory.h +++ b/Framework/Geometry/inc/MantidGeometry/Crystal/SpaceGroupFactory.h @@ -236,7 +236,7 @@ protected: SpaceGroup_const_sptr getPrototype(const std::string &hmSymbol); void subscribe(const AbstractSpaceGroupGenerator_sptr &generator); SpaceGroup_const_sptr - constructFromPrototype(const SpaceGroup_const_sptr prototype) const; + constructFromPrototype(const SpaceGroup_const_sptr &prototype) const; void fillPointGroupMap(); diff --git a/Framework/Geometry/inc/MantidGeometry/Instrument.h b/Framework/Geometry/inc/MantidGeometry/Instrument.h index 0f8bb0a2dbbc5c1a61ac004304897d9b99eb7be5..48fcfc2fc8c0c27c4cf6bc190565e8286b1a4ce0 100644 --- a/Framework/Geometry/inc/MantidGeometry/Instrument.h +++ b/Framework/Geometry/inc/MantidGeometry/Instrument.h @@ -48,8 +48,8 @@ public: /// String description of the type of component std::string type() const override { return "Instrument"; } - Instrument(const boost::shared_ptr<const Instrument> instr, - boost::shared_ptr<ParameterMap> map); + Instrument(const boost::shared_ptr<const Instrument> &instr, + const boost::shared_ptr<ParameterMap> &map); Instrument(); Instrument(const std::string &name); Instrument(const Instrument &); diff --git a/Framework/Geometry/inc/MantidGeometry/Instrument/Detector.h b/Framework/Geometry/inc/MantidGeometry/Instrument/Detector.h index 26b94a73de8a0d5e8aff17cc171c0a8d1e5a0e03..640bcd5bc6bcebf2376eb0c01ce6700ca2ebdd96 100644 --- a/Framework/Geometry/inc/MantidGeometry/Instrument/Detector.h +++ b/Framework/Geometry/inc/MantidGeometry/Instrument/Detector.h @@ -34,8 +34,8 @@ public: std::string type() const override { return "DetectorComponent"; } Detector(const std::string &name, int id, IComponent *parent); - Detector(const std::string &name, int id, boost::shared_ptr<IObject> shape, - IComponent *parent); + Detector(const std::string &name, int id, + const boost::shared_ptr<IObject> &shape, IComponent *parent); // functions inherited from IObjectComponent Component *clone() const override { return new Detector(*this); } diff --git a/Framework/Geometry/inc/MantidGeometry/Instrument/DetectorGroup.h b/Framework/Geometry/inc/MantidGeometry/Instrument/DetectorGroup.h index 317403878ad926bfb5264d31a7ffa8798a1b1104..1dcaa928b670281591db005cbca3944f692c04a3 100644 --- a/Framework/Geometry/inc/MantidGeometry/Instrument/DetectorGroup.h +++ b/Framework/Geometry/inc/MantidGeometry/Instrument/DetectorGroup.h @@ -30,7 +30,7 @@ public: DetectorGroup(); DetectorGroup(const std::vector<IDetector_const_sptr> &dets); - void addDetector(IDetector_const_sptr det); + void addDetector(const IDetector_const_sptr &det); // IDetector methods IDetector *cloneParameterized(const ParameterMap *) const override { diff --git a/Framework/Geometry/inc/MantidGeometry/Instrument/Goniometer.h b/Framework/Geometry/inc/MantidGeometry/Instrument/Goniometer.h index 609b51e4e840e6c1ac341b62245594ba2a1de898..e09c1b7301e6ba95ea4f81b8f1150747d972a45f 100644 --- a/Framework/Geometry/inc/MantidGeometry/Instrument/Goniometer.h +++ b/Framework/Geometry/inc/MantidGeometry/Instrument/Goniometer.h @@ -11,6 +11,7 @@ #include "MantidKernel/V3D.h" #include <nexus/NeXusFile.hpp> #include <string> +#include <utility> namespace Mantid { namespace Geometry { @@ -43,8 +44,8 @@ struct GoniometerAxis { /// Constructor GoniometerAxis(std::string initname, Kernel::V3D initrotationaxis, double initangle, int initsense, int initangleunit) - : name(initname), rotationaxis(initrotationaxis), angle(initangle), - sense(initsense), angleunit(initangleunit) {} + : name(std::move(initname)), rotationaxis(initrotationaxis), + angle(initangle), sense(initsense), angleunit(initangleunit) {} GoniometerAxis() : name(""), rotationaxis(), angle(0.), sense(0), angleunit(0) {} @@ -57,7 +58,7 @@ public: // Default constructor Goniometer(); // Constructor from a rotation matrix - Goniometer(Kernel::DblMatrix rot); + Goniometer(const Kernel::DblMatrix &rot); // Default destructor virtual ~Goniometer() = default; // Return rotation matrix @@ -67,11 +68,12 @@ public: // Return information about axes std::string axesInfo(); // Add axis to goniometer - void pushAxis(std::string name, double axisx, double axisy, double axisz, - double angle = 0., int sense = CCW, int angUnit = angDegrees); + void pushAxis(const std::string &name, double axisx, double axisy, + double axisz, double angle = 0., int sense = CCW, + int angUnit = angDegrees); // Set rotation angle for an axis in the units the angle is set (default -- // degrees) - void setRotationAngle(std::string name, double value); + void setRotationAngle(const std::string &name, double value); // Set rotation angle for an axis in the units the angle is set (default -- // degrees) void setRotationAngle(size_t axisnumber, double value); @@ -83,13 +85,13 @@ public: // Get axis object const GoniometerAxis &getAxis(size_t axisnumber) const; // Get axis object - const GoniometerAxis &getAxis(std::string axisname) const; + const GoniometerAxis &getAxis(const std::string &axisname) const; // Return the number of axes size_t getNumberAxes() const; // Make a default universal goniometer void makeUniversalGoniometer(); // Return Euler angles acording to a convention - std::vector<double> getEulerAngles(std::string convention = "YZX"); + std::vector<double> getEulerAngles(const std::string &convention = "YZX"); void saveNexus(::NeXus::File *file, const std::string &group) const; void loadNexus(::NeXus::File *file, const std::string &group); diff --git a/Framework/Geometry/inc/MantidGeometry/Instrument/GridDetectorPixel.h b/Framework/Geometry/inc/MantidGeometry/Instrument/GridDetectorPixel.h index c98e4fdbd7fd598dd5b90d10e56b1a9bab8a64fa..6d638a04a11c62e990f3c7f62725fcdc8540e09f 100644 --- a/Framework/Geometry/inc/MantidGeometry/Instrument/GridDetectorPixel.h +++ b/Framework/Geometry/inc/MantidGeometry/Instrument/GridDetectorPixel.h @@ -34,7 +34,7 @@ public: virtual std::string type() const override { return "GridDetectorPixel"; } GridDetectorPixel(const std::string &name, int id, - boost::shared_ptr<IObject> shape, IComponent *parent, + const boost::shared_ptr<IObject> &shape, IComponent *parent, const GridDetector *panel, size_t col, size_t row, size_t layer); diff --git a/Framework/Geometry/inc/MantidGeometry/Instrument/InstrumentDefinitionParser.h b/Framework/Geometry/inc/MantidGeometry/Instrument/InstrumentDefinitionParser.h index e8d10918a2dbf4e07d79ada5b1dca1d7cc8d7620..216f9883eab3dfa57c560a4ff11dac9b1db65fa8 100644 --- a/Framework/Geometry/inc/MantidGeometry/Instrument/InstrumentDefinitionParser.h +++ b/Framework/Geometry/inc/MantidGeometry/Instrument/InstrumentDefinitionParser.h @@ -47,8 +47,8 @@ public: InstrumentDefinitionParser(const std::string &filename, const std::string &instName, const std::string &xmlText); - InstrumentDefinitionParser(const IDFObject_const_sptr xmlFile, - const IDFObject_const_sptr expectedCacheFile, + InstrumentDefinitionParser(const IDFObject_const_sptr &xmlFile, + const IDFObject_const_sptr &expectedCacheFile, const std::string &instName, const std::string &xmlText); ~InstrumentDefinitionParser() = default; @@ -153,7 +153,7 @@ private: const Poco::XML::Element *pCompElem, IdList &idList); /// Return true if assembly, false if not assembly and throws exception if /// string not in assembly - bool isAssembly(std::string) const; + bool isAssembly(const std::string &) const; /// Add XML element to parent assuming the element contains no other component /// elements @@ -263,7 +263,7 @@ private: Poco::XML::Element *pRootElem); /// Check IdList - void checkIdListExistsAndDefinesEnoughIDs(IdList idList, + void checkIdListExistsAndDefinesEnoughIDs(const IdList &idList, Poco::XML::Element *pElem, const std::string &filename) const; @@ -290,7 +290,7 @@ public: // for testing private: /// Reads from a cache file. - void applyCache(IDFObject_const_sptr cacheToApply); + void applyCache(const IDFObject_const_sptr &cacheToApply); /// Write out a cache file. CachingOption writeAndApplyCache(IDFObject_const_sptr firstChoiceCache, diff --git a/Framework/Geometry/inc/MantidGeometry/Instrument/ParComponentFactory.h b/Framework/Geometry/inc/MantidGeometry/Instrument/ParComponentFactory.h index 31ca5b2f1441ecaded68dba5949668014e1cab9a..572eba65c9037f634364935e9770935bc93504bc 100644 --- a/Framework/Geometry/inc/MantidGeometry/Instrument/ParComponentFactory.h +++ b/Framework/Geometry/inc/MantidGeometry/Instrument/ParComponentFactory.h @@ -44,7 +44,8 @@ public: /// Create a parameterized component from the given base component and /// ParameterMap static boost::shared_ptr<IComponent> - create(boost::shared_ptr<const IComponent> base, const ParameterMap *map); + create(const boost::shared_ptr<const IComponent> &base, + const ParameterMap *map); }; } // Namespace Geometry diff --git a/Framework/Geometry/inc/MantidGeometry/Instrument/SampleEnvironment.h b/Framework/Geometry/inc/MantidGeometry/Instrument/SampleEnvironment.h index 8091db541cfd43b020e1fd063fa511e0b971b44d..e813f64165f1af3013386a4b71487501ba56a4c9 100644 --- a/Framework/Geometry/inc/MantidGeometry/Instrument/SampleEnvironment.h +++ b/Framework/Geometry/inc/MantidGeometry/Instrument/SampleEnvironment.h @@ -25,7 +25,7 @@ class Track; */ class MANTID_GEOMETRY_DLL SampleEnvironment { public: - SampleEnvironment(std::string name, Container_const_sptr getContainer); + SampleEnvironment(std::string name, const Container_const_sptr &getContainer); /// @return The name of kit inline const std::string name() const { return m_name; } diff --git a/Framework/Geometry/inc/MantidGeometry/MDGeometry/CompositeImplicitFunction.h b/Framework/Geometry/inc/MantidGeometry/MDGeometry/CompositeImplicitFunction.h index a6207bb04d1198c033c16d5a479e9082bbaea568..8d40acfdbfe4bae85382bd8b1f9212d252794244 100644 --- a/Framework/Geometry/inc/MantidGeometry/MDGeometry/CompositeImplicitFunction.h +++ b/Framework/Geometry/inc/MantidGeometry/MDGeometry/CompositeImplicitFunction.h @@ -38,8 +38,8 @@ public: using MDImplicitFunction::isPointContained; //----------------------------------------------------------------- - bool - addFunction(Mantid::Geometry::MDImplicitFunction_sptr constituentFunction); + bool addFunction( + const Mantid::Geometry::MDImplicitFunction_sptr &constituentFunction); std::string getName() const override; std::string toXMLString() const override; int getNFunctions() const; diff --git a/Framework/Geometry/inc/MantidGeometry/MDGeometry/MDGeometryXMLBuilder.h b/Framework/Geometry/inc/MantidGeometry/MDGeometry/MDGeometryXMLBuilder.h index c4a67ea306874f3ae071b364bcc25d6b1c7247b7..e5a4a0f408b5fc8f1e91cdc22f2cdbee4de9107c 100644 --- a/Framework/Geometry/inc/MantidGeometry/MDGeometry/MDGeometryXMLBuilder.h +++ b/Framework/Geometry/inc/MantidGeometry/MDGeometry/MDGeometryXMLBuilder.h @@ -41,19 +41,19 @@ public: bool addOrdinaryDimension(IMDDimension_const_sptr dimensionToAdd) const; /// Add many ordinary dimensions. - void addManyOrdinaryDimensions(VecIMDDimension_sptr manyDims) const; + void addManyOrdinaryDimensions(const VecIMDDimension_sptr &manyDims) const; /// Add x dimension. - bool addXDimension(IMDDimension_const_sptr dimension) const; + bool addXDimension(const IMDDimension_const_sptr &dimension) const; /// Add y dimension. - bool addYDimension(IMDDimension_const_sptr dimension) const; + bool addYDimension(const IMDDimension_const_sptr &dimension) const; /// Add z dimension. - bool addZDimension(IMDDimension_const_sptr dimension) const; + bool addZDimension(const IMDDimension_const_sptr &dimension) const; /// Add t dimension. - bool addTDimension(IMDDimension_const_sptr dimension) const; + bool addTDimension(const IMDDimension_const_sptr &dimension) const; /// Copy constructor MDGeometryBuilderXML(const MDGeometryBuilderXML &); diff --git a/Framework/Geometry/inc/MantidGeometry/MDGeometry/MDGeometryXMLParser.h b/Framework/Geometry/inc/MantidGeometry/MDGeometry/MDGeometryXMLParser.h index 63d314d3a6929cccb6ed69670d071ab7d934cc6c..5ee60ef9f817acd0b40598af9841912d848bd86e 100644 --- a/Framework/Geometry/inc/MantidGeometry/MDGeometry/MDGeometryXMLParser.h +++ b/Framework/Geometry/inc/MantidGeometry/MDGeometry/MDGeometryXMLParser.h @@ -78,13 +78,13 @@ public: bool hasTDimension() const; - bool isXDimension(Mantid::Geometry::IMDDimension_sptr) const; + bool isXDimension(const Mantid::Geometry::IMDDimension_sptr &) const; - bool isYDimension(Mantid::Geometry::IMDDimension_sptr) const; + bool isYDimension(const Mantid::Geometry::IMDDimension_sptr &) const; - bool isZDimension(Mantid::Geometry::IMDDimension_sptr) const; + bool isZDimension(const Mantid::Geometry::IMDDimension_sptr &) const; - bool isTDimension(Mantid::Geometry::IMDDimension_sptr) const; + bool isTDimension(const Mantid::Geometry::IMDDimension_sptr &) const; void SetRootNodeCheck(std::string elementName); diff --git a/Framework/Geometry/inc/MantidGeometry/MDGeometry/MDHistoDimension.h b/Framework/Geometry/inc/MantidGeometry/MDGeometry/MDHistoDimension.h index ba3af9311f5d43f65452ace43c2d4ab709b0a3b2..9db0adde02d2d60f43ca766c73858cb53c9b77a2 100644 --- a/Framework/Geometry/inc/MantidGeometry/MDGeometry/MDHistoDimension.h +++ b/Framework/Geometry/inc/MantidGeometry/MDGeometry/MDHistoDimension.h @@ -6,6 +6,8 @@ // SPDX - License - Identifier: GPL - 3.0 + #pragma once +#include <utility> + #include "MantidGeometry/DllConfig.h" #include "MantidGeometry/MDGeometry/IMDDimension.h" #include "MantidGeometry/MDGeometry/MDFrame.h" @@ -38,8 +40,8 @@ public: */ MDHistoDimension(std::string name, std::string ID, const MDFrame &frame, coord_t min, coord_t max, size_t numBins) - : m_name(name), m_dimensionId(ID), m_frame(frame.clone()), m_min(min), - m_max(max), m_numBins(numBins), + : m_name(std::move(name)), m_dimensionId(std::move(ID)), + m_frame(frame.clone()), m_min(min), m_max(max), m_numBins(numBins), m_binWidth((max - min) / static_cast<coord_t>(numBins)) { if (max < min) { throw std::invalid_argument("Error making MDHistoDimension. Cannot have " diff --git a/Framework/Geometry/inc/MantidGeometry/MDGeometry/MDHistoDimensionBuilder.h b/Framework/Geometry/inc/MantidGeometry/MDGeometry/MDHistoDimensionBuilder.h index ebaa932eeb26df327426360650084abdfcfab807..7443fdb7b7d6415374b8f73f4db5fcdc714fdacb 100644 --- a/Framework/Geometry/inc/MantidGeometry/MDGeometry/MDHistoDimensionBuilder.h +++ b/Framework/Geometry/inc/MantidGeometry/MDGeometry/MDHistoDimensionBuilder.h @@ -50,7 +50,7 @@ public: } MDHistoDimensionBuilder(); - void setName(std::string name); + void setName(const std::string &name); void setId(std::string id); void setUnits(const Kernel::UnitLabel &units); void setMin(double min); diff --git a/Framework/Geometry/inc/MantidGeometry/Objects/CSGObject.h b/Framework/Geometry/inc/MantidGeometry/Objects/CSGObject.h index eda75d48203f0e5e9c3c6f06f6e46996ce82fe0f..31e0e3af432d6431bf7ac8ad50ee8e28bc0b6747 100644 --- a/Framework/Geometry/inc/MantidGeometry/Objects/CSGObject.h +++ b/Framework/Geometry/inc/MantidGeometry/Objects/CSGObject.h @@ -179,7 +179,7 @@ public: // Get Geometry Handler boost::shared_ptr<GeometryHandler> getGeometryHandler() const override; /// Set Geometry Handler - void setGeometryHandler(boost::shared_ptr<GeometryHandler> h); + void setGeometryHandler(const boost::shared_ptr<GeometryHandler> &h); /// set vtkGeometryCache writer void setVtkGeometryCacheWriter(boost::shared_ptr<vtkGeometryCacheWriter>); diff --git a/Framework/Geometry/inc/MantidGeometry/Objects/MeshObject.h b/Framework/Geometry/inc/MantidGeometry/Objects/MeshObject.h index 737d5ba3145bb92f7d63829bfcb7d510e1d973e8..1fd45dfea1bbc325ac5d736dbc8f96e5673c6bd4 100644 --- a/Framework/Geometry/inc/MantidGeometry/Objects/MeshObject.h +++ b/Framework/Geometry/inc/MantidGeometry/Objects/MeshObject.h @@ -51,7 +51,7 @@ public: /// Constructor MeshObject(const std::vector<uint32_t> &faces, const std::vector<Kernel::V3D> &vertices, - const Kernel::Material material); + const Kernel::Material &material); /// Constructor MeshObject(std::vector<uint32_t> &&faces, std::vector<Kernel::V3D> &&vertices, const Kernel::Material &&material); @@ -126,7 +126,7 @@ public: // Get Geometry Handler boost::shared_ptr<GeometryHandler> getGeometryHandler() const override; /// Set Geometry Handler - void setGeometryHandler(boost::shared_ptr<GeometryHandler> h); + void setGeometryHandler(const boost::shared_ptr<GeometryHandler> &h); detail::ShapeInfo::GeometryShape shape() const override; const detail::ShapeInfo &shapeInfo() const override; diff --git a/Framework/Geometry/inc/MantidGeometry/Rendering/GeometryHandler.h b/Framework/Geometry/inc/MantidGeometry/Rendering/GeometryHandler.h index 639670b7ad5c4d4c0ecf60b622fda3a153ec1e78..33b28379aab1ebe207310f9947ab52cf9d850064 100644 --- a/Framework/Geometry/inc/MantidGeometry/Rendering/GeometryHandler.h +++ b/Framework/Geometry/inc/MantidGeometry/Rendering/GeometryHandler.h @@ -76,9 +76,9 @@ protected: nullptr; ///< ObjComponent that uses this geometry handler CSGObject *m_csgObj = nullptr; ///< Object that uses this geometry handler public: - GeometryHandler(IObjComponent *comp); ///< Constructor - GeometryHandler(boost::shared_ptr<CSGObject> obj); ///< Constructor - GeometryHandler(CSGObject *obj); ///< Constructor + GeometryHandler(IObjComponent *comp); ///< Constructor + GeometryHandler(const boost::shared_ptr<CSGObject> &obj); ///< Constructor + GeometryHandler(CSGObject *obj); ///< Constructor GeometryHandler(const MeshObject &obj); GeometryHandler(const MeshObject2D &obj); GeometryHandler(const GeometryHandler &handler); diff --git a/Framework/Geometry/inc/MantidGeometry/Rendering/vtkGeometryCacheReader.h b/Framework/Geometry/inc/MantidGeometry/Rendering/vtkGeometryCacheReader.h index 1f99fc99567c8f396a74db74ba318e5c7c14578f..7cee8e07227fc51c0ed7d23e6cb3b2b49c89d06e 100644 --- a/Framework/Geometry/inc/MantidGeometry/Rendering/vtkGeometryCacheReader.h +++ b/Framework/Geometry/inc/MantidGeometry/Rendering/vtkGeometryCacheReader.h @@ -37,7 +37,7 @@ private: std::string mFileName; ///< The file name // Private Methods void Init(); - Poco::XML::Element *getElementByObjectName(std::string name); + Poco::XML::Element *getElementByObjectName(const std::string &name); void readPoints(Poco::XML::Element *pEle, int noOfPoints, std::vector<double> &points); void readTriangles(Poco::XML::Element *pEle, int noOfTriangles, diff --git a/Framework/Geometry/src/Crystal/EdgePixel.cpp b/Framework/Geometry/src/Crystal/EdgePixel.cpp index e62018bb6b9b89db33a16468d8ec31ce8edfda5d..807ef1678c116ff466d5e19cc62091f90d9f1a94 100644 --- a/Framework/Geometry/src/Crystal/EdgePixel.cpp +++ b/Framework/Geometry/src/Crystal/EdgePixel.cpp @@ -20,8 +20,8 @@ namespace Geometry { @param Edge Number of edge points for each bank @return True if peak is on edge */ -bool edgePixel(Mantid::Geometry::Instrument_const_sptr inst, - std::string bankName, int col, int row, int Edge) { +bool edgePixel(const Mantid::Geometry::Instrument_const_sptr &inst, + const std::string &bankName, int col, int row, int Edge) { if (bankName == "None") return false; boost::shared_ptr<const Geometry::IComponent> parent = diff --git a/Framework/Geometry/src/Crystal/IndexingUtils.cpp b/Framework/Geometry/src/Crystal/IndexingUtils.cpp index adc2ac568b96f09faee51f9b9e0d1ab0d9cac41c..ba096aaa319b5a61edeaaa00d3153e26efb3b4bd 100644 --- a/Framework/Geometry/src/Crystal/IndexingUtils.cpp +++ b/Framework/Geometry/src/Crystal/IndexingUtils.cpp @@ -2854,8 +2854,8 @@ std::vector<V3D> IndexingUtils::MakeCircleDirections(int n_steps, specified. */ int IndexingUtils::SelectDirection(V3D &best_direction, - const std::vector<V3D> q_vectors, - const std::vector<V3D> direction_list, + const std::vector<V3D> &q_vectors, + const std::vector<V3D> &direction_list, double plane_spacing, double required_tolerance) { if (q_vectors.empty()) { diff --git a/Framework/Geometry/src/Crystal/PeakTransformSelector.cpp b/Framework/Geometry/src/Crystal/PeakTransformSelector.cpp index 97fb701e35409643c637c88112048e71b3d56bc4..4eb89198f83c1b61d38384b3dfb9e2131864486b 100644 --- a/Framework/Geometry/src/Crystal/PeakTransformSelector.cpp +++ b/Framework/Geometry/src/Crystal/PeakTransformSelector.cpp @@ -17,7 +17,7 @@ Register a peak transform factory as a candidate. @param candidate : candidate peak transform factory */ void PeakTransformSelector::registerCandidate( - PeakTransformFactory_sptr candidate) { + const PeakTransformFactory_sptr &candidate) { m_candidateFactories.insert(candidate); } @@ -62,8 +62,8 @@ Make a choice for the peak transform factory. @return selected factory */ PeakTransformFactory_sptr -PeakTransformSelector::makeChoice(const std::string labelX, - const std::string labelY) const { +PeakTransformSelector::makeChoice(const std::string &labelX, + const std::string &labelY) const { if (labelX.empty()) { throw std::invalid_argument("labelX is empty"); } @@ -102,7 +102,7 @@ transformation. @return TRUE only if such a factory is available. */ bool PeakTransformSelector::hasFactoryForTransform( - const std::string labelX, const std::string labelY) const { + const std::string &labelX, const std::string &labelY) const { bool hasFactoryForTransform = true; try { this->makeChoice(labelX, labelY); diff --git a/Framework/Geometry/src/Crystal/ReflectionGenerator.cpp b/Framework/Geometry/src/Crystal/ReflectionGenerator.cpp index c64adeba704ffcf653af09feaee65334267e7a7d..39446f2ddda5bde7b67115c135bdb0c2795d5456 100644 --- a/Framework/Geometry/src/Crystal/ReflectionGenerator.cpp +++ b/Framework/Geometry/src/Crystal/ReflectionGenerator.cpp @@ -76,7 +76,7 @@ std::vector<V3D> ReflectionGenerator::getHKLs(double dMin, double dMax) const { /// filter. If the pointer is null, it's ignored. std::vector<Kernel::V3D> ReflectionGenerator::getHKLs( double dMin, double dMax, - HKLFilter_const_sptr reflectionConditionFilter) const { + const HKLFilter_const_sptr &reflectionConditionFilter) const { HKLGenerator generator(m_crystalStructure.cell(), dMin); HKLFilter_const_sptr filter = getDRangeFilter(dMin, dMax); @@ -103,7 +103,7 @@ std::vector<V3D> ReflectionGenerator::getUniqueHKLs(double dMin, /// d-limits using the specified reflection condition filter. std::vector<V3D> ReflectionGenerator::getUniqueHKLs( double dMin, double dMax, - HKLFilter_const_sptr reflectionConditionFilter) const { + const HKLFilter_const_sptr &reflectionConditionFilter) const { HKLGenerator generator(m_crystalStructure.cell(), dMin); HKLFilter_const_sptr filter = getDRangeFilter(dMin, dMax); diff --git a/Framework/Geometry/src/Crystal/SpaceGroupFactory.cpp b/Framework/Geometry/src/Crystal/SpaceGroupFactory.cpp index 4459809313ddbb8ee69cdf5c04e630ec6d38e281..6d6e4bfd014e79b37e2e26165092984d7e716585 100644 --- a/Framework/Geometry/src/Crystal/SpaceGroupFactory.cpp +++ b/Framework/Geometry/src/Crystal/SpaceGroupFactory.cpp @@ -405,7 +405,7 @@ std::string SpaceGroupFactoryImpl::getTransformedSymbolOrthorhombic( /// Returns a copy-constructed instance of the supplied space group prototype /// object. SpaceGroup_const_sptr SpaceGroupFactoryImpl::constructFromPrototype( - const SpaceGroup_const_sptr prototype) const { + const SpaceGroup_const_sptr &prototype) const { return boost::make_shared<const SpaceGroup>(*prototype); } diff --git a/Framework/Geometry/src/Instrument.cpp b/Framework/Geometry/src/Instrument.cpp index e5ed3e3a697c2d732e882b28b28065f87483e6f7..0b79e7780a543f5d9b3b23fb69f99fa65bd5ba81 100644 --- a/Framework/Geometry/src/Instrument.cpp +++ b/Framework/Geometry/src/Instrument.cpp @@ -24,6 +24,7 @@ #include <boost/make_shared.hpp> #include <nexus/NeXusFile.hpp> #include <queue> +#include <utility> using namespace Mantid::Kernel; using Mantid::Kernel::Exception::InstrumentDefinitionError; @@ -59,8 +60,8 @@ Instrument::Instrument(const std::string &name) * @param instr :: instrument for parameter inclusion * @param map :: parameter map to include */ -Instrument::Instrument(const boost::shared_ptr<const Instrument> instr, - boost::shared_ptr<ParameterMap> map) +Instrument::Instrument(const boost::shared_ptr<const Instrument> &instr, + const boost::shared_ptr<ParameterMap> &map) : CompAssembly(instr.get(), map.get()), m_sourceCache(instr->m_sourceCache), m_sampleCache(instr->m_sampleCache), m_defaultView(instr->m_defaultView), m_defaultViewAxis(instr->m_defaultViewAxis), m_instr(instr), @@ -1037,7 +1038,7 @@ Setter for the reference frame. @param frame : reference frame object to use. */ void Instrument::setReferenceFrame(boost::shared_ptr<ReferenceFrame> frame) { - m_referenceFrame = frame; + m_referenceFrame = std::move(frame); } /** diff --git a/Framework/Geometry/src/Instrument/Container.cpp b/Framework/Geometry/src/Instrument/Container.cpp index 86dcc73b9506a0d7473b5ee01ed425fde1197e88..85a74621aa406dc6262761619d47ee501407063d 100644 --- a/Framework/Geometry/src/Instrument/Container.cpp +++ b/Framework/Geometry/src/Instrument/Container.cpp @@ -16,6 +16,7 @@ #include "Poco/SAX/InputSource.h" #include "Poco/SAX/SAXException.h" #include <boost/make_shared.hpp> +#include <utility> namespace Mantid { namespace Geometry { @@ -55,7 +56,7 @@ void updateTreeValues(Poco::XML::Element *root, //------------------------------------------------------------------------------ Container::Container() : m_shape(boost::make_shared<CSGObject>()) {} -Container::Container(IObject_sptr shape) : m_shape(shape) {} +Container::Container(IObject_sptr shape) : m_shape(std::move(shape)) {} Container::Container(const Container &container) : m_shape(IObject_sptr(container.m_shape->clone())), diff --git a/Framework/Geometry/src/Instrument/Detector.cpp b/Framework/Geometry/src/Instrument/Detector.cpp index fee86e8d666b5a50385c24a3495bec1a5e3340b8..377b462a2763bab2e5ff1a92a71d5f0b0ba2463e 100644 --- a/Framework/Geometry/src/Instrument/Detector.cpp +++ b/Framework/Geometry/src/Instrument/Detector.cpp @@ -45,7 +45,7 @@ Detector::Detector(const std::string &name, int id, IComponent *parent) * @param parent :: The parent component */ Detector::Detector(const std::string &name, int id, - boost::shared_ptr<IObject> shape, IComponent *parent) + const boost::shared_ptr<IObject> &shape, IComponent *parent) : IDetector(), ObjComponent(name, shape, parent), m_id(id) {} /** Gets the detector id diff --git a/Framework/Geometry/src/Instrument/DetectorGroup.cpp b/Framework/Geometry/src/Instrument/DetectorGroup.cpp index a8623247a6c8c496698a8069556c4a474af27afd..11d099398512065632201a4459ada11fa9d4b765 100644 --- a/Framework/Geometry/src/Instrument/DetectorGroup.cpp +++ b/Framework/Geometry/src/Instrument/DetectorGroup.cpp @@ -49,7 +49,7 @@ DetectorGroup::DetectorGroup(const std::vector<IDetector_const_sptr> &dets) /** Add a detector to the collection * @param det :: A pointer to the detector to add */ -void DetectorGroup::addDetector(IDetector_const_sptr det) { +void DetectorGroup::addDetector(const IDetector_const_sptr &det) { // the topology of the group become undefined and needs recalculation if new // detector has been added to the group group_topology = undef; diff --git a/Framework/Geometry/src/Instrument/DetectorInfo.cpp b/Framework/Geometry/src/Instrument/DetectorInfo.cpp index 07f32908474b0797acdf5cbe587f82b5d3963eac..992682287becb3c0531d0bb1809873b1172d5861 100644 --- a/Framework/Geometry/src/Instrument/DetectorInfo.cpp +++ b/Framework/Geometry/src/Instrument/DetectorInfo.cpp @@ -4,10 +4,12 @@ // NScD Oak Ridge National Laboratory, European Spallation Source, // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + -#include "MantidGeometry/Instrument/DetectorInfo.h" +#include <utility> + #include "MantidBeamline/DetectorInfo.h" #include "MantidGeometry/Instrument.h" #include "MantidGeometry/Instrument/Detector.h" +#include "MantidGeometry/Instrument/DetectorInfo.h" #include "MantidGeometry/Instrument/DetectorInfoIterator.h" #include "MantidGeometry/Instrument/ReferenceFrame.h" #include "MantidKernel/EigenConversionHelpers.h" @@ -27,8 +29,10 @@ DetectorInfo::DetectorInfo( boost::shared_ptr<const std::vector<detid_t>> detectorIds, boost::shared_ptr<const std::unordered_map<detid_t, size_t>> detIdToIndexMap) - : m_detectorInfo(std::move(detectorInfo)), m_instrument(instrument), - m_detectorIDs(detectorIds), m_detIDToIndex(detIdToIndexMap), + : m_detectorInfo(std::move(detectorInfo)), + m_instrument(std::move(instrument)), + m_detectorIDs(std::move(detectorIds)), + m_detIDToIndex(std::move(detIdToIndexMap)), m_lastDetector(PARALLEL_GET_MAX_THREADS), m_lastIndex(PARALLEL_GET_MAX_THREADS, -1) { diff --git a/Framework/Geometry/src/Instrument/Goniometer.cpp b/Framework/Geometry/src/Instrument/Goniometer.cpp index 15b7efd2f212480b64025221d294b5682993932e..e2dd92bd4764f54b2ec037d0586a12a739f0c9fe 100644 --- a/Framework/Geometry/src/Instrument/Goniometer.cpp +++ b/Framework/Geometry/src/Instrument/Goniometer.cpp @@ -14,6 +14,8 @@ #include <sstream> #include <stdexcept> #include <string> +#include <utility> + #include <vector> using namespace Mantid::Kernel; @@ -64,7 +66,7 @@ Goniometer::Goniometer() : R(3, 3, true), initFromR(false) {} /// Constructor from a rotation matrix /// @param rot :: DblMatrix matrix that is going to be the internal rotation /// matrix of the goniometer. Cannot push additional axes -Goniometer::Goniometer(DblMatrix rot) { +Goniometer::Goniometer(const DblMatrix &rot) { DblMatrix ide(3, 3), rtr(3, 3); rtr = rot.Tprime() * rot; ide.identityMatrix(); @@ -83,7 +85,7 @@ const Kernel::DblMatrix &Goniometer::getR() const { return R; } /// @param rot :: DblMatrix matrix that is going to be the internal rotation /// matrix of the goniometer. void Goniometer::setR(Kernel::DblMatrix rot) { - R = rot; + R = std::move(rot); initFromR = true; } @@ -129,7 +131,7 @@ std::string Goniometer::axesInfo() { @param sense :: rotation sense (CW or CCW), CCW by default @param angUnit :: units for angle of type#AngleUnit, angDegrees by default */ -void Goniometer::pushAxis(std::string name, double axisx, double axisy, +void Goniometer::pushAxis(const std::string &name, double axisx, double axisy, double axisz, double angle, int sense, int angUnit) { if (initFromR) { throw std::runtime_error( @@ -160,7 +162,7 @@ void Goniometer::pushAxis(std::string name, double axisx, double axisy, @param name :: GoniometerAxis name @param value :: value in the units that the axis is set */ -void Goniometer::setRotationAngle(std::string name, double value) { +void Goniometer::setRotationAngle(const std::string &name, double value) { bool changed = false; std::vector<GoniometerAxis>::iterator it; for (it = motors.begin(); it < motors.end(); ++it) { @@ -255,7 +257,7 @@ const GoniometerAxis &Goniometer::getAxis(size_t axisnumber) const { /// Get GoniometerAxis object using motor name /// @param axisname :: axis name -const GoniometerAxis &Goniometer::getAxis(std::string axisname) const { +const GoniometerAxis &Goniometer::getAxis(const std::string &axisname) const { for (auto it = motors.begin(); it < motors.end(); ++it) { if (axisname == it->name) { return (*it); @@ -288,7 +290,7 @@ void Goniometer::makeUniversalGoniometer() { * @param convention :: the convention used to calculate Euler Angles. The * UniversalGoniometer is YZY, a triple axis goniometer at HFIR is YZX */ -std::vector<double> Goniometer::getEulerAngles(std::string convention) { +std::vector<double> Goniometer::getEulerAngles(const std::string &convention) { return Quat(getR()).getEulerAngles(convention); } diff --git a/Framework/Geometry/src/Instrument/GridDetector.cpp b/Framework/Geometry/src/Instrument/GridDetector.cpp index cefb9052583ceb751134e3b4f5e2db667b2a66d2..6acabcbfc1c8b972b2eb500cc69bbb03c40b4d55 100644 --- a/Framework/Geometry/src/Instrument/GridDetector.cpp +++ b/Framework/Geometry/src/Instrument/GridDetector.cpp @@ -23,6 +23,7 @@ #include <boost/regex.hpp> #include <ostream> #include <stdexcept> +#include <utility> namespace Mantid { namespace Geometry { @@ -548,7 +549,7 @@ void GridDetector::initializeValues(boost::shared_ptr<IObject> shape, m_xstep = xstep; m_ystep = ystep; m_zstep = zstep; - m_shape = shape; + m_shape = std::move(shape); /// IDs start here m_idstart = idstart; @@ -609,9 +610,9 @@ void GridDetector::initialize(boost::shared_ptr<IObject> shape, int xpixels, throw std::runtime_error("GridDetector::initialize() called for a " "parametrized GridDetector"); - initializeValues(shape, xpixels, xstart, xstep, ypixels, ystart, ystep, - zpixels, zstart, zstep, idstart, idFillOrder, idstepbyrow, - idstep); + initializeValues(std::move(shape), xpixels, xstart, xstep, ypixels, ystart, + ystep, zpixels, zstart, zstep, idstart, idFillOrder, + idstepbyrow, idstep); std::string name = this->getName(); int minDetId = idstart, maxDetId = idstart; diff --git a/Framework/Geometry/src/Instrument/GridDetectorPixel.cpp b/Framework/Geometry/src/Instrument/GridDetectorPixel.cpp index 065c74b89a104d4665b440abc6cb0742f6889d21..0f1f8ac41be4f08f3e04b3311b724cf2244bf54d 100644 --- a/Framework/Geometry/src/Instrument/GridDetectorPixel.cpp +++ b/Framework/Geometry/src/Instrument/GridDetectorPixel.cpp @@ -4,8 +4,10 @@ // NScD Oak Ridge National Laboratory, European Spallation Source, // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + -#include "MantidGeometry/Instrument/GridDetectorPixel.h" +#include <utility> + #include "MantidGeometry/Instrument/GridDetector.h" +#include "MantidGeometry/Instrument/GridDetectorPixel.h" #include "MantidKernel/System.h" #include "MantidKernel/V3D.h" @@ -36,12 +38,12 @@ GridDetectorPixel::GridDetectorPixel(const GridDetectorPixel *base, * @param layer :: layer of the pixel in the panel */ GridDetectorPixel::GridDetectorPixel(const std::string &name, int id, - boost::shared_ptr<IObject> shape, + const boost::shared_ptr<IObject> &shape, IComponent *parent, const GridDetector *panel, size_t col, size_t row, size_t layer) - : Detector(name, id, shape, parent), m_panel(panel), m_col(col), m_row(row), - m_layer(layer) { + : Detector(name, id, std::move(shape), parent), m_panel(panel), m_col(col), + m_row(row), m_layer(layer) { if (!m_panel) throw std::runtime_error("GridDetectorPixel::ctor(): pixel " + name + " has no valid GridDetector parent."); diff --git a/Framework/Geometry/src/Instrument/InstrumentDefinitionParser.cpp b/Framework/Geometry/src/Instrument/InstrumentDefinitionParser.cpp index aec5c955e3dbabc5ea302141bdef4e5c80a7e0ad..cce5e6cb36fd924e67a59339dd0c1008bfac9eed 100644 --- a/Framework/Geometry/src/Instrument/InstrumentDefinitionParser.cpp +++ b/Framework/Geometry/src/Instrument/InstrumentDefinitionParser.cpp @@ -39,6 +39,7 @@ #include <boost/make_shared.hpp> #include <boost/regex.hpp> #include <unordered_set> +#include <utility> using namespace Mantid; using namespace Mantid::Kernel; @@ -95,8 +96,8 @@ InstrumentDefinitionParser::InstrumentDefinitionParser( * @param xmlText :: XML contents of IDF */ InstrumentDefinitionParser::InstrumentDefinitionParser( - const IDFObject_const_sptr xmlFile, - const IDFObject_const_sptr expectedCacheFile, const std::string &instName, + const IDFObject_const_sptr &xmlFile, + const IDFObject_const_sptr &expectedCacheFile, const std::string &instName, const std::string &xmlText) : m_xmlFile(boost::make_shared<NullIDFObject>()), m_cacheFile(boost::make_shared<NullIDFObject>()), m_pDoc(nullptr), @@ -414,7 +415,7 @@ void InstrumentDefinitionParser::checkComponentContainsLocationElement( * @param filename :: Name of the IDF, for exception message */ void InstrumentDefinitionParser::checkIdListExistsAndDefinesEnoughIDs( - IdList idList, Element *pElem, const std::string &filename) const { + const IdList &idList, Element *pElem, const std::string &filename) const { if (idList.counted != static_cast<int>(idList.vec.size())) { std::stringstream ss1, ss2; ss1 << idList.vec.size(); @@ -1990,7 +1991,7 @@ void InstrumentDefinitionParser::populateIdList(Poco::XML::Element *pE, * @throw InstrumentDefinitionError Thrown if type not defined in XML *definition */ -bool InstrumentDefinitionParser::isAssembly(std::string type) const { +bool InstrumentDefinitionParser::isAssembly(const std::string &type) const { const std::string filename = m_xmlFile->getFileFullPathStr(); auto it = isTypeAssembly.find(type); @@ -2580,7 +2581,8 @@ void InstrumentDefinitionParser::setComponentLinks( Apply the cache. @param cacheToApply : Cache file object to use the the geometries. */ -void InstrumentDefinitionParser::applyCache(IDFObject_const_sptr cacheToApply) { +void InstrumentDefinitionParser::applyCache( + const IDFObject_const_sptr &cacheToApply) { const std::string cacheFullPath = cacheToApply->getFileFullPathStr(); g_log.information("Loading geometry cache from " + cacheFullPath); // create a vtk reader @@ -2605,14 +2607,14 @@ Write the cache file from the IDF file and apply it. InstrumentDefinitionParser::CachingOption InstrumentDefinitionParser::writeAndApplyCache( IDFObject_const_sptr firstChoiceCache, IDFObject_const_sptr fallBackCache) { - IDFObject_const_sptr usedCache = firstChoiceCache; + IDFObject_const_sptr usedCache = std::move(firstChoiceCache); auto cachingOption = WroteGeomCache; g_log.notice("Geometry cache is not available"); try { Poco::File dir = usedCache->getParentDirectory(); if (dir.path().empty() || !dir.exists() || !dir.canWrite()) { - usedCache = fallBackCache; + usedCache = std::move(fallBackCache); cachingOption = WroteCacheTemp; g_log.information() << "Geometrycache directory is read only, writing cache " diff --git a/Framework/Geometry/src/Instrument/ObjCompAssembly.cpp b/Framework/Geometry/src/Instrument/ObjCompAssembly.cpp index aeaa34b846ddf8522c736605e5e21861453624dd..13c327d53751caf48d17ca4777d730936b53c6b5 100644 --- a/Framework/Geometry/src/Instrument/ObjCompAssembly.cpp +++ b/Framework/Geometry/src/Instrument/ObjCompAssembly.cpp @@ -16,6 +16,7 @@ #include <algorithm> #include <ostream> #include <stdexcept> +#include <utility> namespace { Mantid::Kernel::Logger g_log("ObjCompAssembly"); @@ -408,12 +409,12 @@ boost::shared_ptr<IObject> ObjCompAssembly::createOutline() { // find the 'moments of inertia' of the assembly double Ixx = 0, Iyy = 0, Izz = 0, Ixy = 0, Ixz = 0, Iyz = 0; V3D Cmass; // 'center of mass' of the assembly - for (const_comp_it it = group.begin(); it != group.end(); it++) { + for (const_comp_it it = group.begin(); it != group.end(); ++it) { V3D p = (**it).getRelativePos(); Cmass += p; } Cmass /= nelements(); - for (const_comp_it it = group.begin(); it != group.end(); it++) { + for (const_comp_it it = group.begin(); it != group.end(); ++it) { V3D p = (**it).getRelativePos(); double x = p.X() - Cmass.X(), x2 = x * x; double y = p.Y() - Cmass.Y(), y2 = y * y; @@ -475,7 +476,7 @@ boost::shared_ptr<IObject> ObjCompAssembly::createOutline() { // positive displacements are positive numbers and negative ones are negative double hxn = 0, hyn = 0, hzn = 0; double hxp = 0, hyp = 0, hzp = 0; - for (const_comp_it it = group.begin(); it != group.end(); it++) { + for (const_comp_it it = group.begin(); it != group.end(); ++it) { // displacement vector of a detector V3D p = (**it).getRelativePos() - Cmass; // its projection on the vx axis @@ -609,7 +610,7 @@ boost::shared_ptr<IObject> ObjCompAssembly::createOutline() { * @param obj :: The outline shape created previously fith createOutline() */ void ObjCompAssembly::setOutline(boost::shared_ptr<const IObject> obj) { - m_shape = obj; + m_shape = std::move(obj); } /** Print information about elements in the assembly to a stream diff --git a/Framework/Geometry/src/Instrument/ObjComponent.cpp b/Framework/Geometry/src/Instrument/ObjComponent.cpp index 4fe26facc6576a3cec0b5d2b0a4ad8795cb86886..f24ae4316de4c441f280d236d9a3cf7e9f81aed2 100644 --- a/Framework/Geometry/src/Instrument/ObjComponent.cpp +++ b/Framework/Geometry/src/Instrument/ObjComponent.cpp @@ -15,6 +15,7 @@ #include "MantidKernel/Exception.h" #include "MantidKernel/Material.h" #include <cfloat> +#include <utility> namespace Mantid { namespace Geometry { @@ -44,7 +45,7 @@ ObjComponent::ObjComponent(const std::string &name, IComponent *parent) ObjComponent::ObjComponent(const std::string &name, boost::shared_ptr<const IObject> shape, IComponent *parent) - : IObjComponent(), Component(name, parent), m_shape(shape) {} + : IObjComponent(), Component(name, parent), m_shape(std::move(shape)) {} /** Return the shape of the component */ @@ -65,7 +66,7 @@ void ObjComponent::setShape(boost::shared_ptr<const IObject> newShape) { throw std::runtime_error("ObjComponent::setShape - Cannot change the shape " "of a parameterized object"); else - m_shape = newShape; + m_shape = std::move(newShape); } /** diff --git a/Framework/Geometry/src/Instrument/ParComponentFactory.cpp b/Framework/Geometry/src/Instrument/ParComponentFactory.cpp index 4bcc922dceea39a0284564af05d27b725be85f91..c37cc266ef74152829bf44cd9c8fd2d39e2053fb 100644 --- a/Framework/Geometry/src/Instrument/ParComponentFactory.cpp +++ b/Framework/Geometry/src/Instrument/ParComponentFactory.cpp @@ -58,7 +58,7 @@ ParComponentFactory::createInstrument(boost::shared_ptr<const Instrument> base, * @returns A pointer to a parameterized component */ IComponent_sptr -ParComponentFactory::create(boost::shared_ptr<const IComponent> base, +ParComponentFactory::create(const boost::shared_ptr<const IComponent> &base, const ParameterMap *map) { boost::shared_ptr<const IDetector> det_sptr = boost::dynamic_pointer_cast<const IDetector>(base); diff --git a/Framework/Geometry/src/Instrument/RectangularDetector.cpp b/Framework/Geometry/src/Instrument/RectangularDetector.cpp index 42cb3d0ce8e2db8646b9fdf2131c500cff0f128d..03359db991e8be4f8957b51cb4af0b8738a76609 100644 --- a/Framework/Geometry/src/Instrument/RectangularDetector.cpp +++ b/Framework/Geometry/src/Instrument/RectangularDetector.cpp @@ -22,6 +22,7 @@ #include <boost/regex.hpp> #include <ostream> #include <stdexcept> +#include <utility> namespace { /** @@ -180,8 +181,8 @@ void RectangularDetector::initialize(boost::shared_ptr<IObject> shape, int idstepbyrow, int idstep) { GridDetector::initialize( - shape, xpixels, xstart, xstep, ypixels, ystart, ystep, 0, 0, 0, idstart, - idfillbyfirst_y ? "yxz" : "xyz", idstepbyrow, idstep); + std::move(shape), xpixels, xstart, xstep, ypixels, ystart, ystep, 0, 0, 0, + idstart, idfillbyfirst_y ? "yxz" : "xyz", idstepbyrow, idstep); } //------------------------------------------------------------------------------------------------ diff --git a/Framework/Geometry/src/Instrument/SampleEnvironment.cpp b/Framework/Geometry/src/Instrument/SampleEnvironment.cpp index 96261b30070f48492a0c7715109a60abedbce466..4684a6319e196f5216bb3e2ae43279659c2c19e4 100644 --- a/Framework/Geometry/src/Instrument/SampleEnvironment.cpp +++ b/Framework/Geometry/src/Instrument/SampleEnvironment.cpp @@ -29,7 +29,7 @@ using Kernel::V3D; * @param container The object that represents the can */ SampleEnvironment::SampleEnvironment(std::string name, - Container_const_sptr container) + const Container_const_sptr &container) : m_name(std::move(name)), m_components(1, container) {} const IObject &SampleEnvironment::getComponent(const size_t index) const { diff --git a/Framework/Geometry/src/MDGeometry/CompositeImplicitFunction.cpp b/Framework/Geometry/src/MDGeometry/CompositeImplicitFunction.cpp index 1de3d75e75f4ca2524b6033b88a0c825be84bc63..154f5adbb2b1b977bb510dca339ddd72b27f6b0f 100644 --- a/Framework/Geometry/src/MDGeometry/CompositeImplicitFunction.cpp +++ b/Framework/Geometry/src/MDGeometry/CompositeImplicitFunction.cpp @@ -23,7 +23,7 @@ namespace Mantid { namespace Geometry { bool CompositeImplicitFunction::addFunction( - Mantid::Geometry::MDImplicitFunction_sptr constituentFunction) { + const Mantid::Geometry::MDImplicitFunction_sptr &constituentFunction) { bool bSuccess = false; if (constituentFunction.get() != nullptr) { this->m_Functions.emplace_back(constituentFunction); diff --git a/Framework/Geometry/src/MDGeometry/MDGeometryXMLBuilder.cpp b/Framework/Geometry/src/MDGeometry/MDGeometryXMLBuilder.cpp index 5d1e231ddf8b8412cc3d495426c07caa50f9f730..85b59c805d944f4fbb032e2c14ad320eb9d07fa9 100644 --- a/Framework/Geometry/src/MDGeometry/MDGeometryXMLBuilder.cpp +++ b/Framework/Geometry/src/MDGeometry/MDGeometryXMLBuilder.cpp @@ -53,7 +53,7 @@ bool MDGeometryBuilderXML<CheckDimensionPolicy>::addOrdinaryDimension( */ template <typename CheckDimensionPolicy> void MDGeometryBuilderXML<CheckDimensionPolicy>::addManyOrdinaryDimensions( - VecIMDDimension_sptr manyDims) const { + const VecIMDDimension_sptr &manyDims) const { for (auto &manyDim : manyDims) { addOrdinaryDimension(manyDim); } @@ -106,7 +106,7 @@ void MDGeometryBuilderXML<CheckDimensionPolicy>::applyPolicyChecking( */ template <typename CheckDimensionPolicy> bool MDGeometryBuilderXML<CheckDimensionPolicy>::addXDimension( - IMDDimension_const_sptr dimension) const { + const IMDDimension_const_sptr &dimension) const { bool bAdded = false; if (dimension) { @@ -126,7 +126,7 @@ bool MDGeometryBuilderXML<CheckDimensionPolicy>::addXDimension( */ template <typename CheckDimensionPolicy> bool MDGeometryBuilderXML<CheckDimensionPolicy>::addYDimension( - IMDDimension_const_sptr dimension) const { + const IMDDimension_const_sptr &dimension) const { bool bAdded = false; if (dimension) { @@ -146,7 +146,7 @@ bool MDGeometryBuilderXML<CheckDimensionPolicy>::addYDimension( */ template <typename CheckDimensionPolicy> bool MDGeometryBuilderXML<CheckDimensionPolicy>::addZDimension( - IMDDimension_const_sptr dimension) const { + const IMDDimension_const_sptr &dimension) const { bool bAdded = false; if (dimension) { applyPolicyChecking(*dimension); @@ -165,7 +165,7 @@ bool MDGeometryBuilderXML<CheckDimensionPolicy>::addZDimension( */ template <typename CheckDimensionPolicy> bool MDGeometryBuilderXML<CheckDimensionPolicy>::addTDimension( - IMDDimension_const_sptr dimension) const { + const IMDDimension_const_sptr &dimension) const { bool bAdded = false; if (dimension) { diff --git a/Framework/Geometry/src/MDGeometry/MDGeometryXMLParser.cpp b/Framework/Geometry/src/MDGeometry/MDGeometryXMLParser.cpp index 00dee415aaf4d42c6d927a27bf8f89730ba547fb..26735df1cc4775edc651bc091452840547f0be7f 100644 --- a/Framework/Geometry/src/MDGeometry/MDGeometryXMLParser.cpp +++ b/Framework/Geometry/src/MDGeometry/MDGeometryXMLParser.cpp @@ -5,6 +5,7 @@ // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + #include <algorithm> +#include <utility> #include "MantidGeometry/MDGeometry/IMDDimensionFactory.h" #include "MantidGeometry/MDGeometry/MDGeometryXMLDefinitions.h" @@ -23,14 +24,14 @@ struct findID { const std::string m_id; explicit findID(const std::string &id) : m_id(id) {} - bool operator()(const Mantid::Geometry::IMDDimension_sptr obj) const { + bool operator()(const Mantid::Geometry::IMDDimension_sptr &obj) const { return m_id == obj->getDimensionId(); } }; /// Helper unary comparison type for finding non-integrated dimensions. struct findIntegrated { - bool operator()(const Mantid::Geometry::IMDDimension_sptr obj) const { + bool operator()(const Mantid::Geometry::IMDDimension_sptr &obj) const { return obj->getIsIntegrated(); } }; @@ -307,7 +308,7 @@ Setter for the root element. "Dimensions" unless xml snippet passed in directly, in which case do not set. */ void MDGeometryXMLParser::SetRootNodeCheck(std::string elementName) { - m_rootNodeName = elementName; + m_rootNodeName = std::move(elementName); } /** @@ -346,7 +347,7 @@ Determines whether query dimension is the x dimension. @return true if matches. */ bool MDGeometryXMLParser::isXDimension( - Mantid::Geometry::IMDDimension_sptr candidate) const { + const Mantid::Geometry::IMDDimension_sptr &candidate) const { validate(); bool bResult = false; if (hasXDimension()) { @@ -363,7 +364,7 @@ Determines whether query dimension is the y dimension. @return true if matches. */ bool MDGeometryXMLParser::isYDimension( - Mantid::Geometry::IMDDimension_sptr candidate) const { + const Mantid::Geometry::IMDDimension_sptr &candidate) const { validate(); bool bResult = false; if (hasYDimension()) { @@ -380,7 +381,7 @@ Determines whether query dimension is the z dimension. @return true if matches. */ bool MDGeometryXMLParser::isZDimension( - Mantid::Geometry::IMDDimension_sptr candidate) const { + const Mantid::Geometry::IMDDimension_sptr &candidate) const { validate(); bool bResult = false; if (hasZDimension()) { @@ -397,7 +398,7 @@ Determines whether query dimension is the t dimension. @return true if matches. */ bool MDGeometryXMLParser::isTDimension( - Mantid::Geometry::IMDDimension_sptr candidate) const { + const Mantid::Geometry::IMDDimension_sptr &candidate) const { validate(); bool bResult = false; if (hasTDimension()) { diff --git a/Framework/Geometry/src/MDGeometry/MDHistoDimensionBuilder.cpp b/Framework/Geometry/src/MDGeometry/MDHistoDimensionBuilder.cpp index 258aaf310fda016a18b31d2d4710ebe78e7d63d0..83d19054edb293f9a1b0f618089f24d5819326cb 100644 --- a/Framework/Geometry/src/MDGeometry/MDHistoDimensionBuilder.cpp +++ b/Framework/Geometry/src/MDGeometry/MDHistoDimensionBuilder.cpp @@ -4,8 +4,10 @@ // NScD Oak Ridge National Laboratory, European Spallation Source, // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + -#include "MantidGeometry/MDGeometry/MDHistoDimensionBuilder.h" +#include <utility> + #include "MantidGeometry/MDGeometry/MDFrameFactory.h" +#include "MantidGeometry/MDGeometry/MDHistoDimensionBuilder.h" #include "MantidKernel/Strings.h" #include "MantidKernel/UnitLabelTypes.h" @@ -21,7 +23,7 @@ MDHistoDimensionBuilder::MDHistoDimensionBuilder() Setter for the dimension name @param name : friendly name of dimension */ -void MDHistoDimensionBuilder::setName(std::string name) { +void MDHistoDimensionBuilder::setName(const std::string &name) { // String any spaces m_name = Kernel::Strings::strip(name); } @@ -30,7 +32,7 @@ void MDHistoDimensionBuilder::setName(std::string name) { Setter for the dimension id @param id : id of the dimension */ -void MDHistoDimensionBuilder::setId(std::string id) { m_id = id; } +void MDHistoDimensionBuilder::setId(std::string id) { m_id = std::move(id); } /* Setter for the dimension units @@ -69,7 +71,7 @@ void MDHistoDimensionBuilder::setNumBins(size_t nbins) { m_nbins = nbins; } * @param frameName: the frame name */ void MDHistoDimensionBuilder::setFrameName(std::string frameName) { - m_frameName = frameName; + m_frameName = std::move(frameName); } /* diff --git a/Framework/Geometry/src/Objects/CSGObject.cpp b/Framework/Geometry/src/Objects/CSGObject.cpp index 6a140257766ade61f608bef6f89feffef9c38981..bc955a76162d900785d4b338872565fbb29ece9e 100644 --- a/Framework/Geometry/src/Objects/CSGObject.cpp +++ b/Framework/Geometry/src/Objects/CSGObject.cpp @@ -38,6 +38,7 @@ #include <deque> #include <random> #include <stack> +#include <utility> using namespace Mantid::Geometry; using namespace Mantid::Kernel; @@ -1593,6 +1594,7 @@ double CSGObject::singleShotMonteCarloVolume(const int shotSize, const auto threadCount = PARALLEL_NUMBER_OF_THREADS; const auto currentThreadNum = PARALLEL_THREAD_NUMBER; size_t blocksize = shotSize / threadCount; + // cppcheck-suppress knownConditionTrueFalse if (currentThreadNum == threadCount - 1) { // Last thread may have to do threadCount extra iterations in // the worst case. @@ -2113,7 +2115,8 @@ int CSGObject::searchForObject(Kernel::V3D &point) const { * Set the geometry handler for Object * @param[in] h is pointer to the geometry handler. */ -void CSGObject::setGeometryHandler(boost::shared_ptr<GeometryHandler> h) { +void CSGObject::setGeometryHandler( + const boost::shared_ptr<GeometryHandler> &h) { if (h) m_handler = h; } @@ -2145,7 +2148,7 @@ void CSGObject::initDraw() const { */ void CSGObject::setVtkGeometryCacheWriter( boost::shared_ptr<vtkGeometryCacheWriter> writer) { - vtkCacheWriter = writer; + vtkCacheWriter = std::move(writer); updateGeometryHandler(); } @@ -2154,7 +2157,7 @@ void CSGObject::setVtkGeometryCacheWriter( */ void CSGObject::setVtkGeometryCacheReader( boost::shared_ptr<vtkGeometryCacheReader> reader) { - vtkCacheReader = reader; + vtkCacheReader = std::move(reader); updateGeometryHandler(); } diff --git a/Framework/Geometry/src/Objects/InstrumentRayTracer.cpp b/Framework/Geometry/src/Objects/InstrumentRayTracer.cpp index b7e5abd938f3c3854a58c25b29b6503023595ca7..772ca27da44dff1e9afc9eb4db8e16a9db500745 100644 --- a/Framework/Geometry/src/Objects/InstrumentRayTracer.cpp +++ b/Framework/Geometry/src/Objects/InstrumentRayTracer.cpp @@ -15,6 +15,7 @@ #include "MantidKernel/V3D.h" #include <deque> #include <iterator> +#include <utility> namespace Mantid { namespace Geometry { @@ -33,7 +34,7 @@ using Kernel::V3D; * have a defined source. */ InstrumentRayTracer::InstrumentRayTracer(Instrument_const_sptr instrument) - : m_instrument(instrument) { + : m_instrument(std::move(instrument)) { if (!m_instrument) { std::ostringstream lexer; lexer << "Cannot create a InstrumentRayTracer, invalid instrument given. " diff --git a/Framework/Geometry/src/Objects/MeshObject.cpp b/Framework/Geometry/src/Objects/MeshObject.cpp index 4cd9be323fa61b89123da12596f2ccd4c2ded0dc..a17fadbd16358fe937714b82c0ad2cdb8317d932 100644 --- a/Framework/Geometry/src/Objects/MeshObject.cpp +++ b/Framework/Geometry/src/Objects/MeshObject.cpp @@ -21,7 +21,7 @@ namespace Geometry { MeshObject::MeshObject(const std::vector<uint32_t> &faces, const std::vector<Kernel::V3D> &vertices, - const Kernel::Material material) + const Kernel::Material &material) : m_boundingBox(), m_id("MeshObject"), m_triangles(faces), m_vertices(vertices), m_material(material) { @@ -453,7 +453,8 @@ bool MeshObject::searchForObject(Kernel::V3D &point) const { * @param[in] h is pointer to the geometry handler. don't delete this pointer in * the calling function. */ -void MeshObject::setGeometryHandler(boost::shared_ptr<GeometryHandler> h) { +void MeshObject::setGeometryHandler( + const boost::shared_ptr<GeometryHandler> &h) { if (h == nullptr) return; m_handler = h; diff --git a/Framework/Geometry/src/Rendering/GeometryHandler.cpp b/Framework/Geometry/src/Rendering/GeometryHandler.cpp index a51eea57de1c992cfaac3fdd46b8337a089565a6..d0a8d079e3530cd843a2695a578d2a1e276b11f6 100644 --- a/Framework/Geometry/src/Rendering/GeometryHandler.cpp +++ b/Framework/Geometry/src/Rendering/GeometryHandler.cpp @@ -19,7 +19,7 @@ namespace Geometry { GeometryHandler::GeometryHandler(IObjComponent *comp) : m_objComp(comp) {} -GeometryHandler::GeometryHandler(boost::shared_ptr<CSGObject> obj) +GeometryHandler::GeometryHandler(const boost::shared_ptr<CSGObject> &obj) : m_triangulator(new detail::GeometryTriangulator(obj.get())), m_csgObj(obj.get()) {} diff --git a/Framework/Geometry/src/Rendering/vtkGeometryCacheReader.cpp b/Framework/Geometry/src/Rendering/vtkGeometryCacheReader.cpp index 11ec99e32fee1cf623f4fd2f68576dd7cf141d4e..627d711b01a94318736b5ada4ab1eb65c8e22c0b 100644 --- a/Framework/Geometry/src/Rendering/vtkGeometryCacheReader.cpp +++ b/Framework/Geometry/src/Rendering/vtkGeometryCacheReader.cpp @@ -13,6 +13,8 @@ #include <Poco/Exception.h> #include <Poco/SAX/InputSource.h> +#include <utility> + #include "MantidGeometry/Objects/CSGObject.h" #include "MantidGeometry/Rendering/GeometryHandler.h" #include "MantidGeometry/Rendering/vtkGeometryCacheReader.h" @@ -33,7 +35,7 @@ Kernel::Logger g_log("vtkGeometryCacheReader"); * Constructor */ vtkGeometryCacheReader::vtkGeometryCacheReader(std::string filename) { - mFileName = filename; + mFileName = std::move(filename); mDoc = nullptr; Init(); } @@ -104,7 +106,7 @@ void vtkGeometryCacheReader::readCacheForObject(IObject *obj) { * Get the Element by using the object name */ Poco::XML::Element * -vtkGeometryCacheReader::getElementByObjectName(std::string name) { +vtkGeometryCacheReader::getElementByObjectName(const std::string &name) { Element *pRoot = mDoc->documentElement(); if (pRoot == nullptr || pRoot->nodeName() != "VTKFile") return nullptr; diff --git a/Framework/Geometry/src/Rendering/vtkGeometryCacheWriter.cpp b/Framework/Geometry/src/Rendering/vtkGeometryCacheWriter.cpp index 84b834bccf0bdb3d8e2e8e9550a2efe682abd65f..c3a6460587cba7b76fb971cd01e306f707ef3455 100644 --- a/Framework/Geometry/src/Rendering/vtkGeometryCacheWriter.cpp +++ b/Framework/Geometry/src/Rendering/vtkGeometryCacheWriter.cpp @@ -22,6 +22,7 @@ #include <fstream> #include <sstream> +#include <utility> using Poco::XML::AutoPtr; using Poco::XML::Document; @@ -41,7 +42,7 @@ Kernel::Logger g_log("vtkGeometryCacheWriter"); * Constructor */ vtkGeometryCacheWriter::vtkGeometryCacheWriter(std::string filename) { - mFileName = filename; + mFileName = std::move(filename); mDoc = new Document(); Init(); diff --git a/Framework/Geometry/test/CSGObjectTest.h b/Framework/Geometry/test/CSGObjectTest.h index d99f7164575906db730dd7c2dddd5bfb1a419c0e..2f9da83d6f4fa427ba12f1271aa19d6f84debc05 100644 --- a/Framework/Geometry/test/CSGObjectTest.h +++ b/Framework/Geometry/test/CSGObjectTest.h @@ -416,7 +416,7 @@ public: TS_ASSERT_EQUALS(index, expectedResults.size()); } - void checkTrackIntercept(IObject_sptr obj, Track &track, + void checkTrackIntercept(const IObject_sptr &obj, Track &track, const std::vector<Link> &expectedResults) { int unitCount = obj->interceptSurface(track); TS_ASSERT_EQUALS(unitCount, expectedResults.size()); diff --git a/Framework/Geometry/test/IndexingUtilsTest.h b/Framework/Geometry/test/IndexingUtilsTest.h index 3e4d2faea0f7de43e06dadcbb69846a9e767fd16..25f07e272c40f8fc9161fceb373e4246f2592a4d 100644 --- a/Framework/Geometry/test/IndexingUtilsTest.h +++ b/Framework/Geometry/test/IndexingUtilsTest.h @@ -14,6 +14,8 @@ #include "MantidKernel/V3D.h" #include <cxxtest/TestSuite.h> +#include <utility> + using namespace Mantid::Geometry; using Mantid::Kernel::Matrix; using Mantid::Kernel::V3D; @@ -55,7 +57,7 @@ public: static void ShowLatticeParameters(Matrix<double> UB) { Matrix<double> UB_inv(3, 3, false); - UB_inv = UB; + UB_inv = std::move(UB); UB_inv.Invert(); V3D a_dir(UB_inv[0][0], UB_inv[0][1], UB_inv[0][2]); V3D b_dir(UB_inv[1][0], UB_inv[1][1], UB_inv[1][2]); @@ -73,7 +75,8 @@ public: std::cout << "-------------------------------------------\n"; } - static void ShowIndexingStats(Matrix<double> UB, std::vector<V3D> q_vectors, + static void ShowIndexingStats(const Matrix<double> &UB, + const std::vector<V3D> &q_vectors, double required_tolerance) { std::vector<V3D> miller_indices; std::vector<V3D> indexed_qs; diff --git a/Framework/Geometry/test/InstrumentDefinitionParserTest.h b/Framework/Geometry/test/InstrumentDefinitionParserTest.h index ca4654fedc294301d56228c7a36f68c07ccaebe1..8ad15d693e80d6e5da58352386904821ddb140f8 100644 --- a/Framework/Geometry/test/InstrumentDefinitionParserTest.h +++ b/Framework/Geometry/test/InstrumentDefinitionParserTest.h @@ -34,7 +34,7 @@ private: /// Mock Type to act as IDF files. class MockIDFObject : public Mantid::Geometry::IDFObject { public: - MockIDFObject(const std::string fileName) + MockIDFObject(const std::string &fileName) : Mantid::Geometry::IDFObject(fileName) {} MOCK_CONST_METHOD0(exists, bool()); }; @@ -42,7 +42,7 @@ private: /// Mock Type to act as IDF files. class MockIDFObjectWithParentDirectory : public Mantid::Geometry::IDFObject { public: - MockIDFObjectWithParentDirectory(const std::string fileName) + MockIDFObjectWithParentDirectory(const std::string &fileName) : Mantid::Geometry::IDFObject(fileName) {} MOCK_CONST_METHOD0(exists, bool()); MOCK_CONST_METHOD0(getParentDirectory, const Poco::Path()); @@ -54,7 +54,7 @@ private: */ struct IDFEnvironment { IDFEnvironment(const ScopedFile &idf, const ScopedFile &vtp, - const std::string xmlText, const std::string instName) + const std::string &xmlText, const std::string &instName) : _idf(idf), _vtp(vtp), _xmlText(xmlText), _instName(instName){}; ScopedFile _idf; @@ -980,8 +980,8 @@ public: TS_ASSERT_DELTA(instr->getDetector(5)->getPos().Z(), 3.0, 1.0E-8); } - void checkDetectorRot(IDetector_const_sptr det, double deg, double axisx, - double axisy, double axisz) { + void checkDetectorRot(const IDetector_const_sptr &det, double deg, + double axisx, double axisy, double axisz) { double detDeg, detAxisX, detAxisY, detAxisZ; det->getRotation().getAngleAxis(detDeg, detAxisX, detAxisY, detAxisZ); diff --git a/Framework/Geometry/test/InstrumentRayTracerTest.h b/Framework/Geometry/test/InstrumentRayTracerTest.h index 80357a524c2ed09e13486dc61cafc150bd466338..5fea17192a9d1a068741874f5539f4543170bf77 100644 --- a/Framework/Geometry/test/InstrumentRayTracerTest.h +++ b/Framework/Geometry/test/InstrumentRayTracerTest.h @@ -163,8 +163,9 @@ public: * @param expectX :: expected x index, -1 if off * @param expectY :: expected y index, -1 if off */ - void doTestRectangularDetector(std::string message, Instrument_sptr inst, - V3D testDir, int expectX, int expectY) { + void doTestRectangularDetector(const std::string &message, + const Instrument_sptr &inst, V3D testDir, + int expectX, int expectY) { InstrumentRayTracer tracker(inst); testDir.normalize(); tracker.traceFromSample(testDir); diff --git a/Framework/Geometry/test/MDBoxImplicitFunctionTest.h b/Framework/Geometry/test/MDBoxImplicitFunctionTest.h index df0683d05f3da7cd6257bc8924f319e9348cbcf3..6d30faa3b665b3e34b8eaf0442000eaa6340bbec 100644 --- a/Framework/Geometry/test/MDBoxImplicitFunctionTest.h +++ b/Framework/Geometry/test/MDBoxImplicitFunctionTest.h @@ -106,7 +106,6 @@ public: // The box to test. const coord_t boxMin = 1.1f; const coord_t boxMax = 1.9f; - std::vector<coord_t> boxVertexes; std::vector<Extent> extents; // extent extents.emplace_back(Extent(boxMin, boxMax)); diff --git a/Framework/Geometry/test/PointGroupTest.h b/Framework/Geometry/test/PointGroupTest.h index 39929db7257aa10109ff276bf723e6382aadc58c..8917d739944fba93d201102945ff10078964ec72 100644 --- a/Framework/Geometry/test/PointGroupTest.h +++ b/Framework/Geometry/test/PointGroupTest.h @@ -22,7 +22,7 @@ using namespace Mantid::Geometry; class PointGroupTest : public CxxTest::TestSuite { public: - void check_point_group(std::string name, V3D hkl, size_t numEquiv, + void check_point_group(const std::string &name, V3D hkl, size_t numEquiv, V3D *equiv) { PointGroup_sptr testedPointGroup = PointGroupFactory::Instance().createPointGroup(name); diff --git a/Framework/Geometry/test/ShapeFactoryTest.h b/Framework/Geometry/test/ShapeFactoryTest.h index 9f89f8aa98bf26abc3252c3b778ba23fc0c93bdc..5d6fe1e5c283238eba302b45db9b24aac9fda8bb 100644 --- a/Framework/Geometry/test/ShapeFactoryTest.h +++ b/Framework/Geometry/test/ShapeFactoryTest.h @@ -636,7 +636,7 @@ public: TS_ASSERT(!shape_sptr->isValid(V3D(0.0, 0.0, 1))); } - boost::shared_ptr<CSGObject> getObject(std::string xmlShape) { + boost::shared_ptr<CSGObject> getObject(const std::string &xmlShape) { std::string shapeXML = "<type name=\"userShape\"> " + xmlShape + " </type>"; // Set up the DOM parser and parse xml string diff --git a/Framework/HistogramData/test/CountStandardDeviationsTest.h b/Framework/HistogramData/test/CountStandardDeviationsTest.h index fc094f623f4b9eb34e5d6c146b0af99f51a4e60a..4da236676c4c2888e762ab7493f56aeeed1b16ac 100644 --- a/Framework/HistogramData/test/CountStandardDeviationsTest.h +++ b/Framework/HistogramData/test/CountStandardDeviationsTest.h @@ -94,7 +94,6 @@ public: const BinEdges edges{1.0, 2.0}; auto old_ptr = &frequencies[0]; const CountStandardDeviations counts(std::move(frequencies), edges); - TS_ASSERT(!frequencies); TS_ASSERT_EQUALS(&counts[0], old_ptr); } @@ -104,8 +103,6 @@ public: const BinEdges edges{1.0, 2.0}; auto old_ptr = &frequencies[0]; const CountStandardDeviations counts(std::move(frequencies), edges); - // Moved from frequencies... - TS_ASSERT(!frequencies); // ... but made a copy of data, since "copy" also held a reference. TS_ASSERT_DIFFERS(&counts[0], old_ptr); } @@ -127,7 +124,6 @@ public: // This implicitly constructs FrequencyStandardDeviations first, so there is // a two-step move going on! const CountStandardDeviations counts(std::move(frequencies), edges); - TS_ASSERT(!frequencies); TS_ASSERT_EQUALS(&counts[0], old_ptr); } }; diff --git a/Framework/HistogramData/test/CountVariancesTest.h b/Framework/HistogramData/test/CountVariancesTest.h index f574cb79e7ee113e8130c574b165188ac1ce5331..1ee331c55109a2c6a40e37ffb36d27d28aa44e83 100644 --- a/Framework/HistogramData/test/CountVariancesTest.h +++ b/Framework/HistogramData/test/CountVariancesTest.h @@ -101,7 +101,6 @@ public: const BinEdges edges{1.0, 2.0}; auto old_ptr = &frequencies[0]; const CountVariances counts(std::move(frequencies), edges); - TS_ASSERT(!frequencies); TS_ASSERT_EQUALS(&counts[0], old_ptr); } @@ -111,8 +110,6 @@ public: const BinEdges edges{1.0, 2.0}; auto old_ptr = &frequencies[0]; const CountVariances counts(std::move(frequencies), edges); - // Moved from frequencies... - TS_ASSERT(!frequencies); // ... but made a copy of data, since "copy" also held a reference. TS_ASSERT_DIFFERS(&counts[0], old_ptr); } @@ -134,7 +131,6 @@ public: // This implicitly constructs FrequencyVariances first, so there is a // two-step move going on! const CountVariances counts(std::move(frequencies), edges); - TS_ASSERT(!frequencies); TS_ASSERT_EQUALS(&counts[0], old_ptr); } }; diff --git a/Framework/HistogramData/test/CountsTest.h b/Framework/HistogramData/test/CountsTest.h index d6474d26253b361f3c1ba7a510d2066de48acc92..49725b67d754d84891064760d61f8ff99b1b1144 100644 --- a/Framework/HistogramData/test/CountsTest.h +++ b/Framework/HistogramData/test/CountsTest.h @@ -97,7 +97,6 @@ public: const BinEdges edges{1.0, 2.0}; auto old_ptr = &frequencies[0]; const Counts counts(std::move(frequencies), edges); - TS_ASSERT(!frequencies); TS_ASSERT_EQUALS(&counts[0], old_ptr); } @@ -107,8 +106,6 @@ public: const BinEdges edges{1.0, 2.0}; auto old_ptr = &frequencies[0]; const Counts counts(std::move(frequencies), edges); - // Moved from frequencies... - TS_ASSERT(!frequencies); // ... but made a copy of data, since "copy" also held a reference. TS_ASSERT_DIFFERS(&counts[0], old_ptr); } diff --git a/Framework/HistogramData/test/FrequenciesTest.h b/Framework/HistogramData/test/FrequenciesTest.h index 598fd5aa8424e47c2b138a3ba12359f980f2edb8..1eb1b105bddb4a5f8ac56457ea1f7fd568331377 100644 --- a/Framework/HistogramData/test/FrequenciesTest.h +++ b/Framework/HistogramData/test/FrequenciesTest.h @@ -97,7 +97,6 @@ public: const BinEdges edges{1.0, 2.0}; auto old_ptr = &counts[0]; const Frequencies frequencies(std::move(counts), edges); - TS_ASSERT(!counts); TS_ASSERT_EQUALS(&frequencies[0], old_ptr); } @@ -107,8 +106,6 @@ public: const BinEdges edges{1.0, 2.0}; auto old_ptr = &counts[0]; const Frequencies frequencies(std::move(counts), edges); - // Moved from counts... - TS_ASSERT(!counts); // ... but made a copy of data, since "copy" also held a reference. TS_ASSERT_DIFFERS(&frequencies[0], old_ptr); } diff --git a/Framework/HistogramData/test/FrequencyVariancesTest.h b/Framework/HistogramData/test/FrequencyVariancesTest.h index a308a66dd0ede9763c2dfcef1d09febb43b2abb1..cabf615d4746d78df244300195cf2bd624f9b3c2 100644 --- a/Framework/HistogramData/test/FrequencyVariancesTest.h +++ b/Framework/HistogramData/test/FrequencyVariancesTest.h @@ -104,7 +104,6 @@ public: const BinEdges edges{1.0, 2.0}; auto old_ptr = &counts[0]; const FrequencyVariances frequencies(std::move(counts), edges); - TS_ASSERT(!counts); TS_ASSERT_EQUALS(&frequencies[0], old_ptr); } @@ -114,8 +113,6 @@ public: const BinEdges edges{1.0, 2.0}; auto old_ptr = &counts[0]; const FrequencyVariances frequencies(std::move(counts), edges); - // Moved from counts... - TS_ASSERT(!counts); // ... but made a copy of data, since "copy" also held a reference. TS_ASSERT_DIFFERS(&frequencies[0], old_ptr); } @@ -137,7 +134,6 @@ public: // This implicitly constructs CountVariances first, so there is a // two-step move going on! const FrequencyVariances frequencies(std::move(counts), edges); - TS_ASSERT(!counts); TS_ASSERT_EQUALS(&frequencies[0], old_ptr); } }; diff --git a/Framework/HistogramData/test/StandardDeviationVectorOfTest.h b/Framework/HistogramData/test/StandardDeviationVectorOfTest.h index f5da8607d1e5f95fbe39c7ffa020b94014e48ab6..113209ffb93d70d3744fae9eac2c20b8bdd6c953 100644 --- a/Framework/HistogramData/test/StandardDeviationVectorOfTest.h +++ b/Framework/HistogramData/test/StandardDeviationVectorOfTest.h @@ -74,7 +74,6 @@ public: VariancesTester variances{1.0, 4.0}; auto old_ptr = &variances[0]; StandardDeviationVectorOfTester sigmas(std::move(variances)); - TS_ASSERT(!variances); TS_ASSERT_EQUALS(&sigmas[0], old_ptr); TS_ASSERT_EQUALS(sigmas[0], 1.0); TS_ASSERT_EQUALS(sigmas[1], 2.0); @@ -93,7 +92,6 @@ public: auto old_ptr = &variances[0]; StandardDeviationVectorOfTester sigmas{}; sigmas = std::move(variances); - TS_ASSERT(!variances); TS_ASSERT_EQUALS(&sigmas[0], old_ptr); TS_ASSERT_EQUALS(sigmas[0], 1.0); TS_ASSERT_EQUALS(sigmas[1], 2.0); diff --git a/Framework/HistogramData/test/VarianceVectorOfTest.h b/Framework/HistogramData/test/VarianceVectorOfTest.h index 1dfed01a9c67c43698361c8b88ca8705cc49b629..2c58a64f541ba310f5591b327b97653b1e16db30 100644 --- a/Framework/HistogramData/test/VarianceVectorOfTest.h +++ b/Framework/HistogramData/test/VarianceVectorOfTest.h @@ -70,7 +70,6 @@ public: SigmasTester sigmas{1.0, 2.0}; auto old_ptr = &sigmas[0]; VarianceVectorOfTester variances(std::move(sigmas)); - TS_ASSERT(!sigmas); TS_ASSERT_EQUALS(&variances[0], old_ptr); TS_ASSERT_EQUALS(variances[0], 1.0); TS_ASSERT_EQUALS(variances[1], 4.0); @@ -89,7 +88,6 @@ public: auto old_ptr = &sigmas[0]; VarianceVectorOfTester variances{}; variances = std::move(sigmas); - TS_ASSERT(!sigmas); TS_ASSERT_EQUALS(&variances[0], old_ptr); TS_ASSERT_EQUALS(variances[0], 1.0); TS_ASSERT_EQUALS(variances[1], 4.0); diff --git a/Framework/HistogramData/test/VectorOfTest.h b/Framework/HistogramData/test/VectorOfTest.h index 032b30e9fd303422f0360c468f7a9810e23925e3..f38e4d64c540d051b4ef59699534be748bb6e87c 100644 --- a/Framework/HistogramData/test/VectorOfTest.h +++ b/Framework/HistogramData/test/VectorOfTest.h @@ -100,7 +100,6 @@ public: TS_ASSERT_EQUALS(src.size(), 2); TS_ASSERT(src); const VectorOfTester dest(std::move(src)); - TS_ASSERT(!src); TS_ASSERT_EQUALS(dest[0], 0.1); TS_ASSERT_EQUALS(dest[1], 0.1); } @@ -108,7 +107,6 @@ public: void test_move_from_null_constructor() { VectorOfTester src{}; const VectorOfTester dest(std::move(src)); - TS_ASSERT(!src); TS_ASSERT(!dest); } @@ -160,7 +158,6 @@ public: TS_ASSERT_EQUALS(dest[0], 0.0); TS_ASSERT(src); dest = std::move(src); - TS_ASSERT(!src); TS_ASSERT_EQUALS(dest[0], 0.1); TS_ASSERT_EQUALS(dest[1], 0.1); } @@ -169,7 +166,6 @@ public: VectorOfTester src{}; VectorOfTester dest(1); dest = std::move(src); - TS_ASSERT(!src); TS_ASSERT(!dest); } diff --git a/Framework/ICat/test/CatalogSearchTest.h b/Framework/ICat/test/CatalogSearchTest.h index 89c73f02b08983a849dc59697209a73dd6a57b02..54b80e7d6a5fd0989bb6d125330c462407ebbf2f 100644 --- a/Framework/ICat/test/CatalogSearchTest.h +++ b/Framework/ICat/test/CatalogSearchTest.h @@ -121,16 +121,9 @@ public: if (!searchobj.isInitialized()) searchobj.initialize(); - std::string errorMsg = "Invalid value for property StartDate (string) " - "sssss" - ": Invalid Date:date format must be DD/MM/YYYY"; TS_ASSERT_THROWS(searchobj.setPropertyValue("StartDate", "sssss"), const std::invalid_argument &); - - errorMsg = "Invalid value for property EndDate (string) " - "aaaaa" - ": Invalid Date:date format must be DD/MM/YYYY"; TS_ASSERT_THROWS(searchobj.setPropertyValue("EndDate", "aaaaa"), const std::invalid_argument &); @@ -146,17 +139,8 @@ public: if (!searchobj.isInitialized()) searchobj.initialize(); - std::string errorMsg = "Invalid value for property StartDate (string) " - "39/22/2009" - ": Invalid Date:Day part of the Date parameter must " - "be between 1 and 31"; TS_ASSERT_THROWS(searchobj.setPropertyValue("StartDate", "39/22/2009"), const std::invalid_argument &); - - errorMsg = "Invalid value for property EndDate (string) " - "1/22/2009" - ": Invalid Date:Month part of the Date parameter must be " - "between 1 and 12"; TS_ASSERT_THROWS(searchobj.setPropertyValue("EndDate", "1/22/2009"), const std::invalid_argument &); diff --git a/Framework/Indexing/inc/MantidIndexing/IndexInfo.h b/Framework/Indexing/inc/MantidIndexing/IndexInfo.h index 2c20d8f7edb1c91fd23b84eea4ba0e586966fa37..42392f70f58ab9f75f4d135c871c8f8290d6bbae 100644 --- a/Framework/Indexing/inc/MantidIndexing/IndexInfo.h +++ b/Framework/Indexing/inc/MantidIndexing/IndexInfo.h @@ -87,8 +87,9 @@ public: void setSpectrumDefinitions(std::vector<SpectrumDefinition> spectrumDefinitions); - void setSpectrumDefinitions( - Kernel::cow_ptr<std::vector<SpectrumDefinition>> spectrumDefinitions); + void + setSpectrumDefinitions(const Kernel::cow_ptr<std::vector<SpectrumDefinition>> + &spectrumDefinitions); const Kernel::cow_ptr<std::vector<SpectrumDefinition>> & spectrumDefinitions() const; diff --git a/Framework/Indexing/src/IndexInfo.cpp b/Framework/Indexing/src/IndexInfo.cpp index 79b7462634f3dab535e22bc56fd65b912d15ebc6..eb8e07adf815bd47741ea7d6b817bc82d6ddd70a 100644 --- a/Framework/Indexing/src/IndexInfo.cpp +++ b/Framework/Indexing/src/IndexInfo.cpp @@ -174,7 +174,8 @@ void IndexInfo::setSpectrumDefinitions( * indices. Validation requires access to the instrument and thus cannot be done * internally in IndexInfo, i.e., spectrum definitions must be set by hand. */ void IndexInfo::setSpectrumDefinitions( - Kernel::cow_ptr<std::vector<SpectrumDefinition>> spectrumDefinitions) { + const Kernel::cow_ptr<std::vector<SpectrumDefinition>> + &spectrumDefinitions) { if (!spectrumDefinitions || (size() != spectrumDefinitions->size())) throw std::runtime_error( "IndexInfo: Size mismatch when setting new spectrum definitions"); diff --git a/Framework/Indexing/test/PartitionerTest.h b/Framework/Indexing/test/PartitionerTest.h index 3a53a0b5bffdb8ea3d5da07300514547062b7849..f64f74c41ae7c3061f5349ccf4225a03eb806b71 100644 --- a/Framework/Indexing/test/PartitionerTest.h +++ b/Framework/Indexing/test/PartitionerTest.h @@ -8,6 +8,8 @@ #include <cxxtest/TestSuite.h> +#include <utility> + #include "MantidIndexing/Partitioner.h" using namespace Mantid; @@ -23,7 +25,8 @@ public: PartitionerHelper(int numberOfPartitions, const PartitionIndex partition, const MonitorStrategy monitorStrategy, std::vector<GlobalSpectrumIndex> monitors) - : Partitioner(numberOfPartitions, partition, monitorStrategy, monitors) {} + : Partitioner(numberOfPartitions, partition, monitorStrategy, + std::move(monitors)) {} private: PartitionIndex doIndexOf(const GlobalSpectrumIndex) const override { diff --git a/Framework/Kernel/inc/MantidKernel/ArrayProperty.h b/Framework/Kernel/inc/MantidKernel/ArrayProperty.h index 31682068bb7478a103010b0d0569b3dce47356e7..1dff3f72ca932500b88bdc6b0870b53912451654 100644 --- a/Framework/Kernel/inc/MantidKernel/ArrayProperty.h +++ b/Framework/Kernel/inc/MantidKernel/ArrayProperty.h @@ -28,16 +28,18 @@ namespace Kernel { template <typename T> class DLLExport ArrayProperty : public PropertyWithValue<std::vector<T>> { public: - ArrayProperty(std::string name, std::vector<T> vec, - IValidator_sptr validator = IValidator_sptr(new NullValidator), + ArrayProperty( + const std::string &name, std::vector<T> vec, + const IValidator_sptr &validator = IValidator_sptr(new NullValidator), + const unsigned int direction = Direction::Input); + ArrayProperty(const std::string &name, const IValidator_sptr &validator, const unsigned int direction = Direction::Input); - ArrayProperty(std::string name, IValidator_sptr validator, - const unsigned int direction = Direction::Input); - ArrayProperty(std::string name, - const unsigned int direction = Direction::Input); - ArrayProperty(std::string name, const std::string &values, - IValidator_sptr validator = IValidator_sptr(new NullValidator), + ArrayProperty(const std::string &name, const unsigned int direction = Direction::Input); + ArrayProperty( + const std::string &name, const std::string &values, + const IValidator_sptr &validator = IValidator_sptr(new NullValidator), + const unsigned int direction = Direction::Input); ArrayProperty<T> *clone() const override; diff --git a/Framework/Kernel/inc/MantidKernel/CompositeValidator.h b/Framework/Kernel/inc/MantidKernel/CompositeValidator.h index b386e9d55e8b075b1c6fe2e1d43f55e1f47246c3..539762d4fe4c590b7189bc57b03804d58069f4bd 100644 --- a/Framework/Kernel/inc/MantidKernel/CompositeValidator.h +++ b/Framework/Kernel/inc/MantidKernel/CompositeValidator.h @@ -41,7 +41,7 @@ public: /// Clones this and the children into a new Validator IValidator_sptr clone() const override; /// Adds a validator to the group of validators to check - void add(IValidator_sptr child); + void add(const IValidator_sptr &child); /// Add a validator based on a template type. Useful for validators that need /// no arguments template <typename T> void add() { this->add(boost::make_shared<T>()); } diff --git a/Framework/Kernel/inc/MantidKernel/ErrorReporter.h b/Framework/Kernel/inc/MantidKernel/ErrorReporter.h index 785913ae656ac7149d79c5930eda68702422dbe9..40369730102dfeafec1707ae3cb34e6973d81f31 100644 --- a/Framework/Kernel/inc/MantidKernel/ErrorReporter.h +++ b/Framework/Kernel/inc/MantidKernel/ErrorReporter.h @@ -21,16 +21,21 @@ namespace Kernel { class MANTID_KERNEL_DLL ErrorReporter { public: /// Constructor - ErrorReporter(std::string application, Types::Core::time_duration startTime, - std::string exitCode, bool share); + ErrorReporter(const std::string &application, + const Types::Core::time_duration &startTime, + const std::string &exitCode, bool share); /// Constructor - ErrorReporter(std::string application, Types::Core::time_duration startTime, - std::string exitCode, bool share, std::string name, - std::string email, std::string textBox); + ErrorReporter(const std::string &application, + const Types::Core::time_duration &startTime, + const std::string &exitCode, bool share, + const std::string &name, const std::string &email, + const std::string &textBox); /// Constructor - ErrorReporter(std::string application, Types::Core::time_duration startTime, - std::string exitCode, bool share, std::string name, - std::string email, std::string textBox, std::string stacktrace); + ErrorReporter(const std::string &application, + const Types::Core::time_duration &startTime, + const std::string &exitCode, bool share, + const std::string &name, const std::string &email, + const std::string &textBox, const std::string &stacktrace); /// Sends an error report int sendErrorReport(); diff --git a/Framework/Kernel/inc/MantidKernel/FunctionTask.h b/Framework/Kernel/inc/MantidKernel/FunctionTask.h index 905d34025fe580fd2d13217b88efc78fbc5c59b8..6d0d2a849faa75e0d55f913ba0b953d1a485ff7e 100644 --- a/Framework/Kernel/inc/MantidKernel/FunctionTask.h +++ b/Framework/Kernel/inc/MantidKernel/FunctionTask.h @@ -13,6 +13,8 @@ #ifndef Q_MOC_RUN #include <boost/function.hpp> +#include <utility> + #endif namespace Mantid { @@ -61,7 +63,7 @@ public: * @param cost :: computational cost */ FunctionTask(std::function<void()> func, double cost = 1.0) - : Task(cost), m_voidFunc(func) {} + : Task(cost), m_voidFunc(std::move(func)) {} //--------------------------------------------------------------------------------------------- /** Main method that performs the work for the task. */ diff --git a/Framework/Kernel/inc/MantidKernel/IndexSet.h b/Framework/Kernel/inc/MantidKernel/IndexSet.h index 92e33fc2b7e6cf997620580a03751ed8de9de96d..461ffc193b020f0efb1ecf296876ff135c37c56e 100644 --- a/Framework/Kernel/inc/MantidKernel/IndexSet.h +++ b/Framework/Kernel/inc/MantidKernel/IndexSet.h @@ -27,7 +27,7 @@ class MANTID_KERNEL_DLL IndexSet { public: IndexSet(size_t fullRange); IndexSet(int64_t min, int64_t max, size_t fullRange); - IndexSet(const std::vector<size_t> indices, size_t fullRange); + IndexSet(const std::vector<size_t> &indices, size_t fullRange); /// Returns the size of the set. size_t size() const { return m_size; } diff --git a/Framework/Kernel/inc/MantidKernel/MaskedProperty.h b/Framework/Kernel/inc/MantidKernel/MaskedProperty.h index 72c24d37fa78fbd8a90fe51cd12dbac56e5e2bed..b64a0cfb602f932bb12d687a0fac8e814d5c96dc 100644 --- a/Framework/Kernel/inc/MantidKernel/MaskedProperty.h +++ b/Framework/Kernel/inc/MantidKernel/MaskedProperty.h @@ -28,9 +28,10 @@ template <typename TYPE = std::string> class MaskedProperty : public Kernel::PropertyWithValue<TYPE> { public: /// Constructor with a validator - MaskedProperty(const std::string &name, TYPE defaultvalue, - IValidator_sptr validator = IValidator_sptr(new NullValidator), - const unsigned int direction = Direction::Input); + MaskedProperty( + const std::string &name, TYPE defaultvalue, + const IValidator_sptr &validator = IValidator_sptr(new NullValidator), + const unsigned int direction = Direction::Input); /// Constructor with a validator without validation MaskedProperty(const std::string &name, const TYPE &defaultvalue, const unsigned int direction); diff --git a/Framework/Kernel/inc/MantidKernel/Material.h b/Framework/Kernel/inc/MantidKernel/Material.h index 6dc7b597b6977e8299211e143f3da7bd994a16cd..72cf13eac413a932bbe9d9a1a3e6d1a52ef120e9 100644 --- a/Framework/Kernel/inc/MantidKernel/Material.h +++ b/Framework/Kernel/inc/MantidKernel/Material.h @@ -56,7 +56,8 @@ public: using ChemicalFormula = std::vector<FormulaUnit>; - static ChemicalFormula parseChemicalFormula(const std::string chemicalSymbol); + static ChemicalFormula + parseChemicalFormula(const std::string &chemicalSymbol); /// Default constructor. Required for other parts of the code to /// function correctly. The material is considered "empty" diff --git a/Framework/Kernel/inc/MantidKernel/MatrixProperty.h b/Framework/Kernel/inc/MantidKernel/MatrixProperty.h index e3506e147a225f274ac90e0078a41cd51d8dca48..d840b9e35efa871e9c042907b98fd260089cd302 100644 --- a/Framework/Kernel/inc/MantidKernel/MatrixProperty.h +++ b/Framework/Kernel/inc/MantidKernel/MatrixProperty.h @@ -23,9 +23,10 @@ class MatrixProperty : public PropertyWithValue<Matrix<TYPE>> { public: /// Constructor - MatrixProperty(const std::string &propName, - IValidator_sptr validator = IValidator_sptr(new NullValidator), - unsigned int direction = Direction::Input); + MatrixProperty( + const std::string &propName, + const IValidator_sptr &validator = IValidator_sptr(new NullValidator), + unsigned int direction = Direction::Input); /// Copy constructor MatrixProperty(const MatrixProperty &rhs); // Unhide base class members (at minimum, avoids Intel compiler warning) diff --git a/Framework/Kernel/inc/MantidKernel/PropertyWithValue.h b/Framework/Kernel/inc/MantidKernel/PropertyWithValue.h index d24066c5e5c17109ccccc3b4e7f1889a9112a820..5a2dc17558165abbccb4cb3c08a8acbed7a493b2 100644 --- a/Framework/Kernel/inc/MantidKernel/PropertyWithValue.h +++ b/Framework/Kernel/inc/MantidKernel/PropertyWithValue.h @@ -37,12 +37,12 @@ namespace Kernel { template <typename TYPE> class DLLExport PropertyWithValue : public Property { public: PropertyWithValue( - std::string name, TYPE defaultValue, + const std::string &name, TYPE defaultValue, IValidator_sptr validator = IValidator_sptr(new NullValidator), const unsigned int direction = Direction::Input); - PropertyWithValue(std::string name, TYPE defaultValue, + PropertyWithValue(const std::string &name, TYPE defaultValue, const unsigned int direction); - PropertyWithValue(std::string name, TYPE defaultValue, + PropertyWithValue(const std::string &name, TYPE defaultValue, const std::string &defaultValueStr, IValidator_sptr validator, const unsigned int direction); PropertyWithValue(const PropertyWithValue<TYPE> &right); diff --git a/Framework/Kernel/inc/MantidKernel/PropertyWithValue.tcc b/Framework/Kernel/inc/MantidKernel/PropertyWithValue.tcc index 3add2297950ec240a886fb2f878392f7686ad27f..1d2befbb731cbbae61e1058f732020a6e2578e33 100644 --- a/Framework/Kernel/inc/MantidKernel/PropertyWithValue.tcc +++ b/Framework/Kernel/inc/MantidKernel/PropertyWithValue.tcc @@ -42,7 +42,8 @@ namespace Kernel { * or Direction::InOut (Input & Output) property */ template <typename TYPE> -PropertyWithValue<TYPE>::PropertyWithValue(std::string name, TYPE defaultValue, +PropertyWithValue<TYPE>::PropertyWithValue(const std::string &name, + TYPE defaultValue, IValidator_sptr validator, unsigned int direction) : Property(std::move(name), typeid(TYPE), direction), m_value(defaultValue), @@ -56,7 +57,8 @@ PropertyWithValue<TYPE>::PropertyWithValue(std::string name, TYPE defaultValue, * or Direction::InOut (Input & Output) property */ template <typename TYPE> -PropertyWithValue<TYPE>::PropertyWithValue(std::string name, TYPE defaultValue, +PropertyWithValue<TYPE>::PropertyWithValue(const std::string &name, + TYPE defaultValue, unsigned int direction) : Property(std::move(name), typeid(TYPE), direction), m_value(defaultValue), m_initialValue(std::move(defaultValue)), @@ -77,7 +79,8 @@ PropertyWithValue<TYPE>::PropertyWithValue(std::string name, TYPE defaultValue, * or Direction::InOut (Input & Output) property */ template <typename TYPE> -PropertyWithValue<TYPE>::PropertyWithValue(std::string name, TYPE defaultValue, +PropertyWithValue<TYPE>::PropertyWithValue(const std::string &name, + TYPE defaultValue, const std::string &defaultValueStr, IValidator_sptr validator, unsigned int direction) diff --git a/Framework/Kernel/inc/MantidKernel/RemoteJobManager.h b/Framework/Kernel/inc/MantidKernel/RemoteJobManager.h index 6da20d4b5a8ce644c6370b34d6ea8da9d8e63c73..175350eef35d7c3f6629ba28a6bbd8979bec287e 100644 --- a/Framework/Kernel/inc/MantidKernel/RemoteJobManager.h +++ b/Framework/Kernel/inc/MantidKernel/RemoteJobManager.h @@ -70,11 +70,13 @@ public: private: // Wraps up some of the boilerplate code needed to execute HTTP GET and POST // requests - void initGetRequest(Poco::Net::HTTPRequest &req, std::string extraPath, - std::string queryString); - void initPostRequest(Poco::Net::HTTPRequest &req, std::string extraPath); + void initGetRequest(Poco::Net::HTTPRequest &req, const std::string &extraPath, + const std::string &queryString); + void initPostRequest(Poco::Net::HTTPRequest &req, + const std::string &extraPath); void initHTTPRequest(Poco::Net::HTTPRequest &req, const std::string &method, - std::string extraPath, std::string queryString = ""); + const std::string &extraPath, + const std::string &queryString = ""); std::string m_displayName; std::string diff --git a/Framework/Kernel/inc/MantidKernel/SingletonHolder.h b/Framework/Kernel/inc/MantidKernel/SingletonHolder.h index 51ffda22895f82578c9253cd9752cbc2edf0c509..84b793dbe82e059a192f4ba00d0bb0e0e2742d0a 100644 --- a/Framework/Kernel/inc/MantidKernel/SingletonHolder.h +++ b/Framework/Kernel/inc/MantidKernel/SingletonHolder.h @@ -35,7 +35,7 @@ using SingletonDeleterFn = std::function<void()>; /// Register the given deleter function to be called /// at exit -MANTID_KERNEL_DLL void deleteOnExit(SingletonDeleterFn func); +MANTID_KERNEL_DLL void deleteOnExit(const SingletonDeleterFn &func); /// Manage the lifetime of a class intended to be a singleton template <typename T> class SingletonHolder { diff --git a/Framework/Kernel/inc/MantidKernel/ThreadPool.h b/Framework/Kernel/inc/MantidKernel/ThreadPool.h index 7ac894b1dd51576777bf55cba98a6a7608922adf..2e60c564fe0323a1ff58f2d64428f3fe0ffdb203 100644 --- a/Framework/Kernel/inc/MantidKernel/ThreadPool.h +++ b/Framework/Kernel/inc/MantidKernel/ThreadPool.h @@ -42,7 +42,7 @@ public: void start(double waitSec = 0.0); - void schedule(std::shared_ptr<Task> task, bool start = false); + void schedule(const std::shared_ptr<Task> &task, bool start = false); void joinAll(); diff --git a/Framework/Kernel/inc/MantidKernel/Unit.h b/Framework/Kernel/inc/MantidKernel/Unit.h index 4951a26082b0ad016b249619808d3f547e8177c3..2d0a7201d86ce4af713a4c511d5fdc7d5c526b68 100644 --- a/Framework/Kernel/inc/MantidKernel/Unit.h +++ b/Framework/Kernel/inc/MantidKernel/Unit.h @@ -10,6 +10,8 @@ // Includes //---------------------------------------------------------------------- #include "MantidKernel/UnitLabel.h" +#include <utility> + #include <vector> #ifndef Q_MOC_RUN #include <boost/shared_ptr.hpp> @@ -684,13 +686,14 @@ private: //================================================================================================= -MANTID_KERNEL_DLL double timeConversionValue(std::string input_unit, - std::string output_unit); +MANTID_KERNEL_DLL double timeConversionValue(const std::string &input_unit, + const std::string &output_unit); template <typename T> -void timeConversionVector(std::vector<T> &vec, std::string input_unit, - std::string output_unit) { - double factor = timeConversionValue(input_unit, output_unit); +void timeConversionVector(std::vector<T> &vec, const std::string &input_unit, + const std::string &output_unit) { + double factor = + timeConversionValue(std::move(input_unit), std::move(output_unit)); if (factor != 1.0) std::transform(vec.begin(), vec.end(), vec.begin(), [factor](T x) -> T { return x * static_cast<T>(factor); }); diff --git a/Framework/Kernel/inc/MantidKernel/UserCatalogInfo.h b/Framework/Kernel/inc/MantidKernel/UserCatalogInfo.h index ff57c6ab9391bd747be5668a1cd9a01c2424bde8..5b2f259e393293c1bbf75bbead93a91023afc878 100644 --- a/Framework/Kernel/inc/MantidKernel/UserCatalogInfo.h +++ b/Framework/Kernel/inc/MantidKernel/UserCatalogInfo.h @@ -24,14 +24,14 @@ public: template <typename T> CatalogConfigService *makeCatalogConfigServiceAdapter( - const T &adaptee, const std::string key = "icatDownload.mountPoint") { + const T &adaptee, const std::string &key = "icatDownload.mountPoint") { class Adapter : public CatalogConfigService { private: const T &m_adaptee; std::string m_key; public: - Adapter(const T &adaptee, const std::string key) + Adapter(const T &adaptee, const std::string &key) : m_adaptee(adaptee), m_key(key) {} OptionalPath preferredMountPoint() const override { auto const mountPoint = m_adaptee.getString(m_key); diff --git a/Framework/Kernel/inc/MantidKernel/VisibleWhenProperty.h b/Framework/Kernel/inc/MantidKernel/VisibleWhenProperty.h index 6b4cd081f68a5af3795deb85b55cb7f2fd54612c..29340d9c51360712a331524aebb3c514590c1548 100644 --- a/Framework/Kernel/inc/MantidKernel/VisibleWhenProperty.h +++ b/Framework/Kernel/inc/MantidKernel/VisibleWhenProperty.h @@ -19,8 +19,8 @@ class DLLExport VisibleWhenProperty : public EnabledWhenProperty { public: /// Constructs a VisibleWhenProperty object which checks the property /// with name given and if it matches the criteria makes it visible - VisibleWhenProperty(std::string otherPropName, ePropertyCriterion when, - std::string value = ""); + VisibleWhenProperty(const std::string &otherPropName, ePropertyCriterion when, + const std::string &value = ""); /// Constructs a VisibleWhenProperty object which copies two /// already constructed VisibleWhenProperty objects and returns the result diff --git a/Framework/Kernel/src/ArrayProperty.cpp b/Framework/Kernel/src/ArrayProperty.cpp index a9b9652f4922a556962e2218d920ddac7926a62d..eea56e12f4e265c5c08455b76bea27226de92659 100644 --- a/Framework/Kernel/src/ArrayProperty.cpp +++ b/Framework/Kernel/src/ArrayProperty.cpp @@ -19,8 +19,8 @@ namespace Kernel { * @param direction :: The direction (Input/Output/InOut) of this property */ template <typename T> -ArrayProperty<T>::ArrayProperty(std::string name, std::vector<T> vec, - IValidator_sptr validator, +ArrayProperty<T>::ArrayProperty(const std::string &name, std::vector<T> vec, + const IValidator_sptr &validator, const unsigned int direction) : PropertyWithValue<std::vector<T>>(std::move(name), std::move(vec), std::move(validator), direction) {} @@ -34,7 +34,8 @@ ArrayProperty<T>::ArrayProperty(std::string name, std::vector<T> vec, */ template <typename T> -ArrayProperty<T>::ArrayProperty(std::string name, IValidator_sptr validator, +ArrayProperty<T>::ArrayProperty(const std::string &name, + const IValidator_sptr &validator, const unsigned int direction) : PropertyWithValue<std::vector<T>>(std::move(name), std::vector<T>(), std::move(validator), direction) {} @@ -47,7 +48,8 @@ ArrayProperty<T>::ArrayProperty(std::string name, IValidator_sptr validator, * @param direction :: The direction (Input/Output/InOut) of this property */ template <typename T> -ArrayProperty<T>::ArrayProperty(std::string name, const unsigned int direction) +ArrayProperty<T>::ArrayProperty(const std::string &name, + const unsigned int direction) : PropertyWithValue<std::vector<T>>(std::move(name), std::vector<T>(), IValidator_sptr(new NullValidator), direction) {} @@ -68,8 +70,9 @@ ArrayProperty<T>::ArrayProperty(std::string name, const unsigned int direction) * the array type */ template <typename T> -ArrayProperty<T>::ArrayProperty(std::string name, const std::string &values, - IValidator_sptr validator, +ArrayProperty<T>::ArrayProperty(const std::string &name, + const std::string &values, + const IValidator_sptr &validator, const unsigned int direction) : PropertyWithValue<std::vector<T>>(std::move(name), std::vector<T>(), values, std::move(validator), diff --git a/Framework/Kernel/src/CompositeValidator.cpp b/Framework/Kernel/src/CompositeValidator.cpp index d3a49c6555078bc263ff1c30bb8a0eb899afa9ca..696a684d5efb63554c3b030c413c576c9a52db73 100644 --- a/Framework/Kernel/src/CompositeValidator.cpp +++ b/Framework/Kernel/src/CompositeValidator.cpp @@ -68,7 +68,7 @@ Kernel::IValidator_sptr CompositeValidator::clone() const { /** Adds a validator to the group of validators to check * @param child :: A pointer to the validator to add */ -void CompositeValidator::add(Kernel::IValidator_sptr child) { +void CompositeValidator::add(const Kernel::IValidator_sptr &child) { m_children.emplace_back(child); } @@ -106,7 +106,7 @@ std::string CompositeValidator::checkAny(const boost::any &value) const { // capture its error message to a stream so we can potentially print it out // to the user if required. const auto checkIfValid = [&errorStream, - &value](const IValidator_sptr validator) { + &value](const IValidator_sptr &validator) { const auto errorMessage = validator->check(value); if (errorMessage.empty()) { return true; diff --git a/Framework/Kernel/src/ErrorReporter.cpp b/Framework/Kernel/src/ErrorReporter.cpp index 638287dac6ced487fd6e3ddd7687e5712493650c..a79d5dcd835cc8e8ca724523d9056202b48bcf5f 100644 --- a/Framework/Kernel/src/ErrorReporter.cpp +++ b/Framework/Kernel/src/ErrorReporter.cpp @@ -30,27 +30,27 @@ Logger g_log("ErrorReporter"); // Constructor for ErrorReporter /** Constructor */ -ErrorReporter::ErrorReporter(const std::string application, - const Types::Core::time_duration upTime, - const std::string exitCode, const bool share) +ErrorReporter::ErrorReporter(const std::string &application, + const Types::Core::time_duration &upTime, + const std::string &exitCode, const bool share) : ErrorReporter(application, upTime, exitCode, share, "", "", "", "") {} /** Constructor */ -ErrorReporter::ErrorReporter(const std::string application, - const Types::Core::time_duration upTime, - const std::string exitCode, const bool share, - const std::string name, const std::string email, - const std::string textBox) +ErrorReporter::ErrorReporter(const std::string &application, + const Types::Core::time_duration &upTime, + const std::string &exitCode, const bool share, + const std::string &name, const std::string &email, + const std::string &textBox) : ErrorReporter(application, upTime, exitCode, share, name, email, textBox, "") {} -ErrorReporter::ErrorReporter(const std::string application, - const Types::Core::time_duration upTime, - const std::string exitCode, const bool share, - const std::string name, const std::string email, - const std::string textBox, - const std::string traceback) +ErrorReporter::ErrorReporter(const std::string &application, + const Types::Core::time_duration &upTime, + const std::string &exitCode, const bool share, + const std::string &name, const std::string &email, + const std::string &textBox, + const std::string &traceback) : m_application(application), m_exitCode(exitCode), m_upTime(upTime), m_share(share), m_name(name), m_email(email), m_textbox(textBox), m_stacktrace(traceback) { diff --git a/Framework/Kernel/src/IndexSet.cpp b/Framework/Kernel/src/IndexSet.cpp index 9599e391dc17713a5b3b2571be065247d5fdc291..a7842786887f74e977d6e0aa099005667b141045 100644 --- a/Framework/Kernel/src/IndexSet.cpp +++ b/Framework/Kernel/src/IndexSet.cpp @@ -30,7 +30,7 @@ IndexSet::IndexSet(int64_t min, int64_t max, size_t fullRange) { /// Constructor for a set containing all specified indices. Range is verified at /// construction time and duplicates are removed. -IndexSet::IndexSet(const std::vector<size_t> indices, size_t fullRange) +IndexSet::IndexSet(const std::vector<size_t> &indices, size_t fullRange) : m_isRange(false) { // We use a set to create unique and ordered indices. std::set<size_t> index_set; diff --git a/Framework/Kernel/src/MaskedProperty.cpp b/Framework/Kernel/src/MaskedProperty.cpp index ba8d54563238dfa8998f37fb172c8597cb967da5..22e9a7dcdda790e2ba8746e3928e13ce4f768164 100644 --- a/Framework/Kernel/src/MaskedProperty.cpp +++ b/Framework/Kernel/src/MaskedProperty.cpp @@ -22,7 +22,7 @@ namespace Kernel { */ template <typename TYPE> MaskedProperty<TYPE>::MaskedProperty(const std::string &name, TYPE defaultvalue, - IValidator_sptr validator, + const IValidator_sptr &validator, const unsigned int direction) : Kernel::PropertyWithValue<TYPE>(name, defaultvalue, validator, direction), m_maskedValue("") { diff --git a/Framework/Kernel/src/Material.cpp b/Framework/Kernel/src/Material.cpp index 275508c4fd80f61062843bacb8e4ba92a9544001..72794908c5538447e7286a980fedc430c4ce933c 100644 --- a/Framework/Kernel/src/Material.cpp +++ b/Framework/Kernel/src/Material.cpp @@ -600,7 +600,7 @@ getAtomName(const std::string &text) // TODO change to get number after letters } // namespace Material::ChemicalFormula -Material::parseChemicalFormula(const std::string chemicalSymbol) { +Material::parseChemicalFormula(const std::string &chemicalSymbol) { Material::ChemicalFormula CF; tokenizer tokens(chemicalSymbol, " -", diff --git a/Framework/Kernel/src/MaterialBuilder.cpp b/Framework/Kernel/src/MaterialBuilder.cpp index 08af881eecbab11feaf43d2209374384632fa84b..23be2c3e8e6a4972b59224f0c6b92b801ae5334e 100644 --- a/Framework/Kernel/src/MaterialBuilder.cpp +++ b/Framework/Kernel/src/MaterialBuilder.cpp @@ -19,7 +19,7 @@ using PhysicalConstants::NeutronAtom; namespace Kernel { namespace { -inline bool isEmpty(const boost::optional<double> value) { +inline bool isEmpty(const boost::optional<double> &value) { return !value || value == Mantid::EMPTY_DBL(); } } // namespace diff --git a/Framework/Kernel/src/MatrixProperty.cpp b/Framework/Kernel/src/MatrixProperty.cpp index 95f70eda350f4e629b917fa962bde0e7cb24f64a..3a3cc8bad805a0b48b01467363846e438a338e57 100644 --- a/Framework/Kernel/src/MatrixProperty.cpp +++ b/Framework/Kernel/src/MatrixProperty.cpp @@ -22,7 +22,7 @@ namespace Kernel { */ template <typename TYPE> MatrixProperty<TYPE>::MatrixProperty(const std::string &propName, - IValidator_sptr validator, + const IValidator_sptr &validator, unsigned int direction) : PropertyWithValue<HeldType>(propName, HeldType(), validator, direction) {} diff --git a/Framework/Kernel/src/NexusHDF5Descriptor.cpp b/Framework/Kernel/src/NexusHDF5Descriptor.cpp index e35db03f78cbb5a20ef35e9fae98dc08aa450c2b..e0b718ab58114cca9a1d381b222588ba7c81c7bb 100644 --- a/Framework/Kernel/src/NexusHDF5Descriptor.cpp +++ b/Framework/Kernel/src/NexusHDF5Descriptor.cpp @@ -27,15 +27,12 @@ namespace { */ herr_t readStringAttribute(hid_t attr, char **data) { herr_t iRet = 0; - hid_t atype = -1; - hid_t space; - int ndims; - hsize_t thedims[H5S_MAX_RANK], sdim; - - atype = H5Aget_type(attr); - sdim = H5Tget_size(atype); - space = H5Aget_space(attr); - ndims = H5Sget_simple_extent_dims(space, thedims, NULL); + hsize_t thedims[H5S_MAX_RANK]; + + hid_t atype = H5Aget_type(attr); + hsize_t sdim = H5Tget_size(atype); + hid_t space = H5Aget_space(attr); + int ndims = H5Sget_simple_extent_dims(space, thedims, NULL); if (ndims == 0) { if (H5Tis_variable_str(atype)) { diff --git a/Framework/Kernel/src/RemoteJobManager.cpp b/Framework/Kernel/src/RemoteJobManager.cpp index 15e6cbe67032d0a1b02e24d2910131962d6e2a9a..bb6e28d9b94fabe2ab5049bb0218e59a31e2e081 100644 --- a/Framework/Kernel/src/RemoteJobManager.cpp +++ b/Framework/Kernel/src/RemoteJobManager.cpp @@ -17,6 +17,7 @@ #include <Poco/URI.h> #include <sstream> +#include <utility> namespace Mantid { namespace Kernel { @@ -182,21 +183,22 @@ std::istream &RemoteJobManager::httpPost(const std::string &path, // Wrappers for a lot of the boilerplate code needed to perform an HTTPS GET or // POST void RemoteJobManager::initGetRequest(Poco::Net::HTTPRequest &req, - std::string extraPath, - std::string queryString) { - return initHTTPRequest(req, Poco::Net::HTTPRequest::HTTP_GET, extraPath, - queryString); + const std::string &extraPath, + const std::string &queryString) { + return initHTTPRequest(req, Poco::Net::HTTPRequest::HTTP_GET, + std::move(extraPath), std::move(queryString)); } void RemoteJobManager::initPostRequest(Poco::Net::HTTPRequest &req, - std::string extraPath) { - return initHTTPRequest(req, Poco::Net::HTTPRequest::HTTP_POST, extraPath); + const std::string &extraPath) { + return initHTTPRequest(req, Poco::Net::HTTPRequest::HTTP_POST, + std::move(extraPath)); } void RemoteJobManager::initHTTPRequest(Poco::Net::HTTPRequest &req, const std::string &method, - std::string extraPath, - std::string queryString) { + const std::string &extraPath, + const std::string &queryString) { // Set up the session object if (m_session) { diff --git a/Framework/Kernel/src/SingletonHolder.cpp b/Framework/Kernel/src/SingletonHolder.cpp index c418e89babf2aa868c8990d3755263e9ff2ef143..8d41da9b4ba715dc9bc1e3868b63f918d7fddf61 100644 --- a/Framework/Kernel/src/SingletonHolder.cpp +++ b/Framework/Kernel/src/SingletonHolder.cpp @@ -36,7 +36,7 @@ void cleanupSingletons() { /// functions are added to the start of the list so on deletion it is last in, /// first out /// @param func :: Exit function to call - the singleton destructor function -void deleteOnExit(SingletonDeleterFn func) { +void deleteOnExit(const SingletonDeleterFn &func) { auto &deleters = cleanupList(); if (deleters.empty()) { atexit(&cleanupSingletons); diff --git a/Framework/Kernel/src/ThreadPool.cpp b/Framework/Kernel/src/ThreadPool.cpp index 7513c6a972cbaf732aaecfe27a2dd7e14875f3f5..3a55ae88c8d81ea87f2296f963103ae586902c01 100644 --- a/Framework/Kernel/src/ThreadPool.cpp +++ b/Framework/Kernel/src/ThreadPool.cpp @@ -125,7 +125,7 @@ void ThreadPool::start(double waitSec) { * @param task :: pointer to a Task object to run. * @param start :: start the thread at the same time; default false */ -void ThreadPool::schedule(std::shared_ptr<Task> task, bool start) { +void ThreadPool::schedule(const std::shared_ptr<Task> &task, bool start) { if (task) { m_scheduler->push(task); // Start all the threads if they were not already. diff --git a/Framework/Kernel/src/Unit.cpp b/Framework/Kernel/src/Unit.cpp index 458efa1090fd393aec315b4e89a5b0827d4d0edd..41373f2e8edd3561f7168d9a3a64779a829f497d 100644 --- a/Framework/Kernel/src/Unit.cpp +++ b/Framework/Kernel/src/Unit.cpp @@ -1291,7 +1291,8 @@ double AtomicDistance::conversionTOFMax() const { // ================================================================================ -double timeConversionValue(std::string input_unit, std::string output_unit) { +double timeConversionValue(const std::string &input_unit, + const std::string &output_unit) { std::map<std::string, double> timesList; double seconds = 1.0e9; double milliseconds = 1.0e-3 * seconds; diff --git a/Framework/Kernel/src/VisibleWhenProperty.cpp b/Framework/Kernel/src/VisibleWhenProperty.cpp index 85eb26ec50d4fdc7f66f3a467ceb5bc3a925fd4b..82adc3a460d1a945def9e28211a6ca913f06874f 100644 --- a/Framework/Kernel/src/VisibleWhenProperty.cpp +++ b/Framework/Kernel/src/VisibleWhenProperty.cpp @@ -16,9 +16,9 @@ namespace Kernel { * @param value :: For the IS_EQUAL_TO or IS_NOT_EQUAL_TO condition, the value * (as string) to check for */ -VisibleWhenProperty::VisibleWhenProperty(std::string otherPropName, +VisibleWhenProperty::VisibleWhenProperty(const std::string &otherPropName, ePropertyCriterion when, - std::string value) + const std::string &value) : EnabledWhenProperty(otherPropName, when, value) {} /** Multiple conditions constructor - takes two VisibleWhenProperty diff --git a/Framework/Kernel/test/BinaryFileTest.h b/Framework/Kernel/test/BinaryFileTest.h index 4505525a626b61d0873f239a5a07fdb0da3b0f6e..9f6440199afa45072cfbb60a4d406f5eb3beb0f2 100644 --- a/Framework/Kernel/test/BinaryFileTest.h +++ b/Framework/Kernel/test/BinaryFileTest.h @@ -33,7 +33,7 @@ struct DasEvent { }; /** Creates a dummy file with so many bytes */ -static void MakeDummyFile(std::string filename, size_t num_bytes) { +static void MakeDummyFile(const std::string &filename, size_t num_bytes) { std::vector<char> buffer(num_bytes); for (size_t i = 0; i < num_bytes; i++) { // Put 1,2,3 in 32-bit ints diff --git a/Framework/Kernel/test/ConfigPropertyObserverTest.h b/Framework/Kernel/test/ConfigPropertyObserverTest.h index eda5f9655bef291dee9bf6423fa008a478224cbe..941b29a01b4eee8b48033402c2d8523df87d6185 100644 --- a/Framework/Kernel/test/ConfigPropertyObserverTest.h +++ b/Framework/Kernel/test/ConfigPropertyObserverTest.h @@ -15,7 +15,7 @@ using namespace Mantid::Kernel; template <typename Callback> class MockObserver : ConfigPropertyObserver { public: - MockObserver(std::string propertyName, Callback callback) + MockObserver(const std::string &propertyName, Callback callback) : ConfigPropertyObserver(std::move(propertyName)), m_callback(callback) {} protected: diff --git a/Framework/Kernel/test/CowPtrTest.h b/Framework/Kernel/test/CowPtrTest.h index e8de0414bac436662920b2c08a1af1d08eab3687..5736a8dee62a2ad73e15066b772ce1b91c2a0e69 100644 --- a/Framework/Kernel/test/CowPtrTest.h +++ b/Framework/Kernel/test/CowPtrTest.h @@ -10,6 +10,7 @@ #include <boost/make_shared.hpp> #include <boost/shared_ptr.hpp> #include <cxxtest/TestSuite.h> +#include <memory> using namespace Mantid::Kernel; @@ -38,9 +39,8 @@ public: } void testConstructorByPtr() { - - auto *resource = new MyType{2}; - cow_ptr<MyType> cow{resource}; + auto resource = std::make_unique<MyType>(2); + cow_ptr<MyType> cow{resource.release()}; TSM_ASSERT_EQUALS("COW does not hold the expected value", 2, cow->value); } diff --git a/Framework/Kernel/test/InterpolationTest.h b/Framework/Kernel/test/InterpolationTest.h index 9d9e41a15f477a12f775e40f34a7f1e0e8e0be6b..47a491ff8b9e2a2408a0c57d3017f986be5a633e 100644 --- a/Framework/Kernel/test/InterpolationTest.h +++ b/Framework/Kernel/test/InterpolationTest.h @@ -227,8 +227,8 @@ public: } private: - Interpolation getInitializedInterpolation(std::string xUnit, - std::string yUnit) { + Interpolation getInitializedInterpolation(const std::string &xUnit, + const std::string &yUnit) { Interpolation interpolation; // take values from constructor @@ -286,7 +286,7 @@ private: * It takes a string argument to make it more obvious where the problem is. */ void checkValue(const Interpolation &interpolation, double x, double y, - std::string testedRange) { + const std::string &testedRange) { std::ostringstream errorString; errorString << "Interpolation error " << testedRange; diff --git a/Framework/Kernel/test/LogParserTest.h b/Framework/Kernel/test/LogParserTest.h index cc2e5d5e9fbf3e5c9e806f9e1ed44ce967ef0e39..47f6e248f6eb27b6d50948a2afe6c9f78c01672f 100644 --- a/Framework/Kernel/test/LogParserTest.h +++ b/Framework/Kernel/test/LogParserTest.h @@ -69,10 +69,10 @@ public: const auto &ti_data1 = v->first.to_tm(); TS_ASSERT_EQUALS(ti_data1.tm_hour, 12); TS_ASSERT_EQUALS(ti_data1.tm_min, 22); - v++; - v++; - v++; - v++; + ++v; + ++v; + ++v; + ++v; // time 5 const auto &ti_data5 = v->first.to_tm(); TS_ASSERT_EQUALS(ti_data5.tm_hour, 12); @@ -119,10 +119,10 @@ public: const auto &ti_data1 = v->first.to_tm(); TS_ASSERT_EQUALS(ti_data1.tm_hour, 12); TS_ASSERT_EQUALS(ti_data1.tm_min, 22); - v++; - v++; - v++; - v++; + ++v; + ++v; + ++v; + ++v; // time 5 const auto &ti_data5 = v->first.to_tm(); TS_ASSERT_EQUALS(ti_data5.tm_hour, 12); @@ -156,10 +156,10 @@ public: const auto &ti_data1 = v->first.to_tm(); TS_ASSERT_EQUALS(ti_data1.tm_hour, 12); TS_ASSERT_EQUALS(ti_data1.tm_min, 22); - v++; - v++; - v++; - v++; + ++v; + ++v; + ++v; + ++v; // time 5 const auto &ti_data5 = v->first.to_tm(); TS_ASSERT_EQUALS(ti_data5.tm_hour, 12); @@ -216,9 +216,9 @@ public: const auto &ti_data1 = v->first.to_tm(); TS_ASSERT_EQUALS(ti_data1.tm_hour, 12); TS_ASSERT_EQUALS(ti_data1.tm_min, 22); - v++; - v++; - v++; + ++v; + ++v; + ++v; // time 4 TS_ASSERT_EQUALS(v->second, " line 4"); const auto &ti_data4 = v->first.to_tm(); @@ -381,10 +381,10 @@ public: const auto &ti_data1 = v->first.to_tm(); TS_ASSERT_EQUALS(ti_data1.tm_hour, 12); TS_ASSERT_EQUALS(ti_data1.tm_min, 22); - v++; - v++; - v++; - v++; + ++v; + ++v; + ++v; + ++v; // time 5 // TS_ASSERT(!isNaN(v->second)); // last time diff --git a/Framework/Kernel/test/RegexStringsTest.h b/Framework/Kernel/test/RegexStringsTest.h index 6eed39b23afb3fb8b0b2545dc0e9f6adc29324ba..4f3e6c5dbdb971b307fc6bf90c0a37aa0a01324a 100644 --- a/Framework/Kernel/test/RegexStringsTest.h +++ b/Framework/Kernel/test/RegexStringsTest.h @@ -144,7 +144,6 @@ public: } void testStrFullCut() { - std::vector<double> dblresult; double sgldblResult; std::string input("100.01 101.02 103.04 105.06 Remainder of string"); TS_ASSERT_EQUALS( diff --git a/Framework/Kernel/test/SimpleJSONTest.h b/Framework/Kernel/test/SimpleJSONTest.h index 19e730790ae0e460fd90cc155537fd2ae645b111..e4c1e478db2e8b71dea5fa383524e9e351bb1c99 100644 --- a/Framework/Kernel/test/SimpleJSONTest.h +++ b/Framework/Kernel/test/SimpleJSONTest.h @@ -51,8 +51,6 @@ public: void test_JSONArray() { std::string str = "json failure here"; - std::istringstream input(str); - std::string res; JSONArray ja; TS_ASSERT_THROWS_NOTHING(ja.emplace_back(str)); @@ -64,11 +62,10 @@ public: } void test_JSONObjectWrongStrings() { - std::string str = "json failure here"; - std::istringstream input(str); + std::istringstream input; std::string res; - str = ""; + std::string str = ""; JSONObject jo; TS_ASSERT_THROWS(initFromStream(jo, input), const JSONParseException &); TS_ASSERT_THROWS_NOTHING(jo["no_param"].getValue(res)); diff --git a/Framework/Kernel/test/ThreadSchedulerMutexesTest.h b/Framework/Kernel/test/ThreadSchedulerMutexesTest.h index 3c745e553dfc4d9e4ead76b366fd3e9a5d97b809..d2c7285e9324004ec011c800d0e7e90c0e441e5b 100644 --- a/Framework/Kernel/test/ThreadSchedulerMutexesTest.h +++ b/Framework/Kernel/test/ThreadSchedulerMutexesTest.h @@ -9,6 +9,8 @@ #include "MantidKernel/System.h" #include "MantidKernel/Timer.h" #include <boost/make_shared.hpp> +#include <utility> + #include <cxxtest/TestSuite.h> #include "MantidKernel/ThreadSchedulerMutexes.h" @@ -24,7 +26,7 @@ public: class TaskWithMutex : public Task { public: TaskWithMutex(boost::shared_ptr<std::mutex> mutex, double cost) { - m_mutex = mutex; + m_mutex = std::move(mutex); m_cost = cost; } diff --git a/Framework/Kernel/test/TypedValidatorTest.h b/Framework/Kernel/test/TypedValidatorTest.h index 266c39e55661a00228aadfb3de2e385e8044825b..2be8724760fa3bfacff1882c0873bc5d70b60c0b 100644 --- a/Framework/Kernel/test/TypedValidatorTest.h +++ b/Framework/Kernel/test/TypedValidatorTest.h @@ -69,7 +69,7 @@ public: private: template <typename HeldType> void checkIsValidReturnsEmptyString( - const Mantid::Kernel::IValidator_sptr valueChecker, + const Mantid::Kernel::IValidator_sptr &valueChecker, const HeldType &value) { std::string error; TS_ASSERT_THROWS_NOTHING(error = valueChecker->isValid(value)); diff --git a/Framework/Kernel/test/UnitLabelTest.h b/Framework/Kernel/test/UnitLabelTest.h index e3a3db0efc8c83c22a5f9485d40bb318c2bb2f35..0b383a9f9847ef0f9f514d74089f94b512529390 100644 --- a/Framework/Kernel/test/UnitLabelTest.h +++ b/Framework/Kernel/test/UnitLabelTest.h @@ -70,7 +70,7 @@ public: } private: - void doImplicitConversionTest(UnitLabel lbl, std::string expected) { + void doImplicitConversionTest(const UnitLabel &lbl, std::string expected) { TS_ASSERT_EQUALS(expected, lbl.ascii()); const auto &utf8 = lbl.utf8(); TS_ASSERT_EQUALS(std::wstring(expected.begin(), expected.end()), utf8); diff --git a/Framework/LiveData/inc/MantidLiveData/ISIS/ISISHistoDataListener.h b/Framework/LiveData/inc/MantidLiveData/ISIS/ISISHistoDataListener.h index 6bec842c938e8c429479d6214bb9fde7b460586b..77179fa9b50eb13ae9db68b3e0c672098b92a20f 100644 --- a/Framework/LiveData/inc/MantidLiveData/ISIS/ISISHistoDataListener.h +++ b/Framework/LiveData/inc/MantidLiveData/ISIS/ISISHistoDataListener.h @@ -62,13 +62,14 @@ private: void getIntArray(const std::string &par, std::vector<int> &arr, const size_t dim); void getData(int period, int index, int count, - boost::shared_ptr<API::MatrixWorkspace> workspace, + const boost::shared_ptr<API::MatrixWorkspace> &workspace, size_t workspaceIndex); void calculateIndicesForReading(std::vector<int> &index, std::vector<int> &count); void loadSpectraMap(); - void runLoadInstrument(boost::shared_ptr<API::MatrixWorkspace> localWorkspace, - const std::string &iName); + void runLoadInstrument( + const boost::shared_ptr<API::MatrixWorkspace> &localWorkspace, + const std::string &iName); void loadTimeRegimes(); int getTimeRegimeToLoad() const; bool isPeriodIgnored(int period) const; diff --git a/Framework/LiveData/inc/MantidLiveData/Kafka/IKafkaStreamDecoder.h b/Framework/LiveData/inc/MantidLiveData/Kafka/IKafkaStreamDecoder.h index 36fc120bfc654f0cc446b422f5ed63622f254957..461ee24881c351223b95fdcf5ac79fab9f112d91 100644 --- a/Framework/LiveData/inc/MantidLiveData/Kafka/IKafkaStreamDecoder.h +++ b/Framework/LiveData/inc/MantidLiveData/Kafka/IKafkaStreamDecoder.h @@ -35,7 +35,7 @@ public: public: using FnType = std::function<void()>; - Callback(Callback::FnType callback) : m_mutex(), m_callback() { + Callback(const Callback::FnType &callback) : m_mutex(), m_callback() { setFunction(std::move(callback)); } diff --git a/Framework/LiveData/inc/MantidLiveData/LoadLiveData.h b/Framework/LiveData/inc/MantidLiveData/LoadLiveData.h index 3d5dda4a210a9ffb12ddb0b1588027883b0a0dda..67c22d079b2b46bd7708021d1a0ac2f4c15e5b5f 100644 --- a/Framework/LiveData/inc/MantidLiveData/LoadLiveData.h +++ b/Framework/LiveData/inc/MantidLiveData/LoadLiveData.h @@ -42,14 +42,15 @@ private: void runPostProcessing(); void replaceChunk(Mantid::API::Workspace_sptr chunkWS); - void addChunk(Mantid::API::Workspace_sptr chunkWS); - void addMatrixWSChunk(API::Workspace_sptr accumWS, - API::Workspace_sptr chunkWS); + void addChunk(const Mantid::API::Workspace_sptr &chunkWS); + void addMatrixWSChunk(const API::Workspace_sptr &accumWS, + const API::Workspace_sptr &chunkWS); void addMDWSChunk(API::Workspace_sptr &accumWS, const API::Workspace_sptr &chunkWS); - void appendChunk(Mantid::API::Workspace_sptr chunkWS); - API::Workspace_sptr appendMatrixWSChunk(API::Workspace_sptr accumWS, - Mantid::API::Workspace_sptr chunkWS); + void appendChunk(const Mantid::API::Workspace_sptr &chunkWS); + API::Workspace_sptr + appendMatrixWSChunk(API::Workspace_sptr accumWS, + const Mantid::API::Workspace_sptr &chunkWS); void updateDefaultBinBoundaries(API::Workspace *workspace); /// The "accumulation" workspace = after adding, but before post-processing diff --git a/Framework/LiveData/src/ISIS/DAE/isisds_command.cpp b/Framework/LiveData/src/ISIS/DAE/isisds_command.cpp index 3ac632ce22bc2cb6f4a5f2157a91c00455eecddc..0a1d994f055b40da16b6730c209c505b265a3bf9 100644 --- a/Framework/LiveData/src/ISIS/DAE/isisds_command.cpp +++ b/Framework/LiveData/src/ISIS/DAE/isisds_command.cpp @@ -86,10 +86,10 @@ typedef struct { /* wait until read len bytes, return <=0 on error */ static int recv_all(SOCKET s, void *buffer, int len, int flags) { auto *cbuffer = reinterpret_cast<char *>(buffer); - int n, ntot; + int ntot; ntot = 0; while (len > 0) { - n = recv(s, cbuffer, len, flags); + int n = recv(s, cbuffer, len, flags); if (n <= 0) { return n; /* error */ } @@ -283,7 +283,7 @@ int isisds_send_command(SOCKET s, const char *command, const void *data, static int isisds_recv_command_helper(SOCKET s, char **command, void **data, ISISDSDataType *type, int dims_array[], int *ndims, int do_alloc) { - int n, len_data, size_in, i; + int n, len_data, i; isisds_command_header_t comm; n = recv_all(s, reinterpret_cast<char *>(&comm), sizeof(comm), 0); if (n != sizeof(comm)) { @@ -308,7 +308,7 @@ static int isisds_recv_command_helper(SOCKET s, char **command, void **data, *data = malloc(len_data + 1); (reinterpret_cast<char *>(*data))[len_data] = '\0'; } else { - size_in = 1; + int size_in = 1; for (i = 0; i < *ndims; i++) { size_in *= dims_array[i]; } diff --git a/Framework/LiveData/src/ISIS/FakeISISEventDAE.cpp b/Framework/LiveData/src/ISIS/FakeISISEventDAE.cpp index dfc83b63f7b46cb7e0243b12dfdd815b89df572e..73abf7e03159e7791935b9eedfa5091fd23a4e0e 100644 --- a/Framework/LiveData/src/ISIS/FakeISISEventDAE.cpp +++ b/Framework/LiveData/src/ISIS/FakeISISEventDAE.cpp @@ -17,6 +17,8 @@ #include <Poco/Net/StreamSocket.h> #include <Poco/Net/TCPServer.h> +#include <utility> + namespace Mantid { namespace LiveData { // Register the algorithm into the algorithm factory @@ -46,7 +48,8 @@ public: TestServerConnection(const Poco::Net::StreamSocket &soc, int nper, int nspec, int rate, int nevents, boost::shared_ptr<Progress> prog) : Poco::Net::TCPServerConnection(soc), m_nPeriods(nper), - m_nSpectra(nspec), m_Rate(rate), m_nEvents(nevents), m_prog(prog) { + m_nSpectra(nspec), m_Rate(rate), m_nEvents(nevents), + m_prog(std::move(prog)) { m_prog->report(0, "Client Connected"); sendInitialSetup(); } @@ -135,7 +138,8 @@ public: TestServerConnectionFactory(int nper, int nspec, int rate, int nevents, boost::shared_ptr<Progress> prog) : Poco::Net::TCPServerConnectionFactory(), m_nPeriods(nper), - m_nSpectra(nspec), m_Rate(rate), m_nEvents(nevents), m_prog(prog) {} + m_nSpectra(nspec), m_Rate(rate), m_nEvents(nevents), + m_prog(std::move(prog)) {} /** * The factory method. * @param socket :: The socket. diff --git a/Framework/LiveData/src/ISIS/ISISHistoDataListener.cpp b/Framework/LiveData/src/ISIS/ISISHistoDataListener.cpp index cb3d773355b5b45cf3d4006a642e48e5995b0f9f..f5b701b2778e5bc43ef17e0d4b83079e856adae8 100644 --- a/Framework/LiveData/src/ISIS/ISISHistoDataListener.cpp +++ b/Framework/LiveData/src/ISIS/ISISHistoDataListener.cpp @@ -422,7 +422,7 @@ void ISISHistoDataListener::calculateIndicesForReading( * @param workspaceIndex :: index in workspace to store data */ void ISISHistoDataListener::getData(int period, int index, int count, - API::MatrixWorkspace_sptr workspace, + const API::MatrixWorkspace_sptr &workspace, size_t workspaceIndex) { const int numberOfBins = m_numberOfBins[m_timeRegime]; const size_t bufferSize = count * (numberOfBins + 1) * sizeof(int); @@ -466,7 +466,7 @@ void ISISHistoDataListener::loadSpectraMap() { * @param iName :: The instrument name */ void ISISHistoDataListener::runLoadInstrument( - MatrixWorkspace_sptr localWorkspace, const std::string &iName) { + const MatrixWorkspace_sptr &localWorkspace, const std::string &iName) { auto loadInst = API::AlgorithmFactory::Instance().create("LoadInstrument", -1); if (!loadInst) diff --git a/Framework/LiveData/src/Kafka/IKafkaStreamDecoder.cpp b/Framework/LiveData/src/Kafka/IKafkaStreamDecoder.cpp index 588fec16bf274e85898e358716a6c6a1ec9e8b91..4f8ac88f0fe38254a78cae4183ffa3f9839ef1a0 100644 --- a/Framework/LiveData/src/Kafka/IKafkaStreamDecoder.cpp +++ b/Framework/LiveData/src/Kafka/IKafkaStreamDecoder.cpp @@ -21,6 +21,8 @@ GNU_DIAG_ON("conversion") #include <json/json.h> +#include <utility> + using namespace Mantid::Types; namespace { @@ -54,7 +56,7 @@ IKafkaStreamDecoder::IKafkaStreamDecoder(std::shared_ptr<IKafkaBroker> broker, const std::string &sampleEnvTopic, const std::string &chopperTopic, const std::string &monitorTopic) - : m_broker(broker), m_streamTopic(streamTopic), + : m_broker(std::move(broker)), m_streamTopic(streamTopic), m_runInfoTopic(runInfoTopic), m_spDetTopic(spDetTopic), m_sampleEnvTopic(sampleEnvTopic), m_chopperTopic(chopperTopic), m_monitorTopic(monitorTopic), m_interrupt(false), m_specToIdx(), @@ -227,7 +229,7 @@ void IKafkaStreamDecoder::checkIfAllStopOffsetsReached( bool &checkOffsets) { if (std::all_of(reachedEnd.cbegin(), reachedEnd.cend(), - [](std::pair<std::string, std::vector<bool>> kv) { + [](const std::pair<std::string, std::vector<bool>> &kv) { return std::all_of( kv.second.cbegin(), kv.second.cend(), [](bool partitionEnd) { return partitionEnd; }); diff --git a/Framework/LiveData/src/Kafka/KafkaBroker.cpp b/Framework/LiveData/src/Kafka/KafkaBroker.cpp index d9a261729ea6ae14ea1cd6c29d7afd6799eea215..574ef98cc5fd2ad991eb74b505bcea2508c462b9 100644 --- a/Framework/LiveData/src/Kafka/KafkaBroker.cpp +++ b/Framework/LiveData/src/Kafka/KafkaBroker.cpp @@ -4,6 +4,8 @@ // NScD Oak Ridge National Laboratory, European Spallation Source, // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + +#include <utility> + #include "MantidLiveData/Kafka/KafkaBroker.h" #include "MantidLiveData/Kafka/KafkaTopicSubscriber.h" @@ -15,7 +17,7 @@ namespace LiveData { * @param address The address of a broker in the form host:port */ KafkaBroker::KafkaBroker(std::string address) - : IKafkaBroker(), m_address(address) {} + : IKafkaBroker(), m_address(std::move(address)) {} /** * Create an object to provide access to a topic stream from this broker diff --git a/Framework/LiveData/src/Kafka/KafkaEventStreamDecoder.cpp b/Framework/LiveData/src/Kafka/KafkaEventStreamDecoder.cpp index 65e2f62c8f165b518794f67e7f11cfb49e8f9cf2..6a97ab35a03390685e88641a8a5edac7e36c0645 100644 --- a/Framework/LiveData/src/Kafka/KafkaEventStreamDecoder.cpp +++ b/Framework/LiveData/src/Kafka/KafkaEventStreamDecoder.cpp @@ -30,6 +30,8 @@ GNU_DIAG_ON("conversion") #include <chrono> #include <json/json.h> #include <numeric> +#include <utility> + #include <tbb/parallel_sort.h> using namespace Mantid::Types; @@ -120,8 +122,9 @@ KafkaEventStreamDecoder::KafkaEventStreamDecoder( const std::string &runInfoTopic, const std::string &spDetTopic, const std::string &sampleEnvTopic, const std::string &chopperTopic, const std::string &monitorTopic, const std::size_t bufferThreshold) - : IKafkaStreamDecoder(broker, eventTopic, runInfoTopic, spDetTopic, - sampleEnvTopic, chopperTopic, monitorTopic), + : IKafkaStreamDecoder(std::move(broker), eventTopic, runInfoTopic, + spDetTopic, sampleEnvTopic, chopperTopic, + monitorTopic), m_intermediateBufferFlushThreshold(bufferThreshold) { #ifndef _OPENMP g_log.warning() << "Multithreading is not available on your system. This " diff --git a/Framework/LiveData/src/Kafka/KafkaHistoStreamDecoder.cpp b/Framework/LiveData/src/Kafka/KafkaHistoStreamDecoder.cpp index 4c9b432d3e398dd9a460aeff696de8153a66c6e0..90398f877667b872eeb9f6ee544cb3c6bd62aea4 100644 --- a/Framework/LiveData/src/Kafka/KafkaHistoStreamDecoder.cpp +++ b/Framework/LiveData/src/Kafka/KafkaHistoStreamDecoder.cpp @@ -29,6 +29,8 @@ GNU_DIAG_ON("conversion") #include <json/json.h> +#include <utility> + namespace { const std::string PROTON_CHARGE_PROPERTY = "proton_charge"; const std::string RUN_NUMBER_PROPERTY = "run_number"; @@ -59,8 +61,8 @@ KafkaHistoStreamDecoder::KafkaHistoStreamDecoder( std::shared_ptr<IKafkaBroker> broker, const std::string &histoTopic, const std::string &runInfoTopic, const std::string &spDetTopic, const std::string &sampleEnvTopic, const std::string &chopperTopic) - : IKafkaStreamDecoder(broker, histoTopic, runInfoTopic, spDetTopic, - sampleEnvTopic, chopperTopic, ""), + : IKafkaStreamDecoder(std::move(broker), histoTopic, runInfoTopic, + spDetTopic, sampleEnvTopic, chopperTopic, ""), m_workspace() {} /** diff --git a/Framework/LiveData/src/Kafka/KafkaTopicSubscriber.cpp b/Framework/LiveData/src/Kafka/KafkaTopicSubscriber.cpp index d79f64752b32100666557e6cbc760be4205359e4..93d2fba8ed39ef9685be4bbaf46d55b85bc2e9bf 100644 --- a/Framework/LiveData/src/Kafka/KafkaTopicSubscriber.cpp +++ b/Framework/LiveData/src/Kafka/KafkaTopicSubscriber.cpp @@ -13,6 +13,7 @@ #include <iostream> #include <sstream> #include <thread> +#include <utility> using RdKafka::Conf; using RdKafka::KafkaConsumer; @@ -77,8 +78,8 @@ const std::string KafkaTopicSubscriber::MONITOR_TOPIC_SUFFIX = "_monitors"; KafkaTopicSubscriber::KafkaTopicSubscriber(std::string broker, std::vector<std::string> topics, SubscribeAtOption subscribeOption) - : IKafkaStreamSubscriber(), m_consumer(), m_brokerAddr(broker), - m_topicNames(topics), m_subscribeOption(subscribeOption) {} + : IKafkaStreamSubscriber(), m_consumer(), m_brokerAddr(std::move(broker)), + m_topicNames(std::move(topics)), m_subscribeOption(subscribeOption) {} /// Destructor KafkaTopicSubscriber::~KafkaTopicSubscriber() { diff --git a/Framework/LiveData/src/LiveDataAlgorithm.cpp b/Framework/LiveData/src/LiveDataAlgorithm.cpp index 01dbfe061d59b0e95a77366f397a0e53cdc226bb..64e8c16429adbf524353604d5b25c35d27339d83 100644 --- a/Framework/LiveData/src/LiveDataAlgorithm.cpp +++ b/Framework/LiveData/src/LiveDataAlgorithm.cpp @@ -17,6 +17,7 @@ #include <boost/algorithm/string/trim.hpp> #include <unordered_set> +#include <utility> using namespace Mantid::Kernel; using namespace Mantid::API; @@ -260,7 +261,7 @@ ILiveListener_sptr LiveDataAlgorithm::createLiveListener(bool connect) { */ void LiveDataAlgorithm::setLiveListener( Mantid::API::ILiveListener_sptr listener) { - m_listener = listener; + m_listener = std::move(listener); } //---------------------------------------------------------------------------------------------- diff --git a/Framework/LiveData/src/LoadLiveData.cpp b/Framework/LiveData/src/LoadLiveData.cpp index 6010a8160b5fabcba373137968bf0085b162341a..b41ca72a8893d2a359df9640861810c758e99f4c 100644 --- a/Framework/LiveData/src/LoadLiveData.cpp +++ b/Framework/LiveData/src/LoadLiveData.cpp @@ -15,6 +15,7 @@ #include "MantidLiveData/Exception.h" #include <boost/algorithm/string.hpp> +#include <utility> #include <Poco/Thread.h> @@ -204,7 +205,7 @@ LoadLiveData::runProcessing(Mantid::API::Workspace_sptr inputWS, Mantid::API::Workspace_sptr LoadLiveData::processChunk(Mantid::API::Workspace_sptr chunkWS) { try { - return runProcessing(chunkWS, false); + return runProcessing(std::move(chunkWS), false); } catch (...) { g_log.error("While processing chunk:"); throw; @@ -232,7 +233,7 @@ void LoadLiveData::runPostProcessing() { * * @param chunkWS :: processed live data chunk workspace */ -void LoadLiveData::addChunk(Mantid::API::Workspace_sptr chunkWS) { +void LoadLiveData::addChunk(const Mantid::API::Workspace_sptr &chunkWS) { // Acquire locks on the workspaces we use WriteLock _lock1(*m_accumWS); ReadLock _lock2(*chunkWS); @@ -273,8 +274,8 @@ void LoadLiveData::addChunk(Mantid::API::Workspace_sptr chunkWS) { * @param accumWS :: accumulation matrix workspace * @param chunkWS :: processed live data chunk matrix workspace */ -void LoadLiveData::addMatrixWSChunk(Workspace_sptr accumWS, - Workspace_sptr chunkWS) { +void LoadLiveData::addMatrixWSChunk(const Workspace_sptr &accumWS, + const Workspace_sptr &chunkWS) { // Handle the addition of the internal monitor workspace, if present auto accumMW = boost::dynamic_pointer_cast<MatrixWorkspace>(accumWS); auto chunkMW = boost::dynamic_pointer_cast<MatrixWorkspace>(chunkWS); @@ -342,7 +343,7 @@ void LoadLiveData::replaceChunk(Mantid::API::Workspace_sptr chunkWS) { auto instrumentWS = m_accumWS; // When the algorithm exits the chunk workspace will be renamed // and overwrite the old one - m_accumWS = chunkWS; + m_accumWS = std::move(chunkWS); // Put the original instrument back. Otherwise geometry changes will not be // persistent copyInstrument(instrumentWS.get(), m_accumWS.get()); @@ -358,7 +359,7 @@ void LoadLiveData::replaceChunk(Mantid::API::Workspace_sptr chunkWS) { * * @param chunkWS :: processed live data chunk workspace */ -void LoadLiveData::appendChunk(Mantid::API::Workspace_sptr chunkWS) { +void LoadLiveData::appendChunk(const Mantid::API::Workspace_sptr &chunkWS) { // ISIS multi-period data come in workspace groups WorkspaceGroup_sptr chunk_gws = boost::dynamic_pointer_cast<WorkspaceGroup>(chunkWS); @@ -400,8 +401,9 @@ void LoadLiveData::appendChunk(Mantid::API::Workspace_sptr chunkWS) { * @param accumWS :: accumulation matrix workspace * @param chunkWS :: processed live data chunk matrix workspace */ -Workspace_sptr LoadLiveData::appendMatrixWSChunk(Workspace_sptr accumWS, - Workspace_sptr chunkWS) { +Workspace_sptr +LoadLiveData::appendMatrixWSChunk(Workspace_sptr accumWS, + const Workspace_sptr &chunkWS) { IAlgorithm_sptr alg; ReadLock _lock1(*accumWS); ReadLock _lock2(*chunkWS); diff --git a/Framework/LiveData/test/KafkaEventStreamDecoderTest.h b/Framework/LiveData/test/KafkaEventStreamDecoderTest.h index 244435a658bf8c6b988ef5b672cca4226e221a57..a3ca5e72d75be07edb4d483f319e9ec761d6f10d 100644 --- a/Framework/LiveData/test/KafkaEventStreamDecoderTest.h +++ b/Framework/LiveData/test/KafkaEventStreamDecoderTest.h @@ -19,8 +19,11 @@ #include <Poco/Path.h> #include <condition_variable> +#include <iostream> #include <thread> +using Mantid::LiveData::KafkaEventStreamDecoder; + class KafkaEventStreamDecoderTest : public CxxTest::TestSuite { public: // This pair of boilerplate methods prevent the suite being created statically @@ -512,43 +515,54 @@ private: void startCapturing(Mantid::LiveData::KafkaEventStreamDecoder &decoder, uint8_t maxIterations) { // Register callback to know when a whole loop as been iterated through + m_maxIterations = maxIterations; m_niterations = 0; - auto callback = [this, maxIterations]() { - this->iterationCallback(maxIterations); - }; - decoder.registerIterationEndCb(callback); - decoder.registerErrorCb(callback); + decoder.registerIterationEndCb([this]() { this->iterationCallback(); }); + + decoder.registerErrorCb([this, &decoder]() { errCallback(decoder); }); TS_ASSERT_THROWS_NOTHING(decoder.startCapture()); continueCapturing(decoder, maxIterations); } - void iterationCallback(uint8_t maxIterations) { + void iterationCallback() { std::unique_lock<std::mutex> lock(this->m_callbackMutex); this->m_niterations++; - if (this->m_niterations == maxIterations) { + if (this->m_niterations == m_maxIterations) { lock.unlock(); this->m_callbackCondition.notify_one(); } } - void continueCapturing(Mantid::LiveData::KafkaEventStreamDecoder &decoder, + void errCallback(KafkaEventStreamDecoder &decoder) { + try { + // Get the stored exception by calling extract data again + decoder.extractData(); + } catch (std::exception &e) { + // We could try to port the exception from this child thread to the main + // thread, or just print it here which is significantly easier + std::cerr << "Exception: " << e.what() << "\n"; + // Always keep incrementing so we don't deadlock + iterationCallback(); + } + } + + void continueCapturing(KafkaEventStreamDecoder &decoder, uint8_t maxIterations) { + m_maxIterations = maxIterations; + // Re-register callback with the (potentially) new value of maxIterations - auto callback = [this, maxIterations]() { - this->iterationCallback(maxIterations); - }; - decoder.registerIterationEndCb(callback); - decoder.registerErrorCb(callback); + decoder.registerIterationEndCb([this]() { this->iterationCallback(); }); + decoder.registerErrorCb([this, &decoder]() { errCallback(decoder); }); + { std::unique_lock<std::mutex> lk(m_callbackMutex); - this->m_callbackCondition.wait(lk, [this, maxIterations]() { - return this->m_niterations == maxIterations; - }); + this->m_callbackCondition.wait( + lk, [this]() { return this->m_niterations == m_maxIterations; }); } } - std::unique_ptr<Mantid::LiveData::KafkaEventStreamDecoder> - createTestDecoder(std::shared_ptr<Mantid::LiveData::IKafkaBroker> broker) { + std::unique_ptr<Mantid::LiveData::KafkaEventStreamDecoder> createTestDecoder( + const std::shared_ptr<Mantid::LiveData::IKafkaBroker> &broker) { using namespace Mantid::LiveData; return std::make_unique<KafkaEventStreamDecoder>(broker, "", "", "", "", "", "", 0); @@ -574,8 +588,8 @@ private: void checkWorkspaceEventData( const Mantid::DataObjects::EventWorkspace &eventWksp) { - // A timer-based test and each message contains 6 events so the total should - // be divisible by 6, but not be 0 + // A timer-based test and each message contains 6 events so the total + // should be divisible by 6, but not be 0 TS_ASSERT(eventWksp.getNumberEvents() % 6 == 0); TS_ASSERT(eventWksp.getNumberEvents() != 0); } @@ -597,4 +611,5 @@ private: std::mutex m_callbackMutex; std::condition_variable m_callbackCondition; uint8_t m_niterations = 0; + std::atomic<uint8_t> m_maxIterations = 0; }; diff --git a/Framework/LiveData/test/KafkaHistoStreamDecoderTest.h b/Framework/LiveData/test/KafkaHistoStreamDecoderTest.h index 25196cc10b1816826cd226353186c0a99ef7cc54..3fc38756533dd776dda7b5c80e6e3bb4a843b739 100644 --- a/Framework/LiveData/test/KafkaHistoStreamDecoderTest.h +++ b/Framework/LiveData/test/KafkaHistoStreamDecoderTest.h @@ -94,8 +94,8 @@ public: } private: - std::unique_ptr<Mantid::LiveData::KafkaHistoStreamDecoder> - createTestDecoder(std::shared_ptr<Mantid::LiveData::IKafkaBroker> broker) { + std::unique_ptr<Mantid::LiveData::KafkaHistoStreamDecoder> createTestDecoder( + const std::shared_ptr<Mantid::LiveData::IKafkaBroker> &broker) { using namespace Mantid::LiveData; return std::make_unique<KafkaHistoStreamDecoder>(broker, "", "", "", "", ""); diff --git a/Framework/LiveData/test/KafkaTesting.h b/Framework/LiveData/test/KafkaTesting.h index 11670e3e785a6531389dcbc098e3265d19ab24ac..85738a1355caaf142623756c1c149f99081460de 100644 --- a/Framework/LiveData/test/KafkaTesting.h +++ b/Framework/LiveData/test/KafkaTesting.h @@ -220,7 +220,7 @@ void fakeReceiveASampleEnvMessage(std::string *buffer) { void fakeReceiveARunStartMessage(std::string *buffer, int32_t runNumber, const std::string &startTime, const std::string &instName, int32_t nPeriods, - std::string nexusStructure = "") { + const std::string &nexusStructure = "") { // Convert date to time_t auto mantidTime = Mantid::Types::Core::DateAndTime(startTime); auto startTimestamp = diff --git a/Framework/LiveData/test/LoadLiveDataTest.h b/Framework/LiveData/test/LoadLiveDataTest.h index 92b08d01875f866ad97949ff87513fccca580928..146a2afd6e50f01e3e5264c118d570d604bb785d 100644 --- a/Framework/LiveData/test/LoadLiveDataTest.h +++ b/Framework/LiveData/test/LoadLiveDataTest.h @@ -53,11 +53,13 @@ public: */ template <typename TYPE> boost::shared_ptr<TYPE> - doExec(std::string AccumulationMethod, std::string ProcessingAlgorithm = "", - std::string ProcessingProperties = "", - std::string PostProcessingAlgorithm = "", - std::string PostProcessingProperties = "", bool PreserveEvents = true, - ILiveListener_sptr listener = ILiveListener_sptr(), + doExec(const std::string &AccumulationMethod, + const std::string &ProcessingAlgorithm = "", + const std::string &ProcessingProperties = "", + const std::string &PostProcessingAlgorithm = "", + const std::string &PostProcessingProperties = "", + bool PreserveEvents = true, + const ILiveListener_sptr &listener = ILiveListener_sptr(), bool makeThrow = false) { FacilityHelper::ScopedFacilities loadTESTFacility( "unit_testing/UnitTestFacilities.xml", "TEST"); diff --git a/Framework/LiveData/test/MonitorLiveDataTest.h b/Framework/LiveData/test/MonitorLiveDataTest.h index 48d02480083ccc6c1ec2f1cb4f30ee4d87db5165..26575e099c00b333a620511a3456c13d28041caf 100644 --- a/Framework/LiveData/test/MonitorLiveDataTest.h +++ b/Framework/LiveData/test/MonitorLiveDataTest.h @@ -61,10 +61,10 @@ public: /** Create but don't start a MonitorLiveData thread */ boost::shared_ptr<MonitorLiveData> - makeAlgo(std::string output, std::string accumWS = "", - std::string AccumulationMethod = "Replace", - std::string RunTransitionBehavior = "Restart", - std::string UpdateEvery = "1") { + makeAlgo(const std::string &output, const std::string &accumWS = "", + const std::string &AccumulationMethod = "Replace", + const std::string &RunTransitionBehavior = "Restart", + const std::string &UpdateEvery = "1") { auto alg = boost::dynamic_pointer_cast<MonitorLiveData>( AlgorithmManager::Instance().create("MonitorLiveData", -1, false)); alg->setPropertyValue("Instrument", "TestDataListener"); @@ -167,7 +167,7 @@ public: /** Executes the given algorithm asynchronously, until you reach the given * chunk number. * @return false if test failed*/ - bool runAlgoUntilChunk(boost::shared_ptr<MonitorLiveData> alg1, + bool runAlgoUntilChunk(const boost::shared_ptr<MonitorLiveData> &alg1, size_t stopAtChunk) { Poco::ActiveResult<bool> res1 = alg1->executeAsync(); Poco::Thread::sleep(50); diff --git a/Framework/LiveData/test/StartLiveDataTest.h b/Framework/LiveData/test/StartLiveDataTest.h index 65208964909d6443bd3772a9f59b796404e4b626..431bc8091f819687a6ec6927898a469fd28b1e71 100644 --- a/Framework/LiveData/test/StartLiveDataTest.h +++ b/Framework/LiveData/test/StartLiveDataTest.h @@ -51,12 +51,12 @@ public: * @param AccumulationMethod :: parameter string * @return the created processed WS */ - EventWorkspace_sptr doExecEvent(std::string AccumulationMethod, - double UpdateEvery, - std::string ProcessingAlgorithm = "", - std::string ProcessingProperties = "", - std::string PostProcessingAlgorithm = "", - std::string PostProcessingProperties = "") { + EventWorkspace_sptr + doExecEvent(const std::string &AccumulationMethod, double UpdateEvery, + const std::string &ProcessingAlgorithm = "", + const std::string &ProcessingProperties = "", + const std::string &PostProcessingAlgorithm = "", + const std::string &PostProcessingProperties = "") { TS_ASSERT_THROWS_NOTHING(alg.initialize()) TS_ASSERT(alg.isInitialized()) TS_ASSERT_THROWS_NOTHING(alg.setPropertyValue("FromNow", "1")); diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/BoxControllerSettingsAlgorithm.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/BoxControllerSettingsAlgorithm.h index 49227304eac01c374191064f7ccd562b6c162167..3718367586913c2a561981be922fdb980dbdd451 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/BoxControllerSettingsAlgorithm.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/BoxControllerSettingsAlgorithm.h @@ -31,17 +31,18 @@ protected: int MaxRecursionDepth = 5); /// Set the settings in the given box controller - void setBoxController(Mantid::API::BoxController_sptr bc, - Mantid::Geometry::Instrument_const_sptr instrument); + void + setBoxController(const Mantid::API::BoxController_sptr &bc, + const Mantid::Geometry::Instrument_const_sptr &instrument); /// Set the settings in the given box controller - void setBoxController(Mantid::API::BoxController_sptr bc); + void setBoxController(const Mantid::API::BoxController_sptr &bc); std::string getBoxSettingsGroupName() { return "Box Splitting Settings"; } /// Take the defaults for the box splitting from the instrument parameters. - void - takeDefaultsFromInstrument(Mantid::Geometry::Instrument_const_sptr instrument, - const size_t ndims); + void takeDefaultsFromInstrument( + const Mantid::Geometry::Instrument_const_sptr &instrument, + const size_t ndims); private: }; diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/CompactMD.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/CompactMD.h index 2499b0801bb12a5d8ae3f435fc48b1148ae2d15b..11e967304f3bf6623f906d1507ed898e562c30fb 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/CompactMD.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/CompactMD.h @@ -37,10 +37,10 @@ public: /// Algorithm's version for identification int version() const override { return 1; } /// Finding the extents of the first non-zero signals. - void - findFirstNonZeroMinMaxExtents(Mantid::API::IMDHistoWorkspace_sptr inputWs, - std::vector<Mantid::coord_t> &minVec, - std::vector<Mantid::coord_t> &maxVec); + void findFirstNonZeroMinMaxExtents( + const Mantid::API::IMDHistoWorkspace_sptr &inputWs, + std::vector<Mantid::coord_t> &minVec, + std::vector<Mantid::coord_t> &maxVec); }; } // namespace MDAlgorithms } // namespace Mantid diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/CompareMDWorkspaces.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/CompareMDWorkspaces.h index 5d1645549963b77789289d75a6adf50d79a2cf04..c5baef575669c52f0796c25b40827202c5dab26a 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/CompareMDWorkspaces.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/CompareMDWorkspaces.h @@ -34,10 +34,11 @@ private: void init() override; void exec() override; void doComparison(); - void compareMDGeometry(Mantid::API::IMDWorkspace_sptr ws1, - Mantid::API::IMDWorkspace_sptr ws2); - void compareMDHistoWorkspaces(Mantid::DataObjects::MDHistoWorkspace_sptr ws1, - Mantid::DataObjects::MDHistoWorkspace_sptr ws2); + void compareMDGeometry(const Mantid::API::IMDWorkspace_sptr &ws1, + const Mantid::API::IMDWorkspace_sptr &ws2); + void compareMDHistoWorkspaces( + const Mantid::DataObjects::MDHistoWorkspace_sptr &ws1, + const Mantid::DataObjects::MDHistoWorkspace_sptr &ws2); template <typename MDE, size_t nd> void compareMDWorkspaces( diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ConvToMDSelector.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ConvToMDSelector.h index fcf17e012355bb8ebb2347d2e4ef86758330f38c..e6711914d6f539927b6f146c590521960b4ed3f5 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ConvToMDSelector.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ConvToMDSelector.h @@ -33,7 +33,7 @@ public: /// function which selects the convertor depending on workspace type and /// (possibly, in a future) some workspace properties boost::shared_ptr<ConvToMDBase> - convSelector(API::MatrixWorkspace_sptr inputWS, + convSelector(const API::MatrixWorkspace_sptr &inputWS, boost::shared_ptr<ConvToMDBase> ¤tSolver) const; private: diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ConvertCWPDMDToSpectra.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ConvertCWPDMDToSpectra.h index 6485d4323250da7d445788d65f9faee12f9ea144..7e18f4bd3123da2fdf510af4a5684f5f44aef83b 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ConvertCWPDMDToSpectra.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ConvertCWPDMDToSpectra.h @@ -113,35 +113,37 @@ private: void exec() override; /// Main algorithm to reduce powder diffraction data - API::MatrixWorkspace_sptr reducePowderData( - API::IMDEventWorkspace_const_sptr dataws, - API::IMDEventWorkspace_const_sptr monitorws, const std::string targetunit, - const std::map<int, double> &map_runwavelength, const double xmin, - const double xmax, const double binsize, bool dolinearinterpolation, - const std::vector<detid_t> &vec_excludeddets); + API::MatrixWorkspace_sptr + reducePowderData(const API::IMDEventWorkspace_const_sptr &dataws, + const API::IMDEventWorkspace_const_sptr &monitorws, + const std::string &targetunit, + const std::map<int, double> &map_runwavelength, + const double xmin, const double xmax, const double binsize, + bool dolinearinterpolation, + const std::vector<detid_t> &vec_excludeddets); /// Find the binning boundary according to detectors' positions - void findXBoundary(API::IMDEventWorkspace_const_sptr dataws, + void findXBoundary(const API::IMDEventWorkspace_const_sptr &dataws, const std::string &targetunit, const std::map<int, double> &map_runwavelength, double &xmin, double &xmax); /// Bin signals to its 2theta position - void binMD(API::IMDEventWorkspace_const_sptr mdws, const char &unitbit, + void binMD(const API::IMDEventWorkspace_const_sptr &mdws, const char &unitbit, const std::map<int, double> &map_runlambda, const std::vector<double> &vecx, std::vector<double> &vecy, const std::vector<detid_t> &vec_excludedet); /// Do linear interpolation to zero counts if bin is too small - void linearInterpolation(API::MatrixWorkspace_sptr matrixws, + void linearInterpolation(const API::MatrixWorkspace_sptr &matrixws, const double &infinitesimal); /// Set up sample logs - void setupSampleLogs(API::MatrixWorkspace_sptr matrixws, - API::IMDEventWorkspace_const_sptr inputmdws); + void setupSampleLogs(const API::MatrixWorkspace_sptr &matrixws, + const API::IMDEventWorkspace_const_sptr &inputmdws); /// Scale reduced data - void scaleMatrixWorkspace(API::MatrixWorkspace_sptr matrixws, + void scaleMatrixWorkspace(const API::MatrixWorkspace_sptr &matrixws, const double &scalefactor, const double &infinitesimal); diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ConvertCWSDExpToMomentum.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ConvertCWSDExpToMomentum.h index 20d0878628ae5ef15ea6df65a3b282a95e077e9e..1719bb7fa3fa258e2786b912cb822e4904a94b0e 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ConvertCWSDExpToMomentum.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ConvertCWSDExpToMomentum.h @@ -45,7 +45,7 @@ private: void addMDEvents(bool usevirtual); void convertSpiceMatrixToMomentumMDEvents( - API::MatrixWorkspace_sptr dataws, bool usevirtual, + const API::MatrixWorkspace_sptr &dataws, bool usevirtual, const detid_t &startdetid, const int scannumber, const int runnumber, double measuretime, int monitor_counts); @@ -66,7 +66,7 @@ private: void parseDetectorTable(std::vector<Kernel::V3D> &vec_detpos, std::vector<detid_t> &vec_detid); - void setupTransferMatrix(API::MatrixWorkspace_sptr dataws, + void setupTransferMatrix(const API::MatrixWorkspace_sptr &dataws, Kernel::DblMatrix &rotationMatrix); void createVirtualInstrument(); @@ -74,7 +74,7 @@ private: void updateQRange(const std::vector<Mantid::coord_t> &vec_q); /// Remove background from - void removeBackground(API::MatrixWorkspace_sptr dataws); + void removeBackground(const API::MatrixWorkspace_sptr &dataws); API::ITableWorkspace_sptr m_expDataTableWS; API::ITableWorkspace_sptr m_detectorListTableWS; diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ConvertCWSDMDtoHKL.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ConvertCWSDMDtoHKL.h index ccfd30d9182eae27ecab4b504d4a5a3e98862d02..a627f571672e3c2dddce3964e4c5ab95b1ef9901 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ConvertCWSDMDtoHKL.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ConvertCWSDMDtoHKL.h @@ -47,7 +47,7 @@ private: /// Execution code void exec() override; - void exportEvents(API::IMDEventWorkspace_sptr mdws, + void exportEvents(const API::IMDEventWorkspace_sptr &mdws, std::vector<Kernel::V3D> &vec_event_qsample, std::vector<signal_t> &vec_event_signal, std::vector<detid_t> &vec_event_det); @@ -74,7 +74,7 @@ private: void getUBMatrix(); - void getRange(const std::vector<Kernel::V3D> vec_hkl, + void getRange(const std::vector<Kernel::V3D> &vec_hkl, std::vector<double> &extentMins, std::vector<double> &extentMaxs); diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ConvertSpiceDataToRealSpace.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ConvertSpiceDataToRealSpace.h index 4f3abf712c7a98cde242e2e2fd5abf31c2cf2de5..a38007bceaa5d39de511074a535bfa907c4d976f 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ConvertSpiceDataToRealSpace.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ConvertSpiceDataToRealSpace.h @@ -59,8 +59,8 @@ private: /// Parse data table workspace to a vector of matrix workspaces std::vector<API::MatrixWorkspace_sptr> convertToMatrixWorkspace( - DataObjects::TableWorkspace_sptr tablews, - API::MatrixWorkspace_const_sptr parentws, + const DataObjects::TableWorkspace_sptr &tablews, + const API::MatrixWorkspace_const_sptr &parentws, Types::Core::DateAndTime runstart, std::map<std::string, std::vector<double>> &logvecmap, std::vector<Types::Core::DateAndTime> &vectimes); @@ -71,43 +71,42 @@ private: /// Create an MDWorkspace for monitor counts API::IMDEventWorkspace_sptr createMonitorMDWorkspace( - const std::vector<API::MatrixWorkspace_sptr> vec_ws2d, + const std::vector<API::MatrixWorkspace_sptr> &vec_ws2d, const std::vector<double> &vecmonitor); /// Read parameter information from table workspace - void readTableInfo(DataObjects::TableWorkspace_const_sptr tablews, + void readTableInfo(const DataObjects::TableWorkspace_const_sptr &tablews, size_t &ipt, size_t &irotangle, size_t &itime, std::vector<std::pair<size_t, size_t>> &anodelist, std::map<std::string, size_t> &samplenameindexmap); /// Return sample logs - void parseSampleLogs(DataObjects::TableWorkspace_sptr tablews, + void parseSampleLogs(const DataObjects::TableWorkspace_sptr &tablews, const std::map<std::string, size_t> &indexlist, std::map<std::string, std::vector<double>> &logvecmap); /// Load one run (one pt.) to a matrix workspace - API::MatrixWorkspace_sptr - loadRunToMatrixWS(DataObjects::TableWorkspace_sptr tablews, size_t irow, - API::MatrixWorkspace_const_sptr parentws, - Types::Core::DateAndTime runstart, size_t ipt, - size_t irotangle, size_t itime, - const std::vector<std::pair<size_t, size_t>> anodelist, - double &duration); + API::MatrixWorkspace_sptr loadRunToMatrixWS( + const DataObjects::TableWorkspace_sptr &tablews, size_t irow, + const API::MatrixWorkspace_const_sptr &parentws, + Types::Core::DateAndTime runstart, size_t ipt, size_t irotangle, + size_t itime, const std::vector<std::pair<size_t, size_t>> &anodelist, + double &duration); /// Append Experiment Info void - addExperimentInfos(API::IMDEventWorkspace_sptr mdws, - const std::vector<API::MatrixWorkspace_sptr> vec_ws2d); + addExperimentInfos(const API::IMDEventWorkspace_sptr &mdws, + const std::vector<API::MatrixWorkspace_sptr> &vec_ws2d); /// Append sample logs to MD workspace void - appendSampleLogs(API::IMDEventWorkspace_sptr mdws, + appendSampleLogs(const API::IMDEventWorkspace_sptr &mdws, const std::map<std::string, std::vector<double>> &logvecmap, const std::vector<Types::Core::DateAndTime> &vectimes); /// Parse detector efficiency table workspace to map - std::map<detid_t, double> - parseDetectorEfficiencyTable(DataObjects::TableWorkspace_sptr detefftablews); + std::map<detid_t, double> parseDetectorEfficiencyTable( + const DataObjects::TableWorkspace_sptr &detefftablews); /// Apply the detector's efficiency correction to void diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ConvertToMD.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ConvertToMD.h index 19d01bac63c589218f0077c0bc9b8bcb0f8fa28e..cb19a48fac4f9e3486d7188bd1b6e1305a78ef8e 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ConvertToMD.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ConvertToMD.h @@ -60,8 +60,8 @@ private: /// progress reporter boost::scoped_ptr<API::Progress> m_Progress; - void setupFileBackend(std::string filebackPath, - API::IMDEventWorkspace_sptr outputWS); + void setupFileBackend(const std::string &filebackPath, + const API::IMDEventWorkspace_sptr &outputWS); //------------------------------------------------------------------------------------------------------------------------------------------ protected: // for testing, otherwise private: @@ -74,13 +74,13 @@ protected: // for testing, otherwise private: // Workflow helpers: /**Check if target workspace new or existing one and we need to create new * workspace*/ - bool doWeNeedNewTargetWorkspace(API::IMDEventWorkspace_sptr spws); + bool doWeNeedNewTargetWorkspace(const API::IMDEventWorkspace_sptr &spws); /**Create new MD workspace using existing parameters for algorithm */ API::IMDEventWorkspace_sptr createNewMDWorkspace(const MDAlgorithms::MDWSDescription &targWSDescr, const bool filebackend, const std::string &filename); - bool buildTargetWSDescription(API::IMDEventWorkspace_sptr spws, + bool buildTargetWSDescription(const API::IMDEventWorkspace_sptr &spws, const std::string &QModReq, const std::string &dEModReq, const std::vector<std::string> &otherDimNames, @@ -106,7 +106,7 @@ protected: // for testing, otherwise private: std::vector<double> &minVal, std::vector<double> &maxVal); /// Sets up the top level splitting, i.e. of level 0, for the box controller - void setupTopLevelSplitting(Mantid::API::BoxController_sptr bc); + void setupTopLevelSplitting(const Mantid::API::BoxController_sptr &bc); }; } // namespace MDAlgorithms diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/CreateMD.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/CreateMD.h index 4e1b3c7bbf2ce82f70ec5fe7a88c33415c170dcf..7f0eb9c749cb75e7e5c64e4605a3532075b26f2c 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/CreateMD.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/CreateMD.h @@ -43,23 +43,23 @@ private: const std::string &wsname); /// Add a sample log to a workspace - void addSampleLog(Mantid::API::MatrixWorkspace_sptr workspace, + void addSampleLog(const Mantid::API::MatrixWorkspace_sptr &workspace, const std::string &log_name, double log_number); /// Set the goniometer values in a workspace - void setGoniometer(Mantid::API::MatrixWorkspace_sptr workspace); + void setGoniometer(const Mantid::API::MatrixWorkspace_sptr &workspace); /// Set the UB matrix in a workspace - void setUB(Mantid::API::MatrixWorkspace_sptr workspace, double a, double b, - double c, double alpha, double beta, double gamma, + void setUB(const Mantid::API::MatrixWorkspace_sptr &workspace, double a, + double b, double c, double alpha, double beta, double gamma, const std::vector<double> &u, const std::vector<double> &v); /// Convert a workspace to MDWorkspace Mantid::API::IMDEventWorkspace_sptr - convertToMD(Mantid::API::Workspace_sptr workspace, + convertToMD(const Mantid::API::Workspace_sptr &workspace, const std::string &analysis_mode, bool in_place, const std::string &filebackend_filename, const bool filebackend, - Mantid::API::IMDEventWorkspace_sptr out_mdws); + const Mantid::API::IMDEventWorkspace_sptr &out_mdws); /// Merge input workspaces Mantid::API::IMDEventWorkspace_sptr @@ -67,13 +67,13 @@ private: /// Add logs and convert to MDWorkspace for a single run Mantid::API::IMDEventWorkspace_sptr - single_run(Mantid::API::MatrixWorkspace_sptr input_workspace, + single_run(const Mantid::API::MatrixWorkspace_sptr &input_workspace, const std::string &emode, double efix, double psi, double gl, double gs, bool in_place, const std::vector<double> &alatt, const std::vector<double> &angdeg, const std::vector<double> &u, const std::vector<double> &v, const std::string &filebackend_filename, const bool filebackend, - Mantid::API::IMDEventWorkspace_sptr out_mdws); + const Mantid::API::IMDEventWorkspace_sptr &out_mdws); /// Validate the algorithm's input properties std::map<std::string, std::string> validateInputs() override; diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/CreateMDWorkspace.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/CreateMDWorkspace.h index f51b5659331c1e7d195650f36d6a783055b3ea88..af76fc6919dee496e8036c77bfb010cfcd869e4e 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/CreateMDWorkspace.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/CreateMDWorkspace.h @@ -57,8 +57,8 @@ private: template <typename MDE, size_t nd> void finish(typename DataObjects::MDEventWorkspace<MDE, nd>::sptr ws); - Mantid::Geometry::MDFrame_uptr createMDFrame(std::string frame, - std::string unit); + Mantid::Geometry::MDFrame_uptr createMDFrame(const std::string &frame, + const std::string &unit); bool checkIfFrameValid(const std::string &frame, const std::vector<std::string> &targetFrames); }; diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/CutMD.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/CutMD.h index 4330b015afb3007cffea4965540bec17b0728bb6..7b52787fc1883a49532f38b61b239bdf7392a326 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/CutMD.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/CutMD.h @@ -14,9 +14,9 @@ namespace Mantid { namespace MDAlgorithms { -std::vector<std::string> - DLLExport findOriginalQUnits(Mantid::API::IMDWorkspace_const_sptr inws, - Mantid::Kernel::Logger &logger); +std::vector<std::string> DLLExport +findOriginalQUnits(const Mantid::API::IMDWorkspace_const_sptr &inws, + Mantid::Kernel::Logger &logger); /** CutMD : Slices multidimensional workspaces. diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/DisplayNormalizationSetter.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/DisplayNormalizationSetter.h index 7624bd52a7264d8a510cefb890fbae0d84073435..24e2d7c1b902126c23be415a2378da385e39171b 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/DisplayNormalizationSetter.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/DisplayNormalizationSetter.h @@ -19,7 +19,7 @@ energy-transfer-mode */ class DLLExport DisplayNormalizationSetter { public: - void operator()(Mantid::API::IMDWorkspace_sptr mdWorkspace, + void operator()(const Mantid::API::IMDWorkspace_sptr &mdWorkspace, const Mantid::API::MatrixWorkspace_sptr &underlyingWorkspace, bool isQ = false, const Mantid::Kernel::DeltaEMode::Type &mode = @@ -27,14 +27,14 @@ public: private: void setNormalizationMDEvent( - Mantid::API::IMDWorkspace_sptr mdWorkspace, + const Mantid::API::IMDWorkspace_sptr &mdWorkspace, const Mantid::API::MatrixWorkspace_sptr &underlyingWorkspace, bool isQ = false, const Mantid::Kernel::DeltaEMode::Type &mode = Mantid::Kernel::DeltaEMode::Elastic); void applyNormalizationMDEvent( - Mantid::API::IMDWorkspace_sptr mdWorkspace, + const Mantid::API::IMDWorkspace_sptr &mdWorkspace, Mantid::API::MDNormalization displayNormalization, Mantid::API::MDNormalization displayNormalizationHisto); }; diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/FindPeaksMD.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/FindPeaksMD.h index 22666e34921ef6e9c8512cfd6a86875e05f03467..14cb071885c5bb75b155164c8da7da16548ec0ac 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/FindPeaksMD.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/FindPeaksMD.h @@ -74,7 +74,7 @@ private: template <typename MDE, size_t nd> void findPeaks(typename DataObjects::MDEventWorkspace<MDE, nd>::sptr ws); /// Run find peaks on a histo workspace - void findPeaksHisto(Mantid::DataObjects::MDHistoWorkspace_sptr ws); + void findPeaksHisto(const Mantid::DataObjects::MDHistoWorkspace_sptr &ws); /// Output PeaksWorkspace Mantid::DataObjects::PeaksWorkspace_sptr peakWS; diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/FitMD.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/FitMD.h index 794757a422522eb37bf0639be59048a7dad1c4f8..b8350d48d2f4c14bb7d1b71323e49f8c816fe43e 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/FitMD.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/FitMD.h @@ -9,6 +9,8 @@ //---------------------------------------------------------------------- // Includes //---------------------------------------------------------------------- +#include <utility> + #include "MantidAPI/IDomainCreator.h" namespace Mantid { @@ -64,7 +66,7 @@ public: size_t getDomainSize() const override; /// Set the workspace void setWorkspace(boost::shared_ptr<API::IMDWorkspace> IMDWorkspace) { - m_IMDWorkspace = IMDWorkspace; + m_IMDWorkspace = std::move(IMDWorkspace); } /// Set the range void setRange(size_t startIndex, size_t count); @@ -83,8 +85,8 @@ protected: const std::string &outputWorkspacePropertyName); /// Create histo output workspace boost::shared_ptr<API::Workspace> createHistoOutputWorkspace( - const std::string &baseName, API::IFunction_sptr function, - boost::shared_ptr<const API::IMDHistoWorkspace> inputWorkspace, + const std::string &baseName, const API::IFunction_sptr &function, + const boost::shared_ptr<const API::IMDHistoWorkspace> &inputWorkspace, const std::string &outputWorkspacePropertyName); /// Store workspace property name diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/GetSpiceDataRawCountsFromMD.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/GetSpiceDataRawCountsFromMD.h index 841374d59de4669cf02d18147d7b98e43d049357..aba7a9949d9533cb1d29068e02458f74fbb0c079 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/GetSpiceDataRawCountsFromMD.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/GetSpiceDataRawCountsFromMD.h @@ -47,34 +47,35 @@ private: void exec() override; /// Export all detectors' counts for a run - void exportDetCountsOfRun(API::IMDEventWorkspace_const_sptr datamdws, - API::IMDEventWorkspace_const_sptr monitormdws, - const int runnumber, std::vector<double> &vecX, - std::vector<double> &vecY, std::string &xlabel, - std::string &ylabel, bool donormalize); + void + exportDetCountsOfRun(const API::IMDEventWorkspace_const_sptr &datamdws, + const API::IMDEventWorkspace_const_sptr &monitormdws, + const int runnumber, std::vector<double> &vecX, + std::vector<double> &vecY, std::string &xlabel, + std::string &ylabel, bool donormalize); /// Export a detector's counts accross all runs - void exportIndividualDetCounts(API::IMDEventWorkspace_const_sptr datamdws, - API::IMDEventWorkspace_const_sptr monitormdws, - const int detid, std::vector<double> &vecX, - std::vector<double> &vecY, std::string &xlabel, - std::string &ylabel, const bool &donormalize); + void exportIndividualDetCounts( + const API::IMDEventWorkspace_const_sptr &datamdws, + const API::IMDEventWorkspace_const_sptr &monitormdws, const int detid, + std::vector<double> &vecX, std::vector<double> &vecY, std::string &xlabel, + std::string &ylabel, const bool &donormalize); /// Export sample log values accross all runs - void exportSampleLogValue(API::IMDEventWorkspace_const_sptr datamdws, + void exportSampleLogValue(const API::IMDEventWorkspace_const_sptr &datamdws, const std::string &samplelogname, std::vector<double> &vecX, std::vector<double> &vecY, std::string &xlabel, std::string &ylabel); /// Get detectors' counts - void getDetCounts(API::IMDEventWorkspace_const_sptr mdws, + void getDetCounts(const API::IMDEventWorkspace_const_sptr &mdws, const int &runnumber, const int &detid, std::vector<double> &vecX, std::vector<double> &vecY, bool formX); /// Get sample log values - void getSampleLogValues(API::IMDEventWorkspace_const_sptr mdws, + void getSampleLogValues(const API::IMDEventWorkspace_const_sptr &mdws, const std::string &samplelogname, const int runnumber, std::vector<double> &vecSampleLog); diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ImportMDHistoWorkspaceBase.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ImportMDHistoWorkspaceBase.h index 2deb6d2f4095e6437200d8246fcc5d9678b28dbc..c9b16ab41c21634a1d38f5990f0863cd5b71cde3 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ImportMDHistoWorkspaceBase.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ImportMDHistoWorkspaceBase.h @@ -37,8 +37,8 @@ protected: private: // Product of the bins across all dimensions. size_t m_bin_product = 0; - Mantid::Geometry::MDFrame_uptr createMDFrame(std::string frame, - std::string unit); + Mantid::Geometry::MDFrame_uptr createMDFrame(const std::string &frame, + const std::string &unit); bool checkIfFrameValid(const std::string &frame, const std::vector<std::string> &targetFrames); }; diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/Integrate3DEvents.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/Integrate3DEvents.h index 0208bdf1b60ca4e0a97fff70b9584093308ae373..ef2ddcf9f394819323feb5f47ee9de361485e5dc 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/Integrate3DEvents.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/Integrate3DEvents.h @@ -80,7 +80,7 @@ public: /// Find the net integrated intensity of a peak, using ellipsoidal volumes boost::shared_ptr<const Mantid::Geometry::PeakShape> ellipseIntegrateEvents( - std::vector<Kernel::V3D> E1Vec, Mantid::Kernel::V3D const &peak_q, + const std::vector<Kernel::V3D> &E1Vec, Mantid::Kernel::V3D const &peak_q, bool specify_size, double peak_radius, double back_inner_radius, double back_outer_radius, std::vector<double> &axes_radii, double &inti, double &sigi); @@ -88,7 +88,7 @@ public: /// Find the net integrated intensity of a modulated peak, using ellipsoidal /// volumes boost::shared_ptr<const Mantid::Geometry::PeakShape> - ellipseIntegrateModEvents(std::vector<Kernel::V3D> E1Vec, + ellipseIntegrateModEvents(const std::vector<Kernel::V3D> &E1Vec, Mantid::Kernel::V3D const &peak_q, Mantid::Kernel::V3D const &hkl, Mantid::Kernel::V3D const &mnp, bool specify_size, @@ -176,7 +176,7 @@ private: /// Find the net integrated intensity of a list of Q's using ellipsoids boost::shared_ptr<const Mantid::DataObjects::PeakShapeEllipsoid> ellipseIntegrateEvents( - std::vector<Kernel::V3D> E1Vec, Kernel::V3D const &peak_q, + const std::vector<Kernel::V3D> &E1Vec, Kernel::V3D const &peak_q, std::vector<std::pair<std::pair<double, double>, Mantid::Kernel::V3D>> const &ev_list, std::vector<Mantid::Kernel::V3D> const &directions, @@ -185,7 +185,7 @@ private: std::vector<double> &axes_radii, double &inti, double &sigi); /// Compute if a particular Q falls on the edge of a detector - double detectorQ(std::vector<Kernel::V3D> E1Vec, + double detectorQ(const std::vector<Kernel::V3D> &E1Vec, const Mantid::Kernel::V3D QLabFrame, const std::vector<double> &r); diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/IntegrateEllipsoids.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/IntegrateEllipsoids.h index a0851899638c9ab94807783b67a10cb6c6b6cdb9..ba54418df9fd3ffb01fb0f711981a34c6d8bb4ac 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/IntegrateEllipsoids.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/IntegrateEllipsoids.h @@ -52,8 +52,8 @@ private: /// Calculate if this Q is on a detector void calculateE1(const Geometry::DetectorInfo &detectorInfo); - void runMaskDetectors(Mantid::DataObjects::PeaksWorkspace_sptr peakWS, - std::string property, std::string values); + void runMaskDetectors(const Mantid::DataObjects::PeaksWorkspace_sptr &peakWS, + const std::string &property, const std::string &values); /// save for all detector pixels std::vector<Kernel::V3D> E1Vec; diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/IntegrateEllipsoidsTwoStep.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/IntegrateEllipsoidsTwoStep.h index 1148a831df7b9d6266000eff45b4807d937d0340..c00e19cc3a8c77862123761b39358d5c22a3d2ca 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/IntegrateEllipsoidsTwoStep.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/IntegrateEllipsoidsTwoStep.h @@ -54,8 +54,8 @@ private: const Kernel::DblMatrix &UBinv, bool hkl_integ); /// Calculate if this Q is on a detector void calculateE1(const Geometry::DetectorInfo &detectorInfo); - void runMaskDetectors(Mantid::DataObjects::PeaksWorkspace_sptr peakWS, - std::string property, std::string values); + void runMaskDetectors(const Mantid::DataObjects::PeaksWorkspace_sptr &peakWS, + const std::string &property, const std::string &values); /// integrate a collection of strong peaks DataObjects::PeaksWorkspace_sptr diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/IntegratePeaksCWSD.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/IntegratePeaksCWSD.h index 00a8ba972d4c4ec305362cc121b4f41848953114..39f6ce7ae3c9429ae16b16daafb468bef1dbb1ee 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/IntegratePeaksCWSD.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/IntegratePeaksCWSD.h @@ -70,7 +70,7 @@ private: std::map<int, double> getMeasureTime(); std::vector<detid_t> - processMaskWorkspace(DataObjects::MaskWorkspace_const_sptr maskws); + processMaskWorkspace(const DataObjects::MaskWorkspace_const_sptr &maskws); void getPeakInformation(); @@ -82,7 +82,8 @@ private: void normalizePeaksIntensities(); DataObjects::PeaksWorkspace_sptr - createPeakworkspace(Kernel::V3D peakCenter, API::IMDEventWorkspace_sptr mdws); + createPeakworkspace(Kernel::V3D peakCenter, + const API::IMDEventWorkspace_sptr &mdws); /// Input MDEventWorkspace Mantid::API::IMDEventWorkspace_sptr m_inputWS; diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/IntegratePeaksMD2.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/IntegratePeaksMD2.h index 9f955d09525dfe27f9f8e73a5c57a2145f613a66..ce470c860cb4c4a6ffd6c3ee36a2a143589432be 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/IntegratePeaksMD2.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/IntegratePeaksMD2.h @@ -61,14 +61,15 @@ private: /// Calculate if this Q is on a detector void calculateE1(const Geometry::DetectorInfo &detectorInfo); double detectorQ(Mantid::Kernel::V3D QLabFrame, double r); - void runMaskDetectors(Mantid::DataObjects::PeaksWorkspace_sptr peakWS, - std::string property, std::string values); + void runMaskDetectors(const Mantid::DataObjects::PeaksWorkspace_sptr &peakWS, + const std::string &property, const std::string &values); /// save for all detector pixels std::vector<Kernel::V3D> E1Vec; /// Check if peaks overlap - void checkOverlap(int i, Mantid::DataObjects::PeaksWorkspace_sptr peakWS, + void checkOverlap(int i, + const Mantid::DataObjects::PeaksWorkspace_sptr &peakWS, Mantid::Kernel::SpecialCoordinateSystem CoordinatesToUse, double radius); }; diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/IntegratePeaksMDHKL.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/IntegratePeaksMDHKL.h index 8b6b73ced15727592d27a63341c3aea9cd1d9559..a6c4ad062a6b2475d1bce138eaf93aaf1e33732b 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/IntegratePeaksMDHKL.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/IntegratePeaksMDHKL.h @@ -60,8 +60,8 @@ private: DataObjects::MDHistoWorkspace_sptr cropHisto(int h, int k, int l, double box, const API::IMDWorkspace_sptr &ws); void integratePeak(const int neighborPts, - DataObjects::MDHistoWorkspace_sptr out, double &intensity, - double &errorSquared); + const DataObjects::MDHistoWorkspace_sptr &out, + double &intensity, double &errorSquared); }; } // namespace MDAlgorithms diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/LoadDNSSCD.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/LoadDNSSCD.h index 6f4949d3ee9ea389fc9e3b5563ecdd803ac4992d..d67fa614cb781cc4c501170bc77a8492ab63952b 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/LoadDNSSCD.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/LoadDNSSCD.h @@ -89,13 +89,13 @@ private: Mantid::API::IMDEventWorkspace_sptr m_OutWS; int splitIntoColumns(std::list<std::string> &columns, std::string &str); - void read_data(const std::string fname, + void read_data(const std::string &fname, std::map<std::string, std::string> &str_metadata, std::map<std::string, double> &num_metadata); void fillOutputWorkspace(double wavelength); void fillOutputWorkspaceRaw(double wavelength); API::ITableWorkspace_sptr saveHuber(); - void loadHuber(API::ITableWorkspace_sptr tws); + void loadHuber(const API::ITableWorkspace_sptr &tws); template <class T> void updateProperties(API::Run &run, std::map<std::string, T> &metadata, std::string time); diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/LoadMD.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/LoadMD.h index 724a3176a74cd1af7126d0a9f06f2f238eb4655a..9d421695064819b7b09f82e53cd8602bb15a64d4 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/LoadMD.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/LoadMD.h @@ -62,8 +62,8 @@ private: void loadExperimentInfos( boost::shared_ptr<Mantid::API::MultipleExperimentInfos> ws); - void loadSlab(std::string name, void *data, - DataObjects::MDHistoWorkspace_sptr ws, + void loadSlab(const std::string &name, void *data, + const DataObjects::MDHistoWorkspace_sptr &ws, NeXus::NXnumtype dataType); void loadHisto(); @@ -80,18 +80,18 @@ private: boost::optional<Mantid::API::MDNormalization> &normalization); /// Load all the affine matricies - void loadAffineMatricies(API::IMDWorkspace_sptr ws); + void loadAffineMatricies(const API::IMDWorkspace_sptr &ws); /// Load a given affine matrix - API::CoordTransform *loadAffineMatrix(std::string entry_name); + API::CoordTransform *loadAffineMatrix(const std::string &entry_name); /// Sets MDFrames for workspaces from legacy files - void setMDFrameOnWorkspaceFromLegacyFile(API::IMDWorkspace_sptr ws); + void setMDFrameOnWorkspaceFromLegacyFile(const API::IMDWorkspace_sptr &ws); /// Checks if a worspace is a certain type of legacy file - void checkForRequiredLegacyFixup(API::IMDWorkspace_sptr ws); + void checkForRequiredLegacyFixup(const API::IMDWorkspace_sptr &ws); /// Negative scaling for Q dimensions - std::vector<double> qDimensions(API::IMDWorkspace_sptr ws); + std::vector<double> qDimensions(const API::IMDWorkspace_sptr &ws); /// Open file handle // clang-format off diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/LoadSQW2.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/LoadSQW2.h index f121f9adeebdda1daee548f722b6afb7d017cd62..7a95acbba7ed06b91a47b1f23f39303becd58834 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/LoadSQW2.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/LoadSQW2.h @@ -63,7 +63,7 @@ private: Geometry::IMDDimension_sptr createEnDimension(float umin, float umax, size_t nbins); void setupBoxController(); - void setupFileBackend(std::string filebackPath); + void setupFileBackend(const std::string &filebackPath); void readPixelDataIntoWorkspace(); void splitAllBoxes(); void warnIfMemoryInsufficient(int64_t npixtot); diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/MDNorm.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/MDNorm.h index e5cf63619a566e7bfce5dce971118a0d553b3f65..f0bf7fced21ae1f62163a28caf23263099e7016d 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/MDNorm.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/MDNorm.h @@ -34,25 +34,25 @@ private: void exec() override; void validateBinningForTemporaryDataWorkspace( const std::map<std::string, std::string> &, - const Mantid::API::IMDHistoWorkspace_sptr); + const Mantid::API::IMDHistoWorkspace_sptr &); std::map<std::string, std::string> validateInputs() override final; std::string QDimensionName(std::vector<double> projection); std::string QDimensionNameQSample(int i); std::map<std::string, std::string> getBinParameters(); void createNormalizationWS(const DataObjects::MDHistoWorkspace &dataWS); DataObjects::MDHistoWorkspace_sptr - binInputWS(std::vector<Geometry::SymmetryOperation> symmetryOps); + binInputWS(const std::vector<Geometry::SymmetryOperation> &symmetryOps); std::vector<coord_t> getValuesFromOtherDimensions(bool &skipNormalization, uint16_t expInfoIndex = 0) const; void cacheDimensionXValues(); void calculateNormalization(const std::vector<coord_t> &otherValues, - Geometry::SymmetryOperation so, + const Geometry::SymmetryOperation &so, uint16_t expInfoIndex, size_t soIndex); void calculateIntersections(std::vector<std::array<double, 4>> &intersections, const double theta, const double phi, - Kernel::DblMatrix transform, double lowvalue, - double highvalue); + const Kernel::DblMatrix &transform, + double lowvalue, double highvalue); void calcIntegralsForIntersections(const std::vector<double> &xValues, const API::MatrixWorkspace &integrFlux, size_t sp, std::vector<double> &yValues); diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/MDTransfNoQ.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/MDTransfNoQ.h index 4dab97231a00213072119cdee94adeaa25ea900c..b8352419bc22d404f12ae3826fa8c1588c7a8040 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/MDTransfNoQ.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/MDTransfNoQ.h @@ -96,7 +96,7 @@ private: private: // internal helper function which extract one or two axis from input matrix // workspace; - static void getAxes(API::MatrixWorkspace_const_sptr inWS, + static void getAxes(const API::MatrixWorkspace_const_sptr &inWS, API::NumericAxis *&pXAxis, API::NumericAxis *&pYAxis); }; diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/MDWSDescription.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/MDWSDescription.h index 734df7c639362c357353cb899d79fc2bdbc07101..07a7f14a0b7c961903fbe71351966f2d3da13de5 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/MDWSDescription.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/MDWSDescription.h @@ -108,7 +108,7 @@ public: // for the time being /// method builds MD Event ws description from a matrix workspace and the /// transformations, requested to be performed on the workspace void buildFromMatrixWS(const API::MatrixWorkspace_sptr &pWS, - const std::string &QMode, const std::string dEMode, + const std::string &QMode, const std::string &dEMode, const std::vector<std::string> &dimPropertyNames = std::vector<std::string>()); @@ -132,12 +132,12 @@ public: // for the time being /** function extracts the coordinates from additional workspace properties and * places them to AddCoord vector for further usage*/ static void - fillAddProperties(Mantid::API::MatrixWorkspace_const_sptr inWS2D, + fillAddProperties(const Mantid::API::MatrixWorkspace_const_sptr &inWS2D, const std::vector<std::string> &dimPropertyNames, std::vector<coord_t> &AddCoord); static boost::shared_ptr<Geometry::OrientedLattice> - getOrientedLattice(Mantid::API::MatrixWorkspace_const_sptr inWS2D); + getOrientedLattice(const Mantid::API::MatrixWorkspace_const_sptr &inWS2D); /// Set the special coordinate system if any. void @@ -145,7 +145,7 @@ public: // for the time being /// @return the special coordinate system if any. Mantid::Kernel::SpecialCoordinateSystem getCoordinateSystem() const; /// Set the md frame - void setFrame(const std::string frameKey); + void setFrame(const std::string &frameKey); /// Retrieve the md frame Geometry::MDFrame_uptr getFrame(size_t d) const; diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/MergeMDFiles.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/MergeMDFiles.h index 1288d08656dc700b2cfd30db1ecaaf8a840223d5..ab2023ee4f0098a46e66f77c35ab6161c47a68d4 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/MergeMDFiles.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/MergeMDFiles.h @@ -54,7 +54,7 @@ private: void loadBoxData(); - void doExecByCloning(Mantid::API::IMDEventWorkspace_sptr ws, + void doExecByCloning(const Mantid::API::IMDEventWorkspace_sptr &ws, const std::string &outputFile); void finalizeOutput(const std::string &outputFile); diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/PreprocessDetectorsToMD.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/PreprocessDetectorsToMD.h index dfea448c535d223dc9fcfec3642507f653525c30..9a44dcd6a0ab8854d1409bb2596e51bc86bb617e 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/PreprocessDetectorsToMD.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/PreprocessDetectorsToMD.h @@ -66,7 +66,8 @@ protected: // for testing // build a table workspace corresponding to the input matrix workspace boost::shared_ptr<DataObjects::TableWorkspace> createTableWorkspace(const API::MatrixWorkspace_const_sptr &inputWS); - bool isDetInfoLost(Mantid::API::MatrixWorkspace_const_sptr inWS2D) const; + bool + isDetInfoLost(const Mantid::API::MatrixWorkspace_const_sptr &inWS2D) const; // helper function to get efixed if it is there or not; double getEi(const API::MatrixWorkspace_const_sptr &inputWS) const; }; diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/SaveIsawQvector.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/SaveIsawQvector.h index de5a8b8ccceed2995937253061c4e4a50f52d6f9..a72107429aa7ddb145eb1781a058f3358b31df09 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/SaveIsawQvector.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/SaveIsawQvector.h @@ -32,7 +32,7 @@ private: MDWSDescription m_targWSDescr; - void initTargetWSDescr(DataObjects::EventWorkspace_sptr wksp); + void initTargetWSDescr(const DataObjects::EventWorkspace_sptr &wksp); }; } // namespace MDAlgorithms diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/SaveMD.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/SaveMD.h index 90238f869f60b41402fbbe7e586c6076798fa31e..d621277f40c1708de49c2ad00a88c7430e1cdee5 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/SaveMD.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/SaveMD.h @@ -46,7 +46,7 @@ private: void doSaveEvents(typename DataObjects::MDEventWorkspace<MDE, nd>::sptr ws); /// Save the MDHistoWorkspace. - void doSaveHisto(Mantid::DataObjects::MDHistoWorkspace_sptr ws); + void doSaveHisto(const Mantid::DataObjects::MDHistoWorkspace_sptr &ws); /// Save all the affine matricies void saveAffineTransformMatricies(::NeXus::File *const file, diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/SaveMD2.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/SaveMD2.h index 9a2a6b0be456edf0817ff822335646106367ef83..efe1f6204b0c02863c4d2dcc84582f930a5deefa 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/SaveMD2.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/SaveMD2.h @@ -42,7 +42,7 @@ private: void exec() override; /// Save the MDHistoWorkspace. - void doSaveHisto(Mantid::DataObjects::MDHistoWorkspace_sptr ws); + void doSaveHisto(const Mantid::DataObjects::MDHistoWorkspace_sptr &ws); /// Save a generic matrix template <typename T> diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/SlicingAlgorithm.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/SlicingAlgorithm.h index 2bdd1eb5765abb0fe3ae8b933770e124622a2c6b..91be6c61ac581933090312db5dd5de6780e898d2 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/SlicingAlgorithm.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/SlicingAlgorithm.h @@ -136,8 +136,8 @@ protected: private: Mantid::Geometry::MDFrame_uptr - createMDFrameForNonAxisAligned(std::string units, - Mantid::Kernel::VMD basisVector) const; + createMDFrameForNonAxisAligned(const std::string &units, + const Mantid::Kernel::VMD &basisVector) const; std::vector<Mantid::Kernel::VMD> getOldBasis(size_t dimension) const; bool isProjectingOnFrame(const Mantid::Kernel::VMD &oldVector, const Mantid::Kernel::VMD &basisVector) const; @@ -146,7 +146,7 @@ private: const std::vector<Mantid::Kernel::VMD> &oldBasis) const; Mantid::Geometry::MDFrame_uptr extractMDFrameForNonAxisAligned(std::vector<size_t> indicesWithProjection, - std::string units) const; + const std::string &units) const; void setTargetUnits(Mantid::Geometry::MDFrame_uptr &frame, const std::string &units) const; }; diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/SmoothMD.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/SmoothMD.h index 20f2fe9e67d0867d201067425ea814be7d769111..05e2f54c788045868c526a9fed1ed53daa3320e5 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/SmoothMD.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/SmoothMD.h @@ -37,13 +37,13 @@ public: std::map<std::string, std::string> validateInputs() override; boost::shared_ptr<Mantid::API::IMDHistoWorkspace> hatSmooth( - boost::shared_ptr<const Mantid::API::IMDHistoWorkspace> toSmooth, + const boost::shared_ptr<const Mantid::API::IMDHistoWorkspace> &toSmooth, const std::vector<double> &widthVector, boost::optional<boost::shared_ptr<const Mantid::API::IMDHistoWorkspace>> weightingWS); boost::shared_ptr<Mantid::API::IMDHistoWorkspace> gaussianSmooth( - boost::shared_ptr<const Mantid::API::IMDHistoWorkspace> toSmooth, + const boost::shared_ptr<const Mantid::API::IMDHistoWorkspace> &toSmooth, const std::vector<double> &widthVector, boost::optional<boost::shared_ptr<const Mantid::API::IMDHistoWorkspace>> weightingWS); diff --git a/Framework/MDAlgorithms/src/BoxControllerSettingsAlgorithm.cpp b/Framework/MDAlgorithms/src/BoxControllerSettingsAlgorithm.cpp index 855a89d15c0a33734b7c68e209de780b699615c7..84d0e2bc6fee59ce53546312d7b527ca4138eb73 100644 --- a/Framework/MDAlgorithms/src/BoxControllerSettingsAlgorithm.cpp +++ b/Framework/MDAlgorithms/src/BoxControllerSettingsAlgorithm.cpp @@ -4,12 +4,14 @@ // NScD Oak Ridge National Laboratory, European Spallation Source, // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + -#include "MantidMDAlgorithms/BoxControllerSettingsAlgorithm.h" +#include <utility> + #include "MantidKernel/ArrayProperty.h" #include "MantidKernel/BoundedValidator.h" #include "MantidKernel/StringTokenizer.h" #include "MantidKernel/Strings.h" #include "MantidKernel/System.h" +#include "MantidMDAlgorithms/BoxControllerSettingsAlgorithm.h" using namespace Mantid::Kernel; using namespace Mantid::API; @@ -75,7 +77,8 @@ void BoxControllerSettingsAlgorithm::initBoxControllerProps( * @param ndims : Number of dimensions in output workspace. */ void BoxControllerSettingsAlgorithm::takeDefaultsFromInstrument( - Mantid::Geometry::Instrument_const_sptr instrument, const size_t ndims) { + const Mantid::Geometry::Instrument_const_sptr &instrument, + const size_t ndims) { const std::string splitThresholdName = "SplitThreshold"; const std::string splitIntoName = "SplitInto"; const std::string maxRecursionDepthName = "MaxRecursionDepth"; @@ -117,10 +120,11 @@ void BoxControllerSettingsAlgorithm::takeDefaultsFromInstrument( * @param instrument :: instrument to read parameters from. */ void BoxControllerSettingsAlgorithm::setBoxController( - BoxController_sptr bc, Mantid::Geometry::Instrument_const_sptr instrument) { + const BoxController_sptr &bc, + const Mantid::Geometry::Instrument_const_sptr &instrument) { size_t nd = bc->getNDims(); - takeDefaultsFromInstrument(instrument, nd); + takeDefaultsFromInstrument(std::move(instrument), nd); setBoxController(bc); } @@ -131,7 +135,8 @@ void BoxControllerSettingsAlgorithm::setBoxController( * * @param bc :: box controller to modify */ -void BoxControllerSettingsAlgorithm::setBoxController(BoxController_sptr bc) { +void BoxControllerSettingsAlgorithm::setBoxController( + const BoxController_sptr &bc) { size_t nd = bc->getNDims(); int val; diff --git a/Framework/MDAlgorithms/src/CompactMD.cpp b/Framework/MDAlgorithms/src/CompactMD.cpp index e08e00e8d2cb8ab5a792053966414776def816f9..8c158a00c83ed09765dc91e0a2a97493f4832c82 100644 --- a/Framework/MDAlgorithms/src/CompactMD.cpp +++ b/Framework/MDAlgorithms/src/CompactMD.cpp @@ -30,7 +30,7 @@ namespace { std::vector<std::string> createPBinStringVector(std::vector<Mantid::coord_t> minVector, std::vector<Mantid::coord_t> maxVector, - IMDHistoWorkspace_sptr inputWs) { + const IMDHistoWorkspace_sptr &inputWs) { size_t numDims = inputWs->getNumDims(); std::vector<std::string> pBinStrVector; for (size_t iter = 0; iter < numDims; iter++) { @@ -65,7 +65,7 @@ DECLARE_ALGORITHM(CompactMD) */ void CompactMD::findFirstNonZeroMinMaxExtents( - IMDHistoWorkspace_sptr inputWs, std::vector<Mantid::coord_t> &minVec, + const IMDHistoWorkspace_sptr &inputWs, std::vector<Mantid::coord_t> &minVec, std::vector<Mantid::coord_t> &maxVec) { auto ws_iter = inputWs->createIterator(); do { diff --git a/Framework/MDAlgorithms/src/CompareMDWorkspaces.cpp b/Framework/MDAlgorithms/src/CompareMDWorkspaces.cpp index 9554e6a6bcbed42524294b516e486db1864827ce..77411b5561360c3e6110934ad298442f991a3eb0 100644 --- a/Framework/MDAlgorithms/src/CompareMDWorkspaces.cpp +++ b/Framework/MDAlgorithms/src/CompareMDWorkspaces.cpp @@ -130,7 +130,8 @@ void CompareMDWorkspaces::compareTol(T a, T b, const std::string &message) { /** Compare the dimensions etc. of two MDWorkspaces */ void CompareMDWorkspaces::compareMDGeometry( - Mantid::API::IMDWorkspace_sptr ws1, Mantid::API::IMDWorkspace_sptr ws2) { + const Mantid::API::IMDWorkspace_sptr &ws1, + const Mantid::API::IMDWorkspace_sptr &ws2) { compare(ws1->getNumDims(), ws2->getNumDims(), "Workspaces have a different number of dimensions"); for (size_t d = 0; d < ws1->getNumDims(); d++) { @@ -156,8 +157,8 @@ void CompareMDWorkspaces::compareMDGeometry( /** Compare the dimensions etc. of two MDWorkspaces */ void CompareMDWorkspaces::compareMDHistoWorkspaces( - Mantid::DataObjects::MDHistoWorkspace_sptr ws1, - Mantid::DataObjects::MDHistoWorkspace_sptr ws2) { + const Mantid::DataObjects::MDHistoWorkspace_sptr &ws1, + const Mantid::DataObjects::MDHistoWorkspace_sptr &ws2) { compare(ws1->getNumDims(), ws2->getNumDims(), "Workspaces have a different number of dimensions"); compare(ws1->getNPoints(), ws2->getNPoints(), diff --git a/Framework/MDAlgorithms/src/ConvToMDBase.cpp b/Framework/MDAlgorithms/src/ConvToMDBase.cpp index 7938951d5d8c1c205a43bf60761ccc1354b2056d..78eec7938d9af774a1ddc5cf5b41de704a1ac2f4 100644 --- a/Framework/MDAlgorithms/src/ConvToMDBase.cpp +++ b/Framework/MDAlgorithms/src/ConvToMDBase.cpp @@ -4,9 +4,11 @@ // NScD Oak Ridge National Laboratory, European Spallation Source, // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + -#include "MantidMDAlgorithms/ConvToMDBase.h" +#include <utility> + #include "MantidAPI/MatrixWorkspace.h" #include "MantidAPI/Run.h" +#include "MantidMDAlgorithms/ConvToMDBase.h" namespace Mantid { namespace MDAlgorithms { @@ -46,7 +48,7 @@ size_t ConvToMDBase::initialize( m_detID = WSD.m_PreprDetTable->getColVector<int>("DetectorID"); // set up output MD workspace wrapper - m_OutWSWrapper = inWSWrapper; + m_OutWSWrapper = std::move(inWSWrapper); // get the index which identify the run the source workspace came from. // This index will mark the workspace' events for diffetent worksapces to // combine diff --git a/Framework/MDAlgorithms/src/ConvToMDSelector.cpp b/Framework/MDAlgorithms/src/ConvToMDSelector.cpp index 90ef582c913b5f681990ab4995d0eba0ec1f8847..049b9296600bfaeb5677b56795681615398ad882 100644 --- a/Framework/MDAlgorithms/src/ConvToMDSelector.cpp +++ b/Framework/MDAlgorithms/src/ConvToMDSelector.cpp @@ -33,7 +33,7 @@ initiated) *@returns shared pointer to new solver, which corresponds to the workspace */ boost::shared_ptr<ConvToMDBase> ConvToMDSelector::convSelector( - API::MatrixWorkspace_sptr inputWS, + const API::MatrixWorkspace_sptr &inputWS, boost::shared_ptr<ConvToMDBase> ¤tSolver) const { // identify what kind of workspace we expect to process wsType inputWSType = Undefined; diff --git a/Framework/MDAlgorithms/src/ConvertCWPDMDToSpectra.cpp b/Framework/MDAlgorithms/src/ConvertCWPDMDToSpectra.cpp index 8779b9fd0a3992cabcf71b3dc6f90787db3d7bd0..c917989601202c49bb9825226423d72ddd5b6d21 100644 --- a/Framework/MDAlgorithms/src/ConvertCWPDMDToSpectra.cpp +++ b/Framework/MDAlgorithms/src/ConvertCWPDMDToSpectra.cpp @@ -4,6 +4,8 @@ // NScD Oak Ridge National Laboratory, European Spallation Source, // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + +#include <utility> + #include "MantidMDAlgorithms/ConvertCWPDMDToSpectra.h" #include "MantidAPI/Axis.h" @@ -208,8 +210,9 @@ void ConvertCWPDMDToSpectra::exec() { * @return */ API::MatrixWorkspace_sptr ConvertCWPDMDToSpectra::reducePowderData( - API::IMDEventWorkspace_const_sptr dataws, - IMDEventWorkspace_const_sptr monitorws, const std::string targetunit, + const API::IMDEventWorkspace_const_sptr &dataws, + const IMDEventWorkspace_const_sptr &monitorws, + const std::string &targetunit, const std::map<int, double> &map_runwavelength, const double xmin, const double xmax, const double binsize, bool dolinearinterpolation, const std::vector<detid_t> &vec_excludeddets) { @@ -259,7 +262,8 @@ API::MatrixWorkspace_sptr ConvertCWPDMDToSpectra::reducePowderData( unitchar = 'q'; binMD(dataws, unitchar, map_runwavelength, vecx, vecy, vec_excludeddets); - binMD(monitorws, unitchar, map_runwavelength, vecx, vecm, vec_excludeddets); + binMD(std::move(monitorws), unitchar, map_runwavelength, vecx, vecm, + vec_excludeddets); // Normalize by division double maxmonitorcounts = 0; @@ -317,7 +321,8 @@ API::MatrixWorkspace_sptr ConvertCWPDMDToSpectra::reducePowderData( * @param xmax :: (output) upper binning boundary */ void ConvertCWPDMDToSpectra::findXBoundary( - API::IMDEventWorkspace_const_sptr dataws, const std::string &targetunit, + const API::IMDEventWorkspace_const_sptr &dataws, + const std::string &targetunit, const std::map<int, double> &map_runwavelength, double &xmin, double &xmax) { // Go through all instruments @@ -425,12 +430,10 @@ void ConvertCWPDMDToSpectra::findXBoundary( * @param vecy * @param vec_excludedet */ -void ConvertCWPDMDToSpectra::binMD(API::IMDEventWorkspace_const_sptr mdws, - const char &unitbit, - const std::map<int, double> &map_runlambda, - const std::vector<double> &vecx, - std::vector<double> &vecy, - const std::vector<detid_t> &vec_excludedet) { +void ConvertCWPDMDToSpectra::binMD( + const API::IMDEventWorkspace_const_sptr &mdws, const char &unitbit, + const std::map<int, double> &map_runlambda, const std::vector<double> &vecx, + std::vector<double> &vecy, const std::vector<detid_t> &vec_excludedet) { // Check whether MD workspace has proper instrument and experiment Info if (mdws->getNumExperimentInfo() == 0) throw std::runtime_error( @@ -599,7 +602,7 @@ void ConvertCWPDMDToSpectra::binMD(API::IMDEventWorkspace_const_sptr mdws, * @param infinitesimal */ void ConvertCWPDMDToSpectra::linearInterpolation( - API::MatrixWorkspace_sptr matrixws, const double &infinitesimal) { + const API::MatrixWorkspace_sptr &matrixws, const double &infinitesimal) { g_log.debug() << "Number of spectrum = " << matrixws->getNumberHistograms() << " Infinitesimal = " << infinitesimal << "\n"; size_t numspec = matrixws->getNumberHistograms(); @@ -670,8 +673,8 @@ void ConvertCWPDMDToSpectra::linearInterpolation( * @param inputmdws */ void ConvertCWPDMDToSpectra::setupSampleLogs( - API::MatrixWorkspace_sptr matrixws, - API::IMDEventWorkspace_const_sptr inputmdws) { + const API::MatrixWorkspace_sptr &matrixws, + const API::IMDEventWorkspace_const_sptr &inputmdws) { // get hold of the last experiment info from md workspace to copy over auto lastindex = static_cast<uint16_t>(inputmdws->getNumExperimentInfo() - 1); ExperimentInfo_const_sptr lastexpinfo = @@ -696,7 +699,7 @@ void ConvertCWPDMDToSpectra::setupSampleLogs( * @param infinitesimal */ void ConvertCWPDMDToSpectra::scaleMatrixWorkspace( - API::MatrixWorkspace_sptr matrixws, const double &scalefactor, + const API::MatrixWorkspace_sptr &matrixws, const double &scalefactor, const double &infinitesimal) { size_t numspec = matrixws->getNumberHistograms(); for (size_t iws = 0; iws < numspec; ++iws) { diff --git a/Framework/MDAlgorithms/src/ConvertCWSDExpToMomentum.cpp b/Framework/MDAlgorithms/src/ConvertCWSDExpToMomentum.cpp index 8bdb5af394e8aa51214e588841b3ed6864fc38b7..88b8e36f26e7264b2bcf0c235d1e2ff619276992 100644 --- a/Framework/MDAlgorithms/src/ConvertCWSDExpToMomentum.cpp +++ b/Framework/MDAlgorithms/src/ConvertCWSDExpToMomentum.cpp @@ -342,7 +342,8 @@ void ConvertCWSDExpToMomentum::addMDEvents(bool usevirtual) { * Q-sample */ void ConvertCWSDExpToMomentum::setupTransferMatrix( - API::MatrixWorkspace_sptr dataws, Kernel::DblMatrix &rotationMatrix) { + const API::MatrixWorkspace_sptr &dataws, + Kernel::DblMatrix &rotationMatrix) { // Check sample logs if (!dataws->run().hasProperty("_omega") || !dataws->run().hasProperty("_chi") || !dataws->run().hasProperty("_phi")) @@ -384,9 +385,9 @@ void ConvertCWSDExpToMomentum::setupTransferMatrix( * workspace */ void ConvertCWSDExpToMomentum::convertSpiceMatrixToMomentumMDEvents( - MatrixWorkspace_sptr dataws, bool usevirtual, const detid_t &startdetid, - const int scannumber, const int runnumber, double measuretime, - int monitor_counts) { + const MatrixWorkspace_sptr &dataws, bool usevirtual, + const detid_t &startdetid, const int scannumber, const int runnumber, + double measuretime, int monitor_counts) { // Create transformation matrix from which the transformation is Kernel::DblMatrix rotationMatrix; setupTransferMatrix(dataws, rotationMatrix); @@ -696,7 +697,7 @@ void ConvertCWSDExpToMomentum::updateQRange( * @param dataws */ void ConvertCWSDExpToMomentum::removeBackground( - API::MatrixWorkspace_sptr dataws) { + const API::MatrixWorkspace_sptr &dataws) { if (dataws->getNumberHistograms() != m_backgroundWS->getNumberHistograms()) throw std::runtime_error("Impossible to have this situation"); diff --git a/Framework/MDAlgorithms/src/ConvertCWSDMDtoHKL.cpp b/Framework/MDAlgorithms/src/ConvertCWSDMDtoHKL.cpp index 94a2166a39bb355ac799f110e5760c1b7ac93ea0..ee6693b9c76bf319b3fe5761d26dfbd829c4e8ae 100644 --- a/Framework/MDAlgorithms/src/ConvertCWSDMDtoHKL.cpp +++ b/Framework/MDAlgorithms/src/ConvertCWSDMDtoHKL.cpp @@ -169,7 +169,8 @@ void ConvertCWSDMDtoHKL::getUBMatrix() { * number of detectors */ void ConvertCWSDMDtoHKL::exportEvents( - IMDEventWorkspace_sptr mdws, std::vector<Kernel::V3D> &vec_event_qsample, + const IMDEventWorkspace_sptr &mdws, + std::vector<Kernel::V3D> &vec_event_qsample, std::vector<signal_t> &vec_event_signal, std::vector<detid_t> &vec_event_det) { // Set the size of the output vectors @@ -373,7 +374,7 @@ API::IMDEventWorkspace_sptr ConvertCWSDMDtoHKL::createHKLMDWorkspace( return mdws; } -void ConvertCWSDMDtoHKL::getRange(const std::vector<Kernel::V3D> vec_hkl, +void ConvertCWSDMDtoHKL::getRange(const std::vector<Kernel::V3D> &vec_hkl, std::vector<double> &extentMins, std::vector<double> &extentMaxs) { assert(extentMins.size() == 3); diff --git a/Framework/MDAlgorithms/src/ConvertSpiceDataToRealSpace.cpp b/Framework/MDAlgorithms/src/ConvertSpiceDataToRealSpace.cpp index e72e3f73326f66dfd8ae5d59791e036cee160243..0d55347e1e56cee9acd4b0f55d689703de215232 100644 --- a/Framework/MDAlgorithms/src/ConvertSpiceDataToRealSpace.cpp +++ b/Framework/MDAlgorithms/src/ConvertSpiceDataToRealSpace.cpp @@ -209,8 +209,9 @@ void ConvertSpiceDataToRealSpace::exec() { */ std::vector<MatrixWorkspace_sptr> ConvertSpiceDataToRealSpace::convertToMatrixWorkspace( - DataObjects::TableWorkspace_sptr tablews, - API::MatrixWorkspace_const_sptr parentws, Types::Core::DateAndTime runstart, + const DataObjects::TableWorkspace_sptr &tablews, + const API::MatrixWorkspace_const_sptr &parentws, + Types::Core::DateAndTime runstart, std::map<std::string, std::vector<double>> &logvecmap, std::vector<Types::Core::DateAndTime> &vectimes) { // Get table workspace's column information @@ -249,7 +250,7 @@ ConvertSpiceDataToRealSpace::convertToMatrixWorkspace( * @param logvecmap */ void ConvertSpiceDataToRealSpace::parseSampleLogs( - DataObjects::TableWorkspace_sptr tablews, + const DataObjects::TableWorkspace_sptr &tablews, const std::map<std::string, size_t> &indexlist, std::map<std::string, std::vector<double>> &logvecmap) { size_t numrows = tablews->rowCount(); @@ -287,10 +288,11 @@ void ConvertSpiceDataToRealSpace::parseSampleLogs( * @return */ MatrixWorkspace_sptr ConvertSpiceDataToRealSpace::loadRunToMatrixWS( - DataObjects::TableWorkspace_sptr tablews, size_t irow, - MatrixWorkspace_const_sptr parentws, Types::Core::DateAndTime runstart, - size_t ipt, size_t irotangle, size_t itime, - const std::vector<std::pair<size_t, size_t>> anodelist, double &duration) { + const DataObjects::TableWorkspace_sptr &tablews, size_t irow, + const MatrixWorkspace_const_sptr &parentws, + Types::Core::DateAndTime runstart, size_t ipt, size_t irotangle, + size_t itime, const std::vector<std::pair<size_t, size_t>> &anodelist, + double &duration) { // New workspace from parent workspace MatrixWorkspace_sptr tempws = WorkspaceFactory::Instance().create(parentws, m_numSpec, 2, 1); @@ -367,7 +369,7 @@ MatrixWorkspace_sptr ConvertSpiceDataToRealSpace::loadRunToMatrixWS( * @param samplenameindexmap */ void ConvertSpiceDataToRealSpace::readTableInfo( - TableWorkspace_const_sptr tablews, size_t &ipt, size_t &irotangle, + const TableWorkspace_const_sptr &tablews, size_t &ipt, size_t &irotangle, size_t &itime, std::vector<std::pair<size_t, size_t>> &anodelist, std::map<std::string, size_t> &samplenameindexmap) { @@ -439,7 +441,7 @@ void ConvertSpiceDataToRealSpace::readTableInfo( * @param vectimes */ void ConvertSpiceDataToRealSpace::appendSampleLogs( - IMDEventWorkspace_sptr mdws, + const IMDEventWorkspace_sptr &mdws, const std::map<std::string, std::vector<double>> &logvecmap, const std::vector<Types::Core::DateAndTime> &vectimes) { // Check! @@ -524,8 +526,8 @@ void ConvertSpiceDataToRealSpace::appendSampleLogs( * @param vec_ws2d */ void ConvertSpiceDataToRealSpace::addExperimentInfos( - API::IMDEventWorkspace_sptr mdws, - const std::vector<API::MatrixWorkspace_sptr> vec_ws2d) { + const API::IMDEventWorkspace_sptr &mdws, + const std::vector<API::MatrixWorkspace_sptr> &vec_ws2d) { // Add N experiment info as there are N measurment points for (const auto &ws2d : vec_ws2d) { // Create an ExperimentInfo object @@ -633,7 +635,7 @@ IMDEventWorkspace_sptr ConvertSpiceDataToRealSpace::createDataMDWorkspace( * @return */ IMDEventWorkspace_sptr ConvertSpiceDataToRealSpace::createMonitorMDWorkspace( - const std::vector<MatrixWorkspace_sptr> vec_ws2d, + const std::vector<MatrixWorkspace_sptr> &vec_ws2d, const std::vector<double> &vecmonitor) { // Create a target output workspace. IMDEventWorkspace_sptr outWs = @@ -710,7 +712,7 @@ IMDEventWorkspace_sptr ConvertSpiceDataToRealSpace::createMonitorMDWorkspace( */ std::map<detid_t, double> ConvertSpiceDataToRealSpace::parseDetectorEfficiencyTable( - DataObjects::TableWorkspace_sptr detefftablews) { + const DataObjects::TableWorkspace_sptr &detefftablews) { std::map<detid_t, double> deteffmap; // check table workspace diff --git a/Framework/MDAlgorithms/src/ConvertToMD.cpp b/Framework/MDAlgorithms/src/ConvertToMD.cpp index 630390295c80f14457e62d5879107b1f145cc1d9..9c0530b042e66e6756272ad300c87e5c320c0f7a 100644 --- a/Framework/MDAlgorithms/src/ConvertToMD.cpp +++ b/Framework/MDAlgorithms/src/ConvertToMD.cpp @@ -445,7 +445,7 @@ is ignored in any other case together and used to describe selected transformation. */ bool ConvertToMD::buildTargetWSDescription( - API::IMDEventWorkspace_sptr spws, const std::string &QModReq, + const API::IMDEventWorkspace_sptr &spws, const std::string &QModReq, const std::string &dEModReq, const std::vector<std::string> &otherDimNames, std::vector<double> &dimMin, std::vector<double> &dimMax, const std::string &QFrame, const std::string &convertTo_, @@ -604,7 +604,8 @@ ConvertToMD::createNewMDWorkspace(const MDWSDescription &targWSDescr, * the first level. * @param bc A pointer to the box controller. */ -void ConvertToMD::setupTopLevelSplitting(Mantid::API::BoxController_sptr bc) { +void ConvertToMD::setupTopLevelSplitting( + const Mantid::API::BoxController_sptr &bc) { const size_t topLevelSplitSetting = 50; const size_t dimCutoff = 4; @@ -625,7 +626,8 @@ void ConvertToMD::setupTopLevelSplitting(Mantid::API::BoxController_sptr bc) { * *@returns true if one needs to create new workspace and false otherwise */ -bool ConvertToMD::doWeNeedNewTargetWorkspace(API::IMDEventWorkspace_sptr spws) { +bool ConvertToMD::doWeNeedNewTargetWorkspace( + const API::IMDEventWorkspace_sptr &spws) { bool createNewWs(false); if (!spws) { @@ -762,7 +764,8 @@ void ConvertToMD::findMinMax( * @param outputWS :: Workspace on which to set the file back end */ void ConvertToMD::setupFileBackend( - std::string filebackPath, Mantid::API::IMDEventWorkspace_sptr outputWS) { + const std::string &filebackPath, + const Mantid::API::IMDEventWorkspace_sptr &outputWS) { using DataObjects::BoxControllerNeXusIO; auto savemd = this->createChildAlgorithm("SaveMD", 0.01, 0.05, true); savemd->setProperty("InputWorkspace", outputWS); diff --git a/Framework/MDAlgorithms/src/ConvertToReflectometryQ.cpp b/Framework/MDAlgorithms/src/ConvertToReflectometryQ.cpp index a1227491a92aa53ab0709cd8f190b793ed889008..556551412635b6290e0c80ad3228f056267f7d54 100644 --- a/Framework/MDAlgorithms/src/ConvertToReflectometryQ.cpp +++ b/Framework/MDAlgorithms/src/ConvertToReflectometryQ.cpp @@ -75,7 +75,8 @@ Check that the input workspace is of the correct type. @throw: runtime_error if the units do not appear to be correct/compatible with the algorithm. */ -void checkInputWorkspace(Mantid::API::MatrixWorkspace_const_sptr inputWs) { +void checkInputWorkspace( + const Mantid::API::MatrixWorkspace_const_sptr &inputWs) { auto spectraAxis = inputWs->getAxis(1); const std::string label = spectraAxis->unit()->label(); const std::string expectedLabel = "degrees"; @@ -148,7 +149,7 @@ Get the value of theta from the logs @return : theta found in the logs @throw: runtime_errror if 'stheta' was not found. */ -double getThetaFromLogs(MatrixWorkspace_sptr inputWs) { +double getThetaFromLogs(const MatrixWorkspace_sptr &inputWs) { double theta = -1.; const Mantid::API::Run &run = inputWs->run(); diff --git a/Framework/MDAlgorithms/src/CreateMD.cpp b/Framework/MDAlgorithms/src/CreateMD.cpp index b4eafe793cd23ed85a9cc1f59b5f36e0b49c4686..ff6410e56557ed621bf9de955df891ae17fe87ba 100644 --- a/Framework/MDAlgorithms/src/CreateMD.cpp +++ b/Framework/MDAlgorithms/src/CreateMD.cpp @@ -15,6 +15,8 @@ #include "MantidKernel/MandatoryValidator.h" #include <Poco/Path.h> +#include <utility> + using namespace Mantid::Kernel; using namespace Mantid::API; using namespace Mantid::DataObjects; @@ -308,7 +310,7 @@ Mantid::API::Workspace_sptr CreateMD::loadWs(const std::string &filename, * @param log_name :: the name of the log * @param log_number :: the value to record in the log */ -void CreateMD::addSampleLog(Mantid::API::MatrixWorkspace_sptr workspace, +void CreateMD::addSampleLog(const Mantid::API::MatrixWorkspace_sptr &workspace, const std::string &log_name, double log_number) { Algorithm_sptr log_alg = createChildAlgorithm("AddSampleLog"); @@ -327,7 +329,8 @@ void CreateMD::addSampleLog(Mantid::API::MatrixWorkspace_sptr workspace, * * @param workspace :: the workspace to set the goniometer values in */ -void CreateMD::setGoniometer(Mantid::API::MatrixWorkspace_sptr workspace) { +void CreateMD::setGoniometer( + const Mantid::API::MatrixWorkspace_sptr &workspace) { Algorithm_sptr log_alg = createChildAlgorithm("SetGoniometer"); if (!workspace->run().getProperty("gl")) { std::ostringstream temp_ss; @@ -356,8 +359,8 @@ void CreateMD::setGoniometer(Mantid::API::MatrixWorkspace_sptr workspace) { * @param u :: lattice vector parallel to incident neutron beam * @param v :: lattice vector perpendicular to u in the horizontal plane */ -void CreateMD::setUB(Mantid::API::MatrixWorkspace_sptr workspace, double a, - double b, double c, double alpha, double beta, +void CreateMD::setUB(const Mantid::API::MatrixWorkspace_sptr &workspace, + double a, double b, double c, double alpha, double beta, double gamma, const std::vector<double> &u, const std::vector<double> &v) { Algorithm_sptr set_ub_alg = createChildAlgorithm("SetUB"); @@ -383,10 +386,12 @@ void CreateMD::setUB(Mantid::API::MatrixWorkspace_sptr workspace, double a, * @out_mdws :: output workspace to use if merge step is carried out * @returns the output converted workspace */ -Mantid::API::IMDEventWorkspace_sptr CreateMD::convertToMD( - Mantid::API::Workspace_sptr workspace, const std::string &analysis_mode, - bool in_place, const std::string &filebackend_filename, - const bool filebackend, Mantid::API::IMDEventWorkspace_sptr out_mdws) { +Mantid::API::IMDEventWorkspace_sptr +CreateMD::convertToMD(const Mantid::API::Workspace_sptr &workspace, + const std::string &analysis_mode, bool in_place, + const std::string &filebackend_filename, + const bool filebackend, + const Mantid::API::IMDEventWorkspace_sptr &out_mdws) { Algorithm_sptr min_max_alg = createChildAlgorithm("ConvertToMDMinMaxGlobal"); min_max_alg->setProperty("InputWorkspace", workspace); min_max_alg->setProperty("QDimensions", "Q3D"); @@ -462,12 +467,13 @@ CreateMD::merge_runs(const std::vector<std::string> &to_merge) { * @param out_mdws :output workspace to use if merge step is carried out */ Mantid::API::IMDEventWorkspace_sptr CreateMD::single_run( - Mantid::API::MatrixWorkspace_sptr input_workspace, const std::string &emode, - double efix, double psi, double gl, double gs, bool in_place, - const std::vector<double> &alatt, const std::vector<double> &angdeg, - const std::vector<double> &u, const std::vector<double> &v, - const std::string &filebackend_filename, const bool filebackend, - Mantid::API::IMDEventWorkspace_sptr out_mdws) { + const Mantid::API::MatrixWorkspace_sptr &input_workspace, + const std::string &emode, double efix, double psi, double gl, double gs, + bool in_place, const std::vector<double> &alatt, + const std::vector<double> &angdeg, const std::vector<double> &u, + const std::vector<double> &v, const std::string &filebackend_filename, + const bool filebackend, + const Mantid::API::IMDEventWorkspace_sptr &out_mdws) { std::vector<std::vector<double>> ub_params{alatt, angdeg, u, v}; @@ -493,7 +499,7 @@ Mantid::API::IMDEventWorkspace_sptr CreateMD::single_run( setGoniometer(input_workspace); return convertToMD(input_workspace, emode, in_place, filebackend_filename, - filebackend, out_mdws); + filebackend, std::move(out_mdws)); } } diff --git a/Framework/MDAlgorithms/src/CreateMDWorkspace.cpp b/Framework/MDAlgorithms/src/CreateMDWorkspace.cpp index 9c3883ba245df8d4aa4d17174196fbc88a091513..bbaaa2c2a426eb167a30633b8a84b5d0137be3d0 100644 --- a/Framework/MDAlgorithms/src/CreateMDWorkspace.cpp +++ b/Framework/MDAlgorithms/src/CreateMDWorkspace.cpp @@ -243,8 +243,8 @@ void CreateMDWorkspace::exec() { setProperty("OutputWorkspace", boost::dynamic_pointer_cast<Workspace>(out)); } -MDFrame_uptr CreateMDWorkspace::createMDFrame(std::string frame, - std::string unit) { +MDFrame_uptr CreateMDWorkspace::createMDFrame(const std::string &frame, + const std::string &unit) { auto frameFactory = makeMDFrameFactoryChain(); MDFrameArgument frameArg(frame, unit); return frameFactory->create(frameArg); diff --git a/Framework/MDAlgorithms/src/CutMD.cpp b/Framework/MDAlgorithms/src/CutMD.cpp index 07d65b3d8e41a9054dd6e01a30a3cfc915fe9339..0e0c56601b78157f4c8e083c895baef658026a67 100644 --- a/Framework/MDAlgorithms/src/CutMD.cpp +++ b/Framework/MDAlgorithms/src/CutMD.cpp @@ -31,7 +31,7 @@ namespace { // Typedef to simplify function signatures using MinMax = std::pair<double, double>; -MinMax getDimensionExtents(IMDEventWorkspace_sptr ws, size_t index) { +MinMax getDimensionExtents(const IMDEventWorkspace_sptr &ws, size_t index) { if (!ws) throw std::runtime_error( "Invalid workspace passed to getDimensionExtents."); @@ -50,7 +50,7 @@ std::string numToStringWithPrecision(const double num) { DblMatrix scaleProjection(const DblMatrix &inMatrix, const std::vector<std::string> &inUnits, std::vector<std::string> &outUnits, - IMDEventWorkspace_sptr inWS) { + const IMDEventWorkspace_sptr &inWS) { DblMatrix ret(inMatrix); // Check if we actually need to do anything if (std::equal(inUnits.begin(), inUnits.end(), outUnits.begin())) @@ -209,7 +209,7 @@ Determine the original q units. Assumes first 3 dimensions by index are r,l,d @param logger : logging object @return vector of markers */ -std::vector<std::string> findOriginalQUnits(IMDWorkspace_const_sptr inws, +std::vector<std::string> findOriginalQUnits(const IMDWorkspace_const_sptr &inws, Mantid::Kernel::Logger &logger) { std::vector<std::string> unitMarkers(3); for (size_t i = 0; i < inws->getNumDims() && i < 3; ++i) { diff --git a/Framework/MDAlgorithms/src/DisplayNormalizationSetter.cpp b/Framework/MDAlgorithms/src/DisplayNormalizationSetter.cpp index 6572ab64d006425e9a20108a014a208f71ae391e..1d89a09fbf476b1f3fea00d81b5c1047f9cb7d4c 100644 --- a/Framework/MDAlgorithms/src/DisplayNormalizationSetter.cpp +++ b/Framework/MDAlgorithms/src/DisplayNormalizationSetter.cpp @@ -4,10 +4,12 @@ // NScD Oak Ridge National Laboratory, European Spallation Source, // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + -#include "MantidMDAlgorithms/DisplayNormalizationSetter.h" +#include <utility> + #include "MantidAPI/IMDEventWorkspace.h" #include "MantidAPI/MatrixWorkspace.h" #include "MantidDataObjects/EventWorkspace.h" +#include "MantidMDAlgorithms/DisplayNormalizationSetter.h" namespace Mantid { namespace MDAlgorithms { @@ -21,7 +23,7 @@ namespace MDAlgorithms { * @param mode: the energy transfer mode */ void DisplayNormalizationSetter:: -operator()(Mantid::API::IMDWorkspace_sptr mdWorkspace, +operator()(const Mantid::API::IMDWorkspace_sptr &mdWorkspace, const Mantid::API::MatrixWorkspace_sptr &underlyingWorkspace, bool isQ, const Mantid::Kernel::DeltaEMode::Type &mode) { if (boost::dynamic_pointer_cast<Mantid::API::IMDEventWorkspace>( @@ -42,7 +44,7 @@ operator()(Mantid::API::IMDWorkspace_sptr mdWorkspace, * @param mode: the energy transfer mode */ void DisplayNormalizationSetter::setNormalizationMDEvent( - Mantid::API::IMDWorkspace_sptr mdWorkspace, + const Mantid::API::IMDWorkspace_sptr &mdWorkspace, const Mantid::API::MatrixWorkspace_sptr &underlyingWorkspace, bool isQ, const Mantid::Kernel::DeltaEMode::Type &mode) { @@ -73,7 +75,7 @@ void DisplayNormalizationSetter::setNormalizationMDEvent( Mantid::API::MDNormalization::NumEventsNormalization; } - applyNormalizationMDEvent(mdWorkspace, displayNormalization, + applyNormalizationMDEvent(std::move(mdWorkspace), displayNormalization, displayNormalizationHisto); } @@ -86,7 +88,7 @@ void DisplayNormalizationSetter::setNormalizationMDEvent( * MDHisto workspaces */ void DisplayNormalizationSetter::applyNormalizationMDEvent( - Mantid::API::IMDWorkspace_sptr mdWorkspace, + const Mantid::API::IMDWorkspace_sptr &mdWorkspace, Mantid::API::MDNormalization displayNormalization, Mantid::API::MDNormalization displayNormalizationHisto) { auto ws = diff --git a/Framework/MDAlgorithms/src/FindPeaksMD.cpp b/Framework/MDAlgorithms/src/FindPeaksMD.cpp index 10a1aab163167a0f44e738191ac3bb20549f31e7..eb8992ca9d5cdc0046e0a6daa621c979b08d5d6d 100644 --- a/Framework/MDAlgorithms/src/FindPeaksMD.cpp +++ b/Framework/MDAlgorithms/src/FindPeaksMD.cpp @@ -586,7 +586,7 @@ void FindPeaksMD::findPeaks(typename MDEventWorkspace<MDE, nd>::sptr ws) { * @param ws :: MDHistoWorkspace */ void FindPeaksMD::findPeaksHisto( - Mantid::DataObjects::MDHistoWorkspace_sptr ws) { + const Mantid::DataObjects::MDHistoWorkspace_sptr &ws) { size_t nd = ws->getNumDims(); if (nd < 3) throw std::invalid_argument("Workspace must have at least 3 dimensions."); diff --git a/Framework/MDAlgorithms/src/FitMD.cpp b/Framework/MDAlgorithms/src/FitMD.cpp index a0b92864cb4d2b48bc55862df8cf7daa57a3689c..fe289f2f494377274e389388f2fda1d4e946246a 100644 --- a/Framework/MDAlgorithms/src/FitMD.cpp +++ b/Framework/MDAlgorithms/src/FitMD.cpp @@ -269,8 +269,8 @@ boost::shared_ptr<API::Workspace> FitMD::createEventOutputWorkspace( * @param outputWorkspacePropertyName :: The property name */ boost::shared_ptr<API::Workspace> FitMD::createHistoOutputWorkspace( - const std::string &baseName, API::IFunction_sptr function, - API::IMDHistoWorkspace_const_sptr inputWorkspace, + const std::string &baseName, const API::IFunction_sptr &function, + const API::IMDHistoWorkspace_const_sptr &inputWorkspace, const std::string &outputWorkspacePropertyName) { // have to cast const away to be able to pass the workspace to the algorithm API::IMDHistoWorkspace_sptr nonConstInputWS = diff --git a/Framework/MDAlgorithms/src/GetSpiceDataRawCountsFromMD.cpp b/Framework/MDAlgorithms/src/GetSpiceDataRawCountsFromMD.cpp index 9aefe3c58f3c99f631b9f4b86b20920c4de5d57d..b82ab214b1b360fdd5a1147abf0d2407ac5c6c92 100644 --- a/Framework/MDAlgorithms/src/GetSpiceDataRawCountsFromMD.cpp +++ b/Framework/MDAlgorithms/src/GetSpiceDataRawCountsFromMD.cpp @@ -17,6 +17,7 @@ #include "MantidKernel/ListValidator.h" #include <algorithm> +#include <utility> namespace Mantid { namespace MDAlgorithms { @@ -147,15 +148,16 @@ void GetSpiceDataRawCountsFromMD::exec() { * @param donormalize */ void GetSpiceDataRawCountsFromMD::exportDetCountsOfRun( - API::IMDEventWorkspace_const_sptr datamdws, - API::IMDEventWorkspace_const_sptr monitormdws, const int runnumber, + const API::IMDEventWorkspace_const_sptr &datamdws, + const API::IMDEventWorkspace_const_sptr &monitormdws, const int runnumber, std::vector<double> &vecX, std::vector<double> &vecY, std::string &xlabel, std::string &ylabel, bool donormalize) { // Get detector counts std::vector<double> vec2theta; std::vector<double> vecDetCounts; int detid = -1; - getDetCounts(datamdws, runnumber, detid, vec2theta, vecDetCounts, true); + getDetCounts(std::move(datamdws), runnumber, detid, vec2theta, vecDetCounts, + true); if (vec2theta.size() != vecDetCounts.size()) throw std::runtime_error( "Logic error! Vector of 2theta must have same size as " @@ -166,8 +168,8 @@ void GetSpiceDataRawCountsFromMD::exportDetCountsOfRun( std::vector<double> vecMonitorCounts; // Normalize if required if (donormalize) { - getDetCounts(monitormdws, runnumber, detid, vec2thetaMon, vecMonitorCounts, - false); + getDetCounts(std::move(monitormdws), runnumber, detid, vec2thetaMon, + vecMonitorCounts, false); // check if (vecDetCounts.size() != vecMonitorCounts.size()) throw std::runtime_error( @@ -218,8 +220,8 @@ void GetSpiceDataRawCountsFromMD::exportDetCountsOfRun( * @param donormalize */ void GetSpiceDataRawCountsFromMD::exportIndividualDetCounts( - API::IMDEventWorkspace_const_sptr datamdws, - API::IMDEventWorkspace_const_sptr monitormdws, const int detid, + const API::IMDEventWorkspace_const_sptr &datamdws, + const API::IMDEventWorkspace_const_sptr &monitormdws, const int detid, std::vector<double> &vecX, std::vector<double> &vecY, std::string &xlabel, std::string &ylabel, const bool &donormalize) { // Get detector counts @@ -246,8 +248,8 @@ void GetSpiceDataRawCountsFromMD::exportIndividualDetCounts( // FIXME - Consider refactoring in future // Normalize if required if (donormalize) { - getDetCounts(monitormdws, runnumber, detid, vec2thetaMon, vecMonitorCounts, - false); + getDetCounts(std::move(monitormdws), runnumber, detid, vec2thetaMon, + vecMonitorCounts, false); if (vecDetCounts.size() != vecMonitorCounts.size()) throw std::runtime_error( "Number of detectors' counts' is different from that of " @@ -296,7 +298,7 @@ void GetSpiceDataRawCountsFromMD::exportIndividualDetCounts( * @param ylabel */ void GetSpiceDataRawCountsFromMD::exportSampleLogValue( - API::IMDEventWorkspace_const_sptr datamdws, + const API::IMDEventWorkspace_const_sptr &datamdws, const std::string &samplelogname, std::vector<double> &vecX, std::vector<double> &vecY, std::string &xlabel, std::string &ylabel) { // prepare @@ -349,7 +351,7 @@ void GetSpiceDataRawCountsFromMD::exportSampleLogValue( * @param formX :: flag to set up vecX */ void GetSpiceDataRawCountsFromMD::getDetCounts( - API::IMDEventWorkspace_const_sptr mdws, const int &runnumber, + const API::IMDEventWorkspace_const_sptr &mdws, const int &runnumber, const int &detid, std::vector<double> &vecX, std::vector<double> &vecY, bool formX) { // Get sample and source position @@ -441,7 +443,7 @@ void GetSpiceDataRawCountsFromMD::getDetCounts( * @param vecSampleLog */ void GetSpiceDataRawCountsFromMD::getSampleLogValues( - IMDEventWorkspace_const_sptr mdws, const std::string &samplelogname, + const IMDEventWorkspace_const_sptr &mdws, const std::string &samplelogname, const int runnumber, std::vector<double> &vecSampleLog) { // Clear input vecSampleLog.clear(); diff --git a/Framework/MDAlgorithms/src/ImportMDHistoWorkspaceBase.cpp b/Framework/MDAlgorithms/src/ImportMDHistoWorkspaceBase.cpp index fe71eb9bc1982af4b7b6fd6bd41d66f7fb574117..53ae75ebfbbfdb582bd83e70310a4dec7ddb8224 100644 --- a/Framework/MDAlgorithms/src/ImportMDHistoWorkspaceBase.cpp +++ b/Framework/MDAlgorithms/src/ImportMDHistoWorkspaceBase.cpp @@ -145,8 +145,9 @@ MDHistoWorkspace_sptr ImportMDHistoWorkspaceBase::createEmptyOutputWorkspace() { * @param unit: the selected unit * @returns a unique pointer to an MDFrame */ -MDFrame_uptr ImportMDHistoWorkspaceBase::createMDFrame(std::string frame, - std::string unit) { +MDFrame_uptr +ImportMDHistoWorkspaceBase::createMDFrame(const std::string &frame, + const std::string &unit) { auto frameFactory = makeMDFrameFactoryChain(); MDFrameArgument frameArg(frame, unit); return frameFactory->create(frameArg); diff --git a/Framework/MDAlgorithms/src/Integrate3DEvents.cpp b/Framework/MDAlgorithms/src/Integrate3DEvents.cpp index 798c7c907636878f3e106fcbd58cbc5b3bdd6052..b7fa3fe54a4e7fb407c5bb7fc30db005a982bfa5 100644 --- a/Framework/MDAlgorithms/src/Integrate3DEvents.cpp +++ b/Framework/MDAlgorithms/src/Integrate3DEvents.cpp @@ -18,6 +18,8 @@ extern "C" { #include <cstdio> +#include <utility> + #include <gsl/gsl_eigen.h> #include <gsl/gsl_matrix.h> #include <gsl/gsl_vector.h> @@ -447,7 +449,7 @@ bool Integrate3DEvents::correctForDetectorEdges( */ Mantid::Geometry::PeakShape_const_sptr Integrate3DEvents::ellipseIntegrateEvents( - std::vector<V3D> E1Vec, V3D const &peak_q, bool specify_size, + const std::vector<V3D> &E1Vec, V3D const &peak_q, bool specify_size, double peak_radius, double back_inner_radius, double back_outer_radius, std::vector<double> &axes_radii, double &inti, double &sigi) { inti = 0.0; // default values, in case something @@ -494,18 +496,18 @@ Integrate3DEvents::ellipseIntegrateEvents( return boost::make_shared<NoShape>(); // ellipsoids will be zero. } - return ellipseIntegrateEvents(E1Vec, peak_q, some_events, eigen_vectors, - sigmas, specify_size, peak_radius, - back_inner_radius, back_outer_radius, - axes_radii, inti, sigi); + return ellipseIntegrateEvents(std::move(E1Vec), peak_q, some_events, + eigen_vectors, sigmas, specify_size, + peak_radius, back_inner_radius, + back_outer_radius, axes_radii, inti, sigi); } Mantid::Geometry::PeakShape_const_sptr Integrate3DEvents::ellipseIntegrateModEvents( - std::vector<V3D> E1Vec, V3D const &peak_q, V3D const &hkl, V3D const &mnp, - bool specify_size, double peak_radius, double back_inner_radius, - double back_outer_radius, std::vector<double> &axes_radii, double &inti, - double &sigi) { + const std::vector<V3D> &E1Vec, V3D const &peak_q, V3D const &hkl, + V3D const &mnp, bool specify_size, double peak_radius, + double back_inner_radius, double back_outer_radius, + std::vector<double> &axes_radii, double &inti, double &sigi) { inti = 0.0; // default values, in case something sigi = 0.0; // is wrong with the peak. @@ -555,10 +557,10 @@ Integrate3DEvents::ellipseIntegrateModEvents( return boost::make_shared<NoShape>(); // ellipsoids will be zero. } - return ellipseIntegrateEvents(E1Vec, peak_q, some_events, eigen_vectors, - sigmas, specify_size, peak_radius, - back_inner_radius, back_outer_radius, - axes_radii, inti, sigi); + return ellipseIntegrateEvents(std::move(E1Vec), peak_q, some_events, + eigen_vectors, sigmas, specify_size, + peak_radius, back_inner_radius, + back_outer_radius, axes_radii, inti, sigi); } /** * Calculate the number of events in an ellipsoid centered at 0,0,0 with @@ -1107,7 +1109,7 @@ void Integrate3DEvents::addModEvent( * */ PeakShapeEllipsoid_const_sptr Integrate3DEvents::ellipseIntegrateEvents( - std::vector<V3D> E1Vec, V3D const &peak_q, + const std::vector<V3D> &E1Vec, V3D const &peak_q, std::vector<std::pair<std::pair<double, double>, Mantid::Kernel::V3D>> const &ev_list, std::vector<V3D> const &directions, std::vector<double> const &sigmas, @@ -1212,7 +1214,8 @@ PeakShapeEllipsoid_const_sptr Integrate3DEvents::ellipseIntegrateEvents( * @param QLabFrame: The Peak center. * @param r: Peak radius. */ -double Integrate3DEvents::detectorQ(std::vector<V3D> E1Vec, const V3D QLabFrame, +double Integrate3DEvents::detectorQ(const std::vector<V3D> &E1Vec, + const V3D QLabFrame, const std::vector<double> &r) { double quot = 1.0; for (auto &E1 : E1Vec) { diff --git a/Framework/MDAlgorithms/src/IntegrateEllipsoids.cpp b/Framework/MDAlgorithms/src/IntegrateEllipsoids.cpp index ce914be9ceb54483e9c521cda74405fe546a7de5..e11aaaad9fef17eb5767838cd800669c86492abc 100644 --- a/Framework/MDAlgorithms/src/IntegrateEllipsoids.cpp +++ b/Framework/MDAlgorithms/src/IntegrateEllipsoids.cpp @@ -746,8 +746,8 @@ void IntegrateEllipsoids::calculateE1( } void IntegrateEllipsoids::runMaskDetectors( - Mantid::DataObjects::PeaksWorkspace_sptr peakWS, std::string property, - std::string values) { + const Mantid::DataObjects::PeaksWorkspace_sptr &peakWS, + const std::string &property, const std::string &values) { IAlgorithm_sptr alg = createChildAlgorithm("MaskBTP"); alg->setProperty<Workspace_sptr>("Workspace", peakWS); alg->setProperty(property, values); diff --git a/Framework/MDAlgorithms/src/IntegrateEllipsoidsTwoStep.cpp b/Framework/MDAlgorithms/src/IntegrateEllipsoidsTwoStep.cpp index 78ea2ccc95e3ebeabe2152956c588766f9a0d040..0d5a049faa3a8cd77717a32f07c686d82f6f41e2 100644 --- a/Framework/MDAlgorithms/src/IntegrateEllipsoidsTwoStep.cpp +++ b/Framework/MDAlgorithms/src/IntegrateEllipsoidsTwoStep.cpp @@ -559,8 +559,8 @@ void IntegrateEllipsoidsTwoStep::calculateE1( } void IntegrateEllipsoidsTwoStep::runMaskDetectors( - Mantid::DataObjects::PeaksWorkspace_sptr peakWS, std::string property, - std::string values) { + const Mantid::DataObjects::PeaksWorkspace_sptr &peakWS, + const std::string &property, const std::string &values) { IAlgorithm_sptr alg = createChildAlgorithm("MaskBTP"); alg->setProperty<Workspace_sptr>("Workspace", peakWS); alg->setProperty(property, values); diff --git a/Framework/MDAlgorithms/src/IntegratePeaksCWSD.cpp b/Framework/MDAlgorithms/src/IntegratePeaksCWSD.cpp index 066aa52318b58ef5f5270fb09f94bfa37ac9fe03..df0ce5a5a9495f70f2f84a99ad995a02bd2f43c0 100644 --- a/Framework/MDAlgorithms/src/IntegratePeaksCWSD.cpp +++ b/Framework/MDAlgorithms/src/IntegratePeaksCWSD.cpp @@ -368,7 +368,7 @@ void IntegratePeaksCWSD::simplePeakIntegration( * @param maskws */ std::vector<detid_t> IntegratePeaksCWSD::processMaskWorkspace( - DataObjects::MaskWorkspace_const_sptr maskws) { + const DataObjects::MaskWorkspace_const_sptr &maskws) { std::vector<detid_t> vecMaskedDetID; // Add the detector IDs of all masked detector to a vector @@ -452,9 +452,8 @@ DataObjects::PeaksWorkspace_sptr IntegratePeaksCWSD::createOutputs() { * @param mdws :: source MDEventWorkspace where the run numbers come from * @return */ -DataObjects::PeaksWorkspace_sptr -IntegratePeaksCWSD::createPeakworkspace(Kernel::V3D peakCenter, - API::IMDEventWorkspace_sptr mdws) { +DataObjects::PeaksWorkspace_sptr IntegratePeaksCWSD::createPeakworkspace( + Kernel::V3D peakCenter, const API::IMDEventWorkspace_sptr &mdws) { g_log.notice("Create peak workspace for output ... ..."); // new peak workspace DataObjects::PeaksWorkspace_sptr peakws = diff --git a/Framework/MDAlgorithms/src/IntegratePeaksMD2.cpp b/Framework/MDAlgorithms/src/IntegratePeaksMD2.cpp index 246604a2e3d65c7484f5722d56395d01483c430a..5f856905e9dc43d0996d9f6083deff0225e4c4b0 100644 --- a/Framework/MDAlgorithms/src/IntegratePeaksMD2.cpp +++ b/Framework/MDAlgorithms/src/IntegratePeaksMD2.cpp @@ -721,8 +721,8 @@ double IntegratePeaksMD2::detectorQ(Mantid::Kernel::V3D QLabFrame, double r) { } void IntegratePeaksMD2::runMaskDetectors( - Mantid::DataObjects::PeaksWorkspace_sptr peakWS, std::string property, - std::string values) { + const Mantid::DataObjects::PeaksWorkspace_sptr &peakWS, + const std::string &property, const std::string &values) { // For CORELLI do not count as edge if next to another detector bank if (property == "Tube" && peakWS->getInstrument()->getName() == "CORELLI") { IAlgorithm_sptr alg = createChildAlgorithm("MaskBTP"); @@ -750,7 +750,7 @@ void IntegratePeaksMD2::runMaskDetectors( } void IntegratePeaksMD2::checkOverlap( - int i, Mantid::DataObjects::PeaksWorkspace_sptr peakWS, + int i, const Mantid::DataObjects::PeaksWorkspace_sptr &peakWS, Mantid::Kernel::SpecialCoordinateSystem CoordinatesToUse, double radius) { // Get a direct ref to that peak. IPeak &p1 = peakWS->getPeak(i); diff --git a/Framework/MDAlgorithms/src/IntegratePeaksMDHKL.cpp b/Framework/MDAlgorithms/src/IntegratePeaksMDHKL.cpp index a20ee5229227a588ce2ce08361779f69f200f811..777e53bc68cd6e54dd41cc3c548e720a56d4ba3d 100644 --- a/Framework/MDAlgorithms/src/IntegratePeaksMDHKL.cpp +++ b/Framework/MDAlgorithms/src/IntegratePeaksMDHKL.cpp @@ -195,7 +195,7 @@ IntegratePeaksMDHKL::normalize(int h, int k, int l, double box, int gridPts, } void IntegratePeaksMDHKL::integratePeak(const int neighborPts, - MDHistoWorkspace_sptr out, + const MDHistoWorkspace_sptr &out, double &intensity, double &errorSquared) { std::vector<int> gridPts; diff --git a/Framework/MDAlgorithms/src/InvalidParameter.cpp b/Framework/MDAlgorithms/src/InvalidParameter.cpp index 2d0bba40cef0606cff4d155bf982b7a332f1f5cd..3865fbed263b4e3d62b32f92e847f2e3272ee8af 100644 --- a/Framework/MDAlgorithms/src/InvalidParameter.cpp +++ b/Framework/MDAlgorithms/src/InvalidParameter.cpp @@ -4,13 +4,16 @@ // NScD Oak Ridge National Laboratory, European Spallation Source, // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + +#include <utility> + #include "MantidMDAlgorithms/InvalidParameter.h" namespace Mantid { namespace MDAlgorithms { InvalidParameter::InvalidParameter() {} -InvalidParameter::InvalidParameter(std::string value) : m_value(value) {} +InvalidParameter::InvalidParameter(std::string value) + : m_value(std::move(value)) {} std::string InvalidParameter::getName() const { return parameterName(); } diff --git a/Framework/MDAlgorithms/src/InvalidParameterParser.cpp b/Framework/MDAlgorithms/src/InvalidParameterParser.cpp index 56ff18f988c284c60f1bd1f88a243a95461b43de..f27ec3ef84c79591b19d48db49e1fa61cc5062de 100644 --- a/Framework/MDAlgorithms/src/InvalidParameterParser.cpp +++ b/Framework/MDAlgorithms/src/InvalidParameterParser.cpp @@ -7,6 +7,7 @@ #include "MantidMDAlgorithms/InvalidParameterParser.h" #include "MantidAPI/ImplicitFunctionParameterParserFactory.h" #include <boost/algorithm/string.hpp> +#include <utility> namespace Mantid { namespace MDAlgorithms { @@ -23,7 +24,7 @@ InvalidParameterParser::createParameter(Poco::XML::Element *parameterElement) { InvalidParameter * InvalidParameterParser::parseInvalidParameter(std::string value) { - return new InvalidParameter(value); + return new InvalidParameter(std::move(value)); } void InvalidParameterParser::setSuccessorParser( diff --git a/Framework/MDAlgorithms/src/LoadDNSSCD.cpp b/Framework/MDAlgorithms/src/LoadDNSSCD.cpp index e58b7e14a42403de99e10c1ccde02c9af971904b..4dc8143a57dc15d0543e61a23fec1b3533cff30d 100644 --- a/Framework/MDAlgorithms/src/LoadDNSSCD.cpp +++ b/Framework/MDAlgorithms/src/LoadDNSSCD.cpp @@ -240,7 +240,7 @@ void LoadDNSSCD::init() { /** Read Huber angles from a given table workspace. */ -void LoadDNSSCD::loadHuber(ITableWorkspace_sptr tws) { +void LoadDNSSCD::loadHuber(const ITableWorkspace_sptr &tws) { ColumnVector<double> huber = tws->getVector("Huber(degrees)"); // set huber[0] for each run in m_data for (auto &ds : m_data) { @@ -789,7 +789,7 @@ void LoadDNSSCD::fillOutputWorkspaceRaw(double wavelength) { setProperty("NormalizationWorkspace", normWS); } -void LoadDNSSCD::read_data(const std::string fname, +void LoadDNSSCD::read_data(const std::string &fname, std::map<std::string, std::string> &str_metadata, std::map<std::string, double> &num_metadata) { std::ifstream file(fname); diff --git a/Framework/MDAlgorithms/src/LoadMD.cpp b/Framework/MDAlgorithms/src/LoadMD.cpp index af997aae16cf43188d5a7e097fd9c7301fb46402..0ebd94bfad8540fcc52ebfe0fefc3ff11720c3c3 100644 --- a/Framework/MDAlgorithms/src/LoadMD.cpp +++ b/Framework/MDAlgorithms/src/LoadMD.cpp @@ -275,7 +275,8 @@ void LoadMD::exec() { * @param ws * @param dataType */ -void LoadMD::loadSlab(std::string name, void *data, MDHistoWorkspace_sptr ws, +void LoadMD::loadSlab(const std::string &name, void *data, + const MDHistoWorkspace_sptr &ws, NeXus::NXnumtype dataType) { m_file->openData(name); if (m_file->getInfo().type != dataType) @@ -634,7 +635,7 @@ void LoadMD::doLoad(typename MDEventWorkspace<MDE, nd>::sptr ws) { * appropriate coordinate transform and set those on the workspace. * @param ws : workspace to set the coordinate transforms on */ -void LoadMD::loadAffineMatricies(IMDWorkspace_sptr ws) { +void LoadMD::loadAffineMatricies(const IMDWorkspace_sptr &ws) { std::map<std::string, std::string> entries; m_file->getEntries(entries); @@ -655,7 +656,7 @@ void LoadMD::loadAffineMatricies(IMDWorkspace_sptr ws) { * @param entry_name : the entry point in the NeXus file to read * @return the coordinate transform object */ -CoordTransform *LoadMD::loadAffineMatrix(std::string entry_name) { +CoordTransform *LoadMD::loadAffineMatrix(const std::string &entry_name) { m_file->openData(entry_name); std::vector<coord_t> vec; m_file->getData<coord_t>(vec); @@ -686,7 +687,8 @@ CoordTransform *LoadMD::loadAffineMatrix(std::string entry_name) { * Set MDFrames for workspaces from legacy files * @param ws:: poitner to the workspace which needs to be corrected */ -void LoadMD::setMDFrameOnWorkspaceFromLegacyFile(API::IMDWorkspace_sptr ws) { +void LoadMD::setMDFrameOnWorkspaceFromLegacyFile( + const API::IMDWorkspace_sptr &ws) { g_log.information() << "LoadMD: Encountered a legacy file which has a mismatch between " @@ -761,7 +763,7 @@ void LoadMD::setMDFrameOnWorkspaceFromLegacyFile(API::IMDWorkspace_sptr ws) { * where * all MDFrames were stored as MDFrames */ -void LoadMD::checkForRequiredLegacyFixup(API::IMDWorkspace_sptr ws) { +void LoadMD::checkForRequiredLegacyFixup(const API::IMDWorkspace_sptr &ws) { // Check if the special coordinate is not none auto isQBasedSpecialCoordinateSystem = true; if (m_coordSystem == Mantid::Kernel::SpecialCoordinateSystem::None) { @@ -787,7 +789,7 @@ void LoadMD::checkForRequiredLegacyFixup(API::IMDWorkspace_sptr ws) { /** * Find scaling for Q dimensions */ -std::vector<double> LoadMD::qDimensions(API::IMDWorkspace_sptr ws) { +std::vector<double> LoadMD::qDimensions(const API::IMDWorkspace_sptr &ws) { std::vector<double> scaling(m_numDims); for (size_t d = 0; d < m_numDims; d++) { std::string dimd = ws->getDimension(d)->getName(); diff --git a/Framework/MDAlgorithms/src/LoadSQW2.cpp b/Framework/MDAlgorithms/src/LoadSQW2.cpp index a4ca1f4aec93326ace3c6af432809ca98f67ebea..df4856bb6c8183e3129f893cac554baa89e02ee0 100644 --- a/Framework/MDAlgorithms/src/LoadSQW2.cpp +++ b/Framework/MDAlgorithms/src/LoadSQW2.cpp @@ -595,7 +595,7 @@ void LoadSQW2::setupBoxController() { * box controller has already been initialized * @param filebackPath Path to the file used for backend storage */ -void LoadSQW2::setupFileBackend(std::string filebackPath) { +void LoadSQW2::setupFileBackend(const std::string &filebackPath) { using DataObjects::BoxControllerNeXusIO; auto savemd = this->createChildAlgorithm("SaveMD", 0.01, 0.05, true); savemd->setProperty("InputWorkspace", m_outputWS); diff --git a/Framework/MDAlgorithms/src/MDEventWSWrapper.cpp b/Framework/MDAlgorithms/src/MDEventWSWrapper.cpp index d81d9a73226a7c797e38d55c75bcb6f22bf46d18..0df5201068fc3f2547d3de872b1d8f28c34f8cea 100644 --- a/Framework/MDAlgorithms/src/MDEventWSWrapper.cpp +++ b/Framework/MDAlgorithms/src/MDEventWSWrapper.cpp @@ -4,8 +4,10 @@ // NScD Oak Ridge National Laboratory, European Spallation Source, // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + -#include "MantidMDAlgorithms/MDEventWSWrapper.h" +#include <utility> + #include "MantidGeometry/MDGeometry/MDTypes.h" +#include "MantidMDAlgorithms/MDEventWSWrapper.h" namespace Mantid { namespace MDAlgorithms { @@ -202,7 +204,7 @@ MDEventWSWrapper::createEmptyMDWS(const MDWSDescription &WSD) { /// set up existing workspace pointer as internal pointer for the class to /// perform proper MD operations on this workspace void MDEventWSWrapper::setMDWS(API::IMDEventWorkspace_sptr spWS) { - m_Workspace = spWS; + m_Workspace = std::move(spWS); m_NDimensions = m_Workspace->getNumDims(); } diff --git a/Framework/MDAlgorithms/src/MDNorm.cpp b/Framework/MDAlgorithms/src/MDNorm.cpp index 544fa1e7bcabf77d78e6d4053622dcd45a2a712e..e2ba944696455f95a4c84eb72699e1bfc5d92d0c 100644 --- a/Framework/MDAlgorithms/src/MDNorm.cpp +++ b/Framework/MDAlgorithms/src/MDNorm.cpp @@ -746,7 +746,7 @@ void MDNorm::createNormalizationWS( */ void MDNorm::validateBinningForTemporaryDataWorkspace( const std::map<std::string, std::string> ¶meters, - const Mantid::API::IMDHistoWorkspace_sptr tempDataWS) { + const Mantid::API::IMDHistoWorkspace_sptr &tempDataWS) { // parse the paramters map and get extents from tempDataWS const std::string numBinsStr = parameters.at("OutputBins"); @@ -921,8 +921,8 @@ void MDNorm::validateBinningForTemporaryDataWorkspace( * All slicing algorithm properties are passed along * @return MDHistoWorkspace as a result of the binning */ -DataObjects::MDHistoWorkspace_sptr -MDNorm::binInputWS(std::vector<Geometry::SymmetryOperation> symmetryOps) { +DataObjects::MDHistoWorkspace_sptr MDNorm::binInputWS( + const std::vector<Geometry::SymmetryOperation> &symmetryOps) { Mantid::API::IMDHistoWorkspace_sptr tempDataWS = this->getProperty("TemporaryDataWorkspace"); Mantid::API::Workspace_sptr outputWS; @@ -1142,7 +1142,7 @@ void MDNorm::cacheDimensionXValues() { * @param soIndex - the index of symmetry operation (for progress purposes) */ void MDNorm::calculateNormalization(const std::vector<coord_t> &otherValues, - Geometry::SymmetryOperation so, + const Geometry::SymmetryOperation &so, uint16_t expInfoIndex, size_t soIndex) { const auto ¤tExptInfo = *(m_inputWS->getExperimentInfo(expInfoIndex)); std::vector<double> lowValues, highValues; @@ -1330,7 +1330,7 @@ m_accumulate = true; */ void MDNorm::calculateIntersections( std::vector<std::array<double, 4>> &intersections, const double theta, - const double phi, Kernel::DblMatrix transform, double lowvalue, + const double phi, const Kernel::DblMatrix &transform, double lowvalue, double highvalue) { V3D qout(sin(theta) * cos(phi), sin(theta) * sin(phi), cos(theta)), qin(0., 0., 1); diff --git a/Framework/MDAlgorithms/src/MDTransfNoQ.cpp b/Framework/MDAlgorithms/src/MDTransfNoQ.cpp index e0aad525d45d3686604a7cab838668c9afbf3968..146d8188cbc1ab39a473259bff72114f90f1491b 100644 --- a/Framework/MDAlgorithms/src/MDTransfNoQ.cpp +++ b/Framework/MDAlgorithms/src/MDTransfNoQ.cpp @@ -119,7 +119,7 @@ MDTransfNoQ::getNMatrixDimensions(Kernel::DeltaEMode::Type mode, } // internal helper function which extract one or two axis from input matrix // workspace; -void MDTransfNoQ::getAxes(API::MatrixWorkspace_const_sptr inWS, +void MDTransfNoQ::getAxes(const API::MatrixWorkspace_const_sptr &inWS, API::NumericAxis *&pXAxis, API::NumericAxis *&pYAxis) { // get the X axis of input workspace, it has to be there; if not axis throws diff --git a/Framework/MDAlgorithms/src/MDWSDescription.cpp b/Framework/MDAlgorithms/src/MDWSDescription.cpp index 3560edc8cde8c9f0277fa1b65fcc1f9d9ae50450..aecd160aff605199cdce500ebb3ca9b46d49a6cb 100644 --- a/Framework/MDAlgorithms/src/MDWSDescription.cpp +++ b/Framework/MDAlgorithms/src/MDWSDescription.cpp @@ -20,6 +20,7 @@ #include "MantidMDAlgorithms/MDTransfFactory.h" #include <boost/lexical_cast.hpp> +#include <utility> namespace Mantid { namespace MDAlgorithms { @@ -67,7 +68,7 @@ which will be used as dimensions. */ void MDWSDescription::buildFromMatrixWS( const API::MatrixWorkspace_sptr &pWS, const std::string &QMode, - const std::string dEMode, + const std::string &dEMode, const std::vector<std::string> &dimPropertyNames) { m_InWS = pWS; // fill additional dimensions values, defined by workspace properties; @@ -125,7 +126,7 @@ void MDWSDescription::buildFromMatrixWS( } void MDWSDescription::setWS(API::MatrixWorkspace_sptr otherMatrixWS) { - m_InWS = otherMatrixWS; + m_InWS = std::move(otherMatrixWS); } /// Method checks if input workspace has defined goniometer bool MDWSDescription::hasGoniometer() const { @@ -349,7 +350,7 @@ std::string MDWSDescription::getEModeStr() const { *properties) for current multidimensional event */ void MDWSDescription::fillAddProperties( - Mantid::API::MatrixWorkspace_const_sptr inWS2D, + const Mantid::API::MatrixWorkspace_const_sptr &inWS2D, const std::vector<std::string> &dimPropertyNames, std::vector<coord_t> &AddCoord) { size_t nDimPropNames = dimPropertyNames.size(); @@ -400,7 +401,7 @@ void MDWSDescription::checkMinMaxNdimConsistent( /** function retrieves copy of the oriented lattice from the workspace */ boost::shared_ptr<Geometry::OrientedLattice> MDWSDescription::getOrientedLattice( - Mantid::API::MatrixWorkspace_const_sptr inWS2D) { + const Mantid::API::MatrixWorkspace_const_sptr &inWS2D) { // try to get the WS oriented lattice boost::shared_ptr<Geometry::OrientedLattice> orl; if (inWS2D->sample().hasOrientedLattice()) @@ -432,7 +433,7 @@ Geometry::MDFrame_uptr MDWSDescription::getFrame(size_t d) const { * Sets the frame. * @param frameKey : Frame key desired. */ -void MDWSDescription::setFrame(const std::string frameKey) { +void MDWSDescription::setFrame(const std::string &frameKey) { m_frameKey = frameKey; } diff --git a/Framework/MDAlgorithms/src/MaskMD.cpp b/Framework/MDAlgorithms/src/MaskMD.cpp index ad6b749a7075b59eda17ea7fc5f56e810241d0be..7dd1249f4dcee998233373b53e6040d9507a8ada 100644 --- a/Framework/MDAlgorithms/src/MaskMD.cpp +++ b/Framework/MDAlgorithms/src/MaskMD.cpp @@ -116,7 +116,7 @@ workspace. @throws runtime_error if the requested dimension is unknown either by id, or by name in the workspace. */ -size_t tryFetchDimensionIndex(Mantid::API::IMDWorkspace_sptr ws, +size_t tryFetchDimensionIndex(const Mantid::API::IMDWorkspace_sptr &ws, const std::string &candidateNameOrId) { size_t dimWorkspaceIndex; try { diff --git a/Framework/MDAlgorithms/src/MergeMDFiles.cpp b/Framework/MDAlgorithms/src/MergeMDFiles.cpp index 6c3720a0fa8728c3157062447f13702ced5cdce1..74c9a3836f7994d2cf37439275d6603971317acd 100644 --- a/Framework/MDAlgorithms/src/MergeMDFiles.cpp +++ b/Framework/MDAlgorithms/src/MergeMDFiles.cpp @@ -197,8 +197,9 @@ uint64_t MergeMDFiles::loadEventsFromSubBoxes(API::IMDNode *TargetBox) { * @param outputFile :: the name of the output file where file-based workspace *should be saved */ -void MergeMDFiles::doExecByCloning(Mantid::API::IMDEventWorkspace_sptr ws, - const std::string &outputFile) { +void MergeMDFiles::doExecByCloning( + const Mantid::API::IMDEventWorkspace_sptr &ws, + const std::string &outputFile) { m_OutIWS = ws; m_MDEventType = ws->getEventTypeName(); diff --git a/Framework/MDAlgorithms/src/PreprocessDetectorsToMD.cpp b/Framework/MDAlgorithms/src/PreprocessDetectorsToMD.cpp index ee4152a6e705442e69827f3be80a2e036ef7bea7..e8d6dc38f3b9d68ecf3d3eff61860130977fc7aa 100644 --- a/Framework/MDAlgorithms/src/PreprocessDetectorsToMD.cpp +++ b/Framework/MDAlgorithms/src/PreprocessDetectorsToMD.cpp @@ -399,7 +399,7 @@ void PreprocessDetectorsToMD::buildFakeDetectorsPositions( /// function checks if source workspace still has information about detectors. /// Some ws (like rebinned one) do not have this information any more. bool PreprocessDetectorsToMD::isDetInfoLost( - Mantid::API::MatrixWorkspace_const_sptr inWS2D) const { + const Mantid::API::MatrixWorkspace_const_sptr &inWS2D) const { auto pYAxis = dynamic_cast<API::NumericAxis *>(inWS2D->getAxis(1)); // if this is numeric axis, then the detector's information has been lost: return pYAxis != nullptr; diff --git a/Framework/MDAlgorithms/src/SaveIsawQvector.cpp b/Framework/MDAlgorithms/src/SaveIsawQvector.cpp index 761bcdc86dbfde88a6809795bb7b3543240b83eb..a4a5fb82ab42e821964b280690ce77f0445bb029 100644 --- a/Framework/MDAlgorithms/src/SaveIsawQvector.cpp +++ b/Framework/MDAlgorithms/src/SaveIsawQvector.cpp @@ -194,7 +194,7 @@ void SaveIsawQvector::exec() { * * @param wksp The workspace to get information from. */ -void SaveIsawQvector::initTargetWSDescr(EventWorkspace_sptr wksp) { +void SaveIsawQvector::initTargetWSDescr(const EventWorkspace_sptr &wksp) { m_targWSDescr.setMinMax(std::vector<double>(3, -2000.), std::vector<double>(3, 2000.)); m_targWSDescr.buildFromMatrixWS(wksp, Q3D, ELASTIC); diff --git a/Framework/MDAlgorithms/src/SaveMD.cpp b/Framework/MDAlgorithms/src/SaveMD.cpp index 31253526ebee14b5d550d938c98511b0ad102d43..8f9fd29e434b3aa011b508ad4c33f7ed974d128c 100644 --- a/Framework/MDAlgorithms/src/SaveMD.cpp +++ b/Framework/MDAlgorithms/src/SaveMD.cpp @@ -33,7 +33,7 @@ namespace { template <typename MDE, size_t nd> void prepareUpdate(MDBoxFlatTree &BoxFlatStruct, BoxController *bc, typename MDEventWorkspace<MDE, nd>::sptr ws, - std::string filename) { + const std::string &filename) { // remove all boxes from the DiskBuffer. DB will calculate boxes positions // on HDD. bc->getFileIO()->flushCache(); @@ -236,7 +236,7 @@ void SaveMD::doSaveEvents(typename MDEventWorkspace<MDE, nd>::sptr ws) { * * @param ws :: MDHistoWorkspace to save */ -void SaveMD::doSaveHisto(Mantid::DataObjects::MDHistoWorkspace_sptr ws) { +void SaveMD::doSaveHisto(const Mantid::DataObjects::MDHistoWorkspace_sptr &ws) { std::string filename = getPropertyValue("Filename"); // Erase the file if it exists diff --git a/Framework/MDAlgorithms/src/SaveMD2.cpp b/Framework/MDAlgorithms/src/SaveMD2.cpp index 548baf4c74a76985012876bdd7a1be78ca8c2c7d..1bafc3309dd899b8ea6688ebeba50b639568d4d0 100644 --- a/Framework/MDAlgorithms/src/SaveMD2.cpp +++ b/Framework/MDAlgorithms/src/SaveMD2.cpp @@ -88,7 +88,8 @@ void SaveMD2::init() { * * @param ws :: MDHistoWorkspace to save */ -void SaveMD2::doSaveHisto(Mantid::DataObjects::MDHistoWorkspace_sptr ws) { +void SaveMD2::doSaveHisto( + const Mantid::DataObjects::MDHistoWorkspace_sptr &ws) { std::string filename = getPropertyValue("Filename"); // Erase the file if it exists diff --git a/Framework/MDAlgorithms/src/SlicingAlgorithm.cpp b/Framework/MDAlgorithms/src/SlicingAlgorithm.cpp index 954651bc8efff869dcff8a7430415853976c7642..d8b8a17c5b6b876dae4b2734be177b210104ac89 100644 --- a/Framework/MDAlgorithms/src/SlicingAlgorithm.cpp +++ b/Framework/MDAlgorithms/src/SlicingAlgorithm.cpp @@ -19,6 +19,7 @@ #include "MantidKernel/VisibleWhenProperty.h" #include <boost/regex.hpp> +#include <utility> using namespace Mantid::Kernel; using namespace Mantid::API; @@ -903,7 +904,7 @@ SlicingAlgorithm::getImplicitFunctionForChunk(const size_t *const chunkMin, * @returns the unique pointer */ Mantid::Geometry::MDFrame_uptr SlicingAlgorithm::createMDFrameForNonAxisAligned( - std::string units, Mantid::Kernel::VMD basisVector) const { + const std::string &units, const Mantid::Kernel::VMD &basisVector) const { // Get set of basis vectors auto oldBasis = getOldBasis(m_inWS->getNumDims()); @@ -911,7 +912,8 @@ Mantid::Geometry::MDFrame_uptr SlicingAlgorithm::createMDFrameForNonAxisAligned( auto indicesWithProjection = getIndicesWithProjection(basisVector, oldBasis); // Extract MDFrame - return extractMDFrameForNonAxisAligned(indicesWithProjection, units); + return extractMDFrameForNonAxisAligned(indicesWithProjection, + std::move(units)); } std::vector<Mantid::Kernel::VMD> @@ -964,7 +966,7 @@ std::vector<size_t> SlicingAlgorithm::getIndicesWithProjection( */ Mantid::Geometry::MDFrame_uptr SlicingAlgorithm::extractMDFrameForNonAxisAligned( - std::vector<size_t> indicesWithProjection, std::string units) const { + std::vector<size_t> indicesWithProjection, const std::string &units) const { if (indicesWithProjection.empty()) { g_log.warning() << "Slicing Algorithm: Chosen vector does not " "project on any vector of the old basis."; diff --git a/Framework/MDAlgorithms/src/SmoothMD.cpp b/Framework/MDAlgorithms/src/SmoothMD.cpp index 30b8e145c1681b2fb685852ec2522a0015605fbb..e7409a0de4cf588389c63592844925a61dd64c4f 100644 --- a/Framework/MDAlgorithms/src/SmoothMD.cpp +++ b/Framework/MDAlgorithms/src/SmoothMD.cpp @@ -175,7 +175,7 @@ const std::string SmoothMD::summary() const { * @return Smoothed MDHistoWorkspace */ IMDHistoWorkspace_sptr -SmoothMD::hatSmooth(IMDHistoWorkspace_const_sptr toSmooth, +SmoothMD::hatSmooth(const IMDHistoWorkspace_const_sptr &toSmooth, const WidthVector &widthVector, OptionalIMDHistoWorkspace_const_sptr weightingWS) { @@ -278,7 +278,7 @@ SmoothMD::hatSmooth(IMDHistoWorkspace_const_sptr toSmooth, * @return Smoothed MDHistoWorkspace */ IMDHistoWorkspace_sptr -SmoothMD::gaussianSmooth(IMDHistoWorkspace_const_sptr toSmooth, +SmoothMD::gaussianSmooth(const IMDHistoWorkspace_const_sptr &toSmooth, const WidthVector &widthVector, OptionalIMDHistoWorkspace_const_sptr weightingWS) { diff --git a/Framework/MDAlgorithms/test/BinMDTest.h b/Framework/MDAlgorithms/test/BinMDTest.h index d795e966a524dbabf6d5ecc05d14c5cdf7dc008b..4cf15306a9217b3ca62227049d7d9ab7372cfb5a 100644 --- a/Framework/MDAlgorithms/test/BinMDTest.h +++ b/Framework/MDAlgorithms/test/BinMDTest.h @@ -26,6 +26,7 @@ #include "MantidTestHelpers/MDEventsTestHelper.h" #include <cmath> +#include <utility> #include <cxxtest/TestSuite.h> @@ -132,8 +133,9 @@ public: AnalysisDataService::Instance().addOrReplace("BinMDTest_ws", in_ws); execute_bin(functionXML, name1, name2, name3, name4, expected_signal, - expected_numBins, IterateEvents, numEventsPerBox, expectBasisX, - expectBasisY, expectBasisZ, in_ws); + expected_numBins, IterateEvents, numEventsPerBox, + std::move(expectBasisX), std::move(expectBasisY), + std::move(expectBasisZ), in_ws); } MDHistoWorkspace_sptr @@ -142,7 +144,7 @@ public: const std::string &name4, const double expected_signal, const size_t expected_numBins, bool IterateEvents, size_t numEventsPerBox, VMD expectBasisX, VMD expectBasisY, - VMD expectBasisZ, IMDEventWorkspace_sptr in_ws) { + VMD expectBasisZ, const IMDEventWorkspace_sptr &in_ws) { BinMD alg; TS_ASSERT_THROWS_NOTHING(alg.initialize()) TS_ASSERT(alg.isInitialized()) @@ -584,9 +586,9 @@ public: * @param origWS :: both should have this as its originalWorkspace * @return binned2 shared pointer */ - MDHistoWorkspace_sptr do_compare_histo(std::string binned1Name, - std::string binned2Name, - std::string origWS) { + MDHistoWorkspace_sptr do_compare_histo(const std::string &binned1Name, + const std::string &binned2Name, + const std::string &origWS) { MDHistoWorkspace_sptr binned1 = AnalysisDataService::Instance().retrieveWS<MDHistoWorkspace>( binned1Name); @@ -1078,7 +1080,7 @@ public: return outWSName; } - std::string saveWorkspace(IMDEventWorkspace_sptr in_ws) { + std::string saveWorkspace(const IMDEventWorkspace_sptr &in_ws) { SaveMD2 saver; saver.setChild(true); saver.setRethrows(true); @@ -1128,7 +1130,7 @@ public: AnalysisDataService::Instance().remove("BinMDTest_ws"); } - void do_test(std::string binParams, bool IterateEvents) { + void do_test(const std::string &binParams, bool IterateEvents) { BinMD alg; TS_ASSERT_THROWS_NOTHING(alg.initialize()) TS_ASSERT(alg.isInitialized()) diff --git a/Framework/MDAlgorithms/test/BinaryOperationMDTest.h b/Framework/MDAlgorithms/test/BinaryOperationMDTest.h index d0a832cc4aca55694d924f85ec0028dc47ce667d..8b21a38ab82953901622057481deb8bec75cd720 100644 --- a/Framework/MDAlgorithms/test/BinaryOperationMDTest.h +++ b/Framework/MDAlgorithms/test/BinaryOperationMDTest.h @@ -95,8 +95,9 @@ public: } /// Run the mock algorithm - void doTest(MockBinaryOperationMD &alg, std::string lhs, std::string rhs, - std::string outName, bool succeeds = true) { + void doTest(MockBinaryOperationMD &alg, const std::string &lhs, + const std::string &rhs, const std::string &outName, + bool succeeds = true) { out.reset(); TS_ASSERT_THROWS_NOTHING(alg.initialize()) TS_ASSERT(alg.isInitialized()) diff --git a/Framework/MDAlgorithms/test/BoxControllerSettingsAlgorithmTest.h b/Framework/MDAlgorithms/test/BoxControllerSettingsAlgorithmTest.h index 65e5c12ddc73bf052ee09fda4a9b1d9b6d904257..135c89af5537ffb88f9ff5121a82123670c944f1 100644 --- a/Framework/MDAlgorithms/test/BoxControllerSettingsAlgorithmTest.h +++ b/Framework/MDAlgorithms/test/BoxControllerSettingsAlgorithmTest.h @@ -14,6 +14,7 @@ #include "MantidTestHelpers/WorkspaceCreationHelper.h" #include <boost/format.hpp> +#include <utility> #include <cxxtest/TestSuite.h> @@ -47,8 +48,9 @@ private: Helper function. Runs LoadParameterAlg, to get an instrument parameter definition from a file onto a workspace. */ - void apply_instrument_parameter_file_to_workspace(MatrixWorkspace_sptr ws, - const ScopedFile &file) { + void + apply_instrument_parameter_file_to_workspace(const MatrixWorkspace_sptr &ws, + const ScopedFile &file) { // Load the Instrument Parameter file over the existing test workspace + // instrument. using DataHandling::LoadParameterFile; @@ -119,9 +121,9 @@ public: TS_ASSERT_EQUALS(bc->getMaxDepth(), 34); } - void doTest(BoxController_sptr bc, std::string SplitInto = "", - std::string SplitThreshold = "", - std::string MaxRecursionDepth = "") { + void doTest(const BoxController_sptr &bc, const std::string &SplitInto = "", + const std::string &SplitThreshold = "", + const std::string &MaxRecursionDepth = "") { BoxControllerSettingsAlgorithmImpl alg; alg.initBoxControllerProps(); if (!SplitInto.empty()) @@ -130,7 +132,7 @@ public: alg.setPropertyValue("SplitThreshold", SplitThreshold); if (!MaxRecursionDepth.empty()) alg.setPropertyValue("MaxRecursionDepth", MaxRecursionDepth); - alg.setBoxController(bc); + alg.setBoxController(std::move(bc)); } void test_SplitInto() { diff --git a/Framework/MDAlgorithms/test/CentroidPeaksMD2Test.h b/Framework/MDAlgorithms/test/CentroidPeaksMD2Test.h index f669d3671db91fbb193f43ffce77407efc23fd83..843b77ece157848917fbf4f6cc3311c216b3cd31 100644 --- a/Framework/MDAlgorithms/test/CentroidPeaksMD2Test.h +++ b/Framework/MDAlgorithms/test/CentroidPeaksMD2Test.h @@ -43,7 +43,7 @@ public: //------------------------------------------------------------------------------- /** Create the (blank) MDEW */ - static void createMDEW(std::string CoordinatesToUse) { + static void createMDEW(const std::string &CoordinatesToUse) { // ---- Start with empty MDEW ---- std::string frames; if (CoordinatesToUse == "Q (lab frame)") { @@ -98,9 +98,10 @@ public: //------------------------------------------------------------------------------- /** Run the CentroidPeaksMD2 with the given peak radius param */ - void doRun(V3D startPos, double PeakRadius, double binCount, - V3D expectedResult, std::string message, - std::string OutputWorkspace = "CentroidPeaksMD2Test_Peaks") { + void + doRun(V3D startPos, double PeakRadius, double binCount, V3D expectedResult, + const std::string &message, + const std::string &OutputWorkspace = "CentroidPeaksMD2Test_Peaks") { // Make a fake instrument - doesn't matter, we won't use it really Instrument_sptr inst = ComponentCreationHelper::createTestInstrumentCylindrical(5); diff --git a/Framework/MDAlgorithms/test/CentroidPeaksMDTest.h b/Framework/MDAlgorithms/test/CentroidPeaksMDTest.h index 2791e5e7351c0bd894c49e9756b7bec8116421a4..2694382ce73feeee3cbd088e3240e8bc265bcce9 100644 --- a/Framework/MDAlgorithms/test/CentroidPeaksMDTest.h +++ b/Framework/MDAlgorithms/test/CentroidPeaksMDTest.h @@ -43,7 +43,7 @@ public: //------------------------------------------------------------------------------- /** Create the (blank) MDEW */ - static void createMDEW(std::string CoordinatesToUse) { + static void createMDEW(const std::string &CoordinatesToUse) { // ---- Start with empty MDEW ---- std::string frames; if (CoordinatesToUse == "Q (lab frame)") { @@ -100,8 +100,8 @@ public: //------------------------------------------------------------------------------- /** Run the CentroidPeaksMD with the given peak radius param */ void doRun(V3D startPos, double PeakRadius, V3D expectedResult, - std::string message, - std::string OutputWorkspace = "CentroidPeaksMDTest_Peaks") { + const std::string &message, + const std::string &OutputWorkspace = "CentroidPeaksMDTest_Peaks") { // Make a fake instrument - doesn't matter, we won't use it really Instrument_sptr inst = ComponentCreationHelper::createTestInstrumentCylindrical(5); diff --git a/Framework/MDAlgorithms/test/CloneMDWorkspaceTest.h b/Framework/MDAlgorithms/test/CloneMDWorkspaceTest.h index 5fc2b64ec2cd48cecbaac889fc346dd490348fbe..3c5cc4d73d683ea7794f9e9e6eb3e4f94f329fcb 100644 --- a/Framework/MDAlgorithms/test/CloneMDWorkspaceTest.h +++ b/Framework/MDAlgorithms/test/CloneMDWorkspaceTest.h @@ -45,7 +45,7 @@ public: do_test(true, "CloneMDWorkspaceTest_ws_custom_cloned_name2.nxs", true); } - void do_test(bool fileBacked, std::string Filename = "", + void do_test(bool fileBacked, const std::string &Filename = "", bool file_needs_updating = false) { // Name of the output workspace. std::string outWSName("CloneMDWorkspaceTest_OutputWS"); @@ -117,7 +117,7 @@ public: } /** Clone a workspace and check that the clone matches */ - void do_test_MDHisto(MDHistoWorkspace_sptr ws1) { + void do_test_MDHisto(const MDHistoWorkspace_sptr &ws1) { // Name of the output workspace. std::string outWSName("CloneMDWorkspaceTest_OutputWS"); // Add the input workspace diff --git a/Framework/MDAlgorithms/test/CompareMDWorkspacesTest.h b/Framework/MDAlgorithms/test/CompareMDWorkspacesTest.h index 09d48d0b74d6ed0529b6aa2e647694ca564f9e5b..a876e49842b42e483de1b14a84c2b78f83bcdb2a 100644 --- a/Framework/MDAlgorithms/test/CompareMDWorkspacesTest.h +++ b/Framework/MDAlgorithms/test/CompareMDWorkspacesTest.h @@ -31,9 +31,9 @@ public: TS_ASSERT(alg.isInitialized()) } - void doTest(std::string ws1, std::string ws2, - std::string resultExpected = "Success!", bool CheckEvents = true, - bool IgnoreDifferentID = false) { + void doTest(const std::string &ws1, const std::string &ws2, + const std::string &resultExpected = "Success!", + bool CheckEvents = true, bool IgnoreDifferentID = false) { CompareMDWorkspaces alg; TS_ASSERT_THROWS_NOTHING(alg.initialize()) diff --git a/Framework/MDAlgorithms/test/ConvertToMDComponentsTest.h b/Framework/MDAlgorithms/test/ConvertToMDComponentsTest.h index 89cb7617a90efbb58e7ee19a3871ff5ec60aaeb1..e6bb76af1e6cea369664ecaa0448f070970afa35 100644 --- a/Framework/MDAlgorithms/test/ConvertToMDComponentsTest.h +++ b/Framework/MDAlgorithms/test/ConvertToMDComponentsTest.h @@ -18,6 +18,8 @@ #include <cxxtest/TestSuite.h> +#include <utility> + using namespace Mantid; using namespace Mantid::Kernel; using namespace Mantid::API; @@ -26,23 +28,22 @@ using namespace Mantid::MDAlgorithms; class Convert2MDComponentsTestHelper : public ConvertToMD { public: - TableWorkspace_const_sptr - preprocessDetectorsPositions(Mantid::API::MatrixWorkspace_const_sptr InWS2D, - const std::string dEModeRequested = "Direct", - bool updateMasks = true) { + TableWorkspace_const_sptr preprocessDetectorsPositions( + const Mantid::API::MatrixWorkspace_const_sptr &InWS2D, + const std::string &dEModeRequested = "Direct", bool updateMasks = true) { std::string OutWSName(this->getProperty("PreprocDetectorsWS")); return ConvertToMD::preprocessDetectorsPositions(InWS2D, dEModeRequested, updateMasks, OutWSName); } void setSourceWS(Mantid::API::MatrixWorkspace_sptr InWS2D) { - this->m_InWS2D = InWS2D; + this->m_InWS2D = std::move(InWS2D); // and create the class, which will deal with the target workspace if (!this->m_OutWSWrapper) this->m_OutWSWrapper = boost::shared_ptr<MDAlgorithms::MDEventWSWrapper>( new MDAlgorithms::MDEventWSWrapper()); } Convert2MDComponentsTestHelper() { ConvertToMD::initialize(); } - bool buildTargetWSDescription(API::IMDEventWorkspace_sptr spws, + bool buildTargetWSDescription(const API::IMDEventWorkspace_sptr &spws, const std::string &Q_mod_req, const std::string &dEModeRequested, const std::vector<std::string> &other_dim_names, @@ -52,8 +53,8 @@ public: std::vector<double> dimMin = this->getProperty("MinValues"); std::vector<double> dimMax = this->getProperty("MaxValues"); return ConvertToMD::buildTargetWSDescription( - spws, Q_mod_req, dEModeRequested, other_dim_names, dimMin, dimMax, - QFrame, convert_to_, targWSDescr); + std::move(spws), Q_mod_req, dEModeRequested, other_dim_names, dimMin, + dimMax, QFrame, convert_to_, targWSDescr); } void copyMetaData(API::IMDEventWorkspace_sptr mdEventWS) const { ConvertToMD::copyMetaData(mdEventWS); diff --git a/Framework/MDAlgorithms/test/ConvertToMDTest.h b/Framework/MDAlgorithms/test/ConvertToMDTest.h index 9847608765c4e45c6b042037d5f8cda30acb7291..014f131a4cc5fd6fa54546a819dc1804491de1d8 100644 --- a/Framework/MDAlgorithms/test/ConvertToMDTest.h +++ b/Framework/MDAlgorithms/test/ConvertToMDTest.h @@ -19,6 +19,8 @@ #include <Poco/File.h> #include <cxxtest/TestSuite.h> +#include <utility> + using namespace Mantid; using namespace Mantid::Kernel; using namespace Mantid::API; @@ -57,16 +59,15 @@ Mantid::API::MatrixWorkspace_sptr createTestWorkspaces() { class Convert2AnyTestHelper : public ConvertToMD { public: Convert2AnyTestHelper(){}; - TableWorkspace_const_sptr - preprocessDetectorsPositions(Mantid::API::MatrixWorkspace_const_sptr InWS2D, - const std::string dEModeRequested = "Direct", - bool updateMasks = false) { + TableWorkspace_const_sptr preprocessDetectorsPositions( + const Mantid::API::MatrixWorkspace_const_sptr &InWS2D, + const std::string &dEModeRequested = "Direct", bool updateMasks = false) { return ConvertToMD::preprocessDetectorsPositions( InWS2D, dEModeRequested, updateMasks, std::string(this->getProperty("PreprocDetectorsWS"))); } void setSourceWS(Mantid::API::MatrixWorkspace_sptr InWS2D) { - m_InWS2D = InWS2D; + m_InWS2D = std::move(InWS2D); } }; // helper function to provide list of names to test: diff --git a/Framework/MDAlgorithms/test/ConvertToQ3DdETest.h b/Framework/MDAlgorithms/test/ConvertToQ3DdETest.h index 9bbadd84470a48f56c6121b82b7f402d82799a58..2446c16225689947d1bcd4bea14850c8af458ca2 100644 --- a/Framework/MDAlgorithms/test/ConvertToQ3DdETest.h +++ b/Framework/MDAlgorithms/test/ConvertToQ3DdETest.h @@ -59,7 +59,7 @@ public: /** Calculate min-max value defaults*/ Mantid::API::IAlgorithm * calcMinMaxValDefaults(const std::string &QMode, const std::string &QFrame, - std::string OtherProperties = std::string("")) { + const std::string &OtherProperties = std::string("")) { Mantid::API::IAlgorithm *childAlg = Mantid::API::FrameworkManager::Instance().createAlgorithm( diff --git a/Framework/MDAlgorithms/test/ConvertToReflectometryQTest.h b/Framework/MDAlgorithms/test/ConvertToReflectometryQTest.h index f704953755f7320e3632f9a0af24344b751d72e1..04378718a13a55837fa7b67064f222fe91814970 100644 --- a/Framework/MDAlgorithms/test/ConvertToReflectometryQTest.h +++ b/Framework/MDAlgorithms/test/ConvertToReflectometryQTest.h @@ -42,7 +42,7 @@ private: Makes the tests much more readable like this. */ boost::shared_ptr<ConvertToReflectometryQ> - make_standard_algorithm(const std::string outputdimensions = "Q (lab frame)", + make_standard_algorithm(const std::string &outputdimensions = "Q (lab frame)", bool outputAsMD = true) { MatrixWorkspace_sptr in_ws = WorkspaceCreationHelper::create2DWorkspaceWithFullInstrument(10, 10); diff --git a/Framework/MDAlgorithms/test/CreateMDWorkspaceTest.h b/Framework/MDAlgorithms/test/CreateMDWorkspaceTest.h index 11af60f6a5efc48a48b2c113cbbf387fff0f7311..64d9c0c8d866ee3370ffc165cfa80b60b847b930 100644 --- a/Framework/MDAlgorithms/test/CreateMDWorkspaceTest.h +++ b/Framework/MDAlgorithms/test/CreateMDWorkspaceTest.h @@ -91,8 +91,9 @@ public: ->isExecuted()); } - void do_test_exec(std::string Filename, bool lean, int MinRecursionDepth = 0, - int expectedNumMDBoxes = 216, bool withFrames = false) { + void do_test_exec(const std::string &Filename, bool lean, + int MinRecursionDepth = 0, int expectedNumMDBoxes = 216, + bool withFrames = false) { std::string wsName = "CreateMDWorkspaceTest_out"; CreateMDWorkspace alg; diff --git a/Framework/MDAlgorithms/test/CutMDTest.h b/Framework/MDAlgorithms/test/CutMDTest.h index 54c878295c63d97509206471b1255b9ad2ff4c75..cc8cef0d150d7acde449114000a7052bb11cfd8f 100644 --- a/Framework/MDAlgorithms/test/CutMDTest.h +++ b/Framework/MDAlgorithms/test/CutMDTest.h @@ -42,7 +42,7 @@ class CutMDTest : public CxxTest::TestSuite { private: IMDWorkspace_sptr m_inWS; - void addNormalization(std::string wsName) { + void addNormalization(const std::string &wsName) { auto ws = AnalysisDataService::Instance().retrieveWS<IMDWorkspace>(wsName); auto eventWS = boost::dynamic_pointer_cast<IMDEventWorkspace>(ws); auto histoWS = boost::dynamic_pointer_cast<IMDHistoWorkspace>(ws); diff --git a/Framework/MDAlgorithms/test/DivideMDTest.h b/Framework/MDAlgorithms/test/DivideMDTest.h index eb32ec58885242fe4b23c6e416d0676d3d7ab0be..cb039a85f717c58cde13784949f654aed8226d31 100644 --- a/Framework/MDAlgorithms/test/DivideMDTest.h +++ b/Framework/MDAlgorithms/test/DivideMDTest.h @@ -62,7 +62,7 @@ public: /** Get a MDEventWorkspace and check that all events have the given * signal/error */ - void checkMDEWSignal(std::string wsName, signal_t expectedSignal, + void checkMDEWSignal(const std::string &wsName, signal_t expectedSignal, signal_t expectedError) { IMDEventWorkspace_sptr ws = AnalysisDataService::Instance().retrieveWS<IMDEventWorkspace>(wsName); diff --git a/Framework/MDAlgorithms/test/FlippingRatioCorrectionMDTest.h b/Framework/MDAlgorithms/test/FlippingRatioCorrectionMDTest.h index 1d2cc0a197b16126ae555de8f2fbf15627814e76..1020c1488915f77da0f5a7157397b99aecc1b776 100644 --- a/Framework/MDAlgorithms/test/FlippingRatioCorrectionMDTest.h +++ b/Framework/MDAlgorithms/test/FlippingRatioCorrectionMDTest.h @@ -85,7 +85,7 @@ public: } private: - void checkFRCorrection(std::string wsName, double expectedValuePeak1, + void checkFRCorrection(const std::string &wsName, double expectedValuePeak1, double expectedValuePeak2) { Mantid::MDAlgorithms::BinMD algBin; TS_ASSERT_THROWS_NOTHING(algBin.initialize()) diff --git a/Framework/MDAlgorithms/test/ImportMDEventWorkspaceTest.h b/Framework/MDAlgorithms/test/ImportMDEventWorkspaceTest.h index 84212d4c10267c7b0cf073f00225acf71c3f0b07..92dc688f9a2144a62b6416d7afbc39ae48d3efba 100644 --- a/Framework/MDAlgorithms/test/ImportMDEventWorkspaceTest.h +++ b/Framework/MDAlgorithms/test/ImportMDEventWorkspaceTest.h @@ -72,7 +72,7 @@ public: /// Create a simple input file. MDFileObject( const FileContentsBuilder &builder = FileContentsBuilder(), - std::string filename = "test_import_md_event_workspace_file.txt") { + const std::string &filename = "test_import_md_event_workspace_file.txt") { Poco::Path path( Mantid::Kernel::ConfigService::Instance().getTempDir().c_str()); path.append(filename); diff --git a/Framework/MDAlgorithms/test/IntegrateMDHistoWorkspaceTest.h b/Framework/MDAlgorithms/test/IntegrateMDHistoWorkspaceTest.h index 50c8c3d8f3b6c55817648c1c13e19edb2e87b3d9..0636526f31d700097cfc030ad41055b42f6dcf4b 100644 --- a/Framework/MDAlgorithms/test/IntegrateMDHistoWorkspaceTest.h +++ b/Framework/MDAlgorithms/test/IntegrateMDHistoWorkspaceTest.h @@ -18,7 +18,7 @@ namespace { // This helper sets the signal values to the linear index to have some // variety -void resetSignalsToLinearIndexValue(IMDHistoWorkspace_sptr ws) { +void resetSignalsToLinearIndexValue(const IMDHistoWorkspace_sptr &ws) { auto numberOfIndices = static_cast<size_t>(ws->getNPoints()); for (size_t i = 0; i < numberOfIndices; ++i) { auto &signal = ws->signalAt(i); diff --git a/Framework/MDAlgorithms/test/IntegratePeaksMD2Test.h b/Framework/MDAlgorithms/test/IntegratePeaksMD2Test.h index 3ef787860f1604407c3d4c7e6a24ae4709836dbb..790cb2067be1afe6e1192e68857436b8f2aacb92 100644 --- a/Framework/MDAlgorithms/test/IntegratePeaksMD2Test.h +++ b/Framework/MDAlgorithms/test/IntegratePeaksMD2Test.h @@ -51,11 +51,11 @@ public: //------------------------------------------------------------------------------- /** Run the IntegratePeaksMD2 with the given peak radius integration param */ - static void doRun(double PeakRadius, double BackgroundRadius, - std::string OutputWorkspace = "IntegratePeaksMD2Test_peaks", - double BackgroundStartRadius = 0.0, bool edge = true, - bool cyl = false, std::string fnct = "NoFit", - double adaptive = 0.0) { + static void + doRun(double PeakRadius, double BackgroundRadius, + const std::string &OutputWorkspace = "IntegratePeaksMD2Test_peaks", + double BackgroundStartRadius = 0.0, bool edge = true, bool cyl = false, + const std::string &fnct = "NoFit", double adaptive = 0.0) { IntegratePeaksMD2 alg; TS_ASSERT_THROWS_NOTHING(alg.initialize()) TS_ASSERT(alg.isInitialized()) diff --git a/Framework/MDAlgorithms/test/IntegratePeaksMDHKLTest.h b/Framework/MDAlgorithms/test/IntegratePeaksMDHKLTest.h index 43630aa372dd536bc01dbc53a0ba040581237662..23327899699fd2364dd4cdb0086a1105d1abea83 100644 --- a/Framework/MDAlgorithms/test/IntegratePeaksMDHKLTest.h +++ b/Framework/MDAlgorithms/test/IntegratePeaksMDHKLTest.h @@ -55,7 +55,7 @@ public: /** Run the IntegratePeaksMDHKL with the given peak radius integration param */ static void - doRun(std::string OutputWorkspace = "IntegratePeaksMDHKLTest_peaks") { + doRun(const std::string &OutputWorkspace = "IntegratePeaksMDHKLTest_peaks") { IntegratePeaksMDHKL alg; TS_ASSERT_THROWS_NOTHING(alg.initialize()) TS_ASSERT(alg.isInitialized()) diff --git a/Framework/MDAlgorithms/test/IntegratePeaksMDTest.h b/Framework/MDAlgorithms/test/IntegratePeaksMDTest.h index 857f85c65a2c76fdc3ec80a7b7bf1d1626d752f2..167d9e8ab1e52d5bbf14ed881b38b980bcac2684 100644 --- a/Framework/MDAlgorithms/test/IntegratePeaksMDTest.h +++ b/Framework/MDAlgorithms/test/IntegratePeaksMDTest.h @@ -48,10 +48,11 @@ public: //------------------------------------------------------------------------------- /** Run the IntegratePeaksMD with the given peak radius integration param */ - static void doRun(double PeakRadius, double BackgroundRadius, - std::string OutputWorkspace = "IntegratePeaksMDTest_peaks", - double BackgroundStartRadius = 0.0, bool edge = true, - bool cyl = false, std::string fnct = "NoFit") { + static void + doRun(double PeakRadius, double BackgroundRadius, + const std::string &OutputWorkspace = "IntegratePeaksMDTest_peaks", + double BackgroundStartRadius = 0.0, bool edge = true, bool cyl = false, + const std::string &fnct = "NoFit") { IntegratePeaksMD alg; TS_ASSERT_THROWS_NOTHING(alg.initialize()) TS_ASSERT(alg.isInitialized()) diff --git a/Framework/MDAlgorithms/test/LoadMDTest.h b/Framework/MDAlgorithms/test/LoadMDTest.h index bab2255eb4062e79ff4bcaf369294c1116e366a0..6a83c2b735fdc330faf1f1b3a1eaa6bf0aa6bdad 100644 --- a/Framework/MDAlgorithms/test/LoadMDTest.h +++ b/Framework/MDAlgorithms/test/LoadMDTest.h @@ -488,7 +488,7 @@ public: } /** Run SaveMD v1 with the MDHistoWorkspace */ - void doTestHistoV1(MDHistoWorkspace_sptr ws) { + void doTestHistoV1(const MDHistoWorkspace_sptr &ws) { std::string filename = "SaveMDTestHisto.nxs"; SaveMD alg1; @@ -531,7 +531,7 @@ public: } /** Run SaveMD2 with the MDHistoWorkspace */ - void doTestHisto(MDHistoWorkspace_sptr ws) { + void doTestHisto(const MDHistoWorkspace_sptr &ws) { std::string filename = "SaveMD2TestHisto.nxs"; SaveMD2 alg1; @@ -682,7 +682,7 @@ public: } Mantid::API::IMDWorkspace_sptr - testSaveAndLoadWorkspace(Mantid::API::IMDWorkspace_sptr inputWS, + testSaveAndLoadWorkspace(const Mantid::API::IMDWorkspace_sptr &inputWS, const char *rootGroup, const bool rmCoordField = false) { const std::string fileName = "SaveMDSpecialCoordinatesTest.nxs"; diff --git a/Framework/MDAlgorithms/test/LoadSQW2Test.h b/Framework/MDAlgorithms/test/LoadSQW2Test.h index ad577885c83c517e916ddf56ade7675d05eb06e8..afb097b986c74a527569f6878d67610ed303d1bd 100644 --- a/Framework/MDAlgorithms/test/LoadSQW2Test.h +++ b/Framework/MDAlgorithms/test/LoadSQW2Test.h @@ -20,6 +20,7 @@ #include <Poco/TemporaryFile.h> #include <array> +#include <utility> using Mantid::API::ExperimentInfo; using Mantid::API::IAlgorithm; @@ -159,7 +160,8 @@ private: SizeTList nbins; }; - IMDEventWorkspace_sptr runAlgorithm(std::string filename, Arguments args) { + IMDEventWorkspace_sptr runAlgorithm(const std::string &filename, + const Arguments &args) { auto algm = createAlgorithm(); algm->setProperty("Filename", filename); algm->setProperty("MetadataOnly", args.metadataOnly); @@ -180,9 +182,9 @@ private: } void checkGeometryAsExpected(const IMDEventWorkspace &outputWS, - std::string outputFrame, DataType dtype) { + const std::string &outputFrame, DataType dtype) { TS_ASSERT_EQUALS(4, outputWS.getNumDims()); - auto expectedDim = getExpectedDimProperties(outputFrame, dtype); + auto expectedDim = getExpectedDimProperties(std::move(outputFrame), dtype); for (size_t i = 0; i < 4; ++i) { auto dim = outputWS.getDimension(i); TS_ASSERT_EQUALS(expectedDim.ids[i], dim->getDimensionId()); @@ -196,7 +198,7 @@ private: } GNU_DIAG_OFF("missing-braces") - DimensionProperties getExpectedDimProperties(std::string outputFrame, + DimensionProperties getExpectedDimProperties(const std::string &outputFrame, DataType dtype) { DimensionProperties expected; expected.ids = {"qx", "qy", "qz", "en"}; @@ -297,8 +299,8 @@ private: TS_ASSERT_DELTA(0.0, vVec[2], 1e-04); } - void checkDataAsExpected(const IMDEventWorkspace &outputWS, Arguments args, - DataType dtype) { + void checkDataAsExpected(const IMDEventWorkspace &outputWS, + const Arguments &args, DataType dtype) { if (args.metadataOnly) { TS_ASSERT_EQUALS(0, outputWS.getNEvents()); } else { @@ -353,7 +355,7 @@ private: } void checkOutputFile(const IMDEventWorkspace &outputWS, - std::string outputFilename) { + const std::string &outputFilename) { TS_ASSERT(outputWS.isFileBacked()); Poco::File fileback(outputFilename); TS_ASSERT(fileback.getSize() > 0); diff --git a/Framework/MDAlgorithms/test/MergeMDFilesTest.h b/Framework/MDAlgorithms/test/MergeMDFilesTest.h index 923f4a41b88a1dc8eca58205daeda57eda8bc378..64db29a303658a6edb77c21c21ab61cc01746287 100644 --- a/Framework/MDAlgorithms/test/MergeMDFilesTest.h +++ b/Framework/MDAlgorithms/test/MergeMDFilesTest.h @@ -32,7 +32,7 @@ public: void test_exec_fileBacked() { do_test_exec("MergeMDFilesTest_OutputWS.nxs"); } - void do_test_exec(std::string OutputFilename) { + void do_test_exec(const std::string &OutputFilename) { if (OutputFilename != "") { if (Poco::File(OutputFilename).exists()) Poco::File(OutputFilename).remove(); diff --git a/Framework/MDAlgorithms/test/MultiplyMDTest.h b/Framework/MDAlgorithms/test/MultiplyMDTest.h index d50d56c8f148fe948a2631a0f61bab9b33f42938..a59854b4203c1f9f68f2cb7bea89993fdbb24efc 100644 --- a/Framework/MDAlgorithms/test/MultiplyMDTest.h +++ b/Framework/MDAlgorithms/test/MultiplyMDTest.h @@ -61,7 +61,7 @@ public: /** Get a MDEventWorkspace and check that all events have the given * signal/error */ - void checkMDEWSignal(std::string wsName, signal_t expectedSignal, + void checkMDEWSignal(const std::string &wsName, signal_t expectedSignal, signal_t expectedError) { IMDEventWorkspace_sptr ws = AnalysisDataService::Instance().retrieveWS<IMDEventWorkspace>(wsName); diff --git a/Framework/MDAlgorithms/test/QueryMDWorkspaceTest.h b/Framework/MDAlgorithms/test/QueryMDWorkspaceTest.h index ace0a40c7348c57e57d925568481cddadaa99b05..d012668da65384e12ea5ff3046745affc56c6e32 100644 --- a/Framework/MDAlgorithms/test/QueryMDWorkspaceTest.h +++ b/Framework/MDAlgorithms/test/QueryMDWorkspaceTest.h @@ -30,7 +30,7 @@ public: QueryMDWorkspaceTest() { FrameworkManager::Instance(); } - void checkInputs(std::string strNormalisation) { + void checkInputs(const std::string &strNormalisation) { MDEventWorkspace3Lean::sptr in_ws = MDEventsTestHelper::makeMDEW<3>(10, -10.0, 20.0, 3); QueryMDWorkspace query; diff --git a/Framework/MDAlgorithms/test/RecalculateTrajectoriesExtentsTest.h b/Framework/MDAlgorithms/test/RecalculateTrajectoriesExtentsTest.h index e7683d13ce7c8857d25b5b81e7e6f0815f54ad72..c96e482de6a64379a0aab79068051952970e7de8 100644 --- a/Framework/MDAlgorithms/test/RecalculateTrajectoriesExtentsTest.h +++ b/Framework/MDAlgorithms/test/RecalculateTrajectoriesExtentsTest.h @@ -34,8 +34,8 @@ public: delete suite; } - IMDEventWorkspace_sptr create_workspace(std::vector<double> extents, - std::string name) { + IMDEventWorkspace_sptr create_workspace(const std::vector<double> &extents, + const std::string &name) { // ---- empty MDEW ---- TS_ASSERT_EQUALS(extents.size(), 6) CreateMDWorkspace algC; @@ -76,7 +76,7 @@ public: TS_ASSERT(alg.isInitialized()) } - void do_test(std::string name, std::vector<double> extents) { + void do_test(const std::string &name, std::vector<double> extents) { IMDEventWorkspace_sptr inputWS = create_workspace(extents, name); RecalculateTrajectoriesExtents alg; diff --git a/Framework/MDAlgorithms/test/SaveMD2Test.h b/Framework/MDAlgorithms/test/SaveMD2Test.h index fcc675a7a4fd68a779902a229f8c853d7f5a4f1d..1b45b7e34141bff3bc7bd23bb58c0bb77bd4d031 100644 --- a/Framework/MDAlgorithms/test/SaveMD2Test.h +++ b/Framework/MDAlgorithms/test/SaveMD2Test.h @@ -46,7 +46,7 @@ public: do_test_exec(23, "SaveMD2Test_updating.nxs", true, true); } - void do_test_exec(size_t numPerBox, std::string filename, + void do_test_exec(size_t numPerBox, const std::string &filename, bool MakeFileBacked = false, bool UpdateFileBackEnd = false) { @@ -103,8 +103,8 @@ public: } /// Add some data and update the back-end - void do_test_UpdateFileBackEnd(MDEventWorkspace1Lean::sptr ws, - std::string filename) { + void do_test_UpdateFileBackEnd(const MDEventWorkspace1Lean::sptr &ws, + const std::string &filename) { size_t initial_numEvents = ws->getNPoints(); TSM_ASSERT_EQUALS("Starting off with 230 events.", initial_numEvents, 230); @@ -335,7 +335,7 @@ public: } /** Run SaveMD with the MDHistoWorkspace */ - void doTestHisto(MDHistoWorkspace_sptr ws) { + void doTestHisto(const MDHistoWorkspace_sptr &ws) { std::string filename = "SaveMD2TestHisto.nxs"; SaveMD2 alg; diff --git a/Framework/MDAlgorithms/test/SaveMDTest.h b/Framework/MDAlgorithms/test/SaveMDTest.h index 81e927489b55727f5c1e3ff4cfe2ee901b65aa7b..aa73db31c62c87c008e6588d3b3053cf0842cfd9 100644 --- a/Framework/MDAlgorithms/test/SaveMDTest.h +++ b/Framework/MDAlgorithms/test/SaveMDTest.h @@ -50,7 +50,7 @@ public: do_test_exec(23, "SaveMDTest_other_file_name_test.nxs", true, false, true); } - void do_test_exec(size_t numPerBox, std::string filename, + void do_test_exec(size_t numPerBox, const std::string &filename, bool MakeFileBacked = false, bool UpdateFileBackEnd = false, bool OtherFileName = false) { @@ -108,8 +108,8 @@ public: } /// Add some data and update the back-end - void do_test_UpdateFileBackEnd(MDEventWorkspace1Lean::sptr ws, - std::string filename) { + void do_test_UpdateFileBackEnd(const MDEventWorkspace1Lean::sptr &ws, + const std::string &filename) { size_t initial_numEvents = ws->getNPoints(); TSM_ASSERT_EQUALS("Starting off with 230 events.", initial_numEvents, 230); @@ -150,8 +150,8 @@ public: Poco::File(fullPath).remove(); } - void do_test_OtherFileName(MDEventWorkspace1Lean::sptr ws, - std::string originalFileName) { + void do_test_OtherFileName(const MDEventWorkspace1Lean::sptr &ws, + const std::string &originalFileName) { const std::string otherFileName = "SaveMD_other_file_name.nxs"; auto algSave = AlgorithmManager::Instance().createUnmanaged("SaveMD"); @@ -284,7 +284,7 @@ public: } /** Run SaveMD with the MDHistoWorkspace */ - void doTestHisto(MDHistoWorkspace_sptr ws) { + void doTestHisto(const MDHistoWorkspace_sptr &ws) { std::string filename = "SaveMDTestHisto.nxs"; SaveMD alg; diff --git a/Framework/MDAlgorithms/test/SaveZODSTest.h b/Framework/MDAlgorithms/test/SaveZODSTest.h index 6798349998a709c396ee7f6e9308b371b81c1a1c..41eb380be5651b24da845448db6f8183099e9e1b 100644 --- a/Framework/MDAlgorithms/test/SaveZODSTest.h +++ b/Framework/MDAlgorithms/test/SaveZODSTest.h @@ -27,8 +27,8 @@ public: TS_ASSERT(alg.isInitialized()) } - std::string do_test(std::string InputWorkspace, std::string Filename, - bool expectSuccess = true) { + std::string do_test(const std::string &InputWorkspace, + const std::string &Filename, bool expectSuccess = true) { SaveZODS alg; TS_ASSERT_THROWS_NOTHING(alg.initialize()) TS_ASSERT(alg.isInitialized()) diff --git a/Framework/MDAlgorithms/test/SetMDUsingMaskTest.h b/Framework/MDAlgorithms/test/SetMDUsingMaskTest.h index 8c22e846b14fa4e0406c043d69a54c1b76a07e6b..238ddcdeebdadbc5d3b87c9c9c7c6b4f180546d5 100644 --- a/Framework/MDAlgorithms/test/SetMDUsingMaskTest.h +++ b/Framework/MDAlgorithms/test/SetMDUsingMaskTest.h @@ -26,9 +26,10 @@ public: TS_ASSERT(alg.isInitialized()) } - void do_test(std::string InputWorkspace, std::string MaskWorkspace, - std::string ValueWorkspace, std::string Value, - std::string OutputWorkspace, double expectedSignal, + void do_test(const std::string &InputWorkspace, + const std::string &MaskWorkspace, + const std::string &ValueWorkspace, const std::string &Value, + const std::string &OutputWorkspace, double expectedSignal, double expectedError, bool succeeds = true) { MDHistoWorkspace_sptr histo_A = MDEventsTestHelper::makeFakeMDHistoWorkspace(2.0, 2, 5, 10.0, 2.0); diff --git a/Framework/MDAlgorithms/test/SliceMDTest.h b/Framework/MDAlgorithms/test/SliceMDTest.h index e8a69d52565e8dee377e8bd977821b8cabf6c042..7ad71cd97b5bddfe1eefa70115fb254be7b0c1b2 100644 --- a/Framework/MDAlgorithms/test/SliceMDTest.h +++ b/Framework/MDAlgorithms/test/SliceMDTest.h @@ -144,7 +144,7 @@ public: const uint64_t expectedNumPoints, const size_t expectedNumDims, bool willFail, const std::string &OutputFilename, - IMDEventWorkspace_sptr in_ws) { + const IMDEventWorkspace_sptr &in_ws) { SliceMD alg; TS_ASSERT_THROWS_NOTHING(alg.initialize()) TS_ASSERT(alg.isInitialized()) @@ -210,7 +210,7 @@ public: const std::string &name3, const std::string &name4, const uint64_t expectedNumPoints, const size_t expectedNumDims, bool willFail = false, - std::string OutputFilename = "") { + const std::string &OutputFilename = "") { Mantid::Geometry::QSample frame; IMDEventWorkspace_sptr in_ws = diff --git a/Framework/MDAlgorithms/test/SlicingAlgorithmTest.h b/Framework/MDAlgorithms/test/SlicingAlgorithmTest.h index cd5400279418666e900b3618b00db2a37f4327f1..3ca0c17dbec560367f57a0dcd60d5d4a47ab5ad8 100644 --- a/Framework/MDAlgorithms/test/SlicingAlgorithmTest.h +++ b/Framework/MDAlgorithms/test/SlicingAlgorithmTest.h @@ -594,10 +594,11 @@ public: //---------------------------------------------------------------------------- std::unique_ptr<SlicingAlgorithmImpl> do_createGeneralTransform( - IMDEventWorkspace_sptr inWS, std::string name1, std::string name2, - std::string name3, std::string name4, VMD translation, - std::string extents, std::string numBins, bool ForceOrthogonal = false, - bool NormalizeBasisVectors = true) { + const IMDEventWorkspace_sptr &inWS, const std::string &name1, + const std::string &name2, const std::string &name3, + const std::string &name4, const VMD &translation, + const std::string &extents, const std::string &numBins, + bool ForceOrthogonal = false, bool NormalizeBasisVectors = true) { auto alg = std::make_unique<SlicingAlgorithmImpl>(); alg->m_inWS = inWS; alg->initSlicingProps(); diff --git a/Framework/MDAlgorithms/test/ThresholdMDTest.h b/Framework/MDAlgorithms/test/ThresholdMDTest.h index 590dd4479cfbfc20af3ecf867f5bd77c0c15c958..64950aae1367ee773e591310eecfe4a3b3621ffc 100644 --- a/Framework/MDAlgorithms/test/ThresholdMDTest.h +++ b/Framework/MDAlgorithms/test/ThresholdMDTest.h @@ -51,7 +51,7 @@ public: TS_ASSERT(alg.isInitialized()) } - IMDHistoWorkspace_sptr doExecute(IMDHistoWorkspace_sptr inWS, + IMDHistoWorkspace_sptr doExecute(const IMDHistoWorkspace_sptr &inWS, const std::string &condition, const double &referenceValue) { const std::string outWSName = "OutWS"; diff --git a/Framework/MDAlgorithms/test/TransformMDTest.h b/Framework/MDAlgorithms/test/TransformMDTest.h index 2f75f3bbd86d61173fc552e2f514738e5e535b06..5ab835d75b91bc0e8a7c60f039a85d6b31c35fa9 100644 --- a/Framework/MDAlgorithms/test/TransformMDTest.h +++ b/Framework/MDAlgorithms/test/TransformMDTest.h @@ -95,7 +95,7 @@ public: } //-------------------------------------------------------------------------------------------- - void do_test_histo(MDHistoWorkspace_sptr ws1, bool inPlace = false) { + void do_test_histo(const MDHistoWorkspace_sptr &ws1, bool inPlace = false) { // Name of the output workspace. std::string outWSName("TransformMDTest_OutputWS"); std::string inWSName("TransformMDTest_ws"); diff --git a/Framework/MDAlgorithms/test/UnaryOperationMDTest.h b/Framework/MDAlgorithms/test/UnaryOperationMDTest.h index 14b0f2e9b651053bc4e58f3f28b84222e3edb7ff..24c153af76a6654fbcd2cc3f01911997840be2ea 100644 --- a/Framework/MDAlgorithms/test/UnaryOperationMDTest.h +++ b/Framework/MDAlgorithms/test/UnaryOperationMDTest.h @@ -60,8 +60,8 @@ public: } /// Run the mock algorithm - void doTest(MockUnaryOperationMD &alg, std::string inName, - std::string outName, bool succeeds = true) { + void doTest(MockUnaryOperationMD &alg, const std::string &inName, + const std::string &outName, bool succeeds = true) { out.reset(); TS_ASSERT_THROWS_NOTHING(alg.initialize()) TS_ASSERT(alg.isInitialized()) diff --git a/Framework/MDAlgorithms/test/WeightedMeanMDTest.h b/Framework/MDAlgorithms/test/WeightedMeanMDTest.h index 1d91aca4e09d181283cf6e1c795b003a1dbcc3af..e836ac0fe72261da5d032e3db9aadd4e3b1f89c4 100644 --- a/Framework/MDAlgorithms/test/WeightedMeanMDTest.h +++ b/Framework/MDAlgorithms/test/WeightedMeanMDTest.h @@ -45,8 +45,8 @@ private: /// Helper method to run the WeightedMean algorithm on two matrix workspaces /// and return the result. - MatrixWorkspace_sptr run_matrix_weighed_mean(MatrixWorkspace_sptr a, - MatrixWorkspace_sptr b, + MatrixWorkspace_sptr run_matrix_weighed_mean(const MatrixWorkspace_sptr &a, + const MatrixWorkspace_sptr &b, const std::string &name) { AnalysisDataServiceImpl &ADS = Mantid::API::AnalysisDataService::Instance(); IAlgorithm *alg = @@ -61,7 +61,8 @@ private: } /// Helper method to run input type validation checks. - void do_test_workspace_input_types(IMDWorkspace_sptr a, IMDWorkspace_sptr b) { + void do_test_workspace_input_types(const IMDWorkspace_sptr &a, + const IMDWorkspace_sptr &b) { WeightedMeanMD alg; alg.initialize(); diff --git a/Framework/Muon/inc/MantidMuon/ApplyMuonDetectorGroupPairing.h b/Framework/Muon/inc/MantidMuon/ApplyMuonDetectorGroupPairing.h index ba1de51814fe8cc7e9a8e3c060a2bdda2e0d0cd5..ff6d99d2776af6586e4d976078b49d93d65dfc61 100644 --- a/Framework/Muon/inc/MantidMuon/ApplyMuonDetectorGroupPairing.h +++ b/Framework/Muon/inc/MantidMuon/ApplyMuonDetectorGroupPairing.h @@ -56,14 +56,16 @@ public: /// return a workspace for a pair of detector groups, specified in options. API::MatrixWorkspace_sptr - createPairWorkspaceManually(API::Workspace_sptr inputWS, const bool noRebin); + createPairWorkspaceManually(const API::Workspace_sptr &inputWS, + const bool noRebin); /// Store the input properties in options. Muon::AnalysisOptions getUserInput(); /// Set MuonProcess properties (input workspace and period properties). void - setMuonProcessPeriodProperties(IAlgorithm &alg, API::Workspace_sptr inputWS, + setMuonProcessPeriodProperties(IAlgorithm &alg, + const API::Workspace_sptr &inputWS, const Muon::AnalysisOptions &options) const; /// Set MuonProcess properties according to the given options. @@ -72,10 +74,9 @@ public: const Muon::AnalysisOptions &options) const; /// Apply the asymmetry calculation to two workspaces. - API::MatrixWorkspace_sptr - createPairWorkspaceFromGroupWorkspaces(API::MatrixWorkspace_sptr inputWS1, - API::MatrixWorkspace_sptr inputWS2, - const double &alpha); + API::MatrixWorkspace_sptr createPairWorkspaceFromGroupWorkspaces( + const API::MatrixWorkspace_sptr &inputWS1, + const API::MatrixWorkspace_sptr &inputWS2, const double &alpha); /// Set grouping properties of MuonProcess void setMuonProcessAlgorithmGroupingProperties( diff --git a/Framework/Muon/inc/MantidMuon/ApplyMuonDetectorGrouping.h b/Framework/Muon/inc/MantidMuon/ApplyMuonDetectorGrouping.h index 09630bd81cd0e0a9eb4c36d3b0482a291f6cca6b..4f6256f9a865df3d2f91c792a1d1f2b5c341a8ed 100644 --- a/Framework/Muon/inc/MantidMuon/ApplyMuonDetectorGrouping.h +++ b/Framework/Muon/inc/MantidMuon/ApplyMuonDetectorGrouping.h @@ -59,9 +59,9 @@ private: void clipXRangeToWorkspace(const API::WorkspaceGroup &ws, Muon::AnalysisOptions &options); /// Creates and analyses a workspace, if noRebin does not rebin. - API::Workspace_sptr createAnalysisWorkspace(API::Workspace_sptr inputWS, - bool noRebin, - Muon::AnalysisOptions options); + API::Workspace_sptr + createAnalysisWorkspace(const API::Workspace_sptr &inputWS, bool noRebin, + Muon::AnalysisOptions options); /// Sets algorithm properties according to options. void setMuonProcessAlgorithmProperties(API::IAlgorithm &alg, const AnalysisOptions &options) const; @@ -70,7 +70,7 @@ private: /// MuonProcess. void setMuonProcessPeriodProperties(API::IAlgorithm &alg, - API::Workspace_sptr inputWS, + const API::Workspace_sptr &inputWS, const Muon::AnalysisOptions &options) const; void setMuonProcessAlgorithmOutputTypeProperty( diff --git a/Framework/Muon/inc/MantidMuon/CalMuonDetectorPhases.h b/Framework/Muon/inc/MantidMuon/CalMuonDetectorPhases.h index 4a00123c04cdfced2ea890c9ce88087893953168..018a1393e8089d854ace3c2484c69cb52b792706 100644 --- a/Framework/Muon/inc/MantidMuon/CalMuonDetectorPhases.h +++ b/Framework/Muon/inc/MantidMuon/CalMuonDetectorPhases.h @@ -57,7 +57,8 @@ private: removeExpDecay(const API::MatrixWorkspace_sptr &wsInput); /// Fit the workspace void fitWorkspace(const API::MatrixWorkspace_sptr &ws, double freq, - std::string groupName, API::ITableWorkspace_sptr resTab, + const std::string &groupName, + const API::ITableWorkspace_sptr &resTab, API::WorkspaceGroup_sptr &resGroup); /// Create the fitting function as string std::string createFittingFunction(double freq, bool fixFreq); diff --git a/Framework/Muon/inc/MantidMuon/CalculateMuonAsymmetry.h b/Framework/Muon/inc/MantidMuon/CalculateMuonAsymmetry.h index 06d2101dccfb4ef35ea45e587774096c15ce3601..5fe014f469ca7e653cd1578287003732136a7061 100644 --- a/Framework/Muon/inc/MantidMuon/CalculateMuonAsymmetry.h +++ b/Framework/Muon/inc/MantidMuon/CalculateMuonAsymmetry.h @@ -69,10 +69,10 @@ private: void init() override; void exec() override; // calculate Muon normalisation constant - std::vector<double> getNormConstants(std::vector<std::string> wsNames); + std::vector<double> getNormConstants(const std::vector<std::string> &wsNames); std::map<std::string, std::string> validateInputs() override; double getNormValue(API::CompositeFunction_sptr &func); - void addNormalizedFits(size_t numberOfFits, const std::vector<double>); + void addNormalizedFits(size_t numberOfFits, const std::vector<double> &); void normalizeWorkspace( const API::MatrixWorkspace_sptr &normalizedWorkspace, const API::MatrixWorkspace_const_sptr &unnormalizedWorkspace, diff --git a/Framework/Muon/inc/MantidMuon/LoadAndApplyMuonDetectorGrouping.h b/Framework/Muon/inc/MantidMuon/LoadAndApplyMuonDetectorGrouping.h index 484263f830587aaedacbd3cf724731f98fa336f5..a7b9ec57c752df18ed11b1eb0cfb4b9d930e72bf 100644 --- a/Framework/Muon/inc/MantidMuon/LoadAndApplyMuonDetectorGrouping.h +++ b/Framework/Muon/inc/MantidMuon/LoadAndApplyMuonDetectorGrouping.h @@ -61,14 +61,14 @@ private: /// Add all the supplied groups to the ADS, inside wsGrouped, by /// executing the ApplyMuonDetectorGrouping algorithm void addGroupingToADS(const Mantid::Muon::AnalysisOptions &options, - Mantid::API::Workspace_sptr ws, - Mantid::API::WorkspaceGroup_sptr wsGrouped); + const Mantid::API::Workspace_sptr &ws, + const Mantid::API::WorkspaceGroup_sptr &wsGrouped); /// Add all the supplied pairs to the ADS, inside wsGrouped, by /// executing the ApplyMuonDetectorGroupPairing algorithm void addPairingToADS(const Mantid::Muon::AnalysisOptions &options, - Mantid::API::Workspace_sptr ws, - Mantid::API::WorkspaceGroup_sptr wsGrouped); + const Mantid::API::Workspace_sptr &ws, + const Mantid::API::WorkspaceGroup_sptr &wsGrouped); void addGroupingInformationToADS(const Mantid::API::Grouping &grouping); @@ -87,8 +87,9 @@ private: /// are paired are also included as groups. void CheckValidGroupsAndPairs(const Mantid::API::Grouping &grouping); - void getTimeLimitsFromInputWorkspace(Mantid::API::Workspace_sptr inputWS, - Mantid::Muon::AnalysisOptions &options); + void + getTimeLimitsFromInputWorkspace(const Mantid::API::Workspace_sptr &inputWS, + Mantid::Muon::AnalysisOptions &options); void getTimeLimitsFromInputs(AnalysisOptions &options); }; diff --git a/Framework/Muon/inc/MantidMuon/MuonAlgorithmHelper.h b/Framework/Muon/inc/MantidMuon/MuonAlgorithmHelper.h index cf83755b300e31b160c1cf0e01ea52eafc422ad3..7e22e0efeca28579f90a1928326524c21d31f8c6 100644 --- a/Framework/Muon/inc/MantidMuon/MuonAlgorithmHelper.h +++ b/Framework/Muon/inc/MantidMuon/MuonAlgorithmHelper.h @@ -55,7 +55,7 @@ namespace MuonAlgorithmHelper { /// Returns a first period MatrixWorkspace in a run workspace MANTID_MUON_DLL Mantid::API::MatrixWorkspace_sptr -firstPeriod(API::Workspace_sptr ws); +firstPeriod(const API::Workspace_sptr &ws); /// Get a run label for a workspace MANTID_MUON_DLL std::string getRunLabel(API::Workspace_sptr ws); @@ -89,15 +89,15 @@ generateWorkspaceName(const Muon::DatasetParams ¶ms); /// Find all the detector IDs contained inside a workspace (either matrix or /// group) and return as an ordered set. MANTID_MUON_DLL std::set<Mantid::detid_t> -getAllDetectorIDsFromWorkspace(Mantid::API::Workspace_sptr ws); +getAllDetectorIDsFromWorkspace(const Mantid::API::Workspace_sptr &ws); /// Find all the detector IDs contained inside a group workspace MANTID_MUON_DLL std::set<Mantid::detid_t> -getAllDetectorIDsFromGroupWorkspace(Mantid::API::WorkspaceGroup_sptr ws); +getAllDetectorIDsFromGroupWorkspace(const Mantid::API::WorkspaceGroup_sptr &ws); /// Find all the detector IDs contained inside a matrix workspace -MANTID_MUON_DLL std::set<Mantid::detid_t> -getAllDetectorIDsFromMatrixWorkspace(Mantid::API::MatrixWorkspace_sptr ws); +MANTID_MUON_DLL std::set<Mantid::detid_t> getAllDetectorIDsFromMatrixWorkspace( + const Mantid::API::MatrixWorkspace_sptr &ws); /// Find all the detector IDs contained inside a grouping object and return as a /// vector of ints @@ -108,7 +108,7 @@ getAllDetectorIDsFromGroup(const API::Grouping &grouping); /// workspace. Workspace can be matrix or group type. MANTID_MUON_DLL bool checkGroupDetectorsInWorkspace(const API::Grouping &grouping, - API::Workspace_sptr ws); + const API::Workspace_sptr &ws); /// Checks that all of the entries of a vector are contained in a set. MANTID_MUON_DLL bool checkItemsInSet(const std::vector<int> &items, @@ -142,9 +142,9 @@ subtractWorkspaces(const Mantid::API::MatrixWorkspace_sptr &lhs, MANTID_MUON_DLL Mantid::API::MatrixWorkspace_sptr extractSpectrum(const Mantid::API::Workspace_sptr &inputWS, const int index); -MANTID_MUON_DLL void addSampleLog(Mantid::API::MatrixWorkspace_sptr workspace, - const std::string &logName, - const std::string &logValue); +MANTID_MUON_DLL void +addSampleLog(const Mantid::API::MatrixWorkspace_sptr &workspace, + const std::string &logName, const std::string &logValue); MANTID_MUON_DLL bool isAlphanumericOrUnderscore(char character); diff --git a/Framework/Muon/inc/MantidMuon/MuonGroupingAsymmetry.h b/Framework/Muon/inc/MantidMuon/MuonGroupingAsymmetry.h index 9a9f4dbbb863c421d9ba8ca1aa8642dda4a92db9..60c713dd299549d8a7f087c1fd3a448899263bf2 100644 --- a/Framework/Muon/inc/MantidMuon/MuonGroupingAsymmetry.h +++ b/Framework/Muon/inc/MantidMuon/MuonGroupingAsymmetry.h @@ -44,9 +44,9 @@ private: std::map<std::string, std::string> validateInputs() override; - WorkspaceGroup_sptr createGroupWorkspace(WorkspaceGroup_sptr inputWS); + WorkspaceGroup_sptr createGroupWorkspace(const WorkspaceGroup_sptr &inputWS); - void addGroupingAsymmetrySampleLogs(MatrixWorkspace_sptr workspace); + void addGroupingAsymmetrySampleLogs(const MatrixWorkspace_sptr &workspace); }; } // namespace Muon diff --git a/Framework/Muon/inc/MantidMuon/MuonGroupingCounts.h b/Framework/Muon/inc/MantidMuon/MuonGroupingCounts.h index 32bf5f020b81037590993b27866aec9c39117b9a..59caf16207398ffe13675cc6d730342da193788f 100644 --- a/Framework/Muon/inc/MantidMuon/MuonGroupingCounts.h +++ b/Framework/Muon/inc/MantidMuon/MuonGroupingCounts.h @@ -42,7 +42,7 @@ private: void init() override; void exec() override; - void setGroupingSampleLogs(MatrixWorkspace_sptr workspace); + void setGroupingSampleLogs(const MatrixWorkspace_sptr &workspace); }; } // namespace Muon diff --git a/Framework/Muon/inc/MantidMuon/MuonPairingAsymmetry.h b/Framework/Muon/inc/MantidMuon/MuonPairingAsymmetry.h index 671b22636614a926822428d8568f93f353b2ca88..2df71cb4fd18a37944f017d23e0b0e41c2b2150e 100644 --- a/Framework/Muon/inc/MantidMuon/MuonPairingAsymmetry.h +++ b/Framework/Muon/inc/MantidMuon/MuonPairingAsymmetry.h @@ -47,27 +47,27 @@ private: std::map<std::string, std::string> validateInputs() override; void validateManualGroups(std::map<std::string, std::string> &errors); void validateGroupsWorkspaces(std::map<std::string, std::string> &errors); - void validatePeriods(WorkspaceGroup_sptr inputWS, + void validatePeriods(const WorkspaceGroup_sptr &inputWS, std::map<std::string, std::string> &errors); - WorkspaceGroup_sptr createGroupWorkspace(WorkspaceGroup_sptr inputWS); - MatrixWorkspace_sptr appendSpectra(MatrixWorkspace_sptr inputWS1, - MatrixWorkspace_sptr inputWS2); + WorkspaceGroup_sptr createGroupWorkspace(const WorkspaceGroup_sptr &inputWS); + MatrixWorkspace_sptr appendSpectra(const MatrixWorkspace_sptr &inputWS1, + const MatrixWorkspace_sptr &inputWS2); /// Perform an asymmetry calculation - MatrixWorkspace_sptr pairAsymmetryCalc(MatrixWorkspace_sptr inputWS, + MatrixWorkspace_sptr pairAsymmetryCalc(const MatrixWorkspace_sptr &inputWS, const double &alpha); MatrixWorkspace_sptr calcPairAsymmetryWithSummedAndSubtractedPeriods( const std::vector<int> &summedPeriods, const std::vector<int> &subtractedPeriods, - WorkspaceGroup_sptr groupedPeriods, const double &alpha); + const WorkspaceGroup_sptr &groupedPeriods, const double &alpha); /// Execute the algorithm if "SpecifyGroupsManually" is checked MatrixWorkspace_sptr execSpecifyGroupsManually(); MatrixWorkspace_sptr execGroupWorkspaceInput(); - void setPairAsymmetrySampleLogs(MatrixWorkspace_sptr workspace); + void setPairAsymmetrySampleLogs(const MatrixWorkspace_sptr &workspace); }; } // namespace Muon diff --git a/Framework/Muon/inc/MantidMuon/MuonPreProcess.h b/Framework/Muon/inc/MantidMuon/MuonPreProcess.h index 84441fe2c9c434fee995ea0575331431c383f95e..70b2407de69366c355be54fb57194ae842d82aa9 100644 --- a/Framework/Muon/inc/MantidMuon/MuonPreProcess.h +++ b/Framework/Muon/inc/MantidMuon/MuonPreProcess.h @@ -45,11 +45,11 @@ private: void exec() override; /// Apply a series of corrections ; DTC, offset, rebin, crop - WorkspaceGroup_sptr correctWorkspaces(WorkspaceGroup_sptr wsGroup); + WorkspaceGroup_sptr correctWorkspaces(const WorkspaceGroup_sptr &wsGroup); MatrixWorkspace_sptr correctWorkspace(MatrixWorkspace_sptr ws); MatrixWorkspace_sptr applyDTC(MatrixWorkspace_sptr ws, - TableWorkspace_sptr dt); + const TableWorkspace_sptr &dt); MatrixWorkspace_sptr applyTimeOffset(MatrixWorkspace_sptr ws, const double &offset); @@ -60,10 +60,10 @@ private: MatrixWorkspace_sptr applyRebinning(MatrixWorkspace_sptr ws, const std::vector<double> &rebinArgs); - MatrixWorkspace_sptr cloneWorkspace(MatrixWorkspace_sptr ws); + MatrixWorkspace_sptr cloneWorkspace(const MatrixWorkspace_sptr &ws); /// Add the correction inputs into the logs - void addPreProcessSampleLogs(WorkspaceGroup_sptr group); + void addPreProcessSampleLogs(const WorkspaceGroup_sptr &group); /// Perform validation of inputs to the algorithm std::map<std::string, std::string> validateInputs() override; diff --git a/Framework/Muon/inc/MantidMuon/PlotAsymmetryByLogValue.h b/Framework/Muon/inc/MantidMuon/PlotAsymmetryByLogValue.h index a45994979e03e4d2014c3aa534041d2c99550102..9eebe959a5257263ba3f1213212a822a3ab4b439 100644 --- a/Framework/Muon/inc/MantidMuon/PlotAsymmetryByLogValue.h +++ b/Framework/Muon/inc/MantidMuon/PlotAsymmetryByLogValue.h @@ -67,7 +67,7 @@ private: // Load run, apply dead time corrections and detector grouping API::Workspace_sptr doLoad(size_t runNumber); // Analyse loaded run - void doAnalysis(API::Workspace_sptr loadedWs, size_t index); + void doAnalysis(const API::Workspace_sptr &loadedWs, size_t index); // Parse run names void parseRunNames(std::string &firstFN, std::string &lastFN, std::string &fnBase, std::string &fnExt, int &fnZeros); @@ -83,10 +83,11 @@ private: void groupDetectors(API::Workspace_sptr &loadedWs, API::Workspace_sptr grouping); /// Calculate the integral asymmetry for a workspace (single period) - void calcIntAsymmetry(API::MatrixWorkspace_sptr ws, double &Y, double &E); + void calcIntAsymmetry(const API::MatrixWorkspace_sptr &ws, double &Y, + double &E); /// Calculate the integral asymmetry for a workspace (red & green) - void calcIntAsymmetry(API::MatrixWorkspace_sptr ws_red, - API::MatrixWorkspace_sptr ws_green, double &Y, + void calcIntAsymmetry(const API::MatrixWorkspace_sptr &ws_red, + const API::MatrixWorkspace_sptr &ws_green, double &Y, double &E); /// Group detectors void groupDetectors(API::MatrixWorkspace_sptr &ws, diff --git a/Framework/Muon/inc/MantidMuon/RRFMuon.h b/Framework/Muon/inc/MantidMuon/RRFMuon.h index 793a0abd6dabcb14db86b22bfb275ddbadb10410..54ce32546cb730641b8dd77132a69ad880d56cee 100644 --- a/Framework/Muon/inc/MantidMuon/RRFMuon.h +++ b/Framework/Muon/inc/MantidMuon/RRFMuon.h @@ -43,7 +43,7 @@ private: /// Run the algorithm void exec() override; /// Get conversion factor from frequency units to input workspace units - double unitConversionFactor(std::string uin, std::string uuser); + double unitConversionFactor(const std::string &uin, const std::string &uuser); }; } // namespace Algorithms diff --git a/Framework/Muon/inc/MantidMuon/RemoveExpDecay.h b/Framework/Muon/inc/MantidMuon/RemoveExpDecay.h index 9327fa0404bec1a8c5e3dfe3024cd21100b9812d..03b02418ad05daa188f28bc1b5aa550a6b19c8c2 100644 --- a/Framework/Muon/inc/MantidMuon/RemoveExpDecay.h +++ b/Framework/Muon/inc/MantidMuon/RemoveExpDecay.h @@ -56,7 +56,8 @@ private: HistogramData::Histogram removeDecay(const HistogramData::Histogram &histogram) const; // calculate Muon normalisation constant - double calNormalisationConst(API::MatrixWorkspace_sptr ws, int wsIndex); + double calNormalisationConst(const API::MatrixWorkspace_sptr &ws, + int wsIndex); }; } // namespace Algorithms diff --git a/Framework/Muon/src/ApplyMuonDetectorGroupPairing.cpp b/Framework/Muon/src/ApplyMuonDetectorGroupPairing.cpp index 7406f76e62c828988b0e6b1ee34029ce75e7d070..7a26b99d096fbcd618a916bb81bc59ec09247f91 100644 --- a/Framework/Muon/src/ApplyMuonDetectorGroupPairing.cpp +++ b/Framework/Muon/src/ApplyMuonDetectorGroupPairing.cpp @@ -22,6 +22,8 @@ #include <algorithm> #include <cctype> #include <string> +#include <utility> + #include <vector> const std::vector<std::string> g_analysisTypes = {"Counts", "Asymmetry"}; @@ -340,7 +342,7 @@ const std::string ApplyMuonDetectorGroupPairing::getGroupWorkspaceNamesManually( */ MatrixWorkspace_sptr ApplyMuonDetectorGroupPairing::createPairWorkspaceFromGroupWorkspaces( - MatrixWorkspace_sptr inputWS1, MatrixWorkspace_sptr inputWS2, + const MatrixWorkspace_sptr &inputWS1, const MatrixWorkspace_sptr &inputWS2, const double &alpha) { IAlgorithm_sptr alg = this->createChildAlgorithm("AppendSpectra"); @@ -372,7 +374,7 @@ ApplyMuonDetectorGroupPairing::createPairWorkspaceFromGroupWorkspaces( * options. */ MatrixWorkspace_sptr ApplyMuonDetectorGroupPairing::createPairWorkspaceManually( - Workspace_sptr inputWS, bool noRebin) { + const Workspace_sptr &inputWS, bool noRebin) { IAlgorithm_sptr alg = this->createChildAlgorithm("MuonProcess"); if (!this->isLogging()) @@ -427,8 +429,8 @@ Muon::AnalysisOptions ApplyMuonDetectorGroupPairing::getUserInput() { // Checks that the detector IDs in grouping are in the workspace void ApplyMuonDetectorGroupPairing::checkDetectorIDsInWorkspace( API::Grouping &grouping, Workspace_sptr workspace) { - bool check = - MuonAlgorithmHelper::checkGroupDetectorsInWorkspace(grouping, workspace); + bool check = MuonAlgorithmHelper::checkGroupDetectorsInWorkspace( + grouping, std::move(workspace)); if (!check) { g_log.error("One or more detector IDs specified in the groups is not " "contained in the InputWorkspace"); @@ -443,7 +445,7 @@ void ApplyMuonDetectorGroupPairing::checkDetectorIDsInWorkspace( * to the given options. For use with MuonProcess. */ void ApplyMuonDetectorGroupPairing::setMuonProcessPeriodProperties( - IAlgorithm &alg, Workspace_sptr inputWS, + IAlgorithm &alg, const Workspace_sptr &inputWS, const Muon::AnalysisOptions &options) const { auto inputGroup = boost::make_shared<WorkspaceGroup>(); diff --git a/Framework/Muon/src/ApplyMuonDetectorGrouping.cpp b/Framework/Muon/src/ApplyMuonDetectorGrouping.cpp index 6d129b7a2a0bfbf6e3c2e5c65672ffce4eb4b1af..02fca46359cbdb32c236e8e753fc6d0c75247758 100644 --- a/Framework/Muon/src/ApplyMuonDetectorGrouping.cpp +++ b/Framework/Muon/src/ApplyMuonDetectorGrouping.cpp @@ -19,6 +19,8 @@ #include <algorithm> #include <cctype> #include <string> +#include <utility> + #include <vector> const std::vector<std::string> g_analysisTypes = {"Counts", "Asymmetry"}; @@ -44,7 +46,7 @@ Mantid::Muon::PlotType getPlotType(const std::string &plotType) { * single period otherwise leave it alone. */ Mantid::API::WorkspaceGroup_sptr -convertInputWStoWSGroup(Mantid::API::Workspace_sptr inputWS) { +convertInputWStoWSGroup(const Mantid::API::Workspace_sptr &inputWS) { // Cast input WS to a WorkspaceGroup auto muonWS = boost::make_shared<Mantid::API::WorkspaceGroup>(); @@ -317,7 +319,8 @@ void ApplyMuonDetectorGrouping::clipXRangeToWorkspace( * Creates workspace, processing the data using the MuonProcess algorithm. */ Workspace_sptr ApplyMuonDetectorGrouping::createAnalysisWorkspace( - Workspace_sptr inputWS, bool noRebin, Muon::AnalysisOptions options) { + const Workspace_sptr &inputWS, bool noRebin, + Muon::AnalysisOptions options) { IAlgorithm_sptr alg = Algorithm::createChildAlgorithm("MuonProcess"); @@ -325,7 +328,7 @@ Workspace_sptr ApplyMuonDetectorGrouping::createAnalysisWorkspace( options.rebinArgs = ""; } - setMuonProcessPeriodProperties(*alg, inputWS, options); + setMuonProcessPeriodProperties(*alg, std::move(inputWS), options); setMuonProcessAlgorithmProperties(*alg, options); alg->setPropertyValue("OutputWorkspace", "__NotUsed__"); alg->execute(); @@ -350,7 +353,7 @@ bool ApplyMuonDetectorGrouping::renameAndMoveUnNormWorkspace( * to the given options. For use with MuonProcess. */ void ApplyMuonDetectorGrouping::setMuonProcessPeriodProperties( - IAlgorithm &alg, Workspace_sptr inputWS, + IAlgorithm &alg, const Workspace_sptr &inputWS, const Muon::AnalysisOptions &options) const { auto inputGroup = boost::make_shared<WorkspaceGroup>(); diff --git a/Framework/Muon/src/CalMuonDetectorPhases.cpp b/Framework/Muon/src/CalMuonDetectorPhases.cpp index 3f0f0940673be6be57c9012d5c1ca5ce3406d709..9788d4f3253512f9dc3d77cc6619146b09444516 100644 --- a/Framework/Muon/src/CalMuonDetectorPhases.cpp +++ b/Framework/Muon/src/CalMuonDetectorPhases.cpp @@ -152,10 +152,10 @@ void CalMuonDetectorPhases::exec() { * @param resTab :: [output] Table workspace storing the asymmetries and phases * @param resGroup :: [output] Workspace group storing the fitting results */ -void CalMuonDetectorPhases::fitWorkspace(const API::MatrixWorkspace_sptr &ws, - double freq, std::string groupName, - API::ITableWorkspace_sptr resTab, - API::WorkspaceGroup_sptr &resGroup) { +void CalMuonDetectorPhases::fitWorkspace( + const API::MatrixWorkspace_sptr &ws, double freq, + const std::string &groupName, const API::ITableWorkspace_sptr &resTab, + API::WorkspaceGroup_sptr &resGroup) { auto nhist = static_cast<int>(ws->getNumberHistograms()); diff --git a/Framework/Muon/src/CalculateMuonAsymmetry.cpp b/Framework/Muon/src/CalculateMuonAsymmetry.cpp index 6b24c51409c1307567aa78add68ff1f96bdff792..d4f260631723249207ac478bc0167009e46c8bc1 100644 --- a/Framework/Muon/src/CalculateMuonAsymmetry.cpp +++ b/Framework/Muon/src/CalculateMuonAsymmetry.cpp @@ -228,7 +228,7 @@ void CalculateMuonAsymmetry::exec() { * @return normalization constants */ void CalculateMuonAsymmetry::addNormalizedFits( - size_t numberOfFits, const std::vector<double> norms) { + size_t numberOfFits, const std::vector<double> &norms) { for (size_t j = 0; j < numberOfFits; j++) { API::Workspace_sptr fitWorkspace = getProperty("OutputWorkspace"); API::MatrixWorkspace_sptr fitWorkspaceActual; @@ -279,7 +279,7 @@ void CalculateMuonAsymmetry::addNormalizedFits( * @return normalization constants */ std::vector<double> CalculateMuonAsymmetry::getNormConstants( - const std::vector<std::string> wsNames) { + const std::vector<std::string> &wsNames) { std::vector<double> norms; double startX = getProperty("StartX"); double endX = getProperty("EndX"); diff --git a/Framework/Muon/src/LoadAndApplyMuonDetectorGrouping.cpp b/Framework/Muon/src/LoadAndApplyMuonDetectorGrouping.cpp index a6cc50655d6cd668125b8cead2b5a5d6f6b288e7..6a2627176ca84e02727895e86f5b5a7428297a72 100644 --- a/Framework/Muon/src/LoadAndApplyMuonDetectorGrouping.cpp +++ b/Framework/Muon/src/LoadAndApplyMuonDetectorGrouping.cpp @@ -4,6 +4,8 @@ // NScD Oak Ridge National Laboratory, European Spallation Source, // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + +#include <utility> + #include "MantidMuon/LoadAndApplyMuonDetectorGrouping.h" #include "MantidMuon/MuonAlgorithmHelper.h" @@ -198,7 +200,7 @@ LoadAndApplyMuonDetectorGrouping::validateInputs() { } void LoadAndApplyMuonDetectorGrouping::getTimeLimitsFromInputWorkspace( - Workspace_sptr inputWS, AnalysisOptions &options) { + const Workspace_sptr &inputWS, AnalysisOptions &options) { MatrixWorkspace_sptr inputMatrixWS = boost::dynamic_pointer_cast<MatrixWorkspace>(inputWS); WorkspaceGroup_sptr inputGroupWS = @@ -268,8 +270,8 @@ void LoadAndApplyMuonDetectorGrouping::exec() { // Checks that the detector IDs in grouping are in the workspace void LoadAndApplyMuonDetectorGrouping::checkDetectorIDsInWorkspace( API::Grouping &grouping, Workspace_sptr workspace) { - bool check = - MuonAlgorithmHelper::checkGroupDetectorsInWorkspace(grouping, workspace); + bool check = MuonAlgorithmHelper::checkGroupDetectorsInWorkspace( + grouping, std::move(workspace)); if (!check) { g_log.error("One or more detector IDs specified in the groups is not " "contained in the InputWorkspace"); @@ -288,7 +290,8 @@ WorkspaceGroup_sptr LoadAndApplyMuonDetectorGrouping::addGroupedWSWithDefaultName( Workspace_sptr workspace) { auto &ads = AnalysisDataService::Instance(); - std::string groupedWSName = MuonAlgorithmHelper::getRunLabel(workspace); + std::string groupedWSName = + MuonAlgorithmHelper::getRunLabel(std::move(workspace)); WorkspaceGroup_sptr groupedWS; if (ads.doesExist(groupedWSName)) { @@ -388,8 +391,8 @@ void LoadAndApplyMuonDetectorGrouping::CheckValidGroupsAndPairs( */ void LoadAndApplyMuonDetectorGrouping::addGroupingToADS( const Mantid::Muon::AnalysisOptions &options, - Mantid::API::Workspace_sptr ws, - Mantid::API::WorkspaceGroup_sptr wsGrouped) { + const Mantid::API::Workspace_sptr &ws, + const Mantid::API::WorkspaceGroup_sptr &wsGrouped) { size_t numGroups = options.grouping.groups.size(); for (auto i = 0u; i < numGroups; ++i) { @@ -426,8 +429,8 @@ void LoadAndApplyMuonDetectorGrouping::addGroupingToADS( */ void LoadAndApplyMuonDetectorGrouping::addPairingToADS( const Mantid::Muon::AnalysisOptions &options, - Mantid::API::Workspace_sptr ws, - Mantid::API::WorkspaceGroup_sptr wsGrouped) { + const Mantid::API::Workspace_sptr &ws, + const Mantid::API::WorkspaceGroup_sptr &wsGrouped) { size_t numPairs = options.grouping.pairs.size(); for (size_t i = 0; i < numPairs; i++) { diff --git a/Framework/Muon/src/MuonAlgorithmHelper.cpp b/Framework/Muon/src/MuonAlgorithmHelper.cpp index 6e0e93e477caa2baec6019f47e3b345ecc8d1015..f04f4c25d956f02f7630714f9d56e523813419ab 100644 --- a/Framework/Muon/src/MuonAlgorithmHelper.cpp +++ b/Framework/Muon/src/MuonAlgorithmHelper.cpp @@ -15,6 +15,8 @@ #include <fstream> #include <string> +#include <utility> + #include <vector> namespace Mantid { @@ -28,7 +30,7 @@ using namespace Mantid::API; * workspace has one period only - it is returned. * @param ws :: Run workspace */ -MatrixWorkspace_sptr firstPeriod(Workspace_sptr ws) { +MatrixWorkspace_sptr firstPeriod(const Workspace_sptr &ws) { if (auto group = boost::dynamic_pointer_cast<WorkspaceGroup>(ws)) { return boost::dynamic_pointer_cast<MatrixWorkspace>(group->getItem(0)); @@ -43,7 +45,7 @@ MatrixWorkspace_sptr firstPeriod(Workspace_sptr ws) { * @return :: run label */ std::string getRunLabel(Mantid::API::Workspace_sptr ws) { - const std::vector<Mantid::API::Workspace_sptr> wsList{ws}; + const std::vector<Mantid::API::Workspace_sptr> wsList{std::move(ws)}; return getRunLabel(wsList); } @@ -282,7 +284,7 @@ std::string generateWorkspaceName(const Muon::DatasetParams ¶ms) { * group) and return as an ordered set. */ std::set<Mantid::detid_t> -getAllDetectorIDsFromWorkspace(Mantid::API::Workspace_sptr ws) { +getAllDetectorIDsFromWorkspace(const Mantid::API::Workspace_sptr &ws) { std::set<Mantid::detid_t> detectorIDs; if (auto workspace = boost::dynamic_pointer_cast<MatrixWorkspace>(ws)) { @@ -296,8 +298,8 @@ getAllDetectorIDsFromWorkspace(Mantid::API::Workspace_sptr ws) { /** * Find all the detector IDs contained inside a matrix workspace */ -std::set<Mantid::detid_t> -getAllDetectorIDsFromMatrixWorkspace(Mantid::API::MatrixWorkspace_sptr ws) { +std::set<Mantid::detid_t> getAllDetectorIDsFromMatrixWorkspace( + const Mantid::API::MatrixWorkspace_sptr &ws) { std::set<Mantid::detid_t> detectorIDs; std::set<Mantid::detid_t> spectrumIDs; @@ -312,8 +314,8 @@ getAllDetectorIDsFromMatrixWorkspace(Mantid::API::MatrixWorkspace_sptr ws) { /** * Find all the detector IDs contained inside a group workspace */ -std::set<Mantid::detid_t> -getAllDetectorIDsFromGroupWorkspace(Mantid::API::WorkspaceGroup_sptr ws) { +std::set<Mantid::detid_t> getAllDetectorIDsFromGroupWorkspace( + const Mantid::API::WorkspaceGroup_sptr &ws) { std::set<Mantid::detid_t> detectorIDs; std::set<Mantid::detid_t> detectorIDsSingleWorkspace; @@ -348,8 +350,8 @@ std::vector<int> getAllDetectorIDsFromGroup(const Grouping &grouping) { // Checks if all the detectors in the groups in a Grouping are in the workspace. // Workspace can be matrix or group type. bool checkGroupDetectorsInWorkspace(const Grouping &grouping, - Workspace_sptr ws) { - std::set<int> detectorIDs = getAllDetectorIDsFromWorkspace(ws); + const Workspace_sptr &ws) { + std::set<int> detectorIDs = getAllDetectorIDsFromWorkspace(std::move(ws)); std::vector<int> groupDetectorIDs = getAllDetectorIDsFromGroup(grouping); return checkItemsInSet(groupDetectorIDs, detectorIDs); } @@ -605,8 +607,8 @@ MatrixWorkspace_sptr extractSpectrum(const Workspace_sptr &inputWS, return outWS; } -void addSampleLog(MatrixWorkspace_sptr workspace, const std::string &logName, - const std::string &logValue) { +void addSampleLog(const MatrixWorkspace_sptr &workspace, + const std::string &logName, const std::string &logValue) { IAlgorithm_sptr alg = AlgorithmManager::Instance().createUnmanaged("AddSampleLog"); alg->initialize(); diff --git a/Framework/Muon/src/MuonGroupingAsymmetry.cpp b/Framework/Muon/src/MuonGroupingAsymmetry.cpp index 86624ee6054f7761b7f93df527ed5e7569fab22a..a43b232ad84b1f4c6738876395e33d43b7b0788f 100644 --- a/Framework/Muon/src/MuonGroupingAsymmetry.cpp +++ b/Framework/Muon/src/MuonGroupingAsymmetry.cpp @@ -66,7 +66,7 @@ estimateAsymmetry(const Workspace_sptr &inputWS, const int index, } std::pair<MatrixWorkspace_sptr, MatrixWorkspace_sptr> estimateMuonAsymmetry( - WorkspaceGroup_sptr inputWS, const std::vector<int> &summedPeriods, + const WorkspaceGroup_sptr &inputWS, const std::vector<int> &summedPeriods, const std::vector<int> &subtractedPeriods, int groupIndex, const double startX, const double endX, const double normalizationIn) { MatrixWorkspace_sptr tempWS; @@ -118,7 +118,7 @@ std::pair<MatrixWorkspace_sptr, MatrixWorkspace_sptr> estimateMuonAsymmetry( return outputPair; } -MatrixWorkspace_sptr groupDetectors(MatrixWorkspace_sptr workspace, +MatrixWorkspace_sptr groupDetectors(const MatrixWorkspace_sptr &workspace, const std::vector<int> &detectorIDs) { auto outputWS = WorkspaceFactory::Instance().create(workspace, 1); @@ -284,8 +284,8 @@ std::map<std::string, std::string> MuonGroupingAsymmetry::validateInputs() { return errors; } -WorkspaceGroup_sptr -MuonGroupingAsymmetry::createGroupWorkspace(WorkspaceGroup_sptr inputWS) { +WorkspaceGroup_sptr MuonGroupingAsymmetry::createGroupWorkspace( + const WorkspaceGroup_sptr &inputWS) { const std::vector<int> group = this->getProperty("Grouping"); auto groupedPeriods = boost::make_shared<WorkspaceGroup>(); // for each period @@ -320,7 +320,7 @@ void MuonGroupingAsymmetry::exec() { } void MuonGroupingAsymmetry::addGroupingAsymmetrySampleLogs( - MatrixWorkspace_sptr workspace) { + const MatrixWorkspace_sptr &workspace) { MuonAlgorithmHelper::addSampleLog(workspace, "analysis_asymmetry_group_name", getPropertyValue("GroupName")); MuonAlgorithmHelper::addSampleLog(workspace, "analysis_asymmetry_group", diff --git a/Framework/Muon/src/MuonGroupingCounts.cpp b/Framework/Muon/src/MuonGroupingCounts.cpp index 760841a98aca0da0dd76d40ca891be6eba35a182..2d1f6979e82969408aae54a6b29f8c8418ec6348 100644 --- a/Framework/Muon/src/MuonGroupingCounts.cpp +++ b/Framework/Muon/src/MuonGroupingCounts.cpp @@ -25,11 +25,11 @@ using namespace Mantid::HistogramData; namespace { bool checkPeriodInWorkspaceGroup(const int &period, - WorkspaceGroup_sptr workspace) { + const WorkspaceGroup_sptr &workspace) { return period <= workspace->getNumberOfEntries(); } -MatrixWorkspace_sptr groupDetectors(MatrixWorkspace_sptr workspace, +MatrixWorkspace_sptr groupDetectors(const MatrixWorkspace_sptr &workspace, const std::vector<int> &detectorIDs) { auto outputWS = WorkspaceFactory::Instance().create(workspace, 1); @@ -199,7 +199,8 @@ void MuonGroupingCounts::exec() { setProperty("OutputWorkspace", outputWS); } -void MuonGroupingCounts::setGroupingSampleLogs(MatrixWorkspace_sptr workspace) { +void MuonGroupingCounts::setGroupingSampleLogs( + const MatrixWorkspace_sptr &workspace) { MuonAlgorithmHelper::addSampleLog(workspace, "analysis_group_name", getPropertyValue("GroupName")); MuonAlgorithmHelper::addSampleLog(workspace, "analysis_group", diff --git a/Framework/Muon/src/MuonPairingAsymmetry.cpp b/Framework/Muon/src/MuonPairingAsymmetry.cpp index 66d1b70c7bc9c46fa1a9d7549920500db62161f1..5116956eb3a38c37cdf10f9e842242615f6d946e 100644 --- a/Framework/Muon/src/MuonPairingAsymmetry.cpp +++ b/Framework/Muon/src/MuonPairingAsymmetry.cpp @@ -23,11 +23,11 @@ using namespace Mantid::Kernel; namespace { bool checkPeriodInWorkspaceGroup(const int &period, - WorkspaceGroup_const_sptr workspace) { + const WorkspaceGroup_const_sptr &workspace) { return period <= workspace->getNumberOfEntries(); } -int countPeriods(Workspace_const_sptr ws) { +int countPeriods(const Workspace_const_sptr &ws) { if (auto tmp = boost::dynamic_pointer_cast<const WorkspaceGroup>(ws)) { return tmp->getNumberOfEntries(); } else { @@ -35,8 +35,8 @@ int countPeriods(Workspace_const_sptr ws) { } } -bool checkConsistentPeriods(Workspace_const_sptr ws1, - Workspace_const_sptr ws2) { +bool checkConsistentPeriods(const Workspace_const_sptr &ws1, + const Workspace_const_sptr &ws2) { if (ws1->isGroup()) { if (!ws2->isGroup()) { return false; @@ -48,12 +48,13 @@ bool checkConsistentPeriods(Workspace_const_sptr ws1, return true; } -MatrixWorkspace_sptr getWorkspace(WorkspaceGroup_sptr group, const int &index) { +MatrixWorkspace_sptr getWorkspace(const WorkspaceGroup_sptr &group, + const int &index) { auto ws = group->getItem(index); return boost::dynamic_pointer_cast<MatrixWorkspace>(ws); } -MatrixWorkspace_sptr groupDetectors(MatrixWorkspace_sptr workspace, +MatrixWorkspace_sptr groupDetectors(const MatrixWorkspace_sptr &workspace, const std::vector<int> &detectorIDs) { auto outputWS = WorkspaceFactory::Instance().create(workspace, 1); @@ -83,7 +84,7 @@ MatrixWorkspace_sptr groupDetectors(MatrixWorkspace_sptr workspace, // Convert a Workspace_sptr (which may be single period, MatrixWorkspace, or // multi period WorkspaceGroup) to a WorkspaceGroup_sptr -WorkspaceGroup_sptr workspaceToWorkspaceGroup(Workspace_sptr workspace) { +WorkspaceGroup_sptr workspaceToWorkspaceGroup(const Workspace_sptr &workspace) { WorkspaceGroup_sptr ws1; if (workspace->isGroup()) { @@ -333,7 +334,7 @@ MatrixWorkspace_sptr MuonPairingAsymmetry::calcPairAsymmetryWithSummedAndSubtractedPeriods( const std::vector<int> &summedPeriods, const std::vector<int> &subtractedPeriods, - WorkspaceGroup_sptr groupedPeriods, const double &alpha) { + const WorkspaceGroup_sptr &groupedPeriods, const double &alpha) { auto summedWS = MuonAlgorithmHelper::sumPeriods(groupedPeriods, summedPeriods); auto subtractedWS = @@ -358,7 +359,7 @@ workspace has two spectra corresponding to the two groupings specified in the inputs. */ WorkspaceGroup_sptr -MuonPairingAsymmetry::createGroupWorkspace(WorkspaceGroup_sptr inputWS) { +MuonPairingAsymmetry::createGroupWorkspace(const WorkspaceGroup_sptr &inputWS) { std::vector<int> group1 = this->getProperty("Group1"); std::vector<int> group2 = this->getProperty("Group2"); @@ -381,7 +382,7 @@ MuonPairingAsymmetry::createGroupWorkspace(WorkspaceGroup_sptr inputWS) { * @returns MatrixWorkspace containing result of the calculation. */ MatrixWorkspace_sptr -MuonPairingAsymmetry::pairAsymmetryCalc(MatrixWorkspace_sptr inputWS, +MuonPairingAsymmetry::pairAsymmetryCalc(const MatrixWorkspace_sptr &inputWS, const double &alpha) { MatrixWorkspace_sptr outWS; @@ -404,7 +405,7 @@ MuonPairingAsymmetry::pairAsymmetryCalc(MatrixWorkspace_sptr inputWS, } void MuonPairingAsymmetry::setPairAsymmetrySampleLogs( - MatrixWorkspace_sptr workspace) { + const MatrixWorkspace_sptr &workspace) { MuonAlgorithmHelper::addSampleLog(workspace, "analysis_pairName", getProperty("PairName")); MuonAlgorithmHelper::addSampleLog(workspace, "analysis_alpha", @@ -420,8 +421,8 @@ void MuonPairingAsymmetry::setPairAsymmetrySampleLogs( } MatrixWorkspace_sptr -MuonPairingAsymmetry::appendSpectra(MatrixWorkspace_sptr inputWS1, - MatrixWorkspace_sptr inputWS2) { +MuonPairingAsymmetry::appendSpectra(const MatrixWorkspace_sptr &inputWS1, + const MatrixWorkspace_sptr &inputWS2) { IAlgorithm_sptr alg = this->createChildAlgorithm("AppendSpectra"); alg->setProperty("InputWorkspace1", inputWS1); @@ -433,7 +434,8 @@ MuonPairingAsymmetry::appendSpectra(MatrixWorkspace_sptr inputWS1, } void MuonPairingAsymmetry::validatePeriods( - WorkspaceGroup_sptr inputWS, std::map<std::string, std::string> &errors) { + const WorkspaceGroup_sptr &inputWS, + std::map<std::string, std::string> &errors) { const std::vector<int> summedPeriods = getProperty("SummedPeriods"); const std::vector<int> subtractedPeriods = getProperty("SubtractedPeriods"); if (summedPeriods.empty() && subtractedPeriods.empty()) { diff --git a/Framework/Muon/src/MuonPreProcess.cpp b/Framework/Muon/src/MuonPreProcess.cpp index 38c409f9009932e878c8126d51d0a77cc6fa5f56..2d78c07483c09d1825fb4aa32b9cd46aca0505b4 100644 --- a/Framework/Muon/src/MuonPreProcess.cpp +++ b/Framework/Muon/src/MuonPreProcess.cpp @@ -155,7 +155,7 @@ void MuonPreProcess::exec() { * @return Corrected workspaces */ WorkspaceGroup_sptr -MuonPreProcess::correctWorkspaces(WorkspaceGroup_sptr wsGroup) { +MuonPreProcess::correctWorkspaces(const WorkspaceGroup_sptr &wsGroup) { WorkspaceGroup_sptr outWS = boost::make_shared<WorkspaceGroup>(); for (auto &&workspace : *wsGroup) { if (auto ws = boost::dynamic_pointer_cast<MatrixWorkspace>(workspace)) { @@ -191,7 +191,7 @@ MatrixWorkspace_sptr MuonPreProcess::correctWorkspace(MatrixWorkspace_sptr ws) { } MatrixWorkspace_sptr MuonPreProcess::applyDTC(MatrixWorkspace_sptr ws, - TableWorkspace_sptr dt) { + const TableWorkspace_sptr &dt) { if (dt != nullptr) { IAlgorithm_sptr dtc = this->createChildAlgorithm("ApplyDeadTimeCorr"); dtc->setProperty("InputWorkspace", ws); @@ -248,7 +248,8 @@ MuonPreProcess::applyRebinning(MatrixWorkspace_sptr ws, } } -MatrixWorkspace_sptr MuonPreProcess::cloneWorkspace(MatrixWorkspace_sptr ws) { +MatrixWorkspace_sptr +MuonPreProcess::cloneWorkspace(const MatrixWorkspace_sptr &ws) { IAlgorithm_sptr cloneWorkspace = this->createChildAlgorithm("CloneWorkspace"); cloneWorkspace->setProperty("InputWorkspace", ws); cloneWorkspace->execute(); @@ -256,7 +257,7 @@ MatrixWorkspace_sptr MuonPreProcess::cloneWorkspace(MatrixWorkspace_sptr ws) { return boost::dynamic_pointer_cast<MatrixWorkspace>(wsClone); } -void MuonPreProcess::addPreProcessSampleLogs(WorkspaceGroup_sptr group) { +void MuonPreProcess::addPreProcessSampleLogs(const WorkspaceGroup_sptr &group) { const std::string numPeriods = std::to_string(group->getNumberOfEntries()); for (auto &&workspace : *group) { diff --git a/Framework/Muon/src/PlotAsymmetryByLogValue.cpp b/Framework/Muon/src/PlotAsymmetryByLogValue.cpp index 4012572a49bf519f4dbe7557c06194df5ea04edf..c344108e3545418c862747b2e81087a3f320e951 100644 --- a/Framework/Muon/src/PlotAsymmetryByLogValue.cpp +++ b/Framework/Muon/src/PlotAsymmetryByLogValue.cpp @@ -5,6 +5,8 @@ // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + #include <cmath> +#include <utility> + #include <vector> #include "MantidAPI/AlgorithmManager.h" @@ -565,7 +567,7 @@ void PlotAsymmetryByLogValue::parseRunNames(std::string &firstFN, void PlotAsymmetryByLogValue::applyDeadtimeCorr(Workspace_sptr &loadedWs, Workspace_sptr deadTimes) { ScopedWorkspace ws(loadedWs); - ScopedWorkspace dt(deadTimes); + ScopedWorkspace dt(std::move(deadTimes)); IAlgorithm_sptr applyCorr = AlgorithmManager::Instance().createUnmanaged("ApplyDeadTimeCorr"); @@ -610,7 +612,7 @@ void PlotAsymmetryByLogValue::groupDetectors(Workspace_sptr &loadedWs, // Could be groups of workspaces, so need to work with ADS ScopedWorkspace inWS(loadedWs); - ScopedWorkspace grWS(grouping); + ScopedWorkspace grWS(std::move(grouping)); ScopedWorkspace outWS; IAlgorithm_sptr alg = @@ -628,7 +630,7 @@ void PlotAsymmetryByLogValue::groupDetectors(Workspace_sptr &loadedWs, * @param loadedWs :: [input] Workspace to apply analysis to * @param index :: [input] Vector index where results will be stored */ -void PlotAsymmetryByLogValue::doAnalysis(Workspace_sptr loadedWs, +void PlotAsymmetryByLogValue::doAnalysis(const Workspace_sptr &loadedWs, size_t index) { // Check if workspace is a workspace group @@ -698,7 +700,7 @@ void PlotAsymmetryByLogValue::doAnalysis(Workspace_sptr loadedWs, * @param Y :: Reference to a variable receiving the value of asymmetry * @param E :: Reference to a variable receiving the value of the error */ -void PlotAsymmetryByLogValue::calcIntAsymmetry(MatrixWorkspace_sptr ws, +void PlotAsymmetryByLogValue::calcIntAsymmetry(const MatrixWorkspace_sptr &ws, double &Y, double &E) { // Output workspace @@ -746,9 +748,9 @@ void PlotAsymmetryByLogValue::calcIntAsymmetry(MatrixWorkspace_sptr ws, * @param Y :: Reference to a variable receiving the value of asymmetry * @param E :: Reference to a variable receiving the value of the error */ -void PlotAsymmetryByLogValue::calcIntAsymmetry(MatrixWorkspace_sptr ws_red, - MatrixWorkspace_sptr ws_green, - double &Y, double &E) { +void PlotAsymmetryByLogValue::calcIntAsymmetry( + const MatrixWorkspace_sptr &ws_red, const MatrixWorkspace_sptr &ws_green, + double &Y, double &E) { if (!m_int) { // "Differential asymmetry" HistogramBuilder builder; builder.setX(ws_red->x(0).size()); diff --git a/Framework/Muon/src/RRFMuon.cpp b/Framework/Muon/src/RRFMuon.cpp index 945cc980b95c899ceb8f5fee16fdb7d43ada0bf3..801d8bfb95f0e935f8330b91cbb49c2f1f397673 100644 --- a/Framework/Muon/src/RRFMuon.cpp +++ b/Framework/Muon/src/RRFMuon.cpp @@ -109,7 +109,8 @@ void RRFMuon::exec() { * @param uin :: [input] input workspace units * @param uuser :: [input] units selected by user */ -double RRFMuon::unitConversionFactor(std::string uin, std::string uuser) { +double RRFMuon::unitConversionFactor(const std::string &uin, + const std::string &uuser) { if ((uin == "microsecond")) { diff --git a/Framework/Muon/src/RemoveExpDecay.cpp b/Framework/Muon/src/RemoveExpDecay.cpp index e8ac3d63edbf1a0e3bc81044c438d9e68523ecf1..c23d63849799f9062b65bad4aaceb76a57c37f39 100644 --- a/Framework/Muon/src/RemoveExpDecay.cpp +++ b/Framework/Muon/src/RemoveExpDecay.cpp @@ -178,8 +178,9 @@ HistogramData::Histogram MuonRemoveExpDecay::removeDecay( * @param wsIndex :: workspace index * @return normalisation constant */ -double MuonRemoveExpDecay::calNormalisationConst(API::MatrixWorkspace_sptr ws, - int wsIndex) { +double +MuonRemoveExpDecay::calNormalisationConst(const API::MatrixWorkspace_sptr &ws, + int wsIndex) { double retVal = 1.0; API::IAlgorithm_sptr fit; diff --git a/Framework/Muon/test/ApplyMuonDetectorGroupPairingTest.h b/Framework/Muon/test/ApplyMuonDetectorGroupPairingTest.h index 78f280b46e8d0f9ad1afc91651ef03cedf398a13..b0bfef20a031a1f49761228db6abbac5b70c1bfc 100644 --- a/Framework/Muon/test/ApplyMuonDetectorGroupPairingTest.h +++ b/Framework/Muon/test/ApplyMuonDetectorGroupPairingTest.h @@ -36,8 +36,8 @@ namespace { // Set algorithm properties to sensible defaults (assuming data with 10 groups) // Use when specifying groups manually void setPairAlgorithmProperties(ApplyMuonDetectorGroupPairing &alg, - std::string inputWSName, - std::string wsGroupName) { + const std::string &inputWSName, + const std::string &wsGroupName) { alg.setProperty("SpecifyGroupsManually", true); alg.setProperty("PairName", "test"); alg.setProperty("Alpha", 1.0); @@ -58,8 +58,8 @@ void setPairAlgorithmProperties(ApplyMuonDetectorGroupPairing &alg, // Set algorithm properties to sensible defaults (assuming data with 10 groups) // Use when entering workspaces to pair void setPairAlgorithmPropertiesForInputWorkspace( - ApplyMuonDetectorGroupPairing &alg, std::string inputWSName, - std::string wsGroupName) { + ApplyMuonDetectorGroupPairing &alg, const std::string &inputWSName, + const std::string &wsGroupName) { alg.setProperty("SpecifyGroupsManually", false); alg.setProperty("PairName", "test"); alg.setProperty("Alpha", 1.0); @@ -72,7 +72,7 @@ void setPairAlgorithmPropertiesForInputWorkspace( // algorithm (a MatrixWorkspace and an empty group). class setUpADSWithWorkspace { public: - setUpADSWithWorkspace(Workspace_sptr ws) { + setUpADSWithWorkspace(const Workspace_sptr &ws) { AnalysisDataService::Instance().addOrReplace(inputWSName, ws); wsGroup = boost::make_shared<WorkspaceGroup>(); AnalysisDataService::Instance().addOrReplace(groupWSName, wsGroup); diff --git a/Framework/Muon/test/ApplyMuonDetectorGroupingTest.h b/Framework/Muon/test/ApplyMuonDetectorGroupingTest.h index 44d16b3aaf7aab1103405f26cbabb79c2a97d464..08b59730bc17a4f72eb1601c8151d3fdc45022c1 100644 --- a/Framework/Muon/test/ApplyMuonDetectorGroupingTest.h +++ b/Framework/Muon/test/ApplyMuonDetectorGroupingTest.h @@ -50,7 +50,7 @@ IAlgorithm_sptr algorithmWithPropertiesSet(const std::string &inputWSName, // algorithm (a MatrixWorkspace and an empty GroupWorkspace). class setUpADSWithWorkspace { public: - setUpADSWithWorkspace(Workspace_sptr ws) { + setUpADSWithWorkspace(const Workspace_sptr &ws) { AnalysisDataService::Instance().addOrReplace(inputWSName, ws); wsGroup = boost::make_shared<WorkspaceGroup>(); AnalysisDataService::Instance().addOrReplace(groupWSName, wsGroup); diff --git a/Framework/Muon/test/CalMuonDetectorPhasesTest.h b/Framework/Muon/test/CalMuonDetectorPhasesTest.h index 93c061a72b0e0bf93334bfdcb564e6190160ff9e..4fb6b5b283397c79a5d311c69e0b74f0222657bb 100644 --- a/Framework/Muon/test/CalMuonDetectorPhasesTest.h +++ b/Framework/Muon/test/CalMuonDetectorPhasesTest.h @@ -187,7 +187,7 @@ private: } /// Runs test of execution on the given workspace - void runExecutionTest(const MatrixWorkspace_sptr workspace) { + void runExecutionTest(const MatrixWorkspace_sptr &workspace) { auto calc = AlgorithmManager::Instance().create("CalMuonDetectorPhases"); calc->initialize(); calc->setChild(true); diff --git a/Framework/Muon/test/CalculateMuonAsymmetryTest.h b/Framework/Muon/test/CalculateMuonAsymmetryTest.h index a541963ed7fbd1058afa156d4fd23d7888cffb8f..5f97b2a47d66961e95bc6e501ceeaef49837043c 100644 --- a/Framework/Muon/test/CalculateMuonAsymmetryTest.h +++ b/Framework/Muon/test/CalculateMuonAsymmetryTest.h @@ -16,6 +16,8 @@ #include "MantidTestHelpers/WorkspaceCreationHelper.h" #include <cxxtest/TestSuite.h> +#include <utility> + #include "MantidAPI/FunctionFactory.h" #include "MantidAPI/IFunction.h" #include "MantidAPI/ITableWorkspace.h" @@ -90,7 +92,7 @@ ITableWorkspace_sptr genTable() { return table; } -IAlgorithm_sptr setUpFuncAlg(std::vector<std::string> wsNames, +IAlgorithm_sptr setUpFuncAlg(const std::vector<std::string> &wsNames, const IFunction_sptr &func) { IAlgorithm_sptr asymmAlg = AlgorithmManager::Instance().create( "ConvertFitFunctionForMuonTFAsymmetry"); @@ -103,31 +105,32 @@ IAlgorithm_sptr setUpFuncAlg(std::vector<std::string> wsNames, return asymmAlg; } -IFunction_sptr genSingleFunc(std::vector<std::string> wsNames) { +IFunction_sptr genSingleFunc(const std::vector<std::string> &wsNames) { IFunction_sptr func = FunctionFactory::Instance().createInitialized( "name=GausOsc,Frequency=3.0"); - IAlgorithm_sptr alg = setUpFuncAlg(wsNames, func); + IAlgorithm_sptr alg = setUpFuncAlg(std::move(wsNames), func); alg->execute(); IFunction_sptr funcOut = alg->getProperty("OutputFunction"); return funcOut; } -IFunction_sptr genDoubleFunc(std::vector<std::string> wsNames) { +IFunction_sptr genDoubleFunc(const std::vector<std::string> &wsNames) { std::string multiFuncString = "composite=MultiDomainFunction,NumDeriv=1;"; multiFuncString += "name=GausOsc,$domains=i,Frequency=3.0;"; multiFuncString += "name=GausOsc,$domains=i,Frequency=3.0;"; IFunction_sptr func = FunctionFactory::Instance().createInitialized(multiFuncString); - IAlgorithm_sptr alg = setUpFuncAlg(wsNames, func); + IAlgorithm_sptr alg = setUpFuncAlg(std::move(wsNames), func); alg->execute(); IFunction_sptr funcOut = alg->getProperty("OutputFunction"); std::cout << funcOut << std::endl; return funcOut; } -IAlgorithm_sptr setUpAlg(ITableWorkspace_sptr &table, IFunction_sptr func, - std::vector<std::string> wsNamesNorm, - std::vector<std::string> wsOut) { +IAlgorithm_sptr setUpAlg(ITableWorkspace_sptr &table, + const IFunction_sptr &func, + const std::vector<std::string> &wsNamesNorm, + const std::vector<std::string> &wsOut) { IAlgorithm_sptr asymmAlg = AlgorithmManager::Instance().create("CalculateMuonAsymmetry"); asymmAlg->initialize(); diff --git a/Framework/Muon/test/ConvertFitFunctionForMuonTFAsymmetryTest.h b/Framework/Muon/test/ConvertFitFunctionForMuonTFAsymmetryTest.h index 2499f7c21a39c5adc3a33daeac069795a552a129..7d7b8c16f2a9bf274db135ac463fcd34999922c1 100644 --- a/Framework/Muon/test/ConvertFitFunctionForMuonTFAsymmetryTest.h +++ b/Framework/Muon/test/ConvertFitFunctionForMuonTFAsymmetryTest.h @@ -59,7 +59,7 @@ ITableWorkspace_sptr genTable() { return table; } -IAlgorithm_sptr setUpAlg(std::vector<std::string> wsNames, +IAlgorithm_sptr setUpAlg(const std::vector<std::string> &wsNames, const IFunction_sptr &func) { IAlgorithm_sptr asymmAlg = AlgorithmManager::Instance().create( "ConvertFitFunctionForMuonTFAsymmetry"); diff --git a/Framework/Muon/test/LoadAndApplyMuonDetectorGroupingTest.h b/Framework/Muon/test/LoadAndApplyMuonDetectorGroupingTest.h index cf4c786dbd90e8c55f6cf0cd676fcc9cbc807d7b..ee52ecb44b66dcd0e1bd8c1bb3423fcdace2c918 100644 --- a/Framework/Muon/test/LoadAndApplyMuonDetectorGroupingTest.h +++ b/Framework/Muon/test/LoadAndApplyMuonDetectorGroupingTest.h @@ -43,7 +43,7 @@ algorithmWithPropertiesSet(const std::string &inputWSName, // algorithm (a MatrixWorkspace and an empty group). class setUpADSWithWorkspace { public: - setUpADSWithWorkspace(Workspace_sptr ws) { + setUpADSWithWorkspace(const Workspace_sptr &ws) { AnalysisDataService::Instance().addOrReplace(inputWSName, ws); wsGroup = boost::make_shared<WorkspaceGroup>(); AnalysisDataService::Instance().addOrReplace(groupWSName, wsGroup); diff --git a/Framework/Muon/test/MuonGroupingAsymmetryTest.h b/Framework/Muon/test/MuonGroupingAsymmetryTest.h index 589608f3bd58701807eba3cd265e77b0f1095d10..66789bd98278f2c415ec4cfad7ddd58fb7dc2bfb 100644 --- a/Framework/Muon/test/MuonGroupingAsymmetryTest.h +++ b/Framework/Muon/test/MuonGroupingAsymmetryTest.h @@ -27,7 +27,7 @@ namespace { // algorithm (a MatrixWorkspace). class setUpADSWithWorkspace { public: - setUpADSWithWorkspace(Workspace_sptr ws) { + setUpADSWithWorkspace(const Workspace_sptr &ws) { AnalysisDataService::Instance().addOrReplace(inputWSName, ws); }; ~setUpADSWithWorkspace() { AnalysisDataService::Instance().clear(); }; @@ -51,7 +51,7 @@ algorithmWithWorkspacePropertiesSet(const std::string &inputWSName) { // Set up algorithm without any optional properties // i.e. just the input workspace and group name. IAlgorithm_sptr -setUpAlgorithmWithoutOptionalProperties(WorkspaceGroup_sptr ws, +setUpAlgorithmWithoutOptionalProperties(const WorkspaceGroup_sptr &ws, const std::string &name, const std::vector<int> &grouping) { setUpADSWithWorkspace setup(ws); @@ -62,7 +62,7 @@ setUpAlgorithmWithoutOptionalProperties(WorkspaceGroup_sptr ws, } // Retrieve the output workspace from an executed algorithm -MatrixWorkspace_sptr getOutputWorkspace(IAlgorithm_sptr alg) { +MatrixWorkspace_sptr getOutputWorkspace(const IAlgorithm_sptr &alg) { MatrixWorkspace_sptr outputWS = alg->getProperty("OutputWorkspace"); return outputWS; } diff --git a/Framework/Muon/test/MuonGroupingCountsTest.h b/Framework/Muon/test/MuonGroupingCountsTest.h index 6eeef999d7149d68d57d6d00dede8e64d273c72e..bd42678b49d2a2c62e113b99639a97f13cf263c5 100644 --- a/Framework/Muon/test/MuonGroupingCountsTest.h +++ b/Framework/Muon/test/MuonGroupingCountsTest.h @@ -26,7 +26,7 @@ namespace { // algorithm (a MatrixWorkspace). class setUpADSWithWorkspace { public: - setUpADSWithWorkspace(Workspace_sptr ws) { + setUpADSWithWorkspace(const Workspace_sptr &ws) { AnalysisDataService::Instance().addOrReplace(inputWSName, ws); }; ~setUpADSWithWorkspace() { AnalysisDataService::Instance().clear(); }; @@ -50,7 +50,7 @@ algorithmWithoutOptionalPropertiesSet(const std::string &inputWSName) { // Set up algorithm without any optional properties // i.e. just the input workspace and group name. IAlgorithm_sptr -setUpAlgorithmWithoutOptionalProperties(WorkspaceGroup_sptr ws, +setUpAlgorithmWithoutOptionalProperties(const WorkspaceGroup_sptr &ws, const std::string &name) { setUpADSWithWorkspace setup(ws); IAlgorithm_sptr alg = @@ -60,7 +60,7 @@ setUpAlgorithmWithoutOptionalProperties(WorkspaceGroup_sptr ws, } // Set up algorithm with GroupName applied -IAlgorithm_sptr setUpAlgorithmWithGroupName(WorkspaceGroup_sptr ws, +IAlgorithm_sptr setUpAlgorithmWithGroupName(const WorkspaceGroup_sptr &ws, const std::string &name) { setUpADSWithWorkspace setup(ws); IAlgorithm_sptr alg = @@ -71,7 +71,7 @@ IAlgorithm_sptr setUpAlgorithmWithGroupName(WorkspaceGroup_sptr ws, // Set up algorithm with TimeOffset applied IAlgorithm_sptr -setUpAlgorithmWithGroupNameAndDetectors(WorkspaceGroup_sptr ws, +setUpAlgorithmWithGroupNameAndDetectors(const WorkspaceGroup_sptr &ws, const std::string &name, const std::vector<int> &detectors) { setUpADSWithWorkspace setup(ws); @@ -83,7 +83,7 @@ setUpAlgorithmWithGroupNameAndDetectors(WorkspaceGroup_sptr ws, } // Retrieve the output workspace from an executed algorithm -MatrixWorkspace_sptr getOutputWorkspace(IAlgorithm_sptr alg) { +MatrixWorkspace_sptr getOutputWorkspace(const IAlgorithm_sptr &alg) { Workspace_sptr outputWS = alg->getProperty("OutputWorkspace"); auto wsOut = boost::dynamic_pointer_cast<MatrixWorkspace>(outputWS); return wsOut; diff --git a/Framework/Muon/test/MuonPairingAsymmetryTest.h b/Framework/Muon/test/MuonPairingAsymmetryTest.h index ff748fb2031980bc1289df074b2f8d9a9aae31fb..3922da95028dce51f9576da968f299782199d57e 100644 --- a/Framework/Muon/test/MuonPairingAsymmetryTest.h +++ b/Framework/Muon/test/MuonPairingAsymmetryTest.h @@ -27,7 +27,7 @@ namespace { // algorithm (a MatrixWorkspace). class setUpADSWithWorkspace { public: - setUpADSWithWorkspace(Workspace_sptr ws) { + setUpADSWithWorkspace(const Workspace_sptr &ws) { AnalysisDataService::Instance().addOrReplace(inputWSName, ws); }; ~setUpADSWithWorkspace() { AnalysisDataService::Instance().clear(); }; @@ -55,7 +55,7 @@ IAlgorithm_sptr algorithmWithoutOptionalPropertiesSet( // Set up algorithm without any optional properties. IAlgorithm_sptr -setUpAlgorithmWithoutOptionalProperties(WorkspaceGroup_sptr ws, +setUpAlgorithmWithoutOptionalProperties(const WorkspaceGroup_sptr &ws, const std::string &name) { const std::vector<int> group1 = {1, 2}; const std::vector<int> group2 = {3, 4}; @@ -67,7 +67,7 @@ setUpAlgorithmWithoutOptionalProperties(WorkspaceGroup_sptr ws, } // Set up algorithm with groupings -IAlgorithm_sptr setUpAlgorithmWithGroups(WorkspaceGroup_sptr ws, +IAlgorithm_sptr setUpAlgorithmWithGroups(const WorkspaceGroup_sptr &ws, const std::vector<int> &group1, const std::vector<int> &group2) { setUpADSWithWorkspace setup(ws); @@ -78,8 +78,8 @@ IAlgorithm_sptr setUpAlgorithmWithGroups(WorkspaceGroup_sptr ws, // Set up algorithm to accept two group workspaces IAlgorithm_sptr -setUpAlgorithmWithGroupWorkspaces(MatrixWorkspace_sptr groupedWS1, - MatrixWorkspace_sptr groupedWS2) { +setUpAlgorithmWithGroupWorkspaces(const MatrixWorkspace_sptr &groupedWS1, + const MatrixWorkspace_sptr &groupedWS2) { auto alg = boost::make_shared<MuonPairingAsymmetry>(); alg->initialize(); alg->setProperty("SpecifyGroupsManually", false); @@ -94,8 +94,8 @@ setUpAlgorithmWithGroupWorkspaces(MatrixWorkspace_sptr groupedWS1, // Set up MuonPairingAsymmetry algorithm to accept two WorkspaceGroups IAlgorithm_sptr -setUpAlgorithmWithGroupWorkspaceGroups(WorkspaceGroup_sptr groupedWS1, - WorkspaceGroup_sptr groupedWS2) { +setUpAlgorithmWithGroupWorkspaceGroups(const WorkspaceGroup_sptr &groupedWS1, + const WorkspaceGroup_sptr &groupedWS2) { auto alg = boost::make_shared<MuonPairingAsymmetry>(); alg->setRethrows(true); alg->initialize(); @@ -110,7 +110,7 @@ setUpAlgorithmWithGroupWorkspaceGroups(WorkspaceGroup_sptr groupedWS1, } // Retrieve the output workspace from an executed algorithm -MatrixWorkspace_sptr getOutputWorkspace(IAlgorithm_sptr alg) { +MatrixWorkspace_sptr getOutputWorkspace(const IAlgorithm_sptr &alg) { MatrixWorkspace_sptr outputWS = alg->getProperty("OutputWorkspace"); return outputWS; } diff --git a/Framework/Muon/test/MuonPreProcessTest.h b/Framework/Muon/test/MuonPreProcessTest.h index 4ad8086d6ec647e5ab5ee1915f22443b751dbe53..c2554089ce3b936e4815103de9fd13e75f56ffa1 100644 --- a/Framework/Muon/test/MuonPreProcessTest.h +++ b/Framework/Muon/test/MuonPreProcessTest.h @@ -13,6 +13,8 @@ #include <cxxtest/TestSuite.h> +#include <utility> + using namespace Mantid; using namespace Mantid::Kernel; using namespace Mantid::API; @@ -41,22 +43,23 @@ class setUpADSWithWorkspace { public: std::string const inputWSName = "inputData"; - setUpADSWithWorkspace(Workspace_sptr ws) { + setUpADSWithWorkspace(const Workspace_sptr &ws) { AnalysisDataService::Instance().addOrReplace(inputWSName, ws); }; ~setUpADSWithWorkspace() { AnalysisDataService::Instance().clear(); }; }; // Set up algorithm with none of the optional properties -IAlgorithm_sptr setUpAlgorithmWithNoOptionalProperties(Workspace_sptr ws) { - setUpADSWithWorkspace setup(ws); +IAlgorithm_sptr +setUpAlgorithmWithNoOptionalProperties(const Workspace_sptr &ws) { + setUpADSWithWorkspace setup(std::move(ws)); IAlgorithm_sptr alg = algorithmWithoutOptionalPropertiesSet(setup.inputWSName); return alg; } // Set up algorithm with TimeOffset applied -IAlgorithm_sptr setUpAlgorithmWithTimeOffset(MatrixWorkspace_sptr ws, +IAlgorithm_sptr setUpAlgorithmWithTimeOffset(const MatrixWorkspace_sptr &ws, const double &offset) { setUpADSWithWorkspace setup(ws); IAlgorithm_sptr alg = @@ -67,8 +70,8 @@ IAlgorithm_sptr setUpAlgorithmWithTimeOffset(MatrixWorkspace_sptr ws, // Set up algorithm with DeadTimeTable applied IAlgorithm_sptr -setUpAlgorithmWithDeadTimeTable(MatrixWorkspace_sptr ws, - ITableWorkspace_sptr deadTimes) { +setUpAlgorithmWithDeadTimeTable(const MatrixWorkspace_sptr &ws, + const ITableWorkspace_sptr &deadTimes) { setUpADSWithWorkspace setup(ws); IAlgorithm_sptr alg = algorithmWithoutOptionalPropertiesSet(setup.inputWSName); @@ -77,7 +80,7 @@ setUpAlgorithmWithDeadTimeTable(MatrixWorkspace_sptr ws, } // Set up algorithm with TimeMin applied -IAlgorithm_sptr setUpAlgorithmWithTimeMin(MatrixWorkspace_sptr ws, +IAlgorithm_sptr setUpAlgorithmWithTimeMin(const MatrixWorkspace_sptr &ws, const double &timeMin) { setUpADSWithWorkspace setup(ws); IAlgorithm_sptr alg = @@ -87,7 +90,7 @@ IAlgorithm_sptr setUpAlgorithmWithTimeMin(MatrixWorkspace_sptr ws, } // Set up algorithm with TimeMax applied -IAlgorithm_sptr setUpAlgorithmWithTimeMax(MatrixWorkspace_sptr ws, +IAlgorithm_sptr setUpAlgorithmWithTimeMax(const MatrixWorkspace_sptr &ws, const double &timeMax) { setUpADSWithWorkspace setup(ws); IAlgorithm_sptr alg = @@ -98,8 +101,8 @@ IAlgorithm_sptr setUpAlgorithmWithTimeMax(MatrixWorkspace_sptr ws, // Get the workspace at a particular index from the output workspace // group produced by the PreProcess alg -MatrixWorkspace_sptr getOutputWorkspace(IAlgorithm_sptr muonPreProcessAlg, - const int &index) { +MatrixWorkspace_sptr +getOutputWorkspace(const IAlgorithm_sptr &muonPreProcessAlg, const int &index) { WorkspaceGroup_sptr outputWS; outputWS = muonPreProcessAlg->getProperty("OutputWorkspace"); MatrixWorkspace_sptr wsOut = diff --git a/Framework/Muon/test/PhaseQuadMuonTest.h b/Framework/Muon/test/PhaseQuadMuonTest.h index 8f0969d7ae8e4e127173eb907d40d133dfe023c9..b6d69c4febb83353b6b7fad42cbfd329be45ef2d 100644 --- a/Framework/Muon/test/PhaseQuadMuonTest.h +++ b/Framework/Muon/test/PhaseQuadMuonTest.h @@ -17,6 +17,8 @@ #include "MantidDataObjects/TableWorkspace.h" #include <cxxtest/TestSuite.h> +#include <utility> + using namespace Mantid::DataObjects; using namespace Mantid::API; @@ -25,8 +27,8 @@ namespace { const int dead1 = 4; const int dead2 = 12; -void populatePhaseTableWithDeadDetectors(ITableWorkspace_sptr phaseTable, - const MatrixWorkspace_sptr ws) { +void populatePhaseTableWithDeadDetectors(const ITableWorkspace_sptr &phaseTable, + const MatrixWorkspace_sptr &ws) { phaseTable->addColumn("int", "DetectprID"); phaseTable->addColumn("double", "Asymmetry"); phaseTable->addColumn("double", "phase"); @@ -42,7 +44,7 @@ void populatePhaseTableWithDeadDetectors(ITableWorkspace_sptr phaseTable, } } } -void populatePhaseTable(ITableWorkspace_sptr phaseTable, +void populatePhaseTable(const ITableWorkspace_sptr &phaseTable, std::vector<std::string> names, bool swap = false) { phaseTable->addColumn("int", names[0]); phaseTable->addColumn("double", names[1]); @@ -58,12 +60,14 @@ void populatePhaseTable(ITableWorkspace_sptr phaseTable, phaseRow2 << i << asym << phase; } } -void populatePhaseTable(ITableWorkspace_sptr phaseTable) { - populatePhaseTable(phaseTable, {"DetectorID", "Asymmetry", "Phase"}); +void populatePhaseTable(const ITableWorkspace_sptr &phaseTable) { + populatePhaseTable(std::move(phaseTable), + {"DetectorID", "Asymmetry", "Phase"}); } -IAlgorithm_sptr setupAlg(MatrixWorkspace_sptr m_loadedData, bool isChildAlg, - ITableWorkspace_sptr phaseTable) { +IAlgorithm_sptr setupAlg(const MatrixWorkspace_sptr &m_loadedData, + bool isChildAlg, + const ITableWorkspace_sptr &phaseTable) { // Set up PhaseQuad IAlgorithm_sptr phaseQuad = AlgorithmManager::Instance().create("PhaseQuad"); phaseQuad->setChild(isChildAlg); @@ -74,26 +78,28 @@ IAlgorithm_sptr setupAlg(MatrixWorkspace_sptr m_loadedData, bool isChildAlg, return phaseQuad; } -IAlgorithm_sptr setupAlg(MatrixWorkspace_sptr m_loadedData, bool isChildAlg) { +IAlgorithm_sptr setupAlg(const MatrixWorkspace_sptr &m_loadedData, + bool isChildAlg) { // Create and populate a detector table boost::shared_ptr<ITableWorkspace> phaseTable( new Mantid::DataObjects::TableWorkspace); populatePhaseTable(phaseTable); - return setupAlg(m_loadedData, isChildAlg, phaseTable); + return setupAlg(std::move(m_loadedData), isChildAlg, phaseTable); } -IAlgorithm_sptr setupAlg(MatrixWorkspace_sptr m_loadedData, bool isChildAlg, - std::vector<std::string> names, bool swap = false) { +IAlgorithm_sptr setupAlg(const MatrixWorkspace_sptr &m_loadedData, + bool isChildAlg, std::vector<std::string> names, + bool swap = false) { // Create and populate a detector table boost::shared_ptr<ITableWorkspace> phaseTable( new Mantid::DataObjects::TableWorkspace); - populatePhaseTable(phaseTable, names, swap); + populatePhaseTable(phaseTable, std::move(names), swap); - return setupAlg(m_loadedData, isChildAlg, phaseTable); + return setupAlg(std::move(m_loadedData), isChildAlg, phaseTable); } -IAlgorithm_sptr setupAlgDead(MatrixWorkspace_sptr m_loadedData) { +IAlgorithm_sptr setupAlgDead(const MatrixWorkspace_sptr &m_loadedData) { // Create and populate a detector table boost::shared_ptr<ITableWorkspace> phaseTable( new Mantid::DataObjects::TableWorkspace); @@ -102,7 +108,7 @@ IAlgorithm_sptr setupAlgDead(MatrixWorkspace_sptr m_loadedData) { return setupAlg(m_loadedData, true, phaseTable); } -MatrixWorkspace_sptr setupWS(MatrixWorkspace_sptr m_loadedData) { +MatrixWorkspace_sptr setupWS(const MatrixWorkspace_sptr &m_loadedData) { boost::shared_ptr<ITableWorkspace> phaseTable( new Mantid::DataObjects::TableWorkspace); MatrixWorkspace_sptr ws = m_loadedData->clone(); diff --git a/Framework/Nexus/inc/MantidNexus/MuonNexusReader.h b/Framework/Nexus/inc/MantidNexus/MuonNexusReader.h index 0ba3101577d7fa858d19fe6ad7fb80cdfcd079ee..7a8748dae8ffd7853cabea7dbe7d1c2c95dfa3e8 100644 --- a/Framework/Nexus/inc/MantidNexus/MuonNexusReader.h +++ b/Framework/Nexus/inc/MantidNexus/MuonNexusReader.h @@ -48,7 +48,7 @@ private: /// file to base all NXlog times on std::time_t startTime_time_t; ///< startTime in time_t format std::time_t - to_time_t(boost::posix_time::ptime t) ///< convert posix time to time_t + to_time_t(const boost::posix_time::ptime &t) ///< convert posix time to time_t { /** Take the input Posix time, subtract the unix epoch, and return the seconds diff --git a/Framework/Nexus/inc/MantidNexus/NexusFileIO.h b/Framework/Nexus/inc/MantidNexus/NexusFileIO.h index a78851eb13c7436fd9365c4e7b5728f987bc2af0..e6b04b001935f8323cfba04eb3e91f75683d7694 100644 --- a/Framework/Nexus/inc/MantidNexus/NexusFileIO.h +++ b/Framework/Nexus/inc/MantidNexus/NexusFileIO.h @@ -83,7 +83,7 @@ public: float *errorSquareds, int64_t *pulsetimes, bool compress) const; int writeEventList(const DataObjects::EventList &el, - std::string group_name) const; + const std::string &group_name) const; template <class T> void writeEventListData(std::vector<T> events, bool writeTOF, @@ -103,7 +103,7 @@ public: const int &spectra) const; /// write bin masking information - bool writeNexusBinMasking(API::MatrixWorkspace_const_sptr ws) const; + bool writeNexusBinMasking(const API::MatrixWorkspace_const_sptr &ws) const; /// Reset the pointer to the progress object. void resetProgress(Mantid::API::Progress *prog); @@ -171,7 +171,7 @@ private: int findMantidWSEntries() const; /// convert posix time to time_t std::time_t - to_time_t(boost::posix_time::ptime t) ///< convert posix time to time_t + to_time_t(const boost::posix_time::ptime &t) ///< convert posix time to time_t { /** Take the input Posix time, subtract the unix epoch, and return the seconds @@ -202,7 +202,7 @@ private: /// Writes given vector column to the currently open Nexus file template <typename VecType, typename ElemType> - void writeNexusVectorColumn(API::Column_const_sptr col, + void writeNexusVectorColumn(const API::Column_const_sptr &col, const std::string &columnName, int nexusType, const std::string &interpret_as) const; diff --git a/Framework/Nexus/inc/MantidNexus/NexusIOHelper.h b/Framework/Nexus/inc/MantidNexus/NexusIOHelper.h index 5f191b93a878fc18323b63ced6fb9b8ada4a49b7..69de03ffe0d0817af6b2334228f7cf9bdf5a50af 100644 --- a/Framework/Nexus/inc/MantidNexus/NexusIOHelper.h +++ b/Framework/Nexus/inc/MantidNexus/NexusIOHelper.h @@ -12,6 +12,9 @@ #include <nexus/NeXusFile.hpp> #include <numeric> #include <string> +#include <utility> + +#include <utility> namespace Mantid { namespace NeXus { @@ -46,8 +49,8 @@ namespace { throw std::runtime_error("Unknown type in Nexus file"); \ } -std::pair<::NeXus::Info, bool> checkIfOpenAndGetInfo(::NeXus::File &file, - std::string entry) { +std::pair<::NeXus::Info, bool> +checkIfOpenAndGetInfo(::NeXus::File &file, const std::string &&entry) { std::pair<::NeXus::Info, bool> info_and_close; info_and_close.second = false; if (!file.isDataSetOpen()) { @@ -160,8 +163,10 @@ T readNexusAnyVariable(::NeXus::File &file, bool close_file) { * and calls readNexusAnyVector via the RUN_NEXUSIOHELPER_FUNCTION macro. */ template <typename T> -std::vector<T> readNexusVector(::NeXus::File &file, std::string entry = "") { - auto info_and_close = checkIfOpenAndGetInfo(file, entry); +std::vector<T> readNexusVector(::NeXus::File &file, + const std::string &entry = "") { + auto info_and_close = + checkIfOpenAndGetInfo(file, std::move(std::move(entry))); auto dims = (info_and_close.first).dims; auto total_size = std::accumulate(dims.begin(), dims.end(), int64_t{1}, std::multiplies<>()); @@ -173,17 +178,19 @@ std::vector<T> readNexusVector(::NeXus::File &file, std::string entry = "") { * readNexusAnySlab via the RUN_NEXUSIOHELPER_FUNCTION macro. */ template <typename T> -std::vector<T> readNexusSlab(::NeXus::File &file, std::string entry, +std::vector<T> readNexusSlab(::NeXus::File &file, const std::string &entry, const std::vector<int64_t> &start, const std::vector<int64_t> &size) { - auto info_and_close = checkIfOpenAndGetInfo(file, entry); + auto info_and_close = + checkIfOpenAndGetInfo(file, std::move(std::move(entry))); RUN_NEXUSIOHELPER_FUNCTION((info_and_close.first).type, readNexusAnySlab, file, start, size, info_and_close.second); } template <typename T> -T readNexusValue(::NeXus::File &file, std::string entry = "") { - auto info_and_close = checkIfOpenAndGetInfo(file, entry); +T readNexusValue(::NeXus::File &file, const std::string &entry = "") { + auto info_and_close = + checkIfOpenAndGetInfo(file, std::move(std::move(entry))); RUN_NEXUSIOHELPER_FUNCTION((info_and_close.first).type, readNexusAnyVariable, file, info_and_close.second); } diff --git a/Framework/Nexus/src/NexusFileIO.cpp b/Framework/Nexus/src/NexusFileIO.cpp index 08cbbffce57bca7ff7320c18a1b1e8235076a806..c82b40f08d4b92432a2d88fc25de3e7b23edc960 100644 --- a/Framework/Nexus/src/NexusFileIO.cpp +++ b/Framework/Nexus/src/NexusFileIO.cpp @@ -574,7 +574,7 @@ size_t getSizeOf(const Kernel::V3D & /*unused*/) { return 3; } */ template <typename VecType, typename ElemType> void NexusFileIO::writeNexusVectorColumn( - Column_const_sptr col, const std::string &columnName, int nexusType, + const Column_const_sptr &col, const std::string &columnName, int nexusType, const std::string &interpret_as) const { ConstColumnVector<VecType> column(col); size_t rowCount = column.size(); @@ -893,7 +893,7 @@ void NexusFileIO::writeEventListData(std::vector<T> events, bool writeTOF, * @param group_name :: group_name to create. * */ int NexusFileIO::writeEventList(const DataObjects::EventList &el, - std::string group_name) const { + const std::string &group_name) const { // write data entry NXstatus status = NXmakegroup(fileID, group_name.c_str(), "NXdata"); if (status == NX_ERROR) @@ -1162,7 +1162,7 @@ bool NexusFileIO::checkEntryAtLevelByAttribute(const std::string &attribute, * @return true for OK, false for error */ bool NexusFileIO::writeNexusBinMasking( - API::MatrixWorkspace_const_sptr ws) const { + const API::MatrixWorkspace_const_sptr &ws) const { std::vector<int> spectra; std::vector<std::size_t> bins; std::vector<double> weights; diff --git a/Framework/NexusGeometry/inc/MantidNexusGeometry/InstrumentBuilder.h b/Framework/NexusGeometry/inc/MantidNexusGeometry/InstrumentBuilder.h index 242cf870995c7d5d9583c6875d67f309a5026fec..24828bdff3ea60ee460c41bab6e59380ba929293 100644 --- a/Framework/NexusGeometry/inc/MantidNexusGeometry/InstrumentBuilder.h +++ b/Framework/NexusGeometry/inc/MantidNexusGeometry/InstrumentBuilder.h @@ -37,9 +37,10 @@ public: Geometry::IComponent *addComponent(const std::string &compName, const Eigen::Vector3d &position); /// Adds tubes (ObjComponentAssemblies) to the last registered bank - void addTubes(const std::string &bankName, - const std::vector<detail::TubeBuilder> &tubes, - boost::shared_ptr<const Mantid::Geometry::IObject> pixelShape); + void addTubes( + const std::string &bankName, + const std::vector<detail::TubeBuilder> &tubes, + const boost::shared_ptr<const Mantid::Geometry::IObject> &pixelShape); /// Adds detector to the root (instrument) void addDetectorToInstrument( const std::string &detName, detid_t detId, @@ -69,8 +70,9 @@ public: private: /// Add a single tube to the last registed bank - void doAddTube(const std::string &compName, const detail::TubeBuilder &tube, - boost::shared_ptr<const Mantid::Geometry::IObject> pixelShape); + void doAddTube( + const std::string &compName, const detail::TubeBuilder &tube, + const boost::shared_ptr<const Mantid::Geometry::IObject> &pixelShape); /// Sorts detectors void sortDetectors() const; /// product diff --git a/Framework/NexusGeometry/inc/MantidNexusGeometry/TubeBuilder.h b/Framework/NexusGeometry/inc/MantidNexusGeometry/TubeBuilder.h index 2d297dff52035605203c7a1fead17c7189f83059..94626863f7d0b5c938f50a06625fb57cb6e03f2c 100644 --- a/Framework/NexusGeometry/inc/MantidNexusGeometry/TubeBuilder.h +++ b/Framework/NexusGeometry/inc/MantidNexusGeometry/TubeBuilder.h @@ -25,7 +25,8 @@ Colinear detectors with cylindrical shape. class MANTID_NEXUSGEOMETRY_DLL TubeBuilder { public: TubeBuilder(const Mantid::Geometry::IObject &pixelShape, - Eigen::Vector3d firstDetectorPosition, int firstDetectorId); + const Eigen::Vector3d &firstDetectorPosition, + int firstDetectorId); const Eigen::Vector3d &tubePosition() const; const std::vector<Eigen::Vector3d> &detPositions() const; const std::vector<int> &detIDs() const; diff --git a/Framework/NexusGeometry/src/InstrumentBuilder.cpp b/Framework/NexusGeometry/src/InstrumentBuilder.cpp index 22df87101ee6b1330bf476575b0163eaa6302718..30e54b073b651495eed42fe143fae0d5550d25fc 100644 --- a/Framework/NexusGeometry/src/InstrumentBuilder.cpp +++ b/Framework/NexusGeometry/src/InstrumentBuilder.cpp @@ -14,6 +14,7 @@ #include "MantidNexusGeometry/NexusShapeFactory.h" #include <boost/make_shared.hpp> +#include <utility> namespace Mantid { namespace NexusGeometry { @@ -56,7 +57,7 @@ InstrumentBuilder::addComponent(const std::string &compName, */ void InstrumentBuilder::addTubes( const std::string &bankName, const std::vector<detail::TubeBuilder> &tubes, - boost::shared_ptr<const Mantid::Geometry::IObject> pixelShape) { + const boost::shared_ptr<const Mantid::Geometry::IObject> &pixelShape) { for (size_t i = 0; i < tubes.size(); i++) doAddTube(bankName + "_tube_" + std::to_string(i), tubes[i], pixelShape); } @@ -68,7 +69,7 @@ void InstrumentBuilder::addTubes( */ void InstrumentBuilder::doAddTube( const std::string &compName, const detail::TubeBuilder &tube, - boost::shared_ptr<const Mantid::Geometry::IObject> pixelShape) { + const boost::shared_ptr<const Mantid::Geometry::IObject> &pixelShape) { auto *objComp(new Geometry::ObjCompAssembly(compName)); const auto &pos = tube.tubePosition(); objComp->setPos(pos(0), pos(1), pos(2)); @@ -98,7 +99,7 @@ void InstrumentBuilder::addDetectorToLastBank( detector->translate(Mantid::Kernel::toV3D(relativeOffset)); // No rotation set for detector pixels of a bank. This is not possible in the // Nexus Geometry specification. - detector->setShape(shape); + detector->setShape(std::move(shape)); m_lastBank->add(detector); m_instrument->markAsDetectorIncomplete(detector); } diff --git a/Framework/NexusGeometry/src/TubeBuilder.cpp b/Framework/NexusGeometry/src/TubeBuilder.cpp index cc73f59d596fd34e7dcd790d0e22d90a4b1a3f6c..c01c154a3e7d6816c4a18c8f96fdfb018c797180 100644 --- a/Framework/NexusGeometry/src/TubeBuilder.cpp +++ b/Framework/NexusGeometry/src/TubeBuilder.cpp @@ -17,7 +17,7 @@ namespace NexusGeometry { namespace detail { TubeBuilder::TubeBuilder(const Mantid::Geometry::IObject &pixelShape, - Eigen::Vector3d firstDetectorPosition, + const Eigen::Vector3d &firstDetectorPosition, int firstDetectorId) : m_pixelHeight(pixelShape.getGeometryHandler()->shapeInfo().height()), m_pixelRadius(pixelShape.getGeometryHandler()->shapeInfo().radius()) { diff --git a/Framework/Parallel/inc/MantidParallel/IO/EventLoader.h b/Framework/Parallel/inc/MantidParallel/IO/EventLoader.h index ccda1bfe2ec2b103f4ac7bef9fec4ba41c26b2e8..a058a511b4d0f1f3cd19a4f66b1f7369197d7acb 100644 --- a/Framework/Parallel/inc/MantidParallel/IO/EventLoader.h +++ b/Framework/Parallel/inc/MantidParallel/IO/EventLoader.h @@ -37,13 +37,13 @@ MANTID_PARALLEL_DLL void load(const Communicator &communicator, const std::string &filename, const std::string &groupName, const std::vector<std::string> &bankNames, const std::vector<int32_t> &bankOffsets, - std::vector<std::vector<Types::Event::TofEvent> *> eventLists); + const std::vector<std::vector<Types::Event::TofEvent> *> &eventLists); MANTID_PARALLEL_DLL void load(const std::string &filename, const std::string &groupName, const std::vector<std::string> &bankNames, const std::vector<int32_t> &bankOffsets, - std::vector<std::vector<Types::Event::TofEvent> *> eventLists, + const std::vector<std::vector<Types::Event::TofEvent> *> &eventLists, bool precalcEvents); } // namespace EventLoader diff --git a/Framework/Parallel/inc/MantidParallel/IO/EventLoaderHelpers.h b/Framework/Parallel/inc/MantidParallel/IO/EventLoaderHelpers.h index 866894d4c5af6fd6f8a70f42f01e649d9b8664d2..9e0ff90110544551a05dd823c17027b7bc79537e 100644 --- a/Framework/Parallel/inc/MantidParallel/IO/EventLoaderHelpers.h +++ b/Framework/Parallel/inc/MantidParallel/IO/EventLoaderHelpers.h @@ -76,10 +76,11 @@ void load(const Chunker &chunker, NXEventDataSource<TimeOffsetType> &dataSource, } template <class TimeOffsetType> -void load(const Communicator &comm, const H5::Group &group, - const std::vector<std::string> &bankNames, - const std::vector<int32_t> &bankOffsets, - std::vector<std::vector<Types::Event::TofEvent> *> eventLists) { +void load( + const Communicator &comm, const H5::Group &group, + const std::vector<std::string> &bankNames, + const std::vector<int32_t> &bankOffsets, + const std::vector<std::vector<Types::Event::TofEvent> *> &eventLists) { // In tests loading from a single SSD this chunk size seems close to the // optimum. May need to be adjusted in the future (potentially dynamically) // when loading from parallel file systems and running on a cluster. diff --git a/Framework/Parallel/src/Communicator.cpp b/Framework/Parallel/src/Communicator.cpp index 0d8f458daf9a8a12ca7c52bb10aef1e7db2d2bcb..6e44485b03cc0773e16639103f149128527e969d 100644 --- a/Framework/Parallel/src/Communicator.cpp +++ b/Framework/Parallel/src/Communicator.cpp @@ -4,6 +4,8 @@ // NScD Oak Ridge National Laboratory, European Spallation Source, // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + +#include <utility> + #include "MantidParallel/Communicator.h" #ifdef MPI_EXPERIMENTAL @@ -24,7 +26,7 @@ Communicator::Communicator(const boost::mpi::communicator &comm) Communicator::Communicator(boost::shared_ptr<detail::ThreadingBackend> backend, const int rank) - : m_backend(backend), m_rank(rank) {} + : m_backend(std::move(backend)), m_rank(rank) {} int Communicator::rank() const { if (m_backend) diff --git a/Framework/Parallel/src/IO/EventLoader.cpp b/Framework/Parallel/src/IO/EventLoader.cpp index 170795e68bb4db3e63b3951df0e83d8e0993070e..a4a0ba4641aa8ddf72bd277d992a46da5b1f8278 100644 --- a/Framework/Parallel/src/IO/EventLoader.cpp +++ b/Framework/Parallel/src/IO/EventLoader.cpp @@ -45,11 +45,11 @@ makeAnyEventIdToBankMap(const std::string &filename, } /// Load events from given banks into event lists using MPI. -void load(const Communicator &comm, const std::string &filename, - const std::string &groupName, - const std::vector<std::string> &bankNames, - const std::vector<int32_t> &bankOffsets, - std::vector<std::vector<Types::Event::TofEvent> *> eventLists) { +void load( + const Communicator &comm, const std::string &filename, + const std::string &groupName, const std::vector<std::string> &bankNames, + const std::vector<int32_t> &bankOffsets, + const std::vector<std::vector<Types::Event::TofEvent> *> &eventLists) { H5::H5File file(filename, H5F_ACC_RDONLY); H5::Group group = file.openGroup(groupName); load(readDataType(group, bankNames, "event_time_offset"), comm, group, @@ -60,7 +60,7 @@ void load(const Communicator &comm, const std::string &filename, void load(const std::string &filename, const std::string &groupname, const std::vector<std::string> &bankNames, const std::vector<int32_t> &bankOffsets, - std::vector<std::vector<Types::Event::TofEvent> *> eventLists, + const std::vector<std::vector<Types::Event::TofEvent> *> &eventLists, bool precalcEvents) { auto concurencyNumber = PARALLEL_GET_MAX_THREADS; auto numThreads = std::max<int>(concurencyNumber / 2, 1); diff --git a/Framework/PythonInterface/mantid/api/src/Exports/AlgorithmHistory.cpp b/Framework/PythonInterface/mantid/api/src/Exports/AlgorithmHistory.cpp index 03a7faa6ae71c64cb9aebe4f406d55a587cf26f4..f45dc113d3dc90b82666184de2d443d2470be767 100644 --- a/Framework/PythonInterface/mantid/api/src/Exports/AlgorithmHistory.cpp +++ b/Framework/PythonInterface/mantid/api/src/Exports/AlgorithmHistory.cpp @@ -27,7 +27,7 @@ using namespace boost::python; * @returns A python list created from the set of child algorithm histories */ boost::python::list -getChildrenAsList(boost::shared_ptr<AlgorithmHistory> self) { +getChildrenAsList(const boost::shared_ptr<AlgorithmHistory> &self) { boost::python::list names; const auto histories = self->getChildHistories(); for (const auto &history : histories) { diff --git a/Framework/PythonInterface/mantid/api/src/Exports/AlgorithmObserver.cpp b/Framework/PythonInterface/mantid/api/src/Exports/AlgorithmObserver.cpp index d42b9dd3121ae389ec978da825f19e7da051030d..867fcfa855f781f3293036d69aea563a63c6a2c3 100644 --- a/Framework/PythonInterface/mantid/api/src/Exports/AlgorithmObserver.cpp +++ b/Framework/PythonInterface/mantid/api/src/Exports/AlgorithmObserver.cpp @@ -14,22 +14,23 @@ using namespace Mantid::API; using namespace Mantid::PythonInterface; using namespace boost::python; -void observeFinish(AlgorithmObserver &self, boost::python::object alg) { +void observeFinish(AlgorithmObserver &self, const boost::python::object &alg) { IAlgorithm_sptr &calg = boost::python::extract<IAlgorithm_sptr &>(alg); self.observeFinish(calg); } -void observeError(AlgorithmObserver &self, boost::python::object alg) { +void observeError(AlgorithmObserver &self, const boost::python::object &alg) { IAlgorithm_sptr &calg = boost::python::extract<IAlgorithm_sptr &>(alg); self.observeError(calg); } -void observeProgress(AlgorithmObserver &self, boost::python::object alg) { +void observeProgress(AlgorithmObserver &self, + const boost::python::object &alg) { IAlgorithm_sptr &calg = boost::python::extract<IAlgorithm_sptr &>(alg); self.observeProgress(calg); } -void stopObserving(AlgorithmObserver &self, boost::python::object alg) { +void stopObserving(AlgorithmObserver &self, const boost::python::object &alg) { IAlgorithm_sptr &calg = boost::python::extract<IAlgorithm_sptr &>(alg); self.stopObserving(calg); } diff --git a/Framework/PythonInterface/mantid/api/src/Exports/FileFinder.cpp b/Framework/PythonInterface/mantid/api/src/Exports/FileFinder.cpp index 867883010c07206c96df29e236350489308e119d..b03273526f03c7319b213b730ff96175d69be391 100644 --- a/Framework/PythonInterface/mantid/api/src/Exports/FileFinder.cpp +++ b/Framework/PythonInterface/mantid/api/src/Exports/FileFinder.cpp @@ -39,7 +39,8 @@ GNU_DIAG_ON("unused-local-typedef") * combination of exts_list and facility_exts. */ std::vector<std::string> runFinderProxy(FileFinderImpl &self, - std::string hintstr, list exts_list, + const std::string &hintstr, + list exts_list, const bool useExtsOnly) { // Convert python list to c++ vector std::vector<std::string> exts; diff --git a/Framework/PythonInterface/mantid/api/src/Exports/IPeaksWorkspace.cpp b/Framework/PythonInterface/mantid/api/src/Exports/IPeaksWorkspace.cpp index e5245a9dc57d7a5ab08390f7c6c418602886d589..2817282c22a6f4eb76c0244630cee66a2481032c 100644 --- a/Framework/PythonInterface/mantid/api/src/Exports/IPeaksWorkspace.cpp +++ b/Framework/PythonInterface/mantid/api/src/Exports/IPeaksWorkspace.cpp @@ -16,6 +16,7 @@ #include <boost/python/iterator.hpp> #include <boost/python/manage_new_object.hpp> #include <boost/python/return_internal_reference.hpp> +#include <utility> using namespace boost::python; using namespace Mantid::Geometry; @@ -102,7 +103,7 @@ public: throw std::runtime_error(columnName + " is a read only column of a peaks workspace"); } - m_setterMap[columnName](peak, value); + m_setterMap[columnName](peak, std::move(value)); } private: @@ -122,7 +123,7 @@ private: * setter's value type */ template <typename T> SetterType setterFunction(MemberFunc<T> func) { - return [func](IPeak &peak, const object value) { + return [func](IPeak &peak, const object &value) { extract<T> extractor{value}; if (!extractor.check()) { throw std::runtime_error( @@ -143,7 +144,7 @@ private: * setter's value type */ SetterType setterFunction(MemberFuncV3D func) { - return [func](IPeak &peak, const object value) { + return [func](IPeak &peak, const object &value) { extract<const V3D &> extractor{value}; if (!extractor.check()) { throw std::runtime_error( diff --git a/Framework/PythonInterface/mantid/api/src/Exports/ITableWorkspace.cpp b/Framework/PythonInterface/mantid/api/src/Exports/ITableWorkspace.cpp index deaa6bd6c3d466b4adb6c90410f001b1312e4fc7..e2bf4e2c7df6e19541d7a5b324d59385cc38edae 100644 --- a/Framework/PythonInterface/mantid/api/src/Exports/ITableWorkspace.cpp +++ b/Framework/PythonInterface/mantid/api/src/Exports/ITableWorkspace.cpp @@ -82,7 +82,7 @@ namespace { * @param typeID The python identifier of the column type. * @param row The row to get the value from. */ -PyObject *getValue(Mantid::API::Column_const_sptr column, +PyObject *getValue(const Mantid::API::Column_const_sptr &column, const std::type_info &typeID, const int row) { if (typeID.hash_code() == typeid(Mantid::API::Boolean).hash_code()) { bool res = column->cell<Mantid::API::Boolean>(row); @@ -129,7 +129,7 @@ PyObject *getValue(Mantid::API::Column_const_sptr column, * @param row :: The index of the row * @param value :: The value to set */ -void setValue(const Column_sptr column, const int row, const object &value) { +void setValue(const Column_sptr &column, const int row, const object &value) { const auto &typeID = column->get_type_info(); // Special case: Treat Mantid Boolean as normal bool @@ -542,7 +542,7 @@ public: return data; } - static void setstate(ITableWorkspace &ws, dict state) { + static void setstate(ITableWorkspace &ws, const dict &state) { readMetaData(ws, state); readData(ws, state); } diff --git a/Framework/PythonInterface/mantid/api/src/Exports/Run.cpp b/Framework/PythonInterface/mantid/api/src/Exports/Run.cpp index 86e71d566f2421aa2344ef38143eb10094339f54..1a7e17e2221e264269fef95550ce39d5af8e889c 100644 --- a/Framework/PythonInterface/mantid/api/src/Exports/Run.cpp +++ b/Framework/PythonInterface/mantid/api/src/Exports/Run.cpp @@ -16,6 +16,7 @@ #include <boost/python/list.hpp> #include <boost/python/overloads.hpp> #include <boost/python/register_ptr_to_python.hpp> +#include <utility> using Mantid::API::LogManager; using Mantid::API::Run; @@ -103,7 +104,7 @@ void addOrReplaceProperty(Run &self, const std::string &name, * @param key The key * @param default_ The default to return if it does not exist */ -bpl::object getWithDefault(bpl::object self, bpl::object key, +bpl::object getWithDefault(bpl::object self, const bpl::object &key, bpl::object default_) { bpl::object exists(self.attr("__contains__")); if (extract<bool>(exists(key))()) { @@ -119,8 +120,8 @@ bpl::object getWithDefault(bpl::object self, bpl::object key, * @param self The bpl::object called on * @param key The key */ -bpl::object get(bpl::object self, bpl::object key) { - return getWithDefault(self, key, bpl::object()); +bpl::object get(bpl::object self, const bpl::object &key) { + return getWithDefault(std::move(self), std::move(key), bpl::object()); } /** diff --git a/Framework/PythonInterface/mantid/api/src/Exports/SpectrumInfo.cpp b/Framework/PythonInterface/mantid/api/src/Exports/SpectrumInfo.cpp index 2191b63476bdea9805b258c28c4103754d39473c..1c23af6e39416ca7d1dae00963e6e48bddd50144 100644 --- a/Framework/PythonInterface/mantid/api/src/Exports/SpectrumInfo.cpp +++ b/Framework/PythonInterface/mantid/api/src/Exports/SpectrumInfo.cpp @@ -76,5 +76,7 @@ void export_SpectrumInfo() { .def("getSpectrumDefinition", &SpectrumInfo::spectrumDefinition, return_value_policy<return_by_value>(), (arg("self"), arg("index")), "Returns the SpectrumDefinition of the spectrum with the given " - "index."); + "index.") + .def("detectorCount", &SpectrumInfo::detectorCount, arg("self"), + "Returns the total number of detectors used across spectrum info."); } diff --git a/Framework/PythonInterface/mantid/api/src/Exports/SpectrumInfoItem.cpp b/Framework/PythonInterface/mantid/api/src/Exports/SpectrumInfoItem.cpp index bb294ed960006533d1759c7a71cb72bd195da917..2b2dd604232966c98631a55b655c92b599dab0b9 100644 --- a/Framework/PythonInterface/mantid/api/src/Exports/SpectrumInfoItem.cpp +++ b/Framework/PythonInterface/mantid/api/src/Exports/SpectrumInfoItem.cpp @@ -27,6 +27,8 @@ void export_SpectrumInfoItem() { .add_property("signedTwoTheta", &SpectrumInfoItem<SpectrumInfo>::signedTwoTheta) .add_property("l2", &SpectrumInfoItem<SpectrumInfo>::l2) + .add_property("hasDetectors", + &SpectrumInfoItem<SpectrumInfo>::hasDetectors) .add_property("hasUniqueDetector", &SpectrumInfoItem<SpectrumInfo>::hasUniqueDetector) .add_property( diff --git a/Framework/PythonInterface/mantid/api/src/FitFunctions/IFunctionAdapter.cpp b/Framework/PythonInterface/mantid/api/src/FitFunctions/IFunctionAdapter.cpp index 6428d5c8bd162ceddbed655fa74f46658ab566a0..bda56715c423d33730655f195409509e39a039fd 100644 --- a/Framework/PythonInterface/mantid/api/src/FitFunctions/IFunctionAdapter.cpp +++ b/Framework/PythonInterface/mantid/api/src/FitFunctions/IFunctionAdapter.cpp @@ -10,6 +10,7 @@ #include <boost/python/class.hpp> #include <boost/python/list.hpp> +#include <utility> #define PY_ARRAY_UNIQUE_SYMBOL API_ARRAY_API #define NO_IMPORT_ARRAY @@ -80,7 +81,7 @@ IFunction::Attribute createAttributeFromPythonValue(const object &value) { IFunctionAdapter::IFunctionAdapter(PyObject *self, std::string functionMethod, std::string derivMethod) : m_self(self), m_functionName(std::move(functionMethod)), - m_derivName(derivMethod), + m_derivName(std::move(derivMethod)), m_derivOveridden(typeHasAttribute(self, m_derivName.c_str())) { if (!typeHasAttribute(self, "init")) throw std::runtime_error("Function does not define an init method."); diff --git a/Framework/PythonInterface/mantid/geometry/src/Exports/UnitCell.cpp b/Framework/PythonInterface/mantid/geometry/src/Exports/UnitCell.cpp index a2880c72ca7c4cb6d93555f4ab3318fad0e334b6..5811c325eb7e6364637075a26812bf233f720a9a 100644 --- a/Framework/PythonInterface/mantid/geometry/src/Exports/UnitCell.cpp +++ b/Framework/PythonInterface/mantid/geometry/src/Exports/UnitCell.cpp @@ -30,7 +30,7 @@ namespace //<unnamed> using namespace Mantid::PythonInterface; /// Pass-through function to set the unit cell from a 2D numpy array -void recalculateFromGstar(UnitCell &self, object values) { +void recalculateFromGstar(UnitCell &self, const object &values) { // Create a double matrix and put this in to the unit cell self.recalculateFromGstar(Converters::PyObjectToMatrix(values)()); } diff --git a/Framework/PythonInterface/mantid/kernel/src/Exports/ArrayProperty.cpp b/Framework/PythonInterface/mantid/kernel/src/Exports/ArrayProperty.cpp index 9fdb7d3f4cd22398b724503ab734259c2bf80093..0c904dd32a933aaabfafa7ac1c29fad7989cdcf0 100644 --- a/Framework/PythonInterface/mantid/kernel/src/Exports/ArrayProperty.cpp +++ b/Framework/PythonInterface/mantid/kernel/src/Exports/ArrayProperty.cpp @@ -114,7 +114,7 @@ template <> std::string dtype(ArrayProperty<std::string> &self) { template <typename T> ArrayProperty<T> *createArrayPropertyFromList(const std::string &name, const boost::python::list &values, - IValidator_sptr validator, + const IValidator_sptr &validator, const unsigned int direction) { return new ArrayProperty<T>(name, Converters::PySequenceToVector<T>(values)(), validator, direction); @@ -130,10 +130,10 @@ ArrayProperty<T> *createArrayPropertyFromList(const std::string &name, * @return */ template <typename T> -ArrayProperty<T> *createArrayPropertyFromNDArray(const std::string &name, - const NDArray &values, - IValidator_sptr validator, - const unsigned int direction) { +ArrayProperty<T> * +createArrayPropertyFromNDArray(const std::string &name, const NDArray &values, + const IValidator_sptr &validator, + const unsigned int direction) { return new ArrayProperty<T>(name, Converters::NDArrayToVector<T>(values)(), validator, direction); } diff --git a/Framework/PythonInterface/mantid/kernel/src/Exports/CompositeValidator.cpp b/Framework/PythonInterface/mantid/kernel/src/Exports/CompositeValidator.cpp index f2cc1cb0d7b112b144dda737a21f40db740ff381..685993a4f756f33f3aac3547f919d69b1258b328 100644 --- a/Framework/PythonInterface/mantid/kernel/src/Exports/CompositeValidator.cpp +++ b/Framework/PythonInterface/mantid/kernel/src/Exports/CompositeValidator.cpp @@ -52,7 +52,7 @@ void export_CompositeValidator() { &createCompositeValidator, default_call_policies(), (arg("validators"), arg("relation") = CompositeRelation::AND))) .def("add", - (void (CompositeValidator::*)(IValidator_sptr)) & + (void (CompositeValidator::*)(const IValidator_sptr &)) & CompositeValidator::add, (arg("self"), arg("other")), "Add another validator to the list"); } diff --git a/Framework/PythonInterface/mantid/kernel/src/Exports/IPropertyManager.cpp b/Framework/PythonInterface/mantid/kernel/src/Exports/IPropertyManager.cpp index 0ff4fb1eb7532d28a903c9c5bbb7dc9c27eaf99f..ebff49089ca1d8169b915cb0698789548fd5e6fc 100644 --- a/Framework/PythonInterface/mantid/kernel/src/Exports/IPropertyManager.cpp +++ b/Framework/PythonInterface/mantid/kernel/src/Exports/IPropertyManager.cpp @@ -76,7 +76,7 @@ void setProperties(IPropertyManager &self, const boost::python::dict &kwargs) { * @param value :: The value of the property as a bpl object */ void declareProperty(IPropertyManager &self, const std::string &name, - boost::python::object value) { + const boost::python::object &value) { auto p = std::unique_ptr<Property>( Registry::PropertyWithValueFactory::create(name, value, 0)); self.declareProperty(std::move(p)); @@ -91,7 +91,7 @@ void declareProperty(IPropertyManager &self, const std::string &name, * @param value :: The value of the property as a bpl object */ void declareOrSetProperty(IPropertyManager &self, const std::string &name, - boost::python::object value) { + const boost::python::object &value) { bool propExists = self.existsProperty(name); if (propExists) { setProperty(self, name, value); diff --git a/Framework/PythonInterface/test/python/mantid/api/SpectrumInfoTest.py b/Framework/PythonInterface/test/python/mantid/api/SpectrumInfoTest.py index 4dcd6cf7638815092678d28b67bb946b255006e5..bcaee8d1ab35ec74ff46275f60457a9a5e5723c7 100644 --- a/Framework/PythonInterface/test/python/mantid/api/SpectrumInfoTest.py +++ b/Framework/PythonInterface/test/python/mantid/api/SpectrumInfoTest.py @@ -40,6 +40,13 @@ class SpectrumInfoTest(unittest.TestCase): info = self._ws.spectrumInfo() self.assertEqual(info.size(), 3) + def test_detectorCount(self): + """ Check total detector count """ + info = self._ws.spectrumInfo() + # One detector cleared. So not counted. + self.assertEqual(info.detectorCount(), 2) + + def test_isMonitor(self): """ Check if a monitor is present. """ info = self._ws.spectrumInfo() diff --git a/Framework/RemoteJobManagers/inc/MantidRemoteJobManagers/MantidWebServiceAPIHelper.h b/Framework/RemoteJobManagers/inc/MantidRemoteJobManagers/MantidWebServiceAPIHelper.h index cd27ba638b825bfda16c4efd09b25b90268205db..118dd2fc36bdc8c21ed36d3b94333a20a8abe63f 100644 --- a/Framework/RemoteJobManagers/inc/MantidRemoteJobManagers/MantidWebServiceAPIHelper.h +++ b/Framework/RemoteJobManagers/inc/MantidRemoteJobManagers/MantidWebServiceAPIHelper.h @@ -82,13 +82,13 @@ public: private: // Wraps up some of the boilerplate code needed to execute HTTP GET and POST // requests - void initGetRequest(Poco::Net::HTTPRequest &req, std::string extraPath, - std::string queryString) const; + void initGetRequest(Poco::Net::HTTPRequest &req, const std::string &extraPath, + const std::string &queryString) const; void initPostRequest(Poco::Net::HTTPRequest &req, - std::string extraPath) const; + const std::string &extraPath) const; void initHTTPRequest(Poco::Net::HTTPRequest &req, const std::string &method, - std::string extraPath, - std::string queryString = "") const; + const std::string &extraPath, + const std::string &queryString = "") const; std::string m_displayName; std::string diff --git a/Framework/RemoteJobManagers/src/MantidWebServiceAPIHelper.cpp b/Framework/RemoteJobManagers/src/MantidWebServiceAPIHelper.cpp index 25308d73222e5331b0f1c947fd20c5d2a44c8a8e..1c45bfde63d45f7c1423886a236ed51585e05919 100644 --- a/Framework/RemoteJobManagers/src/MantidWebServiceAPIHelper.cpp +++ b/Framework/RemoteJobManagers/src/MantidWebServiceAPIHelper.cpp @@ -19,6 +19,7 @@ #include <ostream> #include <sstream> +#include <utility> namespace Mantid { namespace RemoteJobManagers { @@ -169,22 +170,22 @@ void MantidWebServiceAPIHelper::clearSessionCookies() { g_cookies.clear(); } // Wrappers for a lot of the boilerplate code needed to perform an HTTPS GET or // POST -void MantidWebServiceAPIHelper::initGetRequest(Poco::Net::HTTPRequest &req, - std::string extraPath, - std::string queryString) const { - return initHTTPRequest(req, Poco::Net::HTTPRequest::HTTP_GET, extraPath, - queryString); +void MantidWebServiceAPIHelper::initGetRequest( + Poco::Net::HTTPRequest &req, const std::string &extraPath, + const std::string &queryString) const { + return initHTTPRequest(req, Poco::Net::HTTPRequest::HTTP_GET, + std::move(extraPath), std::move(queryString)); } -void MantidWebServiceAPIHelper::initPostRequest(Poco::Net::HTTPRequest &req, - std::string extraPath) const { - return initHTTPRequest(req, Poco::Net::HTTPRequest::HTTP_POST, extraPath); +void MantidWebServiceAPIHelper::initPostRequest( + Poco::Net::HTTPRequest &req, const std::string &extraPath) const { + return initHTTPRequest(req, Poco::Net::HTTPRequest::HTTP_POST, + std::move(extraPath)); } -void MantidWebServiceAPIHelper::initHTTPRequest(Poco::Net::HTTPRequest &req, - const std::string &method, - std::string extraPath, - std::string queryString) const { +void MantidWebServiceAPIHelper::initHTTPRequest( + Poco::Net::HTTPRequest &req, const std::string &method, + const std::string &extraPath, const std::string &queryString) const { // Set up the session object m_session.reset(); diff --git a/Framework/SINQ/inc/MantidSINQ/InvertMDDim.h b/Framework/SINQ/inc/MantidSINQ/InvertMDDim.h index 29a5ffca558c41c034824eb9a3528825a530be92..dfc7952fa123e2d3442d251f84bc63f836805a7e 100644 --- a/Framework/SINQ/inc/MantidSINQ/InvertMDDim.h +++ b/Framework/SINQ/inc/MantidSINQ/InvertMDDim.h @@ -44,13 +44,14 @@ private: /// Execution code void exec() override; - void copyMetaData(Mantid::API::IMDHistoWorkspace_sptr inws, - Mantid::API::IMDHistoWorkspace_sptr outws); - void recurseDim(Mantid::API::IMDHistoWorkspace_sptr inWS, - Mantid::API::IMDHistoWorkspace_sptr outWS, int currentDim, - int *idx, int rank); + void copyMetaData(const Mantid::API::IMDHistoWorkspace_sptr &inws, + const Mantid::API::IMDHistoWorkspace_sptr &outws); + void recurseDim(const Mantid::API::IMDHistoWorkspace_sptr &inWS, + const Mantid::API::IMDHistoWorkspace_sptr &outWS, + int currentDim, int *idx, int rank); - unsigned int calcIndex(Mantid::API::IMDHistoWorkspace_sptr ws, int *dim); - unsigned int calcInvertedIndex(Mantid::API::IMDHistoWorkspace_sptr ws, + unsigned int calcIndex(const Mantid::API::IMDHistoWorkspace_sptr &ws, + int *dim); + unsigned int calcInvertedIndex(const Mantid::API::IMDHistoWorkspace_sptr &ws, int *dim); }; diff --git a/Framework/SINQ/inc/MantidSINQ/LoadFlexiNexus.h b/Framework/SINQ/inc/MantidSINQ/LoadFlexiNexus.h index a1085680de8d3e8c10cf7ddbfbca703537c2ba93..297e47d74371c1b88506abb45774c52b78986a4e 100644 --- a/Framework/SINQ/inc/MantidSINQ/LoadFlexiNexus.h +++ b/Framework/SINQ/inc/MantidSINQ/LoadFlexiNexus.h @@ -64,7 +64,7 @@ private: // A dictionary std::map<std::string, std::string> dictionary; - void loadDictionary(std::string dictionaryFile); + void loadDictionary(const std::string &dictionaryFile); void load2DWorkspace(NeXus::File *fin); @@ -80,10 +80,10 @@ private: std::unordered_set<std::string> populateSpecialMap(); - void addMetaData(NeXus::File *fin, Mantid::API::Workspace_sptr ws, - Mantid::API::ExperimentInfo_sptr info); + void addMetaData(NeXus::File *fin, const Mantid::API::Workspace_sptr &ws, + const Mantid::API::ExperimentInfo_sptr &info); - int safeOpenpath(NeXus::File *fin, std::string path); + int safeOpenpath(NeXus::File *fin, const std::string &path); int calculateCAddress(int *pos, int *dim, int rank); int calculateF77Address(int *pos, int rank); }; diff --git a/Framework/SINQ/inc/MantidSINQ/MDHistoToWorkspace2D.h b/Framework/SINQ/inc/MantidSINQ/MDHistoToWorkspace2D.h index b45e7d312e573de0388d4ee2984d9527ad748a80..b2890b897d05589c0d2df1e427172966b49581ed 100644 --- a/Framework/SINQ/inc/MantidSINQ/MDHistoToWorkspace2D.h +++ b/Framework/SINQ/inc/MantidSINQ/MDHistoToWorkspace2D.h @@ -51,13 +51,13 @@ private: size_t m_rank; size_t m_currentSpectra; - size_t calculateNSpectra(Mantid::API::IMDHistoWorkspace_sptr inws); - void recurseData(Mantid::API::IMDHistoWorkspace_sptr inWS, - Mantid::DataObjects::Workspace2D_sptr outWS, + size_t calculateNSpectra(const Mantid::API::IMDHistoWorkspace_sptr &inws); + void recurseData(const Mantid::API::IMDHistoWorkspace_sptr &inWS, + const Mantid::DataObjects::Workspace2D_sptr &outWS, size_t currentDim, Mantid::coord_t *pos); - void checkW2D(Mantid::DataObjects::Workspace2D_sptr outWS); + void checkW2D(const Mantid::DataObjects::Workspace2D_sptr &outWS); - void copyMetaData(Mantid::API::IMDHistoWorkspace_sptr inWS, - Mantid::DataObjects::Workspace2D_sptr outWS); + void copyMetaData(const Mantid::API::IMDHistoWorkspace_sptr &inWS, + const Mantid::DataObjects::Workspace2D_sptr &outWS); }; diff --git a/Framework/SINQ/inc/MantidSINQ/PoldiAutoCorrelation5.h b/Framework/SINQ/inc/MantidSINQ/PoldiAutoCorrelation5.h index fe59f3c42104eedd92d1581a1f5e60a6f3320a53..e4ac09f9774751cd4d5808021694b06d8fd72a14 100644 --- a/Framework/SINQ/inc/MantidSINQ/PoldiAutoCorrelation5.h +++ b/Framework/SINQ/inc/MantidSINQ/PoldiAutoCorrelation5.h @@ -59,8 +59,8 @@ protected: void exec() override; void logConfigurationInformation( - boost::shared_ptr<PoldiDeadWireDecorator> cleanDetector, - PoldiAbstractChopper_sptr chopper); + const boost::shared_ptr<PoldiDeadWireDecorator> &cleanDetector, + const PoldiAbstractChopper_sptr &chopper); private: /// Overwrites Algorithm method. diff --git a/Framework/SINQ/inc/MantidSINQ/PoldiFitPeaks1D.h b/Framework/SINQ/inc/MantidSINQ/PoldiFitPeaks1D.h index 9bc3749470e2cba475049086f8da5b1262b52096..444ff42d500887bad3084f21c478eb521c21e5df 100644 --- a/Framework/SINQ/inc/MantidSINQ/PoldiFitPeaks1D.h +++ b/Framework/SINQ/inc/MantidSINQ/PoldiFitPeaks1D.h @@ -43,9 +43,10 @@ protected: API::IFunction_sptr getPeakProfile(const PoldiPeak_sptr &poldiPeak) const; void - setValuesFromProfileFunction(PoldiPeak_sptr poldiPeak, + setValuesFromProfileFunction(const PoldiPeak_sptr &poldiPeak, const API::IFunction_sptr &fittedFunction) const; - double getFwhmWidthRelation(API::IPeakFunction_sptr peakFunction) const; + double + getFwhmWidthRelation(const API::IPeakFunction_sptr &peakFunction) const; API::IAlgorithm_sptr getFitAlgorithm(const DataObjects::Workspace2D_sptr &dataWorkspace, diff --git a/Framework/SINQ/inc/MantidSINQ/PoldiFitPeaks1D2.h b/Framework/SINQ/inc/MantidSINQ/PoldiFitPeaks1D2.h index 895e1d514b7cd1cf0753c1a0e448e29def6de708..65138c4e17f01c7f84aca9fb7cf94428e7e57c81 100644 --- a/Framework/SINQ/inc/MantidSINQ/PoldiFitPeaks1D2.h +++ b/Framework/SINQ/inc/MantidSINQ/PoldiFitPeaks1D2.h @@ -106,10 +106,11 @@ protected: API::IFunction_sptr getPeakProfile(const PoldiPeak_sptr &poldiPeak) const; void - setValuesFromProfileFunction(PoldiPeak_sptr poldiPeak, + setValuesFromProfileFunction(const PoldiPeak_sptr &poldiPeak, const API::IFunction_sptr &fittedFunction) const; - double getFwhmWidthRelation(API::IPeakFunction_sptr peakFunction) const; + double + getFwhmWidthRelation(const API::IPeakFunction_sptr &peakFunction) const; API::IAlgorithm_sptr getFitAlgorithm(const DataObjects::Workspace2D_sptr &dataWorkspace, diff --git a/Framework/SINQ/inc/MantidSINQ/PoldiFitPeaks2D.h b/Framework/SINQ/inc/MantidSINQ/PoldiFitPeaks2D.h index e9394f8cc54e3b40a3a44651e994bdc105a7e133..62d7459d1f00dedabb4bb2b05521b8af5bdb981e 100644 --- a/Framework/SINQ/inc/MantidSINQ/PoldiFitPeaks2D.h +++ b/Framework/SINQ/inc/MantidSINQ/PoldiFitPeaks2D.h @@ -75,7 +75,7 @@ protected: // Conversion between peaks and functions PoldiPeak_sptr - getPeakFromPeakFunction(API::IPeakFunction_sptr profileFunction, + getPeakFromPeakFunction(const API::IPeakFunction_sptr &profileFunction, const Kernel::V3D &hkl); // Conversion between peak collections and functions @@ -83,11 +83,11 @@ protected: getFunctionFromPeakCollection(const PoldiPeakCollection_sptr &peakCollection); Poldi2DFunction_sptr getFunctionIndividualPeaks( - std::string profileFunctionName, + const std::string &profileFunctionName, const PoldiPeakCollection_sptr &peakCollection) const; Poldi2DFunction_sptr - getFunctionPawley(std::string profileFunctionName, + getFunctionPawley(const std::string &profileFunctionName, const PoldiPeakCollection_sptr &peakCollection); std::string getLatticeSystemFromPointGroup( @@ -131,7 +131,7 @@ protected: API::IFunction_sptr getFunction(const API::IAlgorithm_sptr &fitAlgorithm) const; - void addBackgroundTerms(Poldi2DFunction_sptr poldi2DFunction) const; + void addBackgroundTerms(const Poldi2DFunction_sptr &poldi2DFunction) const; boost::shared_ptr<Kernel::DblMatrix> getLocalCovarianceMatrix( const boost::shared_ptr<const Kernel::DblMatrix> &covarianceMatrix, diff --git a/Framework/SINQ/inc/MantidSINQ/PoldiPeakSearch.h b/Framework/SINQ/inc/MantidSINQ/PoldiPeakSearch.h index 3c3da954772bc2dacab76882ffbd2fecd51e6513..b308644161e3bd327100ab51ff690c4684a6656b 100644 --- a/Framework/SINQ/inc/MantidSINQ/PoldiPeakSearch.h +++ b/Framework/SINQ/inc/MantidSINQ/PoldiPeakSearch.h @@ -62,16 +62,17 @@ protected: MantidVec::const_iterator baseDataStart, MantidVec::const_iterator originalDataStart) const; - UncertainValue - getBackgroundWithSigma(std::list<MantidVec::const_iterator> peakPositions, - const MantidVec &correlationCounts) const; - MantidVec getBackground(std::list<MantidVec::const_iterator> peakPositions, - const MantidVec &correlationCounts) const; + UncertainValue getBackgroundWithSigma( + const std::list<MantidVec::const_iterator> &peakPositions, + const MantidVec &correlationCounts) const; + MantidVec + getBackground(const std::list<MantidVec::const_iterator> &peakPositions, + const MantidVec &correlationCounts) const; bool distanceToPeaksGreaterThanMinimum( std::list<MantidVec::const_iterator> peakPositions, MantidVec::const_iterator point) const; size_t getNumberOfBackgroundPoints( - std::list<MantidVec::const_iterator> peakPositions, + const std::list<MantidVec::const_iterator> &peakPositions, const MantidVec &correlationCounts) const; double getMedianFromSortedVector(MantidVec::const_iterator begin, @@ -95,8 +96,9 @@ protected: MantidVec::const_iterator peakPosition, const MantidVec &xData) const; - void setErrorsOnWorkspace(DataObjects::Workspace2D_sptr correlationWorkspace, - double error) const; + void setErrorsOnWorkspace( + const DataObjects::Workspace2D_sptr &correlationWorkspace, + double error) const; void setMinimumDistance(int newMinimumDistance); void setMinimumPeakHeight(double newMinimumPeakHeight); @@ -104,7 +106,7 @@ protected: static bool vectorElementGreaterThan(MantidVec::const_iterator first, MantidVec::const_iterator second); - bool isLessThanMinimum(PoldiPeak_sptr peak); + bool isLessThanMinimum(const PoldiPeak_sptr &peak); int m_minimumDistance; int m_doubleMinimumDistance; diff --git a/Framework/SINQ/inc/MantidSINQ/PoldiTruncateData.h b/Framework/SINQ/inc/MantidSINQ/PoldiTruncateData.h index f14d9889ead38fb03658d9128a5e1d34e0a1f70f..da2b9ecd3a72aab3141415d2106cc49edbce7359 100644 --- a/Framework/SINQ/inc/MantidSINQ/PoldiTruncateData.h +++ b/Framework/SINQ/inc/MantidSINQ/PoldiTruncateData.h @@ -42,10 +42,12 @@ public: size_t getActualBinCount(); protected: - void setChopperFromWorkspace(API::MatrixWorkspace_const_sptr workspace); + void + setChopperFromWorkspace(const API::MatrixWorkspace_const_sptr &workspace); void setChopper(PoldiAbstractChopper_sptr chopper); - void setTimeBinWidthFromWorkspace(API::MatrixWorkspace_const_sptr workspace); + void setTimeBinWidthFromWorkspace( + const API::MatrixWorkspace_const_sptr &workspace); void setTimeBinWidth(double timeBinWidth); void setActualBinCount(size_t actualBinCount); @@ -58,16 +60,17 @@ protected: getExtraCountsWorkspace(API::MatrixWorkspace_sptr workspace); API::MatrixWorkspace_sptr - getWorkspaceBelowX(API::MatrixWorkspace_sptr workspace, double x); + getWorkspaceBelowX(const API::MatrixWorkspace_sptr &workspace, double x); API::MatrixWorkspace_sptr - getWorkspaceAboveX(API::MatrixWorkspace_sptr workspace, double x); + getWorkspaceAboveX(const API::MatrixWorkspace_sptr &workspace, double x); API::Algorithm_sptr - getCropAlgorithmForWorkspace(API::MatrixWorkspace_sptr workspace); - API::MatrixWorkspace_sptr getOutputWorkspace(API::Algorithm_sptr algorithm); + getCropAlgorithmForWorkspace(const API::MatrixWorkspace_sptr &workspace); + API::MatrixWorkspace_sptr + getOutputWorkspace(const API::Algorithm_sptr &algorithm); API::MatrixWorkspace_sptr - getSummedSpectra(API::MatrixWorkspace_sptr workspace); + getSummedSpectra(const API::MatrixWorkspace_sptr &workspace); PoldiAbstractChopper_sptr m_chopper; double m_timeBinWidth; diff --git a/Framework/SINQ/inc/MantidSINQ/PoldiUtilities/PoldiDeadWireDecorator.h b/Framework/SINQ/inc/MantidSINQ/PoldiUtilities/PoldiDeadWireDecorator.h index ac6673891119074ae990a8354a41e399cdcb7b3a..83f317de25e440e0daeeb7ea89c225d17656a9c9 100644 --- a/Framework/SINQ/inc/MantidSINQ/PoldiUtilities/PoldiDeadWireDecorator.h +++ b/Framework/SINQ/inc/MantidSINQ/PoldiUtilities/PoldiDeadWireDecorator.h @@ -30,12 +30,14 @@ namespace Poldi { */ class MANTID_SINQ_DLL PoldiDeadWireDecorator : public PoldiDetectorDecorator { public: - PoldiDeadWireDecorator(std::set<int> deadWires, - boost::shared_ptr<PoldiAbstractDetector> detector = - boost::shared_ptr<PoldiAbstractDetector>()); - PoldiDeadWireDecorator(const Geometry::DetectorInfo &poldiDetectorInfo, - boost::shared_ptr<PoldiAbstractDetector> detector = - boost::shared_ptr<PoldiAbstractDetector>()); + PoldiDeadWireDecorator( + std::set<int> deadWires, + const boost::shared_ptr<PoldiAbstractDetector> &detector = + boost::shared_ptr<PoldiAbstractDetector>()); + PoldiDeadWireDecorator( + const Geometry::DetectorInfo &poldiDetectorInfo, + const boost::shared_ptr<PoldiAbstractDetector> &detector = + boost::shared_ptr<PoldiAbstractDetector>()); void setDeadWires(std::set<int> deadWires); std::set<int> deadWires(); diff --git a/Framework/SINQ/inc/MantidSINQ/PoldiUtilities/PoldiPeakCollection.h b/Framework/SINQ/inc/MantidSINQ/PoldiUtilities/PoldiPeakCollection.h index 993afd00cdbad2f08d6eeeefa40c189ff0e9abdd..04d41ccbd40393a7fd0f80557628f6a33291ec61 100644 --- a/Framework/SINQ/inc/MantidSINQ/PoldiUtilities/PoldiPeakCollection.h +++ b/Framework/SINQ/inc/MantidSINQ/PoldiUtilities/PoldiPeakCollection.h @@ -84,7 +84,7 @@ protected: std::string getUnitCellStringFromLog(const API::LogManager_sptr &tableLog); std::string getStringValueFromLog(const API::LogManager_sptr &logManager, - std::string valueName); + const std::string &valueName); std::string intensityTypeToString(IntensityType type) const; IntensityType intensityTypeFromString(std::string typeString) const; diff --git a/Framework/SINQ/inc/MantidSINQ/PoldiUtilities/PoldiSourceSpectrum.h b/Framework/SINQ/inc/MantidSINQ/PoldiUtilities/PoldiSourceSpectrum.h index 7b99555b3422b660e42cb5fc4d0815787b01926e..66c3592715d91f916e94108d633e62c998fe54e2 100644 --- a/Framework/SINQ/inc/MantidSINQ/PoldiUtilities/PoldiSourceSpectrum.h +++ b/Framework/SINQ/inc/MantidSINQ/PoldiUtilities/PoldiSourceSpectrum.h @@ -27,19 +27,19 @@ namespace Poldi { class MANTID_SINQ_DLL PoldiSourceSpectrum { public: - PoldiSourceSpectrum(Kernel::Interpolation spectrum); - PoldiSourceSpectrum(Geometry::Instrument_const_sptr poldiInstrument); + PoldiSourceSpectrum(const Kernel::Interpolation &spectrum); + PoldiSourceSpectrum(const Geometry::Instrument_const_sptr &poldiInstrument); double intensity(double wavelength) const; protected: - void - setSpectrumFromInstrument(Geometry::Instrument_const_sptr poldiInstrument); + void setSpectrumFromInstrument( + const Geometry::Instrument_const_sptr &poldiInstrument); Geometry::IComponent_const_sptr - getSourceComponent(Geometry::Instrument_const_sptr poldiInstrument); - Geometry::Parameter_sptr - getSpectrumParameter(Geometry::IComponent_const_sptr source, - Geometry::ParameterMap_sptr instrumentParameterMap); - void setSpectrum(Geometry::Parameter_sptr spectrumParameter); + getSourceComponent(const Geometry::Instrument_const_sptr &poldiInstrument); + Geometry::Parameter_sptr getSpectrumParameter( + const Geometry::IComponent_const_sptr &source, + const Geometry::ParameterMap_sptr &instrumentParameterMap); + void setSpectrum(const Geometry::Parameter_sptr &spectrumParameter); Kernel::Interpolation m_spectrum; }; diff --git a/Framework/SINQ/inc/MantidSINQ/ProjectMD.h b/Framework/SINQ/inc/MantidSINQ/ProjectMD.h index 59cc9aaf6ba02b217c17d5276200463b84e238e3..76bb71579a5e3ca29bf25faceab3094c0445f1e2 100644 --- a/Framework/SINQ/inc/MantidSINQ/ProjectMD.h +++ b/Framework/SINQ/inc/MantidSINQ/ProjectMD.h @@ -43,14 +43,16 @@ private: /// Execution code void exec() override; - void copyMetaData(Mantid::API::IMDHistoWorkspace_sptr inws, - Mantid::API::IMDHistoWorkspace_sptr outws); - void sumData(Mantid::API::IMDHistoWorkspace_sptr inws, - Mantid::API::IMDHistoWorkspace_sptr outws, int *sourceDim, + void copyMetaData(const Mantid::API::IMDHistoWorkspace_sptr &inws, + const Mantid::API::IMDHistoWorkspace_sptr &outws); + void sumData(const Mantid::API::IMDHistoWorkspace_sptr &inws, + const Mantid::API::IMDHistoWorkspace_sptr &outws, int *sourceDim, int *targetDim, int targetDimCount, int dimNo, int start, int end, int currentDim); - double getValue(Mantid::API::IMDHistoWorkspace_sptr ws, int *dim); - void putValue(Mantid::API::IMDHistoWorkspace_sptr ws, int *dim, double val); - unsigned int calcIndex(Mantid::API::IMDHistoWorkspace_sptr ws, int *dim); + double getValue(const Mantid::API::IMDHistoWorkspace_sptr &ws, int *dim); + void putValue(const Mantid::API::IMDHistoWorkspace_sptr &ws, int *dim, + double val); + unsigned int calcIndex(const Mantid::API::IMDHistoWorkspace_sptr &ws, + int *dim); }; diff --git a/Framework/SINQ/inc/MantidSINQ/SINQHMListener.h b/Framework/SINQ/inc/MantidSINQ/SINQHMListener.h index f5e8fb77406c68eb2cb897181cf7ded323699aca..1c3fa22862425614163c54f1f78620da73bea308 100644 --- a/Framework/SINQ/inc/MantidSINQ/SINQHMListener.h +++ b/Framework/SINQ/inc/MantidSINQ/SINQHMListener.h @@ -52,11 +52,11 @@ private: int dim[3]; // @SINQ we only do 3D HM's, change when more dimensions std::string hmhost; - std::istream &httpRequest(std::string path); + std::istream &httpRequest(const std::string &path); void loadDimensions(); void doSpecialDim(); - void readHMData(Mantid::API::IMDHistoWorkspace_sptr ws); - void recurseDim(int *data, Mantid::API::IMDHistoWorkspace_sptr ws, + void readHMData(const Mantid::API::IMDHistoWorkspace_sptr &ws); + void recurseDim(int *data, const Mantid::API::IMDHistoWorkspace_sptr &ws, int currentDim, Mantid::coord_t *idx); int calculateCAddress(Mantid::coord_t *pos); diff --git a/Framework/SINQ/inc/MantidSINQ/SINQTranspose3D.h b/Framework/SINQ/inc/MantidSINQ/SINQTranspose3D.h index 69c24e6415dc11a0ea2ebacd3f4d6a30822b8e68..0c64ce7aefb3dd3a90a9dc8325f055a6b6ec2acf 100644 --- a/Framework/SINQ/inc/MantidSINQ/SINQTranspose3D.h +++ b/Framework/SINQ/inc/MantidSINQ/SINQTranspose3D.h @@ -54,11 +54,11 @@ private: /// Execution code void exec() override; - void doYXZ(Mantid::API::IMDHistoWorkspace_sptr inws); - void doXZY(Mantid::API::IMDHistoWorkspace_sptr inws); - void doTRICS(Mantid::API::IMDHistoWorkspace_sptr inws); - void doAMOR(Mantid::API::IMDHistoWorkspace_sptr inws); + void doYXZ(const Mantid::API::IMDHistoWorkspace_sptr &inws); + void doXZY(const Mantid::API::IMDHistoWorkspace_sptr &inws); + void doTRICS(const Mantid::API::IMDHistoWorkspace_sptr &inws); + void doAMOR(const Mantid::API::IMDHistoWorkspace_sptr &inws); - void copyMetaData(Mantid::API::IMDHistoWorkspace_sptr inws, - Mantid::API::IMDHistoWorkspace_sptr outws); + void copyMetaData(const Mantid::API::IMDHistoWorkspace_sptr &inws, + const Mantid::API::IMDHistoWorkspace_sptr &outws); }; diff --git a/Framework/SINQ/inc/MantidSINQ/SliceMDHisto.h b/Framework/SINQ/inc/MantidSINQ/SliceMDHisto.h index 7d3e390ff64babfcde342497cbb75b83931b1bfb..22a30baf55d69410b323a508d369ddd82b8f677b 100644 --- a/Framework/SINQ/inc/MantidSINQ/SliceMDHisto.h +++ b/Framework/SINQ/inc/MantidSINQ/SliceMDHisto.h @@ -48,11 +48,11 @@ private: unsigned int m_rank; std::vector<int> m_dim; - void cutData(Mantid::API::IMDHistoWorkspace_sptr inWS, - Mantid::API::IMDHistoWorkspace_sptr outWS, + void cutData(const Mantid::API::IMDHistoWorkspace_sptr &inWS, + const Mantid::API::IMDHistoWorkspace_sptr &outWS, Mantid::coord_t *sourceDim, Mantid::coord_t *targetDim, std::vector<int> start, std::vector<int> end, unsigned int dim); - void copyMetaData(Mantid::API::IMDHistoWorkspace_sptr inws, - Mantid::API::IMDHistoWorkspace_sptr outws); + void copyMetaData(const Mantid::API::IMDHistoWorkspace_sptr &inws, + const Mantid::API::IMDHistoWorkspace_sptr &outws); }; diff --git a/Framework/SINQ/src/InvertMDDim.cpp b/Framework/SINQ/src/InvertMDDim.cpp index 428afdddea0060d24b328ea3f5281bfe54781534..f2d8e13a4bfc153f9deb29c531232d59f7f0fa8b 100644 --- a/Framework/SINQ/src/InvertMDDim.cpp +++ b/Framework/SINQ/src/InvertMDDim.cpp @@ -62,9 +62,9 @@ void InvertMDDim::exec() { setProperty("OutputWorkspace", outWS); } -void InvertMDDim::recurseDim(IMDHistoWorkspace_sptr inWS, - IMDHistoWorkspace_sptr outWS, int currentDim, - int *idx, int rank) { +void InvertMDDim::recurseDim(const IMDHistoWorkspace_sptr &inWS, + const IMDHistoWorkspace_sptr &outWS, + int currentDim, int *idx, int rank) { boost::shared_ptr<const IMDDimension> dimi = inWS->getDimension(currentDim); if (currentDim == rank - 1) { for (int i = 0; i < static_cast<int>(dimi->getNBins()); i++) { @@ -82,8 +82,9 @@ void InvertMDDim::recurseDim(IMDHistoWorkspace_sptr inWS, } } -void InvertMDDim::copyMetaData(Mantid::API::IMDHistoWorkspace_sptr inws, - Mantid::API::IMDHistoWorkspace_sptr outws) { +void InvertMDDim::copyMetaData( + const Mantid::API::IMDHistoWorkspace_sptr &inws, + const Mantid::API::IMDHistoWorkspace_sptr &outws) { outws->setTitle(inws->getTitle()); ExperimentInfo_sptr info; @@ -97,7 +98,8 @@ void InvertMDDim::copyMetaData(Mantid::API::IMDHistoWorkspace_sptr inws, * IMDHistoWorkspace. * I.e. a proper address calculation from an index array. */ -unsigned int InvertMDDim::calcIndex(IMDHistoWorkspace_sptr ws, int dim[]) { +unsigned int InvertMDDim::calcIndex(const IMDHistoWorkspace_sptr &ws, + int dim[]) { size_t idx = 0; switch (ws->getNumDims()) { case 2: @@ -115,7 +117,7 @@ unsigned int InvertMDDim::calcIndex(IMDHistoWorkspace_sptr ws, int dim[]) { return static_cast<unsigned int>(idx); } -unsigned int InvertMDDim::calcInvertedIndex(IMDHistoWorkspace_sptr ws, +unsigned int InvertMDDim::calcInvertedIndex(const IMDHistoWorkspace_sptr &ws, int dim[]) { size_t idx = 0; switch (ws->getNumDims()) { diff --git a/Framework/SINQ/src/LoadFlexiNexus.cpp b/Framework/SINQ/src/LoadFlexiNexus.cpp index 50b92f5544d3a45f9d1bcd6f5cda819d90e77baa..48156e4a8e12f2e367f87d5738920be9bbe28325 100644 --- a/Framework/SINQ/src/LoadFlexiNexus.cpp +++ b/Framework/SINQ/src/LoadFlexiNexus.cpp @@ -71,7 +71,7 @@ void LoadFlexiNexus::exec() { readData(&fin); } -void LoadFlexiNexus::loadDictionary(std::string dictFile) { +void LoadFlexiNexus::loadDictionary(const std::string &dictFile) { std::ifstream in(dictFile.c_str(), std::ifstream::in); std::string line, key, value; @@ -312,8 +312,8 @@ MDHistoDimension_sptr LoadFlexiNexus::makeDimension(NeXus::File *fin, int index, return MDHistoDimension_sptr( new MDHistoDimension(name, name, frame, min, max, length)); } -void LoadFlexiNexus::addMetaData(NeXus::File *fin, Workspace_sptr ws, - ExperimentInfo_sptr info) { +void LoadFlexiNexus::addMetaData(NeXus::File *fin, const Workspace_sptr &ws, + const ExperimentInfo_sptr &info) { std::map<std::string, std::string>::const_iterator it; // assign a title @@ -404,7 +404,7 @@ std::unordered_set<std::string> LoadFlexiNexus::populateSpecialMap() { return specialMap; } -int LoadFlexiNexus::safeOpenpath(NeXus::File *fin, std::string path) { +int LoadFlexiNexus::safeOpenpath(NeXus::File *fin, const std::string &path) { try { fin->openPath(path); } catch (NeXus::Exception &) { diff --git a/Framework/SINQ/src/MDHistoToWorkspace2D.cpp b/Framework/SINQ/src/MDHistoToWorkspace2D.cpp index db9f959ae21ed2c153f14930f3b40a8aa6ce4c00..e6761fdd99e7b63f393c87caefcaddd5209813af 100644 --- a/Framework/SINQ/src/MDHistoToWorkspace2D.cpp +++ b/Framework/SINQ/src/MDHistoToWorkspace2D.cpp @@ -85,7 +85,8 @@ void MDHistoToWorkspace2D::exec() { setProperty("OutputWorkspace", boost::dynamic_pointer_cast<Workspace>(outWS)); } -size_t MDHistoToWorkspace2D::calculateNSpectra(IMDHistoWorkspace_sptr inWS) { +size_t +MDHistoToWorkspace2D::calculateNSpectra(const IMDHistoWorkspace_sptr &inWS) { size_t nSpectra = 1; for (size_t i = 0; i < m_rank - 1; i++) { boost::shared_ptr<const IMDDimension> dim = inWS->getDimension(i); @@ -94,8 +95,8 @@ size_t MDHistoToWorkspace2D::calculateNSpectra(IMDHistoWorkspace_sptr inWS) { return nSpectra; } -void MDHistoToWorkspace2D::recurseData(IMDHistoWorkspace_sptr inWS, - Workspace2D_sptr outWS, +void MDHistoToWorkspace2D::recurseData(const IMDHistoWorkspace_sptr &inWS, + const Workspace2D_sptr &outWS, size_t currentDim, coord_t *pos) { boost::shared_ptr<const IMDDimension> dim = inWS->getDimension(currentDim); if (currentDim == m_rank - 1) { @@ -128,7 +129,7 @@ void MDHistoToWorkspace2D::recurseData(IMDHistoWorkspace_sptr inWS, } void MDHistoToWorkspace2D::checkW2D( - Mantid::DataObjects::Workspace2D_sptr outWS) { + const Mantid::DataObjects::Workspace2D_sptr &outWS) { size_t nSpectra = outWS->getNumberHistograms(); size_t length = outWS->blocksize(); @@ -155,8 +156,8 @@ void MDHistoToWorkspace2D::checkW2D( } void MDHistoToWorkspace2D::copyMetaData( - Mantid::API::IMDHistoWorkspace_sptr inWS, - Mantid::DataObjects::Workspace2D_sptr outWS) { + const Mantid::API::IMDHistoWorkspace_sptr &inWS, + const Mantid::DataObjects::Workspace2D_sptr &outWS) { if (inWS->getNumExperimentInfo() > 0) { ExperimentInfo_sptr info = inWS->getExperimentInfo(0); outWS->copyExperimentInfoFrom(info.get()); diff --git a/Framework/SINQ/src/PoldiAutoCorrelation5.cpp b/Framework/SINQ/src/PoldiAutoCorrelation5.cpp index b7ee1476624369e50fdf886f977a8086202eb2d1..f40f8a392dac42b9556986e82cf16e9d613c8764 100644 --- a/Framework/SINQ/src/PoldiAutoCorrelation5.cpp +++ b/Framework/SINQ/src/PoldiAutoCorrelation5.cpp @@ -113,8 +113,8 @@ void PoldiAutoCorrelation5::exec() { } void PoldiAutoCorrelation5::logConfigurationInformation( - boost::shared_ptr<PoldiDeadWireDecorator> cleanDetector, - PoldiAbstractChopper_sptr chopper) { + const boost::shared_ptr<PoldiDeadWireDecorator> &cleanDetector, + const PoldiAbstractChopper_sptr &chopper) { if (cleanDetector && chopper) { g_log.information() << "____________________________________________________ \n"; diff --git a/Framework/SINQ/src/PoldiFitPeaks1D.cpp b/Framework/SINQ/src/PoldiFitPeaks1D.cpp index b44a2547d45898a89fd82baa28015349690a2a77..f0cecc14250bdba3708a53bdad4ed853c306735c 100644 --- a/Framework/SINQ/src/PoldiFitPeaks1D.cpp +++ b/Framework/SINQ/src/PoldiFitPeaks1D.cpp @@ -113,7 +113,8 @@ PoldiFitPeaks1D::getPeakProfile(const PoldiPeak_sptr &poldiPeak) const { } void PoldiFitPeaks1D::setValuesFromProfileFunction( - PoldiPeak_sptr poldiPeak, const IFunction_sptr &fittedFunction) const { + const PoldiPeak_sptr &poldiPeak, + const IFunction_sptr &fittedFunction) const { CompositeFunction_sptr totalFunction = boost::dynamic_pointer_cast<CompositeFunction>(fittedFunction); @@ -134,8 +135,8 @@ void PoldiFitPeaks1D::setValuesFromProfileFunction( } } -double -PoldiFitPeaks1D::getFwhmWidthRelation(IPeakFunction_sptr peakFunction) const { +double PoldiFitPeaks1D::getFwhmWidthRelation( + const IPeakFunction_sptr &peakFunction) const { return peakFunction->fwhm() / peakFunction->getParameter(2); } diff --git a/Framework/SINQ/src/PoldiFitPeaks1D2.cpp b/Framework/SINQ/src/PoldiFitPeaks1D2.cpp index 257516171d67a4e8ad818c0a7170e2489fd19fdc..c6a97a0dc4b502eae13ae9d2bbc7ca659811bf0a 100644 --- a/Framework/SINQ/src/PoldiFitPeaks1D2.cpp +++ b/Framework/SINQ/src/PoldiFitPeaks1D2.cpp @@ -256,7 +256,8 @@ PoldiFitPeaks1D2::getPeakProfile(const PoldiPeak_sptr &poldiPeak) const { } void PoldiFitPeaks1D2::setValuesFromProfileFunction( - PoldiPeak_sptr poldiPeak, const IFunction_sptr &fittedFunction) const { + const PoldiPeak_sptr &poldiPeak, + const IFunction_sptr &fittedFunction) const { IPeakFunction_sptr peakFunction = boost::dynamic_pointer_cast<IPeakFunction>(fittedFunction); @@ -271,8 +272,8 @@ void PoldiFitPeaks1D2::setValuesFromProfileFunction( } } -double -PoldiFitPeaks1D2::getFwhmWidthRelation(IPeakFunction_sptr peakFunction) const { +double PoldiFitPeaks1D2::getFwhmWidthRelation( + const IPeakFunction_sptr &peakFunction) const { return peakFunction->fwhm() / peakFunction->getParameter(2); } diff --git a/Framework/SINQ/src/PoldiFitPeaks2D.cpp b/Framework/SINQ/src/PoldiFitPeaks2D.cpp index adb481bed87cd41ccc024aa3a4d6d4f8eeac0b2f..e9456e9734ba633b341f9539f2499f1b8d8cd22f 100644 --- a/Framework/SINQ/src/PoldiFitPeaks2D.cpp +++ b/Framework/SINQ/src/PoldiFitPeaks2D.cpp @@ -381,9 +381,8 @@ PoldiPeakCollection_sptr PoldiFitPeaks2D::getCountPeakCollection( } /// Creates a PoldiPeak from the given profile function/hkl pair. -PoldiPeak_sptr -PoldiFitPeaks2D::getPeakFromPeakFunction(IPeakFunction_sptr profileFunction, - const V3D &hkl) { +PoldiPeak_sptr PoldiFitPeaks2D::getPeakFromPeakFunction( + const IPeakFunction_sptr &profileFunction, const V3D &hkl) { // Use EstimatePeakErrors to calculate errors of FWHM and so on IAlgorithm_sptr errorAlg = createChildAlgorithm("EstimatePeakErrors"); @@ -466,7 +465,7 @@ Poldi2DFunction_sptr PoldiFitPeaks2D::getFunctionFromPeakCollection( * @return :: A Poldi2DFunction with peak profile functions. */ Poldi2DFunction_sptr PoldiFitPeaks2D::getFunctionIndividualPeaks( - std::string profileFunctionName, + const std::string &profileFunctionName, const PoldiPeakCollection_sptr &peakCollection) const { auto mdFunction = boost::make_shared<Poldi2DFunction>(); @@ -519,7 +518,7 @@ Poldi2DFunction_sptr PoldiFitPeaks2D::getFunctionIndividualPeaks( * @return :: A Poldi2DFunction with a PawleyFunction. */ Poldi2DFunction_sptr PoldiFitPeaks2D::getFunctionPawley( - std::string profileFunctionName, + const std::string &profileFunctionName, const PoldiPeakCollection_sptr &peakCollection) { auto mdFunction = boost::make_shared<Poldi2DFunction>(); @@ -1048,7 +1047,7 @@ PoldiFitPeaks2D::getFunction(const IAlgorithm_sptr &fitAlgorithm) const { * @param poldi2DFunction :: Poldi2DFunction to which the background is added. */ void PoldiFitPeaks2D::addBackgroundTerms( - Poldi2DFunction_sptr poldi2DFunction) const { + const Poldi2DFunction_sptr &poldi2DFunction) const { bool addConstantBackground = getProperty("FitConstantBackground"); if (addConstantBackground) { IFunction_sptr constantBackground = diff --git a/Framework/SINQ/src/PoldiPeakSearch.cpp b/Framework/SINQ/src/PoldiPeakSearch.cpp index 930825f230d07d88259ef490b1eca878ddd19441..6c4dc2453266eda129f6a7bb313db2c27664f847 100644 --- a/Framework/SINQ/src/PoldiPeakSearch.cpp +++ b/Framework/SINQ/src/PoldiPeakSearch.cpp @@ -22,6 +22,7 @@ #include <list> #include <numeric> #include <queue> +#include <utility> #include "boost/math/distributions.hpp" @@ -314,7 +315,7 @@ PoldiPeakSearch::getFWHMEstimate(const MantidVec::const_iterator &baseListStart, * @param error :: Error that is set on the workspace. */ void PoldiPeakSearch::setErrorsOnWorkspace( - Workspace2D_sptr correlationWorkspace, double error) const { + const Workspace2D_sptr &correlationWorkspace, double error) const { MantidVec &errors = correlationWorkspace->dataE(0); std::fill(errors.begin(), errors.end(), error); @@ -332,7 +333,7 @@ void PoldiPeakSearch::setErrorsOnWorkspace( * @return Vector only with counts that belong to the background. */ MantidVec PoldiPeakSearch::getBackground( - std::list<MantidVec::const_iterator> peakPositions, + const std::list<MantidVec::const_iterator> &peakPositions, const MantidVec &correlationCounts) const { size_t backgroundPoints = getNumberOfBackgroundPoints(peakPositions, correlationCounts); @@ -366,9 +367,10 @@ MantidVec PoldiPeakSearch::getBackground( * @return Background estimation with error. */ UncertainValue PoldiPeakSearch::getBackgroundWithSigma( - std::list<MantidVec::const_iterator> peakPositions, + const std::list<MantidVec::const_iterator> &peakPositions, const MantidVec &correlationCounts) const { - MantidVec background = getBackground(peakPositions, correlationCounts); + MantidVec background = + getBackground(std::move(peakPositions), correlationCounts); /* Instead of using Mean and Standard deviation, which are appropriate * for data originating from a normal distribution (which is not the case @@ -420,7 +422,7 @@ bool PoldiPeakSearch::distanceToPeaksGreaterThanMinimum( * @return Number of background points. */ size_t PoldiPeakSearch::getNumberOfBackgroundPoints( - std::list<MantidVec::const_iterator> peakPositions, + const std::list<MantidVec::const_iterator> &peakPositions, const MantidVec &correlationCounts) const { /* subtracting 2, to match original algorithm, where * the first and the last point of the spectrum are not @@ -528,7 +530,7 @@ bool PoldiPeakSearch::vectorElementGreaterThan( return *first > *second; } -bool PoldiPeakSearch::isLessThanMinimum(PoldiPeak_sptr peak) { +bool PoldiPeakSearch::isLessThanMinimum(const PoldiPeak_sptr &peak) { return peak->intensity().value() <= m_minimumPeakHeight; } diff --git a/Framework/SINQ/src/PoldiTruncateData.cpp b/Framework/SINQ/src/PoldiTruncateData.cpp index 9f22eb59d5bf863732a8be2a7284b779cdb10c13..e94235204433cbe22533dc07a9bd367c137a8c4b 100644 --- a/Framework/SINQ/src/PoldiTruncateData.cpp +++ b/Framework/SINQ/src/PoldiTruncateData.cpp @@ -4,8 +4,10 @@ // NScD Oak Ridge National Laboratory, European Spallation Source, // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + -#include "MantidSINQ/PoldiTruncateData.h" +#include <utility> + #include "MantidAPI/MatrixWorkspace.h" +#include "MantidSINQ/PoldiTruncateData.h" #include "MantidSINQ/PoldiUtilities/PoldiInstrumentAdapter.h" namespace Mantid { @@ -44,7 +46,7 @@ const std::string PoldiTruncateData::summary() const { *definition and log. */ void PoldiTruncateData::setChopperFromWorkspace( - MatrixWorkspace_const_sptr workspace) { + const MatrixWorkspace_const_sptr &workspace) { PoldiInstrumentAdapter poldiInstrument(workspace); setChopper(poldiInstrument.chopper()); } @@ -54,7 +56,7 @@ void PoldiTruncateData::setChopperFromWorkspace( * @param chopper :: POLDI chopper compatible with the measurement. */ void PoldiTruncateData::setChopper(PoldiAbstractChopper_sptr chopper) { - m_chopper = chopper; + m_chopper = std::move(chopper); } /** Extracts timing information from the given MatrixWorkspace. @@ -68,7 +70,7 @@ void PoldiTruncateData::setChopper(PoldiAbstractChopper_sptr chopper) { * @param workspace :: Workspace with POLDI data */ void PoldiTruncateData::setTimeBinWidthFromWorkspace( - MatrixWorkspace_const_sptr workspace) { + const MatrixWorkspace_const_sptr &workspace) { if (!workspace || workspace->getNumberHistograms() < 1) { throw std::invalid_argument( "Workspace does not contain any data. Aborting."); @@ -233,7 +235,7 @@ MatrixWorkspace_sptr PoldiTruncateData::getCroppedWorkspace(MatrixWorkspace_sptr workspace) { double maximumXValue = getMaximumTimeValue(getCalculatedBinCount()); - return getWorkspaceBelowX(workspace, maximumXValue); + return getWorkspaceBelowX(std::move(workspace), maximumXValue); } /** Returns a MatrixWorkspace with all extra counts @@ -260,7 +262,7 @@ MatrixWorkspace_sptr PoldiTruncateData::getExtraCountsWorkspace(MatrixWorkspace_sptr workspace) { double minimumXValue = getMinimumExtraTimeValue(getCalculatedBinCount()); MatrixWorkspace_sptr croppedOutput = - getWorkspaceAboveX(workspace, minimumXValue); + getWorkspaceAboveX(std::move(workspace), minimumXValue); return getSummedSpectra(croppedOutput); } @@ -272,9 +274,9 @@ PoldiTruncateData::getExtraCountsWorkspace(MatrixWorkspace_sptr workspace) { * @return MatrixWorkspace cropped to values with x < specified limit. */ MatrixWorkspace_sptr -PoldiTruncateData::getWorkspaceBelowX(MatrixWorkspace_sptr workspace, +PoldiTruncateData::getWorkspaceBelowX(const MatrixWorkspace_sptr &workspace, double x) { - Algorithm_sptr crop = getCropAlgorithmForWorkspace(workspace); + Algorithm_sptr crop = getCropAlgorithmForWorkspace(std::move(workspace)); crop->setProperty("XMax", x); return getOutputWorkspace(crop); @@ -288,9 +290,9 @@ PoldiTruncateData::getWorkspaceBelowX(MatrixWorkspace_sptr workspace, * @return MatrixWorkspace cropped to values with x >= specified limit. */ MatrixWorkspace_sptr -PoldiTruncateData::getWorkspaceAboveX(MatrixWorkspace_sptr workspace, +PoldiTruncateData::getWorkspaceAboveX(const MatrixWorkspace_sptr &workspace, double x) { - Algorithm_sptr crop = getCropAlgorithmForWorkspace(workspace); + Algorithm_sptr crop = getCropAlgorithmForWorkspace(std::move(workspace)); crop->setProperty("Xmin", x); return getOutputWorkspace(crop); @@ -307,7 +309,7 @@ PoldiTruncateData::getWorkspaceAboveX(MatrixWorkspace_sptr workspace, * @return Pointer to crop algorithm. */ Algorithm_sptr PoldiTruncateData::getCropAlgorithmForWorkspace( - MatrixWorkspace_sptr workspace) { + const MatrixWorkspace_sptr &workspace) { Algorithm_sptr crop = createChildAlgorithm("CropWorkspace"); if (!crop) { @@ -328,7 +330,7 @@ Algorithm_sptr PoldiTruncateData::getCropAlgorithmForWorkspace( * @return MatrixWorkspace stored in algorithm's OutputWorkspace property. */ MatrixWorkspace_sptr -PoldiTruncateData::getOutputWorkspace(Algorithm_sptr algorithm) { +PoldiTruncateData::getOutputWorkspace(const Algorithm_sptr &algorithm) { if (!algorithm || !algorithm->execute()) { throw std::runtime_error("Workspace could not be retrieved successfully."); } @@ -346,7 +348,7 @@ PoldiTruncateData::getOutputWorkspace(Algorithm_sptr algorithm) { * @return MatrixWorkspace with one spectrum which contains all counts. */ MatrixWorkspace_sptr -PoldiTruncateData::getSummedSpectra(MatrixWorkspace_sptr workspace) { +PoldiTruncateData::getSummedSpectra(const MatrixWorkspace_sptr &workspace) { Algorithm_sptr sumSpectra = createChildAlgorithm("SumSpectra"); if (!sumSpectra) { diff --git a/Framework/SINQ/src/PoldiUtilities/PoldiDGrid.cpp b/Framework/SINQ/src/PoldiUtilities/PoldiDGrid.cpp index 976966e6eee064045994f63a78e22dd7d6d56d3e..d1dedab391ce2f57adb33ae2bd8833af46bf7b0d 100644 --- a/Framework/SINQ/src/PoldiUtilities/PoldiDGrid.cpp +++ b/Framework/SINQ/src/PoldiUtilities/PoldiDGrid.cpp @@ -4,8 +4,10 @@ // NScD Oak Ridge National Laboratory, European Spallation Source, // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + -#include "MantidSINQ/PoldiUtilities/PoldiDGrid.h" +#include <utility> + #include "MantidSINQ/PoldiUtilities/PoldiConversions.h" +#include "MantidSINQ/PoldiUtilities/PoldiDGrid.h" namespace Mantid { namespace Poldi { @@ -13,18 +15,19 @@ namespace Poldi { PoldiDGrid::PoldiDGrid(boost::shared_ptr<PoldiAbstractDetector> detector, boost::shared_ptr<PoldiAbstractChopper> chopper, double deltaT, std::pair<double, double> wavelengthRange) - : m_detector(detector), m_chopper(chopper), m_deltaT(deltaT), - m_wavelengthRange(wavelengthRange), m_dRangeAsMultiples(), m_deltaD(0.0), - m_dgrid(), m_hasCachedCalculation(false) {} + : m_detector(std::move(detector)), m_chopper(std::move(chopper)), + m_deltaT(deltaT), m_wavelengthRange(wavelengthRange), + m_dRangeAsMultiples(), m_deltaD(0.0), m_dgrid(), + m_hasCachedCalculation(false) {} void PoldiDGrid::setDetector( boost::shared_ptr<PoldiAbstractDetector> newDetector) { - m_detector = newDetector; + m_detector = std::move(newDetector); } void PoldiDGrid::setChopper( boost::shared_ptr<PoldiAbstractChopper> newChopper) { - m_chopper = newChopper; + m_chopper = std::move(newChopper); } void PoldiDGrid::setDeltaT(double newDeltaT) { m_deltaT = newDeltaT; } diff --git a/Framework/SINQ/src/PoldiUtilities/PoldiDeadWireDecorator.cpp b/Framework/SINQ/src/PoldiUtilities/PoldiDeadWireDecorator.cpp index c8502b5d57a8981ae030edc436ae97d0f41de375..96a497e8d9977324e5734433008ffad608eb2ab4 100644 --- a/Framework/SINQ/src/PoldiUtilities/PoldiDeadWireDecorator.cpp +++ b/Framework/SINQ/src/PoldiUtilities/PoldiDeadWireDecorator.cpp @@ -8,6 +8,7 @@ #include "MantidGeometry/Instrument/DetectorInfo.h" #include <algorithm> +#include <utility> namespace Mantid { namespace Poldi { @@ -16,15 +17,15 @@ using namespace Geometry; PoldiDeadWireDecorator::PoldiDeadWireDecorator( std::set<int> deadWires, - boost::shared_ptr<Poldi::PoldiAbstractDetector> detector) - : PoldiDetectorDecorator(detector), m_deadWireSet(deadWires), + const boost::shared_ptr<Poldi::PoldiAbstractDetector> &detector) + : PoldiDetectorDecorator(detector), m_deadWireSet(std::move(deadWires)), m_goodElements() { setDecoratedDetector(detector); } PoldiDeadWireDecorator::PoldiDeadWireDecorator( const Geometry::DetectorInfo &poldiDetectorInfo, - boost::shared_ptr<PoldiAbstractDetector> detector) + const boost::shared_ptr<PoldiAbstractDetector> &detector) : PoldiDetectorDecorator(detector), m_deadWireSet(), m_goodElements() { setDecoratedDetector(detector); @@ -42,7 +43,7 @@ PoldiDeadWireDecorator::PoldiDeadWireDecorator( } void PoldiDeadWireDecorator::setDeadWires(std::set<int> deadWires) { - m_deadWireSet = deadWires; + m_deadWireSet = std::move(deadWires); detectorSetHook(); } diff --git a/Framework/SINQ/src/PoldiUtilities/PoldiDetectorDecorator.cpp b/Framework/SINQ/src/PoldiUtilities/PoldiDetectorDecorator.cpp index dabf81181a199c51cba5ce170593441ca4018447..62cf8b06a98fe7befe1dd74fc09f3e761f26ae0b 100644 --- a/Framework/SINQ/src/PoldiUtilities/PoldiDetectorDecorator.cpp +++ b/Framework/SINQ/src/PoldiUtilities/PoldiDetectorDecorator.cpp @@ -4,6 +4,8 @@ // NScD Oak Ridge National Laboratory, European Spallation Source, // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + +#include <utility> + #include "MantidSINQ/PoldiUtilities/PoldiDetectorDecorator.h" namespace Mantid { @@ -14,12 +16,12 @@ using namespace Geometry; PoldiDetectorDecorator::PoldiDetectorDecorator( boost::shared_ptr<PoldiAbstractDetector> decoratedDetector) : PoldiAbstractDetector(), m_decoratedDetector() { - setDecoratedDetector(decoratedDetector); + setDecoratedDetector(std::move(decoratedDetector)); } void PoldiDetectorDecorator::setDecoratedDetector( boost::shared_ptr<PoldiAbstractDetector> detector) { - m_decoratedDetector = detector; + m_decoratedDetector = std::move(detector); detectorSetHook(); } diff --git a/Framework/SINQ/src/PoldiUtilities/PoldiPeak.cpp b/Framework/SINQ/src/PoldiUtilities/PoldiPeak.cpp index da1dc71771324de85c17b2e10937e0553c47c493..8085d49146480f07fe6516eef95ed92b9eec3e05 100644 --- a/Framework/SINQ/src/PoldiUtilities/PoldiPeak.cpp +++ b/Framework/SINQ/src/PoldiUtilities/PoldiPeak.cpp @@ -8,6 +8,7 @@ #include <cmath> #include <stdexcept> +#include <utility> namespace Mantid { namespace Poldi { @@ -18,7 +19,7 @@ PoldiPeak_sptr PoldiPeak::clone() const { const MillerIndices &PoldiPeak::hkl() const { return m_hkl; } -void PoldiPeak::setHKL(MillerIndices hkl) { m_hkl = hkl; } +void PoldiPeak::setHKL(MillerIndices hkl) { m_hkl = std::move(hkl); } UncertainValue PoldiPeak::d() const { return m_d; } @@ -118,14 +119,16 @@ PoldiPeak_sptr PoldiPeak::create(double qValue, double intensity) { } PoldiPeak_sptr PoldiPeak::create(MillerIndices hkl, double dValue) { - return PoldiPeak_sptr(new PoldiPeak( - UncertainValue(dValue), UncertainValue(0.0), UncertainValue(0.0), hkl)); + return PoldiPeak_sptr(new PoldiPeak(UncertainValue(dValue), + UncertainValue(0.0), UncertainValue(0.0), + std::move(hkl))); } PoldiPeak_sptr PoldiPeak::create(MillerIndices hkl, UncertainValue dValue, UncertainValue intensity, UncertainValue fwhmRelative) { - return PoldiPeak_sptr(new PoldiPeak(dValue, intensity, fwhmRelative, hkl)); + return PoldiPeak_sptr( + new PoldiPeak(dValue, intensity, fwhmRelative, std::move(hkl))); } bool PoldiPeak::greaterThan(const PoldiPeak_sptr &first, @@ -144,7 +147,7 @@ bool PoldiPeak::lessThan(const PoldiPeak_sptr &first, PoldiPeak::PoldiPeak(UncertainValue d, UncertainValue intensity, UncertainValue fwhm, MillerIndices hkl) - : m_hkl(hkl), m_intensity(intensity) { + : m_hkl(std::move(hkl)), m_intensity(intensity) { setD(d); setFwhm(fwhm, Relative); } diff --git a/Framework/SINQ/src/PoldiUtilities/PoldiPeakCollection.cpp b/Framework/SINQ/src/PoldiUtilities/PoldiPeakCollection.cpp index 8217baa4b0346c1891301a0e69551452b37b0102..6eb5691a00f8039ad0669f70e3e705253a92b37b 100644 --- a/Framework/SINQ/src/PoldiUtilities/PoldiPeakCollection.cpp +++ b/Framework/SINQ/src/PoldiUtilities/PoldiPeakCollection.cpp @@ -4,11 +4,13 @@ // NScD Oak Ridge National Laboratory, European Spallation Source, // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + -#include "MantidSINQ/PoldiUtilities/PoldiPeakCollection.h" +#include <utility> + #include "MantidAPI/LogManager.h" #include "MantidAPI/TableRow.h" #include "MantidAPI/WorkspaceFactory.h" #include "MantidGeometry/Crystal/PointGroupFactory.h" +#include "MantidSINQ/PoldiUtilities/PoldiPeakCollection.h" #include "MantidGeometry/Crystal/ReflectionGenerator.h" @@ -97,7 +99,7 @@ PoldiPeakCollection::IntensityType PoldiPeakCollection::intensityType() const { void PoldiPeakCollection::setProfileFunctionName( std::string newProfileFunction) { - m_profileFunctionName = newProfileFunction; + m_profileFunctionName = std::move(newProfileFunction); } std::string PoldiPeakCollection::getProfileFunctionName() const { @@ -275,7 +277,7 @@ PoldiPeakCollection::getUnitCellStringFromLog(const LogManager_sptr &tableLog) { std::string PoldiPeakCollection::getStringValueFromLog(const LogManager_sptr &logManager, - std::string valueName) { + const std::string &valueName) { if (logManager->hasProperty(valueName)) { return logManager->getPropertyValueAsType<std::string>(valueName); } @@ -297,7 +299,7 @@ std::string PoldiPeakCollection::intensityTypeToString( PoldiPeakCollection::IntensityType PoldiPeakCollection::intensityTypeFromString(std::string typeString) const { - std::string lowerCaseType(typeString); + std::string lowerCaseType(std::move(typeString)); std::transform(lowerCaseType.begin(), lowerCaseType.end(), lowerCaseType.begin(), ::tolower); diff --git a/Framework/SINQ/src/PoldiUtilities/PoldiSourceSpectrum.cpp b/Framework/SINQ/src/PoldiUtilities/PoldiSourceSpectrum.cpp index 22c3345fe6972124a29d455eea8db8170efa428d..ea2be969a91e0c179a498d901e52ad5680fcb820 100644 --- a/Framework/SINQ/src/PoldiUtilities/PoldiSourceSpectrum.cpp +++ b/Framework/SINQ/src/PoldiUtilities/PoldiSourceSpectrum.cpp @@ -4,9 +4,11 @@ // NScD Oak Ridge National Laboratory, European Spallation Source, // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + -#include "MantidSINQ/PoldiUtilities/PoldiSourceSpectrum.h" +#include <utility> + #include "MantidGeometry/Instrument/FitParameter.h" #include "MantidGeometry/Instrument/ParameterMap.h" +#include "MantidSINQ/PoldiUtilities/PoldiSourceSpectrum.h" namespace Mantid { namespace Poldi { @@ -14,12 +16,13 @@ namespace Poldi { using namespace Mantid::Kernel; using namespace Mantid::Geometry; -PoldiSourceSpectrum::PoldiSourceSpectrum(Interpolation spectrum) +PoldiSourceSpectrum::PoldiSourceSpectrum(const Interpolation &spectrum) : m_spectrum(spectrum) {} -PoldiSourceSpectrum::PoldiSourceSpectrum(Instrument_const_sptr poldiInstrument) +PoldiSourceSpectrum::PoldiSourceSpectrum( + const Instrument_const_sptr &poldiInstrument) : m_spectrum() { - setSpectrumFromInstrument(poldiInstrument); + setSpectrumFromInstrument(std::move(poldiInstrument)); } /** Returns the interpolated intensity at the given wavelength @@ -43,7 +46,7 @@ double PoldiSourceSpectrum::intensity(double wavelength) const { *spectrum. */ void PoldiSourceSpectrum::setSpectrumFromInstrument( - Instrument_const_sptr poldiInstrument) { + const Instrument_const_sptr &poldiInstrument) { IComponent_const_sptr source = getSourceComponent(poldiInstrument); Parameter_sptr spectrumParameter = @@ -61,8 +64,8 @@ void PoldiSourceSpectrum::setSpectrumFromInstrument( * @param poldiInstrument :: Instrument with valid POLDI definition * @return Shared pointer to source component */ -IComponent_const_sptr -PoldiSourceSpectrum::getSourceComponent(Instrument_const_sptr poldiInstrument) { +IComponent_const_sptr PoldiSourceSpectrum::getSourceComponent( + const Instrument_const_sptr &poldiInstrument) { IComponent_const_sptr source = poldiInstrument->getComponentByName("source"); if (!source) { @@ -86,7 +89,8 @@ PoldiSourceSpectrum::getSourceComponent(Instrument_const_sptr poldiInstrument) { * @return Shared pointer to Parameter that contains the spectrum. */ Parameter_sptr PoldiSourceSpectrum::getSpectrumParameter( - IComponent_const_sptr source, ParameterMap_sptr instrumentParameterMap) { + const IComponent_const_sptr &source, + const ParameterMap_sptr &instrumentParameterMap) { Parameter_sptr spectrumParameter = instrumentParameterMap->getRecursive( &(*source), "WavelengthDistribution", "fitting"); @@ -107,7 +111,7 @@ Parameter_sptr PoldiSourceSpectrum::getSpectrumParameter( * @param spectrumParameter :: Shared pointer to fitting parameter with lookup *table */ -void PoldiSourceSpectrum::setSpectrum(Parameter_sptr spectrumParameter) { +void PoldiSourceSpectrum::setSpectrum(const Parameter_sptr &spectrumParameter) { if (!spectrumParameter) { throw std::runtime_error("Spectrum parameter pointer is null"); } diff --git a/Framework/SINQ/src/ProjectMD.cpp b/Framework/SINQ/src/ProjectMD.cpp index a2ab0ac2741d41bedbf7d3c5c846639f19f5914b..5036dbc5f360eb826742bff53a0320ba9316356f 100644 --- a/Framework/SINQ/src/ProjectMD.cpp +++ b/Framework/SINQ/src/ProjectMD.cpp @@ -89,8 +89,8 @@ void ProjectMD::exec() { // assign the workspace setProperty("OutputWorkspace", outWS); } -void ProjectMD::copyMetaData(Mantid::API::IMDHistoWorkspace_sptr inws, - Mantid::API::IMDHistoWorkspace_sptr outws) { +void ProjectMD::copyMetaData(const Mantid::API::IMDHistoWorkspace_sptr &inws, + const Mantid::API::IMDHistoWorkspace_sptr &outws) { outws->setTitle(inws->getTitle()); ExperimentInfo_sptr info; @@ -109,7 +109,7 @@ void ProjectMD::copyMetaData(Mantid::API::IMDHistoWorkspace_sptr inws, * The documentation actually suggest F77, the code too? * This isolates this from the storage order concern. */ -unsigned int ProjectMD::calcIndex(IMDHistoWorkspace_sptr ws, int dim[]) { +unsigned int ProjectMD::calcIndex(const IMDHistoWorkspace_sptr &ws, int dim[]) { size_t idx = 0; switch (ws->getNumDims()) { case 1: @@ -130,7 +130,7 @@ unsigned int ProjectMD::calcIndex(IMDHistoWorkspace_sptr ws, int dim[]) { return static_cast<unsigned int>(idx); } -double ProjectMD::getValue(IMDHistoWorkspace_sptr ws, int dim[]) { +double ProjectMD::getValue(const IMDHistoWorkspace_sptr &ws, int dim[]) { unsigned int idx = calcIndex(ws, dim); double val = ws->signalAt(idx); // double *a = ws->getSignalArray(); @@ -139,7 +139,8 @@ double ProjectMD::getValue(IMDHistoWorkspace_sptr ws, int dim[]) { // " << dim[1] << "," <<dim[2] <<'\n'; return val; } -void ProjectMD::putValue(IMDHistoWorkspace_sptr ws, int dim[], double value) { +void ProjectMD::putValue(const IMDHistoWorkspace_sptr &ws, int dim[], + double value) { unsigned int idx = calcIndex(ws, dim); // std::cout << "Result index " << idx << " value " << value << " dim= " << // dim[0] << ", " << dim[1] <<", " << dim[2] <<'\n'; @@ -147,8 +148,8 @@ void ProjectMD::putValue(IMDHistoWorkspace_sptr ws, int dim[], double value) { ws->setErrorSquaredAt(idx, value); } -void ProjectMD::sumData(IMDHistoWorkspace_sptr inWS, - IMDHistoWorkspace_sptr outWS, int *sourceDim, +void ProjectMD::sumData(const IMDHistoWorkspace_sptr &inWS, + const IMDHistoWorkspace_sptr &outWS, int *sourceDim, int *targetDim, int targetDimCount, int dimNo, int start, int end, int currentDim) { boost::shared_ptr<const IMDDimension> dimi; diff --git a/Framework/SINQ/src/SINQHMListener.cpp b/Framework/SINQ/src/SINQHMListener.cpp index 3e778b43f95bdf8e8969ce02aa32a5e10af63d66..58c876d60584a8f56c506c00d1daad52570aaee8 100644 --- a/Framework/SINQ/src/SINQHMListener.cpp +++ b/Framework/SINQ/src/SINQHMListener.cpp @@ -25,6 +25,7 @@ #include <Poco/StreamCopier.h> #include <boost/algorithm/string/trim.hpp> +#include <utility> using namespace Mantid::API; using namespace Mantid::DataObjects; @@ -165,7 +166,7 @@ void SINQHMListener::loadDimensions() { doSpecialDim(); } -std::istream &SINQHMListener::httpRequest(std::string path) { +std::istream &SINQHMListener::httpRequest(const std::string &path) { HTTPRequest req(HTTPRequest::HTTP_GET, path, HTTPMessage::HTTP_1_1); req.setKeepAlive(true); @@ -208,7 +209,7 @@ int SINQHMListener::calculateCAddress(coord_t *pos) { } return result; } -void SINQHMListener::recurseDim(int *data, IMDHistoWorkspace_sptr ws, +void SINQHMListener::recurseDim(int *data, const IMDHistoWorkspace_sptr &ws, int currentDim, coord_t *idx) { if (currentDim == rank) { int Cindex = calculateCAddress(idx); @@ -226,7 +227,7 @@ void SINQHMListener::recurseDim(int *data, IMDHistoWorkspace_sptr ws, } } -void SINQHMListener::readHMData(IMDHistoWorkspace_sptr ws) { +void SINQHMListener::readHMData(const IMDHistoWorkspace_sptr &ws) { int *data = nullptr, length = 1; coord_t *idx; @@ -256,7 +257,7 @@ void SINQHMListener::readHMData(IMDHistoWorkspace_sptr ws) { * why.... */ idx = reinterpret_cast<coord_t *>(malloc(rank * sizeof(coord_t))); - recurseDim(data, ws, 0, idx); + recurseDim(data, std::move(ws), 0, idx); free(data); free(idx); diff --git a/Framework/SINQ/src/SINQTranspose3D.cpp b/Framework/SINQ/src/SINQTranspose3D.cpp index 856019ec3b333993de83cab654d92ff889b042d0..82a4806b5372b335b0afea06db59aa31b8af763a 100644 --- a/Framework/SINQ/src/SINQTranspose3D.cpp +++ b/Framework/SINQ/src/SINQTranspose3D.cpp @@ -57,7 +57,7 @@ void SINQTranspose3D::exec() { } } -void SINQTranspose3D::doYXZ(IMDHistoWorkspace_sptr inWS) { +void SINQTranspose3D::doYXZ(const IMDHistoWorkspace_sptr &inWS) { size_t idxIn, idxOut; boost::shared_ptr<const IMDDimension> x, y, z; @@ -92,7 +92,7 @@ void SINQTranspose3D::doYXZ(IMDHistoWorkspace_sptr inWS) { setProperty("OutputWorkspace", outWS); } -void SINQTranspose3D::doXZY(IMDHistoWorkspace_sptr inWS) { +void SINQTranspose3D::doXZY(const IMDHistoWorkspace_sptr &inWS) { size_t idxIn, idxOut; unsigned int xdim, ydim, zdim; @@ -130,7 +130,7 @@ void SINQTranspose3D::doXZY(IMDHistoWorkspace_sptr inWS) { // assign the workspace setProperty("OutputWorkspace", outWS); } -void SINQTranspose3D::doTRICS(IMDHistoWorkspace_sptr inWS) { +void SINQTranspose3D::doTRICS(const IMDHistoWorkspace_sptr &inWS) { size_t idxIn, idxOut; unsigned int xdim, ydim, zdim; @@ -169,7 +169,7 @@ void SINQTranspose3D::doTRICS(IMDHistoWorkspace_sptr inWS) { // assign the workspace setProperty("OutputWorkspace", outWS); } -void SINQTranspose3D::doAMOR(IMDHistoWorkspace_sptr inWS) { +void SINQTranspose3D::doAMOR(const IMDHistoWorkspace_sptr &inWS) { double val; unsigned int xdim, ydim, zdim, idx; @@ -208,8 +208,9 @@ void SINQTranspose3D::doAMOR(IMDHistoWorkspace_sptr inWS) { setProperty("OutputWorkspace", outWS); } -void SINQTranspose3D::copyMetaData(Mantid::API::IMDHistoWorkspace_sptr inws, - Mantid::API::IMDHistoWorkspace_sptr outws) { +void SINQTranspose3D::copyMetaData( + const Mantid::API::IMDHistoWorkspace_sptr &inws, + const Mantid::API::IMDHistoWorkspace_sptr &outws) { outws->setTitle(inws->getTitle()); ExperimentInfo_sptr info; diff --git a/Framework/SINQ/src/SliceMDHisto.cpp b/Framework/SINQ/src/SliceMDHisto.cpp index 7ead2951c05d20146e108e19922a44385e354e9c..b6e57a138aa2ac59ae986cfa52c15d9a89e46028 100644 --- a/Framework/SINQ/src/SliceMDHisto.cpp +++ b/Framework/SINQ/src/SliceMDHisto.cpp @@ -99,8 +99,8 @@ void SliceMDHisto::exec() { setProperty("OutputWorkspace", outWS); } -void SliceMDHisto::cutData(Mantid::API::IMDHistoWorkspace_sptr inWS, - Mantid::API::IMDHistoWorkspace_sptr outWS, +void SliceMDHisto::cutData(const Mantid::API::IMDHistoWorkspace_sptr &inWS, + const Mantid::API::IMDHistoWorkspace_sptr &outWS, Mantid::coord_t *sourceDim, Mantid::coord_t *targetDim, std::vector<int> start, std::vector<int> end, unsigned int dim) { @@ -130,8 +130,9 @@ void SliceMDHisto::cutData(Mantid::API::IMDHistoWorkspace_sptr inWS, } } -void SliceMDHisto::copyMetaData(Mantid::API::IMDHistoWorkspace_sptr inws, - Mantid::API::IMDHistoWorkspace_sptr outws) { +void SliceMDHisto::copyMetaData( + const Mantid::API::IMDHistoWorkspace_sptr &inws, + const Mantid::API::IMDHistoWorkspace_sptr &outws) { outws->setTitle(inws->getTitle()); ExperimentInfo_sptr info; diff --git a/Framework/SINQ/test/PoldiDGridTest.h b/Framework/SINQ/test/PoldiDGridTest.h index faf194afd1e1a47b8532ba3e1c422b85856c1e5b..7acbe6e061a83ac4fcafb0f9ac947465b8926672 100644 --- a/Framework/SINQ/test/PoldiDGridTest.h +++ b/Framework/SINQ/test/PoldiDGridTest.h @@ -14,6 +14,7 @@ #include "MantidSINQ/PoldiUtilities/PoldiMockInstrumentHelpers.h" #include <stdexcept> +#include <utility> using ::testing::Return; using namespace Mantid::Poldi; @@ -28,7 +29,8 @@ class TestablePoldiDGrid : public PoldiDGrid { boost::shared_ptr<PoldiAbstractChopper>(), double deltaT = 0.0, std::pair<double, double> wavelengthRange = std::pair<double, double>()) - : PoldiDGrid(detector, chopper, deltaT, wavelengthRange) {} + : PoldiDGrid(std::move(detector), std::move(chopper), deltaT, + wavelengthRange) {} }; class PoldiDGridTest : public CxxTest::TestSuite { diff --git a/Framework/SINQ/test/PoldiFitPeaks2DTest.h b/Framework/SINQ/test/PoldiFitPeaks2DTest.h index fd40da297dfd4c02ae71ea1a346a77b80313dda7..04b91d797c1a1b94909ed24bf1b69fa0e425407a 100644 --- a/Framework/SINQ/test/PoldiFitPeaks2DTest.h +++ b/Framework/SINQ/test/PoldiFitPeaks2DTest.h @@ -481,8 +481,8 @@ private: PoldiInstrumentAdapter_sptr m_instrument; PoldiTimeTransformer_sptr m_timeTransformer; - void compareIntensities(PoldiPeakCollection_sptr first, - PoldiPeakCollection_sptr second, + void compareIntensities(const PoldiPeakCollection_sptr &first, + const PoldiPeakCollection_sptr &second, double relativePrecision) { for (size_t i = 0; i < first->peakCount(); ++i) { PoldiPeak_sptr peak = first->peak(i); diff --git a/Framework/SINQ/test/PoldiPeakCollectionTest.h b/Framework/SINQ/test/PoldiPeakCollectionTest.h index c59ee2fdc12b28d76954303e479645d8c398e8b6..5dd7d0703cfbc7139d72ea282f9ca83634b7e0ff 100644 --- a/Framework/SINQ/test/PoldiPeakCollectionTest.h +++ b/Framework/SINQ/test/PoldiPeakCollectionTest.h @@ -36,7 +36,7 @@ class TestablePoldiPeakCollection : public PoldiPeakCollection { TestablePoldiPeakCollection() : PoldiPeakCollection() {} - TestablePoldiPeakCollection(TableWorkspace_sptr workspace) + TestablePoldiPeakCollection(const TableWorkspace_sptr &workspace) : PoldiPeakCollection(workspace) {} }; diff --git a/Framework/SINQ/test/PoldiSourceSpectrumTest.h b/Framework/SINQ/test/PoldiSourceSpectrumTest.h index 81084f222b4f8f40e63cbfbadbe2d5a4dc600089..3a2d2185d484d40d1e962f37f2f1c7e6e7b6491e 100644 --- a/Framework/SINQ/test/PoldiSourceSpectrumTest.h +++ b/Framework/SINQ/test/PoldiSourceSpectrumTest.h @@ -12,6 +12,7 @@ #include "MantidSINQ/PoldiUtilities/PoldiSourceSpectrum.h" #include <cxxtest/TestSuite.h> #include <stdexcept> +#include <utility> using namespace Mantid::Poldi; using namespace Mantid::Kernel; @@ -97,10 +98,10 @@ private: friend class PoldiSourceSpectrumTest; public: - TestablePoldiSourceSpectrum(Interpolation spectrum = Interpolation()) + TestablePoldiSourceSpectrum(const Interpolation &spectrum = Interpolation()) : PoldiSourceSpectrum(spectrum) {} TestablePoldiSourceSpectrum(Instrument_const_sptr poldiInstrument) - : PoldiSourceSpectrum(poldiInstrument) {} + : PoldiSourceSpectrum(std::move(poldiInstrument)) {} }; }; diff --git a/Framework/ScriptRepository/inc/MantidScriptRepository/ScriptRepositoryImpl.h b/Framework/ScriptRepository/inc/MantidScriptRepository/ScriptRepositoryImpl.h index eccbb0b49642c4e693d71b421cb54ebd0c3b58b7..c6a68c630580f65b3b9b0557221e416839e88b94 100644 --- a/Framework/ScriptRepository/inc/MantidScriptRepository/ScriptRepositoryImpl.h +++ b/Framework/ScriptRepository/inc/MantidScriptRepository/ScriptRepositoryImpl.h @@ -15,7 +15,7 @@ namespace Mantid { namespace API { -void writeJsonFile(const std::string &filename, Json::Value json, +void writeJsonFile(const std::string &filename, const Json::Value &json, const std::string &error); Json::Value readJsonFile(const std::string &filename, const std::string &error); diff --git a/Framework/ScriptRepository/src/ScriptRepositoryImpl.cpp b/Framework/ScriptRepository/src/ScriptRepositoryImpl.cpp index 328ab2b505a5bbd49d8e2bf2365bc7d3f91b8f97..12d7fe2dbf224b8b7bf8a5d16b5a47d1124cfad2 100644 --- a/Framework/ScriptRepository/src/ScriptRepositoryImpl.cpp +++ b/Framework/ScriptRepository/src/ScriptRepositoryImpl.cpp @@ -82,7 +82,7 @@ const char *emptyURL = /** Write json object to file */ -void writeJsonFile(const std::string &filename, Json::Value json, +void writeJsonFile(const std::string &filename, const Json::Value &json, const std::string &error) { Poco::FileOutputStream filestream(filename); if (!filestream.good()) { diff --git a/Framework/ScriptRepository/test/ScriptRepositoryTestImpl.h b/Framework/ScriptRepository/test/ScriptRepositoryTestImpl.h index 1f5b1b125d1fad9e53892458bff4c5816c8fd0fb..93e45055462b5a4843f71e9d91f5ab0183b0a99b 100644 --- a/Framework/ScriptRepository/test/ScriptRepositoryTestImpl.h +++ b/Framework/ScriptRepository/test/ScriptRepositoryTestImpl.h @@ -83,7 +83,8 @@ to simulate changes and new values for the downloading. class ScriptRepositoryImplLocal : public ScriptRepositoryImpl { public: - ScriptRepositoryImplLocal(std::string a = "", std::string b = "") + ScriptRepositoryImplLocal(const std::string &a = "", + const std::string &b = "") : ScriptRepositoryImpl(a, b) { repository_json_content = REPOSITORYJSON; tofconv_readme_content = TOFCONV_README; diff --git a/Framework/TestHelpers/inc/MantidTestHelpers/BinaryOperationMDTestHelper.h b/Framework/TestHelpers/inc/MantidTestHelpers/BinaryOperationMDTestHelper.h index 4e3d45ba6f868b8542720edbab1c75e8bf3ce877..97ad18fe1e367904d0f6f23e40ae557bea216927 100644 --- a/Framework/TestHelpers/inc/MantidTestHelpers/BinaryOperationMDTestHelper.h +++ b/Framework/TestHelpers/inc/MantidTestHelpers/BinaryOperationMDTestHelper.h @@ -16,17 +16,19 @@ namespace BinaryOperationMDTestHelper { /// Run a binary algorithm. DLLExport Mantid::DataObjects::MDHistoWorkspace_sptr -doTest(std::string algoName, std::string lhs, std::string rhs, - std::string outName, bool succeeds = true, std::string otherProp = "", - std::string otherPropValue = ""); +doTest(const std::string &algoName, const std::string &lhs, + const std::string &rhs, const std::string &outName, bool succeeds = true, + const std::string &otherProp = "", + const std::string &otherPropValue = ""); } // namespace BinaryOperationMDTestHelper namespace UnaryOperationMDTestHelper { /// Run a unary algorithm. DLLExport Mantid::DataObjects::MDHistoWorkspace_sptr -doTest(std::string algoName, std::string inName, std::string outName, - bool succeeds = true, std::string otherProp = "", - std::string otherPropValue = ""); +doTest(const std::string &algoName, const std::string &inName, + const std::string &outName, bool succeeds = true, + const std::string &otherProp = "", + const std::string &otherPropValue = ""); } // namespace UnaryOperationMDTestHelper diff --git a/Framework/TestHelpers/inc/MantidTestHelpers/ComponentCreationHelper.h b/Framework/TestHelpers/inc/MantidTestHelpers/ComponentCreationHelper.h index 66454bb43c389e4111a17ee585ef60c4defbf181..362683a46b8b18c4bd55446f3d1e8cd0bad5a637 100644 --- a/Framework/TestHelpers/inc/MantidTestHelpers/ComponentCreationHelper.h +++ b/Framework/TestHelpers/inc/MantidTestHelpers/ComponentCreationHelper.h @@ -200,7 +200,7 @@ Mantid::Geometry::Instrument_sptr createTestInstrumentCylindrical( void addRectangularBank(Mantid::Geometry::Instrument &testInstrument, int idStart, int pixels, double pixelSpacing, - std::string bankName, + const std::string &bankName, const Mantid::Kernel::V3D &bankPos, const Mantid::Kernel::Quat &bankRot); diff --git a/Framework/TestHelpers/inc/MantidTestHelpers/DataProcessorTestHelper.h b/Framework/TestHelpers/inc/MantidTestHelpers/DataProcessorTestHelper.h index 46730b0efe900fdc22abdca6fbeb32c818a95fd7..11a86d24311a2f39c7bf22a0c90f66c64d12f841 100644 --- a/Framework/TestHelpers/inc/MantidTestHelpers/DataProcessorTestHelper.h +++ b/Framework/TestHelpers/inc/MantidTestHelpers/DataProcessorTestHelper.h @@ -25,15 +25,15 @@ namespace DataProcessorTestHelper { // Add a property value from a list to the given row data with an optional // prefix -DLLExport void -addPropertyValue(MantidQt::MantidWidgets::DataProcessor::RowData_sptr rowData, - const std::vector<std::string> &list, const size_t index, - const std::string &property, const std::string &prefix = ""); +DLLExport void addPropertyValue( + const MantidQt::MantidWidgets::DataProcessor::RowData_sptr &rowData, + const std::vector<std::string> &list, const size_t index, + const std::string &property, const std::string &prefix = ""); // Add a property value to the given row data -DLLExport void -addPropertyValue(MantidQt::MantidWidgets::DataProcessor::RowData_sptr rowData, - const std::string &property, const std::string &value); +DLLExport void addPropertyValue( + const MantidQt::MantidWidgets::DataProcessor::RowData_sptr &rowData, + const std::string &property, const std::string &value); // Utility to create a row data class from a string list of simple inputs DLLExport MantidQt::MantidWidgets::DataProcessor::RowData_sptr diff --git a/Framework/TestHelpers/inc/MantidTestHelpers/FakeObjects.h b/Framework/TestHelpers/inc/MantidTestHelpers/FakeObjects.h index 9803484a3c47723e5390af4f0f230c85f627c8a1..1b4d7ad274bfdd780b35f3bf4c0ebed7508f94c9 100644 --- a/Framework/TestHelpers/inc/MantidTestHelpers/FakeObjects.h +++ b/Framework/TestHelpers/inc/MantidTestHelpers/FakeObjects.h @@ -728,8 +728,9 @@ public: throw std::runtime_error("Not Implemented"); } - MDHistoWorkspaceTester(MDHistoDimension_sptr dimX, MDHistoDimension_sptr dimY, - MDHistoDimension_sptr dimZ) { + MDHistoWorkspaceTester(const MDHistoDimension_sptr &dimX, + const MDHistoDimension_sptr &dimY, + const MDHistoDimension_sptr &dimZ) { std::vector<IMDDimension_sptr> dimensions{dimX, dimY, dimZ}; initGeometry(dimensions); } diff --git a/Framework/TestHelpers/inc/MantidTestHelpers/MDEventsTestHelper.h b/Framework/TestHelpers/inc/MantidTestHelpers/MDEventsTestHelper.h index a67c9c86d761e03630f6fdd9a64a22f0793f8952..bbeab78161e64ea1af49996b81e75626bcb38acb 100644 --- a/Framework/TestHelpers/inc/MantidTestHelpers/MDEventsTestHelper.h +++ b/Framework/TestHelpers/inc/MantidTestHelpers/MDEventsTestHelper.h @@ -38,8 +38,8 @@ createOutputWorkspace(size_t splitInto) { template <typename MDE, size_t nd> void addMDDimensions( boost::shared_ptr<Mantid::DataObjects::MDEventWorkspace<MDE, nd>> out, - Mantid::coord_t min, Mantid::coord_t max, std::string axisNameFormat, - std::string axisIdFormat) { + Mantid::coord_t min, Mantid::coord_t max, const std::string &axisNameFormat, + const std::string &axisIdFormat) { // Create MDFrame of General Frame type Mantid::Geometry::GeneralFrame frame( @@ -64,8 +64,8 @@ template <typename MDE, size_t nd> void addMDDimensionsWithFrames( boost::shared_ptr<Mantid::DataObjects::MDEventWorkspace<MDE, nd>> out, Mantid::coord_t min, Mantid::coord_t max, - const Mantid::Geometry::MDFrame &frame, std::string axisNameFormat, - std::string axisIdFormat) { + const Mantid::Geometry::MDFrame &frame, const std::string &axisNameFormat, + const std::string &axisIdFormat) { for (size_t d = 0; d < nd; d++) { char name[200]; sprintf(name, axisNameFormat.c_str(), d); @@ -85,7 +85,7 @@ void addMDDimensionsWithIndividualFrames( boost::shared_ptr<Mantid::DataObjects::MDEventWorkspace<MDE, nd>> out, Mantid::coord_t min, Mantid::coord_t max, const std::vector<Mantid::Geometry::MDFrame_sptr> &frame, - std::string axisNameFormat, std::string axisIdFormat) { + const std::string &axisNameFormat, const std::string &axisIdFormat) { for (size_t d = 0; d < nd; d++) { char name[200]; sprintf(name, axisNameFormat.c_str(), d); @@ -172,17 +172,17 @@ makeFakeMDHistoWorkspace(double signal, size_t numDims, size_t numBins = 10, Mantid::DataObjects::MDHistoWorkspace_sptr makeFakeMDHistoWorkspaceWithMDFrame( double signal, size_t numDims, const Mantid::Geometry::MDFrame &frame, size_t numBins = 10, coord_t max = 10.0, double errorSquared = 1.0, - std::string name = "", double numEvents = 1.0); + const std::string &name = "", double numEvents = 1.0); /// More general fake n-dimensionsal MDHistoWorkspace Mantid::DataObjects::MDHistoWorkspace_sptr makeFakeMDHistoWorkspaceGeneral( size_t numDims, double signal, double errorSquared, size_t *numBins, - coord_t *min, coord_t *max, std::string name = ""); + coord_t *min, coord_t *max, const std::string &name = ""); /// More general fake n-dimensionsal MDHistoWorkspace Mantid::DataObjects::MDHistoWorkspace_sptr makeFakeMDHistoWorkspaceGeneral( size_t numDims, double signal, double errorSquared, size_t *numBins, coord_t *min, coord_t *max, std::vector<std::string> names, - std::string name = ""); + const std::string &name = ""); //------------------------------------------------------------------------------------- /** Create a test MDEventWorkspace<nd> . Dimensions are names Axis0, Axis1, etc. @@ -202,7 +202,7 @@ Mantid::DataObjects::MDHistoWorkspace_sptr makeFakeMDHistoWorkspaceGeneral( template <typename MDE, size_t nd> boost::shared_ptr<Mantid::DataObjects::MDEventWorkspace<MDE, nd>> makeAnyMDEW(size_t splitInto, coord_t min, coord_t max, - size_t numEventsPerBox = 0, std::string wsName = "", + size_t numEventsPerBox = 0, const std::string &wsName = "", std::string axisNameFormat = "Axis%d", std::string axisIdFormat = "Axis%d") { // Create bare workspace @@ -242,7 +242,7 @@ boost::shared_ptr<Mantid::DataObjects::MDEventWorkspace<MDE, nd>> makeAnyMDEWWithIndividualFrames( size_t splitInto, coord_t min, coord_t max, std::vector<Mantid::Geometry::MDFrame_sptr> frames, - size_t numEventsPerBox = 0, std::string wsName = "", + size_t numEventsPerBox = 0, const std::string &wsName = "", std::string axisNameFormat = "Axis%d", std::string axisIdFormat = "Axis%d") { // Create bare workspace @@ -283,7 +283,8 @@ template <typename MDE, size_t nd> boost::shared_ptr<Mantid::DataObjects::MDEventWorkspace<MDE, nd>> makeAnyMDEWWithFrames(size_t splitInto, coord_t min, coord_t max, const Mantid::Geometry::MDFrame &frame, - size_t numEventsPerBox = 0, std::string wsName = "", + size_t numEventsPerBox = 0, + const std::string &wsName = "", std::string axisNameFormat = "Axis%d", std::string axisIdFormat = "Axis%d") { // Create bare workspace @@ -499,7 +500,7 @@ static void extents_match(MDBOX box, size_t dim, double min, double max) { TSM_ASSERT_DELTA(dim, box->getExtents(dim).getMax(), max, 1e-6); } -void checkAndDeleteFile(std::string filename); +void checkAndDeleteFile(const std::string &filename); //===================================================================================== //===================================== TEST METHODS diff --git a/Framework/TestHelpers/inc/MantidTestHelpers/NexusFileReader.h b/Framework/TestHelpers/inc/MantidTestHelpers/NexusFileReader.h index 0215002c0680687c274e43491f183b2116b586bf..519febe4c98b3b1be20adb12dda0ead3bb04efc8 100644 --- a/Framework/TestHelpers/inc/MantidTestHelpers/NexusFileReader.h +++ b/Framework/TestHelpers/inc/MantidTestHelpers/NexusFileReader.h @@ -121,7 +121,7 @@ public: // read a multidimensional dataset and returns vector containing the data template <typename T> std::vector<T> readDataSetMultidimensional(FullNXPath &pathToGroup, - std::string dataSetName) { + const std::string &dataSetName) { std::vector<T> dataInFile; @@ -299,7 +299,7 @@ public: return false; } - bool hasDataset(const std::string dsetName, const FullNXPath &pathToGroup) { + bool hasDataset(const std::string &dsetName, const FullNXPath &pathToGroup) { H5::Group parentGroup = openfullH5Path(pathToGroup); @@ -373,7 +373,7 @@ public: } bool hasAttributeInDataSet( - const std::string dataSetName, const std::string &attrName, + const std::string &dataSetName, const std::string &attrName, const std::string &attrVal, const FullNXPath &pathToGroup /*where the dataset lives*/) { @@ -387,7 +387,7 @@ public: return attributeValue == attrVal; } - bool hasNXAttributeInDataSet(const std::string dataSetName, + bool hasNXAttributeInDataSet(const std::string &dataSetName, const std::string &attrVal, const FullNXPath &pathToGroup) { H5::Attribute attribute; diff --git a/Framework/TestHelpers/inc/MantidTestHelpers/SANSInstrumentCreationHelper.h b/Framework/TestHelpers/inc/MantidTestHelpers/SANSInstrumentCreationHelper.h index 10238c69637e2c639a1cc2e8fe514df01a7112e7..65ca02b5c5c6a78cbf1c7f1d7d84bd4527d2e0b4 100644 --- a/Framework/TestHelpers/inc/MantidTestHelpers/SANSInstrumentCreationHelper.h +++ b/Framework/TestHelpers/inc/MantidTestHelpers/SANSInstrumentCreationHelper.h @@ -31,14 +31,14 @@ public: * @param workspace: name of the workspace to be created. */ static Mantid::DataObjects::Workspace2D_sptr - createSANSInstrumentWorkspace(std::string workspace); + createSANSInstrumentWorkspace(const std::string &workspace); /** Run the Child Algorithm LoadInstrument (as for LoadRaw) * @param inst_name :: The name written in the Nexus file * @param workspace :: The workspace to insert the instrument into */ static void runLoadInstrument(const std::string &inst_name, - Mantid::DataObjects::Workspace2D_sptr workspace); + const Mantid::DataObjects::Workspace2D_sptr &workspace); /** * Populate spectra mapping to detector IDs @@ -48,6 +48,6 @@ public: * @param nybins: number of bins in Y */ static void - runLoadMappingTable(Mantid::DataObjects::Workspace2D_sptr workspace, + runLoadMappingTable(const Mantid::DataObjects::Workspace2D_sptr &workspace, int nxbins, int nybins); }; diff --git a/Framework/TestHelpers/inc/MantidTestHelpers/WorkspaceCreationHelper.h b/Framework/TestHelpers/inc/MantidTestHelpers/WorkspaceCreationHelper.h index a8abc58fef0ec1027c9db75b8a9ce2fdbdbe6d21..7d1886783063a0b3b48b0c927f80b9d6e6ca00e4 100644 --- a/Framework/TestHelpers/inc/MantidTestHelpers/WorkspaceCreationHelper.h +++ b/Framework/TestHelpers/inc/MantidTestHelpers/WorkspaceCreationHelper.h @@ -234,7 +234,7 @@ create2DWorkspaceFromFunction(fT yFunc, int nSpec, double x0, double x1, } /// Add random noise to the signalcreate2DWorkspaceWithFullInstrument -void addNoise(Mantid::API::MatrixWorkspace_sptr ws, double noise, +void addNoise(const Mantid::API::MatrixWorkspace_sptr &ws, double noise, const double lower = -0.5, const double upper = 0.5); /// Create a test workspace with a fully defined instrument. @@ -305,7 +305,8 @@ createWorkspaceSingleValue(double value); Mantid::DataObjects::WorkspaceSingleValue_sptr createWorkspaceSingleValueWithError(double value, double error); /** Perform some finalization on event workspace stuff */ -void eventWorkspace_Finalize(Mantid::DataObjects::EventWorkspace_sptr ew); +void eventWorkspace_Finalize( + const Mantid::DataObjects::EventWorkspace_sptr &ew); /** Create event workspace with: * 500 pixels * 1000 histogrammed bins. @@ -348,22 +349,23 @@ Mantid::API::MatrixWorkspace_sptr createGroupedWorkspace2DWithRingsAndBoxes( size_t RootOfNumHist = 10, int numBins = 10, double binDelta = 1.0); // not strictly creating a workspace, but really helpful to see what one // contains -void displayDataY(Mantid::API::MatrixWorkspace_const_sptr ws); +void displayDataY(const Mantid::API::MatrixWorkspace_const_sptr &ws); // not strictly creating a workspace, but really helpful to see what one // contains -void displayData(Mantid::API::MatrixWorkspace_const_sptr ws); +void displayData(const Mantid::API::MatrixWorkspace_const_sptr &ws); // not strictly creating a workspace, but really helpful to see what one // contains -void displayDataX(Mantid::API::MatrixWorkspace_const_sptr ws); +void displayDataX(const Mantid::API::MatrixWorkspace_const_sptr &ws); // not strictly creating a workspace, but really helpful to see what one // contains -void displayDataE(Mantid::API::MatrixWorkspace_const_sptr ws); +void displayDataE(const Mantid::API::MatrixWorkspace_const_sptr &ws); -void addTSPEntry(Mantid::API::Run &runInfo, std::string name, double val); -void setOrientedLattice(Mantid::API::MatrixWorkspace_sptr ws, double a, +void addTSPEntry(Mantid::API::Run &runInfo, const std::string &name, + double val); +void setOrientedLattice(const Mantid::API::MatrixWorkspace_sptr &ws, double a, double b, double c); -void setGoniometer(Mantid::API::MatrixWorkspace_sptr ws, double phi, double chi, - double omega); +void setGoniometer(const Mantid::API::MatrixWorkspace_sptr &ws, double phi, + double chi, double omega); // create workspace which should be result of homering (transform to energy in // inelastic) @@ -378,9 +380,9 @@ Mantid::API::MatrixWorkspace_sptr createProcessedInelasticWS( const std::vector<double> &azimutal, size_t numBins = 4, double Emin = -10, double Emax = 10, double Ei = 11); -Mantid::DataObjects::EventWorkspace_sptr -createEventWorkspace3(Mantid::DataObjects::EventWorkspace_const_sptr sourceWS, - std::string wsname, Mantid::API::Algorithm *alg); +Mantid::DataObjects::EventWorkspace_sptr createEventWorkspace3( + const Mantid::DataObjects::EventWorkspace_const_sptr &sourceWS, + const std::string &wsname, Mantid::API::Algorithm *alg); /// Function to create a fixed RebinnedOutput workspace Mantid::DataObjects::RebinnedOutput_sptr createRebinnedOutputWorkspace(); @@ -403,7 +405,8 @@ createPeaksWorkspace(const int numPeaks, /**Build table workspace with preprocessed detectors for existing workspace with * instrument */ boost::shared_ptr<Mantid::DataObjects::TableWorkspace> -buildPreprocessedDetectorsWorkspace(Mantid::API::MatrixWorkspace_sptr ws); +buildPreprocessedDetectorsWorkspace( + const Mantid::API::MatrixWorkspace_sptr &ws); // create range of angular detectors positions void create2DAngles(std::vector<double> &L2, std::vector<double> &polar, std::vector<double> &azim, size_t nPolar = 10, @@ -440,7 +443,7 @@ create2DWorkspaceWithReflectometryInstrumentMultiDetector( const int nSpectra = 4, const int nBins = 20, const double deltaX = 5000.0); void createInstrumentForWorkspaceWithDistances( - Mantid::API::MatrixWorkspace_sptr workspace, + const Mantid::API::MatrixWorkspace_sptr &workspace, const Mantid::Kernel::V3D &samplePosition, const Mantid::Kernel::V3D &sourcePosition, const std::vector<Mantid::Kernel::V3D> &detectorPositions); diff --git a/Framework/TestHelpers/src/BinaryOperationMDTestHelper.cpp b/Framework/TestHelpers/src/BinaryOperationMDTestHelper.cpp index e835e4e5ccffe15e5a3a96ee1b4aecbc0020224c..bce53656bb83b9d81c3d0be4fd313c1451eb481e 100644 --- a/Framework/TestHelpers/src/BinaryOperationMDTestHelper.cpp +++ b/Framework/TestHelpers/src/BinaryOperationMDTestHelper.cpp @@ -59,10 +59,11 @@ void setUpBinaryOperationMDTestHelper() { } /// Run a binary algorithm. -MDHistoWorkspace_sptr doTest(std::string algoName, std::string lhs, - std::string rhs, std::string outName, - bool succeeds, std::string otherProp, - std::string otherPropValue) { +MDHistoWorkspace_sptr doTest(const std::string &algoName, + const std::string &lhs, const std::string &rhs, + const std::string &outName, bool succeeds, + const std::string &otherProp, + const std::string &otherPropValue) { setUpBinaryOperationMDTestHelper(); IAlgorithm *alg = FrameworkManager::Instance().createAlgorithm(algoName); @@ -94,10 +95,11 @@ MDHistoWorkspace_sptr doTest(std::string algoName, std::string lhs, namespace UnaryOperationMDTestHelper { -MDHistoWorkspace_sptr doTest(std::string algoName, std::string inName, - std::string outName, bool succeeds, - std::string otherProp, - std::string otherPropValue) { +MDHistoWorkspace_sptr doTest(const std::string &algoName, + const std::string &inName, + const std::string &outName, bool succeeds, + const std::string &otherProp, + const std::string &otherPropValue) { MDHistoWorkspace_sptr histo = MDEventsTestHelper::makeFakeMDHistoWorkspace(2.0, 2, 5, 10.0, 2.0); IMDEventWorkspace_sptr event = diff --git a/Framework/TestHelpers/src/ComponentCreationHelper.cpp b/Framework/TestHelpers/src/ComponentCreationHelper.cpp index c520c9f1b3c746852e6e30f8701b287b70e84039..b40c9378213386232c7a00fa746ee79542f9d7d0 100644 --- a/Framework/TestHelpers/src/ComponentCreationHelper.cpp +++ b/Framework/TestHelpers/src/ComponentCreationHelper.cpp @@ -531,7 +531,7 @@ createCylInstrumentWithDetInGivenPositions(const std::vector<double> &L2, //---------------------------------------------------------------------------------------------- void addRectangularBank(Instrument &testInstrument, int idStart, int pixels, - double pixelSpacing, std::string bankName, + double pixelSpacing, const std::string &bankName, const V3D &bankPos, const Quat &bankRot) { const double cylRadius(pixelSpacing / 2); diff --git a/Framework/TestHelpers/src/DataProcessorTestHelper.cpp b/Framework/TestHelpers/src/DataProcessorTestHelper.cpp index e42ae87e7646ec5bbdfd6ff99fc05f47fc59a578..e8074c49288d743cc76fdc1b6d92b3eb640c6bc3 100644 --- a/Framework/TestHelpers/src/DataProcessorTestHelper.cpp +++ b/Framework/TestHelpers/src/DataProcessorTestHelper.cpp @@ -14,7 +14,7 @@ namespace DataProcessorTestHelper { /* Add a property value from a list to the given row data with an optional * prefix */ -void addPropertyValue(RowData_sptr rowData, +void addPropertyValue(const RowData_sptr &rowData, const std::vector<std::string> &list, const size_t index, const std::string &property, const std::string &prefix) { if (index >= list.size() || list[index].empty()) @@ -28,7 +28,7 @@ void addPropertyValue(RowData_sptr rowData, /* Add a property value to the given row data */ -void addPropertyValue(RowData_sptr rowData, const std::string &property, +void addPropertyValue(const RowData_sptr &rowData, const std::string &property, const std::string &value) { // Set the value and preprocessed value to the given value rowData->setOptionValue(property, value); diff --git a/Framework/TestHelpers/src/MDEventsTestHelper.cpp b/Framework/TestHelpers/src/MDEventsTestHelper.cpp index 1d758e654d1efa5c9af91f120323b0de75ba3161..690db659153f7e9bc38b2a19dc87a491ee38b4fa 100644 --- a/Framework/TestHelpers/src/MDEventsTestHelper.cpp +++ b/Framework/TestHelpers/src/MDEventsTestHelper.cpp @@ -244,10 +244,9 @@ makeFakeMDHistoWorkspace(double signal, size_t numDims, size_t numBins, * @param name :: optional name * @return the MDHisto */ -MDHistoWorkspace_sptr -makeFakeMDHistoWorkspaceGeneral(size_t numDims, double signal, - double errorSquared, size_t *numBins, - coord_t *min, coord_t *max, std::string name) { +MDHistoWorkspace_sptr makeFakeMDHistoWorkspaceGeneral( + size_t numDims, double signal, double errorSquared, size_t *numBins, + coord_t *min, coord_t *max, const std::string &name) { std::vector<std::string> names{"x", "y", "z", "t"}; // Create MDFrame of General Frame type Mantid::Geometry::GeneralFrame frame( @@ -283,7 +282,7 @@ makeFakeMDHistoWorkspaceGeneral(size_t numDims, double signal, MDHistoWorkspace_sptr makeFakeMDHistoWorkspaceGeneral( size_t numDims, double signal, double errorSquared, size_t *numBins, coord_t *min, coord_t *max, std::vector<std::string> names, - std::string name) { + const std::string &name) { std::vector<Mantid::Geometry::MDHistoDimension_sptr> dimensions; // Create MDFrame of General Frame type Mantid::Geometry::GeneralFrame frame( @@ -316,7 +315,7 @@ MDHistoWorkspace_sptr makeFakeMDHistoWorkspaceGeneral( */ Mantid::DataObjects::MDHistoWorkspace_sptr makeFakeMDHistoWorkspaceWithMDFrame( double signal, size_t numDims, const Mantid::Geometry::MDFrame &frame, - size_t numBins, coord_t max, double errorSquared, std::string name, + size_t numBins, coord_t max, double errorSquared, const std::string &name, double numEvents) { // MDHistoWorkspace *ws = nullptr; MDHistoWorkspace_sptr ws_sptr; @@ -365,7 +364,7 @@ Mantid::DataObjects::MDHistoWorkspace_sptr makeFakeMDHistoWorkspaceWithMDFrame( * Delete a file from disk * @param filename : File name to check and delete */ -void checkAndDeleteFile(std::string filename) { +void checkAndDeleteFile(const std::string &filename) { if (!filename.empty()) { if (Poco::File(filename).exists()) { Poco::File(filename).remove(); diff --git a/Framework/TestHelpers/src/ReflectometryHelper.cpp b/Framework/TestHelpers/src/ReflectometryHelper.cpp index 0a03f9137a35d575f4b543868eb71d8be2e26a0a..91e8a5b59795a8544075404b2671c970cc553dee 100644 --- a/Framework/TestHelpers/src/ReflectometryHelper.cpp +++ b/Framework/TestHelpers/src/ReflectometryHelper.cpp @@ -4,6 +4,8 @@ // NScD Oak Ridge National Laboratory, European Spallation Source, // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + +#include <utility> + #include "MantidTestHelpers/ReflectometryHelper.h" #include "MantidAPI/AlgorithmManager.h" @@ -115,7 +117,8 @@ void prepareInputGroup(std::string const &name, std::string const ¶msType, mkGroup->execute(); } -std::vector<MatrixWorkspace_sptr> groupToVector(WorkspaceGroup_sptr group) { +std::vector<MatrixWorkspace_sptr> +groupToVector(const WorkspaceGroup_sptr &group) { std::vector<MatrixWorkspace_sptr> out; for (size_t i = 0; i < group->size(); ++i) { out.emplace_back( @@ -129,9 +132,9 @@ std::vector<MatrixWorkspace_sptr> retrieveOutWS(std::string const &name) { return groupToVector(group); } -void applyPolarizationEfficiencies(WorkspaceGroup_sptr ws) { +void applyPolarizationEfficiencies(const WorkspaceGroup_sptr &ws) { - auto wss = groupToVector(ws); + auto wss = groupToVector(std::move(ws)); auto Rpp = wss[0]; auto Rpa = wss[1]; auto Rap = wss[2]; diff --git a/Framework/TestHelpers/src/SANSInstrumentCreationHelper.cpp b/Framework/TestHelpers/src/SANSInstrumentCreationHelper.cpp index d73a3262928174d8497fc5f770842a6e99ff22e3..a2e26a0b9f948b308f67931d5db7b98c0d3c6f46 100644 --- a/Framework/TestHelpers/src/SANSInstrumentCreationHelper.cpp +++ b/Framework/TestHelpers/src/SANSInstrumentCreationHelper.cpp @@ -44,7 +44,7 @@ const int SANSInstrumentCreationHelper::nMonitors = 2; * @param workspace: name of the workspace to be created. */ Workspace2D_sptr SANSInstrumentCreationHelper::createSANSInstrumentWorkspace( - std::string workspace) { + const std::string &workspace) { // Create a test workspace with test data with a well defined peak // The test instrument has two monitor channels Workspace2D_sptr ws = WorkspaceCreationHelper::create2DWorkspace123( @@ -67,7 +67,7 @@ Workspace2D_sptr SANSInstrumentCreationHelper::createSANSInstrumentWorkspace( */ void SANSInstrumentCreationHelper::runLoadInstrument( const std::string &inst_name, - Mantid::DataObjects::Workspace2D_sptr workspace) { + const Mantid::DataObjects::Workspace2D_sptr &workspace) { // Determine the search directory for XML instrument definition files (IDFs) // std::string directoryName = // Mantid::Kernel::ConfigService::Instance().getInstrumentDirectory(); @@ -97,7 +97,8 @@ void SANSInstrumentCreationHelper::runLoadInstrument( * @param nybins: number of bins in Y */ void SANSInstrumentCreationHelper::runLoadMappingTable( - Mantid::DataObjects::Workspace2D_sptr workspace, int nxbins, int nybins) { + const Mantid::DataObjects::Workspace2D_sptr &workspace, int nxbins, + int nybins) { // Get the number of monitor channels size_t nMonitors(0); size_t nXbins, nYbins; diff --git a/Framework/TestHelpers/src/WorkspaceCreationHelper.cpp b/Framework/TestHelpers/src/WorkspaceCreationHelper.cpp index 9e491ac2393c303fd0fa23b3f602a466bcb1b3e4..a910ef03d33c26a0c3f5f4d57800e6e8f5928fbf 100644 --- a/Framework/TestHelpers/src/WorkspaceCreationHelper.cpp +++ b/Framework/TestHelpers/src/WorkspaceCreationHelper.cpp @@ -366,7 +366,7 @@ Workspace2D_sptr create2DWorkspaceNonUniformlyBinned(int nhist, * @param lower :: The lower bound of the flucation (default=-0.5) * @param upper:: The upper bound of the flucation (default=-0.5) */ -void addNoise(Mantid::API::MatrixWorkspace_sptr ws, double noise, +void addNoise(const Mantid::API::MatrixWorkspace_sptr &ws, double noise, const double lower, const double upper) { const size_t seed(12345); MersenneTwister randGen(seed, lower, upper); @@ -707,7 +707,7 @@ MatrixWorkspace_sptr create2DWorkspaceWithReflectometryInstrumentMultiDetector( } void createInstrumentForWorkspaceWithDistances( - MatrixWorkspace_sptr workspace, const V3D &samplePosition, + const MatrixWorkspace_sptr &workspace, const V3D &samplePosition, const V3D &sourcePosition, const std::vector<V3D> &detectorPositions) { Instrument_sptr instrument = boost::make_shared<Instrument>(); instrument->setReferenceFrame( @@ -739,7 +739,7 @@ WorkspaceSingleValue_sptr createWorkspaceSingleValueWithError(double value, } /** Perform some finalization on event workspace stuff */ -void eventWorkspace_Finalize(EventWorkspace_sptr ew) { +void eventWorkspace_Finalize(const EventWorkspace_sptr &ew) { // get a proton charge ew->mutableRun().integrateProtonCharge(); } @@ -944,7 +944,7 @@ createGroupedWorkspace2DWithRingsAndBoxes(size_t RootOfNumHist, int numBins, // not strictly creating a workspace, but really helpful to see what one // contains -void displayDataY(MatrixWorkspace_const_sptr ws) { +void displayDataY(const MatrixWorkspace_const_sptr &ws) { const size_t numHists = ws->getNumberHistograms(); for (size_t i = 0; i < numHists; ++i) { std::cout << "Histogram " << i << " = "; @@ -955,11 +955,13 @@ void displayDataY(MatrixWorkspace_const_sptr ws) { std::cout << '\n'; } } -void displayData(MatrixWorkspace_const_sptr ws) { displayDataX(ws); } +void displayData(const MatrixWorkspace_const_sptr &ws) { + displayDataX(std::move(ws)); +} // not strictly creating a workspace, but really helpful to see what one // contains -void displayDataX(MatrixWorkspace_const_sptr ws) { +void displayDataX(const MatrixWorkspace_const_sptr &ws) { const size_t numHists = ws->getNumberHistograms(); for (size_t i = 0; i < numHists; ++i) { std::cout << "Histogram " << i << " = "; @@ -973,7 +975,7 @@ void displayDataX(MatrixWorkspace_const_sptr ws) { // not strictly creating a workspace, but really helpful to see what one // contains -void displayDataE(MatrixWorkspace_const_sptr ws) { +void displayDataE(const MatrixWorkspace_const_sptr &ws) { const size_t numHists = ws->getNumberHistograms(); for (size_t i = 0; i < numHists; ++i) { std::cout << "Histogram " << i << " = "; @@ -992,7 +994,7 @@ void displayDataE(MatrixWorkspace_const_sptr ws) { * @param name :: property name * @param val :: value */ -void addTSPEntry(Run &runInfo, std::string name, double val) { +void addTSPEntry(Run &runInfo, const std::string &name, double val) { TimeSeriesProperty<double> *tsp; tsp = new TimeSeriesProperty<double>(name); tsp->addValue("2011-05-24T00:00:00", val); @@ -1008,7 +1010,7 @@ void addTSPEntry(Run &runInfo, std::string name, double val) { * @param b :: lattice length * @param c :: lattice length */ -void setOrientedLattice(Mantid::API::MatrixWorkspace_sptr ws, double a, +void setOrientedLattice(const Mantid::API::MatrixWorkspace_sptr &ws, double a, double b, double c) { ws->mutableSample().setOrientedLattice( std::make_unique<OrientedLattice>(a, b, c, 90., 90., 90.)); @@ -1022,8 +1024,8 @@ void setOrientedLattice(Mantid::API::MatrixWorkspace_sptr ws, double a, * @param chi :: +X rotation angle (deg) * @param omega :: +Y rotation angle (deg) */ -void setGoniometer(Mantid::API::MatrixWorkspace_sptr ws, double phi, double chi, - double omega) { +void setGoniometer(const Mantid::API::MatrixWorkspace_sptr &ws, double phi, + double chi, double omega) { addTSPEntry(ws->mutableRun(), "phi", phi); addTSPEntry(ws->mutableRun(), "chi", chi); addTSPEntry(ws->mutableRun(), "omega", omega); @@ -1151,9 +1153,9 @@ createProcessedInelasticWS(const std::vector<double> &L2, * The new workspace should be exactly the same as the source workspace but * without any events */ -Mantid::DataObjects::EventWorkspace_sptr -createEventWorkspace3(Mantid::DataObjects::EventWorkspace_const_sptr sourceWS, - std::string wsname, API::Algorithm *alg) { +Mantid::DataObjects::EventWorkspace_sptr createEventWorkspace3( + const Mantid::DataObjects::EventWorkspace_const_sptr &sourceWS, + const std::string &wsname, API::Algorithm *alg) { UNUSED_ARG(wsname); // 1. Initialize:use dummy numbers for arguments, for event workspace it // doesn't matter @@ -1474,7 +1476,8 @@ void processDetectorsPositions(const API::MatrixWorkspace_const_sptr &inputWS, } boost::shared_ptr<Mantid::DataObjects::TableWorkspace> -buildPreprocessedDetectorsWorkspace(Mantid::API::MatrixWorkspace_sptr ws) { +buildPreprocessedDetectorsWorkspace( + const Mantid::API::MatrixWorkspace_sptr &ws) { Mantid::DataObjects::TableWorkspace_sptr DetPos = createTableWorkspace(ws); auto Ei = ws->run().getPropertyValueAsType<double>("Ei"); processDetectorsPositions(ws, DetPos, Ei); diff --git a/Framework/Types/inc/MantidTypes/Core/DateAndTime.h b/Framework/Types/inc/MantidTypes/Core/DateAndTime.h index da4b659f1d26437b5e474ca368f670382a6d05d3..d0f48450d1cf5da393540848471f6f4999bf819f 100644 --- a/Framework/Types/inc/MantidTypes/Core/DateAndTime.h +++ b/Framework/Types/inc/MantidTypes/Core/DateAndTime.h @@ -45,9 +45,9 @@ public: DateAndTime(const int32_t seconds, const int32_t nanoseconds); DateAndTime(const int64_t seconds, const int64_t nanoseconds); DateAndTime(const std::string &ISO8601_string); - DateAndTime(const boost::posix_time::ptime _ptime); + DateAndTime(const boost::posix_time::ptime &_ptime); - void set_from_ptime(boost::posix_time::ptime _ptime); + void set_from_ptime(const boost::posix_time::ptime &_ptime); boost::posix_time::ptime to_ptime() const; void set_from_time_t(std::time_t _timet); @@ -59,7 +59,7 @@ public: void setFromISO8601(const std::string &str); std::string toSimpleString() const; std::string - toFormattedString(const std::string format = "%Y-%b-%d %H:%M:%S") const; + toFormattedString(const std::string &format = "%Y-%b-%d %H:%M:%S") const; std::string toISO8601String() const; /// Stream output operator @@ -112,7 +112,7 @@ public: static DateAndTime getCurrentTime(); static DateAndTime maximum(); static DateAndTime minimum(); - static double secondsFromDuration(time_duration duration); + static double secondsFromDuration(const time_duration &duration); static time_duration durationFromSeconds(double duration); static int64_t nanosecondsFromDuration(const time_duration &td); static int64_t nanosecondsFromSeconds(double sec); diff --git a/Framework/Types/src/Core/DateAndTime.cpp b/Framework/Types/src/Core/DateAndTime.cpp index d64835cba9e541f7ecfbb61caa22c32d6259f7ed..3b6c1c9884e19dec72d23ca6b96b09802e4a4d3d 100644 --- a/Framework/Types/src/Core/DateAndTime.cpp +++ b/Framework/Types/src/Core/DateAndTime.cpp @@ -133,7 +133,7 @@ DateAndTime::DateAndTime(const std::string &ISO8601_string) : _nanoseconds(0) { /** Construct time from a boost::posix_time::ptime. * @param _ptime :: boost::posix_time::ptime */ -DateAndTime::DateAndTime(const boost::posix_time::ptime _ptime) +DateAndTime::DateAndTime(const boost::posix_time::ptime &_ptime) : _nanoseconds(0) { this->set_from_ptime(_ptime); } @@ -207,7 +207,7 @@ boost::posix_time::ptime DateAndTime::to_ptime() const { * * @param _ptime :: boost::posix_time::ptime date and time. */ -void DateAndTime::set_from_ptime(boost::posix_time::ptime _ptime) { +void DateAndTime::set_from_ptime(const boost::posix_time::ptime &_ptime) { if (_ptime.is_special()) { // --- SPECIAL VALUES! ---- if (_ptime.is_infinity() || _ptime.is_pos_infinity()) @@ -452,7 +452,7 @@ std::string DateAndTime::toSimpleString() const { * @param format : format for strftime(). Default "%Y-%b-%d %H:%M:%S" * @return date as string, formatted as requested */ -std::string DateAndTime::toFormattedString(const std::string format) const { +std::string DateAndTime::toFormattedString(const std::string &format) const { char buffer[25]; std::tm date_as_tm = this->to_tm(); strftime(buffer, 25, format.c_str(), &date_as_tm); @@ -688,7 +688,7 @@ DateAndTime DateAndTime::getCurrentTime() { * Return the number of seconds in a time_duration, as a double, including * fractional seconds. */ -double DateAndTime::secondsFromDuration(time_duration duration) { +double DateAndTime::secondsFromDuration(const time_duration &duration) { #ifdef BOOST_DATE_TIME_HAS_NANOSECONDS // Nanosecond resolution return static_cast<double>(duration.total_nanoseconds()) / 1e9; diff --git a/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/AlignAndFocusPowder.h b/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/AlignAndFocusPowder.h index 8657a78876b6160f110eca68360fb9563e11de58..a82e1e84769e364e8948d896d428ae534ac5f6a2 100644 --- a/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/AlignAndFocusPowder.h +++ b/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/AlignAndFocusPowder.h @@ -75,23 +75,22 @@ private: const std::string &groupFilename); API::MatrixWorkspace_sptr rebin(API::MatrixWorkspace_sptr matrixws); - API::MatrixWorkspace_sptr conjoinWorkspaces(API::MatrixWorkspace_sptr ws1, - API::MatrixWorkspace_sptr ws2, - size_t offset); + API::MatrixWorkspace_sptr + conjoinWorkspaces(const API::MatrixWorkspace_sptr &ws1, + const API::MatrixWorkspace_sptr &ws2, size_t offset); /// Call diffraction focus to a matrix workspace. API::MatrixWorkspace_sptr diffractionFocus(API::MatrixWorkspace_sptr ws); /// Convert units API::MatrixWorkspace_sptr convertUnits(API::MatrixWorkspace_sptr matrixws, - std::string target); + const std::string &target); /// Call edit instrument geometry - API::MatrixWorkspace_sptr editInstrument(API::MatrixWorkspace_sptr ws, - std::vector<double> polars, - std::vector<specnum_t> specids, - std::vector<double> l2s, - std::vector<double> phis); + API::MatrixWorkspace_sptr editInstrument( + API::MatrixWorkspace_sptr ws, const std::vector<double> &polars, + const std::vector<specnum_t> &specids, const std::vector<double> &l2s, + const std::vector<double> &phis); void convertOffsetsToCal(DataObjects::OffsetsWorkspace_sptr &offsetsWS); double getVecPropertyFromPmOrSelf(const std::string &name, std::vector<double> &avec); @@ -123,7 +122,7 @@ private: double tmin{0.0}; double tmax{0.0}; bool m_preserveEvents{false}; - void doSortEvents(Mantid::API::Workspace_sptr ws); + void doSortEvents(const Mantid::API::Workspace_sptr &ws); /// Low resolution TOF matrix workspace API::MatrixWorkspace_sptr m_lowResW; diff --git a/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/DgsReduction.h b/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/DgsReduction.h index 5da83dcc1e4baee757132d9a4812349dcb5ecfd3..6ed48dc7a615f473c699e2cb4e5c03233f128b3e 100644 --- a/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/DgsReduction.h +++ b/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/DgsReduction.h @@ -32,12 +32,13 @@ public: private: void init() override; void exec() override; - API::Workspace_sptr loadInputData(const std::string prop, + API::Workspace_sptr loadInputData(const std::string &prop, const bool mustLoad = true); - API::MatrixWorkspace_sptr loadGroupingFile(const std::string prop); + API::MatrixWorkspace_sptr loadGroupingFile(const std::string &prop); API::MatrixWorkspace_sptr loadHardMask(); - double getParameter(std::string algParam, API::MatrixWorkspace_sptr ws, - std::string altParam); + double getParameter(const std::string &algParam, + const API::MatrixWorkspace_sptr &ws, + const std::string &altParam); boost::shared_ptr<Kernel::PropertyManager> reductionManager; }; diff --git a/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/DgsRemap.h b/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/DgsRemap.h index 5b7a37597bb473201ee4e05d9a5ed1c8952a16f7..52e054f871e8c628619975904cda8fd2e2108bff 100644 --- a/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/DgsRemap.h +++ b/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/DgsRemap.h @@ -30,9 +30,9 @@ public: private: void init() override; void exec() override; - void execGrouping(API::MatrixWorkspace_sptr iWS, + void execGrouping(const API::MatrixWorkspace_sptr &iWS, API::MatrixWorkspace_sptr &oWS); - void execMasking(API::MatrixWorkspace_sptr iWS); + void execMasking(const API::MatrixWorkspace_sptr &iWS); }; } // namespace WorkflowAlgorithms diff --git a/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/EQSANSInstrument.h b/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/EQSANSInstrument.h index f8bc95b1595f8341a8578bba0e9dcae99c8b06a4..9482d96bbb4f0d7d3644abdeb0ec98e5c291967e 100644 --- a/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/EQSANSInstrument.h +++ b/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/EQSANSInstrument.h @@ -24,17 +24,17 @@ const double default_slit_positions[3][8] = { {0.0, 10.0, 10.0, 15.0, 15.0, 20.0, 20.0, 40.0}}; double readInstrumentParameter(const std::string ¶meter, - API::MatrixWorkspace_sptr dataWS); + const API::MatrixWorkspace_sptr &dataWS); int getDetectorFromPixel(const int &pixel_x, const int &pixel_y, - API::MatrixWorkspace_sptr dataWS); + const API::MatrixWorkspace_sptr &dataWS); void getCoordinateFromPixel(const double &pixel_x, const double &pixel_y, - API::MatrixWorkspace_sptr dataWS, double &x, + const API::MatrixWorkspace_sptr &dataWS, double &x, double &y); void getPixelFromCoordinate(const double &x, const double &y, - API::MatrixWorkspace_sptr dataWS, double &pixel_x, - double &pixel_y); -void getDefaultBeamCenter(API::MatrixWorkspace_sptr dataWS, double &pixel_x, - double &pixel_y); + const API::MatrixWorkspace_sptr &dataWS, + double &pixel_x, double &pixel_y); +void getDefaultBeamCenter(const API::MatrixWorkspace_sptr &dataWS, + double &pixel_x, double &pixel_y); } // namespace EQSANSInstrument } // namespace WorkflowAlgorithms diff --git a/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/EQSANSMonitorTOF.h b/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/EQSANSMonitorTOF.h index 4b8bc0f2890ade4477f459b09c44b13afc479ee2..18c9ef46276c20020cba6aecb8dfab4ae9385c68 100644 --- a/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/EQSANSMonitorTOF.h +++ b/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/EQSANSMonitorTOF.h @@ -52,7 +52,7 @@ private: void exec() override; /// Compute TOF offset - double getTofOffset(API::MatrixWorkspace_const_sptr inputWS, + double getTofOffset(const API::MatrixWorkspace_const_sptr &inputWS, bool frame_skipping, double source_to_monitor); }; diff --git a/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/ExtractQENSMembers.h b/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/ExtractQENSMembers.h index eaf91d39f4d1c632c39c4028e810b40dff796784..18dd6e576e96802cdea0dfce2dd8eb4aee8a4538 100644 --- a/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/ExtractQENSMembers.h +++ b/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/ExtractQENSMembers.h @@ -33,7 +33,7 @@ private: getQValues(const std::vector<Mantid::API::MatrixWorkspace_sptr> &workspaces); std::vector<std::string> - getAxisLabels(Mantid::API::MatrixWorkspace_sptr workspace, + getAxisLabels(const Mantid::API::MatrixWorkspace_sptr &workspace, size_t axisIndex) const; std::vector<std::string> @@ -41,20 +41,21 @@ private: const std::vector<std::string> &newNames) const; Mantid::API::MatrixWorkspace_sptr - extractSpectrum(Mantid::API::MatrixWorkspace_sptr inputWS, size_t spectrum); + extractSpectrum(const Mantid::API::MatrixWorkspace_sptr &inputWS, + size_t spectrum); Mantid::API::MatrixWorkspace_sptr - appendSpectra(Mantid::API::MatrixWorkspace_sptr inputWS, - Mantid::API::MatrixWorkspace_sptr spectraWorkspace); + appendSpectra(const Mantid::API::MatrixWorkspace_sptr &inputWS, + const Mantid::API::MatrixWorkspace_sptr &spectraWorkspace); Mantid::API::WorkspaceGroup_sptr groupWorkspaces(const std::vector<std::string> &workspaceNames); std::vector<Mantid::API::MatrixWorkspace_sptr> - createMembersWorkspaces(Mantid::API::MatrixWorkspace_sptr initialWS, + createMembersWorkspaces(const Mantid::API::MatrixWorkspace_sptr &initialWS, const std::vector<std::string> &members); - void appendToMembers(Mantid::API::MatrixWorkspace_sptr resultWS, + void appendToMembers(const Mantid::API::MatrixWorkspace_sptr &resultWS, std::vector<Mantid::API::MatrixWorkspace_sptr> &members); void setNumericAxis( diff --git a/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/HFIRDarkCurrentSubtraction.h b/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/HFIRDarkCurrentSubtraction.h index 8167b77c9123765e209f981b49f903c8196bebb3..61d45c8c2be64632468474f52e16e005ed4a68e3 100644 --- a/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/HFIRDarkCurrentSubtraction.h +++ b/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/HFIRDarkCurrentSubtraction.h @@ -59,7 +59,7 @@ private: void init() override; /// Execution code void exec() override; - double getCountingTime(API::MatrixWorkspace_sptr inputWS); + double getCountingTime(const API::MatrixWorkspace_sptr &inputWS); static const int DEFAULT_MONITOR_ID = 0; static const int DEFAULT_TIMER_ID = 1; diff --git a/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/HFIRInstrument.h b/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/HFIRInstrument.h index a42ba6969a7050315285920e8c2768081ac6595f..76d24d463d60c1bb58bd227d24b67cf75a65d828 100644 --- a/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/HFIRInstrument.h +++ b/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/HFIRInstrument.h @@ -20,18 +20,18 @@ namespace HFIRInstrument { */ double readInstrumentParameter(const std::string ¶meter, - API::MatrixWorkspace_sptr dataWS); + const API::MatrixWorkspace_sptr &dataWS); int getDetectorFromPixel(const int &pixel_x, const int &pixel_y, - API::MatrixWorkspace_sptr dataWS); + const API::MatrixWorkspace_sptr &dataWS); void getCoordinateFromPixel(const double &pixel_x, const double &pixel_y, - API::MatrixWorkspace_sptr dataWS, double &x, + const API::MatrixWorkspace_sptr &dataWS, double &x, double &y); void getPixelFromCoordinate(const double &x, const double &y, - API::MatrixWorkspace_sptr dataWS, double &pixel_x, - double &pixel_y); -void getDefaultBeamCenter(API::MatrixWorkspace_sptr dataWS, double &pixel_x, - double &pixel_y); -double getSourceToSampleDistance(API::MatrixWorkspace_sptr dataWS); + const API::MatrixWorkspace_sptr &dataWS, + double &pixel_x, double &pixel_y); +void getDefaultBeamCenter(const API::MatrixWorkspace_sptr &dataWS, + double &pixel_x, double &pixel_y); +double getSourceToSampleDistance(const API::MatrixWorkspace_sptr &dataWS); } // namespace HFIRInstrument } // namespace WorkflowAlgorithms diff --git a/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/IMuonAsymmetryCalculator.h b/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/IMuonAsymmetryCalculator.h index 54c73581cedadca69bcbc3a32b3609530a7ec0ce..17b9d84bb998d18f53a3d170727736e06da2c573 100644 --- a/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/IMuonAsymmetryCalculator.h +++ b/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/IMuonAsymmetryCalculator.h @@ -20,9 +20,9 @@ namespace WorkflowAlgorithms { */ class DLLExport IMuonAsymmetryCalculator { public: - IMuonAsymmetryCalculator(const API::WorkspaceGroup_sptr inputWS, - const std::vector<int> summedPeriods, - const std::vector<int> subtractedPeriods); + IMuonAsymmetryCalculator(const API::WorkspaceGroup_sptr &inputWS, + const std::vector<int> &summedPeriods, + const std::vector<int> &subtractedPeriods); virtual ~IMuonAsymmetryCalculator() = default; /// Overridden in derived classes to perform asymmetry calculation virtual API::MatrixWorkspace_sptr calculate() const = 0; diff --git a/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/MuonGroupAsymmetryCalculator.h b/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/MuonGroupAsymmetryCalculator.h index 8226fe81590c000d3bc14f39ec62eab15c80018f..9c9294fce63c81dbce292b90571a721faa540348 100644 --- a/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/MuonGroupAsymmetryCalculator.h +++ b/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/MuonGroupAsymmetryCalculator.h @@ -16,12 +16,12 @@ namespace WorkflowAlgorithms { */ class DLLExport MuonGroupAsymmetryCalculator : public MuonGroupCalculator { public: - MuonGroupAsymmetryCalculator(const API::WorkspaceGroup_sptr inputWS, - const std::vector<int> summedPeriods, - const std::vector<int> subtractedPeriods, + MuonGroupAsymmetryCalculator(const API::WorkspaceGroup_sptr &inputWS, + const std::vector<int> &summedPeriods, + const std::vector<int> &subtractedPeriods, const int groupIndex, const double start = 0.0, const double end = 30.0, - const std::string wsName = ""); + const std::string &wsName = ""); /// Performs group asymmetry calculation API::MatrixWorkspace_sptr calculate() const override; diff --git a/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/MuonGroupCalculator.h b/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/MuonGroupCalculator.h index 7bd7d3fb087d4a6270f110153688bfb85dc445a2..145e64d2dc951b7d7abb8e3bc669123d0fda9de1 100644 --- a/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/MuonGroupCalculator.h +++ b/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/MuonGroupCalculator.h @@ -15,12 +15,12 @@ namespace WorkflowAlgorithms { */ class DLLExport MuonGroupCalculator : public IMuonAsymmetryCalculator { public: - MuonGroupCalculator(const Mantid::API::WorkspaceGroup_sptr inputWS, - const std::vector<int> summedPeriods, - const std::vector<int> subtractedPeriods, + MuonGroupCalculator(const Mantid::API::WorkspaceGroup_sptr &inputWS, + const std::vector<int> &summedPeriods, + const std::vector<int> &subtractedPeriods, const int groupIndex); void setStartEnd(const double start, const double end); - void setWSName(const std::string wsName); + void setWSName(const std::string &wsName); protected: /// Workspace index of the group to analyse diff --git a/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/MuonGroupCountsCalculator.h b/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/MuonGroupCountsCalculator.h index 39527d5f27438f3ed0e67584435d9ce3d858d8e4..7065beb04fd34086b10e0b710450c98494aa545e 100644 --- a/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/MuonGroupCountsCalculator.h +++ b/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/MuonGroupCountsCalculator.h @@ -16,9 +16,9 @@ namespace WorkflowAlgorithms { */ class DLLExport MuonGroupCountsCalculator : public MuonGroupCalculator { public: - MuonGroupCountsCalculator(const Mantid::API::WorkspaceGroup_sptr inputWS, - const std::vector<int> summedPeriods, - const std::vector<int> subtractedPeriods, + MuonGroupCountsCalculator(const Mantid::API::WorkspaceGroup_sptr &inputWS, + const std::vector<int> &summedPeriods, + const std::vector<int> &subtractedPeriods, const int groupIndex); /// Performs group counts calculation Mantid::API::MatrixWorkspace_sptr calculate() const override; diff --git a/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/MuonPairAsymmetryCalculator.h b/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/MuonPairAsymmetryCalculator.h index e648207f6aa0899382211a648e3b7f74236de157..00d978d8757e8cf3a66fc4e7b248bce340db6e3a 100644 --- a/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/MuonPairAsymmetryCalculator.h +++ b/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/MuonPairAsymmetryCalculator.h @@ -16,9 +16,9 @@ namespace WorkflowAlgorithms { */ class DLLExport MuonPairAsymmetryCalculator : public IMuonAsymmetryCalculator { public: - MuonPairAsymmetryCalculator(const API::WorkspaceGroup_sptr inputWS, - const std::vector<int> summedPeriods, - const std::vector<int> subtractedPeriods, + MuonPairAsymmetryCalculator(const API::WorkspaceGroup_sptr &inputWS, + const std::vector<int> &summedPeriods, + const std::vector<int> &subtractedPeriods, const int firstPairIndex, const int secondPairIndex, const double alpha = 1); diff --git a/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/MuonProcess.h b/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/MuonProcess.h index b5e022ab69534d2cf49b91e0796f83b17809d001..7489a3e35a1f45809fe3288ffcfd92f13870f739 100644 --- a/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/MuonProcess.h +++ b/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/MuonProcess.h @@ -39,12 +39,12 @@ private: /// Groups specified workspace group according to specified /// DetectorGroupingTable. API::WorkspaceGroup_sptr - groupWorkspaces(API::WorkspaceGroup_sptr wsGroup, - DataObjects::TableWorkspace_sptr grouping); + groupWorkspaces(const API::WorkspaceGroup_sptr &wsGroup, + const DataObjects::TableWorkspace_sptr &grouping); /// Applies dead time correction to the workspace group. - API::WorkspaceGroup_sptr applyDTC(API::WorkspaceGroup_sptr wsGroup, - DataObjects::TableWorkspace_sptr dt); + API::WorkspaceGroup_sptr applyDTC(const API::WorkspaceGroup_sptr &wsGroup, + const DataObjects::TableWorkspace_sptr &dt); /// Applies offset, crops and rebin the workspace according to specified /// params @@ -52,8 +52,9 @@ private: double loadedTimeZero); /// Applies offset, crops and rebins all workspaces in the group - API::WorkspaceGroup_sptr correctWorkspaces(API::WorkspaceGroup_sptr wsGroup, - double loadedTimeZero); + API::WorkspaceGroup_sptr + correctWorkspaces(const API::WorkspaceGroup_sptr &wsGroup, + double loadedTimeZero); /// Builds an error message from a list of invalid periods std::string buildErrorString(const std::vector<int> &invalidPeriods) const; diff --git a/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/SANSBeamFinder.h b/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/SANSBeamFinder.h index 14feb749b97b2e4284dedb0d1389b0892994d178..4e5ade301355d87dd43635c7a67562f29ad3e135 100644 --- a/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/SANSBeamFinder.h +++ b/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/SANSBeamFinder.h @@ -40,8 +40,8 @@ private: void exec() override; API::MatrixWorkspace_sptr loadBeamFinderFile(const std::string &beamCenterFile); - void maskEdges(API::MatrixWorkspace_sptr beamCenterWS, int high, int low, - int left, int right, + void maskEdges(const API::MatrixWorkspace_sptr &beamCenterWS, int high, + int low, int left, int right, const std::string &componentName = "detector1"); boost::shared_ptr<Kernel::PropertyManager> m_reductionManager; diff --git a/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/SetupEQSANSReduction.h b/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/SetupEQSANSReduction.h index d58c344d69d639e09e94909dd6d543e60b77f4d1..fc5e6f053b362dd2f521697b78100a92112c41d3 100644 --- a/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/SetupEQSANSReduction.h +++ b/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/SetupEQSANSReduction.h @@ -39,12 +39,12 @@ private: /// Execution code void exec() override; std::string _findFile(std::string dataRun); - void - setupSensitivity(boost::shared_ptr<Kernel::PropertyManager> reductionManager); + void setupSensitivity( + const boost::shared_ptr<Kernel::PropertyManager> &reductionManager); void setupTransmission( - boost::shared_ptr<Kernel::PropertyManager> reductionManager); - void - setupBackground(boost::shared_ptr<Kernel::PropertyManager> reductionManager); + const boost::shared_ptr<Kernel::PropertyManager> &reductionManager); + void setupBackground( + const boost::shared_ptr<Kernel::PropertyManager> &reductionManager); }; } // namespace WorkflowAlgorithms diff --git a/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/SetupHFIRReduction.h b/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/SetupHFIRReduction.h index ab794a925ae0feb9958845cb5c70d141c539245d..e3f63b5d70f999f40d05edc2a8ceb8fd1edcb4fa 100644 --- a/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/SetupHFIRReduction.h +++ b/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/SetupHFIRReduction.h @@ -40,11 +40,11 @@ private: /// Execution code void exec() override; void setupTransmission( - boost::shared_ptr<Kernel::PropertyManager> reductionManager); - void - setupBackground(boost::shared_ptr<Kernel::PropertyManager> reductionManager); - void - setupSensitivity(boost::shared_ptr<Kernel::PropertyManager> reductionManager); + const boost::shared_ptr<Kernel::PropertyManager> &reductionManager); + void setupBackground( + const boost::shared_ptr<Kernel::PropertyManager> &reductionManager); + void setupSensitivity( + const boost::shared_ptr<Kernel::PropertyManager> &reductionManager); }; } // namespace WorkflowAlgorithms diff --git a/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/StepScan.h b/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/StepScan.h index 54981c1a711d270b4723483dfdcc09b1a730ef25..7fec136646bb02cb8ff59ec1a1681605cf7b5f74 100644 --- a/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/StepScan.h +++ b/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/StepScan.h @@ -35,13 +35,13 @@ private: void exec() override; DataObjects::EventWorkspace_sptr - getMonitorWorkspace(API::MatrixWorkspace_sptr inputWS); + getMonitorWorkspace(const API::MatrixWorkspace_sptr &inputWS); DataObjects::EventWorkspace_sptr - cloneInputWorkspace(API::Workspace_sptr inputWS); - void runMaskDetectors(API::MatrixWorkspace_sptr inputWS, - API::MatrixWorkspace_sptr maskWS); - void runFilterByXValue(API::MatrixWorkspace_sptr inputWS, const double xmin, - const double xmax); + cloneInputWorkspace(const API::Workspace_sptr &inputWS); + void runMaskDetectors(const API::MatrixWorkspace_sptr &inputWS, + const API::MatrixWorkspace_sptr &maskWS); + void runFilterByXValue(const API::MatrixWorkspace_sptr &inputWS, + const double xmin, const double xmax); }; } // namespace WorkflowAlgorithms diff --git a/Framework/WorkflowAlgorithms/src/AlignAndFocusPowder.cpp b/Framework/WorkflowAlgorithms/src/AlignAndFocusPowder.cpp index 38c7735f2c521f9baa6a6d6550802c1b00d07f74..2a5961d7306cdf1606d0a423863598c8149bc5b2 100644 --- a/Framework/WorkflowAlgorithms/src/AlignAndFocusPowder.cpp +++ b/Framework/WorkflowAlgorithms/src/AlignAndFocusPowder.cpp @@ -823,9 +823,9 @@ void AlignAndFocusPowder::exec() { /** Call edit instrument geometry */ API::MatrixWorkspace_sptr AlignAndFocusPowder::editInstrument( - API::MatrixWorkspace_sptr ws, std::vector<double> polars, - std::vector<specnum_t> specids, std::vector<double> l2s, - std::vector<double> phis) { + API::MatrixWorkspace_sptr ws, const std::vector<double> &polars, + const std::vector<specnum_t> &specids, const std::vector<double> &l2s, + const std::vector<double> &phis) { g_log.information() << "running EditInstrumentGeometry started at " << Types::Core::DateAndTime::getCurrentTime() << "\n"; @@ -884,7 +884,7 @@ AlignAndFocusPowder::diffractionFocus(API::MatrixWorkspace_sptr ws) { */ API::MatrixWorkspace_sptr AlignAndFocusPowder::convertUnits(API::MatrixWorkspace_sptr matrixws, - std::string target) { + const std::string &target) { g_log.information() << "running ConvertUnits(Target=" << target << ") started at " << Types::Core::DateAndTime::getCurrentTime() << "\n"; @@ -955,8 +955,8 @@ AlignAndFocusPowder::rebin(API::MatrixWorkspace_sptr matrixws) { /** Add workspace2 to workspace1 by adding spectrum. */ MatrixWorkspace_sptr -AlignAndFocusPowder::conjoinWorkspaces(API::MatrixWorkspace_sptr ws1, - API::MatrixWorkspace_sptr ws2, +AlignAndFocusPowder::conjoinWorkspaces(const API::MatrixWorkspace_sptr &ws1, + const API::MatrixWorkspace_sptr &ws2, size_t offset) { // Get information from ws1: maximum spectrum number, and store original // spectrum Nos @@ -1129,7 +1129,7 @@ void AlignAndFocusPowder::loadCalFile(const std::string &calFilename, * * @param ws :: any Workspace. Does nothing if not EventWorkspace. */ -void AlignAndFocusPowder::doSortEvents(Mantid::API::Workspace_sptr ws) { +void AlignAndFocusPowder::doSortEvents(const Mantid::API::Workspace_sptr &ws) { EventWorkspace_sptr eventWS = boost::dynamic_pointer_cast<EventWorkspace>(ws); if (!eventWS) return; diff --git a/Framework/WorkflowAlgorithms/src/DgsReduction.cpp b/Framework/WorkflowAlgorithms/src/DgsReduction.cpp index f14fbc06ef24f1b9d6041cce894fa939e7702ab6..0f1c20578807a83cec7cf92bd25685691a1a1298 100644 --- a/Framework/WorkflowAlgorithms/src/DgsReduction.cpp +++ b/Framework/WorkflowAlgorithms/src/DgsReduction.cpp @@ -566,7 +566,7 @@ void DgsReduction::init() { * Create a workspace by either loading a file or using an existing * workspace. */ -Workspace_sptr DgsReduction::loadInputData(const std::string prop, +Workspace_sptr DgsReduction::loadInputData(const std::string &prop, const bool mustLoad) { g_log.debug() << "MustLoad = " << mustLoad << '\n'; Workspace_sptr inputWS; @@ -648,7 +648,7 @@ MatrixWorkspace_sptr DgsReduction::loadHardMask() { } } -MatrixWorkspace_sptr DgsReduction::loadGroupingFile(const std::string prop) { +MatrixWorkspace_sptr DgsReduction::loadGroupingFile(const std::string &prop) { const std::string propName = prop + "GroupingFile"; const std::string groupFile = this->getProperty(propName); if (groupFile.empty()) { @@ -672,8 +672,9 @@ MatrixWorkspace_sptr DgsReduction::loadGroupingFile(const std::string prop) { } } -double DgsReduction::getParameter(std::string algParam, MatrixWorkspace_sptr ws, - std::string altParam) { +double DgsReduction::getParameter(const std::string &algParam, + const MatrixWorkspace_sptr &ws, + const std::string &altParam) { double param = this->getProperty(algParam); if (EMPTY_DBL() == param) { param = ws->getInstrument()->getNumberParameter(altParam)[0]; diff --git a/Framework/WorkflowAlgorithms/src/DgsRemap.cpp b/Framework/WorkflowAlgorithms/src/DgsRemap.cpp index f2675e2c31f01f414897a19ddc098c6ed6e4df75..dc3a07d689405d7795d87f7245828114544bd4e8 100644 --- a/Framework/WorkflowAlgorithms/src/DgsRemap.cpp +++ b/Framework/WorkflowAlgorithms/src/DgsRemap.cpp @@ -74,7 +74,7 @@ void DgsRemap::exec() { this->setProperty("OutputWorkspace", outputWS); } -void DgsRemap::execMasking(MatrixWorkspace_sptr iWS) { +void DgsRemap::execMasking(const MatrixWorkspace_sptr &iWS) { MatrixWorkspace_sptr maskWS = this->getProperty("MaskWorkspace"); if (maskWS) { IAlgorithm_sptr mask = this->createChildAlgorithm("MaskDetectors"); @@ -84,7 +84,7 @@ void DgsRemap::execMasking(MatrixWorkspace_sptr iWS) { } } -void DgsRemap::execGrouping(MatrixWorkspace_sptr iWS, +void DgsRemap::execGrouping(const MatrixWorkspace_sptr &iWS, MatrixWorkspace_sptr &oWS) { MatrixWorkspace_sptr groupWS = this->getProperty("GroupingWorkspace"); std::string oldGroupingFile = this->getProperty("OldGroupingFile"); diff --git a/Framework/WorkflowAlgorithms/src/EQSANSInstrument.cpp b/Framework/WorkflowAlgorithms/src/EQSANSInstrument.cpp index 8e335feaa8d73737048719733835ac127894f7bb..a775a38f9fcd5c79039451f165203be61e68b64f 100644 --- a/Framework/WorkflowAlgorithms/src/EQSANSInstrument.cpp +++ b/Framework/WorkflowAlgorithms/src/EQSANSInstrument.cpp @@ -7,10 +7,12 @@ //---------------------------------------------------------------------- // Includes //---------------------------------------------------------------------- -#include "MantidWorkflowAlgorithms/EQSANSInstrument.h" +#include <utility> + #include "MantidDataObjects/EventWorkspace.h" #include "MantidGeometry/Instrument.h" #include "MantidKernel/Exception.h" +#include "MantidWorkflowAlgorithms/EQSANSInstrument.h" namespace Mantid { namespace WorkflowAlgorithms { @@ -24,7 +26,7 @@ namespace EQSANSInstrument { * Read a parameter from the instrument description */ double readInstrumentParameter(const std::string ¶meter, - API::MatrixWorkspace_sptr dataWS) { + const API::MatrixWorkspace_sptr &dataWS) { std::vector<double> pars = dataWS->getInstrument()->getNumberParameter(parameter); if (pars.empty()) @@ -37,9 +39,9 @@ double readInstrumentParameter(const std::string ¶meter, * Return the detector ID corresponding to the [x,y] pixel coordinates. */ int getDetectorFromPixel(const int &pixel_x, const int &pixel_y, - API::MatrixWorkspace_sptr dataWS) { - int ny_pixels = - static_cast<int>(readInstrumentParameter("number-of-y-pixels", dataWS)); + const API::MatrixWorkspace_sptr &dataWS) { + int ny_pixels = static_cast<int>( + readInstrumentParameter("number-of-y-pixels", std::move(dataWS))); return ny_pixels * pixel_x + pixel_y; } @@ -48,7 +50,7 @@ int getDetectorFromPixel(const int &pixel_x, const int &pixel_y, * given pixel coordinates [m]. */ void getCoordinateFromPixel(const double &pixel_x, const double &pixel_y, - API::MatrixWorkspace_sptr dataWS, double &x, + const API::MatrixWorkspace_sptr &dataWS, double &x, double &y) { const int nx_pixels = static_cast<int>(readInstrumentParameter("number-of-x-pixels", dataWS)); @@ -68,8 +70,8 @@ void getCoordinateFromPixel(const double &pixel_x, const double &pixel_y, * @param y: real-space y coordinate [m] */ void getPixelFromCoordinate(const double &x, const double &y, - API::MatrixWorkspace_sptr dataWS, double &pixel_x, - double &pixel_y) { + const API::MatrixWorkspace_sptr &dataWS, + double &pixel_x, double &pixel_y) { const int nx_pixels = static_cast<int>(readInstrumentParameter("number-of-x-pixels", dataWS)); const int ny_pixels = @@ -84,9 +86,9 @@ void getPixelFromCoordinate(const double &x, const double &y, * Returns the default beam center position, or the pixel location * of real-space coordinates (0,0). */ -void getDefaultBeamCenter(API::MatrixWorkspace_sptr dataWS, double &pixel_x, - double &pixel_y) { - getPixelFromCoordinate(0.0, 0.0, dataWS, pixel_x, pixel_y); +void getDefaultBeamCenter(const API::MatrixWorkspace_sptr &dataWS, + double &pixel_x, double &pixel_y) { + getPixelFromCoordinate(0.0, 0.0, std::move(dataWS), pixel_x, pixel_y); } } // namespace EQSANSInstrument diff --git a/Framework/WorkflowAlgorithms/src/EQSANSLoad.cpp b/Framework/WorkflowAlgorithms/src/EQSANSLoad.cpp index 6eb5dc9957311a09c2d94ffb0b5ee90a7961e61a..67d70ac8cf4c51981ddb433e6342a14acf01e531 100644 --- a/Framework/WorkflowAlgorithms/src/EQSANSLoad.cpp +++ b/Framework/WorkflowAlgorithms/src/EQSANSLoad.cpp @@ -120,7 +120,7 @@ void EQSANSLoad::init() { /// Returns the value of a run property from a given workspace /// @param inputWS :: input workspace /// @param pname :: name of the property to retrieve -double getRunPropertyDbl(MatrixWorkspace_sptr inputWS, +double getRunPropertyDbl(const MatrixWorkspace_sptr &inputWS, const std::string &pname) { Mantid::Kernel::Property *prop = inputWS->run().getProperty(pname); auto *dp = dynamic_cast<Mantid::Kernel::PropertyWithValue<double> *>(prop); diff --git a/Framework/WorkflowAlgorithms/src/EQSANSMonitorTOF.cpp b/Framework/WorkflowAlgorithms/src/EQSANSMonitorTOF.cpp index 80c5abb0c8f9080a56bdb2da7ffe32b8e9a84a41..a35a04e1d8d8d163255be226a737f500f9ce5067 100644 --- a/Framework/WorkflowAlgorithms/src/EQSANSMonitorTOF.cpp +++ b/Framework/WorkflowAlgorithms/src/EQSANSMonitorTOF.cpp @@ -190,7 +190,7 @@ void EQSANSMonitorTOF::exec() { setProperty("OutputWorkspace", outputWS); } -double EQSANSMonitorTOF::getTofOffset(MatrixWorkspace_const_sptr inputWS, +double EQSANSMonitorTOF::getTofOffset(const MatrixWorkspace_const_sptr &inputWS, bool frame_skipping, double source_to_monitor) { //# Storage for chopper information read from the logs diff --git a/Framework/WorkflowAlgorithms/src/EQSANSQ2D.cpp b/Framework/WorkflowAlgorithms/src/EQSANSQ2D.cpp index 0e05c886d9df7f56f0091eccaba308bfca4e406d..e28de98b3f7d4b2f40e5a86178174b04729f0a04 100644 --- a/Framework/WorkflowAlgorithms/src/EQSANSQ2D.cpp +++ b/Framework/WorkflowAlgorithms/src/EQSANSQ2D.cpp @@ -39,7 +39,8 @@ void EQSANSQ2D::init() { /// Returns the value of a run property from a given workspace /// @param inputWS :: input workspace /// @param pname :: name of the property to retrieve -double getRunProperty(MatrixWorkspace_sptr inputWS, const std::string &pname) { +double getRunProperty(const MatrixWorkspace_sptr &inputWS, + const std::string &pname) { return inputWS->run().getPropertyValueAsType<double>(pname); } diff --git a/Framework/WorkflowAlgorithms/src/ExtractQENSMembers.cpp b/Framework/WorkflowAlgorithms/src/ExtractQENSMembers.cpp index c1659b2fcd3c66166555fcfd35fd03b49ab0effb..097629278935e881245e1f9ca681f0419f00458f 100644 --- a/Framework/WorkflowAlgorithms/src/ExtractQENSMembers.cpp +++ b/Framework/WorkflowAlgorithms/src/ExtractQENSMembers.cpp @@ -158,7 +158,7 @@ std::vector<double> ExtractQENSMembers::getQValues( * @return The retrieved axis labels. */ std::vector<std::string> -ExtractQENSMembers::getAxisLabels(MatrixWorkspace_sptr workspace, +ExtractQENSMembers::getAxisLabels(const MatrixWorkspace_sptr &workspace, size_t axisIndex) const { auto axis = workspace->getAxis(axisIndex); std::vector<std::string> labels; @@ -201,7 +201,7 @@ std::vector<std::string> ExtractQENSMembers::renameConvolvedMembers( * @return A workspace containing the extracted spectrum. */ MatrixWorkspace_sptr -ExtractQENSMembers::extractSpectrum(MatrixWorkspace_sptr inputWS, +ExtractQENSMembers::extractSpectrum(const MatrixWorkspace_sptr &inputWS, size_t spectrum) { auto extractAlg = createChildAlgorithm("ExtractSpectra", -1.0, -1.0, false); extractAlg->setProperty("InputWorkspace", inputWS); @@ -221,9 +221,9 @@ ExtractQENSMembers::extractSpectrum(MatrixWorkspace_sptr inputWS, * @param inputWS The input workspace to append to. * @param spectraWorkspace The workspace whose spectra to append. */ -MatrixWorkspace_sptr -ExtractQENSMembers::appendSpectra(MatrixWorkspace_sptr inputWS, - MatrixWorkspace_sptr spectraWorkspace) { +MatrixWorkspace_sptr ExtractQENSMembers::appendSpectra( + const MatrixWorkspace_sptr &inputWS, + const MatrixWorkspace_sptr &spectraWorkspace) { auto appendAlg = createChildAlgorithm("AppendSpectra", -1.0, -1.0, false); appendAlg->setProperty("InputWorkspace1", inputWS); appendAlg->setProperty("InputWorkspace2", spectraWorkspace); @@ -256,7 +256,8 @@ WorkspaceGroup_sptr ExtractQENSMembers::groupWorkspaces( * @return A vector of the created members workspaces. */ std::vector<MatrixWorkspace_sptr> ExtractQENSMembers::createMembersWorkspaces( - MatrixWorkspace_sptr initialWS, const std::vector<std::string> &members) { + const MatrixWorkspace_sptr &initialWS, + const std::vector<std::string> &members) { std::vector<MatrixWorkspace_sptr> memberWorkspaces; memberWorkspaces.reserve(members.size()); for (auto i = 0u; i < members.size(); ++i) @@ -272,7 +273,7 @@ std::vector<MatrixWorkspace_sptr> ExtractQENSMembers::createMembersWorkspaces( * @param members A vector containing the member workspaces. */ void ExtractQENSMembers::appendToMembers( - MatrixWorkspace_sptr resultWS, + const MatrixWorkspace_sptr &resultWS, std::vector<Mantid::API::MatrixWorkspace_sptr> &members) { for (auto i = 0u; i < members.size(); ++i) members[i] = appendSpectra(members[i], extractSpectrum(resultWS, i)); diff --git a/Framework/WorkflowAlgorithms/src/HFIRDarkCurrentSubtraction.cpp b/Framework/WorkflowAlgorithms/src/HFIRDarkCurrentSubtraction.cpp index 1fc8de3bca30398897053aaa804412772cbe0c9a..ea3bf5f6c296d06a475aa1c5ee7e410ae8af9d74 100644 --- a/Framework/WorkflowAlgorithms/src/HFIRDarkCurrentSubtraction.cpp +++ b/Framework/WorkflowAlgorithms/src/HFIRDarkCurrentSubtraction.cpp @@ -157,8 +157,8 @@ void HFIRDarkCurrentSubtraction::exec() { /// Get the counting time from a workspace /// @param inputWS :: workspace to read the counting time from -double -HFIRDarkCurrentSubtraction::getCountingTime(MatrixWorkspace_sptr inputWS) { +double HFIRDarkCurrentSubtraction::getCountingTime( + const MatrixWorkspace_sptr &inputWS) { // First, look whether we have the information in the log if (inputWS->run().hasProperty("timer")) { return inputWS->run().getPropertyValueAsType<double>("timer"); diff --git a/Framework/WorkflowAlgorithms/src/HFIRInstrument.cpp b/Framework/WorkflowAlgorithms/src/HFIRInstrument.cpp index fcedefe5c75478d780949b7511cf9b3c4bfd7621..1063baa7a96692c6428c4d86b79d5744682613f3 100644 --- a/Framework/WorkflowAlgorithms/src/HFIRInstrument.cpp +++ b/Framework/WorkflowAlgorithms/src/HFIRInstrument.cpp @@ -21,6 +21,7 @@ #include <boost/regex.hpp> #include <boost/shared_array.hpp> #include <boost/shared_ptr.hpp> +#include <utility> namespace Mantid { namespace WorkflowAlgorithms { @@ -34,7 +35,7 @@ namespace HFIRInstrument { * Read a parameter from the instrument description */ double readInstrumentParameter(const std::string ¶meter, - API::MatrixWorkspace_sptr dataWS) { + const API::MatrixWorkspace_sptr &dataWS) { std::vector<double> pars = dataWS->getInstrument()->getNumberParameter(parameter); if (pars.empty()) @@ -47,7 +48,7 @@ double readInstrumentParameter(const std::string ¶meter, * Return the detector ID corresponding to the [x,y] pixel coordinates. */ int getDetectorFromPixel(const int &pixel_x, const int &pixel_y, - API::MatrixWorkspace_sptr dataWS) { + const API::MatrixWorkspace_sptr &dataWS) { UNUSED_ARG(dataWS); return 1000000 + 1000 * pixel_x + pixel_y; } @@ -57,7 +58,7 @@ int getDetectorFromPixel(const int &pixel_x, const int &pixel_y, * given pixel coordinates [m]. */ void getCoordinateFromPixel(const double &pixel_x, const double &pixel_y, - API::MatrixWorkspace_sptr dataWS, double &x, + const API::MatrixWorkspace_sptr &dataWS, double &x, double &y) { const int nx_pixels = static_cast<int>(readInstrumentParameter("number-of-x-pixels", dataWS)); @@ -78,8 +79,8 @@ void getCoordinateFromPixel(const double &pixel_x, const double &pixel_y, * */ void getPixelFromCoordinate(const double &x, const double &y, - API::MatrixWorkspace_sptr dataWS, double &pixel_x, - double &pixel_y) { + const API::MatrixWorkspace_sptr &dataWS, + double &pixel_x, double &pixel_y) { const int nx_pixels = static_cast<int>(readInstrumentParameter("number-of-x-pixels", dataWS)); const int ny_pixels = @@ -94,9 +95,9 @@ void getPixelFromCoordinate(const double &x, const double &y, * Returns the default beam center position, or the pixel location * of real-space coordinates (0,0). */ -void getDefaultBeamCenter(API::MatrixWorkspace_sptr dataWS, double &pixel_x, - double &pixel_y) { - getPixelFromCoordinate(0.0, 0.0, dataWS, pixel_x, pixel_y); +void getDefaultBeamCenter(const API::MatrixWorkspace_sptr &dataWS, + double &pixel_x, double &pixel_y) { + getPixelFromCoordinate(0.0, 0.0, std::move(dataWS), pixel_x, pixel_y); } /* @@ -106,7 +107,7 @@ void getDefaultBeamCenter(API::MatrixWorkspace_sptr dataWS, double &pixel_x, * defined in instrument parameters file as "aperture-distances" * and sums "Header/sample_aperture_to_flange" */ -double getSourceToSampleDistance(API::MatrixWorkspace_sptr dataWS) { +double getSourceToSampleDistance(const API::MatrixWorkspace_sptr &dataWS) { double sourceToSampleDistance; diff --git a/Framework/WorkflowAlgorithms/src/IMuonAsymmetryCalculator.cpp b/Framework/WorkflowAlgorithms/src/IMuonAsymmetryCalculator.cpp index 3dd6530b6e5fa73ee3ff878bdf2f32387bdd5cf4..369be06715826c5f00f97dfecb54da4524d22bfe 100644 --- a/Framework/WorkflowAlgorithms/src/IMuonAsymmetryCalculator.cpp +++ b/Framework/WorkflowAlgorithms/src/IMuonAsymmetryCalculator.cpp @@ -25,8 +25,8 @@ namespace WorkflowAlgorithms { * from summed periods */ IMuonAsymmetryCalculator::IMuonAsymmetryCalculator( - const WorkspaceGroup_sptr inputWS, const std::vector<int> summedPeriods, - const std::vector<int> subtractedPeriods) + const WorkspaceGroup_sptr &inputWS, const std::vector<int> &summedPeriods, + const std::vector<int> &subtractedPeriods) : m_inputWS(inputWS), m_summedPeriods(summedPeriods), m_subtractedPeriods(subtractedPeriods) {} diff --git a/Framework/WorkflowAlgorithms/src/MuonGroupAsymmetryCalculator.cpp b/Framework/WorkflowAlgorithms/src/MuonGroupAsymmetryCalculator.cpp index a49dd44f8335d7c63dff94737dd4647168c52d98..92a15201ad5f3713e43e53b73e8250d7877d23a5 100644 --- a/Framework/WorkflowAlgorithms/src/MuonGroupAsymmetryCalculator.cpp +++ b/Framework/WorkflowAlgorithms/src/MuonGroupAsymmetryCalculator.cpp @@ -33,10 +33,10 @@ namespace WorkflowAlgorithms { * @param wsName :: the name of the workspace (for normalization table) */ MuonGroupAsymmetryCalculator::MuonGroupAsymmetryCalculator( - const Mantid::API::WorkspaceGroup_sptr inputWS, - const std::vector<int> summedPeriods, - const std::vector<int> subtractedPeriods, const int groupIndex, - const double start, const double end, const std::string wsName) + const Mantid::API::WorkspaceGroup_sptr &inputWS, + const std::vector<int> &summedPeriods, + const std::vector<int> &subtractedPeriods, const int groupIndex, + const double start, const double end, const std::string &wsName) : MuonGroupCalculator(inputWS, summedPeriods, subtractedPeriods, groupIndex) { MuonGroupCalculator::setStartEnd(start, end); diff --git a/Framework/WorkflowAlgorithms/src/MuonGroupCalculator.cpp b/Framework/WorkflowAlgorithms/src/MuonGroupCalculator.cpp index c17150ef32a32b63022f2c386fb2720c936eb6a8..4dc4d1ec99635bae8638d7c0a6688564841782c0 100644 --- a/Framework/WorkflowAlgorithms/src/MuonGroupCalculator.cpp +++ b/Framework/WorkflowAlgorithms/src/MuonGroupCalculator.cpp @@ -19,16 +19,16 @@ namespace WorkflowAlgorithms { * @param groupIndex :: [input] Workspace index of the group to analyse */ MuonGroupCalculator::MuonGroupCalculator( - const Mantid::API::WorkspaceGroup_sptr inputWS, - const std::vector<int> summedPeriods, - const std::vector<int> subtractedPeriods, const int groupIndex) + const Mantid::API::WorkspaceGroup_sptr &inputWS, + const std::vector<int> &summedPeriods, + const std::vector<int> &subtractedPeriods, const int groupIndex) : IMuonAsymmetryCalculator(inputWS, summedPeriods, subtractedPeriods), m_groupIndex(groupIndex) {} void MuonGroupCalculator::setStartEnd(const double start, const double end) { m_startX = start; m_endX = end; } -void MuonGroupCalculator::setWSName(const std::string wsName) { +void MuonGroupCalculator::setWSName(const std::string &wsName) { m_wsName = wsName; } } // namespace WorkflowAlgorithms diff --git a/Framework/WorkflowAlgorithms/src/MuonGroupCountsCalculator.cpp b/Framework/WorkflowAlgorithms/src/MuonGroupCountsCalculator.cpp index dd4565741960b90427e59d75603ac967793be1aa..0d50f9124dcad767385f13bc34bd27a0310f08bd 100644 --- a/Framework/WorkflowAlgorithms/src/MuonGroupCountsCalculator.cpp +++ b/Framework/WorkflowAlgorithms/src/MuonGroupCountsCalculator.cpp @@ -21,9 +21,9 @@ namespace WorkflowAlgorithms { * @param groupIndex :: [input] Workspace index of the group to analyse */ MuonGroupCountsCalculator::MuonGroupCountsCalculator( - const Mantid::API::WorkspaceGroup_sptr inputWS, - const std::vector<int> summedPeriods, - const std::vector<int> subtractedPeriods, const int groupIndex) + const Mantid::API::WorkspaceGroup_sptr &inputWS, + const std::vector<int> &summedPeriods, + const std::vector<int> &subtractedPeriods, const int groupIndex) : MuonGroupCalculator(inputWS, summedPeriods, subtractedPeriods, groupIndex) {} diff --git a/Framework/WorkflowAlgorithms/src/MuonPairAsymmetryCalculator.cpp b/Framework/WorkflowAlgorithms/src/MuonPairAsymmetryCalculator.cpp index 41f8868be78cbf66c3a9d7ef593ad9a9ae563cc7..e51b7ca8a64a24782ec36e38f271f4f9e663d570 100644 --- a/Framework/WorkflowAlgorithms/src/MuonPairAsymmetryCalculator.cpp +++ b/Framework/WorkflowAlgorithms/src/MuonPairAsymmetryCalculator.cpp @@ -27,9 +27,9 @@ namespace WorkflowAlgorithms { * @param alpha :: [input] Alpha (balance) value of the pair */ MuonPairAsymmetryCalculator::MuonPairAsymmetryCalculator( - const API::WorkspaceGroup_sptr inputWS, - const std::vector<int> summedPeriods, - const std::vector<int> subtractedPeriods, const int firstPairIndex, + const API::WorkspaceGroup_sptr &inputWS, + const std::vector<int> &summedPeriods, + const std::vector<int> &subtractedPeriods, const int firstPairIndex, const int secondPairIndex, const double alpha) : IMuonAsymmetryCalculator(inputWS, summedPeriods, subtractedPeriods), m_alpha(alpha), m_firstPairIndex(firstPairIndex), diff --git a/Framework/WorkflowAlgorithms/src/MuonProcess.cpp b/Framework/WorkflowAlgorithms/src/MuonProcess.cpp index 1fd924f9262c9d893d1c64502f7f3aee19920f80..414e9abca8345caf738baff73778cd980acd2349 100644 --- a/Framework/WorkflowAlgorithms/src/MuonProcess.cpp +++ b/Framework/WorkflowAlgorithms/src/MuonProcess.cpp @@ -218,8 +218,9 @@ void MuonProcess::exec() { * @param grouping :: Detector grouping table to use * @return Grouped workspaces */ -WorkspaceGroup_sptr MuonProcess::groupWorkspaces(WorkspaceGroup_sptr wsGroup, - TableWorkspace_sptr grouping) { +WorkspaceGroup_sptr +MuonProcess::groupWorkspaces(const WorkspaceGroup_sptr &wsGroup, + const TableWorkspace_sptr &grouping) { WorkspaceGroup_sptr outWS = boost::make_shared<WorkspaceGroup>(); for (int i = 0; i < wsGroup->getNumberOfEntries(); i++) { auto ws = boost::dynamic_pointer_cast<MatrixWorkspace>(wsGroup->getItem(i)); @@ -242,8 +243,8 @@ WorkspaceGroup_sptr MuonProcess::groupWorkspaces(WorkspaceGroup_sptr wsGroup, * @param dt :: Dead time table to use * @return Corrected workspace group */ -WorkspaceGroup_sptr MuonProcess::applyDTC(WorkspaceGroup_sptr wsGroup, - TableWorkspace_sptr dt) { +WorkspaceGroup_sptr MuonProcess::applyDTC(const WorkspaceGroup_sptr &wsGroup, + const TableWorkspace_sptr &dt) { WorkspaceGroup_sptr outWS = boost::make_shared<WorkspaceGroup>(); for (int i = 0; i < wsGroup->getNumberOfEntries(); i++) { auto ws = boost::dynamic_pointer_cast<MatrixWorkspace>(wsGroup->getItem(i)); @@ -273,8 +274,9 @@ WorkspaceGroup_sptr MuonProcess::applyDTC(WorkspaceGroup_sptr wsGroup, * offset * @return Corrected workspaces */ -WorkspaceGroup_sptr MuonProcess::correctWorkspaces(WorkspaceGroup_sptr wsGroup, - double loadedTimeZero) { +WorkspaceGroup_sptr +MuonProcess::correctWorkspaces(const WorkspaceGroup_sptr &wsGroup, + double loadedTimeZero) { WorkspaceGroup_sptr outWS = boost::make_shared<WorkspaceGroup>(); for (int i = 0; i < wsGroup->getNumberOfEntries(); i++) { auto ws = boost::dynamic_pointer_cast<MatrixWorkspace>(wsGroup->getItem(i)); diff --git a/Framework/WorkflowAlgorithms/src/ProcessIndirectFitParameters.cpp b/Framework/WorkflowAlgorithms/src/ProcessIndirectFitParameters.cpp index 1afb28210acda212503d97aa63048e67833fb859..8da85b6f7c7236e919537b24cf70ea6874dd0ca5 100644 --- a/Framework/WorkflowAlgorithms/src/ProcessIndirectFitParameters.cpp +++ b/Framework/WorkflowAlgorithms/src/ProcessIndirectFitParameters.cpp @@ -80,7 +80,7 @@ void extractColumnValues(Column const &column, std::size_t startRow, template <typename T, typename OutputIterator> void extractValuesFromColumns(std::size_t startRow, std::size_t endRow, - std::vector<Column_const_sptr> columns, + const std::vector<Column_const_sptr> &columns, OutputIterator outputIt) { for (auto &&column : columns) extractColumnValues<T>(*column, startRow, endRow, outputIt); @@ -104,7 +104,9 @@ std::vector<double> getNumericColumnValuesOrIndices(Column const &column, return getIncrementingSequence(0.0, length); } -std::string getColumnName(Column_const_sptr column) { return column->name(); } +std::string getColumnName(const Column_const_sptr &column) { + return column->name(); +} std::vector<std::string> extractColumnNames(std::vector<Column_const_sptr> const &columns) { diff --git a/Framework/WorkflowAlgorithms/src/SANSBeamFinder.cpp b/Framework/WorkflowAlgorithms/src/SANSBeamFinder.cpp index d79fce4546070bee5c7d80d021c9108a067bf514..7b1eab7f3d375a11aad37904f38435cdd5f7240d 100644 --- a/Framework/WorkflowAlgorithms/src/SANSBeamFinder.cpp +++ b/Framework/WorkflowAlgorithms/src/SANSBeamFinder.cpp @@ -246,8 +246,8 @@ void SANSBeamFinder::exec() { * 2016/05/06 : this only works for RectangularDetector * */ -void SANSBeamFinder::maskEdges(MatrixWorkspace_sptr beamCenterWS, int high, - int low, int left, int right, +void SANSBeamFinder::maskEdges(const MatrixWorkspace_sptr &beamCenterWS, + int high, int low, int left, int right, const std::string &componentName) { auto instrument = beamCenterWS->getInstrument(); diff --git a/Framework/WorkflowAlgorithms/src/SetupEQSANSReduction.cpp b/Framework/WorkflowAlgorithms/src/SetupEQSANSReduction.cpp index 1dbd40376b45e4b918befe962ac7fab1aa36c449..3b364ee50b6a5d618ddad8af53bafd3d2464a592 100644 --- a/Framework/WorkflowAlgorithms/src/SetupEQSANSReduction.cpp +++ b/Framework/WorkflowAlgorithms/src/SetupEQSANSReduction.cpp @@ -890,7 +890,7 @@ void SetupEQSANSReduction::exec() { } void SetupEQSANSReduction::setupSensitivity( - boost::shared_ptr<PropertyManager> reductionManager) { + const boost::shared_ptr<PropertyManager> &reductionManager) { const std::string reductionManagerName = getProperty("ReductionProperties"); const std::string sensitivityFile = getPropertyValue("SensitivityFile"); @@ -957,7 +957,7 @@ void SetupEQSANSReduction::setupSensitivity( } } void SetupEQSANSReduction::setupTransmission( - boost::shared_ptr<PropertyManager> reductionManager) { + const boost::shared_ptr<PropertyManager> &reductionManager) { const std::string reductionManagerName = getProperty("ReductionProperties"); // Transmission options const bool thetaDependentTrans = getProperty("ThetaDependentTransmission"); @@ -1042,7 +1042,7 @@ void SetupEQSANSReduction::setupTransmission( } void SetupEQSANSReduction::setupBackground( - boost::shared_ptr<PropertyManager> reductionManager) { + const boost::shared_ptr<PropertyManager> &reductionManager) { const std::string reductionManagerName = getProperty("ReductionProperties"); // Background const std::string backgroundFile = getPropertyValue("BackgroundFiles"); diff --git a/Framework/WorkflowAlgorithms/src/SetupHFIRReduction.cpp b/Framework/WorkflowAlgorithms/src/SetupHFIRReduction.cpp index abff959319d847e7af655f49717a628048ae4563..dfb032453ad2074d79c4bb60d394b2399b9923d9 100644 --- a/Framework/WorkflowAlgorithms/src/SetupHFIRReduction.cpp +++ b/Framework/WorkflowAlgorithms/src/SetupHFIRReduction.cpp @@ -904,7 +904,7 @@ void SetupHFIRReduction::exec() { } void SetupHFIRReduction::setupSensitivity( - boost::shared_ptr<PropertyManager> reductionManager) { + const boost::shared_ptr<PropertyManager> &reductionManager) { const std::string reductionManagerName = getProperty("ReductionProperties"); const std::string sensitivityFile = getPropertyValue("SensitivityFile"); @@ -994,7 +994,7 @@ void SetupHFIRReduction::setupSensitivity( } void SetupHFIRReduction::setupBackground( - boost::shared_ptr<PropertyManager> reductionManager) { + const boost::shared_ptr<PropertyManager> &reductionManager) { const std::string reductionManagerName = getProperty("ReductionProperties"); // Background const std::string backgroundFile = getPropertyValue("BackgroundFiles"); @@ -1112,7 +1112,7 @@ void SetupHFIRReduction::setupBackground( } void SetupHFIRReduction::setupTransmission( - boost::shared_ptr<PropertyManager> reductionManager) { + const boost::shared_ptr<PropertyManager> &reductionManager) { const std::string reductionManagerName = getProperty("ReductionProperties"); // Transmission options const bool thetaDependentTrans = getProperty("ThetaDependentTransmission"); diff --git a/Framework/WorkflowAlgorithms/src/StepScan.cpp b/Framework/WorkflowAlgorithms/src/StepScan.cpp index 81b4ab565b8c1988f1449e2d790f24948ccfa47a..3efd351eca42d2ec861de0eab65c9db81de0572f 100644 --- a/Framework/WorkflowAlgorithms/src/StepScan.cpp +++ b/Framework/WorkflowAlgorithms/src/StepScan.cpp @@ -114,14 +114,14 @@ void StepScan::exec() { * pointer. */ DataObjects::EventWorkspace_sptr -StepScan::getMonitorWorkspace(API::MatrixWorkspace_sptr inputWS) { +StepScan::getMonitorWorkspace(const API::MatrixWorkspace_sptr &inputWS) { // See if there's a monitor workspace inside the input one return boost::dynamic_pointer_cast<DataObjects::EventWorkspace>( inputWS->monitorWorkspace()); } DataObjects::EventWorkspace_sptr -StepScan::cloneInputWorkspace(API::Workspace_sptr inputWS) { +StepScan::cloneInputWorkspace(const API::Workspace_sptr &inputWS) { IAlgorithm_sptr clone = createChildAlgorithm("CloneWorkspace"); clone->setProperty("InputWorkspace", inputWS); clone->executeAsChildAlg(); @@ -134,8 +134,8 @@ StepScan::cloneInputWorkspace(API::Workspace_sptr inputWS) { * @param inputWS The input workspace * @param maskWS A masking workspace */ -void StepScan::runMaskDetectors(MatrixWorkspace_sptr inputWS, - MatrixWorkspace_sptr maskWS) { +void StepScan::runMaskDetectors(const MatrixWorkspace_sptr &inputWS, + const MatrixWorkspace_sptr &maskWS) { IAlgorithm_sptr maskingAlg = createChildAlgorithm("MaskDetectors"); maskingAlg->setProperty<MatrixWorkspace_sptr>("Workspace", inputWS); maskingAlg->setProperty<MatrixWorkspace_sptr>("MaskedWorkspace", maskWS); @@ -147,7 +147,7 @@ void StepScan::runMaskDetectors(MatrixWorkspace_sptr inputWS, * @param xmin The minimum value of the filter * @param xmax The maximum value of the filter */ -void StepScan::runFilterByXValue(MatrixWorkspace_sptr inputWS, +void StepScan::runFilterByXValue(const MatrixWorkspace_sptr &inputWS, const double xmin, const double xmax) { std::string rangeUnit = getProperty("RangeUnit"); // Run ConvertUnits on the input workspace if xmin/max were given in a diff --git a/Framework/WorkflowAlgorithms/test/AlignAndFocusPowderTest.h b/Framework/WorkflowAlgorithms/test/AlignAndFocusPowderTest.h index 8f737f7403c1fa43bb7ab95307327c050ad2d562..f3c3cd481e0ceb2bb98add6a1c5bc8d6aa70e123 100644 --- a/Framework/WorkflowAlgorithms/test/AlignAndFocusPowderTest.h +++ b/Framework/WorkflowAlgorithms/test/AlignAndFocusPowderTest.h @@ -692,7 +692,8 @@ public: } /* Utility functions */ - void loadDiffCal(std::string calfilename, bool group, bool cal, bool mask) { + void loadDiffCal(const std::string &calfilename, bool group, bool cal, + bool mask) { LoadDiffCal loadDiffAlg; loadDiffAlg.initialize(); loadDiffAlg.setPropertyValue("Filename", calfilename); @@ -704,7 +705,7 @@ public: loadDiffAlg.execute(); } - void groupAllBanks(std::string m_inputWS) { + void groupAllBanks(const std::string &m_inputWS) { CreateGroupingWorkspace groupAlg; groupAlg.initialize(); groupAlg.setPropertyValue("InputWorkspace", m_inputWS); @@ -713,7 +714,7 @@ public: groupAlg.execute(); } - void rebin(std::string params, bool preserveEvents = true) { + void rebin(const std::string ¶ms, bool preserveEvents = true) { Rebin rebin; rebin.initialize(); rebin.setPropertyValue("InputWorkspace", m_inputWS); @@ -734,8 +735,9 @@ public: resamplexAlg.execute(); } - std::string createArgForNumberHistograms(double val, MatrixWorkspace_sptr ws, - std::string delimiter = ",") { + std::string createArgForNumberHistograms(double val, + const MatrixWorkspace_sptr &ws, + const std::string &delimiter = ",") { std::vector<std::string> vec; for (size_t i = 0; i < ws->getNumberHistograms(); i++) vec.emplace_back(boost::lexical_cast<std::string>(val)); diff --git a/Framework/WorkflowAlgorithms/test/ExtractQENSMembersTest.h b/Framework/WorkflowAlgorithms/test/ExtractQENSMembersTest.h index 31adb867821815b7ad4bd077e078eeb73df4f44c..b3e725f6513114743b65be3a754e74feb4f17606 100644 --- a/Framework/WorkflowAlgorithms/test/ExtractQENSMembersTest.h +++ b/Framework/WorkflowAlgorithms/test/ExtractQENSMembersTest.h @@ -26,6 +26,7 @@ #include <algorithm> #include <memory> #include <random> +#include <utility> using Mantid::Algorithms::ExtractQENSMembers; @@ -94,7 +95,7 @@ public: } private: - void checkMembersOutput(WorkspaceGroup_sptr membersWorkspace, + void checkMembersOutput(const WorkspaceGroup_sptr &membersWorkspace, const std::vector<std::string> &members, const std::string &outputName, size_t numSpectra, const std::vector<double> &dataX) const { @@ -112,31 +113,32 @@ private: } } - WorkspaceGroup_sptr extractMembers(MatrixWorkspace_sptr inputWs, - WorkspaceGroup_sptr resultGroupWs, + WorkspaceGroup_sptr extractMembers(const MatrixWorkspace_sptr &inputWs, + const WorkspaceGroup_sptr &resultGroupWs, const std::string &outputWsName) const { - auto extractAlgorithm = - extractMembersAlgorithm(inputWs, resultGroupWs, outputWsName); + auto extractAlgorithm = extractMembersAlgorithm( + std::move(inputWs), std::move(resultGroupWs), outputWsName); extractAlgorithm->execute(); return AnalysisDataService::Instance().retrieveWS<WorkspaceGroup>( outputWsName); } WorkspaceGroup_sptr - extractMembers(MatrixWorkspace_sptr inputWs, - WorkspaceGroup_sptr resultGroupWs, + extractMembers(const MatrixWorkspace_sptr &inputWs, + const WorkspaceGroup_sptr &resultGroupWs, const std::vector<std::string> &convolvedMembers, const std::string &outputWsName) const { - auto extractAlgorithm = extractMembersAlgorithm( - inputWs, resultGroupWs, convolvedMembers, outputWsName); + auto extractAlgorithm = + extractMembersAlgorithm(std::move(inputWs), std::move(resultGroupWs), + convolvedMembers, outputWsName); extractAlgorithm->execute(); return AnalysisDataService::Instance().retrieveWS<WorkspaceGroup>( outputWsName); } IAlgorithm_sptr - extractMembersAlgorithm(MatrixWorkspace_sptr inputWs, - WorkspaceGroup_sptr resultGroupWs, + extractMembersAlgorithm(const MatrixWorkspace_sptr &inputWs, + const WorkspaceGroup_sptr &resultGroupWs, const std::string &outputWsName) const { auto extractMembersAlg = AlgorithmManager::Instance().create("ExtractQENSMembers"); @@ -147,8 +149,8 @@ private: } IAlgorithm_sptr - extractMembersAlgorithm(MatrixWorkspace_sptr inputWs, - WorkspaceGroup_sptr resultGroupWs, + extractMembersAlgorithm(const MatrixWorkspace_sptr &inputWs, + const WorkspaceGroup_sptr &resultGroupWs, const std::vector<std::string> &convolvedMembers, const std::string &outputWsName) const { auto extractMembersAlg = @@ -205,9 +207,11 @@ private: return createWorkspace->getProperty("OutputWorkspace"); } - MatrixWorkspace_sptr appendSpectra(MatrixWorkspace_sptr workspace, - MatrixWorkspace_sptr spectraWS) const { - auto appendAlgorithm = appendSpectraAlgorithm(workspace, spectraWS); + MatrixWorkspace_sptr + appendSpectra(const MatrixWorkspace_sptr &workspace, + const MatrixWorkspace_sptr &spectraWS) const { + auto appendAlgorithm = + appendSpectraAlgorithm(std::move(workspace), std::move(spectraWS)); appendAlgorithm->execute(); return appendAlgorithm->getProperty("OutputWorkspace"); } @@ -257,8 +261,9 @@ private: return createWorkspace; } - IAlgorithm_sptr appendSpectraAlgorithm(MatrixWorkspace_sptr workspace, - MatrixWorkspace_sptr spectraWS) const { + IAlgorithm_sptr + appendSpectraAlgorithm(const MatrixWorkspace_sptr &workspace, + const MatrixWorkspace_sptr &spectraWS) const { auto appendAlgorithm = AlgorithmManager::Instance().create("AppendSpectra"); appendAlgorithm->setChild(true); appendAlgorithm->setProperty("InputWorkspace1", workspace); diff --git a/MantidPlot/src/ApplicationWindow.cpp b/MantidPlot/src/ApplicationWindow.cpp index a403111cc381f952ab5a9833f4f60e0c5a4aac4f..b5af9c6165523e02640d09044a7c2cc83e04dbee 100644 --- a/MantidPlot/src/ApplicationWindow.cpp +++ b/MantidPlot/src/ApplicationWindow.cpp @@ -180,6 +180,7 @@ #include <gsl/gsl_sort.h> #include <boost/regex.hpp> +#include <utility> #include <Poco/Path.h> @@ -3161,7 +3162,7 @@ void ApplicationWindow::initTable(Table *w, const QString &caption) { * base */ TableStatistics *ApplicationWindow::newTableStatistics(Table *base, int type, - QList<int> target, + const QList<int> &target, const QString &caption) { TableStatistics *s = new TableStatistics(scriptingEnv(), this, base, (TableStatistics::Type)type, target); @@ -4231,7 +4232,7 @@ void ApplicationWindow::importASCII( const QString &local_column_separator, int local_ignored_lines, bool local_rename_columns, bool local_strip_spaces, bool local_simplify_spaces, bool local_import_comments, - bool update_dec_separators, QLocale local_separators, + bool update_dec_separators, const QLocale &local_separators, const QString &local_comment_string, bool import_read_only, int endLineChar, const QString &sepforloadAscii) { if (files.isEmpty()) @@ -6158,7 +6159,7 @@ void ApplicationWindow::loadDataFile() { saveSettings(); // save new list of recent files } -void ApplicationWindow::loadDataFileByName(QString fn) { +void ApplicationWindow::loadDataFileByName(const QString &fn) { QFileInfo fnInfo(fn); AlgorithmInputHistory::Instance().setPreviousDirectory( fnInfo.absoluteDir().path()); @@ -13709,7 +13710,7 @@ void ApplicationWindow::updateRecentProjectsList() { recentProjects[i]); } -void ApplicationWindow::updateRecentFilesList(QString fname) { +void ApplicationWindow::updateRecentFilesList(const QString &fname) { if (!fname.isEmpty()) { recentFiles.removeAll(fname); recentFiles.push_front(fname); @@ -16791,8 +16792,8 @@ bool ApplicationWindow::isOfType(const QObject *obj, * @param sourceFile The full path to the .project file * @return True is loading was successful, false otherwise */ -bool ApplicationWindow::loadProjectRecovery(std::string sourceFile, - std::string recoveryFolder) { +bool ApplicationWindow::loadProjectRecovery(const std::string &sourceFile, + const std::string &recoveryFolder) { // Wait on this thread until scriptWindow is finished (Should be a seperate // thread) do { @@ -16801,7 +16802,7 @@ bool ApplicationWindow::loadProjectRecovery(std::string sourceFile, const bool isRecovery = true; ProjectSerialiser projectWriter(this, isRecovery); // File version is not applicable to project recovery - so set to 0 - const auto loadSuccess = projectWriter.load(sourceFile, 0); + const auto loadSuccess = projectWriter.load(std::move(sourceFile), 0); // Handle the removal of old checkpoints and start project saving again Poco::Path deletePath(recoveryFolder); @@ -16820,7 +16821,7 @@ bool ApplicationWindow::loadProjectRecovery(std::string sourceFile, * @param destination:: The full path to write the recovery file to * @return True if saving is successful, false otherwise */ -bool ApplicationWindow::saveProjectRecovery(std::string destination) { +bool ApplicationWindow::saveProjectRecovery(const std::string &destination) { const bool isRecovery = true; ProjectSerialiser projectWriter(this, isRecovery); return projectWriter.save(QString::fromStdString(destination)); diff --git a/MantidPlot/src/ApplicationWindow.h b/MantidPlot/src/ApplicationWindow.h index 0bc349a2f26071d732fd8fb884a755a10ed4ffb2..df62345d86aab9087af8c83b884fdd53c9dd98d7 100644 --- a/MantidPlot/src/ApplicationWindow.h +++ b/MantidPlot/src/ApplicationWindow.h @@ -233,7 +233,7 @@ public slots: /// Load mantid data files using generic load algorithm, opening user dialog void loadDataFile(); /// Load mantid data files (generic load algorithm) - void loadDataFileByName(QString fn); + void loadDataFileByName(const QString &fn); /// Open from the list of recent files void openRecentFile(QAction *action); @@ -492,7 +492,7 @@ public slots: int local_ignored_lines, bool local_rename_columns, bool local_strip_spaces, bool local_simplify_spaces, bool local_import_comments, bool update_dec_separators, - QLocale local_separators, + const QLocale &local_separators, const QString &local_comment_string, bool import_read_only, int endLineChar, const QString &sepforloadAscii); void exportAllTables(const QString &sep, bool colNames, bool colComments, @@ -503,7 +503,7 @@ public slots: //! recalculate selected cells of current table void recalculateTable(); - TableStatistics *newTableStatistics(Table *base, int type, QList<int>, + TableStatistics *newTableStatistics(Table *base, int type, const QList<int> &, const QString &caption = QString::null); //@} @@ -916,7 +916,7 @@ public slots: void updateRecentProjectsList(); //! Inserts file name in the list of recent files (if fname not empty) and // updates the "recent files" menu - void updateRecentFilesList(QString fname = ""); + void updateRecentFilesList(const QString &fname = ""); //! Open QtiPlot homepage in external browser void showHomePage(); //! Open bug tracking system at berliOS in external browser @@ -1123,11 +1123,12 @@ public slots: bool isOfType(const QObject *obj, const char *toCompare) const; - bool loadProjectRecovery(std::string sourceFile, std::string recoveryFolder); + bool loadProjectRecovery(const std::string &sourceFile, + const std::string &recoveryFolder); // The string must be copied from the other thread in saveProjectRecovery /// Saves the current project as part of recovery auto saving - bool saveProjectRecovery(std::string destination); + bool saveProjectRecovery(const std::string &destination); /// Checks for and attempts project recovery if required void checkForProjectRecovery(); diff --git a/MantidPlot/src/AssociationsDialog.cpp b/MantidPlot/src/AssociationsDialog.cpp index c2f5329ef7b454fb781d78851d8b622b62db79d0..88be52400b02868861f3c38c48c90cd91dc662c3 100644 --- a/MantidPlot/src/AssociationsDialog.cpp +++ b/MantidPlot/src/AssociationsDialog.cpp @@ -45,8 +45,9 @@ #include <QMessageBox> #include <QPushButton> #include <QTableWidget> +#include <utility> -AssociationsDialog::AssociationsDialog(Graph *g, Qt::WFlags fl) +AssociationsDialog::AssociationsDialog(Graph *g, const Qt::WFlags &fl) : QDialog(g, fl) { setObjectName("AssociationsDialog"); setWindowTitle(tr("MantidPlot - Plot Associations")); @@ -192,7 +193,7 @@ QString AssociationsDialog::plotAssociation(const QString &text) { } void AssociationsDialog::initTablesList(QList<MdiSubWindow *> lst, int curve) { - tables = lst; + tables = std::move(lst); active_table = nullptr; if (curve < 0 || curve >= static_cast<int>(associations->count())) diff --git a/MantidPlot/src/AssociationsDialog.h b/MantidPlot/src/AssociationsDialog.h index d247ba76570159944f0422160f9774c42431c848..502b6f6df429ebdc7bc436ff106e5983e5144701 100644 --- a/MantidPlot/src/AssociationsDialog.h +++ b/MantidPlot/src/AssociationsDialog.h @@ -46,7 +46,7 @@ class AssociationsDialog : public QDialog { Q_OBJECT public: - AssociationsDialog(Graph *g, Qt::WFlags fl = nullptr); + AssociationsDialog(Graph *g, const Qt::WFlags &fl = nullptr); void initTablesList(QList<MdiSubWindow *> lst, int curve); diff --git a/MantidPlot/src/AxesDialog.cpp b/MantidPlot/src/AxesDialog.cpp index 8548910e0720d35d931f9177eeefb32704387316..912115a736a1ad8132d46528fc6f14dfd4e570a5 100644 --- a/MantidPlot/src/AxesDialog.cpp +++ b/MantidPlot/src/AxesDialog.cpp @@ -1496,7 +1496,7 @@ Mantid::Kernel::Logger g_log("AxisDialog"); * @param g :: the graph the dialog is settign the options for * @param fl :: The QT flags for this window */ -AxesDialog::AxesDialog(ApplicationWindow *app, Graph *g, Qt::WFlags fl) +AxesDialog::AxesDialog(ApplicationWindow *app, Graph *g, const Qt::WFlags &fl) : QDialog(g, fl), m_app(app), m_graph(g) { QPixmap image4((const char **)image4_data); QPixmap image5((const char **)image5_data); diff --git a/MantidPlot/src/AxesDialog.h b/MantidPlot/src/AxesDialog.h index 2c22a6e3db8e899ebada3fd6f071e38bf3945c94..5396b1fcdf6a9d7495dba3f9e76624400f0635f8 100644 --- a/MantidPlot/src/AxesDialog.h +++ b/MantidPlot/src/AxesDialog.h @@ -71,7 +71,7 @@ class AxesDialog : public QDialog { Q_OBJECT public: - AxesDialog(ApplicationWindow *app, Graph *g, Qt::WFlags fl = nullptr); + AxesDialog(ApplicationWindow *app, Graph *g, const Qt::WFlags &fl = nullptr); ~AxesDialog() override; public slots: diff --git a/MantidPlot/src/BoxCurve.h b/MantidPlot/src/BoxCurve.h index 55f8019398dbbf1c4c7ba68ce9610f23308cfef9..edc1839f79e6e63e1ced972cba9bcea9d9cd4873 100644 --- a/MantidPlot/src/BoxCurve.h +++ b/MantidPlot/src/BoxCurve.h @@ -33,6 +33,8 @@ #include <qwt_plot.h> #include <qwt_symbol.h> +#include <utility> + //! Box curve class BoxCurve : public DataCurve { public: @@ -97,7 +99,7 @@ private: class QwtSingleArrayData : public QwtData { public: QwtSingleArrayData(const double x, QwtArray<double> y, size_t) { - d_y = y; + d_y = std::move(y); d_x = x; }; diff --git a/MantidPlot/src/ColorMapDialog.cpp b/MantidPlot/src/ColorMapDialog.cpp index ec3bd737efdb263d9ca698c27a3041f6cfc06c7d..e161f8a3505d93a0a7bd47f2fb537532e4d4434f 100644 --- a/MantidPlot/src/ColorMapDialog.cpp +++ b/MantidPlot/src/ColorMapDialog.cpp @@ -33,7 +33,7 @@ #include <QLayout> #include <QPushButton> -ColorMapDialog::ColorMapDialog(QWidget *parent, Qt::WFlags fl) +ColorMapDialog::ColorMapDialog(QWidget *parent, const Qt::WFlags &fl) : QDialog(parent, fl), applyBtn(nullptr), closeBtn(nullptr), editor(nullptr), d_matrix(nullptr) { setObjectName("ColorMapDialog"); diff --git a/MantidPlot/src/ColorMapDialog.h b/MantidPlot/src/ColorMapDialog.h index 916b1a9d156f6f0e2fec4168c8d99182bed6eb40..27811a06fefee45b381e1749f55ed4ee5f0199f1 100644 --- a/MantidPlot/src/ColorMapDialog.h +++ b/MantidPlot/src/ColorMapDialog.h @@ -37,7 +37,7 @@ class ColorMapDialog : public QDialog { Q_OBJECT public: - ColorMapDialog(QWidget *parent = nullptr, Qt::WFlags fl = nullptr); + ColorMapDialog(QWidget *parent = nullptr, const Qt::WFlags &fl = nullptr); void setMatrix(Matrix *m); protected slots: diff --git a/MantidPlot/src/ConfigDialog.cpp b/MantidPlot/src/ConfigDialog.cpp index 92fd15419a6677bc93e7c4bd5baf987d1bdbaf6b..5e6fb1596b8d98fab61fbfbf97d46982f7a3bbcf 100644 --- a/MantidPlot/src/ConfigDialog.cpp +++ b/MantidPlot/src/ConfigDialog.cpp @@ -1541,7 +1541,7 @@ void ConfigDialog::correctTreePatrialTicks(QTreeWidgetItem &topLevelCat) { } QTreeWidgetItem * -ConfigDialog::createCheckedTreeItem(QString name, +ConfigDialog::createCheckedTreeItem(const QString &name, Qt::CheckState checkBoxState) { QTreeWidgetItem *item = new QTreeWidgetItem(QStringList(name)); item->setFlags(item->flags() | Qt::ItemIsUserCheckable); diff --git a/MantidPlot/src/ConfigDialog.h b/MantidPlot/src/ConfigDialog.h index 669c79f9e914c9d65df70840e58e5f98436b81e2..e68e6907f6595ebe8a78dbecde6e5e4528601242 100644 --- a/MantidPlot/src/ConfigDialog.h +++ b/MantidPlot/src/ConfigDialog.h @@ -178,7 +178,7 @@ private: void updateMdPlottingSettings(); void setupMdPlottingConnections(); - QTreeWidgetItem *createCheckedTreeItem(QString name, + QTreeWidgetItem *createCheckedTreeItem(const QString &name, Qt::CheckState checkBoxState); QStringList buildHiddenCategoryString(QTreeWidgetItem *parent = nullptr); diff --git a/MantidPlot/src/CurveRangeDialog.cpp b/MantidPlot/src/CurveRangeDialog.cpp index 6af557138fad811f6cda0293c24f60b2640e9d35..0f2159bdb3b854df48b2bc65113cf7e7457b548a 100644 --- a/MantidPlot/src/CurveRangeDialog.cpp +++ b/MantidPlot/src/CurveRangeDialog.cpp @@ -27,7 +27,7 @@ #include <QPushButton> #include <QSpinBox> -CurveRangeDialog::CurveRangeDialog(QWidget *parent, Qt::WFlags fl) +CurveRangeDialog::CurveRangeDialog(QWidget *parent, const Qt::WFlags &fl) : QDialog(parent, fl), d_curve(nullptr), d_graph(nullptr) { setWindowTitle(tr("MantidPlot - Plot range")); setObjectName("CurveRangeDialog"); diff --git a/MantidPlot/src/CurveRangeDialog.h b/MantidPlot/src/CurveRangeDialog.h index 1f36476e890ba4debb74be8fba60bfe834f7620b..28749672cab67d1850eff60b74bc6fd71fef661f 100644 --- a/MantidPlot/src/CurveRangeDialog.h +++ b/MantidPlot/src/CurveRangeDialog.h @@ -30,7 +30,7 @@ class CurveRangeDialog : public QDialog { Q_OBJECT public: - CurveRangeDialog(QWidget *parent = nullptr, Qt::WFlags fl = nullptr); + CurveRangeDialog(QWidget *parent = nullptr, const Qt::WFlags &fl = nullptr); public slots: void setCurveToModify(Graph *g, int curve); diff --git a/MantidPlot/src/CurvesDialog.cpp b/MantidPlot/src/CurvesDialog.cpp index 9c4b51f0fc4e85e7b488b25edb639ed5564e9184..0539402541b780e71049a0ed4ce79e1d71663851 100644 --- a/MantidPlot/src/CurvesDialog.cpp +++ b/MantidPlot/src/CurvesDialog.cpp @@ -56,7 +56,8 @@ using namespace MantidQt::API; -CurvesDialog::CurvesDialog(ApplicationWindow *app, Graph *g, Qt::WFlags fl) +CurvesDialog::CurvesDialog(ApplicationWindow *app, Graph *g, + const Qt::WFlags &fl) : QDialog(g, fl), d_app(app), d_graph(g) { if (!app) { throw std::logic_error( diff --git a/MantidPlot/src/CurvesDialog.h b/MantidPlot/src/CurvesDialog.h index 90fb0c8a74ec07498243dc5d1552669b84651eef..9d113a1a1dc7638b6fc426b594db7b61c5bf9310 100644 --- a/MantidPlot/src/CurvesDialog.h +++ b/MantidPlot/src/CurvesDialog.h @@ -45,7 +45,8 @@ class CurvesDialog : public QDialog { Q_OBJECT public: - CurvesDialog(ApplicationWindow *app, Graph *g, Qt::WFlags fl = nullptr); + CurvesDialog(ApplicationWindow *app, Graph *g, + const Qt::WFlags &fl = nullptr); ~CurvesDialog() override; private slots: diff --git a/MantidPlot/src/CustomActionDialog.cpp b/MantidPlot/src/CustomActionDialog.cpp index 1f6a1206e078697c2ecf1fc88f560d8b37ac09a5..51b62e93ba6f33012cb8316c05e7b07f444f1ad5 100644 --- a/MantidPlot/src/CustomActionDialog.cpp +++ b/MantidPlot/src/CustomActionDialog.cpp @@ -36,7 +36,7 @@ #include <QShortcut> #include <QToolBar> -CustomActionDialog::CustomActionDialog(QWidget *parent, Qt::WFlags fl) +CustomActionDialog::CustomActionDialog(QWidget *parent, const Qt::WFlags &fl) : QDialog(parent, fl) { setWindowTitle(tr("MantidPlot") + " - " + tr("Add Custom Action")); diff --git a/MantidPlot/src/CustomActionDialog.h b/MantidPlot/src/CustomActionDialog.h index 2cf37166bcea0669776ee986c277e86c812470e2..bc7d4c3aa4a49ea50c847108e451fe5f4fc3b241 100644 --- a/MantidPlot/src/CustomActionDialog.h +++ b/MantidPlot/src/CustomActionDialog.h @@ -38,7 +38,7 @@ public: * @param parent :: parent widget (must be the application window!= * @param fl :: window flags */ - CustomActionDialog(QWidget *parent, Qt::WFlags fl = nullptr); + CustomActionDialog(QWidget *parent, const Qt::WFlags &fl = nullptr); private slots: void chooseIcon(); diff --git a/MantidPlot/src/DataSetDialog.cpp b/MantidPlot/src/DataSetDialog.cpp index 4a498d9a3b9717f251b287f211128712f2a7a650..b488801c6bec307e8135c14a1e821e9807097d28 100644 --- a/MantidPlot/src/DataSetDialog.cpp +++ b/MantidPlot/src/DataSetDialog.cpp @@ -40,7 +40,7 @@ #include <QVBoxLayout> DataSetDialog::DataSetDialog(const QString &text, ApplicationWindow *app, - Graph *g, Qt::WFlags fl) + Graph *g, const Qt::WFlags &fl) : QDialog(g, fl), d_app(app), d_graph(g) { setAttribute(Qt::WA_DeleteOnClose); setWindowTitle(tr("MantidPlot - Select data set")); diff --git a/MantidPlot/src/DataSetDialog.h b/MantidPlot/src/DataSetDialog.h index dc60ab2abdfd6102b61c8f859e2b42442c630161..ebb4b7657ec0d3891d29deb1f2115e2d89f99915 100644 --- a/MantidPlot/src/DataSetDialog.h +++ b/MantidPlot/src/DataSetDialog.h @@ -45,7 +45,7 @@ class DataSetDialog : public QDialog { public: DataSetDialog(const QString &text, ApplicationWindow *app, Graph *g = nullptr, - Qt::WFlags fl = nullptr); + const Qt::WFlags &fl = nullptr); public slots: void accept() override; diff --git a/MantidPlot/src/ErrDialog.cpp b/MantidPlot/src/ErrDialog.cpp index addd11bef981d196c650afee560db67272f17094..47597ad6dbac4af06db1f79695ce97530416e6cd 100644 --- a/MantidPlot/src/ErrDialog.cpp +++ b/MantidPlot/src/ErrDialog.cpp @@ -45,7 +45,7 @@ #include <QVBoxLayout> #include <QWidget> -ErrDialog::ErrDialog(ApplicationWindow *parent, Qt::WFlags fl) +ErrDialog::ErrDialog(ApplicationWindow *parent, const Qt::WFlags &fl) : QDialog(parent, fl) { setFocusPolicy(Qt::StrongFocus); setSizeGripEnabled(true); @@ -166,7 +166,7 @@ void ErrDialog::setCurveNames(const QStringList &names) { nameLabel->addItems(names); } -void ErrDialog::setSrcTables(QList<MdiSubWindow *> tables) { +void ErrDialog::setSrcTables(const QList<MdiSubWindow *> &tables) { if (tables.isEmpty()) return; diff --git a/MantidPlot/src/ErrDialog.h b/MantidPlot/src/ErrDialog.h index 84287351570a7fc6cce13848a036048683ab51f7..83ac907e708391c41ee26df6f484ca801197988a 100644 --- a/MantidPlot/src/ErrDialog.h +++ b/MantidPlot/src/ErrDialog.h @@ -52,7 +52,7 @@ public: * @param parent :: parent widget * @param fl :: window flags */ - ErrDialog(ApplicationWindow *parent, Qt::WFlags fl = nullptr); + ErrDialog(ApplicationWindow *parent, const Qt::WFlags &fl = nullptr); private: QLabel *textLabel1; @@ -82,7 +82,7 @@ public slots: //! Supply the dialog with a curves list void setCurveNames(const QStringList &names); //! Supply the dialog with a tables list - void setSrcTables(QList<MdiSubWindow *> tables); + void setSrcTables(const QList<MdiSubWindow *> &tables); //! Select a table void selectSrcTable(int tabnr); diff --git a/MantidPlot/src/ExpDecayDialog.cpp b/MantidPlot/src/ExpDecayDialog.cpp index d39b38573f46c998e9ad400862941c3370baa372..e13b229a77d9397ab0f82c79ca1063ed240736f3 100644 --- a/MantidPlot/src/ExpDecayDialog.cpp +++ b/MantidPlot/src/ExpDecayDialog.cpp @@ -43,7 +43,7 @@ #include <QMessageBox> #include <QPushButton> -ExpDecayDialog::ExpDecayDialog(int type, QWidget *parent, Qt::WFlags fl) +ExpDecayDialog::ExpDecayDialog(int type, QWidget *parent, const Qt::WFlags &fl) : QDialog(parent, fl), fitter(nullptr), graph(nullptr), buttonFit(nullptr), buttonCancel(nullptr), boxName(nullptr), boxAmplitude(nullptr), boxFirst(nullptr), boxSecond(nullptr), boxThird(nullptr), diff --git a/MantidPlot/src/ExpDecayDialog.h b/MantidPlot/src/ExpDecayDialog.h index 8c3b04102aef8dda106cb7be411ec4d8fff45269..217f8c9d991a04498f9ffc10cdbe560d91466ac5 100644 --- a/MantidPlot/src/ExpDecayDialog.h +++ b/MantidPlot/src/ExpDecayDialog.h @@ -44,7 +44,8 @@ class ExpDecayDialog : public QDialog { Q_OBJECT public: - ExpDecayDialog(int type, QWidget *parent = nullptr, Qt::WFlags fl = nullptr); + ExpDecayDialog(int type, QWidget *parent = nullptr, + const Qt::WFlags &fl = nullptr); public slots: void fit(); diff --git a/MantidPlot/src/ExportDialog.cpp b/MantidPlot/src/ExportDialog.cpp index 514ac1e30d72c906bf3c3287332bbd80b77b5d78..9ed732b74092dcea0a2d662008380c380dbef2d8 100644 --- a/MantidPlot/src/ExportDialog.cpp +++ b/MantidPlot/src/ExportDialog.cpp @@ -39,7 +39,7 @@ #include <QPushButton> ExportDialog::ExportDialog(const QString &tableName, QWidget *parent, - Qt::WFlags fl) + const Qt::WFlags &fl) : QDialog(parent, fl) { setWindowTitle(tr("MantidPlot - Export ASCII")); setSizeGripEnabled(true); diff --git a/MantidPlot/src/ExportDialog.h b/MantidPlot/src/ExportDialog.h index 2d135b20e0d7a8978162101a99db31c505d7a568..bd5f0a65f9720fb39c4ba9e7db7acc9d0e4033c1 100644 --- a/MantidPlot/src/ExportDialog.h +++ b/MantidPlot/src/ExportDialog.h @@ -47,7 +47,7 @@ public: * @param fl :: window flags */ ExportDialog(const QString &tableName, QWidget *parent = nullptr, - Qt::WFlags fl = nullptr); + const Qt::WFlags &fl = nullptr); private: void closeEvent(QCloseEvent *) override; diff --git a/MantidPlot/src/FFTDialog.cpp b/MantidPlot/src/FFTDialog.cpp index 6b529eed2df9c14f848b4542c0410731e6e9238a..3f0be090532e5ac80829ede8122d8d01be7a5562 100644 --- a/MantidPlot/src/FFTDialog.cpp +++ b/MantidPlot/src/FFTDialog.cpp @@ -49,7 +49,7 @@ #include <QPushButton> #include <QRadioButton> -FFTDialog::FFTDialog(int type, QWidget *parent, Qt::WFlags fl) +FFTDialog::FFTDialog(int type, QWidget *parent, const Qt::WFlags &fl) : QDialog(parent, fl), buttonOK(nullptr), buttonCancel(nullptr), forwardBtn(nullptr), backwardBtn(nullptr), boxName(nullptr), boxReal(nullptr), boxImaginary(nullptr), boxSampling(nullptr), diff --git a/MantidPlot/src/FFTDialog.h b/MantidPlot/src/FFTDialog.h index 9e92aaa6980dd03da6dc318b00bd185ee7ef4fcc..4e4ddb1d828155af185f2fd472c965ec85da99f0 100644 --- a/MantidPlot/src/FFTDialog.h +++ b/MantidPlot/src/FFTDialog.h @@ -47,7 +47,8 @@ class FFTDialog : public QDialog { public: enum DataType { onGraph = 0, onTable = 1, onMatrix = 2 }; - FFTDialog(int type, QWidget *parent = nullptr, Qt::WFlags fl = nullptr); + FFTDialog(int type, QWidget *parent = nullptr, + const Qt::WFlags &fl = nullptr); public slots: void setGraph(Graph *g); diff --git a/MantidPlot/src/FilterDialog.cpp b/MantidPlot/src/FilterDialog.cpp index 43dfe6aba9a0e79dc245f10e53fb787d3732ed27..b078fb7dad093da08c006ae5f63510a0da4abd62 100644 --- a/MantidPlot/src/FilterDialog.cpp +++ b/MantidPlot/src/FilterDialog.cpp @@ -42,7 +42,7 @@ #include <QMessageBox> #include <QPushButton> -FilterDialog::FilterDialog(int type, QWidget *parent, Qt::WFlags fl) +FilterDialog::FilterDialog(int type, QWidget *parent, const Qt::WFlags &fl) : QDialog(parent, fl), graph(nullptr), buttonFilter(nullptr), buttonCancel(nullptr), boxName(nullptr), boxOffset(nullptr), boxStart(nullptr), boxEnd(nullptr), boxColor(nullptr) { diff --git a/MantidPlot/src/FilterDialog.h b/MantidPlot/src/FilterDialog.h index da87c9004897fcea96bf2369eb90e235550ed88a..c361fe97851159d7925adff7ef49c9501b2b8f31 100644 --- a/MantidPlot/src/FilterDialog.h +++ b/MantidPlot/src/FilterDialog.h @@ -43,7 +43,8 @@ class FilterDialog : public QDialog { Q_OBJECT public: - FilterDialog(int type, QWidget *parent = nullptr, Qt::WFlags fl = nullptr); + FilterDialog(int type, QWidget *parent = nullptr, + const Qt::WFlags &fl = nullptr); public slots: void setGraph(Graph *g); diff --git a/MantidPlot/src/FindDialog.cpp b/MantidPlot/src/FindDialog.cpp index e1ff277bd3b3dca260ed65b10df5ff888db47309..9fddeefb9b53d9819d210c03b286088c603b230f 100644 --- a/MantidPlot/src/FindDialog.cpp +++ b/MantidPlot/src/FindDialog.cpp @@ -41,7 +41,8 @@ #include <QRegExp> #include <QVBoxLayout> -FindDialog::FindDialog(QWidget *parent, Qt::WFlags fl) : QDialog(parent, fl) { +FindDialog::FindDialog(QWidget *parent, const Qt::WFlags &fl) + : QDialog(parent, fl) { setWindowTitle(tr("MantidPlot") + " - " + tr("Find")); setSizeGripEnabled(true); diff --git a/MantidPlot/src/FindDialog.h b/MantidPlot/src/FindDialog.h index 53a86644a516a41772da1680b055d32947558be2..3b74832f7a1e76cc11d988c7b0d78c6e3faa9191 100644 --- a/MantidPlot/src/FindDialog.h +++ b/MantidPlot/src/FindDialog.h @@ -42,7 +42,7 @@ class FindDialog : public QDialog { Q_OBJECT public: - FindDialog(QWidget *parent = nullptr, Qt::WFlags fl = nullptr); + FindDialog(QWidget *parent = nullptr, const Qt::WFlags &fl = nullptr); ~FindDialog() override; private: diff --git a/MantidPlot/src/FitDialog.cpp b/MantidPlot/src/FitDialog.cpp index 7bba4f70f2c4f8feb35e9a9c78d417319080f8fc..7524d652aed067759c22e32135ce8970557d16c7 100644 --- a/MantidPlot/src/FitDialog.cpp +++ b/MantidPlot/src/FitDialog.cpp @@ -56,7 +56,7 @@ using namespace MantidQt::API; -FitDialog::FitDialog(Graph *g, QWidget *parent, Qt::WFlags fl) +FitDialog::FitDialog(Graph *g, QWidget *parent, const Qt::WFlags &fl) : QDialog(parent, fl) { setObjectName("FitDialog"); setWindowTitle(tr("MantidPlot - Fit Wizard")); @@ -1215,7 +1215,7 @@ void FitDialog::changeDataRange() { boxTo->setValue(qMax(start, end)); } -void FitDialog::setSrcTables(QList<MdiSubWindow *> tables) { +void FitDialog::setSrcTables(const QList<MdiSubWindow *> &tables) { if (tables.isEmpty()) { tableNamesBox->addItem(tr("No data tables")); colNamesBox->addItem(tr("No data tables")); diff --git a/MantidPlot/src/FitDialog.h b/MantidPlot/src/FitDialog.h index 5e8d0e4219bd6234136162e0efc4dd3e9b3665a3..664ee1aac000a7d70dfa74accd1eb1dab8a6dc21 100644 --- a/MantidPlot/src/FitDialog.h +++ b/MantidPlot/src/FitDialog.h @@ -44,9 +44,10 @@ class FitDialog : public QDialog { Q_OBJECT public: - FitDialog(Graph *g, QWidget *parent = nullptr, Qt::WFlags fl = nullptr); + FitDialog(Graph *g, QWidget *parent = nullptr, + const Qt::WFlags &fl = nullptr); - void setSrcTables(QList<MdiSubWindow *> tables); + void setSrcTables(const QList<MdiSubWindow *> &tables); protected: void closeEvent(QCloseEvent *e) override; diff --git a/MantidPlot/src/FloatingWindow.cpp b/MantidPlot/src/FloatingWindow.cpp index b25f7632c4ad91ac1c4d9981c5a14a1fcc6f0451..5a21ef17e6ab463fa37f50506cff79bf203de5f4 100644 --- a/MantidPlot/src/FloatingWindow.cpp +++ b/MantidPlot/src/FloatingWindow.cpp @@ -24,7 +24,8 @@ /** * Constructor. */ -FloatingWindow::FloatingWindow(ApplicationWindow *appWindow, Qt::WindowFlags f) +FloatingWindow::FloatingWindow(ApplicationWindow *appWindow, + const Qt::WindowFlags &f) : #ifdef Q_OS_WIN QMainWindow(appWindow, f), diff --git a/MantidPlot/src/FloatingWindow.h b/MantidPlot/src/FloatingWindow.h index 91626dcc4791ee6e3a38565f7a7b263c81306534..29bd00795552bbdbb23ed5934c9a7a04ce8792d4 100644 --- a/MantidPlot/src/FloatingWindow.h +++ b/MantidPlot/src/FloatingWindow.h @@ -19,7 +19,8 @@ class QSize; class FloatingWindow : public QMainWindow { Q_OBJECT public: - FloatingWindow(ApplicationWindow *appWindow, Qt::WindowFlags f = nullptr); + FloatingWindow(ApplicationWindow *appWindow, + const Qt::WindowFlags &f = nullptr); ~FloatingWindow() override; void setStaysOnTopFlag(); void removeStaysOnTopFlag(); diff --git a/MantidPlot/src/FunctionCurve.cpp b/MantidPlot/src/FunctionCurve.cpp index 0d658b286bf99ff411c09a373e45db170af2c31e..6ee0f4231f9d35133e736ebe150b5ecd87a668ac 100644 --- a/MantidPlot/src/FunctionCurve.cpp +++ b/MantidPlot/src/FunctionCurve.cpp @@ -243,8 +243,9 @@ void FunctionCurve::loadData(int points) { * @param wi :: An index of a histogram with the data. * @param peakRadius :: A peak radius to pass to the domain. */ -void FunctionCurve::loadMantidData(Mantid::API::MatrixWorkspace_const_sptr ws, - size_t wi, int peakRadius) { +void FunctionCurve::loadMantidData( + const Mantid::API::MatrixWorkspace_const_sptr &ws, size_t wi, + int peakRadius) { if (!d_variable.isEmpty() || d_formulas.isEmpty() || d_formulas[0] != "Mantid") return; diff --git a/MantidPlot/src/FunctionCurve.h b/MantidPlot/src/FunctionCurve.h index 6e4bb863f8fd0f190823f9cf551125153f7aacea..d92cfdfb8e1c48a9f93dfbc7210ba001111b98b6 100644 --- a/MantidPlot/src/FunctionCurve.h +++ b/MantidPlot/src/FunctionCurve.h @@ -84,8 +84,9 @@ public: void loadData(int points = 0); - void loadMantidData(boost::shared_ptr<const Mantid::API::MatrixWorkspace> ws, - size_t wi, int peakRadius = 0); + void loadMantidData( + const boost::shared_ptr<const Mantid::API::MatrixWorkspace> &ws, + size_t wi, int peakRadius = 0); /// No error bars on this curve: Always return an empty list. QList<ErrorBarSettings *> errorBarSettingsList() const override { diff --git a/MantidPlot/src/FunctionDialog.cpp b/MantidPlot/src/FunctionDialog.cpp index c21971bc176dd9784a439701ae4713f3e02f939a..b40241efae5ab093f5203a7bcb29c4ea96c4bb97 100644 --- a/MantidPlot/src/FunctionDialog.cpp +++ b/MantidPlot/src/FunctionDialog.cpp @@ -44,7 +44,8 @@ #include <QTextEdit> #include <QWidget> -FunctionDialog::FunctionDialog(ApplicationWindow *app, Graph *g, Qt::WFlags fl) +FunctionDialog::FunctionDialog(ApplicationWindow *app, Graph *g, + const Qt::WFlags &fl) : QDialog(g, fl), d_app(app), graph(g) { setObjectName("FunctionDialog"); setWindowTitle(tr("MantidPlot - Add function curve")); diff --git a/MantidPlot/src/FunctionDialog.h b/MantidPlot/src/FunctionDialog.h index 69389b2ff243042c766e6524eeced65c3f422dcf..f7a420196549b131ed3996f5f4253a1d4fc926a0 100644 --- a/MantidPlot/src/FunctionDialog.h +++ b/MantidPlot/src/FunctionDialog.h @@ -47,7 +47,7 @@ class FunctionDialog : public QDialog { public: FunctionDialog(ApplicationWindow *app, Graph *g = nullptr, - Qt::WFlags fl = nullptr); + const Qt::WFlags &fl = nullptr); protected: QComboBox *boxXFunction; diff --git a/MantidPlot/src/Graph.cpp b/MantidPlot/src/Graph.cpp index 632d8d90f5674fe49b7d93b677ade6a7c6407d05..07c10ddf1f89e48ee1526def97ea03e1480c1ebe 100644 --- a/MantidPlot/src/Graph.cpp +++ b/MantidPlot/src/Graph.cpp @@ -126,7 +126,8 @@ namespace { Mantid::Kernel::Logger g_log("Graph"); } // namespace -Graph::Graph(int x, int y, int width, int height, QWidget *parent, Qt::WFlags f) +Graph::Graph(int x, int y, int width, int height, QWidget *parent, + const Qt::WFlags &f) : QWidget(parent, f) { setWindowFlags(f); n_curves = 0; @@ -1183,7 +1184,7 @@ void Graph::setScale(QwtPlot::Axis axis, ScaleTransformation::Type scaleType) { * @param axis :: the scale to change either QwtPlot::xBottom or QwtPlot::yLeft * @param logOrLin :: either "log" or "linear" */ -void Graph::setScale(QwtPlot::Axis axis, QString logOrLin) { +void Graph::setScale(QwtPlot::Axis axis, const QString &logOrLin) { if (logOrLin == "log") { setScale(axis, ScaleTransformation::Log10); } else if (logOrLin == "linear") { @@ -2842,7 +2843,7 @@ PlotCurve *Graph::insertCurve(Table *w, const QString &xColName, return c; } -PlotCurve *Graph::insertCurve(QString workspaceName, int index, bool err, +PlotCurve *Graph::insertCurve(const QString &workspaceName, int index, bool err, GraphOptions::CurveType style, bool distribution) { return (new MantidMatrixCurve(workspaceName, this, index, @@ -4954,7 +4955,7 @@ void Graph::setCurveLineColor(int curveIndex, int colorIndex) { } } -void Graph::setCurveLineColor(int curveIndex, QColor qColor) { +void Graph::setCurveLineColor(int curveIndex, const QColor &qColor) { QwtPlotCurve *c = curve(curveIndex); if (c) { QPen pen = c->pen(); diff --git a/MantidPlot/src/Graph.h b/MantidPlot/src/Graph.h index 30d7f397b380f59eb1dd07ab48095ba2b3024718..075294f31896773bce78ece4bf61562a1433f922 100644 --- a/MantidPlot/src/Graph.h +++ b/MantidPlot/src/Graph.h @@ -158,7 +158,7 @@ class Graph : public QWidget { public: Graph(int x = 0, int y = 0, int width = 500, int height = 400, - QWidget *parent = nullptr, Qt::WFlags f = nullptr); + QWidget *parent = nullptr, const Qt::WFlags &f = nullptr); ~Graph() override; enum Ticks { NoTicks = 0, Out = 1, InOut = 2, In = 3 }; @@ -265,7 +265,7 @@ public slots: const QString &yColName, int style, int startRow = 0, int endRow = -1); PlotCurve * - insertCurve(QString workspaceName, int index, bool err = false, + insertCurve(const QString &workspaceName, int index, bool err = false, GraphOptions::CurveType style = GraphOptions::Unspecified, bool distribution = false); PlotCurve *insertCurve(PlotCurve *c, int lineWidth = -1, @@ -338,7 +338,7 @@ public slots: void setCurveStyle(int index, int s); void setCurveFullRange(int curveIndex); void setCurveLineColor(int curveIndex, int colorIndex); - void setCurveLineColor(int curveIndex, QColor qColor); + void setCurveLineColor(int curveIndex, const QColor &qColor); void setCurveLineStyle(int curveIndex, Qt::PenStyle style); void setCurveLineWidth(int curveIndex, double width); void setGrayScale(); @@ -417,7 +417,7 @@ public slots: bool log10AfterBreak = false, int breakWidth = 4, bool breakDecoration = true, double nth_power = 2.0); void setScale(QwtPlot::Axis axis, ScaleTransformation::Type scaleType); - void setScale(QwtPlot::Axis axis, QString logOrLin); + void setScale(QwtPlot::Axis axis, const QString &logOrLin); double axisStep(int axis) { return d_user_step[axis]; }; //! Set the axis scale void setAxisScale(int axis, double start, double end, int scaleType = -1, diff --git a/MantidPlot/src/Graph3D.cpp b/MantidPlot/src/Graph3D.cpp index 69b403023409bdb9a95ed3efa9012bd72ed451dc..1521f5326e8303b577261f04db13060eef958614 100644 --- a/MantidPlot/src/Graph3D.cpp +++ b/MantidPlot/src/Graph3D.cpp @@ -107,7 +107,7 @@ Triple UserParametricSurface::operator()(double u, double v) { } Graph3D::Graph3D(const QString &label, QWidget *parent, const char *name, - Qt::WFlags f) + const Qt::WFlags &f) : MdiSubWindow(parent, label, name, f) { initPlot(); } @@ -2346,7 +2346,7 @@ void Graph3D::setDataColorMap(const QString &fileName) { sp->updateGL(); } -bool Graph3D::openColorMap(ColorVector &cv, QString fname) { +bool Graph3D::openColorMap(ColorVector &cv, const QString &fname) { if (fname.isEmpty()) return false; diff --git a/MantidPlot/src/Graph3D.h b/MantidPlot/src/Graph3D.h index d101f7106ce59e8b90a45e934205be45dc685130..f326a107fac740e1a39c7b6b735858c156fc0055 100644 --- a/MantidPlot/src/Graph3D.h +++ b/MantidPlot/src/Graph3D.h @@ -55,7 +55,7 @@ class Graph3D : public MdiSubWindow { public: Graph3D(const QString &label, QWidget *parent, const char *name = nullptr, - Qt::WFlags f = nullptr); + const Qt::WFlags &f = nullptr); ~Graph3D() override; void initPlot(); @@ -317,7 +317,7 @@ public slots: QString colorMap() { return color_map; }; void setDataColorMap(const QString &fileName); - bool openColorMap(Qwt3D::ColorVector &cv, QString fname); + bool openColorMap(Qwt3D::ColorVector &cv, const QString &fname); void setMeshColor(const QColor &); void setAxesColor(const QColor &); diff --git a/MantidPlot/src/ImageDialog.cpp b/MantidPlot/src/ImageDialog.cpp index 0b46d1158792b84775a4b618793dff88ec111c8c..437b6dd5ab53dddeb4664cb35057d866de0e3bad 100644 --- a/MantidPlot/src/ImageDialog.cpp +++ b/MantidPlot/src/ImageDialog.cpp @@ -21,7 +21,7 @@ #include <QLabel> #include <QLayout> -ImageDialog::ImageDialog(QWidget *parent, Qt::WFlags fl) +ImageDialog::ImageDialog(QWidget *parent, const Qt::WFlags &fl) : QDialog(parent, fl), aspect_ratio(1.) { setObjectName("ImageDialog"); setWindowTitle(tr("MantidPlot - Image Geometry")); diff --git a/MantidPlot/src/ImageDialog.h b/MantidPlot/src/ImageDialog.h index a5936852a96fe0a455a9119cdaeaee884b31570b..db5ccc0dcd2294bc20462b2c129f80b6cc7e3203 100644 --- a/MantidPlot/src/ImageDialog.h +++ b/MantidPlot/src/ImageDialog.h @@ -39,7 +39,7 @@ class ImageDialog : public QDialog { Q_OBJECT public: - ImageDialog(QWidget *parent = nullptr, Qt::WFlags fl = nullptr); + ImageDialog(QWidget *parent = nullptr, const Qt::WFlags &fl = nullptr); void setOrigin(const QPoint &o); void setSize(const QSize &size); diff --git a/MantidPlot/src/ImageExportDialog.cpp b/MantidPlot/src/ImageExportDialog.cpp index 9d0b967b9f37052ba8d5965603a949379d0880d7..dad44dcbdaa09d49e8b4c1bf4fb3b029f427eae8 100644 --- a/MantidPlot/src/ImageExportDialog.cpp +++ b/MantidPlot/src/ImageExportDialog.cpp @@ -42,7 +42,7 @@ #include <QStackedWidget> ImageExportDialog::ImageExportDialog(QWidget *parent, bool vector_options, - bool extended, Qt::WFlags flags) + bool extended, const Qt::WFlags &flags) : ExtensibleFileDialog(parent, extended, flags) { setWindowTitle(tr("MantidPlot - Choose a filename to save under")); setAcceptMode(QFileDialog::AcceptSave); diff --git a/MantidPlot/src/ImageExportDialog.h b/MantidPlot/src/ImageExportDialog.h index 20a4f0118ec8125374567673134cf7626d2d97e4..8c23e08525bd41842bd23559055a6d11e510f377 100644 --- a/MantidPlot/src/ImageExportDialog.h +++ b/MantidPlot/src/ImageExportDialog.h @@ -75,8 +75,8 @@ public: */ ImageExportDialog(QWidget *parent = nullptr, bool vector_options = true, bool extended = true, - Qt::WFlags flags = Qt::WindowCloseButtonHint | - Qt::WindowType::WindowTitleHint); + const Qt::WFlags &flags = Qt::WindowCloseButtonHint | + Qt::WindowType::WindowTitleHint); //! For vector formats: returns the output resolution the user selected, // defaulting to the screen resolution. int resolution() const { return d_resolution->value(); } diff --git a/MantidPlot/src/ImportASCIIDialog.cpp b/MantidPlot/src/ImportASCIIDialog.cpp index bd87d3897dbd421bb4982e6e918116252cceaa32..ee04b06f672f9fd6551db46eb2792fbf687248bf 100644 --- a/MantidPlot/src/ImportASCIIDialog.cpp +++ b/MantidPlot/src/ImportASCIIDialog.cpp @@ -50,7 +50,7 @@ #include <gsl/gsl_math.h> ImportASCIIDialog::ImportASCIIDialog(bool new_windows_only, QWidget *parent, - bool extended, Qt::WFlags flags) + bool extended, const Qt::WFlags &flags) : ExtensibleFileDialog(parent, extended, flags) { setWindowTitle(tr("MantidPlot - Import ASCII File(s)")); diff --git a/MantidPlot/src/ImportASCIIDialog.h b/MantidPlot/src/ImportASCIIDialog.h index cb767e331b6fcbc19d096c5bb6acbcfff379d26f..5b8b3e0e2b91b9030de820ae1ffd63f5df4dfd3b 100644 --- a/MantidPlot/src/ImportASCIIDialog.h +++ b/MantidPlot/src/ImportASCIIDialog.h @@ -117,8 +117,8 @@ public: */ ImportASCIIDialog(bool new_windows_only, QWidget *parent = nullptr, bool extended = true, - Qt::WFlags flags = Qt::WindowCloseButtonHint | - Qt::WindowType::WindowTitleHint); + const Qt::WFlags &flags = Qt::WindowCloseButtonHint | + Qt::WindowType::WindowTitleHint); //! Return the selected import mode /** diff --git a/MantidPlot/src/IntDialog.cpp b/MantidPlot/src/IntDialog.cpp index bc9edb76b73a4c599653b5f85d81b86c1539a924..d072c34e0f9c4bb5d1fc9486b7408ed5064d64e3 100644 --- a/MantidPlot/src/IntDialog.cpp +++ b/MantidPlot/src/IntDialog.cpp @@ -41,7 +41,7 @@ #include <QSpinBox> #include <QTextEdit> -IntDialog::IntDialog(QWidget *parent, Graph *g, Qt::WFlags fl) +IntDialog::IntDialog(QWidget *parent, Graph *g, const Qt::WFlags &fl) : QDialog(parent, fl), d_graph(g) { setObjectName("IntegrationDialog"); setAttribute(Qt::WA_DeleteOnClose); diff --git a/MantidPlot/src/IntDialog.h b/MantidPlot/src/IntDialog.h index 9036ec6136ae6b8297cf7a8e823d5cb3aac65bdd..f4e4257bb158d2ea262dc61077cb4d4b71a57985 100644 --- a/MantidPlot/src/IntDialog.h +++ b/MantidPlot/src/IntDialog.h @@ -44,7 +44,7 @@ class IntDialog : public QDialog { public: IntDialog(QWidget *parent = nullptr, Graph *g = nullptr, - Qt::WFlags fl = nullptr); + const Qt::WFlags &fl = nullptr); public slots: void accept() override; diff --git a/MantidPlot/src/InterpolationDialog.cpp b/MantidPlot/src/InterpolationDialog.cpp index 071c38c945376320d831c0599b4cab9f0423efb8..54a9bb20dfcc7a6ad00cfd753bbf13c48cc40b77 100644 --- a/MantidPlot/src/InterpolationDialog.cpp +++ b/MantidPlot/src/InterpolationDialog.cpp @@ -42,7 +42,7 @@ #include <QPushButton> #include <QSpinBox> -InterpolationDialog::InterpolationDialog(QWidget *parent, Qt::WFlags fl) +InterpolationDialog::InterpolationDialog(QWidget *parent, const Qt::WFlags &fl) : QDialog(parent, fl), graph(nullptr) { setObjectName("InterpolationDialog"); setWindowTitle(tr("MantidPlot - Interpolation Options")); diff --git a/MantidPlot/src/InterpolationDialog.h b/MantidPlot/src/InterpolationDialog.h index 9008dddd68f704f80dfa3411afe9d65ff1309aaf..837dbf5702f3c8740f5800dddbb4bd756016d9b9 100644 --- a/MantidPlot/src/InterpolationDialog.h +++ b/MantidPlot/src/InterpolationDialog.h @@ -43,7 +43,8 @@ class InterpolationDialog : public QDialog { Q_OBJECT public: - InterpolationDialog(QWidget *parent = nullptr, Qt::WFlags fl = nullptr); + InterpolationDialog(QWidget *parent = nullptr, + const Qt::WFlags &fl = nullptr); public slots: void activateCurve(const QString &curveName); diff --git a/MantidPlot/src/LayerDialog.cpp b/MantidPlot/src/LayerDialog.cpp index cde51096487d695c4bb9d95948f7699429731764..f2a43002f88b1faaa35d4fc5b4f6791d9de6c04b 100644 --- a/MantidPlot/src/LayerDialog.cpp +++ b/MantidPlot/src/LayerDialog.cpp @@ -29,7 +29,7 @@ #include <QPushButton> #include <QSpinBox> -LayerDialog::LayerDialog(QWidget *parent, Qt::WFlags fl) +LayerDialog::LayerDialog(QWidget *parent, const Qt::WFlags &fl) : QDialog(parent, fl), multi_layer(nullptr) { setObjectName("LayerDialog"); setWindowTitle(tr("MantidPlot - Arrange Layers")); diff --git a/MantidPlot/src/LayerDialog.h b/MantidPlot/src/LayerDialog.h index bb13823e6246e58f7e0e8da0110cd61826c62d55..71967c37e4c436a034ece6a4c8553ded552763e4 100644 --- a/MantidPlot/src/LayerDialog.h +++ b/MantidPlot/src/LayerDialog.h @@ -30,7 +30,7 @@ class LayerDialog : public QDialog { Q_OBJECT public: - LayerDialog(QWidget *parent = nullptr, Qt::WFlags fl = nullptr); + LayerDialog(QWidget *parent = nullptr, const Qt::WFlags &fl = nullptr); void setMultiLayer(MultiLayer *g); protected slots: diff --git a/MantidPlot/src/LineDialog.cpp b/MantidPlot/src/LineDialog.cpp index 2a9a76ed66e20e6331ca8006a1b0071ddebbfaf7..afef704cd36dbc34256394a0891d4f2d75f2bd3c 100644 --- a/MantidPlot/src/LineDialog.cpp +++ b/MantidPlot/src/LineDialog.cpp @@ -29,7 +29,7 @@ #include <QGroupBox> #include <QSpinBox> -LineDialog::LineDialog(ArrowMarker *line, QWidget *parent, Qt::WFlags fl) +LineDialog::LineDialog(ArrowMarker *line, QWidget *parent, const Qt::WFlags &fl) : QDialog(parent, fl) { unitBox = nullptr; diff --git a/MantidPlot/src/LineDialog.h b/MantidPlot/src/LineDialog.h index 2f54e19f62598ddae864116f6efd4f914e19c410..875243a061855f39ef222a03d2dbfd117731d6cf 100644 --- a/MantidPlot/src/LineDialog.h +++ b/MantidPlot/src/LineDialog.h @@ -36,7 +36,7 @@ class LineDialog : public QDialog { public: LineDialog(ArrowMarker *line, QWidget *parent = nullptr, - Qt::WFlags fl = nullptr); + const Qt::WFlags &fl = nullptr); enum Unit { ScaleCoordinates, Pixels }; diff --git a/MantidPlot/src/Mantid/AlgorithmMonitor.cpp b/MantidPlot/src/Mantid/AlgorithmMonitor.cpp index bb16b32ab27880056e0acff7a763c913230bf046..b090ed4438f4a76d951e74f2d3d0703a8e6fdb86 100644 --- a/MantidPlot/src/Mantid/AlgorithmMonitor.cpp +++ b/MantidPlot/src/Mantid/AlgorithmMonitor.cpp @@ -58,7 +58,7 @@ AlgorithmMonitor::~AlgorithmMonitor() { * * @param alg :: algorithm to monitor. */ -void AlgorithmMonitor::add(Mantid::API::IAlgorithm_sptr alg) { +void AlgorithmMonitor::add(const Mantid::API::IAlgorithm_sptr &alg) { lock(); alg->addObserver(m_finishedObserver); alg->addObserver(m_errorObserver); diff --git a/MantidPlot/src/Mantid/AlgorithmMonitor.h b/MantidPlot/src/Mantid/AlgorithmMonitor.h index 2f926b48b7bb6c54eaefb19ea9cb428f9679e418..aea9f1db805a44c4d69722266fc7d429aa27545c 100644 --- a/MantidPlot/src/Mantid/AlgorithmMonitor.h +++ b/MantidPlot/src/Mantid/AlgorithmMonitor.h @@ -34,7 +34,7 @@ public: /// Destructor ~AlgorithmMonitor() override; /// Add algorithm to monitor - void add(Mantid::API::IAlgorithm_sptr alg); + void add(const Mantid::API::IAlgorithm_sptr &alg); /// Removes stopped algorithm void remove(const Mantid::API::IAlgorithm *alg); @@ -116,7 +116,7 @@ private: class AlgButton : public QPushButton { Q_OBJECT public: - AlgButton(const QString &text, Mantid::API::IAlgorithm_sptr alg) + AlgButton(const QString &text, const Mantid::API::IAlgorithm_sptr &alg) : QPushButton(text), m_alg(alg->getAlgorithmID()) { connect(this, SIGNAL(clicked()), this, SLOT(sendClicked())); } diff --git a/MantidPlot/src/Mantid/FitParameterTie.cpp b/MantidPlot/src/Mantid/FitParameterTie.cpp index f5dc75728629ae73ff3650cdc9b51100b44f4473..dbf91658842ffcab9472894cc1ef90bc7c8cd8af 100644 --- a/MantidPlot/src/Mantid/FitParameterTie.cpp +++ b/MantidPlot/src/Mantid/FitParameterTie.cpp @@ -8,11 +8,12 @@ #include "MantidAPI/CompositeFunction.h" #include <QRegExp> #include <stdexcept> +#include <utility> /// Constructor FitParameterTie::FitParameterTie( boost::shared_ptr<Mantid::API::CompositeFunction> cf) - : m_compositeFunction(cf), m_prop(nullptr) {} + : m_compositeFunction(std::move(cf)), m_prop(nullptr) {} /// Destructor FitParameterTie::~FitParameterTie() { diff --git a/MantidPlot/src/Mantid/IFunctionWrapper.cpp b/MantidPlot/src/Mantid/IFunctionWrapper.cpp index f8d3448b44676d1d55a84f95609fdf85e1f89007..eb2943a0ad0414955f900d148208fa81bca5c58e 100644 --- a/MantidPlot/src/Mantid/IFunctionWrapper.cpp +++ b/MantidPlot/src/Mantid/IFunctionWrapper.cpp @@ -5,6 +5,9 @@ // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + #include "IFunctionWrapper.h" + +#include <utility> + #include "MantidAPI/CompositeFunction.h" #include "MantidAPI/FunctionFactory.h" #include "MantidAPI/IPeakFunction.h" @@ -27,7 +30,7 @@ void IFunctionWrapper::setFunction(const QString &name) { void IFunctionWrapper::setFunction( boost::shared_ptr<Mantid::API::IFunction> function) { - m_function = function; + m_function = std::move(function); m_compositeFunction = boost::dynamic_pointer_cast<Mantid::API::CompositeFunction>(m_function); m_peakFunction = diff --git a/MantidPlot/src/Mantid/InputHistory.cpp b/MantidPlot/src/Mantid/InputHistory.cpp index e52d175f08e4d00ebbe71d69f7a8c65f8e5d5d1d..1879698a2cf776197f346d4a1e2e7fd900d1d9b1 100644 --- a/MantidPlot/src/Mantid/InputHistory.cpp +++ b/MantidPlot/src/Mantid/InputHistory.cpp @@ -68,7 +68,8 @@ void InputHistoryImpl::save() { Upadates the non-default algorithm properties in the history. @param alg :: Pointer to the algorthm */ -void InputHistoryImpl::updateAlgorithm(Mantid::API::IAlgorithm_sptr alg) { +void InputHistoryImpl::updateAlgorithm( + const Mantid::API::IAlgorithm_sptr &alg) { const std::vector<Property *> &props = alg->getProperties(); QList<PropertyData> prop_hist_list; for (std::vector<Property *>::const_iterator prop = props.begin(); diff --git a/MantidPlot/src/Mantid/InputHistory.h b/MantidPlot/src/Mantid/InputHistory.h index c4dc5dcba9385e2e3435a853f3094f24d54eb712..1841b5e9bf004c98d9c222fcff3199b82dcd5cd7 100644 --- a/MantidPlot/src/Mantid/InputHistory.h +++ b/MantidPlot/src/Mantid/InputHistory.h @@ -38,7 +38,7 @@ class InputHistoryImpl { public: InputHistoryImpl(const InputHistoryImpl &) = delete; InputHistoryImpl &operator=(const InputHistoryImpl &) = delete; - void updateAlgorithm(Mantid::API::IAlgorithm_sptr alg); + void updateAlgorithm(const Mantid::API::IAlgorithm_sptr &alg); /// The name:value map of non-default properties with which algorithm algName /// was called last time. QMap<QString, QString> algorithmProperties(const QString &algName); diff --git a/MantidPlot/src/Mantid/LabelToolLogValuesDialog.cpp b/MantidPlot/src/Mantid/LabelToolLogValuesDialog.cpp index 261dcf3be6d1f094f43d8f20b41d0f4de7b36b90..521ed90a3dddaaa8d3ff4f68b4a0064462f14e22 100644 --- a/MantidPlot/src/Mantid/LabelToolLogValuesDialog.cpp +++ b/MantidPlot/src/Mantid/LabelToolLogValuesDialog.cpp @@ -41,7 +41,7 @@ using namespace Mantid::Kernel; */ LabelToolLogValuesDialog::LabelToolLogValuesDialog(const QString &wsname, QWidget *parentContainer, - Qt::WFlags flags, + const Qt::WFlags &flags, size_t experimentInfoIndex) : SampleLogDialogBase(wsname, parentContainer, flags, experimentInfoIndex) { diff --git a/MantidPlot/src/Mantid/LabelToolLogValuesDialog.h b/MantidPlot/src/Mantid/LabelToolLogValuesDialog.h index 676f20dc53c2599bf868d4d11e1216e083ea3b3d..45fcb520f76bf585c9be36e912675582f4093732 100644 --- a/MantidPlot/src/Mantid/LabelToolLogValuesDialog.h +++ b/MantidPlot/src/Mantid/LabelToolLogValuesDialog.h @@ -38,7 +38,7 @@ class LabelToolLogValuesDialog : public SampleLogDialogBase { public: /// Constructor LabelToolLogValuesDialog(const QString &wsname, QWidget *parentContainer, - Qt::WFlags flags = nullptr, + const Qt::WFlags &flags = nullptr, size_t experimentInfoIndex = 0); virtual ~LabelToolLogValuesDialog() override; diff --git a/MantidPlot/src/Mantid/MantidApplication.cpp b/MantidPlot/src/Mantid/MantidApplication.cpp index a12261ca305f2e3efa6395923e2779fc58f25e62..17fa5370465c4d9b320b304f0aac6fb58c90cc0c 100644 --- a/MantidPlot/src/Mantid/MantidApplication.cpp +++ b/MantidPlot/src/Mantid/MantidApplication.cpp @@ -39,8 +39,8 @@ MantidApplication::MantidApplication(int &argc, char **argv) } void MantidApplication::errorHandling(bool continueWork, int share, - QString name, QString email, - QString textbox) { + const QString &name, const QString &email, + const QString &textbox) { if (share == 0) { Mantid::Kernel::ErrorReporter errorReporter( "mantidplot", Mantid::Kernel::UsageService::Instance().getUpTime(), "", diff --git a/MantidPlot/src/Mantid/MantidApplication.h b/MantidPlot/src/Mantid/MantidApplication.h index 977eadb591a21d24a375ede1dd1b588f955faefc..dd8e64600a96aa8e072b3e6c1c1c1226f89c866e 100644 --- a/MantidPlot/src/Mantid/MantidApplication.h +++ b/MantidPlot/src/Mantid/MantidApplication.h @@ -20,6 +20,6 @@ public: signals: bool runAsPythonScript(const QString &code); public slots: - void errorHandling(bool continueWork, int sharing, QString name, - QString email, QString textbox); + void errorHandling(bool continueWork, int sharing, const QString &name, + const QString &email, const QString &textbox); }; diff --git a/MantidPlot/src/Mantid/MantidMDCurveDialog.cpp b/MantidPlot/src/Mantid/MantidMDCurveDialog.cpp index 320b0dd862b6449d222992fdc619375618980e82..d05d007ccede3b0f0ffb6a07c288c93401c4b4d1 100644 --- a/MantidPlot/src/Mantid/MantidMDCurveDialog.cpp +++ b/MantidPlot/src/Mantid/MantidMDCurveDialog.cpp @@ -12,7 +12,7 @@ using Mantid::API::AnalysisDataService; using Mantid::API::IMDWorkspace; using Mantid::API::IMDWorkspace_sptr; -MantidMDCurveDialog::MantidMDCurveDialog(QWidget *parent, QString wsName) +MantidMDCurveDialog::MantidMDCurveDialog(QWidget *parent, const QString &wsName) : QDialog(parent), m_wsName(wsName) { ui.setupUi(this); m_lineOptions = new LinePlotOptions(this); diff --git a/MantidPlot/src/Mantid/MantidMDCurveDialog.h b/MantidPlot/src/Mantid/MantidMDCurveDialog.h index d63a8af756e0697b94e28ccfb025854cb4e951a5..d2ba68801cbc62e66b62875e20177bcc3069f901 100644 --- a/MantidPlot/src/Mantid/MantidMDCurveDialog.h +++ b/MantidPlot/src/Mantid/MantidMDCurveDialog.h @@ -17,7 +17,8 @@ class MantidMDCurveDialog : public QDialog { Q_OBJECT public: - MantidMDCurveDialog(QWidget *parent = nullptr, QString wsName = QString()); + MantidMDCurveDialog(QWidget *parent = nullptr, + const QString &wsName = QString()); ~MantidMDCurveDialog() override; LinePlotOptions *getLineOptionsWidget() { return m_lineOptions; } diff --git a/MantidPlot/src/Mantid/MantidMatrix.cpp b/MantidPlot/src/Mantid/MantidMatrix.cpp index 0b71aa06f6f05b93d9b95f3be15d31957782c3c5..453512d4305eb6dadb2363311a2b02b5c033b8ac 100644 --- a/MantidPlot/src/Mantid/MantidMatrix.cpp +++ b/MantidPlot/src/Mantid/MantidMatrix.cpp @@ -91,7 +91,7 @@ int modelTypeToInt(MantidMatrixModel::Type type) { } } // namespace -MantidMatrix::MantidMatrix(Mantid::API::MatrixWorkspace_const_sptr ws, +MantidMatrix::MantidMatrix(const Mantid::API::MatrixWorkspace_const_sptr &ws, QWidget *parent, const QString &label, const QString &name, int start, int end) : MdiSubWindow(parent, label, name, nullptr), WorkspaceObserver(), @@ -213,8 +213,8 @@ void MantidMatrix::viewChanged(int index) { } } -void MantidMatrix::setup(Mantid::API::MatrixWorkspace_const_sptr ws, int start, - int end) { +void MantidMatrix::setup(const Mantid::API::MatrixWorkspace_const_sptr &ws, + int start, int end) { if (!ws) { QMessageBox::critical(nullptr, "WorkspaceMatrixModel error", "2D workspace expected."); @@ -997,7 +997,8 @@ void MantidMatrix::afterReplaceHandle( } } -void MantidMatrix::changeWorkspace(Mantid::API::MatrixWorkspace_sptr ws) { +void MantidMatrix::changeWorkspace( + const Mantid::API::MatrixWorkspace_sptr &ws) { if (m_workspaceTotalHist != static_cast<int>(ws->getNumberHistograms()) || m_cols != static_cast<int>(ws->blocksize())) { closeDependants(); @@ -1171,7 +1172,8 @@ void MantidMatrix::goToTab(const QString &name) { */ const std::string &MantidMatrix::getWorkspaceName() { return m_strName; } -void findYRange(MatrixWorkspace_const_sptr ws, double &miny, double &maxy) { +void findYRange(const MatrixWorkspace_const_sptr &ws, double &miny, + double &maxy) { // this is here to fill m_min and m_max with numbers that aren't nan miny = std::numeric_limits<double>::max(); maxy = std::numeric_limits<double>::lowest(); @@ -1349,7 +1351,8 @@ void MantidMatrix::setupNewExtension(MantidMatrixModel::Type type) { * Update the existing extensions * @param ws: the new workspace */ -void MantidMatrix::updateExtensions(Mantid::API::MatrixWorkspace_sptr ws) { +void MantidMatrix::updateExtensions( + const Mantid::API::MatrixWorkspace_sptr &ws) { auto it = m_extensions.begin(); while (it != m_extensions.cend()) { auto type = it->first; diff --git a/MantidPlot/src/Mantid/MantidMatrix.h b/MantidPlot/src/Mantid/MantidMatrix.h index 19caf3206f42745172e373fecab9a8f7debfde75..8cb759dddb931f60e11378b806787ffe9f799c8a 100644 --- a/MantidPlot/src/Mantid/MantidMatrix.h +++ b/MantidPlot/src/Mantid/MantidMatrix.h @@ -56,7 +56,7 @@ class ProjectData; * @param miny :: Variable to receive the minimum value. * @param maxy :: Variable to receive the maximum value. */ -void findYRange(Mantid::API::MatrixWorkspace_const_sptr ws, double &miny, +void findYRange(const Mantid::API::MatrixWorkspace_const_sptr &ws, double &miny, double &maxy); /** MantidMatrix is the class that represents a Qtiplot window for displaying @@ -70,9 +70,9 @@ class MantidMatrix : public MdiSubWindow, MantidQt::API::WorkspaceObserver { Q_OBJECT public: - MantidMatrix(Mantid::API::MatrixWorkspace_const_sptr ws, QWidget *parent, - const QString &label, const QString &name = QString(), - int start = -1, int end = -1); + MantidMatrix(const Mantid::API::MatrixWorkspace_const_sptr &ws, + QWidget *parent, const QString &label, + const QString &name = QString(), int start = -1, int end = -1); void connectTableView(QTableView *, MantidMatrixModel *); MantidMatrixModel *model() { return m_modelY; } @@ -173,7 +173,7 @@ signals: public slots: - void changeWorkspace(Mantid::API::MatrixWorkspace_sptr ws); + void changeWorkspace(const Mantid::API::MatrixWorkspace_sptr &ws); void closeMatrix(); //! Return the width of all columns @@ -245,7 +245,7 @@ public slots: void setMatrixProperties(); protected: - void setup(Mantid::API::MatrixWorkspace_const_sptr ws, int start = -1, + void setup(const Mantid::API::MatrixWorkspace_const_sptr &ws, int start = -1, int end = -1); ApplicationWindow *m_appWindow; @@ -308,7 +308,7 @@ private: /// Hook up a MantidMatrixExtension void setupNewExtension(MantidMatrixModel::Type type); /// Update the existing extensions - void updateExtensions(Mantid::API::MatrixWorkspace_sptr ws); + void updateExtensions(const Mantid::API::MatrixWorkspace_sptr &ws); /// ExtensioRequest handler MantidMatrixExtensionRequest m_extensionRequest; diff --git a/MantidPlot/src/Mantid/MantidMatrixCurve.cpp b/MantidPlot/src/Mantid/MantidMatrixCurve.cpp index 723a09b5b09b0b9dd427ae31247d1ad0c59ce9d4..dead95e8e3836f6591b8c7bcf49bc344a2509571 100644 --- a/MantidPlot/src/Mantid/MantidMatrixCurve.cpp +++ b/MantidPlot/src/Mantid/MantidMatrixCurve.cpp @@ -289,7 +289,7 @@ void MantidMatrixCurve::itemChanged() { */ QString MantidMatrixCurve::createCurveName( const QString &prefix, - const boost::shared_ptr<const Mantid::API::MatrixWorkspace> ws) { + const boost::shared_ptr<const Mantid::API::MatrixWorkspace> &ws) { QString name = ""; if (prefix.isEmpty()) diff --git a/MantidPlot/src/Mantid/MantidMatrixCurve.h b/MantidPlot/src/Mantid/MantidMatrixCurve.h index 1b901acbb6d358aa158cd20f9c1456a1a372d2d7..20af7ed6aca3caf4ea0c7e9529848bea01712da7 100644 --- a/MantidPlot/src/Mantid/MantidMatrixCurve.h +++ b/MantidPlot/src/Mantid/MantidMatrixCurve.h @@ -145,7 +145,7 @@ private: /// Make the curve name QString createCurveName( const QString &prefix, - const boost::shared_ptr<const Mantid::API::MatrixWorkspace> ws); + const boost::shared_ptr<const Mantid::API::MatrixWorkspace> &ws); QString m_wsName; ///< Workspace name. If empty the ws isn't in the data service diff --git a/MantidPlot/src/Mantid/MantidMatrixDialog.cpp b/MantidPlot/src/Mantid/MantidMatrixDialog.cpp index 7a7ac69f35a0fcbb73fc68dedeef3aec045d7b7a..d27ab3a758dd9263bb73a5580ed02bcad7b9e118 100644 --- a/MantidPlot/src/Mantid/MantidMatrixDialog.cpp +++ b/MantidPlot/src/Mantid/MantidMatrixDialog.cpp @@ -15,7 +15,7 @@ #include <QPushButton> #include <QSpinBox> -MantidMatrixDialog::MantidMatrixDialog(QWidget *parent, Qt::WFlags fl) +MantidMatrixDialog::MantidMatrixDialog(QWidget *parent, const Qt::WFlags &fl) : QDialog(parent, fl), d_matrix(nullptr) { setWindowTitle(tr("MantidPlot - Matrix Properties")); diff --git a/MantidPlot/src/Mantid/MantidMatrixDialog.h b/MantidPlot/src/Mantid/MantidMatrixDialog.h index 18fccb4abc31037211f2fbbe0c8498b3882f3d44..9b2fcb113a85c2e415c45f0f4134fa470645d4b3 100644 --- a/MantidPlot/src/Mantid/MantidMatrixDialog.h +++ b/MantidPlot/src/Mantid/MantidMatrixDialog.h @@ -25,7 +25,7 @@ public: * @param parent :: parent widget * @param fl :: window flags */ - MantidMatrixDialog(QWidget *parent = nullptr, Qt::WFlags fl = nullptr); + MantidMatrixDialog(QWidget *parent = nullptr, const Qt::WFlags &fl = nullptr); void setMatrix(MantidMatrix *m); private slots: diff --git a/MantidPlot/src/Mantid/MantidMatrixTabExtension.h b/MantidPlot/src/Mantid/MantidMatrixTabExtension.h index 205a28f4d05fc3a06047eada8ab4184e20ea8535..36c0cf2b0a30e608846799e3ba88993384c1fb2f 100644 --- a/MantidPlot/src/Mantid/MantidMatrixTabExtension.h +++ b/MantidPlot/src/Mantid/MantidMatrixTabExtension.h @@ -15,7 +15,7 @@ * Holds the information for a new tab. */ struct MantidMatrixTabExtension { - MantidMatrixTabExtension(QString label, QTableView *tableView, + MantidMatrixTabExtension(const QString &&label, QTableView *tableView, MantidMatrixModel *model, MantidMatrixModel::Type type) : label(label), tableView(tableView), model(model), type(type) {} diff --git a/MantidPlot/src/Mantid/MantidSampleLogDialog.cpp b/MantidPlot/src/Mantid/MantidSampleLogDialog.cpp index 2d5483c9178595f9725883207096b5fd4299e923..6421dc566e22e06ff928f2ce4a4287515d0523f7 100644 --- a/MantidPlot/src/Mantid/MantidSampleLogDialog.cpp +++ b/MantidPlot/src/Mantid/MantidSampleLogDialog.cpp @@ -35,7 +35,8 @@ using namespace Mantid::Kernel; * ExperimentInfo objects. Should only be non-zero for MDWorkspaces. */ MantidSampleLogDialog::MantidSampleLogDialog(const QString &wsname, - MantidUI *mui, Qt::WFlags flags, + MantidUI *mui, + const Qt::WFlags &flags, size_t experimentInfoIndex) : SampleLogDialogBase(wsname, mui->appWindow(), flags, experimentInfoIndex), m_mantidUI(mui) { diff --git a/MantidPlot/src/Mantid/MantidSampleLogDialog.h b/MantidPlot/src/Mantid/MantidSampleLogDialog.h index 4cb33e38381d37124b2177e15f56f76d96754d3a..810c0d8f51c7ab1dc2bc24cedee509327cad0cfb 100644 --- a/MantidPlot/src/Mantid/MantidSampleLogDialog.h +++ b/MantidPlot/src/Mantid/MantidSampleLogDialog.h @@ -39,7 +39,7 @@ class MantidSampleLogDialog : public SampleLogDialogBase { public: /// Constructor MantidSampleLogDialog(const QString &wsname, MantidUI *mui, - Qt::WFlags flags = nullptr, + const Qt::WFlags &flags = nullptr, size_t experimentInfoIndex = 0); /// Destructor diff --git a/MantidPlot/src/Mantid/MantidSampleMaterialDialog.cpp b/MantidPlot/src/Mantid/MantidSampleMaterialDialog.cpp index 8a8eddc24c3ab20eeeb49b0d2c4fbb30fb851973..ca345897ded3e31e3095c4f9563871b3612697e3 100644 --- a/MantidPlot/src/Mantid/MantidSampleMaterialDialog.cpp +++ b/MantidPlot/src/Mantid/MantidSampleMaterialDialog.cpp @@ -29,7 +29,7 @@ using namespace Mantid::Kernel; */ MantidSampleMaterialDialog::MantidSampleMaterialDialog(const QString &wsName, MantidUI *mtdUI, - Qt::WFlags flags) + const Qt::WFlags &flags) : QDialog(mtdUI->appWindow(), flags), m_wsName(wsName), m_mantidUI(mtdUI) { m_uiForm.setupUi(this); diff --git a/MantidPlot/src/Mantid/MantidSampleMaterialDialog.h b/MantidPlot/src/Mantid/MantidSampleMaterialDialog.h index 2044d628e05c95a70341bfd6a543248c934db60f..9dc60cedfaee57abf4ad664b01f9d5e1c18d88bb 100644 --- a/MantidPlot/src/Mantid/MantidSampleMaterialDialog.h +++ b/MantidPlot/src/Mantid/MantidSampleMaterialDialog.h @@ -34,7 +34,7 @@ class MantidSampleMaterialDialog : public QDialog, public: MantidSampleMaterialDialog(const QString &wsName, MantidUI *mtdUI, - Qt::WFlags flags = nullptr); + const Qt::WFlags &flags = nullptr); public slots: void updateMaterial(); diff --git a/MantidPlot/src/Mantid/MantidTable.cpp b/MantidPlot/src/Mantid/MantidTable.cpp index 5d41e306f8f2768091949ca41965d3f3b27c7dd5..da323c473bf284e5a52ebc12b6e7e62c359be7c0 100644 --- a/MantidPlot/src/Mantid/MantidTable.cpp +++ b/MantidPlot/src/Mantid/MantidTable.cpp @@ -34,7 +34,7 @@ using namespace MantidQt::API; * @return the MantidTable created */ MantidTable::MantidTable(ScriptingEnv *env, - Mantid::API::ITableWorkspace_sptr ws, + const Mantid::API::ITableWorkspace_sptr &ws, const QString &label, ApplicationWindow *parent, bool transpose) : Table(env, diff --git a/MantidPlot/src/Mantid/MantidTable.h b/MantidPlot/src/Mantid/MantidTable.h index 030ff75a9451d18c2b5e2bac3e66b86cee47fb41..a88a12b6612efdf39368b29d3d5cb47e9088bdc7 100644 --- a/MantidPlot/src/Mantid/MantidTable.h +++ b/MantidPlot/src/Mantid/MantidTable.h @@ -17,7 +17,7 @@ class MantidTable : public Table, public MantidQt::API::WorkspaceObserver { Q_OBJECT public: - MantidTable(ScriptingEnv *env, Mantid::API::ITableWorkspace_sptr ws, + MantidTable(ScriptingEnv *env, const Mantid::API::ITableWorkspace_sptr &ws, const QString &label, ApplicationWindow *parent, bool transpose = false); diff --git a/MantidPlot/src/Mantid/MantidUI.cpp b/MantidPlot/src/Mantid/MantidUI.cpp index b1ffb8be465bda12c37f6c802dfea7f0a4dd1013..8f6158ce4c5c0e78a55922088bfef9c1dc74d4f8 100644 --- a/MantidPlot/src/Mantid/MantidUI.cpp +++ b/MantidPlot/src/Mantid/MantidUI.cpp @@ -1716,7 +1716,7 @@ void MantidUI::executeAlgorithm(Mantid::API::IAlgorithm_sptr alg) { * This creates an algorithm dialog (the default property entry thingie). */ MantidQt::API::AlgorithmDialog * -MantidUI::createAlgorithmDialog(Mantid::API::IAlgorithm_sptr alg) { +MantidUI::createAlgorithmDialog(const Mantid::API::IAlgorithm_sptr &alg) { QHash<QString, QString> presets; QStringList enabled; @@ -1759,7 +1759,7 @@ MantidUI::createAlgorithmDialog(Mantid::API::IAlgorithm_sptr alg) { * @param algorithm :: A pointer to the algorithm instance */ QString MantidUI::findInputWorkspaceProperty( - Mantid::API::IAlgorithm_sptr algorithm) const { + const Mantid::API::IAlgorithm_sptr &algorithm) const { // Iterate through the properties and find the first input one std::vector<Mantid::Kernel::Property *> props = algorithm->getProperties(); std::vector<Mantid::Kernel::Property *>::const_iterator pend = props.end(); @@ -2974,7 +2974,7 @@ MultiLayer *MantidUI::createGraphFromTable(Table *t, int type) { */ void MantidUI::setUpBinGraph( MultiLayer *ml, const QString &Name, - Mantid::API::MatrixWorkspace_const_sptr workspace) { + const Mantid::API::MatrixWorkspace_const_sptr &workspace) { Graph *g = ml->activeGraph(); g->setTitle(tr("Workspace ") + Name); QString xtitle; @@ -3742,7 +3742,8 @@ MultiLayer *MantidUI::plotSubplots(const QStringList &wsNames, } Table *MantidUI::createTableFromBins( - const QString &wsName, Mantid::API::MatrixWorkspace_const_sptr workspace, + const QString &wsName, + const Mantid::API::MatrixWorkspace_const_sptr &workspace, const QList<int> &bins, bool errs, int fromRow, int toRow) { if (bins.empty()) return nullptr; diff --git a/MantidPlot/src/Mantid/MantidUI.h b/MantidPlot/src/Mantid/MantidUI.h index d2a5c67199fe40fea083bdf1bbdcfc27ca20190c..a19385119f6136a636d5b68e61bfc0e39e058a77 100644 --- a/MantidPlot/src/Mantid/MantidUI.h +++ b/MantidPlot/src/Mantid/MantidUI.h @@ -310,15 +310,17 @@ public slots: bool errs = true); // Set properties of a 1d graph which plots data from a workspace - static void setUpBinGraph(MultiLayer *ml, const QString &wsName, - Mantid::API::MatrixWorkspace_const_sptr workspace); + static void + setUpBinGraph(MultiLayer *ml, const QString &wsName, + const Mantid::API::MatrixWorkspace_const_sptr &workspace); // Copy to a Table Y-values (and Err-values if errs==true) of bins with // indeces from i0 to i1 (inclusive) from a workspace - Table *createTableFromBins(const QString &wsName, - Mantid::API::MatrixWorkspace_const_sptr workspace, - const QList<int> &bins, bool errs = true, - int fromRow = -1, int toRow = -1); + Table * + createTableFromBins(const QString &wsName, + const Mantid::API::MatrixWorkspace_const_sptr &workspace, + const QList<int> &bins, bool errs = true, + int fromRow = -1, int toRow = -1); // Copies selected columns (time bins) in a MantidMatrix to a Table Table *createTableFromSelectedColumns(MantidMatrix *m, bool errs); @@ -499,8 +501,8 @@ public slots: void executeAlgorithm(Mantid::API::IAlgorithm_sptr alg) override; // Find the name of the first input workspace for an algorithm - QString - findInputWorkspaceProperty(Mantid::API::IAlgorithm_sptr algorithm) const; + QString findInputWorkspaceProperty( + const Mantid::API::IAlgorithm_sptr &algorithm) const; // Show Qt critical error message box void showCritical(const QString &) override; // Show the dialog monitoring currently running algorithms @@ -595,7 +597,7 @@ private: /// This creates an algorithm dialog. MantidQt::API::AlgorithmDialog * - createAlgorithmDialog(Mantid::API::IAlgorithm_sptr alg); + createAlgorithmDialog(const Mantid::API::IAlgorithm_sptr &alg); /// This method accepts user inputs and executes loadraw/load nexus /// algorithm diff --git a/MantidPlot/src/Mantid/PeakPickerTool.cpp b/MantidPlot/src/Mantid/PeakPickerTool.cpp index d39062b4a903c9810355a2a31e9882f7d1955462..7dec8b965a94dc0b6715529e14e29cf3a037f817 100644 --- a/MantidPlot/src/Mantid/PeakPickerTool.cpp +++ b/MantidPlot/src/Mantid/PeakPickerTool.cpp @@ -316,8 +316,8 @@ bool PeakPickerTool::eventFilter(QObject *obj, QEvent *event) { return QwtPlotPicker::eventFilter(obj, event); } -void PeakPickerTool::windowStateChanged(Qt::WindowStates, - Qt::WindowStates newState) { +void PeakPickerTool::windowStateChanged(const Qt::WindowStates &, + const Qt::WindowStates &newState) { (void)newState; } diff --git a/MantidPlot/src/Mantid/PeakPickerTool.h b/MantidPlot/src/Mantid/PeakPickerTool.h index 7f8de38db612a677ea946af47470cbb60cf78aa3..bf1b5bae9c45593b8e5d5f0fab1dee15369e0419 100644 --- a/MantidPlot/src/Mantid/PeakPickerTool.h +++ b/MantidPlot/src/Mantid/PeakPickerTool.h @@ -81,7 +81,8 @@ public: bool isInitialized() const { return m_init; } public slots: - void windowStateChanged(Qt::WindowStates oldState, Qt::WindowStates newState); + void windowStateChanged(const Qt::WindowStates &oldState, + const Qt::WindowStates &newState); signals: void peakChanged(); diff --git a/MantidPlot/src/Mantid/SampleLogDialogBase.cpp b/MantidPlot/src/Mantid/SampleLogDialogBase.cpp index cafe18ff040ecdd3dcc0fc87ee1bbee42f872a2b..d9d150c0e264134d2c69ee17d5093dd362c146e7 100644 --- a/MantidPlot/src/Mantid/SampleLogDialogBase.cpp +++ b/MantidPlot/src/Mantid/SampleLogDialogBase.cpp @@ -50,7 +50,7 @@ using namespace Mantid::Kernel; */ SampleLogDialogBase::SampleLogDialogBase(const QString &wsname, QWidget *parentContainer, - Qt::WFlags flags, + const Qt::WFlags &flags, size_t experimentInfoIndex) : QDialog(parentContainer, flags), m_tree(new QTreeWidget()), m_parentContainer(parentContainer), m_wsname(wsname.toStdString()), diff --git a/MantidPlot/src/Mantid/SampleLogDialogBase.h b/MantidPlot/src/Mantid/SampleLogDialogBase.h index e2c155e764a9115bf50aa754afdea47926c680f6..216f180f856ba4bf833c011f3026c218bab9c613 100644 --- a/MantidPlot/src/Mantid/SampleLogDialogBase.h +++ b/MantidPlot/src/Mantid/SampleLogDialogBase.h @@ -47,7 +47,7 @@ class SampleLogDialogBase : public QDialog { public: /// Constructor SampleLogDialogBase(const QString &wsname, QWidget *parentContainer, - Qt::WFlags flags = nullptr, + const Qt::WFlags &flags = nullptr, size_t experimentInfoIndex = 0); /// Virtual Destructor for derived classes diff --git a/MantidPlot/src/Matrix.cpp b/MantidPlot/src/Matrix.cpp index 6d96fad55cda39a3cb4fe67362b1a1b09982fd56..79de07d76efdd2aeb79303ff1d9a36098214fd66 100644 --- a/MantidPlot/src/Matrix.cpp +++ b/MantidPlot/src/Matrix.cpp @@ -76,7 +76,7 @@ using namespace Mantid; using namespace MantidQt::API; Matrix::Matrix(ScriptingEnv *env, const QString &label, QWidget *parent, - const QString &name, Qt::WFlags f) + const QString &name, const Qt::WFlags &f) : MdiSubWindow(parent, label, name, f), Scripted(env), d_matrix_model(nullptr), m_bk_color(), d_stack(nullptr), d_table_view(nullptr), imageLabel(nullptr), formula_str(), txt_format(), @@ -91,7 +91,7 @@ Matrix::Matrix(ScriptingEnv *env, const QString &label, QWidget *parent, } Matrix::Matrix(ScriptingEnv *env, int r, int c, const QString &label, - QWidget *parent, const QString &name, Qt::WFlags f) + QWidget *parent, const QString &name, const Qt::WFlags &f) : MdiSubWindow(parent, label, name, f), Scripted(env), d_matrix_model(nullptr), m_bk_color(), d_stack(nullptr), d_table_view(nullptr), imageLabel(nullptr), formula_str(), txt_format(), @@ -107,7 +107,7 @@ Matrix::Matrix(ScriptingEnv *env, int r, int c, const QString &label, } Matrix::Matrix(ScriptingEnv *env, const QImage &image, const QString &label, - QWidget *parent, const QString &name, Qt::WFlags f) + QWidget *parent, const QString &name, const Qt::WFlags &f) : MdiSubWindow(parent, label, name, f), Scripted(env), d_matrix_model(nullptr), m_bk_color(), d_stack(nullptr), d_table_view(nullptr), imageLabel(nullptr), formula_str(), diff --git a/MantidPlot/src/Matrix.h b/MantidPlot/src/Matrix.h index 5d15ee80410f97feb3227b32212e4bc06f63a87e..7713504f713e355a03ae1bd39a37beb263e12da1 100644 --- a/MantidPlot/src/Matrix.h +++ b/MantidPlot/src/Matrix.h @@ -65,7 +65,7 @@ class Matrix : public MdiSubWindow, public Scripted { protected: Matrix(ScriptingEnv *env, const QString &label, QWidget *parent, - const QString &name = QString(), Qt::WFlags f = nullptr); + const QString &name = QString(), const Qt::WFlags &f = nullptr); public: /** @@ -81,10 +81,10 @@ public: * @param f :: window flags */ Matrix(ScriptingEnv *env, int r, int c, const QString &label, QWidget *parent, - const QString &name = QString(), Qt::WFlags f = nullptr); + const QString &name = QString(), const Qt::WFlags &f = nullptr); Matrix(ScriptingEnv *env, const QImage &image, const QString &label, QWidget *parent, const QString &name = QString(), - Qt::WFlags f = nullptr); + const Qt::WFlags &f = nullptr); ~Matrix() override; enum Operation { diff --git a/MantidPlot/src/MatrixDialog.cpp b/MantidPlot/src/MatrixDialog.cpp index d5322f4015788729777754bbfe06f5cc475587b0..fdcf06258d99bd21ef0369e67931efaef214fadd 100644 --- a/MantidPlot/src/MatrixDialog.cpp +++ b/MantidPlot/src/MatrixDialog.cpp @@ -26,7 +26,7 @@ #include <QPushButton> #include <QSpinBox> -MatrixDialog::MatrixDialog(QWidget *parent, Qt::WFlags fl) +MatrixDialog::MatrixDialog(QWidget *parent, const Qt::WFlags &fl) : QDialog(parent, fl), d_matrix(nullptr) { setWindowTitle(tr("MantidPlot - Matrix Properties")); diff --git a/MantidPlot/src/MatrixDialog.h b/MantidPlot/src/MatrixDialog.h index 13c7a1bf2290106c768909d7e517fc14bf4fe3da..9a14b47ffd1a31bb5c8f1ad7f9a3ca7ce3c00462 100644 --- a/MantidPlot/src/MatrixDialog.h +++ b/MantidPlot/src/MatrixDialog.h @@ -34,7 +34,7 @@ public: * @param parent :: parent widget * @param fl :: window flags */ - MatrixDialog(QWidget *parent = nullptr, Qt::WFlags fl = nullptr); + MatrixDialog(QWidget *parent = nullptr, const Qt::WFlags &fl = nullptr); void setMatrix(Matrix *m); private slots: diff --git a/MantidPlot/src/MatrixSizeDialog.cpp b/MantidPlot/src/MatrixSizeDialog.cpp index 8e1f39838be1b6a0fbd2052efc7cda5e237c6cda..3993bd3b396255a85a071453b0ae5b2c9b6a3841 100644 --- a/MantidPlot/src/MatrixSizeDialog.cpp +++ b/MantidPlot/src/MatrixSizeDialog.cpp @@ -26,7 +26,8 @@ #include <QPushButton> #include <QSpinBox> -MatrixSizeDialog::MatrixSizeDialog(Matrix *m, QWidget *parent, Qt::WFlags fl) +MatrixSizeDialog::MatrixSizeDialog(Matrix *m, QWidget *parent, + const Qt::WFlags &fl) : QDialog(parent, fl), d_matrix(m) { setWindowTitle(tr("MantidPlot - Matrix Dimensions")); diff --git a/MantidPlot/src/MatrixSizeDialog.h b/MantidPlot/src/MatrixSizeDialog.h index 6bcb69b329ac69515a6d62f54d9c03b24811a67a..2fdb1eb92ba6fa8fd5a7d0d7327d089e84cda19a 100644 --- a/MantidPlot/src/MatrixSizeDialog.h +++ b/MantidPlot/src/MatrixSizeDialog.h @@ -36,7 +36,7 @@ public: * @param fl :: window flags */ MatrixSizeDialog(Matrix *m, QWidget *parent = nullptr, - Qt::WFlags fl = nullptr); + const Qt::WFlags &fl = nullptr); private slots: //! Accept changes and quit diff --git a/MantidPlot/src/MatrixValuesDialog.cpp b/MantidPlot/src/MatrixValuesDialog.cpp index 1f5925bd7613f9f5b354440cd6a86cfcef9358df..a4cd794e38f99cc1abdb518c77c3e37cdc1ccacb 100644 --- a/MantidPlot/src/MatrixValuesDialog.cpp +++ b/MantidPlot/src/MatrixValuesDialog.cpp @@ -47,7 +47,7 @@ #endif MatrixValuesDialog::MatrixValuesDialog(ScriptingEnv *env, QWidget *parent, - Qt::WFlags fl) + const Qt::WFlags &fl) : QDialog(parent, fl), Scripted(env), matrix(nullptr) { setObjectName("MatrixValuesDialog"); setWindowTitle(tr("MantidPlot - Set Matrix Values")); diff --git a/MantidPlot/src/MatrixValuesDialog.h b/MantidPlot/src/MatrixValuesDialog.h index 4db565ffb01dc94ba2e4ed9faa426d72d2616410..ea5e401346f1c84f6127fbc4ad2e3be457163f17 100644 --- a/MantidPlot/src/MatrixValuesDialog.h +++ b/MantidPlot/src/MatrixValuesDialog.h @@ -50,7 +50,7 @@ class MatrixValuesDialog : public QDialog, public Scripted { public: MatrixValuesDialog(ScriptingEnv *env, QWidget *parent = nullptr, - Qt::WFlags fl = nullptr); + const Qt::WFlags &fl = nullptr); void setMatrix(Matrix *m); private slots: diff --git a/MantidPlot/src/MdPlottingCmapsProvider.cpp b/MantidPlot/src/MdPlottingCmapsProvider.cpp index 15de0dfbd9d31a6efb20eba01fabd96a589b5c22..f2075d55506b21ce255bcf161dc9c1bcb240d232 100644 --- a/MantidPlot/src/MdPlottingCmapsProvider.cpp +++ b/MantidPlot/src/MdPlottingCmapsProvider.cpp @@ -90,7 +90,7 @@ void MdPlottingCmapsProvider::getColorMapsForVSI(QStringList &colorMapNames) { void MdPlottingCmapsProvider::appendAllFileNamesForFileType( QStringList &colorMapNames, QStringList &colorMapFiles, - QString colorMapDirectory, QString fileType) { + const QString &colorMapDirectory, const QString &fileType) { QDir directory(colorMapDirectory); QStringList filter(QString("*.%1").arg(fileType)); @@ -105,7 +105,7 @@ void MdPlottingCmapsProvider::appendAllFileNamesForFileType( std::vector<int> MdPlottingCmapsProvider::getSliceViewerIndicesForCommonColorMaps( - QStringList colorMapNamesSliceViewer, QStringList colorMapNamesVsi) { + QStringList colorMapNamesSliceViewer, const QStringList &colorMapNamesVsi) { int index = 0; std::vector<int> indexVector; diff --git a/MantidPlot/src/MdPlottingCmapsProvider.h b/MantidPlot/src/MdPlottingCmapsProvider.h index 152b292a4b28a0646a05fedda9de2a448a77daa5..7c8a40e8532bb2552092de53979bc1b9423ec7aa 100644 --- a/MantidPlot/src/MdPlottingCmapsProvider.h +++ b/MantidPlot/src/MdPlottingCmapsProvider.h @@ -52,8 +52,8 @@ private: */ void appendAllFileNamesForFileType(QStringList &colorMapNames, QStringList &colorMapFiles, - QString colorMapDirectory, - QString fileType); + const QString &colorMapDirectory, + const QString &fileType); /** * Compare the colormap names of the Slice Viewer and the VSI and extract all @@ -65,5 +65,5 @@ private: */ std::vector<int> getSliceViewerIndicesForCommonColorMaps(QStringList colorMapNamesSliceViewer, - QStringList colorMapNamesVsi); + const QStringList &colorMapNamesVsi); }; diff --git a/MantidPlot/src/MdiSubWindow.cpp b/MantidPlot/src/MdiSubWindow.cpp index fd422b069e77c89950997cd8fbe5199c2b90c3b6..5d1f5ef9b7a8c5d5a851c3ed6153c8776038daad 100644 --- a/MantidPlot/src/MdiSubWindow.cpp +++ b/MantidPlot/src/MdiSubWindow.cpp @@ -52,7 +52,7 @@ using std::string; using namespace Mantid; MdiSubWindow::MdiSubWindow(QWidget *parent, const QString &label, - const QString &name, Qt::WFlags f) + const QString &name, const Qt::WFlags &f) : MdiSubWindowParent_t(parent, f), d_app(static_cast<ApplicationWindow *>(parent)), d_folder(d_app->currentFolder()), d_label(label), d_status(Normal), @@ -70,7 +70,7 @@ MdiSubWindow::MdiSubWindow() d_min_restore_size(QSize()) {} void MdiSubWindow::init(QWidget *parent, const QString &label, - const QString &name, Qt::WFlags flags) { + const QString &name, const Qt::WFlags &flags) { setParent(parent); setObjectName(name); setName(name); diff --git a/MantidPlot/src/MdiSubWindow.h b/MantidPlot/src/MdiSubWindow.h index 87c7330c64179e098c9f247ac5a5fe675647d664..b2575cf0a8b0ce1aa3b26480652620cae5bd5a3a 100644 --- a/MantidPlot/src/MdiSubWindow.h +++ b/MantidPlot/src/MdiSubWindow.h @@ -49,7 +49,7 @@ class Folder; class MdiSubWindowParent_t : public QFrame { Q_OBJECT public: - MdiSubWindowParent_t(QWidget *parent, Qt::WFlags f = nullptr) + MdiSubWindowParent_t(QWidget *parent, const Qt::WFlags &f = nullptr) : QFrame(parent, f), m_widget(nullptr) {} void setWidget(QWidget *w) { if (w == nullptr) { // removing widget @@ -124,13 +124,13 @@ public: * \sa setCaptionPolicy(), captionPolicy() */ MdiSubWindow(QWidget *parent, const QString &label = QString(), - const QString &name = QString(), Qt::WFlags f = nullptr); + const QString &name = QString(), const Qt::WFlags &f = nullptr); MdiSubWindow(); /// Setup the window without constructor void init(QWidget *parent, const QString &label, const QString &name, - Qt::WFlags flags); + const Qt::WFlags &flags); //! Possible window captions. enum CaptionPolicy { diff --git a/MantidPlot/src/MultiLayer.cpp b/MantidPlot/src/MultiLayer.cpp index 13ea8f39184ad2d23a120b1d1df3cbfdaf74d277..f9e07ea5f817de2611c8569ccb9f97252d01076e 100644 --- a/MantidPlot/src/MultiLayer.cpp +++ b/MantidPlot/src/MultiLayer.cpp @@ -113,7 +113,8 @@ void LayerButton::mouseDoubleClickEvent(QMouseEvent *) { } MultiLayer::MultiLayer(QWidget *parent, int layers, int rows, int cols, - const QString &label, const char *name, Qt::WFlags f) + const QString &label, const char *name, + const Qt::WFlags &f) : MdiSubWindow(parent, label, name, f), active_graph(nullptr), d_cols(cols), d_rows(rows), graph_width(500), graph_height(400), colsSpace(5), rowsSpace(5), left_margin(5), right_margin(5), top_margin(5), diff --git a/MantidPlot/src/MultiLayer.h b/MantidPlot/src/MultiLayer.h index ad453f12b188d91cd64b856fa7e5c5ce84cc576f..b0ce909fd8666127c0da4a9c1162925af88164c6 100644 --- a/MantidPlot/src/MultiLayer.h +++ b/MantidPlot/src/MultiLayer.h @@ -82,7 +82,7 @@ class MultiLayer : public MdiSubWindow { public: MultiLayer(QWidget *parent, int layers = 1, int rows = 1, int cols = 1, const QString &label = "", const char *name = nullptr, - Qt::WFlags f = nullptr); + const Qt::WFlags &f = nullptr); ~MultiLayer() override; /// Get the window type as a string diff --git a/MantidPlot/src/Note.cpp b/MantidPlot/src/Note.cpp index 51dd908bec782c521379afa66754ee8bef0087bc..ca70a44a87aacc685127fb804a81fc126617ef07 100644 --- a/MantidPlot/src/Note.cpp +++ b/MantidPlot/src/Note.cpp @@ -50,7 +50,7 @@ DECLARE_WINDOW(Note) using namespace Mantid; Note::Note(const QString &label, QWidget *parent, const QString &name, - Qt::WFlags f) + const Qt::WFlags &f) : MdiSubWindow(parent, label, name, f) { te = new QTextEdit(this); te->setObjectName(name); diff --git a/MantidPlot/src/Note.h b/MantidPlot/src/Note.h index d338954d35661a873d29b53a80eac6ccbb8d28b4..e724c86c9ae95d0de2fcd8e40f0036e6752e71b0 100644 --- a/MantidPlot/src/Note.h +++ b/MantidPlot/src/Note.h @@ -45,7 +45,7 @@ class Note : public MdiSubWindow { public: Note(const QString &label, QWidget *parent, const QString &name = QString(), - Qt::WFlags f = nullptr); + const Qt::WFlags &f = nullptr); ~Note() override{}; static MantidQt::API::IProjectSerialisable * diff --git a/MantidPlot/src/Plot3DDialog.cpp b/MantidPlot/src/Plot3DDialog.cpp index ec764b88452f34c24424b2ee508bbf7dd8ca3a84..eedff1758176b13ef436475beff0cf33a447ce22 100644 --- a/MantidPlot/src/Plot3DDialog.cpp +++ b/MantidPlot/src/Plot3DDialog.cpp @@ -46,7 +46,7 @@ using Mantid::Kernel::ConfigService; -Plot3DDialog::Plot3DDialog(QWidget *parent, Qt::WFlags fl) +Plot3DDialog::Plot3DDialog(QWidget *parent, const Qt::WFlags &fl) : QDialog(parent, fl) { setObjectName("Plot3DDialog"); setWindowTitle(tr("MantidPlot - Surface Plot Options")); diff --git a/MantidPlot/src/Plot3DDialog.h b/MantidPlot/src/Plot3DDialog.h index 664806982666b0d2ce5ab417ddfef27f4f9cbec9..f8a6a179edf4d0b82cb22baca38c00add951fab4 100644 --- a/MantidPlot/src/Plot3DDialog.h +++ b/MantidPlot/src/Plot3DDialog.h @@ -41,7 +41,7 @@ class Plot3DDialog : public QDialog { Q_OBJECT public: - Plot3DDialog(QWidget *parent, Qt::WFlags fl = nullptr); + Plot3DDialog(QWidget *parent, const Qt::WFlags &fl = nullptr); void setPlot(Graph3D *); void showTitleTab(); diff --git a/MantidPlot/src/PlotDialog.cpp b/MantidPlot/src/PlotDialog.cpp index 933f04a338a81b5ed619617a2953ff90c922630c..5ca24067fa4fbfc4613a4499e2c13f2d0c4843e2 100644 --- a/MantidPlot/src/PlotDialog.cpp +++ b/MantidPlot/src/PlotDialog.cpp @@ -75,7 +75,7 @@ using Mantid::Kernel::ConfigService; using namespace MantidQt::API; PlotDialog::PlotDialog(bool showExtended, ApplicationWindow *app, - MultiLayer *ml, Qt::WFlags fl) + MultiLayer *ml, const Qt::WFlags &fl) : QDialog(ml, fl), d_app(app), d_ml(nullptr) { setObjectName("PlotDialog"); setWindowTitle(tr("MantidPlot - Plot details")); diff --git a/MantidPlot/src/PlotDialog.h b/MantidPlot/src/PlotDialog.h index beb8d8a62a29ea88227bb497153835efe78d6000..a1d7a4175197797b6508d8072c3c1351e651d588 100644 --- a/MantidPlot/src/PlotDialog.h +++ b/MantidPlot/src/PlotDialog.h @@ -69,7 +69,7 @@ class PlotDialog : public QDialog { public: PlotDialog(bool showExtended, ApplicationWindow *app, MultiLayer *ml, - Qt::WFlags fl = nullptr); + const Qt::WFlags &fl = nullptr); void initFonts(const QFont &titlefont, const QFont &axesfont, const QFont &numbersfont, const QFont &legendfont); void insertColumnsList(const QStringList &names) { columnNames = names; }; diff --git a/MantidPlot/src/PlotWizard.cpp b/MantidPlot/src/PlotWizard.cpp index e181c6d17808b9520ab9253212716a5f8d395a5d..4d7db635cb44656d0fb8a9994a2efd7cb71fe4b6 100644 --- a/MantidPlot/src/PlotWizard.cpp +++ b/MantidPlot/src/PlotWizard.cpp @@ -37,7 +37,8 @@ #include <QGroupBox> #include <QListWidget> -PlotWizard::PlotWizard(QWidget *parent, Qt::WFlags fl) : QDialog(parent, fl) { +PlotWizard::PlotWizard(QWidget *parent, const Qt::WFlags &fl) + : QDialog(parent, fl) { setWindowTitle(tr("MantidPlot - Select Columns to Plot")); setSizeGripEnabled(true); diff --git a/MantidPlot/src/PlotWizard.h b/MantidPlot/src/PlotWizard.h index e7e69ff2ef4319d7aabcae886fa9eff355d05829..cb68e8867ed89783c36a80c7c97255c7705633a8 100644 --- a/MantidPlot/src/PlotWizard.h +++ b/MantidPlot/src/PlotWizard.h @@ -46,7 +46,7 @@ public: * @param parent :: parent widget * @param fl :: Qt window flags */ - PlotWizard(QWidget *parent = nullptr, Qt::WFlags fl = nullptr); + PlotWizard(QWidget *parent = nullptr, const Qt::WFlags &fl = nullptr); private: //! Button "Plot" diff --git a/MantidPlot/src/PolynomFitDialog.cpp b/MantidPlot/src/PolynomFitDialog.cpp index c06057a329063938c6d00574c0718ae4bad5b5f2..8d950fcfdace5b77d80e980da293cb610e1d7124 100644 --- a/MantidPlot/src/PolynomFitDialog.cpp +++ b/MantidPlot/src/PolynomFitDialog.cpp @@ -38,7 +38,7 @@ #include <QMessageBox> #include <QSpinBox> -PolynomFitDialog::PolynomFitDialog(QWidget *parent, Qt::WFlags fl) +PolynomFitDialog::PolynomFitDialog(QWidget *parent, const Qt::WFlags &fl) : QDialog(parent, fl), graph(nullptr) { setObjectName("PolynomFitDialog"); setWindowTitle(tr("MantidPlot - Polynomial Fit Options")); diff --git a/MantidPlot/src/PolynomFitDialog.h b/MantidPlot/src/PolynomFitDialog.h index 148607e92d58efcd95e9f12022af1769b6207ae0..7a1d51c1daf8a7c55d57e1ff33449559353acf8a 100644 --- a/MantidPlot/src/PolynomFitDialog.h +++ b/MantidPlot/src/PolynomFitDialog.h @@ -44,7 +44,7 @@ class PolynomFitDialog : public QDialog { Q_OBJECT public: - PolynomFitDialog(QWidget *parent = nullptr, Qt::WFlags fl = nullptr); + PolynomFitDialog(QWidget *parent = nullptr, const Qt::WFlags &fl = nullptr); public slots: void fit(); diff --git a/MantidPlot/src/Processes.cpp b/MantidPlot/src/Processes.cpp index 392770cefb934bd778e0107497ec97cd880d4afc..92723188e4c696c81eb01e441a32973c236525ea 100644 --- a/MantidPlot/src/Processes.cpp +++ b/MantidPlot/src/Processes.cpp @@ -24,7 +24,7 @@ namespace { -bool isOtherInstance(int64_t otherPID, QString otherExeName) { +bool isOtherInstance(int64_t otherPID, const QString &otherExeName) { static const int64_t ourPID(QCoreApplication::applicationPid()); if (otherPID == ourPID) return false; diff --git a/MantidPlot/src/ProjectRecovery.cpp b/MantidPlot/src/ProjectRecovery.cpp index 5085c402c690ce660ee12131e75d18c41547fd87..7007e0d5a7bf9cf6aa27b603cc4f950f576cc371 100644 --- a/MantidPlot/src/ProjectRecovery.cpp +++ b/MantidPlot/src/ProjectRecovery.cpp @@ -339,7 +339,8 @@ bool ProjectRecovery::checkForRecovery() const noexcept { } } -bool ProjectRecovery::clearAllCheckpoints(Poco::Path path) const noexcept { +bool ProjectRecovery::clearAllCheckpoints(const Poco::Path &path) const + noexcept { try { Poco::File(path).remove(true); return true; diff --git a/MantidPlot/src/ProjectRecovery.h b/MantidPlot/src/ProjectRecovery.h index cca98b0ce4eed238b47da058c22d5a1ed439ae56..bc323123d21a490384d0dbde04cc201731310b14 100644 --- a/MantidPlot/src/ProjectRecovery.h +++ b/MantidPlot/src/ProjectRecovery.h @@ -47,7 +47,7 @@ public: bool checkForRecovery() const noexcept; /// Clears all checkpoints in the existing folder at the given path - bool clearAllCheckpoints(Poco::Path path) const noexcept; + bool clearAllCheckpoints(const Poco::Path &path) const noexcept; /// Clears all checkpoints in the existing folder at the given path bool clearAllUnusedCheckpoints() const noexcept; diff --git a/MantidPlot/src/ProjectSerialiser.cpp b/MantidPlot/src/ProjectSerialiser.cpp index cbd97ac9b4e2d13c2eaad24e21482fdd37715588..3cfbb334e7c6bb34d74b51ddab44bc4396706c7c 100644 --- a/MantidPlot/src/ProjectSerialiser.cpp +++ b/MantidPlot/src/ProjectSerialiser.cpp @@ -220,7 +220,7 @@ bool ProjectSerialiser::save(const QString &projectName, bool compress, * folder. (Default True) * @return True is loading was successful, otherwise false */ -bool ProjectSerialiser::load(std::string filepath, const int fileVersion, +bool ProjectSerialiser::load(const std::string &filepath, const int fileVersion, const bool isTopLevel) { // We have to accept std::string to maintain Python compatibility auto qfilePath = QString::fromStdString(filepath); diff --git a/MantidPlot/src/ProjectSerialiser.h b/MantidPlot/src/ProjectSerialiser.h index 36b3b6d6fa907b5ed86959d29f4f98d3a9b3f93b..7ef131461b2a734cd11e176a8655a3f4b8cd6498 100644 --- a/MantidPlot/src/ProjectSerialiser.h +++ b/MantidPlot/src/ProjectSerialiser.h @@ -59,7 +59,7 @@ public: bool save(const QString &projectName, bool compress = false, bool saveAll = true); /// Load a project file from disk - bool load(std::string filepath, const int fileVersion, + bool load(const std::string &filepath, const int fileVersion, const bool isTopLevel = true); /// Open the script window and load scripts from string void openScriptWindow(const QStringList &files); diff --git a/MantidPlot/src/RenameWindowDialog.cpp b/MantidPlot/src/RenameWindowDialog.cpp index e717cf0ec27ae05555c28d5d2e91012dfe2982d5..0fde8040217f54a9bd6235b6f96603f75c9d9a2a 100644 --- a/MantidPlot/src/RenameWindowDialog.cpp +++ b/MantidPlot/src/RenameWindowDialog.cpp @@ -37,7 +37,7 @@ #include <QMessageBox> #include <QRadioButton> -RenameWindowDialog::RenameWindowDialog(QWidget *parent, Qt::WFlags fl) +RenameWindowDialog::RenameWindowDialog(QWidget *parent, const Qt::WFlags &fl) : QDialog(parent, fl) { setWindowTitle(tr("MantidPlot - Rename Window")); diff --git a/MantidPlot/src/RenameWindowDialog.h b/MantidPlot/src/RenameWindowDialog.h index 2307e1af7f3e77c8c7c2839feb3de008b04b2533..87efc06339dd8c9efd9612a1755451a7933ebd5a 100644 --- a/MantidPlot/src/RenameWindowDialog.h +++ b/MantidPlot/src/RenameWindowDialog.h @@ -47,7 +47,7 @@ class RenameWindowDialog : public QDialog { Q_OBJECT public: - RenameWindowDialog(QWidget *parent = nullptr, Qt::WFlags fl = nullptr); + RenameWindowDialog(QWidget *parent = nullptr, const Qt::WFlags &fl = nullptr); private: QPushButton *buttonOk; diff --git a/MantidPlot/src/ScriptingLangDialog.cpp b/MantidPlot/src/ScriptingLangDialog.cpp index 58308238c79c30cc6fdff502c7bc6b28db296cfa..4ee342dd39c5daf7eb4d57710acef340e6e97c78 100644 --- a/MantidPlot/src/ScriptingLangDialog.cpp +++ b/MantidPlot/src/ScriptingLangDialog.cpp @@ -37,7 +37,7 @@ ScriptingLangDialog::ScriptingLangDialog(ScriptingEnv *env, ApplicationWindow *parent, - Qt::WFlags fl) + const Qt::WFlags &fl) : QDialog(parent, fl), Scripted(env) { setWindowTitle(tr("MantidPlot - Select scripting language")); diff --git a/MantidPlot/src/ScriptingLangDialog.h b/MantidPlot/src/ScriptingLangDialog.h index 1dc8dba2cdd226d7b9b3e2b9c8af31b3a0400d82..780c6ba9861cd1f6d4a1f1662b976917de4b48eb 100644 --- a/MantidPlot/src/ScriptingLangDialog.h +++ b/MantidPlot/src/ScriptingLangDialog.h @@ -43,7 +43,7 @@ class ScriptingLangDialog : public QDialog, public Scripted { public: ScriptingLangDialog(ScriptingEnv *env, ApplicationWindow *parent, - Qt::WFlags fl = nullptr); + const Qt::WFlags &fl = nullptr); public slots: void updateLangList(); diff --git a/MantidPlot/src/SendToProgramDialog.cpp b/MantidPlot/src/SendToProgramDialog.cpp index 2902f85d2e668be3f1aae31fffa2c7d766fa94b1..dd72797177637d5fcfe30c3df395e8bae379ba17 100644 --- a/MantidPlot/src/SendToProgramDialog.cpp +++ b/MantidPlot/src/SendToProgramDialog.cpp @@ -31,7 +31,7 @@ using namespace MantidQt::API; /** * Constructor when adding a new program to the send to list */ -SendToProgramDialog::SendToProgramDialog(QWidget *parent, Qt::WFlags fl) +SendToProgramDialog::SendToProgramDialog(QWidget *parent, const Qt::WFlags &fl) : QDialog(parent, fl), validName(false), validTarget(false), validSaveUsing(false) { m_uiform.setupUi(this); @@ -61,8 +61,9 @@ SendToProgramDialog::SendToProgramDialog(QWidget *parent, Qt::WFlags fl) * Constructor when editing a program settings */ SendToProgramDialog::SendToProgramDialog( - QWidget *parent, QString programName, - std::map<std::string, std::string> programKeysAndDetails, Qt::WFlags fl) + QWidget *parent, const QString &programName, + std::map<std::string, std::string> programKeysAndDetails, + const Qt::WFlags &fl) : QDialog(parent, fl), validName(true), validTarget(true), validSaveUsing(true) { m_uiform.setupUi(this); diff --git a/MantidPlot/src/SendToProgramDialog.h b/MantidPlot/src/SendToProgramDialog.h index 19fe0936f911e7c3226d0fb6680c167e7cd83d78..1e16fc996abd1abdfba0ee8d0e2fd40d291fb0fb 100644 --- a/MantidPlot/src/SendToProgramDialog.h +++ b/MantidPlot/src/SendToProgramDialog.h @@ -26,10 +26,10 @@ class SendToProgramDialog : public QDialog { Q_OBJECT public: - SendToProgramDialog(QWidget *parent, Qt::WFlags fl = nullptr); - SendToProgramDialog(QWidget *parent, QString programName, + SendToProgramDialog(QWidget *parent, const Qt::WFlags &fl = nullptr); + SendToProgramDialog(QWidget *parent, const QString &programName, std::map<std::string, std::string> programKeysAndDetails, - Qt::WFlags fl = nullptr); + const Qt::WFlags &fl = nullptr); std::pair<std::string, std::map<std::string, std::string>> getSettings() const; diff --git a/MantidPlot/src/SetColValuesDialog.cpp b/MantidPlot/src/SetColValuesDialog.cpp index a04958664203f33cbf845fe1e7d366bfb76480a5..969f46337c3b24c1e801c2e0adc122a5456ead55 100644 --- a/MantidPlot/src/SetColValuesDialog.cpp +++ b/MantidPlot/src/SetColValuesDialog.cpp @@ -50,7 +50,7 @@ #endif SetColValuesDialog::SetColValuesDialog(ScriptingEnv *env, Table *t, - Qt::WFlags fl) + const Qt::WFlags &fl) : QDialog(t, fl), Scripted(env) { setObjectName("SetColValuesDialog"); setWindowTitle(tr("MantidPlot - Set column values")); diff --git a/MantidPlot/src/SetColValuesDialog.h b/MantidPlot/src/SetColValuesDialog.h index 9732f19ff59d51fb3bf0d0a108865fbb0422c812..65be95aec42f88a53e158f143bd20a96f920555d 100644 --- a/MantidPlot/src/SetColValuesDialog.h +++ b/MantidPlot/src/SetColValuesDialog.h @@ -52,7 +52,8 @@ class SetColValuesDialog : public QDialog, public Scripted { Q_OBJECT public: - SetColValuesDialog(ScriptingEnv *env, Table *t, Qt::WFlags fl = nullptr); + SetColValuesDialog(ScriptingEnv *env, Table *t, + const Qt::WFlags &fl = nullptr); private slots: bool apply(); diff --git a/MantidPlot/src/SmoothCurveDialog.cpp b/MantidPlot/src/SmoothCurveDialog.cpp index 1881bb953b86272117e382c6820e466ccfc4ef40..83d941b1166b1f19db86658086aeea994b641c0a 100644 --- a/MantidPlot/src/SmoothCurveDialog.cpp +++ b/MantidPlot/src/SmoothCurveDialog.cpp @@ -42,7 +42,8 @@ #include <QPushButton> #include <QSpinBox> -SmoothCurveDialog::SmoothCurveDialog(int method, QWidget *parent, Qt::WFlags fl) +SmoothCurveDialog::SmoothCurveDialog(int method, QWidget *parent, + const Qt::WFlags &fl) : QDialog(parent, fl), graph(nullptr), boxPointsLeft(nullptr), boxPointsRight(nullptr), boxOrder(nullptr) { smooth_method = method; diff --git a/MantidPlot/src/SmoothCurveDialog.h b/MantidPlot/src/SmoothCurveDialog.h index 644f417a1fa5b5b79e45cb9fa45442e5abf67d1f..e5e9048ce28d295a5ce4cda4e0e5ea4cac959bd9 100644 --- a/MantidPlot/src/SmoothCurveDialog.h +++ b/MantidPlot/src/SmoothCurveDialog.h @@ -43,7 +43,7 @@ class SmoothCurveDialog : public QDialog { public: SmoothCurveDialog(int method, QWidget *parent = nullptr, - Qt::WFlags fl = nullptr); + const Qt::WFlags &fl = nullptr); public slots: void setGraph(Graph *g); diff --git a/MantidPlot/src/SortDialog.cpp b/MantidPlot/src/SortDialog.cpp index 4914069e850538758fc35b068c9fb5c84a8891e7..8e422cbcc3d968ed78be05372176ebf1e9f95cf8 100644 --- a/MantidPlot/src/SortDialog.cpp +++ b/MantidPlot/src/SortDialog.cpp @@ -36,7 +36,8 @@ #include <QLayout> #include <QPushButton> -SortDialog::SortDialog(QWidget *parent, Qt::WFlags fl) : QDialog(parent, fl) { +SortDialog::SortDialog(QWidget *parent, const Qt::WFlags &fl) + : QDialog(parent, fl) { setWindowTitle(tr("MantidPlot - Sorting Options")); setSizeGripEnabled(true); diff --git a/MantidPlot/src/SortDialog.h b/MantidPlot/src/SortDialog.h index 42ce2a3e622898ec5b5f448e600d6dbc761e0422..6773e9bb1fd47f79d0de4746b979b62c52f1433c 100644 --- a/MantidPlot/src/SortDialog.h +++ b/MantidPlot/src/SortDialog.h @@ -39,7 +39,7 @@ class SortDialog : public QDialog { Q_OBJECT public: - SortDialog(QWidget *parent = nullptr, Qt::WFlags fl = nullptr); + SortDialog(QWidget *parent = nullptr, const Qt::WFlags &fl = nullptr); void insertColumnsList(const QStringList &cols); private slots: diff --git a/MantidPlot/src/Spectrogram.cpp b/MantidPlot/src/Spectrogram.cpp index 3d60e8bc3894a3fb0c225686fb5cff80989c5d61..8c02a539d938d6fb9827d372a731dabca31ef679 100644 --- a/MantidPlot/src/Spectrogram.cpp +++ b/MantidPlot/src/Spectrogram.cpp @@ -49,6 +49,7 @@ #include "MantidQtWidgets/Common/TSVSerialiser.h" #include <numeric> +#include <utility> Spectrogram::Spectrogram() : QObject(), QwtPlotSpectrogram(), d_color_map_pen(false), @@ -694,7 +695,7 @@ void Spectrogram::loadSettings() { * This method saves the selectcolrmap file name to membervaraible */ void Spectrogram::setColorMapFileName(QString colormapName) { - mCurrentColorMap = colormapName; + mCurrentColorMap = std::move(colormapName); } QwtDoubleRect Spectrogram::boundingRect() const { return d_matrix ? d_matrix->boundingRect() : data().boundingRect(); @@ -707,7 +708,7 @@ double Spectrogram::getMinPositiveValue() const { } void Spectrogram::setContourPenList(QList<QPen> lst) { - d_pen_list = lst; + d_pen_list = std::move(lst); setDefaultContourPen(Qt::NoPen); d_color_map_pen = false; } diff --git a/MantidPlot/src/SurfaceDialog.cpp b/MantidPlot/src/SurfaceDialog.cpp index dcbef03d769d6f9604c07946fa5c37e8bb95e4ea..812bde0ca580b0e3e1d73f1c44783509b8438192 100644 --- a/MantidPlot/src/SurfaceDialog.cpp +++ b/MantidPlot/src/SurfaceDialog.cpp @@ -34,7 +34,7 @@ #include <QSpinBox> #include <QStackedWidget> -SurfaceDialog::SurfaceDialog(QWidget *parent, Qt::WFlags fl) +SurfaceDialog::SurfaceDialog(QWidget *parent, const Qt::WFlags &fl) : QDialog(parent, fl) { setObjectName("SurfaceDialog"); setWindowTitle(tr("MantidPlot - Define surface plot")); diff --git a/MantidPlot/src/SurfaceDialog.h b/MantidPlot/src/SurfaceDialog.h index f14ae164915c8d733dd3e61a677a7538102d28de..239a4ae773745654669c94be3b227be6b82f8783 100644 --- a/MantidPlot/src/SurfaceDialog.h +++ b/MantidPlot/src/SurfaceDialog.h @@ -32,7 +32,7 @@ class SurfaceDialog : public QDialog { Q_OBJECT public: - SurfaceDialog(QWidget *parent = nullptr, Qt::WFlags fl = nullptr); + SurfaceDialog(QWidget *parent = nullptr, const Qt::WFlags &fl = nullptr); public slots: void accept() override; diff --git a/MantidPlot/src/Table.cpp b/MantidPlot/src/Table.cpp index 77a64b210d3752c16b4d78266a2f3ddf36d354dd..606c439cc61bb73f0f604720df53e0106e8338c8 100644 --- a/MantidPlot/src/Table.cpp +++ b/MantidPlot/src/Table.cpp @@ -73,7 +73,7 @@ using namespace Mantid; using namespace MantidQt::API; Table::Table(ScriptingEnv *env, int rows, int cols, const QString &label, - QWidget *parent, const QString &name, Qt::WFlags f) + QWidget *parent, const QString &name, const Qt::WFlags &f) : MdiSubWindow(parent, label, name, f), Scripted(env) { selectedCol = -1; d_saved_cells = nullptr; @@ -2002,7 +2002,7 @@ void Table::loadHeader(QStringList header) { setHeaderColType(); } -void Table::setHeader(QStringList header) { +void Table::setHeader(const QStringList &header) { col_label = header; setHeaderColType(); } @@ -3267,7 +3267,7 @@ void Table::recordSelection() { * @param alignment :: [input] Alignment flags to give the cell */ void Table::setTextAlignment(int row, int col, - QFlags<Qt::AlignmentFlag> alignment) { + const QFlags<Qt::AlignmentFlag> &alignment) { auto *cell = d_table->item(row, col); if (cell) { cell->setTextAlignment(alignment); diff --git a/MantidPlot/src/Table.h b/MantidPlot/src/Table.h index e81b3bc679523386b085e04de447c5ebce8fad66..434bb77f1c2078917aca9023420383a2b82bb44d 100644 --- a/MantidPlot/src/Table.h +++ b/MantidPlot/src/Table.h @@ -33,6 +33,9 @@ #include <QTableWidget> #include <QVarLengthArray> +#include <utility> + +#include <utility> #include "Graph.h" #include "MdiSubWindow.h" @@ -116,7 +119,7 @@ public: }; Table(ScriptingEnv *env, int r, int c, const QString &label, QWidget *parent, - const QString &name = QString(), Qt::WFlags f = nullptr); + const QString &name = QString(), const Qt::WFlags &f = nullptr); int topSelectedRow() const { return d_table->topSelectedRow(); } int bottomSelectedRow() const { return d_table->bottomSelectedRow(); } @@ -160,13 +163,14 @@ public slots: bool rightColumns = false); QList<int> plotDesignations() { return col_plot_type; }; - void setHeader(QStringList header); + void setHeader(const QStringList &header); void loadHeader(QStringList header); void setHeaderColType(); void setText(int row, int col, const QString &text); void setRandomValues(); void setAscValues(); - void setTextAlignment(int row, int col, QFlags<Qt::AlignmentFlag> alignment); + void setTextAlignment(int row, int col, + const QFlags<Qt::AlignmentFlag> &alignment); virtual void cellEdited(int, int col); void moveCurrentCell(); @@ -339,7 +343,7 @@ public slots: int columnType(int col) { return colTypes[col]; }; QList<int> columnTypes() { return colTypes; }; - void setColumnTypes(QList<int> ctl) { colTypes = ctl; }; + void setColumnTypes(QList<int> ctl) { colTypes = std::move(std::move(ctl)); }; void setColumnTypes(const QStringList &ctl); void setColumnType(int col, ColType val) { colTypes[col] = val; } diff --git a/MantidPlot/src/TableDialog.cpp b/MantidPlot/src/TableDialog.cpp index 546de53ec27cf47369e92622dea158d0f0edbe55..b7a10b34342c0364964fbe5310ca63565133db6c 100644 --- a/MantidPlot/src/TableDialog.cpp +++ b/MantidPlot/src/TableDialog.cpp @@ -45,7 +45,8 @@ #include <QSpinBox> #include <QTextEdit> -TableDialog::TableDialog(Table *t, Qt::WFlags fl) : QDialog(t, fl), d_table(t) { +TableDialog::TableDialog(Table *t, const Qt::WFlags &fl) + : QDialog(t, fl), d_table(t) { setObjectName("TableDialog"); setWindowTitle(tr("MantidPlot - Column options")); setSizeGripEnabled(true); diff --git a/MantidPlot/src/TableDialog.h b/MantidPlot/src/TableDialog.h index 0ddef50ab45ff6dc0dad8591103afcd637d4a519..5fc8b09dcc8d2c3b388a8bb5b93f518c9ea5d390 100644 --- a/MantidPlot/src/TableDialog.h +++ b/MantidPlot/src/TableDialog.h @@ -44,7 +44,7 @@ class TableDialog : public QDialog { Q_OBJECT public: - TableDialog(Table *t, Qt::WFlags fl = nullptr); + TableDialog(Table *t, const Qt::WFlags &fl = nullptr); private slots: void prevColumn(); diff --git a/MantidPlot/src/TableStatistics.cpp b/MantidPlot/src/TableStatistics.cpp index 98e09f7a1b043b6146d25f08ce2fce4d414ac9d9..fc6bbb93f3e42686b82b2d252ac89ea195a66a1b 100644 --- a/MantidPlot/src/TableStatistics.cpp +++ b/MantidPlot/src/TableStatistics.cpp @@ -47,7 +47,7 @@ DECLARE_WINDOW(TableStatistics) using namespace Mantid; TableStatistics::TableStatistics(ScriptingEnv *env, QWidget *parent, - Table *base, Type t, QList<int> targets) + Table *base, Type t, const QList<int> &targets) : Table(env, 1, 1, "", parent, ""), d_base(base), d_type(t), d_targets(targets) { diff --git a/MantidPlot/src/TableStatistics.h b/MantidPlot/src/TableStatistics.h index 0877b0e7be658b632ed2654801f3c311a3a33151..f489cc3db1f18c83cab8ba78ba46e73031df9751 100644 --- a/MantidPlot/src/TableStatistics.h +++ b/MantidPlot/src/TableStatistics.h @@ -43,7 +43,7 @@ public: //! supported statistics types enum Type { row, column }; TableStatistics(ScriptingEnv *env, QWidget *parent, Table *base, Type, - QList<int> targets); + const QList<int> &targets); //! return the type of statistics Type type() const { return d_type; } //! return the base table of which statistics are displayed diff --git a/MantidPlot/src/TextDialog.cpp b/MantidPlot/src/TextDialog.cpp index 62a2da5fb0e8b64486dd526d26d28c7841d57f60..255bf8398dbd138c307fe97bb05725c7baefaeb1 100644 --- a/MantidPlot/src/TextDialog.cpp +++ b/MantidPlot/src/TextDialog.cpp @@ -47,7 +47,7 @@ #include <qwt_scale_widget.h> -TextDialog::TextDialog(TextType type, QWidget *parent, Qt::WFlags fl) +TextDialog::TextDialog(TextType type, QWidget *parent, const Qt::WFlags &fl) : QDialog(parent, fl) { setAttribute(Qt::WA_DeleteOnClose); setWindowTitle(tr("MantidPlot - Text options")); diff --git a/MantidPlot/src/TextDialog.h b/MantidPlot/src/TextDialog.h index 28b7fecf68ef6930781255f9e561f7ec689c2381..59bbbd53dd3edcc47f0713279c46ccc6f615ca01 100644 --- a/MantidPlot/src/TextDialog.h +++ b/MantidPlot/src/TextDialog.h @@ -62,7 +62,8 @@ public: * @param parent :: parent widget * @param fl :: window flags */ - TextDialog(TextType type, QWidget *parent = nullptr, Qt::WFlags fl = nullptr); + TextDialog(TextType type, QWidget *parent = nullptr, + const Qt::WFlags &fl = nullptr); //! Return axis label alignment /** diff --git a/MantidPlot/src/TextFileIO.cpp b/MantidPlot/src/TextFileIO.cpp index 64df4906e6af0e0590bdb615990f15b71d25df13..3e0085c4f12c13bee323e69af2fc001c3de08db4 100644 --- a/MantidPlot/src/TextFileIO.cpp +++ b/MantidPlot/src/TextFileIO.cpp @@ -16,7 +16,8 @@ /** * Construct an object with a list of file filters */ -TextFileIO::TextFileIO(QStringList fileFilters) : m_filters(fileFilters) {} +TextFileIO::TextFileIO(const QStringList &fileFilters) + : m_filters(fileFilters) {} /** * Save to a file diff --git a/MantidPlot/src/TextFileIO.h b/MantidPlot/src/TextFileIO.h index edb217ce5e6b3b09bf0eb34ee4e367b00d3185ab..1c4b36c6bebf0802d1f64c3724955e8bc1e89195 100644 --- a/MantidPlot/src/TextFileIO.h +++ b/MantidPlot/src/TextFileIO.h @@ -16,7 +16,7 @@ class TextFileIO { public: /// Construct the object with a list of file filters - explicit TextFileIO(QStringList fileFilters = QStringList()); + explicit TextFileIO(const QStringList &fileFilters = QStringList()); /// Save to a file bool save(const QString &txt, const QString &filename) const; diff --git a/MantidPlot/src/TiledWindow.cpp b/MantidPlot/src/TiledWindow.cpp index 1661270ade1c44b2ad7410718552e5a0c84c37aa..46925af38084a218cb818107378e75247182af8d 100644 --- a/MantidPlot/src/TiledWindow.cpp +++ b/MantidPlot/src/TiledWindow.cpp @@ -215,7 +215,7 @@ InnerWidget *getInnerWidget(QWidget *w) { */ TiledWindow::TiledWindow(QWidget *parent, const QString &label, const QString &name, int nrows, int ncols, - Qt::WFlags f) + const Qt::WFlags &f) : MdiSubWindow(parent, label, name, f), m_scrollArea(nullptr), m_layout(nullptr), m_buttonPressed(false) { connect(this, SIGNAL(dropAtPositionQueued(MdiSubWindow *, QPoint, bool)), diff --git a/MantidPlot/src/TiledWindow.h b/MantidPlot/src/TiledWindow.h index d4ce70a50d83888a52a9ec5c98422cfebcd70a6f..49df22a9e90743a2c29bb9c658f2b7b0d3241747 100644 --- a/MantidPlot/src/TiledWindow.h +++ b/MantidPlot/src/TiledWindow.h @@ -30,7 +30,7 @@ class TiledWindow : public MdiSubWindow { public: TiledWindow(QWidget *parent, const QString &label, const QString &name = QString(), int nrows = 1, int ncols = 1, - Qt::WFlags f = nullptr); + const Qt::WFlags &f = nullptr); /// Populate a menu with actions void populateMenu(QMenu *menu); diff --git a/MantidPlot/src/lib/include/ExtensibleFileDialog.h b/MantidPlot/src/lib/include/ExtensibleFileDialog.h index 0dcea4e15f3a39760105d384de8d5ed30120a8fc..6162c67f713dbd465ef49928370091de38f86b82 100644 --- a/MantidPlot/src/lib/include/ExtensibleFileDialog.h +++ b/MantidPlot/src/lib/include/ExtensibleFileDialog.h @@ -54,9 +54,10 @@ public: * \param extended flag: show/hide the advanced options on start-up * \param flags window flags */ - ExtensibleFileDialog(QWidget *parent = nullptr, bool extended = true, - Qt::WFlags flags = Qt::WindowCloseButtonHint | - Qt::WindowType::WindowTitleHint); + ExtensibleFileDialog( + QWidget *parent = nullptr, bool extended = true, + const Qt::WFlags &flags = Qt::WindowCloseButtonHint | + Qt::WindowType::WindowTitleHint); //! Set the extension widget to be displayed when the user presses the toggle // button. void setExtensionWidget(QWidget *extension); diff --git a/MantidPlot/src/lib/include/SymbolDialog.h b/MantidPlot/src/lib/include/SymbolDialog.h index 659cc9c3095aeaa400e0d0838cb9febfcaf8218a..e8aaf0f03a1d5eee32b0004a78585b88a758b29f 100644 --- a/MantidPlot/src/lib/include/SymbolDialog.h +++ b/MantidPlot/src/lib/include/SymbolDialog.h @@ -62,7 +62,7 @@ public: * \param fl window flags */ SymbolDialog(CharSet charSet, QWidget *parent = nullptr, - Qt::WFlags fl = nullptr); + const Qt::WFlags &fl = nullptr); private: //! Show lowercase Greek characters diff --git a/MantidPlot/src/lib/src/ExtensibleFileDialog.cpp b/MantidPlot/src/lib/src/ExtensibleFileDialog.cpp index 71a0cecd62fd3e13453b87f98830a7a606cd3902..4a189d275001c051bc188c9e3c79de29d8aa8c38 100644 --- a/MantidPlot/src/lib/src/ExtensibleFileDialog.cpp +++ b/MantidPlot/src/lib/src/ExtensibleFileDialog.cpp @@ -35,7 +35,7 @@ #include <QUrl> ExtensibleFileDialog::ExtensibleFileDialog(QWidget *parent, bool extended, - Qt::WFlags flags) + const Qt::WFlags &flags) : QFileDialog(parent, flags) { d_extension = nullptr; d_extension_row = 0; diff --git a/MantidPlot/src/lib/src/SymbolDialog.cpp b/MantidPlot/src/lib/src/SymbolDialog.cpp index 812744badd640d0cb6d2dd5bc4f4207da00f64b2..3029e085474350c7d50a8846715d73ca7b0ebcce 100644 --- a/MantidPlot/src/lib/src/SymbolDialog.cpp +++ b/MantidPlot/src/lib/src/SymbolDialog.cpp @@ -38,7 +38,8 @@ #include <QSizePolicy> #include <QTextCodec> -SymbolDialog::SymbolDialog(CharSet charSet, QWidget *parent, Qt::WFlags fl) +SymbolDialog::SymbolDialog(CharSet charSet, QWidget *parent, + const Qt::WFlags &fl) : QDialog(parent, fl) { setAttribute(Qt::WA_DeleteOnClose); setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); diff --git a/MantidPlot/src/origin/OPJFile.h b/MantidPlot/src/origin/OPJFile.h index 7bbecb120a7b7ed3c88ed669759074e9f7b47644..61aa4550ec67946bfbab159c0424e003ece4aa35 100644 --- a/MantidPlot/src/origin/OPJFile.h +++ b/MantidPlot/src/origin/OPJFile.h @@ -37,6 +37,8 @@ #include "tree.hh" #include <string> +#include <utility> + #include <vector> struct rect { @@ -67,8 +69,8 @@ struct originWindow { originWindow(std::string _name = "", std::string _label = "", bool _bHidden = false) - : name(_name), label(_label), objectID(0), bHidden(_bHidden), - state(Normal), title(Both), creation_date(0.0), + : name(std::move(_name)), label(std::move(_label)), objectID(0), + bHidden(_bHidden), state(Normal), title(Both), creation_date(0.0), modification_date(0.0){}; }; struct originData { @@ -97,9 +99,10 @@ struct spreadColumn { int index; std::vector<originData> odata; spreadColumn(std::string _name = "", int _index = 0) - : name(_name), type(NONE), value_type(0), value_type_specification(0), - significant_digits(6), decimal_places(6), numeric_display_type(0), - command(""), comment(""), width(8), index(_index){}; + : name(std::move(_name)), type(NONE), value_type(0), + value_type_specification(0), significant_digits(6), decimal_places(6), + numeric_display_type(0), command(""), comment(""), width(8), + index(_index){}; }; struct spreadSheet : public originWindow { @@ -108,8 +111,8 @@ struct spreadSheet : public originWindow { bool bMultisheet; std::vector<spreadColumn> column; spreadSheet(std::string _name = "") - : originWindow(_name), maxRows(0), bLoose(true), bMultisheet(false), - column(){}; + : originWindow(std::move(_name)), maxRows(0), bLoose(true), + bMultisheet(false), column(){}; }; struct excel : public originWindow { @@ -118,8 +121,8 @@ struct excel : public originWindow { std::vector<spreadSheet> sheet; excel(std::string _name = "", std::string _label = "", int _maxRows = 0, bool _bHidden = false, bool _bLoose = true) - : originWindow(_name, _label, _bHidden), maxRows(_maxRows), - bLoose(_bLoose){}; + : originWindow(std::move(_name), std::move(_label), _bHidden), + maxRows(_maxRows), bLoose(_bLoose){}; }; struct matrix : public originWindow { @@ -139,7 +142,7 @@ struct matrix : public originWindow { HeaderViewType header; std::vector<double> data; matrix(std::string _name = "", int _index = 0) - : originWindow(_name), nr_rows(0), nr_cols(0), + : originWindow(std::move(_name)), nr_rows(0), nr_cols(0), value_type_specification(0), significant_digits(6), decimal_places(6), numeric_display_type(0), command(""), width(8), index(_index), view(DataView), header(ColumnRow){}; @@ -154,8 +157,8 @@ struct function { int points; int index; function(std::string _name = "", int _index = 0) - : name(_name), type(0), formula(""), begin(0.0), end(0.0), points(0), - index(_index){}; + : name(std::move(_name)), type(0), formula(""), begin(0.0), end(0.0), + points(0), index(_index){}; }; struct text { @@ -414,12 +417,13 @@ struct graph : public originWindow { unsigned short width; unsigned short height; - graph(std::string _name = "") : originWindow(_name), width(0), height(0){}; + graph(std::string _name = "") + : originWindow(std::move(_name)), width(0), height(0){}; }; struct note : public originWindow { std::string text; - note(std::string _name = "") : originWindow(_name){}; + note(std::string _name = "") : originWindow(std::move(_name)){}; }; struct projectNode { @@ -430,7 +434,7 @@ struct projectNode { projectNode(std::string _name = "", int _type = 0, double _creation_date = 0.0, double _modification_date = 0.0) - : type(_type), name(_name), creation_date(_creation_date), + : type(_type), name(std::move(_name)), creation_date(_creation_date), modification_date(_modification_date){}; }; diff --git a/buildconfig/CMake/CppCheckSetup.cmake b/buildconfig/CMake/CppCheckSetup.cmake index 75d183a1a1004b0dc9d44e46e89a15ab336502f8..cf1df3315898c12266a409d1cb05b766c0bf4780 100644 --- a/buildconfig/CMake/CppCheckSetup.cmake +++ b/buildconfig/CMake/CppCheckSetup.cmake @@ -1,133 +1,28 @@ find_package ( Cppcheck ) if ( CPPCHECK_EXECUTABLE ) - set ( CPPCHECK_SOURCE_DIRS - Framework - MantidPlot - qt/paraview_ext - qt/scientific_interfaces - qt/widgets/common - qt/widgets/instrumentView - qt/widgets/mplcpp - ) - option ( CPPCHECK_USE_INCLUDE_DIRS "Use specified include directories. WARNING: cppcheck will run significantly slower." ) + # We must export the compile commands for cppcheck to be able to check + # everything correctly + set(CMAKE_EXPORT_COMPILE_COMMANDS ON) - set ( CPPCHECK_INCLUDE_DIRS - Framework/Algorithms/inc - Framework/PythonInterface/inc - Framework/Nexus/inc - Framework/MPIAlgorithms/inc - Framework/MDAlgorithms/inc - Framework/DataHandling/inc - Framework/WorkflowAlgorithms/inc - Framework/MDEvents/inc - Framework/DataObjects/inc - Framework/Geometry/inc - Framework/ICat/inc - Framework/CurveFitting/inc - Framework/API/inc - Framework/TestHelpers/inc - Framework/Crystal/inc - Framework/Kernel/inc - qt/paraview_ext/VatesAPI/inc - qt/paraview_ext/VatesSimpleGui/ViewWidgets/inc - qt/paraview_ext/VatesSimpleGui/QtWidgets/inc - qt/widgets/common/inc - qt/widgets/factory/inc - qt/widgets/instrumentview/inc - qt/widgets/refdetectrview/inc - qt/widgets/sliceviewer/inc - qt/widgets/spectrumviewer/inc - qt/widgets/plugins/algorithm_dialogs/inc - qt/widgets/plugins/designer/inc - qt/scientific_interfaces - ) - - set ( CPPCHECK_EXCLUDES - Framework/LiveData/src/ISIS/DAE/ - Framework/LiveData/src/Kafka/private/Schema/ - Framework/DataHandling/src/LoadRaw/ - Framework/ICat/inc/MantidICat/ICat3/GSoapGenerated/ - Framework/ICat/src/ICat3/GSoapGenerated/ - Framework/ICat/src/ICat3/ICat3GSoapGenerated.cpp - Framework/ICat/inc/MantidICat/ICat4/GSoapGenerated/ - Framework/ICat/src/ICat4/GSoapGenerated/ - Framework/ICat/src/ICat4/ICat4GSoapGenerated.cpp - Framework/ICat/src/GSoap/ - Framework/ICat/src/GSoap.cpp - Framework/Kernel/src/ANN/ - Framework/Kernel/src/ANN_complete.cpp - Framework/Kernel/src/Math/Optimization/SLSQPMinimizer.cpp - MantidPlot/src/nrutil.cpp - MantidPlot/src/origin/OPJFile.cpp - MantidPlot/src/zlib123/minigzip.c - Framework/SINQ/src/PoldiPeakFit.cpp - qt/widgets/common/src/QtPropertyBrowser/ - qt/widgets/common/inc/MantidQtWidgets/Common/QtPropertyBrowser/ - ) - - # Header files to be ignored require different handling - set ( CPPCHECK_HEADER_EXCLUDES - Framework/LiveData/src/Kafka/private/Schema/ba57_run_info_generated.h - Framework/LiveData/src/Kafka/private/Schema/df12_det_spec_map_generated.h - Framework/LiveData/src/Kafka/private/Schema/ev42_events_generated.h - Framework/LiveData/src/Kafka/private/Schema/fwdi_forwarder_internal_generated.h - Framework/LiveData/src/Kafka/private/Schema/f142_logdata_generated.h - Framework/LiveData/src/Kafka/private/Schema/is84_isis_events_generated.h - Framework/LiveData/src/Kafka/private/Schema/flatbuffers/base.h - Framework/LiveData/src/Kafka/private/Schema/flatbuffers/flatbuffers.h - Framework/LiveData/src/Kafka/private/Schema/flatbuffers/stl_emulation.h - MantidPlot/src/origin/OPJFile.h - MantidPlot/src/origin/tree.hh - ) + configure_file(${CMAKE_SOURCE_DIR}/buildconfig/CMake/CppCheck_Suppressions.txt.in ${CMAKE_BINARY_DIR}/CppCheck_Suppressions.txt) # setup the standard arguments + set ( CPPCHECK_ARGS --enable=all --inline-suppr --max-configs=120 + --suppressions-list=${CMAKE_BINARY_DIR}/CppCheck_Suppressions.txt + --project=${CMAKE_BINARY_DIR}/compile_commands.json + # Force cppcheck to check when we use project-wide macros + -DDLLExport= + -DMANTID_ALGORITHMS_DLL= + ) + set (_cppcheck_args "${CPPCHECK_ARGS}") list ( APPEND _cppcheck_args ${CPPCHECK_TEMPLATE_ARG} ) if ( CPPCHECK_NUM_THREADS GREATER 0) list ( APPEND _cppcheck_args -j ${CPPCHECK_NUM_THREADS} ) endif ( CPPCHECK_NUM_THREADS GREATER 0) - # process list of include/exclude directories - set (_cppcheck_source_dirs) - foreach (_dir ${CPPCHECK_SOURCE_DIRS} ) - set ( _tmpdir "${CMAKE_SOURCE_DIR}/${_dir}" ) - if ( EXISTS ${_tmpdir} ) - list ( APPEND _cppcheck_source_dirs ${_tmpdir} ) - endif () - endforeach() - - set (_cppcheck_includes) - foreach( _dir ${CPPCHECK_INCLUDE_DIRS} ) - set ( _tmpdir "${CMAKE_SOURCE_DIR}/${_dir}" ) - if ( EXISTS ${_tmpdir} ) - list ( APPEND _cppcheck_includes -I ${_tmpdir} ) - endif () - endforeach() - if (CPPCHECK_USE_INCLUDE_DIRS) - list ( APPEND _cppcheck_args ${_cppcheck_includes} ) - endif (CPPCHECK_USE_INCLUDE_DIRS) - - set (_cppcheck_excludes) - foreach( _file ${CPPCHECK_EXCLUDES} ) - set ( _tmp "${CMAKE_SOURCE_DIR}/${_file}" ) - if ( EXISTS ${_tmp} ) - list ( APPEND _cppcheck_excludes -i ${_tmp} ) - endif () - endforeach() - list ( APPEND _cppcheck_args ${_cppcheck_excludes} ) - - # Handle header files in the required manner - set (_cppcheck_header_excludes) - foreach( _file ${CPPCHECK_HEADER_EXCLUDES} ) - set ( _tmp "${CMAKE_SOURCE_DIR}/${_file}" ) - if ( EXISTS ${_tmp} ) - list ( APPEND _cppcheck_header_excludes --suppress=*:${_tmp} ) - endif() - endforeach() - list ( APPEND _cppcheck_args ${_cppcheck_header_excludes} ) - # put the finishing bits on the final command call set (_cppcheck_xml_args) if (CPPCHECK_GENERATE_XML) @@ -136,10 +31,12 @@ if ( CPPCHECK_EXECUTABLE ) list( APPEND _cppcheck_xml_args ${_cppcheck_source_dirs} ) endif (CPPCHECK_GENERATE_XML) + + # generate the target if (NOT TARGET cppcheck) add_custom_target ( cppcheck - COMMAND ${CPPCHECK_EXECUTABLE} ${_cppcheck_args} ${_cppcheck_header_excludes} ${_cppcheck_xml_args} + COMMAND ${CPPCHECK_EXECUTABLE} ${_cppcheck_args} ${_cppcheck_xml_args} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} COMMENT "Running cppcheck" ) diff --git a/buildconfig/CMake/CppCheck_Suppressions.txt b/buildconfig/CMake/CppCheck_Suppressions.txt deleted file mode 100644 index 8ea3af11393379dcf667cea4c56c76b7da6ad5cd..0000000000000000000000000000000000000000 --- a/buildconfig/CMake/CppCheck_Suppressions.txt +++ /dev/null @@ -1,14 +0,0 @@ -// suppress specific rule in specific files -// NOTE this needs the full path to the file, so would need this file to be generated by cmake -// as different build servers have different starts to the file path -// Example: -// memsetClassFloat:/Users/builder/Jenkins/workspace/cppcheck-1.72/Framework/DataHandling/src/LoadRaw/isisraw.h - - -// suppress in all files - BE CAREFUL not to leave trailing spaces after the rule id. or empty lines -// For a library this is not a problem per se -// unusedFunction -// cppcheck has problems handling the number of pre-processor definitions used in the DLL_EXPORTs -class_X_Y -// the exported functions are not used in the cpp land -unusedFunction:Framework/PythonInterface/mantid/*/src/Exports/*.cpp diff --git a/buildconfig/CMake/CppCheck_Suppressions.txt.in b/buildconfig/CMake/CppCheck_Suppressions.txt.in new file mode 100644 index 0000000000000000000000000000000000000000..f60bde7ca6c07350da914bd49f6587cc984566e3 --- /dev/null +++ b/buildconfig/CMake/CppCheck_Suppressions.txt.in @@ -0,0 +1,104 @@ +// suppress specific rule in specific files +// NOTE this needs the full path to the file, so would need this file to be generated by cmake +// as different build servers have different starts to the file path + +// -------- Project Wide ------------------ + +// Hide warnings about using explicit keyword constructors as we have "too many" +// and automated clang-tidy breaks a couple of implicit conversions we use widely +noExplicitConstructor + +// Hide warnings about shadowed members for inheritance. Typically "m_log" with Algorithm +duplInheritedMember + +// We have some potentially uninitialized member vars but too many to fix at the moment +uninitMemberVar + +// Around 100 of these exist where noConstructor is present +noConstructor + +// Pre-processor Directives, such as #error, which are upstream anyway +preprocessorErrorDirective + +// ---------- cppcheck 1.90 Transition ------- +unmatchedSuppression + +// If-init not supported +syntaxError:${CMAKE_SOURCE_DIR}/Framework/API/src/MatrixWorkspace.cpp + +// --- To be added back ------ +//cstyleCase:*${CMAKE_SOURCE_DIR}/MantidPlot + +// A large number of copying instead of pass by ref were picked up by clang-tidy, but around 200 remain +//passedByValue + +// Cppcheck struggles with some inheritance chains, some of these might be true though +//unusedPrivateFunction + +// Nice to have, not need to have at the moment +//useInitializationList + +// Libs we have in-source +// *:${CMAKE_SOURCE_DIR}/Framework/DataObjects/inc/MantidDataObjects/MortonIndex/* + +// ---------- Individual suppressions ----------------- + +// Mantid Plot specific ones we probably won't fix before removal + +*:${CMAKE_SOURCE_DIR}/MantidPlot/src/origin/tree.hh +*:${CMAKE_SOURCE_DIR}/MantidPlot/src/nrutil.cpp + +pureVirtualCall:${CMAKE_SOURCE_DIR}/qt/scientific_interfaces/Indirect/IndirectBayesTab.cpp +pureVirtualCall:${CMAKE_SOURCE_DIR}/qt/scientific_interfaces/Indirect/IndirectBayesTab.h + +// Macro expansion means this is incorrectly flagged on Unix +redundantAssignment:${CMAKE_SOURCE_DIR}/Framework/DataHandling/src/LoadRaw/isisraw.cpp + +// Ref binding means Cppcheck can't see these are used +unreadVariable:${CMAKE_SOURCE_DIR}/Framework/Algorithms/src/MaskBinsIf.cpp + +// --------- Missing copy assignment / constructors ------------------- +// We don't want more creeping in so just mark these one by one + +copyCtorAndEqOperator:${CMAKE_SOURCE_DIR}/Framework/API/inc/MantidAPI/BoxController.h +copyCtorAndEqOperator:${CMAKE_SOURCE_DIR}/Framework/API/inc/MantidAPI/ExperimentInfo.h +copyCtorAndEqOperator:${CMAKE_SOURCE_DIR}/Framework/API/inc/MantidAPI/IFunction.h +copyCtorAndEqOperator:${CMAKE_SOURCE_DIR}/Framework/API/inc/MantidAPI/MDGeometry.h +copyCtorAndEqOperator:${CMAKE_SOURCE_DIR}/Framework/API/inc/MantidAPI/MultipleExperimentInfos.h +copyCtorAndEqOperator:${CMAKE_SOURCE_DIR}/Framework/API/inc/MantidAPI/SingleValueParameter.h +copyCtorAndEqOperator:${CMAKE_SOURCE_DIR}/Framework/API/inc/MantidAPI/VectorParameter.h + +copyCtorAndEqOperator:${CMAKE_SOURCE_DIR}/Framework/Catalog/inc/MantidCatalog/ONCat.h +copyCtorAndEqOperator:${CMAKE_SOURCE_DIR}/Framework/Catalog/inc/MantidCatalog/ONCatEntity.h + +copyCtorAndEqOperator:${CMAKE_SOURCE_DIR}/Framework/Crystal/inc/MantidCrystal/IndexSXPeaks.h +copyCtorAndEqOperator:${CMAKE_SOURCE_DIR}/Framework/Crystal/inc/MantidCrystal/IntegratePeakTimeSlices.h + +copyCtorAndEqOperator:${CMAKE_SOURCE_DIR}/Framework/Geometry/inc/MantidGeometry/Instrument/CompAssembly.h +copyCtorAndEqOperator:${CMAKE_SOURCE_DIR}/Framework/Geometry/inc/MantidGeometry/Instrument/Container.h +copyCtorAndEqOperator:${CMAKE_SOURCE_DIR}/Framework/Geometry/inc/MantidGeometry/Instrument/ObjCompAssembly.h +copyCtorAndEqOperator:${CMAKE_SOURCE_DIR}/Framework/Geometry/inc/MantidGeometry/Rendering/GeometryHandler.h + +copyCtorAndEqOperator:${CMAKE_SOURCE_DIR}/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Qwt/QwtWorkspaceBinData.h +copyCtorAndEqOperator:${CMAKE_SOURCE_DIR}/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Qwt/QwtWorkspaceSpectrumData.h + +noCopyConstructor:${CMAKE_SOURCE_DIR}/Framework/DataHandling/inc/MantidDataHandling/BankPulseTimes.h +noCopyConstructor:${CMAKE_SOURCE_DIR}/Framework/DataHandling/src/LoadRaw/isisraw.h +noCopyConstructor:${CMAKE_SOURCE_DIR}/Framework/Geometry/inc/MantidGeometry/Rendering/vtkGeometryCacheWriter.h + +// ----------------- Upstream libs --------------- + +// Always ignore bin dir +*:*${CMAKE_BINARY_DIR}/* + +// For some reason upstream libs sometimes end up in the check results +*:*/usr/include/* + +// All ANN files as they are upstream anyway +*:*${CMAKE_SOURCE_DIR}/Framework/Kernel/src/ANN/* + +// Libs we have in-source +*:${CMAKE_SOURCE_DIR}/Framework/ICat/src/GSoap/* +*:${CMAKE_SOURCE_DIR}/Framework/ICat/src/ICat3/GSoapGenerated/* +*:${CMAKE_SOURCE_DIR}/Framework/ICat/src/ICat4/GSoapGenerated/* +*:${CMAKE_SOURCE_DIR}/MantidPlot/src/zlib123/* diff --git a/buildconfig/CMake/FindCppcheck.cmake b/buildconfig/CMake/FindCppcheck.cmake index fad22793cb0533a477cdb92d454e4c8e37c9ece9..89bb0b88ec5e512df5d147450bf3893b278e7cf0 100644 --- a/buildconfig/CMake/FindCppcheck.cmake +++ b/buildconfig/CMake/FindCppcheck.cmake @@ -61,15 +61,6 @@ if(CPPCHECK_EXECUTABLE) endif() mark_as_advanced(CPPCHECK_EXECUTABLE) -if(CPPCHECK_EXECUTABLE) - if (${CPPCHECK_VERSION} VERSION_LESS 1.71) - set ( CPPCHECK_ARGS --enable=all --inline-suppr --max-configs=120 - --suppressions ${CMAKE_CURRENT_SOURCE_DIR}/buildconfig/CMake/CppCheck_Suppressions.txt ) - else() - set ( CPPCHECK_ARGS --enable=all --inline-suppr --max-configs=120 - --suppressions-list=${CMAKE_CURRENT_SOURCE_DIR}/buildconfig/CMake/CppCheck_Suppressions.txt ) - endif() -endif() set ( CPPCHECK_NUM_THREADS 0 CACHE STRING "Number of threads to use when running cppcheck" ) set ( CPPCHECK_GENERATE_XML OFF CACHE BOOL "Generate xml output files from cppcheck" ) diff --git a/buildconfig/CMake/FindCxxTest.cmake b/buildconfig/CMake/FindCxxTest.cmake index d88bbdd42c8bd0c64aa8d148be3f74148e8b2e68..ffb3dad5f08348f62abea9cbf66b1bae3e16beb0 100644 --- a/buildconfig/CMake/FindCxxTest.cmake +++ b/buildconfig/CMake/FindCxxTest.cmake @@ -180,26 +180,43 @@ macro(CXXTEST_ADD_TEST _cxxtest_testname) add_test ( NAME ${_cxxtest_separate_name} COMMAND ${CMAKE_COMMAND} -E chdir "${CMAKE_BINARY_DIR}/bin/Testing" $<TARGET_FILE:${_cxxtest_testname}> ${_suitename} ) - set_tests_properties ( ${_cxxtest_separate_name} PROPERTIES - TIMEOUT ${TESTING_TIMEOUT} ) - if (CXXTEST_ADD_PERFORMANCE) - # ------ Performance test version ------- - # Name of the possibly-existing Performance test suite - set( _performance_suite_name "${_suitename}Performance" ) - # Read the contents of the header file - FILE( READ ${part} _file_contents ) - # Is that suite defined in there at all? - STRING(REGEX MATCH ${_performance_suite_name} _search_res ${_file_contents} ) - if (NOT "${_search_res}" STREQUAL "") - set( _cxxtest_separate_name "${_cxxtest_testname}_${_performance_suite_name}") - add_test ( NAME ${_cxxtest_separate_name} - COMMAND ${CMAKE_COMMAND} -E chdir "${CMAKE_BINARY_DIR}/bin/Testing" - $<TARGET_FILE:${_cxxtest_testname}> ${_performance_suite_name} ) set_tests_properties ( ${_cxxtest_separate_name} PROPERTIES TIMEOUT ${TESTING_TIMEOUT} ) - endif () - endif () + + if (CXXTEST_ADD_PERFORMANCE) + # ------ Performance test version ------- + # Name of the possibly-existing Performance test suite + set( _performance_suite_name "${_suitename}Performance" ) + # Read the contents of the header file + FILE( READ ${part} _file_contents ) + # Is that suite defined in there at all? + STRING(REGEX MATCH ${_performance_suite_name} _search_res ${_file_contents} ) + if (NOT "${_search_res}" STREQUAL "") + set( _cxxtest_separate_name "${_cxxtest_testname}_${_performance_suite_name}") + add_test ( NAME ${_cxxtest_separate_name} + COMMAND ${CMAKE_COMMAND} -E chdir "${CMAKE_BINARY_DIR}/bin/Testing" + $<TARGET_FILE:${_cxxtest_testname}> ${_performance_suite_name} ) + set_tests_properties ( ${_cxxtest_separate_name} PROPERTIES + TIMEOUT ${TESTING_TIMEOUT} ) + endif () + endif () + + set( SUPPRESSIONS_DIR "${CMAKE_SOURCE_DIR}/tools/Sanitizer" ) + if ( USE_SANITIZERS_LOWER STREQUAL "address" ) + # See dev docs on sanitizers for details on why verify_asan_link is false + # Trying to quote these options causes the quotation to be forwarded + set(_ASAN_OPTS "suppressions=${SUPPRESSIONS_DIR}/Address.supp:detect_stack_use_after_return=true") + set_property( TEST ${_cxxtest_separate_name} APPEND PROPERTY + ENVIRONMENT ASAN_OPTIONS=${_ASAN_OPTS} ) + + set( _LSAN_OPTS "suppressions=${SUPPRESSIONS_DIR}/Leak.supp" ) + set_property( TEST ${_cxxtest_separate_name} APPEND PROPERTY + ENVIRONMENT LSAN_OPTIONS=${_LSAN_OPTS} ) + + endif() + + endforeach ( part ${ARGN} ) endmacro(CXXTEST_ADD_TEST) diff --git a/buildconfig/CMake/GNUSetup.cmake b/buildconfig/CMake/GNUSetup.cmake index a129359016f7638690fb3151163728a3066d8fd1..6fbf75cc72463dfdd66c5b771be881331951a6e2 100644 --- a/buildconfig/CMake/GNUSetup.cmake +++ b/buildconfig/CMake/GNUSetup.cmake @@ -72,39 +72,6 @@ endif() # Add some options for debug build to help the Zoom profiler add_compile_options ( $<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:-fno-omit-frame-pointer> ) -option(WITH_ASAN "Enable address sanitizer" OFF) -if(WITH_ASAN) - message(STATUS "enabling address sanitizer") - add_compile_options(-fno-omit-frame-pointer -fno-common -fsanitize=address) - set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -fsanitize=address" ) - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address") - set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fsanitize=address") -endif() - -option(WITH_TSAN "Enable thread sanitizer" OFF) -if(WITH_TSAN) - message(STATUS "enabling thread sanitizer") - add_compile_options(-fno-omit-frame-pointer -fno-common -fsanitize=thread) - set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -fsanitize=thread" ) - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=thread") - set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fsanitize=thread") -endif() - -option(WITH_UBSAN "Enable undefined behavior sanitizer" OFF) -if(WITH_UBSAN) - message(STATUS "enabling undefined behavior sanitizers") - set( UBSAN_NO_RECOVER "-fno-sanitize-recover") - if ( CMAKE_COMPILER_IS_GNUCXX AND GCC_COMPILER_VERSION VERSION_LESS "5.1.0") - set( UBSAN_NO_RECOVER "") - endif() - # vptr check is generating a lot of false positives, hiding other more serious warnings. - set(SAN_FLAGS "-fno-omit-frame-pointer -fno-common -fsanitize=undefined -fno-sanitize=vptr ${UBSAN_NO_RECOVER}") - add_compile_options(-fno-omit-frame-pointer -fno-common -fsanitize=undefined -fno-sanitize=vptr ${UBSAN_NO_RECOVER}) - set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${SAN_FLAGS}" ) - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${SAN_FLAGS}" ) - set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${SAN_FLAGS}" ) -endif() - # XCode isn't picking up the c++ standard by CMAKE_CXX_STANDARD if(CMAKE_GENERATOR STREQUAL Xcode) set ( CMAKE_XCODE_ATTRIBUTE_OTHER_CPLUSPLUSFLAGS "${GNUFLAGS} -Woverloaded-virtual -fno-operator-names") diff --git a/buildconfig/CMake/Sanitizers.cmake b/buildconfig/CMake/Sanitizers.cmake new file mode 100644 index 0000000000000000000000000000000000000000..4e8c29a8e274edb188102534cc753a2b8ced9ba1 --- /dev/null +++ b/buildconfig/CMake/Sanitizers.cmake @@ -0,0 +1,62 @@ +################################################# +# Controls various project wide sanitizer options +################################################# + +set(USE_SANITIZER "Off" CACHE STRING "Sanitizer mode to enable") +set_property(CACHE USE_SANITIZER PROPERTY STRINGS + Off Address Thread Undefined) + +string(TOLOWER "${USE_SANITIZER}" USE_SANITIZERS_LOWER) + +if(NOT ${USE_SANITIZERS_LOWER} MATCHES "off") + # Check we have a supported compiler + if(WIN32) + message(FATAL_ERROR "Windows does not support sanitizers") + endif() + + if(CMAKE_COMPILER_IS_GNUCXX AND (NOT CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 8)) + message(FATAL_ERROR "GCC 7 and below do not support sanitizers") + endif() + + # Check and warn if we are not in a mode without debug symbols + string(TOLOWER "${CMAKE_BUILD_TYPE}" build_type_lower) + if("${build_type_lower}" MATCHES "release" OR "${build_type_lower}" MATCHES "minsizerel" ) + message(WARNING "You are running address sanitizers without debug information, try RelWithDebInfo") + + elseif(${build_type_lower} MATCHES "relwithdebinfo") + # RelWithDebug runs with -o2 which performs inlining reducing the usefulness + message("Replacing -O2 flag with -O1 to preserve stack trace on sanitizers") + string(REPLACE "-O2" "-O1" CMAKE_CXX_FLAGS_RELWITHDEBINFO ${CMAKE_CXX_FLAGS_RELWITHDEBINFO}) + string(REPLACE "-O2" "-O1" CMAKE_C_FLAGS_RELWITHDEBINFO ${CMAKE_C_FLAGS_RELWITHDEBINFO}) + + set(CMAKE_CXX_FLAGS_RELWITHDEBINFO ${CMAKE_CXX_FLAGS_RELWITHDEBINFO} CACHE STRING "" FORCE) + set(CMAKE_C_FLAGS_RELWITHDEBINFO ${CMAKE_C_FLAGS_RELWITHDEBINFO} CACHE STRING "" FORCE) + + add_compile_options(-fno-omit-frame-pointer -fno-optimize-sibling-calls) + endif() +endif() + +# Allow all instrumented code to continue beyond the first error +add_compile_options($<$<NOT:$<STREQUAL:$<LOWER_CASE:"${USE_SANITIZER}">,"off">>:-fsanitize-recover=all>) + +# Address +add_compile_options( + $<$<STREQUAL:$<LOWER_CASE:"${USE_SANITIZER}">,"address">:-fsanitize=address>) +add_link_options( + $<$<STREQUAL:$<LOWER_CASE:"${USE_SANITIZER}">,"address">:-fsanitize=address>) + +# Thread +add_compile_options( + $<$<STREQUAL:$<LOWER_CASE:"${USE_SANITIZER}">,"thread">:-fsanitize=thread>) +add_link_options( + $<$<STREQUAL:$<LOWER_CASE:"${USE_SANITIZER}">,"thread">:-fsanitize=thread>) + +# Undefined +# RTTI information is not exported for some classes causing the +# linker to fail whilst adding vptr instrumentation +add_compile_options( + $<$<STREQUAL:$<LOWER_CASE:"${USE_SANITIZER}">,"undefined">:-fsanitize=undefined> + $<$<STREQUAL:$<LOWER_CASE:"${USE_SANITIZER}">,"undefined">:-fno-sanitize=vptr>) + +add_link_options( + $<$<STREQUAL:$<LOWER_CASE:"${USE_SANITIZER}">,"undefined">:-fsanitize=undefined>) diff --git a/buildconfig/CMake/Span.cmake b/buildconfig/CMake/Span.cmake index e5020d24c8a67de0ef3853c2c29156f146f05b36..426d1880d95ec859b5d6bf0838d574cf9b236721 100644 --- a/buildconfig/CMake/Span.cmake +++ b/buildconfig/CMake/Span.cmake @@ -9,8 +9,8 @@ FetchContent_Declare( span GIT_REPOSITORY https://github.com/tcbrindle/span.git GIT_TAG 08cb4bf0e06c0e36f7e2b64e488ede711a8bb5ad - PATCH_COMMAND ${GIT_EXECUTABLE} reset --hard ${_tag} - COMMAND ${GIT_EXECUTABLE} apply ${_apply_flags} ${CMAKE_SOURCE_DIR}/buildconfig/CMake/span_disable_testing.patch + PATCH_COMMAND "${GIT_EXECUTABLE}" reset --hard ${_tag} + COMMAND "${GIT_EXECUTABLE}" apply ${_apply_flags} "${CMAKE_SOURCE_DIR}/buildconfig/CMake/span_disable_testing.patch" ) FetchContent_GetProperties(span) diff --git a/buildconfig/Jenkins/buildscript b/buildconfig/Jenkins/buildscript index 796f2625dbfcf069da8a71aebfc54bb3e867f3fd..09c68128ccb0427feba51de0de1acc7146f79fe1 100755 --- a/buildconfig/Jenkins/buildscript +++ b/buildconfig/Jenkins/buildscript @@ -9,6 +9,9 @@ # corresponds to any labels set on a slave. BUILD_THREADS & # PARAVIEW_DIR should be set in the configuration of each slave. ############################################################################### +# Set all string comparisons to case insensitive (i.e. Release == release) +shopt -s nocasematch + SCRIPT_DIR=$(dirname "$0") XVFB_SERVER_NUM=101 ULIMIT_CORE_ORIG=$(ulimit -c) @@ -61,6 +64,14 @@ if [[ ${NODE_LABELS} == *rhel7* ]] || [[ ${NODE_LABELS} == *centos7* ]] || [[ ${ USE_CORE_DUMPS=false fi +# Setup software collections on rhel7 to allow using gcc7 +if [[ $ON_RHEL7 ]]; then + SCL_ENABLE="scl enable devtoolset-7" +else + SCL_ENABLE="eval" +fi + + ############################################################################### # Script cleanup ############################################################################### @@ -100,10 +111,7 @@ $CMAKE_EXE --version ############################################################################### # Check job requirements from the name and changes ############################################################################### -if [[ ${JOB_NAME} == *clean* ]]; then - CLEANBUILD=true -fi -if [[ ${JOB_NAME} == *clang_tidy* ]]; then +if [[ ${JOB_NAME} == *clean* || ${JOB_NAME} == *clang_tidy* ]]; then CLEANBUILD=true fi @@ -146,6 +154,7 @@ DO_DOCTESTS_USER=true DO_BUILD_DEVDOCS=true DO_BUILD_PKG=true DO_SYSTEMTESTS=false + if [[ ${PRBUILD} == true ]]; then if ${SCRIPT_DIR}/check_for_changes dev-docs-only || ${SCRIPT_DIR}/check_for_changes user-docs-only; then DO_BUILD_CODE=false @@ -157,7 +166,7 @@ if [[ ${PRBUILD} == true ]]; then DO_SYSTEMTESTS=false if [[ ${ON_RHEL7} == true ]]; then - # rhel does system testing + # rhel does system testing if there are any non-doc or gui changes if ! ${SCRIPT_DIR}/check_for_changes docs-gui-only; then if [[ ${PY3_BUILD} == true ]]; then DO_BUILD_PKG=true @@ -196,15 +205,16 @@ fi if [[ "$CLEANBUILD" == true ]]; then rm -rf $BUILD_DIR fi -if [ -d $BUILD_DIR ]; then - rm -rf ${BUILD_DIR:?}/bin ${BUILD_DIR:?}/ExternalData ${BUILD_DIR:?}/Testing - find ${BUILD_DIR:?} -name 'TEST-*.xml' -delete - if [[ -n ${CLEAN_EXTERNAL_PROJECTS} && "${CLEAN_EXTERNAL_PROJECTS}" == true ]]; then - rm -rf $BUILD_DIR/eigen-* - rm -rf $BUILD_DIR/googletest-* - fi -else - mkdir $BUILD_DIR + +mkdir -p $BUILD_DIR + +# Tidy build dir +rm -rf ${BUILD_DIR:?}/bin ${BUILD_DIR:?}/ExternalData ${BUILD_DIR:?}/Testing +find ${BUILD_DIR:?} -name 'TEST-*.xml' -delete + +if [[ -n ${CLEAN_EXTERNAL_PROJECTS} && "${CLEAN_EXTERNAL_PROJECTS}" == true ]]; then + rm -rf $BUILD_DIR/eigen-* + rm -rf $BUILD_DIR/googletest-* fi ############################################################################### @@ -298,6 +308,27 @@ if [[ ${DO_BUILD_PKG} == true ]]; then fi fi +############################################################################### +# Figure out if were doing a sanitizer build and setup any steps we need +############################################################################### + +if [[ ${JOB_NAME} == *address* ]]; then + SANITIZER_FLAGS="-DUSE_SANITIZER=Address" + +elif [[ ${JOB_NAME} == *memory* ]]; then + SANITIZER_FLAGS="-DUSE_SANITIZER=memory" + +elif [[ ${JOB_NAME} == *thread* ]]; then + SANITIZER_FLAGS="-DUSE_SANITIZER=thread" + +elif [[ ${JOB_NAME} == *undefined* ]]; then + SANITIZER_FLAGS="-DUSE_SANITIZER=undefined" +fi + +if [[ -n "${SANITIZER_FLAGS}" ]]; then + # Force build to RelWithDebInfo + BUILD_CONFIG="RelWithDebInfo" +fi ############################################################################### # Generator @@ -307,6 +338,7 @@ if [ "$(command -v ninja)" ]; then elif [ "$(command -v ninja-build)" ]; then CMAKE_GENERATOR="-G Ninja" fi + if [ -e $BUILD_DIR/CMakeCache.txt ]; then CMAKE_GENERATOR="" fi @@ -325,7 +357,7 @@ rm -f -- *.dmg *.rpm *.deb *.tar.gz *.tar.xz ############################################################################### # CMake configuration ############################################################################### -$SCL_ENABLE "${CMAKE_EXE} ${CMAKE_GENERATOR} -DCMAKE_BUILD_TYPE=${BUILD_CONFIG} -DENABLE_CPACK=ON -DMAKE_VATES=ON -DParaView_DIR=${PARAVIEW_DIR} -DMANTID_DATA_STORE=${MANTID_DATA_STORE} -DDOCS_HTML=ON -DENABLE_CONDA=ON -DCOLORED_COMPILER_OUTPUT=OFF ${DIST_FLAGS} ${PACKAGINGVARS} ${CLANGTIDYVAR} .." +$SCL_ENABLE "${CMAKE_EXE} ${CMAKE_GENERATOR} -DCMAKE_BUILD_TYPE=${BUILD_CONFIG} -DENABLE_CPACK=ON -DMAKE_VATES=ON -DParaView_DIR=${PARAVIEW_DIR} -DMANTID_DATA_STORE=${MANTID_DATA_STORE} -DDOCS_HTML=ON -DENABLE_CONDA=ON -DCOLORED_COMPILER_OUTPUT=OFF ${DIST_FLAGS} ${PACKAGINGVARS} ${CLANGTIDYVAR} ${SANITIZER_FLAGS} .." ############################################################################### # Coverity build should exit early @@ -360,7 +392,6 @@ if [[ $USE_CLANG ]] && [[ ${JOB_NAME} == *clang_tidy* ]]; then exit 0 fi - ############################################################################### # Run the unit tests ############################################################################### diff --git a/dev-docs/source/RunningSanitizers.rst b/dev-docs/source/RunningSanitizers.rst new file mode 100644 index 0000000000000000000000000000000000000000..b3d916c0f6d1d898d8cb3c8c6b2430c08ef5d472 --- /dev/null +++ b/dev-docs/source/RunningSanitizers.rst @@ -0,0 +1,155 @@ +.. _RunningSanitizers: + +################## +Running Sanitizers +################## + +.. contents:: + :local: + +Overview +========= + +Sanitizers allow developers to find any issues with their code at runtime +related to memory, threading or undefined behaviour. + +Pre-requisites +============== + +The following tooling is required: + +- GCC-8 onwards +- Clang 3.2 onwards + + +Switching to Sanitizer Build +============================ + +The following sanitizers modes are available: + +- Address +- Thread +- Undefined + +It's recommended to build in *RelWithDebInfo* mode, CMake will automatically +switch to -O1 and append extra flags for stack traces to work correctly whilst +preserving high performance + +If required, a build can be completed in debug mode too, however the +performance penalty will be pretty severe. + +Command Line +------------ + +First, delete *CMakeCache.txt* if your system compiler is GCC 7 or below +(you can check with *gcc -v*). + +To change to a sanitized build navigate to your build folder and execute the +following: + + .. code-block:: sh + + cmake *path_to_src* -DUSE_SANITIZER=*Mode* -DCMAKE_BUILD_TYPE=RelWithDebInfo + +If you need to specify a different compiler too (for example if your system +default is GCC-7) + + .. code-block:: sh + + CC=gcc-8 CXX=g++-8 cmake *path_to_src* -DUSE_SANITIZER=*Mode* -DCMAKE_BUILD_TYPE=RelWithDebInfo + + +For example, to switch to an address sanitizer build the following can be used: + + .. code-block:: sh + + cmake *path_to_src* -DUSE_SANITIZER=Address -DCMAKE_BUILD_TYPE=RelWithDebInfo + +CMake GUI +--------- + +- Delete the cache if your system compiler is GCC 7 or below (you can check + with *gcc -v*). Hit configure and click specify native compilers to *gcc-8* + and *g++-8* +- Change *CMAKE_BUILD_TYPE* to *RelWithDebInfo* (or *Debug*) +- Change *USE_SANITIZERS* to any of the options in the drop down +- Hit generate and rebuild the project + +Running Tests +============= + +Several upstream linked libraries currently contain leaks which we cannot +resolve (or have been resolved but not appeared downstream). + +We can suppress warnings in the address sanitizer by setting environment +variables in the console before running in each mode. + +Advanced Details +================ + +Most developers do not need to read this, but it's good for those who +want to know what's happening + +CMake substitutes in various flags for the address sanitizer builds to +setup suppressions etc... this is the equivalent of doing the following +in a local shell: + + .. code-block:: sh + + export ASAN_OPTIONS="verify_asan_link_order=0:detect_stack_use_after_return=true:halt_on_error=false:suppressions=*path_to_mantid*/tools/Sanitizer/Address.supp" + export LSAN_OPTIONS="suppressions=*path_to_mantid*/tools/Sanitizer/Leak.supp" + +All code executed which is executed in that shell will now be sanitized +correctly. To save developers effort the CXX_ADD_TEST macro (in +FindCxxTest.cmake) will append these environment variables on a developers +behalf. + +Instrumenting Python (Advanced) +------------------------------- + +Currently any code started in Python (i.e. Python Unit Tests) will not pre-load +ASAN instrumentation. This can be split into two categories: + +- Code which uses Python only components: Not worth instrumenting as any + issues will be upstream. This also will emit an error if + *verify_asan_link_order* is set to true, as we technically haven't + instrumented anything (unless you have a sanitized Python build) +- Code which uses Mantid C++ components: This can be instrumented, but + (currently) isn't by default, as the user has to determine the *LD_PRELOAD* + path. + +If you need / want to profile C++ components which are triggered from Python +the following steps should setup your environment: + + .. code-block:: sh + + # Get the path to your linked ASAN + ldd bin/KernelTest | grep "libasan" + export LD_PRELOAD=/usr/lib/path_to/libasan.so.x + + # You may want to re-run the ASAN_OPTIONS export dropping + # the verify to make sure that the C++ component is being instrumented: + + export ASAN_OPTIONS="detect_stack_use_after_return=true:halt_on_error=false:suppressions=*path_to_mantid*/buildconfig/Sanitizer/Address.supp" + + +Common Problems +=============== + +Library Leaks Appearing +----------------------- + +Check that you have correctly spelt *suppressions* as there will be no warnings +for typos. A good check is to put some random characters in the .supp files, +which will cause all tests to fail if it's begin read. + +Any new third party memory leaks need to go into *Leaks.supp* not +*Address.supp* (which should ideally be completely empty) to be suppressed. + +ASAN was not the first library loaded +-------------------------------------- + +This can appear when running Python tests, as the executable is not build +with instrumentation. To avoid this warning ensure that +*verify_asan_link_order=0* is set in your environment and that you are +using GCC 8 onwards. diff --git a/dev-docs/source/index.rst b/dev-docs/source/index.rst index 1bd00d7980ca5ab63883dee9915a444f07e9565c..dde789db23843c5db47545dd4c2e6ec30ef5b283 100644 --- a/dev-docs/source/index.rst +++ b/dev-docs/source/index.rst @@ -155,6 +155,7 @@ Testing SystemTests DataFilesForTesting TestingUtilities + RunningSanitizers :doc:`RunningTheUnitTests` Details on how to run the suite of unit tests. @@ -180,6 +181,9 @@ Testing :doc:`TestingUtilities` Helper utlities used for testing. +:doc:`RunningSanitizers` + How to run the various sanitizers locally. + =============== GUI Development =============== diff --git a/docs/source/release/v5.1.0/diffraction.rst b/docs/source/release/v5.1.0/diffraction.rst index 6a86de8a8e6c03acb1590156efefb2db30928069..954c18bc6991e108c15ba1f58a9aba19c3e71379 100644 --- a/docs/source/release/v5.1.0/diffraction.rst +++ b/docs/source/release/v5.1.0/diffraction.rst @@ -12,6 +12,8 @@ Diffraction Changes Powder Diffraction ------------------ +- Polaris.create_total_scattering_pdf output workspaces now have the run number in the names. + Engineering Diffraction ----------------------- Improvements diff --git a/qt/icons/inc/MantidQtIcons/CharIconEngine.h b/qt/icons/inc/MantidQtIcons/CharIconEngine.h index efd7962da46b73eb4e628d6cb06138a56c844cfc..9002cae11d94b2657863db43d35e8e084eb42bca 100644 --- a/qt/icons/inc/MantidQtIcons/CharIconEngine.h +++ b/qt/icons/inc/MantidQtIcons/CharIconEngine.h @@ -35,7 +35,7 @@ class CharIconPainter; class EXPORT_OPT_MANTIDQT_ICONS CharIconEngine : public QIconEngine { public: CharIconEngine(IconicFont *iconic, CharIconPainter *painter, - QList<QHash<QString, QVariant>> options); + const QList<QHash<QString, QVariant>> &options); void paint(QPainter *painter, const QRect &rect, QIcon::Mode mode, QIcon::State state) override; QPixmap pixmap(const QSize &size, QIcon::Mode mode, diff --git a/qt/icons/src/CharIconEngine.cpp b/qt/icons/src/CharIconEngine.cpp index adbd38b437a23cd4c07c4a970b2cc41b10455c49..40fa6670bfd65967150016fd6a4ce60f2e7ebf6d 100644 --- a/qt/icons/src/CharIconEngine.cpp +++ b/qt/icons/src/CharIconEngine.cpp @@ -4,6 +4,8 @@ // NScD Oak Ridge National Laboratory, European Spallation Source, // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + +#include <utility> + #include "MantidQtIcons/CharIconEngine.h" #include "MantidQtIcons/CharIconPainter.h" @@ -11,8 +13,8 @@ namespace MantidQt { namespace Icons { CharIconEngine::CharIconEngine(IconicFont *iconic, CharIconPainter *painter, - QList<QHash<QString, QVariant>> options) - : m_iconic(iconic), m_painter(painter), m_options(options) {} + const QList<QHash<QString, QVariant>> &options) + : m_iconic(iconic), m_painter(painter), m_options(std::move(options)) {} void CharIconEngine::paint(QPainter *painter, const QRect &rect, QIcon::Mode mode, QIcon::State state) { diff --git a/qt/icons/src/Icon.cpp b/qt/icons/src/Icon.cpp index 1ef2f925b6834412bb92576805faa16ed151269b..0bc0293ad1274649f01df25aa05b2bc192f96db2 100644 --- a/qt/icons/src/Icon.cpp +++ b/qt/icons/src/Icon.cpp @@ -31,7 +31,7 @@ MantidQt::Icons::IconicFont &iconFontInstance() { // https://stackoverflow.com/questions/4169988/easiest-way-to-parse-json-in-qt-4-7 // specifically in the answer by user2243820 on April 4th 2013 at 8:10 -QHash<QString, QVariant> decodeInner(QScriptValue object) { +QHash<QString, QVariant> decodeInner(const QScriptValue &object) { QHash<QString, QVariant> map; QScriptValueIterator it(object); while (it.hasNext()) { diff --git a/qt/scientific_interfaces/Direct/ALFCustomInstrumentView.cpp b/qt/scientific_interfaces/Direct/ALFCustomInstrumentView.cpp index 5481fdba6195771225d6ba1300c3e17a2d8dbe40..916da8260701fbd5b9086ad92dd11ade90128e2e 100644 --- a/qt/scientific_interfaces/Direct/ALFCustomInstrumentView.cpp +++ b/qt/scientific_interfaces/Direct/ALFCustomInstrumentView.cpp @@ -11,6 +11,7 @@ #include <QSizePolicy> #include <QSpacerItem> #include <QVBoxLayout> +#include <utility> namespace MantidQt { namespace CustomInterfaces { @@ -90,8 +91,8 @@ void ALFCustomInstrumentView::setupAnalysisPane( BaseCustomInstrumentView::setupInstrumentAnalysisSplitters(analysis); } -void ALFCustomInstrumentView::addSpectrum(std::string wsName) { - m_analysisPane->addSpectrum(wsName); +void ALFCustomInstrumentView::addSpectrum(const std::string &wsName) { + m_analysisPane->addSpectrum(std::move(wsName)); } } // namespace CustomInterfaces diff --git a/qt/scientific_interfaces/Direct/ALFCustomInstrumentView.h b/qt/scientific_interfaces/Direct/ALFCustomInstrumentView.h index 99d71e6ef74d6667a34f0865de816ede92f36f2d..5eec9fbc802e664671758c069f15304491dbd7f6 100644 --- a/qt/scientific_interfaces/Direct/ALFCustomInstrumentView.h +++ b/qt/scientific_interfaces/Direct/ALFCustomInstrumentView.h @@ -35,7 +35,7 @@ public: &binders) override; void addObserver(std::tuple<std::string, Observer *> &listener) override; - void addSpectrum(std::string wsName); + void addSpectrum(const std::string &wsName); void setupAnalysisPane(MantidWidgets::PlotFitAnalysisPaneView *analysis); public slots: diff --git a/qt/scientific_interfaces/DynamicPDF/DPDFFitControl.cpp b/qt/scientific_interfaces/DynamicPDF/DPDFFitControl.cpp index b381d9a24b91fafb1554fc52b395f10d38b77689..6a49d01388e049238a031193f19f921f99203099 100644 --- a/qt/scientific_interfaces/DynamicPDF/DPDFFitControl.cpp +++ b/qt/scientific_interfaces/DynamicPDF/DPDFFitControl.cpp @@ -23,6 +23,7 @@ #include <QPushButton> #include <QSettings> #include <QSignalMapper> +#include <utility> namespace { Mantid::Kernel::Logger g_log("DynamicPDF"); @@ -312,7 +313,7 @@ void FitControl::fitIndividual(const bool &isEvaluation) { * @param fun A function from which to retrieve the parameters */ void FitControl::updateFunctionBrowser(Mantid::API::IFunction_sptr fun) { - m_functionBrowser->setFunction(fun); + m_functionBrowser->setFunction(std::move(fun)); } /* diff --git a/qt/scientific_interfaces/EnggDiffraction/EnggDiffFittingModel.cpp b/qt/scientific_interfaces/EnggDiffraction/EnggDiffFittingModel.cpp new file mode 100644 index 0000000000000000000000000000000000000000..24e3c22e00b125f8f7f52e95655bfb4b0c4d851a --- /dev/null +++ b/qt/scientific_interfaces/EnggDiffraction/EnggDiffFittingModel.cpp @@ -0,0 +1,609 @@ +// Mantid Repository : https://github.com/mantidproject/mantid +// +// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI, +// NScD Oak Ridge National Laboratory, European Spallation Source +// & Institut Laue - Langevin +// SPDX - License - Identifier: GPL - 3.0 + +#include "EnggDiffFittingModel.h" + +#include "MantidAPI/AlgorithmManager.h" +#include "MantidAPI/AnalysisDataService.h" +#include "MantidAPI/ITableWorkspace_fwd.h" +#include "MantidAPI/MatrixWorkspace.h" +#include "MantidAPI/Run.h" +#include "MantidAPI/TableRow.h" +#include "MantidAPI/WorkspaceFactory.h" +#include "MantidAPI/WorkspaceGroup.h" +#include "MantidKernel/PropertyWithValue.h" + +#include <algorithm> +#include <numeric> + +using namespace Mantid; + +namespace { // helpers + +bool isDigit(const std::string &text) { + return std::all_of(text.cbegin(), text.cend(), ::isdigit); +} + +} // anonymous namespace + +namespace MantidQt { +namespace CustomInterfaces { + +void EnggDiffFittingModel::addFocusedWorkspace( + const RunLabel &runLabel, const API::MatrixWorkspace_sptr &ws, + const std::string &filename) { + m_focusedWorkspaceMap.add(runLabel, ws); + m_wsFilenameMap.add(runLabel, filename); +} + +void EnggDiffFittingModel::addFitResults( + const RunLabel &runLabel, const Mantid::API::ITableWorkspace_sptr &ws) { + m_fitParamsMap.add(runLabel, ws); +} + +const std::string & +EnggDiffFittingModel::getWorkspaceFilename(const RunLabel &runLabel) const { + return m_wsFilenameMap.get(runLabel); +} + +Mantid::API::ITableWorkspace_sptr +EnggDiffFittingModel::getFitResults(const RunLabel &runLabel) const { + return m_fitParamsMap.get(runLabel); +} + +namespace { + +template <size_t S, typename T> +void removeFromRunMapAndADS(const RunLabel &runLabel, RunMap<S, T> &map, + Mantid::API::AnalysisDataServiceImpl &ADS) { + if (map.contains(runLabel)) { + const auto &name = map.get(runLabel)->getName(); + if (ADS.doesExist(name)) { + ADS.remove(name); + } + map.remove(runLabel); + } +} + +} // anonymous namespace + +void EnggDiffFittingModel::removeRun(const RunLabel &runLabel) { + m_wsFilenameMap.remove(runLabel); + + auto &ADS = Mantid::API::AnalysisDataService::Instance(); + removeFromRunMapAndADS(runLabel, m_focusedWorkspaceMap, ADS); + removeFromRunMapAndADS(runLabel, m_fittedPeaksMap, ADS); + removeFromRunMapAndADS(runLabel, m_alignedWorkspaceMap, ADS); + removeFromRunMapAndADS(runLabel, m_fitParamsMap, ADS); +} + +void EnggDiffFittingModel::setDifcTzero( + const RunLabel &runLabel, + const std::vector<GSASCalibrationParms> &calibParams) { + auto ws = getFocusedWorkspace(runLabel); + auto &run = ws->mutableRun(); + const std::string units = "none"; + + if (calibParams.empty()) { + run.addProperty<double>("difc", DEFAULT_DIFC, units, true); + run.addProperty<double>("difa", DEFAULT_DIFA, units, true); + run.addProperty<double>("tzero", DEFAULT_TZERO, units, true); + } else { + GSASCalibrationParms params(0, 0.0, 0.0, 0.0); + const auto found = std::find_if(calibParams.cbegin(), calibParams.cend(), + [&runLabel](const auto ¶mSet) { + return paramSet.bankid == runLabel.bank; + }); + if (found != calibParams.cend()) { + params = *found; + } + if (params.difc == 0) { + params = calibParams.front(); + } + + run.addProperty<double>("difc", params.difc, units, true); + run.addProperty<double>("difa", params.difa, units, false); + run.addProperty<double>("tzero", params.tzero, units, false); + } +} + +void EnggDiffFittingModel::enggFitPeaks(const RunLabel &runLabel, + const std::string &expectedPeaks) { + const auto ws = getFocusedWorkspace(runLabel); + auto enggFitPeaksAlg = + Mantid::API::AlgorithmManager::Instance().create("EnggFitPeaks"); + + enggFitPeaksAlg->initialize(); + enggFitPeaksAlg->setProperty("InputWorkspace", ws); + if (!expectedPeaks.empty()) { + enggFitPeaksAlg->setProperty("ExpectedPeaks", expectedPeaks); + } + enggFitPeaksAlg->setProperty("FittedPeaks", FIT_RESULTS_TABLE_NAME); + enggFitPeaksAlg->execute(); + + API::AnalysisDataServiceImpl &ADS = API::AnalysisDataService::Instance(); + const auto fitResultsTable = + ADS.retrieveWS<API::ITableWorkspace>(FIT_RESULTS_TABLE_NAME); + addFitResults(runLabel, fitResultsTable); +} + +void EnggDiffFittingModel::saveFitResultsToHDF5( + const std::vector<RunLabel> &runLabels, const std::string &filename) const { + std::vector<std::string> inputWorkspaces; + inputWorkspaces.reserve(runLabels.size()); + std::vector<std::string> runNumbers; + runNumbers.reserve(runLabels.size()); + std::vector<long> bankIDs; + bankIDs.reserve(runLabels.size()); + + for (const auto &runLabel : runLabels) { + const auto ws = getFitResults(runLabel); + const auto clonedWSName = "enggggui_fit_params_" + runLabel.runNumber + + "_" + std::to_string(runLabel.bank); + cloneWorkspace(ws, clonedWSName); + inputWorkspaces.emplace_back(clonedWSName); + runNumbers.emplace_back(runLabel.runNumber); + bankIDs.emplace_back(static_cast<long>(runLabel.bank)); + } + + auto saveAlg = Mantid::API::AlgorithmManager::Instance().create( + "EnggSaveSinglePeakFitResultsToHDF5"); + saveAlg->initialize(); + saveAlg->setProperty("InputWorkspaces", inputWorkspaces); + saveAlg->setProperty("RunNumbers", runNumbers); + saveAlg->setProperty("BankIDs", bankIDs); + saveAlg->setProperty("Filename", filename); + saveAlg->execute(); + + auto &ADS = API::AnalysisDataService::Instance(); + for (const auto &wsName : inputWorkspaces) { + ADS.remove(wsName); + } +} + +void EnggDiffFittingModel::createFittedPeaksWS(const RunLabel &runLabel) { + const auto fitFunctionParams = getFitResults(runLabel); + const auto focusedWS = getFocusedWorkspace(runLabel); + + const size_t numberOfPeaks = fitFunctionParams->rowCount(); + + for (size_t i = 0; i < numberOfPeaks; ++i) { + const auto functionDescription = createFunctionString(fitFunctionParams, i); + double startX, endX; + std::tie(startX, endX) = getStartAndEndXFromFitParams(fitFunctionParams, i); + + const std::string singlePeakWSName = + "__engggui_fitting_single_peak_" + std::to_string(i); + + evaluateFunction(functionDescription, focusedWS, singlePeakWSName, startX, + endX); + + cropWorkspace(singlePeakWSName, singlePeakWSName, 1, 1); + + rebinToFocusedWorkspace(singlePeakWSName, runLabel, singlePeakWSName); + + if (i == 0) { + cloneWorkspace(focusedWS, FITTED_PEAKS_WS_NAME); + setDataToClonedWS(singlePeakWSName, FITTED_PEAKS_WS_NAME); + } else { + const std::string clonedWSName = + "__engggui_cloned_peaks_" + std::to_string(i); + cloneWorkspace(focusedWS, clonedWSName); + setDataToClonedWS(singlePeakWSName, clonedWSName); + + appendSpectra(FITTED_PEAKS_WS_NAME, clonedWSName); + } + } + + const std::string alignedWSName = FOCUSED_WS_NAME + "_d"; + cloneWorkspace(focusedWS, alignedWSName); + alignDetectors(alignedWSName, alignedWSName); + + alignDetectors(FITTED_PEAKS_WS_NAME, FITTED_PEAKS_WS_NAME); + + const auto &ADS = Mantid::API::AnalysisDataService::Instance(); + + const auto fittedPeaksWS = + ADS.retrieveWS<Mantid::API::MatrixWorkspace>(FITTED_PEAKS_WS_NAME); + m_fittedPeaksMap.add(runLabel, fittedPeaksWS); + + const auto alignedFocusedWS = + ADS.retrieveWS<Mantid::API::MatrixWorkspace>(alignedWSName); + m_alignedWorkspaceMap.add(runLabel, alignedFocusedWS); +} + +size_t EnggDiffFittingModel::getNumFocusedWorkspaces() const { + return m_focusedWorkspaceMap.size(); +} + +bool EnggDiffFittingModel::hasFittedPeaksForRun( + const RunLabel &runLabel) const { + return m_fittedPeaksMap.contains(runLabel); +} + +Mantid::API::MatrixWorkspace_sptr +EnggDiffFittingModel::getAlignedWorkspace(const RunLabel &runLabel) const { + return m_alignedWorkspaceMap.get(runLabel); +} + +Mantid::API::MatrixWorkspace_sptr +EnggDiffFittingModel::getFittedPeaksWS(const RunLabel &runLabel) const { + return m_fittedPeaksMap.get(runLabel); +} + +void EnggDiffFittingModel::evaluateFunction( + const std::string &function, + const Mantid::API::MatrixWorkspace_sptr &inputWS, + const std::string &outputWSName, const double startX, const double endX) { + + auto evalFunctionAlg = + Mantid::API::AlgorithmManager::Instance().create("EvaluateFunction"); + evalFunctionAlg->initialize(); + evalFunctionAlg->setProperty("Function", function); + evalFunctionAlg->setProperty("InputWorkspace", inputWS); + evalFunctionAlg->setProperty("OutputWorkspace", outputWSName); + evalFunctionAlg->setProperty("StartX", startX); + evalFunctionAlg->setProperty("EndX", endX); + evalFunctionAlg->execute(); +} + +void EnggDiffFittingModel::cropWorkspace(const std::string &inputWSName, + const std::string &outputWSName, + const int startWSIndex, + const int endWSIndex) { + auto cropWSAlg = + Mantid::API::AlgorithmManager::Instance().create("CropWorkspace"); + cropWSAlg->initialize(); + cropWSAlg->setProperty("InputWorkspace", inputWSName); + cropWSAlg->setProperty("OutputWorkspace", outputWSName); + cropWSAlg->setProperty("StartWorkspaceIndex", startWSIndex); + cropWSAlg->setProperty("EndWorkspaceIndex", endWSIndex); + cropWSAlg->execute(); +} + +void EnggDiffFittingModel::rebinToFocusedWorkspace( + const std::string &wsToRebinName, const RunLabel &runLabelToMatch, + const std::string &outputWSName) { + auto rebinToWSAlg = + Mantid::API::AlgorithmManager::Instance().create("RebinToWorkspace"); + + rebinToWSAlg->initialize(); + rebinToWSAlg->setProperty("WorkspaceToRebin", wsToRebinName); + + const auto wsToMatch = getFocusedWorkspace(runLabelToMatch); + rebinToWSAlg->setProperty("WorkspaceToMatch", wsToMatch); + rebinToWSAlg->setProperty("OutputWorkspace", outputWSName); + rebinToWSAlg->execute(); +} + +void EnggDiffFittingModel::cloneWorkspace( + const Mantid::API::MatrixWorkspace_sptr &inputWorkspace, + const std::string &outputWSName) const { + auto cloneWSAlg = + Mantid::API::AlgorithmManager::Instance().create("CloneWorkspace"); + cloneWSAlg->initialize(); + cloneWSAlg->setProperty("InputWorkspace", inputWorkspace); + cloneWSAlg->setProperty("OutputWorkspace", outputWSName); + cloneWSAlg->execute(); +} + +void EnggDiffFittingModel::cloneWorkspace( + const Mantid::API::ITableWorkspace_sptr &inputWorkspace, + const std::string &outputWSName) const { + auto cloneWSAlg = + Mantid::API::AlgorithmManager::Instance().create("CloneWorkspace"); + cloneWSAlg->initialize(); + cloneWSAlg->setProperty("InputWorkspace", inputWorkspace); + cloneWSAlg->setProperty("OutputWorkspace", outputWSName); + cloneWSAlg->execute(); +} + +void EnggDiffFittingModel::setDataToClonedWS(const std::string &wsToCopyName, + const std::string &targetWSName) { + auto &ADS = Mantid::API::AnalysisDataService::Instance(); + auto wsToCopy = ADS.retrieveWS<Mantid::API::MatrixWorkspace>(wsToCopyName); + auto currentClonedWS = + ADS.retrieveWS<Mantid::API::MatrixWorkspace>(targetWSName); + currentClonedWS->mutableY(0) = wsToCopy->y(0); + currentClonedWS->mutableE(0) = wsToCopy->e(0); +} + +void EnggDiffFittingModel::appendSpectra(const std::string &ws1Name, + const std::string &ws2Name) const { + auto appendSpectraAlg = + Mantid::API::AlgorithmManager::Instance().create("AppendSpectra"); + + appendSpectraAlg->initialize(); + appendSpectraAlg->setProperty("InputWorkspace1", ws1Name); + appendSpectraAlg->setProperty("InputWorkspace2", ws2Name); + appendSpectraAlg->setProperty("OutputWorkspace", ws1Name); + appendSpectraAlg->execute(); +} + +std::tuple<double, double, double> EnggDiffFittingModel::getDifcDifaTzero( + const Mantid::API::MatrixWorkspace_const_sptr &ws) { + const auto run = ws->run(); + + const auto difc = run.getPropertyValueAsType<double>("difc"); + const auto difa = run.getPropertyValueAsType<double>("difa"); + const auto tzero = run.getPropertyValueAsType<double>("tzero"); + + return std::tuple<double, double, double>(difc, difa, tzero); +} + +Mantid::API::ITableWorkspace_sptr +EnggDiffFittingModel::createCalibrationParamsTable( + const Mantid::API::MatrixWorkspace_const_sptr &inputWS) { + double difc, difa, tzero; + std::tie(difc, difa, tzero) = getDifcDifaTzero(inputWS); + + auto calibrationParamsTable = + Mantid::API::WorkspaceFactory::Instance().createTable(); + + calibrationParamsTable->addColumn("int", "detid"); + calibrationParamsTable->addColumn("double", "difc"); + calibrationParamsTable->addColumn("double", "difa"); + calibrationParamsTable->addColumn("double", "tzero"); + + Mantid::API::TableRow row = calibrationParamsTable->appendRow(); + const auto &spectrum = inputWS->getSpectrum(0); + + Mantid::detid_t detID = *(spectrum.getDetectorIDs().cbegin()); + row << detID << difc << difa << tzero; + return calibrationParamsTable; +} + +void EnggDiffFittingModel::convertFromDistribution( + const Mantid::API::MatrixWorkspace_sptr &inputWS) { + auto convertFromDistAlg = Mantid::API::AlgorithmManager::Instance().create( + "ConvertFromDistribution"); + convertFromDistAlg->initialize(); + convertFromDistAlg->setProperty("Workspace", inputWS); + convertFromDistAlg->execute(); +} + +void EnggDiffFittingModel::alignDetectors(const std::string &inputWSName, + const std::string &outputWSName) { + const auto &ADS = Mantid::API::AnalysisDataService::Instance(); + const auto inputWS = + ADS.retrieveWS<Mantid::API::MatrixWorkspace>(inputWSName); + alignDetectors(inputWS, outputWSName); +} + +void EnggDiffFittingModel::alignDetectors( + const Mantid::API::MatrixWorkspace_sptr &inputWS, + const std::string &outputWSName) { + const auto calibrationParamsTable = createCalibrationParamsTable(inputWS); + + if (inputWS->isDistribution()) { + convertFromDistribution(inputWS); + } + + auto alignDetAlg = + Mantid::API::AlgorithmManager::Instance().create("AlignDetectors"); + alignDetAlg->initialize(); + alignDetAlg->setProperty("InputWorkspace", inputWS); + alignDetAlg->setProperty("OutputWorkspace", outputWSName); + alignDetAlg->setProperty("CalibrationWorkspace", calibrationParamsTable); + alignDetAlg->execute(); +} + +void EnggDiffFittingModel::loadWorkspace(const std::string &filename, + const std::string &wsName) { + auto loadAlg = API::AlgorithmManager::Instance().create("Load"); + loadAlg->setProperty("Filename", filename); + loadAlg->setProperty("OutputWorkspace", wsName); + loadAlg->execute(); +} + +void EnggDiffFittingModel::renameWorkspace(const API::Workspace_sptr &inputWS, + const std::string &newName) const { + auto renameAlg = API::AlgorithmManager::Instance().create("RenameWorkspace"); + renameAlg->setProperty("InputWorkspace", inputWS); + renameAlg->setProperty("OutputWorkspace", newName); + renameAlg->execute(); +} + +void EnggDiffFittingModel::groupWorkspaces( + const std::vector<std::string> &workspaceNames, + const std::string &outputWSName) { + auto groupAlg = API::AlgorithmManager::Instance().create("GroupWorkspaces"); + groupAlg->setProperty("InputWorkspaces", workspaceNames); + groupAlg->setProperty("OutputWorkspace", outputWSName); + groupAlg->execute(); +} + +API::MatrixWorkspace_sptr +EnggDiffFittingModel::getFocusedWorkspace(const RunLabel &runLabel) const { + return m_focusedWorkspaceMap.get(runLabel); +} + +void EnggDiffFittingModel::mergeTables( + const API::ITableWorkspace_sptr &tableToCopy, + const API::ITableWorkspace_sptr &targetTable) const { + for (size_t i = 0; i < tableToCopy->rowCount(); ++i) { + API::TableRow rowToCopy = tableToCopy->getRow(i); + API::TableRow newRow = targetTable->appendRow(); + + for (size_t j = 0; j < tableToCopy->columnCount(); ++j) { + double valueToCopy; + rowToCopy >> valueToCopy; + newRow << valueToCopy; + } + } +} + +void EnggDiffFittingModel::addAllFitResultsToADS() const { + auto fitParamsTable = Mantid::API::WorkspaceFactory::Instance().createTable(); + renameWorkspace(fitParamsTable, FIT_RESULTS_TABLE_NAME); + + const auto runLabels = getRunLabels(); + + for (const auto &runLabel : runLabels) { + const auto singleWSFitResults = getFitResults(runLabel); + + if (runLabel == *runLabels.begin()) { + // First element - copy column headings over + const auto columnHeaders = singleWSFitResults->getColumnNames(); + for (const auto &header : columnHeaders) { + fitParamsTable->addColumn("double", header); + } + } + mergeTables(singleWSFitResults, fitParamsTable); + } +} + +void EnggDiffFittingModel::addAllFittedPeaksToADS() const { + const auto runLabels = getRunLabels(); + if (runLabels.size() < 1) { + return; + } + const auto firstWSLabel = runLabels[0]; + auto fittedPeaksWS = getFittedPeaksWS(firstWSLabel); + cloneWorkspace(fittedPeaksWS, FITTED_PEAKS_WS_NAME); + + for (size_t i = 1; i < runLabels.size(); ++i) { + auto wsToAppend = getFittedPeaksWS(runLabels[i]); + appendSpectra(FITTED_PEAKS_WS_NAME, wsToAppend->getName()); + } +} + +namespace { + +std::string stripWSNameFromFilename(const std::string &fullyQualifiedFilename) { + std::vector<std::string> directories; + boost::split(directories, fullyQualifiedFilename, boost::is_any_of("\\/")); + const std::string filename = directories.back(); + std::vector<std::string> filenameSegments; + boost::split(filenameSegments, filename, boost::is_any_of(".")); + return filenameSegments[0]; +} +} // namespace + +void EnggDiffFittingModel::loadWorkspaces(const std::string &filenamesString) { + std::vector<std::string> filenames; + boost::split(filenames, filenamesString, boost::is_any_of(",")); + + std::vector<RunLabel> collectedRunLabels; + + for (const auto &filename : filenames) { + // Set ws name to filename first, in case we need to guess bank ID from it + const std::string temporaryWSName = stripWSNameFromFilename(filename); + loadWorkspace(filename, temporaryWSName); + + API::AnalysisDataServiceImpl &ADS = API::AnalysisDataService::Instance(); + auto ws_test = ADS.retrieveWS<API::Workspace>(temporaryWSName); + const auto ws = boost::dynamic_pointer_cast<API::MatrixWorkspace>(ws_test); + if (!ws) { + throw std::invalid_argument("Workspace is not a matrix workspace."); + } + const auto bank = guessBankID(ws); + const auto runNumber = std::to_string(ws->getRunNumber()); + RunLabel runLabel(runNumber, bank); + + addFocusedWorkspace(runLabel, ws, filename); + collectedRunLabels.emplace_back(runLabel); + } + + if (collectedRunLabels.size() == 1) { + auto ws = getFocusedWorkspace(collectedRunLabels[0]); + renameWorkspace(ws, FOCUSED_WS_NAME); + } else { + std::vector<std::string> workspaceNames; + std::transform(collectedRunLabels.begin(), collectedRunLabels.end(), + std::back_inserter(workspaceNames), + [&](const RunLabel &runLabel) { + return getFocusedWorkspace(runLabel)->getName(); + }); + groupWorkspaces(workspaceNames, FOCUSED_WS_NAME); + } +} + +std::vector<RunLabel> EnggDiffFittingModel::getRunLabels() const { + return m_focusedWorkspaceMap.getRunLabels(); +} + +size_t EnggDiffFittingModel::guessBankID( + const API::MatrixWorkspace_const_sptr &ws) const { + const static std::string bankIDName = "bankid"; + if (ws->run().hasProperty(bankIDName)) { + const auto log = dynamic_cast<Kernel::PropertyWithValue<int> *>( + ws->run().getLogData(bankIDName)); + return boost::lexical_cast<size_t>(log->value()); + } + + // couldn't get it from sample logs - try using the old naming convention + const std::string name = ws->getName(); + std::vector<std::string> chunks; + boost::split(chunks, name, boost::is_any_of("_")); + if (!chunks.empty()) { + const bool isNum = isDigit(chunks.back()); + if (isNum) { + try { + return boost::lexical_cast<size_t>(chunks.back()); + } catch (boost::exception &) { + // If we get a bad cast or something goes wrong then + // the file is probably not what we were expecting + // so throw a runtime error + throw std::runtime_error( + "Failed to fit file: The data was not what is expected. " + "Does the file contain a focused workspace?"); + } + } + } + + throw std::runtime_error("Could not guess run number from input workspace. " + "Are you sure it has been focused correctly?"); +} + +std::string EnggDiffFittingModel::createFunctionString( + const Mantid::API::ITableWorkspace_sptr &fitFunctionParams, + const size_t row) { + const auto A0 = fitFunctionParams->cell<double>(row, size_t(1)); + const auto A1 = fitFunctionParams->cell<double>(row, size_t(3)); + const auto I = fitFunctionParams->cell<double>(row, size_t(13)); + const auto A = fitFunctionParams->cell<double>(row, size_t(7)); + const auto B = fitFunctionParams->cell<double>(row, size_t(9)); + const auto X0 = fitFunctionParams->cell<double>(row, size_t(5)); + const auto S = fitFunctionParams->cell<double>(row, size_t(11)); + + const std::string function = + "name=LinearBackground,A0=" + boost::lexical_cast<std::string>(A0) + + ",A1=" + boost::lexical_cast<std::string>(A1) + + ";name=BackToBackExponential,I=" + boost::lexical_cast<std::string>(I) + + ",A=" + boost::lexical_cast<std::string>(A) + + ",B=" + boost::lexical_cast<std::string>(B) + + ",X0=" + boost::lexical_cast<std::string>(X0) + + ",S=" + boost::lexical_cast<std::string>(S); + return function; +} + +std::pair<double, double> EnggDiffFittingModel::getStartAndEndXFromFitParams( + const Mantid::API::ITableWorkspace_sptr &fitFunctionParams, + const size_t row) { + const auto X0 = fitFunctionParams->cell<double>(row, size_t(5)); + const auto S = fitFunctionParams->cell<double>(row, size_t(11)); + const double windowLeft = 9; + const double windowRight = 12; + + const auto startX = X0 - (windowLeft * S); + const auto endX = X0 + (windowRight * S); + return std::pair<double, double>(startX, endX); +} + +const std::string EnggDiffFittingModel::FOCUSED_WS_NAME = + "engggui_fitting_focused_ws"; +const std::string EnggDiffFittingModel::FIT_RESULTS_TABLE_NAME = + "engggui_fitting_fitpeaks_params"; +const std::string EnggDiffFittingModel::FITTED_PEAKS_WS_NAME = + "engggui_fitting_single_peaks"; + +const double EnggDiffFittingModel::DEFAULT_DIFA = 0.0; +const double EnggDiffFittingModel::DEFAULT_DIFC = 18400.0; +const double EnggDiffFittingModel::DEFAULT_TZERO = 4.0; + +} // namespace CustomInterfaces +} // namespace MantidQt diff --git a/qt/scientific_interfaces/EnggDiffraction/EnggDiffFittingModel.h b/qt/scientific_interfaces/EnggDiffraction/EnggDiffFittingModel.h new file mode 100644 index 0000000000000000000000000000000000000000..73d8b5f3f80d9d65cf007234cc493891c71183fb --- /dev/null +++ b/qt/scientific_interfaces/EnggDiffraction/EnggDiffFittingModel.h @@ -0,0 +1,152 @@ +// Mantid Repository : https://github.com/mantidproject/mantid +// +// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI, +// NScD Oak Ridge National Laboratory, European Spallation Source +// & Institut Laue - Langevin +// SPDX - License - Identifier: GPL - 3.0 + +#pragma once + +#include "DllConfig.h" +#include "IEnggDiffFittingModel.h" +#include "IEnggDiffractionCalibration.h" +#include "RunMap.h" + +#include <array> +#include <unordered_map> + +namespace MantidQt { +namespace CustomInterfaces { + +class MANTIDQT_ENGGDIFFRACTION_DLL EnggDiffFittingModel + : public IEnggDiffFittingModel { + +public: + Mantid::API::MatrixWorkspace_sptr + getFocusedWorkspace(const RunLabel &runLabel) const override; + + Mantid::API::MatrixWorkspace_sptr + getAlignedWorkspace(const RunLabel &runLabel) const override; + + Mantid::API::MatrixWorkspace_sptr + getFittedPeaksWS(const RunLabel &runLabel) const override; + + Mantid::API::ITableWorkspace_sptr + getFitResults(const RunLabel &runLabel) const override; + + const std::string & + getWorkspaceFilename(const RunLabel &runLabel) const override; + + void removeRun(const RunLabel &runLabel) override; + + void loadWorkspaces(const std::string &filenames) override; + + std::vector<RunLabel> getRunLabels() const override; + + void + setDifcTzero(const RunLabel &runLabel, + const std::vector<GSASCalibrationParms> &calibParams) override; + + void enggFitPeaks(const RunLabel &runLabel, + const std::string &expectedPeaks) override; + + void saveFitResultsToHDF5(const std::vector<RunLabel> &runLabels, + const std::string &filename) const override; + + void createFittedPeaksWS(const RunLabel &runLabel) override; + + size_t getNumFocusedWorkspaces() const override; + + void addAllFitResultsToADS() const override; + + void addAllFittedPeaksToADS() const override; + + bool hasFittedPeaksForRun(const RunLabel &runLabel) const override; + +protected: + void addFocusedWorkspace(const RunLabel &runLabel, + const Mantid::API::MatrixWorkspace_sptr &ws, + const std::string &filename); + + void addFitResults(const RunLabel &runLabel, + const Mantid::API::ITableWorkspace_sptr &ws); + + void mergeTables(const Mantid::API::ITableWorkspace_sptr &tableToCopy, + const Mantid::API::ITableWorkspace_sptr &targetTable) const; + +private: + static const size_t MAX_BANKS = 3; + static const double DEFAULT_DIFC; + static const double DEFAULT_DIFA; + static const double DEFAULT_TZERO; + static const std::string FOCUSED_WS_NAME; + static const std::string FIT_RESULTS_TABLE_NAME; + static const std::string FITTED_PEAKS_WS_NAME; + + RunMap<MAX_BANKS, Mantid::API::MatrixWorkspace_sptr> m_focusedWorkspaceMap; + RunMap<MAX_BANKS, std::string> m_wsFilenameMap; + RunMap<MAX_BANKS, Mantid::API::ITableWorkspace_sptr> m_fitParamsMap; + RunMap<MAX_BANKS, Mantid::API::MatrixWorkspace_sptr> m_fittedPeaksMap; + RunMap<MAX_BANKS, Mantid::API::MatrixWorkspace_sptr> m_alignedWorkspaceMap; + + std::string createFunctionString( + const Mantid::API::ITableWorkspace_sptr &fitFunctionParams, + const size_t row); + + std::pair<double, double> getStartAndEndXFromFitParams( + const Mantid::API::ITableWorkspace_sptr &fitFunctionParams, + const size_t row); + + void evaluateFunction(const std::string &function, + const Mantid::API::MatrixWorkspace_sptr &inputWS, + const std::string &outputWSName, const double startX, + const double endX); + + void cropWorkspace(const std::string &inputWSName, + const std::string &outputWSName, const int startWSIndex, + const int endWSIndex); + + void rebinToFocusedWorkspace(const std::string &wsToRebinName, + const RunLabel &runLabelToMatch, + const std::string &outputWSName); + + void cloneWorkspace(const Mantid::API::MatrixWorkspace_sptr &inputWorkspace, + const std::string &outputWSName) const; + + void cloneWorkspace(const Mantid::API::ITableWorkspace_sptr &inputWorkspace, + const std::string &outputWSName) const; + + void setDataToClonedWS(const std::string &wsToCopyName, + const std::string &targetWSName); + + void appendSpectra(const std::string &ws1Name, + const std::string &ws2Name) const; + + std::tuple<double, double, double> + getDifcDifaTzero(const Mantid::API::MatrixWorkspace_const_sptr &ws); + + Mantid::API::ITableWorkspace_sptr createCalibrationParamsTable( + const Mantid::API::MatrixWorkspace_const_sptr &inputWS); + + void + convertFromDistribution(const Mantid::API::MatrixWorkspace_sptr &inputWS); + + void alignDetectors(const std::string &inputWSName, + const std::string &outputWSName); + + void alignDetectors(const Mantid::API::MatrixWorkspace_sptr &inputWS, + const std::string &outputWSName); + + void loadWorkspace(const std::string &filename, const std::string &wsName); + + void renameWorkspace(const Mantid::API::Workspace_sptr &inputWS, + const std::string &newName) const; + + void groupWorkspaces(const std::vector<std::string> &workspaceNames, + const std::string &outputWSName); + + size_t + guessBankID(const Mantid::API::MatrixWorkspace_const_sptr & /*ws*/) const; +}; + +} // namespace CustomInterfaces +} // namespace MantidQt diff --git a/qt/scientific_interfaces/EnggDiffraction/EnggDiffFittingPresenter.cpp b/qt/scientific_interfaces/EnggDiffraction/EnggDiffFittingPresenter.cpp new file mode 100644 index 0000000000000000000000000000000000000000..6d24969f6b5a156fce07f4723efaa2a0e042fd85 --- /dev/null +++ b/qt/scientific_interfaces/EnggDiffraction/EnggDiffFittingPresenter.cpp @@ -0,0 +1,745 @@ +// Mantid Repository : https://github.com/mantidproject/mantid +// +// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI, +// NScD Oak Ridge National Laboratory, European Spallation Source +// & Institut Laue - Langevin +// SPDX - License - Identifier: GPL - 3.0 + +#include "EnggDiffFittingPresenter.h" +#include "EnggDiffFittingPresWorker.h" +#include "IEnggDiffFittingModel.h" +#include "MantidAPI/Algorithm.h" +#include "MantidAPI/Axis.h" +#include "MantidAPI/MatrixWorkspace.h" +#include "MantidAPI/Run.h" +#include "MantidAPI/WorkspaceFactory.h" +#include "MantidQtWidgets/Plotting/Qwt/QwtHelper.h" + +#include <boost/algorithm/string.hpp> +#include <boost/lexical_cast.hpp> +#include <cctype> +#include <fstream> +#include <utility> + +#include <Poco/DirectoryIterator.h> +#include <Poco/File.h> + +using namespace Mantid::API; +using namespace MantidQt::CustomInterfaces; + +namespace MantidQt { +namespace QwtHelper = API::QwtHelper; +namespace CustomInterfaces { + +namespace { +Mantid::Kernel::Logger g_log("EngineeringDiffractionGUI"); + +RunLabel runLabelFromListWidgetLabel(const std::string &listLabel) { + const size_t underscorePosition = listLabel.find_first_of("_"); + const auto runNumber = listLabel.substr(0, underscorePosition); + const auto bank = listLabel.substr(underscorePosition + 1); + + return RunLabel(runNumber, std::atoi(bank.c_str())); +} + +std::string listWidgetLabelFromRunLabel(const RunLabel &runLabel) { + return runLabel.runNumber + "_" + std::to_string(runLabel.bank); +} + +// Remove commas at the start and end of the string, +// as well as any adjacent to another (eg ,, gets corrected to ,) +std::string stripExtraCommas(std::string &expectedPeaks) { + if (!expectedPeaks.empty()) { + + g_log.debug() << "Validating the expected peak list.\n"; + + const auto comma = ','; + + for (size_t i = 0; i < expectedPeaks.size() - 1; i++) { + size_t j = i + 1; + + if (expectedPeaks[i] == comma && expectedPeaks[i] == expectedPeaks[j]) { + expectedPeaks.erase(j, 1); + i--; + + } else { + ++j; + } + } + + size_t strLength = expectedPeaks.length() - 1; + if (expectedPeaks.at(0) == ',') { + expectedPeaks.erase(0, 1); + strLength -= 1; + } + + if (expectedPeaks.at(strLength) == ',') { + expectedPeaks.erase(strLength, 1); + } + } + return expectedPeaks; +} + +std::string generateXAxisLabel(const Mantid::Kernel::Unit_const_sptr &unit) { + std::string label = unit->unitID(); + if (label == "TOF") { + label += " (us)"; + } else if (label == "dSpacing") { + label += " (A)"; + } + return label; +} +} // namespace + +/** + * Constructs a presenter for a fitting tab/widget view, which has a + * handle on the current calibration (produced and updated elsewhere). + * + * @param view the view that is attached to this presenter + * @param model the model that is attached to this presenter + * @param mainCalib provides the current calibration parameters/status + * @param mainParam provides current params and functions + */ +EnggDiffFittingPresenter::EnggDiffFittingPresenter( + IEnggDiffFittingView *view, std::unique_ptr<IEnggDiffFittingModel> model, + boost::shared_ptr<IEnggDiffractionCalibration> mainCalib, + boost::shared_ptr<IEnggDiffractionParam> mainParam) + : m_fittingFinishedOK(false), m_workerThread(nullptr), + m_mainCalib(std::move(mainCalib)), m_mainParam(std::move(mainParam)), + m_view(view), m_model(std::move(model)), m_viewHasClosed(false) {} + +EnggDiffFittingPresenter::~EnggDiffFittingPresenter() { cleanup(); } + +/** + * Close open sessions, kill threads etc., for a graceful window + * close/destruction + */ +void EnggDiffFittingPresenter::cleanup() { + // m_model->cleanup(); + + // this may still be running + if (m_workerThread) { + if (m_workerThread->isRunning()) { + g_log.notice() << "A fitting process is currently running, shutting " + "it down immediately...\n"; + m_workerThread->wait(10); + } + delete m_workerThread; + m_workerThread = nullptr; + } +} + +void EnggDiffFittingPresenter::notify( + IEnggDiffFittingPresenter::Notification notif) { + + // Check the view is valid - QT can send multiple notification + // signals in any order at any time. This means that it is possible + // to receive a shutdown signal and subsequently an input example + // for example. As we can't guarantee the state of the viewer + // after calling shutdown instead we shouldn't do anything after + if (m_viewHasClosed) { + return; + } + + switch (notif) { + + case IEnggDiffFittingPresenter::Start: + processStart(); + break; + + case IEnggDiffFittingPresenter::Load: + processLoad(); + break; + + case IEnggDiffFittingPresenter::FitPeaks: + processFitPeaks(); + break; + + case IEnggDiffFittingPresenter::FitAllPeaks: + processFitAllPeaks(); + break; + + case IEnggDiffFittingPresenter::addPeaks: + addPeakToList(); + break; + + case IEnggDiffFittingPresenter::browsePeaks: + browsePeaksToFit(); + break; + + case IEnggDiffFittingPresenter::savePeaks: + savePeakList(); + break; + + case IEnggDiffFittingPresenter::ShutDown: + processShutDown(); + break; + + case IEnggDiffFittingPresenter::LogMsg: + processLogMsg(); + break; + + case IEnggDiffFittingPresenter::selectRun: + processSelectRun(); + break; + + case IEnggDiffFittingPresenter::updatePlotFittedPeaks: + processUpdatePlotFitPeaks(); + break; + + case IEnggDiffFittingPresenter::removeRun: + processRemoveRun(); + break; + } +} + +std::vector<GSASCalibrationParms> +EnggDiffFittingPresenter::currentCalibration() const { + return m_mainCalib->currentCalibration(); +} + +Poco::Path +EnggDiffFittingPresenter::outFilesUserDir(const std::string &addToDir) const { + return m_mainParam->outFilesUserDir(addToDir); +} + +std::string EnggDiffFittingPresenter::userHDFRunFilename( + const std::string &runNumber) const { + return m_mainParam->userHDFRunFilename(runNumber); +} + +std::string EnggDiffFittingPresenter::userHDFMultiRunFilename( + const std::vector<RunLabel> &runLabels) const { + return m_mainParam->userHDFMultiRunFilename(runLabels); +} + +void EnggDiffFittingPresenter::startAsyncFittingWorker( + const std::vector<RunLabel> &runLabels, const std::string &expectedPeaks) { + + delete m_workerThread; + m_workerThread = new QThread(this); + EnggDiffFittingWorker *worker = + new EnggDiffFittingWorker(this, runLabels, expectedPeaks); + worker->moveToThread(m_workerThread); + + connect(m_workerThread, SIGNAL(started()), worker, SLOT(fitting())); + connect(worker, SIGNAL(finished()), this, SLOT(fittingFinished())); + // early delete of thread and worker + connect(m_workerThread, SIGNAL(finished()), m_workerThread, + SLOT(deleteLater()), Qt::DirectConnection); + connect(worker, SIGNAL(finished()), worker, SLOT(deleteLater())); + m_workerThread->start(); +} + +/** + * Takes a full file path as a string and attempts to get the base name + * of the file at that location and return it + * + * @param filePath The full path to get the basename of + * + * @return The base name (without ext) of the file + */ +std::string EnggDiffFittingPresenter::getBaseNameFromStr( + const std::string &filePath) const { + Poco::Path pocoPath = filePath; + return pocoPath.getBaseName(); +} + +void EnggDiffFittingPresenter::fittingFinished() { + if (!m_view) + return; + + if (m_fittingFinishedOK) { + + g_log.notice() << "The single peak fitting finished - the output " + "workspace is ready.\n"; + + m_view->showStatus("Single peak fitting process finished. Ready"); + + if (!m_view->listWidgetHasSelectedRow()) { + m_view->setFittingListWidgetCurrentRow(0); + } + + m_model->addAllFitResultsToADS(); + m_model->addAllFittedPeaksToADS(); + + try { + // should now plot the focused workspace when single peak fitting + // process fails + plotAlignedWorkspace(m_view->plotFittedPeaksEnabled()); + + } catch (std::runtime_error &re) { + g_log.error() << "Unable to finish the plotting of the graph for " + "engggui_fitting_focused_fitpeaks workspace. Error " + "description: " + + static_cast<std::string>(re.what()) + + " Please check also the log message for detail."; + } + g_log.notice() << "EnggDiffraction GUI: plotting of peaks for single peak " + "fits has completed. \n"; + + if (m_workerThread) { + delete m_workerThread; + m_workerThread = nullptr; + } + + } else { + // Fitting failed log and tidy up + g_log.warning() << "The single peak fitting did not finish correctly. " + "Please check a focused file was selected."; + if (m_workerThread) { + delete m_workerThread; + m_workerThread = nullptr; + } + + m_view->showStatus( + "Single peak fitting process did not complete successfully"); + } + // enable the GUI + m_view->enableFitAllButton(m_model->getNumFocusedWorkspaces() > 1); + m_view->enableCalibrateFocusFitUserActions(true); +} + +void EnggDiffFittingPresenter::processSelectRun() { updatePlot(); } + +void EnggDiffFittingPresenter::processStart() {} + +void EnggDiffFittingPresenter::processLoad() { + const std::string filenames = m_view->getFocusedFileNames(); + if (filenames.empty()) { + m_view->userWarning("No file selected", "Please enter filename(s) to load"); + return; + } + + try { + m_model->loadWorkspaces(filenames); + } catch (Poco::PathSyntaxException &ex) { + warnFileNotFound(ex); + return; + } catch (std::invalid_argument &ex) { + warnFileNotFound(ex); + return; + } catch (std::runtime_error &ex) { + warnFileNotFound(ex); + return; + } + + const auto runLabels = m_model->getRunLabels(); + std::vector<std::string> listWidgetLabels; + std::transform(runLabels.begin(), runLabels.end(), + std::back_inserter(listWidgetLabels), + [](const RunLabel &runLabel) { + return listWidgetLabelFromRunLabel(runLabel); + }); + m_view->enableFittingListWidget(true); + m_view->updateFittingListWidget(listWidgetLabels); + + m_view->enableFitAllButton(m_model->getNumFocusedWorkspaces() > 1); +} + +void EnggDiffFittingPresenter::processShutDown() { + m_viewHasClosed = true; + m_view->saveSettings(); + cleanup(); +} + +void EnggDiffFittingPresenter::processLogMsg() { + std::vector<std::string> msgs = m_view->logMsgs(); + for (const auto &msg : msgs) { + g_log.information() << msg << '\n'; + } +} + +void EnggDiffFittingPresenter::processUpdatePlotFitPeaks() { updatePlot(); } + +void EnggDiffFittingPresenter::processRemoveRun() { + const auto workspaceLabel = m_view->getFittingListWidgetCurrentValue(); + + if (workspaceLabel) { + const auto runLabel = runLabelFromListWidgetLabel(*workspaceLabel); + m_model->removeRun(runLabel); + + const auto runLabels = m_model->getRunLabels(); + std::vector<std::string> listWidgetLabels; + std::transform(runLabels.begin(), runLabels.end(), + std::back_inserter(listWidgetLabels), + [](const RunLabel &runLabel) { + return listWidgetLabelFromRunLabel(runLabel); + }); + m_view->updateFittingListWidget(listWidgetLabels); + } else { + m_view->userWarning("No run selected", + "Tried to remove run but no run was selected.\n" + "Please select a run and try again"); + } +} + +void EnggDiffFittingPresenter::processFitAllPeaks() { + std::string fittingPeaks = m_view->getExpectedPeaksInput(); + + const std::string normalisedPeakCentres = stripExtraCommas(fittingPeaks); + m_view->setPeakList(normalisedPeakCentres); + + const auto runLabels = m_model->getRunLabels(); + + g_log.debug() << "Focused files found are: " << normalisedPeakCentres << '\n'; + for (const auto &runLabel : runLabels) { + g_log.debug() << listWidgetLabelFromRunLabel(runLabel) << '\n'; + } + + if (!runLabels.empty()) { + + for (const auto &runLabel : runLabels) { + try { + validateFittingInputs(m_model->getWorkspaceFilename(runLabel), + normalisedPeakCentres); + } catch (std::invalid_argument &ia) { + m_view->userWarning("Error in the inputs required for fitting", + ia.what()); + return; + } + } + + g_log.notice() << "EnggDiffraction GUI: starting new multi-run " + << "single peak fits. This may take some seconds...\n"; + m_view->showStatus("Fitting multi-run single peaks..."); + + // disable GUI to avoid any double threads + m_view->enableCalibrateFocusFitUserActions(false); + m_view->enableFitAllButton(false); + + startAsyncFittingWorker(runLabels, normalisedPeakCentres); + } else { + m_view->userWarning("Error in the inputs required for fitting", + "No runs were loaded for fitting"); + } +} + +void EnggDiffFittingPresenter::processFitPeaks() { + const auto listLabel = m_view->getFittingListWidgetCurrentValue(); + + if (!listLabel) { + m_view->userWarning("No run selected", + "Please select a run to fit from the list"); + return; + } + + const auto runLabel = runLabelFromListWidgetLabel(*listLabel); + std::string fittingPeaks = m_view->getExpectedPeaksInput(); + + const std::string normalisedPeakCentres = stripExtraCommas(fittingPeaks); + m_view->setPeakList(normalisedPeakCentres); + + g_log.debug() << "the expected peaks are: " << normalisedPeakCentres << '\n'; + + const auto filename = m_model->getWorkspaceFilename(runLabel); + try { + validateFittingInputs(filename, normalisedPeakCentres); + } catch (std::invalid_argument &ia) { + m_view->userWarning("Error in the inputs required for fitting", ia.what()); + return; + } + + // disable so that user is forced to select file again + // otherwise empty vector will be passed + m_view->enableFitAllButton(false); + + const std::string outWSName = "engggui_fitting_fit_peak_ws"; + g_log.notice() << "EnggDiffraction GUI: starting new " + << "single peak fits into workspace '" << outWSName + << "'. This may take some seconds... \n"; + + m_view->showStatus("Fitting single peaks..."); + // disable GUI to avoid any double threads + m_view->enableCalibrateFocusFitUserActions(false); + + startAsyncFittingWorker({runLabel}, normalisedPeakCentres); +} + +void EnggDiffFittingPresenter::validateFittingInputs( + const std::string &focusedRunFilename, const std::string &expectedPeaks) { + if (focusedRunFilename.empty()) { + throw std::invalid_argument( + "Focused run filename cannot be empty and must be a valid file"); + } + + Poco::File file(focusedRunFilename); + if (!file.exists()) { + throw std::invalid_argument("The focused workspace file for single peak " + "fitting could not be found: " + + focusedRunFilename); + } + + if (expectedPeaks.empty()) { + g_log.warning() << "Expected peaks were not passed, via fitting interface, " + "the default list of " + "expected peaks will be utilised instead.\n"; + } + bool contains_non_digits = + expectedPeaks.find_first_not_of("0123456789,. ") != std::string::npos; + if (contains_non_digits) { + throw std::invalid_argument("The expected peaks provided " + expectedPeaks + + " is invalid, " + "fitting process failed. Please try again!"); + } +} + +void EnggDiffFittingPresenter::doFitting(const std::vector<RunLabel> &runLabels, + const std::string &expectedPeaks) { + m_fittingFinishedOK = false; + + for (const auto &runLabel : runLabels) { + g_log.notice() << "EnggDiffraction GUI: starting new fitting with run " + << runLabel.runNumber << " and bank " << runLabel.bank + << ". This may take a few seconds... \n"; + + // apply calibration to the focused workspace + m_model->setDifcTzero(runLabel, currentCalibration()); + + // run the algorithm EnggFitPeaks with workspace loaded above + // requires unit in Time of Flight + try { + m_model->enggFitPeaks(runLabel, expectedPeaks); + } catch (const std::runtime_error &exc) { + g_log.error() << "Could not run the algorithm EnggFitPeaks successfully." + << exc.what(); + // A userError should be used for this message once the threading has been + // looked into + return; + } catch (const Mantid::API::Algorithm::CancelException &) { + g_log.error() << "Fit terminated by user.\n"; + return; + } + + const auto outFilename = userHDFRunFilename(runLabel.runNumber); + m_model->saveFitResultsToHDF5({runLabel}, outFilename); + + m_model->createFittedPeaksWS(runLabel); + } + + if (runLabels.size() > 1) { + m_model->saveFitResultsToHDF5(runLabels, + userHDFMultiRunFilename(runLabels)); + } + m_fittingFinishedOK = true; +} + +void EnggDiffFittingPresenter::browsePeaksToFit() { + try { + const auto &userDir = outFilesUserDir(""); + std::string path = m_view->getOpenFile(userDir.toString()); + if (path.empty()) { + return; + } + + m_view->setPreviousDir(path); + std::string peaksData = readPeaksFile(path); + m_view->setPeakList(peaksData); + + } catch (std::runtime_error &re) { + m_view->userWarning( + "Unable to import the peaks from a file: ", + "File corrupted or could not be opened. Please try again" + + static_cast<std::string>(re.what()) + '\n'); + return; + } +} + +void EnggDiffFittingPresenter::addPeakToList() { + + if (m_view->peakPickerEnabled()) { + auto peakCentre = m_view->getPeakCentre(); + + std::stringstream stream; + stream << std::fixed << std::setprecision(4) << peakCentre; + auto strPeakCentre = stream.str(); + + auto curExpPeaksList = m_view->getExpectedPeaksInput(); + + std::string comma = ","; + + if (!curExpPeaksList.empty()) { + // when further peak added to list + + std::string lastTwoChr = + curExpPeaksList.substr(curExpPeaksList.size() - 2); + auto lastChr = curExpPeaksList.back(); + if (lastChr == ',' || lastTwoChr == ", ") { + curExpPeaksList.append(strPeakCentre); + } else { + curExpPeaksList.append(comma + strPeakCentre); + } + m_view->setPeakList(curExpPeaksList); + } else { + // when new peak given when list is empty + curExpPeaksList.append(strPeakCentre); + curExpPeaksList.append(comma); + m_view->setPeakList(curExpPeaksList); + } + } +} + +void EnggDiffFittingPresenter::savePeakList() { + try { + const auto &userDir = outFilesUserDir(""); + const auto &path = m_view->getSaveFile(userDir.toString()); + + if (path.empty()) { + return; + } + + fittingWriteFile(path); + } catch (std::runtime_error &re) { + m_view->userWarning( + "Unable to save the peaks file: ", + "Invalid file path or could not be saved. Error description : " + + static_cast<std::string>(re.what()) + '\n'); + return; + } +} + +std::string +EnggDiffFittingPresenter::readPeaksFile(const std::string &fileDir) { + std::string fileData = ""; + std::string line; + std::string comma = ", "; + + std::ifstream peakFile(fileDir); + + if (peakFile.is_open()) { + while (std::getline(peakFile, line)) { + fileData += line; + if (!peakFile.eof()) + fileData += comma; + } + peakFile.close(); + } + + else + fileData = ""; + + return fileData; +} + +void EnggDiffFittingPresenter::fittingWriteFile(const std::string &fileDir) { + std::ofstream outfile(fileDir.c_str()); + if (!outfile) { + m_view->userWarning("File not found", + "File " + fileDir + + " , could not be found. Please try again!"); + } else { + auto expPeaks = m_view->getExpectedPeaksInput(); + outfile << expPeaks; + } +} + +void EnggDiffFittingPresenter::updatePlot() { + const auto listLabel = m_view->getFittingListWidgetCurrentValue(); + if (listLabel) { + const auto runLabel = runLabelFromListWidgetLabel(*listLabel); + + const bool fitResultsExist = m_model->hasFittedPeaksForRun(runLabel); + const bool plotFittedPeaksEnabled = m_view->plotFittedPeaksEnabled(); + + if (fitResultsExist) { + plotAlignedWorkspace(plotFittedPeaksEnabled); + } else { + if (plotFittedPeaksEnabled) { + m_view->userWarning("Cannot plot fitted peaks", + "Cannot plot fitted peaks, as none have been " + "generated by a fit. Plotting focused workspace " + "instead."); + } + const auto ws = m_model->getFocusedWorkspace(runLabel); + plotFocusedFile(false, ws); + } + } +} + +bool EnggDiffFittingPresenter::isDigit(const std::string &text) const { + return std::all_of(text.cbegin(), text.cend(), ::isdigit); +} + +void EnggDiffFittingPresenter::warnFileNotFound(const std::exception &ex) { + m_view->showStatus("Error while loading focused run"); + m_view->userWarning("Invalid file selected", + "Mantid could not load the selected file, " + "or was unable to get necessary information." + "See the logger for more information"); + g_log.error("Failed to load file. Error message: "); + g_log.error(ex.what()); +} + +void EnggDiffFittingPresenter::plotFocusedFile( + bool plotSinglePeaks, const MatrixWorkspace_sptr &focusedPeaksWS) { + + try { + auto focusedData = QwtHelper::curveDataFromWs(focusedPeaksWS); + + // Check that the number of curves to plot isn't excessive + // lets cap it at 20 to begin with - this number could need + // raising but each curve creates about ~5 calls on the stack + // so keep the limit low. This will stop users using unfocused + // files which have 200+ curves to plot and will "freeze" Mantid + constexpr int maxCurves = 20; + + if (focusedData.size() > maxCurves) { + throw std::invalid_argument("Too many curves to plot." + " Is this a focused file?"); + } + + m_view->setDataVector( + focusedData, true, plotSinglePeaks, + generateXAxisLabel(focusedPeaksWS->getAxis(0)->unit())); + + } catch (std::runtime_error &re) { + g_log.error() + << "Unable to plot focused workspace on the canvas. " + << "Error description: " << re.what() + << " Please check also the previous log messages for details."; + + m_view->showStatus("Error while plotting the peaks fitted"); + throw; + } +} + +void EnggDiffFittingPresenter::plotAlignedWorkspace( + const bool plotFittedPeaks) { + try { + + // detaches previous plots from canvas + m_view->resetCanvas(); + + const auto listLabel = m_view->getFittingListWidgetCurrentValue(); + if (!listLabel) { + m_view->userWarning("Invalid run number or bank", + "Tried to plot a focused file which does not exist"); + return; + } + + const auto runLabel = runLabelFromListWidgetLabel(*listLabel); + const auto ws = m_model->getAlignedWorkspace(runLabel); + + // plots focused workspace + plotFocusedFile(m_fittingFinishedOK, ws); + + if (plotFittedPeaks) { + g_log.debug() << "single peaks fitting being plotted now.\n"; + auto singlePeaksWS = m_model->getFittedPeaksWS(runLabel); + auto singlePeaksData = QwtHelper::curveDataFromWs(singlePeaksWS); + m_view->setDataVector(singlePeaksData, false, true, + generateXAxisLabel(ws->getAxis(0)->unit())); + m_view->showStatus("Peaks fitted successfully"); + } + } catch (const std::runtime_error &) { + g_log.error() + << "Unable to finish of the plotting of the graph for " + "engggui_fitting_focused_fitpeaks workspace. Error " + "description. Please check also the log message for detail."; + + m_view->showStatus("Error while plotting the peaks fitted"); + throw; + } +} + +} // namespace CustomInterfaces +} // namespace MantidQt diff --git a/qt/scientific_interfaces/EnggDiffraction/EnggDiffFittingPresenter.h b/qt/scientific_interfaces/EnggDiffraction/EnggDiffFittingPresenter.h new file mode 100644 index 0000000000000000000000000000000000000000..79acf0ae5fe95d60aae3fb631c06482d7571619f --- /dev/null +++ b/qt/scientific_interfaces/EnggDiffraction/EnggDiffFittingPresenter.h @@ -0,0 +1,142 @@ +// Mantid Repository : https://github.com/mantidproject/mantid +// +// Copyright © 2016 ISIS Rutherford Appleton Laboratory UKRI, +// NScD Oak Ridge National Laboratory, European Spallation Source +// & Institut Laue - Langevin +// SPDX - License - Identifier: GPL - 3.0 + +#pragma once + +#include "DllConfig.h" +#include "IEnggDiffFittingModel.h" +#include "IEnggDiffFittingPresenter.h" +#include "IEnggDiffFittingView.h" +#include "IEnggDiffractionCalibration.h" +#include "IEnggDiffractionParam.h" + +#include <string> +#include <vector> + +#include <QObject> + +class QThread; + +namespace MantidQt { +namespace CustomInterfaces { + +/** +Presenter for the fitting tab/widget of the enggineering diffraction +GUI (presenter as in the MVP Model-View-Presenter pattern). +*/ +// needs to be dll-exported for the tests +class MANTIDQT_ENGGDIFFRACTION_DLL EnggDiffFittingPresenter + : public QObject, + public IEnggDiffFittingPresenter, + public IEnggDiffractionCalibration, + public IEnggDiffractionParam { + // Q_OBJECT for 'connect' with thread/worker + Q_OBJECT + +public: + EnggDiffFittingPresenter( + IEnggDiffFittingView *view, std::unique_ptr<IEnggDiffFittingModel> model, + boost::shared_ptr<IEnggDiffractionCalibration> mainCalib, + boost::shared_ptr<IEnggDiffractionParam> mainParam); + ~EnggDiffFittingPresenter() override; + + void notify(IEnggDiffFittingPresenter::Notification notif) override; + + /// From the IEnggDiffractionCalibration interface + //@{ + std::vector<GSASCalibrationParms> currentCalibration() const override; + //@} + + /// From the IEnggDiffractionCalibration interface + //@{ + Poco::Path outFilesUserDir(const std::string &addToDir) const override; + //@} + + std::string userHDFRunFilename(const std::string &runNumber) const override; + std::string userHDFMultiRunFilename( + const std::vector<RunLabel> &runLabels) const override; + + /// the fitting hard work that a worker / thread will run + void doFitting(const std::vector<RunLabel> &runLabels, + const std::string &expectedPeaks); + + void plotFocusedFile(bool plotSinglePeaks, + const Mantid::API::MatrixWorkspace_sptr &focusedPeaksWS); + + void plotAlignedWorkspace(const bool plotFittedPeaks); + +protected: + void processStart(); + void processLoad(); + void processFitPeaks(); + void processFitAllPeaks(); + void processShutDown(); + void processLogMsg(); + void processUpdatePlotFitPeaks(); + void processRemoveRun(); + + /// clean shut down of model, view, etc. + void cleanup(); + +protected slots: + + void fittingFinished(); + +private: + void updatePlot(); + + bool isDigit(const std::string &text) const; + + void warnFileNotFound(const std::exception &ex); + + // Methods related single peak fits + virtual void startAsyncFittingWorker(const std::vector<RunLabel> &runLabels, + const std::string &expectedPeaks); + + std::string getBaseNameFromStr(const std::string &filePath) const; + + void validateFittingInputs(const std::string &focusedRunNo, + const std::string &expectedPeaks); + + void browsePeaksToFit(); + + void addPeakToList(); + + void savePeakList(); + + std::string readPeaksFile(const std::string &fileDir); + + void fittingWriteFile(const std::string &fileDir); + + // Holds the previous user input so we can short circuit further checks + std::string m_previousInput; + + /// true if the last fitting completed successfully + bool m_fittingFinishedOK; + + QThread *m_workerThread; + + /// interface for the 'current' calibration + boost::shared_ptr<IEnggDiffractionCalibration> m_mainCalib; + + /// interface for the 'current' calibration + boost::shared_ptr<IEnggDiffractionParam> m_mainParam; + + /// Associated view for this presenter (MVP pattern) + IEnggDiffFittingView *const m_view; + + /// Associated model for this presenter + std::unique_ptr<IEnggDiffFittingModel> m_model; + + /// Holds if the view is in the process of being closed + bool m_viewHasClosed; + + /// Handle the user selecting a different run to plot + void processSelectRun(); +}; + +} // namespace CustomInterfaces +} // namespace MantidQt \ No newline at end of file diff --git a/qt/scientific_interfaces/EnggDiffraction/EnggDiffFittingViewQtWidget.cpp b/qt/scientific_interfaces/EnggDiffraction/EnggDiffFittingViewQtWidget.cpp new file mode 100644 index 0000000000000000000000000000000000000000..f2a1dc1100ad037563e9bb742edfd359f1d9ef92 --- /dev/null +++ b/qt/scientific_interfaces/EnggDiffraction/EnggDiffFittingViewQtWidget.cpp @@ -0,0 +1,577 @@ +// Mantid Repository : https://github.com/mantidproject/mantid +// +// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI, +// NScD Oak Ridge National Laboratory, European Spallation Source +// & Institut Laue - Langevin +// SPDX - License - Identifier: GPL - 3.0 + +#include "EnggDiffFittingViewQtWidget.h" +#include "EnggDiffFittingModel.h" +#include "EnggDiffFittingPresenter.h" +#include "MantidAPI/FunctionFactory.h" +#include "MantidAPI/IPeakFunction.h" + +#include "MantidQtWidgets/Common/AlgorithmInputHistory.h" +#include "MantidQtWidgets/Plotting/Qwt/PeakPicker.h" + +#include <array> +#include <iomanip> +#include <random> +#include <sstream> + +#include <boost/algorithm/string.hpp> +#include <boost/make_shared.hpp> + +#include <Poco/Path.h> + +#include <QEvent> +#include <QFileDialog> +#include <QHelpEvent> +#include <QSettings> +#include <utility> + +#include <qwt_plot_curve.h> +#include <qwt_plot_zoomer.h> +#include <qwt_symbol.h> + +using namespace Mantid::API; +using namespace MantidQt::CustomInterfaces; + +namespace MantidQt { +namespace CustomInterfaces { + +const std::string EnggDiffFittingViewQtWidget::g_settingsGroup = + "CustomInterfaces/EnggDiffraction/FittingView"; + +const std::string EnggDiffFittingViewQtWidget::g_peaksListExt = + "Peaks list File: CSV " + "(*.csv *.txt);;" + "Other extensions/all files (*)"; + +std::vector<std::string> EnggDiffFittingViewQtWidget::m_fitting_runno_dir_vec; + +EnggDiffFittingViewQtWidget::EnggDiffFittingViewQtWidget( + QWidget * /*parent*/, boost::shared_ptr<IEnggDiffractionUserMsg> mainMsg, + boost::shared_ptr<IEnggDiffractionSettings> mainSettings, + boost::shared_ptr<IEnggDiffractionCalibration> mainCalib, + boost::shared_ptr<IEnggDiffractionParam> mainParam, + boost::shared_ptr<IEnggDiffractionPythonRunner> mainPythonRunner, + boost::shared_ptr<IEnggDiffractionParam> fileSettings) + : IEnggDiffFittingView(), m_fittedDataVector(), + m_fileSettings(std::move(fileSettings)), + m_mainMsgProvider(std::move(mainMsg)), + m_mainSettings(std::move(mainSettings)), + m_mainPythonRunner(std::move(mainPythonRunner)), + m_presenter(boost::make_shared<EnggDiffFittingPresenter>( + this, std::make_unique<EnggDiffFittingModel>(), mainCalib, + mainParam)) { + + initLayout(); + m_presenter->notify(IEnggDiffFittingPresenter::Start); +} + +EnggDiffFittingViewQtWidget::~EnggDiffFittingViewQtWidget() { + m_presenter->notify(IEnggDiffFittingPresenter::ShutDown); + + for (auto curves : m_focusedDataVector) { + curves->detach(); + delete curves; + } + + for (auto curves : m_fittedDataVector) { + curves->detach(); + delete curves; + } +} + +void EnggDiffFittingViewQtWidget::initLayout() { + m_ui.setupUi(this); + + readSettings(); + doSetup(); +} + +void EnggDiffFittingViewQtWidget::doSetup() { + connect(m_ui.pushButton_fitting_browse_run_num, SIGNAL(released()), this, + SLOT(browseFitFocusedRun())); + + connect(m_ui.lineEdit_pushButton_run_num, SIGNAL(returnPressed()), this, + SLOT(loadClicked())); + + connect(m_ui.pushButton_fitting_browse_peaks, SIGNAL(released()), this, + SLOT(browseClicked())); + + connect(m_ui.pushButton_load, SIGNAL(released()), this, SLOT(loadClicked())); + + connect(m_ui.pushButton_fit, SIGNAL(released()), this, SLOT(fitClicked())); + + connect(m_ui.pushButton_fit_all, SIGNAL(released()), this, + SLOT(fitAllClicked())); + + // add peak by clicking the button + connect(m_ui.pushButton_select_peak, SIGNAL(released()), SLOT(setPeakPick())); + + connect(m_ui.pushButton_add_peak, SIGNAL(released()), SLOT(addClicked())); + + connect(m_ui.pushButton_save_peak_list, SIGNAL(released()), + SLOT(saveClicked())); + + connect(m_ui.pushButton_clear_peak_list, SIGNAL(released()), + SLOT(clearPeakList())); + + connect(m_ui.pushButton_plot_separate_window, SIGNAL(released()), + SLOT(plotSeparateWindow())); + + connect(m_ui.listWidget_fitting_run_num, + SIGNAL(itemClicked(QListWidgetItem *)), this, + SLOT(listWidget_fitting_run_num_clicked(QListWidgetItem *))); + + connect(m_ui.checkBox_plotFittedPeaks, SIGNAL(stateChanged(int)), this, + SLOT(plotFittedPeaksStateChanged())); + + // Tool-tip button + connect(m_ui.pushButton_tooltip, SIGNAL(released()), SLOT(showToolTipHelp())); + + // Remove run button + connect(m_ui.pushButton_remove_run, SIGNAL(released()), this, + SLOT(removeRunClicked())); + + m_ui.dataPlot->setCanvasBackground(Qt::white); + m_ui.dataPlot->setAxisTitle(QwtPlot::xBottom, "d-Spacing (A)"); + m_ui.dataPlot->setAxisTitle(QwtPlot::yLeft, "Counts (us)^-1"); + QFont font("MS Shell Dlg 2", 8); + m_ui.dataPlot->setAxisFont(QwtPlot::xBottom, font); + m_ui.dataPlot->setAxisFont(QwtPlot::yLeft, font); + + // constructor of the peakPicker + // XXX: Being a QwtPlotItem, should get deleted when m_ui.plot gets deleted + // (auto-delete option) + m_peakPicker = new MantidWidgets::PeakPicker(m_ui.dataPlot, Qt::red); + setPeakPickerEnabled(false); + + m_zoomTool = + new QwtPlotZoomer(QwtPlot::xBottom, QwtPlot::yLeft, + QwtPicker::DragSelection | QwtPicker::CornerToCorner, + QwtPicker::AlwaysOff, m_ui.dataPlot->canvas()); + m_zoomTool->setRubberBandPen(QPen(Qt::black)); + setZoomTool(false); +} + +void EnggDiffFittingViewQtWidget::readSettings() { + QSettings qs; + qs.beginGroup(QString::fromStdString(g_settingsGroup)); + + // user params + m_ui.lineEdit_pushButton_run_num->setText( + qs.value("user-params-fitting-focused-file", "").toString()); + m_ui.lineEdit_fitting_peaks->setText( + qs.value("user-params-fitting-peaks-to-fit", "").toString()); + + qs.endGroup(); +} + +void EnggDiffFittingViewQtWidget::saveSettings() const { + QSettings qs; + qs.beginGroup(QString::fromStdString(g_settingsGroup)); + + qs.setValue("user-params-fitting-focused-file", + m_ui.lineEdit_pushButton_run_num->text()); + qs.setValue("user-params-fitting-peaks-to-fit", + m_ui.lineEdit_fitting_peaks->text()); + + qs.endGroup(); +} + +void EnggDiffFittingViewQtWidget::enable(bool enable) { + m_ui.pushButton_fitting_browse_run_num->setEnabled(enable); + m_ui.pushButton_load->setEnabled(enable); + m_ui.lineEdit_pushButton_run_num->setEnabled(enable); + m_ui.pushButton_fitting_browse_peaks->setEnabled(enable); + m_ui.lineEdit_fitting_peaks->setEnabled(enable); + m_ui.pushButton_fit->setEnabled(enable); + m_ui.pushButton_clear_peak_list->setEnabled(enable); + m_ui.pushButton_save_peak_list->setEnabled(enable); + m_ui.groupBox_fititng_preview->setEnabled(enable); +} + +void EnggDiffFittingViewQtWidget::showStatus(const std::string &sts) { + m_mainMsgProvider->showStatus(sts); +} + +void EnggDiffFittingViewQtWidget::userWarning(const std::string &err, + const std::string &description) { + m_mainMsgProvider->userWarning(err, description); +} + +void EnggDiffFittingViewQtWidget::userError(const std::string &err, + const std::string &description) { + m_mainMsgProvider->userError(err, description); +} + +void EnggDiffFittingViewQtWidget::enableCalibrateFocusFitUserActions( + bool enable) { + m_mainMsgProvider->enableCalibrateFocusFitUserActions(enable); +} + +EnggDiffCalibSettings +EnggDiffFittingViewQtWidget::currentCalibSettings() const { + return m_mainSettings->currentCalibSettings(); +} + +std::string +EnggDiffFittingViewQtWidget::enggRunPythonCode(const std::string &pyCode) { + return m_mainPythonRunner->enggRunPythonCode(pyCode); +} + +void EnggDiffFittingViewQtWidget::loadClicked() { + m_presenter->notify(IEnggDiffFittingPresenter::Load); +} + +void EnggDiffFittingViewQtWidget::fitClicked() { + m_presenter->notify(IEnggDiffFittingPresenter::FitPeaks); +} + +void EnggDiffFittingViewQtWidget::fitAllClicked() { + m_presenter->notify(IEnggDiffFittingPresenter::FitAllPeaks); +} + +void EnggDiffFittingViewQtWidget::addClicked() { + m_presenter->notify(IEnggDiffFittingPresenter::addPeaks); +} + +void EnggDiffFittingViewQtWidget::browseClicked() { + m_presenter->notify(IEnggDiffFittingPresenter::browsePeaks); +} + +void EnggDiffFittingViewQtWidget::saveClicked() { + m_presenter->notify(IEnggDiffFittingPresenter::savePeaks); +} + +void EnggDiffFittingViewQtWidget::plotFittedPeaksStateChanged() { + m_presenter->notify(IEnggDiffFittingPresenter::updatePlotFittedPeaks); +} + +void EnggDiffFittingViewQtWidget::listWidget_fitting_run_num_clicked( + QListWidgetItem *) { + m_presenter->notify(IEnggDiffFittingPresenter::selectRun); +} + +void EnggDiffFittingViewQtWidget::removeRunClicked() { + m_presenter->notify(IEnggDiffFittingPresenter::removeRun); +} + +void EnggDiffFittingViewQtWidget::resetCanvas() { + // clear vector and detach curves to avoid plot crash + // when only plotting focused workspace + for (auto curves : m_fittedDataVector) { + if (curves) { + curves->detach(); + delete curves; + } + } + + if (m_fittedDataVector.size() > 0) + m_fittedDataVector.clear(); + + // set it as false as there will be no valid workspace to plot + m_ui.pushButton_plot_separate_window->setEnabled(false); +} + +void EnggDiffFittingViewQtWidget::setDataVector( + std::vector<boost::shared_ptr<QwtData>> &data, bool focused, + bool plotSinglePeaks, const std::string &xAxisLabel) { + + if (!plotSinglePeaks) { + // clear vector and detach curves to avoid plot crash + resetCanvas(); + } + m_ui.dataPlot->setAxisTitle(QwtPlot::xBottom, xAxisLabel.c_str()); + + // when only plotting focused workspace + if (focused) { + dataCurvesFactory(data, m_focusedDataVector, focused); + } else { + dataCurvesFactory(data, m_fittedDataVector, focused); + } +} + +void EnggDiffFittingViewQtWidget::dataCurvesFactory( + std::vector<boost::shared_ptr<QwtData>> &data, + std::vector<QwtPlotCurve *> &dataVector, bool focused) { + + // clear vector + for (auto curves : dataVector) { + if (curves) { + curves->detach(); + delete curves; + } + } + + if (dataVector.size() > 0) + dataVector.clear(); + resetView(); + + // dark colours could be removed so that the coloured peaks stand out more + const std::array<QColor, 16> QPenList{ + {Qt::white, Qt::red, Qt::darkRed, Qt::green, Qt::darkGreen, Qt::blue, + Qt::darkBlue, Qt::cyan, Qt::darkCyan, Qt::magenta, Qt::darkMagenta, + Qt::yellow, Qt::darkYellow, Qt::gray, Qt::lightGray, Qt::black}}; + + std::mt19937 gen; + std::uniform_int_distribution<std::size_t> dis(0, QPenList.size() - 1); + + for (size_t i = 0; i < data.size(); i++) { + auto *peak = data[i].get(); + + QwtPlotCurve *dataCurve = new QwtPlotCurve(); + if (!focused) { + dataCurve->setStyle(QwtPlotCurve::Lines); + auto randIndex = dis(gen); + dataCurve->setPen(QPen(QPenList[randIndex], 2)); + + // only set enabled when single peak workspace plotted + m_ui.pushButton_plot_separate_window->setEnabled(true); + } else { + dataCurve->setStyle(QwtPlotCurve::NoCurve); + // focused workspace in bg set as darkGrey crosses insted of line + dataCurve->setSymbol(QwtSymbol(QwtSymbol::XCross, QBrush(), + QPen(Qt::darkGray, 1), QSize(3, 3))); + } + dataCurve->setRenderHint(QwtPlotItem::RenderAntialiased, true); + + dataVector.emplace_back(dataCurve); + + dataVector[i]->setData(*peak); + dataVector[i]->attach(m_ui.dataPlot); + } + + m_ui.dataPlot->replot(); + m_zoomTool->setZoomBase(); + // enable zoom & select peak btn after the plotting on graph + setZoomTool(true); + m_ui.pushButton_select_peak->setEnabled(true); + data.clear(); +} + +void EnggDiffFittingViewQtWidget::setPeakPickerEnabled(bool enabled) { + m_peakPicker->setEnabled(enabled); + m_peakPicker->setVisible(enabled); + m_ui.dataPlot->replot(); // PeakPicker might get hidden/shown + m_ui.pushButton_add_peak->setEnabled(enabled); + if (enabled) { + QString btnText = "Reset Peak Selector"; + m_ui.pushButton_select_peak->setText(btnText); + } +} + +void EnggDiffFittingViewQtWidget::setPeakPicker( + const IPeakFunction_const_sptr &peak) { + m_peakPicker->setPeak(peak); + m_ui.dataPlot->replot(); +} + +double EnggDiffFittingViewQtWidget::getPeakCentre() const { + auto peak = m_peakPicker->peak(); + auto centre = peak->centre(); + return centre; +} + +bool EnggDiffFittingViewQtWidget::peakPickerEnabled() const { + return m_peakPicker->isEnabled(); +} + +void EnggDiffFittingViewQtWidget::setZoomTool(bool enabled) { + m_zoomTool->setEnabled(enabled); +} + +void EnggDiffFittingViewQtWidget::resetView() { + // Resets the view to a sensible default + // Auto scale the axis + m_ui.dataPlot->setAxisAutoScale(QwtPlot::xBottom); + m_ui.dataPlot->setAxisAutoScale(QwtPlot::yLeft); + + // Set this as the default zoom level + m_zoomTool->setZoomBase(true); +} + +std::string EnggDiffFittingViewQtWidget::getPreviousDir() const { + + QString prevPath = + MantidQt::API::AlgorithmInputHistory::Instance().getPreviousDirectory(); + + return prevPath.toStdString(); +} + +void EnggDiffFittingViewQtWidget::setPreviousDir(const std::string &path) { + QString qPath = QString::fromStdString(path); + MantidQt::API::AlgorithmInputHistory::Instance().setPreviousDirectory(qPath); +} + +std::string +EnggDiffFittingViewQtWidget::getOpenFile(const std::string &prevPath) { + + QString path(QFileDialog::getOpenFileName( + this, tr("Open Peaks To Fit"), QString::fromStdString(prevPath), + QString::fromStdString(g_peaksListExt))); + + return path.toStdString(); +} + +std::string +EnggDiffFittingViewQtWidget::getSaveFile(const std::string &prevPath) { + + QString path(QFileDialog::getSaveFileName( + this, tr("Save Expected Peaks List"), QString::fromStdString(prevPath), + QString::fromStdString(g_peaksListExt))); + + return path.toStdString(); +} + +void EnggDiffFittingViewQtWidget::browseFitFocusedRun() { + const auto &focusDir = m_fileSettings->outFilesUserDir("Focus").toString(); + std::string nexusFormat = "Nexus file with calibration table: NXS, NEXUS" + "(*.nxs *.nexus);;"; + + QStringList paths(QFileDialog::getOpenFileNames( + this, tr("Open Focused File "), QString::fromStdString(focusDir), + QString::fromStdString(nexusFormat))); + + if (paths.isEmpty()) { + return; + } + + setFocusedFileNames(paths.join(",").toStdString()); +} + +void EnggDiffFittingViewQtWidget::setFocusedFileNames( + const std::string &paths) { + m_ui.lineEdit_pushButton_run_num->setText(QString::fromStdString(paths)); +} + +std::string EnggDiffFittingViewQtWidget::getFocusedFileNames() const { + return m_ui.lineEdit_pushButton_run_num->text().toStdString(); +} + +void EnggDiffFittingViewQtWidget::enableFitAllButton(bool enable) const { + m_ui.pushButton_fit_all->setEnabled(enable); +} + +void EnggDiffFittingViewQtWidget::clearFittingListWidget() const { + m_ui.listWidget_fitting_run_num->clear(); +} + +void EnggDiffFittingViewQtWidget::enableFittingListWidget(bool enable) const { + m_ui.listWidget_fitting_run_num->setEnabled(enable); +} + +int EnggDiffFittingViewQtWidget::getFittingListWidgetCurrentRow() const { + return m_ui.listWidget_fitting_run_num->currentRow(); +} + +boost::optional<std::string> +EnggDiffFittingViewQtWidget::getFittingListWidgetCurrentValue() const { + if (listWidgetHasSelectedRow()) { + return m_ui.listWidget_fitting_run_num->currentItem()->text().toStdString(); + } + return boost::none; +} + +bool EnggDiffFittingViewQtWidget::listWidgetHasSelectedRow() const { + return m_ui.listWidget_fitting_run_num->selectedItems().size() != 0; +} + +void EnggDiffFittingViewQtWidget::updateFittingListWidget( + const std::vector<std::string> &rows) { + clearFittingListWidget(); + + for (const auto &rowLabel : rows) { + this->addRunNoItem(rowLabel); + } +} + +void EnggDiffFittingViewQtWidget::setFittingListWidgetCurrentRow( + int idx) const { + m_ui.listWidget_fitting_run_num->setCurrentRow(idx); +} + +bool EnggDiffFittingViewQtWidget::plotFittedPeaksEnabled() const { + return m_ui.checkBox_plotFittedPeaks->isChecked(); +} + +void EnggDiffFittingViewQtWidget::plotSeparateWindow() { + std::string pyCode = + + "fitting_single_peaks_twin_ws = \"__engggui_fitting_single_peaks_twin\"\n" + "if (mtd.doesExist(fitting_single_peaks_twin_ws)):\n" + " DeleteWorkspace(fitting_single_peaks_twin_ws)\n" + + "single_peak_ws = CloneWorkspace(InputWorkspace = " + "\"engggui_fitting_single_peaks\", OutputWorkspace = " + "fitting_single_peaks_twin_ws)\n" + "tot_spec = single_peak_ws.getNumberHistograms()\n" + + "spec_list = []\n" + "for i in range(0, tot_spec):\n" + " spec_list.append(i)\n" + + "fitting_plot = plotSpectrum(single_peak_ws, spec_list).activeLayer()\n" + "fitting_plot.setTitle(\"Engg GUI Single Peaks Fitting Workspace\")\n"; + + std::string status = m_mainPythonRunner->enggRunPythonCode(pyCode); + m_logMsgs.emplace_back("Plotted output focused data, with status string " + + status); + m_presenter->notify(IEnggDiffFittingPresenter::LogMsg); +} + +void EnggDiffFittingViewQtWidget::showToolTipHelp() { + // We need a the mouse click position relative to the widget + // and relative to the screen. We will set the mouse click position + // relative to widget to 0 as the global position of the mouse + // is what is considered when the tool tip is displayed + const QPoint relWidgetPosition(0, 0); + const QPoint mousePos = QCursor::pos(); + // Now fire the generated event to show a tool tip at the cursor + QEvent *toolTipEvent = + new QHelpEvent(QEvent::ToolTip, relWidgetPosition, mousePos); + QCoreApplication::sendEvent(m_ui.pushButton_tooltip, toolTipEvent); +} + +std::string EnggDiffFittingViewQtWidget::getExpectedPeaksInput() const { + + return m_ui.lineEdit_fitting_peaks->text().toStdString(); +} + +void EnggDiffFittingViewQtWidget::setPeakList( + const std::string &peakList) const { + m_ui.lineEdit_fitting_peaks->setText(QString::fromStdString(peakList)); +} + +void EnggDiffFittingViewQtWidget::addRunNoItem(std::string runNo) { + m_ui.listWidget_fitting_run_num->addItem(QString::fromStdString(runNo)); +} + +std::vector<std::string> EnggDiffFittingViewQtWidget::getFittingRunNumVec() { + return m_fitting_runno_dir_vec; +} + +void EnggDiffFittingViewQtWidget::setFittingRunNumVec( + std::vector<std::string> assignVec) { + // holds all the directories required + m_fitting_runno_dir_vec.clear(); + m_fitting_runno_dir_vec = assignVec; +} + +void EnggDiffFittingViewQtWidget::setPeakPick() { + auto bk2bk = + FunctionFactory::Instance().createFunction("BackToBackExponential"); + auto bk2bkFunc = boost::dynamic_pointer_cast<IPeakFunction>(bk2bk); + // set the peak to BackToBackExponential function + setPeakPicker(bk2bkFunc); + setPeakPickerEnabled(true); +} + +void EnggDiffFittingViewQtWidget::clearPeakList() { + m_ui.lineEdit_fitting_peaks->clear(); +} + +} // namespace CustomInterfaces +} // namespace MantidQt diff --git a/qt/scientific_interfaces/EnggDiffraction/EnggDiffGSASFittingModel.cpp b/qt/scientific_interfaces/EnggDiffraction/EnggDiffGSASFittingModel.cpp new file mode 100644 index 0000000000000000000000000000000000000000..8a3b71e7e044b3c92d18296039dd9aab276f48ce --- /dev/null +++ b/qt/scientific_interfaces/EnggDiffraction/EnggDiffGSASFittingModel.cpp @@ -0,0 +1,353 @@ +// Mantid Repository : https://github.com/mantidproject/mantid +// +// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI, +// NScD Oak Ridge National Laboratory, European Spallation Source +// & Institut Laue - Langevin +// SPDX - License - Identifier: GPL - 3.0 + +#include "EnggDiffGSASFittingModel.h" + +#include "MantidAPI/AlgorithmManager.h" +#include "MantidAPI/AnalysisDataService.h" +#include "MantidAPI/MatrixWorkspace.h" +#include "MantidQtWidgets/Common/MantidAlgorithmMetatype.h" + +#include <boost/algorithm/string/join.hpp> +#include <utility> + +using namespace Mantid; + +namespace { + +std::string stripWSNameFromFilename(const std::string &fullyQualifiedFilename) { + std::vector<std::string> directories; + boost::split(directories, fullyQualifiedFilename, boost::is_any_of("\\/")); + const std::string filename = directories.back(); + std::vector<std::string> filenameSegments; + boost::split(filenameSegments, filename, boost::is_any_of(".")); + return filenameSegments[0]; +} + +std::string refinementMethodToString( + const MantidQt::CustomInterfaces::GSASRefinementMethod &method) { + switch (method) { + case MantidQt::CustomInterfaces::GSASRefinementMethod::PAWLEY: + return "Pawley refinement"; + case MantidQt::CustomInterfaces::GSASRefinementMethod::RIETVELD: + return "Rietveld refinement"; + default: + throw std::invalid_argument( + "Invalid refinement method: please contact the development team"); + } +} + +} // anonymous namespace + +namespace MantidQt { +namespace CustomInterfaces { + +EnggDiffGSASFittingModel::EnggDiffGSASFittingModel() { + qRegisterMetaType< + MantidQt::CustomInterfaces::GSASIIRefineFitPeaksOutputProperties>( + "GSASIIRefineFitPeaksOutputProperties"); + qRegisterMetaType<Mantid::API::IAlgorithm_sptr>("IAlgorithm_sptr"); + qRegisterMetaType<std::vector<GSASIIRefineFitPeaksOutputProperties>>( + "std::vector<GSASIIRefineFitPeaksOutputProperties>"); +} + +EnggDiffGSASFittingModel::~EnggDiffGSASFittingModel() { + if (m_workerThread) { + if (m_workerThread->isRunning()) { + m_workerThread->wait(10); + } + } +} + +void EnggDiffGSASFittingModel::addFitResultsToMaps( + const RunLabel &runLabel, const double rwp, const double sigma, + const double gamma, const API::ITableWorkspace_sptr &latticeParams) { + addRwp(runLabel, rwp); + addSigma(runLabel, sigma); + addGamma(runLabel, gamma); + addLatticeParams(runLabel, latticeParams); +} + +void EnggDiffGSASFittingModel::addLatticeParams( + const RunLabel &runLabel, const API::ITableWorkspace_sptr &table) { + m_latticeParamsMap.add(runLabel, table); +} + +void EnggDiffGSASFittingModel::addGamma(const RunLabel &runLabel, + const double gamma) { + m_gammaMap.add(runLabel, gamma); +} + +void EnggDiffGSASFittingModel::addRwp(const RunLabel &runLabel, + const double rwp) { + m_rwpMap.add(runLabel, rwp); +} + +void EnggDiffGSASFittingModel::addSigma(const RunLabel &runLabel, + const double sigma) { + m_sigmaMap.add(runLabel, sigma); +} + +namespace { + +std::string generateFittedPeaksWSName(const RunLabel &runLabel) { + return runLabel.runNumber + "_" + std::to_string(runLabel.bank) + + "_gsasii_fitted_peaks"; +} + +std::string generateLatticeParamsName(const RunLabel &runLabel) { + return runLabel.runNumber + "_" + std::to_string(runLabel.bank) + + "_lattice_params"; +} +} // namespace + +std::pair<API::IAlgorithm_sptr, GSASIIRefineFitPeaksOutputProperties> +EnggDiffGSASFittingModel::doGSASRefinementAlgorithm( + const GSASIIRefineFitPeaksParameters ¶ms) { + auto gsasAlg = + API::AlgorithmManager::Instance().create("GSASIIRefineFitPeaks"); + + gsasAlg->setProperty("RefinementMethod", + refinementMethodToString(params.refinementMethod)); + gsasAlg->setProperty("InputWorkspace", params.inputWorkspace); + gsasAlg->setProperty("InstrumentFile", params.instParamsFile); + gsasAlg->setProperty("PhaseInfoFiles", + boost::algorithm::join(params.phaseFiles, ",")); + gsasAlg->setProperty("PathToGSASII", params.gsasHome); + + if (params.dMin) { + gsasAlg->setProperty("PawleyDMin", *(params.dMin)); + } + if (params.negativeWeight) { + gsasAlg->setProperty("PawleyNegativeWeight", *(params.negativeWeight)); + } + if (params.xMin) { + gsasAlg->setProperty("XMin", *(params.xMin)); + } + if (params.xMax) { + gsasAlg->setProperty("XMax", *(params.xMax)); + } + gsasAlg->setProperty("RefineSigma", params.refineSigma); + gsasAlg->setProperty("RefineGamma", params.refineGamma); + + const auto outputWSName = generateFittedPeaksWSName(params.runLabel); + const auto latticeParamsName = generateLatticeParamsName(params.runLabel); + gsasAlg->setProperty("OutputWorkspace", outputWSName); + gsasAlg->setProperty("LatticeParameters", latticeParamsName); + gsasAlg->setProperty("SaveGSASIIProjectFile", params.gsasProjectFile); + gsasAlg->execute(); + + const double rwp = gsasAlg->getProperty("Rwp"); + const double sigma = gsasAlg->getProperty("Sigma"); + const double gamma = gsasAlg->getProperty("Gamma"); + + API::AnalysisDataServiceImpl &ADS = API::AnalysisDataService::Instance(); + const auto fittedPeaks = ADS.retrieveWS<API::MatrixWorkspace>(outputWSName); + const auto latticeParams = + ADS.retrieveWS<API::ITableWorkspace>(latticeParamsName); + return std::make_pair(gsasAlg, GSASIIRefineFitPeaksOutputProperties( + rwp, sigma, gamma, fittedPeaks, + latticeParams, params.runLabel)); +} + +void EnggDiffGSASFittingModel::doRefinements( + const std::vector<GSASIIRefineFitPeaksParameters> ¶ms) { + m_workerThread = std::make_unique<QThread>(this); + EnggDiffGSASFittingWorker *worker = + new EnggDiffGSASFittingWorker(this, params); + worker->moveToThread(m_workerThread.get()); + + connect(m_workerThread.get(), SIGNAL(started()), worker, + SLOT(doRefinements())); + connect(worker, + SIGNAL(refinementSuccessful(Mantid::API::IAlgorithm_sptr, + GSASIIRefineFitPeaksOutputProperties)), + this, + SLOT(processRefinementSuccessful( + Mantid::API::IAlgorithm_sptr, + const GSASIIRefineFitPeaksOutputProperties &))); + connect(worker, + SIGNAL(refinementsComplete( + Mantid::API::IAlgorithm_sptr, + std::vector<GSASIIRefineFitPeaksOutputProperties>)), + this, + SLOT(processRefinementsComplete( + Mantid::API::IAlgorithm_sptr, + const std::vector<GSASIIRefineFitPeaksOutputProperties> &))); + connect(worker, SIGNAL(refinementFailed(const std::string &)), this, + SLOT(processRefinementFailed(const std::string &))); + connect(worker, SIGNAL(refinementCancelled()), this, + SLOT(processRefinementCancelled())); + connect(m_workerThread.get(), SIGNAL(finished()), m_workerThread.get(), + SLOT(deleteLater())); + connect(worker, + SIGNAL(refinementSuccessful(Mantid::API::IAlgorithm_sptr, + GSASIIRefineFitPeaksOutputProperties)), + worker, SLOT(deleteLater())); + connect(worker, SIGNAL(refinementFailed(const std::string &)), worker, + SLOT(deleteLater())); + m_workerThread->start(); +} + +boost::optional<API::ITableWorkspace_sptr> +EnggDiffGSASFittingModel::getLatticeParams(const RunLabel &runLabel) const { + return getFromRunMapOptional(m_latticeParamsMap, runLabel); +} + +boost::optional<double> +EnggDiffGSASFittingModel::getGamma(const RunLabel &runLabel) const { + return getFromRunMapOptional(m_gammaMap, runLabel); +} + +boost::optional<double> +EnggDiffGSASFittingModel::getRwp(const RunLabel &runLabel) const { + return getFromRunMapOptional(m_rwpMap, runLabel); +} + +boost::optional<double> +EnggDiffGSASFittingModel::getSigma(const RunLabel &runLabel) const { + return getFromRunMapOptional(m_sigmaMap, runLabel); +} + +bool EnggDiffGSASFittingModel::hasFitResultsForRun( + const RunLabel &runLabel) const { + return m_rwpMap.contains(runLabel) && m_sigmaMap.contains(runLabel) && + m_gammaMap.contains(runLabel); +} + +Mantid::API::MatrixWorkspace_sptr +EnggDiffGSASFittingModel::loadFocusedRun(const std::string &filename) const { + const auto wsName = stripWSNameFromFilename(filename); + + auto loadAlg = API::AlgorithmManager::Instance().create("Load"); + loadAlg->setProperty("Filename", filename); + loadAlg->setProperty("OutputWorkspace", wsName); + loadAlg->execute(); + + API::AnalysisDataServiceImpl &ADS = API::AnalysisDataService::Instance(); + auto wsTest = ADS.retrieveWS<API::Workspace>(wsName); + const auto ws = boost::dynamic_pointer_cast<API::MatrixWorkspace>(wsTest); + if (!ws) { + throw std::invalid_argument( + "Invalid Workspace loaded, are you sure it has been focused?"); + } + return ws; +} + +void EnggDiffGSASFittingModel::processRefinementsComplete( + Mantid::API::IAlgorithm_sptr alg, + const std::vector<GSASIIRefineFitPeaksOutputProperties> + &refinementResultSets) { + m_observer->notifyRefinementsComplete(std::move(alg), refinementResultSets); +} + +void EnggDiffGSASFittingModel::processRefinementFailed( + const std::string &failureMessage) { + if (m_observer) { + m_observer->notifyRefinementFailed(failureMessage); + } +} + +void EnggDiffGSASFittingModel::processRefinementSuccessful( + API::IAlgorithm_sptr successfulAlgorithm, + const GSASIIRefineFitPeaksOutputProperties &refinementResults) { + addFitResultsToMaps(refinementResults.runLabel, refinementResults.rwp, + refinementResults.sigma, refinementResults.gamma, + refinementResults.latticeParamsWS); + if (m_observer) { + m_observer->notifyRefinementSuccessful(std::move(successfulAlgorithm), + refinementResults); + } +} + +void EnggDiffGSASFittingModel::processRefinementCancelled() { + if (m_observer) { + m_observer->notifyRefinementCancelled(); + } +} + +void EnggDiffGSASFittingModel::saveRefinementResultsToHDF5( + const Mantid::API::IAlgorithm_sptr successfulAlg, + const std::vector<GSASIIRefineFitPeaksOutputProperties> + &refinementResultSets, + const std::string &filename) const { + auto saveAlg = API::AlgorithmManager::Instance().create( + "EnggSaveGSASIIFitResultsToHDF5"); + + const auto numRuns = refinementResultSets.size(); + std::vector<std::string> latticeParamWSNames; + latticeParamWSNames.reserve(numRuns); + std::vector<std::string> runNumbers; + runNumbers.reserve(numRuns); + std::vector<long> bankIDs; + bankIDs.reserve(numRuns); + std::vector<double> sigmas; + sigmas.reserve(numRuns); + std::vector<double> gammas; + gammas.reserve(numRuns); + std::vector<double> rwps; + rwps.reserve(numRuns); + + const bool refineSigma = successfulAlg->getProperty("RefineSigma"); + saveAlg->setProperty("RefineSigma", refineSigma); + const bool refineGamma = successfulAlg->getProperty("RefineGamma"); + saveAlg->setProperty("RefineGamma", refineGamma); + + for (const auto &refinementResults : refinementResultSets) { + const auto &runLabel = refinementResults.runLabel; + const auto latticeParams = *getLatticeParams(runLabel); + + latticeParamWSNames.emplace_back(latticeParams->getName()); + runNumbers.emplace_back(runLabel.runNumber); + bankIDs.emplace_back(static_cast<long>(runLabel.bank)); + rwps.emplace_back(refinementResults.rwp); + + if (refineSigma) { + sigmas.emplace_back(refinementResults.sigma); + } + if (refineGamma) { + gammas.emplace_back(refinementResults.gamma); + } + } + + saveAlg->setProperty("LatticeParamWorkspaces", latticeParamWSNames); + saveAlg->setProperty("BankIDs", bankIDs); + saveAlg->setProperty("RunNumbers", runNumbers); + + const std::string refinementMethod = + successfulAlg->getProperty("RefinementMethod"); + saveAlg->setProperty("RefinementMethod", refinementMethod); + saveAlg->setProperty("XMin", successfulAlg->getPropertyValue("XMin")); + saveAlg->setProperty("XMax", successfulAlg->getPropertyValue("XMax")); + + if (refinementMethod == "Pawley refinement") { + saveAlg->setProperty("PawleyDMin", + successfulAlg->getPropertyValue("PawleyDMin")); + saveAlg->setProperty( + "PawleyNegativeWeight", + successfulAlg->getPropertyValue("PawleyNegativeWeight")); + } + + if (refineSigma) { + saveAlg->setProperty("Sigma", sigmas); + } + + if (refineGamma) { + saveAlg->setProperty("Gamma", gammas); + } + + saveAlg->setProperty("Rwp", rwps); + saveAlg->setProperty("Filename", filename); + saveAlg->execute(); +} + +void EnggDiffGSASFittingModel::setObserver( + boost::shared_ptr<IEnggDiffGSASFittingObserver> observer) { + m_observer = observer; +} + +} // namespace CustomInterfaces +} // namespace MantidQt diff --git a/qt/scientific_interfaces/EnggDiffraction/EnggDiffGSASFittingModel.h b/qt/scientific_interfaces/EnggDiffraction/EnggDiffGSASFittingModel.h new file mode 100644 index 0000000000000000000000000000000000000000..b8efb449f66462484d2220e6e779c25f9e698aae --- /dev/null +++ b/qt/scientific_interfaces/EnggDiffraction/EnggDiffGSASFittingModel.h @@ -0,0 +1,132 @@ +// Mantid Repository : https://github.com/mantidproject/mantid +// +// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI, +// NScD Oak Ridge National Laboratory, European Spallation Source +// & Institut Laue - Langevin +// SPDX - License - Identifier: GPL - 3.0 + +#pragma once + +#include "DllConfig.h" +#include "EnggDiffGSASFittingWorker.h" +#include "GSASIIRefineFitPeaksOutputProperties.h" +#include "IEnggDiffGSASFittingModel.h" +#include "IEnggDiffGSASFittingObserver.h" +#include "RunMap.h" + +#include "MantidAPI/IAlgorithm_fwd.h" + +#include <QObject> +#include <QThread> + +namespace MantidQt { +namespace CustomInterfaces { + +class MANTIDQT_ENGGDIFFRACTION_DLL EnggDiffGSASFittingModel + : public QObject, // Must be a QObject to run GSASIIRefineFitPeaksWorker + // asynchronously + public IEnggDiffGSASFittingModel { + Q_OBJECT + + friend void EnggDiffGSASFittingWorker::doRefinements(); + +public: + EnggDiffGSASFittingModel(); + + ~EnggDiffGSASFittingModel(); + + void setObserver( + boost::shared_ptr<IEnggDiffGSASFittingObserver> observer) override; + + void doRefinements( + const std::vector<GSASIIRefineFitPeaksParameters> ¶ms) override; + + boost::optional<Mantid::API::ITableWorkspace_sptr> + getLatticeParams(const RunLabel &runLabel) const override; + + boost::optional<double> getGamma(const RunLabel &runLabel) const override; + + boost::optional<double> getRwp(const RunLabel &runLabel) const override; + + boost::optional<double> getSigma(const RunLabel &runLabel) const override; + + bool hasFitResultsForRun(const RunLabel &runLabel) const override; + + Mantid::API::MatrixWorkspace_sptr + loadFocusedRun(const std::string &filename) const override; + + void saveRefinementResultsToHDF5( + const Mantid::API::IAlgorithm_sptr successfulAlgorithm, + const std::vector<GSASIIRefineFitPeaksOutputProperties> + &refinementResultSets, + const std::string &filename) const override; + +protected: + /// The following methods are marked as protected so that they can be exposed + /// by a helper class in the tests + + /// Add a lattice parameter table to the map + void addLatticeParams(const RunLabel &runLabel, + const Mantid::API::ITableWorkspace_sptr &table); + + /// Add a gamma value to the gamma map + void addGamma(const RunLabel &runLabel, const double gamma); + + /// Add an rwp value to the rwp map + void addRwp(const RunLabel &runLabel, const double rwp); + + /// Add a sigma value to the sigma map + void addSigma(const RunLabel &runLabel, const double sigma); + +protected slots: + void processRefinementsComplete( + Mantid::API::IAlgorithm_sptr alg, + const std::vector<GSASIIRefineFitPeaksOutputProperties> + &refinementResultSets); + + void processRefinementFailed(const std::string &failureMessage); + + void processRefinementSuccessful( + Mantid::API::IAlgorithm_sptr successfulAlgorithm, + const GSASIIRefineFitPeaksOutputProperties &refinementResults); + + void processRefinementCancelled(); + +private: + static constexpr double DEFAULT_PAWLEY_DMIN = 1; + static constexpr double DEFAULT_PAWLEY_NEGATIVE_WEIGHT = 0; + static const size_t MAX_BANKS = 3; + + RunMap<MAX_BANKS, double> m_gammaMap; + RunMap<MAX_BANKS, Mantid::API::ITableWorkspace_sptr> m_latticeParamsMap; + RunMap<MAX_BANKS, double> m_rwpMap; + RunMap<MAX_BANKS, double> m_sigmaMap; + + boost::shared_ptr<IEnggDiffGSASFittingObserver> m_observer; + + std::unique_ptr<QThread> m_workerThread; + + /// Add Rwp, sigma, gamma and lattice params table to their + /// respective RunMaps + void + addFitResultsToMaps(const RunLabel &runLabel, const double rwp, + const double sigma, const double gamma, + const Mantid::API::ITableWorkspace_sptr &latticeParams); + + void deleteWorkerThread(); + + /// Run GSASIIRefineFitPeaks + std::pair<Mantid::API::IAlgorithm_sptr, GSASIIRefineFitPeaksOutputProperties> + doGSASRefinementAlgorithm(const GSASIIRefineFitPeaksParameters ¶ms); + + template <typename T> + boost::optional<T> getFromRunMapOptional(const RunMap<MAX_BANKS, T> &map, + const RunLabel &runLabel) const { + if (map.contains(runLabel)) { + return map.get(runLabel); + } + return boost::none; + } +}; + +} // namespace CustomInterfaces +} // namespace MantidQt diff --git a/qt/scientific_interfaces/EnggDiffraction/EnggDiffGSASFittingPresenter.cpp b/qt/scientific_interfaces/EnggDiffraction/EnggDiffGSASFittingPresenter.cpp new file mode 100644 index 0000000000000000000000000000000000000000..7c536da040a59dc10980d1c83331461c12113d34 --- /dev/null +++ b/qt/scientific_interfaces/EnggDiffraction/EnggDiffGSASFittingPresenter.cpp @@ -0,0 +1,301 @@ +// Mantid Repository : https://github.com/mantidproject/mantid +// +// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI, +// NScD Oak Ridge National Laboratory, European Spallation Source +// & Institut Laue - Langevin +// SPDX - License - Identifier: GPL - 3.0 + +#include "EnggDiffGSASFittingPresenter.h" + +#include <utility> + +#include "EnggDiffGSASRefinementMethod.h" +#include "MantidQtWidgets/Plotting/Qwt/QwtHelper.h" + +namespace { + +std::string addRunNumberToGSASIIProjectFile( + const std::string &filename, + const MantidQt::CustomInterfaces::RunLabel &runLabel) { + const auto dotPosition = filename.find_last_of("."); + return filename.substr(0, dotPosition) + "_" + runLabel.runNumber + "_" + + std::to_string(runLabel.bank) + + filename.substr(dotPosition, filename.length()); +} + +} // anonymous namespace + +namespace MantidQt { +namespace CustomInterfaces { + +EnggDiffGSASFittingPresenter::EnggDiffGSASFittingPresenter( + std::unique_ptr<IEnggDiffGSASFittingModel> model, + IEnggDiffGSASFittingView *view, + boost::shared_ptr<IEnggDiffMultiRunFittingWidgetPresenter> multiRunWidget, + boost::shared_ptr<IEnggDiffractionParam> mainSettings) + : m_model(std::move(model)), m_multiRunWidget(std::move(multiRunWidget)), + m_mainSettings(std::move(mainSettings)), m_view(view), + m_viewHasClosed(false) {} + +EnggDiffGSASFittingPresenter::~EnggDiffGSASFittingPresenter() {} + +void EnggDiffGSASFittingPresenter::notify( + IEnggDiffGSASFittingPresenter::Notification notif) { + + if (m_viewHasClosed) { + return; + } + + switch (notif) { + + case IEnggDiffGSASFittingPresenter::DoRefinement: + processDoRefinement(); + break; + + case IEnggDiffGSASFittingPresenter::LoadRun: + processLoadRun(); + break; + + case IEnggDiffGSASFittingPresenter::RefineAll: + processRefineAll(); + break; + + case IEnggDiffGSASFittingPresenter::SelectRun: + processSelectRun(); + break; + + case IEnggDiffGSASFittingPresenter::Start: + processStart(); + break; + + case IEnggDiffGSASFittingPresenter::ShutDown: + processShutDown(); + break; + } +} + +std::vector<GSASIIRefineFitPeaksParameters> +EnggDiffGSASFittingPresenter::collectAllInputParameters() const { + const auto runLabels = m_multiRunWidget->getAllRunLabels(); + std::vector<GSASIIRefineFitPeaksParameters> inputParams; + std::vector<std::string> GSASIIProjectFiles; + inputParams.reserve(runLabels.size()); + + const auto refinementMethod = m_view->getRefinementMethod(); + const auto instParamFile = m_view->getInstrumentFileName(); + const auto phaseFiles = m_view->getPhaseFileNames(); + const auto pathToGSASII = m_view->getPathToGSASII(); + const auto GSASIIProjectFile = m_view->getGSASIIProjectPath(); + if (runLabels.size() == 1) { + GSASIIProjectFiles = std::vector<std::string>({GSASIIProjectFile}); + } else { + GSASIIProjectFiles.reserve(runLabels.size()); + for (const auto &runLabel : runLabels) { + GSASIIProjectFiles.emplace_back( + addRunNumberToGSASIIProjectFile(GSASIIProjectFile, runLabel)); + } + } + + const auto dMin = m_view->getPawleyDMin(); + const auto negativeWeight = m_view->getPawleyNegativeWeight(); + const auto xMin = m_view->getXMin(); + const auto xMax = m_view->getXMax(); + const auto refineSigma = m_view->getRefineSigma(); + const auto refineGamma = m_view->getRefineGamma(); + + for (size_t i = 0; i < runLabels.size(); i++) { + const auto &runLabel = runLabels[i]; + const auto inputWS = *(m_multiRunWidget->getFocusedRun(runLabel)); + + inputParams.emplace_back(inputWS, runLabel, refinementMethod, instParamFile, + phaseFiles, pathToGSASII, GSASIIProjectFiles[i], + dMin, negativeWeight, xMin, xMax, refineSigma, + refineGamma); + } + return inputParams; +} + +GSASIIRefineFitPeaksParameters +EnggDiffGSASFittingPresenter::collectInputParameters( + const RunLabel &runLabel, + const Mantid::API::MatrixWorkspace_sptr &inputWS) const { + const auto refinementMethod = m_view->getRefinementMethod(); + const auto instParamFile = m_view->getInstrumentFileName(); + const auto phaseFiles = m_view->getPhaseFileNames(); + const auto pathToGSASII = m_view->getPathToGSASII(); + const auto GSASIIProjectFile = m_view->getGSASIIProjectPath(); + + const auto dMin = m_view->getPawleyDMin(); + const auto negativeWeight = m_view->getPawleyNegativeWeight(); + const auto xMin = m_view->getXMin(); + const auto xMax = m_view->getXMax(); + const auto refineSigma = m_view->getRefineSigma(); + const auto refineGamma = m_view->getRefineGamma(); + + return GSASIIRefineFitPeaksParameters(inputWS, runLabel, refinementMethod, + instParamFile, phaseFiles, pathToGSASII, + GSASIIProjectFile, dMin, negativeWeight, + xMin, xMax, refineSigma, refineGamma); +} + +void EnggDiffGSASFittingPresenter::displayFitResults(const RunLabel &runLabel) { + const auto latticeParams = m_model->getLatticeParams(runLabel); + const auto rwp = m_model->getRwp(runLabel); + const auto sigma = m_model->getSigma(runLabel); + const auto gamma = m_model->getGamma(runLabel); + + if (!latticeParams || !rwp || !sigma || !gamma) { + m_view->userError("Invalid run identifier", + "Unexpectedly tried to display fit results for invalid " + "run, run number = " + + runLabel.runNumber + + ", bank ID = " + std::to_string(runLabel.bank) + + ". Please contact the development team"); + return; + } + + m_view->displayLatticeParams(*latticeParams); + m_view->displayRwp(*rwp); + m_view->displaySigma(*sigma); + m_view->displayGamma(*gamma); +} + +void EnggDiffGSASFittingPresenter::doRefinements( + const std::vector<GSASIIRefineFitPeaksParameters> ¶ms) { + m_model->doRefinements(params); +} + +void EnggDiffGSASFittingPresenter::notifyRefinementsComplete( + Mantid::API::IAlgorithm_sptr alg, + const std::vector<GSASIIRefineFitPeaksOutputProperties> + &refinementResultSets) { + if (!m_viewHasClosed) { + const auto numRuns = refinementResultSets.size(); + + if (numRuns > 1) { + std::vector<RunLabel> runLabels; + runLabels.reserve(numRuns); + for (const auto &refinementResults : refinementResultSets) { + runLabels.emplace_back(refinementResults.runLabel); + } + m_model->saveRefinementResultsToHDF5( + alg, refinementResultSets, + m_mainSettings->userHDFMultiRunFilename(runLabels)); + } + + m_view->setEnabled(true); + m_view->showStatus("Ready"); + } +} + +void EnggDiffGSASFittingPresenter::notifyRefinementCancelled() { + if (!m_viewHasClosed) { + m_view->setEnabled(true); + m_view->showStatus("Ready"); + } +} + +void EnggDiffGSASFittingPresenter::notifyRefinementFailed( + const std::string &failureMessage) { + if (!m_viewHasClosed) { + m_view->setEnabled(true); + m_view->userWarning("Refinement failed", failureMessage); + m_view->showStatus("Refinement failed"); + } +} + +void EnggDiffGSASFittingPresenter::notifyRefinementSuccessful( + const Mantid::API::IAlgorithm_sptr successfulAlgorithm, + const GSASIIRefineFitPeaksOutputProperties &refinementResults) { + if (!m_viewHasClosed) { + m_view->showStatus("Saving refinement results"); + const auto filename = m_mainSettings->userHDFRunFilename( + refinementResults.runLabel.runNumber); + + try { + m_model->saveRefinementResultsToHDF5(successfulAlgorithm, + {refinementResults}, filename); + } catch (std::exception &e) { + m_view->userWarning( + "Could not save refinement results", + std::string("Refinement was successful but saving results to " + "HDF5 failed for the following reason:\n") + + e.what()); + } + m_view->setEnabled(true); + m_view->showStatus("Ready"); + + m_multiRunWidget->addFittedPeaks(refinementResults.runLabel, + refinementResults.fittedPeaksWS); + displayFitResults(refinementResults.runLabel); + } +} + +void EnggDiffGSASFittingPresenter::processDoRefinement() { + const auto runLabel = m_multiRunWidget->getSelectedRunLabel(); + if (!runLabel) { + m_view->userWarning("No run selected", + "Please select a run to do refinement on"); + return; + } + + const auto inputWSOptional = m_multiRunWidget->getFocusedRun(*runLabel); + if (!inputWSOptional) { + m_view->userError( + "Invalid run selected for refinement", + "Tried to run refinement on invalid focused run, run number " + + runLabel->runNumber + " and bank ID " + + std::to_string(runLabel->bank) + + ". Please contact the development team with this message"); + return; + } + + m_view->showStatus("Refining run"); + const auto refinementParams = + collectInputParameters(*runLabel, *inputWSOptional); + + m_view->setEnabled(false); + doRefinements({refinementParams}); +} + +void EnggDiffGSASFittingPresenter::processLoadRun() { + const auto focusedFileNames = m_view->getFocusedFileNames(); + + try { + for (const auto fileName : focusedFileNames) { + const auto focusedRun = m_model->loadFocusedRun(fileName); + m_multiRunWidget->addFocusedRun(focusedRun); + } + } catch (const std::exception &ex) { + m_view->userWarning("Could not load file", ex.what()); + } +} + +void EnggDiffGSASFittingPresenter::processRefineAll() { + const auto refinementParams = collectAllInputParameters(); + if (refinementParams.size() == 0) { + m_view->userWarning("No runs loaded", + "Please load at least one run before refining"); + return; + } + m_view->showStatus("Refining run"); + m_view->setEnabled(false); + doRefinements(refinementParams); +} + +void EnggDiffGSASFittingPresenter::processSelectRun() { + const auto runLabel = m_multiRunWidget->getSelectedRunLabel(); + if (runLabel && m_model->hasFitResultsForRun(*runLabel)) { + displayFitResults(*runLabel); + } +} + +void EnggDiffGSASFittingPresenter::processStart() { + auto addMultiRunWidget = m_multiRunWidget->getWidgetAdder(); + (*addMultiRunWidget)(*m_view); + m_view->showStatus("Ready"); +} + +void EnggDiffGSASFittingPresenter::processShutDown() { m_viewHasClosed = true; } + +} // namespace CustomInterfaces +} // namespace MantidQt diff --git a/qt/scientific_interfaces/EnggDiffraction/EnggDiffGSASFittingPresenter.h b/qt/scientific_interfaces/EnggDiffraction/EnggDiffGSASFittingPresenter.h new file mode 100644 index 0000000000000000000000000000000000000000..6b0c930826551fe71203399969777a0f724f5aaf --- /dev/null +++ b/qt/scientific_interfaces/EnggDiffraction/EnggDiffGSASFittingPresenter.h @@ -0,0 +1,100 @@ +// Mantid Repository : https://github.com/mantidproject/mantid +// +// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI, +// NScD Oak Ridge National Laboratory, European Spallation Source +// & Institut Laue - Langevin +// SPDX - License - Identifier: GPL - 3.0 + +#pragma once + +#include "DllConfig.h" +#include "GSASIIRefineFitPeaksOutputProperties.h" +#include "IEnggDiffGSASFittingModel.h" +#include "IEnggDiffGSASFittingPresenter.h" +#include "IEnggDiffGSASFittingView.h" +#include "IEnggDiffMultiRunFittingWidgetPresenter.h" +#include "IEnggDiffractionParam.h" + +#include "MantidAPI/MatrixWorkspace_fwd.h" + +#include <boost/shared_ptr.hpp> +#include <memory> + +namespace MantidQt { +namespace CustomInterfaces { + +// needs to be dll-exported for the tests +class MANTIDQT_ENGGDIFFRACTION_DLL EnggDiffGSASFittingPresenter + : public IEnggDiffGSASFittingPresenter { + +public: + EnggDiffGSASFittingPresenter( + std::unique_ptr<IEnggDiffGSASFittingModel> model, + IEnggDiffGSASFittingView *view, + boost::shared_ptr<IEnggDiffMultiRunFittingWidgetPresenter> multiRunWidget, + boost::shared_ptr<IEnggDiffractionParam> mainSettings); + + EnggDiffGSASFittingPresenter(EnggDiffGSASFittingPresenter &&other) = default; + + EnggDiffGSASFittingPresenter & + operator=(EnggDiffGSASFittingPresenter &&other) = default; + + ~EnggDiffGSASFittingPresenter() override; + + void notify(IEnggDiffGSASFittingPresenter::Notification notif) override; + + void notifyRefinementsComplete( + Mantid::API::IAlgorithm_sptr alg, + const std::vector<GSASIIRefineFitPeaksOutputProperties> + &refinementResultSets) override; + + void notifyRefinementSuccessful( + const Mantid::API::IAlgorithm_sptr successfulAlgorithm, + const GSASIIRefineFitPeaksOutputProperties &refinementResults) override; + + void notifyRefinementFailed(const std::string &failureMessage) override; + + void notifyRefinementCancelled() override; + +private: + void processDoRefinement(); + void processLoadRun(); + void processRefineAll(); + void processSelectRun(); + void processShutDown(); + void processStart(); + + /// Collect GSASIIRefineFitPeaks parameters for all runs loaded in + std::vector<GSASIIRefineFitPeaksParameters> collectAllInputParameters() const; + + /// Collect GSASIIRefineFitPeaks input parameters for a given run from the + /// presenter's various children + GSASIIRefineFitPeaksParameters + collectInputParameters(const RunLabel &runLabel, + const Mantid::API::MatrixWorkspace_sptr &ws) const; + + /** + Perform refinements on a number of runs + @param params Input parameters for each run to pass to GSASIIRefineFitPeaks + */ + void doRefinements(const std::vector<GSASIIRefineFitPeaksParameters> ¶ms); + + /** + Overplot fitted peaks for a run, and display lattice parameters and Rwp in + the view + @param runLabel Run number and bank ID of the run to display + */ + void displayFitResults(const RunLabel &runLabel); + + std::unique_ptr<IEnggDiffGSASFittingModel> m_model; + + boost::shared_ptr<IEnggDiffMultiRunFittingWidgetPresenter> m_multiRunWidget; + + boost::shared_ptr<IEnggDiffractionParam> m_mainSettings; + + IEnggDiffGSASFittingView *m_view; + + bool m_viewHasClosed; +}; + +} // namespace CustomInterfaces +} // namespace MantidQt diff --git a/qt/scientific_interfaces/EnggDiffraction/EnggDiffGSASFittingViewQtWidget.cpp b/qt/scientific_interfaces/EnggDiffraction/EnggDiffGSASFittingViewQtWidget.cpp new file mode 100644 index 0000000000000000000000000000000000000000..c3f88619fe05879a7f1e65c42b426b3b7a7e90f0 --- /dev/null +++ b/qt/scientific_interfaces/EnggDiffraction/EnggDiffGSASFittingViewQtWidget.cpp @@ -0,0 +1,389 @@ +// Mantid Repository : https://github.com/mantidproject/mantid +// +// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI, +// NScD Oak Ridge National Laboratory, European Spallation Source +// & Institut Laue - Langevin +// SPDX - License - Identifier: GPL - 3.0 + +#include "EnggDiffGSASFittingViewQtWidget.h" +#include "EnggDiffGSASFittingModel.h" +#include "EnggDiffGSASFittingPresenter.h" +#include "EnggDiffMultiRunFittingQtWidget.h" +#include "EnggDiffMultiRunFittingWidgetModel.h" +#include "EnggDiffMultiRunFittingWidgetPresenter.h" + +#include "MantidAPI/TableRow.h" + +#include <QFileDialog> +#include <QSettings> +#include <boost/make_shared.hpp> +#include <utility> + +namespace MantidQt { +namespace CustomInterfaces { + +EnggDiffGSASFittingViewQtWidget::EnggDiffGSASFittingViewQtWidget( + boost::shared_ptr<IEnggDiffractionUserMsg> userMessageProvider, + const boost::shared_ptr<IEnggDiffractionPythonRunner> &pythonRunner, + boost::shared_ptr<IEnggDiffractionParam> mainSettings) + : m_userMessageProvider(std::move(userMessageProvider)) { + + auto multiRunWidgetModel = + std::make_unique<EnggDiffMultiRunFittingWidgetModel>(); + m_multiRunWidgetView = + std::make_unique<EnggDiffMultiRunFittingQtWidget>(pythonRunner); + + auto multiRunWidgetPresenter = + boost::make_shared<EnggDiffMultiRunFittingWidgetPresenter>( + std::move(multiRunWidgetModel), m_multiRunWidgetView.get()); + + m_multiRunWidgetView->setPresenter(multiRunWidgetPresenter); + m_multiRunWidgetView->setMessageProvider(m_userMessageProvider); + + setupUI(); + + auto model = std::make_unique<EnggDiffGSASFittingModel>(); + auto *model_ptr = model.get(); + m_presenter = boost::make_shared<EnggDiffGSASFittingPresenter>( + std::move(model), this, multiRunWidgetPresenter, mainSettings); + model_ptr->setObserver(m_presenter); + m_presenter->notify(IEnggDiffGSASFittingPresenter::Start); +} + +EnggDiffGSASFittingViewQtWidget::~EnggDiffGSASFittingViewQtWidget() { + QSettings settings(tr(SETTINGS_NAME)); + const auto gsasHome = m_ui.lineEdit_gsasHome->text(); + settings.setValue(tr(GSAS_HOME_SETTING_NAME), gsasHome); + + m_presenter->notify(IEnggDiffGSASFittingPresenter::ShutDown); +} + +void EnggDiffGSASFittingViewQtWidget::addWidget( + IEnggDiffMultiRunFittingWidgetView *widget) { + auto *qWidget = dynamic_cast<QWidget *>(widget); + m_ui.gridLayout_multiRunWidget->addWidget(qWidget, 0, 0); +} + +void EnggDiffGSASFittingViewQtWidget::browseFocusedRun() { + const auto filenames( + QFileDialog::getOpenFileNames(this, tr("Find focused run files"))); + setFocusedRunFileNames(filenames); +} + +void EnggDiffGSASFittingViewQtWidget::browseGSASHome() { + auto directoryName(QFileDialog::getExistingDirectory( + this, tr("GSAS-II installation directory"))); + m_ui.lineEdit_gsasHome->setText(directoryName); +} + +void EnggDiffGSASFittingViewQtWidget::browseGSASProj() { + auto filename(QFileDialog::getSaveFileName( + this, tr("Output GSAS-II project file"), "", "GSAS-II Project (*.gpx)")); + if (!filename.endsWith(".gpx")) { + filename.append(".gpx"); + } + m_ui.lineEdit_gsasProjPath->setText(filename); +} + +void EnggDiffGSASFittingViewQtWidget::browseInstParams() { + const auto filename( + QFileDialog::getOpenFileName(this, tr("Instrument parameter file"), "", + "Instrument parameter file (*.par *.prm)")); + m_ui.lineEdit_instParamsFile->setText(filename); +} + +void EnggDiffGSASFittingViewQtWidget::browsePhaseFiles() { + const auto filenames(QFileDialog::getOpenFileNames( + this, tr("Phase files"), "", "Phase files (*.cif)")); + m_ui.lineEdit_phaseFiles->setText(filenames.join(tr(","))); +} + +void EnggDiffGSASFittingViewQtWidget::disableLoadIfInputEmpty() { + setLoadEnabled(!runFileLineEditEmpty()); +} + +void EnggDiffGSASFittingViewQtWidget::displayLatticeParams( + const Mantid::API::ITableWorkspace_sptr latticeParams) const { + double length_a, length_b, length_c, angle_alpha, angle_beta, angle_gamma; + Mantid::API::TableRow row = latticeParams->getFirstRow(); + row >> length_a >> length_b >> length_c >> angle_alpha >> angle_beta >> + angle_gamma; + m_ui.lineEdit_latticeParamA->setText(QString::number(length_a)); + m_ui.lineEdit_latticeParamB->setText(QString::number(length_b)); + m_ui.lineEdit_latticeParamC->setText(QString::number(length_c)); + m_ui.lineEdit_latticeParamAlpha->setText(QString::number(angle_alpha)); + m_ui.lineEdit_latticeParamBeta->setText(QString::number(angle_beta)); + m_ui.lineEdit_latticeParamGamma->setText(QString::number(angle_gamma)); +} + +void EnggDiffGSASFittingViewQtWidget::displayGamma(const double gamma) const { + m_ui.lineEdit_gamma->setText(QString::number(gamma)); +} + +void EnggDiffGSASFittingViewQtWidget::displayRwp(const double rwp) const { + m_ui.lineEdit_rwp->setText(QString::number(rwp)); +} + +void EnggDiffGSASFittingViewQtWidget::displaySigma(const double sigma) const { + m_ui.lineEdit_sigma->setText(QString::number(sigma)); +} + +void EnggDiffGSASFittingViewQtWidget::doRefinement() { + m_presenter->notify(IEnggDiffGSASFittingPresenter::DoRefinement); +} + +std::vector<std::string> +EnggDiffGSASFittingViewQtWidget::getFocusedFileNames() const { + const auto filenamesQStringList = m_ui.lineEdit_runFile->text().split(","); + std::vector<std::string> filenames; + filenames.reserve(filenamesQStringList.size()); + for (const auto &filenameQString : filenamesQStringList) { + filenames.emplace_back(filenameQString.toStdString()); + } + return filenames; +} + +std::string EnggDiffGSASFittingViewQtWidget::getGSASIIProjectPath() const { + return m_ui.lineEdit_gsasProjPath->text().toStdString(); +} + +std::string EnggDiffGSASFittingViewQtWidget::getInstrumentFileName() const { + return m_ui.lineEdit_instParamsFile->text().toStdString(); +} + +std::string EnggDiffGSASFittingViewQtWidget::getPathToGSASII() const { + return m_ui.lineEdit_gsasHome->text().toStdString(); +} + +boost::optional<double> EnggDiffGSASFittingViewQtWidget::getPawleyDMin() const { + const auto pawleyDMinString = m_ui.lineEdit_pawleyDMin->text(); + if (pawleyDMinString.isEmpty()) { + return boost::none; + } + + bool conversionSuccessful(false); + const auto pawleyDMin = pawleyDMinString.toDouble(&conversionSuccessful); + if (!conversionSuccessful) { + userWarning("Invalid Pawley DMin", "Invalid entry for Pawley DMin \"" + + pawleyDMinString.toStdString() + + "\". Using default"); + return boost::none; + } + + return pawleyDMin; +} + +boost::optional<double> +EnggDiffGSASFittingViewQtWidget::getPawleyNegativeWeight() const { + const auto pawleyNegWeightString = m_ui.lineEdit_pawleyNegativeWeight->text(); + if (pawleyNegWeightString.isEmpty()) { + return boost::none; + } + + bool conversionSuccessful(false); + const auto pawleyNegWeight = + pawleyNegWeightString.toDouble(&conversionSuccessful); + if (!conversionSuccessful) { + userWarning("Invalid Pawley negative weight", + "Invalid entry for negative weight \"" + + pawleyNegWeightString.toStdString() + "\". Using default"); + return boost::none; + } + + return pawleyNegWeight; +} + +std::vector<std::string> +EnggDiffGSASFittingViewQtWidget::getPhaseFileNames() const { + std::vector<std::string> fileNameStrings; + const auto fileNameQStrings = m_ui.lineEdit_phaseFiles->text().split(","); + fileNameStrings.reserve(fileNameQStrings.size()); + for (const auto &fileNameQString : fileNameQStrings) { + fileNameStrings.emplace_back(fileNameQString.toStdString()); + } + return fileNameStrings; +} + +bool EnggDiffGSASFittingViewQtWidget::getRefineGamma() const { + return m_ui.checkBox_refineGamma->isChecked(); +} + +bool EnggDiffGSASFittingViewQtWidget::getRefineSigma() const { + return m_ui.checkBox_refineSigma->isChecked(); +} + +GSASRefinementMethod +EnggDiffGSASFittingViewQtWidget::getRefinementMethod() const { + const auto refinementMethod = + m_ui.comboBox_refinementMethod->currentText().toStdString(); + if (refinementMethod == "Pawley") { + return GSASRefinementMethod::PAWLEY; + } else if (refinementMethod == "Rietveld") { + return GSASRefinementMethod::RIETVELD; + } else { + userError("Unexpected refinement method", + "Unexpected refinement method \"" + refinementMethod + + "\" selected. Please contact development team with this " + "message. If you choose to continue, Pawley will be used"); + return GSASRefinementMethod::PAWLEY; + } +} + +boost::optional<double> EnggDiffGSASFittingViewQtWidget::getXMax() const { + const auto xMaxString = m_ui.lineEdit_xMax->text(); + if (xMaxString.isEmpty()) { + return boost::none; + } + + bool conversionSuccessful(false); + const auto xMax = xMaxString.toDouble(&conversionSuccessful); + if (!conversionSuccessful) { + userWarning("Invalid XMax", "Invalid entry for XMax \"" + + xMaxString.toStdString() + + "\". Using default"); + return boost::none; + } + + return xMax; +} + +boost::optional<double> EnggDiffGSASFittingViewQtWidget::getXMin() const { + const auto xMinString = m_ui.lineEdit_xMin->text(); + if (xMinString.isEmpty()) { + return boost::none; + } + + bool conversionSuccessful(false); + const auto xMin = xMinString.toDouble(&conversionSuccessful); + if (!conversionSuccessful) { + userWarning("Invalid XMin", "Invalid entry for XMin \"" + + xMinString.toStdString() + + "\". Using default"); + return boost::none; + } + + return xMin; +} + +void EnggDiffGSASFittingViewQtWidget::loadFocusedRun() { + m_presenter->notify(IEnggDiffGSASFittingPresenter::LoadRun); +} + +void EnggDiffGSASFittingViewQtWidget::refineAll() { + m_presenter->notify(IEnggDiffGSASFittingPresenter::RefineAll); +} + +bool EnggDiffGSASFittingViewQtWidget::runFileLineEditEmpty() const { + return m_ui.lineEdit_runFile->text().isEmpty(); +} + +void EnggDiffGSASFittingViewQtWidget::selectRun() { + m_presenter->notify(IEnggDiffGSASFittingPresenter::SelectRun); +} + +void EnggDiffGSASFittingViewQtWidget::setEnabled(const bool enabled) { + m_ui.lineEdit_runFile->setEnabled(enabled); + m_ui.pushButton_browseRunFile->setEnabled(enabled); + setLoadEnabled(enabled && !runFileLineEditEmpty()); + + m_ui.lineEdit_instParamsFile->setEnabled(enabled); + m_ui.pushButton_browseInstParams->setEnabled(enabled); + + m_ui.lineEdit_phaseFiles->setEnabled(enabled); + m_ui.pushButton_browsePhaseFiles->setEnabled(enabled); + + m_ui.lineEdit_gsasProjPath->setEnabled(enabled); + m_ui.pushButton_gsasProjPath->setEnabled(enabled); + + m_ui.lineEdit_gsasHome->setEnabled(enabled); + m_ui.pushButton_browseGSASHome->setEnabled(enabled); + + m_ui.comboBox_refinementMethod->setEnabled(enabled); + + m_ui.lineEdit_pawleyDMin->setEnabled(enabled); + m_ui.lineEdit_pawleyNegativeWeight->setEnabled(enabled); + + m_ui.lineEdit_xMin->setEnabled(enabled); + m_ui.lineEdit_xMax->setEnabled(enabled); + + m_ui.checkBox_refineSigma->setEnabled(enabled); + m_ui.checkBox_refineGamma->setEnabled(enabled); + + m_ui.pushButton_doRefinement->setEnabled(enabled); + m_ui.pushButton_refineAll->setEnabled(enabled); + + m_multiRunWidgetView->setEnabled(enabled); +} + +void EnggDiffGSASFittingViewQtWidget::setFocusedRunFileNames( + const QStringList &filenames) { + m_ui.lineEdit_runFile->setText(filenames.join(tr(","))); +} + +void EnggDiffGSASFittingViewQtWidget::setLoadEnabled(const bool enabled) { + if (enabled) { + m_ui.pushButton_loadRun->setEnabled(true); + m_ui.pushButton_loadRun->setToolTip(tr("Load focused run file")); + } else { + m_ui.pushButton_loadRun->setEnabled(false); + m_ui.pushButton_loadRun->setToolTip( + tr("Please specify a file to load via the browse menu or by typing the " + "full path to the file in the text field")); + } +} + +void EnggDiffGSASFittingViewQtWidget::setupUI() { + m_ui.setupUi(this); + connect(m_ui.pushButton_browseRunFile, SIGNAL(clicked()), this, + SLOT(browseFocusedRun())); + connect(m_ui.pushButton_loadRun, SIGNAL(clicked()), this, + SLOT(loadFocusedRun())); + connect(m_ui.lineEdit_runFile, SIGNAL(textChanged(const QString &)), this, + SLOT(disableLoadIfInputEmpty())); + + connect(m_ui.pushButton_browseInstParams, SIGNAL(clicked()), this, + SLOT(browseInstParams())); + connect(m_ui.pushButton_browsePhaseFiles, SIGNAL(clicked()), this, + SLOT(browsePhaseFiles())); + connect(m_ui.pushButton_gsasProjPath, SIGNAL(clicked()), this, + SLOT(browseGSASProj())); + connect(m_ui.pushButton_browseGSASHome, SIGNAL(clicked()), this, + SLOT(browseGSASHome())); + + connect(m_ui.pushButton_doRefinement, SIGNAL(clicked()), this, + SLOT(doRefinement())); + connect(m_ui.pushButton_refineAll, SIGNAL(clicked()), this, + SLOT(refineAll())); + + connect(m_multiRunWidgetView.get(), SIGNAL(runSelected()), this, + SLOT(selectRun())); + + QSettings settings(tr(SETTINGS_NAME)); + if (settings.contains(tr(GSAS_HOME_SETTING_NAME))) { + m_ui.lineEdit_gsasHome->setText( + settings.value(tr(GSAS_HOME_SETTING_NAME)).toString()); + } +} + +void EnggDiffGSASFittingViewQtWidget::showStatus( + const std::string &status) const { + m_userMessageProvider->showStatus(status); +} + +void EnggDiffGSASFittingViewQtWidget::userError( + const std::string &errorTitle, const std::string &errorDescription) const { + m_userMessageProvider->userError(errorTitle, errorDescription); +} + +void EnggDiffGSASFittingViewQtWidget::userWarning( + const std::string &warningTitle, + const std::string &warningDescription) const { + m_userMessageProvider->userWarning(warningTitle, warningDescription); +} + +const char EnggDiffGSASFittingViewQtWidget::GSAS_HOME_SETTING_NAME[] = + "GSAS_HOME"; +const char EnggDiffGSASFittingViewQtWidget::SETTINGS_NAME[] = + "EnggGUIGSASTabSettings"; + +} // namespace CustomInterfaces +} // namespace MantidQt diff --git a/qt/scientific_interfaces/EnggDiffraction/EnggDiffGSASFittingViewQtWidget.h b/qt/scientific_interfaces/EnggDiffraction/EnggDiffGSASFittingViewQtWidget.h new file mode 100644 index 0000000000000000000000000000000000000000..e8807d6329182731cb05768574b3e0f66e4ccfd9 --- /dev/null +++ b/qt/scientific_interfaces/EnggDiffraction/EnggDiffGSASFittingViewQtWidget.h @@ -0,0 +1,118 @@ +// Mantid Repository : https://github.com/mantidproject/mantid +// +// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI, +// NScD Oak Ridge National Laboratory, European Spallation Source +// & Institut Laue - Langevin +// SPDX - License - Identifier: GPL - 3.0 + +#pragma once + +#include "DllConfig.h" +#include "EnggDiffMultiRunFittingQtWidget.h" +#include "IEnggDiffGSASFittingPresenter.h" +#include "IEnggDiffGSASFittingView.h" +#include "IEnggDiffractionParam.h" +#include "IEnggDiffractionPythonRunner.h" +#include "IEnggDiffractionUserMsg.h" + +#include <boost/shared_ptr.hpp> +#include <qwt_plot_curve.h> +#include <qwt_plot_zoomer.h> + +#include "ui_EnggDiffractionQtTabGSAS.h" + +namespace MantidQt { +namespace CustomInterfaces { + +class MANTIDQT_ENGGDIFFRACTION_DLL EnggDiffGSASFittingViewQtWidget + : public QWidget, + public IEnggDiffGSASFittingView { + Q_OBJECT + +public: + EnggDiffGSASFittingViewQtWidget( + boost::shared_ptr<IEnggDiffractionUserMsg> userMessageProvider, + const boost::shared_ptr<IEnggDiffractionPythonRunner> &pythonRunner, + boost::shared_ptr<IEnggDiffractionParam> mainSettings); + + ~EnggDiffGSASFittingViewQtWidget() override; + + void addWidget(IEnggDiffMultiRunFittingWidgetView *widget) override; + + void displayLatticeParams( + const Mantid::API::ITableWorkspace_sptr latticeParams) const override; + + void displayGamma(const double gamma) const override; + + void displayRwp(const double rwp) const override; + + void displaySigma(const double sigma) const override; + + std::vector<std::string> getFocusedFileNames() const override; + + std::string getGSASIIProjectPath() const override; + + std::string getInstrumentFileName() const override; + + std::string getPathToGSASII() const override; + + boost::optional<double> getPawleyDMin() const override; + + boost::optional<double> getPawleyNegativeWeight() const override; + + std::vector<std::string> getPhaseFileNames() const override; + + GSASRefinementMethod getRefinementMethod() const override; + + bool getRefineGamma() const override; + + bool getRefineSigma() const override; + + boost::optional<double> getXMax() const override; + + boost::optional<double> getXMin() const override; + + void setEnabled(const bool enabled) override; + + void showStatus(const std::string &status) const override; + + void userError(const std::string &errorTitle, + const std::string &errorDescription) const override; + + void userWarning(const std::string &warningTitle, + const std::string &warningDescription) const override; + +private slots: + void browseFocusedRun(); + void browseGSASHome(); + void browseGSASProj(); + void browseInstParams(); + void browsePhaseFiles(); + void disableLoadIfInputEmpty(); + void doRefinement(); + void loadFocusedRun(); + void refineAll(); + void selectRun(); + +private: + bool runFileLineEditEmpty() const; + + void setLoadEnabled(const bool enabled); + + static const char GSAS_HOME_SETTING_NAME[]; + static const char SETTINGS_NAME[]; + + boost::shared_ptr<EnggDiffMultiRunFittingQtWidget> m_multiRunWidgetView; + + boost::shared_ptr<IEnggDiffGSASFittingPresenter> m_presenter; + + Ui::EnggDiffractionQtTabGSAS m_ui; + + boost::shared_ptr<IEnggDiffractionUserMsg> m_userMessageProvider; + + void setFocusedRunFileNames(const QStringList &filenames); + + void setupUI(); +}; + +} // namespace CustomInterfaces +} // namespace MantidQt diff --git a/qt/scientific_interfaces/EnggDiffraction/EnggDiffMultiRunFittingQtWidget.cpp b/qt/scientific_interfaces/EnggDiffraction/EnggDiffMultiRunFittingQtWidget.cpp new file mode 100644 index 0000000000000000000000000000000000000000..fc14fa9b51eb061e566ee885bf799cbd6cda1a97 --- /dev/null +++ b/qt/scientific_interfaces/EnggDiffraction/EnggDiffMultiRunFittingQtWidget.cpp @@ -0,0 +1,255 @@ +// Mantid Repository : https://github.com/mantidproject/mantid +// +// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI, +// NScD Oak Ridge National Laboratory, European Spallation Source +// & Institut Laue - Langevin +// SPDX - License - Identifier: GPL - 3.0 + +#include "EnggDiffMultiRunFittingQtWidget.h" + +#include <utility> + +namespace { + +MantidQt::CustomInterfaces::RunLabel +parseListWidgetItem(const QString &listWidgetItem) { + const auto pieces = listWidgetItem.split("_"); + if (pieces.size() != 2) { + throw std::runtime_error( + "Unexpected run label: \"" + listWidgetItem.toStdString() + + "\". Please contact the development team with this message"); + } + return MantidQt::CustomInterfaces::RunLabel(pieces[0].toStdString(), + pieces[1].toUInt()); +} + +} // anonymous namespace + +namespace MantidQt { +namespace CustomInterfaces { + +EnggDiffMultiRunFittingQtWidget::EnggDiffMultiRunFittingQtWidget( + boost::shared_ptr<IEnggDiffractionPythonRunner> pythonRunner) + : m_pythonRunner(std::move(pythonRunner)) { + setupUI(); + + m_zoomTool = std::make_unique<QwtPlotZoomer>( + QwtPlot::xBottom, QwtPlot::yLeft, + QwtPicker::DragSelection | QwtPicker::CornerToCorner, + QwtPicker::AlwaysOff, m_ui.plotArea->canvas()); + m_zoomTool->setRubberBandPen(QPen(Qt::black)); + m_zoomTool->setEnabled(false); +} + +EnggDiffMultiRunFittingQtWidget::~EnggDiffMultiRunFittingQtWidget() { + cleanUpPlot(); +} + +void EnggDiffMultiRunFittingQtWidget::cleanUpPlot() { + for (auto &curve : m_focusedRunCurves) { + curve->detach(); + } + m_focusedRunCurves.clear(); + for (auto &curve : m_fittedPeaksCurves) { + curve->detach(); + } + m_fittedPeaksCurves.clear(); +} + +std::vector<RunLabel> EnggDiffMultiRunFittingQtWidget::getAllRunLabels() const { + std::vector<RunLabel> runLabels; + runLabels.reserve(m_ui.listWidget_runLabels->count()); + + for (int i = 0; i < m_ui.listWidget_runLabels->count(); i++) { + const auto currentLabel = m_ui.listWidget_runLabels->item(i)->text(); + runLabels.emplace_back(parseListWidgetItem(currentLabel)); + } + return runLabels; +} + +boost::optional<RunLabel> +EnggDiffMultiRunFittingQtWidget::getSelectedRunLabel() const { + if (hasSelectedRunLabel()) { + const auto currentLabel = m_ui.listWidget_runLabels->currentItem()->text(); + return parseListWidgetItem(currentLabel); + } else { + return boost::none; + } +} + +void EnggDiffMultiRunFittingQtWidget::reportNoRunSelectedForPlot() { + userError("No run selected", + "Please select a run from the list before plotting"); +} + +void EnggDiffMultiRunFittingQtWidget::reportPlotInvalidFittedPeaks( + const RunLabel &runLabel) { + userError("Invalid fitted peaks identifier", + "Tried to plot invalid fitted peaks, run number " + + runLabel.runNumber + " and bank ID " + + std::to_string(runLabel.bank) + + ". Please contact the development team with this message"); +} + +void EnggDiffMultiRunFittingQtWidget::reportPlotInvalidFocusedRun( + const RunLabel &runLabel) { + userError("Invalid focused run identifier", + "Tried to plot invalid focused run, run number " + + runLabel.runNumber + " and bank ID " + + std::to_string(runLabel.bank) + + ". Please contact the development team with this message"); +} + +bool EnggDiffMultiRunFittingQtWidget::hasSelectedRunLabel() const { + return m_ui.listWidget_runLabels->selectedItems().size() != 0; +} + +void EnggDiffMultiRunFittingQtWidget::plotFittedPeaksStateChanged() { + m_presenter->notify(IEnggDiffMultiRunFittingWidgetPresenter::Notification:: + PlotPeaksStateChanged); +} + +void EnggDiffMultiRunFittingQtWidget::plotFittedPeaks( + const std::vector<boost::shared_ptr<QwtData>> &curves) { + for (const auto &curve : curves) { + auto plotCurve = std::make_unique<QwtPlotCurve>(); + + plotCurve->setPen(QColor(Qt::red)); + plotCurve->setData(*curve); + plotCurve->attach(m_ui.plotArea); + m_fittedPeaksCurves.emplace_back(std::move(plotCurve)); + } + m_ui.plotArea->replot(); + m_zoomTool->setZoomBase(); + m_zoomTool->setEnabled(true); +} + +void EnggDiffMultiRunFittingQtWidget::processPlotToSeparateWindow() { + m_presenter->notify(IEnggDiffMultiRunFittingWidgetPresenter::Notification:: + PlotToSeparateWindow); +} + +void EnggDiffMultiRunFittingQtWidget::plotFocusedRun( + const std::vector<boost::shared_ptr<QwtData>> &curves) { + for (const auto &curve : curves) { + auto plotCurve = std::make_unique<QwtPlotCurve>(); + + plotCurve->setData(*curve); + plotCurve->attach(m_ui.plotArea); + m_focusedRunCurves.emplace_back(std::move(plotCurve)); + } + m_ui.plotArea->replot(); + m_zoomTool->setZoomBase(); + m_zoomTool->setEnabled(true); +} + +void EnggDiffMultiRunFittingQtWidget::plotToSeparateWindow( + const std::string &focusedRunName, + const boost::optional<std::string> fittedPeaksName) { + + std::string plotCode = "ws1 = \"" + focusedRunName + "\"\n"; + + plotCode += "workspaceToPlot = \"engg_gui_separate_plot_ws\"\n" + + "if (mtd.doesExist(workspaceToPlot)):\n" + " DeleteWorkspace(workspaceToPlot)\n" + + "ExtractSingleSpectrum(InputWorkspace=ws1, WorkspaceIndex=0, " + "OutputWorkspace=workspaceToPlot)\n" + + "spectra_to_plot = [0]\n"; + + if (fittedPeaksName) { + plotCode += "ws2 = \"" + *fittedPeaksName + "\"\n"; + plotCode += + "ws2_spectrum = ExtractSingleSpectrum(InputWorkspace=ws2, " + "WorkspaceIndex=0, StoreInADS=False)\n" + + "AppendSpectra(InputWorkspace1=workspaceToPlot, " + "InputWorkspace2=ws2_spectrum, OutputWorkspace=workspaceToPlot)\n" + + "DeleteWorkspace(ws2_spectrum)\n" + "spectra_to_plot = [0, 1]\n"; + } + + plotCode += + "plot = plotSpectrum(workspaceToPlot, spectra_to_plot).activeLayer()\n" + "plot.setTitle(\"Engg GUI Fitting Workspaces\")\n"; + m_pythonRunner->enggRunPythonCode(plotCode); +} + +void EnggDiffMultiRunFittingQtWidget::processRemoveRun() { + emit removeRunClicked(); + m_presenter->notify( + IEnggDiffMultiRunFittingWidgetPresenter::Notification::RemoveRun); +} + +void EnggDiffMultiRunFittingQtWidget::processSelectRun() { + emit runSelected(); + m_presenter->notify( + IEnggDiffMultiRunFittingWidgetPresenter::Notification::SelectRun); +} + +void EnggDiffMultiRunFittingQtWidget::resetCanvas() { + cleanUpPlot(); + m_ui.plotArea->replot(); + resetPlotZoomLevel(); +} + +void EnggDiffMultiRunFittingQtWidget::resetPlotZoomLevel() { + m_ui.plotArea->setAxisAutoScale(QwtPlot::xBottom); + m_ui.plotArea->setAxisAutoScale(QwtPlot::yLeft); + m_zoomTool->setZoomBase(true); +} + +void EnggDiffMultiRunFittingQtWidget::setEnabled(const bool enabled) { + m_ui.listWidget_runLabels->setEnabled(enabled); + m_ui.pushButton_removeRun->setEnabled(enabled); + m_ui.pushButton_plotToSeparateWindow->setEnabled(enabled); + m_ui.checkBox_plotFittedPeaks->setEnabled(enabled); + m_zoomTool->setEnabled(enabled); +} + +void EnggDiffMultiRunFittingQtWidget::setMessageProvider( + boost::shared_ptr<IEnggDiffractionUserMsg> messageProvider) { + m_userMessageProvider = messageProvider; +} + +void EnggDiffMultiRunFittingQtWidget::setPresenter( + boost::shared_ptr<IEnggDiffMultiRunFittingWidgetPresenter> presenter) { + m_presenter = presenter; +} + +void EnggDiffMultiRunFittingQtWidget::setupUI() { + m_ui.setupUi(this); + + connect(m_ui.listWidget_runLabels, SIGNAL(itemSelectionChanged()), this, + SLOT(processSelectRun())); + connect(m_ui.checkBox_plotFittedPeaks, SIGNAL(stateChanged(int)), this, + SLOT(plotFittedPeaksStateChanged())); + connect(m_ui.pushButton_removeRun, SIGNAL(clicked()), this, + SLOT(processRemoveRun())); + connect(m_ui.pushButton_plotToSeparateWindow, SIGNAL(clicked()), this, + SLOT(processPlotToSeparateWindow())); +} + +bool EnggDiffMultiRunFittingQtWidget::showFitResultsSelected() const { + return m_ui.checkBox_plotFittedPeaks->isChecked(); +} + +void EnggDiffMultiRunFittingQtWidget::updateRunList( + const std::vector<RunLabel> &runLabels) { + m_ui.listWidget_runLabels->clear(); + for (const auto &runLabel : runLabels) { + const auto labelStr = QString(runLabel.runNumber.c_str()) + tr("_") + + QString::number(runLabel.bank); + m_ui.listWidget_runLabels->addItem(labelStr); + } +} + +void EnggDiffMultiRunFittingQtWidget::userError( + const std::string &errorTitle, const std::string &errorDescription) { + m_userMessageProvider->userError(errorTitle, errorDescription); +} + +} // namespace CustomInterfaces +} // namespace MantidQt diff --git a/qt/scientific_interfaces/EnggDiffraction/EnggDiffMultiRunFittingWidgetPresenter.cpp b/qt/scientific_interfaces/EnggDiffraction/EnggDiffMultiRunFittingWidgetPresenter.cpp new file mode 100644 index 0000000000000000000000000000000000000000..721de6b05ca9cea191e3caea198213d957ed3c01 --- /dev/null +++ b/qt/scientific_interfaces/EnggDiffraction/EnggDiffMultiRunFittingWidgetPresenter.cpp @@ -0,0 +1,227 @@ +// Mantid Repository : https://github.com/mantidproject/mantid +// +// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI, +// NScD Oak Ridge National Laboratory, European Spallation Source +// & Institut Laue - Langevin +// SPDX - License - Identifier: GPL - 3.0 + +#include "EnggDiffMultiRunFittingWidgetPresenter.h" +#include "EnggDiffMultiRunFittingWidgetAdder.h" + +#include "MantidAPI/AnalysisDataService.h" +#include "MantidAPI/Run.h" + +#include "MantidQtWidgets/Plotting/Qwt/QwtHelper.h" + +#include <boost/algorithm/string.hpp> +#include <cctype> + +namespace { + +bool isDigit(const std::string &text) { + return std::all_of(text.cbegin(), text.cend(), isdigit); +} + +std::string +generateFittedPeaksName(const MantidQt::CustomInterfaces::RunLabel &runLabel) { + return runLabel.runNumber + "_" + std::to_string(runLabel.bank) + + "_fitted_peaks_external_plot"; +} + +std::string +generateFocusedRunName(const MantidQt::CustomInterfaces::RunLabel &runLabel) { + return runLabel.runNumber + "_" + std::to_string(runLabel.bank) + + "_external_plot"; +} + +size_t guessBankID(const Mantid::API::MatrixWorkspace_const_sptr &ws) { + const static std::string bankIDName = "bankid"; + if (ws->run().hasProperty(bankIDName)) { + const auto log = dynamic_cast<Mantid::Kernel::PropertyWithValue<int> *>( + ws->run().getLogData(bankIDName)); + return boost::lexical_cast<size_t>(log->value()); + } + + // couldn't get it from sample logs - try using the old naming convention + const std::string name = ws->getName(); + std::vector<std::string> chunks; + boost::split(chunks, name, boost::is_any_of("_")); + if (!chunks.empty()) { + const bool isNum = isDigit(chunks.back()); + if (isNum) { + try { + return boost::lexical_cast<size_t>(chunks.back()); + } catch (boost::exception &) { + // If we get a bad cast or something goes wrong then + // the file is probably not what we were expecting + // so throw a runtime error + throw std::runtime_error( + "Failed to fit file: The data was not what is expected. " + "Does the file contain a focused workspace?"); + } + } + } + + throw std::runtime_error("Could not guess run number from input workspace. " + "Are you sure it has been focused correctly?"); +} +} // anonymous namespace + +namespace MantidQt { +namespace CustomInterfaces { + +EnggDiffMultiRunFittingWidgetPresenter::EnggDiffMultiRunFittingWidgetPresenter( + std::unique_ptr<IEnggDiffMultiRunFittingWidgetModel> model, + IEnggDiffMultiRunFittingWidgetView *view) + : m_model(std::move(model)), m_view(view) {} + +void EnggDiffMultiRunFittingWidgetPresenter::addFittedPeaks( + const RunLabel &runLabel, const Mantid::API::MatrixWorkspace_sptr ws) { + m_model->addFittedPeaks(runLabel, ws); + updatePlot(runLabel); +} + +void EnggDiffMultiRunFittingWidgetPresenter::addFocusedRun( + const Mantid::API::MatrixWorkspace_sptr ws) { + const auto runNumber = std::to_string(ws->getRunNumber()); + const auto bankID = guessBankID(ws); + + m_model->addFocusedRun(RunLabel(runNumber, bankID), ws); + m_view->updateRunList(m_model->getAllWorkspaceLabels()); +} + +void EnggDiffMultiRunFittingWidgetPresenter::displayFitResults( + const RunLabel &runLabel) { + const auto fittedPeaks = m_model->getFittedPeaks(runLabel); + if (!fittedPeaks) { + m_view->reportPlotInvalidFittedPeaks(runLabel); + } else { + const auto plottablePeaks = API::QwtHelper::curveDataFromWs(*fittedPeaks); + m_view->plotFittedPeaks(plottablePeaks); + } +} + +std::vector<RunLabel> +EnggDiffMultiRunFittingWidgetPresenter::getAllRunLabels() const { + return m_view->getAllRunLabels(); +} + +std::unique_ptr<IEnggDiffMultiRunFittingWidgetAdder> +EnggDiffMultiRunFittingWidgetPresenter::getWidgetAdder() const { + return std::make_unique<EnggDiffMultiRunFittingWidgetAdder>(m_view); +} + +boost::optional<Mantid::API::MatrixWorkspace_sptr> +EnggDiffMultiRunFittingWidgetPresenter::getFittedPeaks( + const RunLabel &runLabel) const { + return m_model->getFittedPeaks(runLabel); +} + +boost::optional<Mantid::API::MatrixWorkspace_sptr> +EnggDiffMultiRunFittingWidgetPresenter::getFocusedRun( + const RunLabel &runLabel) const { + return m_model->getFocusedRun(runLabel); +} + +boost::optional<RunLabel> +EnggDiffMultiRunFittingWidgetPresenter::getSelectedRunLabel() const { + return m_view->getSelectedRunLabel(); +} + +void EnggDiffMultiRunFittingWidgetPresenter::notify( + IEnggDiffMultiRunFittingWidgetPresenter::Notification notif) { + switch (notif) { + case Notification::PlotPeaksStateChanged: + processPlotPeaksStateChanged(); + break; + + case Notification::PlotToSeparateWindow: + processPlotToSeparateWindow(); + break; + + case Notification::RemoveRun: + processRemoveRun(); + break; + + case Notification::SelectRun: + processSelectRun(); + break; + } +} + +void EnggDiffMultiRunFittingWidgetPresenter::processPlotPeaksStateChanged() { + const auto runLabel = getSelectedRunLabel(); + if (runLabel) { + updatePlot(*runLabel); + } +} + +void EnggDiffMultiRunFittingWidgetPresenter::processPlotToSeparateWindow() { + const auto runLabel = m_view->getSelectedRunLabel(); + if (!runLabel) { + m_view->reportNoRunSelectedForPlot(); + return; + } + + const auto focusedRun = m_model->getFocusedRun(*runLabel); + if (!focusedRun) { + m_view->reportPlotInvalidFocusedRun(*runLabel); + return; + } + + auto &ADS = Mantid::API::AnalysisDataService::Instance(); + const auto focusedRunName = generateFocusedRunName(*runLabel); + ADS.add(focusedRunName, *focusedRun); + + boost::optional<std::string> fittedPeaksName = boost::none; + if (m_view->showFitResultsSelected() && + m_model->hasFittedPeaksForRun(*runLabel)) { + fittedPeaksName = generateFittedPeaksName(*runLabel); + const auto fittedPeaks = m_model->getFittedPeaks(*runLabel); + ADS.add(*fittedPeaksName, *fittedPeaks); + } + + m_view->plotToSeparateWindow(focusedRunName, fittedPeaksName); + + ADS.remove(focusedRunName); + if (fittedPeaksName) { + ADS.remove(*fittedPeaksName); + } +} + +void EnggDiffMultiRunFittingWidgetPresenter::processRemoveRun() { + const auto runLabel = getSelectedRunLabel(); + if (runLabel) { + m_model->removeRun(*runLabel); + m_view->updateRunList(m_model->getAllWorkspaceLabels()); + m_view->resetCanvas(); + } +} + +void EnggDiffMultiRunFittingWidgetPresenter::processSelectRun() { + const auto runLabel = getSelectedRunLabel(); + if (runLabel) { + updatePlot(*runLabel); + } +} + +void EnggDiffMultiRunFittingWidgetPresenter::updatePlot( + const RunLabel &runLabel) { + const auto focusedRun = m_model->getFocusedRun(runLabel); + + if (!focusedRun) { + m_view->reportPlotInvalidFocusedRun(runLabel); + } else { + const auto plottableCurve = API::QwtHelper::curveDataFromWs(*focusedRun); + + m_view->resetCanvas(); + m_view->plotFocusedRun(plottableCurve); + + if (m_model->hasFittedPeaksForRun(runLabel) && + m_view->showFitResultsSelected()) { + displayFitResults(runLabel); + } + } +} + +} // namespace CustomInterfaces +} // namespace MantidQt diff --git a/qt/scientific_interfaces/EnggDiffraction/EnggDiffractionPresenter.cpp b/qt/scientific_interfaces/EnggDiffraction/EnggDiffractionPresenter.cpp new file mode 100644 index 0000000000000000000000000000000000000000..1ff4eceb0d89776edc5153d9040fc455b15e5de8 --- /dev/null +++ b/qt/scientific_interfaces/EnggDiffraction/EnggDiffractionPresenter.cpp @@ -0,0 +1,2899 @@ +// Mantid Repository : https://github.com/mantidproject/mantid +// +// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI, +// NScD Oak Ridge National Laboratory, European Spallation Source +// & Institut Laue - Langevin +// SPDX - License - Identifier: GPL - 3.0 + +#include "EnggDiffractionPresenter.h" +#include "EnggDiffractionPresWorker.h" +#include "EnggVanadiumCorrectionsModel.h" +#include "IEnggDiffractionView.h" +#include "MantidAPI/AlgorithmManager.h" +#include "MantidAPI/AnalysisDataService.h" +#include "MantidAPI/ITableWorkspace.h" +#include "MantidAPI/MatrixWorkspace.h" +#include "MantidAPI/TableRow.h" +#include "MantidKernel/Property.h" +#include "MantidKernel/StringTokenizer.h" +#include "MantidQtWidgets/Common/PythonRunner.h" + +#include <algorithm> +#include <cctype> +#include <fstream> + +#include <boost/lexical_cast.hpp> + +#include <Poco/File.h> +#include <Poco/Path.h> + +#include <QThread> + +using namespace Mantid::API; +using namespace MantidQt::CustomInterfaces; + +namespace MantidQt { +namespace CustomInterfaces { + +namespace { +Mantid::Kernel::Logger g_log("EngineeringDiffractionGUI"); +} + +const std::string EnggDiffractionPresenter::g_runNumberErrorStr = + " cannot be empty, must be an integer number, valid ENGINX run number/s " + "or " + "valid directory/directories."; + +// discouraged at the moment +const bool EnggDiffractionPresenter::g_askUserCalibFilename = false; + +const std::string EnggDiffractionPresenter::g_calibBanksParms = + "engggui_calibration_banks_parameters"; + +int EnggDiffractionPresenter::g_croppedCounter = 0; +int EnggDiffractionPresenter::g_plottingCounter = 0; +bool EnggDiffractionPresenter::g_abortThread = false; +std::string EnggDiffractionPresenter::g_lastValidRun = ""; +std::string EnggDiffractionPresenter::g_calibCropIdentifier = "SpectrumNumbers"; +std::string EnggDiffractionPresenter::g_sumOfFilesFocus = ""; + +EnggDiffractionPresenter::EnggDiffractionPresenter(IEnggDiffractionView *view) + : m_workerThread(nullptr), m_calibFinishedOK(false), + m_focusFinishedOK(false), m_rebinningFinishedOK(false), m_view(view), + m_viewHasClosed(false), + m_vanadiumCorrectionsModel( + boost::make_shared<EnggVanadiumCorrectionsModel>( + m_view->currentCalibSettings(), m_view->currentInstrument())) { + if (!m_view) { + throw std::runtime_error( + "Severe inconsistency found. Presenter created " + "with an empty/null view (Engineering diffraction interface). " + "Cannot continue."); + } + + m_currentInst = m_view->currentInstrument(); +} + +EnggDiffractionPresenter::~EnggDiffractionPresenter() { cleanup(); } + +/** + * Close open sessions, kill threads etc., save settings, etc. for a + * graceful window close/destruction + */ +void EnggDiffractionPresenter::cleanup() { + // m_model->cleanup(); + + // this may still be running + if (m_workerThread) { + if (m_workerThread->isRunning()) { + g_log.notice() << "A calibration process is currently running, shutting " + "it down immediately...\n"; + m_workerThread->wait(10); + } + delete m_workerThread; + m_workerThread = nullptr; + } + + // Remove the workspace which is loaded when the interface starts + auto &ADS = Mantid::API::AnalysisDataService::Instance(); + if (ADS.doesExist(g_calibBanksParms)) { + ADS.remove(g_calibBanksParms); + } +} + +void EnggDiffractionPresenter::notify( + IEnggDiffractionPresenter::Notification notif) { + + // Check the view is valid - QT can send multiple notification + // signals in any order at any time. This means that it is possible + // to receive a shutdown signal and subsequently an input example + // for example. As we can't guarantee the state of the viewer + // after calling shutdown instead we shouldn't do anything after + if (m_viewHasClosed) { + return; + } + + switch (notif) { + + case IEnggDiffractionPresenter::Start: + processStart(); + break; + + case IEnggDiffractionPresenter::LoadExistingCalib: + processLoadExistingCalib(); + break; + + case IEnggDiffractionPresenter::CalcCalib: + processCalcCalib(); + break; + + case IEnggDiffractionPresenter::CropCalib: + ProcessCropCalib(); + break; + + case IEnggDiffractionPresenter::FocusRun: + processFocusBasic(); + break; + + case IEnggDiffractionPresenter::FocusCropped: + processFocusCropped(); + break; + + case IEnggDiffractionPresenter::FocusTexture: + processFocusTexture(); + break; + + case IEnggDiffractionPresenter::ResetFocus: + processResetFocus(); + break; + + case IEnggDiffractionPresenter::RebinTime: + processRebinTime(); + break; + + case IEnggDiffractionPresenter::RebinMultiperiod: + processRebinMultiperiod(); + break; + + case IEnggDiffractionPresenter::LogMsg: + processLogMsg(); + break; + + case IEnggDiffractionPresenter::InstrumentChange: + processInstChange(); + break; + + case IEnggDiffractionPresenter::RBNumberChange: + processRBNumberChange(); + break; + + case IEnggDiffractionPresenter::ShutDown: + processShutDown(); + break; + + case IEnggDiffractionPresenter::StopFocus: + processStopFocus(); + break; + } +} + +void EnggDiffractionPresenter::processStart() { m_view->showStatus("Ready"); } + +void EnggDiffractionPresenter::processLoadExistingCalib() { + const std::string fname = m_view->askExistingCalibFilename(); + if (fname.empty()) { + return; + } + + updateNewCalib(fname); +} + +/** + * Grab a calibration from a (GSAS calibration) file + * (.prm/.par/.iparm) and set/use it as current calibration. + * + * @param fname name/path of the calibration file + */ + +void EnggDiffractionPresenter::updateNewCalib(const std::string &fname) { + + Poco::Path pocoPath; + const bool pathValid = pocoPath.tryParse(fname); + + if (!pathValid || fname.empty() || pocoPath.isDirectory()) { + // Log that we couldn't open the file - its probably and invalid + // path which will be regenerated + g_log.warning("Could not open GSAS calibration file: " + fname); + return; + } + + std::string instName, vanNo, ceriaNo; + try { + parseCalibrateFilename(fname, instName, vanNo, ceriaNo); + } catch (std::invalid_argument &ia) { + m_view->userWarning("Invalid calibration filename : " + fname, ia.what()); + return; + } + + try { + grabCalibParms(fname, vanNo, ceriaNo); + updateCalibParmsTable(); + m_view->newCalibLoaded(vanNo, ceriaNo, fname); + } catch (std::runtime_error &rexc) { + m_view->userWarning("Problem while updating calibration.", rexc.what()); + } +} + +/** + * Get from a calibration file (GSAS instrument parameters file) the + * DIFC, DIFA, TZERO calibration parameters used for units + * conversions. Normally this is used on the ...all_banks.prm file + * which has the parameters for every bank included in the calibration + * process. + * + * @param fname name of the calibration/GSAS iparm file + * @param vanNo output param to hold the vanadium run + * @param ceriaNo output param to hold the ceria run + */ +void EnggDiffractionPresenter::grabCalibParms(const std::string &fname, + std::string &vanNo, + std::string &ceriaNo) { + std::vector<GSASCalibrationParms> parms; + + // To grab the bank indices, lines like "INS BANK 2" + // To grab the difc,difa,tzero parameters, lines like: + // "INS 2 ICONS 18388.00 0.00 -6.76" + try { + std::ifstream prmFile(fname); + std::string line; + int opts = Mantid::Kernel::StringTokenizer::TOK_TRIM + + Mantid::Kernel::StringTokenizer::TOK_IGNORE_EMPTY; + while (std::getline(prmFile, line)) { + if (line.find("ICONS") != std::string::npos) { + Mantid::Kernel::StringTokenizer tokenizer(line, " ", opts); + const size_t numElems = 6; + if (tokenizer.count() == numElems) { + try { + size_t bid = boost::lexical_cast<size_t>(tokenizer[1]); + double difc = boost::lexical_cast<double>(tokenizer[3]); + double difa = boost::lexical_cast<double>(tokenizer[4]); + double tzero = boost::lexical_cast<double>(tokenizer[5]); + parms.emplace_back(GSASCalibrationParms(bid, difc, difa, tzero)); + } catch (std::runtime_error &rexc) { + g_log.warning() + << "Error when trying to extract parameters from this line: " + << line + << ". This calibration file may not load correctly. " + "Error details: " + << rexc.what() << '\n'; + } + } else { + g_log.warning() << "Could not parse correctly a parameters " + "definition line in this calibration file (" + << fname << "). Did not find " << numElems + << " elements as expected. The calibration may not " + "load correctly\n"; + } + } else if (line.find("CALIB") != std::string::npos) { + Mantid::Kernel::StringTokenizer tokenizer(line, " ", opts); + ceriaNo = tokenizer[2]; + vanNo = tokenizer[3]; + } + } + + } catch (std::runtime_error &rexc) { + g_log.error() + << "Error while loading calibration / GSAS IPARM file (" << fname + << "). Could not parse the file. Please check its contents. Details: " + << rexc.what() << '\n'; + } + + m_currentCalibParms = parms; +} + +/** + * Puts in a table workspace, visible in the ADS, the per-bank + * calibration parameters for the current calibration. + */ +void EnggDiffractionPresenter::updateCalibParmsTable() { + if (m_currentCalibParms.empty()) { + return; + } + + ITableWorkspace_sptr parmsTbl; + AnalysisDataServiceImpl &ADS = Mantid::API::AnalysisDataService::Instance(); + if (ADS.doesExist(g_calibBanksParms)) { + parmsTbl = ADS.retrieveWS<ITableWorkspace>(g_calibBanksParms); + parmsTbl->setRowCount(0); + } else { + auto alg = Mantid::API::AlgorithmManager::Instance().createUnmanaged( + "CreateEmptyTableWorkspace"); + alg->initialize(); + alg->setPropertyValue("OutputWorkspace", g_calibBanksParms); + alg->execute(); + + parmsTbl = ADS.retrieveWS<ITableWorkspace>(g_calibBanksParms); + parmsTbl->addColumn("int", "bankid"); + parmsTbl->addColumn("double", "difc"); + parmsTbl->addColumn("double", "difa"); + parmsTbl->addColumn("double", "tzero"); + } + + for (const auto &parms : m_currentCalibParms) { + // ADS.remove(FocusedFitPeaksTableName); + TableRow row = parmsTbl->appendRow(); + row << static_cast<int>(parms.bankid) << parms.difc << parms.difa + << parms.tzero; + } +} + +void EnggDiffractionPresenter::processCalcCalib() { + const std::string vanNo = isValidRunNumber(m_view->newVanadiumNo()); + const std::string ceriaNo = isValidRunNumber(m_view->newCeriaNo()); + try { + inputChecksBeforeCalibrate(vanNo, ceriaNo); + } catch (std::invalid_argument &ia) { + m_view->userWarning("Error in the inputs required for calibrate", + ia.what()); + return; + } + g_log.notice() << "EnggDiffraction GUI: starting new calibration. This may " + "take a few seconds... \n"; + + const std::string outFilename = outputCalibFilename(vanNo, ceriaNo); + + m_view->showStatus("Calculating calibration..."); + m_view->enableCalibrateFocusFitUserActions(false); + // alternatively, this would be GUI-blocking: + // doNewCalibration(outFilename, vanNo, ceriaNo, ""); + // calibrationFinished(); + startAsyncCalibWorker(outFilename, vanNo, ceriaNo, ""); +} + +void EnggDiffractionPresenter::ProcessCropCalib() { + const std::string vanNo = isValidRunNumber(m_view->newVanadiumNo()); + const std::string ceriaNo = isValidRunNumber(m_view->newCeriaNo()); + int specNoNum = m_view->currentCropCalibBankName(); + enum BankMode { SPECNOS = 0, NORTH = 1, SOUTH = 2 }; + + try { + inputChecksBeforeCalibrate(vanNo, ceriaNo); + if (m_view->currentCalibSpecNos().empty() && + specNoNum == BankMode::SPECNOS) { + throw std::invalid_argument( + "The Spectrum Numbers field cannot be empty, must be a " + "valid range or a Bank Name can be selected instead."); + } + } catch (std::invalid_argument &ia) { + m_view->userWarning("Error in the inputs required for cropped calibration", + ia.what()); + return; + } + + g_log.notice() + << "EnggDiffraction GUI: starting cropped calibration. This may " + "take a few seconds... \n"; + + const std::string outFilename = outputCalibFilename(vanNo, ceriaNo); + + std::string specNo = ""; + if (specNoNum == BankMode::NORTH) { + specNo = "North"; + g_calibCropIdentifier = "Bank"; + + } else if (specNoNum == BankMode::SOUTH) { + specNo = "South"; + g_calibCropIdentifier = "Bank"; + + } else if (specNoNum == BankMode::SPECNOS) { + g_calibCropIdentifier = "SpectrumNumbers"; + specNo = m_view->currentCalibSpecNos(); + } + + m_view->showStatus("Calculating cropped calibration..."); + m_view->enableCalibrateFocusFitUserActions(false); + startAsyncCalibWorker(outFilename, vanNo, ceriaNo, specNo); +} + +void EnggDiffractionPresenter::processFocusBasic() { + std::vector<std::string> multi_RunNo = + isValidMultiRunNumber(m_view->focusingRunNo()); + const std::vector<bool> banks = m_view->focusingBanks(); + + // reset global values + g_abortThread = false; + g_sumOfFilesFocus = ""; + g_plottingCounter = 0; + + // check if valid run number provided before focusin + try { + inputChecksBeforeFocusBasic(multi_RunNo, banks); + } catch (std::invalid_argument &ia) { + m_view->userWarning("Error in the inputs required to focus a run", + ia.what()); + return; + } + + int focusMode = m_view->currentMultiRunMode(); + if (focusMode == 0) { + g_log.debug() << " focus mode selected Individual Run Files Separately \n"; + + // start focusing + startFocusing(multi_RunNo, banks, "", ""); + + } else if (focusMode == 1) { + g_log.debug() << " focus mode selected Focus Sum Of Files \n"; + g_sumOfFilesFocus = "basic"; + std::vector<std::string> firstRun; + firstRun.emplace_back(multi_RunNo[0]); + + // to avoid multiple loops, use firstRun instead as the + // multi-run number is not required for sumOfFiles + startFocusing(firstRun, banks, "", ""); + } +} + +void EnggDiffractionPresenter::processFocusCropped() { + const std::vector<std::string> multi_RunNo = + isValidMultiRunNumber(m_view->focusingCroppedRunNo()); + const std::vector<bool> banks = m_view->focusingBanks(); + const std::string specNos = m_view->focusingCroppedSpectrumNos(); + + // reset global values + g_abortThread = false; + g_sumOfFilesFocus = ""; + g_plottingCounter = 0; + + // check if valid run number provided before focusin + try { + inputChecksBeforeFocusCropped(multi_RunNo, banks, specNos); + } catch (std::invalid_argument &ia) { + m_view->userWarning( + "Error in the inputs required to focus a run (in cropped mode)", + ia.what()); + return; + } + + int focusMode = m_view->currentMultiRunMode(); + if (focusMode == 0) { + g_log.debug() << " focus mode selected Individual Run Files Separately \n"; + + startFocusing(multi_RunNo, banks, specNos, ""); + + } else if (focusMode == 1) { + g_log.debug() << " focus mode selected Focus Sum Of Files \n"; + g_sumOfFilesFocus = "cropped"; + std::vector<std::string> firstRun{multi_RunNo[0]}; + + // to avoid multiple loops, use firstRun instead as the + // multi-run number is not required for sumOfFiles + startFocusing(firstRun, banks, specNos, ""); + } +} + +void EnggDiffractionPresenter::processFocusTexture() { + const std::vector<std::string> multi_RunNo = + isValidMultiRunNumber(m_view->focusingTextureRunNo()); + const std::string dgFile = m_view->focusingTextureGroupingFile(); + + // reset global values + g_abortThread = false; + g_sumOfFilesFocus = ""; + g_plottingCounter = 0; + + // check if valid run number provided before focusing + try { + inputChecksBeforeFocusTexture(multi_RunNo, dgFile); + } catch (std::invalid_argument &ia) { + m_view->userWarning( + "Error in the inputs required to focus a run (in texture mode)", + ia.what()); + return; + } + + int focusMode = m_view->currentMultiRunMode(); + if (focusMode == 0) { + g_log.debug() << " focus mode selected Individual Run Files Separately \n"; + startFocusing(multi_RunNo, std::vector<bool>(), "", dgFile); + + } else if (focusMode == 1) { + g_log.debug() << " focus mode selected Focus Sum Of Files \n"; + g_sumOfFilesFocus = "texture"; + std::vector<std::string> firstRun{multi_RunNo[0]}; + + // to avoid multiple loops, use firstRun instead as the + // multi-run number is not required for sumOfFiles + startFocusing(firstRun, std::vector<bool>(), "", dgFile); + } +} + +/** + * Starts a focusing worker, for different modes depending on the + * inputs provided. Assumes that the inputs have been checked by the + * respective specific processFocus methods (for normal, cropped, + * texture, etc. focusing). + * + * @param multi_RunNo vector of run/file number to focus + * @param banks banks to include in the focusing, processed one at a time + * + * @param specNos list of spectra to use when focusing. If not empty + * this implies focusing in cropped mode. + * + * @param dgFile detector grouping file to define banks (texture). If + * not empty, this implies focusing in texture mode. + */ +void EnggDiffractionPresenter::startFocusing( + const std::vector<std::string> &multi_RunNo, const std::vector<bool> &banks, + const std::string &specNos, const std::string &dgFile) { + + std::string optMsg = ""; + if (!specNos.empty()) { + optMsg = " (cropped)"; + } else if (!dgFile.empty()) { + optMsg = " (texture)"; + } + g_log.notice() << "EnggDiffraction GUI: starting new focusing" << optMsg + << ". This may take some seconds... \n"; + + m_view->showStatus("Focusing..."); + m_view->enableCalibrateFocusFitUserActions(false); + startAsyncFocusWorker(multi_RunNo, banks, specNos, dgFile); +} + +void EnggDiffractionPresenter::processResetFocus() { m_view->resetFocus(); } + +void EnggDiffractionPresenter::processRebinTime() { + + const std::string runNo = isValidRunNumber(m_view->currentPreprocRunNo()); + double bin = m_view->rebinningTimeBin(); + + try { + inputChecksBeforeRebinTime(runNo, bin); + } catch (std::invalid_argument &ia) { + m_view->userWarning( + "Error in the inputs required to pre-process (rebin) a run", ia.what()); + return; + } + + const std::string outWSName = "engggui_preproc_time_ws"; + g_log.notice() << "EnggDiffraction GUI: starting new pre-processing " + "(re-binning) with a TOF bin into workspace '" + + outWSName + + "'. This " + "may take some seconds... \n"; + + m_view->showStatus("Rebinning by time..."); + m_view->enableCalibrateFocusFitUserActions(false); + startAsyncRebinningTimeWorker(runNo, bin, outWSName); +} + +void EnggDiffractionPresenter::processRebinMultiperiod() { + const std::string runNo = isValidRunNumber(m_view->currentPreprocRunNo()); + size_t nperiods = m_view->rebinningPulsesNumberPeriods(); + double timeStep = m_view->rebinningPulsesTime(); + + try { + inputChecksBeforeRebinPulses(runNo, nperiods, timeStep); + } catch (std::invalid_argument &ia) { + m_view->userWarning("Error in the inputs required to pre-process (rebin) a " + "run by pulse times", + ia.what()); + return; + } + const std::string outWSName = "engggui_preproc_by_pulse_time_ws"; + g_log.notice() << "EnggDiffraction GUI: starting new pre-processing " + "(re-binning) by pulse times into workspace '" + + outWSName + + "'. This " + "may take some seconds... \n"; + + m_view->showStatus("Rebinning by pulses..."); + m_view->enableCalibrateFocusFitUserActions(false); + startAsyncRebinningPulsesWorker(runNo, nperiods, timeStep, outWSName); +} + +void EnggDiffractionPresenter::processLogMsg() { + std::vector<std::string> msgs = m_view->logMsgs(); + for (const auto &msg : msgs) { + g_log.information() << msg << '\n'; + } +} + +void EnggDiffractionPresenter::processInstChange() { + m_currentInst = m_view->currentInstrument(); + m_view->updateTabsInstrument(m_currentInst); +} + +void EnggDiffractionPresenter::processRBNumberChange() { + const std::string rbn = m_view->getRBNumber(); + auto valid = validateRBNumber(rbn); + m_view->enableTabs(valid); + m_view->showInvalidRBNumber(valid); + if (!valid) { + m_view->showStatus("Valid RB number required"); + } else { + m_view->showStatus("Ready"); + } +} + +void EnggDiffractionPresenter::processShutDown() { + // Set that the view has closed in case QT attempts to fire another + // signal whilst we are shutting down. This stops notify before + // it hits the switch statement as the view could be in any state. + m_viewHasClosed = true; + m_view->showStatus("Closing..."); + m_view->saveSettings(); + cleanup(); +} + +void EnggDiffractionPresenter::processStopFocus() { + if (m_workerThread) { + if (m_workerThread->isRunning()) { + g_log.notice() << "A focus process is currently running, shutting " + "it down as soon as possible...\n"; + + g_abortThread = true; + g_log.warning() << "Focus Stop has been clicked, please wait until " + "current focus run process has been completed. \n"; + } + } +} + +/** + * Check if an RB number is valid to work with it (retrieve data, + * calibrate, focus, etc.). For now this will accept any non-empty + * string. Later on we might be more strict about valid RB numbers / + * experiment IDs. + * + * @param rbn RB number as given by the user + */ +bool EnggDiffractionPresenter::validateRBNumber(const std::string &rbn) const { + return !rbn.empty(); +} + +/** + * Checks if the provided run number is valid and if a directory is + * provided it will convert it to a run number. It also records the + * paths the user has browsed to. + * + * @param userPaths the input/directory given by the user via the "browse" + * button + * + * @return run_number 6 character string of a run number + */ +std::string EnggDiffractionPresenter::isValidRunNumber( + const std::vector<std::string> &userPaths) { + + std::string run_number; + if (userPaths.empty() || userPaths.front().empty()) { + return run_number; + } + return userPaths[0]; +} + +/** + * Checks if the provided run number is valid and if a directory is provided + * + * @param paths takes the input/paths of the user + * + * @return vector of string multi_run_number, 6 character string of a run number + */ +std::vector<std::string> EnggDiffractionPresenter::isValidMultiRunNumber( + const std::vector<std::string> &paths) { + + std::vector<std::string> multi_run_number; + if (paths.empty() || paths.front().empty()) + return multi_run_number; + return paths; +} + +/** + * Does several checks on the current inputs and settings. This should + * be done before starting any calibration work. The message return + * should in principle be shown to the user as a visible message + * (pop-up, error log, etc.) + * + * @param newVanNo number of the Vanadium run for the new calibration + * @param newCeriaNo number of the Ceria run for the new calibration + * + * @throws std::invalid_argument with an informative message. + */ +void EnggDiffractionPresenter::inputChecksBeforeCalibrate( + const std::string &newVanNo, const std::string &newCeriaNo) { + if (newVanNo.empty()) { + throw std::invalid_argument("The Vanadium number" + g_runNumberErrorStr); + } + if (newCeriaNo.empty()) { + throw std::invalid_argument("The Ceria number" + g_runNumberErrorStr); + } + + const auto &cs = m_view->currentCalibSettings(); + const auto &pixelCalib = cs.m_pixelCalibFilename; + if (pixelCalib.empty()) { + throw std::invalid_argument( + "You need to set a pixel (full) calibration in settings."); + } + const auto &templGSAS = cs.m_templateGSAS_PRM; + if (templGSAS.empty()) { + throw std::invalid_argument( + "You need to set a template calibration file for GSAS in settings."); + } +} + +/** + * What should be the name of the output GSAS calibration file, given + * the Vanadium and Ceria runs + * + * @param vanNo number of the Vanadium run, which is normally part of the name + * @param ceriaNo number of the Ceria run, which is normally part of the name + * @param bankName bank name when generating a file for an individual + * bank. Leave empty to use a generic name for all banks + * + * @return filename (without the full path) + */ +std::string +EnggDiffractionPresenter::outputCalibFilename(const std::string &vanNo, + const std::string &ceriaNo, + const std::string &bankName) { + std::string outFilename = ""; + const std::string sugg = + buildCalibrateSuggestedFilename(vanNo, ceriaNo, bankName); + if (!g_askUserCalibFilename) { + outFilename = sugg; + } else { + outFilename = m_view->askNewCalibrationFilename(sugg); + if (!outFilename.empty()) { + // make sure it follows the rules + try { + std::string inst, van, ceria; + parseCalibrateFilename(outFilename, inst, van, ceria); + } catch (std::invalid_argument &ia) { + m_view->userWarning( + "Invalid output calibration filename: " + outFilename, ia.what()); + outFilename = ""; + } + } + } + + return outFilename; +} + +/** + * Parses the name of a calibration file and guesses the instrument, + * vanadium and ceria run numbers, assuming that the name has been + * build with buildCalibrateSuggestedFilename(). + * + * @todo this is currently based on the filename. This method should + * do a basic sanity check that the file is actually a calibration + * file (IPARM file for GSAS), and get the numbers from the file not + * from the name of the file. Leaving this as a TODO for now, as the + * file template and contents are still subject to change. + * + * @param path full path to a calibration file + * @param instName instrument used in the file + * @param vanNo number of the Vanadium run used for this calibration file + * @param ceriaNo number of the Ceria run + * + * @throws invalid_argument with an informative message if tha name does + * not look correct (does not follow the conventions). + */ +void EnggDiffractionPresenter::parseCalibrateFilename(const std::string &path, + std::string &instName, + std::string &vanNo, + std::string &ceriaNo) { + instName = ""; + vanNo = ""; + ceriaNo = ""; + + Poco::Path fullPath(path); + const std::string &filename = fullPath.getFileName(); + if (filename.empty()) { + return; + } + + const std::string explMsg = + "Expected a file name like 'INSTR_vanNo_ceriaNo_....par', " + "where INSTR is the instrument name and vanNo and ceriaNo are the " + "numbers of the Vanadium and calibration sample (Ceria, CeO2) runs."; + std::vector<std::string> parts; + boost::split(parts, filename, boost::is_any_of("_")); + if (parts.size() < 4) { + throw std::invalid_argument( + "Failed to find at least the 4 required parts of the file name.\n\n" + + explMsg); + } + + // check the rules on the file name + if (m_currentInst != parts[0]) { + throw std::invalid_argument("The first component of the file name is not " + "the expected instrument name: " + + m_currentInst + ".\n\n" + explMsg); + } + + instName = parts[0]; +} + +/** + * Start the calibration work without blocking the GUI. This uses + * connect for Qt signals/slots so that it runs well with the Qt event + * loop. Because of that this class needs to be a Q_OBJECT. + * + * @param outFilename name for the output GSAS calibration file + * @param vanNo vanadium run number + * @param ceriaNo ceria run number + * @param specNos SpecNos or bank name to be passed + */ +void EnggDiffractionPresenter::startAsyncCalibWorker( + const std::string &outFilename, const std::string &vanNo, + const std::string &ceriaNo, const std::string &specNos) { + delete m_workerThread; + m_workerThread = new QThread(this); + auto *worker = new EnggDiffWorker(this, outFilename, vanNo, ceriaNo, specNos); + worker->moveToThread(m_workerThread); + + connect(m_workerThread, SIGNAL(started()), worker, SLOT(calibrate())); + connect(worker, SIGNAL(finished()), this, SLOT(calibrationFinished())); + // early delete of thread and worker + connect(m_workerThread, SIGNAL(finished()), m_workerThread, + SLOT(deleteLater()), Qt::DirectConnection); + connect(worker, SIGNAL(finished()), worker, SLOT(deleteLater())); + m_workerThread->start(); +} + +/** + * Calculate a new calibration. This is what threads/workers should + * use to run the calculations in response to the user clicking + * 'calibrate' or similar. + * + * @param outFilename name for the output GSAS calibration file + * @param vanNo vanadium run number + * @param ceriaNo ceria run number + * @param specNos SpecNos or bank name to be passed + */ +void EnggDiffractionPresenter::doNewCalibration(const std::string &outFilename, + const std::string &vanNo, + const std::string &ceriaNo, + const std::string &specNos) { + g_log.notice() << "Generating new calibration file: " << outFilename << '\n'; + + EnggDiffCalibSettings cs = m_view->currentCalibSettings(); + Mantid::Kernel::ConfigServiceImpl &conf = + Mantid::Kernel::ConfigService::Instance(); + const std::vector<std::string> tmpDirs = conf.getDataSearchDirs(); + // in principle, the run files will be found from 'DirRaw', and the + // pre-calculated Vanadium corrections from 'DirCalib' + if (!cs.m_inputDirCalib.empty() && Poco::File(cs.m_inputDirCalib).exists()) { + conf.appendDataSearchDir(cs.m_inputDirCalib); + } + if (!cs.m_inputDirRaw.empty() && Poco::File(cs.m_inputDirRaw).exists()) + conf.appendDataSearchDir(cs.m_inputDirRaw); + for (const auto &browsed : m_browsedToPaths) { + conf.appendDataSearchDir(browsed); + } + + try { + m_calibFinishedOK = true; + doCalib(cs, vanNo, ceriaNo, outFilename, specNos); + } catch (std::runtime_error &rexc) { + m_calibFinishedOK = false; + m_calibError = "The calibration calculations failed. One of the " + "algorithms did not execute correctly. See log messages for " + "further details."; + g_log.error() + << "The calibration calculations failed. One of the " + "algorithms did not execute correctly. See log messages for " + "further details. Error: " + + std::string(rexc.what()) + << '\n'; + } catch (std::invalid_argument &iaexc) { + m_calibFinishedOK = false; + m_calibError = "The calibration calculations failed. Some input properties " + "were not valid. See log messages for details. \n Error: " + + std::string(iaexc.what()); + g_log.error() + << "The calibration calculations failed. Some input properties " + "were not valid. See log messages for details. \n"; + } catch (Mantid::API::Algorithm::CancelException &) { + m_calibFinishedOK = false; + m_cancelled = true; + g_log.warning() << "Execution cancelled by user. \n"; + } + // restore normal data search paths + conf.setDataSearchDirs(tmpDirs); +} + +/** + * Method to call when the calibration work has finished, either from + * a separate thread or not (as in this presenter's' test). + */ +void EnggDiffractionPresenter::calibrationFinished() { + if (!m_view) + return; + + m_view->enableCalibrateFocusFitUserActions(true); + if (!m_calibFinishedOK) { + if (!m_cancelled) { + m_view->userWarning("Calibration Error", m_calibError); + } + m_cancelled = false; + + m_view->showStatus("Calibration didn't finish succesfully. Ready"); + } else { + const std::string vanNo = isValidRunNumber(m_view->newVanadiumNo()); + + const std::string ceriaNo = isValidRunNumber(m_view->newCeriaNo()); + updateCalibParmsTable(); + m_view->newCalibLoaded(vanNo, ceriaNo, m_calibFullPath); + g_log.notice() + << "Calibration finished and ready as 'current calibration'.\n"; + m_view->showStatus("Calibration finished succesfully. Ready"); + } + if (m_workerThread) { + delete m_workerThread; + m_workerThread = nullptr; + } +} + +/** + * Build a suggested name for a new calibration, by appending instrument name, + * relevant run numbers, etc., like: ENGINX_241391_236516_all_banks.par + * + * @param vanNo number of the Vanadium run + * @param ceriaNo number of the Ceria run + * @param bankName bank name when generating a file for an individual + * bank. Leave empty to use a generic name for all banks + * + * @return Suggested name for a new calibration file, following + * ENGIN-X practices + */ +std::string EnggDiffractionPresenter::buildCalibrateSuggestedFilename( + const std::string &vanNo, const std::string &ceriaNo, + const std::string &bankName) const { + // default and only one supported instrument for now + std::string instStr = m_currentInst; + std::string nameAppendix = "_all_banks"; + if (!bankName.empty()) { + nameAppendix = "_" + bankName; + } + + // default extension for calibration files + const std::string calibExt = ".prm"; + std::string vanFilename = Poco::Path(vanNo).getBaseName(); + std::string ceriaFilename = Poco::Path(ceriaNo).getBaseName(); + std::string vanRun = + vanFilename.substr(vanFilename.find(instStr) + instStr.size()); + std::string ceriaRun = + ceriaFilename.substr(ceriaFilename.find(instStr) + instStr.size()); + vanRun.erase(0, std::min(vanRun.find_first_not_of('0'), vanRun.size() - 1)); + ceriaRun.erase( + 0, std::min(ceriaRun.find_first_not_of('0'), ceriaRun.size() - 1)); + std::string sugg = + instStr + "_" + vanRun + "_" + ceriaRun + nameAppendix + calibExt; + + return sugg; +} + +std::vector<GSASCalibrationParms> +EnggDiffractionPresenter::currentCalibration() const { + return m_currentCalibParms; +} + +/** + * Calculate a calibration, responding the the "new calibration" + * action/button. + * + * @param cs user settings + * @param vanNo Vanadium run number + * @param ceriaNo Ceria run number + * @param outFilename output filename chosen by the user + * @param specNos SpecNos or bank name to be passed + */ +void EnggDiffractionPresenter::doCalib(const EnggDiffCalibSettings &cs, + const std::string &vanNo, + const std::string &ceriaNo, + const std::string &outFilename, + const std::string &specNos) { + if (cs.m_inputDirCalib.empty()) { + m_calibError = + "No calibration directory selected. Please select a calibration " + "directory in Settings. This will be used to " + "cache Vanadium calibration data"; + g_log.warning("No calibration directory selected. Please select a " + "calibration directory in Settings. This will be used to " + "cache Vanadium calibration data"); + // This should be a userWarning once the threading problem has been dealt + // with + m_calibFinishedOK = false; + return; + } + + // TODO: the settings tab should emit a signal when these are changed, on + // which the vanadium corrections model should be updated automatically + m_vanadiumCorrectionsModel->setCalibSettings(cs); + m_vanadiumCorrectionsModel->setCurrentInstrument(m_view->currentInstrument()); + const auto vanadiumCorrectionWorkspaces = + m_vanadiumCorrectionsModel->fetchCorrectionWorkspaces(vanNo); + const auto &vanIntegWS = vanadiumCorrectionWorkspaces.first; + const auto &vanCurvesWS = vanadiumCorrectionWorkspaces.second; + + MatrixWorkspace_sptr ceriaWS; + try { + auto load = Mantid::API::AlgorithmManager::Instance().create("Load"); + load->initialize(); + load->setPropertyValue("Filename", ceriaNo); + const std::string ceriaWSName = "engggui_calibration_sample_ws"; + load->setPropertyValue("OutputWorkspace", ceriaWSName); + load->execute(); + + AnalysisDataServiceImpl &ADS = Mantid::API::AnalysisDataService::Instance(); + ceriaWS = ADS.retrieveWS<MatrixWorkspace>(ceriaWSName); + } catch (std::runtime_error &re) { + g_log.error() + << "Error while loading calibration sample data. " + "Could not run the algorithm Load succesfully for the " + "calibration " + "sample (run number: " + + ceriaNo + "). Error description: " + re.what() + + " Please check also the previous log messages for details."; + throw; + } + + // Bank 1 and 2 - ENGIN-X + // bank 1 - loops once & used for cropped calibration + // bank 2 - loops twice, one with each bank & used for new calibration + std::vector<double> difa, difc, tzero; + // for the names of the output files + std::vector<std::string> bankNames; + + bool specNumUsed = specNos != ""; + // TODO: this needs sanitizing, it should be simpler + if (specNumUsed) { + constexpr size_t bankNo1 = 1; + + difa.resize(bankNo1); + difc.resize(bankNo1); + tzero.resize(bankNo1); + int selection = m_view->currentCropCalibBankName(); + if (0 == selection) { + // user selected "custom" name + const std::string customName = m_view->currentCalibCustomisedBankName(); + if (customName.empty()) { + bankNames.emplace_back("cropped"); + } else { + bankNames.emplace_back(customName); + } + } else if (1 == selection) { + bankNames.emplace_back("North"); + } else { + bankNames.emplace_back("South"); + } + } else { + constexpr size_t bankNo2 = 2; + + difa.resize(bankNo2); + difc.resize(bankNo2); + tzero.resize(bankNo2); + bankNames = {"North", "South"}; + } + + for (size_t i = 0; i < difc.size(); i++) { + auto alg = + Mantid::API::AlgorithmManager::Instance().create("EnggCalibrate"); + + alg->initialize(); + alg->setProperty("InputWorkspace", ceriaWS); + alg->setProperty("VanIntegrationWorkspace", vanIntegWS); + alg->setProperty("VanCurvesWorkspace", vanCurvesWS); + if (specNumUsed) { + alg->setPropertyValue(g_calibCropIdentifier, + boost::lexical_cast<std::string>(specNos)); + } else { + alg->setPropertyValue("Bank", boost::lexical_cast<std::string>(i + 1)); + } + const std::string outFitParamsTblName = + outFitParamsTblNameGenerator(specNos, i); + alg->setPropertyValue("FittedPeaks", outFitParamsTblName); + alg->setPropertyValue("OutputParametersTableName", outFitParamsTblName); + alg->execute(); + if (!alg->isExecuted()) { + g_log.error() << "Error in calibration. ", + "Could not run the algorithm EnggCalibrate successfully for bank " + + boost::lexical_cast<std::string>(i); + throw std::runtime_error("EnggCalibrate failed"); + } + + difa[i] = alg->getProperty("DIFA"); + difc[i] = alg->getProperty("DIFC"); + tzero[i] = alg->getProperty("TZERO"); + + g_log.information() << " * Bank " << i + 1 << " calibrated, " + << "difa: " << difa[i] << ", difc: " << difc[i] + << ", zero: " << tzero[i] << '\n'; + } + + // Creates appropriate output directory + const std::string calibrationComp = "Calibration"; + const Poco::Path userCalSaveDir = outFilesUserDir(calibrationComp); + const Poco::Path generalCalSaveDir = outFilesGeneralDir(calibrationComp); + + // Use poco to append filename so it is OS independent + std::string userCalFullPath = + appendToPath(userCalSaveDir.toString(), outFilename); + std::string generalCalFullPath = + appendToPath(generalCalSaveDir.toString(), outFilename); + + // Double horror: 1st use a python script + // 2nd: because runPythonCode does this by emitting a signal that goes to + // MantidPlot, it has to be done in the view (which is a UserSubWindow). + // First write the all banks parameters file + m_calibFullPath = generalCalSaveDir.toString(); + writeOutCalibFile(userCalFullPath, difa, difc, tzero, bankNames, ceriaNo, + vanNo); + writeOutCalibFile(generalCalFullPath, difa, difc, tzero, bankNames, ceriaNo, + vanNo); + + m_currentCalibParms.clear(); + + // Then write one individual file per bank, using different templates and the + // specific bank name as suffix + for (size_t bankIdx = 0; bankIdx < difc.size(); ++bankIdx) { + // Need to use van number not file name here else it will be + // "ENGINX_ENGINX12345_ENGINX12345...." as out name + const std::string bankFilename = buildCalibrateSuggestedFilename( + vanNo, ceriaNo, "bank_" + bankNames[bankIdx]); + + // Regenerate both full paths for each bank now + userCalFullPath = appendToPath(userCalSaveDir.toString(), bankFilename); + generalCalFullPath = + appendToPath(generalCalSaveDir.toString(), bankFilename); + + std::string templateFile = "template_ENGINX_241391_236516_North_bank.prm"; + if (1 == bankIdx) { + templateFile = "template_ENGINX_241391_236516_South_bank.prm"; + } + + writeOutCalibFile(userCalFullPath, {difa[bankIdx]}, {difc[bankIdx]}, + {tzero[bankIdx]}, {bankNames[bankIdx]}, ceriaNo, vanNo, + templateFile); + writeOutCalibFile(generalCalFullPath, {difa[bankIdx]}, {difc[bankIdx]}, + {tzero[bankIdx]}, {bankNames[bankIdx]}, ceriaNo, vanNo, + templateFile); + + m_currentCalibParms.emplace_back(GSASCalibrationParms( + bankIdx, difc[bankIdx], difa[bankIdx], tzero[bankIdx])); + if (1 == difc.size()) { + // it is a single bank or cropped calibration, so take its specific name + m_calibFullPath = generalCalFullPath; + } + } + g_log.notice() << "Calibration file written as " << generalCalFullPath << '\n' + << "And: " << userCalFullPath; + + // plots the calibrated workspaces. + g_plottingCounter++; + plotCalibWorkspace(difa, difc, tzero, specNos); +} + +/** + * Appends the current instrument as a filename prefix for numeric + * only inputs of the Vanadium run so Load can find the file + * + * @param vanNo The user input for the vanadium run + * @param outVanName The fixed filename for the vanadium run + */ +void EnggDiffractionPresenter::appendCalibInstPrefix( + const std::string &vanNo, std::string &outVanName) const { + // Use a single non numeric digit so we are guaranteed to skip + // generating cerium file names + const std::string cer = "-"; + std::string outCerName; + appendCalibInstPrefix(vanNo, cer, outVanName, outCerName); +} + +/** + * Appends the current instrument as a filename prefix for numeric + * only inputs of both the Vanadium and Cerium Oxide runs so Load + * can find the files. + * + * @param vanNo The user input for the vanadium run + * @param cerNo The user input for the cerium run + * @param outVanName The fixed filename for the vanadium run + * @param outCerName The fixed filename for the cerium run + */ +void EnggDiffractionPresenter::appendCalibInstPrefix( + const std::string &vanNo, const std::string &cerNo, std::string &outVanName, + std::string &outCerName) const { + + // Load uses the default instrument if we don't give it the name of the + // instrument as a prefix (m_currentInst), when one isn't set or is set + // incorrectly, we prepend the name of the instrument to the vanadium number + // so that load can find the file and not cause a crash in Mantid + // Vanadium file + if (std::all_of(vanNo.begin(), vanNo.end(), ::isdigit)) { + // This only has digits - append prefix + outVanName = m_currentInst + vanNo; + } + + // Cerium file + if (std::all_of(cerNo.begin(), cerNo.end(), ::isdigit)) { + // All digits - append inst prefix + outCerName = m_currentInst + cerNo; + } +} + +/** + * Perform checks specific to normal/basic run focusing in addition to + * the general checks for any focusing (as done by + * inputChecksBeforeFocus() which is called from this method). Use + * always before running 'Focus' + * + * @param multi_RunNo vector of run number to focus + * @param banks which banks to consider in the focusing + * + * @throws std::invalid_argument with an informative message. + */ +void EnggDiffractionPresenter::inputChecksBeforeFocusBasic( + const std::vector<std::string> &multi_RunNo, + const std::vector<bool> &banks) { + if (multi_RunNo.size() == 0) { + const std::string msg = "The sample run number" + g_runNumberErrorStr; + throw std::invalid_argument(msg); + } + + inputChecksBanks(banks); + + inputChecksBeforeFocus(); +} + +/** + * Perform checks specific to focusing in "cropped" mode, in addition + * to the general checks for any focusing (as done by + * inputChecksBeforeFocus() which is called from this method). Use + * always before running 'FocusCropped' + * + * @param multi_RunNo vector of run number to focus + * @param banks which banks to consider in the focusing + * @param specNos list of spectra (as usual csv list of spectra in Mantid) + * + * @throws std::invalid_argument with an informative message. + */ +void EnggDiffractionPresenter::inputChecksBeforeFocusCropped( + const std::vector<std::string> &multi_RunNo, const std::vector<bool> &banks, + const std::string &specNos) { + if (multi_RunNo.size() == 0) { + throw std::invalid_argument("To focus cropped the sample run number" + + g_runNumberErrorStr); + } + + if (specNos.empty()) { + throw std::invalid_argument( + "The Spectrum Numbers field cannot be empty when " + "focusing in 'cropped' mode."); + } + + inputChecksBanks(banks); + + inputChecksBeforeFocus(); +} + +/** + * Perform checks specific to focusing in "texture" mode, in addition + * to the general checks for any focusing (as done by + * inputChecksBeforeFocus() which is called from this method). Use + * always before running 'FocusCropped' + * + * @param multi_RunNo vector of run number to focus + * @param dgFile file with detector grouping info + * + * @throws std::invalid_argument with an informative message. + */ +void EnggDiffractionPresenter::inputChecksBeforeFocusTexture( + const std::vector<std::string> &multi_RunNo, const std::string &dgFile) { + if (multi_RunNo.size() == 0) { + throw std::invalid_argument("To focus texture banks the sample run number" + + g_runNumberErrorStr); + } + + if (dgFile.empty()) { + throw std::invalid_argument("A detector grouping file needs to be " + "specified when focusing texture banks."); + } + Poco::File dgf(dgFile); + if (!dgf.exists()) { + throw std::invalid_argument( + "The detector grouping file coult not be found: " + dgFile); + } + + inputChecksBeforeFocus(); +} + +void EnggDiffractionPresenter::inputChecksBanks( + const std::vector<bool> &banks) { + if (0 == banks.size()) { + const std::string msg = + "Error in specification of banks found when starting the " + "focusing process. Cannot continue."; + g_log.error() << msg << '\n'; + throw std::invalid_argument(msg); + } + if (banks.end() == std::find(banks.begin(), banks.end(), true)) { + const std::string msg = + "EnggDiffraction GUI: not focusing, as none of the banks " + "have been selected. You probably forgot to select at least one."; + g_log.warning() << msg << '\n'; + throw std::invalid_argument(msg); + } +} + +/** + * Performs several checks on the current focusing inputs and + * settings. This should be done before starting any focus work. The + * message return should be shown to the user as a visible message + * (pop-up, error log, etc.) + * + * @throws std::invalid_argument with an informative message. + */ +void EnggDiffractionPresenter::inputChecksBeforeFocus() { + EnggDiffCalibSettings cs = m_view->currentCalibSettings(); + const std::string pixelCalib = cs.m_pixelCalibFilename; + if (pixelCalib.empty()) { + throw std::invalid_argument( + "You need to set a pixel (full) calibration in settings."); + } +} + +/** + * Builds the names of the output focused files (one per bank), given + * the sample run number and which banks should be focused. + * + * @param runNo number of the run for which we want a focused output + * file name + * + * @param banks for every bank, (true/false) to consider it or not for + * the focusing + * + * @return filenames (without the full path) + */ +std::vector<std::string> +EnggDiffractionPresenter::outputFocusFilenames(const std::string &runNo, + const std::vector<bool> &banks) { + const std::string instStr = m_view->currentInstrument(); + const std::string runNumber = Poco::Path(runNo).getBaseName(); + std::vector<std::string> res; + res.reserve(banks.size()); + const auto instrumentPresent = runNumber.find(instStr); + std::string runName = + (instrumentPresent != std::string::npos) + ? runNumber.substr(instrumentPresent + instStr.size()) + : runNumber; + + std::string prefix = instStr + "_" + + runName.erase(0, std::min(runName.find_first_not_of('0'), + runName.size() - 1)) + + "_focused_bank_"; + + for (size_t b = 1; b <= banks.size(); b++) { + res.emplace_back(prefix + boost::lexical_cast<std::string>(b) + ".nxs"); + } + return res; +} + +std::string +EnggDiffractionPresenter::outputFocusCroppedFilename(const std::string &runNo) { + const std::string instStr = m_view->currentInstrument(); + const std::string runNumber = Poco::Path(runNo).getBaseName(); + const auto instrumentPresent = runNumber.find(instStr); + std::string runName = + (instrumentPresent != std::string::npos) + ? runNumber.substr(instrumentPresent + instStr.size()) + : runNumber; + return instStr + "_" + + runName.erase( + 0, std::min(runName.find_first_not_of('0'), runName.size() - 1)) + + "_focused_cropped.nxs"; +} + +std::vector<std::string> EnggDiffractionPresenter::sumOfFilesLoadVec() { + std::vector<std::string> multi_RunNo; + + if (g_sumOfFilesFocus == "basic") + multi_RunNo = isValidMultiRunNumber(m_view->focusingRunNo()); + else if (g_sumOfFilesFocus == "cropped") + multi_RunNo = isValidMultiRunNumber(m_view->focusingCroppedRunNo()); + else if (g_sumOfFilesFocus == "texture") + multi_RunNo = isValidMultiRunNumber(m_view->focusingTextureRunNo()); + + return multi_RunNo; +} + +std::vector<std::string> EnggDiffractionPresenter::outputFocusTextureFilenames( + const std::string &runNo, const std::vector<size_t> &bankIDs) { + const std::string instStr = m_view->currentInstrument(); + const std::string runNumber = Poco::Path(runNo).getBaseName(); + const std::string runName = + runNumber.substr(runNumber.find(instStr) + instStr.size()); + std::vector<std::string> res; + res.reserve(bankIDs.size()); + std::string prefix = instStr + "_" + runName + "_focused_texture_bank_"; + for (auto bankID : bankIDs) { + res.emplace_back(prefix + boost::lexical_cast<std::string>(bankID) + + ".nxs"); + } + + return res; +} + +/** + * Start the focusing algorithm(s) without blocking the GUI. This is + * based on Qt connect / signals-slots so that it goes in sync with + * the Qt event loop. For that reason this class needs to be a + * Q_OBJECT. + * + * @param multi_RunNo input vector of run number + * @param banks instrument bank to focus + * @param specNos list of spectra (as usual csv list of spectra in Mantid) + * @param dgFile detector grouping file name + */ +void EnggDiffractionPresenter::startAsyncFocusWorker( + const std::vector<std::string> &multi_RunNo, const std::vector<bool> &banks, + const std::string &dgFile, const std::string &specNos) { + + delete m_workerThread; + m_workerThread = new QThread(this); + EnggDiffWorker *worker = + new EnggDiffWorker(this, multi_RunNo, banks, dgFile, specNos); + worker->moveToThread(m_workerThread); + connect(m_workerThread, SIGNAL(started()), worker, SLOT(focus())); + connect(worker, SIGNAL(finished()), this, SLOT(focusingFinished())); + // early delete of thread and worker + connect(m_workerThread, SIGNAL(finished()), m_workerThread, + SLOT(deleteLater()), Qt::DirectConnection); + connect(worker, SIGNAL(finished()), worker, SLOT(deleteLater())); + m_workerThread->start(); +} + +/** + * Produce a new focused output file. This is what threads/workers + * should use to run the calculations required to process a 'focus' + * push or similar from the user. + * + * @param runNo input run number + * + * @param specNos list of spectra to use when focusing. Not empty + * implies focusing in cropped mode. + * + * @param dgFile detector grouping file to define banks (texture). Not + * empty implies focusing in texture mode. + * + * @param banks for every bank, (true/false) to consider it or not for + * the focusing + */ +void EnggDiffractionPresenter::doFocusRun(const std::string &runNo, + const std::vector<bool> &banks, + const std::string &specNos, + const std::string &dgFile) { + + if (g_abortThread) { + return; + } + + // to track last valid run + g_lastValidRun = runNo; + + g_log.notice() << "Generating new focusing workspace(s) and file(s)"; + + // TODO: this is almost 100% common with doNewCalibrate() - refactor + EnggDiffCalibSettings cs = m_view->currentCalibSettings(); + Mantid::Kernel::ConfigServiceImpl &conf = + Mantid::Kernel::ConfigService::Instance(); + const std::vector<std::string> tmpDirs = conf.getDataSearchDirs(); + // in principle, the run files will be found from 'DirRaw', and the + // pre-calculated Vanadium corrections from 'DirCalib' + if (!cs.m_inputDirCalib.empty() && Poco::File(cs.m_inputDirCalib).exists()) { + conf.appendDataSearchDir(cs.m_inputDirCalib); + } + if (!cs.m_inputDirRaw.empty() && Poco::File(cs.m_inputDirRaw).exists()) { + conf.appendDataSearchDir(cs.m_inputDirRaw); + } + for (const auto &browsed : m_browsedToPaths) { + conf.appendDataSearchDir(browsed); + } + + // Prepare special inputs for "texture" focusing + std::vector<size_t> bankIDs; + std::vector<std::string> effectiveFilenames; + std::vector<std::string> specs; + if (!specNos.empty()) { + // Cropped focusing + // just to iterate once, but there's no real bank here + bankIDs.emplace_back(0); + specs.emplace_back(specNos); // one spectrum Nos list given by the user + effectiveFilenames.emplace_back(outputFocusCroppedFilename(runNo)); + } else { + if (dgFile.empty()) { + // Basic/normal focusing + for (size_t bidx = 0; bidx < banks.size(); bidx++) { + if (banks[bidx]) { + bankIDs.emplace_back(bidx + 1); + specs.emplace_back(""); + effectiveFilenames = outputFocusFilenames(runNo, banks); + } + } + } else { + // texture focusing + try { + loadDetectorGroupingCSV(dgFile, bankIDs, specs); + } catch (std::runtime_error &re) { + g_log.error() << "Error loading detector grouping file: " + dgFile + + ". Detailed error: " + re.what() + << '\n'; + bankIDs.clear(); + specs.clear(); + } + effectiveFilenames = outputFocusTextureFilenames(runNo, bankIDs); + } + } + + // focus all requested banks + for (size_t idx = 0; idx < bankIDs.size(); idx++) { + g_log.notice() << "Generating new focused file (bank " + + boost::lexical_cast<std::string>(bankIDs[idx]) + + ") for run " + runNo + " into: " + << effectiveFilenames[idx] << '\n'; + try { + + doFocusing(cs, runNo, bankIDs[idx], specs[idx], dgFile); + m_focusFinishedOK = true; + } catch (std::runtime_error &rexc) { + m_focusFinishedOK = false; + g_log.error() << "The focusing calculations failed. One of the algorithms" + "did not execute correctly. See log messages for " + "further details. Error: " + + std::string(rexc.what()) + << '\n'; + } catch (std::invalid_argument &ia) { + m_focusFinishedOK = false; + g_log.error() << "The focusing failed. Some input properties " + "were not valid. " + "See log messages for details. Error: " + << ia.what() << '\n'; + } catch (const Mantid::API::Algorithm::CancelException &) { + m_focusFinishedOK = false; + g_log.error() << "Focus terminated by user.\n"; + } + } + + // restore initial data search paths + conf.setDataSearchDirs(tmpDirs); +} + +void EnggDiffractionPresenter::loadDetectorGroupingCSV( + const std::string &dgFile, std::vector<size_t> &bankIDs, + std::vector<std::string> &specs) { + const char commentChar = '#'; + const std::string delim = ","; + + std::ifstream file(dgFile.c_str()); + if (!file.is_open()) { + throw std::runtime_error("Failed to open file."); + } + + bankIDs.clear(); + specs.clear(); + std::string line; + for (size_t li = 1; getline(file, line); li++) { + if (line.empty() || commentChar == line[0]) + continue; + + auto delimPos = line.find_first_of(delim); + if (std::string::npos == delimPos) { + throw std::runtime_error( + "In file '" + dgFile + + "', wrong format in line: " + boost::lexical_cast<std::string>(li) + + " which does not contain any delimiters (comma, etc.)"); + } + + try { + const std::string bstr = line.substr(0, delimPos); + const std::string spec = line.substr(delimPos + 1, std::string::npos); + + if (bstr.empty()) { + throw std::runtime_error( + "In file '" + dgFile + "', wrong format in line: " + + boost::lexical_cast<std::string>(li) + ", the bank ID is empty!"); + } + if (spec.empty()) { + throw std::runtime_error( + "In file '" + dgFile + + "', wrong format in line: " + boost::lexical_cast<std::string>(li) + + ", the list of spectrum Nos is empty!"); + } + + size_t bankID = boost::lexical_cast<size_t>(bstr); + bankIDs.emplace_back(bankID); + specs.emplace_back(spec); + } catch (std::runtime_error &re) { + throw std::runtime_error( + "In file '" + dgFile + + "', issue found when trying to interpret line: " + + boost::lexical_cast<std::string>(li) + + ". Error description: " + re.what()); + } + } +} + +/** + * Method (Qt slot) to call when the focusing work has finished, + * possibly from a separate thread but sometimes not (as in this + * presenter class' test). + */ +void EnggDiffractionPresenter::focusingFinished() { + if (!m_view) + return; + + if (!m_focusFinishedOK) { + g_log.warning() << "The focusing did not finish correctly. Check previous " + "log messages for details\n"; + m_view->showStatus("Focusing didn't finish succesfully. Ready"); + } else { + g_log.notice() << "Focusing finished - focused run(s) are ready.\n"; + m_view->showStatus("Focusing finished succesfully. Ready"); + } + if (m_workerThread) { + delete m_workerThread; + m_workerThread = nullptr; + } + + m_view->enableCalibrateFocusFitUserActions(true); + + // display warning and information to the users regarding Stop Focus + if (g_abortThread) { + // will get the last number in the list + const std::string last_RunNo = isValidRunNumber(m_view->focusingRunNo()); + if (last_RunNo != g_lastValidRun) { + g_log.warning() << "Focussing process has been stopped, last successful " + "run: " + << g_lastValidRun << '\n'; + m_view->showStatus("Focusing stopped. Ready"); + } + } +} + +/** + * Focuses a run, produces a focused workspace, and saves it into a + * file. + * + * @param cs user settings for calibration (this does not calibrate but + * uses calibration input files such as vanadium runs + * + * @param runLabel run number of the run to focus + * + * @param bank the Bank ID to focus + * + * @param specNos string specifying a list of spectra (for "cropped" + * focusing or "texture" focusing), only considered if not empty + * + * @param dgFile detector grouping file name. If not empty implies + * texture focusing + */ +void EnggDiffractionPresenter::doFocusing(const EnggDiffCalibSettings &cs, + const std::string &runLabel, + const size_t bank, + const std::string &specNos, + const std::string &dgFile) { + MatrixWorkspace_sptr inWS; + + m_vanadiumCorrectionsModel->setCalibSettings(cs); + m_vanadiumCorrectionsModel->setCurrentInstrument(m_view->currentInstrument()); + const auto vanadiumCorrectionWorkspaces = + m_vanadiumCorrectionsModel->fetchCorrectionWorkspaces( + m_view->currentVanadiumNo()); + const auto &vanIntegWS = vanadiumCorrectionWorkspaces.first; + const auto &vanCurvesWS = vanadiumCorrectionWorkspaces.second; + + const std::string inWSName = "engggui_focusing_input_ws"; + const std::string instStr = m_view->currentInstrument(); + std::vector<std::string> multi_RunNo = sumOfFilesLoadVec(); + std::string loadInput = ""; + + for (size_t i = 0; i < multi_RunNo.size(); i++) { + // if last run number in list + if (i + 1 == multi_RunNo.size()) + loadInput += multi_RunNo[i]; + else + loadInput += multi_RunNo[i] + '+'; + } + + // if its not empty the global variable is set for sumOfFiles + if (!g_sumOfFilesFocus.empty()) { + + try { + auto load = + Mantid::API::AlgorithmManager::Instance().createUnmanaged("Load"); + load->initialize(); + load->setPropertyValue("Filename", loadInput); + + load->setPropertyValue("OutputWorkspace", inWSName); + load->execute(); + + AnalysisDataServiceImpl &ADS = + Mantid::API::AnalysisDataService::Instance(); + inWS = ADS.retrieveWS<MatrixWorkspace>(inWSName); + } catch (std::runtime_error &re) { + g_log.error() + << "Error while loading files provided. " + "Could not run the algorithm Load succesfully for the focus " + "(run number provided. Error description:" + "Please check also the previous log messages for details." + + static_cast<std::string>(re.what()); + throw; + } + + if (multi_RunNo.size() == 1) { + g_log.notice() << "Only single file has been listed, the Sum Of Files" + "cannot not be processed\n"; + } else { + g_log.notice() + << "Load alogirthm has successfully merged the files provided\n"; + } + + } else { + try { + auto load = Mantid::API::AlgorithmManager::Instance().create("Load"); + load->initialize(); + load->setPropertyValue("Filename", runLabel); + load->setPropertyValue("OutputWorkspace", inWSName); + load->execute(); + + AnalysisDataServiceImpl &ADS = + Mantid::API::AnalysisDataService::Instance(); + inWS = ADS.retrieveWS<MatrixWorkspace>(inWSName); + } catch (std::runtime_error &re) { + g_log.error() << "Error while loading sample data for focusing. " + "Could not run the algorithm Load succesfully for " + "the focusing " + "sample (run number: " + + runLabel + "). Error description: " + re.what() + + " Please check also the previous log messages " + "for details."; + throw; + } + } + const auto bankString = std::to_string(bank); + std::string outWSName; + if (!dgFile.empty()) { + // doing focus "texture" + outWSName = "engggui_focusing_output_ws_texture_bank_" + bankString; + } else if (specNos.empty()) { + // doing focus "normal" / by banks + outWSName = "engggui_focusing_output_ws_bank_" + bankString; + } else { + // doing focus "cropped" + outWSName = "engggui_focusing_output_ws_cropped"; + } + try { + auto alg = Mantid::API::AlgorithmManager::Instance().create("EnggFocus"); + alg->initialize(); + alg->setProperty("InputWorkspace", inWSName); + alg->setProperty("OutputWorkspace", outWSName); + alg->setProperty("VanIntegrationWorkspace", vanIntegWS); + alg->setProperty("VanCurvesWorkspace", vanCurvesWS); + // cropped / normal focusing + if (specNos.empty()) { + alg->setPropertyValue("Bank", bankString); + } else { + alg->setPropertyValue("SpectrumNumbers", specNos); + } + // TODO: use detector positions (from calibrate full) when available + // alg->setProperty(DetectorPositions, TableWorkspace) + alg->execute(); + g_plottingCounter++; + plotFocusedWorkspace(outWSName); + + } catch (std::runtime_error &re) { + g_log.error() << "Error in calibration. ", + "Could not run the algorithm EnggCalibrate successfully for bank " + + bankString + ". Error description: " + re.what() + + " Please check also the log messages for details."; + throw; + } + g_log.notice() << "Produced focused workspace: " << outWSName << '\n'; + + const bool saveOutputFiles = m_view->saveFocusedOutputFiles(); + if (saveOutputFiles) { + try { + const auto runNo = + runLabel.substr(runLabel.rfind(instStr) + instStr.size()); + RunLabel label(runNo, bank); + saveFocusedXYE(label, outWSName); + saveGSS(label, outWSName); + saveOpenGenie(label, outWSName); + saveNexus(label, outWSName); + exportSampleLogsToHDF5(outWSName, userHDFRunFilename(runNo)); + } catch (std::runtime_error &re) { + g_log.error() << "Error saving focused data. ", + "There was an error while saving focused data. " + "Error Description: " + + std::string(re.what()) + + "Please check log messages for more details."; + throw; + } + } +} + +/** + * Loads a workspace to pre-process (rebin, etc.). The workspace + * loaded can be a MatrixWorkspace or a group of MatrixWorkspace (for + * multiperiod data). + * + * @param runNo run number to search for the file with 'Load'. + */ +Workspace_sptr +EnggDiffractionPresenter::loadToPreproc(const std::string &runNo) { + const std::string instStr = m_view->currentInstrument(); + Workspace_sptr inWS; + + // this is required when file is selected via browse button + const auto MultiRunNoDir = m_view->currentPreprocRunNo(); + const auto runNoDir = MultiRunNoDir[0]; + + try { + auto load = + Mantid::API::AlgorithmManager::Instance().createUnmanaged("Load"); + load->initialize(); + if (Poco::File(runNoDir).exists()) { + load->setPropertyValue("Filename", runNoDir); + } else { + load->setPropertyValue("Filename", instStr + runNo); + } + const std::string inWSName = "engggui_preproc_input_ws"; + load->setPropertyValue("OutputWorkspace", inWSName); + + load->execute(); + + auto &ADS = Mantid::API::AnalysisDataService::Instance(); + inWS = ADS.retrieveWS<Workspace>(inWSName); + } catch (std::runtime_error &re) { + g_log.error() + << "Error while loading run data to pre-process. " + "Could not run the algorithm Load succesfully for the run " + "number: " + + runNo + "). Error description: " + re.what() + + " Please check also the previous log messages for details."; + throw; + } + + return inWS; +} + +void EnggDiffractionPresenter::doRebinningTime(const std::string &runNo, + double bin, + const std::string &outWSName) { + + // Runs something like: + // Rebin(InputWorkspace='ws_runNo', outputWorkspace=outWSName,Params=bin) + + m_rebinningFinishedOK = false; + const Workspace_sptr inWS = loadToPreproc(runNo); + if (!inWS) + g_log.error() + << "Error: could not load the input workspace for rebinning.\n"; + + const std::string rebinName = "Rebin"; + try { + auto alg = + Mantid::API::AlgorithmManager::Instance().createUnmanaged(rebinName); + alg->initialize(); + alg->setPropertyValue("InputWorkspace", inWS->getName()); + alg->setPropertyValue("OutputWorkspace", outWSName); + alg->setProperty("Params", boost::lexical_cast<std::string>(bin)); + + alg->execute(); + } catch (std::invalid_argument &ia) { + g_log.error() << "Error when rebinning with a regular bin width in time. " + "There was an error in the inputs to the algorithm " + + rebinName + ". Error description: " + ia.what() + + ".\n"; + return; + } catch (std::runtime_error &re) { + g_log.error() << "Error when rebinning with a regular bin width in time. " + "Coult not run the algorithm " + + rebinName + + " successfully. Error description: " + re.what() + + ".\n"; + return; + } + + // succesful completion + m_rebinningFinishedOK = true; +} + +void EnggDiffractionPresenter::inputChecksBeforeRebin( + const std::string &runNo) { + if (runNo.empty()) { + throw std::invalid_argument("The run to pre-process" + g_runNumberErrorStr); + } +} + +void EnggDiffractionPresenter::inputChecksBeforeRebinTime( + const std::string &runNo, double bin) { + inputChecksBeforeRebin(runNo); + + if (bin <= 0) { + throw std::invalid_argument("The bin width must be strictly positive"); + } +} + +/** + * Starts the Rebin algorithm(s) without blocking the GUI. This is + * based on Qt connect / signals-slots so that it goes in sync with + * the Qt event loop. For that reason this class needs to be a + * Q_OBJECT. + * + * @param runNo run number(s) + * @param bin bin width parameter for Rebin + * @param outWSName name for the output workspace produced here + */ +void EnggDiffractionPresenter::startAsyncRebinningTimeWorker( + const std::string &runNo, double bin, const std::string &outWSName) { + + delete m_workerThread; + m_workerThread = new QThread(this); + auto *worker = new EnggDiffWorker(this, runNo, bin, outWSName); + worker->moveToThread(m_workerThread); + + connect(m_workerThread, SIGNAL(started()), worker, SLOT(rebinTime())); + connect(worker, SIGNAL(finished()), this, SLOT(rebinningFinished())); + // early delete of thread and worker + connect(m_workerThread, SIGNAL(finished()), m_workerThread, + SLOT(deleteLater()), Qt::DirectConnection); + connect(worker, SIGNAL(finished()), worker, SLOT(deleteLater())); + m_workerThread->start(); +} + +void EnggDiffractionPresenter::inputChecksBeforeRebinPulses( + const std::string &runNo, size_t nperiods, double timeStep) { + inputChecksBeforeRebin(runNo); + + if (0 == nperiods) { + throw std::invalid_argument("The number of periods has been set to 0 so " + "none of the periods will be processed"); + } + + if (timeStep <= 0) { + throw std::invalid_argument( + "The bin or step for the time axis must be strictly positive"); + } +} + +void EnggDiffractionPresenter::doRebinningPulses(const std::string &runNo, + size_t nperiods, + double timeStep, + const std::string &outWSName) { + // TOOD: not clear what will be the role of this parameter for now + UNUSED_ARG(nperiods); + + // Runs something like: + // RebinByPulseTimes(InputWorkspace='ws_runNo', outputWorkspace=outWSName, + // Params=timeStepstep) + + m_rebinningFinishedOK = false; + const Workspace_sptr inWS = loadToPreproc(runNo); + if (!inWS) + g_log.error() + << "Error: could not load the input workspace for rebinning.\n"; + + const std::string rebinName = "RebinByPulseTimes"; + try { + auto alg = + Mantid::API::AlgorithmManager::Instance().createUnmanaged(rebinName); + alg->initialize(); + alg->setPropertyValue("InputWorkspace", inWS->getName()); + alg->setPropertyValue("OutputWorkspace", outWSName); + alg->setProperty("Params", boost::lexical_cast<std::string>(timeStep)); + + alg->execute(); + } catch (std::invalid_argument &ia) { + g_log.error() << "Error when rebinning by pulse times. " + "There was an error in the inputs to the algorithm " + + rebinName + ". Error description: " + ia.what() + + ".\n"; + return; + } catch (std::runtime_error &re) { + g_log.error() << "Error when rebinning by pulse times. " + "Coult not run the algorithm " + + rebinName + + " successfully. Error description: " + re.what() + + ".\n"; + return; + } + + // successful execution + m_rebinningFinishedOK = true; +} + +/** + * Starts the Rebin (by pulses) algorithm(s) without blocking the + * GUI. This is based on Qt connect / signals-slots so that it goes in + * sync with the Qt event loop. For that reason this class needs to be + * a Q_OBJECT. + * + * @param runNo run number(s) + * @param nperiods max number of periods to process + * @param timeStep bin width parameter for the x (time) axis + * @param outWSName name for the output workspace produced here + */ +void EnggDiffractionPresenter::startAsyncRebinningPulsesWorker( + const std::string &runNo, size_t nperiods, double timeStep, + const std::string &outWSName) { + + delete m_workerThread; + m_workerThread = new QThread(this); + auto *worker = new EnggDiffWorker(this, runNo, nperiods, timeStep, outWSName); + worker->moveToThread(m_workerThread); + + connect(m_workerThread, SIGNAL(started()), worker, SLOT(rebinPulses())); + connect(worker, SIGNAL(finished()), this, SLOT(rebinningFinished())); + // early delete of thread and worker + connect(m_workerThread, SIGNAL(finished()), m_workerThread, + SLOT(deleteLater()), Qt::DirectConnection); + connect(worker, SIGNAL(finished()), worker, SLOT(deleteLater())); + m_workerThread->start(); +} + +/** + * Method (Qt slot) to call when the rebin work has finished, + * possibly from a separate thread but sometimes not (as in this + * presenter class' test). + */ +void EnggDiffractionPresenter::rebinningFinished() { + if (!m_view) + return; + + if (!m_rebinningFinishedOK) { + g_log.warning() << "The pre-processing (re-binning) did not finish " + "correctly. Check previous log messages for details\n"; + m_view->showStatus("Rebinning didn't finish succesfully. Ready"); + } else { + g_log.notice() << "Pre-processing (re-binning) finished - the output " + "workspace is ready.\n"; + m_view->showStatus("Rebinning finished succesfully. Ready"); + } + if (m_workerThread) { + delete m_workerThread; + m_workerThread = nullptr; + } + + m_view->enableCalibrateFocusFitUserActions(true); +} + +/** + * Checks the plot type selected and applies the appropriate + * python function to apply during first bank and second bank + * + * @param outWSName title of the focused workspace + */ +void EnggDiffractionPresenter::plotFocusedWorkspace( + const std::string &outWSName) { + const bool plotFocusedWS = m_view->focusedOutWorkspace(); + enum PlotMode { REPLACING = 0, WATERFALL = 1, MULTIPLE = 2 }; + + int plotType = m_view->currentPlotType(); + + if (plotFocusedWS) { + if (plotType == PlotMode::REPLACING) { + if (g_plottingCounter == 1) + m_view->plotFocusedSpectrum(outWSName); + else + m_view->plotReplacingWindow(outWSName, "0", "0"); + + } else if (plotType == PlotMode::WATERFALL) { + if (g_plottingCounter == 1) + m_view->plotFocusedSpectrum(outWSName); + else + m_view->plotWaterfallSpectrum(outWSName); + + } else if (plotType == PlotMode::MULTIPLE) { + m_view->plotFocusedSpectrum(outWSName); + } + } +} + +/** + * Check if the plot calibration check-box is ticked + * python script is passed on to mantid python window + * which plots the workspaces with customisation + * + * @param difa vector of double passed on to py script + * @param difc vector of double passed on to py script + * @param tzero vector of double to plot graph + * @param specNos string carrying cropped calib info + */ +void EnggDiffractionPresenter::plotCalibWorkspace( + const std::vector<double> &difa, const std::vector<double> &difc, + const std::vector<double> &tzero, const std::string &specNos) { + const bool plotCalibWS = m_view->plotCalibWorkspace(); + if (plotCalibWS) { + std::string pyCode = vanadiumCurvesPlotFactory(); + m_view->plotCalibOutput(pyCode); + + // Get the Customised Bank Name text-ield string from qt + std::string CustomisedBankName = m_view->currentCalibCustomisedBankName(); + if (CustomisedBankName.empty()) + CustomisedBankName = "cropped"; + const std::string pythonCode = + TOFFitWorkspaceFactory(difa, difc, tzero, specNos, CustomisedBankName) + + plotTOFWorkspace(CustomisedBankName); + m_view->plotCalibOutput(pythonCode); + } +} + +/** + * Convert the generated output files and saves them in + * FocusedXYE format + * + * @param runLabel run number and bank ID of the workspace to save + * @param inputWorkspace title of the focused workspace + */ +void EnggDiffractionPresenter::saveFocusedXYE( + const RunLabel &runLabel, const std::string &inputWorkspace) { + + // Generates the file name in the appropriate format + std::string fullFilename = + outFileNameFactory(inputWorkspace, runLabel, ".dat"); + + const std::string focusingComp = "Focus"; + // Creates appropriate directory + auto saveDir = outFilesUserDir(focusingComp); + + // append the full file name in the end + saveDir.append(fullFilename); + + try { + g_log.debug() << "Going to save focused output into OpenGenie file: " + << fullFilename << '\n'; + auto alg = Mantid::API::AlgorithmManager::Instance().createUnmanaged( + "SaveFocusedXYE"); + alg->initialize(); + alg->setProperty("InputWorkspace", inputWorkspace); + const std::string filename(saveDir.toString()); + alg->setPropertyValue("Filename", filename); + alg->setProperty("SplitFiles", false); + alg->setPropertyValue("StartAtBankNumber", std::to_string(runLabel.bank)); + alg->execute(); + } catch (std::runtime_error &re) { + g_log.error() << "Error in saving FocusedXYE format file. ", + "Could not run the algorithm SaveFocusXYE succesfully for " + "workspace " + + inputWorkspace + ". Error description: " + re.what() + + " Please check also the log messages for details."; + throw; + } + g_log.notice() << "Saved focused workspace as file: " << saveDir.toString() + << '\n'; + copyToGeneral(saveDir, focusingComp); +} + +/** + * Convert the generated output files and saves them in + * GSS format + * + * @param runLabel run number and bank ID the workspace to save + * @param inputWorkspace title of the focused workspace + */ +void EnggDiffractionPresenter::saveGSS(const RunLabel &runLabel, + const std::string &inputWorkspace) { + + // Generates the file name in the appropriate format + std::string fullFilename = + outFileNameFactory(inputWorkspace, runLabel, ".gss"); + + const std::string focusingComp = "Focus"; + // Creates appropriate directory + auto saveDir = outFilesUserDir(focusingComp); + + // append the full file name in the end + saveDir.append(fullFilename); + + try { + g_log.debug() << "Going to save focused output into OpenGenie file: " + << fullFilename << '\n'; + auto alg = + Mantid::API::AlgorithmManager::Instance().createUnmanaged("SaveGSS"); + alg->initialize(); + alg->setProperty("InputWorkspace", inputWorkspace); + std::string filename(saveDir.toString()); + alg->setPropertyValue("Filename", filename); + alg->setProperty("SplitFiles", false); + alg->setPropertyValue("Bank", std::to_string(runLabel.bank)); + alg->execute(); + } catch (std::runtime_error &re) { + g_log.error() << "Error in saving GSS format file. ", + "Could not run the algorithm saveGSS succesfully for " + "workspace " + + inputWorkspace + ". Error description: " + re.what() + + " Please check also the log messages for details."; + throw; + } + g_log.notice() << "Saved focused workspace as file: " << saveDir.toString() + << '\n'; + copyToGeneral(saveDir, focusingComp); +} + +void EnggDiffractionPresenter::saveNexus(const RunLabel &runLabel, + const std::string &inputWorkspace) { + const auto filename = outFileNameFactory(inputWorkspace, runLabel, ".nxs"); + auto saveDirectory = outFilesUserDir("Focus"); + saveDirectory.append(filename); + const auto fullOutFileName = saveDirectory.toString(); + + try { + g_log.debug() << "Going to save focused output into OpenGenie file: " + << fullOutFileName << "\n"; + auto alg = + Mantid::API::AlgorithmManager::Instance().createUnmanaged("SaveNexus"); + alg->initialize(); + alg->setProperty("InputWorkspace", inputWorkspace); + alg->setProperty("Filename", fullOutFileName); + alg->execute(); + } catch (std::runtime_error &re) { + g_log.error() << "Error in save NXS format file. Could not run the " + "algorithm SaveNexus successfully for workspace " + << inputWorkspace << ". Error description: " << re.what() + << ". Please also check the log message for details."; + throw; + } + g_log.notice() << "Saved focused workspace as file: " << fullOutFileName + << "\n"; + copyToGeneral(saveDirectory, "Focus"); +} + +/** + * Convert the generated output files and saves them in + * OpenGenie format + * + * @param runLabel run number and bank ID of the workspace to save + * @param inputWorkspace title of the focused workspace + */ +void EnggDiffractionPresenter::saveOpenGenie( + const RunLabel &runLabel, const std::string &inputWorkspace) { + + // Generates the file name in the appropriate format + std::string fullFilename = + outFileNameFactory(inputWorkspace, runLabel, ".his"); + + std::string comp; + Poco::Path saveDir; + if (inputWorkspace.std::string::find("curves") != std::string::npos || + inputWorkspace.std::string::find("intgration") != std::string::npos) { + // Creates appropriate directory + comp = "Calibration"; + saveDir = outFilesUserDir(comp); + } else { + // Creates appropriate directory + comp = "Focus"; + saveDir = outFilesUserDir(comp); + } + + // append the full file name in the end + saveDir.append(fullFilename); + + try { + g_log.debug() << "Going to save focused output into OpenGenie file: " + << fullFilename << '\n'; + auto alg = Mantid::API::AlgorithmManager::Instance().createUnmanaged( + "SaveOpenGenieAscii"); + alg->initialize(); + alg->setProperty("InputWorkspace", inputWorkspace); + std::string filename(saveDir.toString()); + alg->setPropertyValue("Filename", filename); + alg->setPropertyValue("OpenGenieFormat", "ENGIN-X Format"); + alg->execute(); + } catch (std::runtime_error &re) { + g_log.error() << "Error in saving OpenGenie format file. ", + "Could not run the algorithm SaveOpenGenieAscii succesfully for " + "workspace " + + inputWorkspace + ". Error description: " + re.what() + + " Please check also the log messages for details."; + throw; + } + g_log.notice() << "Saves OpenGenieAscii (.his) file written as: " + << saveDir.toString() << '\n'; + copyToGeneral(saveDir, comp); +} + +void EnggDiffractionPresenter::exportSampleLogsToHDF5( + const std::string &inputWorkspace, const std::string &filename) const { + auto saveAlg = Mantid::API::AlgorithmManager::Instance().create( + "ExportSampleLogsToHDF5"); + saveAlg->initialize(); + saveAlg->setProperty("InputWorkspace", inputWorkspace); + saveAlg->setProperty("Filename", filename); + saveAlg->setProperty("Blacklist", "bankid"); + saveAlg->execute(); +} + +/** + * Generates the required file name of the output files + * + * @param inputWorkspace title of the focused workspace + * @param runLabel run number and bank ID of the workspace to save + * @param format the format of the file to be saved as + */ +std::string +EnggDiffractionPresenter::outFileNameFactory(const std::string &inputWorkspace, + const RunLabel &runLabel, + const std::string &format) { + std::string fullFilename; + + const auto runNo = runLabel.runNumber; + const auto bank = std::to_string(runLabel.bank); + + // calibration output files + if (inputWorkspace.std::string::find("curves") != std::string::npos) { + fullFilename = + "ob+" + m_currentInst + "_" + runNo + "_" + bank + "_bank" + format; + + // focus output files + } else if (inputWorkspace.std::string::find("texture") != std::string::npos) { + fullFilename = m_currentInst + "_" + runNo + "_texture_" + bank + format; + } else if (inputWorkspace.std::string::find("cropped") != std::string::npos) { + fullFilename = m_currentInst + "_" + runNo + "_cropped_" + + boost::lexical_cast<std::string>(g_croppedCounter) + format; + g_croppedCounter++; + } else { + fullFilename = m_currentInst + "_" + runNo + "_bank_" + bank + format; + } + return fullFilename; +} + +std::string EnggDiffractionPresenter::vanadiumCurvesPlotFactory() { + std::string pyCode = + + "van_curve_twin_ws = \"__engggui_vanadium_curves_twin_ws\"\n" + + "if(mtd.doesExist(van_curve_twin_ws)):\n" + " DeleteWorkspace(van_curve_twin_ws)\n" + + "CloneWorkspace(InputWorkspace = \"engggui_vanadium_curves\", " + "OutputWorkspace = van_curve_twin_ws)\n" + + "van_curves_ws = workspace(van_curve_twin_ws)\n" + "for i in range(1, 3):\n" + " if (i == 1):\n" + " curve_plot_bank_1 = plotSpectrum(van_curves_ws, [0, 1, " + "2]).activeLayer()\n" + " curve_plot_bank_1.setTitle(\"Engg GUI Vanadium Curves Bank 1\")\n" + + " if (i == 2):\n" + " curve_plot_bank_2 = plotSpectrum(van_curves_ws, [3, 4, " + "5]).activeLayer()\n" + " curve_plot_bank_2.setTitle(\"Engg GUI Vanadium Curves Bank 2\")\n"; + + return pyCode; +} + +/** + * Generates the workspace with difc/zero according to the selected bank + * + * @param difa vector containing constants difa value of each bank + * @param difc vector containing constants difc value of each bank + * @param tzero vector containing constants tzero value of each bank + * @param specNo used to set range for Calibration Cropped + * @param customisedBankName used to set the file and workspace name + * + * @return string with a python script + */ +std::string EnggDiffractionPresenter::TOFFitWorkspaceFactory( + const std::vector<double> &difa, const std::vector<double> &difc, + const std::vector<double> &tzero, const std::string &specNo, + const std::string &customisedBankName) const { + + auto bank1 = size_t(0); + auto bank2 = size_t(1); + std::string pyRange; + std::string plotSpecNum = "False"; + + // sets the range to plot appropriate graph for the particular bank + if (specNo == "North") { + // only enable script to plot bank 1 + pyRange = "1, 2"; + } else if (specNo == "South") { + // only enables python script to plot bank 2 + // as bank 2 data will be located in difc[0] & tzero[0] - refactor + pyRange = "2, 3"; + bank2 = size_t(0); + } else if (specNo != "") { + pyRange = "1, 2"; + plotSpecNum = "True"; + } else { + // enables python script to plot bank 1 & 2 + pyRange = "1, 3"; + } + + std::string pyCode = + "plotSpecNum = " + plotSpecNum + + "\n" + "for i in range(" + + pyRange + + "):\n" + + " if (plotSpecNum == False):\n" + " bank_ws = workspace(\"engggui_calibration_bank_\" + str(i))\n" + " else:\n" + " bank_ws = workspace(\"engggui_calibration_bank_" + + customisedBankName + + "\")\n" + + " xVal = []\n" + " yVal = []\n" + " y2Val = []\n" + + " if (i == 1):\n" + " difa=" + + boost::lexical_cast<std::string>(difa[bank1]) + "\n" + + " difc=" + boost::lexical_cast<std::string>(difc[bank1]) + "\n" + + " tzero=" + boost::lexical_cast<std::string>(tzero[bank1]) + "\n" + + " else:\n" + + " difa=" + + boost::lexical_cast<std::string>(difa[bank2]) + "\n" + + " difc=" + boost::lexical_cast<std::string>(difc[bank2]) + "\n" + + " tzero=" + boost::lexical_cast<std::string>(tzero[bank2]) + "\n" + + + " for irow in range(0, bank_ws.rowCount()):\n" + " xVal.append(bank_ws.cell(irow, 0))\n" + " yVal.append(bank_ws.cell(irow, 5))\n" + + " y2Val.append(pow(xVal[irow], 2) * difa + xVal[irow] * difc + tzero)\n" + + " ws1 = CreateWorkspace(DataX=xVal, DataY=yVal, UnitX=\"Expected " + "Peaks " + " Centre(dSpacing, A)\", YUnitLabel = \"Fitted Peaks Centre(TOF, " + "us)\")\n" + " ws2 = CreateWorkspace(DataX=xVal, DataY=y2Val)\n"; + return pyCode; +} + +/** +* Plot the workspace with difc/zero acordding to selected bank +* +* @param customisedBankName used to set the file and workspace name +* +* @return string with a python script which will merge with +* + +*/ +std::string EnggDiffractionPresenter::plotTOFWorkspace( + const std::string &customisedBankName) const { + std::string pyCode = + // plotSpecNum is true when SpectrumNos being used + " if (plotSpecNum == False):\n" + " output_ws = \"engggui_difc_zero_peaks_bank_\" + str(i)\n" + " else:\n" + " output_ws = \"engggui_difc_zero_peaks_" + + customisedBankName + + "\"\n" + + // delete workspace if exists within ADS already + " if(mtd.doesExist(output_ws)):\n" + " DeleteWorkspace(output_ws)\n" + + // append workspace with peaks data for Peaks Fitted + // and Difc/TZero Straight line + " AppendSpectra(ws1, ws2, OutputWorkspace=output_ws)\n" + " DeleteWorkspace(ws1)\n" + " DeleteWorkspace(ws2)\n" + + " if (plotSpecNum == False):\n" + " DifcZero = \"engggui_difc_zero_peaks_bank_\" + str(i)\n" + " else:\n" + " DifcZero = \"engggui_difc_zero_peaks_" + + customisedBankName + + "\"\n" + + " DifcZeroWs = workspace(DifcZero)\n" + " DifcZeroPlot = plotSpectrum(DifcZeroWs, [0, 1]).activeLayer()\n" + + " if (plotSpecNum == False):\n" + " DifcZeroPlot.setTitle(\"Engg Gui Difc Zero Peaks Bank \" + " + "str(i))\n" + " else:\n" + " DifcZeroPlot.setTitle(\"Engg Gui Difc Zero Peaks " + + customisedBankName + + "\")\n" + + // set the legend title + " DifcZeroPlot.setCurveTitle(0, \"Peaks Fitted\")\n" + " DifcZeroPlot.setCurveTitle(1, \"DifC/TZero Fitted Straight Line\")\n" + " DifcZeroPlot.setAxisTitle(Layer.Bottom, \"Expected Peaks " + "Centre(dSpacing, " + " A)\")\n" + " DifcZeroPlot.setCurveLineStyle(0, QtCore.Qt.DotLine)\n"; + + return pyCode; +} + +/** + * Generates appropriate names for table workspaces + * + * @param specNos SpecNos or bank name to be passed + * @param bank_i current loop of the bank during calibration + */ +std::string EnggDiffractionPresenter::outFitParamsTblNameGenerator( + const std::string &specNos, const size_t bank_i) const { + std::string outFitParamsTblName; + bool specNumUsed = specNos != ""; + + if (specNumUsed) { + if (specNos == "North") + outFitParamsTblName = "engggui_calibration_bank_1"; + else if (specNos == "South") + outFitParamsTblName = "engggui_calibration_bank_2"; + else { + // Get the Customised Bank Name text-ield string from qt + std::string CustomisedBankName = m_view->currentCalibCustomisedBankName(); + + if (CustomisedBankName.empty()) + outFitParamsTblName = "engggui_calibration_bank_cropped"; + else + outFitParamsTblName = "engggui_calibration_bank_" + CustomisedBankName; + } + } else { + outFitParamsTblName = "engggui_calibration_bank_" + + boost::lexical_cast<std::string>(bank_i + 1); + } + return outFitParamsTblName; +} + +/** + * Produces a path to the output directory where files are going to be + * written for a specific user + RB number / experiment ID. It creates + * the output directory if not found, and checks if it is ok and readable. + * + * @param addToDir adds a component to a specific directory for + * focusing, calibration or other files, for example "Calibration" or + * "Focus" + */ +Poco::Path +EnggDiffractionPresenter::outFilesUserDir(const std::string &addToDir) const { + std::string rbn = m_view->getRBNumber(); + Poco::Path dir = outFilesRootDir(); + + try { + dir.append("User"); + dir.append(rbn); + dir.append(addToDir); + + Poco::File dirFile(dir); + if (!dirFile.exists()) { + dirFile.createDirectories(); + } + } catch (Poco::FileAccessDeniedException &e) { + g_log.error() << "Error caused by file access/permission, path to user " + "directory: " + << dir.toString() << ". Error details: " << e.what() << '\n'; + } catch (std::runtime_error &re) { + g_log.error() << "Error while finding/creating a user path: " + << dir.toString() << ". Error details: " << re.what() << '\n'; + } + return dir; +} + +std::string EnggDiffractionPresenter::userHDFRunFilename( + const std::string &runNumber) const { + auto userOutputDir = outFilesUserDir("Runs"); + userOutputDir.append(runNumber + ".hdf5"); + return userOutputDir.toString(); +} + +std::string EnggDiffractionPresenter::userHDFMultiRunFilename( + const std::vector<RunLabel> &runLabels) const { + const auto &begin = runLabels.cbegin(); + const auto &end = runLabels.cend(); + const auto minLabel = std::min_element(begin, end); + const auto maxLabel = std::max_element(begin, end); + auto userOutputDir = outFilesUserDir("Runs"); + userOutputDir.append((minLabel->runNumber) + "_" + (maxLabel->runNumber) + + ".hdf5"); + return userOutputDir.toString(); +} + +/** + * Produces a path to the output directory where files are going to be + * written for a specific user + RB number / experiment ID. It creates + * the output directory if not found. See outFilesUserDir() for the + * sibling method that produces user/rb number-specific directories. + * + * @param addComponent path component to add to the root of general + * files, for example "Calibration" or "Focus" + */ +Poco::Path +EnggDiffractionPresenter::outFilesGeneralDir(const std::string &addComponent) { + Poco::Path dir = outFilesRootDir(); + + try { + + dir.append(addComponent); + + Poco::File dirFile(dir); + if (!dirFile.exists()) { + dirFile.createDirectories(); + } + } catch (Poco::FileAccessDeniedException &e) { + g_log.error() << "Error caused by file access/permission, path to " + "general directory: " + << dir.toString() << ". Error details: " << e.what() << '\n'; + } catch (std::runtime_error &re) { + g_log.error() << "Error while finding/creating a general path: " + << dir.toString() << ". Error details: " << re.what() << '\n'; + } + return dir; +} + +/** + * Produces the root path where output files are going to be written. + */ +Poco::Path EnggDiffractionPresenter::outFilesRootDir() const { + // TODO decide whether to move into settings or use mantid's default directory + // after discussion with users + const std::string rootDir = "EnginX_Mantid"; + Poco::Path dir; + + try { +// takes to the root of directory according to the platform +#ifdef _WIN32 + const std::string ROOT_DRIVE = "C:/"; + dir.assign(ROOT_DRIVE); +#else + dir = Poco::Path().home(); +#endif + dir.append(rootDir); + + Poco::File dirFile(dir); + if (!dirFile.exists()) { + dirFile.createDirectories(); + g_log.notice() << "Creating output directory root for the first time: " + << dir.toString() << '\n'; + } + + } catch (Poco::FileAccessDeniedException &e) { + g_log.error() << "Error, access/permission denied for root directory: " + << dir.toString() + << ". This is a severe error. The interface will not behave " + "correctly when generating files. Error details: " + << e.what() << '\n'; + } catch (std::runtime_error &re) { + g_log.error() << "Error while finding/creating the root directory: " + << dir.toString() + << ". This is a severe error. Details: " << re.what() << '\n'; + } + + return dir; +} + +/* + * Provides a small wrapper function that appends the given string + * to the given path in an OS independent manner and returns the + * resulting path as a string. + * + * @param currentPath The path to be appended to + * @param toAppend The string to append to the path (note '/' or '\\' + * characters should not be included + * + * @return String with the two parts of the path appended + */ +std::string +EnggDiffractionPresenter::appendToPath(const std::string ¤tPath, + const std::string &toAppend) const { + // Uses poco to handle to operation to ensure OS independence + Poco::Path newPath(currentPath); + newPath.append(toAppend); + return newPath.toString(); +} + +/** + * Copy files to the general directories. Normally files are produced + * in the user/RB number specific directories and then can be copied + * to the general/all directories using this method. + * + * @param source path to the file to copy + * + * @param pathComp path component to use for the copy file in the + * general directories, for example "Calibration" or "Focus" + */ +void EnggDiffractionPresenter::copyToGeneral(const Poco::Path &source, + const std::string &pathComp) { + Poco::File file(source); + if (!file.exists() || !file.canRead()) { + g_log.warning() << "Cannot copy the file " << source.toString() + << " to the general/all users directories because it " + "cannot be read.\n"; + return; + } + + auto destDir = outFilesGeneralDir(pathComp); + try { + Poco::File destDirFile(destDir); + if (!destDirFile.exists()) { + destDirFile.createDirectories(); + } + } catch (std::runtime_error &rexc) { + g_log.error() << "Could not create output directory for the general/all " + "files. Cannot copy the user files there: " + << destDir.toString() << ". Error details: " << rexc.what() + << '\n'; + + return; + } + + try { + file.copyTo(destDir.toString()); + } catch (std::runtime_error &rexc) { + g_log.error() << " Could not copy the file '" << file.path() << "' to " + << destDir.toString() << ". Error details: " << rexc.what() + << '\n'; + } + + g_log.information() << "Copied file '" << source.toString() + << "'to general/all directory: " << destDir.toString() + << '\n'; +} + +/** + * Copy files to the user/RB number directories. + * + * @param source path to the file to copy + * + * @param pathComp path component to use for the copy file in the + * general directories, for example "Calibration" or "Focus" + */ +void EnggDiffractionPresenter::copyToUser(const Poco::Path &source, + const std::string &pathComp) { + Poco::File file(source); + if (!file.exists() || !file.canRead()) { + g_log.warning() << "Cannot copy the file " << source.toString() + << " to the user directories because it cannot be read.\n"; + return; + } + + auto destDir = outFilesUserDir(pathComp); + try { + Poco::File destDirFile(destDir); + if (!destDirFile.exists()) { + destDirFile.createDirectories(); + } + } catch (std::runtime_error &rexc) { + g_log.error() << "Could not create output directory for the user " + "files. Cannot copy the user files there: " + << destDir.toString() << ". Error details: " << rexc.what() + << '\n'; + + return; + } + + try { + file.copyTo(destDir.toString()); + } catch (std::runtime_error &rexc) { + g_log.error() << " Could not copy the file '" << file.path() << "' to " + << destDir.toString() << ". Error details: " << rexc.what() + << '\n'; + } + + g_log.information() << "Copied file '" << source.toString() + << "'to user directory: " << destDir.toString() << '\n'; +} + +/** + * Copies a file from a third location to the standard user/RB number + * and the general/all directories. This just uses copyToUser() and + * copyToGeneral(). + * + * @param fullFilename full path to the origin file + */ +void EnggDiffractionPresenter::copyFocusedToUserAndAll( + const std::string &fullFilename) { + // The files are saved by SaveNexus in the Settings/Focusing output folder. + // Then they need to go to the user and 'all' directories. + // The "Settings/Focusing output folder" may go away in the future + Poco::Path nxsPath(fullFilename); + const std::string focusingComp = "Focus"; + auto saveDir = outFilesUserDir(focusingComp); + Poco::Path outFullPath(saveDir); + outFullPath.append(nxsPath.getFileName()); + copyToUser(nxsPath, focusingComp); + copyToGeneral(nxsPath, focusingComp); +} + +/** + * To write the calibration/instrument parameter for GSAS. + * + * @param outFilename name of the output .par/.prm/.iparm file for GSAS + * @param difa list of GSAS DIFA values to include in the file + * @param difc list of GSAS DIFC values to include in the file + * @param tzero list of GSAS TZERO values to include in the file + * @param bankNames list of bank names corresponding the the difc/tzero + * + * @param ceriaNo ceria/calibration run number, to be replaced in the + * template file + * + * @param vanNo vanadium run number, to be replaced in the template file + * + * @param templateFile a template file where to replace the difc/zero + * values. An empty default implies using an "all-banks" template. + */ +void EnggDiffractionPresenter::writeOutCalibFile( + const std::string &outFilename, const std::vector<double> &difa, + const std::vector<double> &difc, const std::vector<double> &tzero, + const std::vector<std::string> &bankNames, const std::string &ceriaNo, + const std::string &vanNo, const std::string &templateFile) { + // TODO: this is horrible and should be changed to avoid running + // Python code. Update this as soon as we have a more stable way of + // generating IPARM/PRM files. + + // Writes a file doing this: + // write_ENGINX_GSAS_iparam_file(output_file, difa, difc, zero, + // ceria_run=241391, vanadium_run=236516, template_file=None): + + // this replace is to prevent issues with network drives on windows: + const std::string safeOutFname = + boost::replace_all_copy(outFilename, "\\", "/"); + std::string pyCode = "import EnggUtils\n"; + pyCode += "import os\n"; + // normalize apparently not needed after the replace, but to be double-safe: + pyCode += "GSAS_iparm_fname = os.path.normpath('" + safeOutFname + "')\n"; + pyCode += "bank_names = []\n"; + pyCode += "ceria_number = \"" + ceriaNo + "\"\n"; + pyCode += "van_number = \"" + vanNo + "\"\n"; + pyCode += "Difas = []\n"; + pyCode += "Difcs = []\n"; + pyCode += "Zeros = []\n"; + std::string templateFileVal = "None"; + if (!templateFile.empty()) { + templateFileVal = "'" + templateFile + "'"; + } + pyCode += "template_file = " + templateFileVal + "\n"; + for (size_t i = 0; i < difc.size(); ++i) { + pyCode += "bank_names.append('" + bankNames[i] + "')\n"; + pyCode += + "Difas.append(" + boost::lexical_cast<std::string>(difa[i]) + ")\n"; + pyCode += + "Difcs.append(" + boost::lexical_cast<std::string>(difc[i]) + ")\n"; + pyCode += + "Zeros.append(" + boost::lexical_cast<std::string>(tzero[i]) + ")\n"; + } + pyCode += + "EnggUtils.write_ENGINX_GSAS_iparam_file(output_file=GSAS_iparm_fname, " + "bank_names=bank_names, difa=Difas, difc=Difcs, tzero=Zeros, " + "ceria_run=ceria_number, " + "vanadium_run=van_number, template_file=template_file) \n"; + + const auto status = m_view->enggRunPythonCode(pyCode); + g_log.information() << "Saved output calibration file via Python. Status: " + << status << '\n'; +} + +/** + * Note down a directory that needs to be added to the data search + * path when looking for run files. This simply uses a vector and adds + * all the paths, as the ConfigService will take care of duplicates, + * invalid directories, etc. + * + * @param filename (full) path to a file + */ +void EnggDiffractionPresenter::recordPathBrowsedTo( + const std::string &filename) { + + Poco::File file(filename); + if (!file.exists() || !file.isFile()) + return; + + Poco::Path path(filename); + Poco::File directory(path.parent()); + if (!directory.exists() || !directory.isDirectory()) + return; + + m_browsedToPaths.emplace_back(directory.path()); +} + +} // namespace CustomInterfaces +} // namespace MantidQt diff --git a/qt/scientific_interfaces/EnggDiffraction/EnggDiffractionPresenter.h b/qt/scientific_interfaces/EnggDiffraction/EnggDiffractionPresenter.h new file mode 100644 index 0000000000000000000000000000000000000000..ab7f699f238059ff13d185a1f98a33a8f9a5c59f --- /dev/null +++ b/qt/scientific_interfaces/EnggDiffraction/EnggDiffractionPresenter.h @@ -0,0 +1,354 @@ +// Mantid Repository : https://github.com/mantidproject/mantid +// +// Copyright © 2015 ISIS Rutherford Appleton Laboratory UKRI, +// NScD Oak Ridge National Laboratory, European Spallation Source +// & Institut Laue - Langevin +// SPDX - License - Identifier: GPL - 3.0 + +#pragma once + +#include "DllConfig.h" +#include "IEnggDiffractionCalibration.h" +#include "IEnggDiffractionParam.h" +#include "IEnggDiffractionPresenter.h" +#include "IEnggDiffractionView.h" +#include "IEnggVanadiumCorrectionsModel.h" +#include "MantidAPI/ITableWorkspace_fwd.h" +#include "MantidAPI/MatrixWorkspace_fwd.h" +#include "MantidAPI/Workspace_fwd.h" + +#include <boost/scoped_ptr.hpp> + +#include <QObject> + +namespace Poco { +class Path; +} + +class QThread; + +namespace MantidQt { +namespace CustomInterfaces { + +/** +Presenter for the Enggineering Diffraction GUI (presenter as in the +MVP Model-View-Presenter pattern). In principle, in a strict MVP +setup, signals from the model should always be handled through this +presenter and never go directly to the view, and viceversa. +*/ +// needs to be dll-exported for the tests +class MANTIDQT_ENGGDIFFRACTION_DLL EnggDiffractionPresenter + : public QObject, + public IEnggDiffractionPresenter, + public IEnggDiffractionCalibration, + public IEnggDiffractionParam { + // Q_OBJECT for 'connect' with thread/worker + Q_OBJECT + +public: + EnggDiffractionPresenter(IEnggDiffractionView *view); + ~EnggDiffractionPresenter() override; + + void notify(IEnggDiffractionPresenter::Notification notif) override; + + /// the calibration hard work that a worker / thread will run + void doNewCalibration(const std::string &outFilename, + const std::string &vanNo, const std::string &ceriaNo, + const std::string &specNos); + + /// the focusing hard work that a worker / thread will run + void doFocusRun(const std::string &runNo, const std::vector<bool> &banks, + const std::string &specNos, const std::string &dgFile); + + /// checks if its a valid run number returns string + std::string isValidRunNumber(const std::vector<std::string> &dir); + + /// checks if its a valid run number inside vector and returns a vector; + /// used for mutli-run focusing, and other multi-run file selections + std::vector<std::string> + isValidMultiRunNumber(const std::vector<std::string> &dir); + + /// pre-processing re-binning with Rebin, for a worker/thread + void doRebinningTime(const std::string &runNo, double bin, + const std::string &outWSName); + + /// pre-processing re-binning with RebinByPulseTimes, for a worker/thread + void doRebinningPulses(const std::string &runNo, size_t nperiods, double bin, + const std::string &outWSName); + +protected: + void initialize(); + + /// clean shut down of model, view, etc. + void cleanup(); + + void processStart(); + void processLoadExistingCalib(); + void processCalcCalib(); + void ProcessCropCalib(); + void processFocusBasic(); + void processFocusCropped(); + void processFocusTexture(); + void processResetFocus(); + void processRebinTime(); + void processRebinMultiperiod(); + void processLogMsg(); + void processInstChange(); + void processRBNumberChange(); + void processShutDown(); + void processStopFocus(); + + std::vector<std::string> outputFocusFilenames(const std::string &runNo, + const std::vector<bool> &banks); + + std::string outputFocusCroppedFilename(const std::string &runNo); + +protected slots: + void calibrationFinished(); + void focusingFinished(); + void rebinningFinished(); + +private: + bool validateRBNumber(const std::string &rbn) const; + + /// @name Calibration related private methods + //@{ + void inputChecksBeforeCalibrate(const std::string &newVanNo, + const std::string &newCeriaNo); + + std::string outputCalibFilename(const std::string &vanNo, + const std::string &ceriaNo, + const std::string &bankName = ""); + + void updateNewCalib(const std::string &fname); + + void parseCalibrateFilename(const std::string &path, std::string &instName, + std::string &vanNo, std::string &ceriaNo); + + void grabCalibParms(const std::string &fname, std::string &vanNo, + std::string &ceriaNo); + + void updateCalibParmsTable(); + + // this may need to be mocked up in tests + virtual void startAsyncCalibWorker(const std::string &outFilename, + const std::string &vanNo, + const std::string &ceriaNo, + const std::string &specNos); + + void doCalib(const EnggDiffCalibSettings &cs, const std::string &vanNo, + const std::string &ceriaNo, const std::string &outFilename, + const std::string &specNos); + + void appendCalibInstPrefix(const std::string &vanNo, + std::string &outVanName) const; + + void appendCalibInstPrefix(const std::string &vanNo, const std::string &cerNo, + std::string &outVanName, + std::string &outCerName) const; + + std::string + buildCalibrateSuggestedFilename(const std::string &vanNo, + const std::string &ceriaNo, + const std::string &bankName = "") const; + + std::vector<GSASCalibrationParms> currentCalibration() const override; + //@} + + /// @name Focusing related private methods + //@{ + /// this may also need to be mocked up in tests + void startFocusing(const std::vector<std::string> &multi_runNo, + const std::vector<bool> &banks, + const std::string &specNos = "", + const std::string &dgFile = ""); + + virtual void + startAsyncFocusWorker(const std::vector<std::string> &multi_RunNo, + const std::vector<bool> &banks, + const std::string &specNos, const std::string &dgFile); + + void inputChecksBeforeFocusBasic(const std::vector<std::string> &multi_RunNo, + const std::vector<bool> &banks); + void + inputChecksBeforeFocusCropped(const std::vector<std::string> &multi_RunNo, + const std::vector<bool> &banks, + const std::string &specNos); + void + inputChecksBeforeFocusTexture(const std::vector<std::string> &multi_RunNo, + const std::string &dgfile); + void inputChecksBeforeFocus(); + void inputChecksBanks(const std::vector<bool> &banks); + + std::vector<std::string> sumOfFilesLoadVec(); + + std::vector<std::string> + outputFocusTextureFilenames(const std::string &runNo, + const std::vector<size_t> &bankIDs); + + void loadDetectorGroupingCSV(const std::string &dgFile, + std::vector<size_t> &bankIDs, + std::vector<std::string> &specs); + + void doFocusing(const EnggDiffCalibSettings &cs, const std::string &runLabel, + const size_t bank, const std::string &specNos, + const std::string &dgFile); + + /// @name Methods related to pre-processing / re-binning + //@{ + void inputChecksBeforeRebin(const std::string &runNo); + + void inputChecksBeforeRebinTime(const std::string &runNo, double bin); + + void inputChecksBeforeRebinPulses(const std::string &runNo, size_t nperiods, + double timeStep); + + Mantid::API::Workspace_sptr loadToPreproc(const std::string &runNo); + + virtual void startAsyncRebinningTimeWorker(const std::string &runNo, + double bin, + const std::string &outWSName); + + virtual void startAsyncRebinningPulsesWorker(const std::string &runNo, + size_t nperiods, double timeStep, + const std::string &outWSName); + //@} + + // plots workspace according to the user selection + void plotFocusedWorkspace(const std::string &outWSName); + + void plotCalibWorkspace(const std::vector<double> &difa, + const std::vector<double> &difc, + const std::vector<double> &tzero, + const std::string &specNos); + + // algorithms to save the generated workspace + void saveGSS(const RunLabel &runLabel, const std::string &inputWorkspace); + void saveFocusedXYE(const RunLabel &runLabel, + const std::string &inputWorkspace); + void saveNexus(const RunLabel &runLabel, const std::string &inputWorkspace); + void saveOpenGenie(const RunLabel &runLabel, + const std::string &inputWorkspace); + void exportSampleLogsToHDF5(const std::string &inputWorkspace, + const std::string &filename) const; + + // generates the required file name of the output files + std::string outFileNameFactory(const std::string &inputWorkspace, + const RunLabel &runLabel, + const std::string &format); + + // returns a directory as a path, creating it if not found, and checking + // errors + Poco::Path outFilesUserDir(const std::string &addToDir) const override; + std::string userHDFRunFilename(const std::string &runNumber) const override; + std::string userHDFMultiRunFilename( + const std::vector<RunLabel> &runLabels) const override; + Poco::Path outFilesGeneralDir(const std::string &addComponent); + Poco::Path outFilesRootDir() const; + + std::string appendToPath(const std::string &path, + const std::string &toAppend) const; + + /// convenience methods to copy files to different destinations + void copyToGeneral(const Poco::Path &source, const std::string &pathComp); + void copyToUser(const Poco::Path &source, const std::string &pathComp); + void copyFocusedToUserAndAll(const std::string &fullFilename); + + // generates appropriate names for table workspaces + std::string outFitParamsTblNameGenerator(const std::string &specNos, + size_t bank_i) const; + + // generates the pycode string which can be passed to view + std::string vanadiumCurvesPlotFactory(); + + std::string TOFFitWorkspaceFactory( + const std::vector<double> &difa, const std::vector<double> &difc, + const std::vector<double> &tzero, const std::string &specNo, + const std::string &customisedBankName) const; + + std::string plotTOFWorkspace(const std::string &customisedBankName) const; + + void writeOutCalibFile(const std::string &outFilename, + const std::vector<double> &difa, + const std::vector<double> &difc, + const std::vector<double> &tzero, + const std::vector<std::string> &bankNames, + const std::string &ceriaNo, const std::string &vanNo, + const std::string &templateFile = ""); + + /// keep track of the paths the user "browses to", to add them in + /// the file search path + void recordPathBrowsedTo(const std::string &filename); + + /// paths the user has "browsed to", to add them to the search path + std::vector<std::string> m_browsedToPaths; + + /// string to use for invalid run number error message + const static std::string g_runNumberErrorStr; + + // for the GSAS parameters (difc, difa, tzero) of the banks + static const std::string g_calibBanksParms; + + /// whether to allow users to give the output calibration filename + const static bool g_askUserCalibFilename; + + /// whether to break the thread + static bool g_abortThread; + + /// whether to run Sum Of Files & which focus run number to use + static std::string g_sumOfFilesFocus; + + /// saves the last valid run number + static std::string g_lastValidRun; + + /// bank name used or SpecNos for cropped calibration + static std::string g_calibCropIdentifier; + + QThread *m_workerThread; + + /// true if the last thing ran was cancelled + bool m_cancelled; + + /// true if the last calibration completed successfully + bool m_calibFinishedOK; + + /// error that caused the calibration to fail + std::string m_calibError; + /// path where the calibration has been produced (par/prm file) + std::string m_calibFullPath; + + /// The current calibration parameters (used for units conversion). It should + /// be updated when a new calibration is done or re-loading an existing one + std::vector<GSASCalibrationParms> m_currentCalibParms; + + /// true if the last focusing completed successfully + bool m_focusFinishedOK; + /// error that caused the focus to fail + std::string m_focusError; + /// true if the last pre-processing/re-binning completed successfully + bool m_rebinningFinishedOK; + + /// Counter for the cropped output files + static int g_croppedCounter; + + /// counter for the plotting workspace + static int g_plottingCounter; + + /// Associated view for this presenter (MVP pattern) + IEnggDiffractionView *const m_view; + + /// Tracks if the view has started to shut down following a close signal + bool m_viewHasClosed; + + /// Associated model for this presenter (MVP pattern) + // const boost::scoped_ptr<EnggDiffractionModel> m_model; + + /// the current selected instrument + std::string m_currentInst = ""; + + /// Model for calculating the vanadium corrections workspaces for focus and + /// calib + boost::shared_ptr<IEnggVanadiumCorrectionsModel> m_vanadiumCorrectionsModel; +}; + +} // namespace CustomInterfaces +} // namespace MantidQt \ No newline at end of file diff --git a/qt/scientific_interfaces/EnggDiffraction/EnggDiffractionViewQtGUI.cpp b/qt/scientific_interfaces/EnggDiffraction/EnggDiffractionViewQtGUI.cpp new file mode 100644 index 0000000000000000000000000000000000000000..d8abce02b5edaf2e809430707b77ae3878f5cf0f --- /dev/null +++ b/qt/scientific_interfaces/EnggDiffraction/EnggDiffractionViewQtGUI.cpp @@ -0,0 +1,1105 @@ +// Mantid Repository : https://github.com/mantidproject/mantid +// +// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI, +// NScD Oak Ridge National Laboratory, European Spallation Source +// & Institut Laue - Langevin +// SPDX - License - Identifier: GPL - 3.0 + +#include "EnggDiffractionViewQtGUI.h" +#include "EnggDiffractionPresenter.h" +#include "MantidKernel/ConfigService.h" +#include "MantidQtWidgets/Common/AlgorithmInputHistory.h" +#include "MantidQtWidgets/Common/AlgorithmRunner.h" +#include "MantidQtWidgets/Common/HelpWindow.h" +#include "MantidQtWidgets/Common/MWRunFiles.h" + +#include <Poco/DirectoryIterator.h> +#include <Poco/Path.h> + +#include <QCheckBox> +#include <QCloseEvent> +#include <QFileDialog> +#include <QMessageBox> +#include <QSettings> + +using namespace Mantid::API; +using namespace MantidQt::CustomInterfaces; + +namespace MantidQt { +namespace CustomInterfaces { + +// Add this class to the list of specialised dialogs in this namespace +// Hidden for release of 5.0 to be removed as a maintainance issue. +// DECLARE_SUBWINDOW(EnggDiffractionViewQtGUI) + +const double EnggDiffractionViewQtGUI::g_defaultRebinWidth = -0.0005; + +int EnggDiffractionViewQtGUI::g_currentType = 0; +int EnggDiffractionViewQtGUI::g_currentRunMode = 0; +int EnggDiffractionViewQtGUI::g_currentCropCalibBankName = 0; + +const std::string EnggDiffractionViewQtGUI::g_iparmExtStr = + "GSAS instrument parameters, IPARM file: PRM, PAR, IPAR, IPARAM " + "(*.prm *.par *.ipar *.iparam);;" + "Other extensions/all files (*)"; + +const std::string EnggDiffractionViewQtGUI::g_pixelCalibExt = + "Comma separated values text file with calibration table, CSV" + "(*.csv);;" + "Nexus file with calibration table: NXS, NEXUS" + "(*.nxs *.nexus);;" + "Supported formats: CSV, NXS " + "(*.csv *.nxs *.nexus);;" + "Other extensions/all files (*)"; + +const std::string EnggDiffractionViewQtGUI::g_DetGrpExtStr = + "Detector Grouping File: CSV " + "(*.csv *.txt);;" + "Other extensions/all files (*)"; + +const std::string EnggDiffractionViewQtGUI::g_settingsGroup = + "CustomInterfaces/EnggDiffractionView"; + +/** + * Default constructor. + * + * @param parent Parent window (most likely the Mantid main app window). + */ +EnggDiffractionViewQtGUI::EnggDiffractionViewQtGUI(QWidget *parent) + : UserSubWindow(parent), IEnggDiffractionView(), m_fittingWidget(nullptr), + m_currentInst("ENGINX"), m_splashMsg(nullptr), m_presenter(nullptr) {} + +void EnggDiffractionViewQtGUI::initLayout() { + // setup container ui + m_ui.setupUi(this); + + // presenter that knows how to handle a IEnggDiffractionView should + // take care of all the logic. Note that the view needs to know the + // concrete presenter + auto fullPres = boost::make_shared<EnggDiffractionPresenter>(this); + m_presenter = fullPres; + + // add tab contents and set up their ui's + QWidget *wCalib = new QWidget(m_ui.tabMain); + m_uiTabCalib.setupUi(wCalib); + m_ui.tabMain->addTab(wCalib, QString("Calibration")); + + QWidget *wFocus = new QWidget(m_ui.tabMain); + m_uiTabFocus.setupUi(wFocus); + m_ui.tabMain->addTab(wFocus, QString("Focus")); + + QWidget *wPreproc = new QWidget(m_ui.tabMain); + m_uiTabPreproc.setupUi(wPreproc); + m_ui.tabMain->addTab(wPreproc, QString("Pre-processing")); + + // This is created from a QWidget* -> use null-deleter to prevent double-free + // with Qt + boost::shared_ptr<EnggDiffractionViewQtGUI> sharedView( + this, [](EnggDiffractionViewQtGUI * /*unused*/) {}); + m_fittingWidget = + new EnggDiffFittingViewQtWidget(m_ui.tabMain, sharedView, sharedView, + fullPres, fullPres, sharedView, fullPres); + m_ui.tabMain->addTab(m_fittingWidget, QString("Fitting")); + + m_gsasWidget = + new EnggDiffGSASFittingViewQtWidget(sharedView, sharedView, fullPres); + m_ui.tabMain->addTab(m_gsasWidget, QString("GSAS-II Refinement")); + + QWidget *wSettings = new QWidget(m_ui.tabMain); + m_uiTabSettings.setupUi(wSettings); + m_ui.tabMain->addTab(wSettings, QString("Settings")); + + QComboBox *inst = m_ui.comboBox_instrument; + m_currentInst = inst->currentText().toStdString(); + + setPrefix(m_currentInst); + // An initial check on the RB number will enable the tabs after all + // the widgets and connections are set up + enableTabs(false); + + readSettings(); + + // basic UI setup, connect signals, etc. + doSetupGeneralWidgets(); + doSetupTabCalib(); + doSetupTabFocus(); + doSetupTabPreproc(); + doSetupTabSettings(); + + m_presenter->notify(IEnggDiffractionPresenter::Start); + // We need to delay the RB-number check for the pop-up (splash message) + // as it will be shown very early (before the interface + // window itself is shown) and that will cause a crash in Qt code on + // some platforms (windows 10, and 7 sometimes). + // so perform the check in the showEvent method to check on start up +} + +void EnggDiffractionViewQtGUI::doSetupTabCalib() { + // Some recent available runs as defaults. This (as well as the + // empty defaults just above) should probably be made persistent - + // and encapsulated into a CalibrationParameters or similar + // class/structure + const std::string vanadiumRun = "236516"; + const std::string ceriaRun = "241391"; + if (m_uiTabCalib.MWRunFiles_new_vanadium_num->getUserInput() + .toString() + .isEmpty()) { + m_uiTabCalib.MWRunFiles_new_vanadium_num->setFileTextWithoutSearch( + QString::fromStdString(vanadiumRun)); + } + if (m_uiTabCalib.MWRunFiles_new_ceria_num->getUserInput() + .toString() + .isEmpty()) { + m_uiTabCalib.MWRunFiles_new_ceria_num->setFileTextWithoutSearch( + QString::fromStdString(ceriaRun)); + } + + // push button signals/slots + connect(m_uiTabCalib.pushButton_load_calib, SIGNAL(released()), this, + SLOT(loadCalibrationClicked())); + + connect(m_uiTabCalib.pushButton_new_calib, SIGNAL(released()), this, + SLOT(calibrateClicked())); + + connect(m_uiTabCalib.pushButton_new_cropped_calib, SIGNAL(released()), this, + SLOT(CroppedCalibrateClicked())); + + connect(m_uiTabCalib.comboBox_calib_cropped_bank_name, + SIGNAL(currentIndexChanged(int)), this, + SLOT(calibspecNoChanged(int))); + + connect(m_uiTabCalib.comboBox_calib_cropped_bank_name, + SIGNAL(currentIndexChanged(int)), this, SLOT(enableSpecNos())); + + enableCalibrateFocusFitUserActions(true); +} + +void EnggDiffractionViewQtGUI::doSetupTabFocus() { + + connect(m_uiTabFocus.pushButton_focus, SIGNAL(released()), this, + SLOT(focusClicked())); + + connect(m_uiTabFocus.pushButton_focus_cropped, SIGNAL(released()), this, + SLOT(focusCroppedClicked())); + + connect(m_uiTabFocus.pushButton_texture_browse_grouping_file, + SIGNAL(released()), this, SLOT(browseTextureDetGroupingFile())); + + connect(m_uiTabFocus.pushButton_focus_texture, SIGNAL(released()), this, + SLOT(focusTextureClicked())); + + connect(m_uiTabFocus.pushButton_reset, SIGNAL(released()), this, + SLOT(focusResetClicked())); + + connect(m_uiTabFocus.pushButton_stop_focus, SIGNAL(released()), this, + SLOT(focusStopClicked())); + + connect(m_uiTabFocus.comboBox_PlotData, SIGNAL(currentIndexChanged(int)), + this, SLOT(plotRepChanged(int))); + + connect(m_uiTabFocus.comboBox_Multi_Runs, SIGNAL(currentIndexChanged(int)), + this, SLOT(multiRunModeChanged(int))); + + connect(m_uiTabFocus.checkBox_plot_focused_ws, SIGNAL(clicked()), this, + SLOT(plotFocusStatus())); +} + +void EnggDiffractionViewQtGUI::doSetupTabPreproc() { + connect(m_uiTabPreproc.pushButton_rebin_time, SIGNAL(released()), this, + SLOT(rebinTimeClicked())); + + connect(m_uiTabPreproc.pushButton_rebin_multiperiod, SIGNAL(released()), this, + SLOT(rebinMultiperiodClicked())); +} + +void EnggDiffractionViewQtGUI::doSetupTabSettings() { + // line edits that display paths and the like + m_uiTabSettings.lineEdit_input_dir_calib->setText( + QString::fromStdString(m_calibSettings.m_inputDirCalib)); + m_uiTabSettings.lineEdit_input_dir_raw->setText( + QString::fromStdString(m_calibSettings.m_inputDirRaw)); + m_uiTabSettings.lineEdit_pixel_calib_filename->setText( + QString::fromStdString(m_calibSettings.m_pixelCalibFilename)); + m_uiTabSettings.lineEdit_template_gsas_prm->setText( + QString::fromStdString(m_calibSettings.m_templateGSAS_PRM)); + m_calibSettings.m_forceRecalcOverwrite = false; + m_uiTabSettings.checkBox_force_recalculate_overwrite->setChecked( + m_calibSettings.m_forceRecalcOverwrite); + + // push button signals/slots + connect(m_uiTabSettings.pushButton_browse_input_dir_calib, SIGNAL(released()), + this, SLOT(browseInputDirCalib())); + + connect(m_uiTabSettings.pushButton_browse_input_dir_raw, SIGNAL(released()), + this, SLOT(browseInputDirRaw())); + + connect(m_uiTabSettings.pushButton_browse_pixel_calib_filename, + SIGNAL(released()), this, SLOT(browsePixelCalibFilename())); + + connect(m_uiTabSettings.pushButton_browse_template_gsas_prm, + SIGNAL(released()), this, SLOT(browseTemplateGSAS_PRM())); + + connect(m_uiTabSettings.checkBox_force_recalculate_overwrite, + SIGNAL(stateChanged(int)), this, + SLOT(forceRecalculateStateChanged())); +} + +void EnggDiffractionViewQtGUI::doSetupGeneralWidgets() { + doSetupSplashMsg(); + + // don't show the re-size corner + m_ui.statusbar->setSizeGripEnabled(false); + + // change instrument + connect(m_ui.comboBox_instrument, SIGNAL(currentIndexChanged(int)), this, + SLOT(instrumentChanged(int))); + connect(m_ui.pushButton_help, SIGNAL(released()), this, SLOT(openHelpWin())); + // note connection to the parent window, otherwise an empty frame window + // may remain open and visible after this close + if (this->parent()) { + connect(m_ui.pushButton_close, SIGNAL(released()), this->parent(), + SLOT(close())); + } + + connect(m_ui.lineEdit_RBNumber, SIGNAL(editingFinished()), this, + SLOT(RBNumberChanged())); +} + +void EnggDiffractionViewQtGUI::doSetupSplashMsg() { + if (m_splashMsg) + delete m_splashMsg; + + m_splashMsg = new QMessageBox(this); + m_splashMsg->setIcon(QMessageBox::Information); + m_splashMsg->setStandardButtons(QMessageBox::NoButton); + m_splashMsg->setWindowTitle("Setting up"); + m_splashMsg->setText("Setting up the interface!"); + m_splashMsg->setWindowFlags(Qt::SplashScreen | Qt::FramelessWindowHint | + Qt::X11BypassWindowManagerHint); + m_splashMsg->setWindowModality(Qt::NonModal); + // we don't want to show now: m_splashMsg->show(); +} + +void EnggDiffractionViewQtGUI::readSettings() { + QSettings qs; + qs.beginGroup(QString::fromStdString(g_settingsGroup)); + + m_ui.lineEdit_RBNumber->setText( + qs.value("user-params-RBNumber", "").toString()); + + m_uiTabCalib.lineEdit_current_vanadium_num->setText( + qs.value("user-params-current-vanadium-num", "").toString()); + m_uiTabCalib.lineEdit_current_ceria_num->setText( + qs.value("user-params-current-ceria-num", "").toString()); + QString calibFname = qs.value("current-calib-filename", "").toString(); + m_uiTabCalib.lineEdit_current_calib_filename->setText(calibFname); + + m_uiTabCalib.MWRunFiles_new_vanadium_num->setUserInput( + qs.value("user-params-new-vanadium-num", "").toString()); + m_uiTabCalib.MWRunFiles_new_ceria_num->setUserInput( + qs.value("user-params-new-ceria-num", "").toString()); + + m_uiTabCalib.groupBox_calib_cropped->setChecked( + qs.value("user-params-calib-cropped-group-checkbox", false).toBool()); + + m_uiTabCalib.comboBox_calib_cropped_bank_name->setCurrentIndex(0); + + m_uiTabCalib.lineEdit_cropped_spec_nos->setText( + qs.value("user-params-calib-cropped-spectrum-nos", "").toString()); + + m_uiTabCalib.lineEdit_cropped_customise_bank_name->setText( + qs.value("user-params-calib-cropped-customise-name", "cropped") + .toString()); + + m_uiTabCalib.checkBox_PlotData_Calib->setChecked( + qs.value("user-param-calib-plot-data", true).toBool()); + + // user params - focusing + m_uiTabFocus.MWRunFiles_run_num->setUserInput( + qs.value("user-params-focus-runno", "").toString()); + + qs.beginReadArray("user-params-focus-bank_i"); + qs.setArrayIndex(0); + m_uiTabFocus.checkBox_focus_bank1->setChecked( + qs.value("value", true).toBool()); + qs.setArrayIndex(1); + m_uiTabFocus.checkBox_focus_bank2->setChecked( + qs.value("value", true).toBool()); + qs.endArray(); + + m_uiTabFocus.MWRunFiles_cropped_run_num->setUserInput( + qs.value("user-params-focus-cropped-runno", "").toString()); + + m_uiTabFocus.lineEdit_cropped_spec_nos->setText( + qs.value("user-params-focus-cropped-spectrum-nos", "").toString()); + + m_uiTabFocus.MWRunFiles_texture_run_num->setUserInput( + qs.value("user-params-focus-texture-runno", "").toString()); + + m_uiTabFocus.lineEdit_texture_grouping_file->setText( + qs.value("user-params-focus-texture-detector-grouping-file", "") + .toString()); + + m_uiTabFocus.groupBox_cropped->setChecked( + qs.value("user-params-focus-cropped-group-checkbox", false).toBool()); + + m_uiTabFocus.groupBox_texture->setChecked( + qs.value("user-params-focus-texture-group-checkbox", false).toBool()); + + m_uiTabFocus.checkBox_plot_focused_ws->setChecked( + qs.value("user-params-focus-plot-focused-ws", true).toBool()); + + m_uiTabFocus.checkBox_save_output_files->setChecked( + qs.value("user-params-focus-save-output-files", true).toBool()); + + m_uiTabFocus.comboBox_PlotData->setCurrentIndex( + qs.value("user-params-focus-plot-type", 0).toInt()); + + m_uiTabFocus.comboBox_Multi_Runs->setCurrentIndex( + qs.value("user-params-multiple-runs-focus-mode", 0).toInt()); + + // pre-processing (re-binning) + m_uiTabPreproc.MWRunFiles_preproc_run_num->setUserInput( + qs.value("user-params-preproc-runno", "").toString()); + + m_uiTabPreproc.doubleSpinBox_time_bin->setValue( + qs.value("user-params-time-bin", 0.1).toDouble()); + + m_uiTabPreproc.spinBox_nperiods->setValue( + qs.value("user-params-nperiods", 2).toInt()); + + m_uiTabPreproc.doubleSpinBox_step_time->setValue( + qs.value("user-params-step-time", 1).toDouble()); + + // settings + QString lastPath = + MantidQt::API::AlgorithmInputHistory::Instance().getPreviousDirectory(); + // TODO: as this is growing, it should become << >> operators on + // EnggDiffCalibSettings + m_calibSettings.m_inputDirCalib = + qs.value("input-dir-calib-files", lastPath).toString().toStdString(); + + m_calibSettings.m_inputDirRaw = + qs.value("input-dir-raw-files", lastPath).toString().toStdString(); + + const std::string fullCalib = guessDefaultFullCalibrationPath(); + m_calibSettings.m_pixelCalibFilename = + qs.value("pixel-calib-filename", QString::fromStdString(fullCalib)) + .toString() + .toStdString(); + + // 'advanced' block + m_calibSettings.m_forceRecalcOverwrite = + qs.value("force-recalc-overwrite", false).toBool(); + + const std::string templ = guessGSASTemplatePath(); + m_calibSettings.m_templateGSAS_PRM = + qs.value("template-gsas-prm", QString::fromStdString(templ)) + .toString() + .toStdString(); + + m_calibSettings.m_rebinCalibrate = + qs.value("rebin-calib", g_defaultRebinWidth).toFloat(); + + m_ui.tabMain->setCurrentIndex(qs.value("selected-tab-index").toInt()); + + restoreGeometry(qs.value("interface-win-geometry").toByteArray()); + qs.endGroup(); +} + +void EnggDiffractionViewQtGUI::saveSettings() const { + QSettings qs; + qs.beginGroup(QString::fromStdString(g_settingsGroup)); + + qs.setValue("user-params-RBNumber", m_ui.lineEdit_RBNumber->text()); + + qs.setValue("user-params-current-vanadium-num", + m_uiTabCalib.lineEdit_current_vanadium_num->text()); + qs.setValue("user-params-current-ceria-num", + m_uiTabCalib.lineEdit_current_ceria_num->text()); + qs.setValue("current-calib-filename", + m_uiTabCalib.lineEdit_current_calib_filename->text()); + + qs.setValue("user-params-new-vanadium-num", ""); + qs.setValue("user-params-new-ceria-num", ""); + + qs.setValue("user-params-calib-cropped-group-checkbox", + m_uiTabCalib.groupBox_calib_cropped->isChecked()); + + qs.setValue("user-params-calib-cropped-spectrum-nos", + m_uiTabCalib.lineEdit_cropped_spec_nos->text()); + + qs.setValue("user-params-calib-cropped-customise-name", + m_uiTabCalib.lineEdit_cropped_customise_bank_name->text()); + + qs.setValue("user-param-calib-plot-data", + m_uiTabCalib.checkBox_PlotData_Calib->isChecked()); + + // user params - focusing + qs.setValue("user-params-focus-runno", + m_uiTabFocus.MWRunFiles_run_num->getText()); + + qs.beginWriteArray("user-params-focus-bank_i"); + qs.setArrayIndex(0); + qs.setValue("value", m_uiTabFocus.checkBox_focus_bank1->isChecked()); + qs.setArrayIndex(1); + qs.setValue("value", m_uiTabFocus.checkBox_focus_bank2->isChecked()); + qs.endArray(); + + qs.setValue("user-params-focus-cropped-runno", + m_uiTabFocus.MWRunFiles_cropped_run_num->getText()); + qs.setValue("user-params-focus-cropped-spectrum-nos", + m_uiTabFocus.lineEdit_cropped_spec_nos->text()); + + qs.setValue("user-params-focus-texture-runno", + m_uiTabFocus.MWRunFiles_texture_run_num->getText()); + qs.setValue("user-params-focus-texture-detector-grouping-file", + m_uiTabFocus.lineEdit_texture_grouping_file->text()); + + qs.setValue("user-params-focus-cropped-group-checkbox", + m_uiTabFocus.groupBox_cropped->isChecked()); + + qs.setValue("user-params-focus-texture-group-checkbox", + m_uiTabFocus.groupBox_texture->isChecked()); + + qs.setValue("user-params-focus-plot-focused-ws", + m_uiTabFocus.checkBox_plot_focused_ws->isChecked()); + + qs.setValue("user-params-focus-save-output-files", + m_uiTabFocus.checkBox_plot_focused_ws->isChecked()); + + qs.setValue("user-params-focus-plot-type", + m_uiTabFocus.comboBox_PlotData->currentIndex()); + + qs.setValue("user-params-multiple-runs-focus-mode", + m_uiTabFocus.comboBox_Multi_Runs->currentIndex()); + + // pre-processing (re-binning) + qs.setValue("user-params-preproc-runno", + m_uiTabPreproc.MWRunFiles_preproc_run_num->getText()); + + qs.setValue("user-params-time-bin", + m_uiTabPreproc.doubleSpinBox_time_bin->value()); + + qs.setValue("user-params-nperiods", m_uiTabPreproc.spinBox_nperiods->value()); + + qs.value("user-params-step-time", + m_uiTabPreproc.doubleSpinBox_step_time->value()); + + // TODO: this should become << >> operators on EnggDiffCalibSettings + qs.setValue("input-dir-calib-files", + QString::fromStdString(m_calibSettings.m_inputDirCalib)); + qs.setValue("input-dir-raw-files", + QString::fromStdString(m_calibSettings.m_inputDirRaw)); + qs.setValue("pixel-calib-filename", + QString::fromStdString(m_calibSettings.m_pixelCalibFilename)); + // 'advanced' block + qs.setValue("force-recalc-overwrite", m_calibSettings.m_forceRecalcOverwrite); + qs.setValue("template-gsas-prm", + QString::fromStdString(m_calibSettings.m_templateGSAS_PRM)); + qs.setValue("rebin-calib", m_calibSettings.m_rebinCalibrate); + + qs.setValue("selected-tab-index", m_ui.tabMain->currentIndex()); + + qs.setValue("interface-win-geometry", saveGeometry()); + qs.endGroup(); +} + +std::string EnggDiffractionViewQtGUI::guessGSASTemplatePath() const { + // Inside the mantid installation target directory: + // scripts/Engineering/template_ENGINX_241391_236516_North_and_South_banks.par + Poco::Path templ = + Mantid::Kernel::ConfigService::Instance().getInstrumentDirectory(); + templ = templ.makeParent(); + templ.append("scripts"); + templ.append("Engineering"); + templ.append("template_ENGINX_241391_236516_North_and_South_banks.par"); + return templ.toString(); +} + +std::string EnggDiffractionViewQtGUI::guessDefaultFullCalibrationPath() const { + // Inside the mantid installation target directory: + // scripts/Engineering/ENGINX_full_pixel_calibration_vana194547_ceria193749.csv + Poco::Path templ = + Mantid::Kernel::ConfigService::Instance().getInstrumentDirectory(); + templ = templ.makeParent(); + templ.append("scripts"); + templ.append("Engineering"); + templ.append("calib"); + templ.append("ENGINX_full_pixel_calibration_vana194547_ceria193749.csv"); + return templ.toString(); +} + +void EnggDiffractionViewQtGUI::splashMessage(bool visible, + const std::string &shortMsg, + const std::string &description) { + if (!m_splashMsg) + return; + + m_splashMsg->setWindowTitle(QString::fromStdString(shortMsg)); + m_splashMsg->setText(QString::fromStdString(description)); + // when showing the message, force it to show up centered + if (visible) { + const auto pos = this->mapToGlobal(rect().center()); + m_splashMsg->move(pos.x() - m_splashMsg->width() / 2, + pos.y() - m_splashMsg->height() / 2); + } + m_splashMsg->setVisible(visible); +} + +void EnggDiffractionViewQtGUI::showStatus(const std::string &sts) { + m_ui.statusbar->showMessage(QString::fromStdString(sts)); +} + +void EnggDiffractionViewQtGUI::userWarning(const std::string &err, + const std::string &description) { + QMessageBox::warning(this, QString::fromStdString(err), + QString::fromStdString(description), QMessageBox::Ok, + QMessageBox::Ok); +} + +void EnggDiffractionViewQtGUI::userError(const std::string &err, + const std::string &description) { + QMessageBox::critical(this, QString::fromStdString(err), + QString::fromStdString(description), QMessageBox::Ok, + QMessageBox::Ok); +} + +std::string EnggDiffractionViewQtGUI::askNewCalibrationFilename( + const std::string &suggestedFname) { + // append dir (basename) + filename + QString prevPath = QString::fromStdString(m_calibSettings.m_inputDirCalib); + if (prevPath.isEmpty()) { + prevPath = + MantidQt::API::AlgorithmInputHistory::Instance().getPreviousDirectory(); + } + QDir path(prevPath); + QString suggestion = path.filePath(QString::fromStdString(suggestedFname)); + QString choice = QFileDialog::getSaveFileName( + this, tr("Please select the name of the calibration file"), suggestion, + QString::fromStdString(g_iparmExtStr)); + + return choice.toStdString(); +} + +std::string EnggDiffractionViewQtGUI::getRBNumber() const { + return m_ui.lineEdit_RBNumber->text().toStdString(); +} + +std::string EnggDiffractionViewQtGUI::currentVanadiumNo() const { + return m_uiTabCalib.lineEdit_current_vanadium_num->text().toStdString(); +} + +std::string EnggDiffractionViewQtGUI::currentCeriaNo() const { + return m_uiTabCalib.lineEdit_current_ceria_num->text().toStdString(); +} + +std::vector<std::string> EnggDiffractionViewQtGUI::newVanadiumNo() const { + return qListToVector(m_uiTabCalib.MWRunFiles_new_vanadium_num->getFilenames(), + m_uiTabCalib.MWRunFiles_new_vanadium_num->isValid()); +} + +std::vector<std::string> EnggDiffractionViewQtGUI::newCeriaNo() const { + return qListToVector(m_uiTabCalib.MWRunFiles_new_ceria_num->getFilenames(), + m_uiTabCalib.MWRunFiles_new_ceria_num->isValid()); +} + +std::string EnggDiffractionViewQtGUI::currentCalibFile() const { + return m_uiTabCalib.lineEdit_current_calib_filename->text().toStdString(); +} + +void EnggDiffractionViewQtGUI::newCalibLoaded(const std::string &vanadiumNo, + const std::string &ceriaNo, + const std::string &fname) { + + m_uiTabCalib.lineEdit_current_vanadium_num->setText( + QString::fromStdString(vanadiumNo)); + m_uiTabCalib.lineEdit_current_ceria_num->setText( + QString::fromStdString(ceriaNo)); + m_uiTabCalib.lineEdit_current_calib_filename->setText( + QString::fromStdString(fname)); + + if (!fname.empty()) { + MantidQt::API::AlgorithmInputHistory::Instance().setPreviousDirectory( + QString::fromStdString(fname)); + } +} + +void EnggDiffractionViewQtGUI::enableCalibrateFocusFitUserActions(bool enable) { + // calibrate + m_uiTabCalib.groupBox_make_new_calib->setEnabled(enable); + m_uiTabCalib.groupBox_current_calib->setEnabled(enable); + m_uiTabCalib.groupBox_calib_cropped->setEnabled(enable); + m_uiTabCalib.pushButton_new_cropped_calib->setEnabled(enable); + m_ui.pushButton_close->setEnabled(enable); + m_uiTabCalib.checkBox_PlotData_Calib->setEnabled(enable); + + // focus + m_uiTabFocus.MWRunFiles_run_num->setEnabled(enable); + m_uiTabFocus.pushButton_focus->setEnabled(enable); + + m_uiTabFocus.groupBox_cropped->setEnabled(enable); + m_uiTabFocus.groupBox_texture->setEnabled(enable); + + // Disable all focus output options except graph plotting + m_uiTabFocus.checkBox_plot_focused_ws->setEnabled(enable); + m_uiTabFocus.checkBox_save_output_files->setEnabled(enable); + m_uiTabFocus.comboBox_Multi_Runs->setEnabled(enable); + + m_uiTabFocus.pushButton_stop_focus->setDisabled(enable); + m_uiTabFocus.pushButton_reset->setEnabled(enable); + + // pre-processing + m_uiTabPreproc.MWRunFiles_preproc_run_num->setEnabled(enable); + m_uiTabPreproc.pushButton_rebin_time->setEnabled(enable); + m_uiTabPreproc.pushButton_rebin_multiperiod->setEnabled(enable); + + // fitting + m_fittingWidget->enable(enable); + m_gsasWidget->setEnabled(enable); +} + +void EnggDiffractionViewQtGUI::enableTabs(bool enable) { + for (int ti = 0; ti < m_ui.tabMain->count(); ++ti) { + m_ui.tabMain->setTabEnabled(ti, enable); + } +} + +std::vector<std::string> EnggDiffractionViewQtGUI::currentPreprocRunNo() const { + return qListToVector( + m_uiTabPreproc.MWRunFiles_preproc_run_num->getFilenames(), + m_uiTabPreproc.MWRunFiles_preproc_run_num->isValid()); +} + +double EnggDiffractionViewQtGUI::rebinningTimeBin() const { + return m_uiTabPreproc.doubleSpinBox_time_bin->value(); +} + +size_t EnggDiffractionViewQtGUI::rebinningPulsesNumberPeriods() const { + return m_uiTabPreproc.spinBox_nperiods->value(); +} + +double EnggDiffractionViewQtGUI::rebinningPulsesTime() const { + return m_uiTabPreproc.doubleSpinBox_step_time->value(); +} + +void EnggDiffractionViewQtGUI::plotFocusedSpectrum(const std::string &wsName) { + std::string pyCode = + "win=plotSpectrum('" + wsName + "', 0, error_bars=False, type=0)"; + + std::string status = + runPythonCode(QString::fromStdString(pyCode), false).toStdString(); + m_logMsgs.emplace_back("Plotted output focused data, with status string " + + status); + m_presenter->notify(IEnggDiffractionPresenter::LogMsg); +} + +void EnggDiffractionViewQtGUI::plotWaterfallSpectrum( + const std::string &wsName) { + // parameter of list ? + std::string pyCode = + "plotSpectrum('" + wsName + + "', 0, error_bars=False, type=0, waterfall=True, window=win)"; + std::string status = + runPythonCode(QString::fromStdString(pyCode), false).toStdString(); + m_logMsgs.emplace_back("Plotted output focused data, with status string " + + status); + m_presenter->notify(IEnggDiffractionPresenter::LogMsg); +} + +void EnggDiffractionViewQtGUI::plotReplacingWindow(const std::string &wsName, + const std::string &spectrum, + const std::string &type) { + std::string pyCode = "win=plotSpectrum('" + wsName + "', " + spectrum + + ", error_bars=False, type=" + type + + ", window=win, clearWindow=True)"; + std::string status = + runPythonCode(QString::fromStdString(pyCode), false).toStdString(); + + m_logMsgs.emplace_back("Plotted output focused data, with status string " + + status); + m_presenter->notify(IEnggDiffractionPresenter::LogMsg); +} + +void EnggDiffractionViewQtGUI::plotCalibOutput(const std::string &pyCode) { + + std::string status = + runPythonCode(QString::fromStdString(pyCode), false).toStdString(); + + m_logMsgs.emplace_back( + "Plotted output calibration vanadium curves, with status string " + + status); + m_presenter->notify(IEnggDiffractionPresenter::LogMsg); +} + +void EnggDiffractionViewQtGUI::resetFocus() { + m_uiTabFocus.MWRunFiles_run_num->setUserInput(""); + m_uiTabFocus.checkBox_focus_bank1->setChecked(true); + m_uiTabFocus.checkBox_focus_bank2->setChecked(true); + + m_uiTabFocus.MWRunFiles_cropped_run_num->setUserInput(""); + m_uiTabFocus.lineEdit_cropped_spec_nos->setText(""); + + m_uiTabFocus.groupBox_cropped->setChecked(false); + m_uiTabFocus.groupBox_texture->setChecked(false); + + m_uiTabFocus.MWRunFiles_run_num->setUserInput(""); + m_uiTabFocus.lineEdit_texture_grouping_file->setText(""); +} + +std::string +EnggDiffractionViewQtGUI::enggRunPythonCode(const std::string &pyCode) { + std::string status = + runPythonCode(QString::fromStdString(pyCode), false).toStdString(); + + return status; +} + +std::string EnggDiffractionViewQtGUI::askExistingCalibFilename() { + QString prevPath = QString::fromStdString(m_calibSettings.m_inputDirCalib); + if (prevPath.isEmpty()) { + prevPath = + MantidQt::API::AlgorithmInputHistory::Instance().getPreviousDirectory(); + } + + QString filename = + QFileDialog::getOpenFileName(this, tr("Open calibration file"), prevPath, + QString::fromStdString(g_iparmExtStr)); + + if (!filename.isEmpty()) { + MantidQt::API::AlgorithmInputHistory::Instance().setPreviousDirectory( + filename); + } + + return filename.toStdString(); +} + +void EnggDiffractionViewQtGUI::loadCalibrationClicked() { + m_presenter->notify(IEnggDiffractionPresenter::LoadExistingCalib); +} + +void EnggDiffractionViewQtGUI::calibrateClicked() { + m_presenter->notify(IEnggDiffractionPresenter::CalcCalib); +} + +void EnggDiffractionViewQtGUI::CroppedCalibrateClicked() { + m_presenter->notify(IEnggDiffractionPresenter::CropCalib); +} + +void EnggDiffractionViewQtGUI::focusClicked() { + m_presenter->notify(IEnggDiffractionPresenter::FocusRun); +} + +void EnggDiffractionViewQtGUI::focusCroppedClicked() { + m_presenter->notify(IEnggDiffractionPresenter::FocusCropped); +} + +void EnggDiffractionViewQtGUI::focusTextureClicked() { + m_presenter->notify(IEnggDiffractionPresenter::FocusTexture); +} + +void EnggDiffractionViewQtGUI::focusResetClicked() { + m_presenter->notify(IEnggDiffractionPresenter::ResetFocus); +} + +void EnggDiffractionViewQtGUI::focusStopClicked() { + m_presenter->notify(IEnggDiffractionPresenter::StopFocus); +} + +void EnggDiffractionViewQtGUI::rebinTimeClicked() { + m_presenter->notify(IEnggDiffractionPresenter::RebinTime); +} + +void EnggDiffractionViewQtGUI::rebinMultiperiodClicked() { + m_presenter->notify(IEnggDiffractionPresenter::RebinMultiperiod); +} + +void EnggDiffractionViewQtGUI::browseInputDirCalib() { + QString prevPath = QString::fromStdString(m_calibSettings.m_inputDirCalib); + if (prevPath.isEmpty()) { + prevPath = + MantidQt::API::AlgorithmInputHistory::Instance().getPreviousDirectory(); + } + QString dir = QFileDialog::getExistingDirectory( + this, tr("Open Directory"), prevPath, + QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks); + + if (dir.isEmpty()) { + return; + } + + MantidQt::API::AlgorithmInputHistory::Instance().setPreviousDirectory(dir); + m_calibSettings.m_inputDirCalib = dir.toStdString(); + m_uiTabSettings.lineEdit_input_dir_calib->setText( + QString::fromStdString(m_calibSettings.m_inputDirCalib)); +} + +void EnggDiffractionViewQtGUI::browseInputDirRaw() { + QString prevPath = QString::fromStdString(m_calibSettings.m_inputDirRaw); + if (prevPath.isEmpty()) { + prevPath = + MantidQt::API::AlgorithmInputHistory::Instance().getPreviousDirectory(); + } + QString dir = QFileDialog::getExistingDirectory( + this, tr("Open Directory"), prevPath, + QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks); + + if (dir.isEmpty()) { + return; + } + + MantidQt::API::AlgorithmInputHistory::Instance().setPreviousDirectory(dir); + m_calibSettings.m_inputDirRaw = dir.toStdString(); + m_uiTabSettings.lineEdit_input_dir_raw->setText( + QString::fromStdString(m_calibSettings.m_inputDirRaw)); +} + +void EnggDiffractionViewQtGUI::browsePixelCalibFilename() { + QString prevPath = QString::fromStdString(m_calibSettings.m_inputDirCalib); + if (prevPath.isEmpty()) { + prevPath = + MantidQt::API::AlgorithmInputHistory::Instance().getPreviousDirectory(); + } + + QString filename = QFileDialog::getOpenFileName( + this, tr("Open pixel calibration (full calibration) file"), prevPath, + QString::fromStdString(g_pixelCalibExt)); + + if (filename.isEmpty()) { + return; + } + + m_calibSettings.m_pixelCalibFilename = filename.toStdString(); + m_uiTabSettings.lineEdit_pixel_calib_filename->setText( + QString::fromStdString(m_calibSettings.m_pixelCalibFilename)); +} + +void EnggDiffractionViewQtGUI::browseTemplateGSAS_PRM() { + + QString prevPath = QString::fromStdString(m_calibSettings.m_templateGSAS_PRM); + QString path(QFileDialog::getOpenFileName( + this, tr("Open GSAS IPAR template file"), prevPath, + QString::fromStdString(g_iparmExtStr))); + + if (path.isEmpty()) { + return; + } + + m_calibSettings.m_templateGSAS_PRM = path.toStdString(); + m_uiTabSettings.lineEdit_template_gsas_prm->setText( + QString::fromStdString(m_calibSettings.m_templateGSAS_PRM)); +} + +void EnggDiffractionViewQtGUI::forceRecalculateStateChanged() { + m_calibSettings.m_forceRecalcOverwrite = + m_uiTabSettings.checkBox_force_recalculate_overwrite->isChecked(); +} + +void EnggDiffractionViewQtGUI::browseTextureDetGroupingFile() { + QString prevPath = QString::fromStdString(m_calibSettings.m_inputDirRaw); + if (prevPath.isEmpty()) { + prevPath = + MantidQt::API::AlgorithmInputHistory::Instance().getPreviousDirectory(); + } + + QString path(QFileDialog::getOpenFileName( + this, tr("Open detector grouping file"), prevPath, + QString::fromStdString(g_DetGrpExtStr))); + + if (path.isEmpty()) { + return; + } + + MantidQt::API::AlgorithmInputHistory::Instance().setPreviousDirectory(path); + m_uiTabFocus.lineEdit_texture_grouping_file->setText(path); +} + +std::vector<std::string> EnggDiffractionViewQtGUI::focusingRunNo() const { + return qListToVector(m_uiTabFocus.MWRunFiles_run_num->getFilenames(), + m_uiTabFocus.MWRunFiles_run_num->isValid()); +} + +std::vector<std::string> +EnggDiffractionViewQtGUI::focusingCroppedRunNo() const { + return qListToVector(m_uiTabFocus.MWRunFiles_cropped_run_num->getFilenames(), + m_uiTabFocus.MWRunFiles_cropped_run_num->isValid()); +} + +std::vector<std::string> +EnggDiffractionViewQtGUI::focusingTextureRunNo() const { + return qListToVector(m_uiTabFocus.MWRunFiles_texture_run_num->getFilenames(), + m_uiTabFocus.MWRunFiles_texture_run_num->isValid()); +} + +std::vector<std::string> +EnggDiffractionViewQtGUI::qListToVector(const QStringList &list, + bool validator) const { + std::vector<std::string> vec; + if (validator) { + foreach (const QString &str, list) { vec.emplace_back(str.toStdString()); } + } + + return vec; +} + +std::vector<bool> EnggDiffractionViewQtGUI::focusingBanks() const { + std::vector<bool> res; + res.emplace_back(m_uiTabFocus.checkBox_focus_bank1->isChecked()); + res.emplace_back(m_uiTabFocus.checkBox_focus_bank2->isChecked()); + return res; +} + +std::string EnggDiffractionViewQtGUI::focusingCroppedSpectrumNos() const { + return m_uiTabFocus.lineEdit_cropped_spec_nos->text().toStdString(); +} + +std::string EnggDiffractionViewQtGUI::focusingTextureGroupingFile() const { + return m_uiTabFocus.lineEdit_texture_grouping_file->text().toStdString(); +} + +bool EnggDiffractionViewQtGUI::focusedOutWorkspace() const { + return m_uiTabFocus.checkBox_plot_focused_ws->checkState(); +} + +bool EnggDiffractionViewQtGUI::plotCalibWorkspace() const { + return m_uiTabCalib.checkBox_PlotData_Calib->checkState(); +} + +bool EnggDiffractionViewQtGUI::saveFocusedOutputFiles() const { + return m_uiTabFocus.checkBox_save_output_files->checkState(); +} + +void MantidQt::CustomInterfaces::EnggDiffractionViewQtGUI::showInvalidRBNumber( + const bool rbNumberIsValid) { + m_ui.label_invalidRBNumber->setVisible(!rbNumberIsValid); +} + +void EnggDiffractionViewQtGUI::plotFocusStatus() { + if (focusedOutWorkspace()) { + m_uiTabFocus.comboBox_PlotData->setEnabled(true); + } else { + m_uiTabFocus.comboBox_PlotData->setEnabled(false); + } +} + +void EnggDiffractionViewQtGUI::calibspecNoChanged(int /*idx*/) { + QComboBox *BankName = m_uiTabCalib.comboBox_calib_cropped_bank_name; + if (!BankName) + return; + g_currentCropCalibBankName = BankName->currentIndex(); +} + +void EnggDiffractionViewQtGUI::enableSpecNos() { + if (g_currentCropCalibBankName == 0) { + m_uiTabCalib.lineEdit_cropped_spec_nos->setEnabled(true); + m_uiTabCalib.lineEdit_cropped_customise_bank_name->setEnabled(true); + } else { + m_uiTabCalib.lineEdit_cropped_spec_nos->setDisabled(true); + m_uiTabCalib.lineEdit_cropped_customise_bank_name->setDisabled(true); + } +} + +std::string EnggDiffractionViewQtGUI::currentCalibSpecNos() const { + return m_uiTabCalib.lineEdit_cropped_spec_nos->text().toStdString(); +} + +std::string EnggDiffractionViewQtGUI::currentCalibCustomisedBankName() const { + return m_uiTabCalib.lineEdit_cropped_customise_bank_name->text() + .toStdString(); +} + +void EnggDiffractionViewQtGUI::multiRunModeChanged(int /*idx*/) { + QComboBox *plotType = m_uiTabFocus.comboBox_Multi_Runs; + if (!plotType) + return; + g_currentRunMode = plotType->currentIndex(); +} + +void EnggDiffractionViewQtGUI::plotRepChanged(int /*idx*/) { + QComboBox *plotType = m_uiTabFocus.comboBox_PlotData; + if (!plotType) + return; + g_currentType = plotType->currentIndex(); +} + +void EnggDiffractionViewQtGUI::instrumentChanged(int /*idx*/) { + QComboBox *inst = m_ui.comboBox_instrument; + if (!inst) + return; + m_currentInst = inst->currentText().toStdString(); + m_presenter->notify(IEnggDiffractionPresenter::InstrumentChange); +} + +void EnggDiffractionViewQtGUI::RBNumberChanged() { + m_presenter->notify(IEnggDiffractionPresenter::RBNumberChange); +} + +void EnggDiffractionViewQtGUI::userSelectInstrument(const QString &prefix) { + // Set file browsing to current instrument + setPrefix(prefix.toStdString()); +} + +void EnggDiffractionViewQtGUI::setPrefix(const std::string &prefix) { + QString prefixInput = QString::fromStdString(prefix); + // focus tab + m_uiTabFocus.MWRunFiles_run_num->setInstrumentOverride(prefixInput); + m_uiTabFocus.MWRunFiles_texture_run_num->setInstrumentOverride(prefixInput); + + // calibration tab + m_uiTabCalib.MWRunFiles_new_ceria_num->setInstrumentOverride(prefixInput); + m_uiTabCalib.MWRunFiles_new_vanadium_num->setInstrumentOverride(prefixInput); + + // rebin tab + m_uiTabPreproc.MWRunFiles_preproc_run_num->setInstrumentOverride(prefixInput); +} + +void EnggDiffractionViewQtGUI::showEvent(QShowEvent * /*unused*/) { + // make sure that the RB number is checked on interface startup/show + m_presenter->notify(IEnggDiffractionPresenter::RBNumberChange); +} + +void EnggDiffractionViewQtGUI::closeEvent(QCloseEvent *event) { + int answer = QMessageBox::AcceptRole; + + QMessageBox msgBox; + if (false /* TODO: get this from user settings if eventually used */) { + msgBox.setWindowTitle("Close the engineering diffraction interface"); + // with something like this, we'd have layout issues: + // msgBox.setStandardButtons(QMessageBox::No | QMessageBox::Yes); + // msgBox.setDefaultButton(QMessageBox::Yes); + msgBox.setIconPixmap(QPixmap(":/win/unknown.png")); + QCheckBox confirmCheckBox("Always ask for confirmation", &msgBox); + confirmCheckBox.setCheckState(Qt::Checked); + msgBox.layout()->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding)); + msgBox.layout()->addWidget(&confirmCheckBox); + QPushButton *bYes = msgBox.addButton("Yes", QMessageBox::YesRole); + bYes->setIcon(style()->standardIcon(QStyle::SP_DialogYesButton)); + QPushButton *bNo = msgBox.addButton("No", QMessageBox::NoRole); + bNo->setIcon(style()->standardIcon(QStyle::SP_DialogNoButton)); + msgBox.setDefaultButton(bNo); + msgBox.setText("You are about to close this interface"); + msgBox.setInformativeText("Are you sure?"); + answer = msgBox.exec(); + } + + if (answer == QMessageBox::AcceptRole && m_ui.pushButton_close->isEnabled()) { + m_presenter->notify(IEnggDiffractionPresenter::ShutDown); + delete m_splashMsg; + m_splashMsg = nullptr; + event->accept(); + } else { + event->ignore(); + } +} + +void EnggDiffractionViewQtGUI::openHelpWin() { + MantidQt::API::HelpWindow::showCustomInterface( + nullptr, QString("Engineering Diffraction")); +} + +void EnggDiffractionViewQtGUI::updateTabsInstrument( + const std::string &newInstrument) { + m_fittingWidget->setCurrentInstrument(newInstrument); +} + +} // namespace CustomInterfaces +} // namespace MantidQt diff --git a/qt/scientific_interfaces/EnggDiffraction/EnggDiffractionViewQtGUI.h b/qt/scientific_interfaces/EnggDiffraction/EnggDiffractionViewQtGUI.h new file mode 100644 index 0000000000000000000000000000000000000000..a189152fb8d09a1dfb960508d5a0449b8a69a7ce --- /dev/null +++ b/qt/scientific_interfaces/EnggDiffraction/EnggDiffractionViewQtGUI.h @@ -0,0 +1,301 @@ +// Mantid Repository : https://github.com/mantidproject/mantid +// +// Copyright © 2015 ISIS Rutherford Appleton Laboratory UKRI, +// NScD Oak Ridge National Laboratory, European Spallation Source +// & Institut Laue - Langevin +// SPDX - License - Identifier: GPL - 3.0 + +#pragma once + +#include "DllConfig.h" +#include "EnggDiffFittingViewQtWidget.h" +#include "EnggDiffGSASFittingViewQtWidget.h" +#include "IEnggDiffractionPresenter.h" +#include "IEnggDiffractionView.h" +#include "MantidAPI/IPeakFunction.h" +#include "MantidQtWidgets/Common/UserSubWindow.h" +#include "MantidQtWidgets/Plotting/Qwt/PeakPicker.h" + +#include "ui_EnggDiffractionQtGUI.h" +#include "ui_EnggDiffractionQtTabCalib.h" +#include "ui_EnggDiffractionQtTabFocus.h" +#include "ui_EnggDiffractionQtTabPreproc.h" +#include "ui_EnggDiffractionQtTabSettings.h" + +// Qt classes forward declarations +class QMessageBox; +class QMutex; + +class QwtPlotCurve; +class QwtPlotZoomer; + +namespace MantidQt { +namespace CustomInterfaces { + +/** +Qt-based view of the Engineering Diffraction (EnggDiffraction) +GUI. Provides a concrete view for the graphical interface for Engg +functionality in Mantid. This view is Qt-based and it is probably the +only one that will be implemented in a foreseeable horizon. The +interface of this class is given by IEnggDiffractionView so that it +fits in the MVP (Model-View-Presenter) design of this GUI. +*/ +class MANTIDQT_ENGGDIFFRACTION_DLL EnggDiffractionViewQtGUI + : public MantidQt::API::UserSubWindow, + public IEnggDiffractionView { + Q_OBJECT + +public: + /// Default Constructor + EnggDiffractionViewQtGUI(QWidget *parent = nullptr); + /// Interface name + static std::string name() { return "Engineering Diffraction (Old)"; } + /// This interface's categories. + static QString categoryInfo() { return "Diffraction"; } + + void splashMessage(bool visible, const std::string &shortMsg, + const std::string &description) override; + + void showStatus(const std::string &sts) override; + + void userWarning(const std::string &warn, + const std::string &description) override; + + void userError(const std::string &err, + const std::string &description) override; + + std::string + askNewCalibrationFilename(const std::string &suggestedFname) override; + + std::string askExistingCalibFilename() override; + + std::vector<std::string> logMsgs() const override { return m_logMsgs; } + + std::string getRBNumber() const override; + + EnggDiffCalibSettings currentCalibSettings() const override { + return m_calibSettings; + } + + std::string currentInstrument() const override { return m_currentInst; } + + std::string currentVanadiumNo() const override; + + std::string currentCeriaNo() const override; + + std::string currentCalibFile() const override; + + std::vector<std::string> newVanadiumNo() const override; + + std::vector<std::string> newCeriaNo() const override; + + int currentCropCalibBankName() const override { + return g_currentCropCalibBankName; + } + + std::string currentCalibSpecNos() const override; + + std::string currentCalibCustomisedBankName() const override; + + void newCalibLoaded(const std::string &vanadiumNo, const std::string &ceriaNo, + const std::string &fname) override; + + std::string enggRunPythonCode(const std::string &pyCode) override; + + void enableTabs(bool enable) override; + + void enableCalibrateFocusFitUserActions(bool enable) override; + + std::vector<std::string> focusingRunNo() const override; + + std::vector<std::string> focusingCroppedRunNo() const override; + + std::vector<std::string> focusingTextureRunNo() const override; + + std::vector<bool> focusingBanks() const override; + + std::string focusingCroppedSpectrumNos() const override; + + std::string focusingTextureGroupingFile() const override; + + bool focusedOutWorkspace() const override; + + bool plotCalibWorkspace() const override; + + void resetFocus() override; + + std::vector<std::string> currentPreprocRunNo() const override; + + double rebinningTimeBin() const override; + + size_t rebinningPulsesNumberPeriods() const override; + + double rebinningPulsesTime() const override; + + void plotFocusedSpectrum(const std::string &wsName) override; + + void plotWaterfallSpectrum(const std::string &wsName) override; + + void plotReplacingWindow(const std::string &wsName, + const std::string &spectrum, + const std::string &type) override; + + void plotCalibOutput(const std::string &pyCode) override; + + bool saveFocusedOutputFiles() const override; + + void showInvalidRBNumber(const bool rbNumberIsValid) override; + + int currentPlotType() const override { return g_currentType; } + + int currentMultiRunMode() const override { return g_currentRunMode; } + + void updateTabsInstrument(const std::string &newInstrument) override; + +signals: + void getBanks(); + void setBank(); + +private slots: + /// for buttons, do calibrate, focus, event->histo rebin, and similar + void loadCalibrationClicked(); + void calibrateClicked(); + void CroppedCalibrateClicked(); + void focusClicked(); + void focusCroppedClicked(); + void focusTextureClicked(); + void focusStopClicked(); + void rebinTimeClicked(); + void rebinMultiperiodClicked(); + + // slots of the settings tab/section of the interface + void browseInputDirCalib(); + void browseInputDirRaw(); + void browsePixelCalibFilename(); + void browseTemplateGSAS_PRM(); + void forceRecalculateStateChanged(); + + // slots for the focusing options + void browseTextureDetGroupingFile(); + void focusResetClicked(); + + // slots of the calibration tab/section of the interface + + // slots of the general part of the interface + void instrumentChanged(int idx); + + void RBNumberChanged(); + + // slot of the cropped calibration part of the interface + void calibspecNoChanged(int idx); + + // slots of the focus part of the interface + void plotRepChanged(int idx); + + // slot of the multi-run mode for focus + void multiRunModeChanged(int idx); + + // slots of plot spectrum check box status + void plotFocusStatus(); + + // enables the text field when appropriate bank name is selected + void enableSpecNos(); + + // show the standard Mantid help window with this interface's help + void openHelpWin(); + +private: + /// Setup the interface (tab UI) + void initLayout() override; + void doSetupGeneralWidgets(); + void doSetupSplashMsg(); + void doSetupTabCalib(); + void doSetupTabFocus(); + void doSetupTabPreproc(); + void doSetupTabSettings(); + + std::string guessGSASTemplatePath() const; + std::string guessDefaultFullCalibrationPath() const; + + /// Load default interface settings for each tab, normally on startup + void readSettings(); + /// save settings (before closing) + void saveSettings() const override; + + // when the interface is shown + void showEvent(QShowEvent * /*unused*/) override; + + // window (custom interface) close + void closeEvent(QCloseEvent *ev) override; + + // path/name for the persistent settings group of this interface + const static std::string g_settingsGroup; + + // here the view puts messages before notifying the presenter to show them + std::vector<std::string> m_logMsgs; + + /// Interface definition with widgets for the main interface window + Ui::EnggDiffractionQtGUI m_ui; + // And its sections/tabs. Note that for compactness they're called simply + // 'tabs' + // but they could be separate dialogs, widgets, etc. + Ui::EnggDiffractionQtTabCalib m_uiTabCalib; + Ui::EnggDiffractionQtTabFocus m_uiTabFocus; + Ui::EnggDiffractionQtTabPreproc m_uiTabPreproc; + // Ui::EnggDiffractionQtTabFitting m_uiTabFitting; + EnggDiffFittingViewQtWidget *m_fittingWidget; + EnggDiffGSASFittingViewQtWidget *m_gsasWidget; + Ui::EnggDiffractionQtTabSettings m_uiTabSettings; + + /// converts QList to a vector + std::vector<std::string> qListToVector(const QStringList &list, + bool validator) const; + + /// instrument selected (ENGIN-X, etc.) + std::string m_currentInst; + + /// User select instrument + void userSelectInstrument(const QString &prefix); + + /// setting the instrument prefix ahead of the run number + void setPrefix(const std::string &prefix); + + // TODO: The values of these three next static members (bank name, + // type, run mode) can be obtained from widgets when requested/required. They + // shouldn't need to be cached in data members. Remove them. + + // current bank number used for cropped calibration + int static g_currentCropCalibBankName; + + // plot data representation type selected + int static g_currentType; + + // multi-run focus mode type selected + int static g_currentRunMode; + + /// calibration settings - from/to the 'settings' tab + EnggDiffCalibSettings m_calibSettings; + + /// To show important non-modal messages + QMessageBox *m_splashMsg; + + /// This is in principle the only settings for 'focus' + std::string m_focusDir; + + /// for the 'Rebin' parameter of some Engg* algorithms + static const double g_defaultRebinWidth; + + /// supported file extensions string for IPARM files (for the open + /// file dialogs) + static const std::string g_iparmExtStr; + /// supported file extensions string for the pixel (full) claibration + static const std::string g_pixelCalibExt; + /// supported/suggested file extensions for the detector groups file + /// (focusing) + static const std::string g_DetGrpExtStr; + + /// presenter as in the model-view-presenter + boost::shared_ptr<IEnggDiffractionPresenter> m_presenter; +}; + +} // namespace CustomInterfaces +} // namespace MantidQt diff --git a/qt/scientific_interfaces/EnggDiffraction/EnggVanadiumCorrectionsModel.cpp b/qt/scientific_interfaces/EnggDiffraction/EnggVanadiumCorrectionsModel.cpp new file mode 100644 index 0000000000000000000000000000000000000000..4a853ba26050276c93b2361c80b5cfa3fd50c3fb --- /dev/null +++ b/qt/scientific_interfaces/EnggDiffraction/EnggVanadiumCorrectionsModel.cpp @@ -0,0 +1,196 @@ +// Mantid Repository : https://github.com/mantidproject/mantid +// +// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI, +// NScD Oak Ridge National Laboratory, European Spallation Source +// & Institut Laue - Langevin +// SPDX - License - Identifier: GPL - 3.0 + +#include "EnggVanadiumCorrectionsModel.h" + +#include "MantidAPI/AlgorithmManager.h" +#include "MantidAPI/AnalysisDataService.h" +#include "MantidAPI/MatrixWorkspace.h" + +#include <Poco/File.h> +#include <Poco/Path.h> + +namespace MantidQt { +namespace CustomInterfaces { + +EnggVanadiumCorrectionsModel::EnggVanadiumCorrectionsModel( + const EnggDiffCalibSettings &calibSettings, + const std::string ¤tInstrument) + : m_calibSettings(calibSettings), m_currentInstrument(currentInstrument) {} + +const std::string EnggVanadiumCorrectionsModel::CURVES_WORKSPACE_NAME = + "engggui_vanadium_curves"; + +const std::string EnggVanadiumCorrectionsModel::INTEGRATED_WORKSPACE_NAME = + "engggui_vanadium_integration"; + +const std::string EnggVanadiumCorrectionsModel::VANADIUM_INPUT_WORKSPACE_NAME = + "engggui_vanadium_ws"; + +std::pair<Mantid::API::ITableWorkspace_sptr, Mantid::API::MatrixWorkspace_sptr> +EnggVanadiumCorrectionsModel::calculateCorrectionWorkspaces( + const std::string &vanadiumRunNumber) const { + const auto vanadiumWS = + loadMatrixWorkspace(vanadiumRunNumber, VANADIUM_INPUT_WORKSPACE_NAME); + + auto enggVanadiumCorrections = + Mantid::API::AlgorithmManager::Instance().create( + "EnggVanadiumCorrections"); + enggVanadiumCorrections->initialize(); + enggVanadiumCorrections->setPropertyValue("VanadiumWorkspace", + VANADIUM_INPUT_WORKSPACE_NAME); + enggVanadiumCorrections->setPropertyValue("OutIntegrationWorkspace", + INTEGRATED_WORKSPACE_NAME); + enggVanadiumCorrections->setPropertyValue("OutCurvesWorkspace", + CURVES_WORKSPACE_NAME); + enggVanadiumCorrections->execute(); + + auto &ADS = Mantid::API::AnalysisDataService::Instance(); + + ADS.remove(VANADIUM_INPUT_WORKSPACE_NAME); + const auto integratedWorkspace = + ADS.retrieveWS<Mantid::API::ITableWorkspace>(INTEGRATED_WORKSPACE_NAME); + const auto curvesWorkspace = + ADS.retrieveWS<Mantid::API::MatrixWorkspace>(CURVES_WORKSPACE_NAME); + return std::make_pair(integratedWorkspace, curvesWorkspace); +} + +std::pair<Mantid::API::ITableWorkspace_sptr, Mantid::API::MatrixWorkspace_sptr> +EnggVanadiumCorrectionsModel::fetchCorrectionWorkspaces( + const std::string &vanadiumRunNumber) const { + const auto cachedCurvesWorkspace = + fetchCachedCurvesWorkspace(vanadiumRunNumber); + const auto cachedIntegratedWorkspace = + fetchCachedIntegratedWorkspace(vanadiumRunNumber); + + if (cachedCurvesWorkspace && cachedIntegratedWorkspace && + !m_calibSettings.m_forceRecalcOverwrite) { + return std::make_pair(cachedIntegratedWorkspace, cachedCurvesWorkspace); + } else { + const auto correctionWorkspaces = + calculateCorrectionWorkspaces(vanadiumRunNumber); + saveCorrectionsToCache(vanadiumRunNumber, correctionWorkspaces.second, + correctionWorkspaces.first); + return correctionWorkspaces; + } +} + +Mantid::API::MatrixWorkspace_sptr +EnggVanadiumCorrectionsModel::fetchCachedCurvesWorkspace( + const std::string &vanadiumRunNumber) const { + const auto filename = generateCurvesFilename(vanadiumRunNumber); + const Poco::File inputFile(filename); + if (inputFile.exists()) { + return loadMatrixWorkspace(filename, CURVES_WORKSPACE_NAME); + } + + return nullptr; +} + +Mantid::API::ITableWorkspace_sptr +EnggVanadiumCorrectionsModel::fetchCachedIntegratedWorkspace( + const std::string &vanadiumRunNumber) const { + const auto filename = generateIntegratedFilename(vanadiumRunNumber); + const Poco::File inputFile(filename); + if (inputFile.exists()) { + return loadTableWorkspace(filename, INTEGRATED_WORKSPACE_NAME); + } + + return nullptr; +} + +std::string EnggVanadiumCorrectionsModel::generateCurvesFilename( + const std::string &vanadiumRunNumber) const { + const static std::string filenameSuffix = + "_precalculated_vanadium_run_bank_curves.nxs"; + + const auto normalisedRunName = Poco::Path(vanadiumRunNumber).getBaseName(); + const auto curvesFilename = normalisedRunName + filenameSuffix; + + Poco::Path inputDir(m_calibSettings.m_inputDirCalib); + inputDir.append(curvesFilename); + return inputDir.toString(); +} + +std::string EnggVanadiumCorrectionsModel::generateIntegratedFilename( + const std::string &vanadiumRunNumber) const { + const static std::string filenameSuffix = + "_precalculated_vanadium_run_integration.nxs"; + + const auto normalisedRunName = Poco::Path(vanadiumRunNumber).getBaseName(); + const auto integratedFilename = normalisedRunName + filenameSuffix; + + Poco::Path inputDir(m_calibSettings.m_inputDirCalib); + inputDir.append(integratedFilename); + return inputDir.toString(); +} + +std::string EnggVanadiumCorrectionsModel::generateVanadiumRunName( + const std::string &vanadiumRunNumber) const { + constexpr static size_t normalisedRunNumberLength = 8; + return m_currentInstrument + + std::string(normalisedRunNumberLength - vanadiumRunNumber.length(), + '0') + + vanadiumRunNumber; +} + +Mantid::API::MatrixWorkspace_sptr +EnggVanadiumCorrectionsModel::loadMatrixWorkspace( + const std::string &filename, const std::string &workspaceName) const { + auto load = Mantid::API::AlgorithmManager::Instance().create("Load"); + load->initialize(); + load->setPropertyValue("Filename", filename); + load->setPropertyValue("OutputWorkspace", workspaceName); + load->execute(); + return Mantid::API::AnalysisDataService::Instance() + .retrieveWS<Mantid::API::MatrixWorkspace>(workspaceName); +} + +Mantid::API::ITableWorkspace_sptr +EnggVanadiumCorrectionsModel::loadTableWorkspace( + const std::string &filename, const std::string &workspaceName) const { + auto load = Mantid::API::AlgorithmManager::Instance().create("Load"); + load->initialize(); + load->setPropertyValue("Filename", filename); + load->setPropertyValue("OutputWorkspace", workspaceName); + load->execute(); + return Mantid::API::AnalysisDataService::Instance() + .retrieveWS<Mantid::API::ITableWorkspace>(workspaceName); +} + +void EnggVanadiumCorrectionsModel::saveCorrectionsToCache( + const std::string &runNumber, + const Mantid::API::MatrixWorkspace_sptr &curvesWorkspace, + const Mantid::API::ITableWorkspace_sptr &integratedWorkspace) const { + const auto curvesFilename = generateCurvesFilename(runNumber); + saveNexus(curvesFilename, curvesWorkspace); + + const auto integratedFilename = generateIntegratedFilename(runNumber); + saveNexus(integratedFilename, integratedWorkspace); +} + +void EnggVanadiumCorrectionsModel::saveNexus( + const std::string &filename, + const Mantid::API::Workspace_sptr &workspace) const { + auto save = Mantid::API::AlgorithmManager::Instance().create("SaveNexus"); + save->initialize(); + save->setProperty("InputWorkspace", workspace); + save->setProperty("Filename", filename); + save->execute(); +} + +void EnggVanadiumCorrectionsModel::setCalibSettings( + const EnggDiffCalibSettings &calibSettings) { + m_calibSettings = calibSettings; +} + +void EnggVanadiumCorrectionsModel::setCurrentInstrument( + const std::string ¤tInstrument) { + m_currentInstrument = currentInstrument; +} + +} // namespace CustomInterfaces +} // namespace MantidQt diff --git a/qt/scientific_interfaces/EnggDiffraction/EnggVanadiumCorrectionsModel.h b/qt/scientific_interfaces/EnggDiffraction/EnggVanadiumCorrectionsModel.h new file mode 100644 index 0000000000000000000000000000000000000000..e448801a74efcdc84dd7921e4c9b69c994163461 --- /dev/null +++ b/qt/scientific_interfaces/EnggDiffraction/EnggVanadiumCorrectionsModel.h @@ -0,0 +1,83 @@ +// Mantid Repository : https://github.com/mantidproject/mantid +// +// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI, +// NScD Oak Ridge National Laboratory, European Spallation Source +// & Institut Laue - Langevin +// SPDX - License - Identifier: GPL - 3.0 + +#pragma once + +#include "DllConfig.h" +#include "IEnggVanadiumCorrectionsModel.h" + +#include <Poco/Path.h> +#include <boost/optional.hpp> + +namespace MantidQt { +namespace CustomInterfaces { + +class MANTIDQT_ENGGDIFFRACTION_DLL EnggVanadiumCorrectionsModel + : public IEnggVanadiumCorrectionsModel { + +public: + EnggVanadiumCorrectionsModel(const EnggDiffCalibSettings &calibSettings, + const std::string ¤tInstrument); + + std::pair<Mantid::API::ITableWorkspace_sptr, + Mantid::API::MatrixWorkspace_sptr> + fetchCorrectionWorkspaces( + const std::string &vanadiumRunNumber) const override; + + void setCalibSettings(const EnggDiffCalibSettings &calibSettings) override; + + void setCurrentInstrument(const std::string ¤tInstrument) override; + +protected: + const static std::string CURVES_WORKSPACE_NAME; + + const static std::string INTEGRATED_WORKSPACE_NAME; + +private: + const static std::string VANADIUM_INPUT_WORKSPACE_NAME; + + virtual std::pair<Mantid::API::ITableWorkspace_sptr, + Mantid::API::MatrixWorkspace_sptr> + calculateCorrectionWorkspaces(const std::string &vanadiumRunNumber) const; + + Mantid::API::MatrixWorkspace_sptr + fetchCachedCurvesWorkspace(const std::string &vanadiumRunNumber) const; + + Mantid::API::ITableWorkspace_sptr + fetchCachedIntegratedWorkspace(const std::string &vanadiumRunNumber) const; + + std::string + generateCurvesFilename(const std::string &vanadiumRunNumber) const; + + std::string + generateIntegratedFilename(const std::string &vanadiumRunNumber) const; + + std::string + generateVanadiumRunName(const std::string &vanadiumRunNumber) const; + + Mantid::API::MatrixWorkspace_sptr + loadMatrixWorkspace(const std::string &filename, + const std::string &workspaceName) const; + + Mantid::API::ITableWorkspace_sptr + loadTableWorkspace(const std::string &filename, + const std::string &workspaceName) const; + + void saveCorrectionsToCache( + const std::string &runNumber, + const Mantid::API::MatrixWorkspace_sptr &curvesWorkspace, + const Mantid::API::ITableWorkspace_sptr &integratedWorkspace) const; + + void saveNexus(const std::string &filename, + const Mantid::API::Workspace_sptr &workspace) const; + + EnggDiffCalibSettings m_calibSettings; + + std::string m_currentInstrument; +}; + +} // namespace CustomInterfaces +} // namespace MantidQt diff --git a/qt/scientific_interfaces/EnggDiffraction/GSASIIRefineFitPeaksOutputProperties.cpp b/qt/scientific_interfaces/EnggDiffraction/GSASIIRefineFitPeaksOutputProperties.cpp new file mode 100644 index 0000000000000000000000000000000000000000..64bf41193da13485979afaee0cbf5bb156c4159c --- /dev/null +++ b/qt/scientific_interfaces/EnggDiffraction/GSASIIRefineFitPeaksOutputProperties.cpp @@ -0,0 +1,34 @@ +// Mantid Repository : https://github.com/mantidproject/mantid +// +// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI, +// NScD Oak Ridge National Laboratory, European Spallation Source +// & Institut Laue - Langevin +// SPDX - License - Identifier: GPL - 3.0 + +#include "GSASIIRefineFitPeaksOutputProperties.h" + +namespace MantidQt { +namespace CustomInterfaces { + +GSASIIRefineFitPeaksOutputProperties::GSASIIRefineFitPeaksOutputProperties( + const double _rwp, const double _sigma, const double _gamma, + const Mantid::API::MatrixWorkspace_sptr &_fittedPeaksWS, + const Mantid::API::ITableWorkspace_sptr &_latticeParamsWS, + const RunLabel &_runLabel) + : rwp(_rwp), sigma(_sigma), gamma(_gamma), fittedPeaksWS(_fittedPeaksWS), + latticeParamsWS(_latticeParamsWS), runLabel(_runLabel) {} + +bool operator==(const GSASIIRefineFitPeaksOutputProperties &lhs, + const GSASIIRefineFitPeaksOutputProperties &rhs) { + return lhs.rwp == rhs.rwp && lhs.sigma == rhs.sigma && + lhs.gamma == rhs.gamma && lhs.fittedPeaksWS == rhs.fittedPeaksWS && + lhs.latticeParamsWS == rhs.latticeParamsWS && + lhs.runLabel == rhs.runLabel; +} + +bool operator!=(const GSASIIRefineFitPeaksOutputProperties &lhs, + const GSASIIRefineFitPeaksOutputProperties &rhs) { + return !(lhs == rhs); +} + +} // namespace CustomInterfaces +} // namespace MantidQt diff --git a/qt/scientific_interfaces/EnggDiffraction/GSASIIRefineFitPeaksOutputProperties.h b/qt/scientific_interfaces/EnggDiffraction/GSASIIRefineFitPeaksOutputProperties.h new file mode 100644 index 0000000000000000000000000000000000000000..435cf4b170a69710eeccae647d4473ad910bf54b --- /dev/null +++ b/qt/scientific_interfaces/EnggDiffraction/GSASIIRefineFitPeaksOutputProperties.h @@ -0,0 +1,49 @@ +// Mantid Repository : https://github.com/mantidproject/mantid +// +// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI, +// NScD Oak Ridge National Laboratory, European Spallation Source +// & Institut Laue - Langevin +// SPDX - License - Identifier: GPL - 3.0 + +#pragma once + +#include "DllConfig.h" +#include "RunLabel.h" + +#include "MantidAPI/ITableWorkspace.h" +#include "MantidAPI/MatrixWorkspace_fwd.h" + +#include <QMetaType> + +namespace MantidQt { +namespace CustomInterfaces { + +struct MANTIDQT_ENGGDIFFRACTION_DLL GSASIIRefineFitPeaksOutputProperties { + GSASIIRefineFitPeaksOutputProperties( + const double _rwp, const double _sigma, const double _gamma, + const Mantid::API::MatrixWorkspace_sptr &_fittedPeaksWS, + const Mantid::API::ITableWorkspace_sptr &_latticeParamsWS, + const RunLabel &_runLabel); + + GSASIIRefineFitPeaksOutputProperties() = default; + + double rwp; + double sigma; + double gamma; + Mantid::API::MatrixWorkspace_sptr fittedPeaksWS; + Mantid::API::ITableWorkspace_sptr latticeParamsWS; + RunLabel runLabel; +}; + +MANTIDQT_ENGGDIFFRACTION_DLL bool +operator==(const GSASIIRefineFitPeaksOutputProperties &lhs, + const GSASIIRefineFitPeaksOutputProperties &rhs); + +MANTIDQT_ENGGDIFFRACTION_DLL bool +operator!=(const GSASIIRefineFitPeaksOutputProperties &lhs, + const GSASIIRefineFitPeaksOutputProperties &rhs); + +} // namespace CustomInterfaces +} // namespace MantidQt + +Q_DECLARE_METATYPE( + MantidQt::CustomInterfaces::GSASIIRefineFitPeaksOutputProperties) diff --git a/qt/scientific_interfaces/EnggDiffraction/GSASIIRefineFitPeaksParameters.cpp b/qt/scientific_interfaces/EnggDiffraction/GSASIIRefineFitPeaksParameters.cpp new file mode 100644 index 0000000000000000000000000000000000000000..370d025fc80a0e2688ce09dc9e96bfda2a84b49a --- /dev/null +++ b/qt/scientific_interfaces/EnggDiffraction/GSASIIRefineFitPeaksParameters.cpp @@ -0,0 +1,47 @@ +// Mantid Repository : https://github.com/mantidproject/mantid +// +// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI, +// NScD Oak Ridge National Laboratory, European Spallation Source +// & Institut Laue - Langevin +// SPDX - License - Identifier: GPL - 3.0 + +#include "GSASIIRefineFitPeaksParameters.h" + +namespace MantidQt { +namespace CustomInterfaces { + +GSASIIRefineFitPeaksParameters::GSASIIRefineFitPeaksParameters( + const Mantid::API::MatrixWorkspace_sptr &_inputWorkspace, + const RunLabel &_runLabel, const GSASRefinementMethod &_refinementMethod, + const std::string &_instParamsFile, + const std::vector<std::string> &_phaseFiles, const std::string &_gsasHome, + const std::string &_gsasProjectFile, const boost::optional<double> &_dMin, + const boost::optional<double> &_negativeWeight, + const boost::optional<double> &_xMin, const boost::optional<double> &_xMax, + const bool _refineSigma, const bool _refineGamma) + : inputWorkspace(_inputWorkspace), runLabel(_runLabel), + refinementMethod(_refinementMethod), instParamsFile(_instParamsFile), + phaseFiles(_phaseFiles), gsasHome(_gsasHome), + gsasProjectFile(_gsasProjectFile), dMin(_dMin), + negativeWeight(_negativeWeight), xMin(_xMin), xMax(_xMax), + refineSigma(_refineSigma), refineGamma(_refineGamma) {} + +bool operator==(const GSASIIRefineFitPeaksParameters &lhs, + const GSASIIRefineFitPeaksParameters &rhs) { + return lhs.inputWorkspace == rhs.inputWorkspace && + lhs.runLabel == rhs.runLabel && + lhs.refinementMethod == rhs.refinementMethod && + lhs.instParamsFile == rhs.instParamsFile && + lhs.phaseFiles == rhs.phaseFiles && lhs.gsasHome == rhs.gsasHome && + lhs.gsasProjectFile == rhs.gsasProjectFile && lhs.dMin == rhs.dMin && + lhs.negativeWeight == rhs.negativeWeight && lhs.xMin == rhs.xMin && + lhs.xMax == rhs.xMax && lhs.refineSigma == rhs.refineSigma && + lhs.refineGamma == rhs.refineGamma; +} + +bool operator!=(const GSASIIRefineFitPeaksParameters &lhs, + const GSASIIRefineFitPeaksParameters &rhs) { + return !(lhs == rhs); +} + +} // namespace CustomInterfaces +} // namespace MantidQt diff --git a/qt/scientific_interfaces/EnggDiffraction/GSASIIRefineFitPeaksParameters.h b/qt/scientific_interfaces/EnggDiffraction/GSASIIRefineFitPeaksParameters.h new file mode 100644 index 0000000000000000000000000000000000000000..d3ef97805f656d90e5484e6bc245761bfb196c5e --- /dev/null +++ b/qt/scientific_interfaces/EnggDiffraction/GSASIIRefineFitPeaksParameters.h @@ -0,0 +1,59 @@ +// Mantid Repository : https://github.com/mantidproject/mantid +// +// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI, +// NScD Oak Ridge National Laboratory, European Spallation Source +// & Institut Laue - Langevin +// SPDX - License - Identifier: GPL - 3.0 + +#pragma once + +#include "DllConfig.h" +#include "EnggDiffGSASRefinementMethod.h" +#include "RunLabel.h" + +#include "MantidAPI/MatrixWorkspace.h" + +#include <boost/optional.hpp> +#include <vector> + +namespace MantidQt { +namespace CustomInterfaces { + +struct MANTIDQT_ENGGDIFFRACTION_DLL GSASIIRefineFitPeaksParameters { + GSASIIRefineFitPeaksParameters( + const Mantid::API::MatrixWorkspace_sptr &_inputWorkspace, + const RunLabel &_runLabel, const GSASRefinementMethod &_refinementMethod, + const std::string &_instParamsFile, + const std::vector<std::string> &_phaseFiles, const std::string &_gsasHome, + const std::string &_gsasProjectFile, const boost::optional<double> &_dMin, + const boost::optional<double> &_negativeWeight, + const boost::optional<double> &_xMin, + const boost::optional<double> &_xMax, const bool _refineSigma, + const bool _refineGamma); + + const Mantid::API::MatrixWorkspace_sptr inputWorkspace; + const RunLabel runLabel; + const GSASRefinementMethod refinementMethod; + const std::string instParamsFile; + const std::vector<std::string> phaseFiles; + const std::string gsasHome; + const std::string gsasProjectFile; + + const boost::optional<double> dMin; + const boost::optional<double> negativeWeight; + const boost::optional<double> xMin; + const boost::optional<double> xMax; + + const bool refineSigma; + const bool refineGamma; +}; + +MANTIDQT_ENGGDIFFRACTION_DLL bool +operator==(const GSASIIRefineFitPeaksParameters &lhs, + const GSASIIRefineFitPeaksParameters &rhs); + +MANTIDQT_ENGGDIFFRACTION_DLL bool +operator!=(const GSASIIRefineFitPeaksParameters &lhs, + const GSASIIRefineFitPeaksParameters &rhs); + +} // namespace CustomInterfaces +} // namespace MantidQt diff --git a/qt/scientific_interfaces/General/DataComparison.cpp b/qt/scientific_interfaces/General/DataComparison.cpp index b328b1ef313b66bcf8b125e3c0b8b219de310e3e..8eaa1ccad120c82811c93b748f5f124fce7972b9 100644 --- a/qt/scientific_interfaces/General/DataComparison.cpp +++ b/qt/scientific_interfaces/General/DataComparison.cpp @@ -139,7 +139,7 @@ void DataComparison::addData() { * * @param ws Pointer to workspace to add. */ -void DataComparison::addDataItem(Workspace_const_sptr ws) { +void DataComparison::addDataItem(const Workspace_const_sptr &ws) { // Check that the workspace is the correct type MatrixWorkspace_const_sptr matrixWs = boost::dynamic_pointer_cast<const MatrixWorkspace>(ws); @@ -212,7 +212,7 @@ void DataComparison::addDataItem(Workspace_const_sptr ws) { * * @param ws Pointer to the workspace */ -bool DataComparison::containsWorkspace(MatrixWorkspace_const_sptr ws) { +bool DataComparison::containsWorkspace(const MatrixWorkspace_const_sptr &ws) { QString testWsName = QString::fromStdString(ws->getName()); int numRows = m_uiForm.twCurrentData->rowCount(); diff --git a/qt/scientific_interfaces/General/DataComparison.h b/qt/scientific_interfaces/General/DataComparison.h index 8e40d12b61afe3894463ffd61e3825ff7044db93..b7893dae28cfa8ee97cdc03edc9ed5d1365a60bd 100644 --- a/qt/scientific_interfaces/General/DataComparison.h +++ b/qt/scientific_interfaces/General/DataComparison.h @@ -37,7 +37,7 @@ public: explicit DataComparison(QWidget *parent = nullptr); /// Tests if a workspace is shown in the UI - bool containsWorkspace(Mantid::API::MatrixWorkspace_const_sptr ws); + bool containsWorkspace(const Mantid::API::MatrixWorkspace_const_sptr &ws); private slots: /// Add selected data to plot @@ -72,7 +72,7 @@ private: /// Initialize the layout void initLayout() override; /// Adds a workspace to the data table - void addDataItem(Mantid::API::Workspace_const_sptr ws); + void addDataItem(const Mantid::API::Workspace_const_sptr &ws); /// Normalises spectra offsets in table void normaliseSpectraOffsets(); /// Gets an initial curve colour for a new workspace diff --git a/qt/scientific_interfaces/General/MantidEV.cpp b/qt/scientific_interfaces/General/MantidEV.cpp index fe65cb689995791917969c12919b7f0cc414bfa0..88506b13206bc0b60fa46baf06d965e867846dcf 100644 --- a/qt/scientific_interfaces/General/MantidEV.cpp +++ b/qt/scientific_interfaces/General/MantidEV.cpp @@ -1833,7 +1833,7 @@ void MantidEV::errorMessage(const std::string &message) { * * @return true if a double was extacted from the string. */ -bool MantidEV::getDouble(std::string str, double &value) { +bool MantidEV::getDouble(const std::string &str, double &value) { std::istringstream strs(str); if (strs >> value) { return true; @@ -2260,7 +2260,7 @@ void MantidEV::loadSettings(const std::string &filename) { * @param ledt pointer to the QLineEdit component whose state * is to be restored. */ -void MantidEV::restore(QSettings *state, QString name, QLineEdit *ledt) { +void MantidEV::restore(QSettings *state, const QString &name, QLineEdit *ledt) { // NOTE: If state was not saved yet, we don't want to change the // default value, so we only change the text if it's non-empty QString sText = state->value(name, "").toString(); @@ -2278,7 +2278,8 @@ void MantidEV::restore(QSettings *state, QString name, QLineEdit *ledt) { * @param btn pointer to the QCheckbox or QRadioButton component * whose state is to be restored. */ -void MantidEV::restore(QSettings *state, QString name, QAbstractButton *btn) { +void MantidEV::restore(QSettings *state, const QString &name, + QAbstractButton *btn) { btn->setChecked(state->value(name, false).toBool()); } @@ -2290,7 +2291,7 @@ void MantidEV::restore(QSettings *state, QString name, QAbstractButton *btn) { * @param cmbx pointer to the QComboBox component whose state is * to be restored. */ -void MantidEV::restore(QSettings *state, QString name, QComboBox *cmbx) { +void MantidEV::restore(QSettings *state, const QString &name, QComboBox *cmbx) { // NOTE: If state was not saved yet, we don't want to change the // default value, so we only change the selected item if the index // has been set to a valid value. diff --git a/qt/scientific_interfaces/General/MantidEV.h b/qt/scientific_interfaces/General/MantidEV.h index 5818a94f5f11043ba14e08ade84a7558644321d3..ca678fdcb1141f4cc26ed4f7ce95e0cae2cd17cd 100644 --- a/qt/scientific_interfaces/General/MantidEV.h +++ b/qt/scientific_interfaces/General/MantidEV.h @@ -363,7 +363,7 @@ private: void errorMessage(const std::string &message); /// Utility method to parse a double value in a string - bool getDouble(std::string str, double &value); + bool getDouble(const std::string &str, double &value); /// Utility method to get a double value from a QtLineEdit widget bool getDouble(QLineEdit *ledt, double &value); @@ -393,13 +393,13 @@ private: void loadSettings(const std::string &filename); /// Restore the value of the QLineEdit component from QSettings - void restore(QSettings *state, QString name, QLineEdit *ledt); + void restore(QSettings *state, const QString &name, QLineEdit *ledt); /// Restore the value of the QCheckbox or QRadioButton from QSettings - void restore(QSettings *state, QString name, QAbstractButton *btn); + void restore(QSettings *state, const QString &name, QAbstractButton *btn); /// Restore the value of a QComboBox from QSettings - void restore(QSettings *state, QString name, QComboBox *cmbx); + void restore(QSettings *state, const QString &name, QComboBox *cmbx); Ui::MantidEV m_uiForm; /// The form generated by Qt Designer diff --git a/qt/scientific_interfaces/General/StepScan.cpp b/qt/scientific_interfaces/General/StepScan.cpp index 0af5bf2a9fa92195ea58e0a16ecd27104e389a9a..0731b28502048f2c0d067e38e9dcde51086ffedd 100644 --- a/qt/scientific_interfaces/General/StepScan.cpp +++ b/qt/scientific_interfaces/General/StepScan.cpp @@ -248,7 +248,8 @@ void StepScan::loadFileComplete(bool error) { namespace { class ScopedStatusText { public: - ScopedStatusText(QLabel *label, QString labelText) : status_label(label) { + ScopedStatusText(QLabel *label, const QString &labelText) + : status_label(label) { status_label->setText("<i><font color='darkblue'>" + labelText + "</font></i>"); } @@ -549,7 +550,7 @@ void StepScan::runStepScanAlg() { generateCurve(m_uiForm.plotVariable->currentText()); } -bool StepScan::runStepScanAlgLive(std::string stepScanProperties) { +bool StepScan::runStepScanAlgLive(const std::string &stepScanProperties) { // First stop the currently running live algorithm IAlgorithm_const_sptr oldMonitorLiveData = m_uiForm.mWRunFiles->stopLiveAlgorithm(); diff --git a/qt/scientific_interfaces/General/StepScan.h b/qt/scientific_interfaces/General/StepScan.h index 5e713baae37ae4ee41369407d7b2899a12ad4246..b44c224b5af56630fed50c1d7d1d9f7a4ddff31d 100644 --- a/qt/scientific_interfaces/General/StepScan.h +++ b/qt/scientific_interfaces/General/StepScan.h @@ -45,7 +45,7 @@ private slots: void expandPlotVarCombobox(const Mantid::API::MatrixWorkspace_const_sptr &ws); void fillNormalizationCombobox(); void runStepScanAlg(); - bool runStepScanAlgLive(std::string stepScanProperties); + bool runStepScanAlgLive(const std::string &stepScanProperties); void updateForNormalizationChange(); void generateCurve(const QString &var); diff --git a/qt/scientific_interfaces/ISISReflectometry/Common/GetInstrumentParameter.cpp b/qt/scientific_interfaces/ISISReflectometry/Common/GetInstrumentParameter.cpp index 998b086eaac86631655fefa30dbed7c9980802d7..ef4d6a8ac6c7850e9aa74167cfb1a1708ca55b53 100644 --- a/qt/scientific_interfaces/ISISReflectometry/Common/GetInstrumentParameter.cpp +++ b/qt/scientific_interfaces/ISISReflectometry/Common/GetInstrumentParameter.cpp @@ -10,7 +10,7 @@ namespace CustomInterfaces { namespace ISISReflectometry { std::vector<std::string> InstrumentParameter<std::string>::get( - Mantid::Geometry::Instrument_const_sptr instrument, + const Mantid::Geometry::Instrument_const_sptr &instrument, std::string const ¶meterName) { try { return instrument->getStringParameter(parameterName); @@ -20,7 +20,7 @@ std::vector<std::string> InstrumentParameter<std::string>::get( } std::vector<int> InstrumentParameter<int>::get( - Mantid::Geometry::Instrument_const_sptr instrument, + const Mantid::Geometry::Instrument_const_sptr &instrument, std::string const ¶meterName) { try { return instrument->getIntParameter(parameterName); @@ -30,7 +30,7 @@ std::vector<int> InstrumentParameter<int>::get( } std::vector<bool> InstrumentParameter<bool>::get( - Mantid::Geometry::Instrument_const_sptr instrument, + const Mantid::Geometry::Instrument_const_sptr &instrument, std::string const ¶meterName) { try { return instrument->getBoolParameter(parameterName); @@ -40,7 +40,7 @@ std::vector<bool> InstrumentParameter<bool>::get( } std::vector<double> InstrumentParameter<double>::get( - Mantid::Geometry::Instrument_const_sptr instrument, + const Mantid::Geometry::Instrument_const_sptr &instrument, std::string const ¶meterName) { try { return instrument->getNumberParameter(parameterName); diff --git a/qt/scientific_interfaces/ISISReflectometry/Common/GetInstrumentParameter.h b/qt/scientific_interfaces/ISISReflectometry/Common/GetInstrumentParameter.h index dc31f2ea2dab45c1cb58360a2f6041edb73bd013..d10c16bc5b2d105de141f88dbfe62c7dc7f6c563 100644 --- a/qt/scientific_interfaces/ISISReflectometry/Common/GetInstrumentParameter.h +++ b/qt/scientific_interfaces/ISISReflectometry/Common/GetInstrumentParameter.h @@ -17,28 +17,28 @@ template <typename T> class InstrumentParameter; template <> class InstrumentParameter<std::string> { public: static std::vector<std::string> - get(Mantid::Geometry::Instrument_const_sptr instrument, + get(const Mantid::Geometry::Instrument_const_sptr &instrument, std::string const ¶meterName); }; template <> class InstrumentParameter<double> { public: static std::vector<double> - get(Mantid::Geometry::Instrument_const_sptr instrument, + get(const Mantid::Geometry::Instrument_const_sptr &instrument, std::string const ¶meterName); }; template <> class InstrumentParameter<int> { public: static std::vector<int> - get(Mantid::Geometry::Instrument_const_sptr instrument, + get(const Mantid::Geometry::Instrument_const_sptr &instrument, std::string const ¶meterName); }; template <> class InstrumentParameter<bool> { public: static std::vector<bool> - get(Mantid::Geometry::Instrument_const_sptr instrument, + get(const Mantid::Geometry::Instrument_const_sptr &instrument, std::string const ¶meterName); }; @@ -73,7 +73,7 @@ template <typename T1, typename T2> class InstrumentParameter<boost::variant<T1, T2>> { public: static boost::variant<std::vector<T1>, std::vector<T2>> - get(Mantid::Geometry::Instrument_const_sptr instrument, + get(const Mantid::Geometry::Instrument_const_sptr &instrument, std::string const ¶meterName) { try { return InstrumentParameter<T1>::get(instrument, parameterName); @@ -106,7 +106,7 @@ class InstrumentParameter<boost::variant<T1, T2, T3, Ts...>> { public: static boost::variant<std::vector<T1>, std::vector<T2>, std::vector<T3>, std::vector<Ts>...> - get(Mantid::Geometry::Instrument_const_sptr instrument, + get(const Mantid::Geometry::Instrument_const_sptr &instrument, std::string const ¶meterName) { try { return InstrumentParameter<T1>::get(instrument, parameterName); @@ -124,8 +124,9 @@ public: }; template <typename T> -auto getInstrumentParameter(Mantid::Geometry::Instrument_const_sptr instrument, - std::string const ¶meterName) +auto getInstrumentParameter( + const Mantid::Geometry::Instrument_const_sptr &instrument, + std::string const ¶meterName) -> decltype(InstrumentParameter<T>::get( std::declval<Mantid::Geometry::Instrument_const_sptr>(), std::declval<std::string const &>())) { diff --git a/qt/scientific_interfaces/ISISReflectometry/Common/OptionDefaults.cpp b/qt/scientific_interfaces/ISISReflectometry/Common/OptionDefaults.cpp index f75d7957cf110676a096611b7a7eaa63f1215457..7e06d2d8a2347b1ad888b47845b54d9cf3f64a95 100644 --- a/qt/scientific_interfaces/ISISReflectometry/Common/OptionDefaults.cpp +++ b/qt/scientific_interfaces/ISISReflectometry/Common/OptionDefaults.cpp @@ -5,6 +5,9 @@ // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + #include "OptionDefaults.h" + +#include <utility> + #include "MantidAPI/AlgorithmManager.h" namespace MantidQt { @@ -13,7 +16,7 @@ namespace ISISReflectometry { OptionDefaults::OptionDefaults( Mantid::Geometry::Instrument_const_sptr instrument) - : m_instrument(instrument) { + : m_instrument(std::move(instrument)) { // Get the algorithm for which we'll take defaults if available m_algorithm = Mantid::API::AlgorithmManager::Instance().createUnmanaged( "ReflectometryReductionOneAuto"); diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/Batch/AlgorithmProperties.cpp b/qt/scientific_interfaces/ISISReflectometry/GUI/Batch/AlgorithmProperties.cpp index c83da7f41013b74e406b9a51f3162db97ce9aaab..c4376c478c3d1ac55281e5c82acdd176be46dbe1 100644 --- a/qt/scientific_interfaces/ISISReflectometry/GUI/Batch/AlgorithmProperties.cpp +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/Batch/AlgorithmProperties.cpp @@ -65,7 +65,7 @@ void updateFromMap(AlgorithmRuntimeProps &properties, update(kvp.first, kvp.second, properties); } } -std::string getOutputWorkspace(IAlgorithm_sptr algorithm, +std::string getOutputWorkspace(const IAlgorithm_sptr &algorithm, std::string const &property) { auto const workspaceName = algorithm->getPropertyValue(property); return workspaceName; diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/Batch/AlgorithmProperties.h b/qt/scientific_interfaces/ISISReflectometry/GUI/Batch/AlgorithmProperties.h index 4761c175603231d1cd54e7d015e4304806776b5b..5ed98adf3a780fe13b049a5c74eb0cfd09ba3d62 100644 --- a/qt/scientific_interfaces/ISISReflectometry/GUI/Batch/AlgorithmProperties.h +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/Batch/AlgorithmProperties.h @@ -47,7 +47,7 @@ void update(std::string const &property, boost::optional<double> const &value, void updateFromMap(AlgorithmRuntimeProps &properties, std::map<std::string, std::string> const ¶meterMap); -std::string getOutputWorkspace(Mantid::API::IAlgorithm_sptr algorithm, +std::string getOutputWorkspace(const Mantid::API::IAlgorithm_sptr &algorithm, std::string const &property); template <typename VALUE_TYPE> diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/Batch/BatchJobAlgorithm.cpp b/qt/scientific_interfaces/ISISReflectometry/GUI/Batch/BatchJobAlgorithm.cpp index fe526791206f60ffd463b634a7ff09d9c743224c..8e2a949474d2ab67ce49aacbb32770352ea74079 100644 --- a/qt/scientific_interfaces/ISISReflectometry/GUI/Batch/BatchJobAlgorithm.cpp +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/Batch/BatchJobAlgorithm.cpp @@ -5,6 +5,9 @@ // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + #include "BatchJobAlgorithm.h" + +#include <utility> + #include "MantidAPI/IAlgorithm.h" namespace MantidQt { @@ -18,8 +21,8 @@ BatchJobAlgorithm::BatchJobAlgorithm( Mantid::API::IAlgorithm_sptr algorithm, MantidQt::API::ConfiguredAlgorithm::AlgorithmRuntimeProps properties, UpdateFunction updateFunction, Item *item) - : ConfiguredAlgorithm(algorithm, properties), m_item(item), - m_updateFunction(updateFunction) {} + : ConfiguredAlgorithm(std::move(algorithm), std::move(properties)), + m_item(item), m_updateFunction(updateFunction) {} Item *BatchJobAlgorithm::item() { return m_item; } diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/Batch/BatchJobAlgorithm.h b/qt/scientific_interfaces/ISISReflectometry/GUI/Batch/BatchJobAlgorithm.h index dc9aaff17ea5bef89723de8b4b742a7462d900bc..4799ae993fda8fcb122ed2a8d14ea244904572d4 100644 --- a/qt/scientific_interfaces/ISISReflectometry/GUI/Batch/BatchJobAlgorithm.h +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/Batch/BatchJobAlgorithm.h @@ -23,7 +23,7 @@ class MANTIDQT_ISISREFLECTOMETRY_DLL BatchJobAlgorithm : public IBatchJobAlgorithm, public MantidQt::API::ConfiguredAlgorithm { public: - using UpdateFunction = void (*)(Mantid::API::IAlgorithm_sptr algorithm, + using UpdateFunction = void (*)(const Mantid::API::IAlgorithm_sptr &algorithm, Item &item); BatchJobAlgorithm( diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/Batch/GroupProcessingAlgorithm.cpp b/qt/scientific_interfaces/ISISReflectometry/GUI/Batch/GroupProcessingAlgorithm.cpp index 10d4cf321f30b9b77e1226006445c4469097ee5d..168134898f8d225f5b04e1015f48e87499c7995e 100644 --- a/qt/scientific_interfaces/ISISReflectometry/GUI/Batch/GroupProcessingAlgorithm.cpp +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/Batch/GroupProcessingAlgorithm.cpp @@ -5,6 +5,9 @@ // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + #include "GroupProcessingAlgorithm.h" + +#include <utility> + #include "../../Reduction/Batch.h" #include "../../Reduction/Group.h" #include "AlgorithmProperties.h" @@ -58,9 +61,10 @@ void updateWorkspaceProperties(AlgorithmRuntimeProps &properties, AlgorithmProperties::update("OutputWorkspace", outputName, properties); } -void updateGroupFromOutputProperties(IAlgorithm_sptr algorithm, Item &group) { - auto const stitched = - AlgorithmProperties::getOutputWorkspace(algorithm, "OutputWorkspace"); +void updateGroupFromOutputProperties(const IAlgorithm_sptr &algorithm, + Item &group) { + auto const stitched = AlgorithmProperties::getOutputWorkspace( + std::move(algorithm), "OutputWorkspace"); group.setOutputNames(std::vector<std::string>{stitched}); } diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/Batch/QtBatchView.cpp b/qt/scientific_interfaces/ISISReflectometry/GUI/Batch/QtBatchView.cpp index cf2ffff5a62cadaf7be4d4de3ab1cf44029673a6..a9c9a13c6e4faa1f07cee87929c0bb43933c849e 100644 --- a/qt/scientific_interfaces/ISISReflectometry/GUI/Batch/QtBatchView.cpp +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/Batch/QtBatchView.cpp @@ -14,6 +14,7 @@ #include <QMessageBox> #include <QMetaType> +#include <utility> namespace MantidQt { namespace CustomInterfaces { @@ -105,17 +106,17 @@ void QtBatchView::onBatchComplete(bool error) { void QtBatchView::onBatchCancelled() { m_notifyee->notifyBatchCancelled(); } void QtBatchView::onAlgorithmStarted(API::IConfiguredAlgorithm_sptr algorithm) { - m_notifyee->notifyAlgorithmStarted(algorithm); + m_notifyee->notifyAlgorithmStarted(std::move(algorithm)); } void QtBatchView::onAlgorithmComplete( API::IConfiguredAlgorithm_sptr algorithm) { - m_notifyee->notifyAlgorithmComplete(algorithm); + m_notifyee->notifyAlgorithmComplete(std::move(algorithm)); } void QtBatchView::onAlgorithmError(API::IConfiguredAlgorithm_sptr algorithm, - std::string message) { - m_notifyee->notifyAlgorithmError(algorithm, message); + const std::string &message) { + m_notifyee->notifyAlgorithmError(std::move(algorithm), message); } std::unique_ptr<QtRunsView> QtBatchView::createRunsTab() { diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/Batch/QtBatchView.h b/qt/scientific_interfaces/ISISReflectometry/GUI/Batch/QtBatchView.h index 9ecf75f901650f85169f6ba0ef50a0e01ff6c440..a97d90a15de5d8d86b08f53ef6b0a468c63aa8d8 100644 --- a/qt/scientific_interfaces/ISISReflectometry/GUI/Batch/QtBatchView.h +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/Batch/QtBatchView.h @@ -47,7 +47,7 @@ private slots: void onAlgorithmStarted(MantidQt::API::IConfiguredAlgorithm_sptr algorithm); void onAlgorithmComplete(MantidQt::API::IConfiguredAlgorithm_sptr algorithm); void onAlgorithmError(MantidQt::API::IConfiguredAlgorithm_sptr algorithm, - std::string errorMessage); + const std::string &errorMessage); private: void initLayout(); diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/Batch/RowProcessingAlgorithm.cpp b/qt/scientific_interfaces/ISISReflectometry/GUI/Batch/RowProcessingAlgorithm.cpp index e02d207771a4c4feb8ce4b4937b6913d218fcea9..ad82098a4f180b18a3004c51b91b6cd705182301 100644 --- a/qt/scientific_interfaces/ISISReflectometry/GUI/Batch/RowProcessingAlgorithm.cpp +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/Batch/RowProcessingAlgorithm.cpp @@ -242,13 +242,14 @@ void updateEventProperties(AlgorithmRuntimeProps &properties, boost::apply_visitor(UpdateEventPropertiesVisitor(properties), slicing); } -boost::optional<double> getDouble(IAlgorithm_sptr algorithm, +boost::optional<double> getDouble(const IAlgorithm_sptr &algorithm, std::string const &property) { double result = algorithm->getProperty(property); return result; } -void updateRowFromOutputProperties(IAlgorithm_sptr algorithm, Item &item) { +void updateRowFromOutputProperties(const IAlgorithm_sptr &algorithm, + Item &item) { auto &row = dynamic_cast<Row &>(item); auto const iVsLam = AlgorithmProperties::getOutputWorkspace( diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/ExperimentOptionDefaults.cpp b/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/ExperimentOptionDefaults.cpp index 025d0812238ca6a9a37fc7bda4032baf2c797759..94441e5f3d46806702caf89b449397764ac32d48 100644 --- a/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/ExperimentOptionDefaults.cpp +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/ExperimentOptionDefaults.cpp @@ -5,6 +5,9 @@ // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + #include "ExperimentOptionDefaults.h" + +#include <utility> + #include "Common/OptionDefaults.h" #include "MantidAPI/AlgorithmManager.h" #include "PerThetaDefaultsTableValidator.h" @@ -24,7 +27,7 @@ std::string stringValueOrEmpty(boost::optional<double> value) { Experiment getExperimentDefaults(Mantid::Geometry::Instrument_const_sptr instrument) { - auto defaults = OptionDefaults(instrument); + auto defaults = OptionDefaults(std::move(instrument)); auto analysisMode = analysisModeFromString(defaults.getStringOrDefault( "AnalysisMode", "AnalysisMode", "PointDetectorAnalysis")); diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/PerThetaDefaultsTableValidationError.cpp b/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/PerThetaDefaultsTableValidationError.cpp index b939c91d707382c7e46becf825c342550567973e..b47755f1c0c42e70affc2c26fa67c3a4a8184879 100644 --- a/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/PerThetaDefaultsTableValidationError.cpp +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/PerThetaDefaultsTableValidationError.cpp @@ -5,6 +5,9 @@ // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + #include "PerThetaDefaultsTableValidationError.h" + +#include <utility> + #include "ThetaValuesValidationError.h" namespace MantidQt { namespace CustomInterfaces { @@ -15,7 +18,7 @@ PerThetaDefaultsTableValidationError::PerThetaDefaultsTableValidationError( std::vector<InvalidDefaultsError> validationErrors, boost::optional<ThetaValuesValidationError> fullTableError) : m_validationErrors(std::move(validationErrors)), - m_fullTableError(fullTableError) {} + m_fullTableError(std::move(fullTableError)) {} std::vector<InvalidDefaultsError> const & PerThetaDefaultsTableValidationError::errors() const { diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/QtExperimentView.cpp b/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/QtExperimentView.cpp index 4acf28d3cb1be47cc21d14010d8cc19837e357dd..bf8ae9f8a0122ace44b4458c1609b75ca2942588 100644 --- a/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/QtExperimentView.cpp +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/QtExperimentView.cpp @@ -11,6 +11,7 @@ #include <QMessageBox> #include <QScrollBar> #include <boost/algorithm/string/join.hpp> +#include <utility> namespace MantidQt { namespace CustomInterfaces { @@ -46,7 +47,7 @@ void showAsValid(QLineEdit &lineEdit) { * @param parent :: [input] The parent of this widget */ QtExperimentView::QtExperimentView( - Mantid::API::IAlgorithm_sptr algorithmForTooltips, QWidget *parent) + const Mantid::API::IAlgorithm_sptr &algorithmForTooltips, QWidget *parent) : QWidget(parent), m_stitchEdit(nullptr), m_deleteShortcut(), m_notifyee(nullptr), m_columnToolTips() { initLayout(algorithmForTooltips); @@ -98,7 +99,7 @@ void QtExperimentView::initLayout( m_ui.optionsTable); connect(m_deleteShortcut.get(), SIGNAL(activated()), this, SLOT(onRemovePerThetaDefaultsRequested())); - initOptionsTable(algorithmForTooltips); + initOptionsTable(std::move(algorithmForTooltips)); initFloodControls(); auto blacklist = @@ -116,7 +117,8 @@ void QtExperimentView::initLayout( } void QtExperimentView::initializeTableColumns( - QTableWidget &table, Mantid::API::IAlgorithm_sptr algorithmForTooltips) { + QTableWidget &table, + const Mantid::API::IAlgorithm_sptr &algorithmForTooltips) { for (auto column = 0; column < table.columnCount(); ++column) { // Get the tooltip for this column based on the algorithm property auto const propertyName = PerThetaDefaults::ColumnPropertyName[column]; @@ -159,14 +161,14 @@ void QtExperimentView::initializeTableRow( } void QtExperimentView::initOptionsTable( - Mantid::API::IAlgorithm_sptr algorithmForTooltips) { + const Mantid::API::IAlgorithm_sptr &algorithmForTooltips) { auto table = m_ui.optionsTable; // Set angle and scale columns to a small width so everything fits table->resizeColumnsToContents(); table->setColumnCount(PerThetaDefaults::OPTIONS_TABLE_COLUMN_COUNT); table->setRowCount(1); - initializeTableColumns(*table, algorithmForTooltips); + initializeTableColumns(*table, std::move(algorithmForTooltips)); initializeTableItems(*table); auto header = table->horizontalHeader(); @@ -254,13 +256,13 @@ void QtExperimentView::disableAll() { setEnabledStateForAllWidgets(false); } void QtExperimentView::enableAll() { setEnabledStateForAllWidgets(true); } void QtExperimentView::registerSettingsWidgets( - Mantid::API::IAlgorithm_sptr alg) { - registerExperimentSettingsWidgets(alg); + const Mantid::API::IAlgorithm_sptr &alg) { + registerExperimentSettingsWidgets(std::move(alg)); connectExperimentSettingsWidgets(); } void QtExperimentView::registerExperimentSettingsWidgets( - Mantid::API::IAlgorithm_sptr alg) { + const Mantid::API::IAlgorithm_sptr &alg) { registerSettingWidget(*m_ui.analysisModeComboBox, "AnalysisMode", alg); registerSettingWidget(*m_ui.startOverlapEdit, "StartOverlap", alg); registerSettingWidget(*m_ui.endOverlapEdit, "EndOverlap", alg); @@ -341,15 +343,15 @@ void QtExperimentView::disableIncludePartialBins() { } template <typename Widget> -void QtExperimentView::registerSettingWidget(Widget &widget, - std::string const &propertyName, - Mantid::API::IAlgorithm_sptr alg) { +void QtExperimentView::registerSettingWidget( + Widget &widget, std::string const &propertyName, + const Mantid::API::IAlgorithm_sptr &alg) { setToolTipAsPropertyDocumentation(widget, propertyName, alg); } void QtExperimentView::setToolTipAsPropertyDocumentation( QWidget &widget, std::string const &propertyName, - Mantid::API::IAlgorithm_sptr alg) { + const Mantid::API::IAlgorithm_sptr &alg) { widget.setToolTip(QString::fromStdString( alg->getPointerToProperty(propertyName)->documentation())); } diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/QtExperimentView.h b/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/QtExperimentView.h index 386b2e3cd9c630454710c977c5f9dd80d9087a00..285ffe9cf06bc850caee82b2225658e193954a85 100644 --- a/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/QtExperimentView.h +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/QtExperimentView.h @@ -25,7 +25,7 @@ class MANTIDQT_ISISREFLECTOMETRY_DLL QtExperimentView : public QWidget, public IExperimentView { Q_OBJECT public: - QtExperimentView(Mantid::API::IAlgorithm_sptr algorithmForTooltips, + QtExperimentView(const Mantid::API::IAlgorithm_sptr &algorithmForTooltips, QWidget *parent = nullptr); void subscribe(ExperimentViewSubscriber *notifyee) override; void connectExperimentSettingsWidgets() override; @@ -114,9 +114,9 @@ public slots: void onPerAngleDefaultsChanged(int row, int column); private: - void - initializeTableColumns(QTableWidget &table, - Mantid::API::IAlgorithm_sptr algorithmForTooltips); + void initializeTableColumns( + QTableWidget &table, + const Mantid::API::IAlgorithm_sptr &algorithmForTooltips); void initializeTableItems(QTableWidget &table); void initializeTableRow(QTableWidget &table, int row); void initializeTableRow(QTableWidget &table, int row, @@ -127,17 +127,20 @@ private: /// Initialise the interface void initLayout(Mantid::API::IAlgorithm_sptr algorithmForTooltips); - void initOptionsTable(Mantid::API::IAlgorithm_sptr algorithmForTooltips); + void + initOptionsTable(const Mantid::API::IAlgorithm_sptr &algorithmForTooltips); void initFloodControls(); - void registerSettingsWidgets(Mantid::API::IAlgorithm_sptr alg); - void registerExperimentSettingsWidgets(Mantid::API::IAlgorithm_sptr alg); - void setToolTipAsPropertyDocumentation(QWidget &widget, - std::string const &propertyName, - Mantid::API::IAlgorithm_sptr alg); + void registerSettingsWidgets(const Mantid::API::IAlgorithm_sptr &alg); + void + registerExperimentSettingsWidgets(const Mantid::API::IAlgorithm_sptr &alg); + void + setToolTipAsPropertyDocumentation(QWidget &widget, + std::string const &propertyName, + const Mantid::API::IAlgorithm_sptr &alg); template <typename Widget> void registerSettingWidget(Widget &widget, std::string const &propertyName, - Mantid::API::IAlgorithm_sptr alg); + const Mantid::API::IAlgorithm_sptr &alg); void connectSettingsChange(QLineEdit &edit); void connectSettingsChange(QComboBox &edit); void connectSettingsChange(QCheckBox &edit); diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/Instrument/InstrumentOptionDefaults.cpp b/qt/scientific_interfaces/ISISReflectometry/GUI/Instrument/InstrumentOptionDefaults.cpp index d1a7f3eed32e7a0b29d7be3ce081ee05ea933a9e..73d3c4b5ecfb954971b4c2893bdd176914619766 100644 --- a/qt/scientific_interfaces/ISISReflectometry/GUI/Instrument/InstrumentOptionDefaults.cpp +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/Instrument/InstrumentOptionDefaults.cpp @@ -5,6 +5,9 @@ // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + #include "InstrumentOptionDefaults.h" + +#include <utility> + #include "Common/OptionDefaults.h" #include "MantidAPI/AlgorithmManager.h" #include "Reduction/Instrument.h" @@ -19,7 +22,7 @@ Mantid::Kernel::Logger g_log("Reflectometry GUI"); Instrument getInstrumentDefaults(Mantid::Geometry::Instrument_const_sptr instrument) { - auto defaults = OptionDefaults(instrument); + auto defaults = OptionDefaults(std::move(instrument)); auto wavelengthRange = RangeInLambda(defaults.getValue<double>("WavelengthMin", "LambdaMin"), diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/Instrument/QtInstrumentView.cpp b/qt/scientific_interfaces/ISISReflectometry/GUI/Instrument/QtInstrumentView.cpp index a527c694704ff299c39cedb6314ded0aa4d111e1..7fd4fac9f4b24406af044d5d034b1b96022b5c51 100644 --- a/qt/scientific_interfaces/ISISReflectometry/GUI/Instrument/QtInstrumentView.cpp +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/Instrument/QtInstrumentView.cpp @@ -10,6 +10,7 @@ #include <QMessageBox> #include <QScrollBar> #include <boost/algorithm/string/join.hpp> +#include <utility> namespace MantidQt { namespace CustomInterfaces { @@ -36,7 +37,7 @@ QtInstrumentView::QtInstrumentView( Mantid::API::IAlgorithm_sptr algorithmForTooltips, QWidget *parent) : QWidget(parent) { initLayout(); - registerSettingsWidgets(algorithmForTooltips); + registerSettingsWidgets(std::move(algorithmForTooltips)); } void QtInstrumentView::subscribe(InstrumentViewSubscriber *notifyee) { @@ -132,12 +133,12 @@ void QtInstrumentView::disableDetectorCorrectionType() { } void QtInstrumentView::registerSettingsWidgets( - Mantid::API::IAlgorithm_sptr alg) { - registerInstrumentSettingsWidgets(alg); + const Mantid::API::IAlgorithm_sptr &alg) { + registerInstrumentSettingsWidgets(std::move(alg)); } void QtInstrumentView::registerInstrumentSettingsWidgets( - Mantid::API::IAlgorithm_sptr alg) { + const Mantid::API::IAlgorithm_sptr &alg) { registerSettingWidget(*m_ui.intMonCheckBox, "NormalizeByIntegratedMonitors", alg); registerSettingWidget(*m_ui.monIntMinEdit, "MonitorIntegrationWavelengthMin", @@ -184,16 +185,16 @@ void QtInstrumentView::disconnectInstrumentSettingsWidgets() { } template <typename Widget> -void QtInstrumentView::registerSettingWidget(Widget &widget, - std::string const &propertyName, - Mantid::API::IAlgorithm_sptr alg) { +void QtInstrumentView::registerSettingWidget( + Widget &widget, std::string const &propertyName, + const Mantid::API::IAlgorithm_sptr &alg) { connectSettingsChange(widget); setToolTipAsPropertyDocumentation(widget, propertyName, alg); } void QtInstrumentView::setToolTipAsPropertyDocumentation( QWidget &widget, std::string const &propertyName, - Mantid::API::IAlgorithm_sptr alg) { + const Mantid::API::IAlgorithm_sptr &alg) { widget.setToolTip(QString::fromStdString( alg->getPointerToProperty(propertyName)->documentation())); } diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/Instrument/QtInstrumentView.h b/qt/scientific_interfaces/ISISReflectometry/GUI/Instrument/QtInstrumentView.h index 52cd251212221c7e7d453bfed417ec93289f9dba..6735bcf0fffd75c0b83a894bc30c19d8453ac9ab 100644 --- a/qt/scientific_interfaces/ISISReflectometry/GUI/Instrument/QtInstrumentView.h +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/Instrument/QtInstrumentView.h @@ -77,15 +77,17 @@ private: /// Initialise the interface void initLayout(); - void registerSettingsWidgets(Mantid::API::IAlgorithm_sptr alg); - void registerInstrumentSettingsWidgets(Mantid::API::IAlgorithm_sptr alg); - void setToolTipAsPropertyDocumentation(QWidget &widget, - std::string const &propertyName, - Mantid::API::IAlgorithm_sptr alg); + void registerSettingsWidgets(const Mantid::API::IAlgorithm_sptr &alg); + void + registerInstrumentSettingsWidgets(const Mantid::API::IAlgorithm_sptr &alg); + void + setToolTipAsPropertyDocumentation(QWidget &widget, + std::string const &propertyName, + const Mantid::API::IAlgorithm_sptr &alg); template <typename Widget> void registerSettingWidget(Widget &widget, std::string const &propertyName, - Mantid::API::IAlgorithm_sptr alg); + const Mantid::API::IAlgorithm_sptr &alg); void connectSettingsChange(QLineEdit &edit); void connectSettingsChange(QComboBox &edit); void connectSettingsChange(QCheckBox &edit); diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/Runs/QtCatalogSearcher.cpp b/qt/scientific_interfaces/ISISReflectometry/GUI/Runs/QtCatalogSearcher.cpp index d6facb1a02f61572bfd43b776cd2e37076252002..a270d106334b2257eb6e7bdb0782ef2dd51f6895 100644 --- a/qt/scientific_interfaces/ISISReflectometry/GUI/Runs/QtCatalogSearcher.cpp +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/Runs/QtCatalogSearcher.cpp @@ -21,7 +21,8 @@ namespace CustomInterfaces { namespace ISISReflectometry { namespace { // unnamed -void removeResultsWithoutFilenameExtension(ITableWorkspace_sptr results) { +void removeResultsWithoutFilenameExtension( + const ITableWorkspace_sptr &results) { std::set<size_t> toRemove; for (size_t i = 0; i < results->rowCount(); ++i) { std::string &run = results->String(i, 0); diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/Runs/QtRunsView.cpp b/qt/scientific_interfaces/ISISReflectometry/GUI/Runs/QtRunsView.cpp index d654e5187dbb947b7a44f1bbbc8e592083820ca1..2ac57dcdbe5646904cf664d81e3bbfc4924dfe88 100644 --- a/qt/scientific_interfaces/ISISReflectometry/GUI/Runs/QtRunsView.cpp +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/Runs/QtRunsView.cpp @@ -27,7 +27,8 @@ using namespace MantidQt::Icons; * @param parent :: The parent of this view * @param makeRunsTableView :: The factory for the RunsTableView. */ -QtRunsView::QtRunsView(QWidget *parent, RunsTableViewFactory makeRunsTableView) +QtRunsView::QtRunsView(QWidget *parent, + const RunsTableViewFactory &makeRunsTableView) : MantidWidget(parent), m_notifyee(nullptr), m_timerNotifyee(nullptr), m_searchNotifyee(nullptr), m_searchModel(), m_tableView(makeRunsTableView()), m_timer() { diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/Runs/QtRunsView.h b/qt/scientific_interfaces/ISISReflectometry/GUI/Runs/QtRunsView.h index a9b16bbe3837d5e4882efd3e3f4752bb0fc10192..9f50d4c262b6404cfc19ff10920032e95dd59c73 100644 --- a/qt/scientific_interfaces/ISISReflectometry/GUI/Runs/QtRunsView.h +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/Runs/QtRunsView.h @@ -33,7 +33,7 @@ class MANTIDQT_ISISREFLECTOMETRY_DLL QtRunsView public IRunsView { Q_OBJECT public: - QtRunsView(QWidget *parent, RunsTableViewFactory makeView); + QtRunsView(QWidget *parent, const RunsTableViewFactory &makeView); void subscribe(RunsViewSubscriber *notifyee) override; void subscribeTimer(RunsViewTimerSubscriber *notifyee) override; diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/RunsTable/RegexRowFilter.cpp b/qt/scientific_interfaces/ISISReflectometry/GUI/RunsTable/RegexRowFilter.cpp index b242bc70f8c9a4ee5cb8367f97b8dc58da29527f..a6b08d7016a918c4814a8849595f8fe12a9ec828 100644 --- a/qt/scientific_interfaces/ISISReflectometry/GUI/RunsTable/RegexRowFilter.cpp +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/RunsTable/RegexRowFilter.cpp @@ -13,7 +13,7 @@ namespace ISISReflectometry { using MantidQt::MantidWidgets::Batch::IJobTreeView; using MantidQt::MantidWidgets::Batch::RowLocation; -RegexFilter::RegexFilter(boost::regex regex, IJobTreeView const &view, +RegexFilter::RegexFilter(const boost::regex ®ex, IJobTreeView const &view, ReductionJobs const &jobs) : m_filter(std::move(regex)), m_view(view), m_jobs(jobs) {} diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/RunsTable/RegexRowFilter.h b/qt/scientific_interfaces/ISISReflectometry/GUI/RunsTable/RegexRowFilter.h index c95a22ef720983a797c0665e213c66318098a68a..6c5e45643148783afe999e344e38784f9b626ded 100644 --- a/qt/scientific_interfaces/ISISReflectometry/GUI/RunsTable/RegexRowFilter.h +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/RunsTable/RegexRowFilter.h @@ -19,7 +19,7 @@ namespace ISISReflectometry { class RegexFilter : public MantidQt::MantidWidgets::Batch::RowPredicate { public: - RegexFilter(boost::regex regex, + RegexFilter(const boost::regex ®ex, MantidQt::MantidWidgets::Batch::IJobTreeView const &view, ReductionJobs const &jobs); bool rowMeetsCriteria( diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/Save/AsciiSaver.cpp b/qt/scientific_interfaces/ISISReflectometry/GUI/Save/AsciiSaver.cpp index cd0148060e31625b0721f32c3cff0be10e566699..80c8a48e4d11b5f5a6bef22ce31d47a5cb75821c 100644 --- a/qt/scientific_interfaces/ISISReflectometry/GUI/Save/AsciiSaver.cpp +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/Save/AsciiSaver.cpp @@ -11,6 +11,9 @@ #include "MantidAPI/WorkspaceGroup.h" #include <Poco/File.h> #include <Poco/Path.h> + +#include <utility> + namespace MantidQt { namespace CustomInterfaces { namespace ISISReflectometry { @@ -65,7 +68,7 @@ bool AsciiSaver::isValidSaveDirectory(std::string const &path) const { namespace { template <typename T> -void setPropertyIfSupported(Mantid::API::IAlgorithm_sptr alg, +void setPropertyIfSupported(const Mantid::API::IAlgorithm_sptr &alg, std::string const &propertyName, T const &value) { if (alg->existsProperty(propertyName)) alg->setProperty(propertyName, value); @@ -93,7 +96,7 @@ AsciiSaver::workspace(std::string const &workspaceName) const { Mantid::API::IAlgorithm_sptr AsciiSaver::setUpSaveAlgorithm(std::string const &saveDirectory, - Mantid::API::Workspace_sptr workspace, + const Mantid::API::Workspace_sptr &workspace, std::vector<std::string> const &logParameters, FileFormatOptions const &fileFormat) const { auto saveAlg = algorithmForFormat(fileFormat.format()); @@ -112,12 +115,12 @@ AsciiSaver::setUpSaveAlgorithm(std::string const &saveDirectory, return saveAlg; } -void AsciiSaver::save(Mantid::API::Workspace_sptr workspace, +void AsciiSaver::save(const Mantid::API::Workspace_sptr &workspace, std::string const &saveDirectory, std::vector<std::string> const &logParameters, FileFormatOptions const &fileFormat) const { - auto alg = - setUpSaveAlgorithm(saveDirectory, workspace, logParameters, fileFormat); + auto alg = setUpSaveAlgorithm(saveDirectory, std::move(workspace), + logParameters, fileFormat); alg->execute(); } diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/Save/AsciiSaver.h b/qt/scientific_interfaces/ISISReflectometry/GUI/Save/AsciiSaver.h index 1f028e4b52ad685980e31470c0280622ad635d5c..695674e61efe5403d38ae3615084f919e0a5224c 100644 --- a/qt/scientific_interfaces/ISISReflectometry/GUI/Save/AsciiSaver.h +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/Save/AsciiSaver.h @@ -28,7 +28,7 @@ public: private: Mantid::API::IAlgorithm_sptr setUpSaveAlgorithm(std::string const &saveDirectory, - Mantid::API::Workspace_sptr workspace, + const Mantid::API::Workspace_sptr &workspace, std::vector<std::string> const &logParameters, FileFormatOptions const &fileFormat) const; @@ -38,7 +38,7 @@ private: std::string const &extension) const; Mantid::API::Workspace_sptr workspace(std::string const &workspaceName) const; - void save(Mantid::API::Workspace_sptr workspace, + void save(const Mantid::API::Workspace_sptr &workspace, std::string const &saveDirectory, std::vector<std::string> const &logParameters, FileFormatOptions const &fileFormat) const; diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/Save/SavePresenter.cpp b/qt/scientific_interfaces/ISISReflectometry/GUI/Save/SavePresenter.cpp index add0b4c9e071540d20f17b7abc54188a8b34016f..1c6e779087e6e95c4cb848113eb3f6bb377260e8 100644 --- a/qt/scientific_interfaces/ISISReflectometry/GUI/Save/SavePresenter.cpp +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/Save/SavePresenter.cpp @@ -135,7 +135,7 @@ void SavePresenter::filterWorkspaceNames() { boost::regex rgx(filter); it = std::copy_if( wsNames.begin(), wsNames.end(), validNames.begin(), - [rgx](std::string s) { return boost::regex_search(s, rgx); }); + [rgx](const std::string &s) { return boost::regex_search(s, rgx); }); m_view->showFilterEditValid(); } catch (boost::regex_error &) { m_view->showFilterEditInvalid(); @@ -143,7 +143,7 @@ void SavePresenter::filterWorkspaceNames() { } else { // Otherwise simply add names where the filter string is found in it = std::copy_if(wsNames.begin(), wsNames.end(), validNames.begin(), - [filter](std::string s) { + [filter](const std::string &s) { return s.find(filter) != std::string::npos; }); } diff --git a/qt/scientific_interfaces/ISISReflectometry/Reduction/FloodCorrections.cpp b/qt/scientific_interfaces/ISISReflectometry/Reduction/FloodCorrections.cpp index 4f5b0503d675cd600ac468e28f1949774d8f2f76..aba3620fb54f210545f843e55ec2a7cc43e414b3 100644 --- a/qt/scientific_interfaces/ISISReflectometry/Reduction/FloodCorrections.cpp +++ b/qt/scientific_interfaces/ISISReflectometry/Reduction/FloodCorrections.cpp @@ -5,13 +5,16 @@ // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + #include "FloodCorrections.h" + +#include <utility> + namespace MantidQt { namespace CustomInterfaces { namespace ISISReflectometry { FloodCorrections::FloodCorrections(FloodCorrectionType correctionType, boost::optional<std::string> workspace) - : m_correctionType(correctionType), m_workspace(workspace) {} + : m_correctionType(correctionType), m_workspace(std::move(workspace)) {} FloodCorrectionType FloodCorrections::correctionType() const { return m_correctionType; diff --git a/qt/scientific_interfaces/ISISReflectometry/Reduction/MonitorCorrections.cpp b/qt/scientific_interfaces/ISISReflectometry/Reduction/MonitorCorrections.cpp index d4efc4bfca57f8ba2a27b692a91df2edd955ddba..a4b931cb8395ae77b65788a843cb26a574a36a0c 100644 --- a/qt/scientific_interfaces/ISISReflectometry/Reduction/MonitorCorrections.cpp +++ b/qt/scientific_interfaces/ISISReflectometry/Reduction/MonitorCorrections.cpp @@ -5,6 +5,9 @@ // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + #include "MonitorCorrections.h" + +#include <utility> + namespace MantidQt { namespace CustomInterfaces { namespace ISISReflectometry { @@ -14,7 +17,8 @@ MonitorCorrections::MonitorCorrections( boost::optional<RangeInLambda> backgroundRange, boost::optional<RangeInLambda> integralRange) : m_monitorIndex(monitorIndex), m_integrate(integrate), - m_backgroundRange(backgroundRange), m_integralRange(integralRange) {} + m_backgroundRange(std::move(backgroundRange)), + m_integralRange(std::move(integralRange)) {} size_t MonitorCorrections::monitorIndex() const { return m_monitorIndex; } diff --git a/qt/scientific_interfaces/ISISReflectometry/Reduction/RangeInQ.cpp b/qt/scientific_interfaces/ISISReflectometry/Reduction/RangeInQ.cpp index 83d975eb03331b2a9cecb50801b5837533118fb5..b629cdcb190fdb99d9bf264052a1fd0657f6eac9 100644 --- a/qt/scientific_interfaces/ISISReflectometry/Reduction/RangeInQ.cpp +++ b/qt/scientific_interfaces/ISISReflectometry/Reduction/RangeInQ.cpp @@ -6,13 +6,15 @@ // SPDX - License - Identifier: GPL - 3.0 + #include "RangeInQ.h" #include <cassert> +#include <utility> + namespace MantidQt { namespace CustomInterfaces { namespace ISISReflectometry { RangeInQ::RangeInQ(boost::optional<double> min, boost::optional<double> step, boost::optional<double> max) - : m_min(min), m_step(step), m_max(max) { + : m_min(std::move(min)), m_step(std::move(step)), m_max(std::move(max)) { assert(!(m_min.is_initialized() && m_max.is_initialized() && m_max < m_min)); } diff --git a/qt/scientific_interfaces/ISISReflectometry/Reduction/ReductionJobs.cpp b/qt/scientific_interfaces/ISISReflectometry/Reduction/ReductionJobs.cpp index 656088bcba85e1fce999a62ea581719eea511ca8..a3d92ecaeb706a968eeb269a220807ebede058bc 100644 --- a/qt/scientific_interfaces/ISISReflectometry/Reduction/ReductionJobs.cpp +++ b/qt/scientific_interfaces/ISISReflectometry/Reduction/ReductionJobs.cpp @@ -288,7 +288,7 @@ ReductionJobs::getItemWithOutputWorkspaceOrNone(std::string const &wsName) { } Group const &ReductionJobs::getGroupFromPath( - const MantidWidgets::Batch::RowLocation rowLocation) const { + const MantidWidgets::Batch::RowLocation &rowLocation) const { if (isGroupLocation(rowLocation)) { return groups()[groupOf(rowLocation)]; } else { @@ -297,7 +297,7 @@ Group const &ReductionJobs::getGroupFromPath( } boost::optional<Row> const &ReductionJobs::getRowFromPath( - const MantidWidgets::Batch::RowLocation rowLocation) const { + const MantidWidgets::Batch::RowLocation &rowLocation) const { if (isRowLocation(rowLocation)) { return groups()[groupOf(rowLocation)].rows()[rowOf(rowLocation)]; } else { @@ -306,7 +306,7 @@ boost::optional<Row> const &ReductionJobs::getRowFromPath( } bool ReductionJobs::validItemAtPath( - const MantidWidgets::Batch::RowLocation rowLocation) const { + const MantidWidgets::Batch::RowLocation &rowLocation) const { if (isGroupLocation(rowLocation)) return true; @@ -314,7 +314,7 @@ bool ReductionJobs::validItemAtPath( } Item const &ReductionJobs::getItemFromPath( - const MantidWidgets::Batch::RowLocation rowLocation) const { + const MantidWidgets::Batch::RowLocation &rowLocation) const { if (isGroupLocation(rowLocation)) { return getGroupFromPath(rowLocation); } else { diff --git a/qt/scientific_interfaces/ISISReflectometry/Reduction/ReductionJobs.h b/qt/scientific_interfaces/ISISReflectometry/Reduction/ReductionJobs.h index 3f2c4ea7a69aa6af6a9f0035e2f6b70838e03ad0..030fb2033b20e31b2a2ee5d5e24008bce43a530e 100644 --- a/qt/scientific_interfaces/ISISReflectometry/Reduction/ReductionJobs.h +++ b/qt/scientific_interfaces/ISISReflectometry/Reduction/ReductionJobs.h @@ -47,13 +47,13 @@ public: getItemWithOutputWorkspaceOrNone(std::string const &wsName); bool - validItemAtPath(const MantidWidgets::Batch::RowLocation rowLocation) const; + validItemAtPath(const MantidWidgets::Batch::RowLocation &rowLocation) const; Group const & - getGroupFromPath(const MantidWidgets::Batch::RowLocation path) const; + getGroupFromPath(const MantidWidgets::Batch::RowLocation &path) const; boost::optional<Row> const & - getRowFromPath(const MantidWidgets::Batch::RowLocation path) const; + getRowFromPath(const MantidWidgets::Batch::RowLocation &path) const; Item const & - getItemFromPath(const MantidWidgets::Batch::RowLocation path) const; + getItemFromPath(const MantidWidgets::Batch::RowLocation &path) const; private: std::vector<Group> m_groups; diff --git a/qt/scientific_interfaces/ISISReflectometry/Reduction/ReductionWorkspaces.cpp b/qt/scientific_interfaces/ISISReflectometry/Reduction/ReductionWorkspaces.cpp index 414351f7c11efacc9b4018df469b183bbf54ed48..fff3cc9003ec1f2fb4c0710ab63f60fa8084b359 100644 --- a/qt/scientific_interfaces/ISISReflectometry/Reduction/ReductionWorkspaces.cpp +++ b/qt/scientific_interfaces/ISISReflectometry/Reduction/ReductionWorkspaces.cpp @@ -5,6 +5,9 @@ // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + #include "ReductionWorkspaces.h" + +#include <utility> + #include "Common/Map.h" namespace MantidQt { @@ -16,7 +19,7 @@ ReductionWorkspaces::ReductionWorkspaces( // cppcheck-suppress passedByValue TransmissionRunPair transmissionRuns) : m_inputRunNumbers(std::move(inputRunNumbers)), - m_transmissionRuns(transmissionRuns), m_iVsLambda(), m_iVsQ(), + m_transmissionRuns(std::move(transmissionRuns)), m_iVsLambda(), m_iVsQ(), m_iVsQBinned() {} std::vector<std::string> const &ReductionWorkspaces::inputRunNumbers() const { diff --git a/qt/scientific_interfaces/ISISReflectometry/Reduction/ValidatePerThetaDefaults.cpp b/qt/scientific_interfaces/ISISReflectometry/Reduction/ValidatePerThetaDefaults.cpp index f48a38c25fc6017de828d77548cd8f27ebb227dc..812ef2fdcabe79bf8dd4a59eb9342d83c519cb48 100644 --- a/qt/scientific_interfaces/ISISReflectometry/Reduction/ValidatePerThetaDefaults.cpp +++ b/qt/scientific_interfaces/ISISReflectometry/Reduction/ValidatePerThetaDefaults.cpp @@ -28,7 +28,7 @@ public: return boost::none; } - boost::optional<T> operator()(std::vector<int> errorColumns) const { + boost::optional<T> operator()(const std::vector<int> &errorColumns) const { std::transform(errorColumns.cbegin(), errorColumns.cend(), std::back_inserter(m_invalidParams), [this](int column) -> int { return m_baseColumn + column; }); diff --git a/qt/scientific_interfaces/ISISReflectometry/Reduction/ValidateRow.cpp b/qt/scientific_interfaces/ISISReflectometry/Reduction/ValidateRow.cpp index 1e08a461995d8c453d2a2965d81682738770f394..02edeee301e441e780f1c877f19b2c975f059c8c 100644 --- a/qt/scientific_interfaces/ISISReflectometry/Reduction/ValidateRow.cpp +++ b/qt/scientific_interfaces/ISISReflectometry/Reduction/ValidateRow.cpp @@ -44,7 +44,7 @@ public: return boost::none; } - boost::optional<T> operator()(std::vector<int> errorColumns) const { + boost::optional<T> operator()(const std::vector<int> &errorColumns) const { std::transform(errorColumns.cbegin(), errorColumns.cend(), std::back_inserter(m_invalidParams), [this](int column) -> int { return m_baseColumn + column; }); diff --git a/qt/scientific_interfaces/ISISReflectometry/TestHelpers/ModelCreationHelper.cpp b/qt/scientific_interfaces/ISISReflectometry/TestHelpers/ModelCreationHelper.cpp index 5b0c880b25358083f587512b709f77787335c170..27dc770b73f52e0b09468b276ba172badcbc591c 100644 --- a/qt/scientific_interfaces/ISISReflectometry/TestHelpers/ModelCreationHelper.cpp +++ b/qt/scientific_interfaces/ISISReflectometry/TestHelpers/ModelCreationHelper.cpp @@ -5,6 +5,9 @@ // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + #include "ModelCreationHelper.h" + +#include <utility> + #include "../../ISISReflectometry/Reduction/Batch.h" namespace MantidQt { @@ -55,7 +58,8 @@ Row makeRow(std::string const &run, double theta, std::string const &trans1, boost::optional<double> scale, ReductionOptionsMap const &optionsMap) { return Row({run}, theta, TransmissionRunPair({trans1, trans2}), - RangeInQ(qMin, qMax, qStep), scale, optionsMap, + RangeInQ(std::move(qMin), std::move(qMax), std::move(qStep)), + std::move(scale), optionsMap, ReductionWorkspaces({run}, TransmissionRunPair({trans1, trans2}))); } diff --git a/qt/scientific_interfaces/ISISSANS/SANSAddFiles.cpp b/qt/scientific_interfaces/ISISSANS/SANSAddFiles.cpp index f11b53d9ef656853b5a5f8be7e5a0190d8779b2e..7f050f86aac28811a0514a3811ea3c9e8f391e08 100644 --- a/qt/scientific_interfaces/ISISSANS/SANSAddFiles.cpp +++ b/qt/scientific_interfaces/ISISSANS/SANSAddFiles.cpp @@ -175,7 +175,7 @@ QListWidgetItem *SANSAddFiles::insertListFront(const QString &text) { * that users see * @param dir :: full path of the output directory */ -void SANSAddFiles::setOutDir(std::string dir) { +void SANSAddFiles::setOutDir(const std::string &dir) { m_outDir = QString::fromStdString(dir); m_SANSForm->summedPath_lb->setText(OUT_MSG + m_outDir); } @@ -521,8 +521,10 @@ bool SANSAddFiles::checkValidityTimeShiftsForAddedEventFiles() { * @param lineEditText :: text for the line edit field * @param enabled :: if the input should be enabled. */ -void SANSAddFiles::setHistogramUiLogic(QString label, QString toolTip, - QString lineEditText, bool enabled) { +void SANSAddFiles::setHistogramUiLogic(const QString &label, + const QString &toolTip, + const QString &lineEditText, + bool enabled) { // Line edit field m_SANSForm->eventToHistBinning->setText(lineEditText); m_SANSForm->eventToHistBinning->setToolTip(toolTip); diff --git a/qt/scientific_interfaces/ISISSANS/SANSAddFiles.h b/qt/scientific_interfaces/ISISSANS/SANSAddFiles.h index a03ad3a03f2381778e6991a20d5852188e95d6c2..ad16cc7c93d7600ef8f4ef519a052205d513a1f8 100644 --- a/qt/scientific_interfaces/ISISSANS/SANSAddFiles.h +++ b/qt/scientific_interfaces/ISISSANS/SANSAddFiles.h @@ -55,8 +55,8 @@ private: /// Text for tooltip for save event data QString m_saveEventDataToolTip; /// Set the bin field - void setHistogramUiLogic(QString label, QString toolTip, QString lineEditText, - bool enabled); + void setHistogramUiLogic(const QString &label, const QString &toolTip, + const QString &lineEditText, bool enabled); /// Set the histo gram input enabled or disabled void setInputEnabled(bool enabled); /// Create Python string list @@ -69,7 +69,7 @@ private: QListWidgetItem *insertListFront(const QString &text); void changeOutputDir(Mantid::Kernel::ConfigValChangeNotification_ptr pDirInfo); - void setOutDir(std::string dir); + void setOutDir(const std::string &dir); bool checkValidityTimeShiftsForAddedEventFiles(); private slots: diff --git a/qt/scientific_interfaces/ISISSANS/SANSBackgroundCorrectionSettings.cpp b/qt/scientific_interfaces/ISISSANS/SANSBackgroundCorrectionSettings.cpp index 59929314117a4220628c31b52c070e01a62d5f44..e0aeb2f9f73de9a4b74d615c33760315fef4d429 100644 --- a/qt/scientific_interfaces/ISISSANS/SANSBackgroundCorrectionSettings.cpp +++ b/qt/scientific_interfaces/ISISSANS/SANSBackgroundCorrectionSettings.cpp @@ -9,7 +9,8 @@ namespace MantidQt { namespace CustomInterfaces { SANSBackgroundCorrectionSettings::SANSBackgroundCorrectionSettings( - QString runNumber, bool useMean, bool useMon, QString monNumber) + const QString &runNumber, bool useMean, bool useMon, + const QString &monNumber) : m_runNumber(runNumber), m_useMean(useMean), m_useMon(useMon), m_monNumber(monNumber) { hasValidSettings(); diff --git a/qt/scientific_interfaces/ISISSANS/SANSBackgroundCorrectionSettings.h b/qt/scientific_interfaces/ISISSANS/SANSBackgroundCorrectionSettings.h index 4614ee57d50cf7979e09aa40f4cb7eeeb7b6e56c..546b9a0b9d8953430e12230d9c48e1ba650c18a7 100644 --- a/qt/scientific_interfaces/ISISSANS/SANSBackgroundCorrectionSettings.h +++ b/qt/scientific_interfaces/ISISSANS/SANSBackgroundCorrectionSettings.h @@ -19,8 +19,8 @@ the SANSBackgroundCorrectionWidget */ class MANTIDQT_ISISSANS_DLL SANSBackgroundCorrectionSettings { public: - SANSBackgroundCorrectionSettings(QString runNumber, bool useMean, bool useMon, - QString monNumber); + SANSBackgroundCorrectionSettings(const QString &runNumber, bool useMean, + bool useMon, const QString &monNumber); bool hasValidSettings(); diff --git a/qt/scientific_interfaces/ISISSANS/SANSBackgroundCorrectionWidget.cpp b/qt/scientific_interfaces/ISISSANS/SANSBackgroundCorrectionWidget.cpp index c9905f1a26624b9813d7cea037f49f6a3aa804d4..2120d89456deaec65aae556526aacc15b9531ef1 100644 --- a/qt/scientific_interfaces/ISISSANS/SANSBackgroundCorrectionWidget.cpp +++ b/qt/scientific_interfaces/ISISSANS/SANSBackgroundCorrectionWidget.cpp @@ -16,7 +16,8 @@ namespace { Mantid::Kernel::Logger g_log("SANSBackgroundCorrectionWidget"); bool hasRunNumber( - MantidQt::CustomInterfaces::SANSBackgroundCorrectionSettings setting) { + const MantidQt::CustomInterfaces::SANSBackgroundCorrectionSettings + &setting) { auto hasNumber = true; if (setting.getRunNumber().isEmpty()) { hasNumber = false; @@ -49,7 +50,7 @@ SANSBackgroundCorrectionWidget::SANSBackgroundCorrectionWidget(QWidget *parent) * want */ void SANSBackgroundCorrectionWidget::setDarkRunSettingForTimeDetectors( - SANSBackgroundCorrectionSettings setting) { + const SANSBackgroundCorrectionSettings &setting) { if (!hasRunNumber(setting)) { return; @@ -73,7 +74,7 @@ void SANSBackgroundCorrectionWidget::setDarkRunSettingForTimeDetectors( * want */ void SANSBackgroundCorrectionWidget::setDarkRunSettingForTimeMonitors( - SANSBackgroundCorrectionSettings setting) { + const SANSBackgroundCorrectionSettings &setting) { if (!hasRunNumber(setting)) { return; } @@ -97,7 +98,7 @@ void SANSBackgroundCorrectionWidget::setDarkRunSettingForTimeMonitors( * want */ void SANSBackgroundCorrectionWidget::setDarkRunSettingForUampDetectors( - SANSBackgroundCorrectionSettings setting) { + const SANSBackgroundCorrectionSettings &setting) { if (!hasRunNumber(setting)) { return; } @@ -118,7 +119,7 @@ void SANSBackgroundCorrectionWidget::setDarkRunSettingForUampDetectors( * want */ void SANSBackgroundCorrectionWidget::setDarkRunSettingForUampMonitors( - SANSBackgroundCorrectionSettings setting) { + const SANSBackgroundCorrectionSettings &setting) { if (!hasRunNumber(setting)) { return; } diff --git a/qt/scientific_interfaces/ISISSANS/SANSBackgroundCorrectionWidget.h b/qt/scientific_interfaces/ISISSANS/SANSBackgroundCorrectionWidget.h index 52df3b2bd1c8aa580bfb5327bafca4f69ba89c24..dfe8a3550d29250144723b7596a7a8ad010d238a 100644 --- a/qt/scientific_interfaces/ISISSANS/SANSBackgroundCorrectionWidget.h +++ b/qt/scientific_interfaces/ISISSANS/SANSBackgroundCorrectionWidget.h @@ -25,18 +25,18 @@ class MANTIDQT_ISISSANS_DLL SANSBackgroundCorrectionWidget : public QWidget { public: SANSBackgroundCorrectionWidget(QWidget *parent = nullptr); - void - setDarkRunSettingForTimeDetectors(SANSBackgroundCorrectionSettings setting); + void setDarkRunSettingForTimeDetectors( + const SANSBackgroundCorrectionSettings &setting); SANSBackgroundCorrectionSettings getDarkRunSettingForTimeDetectors(); - void - setDarkRunSettingForUampDetectors(SANSBackgroundCorrectionSettings setting); + void setDarkRunSettingForUampDetectors( + const SANSBackgroundCorrectionSettings &setting); SANSBackgroundCorrectionSettings getDarkRunSettingForUampDetectors(); - void - setDarkRunSettingForTimeMonitors(SANSBackgroundCorrectionSettings setting); + void setDarkRunSettingForTimeMonitors( + const SANSBackgroundCorrectionSettings &setting); SANSBackgroundCorrectionSettings getDarkRunSettingForTimeMonitors(); - void - setDarkRunSettingForUampMonitors(SANSBackgroundCorrectionSettings setting); + void setDarkRunSettingForUampMonitors( + const SANSBackgroundCorrectionSettings &setting); SANSBackgroundCorrectionSettings getDarkRunSettingForUampMonitors(); void resetEntries(); diff --git a/qt/scientific_interfaces/ISISSANS/SANSDiagnostics.cpp b/qt/scientific_interfaces/ISISSANS/SANSDiagnostics.cpp index 16083b0dcfa5b20ffd4ceb544c20c37674184b62..a315af1582f5369fe9814bf5276bb1c2b860e2c6 100644 --- a/qt/scientific_interfaces/ISISSANS/SANSDiagnostics.cpp +++ b/qt/scientific_interfaces/ISISSANS/SANSDiagnostics.cpp @@ -1185,7 +1185,7 @@ void SANSDiagnostics::saveSettings() { * @param orientation - orientation of the detector */ bool SANSDiagnostics::executeSumRowColumn( - const std::vector<unsigned int> &values, const QString ipws, + const std::vector<unsigned int> &values, const QString &ipws, const QString &opws, const QString &orientation) { if (values.empty()) { return false; @@ -1229,7 +1229,7 @@ bool SANSDiagnostics::executeSumRowColumn( * @param hvMin minimum value of * @param hvMax */ -bool SANSDiagnostics::runsumRowColumn(const QString ipwsName, +bool SANSDiagnostics::runsumRowColumn(const QString &ipwsName, const QString &opwsName, const QString &orientation, const QString &hvMin, @@ -1431,8 +1431,8 @@ void SANSDiagnostics::enableMaskFileControls() { * @returns an output workspace name */ QString SANSDiagnostics::createOutputWorkspaceName( - QString originalWorkspaceName, QString detectorName, - QString integrationType, QString min, QString max) { + const QString &originalWorkspaceName, const QString &detectorName, + const QString &integrationType, const QString &min, const QString &max) { // Get run number from the loaded workspace boost::optional<int> runNumber = boost::none; try { diff --git a/qt/scientific_interfaces/ISISSANS/SANSDiagnostics.h b/qt/scientific_interfaces/ISISSANS/SANSDiagnostics.h index d305c4723f22dc342aafddb936cfda74816ecec1..f3ab468401ab4b3be72773be96592797616efd07 100644 --- a/qt/scientific_interfaces/ISISSANS/SANSDiagnostics.h +++ b/qt/scientific_interfaces/ISISSANS/SANSDiagnostics.h @@ -80,7 +80,7 @@ private: void setToolTips(); /// execute sumrowcolumn algorithm bool executeSumRowColumn(const std::vector<unsigned int> &values, - const QString ipws, const QString &op, + const QString &ipws, const QString &op, const QString &orientation); /// load the settings from the registry void loadSettings(); @@ -99,7 +99,7 @@ private: bool runLoadAlgorithm(const QString &fileName, const QString &specMin = "-1", const QString &specMax = "-1"); /// returns sumrowcolumn script - bool runsumRowColumn(const QString ipwsName, const QString &opwsName, + bool runsumRowColumn(const QString &ipwsName, const QString &opwsName, const QString &orientation, const QString &hvMin, const QString &hvMax); // get rectangular detector details @@ -173,10 +173,10 @@ private: void HVMinHVMaxStringValues(const int minVal, const int maxVal, QString &hvMin, QString &hvMax); /// Create the name for the outputworkspace - QString createOutputWorkspaceName(QString originalWorkspaceName, - QString detectorName, - QString integrationType, QString min, - QString max); + QString createOutputWorkspaceName(const QString &originalWorkspaceName, + const QString &detectorName, + const QString &integrationType, + const QString &min, const QString &max); private: QString m_dataDir; ///< default data search directory diff --git a/qt/scientific_interfaces/ISISSANS/SANSEventSlicing.cpp b/qt/scientific_interfaces/ISISSANS/SANSEventSlicing.cpp index 7c37701d14058d30968f2a54dbe1c85e6f7b21c2..e9f824dd02ecddfd7c0fa8a5a9b7c1ec39924c86 100644 --- a/qt/scientific_interfaces/ISISSANS/SANSEventSlicing.cpp +++ b/qt/scientific_interfaces/ISISSANS/SANSEventSlicing.cpp @@ -148,7 +148,8 @@ SANSEventSlicing::runSliceEvent(const QString &code) { return values2ChargeAndTime(result); } -void SANSEventSlicing::raiseWarning(QString title, QString message) { +void SANSEventSlicing::raiseWarning(const QString &title, + const QString &message) { QMessageBox::warning(this, title, message); } diff --git a/qt/scientific_interfaces/ISISSANS/SANSEventSlicing.h b/qt/scientific_interfaces/ISISSANS/SANSEventSlicing.h index 67434d6b236c000e81903f6692e9c985ecdf1d34..446f138a5eee9661efeff6548d52bd9408c1576b 100644 --- a/qt/scientific_interfaces/ISISSANS/SANSEventSlicing.h +++ b/qt/scientific_interfaces/ISISSANS/SANSEventSlicing.h @@ -39,7 +39,7 @@ private: ChargeAndTime runSliceEvent(const QString &code2run); void checkPythonOutput(const QString &result); ChargeAndTime values2ChargeAndTime(const QString &input); - void raiseWarning(QString title, QString message); + void raiseWarning(const QString &title, const QString &message); protected: void showEvent(QShowEvent * /*unused*/) override; diff --git a/qt/scientific_interfaces/ISISSANS/SANSPlotSpecial.cpp b/qt/scientific_interfaces/ISISSANS/SANSPlotSpecial.cpp index fd1591ea4ee4d4b6af0a5ac3b143d705c01beba4..d4094c00dc48c08bc2230c68cb45a2aa15d76f15 100644 --- a/qt/scientific_interfaces/ISISSANS/SANSPlotSpecial.cpp +++ b/qt/scientific_interfaces/ISISSANS/SANSPlotSpecial.cpp @@ -474,7 +474,7 @@ void SANSPlotSpecial::setupTable() { QwtPlotCurve *SANSPlotSpecial::plotMiniplot( QwtPlotCurve *curve, - boost::shared_ptr<Mantid::API::MatrixWorkspace> workspace, + const boost::shared_ptr<Mantid::API::MatrixWorkspace> &workspace, size_t workspaceIndex) { bool data = (curve == m_dataCurve); diff --git a/qt/scientific_interfaces/ISISSANS/SANSPlotSpecial.h b/qt/scientific_interfaces/ISISSANS/SANSPlotSpecial.h index 131e69decbc7326e5175e30e108f02a8101808a1..abcddc324ee66727d6f864f271883f5035567113 100644 --- a/qt/scientific_interfaces/ISISSANS/SANSPlotSpecial.h +++ b/qt/scientific_interfaces/ISISSANS/SANSPlotSpecial.h @@ -100,7 +100,7 @@ private: void createTransforms(); QwtPlotCurve * plotMiniplot(QwtPlotCurve *curve, - boost::shared_ptr<Mantid::API::MatrixWorkspace> workspace, + const boost::shared_ptr<Mantid::API::MatrixWorkspace> &workspace, size_t workspaceIndex = 0); void deriveGuinierSpheres(); diff --git a/qt/scientific_interfaces/ISISSANS/SANSRunWindow.cpp b/qt/scientific_interfaces/ISISSANS/SANSRunWindow.cpp index acd8be43bda711b981eb3649f5c786d63dd8fb6b..f882baace119c80ae470f6acf4626427e8afa0bd 100644 --- a/qt/scientific_interfaces/ISISSANS/SANSRunWindow.cpp +++ b/qt/scientific_interfaces/ISISSANS/SANSRunWindow.cpp @@ -45,6 +45,7 @@ #include <boost/tuple/tuple.hpp> #include <cmath> +#include <utility> using Mantid::detid_t; @@ -159,7 +160,7 @@ QString convertBoolToPythonBoolString(bool input) { * @param input: the python string representation * @returns a true or false */ -bool convertPythonBoolStringToBool(QString input) { +bool convertPythonBoolStringToBool(const QString &input) { bool value = false; if (input == MantidQt::CustomInterfaces::SANSConstants::getPythonTrueKeyword()) { @@ -173,7 +174,8 @@ bool convertPythonBoolStringToBool(QString input) { } void setTransmissionOnSaveCommand( - QString &saveCommand, Mantid::API::MatrixWorkspace_sptr matrix_workspace, + QString &saveCommand, + const Mantid::API::MatrixWorkspace_sptr &matrix_workspace, const QString &detectorSelection) { if (matrix_workspace->getInstrument()->getName() == "SANS2D") saveCommand += "'front-detector, rear-detector'"; @@ -1461,7 +1463,7 @@ void SANSRunWindow::appendRowToMaskTable(const QString &type, * @param lsdb :: The result of the sample-detector bank 2 distance */ void SANSRunWindow::componentLOQDistances( - boost::shared_ptr<const Mantid::API::MatrixWorkspace> workspace, + const boost::shared_ptr<const Mantid::API::MatrixWorkspace> &workspace, double &lms, double &lsda, double &lsdb) { Instrument_const_sptr instr = workspace->getInstrument(); if (!instr) @@ -1882,7 +1884,7 @@ void SANSRunWindow::setGeometryDetails() { * @param wscode :: 0 for sample, 1 for can, others not defined */ void SANSRunWindow::setSANS2DGeometry( - boost::shared_ptr<const Mantid::API::MatrixWorkspace> workspace, + const boost::shared_ptr<const Mantid::API::MatrixWorkspace> &workspace, int wscode) { const double unitconv = 1000.; const double distance = workspace->spectrumInfo().l1() * unitconv; @@ -1934,11 +1936,11 @@ void SANSRunWindow::setSANS2DGeometry( * @param wscode :: ????? */ void SANSRunWindow::setLOQGeometry( - boost::shared_ptr<const Mantid::API::MatrixWorkspace> workspace, + const boost::shared_ptr<const Mantid::API::MatrixWorkspace> &workspace, int wscode) { double dist_ms(0.0), dist_mdb(0.0), dist_hab(0.0); // Sample - componentLOQDistances(workspace, dist_ms, dist_mdb, dist_hab); + componentLOQDistances(std::move(workspace), dist_ms, dist_mdb, dist_hab); QHash<QString, QLabel *> &labels = m_loq_detlabels[wscode]; QLabel *detlabel = labels.value("moderator-sample"); @@ -3687,7 +3689,7 @@ void SANSRunWindow::fillDetectNames(QComboBox *output) { * @throw NotFoundError if a workspace can't be returned */ Mantid::API::MatrixWorkspace_sptr -SANSRunWindow::getGroupMember(Mantid::API::Workspace_const_sptr in, +SANSRunWindow::getGroupMember(const Mantid::API::Workspace_const_sptr &in, const int member) const { Mantid::API::WorkspaceGroup_const_sptr group = boost::dynamic_pointer_cast<const Mantid::API::WorkspaceGroup>(in); @@ -3820,7 +3822,7 @@ void SANSRunWindow::cleanup() { * @param csv_line :: Add a line of csv text to the grid * @param separator :: An optional separator, default = "," */ -int SANSRunWindow::addBatchLine(QString csv_line, QString separator) { +int SANSRunWindow::addBatchLine(const QString &csv_line, QString separator) { // Try to detect separator if one is not specified if (separator.isEmpty()) { if (csv_line.contains(",")) { @@ -4688,7 +4690,7 @@ bool SANSRunWindow::areSettingsValid(States type) { void SANSRunWindow::checkWaveLengthAndQValues(bool &isValid, QString &message, QLineEdit *min, QLineEdit *max, QComboBox *selection, - QString type) { + const QString &type) { auto min_value = min->text().simplified().toDouble(); auto max_value = max->text().simplified().toDouble(); @@ -4834,7 +4836,7 @@ void SANSRunWindow::retrieveQResolutionAperture() { * @param command: the python command to execute * @returns either a length (string) in mm or an empty string */ -QString SANSRunWindow::retrieveQResolutionGeometry(QString command) { +QString SANSRunWindow::retrieveQResolutionGeometry(const QString &command) { QString result(runPythonCode(command, false)); result = result.simplified(); if (result == m_constants.getPythonEmptyKeyword()) { @@ -4864,9 +4866,10 @@ void SANSRunWindow::setupQResolutionCircularAperture() { * @param h2: the height of the second aperture * @param w2: the width of the second aperture */ -void SANSRunWindow::setupQResolutionRectangularAperture(QString h1, QString w1, - QString h2, - QString w2) { +void SANSRunWindow::setupQResolutionRectangularAperture(const QString &h1, + const QString &w1, + const QString &h2, + const QString &w2) { // Set the QResolution Aperture setQResolutionApertureType(QResoluationAperture::RECTANGULAR, "H1 [mm]", "H2 [mm]", h1, h2, @@ -4914,9 +4917,9 @@ void SANSRunWindow::setupQResolutionRectangularAperture() { * @param w1W2Disabled: if the w1W2Inputs should be disabled */ void SANSRunWindow::setQResolutionApertureType( - QResoluationAperture apertureType, QString a1H1Label, QString a2H2Label, - QString a1H1, QString a2H2, QString toolTipA1H1, QString toolTipA2H2, - bool w1W2Disabled) { + QResoluationAperture apertureType, const QString &a1H1Label, + const QString &a2H2Label, const QString &a1H1, const QString &a2H2, + const QString &toolTipA1H1, const QString &toolTipA2H2, bool w1W2Disabled) { // Set the labels m_uiForm.q_resolution_a1_h1_label->setText(a1H1Label); m_uiForm.q_resolution_a2_h2_label->setText(a2H2Label); @@ -5012,7 +5015,7 @@ void SANSRunWindow::writeQResolutionSettingsToPythonScript( * @param py_code: the code segment to which we want to append */ void SANSRunWindow::writeQResolutionSettingsToPythonScriptSingleEntry( - QString value, QString code_entry, const QString lineEnding, + const QString &value, const QString &code_entry, const QString &lineEnding, QString &py_code) const { if (!value.isEmpty()) { py_code += code_entry + value + lineEnding; @@ -5125,7 +5128,8 @@ SANSRunWindow::retrieveBackgroundCorrectionSetting(bool isTime, bool isMon) { std::map<QString, QString> commandMap = { {"run_number", ""}, {"is_mean", ""}, {"is_mon", ""}, {"mon_number", ""}}; - auto createPythonScript = [](bool isTime, bool isMon, QString component) { + auto createPythonScript = [](bool isTime, bool isMon, + const QString &component) { return "i.get_background_correction(is_time = " + convertBoolToPythonBoolString(isTime) + ", is_mon=" + convertBoolToPythonBoolString(isMon) + @@ -5185,7 +5189,7 @@ void SANSRunWindow::writeBackgroundCorrectionToPythonScript( */ void SANSRunWindow::addBackgroundCorrectionToPythonScript( QString &pythonCode, - MantidQt::CustomInterfaces::SANSBackgroundCorrectionSettings setting, + const MantidQt::CustomInterfaces::SANSBackgroundCorrectionSettings &setting, bool isTimeBased) { QString newSetting = diff --git a/qt/scientific_interfaces/ISISSANS/SANSRunWindow.h b/qt/scientific_interfaces/ISISSANS/SANSRunWindow.h index 426533cd3197851fba11fb07d26f0cb63e283636..096cfd7636556ef64a1a1f262e41af2bab5e71c9 100644 --- a/qt/scientific_interfaces/ISISSANS/SANSRunWindow.h +++ b/qt/scientific_interfaces/ISISSANS/SANSRunWindow.h @@ -149,14 +149,15 @@ private: QString readSampleObjectGUIChanges(); /// Get the component distances void componentLOQDistances( - boost::shared_ptr<const Mantid::API::MatrixWorkspace> workspace, + const boost::shared_ptr<const Mantid::API::MatrixWorkspace> &workspace, double &lms, double &lsda, double &lsdb); /// Enable/disable user interaction void setProcessingState(const States action); /// Check for workspace name in the AnalysisDataService bool workspaceExists(const QString &ws_name) const; Mantid::API::MatrixWorkspace_sptr - getGroupMember(Mantid::API::Workspace_const_sptr in, const int member) const; + getGroupMember(const Mantid::API::Workspace_const_sptr &in, + const int member) const; /// Construct a QStringList of the currently loaded workspaces QStringList currentWorkspaceList() const; /// Is the user file loaded @@ -168,11 +169,11 @@ private: void setGeometryDetails(); /// Set the SANS2D geometry void setSANS2DGeometry( - boost::shared_ptr<const Mantid::API::MatrixWorkspace> workspace, + const boost::shared_ptr<const Mantid::API::MatrixWorkspace> &workspace, int wscode); /// Set LOQ geometry void setLOQGeometry( - boost::shared_ptr<const Mantid::API::MatrixWorkspace> workspace, + const boost::shared_ptr<const Mantid::API::MatrixWorkspace> &workspace, int wscode); /// Mark an error on a label void markError(QLabel *label); @@ -207,7 +208,7 @@ private: bool browseForFile(const QString &box_title, QLineEdit *file_field, QString file_filter = QString()); /// Add a csv line to the batch grid - int addBatchLine(QString csv_line, QString separator = ""); + int addBatchLine(const QString &csv_line, QString separator = ""); /// Save the batch file QString saveBatchGrid(const QString &filename = ""); /// Check that the workspace can have the zero errors removed @@ -445,7 +446,7 @@ private: /// Check setting for wavelengths and Q values void checkWaveLengthAndQValues(bool &isValid, QString &message, QLineEdit *min, QLineEdit *max, - QComboBox *selection, QString type); + QComboBox *selection, const QString &type); /// Checks if the save settings are valid for a particular workspace bool areSaveSettingsValid(const QString &workspaceName); /// Update the beam center fields @@ -458,26 +459,29 @@ private: /// correct setting and displays it void retrieveQResolutionAperture(); /// General getter for aperture settings of Q Resolution - QString retrieveQResolutionGeometry(QString command); + QString retrieveQResolutionGeometry(const QString &command); /// Write the QResolution GUI changes to a python script void writeQResolutionSettingsToPythonScript(QString &pythonCode); /// Write single line for Q Resolution void writeQResolutionSettingsToPythonScriptSingleEntry( - QString value, QString code_entry, const QString lineEnding, - QString &py_code) const; + const QString &value, const QString &code_entry, + const QString &lineEnding, QString &py_code) const; /// Sets the cirucular aperture, ie labels and populates the values with what /// is available from the user file void setupQResolutionCircularAperture(); /// Sets the rectuanular aperture - void setupQResolutionRectangularAperture(QString h1, QString w1, QString h2, - QString w2); + void setupQResolutionRectangularAperture(const QString &h1, const QString &w1, + const QString &h2, + const QString &w2); /// Set the rectangular aperture void setupQResolutionRectangularAperture(); /// Set the aperture type void setQResolutionApertureType(QResoluationAperture apertureType, - QString a1H1Label, QString a2H2Label, - QString a1H1, QString a2H2, - QString toolTipA1H1, QString toolTipA2H2, + const QString &a1H1Label, + const QString &a2H2Label, const QString &a1H1, + const QString &a2H2, + const QString &toolTipA1H1, + const QString &toolTipA2H2, bool w1W2Disabled); /// Initialize the QResolution settings void initQResolutionSettings(); @@ -494,7 +498,8 @@ private: /// Generic addition of background correction to python script void addBackgroundCorrectionToPythonScript( QString &pythonCode, - MantidQt::CustomInterfaces::SANSBackgroundCorrectionSettings setting, + const MantidQt::CustomInterfaces::SANSBackgroundCorrectionSettings + &setting, bool isTimeBased); /// Check if the user file has a valid user file extension bool hasUserFileValidFileExtension(); diff --git a/qt/scientific_interfaces/Indirect/AbsorptionCorrections.cpp b/qt/scientific_interfaces/Indirect/AbsorptionCorrections.cpp index 4eb769e324841862cc09281e4056b48878b59d5a..a3e6cbf5d131c400fbc8f8c52c028893ba6bc32e 100644 --- a/qt/scientific_interfaces/Indirect/AbsorptionCorrections.cpp +++ b/qt/scientific_interfaces/Indirect/AbsorptionCorrections.cpp @@ -47,7 +47,7 @@ std::string extractFirstOf(std::string const &str, return str; } -void setYAxisLabels(WorkspaceGroup_sptr group, std::string const &unit, +void setYAxisLabels(const WorkspaceGroup_sptr &group, std::string const &unit, std::string const &axisLabel) { for (auto const &workspace : *group) { auto matrixWs = boost::dynamic_pointer_cast<MatrixWorkspace>(workspace); @@ -56,7 +56,8 @@ void setYAxisLabels(WorkspaceGroup_sptr group, std::string const &unit, } } -void convertSpectrumAxis(MatrixWorkspace_sptr workspace, double eFixed = 0.0) { +void convertSpectrumAxis(const MatrixWorkspace_sptr &workspace, + double eFixed = 0.0) { auto convertAlg = AlgorithmManager::Instance().create("ConvertSpectrumAxis"); convertAlg->initialize(); convertAlg->setProperty("InputWorkspace", workspace); @@ -68,7 +69,7 @@ void convertSpectrumAxis(MatrixWorkspace_sptr workspace, double eFixed = 0.0) { convertAlg->execute(); } -MatrixWorkspace_sptr convertUnits(MatrixWorkspace_sptr workspace, +MatrixWorkspace_sptr convertUnits(const MatrixWorkspace_sptr &workspace, std::string const &target) { auto convertAlg = AlgorithmManager::Instance().create("ConvertUnits"); convertAlg->initialize(); @@ -95,7 +96,7 @@ groupWorkspaces(std::vector<std::string> const &workspaceNames) { return groupAlg->getProperty("OutputWorkspace"); } -WorkspaceGroup_sptr convertUnits(WorkspaceGroup_sptr workspaceGroup, +WorkspaceGroup_sptr convertUnits(const WorkspaceGroup_sptr &workspaceGroup, std::string const &target) { std::vector<std::string> convertedNames; convertedNames.reserve(workspaceGroup->size()); @@ -299,8 +300,8 @@ void AbsorptionCorrections::run() { * @param alg Algorithm to set properties of * @param shape Sample shape */ -void AbsorptionCorrections::addShapeSpecificSampleOptions(IAlgorithm_sptr alg, - QString shape) { +void AbsorptionCorrections::addShapeSpecificSampleOptions( + const IAlgorithm_sptr &alg, const QString &shape) { if (shape == "FlatPlate") { double const sampleHeight = m_uiForm.spFlatSampleHeight->value(); @@ -342,8 +343,8 @@ void AbsorptionCorrections::addShapeSpecificSampleOptions(IAlgorithm_sptr alg, * @param alg Algorithm to set properties of * @param shape Sample shape */ -void AbsorptionCorrections::addShapeSpecificCanOptions(IAlgorithm_sptr alg, - QString const &shape) { +void AbsorptionCorrections::addShapeSpecificCanOptions( + const IAlgorithm_sptr &alg, QString const &shape) { if (shape == "FlatPlate") { double const canFrontThickness = m_uiForm.spFlatCanFrontThickness->value(); alg->setProperty("ContainerFrontThickness", canFrontThickness); @@ -470,7 +471,7 @@ void AbsorptionCorrections::processWavelengthWorkspace() { } void AbsorptionCorrections::convertSpectrumAxes( - WorkspaceGroup_sptr correctionsWs) { + const WorkspaceGroup_sptr &correctionsWs) { auto const sampleWsName = m_uiForm.dsSampleInput->getCurrentDataName().toStdString(); convertSpectrumAxes(correctionsWs, getADSMatrixWorkspace(sampleWsName)); @@ -478,7 +479,8 @@ void AbsorptionCorrections::convertSpectrumAxes( } void AbsorptionCorrections::convertSpectrumAxes( - WorkspaceGroup_sptr correctionsGroup, MatrixWorkspace_sptr sample) { + const WorkspaceGroup_sptr &correctionsGroup, + const MatrixWorkspace_sptr &sample) { for (auto const &workspace : *correctionsGroup) { auto const correction = boost::dynamic_pointer_cast<MatrixWorkspace>(workspace); @@ -486,8 +488,9 @@ void AbsorptionCorrections::convertSpectrumAxes( } } -void AbsorptionCorrections::convertSpectrumAxes(MatrixWorkspace_sptr correction, - MatrixWorkspace_sptr sample) { +void AbsorptionCorrections::convertSpectrumAxes( + const MatrixWorkspace_sptr &correction, + const MatrixWorkspace_sptr &sample) { if (correction && sample && getEMode(sample) == "Indirect") { try { convertSpectrumAxis(correction, getEFixed(correction)); @@ -523,7 +526,7 @@ void AbsorptionCorrections::getParameterDefaults(QString const &dataName) { } void AbsorptionCorrections::getParameterDefaults( - Instrument_const_sptr instrument) { + const Instrument_const_sptr &instrument) { setBeamWidthValue(instrument, "Workflow.beam-width"); setBeamHeightValue(instrument, "Workflow.beam-height"); setWavelengthsValue(instrument, "Workflow.absorption-wavelengths"); @@ -533,7 +536,7 @@ void AbsorptionCorrections::getParameterDefaults( } void AbsorptionCorrections::setBeamWidthValue( - Instrument_const_sptr instrument, + const Instrument_const_sptr &instrument, std::string const &beamWidthParamName) const { if (instrument->hasParameter(beamWidthParamName)) { auto const beamWidth = QString::fromStdString( @@ -544,7 +547,7 @@ void AbsorptionCorrections::setBeamWidthValue( } void AbsorptionCorrections::setBeamHeightValue( - Instrument_const_sptr instrument, + const Instrument_const_sptr &instrument, std::string const &beamHeightParamName) const { if (instrument->hasParameter(beamHeightParamName)) { auto const beamHeight = QString::fromStdString( @@ -555,7 +558,7 @@ void AbsorptionCorrections::setBeamHeightValue( } void AbsorptionCorrections::setWavelengthsValue( - Instrument_const_sptr instrument, + const Instrument_const_sptr &instrument, std::string const &wavelengthsParamName) const { if (instrument->hasParameter(wavelengthsParamName)) { auto const wavelengths = QString::fromStdString( @@ -566,7 +569,7 @@ void AbsorptionCorrections::setWavelengthsValue( } void AbsorptionCorrections::setEventsValue( - Instrument_const_sptr instrument, + const Instrument_const_sptr &instrument, std::string const &eventsParamName) const { if (instrument->hasParameter(eventsParamName)) { auto const events = QString::fromStdString( @@ -577,7 +580,7 @@ void AbsorptionCorrections::setEventsValue( } void AbsorptionCorrections::setInterpolationValue( - Instrument_const_sptr instrument, + const Instrument_const_sptr &instrument, std::string const &interpolationParamName) const { if (instrument->hasParameter(interpolationParamName)) { auto const interpolation = QString::fromStdString( @@ -589,7 +592,7 @@ void AbsorptionCorrections::setInterpolationValue( } void AbsorptionCorrections::setMaxAttemptsValue( - Instrument_const_sptr instrument, + const Instrument_const_sptr &instrument, std::string const &maxAttemptsParamName) const { if (instrument->hasParameter(maxAttemptsParamName)) { auto const maxScatterAttempts = QString::fromStdString( diff --git a/qt/scientific_interfaces/Indirect/AbsorptionCorrections.h b/qt/scientific_interfaces/Indirect/AbsorptionCorrections.h index 330a2fdb9cfb0bc6878a561c0a3ef446f8be687a..fbac43c086653408fbc6a6f412d1879e5745314c 100644 --- a/qt/scientific_interfaces/Indirect/AbsorptionCorrections.h +++ b/qt/scientific_interfaces/Indirect/AbsorptionCorrections.h @@ -51,31 +51,39 @@ private: void setFileExtensionsByName(bool filter) override; void addSaveWorkspace(std::string const &wsName); - void addShapeSpecificSampleOptions(Mantid::API::IAlgorithm_sptr alg, - QString shape); - void addShapeSpecificCanOptions(Mantid::API::IAlgorithm_sptr alg, + void addShapeSpecificSampleOptions(const Mantid::API::IAlgorithm_sptr &alg, + const QString &shape); + void addShapeSpecificCanOptions(const Mantid::API::IAlgorithm_sptr &alg, QString const &shape); void processWavelengthWorkspace(); - void convertSpectrumAxes(Mantid::API::WorkspaceGroup_sptr correctionsWs); - void convertSpectrumAxes(Mantid::API::WorkspaceGroup_sptr correctionsGroup, - Mantid::API::MatrixWorkspace_sptr sample); - void convertSpectrumAxes(Mantid::API::MatrixWorkspace_sptr correction, - Mantid::API::MatrixWorkspace_sptr sample); - - void getParameterDefaults(Mantid::Geometry::Instrument_const_sptr instrument); - void setBeamWidthValue(Mantid::Geometry::Instrument_const_sptr instrument, - std::string const &beamWidthParamName) const; - void setBeamHeightValue(Mantid::Geometry::Instrument_const_sptr instrument, - std::string const &beamHeightParamName) const; - void setWavelengthsValue(Mantid::Geometry::Instrument_const_sptr instrument, - std::string const &wavelengthsParamName) const; - void setEventsValue(Mantid::Geometry::Instrument_const_sptr instrument, + void + convertSpectrumAxes(const Mantid::API::WorkspaceGroup_sptr &correctionsWs); + void + convertSpectrumAxes(const Mantid::API::WorkspaceGroup_sptr &correctionsGroup, + const Mantid::API::MatrixWorkspace_sptr &sample); + void convertSpectrumAxes(const Mantid::API::MatrixWorkspace_sptr &correction, + const Mantid::API::MatrixWorkspace_sptr &sample); + + void getParameterDefaults( + const Mantid::Geometry::Instrument_const_sptr &instrument); + void + setBeamWidthValue(const Mantid::Geometry::Instrument_const_sptr &instrument, + std::string const &beamWidthParamName) const; + void + setBeamHeightValue(const Mantid::Geometry::Instrument_const_sptr &instrument, + std::string const &beamHeightParamName) const; + void + setWavelengthsValue(const Mantid::Geometry::Instrument_const_sptr &instrument, + std::string const &wavelengthsParamName) const; + void setEventsValue(const Mantid::Geometry::Instrument_const_sptr &instrument, std::string const &eventsParamName) const; - void setInterpolationValue(Mantid::Geometry::Instrument_const_sptr instrument, - std::string const &interpolationParamName) const; - void setMaxAttemptsValue(Mantid::Geometry::Instrument_const_sptr instrument, - std::string const &maxAttemptsParamName) const; + void setInterpolationValue( + const Mantid::Geometry::Instrument_const_sptr &instrument, + std::string const &interpolationParamName) const; + void + setMaxAttemptsValue(const Mantid::Geometry::Instrument_const_sptr &instrument, + std::string const &maxAttemptsParamName) const; void setComboBoxOptions(QComboBox *combobox, std::vector<std::string> const &options); diff --git a/qt/scientific_interfaces/Indirect/ApplyAbsorptionCorrections.cpp b/qt/scientific_interfaces/Indirect/ApplyAbsorptionCorrections.cpp index 86940d28ec0c0a00718e12c9a5e9ad8854c90a08..ba1fb9b74c69ddb92c865c6a409b42016a3efc2c 100644 --- a/qt/scientific_interfaces/Indirect/ApplyAbsorptionCorrections.cpp +++ b/qt/scientific_interfaces/Indirect/ApplyAbsorptionCorrections.cpp @@ -15,6 +15,7 @@ #include "MantidQtWidgets/Common/SignalBlocker.h" #include <QStringList> +#include <utility> using namespace IndirectDataValidationHelper; using namespace Mantid::API; @@ -370,9 +371,9 @@ void ApplyAbsorptionCorrections::run() { * @param toMatch Name of the workspace to match */ void ApplyAbsorptionCorrections::addInterpolationStep( - MatrixWorkspace_sptr toInterpolate, std::string toMatch) { + const MatrixWorkspace_sptr &toInterpolate, std::string toMatch) { API::BatchAlgorithmRunner::AlgorithmRuntimeProps interpolationProps; - interpolationProps["WorkspaceToMatch"] = toMatch; + interpolationProps["WorkspaceToMatch"] = std::move(toMatch); IAlgorithm_sptr interpolationAlg = AlgorithmManager::Instance().create("SplineInterpolation"); diff --git a/qt/scientific_interfaces/Indirect/ApplyAbsorptionCorrections.h b/qt/scientific_interfaces/Indirect/ApplyAbsorptionCorrections.h index 30335c7cc610ac4bb4a7eaf31e940602adc6743f..13420b73c8f725f4aabcd5452c4bfaaec9617980 100644 --- a/qt/scientific_interfaces/Indirect/ApplyAbsorptionCorrections.h +++ b/qt/scientific_interfaces/Indirect/ApplyAbsorptionCorrections.h @@ -47,8 +47,9 @@ private: void loadSettings(const QSettings &settings) override; void setFileExtensionsByName(bool filter) override; - void addInterpolationStep(Mantid::API::MatrixWorkspace_sptr toInterpolate, - std::string toMatch); + void + addInterpolationStep(const Mantid::API::MatrixWorkspace_sptr &toInterpolate, + std::string toMatch); void plotInPreview(const QString &curveName, Mantid::API::MatrixWorkspace_sptr &ws, const QColor &curveColor); diff --git a/qt/scientific_interfaces/Indirect/CalculatePaalmanPings.cpp b/qt/scientific_interfaces/Indirect/CalculatePaalmanPings.cpp index 3e6ed6cd3861a1efdbe8f099b9f4cc754744fbf7..01166a226eb8fbff811ee2bd1e024de55aa9653c 100644 --- a/qt/scientific_interfaces/Indirect/CalculatePaalmanPings.cpp +++ b/qt/scientific_interfaces/Indirect/CalculatePaalmanPings.cpp @@ -572,7 +572,7 @@ void CalculatePaalmanPings::getBeamWidthFromWorkspace(const QString &wsName) { * boost::none. */ boost::optional<double> CalculatePaalmanPings::getInstrumentParameter( - Mantid::Geometry::Instrument_const_sptr instrument, + const Mantid::Geometry::Instrument_const_sptr &instrument, const std::string ¶meterName) { if (instrument->hasParameter(parameterName)) { @@ -589,8 +589,8 @@ boost::optional<double> CalculatePaalmanPings::getInstrumentParameter( * @param alg Algorithm to set properties of * @param shape Sample shape */ -void CalculatePaalmanPings::addShapeSpecificSampleOptions(IAlgorithm_sptr alg, - QString shape) { +void CalculatePaalmanPings::addShapeSpecificSampleOptions( + const IAlgorithm_sptr &alg, const QString &shape) { if (shape == "FlatPlate") { const auto sampleThickness = m_uiForm.spFlatSampleThickness->value(); alg->setProperty("SampleThickness", sampleThickness); @@ -635,8 +635,8 @@ void CalculatePaalmanPings::addShapeSpecificSampleOptions(IAlgorithm_sptr alg, * @param alg Algorithm to set properties of * @param shape Sample shape */ -void CalculatePaalmanPings::addShapeSpecificCanOptions(IAlgorithm_sptr alg, - QString shape) { +void CalculatePaalmanPings::addShapeSpecificCanOptions( + const IAlgorithm_sptr &alg, const QString &shape) { if (shape == "FlatPlate") { const auto canFrontThickness = m_uiForm.spFlatCanFrontThickness->value(); alg->setProperty("CanFrontThickness", canFrontThickness); diff --git a/qt/scientific_interfaces/Indirect/CalculatePaalmanPings.h b/qt/scientific_interfaces/Indirect/CalculatePaalmanPings.h index dda97d5a3b2a9538ba9f47a5a913e6f3c2639f8d..907f9490186b356f75568253b9aaa800f5910f4b 100644 --- a/qt/scientific_interfaces/Indirect/CalculatePaalmanPings.h +++ b/qt/scientific_interfaces/Indirect/CalculatePaalmanPings.h @@ -51,10 +51,10 @@ private: bool doValidation(bool silent = false); - void addShapeSpecificSampleOptions(Mantid::API::IAlgorithm_sptr alg, - QString shape); - void addShapeSpecificCanOptions(Mantid::API::IAlgorithm_sptr alg, - QString shape); + void addShapeSpecificSampleOptions(const Mantid::API::IAlgorithm_sptr &alg, + const QString &shape); + void addShapeSpecificCanOptions(const Mantid::API::IAlgorithm_sptr &alg, + const QString &shape); void setComboBoxOptions(QComboBox *combobox, std::vector<std::string> const &options); @@ -71,9 +71,9 @@ private: void setButtonsEnabled(bool enabled); void setRunIsRunning(bool running); - boost::optional<double> - getInstrumentParameter(Mantid::Geometry::Instrument_const_sptr instrument, - const std::string ¶meterName); + boost::optional<double> getInstrumentParameter( + const Mantid::Geometry::Instrument_const_sptr &instrument, + const std::string ¶meterName); Ui::CalculatePaalmanPings m_uiForm; diff --git a/qt/scientific_interfaces/Indirect/ContainerSubtraction.cpp b/qt/scientific_interfaces/Indirect/ContainerSubtraction.cpp index 65bf7a458adeaacf2e0e0a3acfaeef224c68e7b1..d917718b4a219895dec728e8bbb3670f01c88d98 100644 --- a/qt/scientific_interfaces/Indirect/ContainerSubtraction.cpp +++ b/qt/scientific_interfaces/Indirect/ContainerSubtraction.cpp @@ -5,6 +5,9 @@ // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + #include "ContainerSubtraction.h" + +#include <utility> + #include "MantidQtWidgets/Common/UserInputValidator.h" #include "MantidAPI/Axis.h" @@ -58,12 +61,12 @@ ContainerSubtraction::~ContainerSubtraction() { void ContainerSubtraction::setTransformedContainer( MatrixWorkspace_sptr workspace, const std::string &name) { - m_transformedContainerWS = workspace; + m_transformedContainerWS = std::move(workspace); AnalysisDataService::Instance().addOrReplace(name, m_transformedContainerWS); } void ContainerSubtraction::setTransformedContainer( - MatrixWorkspace_sptr workspace) { + const MatrixWorkspace_sptr &workspace) { m_transformedContainerWS = workspace; AnalysisDataService::Instance().addOrReplace(workspace->getName(), m_transformedContainerWS); @@ -456,46 +459,48 @@ MatrixWorkspace_sptr ContainerSubtraction::requestRebinToSample( } MatrixWorkspace_sptr -ContainerSubtraction::shiftWorkspace(MatrixWorkspace_sptr workspace, +ContainerSubtraction::shiftWorkspace(const MatrixWorkspace_sptr &workspace, double shiftValue) const { - auto shiftAlg = shiftAlgorithm(workspace, shiftValue); + auto shiftAlg = shiftAlgorithm(std::move(workspace), shiftValue); shiftAlg->execute(); return shiftAlg->getProperty("OutputWorkspace"); } MatrixWorkspace_sptr -ContainerSubtraction::scaleWorkspace(MatrixWorkspace_sptr workspace, +ContainerSubtraction::scaleWorkspace(const MatrixWorkspace_sptr &workspace, double scaleValue) const { - auto scaleAlg = scaleAlgorithm(workspace, scaleValue); + auto scaleAlg = scaleAlgorithm(std::move(workspace), scaleValue); scaleAlg->execute(); return scaleAlg->getProperty("OutputWorkspace"); } -MatrixWorkspace_sptr -ContainerSubtraction::minusWorkspace(MatrixWorkspace_sptr lhsWorkspace, - MatrixWorkspace_sptr rhsWorkspace) const { - auto minusAlg = minusAlgorithm(lhsWorkspace, rhsWorkspace); +MatrixWorkspace_sptr ContainerSubtraction::minusWorkspace( + const MatrixWorkspace_sptr &lhsWorkspace, + const MatrixWorkspace_sptr &rhsWorkspace) const { + auto minusAlg = + minusAlgorithm(std::move(lhsWorkspace), std::move(rhsWorkspace)); minusAlg->execute(); return minusAlg->getProperty("OutputWorkspace"); } MatrixWorkspace_sptr ContainerSubtraction::rebinToWorkspace( - MatrixWorkspace_sptr workspaceToRebin, - MatrixWorkspace_sptr workspaceToMatch) const { - auto rebinAlg = rebinToWorkspaceAlgorithm(workspaceToRebin, workspaceToMatch); + const MatrixWorkspace_sptr &workspaceToRebin, + const MatrixWorkspace_sptr &workspaceToMatch) const { + auto rebinAlg = rebinToWorkspaceAlgorithm(std::move(workspaceToRebin), + std::move(workspaceToMatch)); rebinAlg->execute(); return rebinAlg->getProperty("OutputWorkspace"); } -MatrixWorkspace_sptr -ContainerSubtraction::convertToHistogram(MatrixWorkspace_sptr workspace) const { - auto convertAlg = convertToHistogramAlgorithm(workspace); +MatrixWorkspace_sptr ContainerSubtraction::convertToHistogram( + const MatrixWorkspace_sptr &workspace) const { + auto convertAlg = convertToHistogramAlgorithm(std::move(workspace)); convertAlg->execute(); return convertAlg->getProperty("OutputWorkspace"); } IAlgorithm_sptr -ContainerSubtraction::shiftAlgorithm(MatrixWorkspace_sptr workspace, +ContainerSubtraction::shiftAlgorithm(const MatrixWorkspace_sptr &workspace, double shiftValue) const { IAlgorithm_sptr shift = AlgorithmManager::Instance().create("ScaleX"); shift->initialize(); @@ -509,7 +514,7 @@ ContainerSubtraction::shiftAlgorithm(MatrixWorkspace_sptr workspace, } IAlgorithm_sptr -ContainerSubtraction::scaleAlgorithm(MatrixWorkspace_sptr workspace, +ContainerSubtraction::scaleAlgorithm(const MatrixWorkspace_sptr &workspace, double scaleValue) const { IAlgorithm_sptr scale = AlgorithmManager::Instance().create("Scale"); scale->initialize(); @@ -522,9 +527,9 @@ ContainerSubtraction::scaleAlgorithm(MatrixWorkspace_sptr workspace, return scale; } -IAlgorithm_sptr -ContainerSubtraction::minusAlgorithm(MatrixWorkspace_sptr lhsWorkspace, - MatrixWorkspace_sptr rhsWorkspace) const { +IAlgorithm_sptr ContainerSubtraction::minusAlgorithm( + const MatrixWorkspace_sptr &lhsWorkspace, + const MatrixWorkspace_sptr &rhsWorkspace) const { IAlgorithm_sptr minus = AlgorithmManager::Instance().create("Minus"); minus->initialize(); minus->setChild(true); @@ -536,8 +541,8 @@ ContainerSubtraction::minusAlgorithm(MatrixWorkspace_sptr lhsWorkspace, } IAlgorithm_sptr ContainerSubtraction::rebinToWorkspaceAlgorithm( - MatrixWorkspace_sptr workspaceToRebin, - MatrixWorkspace_sptr workspaceToMatch) const { + const MatrixWorkspace_sptr &workspaceToRebin, + const MatrixWorkspace_sptr &workspaceToMatch) const { IAlgorithm_sptr rebin = AlgorithmManager::Instance().create("RebinToWorkspace"); rebin->initialize(); @@ -550,7 +555,7 @@ IAlgorithm_sptr ContainerSubtraction::rebinToWorkspaceAlgorithm( } IAlgorithm_sptr ContainerSubtraction::convertToHistogramAlgorithm( - MatrixWorkspace_sptr workspace) const { + const MatrixWorkspace_sptr &workspace) const { IAlgorithm_sptr convert = AlgorithmManager::Instance().create("ConvertToHistogram"); convert->initialize(); @@ -562,7 +567,7 @@ IAlgorithm_sptr ContainerSubtraction::convertToHistogramAlgorithm( } IAlgorithm_sptr ContainerSubtraction::addSampleLogAlgorithm( - MatrixWorkspace_sptr workspace, const std::string &name, + const MatrixWorkspace_sptr &workspace, const std::string &name, const std::string &type, const std::string &value) const { IAlgorithm_sptr shiftLog = AlgorithmManager::Instance().create("AddSampleLog"); diff --git a/qt/scientific_interfaces/Indirect/ContainerSubtraction.h b/qt/scientific_interfaces/Indirect/ContainerSubtraction.h index 2a8a230b3baaaa0f683ae84a2c052fb501e467a7..2821e893d53ae4ff586185779b11eaf14e5143ba 100644 --- a/qt/scientific_interfaces/Indirect/ContainerSubtraction.h +++ b/qt/scientific_interfaces/Indirect/ContainerSubtraction.h @@ -20,7 +20,8 @@ public: void setTransformedContainer(Mantid::API::MatrixWorkspace_sptr workspace, const std::string &name); - void setTransformedContainer(Mantid::API::MatrixWorkspace_sptr workspace); + void + setTransformedContainer(const Mantid::API::MatrixWorkspace_sptr &workspace); private slots: /// Handles a new sample being loaded @@ -57,36 +58,36 @@ private: requestRebinToSample(Mantid::API::MatrixWorkspace_sptr workspace) const; Mantid::API::MatrixWorkspace_sptr - shiftWorkspace(Mantid::API::MatrixWorkspace_sptr workspace, + shiftWorkspace(const Mantid::API::MatrixWorkspace_sptr &workspace, double shiftValue) const; Mantid::API::MatrixWorkspace_sptr - scaleWorkspace(Mantid::API::MatrixWorkspace_sptr workspace, + scaleWorkspace(const Mantid::API::MatrixWorkspace_sptr &workspace, double scaleValue) const; Mantid::API::MatrixWorkspace_sptr - minusWorkspace(Mantid::API::MatrixWorkspace_sptr lhsWorkspace, - Mantid::API::MatrixWorkspace_sptr rhsWorkspace) const; + minusWorkspace(const Mantid::API::MatrixWorkspace_sptr &lhsWorkspace, + const Mantid::API::MatrixWorkspace_sptr &rhsWorkspace) const; + Mantid::API::MatrixWorkspace_sptr rebinToWorkspace( + const Mantid::API::MatrixWorkspace_sptr &workspaceToRebin, + const Mantid::API::MatrixWorkspace_sptr &workspaceToMatch) const; Mantid::API::MatrixWorkspace_sptr - rebinToWorkspace(Mantid::API::MatrixWorkspace_sptr workspaceToRebin, - Mantid::API::MatrixWorkspace_sptr workspaceToMatch) const; - Mantid::API::MatrixWorkspace_sptr - convertToHistogram(Mantid::API::MatrixWorkspace_sptr workspace) const; + convertToHistogram(const Mantid::API::MatrixWorkspace_sptr &workspace) const; Mantid::API::IAlgorithm_sptr - shiftAlgorithm(Mantid::API::MatrixWorkspace_sptr workspace, + shiftAlgorithm(const Mantid::API::MatrixWorkspace_sptr &workspace, double shiftValue) const; Mantid::API::IAlgorithm_sptr - scaleAlgorithm(Mantid::API::MatrixWorkspace_sptr workspace, + scaleAlgorithm(const Mantid::API::MatrixWorkspace_sptr &workspace, double scaleValue) const; Mantid::API::IAlgorithm_sptr - minusAlgorithm(Mantid::API::MatrixWorkspace_sptr lhsWorkspace, - Mantid::API::MatrixWorkspace_sptr rhsWorkspace) const; + minusAlgorithm(const Mantid::API::MatrixWorkspace_sptr &lhsWorkspace, + const Mantid::API::MatrixWorkspace_sptr &rhsWorkspace) const; Mantid::API::IAlgorithm_sptr rebinToWorkspaceAlgorithm( - Mantid::API::MatrixWorkspace_sptr workspaceToRebin, - Mantid::API::MatrixWorkspace_sptr workspaceToMatch) const; + const Mantid::API::MatrixWorkspace_sptr &workspaceToRebin, + const Mantid::API::MatrixWorkspace_sptr &workspaceToMatch) const; Mantid::API::IAlgorithm_sptr convertToHistogramAlgorithm( - Mantid::API::MatrixWorkspace_sptr workspace) const; + const Mantid::API::MatrixWorkspace_sptr &workspace) const; Mantid::API::IAlgorithm_sptr - addSampleLogAlgorithm(Mantid::API::MatrixWorkspace_sptr workspace, + addSampleLogAlgorithm(const Mantid::API::MatrixWorkspace_sptr &workspace, const std::string &name, const std::string &type, const std::string &value) const; diff --git a/qt/scientific_interfaces/Indirect/ConvFitAddWorkspaceDialog.cpp b/qt/scientific_interfaces/Indirect/ConvFitAddWorkspaceDialog.cpp index ddfc5f938782041db8c7c19d5781f0602443cadb..16f7e273429bb9e9b99131919624fb0c48b21895 100644 --- a/qt/scientific_interfaces/Indirect/ConvFitAddWorkspaceDialog.cpp +++ b/qt/scientific_interfaces/Indirect/ConvFitAddWorkspaceDialog.cpp @@ -11,6 +11,7 @@ #include "MantidQtWidgets/Common/SignalBlocker.h" #include <boost/optional.hpp> +#include <utility> namespace { using namespace Mantid::API; @@ -27,7 +28,8 @@ bool validWorkspace(std::string const &name) { return !name.empty() && doesExistInADS(name); } -boost::optional<std::size_t> maximumIndex(MatrixWorkspace_sptr workspace) { +boost::optional<std::size_t> +maximumIndex(const MatrixWorkspace_sptr &workspace) { if (workspace) { const auto numberOfHistograms = workspace->getNumberHistograms(); if (numberOfHistograms > 0) @@ -36,8 +38,8 @@ boost::optional<std::size_t> maximumIndex(MatrixWorkspace_sptr workspace) { return boost::none; } -QString getIndexString(MatrixWorkspace_sptr workspace) { - const auto maximum = maximumIndex(workspace); +QString getIndexString(const MatrixWorkspace_sptr &workspace) { + const auto maximum = maximumIndex(std::move(workspace)); if (maximum) return QString("0-%1").arg(*maximum); return ""; diff --git a/qt/scientific_interfaces/Indirect/ConvFitModel.cpp b/qt/scientific_interfaces/Indirect/ConvFitModel.cpp index 2c10111356b36fdc28f3f3ef9618ef7eb99cb7f0..8e2af45fa01a33eca3b490fd30e69a91c766ac53 100644 --- a/qt/scientific_interfaces/Indirect/ConvFitModel.cpp +++ b/qt/scientific_interfaces/Indirect/ConvFitModel.cpp @@ -14,6 +14,7 @@ #include <boost/algorithm/string/join.hpp> #include <stdexcept> +#include <utility> using namespace Mantid::API; @@ -38,7 +39,7 @@ IAlgorithm_sptr loadParameterFileAlgorithm(std::string const &workspaceName, } void readAnalyserFromFile(const std::string &analyser, - MatrixWorkspace_sptr workspace) { + const MatrixWorkspace_sptr &workspace) { auto const instrument = workspace->getInstrument(); auto const idfDirectory = Mantid::Kernel::ConfigService::Instance().getString( "instrumentDefinition.directory"); @@ -57,7 +58,7 @@ void readAnalyserFromFile(const std::string &analyser, } Mantid::Geometry::IComponent_const_sptr -getAnalyser(MatrixWorkspace_sptr workspace) { +getAnalyser(const MatrixWorkspace_sptr &workspace) { auto const instrument = workspace->getInstrument(); auto const analysers = instrument->getStringParameter("analyser"); @@ -79,7 +80,8 @@ getAnalyser(MatrixWorkspace_sptr workspace) { return instrument->getComponentByName(analysers[0]); } -boost::optional<double> instrumentResolution(MatrixWorkspace_sptr workspace) { +boost::optional<double> +instrumentResolution(const MatrixWorkspace_sptr &workspace) { try { auto const analyser = getAnalyser(workspace); if (analyser && analyser->hasParameter("resolution")) @@ -101,7 +103,7 @@ boost::optional<double> instrumentResolution(MatrixWorkspace_sptr workspace) { } } -MatrixWorkspace_sptr cloneWorkspace(MatrixWorkspace_sptr inputWS, +MatrixWorkspace_sptr cloneWorkspace(const MatrixWorkspace_sptr &inputWS, std::string const &outputName) { auto cloneAlg = AlgorithmManager::Instance().create("CloneWorkspace"); cloneAlg->setLogging(false); @@ -112,8 +114,8 @@ MatrixWorkspace_sptr cloneWorkspace(MatrixWorkspace_sptr inputWS, return getADSMatrixWorkspace(outputName); } -MatrixWorkspace_sptr appendWorkspace(MatrixWorkspace_sptr leftWS, - MatrixWorkspace_sptr rightWS, +MatrixWorkspace_sptr appendWorkspace(const MatrixWorkspace_sptr &leftWS, + const MatrixWorkspace_sptr &rightWS, int numHistograms, std::string const &outputName) { auto appendAlg = AlgorithmManager::Instance().create("AppendSpectra"); @@ -144,7 +146,7 @@ void deleteWorkspace(std::string const &workspaceName) { deleter->execute(); } -void extendResolutionWorkspace(MatrixWorkspace_sptr resolution, +void extendResolutionWorkspace(const MatrixWorkspace_sptr &resolution, std::size_t numberOfHistograms, std::string const &outputName) { const auto resolutionNumHist = resolution->getNumberHistograms(); @@ -257,7 +259,7 @@ constructParameterNameChanges(const IFunction &model, } } -IAlgorithm_sptr addSampleLogAlgorithm(Workspace_sptr workspace, +IAlgorithm_sptr addSampleLogAlgorithm(const Workspace_sptr &workspace, const std::string &name, const std::string &text, const std::string &type) { @@ -273,7 +275,8 @@ IAlgorithm_sptr addSampleLogAlgorithm(Workspace_sptr workspace, struct AddSampleLogRunner { AddSampleLogRunner(Workspace_sptr resultWorkspace, WorkspaceGroup_sptr resultGroup) - : m_resultWorkspace(resultWorkspace), m_resultGroup(resultGroup) {} + : m_resultWorkspace(std::move(resultWorkspace)), + m_resultGroup(std::move(resultGroup)) {} void operator()(const std::string &name, const std::string &text, const std::string &type) { @@ -291,15 +294,15 @@ getNames(const MantidQt::CustomInterfaces::IDA::ResolutionCollectionType &workspaces) { std::vector<std::string> names; names.reserve(workspaces.size().value); - std::transform(workspaces.begin(), workspaces.end(), - std::back_inserter(names), - [](boost::weak_ptr<Mantid::API::MatrixWorkspace> workspace) { - return workspace.lock()->getName(); - }); + std::transform( + workspaces.begin(), workspaces.end(), std::back_inserter(names), + [](const boost::weak_ptr<Mantid::API::MatrixWorkspace> &workspace) { + return workspace.lock()->getName(); + }); return names; } -void setResolutionAttribute(CompositeFunction_sptr convolutionModel, +void setResolutionAttribute(const CompositeFunction_sptr &convolutionModel, const IFunction::Attribute &attr) { if (convolutionModel->name() == "Convolution") convolutionModel->getFunction(0)->setAttribute("Workspace", attr); @@ -425,7 +428,7 @@ void ConvFitModel::setResolution(const std::string &name, throw std::runtime_error("A valid resolution file needs to be selected."); } -void ConvFitModel::setResolution(MatrixWorkspace_sptr resolution, +void ConvFitModel::setResolution(const MatrixWorkspace_sptr &resolution, TableDatasetIndex index) { if (m_resolution.size() > index) m_resolution[index] = resolution; @@ -556,7 +559,7 @@ void ConvFitModel::addOutput(IndirectFitOutput *fitOutput, void ConvFitModel::setParameterNameChanges( const IFunction &model, boost::optional<std::size_t> backgroundIndex) { m_parameterNameChanges = constructParameterNameChanges( - model, backgroundIndex, m_temperature.is_initialized()); + model, std::move(backgroundIndex), m_temperature.is_initialized()); } std::vector<std::pair<std::string, int>> diff --git a/qt/scientific_interfaces/Indirect/ConvFitModel.h b/qt/scientific_interfaces/Indirect/ConvFitModel.h index 7779f69264256ef0d8c9cd36bd8b17185c640659..c1e01b72876984760f4fbf97d7c8c7c81b1944ef 100644 --- a/qt/scientific_interfaces/Indirect/ConvFitModel.h +++ b/qt/scientific_interfaces/Indirect/ConvFitModel.h @@ -41,7 +41,7 @@ public: const Spectra &spectra) override; void removeWorkspace(TableDatasetIndex index) override; void setResolution(const std::string &name, TableDatasetIndex index); - void setResolution(Mantid::API::MatrixWorkspace_sptr resolution, + void setResolution(const Mantid::API::MatrixWorkspace_sptr &resolution, TableDatasetIndex index); void setFitTypeString(const std::string &fitType); diff --git a/qt/scientific_interfaces/Indirect/CorrectionsTab.cpp b/qt/scientific_interfaces/Indirect/CorrectionsTab.cpp index 20f11e3de5e34d0b37ce2d58ab8ac0605d9d16c5..4e0918d4721826aa247bf0c2faa7dffb9aae52d6 100644 --- a/qt/scientific_interfaces/Indirect/CorrectionsTab.cpp +++ b/qt/scientific_interfaces/Indirect/CorrectionsTab.cpp @@ -74,7 +74,8 @@ void CorrectionsTab::inputChanged() { validate(); } * @throws std::runtime_error if one of the workspaces is an invalid pointer */ bool CorrectionsTab::checkWorkspaceBinningMatches( - MatrixWorkspace_const_sptr left, MatrixWorkspace_const_sptr right) { + const MatrixWorkspace_const_sptr &left, + const MatrixWorkspace_const_sptr &right) { if (left && right) // check the workspaces actually point to something first { const auto &leftX = left->x(0); @@ -100,7 +101,7 @@ bool CorrectionsTab::checkWorkspaceBinningMatches( * @return Name of output workspace */ boost::optional<std::string> CorrectionsTab::addConvertUnitsStep( - MatrixWorkspace_sptr ws, std::string const &unitID, + const MatrixWorkspace_sptr &ws, std::string const &unitID, std::string const &suffix, std::string eMode, double eFixed) { std::string outputName = ws->getName(); diff --git a/qt/scientific_interfaces/Indirect/CorrectionsTab.h b/qt/scientific_interfaces/Indirect/CorrectionsTab.h index c26de73e64e36d64fea6d9b551cb04c2d0a52161..665934445bcc4a3edcbe1dd214e93006743fd849 100644 --- a/qt/scientific_interfaces/Indirect/CorrectionsTab.h +++ b/qt/scientific_interfaces/Indirect/CorrectionsTab.h @@ -84,12 +84,12 @@ public: protected: /// Check the binning between two workspaces match - bool - checkWorkspaceBinningMatches(Mantid::API::MatrixWorkspace_const_sptr left, - Mantid::API::MatrixWorkspace_const_sptr right); + bool checkWorkspaceBinningMatches( + const Mantid::API::MatrixWorkspace_const_sptr &left, + const Mantid::API::MatrixWorkspace_const_sptr &right); /// Adds a unit conversion step to the algorithm queue boost::optional<std::string> - addConvertUnitsStep(Mantid::API::MatrixWorkspace_sptr ws, + addConvertUnitsStep(const Mantid::API::MatrixWorkspace_sptr &ws, const std::string &unitID, const std::string &suffix = "UNIT", std::string eMode = "", double eFixed = 0.0); diff --git a/qt/scientific_interfaces/Indirect/Elwin.cpp b/qt/scientific_interfaces/Indirect/Elwin.cpp index d25764868d2af036ae9a1d7863bd30a51b3baea0..93bece3aef0dadd4e4e24ea08a49bf518b33fd79 100644 --- a/qt/scientific_interfaces/Indirect/Elwin.cpp +++ b/qt/scientific_interfaces/Indirect/Elwin.cpp @@ -384,8 +384,9 @@ void Elwin::setFileExtensionsByName(bool filter) { : getExtensions(tabName)); } -void Elwin::setDefaultResolution(Mantid::API::MatrixWorkspace_const_sptr ws, - const QPair<double, double> &range) { +void Elwin::setDefaultResolution( + const Mantid::API::MatrixWorkspace_const_sptr &ws, + const QPair<double, double> &range) { auto inst = ws->getInstrument(); auto analyser = inst->getStringParameter("analyser"); @@ -414,7 +415,8 @@ void Elwin::setDefaultResolution(Mantid::API::MatrixWorkspace_const_sptr ws, } } -void Elwin::setDefaultSampleLog(Mantid::API::MatrixWorkspace_const_sptr ws) { +void Elwin::setDefaultSampleLog( + const Mantid::API::MatrixWorkspace_const_sptr &ws) { auto inst = ws->getInstrument(); // Set sample environment log name auto log = inst->getStringParameter("Workflow.SE-log"); diff --git a/qt/scientific_interfaces/Indirect/Elwin.h b/qt/scientific_interfaces/Indirect/Elwin.h index 0c66b5b6805645f5c0e37be30410246314f57b9f..40a87b96c83f3d9eab47a06b5b10efe91b7d1cab 100644 --- a/qt/scientific_interfaces/Indirect/Elwin.h +++ b/qt/scientific_interfaces/Indirect/Elwin.h @@ -40,9 +40,9 @@ private: void loadSettings(const QSettings &settings) override; void setFileExtensionsByName(bool filter) override; void setBrowserWorkspace() override{}; - void setDefaultResolution(Mantid::API::MatrixWorkspace_const_sptr ws, + void setDefaultResolution(const Mantid::API::MatrixWorkspace_const_sptr &ws, const QPair<double, double> &range); - void setDefaultSampleLog(Mantid::API::MatrixWorkspace_const_sptr ws); + void setDefaultSampleLog(const Mantid::API::MatrixWorkspace_const_sptr &ws); void checkForELTWorkspace(); diff --git a/qt/scientific_interfaces/Indirect/ILLEnergyTransfer.cpp b/qt/scientific_interfaces/Indirect/ILLEnergyTransfer.cpp index bb56ecc89ac898a31cabbb28e7ae0f7700f7fbab..6da405dd977e1510631c9656e1c4cb393a9ec467 100644 --- a/qt/scientific_interfaces/Indirect/ILLEnergyTransfer.cpp +++ b/qt/scientific_interfaces/Indirect/ILLEnergyTransfer.cpp @@ -386,8 +386,8 @@ void ILLEnergyTransfer::setRunEnabled(bool enabled) { void ILLEnergyTransfer::updateRunButton(bool enabled, std::string const &enableOutputButtons, - QString const message, - QString const tooltip) { + QString const &message, + QString const &tooltip) { UNUSED_ARG(enableOutputButtons); setRunEnabled(enabled); m_uiForm.pbRun->setText(message); diff --git a/qt/scientific_interfaces/Indirect/ILLEnergyTransfer.h b/qt/scientific_interfaces/Indirect/ILLEnergyTransfer.h index c7f253575a4f14e4b721877fa56e78846d4f4090..3ac3e459575fa4b99278b0d04455f98dbd702b94 100644 --- a/qt/scientific_interfaces/Indirect/ILLEnergyTransfer.h +++ b/qt/scientific_interfaces/Indirect/ILLEnergyTransfer.h @@ -39,8 +39,8 @@ private slots: void setRunEnabled(bool enabled); void updateRunButton(bool enabled = true, std::string const &enableOutputButtons = "unchanged", - QString const message = "Run", - QString const tooltip = ""); + QString const &message = "Run", + QString const &tooltip = ""); private: Ui::ILLEnergyTransfer m_uiForm; diff --git a/qt/scientific_interfaces/Indirect/ISISCalibration.cpp b/qt/scientific_interfaces/Indirect/ISISCalibration.cpp index d4b0a47ae2657d118b9b66f24e46f19387ef27da..fb906d2b395162ec0dc1a1e4f23e974fe4c09d92 100644 --- a/qt/scientific_interfaces/Indirect/ISISCalibration.cpp +++ b/qt/scientific_interfaces/Indirect/ISISCalibration.cpp @@ -522,7 +522,8 @@ void ISISCalibration::calPlotEnergy() { * * @param ws :: Mantid workspace containing the loaded instrument */ -void ISISCalibration::calSetDefaultResolution(MatrixWorkspace_const_sptr ws) { +void ISISCalibration::calSetDefaultResolution( + const MatrixWorkspace_const_sptr &ws) { auto inst = ws->getInstrument(); auto analyser = inst->getStringParameter("analyser"); @@ -816,8 +817,8 @@ void ISISCalibration::setSaveEnabled(bool enabled) { void ISISCalibration::updateRunButton(bool enabled, std::string const &enableOutputButtons, - QString const message, - QString const tooltip) { + QString const &message, + QString const &tooltip) { setRunEnabled(enabled); m_uiForm.pbRun->setText(message); m_uiForm.pbRun->setToolTip(tooltip); diff --git a/qt/scientific_interfaces/Indirect/ISISCalibration.h b/qt/scientific_interfaces/Indirect/ISISCalibration.h index 945cce8711717fcdb3244dda3bf13f8161a21793..1aa3634d6c230ccc5d8b8db5595b045aa0cd9680 100644 --- a/qt/scientific_interfaces/Indirect/ISISCalibration.h +++ b/qt/scientific_interfaces/Indirect/ISISCalibration.h @@ -56,7 +56,8 @@ private slots: void calMinChanged(double /*val*/); void calMaxChanged(double /*val*/); void calUpdateRS(QtProperty * /*prop*/, double /*val*/); - void calSetDefaultResolution(Mantid::API::MatrixWorkspace_const_sptr ws); + void + calSetDefaultResolution(const Mantid::API::MatrixWorkspace_const_sptr &ws); void resCheck(bool state); ///< handles checking/unchecking of "Create RES /// File" checkbox void setDefaultInstDetails(); @@ -73,8 +74,8 @@ private slots: void setSaveEnabled(bool enabled); void updateRunButton(bool enabled = true, std::string const &enableOutputButtons = "unchanged", - QString const message = "Run", - QString const tooltip = ""); + QString const &message = "Run", + QString const &tooltip = ""); private: void setDefaultInstDetails(QMap<QString, QString> const &instrumentDetails); diff --git a/qt/scientific_interfaces/Indirect/ISISDiagnostics.cpp b/qt/scientific_interfaces/Indirect/ISISDiagnostics.cpp index a238b385ee1b78a97ef12de870258cbdd7d8f3ed..df670758704a45bc0565008083b6efd6e99c69b8 100644 --- a/qt/scientific_interfaces/Indirect/ISISDiagnostics.cpp +++ b/qt/scientific_interfaces/Indirect/ISISDiagnostics.cpp @@ -561,8 +561,8 @@ void ISISDiagnostics::setSaveEnabled(bool enabled) { void ISISDiagnostics::updateRunButton(bool enabled, std::string const &enableOutputButtons, - QString const message, - QString const tooltip) { + QString const &message, + QString const &tooltip) { setRunEnabled(enabled); m_uiForm.pbRun->setText(message); m_uiForm.pbRun->setToolTip(tooltip); diff --git a/qt/scientific_interfaces/Indirect/ISISDiagnostics.h b/qt/scientific_interfaces/Indirect/ISISDiagnostics.h index e40fd3f1f6890af1f95cbbc84716c4786e337ccd..05cb96df8ed99bc7dfe682761f2bb765eeae3621 100644 --- a/qt/scientific_interfaces/Indirect/ISISDiagnostics.h +++ b/qt/scientific_interfaces/Indirect/ISISDiagnostics.h @@ -69,8 +69,8 @@ private slots: void setSaveEnabled(bool enabled); void updateRunButton(bool enabled = true, std::string const &enableOutputButtons = "unchanged", - QString const message = "Run", - QString const tooltip = ""); + QString const &message = "Run", + QString const &tooltip = ""); private: void setDefaultInstDetails(QMap<QString, QString> const &instrumentDetails); diff --git a/qt/scientific_interfaces/Indirect/ISISEnergyTransfer.cpp b/qt/scientific_interfaces/Indirect/ISISEnergyTransfer.cpp index 24c5e4b661d1cadf442bfc4b00d492bf777269b9..71bf58cb7d69dec92a7507df1729b400e167c591 100644 --- a/qt/scientific_interfaces/Indirect/ISISEnergyTransfer.cpp +++ b/qt/scientific_interfaces/Indirect/ISISEnergyTransfer.cpp @@ -115,7 +115,7 @@ void deleteWorkspace(std::string const &name) { deleter->execute(); } -double getSampleLog(MatrixWorkspace_const_sptr workspace, +double getSampleLog(const MatrixWorkspace_const_sptr &workspace, std::string const &logName, double const &defaultValue) { try { return workspace->getLogAsSingleValue(logName); @@ -124,7 +124,7 @@ double getSampleLog(MatrixWorkspace_const_sptr workspace, } } -double getSampleLog(MatrixWorkspace_const_sptr workspace, +double getSampleLog(const MatrixWorkspace_const_sptr &workspace, std::vector<std::string> const &logNames, double const &defaultValue) { double value(defaultValue); @@ -1014,8 +1014,8 @@ void ISISEnergyTransfer::setSaveEnabled(bool enable) { void ISISEnergyTransfer::updateRunButton(bool enabled, std::string const &enableOutputButtons, - QString const message, - QString const tooltip) { + QString const &message, + QString const &tooltip) { setRunEnabled(enabled); m_uiForm.pbRun->setText(message); m_uiForm.pbRun->setToolTip(tooltip); diff --git a/qt/scientific_interfaces/Indirect/ISISEnergyTransfer.h b/qt/scientific_interfaces/Indirect/ISISEnergyTransfer.h index c0b547acf0c4ee3825e8feecca75c377f930872e..3dfcca5b65964320f1ea7ad38e5c213c81552b1a 100644 --- a/qt/scientific_interfaces/Indirect/ISISEnergyTransfer.h +++ b/qt/scientific_interfaces/Indirect/ISISEnergyTransfer.h @@ -60,8 +60,8 @@ private slots: void updateRunButton(bool enabled = true, std::string const &enableOutputButtons = "unchanged", - QString const message = "Run", - QString const tooltip = ""); + QString const &message = "Run", + QString const &tooltip = ""); private: void setInstrumentDefault(QMap<QString, QString> const &instDetails); diff --git a/qt/scientific_interfaces/Indirect/IndirectAddWorkspaceDialog.cpp b/qt/scientific_interfaces/Indirect/IndirectAddWorkspaceDialog.cpp index 3fe56ac1f40f36d69d4ea2d64e326a81f2b5cd82..9917de6f81633485fb416e6579323ad942267bfa 100644 --- a/qt/scientific_interfaces/Indirect/IndirectAddWorkspaceDialog.cpp +++ b/qt/scientific_interfaces/Indirect/IndirectAddWorkspaceDialog.cpp @@ -10,6 +10,7 @@ #include "MantidAPI/MatrixWorkspace.h" #include <boost/optional.hpp> +#include <utility> namespace { using namespace Mantid::API; @@ -26,7 +27,8 @@ bool validWorkspace(std::string const &name) { return !name.empty() && doesExistInADS(name); } -boost::optional<std::size_t> maximumIndex(MatrixWorkspace_sptr workspace) { +boost::optional<std::size_t> +maximumIndex(const MatrixWorkspace_sptr &workspace) { if (workspace) { const auto numberOfHistograms = workspace->getNumberHistograms(); if (numberOfHistograms > 0) @@ -35,8 +37,8 @@ boost::optional<std::size_t> maximumIndex(MatrixWorkspace_sptr workspace) { return boost::none; } -QString getIndexString(MatrixWorkspace_sptr workspace) { - const auto maximum = maximumIndex(workspace); +QString getIndexString(const MatrixWorkspace_sptr &workspace) { + const auto maximum = maximumIndex(std::move(workspace)); if (maximum) { if (*maximum > 0) return QString("0-%1").arg(*maximum); diff --git a/qt/scientific_interfaces/Indirect/IndirectBayesTab.cpp b/qt/scientific_interfaces/Indirect/IndirectBayesTab.cpp index 050001f810f021eeaa47d54d14015cf47e2eb011..8d7484a3a3f81e6868d9deaa9841100fab83ddcf 100644 --- a/qt/scientific_interfaces/Indirect/IndirectBayesTab.cpp +++ b/qt/scientific_interfaces/Indirect/IndirectBayesTab.cpp @@ -14,6 +14,7 @@ IndirectBayesTab::IndirectBayesTab(QWidget *parent) m_propTree->setFactoryForManager(m_dblManager, m_dblEdFac); connect(m_dblManager, SIGNAL(valueChanged(QtProperty *, double)), this, + // cppcheck-suppress pureVirtualCall SLOT(updateProperties(QtProperty *, double))); } diff --git a/qt/scientific_interfaces/Indirect/IndirectDataAnalysisTab.cpp b/qt/scientific_interfaces/Indirect/IndirectDataAnalysisTab.cpp index a1709e90c81db1ed5d26bbdb39feac1a8f6180b8..ff7996578005feba4f433f1de35a31c00d5f8594 100644 --- a/qt/scientific_interfaces/Indirect/IndirectDataAnalysisTab.cpp +++ b/qt/scientific_interfaces/Indirect/IndirectDataAnalysisTab.cpp @@ -15,6 +15,7 @@ #include <QSettings> #include <QString> +#include <utility> using namespace Mantid::API; @@ -92,7 +93,7 @@ MatrixWorkspace_sptr IndirectDataAnalysisTab::inputWorkspace() const { */ void IndirectDataAnalysisTab::setInputWorkspace( MatrixWorkspace_sptr inputWorkspace) { - m_inputWorkspace = inputWorkspace; + m_inputWorkspace = std::move(inputWorkspace); } /** @@ -113,7 +114,7 @@ MatrixWorkspace_sptr IndirectDataAnalysisTab::previewPlotWorkspace() { * @param previewPlotWorkspace The workspace to set. */ void IndirectDataAnalysisTab::setPreviewPlotWorkspace( - MatrixWorkspace_sptr previewPlotWorkspace) { + const MatrixWorkspace_sptr &previewPlotWorkspace) { m_previewPlotWorkspace = previewPlotWorkspace; } @@ -262,7 +263,7 @@ void IndirectDataAnalysisTab::updatePlot( * @param diffPreviewPlot The difference preview plot. */ void IndirectDataAnalysisTab::updatePlot( - WorkspaceGroup_sptr outputWS, size_t index, + const WorkspaceGroup_sptr &outputWS, size_t index, MantidQt::MantidWidgets::PreviewPlot *fitPreviewPlot, MantidQt::MantidWidgets::PreviewPlot *diffPreviewPlot) { // Check whether the specified index is within the bounds of the @@ -318,7 +319,7 @@ void IndirectDataAnalysisTab::updatePlot( * @param diffPreviewPlot The difference preview plot. */ void IndirectDataAnalysisTab::updatePlot( - WorkspaceGroup_sptr outputWS, + const WorkspaceGroup_sptr &outputWS, MantidQt::MantidWidgets::PreviewPlot *fitPreviewPlot, MantidQt::MantidWidgets::PreviewPlot *diffPreviewPlot) { if (outputWS && selectedSpectrum() >= minimumSpectrum() && @@ -339,7 +340,7 @@ void IndirectDataAnalysisTab::updatePlot( * @param diffPreviewPlot The difference preview plot. */ void IndirectDataAnalysisTab::updatePlot( - MatrixWorkspace_sptr outputWS, + const MatrixWorkspace_sptr &outputWS, MantidQt::MantidWidgets::PreviewPlot *fitPreviewPlot, MantidQt::MantidWidgets::PreviewPlot *diffPreviewPlot) { fitPreviewPlot->clear(); diff --git a/qt/scientific_interfaces/Indirect/IndirectDataAnalysisTab.h b/qt/scientific_interfaces/Indirect/IndirectDataAnalysisTab.h index 9c2b956c77fd33308c167bf966062a993237e362..beb59db18d80a1d1daf5cd98d6fc724f252291f2 100644 --- a/qt/scientific_interfaces/Indirect/IndirectDataAnalysisTab.h +++ b/qt/scientific_interfaces/Indirect/IndirectDataAnalysisTab.h @@ -90,7 +90,7 @@ protected: /// Set preview plot workspace void setPreviewPlotWorkspace( - Mantid::API::MatrixWorkspace_sptr previewPlotWorkspace); + const Mantid::API::MatrixWorkspace_sptr &previewPlotWorkspace); /// Retrieve the selected spectrum int selectedSpectrum() const; @@ -110,11 +110,12 @@ protected: MantidQt::MantidWidgets::PreviewPlot *fitPreviewPlot, MantidQt::MantidWidgets::PreviewPlot *diffPreviewPlot); - void updatePlot(Mantid::API::WorkspaceGroup_sptr workspaceGroup, size_t index, + void updatePlot(const Mantid::API::WorkspaceGroup_sptr &workspaceGroup, + size_t index, MantidQt::MantidWidgets::PreviewPlot *fitPreviewPlot, MantidQt::MantidWidgets::PreviewPlot *diffPreviewPlot); - void updatePlot(Mantid::API::WorkspaceGroup_sptr outputWS, + void updatePlot(const Mantid::API::WorkspaceGroup_sptr &outputWS, MantidQt::MantidWidgets::PreviewPlot *fitPreviewPlot, MantidQt::MantidWidgets::PreviewPlot *diffPreviewPlot); @@ -122,7 +123,7 @@ protected: MantidQt::MantidWidgets::PreviewPlot *fitPreviewPlot, MantidQt::MantidWidgets::PreviewPlot *diffPreviewPlot); - void updatePlot(Mantid::API::MatrixWorkspace_sptr outputWS, + void updatePlot(const Mantid::API::MatrixWorkspace_sptr &outputWS, MantidQt::MantidWidgets::PreviewPlot *fitPreviewPlot, MantidQt::MantidWidgets::PreviewPlot *diffPreviewPlot); diff --git a/qt/scientific_interfaces/Indirect/IndirectDataReduction.cpp b/qt/scientific_interfaces/Indirect/IndirectDataReduction.cpp index e785ece295abd8a11768ec4ce49dd3d9bc535a93..61b659e070469ecb332a0382c298d28c3f386424 100644 --- a/qt/scientific_interfaces/Indirect/IndirectDataReduction.cpp +++ b/qt/scientific_interfaces/Indirect/IndirectDataReduction.cpp @@ -316,7 +316,8 @@ void IndirectDataReduction::loadInstrumentDetails() { * @return Value as QString */ QString IndirectDataReduction::getInstrumentParameterFrom( - Mantid::Geometry::IComponent_const_sptr comp, std::string param) { + const Mantid::Geometry::IComponent_const_sptr &comp, + const std::string ¶m) { QString value; if (!comp->hasParameter(param)) { @@ -445,7 +446,7 @@ void IndirectDataReduction::saveSettings() { * * @param facility Name of facility */ -void IndirectDataReduction::filterUiForFacility(QString facility) { +void IndirectDataReduction::filterUiForFacility(const QString &facility) { g_log.information() << "Facility selected: " << facility.toStdString() << '\n'; QStringList enabledTabs; diff --git a/qt/scientific_interfaces/Indirect/IndirectDataReduction.h b/qt/scientific_interfaces/Indirect/IndirectDataReduction.h index 9cd0cbfbba9749736b19018993d942b95e9d1681..582b93441d3b6f16bf63f87818e23e7863b3f85e 100644 --- a/qt/scientific_interfaces/Indirect/IndirectDataReduction.h +++ b/qt/scientific_interfaces/Indirect/IndirectDataReduction.h @@ -69,7 +69,7 @@ signals: private slots: /// Shows/hides tabs based on facility - void filterUiForFacility(QString facility); + void filterUiForFacility(const QString &facility); /// Exports the current tab algorithms as a Python script void exportTabPython(); @@ -89,9 +89,9 @@ private: void loadInstrumentDetails(); - QString - getInstrumentParameterFrom(Mantid::Geometry::IComponent_const_sptr comp, - std::string param); + QString getInstrumentParameterFrom( + const Mantid::Geometry::IComponent_const_sptr &comp, + const std::string ¶m); void readSettings(); void saveSettings(); diff --git a/qt/scientific_interfaces/Indirect/IndirectDataTablePresenter.cpp b/qt/scientific_interfaces/Indirect/IndirectDataTablePresenter.cpp index eafa0818ac2602c7720bc0e980956fd4a3c0cc5c..3039804bcef9a0a3ee99b0f86988a388e6616e3e 100644 --- a/qt/scientific_interfaces/Indirect/IndirectDataTablePresenter.cpp +++ b/qt/scientific_interfaces/Indirect/IndirectDataTablePresenter.cpp @@ -216,11 +216,11 @@ IndirectDataTablePresenter::getSpectra(TableRowIndex start, while (start < end) { WorkspaceIndex minimum = getWorkspaceIndex(start); WorkspaceIndex maximum = minimum; - start++; + ++start; while (start < end && getWorkspaceIndex(start) == maximum + WorkspaceIndex{1}) { ++maximum; - start++; + ++start; } spectraPairs.emplace_back(minimum, maximum); } diff --git a/qt/scientific_interfaces/Indirect/IndirectDiffractionReduction.cpp b/qt/scientific_interfaces/Indirect/IndirectDiffractionReduction.cpp index e40aa619cc172ce040e69f839462a780a2966c09..6ae644b2f730c022931243fe0840e34e7c3d3e72 100644 --- a/qt/scientific_interfaces/Indirect/IndirectDiffractionReduction.cpp +++ b/qt/scientific_interfaces/Indirect/IndirectDiffractionReduction.cpp @@ -354,8 +354,8 @@ IAlgorithm_sptr IndirectDiffractionReduction::convertUnitsAlgorithm( * @param instName Name of the instrument * @param mode Mode instrument is operating in (diffspec/diffonly) */ -void IndirectDiffractionReduction::runGenericReduction(QString instName, - QString mode) { +void IndirectDiffractionReduction::runGenericReduction(const QString &instName, + const QString &mode) { QString rebinStart = ""; QString rebinWidth = ""; diff --git a/qt/scientific_interfaces/Indirect/IndirectDiffractionReduction.h b/qt/scientific_interfaces/Indirect/IndirectDiffractionReduction.h index 03c119a5a6f15a0a08c62529797480df7dae62f2..8e9e8aafd85849fa8a3458d7d3e9b12e52abfe54 100644 --- a/qt/scientific_interfaces/Indirect/IndirectDiffractionReduction.h +++ b/qt/scientific_interfaces/Indirect/IndirectDiffractionReduction.h @@ -79,7 +79,7 @@ private: loadInstrument(const std::string &instrumentName, const std::string &reflection = ""); - void runGenericReduction(QString instName, QString mode); + void runGenericReduction(const QString &instName, const QString &mode); void connectRunButtonValidation(const MantidQt::API::MWRunFiles *file_field); void runOSIRISdiffonlyReduction(); void createGroupingWorkspace(const std::string &outputWsName); diff --git a/qt/scientific_interfaces/Indirect/IndirectFitAnalysisTab.cpp b/qt/scientific_interfaces/Indirect/IndirectFitAnalysisTab.cpp index d87a94d8b5f13542c170ba9fcd36c6b681f396f7..4c4793df70b4e6c6751bc9779bd44e1451af1812 100644 --- a/qt/scientific_interfaces/Indirect/IndirectFitAnalysisTab.cpp +++ b/qt/scientific_interfaces/Indirect/IndirectFitAnalysisTab.cpp @@ -19,6 +19,7 @@ #include <QtCore> #include <algorithm> +#include <utility> /// Logger Mantid::Kernel::Logger g_log("IndirectFitAnalysisTab"); @@ -643,7 +644,7 @@ void IndirectFitAnalysisTab::setEditResultVisible(bool visible) { } void IndirectFitAnalysisTab::setAlgorithmProperties( - IAlgorithm_sptr fitAlgorithm) const { + const IAlgorithm_sptr &fitAlgorithm) const { fitAlgorithm->setProperty("Minimizer", m_fitPropertyBrowser->minimizer(true)); fitAlgorithm->setProperty("MaxIterations", m_fitPropertyBrowser->maxIterations()); @@ -674,14 +675,14 @@ void IndirectFitAnalysisTab::setAlgorithmProperties( void IndirectFitAnalysisTab::runFitAlgorithm(IAlgorithm_sptr fitAlgorithm) { connect(m_batchAlgoRunner, SIGNAL(batchComplete(bool)), this, SLOT(updateFitOutput(bool))); - setupFit(fitAlgorithm); + setupFit(std::move(fitAlgorithm)); m_batchAlgoRunner->executeBatchAsync(); } void IndirectFitAnalysisTab::runSingleFit(IAlgorithm_sptr fitAlgorithm) { connect(m_batchAlgoRunner, SIGNAL(batchComplete(bool)), this, SLOT(updateSingleFitOutput(bool))); - setupFit(fitAlgorithm); + setupFit(std::move(fitAlgorithm)); m_batchAlgoRunner->executeBatchAsync(); } diff --git a/qt/scientific_interfaces/Indirect/IndirectFitAnalysisTab.h b/qt/scientific_interfaces/Indirect/IndirectFitAnalysisTab.h index d18221f9fcbe6315f8000cca6a304b532798dce6..001d4335225586f3044943a968874f1b9003f65d 100644 --- a/qt/scientific_interfaces/Indirect/IndirectFitAnalysisTab.h +++ b/qt/scientific_interfaces/Indirect/IndirectFitAnalysisTab.h @@ -71,7 +71,8 @@ protected: void setSampleSuffixes(std::string const &tab, bool filter); void setResolutionSuffixes(std::string const &tab, bool filter); - void setAlgorithmProperties(Mantid::API::IAlgorithm_sptr fitAlgorithm) const; + void setAlgorithmProperties( + const Mantid::API::IAlgorithm_sptr &fitAlgorithm) const; void runFitAlgorithm(Mantid::API::IAlgorithm_sptr fitAlgorithm); void runSingleFit(Mantid::API::IAlgorithm_sptr fitAlgorithm); virtual void setupFit(Mantid::API::IAlgorithm_sptr fitAlgorithm); diff --git a/qt/scientific_interfaces/Indirect/IndirectFitAnalysisTabLegacy.cpp b/qt/scientific_interfaces/Indirect/IndirectFitAnalysisTabLegacy.cpp index bc22a7f659a9eefea54ba620098e15654f3d2b3a..02d0163c5e8e5afb4fff36f80fe9d293ca31d026 100644 --- a/qt/scientific_interfaces/Indirect/IndirectFitAnalysisTabLegacy.cpp +++ b/qt/scientific_interfaces/Indirect/IndirectFitAnalysisTabLegacy.cpp @@ -21,6 +21,7 @@ #include <QtCore> #include <algorithm> +#include <utility> using namespace Mantid::API; @@ -37,7 +38,7 @@ WorkspaceGroup_sptr getADSGroupWorkspace(std::string const &workspaceName) { } void updateParameters( - IFunction_sptr function, + const IFunction_sptr &function, std::unordered_map<std::string, ParameterValueLegacy> const ¶meters) { for (auto i = 0u; i < function->nParams(); ++i) { auto const value = parameters.find(function->parameterName(i)); @@ -50,7 +51,8 @@ void updateParameters( } void updateAttributes( - IFunction_sptr function, std::vector<std::string> const &attributeNames, + const IFunction_sptr &function, + std::vector<std::string> const &attributeNames, std::unordered_map<std::string, IFunction::Attribute> const &attributes) { for (const auto &attributeName : attributeNames) { auto const value = attributes.find(attributeName); @@ -807,17 +809,19 @@ void IndirectFitAnalysisTabLegacy::updateAttributeValues() { * @param attributeNames The attributes to update */ void IndirectFitAnalysisTabLegacy::updateAttributeValues( - IFunction_sptr function, std::vector<std::string> const &attributeNames) { + const IFunction_sptr &function, + std::vector<std::string> const &attributeNames) { auto const attributes = getAttributes(function, attributeNames); if (!attributes.empty()) updateAttributeValues(function, attributeNames, attributes); } void IndirectFitAnalysisTabLegacy::updateAttributeValues( - IFunction_sptr fitFunction, std::vector<std::string> const &attributeNames, + const IFunction_sptr &fitFunction, + std::vector<std::string> const &attributeNames, std::unordered_map<std::string, IFunction::Attribute> const &attributes) { try { - updateAttributes(fitFunction, attributeNames, attributes); + updateAttributes(std::move(fitFunction), attributeNames, attributes); updateFitBrowserAttributeValues(); } catch (const std::runtime_error &) { showMessageBox("An unexpected error occured:\n The setting of attribute " @@ -1067,7 +1071,7 @@ void IndirectFitAnalysisTabLegacy::setEditResultVisible(bool visible) { } void IndirectFitAnalysisTabLegacy::setAlgorithmProperties( - IAlgorithm_sptr fitAlgorithm) const { + const IAlgorithm_sptr &fitAlgorithm) const { fitAlgorithm->setProperty("Minimizer", m_fitPropertyBrowser->minimizer(true)); fitAlgorithm->setProperty("MaxIterations", m_fitPropertyBrowser->maxIterations()); @@ -1094,14 +1098,14 @@ void IndirectFitAnalysisTabLegacy::runFitAlgorithm( IAlgorithm_sptr fitAlgorithm) { connect(m_batchAlgoRunner, SIGNAL(batchComplete(bool)), this, SLOT(updateFitOutput(bool))); - setupFit(fitAlgorithm); + setupFit(std::move(fitAlgorithm)); m_batchAlgoRunner->executeBatchAsync(); } void IndirectFitAnalysisTabLegacy::runSingleFit(IAlgorithm_sptr fitAlgorithm) { connect(m_batchAlgoRunner, SIGNAL(batchComplete(bool)), this, SLOT(updateSingleFitOutput(bool))); - setupFit(fitAlgorithm); + setupFit(std::move(fitAlgorithm)); m_batchAlgoRunner->executeBatchAsync(); } diff --git a/qt/scientific_interfaces/Indirect/IndirectFitAnalysisTabLegacy.h b/qt/scientific_interfaces/Indirect/IndirectFitAnalysisTabLegacy.h index afcd92bf5275fd8a90e00fedc3c5ecafaa89c05c..0deb72aedee5bfbe11213310bac15a59038ff50a 100644 --- a/qt/scientific_interfaces/Indirect/IndirectFitAnalysisTabLegacy.h +++ b/qt/scientific_interfaces/Indirect/IndirectFitAnalysisTabLegacy.h @@ -131,7 +131,8 @@ protected: void setResolutionWSSuffixes(const QStringList &suffices); void setResolutionFBSuffixes(const QStringList &suffices); - void setAlgorithmProperties(Mantid::API::IAlgorithm_sptr fitAlgorithm) const; + void setAlgorithmProperties( + const Mantid::API::IAlgorithm_sptr &fitAlgorithm) const; void runFitAlgorithm(Mantid::API::IAlgorithm_sptr fitAlgorithm); void runSingleFit(Mantid::API::IAlgorithm_sptr fitAlgorithm); virtual void setupFit(Mantid::API::IAlgorithm_sptr fitAlgorithm); @@ -176,10 +177,10 @@ protected slots: void executeFit(); void updateAttributeValues(); - void updateAttributeValues(Mantid::API::IFunction_sptr function, + void updateAttributeValues(const Mantid::API::IFunction_sptr &function, std::vector<std::string> const &attributeNames); void updateAttributeValues( - Mantid::API::IFunction_sptr function, + const Mantid::API::IFunction_sptr &function, std::vector<std::string> const &attributeNames, std::unordered_map<std::string, Mantid::API::IFunction::Attribute> const &attributes); diff --git a/qt/scientific_interfaces/Indirect/IndirectFitData.cpp b/qt/scientific_interfaces/Indirect/IndirectFitData.cpp index f81b02c69a2b0ac7e1424f35827b051a74fe9fda..d3cddcda4766c4d18cf2a7c21cc1bac2199bd367 100644 --- a/qt/scientific_interfaces/Indirect/IndirectFitData.cpp +++ b/qt/scientific_interfaces/Indirect/IndirectFitData.cpp @@ -29,7 +29,7 @@ using namespace Mantid::Kernel::Strings; * them. * @param workspace workspace possibly containing Q values. */ -std::vector<double> extractQValues(const MatrixWorkspace_sptr workspace, +std::vector<double> extractQValues(const MatrixWorkspace_sptr &workspace, const Spectra &spectra) { std::vector<double> qs; // Check if the vertical axis has units of momentum transfer, then extract Q @@ -143,7 +143,7 @@ tryPassFormatArgument(boost::basic_format<char> &formatString, } } -std::pair<double, double> getBinRange(MatrixWorkspace_sptr workspace) { +std::pair<double, double> getBinRange(const MatrixWorkspace_sptr &workspace) { return std::make_pair(workspace->x(0).front(), workspace->x(0).back()); } @@ -296,7 +296,7 @@ void Spectra::checkContinuous() { } } -IndirectFitData::IndirectFitData(MatrixWorkspace_sptr workspace, +IndirectFitData::IndirectFitData(const MatrixWorkspace_sptr &workspace, const Spectra &spectra) : m_workspace(workspace), m_spectra(Spectra("")) { setSpectra(spectra); diff --git a/qt/scientific_interfaces/Indirect/IndirectFitData.h b/qt/scientific_interfaces/Indirect/IndirectFitData.h index 58913cc934b0a11c17b3f408852b2a429e251c77..41f44de2b63bd2dc647491451cb2c52271d831ff 100644 --- a/qt/scientific_interfaces/Indirect/IndirectFitData.h +++ b/qt/scientific_interfaces/Indirect/IndirectFitData.h @@ -108,7 +108,7 @@ std::vector<T> vectorFromString(const std::string &listString) { */ class MANTIDQT_INDIRECT_DLL IndirectFitData { public: - IndirectFitData(Mantid::API::MatrixWorkspace_sptr workspace, + IndirectFitData(const Mantid::API::MatrixWorkspace_sptr &workspace, const Spectra &spectra); std::string displayName(const std::string &formatString, diff --git a/qt/scientific_interfaces/Indirect/IndirectFitDataLegacy.cpp b/qt/scientific_interfaces/Indirect/IndirectFitDataLegacy.cpp index f8735143ada34fea30a25ced287ab7dd9de71728..f54ed01a18df09584bc532223514f8970f740611 100644 --- a/qt/scientific_interfaces/Indirect/IndirectFitDataLegacy.cpp +++ b/qt/scientific_interfaces/Indirect/IndirectFitDataLegacy.cpp @@ -12,6 +12,7 @@ #include <boost/format.hpp> #include <sstream> +#include <utility> using namespace Mantid::API; @@ -227,7 +228,7 @@ tryPassFormatArgument(boost::basic_format<char> &formatString, } } -std::pair<double, double> getBinRange(MatrixWorkspace_sptr workspace) { +std::pair<double, double> getBinRange(const MatrixWorkspace_sptr &workspace) { return std::make_pair(workspace->x(0).front(), workspace->x(0).back()); } @@ -275,7 +276,8 @@ namespace IDA { IndirectFitDataLegacy::IndirectFitDataLegacy(MatrixWorkspace_sptr workspace, const SpectraLegacy &spectra) - : m_workspace(workspace), m_spectra(DiscontinuousSpectra<std::size_t>("")) { + : m_workspace(std::move(workspace)), + m_spectra(DiscontinuousSpectra<std::size_t>("")) { setSpectra(spectra); } diff --git a/qt/scientific_interfaces/Indirect/IndirectFitDataPresenter.cpp b/qt/scientific_interfaces/Indirect/IndirectFitDataPresenter.cpp index 2d926e32acb9203086fbefb8a3987fb89d6175a9..0c6eb63abff0431ec2ad08ff2f0f229b6e1ca7dd 100644 --- a/qt/scientific_interfaces/Indirect/IndirectFitDataPresenter.cpp +++ b/qt/scientific_interfaces/Indirect/IndirectFitDataPresenter.cpp @@ -5,6 +5,9 @@ // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + #include "IndirectFitDataPresenter.h" + +#include <utility> + #include "IndirectAddWorkspaceDialog.h" namespace MantidQt { @@ -208,8 +211,8 @@ void IndirectFitDataPresenter::replaceHandle(const std::string &workspaceName, DataForParameterEstimationCollection IndirectFitDataPresenter::getDataForParameterEstimation( - EstimationDataSelector selector) const { - return m_model->getDataForParameterEstimation(selector); + const EstimationDataSelector &selector) const { + return m_model->getDataForParameterEstimation(std::move(selector)); } void IndirectFitDataPresenter::selectReplacedWorkspace( diff --git a/qt/scientific_interfaces/Indirect/IndirectFitDataPresenter.h b/qt/scientific_interfaces/Indirect/IndirectFitDataPresenter.h index 9240d20217755ee32209db0250acf7213a31456a..ae5f9d668e03d709b14ec4dfaedce365bc79850e 100644 --- a/qt/scientific_interfaces/Indirect/IndirectFitDataPresenter.h +++ b/qt/scientific_interfaces/Indirect/IndirectFitDataPresenter.h @@ -58,7 +58,7 @@ public: void replaceHandle(const std::string &workspaceName, const Workspace_sptr &workspace) override; DataForParameterEstimationCollection - getDataForParameterEstimation(EstimationDataSelector selector) const; + getDataForParameterEstimation(const EstimationDataSelector &selector) const; public slots: void updateSpectraInTable(TableDatasetIndex dataIndex); diff --git a/qt/scientific_interfaces/Indirect/IndirectFitOutput.cpp b/qt/scientific_interfaces/Indirect/IndirectFitOutput.cpp index 2e78f0e3a46ffa595f517d0448ccefc8ffe9ab07..f471023b4a08c10ca59efc6a15cd3a45d6d1fa2c 100644 --- a/qt/scientific_interfaces/Indirect/IndirectFitOutput.cpp +++ b/qt/scientific_interfaces/Indirect/IndirectFitOutput.cpp @@ -14,6 +14,7 @@ #include <boost/functional/hash.hpp> #include <unordered_set> +#include <utility> using namespace Mantid::API; using IDAWorkspaceIndex = MantidQt::CustomInterfaces::IDA::WorkspaceIndex; @@ -23,7 +24,7 @@ using namespace MantidQt::CustomInterfaces::IDA; struct TableRowExtractor { explicit TableRowExtractor(ITableWorkspace_sptr table) - : m_table(table), m_columns(m_table->getColumnNames()) { + : m_table(std::move(table)), m_columns(m_table->getColumnNames()) { m_chiIndex = std::find(m_columns.begin(), m_columns.end(), "Chi_squared") - m_columns.begin(); } @@ -74,7 +75,7 @@ void extractParametersFromTable( const FitDataIterator &fitDataEnd, std::unordered_map<IndirectFitData const *, ParameterValuesNew> ¶meters) { - TableRowExtractor extractRowFromTable(tableWs); + TableRowExtractor extractRowFromTable(std::move(tableWs)); IDAWorkspaceIndex index; for (auto fitData = fitDataBegin; fitData < fitDataEnd; ++fitData) { auto &values = parameters[fitData->get()]; @@ -116,8 +117,9 @@ Map mapKeys(const Map &map, const KeyMap &keyMap) { return newMap; } -MatrixWorkspace_sptr getMatrixWorkspaceFromGroup(WorkspaceGroup_sptr group, - std::size_t index) { +MatrixWorkspace_sptr +getMatrixWorkspaceFromGroup(const WorkspaceGroup_sptr &group, + std::size_t index) { if (group->size() > index) return boost::dynamic_pointer_cast<MatrixWorkspace>(group->getItem(index)); return nullptr; @@ -131,7 +133,7 @@ std::vector<std::string> getAxisLabels(TextAxis const *axis) { return labels; } -std::vector<std::string> getAxisLabels(MatrixWorkspace_sptr workspace, +std::vector<std::string> getAxisLabels(const MatrixWorkspace_sptr &workspace, std::size_t index) { auto axis = dynamic_cast<TextAxis *>(workspace->getAxis(index)); if (axis) @@ -166,12 +168,12 @@ void renameWorkspace(std::string const &name, std::string const &newName) { renamer->execute(); } -void renameResult(Workspace_sptr resultWorkspace, +void renameResult(const Workspace_sptr &resultWorkspace, const std::string &workspaceName) { renameWorkspace(resultWorkspace->getName(), workspaceName + "_Result"); } -void renameResult(Workspace_sptr resultWorkspace, +void renameResult(const Workspace_sptr &resultWorkspace, IndirectFitData const *fitData) { const auto name = resultWorkspace->getName(); const auto newName = constructResultName(name, fitData); @@ -179,13 +181,13 @@ void renameResult(Workspace_sptr resultWorkspace, renameWorkspace(name, newName); } -void renameResult(WorkspaceGroup_sptr resultWorkspace, +void renameResult(const WorkspaceGroup_sptr &resultWorkspace, IndirectFitData const *fitData) { for (auto const &workspace : *resultWorkspace) renameResult(workspace, fitData); } -void renameResultWithoutSpectra(WorkspaceGroup_sptr resultWorkspace, +void renameResultWithoutSpectra(const WorkspaceGroup_sptr &resultWorkspace, const FitDataIterator &fitDataBegin, const FitDataIterator &fitDataEnd) { std::size_t index = 0; @@ -200,7 +202,7 @@ void renameResultWithoutSpectra(WorkspaceGroup_sptr resultWorkspace, } } -void renameResultWithSpectra(WorkspaceGroup_sptr resultWorkspace, +void renameResultWithSpectra(const WorkspaceGroup_sptr &resultWorkspace, const FitDataIterator &fitDataBegin, const FitDataIterator &fitDataEnd) { std::size_t index = 0; @@ -208,7 +210,7 @@ void renameResultWithSpectra(WorkspaceGroup_sptr resultWorkspace, renameResult(resultWorkspace->getItem(index++), it->get()); } -void renameResult(WorkspaceGroup_sptr resultWorkspace, +void renameResult(const WorkspaceGroup_sptr &resultWorkspace, const FitDataIterator &fitDataBegin, const FitDataIterator &fitDataEnd) { if (static_cast<int>(resultWorkspace->size()) >= fitDataEnd - fitDataBegin) @@ -238,25 +240,26 @@ namespace MantidQt { namespace CustomInterfaces { namespace IDA { -IndirectFitOutput::IndirectFitOutput(WorkspaceGroup_sptr resultGroup, +IndirectFitOutput::IndirectFitOutput(const WorkspaceGroup_sptr &resultGroup, ITableWorkspace_sptr parameterTable, - WorkspaceGroup_sptr resultWorkspace, + const WorkspaceGroup_sptr &resultWorkspace, const FitDataIterator &fitDataBegin, const FitDataIterator &fitDataEnd) : m_resultGroup(resultGroup), m_resultWorkspace(resultWorkspace), m_parameters(), m_outputResultLocations() { - addOutput(resultGroup, parameterTable, resultWorkspace, fitDataBegin, - fitDataEnd); + addOutput(resultGroup, std::move(parameterTable), resultWorkspace, + fitDataBegin, fitDataEnd); } -IndirectFitOutput::IndirectFitOutput(WorkspaceGroup_sptr resultGroup, +IndirectFitOutput::IndirectFitOutput(const WorkspaceGroup_sptr &resultGroup, ITableWorkspace_sptr parameterTable, - WorkspaceGroup_sptr resultWorkspace, + const WorkspaceGroup_sptr &resultWorkspace, IndirectFitData const *fitData, WorkspaceIndex spectrum) { m_parameters[fitData] = ParameterValuesNew(); m_outputResultLocations[fitData] = ResultLocationsNew(); - addOutput(resultGroup, parameterTable, resultWorkspace, fitData, spectrum); + addOutput(std::move(resultGroup), std::move(parameterTable), + std::move(resultWorkspace), fitData, spectrum); } bool IndirectFitOutput::isSpectrumFit(IndirectFitData const *fitData, @@ -322,24 +325,24 @@ void IndirectFitOutput::mapParameterNames( parameters = mapKeys(parameters, parameterNameChanges); } -void IndirectFitOutput::addOutput(WorkspaceGroup_sptr resultGroup, +void IndirectFitOutput::addOutput(const WorkspaceGroup_sptr &resultGroup, ITableWorkspace_sptr parameterTable, - WorkspaceGroup_sptr resultWorkspace, + const WorkspaceGroup_sptr &resultWorkspace, const FitDataIterator &fitDataBegin, const FitDataIterator &fitDataEnd) { - updateParameters(parameterTable, fitDataBegin, fitDataEnd); + updateParameters(std::move(parameterTable), fitDataBegin, fitDataEnd); updateFitResults(resultGroup, fitDataBegin, fitDataEnd); renameResult(resultWorkspace, fitDataBegin, fitDataEnd); m_resultWorkspace = resultWorkspace; m_resultGroup = resultGroup; } -void IndirectFitOutput::addOutput(WorkspaceGroup_sptr resultGroup, +void IndirectFitOutput::addOutput(const WorkspaceGroup_sptr &resultGroup, ITableWorkspace_sptr parameterTable, - WorkspaceGroup_sptr resultWorkspace, + const WorkspaceGroup_sptr &resultWorkspace, IndirectFitData const *fitData, WorkspaceIndex spectrum) { - TableRowExtractor extractRowFromTable(parameterTable); + TableRowExtractor extractRowFromTable(std::move(parameterTable)); m_parameters[fitData][spectrum] = extractRowFromTable(WorkspaceIndex{0}); m_outputResultLocations[fitData][spectrum] = ResultLocationNew(resultGroup, WorkspaceGroupIndex{0}); @@ -353,7 +356,7 @@ void IndirectFitOutput::removeOutput(IndirectFitData const *fitData) { m_outputResultLocations.erase(fitData); } -void IndirectFitOutput::updateFitResults(WorkspaceGroup_sptr resultGroup, +void IndirectFitOutput::updateFitResults(const WorkspaceGroup_sptr &resultGroup, const FitDataIterator &fitDataBegin, const FitDataIterator &fitDataEnd) { if (numberOfSpectraIn(fitDataBegin, fitDataEnd).value <= @@ -366,12 +369,12 @@ void IndirectFitOutput::updateFitResults(WorkspaceGroup_sptr resultGroup, void IndirectFitOutput::updateParameters(ITableWorkspace_sptr parameterTable, const FitDataIterator &fitDataBegin, const FitDataIterator &fitDataEnd) { - extractParametersFromTable(parameterTable, fitDataBegin, fitDataEnd, - m_parameters); + extractParametersFromTable(std::move(parameterTable), fitDataBegin, + fitDataEnd, m_parameters); } void IndirectFitOutput::updateFitResultsFromUnstructured( - WorkspaceGroup_sptr resultGroup, const FitDataIterator &fitDataBegin, + const WorkspaceGroup_sptr &resultGroup, const FitDataIterator &fitDataBegin, const FitDataIterator &fitDataEnd) { std::unordered_map<MatrixWorkspace *, std::map<WorkspaceIndex, WorkspaceGroupIndex>> @@ -396,7 +399,7 @@ void IndirectFitOutput::updateFitResultsFromUnstructured( } void IndirectFitOutput::updateFitResultsFromStructured( - WorkspaceGroup_sptr resultGroup, const FitDataIterator &fitDataBegin, + const WorkspaceGroup_sptr &resultGroup, const FitDataIterator &fitDataBegin, const FitDataIterator &fitDataEnd) { WorkspaceGroupIndex index; for (auto fitData = fitDataBegin; fitData < fitDataEnd; ++fitData) { diff --git a/qt/scientific_interfaces/Indirect/IndirectFitOutput.h b/qt/scientific_interfaces/Indirect/IndirectFitOutput.h index 9bf1c957377a609ddefcde35b03ca93958b1fa9b..92bc19a0612fbdd10be1b71527d90af27dcc5c6d 100644 --- a/qt/scientific_interfaces/Indirect/IndirectFitOutput.h +++ b/qt/scientific_interfaces/Indirect/IndirectFitOutput.h @@ -30,7 +30,7 @@ struct ParameterValue { struct ResultLocationNew { ResultLocationNew() = default; - ResultLocationNew(Mantid::API::WorkspaceGroup_sptr group, + ResultLocationNew(const Mantid::API::WorkspaceGroup_sptr &group, WorkspaceGroupIndex i) : result(group), index(i) {} boost::weak_ptr<Mantid::API::WorkspaceGroup> result; @@ -51,15 +51,15 @@ using FitDataIterator = */ class MANTIDQT_INDIRECT_DLL IndirectFitOutput { public: - IndirectFitOutput(Mantid::API::WorkspaceGroup_sptr resultGroup, + IndirectFitOutput(const Mantid::API::WorkspaceGroup_sptr &resultGroup, Mantid::API::ITableWorkspace_sptr parameterTable, - Mantid::API::WorkspaceGroup_sptr resultWorkspace, + const Mantid::API::WorkspaceGroup_sptr &resultWorkspace, const FitDataIterator &fitDataBegin, const FitDataIterator &fitDataEnd); - IndirectFitOutput(Mantid::API::WorkspaceGroup_sptr resultGroup, + IndirectFitOutput(const Mantid::API::WorkspaceGroup_sptr &resultGroup, Mantid::API::ITableWorkspace_sptr parameterTable, - Mantid::API::WorkspaceGroup_sptr resultWorkspace, + const Mantid::API::WorkspaceGroup_sptr &resultWorkspace, IndirectFitData const *fitData, WorkspaceIndex spectrum); bool isSpectrumFit(IndirectFitData const *fitData, @@ -85,33 +85,31 @@ public: const std::unordered_map<std::string, std::string> ¶meterNameChanges, IndirectFitData const *fitData, WorkspaceIndex spectrum); - void addOutput(Mantid::API::WorkspaceGroup_sptr resultGroup, + void addOutput(const Mantid::API::WorkspaceGroup_sptr &resultGroup, Mantid::API::ITableWorkspace_sptr parameterTable, - Mantid::API::WorkspaceGroup_sptr resultWorkspace, + const Mantid::API::WorkspaceGroup_sptr &resultWorkspace, const FitDataIterator &fitDataBegin, const FitDataIterator &fitDataEnd); - void addOutput(Mantid::API::WorkspaceGroup_sptr resultGroup, + void addOutput(const Mantid::API::WorkspaceGroup_sptr &resultGroup, Mantid::API::ITableWorkspace_sptr parameterTable, - Mantid::API::WorkspaceGroup_sptr resultWorkspace, + const Mantid::API::WorkspaceGroup_sptr &resultWorkspace, IndirectFitData const *fitData, WorkspaceIndex spectrum); void removeOutput(IndirectFitData const *fitData); private: - void updateFitResults(Mantid::API::WorkspaceGroup_sptr resultGroup, + void updateFitResults(const Mantid::API::WorkspaceGroup_sptr &resultGroup, const FitDataIterator &fitDataBegin, const FitDataIterator &fitDataEnd); void updateParameters(Mantid::API::ITableWorkspace_sptr parameterTable, const FitDataIterator &fitDataBegin, const FitDataIterator &fitDataEnd); - void - updateFitResultsFromUnstructured(Mantid::API::WorkspaceGroup_sptr resultGroup, - const FitDataIterator &fitDataBegin, - const FitDataIterator &fitDataEnd); - void - updateFitResultsFromStructured(Mantid::API::WorkspaceGroup_sptr resultGroup, - const FitDataIterator &fitDataBegin, - const FitDataIterator &fitDataEnd); + void updateFitResultsFromUnstructured( + const Mantid::API::WorkspaceGroup_sptr &resultGroup, + const FitDataIterator &fitDataBegin, const FitDataIterator &fitDataEnd); + void updateFitResultsFromStructured( + const Mantid::API::WorkspaceGroup_sptr &resultGroup, + const FitDataIterator &fitDataBegin, const FitDataIterator &fitDataEnd); boost::weak_ptr<Mantid::API::WorkspaceGroup> m_resultGroup; boost::weak_ptr<Mantid::API::WorkspaceGroup> m_resultWorkspace; diff --git a/qt/scientific_interfaces/Indirect/IndirectFitOutputLegacy.cpp b/qt/scientific_interfaces/Indirect/IndirectFitOutputLegacy.cpp index 66f8d682659c3a2b3cf7239c2ed68854baf8a4e8..0fce2d58734799ad1cc3c112478051d732c55255 100644 --- a/qt/scientific_interfaces/Indirect/IndirectFitOutputLegacy.cpp +++ b/qt/scientific_interfaces/Indirect/IndirectFitOutputLegacy.cpp @@ -14,6 +14,7 @@ #include <boost/functional/hash.hpp> #include <unordered_set> +#include <utility> using namespace Mantid::API; @@ -22,7 +23,7 @@ using namespace MantidQt::CustomInterfaces::IDA; struct TableRowExtractor { explicit TableRowExtractor(ITableWorkspace_sptr table) - : m_table(table), m_columns(m_table->getColumnNames()) { + : m_table(std::move(table)), m_columns(m_table->getColumnNames()) { m_chiIndex = std::find(m_columns.begin(), m_columns.end(), "Chi_squared") - m_columns.begin(); } @@ -74,7 +75,7 @@ void extractParametersFromTable( const FitDataIteratorLegacy &fitDataEnd, std::unordered_map<IndirectFitDataLegacy const *, ParameterValues> ¶meters) { - TableRowExtractor extractRowFromTable(tableWs); + TableRowExtractor extractRowFromTable(std::move(tableWs)); auto extract = [&](IndirectFitDataLegacy const *inputData) { auto &values = extractOrAddDefault(parameters, inputData); return [&](std::size_t index, std::size_t spectrum) { @@ -115,8 +116,9 @@ Map mapKeys(const Map &map, const KeyMap &keyMap) { return newMap; } -MatrixWorkspace_sptr getMatrixWorkspaceFromGroup(WorkspaceGroup_sptr group, - std::size_t index) { +MatrixWorkspace_sptr +getMatrixWorkspaceFromGroup(const WorkspaceGroup_sptr &group, + std::size_t index) { if (group->size() > index) return boost::dynamic_pointer_cast<MatrixWorkspace>(group->getItem(index)); return nullptr; @@ -130,7 +132,7 @@ std::vector<std::string> getAxisLabels(TextAxis const *axis) { return labels; } -std::vector<std::string> getAxisLabels(MatrixWorkspace_sptr workspace, +std::vector<std::string> getAxisLabels(const MatrixWorkspace_sptr &workspace, std::size_t index) { auto axis = dynamic_cast<TextAxis *>(workspace->getAxis(index)); if (axis) @@ -165,12 +167,12 @@ void renameWorkspace(std::string const &name, std::string const &newName) { renamer->execute(); } -void renameResult(Workspace_sptr resultWorkspace, +void renameResult(const Workspace_sptr &resultWorkspace, const std::string &workspaceName) { renameWorkspace(resultWorkspace->getName(), workspaceName + "_Result"); } -void renameResult(Workspace_sptr resultWorkspace, +void renameResult(const Workspace_sptr &resultWorkspace, IndirectFitDataLegacy const *fitData) { const auto name = resultWorkspace->getName(); const auto newName = constructResultName(name, fitData); @@ -178,13 +180,13 @@ void renameResult(Workspace_sptr resultWorkspace, renameWorkspace(name, newName); } -void renameResult(WorkspaceGroup_sptr resultWorkspace, +void renameResult(const WorkspaceGroup_sptr &resultWorkspace, IndirectFitDataLegacy const *fitData) { for (auto const &workspace : *resultWorkspace) renameResult(workspace, fitData); } -void renameResultWithoutSpectra(WorkspaceGroup_sptr resultWorkspace, +void renameResultWithoutSpectra(const WorkspaceGroup_sptr &resultWorkspace, const FitDataIteratorLegacy &fitDataBegin, const FitDataIteratorLegacy &fitDataEnd) { std::size_t index = 0; @@ -199,7 +201,7 @@ void renameResultWithoutSpectra(WorkspaceGroup_sptr resultWorkspace, } } -void renameResultWithSpectra(WorkspaceGroup_sptr resultWorkspace, +void renameResultWithSpectra(const WorkspaceGroup_sptr &resultWorkspace, const FitDataIteratorLegacy &fitDataBegin, const FitDataIteratorLegacy &fitDataEnd) { std::size_t index = 0; @@ -207,7 +209,7 @@ void renameResultWithSpectra(WorkspaceGroup_sptr resultWorkspace, renameResult(resultWorkspace->getItem(index++), it->get()); } -void renameResult(WorkspaceGroup_sptr resultWorkspace, +void renameResult(const WorkspaceGroup_sptr &resultWorkspace, const FitDataIteratorLegacy &fitDataBegin, const FitDataIteratorLegacy &fitDataEnd) { if (static_cast<int>(resultWorkspace->size()) >= fitDataEnd - fitDataBegin) @@ -230,7 +232,7 @@ public: WorkspaceGroup_sptr resultGroup, ResultLocations &locations, std::unordered_map<std::size_t, std::size_t> &defaultPositions, std::size_t &index) - : m_resultGroup(resultGroup), m_locations(locations), + : m_resultGroup(std::move(resultGroup)), m_locations(locations), m_defaultPositions(defaultPositions), m_index(index) {} void operator()(std::size_t spectrum) const { @@ -264,23 +266,24 @@ namespace CustomInterfaces { namespace IDA { IndirectFitOutputLegacy::IndirectFitOutputLegacy( - WorkspaceGroup_sptr resultGroup, ITableWorkspace_sptr parameterTable, - WorkspaceGroup_sptr resultWorkspace, + const WorkspaceGroup_sptr &resultGroup, ITableWorkspace_sptr parameterTable, + const WorkspaceGroup_sptr &resultWorkspace, const FitDataIteratorLegacy &fitDataBegin, const FitDataIteratorLegacy &fitDataEnd) : m_resultGroup(resultGroup), m_resultWorkspace(resultWorkspace), m_parameters(), m_outputResultLocations() { - addOutput(resultGroup, parameterTable, resultWorkspace, fitDataBegin, - fitDataEnd); + addOutput(resultGroup, std::move(parameterTable), resultWorkspace, + fitDataBegin, fitDataEnd); } IndirectFitOutputLegacy::IndirectFitOutputLegacy( - WorkspaceGroup_sptr resultGroup, ITableWorkspace_sptr parameterTable, - WorkspaceGroup_sptr resultWorkspace, IndirectFitDataLegacy const *fitData, - std::size_t spectrum) { + const WorkspaceGroup_sptr &resultGroup, ITableWorkspace_sptr parameterTable, + const WorkspaceGroup_sptr &resultWorkspace, + IndirectFitDataLegacy const *fitData, std::size_t spectrum) { m_parameters[fitData] = ParameterValues(); m_outputResultLocations[fitData] = ResultLocations(); - addOutput(resultGroup, parameterTable, resultWorkspace, fitData, spectrum); + addOutput(std::move(resultGroup), std::move(parameterTable), + std::move(resultWorkspace), fitData, spectrum); } bool IndirectFitOutputLegacy::isSpectrumFit( @@ -349,23 +352,22 @@ void IndirectFitOutputLegacy::mapParameterNames( } void IndirectFitOutputLegacy::addOutput( - WorkspaceGroup_sptr resultGroup, ITableWorkspace_sptr parameterTable, - WorkspaceGroup_sptr resultWorkspace, + const WorkspaceGroup_sptr &resultGroup, ITableWorkspace_sptr parameterTable, + const WorkspaceGroup_sptr &resultWorkspace, const FitDataIteratorLegacy &fitDataBegin, const FitDataIteratorLegacy &fitDataEnd) { - updateParameters(parameterTable, fitDataBegin, fitDataEnd); + updateParameters(std::move(parameterTable), fitDataBegin, fitDataEnd); updateFitResults(resultGroup, fitDataBegin, fitDataEnd); renameResult(resultWorkspace, fitDataBegin, fitDataEnd); m_resultWorkspace = resultWorkspace; m_resultGroup = resultGroup; } -void IndirectFitOutputLegacy::addOutput(WorkspaceGroup_sptr resultGroup, - ITableWorkspace_sptr parameterTable, - WorkspaceGroup_sptr resultWorkspace, - IndirectFitDataLegacy const *fitData, - std::size_t spectrum) { - TableRowExtractor extractRowFromTable(parameterTable); +void IndirectFitOutputLegacy::addOutput( + const WorkspaceGroup_sptr &resultGroup, ITableWorkspace_sptr parameterTable, + const WorkspaceGroup_sptr &resultWorkspace, + IndirectFitDataLegacy const *fitData, std::size_t spectrum) { + TableRowExtractor extractRowFromTable(std::move(parameterTable)); m_parameters[fitData][spectrum] = extractRowFromTable(0); m_outputResultLocations[fitData][spectrum] = ResultLocation(resultGroup, 0); renameResult(resultWorkspace, fitData); @@ -380,7 +382,8 @@ void IndirectFitOutputLegacy::removeOutput( } void IndirectFitOutputLegacy::updateFitResults( - WorkspaceGroup_sptr resultGroup, const FitDataIteratorLegacy &fitDataBegin, + const WorkspaceGroup_sptr &resultGroup, + const FitDataIteratorLegacy &fitDataBegin, const FitDataIteratorLegacy &fitDataEnd) { if (numberOfSpectraIn(fitDataBegin, fitDataEnd) <= resultGroup->size()) updateFitResultsFromStructured(resultGroup, fitDataBegin, fitDataEnd); @@ -392,8 +395,8 @@ void IndirectFitOutputLegacy::updateParameters( ITableWorkspace_sptr parameterTable, const FitDataIteratorLegacy &fitDataBegin, const FitDataIteratorLegacy &fitDataEnd) { - extractParametersFromTable(parameterTable, fitDataBegin, fitDataEnd, - m_parameters); + extractParametersFromTable(std::move(parameterTable), fitDataBegin, + fitDataEnd, m_parameters); } void IndirectFitOutputLegacy::updateFitResultsFromUnstructured( diff --git a/qt/scientific_interfaces/Indirect/IndirectFitOutputLegacy.h b/qt/scientific_interfaces/Indirect/IndirectFitOutputLegacy.h index 58bc119c27feb55e78dcea4ec11b8ea6b728fee1..7dc61035373a1c45b570e16469947dc6cc605da0 100644 --- a/qt/scientific_interfaces/Indirect/IndirectFitOutputLegacy.h +++ b/qt/scientific_interfaces/Indirect/IndirectFitOutputLegacy.h @@ -30,7 +30,7 @@ struct ParameterValueLegacy { struct ResultLocation { ResultLocation() : result(), index(0) {} - ResultLocation(Mantid::API::WorkspaceGroup_sptr group, std::size_t i) + ResultLocation(const Mantid::API::WorkspaceGroup_sptr &group, std::size_t i) : result(group), index(i) {} boost::weak_ptr<Mantid::API::WorkspaceGroup> result; std::size_t index; @@ -51,17 +51,18 @@ using FitDataIteratorLegacy = */ class MANTIDQT_INDIRECT_DLL IndirectFitOutputLegacy { public: - IndirectFitOutputLegacy(Mantid::API::WorkspaceGroup_sptr resultGroup, - Mantid::API::ITableWorkspace_sptr parameterTable, - Mantid::API::WorkspaceGroup_sptr resultWorkspace, - const FitDataIteratorLegacy &fitDataBegin, - const FitDataIteratorLegacy &fitDataEnd); - - IndirectFitOutputLegacy(Mantid::API::WorkspaceGroup_sptr resultGroup, - Mantid::API::ITableWorkspace_sptr parameterTable, - Mantid::API::WorkspaceGroup_sptr resultWorkspace, - IndirectFitDataLegacy const *fitData, - std::size_t spectrum); + IndirectFitOutputLegacy( + const Mantid::API::WorkspaceGroup_sptr &resultGroup, + Mantid::API::ITableWorkspace_sptr parameterTable, + const Mantid::API::WorkspaceGroup_sptr &resultWorkspace, + const FitDataIteratorLegacy &fitDataBegin, + const FitDataIteratorLegacy &fitDataEnd); + + IndirectFitOutputLegacy( + const Mantid::API::WorkspaceGroup_sptr &resultGroup, + Mantid::API::ITableWorkspace_sptr parameterTable, + const Mantid::API::WorkspaceGroup_sptr &resultWorkspace, + IndirectFitDataLegacy const *fitData, std::size_t spectrum); bool isSpectrumFit(IndirectFitDataLegacy const *fitData, std::size_t spectrum) const; @@ -88,20 +89,20 @@ public: const std::unordered_map<std::string, std::string> ¶meterNameChanges, IndirectFitDataLegacy const *fitData, std::size_t spectrum); - void addOutput(Mantid::API::WorkspaceGroup_sptr resultGroup, + void addOutput(const Mantid::API::WorkspaceGroup_sptr &resultGroup, Mantid::API::ITableWorkspace_sptr parameterTable, - Mantid::API::WorkspaceGroup_sptr resultWorkspace, + const Mantid::API::WorkspaceGroup_sptr &resultWorkspace, const FitDataIteratorLegacy &fitDataBegin, const FitDataIteratorLegacy &fitDataEnd); - void addOutput(Mantid::API::WorkspaceGroup_sptr resultGroup, + void addOutput(const Mantid::API::WorkspaceGroup_sptr &resultGroup, Mantid::API::ITableWorkspace_sptr parameterTable, - Mantid::API::WorkspaceGroup_sptr resultWorkspace, + const Mantid::API::WorkspaceGroup_sptr &resultWorkspace, IndirectFitDataLegacy const *fitData, std::size_t spectrum); void removeOutput(IndirectFitDataLegacy const *fitData); private: - void updateFitResults(Mantid::API::WorkspaceGroup_sptr resultGroup, + void updateFitResults(const Mantid::API::WorkspaceGroup_sptr &resultGroup, const FitDataIteratorLegacy &fitDataBegin, const FitDataIteratorLegacy &fitDataEnd); void updateParameters(Mantid::API::ITableWorkspace_sptr parameterTable, diff --git a/qt/scientific_interfaces/Indirect/IndirectFitOutputOptionsModel.cpp b/qt/scientific_interfaces/Indirect/IndirectFitOutputOptionsModel.cpp index ae7f7ab60b9ad94f9b542ca7e0a2045c3cb2b38e..d946dbe86babef55436b78ab98c7d7ac66ed7f13 100644 --- a/qt/scientific_interfaces/Indirect/IndirectFitOutputOptionsModel.cpp +++ b/qt/scientific_interfaces/Indirect/IndirectFitOutputOptionsModel.cpp @@ -6,6 +6,8 @@ // SPDX - License - Identifier: GPL - 3.0 + #include "IndirectFitOutputOptionsModel.h" +#include <utility> + #include "MantidAPI/AlgorithmManager.h" #include "MantidAPI/AnalysisDataService.h" #include "MantidAPI/Axis.h" @@ -20,11 +22,11 @@ std::string noWorkspaceErrorMessage(std::string const &process) { return "The " + process + " of a workspace failed:\n\n No workspace found"; } -MatrixWorkspace_sptr convertToMatrixWorkspace(Workspace_sptr workspace) { +MatrixWorkspace_sptr convertToMatrixWorkspace(const Workspace_sptr &workspace) { return boost::dynamic_pointer_cast<MatrixWorkspace>(workspace); } -WorkspaceGroup_sptr convertToGroupWorkspace(Workspace_sptr workspace) { +WorkspaceGroup_sptr convertToGroupWorkspace(const Workspace_sptr &workspace) { return boost::dynamic_pointer_cast<WorkspaceGroup>(workspace); } @@ -50,7 +52,7 @@ std::unordered_map<std::string, std::size_t> extractAxisLabels(Axis *axis) { } std::unordered_map<std::string, std::size_t> -extractAxisLabels(MatrixWorkspace_const_sptr workspace, +extractAxisLabels(const MatrixWorkspace_const_sptr &workspace, std::size_t const &axisIndex) { auto const axis = workspace->getAxis(axisIndex); if (axis->isText()) @@ -67,18 +69,20 @@ std::vector<std::string> extractParameterNames(Axis *axis) { return parameters; } -std::vector<std::string> extractParameterNames(MatrixWorkspace_sptr workspace) { +std::vector<std::string> +extractParameterNames(const MatrixWorkspace_sptr &workspace) { auto const axis = workspace->getAxis(1); if (axis->isText()) return extractParameterNames(axis); return std::vector<std::string>(); } -std::vector<std::string> extractParameterNames(Workspace_sptr workspace) { - return extractParameterNames(convertToMatrixWorkspace(workspace)); +std::vector<std::string> +extractParameterNames(const Workspace_sptr &workspace) { + return extractParameterNames(convertToMatrixWorkspace(std::move(workspace))); } -IAlgorithm_sptr saveNexusProcessedAlgorithm(Workspace_sptr workspace, +IAlgorithm_sptr saveNexusProcessedAlgorithm(const Workspace_sptr &workspace, std::string const &filename) { auto saveAlg = AlgorithmManager::Instance().create("SaveNexusProcessed"); saveAlg->setProperty("InputWorkspace", workspace); @@ -86,23 +90,24 @@ IAlgorithm_sptr saveNexusProcessedAlgorithm(Workspace_sptr workspace, return saveAlg; } -void saveWorkspace(Workspace_sptr workspace) { +void saveWorkspace(const Workspace_sptr &workspace) { auto const filename = Mantid::Kernel::ConfigService::Instance().getString( "defaultsave.directory") + workspace->getName() + ".nxs"; saveNexusProcessedAlgorithm(workspace, filename)->execute(); } -void saveWorkspacesInGroup(WorkspaceGroup_const_sptr group) { +void saveWorkspacesInGroup(const WorkspaceGroup_const_sptr &group) { for (auto const workspace : *group) saveWorkspace(workspace); } -bool workspaceIsPlottable(MatrixWorkspace_const_sptr workspace) { +bool workspaceIsPlottable(const MatrixWorkspace_const_sptr &workspace) { return workspace->y(0).size() > 1; } -bool containsPlottableWorkspace(WorkspaceGroup_const_sptr groupWorkspace) { +bool containsPlottableWorkspace( + const WorkspaceGroup_const_sptr &groupWorkspace) { return std::any_of(groupWorkspace->begin(), groupWorkspace->end(), [](auto const &workspace) { return workspaceIsPlottable( @@ -126,8 +131,8 @@ validateInputs(std::string const &inputWorkspaceName, return errors; } -IAlgorithm_sptr replaceAlgorithm(MatrixWorkspace_sptr inputWorkspace, - MatrixWorkspace_sptr singleFitWorkspace, +IAlgorithm_sptr replaceAlgorithm(const MatrixWorkspace_sptr &inputWorkspace, + const MatrixWorkspace_sptr &singleFitWorkspace, std::string const &outputName) { auto replaceAlg = AlgorithmManager::Instance().create("IndirectReplaceFitResult"); @@ -159,7 +164,7 @@ std::vector<std::string> filterByEndSuffix(std::vector<std::string> &strings, } bool doesGroupContain(std::string const &groupName, - MatrixWorkspace_sptr workspace) { + const MatrixWorkspace_sptr &workspace) { auto const adsWorkspace = getADSWorkspace(groupName); if (adsWorkspace->isGroup()) { auto const group = @@ -180,7 +185,9 @@ std::string filterByContents(std::vector<std::string> &strings, std::string findGroupWorkspaceContaining(MatrixWorkspace_sptr workspace) { auto workspaceNames = AnalysisDataService::Instance().getObjectNames(); auto resultGroups = filterByEndSuffix(workspaceNames, "_Results"); - return !resultGroups.empty() ? filterByContents(resultGroups, workspace) : ""; + return !resultGroups.empty() + ? filterByContents(resultGroups, std::move(workspace)) + : ""; } } // namespace @@ -247,7 +254,8 @@ void IndirectFitOutputOptionsModel::plotResult(std::string const &plotType) { } void IndirectFitOutputOptionsModel::plotResult( - WorkspaceGroup_const_sptr groupWorkspace, std::string const &plotType) { + const WorkspaceGroup_const_sptr &groupWorkspace, + std::string const &plotType) { if (plotType == "All") plotAll(groupWorkspace); else @@ -255,19 +263,19 @@ void IndirectFitOutputOptionsModel::plotResult( } void IndirectFitOutputOptionsModel::plotAll( - WorkspaceGroup_const_sptr groupWorkspace) { + const WorkspaceGroup_const_sptr &groupWorkspace) { for (auto const &workspace : *groupWorkspace) plotAll(convertToMatrixWorkspace(workspace)); } void IndirectFitOutputOptionsModel::plotAll( - MatrixWorkspace_const_sptr workspace) { + const MatrixWorkspace_const_sptr &workspace) { if (workspaceIsPlottable(workspace)) plotAllSpectra(workspace); } void IndirectFitOutputOptionsModel::plotAllSpectra( - MatrixWorkspace_const_sptr workspace) { + const MatrixWorkspace_const_sptr &workspace) { for (auto index = 0u; index < workspace->getNumberHistograms(); ++index) { auto const plotInfo = std::make_pair(workspace->getName(), index); m_spectraToPlot.emplace_back(plotInfo); @@ -275,19 +283,20 @@ void IndirectFitOutputOptionsModel::plotAllSpectra( } void IndirectFitOutputOptionsModel::plotParameter( - WorkspaceGroup_const_sptr groupWorkspace, std::string const ¶meter) { + const WorkspaceGroup_const_sptr &groupWorkspace, + std::string const ¶meter) { for (auto const &workspace : *groupWorkspace) plotParameter(convertToMatrixWorkspace(workspace), parameter); } void IndirectFitOutputOptionsModel::plotParameter( - MatrixWorkspace_const_sptr workspace, std::string const ¶meter) { + const MatrixWorkspace_const_sptr &workspace, std::string const ¶meter) { if (workspaceIsPlottable(workspace)) plotParameterSpectrum(workspace, parameter); } void IndirectFitOutputOptionsModel::plotParameterSpectrum( - MatrixWorkspace_const_sptr workspace, std::string const ¶meter) { + const MatrixWorkspace_const_sptr &workspace, std::string const ¶meter) { auto const parameters = extractAxisLabels(workspace, 1); auto const iter = parameters.find(parameter); if (iter != parameters.end()) { @@ -306,7 +315,7 @@ void IndirectFitOutputOptionsModel::plotPDF(std::string const &workspaceName, } void IndirectFitOutputOptionsModel::plotPDF( - MatrixWorkspace_const_sptr workspace, std::string const &plotType) { + const MatrixWorkspace_const_sptr &workspace, std::string const &plotType) { if (plotType == "All") plotAll(workspace); else @@ -353,16 +362,17 @@ void IndirectFitOutputOptionsModel::replaceFitResult( } void IndirectFitOutputOptionsModel::replaceFitResult( - MatrixWorkspace_sptr inputWorkspace, - MatrixWorkspace_sptr singleFitWorkspace, std::string const &outputName) { - auto const replaceAlg = - replaceAlgorithm(inputWorkspace, singleFitWorkspace, outputName); + const MatrixWorkspace_sptr &inputWorkspace, + const MatrixWorkspace_sptr &singleFitWorkspace, + std::string const &outputName) { + auto const replaceAlg = replaceAlgorithm( + std::move(inputWorkspace), std::move(singleFitWorkspace), outputName); replaceAlg->execute(); setOutputAsResultWorkspace(replaceAlg); } void IndirectFitOutputOptionsModel::setOutputAsResultWorkspace( - IAlgorithm_sptr algorithm) { + const IAlgorithm_sptr &algorithm) { auto const outputName = algorithm->getPropertyValue("OutputWorkspace"); auto const output = getADSMatrixWorkspace(outputName); setResultWorkspace(findGroupWorkspaceContaining(output)); diff --git a/qt/scientific_interfaces/Indirect/IndirectFitOutputOptionsModel.h b/qt/scientific_interfaces/Indirect/IndirectFitOutputOptionsModel.h index 70f9c115426f46320581f4ad35dfee610f10833a..958fc3823a18d19efb74bb2854f0ff190f5c8949 100644 --- a/qt/scientific_interfaces/Indirect/IndirectFitOutputOptionsModel.h +++ b/qt/scientific_interfaces/Indirect/IndirectFitOutputOptionsModel.h @@ -59,25 +59,29 @@ public: std::string const &outputName) override; private: - void plotResult(Mantid::API::WorkspaceGroup_const_sptr groupWorkspace, + void plotResult(const Mantid::API::WorkspaceGroup_const_sptr &groupWorkspace, std::string const &plotType); - void plotAll(Mantid::API::WorkspaceGroup_const_sptr groupWorkspace); - void plotAll(Mantid::API::MatrixWorkspace_const_sptr workspace); - void plotAllSpectra(Mantid::API::MatrixWorkspace_const_sptr workspace); - void plotParameter(Mantid::API::WorkspaceGroup_const_sptr groupWorkspace, - std::string const ¶meter); - void plotParameter(Mantid::API::MatrixWorkspace_const_sptr workspace, + void plotAll(const Mantid::API::WorkspaceGroup_const_sptr &groupWorkspace); + void plotAll(const Mantid::API::MatrixWorkspace_const_sptr &workspace); + void plotAllSpectra(const Mantid::API::MatrixWorkspace_const_sptr &workspace); + void + plotParameter(const Mantid::API::WorkspaceGroup_const_sptr &groupWorkspace, + std::string const ¶meter); + void plotParameter(const Mantid::API::MatrixWorkspace_const_sptr &workspace, std::string const ¶meter); - void plotParameterSpectrum(Mantid::API::MatrixWorkspace_const_sptr workspace, - std::string const ¶meter); + void plotParameterSpectrum( + const Mantid::API::MatrixWorkspace_const_sptr &workspace, + std::string const ¶meter); - void plotPDF(Mantid::API::MatrixWorkspace_const_sptr workspace, + void plotPDF(const Mantid::API::MatrixWorkspace_const_sptr &workspace, std::string const &plotType); - void replaceFitResult(Mantid::API::MatrixWorkspace_sptr inputWorkspace, - Mantid::API::MatrixWorkspace_sptr singleFitWorkspace, - std::string const &outputName); - void setOutputAsResultWorkspace(Mantid::API::IAlgorithm_sptr algorithm); + void + replaceFitResult(const Mantid::API::MatrixWorkspace_sptr &inputWorkspace, + const Mantid::API::MatrixWorkspace_sptr &singleFitWorkspace, + std::string const &outputName); + void + setOutputAsResultWorkspace(const Mantid::API::IAlgorithm_sptr &algorithm); void setResultWorkspace(std::string const &groupName); Mantid::API::WorkspaceGroup_sptr m_resultGroup; diff --git a/qt/scientific_interfaces/Indirect/IndirectFitOutputOptionsPresenter.cpp b/qt/scientific_interfaces/Indirect/IndirectFitOutputOptionsPresenter.cpp index 9cb4003e07fac2b0a2796b5cdc0f528fe88e19de..01a58541e8871c6b38ce39c714aea3942ffe4dcf 100644 --- a/qt/scientific_interfaces/Indirect/IndirectFitOutputOptionsPresenter.cpp +++ b/qt/scientific_interfaces/Indirect/IndirectFitOutputOptionsPresenter.cpp @@ -6,6 +6,8 @@ // SPDX - License - Identifier: GPL - 3.0 + #include "IndirectFitOutputOptionsPresenter.h" +#include <utility> + using namespace Mantid::API; namespace MantidQt { @@ -56,12 +58,12 @@ void IndirectFitOutputOptionsPresenter::setAvailablePlotOptions( void IndirectFitOutputOptionsPresenter::setResultWorkspace( WorkspaceGroup_sptr groupWorkspace) { - m_model->setResultWorkspace(groupWorkspace); + m_model->setResultWorkspace(std::move(groupWorkspace)); } void IndirectFitOutputOptionsPresenter::setPDFWorkspace( WorkspaceGroup_sptr groupWorkspace) { - m_model->setPDFWorkspace(groupWorkspace); + m_model->setPDFWorkspace(std::move(groupWorkspace)); } void IndirectFitOutputOptionsPresenter::setPlotWorkspaces() { diff --git a/qt/scientific_interfaces/Indirect/IndirectFitPlotModel.cpp b/qt/scientific_interfaces/Indirect/IndirectFitPlotModel.cpp index 897f137a9e43f765cff56560fd65d91db024bc42..e0663de8ace8189e0510bd4c6aed94ae6b486b9b 100644 --- a/qt/scientific_interfaces/Indirect/IndirectFitPlotModel.cpp +++ b/qt/scientific_interfaces/Indirect/IndirectFitPlotModel.cpp @@ -6,6 +6,8 @@ // SPDX - License - Identifier: GPL - 3.0 + #include "IndirectFitPlotModel.h" +#include <utility> + #include "MantidAPI/AlgorithmManager.h" #include "MantidAPI/AnalysisDataService.h" #include "MantidAPI/FunctionDomain1D.h" @@ -25,9 +27,10 @@ IFunction_sptr firstFunctionWithParameter(IFunction_sptr function, const std::string &category, const std::string ¶meterName); -IFunction_sptr firstFunctionWithParameter(CompositeFunction_sptr composite, - const std::string &category, - const std::string ¶meterName) { +IFunction_sptr +firstFunctionWithParameter(const CompositeFunction_sptr &composite, + const std::string &category, + const std::string ¶meterName) { for (auto i = 0u; i < composite->nFunctions(); ++i) { const auto value = firstFunctionWithParameter(composite->getFunction(i), category, parameterName); @@ -50,7 +53,7 @@ IFunction_sptr firstFunctionWithParameter(IFunction_sptr function, return nullptr; } -boost::optional<double> firstParameterValue(IFunction_sptr function, +boost::optional<double> firstParameterValue(const IFunction_sptr &function, const std::string &category, const std::string ¶meterName) { if (!function) @@ -63,22 +66,24 @@ boost::optional<double> firstParameterValue(IFunction_sptr function, return boost::none; } -boost::optional<double> findFirstPeakCentre(IFunction_sptr function) { - return firstParameterValue(function, "Peak", "PeakCentre"); +boost::optional<double> findFirstPeakCentre(const IFunction_sptr &function) { + return firstParameterValue(std::move(function), "Peak", "PeakCentre"); } -boost::optional<double> findFirstFWHM(IFunction_sptr function) { - return firstParameterValue(function, "Peak", "FWHM"); +boost::optional<double> findFirstFWHM(const IFunction_sptr &function) { + return firstParameterValue(std::move(function), "Peak", "FWHM"); } -boost::optional<double> findFirstBackgroundLevel(IFunction_sptr function) { - return firstParameterValue(function, "Background", "A0"); +boost::optional<double> +findFirstBackgroundLevel(const IFunction_sptr &function) { + return firstParameterValue(std::move(function), "Background", "A0"); } -void setFunctionParameters(IFunction_sptr function, const std::string &category, +void setFunctionParameters(const IFunction_sptr &function, + const std::string &category, const std::string ¶meterName, double value); -void setFunctionParameters(CompositeFunction_sptr composite, +void setFunctionParameters(const CompositeFunction_sptr &composite, const std::string &category, const std::string ¶meterName, double value) { for (auto i = 0u; i < composite->nFunctions(); ++i) @@ -86,7 +91,8 @@ void setFunctionParameters(CompositeFunction_sptr composite, value); } -void setFunctionParameters(IFunction_sptr function, const std::string &category, +void setFunctionParameters(const IFunction_sptr &function, + const std::string &category, const std::string ¶meterName, double value) { if (function->category() == category && function->hasParameter(parameterName)) function->setParameter(parameterName, value); @@ -96,7 +102,7 @@ void setFunctionParameters(IFunction_sptr function, const std::string &category, setFunctionParameters(composite, category, parameterName, value); } -void setFunctionParameters(MultiDomainFunction_sptr function, +void setFunctionParameters(const MultiDomainFunction_sptr &function, const std::string &category, const std::string ¶meterName, double value) { for (size_t i = 0u; i < function->nFunctions(); ++i) @@ -105,11 +111,11 @@ void setFunctionParameters(MultiDomainFunction_sptr function, } void setFirstBackground(IFunction_sptr function, double value) { - firstFunctionWithParameter(function, "Background", "A0") + firstFunctionWithParameter(std::move(function), "Background", "A0") ->setParameter("A0", value); } -MatrixWorkspace_sptr castToMatrixWorkspace(Workspace_sptr workspace) { +MatrixWorkspace_sptr castToMatrixWorkspace(const Workspace_sptr &workspace) { return boost::dynamic_pointer_cast<MatrixWorkspace>(workspace); } @@ -297,9 +303,9 @@ MatrixWorkspace_sptr IndirectFitPlotModel::getGuessWorkspace() const { } MatrixWorkspace_sptr IndirectFitPlotModel::appendGuessToInput( - MatrixWorkspace_sptr guessWorkspace) const { + const MatrixWorkspace_sptr &guessWorkspace) const { const auto range = getGuessRange(); - return createInputAndGuessWorkspace(getWorkspace(), guessWorkspace, + return createInputAndGuessWorkspace(getWorkspace(), std::move(guessWorkspace), m_activeSpectrum.value, range.first, range.second); } @@ -311,8 +317,9 @@ std::pair<double, double> IndirectFitPlotModel::getGuessRange() const { } MatrixWorkspace_sptr IndirectFitPlotModel::createInputAndGuessWorkspace( - MatrixWorkspace_sptr inputWS, MatrixWorkspace_sptr guessWorkspace, - int spectrum, double startX, double endX) const { + const MatrixWorkspace_sptr &inputWS, + const MatrixWorkspace_sptr &guessWorkspace, int spectrum, double startX, + double endX) const { guessWorkspace->setInstrument(inputWS->getInstrument()); guessWorkspace->replaceAxis( 0, @@ -331,10 +338,9 @@ MatrixWorkspace_sptr IndirectFitPlotModel::createInputAndGuessWorkspace( return inputAndGuess; } -MatrixWorkspace_sptr -IndirectFitPlotModel::createGuessWorkspace(MatrixWorkspace_sptr inputWorkspace, - IFunction_const_sptr func, - double startX, double endX) const { +MatrixWorkspace_sptr IndirectFitPlotModel::createGuessWorkspace( + const MatrixWorkspace_sptr &inputWorkspace, + const IFunction_const_sptr &func, double startX, double endX) const { IAlgorithm_sptr createWsAlg = AlgorithmManager::Instance().create("EvaluateFunction"); createWsAlg->initialize(); @@ -354,7 +360,7 @@ IndirectFitPlotModel::createGuessWorkspace(MatrixWorkspace_sptr inputWorkspace, } std::vector<double> -IndirectFitPlotModel::computeOutput(IFunction_const_sptr func, +IndirectFitPlotModel::computeOutput(const IFunction_const_sptr &func, const std::vector<double> &dataX) const { if (dataX.empty()) return std::vector<double>(); @@ -385,7 +391,7 @@ IAlgorithm_sptr IndirectFitPlotModel::createWorkspaceAlgorithm( } MatrixWorkspace_sptr -IndirectFitPlotModel::extractSpectra(MatrixWorkspace_sptr inputWS, +IndirectFitPlotModel::extractSpectra(const MatrixWorkspace_sptr &inputWS, int startIndex, int endIndex, double startX, double endX) const { auto extractSpectraAlg = @@ -403,9 +409,9 @@ IndirectFitPlotModel::extractSpectra(MatrixWorkspace_sptr inputWS, return extractSpectraAlg->getProperty("OutputWorkspace"); } -MatrixWorkspace_sptr -IndirectFitPlotModel::appendSpectra(MatrixWorkspace_sptr inputWS, - MatrixWorkspace_sptr spectraWS) const { +MatrixWorkspace_sptr IndirectFitPlotModel::appendSpectra( + const MatrixWorkspace_sptr &inputWS, + const MatrixWorkspace_sptr &spectraWS) const { auto appendSpectraAlg = AlgorithmManager::Instance().create("AppendSpectra"); appendSpectraAlg->initialize(); appendSpectraAlg->setChild(true); @@ -418,8 +424,8 @@ IndirectFitPlotModel::appendSpectra(MatrixWorkspace_sptr inputWS, } MatrixWorkspace_sptr -IndirectFitPlotModel::cropWorkspace(MatrixWorkspace_sptr inputWS, double startX, - double endX, int startIndex, +IndirectFitPlotModel::cropWorkspace(const MatrixWorkspace_sptr &inputWS, + double startX, double endX, int startIndex, int endIndex) const { const auto cropAlg = AlgorithmManager::Instance().create("CropWorkspace"); cropAlg->initialize(); diff --git a/qt/scientific_interfaces/Indirect/IndirectFitPlotModel.h b/qt/scientific_interfaces/Indirect/IndirectFitPlotModel.h index 58c37cc0b163db1c77feed09f94cefdd57e8d0db..9d8603612c19e00593d96e09e429c6deacc238e9 100644 --- a/qt/scientific_interfaces/Indirect/IndirectFitPlotModel.h +++ b/qt/scientific_interfaces/Indirect/IndirectFitPlotModel.h @@ -30,8 +30,8 @@ public: Mantid::API::MatrixWorkspace_sptr getGuessWorkspace() const; Spectra getSpectra() const; - Mantid::API::MatrixWorkspace_sptr - appendGuessToInput(Mantid::API::MatrixWorkspace_sptr guessWorkspace) const; + Mantid::API::MatrixWorkspace_sptr appendGuessToInput( + const Mantid::API::MatrixWorkspace_sptr &guessWorkspace) const; TableDatasetIndex getActiveDataIndex() const; WorkspaceIndex getActiveSpectrum() const; @@ -62,18 +62,19 @@ public: private: std::pair<double, double> getGuessRange() const; - Mantid::API::MatrixWorkspace_sptr - createInputAndGuessWorkspace(Mantid::API::MatrixWorkspace_sptr inputWS, - Mantid::API::MatrixWorkspace_sptr guessWorkspace, - int spectrum, double startX, double endX) const; + Mantid::API::MatrixWorkspace_sptr createInputAndGuessWorkspace( + const Mantid::API::MatrixWorkspace_sptr &inputWS, + const Mantid::API::MatrixWorkspace_sptr &guessWorkspace, int spectrum, + double startX, double endX) const; Mantid::API::MatrixWorkspace_sptr - createGuessWorkspace(Mantid::API::MatrixWorkspace_sptr inputWorkspace, - Mantid::API::IFunction_const_sptr func, double startX, - double endX) const; + createGuessWorkspace(const Mantid::API::MatrixWorkspace_sptr &inputWorkspace, + const Mantid::API::IFunction_const_sptr &func, + double startX, double endX) const; - std::vector<double> computeOutput(Mantid::API::IFunction_const_sptr func, - const std::vector<double> &dataX) const; + std::vector<double> + computeOutput(const Mantid::API::IFunction_const_sptr &func, + const std::vector<double> &dataX) const; Mantid::API::IAlgorithm_sptr createWorkspaceAlgorithm(std::size_t numberOfSpectra, @@ -81,15 +82,16 @@ private: const std::vector<double> &dataY) const; Mantid::API::MatrixWorkspace_sptr - extractSpectra(Mantid::API::MatrixWorkspace_sptr inputWS, int startIndex, - int endIndex, double startX, double endX) const; + extractSpectra(const Mantid::API::MatrixWorkspace_sptr &inputWS, + int startIndex, int endIndex, double startX, + double endX) const; Mantid::API::MatrixWorkspace_sptr - appendSpectra(Mantid::API::MatrixWorkspace_sptr inputWS, - Mantid::API::MatrixWorkspace_sptr spectraWS) const; + appendSpectra(const Mantid::API::MatrixWorkspace_sptr &inputWS, + const Mantid::API::MatrixWorkspace_sptr &spectraWS) const; Mantid::API::MatrixWorkspace_sptr - cropWorkspace(Mantid::API::MatrixWorkspace_sptr inputWS, double startX, + cropWorkspace(const Mantid::API::MatrixWorkspace_sptr &inputWS, double startX, double endX, int startIndex, int endIndex) const; void deleteWorkspace(const std::string &name) const; diff --git a/qt/scientific_interfaces/Indirect/IndirectFitPlotModelLegacy.cpp b/qt/scientific_interfaces/Indirect/IndirectFitPlotModelLegacy.cpp index 673c2894e62d5d8ed21a1f687640b09f6b6edfc5..b6bd5fc96ce99f51250fdb1ccfe197937cec39f9 100644 --- a/qt/scientific_interfaces/Indirect/IndirectFitPlotModelLegacy.cpp +++ b/qt/scientific_interfaces/Indirect/IndirectFitPlotModelLegacy.cpp @@ -6,6 +6,8 @@ // SPDX - License - Identifier: GPL - 3.0 + #include "IndirectFitPlotModelLegacy.h" +#include <utility> + #include "MantidAPI/AlgorithmManager.h" #include "MantidAPI/AnalysisDataService.h" #include "MantidAPI/CompositeFunction.h" @@ -25,9 +27,10 @@ IFunction_sptr firstFunctionWithParameter(IFunction_sptr function, const std::string &category, const std::string ¶meterName); -IFunction_sptr firstFunctionWithParameter(CompositeFunction_sptr composite, - const std::string &category, - const std::string ¶meterName) { +IFunction_sptr +firstFunctionWithParameter(const CompositeFunction_sptr &composite, + const std::string &category, + const std::string ¶meterName) { for (auto i = 0u; i < composite->nFunctions(); ++i) { const auto value = firstFunctionWithParameter(composite->getFunction(i), category, parameterName); @@ -50,7 +53,7 @@ IFunction_sptr firstFunctionWithParameter(IFunction_sptr function, return nullptr; } -boost::optional<double> firstParameterValue(IFunction_sptr function, +boost::optional<double> firstParameterValue(const IFunction_sptr &function, const std::string &category, const std::string ¶meterName) { if (!function) @@ -63,22 +66,24 @@ boost::optional<double> firstParameterValue(IFunction_sptr function, return boost::none; } -boost::optional<double> findFirstPeakCentre(IFunction_sptr function) { - return firstParameterValue(function, "Peak", "PeakCentre"); +boost::optional<double> findFirstPeakCentre(const IFunction_sptr &function) { + return firstParameterValue(std::move(function), "Peak", "PeakCentre"); } -boost::optional<double> findFirstFWHM(IFunction_sptr function) { - return firstParameterValue(function, "Peak", "FWHM"); +boost::optional<double> findFirstFWHM(const IFunction_sptr &function) { + return firstParameterValue(std::move(function), "Peak", "FWHM"); } -boost::optional<double> findFirstBackgroundLevel(IFunction_sptr function) { - return firstParameterValue(function, "Background", "A0"); +boost::optional<double> +findFirstBackgroundLevel(const IFunction_sptr &function) { + return firstParameterValue(std::move(function), "Background", "A0"); } -void setFunctionParameters(IFunction_sptr function, const std::string &category, +void setFunctionParameters(const IFunction_sptr &function, + const std::string &category, const std::string ¶meterName, double value); -void setFunctionParameters(CompositeFunction_sptr composite, +void setFunctionParameters(const CompositeFunction_sptr &composite, const std::string &category, const std::string ¶meterName, double value) { for (auto i = 0u; i < composite->nFunctions(); ++i) @@ -86,7 +91,8 @@ void setFunctionParameters(CompositeFunction_sptr composite, value); } -void setFunctionParameters(IFunction_sptr function, const std::string &category, +void setFunctionParameters(const IFunction_sptr &function, + const std::string &category, const std::string ¶meterName, double value) { if (function->category() == category && function->hasParameter(parameterName)) function->setParameter(parameterName, value); @@ -97,11 +103,11 @@ void setFunctionParameters(IFunction_sptr function, const std::string &category, } void setFirstBackground(IFunction_sptr function, double value) { - firstFunctionWithParameter(function, "Background", "A0") + firstFunctionWithParameter(std::move(function), "Background", "A0") ->setParameter("A0", value); } -MatrixWorkspace_sptr castToMatrixWorkspace(Workspace_sptr workspace) { +MatrixWorkspace_sptr castToMatrixWorkspace(const Workspace_sptr &workspace) { return boost::dynamic_pointer_cast<MatrixWorkspace>(workspace); } @@ -265,10 +271,10 @@ MatrixWorkspace_sptr IndirectFitPlotModelLegacy::getGuessWorkspace() const { } MatrixWorkspace_sptr IndirectFitPlotModelLegacy::appendGuessToInput( - MatrixWorkspace_sptr guessWorkspace) const { + const MatrixWorkspace_sptr &guessWorkspace) const { const auto range = getGuessRange(); return createInputAndGuessWorkspace( - getWorkspace(), guessWorkspace, + getWorkspace(), std::move(guessWorkspace), boost::numeric_cast<int>(m_activeSpectrum), range.first, range.second); } @@ -279,8 +285,9 @@ std::pair<double, double> IndirectFitPlotModelLegacy::getGuessRange() const { } MatrixWorkspace_sptr IndirectFitPlotModelLegacy::createInputAndGuessWorkspace( - MatrixWorkspace_sptr inputWS, MatrixWorkspace_sptr guessWorkspace, - int spectrum, double startX, double endX) const { + const MatrixWorkspace_sptr &inputWS, + const MatrixWorkspace_sptr &guessWorkspace, int spectrum, double startX, + double endX) const { guessWorkspace->setInstrument(inputWS->getInstrument()); guessWorkspace->replaceAxis( 0, @@ -300,8 +307,8 @@ MatrixWorkspace_sptr IndirectFitPlotModelLegacy::createInputAndGuessWorkspace( } MatrixWorkspace_sptr IndirectFitPlotModelLegacy::createGuessWorkspace( - MatrixWorkspace_sptr inputWorkspace, IFunction_const_sptr func, - double startX, double endX) const { + const MatrixWorkspace_sptr &inputWorkspace, + const IFunction_const_sptr &func, double startX, double endX) const { IAlgorithm_sptr createWsAlg = AlgorithmManager::Instance().create("EvaluateFunction"); createWsAlg->initialize(); @@ -321,7 +328,7 @@ MatrixWorkspace_sptr IndirectFitPlotModelLegacy::createGuessWorkspace( } std::vector<double> IndirectFitPlotModelLegacy::computeOutput( - IFunction_const_sptr func, const std::vector<double> &dataX) const { + const IFunction_const_sptr &func, const std::vector<double> &dataX) const { if (dataX.empty()) return std::vector<double>(); @@ -351,7 +358,7 @@ IAlgorithm_sptr IndirectFitPlotModelLegacy::createWorkspaceAlgorithm( } MatrixWorkspace_sptr -IndirectFitPlotModelLegacy::extractSpectra(MatrixWorkspace_sptr inputWS, +IndirectFitPlotModelLegacy::extractSpectra(const MatrixWorkspace_sptr &inputWS, int startIndex, int endIndex, double startX, double endX) const { auto extractSpectraAlg = @@ -370,7 +377,8 @@ IndirectFitPlotModelLegacy::extractSpectra(MatrixWorkspace_sptr inputWS, } MatrixWorkspace_sptr IndirectFitPlotModelLegacy::appendSpectra( - MatrixWorkspace_sptr inputWS, MatrixWorkspace_sptr spectraWS) const { + const MatrixWorkspace_sptr &inputWS, + const MatrixWorkspace_sptr &spectraWS) const { auto appendSpectraAlg = AlgorithmManager::Instance().create("AppendSpectra"); appendSpectraAlg->initialize(); appendSpectraAlg->setChild(true); @@ -383,7 +391,7 @@ MatrixWorkspace_sptr IndirectFitPlotModelLegacy::appendSpectra( } MatrixWorkspace_sptr -IndirectFitPlotModelLegacy::cropWorkspace(MatrixWorkspace_sptr inputWS, +IndirectFitPlotModelLegacy::cropWorkspace(const MatrixWorkspace_sptr &inputWS, double startX, double endX, int startIndex, int endIndex) const { const auto cropAlg = AlgorithmManager::Instance().create("CropWorkspace"); diff --git a/qt/scientific_interfaces/Indirect/IndirectFitPlotModelLegacy.h b/qt/scientific_interfaces/Indirect/IndirectFitPlotModelLegacy.h index 3f8cfc43e8e1535264f71aa73d478e91df7cf00b..2da0b9fa59b40b24f3077fbbfe2ff4b3db77c503 100644 --- a/qt/scientific_interfaces/Indirect/IndirectFitPlotModelLegacy.h +++ b/qt/scientific_interfaces/Indirect/IndirectFitPlotModelLegacy.h @@ -29,8 +29,8 @@ public: Mantid::API::MatrixWorkspace_sptr getGuessWorkspace() const; SpectraLegacy getSpectra() const; - Mantid::API::MatrixWorkspace_sptr - appendGuessToInput(Mantid::API::MatrixWorkspace_sptr guessWorkspace) const; + Mantid::API::MatrixWorkspace_sptr appendGuessToInput( + const Mantid::API::MatrixWorkspace_sptr &guessWorkspace) const; std::size_t getActiveDataIndex() const; std::size_t getActiveSpectrum() const; @@ -60,18 +60,19 @@ public: private: std::pair<double, double> getGuessRange() const; - Mantid::API::MatrixWorkspace_sptr - createInputAndGuessWorkspace(Mantid::API::MatrixWorkspace_sptr inputWS, - Mantid::API::MatrixWorkspace_sptr guessWorkspace, - int spectrum, double startX, double endX) const; + Mantid::API::MatrixWorkspace_sptr createInputAndGuessWorkspace( + const Mantid::API::MatrixWorkspace_sptr &inputWS, + const Mantid::API::MatrixWorkspace_sptr &guessWorkspace, int spectrum, + double startX, double endX) const; Mantid::API::MatrixWorkspace_sptr - createGuessWorkspace(Mantid::API::MatrixWorkspace_sptr inputWorkspace, - Mantid::API::IFunction_const_sptr func, double startX, - double endX) const; + createGuessWorkspace(const Mantid::API::MatrixWorkspace_sptr &inputWorkspace, + const Mantid::API::IFunction_const_sptr &func, + double startX, double endX) const; - std::vector<double> computeOutput(Mantid::API::IFunction_const_sptr func, - const std::vector<double> &dataX) const; + std::vector<double> + computeOutput(const Mantid::API::IFunction_const_sptr &func, + const std::vector<double> &dataX) const; Mantid::API::IAlgorithm_sptr createWorkspaceAlgorithm(std::size_t numberOfSpectra, @@ -79,15 +80,16 @@ private: const std::vector<double> &dataY) const; Mantid::API::MatrixWorkspace_sptr - extractSpectra(Mantid::API::MatrixWorkspace_sptr inputWS, int startIndex, - int endIndex, double startX, double endX) const; + extractSpectra(const Mantid::API::MatrixWorkspace_sptr &inputWS, + int startIndex, int endIndex, double startX, + double endX) const; Mantid::API::MatrixWorkspace_sptr - appendSpectra(Mantid::API::MatrixWorkspace_sptr inputWS, - Mantid::API::MatrixWorkspace_sptr spectraWS) const; + appendSpectra(const Mantid::API::MatrixWorkspace_sptr &inputWS, + const Mantid::API::MatrixWorkspace_sptr &spectraWS) const; Mantid::API::MatrixWorkspace_sptr - cropWorkspace(Mantid::API::MatrixWorkspace_sptr inputWS, double startX, + cropWorkspace(const Mantid::API::MatrixWorkspace_sptr &inputWS, double startX, double endX, int startIndex, int endIndex) const; void deleteWorkspace(const std::string &name) const; diff --git a/qt/scientific_interfaces/Indirect/IndirectFitPlotPresenter.cpp b/qt/scientific_interfaces/Indirect/IndirectFitPlotPresenter.cpp index fec31eb06db4233deeebdfa3d2a0514dfa862520..bfcea94e63e568dbbce6b6710a1fbc8a770685d5 100644 --- a/qt/scientific_interfaces/Indirect/IndirectFitPlotPresenter.cpp +++ b/qt/scientific_interfaces/Indirect/IndirectFitPlotPresenter.cpp @@ -9,6 +9,7 @@ #include "MantidQtWidgets/Common/SignalBlocker.h" #include <QTimer> +#include <utility> namespace { using MantidQt::CustomInterfaces::IDA::IIndirectFitPlotView; @@ -278,17 +279,17 @@ void IndirectFitPlotPresenter::plotLines() { } void IndirectFitPlotPresenter::plotInput(MatrixWorkspace_sptr workspace) { - plotInput(workspace, m_model->getActiveSpectrum()); + plotInput(std::move(workspace), m_model->getActiveSpectrum()); if (auto doGuess = m_view->isPlotGuessChecked()) plotGuess(doGuess); } void IndirectFitPlotPresenter::plotInput(MatrixWorkspace_sptr workspace, WorkspaceIndex spectrum) { - m_view->plotInTopPreview("Sample", workspace, spectrum, Qt::black); + m_view->plotInTopPreview("Sample", std::move(workspace), spectrum, Qt::black); } -void IndirectFitPlotPresenter::plotFit(MatrixWorkspace_sptr workspace) { +void IndirectFitPlotPresenter::plotFit(const MatrixWorkspace_sptr &workspace) { plotInput(workspace, WorkspaceIndex{0}); if (auto doGuess = m_view->isPlotGuessChecked()) plotGuess(doGuess); @@ -298,12 +299,13 @@ void IndirectFitPlotPresenter::plotFit(MatrixWorkspace_sptr workspace) { void IndirectFitPlotPresenter::plotFit(MatrixWorkspace_sptr workspace, WorkspaceIndex spectrum) { - m_view->plotInTopPreview("Fit", workspace, spectrum, Qt::red); + m_view->plotInTopPreview("Fit", std::move(workspace), spectrum, Qt::red); } void IndirectFitPlotPresenter::plotDifference(MatrixWorkspace_sptr workspace, WorkspaceIndex spectrum) { - m_view->plotInBottomPreview("Difference", workspace, spectrum, Qt::blue); + m_view->plotInBottomPreview("Difference", std::move(workspace), spectrum, + Qt::blue); } void IndirectFitPlotPresenter::updatePlotRange( @@ -360,11 +362,12 @@ void IndirectFitPlotPresenter::plotGuess(bool doPlotGuess) { void IndirectFitPlotPresenter::plotGuess( Mantid::API::MatrixWorkspace_sptr workspace) { - m_view->plotInTopPreview("Guess", workspace, WorkspaceIndex{0}, Qt::green); + m_view->plotInTopPreview("Guess", std::move(workspace), WorkspaceIndex{0}, + Qt::green); } void IndirectFitPlotPresenter::plotGuessInSeparateWindow( - Mantid::API::MatrixWorkspace_sptr workspace) { + const Mantid::API::MatrixWorkspace_sptr &workspace) { m_plotExternalGuessRunner.addCallback( [this, workspace]() { m_model->appendGuessToInput(workspace); }); } diff --git a/qt/scientific_interfaces/Indirect/IndirectFitPlotPresenter.h b/qt/scientific_interfaces/Indirect/IndirectFitPlotPresenter.h index 6c4bc0f96a21acb83be5b10e1859535263f7959b..0a4218be8eb52f52929054ec946af4fef2a411a5 100644 --- a/qt/scientific_interfaces/Indirect/IndirectFitPlotPresenter.h +++ b/qt/scientific_interfaces/Indirect/IndirectFitPlotPresenter.h @@ -91,7 +91,7 @@ private: void plotInput(Mantid::API::MatrixWorkspace_sptr workspace); void plotInput(Mantid::API::MatrixWorkspace_sptr workspace, WorkspaceIndex spectrum); - void plotFit(Mantid::API::MatrixWorkspace_sptr workspace); + void plotFit(const Mantid::API::MatrixWorkspace_sptr &workspace); void plotFit(Mantid::API::MatrixWorkspace_sptr workspace, WorkspaceIndex spectrum); void plotDifference(Mantid::API::MatrixWorkspace_sptr workspace, @@ -100,7 +100,8 @@ private: void clearFit(); void clearDifference(); void plotGuess(Mantid::API::MatrixWorkspace_sptr workspace); - void plotGuessInSeparateWindow(Mantid::API::MatrixWorkspace_sptr workspace); + void + plotGuessInSeparateWindow(const Mantid::API::MatrixWorkspace_sptr &workspace); void plotLines(); void updatePlotRange(const std::pair<double, double> &range); void clearGuess(); diff --git a/qt/scientific_interfaces/Indirect/IndirectFitPlotPresenterLegacy.cpp b/qt/scientific_interfaces/Indirect/IndirectFitPlotPresenterLegacy.cpp index b3ab5fe5f99da383b6cc9041c8c2c094facdc935..1039289f86d912575fc0df9740e02b6ea0aa428a 100644 --- a/qt/scientific_interfaces/Indirect/IndirectFitPlotPresenterLegacy.cpp +++ b/qt/scientific_interfaces/Indirect/IndirectFitPlotPresenterLegacy.cpp @@ -9,6 +9,7 @@ #include "MantidQtWidgets/Common/SignalBlocker.h" #include <QTimer> +#include <utility> namespace { using MantidQt::CustomInterfaces::IDA::DiscontinuousSpectra; @@ -264,17 +265,18 @@ void IndirectFitPlotPresenterLegacy::plotLines() { } void IndirectFitPlotPresenterLegacy::plotInput(MatrixWorkspace_sptr workspace) { - plotInput(workspace, m_model->getActiveSpectrum()); + plotInput(std::move(workspace), m_model->getActiveSpectrum()); if (auto doGuess = m_view->isPlotGuessChecked()) plotGuess(doGuess); } void IndirectFitPlotPresenterLegacy::plotInput(MatrixWorkspace_sptr workspace, std::size_t spectrum) { - m_view->plotInTopPreview("Sample", workspace, spectrum, Qt::black); + m_view->plotInTopPreview("Sample", std::move(workspace), spectrum, Qt::black); } -void IndirectFitPlotPresenterLegacy::plotFit(MatrixWorkspace_sptr workspace) { +void IndirectFitPlotPresenterLegacy::plotFit( + const MatrixWorkspace_sptr &workspace) { plotInput(workspace, 0); if (auto doGuess = m_view->isPlotGuessChecked()) plotGuess(doGuess); @@ -284,12 +286,13 @@ void IndirectFitPlotPresenterLegacy::plotFit(MatrixWorkspace_sptr workspace) { void IndirectFitPlotPresenterLegacy::plotFit(MatrixWorkspace_sptr workspace, std::size_t spectrum) { - m_view->plotInTopPreview("Fit", workspace, spectrum, Qt::red); + m_view->plotInTopPreview("Fit", std::move(workspace), spectrum, Qt::red); } void IndirectFitPlotPresenterLegacy::plotDifference( MatrixWorkspace_sptr workspace, std::size_t spectrum) { - m_view->plotInBottomPreview("Difference", workspace, spectrum, Qt::blue); + m_view->plotInBottomPreview("Difference", std::move(workspace), spectrum, + Qt::blue); } void IndirectFitPlotPresenterLegacy::updatePlotRange( @@ -346,11 +349,11 @@ void IndirectFitPlotPresenterLegacy::plotGuess(bool doPlotGuess) { void IndirectFitPlotPresenterLegacy::plotGuess( Mantid::API::MatrixWorkspace_sptr workspace) { - m_view->plotInTopPreview("Guess", workspace, 0, Qt::green); + m_view->plotInTopPreview("Guess", std::move(workspace), 0, Qt::green); } void IndirectFitPlotPresenterLegacy::plotGuessInSeparateWindow( - Mantid::API::MatrixWorkspace_sptr workspace) { + const Mantid::API::MatrixWorkspace_sptr &workspace) { m_plotExternalGuessRunner.addCallback( [this, workspace]() { m_model->appendGuessToInput(workspace); }); } diff --git a/qt/scientific_interfaces/Indirect/IndirectFitPlotPresenterLegacy.h b/qt/scientific_interfaces/Indirect/IndirectFitPlotPresenterLegacy.h index 35baeea08b4873b4315973b0d4b0b3d2d62af985..b893ba19b8acc33ae0cdd224941c662d4cad06c3 100644 --- a/qt/scientific_interfaces/Indirect/IndirectFitPlotPresenterLegacy.h +++ b/qt/scientific_interfaces/Indirect/IndirectFitPlotPresenterLegacy.h @@ -85,13 +85,14 @@ private: void plotInput(Mantid::API::MatrixWorkspace_sptr workspace); void plotInput(Mantid::API::MatrixWorkspace_sptr workspace, std::size_t spectrum); - void plotFit(Mantid::API::MatrixWorkspace_sptr workspace); + void plotFit(const Mantid::API::MatrixWorkspace_sptr &workspace); void plotFit(Mantid::API::MatrixWorkspace_sptr workspace, std::size_t spectrum); void plotDifference(Mantid::API::MatrixWorkspace_sptr workspace, std::size_t spectrum); void plotGuess(Mantid::API::MatrixWorkspace_sptr workspace); - void plotGuessInSeparateWindow(Mantid::API::MatrixWorkspace_sptr workspace); + void + plotGuessInSeparateWindow(const Mantid::API::MatrixWorkspace_sptr &workspace); void plotLines(); void updatePlotRange(const std::pair<double, double> &range); void clearGuess(); diff --git a/qt/scientific_interfaces/Indirect/IndirectFitPlotView.h b/qt/scientific_interfaces/Indirect/IndirectFitPlotView.h index 49fda6350e2f2f5d5a8a4c7d8525a737da1f4b02..f2c750704e044c7ae0b155d7b4764c8dfc294740 100644 --- a/qt/scientific_interfaces/Indirect/IndirectFitPlotView.h +++ b/qt/scientific_interfaces/Indirect/IndirectFitPlotView.h @@ -19,6 +19,7 @@ #include <QSplitterHandle> #endif #include <QSplitter> +#include <utility> namespace MantidQt { namespace CustomInterfaces { @@ -30,7 +31,7 @@ class SplitterHandle : public QSplitterHandle { public: SplitterHandle(QIcon icon, Qt::Orientation orientation, QSplitter *parent = nullptr) - : QSplitterHandle(orientation, parent), m_icon(icon) {} + : QSplitterHandle(orientation, parent), m_icon(std::move(icon)) {} void paintEvent(QPaintEvent *e) override { QSplitterHandle::paintEvent(e); @@ -47,7 +48,7 @@ private: class Splitter : public QSplitter { public: Splitter(QIcon icon, QWidget *parent = nullptr) - : QSplitter(parent), m_icon(icon) {} + : QSplitter(parent), m_icon(std::move(icon)) {} QSplitterHandle *createHandle() override { return new SplitterHandle(m_icon, Qt::Vertical, this); diff --git a/qt/scientific_interfaces/Indirect/IndirectFitPlotViewLegacy.h b/qt/scientific_interfaces/Indirect/IndirectFitPlotViewLegacy.h index 7a079933b4399a4d86d4e91c1400568f77e2f3ba..541d49473036c30d9664fcdc809a39f4aee0ead9 100644 --- a/qt/scientific_interfaces/Indirect/IndirectFitPlotViewLegacy.h +++ b/qt/scientific_interfaces/Indirect/IndirectFitPlotViewLegacy.h @@ -19,6 +19,7 @@ #include <QSplitterHandle> #endif #include <QSplitter> +#include <utility> namespace MantidQt { namespace CustomInterfaces { @@ -30,7 +31,7 @@ class SplitterHandleLegacy : public QSplitterHandle { public: SplitterHandleLegacy(QIcon icon, Qt::Orientation orientation, QSplitter *parent = nullptr) - : QSplitterHandle(orientation, parent), m_icon(icon) {} + : QSplitterHandle(orientation, parent), m_icon(std::move(icon)) {} void paintEvent(QPaintEvent *e) override { QSplitterHandle::paintEvent(e); @@ -47,7 +48,7 @@ private: class SplitterLegacy : public QSplitter { public: SplitterLegacy(QIcon icon, QWidget *parent = nullptr) - : QSplitter(parent), m_icon(icon) {} + : QSplitter(parent), m_icon(std::move(icon)) {} QSplitterHandle *createHandle() override { return new SplitterHandleLegacy(m_icon, Qt::Vertical, this); diff --git a/qt/scientific_interfaces/Indirect/IndirectFitPropertyBrowser.cpp b/qt/scientific_interfaces/Indirect/IndirectFitPropertyBrowser.cpp index 69209c537e8fa483c2972eb469ad2e9858514ff1..1471c62ee515438741fe44dba0deb011d2394b5c 100644 --- a/qt/scientific_interfaces/Indirect/IndirectFitPropertyBrowser.cpp +++ b/qt/scientific_interfaces/Indirect/IndirectFitPropertyBrowser.cpp @@ -318,7 +318,8 @@ void IndirectFitPropertyBrowser::clear() { * Updates the plot guess feature in this indirect fit property browser. * @param sampleWorkspace :: The workspace loaded as sample */ -void IndirectFitPropertyBrowser::updatePlotGuess(MatrixWorkspace_const_sptr) {} +void IndirectFitPropertyBrowser::updatePlotGuess( + const MatrixWorkspace_const_sptr &) {} void IndirectFitPropertyBrowser::setErrorsEnabled(bool enabled) { m_functionBrowser->setErrorsEnabled(enabled); diff --git a/qt/scientific_interfaces/Indirect/IndirectFitPropertyBrowser.h b/qt/scientific_interfaces/Indirect/IndirectFitPropertyBrowser.h index 369dfdfa8d69983de37261d6464044d57200e057..80fbebee9fb2c92bb6c4ef1e38f7fec07b9d8735 100644 --- a/qt/scientific_interfaces/Indirect/IndirectFitPropertyBrowser.h +++ b/qt/scientific_interfaces/Indirect/IndirectFitPropertyBrowser.h @@ -66,7 +66,7 @@ public: TableRowIndex nData, const QStringList &datasetNames, const std::vector<double> &qValues, const std::vector<std::pair<std::string, int>> &fitResolutions); - void updatePlotGuess(MatrixWorkspace_const_sptr sampleWorkspace); + void updatePlotGuess(const MatrixWorkspace_const_sptr &sampleWorkspace); void setErrorsEnabled(bool enabled); void updateParameterEstimationData(DataForParameterEstimationCollection &&data); diff --git a/qt/scientific_interfaces/Indirect/IndirectFittingModel.cpp b/qt/scientific_interfaces/Indirect/IndirectFittingModel.cpp index 2a4bf65eefd136afc0a36fb20b62a87e3626e343..67a5e0b8db4e7865b3e56e785a24f101bfbdde7c 100644 --- a/qt/scientific_interfaces/Indirect/IndirectFittingModel.cpp +++ b/qt/scientific_interfaces/Indirect/IndirectFittingModel.cpp @@ -19,6 +19,7 @@ #include <set> #include <boost/algorithm/string.hpp> +#include <utility> using namespace Mantid::API; using IDAWorkspaceIndex = MantidQt::CustomInterfaces::IDA::WorkspaceIndex; @@ -37,8 +38,8 @@ std::string cutLastOf(std::string const &str, std::string const &delimiter) { return str; } -bool equivalentWorkspaces(MatrixWorkspace_const_sptr lhs, - MatrixWorkspace_const_sptr rhs) { +bool equivalentWorkspaces(const MatrixWorkspace_const_sptr &lhs, + const MatrixWorkspace_const_sptr &rhs) { if (!lhs || !rhs) return false; else if (lhs->getName() == "" && rhs->getName() == "") @@ -50,8 +51,8 @@ bool equivalentWorkspaces(MatrixWorkspace_const_sptr lhs, * @return True if the first function precedes the second when ordering by * name. */ -bool functionNameComparator(IFunction_const_sptr first, - IFunction_const_sptr second) { +bool functionNameComparator(const IFunction_const_sptr &first, + const IFunction_const_sptr &second) { return first->name() < second->name(); } @@ -72,8 +73,8 @@ extractFunctions(const CompositeFunction &composite) { return functions; } -bool equivalentFunctions(IFunction_const_sptr func1, - IFunction_const_sptr func2); +bool equivalentFunctions(const IFunction_const_sptr &func1, + const IFunction_const_sptr &func2); /* * Checks whether the specified composite functions have the same composition. @@ -111,8 +112,8 @@ bool equivalentComposites(const CompositeFunction &composite1, * @return True if the specified functions have the same composition, * False otherwise. */ -bool equivalentFunctions(IFunction_const_sptr func1, - IFunction_const_sptr func2) { +bool equivalentFunctions(const IFunction_const_sptr &func1, + const IFunction_const_sptr &func2) { const auto composite1 = boost::dynamic_pointer_cast<const CompositeFunction>(func1); const auto composite2 = @@ -147,8 +148,8 @@ constructInputString(const IndirectFitDataCollectionType &fittingData) { return input.str(); } -void addInputDataToSimultaneousFit(IAlgorithm_sptr fitAlgorithm, - MatrixWorkspace_sptr workspace, +void addInputDataToSimultaneousFit(const IAlgorithm_sptr &fitAlgorithm, + const MatrixWorkspace_sptr &workspace, IDAWorkspaceIndex spectrum, const std::pair<double, double> &xRange, const std::vector<double> &excludeRegions, @@ -192,7 +193,7 @@ void addInputDataToSimultaneousFit( } void addInputDataToSimultaneousFit( - IAlgorithm_sptr fitAlgorithm, + const IAlgorithm_sptr &fitAlgorithm, const IndirectFitDataCollectionType &fittingData) { std::size_t counter = 0; for (const auto &data : fittingData) @@ -200,7 +201,7 @@ void addInputDataToSimultaneousFit( } void addInputDataToSimultaneousFit( - IAlgorithm_sptr fitAlgorithm, + const IAlgorithm_sptr &fitAlgorithm, const IndirectFitDataCollectionType &fittingData, const std::pair<double, double> &range, const std::vector<double> &exclude) { @@ -216,7 +217,7 @@ template <typename Map> Map combine(const Map &mapA, const Map &mapB) { } std::unordered_map<std::string, std::string> -shortToLongParameterNames(IFunction_sptr function) { +shortToLongParameterNames(const IFunction_sptr &function) { std::unordered_map<std::string, std::string> shortToLong; for (const auto &name : function->getParameterNames()) shortToLong[name.substr(name.rfind(".") + 1)] = name; @@ -279,26 +280,29 @@ IFunction_sptr extractFirstInnerFunction(const std::string &function) { template <typename WorkspaceType> boost::shared_ptr<WorkspaceType> -getWorkspaceOutput(IAlgorithm_sptr algorithm, const std::string &propertyName) { +getWorkspaceOutput(const IAlgorithm_sptr &algorithm, + const std::string &propertyName) { return AnalysisDataService::Instance().retrieveWS<WorkspaceType>( algorithm->getProperty(propertyName)); } -WorkspaceGroup_sptr getOutputResult(IAlgorithm_sptr algorithm) { - return getWorkspaceOutput<WorkspaceGroup>(algorithm, "OutputWorkspace"); +WorkspaceGroup_sptr getOutputResult(const IAlgorithm_sptr &algorithm) { + return getWorkspaceOutput<WorkspaceGroup>(std::move(algorithm), + "OutputWorkspace"); } -ITableWorkspace_sptr getOutputParameters(IAlgorithm_sptr algorithm) { - return getWorkspaceOutput<ITableWorkspace>(algorithm, +ITableWorkspace_sptr getOutputParameters(const IAlgorithm_sptr &algorithm) { + return getWorkspaceOutput<ITableWorkspace>(std::move(algorithm), "OutputParameterWorkspace"); } -WorkspaceGroup_sptr getOutputGroup(IAlgorithm_sptr algorithm) { - return getWorkspaceOutput<WorkspaceGroup>(algorithm, "OutputWorkspaceGroup"); +WorkspaceGroup_sptr getOutputGroup(const IAlgorithm_sptr &algorithm) { + return getWorkspaceOutput<WorkspaceGroup>(std::move(algorithm), + "OutputWorkspaceGroup"); } void addFitProperties(Mantid::API::IAlgorithm &algorithm, - Mantid::API::IFunction_sptr function, + const Mantid::API::IFunction_sptr &function, std::string const &xAxisUnit) { algorithm.setProperty("Function", function); algorithm.setProperty("ResultXAxisUnit", xAxisUnit); @@ -576,9 +580,10 @@ void IndirectFittingModel::addWorkspace(MatrixWorkspace_sptr workspace, addNewWorkspace(workspace, spectra); } -void IndirectFittingModel::addNewWorkspace(MatrixWorkspace_sptr workspace, - const Spectra &spectra) { - m_fittingData.emplace_back(new IndirectFitData(workspace, spectra)); +void IndirectFittingModel::addNewWorkspace( + const MatrixWorkspace_sptr &workspace, const Spectra &spectra) { + m_fittingData.emplace_back( + new IndirectFitData(std::move(workspace), spectra)); m_defaultParameters.emplace_back( createDefaultParameters(m_fittingData.last())); } @@ -626,7 +631,7 @@ void IndirectFittingModel::setFittingMode(FittingMode mode) { } void IndirectFittingModel::setFitFunction(MultiDomainFunction_sptr function) { - m_activeFunction = function; + m_activeFunction = std::move(function); m_previousModelSelected = isPreviousModelSelected(); } @@ -637,10 +642,11 @@ void IndirectFittingModel::setDefaultParameterValue( } void IndirectFittingModel::addOutput(IAlgorithm_sptr fitAlgorithm) { - addOutput(fitAlgorithm, m_fittingData.begin(), m_fittingData.end()); + addOutput(std::move(fitAlgorithm), m_fittingData.begin(), + m_fittingData.end()); } -void IndirectFittingModel::addOutput(IAlgorithm_sptr fitAlgorithm, +void IndirectFittingModel::addOutput(const IAlgorithm_sptr &fitAlgorithm, const FitDataIterator &fitDataBegin, const FitDataIterator &fitDataEnd) { auto group = getOutputGroup(fitAlgorithm); @@ -651,8 +657,8 @@ void IndirectFittingModel::addOutput(IAlgorithm_sptr fitAlgorithm, addOutput(group, parameters, result, fitDataBegin, fitDataEnd); } -void IndirectFittingModel::addSingleFitOutput(IAlgorithm_sptr fitAlgorithm, - TableDatasetIndex index) { +void IndirectFittingModel::addSingleFitOutput( + const IAlgorithm_sptr &fitAlgorithm, TableDatasetIndex index) { auto group = getOutputGroup(fitAlgorithm); auto parameters = getOutputParameters(fitAlgorithm); auto result = getOutputResult(fitAlgorithm); @@ -663,9 +669,9 @@ void IndirectFittingModel::addSingleFitOutput(IAlgorithm_sptr fitAlgorithm, WorkspaceIndex{spectrum}); } -void IndirectFittingModel::addOutput(WorkspaceGroup_sptr resultGroup, - ITableWorkspace_sptr parameterTable, - WorkspaceGroup_sptr resultWorkspace, +void IndirectFittingModel::addOutput(const WorkspaceGroup_sptr &resultGroup, + const ITableWorkspace_sptr ¶meterTable, + const WorkspaceGroup_sptr &resultWorkspace, const FitDataIterator &fitDataBegin, const FitDataIterator &fitDataEnd) { if (m_previousModelSelected && m_fitOutput) @@ -678,9 +684,9 @@ void IndirectFittingModel::addOutput(WorkspaceGroup_sptr resultGroup, m_previousModelSelected = isPreviousModelSelected(); } -void IndirectFittingModel::addOutput(WorkspaceGroup_sptr resultGroup, - ITableWorkspace_sptr parameterTable, - WorkspaceGroup_sptr resultWorkspace, +void IndirectFittingModel::addOutput(const WorkspaceGroup_sptr &resultGroup, + const ITableWorkspace_sptr ¶meterTable, + const WorkspaceGroup_sptr &resultWorkspace, IndirectFitData *fitData, WorkspaceIndex spectrum) { if (m_previousModelSelected && m_fitOutput) @@ -696,8 +702,9 @@ IndirectFitOutput IndirectFittingModel::createFitOutput( WorkspaceGroup_sptr resultGroup, ITableWorkspace_sptr parameterTable, WorkspaceGroup_sptr resultWorkspace, const FitDataIterator &fitDataBegin, const FitDataIterator &fitDataEnd) const { - return IndirectFitOutput(resultGroup, parameterTable, resultWorkspace, - fitDataBegin, fitDataEnd); + return IndirectFitOutput(std::move(resultGroup), std::move(parameterTable), + std::move(resultWorkspace), fitDataBegin, + fitDataEnd); } IndirectFitOutput IndirectFittingModel::createFitOutput( @@ -705,8 +712,8 @@ IndirectFitOutput IndirectFittingModel::createFitOutput( Mantid::API::ITableWorkspace_sptr parameterTable, Mantid::API::WorkspaceGroup_sptr resultWorkspace, IndirectFitData *fitData, WorkspaceIndex spectrum) const { - return IndirectFitOutput(resultGroup, parameterTable, resultWorkspace, - fitData, spectrum); + return IndirectFitOutput(std::move(resultGroup), std::move(parameterTable), + std::move(resultWorkspace), fitData, spectrum); } void IndirectFittingModel::addOutput(IndirectFitOutput *fitOutput, @@ -715,8 +722,8 @@ void IndirectFittingModel::addOutput(IndirectFitOutput *fitOutput, WorkspaceGroup_sptr resultWorkspace, const FitDataIterator &fitDataBegin, const FitDataIterator &fitDataEnd) const { - fitOutput->addOutput(resultGroup, parameterTable, resultWorkspace, - fitDataBegin, fitDataEnd); + fitOutput->addOutput(std::move(resultGroup), std::move(parameterTable), + std::move(resultWorkspace), fitDataBegin, fitDataEnd); } void IndirectFittingModel::addOutput( @@ -724,8 +731,8 @@ void IndirectFittingModel::addOutput( Mantid::API::ITableWorkspace_sptr parameterTable, Mantid::API::WorkspaceGroup_sptr resultWorkspace, IndirectFitData *fitData, WorkspaceIndex spectrum) const { - fitOutput->addOutput(resultGroup, parameterTable, resultWorkspace, fitData, - spectrum); + fitOutput->addOutput(std::move(resultGroup), std::move(parameterTable), + std::move(resultWorkspace), fitData, spectrum); } FittingMode IndirectFittingModel::getFittingMode() const { @@ -867,14 +874,15 @@ IndirectFittingModel::simultaneousFitAlgorithm() const { IAlgorithm_sptr IndirectFittingModel::createSequentialFit(IFunction_sptr function) const { const auto input = constructInputString(m_fittingData); - return createSequentialFit(function, input, m_fittingData.front().get()); + return createSequentialFit(std::move(function), input, + m_fittingData.front().get()); } IAlgorithm_sptr IndirectFittingModel::createSequentialFit( - IFunction_sptr function, const std::string &input, + const IFunction_sptr &function, const std::string &input, IndirectFitData *initialFitData) const { auto fitAlgorithm = sequentialFitAlgorithm(); - addFitProperties(*fitAlgorithm, function, getResultXAxisUnit()); + addFitProperties(*fitAlgorithm, std::move(function), getResultXAxisUnit()); fitAlgorithm->setProperty("Input", input); fitAlgorithm->setProperty("OutputWorkspace", sequentialFitOutputName()); fitAlgorithm->setProperty("LogName", getResultLogName()); @@ -892,7 +900,7 @@ IAlgorithm_sptr IndirectFittingModel::createSequentialFit( } IAlgorithm_sptr IndirectFittingModel::createSimultaneousFit( - MultiDomainFunction_sptr function) const { + const MultiDomainFunction_sptr &function) const { auto fitAlgorithm = simultaneousFitAlgorithm(); addFitProperties(*fitAlgorithm, function, getResultXAxisUnit()); addInputDataToSimultaneousFit(fitAlgorithm, m_fittingData); @@ -901,9 +909,9 @@ IAlgorithm_sptr IndirectFittingModel::createSimultaneousFit( } IAlgorithm_sptr IndirectFittingModel::createSimultaneousFitWithEqualRange( - IFunction_sptr function) const { + const IFunction_sptr &function) const { auto fitAlgorithm = simultaneousFitAlgorithm(); - addFitProperties(*fitAlgorithm, function, getResultXAxisUnit()); + addFitProperties(*fitAlgorithm, std::move(function), getResultXAxisUnit()); auto const dataIndex = TableDatasetIndex{0}; auto const workspaceIndex = getSpectra(dataIndex).front(); @@ -931,12 +939,13 @@ std::string IndirectFittingModel::getOutputBasename() const { return cutLastOf(sequentialFitOutputName(), "_Results"); } -void IndirectFittingModel::cleanFailedRun(IAlgorithm_sptr fittingAlgorithm) { +void IndirectFittingModel::cleanFailedRun( + const IAlgorithm_sptr &fittingAlgorithm) { cleanTemporaries(fittingAlgorithm->name(), m_fittingData); } void IndirectFittingModel::cleanFailedSingleRun( - IAlgorithm_sptr fittingAlgorithm, TableDatasetIndex index) { + const IAlgorithm_sptr &fittingAlgorithm, TableDatasetIndex index) { const auto base = "__" + fittingAlgorithm->name() + "_ws" + std::to_string(index.value + 1); removeFromADSIfExists(base); @@ -945,7 +954,7 @@ void IndirectFittingModel::cleanFailedSingleRun( DataForParameterEstimationCollection IndirectFittingModel::getDataForParameterEstimation( - EstimationDataSelector selector) const { + const EstimationDataSelector &selector) const { DataForParameterEstimationCollection dataCollection; for (auto i = m_fittingData.zero(); i < m_fittingData.size(); ++i) { auto const &data = *m_fittingData[i]; diff --git a/qt/scientific_interfaces/Indirect/IndirectFittingModel.h b/qt/scientific_interfaces/Indirect/IndirectFittingModel.h index dd5b37ad3c2edb92740c20790fa24bc2653c814d..b4b39ccbb0ab93ab8906fb5d482988c9eb06820e 100644 --- a/qt/scientific_interfaces/Indirect/IndirectFittingModel.h +++ b/qt/scientific_interfaces/Indirect/IndirectFittingModel.h @@ -109,7 +109,7 @@ public: virtual void setFitFunction(Mantid::API::MultiDomainFunction_sptr function); virtual void setDefaultParameterValue(const std::string &name, double value, TableDatasetIndex dataIndex); - void addSingleFitOutput(Mantid::API::IAlgorithm_sptr fitAlgorithm, + void addSingleFitOutput(const Mantid::API::IAlgorithm_sptr &fitAlgorithm, TableDatasetIndex index); virtual void addOutput(Mantid::API::IAlgorithm_sptr fitAlgorithm); @@ -135,11 +135,12 @@ public: WorkspaceIndex spectrum) const; std::string getOutputBasename() const; - void cleanFailedRun(Mantid::API::IAlgorithm_sptr fittingAlgorithm); - void cleanFailedSingleRun(Mantid::API::IAlgorithm_sptr fittingAlgorithm, - TableDatasetIndex index); + void cleanFailedRun(const Mantid::API::IAlgorithm_sptr &fittingAlgorithm); + void + cleanFailedSingleRun(const Mantid::API::IAlgorithm_sptr &fittingAlgorithm, + TableDatasetIndex index); DataForParameterEstimationCollection - getDataForParameterEstimation(EstimationDataSelector selector) const; + getDataForParameterEstimation(const EstimationDataSelector &selector) const; std::vector<double> getQValuesForData() const; virtual std::vector<std::pair<std::string, int>> getResolutionsForFit() const; @@ -148,17 +149,17 @@ protected: Mantid::API::IAlgorithm_sptr getFittingAlgorithm(FittingMode mode) const; Mantid::API::IAlgorithm_sptr createSequentialFit(Mantid::API::IFunction_sptr function) const; - Mantid::API::IAlgorithm_sptr - createSimultaneousFit(Mantid::API::MultiDomainFunction_sptr function) const; + Mantid::API::IAlgorithm_sptr createSimultaneousFit( + const Mantid::API::MultiDomainFunction_sptr &function) const; Mantid::API::IAlgorithm_sptr createSimultaneousFitWithEqualRange( - Mantid::API::IFunction_sptr function) const; + const Mantid::API::IFunction_sptr &function) const; virtual Mantid::API::MultiDomainFunction_sptr getMultiDomainFunction() const; virtual std::unordered_map<std::string, std::string> mapDefaultParameterNames() const; std::string createSingleFitOutputName(const std::string &formatString, TableDatasetIndex index, WorkspaceIndex spectrum) const; - void addNewWorkspace(Mantid::API::MatrixWorkspace_sptr workspace, + void addNewWorkspace(const Mantid::API::MatrixWorkspace_sptr &workspace, const Spectra &spectra); void removeFittingData(TableDatasetIndex index); @@ -168,7 +169,7 @@ private: void removeWorkspaceFromFittingData(TableDatasetIndex const &index); Mantid::API::IAlgorithm_sptr - createSequentialFit(Mantid::API::IFunction_sptr function, + createSequentialFit(const Mantid::API::IFunction_sptr &function, const std::string &input, IndirectFitData *initialFitData) const; virtual Mantid::API::IAlgorithm_sptr sequentialFitAlgorithm() const; @@ -197,17 +198,17 @@ private: Mantid::API::WorkspaceGroup_sptr resultWorkspace, IndirectFitData *fitData, WorkspaceIndex spectrum) const; - void addOutput(Mantid::API::IAlgorithm_sptr fitAlgorithm, + void addOutput(const Mantid::API::IAlgorithm_sptr &fitAlgorithm, const FitDataIterator &fitDataBegin, const FitDataIterator &fitDataEnd); - void addOutput(Mantid::API::WorkspaceGroup_sptr resultGroup, - Mantid::API::ITableWorkspace_sptr parameterTable, - Mantid::API::WorkspaceGroup_sptr resultWorkspace, + void addOutput(const Mantid::API::WorkspaceGroup_sptr &resultGroup, + const Mantid::API::ITableWorkspace_sptr ¶meterTable, + const Mantid::API::WorkspaceGroup_sptr &resultWorkspace, const FitDataIterator &fitDataBegin, const FitDataIterator &fitDataEnd); - void addOutput(Mantid::API::WorkspaceGroup_sptr resultGroup, - Mantid::API::ITableWorkspace_sptr parameterTable, - Mantid::API::WorkspaceGroup_sptr resultWorkspace, + void addOutput(const Mantid::API::WorkspaceGroup_sptr &resultGroup, + const Mantid::API::ITableWorkspace_sptr ¶meterTable, + const Mantid::API::WorkspaceGroup_sptr &resultWorkspace, IndirectFitData *fitData, WorkspaceIndex spectrum); virtual void addOutput(IndirectFitOutput *fitOutput, diff --git a/qt/scientific_interfaces/Indirect/IndirectFittingModelLegacy.cpp b/qt/scientific_interfaces/Indirect/IndirectFittingModelLegacy.cpp index 059c0de67ff38f0847e8ec4922932189981c37f1..fb1120f4b61c61ed7219c6a4ebf00032349597e6 100644 --- a/qt/scientific_interfaces/Indirect/IndirectFittingModelLegacy.cpp +++ b/qt/scientific_interfaces/Indirect/IndirectFittingModelLegacy.cpp @@ -19,6 +19,7 @@ #include <set> #include <boost/algorithm/string.hpp> +#include <utility> using namespace Mantid::API; @@ -36,8 +37,8 @@ std::string cutLastOf(std::string const &str, std::string const &delimiter) { return str; } -bool equivalentWorkspaces(MatrixWorkspace_const_sptr lhs, - MatrixWorkspace_const_sptr rhs) { +bool equivalentWorkspaces(const MatrixWorkspace_const_sptr &lhs, + const MatrixWorkspace_const_sptr &rhs) { if (!lhs || !rhs) return false; else if (lhs->getName() == "" && rhs->getName() == "") @@ -49,8 +50,8 @@ bool equivalentWorkspaces(MatrixWorkspace_const_sptr lhs, * @return True if the first function precedes the second when ordering by * name. */ -bool functionNameComparator(IFunction_const_sptr first, - IFunction_const_sptr second) { +bool functionNameComparator(const IFunction_const_sptr &first, + const IFunction_const_sptr &second) { return first->name() < second->name(); } @@ -71,8 +72,8 @@ extractFunctions(const CompositeFunction &composite) { return functions; } -bool equivalentFunctions(IFunction_const_sptr func1, - IFunction_const_sptr func2); +bool equivalentFunctions(const IFunction_const_sptr &func1, + const IFunction_const_sptr &func2); /* * Checks whether the specified composite functions have the same composition. @@ -110,8 +111,8 @@ bool equivalentComposites(const CompositeFunction &composite1, * @return True if the specified functions have the same composition, * False otherwise. */ -bool equivalentFunctions(IFunction_const_sptr func1, - IFunction_const_sptr func2) { +bool equivalentFunctions(const IFunction_const_sptr &func1, + const IFunction_const_sptr &func2) { const auto composite1 = boost::dynamic_pointer_cast<const CompositeFunction>(func1); const auto composite2 = @@ -146,8 +147,8 @@ std::string constructInputString( return input.str(); } -void addInputDataToSimultaneousFit(IAlgorithm_sptr fitAlgorithm, - MatrixWorkspace_sptr workspace, +void addInputDataToSimultaneousFit(const IAlgorithm_sptr &fitAlgorithm, + const MatrixWorkspace_sptr &workspace, std::size_t spectrum, const std::pair<double, double> &xRange, const std::vector<double> &excludeRegions, @@ -193,7 +194,7 @@ void addInputDataToSimultaneousFit( } void addInputDataToSimultaneousFit( - IAlgorithm_sptr fitAlgorithm, + const IAlgorithm_sptr &fitAlgorithm, const std::vector<std::unique_ptr<IndirectFitDataLegacy>> &fittingData) { std::size_t counter = 0; for (const auto &data : fittingData) @@ -201,7 +202,7 @@ void addInputDataToSimultaneousFit( } void addInputDataToSimultaneousFit( - IAlgorithm_sptr fitAlgorithm, + const IAlgorithm_sptr &fitAlgorithm, const std::vector<std::unique_ptr<IndirectFitDataLegacy>> &fittingData, const std::pair<double, double> &range, const std::vector<double> &exclude) { @@ -217,7 +218,7 @@ template <typename Map> Map combine(const Map &mapA, const Map &mapB) { } std::unordered_map<std::string, std::string> -shortToLongParameterNames(IFunction_sptr function) { +shortToLongParameterNames(const IFunction_sptr &function) { std::unordered_map<std::string, std::string> shortToLong; for (const auto &name : function->getParameterNames()) shortToLong[name.substr(name.rfind(".") + 1)] = name; @@ -264,7 +265,7 @@ void cleanTemporaries( cleanTemporaries(prefix + std::to_string(i + 1), fittingData[i]); } -CompositeFunction_sptr createMultiDomainFunction(IFunction_sptr function, +CompositeFunction_sptr createMultiDomainFunction(const IFunction_sptr &function, std::size_t numberOfDomains) { auto multiDomainFunction = boost::make_shared<MultiDomainFunction>(); @@ -291,26 +292,29 @@ IFunction_sptr extractFirstInnerFunction(const std::string &function) { template <typename WorkspaceType> boost::shared_ptr<WorkspaceType> -getWorkspaceOutput(IAlgorithm_sptr algorithm, const std::string &propertyName) { +getWorkspaceOutput(const IAlgorithm_sptr &algorithm, + const std::string &propertyName) { return AnalysisDataService::Instance().retrieveWS<WorkspaceType>( algorithm->getProperty(propertyName)); } -WorkspaceGroup_sptr getOutputResult(IAlgorithm_sptr algorithm) { - return getWorkspaceOutput<WorkspaceGroup>(algorithm, "OutputWorkspace"); +WorkspaceGroup_sptr getOutputResult(const IAlgorithm_sptr &algorithm) { + return getWorkspaceOutput<WorkspaceGroup>(std::move(algorithm), + "OutputWorkspace"); } -ITableWorkspace_sptr getOutputParameters(IAlgorithm_sptr algorithm) { - return getWorkspaceOutput<ITableWorkspace>(algorithm, +ITableWorkspace_sptr getOutputParameters(const IAlgorithm_sptr &algorithm) { + return getWorkspaceOutput<ITableWorkspace>(std::move(algorithm), "OutputParameterWorkspace"); } -WorkspaceGroup_sptr getOutputGroup(IAlgorithm_sptr algorithm) { - return getWorkspaceOutput<WorkspaceGroup>(algorithm, "OutputWorkspaceGroup"); +WorkspaceGroup_sptr getOutputGroup(const IAlgorithm_sptr &algorithm) { + return getWorkspaceOutput<WorkspaceGroup>(std::move(algorithm), + "OutputWorkspaceGroup"); } void addFitProperties(Mantid::API::IAlgorithm &algorithm, - Mantid::API::IFunction_sptr function, + const Mantid::API::IFunction_sptr &function, std::string const &xAxisUnit) { algorithm.setProperty("Function", function); algorithm.setProperty("ResultXAxisUnit", xAxisUnit); @@ -550,7 +554,8 @@ void IndirectFittingModelLegacy::addWorkspace(MatrixWorkspace_sptr workspace, void IndirectFittingModelLegacy::addNewWorkspace(MatrixWorkspace_sptr workspace, const SpectraLegacy &spectra) { - m_fittingData.emplace_back(new IndirectFitDataLegacy(workspace, spectra)); + m_fittingData.emplace_back( + new IndirectFitDataLegacy(std::move(workspace), spectra)); m_defaultParameters.emplace_back( createDefaultParameters(m_fittingData.size() - 1)); } @@ -596,7 +601,7 @@ void IndirectFittingModelLegacy::setFittingMode(FittingModeLegacy mode) { } void IndirectFittingModelLegacy::setFitFunction(IFunction_sptr function) { - m_activeFunction = function; + m_activeFunction = std::move(function); m_previousModelSelected = isPreviousModelSelected(); } @@ -607,11 +612,13 @@ void IndirectFittingModelLegacy::setDefaultParameterValue( } void IndirectFittingModelLegacy::addOutput(IAlgorithm_sptr fitAlgorithm) { - addOutput(fitAlgorithm, m_fittingData.begin(), m_fittingData.end()); + addOutput(std::move(fitAlgorithm), m_fittingData.begin(), + m_fittingData.end()); } void IndirectFittingModelLegacy::addOutput( - IAlgorithm_sptr fitAlgorithm, const FitDataIteratorLegacy &fitDataBegin, + const IAlgorithm_sptr &fitAlgorithm, + const FitDataIteratorLegacy &fitDataBegin, const FitDataIteratorLegacy &fitDataEnd) { auto group = getOutputGroup(fitAlgorithm); auto parameters = getOutputParameters(fitAlgorithm); @@ -622,7 +629,7 @@ void IndirectFittingModelLegacy::addOutput( } void IndirectFittingModelLegacy::addSingleFitOutput( - IAlgorithm_sptr fitAlgorithm, std::size_t index) { + const IAlgorithm_sptr &fitAlgorithm, std::size_t index) { auto group = getOutputGroup(fitAlgorithm); auto parameters = getOutputParameters(fitAlgorithm); auto result = getOutputResult(fitAlgorithm); @@ -634,8 +641,9 @@ void IndirectFittingModelLegacy::addSingleFitOutput( } void IndirectFittingModelLegacy::addOutput( - WorkspaceGroup_sptr resultGroup, ITableWorkspace_sptr parameterTable, - WorkspaceGroup_sptr resultWorkspace, + const WorkspaceGroup_sptr &resultGroup, + const ITableWorkspace_sptr ¶meterTable, + const WorkspaceGroup_sptr &resultWorkspace, const FitDataIteratorLegacy &fitDataBegin, const FitDataIteratorLegacy &fitDataEnd) { if (m_previousModelSelected && m_fitOutput) @@ -648,11 +656,11 @@ void IndirectFittingModelLegacy::addOutput( m_previousModelSelected = isPreviousModelSelected(); } -void IndirectFittingModelLegacy::addOutput(WorkspaceGroup_sptr resultGroup, - ITableWorkspace_sptr parameterTable, - WorkspaceGroup_sptr resultWorkspace, - IndirectFitDataLegacy *fitData, - std::size_t spectrum) { +void IndirectFittingModelLegacy::addOutput( + const WorkspaceGroup_sptr &resultGroup, + const ITableWorkspace_sptr ¶meterTable, + const WorkspaceGroup_sptr &resultWorkspace, IndirectFitDataLegacy *fitData, + std::size_t spectrum) { if (m_previousModelSelected && m_fitOutput) addOutput(m_fitOutput.get(), resultGroup, parameterTable, resultWorkspace, fitData, spectrum); @@ -667,8 +675,9 @@ IndirectFitOutputLegacy IndirectFittingModelLegacy::createFitOutput( WorkspaceGroup_sptr resultWorkspace, const FitDataIteratorLegacy &fitDataBegin, const FitDataIteratorLegacy &fitDataEnd) const { - return IndirectFitOutputLegacy(resultGroup, parameterTable, resultWorkspace, - fitDataBegin, fitDataEnd); + return IndirectFitOutputLegacy( + std::move(resultGroup), std::move(parameterTable), + std::move(resultWorkspace), fitDataBegin, fitDataEnd); } IndirectFitOutputLegacy IndirectFittingModelLegacy::createFitOutput( @@ -676,8 +685,9 @@ IndirectFitOutputLegacy IndirectFittingModelLegacy::createFitOutput( Mantid::API::ITableWorkspace_sptr parameterTable, Mantid::API::WorkspaceGroup_sptr resultWorkspace, IndirectFitDataLegacy *fitData, std::size_t spectrum) const { - return IndirectFitOutputLegacy(resultGroup, parameterTable, resultWorkspace, - fitData, spectrum); + return IndirectFitOutputLegacy(std::move(resultGroup), + std::move(parameterTable), + std::move(resultWorkspace), fitData, spectrum); } void IndirectFittingModelLegacy::addOutput( @@ -685,8 +695,8 @@ void IndirectFittingModelLegacy::addOutput( ITableWorkspace_sptr parameterTable, WorkspaceGroup_sptr resultWorkspace, const FitDataIteratorLegacy &fitDataBegin, const FitDataIteratorLegacy &fitDataEnd) const { - fitOutput->addOutput(resultGroup, parameterTable, resultWorkspace, - fitDataBegin, fitDataEnd); + fitOutput->addOutput(std::move(resultGroup), std::move(parameterTable), + std::move(resultWorkspace), fitDataBegin, fitDataEnd); } void IndirectFittingModelLegacy::addOutput( @@ -695,8 +705,8 @@ void IndirectFittingModelLegacy::addOutput( Mantid::API::ITableWorkspace_sptr parameterTable, Mantid::API::WorkspaceGroup_sptr resultWorkspace, IndirectFitDataLegacy *fitData, std::size_t spectrum) const { - fitOutput->addOutput(resultGroup, parameterTable, resultWorkspace, fitData, - spectrum); + fitOutput->addOutput(std::move(resultGroup), std::move(parameterTable), + std::move(resultWorkspace), fitData, spectrum); } FittingModeLegacy IndirectFittingModelLegacy::getFittingMode() const { @@ -820,14 +830,15 @@ IndirectFittingModelLegacy::simultaneousFitAlgorithm() const { IAlgorithm_sptr IndirectFittingModelLegacy::createSequentialFit(IFunction_sptr function) const { const auto input = constructInputString(m_fittingData); - return createSequentialFit(function, input, m_fittingData.front().get()); + return createSequentialFit(std::move(function), input, + m_fittingData.front().get()); } IAlgorithm_sptr IndirectFittingModelLegacy::createSequentialFit( - IFunction_sptr function, const std::string &input, + const IFunction_sptr &function, const std::string &input, IndirectFitDataLegacy *initialFitData) const { auto fitAlgorithm = sequentialFitAlgorithm(); - addFitProperties(*fitAlgorithm, function, getResultXAxisUnit()); + addFitProperties(*fitAlgorithm, std::move(function), getResultXAxisUnit()); fitAlgorithm->setProperty("Input", input); fitAlgorithm->setProperty("OutputWorkspace", sequentialFitOutputName()); fitAlgorithm->setProperty("PassWSIndexToFunction", true); @@ -845,18 +856,18 @@ IAlgorithm_sptr IndirectFittingModelLegacy::createSequentialFit( } IAlgorithm_sptr IndirectFittingModelLegacy::createSimultaneousFit( - IFunction_sptr function) const { + const IFunction_sptr &function) const { auto fitAlgorithm = simultaneousFitAlgorithm(); - addFitProperties(*fitAlgorithm, function, getResultXAxisUnit()); + addFitProperties(*fitAlgorithm, std::move(function), getResultXAxisUnit()); addInputDataToSimultaneousFit(fitAlgorithm, m_fittingData); fitAlgorithm->setProperty("OutputWorkspace", simultaneousFitOutputName()); return fitAlgorithm; } IAlgorithm_sptr IndirectFittingModelLegacy::createSimultaneousFitWithEqualRange( - IFunction_sptr function) const { + const IFunction_sptr &function) const { auto fitAlgorithm = simultaneousFitAlgorithm(); - addFitProperties(*fitAlgorithm, function, getResultXAxisUnit()); + addFitProperties(*fitAlgorithm, std::move(function), getResultXAxisUnit()); auto exclude = vectorFromStringLegacy<double>(getExcludeRegion(0, 0)); addInputDataToSimultaneousFit(fitAlgorithm, m_fittingData, @@ -880,12 +891,12 @@ std::string IndirectFittingModelLegacy::getOutputBasename() const { } void IndirectFittingModelLegacy::cleanFailedRun( - IAlgorithm_sptr fittingAlgorithm) { + const IAlgorithm_sptr &fittingAlgorithm) { cleanTemporaries(fittingAlgorithm->name(), m_fittingData); } void IndirectFittingModelLegacy::cleanFailedSingleRun( - IAlgorithm_sptr fittingAlgorithm, std::size_t index) { + const IAlgorithm_sptr &fittingAlgorithm, std::size_t index) { const auto base = "__" + fittingAlgorithm->name() + "_ws" + std::to_string(index + 1); removeFromADSIfExists(base); diff --git a/qt/scientific_interfaces/Indirect/IndirectFittingModelLegacy.h b/qt/scientific_interfaces/Indirect/IndirectFittingModelLegacy.h index 1e316cc02dd050abc94f8bd7fa8161bd574a2d32..d87fee500ee4439fad1b67dd3fde9936ea76ea58 100644 --- a/qt/scientific_interfaces/Indirect/IndirectFittingModelLegacy.h +++ b/qt/scientific_interfaces/Indirect/IndirectFittingModelLegacy.h @@ -96,7 +96,7 @@ public: virtual void setFitFunction(Mantid::API::IFunction_sptr function); virtual void setDefaultParameterValue(const std::string &name, double value, std::size_t dataIndex); - void addSingleFitOutput(Mantid::API::IAlgorithm_sptr fitAlgorithm, + void addSingleFitOutput(const Mantid::API::IAlgorithm_sptr &fitAlgorithm, std::size_t index); virtual void addOutput(Mantid::API::IAlgorithm_sptr fitAlgorithm); @@ -119,9 +119,10 @@ public: std::size_t spectrum) const; std::string getOutputBasename() const; - void cleanFailedRun(Mantid::API::IAlgorithm_sptr fittingAlgorithm); - void cleanFailedSingleRun(Mantid::API::IAlgorithm_sptr fittingAlgorithm, - std::size_t index); + void cleanFailedRun(const Mantid::API::IAlgorithm_sptr &fittingAlgorithm); + void + cleanFailedSingleRun(const Mantid::API::IAlgorithm_sptr &fittingAlgorithm, + std::size_t index); protected: Mantid::API::IAlgorithm_sptr @@ -129,9 +130,9 @@ protected: Mantid::API::IAlgorithm_sptr createSequentialFit(Mantid::API::IFunction_sptr function) const; Mantid::API::IAlgorithm_sptr - createSimultaneousFit(Mantid::API::IFunction_sptr function) const; + createSimultaneousFit(const Mantid::API::IFunction_sptr &function) const; Mantid::API::IAlgorithm_sptr createSimultaneousFitWithEqualRange( - Mantid::API::IFunction_sptr function) const; + const Mantid::API::IFunction_sptr &function) const; virtual Mantid::API::CompositeFunction_sptr getMultiDomainFunction() const; virtual std::unordered_map<std::string, std::string> mapDefaultParameterNames() const; @@ -148,7 +149,7 @@ private: void removeWorkspaceFromFittingData(std::size_t const &index); Mantid::API::IAlgorithm_sptr - createSequentialFit(Mantid::API::IFunction_sptr function, + createSequentialFit(const Mantid::API::IFunction_sptr &function, const std::string &input, IndirectFitDataLegacy *initialFitData) const; virtual Mantid::API::IAlgorithm_sptr sequentialFitAlgorithm() const; @@ -177,17 +178,17 @@ private: Mantid::API::WorkspaceGroup_sptr resultWorkspace, IndirectFitDataLegacy *fitData, std::size_t spectrum) const; - void addOutput(Mantid::API::IAlgorithm_sptr fitAlgorithm, + void addOutput(const Mantid::API::IAlgorithm_sptr &fitAlgorithm, const FitDataIteratorLegacy &fitDataBegin, const FitDataIteratorLegacy &fitDataEnd); - void addOutput(Mantid::API::WorkspaceGroup_sptr resultGroup, - Mantid::API::ITableWorkspace_sptr parameterTable, - Mantid::API::WorkspaceGroup_sptr resultWorkspace, + void addOutput(const Mantid::API::WorkspaceGroup_sptr &resultGroup, + const Mantid::API::ITableWorkspace_sptr ¶meterTable, + const Mantid::API::WorkspaceGroup_sptr &resultWorkspace, const FitDataIteratorLegacy &fitDataBegin, const FitDataIteratorLegacy &fitDataEnd); - void addOutput(Mantid::API::WorkspaceGroup_sptr resultGroup, - Mantid::API::ITableWorkspace_sptr parameterTable, - Mantid::API::WorkspaceGroup_sptr resultWorkspace, + void addOutput(const Mantid::API::WorkspaceGroup_sptr &resultGroup, + const Mantid::API::ITableWorkspace_sptr ¶meterTable, + const Mantid::API::WorkspaceGroup_sptr &resultWorkspace, IndirectFitDataLegacy *fitData, std::size_t spectrum); virtual void addOutput(IndirectFitOutputLegacy *fitOutput, diff --git a/qt/scientific_interfaces/Indirect/IndirectFunctionBrowser/ConvFunctionModel.cpp b/qt/scientific_interfaces/Indirect/IndirectFunctionBrowser/ConvFunctionModel.cpp index 563f7ba7366fedafec1408722656a80ceecff8c0..0cf9dc9adbe76ad0176ecc227295b216d5048b36 100644 --- a/qt/scientific_interfaces/Indirect/IndirectFunctionBrowser/ConvFunctionModel.cpp +++ b/qt/scientific_interfaces/Indirect/IndirectFunctionBrowser/ConvFunctionModel.cpp @@ -69,7 +69,7 @@ void ConvFunctionModel::setFunction(IFunction_sptr fun) { m_model.setFunction(fun); } -void ConvFunctionModel::checkConvolution(IFunction_sptr fun) { +void ConvFunctionModel::checkConvolution(const IFunction_sptr &fun) { bool isFitTypeSet = false; bool isResolutionSet = false; for (size_t i = 0; i < fun->nFunctions(); ++i) { @@ -102,7 +102,7 @@ void ConvFunctionModel::checkConvolution(IFunction_sptr fun) { } } -void ConvFunctionModel::checkSingleFunction(IFunction_sptr fun, +void ConvFunctionModel::checkSingleFunction(const IFunction_sptr &fun, bool &isFitTypeSet) { assert(fun->nFunctions() == 0); auto const name = fun->name(); @@ -609,7 +609,7 @@ void ConvFunctionModel::setCurrentValues(const QMap<ParamID, double> &values) { } void ConvFunctionModel::applyParameterFunction( - std::function<void(ParamID)> paramFun) const { + const std::function<void(ParamID)> ¶mFun) const { applyToFitType(m_fitType, paramFun); applyToBackground(m_backgroundType, paramFun); applyToDelta(m_hasDeltaFunction, paramFun); diff --git a/qt/scientific_interfaces/Indirect/IndirectFunctionBrowser/ConvFunctionModel.h b/qt/scientific_interfaces/Indirect/IndirectFunctionBrowser/ConvFunctionModel.h index 2f67831a5e25f165af7d358ae1e5807200422b37..edfa5f477bf7d12ac9c9bd5671f5f8e276016be4 100644 --- a/qt/scientific_interfaces/Indirect/IndirectFunctionBrowser/ConvFunctionModel.h +++ b/qt/scientific_interfaces/Indirect/IndirectFunctionBrowser/ConvFunctionModel.h @@ -115,7 +115,8 @@ private: boost::optional<QString> getParameterDescription(ParamID name) const; boost::optional<QString> getPrefix(ParamID name) const; void setCurrentValues(const QMap<ParamID, double> &); - void applyParameterFunction(std::function<void(ParamID)> paramFun) const; + void + applyParameterFunction(const std::function<void(ParamID)> ¶mFun) const; boost::optional<ParamID> getParameterId(const QString &parName); std::string buildLorentzianFunctionString() const; std::string buildTeixeiraFunctionString() const; @@ -130,8 +131,8 @@ private: void removeGlobal(const QString &parName); QStringList makeGlobalList() const; int getNumberOfPeaks() const; - void checkConvolution(IFunction_sptr fun); - void checkSingleFunction(IFunction_sptr fun, bool &isFitTypeSet); + void checkConvolution(const IFunction_sptr &fun); + void checkSingleFunction(const IFunction_sptr &fun, bool &isFitTypeSet); ConvolutionFunctionModel m_model; FitType m_fitType = FitType::None; diff --git a/qt/scientific_interfaces/Indirect/IndirectFunctionBrowser/ConvTypes.h b/qt/scientific_interfaces/Indirect/IndirectFunctionBrowser/ConvTypes.h index daaedec3ca4a1002c275e89563bb20cb0c631a8d..99473fdaed02f6e47418adb05dd9f89650721732 100644 --- a/qt/scientific_interfaces/Indirect/IndirectFunctionBrowser/ConvTypes.h +++ b/qt/scientific_interfaces/Indirect/IndirectFunctionBrowser/ConvTypes.h @@ -91,7 +91,7 @@ inline ParamID &operator++(ParamID &id) { } inline void applyToParamIDRange(ParamID from, ParamID to, - std::function<void(ParamID)> fun) { + const std::function<void(ParamID)> &fun) { if (from == ParamID::NONE || to == ParamID::NONE) return; for (auto i = from; i <= to; ++i) diff --git a/qt/scientific_interfaces/Indirect/IndirectFunctionBrowser/FQTemplateBrowser.cpp b/qt/scientific_interfaces/Indirect/IndirectFunctionBrowser/FQTemplateBrowser.cpp index 50ba28e890706ff3db8f2224d7becd244698cf2f..d46c53ec0aaf43003a79e3cd2f6a82865960d0f3 100644 --- a/qt/scientific_interfaces/Indirect/IndirectFunctionBrowser/FQTemplateBrowser.cpp +++ b/qt/scientific_interfaces/Indirect/IndirectFunctionBrowser/FQTemplateBrowser.cpp @@ -56,7 +56,7 @@ void FQTemplateBrowser::createProperties() { m_boolManager->blockSignals(false); } -void FQTemplateBrowser::setDataType(QStringList allowedFunctionsList) { +void FQTemplateBrowser::setDataType(const QStringList &allowedFunctionsList) { ScopedFalse _false(m_emitEnumChange); m_enumManager->setEnumNames(m_fitType, allowedFunctionsList); m_enumManager->setValue(m_fitType, 0); @@ -67,8 +67,8 @@ void FQTemplateBrowser::setEnumValue(int enumIndex) { m_enumManager->setValue(m_fitType, enumIndex); } -void FQTemplateBrowser::addParameter(QString parameterName, - QString parameterDescription) { +void FQTemplateBrowser::addParameter(const QString ¶meterName, + const QString ¶meterDescription) { auto newParameter = m_parameterManager->addProperty(parameterName); m_parameterManager->setDescription(newParameter, parameterDescription.toStdString()); @@ -152,7 +152,7 @@ void FQTemplateBrowser::updateParameters(const IFunction &fun) { m_presenter.updateParameters(fun); } -void FQTemplateBrowser::setParameterValue(QString parameterName, +void FQTemplateBrowser::setParameterValue(const QString ¶meterName, double parameterValue, double parameterError) { m_parameterManager->setValue(m_parameterMap[parameterName], parameterValue); diff --git a/qt/scientific_interfaces/Indirect/IndirectFunctionBrowser/FQTemplateBrowser.h b/qt/scientific_interfaces/Indirect/IndirectFunctionBrowser/FQTemplateBrowser.h index 74b37cecedd4b5f798f236127dbaf03bcc47ec98..72c5221d0a1079a0a6358bff8ce07fc7b0ddf767 100644 --- a/qt/scientific_interfaces/Indirect/IndirectFunctionBrowser/FQTemplateBrowser.h +++ b/qt/scientific_interfaces/Indirect/IndirectFunctionBrowser/FQTemplateBrowser.h @@ -59,10 +59,11 @@ public: int getCurrentDataset() override; void updateDataType(DataType) override; void spectrumChanged(int) override; - void addParameter(QString parameterName, QString parameterDescription); - void setParameterValue(QString parameterName, double parameterValue, + void addParameter(const QString ¶meterName, + const QString ¶meterDescription); + void setParameterValue(const QString ¶meterName, double parameterValue, double parameterError); - void setDataType(QStringList allowedFunctionsList); + void setDataType(const QStringList &allowedFunctionsList); void setEnumValue(int enumIndex); signals: diff --git a/qt/scientific_interfaces/Indirect/IndirectFunctionBrowser/IqtFunctionModel.cpp b/qt/scientific_interfaces/Indirect/IndirectFunctionBrowser/IqtFunctionModel.cpp index 6f52de42fd7779c840451f45312f698e6bef8cc4..d299d35e23b23a007c2cb35c10dc07c2b410232b 100644 --- a/qt/scientific_interfaces/Indirect/IndirectFunctionBrowser/IqtFunctionModel.cpp +++ b/qt/scientific_interfaces/Indirect/IndirectFunctionBrowser/IqtFunctionModel.cpp @@ -565,7 +565,7 @@ void IqtFunctionModel::setCurrentValues(const QMap<ParamID, double> &values) { } void IqtFunctionModel::applyParameterFunction( - std::function<void(ParamID)> paramFun) const { + const std::function<void(ParamID)> ¶mFun) const { if (m_numberOfExponentials > 0) { paramFun(ParamID::EXP1_HEIGHT); paramFun(ParamID::EXP1_LIFETIME); diff --git a/qt/scientific_interfaces/Indirect/IndirectFunctionBrowser/IqtFunctionModel.h b/qt/scientific_interfaces/Indirect/IndirectFunctionBrowser/IqtFunctionModel.h index 7e41e7ed46c202d73589ea29eafbd964fd05988f..3751883378023cfbda4124420f6936ef14e40f1b 100644 --- a/qt/scientific_interfaces/Indirect/IndirectFunctionBrowser/IqtFunctionModel.h +++ b/qt/scientific_interfaces/Indirect/IndirectFunctionBrowser/IqtFunctionModel.h @@ -114,7 +114,8 @@ private: boost::optional<QString> getParameterDescription(ParamID name) const; boost::optional<QString> getPrefix(ParamID name) const; void setCurrentValues(const QMap<ParamID, double> &); - void applyParameterFunction(std::function<void(ParamID)> paramFun) const; + void + applyParameterFunction(const std::function<void(ParamID)> ¶mFun) const; boost::optional<ParamID> getParameterId(const QString &parName); std::string buildExpDecayFunctionString() const; std::string buildStretchExpFunctionString() const; diff --git a/qt/scientific_interfaces/Indirect/IndirectFunctionBrowser/MSDFunctionModel.cpp b/qt/scientific_interfaces/Indirect/IndirectFunctionBrowser/MSDFunctionModel.cpp index 3dbc02bab6192fba34ea2b342539e850e74fe19c..be208b3b0673db08b6b8b675591117954eab4645 100644 --- a/qt/scientific_interfaces/Indirect/IndirectFunctionBrowser/MSDFunctionModel.cpp +++ b/qt/scientific_interfaces/Indirect/IndirectFunctionBrowser/MSDFunctionModel.cpp @@ -457,7 +457,7 @@ void MSDFunctionModel::setCurrentValues(const QMap<ParamID, double> &values) { } void MSDFunctionModel::applyParameterFunction( - std::function<void(ParamID)> paramFun) const { + const std::function<void(ParamID)> ¶mFun) const { if (m_fitType == QString::fromStdString(Gauss)) { paramFun(ParamID::GAUSSIAN_HEIGHT); paramFun(ParamID::GAUSSIAN_MSD); diff --git a/qt/scientific_interfaces/Indirect/IndirectFunctionBrowser/MSDFunctionModel.h b/qt/scientific_interfaces/Indirect/IndirectFunctionBrowser/MSDFunctionModel.h index fef723310a80c523594e30577771d4d567464b0b..19962b630a85e237e4985e0158fe346f1edfc6e9 100644 --- a/qt/scientific_interfaces/Indirect/IndirectFunctionBrowser/MSDFunctionModel.h +++ b/qt/scientific_interfaces/Indirect/IndirectFunctionBrowser/MSDFunctionModel.h @@ -109,7 +109,8 @@ private: boost::optional<QString> getParameterDescription(ParamID name) const; boost::optional<QString> getPrefix(ParamID name) const; void setCurrentValues(const QMap<ParamID, double> &); - void applyParameterFunction(std::function<void(ParamID)> paramFun) const; + void + applyParameterFunction(const std::function<void(ParamID)> ¶mFun) const; boost::optional<ParamID> getParameterId(const QString &parName); std::string buildGaussianFunctionString() const; std::string buildPetersFunctionString() const; diff --git a/qt/scientific_interfaces/Indirect/IndirectInstrumentConfig.cpp b/qt/scientific_interfaces/Indirect/IndirectInstrumentConfig.cpp index 33dccab2d0cf7dbcbdad5c373f8815e8b1c00ee9..a743511ad4c57647bccb370618416c66b18f6602 100644 --- a/qt/scientific_interfaces/Indirect/IndirectInstrumentConfig.cpp +++ b/qt/scientific_interfaces/Indirect/IndirectInstrumentConfig.cpp @@ -300,7 +300,8 @@ void IndirectInstrumentConfig::updateInstrumentConfigurations( * @param ws Instrument workspace * @return If the workspace contained valid analysers */ -bool IndirectInstrumentConfig::updateAnalysersList(MatrixWorkspace_sptr ws) { +bool IndirectInstrumentConfig::updateAnalysersList( + const MatrixWorkspace_sptr &ws) { if (!ws) return false; diff --git a/qt/scientific_interfaces/Indirect/IndirectInstrumentConfig.h b/qt/scientific_interfaces/Indirect/IndirectInstrumentConfig.h index dafeaba3598e88023a35a782a1aaa109f4de2a4c..1419916b327a71b4386a732ddc508ae132ae3e48 100644 --- a/qt/scientific_interfaces/Indirect/IndirectInstrumentConfig.h +++ b/qt/scientific_interfaces/Indirect/IndirectInstrumentConfig.h @@ -96,7 +96,7 @@ signals: private slots: /// Updates the list of analysers when an instrument is selected - bool updateAnalysersList(Mantid::API::MatrixWorkspace_sptr ws); + bool updateAnalysersList(const Mantid::API::MatrixWorkspace_sptr &ws); /// Updates the list of reflections when an analyser is selected void updateReflectionsList(int index); /// Filters out any disabled instruments diff --git a/qt/scientific_interfaces/Indirect/IndirectLoadILL.cpp b/qt/scientific_interfaces/Indirect/IndirectLoadILL.cpp index fa721defb413e7300b9a61943f7cf6324b6fe62e..9b7e11f354ac40d62053ad0bc93ce401c03cfcdc 100644 --- a/qt/scientific_interfaces/Indirect/IndirectLoadILL.cpp +++ b/qt/scientific_interfaces/Indirect/IndirectLoadILL.cpp @@ -47,7 +47,7 @@ std::string constructPrefix(std::string const &runName, return constructPrefix(runName, analyser, reflection); } -std::string getWorkspacePrefix(MatrixWorkspace_const_sptr workspace, +std::string getWorkspacePrefix(const MatrixWorkspace_const_sptr &workspace, std::string const &facility) { auto const instrument = workspace->getInstrument(); auto const runName = diff --git a/qt/scientific_interfaces/Indirect/IndirectMoments.cpp b/qt/scientific_interfaces/Indirect/IndirectMoments.cpp index d95ef29160435e1cf86c3a2b7d296d3d4e0da401..85f54fcd2caa75df4ef5c3cc805aee95b111eecb 100644 --- a/qt/scientific_interfaces/Indirect/IndirectMoments.cpp +++ b/qt/scientific_interfaces/Indirect/IndirectMoments.cpp @@ -267,8 +267,8 @@ void IndirectMoments::setSaveEnabled(bool enabled) { void IndirectMoments::updateRunButton(bool enabled, std::string const &enableOutputButtons, - QString const message, - QString const tooltip) { + QString const &message, + QString const &tooltip) { setRunEnabled(enabled); m_uiForm.pbRun->setText(message); m_uiForm.pbRun->setToolTip(tooltip); diff --git a/qt/scientific_interfaces/Indirect/IndirectMoments.h b/qt/scientific_interfaces/Indirect/IndirectMoments.h index 8ea77bb0812a1a1659a4f92707a7ed1b245838ad..35234afd12b0d51f2f20d05799ceeb4067cb36ab 100644 --- a/qt/scientific_interfaces/Indirect/IndirectMoments.h +++ b/qt/scientific_interfaces/Indirect/IndirectMoments.h @@ -48,8 +48,8 @@ protected slots: void setSaveEnabled(bool enabled); void updateRunButton(bool enabled = true, std::string const &enableOutputButtons = "unchanged", - QString const message = "Run", - QString const tooltip = ""); + QString const &message = "Run", + QString const &tooltip = ""); private slots: void handleDataReady(QString const &dataName) override; diff --git a/qt/scientific_interfaces/Indirect/IndirectPlotOptionsModel.cpp b/qt/scientific_interfaces/Indirect/IndirectPlotOptionsModel.cpp index cddf78e04ff10213c34ba079c4e7a5e68d2933e8..cb11eac1a0821bb5591aa4ff86884a4684182766 100644 --- a/qt/scientific_interfaces/Indirect/IndirectPlotOptionsModel.cpp +++ b/qt/scientific_interfaces/Indirect/IndirectPlotOptionsModel.cpp @@ -86,7 +86,7 @@ void insertWorkspaceNames(std::vector<std::string> &allNames, } boost::optional<std::string> -checkWorkspaceSpectrumSize(MatrixWorkspace_const_sptr workspace) { +checkWorkspaceSpectrumSize(const MatrixWorkspace_const_sptr &workspace) { if (workspace->y(0).size() < 2) return "Plot Spectra failed: There is only one data point to plot in " + workspace->getName() + "."; @@ -94,7 +94,7 @@ checkWorkspaceSpectrumSize(MatrixWorkspace_const_sptr workspace) { } boost::optional<std::string> -checkWorkspaceBinSize(MatrixWorkspace_const_sptr workspace) { +checkWorkspaceBinSize(const MatrixWorkspace_const_sptr &workspace) { if (workspace->getNumberHistograms() < 2) return "Plot Bins failed: There is only one data point to plot in " + workspace->getName() + "."; @@ -208,14 +208,14 @@ bool IndirectPlotOptionsModel::validateIndices( } bool IndirectPlotOptionsModel::validateSpectra( - MatrixWorkspace_sptr workspace, std::string const &spectra) const { + const MatrixWorkspace_sptr &workspace, std::string const &spectra) const { auto const numberOfHistograms = workspace->getNumberHistograms(); auto const lastIndex = std::stoul(splitStringBy(spectra, ",-").back()); return lastIndex < numberOfHistograms; } -bool IndirectPlotOptionsModel::validateBins(MatrixWorkspace_sptr workspace, - std::string const &bins) const { +bool IndirectPlotOptionsModel::validateBins( + const MatrixWorkspace_sptr &workspace, std::string const &bins) const { auto const numberOfBins = workspace->y(0).size(); auto const lastIndex = std::stoul(splitStringBy(bins, ",-").back()); return lastIndex < numberOfBins; diff --git a/qt/scientific_interfaces/Indirect/IndirectPlotOptionsModel.h b/qt/scientific_interfaces/Indirect/IndirectPlotOptionsModel.h index 6092f5f3330bfe9f2ec61b83c587008e398cb157..eebcf27dbddd4899f2920c2b88194140383c350b 100644 --- a/qt/scientific_interfaces/Indirect/IndirectPlotOptionsModel.h +++ b/qt/scientific_interfaces/Indirect/IndirectPlotOptionsModel.h @@ -61,9 +61,9 @@ public: std::map<std::string, std::string> availableActions() const; private: - bool validateSpectra(Mantid::API::MatrixWorkspace_sptr workspace, + bool validateSpectra(const Mantid::API::MatrixWorkspace_sptr &workspace, std::string const &spectra) const; - bool validateBins(Mantid::API::MatrixWorkspace_sptr workspace, + bool validateBins(const Mantid::API::MatrixWorkspace_sptr &workspace, std::string const &bins) const; boost::optional<std::string> diff --git a/qt/scientific_interfaces/Indirect/IndirectPlotter.cpp b/qt/scientific_interfaces/Indirect/IndirectPlotter.cpp index aa18b4cd7c47307fd51ba232fd18360b70b37cd0..56711979d16521a4924a6483d515050ed7a4702d 100644 --- a/qt/scientific_interfaces/Indirect/IndirectPlotter.cpp +++ b/qt/scientific_interfaces/Indirect/IndirectPlotter.cpp @@ -18,6 +18,7 @@ #include <QString> #include <QStringList> #include <QVariant> +#include <utility> using namespace MantidQt::Widgets::MplCpp; #endif @@ -178,8 +179,8 @@ workbenchPlot(QStringList const &workspaceNames, plotKwargs["capsize"] = ERROR_CAPSIZE; using MantidQt::Widgets::MplCpp::plot; - return plot(workspaceNames, boost::none, indices, figure, plotKwargs, - boost::none, boost::none, errorBars); + return plot(workspaceNames, boost::none, indices, std::move(figure), + plotKwargs, boost::none, boost::none, errorBars); } #endif @@ -360,7 +361,7 @@ bool IndirectPlotter::validate( * @return True if the data is valid */ bool IndirectPlotter::validate( - MatrixWorkspace_const_sptr workspace, + const MatrixWorkspace_const_sptr &workspace, boost::optional<std::string> const &workspaceIndices, boost::optional<MantidAxis> const &axisType) const { if (workspaceIndices && axisType && axisType.get() == MantidAxis::Spectrum) @@ -379,7 +380,7 @@ bool IndirectPlotter::validate( * @return True if the indices exist */ bool IndirectPlotter::validateSpectra( - MatrixWorkspace_const_sptr workspace, + const MatrixWorkspace_const_sptr &workspace, std::string const &workspaceIndices) const { auto const numberOfHistograms = workspace->getNumberHistograms(); auto const lastIndex = @@ -395,7 +396,7 @@ bool IndirectPlotter::validateSpectra( * '0-2,5,7-10') * @return True if the bin indices exist */ -bool IndirectPlotter::validateBins(MatrixWorkspace_const_sptr workspace, +bool IndirectPlotter::validateBins(const MatrixWorkspace_const_sptr &workspace, std::string const &binIndices) const { auto const numberOfBins = workspace->y(0).size(); auto const lastIndex = std::stoul(splitStringBy(binIndices, ",-").back()); diff --git a/qt/scientific_interfaces/Indirect/IndirectPlotter.h b/qt/scientific_interfaces/Indirect/IndirectPlotter.h index 4e3560d3d5750f98d73e98bbcdf6fd1a6ad7eb8f..db9a1a2e01a9b644daeb4f11303726bff52a1051 100644 --- a/qt/scientific_interfaces/Indirect/IndirectPlotter.h +++ b/qt/scientific_interfaces/Indirect/IndirectPlotter.h @@ -54,12 +54,12 @@ public: private: bool - validate(Mantid::API::MatrixWorkspace_const_sptr workspace, + validate(const Mantid::API::MatrixWorkspace_const_sptr &workspace, boost::optional<std::string> const &workspaceIndices = boost::none, boost::optional<MantidAxis> const &axisType = boost::none) const; - bool validateSpectra(Mantid::API::MatrixWorkspace_const_sptr workspace, + bool validateSpectra(const Mantid::API::MatrixWorkspace_const_sptr &workspace, std::string const &workspaceIndices) const; - bool validateBins(Mantid::API::MatrixWorkspace_const_sptr workspace, + bool validateBins(const Mantid::API::MatrixWorkspace_const_sptr &workspace, std::string const &binIndices) const; #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) diff --git a/qt/scientific_interfaces/Indirect/IndirectSettings.cpp b/qt/scientific_interfaces/Indirect/IndirectSettings.cpp index 983666592b06966cd6c424ede601aa1895cd861c..cc3e604f7f91d3b1d9cab56c96908cb6809f5a09 100644 --- a/qt/scientific_interfaces/Indirect/IndirectSettings.cpp +++ b/qt/scientific_interfaces/Indirect/IndirectSettings.cpp @@ -54,7 +54,7 @@ void IndirectSettings::otherUserSubWindowCreated( } void IndirectSettings::connectIndirectInterface( - QPointer<UserSubWindow> window) { + const QPointer<UserSubWindow> &window) { if (auto indirectInterface = dynamic_cast<IndirectInterface *>(window.data())) connect(m_presenter.get(), SIGNAL(applySettings()), indirectInterface, SLOT(applySettings())); diff --git a/qt/scientific_interfaces/Indirect/IndirectSettings.h b/qt/scientific_interfaces/Indirect/IndirectSettings.h index 02e3fb43722827481433def648c2cc29a2291757..581da825cd230e99f00dee20b97223b72ea94536 100644 --- a/qt/scientific_interfaces/Indirect/IndirectSettings.h +++ b/qt/scientific_interfaces/Indirect/IndirectSettings.h @@ -51,7 +51,7 @@ private: void otherUserSubWindowCreated(QList<QPointer<UserSubWindow>> &windows) override; - void connectIndirectInterface(QPointer<UserSubWindow> window); + void connectIndirectInterface(const QPointer<UserSubWindow> &window); QWidget *getDockedOrFloatingWindow(); diff --git a/qt/scientific_interfaces/Indirect/IndirectSqw.cpp b/qt/scientific_interfaces/Indirect/IndirectSqw.cpp index 0b7a4ac2568b5e1a789b198c9fc8304500e55468..61368c34ca774285237ae8c6686e9c67dcdeb17e 100644 --- a/qt/scientific_interfaces/Indirect/IndirectSqw.cpp +++ b/qt/scientific_interfaces/Indirect/IndirectSqw.cpp @@ -300,8 +300,8 @@ void IndirectSqw::setSaveEnabled(bool enabled) { void IndirectSqw::updateRunButton(bool enabled, std::string const &enableOutputButtons, - QString const message, - QString const tooltip) { + QString const &message, + QString const &tooltip) { setRunEnabled(enabled); m_uiForm.pbRun->setText(message); m_uiForm.pbRun->setToolTip(tooltip); diff --git a/qt/scientific_interfaces/Indirect/IndirectSqw.h b/qt/scientific_interfaces/Indirect/IndirectSqw.h index ea018c966ed71fe24f76511e86fbb3dc6ce0bc40..68299a9e82bae2194f207b995421f25fb7e9f2db 100644 --- a/qt/scientific_interfaces/Indirect/IndirectSqw.h +++ b/qt/scientific_interfaces/Indirect/IndirectSqw.h @@ -38,8 +38,8 @@ private slots: void updateRunButton(bool enabled = true, std::string const &enableOutputButtons = "unchanged", - QString const message = "Run", - QString const tooltip = ""); + QString const &message = "Run", + QString const &tooltip = ""); private: void plotRqwContour(std::string const &sampleName); diff --git a/qt/scientific_interfaces/Indirect/IndirectSymmetrise.cpp b/qt/scientific_interfaces/Indirect/IndirectSymmetrise.cpp index 33e78fe617ec1505f994da3539a5292d01304504..955c6774538cfaf3ea2a81305fd543c6870f799e 100644 --- a/qt/scientific_interfaces/Indirect/IndirectSymmetrise.cpp +++ b/qt/scientific_interfaces/Indirect/IndirectSymmetrise.cpp @@ -620,8 +620,8 @@ void IndirectSymmetrise::setSaveEnabled(bool enabled) { void IndirectSymmetrise::updateRunButton(bool enabled, std::string const &enableOutputButtons, - QString const message, - QString const tooltip) { + QString const &message, + QString const &tooltip) { setRunEnabled(enabled); m_uiForm.pbRun->setText(message); m_uiForm.pbRun->setToolTip(tooltip); diff --git a/qt/scientific_interfaces/Indirect/IndirectSymmetrise.h b/qt/scientific_interfaces/Indirect/IndirectSymmetrise.h index 49dc8ab1b27ab4be13a0e6c288d93f0c0688dd97..c1d739beed57eab2ae3236db306ec5b8dafb1c4a 100644 --- a/qt/scientific_interfaces/Indirect/IndirectSymmetrise.h +++ b/qt/scientific_interfaces/Indirect/IndirectSymmetrise.h @@ -68,8 +68,8 @@ private slots: void setSaveEnabled(bool enabled); void updateRunButton(bool enabled = true, std::string const &enableOutputButtons = "unchanged", - QString const message = "Run", - QString const tooltip = ""); + QString const &message = "Run", + QString const &tooltip = ""); private: void setFileExtensionsByName(bool filter) override; diff --git a/qt/scientific_interfaces/Indirect/IndirectTab.cpp b/qt/scientific_interfaces/Indirect/IndirectTab.cpp index 5e0ae57d68c53bc0b1313ab7422b297f72b28060..efc40de6b1862c8e77ce45a357af320cb34be4f5 100644 --- a/qt/scientific_interfaces/Indirect/IndirectTab.cpp +++ b/qt/scientific_interfaces/Indirect/IndirectTab.cpp @@ -51,7 +51,7 @@ std::string castToString(int value) { } template <typename Predicate> -void setPropertyIf(Algorithm_sptr algorithm, std::string const &propName, +void setPropertyIf(const Algorithm_sptr &algorithm, std::string const &propName, std::string const &value, Predicate const &condition) { if (condition) algorithm->setPropertyValue(propName, value); @@ -503,7 +503,7 @@ void IndirectTab::setRangeSelectorMax(QtProperty *minProperty, * @param ws Pointer to the workspace * @return Energy mode */ -std::string IndirectTab::getEMode(Mantid::API::MatrixWorkspace_sptr ws) { +std::string IndirectTab::getEMode(const Mantid::API::MatrixWorkspace_sptr &ws) { Mantid::Kernel::Unit_sptr xUnit = ws->getAxis(0)->unit(); std::string xUnitName = xUnit->caption(); @@ -521,7 +521,7 @@ std::string IndirectTab::getEMode(Mantid::API::MatrixWorkspace_sptr ws) { * @param ws Pointer to the workspace * @return eFixed value */ -double IndirectTab::getEFixed(Mantid::API::MatrixWorkspace_sptr ws) { +double IndirectTab::getEFixed(const Mantid::API::MatrixWorkspace_sptr &ws) { Mantid::Geometry::Instrument_const_sptr inst = ws->getInstrument(); if (!inst) throw std::runtime_error("No instrument on workspace"); @@ -567,7 +567,7 @@ bool IndirectTab::getResolutionRangeFromWs(const QString &workspace, *found) */ bool IndirectTab::getResolutionRangeFromWs( - Mantid::API::MatrixWorkspace_const_sptr workspace, + const Mantid::API::MatrixWorkspace_const_sptr &workspace, QPair<double, double> &res) { if (workspace) { auto const instrument = workspace->getInstrument(); @@ -601,7 +601,8 @@ IndirectTab::getXRangeFromWorkspace(std::string const &workspaceName, } QPair<double, double> IndirectTab::getXRangeFromWorkspace( - Mantid::API::MatrixWorkspace_const_sptr workspace, double precision) const { + const Mantid::API::MatrixWorkspace_const_sptr &workspace, + double precision) const { auto const xValues = workspace->x(0); return roundRangeToPrecision(xValues.front(), xValues.back(), precision); } @@ -611,7 +612,7 @@ QPair<double, double> IndirectTab::getXRangeFromWorkspace( * * @param algorithm :: The algorithm to be run */ -void IndirectTab::runAlgorithm(const Mantid::API::IAlgorithm_sptr algorithm) { +void IndirectTab::runAlgorithm(const Mantid::API::IAlgorithm_sptr &algorithm) { algorithm->setRethrows(true); // There should never really be unexecuted algorithms in the queue, but it is @@ -646,7 +647,7 @@ void IndirectTab::algorithmFinished(bool error) { * @param no_output Enable to ignore any output * @returns What was printed to stdout */ -QString IndirectTab::runPythonCode(QString code, bool no_output) { +QString IndirectTab::runPythonCode(const QString &code, bool no_output) { return m_pythonRunner.runPythonCode(code, no_output); } @@ -675,7 +676,7 @@ bool IndirectTab::checkADSForPlotSaveWorkspace(const std::string &workspaceName, } std::unordered_map<std::string, size_t> IndirectTab::extractAxisLabels( - Mantid::API::MatrixWorkspace_const_sptr workspace, + const Mantid::API::MatrixWorkspace_const_sptr &workspace, const size_t &axisIndex) const { Axis *axis = workspace->getAxis(axisIndex); if (!axis->isText()) diff --git a/qt/scientific_interfaces/Indirect/IndirectTab.h b/qt/scientific_interfaces/Indirect/IndirectTab.h index a327c5d9eaa39556918cb976dd690e0486ce8ff3..199dfe650e27af120a503eaf5e5ca305d155060e 100644 --- a/qt/scientific_interfaces/Indirect/IndirectTab.h +++ b/qt/scientific_interfaces/Indirect/IndirectTab.h @@ -116,7 +116,7 @@ protected: /// Extracts the labels from the axis at the specified index in the /// specified workspace. std::unordered_map<std::string, size_t> - extractAxisLabels(Mantid::API::MatrixWorkspace_const_sptr workspace, + extractAxisLabels(const Mantid::API::MatrixWorkspace_const_sptr &workspace, const size_t &axisIndex) const; /// Function to set the range limits of the plot @@ -138,10 +138,10 @@ protected: double newValue); /// Function to get energy mode from a workspace - std::string getEMode(Mantid::API::MatrixWorkspace_sptr ws); + std::string getEMode(const Mantid::API::MatrixWorkspace_sptr &ws); /// Function to get eFixed from a workspace - double getEFixed(Mantid::API::MatrixWorkspace_sptr ws); + double getEFixed(const Mantid::API::MatrixWorkspace_sptr &ws); /// Function to read an instrument's resolution from the IPF using a string bool getResolutionRangeFromWs(const QString &filename, @@ -149,25 +149,26 @@ protected: /// Function to read an instrument's resolution from the IPF using a workspace /// pointer - bool getResolutionRangeFromWs(Mantid::API::MatrixWorkspace_const_sptr ws, - QPair<double, double> &res); + bool + getResolutionRangeFromWs(const Mantid::API::MatrixWorkspace_const_sptr &ws, + QPair<double, double> &res); /// Gets the x range from a workspace QPair<double, double> getXRangeFromWorkspace(std::string const &workspaceName, double precision = 0.000001) const; - QPair<double, double> - getXRangeFromWorkspace(Mantid::API::MatrixWorkspace_const_sptr workspace, - double precision = 0.000001) const; + QPair<double, double> getXRangeFromWorkspace( + const Mantid::API::MatrixWorkspace_const_sptr &workspace, + double precision = 0.000001) const; /// Converts a standard vector of standard strings to a QVector of QStrings. QVector<QString> convertStdStringVector(const std::vector<std::string> &stringVec) const; /// Function to run an algorithm on a seperate thread - void runAlgorithm(const Mantid::API::IAlgorithm_sptr algorithm); + void runAlgorithm(const Mantid::API::IAlgorithm_sptr &algorithm); - QString runPythonCode(QString vode, bool no_output = false); + QString runPythonCode(const QString &vode, bool no_output = false); /// Checks the ADS for a workspace named `workspaceName`, /// opens a warning box for plotting/saving if none found diff --git a/qt/scientific_interfaces/Indirect/IndirectTransmission.cpp b/qt/scientific_interfaces/Indirect/IndirectTransmission.cpp index 71f8def07411774905f37688f9426ff0e2f734d0..db76d8e2632486d38a72b7a024b03961a0e517b5 100644 --- a/qt/scientific_interfaces/Indirect/IndirectTransmission.cpp +++ b/qt/scientific_interfaces/Indirect/IndirectTransmission.cpp @@ -165,8 +165,8 @@ void IndirectTransmission::setSaveEnabled(bool enabled) { } void IndirectTransmission::updateRunButton( - bool enabled, std::string const &enableOutputButtons, QString const message, - QString const tooltip) { + bool enabled, std::string const &enableOutputButtons, + QString const &message, QString const &tooltip) { setRunEnabled(enabled); m_uiForm.pbRun->setText(message); m_uiForm.pbRun->setToolTip(tooltip); diff --git a/qt/scientific_interfaces/Indirect/IndirectTransmission.h b/qt/scientific_interfaces/Indirect/IndirectTransmission.h index 2531a66baabb46ec5df507552f492c948860b54e..310e712854766699f9b3d5686d186b7e8792b970 100644 --- a/qt/scientific_interfaces/Indirect/IndirectTransmission.h +++ b/qt/scientific_interfaces/Indirect/IndirectTransmission.h @@ -44,8 +44,8 @@ private slots: void setSaveEnabled(bool enabled); void updateRunButton(bool enabled = true, std::string const &enableOutputButtons = "unchanged", - QString const message = "Run", - QString const tooltip = ""); + QString const &message = "Run", + QString const &tooltip = ""); private: void setInstrument(QString const &instrumentName); diff --git a/qt/scientific_interfaces/Indirect/Iqt.cpp b/qt/scientific_interfaces/Indirect/Iqt.cpp index 17c7e47c09f58b9e1a6fdd16b22928f4d1fadb19..058e944fc594b59a20626464628533feecf7940e 100644 --- a/qt/scientific_interfaces/Indirect/Iqt.cpp +++ b/qt/scientific_interfaces/Indirect/Iqt.cpp @@ -28,10 +28,10 @@ MatrixWorkspace_sptr getADSMatrixWorkspace(std::string const &workspaceName) { workspaceName); } -std::string -checkInstrumentParametersMatch(Instrument_const_sptr sampleInstrument, - Instrument_const_sptr resolutionInstrument, - std::string const ¶meter) { +std::string checkInstrumentParametersMatch( + const Instrument_const_sptr &sampleInstrument, + const Instrument_const_sptr &resolutionInstrument, + std::string const ¶meter) { if (!sampleInstrument->hasParameter(parameter)) return "Could not find the " + parameter + " for the sample workspace."; if (!resolutionInstrument->hasParameter(parameter)) @@ -43,9 +43,10 @@ checkInstrumentParametersMatch(Instrument_const_sptr sampleInstrument, return ""; } -std::string checkParametersMatch(MatrixWorkspace_const_sptr sampleWorkspace, - MatrixWorkspace_const_sptr resolutionWorkspace, - std::string const ¶meter) { +std::string +checkParametersMatch(const MatrixWorkspace_const_sptr &sampleWorkspace, + const MatrixWorkspace_const_sptr &resolutionWorkspace, + std::string const ¶meter) { auto const sampleInstrument = sampleWorkspace->getInstrument(); auto const resolutionInstrument = resolutionWorkspace->getInstrument(); return checkInstrumentParametersMatch(sampleInstrument, resolutionInstrument, @@ -61,8 +62,8 @@ std::string checkParametersMatch(std::string const &sampleName, } std::string -checkInstrumentsMatch(MatrixWorkspace_const_sptr sampleWorkspace, - MatrixWorkspace_const_sptr resolutionWorkspace) { +checkInstrumentsMatch(const MatrixWorkspace_const_sptr &sampleWorkspace, + const MatrixWorkspace_const_sptr &resolutionWorkspace) { auto const sampleInstrument = sampleWorkspace->getInstrument(); auto const resolutionInstrument = resolutionWorkspace->getInstrument(); if (sampleInstrument->getName() != resolutionInstrument->getName()) @@ -70,9 +71,9 @@ checkInstrumentsMatch(MatrixWorkspace_const_sptr sampleWorkspace, return ""; } -std::string -validateNumberOfHistograms(MatrixWorkspace_const_sptr sampleWorkspace, - MatrixWorkspace_const_sptr resolutionWorkspace) { +std::string validateNumberOfHistograms( + const MatrixWorkspace_const_sptr &sampleWorkspace, + const MatrixWorkspace_const_sptr &resolutionWorkspace) { auto const sampleSize = sampleWorkspace->getNumberHistograms(); auto const resolutionSize = resolutionWorkspace->getNumberHistograms(); if (resolutionSize > 1 && sampleSize != resolutionSize) @@ -85,8 +86,8 @@ void addErrorMessage(UserInputValidator &uiv, std::string const &message) { uiv.addErrorMessage(QString::fromStdString(message) + "\n"); } -bool isTechniqueDirect(MatrixWorkspace_const_sptr sampleWorkspace, - MatrixWorkspace_const_sptr resWorkspace) { +bool isTechniqueDirect(const MatrixWorkspace_const_sptr &sampleWorkspace, + const MatrixWorkspace_const_sptr &resWorkspace) { try { auto const logValue1 = sampleWorkspace->getLog("deltaE-mode")->value(); auto const logValue2 = resWorkspace->getLog("deltaE-mode")->value(); diff --git a/qt/scientific_interfaces/Indirect/IqtFitModel.cpp b/qt/scientific_interfaces/Indirect/IqtFitModel.cpp index ef402af173b4cf6e1b9925c555bf0360b798a555..2750e94081f60c70d4982362d9829e33339eb480 100644 --- a/qt/scientific_interfaces/Indirect/IqtFitModel.cpp +++ b/qt/scientific_interfaces/Indirect/IqtFitModel.cpp @@ -12,6 +12,7 @@ #include "MantidAPI/MultiDomainFunction.h" #include <boost/algorithm/string/predicate.hpp> +#include <utility> using namespace Mantid::API; @@ -19,7 +20,7 @@ namespace { IFunction_sptr getFirstInCategory(IFunction_sptr function, const std::string &category); -IFunction_sptr getFirstInCategory(CompositeFunction_sptr composite, +IFunction_sptr getFirstInCategory(const CompositeFunction_sptr &composite, const std::string &category) { for (auto i = 0u; i < composite->nFunctions(); ++i) { auto function = getFirstInCategory(composite->getFunction(i), category); @@ -41,7 +42,7 @@ IFunction_sptr getFirstInCategory(IFunction_sptr function, return nullptr; } -std::vector<std::string> getParameters(IFunction_sptr function, +std::vector<std::string> getParameters(const IFunction_sptr &function, const std::string &shortParameterName) { std::vector<std::string> parameters; @@ -52,7 +53,7 @@ std::vector<std::string> getParameters(IFunction_sptr function, return parameters; } -bool constrainIntensities(IFunction_sptr function) { +bool constrainIntensities(const IFunction_sptr &function) { const auto intensityParameters = getParameters(function, "Height"); const auto backgroundParameters = getParameters(function, "A0"); @@ -73,7 +74,7 @@ bool constrainIntensities(IFunction_sptr function) { return true; } -double computeTauApproximation(MatrixWorkspace_sptr workspace) { +double computeTauApproximation(const MatrixWorkspace_sptr &workspace) { const auto &x = workspace->x(0); const auto &y = workspace->y(0); @@ -83,28 +84,28 @@ double computeTauApproximation(MatrixWorkspace_sptr workspace) { } double computeHeightApproximation(IFunction_sptr function) { - const auto background = getFirstInCategory(function, "Background"); + const auto background = getFirstInCategory(std::move(function), "Background"); const double height = 1.0; if (background && background->hasParameter("A0")) return height - background->getParameter("A0"); return height; } -std::string getSuffix(MatrixWorkspace_sptr workspace) { +std::string getSuffix(const MatrixWorkspace_sptr &workspace) { const auto position = workspace->getName().rfind("_"); return workspace->getName().substr(position + 1); } -std::string getFitString(MatrixWorkspace_sptr workspace) { - auto suffix = getSuffix(workspace); +std::string getFitString(const MatrixWorkspace_sptr &workspace) { + auto suffix = getSuffix(std::move(workspace)); boost::algorithm::to_lower(suffix); if (suffix == "iqt") return "Fit"; return "_IqtFit"; } -boost::optional<std::string> findFullParameterName(IFunction_sptr function, - const std::string &name) { +boost::optional<std::string> +findFullParameterName(const IFunction_sptr &function, const std::string &name) { for (auto i = 0u; i < function->nParams(); ++i) { const auto fullName = function->parameterName(i); if (boost::algorithm::ends_with(fullName, name)) @@ -230,8 +231,8 @@ IqtFitModel::createDefaultParameters(TableDatasetIndex index) const { return parameters; } -MultiDomainFunction_sptr -IqtFitModel::createFunctionWithGlobalBeta(IFunction_sptr function) const { +MultiDomainFunction_sptr IqtFitModel::createFunctionWithGlobalBeta( + const IFunction_sptr &function) const { boost::shared_ptr<MultiDomainFunction> multiDomainFunction( new MultiDomainFunction); const auto functionString = function->asString(); diff --git a/qt/scientific_interfaces/Indirect/IqtFitModel.h b/qt/scientific_interfaces/Indirect/IqtFitModel.h index 962064594cedc70729452c8a3a1487845bc60892..3c083447af3c56f1f7e6ad78206ec7923ff191d5 100644 --- a/qt/scientific_interfaces/Indirect/IqtFitModel.h +++ b/qt/scientific_interfaces/Indirect/IqtFitModel.h @@ -31,8 +31,8 @@ private: WorkspaceIndex spectrum) const override; std::unordered_map<std::string, ParameterValue> createDefaultParameters(TableDatasetIndex index) const override; - Mantid::API::MultiDomainFunction_sptr - createFunctionWithGlobalBeta(Mantid::API::IFunction_sptr function) const; + Mantid::API::MultiDomainFunction_sptr createFunctionWithGlobalBeta( + const Mantid::API::IFunction_sptr &function) const; bool m_makeBetaGlobal; bool m_constrainIntensities; diff --git a/qt/scientific_interfaces/Indirect/JumpFitModel.cpp b/qt/scientific_interfaces/Indirect/JumpFitModel.cpp index fbb7043541c17a01d0fbd77613d8fdb3c57c11a1..a1050b133a3ad8d81958dd6055939320db65b1f7 100644 --- a/qt/scientific_interfaces/Indirect/JumpFitModel.cpp +++ b/qt/scientific_interfaces/Indirect/JumpFitModel.cpp @@ -6,6 +6,8 @@ // SPDX - License - Identifier: GPL - 3.0 + #include "JumpFitModel.h" +#include <utility> + #include "MantidAPI/AlgorithmManager.h" #include "MantidAPI/TextAxis.h" #include "MantidKernel/Logger.h" @@ -60,7 +62,7 @@ findAxisLabels(MatrixWorkspace const *workspace, Predicate const &predicate) { return std::make_pair(std::vector<std::string>(), std::vector<std::size_t>()); } -std::string createSpectra(std::vector<std::size_t> spectrum) { +std::string createSpectra(const std::vector<std::size_t> &spectrum) { std::string spectra = ""; for (auto spec : spectrum) { spectra.append(std::to_string(spec) + ","); @@ -123,16 +125,18 @@ std::string extractSpectra(std::string const &inputName, int startIndex, return outputName; } -std::string extractSpectrum(MatrixWorkspace_sptr workspace, int index, +std::string extractSpectrum(const MatrixWorkspace_sptr &workspace, int index, std::string const &outputName) { return extractSpectra(workspace->getName(), index, index, outputName); } -std::string extractHWHMSpectrum(MatrixWorkspace_sptr workspace, int index) { +std::string extractHWHMSpectrum(const MatrixWorkspace_sptr &workspace, + int index) { auto const scaledName = "__scaled_" + std::to_string(index); auto const extractedName = "__extracted_" + std::to_string(index); auto const outputName = scaleWorkspace( - extractSpectrum(workspace, index, extractedName), scaledName, 0.5); + extractSpectrum(std::move(workspace), index, extractedName), scaledName, + 0.5); deleteTemporaryWorkspaces({extractedName}); return outputName; } @@ -159,7 +163,7 @@ MatrixWorkspace_sptr appendAll(std::vector<std::string> const &workspaces, } std::vector<std::string> -subdivideWidthWorkspace(MatrixWorkspace_sptr workspace, +subdivideWidthWorkspace(const MatrixWorkspace_sptr &workspace, const std::vector<std::size_t> &widthSpectra) { std::vector<std::string> subworkspaces; subworkspaces.reserve(1 + 2 * widthSpectra.size()); @@ -393,7 +397,7 @@ std::string JumpFitModel::constructOutputName() const { } bool JumpFitModel::allWorkspacesEqual( - Mantid::API::MatrixWorkspace_sptr workspace) const { + const Mantid::API::MatrixWorkspace_sptr &workspace) const { for (auto i = TableDatasetIndex{1}; i < numberOfWorkspaces(); ++i) { if (getWorkspace(i) != workspace) return false; diff --git a/qt/scientific_interfaces/Indirect/JumpFitModel.h b/qt/scientific_interfaces/Indirect/JumpFitModel.h index ac9881c537b5cf79ba0f83a833214f0c362cc1fc..12125b237bf996b536471bf0055c4f6ccace6f9b 100644 --- a/qt/scientific_interfaces/Indirect/JumpFitModel.h +++ b/qt/scientific_interfaces/Indirect/JumpFitModel.h @@ -53,7 +53,8 @@ public: private: std::string constructOutputName() const; - bool allWorkspacesEqual(Mantid::API::MatrixWorkspace_sptr workspace) const; + bool + allWorkspacesEqual(const Mantid::API::MatrixWorkspace_sptr &workspace) const; JumpFitParameters & addJumpFitParameters(Mantid::API::MatrixWorkspace *workspace, const std::string &hwhmName); diff --git a/qt/scientific_interfaces/Indirect/ResNorm.cpp b/qt/scientific_interfaces/Indirect/ResNorm.cpp index 35ef872c1284fb0b5cbbd3531d8a13eed7561910..21b982a8ac9b7f652704030fb274b566328a293c 100644 --- a/qt/scientific_interfaces/Indirect/ResNorm.cpp +++ b/qt/scientific_interfaces/Indirect/ResNorm.cpp @@ -215,12 +215,12 @@ void ResNorm::processLogs() { addAdditionalLogs(resultWorkspace); } -void ResNorm::addAdditionalLogs(WorkspaceGroup_sptr resultGroup) const { +void ResNorm::addAdditionalLogs(const WorkspaceGroup_sptr &resultGroup) const { for (auto const &workspace : *resultGroup) addAdditionalLogs(workspace); } -void ResNorm::addAdditionalLogs(Workspace_sptr resultWorkspace) const { +void ResNorm::addAdditionalLogs(const Workspace_sptr &resultWorkspace) const { auto logAdder = AlgorithmManager::Instance().create("AddSampleLog"); auto const name = resultWorkspace->getName(); @@ -265,14 +265,14 @@ double ResNorm::getDoubleManagerProperty(QString const &propName) const { return m_dblManager->value(m_properties[propName]); } -void ResNorm::copyLogs(MatrixWorkspace_sptr resultWorkspace, - WorkspaceGroup_sptr resultGroup) const { +void ResNorm::copyLogs(const MatrixWorkspace_sptr &resultWorkspace, + const WorkspaceGroup_sptr &resultGroup) const { for (auto const &workspace : *resultGroup) copyLogs(resultWorkspace, workspace); } -void ResNorm::copyLogs(MatrixWorkspace_sptr resultWorkspace, - Workspace_sptr workspace) const { +void ResNorm::copyLogs(const MatrixWorkspace_sptr &resultWorkspace, + const Workspace_sptr &workspace) const { auto logCopier = AlgorithmManager::Instance().create("CopyLogs"); logCopier->setProperty("InputWorkspace", resultWorkspace->getName()); logCopier->setProperty("OutputWorkspace", workspace->getName()); diff --git a/qt/scientific_interfaces/Indirect/ResNorm.h b/qt/scientific_interfaces/Indirect/ResNorm.h index 77319d6be74f8204447715c537d524ca70bb527e..c793c9c751e8737ddb8300484f491b687af604a2 100644 --- a/qt/scientific_interfaces/Indirect/ResNorm.h +++ b/qt/scientific_interfaces/Indirect/ResNorm.h @@ -51,15 +51,17 @@ private: void setFileExtensionsByName(bool filter) override; void processLogs(); - void addAdditionalLogs(Mantid::API::WorkspaceGroup_sptr resultGroup) const; - void addAdditionalLogs(Mantid::API::Workspace_sptr resultWorkspace) const; + void + addAdditionalLogs(const Mantid::API::WorkspaceGroup_sptr &resultGroup) const; + void + addAdditionalLogs(const Mantid::API::Workspace_sptr &resultWorkspace) const; std::map<std::string, std::string> getAdditionalLogStrings() const; std::map<std::string, std::string> getAdditionalLogNumbers() const; double getDoubleManagerProperty(QString const &propName) const; - void copyLogs(Mantid::API::MatrixWorkspace_sptr resultWorkspace, - Mantid::API::WorkspaceGroup_sptr resultGroup) const; - void copyLogs(Mantid::API::MatrixWorkspace_sptr resultWorkspace, - Mantid::API::Workspace_sptr workspace) const; + void copyLogs(const Mantid::API::MatrixWorkspace_sptr &resultWorkspace, + const Mantid::API::WorkspaceGroup_sptr &resultGroup) const; + void copyLogs(const Mantid::API::MatrixWorkspace_sptr &resultWorkspace, + const Mantid::API::Workspace_sptr &workspace) const; void setRunEnabled(bool enabled); void setPlotResultEnabled(bool enabled); diff --git a/qt/scientific_interfaces/Indirect/test/IndirectDataValidationHelperTest.h b/qt/scientific_interfaces/Indirect/test/IndirectDataValidationHelperTest.h index 8538eddeb39080863adf72bd9e4f1994a0af4b6f..f8f511c6691e88c609f2bf44c67c594d0a81c3f0 100644 --- a/qt/scientific_interfaces/Indirect/test/IndirectDataValidationHelperTest.h +++ b/qt/scientific_interfaces/Indirect/test/IndirectDataValidationHelperTest.h @@ -45,7 +45,8 @@ std::string emptyWorkspaceGroupError() { " is empty."; } -MatrixWorkspace_sptr convertWorkspace2DToMatrix(Workspace2D_sptr workspace) { +MatrixWorkspace_sptr +convertWorkspace2DToMatrix(const Workspace2D_sptr &workspace) { return boost::dynamic_pointer_cast<MatrixWorkspace>(workspace); } diff --git a/qt/scientific_interfaces/Indirect/test/IndirectFitOutputTest.h b/qt/scientific_interfaces/Indirect/test/IndirectFitOutputTest.h index a7917e4d55cd6eb9593b5f160298706d99f38d13..4ec0658d631896a8645e6d2def18d33eb026d84e 100644 --- a/qt/scientific_interfaces/Indirect/test/IndirectFitOutputTest.h +++ b/qt/scientific_interfaces/Indirect/test/IndirectFitOutputTest.h @@ -88,9 +88,9 @@ WorkspaceGroup_sptr getPopulatedGroup(std::size_t const &size) { } std::unique_ptr<IndirectFitOutputLegacy> -createFitOutput(WorkspaceGroup_sptr resultGroup, - ITableWorkspace_sptr parameterTable, - WorkspaceGroup_sptr resultWorkspace, +createFitOutput(const WorkspaceGroup_sptr &resultGroup, + const ITableWorkspace_sptr ¶meterTable, + const WorkspaceGroup_sptr &resultWorkspace, IndirectFitDataLegacy *fitData, std::size_t spectrum) { return std::make_unique<IndirectFitOutputLegacy>( resultGroup, parameterTable, resultWorkspace, fitData, spectrum); @@ -324,9 +324,9 @@ private: } /// Store workspaces in ADS and won't destruct the ADS when leaving scope - void storeWorkspacesInADS(WorkspaceGroup_sptr workspacesGroup, - WorkspaceGroup_sptr resultGroup, - ITableWorkspace_sptr table) { + void storeWorkspacesInADS(const WorkspaceGroup_sptr &workspacesGroup, + const WorkspaceGroup_sptr &resultGroup, + const ITableWorkspace_sptr &table) { std::string const nameStart = resultGroup->size() > 1 ? "Multi" : ""; m_ads = std::make_unique<SetUpADSWithWorkspace>( nameStart + "ConvFit_1L_Workspaces", workspacesGroup); diff --git a/qt/scientific_interfaces/Indirect/test/IndirectFitPlotModelTest.h b/qt/scientific_interfaces/Indirect/test/IndirectFitPlotModelTest.h index 55a0f2ce1252d81dcca3209ea372f0121c9ea1c1..2114fe0717ec4de8b56054201c8a6a51f9546c6c 100644 --- a/qt/scientific_interfaces/Indirect/test/IndirectFitPlotModelTest.h +++ b/qt/scientific_interfaces/Indirect/test/IndirectFitPlotModelTest.h @@ -8,6 +8,8 @@ #include <cxxtest/TestSuite.h> +#include <utility> + #include "IndirectFitPlotModelLegacy.h" #include "MantidAPI/FrameworkManager.h" #include "MantidAPI/FunctionFactory.h" @@ -121,7 +123,7 @@ IndirectFittingModelLegacy *createModelWithSingleInstrumentWorkspace( return model; } -IAlgorithm_sptr setupFitAlgorithm(MatrixWorkspace_sptr workspace, +IAlgorithm_sptr setupFitAlgorithm(const MatrixWorkspace_sptr &workspace, std::string const &functionString) { auto alg = boost::make_shared<ConvolutionFitSequential>(); alg->initialize(); @@ -140,18 +142,19 @@ IAlgorithm_sptr setupFitAlgorithm(MatrixWorkspace_sptr workspace, } IAlgorithm_sptr getSetupFitAlgorithm(IndirectFittingModelLegacy *model, - MatrixWorkspace_sptr workspace, + const MatrixWorkspace_sptr &workspace, std::string const &workspaceName) { setFittingFunction(model, getFittingFunctionString(workspaceName), true); - auto alg = - setupFitAlgorithm(workspace, getFittingFunctionString(workspaceName)); + auto alg = setupFitAlgorithm(std::move(workspace), + getFittingFunctionString(workspaceName)); return alg; } IAlgorithm_sptr getExecutedFitAlgorithm(IndirectFittingModelLegacy *model, MatrixWorkspace_sptr workspace, std::string const &workspaceName) { - auto const alg = getSetupFitAlgorithm(model, workspace, workspaceName); + auto const alg = + getSetupFitAlgorithm(model, std::move(workspace), workspaceName); alg->execute(); return alg; } diff --git a/qt/scientific_interfaces/Indirect/test/IndirectFittingModelTest.h b/qt/scientific_interfaces/Indirect/test/IndirectFittingModelTest.h index cf0333eb5034f692ab53e855eeb26f7fb695f94f..b5afd434e62d86001c1217058a993a180e81a1e9 100644 --- a/qt/scientific_interfaces/Indirect/test/IndirectFittingModelTest.h +++ b/qt/scientific_interfaces/Indirect/test/IndirectFittingModelTest.h @@ -8,6 +8,8 @@ #include <cxxtest/TestSuite.h> +#include <utility> + #include "IndirectFittingModelLegacy.h" #include "MantidAPI/FrameworkManager.h" #include "MantidAPI/FunctionFactory.h" @@ -106,7 +108,7 @@ void setFittingFunction(std::unique_ptr<DummyModel> &model, model->setFitFunction(getFunction(functionString)); } -IAlgorithm_sptr setupFitAlgorithm(MatrixWorkspace_sptr workspace, +IAlgorithm_sptr setupFitAlgorithm(const MatrixWorkspace_sptr &workspace, std::string const &functionString) { auto alg = boost::make_shared<ConvolutionFitSequential>(); alg->initialize(); @@ -125,7 +127,7 @@ IAlgorithm_sptr setupFitAlgorithm(MatrixWorkspace_sptr workspace, } IAlgorithm_sptr getSetupFitAlgorithm(std::unique_ptr<DummyModel> &model, - MatrixWorkspace_sptr workspace, + const MatrixWorkspace_sptr &workspace, std::string const &workspaceName) { std::string const function = "name=LinearBackground,A0=0,A1=0,ties=(A0=0.000000,A1=0.0);" @@ -136,14 +138,15 @@ IAlgorithm_sptr getSetupFitAlgorithm(std::unique_ptr<DummyModel> &model, "false;name=Lorentzian,Amplitude=1,PeakCentre=0,FWHM=0." "0175)))"; setFittingFunction(model, function); - auto alg = setupFitAlgorithm(workspace, function); + auto alg = setupFitAlgorithm(std::move(workspace), function); return alg; } IAlgorithm_sptr getExecutedFitAlgorithm(std::unique_ptr<DummyModel> &model, MatrixWorkspace_sptr workspace, std::string const &workspaceName) { - auto const alg = getSetupFitAlgorithm(model, workspace, workspaceName); + auto const alg = + getSetupFitAlgorithm(model, std::move(workspace), workspaceName); alg->execute(); return alg; } diff --git a/qt/scientific_interfaces/Indirect/test/IndirectPlotOptionsModelTest.h b/qt/scientific_interfaces/Indirect/test/IndirectPlotOptionsModelTest.h index 963a8a9ee9457bf7cd45417f8fa7cdad0f52c025..50daa20751bd4fb4365d3a1d86dde3c9a56050a1 100644 --- a/qt/scientific_interfaces/Indirect/test/IndirectPlotOptionsModelTest.h +++ b/qt/scientific_interfaces/Indirect/test/IndirectPlotOptionsModelTest.h @@ -32,7 +32,8 @@ std::string const GROUP_NAME = "GroupName"; std::string const WORKSPACE_NAME = "WorkspaceName"; std::string const WORKSPACE_INDICES = "0-2,4"; -MatrixWorkspace_sptr convertWorkspace2DToMatrix(Workspace2D_sptr workspace) { +MatrixWorkspace_sptr +convertWorkspace2DToMatrix(const Workspace2D_sptr &workspace) { return boost::dynamic_pointer_cast<MatrixWorkspace>(workspace); } diff --git a/qt/scientific_interfaces/Indirect/test/IndirectPlotterTest.h b/qt/scientific_interfaces/Indirect/test/IndirectPlotterTest.h index 8a8ac0ca31ebe158afa8b6275e1289dfa520799c..63e26d4b06a4e5e2ce872fa6ca018a218cfc8800 100644 --- a/qt/scientific_interfaces/Indirect/test/IndirectPlotterTest.h +++ b/qt/scientific_interfaces/Indirect/test/IndirectPlotterTest.h @@ -28,7 +28,8 @@ namespace { std::string const WORKSPACE_NAME = "WorkspaceName"; std::string const WORKSPACE_INDICES = "0-2,4"; -MatrixWorkspace_sptr convertWorkspace2DToMatrix(Workspace2D_sptr workspace) { +MatrixWorkspace_sptr +convertWorkspace2DToMatrix(const Workspace2D_sptr &workspace) { return boost::dynamic_pointer_cast<MatrixWorkspace>(workspace); } diff --git a/qt/scientific_interfaces/MultiDatasetFit/MDFFunctionPlotData.cpp b/qt/scientific_interfaces/MultiDatasetFit/MDFFunctionPlotData.cpp index 269e083b5ff8ea78994b1ebce78618aefd430244..775b683bac3d9e8fd00139c3dd9cd87f881c9e39 100644 --- a/qt/scientific_interfaces/MultiDatasetFit/MDFFunctionPlotData.cpp +++ b/qt/scientific_interfaces/MultiDatasetFit/MDFFunctionPlotData.cpp @@ -18,6 +18,8 @@ #include <qwt_plot.h> #include <qwt_plot_curve.h> +#include <utility> + namespace MantidQt { namespace CustomInterfaces { namespace MDF { @@ -38,7 +40,7 @@ auto FUNCTION_CURVE_COLOR = Qt::magenta; MDFFunctionPlotData::MDFFunctionPlotData( boost::shared_ptr<Mantid::API::IFunction> fun, double startX, double endX, size_t nX) - : m_function(fun), m_functionCurve(new QwtPlotCurve()) { + : m_function(std::move(fun)), m_functionCurve(new QwtPlotCurve()) { setDomain(startX, endX, nX); auto pen = m_functionCurve->pen(); pen.setColor(FUNCTION_CURVE_COLOR); diff --git a/qt/scientific_interfaces/MultiDatasetFit/MultiDatasetFit.cpp b/qt/scientific_interfaces/MultiDatasetFit/MultiDatasetFit.cpp index 66f8c2d83d91cd5030d6dbe14907eebd73725c71..16ddb25e259a86ae7fdede67135202373faf53fb 100644 --- a/qt/scientific_interfaces/MultiDatasetFit/MultiDatasetFit.cpp +++ b/qt/scientific_interfaces/MultiDatasetFit/MultiDatasetFit.cpp @@ -704,7 +704,7 @@ QString MultiDatasetFit::getLocalParameterTie(const QString &parName, /// @param i :: Index of the dataset (spectrum). /// @param tie :: A tie string to set. void MultiDatasetFit::setLocalParameterTie(const QString &parName, int i, - QString tie) { + const QString &tie) { m_functionBrowser->setLocalParameterTie(parName, i, tie); } diff --git a/qt/scientific_interfaces/MultiDatasetFit/MultiDatasetFit.h b/qt/scientific_interfaces/MultiDatasetFit/MultiDatasetFit.h index 1c22f702a8943c468585a7ac60a167926e15aaf4..4fbffc943cb3aef475a674c5a29257c0148f54f2 100644 --- a/qt/scientific_interfaces/MultiDatasetFit/MultiDatasetFit.h +++ b/qt/scientific_interfaces/MultiDatasetFit/MultiDatasetFit.h @@ -79,7 +79,7 @@ public: /// Get the tie for a local parameter. QString getLocalParameterTie(const QString &parName, int i) const; /// Set a tie for a local parameter. - void setLocalParameterTie(const QString &parName, int i, QString tie); + void setLocalParameterTie(const QString &parName, int i, const QString &tie); /// Log a warning static void logWarning(const std::string &msg); diff --git a/qt/scientific_interfaces/Muon/ALCBaselineModellingModel.cpp b/qt/scientific_interfaces/Muon/ALCBaselineModellingModel.cpp index 5d098f6c3a688bf9e1c5edd6a60c65bfa1aa7eee..6bce171fc778969a6b2aeee621d6c2c4e2d74401 100644 --- a/qt/scientific_interfaces/Muon/ALCBaselineModellingModel.cpp +++ b/qt/scientific_interfaces/Muon/ALCBaselineModellingModel.cpp @@ -14,12 +14,13 @@ #include "Poco/ActiveResult.h" #include <QApplication> +#include <utility> using namespace Mantid::API; namespace { -MatrixWorkspace_sptr extractSpectrum(MatrixWorkspace_sptr inputWorkspace, +MatrixWorkspace_sptr extractSpectrum(const MatrixWorkspace_sptr &inputWorkspace, const int workspaceIndex) { auto extracter = AlgorithmManager::Instance().create("ExtractSingleSpectrum"); extracter->setChild(true); @@ -31,8 +32,9 @@ MatrixWorkspace_sptr extractSpectrum(MatrixWorkspace_sptr inputWorkspace, return output; } -MatrixWorkspace_sptr evaluateFunction(IFunction_const_sptr function, - MatrixWorkspace_sptr inputWorkspace) { +MatrixWorkspace_sptr +evaluateFunction(const IFunction_const_sptr &function, + const MatrixWorkspace_sptr &inputWorkspace) { auto fit = AlgorithmManager::Instance().create("Fit"); fit->setChild(true); fit->setProperty("Function", function->asString()); @@ -96,7 +98,7 @@ void ALCBaselineModellingModel::fit(IFunction_const_sptr function, } void ALCBaselineModellingModel::setData(MatrixWorkspace_sptr data) { - m_data = data; + m_data = std::move(data); emit dataChanged(); } @@ -108,7 +110,7 @@ void ALCBaselineModellingModel::setData(MatrixWorkspace_sptr data) { * @param sections :: Section we want to use for fitting */ void ALCBaselineModellingModel::disableUnwantedPoints( - MatrixWorkspace_sptr ws, + const MatrixWorkspace_sptr &ws, const std::vector<IALCBaselineModellingModel::Section> §ions) { // Whether point with particular index should be disabled const size_t numBins = ws->blocksize(); @@ -146,7 +148,8 @@ void ALCBaselineModellingModel::disableUnwantedPoints( * @param sourceWs :: Workspace with original errors */ void ALCBaselineModellingModel::enableDisabledPoints( - MatrixWorkspace_sptr destWs, MatrixWorkspace_const_sptr sourceWs) { + const MatrixWorkspace_sptr &destWs, + const MatrixWorkspace_const_sptr &sourceWs) { // Unwanted points were disabled by setting their errors to very high values. // We recover here the original errors stored in sourceWs destWs->mutableE(0) = sourceWs->e(0); @@ -156,7 +159,8 @@ void ALCBaselineModellingModel::enableDisabledPoints( * Set errors in Diff spectrum after a fit * @param data :: [input/output] Workspace containing spectrum to set errors to */ -void ALCBaselineModellingModel::setErrorsAfterFit(MatrixWorkspace_sptr data) { +void ALCBaselineModellingModel::setErrorsAfterFit( + const MatrixWorkspace_sptr &data) { data->mutableE(2) = data->e(0); } @@ -208,13 +212,13 @@ ITableWorkspace_sptr ALCBaselineModellingModel::exportModel() { } void ALCBaselineModellingModel::setCorrectedData(MatrixWorkspace_sptr data) { - m_data = data; + m_data = std::move(data); emit correctedDataChanged(); } void ALCBaselineModellingModel::setFittedFunction( IFunction_const_sptr function) { - m_fittedFunction = function; + m_fittedFunction = std::move(function); emit fittedFunctionChanged(); } diff --git a/qt/scientific_interfaces/Muon/ALCBaselineModellingModel.h b/qt/scientific_interfaces/Muon/ALCBaselineModellingModel.h index 58b7793440ea6442497f509b63660c9a0b07cdf5..552cf859176858c2f330fe2e5d2f2ecef5124d32 100644 --- a/qt/scientific_interfaces/Muon/ALCBaselineModellingModel.h +++ b/qt/scientific_interfaces/Muon/ALCBaselineModellingModel.h @@ -76,16 +76,16 @@ private: void setFittedFunction(Mantid::API::IFunction_const_sptr function); // Set errors in the ws after the fit - void setErrorsAfterFit(Mantid::API::MatrixWorkspace_sptr data); + void setErrorsAfterFit(const Mantid::API::MatrixWorkspace_sptr &data); /// Disables points which shouldn't be used for fitting - static void disableUnwantedPoints(Mantid::API::MatrixWorkspace_sptr ws, + static void disableUnwantedPoints(const Mantid::API::MatrixWorkspace_sptr &ws, const std::vector<Section> §ions); /// Enable previously disabled points static void - enableDisabledPoints(Mantid::API::MatrixWorkspace_sptr destWs, - Mantid::API::MatrixWorkspace_const_sptr sourceWs); + enableDisabledPoints(const Mantid::API::MatrixWorkspace_sptr &destWs, + const Mantid::API::MatrixWorkspace_const_sptr &sourceWs); }; } // namespace CustomInterfaces diff --git a/qt/scientific_interfaces/Muon/ALCDataLoadingPresenter.cpp b/qt/scientific_interfaces/Muon/ALCDataLoadingPresenter.cpp index 9b690fb5a69f9a38652966ca646dfd6da182da28..b69d77f6408322d3b340d73fc5894d3ba6fb02bf 100644 --- a/qt/scientific_interfaces/Muon/ALCDataLoadingPresenter.cpp +++ b/qt/scientific_interfaces/Muon/ALCDataLoadingPresenter.cpp @@ -331,7 +331,7 @@ MatrixWorkspace_sptr ALCDataLoadingPresenter::exportWorkspace() { return MatrixWorkspace_sptr(); } -void ALCDataLoadingPresenter::setData(MatrixWorkspace_sptr data) { +void ALCDataLoadingPresenter::setData(const MatrixWorkspace_sptr &data) { if (data) { // Set the data diff --git a/qt/scientific_interfaces/Muon/ALCDataLoadingPresenter.h b/qt/scientific_interfaces/Muon/ALCDataLoadingPresenter.h index 5d3c9b115f5d2da19b445043785b725705cf10d3..cd32412a5bfa946942c83f266ca9cd0c123e4a5f 100644 --- a/qt/scientific_interfaces/Muon/ALCDataLoadingPresenter.h +++ b/qt/scientific_interfaces/Muon/ALCDataLoadingPresenter.h @@ -35,7 +35,7 @@ public: Mantid::API::MatrixWorkspace_sptr exportWorkspace(); /// Sets some data - void setData(Mantid::API::MatrixWorkspace_sptr data); + void setData(const Mantid::API::MatrixWorkspace_sptr &data); // Returns a boolean stating whether data is currently being loading bool isLoading() const; diff --git a/qt/scientific_interfaces/Muon/ALCPeakFittingModel.cpp b/qt/scientific_interfaces/Muon/ALCPeakFittingModel.cpp index e163ec97d036e269a9adcf43d0fa6aaff19356a9..9eae7ba7510fc4d3a2e3d71ad7807807009ccdd8 100644 --- a/qt/scientific_interfaces/Muon/ALCPeakFittingModel.cpp +++ b/qt/scientific_interfaces/Muon/ALCPeakFittingModel.cpp @@ -16,12 +16,13 @@ #include <Poco/ActiveResult.h> #include <QApplication> +#include <utility> using namespace Mantid::API; namespace { -MatrixWorkspace_sptr extractSpectrum(MatrixWorkspace_sptr inputWorkspace, +MatrixWorkspace_sptr extractSpectrum(const MatrixWorkspace_sptr &inputWorkspace, const int workspaceIndex) { auto extracter = AlgorithmManager::Instance().create("ExtractSingleSpectrum"); extracter->setChild(true); @@ -33,8 +34,9 @@ MatrixWorkspace_sptr extractSpectrum(MatrixWorkspace_sptr inputWorkspace, return output; } -MatrixWorkspace_sptr evaluateFunction(IFunction_const_sptr function, - MatrixWorkspace_sptr inputWorkspace) { +MatrixWorkspace_sptr +evaluateFunction(const IFunction_const_sptr &function, + const MatrixWorkspace_sptr &inputWorkspace) { auto fit = AlgorithmManager::Instance().create("Fit"); fit->setChild(true); fit->setProperty("Function", function->asString()); @@ -52,7 +54,7 @@ namespace MantidQt { namespace CustomInterfaces { void ALCPeakFittingModel::setData(MatrixWorkspace_sptr newData) { - m_data = newData; + m_data = std::move(newData); emit dataChanged(); } @@ -79,7 +81,7 @@ ITableWorkspace_sptr ALCPeakFittingModel::exportFittedPeaks() { } void ALCPeakFittingModel::setFittedPeaks(IFunction_const_sptr fittedPeaks) { - m_fittedPeaks = fittedPeaks; + m_fittedPeaks = std::move(fittedPeaks); emit fittedPeaksChanged(); } diff --git a/qt/scientific_interfaces/Muon/MuonAnalysis.cpp b/qt/scientific_interfaces/Muon/MuonAnalysis.cpp index 656b4b0092ec843eef2a4b18b7266b89bfa0cfe2..2de5fbaf935ed5c766331b0b2088b462878317b1 100644 --- a/qt/scientific_interfaces/Muon/MuonAnalysis.cpp +++ b/qt/scientific_interfaces/Muon/MuonAnalysis.cpp @@ -60,6 +60,7 @@ #include <QVariant> #include <fstream> +#include <utility> // Add this class to the list of specialised dialogs in this namespace namespace MantidQt { @@ -604,7 +605,7 @@ Workspace_sptr MuonAnalysis::createAnalysisWorkspace(ItemType itemType, options.timeLimits.second = finishTime(); options.rebinArgs = isRaw ? "" : rebinParams(loadedWS); options.plotType = plotType; - options.wsName = wsName; + options.wsName = std::move(wsName); const auto *table = itemType == ItemType::Group ? m_uiForm.groupTable : m_uiForm.pairTable; options.groupPairName = table->item(tableRow, 0)->text().toStdString(); @@ -1180,8 +1181,8 @@ void MuonAnalysis::handleInputFileChanges() { * @param loadResult :: Various loaded parameters as returned by load() * @return Used grouping for populating grouping table */ -boost::shared_ptr<GroupResult> -MuonAnalysis::getGrouping(boost::shared_ptr<LoadResult> loadResult) const { +boost::shared_ptr<GroupResult> MuonAnalysis::getGrouping( + const boost::shared_ptr<LoadResult> &loadResult) const { auto result = boost::make_shared<GroupResult>(); boost::shared_ptr<Mantid::API::Grouping> groupingToUse; @@ -2220,13 +2221,13 @@ double MuonAnalysis::timeZero() { * size * @return Params string to pass to rebin */ -std::string MuonAnalysis::rebinParams(Workspace_sptr wsForRebin) { +std::string MuonAnalysis::rebinParams(const Workspace_sptr &wsForRebin) { MuonAnalysisOptionTab::RebinType rebinType = m_optionTab->getRebinType(); if (rebinType == MuonAnalysisOptionTab::NoRebin) { return ""; } else if (rebinType == MuonAnalysisOptionTab::FixedRebin) { - MatrixWorkspace_sptr ws = firstPeriod(wsForRebin); + MatrixWorkspace_sptr ws = firstPeriod(std::move(wsForRebin)); double binSize = ws->x(0)[1] - ws->x(0)[0]; double stepSize = m_optionTab->getRebinStep(); @@ -2749,7 +2750,7 @@ void MuonAnalysis::changeTab(int newTabIndex) { m_currentTab = newTab; } -void MuonAnalysis::updateNormalization(QString name) { +void MuonAnalysis::updateNormalization(const QString &name) { m_uiForm.fitBrowser->setNormalization(name.toStdString()); } diff --git a/qt/scientific_interfaces/Muon/MuonAnalysis.h b/qt/scientific_interfaces/Muon/MuonAnalysis.h index 66edab2ad32081072730286cb7a51454a8dc00cd..928e66f62e98c86aaf97017908e6ef3b2cbb7198 100644 --- a/qt/scientific_interfaces/Muon/MuonAnalysis.h +++ b/qt/scientific_interfaces/Muon/MuonAnalysis.h @@ -241,7 +241,7 @@ private slots: /// Called when "overwrite" is changed void updateDataPresenterOverwrite(int state); // update the displayed normalization - void updateNormalization(QString name); + void updateNormalization(const QString &name); private: void moveUnNormWS(const std::string &name, std::vector<std::string> &wsNames, @@ -270,7 +270,7 @@ private: /// Get grouping for the loaded workspace boost::shared_ptr<Muon::GroupResult> - getGrouping(boost::shared_ptr<Muon::LoadResult> loadResult) const; + getGrouping(const boost::shared_ptr<Muon::LoadResult> &loadResult) const; /// Set whether the loading buttons and MWRunFiles widget are enabled. void allowLoading(bool enabled); @@ -413,7 +413,7 @@ private: /// Returns params string which can be passed to Rebin, according to what user /// specified - std::string rebinParams(Mantid::API::Workspace_sptr wsForRebin); + std::string rebinParams(const Mantid::API::Workspace_sptr &wsForRebin); /// Updates rebin params in the fit data presenter void updateRebinParams(); diff --git a/qt/scientific_interfaces/Muon/MuonAnalysisDataLoader.cpp b/qt/scientific_interfaces/Muon/MuonAnalysisDataLoader.cpp index 7c173945654d579e4ef90c4831acb62ec4c495ba..07eee852f1d2fa6f728982b73ace406524445808 100644 --- a/qt/scientific_interfaces/Muon/MuonAnalysisDataLoader.cpp +++ b/qt/scientific_interfaces/Muon/MuonAnalysisDataLoader.cpp @@ -199,7 +199,7 @@ LoadResult MuonAnalysisDataLoader::loadFiles(const QStringList &files) const { * @returns :: name of instrument (empty if failed to get it) */ std::string MuonAnalysisDataLoader::getInstrumentName( - const Workspace_sptr workspace) const { + const Workspace_sptr &workspace) const { if (workspace) { const auto period = MuonAnalysisHelper::firstPeriod(workspace); if (period) { @@ -339,7 +339,7 @@ Workspace_sptr MuonAnalysisDataLoader::loadDeadTimesFromFile( * @returns :: Workspace containing analysed data */ Workspace_sptr MuonAnalysisDataLoader::createAnalysisWorkspace( - const Workspace_sptr inputWS, const AnalysisOptions &options) const { + const Workspace_sptr &inputWS, const AnalysisOptions &options) const { IAlgorithm_sptr alg = AlgorithmManager::Instance().createUnmanaged("MuonProcess"); @@ -381,7 +381,7 @@ Workspace_sptr MuonAnalysisDataLoader::createAnalysisWorkspace( * @param options :: [input] Options to get properties from */ void MuonAnalysisDataLoader::setProcessAlgorithmProperties( - IAlgorithm_sptr alg, const AnalysisOptions &options) const { + const IAlgorithm_sptr &alg, const AnalysisOptions &options) const { alg->setProperty("Mode", "Analyse"); alg->setProperty("TimeZero", options.timeZero); // user input alg->setProperty("LoadedTimeZero", options.loadedTimeZero); // from file diff --git a/qt/scientific_interfaces/Muon/MuonAnalysisDataLoader.h b/qt/scientific_interfaces/Muon/MuonAnalysisDataLoader.h index e79b47c4e8536d32769cbd16d6697b43ff3fa322..1922723d230e2e9347b32a6575cb9841f4835c78 100644 --- a/qt/scientific_interfaces/Muon/MuonAnalysisDataLoader.h +++ b/qt/scientific_interfaces/Muon/MuonAnalysisDataLoader.h @@ -72,7 +72,7 @@ public: const Mantid::API::Grouping &grouping) const; /// create analysis workspace Mantid::API::Workspace_sptr - createAnalysisWorkspace(const Mantid::API::Workspace_sptr inputWS, + createAnalysisWorkspace(const Mantid::API::Workspace_sptr &inputWS, const Muon::AnalysisOptions &options) const; /// Get dead time table Mantid::API::ITableWorkspace_sptr @@ -92,7 +92,7 @@ public: protected: /// Set properties of algorithm from options void - setProcessAlgorithmProperties(Mantid::API::IAlgorithm_sptr alg, + setProcessAlgorithmProperties(const Mantid::API::IAlgorithm_sptr &alg, const Muon::AnalysisOptions &options) const; /// Remove from cache any workspaces that have been deleted in the meantime void updateCache() const; @@ -100,7 +100,7 @@ protected: private: /// Get instrument name from workspace std::string - getInstrumentName(const Mantid::API::Workspace_sptr workspace) const; + getInstrumentName(const Mantid::API::Workspace_sptr &workspace) const; /// Check if we should cache result of a load of the given files bool shouldBeCached(const QStringList &filenames) const; diff --git a/qt/scientific_interfaces/Muon/MuonAnalysisFitDataPresenter.cpp b/qt/scientific_interfaces/Muon/MuonAnalysisFitDataPresenter.cpp index f02b2080ab4f386dd1640dff18cf38f3115c9797..4130fd8f14b0b211e6cbaa075fc0edc6791be193 100644 --- a/qt/scientific_interfaces/Muon/MuonAnalysisFitDataPresenter.cpp +++ b/qt/scientific_interfaces/Muon/MuonAnalysisFitDataPresenter.cpp @@ -483,7 +483,7 @@ MuonAnalysisFitDataPresenter::createWorkspace(const std::string &name, * @returns :: parameter string for rebinning */ std::string MuonAnalysisFitDataPresenter::getRebinParams( - const Mantid::API::Workspace_sptr ws) const { + const Mantid::API::Workspace_sptr &ws) const { // First check for workspace group. If it is, use first entry if (const auto &group = boost::dynamic_pointer_cast<WorkspaceGroup>(ws)) { if (group->size() > 0) { diff --git a/qt/scientific_interfaces/Muon/MuonAnalysisFitDataPresenter.h b/qt/scientific_interfaces/Muon/MuonAnalysisFitDataPresenter.h index 438b59b8a08c9393964ffb3fc7b8b25e24b8e73e..bf7701c46f8df1998ad1c9cb6b22a19784f9606b 100644 --- a/qt/scientific_interfaces/Muon/MuonAnalysisFitDataPresenter.h +++ b/qt/scientific_interfaces/Muon/MuonAnalysisFitDataPresenter.h @@ -134,7 +134,7 @@ private: /// Update model and view with names of workspaces to fit void updateWorkspaceNames(const std::vector<std::string> &names) const; /// Get rebin options for analysis - std::string getRebinParams(const Mantid::API::Workspace_sptr ws) const; + std::string getRebinParams(const Mantid::API::Workspace_sptr &ws) const; /// Add special logs to fitted workspaces void addSpecialLogs( const std::string &wsName, diff --git a/qt/scientific_interfaces/Muon/MuonAnalysisHelper.cpp b/qt/scientific_interfaces/Muon/MuonAnalysisHelper.cpp index c48468a378df4f4a1a57dbf6f7dd347c12173892..bc4dea86177f3fed4fcf6f4d1630645abcf18c15 100644 --- a/qt/scientific_interfaces/Muon/MuonAnalysisHelper.cpp +++ b/qt/scientific_interfaces/Muon/MuonAnalysisHelper.cpp @@ -27,6 +27,7 @@ #include <boost/lexical_cast.hpp> #include <boost/scope_exit.hpp> #include <stdexcept> +#include <utility> namespace { /// Colors for workspace (Black, Red, Green, Blue, Orange, Purple, if there are @@ -96,7 +97,7 @@ void setDoubleValidator(QLineEdit *field, bool allowEmpty) { * only - it is returned. * @param ws :: Run workspace */ -MatrixWorkspace_sptr firstPeriod(Workspace_sptr ws) { +MatrixWorkspace_sptr firstPeriod(const Workspace_sptr &ws) { if (auto group = boost::dynamic_pointer_cast<WorkspaceGroup>(ws)) { return boost::dynamic_pointer_cast<MatrixWorkspace>(group->getItem(0)); } else { @@ -109,7 +110,7 @@ MatrixWorkspace_sptr firstPeriod(Workspace_sptr ws) { * @param ws :: Run wokspace * @return Number of periods */ -size_t numPeriods(Workspace_sptr ws) { +size_t numPeriods(const Workspace_sptr &ws) { if (auto group = boost::dynamic_pointer_cast<WorkspaceGroup>(ws)) { return group->size(); } else { @@ -122,7 +123,7 @@ size_t numPeriods(Workspace_sptr ws) { * @param runWs :: Run workspace to retrieve information from * @param out :: Stream to print to */ -void printRunInfo(MatrixWorkspace_sptr runWs, std::ostringstream &out) { +void printRunInfo(const MatrixWorkspace_sptr &runWs, std::ostringstream &out) { // Remember current out stream format std::ios_base::fmtflags outFlags(out.flags()); std::streamsize outPrecision(out.precision()); @@ -253,7 +254,7 @@ void WidgetAutoSaver::registerWidget(QWidget *widget, const QString &name, QVariant defaultValue) { m_registeredWidgets.push_back(widget); m_widgetNames[widget] = name; - m_widgetDefaultValues[widget] = defaultValue; + m_widgetDefaultValues[widget] = std::move(defaultValue); m_widgetGroups[widget] = m_settings.group(); // Current group set up using beginGroup and endGroup } @@ -710,7 +711,7 @@ void replaceLogValue(const std::string &wsName, const std::string &logName, * @param logName :: [input] Name of log * @returns All values found for the given log */ -std::vector<std::string> findLogValues(const Workspace_sptr ws, +std::vector<std::string> findLogValues(const Workspace_sptr &ws, const std::string &logName) { std::vector<std::string> values; MatrixWorkspace_sptr matrixWS; @@ -747,7 +748,7 @@ std::vector<std::string> findLogValues(const Workspace_sptr ws, * @returns :: Pair of (smallest, largest) values */ std::pair<std::string, std::string> findLogRange( - const Workspace_sptr ws, const std::string &logName, + const Workspace_sptr &ws, const std::string &logName, bool (*isLessThan)(const std::string &first, const std::string &second)) { auto values = findLogValues(ws, logName); if (!values.empty()) { @@ -793,7 +794,8 @@ std::pair<std::string, std::string> findLogRange( * @throws std::invalid_argument if the workspaces supplied are null or have * different number of periods */ -void appendTimeSeriesLogs(Workspace_sptr toAppend, Workspace_sptr resultant, +void appendTimeSeriesLogs(const Workspace_sptr &toAppend, + const Workspace_sptr &resultant, const std::string &logName) { // check input if (!toAppend || !resultant) { @@ -802,7 +804,7 @@ void appendTimeSeriesLogs(Workspace_sptr toAppend, Workspace_sptr resultant, } // Cast the inputs to MatrixWorkspace (could be a group) - auto getWorkspaces = [](const Workspace_sptr ws) { + auto getWorkspaces = [](const Workspace_sptr &ws) { std::vector<MatrixWorkspace_sptr> workspaces; MatrixWorkspace_sptr matrixWS = boost::dynamic_pointer_cast<MatrixWorkspace>(ws); @@ -824,7 +826,7 @@ void appendTimeSeriesLogs(Workspace_sptr toAppend, Workspace_sptr resultant, }; // Extract time series log from workspace - auto getTSLog = [&logName](const MatrixWorkspace_sptr ws) { + auto getTSLog = [&logName](const MatrixWorkspace_sptr &ws) { const Mantid::API::Run &run = ws->run(); TimeSeriesProperty<double> *prop = nullptr; if (run.hasProperty(logName)) { @@ -905,8 +907,8 @@ QString runNumberString(const std::string &workspaceName, * @throws std::invalid_argument if loadedWorkspace is null */ bool isReloadGroupingNecessary( - const boost::shared_ptr<Mantid::API::Workspace> currentWorkspace, - const boost::shared_ptr<Mantid::API::Workspace> loadedWorkspace) { + const boost::shared_ptr<Mantid::API::Workspace> ¤tWorkspace, + const boost::shared_ptr<Mantid::API::Workspace> &loadedWorkspace) { if (!loadedWorkspace) { throw std::invalid_argument("No loaded workspace to get grouping for!"); } diff --git a/qt/scientific_interfaces/Muon/MuonAnalysisHelper.h b/qt/scientific_interfaces/Muon/MuonAnalysisHelper.h index 8eb5319168f12e98d98325873e2e5fafb13ebab5..4044b3314635ac50cefe91cab379eff63d4856a1 100644 --- a/qt/scientific_interfaces/Muon/MuonAnalysisHelper.h +++ b/qt/scientific_interfaces/Muon/MuonAnalysisHelper.h @@ -50,7 +50,7 @@ MANTIDQT_MUONINTERFACE_DLL void setDoubleValidator(QLineEdit *field, /// Returns a first period MatrixWorkspace in a run workspace MANTIDQT_MUONINTERFACE_DLL Mantid::API::MatrixWorkspace_sptr -firstPeriod(Mantid::API::Workspace_sptr ws); +firstPeriod(const Mantid::API::Workspace_sptr &ws); /// Validates the field and returns the value MANTIDQT_MUONINTERFACE_DLL double @@ -58,11 +58,13 @@ getValidatedDouble(QLineEdit *field, const QString &defaultValue, const QString &valueDescr, Mantid::Kernel::Logger &log); /// Returns a number of periods in a run workspace -MANTIDQT_MUONINTERFACE_DLL size_t numPeriods(Mantid::API::Workspace_sptr ws); +MANTIDQT_MUONINTERFACE_DLL size_t +numPeriods(const Mantid::API::Workspace_sptr &ws); /// Print various information about the run MANTIDQT_MUONINTERFACE_DLL void -printRunInfo(Mantid::API::MatrixWorkspace_sptr runWs, std::ostringstream &out); +printRunInfo(const Mantid::API::MatrixWorkspace_sptr &runWs, + std::ostringstream &out); /// Get a run label for the workspace MANTIDQT_MUONINTERFACE_DLL std::string @@ -97,11 +99,12 @@ MANTIDQT_MUONINTERFACE_DLL void replaceLogValue(const std::string &wsName, /// Finds all of the values for a log MANTIDQT_MUONINTERFACE_DLL std::vector<std::string> -findLogValues(const Mantid::API::Workspace_sptr ws, const std::string &logName); +findLogValues(const Mantid::API::Workspace_sptr &ws, + const std::string &logName); /// Finds the range of values for a log MANTIDQT_MUONINTERFACE_DLL std::pair<std::string, std::string> findLogRange( - const Mantid::API::Workspace_sptr ws, const std::string &logName, + const Mantid::API::Workspace_sptr &ws, const std::string &logName, bool (*isLessThan)(const std::string &first, const std::string &second)); /// Finds the range of values for a log for a vector of workspaces @@ -112,8 +115,8 @@ MANTIDQT_MUONINTERFACE_DLL std::pair<std::string, std::string> findLogRange( /// Concatenates time-series log of one workspace with the second MANTIDQT_MUONINTERFACE_DLL void -appendTimeSeriesLogs(boost::shared_ptr<Mantid::API::Workspace> toAppend, - boost::shared_ptr<Mantid::API::Workspace> resultant, +appendTimeSeriesLogs(const boost::shared_ptr<Mantid::API::Workspace> &toAppend, + const boost::shared_ptr<Mantid::API::Workspace> &resultant, const std::string &logName); /// Parse analysis workspace name @@ -130,8 +133,8 @@ runNumberString(const std::string &workspaceName, const std::string &firstRun); /// Decide if grouping needs to be reloaded MANTIDQT_MUONINTERFACE_DLL bool isReloadGroupingNecessary( - const boost::shared_ptr<Mantid::API::Workspace> currentWorkspace, - const boost::shared_ptr<Mantid::API::Workspace> loadedWorkspace); + const boost::shared_ptr<Mantid::API::Workspace> ¤tWorkspace, + const boost::shared_ptr<Mantid::API::Workspace> &loadedWorkspace); /// Parse run label into instrument and runs MANTIDQT_MUONINTERFACE_DLL void parseRunLabel(const std::string &label, diff --git a/qt/scientific_interfaces/Muon/MuonAnalysisResultTableCreator.cpp b/qt/scientific_interfaces/Muon/MuonAnalysisResultTableCreator.cpp index 976259602cd2787aee33cf41f8527d287be34b2e..73921efcb8fea5d35423860779f5246c4ab6fd03 100644 --- a/qt/scientific_interfaces/Muon/MuonAnalysisResultTableCreator.cpp +++ b/qt/scientific_interfaces/Muon/MuonAnalysisResultTableCreator.cpp @@ -278,7 +278,7 @@ void MuonAnalysisResultTableCreator::checkSameNumberOfDatasets( const size_t firstNumRuns = workspacesByLabel.begin()->second.size(); if (std::any_of(workspacesByLabel.begin(), workspacesByLabel.end(), [&firstNumRuns]( - const std::pair<QString, std::vector<std::string>> fit) { + const std::pair<QString, std::vector<std::string>> &fit) { return fit.second.size() != firstNumRuns; })) { throw std::runtime_error( @@ -753,7 +753,7 @@ bool MuonAnalysisResultTableCreator::haveSameParameters( * @param table :: [input, output] Pointer to TableWorkspace to edit */ void MuonAnalysisResultTableCreator::removeFixedParameterErrors( - const ITableWorkspace_sptr table) const { + const ITableWorkspace_sptr &table) const { assert(table); const size_t nRows = table->rowCount(); const auto colNames = table->getColumnNames(); diff --git a/qt/scientific_interfaces/Muon/MuonAnalysisResultTableCreator.h b/qt/scientific_interfaces/Muon/MuonAnalysisResultTableCreator.h index 35b5255dfbc6684c75a59648359bfaa3ed82cc52..54a07a44d503cc7fa7a7b082695a3d8413f65984 100644 --- a/qt/scientific_interfaces/Muon/MuonAnalysisResultTableCreator.h +++ b/qt/scientific_interfaces/Muon/MuonAnalysisResultTableCreator.h @@ -37,7 +37,7 @@ protected: const std::vector<Mantid::API::ITableWorkspace_sptr> &tables) const; /// Remove error columns for fixed parameters from a results table void removeFixedParameterErrors( - const Mantid::API::ITableWorkspace_sptr table) const; + const Mantid::API::ITableWorkspace_sptr &table) const; private: /// Get map of label to workspaces diff --git a/qt/scientific_interfaces/Muon/MuonAnalysisResultTableTab.cpp b/qt/scientific_interfaces/Muon/MuonAnalysisResultTableTab.cpp index ad0aaa54505281b32aefeb452574c3cf2a5fcda0..448285609140d4f8ffee450bf343be3858bea5cf 100644 --- a/qt/scientific_interfaces/Muon/MuonAnalysisResultTableTab.cpp +++ b/qt/scientific_interfaces/Muon/MuonAnalysisResultTableTab.cpp @@ -676,7 +676,7 @@ bool MuonAnalysisResultTableTab::logNameLessThan(const QString &logName1, */ void MuonAnalysisResultTableTab::populateFittings( const QStringList &names, - std::function<Workspace_sptr(const QString &)> wsFromName) { + const std::function<Workspace_sptr(const QString &)> &wsFromName) { // Add number of rows for the amount of fittings. m_uiForm.fittingResultsTable->setRowCount(names.size()); diff --git a/qt/scientific_interfaces/Muon/MuonAnalysisResultTableTab.h b/qt/scientific_interfaces/Muon/MuonAnalysisResultTableTab.h index e055b3238f8b59074f5e5295845db9df4bd62ffa..180e873717d2cdb4d87d28a654488d4887ebb6a9 100644 --- a/qt/scientific_interfaces/Muon/MuonAnalysisResultTableTab.h +++ b/qt/scientific_interfaces/Muon/MuonAnalysisResultTableTab.h @@ -98,7 +98,8 @@ private: void populateLogsAndValues(const QStringList &fittedWsList); void populateFittings( const QStringList &names, - std::function<Mantid::API::Workspace_sptr(const QString &)> wsFromName); + const std::function<Mantid::API::Workspace_sptr(const QString &)> + &wsFromName); /// Creates the results table void createTable(bool multipleFits); diff --git a/qt/scientific_interfaces/Muon/MuonSequentialFitDialog.cpp b/qt/scientific_interfaces/Muon/MuonSequentialFitDialog.cpp index b4b32f5cd36240f94824cd7ef319f5673d687369..12bbd3b993f3df84ee1ccd873defa97ad6d5e185 100644 --- a/qt/scientific_interfaces/Muon/MuonSequentialFitDialog.cpp +++ b/qt/scientific_interfaces/Muon/MuonSequentialFitDialog.cpp @@ -140,7 +140,8 @@ std::string MuonSequentialFitDialog::isValidLabel(const std::string &label) { * @param ws :: Workspace to get title from * @return The title, or empty string if unable to get one */ -std::string MuonSequentialFitDialog::getRunTitle(Workspace_const_sptr ws) { +std::string +MuonSequentialFitDialog::getRunTitle(const Workspace_const_sptr &ws) { auto matrixWS = boost::dynamic_pointer_cast<const MatrixWorkspace>(ws); if (!matrixWS) @@ -194,9 +195,9 @@ void MuonSequentialFitDialog::initDiagnosisTable() { * @param fitQuality :: Number representing goodness of the fit * @param fittedFunction :: Function containing fitted parameters */ -void MuonSequentialFitDialog::addDiagnosisEntry(const std::string &runTitle, - double fitQuality, - IFunction_sptr fittedFunction) { +void MuonSequentialFitDialog::addDiagnosisEntry( + const std::string &runTitle, double fitQuality, + const IFunction_sptr &fittedFunction) { int newRow = m_ui.diagnosisTable->rowCount(); m_ui.diagnosisTable->insertRow(newRow); diff --git a/qt/scientific_interfaces/Muon/MuonSequentialFitDialog.h b/qt/scientific_interfaces/Muon/MuonSequentialFitDialog.h index ae4b581bbc7c780e096a52959b25e7c9fc4c5154..b63041d86e7e39fd1e5e6cc65b137fee01f10aa9 100644 --- a/qt/scientific_interfaces/Muon/MuonSequentialFitDialog.h +++ b/qt/scientific_interfaces/Muon/MuonSequentialFitDialog.h @@ -56,7 +56,7 @@ private: /// Add a new entry to the diagnosis table void addDiagnosisEntry(const std::string &runTitle, double fitQuality, - Mantid::API::IFunction_sptr fittedFunction); + const Mantid::API::IFunction_sptr &fittedFunction); /// Helper function to create new item for Diagnosis table QTableWidgetItem *createTableWidgetItem(const QString &text); @@ -90,7 +90,7 @@ private: static std::string isValidLabel(const std::string &label); /// Returns displayable title for the given workspace - static std::string getRunTitle(Mantid::API::Workspace_const_sptr ws); + static std::string getRunTitle(const Mantid::API::Workspace_const_sptr &ws); // -- SLOTS ------------------------------------------------------ diff --git a/qt/scientific_interfaces/test/EnggDiffFittingModelTest.h b/qt/scientific_interfaces/test/EnggDiffFittingModelTest.h new file mode 100644 index 0000000000000000000000000000000000000000..7a7355b78ced0fbe7863d5bc2f7c3910b5339fa0 --- /dev/null +++ b/qt/scientific_interfaces/test/EnggDiffFittingModelTest.h @@ -0,0 +1,312 @@ +// Mantid Repository : https://github.com/mantidproject/mantid +// +// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI, +// NScD Oak Ridge National Laboratory, European Spallation Source +// & Institut Laue - Langevin +// SPDX - License - Identifier: GPL - 3.0 + +#pragma once + +#include "MantidAPI/FrameworkManager.h" +#include "MantidAPI/ITableWorkspace.h" +#include "MantidAPI/MatrixWorkspace.h" +#include "MantidAPI/Run.h" +#include "MantidAPI/TableRow.h" +#include "MantidAPI/WorkspaceFactory.h" + +#include "../EnggDiffraction/EnggDiffFittingModel.h" + +#include <cxxtest/TestSuite.h> +#include <utility> + +#include <vector> + +using namespace Mantid; +using namespace MantidQt::CustomInterfaces; + +namespace { + +// Helper class that exposes addFocusedWorkspace +// This means we can test the workspace maps without having to run Load +class EnggDiffFittingModelAddWSExposed : public EnggDiffFittingModel { +public: + void addWorkspace(const RunLabel &runLabel, + const Mantid::API::MatrixWorkspace_sptr &ws); + + void addFitParams(const RunLabel &runLabel, + const Mantid::API::ITableWorkspace_sptr &ws); + + void mergeTablesExposed(const API::ITableWorkspace_sptr &tableToCopy, + const API::ITableWorkspace_sptr &targetTable); +}; + +inline void EnggDiffFittingModelAddWSExposed::addWorkspace( + const RunLabel &runLabel, const API::MatrixWorkspace_sptr &ws) { + addFocusedWorkspace(runLabel, std::move(ws), + runLabel.runNumber + "_" + std::to_string(runLabel.bank)); +} + +inline void EnggDiffFittingModelAddWSExposed::addFitParams( + const RunLabel &runLabel, const Mantid::API::ITableWorkspace_sptr &ws) { + addFitResults(runLabel, std::move(ws)); +} + +inline void EnggDiffFittingModelAddWSExposed::mergeTablesExposed( + const API::ITableWorkspace_sptr &tableToCopy, + const API::ITableWorkspace_sptr &targetTable) { + mergeTables(std::move(tableToCopy), std::move(targetTable)); +} + +void addSampleWorkspaceToModel(const RunLabel &runLabel, + EnggDiffFittingModelAddWSExposed &model) { + API::MatrixWorkspace_sptr ws = + API::WorkspaceFactory::Instance().create("Workspace2D", 1, 10, 10); + model.addWorkspace(runLabel, ws); +} + +API::ITableWorkspace_sptr createFitParamsTable() { + const size_t numColumns = 16; + const size_t numRows = 4; + auto table = API::WorkspaceFactory::Instance().createTable("TableWorkspace"); + const std::array<std::string, numColumns> headings({{ + "dSpacing[Y]", + "A0[Y]", + "A0_Err[yEr]", + "A1[Y]", + "A1_Err[yEr]", + "X0[Y]", + "X0_Err[yEr]", + "A[Y]", + "A_Err[yEr]", + "B[Y]", + "B_Err[yEr]", + "S[Y]", + "S_Err[yEr]", + "I[Y]", + "I_Err[yEr]", + "Chi[Y]", + }}); + + for (const auto &columnHeading : headings) { + table->addColumn("double", columnHeading); + } + + const std::array<std::array<double, numColumns>, numRows> rows = { + {{{1.4826999999999999, 0.093628531894011102, 0.66109193835092461, + 1.2564478992707699e-06, 2.4291293347225761e-05, 27140.960929827994, + 4.4430783321852303, 0.045621368052062856, 0.0092005773305902459, + 0.020298218347394655, 0.0025002243189996306, 11.741120992807753, + 5.3771683079349311, 34.202007864467461, 1.8695496489293224, + 1.4096728498206776}}, + {{1.7197, 1.0731062065126851, 0.72931461734063008, + -2.9359794063082084e-05, 2.285663646689115e-05, 31770.101042814735, + 5.6899014393655358, 0.050855278541599255, 0.013915934527381201, + 0.029076388335360012, 0.002935493268317269, 27.132751332587915, + 4.5849081323418064, 89.646425792809978, 2.1570533782524279, + 0.79304374868658656}}, + {{2.2399, 1.3229681799066122, 0.45360789821414083, + -3.0219780224537017e-05, 1.0941426250415265e-05, 41266.973604075109, + 4.0391546488412224, 0.043604800066098286, 0.0071406722143233931, + 0.021740542092941812, 0.001008755490980281, 36.523446658868707, + 3.2982922870662814, 205.36292151601506, 2.3728608996241367, + 0.90144473999482344}}, + {{2.552, 0.46162942972449567, 0.24323265893625406, + -9.0850559562388256e-06, 5.1638893666718458e-06, 46982.314791027922, + 46.041577282817634, 0.14208244137460718, 0.61720906575104273, + 0.018444321135930489, 0.0078725143001187933, 45.171720946242374, + 18.656365897259217, 14.950355673087914, 1.02699955199189, + 0.68147322764610252}}}}; + + for (const auto &row : rows) { + API::TableRow tableRow = table->appendRow(); + for (const auto entry : row) { + tableRow << entry; + } + } + return table; +} + +template <size_t numColumns, size_t numRows> +API::ITableWorkspace_sptr createDummyTable( + const std::array<std::string, numColumns> &columnHeadings, + const std::array<std::array<double, numColumns>, numRows> tableContents) { + auto table = API::WorkspaceFactory::Instance().createTable(); + for (const auto &header : columnHeadings) { + table->addColumn("double", header); + } + for (const auto &row : tableContents) { + API::TableRow newRow = table->appendRow(); + for (const auto value : row) { + newRow << value; + } + } + return table; +} + +} // anonymous namespace + +class EnggDiffFittingModelTest : public CxxTest::TestSuite { + +public: + // This pair of boilerplate methods prevent the suite being created statically + // This means the constructor isn't called when running other tests + static EnggDiffFittingModelTest *createSuite() { + return new EnggDiffFittingModelTest(); + } + static void destroySuite(EnggDiffFittingModelTest *suite) { delete suite; } + + EnggDiffFittingModelTest() { API::FrameworkManager::Instance(); } + + void test_addAndGetWorkspace() { + auto model = EnggDiffFittingModelAddWSExposed(); + API::MatrixWorkspace_sptr ws = + API::WorkspaceFactory::Instance().create("Workspace2D", 1, 10, 10); + + const RunLabel runLabel("100", 1); + TS_ASSERT_THROWS_NOTHING(model.addWorkspace(runLabel, ws)); + const auto retrievedWS = model.getFocusedWorkspace(runLabel); + + TS_ASSERT(retrievedWS != nullptr); + TS_ASSERT_EQUALS(ws, retrievedWS); + } + + void test_getRunNumbersAndBankIDs() { + auto model = EnggDiffFittingModelAddWSExposed(); + + addSampleWorkspaceToModel(RunLabel("123", 1), model); + addSampleWorkspaceToModel(RunLabel("456", 2), model); + addSampleWorkspaceToModel(RunLabel("789", 1), model); + addSampleWorkspaceToModel(RunLabel("123", 2), model); + + const auto runLabels = model.getRunLabels(); + + TS_ASSERT_EQUALS(runLabels.size(), 4); + TS_ASSERT_EQUALS(runLabels[0], RunLabel("123", 1)); + TS_ASSERT_EQUALS(runLabels[1], RunLabel("123", 2)); + TS_ASSERT_EQUALS(runLabels[2], RunLabel("456", 2)); + TS_ASSERT_EQUALS(runLabels[3], RunLabel("789", 1)); + } + + void test_loadWorkspaces() { + auto model = EnggDiffFittingModel(); + TS_ASSERT_THROWS_NOTHING(model.loadWorkspaces(FOCUSED_WS_FILENAME)); + API::MatrixWorkspace_sptr ws; + TS_ASSERT_THROWS_NOTHING( + ws = model.getFocusedWorkspace(FOCUSED_WS_RUN_LABEL)); + TS_ASSERT_EQUALS(ws->getNumberHistograms(), 1); + TS_ASSERT_EQUALS(std::to_string(ws->getRunNumber()), + FOCUSED_WS_RUN_LABEL.runNumber); + } + + void test_setDifcTzero() { + auto model = EnggDiffFittingModel(); + TS_ASSERT_THROWS_NOTHING(model.loadWorkspaces(FOCUSED_WS_FILENAME)); + + TS_ASSERT_THROWS_NOTHING(model.setDifcTzero( + FOCUSED_WS_RUN_LABEL, std::vector<GSASCalibrationParms>())); + auto ws = model.getFocusedWorkspace(FOCUSED_WS_RUN_LABEL); + auto run = ws->run(); + TS_ASSERT(run.hasProperty("difa")); + TS_ASSERT(run.hasProperty("difc")); + TS_ASSERT(run.hasProperty("tzero")); + } + + void test_createFittedPeaksWS() { + auto model = EnggDiffFittingModelAddWSExposed(); + + const auto fitParams = createFitParamsTable(); + TS_ASSERT_THROWS_NOTHING( + model.addFitParams(FOCUSED_WS_RUN_LABEL, fitParams)); + TS_ASSERT_THROWS_NOTHING(model.loadWorkspaces(FOCUSED_WS_FILENAME)); + + TS_ASSERT_THROWS_NOTHING(model.setDifcTzero( + FOCUSED_WS_RUN_LABEL, std::vector<GSASCalibrationParms>())); + TS_ASSERT_THROWS_NOTHING(model.createFittedPeaksWS(FOCUSED_WS_RUN_LABEL)); + + API::MatrixWorkspace_sptr fittedPeaksWS; + TS_ASSERT_THROWS_NOTHING(fittedPeaksWS = + model.getFittedPeaksWS(FOCUSED_WS_RUN_LABEL)); + TS_ASSERT_EQUALS(fittedPeaksWS->getNumberHistograms(), 4); + } + + void test_getNumFocusedWorkspaces() { + auto model = EnggDiffFittingModelAddWSExposed(); + + addSampleWorkspaceToModel(RunLabel("123", 1), model); + addSampleWorkspaceToModel(RunLabel("456", 2), model); + addSampleWorkspaceToModel(RunLabel("789", 1), model); + + TS_ASSERT_EQUALS(model.getNumFocusedWorkspaces(), 3); + } + + void test_mergeTables() { + auto model = EnggDiffFittingModelAddWSExposed(); + + const size_t numberOfColumns = 3; + const size_t numberOfRows = 2; + + const std::array<std::string, numberOfColumns> columnHeadings = { + {"X", "Y", "Z"}}; + + const std::array<std::array<double, numberOfColumns>, numberOfRows> + targetTableValues = {{{{1, 2, 3}}, {{4, 5, 6}}}}; + + auto targetTable = createDummyTable(columnHeadings, targetTableValues); + + const std::array<std::array<double, numberOfColumns>, numberOfRows> + copyTableValues = {{{{7, 8, 9}}, {{10, 11, 12}}}}; + + auto copyTable = createDummyTable(columnHeadings, copyTableValues); + + TS_ASSERT_THROWS_NOTHING(model.mergeTablesExposed(copyTable, targetTable)); + + TS_ASSERT_EQUALS(targetTable->columnCount(), numberOfColumns); + TS_ASSERT_EQUALS(targetTable->rowCount(), numberOfRows * 2); + + for (size_t rowIndex = 0; rowIndex < numberOfRows * 2; ++rowIndex) { + std::cout << "ROW " << rowIndex << "\n"; + API::TableRow row = targetTable->getRow(rowIndex); + const double expectedX = static_cast<double>(rowIndex) * 3 + 1; + const double expectedY = static_cast<double>(rowIndex) * 3 + 2; + const double expectedZ = static_cast<double>(rowIndex) * 3 + 3; + + // x, y and z must be initialized to keep RHEL7 happy + auto x = expectedX + 1; + auto y = expectedY + 1; + auto z = expectedZ + 1; + + TS_ASSERT_THROWS_NOTHING(row >> x >> y >> z); + TS_ASSERT_EQUALS(x, expectedX); + TS_ASSERT_EQUALS(y, expectedY); + TS_ASSERT_EQUALS(z, expectedZ); + } + } + + void test_removeRun() { + auto model = EnggDiffFittingModelAddWSExposed(); + + const RunLabel label1("123", 1); + addSampleWorkspaceToModel(label1, model); + const RunLabel label2("456", 2); + addSampleWorkspaceToModel(label2, model); + const RunLabel label3("789", 1); + addSampleWorkspaceToModel(label3, model); + + model.removeRun(label1); + + const auto runLabels = model.getRunLabels(); + TS_ASSERT_EQUALS(runLabels.size(), 2); + + TS_ASSERT_EQUALS(runLabels[0], label2); + TS_ASSERT_EQUALS(runLabels[1], label3); + } + +private: + const static std::string FOCUSED_WS_FILENAME; + const static RunLabel FOCUSED_WS_RUN_LABEL; +}; + +const std::string EnggDiffFittingModelTest::FOCUSED_WS_FILENAME = + "ENGINX_277208_focused_bank_2.nxs"; + +const RunLabel EnggDiffFittingModelTest::FOCUSED_WS_RUN_LABEL = + RunLabel("277208", 2); diff --git a/qt/scientific_interfaces/test/EnggDiffFittingPresenterTest.h b/qt/scientific_interfaces/test/EnggDiffFittingPresenterTest.h new file mode 100644 index 0000000000000000000000000000000000000000..94f569ca36d0d8658c7e2b8a4a33d9d85180014a --- /dev/null +++ b/qt/scientific_interfaces/test/EnggDiffFittingPresenterTest.h @@ -0,0 +1,764 @@ +// Mantid Repository : https://github.com/mantidproject/mantid +// +// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI, +// NScD Oak Ridge National Laboratory, European Spallation Source +// & Institut Laue - Langevin +// SPDX - License - Identifier: GPL - 3.0 + +#pragma once + +#include "../EnggDiffraction/EnggDiffFittingPresenter.h" +#include "MantidAPI/FrameworkManager.h" + +#include "MantidTestHelpers/WorkspaceCreationHelper.h" + +#include "EnggDiffFittingModelMock.h" +#include "EnggDiffFittingViewMock.h" +#include "EnggDiffractionParamMock.h" +#include <cxxtest/TestSuite.h> +#include <utility> + +#include <vector> + +using namespace MantidQt::CustomInterfaces; +using testing::Return; +using testing::ReturnRef; +using testing::TypedEq; + +// Use this mocked presenter for tests that will start the focusing +// workers/threads. Otherwise you'll run into trouble with issues like +// "QEventLoop: Cannot be used without QApplication", as there is not +// Qt application here and the normal Qt thread used by the presenter +// uses signals/slots. +class EnggDiffFittingPresenterNoThread : public EnggDiffFittingPresenter { +public: + EnggDiffFittingPresenterNoThread(IEnggDiffFittingView *view) + : EnggDiffFittingPresenterNoThread( + view, + std::make_unique<testing::NiceMock<MockEnggDiffFittingModel>>()) {} + + EnggDiffFittingPresenterNoThread(IEnggDiffFittingView *view, + std::unique_ptr<IEnggDiffFittingModel> model) + : EnggDiffFittingPresenter(view, std::move(model), nullptr, nullptr) {} + + EnggDiffFittingPresenterNoThread( + IEnggDiffFittingView *view, std::unique_ptr<IEnggDiffFittingModel> model, + boost::shared_ptr<IEnggDiffractionParam> mainParam) + : EnggDiffFittingPresenter(view, std::move(model), nullptr, + std::move(mainParam)) {} + +private: + // not async at all + void startAsyncFittingWorker(const std::vector<RunLabel> &runLabels, + const std::string &ExpectedPeaks) override { + assert(runLabels.size() == 1); + doFitting(runLabels, ExpectedPeaks); + fittingFinished(); + } +}; + +class EnggDiffFittingPresenterTest : public CxxTest::TestSuite { + +public: + // This pair of boilerplate methods prevent tghe suite being created + // statically + // This means the constructor isn't called when running other tests + static EnggDiffFittingPresenterTest *createSuite() { + return new EnggDiffFittingPresenterTest(); + } + + static void destroySuite(EnggDiffFittingPresenterTest *suite) { + delete suite; + } + + EnggDiffFittingPresenterTest() { + Mantid::API::FrameworkManager::Instance(); // make sure framework is + // initialized + } + + void setUp() override { + m_view.reset(new testing::NiceMock<MockEnggDiffFittingView>()); + auto mockModel = + std::make_unique<testing::NiceMock<MockEnggDiffFittingModel>>(); + + m_presenter.reset(new MantidQt::CustomInterfaces::EnggDiffFittingPresenter( + m_view.get(), std::move(mockModel), nullptr, nullptr)); + + // default banks + m_ex_enginx_banks.emplace_back(true); + m_ex_enginx_banks.emplace_back(false); + + // default run number + m_ex_empty_run_num.emplace_back(""); + m_invalid_run_number.emplace_back(""); + m_ex_run_number.emplace_back(g_validRunNo); + g_vanNo.emplace_back("8899999988"); + g_ceriaNo.emplace_back("9999999999"); + + // provide personal directories in order to carry out the full disable tests + m_basicCalibSettings.m_inputDirCalib = "GUI_calib_folder/"; + m_basicCalibSettings.m_inputDirRaw = "GUI_calib_folder/"; + + m_basicCalibSettings.m_pixelCalibFilename = + "ENGINX_full_pixel_calibration.csv"; + + m_basicCalibSettings.m_templateGSAS_PRM = "GUI_calib_folder/" + "template_ENGINX_241391_236516_" + "North_and_South_banks.prm"; + + m_basicCalibSettings.m_forceRecalcOverwrite = false; + m_basicCalibSettings.m_rebinCalibrate = 1; + } + + void tearDown() override { + TS_ASSERT(testing::Mock::VerifyAndClearExpectations(m_view.get())); + } + + void test_load_with_missing_param() { + testing::NiceMock<MockEnggDiffFittingView> mockView; + auto mockModel = + std::make_unique<testing::NiceMock<MockEnggDiffFittingModel>>(); + auto *mockModel_ptr = mockModel.get(); + MantidQt::CustomInterfaces::EnggDiffFittingPresenter pres( + &mockView, std::move(mockModel), nullptr, nullptr); + + EXPECT_CALL(mockView, getFocusedFileNames()).Times(1).WillOnce(Return("")); + + EXPECT_CALL(mockView, userWarning(testing::_, testing::_)).Times(1); + EXPECT_CALL(mockView, userError(testing::_, testing::_)).Times(0); + + // Should never get as far as trying to load + EXPECT_CALL(*mockModel_ptr, loadWorkspaces(testing::_)).Times(0); + + pres.notify(IEnggDiffFittingPresenter::Load); + TSM_ASSERT( + "View mock not used as expected. Some EXPECT_CALL conditions were not " + "satisfied.", + testing::Mock::VerifyAndClearExpectations(&mockView)) + TSM_ASSERT( + "Model mock not used as expected. Some EXPECT_CALL conditions were not " + "satisfied.", + testing::Mock::VerifyAndClearExpectations(mockModel_ptr)) + } + + void test_fitting_with_missing_param() { + testing::NiceMock<MockEnggDiffFittingView> mockView; + auto mockModel = + std::make_unique<testing::NiceMock<MockEnggDiffFittingModel>>(); + MantidQt::CustomInterfaces::EnggDiffFittingPresenter pres( + &mockView, std::move(mockModel), nullptr, nullptr); + + EXPECT_CALL(mockView, getFittingListWidgetCurrentValue()) + .Times(1) + .WillOnce(Return(boost::none)); + + // should not get to the point where the status is updated + EXPECT_CALL(mockView, setPeakList(testing::_)).Times(0); + EXPECT_CALL(mockView, showStatus(testing::_)).Times(0); + + // No errors/1 warnings. There will be an error log from the algorithms + EXPECT_CALL(mockView, userError(testing::_, testing::_)).Times(0); + EXPECT_CALL(mockView, userWarning(testing::_, testing::_)).Times(1); + + pres.notify(IEnggDiffFittingPresenter::FitPeaks); + TSM_ASSERT( + "Mock not used as expected. Some EXPECT_CALL conditions were not " + "satisfied.", + testing::Mock::VerifyAndClearExpectations(&mockView)) + } + + // This would test the fitting tab with no focused workspace + // which should produce a warning + void test_fitting_without_focused_run() { + testing::NiceMock<MockEnggDiffFittingView> mockView; + EnggDiffFittingPresenterNoThread pres(&mockView); + + // inputs from user + EXPECT_CALL(mockView, getFittingListWidgetCurrentValue()) + .Times(1) + .WillOnce(Return(boost::none)); + + // should not get to the point where the status is updated + EXPECT_CALL(mockView, setPeakList(testing::_)).Times(0); + EXPECT_CALL(mockView, showStatus(testing::_)).Times(0); + + // No errors/1 warnings. There will be an error log from the algorithms + EXPECT_CALL(mockView, userError(testing::_, testing::_)).Times(0); + EXPECT_CALL(mockView, userWarning(testing::_, testing::_)).Times(1); + + pres.notify(IEnggDiffFittingPresenter::FitPeaks); + TSM_ASSERT( + "Mock not used as expected. Some EXPECT_CALL conditions were not " + "satisfied.", + testing::Mock::VerifyAndClearExpectations(&mockView)) + } + + // This would test the fitting tab with invalid expected peaks but should only + // produce a warning + void test_fitting_with_invalid_expected_peaks() { + testing::NiceMock<MockEnggDiffFittingView> mockView; + auto mockModel = + std::make_unique<testing::NiceMock<MockEnggDiffFittingModel>>(); + auto *mockModel_ptr = mockModel.get(); + + EnggDiffFittingPresenterNoThread pres(&mockView, std::move(mockModel)); + + EXPECT_CALL(mockView, getFittingListWidgetCurrentValue()) + .Times(1) + .WillOnce(Return(boost::optional<std::string>( + boost::optional<std::string>("123_1")))); + EXPECT_CALL(*mockModel_ptr, getWorkspaceFilename(testing::_)) + .Times(1) + .WillOnce(ReturnRef(EMPTY)); + + EXPECT_CALL(mockView, getExpectedPeaksInput()) + .Times(1) + .WillOnce(Return(",3.5,7.78,r43d")); + EXPECT_CALL(mockView, setPeakList(testing::_)).Times(1); + + // should not get to the point where the status is updated + EXPECT_CALL(mockView, showStatus(testing::_)).Times(0); + + // No errors/1 warnings. There will be an error log from the algorithms + EXPECT_CALL(mockView, userError(testing::_, testing::_)).Times(0); + EXPECT_CALL(mockView, userWarning(testing::_, testing::_)).Times(1); + + pres.notify(IEnggDiffFittingPresenter::FitPeaks); + TSM_ASSERT( + "View mock not used as expected. Some EXPECT_CALL conditions were not " + "satisfied.", + testing::Mock::VerifyAndClearExpectations(&mockView)) + TSM_ASSERT( + "Model mock not used as expected. Some EXPECT_CALL conditions were not " + "satisfied.", + testing::Mock::VerifyAndClearExpectations(mockModel_ptr)) + } + + // Fit All Peaks test begin here + void test_fit_all_runno_valid_single_run() { + testing::NiceMock<MockEnggDiffFittingView> mockView; + auto mockModel = + std::make_unique<testing::NiceMock<MockEnggDiffFittingModel>>(); + auto *mockModel_ptr = mockModel.get(); + + EnggDiffFittingPresenterNoThread pres(&mockView, std::move(mockModel)); + + EXPECT_CALL(mockView, getExpectedPeaksInput()) + .Times(1) + .WillOnce(Return("2.3445,3.3433,4.5664")); + + const RunLabel runLabel("123", 1); + EXPECT_CALL(*mockModel_ptr, getRunLabels()) + .Times(1) + .WillOnce(Return(std::vector<RunLabel>({runLabel}))); + + EXPECT_CALL(*mockModel_ptr, getWorkspaceFilename(runLabel)) + .Times(1) + .WillOnce(ReturnRef(EMPTY)); + + EXPECT_CALL(mockView, setPeakList(testing::_)).Times(1); + + EXPECT_CALL(mockView, enableFitAllButton(testing::_)).Times(0); + + // should not get to the point where the status is updated + EXPECT_CALL(mockView, showStatus(testing::_)).Times(0); + + // No errors/1 warnings. There will be an error log because dir vector + // is empty + EXPECT_CALL(mockView, userError(testing::_, testing::_)).Times(0); + EXPECT_CALL(mockView, userWarning(testing::_, testing::_)).Times(1); + + pres.notify(IEnggDiffFittingPresenter::FitAllPeaks); + } + + // This would test the fitting tab with invalid expected peaks but should only + // produce a warning + void test_fit_all_with_invalid_expected_peaks() { + testing::NiceMock<MockEnggDiffFittingView> mockView; + auto mockModel = + std::make_unique<testing::NiceMock<MockEnggDiffFittingModel>>(); + auto *mockModel_ptr = mockModel.get(); + + EnggDiffFittingPresenterNoThread pres(&mockView, std::move(mockModel)); + + // inputs from user + EXPECT_CALL(mockView, getExpectedPeaksInput()) + .Times(1) + .WillOnce(Return(",3.5,7.78,r43d")); + EXPECT_CALL(mockView, setPeakList(testing::_)).Times(1); + + const RunLabel runLabel("123", 1); + EXPECT_CALL(*mockModel_ptr, getRunLabels()) + .Times(1) + .WillOnce(Return(std::vector<RunLabel>({runLabel}))); + + EXPECT_CALL(*mockModel_ptr, getWorkspaceFilename(runLabel)) + .Times(1) + .WillOnce(ReturnRef(EMPTY)); + + // should not get to the point where the status is updated + EXPECT_CALL(mockView, showStatus(testing::_)).Times(0); + + // No errors/1 warnings. There will be an error log from the algorithms + EXPECT_CALL(mockView, userError(testing::_, testing::_)).Times(0); + EXPECT_CALL(mockView, userWarning(testing::_, testing::_)).Times(1); + + pres.notify(IEnggDiffFittingPresenter::FitAllPeaks); + TSM_ASSERT( + "Mock not used as expected. Some EXPECT_CALL conditions were not " + "satisfied.", + testing::Mock::VerifyAndClearExpectations(&mockView)) + } + + void test_browse_peaks_list() { + testing::NiceMock<MockEnggDiffFittingView> mockView; + const auto paramMock = + boost::make_shared<testing::NiceMock<MockEnggDiffractionParam>>(); + EnggDiffFittingPresenterNoThread pres( + &mockView, + std::make_unique<testing::NiceMock<MockEnggDiffFittingModel>>(), + paramMock); + + const auto &userDir(Poco::Path::home()); + EXPECT_CALL(*paramMock, outFilesUserDir("")) + .Times(1) + .WillOnce(Return(userDir)); + + EXPECT_CALL(mockView, getOpenFile(userDir)).Times(1); + + EXPECT_CALL(mockView, getSaveFile(testing::_)).Times(0); + + // No errors/0 warnings. + EXPECT_CALL(mockView, userError(testing::_, testing::_)).Times(0); + EXPECT_CALL(mockView, userWarning(testing::_, testing::_)).Times(0); + + pres.notify(IEnggDiffFittingPresenter::browsePeaks); + TSM_ASSERT( + "Mock not used as expected. Some EXPECT_CALL conditions were not " + "satisfied.", + testing::Mock::VerifyAndClearExpectations(&mockView)) + } + + void test_browse_peaks_list_with_warning() { + testing::NiceMock<MockEnggDiffFittingView> mockView; + const auto paramMock = + boost::make_shared<testing::NiceMock<MockEnggDiffractionParam>>(); + EnggDiffFittingPresenterNoThread pres( + &mockView, + std::make_unique<testing::NiceMock<MockEnggDiffFittingModel>>(), + paramMock); + + const auto &userDir(Poco::Path::home()); + EXPECT_CALL(*paramMock, outFilesUserDir("")) + .Times(1) + .WillOnce(Return(userDir)); + + std::string dummyDir = "I/am/a/dummy/directory"; + + EXPECT_CALL(mockView, getOpenFile(userDir)) + .Times(1) + .WillOnce(Return(dummyDir)); + + EXPECT_CALL(mockView, setPreviousDir(dummyDir)).Times(1); + + EXPECT_CALL(mockView, setPeakList(testing::_)).Times(1); + + // No errors/0 warnings. + EXPECT_CALL(mockView, userError(testing::_, testing::_)).Times(0); + EXPECT_CALL(mockView, userWarning(testing::_, testing::_)).Times(0); + + pres.notify(IEnggDiffFittingPresenter::browsePeaks); + TSM_ASSERT( + "Mock not used as expected. Some EXPECT_CALL conditions were not " + "satisfied.", + testing::Mock::VerifyAndClearExpectations(&mockView)) + } + + void test_save_peaks_list() { + testing::NiceMock<MockEnggDiffFittingView> mockView; + const auto paramMock = + boost::make_shared<testing::NiceMock<MockEnggDiffractionParam>>(); + EnggDiffFittingPresenterNoThread pres( + &mockView, + std::make_unique<testing::NiceMock<MockEnggDiffFittingModel>>(), + paramMock); + + const auto &userDir(Poco::Path::home()); + EXPECT_CALL(*paramMock, outFilesUserDir("")) + .Times(1) + .WillOnce(Return(userDir)); + + EXPECT_CALL(mockView, getSaveFile(userDir)).Times(1); + + // No errors/No warnings. + EXPECT_CALL(mockView, userError(testing::_, testing::_)).Times(0); + EXPECT_CALL(mockView, userWarning(testing::_, testing::_)).Times(0); + + pres.notify(IEnggDiffFittingPresenter::savePeaks); + TSM_ASSERT( + "Mock not used as expected. Some EXPECT_CALL conditions were not " + "satisfied.", + testing::Mock::VerifyAndClearExpectations(&mockView)) + } + + void test_save_peaks_list_with_warning() { + testing::NiceMock<MockEnggDiffFittingView> mockView; + const auto paramMock = + boost::make_shared<testing::NiceMock<MockEnggDiffractionParam>>(); + EnggDiffFittingPresenterNoThread pres( + &mockView, + std::make_unique<testing::NiceMock<MockEnggDiffFittingModel>>(), + paramMock); + + const auto &userDir(Poco::Path::home()); + EXPECT_CALL(*paramMock, outFilesUserDir("")) + .Times(1) + .WillOnce(Return(userDir)); + + std::string dummyDir = "/dummy/directory/"; + EXPECT_CALL(mockView, getSaveFile(userDir)) + .Times(1) + .WillOnce(Return(dummyDir)); + + EXPECT_CALL(mockView, getExpectedPeaksInput()).Times(0); + + // No errors/1 warnings. Dummy file entered is not found + EXPECT_CALL(mockView, userError(testing::_, testing::_)).Times(0); + EXPECT_CALL(mockView, userWarning(testing::_, testing::_)).Times(1); + + pres.notify(IEnggDiffFittingPresenter::savePeaks); + TSM_ASSERT( + "Mock not used as expected. Some EXPECT_CALL conditions were not " + "satisfied.", + testing::Mock::VerifyAndClearExpectations(&mockView)) + } + + void test_add_peaks_to_empty_list() { + + testing::NiceMock<MockEnggDiffFittingView> mockView; + EnggDiffFittingPresenterNoThread pres(&mockView); + + EXPECT_CALL(mockView, peakPickerEnabled()).Times(1).WillOnce(Return(true)); + + EXPECT_CALL(mockView, getPeakCentre()).Times(1); + + EXPECT_CALL(mockView, getExpectedPeaksInput()) + .Times(1) + .WillOnce(Return("")); + ; + + EXPECT_CALL(mockView, setPeakList(testing::_)).Times(1); + + // should not be updating the status + EXPECT_CALL(mockView, showStatus(testing::_)).Times(0); + + // No errors/0 warnings. + EXPECT_CALL(mockView, userError(testing::_, testing::_)).Times(0); + EXPECT_CALL(mockView, userWarning(testing::_, testing::_)).Times(0); + + pres.notify(IEnggDiffFittingPresenter::addPeaks); + TSM_ASSERT( + "Mock not used as expected. Some EXPECT_CALL conditions were not " + "satisfied.", + testing::Mock::VerifyAndClearExpectations(&mockView)) + } + + void test_add_peaks_with_disabled_peak_picker() { + + testing::NiceMock<MockEnggDiffFittingView> mockView; + EnggDiffFittingPresenterNoThread pres(&mockView); + + EXPECT_CALL(mockView, peakPickerEnabled()).Times(1).WillOnce(Return(false)); + + EXPECT_CALL(mockView, getPeakCentre()).Times(0); + + EXPECT_CALL(mockView, getExpectedPeaksInput()).Times(0); + + EXPECT_CALL(mockView, setPeakList(testing::_)).Times(0); + + // should not be updating the status + EXPECT_CALL(mockView, showStatus(testing::_)).Times(0); + + // No errors/0 warnings. + EXPECT_CALL(mockView, userError(testing::_, testing::_)).Times(0); + EXPECT_CALL(mockView, userWarning(testing::_, testing::_)).Times(0); + + pres.notify(IEnggDiffFittingPresenter::addPeaks); + TSM_ASSERT( + "Mock not used as expected. Some EXPECT_CALL conditions were not " + "satisfied.", + testing::Mock::VerifyAndClearExpectations(&mockView)) + } + + void test_add_valid_peaks_to_list_with_comma() { + + testing::NiceMock<MockEnggDiffFittingView> mockView; + EnggDiffFittingPresenterNoThread pres(&mockView); + + EXPECT_CALL(mockView, peakPickerEnabled()).Times(1).WillOnce(Return(true)); + + EXPECT_CALL(mockView, getPeakCentre()).Times(1).WillOnce(Return(2.0684)); + + EXPECT_CALL(mockView, getExpectedPeaksInput()) + .Times(1) + .WillOnce(Return("1.7906,2.0684,1.2676,")); + + EXPECT_CALL(mockView, setPeakList("1.7906,2.0684,1.2676,2.0684")).Times(1); + + // No errors/0 warnings. + EXPECT_CALL(mockView, userError(testing::_, testing::_)).Times(0); + EXPECT_CALL(mockView, userWarning(testing::_, testing::_)).Times(0); + + pres.notify(IEnggDiffFittingPresenter::addPeaks); + TSM_ASSERT( + "Mock not used as expected. Some EXPECT_CALL conditions were not " + "satisfied.", + testing::Mock::VerifyAndClearExpectations(&mockView)) + } + + void test_add_customised_valid_peaks_to_list_without_comma() { + + testing::NiceMock<MockEnggDiffFittingView> mockView; + EnggDiffFittingPresenterNoThread pres(&mockView); + + EXPECT_CALL(mockView, peakPickerEnabled()).Times(1).WillOnce(Return(true)); + + EXPECT_CALL(mockView, getPeakCentre()).Times(1).WillOnce(Return(3.0234)); + + EXPECT_CALL(mockView, getExpectedPeaksInput()) + .Times(1) + .WillOnce(Return("2.0684,1.2676")); + + EXPECT_CALL(mockView, setPeakList("2.0684,1.2676,3.0234")).Times(1); + + // should not be updating the status + EXPECT_CALL(mockView, showStatus(testing::_)).Times(0); + + // No errors/0 warnings. + EXPECT_CALL(mockView, userError(testing::_, testing::_)).Times(0); + EXPECT_CALL(mockView, userWarning(testing::_, testing::_)).Times(0); + + pres.notify(IEnggDiffFittingPresenter::addPeaks); + TSM_ASSERT( + "Mock not used as expected. Some EXPECT_CALL conditions were not " + "satisfied.", + testing::Mock::VerifyAndClearExpectations(&mockView)) + } + + void test_add_invalid_peaks_to_list() { + + testing::NiceMock<MockEnggDiffFittingView> mockView; + EnggDiffFittingPresenterNoThread pres(&mockView); + + EXPECT_CALL(mockView, peakPickerEnabled()).Times(1).WillOnce(Return(true)); + + EXPECT_CALL(mockView, getPeakCentre()).Times(1).WillOnce(Return(0.0133)); + + EXPECT_CALL(mockView, getExpectedPeaksInput()) + .Times(1) + .WillOnce(Return("")); + + // string should be "0.133," instead + EXPECT_CALL(mockView, setPeakList("0.0133")).Times(0); + EXPECT_CALL(mockView, setPeakList(",0.0133")).Times(0); + EXPECT_CALL(mockView, setPeakList("0.0133,")).Times(1); + + // No errors/0 warnings. File entered is not found + EXPECT_CALL(mockView, userError(testing::_, testing::_)).Times(0); + EXPECT_CALL(mockView, userWarning(testing::_, testing::_)).Times(0); + + pres.notify(IEnggDiffFittingPresenter::addPeaks); + TSM_ASSERT( + "Mock not used as expected. Some EXPECT_CALL conditions were not " + "satisfied.", + testing::Mock::VerifyAndClearExpectations(&mockView)) + } + + void test_shutDown() { + testing::NiceMock<MockEnggDiffFittingView> mockView; + MantidQt::CustomInterfaces::EnggDiffFittingPresenter pres( + &mockView, + std::make_unique<testing::NiceMock<MockEnggDiffFittingModel>>(), + nullptr, nullptr); + + EXPECT_CALL(mockView, setPeakList(testing::_)).Times(0); + EXPECT_CALL(mockView, getFocusedFileNames()).Times(0); + EXPECT_CALL(mockView, getFittingRunNumVec()).Times(0); + + EXPECT_CALL(mockView, getFittingMultiRunMode()).Times(0); + + EXPECT_CALL(mockView, showStatus(testing::_)).Times(0); + + EXPECT_CALL(mockView, saveSettings()).Times(1); + // No errors, no warnings + EXPECT_CALL(mockView, userError(testing::_, testing::_)).Times(0); + EXPECT_CALL(mockView, userWarning(testing::_, testing::_)).Times(0); + + pres.notify(IEnggDiffFittingPresenter::ShutDown); + TSM_ASSERT( + "Mock not used as expected. Some EXPECT_CALL conditions were not " + "satisfied.", + testing::Mock::VerifyAndClearExpectations(&mockView)) + } + + void test_removeRun() { + testing::NiceMock<MockEnggDiffFittingView> mockView; + auto mockModel = + std::make_unique<testing::NiceMock<MockEnggDiffFittingModel>>(); + auto *mockModel_ptr = mockModel.get(); + MantidQt::CustomInterfaces::EnggDiffFittingPresenter pres( + &mockView, std::move(mockModel), nullptr, nullptr); + + EXPECT_CALL(mockView, getFittingListWidgetCurrentValue()) + .Times(1) + .WillOnce(Return(boost::optional<std::string>("123_1"))); + EXPECT_CALL(*mockModel_ptr, removeRun(RunLabel("123", 1))); + EXPECT_CALL(*mockModel_ptr, getRunLabels()) + .Times(1) + .WillOnce(Return( + std::vector<RunLabel>({RunLabel("123", 2), RunLabel("456", 1)}))); + EXPECT_CALL(mockView, updateFittingListWidget( + std::vector<std::string>({"123_2", "456_1"}))); + + pres.notify(IEnggDiffFittingPresenter::removeRun); + + TSM_ASSERT( + "Mock not used as expected. Some EXPECT_CALL conditions were not " + "satisfied.", + testing::Mock::VerifyAndClearExpectations(&mockView)) + } + + void test_updatePlotFittedPeaksValidFittedPeaks() { + testing::NiceMock<MockEnggDiffFittingView> mockView; + auto mockModel = + std::make_unique<testing::NiceMock<MockEnggDiffFittingModel>>(); + auto *mockModel_ptr = mockModel.get(); + + EnggDiffFittingPresenterNoThread pres(&mockView, std::move(mockModel)); + + const RunLabel runLabel("123", 1); + EXPECT_CALL(mockView, getFittingListWidgetCurrentValue()) + .Times(2) + .WillRepeatedly(Return(boost::optional<std::string>("123_1"))); + EXPECT_CALL(*mockModel_ptr, hasFittedPeaksForRun(runLabel)) + .Times(1) + .WillOnce(Return(true)); + EXPECT_CALL(*mockModel_ptr, getAlignedWorkspace(runLabel)) + .Times(1) + .WillOnce(Return(WorkspaceCreationHelper::create2DWorkspace(10, 10))); + EXPECT_CALL(mockView, plotFittedPeaksEnabled()) + .Times(1) + .WillOnce(Return(true)); + EXPECT_CALL(*mockModel_ptr, getFittedPeaksWS(runLabel)) + .Times(1) + .WillOnce(Return(WorkspaceCreationHelper::create2DWorkspace(10, 10))); + EXPECT_CALL(mockView, + setDataVector(testing::_, testing::_, testing::_, testing::_)) + .Times(2); + + pres.notify(IEnggDiffFittingPresenter::updatePlotFittedPeaks); + TSM_ASSERT( + "Mock not used as expected. Some EXPECT_CALL conditions were not " + "satisfied.", + testing::Mock::VerifyAndClearExpectations(&mockView)) + } + + void test_updatePlotFittedPeaksNoFittedPeaks() { + testing::NiceMock<MockEnggDiffFittingView> mockView; + auto mockModel = + std::make_unique<testing::NiceMock<MockEnggDiffFittingModel>>(); + auto *mockModel_ptr = mockModel.get(); + + EnggDiffFittingPresenterNoThread pres(&mockView, std::move(mockModel)); + + const RunLabel runLabel("123", 1); + EXPECT_CALL(mockView, getFittingListWidgetCurrentValue()) + .Times(1) + .WillOnce(Return(boost::optional<std::string>("123_1"))); + EXPECT_CALL(*mockModel_ptr, hasFittedPeaksForRun(runLabel)) + .Times(1) + .WillOnce(Return(false)); + EXPECT_CALL(*mockModel_ptr, getFocusedWorkspace(runLabel)) + .Times(1) + .WillOnce(Return(WorkspaceCreationHelper::create2DWorkspace(10, 10))); + EXPECT_CALL(mockView, plotFittedPeaksEnabled()) + .Times(1) + .WillOnce(Return(true)); + EXPECT_CALL(*mockModel_ptr, getFittedPeaksWS(runLabel)).Times(0); + EXPECT_CALL(mockView, + setDataVector(testing::_, testing::_, testing::_, testing::_)) + .Times(1); + EXPECT_CALL(mockView, userWarning("Cannot plot fitted peaks", testing::_)) + .Times(1); + + pres.notify(IEnggDiffFittingPresenter::updatePlotFittedPeaks); + TSM_ASSERT( + "Mock not used as expected. Some EXPECT_CALL conditions were not " + "satisfied.", + testing::Mock::VerifyAndClearExpectations(&mockView)) + } + + void test_updatePlotSuccessfulFitPlotPeaksDisabled() { + testing::NiceMock<MockEnggDiffFittingView> mockView; + auto mockModel = + std::make_unique<testing::NiceMock<MockEnggDiffFittingModel>>(); + auto *mockModel_ptr = mockModel.get(); + + EnggDiffFittingPresenterNoThread pres(&mockView, std::move(mockModel)); + + const RunLabel runLabel("123", 1); + EXPECT_CALL(mockView, getFittingListWidgetCurrentValue()) + .Times(2) + .WillRepeatedly(Return(boost::optional<std::string>("123_1"))); + EXPECT_CALL(*mockModel_ptr, hasFittedPeaksForRun(runLabel)) + .Times(1) + .WillOnce(Return(true)); + EXPECT_CALL(*mockModel_ptr, getAlignedWorkspace(runLabel)) + .Times(1) + .WillOnce(Return(WorkspaceCreationHelper::create2DWorkspace(10, 10))); + EXPECT_CALL(mockView, plotFittedPeaksEnabled()) + .Times(1) + .WillOnce(Return(false)); + EXPECT_CALL(*mockModel_ptr, getFittedPeaksWS(runLabel)).Times(0); + EXPECT_CALL(mockView, + setDataVector(testing::_, testing::_, testing::_, testing::_)) + .Times(1); + + pres.notify(IEnggDiffFittingPresenter::updatePlotFittedPeaks); + TSM_ASSERT( + "Mock not used as expected. Some EXPECT_CALL conditions were not " + "satisfied.", + testing::Mock::VerifyAndClearExpectations(&mockView)) + } + +private: + std::unique_ptr<testing::NiceMock<MockEnggDiffFittingView>> m_view; + std::unique_ptr<MantidQt::CustomInterfaces::EnggDiffFittingPresenter> + m_presenter; + + std::vector<bool> m_ex_enginx_banks; + const static std::string g_validRunNo; + const static std::string g_focusedRun; + const static std::string g_focusedBankFile; + const static std::string g_focusedFittingRunNo; + const static std::string EMPTY; + EnggDiffCalibSettings m_basicCalibSettings; + + std::vector<std::string> m_ex_empty_run_num; + std::vector<std::string> m_invalid_run_number; + std::vector<std::string> m_ex_run_number; + std::vector<std::string> g_vanNo; + std::vector<std::string> g_ceriaNo; +}; + +const std::string EnggDiffFittingPresenterTest::g_focusedRun = + "focused_texture_bank_1"; + +const std::string EnggDiffFittingPresenterTest::g_validRunNo = "228061"; + +const std::string EnggDiffFittingPresenterTest::g_focusedBankFile = + "ENGINX_241395_focused_texture_bank_1"; + +const std::string EnggDiffFittingPresenterTest::g_focusedFittingRunNo = + "241391-241394"; + +const std::string EnggDiffFittingPresenterTest::EMPTY = ""; diff --git a/qt/scientific_interfaces/test/EnggDiffGSASFittingModelTest.h b/qt/scientific_interfaces/test/EnggDiffGSASFittingModelTest.h new file mode 100644 index 0000000000000000000000000000000000000000..245b8b7b1a4561ffff018192125fedab73ea7b28 --- /dev/null +++ b/qt/scientific_interfaces/test/EnggDiffGSASFittingModelTest.h @@ -0,0 +1,289 @@ +// Mantid Repository : https://github.com/mantidproject/mantid +// +// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI, +// NScD Oak Ridge National Laboratory, European Spallation Source +// & Institut Laue - Langevin +// SPDX - License - Identifier: GPL - 3.0 + +#pragma once + +#include "../EnggDiffraction/EnggDiffGSASFittingModel.h" + +#include "MantidAPI/AlgorithmManager.h" +#include "MantidAPI/AnalysisDataService.h" +#include "MantidAPI/FrameworkManager.h" +#include "MantidAPI/TableRow.h" +#include "MantidAPI/WorkspaceFactory.h" +#include "MantidTestHelpers/WorkspaceCreationHelper.h" + +#include <cxxtest/TestSuite.h> + +#include <utility> + +using namespace Mantid; +using namespace MantidQt::CustomInterfaces; + +namespace { // Helpers + +std::vector<GSASIIRefineFitPeaksParameters> +createGSASIIRefineFitPeaksParameters( + const API::MatrixWorkspace_sptr &inputWS, const RunLabel &runLabel, + const GSASRefinementMethod &refinementMethod) { + return {GSASIIRefineFitPeaksParameters( + inputWS, runLabel, refinementMethod, "", std::vector<std::string>({}), "", + "", boost::none, boost::none, boost::none, boost::none, false, false)}; +} + +template <size_t numColumns, size_t numRows> +API::ITableWorkspace_sptr createDummyTable( + const std::array<std::string, numColumns> &columnHeadings, + const std::array<std::array<double, numColumns>, numRows> tableContents) { + auto table = API::WorkspaceFactory::Instance().createTable(); + for (const auto &header : columnHeadings) { + table->addColumn("double", header); + } + for (const auto &row : tableContents) { + API::TableRow newRow = table->appendRow(); + for (const auto value : row) { + newRow << value; + } + } + return table; +} + +// Helper class with some protected methods exposed +class TestEnggDiffGSASFittingModel : public EnggDiffGSASFittingModel { +public: + void addGammaValue(const RunLabel &runLabel, const double gamma); + + void addLatticeParamTable(const RunLabel &runLabel, + const API::ITableWorkspace_sptr &table); + + void addRwpValue(const RunLabel &runLabel, const double rwp); + + void addSigmaValue(const RunLabel &runLabel, const double sigma); + + void doRefinements( + const std::vector<GSASIIRefineFitPeaksParameters> ¶ms) override; +}; + +inline void +TestEnggDiffGSASFittingModel::addGammaValue(const RunLabel &runLabel, + const double gamma) { + addGamma(runLabel, gamma); +} + +inline void TestEnggDiffGSASFittingModel::addLatticeParamTable( + const RunLabel &runLabel, const API::ITableWorkspace_sptr &table) { + addLatticeParams(runLabel, std::move(table)); +} + +inline void TestEnggDiffGSASFittingModel::addRwpValue(const RunLabel &runLabel, + const double rwp) { + addRwp(runLabel, rwp); +} + +inline void +TestEnggDiffGSASFittingModel::addSigmaValue(const RunLabel &runLabel, + const double sigma) { + addSigma(runLabel, sigma); +} + +void TestEnggDiffGSASFittingModel::doRefinements( + const std::vector<GSASIIRefineFitPeaksParameters> ¶ms) { + // Mock method - just create some dummy output and ignore all the parameters + UNUSED_ARG(params); + + const static std::array<std::string, 3> columnHeadings = {{"a", "b", "c"}}; + const static std::array<std::array<double, 3>, 1> targetTableValues = { + {{{1, 2, 3}}}}; + const auto latticeParams = + createDummyTable(columnHeadings, targetTableValues); + + API::AnalysisDataServiceImpl &ADS = API::AnalysisDataService::Instance(); + ADS.add("LATTICEPARAMS", latticeParams); + + API::MatrixWorkspace_sptr ws = + WorkspaceCreationHelper::create2DWorkspaceBinned(4, 4, 0.5); + ADS.add("FITTEDPEAKS", ws); + + processRefinementSuccessful( + nullptr, GSASIIRefineFitPeaksOutputProperties(1, 2, 3, ws, latticeParams, + params[0].runLabel)); +} + +} // Anonymous namespace + +class EnggDiffGSASFittingModelTest : public CxxTest::TestSuite { +public: + // This pair of boilerplate methods prevent the suite being created statically + // This means the constructor isn't called when running other tests + static EnggDiffGSASFittingModelTest *createSuite() { + return new EnggDiffGSASFittingModelTest(); + } + static void destroySuite(EnggDiffGSASFittingModelTest *suite) { + delete suite; + } + + EnggDiffGSASFittingModelTest() { API::FrameworkManager::Instance(); } + + void test_validLoadRun() { + const static std::string inputFilename = "ENGINX_277208_focused_bank_2.nxs"; + TestEnggDiffGSASFittingModel model; + + API::MatrixWorkspace_sptr ws; + TS_ASSERT_THROWS_NOTHING(ws = model.loadFocusedRun(inputFilename)); + TS_ASSERT(ws); + } + + void test_invalidLoadRun() { + const static std::string inputFilename = "ENGINX_277209_focused_bank_2.nxs"; + TestEnggDiffGSASFittingModel model; + + API::MatrixWorkspace_sptr ws; + TS_ASSERT_THROWS_ANYTHING(ws = model.loadFocusedRun(inputFilename)); + TS_ASSERT(!ws); + } + + void test_getRwp() { + TestEnggDiffGSASFittingModel model; + + const RunLabel valid("123", 1); + const double rwp = 75.5; + model.addRwpValue(valid, rwp); + + auto retrievedRwp = boost::make_optional<double>(false, double()); + TS_ASSERT_THROWS_NOTHING(retrievedRwp = model.getRwp(valid)); + TS_ASSERT(retrievedRwp); + TS_ASSERT_EQUALS(rwp, *retrievedRwp); + + const RunLabel invalid("456", 2); + TS_ASSERT_THROWS_NOTHING(retrievedRwp = model.getRwp(invalid)); + TS_ASSERT_EQUALS(retrievedRwp, boost::none); + } + + void test_getGamma() { + TestEnggDiffGSASFittingModel model; + + const RunLabel valid("123", 1); + const double gamma = 75.5; + model.addGammaValue(valid, gamma); + + auto retrievedGamma = boost::make_optional<double>(false, double()); + TS_ASSERT_THROWS_NOTHING(retrievedGamma = model.getGamma(valid)); + TS_ASSERT(retrievedGamma); + TS_ASSERT_EQUALS(gamma, *retrievedGamma); + + const RunLabel invalid("456", 2); + TS_ASSERT_THROWS_NOTHING(retrievedGamma = model.getGamma(invalid)); + TS_ASSERT_EQUALS(retrievedGamma, boost::none); + } + + void test_getSigma() { + TestEnggDiffGSASFittingModel model; + + const RunLabel valid("123", 1); + const double sigma = 75.5; + model.addSigmaValue(valid, sigma); + + auto retrievedSigma = boost::make_optional<double>(false, double()); + TS_ASSERT_THROWS_NOTHING(retrievedSigma = model.getSigma(valid)); + TS_ASSERT(retrievedSigma); + TS_ASSERT_EQUALS(sigma, *retrievedSigma); + + const RunLabel invalid("456", 2); + TS_ASSERT_THROWS_NOTHING(retrievedSigma = model.getSigma(invalid)); + TS_ASSERT_EQUALS(retrievedSigma, boost::none); + } + + void test_getLatticeParams() { + const std::array<std::string, 3> columnHeadings = {{"a", "b", "c"}}; + const std::array<std::array<double, 3>, 1> targetTableValues = { + {{{1, 2, 3}}}}; + const auto table = createDummyTable(columnHeadings, targetTableValues); + + TestEnggDiffGSASFittingModel model; + + const RunLabel valid("123", 1); + TS_ASSERT_THROWS_NOTHING(model.addLatticeParamTable(valid, table)); + + // auto retrievedTable = model.getLatticeParams(123, 1); + boost::optional<API::ITableWorkspace_sptr> retrievedTable; + TS_ASSERT_THROWS_NOTHING(retrievedTable = model.getLatticeParams(valid)); + TS_ASSERT(retrievedTable); + + API::TableRow row = (*retrievedTable)->getRow(0); + const double expectedA = 1; + const double expectedB = 2; + const double expectedC = 3; + auto a = expectedA + 1; + auto b = expectedB + 1; + auto c = expectedC + 1; + + TS_ASSERT_THROWS_NOTHING(row >> a >> b >> c); + TS_ASSERT_EQUALS(a, expectedA); + TS_ASSERT_EQUALS(b, expectedB); + TS_ASSERT_EQUALS(c, expectedC); + + const RunLabel invalid("456", 2); + TS_ASSERT_THROWS_NOTHING(retrievedTable = model.getLatticeParams(invalid)); + TS_ASSERT_EQUALS(retrievedTable, boost::none); + } + + void test_pawleyRefinement() { + // Note: due to the reliance on GSAS-II, this cannot test that the algorithm + // is used properly. It tests that, given that the algorithm is used + // properly, results are added to the appropriate maps in the model + TestEnggDiffGSASFittingModel model; + const RunLabel runLabel("123", 1); + + API::MatrixWorkspace_sptr inputWS = + API::WorkspaceFactory::Instance().create("Workspace2D", 1, 10, 10); + + TS_ASSERT_THROWS_NOTHING( + model.doRefinements(createGSASIIRefineFitPeaksParameters( + inputWS, runLabel, GSASRefinementMethod::PAWLEY))); + + const auto rwp = model.getRwp(runLabel); + TS_ASSERT(rwp); + + const auto sigma = model.getSigma(runLabel); + TS_ASSERT(sigma); + + const auto gamma = model.getGamma(runLabel); + TS_ASSERT(gamma); + + const auto latticeParams = model.getLatticeParams(runLabel); + TS_ASSERT(latticeParams); + + API::AnalysisDataService::Instance().clear(); + } + + void test_RietveldRefinement() { + // Note: due to the reliance on GSAS-II, this cannot test that the algorithm + // is used properly. It tests that, given that the algorithm is used + // properly, results are added to the appropriate maps in the model + TestEnggDiffGSASFittingModel model; + const RunLabel runLabel("123", 1); + + API::MatrixWorkspace_sptr inputWS = + API::WorkspaceFactory::Instance().create("Workspace2D", 1, 10, 10); + + TS_ASSERT_THROWS_NOTHING( + model.doRefinements(createGSASIIRefineFitPeaksParameters( + inputWS, runLabel, GSASRefinementMethod::RIETVELD))); + + const auto rwp = model.getRwp(runLabel); + TS_ASSERT(rwp); + + const auto sigma = model.getSigma(runLabel); + TS_ASSERT(sigma); + + const auto gamma = model.getGamma(runLabel); + TS_ASSERT(gamma); + + const auto latticeParams = model.getLatticeParams(runLabel); + TS_ASSERT(latticeParams); + + API::AnalysisDataService::Instance().clear(); + } +}; diff --git a/qt/scientific_interfaces/test/EnggDiffMultiRunFittingWidgetPresenterTest.h b/qt/scientific_interfaces/test/EnggDiffMultiRunFittingWidgetPresenterTest.h new file mode 100644 index 0000000000000000000000000000000000000000..f46a1ee251847b71f520a41cce1f9f1641b142dd --- /dev/null +++ b/qt/scientific_interfaces/test/EnggDiffMultiRunFittingWidgetPresenterTest.h @@ -0,0 +1,393 @@ +// Mantid Repository : https://github.com/mantidproject/mantid +// +// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI, +// NScD Oak Ridge National Laboratory, European Spallation Source +// & Institut Laue - Langevin +// SPDX - License - Identifier: GPL - 3.0 + +#pragma once + +#include "../EnggDiffraction/EnggDiffMultiRunFittingWidgetPresenter.h" +#include "EnggDiffMultiRunFittingWidgetModelMock.h" +#include "EnggDiffMultiRunFittingWidgetViewMock.h" + +#include "MantidAPI/FrameworkManager.h" +#include "MantidAPI/WorkspaceFactory.h" +#include "MantidTestHelpers/WorkspaceCreationHelper.h" + +#include <cxxtest/TestSuite.h> + +using namespace Mantid; + +using namespace MantidQt::CustomInterfaces; +using testing::Return; + +namespace { +API::MatrixWorkspace_sptr createSampleWorkspace() { + return API::WorkspaceFactory::Instance().create("Workspace2D", 1, 1, 1); +} + +void addBankID(const API::MatrixWorkspace_sptr &ws, const size_t bankID) { + auto addLogAlg = + API::FrameworkManager::Instance().createAlgorithm("AddSampleLog"); + addLogAlg->initialize(); + addLogAlg->setProperty("Workspace", ws); + addLogAlg->setPropertyValue("LogName", "bankid"); + addLogAlg->setPropertyValue("LogText", std::to_string(bankID)); + addLogAlg->setPropertyValue("LogType", "Number"); + addLogAlg->execute(); +} +} // namespace + +class EnggDiffMultiRunFittingWidgetPresenterTest : public CxxTest::TestSuite { +public: + void test_addFittedPeaks() { + auto presenter = setUpPresenter(); + const auto ws = createSampleWorkspace(); + + const RunLabel runLabel("123", 1); + EXPECT_CALL(*m_mockModel, addFittedPeaks(runLabel, ws)).Times(1); + + EXPECT_CALL(*m_mockModel, getFocusedRun(runLabel)) + .Times(1) + .WillOnce(Return(ws)); + EXPECT_CALL(*m_mockView, reportPlotInvalidFocusedRun(testing::_)).Times(0); + EXPECT_CALL(*m_mockView, resetCanvas()).Times(1); + EXPECT_CALL(*m_mockView, plotFocusedRun(testing::_)).Times(1); + EXPECT_CALL(*m_mockModel, hasFittedPeaksForRun(runLabel)) + .Times(1) + .WillOnce(Return(true)); + EXPECT_CALL(*m_mockView, showFitResultsSelected()) + .Times(1) + .WillOnce(Return(false)); + EXPECT_CALL(*m_mockModel, getFittedPeaks(testing::_)).Times(0); + + presenter->addFittedPeaks(runLabel, ws); + assertMocksUsedCorrectly(); + } + + void test_addFocusedRun() { + auto presenter = setUpPresenter(); + const API::MatrixWorkspace_sptr ws = createSampleWorkspace(); + addBankID(ws, 2); + const RunLabel runLabel("0", 2); + + const std::vector<RunLabel> workspaceLabels({runLabel}); + EXPECT_CALL(*m_mockModel, getAllWorkspaceLabels()) + .Times(1) + .WillOnce(Return(workspaceLabels)); + + EXPECT_CALL(*m_mockView, updateRunList(workspaceLabels)); + presenter->addFocusedRun(ws); + assertMocksUsedCorrectly(); + } + + void test_loadRunUpdatesView() { + auto presenter = setUpPresenter(); + const API::MatrixWorkspace_sptr ws = createSampleWorkspace(); + addBankID(ws, 2); + + const RunLabel runLabel("0", 2); + const std::vector<RunLabel> workspaceLabels({runLabel}); + ON_CALL(*m_mockModel, getAllWorkspaceLabels()) + .WillByDefault(Return(workspaceLabels)); + EXPECT_CALL(*m_mockView, updateRunList(workspaceLabels)); + + presenter->addFocusedRun(ws); + assertMocksUsedCorrectly(); + } + + void test_getFittedPeaks() { + auto presenter = setUpPresenter(); + + const RunLabel runLabel("123", 1); + EXPECT_CALL(*m_mockModel, getFittedPeaks(runLabel)) + .Times(1) + .WillOnce(Return(boost::none)); + + presenter->getFittedPeaks(runLabel); + assertMocksUsedCorrectly(); + } + + void test_getFocusedRun() { + auto presenter = setUpPresenter(); + + const RunLabel runLabel("123", 1); + EXPECT_CALL(*m_mockModel, getFocusedRun(runLabel)) + .Times(1) + .WillOnce(Return(boost::none)); + + presenter->getFocusedRun(runLabel); + assertMocksUsedCorrectly(); + } + + void test_selectValidRunWithoutFittedPeaks() { + auto presenter = setUpPresenter(); + + const RunLabel runLabel("123", 1); + EXPECT_CALL(*m_mockView, getSelectedRunLabel()) + .Times(1) + .WillOnce(Return(runLabel)); + + EXPECT_CALL(*m_mockModel, getFocusedRun(runLabel)) + .Times(1) + .WillOnce(Return(createSampleWorkspace())); + + EXPECT_CALL(*m_mockView, reportPlotInvalidFocusedRun(testing::_)).Times(0); + EXPECT_CALL(*m_mockView, resetCanvas()).Times(1); + EXPECT_CALL(*m_mockView, plotFocusedRun(testing::_)).Times(1); + + ON_CALL(*m_mockModel, hasFittedPeaksForRun(runLabel)) + .WillByDefault(Return(false)); + EXPECT_CALL(*m_mockView, plotFittedPeaks(testing::_)).Times(0); + + presenter->notify( + IEnggDiffMultiRunFittingWidgetPresenter::Notification::SelectRun); + assertMocksUsedCorrectly(); + } + + void test_selectRunInvalid() { + auto presenter = setUpPresenter(); + + const RunLabel runLabel("123", 1); + EXPECT_CALL(*m_mockView, getSelectedRunLabel()) + .Times(1) + .WillOnce(Return(runLabel)); + EXPECT_CALL(*m_mockModel, getFocusedRun(runLabel)) + .Times(1) + .WillOnce(Return(boost::none)); + EXPECT_CALL(*m_mockView, reportPlotInvalidFocusedRun(runLabel)).Times(1); + EXPECT_CALL(*m_mockView, resetCanvas()).Times(0); + + presenter->notify( + IEnggDiffMultiRunFittingWidgetPresenter::Notification::SelectRun); + assertMocksUsedCorrectly(); + } + + void test_selectValidRunWithFittedPeaks() { + auto presenter = setUpPresenter(); + + const RunLabel runLabel("123", 1); + ON_CALL(*m_mockView, getSelectedRunLabel()).WillByDefault(Return(runLabel)); + + const auto sampleWorkspace = createSampleWorkspace(); + ON_CALL(*m_mockModel, getFocusedRun(runLabel)) + .WillByDefault(Return(sampleWorkspace)); + + ON_CALL(*m_mockModel, hasFittedPeaksForRun(runLabel)) + .WillByDefault(Return(true)); + ON_CALL(*m_mockView, showFitResultsSelected()).WillByDefault(Return(true)); + EXPECT_CALL(*m_mockModel, getFittedPeaks(runLabel)) + .Times(1) + .WillOnce(Return(sampleWorkspace)); + EXPECT_CALL(*m_mockView, reportPlotInvalidFittedPeaks(testing::_)).Times(0); + EXPECT_CALL(*m_mockView, plotFittedPeaks(testing::_)).Times(1); + + presenter->notify( + IEnggDiffMultiRunFittingWidgetPresenter::Notification::SelectRun); + assertMocksUsedCorrectly(); + } + + void test_selectRunDoesNothingWhenNoRunSelected() { + auto presenter = setUpPresenter(); + + EXPECT_CALL(*m_mockView, getSelectedRunLabel()) + .Times(1) + .WillOnce(Return(boost::none)); + presenter->notify( + IEnggDiffMultiRunFittingWidgetPresenter::Notification::SelectRun); + assertMocksUsedCorrectly(); + } + + void test_plotPeaksStateChangedUpdatesPlot() { + auto presenter = setUpPresenter(); + + const RunLabel runLabel("123", 1); + EXPECT_CALL(*m_mockView, getSelectedRunLabel()) + .Times(1) + .WillOnce(Return(runLabel)); + + const boost::optional<Mantid::API::MatrixWorkspace_sptr> sampleWorkspace( + WorkspaceCreationHelper::create2DWorkspaceBinned(1, 100)); + EXPECT_CALL(*m_mockModel, getFocusedRun(runLabel)) + .Times(1) + .WillOnce(Return(sampleWorkspace)); + + EXPECT_CALL(*m_mockView, resetCanvas()).Times(1); + EXPECT_CALL(*m_mockView, plotFocusedRun(testing::_)).Times(1); + + EXPECT_CALL(*m_mockModel, hasFittedPeaksForRun(runLabel)) + .Times(1) + .WillOnce(Return(false)); + + presenter->notify(IEnggDiffMultiRunFittingWidgetPresenter::Notification:: + PlotPeaksStateChanged); + assertMocksUsedCorrectly(); + } + + void test_plotPeaksStateChangedDoesNotCrashWhenNoRunSelected() { + auto presenter = setUpPresenter(); + + EXPECT_CALL(*m_mockView, getSelectedRunLabel()) + .Times(1) + .WillOnce(Return(boost::none)); + EXPECT_CALL(*m_mockModel, getFocusedRun(testing::_)).Times(0); + + presenter->notify(IEnggDiffMultiRunFittingWidgetPresenter::Notification:: + PlotPeaksStateChanged); + assertMocksUsedCorrectly(); + } + + void test_removeRun() { + auto presenter = setUpPresenter(); + + const RunLabel runLabel("123", 1); + EXPECT_CALL(*m_mockView, getSelectedRunLabel()) + .Times(1) + .WillOnce(Return(runLabel)); + EXPECT_CALL(*m_mockModel, removeRun(runLabel)); + + const std::vector<RunLabel> runLabels({runLabel}); + EXPECT_CALL(*m_mockModel, getAllWorkspaceLabels()) + .Times(1) + .WillOnce(Return(runLabels)); + EXPECT_CALL(*m_mockView, updateRunList(runLabels)); + EXPECT_CALL(*m_mockView, resetCanvas()); + + presenter->notify( + IEnggDiffMultiRunFittingWidgetPresenter::Notification::RemoveRun); + assertMocksUsedCorrectly(); + } + + void test_removeRunDoesNothingWhenNoRunSelected() { + auto presenter = setUpPresenter(); + EXPECT_CALL(*m_mockView, getSelectedRunLabel()) + .Times(1) + .WillOnce(Return(boost::none)); + EXPECT_CALL(*m_mockModel, removeRun(testing::_)).Times(0); + presenter->notify( + IEnggDiffMultiRunFittingWidgetPresenter::Notification::RemoveRun); + assertMocksUsedCorrectly(); + } + + void test_plotToSeparateWindowDoesNothingWhenNoRunSelected() { + auto presenter = setUpPresenter(); + + EXPECT_CALL(*m_mockView, getSelectedRunLabel()) + .Times(1) + .WillOnce(Return(boost::none)); + EXPECT_CALL(*m_mockView, reportNoRunSelectedForPlot()).Times(1); + + presenter->notify(IEnggDiffMultiRunFittingWidgetPresenter::Notification:: + PlotToSeparateWindow); + assertMocksUsedCorrectly(); + } + + void test_plotToSeparateWindowValidFocusedRunNoFittedPeaks() { + auto presenter = setUpPresenter(); + const RunLabel runLabel("123", 1); + + EXPECT_CALL(*m_mockView, getSelectedRunLabel()) + .Times(1) + .WillOnce(Return(runLabel)); + + const boost::optional<Mantid::API::MatrixWorkspace_sptr> sampleWorkspace( + WorkspaceCreationHelper::create2DWorkspaceBinned(1, 100)); + + EXPECT_CALL(*m_mockModel, getFocusedRun(runLabel)) + .Times(1) + .WillOnce(Return(sampleWorkspace)); + + EXPECT_CALL(*m_mockView, reportNoRunSelectedForPlot()).Times(0); + EXPECT_CALL(*m_mockView, reportPlotInvalidFocusedRun(testing::_)).Times(0); + + EXPECT_CALL(*m_mockView, showFitResultsSelected()) + .Times(1) + .WillOnce(Return(true)); + EXPECT_CALL(*m_mockModel, hasFittedPeaksForRun(runLabel)) + .Times(1) + .WillOnce(Return(false)); + + EXPECT_CALL(*m_mockView, plotToSeparateWindow( + "123_1_external_plot", + boost::make_optional(false, std::string()))) + .Times(1); + + presenter->notify(IEnggDiffMultiRunFittingWidgetPresenter::Notification:: + PlotToSeparateWindow); + assertMocksUsedCorrectly(); + } + + void test_plotToSeparateWindowWithFittedPeaks() { + auto presenter = setUpPresenter(); + const RunLabel runLabel("123", 1); + + EXPECT_CALL(*m_mockView, getSelectedRunLabel()) + .Times(1) + .WillOnce(Return(runLabel)); + + const boost::optional<Mantid::API::MatrixWorkspace_sptr> sampleWorkspace( + WorkspaceCreationHelper::create2DWorkspaceBinned(1, 100)); + + EXPECT_CALL(*m_mockModel, getFocusedRun(runLabel)) + .Times(1) + .WillOnce(Return(sampleWorkspace)); + + EXPECT_CALL(*m_mockView, showFitResultsSelected()) + .Times(1) + .WillOnce(Return(true)); + EXPECT_CALL(*m_mockModel, hasFittedPeaksForRun(runLabel)) + .Times(1) + .WillOnce(Return(true)); + + const boost::optional<Mantid::API::MatrixWorkspace_sptr> sampleFittedPeaks( + WorkspaceCreationHelper::create2DWorkspaceBinned(1, 100)); + EXPECT_CALL(*m_mockModel, getFittedPeaks(runLabel)) + .Times(1) + .WillOnce(Return(sampleFittedPeaks)); + EXPECT_CALL(*m_mockView, reportPlotInvalidFittedPeaks(testing::_)).Times(0); + + EXPECT_CALL(*m_mockView, + plotToSeparateWindow("123_1_external_plot", + boost::optional<std::string>( + "123_1_fitted_peaks_external_plot"))) + .Times(1); + + presenter->notify(IEnggDiffMultiRunFittingWidgetPresenter::Notification:: + PlotToSeparateWindow); + assertMocksUsedCorrectly(); + } + + void test_getAllRunLabelsDelegatesToView() { + auto presenter = setUpPresenter(); + EXPECT_CALL(*m_mockView, getAllRunLabels()); + presenter->getAllRunLabels(); + assertMocksUsedCorrectly(); + } + +private: + MockEnggDiffMultiRunFittingWidgetModel *m_mockModel; + MockEnggDiffMultiRunFittingWidgetView *m_mockView; + + std::unique_ptr<EnggDiffMultiRunFittingWidgetPresenter> setUpPresenter() { + auto mockModel_uptr = std::make_unique< + testing::NiceMock<MockEnggDiffMultiRunFittingWidgetModel>>(); + m_mockModel = mockModel_uptr.get(); + + m_mockView = new testing::NiceMock<MockEnggDiffMultiRunFittingWidgetView>(); + + return std::make_unique<EnggDiffMultiRunFittingWidgetPresenter>( + std::move(mockModel_uptr), m_mockView); + } + + void assertMocksUsedCorrectly() { + TSM_ASSERT("View mock not used as expected: some EXPECT_CALL conditions " + "not satisfied", + testing::Mock::VerifyAndClearExpectations(m_mockModel)); + TSM_ASSERT("Model mock not used as expected: some EXPECT_CALL conditions " + "not satisfied", + testing::Mock::VerifyAndClearExpectations(m_mockView)); + if (m_mockView) { + delete m_mockView; + } + } +}; diff --git a/qt/scientific_interfaces/test/EnggVanadiumCorrectionsModelTest.h b/qt/scientific_interfaces/test/EnggVanadiumCorrectionsModelTest.h new file mode 100644 index 0000000000000000000000000000000000000000..c3c5309a19015ca67f4ca1ddfef958651a85a6ec --- /dev/null +++ b/qt/scientific_interfaces/test/EnggVanadiumCorrectionsModelTest.h @@ -0,0 +1,206 @@ +// Mantid Repository : https://github.com/mantidproject/mantid +// +// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI, +// NScD Oak Ridge National Laboratory, European Spallation Source +// & Institut Laue - Langevin +// SPDX - License - Identifier: GPL - 3.0 + +#pragma once + +#include "../EnggDiffraction/EnggVanadiumCorrectionsModel.h" + +#include "MantidAPI/AlgorithmManager.h" +#include "MantidAPI/FrameworkManager.h" +#include "MantidAPI/TableRow.h" +#include "MantidAPI/WorkspaceFactory.h" +#include "MantidTestHelpers/WorkspaceCreationHelper.h" + +#include <Poco/File.h> +#include <Poco/Path.h> + +#include <cxxtest/TestSuite.h> + +using namespace MantidQt::CustomInterfaces; + +namespace { + +Mantid::API::MatrixWorkspace_sptr createSampleMatrixWorkspace() { + return WorkspaceCreationHelper::create2DWorkspaceBinned(1, 1, 2); +} + +Mantid::API::ITableWorkspace_sptr createSampleTableWorkspace() { + auto table = Mantid::API::WorkspaceFactory::Instance().createTable(); + table->addColumn("double", "x"); + Mantid::API::TableRow newRow = table->appendRow(); + newRow << 1.0; + return table; +} + +/// Helper class to allow us to fake EnggVanadiumCorrections +class TestEnggVanadiumCorrectionsModel : public EnggVanadiumCorrectionsModel { +public: + TestEnggVanadiumCorrectionsModel(const EnggDiffCalibSettings &calibSettings, + const std::string ¤tInstrument); + + mutable bool m_calculateCorrectionsCalled; + +private: + std::pair<Mantid::API::ITableWorkspace_sptr, + Mantid::API::MatrixWorkspace_sptr> + calculateCorrectionWorkspaces( + const std::string &vanadiumRunNumber) const override; +}; + +inline TestEnggVanadiumCorrectionsModel::TestEnggVanadiumCorrectionsModel( + const EnggDiffCalibSettings &calibSettings, + const std::string ¤tInstrument) + : EnggVanadiumCorrectionsModel(calibSettings, currentInstrument), + m_calculateCorrectionsCalled(false) {} + +inline std::pair<Mantid::API::ITableWorkspace_sptr, + Mantid::API::MatrixWorkspace_sptr> +TestEnggVanadiumCorrectionsModel::calculateCorrectionWorkspaces( + const std::string &) const { + m_calculateCorrectionsCalled = true; + + auto &ADS = Mantid::API::AnalysisDataService::Instance(); + + Mantid::API::MatrixWorkspace_sptr curvesWS = createSampleMatrixWorkspace(); + ADS.addOrReplace(CURVES_WORKSPACE_NAME, curvesWS); + + auto integratedWS = createSampleTableWorkspace(); + ADS.addOrReplace(INTEGRATED_WORKSPACE_NAME, integratedWS); + + return std::make_pair(integratedWS, curvesWS); +} + +} // anonymous namespace + +class EnggVanadiumCorrectionsModelTest : public CxxTest::TestSuite { + +public: + static EnggVanadiumCorrectionsModelTest *createSuite() { + return new EnggVanadiumCorrectionsModelTest(); + } + + static void destroySuite(EnggVanadiumCorrectionsModelTest *suite) { + delete suite; + } + + EnggVanadiumCorrectionsModelTest() { + Poco::Path tempDir(Poco::Path::temp()); + tempDir.append(INPUT_DIR_NAME); + m_inputDir = tempDir; + Mantid::API::FrameworkManager::Instance(); + } + + void setUp() override { m_inputDir.createDirectory(); } + + void tearDown() override { m_inputDir.remove(true); } + + void test_generateNewWorkspacesWhenNoCache() { + // We've created the calib directory but not populated it with any + // workspaces, so we should get our fake ones + EnggDiffCalibSettings calibSettings; + calibSettings.m_inputDirCalib = m_inputDir.path(); + calibSettings.m_forceRecalcOverwrite = false; + + if (m_inputDir.exists()) { + // Make sure that m_inputDir doesn't exist, as if a previous test exited + // abnormally tearDown() may not have been called + m_inputDir.remove(true); + } + + TestEnggVanadiumCorrectionsModel model(calibSettings, CURRENT_INSTRUMENT); + std::pair<Mantid::API::ITableWorkspace_sptr, + Mantid::API::MatrixWorkspace_sptr> + correctionWorkspaces; + TS_ASSERT_THROWS_NOTHING(correctionWorkspaces = + model.fetchCorrectionWorkspaces("123")); + TS_ASSERT(model.m_calculateCorrectionsCalled); + TS_ASSERT(correctionWorkspaces.first); + TS_ASSERT(correctionWorkspaces.second); + + Poco::Path curvesWSPath(m_inputDir.path()); + curvesWSPath.append("123_precalculated_vanadium_run_bank_curves.nxs"); + TS_ASSERT(Poco::File(curvesWSPath).exists()); + + Poco::Path integWSPath(m_inputDir.path()); + integWSPath.append("123_precalculated_vanadium_run_integration.nxs"); + TS_ASSERT(Poco::File(integWSPath).exists()); + } + + void test_cacheUsedWhenAvailable() { + const auto curvesWS = createSampleMatrixWorkspace(); + const auto integratedWS = createSampleTableWorkspace(); + writeOutSampleCorrectionWorkspaces(integratedWS, curvesWS); + + EnggDiffCalibSettings calibSettings; + calibSettings.m_inputDirCalib = m_inputDir.path(); + calibSettings.m_forceRecalcOverwrite = false; + TestEnggVanadiumCorrectionsModel model(calibSettings, CURRENT_INSTRUMENT); + + std::pair<Mantid::API::ITableWorkspace_sptr, + Mantid::API::MatrixWorkspace_sptr> + correctionWorkspaces; + TS_ASSERT_THROWS_NOTHING(correctionWorkspaces = + model.fetchCorrectionWorkspaces("123")); + TS_ASSERT(!model.m_calculateCorrectionsCalled); + + TS_ASSERT_EQUALS(curvesWS->y(0), correctionWorkspaces.second->y(0)); + + Mantid::API::TableRow sampleDataRow = integratedWS->getRow(0); + Mantid::API::TableRow readDataRow = correctionWorkspaces.first->getRow(0); + TS_ASSERT_EQUALS(sampleDataRow.Double(0), readDataRow.Double(0)); + } + + void test_recalculateIfRequired() { + const auto curvesWS = createSampleMatrixWorkspace(); + const auto integratedWS = createSampleTableWorkspace(); + writeOutSampleCorrectionWorkspaces(integratedWS, curvesWS); + + EnggDiffCalibSettings calibSettings; + calibSettings.m_inputDirCalib = m_inputDir.path(); + calibSettings.m_forceRecalcOverwrite = true; + TestEnggVanadiumCorrectionsModel model(calibSettings, CURRENT_INSTRUMENT); + + std::pair<Mantid::API::ITableWorkspace_sptr, + Mantid::API::MatrixWorkspace_sptr> + correctionWorkspaces; + TS_ASSERT_THROWS_NOTHING(correctionWorkspaces = + model.fetchCorrectionWorkspaces("123")); + TS_ASSERT(model.m_calculateCorrectionsCalled); + } + +private: + const static std::string CURRENT_INSTRUMENT; + const static std::string INPUT_DIR_NAME; + + Poco::File m_inputDir; + + void saveNexus(const std::string &filename, + const Mantid::API::Workspace_sptr &workspace) const { + auto save = Mantid::API::AlgorithmManager::Instance().create("SaveNexus"); + save->initialize(); + save->setProperty("InputWorkspace", workspace); + save->setProperty("Filename", filename); + save->execute(); + } + + void writeOutSampleCorrectionWorkspaces( + const Mantid::API::ITableWorkspace_sptr &integratedWS, + const Mantid::API::MatrixWorkspace_sptr &curvesWS) { + Poco::Path curvesWSPath(m_inputDir.path()); + curvesWSPath.append("123_precalculated_vanadium_run_bank_curves.nxs"); + saveNexus(curvesWSPath.toString(), curvesWS); + + Poco::Path integWSPath(m_inputDir.path()); + integWSPath.append("123_precalculated_vanadium_run_integration.nxs"); + saveNexus(integWSPath.toString(), integratedWS); + } +}; + +const std::string EnggVanadiumCorrectionsModelTest::CURRENT_INSTRUMENT = + "TESTINST"; + +const std::string EnggVanadiumCorrectionsModelTest::INPUT_DIR_NAME( + "EnggVanadiumCorrectionsModelTestData"); diff --git a/qt/scientific_interfaces/test/ISISReflectometry/Experiment/ExperimentPresenterTest.h b/qt/scientific_interfaces/test/ISISReflectometry/Experiment/ExperimentPresenterTest.h index d332900b9776b7f68dbd28e711d434379637199d..15bc9f560a104312935950d273a25b9b5d80c6a2 100644 --- a/qt/scientific_interfaces/test/ISISReflectometry/Experiment/ExperimentPresenterTest.h +++ b/qt/scientific_interfaces/test/ISISReflectometry/Experiment/ExperimentPresenterTest.h @@ -903,7 +903,8 @@ private: } void runTestForInvalidPerAngleOptions(OptionsTable const &optionsTable, - std::vector<int> rows, int column) { + const std::vector<int> &rows, + int column) { auto presenter = makePresenter(); EXPECT_CALL(m_view, getPerAngleOptions()).WillOnce(Return(optionsTable)); for (auto row : rows) diff --git a/qt/scientific_interfaces/test/ISISReflectometry/Experiment/PerThetaDefaultsTableValidatorTest.h b/qt/scientific_interfaces/test/ISISReflectometry/Experiment/PerThetaDefaultsTableValidatorTest.h index 427fe07ae5a961b371109022acb48b35dfef1600..cfd1f346c4bea414397b07dd501c0f4f067957f3 100644 --- a/qt/scientific_interfaces/test/ISISReflectometry/Experiment/PerThetaDefaultsTableValidatorTest.h +++ b/qt/scientific_interfaces/test/ISISReflectometry/Experiment/PerThetaDefaultsTableValidatorTest.h @@ -173,22 +173,23 @@ private: Table emptyTable() { return Table(); } Cells emptyRow() { return Cells(); } - std::vector<InvalidDefaultsError> expectedErrors(std::vector<int> rows, - std::vector<int> columns) { + std::vector<InvalidDefaultsError> + expectedErrors(const std::vector<int> &rows, + const std::vector<int> &columns) { std::vector<InvalidDefaultsError> errors; for (auto row : rows) errors.emplace_back(InvalidDefaultsError(row, columns)); return errors; } - std::vector<PerThetaDefaults> runTestValid(Table table) { + std::vector<PerThetaDefaults> runTestValid(const Table &table) { PerThetaDefaultsTableValidator validator; auto result = validator(table, TOLERANCE); TS_ASSERT(result.isValid()); return result.assertValid(); } - void runTestInvalidThetas(Table table, + void runTestInvalidThetas(const Table &table, ThetaValuesValidationError thetaValuesError, std::vector<InvalidDefaultsError> expectedErrors) { PerThetaDefaultsTableValidator validator; @@ -200,7 +201,7 @@ private: TS_ASSERT_EQUALS(validationError.errors(), expectedErrors); } - void runTestInvalidCells(Table table, + void runTestInvalidCells(const Table &table, std::vector<InvalidDefaultsError> expectedErrors) { PerThetaDefaultsTableValidator validator; auto result = validator(table, TOLERANCE); diff --git a/qt/scientific_interfaces/test/ISISReflectometry/Runs/RunsPresenterTest.h b/qt/scientific_interfaces/test/ISISReflectometry/Runs/RunsPresenterTest.h index 399ea8ca6f0fbca733a0fd0b25bcf453a282d795..57e05ea745940becba851e0a94dbdadb145e258a 100644 --- a/qt/scientific_interfaces/test/ISISReflectometry/Runs/RunsPresenterTest.h +++ b/qt/scientific_interfaces/test/ISISReflectometry/Runs/RunsPresenterTest.h @@ -24,6 +24,8 @@ #include <gmock/gmock.h> #include <gtest/gtest.h> +#include <utility> + using namespace MantidQt::CustomInterfaces::ISISReflectometry; using namespace MantidQt::CustomInterfaces::ISISReflectometry:: ModelCreationHelper; @@ -708,7 +710,7 @@ private: } AlgorithmRuntimeProps defaultLiveMonitorReductionOptions( - std::string instrument = std::string("OFFSPEC")) { + const std::string &instrument = std::string("OFFSPEC")) { return AlgorithmRuntimeProps{ {"GetLiveValueAlgorithm", "GetLiveInstrumentValue"}, {"InputWorkspace", "TOF_live"}, @@ -1005,7 +1007,7 @@ private: expectGetUpdateInterval(updateInterval); EXPECT_CALL(m_mainPresenter, rowProcessingProperties()) .Times(1) - .WillOnce(Return(options)); + .WillOnce(Return(std::move(options))); } void expectGetLiveDataOptions(std::string const &instrument, diff --git a/qt/scientific_interfaces/test/ISISReflectometry/Save/SavePresenterTest.h b/qt/scientific_interfaces/test/ISISReflectometry/Save/SavePresenterTest.h index 7484989a61580d955b68b8a3c42e56e9ae0d18de..182f9f6f32669b35c8916dc3e9011f6b84fd08da 100644 --- a/qt/scientific_interfaces/test/ISISReflectometry/Save/SavePresenterTest.h +++ b/qt/scientific_interfaces/test/ISISReflectometry/Save/SavePresenterTest.h @@ -347,13 +347,13 @@ private: AnalysisDataService::Instance().clear(); } - Workspace2D_sptr createWorkspace(std::string name) { + Workspace2D_sptr createWorkspace(const std::string &name) { Workspace2D_sptr ws = WorkspaceCreationHelper::create2DWorkspace(10, 10); AnalysisDataService::Instance().addOrReplace(name, ws); return ws; } - void createTableWorkspace(std::string name) { + void createTableWorkspace(const std::string &name) { ITableWorkspace_sptr ws = WorkspaceFactory::Instance().createTable("TableWorkspace"); AnalysisDataService::Instance().addOrReplace(name, ws); @@ -367,8 +367,8 @@ private: return workspaceNames; } - void createWorkspaceGroup(std::string groupName, - std::vector<std::string> workspaceNames) { + void createWorkspaceGroup(const std::string &groupName, + const std::vector<std::string> &workspaceNames) { AnalysisDataService::Instance().add(groupName, boost::make_shared<WorkspaceGroup>()); createWorkspaces(workspaceNames); @@ -436,8 +436,8 @@ private: } void expectSaveWorkspaces( - std::vector<std::string> workspaceNames, - std::vector<std::string> logs = std::vector<std::string>{}) { + const std::vector<std::string> &workspaceNames, + const std::vector<std::string> &logs = std::vector<std::string>{}) { EXPECT_CALL(m_view, getSelectedParameters()) .Times(1) .WillOnce(Return(logs)); diff --git a/qt/scientific_interfaces/test/MuonAnalysisDataLoaderTest.h b/qt/scientific_interfaces/test/MuonAnalysisDataLoaderTest.h index ea2dfa309fe8f0dd134b64e05a3fe0b7b4d0510f..04cdbe410a675e2262aa5ec3054d8645d4ac1c40 100644 --- a/qt/scientific_interfaces/test/MuonAnalysisDataLoaderTest.h +++ b/qt/scientific_interfaces/test/MuonAnalysisDataLoaderTest.h @@ -10,6 +10,8 @@ #include <Poco/Path.h> #include <cxxtest/TestSuite.h> +#include <utility> + #include "../Muon/MuonAnalysisDataLoader.h" #include "MantidAPI/Algorithm.h" #include "MantidAPI/AlgorithmManager.h" @@ -42,9 +44,10 @@ public: const QStringList &instruments, const std::string &deadTimesFile = "") : MuonAnalysisDataLoader(deadTimesType, instruments, deadTimesFile){}; - void setProcessAlgorithmProperties(IAlgorithm_sptr alg, + void setProcessAlgorithmProperties(const IAlgorithm_sptr &alg, const AnalysisOptions &options) const { - MuonAnalysisDataLoader::setProcessAlgorithmProperties(alg, options); + MuonAnalysisDataLoader::setProcessAlgorithmProperties(std::move(alg), + options); } }; diff --git a/qt/scientific_interfaces/test/MuonAnalysisResultTableCreatorTest.h b/qt/scientific_interfaces/test/MuonAnalysisResultTableCreatorTest.h index c3d785d9cd2eecbc899b644136d49634bdef4cc4..b41151b0d6a69815a7ae953dbf0534af6dbc5a27 100644 --- a/qt/scientific_interfaces/test/MuonAnalysisResultTableCreatorTest.h +++ b/qt/scientific_interfaces/test/MuonAnalysisResultTableCreatorTest.h @@ -58,7 +58,7 @@ public: return MuonAnalysisResultTableCreator::haveSameParameters(tables); } void removeFixedParameterErrors( - const Mantid::API::ITableWorkspace_sptr table) const { + const Mantid::API::ITableWorkspace_sptr &table) const { MuonAnalysisResultTableCreator::removeFixedParameterErrors(table); } }; @@ -467,7 +467,7 @@ private: } /// Expected output table - ITableWorkspace_sptr getExpectedOutputSingle(const QStringList workspaces) { + ITableWorkspace_sptr getExpectedOutputSingle(const QStringList &workspaces) { auto table = WorkspaceFactory::Instance().createTable(); table->addColumn("str", "workspace_Name"); const std::vector<std::string> titles = { @@ -548,8 +548,8 @@ private: return table; } - bool compareTables(const ITableWorkspace_sptr lhs, - const ITableWorkspace_sptr rhs) { + bool compareTables(const ITableWorkspace_sptr &lhs, + const ITableWorkspace_sptr &rhs) { auto alg = AlgorithmManager::Instance().create("CompareWorkspaces"); alg->initialize(); alg->setChild(true); diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/AlgorithmDialog.h b/qt/widgets/common/inc/MantidQtWidgets/Common/AlgorithmDialog.h index ea8e08a8444b6fafd086e41eafa1efce7e817d98..c77003e337c82a08e9c8197262b8a393f576d1d7 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/AlgorithmDialog.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/AlgorithmDialog.h @@ -141,7 +141,7 @@ protected: /// Set properties on this algorithm by pulling values from the tied widgets bool setPropertyValues(const QStringList &skipList = QStringList()); - bool setPropertyValue(const QString pName, bool validateOthers); + bool setPropertyValue(const QString &pName, bool validateOthers); void showValidators(); //@} @@ -255,7 +255,7 @@ protected: /// GenericDialogDemo.cpp public: /// Set the algorithm associated with this dialog - void setAlgorithm(Mantid::API::IAlgorithm_sptr /*alg*/); + void setAlgorithm(const Mantid::API::IAlgorithm_sptr & /*alg*/); /// Set a list of suggested values void setPresetValues(const QHash<QString, QString> &presetValues); /// Set whether this is intended for use from a script or not diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/AlgorithmHintStrategy.h b/qt/widgets/common/inc/MantidQtWidgets/Common/AlgorithmHintStrategy.h index c50fd636cf32ec9318bb181f121631f47025f894..4b63aad0dafdc666c4c715a6591adeb92cba3266 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/AlgorithmHintStrategy.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/AlgorithmHintStrategy.h @@ -6,6 +6,8 @@ // SPDX - License - Identifier: GPL - 3.0 + #pragma once +#include <utility> + #include "MantidAPI/AlgorithmManager.h" #include "MantidAPI/IAlgorithm.h" #include "MantidQtWidgets/Common/HintStrategy.h" @@ -18,7 +20,7 @@ class AlgorithmHintStrategy : public HintStrategy { public: AlgorithmHintStrategy(Mantid::API::IAlgorithm_sptr algorithm, std::vector<std::string> blacklist) - : m_algorithm(algorithm), m_blacklist(blacklist) {} + : m_algorithm(std::move(algorithm)), m_blacklist(std::move(blacklist)) {} AlgorithmHintStrategy(std::string const &algorithmName, std::vector<std::string> blacklist) diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/AlgorithmHistoryWindow.h b/qt/widgets/common/inc/MantidQtWidgets/Common/AlgorithmHistoryWindow.h index 523cb50607ca7f51c15dcd62894800eeb9056130..985fc73eff5fae7d69b02b2c574a3e363248fc13 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/AlgorithmHistoryWindow.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/AlgorithmHistoryWindow.h @@ -24,6 +24,9 @@ #include <QStandardItemModel> #include <QTreeView> #include <QTreeWidget> +#include <utility> + +#include <utility> //------------------------------------------------------------------------------ // Forward declarations @@ -49,7 +52,8 @@ public: Mantid::API::AlgorithmHistory_const_sptr algHistory, AlgHistoryItem *parent = nullptr) : QTreeWidgetItem(parent, names, UserType), Mantid::API::HistoryItem( - algHistory) {} + std::move(std::move( + algHistory))) {} }; class AlgHistoryTreeWidget : public QTreeWidget { @@ -84,7 +88,7 @@ private: void itemChecked(QTreeWidgetItem *item, int index); void itemUnchecked(QTreeWidgetItem *item, int index); void populateNestedHistory(AlgHistoryItem *parentWidget, - Mantid::API::AlgorithmHistory_sptr history); + const Mantid::API::AlgorithmHistory_sptr &history); void uncheckAllChildren(QTreeWidgetItem *item, int index); QString concatVersionwithName(const std::string &name, const int version); @@ -97,7 +101,7 @@ class AlgExecSummaryGrpBox : public QGroupBox { Q_OBJECT public: explicit AlgExecSummaryGrpBox(QWidget *w); - AlgExecSummaryGrpBox(QString /*title*/, QWidget *w); + AlgExecSummaryGrpBox(const QString & /*title*/, QWidget *w); ~AlgExecSummaryGrpBox() override; void setData(const double execDuration, const Mantid::Types::Core::DateAndTime execDate); @@ -118,7 +122,7 @@ class AlgEnvHistoryGrpBox : public QGroupBox { Q_OBJECT public: explicit AlgEnvHistoryGrpBox(QWidget *w); - AlgEnvHistoryGrpBox(QString /*title*/, QWidget *w); + AlgEnvHistoryGrpBox(const QString & /*title*/, QWidget *w); ~AlgEnvHistoryGrpBox() override; QLineEdit *getosNameEdit() const { return m_osNameEdit; } @@ -145,14 +149,15 @@ signals: public: AlgorithmHistoryWindow( QWidget *parent, - const boost::shared_ptr<const Mantid::API::Workspace> /*wsptr*/); + const boost::shared_ptr<const Mantid::API::Workspace> & /*wsptr*/); AlgorithmHistoryWindow(QWidget *parent, const QString &workspaceName); ~AlgorithmHistoryWindow() override; void closeEvent(QCloseEvent *ce) override; public slots: - void updateAll(Mantid::API::AlgorithmHistory_const_sptr algHistmakeory); + void + updateAll(const Mantid::API::AlgorithmHistory_const_sptr &algHistmakeory); void doUnroll(const std::vector<int> &unrollIndicies); void doRoll(int index); @@ -166,10 +171,10 @@ private: AlgHistoryProperties *createAlgHistoryPropWindow(); QFileDialog *createScriptDialog(const QString &algName); - void - updateExecSummaryGrpBox(Mantid::API::AlgorithmHistory_const_sptr algHistory); + void updateExecSummaryGrpBox( + const Mantid::API::AlgorithmHistory_const_sptr &algHistory); void updateAlgHistoryProperties( - Mantid::API::AlgorithmHistory_const_sptr algHistory); + const Mantid::API::AlgorithmHistory_const_sptr &algHistory); std::string getScriptVersionMode(); diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/AlgorithmInputHistory.h b/qt/widgets/common/inc/MantidQtWidgets/Common/AlgorithmInputHistory.h index b7fc3579623279a7c343ab692ee7bc765797b10d..6ba3742680b0e7146c8abd9e627f26c8aebcc29b 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/AlgorithmInputHistory.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/AlgorithmInputHistory.h @@ -60,7 +60,7 @@ public: protected: /// Constructor - AbstractAlgorithmInputHistory(QString settingsGroup); + AbstractAlgorithmInputHistory(const QString &settingsGroup); private: /// Load any values that are available from persistent storage diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/AlgorithmPropertiesWidget.h b/qt/widgets/common/inc/MantidQtWidgets/Common/AlgorithmPropertiesWidget.h index 0428e7f18745afe6a99ee9f7ee4cba44f1511385..bb74c538df04ac72eccbfb649f50b1ed77fa0cbb 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/AlgorithmPropertiesWidget.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/AlgorithmPropertiesWidget.h @@ -46,7 +46,7 @@ public: void initLayout(); Mantid::API::IAlgorithm_sptr getAlgorithm(); - void setAlgorithm(Mantid::API::IAlgorithm_sptr algo); + void setAlgorithm(const Mantid::API::IAlgorithm_sptr &algo); QString getAlgorithmName() const; void setAlgorithmName(QString name); diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/AlgorithmSelectorWidget.h b/qt/widgets/common/inc/MantidQtWidgets/Common/AlgorithmSelectorWidget.h index 6944e44b90393baba9c6e3a734f56662106c10be..26aed5baa8fbde226fdfa22a3ec79db9a8fb293e 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/AlgorithmSelectorWidget.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/AlgorithmSelectorWidget.h @@ -44,7 +44,7 @@ struct SelectedAlgorithm { /// implicit conversion to QString operator QString() { return name; } /// constructor - SelectedAlgorithm(const QString nameIn, const int versionIn) + SelectedAlgorithm(const QString &nameIn, const int versionIn) : name(nameIn), version(versionIn){}; }; diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/BatchAlgorithmRunner.h b/qt/widgets/common/inc/MantidQtWidgets/Common/BatchAlgorithmRunner.h index c5e68293b80ddc4e8e0b7f2f667ce21aeed75a63..687a16aa311fbdddae5c3bb18a6297b4c9602f35 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/BatchAlgorithmRunner.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/BatchAlgorithmRunner.h @@ -19,6 +19,7 @@ #include <QMetaType> #include <deque> #include <mutex> +#include <utility> namespace MantidQt { namespace API { @@ -70,7 +71,7 @@ public: class AlgorithmCompleteNotification : public Poco::Notification { public: AlgorithmCompleteNotification(IConfiguredAlgorithm_sptr algorithm) - : Poco::Notification(), m_algorithm(algorithm) {} + : Poco::Notification(), m_algorithm(std::move(algorithm)) {} IConfiguredAlgorithm_sptr algorithm() const { return m_algorithm; } @@ -81,7 +82,7 @@ private: class AlgorithmStartedNotification : public Poco::Notification { public: AlgorithmStartedNotification(IConfiguredAlgorithm_sptr algorithm) - : Poco::Notification(), m_algorithm(algorithm) {} + : Poco::Notification(), m_algorithm(std::move(algorithm)) {} IConfiguredAlgorithm_sptr algorithm() const { return m_algorithm; } @@ -93,7 +94,7 @@ class AlgorithmErrorNotification : public Poco::Notification { public: AlgorithmErrorNotification(IConfiguredAlgorithm_sptr algorithm, std::string const &errorMessage) - : Poco::Notification(), m_algorithm(algorithm), + : Poco::Notification(), m_algorithm(std::move(algorithm)), m_errorMessage(errorMessage) {} IConfiguredAlgorithm_sptr algorithm() const { return m_algorithm; } @@ -120,8 +121,9 @@ public: ~BatchAlgorithmRunner() override; /// Adds an algorithm to the execution queue - void addAlgorithm(Mantid::API::IAlgorithm_sptr algo, - AlgorithmRuntimeProps props = AlgorithmRuntimeProps()); + void + addAlgorithm(const Mantid::API::IAlgorithm_sptr &algo, + const AlgorithmRuntimeProps &props = AlgorithmRuntimeProps()); void setQueue(std::deque<IConfiguredAlgorithm_sptr> algorithm); /// Clears all algorithms from queue void clearQueue(); @@ -151,7 +153,7 @@ private: /// Implementation of algorithm runner bool executeBatchAsyncImpl(const Poco::Void & /*unused*/); /// Sets up and executes an algorithm - bool executeAlgo(IConfiguredAlgorithm_sptr algorithm); + bool executeAlgo(const IConfiguredAlgorithm_sptr &algorithm); /// Handlers for notifications void handleBatchComplete(const Poco::AutoPtr<BatchCompleteNotification> &pNf); diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/CatalogSearch.h b/qt/widgets/common/inc/MantidQtWidgets/Common/CatalogSearch.h index 8a7296221a3920b55636674ed7b889756840cea9..af2ee7038ba350f4094e85dfad62624d6ff06d75 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/CatalogSearch.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/CatalogSearch.h @@ -100,7 +100,7 @@ private: /// Obtain all file extensions from the provided column (dataFileResults -> /// File name). std::unordered_set<std::string> - getDataFileExtensions(Mantid::API::Column_sptr column); + getDataFileExtensions(const Mantid::API::Column_sptr &column); /// Add the list of file extensions to the "Filter type..." drop-down. void populateDataFileType(const std::unordered_set<std::string> &extensions); /// Disable the download button if user can access the files locally from the @@ -197,7 +197,7 @@ private: /// The current page the user is on in the results window. Used for paging. int m_currentPageNumber; // Ensure tooltip uses visible color on current OS - void correctedToolTip(std::string toolTip, QLabel *label); + void correctedToolTip(const std::string &toolTip, QLabel *label); }; } // namespace MantidWidgets } // namespace MantidQt \ No newline at end of file diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/ConvolutionFunctionModel.h b/qt/widgets/common/inc/MantidQtWidgets/Common/ConvolutionFunctionModel.h index e7ae0322114b50a79def549253c1203a43a263c4..0ad93fa0aae23ac038f4563a8adde5bdd28431c9 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/ConvolutionFunctionModel.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/ConvolutionFunctionModel.h @@ -51,21 +51,22 @@ private: // void findConvolutionPrefixes(const IFunction_sptr &fun); void iterateThroughFunction(IFunction *func, const QString &prefix); void setPrefix(IFunction *func, const QString &prefix); - CompositeFunction_sptr createInnerFunction(std::string peaksFunction, + CompositeFunction_sptr createInnerFunction(const std::string &peaksFunction, bool hasDeltaFunction, bool isQDependent, double q, bool hasTempCorrection, double tempValue); - CompositeFunction_sptr addTempCorrection(CompositeFunction_sptr peaksFunction, - double tempValue); + CompositeFunction_sptr + addTempCorrection(const CompositeFunction_sptr &peaksFunction, + double tempValue); IFunction_sptr createTemperatureCorrection(double correction); CompositeFunction_sptr createConvolutionFunction(IFunction_sptr resolutionFunction, - IFunction_sptr innerFunction); - IFunction_sptr createResolutionFunction(std::string workspaceName, + const IFunction_sptr &innerFunction); + IFunction_sptr createResolutionFunction(const std::string &workspaceName, int workspaceIndex); CompositeFunction_sptr addBackground(CompositeFunction_sptr domainFunction, - std::string background); + const std::string &background); boost::optional<QString> m_backgroundPrefix; boost::optional<QString> m_convolutionPrefix; boost::optional<QString> m_deltaFunctionPrefix; diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/GenerateNotebook.h b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/GenerateNotebook.h index 594db9c9d40fbf4afe5186f9871cd93167de74dd..4eb2c2daa9106b0964d2a11abfd3d0271b6868bd 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/GenerateNotebook.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/GenerateNotebook.h @@ -50,7 +50,7 @@ QString DLLExport plotsString(const GroupData &groupData, const ProcessingAlgorithm &processor); QString DLLExport -reduceRowString(const RowData_sptr data, const QString &instrument, +reduceRowString(const RowData_sptr &data, const QString &instrument, const WhiteList &whitelist, const std::map<QString, PreprocessingAlgorithm> &preprocessMap, const ProcessingAlgorithm &processor, @@ -77,9 +77,10 @@ QString DLLExport completeOutputProperties(const QString &algName, class DLLExport GenerateNotebook { public: - GenerateNotebook(QString name, QString instrument, WhiteList whitelist, + GenerateNotebook(const QString &name, const QString &instrument, + WhiteList whitelist, std::map<QString, PreprocessingAlgorithm> preprocessMap, - ProcessingAlgorithm processor, + const ProcessingAlgorithm &processor, boost::optional<PostprocessingStep> postprocessingStep, ColumnOptionsMap preprocessingInstructionsMap); virtual ~GenerateNotebook() = default; diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/GenericDataProcessorPresenter.h b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/GenericDataProcessorPresenter.h index fd8e95f54d692afee36445c40a36bf75642b0c4a..e1ef47643f74f09faa48d4b0a759514719538af6 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/GenericDataProcessorPresenter.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/GenericDataProcessorPresenter.h @@ -33,6 +33,7 @@ #include "MantidAPI/AnalysisDataService.h" #include <QObject> +#include <utility> namespace MantidQt { namespace MantidWidgets { @@ -57,7 +58,7 @@ struct PreprocessingAttributes { : m_options(options) {} PreprocessingAttributes(const ColumnOptionsMap &options, std::map<QString, PreprocessingAlgorithm> map) - : m_options(options), m_map(map) {} + : m_options(options), m_map(std::move(map)) {} ColumnOptionsMap m_options; std::map<QString, PreprocessingAlgorithm> m_map; @@ -91,23 +92,24 @@ public: GenericDataProcessorPresenter( WhiteList whitelist, std::map<QString, PreprocessingAlgorithm> preprocessMap, - ProcessingAlgorithm processor, PostprocessingAlgorithm postprocessor, - int group, + const ProcessingAlgorithm &processor, + const PostprocessingAlgorithm &postprocessor, int group, std::map<QString, QString> postprocessMap = std::map<QString, QString>(), - QString loader = "Load"); + const QString &loader = "Load"); // Constructor: no pre-processing, post-processing GenericDataProcessorPresenter(WhiteList whitelist, - ProcessingAlgorithm processor, - PostprocessingAlgorithm postprocessor, + const ProcessingAlgorithm &processor, + const PostprocessingAlgorithm &postprocessor, int group); // Constructor: pre-processing, no post-processing GenericDataProcessorPresenter( WhiteList whitelist, std::map<QString, PreprocessingAlgorithm> preprocessMap, - ProcessingAlgorithm processor, int group); + const ProcessingAlgorithm &processor, int group); // Constructor: no pre-processing, no post-processing GenericDataProcessorPresenter(WhiteList whitelist, - ProcessingAlgorithm processor, int group); + const ProcessingAlgorithm &processor, + int group); // Constructor: only whitelist GenericDataProcessorPresenter(WhiteList whitelist, int group); // Delegating constructor: pre-processing, no post-processing @@ -141,7 +143,7 @@ public: // Get the whitelist WhiteList getWhiteList() const { return m_whitelist; }; // Get the name of the reduced workspace for a given row - QString getReducedWorkspaceName(const RowData_sptr data) const; + QString getReducedWorkspaceName(const RowData_sptr &data) const; ParentItems selectedParents() const override; ChildItems selectedChildren() const override; @@ -195,23 +197,23 @@ protected: void postProcessGroup(const GroupData &data); // Preprocess the given column value if applicable void preprocessColumnValue(const QString &columnName, QString &columnValue, - RowData_sptr data); + const RowData_sptr &data); // Preprocess all option values where applicable - void preprocessOptionValues(RowData_sptr data); + void preprocessOptionValues(const RowData_sptr &data); // Update the model with values used from the options and/or the results from // the algorithm - void updateModelFromResults(Mantid::API::IAlgorithm_sptr alg, - RowData_sptr data); + void updateModelFromResults(const Mantid::API::IAlgorithm_sptr &alg, + const RowData_sptr &data); // Create and execute the algorithm with the given properties Mantid::API::IAlgorithm_sptr createAndRunAlgorithm(const OptionsMap &options); // Reduce a row - void reduceRow(RowData_sptr data); + void reduceRow(const RowData_sptr &data); // Finds a run in the AnalysisDataService QString findRunInADS(const QString &run, const QString &prefix, bool &runFound); // Set up data required for processing a row - bool initRowForProcessing(RowData_sptr rowData); + bool initRowForProcessing(const RowData_sptr &rowData); // Process rows virtual void process(TreeData itemsToProcess); // Plotting @@ -249,12 +251,12 @@ protected: bool promptUser() const { return m_promptUser; } void setGroupIsProcessed(const int groupIndex, const bool isProcessed); void setGroupError(const int groupIndex, const std::string &error); - void setRowIsProcessed(RowData_sptr rowData, const bool isProcessed); - void setRowError(RowData_sptr rowData, const std::string &error); - bool rowNeedsProcessing(RowData_sptr rowData) const; + void setRowIsProcessed(const RowData_sptr &rowData, const bool isProcessed); + void setRowError(const RowData_sptr &rowData, const std::string &error); + bool rowNeedsProcessing(const RowData_sptr &rowData) const; bool groupNeedsProcessing(const int groupIndex) const; void resetProcessedState(const int groupIndex); - void resetProcessedState(RowData_sptr rowData); + void resetProcessedState(const RowData_sptr &rowData); void resetProcessedState(const std::string &workspaceName); void resetProcessedState(); void updateWidgetEnabledState(const bool isProcessing) const; @@ -383,7 +385,7 @@ private: int parentColumn) override; int getNumberOfRows() override; void clearTable() override; - bool workspaceIsOutputOfRow(RowData_sptr rowData, + bool workspaceIsOutputOfRow(const RowData_sptr &rowData, const std::string &workspaceName) const; bool workspaceIsBeingReduced(const std::string &workspaceName) const; void handleWorkspaceRemoved(const std::string &workspaceName, diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/GenericDataProcessorPresenterRowReducerWorker.h b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/GenericDataProcessorPresenterRowReducerWorker.h index ee0705a292ce4f60ac5c7498626cd44682cb3492..82d41b9e37a58913aaea996b50961e52f493280a 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/GenericDataProcessorPresenterRowReducerWorker.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/GenericDataProcessorPresenterRowReducerWorker.h @@ -9,6 +9,7 @@ #include "MantidQtWidgets/Common/DataProcessorUI/GenericDataProcessorPresenter.h" #include <QThread> +#include <utility> namespace MantidQt { namespace MantidWidgets { @@ -27,8 +28,8 @@ public: GenericDataProcessorPresenterRowReducerWorker( GenericDataProcessorPresenter *presenter, RowData_sptr rowData, const int rowIndex, const int groupIndex) - : m_presenter(presenter), m_rowData(rowData), m_rowIndex(rowIndex), - m_groupIndex(groupIndex) {} + : m_presenter(presenter), m_rowData(std::move(rowData)), + m_rowIndex(rowIndex), m_groupIndex(groupIndex) {} private slots: void startWorker() { diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/OneLevelTreeManager.h b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/OneLevelTreeManager.h index 6a0c2c30646ae7a7f6a39c0e653ef917b3810599..76f9fd9179ce3d61d1c37a497fd243d1bb20b44f 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/OneLevelTreeManager.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/OneLevelTreeManager.h @@ -27,7 +27,7 @@ class EXPORT_OPT_MANTIDQT_COMMON OneLevelTreeManager : public TreeManager { public: /// Constructor OneLevelTreeManager(DataProcessorPresenter *presenter, - Mantid::API::ITableWorkspace_sptr table, + const Mantid::API::ITableWorkspace_sptr &table, const WhiteList &whitelist); /// Constructor (no table ws given) OneLevelTreeManager(DataProcessorPresenter *presenter, @@ -123,9 +123,9 @@ private: Mantid::API::ITableWorkspace_sptr createDefaultWorkspace(const WhiteList &whitelist); /// Validate a table workspace - void validateModel(Mantid::API::ITableWorkspace_sptr ws, + void validateModel(const Mantid::API::ITableWorkspace_sptr &ws, size_t whitelistColumns) const; - TreeData constructTreeData(std::set<int> rows); + TreeData constructTreeData(const std::set<int> &rows); }; } // namespace DataProcessor } // namespace MantidWidgets diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/PostprocessingStep.h b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/PostprocessingStep.h index f84122987deb9ef3840388cfb75e6613c62e48e0..891cda313b7d5117fc96e0ea91e8d99b1523416b 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/PostprocessingStep.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/PostprocessingStep.h @@ -21,8 +21,9 @@ namespace MantidWidgets { namespace DataProcessor { struct EXPORT_OPT_MANTIDQT_COMMON PostprocessingStep { public: - PostprocessingStep(QString options); - PostprocessingStep(QString options, PostprocessingAlgorithm algorithm, + PostprocessingStep(const QString &options); + PostprocessingStep(const QString &options, + const PostprocessingAlgorithm &algorithm, std::map<QString, QString> map); void postProcessGroup(const QString &outputWSName, diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/PreprocessingAlgorithm.h b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/PreprocessingAlgorithm.h index 95e3e86f2941caed37d64f941037a4c96ab6bdce..9fd596235f892c608264f1004d35d37367e5101e 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/PreprocessingAlgorithm.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/PreprocessingAlgorithm.h @@ -23,12 +23,13 @@ class EXPORT_OPT_MANTIDQT_COMMON PreprocessingAlgorithm : public ProcessingAlgorithmBase { public: // Constructor - PreprocessingAlgorithm(QString name, QString prefix = "", - QString separator = "", - std::set<QString> blacklist = std::set<QString>()); + PreprocessingAlgorithm( + const QString &name, const QString &prefix = "", + const QString &separator = "", + const std::set<QString> &blacklist = std::set<QString>()); // Delegating constructor - PreprocessingAlgorithm(QString name, QString prefix, QString separator, - const QString &blacklist); + PreprocessingAlgorithm(const QString &name, const QString &prefix, + const QString &separator, const QString &blacklist); // Default constructor PreprocessingAlgorithm(); // Destructor diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/ProcessingAlgorithm.h b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/ProcessingAlgorithm.h index eda2f2f5cf6a5c3c7a85d445b45618ec7495f33e..77010523d6ac2c62cc4a4210f39be9a280d8cc0f 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/ProcessingAlgorithm.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/ProcessingAlgorithm.h @@ -25,12 +25,12 @@ class EXPORT_OPT_MANTIDQT_COMMON ProcessingAlgorithm public: ProcessingAlgorithm(); // Constructor - ProcessingAlgorithm(QString name, std::vector<QString> prefix, + ProcessingAlgorithm(const QString &name, std::vector<QString> prefix, std::size_t postprocessedOutputPrefixIndex, - std::set<QString> blacklist = std::set<QString>(), + const std::set<QString> &blacklist = std::set<QString>(), const int version = -1); // Delegating constructor - ProcessingAlgorithm(QString name, QString const &prefix, + ProcessingAlgorithm(const QString &name, QString const &prefix, std::size_t postprocessedOutputPrefixIndex, QString const &blacklist = "", const int version = -1); // Destructor diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/QOneLevelTreeModel.h b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/QOneLevelTreeModel.h index a1b9420c31de63f7e79345bbaf14802b6de80a20..2b0e7624a1f65104469bb87732ced25f08509b32 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/QOneLevelTreeModel.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/QOneLevelTreeModel.h @@ -31,7 +31,7 @@ the same number of columns as the number of items in the WhiteList. class EXPORT_OPT_MANTIDQT_COMMON QOneLevelTreeModel : public AbstractTreeModel { Q_OBJECT public: - QOneLevelTreeModel(Mantid::API::ITableWorkspace_sptr tableWorkspace, + QOneLevelTreeModel(const Mantid::API::ITableWorkspace_sptr &tableWorkspace, const WhiteList &whitelist); ~QOneLevelTreeModel() override; diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/QTwoLevelTreeModel.h b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/QTwoLevelTreeModel.h index 2742bf09fc08bfaaa12c570e13ce6d529dd0a265..37c5d68c43fb3b836235fdaa194859a28207284d 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/QTwoLevelTreeModel.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/QTwoLevelTreeModel.h @@ -36,7 +36,7 @@ number of items in the WhiteList. class EXPORT_OPT_MANTIDQT_COMMON QTwoLevelTreeModel : public AbstractTreeModel { Q_OBJECT public: - QTwoLevelTreeModel(Mantid::API::ITableWorkspace_sptr tableWorkspace, + QTwoLevelTreeModel(const Mantid::API::ITableWorkspace_sptr &tableWorkspace, const WhiteList &whitelist); ~QTwoLevelTreeModel() override; @@ -112,7 +112,7 @@ private: const std::map<QString, QString> &rowValues); void insertRowAndGroupWithValues(const std::map<QString, QString> &rowValues); bool rowIsEmpty(int row, int parent) const; - void setupModelData(Mantid::API::ITableWorkspace_sptr table); + void setupModelData(const Mantid::API::ITableWorkspace_sptr &table); bool insertGroups(int position, int count); bool removeGroups(int position, int count); bool removeRows(int position, int count, int parent); diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/TreeData.h b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/TreeData.h index e19fa5862f6c79e7cf48d77d911085f124a58de1..3f29447436f74a16aca281434d242a0e87b1c043 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/TreeData.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/TreeData.h @@ -35,7 +35,7 @@ class DLLExport RowData { public: // Constructors explicit RowData(const int columnCount); - explicit RowData(QStringList data); + explicit RowData(const QStringList &data); explicit RowData(const std::vector<std::string> &data); explicit RowData(const RowData &src); @@ -112,7 +112,7 @@ public: bool reductionFailed() const; /// Get the reduced workspace name, optionally adding a prefix - QString reducedName(const QString prefix = QString()) const; + QString reducedName(const QString &prefix = QString()) const; /// Set the reduced workspace name void setReducedName(const QString &name) { m_reducedName = name; } bool hasOutputWorkspaceWithNameAndPrefix(const QString &workspaceName, diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/TwoLevelTreeManager.h b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/TwoLevelTreeManager.h index fe365bf7d26bde67f51d800c52a8e57e072bec17..fde32267a06b16eff5b0d7f2247271b4c057c234 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/TwoLevelTreeManager.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/TwoLevelTreeManager.h @@ -29,7 +29,7 @@ class EXPORT_OPT_MANTIDQT_COMMON TwoLevelTreeManager : public TreeManager { public: /// Constructor TwoLevelTreeManager(DataProcessorPresenter *presenter, - Mantid::API::ITableWorkspace_sptr table, + const Mantid::API::ITableWorkspace_sptr &table, const WhiteList &whitelist); /// Constructor (no table ws given) TwoLevelTreeManager(DataProcessorPresenter *presenter, @@ -122,9 +122,9 @@ private: Mantid::API::ITableWorkspace_sptr createDefaultWorkspace(const WhiteList &whitelist); /// Validate a table workspace - void validateModel(Mantid::API::ITableWorkspace_sptr ws, + void validateModel(const Mantid::API::ITableWorkspace_sptr &ws, size_t whitelistColumns) const; - TreeData constructTreeData(ChildItems rows); + TreeData constructTreeData(const ChildItems &rows); }; } // namespace DataProcessor } // namespace MantidWidgets diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/WorkspaceNameUtils.h b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/WorkspaceNameUtils.h index 8690aa2bce30a7709f90ba9b16c8db68574049ed..8d34e2234ba168291a813d1a84575eef31275390 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/WorkspaceNameUtils.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/WorkspaceNameUtils.h @@ -31,11 +31,11 @@ QString preprocessingListToString(const QStringList &values, const QString &separator); // Returns the name of the reduced workspace for a given row QString DLLExport getReducedWorkspaceName( - const RowData_sptr data, const WhiteList &whitelist, + const RowData_sptr &data, const WhiteList &whitelist, const std::map<QString, PreprocessingAlgorithm> &preprocessor); // Consolidate global options with row values OptionsMap DLLExport getCanonicalOptions( - const RowData_sptr data, const OptionsMap &globalOptions, + const RowData_sptr &data, const OptionsMap &globalOptions, const WhiteList &whitelist, const bool allowInsertions, const std::vector<QString> &outputProperties = std::vector<QString>(), const std::vector<QString> &prefixes = std::vector<QString>()); diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/DiagResults.h b/qt/widgets/common/inc/MantidQtWidgets/Common/DiagResults.h index 622baafe033cf37ef0326a4e358f474818c7bc57..36c1891eec3a2c627b5210f66d72811fe762cca6 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/DiagResults.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/DiagResults.h @@ -28,8 +28,8 @@ signals: void died(); private: - void updateRow(int row, QString text); - int addRow(QString firstColumn, QString secondColumn); + void updateRow(int row, const QString &text); + int addRow(const QString &firstColumn, const QString &secondColumn); void closeEvent(QCloseEvent *event) override; private: diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/DoubleSpinBox.h b/qt/widgets/common/inc/MantidQtWidgets/Common/DoubleSpinBox.h index bad6c44add3850a6326996eff327a5976e5a6648..11af6dae0bd741c300600ba4a37b5391974415cb 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/DoubleSpinBox.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/DoubleSpinBox.h @@ -62,7 +62,7 @@ public: setDecimals(prec); }; - void addSpecialTextMapping(QString text, double value); + void addSpecialTextMapping(const QString &text, double value); QString textFromValue(double value) const; QValidator::State validate(QString &input, int &pos) const override; diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/EditLocalParameterDialog.h b/qt/widgets/common/inc/MantidQtWidgets/Common/EditLocalParameterDialog.h index 811941e87c0c408cb719236917872d494fa7de1c..14a36248c28f3549b6a5a4068e6eb5a54e5584ce 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/EditLocalParameterDialog.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/EditLocalParameterDialog.h @@ -28,9 +28,10 @@ class EXPORT_OPT_MANTIDQT_COMMON EditLocalParameterDialog Q_OBJECT public: EditLocalParameterDialog(QWidget *parent, const QString &parName, - const QStringList &wsNames, QList<double> values, - QList<bool> fixes, QStringList ties, - QStringList constraints); + const QStringList &wsNames, + const QList<double> &values, + const QList<bool> &fixes, const QStringList &ties, + const QStringList &constraints); void doSetup(const QString &parName, const QStringList &wsNames); QString getParameterName() const { return m_parName; } QList<double> getValues() const; @@ -55,9 +56,9 @@ private slots: void fixParameter(int /*index*/, bool /*fix*/); void setAllFixed(bool /*fix*/); void setTie(int /*index*/, QString /*tie*/); - void setTieAll(QString /*tie*/); + void setTieAll(const QString & /*tie*/); void setConstraint(int /*index*/, QString /*tie*/); - void setConstraintAll(QString /*tie*/); + void setConstraintAll(const QString & /*tie*/); void copy(); void paste(); void setValueToLog(int /*i*/); diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/FileDialogHandler.h b/qt/widgets/common/inc/MantidQtWidgets/Common/FileDialogHandler.h index cb511b106e713c3921ccbec8f66752ca9b5bdc0b..c9a80cb04781f64b5261bc247f7ed083879838c4 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/FileDialogHandler.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/FileDialogHandler.h @@ -37,7 +37,7 @@ namespace FileDialogHandler { DLLExport QString getSaveFileName(QWidget *parent = nullptr, const Mantid::Kernel::Property *baseProp = nullptr, - QFileDialog::Options options = nullptr); + const QFileDialog::Options &options = nullptr); /** * For file dialogs. This will add the selected extension if an extension diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/FitOptionsBrowser.h b/qt/widgets/common/inc/MantidQtWidgets/Common/FitOptionsBrowser.h index 66d6c471214667f898bea756fbe06c41b9008aff..d0d0f4c1c91f329c2a907dbb74692ca1c7f2116e 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/FitOptionsBrowser.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/FitOptionsBrowser.h @@ -64,7 +64,7 @@ public: void setLogNames(const QStringList &logNames); void setParameterNamesForPlotting(const QStringList &parNames); QString getParameterToPlot() const; - bool addPropertyToBlacklist(QString); + bool addPropertyToBlacklist(const QString &); signals: void changedToSequentialFitting(); diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/FitPropertyBrowser.h b/qt/widgets/common/inc/MantidQtWidgets/Common/FitPropertyBrowser.h index 862b93bd5c37c90d23b9d441f5248ceaae6794e3..c7a0832df9f5bae34ce9f74c4ea80139d9bcef94 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/FitPropertyBrowser.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/FitPropertyBrowser.h @@ -226,7 +226,7 @@ public: void setTip(const QString &txt); /// alter text of Plot Guess - void setTextPlotGuess(const QString text); + void setTextPlotGuess(const QString &text); /// Creates the "Ties" property value for the Fit algorithm QString getTieString() const; @@ -466,7 +466,7 @@ protected: /// void updateDecimals(); /// Sets the workspace to a function - void setWorkspace(boost::shared_ptr<Mantid::API::IFunction> f) const; + void setWorkspace(const boost::shared_ptr<Mantid::API::IFunction> &f) const; /// Display properties relevant to the selected workspace void setWorkspaceProperties(); /// Adds the workspace index property to the browser. @@ -486,7 +486,7 @@ protected: /// Catches unexpected not found exceptions Mantid::API::IFunction_sptr tryCreateFitFunction(const QString &str); /// Create CompositeFunction from pointer - void createCompositeFunction(const Mantid::API::IFunction_sptr func); + void createCompositeFunction(const Mantid::API::IFunction_sptr &func); /// Property managers: QtGroupPropertyManager *m_groupManager; @@ -593,7 +593,7 @@ private: /// Return the nearest allowed workspace index. int getAllowedIndex(int currentIndex) const; - void setCurrentFunction(Mantid::API::IFunction_const_sptr f) const; + void setCurrentFunction(const Mantid::API::IFunction_const_sptr &f) const; /// Sets the new workspace to the current one virtual void workspaceChange(const QString &wsName); diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/FunctionBrowser.h b/qt/widgets/common/inc/MantidQtWidgets/Common/FunctionBrowser.h index b99020efd284384f5af4445bacf89d77c33aa56b..eb2d18a920197321cb4e73331020dfac96e068f4 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/FunctionBrowser.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/FunctionBrowser.h @@ -142,7 +142,7 @@ public slots: void setDatasetNames(const QStringList &names) override; void resetLocalParameters(); void setCurrentDataset(int i) override; - void removeDatasets(QList<int> indices); + void removeDatasets(const QList<int> &indices); void addDatasets(const QStringList &names); protected: diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/FunctionModel.h b/qt/widgets/common/inc/MantidQtWidgets/Common/FunctionModel.h index db966aed4d08dbf7793986df4492680b631c823d..64fb98aec9ec037b5290d93dd51b6377b04de565 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/FunctionModel.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/FunctionModel.h @@ -33,7 +33,7 @@ public: bool isParameterFixed(const QString &parName) const; QString getParameterTie(const QString &parName) const; void setParameterFixed(const QString &parName, bool fixed); - void setParameterTie(const QString &parName, QString tie); + void setParameterTie(const QString &parName, const QString &tie); QStringList getParameterNames() const override; IFunction_sptr getSingleFunction(int index) const override; IFunction_sptr getCurrentFunction() const override; diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/FunctionMultiDomainPresenter.h b/qt/widgets/common/inc/MantidQtWidgets/Common/FunctionMultiDomainPresenter.h index e6f852b08b01d2977d0ace85d823b80c3dab289d..ca5a129267555c4cbaf29eba2a164e25e2d07f9e 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/FunctionMultiDomainPresenter.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/FunctionMultiDomainPresenter.h @@ -62,9 +62,9 @@ public: void setLocalParameterValue(const QString &parName, int i, double value, double error); void setLocalParameterFixed(const QString &parName, int i, bool fixed); - void setLocalParameterTie(const QString &parName, int i, QString tie); + void setLocalParameterTie(const QString &parName, int i, const QString &tie); void setLocalParameterConstraint(const QString &parName, int i, - QString constraint); + const QString &constraint); QStringList getGlobalParameters() const; void setGlobalParameters(const QStringList &globals); QStringList getLocalParameters() const; diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/FunctionTreeView.h b/qt/widgets/common/inc/MantidQtWidgets/Common/FunctionTreeView.h index 365ea2d20a69e83c89c89e21f503f770b3cc47c5..cf0a75346af8c7b2ac762c8b77a48750b06968a6 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/FunctionTreeView.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/FunctionTreeView.h @@ -137,24 +137,26 @@ protected: /// Remove and delete property void removeProperty(QtProperty *prop); /// Set a function - void setFunction(QtProperty *prop, Mantid::API::IFunction_sptr fun); + void setFunction(QtProperty *prop, const Mantid::API::IFunction_sptr &fun); /// Add a function - bool addFunction(QtProperty *prop, Mantid::API::IFunction_sptr fun); + bool addFunction(QtProperty *prop, const Mantid::API::IFunction_sptr &fun); /// Add a function property - AProperty addFunctionProperty(QtProperty *parent, QString funName); + AProperty addFunctionProperty(QtProperty *parent, const QString &funName); /// Add a parameter property - AProperty addParameterProperty(QtProperty *parent, QString paramName, - QString paramDesc, double paramValue); + AProperty addParameterProperty(QtProperty *parent, const QString ¶mName, + const QString ¶mDesc, double paramValue); /// Add a attribute property - AProperty addAttributeProperty(QtProperty *parent, QString attName, + AProperty addAttributeProperty(QtProperty *parent, const QString &attName, const Mantid::API::IFunction::Attribute &att); /// Add attribute and parameter properties to a function property - void addAttributeAndParameterProperties(QtProperty *prop, - Mantid::API::IFunction_sptr fun); + void + addAttributeAndParameterProperties(QtProperty *prop, + const Mantid::API::IFunction_sptr &fun); /// Add property showing function's index in the composite function AProperty addIndexProperty(QtProperty *prop); /// Update function index properties - void updateFunctionIndices(QtProperty *prop = nullptr, QString index = ""); + void updateFunctionIndices(QtProperty *prop = nullptr, + const QString &index = ""); /// Get property of the overall function AProperty getFunctionProperty() const; /// Check if property is a function group @@ -194,7 +196,7 @@ protected: QtProperty *getTieProperty(QtProperty *prop) const; /// Add a tie property - void addTieProperty(QtProperty *prop, QString tie); + void addTieProperty(QtProperty *prop, const QString &tie); /// Check if a parameter property has a tie bool hasTie(QtProperty *prop) const; /// Check if a property is a tie @@ -204,7 +206,7 @@ protected: /// Add a constraint property QList<AProperty> addConstraintProperties(QtProperty *prop, - QString constraint); + const QString &constraint); /// Check if a property is a constraint bool isConstraint(QtProperty *prop) const; /// Check if a parameter property has a constraint diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/IndirectFitPropertyBrowserLegacy.h b/qt/widgets/common/inc/MantidQtWidgets/Common/IndirectFitPropertyBrowserLegacy.h index b7c60108de7e6becfba459249952aff346bc43ae..fa184ab919f8a11fc162eb29542bd5b9d0ce702a 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/IndirectFitPropertyBrowserLegacy.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/IndirectFitPropertyBrowserLegacy.h @@ -34,7 +34,7 @@ public: boost::optional<size_t> backgroundIndex() const; boost::optional<size_t> - functionIndex(Mantid::API::IFunction_sptr function) const; + functionIndex(const Mantid::API::IFunction_sptr &function) const; QString selectedFitType() const; @@ -55,7 +55,7 @@ public: void setParameterValue(const std::string &functionName, const std::string ¶meterName, double value); - void setParameterValue(Mantid::API::IFunction_sptr function, + void setParameterValue(const Mantid::API::IFunction_sptr &function, const std::string ¶meterName, double value); void setBackground(const std::string &backgroundName); @@ -134,7 +134,8 @@ public: void setWorkspaceIndex(int i) override; - void updatePlotGuess(Mantid::API::MatrixWorkspace_const_sptr sampleWorkspace); + void updatePlotGuess( + const Mantid::API::MatrixWorkspace_const_sptr &sampleWorkspace); public slots: void fit() override; diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/InterfaceManager.h b/qt/widgets/common/inc/MantidQtWidgets/Common/InterfaceManager.h index a59322011b495f71b11e1b8b56111fcc3747d7f0..547503c904cbb6d2de79834ee11035232ba92322 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/InterfaceManager.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/InterfaceManager.h @@ -58,8 +58,8 @@ class EXPORT_OPT_MANTIDQT_COMMON InterfaceManager { public: /// Create a new instance of the correct type of AlgorithmDialog AlgorithmDialog *createDialog( - boost::shared_ptr<Mantid::API::IAlgorithm> alg, QWidget *parent = nullptr, - bool forScript = false, + const boost::shared_ptr<Mantid::API::IAlgorithm> &alg, + QWidget *parent = nullptr, bool forScript = false, const QHash<QString, QString> &presetValues = (QHash<QString, QString>()), const QString &optional_msg = QString(), const QStringList &enabled = QStringList(), diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/LocalParameterEditor.h b/qt/widgets/common/inc/MantidQtWidgets/Common/LocalParameterEditor.h index 47c65042c6ee0ff16ae09c0307b62134d5dc7ce1..01701a1af44141fabc72c097cbaa6177c9ccb2b6 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/LocalParameterEditor.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/LocalParameterEditor.h @@ -24,8 +24,8 @@ class LocalParameterEditor : public QWidget { Q_OBJECT public: LocalParameterEditor(QWidget *parent, int index, double value, bool fixed, - QString tie, QString constraint, bool othersFixed, - bool allOthersFixed, bool othersTied, + const QString &tie, const QString &constraint, + bool othersFixed, bool allOthersFixed, bool othersTied, bool logOptionsEnabled); signals: void setAllValues(double /*_t1*/); @@ -57,8 +57,8 @@ private slots: private: bool eventFilter(QObject *widget, QEvent *evn) override; void setEditorState(); - static QString setTieDialog(QString tie); - static QString setConstraintDialog(QString tie); + static QString setTieDialog(const QString &tie); + static QString setConstraintDialog(const QString &tie); QLineEdit *m_editor; QPushButton *m_button; QAction *m_setAllAction; diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/MantidDialog.h b/qt/widgets/common/inc/MantidQtWidgets/Common/MantidDialog.h index 98e2530fdd79cee9f90eccae9a24d01d14214dde..68f45b649caab64c72616e68ef579d6c3259fb34 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/MantidDialog.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/MantidDialog.h @@ -58,8 +58,8 @@ class EXPORT_OPT_MANTIDQT_COMMON MantidDialog : public QDialog { public: /// DefaultConstructor MantidDialog(QWidget *parent = nullptr, - Qt::WindowFlags flags = Qt::WindowCloseButtonHint | - Qt::WindowType::WindowTitleHint); + const Qt::WindowFlags &flags = Qt::WindowCloseButtonHint | + Qt::WindowType::WindowTitleHint); /// Destructor ~MantidDialog() override; diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/MantidHelpWindow.h b/qt/widgets/common/inc/MantidQtWidgets/Common/MantidHelpWindow.h index eb827f00ce9165ee8bcff9a86326e73f4cb97739..d4f39094c92e175265db7f1b468b24a43c24bd54 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/MantidHelpWindow.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/MantidHelpWindow.h @@ -27,7 +27,8 @@ class EXPORT_OPT_MANTIDQT_COMMON MantidHelpWindow public: static bool helpWindowExists() { return g_helpWindow != nullptr; } - MantidHelpWindow(QWidget *parent = nullptr, Qt::WindowFlags flags = nullptr); + MantidHelpWindow(QWidget *parent = nullptr, + const Qt::WindowFlags &flags = nullptr); ~MantidHelpWindow() override; void showPage(const std::string &url = std::string()) override; @@ -68,7 +69,7 @@ private: public slots: /// Perform any clean up on main window shutdown void shutdown() override; - void warning(QString msg); + void warning(const QString &msg); }; } // namespace MantidWidgets diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/MantidTreeModel.h b/qt/widgets/common/inc/MantidQtWidgets/Common/MantidTreeModel.h index 097001f301bbba7540b6a6260d9a99c3c712ff19..c351c8080cc02d54f669021e999a5f65eee5aaf2 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/MantidTreeModel.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/MantidTreeModel.h @@ -57,7 +57,7 @@ public: QWidget *getParent() override; MantidQt::API::AlgorithmDialog * - createAlgorithmDialog(Mantid::API::IAlgorithm_sptr alg); + createAlgorithmDialog(const Mantid::API::IAlgorithm_sptr &alg); // Plotting Methods MultiLayer * diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/MantidTreeWidgetItem.h b/qt/widgets/common/inc/MantidQtWidgets/Common/MantidTreeWidgetItem.h index b3854149d3796831b4c9f2dc232f81291083098b..3ff2ee37ebbb61c4e95d351f0e60eae72801a8f5 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/MantidTreeWidgetItem.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/MantidTreeWidgetItem.h @@ -22,7 +22,8 @@ class MantidTreeWidget; class EXPORT_OPT_MANTIDQT_COMMON MantidTreeWidgetItem : public QTreeWidgetItem { public: explicit MantidTreeWidgetItem(MantidTreeWidget * /*parent*/); - MantidTreeWidgetItem(QStringList /*list*/, MantidTreeWidget * /*parent*/); + MantidTreeWidgetItem(const QStringList & /*list*/, + MantidTreeWidget * /*parent*/); void disableIfNode(bool); void setSortPos(int o) { m_sortPos = o; } int getSortPos() const { return m_sortPos; } diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/MantidWSIndexDialog.h b/qt/widgets/common/inc/MantidQtWidgets/Common/MantidWSIndexDialog.h index 48f03a8dc184d04682a6f6e98318e19804882539..483e5edddd5c4537815d86b0015bc88b467805dc 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/MantidWSIndexDialog.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/MantidWSIndexDialog.h @@ -72,7 +72,7 @@ public: /// Constructor - starting at start and ending at end. Interval(int start, int end); /// Constructor - attempts to parse given string to find start and end. - explicit Interval(QString /*intervalString*/); + explicit Interval(const QString & /*intervalString*/); /// Copy constructor Interval(const Interval & /*copy*/); @@ -114,9 +114,9 @@ public: /// Constructor - with empty list. IntervalList(void); /// Constructor - with a list created by parsing the input string - explicit IntervalList(QString /*intervals*/); + explicit IntervalList(const QString & /*intervals*/); /// Constructor - with a list containing a single Interval - explicit IntervalList(Interval /*interval*/); + explicit IntervalList(const Interval & /*interval*/); /// Copy Constructor IntervalList(const IntervalList & /*copy*/); @@ -220,7 +220,7 @@ class EXPORT_OPT_MANTIDQT_COMMON MantidWSIndexWidget : public QWidget { QLineEdit *lineEdit() { return _lineEdit; }; /// if Error is not empty, it will make the * label visible and set the /// tooltip as the error. - void setError(QString error); + void setError(const QString &error); private: QLineEdit *_lineEdit; @@ -268,7 +268,7 @@ public: /// Constructor - same parameters as one of the parent constructors, along /// with a /// list of the names of workspaces to be plotted. - MantidWSIndexWidget(QWidget *parent, Qt::WindowFlags flags, + MantidWSIndexWidget(QWidget *parent, const Qt::WindowFlags &flags, const QList<QString> &wsNames, const bool showWaterfallOption = false, const bool showTiledOption = false, @@ -391,7 +391,7 @@ class EXPORT_OPT_MANTIDQT_COMMON MantidWSIndexDialog : public QDialog { public: /// Constructor - has a list of the names of workspaces to be plotted. - MantidWSIndexDialog(QWidget *parent, Qt::WindowFlags flags, + MantidWSIndexDialog(QWidget *parent, const Qt::WindowFlags &flags, const QList<QString> &wsNames, const bool showWaterfallOption = false, const bool showPlotAll = true, diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/MdSettings.h b/qt/widgets/common/inc/MantidQtWidgets/Common/MdSettings.h index 65f84da41a61ca74113d0e0f08f1edb96e0ed8aa..ab09a44d7e7c566343bb7202edda83bcfef57147 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/MdSettings.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/MdSettings.h @@ -31,7 +31,7 @@ public: * Set the UserSetting color map for the vsi. *@param colorMap UserSetting colormap for the vsi */ - void setUserSettingColorMap(QString colorMap); + void setUserSettingColorMap(const QString &colorMap); /** * Get the UserSetting color map for the vsi. @@ -48,7 +48,7 @@ public: * Set the LastSession color map * @param colorMap The colormap for the VSI. */ - void setLastSessionColorMap(QString colorMap); + void setLastSessionColorMap(const QString &colorMap); /** * Get the background color for the user setting. @@ -66,7 +66,7 @@ public: * Set the background color for the user setting. * @param backgroundColor The background color. */ - void setUserSettingBackgroundColor(QColor backgroundColor); + void setUserSettingBackgroundColor(const QColor &backgroundColor); /** * Get the background color for the last session. @@ -78,14 +78,15 @@ public: * Set the background color for the user setting. * @param backgroundColor The background color. */ - void setLastSessionBackgroundColor(QColor backgroundColor); + void setLastSessionBackgroundColor(const QColor &backgroundColor); /** * Set the general MD color map * @param colorMapName The name of the general color map. * @param colorMapFile The file name of the general color map. */ - void setGeneralMdColorMap(QString colorMapName, QString colorMapFile); + void setGeneralMdColorMap(const QString &colorMapName, + const QString &colorMapFile); /** * Get the general MD color map file @@ -141,7 +142,7 @@ public: * Set the user setting for the initial view. * @param initialView The selected initial view. */ - void setUserSettingIntialView(QString initialView); + void setUserSettingIntialView(const QString &initialView); /** * Retrieves the state of the last session's log scale. diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/Message.h b/qt/widgets/common/inc/MantidQtWidgets/Common/Message.h index d5667c988bef848e7832c016e81dcfbd9859b636..c218b7fec153fe44702e9217e708fb691238f0e2 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/Message.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/Message.h @@ -36,15 +36,15 @@ public: Message(); /// Construct a message from a QString with a given priority (default=notice) Message(const QString &text, Priority priority = Priority::PRIO_NOTICE, - QString scriptPath = ""); + const QString &scriptPath = ""); /// Construct a message from a std::string with a given priority /// (default=notice) Message(const std::string &text, Priority priority = Priority::PRIO_NOTICE, - QString scriptPath = ""); + const QString &scriptPath = ""); /// Construct a message from a c-style string and a given priority /// (default=notice) Message(const char *text, Priority priority = Priority::PRIO_NOTICE, - QString scriptPath = ""); + const QString &scriptPath = ""); /// Copy constructor Message(const Message &msg); /// Copy assignment diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/MuonFitDataSelector.h b/qt/widgets/common/inc/MantidQtWidgets/Common/MuonFitDataSelector.h index e3caa39e9d337058084aec767c8eb9231e41042e..4baa49c3dbc1e196dbfc9eb8e0ba7d923958aa1f 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/MuonFitDataSelector.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/MuonFitDataSelector.h @@ -48,8 +48,12 @@ public: /// Get names of chosen groups QStringList getChosenGroups() const override; /// Set chosen group/period - void setGroupsSelected(QStringList groups) { m_chosenGroups = groups; }; - void setPeriodsSelected(QStringList periods) { m_chosenPeriods = periods; }; + void setGroupsSelected(const QStringList &groups) { + m_chosenGroups = groups; + }; + void setPeriodsSelected(const QStringList &periods) { + m_chosenPeriods = periods; + }; /// Get selected periods QStringList getPeriodSelections() const override; /// Get type of fit diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/MuonFitPropertyBrowser.h b/qt/widgets/common/inc/MantidQtWidgets/Common/MuonFitPropertyBrowser.h index e5ebbd454dc1f28a5066b9081f4ff91b1822d609..3239b024b3f9eabf072d92a92184ec5764ce5c8b 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/MuonFitPropertyBrowser.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/MuonFitPropertyBrowser.h @@ -128,8 +128,8 @@ public: void setChosenGroup(const QString &group); void setAllPeriods(); void setChosenPeriods(const QString &period); - void setSingleFitLabel(std::string name); - void setNormalization(const std::string name); + void setSingleFitLabel(const std::string &name); + void setNormalization(const std::string &name); void checkFitEnabled(); public slots: /// Perform the fit algorithm @@ -185,8 +185,8 @@ private: void finishAfterSimultaneousFit(const Mantid::API::IAlgorithm *fitAlg, const int nWorkspaces) const; void finishAfterTFSimultaneousFit(const Mantid::API::IAlgorithm *alg, - const std::string baseName) const; - void setFitWorkspaces(const std::string input); + const std::string &baseName) const; + void setFitWorkspaces(const std::string &input); std::string getUnnormName(const std::string wsName); void ConvertFitFunctionForMuonTFAsymmetry(bool enabled); void setTFAsymmMode(bool state); diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/NonOrthogonal.h b/qt/widgets/common/inc/MantidQtWidgets/Common/NonOrthogonal.h index 9e87f040843fd46bc4c947bcffef61dcfd93e0f1..773b926fd90c7f95fb981273c44ab6e25b522075 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/NonOrthogonal.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/NonOrthogonal.h @@ -27,7 +27,8 @@ bool EXPORT_OPT_MANTIDQT_COMMON isHKLDimensions( const Mantid::API::IMDWorkspace &workspace, size_t dimX, size_t dimY); size_t EXPORT_OPT_MANTIDQT_COMMON getMissingHKLDimensionIndex( - Mantid::API::IMDWorkspace_const_sptr workspace, size_t dimX, size_t dimY); + const Mantid::API::IMDWorkspace_const_sptr &workspace, size_t dimX, + size_t dimY); void EXPORT_OPT_MANTIDQT_COMMON transformFromDoubleToCoordT(const Mantid::Kernel::DblMatrix &skewMatrix, diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/PluginLibraries.h b/qt/widgets/common/inc/MantidQtWidgets/Common/PluginLibraries.h index 158052067ee156ec84128a3896aa8f10a6395629..f84dd4db5c09fd97f3323d6964c62a1ff6af8e21 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/PluginLibraries.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/PluginLibraries.h @@ -13,12 +13,13 @@ namespace MantidQt { namespace API { -EXPORT_OPT_MANTIDQT_COMMON std::string qtPluginPathFromCfg(std::string key); +EXPORT_OPT_MANTIDQT_COMMON std::string +qtPluginPathFromCfg(const std::string &key); /// Load plugins from a path given by the key in the config service -EXPORT_OPT_MANTIDQT_COMMON int loadPluginsFromCfgPath(std::string key); +EXPORT_OPT_MANTIDQT_COMMON int loadPluginsFromCfgPath(const std::string &key); /// Load plugins from a path -EXPORT_OPT_MANTIDQT_COMMON int loadPluginsFromPath(std::string path); +EXPORT_OPT_MANTIDQT_COMMON int loadPluginsFromPath(const std::string &path); } // namespace API } // namespace MantidQt diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/ProcessingAlgoWidget.h b/qt/widgets/common/inc/MantidQtWidgets/Common/ProcessingAlgoWidget.h index 92f2975ebceb4e72d354e5ad3ffce3edd4ddc724..913753c63a757c34952a88c430c1426e48c8fb59 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/ProcessingAlgoWidget.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/ProcessingAlgoWidget.h @@ -34,7 +34,7 @@ public: /// @return the info string displayed at the top QString infoString() { return ui.lblInfo->text(); } /// Sets the info string displayed at the top - void infoString(QString text) { return ui.lblInfo->setText(text); } + void infoString(const QString &text) { return ui.lblInfo->setText(text); } /// @return true if the script editor is visible bool editorVisible() { return ui.editorContainer->isVisible(); } @@ -55,7 +55,7 @@ public: /// @return the text in the script editor QString getScriptText(); /// Set the script editor text - void setScriptText(QString text); + void setScriptText(const QString &text); void saveInput(); /// Sets the AlgorithmInputHistory object recording the algorithm properties diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/ProjectSaveModel.h b/qt/widgets/common/inc/MantidQtWidgets/Common/ProjectSaveModel.h index eb1c2078e049cf6babdb30712a1eac432d455f47..25db0015b4a53286d66a4737851bf9c3f6f05039 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/ProjectSaveModel.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/ProjectSaveModel.h @@ -45,9 +45,10 @@ struct WindowInfo { class EXPORT_OPT_MANTIDQT_COMMON ProjectSaveModel { public: /// Construct a new model instance with vector of window handles - ProjectSaveModel(std::vector<MantidQt::API::IProjectSerialisable *> windows, - std::vector<std::string> activePythonInterfaces = - std::vector<std::string>()); + ProjectSaveModel( + const std::vector<MantidQt::API::IProjectSerialisable *> &windows, + std::vector<std::string> activePythonInterfaces = + std::vector<std::string>()); /// Check if a workspace has any windows attached to it bool hasWindows(const std::string &ws) const; @@ -80,7 +81,7 @@ public: private: /// Create a workspace info object for this workspace WorkspaceInfo - makeWorkspaceInfoObject(Mantid::API::Workspace_const_sptr ws) const; + makeWorkspaceInfoObject(const Mantid::API::Workspace_const_sptr &ws) const; WindowInfo makeWindowInfoObject(MantidQt::API::IProjectSerialisable *window) const; diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/PropertyHandler.h b/qt/widgets/common/inc/MantidQtWidgets/Common/PropertyHandler.h index ac28a12a507f007ae665f35c260d868410632d85..1fa12b5f7bff5c48d3d4690c10a5c9926af7dcfe 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/PropertyHandler.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/PropertyHandler.h @@ -42,7 +42,7 @@ class EXPORT_OPT_MANTIDQT_COMMON PropertyHandler Q_OBJECT public: // Constructor - PropertyHandler(Mantid::API::IFunction_sptr fun, + PropertyHandler(const Mantid::API::IFunction_sptr &fun, boost::shared_ptr<Mantid::API::CompositeFunction> parent, FitPropertyBrowser *browser, QtBrowserItem *item = nullptr); @@ -94,7 +94,7 @@ public: PropertyHandler *findHandler(QtProperty *prop); - PropertyHandler *findHandler(Mantid::API::IFunction_const_sptr fun); + PropertyHandler *findHandler(const Mantid::API::IFunction_const_sptr &fun); PropertyHandler *findHandler(const Mantid::API::IFunction *fun); /** @@ -184,7 +184,7 @@ public: void addTie(const QString &tieStr); void fix(const QString &parName); - void removeTie(QtProperty *prop, std::string globalName); + void removeTie(QtProperty *prop, const std::string &globalName); void removeTie(QtProperty *prop); void removeTie(const QString &propName); void addConstraint(QtProperty *parProp, bool lo, bool up, double loBound, diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/QtPropertyBrowser/qtpropertybrowserutils_p.h b/qt/widgets/common/inc/MantidQtWidgets/Common/QtPropertyBrowser/qtpropertybrowserutils_p.h index 39f0522746e15312802508b4fcf4bec6a0567f7d..0d4a272bf932ae84cdf6bee28c2c827203778cfb 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/QtPropertyBrowser/qtpropertybrowserutils_p.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/QtPropertyBrowser/qtpropertybrowserutils_p.h @@ -192,7 +192,7 @@ private slots: private: void handleKeyEvent(QKeyEvent *e); - int translateModifiers(Qt::KeyboardModifiers state, + int translateModifiers(const Qt::KeyboardModifiers &state, const QString &text) const; int m_num; diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/SaveWorkspaces.h b/qt/widgets/common/inc/MantidQtWidgets/Common/SaveWorkspaces.h index 59a69bd24c59c01adf791f7960e0bd7fadafc9bb..a0fcbbbfe2c9139ab2a9c82d41856571b7cfe7dc 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/SaveWorkspaces.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/SaveWorkspaces.h @@ -77,7 +77,7 @@ private: QHash<QString, QString> workspaceMap); QHash<QString, QString> provideZeroFreeWorkspaces(const QListWidget *workspaces); - void removeZeroFreeWorkspaces(QHash<QString, QString> workspaces); + void removeZeroFreeWorkspaces(const QHash<QString, QString> &workspaces); bool isValid(); private slots: void saveSel(); diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/ScriptRepositoryView.h b/qt/widgets/common/inc/MantidQtWidgets/Common/ScriptRepositoryView.h index 2ff1ff0d336f8dbf04277eddf38340704c5feb86..bbb6ecd5c853aa61aab6c6257a627ae5f81cbb92 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/ScriptRepositoryView.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/ScriptRepositoryView.h @@ -37,7 +37,7 @@ class EXPORT_OPT_MANTIDQT_COMMON ScriptRepositoryView : public MantidDialog { const QModelIndex &index) override; QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override; - QIcon getIcon(QString state) const; + QIcon getIcon(const QString &state) const; }; /// Delegate to show the checkbox for configuring the auto update class CheckBoxDelegate : public QStyledItemDelegate { @@ -78,7 +78,7 @@ protected slots: void updateModel(); void currentChanged(const QModelIndex ¤t); void helpClicked(); - void openFolderLink(QString /*link*/); + void openFolderLink(const QString & /*link*/); private: Ui::ScriptRepositoryView *ui; diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/SequentialFitDialog.h b/qt/widgets/common/inc/MantidQtWidgets/Common/SequentialFitDialog.h index f2d09a6454da10e7f3e2be12cebae635be5e54ca..9f6f9ec91a6b27c7609a414f8efab56173a03b7d 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/SequentialFitDialog.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/SequentialFitDialog.h @@ -37,7 +37,7 @@ public: /// Add a list of workspace names to the data list /// Returns false if neither of the workspaces can be loaded - bool addWorkspaces(const QStringList wsNames); + bool addWorkspaces(const QStringList &wsNames); private: /// The form generated with Qt Designer @@ -84,7 +84,7 @@ private slots: private: /// Checks that the logs in workspace wsName are consistent /// with logs of other workspaces - bool validateLogs(const QString wsName); + bool validateLogs(const QString &wsName); /// Populate parameter combo box with possible parameter names void populateParameters(); diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/SlicingAlgorithmDialog.h b/qt/widgets/common/inc/MantidQtWidgets/Common/SlicingAlgorithmDialog.h index 38a18c6755043e37b3707d92f23f0553606b6637..8b65c65627856505c0529ae3a34568ccf51438c6 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/SlicingAlgorithmDialog.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/SlicingAlgorithmDialog.h @@ -44,10 +44,10 @@ public: ~SlicingAlgorithmDialog() override; // Customisation for the VSI - void customiseLayoutForVsi(std::string initialWorkspace); + void customiseLayoutForVsi(const std::string &initialWorkspace); /// Reset the aligned dim values for the VSI - void resestAlignedDimProperty(size_t index, QString propertyValue); + void resestAlignedDimProperty(size_t index, const QString &propertyValue); protected: /// view @@ -96,7 +96,7 @@ private: /// Build dimension inputs. void makeDimensionInputs( const QString &propertyPrefix, QLayout *owningLayout, - QString (*format)(Mantid::Geometry::IMDDimension_const_sptr), + QString (*format)(const Mantid::Geometry::IMDDimension_const_sptr &), History history); /// Determine if history should be used. diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/SlitCalculator.h b/qt/widgets/common/inc/MantidQtWidgets/Common/SlitCalculator.h index 5d2dfa271f802cb7a1a06dbb19d52b23dcea3184..c9cf9d3fedf6c912045e594313c1796a8db9f063 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/SlitCalculator.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/SlitCalculator.h @@ -37,10 +37,10 @@ private: Mantid::Geometry::Instrument_const_sptr instrument; std::string currentInstrumentName; void setupSlitCalculatorWithInstrumentValues( - Mantid::Geometry::Instrument_const_sptr /*instrument*/); + const Mantid::Geometry::Instrument_const_sptr & /*instrument*/); std::string getCurrentInstrumentName(); Mantid::Geometry::Instrument_const_sptr getInstrument(); - void setInstrument(std::string instrumentName); + void setInstrument(const std::string &instrumentName); private slots: void on_recalculate_triggered(); }; diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/TSVSerialiser.h b/qt/widgets/common/inc/MantidQtWidgets/Common/TSVSerialiser.h index dfc351b42b18d20b6cd5c610ab15cc25cb8e9121..7fec9813d37849d5b893da6294bcdf812a2dc3f5 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/TSVSerialiser.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/TSVSerialiser.h @@ -110,7 +110,7 @@ public: void storeDouble(const double val); void storeInt(const int val); - void storeString(const std::string val); + void storeString(const std::string &val); void storeBool(const bool val); double readDouble(); diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/UserInputValidator.h b/qt/widgets/common/inc/MantidQtWidgets/Common/UserInputValidator.h index 0eeac6564f865be56a8a3ddcdabfe0a79b50f648..8647a5dcc000ae1629870ffc82d9b398ba1d55b2 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/UserInputValidator.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/UserInputValidator.h @@ -80,12 +80,13 @@ public: /// Checks the number of histograms in a workspace bool checkWorkspaceNumberOfHistograms(QString const &workspaceName, std::size_t const &validSize); - bool checkWorkspaceNumberOfHistograms(Mantid::API::MatrixWorkspace_sptr, - std::size_t const &validSize); + bool + checkWorkspaceNumberOfHistograms(const Mantid::API::MatrixWorkspace_sptr &, + std::size_t const &validSize); /// Checks the number of bins in a workspace bool checkWorkspaceNumberOfBins(QString const &workspaceName, std::size_t const &validSize); - bool checkWorkspaceNumberOfBins(Mantid::API::MatrixWorkspace_sptr, + bool checkWorkspaceNumberOfBins(const Mantid::API::MatrixWorkspace_sptr &, std::size_t const &validSize); /// Checks that a workspace group contains valid matrix workspace's bool checkWorkspaceGroupIsValid(QString const &groupName, diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/WorkspacePresenter/WorkspaceTreeWidget.h b/qt/widgets/common/inc/MantidQtWidgets/Common/WorkspacePresenter/WorkspaceTreeWidget.h index 136d68e6aac274b06fe76d2c00d8348231d6e504..3f744bcbb7ae52ec7cc3536ba26fe5aae5b16818 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/WorkspacePresenter/WorkspaceTreeWidget.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/WorkspacePresenter/WorkspaceTreeWidget.h @@ -131,7 +131,8 @@ public: private: bool hasUBMatrix(const std::string &wsName); - void addSaveMenuOption(QString algorithmString, QString menuEntryName = ""); + void addSaveMenuOption(const QString &algorithmString, + QString menuEntryName = ""); void setTreeUpdating(const bool state); inline bool isTreeUpdating() const { return m_treeUpdating; } void updateTree(const TopLevelItems &items) override; @@ -140,7 +141,7 @@ private: MantidTreeWidgetItem * addTreeEntry(const std::pair<std::string, Mantid::API::Workspace_sptr> &item, QTreeWidgetItem *parent = nullptr); - bool shouldBeSelected(QString name) const; + bool shouldBeSelected(const QString &name) const; void createWorkspaceMenuActions(); void createSortMenuActions(); void setItemIcon(QTreeWidgetItem *item, const std::string &wsID); diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/WorkspaceSelector.h b/qt/widgets/common/inc/MantidQtWidgets/Common/WorkspaceSelector.h index a59a49342dac3f38027708451b9ff5bd6c87b962..e01677133bdc416afb2b8e06d4dcf5f0fe89bbe5 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/WorkspaceSelector.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/WorkspaceSelector.h @@ -94,9 +94,9 @@ private: handleReplaceEvent(Mantid::API::WorkspaceAfterReplaceNotification_ptr pNf); bool checkEligibility(const QString &name, - Mantid::API::Workspace_sptr object) const; + const Mantid::API::Workspace_sptr &object) const; bool hasValidSuffix(const QString &name) const; - bool hasValidNumberOfBins(Mantid::API::Workspace_sptr object) const; + bool hasValidNumberOfBins(const Mantid::API::Workspace_sptr &object) const; protected: // Method for handling drop events diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/pqHelpWindow.h b/qt/widgets/common/inc/MantidQtWidgets/Common/pqHelpWindow.h index 3ad5450c2912319e3cb31eb75fd62907d3bb1c83..e3ae6d05ee26dd87e1c48bfba94c8f3f8f26e152 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/pqHelpWindow.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/pqHelpWindow.h @@ -78,7 +78,7 @@ class EXPORT_OPT_MANTIDQT_COMMON pqHelpWindow : public QMainWindow { public: pqHelpWindow(QHelpEngine *engine, QWidget *parent = nullptr, - Qt::WindowFlags flags = nullptr); + const Qt::WindowFlags &flags = nullptr); public slots: /// Requests showing of a particular page. The url must begin with "qthelp:" diff --git a/qt/widgets/common/src/AlgorithmDialog.cpp b/qt/widgets/common/src/AlgorithmDialog.cpp index a7f2c0c8ae44aaca501126e2938ea188e9f41398..9a29351738bd4969e4fe7a5ab0202ccf0c8cc8f3 100644 --- a/qt/widgets/common/src/AlgorithmDialog.cpp +++ b/qt/widgets/common/src/AlgorithmDialog.cpp @@ -180,7 +180,7 @@ void AlgorithmDialog::saveInput() { * Set the algorithm pointer * @param alg :: A pointer to the algorithm */ -void AlgorithmDialog::setAlgorithm(Mantid::API::IAlgorithm_sptr alg) { +void AlgorithmDialog::setAlgorithm(const Mantid::API::IAlgorithm_sptr &alg) { m_algorithm = alg; m_algName = QString::fromStdString(alg->name()); m_algProperties.clear(); @@ -330,7 +330,7 @@ void AlgorithmDialog::showValidators() { * end. * @return true if the property is valid. */ -bool AlgorithmDialog::setPropertyValue(const QString pName, +bool AlgorithmDialog::setPropertyValue(const QString &pName, bool validateOthers) { // Mantid::Kernel::Property *p = getAlgorithmProperty(pName); QString value = getInputValue(pName); diff --git a/qt/widgets/common/src/AlgorithmHistoryWindow.cpp b/qt/widgets/common/src/AlgorithmHistoryWindow.cpp index cbc796ec461727e6ce3ace05053e3a401256b7c5..c6308d8aab9b4f304f2715b060729c322a8287bb 100644 --- a/qt/widgets/common/src/AlgorithmHistoryWindow.cpp +++ b/qt/widgets/common/src/AlgorithmHistoryWindow.cpp @@ -60,7 +60,7 @@ AlgExecSummaryGrpBox::AlgExecSummaryGrpBox(QWidget *w) : QGroupBox(w), m_execDurationlabel(nullptr), m_execDurationEdit(nullptr), m_Datelabel(nullptr), m_execDateTimeEdit(nullptr), m_algexecDuration() {} -AlgExecSummaryGrpBox::AlgExecSummaryGrpBox(QString title, QWidget *w) +AlgExecSummaryGrpBox::AlgExecSummaryGrpBox(const QString &title, QWidget *w) : QGroupBox(title, w), m_execDurationlabel(nullptr), m_execDurationEdit(nullptr), m_Datelabel(nullptr), m_execDateTimeEdit(nullptr), m_algexecDuration() { @@ -135,7 +135,7 @@ AlgEnvHistoryGrpBox::AlgEnvHistoryGrpBox(QWidget *w) m_osVersionLabel(nullptr), m_osVersionEdit(nullptr), m_frmworkVersionLabel(nullptr), m_frmwkVersnEdit(nullptr) {} -AlgEnvHistoryGrpBox::AlgEnvHistoryGrpBox(QString title, QWidget *w) +AlgEnvHistoryGrpBox::AlgEnvHistoryGrpBox(const QString &title, QWidget *w) : QGroupBox(title, w), m_osNameLabel(nullptr), m_osNameEdit(nullptr), m_osVersionLabel(nullptr), m_osVersionEdit(nullptr), m_frmworkVersionLabel(nullptr), m_frmwkVersnEdit(nullptr) { @@ -202,7 +202,7 @@ AlgEnvHistoryGrpBox::~AlgEnvHistoryGrpBox() { } AlgorithmHistoryWindow::AlgorithmHistoryWindow( - QWidget *parent, const boost::shared_ptr<const Workspace> wsptr) + QWidget *parent, const boost::shared_ptr<const Workspace> &wsptr) : QDialog(parent), m_algHist(wsptr->getHistory()), m_histPropWindow(nullptr), m_execSumGrpBox(nullptr), m_envHistGrpBox(nullptr), m_wsName(wsptr->getName().c_str()), @@ -464,13 +464,13 @@ void AlgEnvHistoryGrpBox::fillEnvHistoryGroupBox( } void AlgorithmHistoryWindow::updateAll( - Mantid::API::AlgorithmHistory_const_sptr algHistory) { + const Mantid::API::AlgorithmHistory_const_sptr &algHistory) { updateAlgHistoryProperties(algHistory); updateExecSummaryGrpBox(algHistory); } void AlgorithmHistoryWindow::updateAlgHistoryProperties( - AlgorithmHistory_const_sptr algHistory) { + const AlgorithmHistory_const_sptr &algHistory) { PropertyHistories histProp = algHistory->getProperties(); if (m_histPropWindow) { m_histPropWindow->setAlgProperties(histProp); @@ -480,7 +480,7 @@ void AlgorithmHistoryWindow::updateAlgHistoryProperties( } void AlgorithmHistoryWindow::updateExecSummaryGrpBox( - AlgorithmHistory_const_sptr algHistory) { + const AlgorithmHistory_const_sptr &algHistory) { // getting the selected algorithm at pos from History vector double duration = algHistory->executionDuration(); Mantid::Types::Core::DateAndTime date = algHistory->executionDate(); @@ -766,7 +766,8 @@ void AlgHistoryTreeWidget::populateAlgHistoryTreeWidget( } void AlgHistoryTreeWidget::populateNestedHistory( - AlgHistoryItem *parentWidget, Mantid::API::AlgorithmHistory_sptr history) { + AlgHistoryItem *parentWidget, + const Mantid::API::AlgorithmHistory_sptr &history) { const Mantid::API::AlgorithmHistories &entries = history->getChildHistories(); if (history->childHistorySize() > 0) { parentWidget->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsSelectable | diff --git a/qt/widgets/common/src/AlgorithmInputHistory.cpp b/qt/widgets/common/src/AlgorithmInputHistory.cpp index 9ed41fb910c48b339e97170f486bc96a76377c62..84228b2ae6e6fcdb06981e82bd2cfc13bbd3b2c8 100644 --- a/qt/widgets/common/src/AlgorithmInputHistory.cpp +++ b/qt/widgets/common/src/AlgorithmInputHistory.cpp @@ -12,6 +12,7 @@ #include <QSettings> #include <QStringList> +#include <utility> using namespace MantidQt::API; @@ -23,9 +24,9 @@ using namespace MantidQt::API; * Constructor */ AbstractAlgorithmInputHistory::AbstractAlgorithmInputHistory( - QString settingsGroup) - : m_lastInput(), m_previousDirectory(""), m_algorithmsGroup(settingsGroup), - m_dirKey("LastDirectory") { + const QString &settingsGroup) + : m_lastInput(), m_previousDirectory(""), + m_algorithmsGroup(std::move(settingsGroup)), m_dirKey("LastDirectory") { // Fill the stored map from the QSettings information load(); } diff --git a/qt/widgets/common/src/AlgorithmPropertiesWidget.cpp b/qt/widgets/common/src/AlgorithmPropertiesWidget.cpp index 6c51bf9ae4641477f8450434735bbabda5009fc8..ffb6d372ccf23b521b5515fac66b0b6e7549b7c2 100644 --- a/qt/widgets/common/src/AlgorithmPropertiesWidget.cpp +++ b/qt/widgets/common/src/AlgorithmPropertiesWidget.cpp @@ -23,6 +23,8 @@ #include <QScrollArea> #include <algorithm> +#include <utility> + #include <vector> using namespace Mantid::Kernel; @@ -98,7 +100,7 @@ Mantid::API::IAlgorithm_sptr AlgorithmPropertiesWidget::getAlgorithm() { * * @param algo :: IAlgorithm bare ptr */ void AlgorithmPropertiesWidget::setAlgorithm( - Mantid::API::IAlgorithm_sptr algo) { + const Mantid::API::IAlgorithm_sptr &algo) { if (!algo) return; saveInput(); @@ -118,7 +120,7 @@ QString AlgorithmPropertiesWidget::getAlgorithmName() const { * @param name :: The algorithm name*/ void AlgorithmPropertiesWidget::setAlgorithmName(QString name) { FrameworkManager::Instance(); - m_algoName = name; + m_algoName = std::move(name); try { Algorithm_sptr alg = AlgorithmManager::Instance().createUnmanaged(m_algoName.toStdString()); diff --git a/qt/widgets/common/src/Batch/RowLocation.cpp b/qt/widgets/common/src/Batch/RowLocation.cpp index 6a1ea542bb9265f9e9971979afea7e2bbf3f55f1..17a93674670c82ec90a9b0cca14e4a4829563f95 100644 --- a/qt/widgets/common/src/Batch/RowLocation.cpp +++ b/qt/widgets/common/src/Batch/RowLocation.cpp @@ -7,6 +7,7 @@ #include "MantidQtWidgets/Common/Batch/RowLocation.h" #include "MantidQtWidgets/Common/Batch/AssertOrThrow.h" #include <boost/algorithm/string/predicate.hpp> +#include <utility> #include "MantidQtWidgets/Common/Batch/equal.hpp" // equivalent to @@ -18,7 +19,7 @@ namespace MantidQt { namespace MantidWidgets { namespace Batch { -RowLocation::RowLocation(RowPath path) : m_path(path) {} +RowLocation::RowLocation(RowPath path) : m_path(std::move(path)) {} RowPath const &RowLocation::path() const { return m_path; } int RowLocation::rowRelativeToParent() const { return m_path.back(); } bool RowLocation::isRoot() const { return m_path.empty(); } diff --git a/qt/widgets/common/src/BatchAlgorithmRunner.cpp b/qt/widgets/common/src/BatchAlgorithmRunner.cpp index 28b47469e2f2d00b6051260b571dcc4c8abcfe39..a7aea0cff7ee7c9e266c26faf84a9558e59c9f54 100644 --- a/qt/widgets/common/src/BatchAlgorithmRunner.cpp +++ b/qt/widgets/common/src/BatchAlgorithmRunner.cpp @@ -4,6 +4,8 @@ // NScD Oak Ridge National Laboratory, European Spallation Source, // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + +#include <utility> + #include "MantidQtWidgets/Common/BatchAlgorithmRunner.h" #include "MantidAPI/AlgorithmManager.h" @@ -20,7 +22,7 @@ namespace API { ConfiguredAlgorithm::ConfiguredAlgorithm(Mantid::API::IAlgorithm_sptr algorithm, AlgorithmRuntimeProps properties) - : m_algorithm(algorithm), m_properties(std::move(properties)) {} + : m_algorithm(std::move(algorithm)), m_properties(std::move(properties)) {} ConfiguredAlgorithm::~ConfiguredAlgorithm() {} @@ -82,8 +84,8 @@ void BatchAlgorithmRunner::stopOnFailure(bool stopOnFailure) { * @param props Optional map of property name to property values to be set just *before execution (mainly intended for input and inout workspace names) */ -void BatchAlgorithmRunner::addAlgorithm(IAlgorithm_sptr algo, - AlgorithmRuntimeProps props) { +void BatchAlgorithmRunner::addAlgorithm(const IAlgorithm_sptr &algo, + const AlgorithmRuntimeProps &props) { m_algorithms.emplace_back(std::make_unique<ConfiguredAlgorithm>(algo, props)); g_log.debug() << "Added algorithm \"" @@ -216,7 +218,8 @@ bool BatchAlgorithmRunner::executeBatchAsyncImpl( * @param algorithm Algorithm and properties to assign to it * @return False if algorithm execution failed */ -bool BatchAlgorithmRunner::executeAlgo(IConfiguredAlgorithm_sptr algorithm) { +bool BatchAlgorithmRunner::executeAlgo( + const IConfiguredAlgorithm_sptr &algorithm) { try { m_currentAlgorithm = algorithm->algorithm(); diff --git a/qt/widgets/common/src/CatalogSearch.cpp b/qt/widgets/common/src/CatalogSearch.cpp index 7ac9b3a457de92b352c07df86e3eac08c41e717a..e7e59c70eb28a0cb232506c57172e03052d8e29a 100644 --- a/qt/widgets/common/src/CatalogSearch.cpp +++ b/qt/widgets/common/src/CatalogSearch.cpp @@ -576,7 +576,7 @@ bool CatalogSearch::validateDates() { return ret; } -void CatalogSearch::correctedToolTip(std::string text, QLabel *label) { +void CatalogSearch::correctedToolTip(const std::string &text, QLabel *label) { #ifdef Q_OS_WIN label->setToolTip(QString::fromStdString("<span style=\"color: black;\">" + text + "</span>")); @@ -1121,7 +1121,7 @@ void CatalogSearch::updateDataFileLabels(QTableWidgetItem *item) { * @return A set containing all file extensions. */ std::unordered_set<std::string> -CatalogSearch::getDataFileExtensions(Mantid::API::Column_sptr column) { +CatalogSearch::getDataFileExtensions(const Mantid::API::Column_sptr &column) { std::unordered_set<std::string> extensions; // For every filename in the column... diff --git a/qt/widgets/common/src/ConvolutionFunctionModel.cpp b/qt/widgets/common/src/ConvolutionFunctionModel.cpp index 1caaf25bd7e649dfe090919f58d156936457da57..b67f48c0105da4a1fc7b9bfe83e0db4befed4e3d 100644 --- a/qt/widgets/common/src/ConvolutionFunctionModel.cpp +++ b/qt/widgets/common/src/ConvolutionFunctionModel.cpp @@ -12,6 +12,7 @@ #include "MantidKernel/Logger.h" #include "MantidQtWidgets/Common/FunctionBrowser/FunctionBrowserUtils.h" #include <iostream> +#include <utility> namespace { Mantid::Kernel::Logger g_log("ConvolutionFunctionModel"); @@ -112,7 +113,7 @@ void ConvolutionFunctionModel::setModel( CompositeFunction_sptr ConvolutionFunctionModel::addBackground(CompositeFunction_sptr domainFunction, - std::string background) { + const std::string &background) { if (background.empty()) return domainFunction; @@ -126,7 +127,7 @@ ConvolutionFunctionModel::addBackground(CompositeFunction_sptr domainFunction, } CompositeFunction_sptr ConvolutionFunctionModel::createInnerFunction( - std::string peaksFunction, bool hasDeltaFunction, bool isQDependent, + const std::string &peaksFunction, bool hasDeltaFunction, bool isQDependent, double qValue, bool hasTempCorrection, double tempValue) { auto functionSpecified = !peaksFunction.empty(); CompositeFunction_sptr innerFunction = @@ -169,7 +170,7 @@ CompositeFunction_sptr ConvolutionFunctionModel::createInnerFunction( } CompositeFunction_sptr ConvolutionFunctionModel::addTempCorrection( - CompositeFunction_sptr peaksFunction, double tempValue) { + const CompositeFunction_sptr &peaksFunction, double tempValue) { CompositeFunction_sptr productFunction = boost::dynamic_pointer_cast<CompositeFunction>( FunctionFactory::Instance().createFunction("ProductFunction")); @@ -194,11 +195,11 @@ ConvolutionFunctionModel::createTemperatureCorrection(double correction) { } CompositeFunction_sptr ConvolutionFunctionModel::createConvolutionFunction( - IFunction_sptr resolutionFunction, IFunction_sptr innerFunction) { + IFunction_sptr resolutionFunction, const IFunction_sptr &innerFunction) { CompositeFunction_sptr convolution = boost::dynamic_pointer_cast<CompositeFunction>( FunctionFactory::Instance().createFunction("Convolution")); - convolution->addFunction(resolutionFunction); + convolution->addFunction(std::move(resolutionFunction)); if (innerFunction->nFunctions() > 0) convolution->addFunction(innerFunction); @@ -206,9 +207,8 @@ CompositeFunction_sptr ConvolutionFunctionModel::createConvolutionFunction( return convolution; } -IFunction_sptr -ConvolutionFunctionModel::createResolutionFunction(std::string workspaceName, - int workspaceIndex) { +IFunction_sptr ConvolutionFunctionModel::createResolutionFunction( + const std::string &workspaceName, int workspaceIndex) { std::string resolution = workspaceName.empty() ? "name=Resolution" diff --git a/qt/widgets/common/src/DataProcessorUI/AbstractTreeModel.cpp b/qt/widgets/common/src/DataProcessorUI/AbstractTreeModel.cpp index 2d8eae3ddd683aa34c46a2e2d85398c6b86bee9b..f5ea73451f7e3f6790bc04ca84f41d7a7e74b875 100644 --- a/qt/widgets/common/src/DataProcessorUI/AbstractTreeModel.cpp +++ b/qt/widgets/common/src/DataProcessorUI/AbstractTreeModel.cpp @@ -4,9 +4,11 @@ // NScD Oak Ridge National Laboratory, European Spallation Source, // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + -#include "MantidQtWidgets/Common/DataProcessorUI/AbstractTreeModel.h" +#include <utility> + #include "MantidAPI/ITableWorkspace.h" #include "MantidAPI/TableRow.h" +#include "MantidQtWidgets/Common/DataProcessorUI/AbstractTreeModel.h" namespace MantidQt { namespace MantidWidgets { @@ -21,7 +23,7 @@ using namespace Mantid::API; */ AbstractTreeModel::AbstractTreeModel(ITableWorkspace_sptr tableWorkspace, const WhiteList &whitelist) - : m_tWS(tableWorkspace), m_whitelist(whitelist) {} + : m_tWS(std::move(tableWorkspace)), m_whitelist(whitelist) {} AbstractTreeModel::~AbstractTreeModel() {} diff --git a/qt/widgets/common/src/DataProcessorUI/GenerateNotebook.cpp b/qt/widgets/common/src/DataProcessorUI/GenerateNotebook.cpp index d7de335e5dfed0167e4994c88db712f6990dd548..17f11bedd75fec12b0a951b7776a7ee5b3ac5a1d 100644 --- a/qt/widgets/common/src/DataProcessorUI/GenerateNotebook.cpp +++ b/qt/widgets/common/src/DataProcessorUI/GenerateNotebook.cpp @@ -51,9 +51,9 @@ the corresponding hinting line edit in the view @returns ipython notebook string */ GenerateNotebook::GenerateNotebook( - QString name, QString instrument, WhiteList whitelist, + const QString &name, const QString &instrument, WhiteList whitelist, std::map<QString, PreprocessingAlgorithm> preprocessMap, - ProcessingAlgorithm processor, + const ProcessingAlgorithm &processor, boost::optional<PostprocessingStep> postprocessingStep, ColumnOptionsMap preprocessingOptionsMap) : m_wsName(std::move(name)), m_instrument(std::move(instrument)), @@ -391,7 +391,7 @@ void addProperties(QStringList &algProperties, const Map &optionsMap) { second item are the names of the output workspaces. */ QString -reduceRowString(const RowData_sptr data, const QString &instrument, +reduceRowString(const RowData_sptr &data, const QString &instrument, const WhiteList &whitelist, const std::map<QString, PreprocessingAlgorithm> &preprocessMap, const ProcessingAlgorithm &processor, diff --git a/qt/widgets/common/src/DataProcessorUI/GenericDataProcessorPresenter.cpp b/qt/widgets/common/src/DataProcessorUI/GenericDataProcessorPresenter.cpp index 405d70d087629cabe34e907ad06751c6959c25a9..dbb8011a087ee37dc331c2e606d63c9fd0853a25 100644 --- a/qt/widgets/common/src/DataProcessorUI/GenericDataProcessorPresenter.cpp +++ b/qt/widgets/common/src/DataProcessorUI/GenericDataProcessorPresenter.cpp @@ -37,6 +37,7 @@ #include <fstream> #include <iterator> #include <sstream> +#include <utility> using namespace Mantid::API; using namespace Mantid::Geometry; @@ -80,7 +81,7 @@ template <typename T> void pop_front(std::vector<T> &queue) { /** Validate the algorithm inputs * @return : an error message, or empty string if ok */ -std::string validateAlgorithmInputs(IAlgorithm_sptr alg) { +std::string validateAlgorithmInputs(const IAlgorithm_sptr &alg) { std::string error; // Get input property errors as a map auto errorMap = alg->validateInputs(); @@ -115,8 +116,9 @@ namespace DataProcessor { GenericDataProcessorPresenter::GenericDataProcessorPresenter( WhiteList whitelist, std::map<QString, PreprocessingAlgorithm> preprocessMap, - ProcessingAlgorithm processor, PostprocessingAlgorithm postprocessor, - int group, std::map<QString, QString> postprocessMap, QString loader) + const ProcessingAlgorithm &processor, + const PostprocessingAlgorithm &postprocessor, int group, + std::map<QString, QString> postprocessMap, const QString &loader) : WorkspaceObserver(), m_view(nullptr), m_progressView(nullptr), m_mainPresenter(), m_loader(std::move(loader)), m_reductionPaused(true), m_postprocessing(postprocessor.name().isEmpty() @@ -178,8 +180,8 @@ GenericDataProcessorPresenter::GenericDataProcessorPresenter( * (reflectometry). */ GenericDataProcessorPresenter::GenericDataProcessorPresenter( - WhiteList whitelist, ProcessingAlgorithm processor, - PostprocessingAlgorithm postprocessor, int group) + WhiteList whitelist, const ProcessingAlgorithm &processor, + const PostprocessingAlgorithm &postprocessor, int group) : GenericDataProcessorPresenter( std::move(whitelist), std::map<QString, PreprocessingAlgorithm>(), std::move(processor), std::move(postprocessor), group) {} @@ -208,7 +210,7 @@ GenericDataProcessorPresenter::GenericDataProcessorPresenter( GenericDataProcessorPresenter::GenericDataProcessorPresenter( WhiteList whitelist, std::map<QString, PreprocessingAlgorithm> preprocessMap, - ProcessingAlgorithm processor, int group) + const ProcessingAlgorithm &processor, int group) : GenericDataProcessorPresenter( std::move(whitelist), std::move(preprocessMap), std::move(processor), PostprocessingAlgorithm(), group) {} @@ -222,7 +224,7 @@ GenericDataProcessorPresenter::GenericDataProcessorPresenter( * (reflectometry) */ GenericDataProcessorPresenter::GenericDataProcessorPresenter( - WhiteList whitelist, ProcessingAlgorithm processor, int group) + WhiteList whitelist, const ProcessingAlgorithm &processor, int group) : GenericDataProcessorPresenter( std::move(whitelist), std::map<QString, PreprocessingAlgorithm>(), std::move(processor), PostprocessingAlgorithm(), group) {} @@ -233,7 +235,7 @@ GenericDataProcessorPresenter::GenericDataProcessorPresenter( GenericDataProcessorPresenter::~GenericDataProcessorPresenter() {} namespace { -std::vector<std::string> toStdStringVector(std::set<QString> in) { +std::vector<std::string> toStdStringVector(const std::set<QString> &in) { auto out = std::vector<std::string>(); std::transform( in.cbegin(), in.cend(), std::back_inserter(out), @@ -320,7 +322,7 @@ Returns the name of the reduced workspace for a given row @returns : The name of the workspace */ QString GenericDataProcessorPresenter::getReducedWorkspaceName( - const RowData_sptr data) const { + const RowData_sptr &data) const { return MantidQt::MantidWidgets::DataProcessor::getReducedWorkspaceName( data, m_whitelist, m_preprocessing.m_map); } @@ -356,13 +358,13 @@ void GenericDataProcessorPresenter::setGroupError(const int groupIndex, m_manager->setError(error, groupIndex); } -void GenericDataProcessorPresenter::setRowIsProcessed(RowData_sptr rowData, - const bool isProcessed) { +void GenericDataProcessorPresenter::setRowIsProcessed( + const RowData_sptr &rowData, const bool isProcessed) { if (rowData) rowData->setProcessed(isProcessed); } -void GenericDataProcessorPresenter::setRowError(RowData_sptr rowData, +void GenericDataProcessorPresenter::setRowError(const RowData_sptr &rowData, const std::string &error) { if (rowData) rowData->setError(error); @@ -439,7 +441,7 @@ bool GenericDataProcessorPresenter::workspaceIsOutputOfGroup( } bool GenericDataProcessorPresenter::workspaceIsOutputOfRow( - RowData_sptr rowData, const std::string &workspaceName) const { + const RowData_sptr &rowData, const std::string &workspaceName) const { if (!rowData) return false; @@ -458,7 +460,8 @@ void GenericDataProcessorPresenter::resetProcessedState(const int groupIndex) { /** Reset the processed state for a row */ -void GenericDataProcessorPresenter::resetProcessedState(RowData_sptr rowData) { +void GenericDataProcessorPresenter::resetProcessedState( + const RowData_sptr &rowData) { rowData->reset(); } @@ -505,7 +508,8 @@ void GenericDataProcessorPresenter::resetProcessedState() { * @param rowData [inout] : the data to initialise * @return : true if ok, false if there was a problem */ -bool GenericDataProcessorPresenter::initRowForProcessing(RowData_sptr rowData) { +bool GenericDataProcessorPresenter::initRowForProcessing( + const RowData_sptr &rowData) { // Reset the row to its unprocessed state rowData->reset(); @@ -575,7 +579,7 @@ bool GenericDataProcessorPresenter::groupNeedsProcessing( /** Check whether a row should be processed */ bool GenericDataProcessorPresenter::rowNeedsProcessing( - RowData_sptr rowData) const { + const RowData_sptr &rowData) const { if (m_forceProcessing) return true; @@ -591,7 +595,7 @@ bool GenericDataProcessorPresenter::rowNeedsProcessing( /** Process a given set of items */ void GenericDataProcessorPresenter::process(TreeData itemsToProcess) { - m_itemsToProcess = itemsToProcess; + m_itemsToProcess = std::move(itemsToProcess); // Emit a signal that the process is starting m_view->emitProcessClicked(); @@ -707,7 +711,7 @@ void GenericDataProcessorPresenter::startAsyncRowReduceThread( RowData_sptr rowData, const int rowIndex, const int groupIndex) { auto *worker = new GenericDataProcessorPresenterRowReducerWorker( - this, rowData, rowIndex, groupIndex); + this, std::move(rowData), rowIndex, groupIndex); connect(worker, SIGNAL(finished(int)), this, SLOT(rowThreadFinished(int))); connect(worker, SIGNAL(reductionErrorSignal(QString)), this, @@ -960,7 +964,8 @@ QString GenericDataProcessorPresenter::getPostprocessedWorkspaceName( if (!hasPostprocessing()) throw std::runtime_error("Attempted to get postprocessing workspace but no " "postprocessing is specified."); - return m_postprocessing->getPostprocessedWorkspaceName(groupData, sliceIndex); + return m_postprocessing->getPostprocessedWorkspaceName(groupData, + std::move(sliceIndex)); } /** Loads a run found from disk or AnalysisDataService @@ -1089,7 +1094,7 @@ GenericDataProcessorPresenter::createProcessingAlgorithm() const { * @param data [in] :: the data in the row */ void GenericDataProcessorPresenter::preprocessColumnValue( - const QString &columnName, QString &columnValue, RowData_sptr data) { + const QString &columnName, QString &columnValue, const RowData_sptr &data) { // Check if preprocessing is required for this column if (!m_preprocessing.hasPreprocessing(columnName)) return; @@ -1099,7 +1104,8 @@ void GenericDataProcessorPresenter::preprocessColumnValue( OptionsMap options; if (m_preprocessing.hasOptions(columnName)) { auto globalOptions = m_preprocessing.m_options.at(columnName); - options = getCanonicalOptions(data, globalOptions, m_whitelist, false); + options = + getCanonicalOptions(std::move(data), globalOptions, m_whitelist, false); } // Run the preprocessing algorithm @@ -1112,7 +1118,8 @@ void GenericDataProcessorPresenter::preprocessColumnValue( /** Perform preprocessing on algorithm property values where applicable * @param data : the data in the row */ -void GenericDataProcessorPresenter::preprocessOptionValues(RowData_sptr data) { +void GenericDataProcessorPresenter::preprocessOptionValues( + const RowData_sptr &data) { auto options = data->options(); // Loop through all columns (excluding the Options and Hidden options // columns) @@ -1137,8 +1144,8 @@ void GenericDataProcessorPresenter::preprocessOptionValues(RowData_sptr data) { * @param alg : the executed algorithm * @param data : the row data */ -void GenericDataProcessorPresenter::updateModelFromResults(IAlgorithm_sptr alg, - RowData_sptr data) { +void GenericDataProcessorPresenter::updateModelFromResults( + const IAlgorithm_sptr &alg, const RowData_sptr &data) { auto newData = data; @@ -1221,7 +1228,7 @@ IAlgorithm_sptr GenericDataProcessorPresenter::createAndRunAlgorithm( * correspond to column contents * @throws std::runtime_error if reduction fails */ -void GenericDataProcessorPresenter::reduceRow(RowData_sptr data) { +void GenericDataProcessorPresenter::reduceRow(const RowData_sptr &data) { // Perform any preprocessing on the input properties and cache the results // in the row data diff --git a/qt/widgets/common/src/DataProcessorUI/OneLevelTreeManager.cpp b/qt/widgets/common/src/DataProcessorUI/OneLevelTreeManager.cpp index 03694d1dfeb8fb620624f459f8818a6e2158065e..5218be72ac0894ec182e93204941df26d3cca433 100644 --- a/qt/widgets/common/src/DataProcessorUI/OneLevelTreeManager.cpp +++ b/qt/widgets/common/src/DataProcessorUI/OneLevelTreeManager.cpp @@ -30,6 +30,7 @@ #include <boost/algorithm/string/classification.hpp> #include <boost/algorithm/string/join.hpp> #include <boost/algorithm/string/split.hpp> +#include <utility> using namespace Mantid::API; using namespace Mantid::Kernel; @@ -46,10 +47,10 @@ namespace DataProcessor { * @param whitelist :: a whitelist */ OneLevelTreeManager::OneLevelTreeManager( - DataProcessorPresenter *presenter, Mantid::API::ITableWorkspace_sptr table, - const WhiteList &whitelist) + DataProcessorPresenter *presenter, + const Mantid::API::ITableWorkspace_sptr &table, const WhiteList &whitelist) : m_presenter(presenter), - m_model(new QOneLevelTreeModel(table, whitelist)) {} + m_model(new QOneLevelTreeModel(std::move(table), whitelist)) {} /** * Constructor (no table workspace given) @@ -323,7 +324,7 @@ std::set<int> OneLevelTreeManager::getRowsToProcess(bool shouldPrompt) const { * @return :: All data as a map where keys are units of post-processing (i.e. * group indices) and values are a map of row index in the group to row data */ -TreeData OneLevelTreeManager::constructTreeData(std::set<int> rows) { +TreeData OneLevelTreeManager::constructTreeData(const std::set<int> &rows) { // Return data in the format: map<int, set<RowData_sptr>>, where: // int -> row index @@ -525,7 +526,7 @@ OneLevelTreeManager::createDefaultWorkspace(const WhiteList &whitelist) { * @param ws :: the table workspace * @param whitelistColumns :: the number of columns as specified in a whitelist */ -void OneLevelTreeManager::validateModel(ITableWorkspace_sptr ws, +void OneLevelTreeManager::validateModel(const ITableWorkspace_sptr &ws, size_t whitelistColumns) const { if (!ws) diff --git a/qt/widgets/common/src/DataProcessorUI/PostprocessingStep.cpp b/qt/widgets/common/src/DataProcessorUI/PostprocessingStep.cpp index 5a101cb911c56a5fc732db8299b40aa2d74a645e..eb731cdc8e42bbcbc5d2f6869f575fb4e764aaed 100644 --- a/qt/widgets/common/src/DataProcessorUI/PostprocessingStep.cpp +++ b/qt/widgets/common/src/DataProcessorUI/PostprocessingStep.cpp @@ -10,10 +10,10 @@ namespace MantidQt { namespace MantidWidgets { namespace DataProcessor { -PostprocessingStep::PostprocessingStep(QString options) +PostprocessingStep::PostprocessingStep(const QString &options) : m_options(std::move(options)) {} -PostprocessingStep::PostprocessingStep(QString options, - PostprocessingAlgorithm algorithm, +PostprocessingStep::PostprocessingStep(const QString &options, + const PostprocessingAlgorithm &algorithm, std::map<QString, QString> map) : m_options(std::move(options)), m_algorithm(std::move(algorithm)), m_map(std::move(map)) {} diff --git a/qt/widgets/common/src/DataProcessorUI/PreprocessingAlgorithm.cpp b/qt/widgets/common/src/DataProcessorUI/PreprocessingAlgorithm.cpp index 3ec222ce2dc0c85c52c7390b39a0dd106750c4d5..b17a8ca3bb352852b787994098ee7d27ef7dd4be 100644 --- a/qt/widgets/common/src/DataProcessorUI/PreprocessingAlgorithm.cpp +++ b/qt/widgets/common/src/DataProcessorUI/PreprocessingAlgorithm.cpp @@ -18,9 +18,9 @@ namespace DataProcessor { * @param blacklist : The list of properties we don't want to show * algorithm in the processed workspace's name */ -PreprocessingAlgorithm::PreprocessingAlgorithm(QString name, QString prefix, - QString separator, - std::set<QString> blacklist) +PreprocessingAlgorithm::PreprocessingAlgorithm( + const QString &name, const QString &prefix, const QString &separator, + const std::set<QString> &blacklist) : ProcessingAlgorithmBase(std::move(name), std::move(blacklist)), m_prefix(std::move(prefix)), m_separator(std::move(separator)) { @@ -53,8 +53,9 @@ PreprocessingAlgorithm::PreprocessingAlgorithm(QString name, QString prefix, * @param blacklist : The list of properties we don't want to show, as a string * algorithm in the processed workspace's name */ -PreprocessingAlgorithm::PreprocessingAlgorithm(QString name, QString prefix, - QString separator, +PreprocessingAlgorithm::PreprocessingAlgorithm(const QString &name, + const QString &prefix, + const QString &separator, const QString &blacklist) : PreprocessingAlgorithm(std::move(name), std::move(prefix), std::move(separator), diff --git a/qt/widgets/common/src/DataProcessorUI/ProcessingAlgorithm.cpp b/qt/widgets/common/src/DataProcessorUI/ProcessingAlgorithm.cpp index b470b1bfbb950e8769b90b296307929795d9de13..186423fd86081ed795f0e7d1bc67fb1b36d267b1 100644 --- a/qt/widgets/common/src/DataProcessorUI/ProcessingAlgorithm.cpp +++ b/qt/widgets/common/src/DataProcessorUI/ProcessingAlgorithm.cpp @@ -21,9 +21,9 @@ namespace DataProcessor { * indicate the most recent version. */ ProcessingAlgorithm::ProcessingAlgorithm( - QString name, std::vector<QString> prefix, - std::size_t postprocessedOutputPrefixIndex, std::set<QString> blacklist, - const int version) + const QString &name, std::vector<QString> prefix, + std::size_t postprocessedOutputPrefixIndex, + const std::set<QString> &blacklist, const int version) : ProcessingAlgorithmBase(std::move(name), std::move(blacklist), version), m_postprocessedOutputPrefixIndex(postprocessedOutputPrefixIndex), m_prefix(std::move(prefix)) { @@ -63,7 +63,7 @@ ProcessingAlgorithm::ProcessingAlgorithm( * indicate the most recent version. */ ProcessingAlgorithm::ProcessingAlgorithm( - QString name, QString const &prefix, + const QString &name, QString const &prefix, std::size_t postprocessedOutputPrefixIndex, QString const &blacklist, const int version) : ProcessingAlgorithm(std::move(name), convertStringToVector(prefix), diff --git a/qt/widgets/common/src/DataProcessorUI/QOneLevelTreeModel.cpp b/qt/widgets/common/src/DataProcessorUI/QOneLevelTreeModel.cpp index d8b577cc69eb19192f4491c9f15f263ad1ec1bd5..8e417ba67f655f61a02841d473c71c7ce67e1abe 100644 --- a/qt/widgets/common/src/DataProcessorUI/QOneLevelTreeModel.cpp +++ b/qt/widgets/common/src/DataProcessorUI/QOneLevelTreeModel.cpp @@ -19,8 +19,8 @@ using namespace Mantid::API; @param tableWorkspace : The table workspace to wrap @param whitelist : A WhiteList containing the columns */ -QOneLevelTreeModel::QOneLevelTreeModel(ITableWorkspace_sptr tableWorkspace, - const WhiteList &whitelist) +QOneLevelTreeModel::QOneLevelTreeModel( + const ITableWorkspace_sptr &tableWorkspace, const WhiteList &whitelist) : AbstractTreeModel(tableWorkspace, whitelist) { if (tableWorkspace->columnCount() != m_whitelist.size()) diff --git a/qt/widgets/common/src/DataProcessorUI/QTwoLevelTreeModel.cpp b/qt/widgets/common/src/DataProcessorUI/QTwoLevelTreeModel.cpp index 57a1a32609755a13b8176e1514556bfd26bb632a..7f6e3707c40cd70c660db545525326eb0f31d50d 100644 --- a/qt/widgets/common/src/DataProcessorUI/QTwoLevelTreeModel.cpp +++ b/qt/widgets/common/src/DataProcessorUI/QTwoLevelTreeModel.cpp @@ -25,7 +25,7 @@ public: : m_absoluteIndex(absoluteIndex), m_rowData(std::make_shared<RowData>(columnCount)) {} // Constructor taking a list of data values - RowInfo(const size_t absoluteIndex, QStringList rowDataValues) + RowInfo(const size_t absoluteIndex, const QStringList &rowDataValues) : m_absoluteIndex(absoluteIndex), m_rowData(std::make_shared<RowData>(std::move(rowDataValues))) {} @@ -174,8 +174,8 @@ private: @param whitelist : A WhiteList containing information about the columns, their indices and descriptions */ -QTwoLevelTreeModel::QTwoLevelTreeModel(ITableWorkspace_sptr tableWorkspace, - const WhiteList &whitelist) +QTwoLevelTreeModel::QTwoLevelTreeModel( + const ITableWorkspace_sptr &tableWorkspace, const WhiteList &whitelist) : AbstractTreeModel(tableWorkspace, whitelist) { if (tableWorkspace->columnCount() != m_whitelist.size() + 1) @@ -786,7 +786,7 @@ bool QTwoLevelTreeModel::setData(const QModelIndex &index, * whitelist * @param table : A table workspace containing the data */ -void QTwoLevelTreeModel::setupModelData(ITableWorkspace_sptr table) { +void QTwoLevelTreeModel::setupModelData(const ITableWorkspace_sptr &table) { int nrows = static_cast<int>(table->rowCount()); diff --git a/qt/widgets/common/src/DataProcessorUI/TreeData.cpp b/qt/widgets/common/src/DataProcessorUI/TreeData.cpp index 566c778c3e31015d635da6c2006405bcad2bd38f..16aa102ccadd71a0ba04c4a967aede03ab9c16bf 100644 --- a/qt/widgets/common/src/DataProcessorUI/TreeData.cpp +++ b/qt/widgets/common/src/DataProcessorUI/TreeData.cpp @@ -18,7 +18,7 @@ RowData::RowData(const int columnCount) : m_isProcessed{false} { m_data.append(""); } -RowData::RowData(QStringList data) +RowData::RowData(const QStringList &data) : m_data(std::move(data)), m_isProcessed{false} {} RowData::RowData(const std::vector<std::string> &data) : m_isProcessed{false} { @@ -311,7 +311,7 @@ bool RowData::reductionFailed() const { * prefixes have been applied for specific output properties. * @param prefix [in] : if not empty, apply this prefix to the name */ -QString RowData::reducedName(const QString prefix) const { +QString RowData::reducedName(const QString &prefix) const { if (prefix.isEmpty()) return m_reducedName; else diff --git a/qt/widgets/common/src/DataProcessorUI/TwoLevelTreeManager.cpp b/qt/widgets/common/src/DataProcessorUI/TwoLevelTreeManager.cpp index 64d2b5e8864954e2f5e4a1a9406af5e293e56739..c78a17311e0595e8d9319bf63827d6fef7dd0bfb 100644 --- a/qt/widgets/common/src/DataProcessorUI/TwoLevelTreeManager.cpp +++ b/qt/widgets/common/src/DataProcessorUI/TwoLevelTreeManager.cpp @@ -39,6 +39,7 @@ #include <boost/algorithm/string/classification.hpp> #include <boost/algorithm/string/join.hpp> #include <boost/algorithm/string/split.hpp> +#include <utility> using namespace Mantid::API; using namespace Mantid::Kernel; @@ -55,10 +56,10 @@ namespace DataProcessor { * @param whitelist :: a whitelist */ TwoLevelTreeManager::TwoLevelTreeManager( - DataProcessorPresenter *presenter, Mantid::API::ITableWorkspace_sptr table, - const WhiteList &whitelist) + DataProcessorPresenter *presenter, + const Mantid::API::ITableWorkspace_sptr &table, const WhiteList &whitelist) : m_presenter(presenter), - m_model(new QTwoLevelTreeModel(table, whitelist)) {} + m_model(new QTwoLevelTreeModel(std::move(table), whitelist)) {} /** * Constructor (no table workspace given) @@ -446,7 +447,7 @@ int TwoLevelTreeManager::numRowsInGroup(int group) const { * @return :: All data as a map where keys are units of post-processing (i.e. * group indices) and values are a map of row index in the group to row data */ -TreeData TwoLevelTreeManager::constructTreeData(ChildItems rows) { +TreeData TwoLevelTreeManager::constructTreeData(const ChildItems &rows) { TreeData tree; const int columnNotUsed = 0; // dummy value required to create index // Return row data in the format: map<int, set<vector<string>>>, where: @@ -722,7 +723,7 @@ TwoLevelTreeManager::createDefaultWorkspace(const WhiteList &whitelist) { * @param ws :: the table workspace * @param whitelistColumns :: the number of columns as specified in a whitelist */ -void TwoLevelTreeManager::validateModel(ITableWorkspace_sptr ws, +void TwoLevelTreeManager::validateModel(const ITableWorkspace_sptr &ws, size_t whitelistColumns) const { if (!ws) diff --git a/qt/widgets/common/src/DataProcessorUI/WorkspaceNameUtils.cpp b/qt/widgets/common/src/DataProcessorUI/WorkspaceNameUtils.cpp index 88563e9f060a9ec3f76fba198a47cb9882689e6a..1dff5796842f1b8f94300f0520c041193480f776 100644 --- a/qt/widgets/common/src/DataProcessorUI/WorkspaceNameUtils.cpp +++ b/qt/widgets/common/src/DataProcessorUI/WorkspaceNameUtils.cpp @@ -27,7 +27,7 @@ namespace { // unnamed namespace * @param allowInsertions : if true, allow new keys to be inserted; * otherwise, only allow updating of keys that already exist */ -void updateRowOptions(OptionsMap &options, const RowData_sptr data, +void updateRowOptions(OptionsMap &options, const RowData_sptr &data, const WhiteList &whitelist, const bool allowInsertions) { // Loop through all columns (excluding the Options and Hidden options // columns) @@ -55,7 +55,7 @@ void updateRowOptions(OptionsMap &options, const RowData_sptr data, * @param allowInsertions : if true, allow new keys to be inserted; * otherwise, only allow updating of keys that already exist */ -void updateUserOptions(OptionsMap &options, const RowData_sptr data, +void updateUserOptions(OptionsMap &options, const RowData_sptr &data, const WhiteList &whitelist, const bool allowInsertions) { auto userOptions = parseKeyValueQString(data->value(static_cast<int>(whitelist.size()) - 2)); @@ -72,7 +72,7 @@ void updateUserOptions(OptionsMap &options, const RowData_sptr data, * @param allowInsertions : if true, allow new keys to be inserted; * otherwise, only allow updating of keys that already exist */ -void updateHiddenOptions(OptionsMap &options, const RowData_sptr data, +void updateHiddenOptions(OptionsMap &options, const RowData_sptr &data, const bool allowInsertions) { const auto hiddenOptions = parseKeyValueQString(data->back()); for (auto &kvp : hiddenOptions) { @@ -86,7 +86,7 @@ void updateHiddenOptions(OptionsMap &options, const RowData_sptr data, * @param options : a map of property name to option value to update * @param data : the data for this row */ -void updateOutputOptions(OptionsMap &options, const RowData_sptr data, +void updateOutputOptions(OptionsMap &options, const RowData_sptr &data, const bool allowInsertions, const std::vector<QString> &outputPropertyNames, const std::vector<QString> &outputNamePrefixes) { @@ -141,7 +141,7 @@ algorithm for that column @returns : The name of the workspace */ QString getReducedWorkspaceName( - const RowData_sptr data, const WhiteList &whitelist, + const RowData_sptr &data, const WhiteList &whitelist, const std::map<QString, PreprocessingAlgorithm> &preprocessMap) { if (data->size() != static_cast<int>(whitelist.size())) throw std::invalid_argument("Can't find reduced workspace name"); @@ -206,7 +206,7 @@ QString getReducedWorkspaceName( * names * @return : a map of property names to value */ -OptionsMap getCanonicalOptions(const RowData_sptr data, +OptionsMap getCanonicalOptions(const RowData_sptr &data, const OptionsMap &globalOptions, const WhiteList &whitelist, const bool allowInsertions, diff --git a/qt/widgets/common/src/DiagResults.cpp b/qt/widgets/common/src/DiagResults.cpp index 66a944e5b7ae3043d185f893e070ba4b46dea858..90b925690a8573bddb92ba1e7fa46052dea8d1e6 100644 --- a/qt/widgets/common/src/DiagResults.cpp +++ b/qt/widgets/common/src/DiagResults.cpp @@ -112,7 +112,8 @@ void DiagResults::updateResults(const QString &testSummary) { // Private member functions //---------------------- /// insert a row at the bottom of the grid -int DiagResults::addRow(QString firstColumn, QString secondColumn) { +int DiagResults::addRow(const QString &firstColumn, + const QString &secondColumn) { // set row to one past the end of the number of rows that currently exist int row = m_Grid->rowCount(); m_Grid->addWidget(new QLabel(firstColumn), row, 0); @@ -124,7 +125,7 @@ int DiagResults::addRow(QString firstColumn, QString secondColumn) { * @param row :: the row where the data will be displayed * @param text :: the text that should be displayed in the first column */ -void DiagResults::updateRow(int row, QString text) { +void DiagResults::updateRow(int row, const QString &text) { // Get the text label from the grid QWidget *widget = m_Grid->itemAtPosition(row, 1)->widget(); QLabel *label = qobject_cast<QLabel *>(widget); diff --git a/qt/widgets/common/src/DoubleSpinBox.cpp b/qt/widgets/common/src/DoubleSpinBox.cpp index f215e3c726a33af56867c757f7cbda3db67ac98c..583cdf5a216a67649a6d06956664737e22fb4eb8 100644 --- a/qt/widgets/common/src/DoubleSpinBox.cpp +++ b/qt/widgets/common/src/DoubleSpinBox.cpp @@ -115,7 +115,7 @@ void DoubleSpinBox::interpretText(bool notify) { * @param text QString with text to map * @param value Value to map it to */ -void DoubleSpinBox::addSpecialTextMapping(QString text, double value) { +void DoubleSpinBox::addSpecialTextMapping(const QString &text, double value) { m_specialTextMappings[text] = value; } diff --git a/qt/widgets/common/src/EditLocalParameterDialog.cpp b/qt/widgets/common/src/EditLocalParameterDialog.cpp index 226cae763bd5cee131834b32bc0e48e371a2ece5..b39f1e02c302505b45000cbe1462276038b7ac61 100644 --- a/qt/widgets/common/src/EditLocalParameterDialog.cpp +++ b/qt/widgets/common/src/EditLocalParameterDialog.cpp @@ -13,6 +13,7 @@ #include <QMenu> #include <QMessageBox> #include <limits> +#include <utility> namespace { QString makeNumber(double d) { return QString::number(d, 'g', 16); } @@ -35,8 +36,8 @@ namespace MantidWidgets { */ EditLocalParameterDialog::EditLocalParameterDialog( QWidget *parent, const QString &parName, const QStringList &wsNames, - QList<double> values, QList<bool> fixes, QStringList ties, - QStringList constraints) + const QList<double> &values, const QList<bool> &fixes, + const QStringList &ties, const QStringList &constraints) : MantidDialog(parent), m_parName(parName), m_values(values), m_fixes(fixes), m_ties(ties), m_constraints(constraints) { assert(values.size() == wsNames.size()); @@ -171,14 +172,14 @@ void EditLocalParameterDialog::fixParameter(int index, bool fix) { /// @param index :: Index of a paramter to tie. /// @param tie :: A tie string. void EditLocalParameterDialog::setTie(int index, QString tie) { - m_ties[index] = tie; + m_ties[index] = std::move(tie); m_fixes[index] = false; updateRoleColumn(index); } /// Set the same tie to all parameters. /// @param tie :: A tie string. -void EditLocalParameterDialog::setTieAll(QString tie) { +void EditLocalParameterDialog::setTieAll(const QString &tie) { for (int i = 0; i < m_ties.size(); ++i) { m_ties[i] = tie; m_fixes[i] = false; @@ -188,11 +189,11 @@ void EditLocalParameterDialog::setTieAll(QString tie) { } void EditLocalParameterDialog::setConstraint(int index, QString constraint) { - m_constraints[index] = constraint; + m_constraints[index] = std::move(constraint); updateRoleColumn(index); } -void EditLocalParameterDialog::setConstraintAll(QString constraint) { +void EditLocalParameterDialog::setConstraintAll(const QString &constraint) { for (int i = 0; i < m_constraints.size(); ++i) { m_constraints[i] = constraint; updateRoleColumn(i); diff --git a/qt/widgets/common/src/FileDialogHandler.cpp b/qt/widgets/common/src/FileDialogHandler.cpp index 8afbe8aef42e9e3d4d1321d7f68b5585df7ba374..aadd30c3ceacf918f95f53ae9307a133cebb45b4 100644 --- a/qt/widgets/common/src/FileDialogHandler.cpp +++ b/qt/widgets/common/src/FileDialogHandler.cpp @@ -41,7 +41,7 @@ namespace FileDialogHandler { */ QString getSaveFileName(QWidget *parent, const Mantid::Kernel::Property *baseProp, - QFileDialog::Options options) { + const QFileDialog::Options &options) { // set up filters and dialog title const auto filter = getFilter(baseProp); const auto caption = getCaption("Save file", baseProp); diff --git a/qt/widgets/common/src/FindFilesThreadPoolManager.cpp b/qt/widgets/common/src/FindFilesThreadPoolManager.cpp index 6fc29255e7cac4ac96699fc190405fa2328528db..2f03ba23f9798699ed33bcb988dc3816e27c6238 100644 --- a/qt/widgets/common/src/FindFilesThreadPoolManager.cpp +++ b/qt/widgets/common/src/FindFilesThreadPoolManager.cpp @@ -17,6 +17,7 @@ #include <QCoreApplication> #include <QSharedPointer> #include <boost/algorithm/string.hpp> +#include <utility> using namespace Mantid::Kernel; using namespace Mantid::API; @@ -63,7 +64,7 @@ FindFilesThreadPoolManager::FindFilesThreadPoolManager() { * worker objects */ void FindFilesThreadPoolManager::setAllocator(ThreadAllocator allocator) { - m_workerAllocator = allocator; + m_workerAllocator = std::move(allocator); } void FindFilesThreadPoolManager::createWorker( diff --git a/qt/widgets/common/src/FitOptionsBrowser.cpp b/qt/widgets/common/src/FitOptionsBrowser.cpp index c964e6f595da80a1e1b3a639d1da9c0ae209c901..83b2719810143120570e5972075f49c14717b4b0 100644 --- a/qt/widgets/common/src/FitOptionsBrowser.cpp +++ b/qt/widgets/common/src/FitOptionsBrowser.cpp @@ -838,7 +838,7 @@ void FitOptionsBrowser::displayProperty(const QString &propertyName, /** * Adds the property with the given name to a blacklist of properties to hide */ -bool FitOptionsBrowser::addPropertyToBlacklist(QString name) { +bool FitOptionsBrowser::addPropertyToBlacklist(const QString &name) { if (!m_propertyNameMap.contains(name)) { return false; } diff --git a/qt/widgets/common/src/FitPropertyBrowser.cpp b/qt/widgets/common/src/FitPropertyBrowser.cpp index 25d268dc758f4c189c68e434b7487794dab52586..1d75b9d193c2639287f0ee9cc793c2328a8bf748 100644 --- a/qt/widgets/common/src/FitPropertyBrowser.cpp +++ b/qt/widgets/common/src/FitPropertyBrowser.cpp @@ -55,6 +55,7 @@ #include <QVBoxLayout> #include <algorithm> +#include <utility> namespace MantidQt { using API::MantidDesktopServices; @@ -66,7 +67,7 @@ Mantid::Kernel::Logger g_log("FitPropertyBrowser"); using namespace Mantid::API; -int getNumberOfSpectra(MatrixWorkspace_sptr workspace) { +int getNumberOfSpectra(const MatrixWorkspace_sptr &workspace) { return static_cast<int>(workspace->getNumberHistograms()); } @@ -774,7 +775,7 @@ void FitPropertyBrowser::closeFit() { m_fitSelector->close(); } * @param func :: [input] Pointer to function */ void FitPropertyBrowser::createCompositeFunction( - const Mantid::API::IFunction_sptr func) { + const Mantid::API::IFunction_sptr &func) { if (m_compositeFunction) { emit functionRemoved(); m_autoBackground = nullptr; @@ -1598,8 +1599,8 @@ void FitPropertyBrowser::setCurrentFunction(PropertyHandler *h) const { * @param f :: New current function */ void FitPropertyBrowser::setCurrentFunction( - Mantid::API::IFunction_const_sptr f) const { - setCurrentFunction(getHandler()->findHandler(f)); + const Mantid::API::IFunction_const_sptr &f) const { + setCurrentFunction(getHandler()->findHandler(std::move(f))); } /** @@ -2716,7 +2717,7 @@ void FitPropertyBrowser::reset() { } void FitPropertyBrowser::setWorkspace( - Mantid::API::IFunction_sptr function) const { + const Mantid::API::IFunction_sptr &function) const { std::string wsName = workspaceName(); if (!wsName.empty()) { try { @@ -2979,7 +2980,7 @@ bool FitPropertyBrowser::rawData() const { return m_boolManager->value(m_rawData); } -void FitPropertyBrowser::setTextPlotGuess(const QString text) { +void FitPropertyBrowser::setTextPlotGuess(const QString &text) { m_displayActionPlotGuess->setText(text); } diff --git a/qt/widgets/common/src/FunctionBrowser.cpp b/qt/widgets/common/src/FunctionBrowser.cpp index b207df97dc17b6a19ae9923892d06500ded6ff9b..6824ab9ea5bb7ee3cae3b9bc55dadb3f77f3c5c7 100644 --- a/qt/widgets/common/src/FunctionBrowser.cpp +++ b/qt/widgets/common/src/FunctionBrowser.cpp @@ -25,6 +25,7 @@ #include <algorithm> #include <boost/lexical_cast.hpp> +#include <utility> namespace { Mantid::Kernel::Logger g_log("Function Browser"); @@ -81,7 +82,7 @@ void FunctionBrowser::setFunction(const QString &funStr) { * @param fun :: A function */ void FunctionBrowser::setFunction(IFunction_sptr fun) { - m_presenter->setFunction(fun); + m_presenter->setFunction(std::move(fun)); } /** @@ -199,8 +200,8 @@ void FunctionBrowser::setCurrentDataset(int i) { /// Remove local parameter values for a number of datasets. /// @param indices :: A list of indices of datasets to remove. -void FunctionBrowser::removeDatasets(QList<int> indices) { - m_presenter->removeDatasets(indices); +void FunctionBrowser::removeDatasets(const QList<int> &indices) { + m_presenter->removeDatasets(std::move(indices)); } /// Add some datasets to those already set. diff --git a/qt/widgets/common/src/FunctionModel.cpp b/qt/widgets/common/src/FunctionModel.cpp index 2d74d736d6a4418809fd8a8c53d6bd1e4af9db80..6109e3be89a85e86e6faf8752d78f064a590f991 100644 --- a/qt/widgets/common/src/FunctionModel.cpp +++ b/qt/widgets/common/src/FunctionModel.cpp @@ -178,7 +178,8 @@ void FunctionModel::setParameterFixed(const QString &parName, bool fixed) { fixed); } -void FunctionModel::setParameterTie(const QString &parName, QString tie) { +void FunctionModel::setParameterTie(const QString &parName, + const QString &tie) { setLocalParameterTie(parName, static_cast<int>(m_currentDomainIndex), tie); } diff --git a/qt/widgets/common/src/FunctionMultiDomainPresenter.cpp b/qt/widgets/common/src/FunctionMultiDomainPresenter.cpp index 54b5abade8cd2eb374199d1c36a08fe3ef8ed1aa..f6877ec980c03b52209a6d1b6690ae68d98c4cbc 100644 --- a/qt/widgets/common/src/FunctionMultiDomainPresenter.cpp +++ b/qt/widgets/common/src/FunctionMultiDomainPresenter.cpp @@ -17,6 +17,7 @@ #include <QClipboard> #include <QMessageBox> #include <QWidget> +#include <utility> namespace MantidQt { namespace MantidWidgets { @@ -51,7 +52,7 @@ FunctionMultiDomainPresenter::FunctionMultiDomainPresenter(IFunctionView *view) } void FunctionMultiDomainPresenter::setFunction(IFunction_sptr fun) { - m_model->setFunction(fun); + m_model->setFunction(std::move(fun)); m_view->setFunction(m_model->getCurrentFunction()); emit functionStructureChanged(); } @@ -224,7 +225,8 @@ void FunctionMultiDomainPresenter::setLocalParameterFixed( } void FunctionMultiDomainPresenter::setLocalParameterTie(const QString &parName, - int i, QString tie) { + int i, + const QString &tie) { m_model->setLocalParameterTie(parName, i, tie); if (m_model->currentDomainIndex() == i) { m_view->setParameterTie(parName, tie); @@ -232,7 +234,7 @@ void FunctionMultiDomainPresenter::setLocalParameterTie(const QString &parName, } void FunctionMultiDomainPresenter::setLocalParameterConstraint( - const QString &parName, int i, QString constraint) { + const QString &parName, int i, const QString &constraint) { m_model->setLocalParameterConstraint(parName, i, constraint); if (m_model->currentDomainIndex() == i) { m_view->setParameterConstraint(parName, constraint); diff --git a/qt/widgets/common/src/FunctionTreeView.cpp b/qt/widgets/common/src/FunctionTreeView.cpp index 7fe4bba3e687e6c2d1f1cd54af85ddc6d1b5c251..3969cf380a94a78f20d84c46e072ac754664b0af 100644 --- a/qt/widgets/common/src/FunctionTreeView.cpp +++ b/qt/widgets/common/src/FunctionTreeView.cpp @@ -47,6 +47,7 @@ #include <algorithm> #include <boost/lexical_cast.hpp> +#include <utility> namespace { const char *globalOptionName = "Global"; @@ -362,7 +363,8 @@ void FunctionTreeView::removeProperty(QtProperty *prop) { * @return :: A set AProperty struct */ FunctionTreeView::AProperty -FunctionTreeView::addFunctionProperty(QtProperty *parent, QString funName) { +FunctionTreeView::addFunctionProperty(QtProperty *parent, + const QString &funName) { // check that parent is a function property if (parent && dynamic_cast<QtAbstractPropertyManager *>(m_functionManager) != parent->propertyManager()) { @@ -379,9 +381,9 @@ FunctionTreeView::addFunctionProperty(QtProperty *parent, QString funName) { * @param paramDesc :: Parameter description * @param paramValue :: Parameter value */ -FunctionTreeView::AProperty -FunctionTreeView::addParameterProperty(QtProperty *parent, QString paramName, - QString paramDesc, double paramValue) { +FunctionTreeView::AProperty FunctionTreeView::addParameterProperty( + QtProperty *parent, const QString ¶mName, const QString ¶mDesc, + double paramValue) { // check that parent is a function property if (!parent || dynamic_cast<QtAbstractPropertyManager *>(m_functionManager) != parent->propertyManager()) { @@ -406,11 +408,11 @@ FunctionTreeView::addParameterProperty(QtProperty *parent, QString paramName, * @param fun :: A function */ void FunctionTreeView::setFunction(QtProperty *prop, - Mantid::API::IFunction_sptr fun) { + const Mantid::API::IFunction_sptr &fun) { auto children = prop->subProperties(); foreach (QtProperty *child, children) { removeProperty(child); } // m_localParameterValues.clear(); - addAttributeAndParameterProperties(prop, fun); + addAttributeAndParameterProperties(prop, std::move(fun)); } /** @@ -419,7 +421,7 @@ void FunctionTreeView::setFunction(QtProperty *prop, * @param fun :: A function to add */ bool FunctionTreeView::addFunction(QtProperty *prop, - Mantid::API::IFunction_sptr fun) { + const Mantid::API::IFunction_sptr &fun) { if (!fun) return false; if (!prop) { @@ -459,8 +461,8 @@ class CreateAttributePropertyForFunctionTreeView public: CreateAttributePropertyForFunctionTreeView(FunctionTreeView *browser, QtProperty *parent, - QString attName) - : m_browser(browser), m_parent(parent), m_attName(attName) { + const QString &attName) + : m_browser(browser), m_parent(parent), m_attName(std::move(attName)) { // check that parent is a function property if (!m_parent || dynamic_cast<QtAbstractPropertyManager *>( @@ -614,9 +616,10 @@ private: * @param att :: Attribute value */ FunctionTreeView::AProperty FunctionTreeView::addAttributeProperty( - QtProperty *parent, QString attName, + QtProperty *parent, const QString &attName, const Mantid::API::IFunction::Attribute &att) { - CreateAttributePropertyForFunctionTreeView cap(this, parent, attName); + CreateAttributePropertyForFunctionTreeView cap(this, parent, + std::move(attName)); return att.apply(cap); } @@ -628,7 +631,7 @@ FunctionTreeView::AProperty FunctionTreeView::addAttributeProperty( * @param fun :: Shared pointer to a created function */ void FunctionTreeView::addAttributeAndParameterProperties( - QtProperty *prop, Mantid::API::IFunction_sptr fun) { + QtProperty *prop, const Mantid::API::IFunction_sptr &fun) { // add the function index property addIndexProperty(prop); @@ -703,7 +706,8 @@ FunctionTreeView::addIndexProperty(QtProperty *prop) { * @param prop :: A function property * @param index :: The parent function's index */ -void FunctionTreeView::updateFunctionIndices(QtProperty *prop, QString index) { +void FunctionTreeView::updateFunctionIndices(QtProperty *prop, + const QString &index) { if (prop == nullptr) { auto top = m_browser->properties(); if (top.isEmpty()) @@ -896,14 +900,10 @@ QtProperty *FunctionTreeView::getFunctionProperty(const QString &index) const { * @param prop :: Parent parameter property * @param tie :: A tie string */ -void FunctionTreeView::addTieProperty(QtProperty *prop, QString tie) { +void FunctionTreeView::addTieProperty(QtProperty *prop, const QString &tie) { if (!prop) { throw std::runtime_error("FunctionTreeView: null property pointer"); } - AProperty ap; - ap.item = nullptr; - ap.prop = nullptr; - ap.parent = nullptr; if (!isParameter(prop)) return; @@ -914,7 +914,7 @@ void FunctionTreeView::addTieProperty(QtProperty *prop, QString tie) { m_tieManager->blockSignals(true); QtProperty *tieProp = m_tieManager->addProperty("Tie"); m_tieManager->setValue(tieProp, tie); - ap = addProperty(prop, tieProp); + addProperty(prop, tieProp); m_tieManager->blockSignals(false); const auto parName = getParameterName(prop); @@ -977,7 +977,7 @@ QString FunctionTreeView::getTie(QtProperty *prop) const { */ QList<FunctionTreeView::AProperty> FunctionTreeView::addConstraintProperties(QtProperty *prop, - QString constraint) { + const QString &constraint) { if (!isParameter(prop)) return QList<FunctionTreeView::AProperty>(); auto const parts = splitConstraintString(constraint); diff --git a/qt/widgets/common/src/HintingLineEdit.cpp b/qt/widgets/common/src/HintingLineEdit.cpp index 17267943b059819c52b906287f9abfa0bba2a1ac..0454039340b0f0c6c1c8f8eee4f30f15cc93d0ae 100644 --- a/qt/widgets/common/src/HintingLineEdit.cpp +++ b/qt/widgets/common/src/HintingLineEdit.cpp @@ -11,11 +11,12 @@ #include <QStyle> #include <QToolTip> #include <boost/algorithm/string.hpp> +#include <utility> namespace MantidQt { namespace MantidWidgets { HintingLineEdit::HintingLineEdit(QWidget *parent, std::vector<Hint> hints) - : QLineEdit(parent), m_hints(hints), m_dontComplete(false) { + : QLineEdit(parent), m_hints(std::move(hints)), m_dontComplete(false) { m_hintLabel = new QLabel(this, Qt::ToolTip); m_hintLabel->setMargin(1 + style()->pixelMetric(QStyle::PM_ToolTipLabelFrameWidth, diff --git a/qt/widgets/common/src/IndirectFitPropertyBrowserLegacy.cpp b/qt/widgets/common/src/IndirectFitPropertyBrowserLegacy.cpp index 2685c42720f9bf7da554070d7d7748b2c18d0e7b..4d6335bc43bf5677def7b96873967deae3ba075f 100644 --- a/qt/widgets/common/src/IndirectFitPropertyBrowserLegacy.cpp +++ b/qt/widgets/common/src/IndirectFitPropertyBrowserLegacy.cpp @@ -211,8 +211,8 @@ IndirectFitPropertyBrowserLegacy::backgroundIndex() const { * @param function The function, whose function index to retrieve. * @return The function index of the specified function in the browser. */ -boost::optional<size_t> -IndirectFitPropertyBrowserLegacy::functionIndex(IFunction_sptr function) const { +boost::optional<size_t> IndirectFitPropertyBrowserLegacy::functionIndex( + const IFunction_sptr &function) const { for (size_t i = 0u; i < compositeFunction()->nFunctions(); ++i) { if (compositeFunction()->getFunction(i) == function) return i; @@ -344,7 +344,8 @@ void IndirectFitPropertyBrowserLegacy::setParameterValue( * @param value The value to set. */ void IndirectFitPropertyBrowserLegacy::setParameterValue( - IFunction_sptr function, const std::string ¶meterName, double value) { + const IFunction_sptr &function, const std::string ¶meterName, + double value) { if (function->hasParameter(parameterName)) { function->setParameter(parameterName, value); emit parameterChanged(function.get()); @@ -818,7 +819,7 @@ void IndirectFitPropertyBrowserLegacy::clearAllCustomFunctions() { * @param sampleWorkspace :: The workspace loaded as sample */ void IndirectFitPropertyBrowserLegacy::updatePlotGuess( - MatrixWorkspace_const_sptr sampleWorkspace) { + const MatrixWorkspace_const_sptr &sampleWorkspace) { if (sampleWorkspace && compositeFunction()->nFunctions() > 0) setPeakToolOn(true); else diff --git a/qt/widgets/common/src/InterfaceManager.cpp b/qt/widgets/common/src/InterfaceManager.cpp index 60da0c8b8c88e01df4e075c5adb1c3fcaaf1321d..e0c13a43397318707e0f068306c4f9e01c241ba9 100644 --- a/qt/widgets/common/src/InterfaceManager.cpp +++ b/qt/widgets/common/src/InterfaceManager.cpp @@ -74,7 +74,7 @@ Mantid::Kernel::AbstractInstantiator<MantidHelpInterface> * @returns An AlgorithmDialog object */ AlgorithmDialog *InterfaceManager::createDialog( - boost::shared_ptr<Mantid::API::IAlgorithm> alg, QWidget *parent, + const boost::shared_ptr<Mantid::API::IAlgorithm> &alg, QWidget *parent, bool forScript, const QHash<QString, QString> &presetValues, const QString &optionalMsg, const QStringList &enabled, const QStringList &disabled) { diff --git a/qt/widgets/common/src/LocalParameterEditor.cpp b/qt/widgets/common/src/LocalParameterEditor.cpp index 0546605e8d69b244eb28582e1d80a8d53201393c..c502f1c4a3b9ceb6823fafd421a37a931f0579df 100644 --- a/qt/widgets/common/src/LocalParameterEditor.cpp +++ b/qt/widgets/common/src/LocalParameterEditor.cpp @@ -16,6 +16,7 @@ #include <QLineEdit> #include <QMenu> #include <QPushButton> +#include <utility> namespace MantidQt { namespace MantidWidgets { @@ -31,16 +32,14 @@ namespace MantidWidgets { /// @param allOthersFixed :: True if all other local parameters are fixed. /// @param othersTied :: True if there are other tied parameters. /// @param logOptionsEnabled :: True if the log checkbox is ticked. -LocalParameterEditor::LocalParameterEditor(QWidget *parent, int index, - double value, bool fixed, - QString tie, QString constraint, - bool othersFixed, - bool allOthersFixed, bool othersTied, - bool logOptionsEnabled) +LocalParameterEditor::LocalParameterEditor( + QWidget *parent, int index, double value, bool fixed, const QString &tie, + const QString &constraint, bool othersFixed, bool allOthersFixed, + bool othersTied, bool logOptionsEnabled) : QWidget(parent), m_index(index), m_value(QString::number(value, 'g', 16)), - m_fixed(fixed), m_tie(tie), m_constraint(constraint), - m_othersFixed(othersFixed), m_allOthersFixed(allOthersFixed), - m_othersTied(othersTied) { + m_fixed(fixed), m_tie(std::move(tie)), + m_constraint(std::move(constraint)), m_othersFixed(othersFixed), + m_allOthersFixed(allOthersFixed), m_othersTied(othersTied) { auto layout = new QHBoxLayout(this); layout->setMargin(0); layout->setSpacing(0); @@ -312,7 +311,7 @@ void LocalParameterEditor::setEditorState() { } /// Open an input dialog to enter a tie expression. -QString LocalParameterEditor::setTieDialog(QString tie) { +QString LocalParameterEditor::setTieDialog(const QString &tie) { QInputDialog input; input.setWindowTitle("Set a tie."); input.setTextValue(tie); @@ -322,7 +321,7 @@ QString LocalParameterEditor::setTieDialog(QString tie) { return ""; } -QString LocalParameterEditor::setConstraintDialog(QString constraint) { +QString LocalParameterEditor::setConstraintDialog(const QString &constraint) { QInputDialog input; input.setWindowTitle("Set a constraint."); input.setTextValue(constraint); diff --git a/qt/widgets/common/src/MantidDialog.cpp b/qt/widgets/common/src/MantidDialog.cpp index 74a30e921740dd0853104fb22e87d02b1003d9b0..dd67a2f8c7d3a8f00d69435db2146bcb2926eec2 100644 --- a/qt/widgets/common/src/MantidDialog.cpp +++ b/qt/widgets/common/src/MantidDialog.cpp @@ -19,7 +19,7 @@ using namespace MantidQt::API; /** * Default Constructor */ -MantidDialog::MantidDialog(QWidget *parent, Qt::WindowFlags flags) +MantidDialog::MantidDialog(QWidget *parent, const Qt::WindowFlags &flags) : QDialog(parent, flags), m_pyRunner() { // re-emit the run Python code from m_pyRunner, to work this signal must reach // the slot in QtiPlot diff --git a/qt/widgets/common/src/MantidHelpWindow.cpp b/qt/widgets/common/src/MantidHelpWindow.cpp index b65427535ac25c6325a8f9b87d17259940ca1e32..cb0af5b2e49db68bb93bbee2d07ed9ecb921ab5d 100644 --- a/qt/widgets/common/src/MantidHelpWindow.cpp +++ b/qt/widgets/common/src/MantidHelpWindow.cpp @@ -65,7 +65,8 @@ const QString COLLECTION_FILE("MantidProject.qhc"); /** * Default constructor shows the @link DEFAULT_URL @endlink. */ -MantidHelpWindow::MantidHelpWindow(QWidget *parent, Qt::WindowFlags flags) +MantidHelpWindow::MantidHelpWindow(QWidget *parent, + const Qt::WindowFlags &flags) : MantidHelpInterface(), m_collectionFile(""), m_cacheFile(""), m_firstRun(true) { // find the collection and delete the cache file if this is the first run @@ -487,7 +488,7 @@ void MantidHelpWindow::determineFileLocs() { } } -void MantidHelpWindow::warning(QString msg) { +void MantidHelpWindow::warning(const QString &msg) { g_log.warning(msg.toStdString()); } diff --git a/qt/widgets/common/src/MantidTreeModel.cpp b/qt/widgets/common/src/MantidTreeModel.cpp index 9e9508d53b9e578980cf0b0012b7168753c0c2ed..f7dbee085936a1d1f9f38b9a87c6ebd223761704 100644 --- a/qt/widgets/common/src/MantidTreeModel.cpp +++ b/qt/widgets/common/src/MantidTreeModel.cpp @@ -121,8 +121,8 @@ void MantidTreeModel::showAlgorithmDialog(const QString &algName, * This creates an algorithm dialog (the default property entry thingie). * Helper function not required by interface */ -MantidQt::API::AlgorithmDialog * -MantidTreeModel::createAlgorithmDialog(Mantid::API::IAlgorithm_sptr alg) { +MantidQt::API::AlgorithmDialog *MantidTreeModel::createAlgorithmDialog( + const Mantid::API::IAlgorithm_sptr &alg) { QHash<QString, QString> presets; QStringList enabled; diff --git a/qt/widgets/common/src/MantidTreeWidget.cpp b/qt/widgets/common/src/MantidTreeWidget.cpp index d94c406f99f8bcf3fb365bebcf51de3a0ea1f076..fa6c4d5a6f0e4e7906f73bc76f818ca1e7d1a1d5 100644 --- a/qt/widgets/common/src/MantidTreeWidget.cpp +++ b/qt/widgets/common/src/MantidTreeWidget.cpp @@ -37,7 +37,7 @@ MantidTreeWidget::MantidTreeWidget(MantidDisplayBase *mui, QWidget *parent) setSortOrder(Qt::AscendingOrder); setAcceptDrops(true); - m_doubleClickAction = [&](QString wsName) { + m_doubleClickAction = [&](const QString &wsName) { m_mantidUI->importWorkspace(wsName, false); }; } diff --git a/qt/widgets/common/src/MantidTreeWidgetItem.cpp b/qt/widgets/common/src/MantidTreeWidgetItem.cpp index 200faef424af6ec4fbb9650d870134a688ab5589..0381fcafdcde5130cbfe4dbc9dca25b3794b913c 100644 --- a/qt/widgets/common/src/MantidTreeWidgetItem.cpp +++ b/qt/widgets/common/src/MantidTreeWidgetItem.cpp @@ -25,7 +25,7 @@ MantidTreeWidgetItem::MantidTreeWidgetItem(MantidTreeWidget *parent) /**Constructor. * Must be passed its parent MantidTreeWidget, to facilitate correct sorting. */ -MantidTreeWidgetItem::MantidTreeWidgetItem(QStringList list, +MantidTreeWidgetItem::MantidTreeWidgetItem(const QStringList &list, MantidTreeWidget *parent) : QTreeWidgetItem(list), m_parent(parent), m_sortPos(0) {} diff --git a/qt/widgets/common/src/MantidWSIndexDialog.cpp b/qt/widgets/common/src/MantidWSIndexDialog.cpp index 77590e3268df805c6d1f2f3f1ccafcd961fdf5a5..b017b39fa43f09ad9296dd5d008d3d09951c0a25 100644 --- a/qt/widgets/common/src/MantidWSIndexDialog.cpp +++ b/qt/widgets/common/src/MantidWSIndexDialog.cpp @@ -20,6 +20,7 @@ #include <boost/lexical_cast.hpp> #include <cstdlib> #include <exception> +#include <utility> namespace MantidQt { namespace MantidWidgets { @@ -48,7 +49,8 @@ const QString MantidWSIndexWidget::CONTOUR_PLOT = "Contour Plot"; * @param showTiledOption :: true if tiled plot enabled * @param isAdvanced :: true if advanced plotting has been selected */ -MantidWSIndexWidget::MantidWSIndexWidget(QWidget *parent, Qt::WindowFlags flags, +MantidWSIndexWidget::MantidWSIndexWidget(QWidget *parent, + const Qt::WindowFlags &flags, const QList<QString> &wsNames, const bool showWaterfallOption, const bool showTiledOption, @@ -830,12 +832,10 @@ bool MantidWSIndexWidget::usingSpectraNumbers() const { * @param showTiledOption :: If true the "Tiled" option is created * @param isAdvanced :: true if adanced plotting dialog is created */ -MantidWSIndexDialog::MantidWSIndexDialog(QWidget *parent, Qt::WindowFlags flags, - const QList<QString> &wsNames, - const bool showWaterfallOption, - const bool showPlotAll, - const bool showTiledOption, - const bool isAdvanced) +MantidWSIndexDialog::MantidWSIndexDialog( + QWidget *parent, const Qt::WindowFlags &flags, + const QList<QString> &wsNames, const bool showWaterfallOption, + const bool showPlotAll, const bool showTiledOption, const bool isAdvanced) : QDialog(parent, flags), m_widget(this, flags, wsNames, showWaterfallOption, showTiledOption, isAdvanced), @@ -973,7 +973,7 @@ Interval::Interval(int single) { init(single, single); } Interval::Interval(int start, int end) { init(start, end); } -Interval::Interval(QString intervalString) { +Interval::Interval(const QString &intervalString) { // Check to see if string is of the correct format, and then parse. // An interval can either be "n" or "n-m" where n and m are integers const QString patternSingle("^\\d+$"); // E.g. "2" or "712" @@ -1086,9 +1086,13 @@ void Interval::init(int start, int end) { //---------------------------------- IntervalList::IntervalList(void) {} -IntervalList::IntervalList(QString intervals) { addIntervals(intervals); } +IntervalList::IntervalList(const QString &intervals) { + addIntervals(std::move(intervals)); +} -IntervalList::IntervalList(Interval interval) { m_list.append(interval); } +IntervalList::IntervalList(const Interval &interval) { + m_list.append(interval); +} IntervalList::IntervalList(const IntervalList ©) { m_list = copy.m_list; } @@ -1350,7 +1354,8 @@ MantidWSIndexWidget::QLineEditWithErrorMark::QLineEditWithErrorMark( setLayout(layout); } -void MantidWSIndexWidget::QLineEditWithErrorMark::setError(QString error) { +void MantidWSIndexWidget::QLineEditWithErrorMark::setError( + const QString &error) { if (error.isEmpty()) { m_validLbl->setVisible(false); } else { diff --git a/qt/widgets/common/src/MdSettings.cpp b/qt/widgets/common/src/MdSettings.cpp index 3ae4ba778f6b30326586666818809c5bff774291..291db7c62ccb1616619c628f45d37251c16c3a19 100644 --- a/qt/widgets/common/src/MdSettings.cpp +++ b/qt/widgets/common/src/MdSettings.cpp @@ -47,7 +47,7 @@ QString MdSettings::getUserSettingColorMap() { return userSettingColorMap; } -void MdSettings::setUserSettingColorMap(QString colorMap) { +void MdSettings::setUserSettingColorMap(const QString &colorMap) { QSettings settings; settings.beginGroup(m_vsiGroup); @@ -66,7 +66,7 @@ QString MdSettings::getLastSessionColorMap() { return colormap; } -void MdSettings::setLastSessionColorMap(QString colorMap) { +void MdSettings::setLastSessionColorMap(const QString &colorMap) { QSettings settings; settings.beginGroup(m_vsiGroup); @@ -87,7 +87,7 @@ QColor MdSettings::getUserSettingBackgroundColor() { return backgroundColor; } -void MdSettings::setUserSettingBackgroundColor(QColor backgroundColor) { +void MdSettings::setUserSettingBackgroundColor(const QColor &backgroundColor) { QSettings settings; settings.beginGroup(m_vsiGroup); @@ -112,7 +112,7 @@ QColor MdSettings::getDefaultBackgroundColor() { return m_mdConstants.getDefaultBackgroundColor(); } -void MdSettings::setLastSessionBackgroundColor(QColor backgroundColor) { +void MdSettings::setLastSessionBackgroundColor(const QColor &backgroundColor) { QSettings settings; settings.beginGroup(m_vsiGroup); @@ -120,8 +120,8 @@ void MdSettings::setLastSessionBackgroundColor(QColor backgroundColor) { settings.endGroup(); } -void MdSettings::setGeneralMdColorMap(QString colorMapName, - QString colorMapFile) { +void MdSettings::setGeneralMdColorMap(const QString &colorMapName, + const QString &colorMapFile) { QSettings settings; settings.beginGroup(m_generalMdGroup); @@ -221,7 +221,7 @@ bool MdSettings::getLastSessionLogScale() { return logScale; } -void MdSettings::setUserSettingIntialView(QString initialView) { +void MdSettings::setUserSettingIntialView(const QString &initialView) { QSettings settings; settings.beginGroup(m_vsiGroup); diff --git a/qt/widgets/common/src/Message.cpp b/qt/widgets/common/src/Message.cpp index 21dda845f29d57f820c7e287571163961af2f51c..fe80bde54c025d63f19cd10cf90cfd2c36968076 100644 --- a/qt/widgets/common/src/Message.cpp +++ b/qt/widgets/common/src/Message.cpp @@ -7,6 +7,8 @@ //------------------------------------------- // Includes //------------------------------------------- +#include <utility> + #include "MantidQtWidgets/Common/Message.h" namespace MantidQt { @@ -28,8 +30,10 @@ Message::Message() * @param scriptPath The path of the script the message originated from. Empty * string if no script applicable */ -Message::Message(const QString &text, Priority priority, QString scriptPath) - : QObject(), m_text(text), m_priority(priority), m_scriptPath(scriptPath) {} +Message::Message(const QString &text, Priority priority, + const QString &scriptPath) + : QObject(), m_text(text), m_priority(priority), + m_scriptPath(std::move(scriptPath)) {} /** * @param text A std::string containing the message text @@ -37,9 +41,10 @@ Message::Message(const QString &text, Priority priority, QString scriptPath) * @param scriptPath The path of the script the message originated from. Empty * string if no script applicable */ -Message::Message(const std::string &text, Priority priority, QString scriptPath) +Message::Message(const std::string &text, Priority priority, + const QString &scriptPath) : QObject(), m_text(QString::fromStdString(text)), m_priority(priority), - m_scriptPath(scriptPath) {} + m_scriptPath(std::move(scriptPath)) {} /** * @param text A c-style string containing the message text @@ -47,8 +52,9 @@ Message::Message(const std::string &text, Priority priority, QString scriptPath) * @param scriptPath The path of the script the message originated from. Empty * string if no script applicable */ -Message::Message(const char *text, Priority priority, QString scriptPath) - : QObject(), m_text(text), m_priority(priority), m_scriptPath(scriptPath) {} +Message::Message(const char *text, Priority priority, const QString &scriptPath) + : QObject(), m_text(text), m_priority(priority), + m_scriptPath(std::move(scriptPath)) {} /** * Construct a message from another object diff --git a/qt/widgets/common/src/MuonFitPropertyBrowser.cpp b/qt/widgets/common/src/MuonFitPropertyBrowser.cpp index 48fe43dc82fdee4ee88873d169ba71b9ce521fc3..f4bb2caa3260259299a9b79b19962d30a28a2669 100644 --- a/qt/widgets/common/src/MuonFitPropertyBrowser.cpp +++ b/qt/widgets/common/src/MuonFitPropertyBrowser.cpp @@ -64,6 +64,7 @@ #include <QMessageBox> #include <QSignalMapper> #include <QTableWidgetItem> +#include <utility> namespace { Mantid::Kernel::Logger g_log("MuonFitPropertyBrowser"); @@ -514,7 +515,7 @@ void MuonFitPropertyBrowser::setNormalization() { * @param name :: the ws name to get normalization for * @returns the normalization */ -void MuonFitPropertyBrowser::setNormalization(const std::string name) { +void MuonFitPropertyBrowser::setNormalization(const std::string &name) { m_normalizationValue.clear(); QString label; auto norms = readMultipleNormalization(); @@ -891,7 +892,7 @@ bool MuonFitPropertyBrowser::isWorkspaceValid(Workspace_sptr ws) const { return dynamic_cast<MatrixWorkspace *>(ws.get()) != nullptr; } -void MuonFitPropertyBrowser::setFitWorkspaces(const std::string input) { +void MuonFitPropertyBrowser::setFitWorkspaces(const std::string &input) { // Copy experiment info to output workspace if (AnalysisDataService::Instance().doesExist(outputName() + "_Workspace")) { // Input workspace should be a MatrixWorkspace according to isWorkspaceValid @@ -1027,7 +1028,7 @@ void MuonFitPropertyBrowser::finishAfterSimultaneousFit( * @param baseName :: [input] The common name of the workspaces of interest */ void MuonFitPropertyBrowser::finishAfterTFSimultaneousFit( - const Mantid::API::IAlgorithm *alg, const std::string baseName) const { + const Mantid::API::IAlgorithm *alg, const std::string &baseName) const { AnalysisDataServiceImpl &ads = AnalysisDataService::Instance(); try { std::vector<std::string> wsList = @@ -1827,7 +1828,7 @@ void MuonFitPropertyBrowser::combineBtnPressed() { * selects the relevant group/pair * @param name :: string of the ws */ -void MuonFitPropertyBrowser::setSingleFitLabel(std::string name) { +void MuonFitPropertyBrowser::setSingleFitLabel(const std::string &name) { clearChosenGroups(); clearChosenPeriods(); std::vector<std::string> splitName; @@ -1898,7 +1899,7 @@ void MuonFitPropertyBrowser::setAllGroupsOrPairs(const bool isItGroup) { } void MuonFitPropertyBrowser::setGroupNames( std::vector<std::string> groupNames) { - m_groupsList = groupNames; + m_groupsList = std::move(groupNames); } void MuonFitPropertyBrowser::setTFAsymm(bool state) { m_boolManager->setValue(m_TFAsymmMode, state); diff --git a/qt/widgets/common/src/NonOrthogonal.cpp b/qt/widgets/common/src/NonOrthogonal.cpp index 01a5ab14b5f0ebd3ea4a05bf5f7c41ce45fb2fa7..7a5d216a9a8f15add575e5324ad15fa87fb06d9b 100644 --- a/qt/widgets/common/src/NonOrthogonal.cpp +++ b/qt/widgets/common/src/NonOrthogonal.cpp @@ -350,9 +350,9 @@ double getAngleInRadian(std::array<Mantid::coord_t, N> orthogonalVector, namespace MantidQt { namespace API { -size_t -getMissingHKLDimensionIndex(Mantid::API::IMDWorkspace_const_sptr workspace, - size_t dimX, size_t dimY) { +size_t getMissingHKLDimensionIndex( + const Mantid::API::IMDWorkspace_const_sptr &workspace, size_t dimX, + size_t dimY) { for (size_t i = 0; i < workspace->getNumDims(); ++i) { auto dimension = workspace->getDimension(i); const auto &frame = dimension->getMDFrame(); diff --git a/qt/widgets/common/src/PlotAxis.cpp b/qt/widgets/common/src/PlotAxis.cpp index a1ae86bcbd5799f6ec386cba0e50b7a3e27f269a..16ed2f1d3e6e8e256a7791a11985a50ecae0b40e 100644 --- a/qt/widgets/common/src/PlotAxis.cpp +++ b/qt/widgets/common/src/PlotAxis.cpp @@ -22,7 +22,7 @@ namespace { QString replacePerWithNegativeIndice(const std::string &label, const bool &plotAsDistribution, - const Mantid::Kernel::UnitLabel xLabel = "") { + const Mantid::Kernel::UnitLabel &xLabel = "") { std::vector<std::string> splitVec; QString negativeOnePower = toQStringInternal(L"\u207b\u00b9"); QString newLabel; diff --git a/qt/widgets/common/src/PluginLibraries.cpp b/qt/widgets/common/src/PluginLibraries.cpp index ae681c9b7971acf58b17559e2d776e7bb1675214..ef046a6cb87e9ac792fdbb3a5829e7a2dc37dd19 100644 --- a/qt/widgets/common/src/PluginLibraries.cpp +++ b/qt/widgets/common/src/PluginLibraries.cpp @@ -25,7 +25,7 @@ namespace API { * @param key The name of a key in the Mantid config * @return The value of the key */ -std::string qtPluginPathFromCfg(std::string key) { +std::string qtPluginPathFromCfg(const std::string &key) { static std::string qtMajorVersion; static std::string qtTag("%V"); if (qtMajorVersion.empty()) { @@ -42,7 +42,7 @@ std::string qtPluginPathFromCfg(std::string key) { * %V to specify the Qt version * @return The number of libraries successfully loaded */ -int loadPluginsFromCfgPath(std::string key) { +int loadPluginsFromCfgPath(const std::string &key) { return loadPluginsFromPath(qtPluginPathFromCfg(std::move(key))); } @@ -50,7 +50,7 @@ int loadPluginsFromCfgPath(std::string key) { * Load all plugins from the path specified. * @return The number of libraries successfully loaded */ -int loadPluginsFromPath(std::string path) { +int loadPluginsFromPath(const std::string &path) { // We must *NOT* load plugins compiled against a different version of Qt // so we set exclude flags by Qt version. #if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) diff --git a/qt/widgets/common/src/ProcessingAlgoWidget.cpp b/qt/widgets/common/src/ProcessingAlgoWidget.cpp index 86a64dcd7d9c13d58281fbb7729d1a1aa49531fe..d0fb062f7d4e7abacbd60618ee2cefe099f0ebb0 100644 --- a/qt/widgets/common/src/ProcessingAlgoWidget.cpp +++ b/qt/widgets/common/src/ProcessingAlgoWidget.cpp @@ -164,7 +164,7 @@ void ProcessingAlgoWidget::setSelectedAlgorithm(QString algo) { /// @return the text in the script editor QString ProcessingAlgoWidget::getScriptText() { return ui.editor->text(); } /// Set the script editor text -void ProcessingAlgoWidget::setScriptText(QString text) { +void ProcessingAlgoWidget::setScriptText(const QString &text) { ui.editor->setText(text); } diff --git a/qt/widgets/common/src/ProjectSaveModel.cpp b/qt/widgets/common/src/ProjectSaveModel.cpp index 86b2a1fdb8bcd51a6ccf53240086903ae911d516..83b529b11d9c6b10949c649000dbac2c03b78d0f 100644 --- a/qt/widgets/common/src/ProjectSaveModel.cpp +++ b/qt/widgets/common/src/ProjectSaveModel.cpp @@ -24,7 +24,7 @@ using namespace MantidQt::MantidWidgets; * @param activePythonInterfaces The list of active Python interfaces */ ProjectSaveModel::ProjectSaveModel( - std::vector<IProjectSerialisable *> windows, + const std::vector<IProjectSerialisable *> &windows, std::vector<std::string> activePythonInterfaces) : m_activePythonInterfaces(std::move(activePythonInterfaces)) { auto workspaces = getWorkspaces(); @@ -204,8 +204,8 @@ std::vector<Workspace_sptr> ProjectSaveModel::getWorkspaces() const { return ads.getObjects(); } -WorkspaceInfo -ProjectSaveModel::makeWorkspaceInfoObject(Workspace_const_sptr ws) const { +WorkspaceInfo ProjectSaveModel::makeWorkspaceInfoObject( + const Workspace_const_sptr &ws) const { WorkspaceIcons icons; WorkspaceInfo info; info.name = ws->getName(); diff --git a/qt/widgets/common/src/PropertyHandler.cpp b/qt/widgets/common/src/PropertyHandler.cpp index d66dc9a77ba24ff442a5bfc83349b652da6bce28..ce324b420ede4370fb64718a760ca425fd601f16 100644 --- a/qt/widgets/common/src/PropertyHandler.cpp +++ b/qt/widgets/common/src/PropertyHandler.cpp @@ -26,6 +26,7 @@ #include "MantidQtWidgets/Common/QtPropertyBrowser/qttreepropertybrowser.h" #include <QMessageBox> +#include <utility> using std::size_t; @@ -33,16 +34,16 @@ namespace MantidQt { namespace MantidWidgets { // Constructor -PropertyHandler::PropertyHandler(Mantid::API::IFunction_sptr fun, +PropertyHandler::PropertyHandler(const Mantid::API::IFunction_sptr &fun, Mantid::API::CompositeFunction_sptr parent, FitPropertyBrowser *browser, QtBrowserItem *item) : FunctionHandler(fun), m_browser(browser), m_cf(boost::dynamic_pointer_cast<Mantid::API::CompositeFunction>(fun)), m_pf(boost::dynamic_pointer_cast<Mantid::API::IPeakFunction>(fun)), - m_parent(parent), m_type(nullptr), m_item(item), m_isMultispectral(false), - m_workspace(nullptr), m_workspaceIndex(nullptr), m_base(0), m_ci(0), - m_hasPlot(false) {} + m_parent(std::move(parent)), m_type(nullptr), m_item(item), + m_isMultispectral(false), m_workspace(nullptr), m_workspaceIndex(nullptr), + m_base(0), m_ci(0), m_hasPlot(false) {} /// Destructor PropertyHandler::~PropertyHandler() {} @@ -606,7 +607,7 @@ PropertyHandler *PropertyHandler::findHandler(QtProperty *prop) { } PropertyHandler * -PropertyHandler::findHandler(Mantid::API::IFunction_const_sptr fun) { +PropertyHandler::findHandler(const Mantid::API::IFunction_const_sptr &fun) { if (fun == function()) return this; if (m_cf) { @@ -1156,7 +1157,8 @@ void PropertyHandler::fix(const QString &parName) { * @param globalName :: Name of the parameter in compoite function * (e.g. f1.omega) */ -void PropertyHandler::removeTie(QtProperty *prop, std::string globalName) { +void PropertyHandler::removeTie(QtProperty *prop, + const std::string &globalName) { QString parName = m_ties.key(prop, ""); if (parName.isEmpty()) return; diff --git a/qt/widgets/common/src/QtJSONUtils.cpp b/qt/widgets/common/src/QtJSONUtils.cpp index 44e1821f07114023ea2fe5aac06d7c87d8cbc69d..ad1d4d972f14f2d471ca163202dee7d20887302c 100644 --- a/qt/widgets/common/src/QtJSONUtils.cpp +++ b/qt/widgets/common/src/QtJSONUtils.cpp @@ -58,7 +58,7 @@ public: return toString.call(obj).toString(); } - QMap<QString, QVariant> decodeInner(QScriptValue object) { + QMap<QString, QVariant> decodeInner(const QScriptValue &object) { QMap<QString, QVariant> map; QScriptValueIterator it(object); while (it.hasNext()) { @@ -79,7 +79,7 @@ public: return map; } - QList<QVariant> decodeInnerToList(QScriptValue arrayValue) { + QList<QVariant> decodeInnerToList(const QScriptValue &arrayValue) { QList<QVariant> list; QScriptValueIterator it(arrayValue); while (it.hasNext()) { diff --git a/qt/widgets/common/src/QtPropertyBrowser/qtgroupboxpropertybrowser.cpp b/qt/widgets/common/src/QtPropertyBrowser/qtgroupboxpropertybrowser.cpp index bf89eb4fde6cc877dc10e35056ac6412ecf239a6..5d38e2237fa91442f937470c362504f6aae4bcb6 100644 --- a/qt/widgets/common/src/QtPropertyBrowser/qtgroupboxpropertybrowser.cpp +++ b/qt/widgets/common/src/QtPropertyBrowser/qtgroupboxpropertybrowser.cpp @@ -308,15 +308,12 @@ void QtGroupBoxPropertyBrowserPrivate::propertyRemoved(QtBrowserItem *index) { } else { WidgetItem *par = parentItem->parent; QGridLayout *l = nullptr; - int oldRow = -1; if (!par) { l = m_mainLayout; - oldRow = m_children.indexOf(parentItem); + m_children.indexOf(parentItem); } else { l = par->layout; - oldRow = par->children.indexOf(parentItem); - if (hasHeader(par)) - oldRow += 2; + par->children.indexOf(parentItem); } if (parentItem->widget) { diff --git a/qt/widgets/common/src/QtPropertyBrowser/qtpropertybrowserutils.cpp b/qt/widgets/common/src/QtPropertyBrowser/qtpropertybrowserutils.cpp index b314504ea06de5f1080e340211f4b642715357b8..d36cf51256d44db9b6659fb9dd1a711fd7d52e90 100644 --- a/qt/widgets/common/src/QtPropertyBrowser/qtpropertybrowserutils.cpp +++ b/qt/widgets/common/src/QtPropertyBrowser/qtpropertybrowserutils.cpp @@ -461,7 +461,7 @@ void QtKeySequenceEdit::setKeySequence(const QKeySequence &sequence) { QKeySequence QtKeySequenceEdit::keySequence() const { return m_keySequence; } -int QtKeySequenceEdit::translateModifiers(Qt::KeyboardModifiers state, +int QtKeySequenceEdit::translateModifiers(const Qt::KeyboardModifiers &state, const QString &text) const { int result = 0; if ((state & Qt::ShiftModifier) && diff --git a/qt/widgets/common/src/SaveWorkspaces.cpp b/qt/widgets/common/src/SaveWorkspaces.cpp index b9b9a82511f542a9fe8e8a59bde0c82968373647..379f2712a6da7f1feb1293c9653feb39e5a3311a 100644 --- a/qt/widgets/common/src/SaveWorkspaces.cpp +++ b/qt/widgets/common/src/SaveWorkspaces.cpp @@ -482,7 +482,7 @@ SaveWorkspaces::provideZeroFreeWorkspaces(const QListWidget *workspaces) { * workspaces. */ void SaveWorkspaces::removeZeroFreeWorkspaces( - QHash<QString, QString> workspaces) { + const QHash<QString, QString> &workspaces) { auto zeroFreeWorkspaceNames = workspaces.values(); for (auto &zeroFreeWorkspaceName : zeroFreeWorkspaceNames) { emit deleteZeroErrorFreeWorkspace(zeroFreeWorkspaceName); diff --git a/qt/widgets/common/src/ScriptRepositoryView.cpp b/qt/widgets/common/src/ScriptRepositoryView.cpp index e9f39afc030f435f2fdb8e6c66b3aad7814fbadb..71d96520c2a4e71164c5bcf9e95006cf760195ce 100644 --- a/qt/widgets/common/src/ScriptRepositoryView.cpp +++ b/qt/widgets/common/src/ScriptRepositoryView.cpp @@ -360,7 +360,7 @@ void ScriptRepositoryView::RepoDelegate::paint( QApplication::style()->drawControl(QStyle::CE_PushButton, &button, painter); } -QIcon ScriptRepositoryView::RepoDelegate::getIcon(QString state) const { +QIcon ScriptRepositoryView::RepoDelegate::getIcon(const QString &state) const { QIcon icon; #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) if (state == RepoModel::remoteOnlySt()) @@ -646,7 +646,7 @@ bool ScriptRepositoryView::RemoveEntryDelegate::editorEvent( * * @param link :: the folder link to open. */ -void ScriptRepositoryView::openFolderLink(QString link) { +void ScriptRepositoryView::openFolderLink(const QString &link) { const std::string error_msg = "Unable to open \"" + link.toStdString() + "\". Reason: "; diff --git a/qt/widgets/common/src/SelectWorkspacesDialog.cpp b/qt/widgets/common/src/SelectWorkspacesDialog.cpp index 77c0465afe06ccd1efa1957ebe172b8e85d24902..1a3617b57b3fc4f41c80cb05bbf9d9b80b363f8b 100644 --- a/qt/widgets/common/src/SelectWorkspacesDialog.cpp +++ b/qt/widgets/common/src/SelectWorkspacesDialog.cpp @@ -32,7 +32,7 @@ private: public: explicit WorkspaceIsNotOfType(const std::string &type) : m_type(type), m_isMatrixWorkspace(type == "MatrixWorkspace") {} - bool operator()(Mantid::API::Workspace_sptr ws) const { + bool operator()(const Mantid::API::Workspace_sptr &ws) const { if (m_type.empty()) return false; if (m_isMatrixWorkspace) { diff --git a/qt/widgets/common/src/SequentialFitDialog.cpp b/qt/widgets/common/src/SequentialFitDialog.cpp index 3b3eb16fe4cd839c9d381be101bd742b99b014f3..e4db13d7fb551087fcb33b82b09333ada03113bf 100644 --- a/qt/widgets/common/src/SequentialFitDialog.cpp +++ b/qt/widgets/common/src/SequentialFitDialog.cpp @@ -88,7 +88,7 @@ void SequentialFitDialog::addWorkspace() { } } -bool SequentialFitDialog::addWorkspaces(const QStringList wsNames) { +bool SequentialFitDialog::addWorkspaces(const QStringList &wsNames) { if (wsNames.isEmpty()) return false; int row = ui.tWorkspaces->rowCount(); @@ -191,7 +191,7 @@ void SequentialFitDialog::removeItem() { } } -bool SequentialFitDialog::validateLogs(const QString wsName) { +bool SequentialFitDialog::validateLogs(const QString &wsName) { Mantid::API::MatrixWorkspace_sptr ws = boost::dynamic_pointer_cast<Mantid::API::MatrixWorkspace>( Mantid::API::AnalysisDataService::Instance().retrieve( diff --git a/qt/widgets/common/src/SlicingAlgorithmDialog.cpp b/qt/widgets/common/src/SlicingAlgorithmDialog.cpp index 523f936469efe00030c723abd9e25ad89f83ee45..d55299da9b42dadc74ce89d70f8d09bd1ad905ef 100644 --- a/qt/widgets/common/src/SlicingAlgorithmDialog.cpp +++ b/qt/widgets/common/src/SlicingAlgorithmDialog.cpp @@ -102,8 +102,8 @@ SlicingAlgorithmDialog::~SlicingAlgorithmDialog() { saveSettings(); } dimension. @param dim : dimension to format to string. */ -QString -formattedAlignedDimensionInput(Mantid::Geometry::IMDDimension_const_sptr dim) { +QString formattedAlignedDimensionInput( + const Mantid::Geometry::IMDDimension_const_sptr &dim) { QString min, max, nbins, result; QString name(dim->getName().c_str()); min.setNum(dim->getMinimum()); @@ -133,7 +133,7 @@ formattedAlignedDimensionInput(Mantid::Geometry::IMDDimension_const_sptr dim) { @return : empty string. */ QString formatNonAlignedDimensionInput( - Mantid::Geometry::IMDDimension_const_sptr /*unused*/) { + const Mantid::Geometry::IMDDimension_const_sptr & /*unused*/) { // Deliberately return an empty string here, because it's not obvious how the // basis vectors could be automatically formed. return QString(""); @@ -288,7 +288,7 @@ generated. */ void SlicingAlgorithmDialog::makeDimensionInputs( const QString &propertyPrefix, QLayout *owningLayout, - QString (*format)(IMDDimension_const_sptr), History history) { + QString (*format)(const IMDDimension_const_sptr &), History history) { // Remove excess dimensions from the tied properties and the stored property // values size_t indexRemoved = 0; @@ -441,7 +441,7 @@ bool SlicingAlgorithmDialog::doAutoFillDimensions() const { *Customise the layout for usage in the Vsi */ void SlicingAlgorithmDialog::customiseLayoutForVsi( - std::string initialWorkspace) { + const std::string &initialWorkspace) { // File back-end ui.file_backend_layout->setVisible(false); @@ -466,8 +466,8 @@ void SlicingAlgorithmDialog::customiseLayoutForVsi( * @param index The property index. * @param propertyValue The new value of the axis dimension. */ -void SlicingAlgorithmDialog::resestAlignedDimProperty(size_t index, - QString propertyValue) { +void SlicingAlgorithmDialog::resestAlignedDimProperty( + size_t index, const QString &propertyValue) { QString alignedDim = "AlignedDim"; const QString propertyName = alignedDim.append(QString().number(index)); diff --git a/qt/widgets/common/src/SlitCalculator.cpp b/qt/widgets/common/src/SlitCalculator.cpp index 5b6b51b76cf25e7918b9bafb6d1143fb370b69cc..33b7e1d7703b36a46c560e02639542f71ae6d81b 100644 --- a/qt/widgets/common/src/SlitCalculator.cpp +++ b/qt/widgets/common/src/SlitCalculator.cpp @@ -32,7 +32,7 @@ void SlitCalculator::processInstrumentHasBeenChanged() { on_recalculate_triggered(); } SlitCalculator::~SlitCalculator() {} -void SlitCalculator::setInstrument(std::string instrumentName) { +void SlitCalculator::setInstrument(const std::string &instrumentName) { // we want to get the most up-to-date definition, so we use the current // date/time auto date = @@ -64,7 +64,7 @@ void SlitCalculator::setInstrument(std::string instrumentName) { void SlitCalculator::show() { QDialog::show(); } void SlitCalculator::setupSlitCalculatorWithInstrumentValues( - Mantid::Geometry::Instrument_const_sptr instrument) { + const Mantid::Geometry::Instrument_const_sptr &instrument) { // fetch the components that we need for values from IDF auto slit1Component = instrument->getComponentByName("slit1"); auto slit2Component = instrument->getComponentByName("slit2"); diff --git a/qt/widgets/common/src/TSVSerialiser.cpp b/qt/widgets/common/src/TSVSerialiser.cpp index fa34ed03c945e691b55e79986829a02068b5b970..240460e63a4db527a0cd900238b1f9daa196b0d1 100644 --- a/qt/widgets/common/src/TSVSerialiser.cpp +++ b/qt/widgets/common/src/TSVSerialiser.cpp @@ -325,7 +325,7 @@ QString TSVSerialiser::asQString(const size_t i) const { void TSVSerialiser::storeDouble(const double val) { m_output << "\t" << val; } void TSVSerialiser::storeInt(const int val) { m_output << "\t" << val; } -void TSVSerialiser::storeString(const std::string val) { +void TSVSerialiser::storeString(const std::string &val) { m_output << "\t" << val; } diff --git a/qt/widgets/common/src/UserInputValidator.cpp b/qt/widgets/common/src/UserInputValidator.cpp index 7572c5148db32dd3ea72bcb147b2a157a27b080a..c3b520b567eaebbfa8cbf6cab5bf08ea9ed019bf 100644 --- a/qt/widgets/common/src/UserInputValidator.cpp +++ b/qt/widgets/common/src/UserInputValidator.cpp @@ -33,7 +33,7 @@ bool doesExistInADS(std::string const &workspaceName) { } boost::optional<std::string> -containsInvalidWorkspace(WorkspaceGroup_const_sptr group) { +containsInvalidWorkspace(const WorkspaceGroup_const_sptr &group) { if (group->isEmpty()) return "The group workspace " + group->getName() + " is empty."; @@ -337,7 +337,7 @@ bool UserInputValidator::checkWorkspaceNumberOfHistograms( * @return True if the workspace has the correct size */ bool UserInputValidator::checkWorkspaceNumberOfHistograms( - MatrixWorkspace_sptr workspace, std::size_t const &validSize) { + const MatrixWorkspace_sptr &workspace, std::size_t const &validSize) { if (workspace->getNumberHistograms() != validSize) { addErrorMessage( QString::fromStdString(workspace->getName()) + " should contain " + @@ -370,7 +370,7 @@ bool UserInputValidator::checkWorkspaceNumberOfBins( * @return True if the workspace has the correct size */ bool UserInputValidator::checkWorkspaceNumberOfBins( - MatrixWorkspace_sptr workspace, std::size_t const &validSize) { + const MatrixWorkspace_sptr &workspace, std::size_t const &validSize) { if (workspace->x(0).size() != validSize) { addErrorMessage( QString::fromStdString(workspace->getName()) + " should contain " + diff --git a/qt/widgets/common/src/WorkspaceObserver.cpp b/qt/widgets/common/src/WorkspaceObserver.cpp index af54813cd84bed12672b6387133911f334892d4d..7d58b5b0b940b9a0a6d22b326b95318d4bf1bdc0 100644 --- a/qt/widgets/common/src/WorkspaceObserver.cpp +++ b/qt/widgets/common/src/WorkspaceObserver.cpp @@ -7,8 +7,10 @@ //----------------------------------- // Includes //----------------------------------- -#include "MantidQtWidgets/Common/WorkspaceObserver.h" +#include <utility> + #include "MantidAPI/AnalysisDataService.h" +#include "MantidQtWidgets/Common/WorkspaceObserver.h" namespace MantidQt { namespace API { @@ -18,7 +20,7 @@ namespace API { //--------------------------------------------------------------------------- void ObserverCallback::handlePreDelete(const std::string &name, Mantid::API::Workspace_sptr workspace) { - m_observer->preDeleteHandle(name, workspace); + m_observer->preDeleteHandle(name, std::move(workspace)); } void ObserverCallback::handlePostDelete(const std::string &name) { @@ -27,12 +29,12 @@ void ObserverCallback::handlePostDelete(const std::string &name) { void ObserverCallback::handleAdd(const std::string &name, Mantid::API::Workspace_sptr workspace) { - m_observer->addHandle(name, workspace); + m_observer->addHandle(name, std::move(workspace)); } void ObserverCallback::handleAfterReplace( const std::string &name, Mantid::API::Workspace_sptr workspace) { - m_observer->afterReplaceHandle(name, workspace); + m_observer->afterReplaceHandle(name, std::move(workspace)); } void ObserverCallback::handleRename(const std::string &oldName, diff --git a/qt/widgets/common/src/WorkspacePresenter/WorkspaceTreeWidget.cpp b/qt/widgets/common/src/WorkspacePresenter/WorkspaceTreeWidget.cpp index 72baa7b8d2ce10050edf94a1a885222b41aa709a..cf9a9136fadeb80d9ccc2c034c32ceaaa148f6e5 100644 --- a/qt/widgets/common/src/WorkspacePresenter/WorkspaceTreeWidget.cpp +++ b/qt/widgets/common/src/WorkspacePresenter/WorkspaceTreeWidget.cpp @@ -883,7 +883,7 @@ MantidTreeWidgetItem *WorkspaceTreeWidget::addTreeEntry( * Check if a workspace should be selected after dock update. * @param name :: Name of a workspace to check. */ -bool WorkspaceTreeWidget::shouldBeSelected(QString name) const { +bool WorkspaceTreeWidget::shouldBeSelected(const QString &name) const { QMutexLocker lock(&m_mutex); QStringList renamed = m_renameMap.keys(name); if (!renamed.isEmpty()) { @@ -1114,7 +1114,7 @@ bool WorkspaceTreeWidget::hasUBMatrix(const std::string &wsName) { * ALGO_NAME * @param menuEntryName Text to be shown in menu */ -void WorkspaceTreeWidget::addSaveMenuOption(QString algorithmString, +void WorkspaceTreeWidget::addSaveMenuOption(const QString &algorithmString, QString menuEntryName) { // Default to algo string if no entry name given if (menuEntryName.isEmpty()) diff --git a/qt/widgets/common/src/WorkspacePresenter/WorkspaceTreeWidgetSimple.cpp b/qt/widgets/common/src/WorkspacePresenter/WorkspaceTreeWidgetSimple.cpp index 151c0ce6d4aa1870b20c021202fd20bc26a01d78..b21c583f702abc7c7563a00bbcf50e5df5fdb8e0 100644 --- a/qt/widgets/common/src/WorkspacePresenter/WorkspaceTreeWidgetSimple.cpp +++ b/qt/widgets/common/src/WorkspacePresenter/WorkspaceTreeWidgetSimple.cpp @@ -45,7 +45,7 @@ WorkspaceTreeWidgetSimple::WorkspaceTreeWidgetSimple(bool viewOnly, m_showDetectors(new QAction("Show Detectors", this)) { // Replace the double click action on the MantidTreeWidget - m_tree->m_doubleClickAction = [&](QString wsName) { + m_tree->m_doubleClickAction = [&](const QString &wsName) { emit workspaceDoubleClicked(wsName); }; diff --git a/qt/widgets/common/src/WorkspaceSelector.cpp b/qt/widgets/common/src/WorkspaceSelector.cpp index 69d8f4ee05f7bcca9b31b42de716c2021b633468..d21f5d69936512fbb9f082064996be63e528e759 100644 --- a/qt/widgets/common/src/WorkspaceSelector.cpp +++ b/qt/widgets/common/src/WorkspaceSelector.cpp @@ -246,7 +246,7 @@ void WorkspaceSelector::handleReplaceEvent( } bool WorkspaceSelector::checkEligibility( - const QString &name, Mantid::API::Workspace_sptr object) const { + const QString &name, const Mantid::API::Workspace_sptr &object) const { if (m_algorithm && !m_algPropName.isEmpty()) { try { m_algorithm->setPropertyValue(m_algPropName.toStdString(), @@ -287,7 +287,7 @@ bool WorkspaceSelector::hasValidSuffix(const QString &name) const { } bool WorkspaceSelector::hasValidNumberOfBins( - Mantid::API::Workspace_sptr object) const { + const Mantid::API::Workspace_sptr &object) const { if (m_binLimits.first != 0 || m_binLimits.second != -1) { if (auto const workspace = boost::dynamic_pointer_cast<Mantid::API::MatrixWorkspace>(object)) { diff --git a/qt/widgets/common/src/pqHelpWindow.cxx b/qt/widgets/common/src/pqHelpWindow.cxx index 3af9bb00463b4534a6b422a9844a05ddc3f457d3..6973caf08ef0e4eb619c027b5662f80b9ddb6254 100644 --- a/qt/widgets/common/src/pqHelpWindow.cxx +++ b/qt/widgets/common/src/pqHelpWindow.cxx @@ -224,7 +224,7 @@ private: //----------------------------------------------------------------------------- pqHelpWindow::pqHelpWindow(QHelpEngine *engine, QWidget *parentObject, - Qt::WindowFlags parentFlags) + const Qt::WindowFlags& parentFlags) : Superclass(parentObject, parentFlags), m_helpEngine(engine) { Q_ASSERT(engine != nullptr); // Take ownership of the engine diff --git a/qt/widgets/common/test/DataProcessorUI/GenericDataProcessorPresenterTest.h b/qt/widgets/common/test/DataProcessorUI/GenericDataProcessorPresenterTest.h index 6d1e519ae89f0754733584f58c096af4782a1014..8bbea10b4e9a8b4be21c546d33ab796406c83781 100644 --- a/qt/widgets/common/test/DataProcessorUI/GenericDataProcessorPresenterTest.h +++ b/qt/widgets/common/test/DataProcessorUI/GenericDataProcessorPresenterTest.h @@ -9,6 +9,8 @@ #include <gmock/gmock.h> #include <gtest/gtest.h> +#include <utility> + #include "MantidAPI/FrameworkManager.h" #include "MantidAPI/TableRow.h" #include "MantidAPI/WorkspaceGroup.h" @@ -432,7 +434,7 @@ private: // Expect the view's widgets to be set in a particular state according to // whether processing or not void expectUpdateViewState(MockDataProcessorView &mockDataProcessorView, - Cardinality numTimes, bool isProcessing) { + const Cardinality &numTimes, bool isProcessing) { // Update menu items according to whether processing or not EXPECT_CALL(mockDataProcessorView, updateMenuEnabledState(isProcessing)) .Times(numTimes); @@ -451,18 +453,20 @@ private: // Expect the view's widgets to be set in the paused state void expectUpdateViewToPausedState(MockDataProcessorView &mockDataProcessorView, - Cardinality numTimes) { - expectUpdateViewState(mockDataProcessorView, numTimes, false); + const Cardinality &numTimes) { + expectUpdateViewState(mockDataProcessorView, std::move(numTimes), false); } // Expect the view's widgets to be set in the processing state void expectUpdateViewToProcessingState( - MockDataProcessorView &mockDataProcessorView, Cardinality numTimes) { - expectUpdateViewState(mockDataProcessorView, numTimes, true); + MockDataProcessorView &mockDataProcessorView, + const Cardinality &numTimes) { + expectUpdateViewState(mockDataProcessorView, std::move(numTimes), true); } void expectGetSelection(MockDataProcessorView &mockDataProcessorView, - Cardinality numTimes, RowList rowlist = RowList(), + const Cardinality &numTimes, + RowList rowlist = RowList(), GroupList grouplist = GroupList()) { if (numTimes.IsSatisfiedByCallCount(0)) { @@ -472,16 +476,16 @@ private: } else { EXPECT_CALL(mockDataProcessorView, getSelectedChildren()) .Times(numTimes) - .WillRepeatedly(Return(rowlist)); + .WillRepeatedly(Return(std::move(rowlist))); EXPECT_CALL(mockDataProcessorView, getSelectedParents()) .Times(numTimes) - .WillRepeatedly(Return(grouplist)); + .WillRepeatedly(Return(std::move(grouplist))); } } void expectGetOptions(MockMainPresenter &mockMainPresenter, - Cardinality numTimes, - std::string postprocessingOptions = "") { + const Cardinality &numTimes, + const std::string &postprocessingOptions = "") { if (numTimes.IsSatisfiedByCallCount(0)) { // If 0 calls, don't check return value EXPECT_CALL(mockMainPresenter, getPreprocessingOptions()).Times(numTimes); @@ -503,7 +507,7 @@ private: } void expectNotebookIsDisabled(MockDataProcessorView &mockDataProcessorView, - Cardinality numTimes) { + const Cardinality &numTimes) { // Call to check whether the notebook is enabled if (numTimes.IsSatisfiedByCallCount(0)) { // If 0 calls, don't check return value @@ -519,7 +523,7 @@ private: } void expectNotebookIsEnabled(MockDataProcessorView &mockDataProcessorView, - Cardinality numTimes) { + const Cardinality &numTimes) { // Call to check whether the notebook is enabled if (numTimes.IsSatisfiedByCallCount(0)) { // If 0 calls, don't check return value @@ -535,7 +539,8 @@ private: } void expectGetWorkspace(MockDataProcessorView &mockDataProcessorView, - Cardinality numTimes, const char *workspaceName) { + const Cardinality &numTimes, + const char *workspaceName) { if (numTimes.IsSatisfiedByCallCount(0)) { // If 0 calls, don't check return value EXPECT_CALL(mockDataProcessorView, getWorkspaceToOpen()).Times(numTimes); @@ -547,7 +552,7 @@ private: } void expectAskUserWorkspaceName(MockDataProcessorView &mockDataProcessorView, - Cardinality numTimes, + const Cardinality &numTimes, const char *workspaceName = "") { if (numTimes.IsSatisfiedByCallCount(0)) { // If 0 calls, don't check return value @@ -563,7 +568,8 @@ private: } void expectAskUserYesNo(MockDataProcessorView &mockDataProcessorView, - Cardinality numTimes, const bool answer = false) { + const Cardinality &numTimes, + const bool answer = false) { if (numTimes.IsSatisfiedByCallCount(0)) { // If 0 calls, don't check return value @@ -581,7 +587,7 @@ private: } void expectInstrumentIsINTER(MockDataProcessorView &mockDataProcessorView, - Cardinality numTimes) { + const Cardinality &numTimes) { if (numTimes.IsSatisfiedByCallCount(0)) { // If 0 calls, don't check return value EXPECT_CALL(mockDataProcessorView, getProcessInstrument()) @@ -607,12 +613,13 @@ private: "IvsQ_TOF_12345", "IvsQ_binned_TOF_12346", "IvsQ_TOF_12346", "IvsQ_TOF_12345_TOF_12346"}; - void checkWorkspacesExistInADS(std::vector<std::string> workspaceNames) { + void + checkWorkspacesExistInADS(const std::vector<std::string> &workspaceNames) { for (auto &ws : workspaceNames) TS_ASSERT(AnalysisDataService::Instance().doesExist(ws)); } - void removeWorkspacesFromADS(std::vector<std::string> workspaceNames) { + void removeWorkspacesFromADS(const std::vector<std::string> &workspaceNames) { for (auto &ws : workspaceNames) AnalysisDataService::Instance().remove(ws); } diff --git a/qt/widgets/common/test/ProjectSaveModelTest.h b/qt/widgets/common/test/ProjectSaveModelTest.h index 31977d77ce3380a3d119d0cf3919af165d4925b5..9489c88aced403f84adc23f78969dbfa8271ffdf 100644 --- a/qt/widgets/common/test/ProjectSaveModelTest.h +++ b/qt/widgets/common/test/ProjectSaveModelTest.h @@ -17,6 +17,8 @@ #include <cxxtest/TestSuite.h> #include <gmock/gmock.h> +#include <utility> + using namespace MantidQt::API; using namespace MantidQt::MantidWidgets; using namespace testing; @@ -28,17 +30,18 @@ GNU_DIAG_OFF_SUGGEST_OVERRIDE class MockProjectSaveModel : public ProjectSaveModel { public: MockProjectSaveModel( - std::vector<MantidQt::API::IProjectSerialisable *> windows, + const std::vector<MantidQt::API::IProjectSerialisable *> &windows, std::vector<std::string> activePythonInterfaces = std::vector<std::string>()) - : ProjectSaveModel(windows, activePythonInterfaces) {} + : ProjectSaveModel(std::move(windows), + std::move(activePythonInterfaces)) {} MOCK_METHOD1(getProjectSize, size_t(const std::vector<std::string> &wsNames)); }; GNU_DIAG_ON_SUGGEST_OVERRIDE namespace { -size_t calculateSize(std::vector<Workspace_sptr> workspaces) { +size_t calculateSize(const std::vector<Workspace_sptr> &workspaces) { size_t result = 0; for (const auto &ws : workspaces) { result += ws->getMemorySize(); diff --git a/qt/widgets/common/test/WorkspacePresenter/WorkspacePresenterTest.h b/qt/widgets/common/test/WorkspacePresenter/WorkspacePresenterTest.h index ce64cbfef79f482a5af7c7a249b03695cba5cdba..916adb5874e612fc6e7e7075a2314394df85d5af 100644 --- a/qt/widgets/common/test/WorkspacePresenter/WorkspacePresenterTest.h +++ b/qt/widgets/common/test/WorkspacePresenter/WorkspacePresenterTest.h @@ -657,7 +657,7 @@ private: boost::shared_ptr<NiceMock<MockWorkspaceDockView>> mockView; WorkspacePresenterVN_sptr presenter; - void createGroup(std::string groupName) { + void createGroup(const std::string &groupName) { auto group = WorkspaceCreationHelper::createWorkspaceGroup(0, 10, 10, groupName); auto wksp1 = WorkspaceCreationHelper::create2DWorkspace(10, 10); @@ -669,7 +669,7 @@ private: AnalysisDataService::Instance().addToGroup(groupName, "wksp2"); } - void removeGroup(std::string groupName) { + void removeGroup(const std::string &groupName) { AnalysisDataService::Instance().deepRemoveGroup(groupName); } }; diff --git a/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/InstrumentActor.h b/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/InstrumentActor.h index dd8c977526fdec0ef31d79c124feec9dcfdecac5..12f95b9866f86c07bfd5ce3ed37bc44c86fe353e 100644 --- a/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/InstrumentActor.h +++ b/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/InstrumentActor.h @@ -216,9 +216,10 @@ signals: void colorMapChanged() const; private: - void setUpWorkspace( - boost::shared_ptr<const Mantid::API::MatrixWorkspace> sharedWorkspace, - double scaleMin, double scaleMax); + void + setUpWorkspace(const boost::shared_ptr<const Mantid::API::MatrixWorkspace> + &sharedWorkspace, + double scaleMin, double scaleMax); void setupPhysicalInstrumentIfExists(); void resetColors(); void loadSettings(); diff --git a/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/InstrumentTreeWidget.h b/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/InstrumentTreeWidget.h index eb0f5f9c17b29de73e1f0fe2cde91cd7cc88e059..20a66988fdde9c2119298d806bcbe97ad046f78c 100644 --- a/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/InstrumentTreeWidget.h +++ b/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/InstrumentTreeWidget.h @@ -39,7 +39,7 @@ public: QStringList findExpandedComponents(const QModelIndex &parent = QModelIndex()) const; public slots: - void sendComponentSelectedSignal(const QModelIndex /*index*/); + void sendComponentSelectedSignal(const QModelIndex & /*index*/); signals: void componentSelected(size_t /*_t1*/); diff --git a/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/InstrumentWidget.h b/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/InstrumentWidget.h index 33e697c4735d00ebac6c85a4cd6e4a39f284a90c..1592f4fcd6f8889ab820e781b4b2852200a59d27 100644 --- a/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/InstrumentWidget.h +++ b/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/InstrumentWidget.h @@ -117,7 +117,7 @@ public: /// Recalculate the detector data and redraw the instrument view void updateInstrumentDetectors(); /// Delete the peaks workspace. - void deletePeaksWorkspace(Mantid::API::IPeaksWorkspace_sptr pws); + void deletePeaksWorkspace(const Mantid::API::IPeaksWorkspace_sptr &pws); /// Alter data from a script. These just foward calls to the 3D widget void setColorMapMinValue(double minValue); @@ -148,7 +148,7 @@ public: bool hasWorkspace(const std::string &wsName) const; void handleWorkspaceReplacement( const std::string &wsName, - const boost::shared_ptr<Mantid::API::Workspace> workspace); + const boost::shared_ptr<Mantid::API::Workspace> &workspace); /// Get the currently selected tab index int getCurrentTab() const; @@ -193,7 +193,7 @@ public slots: void tabChanged(int /*unused*/); void componentSelected(size_t componentIndex); void executeAlgorithm(const QString & /*unused*/, const QString & /*unused*/); - void executeAlgorithm(Mantid::API::IAlgorithm_sptr /*alg*/); + void executeAlgorithm(const Mantid::API::IAlgorithm_sptr & /*alg*/); void setupColorMap(); @@ -325,11 +325,11 @@ private: const std::string &newName) override; void clearADSHandle() override; /// overlay a peaks workspace on the projection surface - void overlayPeaksWorkspace(Mantid::API::IPeaksWorkspace_sptr ws); + void overlayPeaksWorkspace(const Mantid::API::IPeaksWorkspace_sptr &ws); /// overlay a masked workspace on the projection surface - void overlayMaskedWorkspace(Mantid::API::IMaskWorkspace_sptr ws); + void overlayMaskedWorkspace(const Mantid::API::IMaskWorkspace_sptr &ws); /// overlay a table workspace with shape parameters on the projection surface - void overlayShapesWorkspace(Mantid::API::ITableWorkspace_sptr /*ws*/); + void overlayShapesWorkspace(const Mantid::API::ITableWorkspace_sptr & /*ws*/); /// get a workspace from the ADS Mantid::API::Workspace_sptr getWorkspaceFromADS(const std::string &name); /// get a handle to the unwrapped surface diff --git a/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/InstrumentWidgetRenderTab.h b/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/InstrumentWidgetRenderTab.h index e5f9794f2b97db54017bcb63f94b610454197611..fc2dce20e2753ae9a7743e13aacf7d645d76a119 100644 --- a/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/InstrumentWidgetRenderTab.h +++ b/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/InstrumentWidgetRenderTab.h @@ -71,7 +71,7 @@ public slots: void changeColorMap(const QString &filename = ""); void setSurfaceType(int /*index*/); void flipUnwrappedView(bool /*on*/); - void saveImage(QString filename = ""); + void saveImage(const QString &filename = ""); private slots: diff --git a/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/MantidGLWidget.h b/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/MantidGLWidget.h index 19216c20d91f5199173f569bcd82264537b42f67..049049a3fbc7d0f4130aa8e6aca9e40e952ff3a5 100644 --- a/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/MantidGLWidget.h +++ b/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/MantidGLWidget.h @@ -30,7 +30,7 @@ public: void setSurface(boost::shared_ptr<ProjectionSurface> surface); boost::shared_ptr<ProjectionSurface> getSurface() { return m_surface; } - void setBackgroundColor(QColor /*input*/); + void setBackgroundColor(const QColor & /*input*/); QColor currentBackgroundColor() const; void saveToFile(const QString &filename); // int getLightingState() const {return m_lightingState;} diff --git a/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/PeakMarker2D.h b/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/PeakMarker2D.h index 36265b569ee78776ce6f7b330412d640bd6ea347..5935ef11dc24dae69397c4f62e1813dd7b3a7def 100644 --- a/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/PeakMarker2D.h +++ b/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/PeakMarker2D.h @@ -6,6 +6,8 @@ // SPDX - License - Identifier: GPL - 3.0 + #pragma once +#include <utility> + #include "MantidGeometry/Crystal/IPeak.h" #include "Shape2D.h" @@ -23,8 +25,9 @@ class PeakMarker2D : public Shape2D { public: enum Symbol { Circle = 0, Diamond, Square }; struct Style { - Style(Symbol sb = Circle, QColor c = Qt::red, int sz = g_defaultMarkerSize) - : symbol(sb), color(c), size(sz) {} + Style(Symbol sb = Circle, const QColor &c = Qt::red, + int sz = g_defaultMarkerSize) + : symbol(sb), color(std::move(c)), size(sz) {} Symbol symbol; QColor color; int size; diff --git a/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/PeakOverlay.h b/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/PeakOverlay.h index d3f4595fdacaf42525eb46ec8b71b05eb7c68d6b..134d4f8eb1cc340c76204336c73f838e60531dce 100644 --- a/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/PeakOverlay.h +++ b/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/PeakOverlay.h @@ -122,7 +122,7 @@ class PeakOverlay : public Shape2DCollection, Q_OBJECT public: PeakOverlay(UnwrappedSurface *surface, - boost::shared_ptr<Mantid::API::IPeaksWorkspace> pws); + const boost::shared_ptr<Mantid::API::IPeaksWorkspace> &pws); ~PeakOverlay() override {} /// Override the drawing method void draw(QPainter &painter) const override; @@ -146,7 +146,7 @@ public: void setShowLabelsFlag(bool yes) { m_showLabels = yes; } void setShowRelativeIntensityFlag(bool yes); static PeakMarker2D::Style getDefaultStyle(int index); - void setPeakVisibility(double xmin, double xmax, QString units); + void setPeakVisibility(double xmin, double xmax, const QString &units); signals: void executeAlgorithm(Mantid::API::IAlgorithm_sptr /*_t1*/); diff --git a/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/PlotFitAnalysisPaneModel.h b/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/PlotFitAnalysisPaneModel.h index 3084622be38b21fc4c1add2ea75184d007a9c8dd..d3f799633cf97ec2f18eadcf71bb6b544116c489 100644 --- a/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/PlotFitAnalysisPaneModel.h +++ b/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/PlotFitAnalysisPaneModel.h @@ -19,7 +19,7 @@ class PlotFitAnalysisPaneModel { public: IFunction_sptr doFit(const std::string &wsName, const std::pair<double, double> &range, - const IFunction_sptr func); + const IFunction_sptr &func); }; } // namespace MantidWidgets diff --git a/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/PlotFitAnalysisPaneView.h b/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/PlotFitAnalysisPaneView.h index 51db83e9ceb1e1c8c12e1398cfe6f7d28177af01..63764ebde7ee1ee02cf07eaef2e518a41f57e547 100644 --- a/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/PlotFitAnalysisPaneView.h +++ b/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/PlotFitAnalysisPaneView.h @@ -35,10 +35,10 @@ public: }; std::pair<double, double> getRange(); Mantid::API::IFunction_sptr getFunction(); - void addSpectrum(std::string wsName); - void addFitSpectrum(std::string wsName); + void addSpectrum(const std::string &wsName); + void addFitSpectrum(const std::string &wsName); void addFunction(Mantid::API::IFunction_sptr func); - void updateFunction(Mantid::API::IFunction_sptr func); + void updateFunction(const Mantid::API::IFunction_sptr &func); void fitWarning(const std::string &message); public slots: diff --git a/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/ProjectionSurface.h b/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/ProjectionSurface.h index 4d13f8079d6a4350c98055dd122918904f6e23d4..3e557dc36d092b1384fc4b9a574e141056e360b6 100644 --- a/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/ProjectionSurface.h +++ b/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/ProjectionSurface.h @@ -235,7 +235,8 @@ public: /// Save masks to a table workspace void saveShapesToTableWorkspace(); /// Load masks from a table workspace - void loadShapesFromTableWorkspace(Mantid::API::ITableWorkspace_const_sptr ws); + void loadShapesFromTableWorkspace( + const Mantid::API::ITableWorkspace_const_sptr &ws); //----------------------------------- // Peaks overlay methods @@ -244,7 +245,8 @@ public: QList<PeakMarker2D *> getMarkersWithID(int detID) const; boost::shared_ptr<Mantid::API::IPeaksWorkspace> getEditPeaksWorkspace() const; QStringList getPeaksWorkspaceNames() const; - void deletePeaksWorkspace(boost::shared_ptr<Mantid::API::IPeaksWorkspace> ws); + void deletePeaksWorkspace( + const boost::shared_ptr<Mantid::API::IPeaksWorkspace> &ws); void clearPeakOverlays(); void clearAlignmentPlane(); void clearComparisonPeaks(); diff --git a/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/Shape2DCollection.h b/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/Shape2DCollection.h index eefdd65ed15d0145bbe77afdd1991d5b5a835abe..4546c0b021a7348d1004bc61158e21bd4b870dfd 100644 --- a/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/Shape2DCollection.h +++ b/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/Shape2DCollection.h @@ -96,7 +96,8 @@ public: /// Save shape collection to a Table workspace void saveToTableWorkspace(); /// Load shape collectio from a Table workspace - void loadFromTableWorkspace(Mantid::API::ITableWorkspace_const_sptr ws); + void + loadFromTableWorkspace(const Mantid::API::ITableWorkspace_const_sptr &ws); /// Load settings for the shape 2D collection from a project file virtual void loadFromProject(const std::string &lines); /// Save settings for the shape 2D collection to a project file diff --git a/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/UnwrappedDetector.h b/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/UnwrappedDetector.h index 28a33c3632a71701112cee74c18295858c5fdd46..9a35771d759efc6600d428d6b20e81a7fa039db5 100644 --- a/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/UnwrappedDetector.h +++ b/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/UnwrappedDetector.h @@ -34,7 +34,7 @@ This class keeps information used to draw a detector on an unwrapped surface. class UnwrappedDetector { public: UnwrappedDetector(); - UnwrappedDetector(GLColor color, size_t detIndex); + UnwrappedDetector(const GLColor &color, size_t detIndex); UnwrappedDetector(const UnwrappedDetector &other); UnwrappedDetector &operator=(const UnwrappedDetector &other); bool empty() const; diff --git a/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/UnwrappedSurface.h b/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/UnwrappedSurface.h index 84a3d5934d3d3701a71dc33eaae81b93cfd6cc62..44b56e70a32d17b31f17794d7fbc0b89da960c29 100644 --- a/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/UnwrappedSurface.h +++ b/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/UnwrappedSurface.h @@ -67,7 +67,8 @@ public: void componentSelected(size_t componentIndex) override; void getSelectedDetectors(std::vector<size_t> &detIndices) override; void getMaskedDetectors(std::vector<size_t> &detIndices) const override; - void setPeaksWorkspace(boost::shared_ptr<Mantid::API::IPeaksWorkspace> pws); + void + setPeaksWorkspace(const boost::shared_ptr<Mantid::API::IPeaksWorkspace> &pws); QString getInfoText() const override; RectF getSurfaceBounds() const override; //@} diff --git a/qt/widgets/instrumentview/src/InstrumentActor.cpp b/qt/widgets/instrumentview/src/InstrumentActor.cpp index 43de0c06ec5986acd7fd59f0b3818acc8418f59b..b82e897367471665aac3f858cb5f9a8e18518a3e 100644 --- a/qt/widgets/instrumentview/src/InstrumentActor.cpp +++ b/qt/widgets/instrumentview/src/InstrumentActor.cpp @@ -38,6 +38,7 @@ #include <limits> #include <numeric> +#include <utility> using namespace Mantid::Kernel::Exception; using namespace Mantid::Geometry; @@ -140,7 +141,8 @@ InstrumentActor::~InstrumentActor() { saveSettings(); } * value is ignored. */ void InstrumentActor::setUpWorkspace( - boost::shared_ptr<const Mantid::API::MatrixWorkspace> sharedWorkspace, + const boost::shared_ptr<const Mantid::API::MatrixWorkspace> + &sharedWorkspace, double scaleMin, double scaleMax) { m_WkspBinMinValue = DBL_MAX; m_WkspBinMaxValue = -DBL_MAX; @@ -257,7 +259,7 @@ MatrixWorkspace_sptr InstrumentActor::getMaskMatrixWorkspace() const { */ void InstrumentActor::setMaskMatrixWorkspace( MatrixWorkspace_sptr wsMask) const { - m_maskWorkspace = wsMask; + m_maskWorkspace = std::move(wsMask); } void InstrumentActor::invertMaskWorkspace() const { diff --git a/qt/widgets/instrumentview/src/InstrumentTreeWidget.cpp b/qt/widgets/instrumentview/src/InstrumentTreeWidget.cpp index 5809d78c549f031833cc4e87488b20991dc175b0..558c6dbce2f4ee9cf6508c91bc0d50310711aae9 100644 --- a/qt/widgets/instrumentview/src/InstrumentTreeWidget.cpp +++ b/qt/widgets/instrumentview/src/InstrumentTreeWidget.cpp @@ -70,7 +70,7 @@ InstrumentTreeWidget::findComponentByName(const QString &name) const { } void InstrumentTreeWidget::sendComponentSelectedSignal( - const QModelIndex index) { + const QModelIndex &index) { auto selectedIndex = InstrumentTreeModel::extractIndex(index); m_instrWidget->getInstrumentActor().setComponentVisible(selectedIndex); emit componentSelected(selectedIndex); diff --git a/qt/widgets/instrumentview/src/InstrumentWidget.cpp b/qt/widgets/instrumentview/src/InstrumentWidget.cpp index a2b103af25cf47a33550dbbb4f71a25df2686c99..dd0dab3d9d22dd4e61aaee6ee57f9deaedb2ef88 100644 --- a/qt/widgets/instrumentview/src/InstrumentWidget.cpp +++ b/qt/widgets/instrumentview/src/InstrumentWidget.cpp @@ -65,6 +65,7 @@ #include <numeric> #include <stdexcept> +#include <utility> using namespace Mantid::API; using namespace Mantid::Geometry; @@ -893,7 +894,8 @@ void InstrumentWidget::executeAlgorithm(const QString & /*unused*/, // emit execMantidAlgorithm(alg_name, param_list, this); } -void InstrumentWidget::executeAlgorithm(Mantid::API::IAlgorithm_sptr alg) { +void InstrumentWidget::executeAlgorithm( + const Mantid::API::IAlgorithm_sptr &alg) { try { alg->executeAsync(); } catch (Poco::NoThreadAvailableException &) { @@ -1184,8 +1186,8 @@ void InstrumentWidget::updateInstrumentDetectors() { } void InstrumentWidget::deletePeaksWorkspace( - Mantid::API::IPeaksWorkspace_sptr pws) { - this->getSurface()->deletePeaksWorkspace(pws); + const Mantid::API::IPeaksWorkspace_sptr &pws) { + this->getSurface()->deletePeaksWorkspace(std::move(pws)); updateInstrumentView(); } @@ -1336,7 +1338,7 @@ bool InstrumentWidget::hasWorkspace(const std::string &wsName) const { } void InstrumentWidget::handleWorkspaceReplacement( - const std::string &wsName, const boost::shared_ptr<Workspace> workspace) { + const std::string &wsName, const boost::shared_ptr<Workspace> &workspace) { if (!hasWorkspace(wsName) || !m_instrumentActor) { return; } @@ -1400,10 +1402,10 @@ void InstrumentWidget::clearADSHandle() { * Overlay a peaks workspace on the surface projection * @param ws :: peaks workspace to overlay */ -void InstrumentWidget::overlayPeaksWorkspace(IPeaksWorkspace_sptr ws) { +void InstrumentWidget::overlayPeaksWorkspace(const IPeaksWorkspace_sptr &ws) { auto surface = getUnwrappedSurface(); if (surface) { - surface->setPeaksWorkspace(ws); + surface->setPeaksWorkspace(std::move(ws)); updateInstrumentView(); } } @@ -1412,7 +1414,7 @@ void InstrumentWidget::overlayPeaksWorkspace(IPeaksWorkspace_sptr ws) { * Overlay a mask workspace on the surface projection * @param ws :: mask workspace to overlay */ -void InstrumentWidget::overlayMaskedWorkspace(IMaskWorkspace_sptr ws) { +void InstrumentWidget::overlayMaskedWorkspace(const IMaskWorkspace_sptr &ws) { auto &actor = getInstrumentActor(); actor.setMaskMatrixWorkspace( boost::dynamic_pointer_cast<Mantid::API::MatrixWorkspace>(ws)); @@ -1425,7 +1427,7 @@ void InstrumentWidget::overlayMaskedWorkspace(IMaskWorkspace_sptr ws) { * Overlay a table workspace containing shape parameters * @param ws :: a workspace of shape parameters to create */ -void InstrumentWidget::overlayShapesWorkspace(ITableWorkspace_sptr ws) { +void InstrumentWidget::overlayShapesWorkspace(const ITableWorkspace_sptr &ws) { auto surface = getUnwrappedSurface(); if (surface) { surface->loadShapesFromTableWorkspace(ws); diff --git a/qt/widgets/instrumentview/src/InstrumentWidgetRenderTab.cpp b/qt/widgets/instrumentview/src/InstrumentWidgetRenderTab.cpp index 6b212df0eb02e6bd7e5c1d145f73a5bc2b5b2ca9..1709377cd178b4a70976839ceb357bebd7c59e08 100644 --- a/qt/widgets/instrumentview/src/InstrumentWidgetRenderTab.cpp +++ b/qt/widgets/instrumentview/src/InstrumentWidgetRenderTab.cpp @@ -35,6 +35,7 @@ #include "MantidQtWidgets/InstrumentView/InstrumentWidget.h" #include <limits> +#include <utility> namespace MantidQt { namespace MantidWidgets { @@ -610,8 +611,8 @@ void InstrumentWidgetRenderTab::flipUnwrappedView(bool on) { * for finding the file * @param filename Optional full path of the saved image */ -void InstrumentWidgetRenderTab::saveImage(QString filename) { - m_instrWidget->saveImage(filename); +void InstrumentWidgetRenderTab::saveImage(const QString &filename) { + m_instrWidget->saveImage(std::move(filename)); } /** diff --git a/qt/widgets/instrumentview/src/MantidGLWidget.cpp b/qt/widgets/instrumentview/src/MantidGLWidget.cpp index de77556d24a27ee2b0399e6d260d905d069a857e..227fe14cefcb06d50720106c6e07661bb3273523 100644 --- a/qt/widgets/instrumentview/src/MantidGLWidget.cpp +++ b/qt/widgets/instrumentview/src/MantidGLWidget.cpp @@ -23,6 +23,7 @@ #include <map> #include <string> #include <typeinfo> +#include <utility> namespace MantidQt { namespace MantidWidgets { @@ -57,7 +58,7 @@ MantidGLWidget::MantidGLWidget(QWidget *parent) MantidGLWidget::~MantidGLWidget() {} void MantidGLWidget::setSurface(boost::shared_ptr<ProjectionSurface> surface) { - m_surface = surface; + m_surface = std::move(surface); connect(m_surface.get(), SIGNAL(redrawRequired()), this, SLOT(repaint()), Qt::QueuedConnection); m_firstFrame = true; @@ -227,7 +228,7 @@ void MantidGLWidget::keyReleaseEvent(QKeyEvent *event) { /** * This method set the background color. */ -void MantidGLWidget::setBackgroundColor(QColor input) { +void MantidGLWidget::setBackgroundColor(const QColor &input) { makeCurrent(); glClearColor(GLclampf(input.red() / 255.0), GLclampf(input.green() / 255.0), GLclampf(input.blue() / 255.0), 1.0); diff --git a/qt/widgets/instrumentview/src/MiniPlotMpl.cpp b/qt/widgets/instrumentview/src/MiniPlotMpl.cpp index 4ecdb1aea4397e76927953e0167e4b8836e2276a..1a721c83a084edeffff3e5c0be6cd5902733fe66 100644 --- a/qt/widgets/instrumentview/src/MiniPlotMpl.cpp +++ b/qt/widgets/instrumentview/src/MiniPlotMpl.cpp @@ -20,6 +20,7 @@ #include <QPushButton> #include <QSpacerItem> #include <QVBoxLayout> +#include <utility> using Mantid::PythonInterface::GlobalInterpreterLock; using MantidQt::Widgets::MplCpp::cycler; @@ -116,7 +117,7 @@ void MiniPlotMpl::setData(std::vector<double> x, std::vector<double> y, // plot automatically calls "scalex=True, scaley=True" m_lines.emplace_back( axes.plot(std::move(x), std::move(y), ACTIVE_CURVE_FORMAT)); - m_activeCurveLabel = curveLabel; + m_activeCurveLabel = std::move(curveLabel); setXLabel(std::move(xunit)); // If the current axis limits can fit the data then matplotlib // won't change the axis scale. If the intensity of different plots diff --git a/qt/widgets/instrumentview/src/MiniPlotQwt.cpp b/qt/widgets/instrumentview/src/MiniPlotQwt.cpp index f8d5806e4dc551caf1e86e82525d88975c12fe25..8283466913532d29b23805efbdc63ca8a03dca18 100644 --- a/qt/widgets/instrumentview/src/MiniPlotQwt.cpp +++ b/qt/widgets/instrumentview/src/MiniPlotQwt.cpp @@ -24,6 +24,7 @@ #include <QPainter> #include <cmath> +#include <utility> namespace { Mantid::Kernel::Logger g_log("MiniPlotQwt"); @@ -72,7 +73,7 @@ MiniPlotQwt::~MiniPlotQwt() { clearAll(); } * @param xunit */ void MiniPlotQwt::setXLabel(QString xunit) { - m_xUnits = xunit; + m_xUnits = std::move(xunit); this->setAxisTitle(xBottom, m_xUnits); } @@ -238,8 +239,8 @@ void MiniPlotQwt::setData(std::vector<double> x, std::vector<double> y, return; } - m_xUnits = xunit; - m_label = curveLabel; + m_xUnits = std::move(xunit); + m_label = std::move(curveLabel); if (!m_curve) { m_curve = new QwtPlotCurve(); m_curve->attach(this); diff --git a/qt/widgets/instrumentview/src/PeakOverlay.cpp b/qt/widgets/instrumentview/src/PeakOverlay.cpp index 05ef068ed7b82e79f352eb3d3f30c7400ddb0da3..9311990a846b82475f2c5f48bf73f88830c9bffd 100644 --- a/qt/widgets/instrumentview/src/PeakOverlay.cpp +++ b/qt/widgets/instrumentview/src/PeakOverlay.cpp @@ -176,8 +176,9 @@ int QualitativeIntensityScale::getIntensityLevel(double intensity) const { /**--------------------------------------------------------------------- * Constructor */ -PeakOverlay::PeakOverlay(UnwrappedSurface *surface, - boost::shared_ptr<Mantid::API::IPeaksWorkspace> pws) +PeakOverlay::PeakOverlay( + UnwrappedSurface *surface, + const boost::shared_ptr<Mantid::API::IPeaksWorkspace> &pws) : Shape2DCollection(), m_peaksWorkspace(pws), m_surface(surface), m_precision(6), m_showRows(true), m_showLabels(true), m_peakIntensityScale(std::make_unique<QualitativeIntensityScale>(pws)) { @@ -416,7 +417,8 @@ PeakMarker2D::Style PeakOverlay::getDefaultStyle(int index) { * @param units :: Units of the x - array in the underlying workspace: * "TOF", "dSpacing", or "Wavelength". */ -void PeakOverlay::setPeakVisibility(double xmin, double xmax, QString units) { +void PeakOverlay::setPeakVisibility(double xmin, double xmax, + const QString &units) { enum XUnits { Unknown, TOF, dSpacing, Wavelength }; XUnits xUnits = Unknown; if (units == "TOF") diff --git a/qt/widgets/instrumentview/src/PlotFitAnalysisPaneModel.cpp b/qt/widgets/instrumentview/src/PlotFitAnalysisPaneModel.cpp index d31692b947433a1437ba442edb23b6abfa11a226..0b5e38f9cb4c7327362c7a71cacdebc7321396aa 100644 --- a/qt/widgets/instrumentview/src/PlotFitAnalysisPaneModel.cpp +++ b/qt/widgets/instrumentview/src/PlotFitAnalysisPaneModel.cpp @@ -15,7 +15,7 @@ namespace MantidWidgets { IFunction_sptr PlotFitAnalysisPaneModel::doFit(const std::string &wsName, const std::pair<double, double> &range, - IFunction_sptr func) { + const IFunction_sptr &func) { IAlgorithm_sptr alg = AlgorithmManager::Instance().create("Fit"); alg->initialize(); diff --git a/qt/widgets/instrumentview/src/PlotFitAnalysisPanePresenter.cpp b/qt/widgets/instrumentview/src/PlotFitAnalysisPanePresenter.cpp index 73b45b00ffd5331796a341912f8a9123e5a2f15a..792eab3751772c81d364add6699f3ef7a7e93ba7 100644 --- a/qt/widgets/instrumentview/src/PlotFitAnalysisPanePresenter.cpp +++ b/qt/widgets/instrumentview/src/PlotFitAnalysisPanePresenter.cpp @@ -9,6 +9,7 @@ #include <exception> #include <functional> #include <tuple> +#include <utility> namespace MantidQt { namespace MantidWidgets { @@ -42,7 +43,7 @@ void PlotFitAnalysisPanePresenter::doFit() { void PlotFitAnalysisPanePresenter::addFunction( Mantid::API::IFunction_sptr func) { - m_view->addFunction(func); + m_view->addFunction(std::move(func)); } void PlotFitAnalysisPanePresenter::addSpectrum(const std::string &wsName) { diff --git a/qt/widgets/instrumentview/src/PlotFitAnalysisPaneView.cpp b/qt/widgets/instrumentview/src/PlotFitAnalysisPaneView.cpp index 5f2ea4000543b90c5b57da4fa1d337b0c6b78303..044ea34f26d526bfceb772195b5bbf189f8953a4 100644 --- a/qt/widgets/instrumentview/src/PlotFitAnalysisPaneView.cpp +++ b/qt/widgets/instrumentview/src/PlotFitAnalysisPaneView.cpp @@ -15,6 +15,8 @@ #include <QSpacerItem> #include <QSplitter> #include <QVBoxLayout> +#include <utility> + namespace MantidQt { namespace MantidWidgets { @@ -86,10 +88,10 @@ void PlotFitAnalysisPaneView::doFit() { } } -void PlotFitAnalysisPaneView::addSpectrum(std::string wsName) { +void PlotFitAnalysisPaneView::addSpectrum(const std::string &wsName) { m_plot->addSpectrum("Extracted Data", wsName.c_str(), 0, Qt::black); } -void PlotFitAnalysisPaneView::addFitSpectrum(std::string wsName) { +void PlotFitAnalysisPaneView::addFitSpectrum(const std::string &wsName) { m_plot->addSpectrum("Fitted Data", wsName.c_str(), 1, Qt::red); } @@ -103,12 +105,13 @@ Mantid::API::IFunction_sptr PlotFitAnalysisPaneView::getFunction() { return m_fitBrowser->getFunction(); } -void PlotFitAnalysisPaneView::updateFunction(Mantid::API::IFunction_sptr func) { +void PlotFitAnalysisPaneView::updateFunction( + const Mantid::API::IFunction_sptr &func) { m_fitBrowser->updateMultiDatasetParameters(*func); } void PlotFitAnalysisPaneView::addFunction(Mantid::API::IFunction_sptr func) { - m_fitBrowser->setFunction(func); + m_fitBrowser->setFunction(std::move(func)); } void PlotFitAnalysisPaneView::fitWarning(const std::string &message) { diff --git a/qt/widgets/instrumentview/src/ProjectionSurface.cpp b/qt/widgets/instrumentview/src/ProjectionSurface.cpp index 350e38d7e9969481777859f392978b09c9880141..9b9d0667480e89fa5b1627a735e31c3bb2f47a95 100644 --- a/qt/widgets/instrumentview/src/ProjectionSurface.cpp +++ b/qt/widgets/instrumentview/src/ProjectionSurface.cpp @@ -33,6 +33,7 @@ #include <cfloat> #include <cmath> #include <limits> +#include <utility> using Mantid::Kernel::V3D; @@ -689,8 +690,8 @@ void ProjectionSurface::saveShapesToTableWorkspace() { * @param ws :: table workspace to load shapes from */ void ProjectionSurface::loadShapesFromTableWorkspace( - Mantid::API::ITableWorkspace_const_sptr ws) { - m_maskShapes.loadFromTableWorkspace(ws); + const Mantid::API::ITableWorkspace_const_sptr &ws) { + m_maskShapes.loadFromTableWorkspace(std::move(ws)); } /** @@ -721,7 +722,7 @@ ProjectionSurface::getEditPeaksWorkspace() const { * @param ws :: Shared pointer to the deleted peaks workspace. */ void ProjectionSurface::deletePeaksWorkspace( - boost::shared_ptr<Mantid::API::IPeaksWorkspace> ws) { + const boost::shared_ptr<Mantid::API::IPeaksWorkspace> &ws) { const int npeaks = m_peakShapes.size(); for (int i = 0; i < npeaks; ++i) { if (m_peakShapes[i]->getPeaksWorkspace() == ws) { diff --git a/qt/widgets/instrumentview/src/Shape2DCollection.cpp b/qt/widgets/instrumentview/src/Shape2DCollection.cpp index 31fa6c27c8012ad6fd581fbdef8d50dffb4fc66c..762dfc384f2f1cb208a512e56ebb03d1624551e0 100644 --- a/qt/widgets/instrumentview/src/Shape2DCollection.cpp +++ b/qt/widgets/instrumentview/src/Shape2DCollection.cpp @@ -677,7 +677,7 @@ void Shape2DCollection::saveToTableWorkspace() { * @param ws :: table workspace to load shapes from. */ void Shape2DCollection::loadFromTableWorkspace( - Mantid::API::ITableWorkspace_const_sptr ws) { + const Mantid::API::ITableWorkspace_const_sptr &ws) { using namespace Mantid::API; auto columnNames = ws->getColumnNames(); diff --git a/qt/widgets/instrumentview/src/SimpleWidget.cpp b/qt/widgets/instrumentview/src/SimpleWidget.cpp index aad5c279317dcc3bb40092aea30c9fd519ace4d2..8b1842ded58b2d41268bbe341044ca80bc02ed7b 100644 --- a/qt/widgets/instrumentview/src/SimpleWidget.cpp +++ b/qt/widgets/instrumentview/src/SimpleWidget.cpp @@ -9,6 +9,7 @@ #include <QApplication> #include <QPixmap> +#include <utility> namespace MantidQt { namespace MantidWidgets { @@ -25,7 +26,7 @@ SimpleWidget::~SimpleWidget() {} /// Assign a surface to draw on void SimpleWidget::setSurface(boost::shared_ptr<ProjectionSurface> surface) { - m_surface = surface; + m_surface = std::move(surface); connect(m_surface.get(), SIGNAL(redrawRequired()), this, SLOT(repaint()), Qt::QueuedConnection); } diff --git a/qt/widgets/instrumentview/src/UnwrappedDetector.cpp b/qt/widgets/instrumentview/src/UnwrappedDetector.cpp index fde0abeff9eb728731c39e5005d55336ce425b24..6e09fd0c7778e6b30477c4ffbcfc296847cc8b3c 100644 --- a/qt/widgets/instrumentview/src/UnwrappedDetector.cpp +++ b/qt/widgets/instrumentview/src/UnwrappedDetector.cpp @@ -18,7 +18,7 @@ UnwrappedDetector::UnwrappedDetector() color = GLColor(0, 0, 0); } -UnwrappedDetector::UnwrappedDetector(GLColor color, size_t detIndex) +UnwrappedDetector::UnwrappedDetector(const GLColor &color, size_t detIndex) : u(0), v(0), width(0), height(0), uscale(0), vscale(0), detIndex(detIndex) { this->color = color; diff --git a/qt/widgets/instrumentview/src/UnwrappedSurface.cpp b/qt/widgets/instrumentview/src/UnwrappedSurface.cpp index 4661474e0b4c0e04b0467ef2945bd4f4ef0c900b..81bd7c3068df2cb5a5fce2a6647454ea2a59e76f 100644 --- a/qt/widgets/instrumentview/src/UnwrappedSurface.cpp +++ b/qt/widgets/instrumentview/src/UnwrappedSurface.cpp @@ -226,8 +226,9 @@ void UnwrappedSurface::setColor(size_t index, bool picking) const { } } -bool hasParent(boost::shared_ptr<const Mantid::Geometry::IComponent> comp, - Mantid::Geometry::ComponentID id) { +bool hasParent( + const boost::shared_ptr<const Mantid::Geometry::IComponent> &comp, + Mantid::Geometry::ComponentID id) { boost::shared_ptr<const Mantid::Geometry::IComponent> parent = comp->getParent(); if (!parent) @@ -362,7 +363,7 @@ RectF UnwrappedSurface::getSurfaceBounds() const { return m_viewRect; } * @param pws :: A shared pointer to the workspace. */ void UnwrappedSurface::setPeaksWorkspace( - boost::shared_ptr<Mantid::API::IPeaksWorkspace> pws) { + const boost::shared_ptr<Mantid::API::IPeaksWorkspace> &pws) { if (!pws) { return; } diff --git a/qt/widgets/mplcpp/inc/MantidQtWidgets/MplCpp/Artist.h b/qt/widgets/mplcpp/inc/MantidQtWidgets/MplCpp/Artist.h index 6e8ccc100814d2c55ee55c69188d287b8dde9729..e00b29ba706b86c68c93daee2fa19390cc9e45fd 100644 --- a/qt/widgets/mplcpp/inc/MantidQtWidgets/MplCpp/Artist.h +++ b/qt/widgets/mplcpp/inc/MantidQtWidgets/MplCpp/Artist.h @@ -21,7 +21,7 @@ public: // Holds a reference to the matplotlib artist object explicit Artist(Common::Python::Object obj); - void set(Common::Python::Dict kwargs); + void set(const Common::Python::Dict &kwargs); void remove(); }; diff --git a/qt/widgets/mplcpp/inc/MantidQtWidgets/MplCpp/Axes.h b/qt/widgets/mplcpp/inc/MantidQtWidgets/MplCpp/Axes.h index b9bdf7ee6110b4e5158d00862ceca18636a329d3..c85cd575f371598b62919a5034df43eef68334e0 100644 --- a/qt/widgets/mplcpp/inc/MantidQtWidgets/MplCpp/Axes.h +++ b/qt/widgets/mplcpp/inc/MantidQtWidgets/MplCpp/Axes.h @@ -27,7 +27,7 @@ public: /// Function-signature required for operation applied to each artist using ArtistOperation = std::function<void(Artist &&)>; void forEachArtist(const char *containerAttr, const ArtistOperation &op); - void removeArtists(const char *containerAttr, const QString label); + void removeArtists(const char *containerAttr, const QString &label); void setXLabel(const char *label); void setYLabel(const char *label); void setTitle(const char *label); @@ -40,8 +40,8 @@ public: Line2D plot(std::vector<double> xdata, std::vector<double> ydata, const char *format = "b-"); Line2D plot(std::vector<double> xdata, std::vector<double> ydata, - const QString format, const QString label); - Artist text(double x, double y, QString text, + const QString &format, const QString &label); + Artist text(double x, double y, const QString &text, const char *horizontalAlignment); /// @} diff --git a/qt/widgets/mplcpp/inc/MantidQtWidgets/MplCpp/Cycler.h b/qt/widgets/mplcpp/inc/MantidQtWidgets/MplCpp/Cycler.h index cc1bd6f7e7ec0deadee11d06153eb85229bc42f7..64058256db2bea93dc6f84d651a10b9a4cf3ce8f 100644 --- a/qt/widgets/mplcpp/inc/MantidQtWidgets/MplCpp/Cycler.h +++ b/qt/widgets/mplcpp/inc/MantidQtWidgets/MplCpp/Cycler.h @@ -24,7 +24,7 @@ namespace MplCpp { */ class MANTID_MPLCPP_DLL Cycler : public Common::Python::InstanceHolder { public: - Cycler(Common::Python::Object obj); + Cycler(const Common::Python::Object &obj); /// Return the next value in the sequence Common::Python::Dict operator()() const; diff --git a/qt/widgets/mplcpp/inc/MantidQtWidgets/MplCpp/Figure.h b/qt/widgets/mplcpp/inc/MantidQtWidgets/MplCpp/Figure.h index a38a3b10d9a998bf42d8b65facf39d74805b880b..61c1171108b5c2e9091e6b74ff1fa6cec3587a89 100644 --- a/qt/widgets/mplcpp/inc/MantidQtWidgets/MplCpp/Figure.h +++ b/qt/widgets/mplcpp/inc/MantidQtWidgets/MplCpp/Figure.h @@ -46,10 +46,10 @@ public: void setTightLayout(QHash<QString, QVariant> const &args); QColor faceColor() const; - void setFaceColor(const QColor color); + void setFaceColor(const QColor &color); void setFaceColor(const char *color); Axes addAxes(double left, double bottom, double width, double height); - Axes addSubPlot(const int subplotspec, const QString projection = ""); + Axes addSubPlot(const int subplotspec, const QString &projection = ""); Common::Python::Object colorbar(const ScalarMappable &mappable, const Axes &cax, const Common::Python::Object &ticks = Common::Python::Object(), diff --git a/qt/widgets/mplcpp/inc/MantidQtWidgets/MplCpp/FigureCanvasQt.h b/qt/widgets/mplcpp/inc/MantidQtWidgets/MplCpp/FigureCanvasQt.h index eb11150f311831b36a6457b5d67ae346f75b543d..63320a265a16e63c46a6e596451a1fda7a03b088 100644 --- a/qt/widgets/mplcpp/inc/MantidQtWidgets/MplCpp/FigureCanvasQt.h +++ b/qt/widgets/mplcpp/inc/MantidQtWidgets/MplCpp/FigureCanvasQt.h @@ -26,7 +26,7 @@ class MANTID_MPLCPP_DLL FigureCanvasQt : public QWidget, public Common::Python::InstanceHolder { Q_OBJECT public: - FigureCanvasQt(const int subplotspec, const QString projection = "", + FigureCanvasQt(const int subplotspec, const QString &projection = "", QWidget *parent = nullptr); FigureCanvasQt(Figure fig, QWidget *parent = nullptr); diff --git a/qt/widgets/mplcpp/inc/MantidQtWidgets/MplCpp/MantidAxes.h b/qt/widgets/mplcpp/inc/MantidQtWidgets/MplCpp/MantidAxes.h index 07e10c445010c85b1109158805f32485dca2f4f8..23730a5fafa46b7890287082694e439323f73287 100644 --- a/qt/widgets/mplcpp/inc/MantidQtWidgets/MplCpp/MantidAxes.h +++ b/qt/widgets/mplcpp/inc/MantidQtWidgets/MplCpp/MantidAxes.h @@ -30,13 +30,13 @@ public: /// @name Plot creation functions ///@{ Line2D plot(const Mantid::API::MatrixWorkspace_sptr &workspace, - const size_t wkspIndex, const QString lineColour, - const QString label, + const size_t wkspIndex, const QString &lineColour, + const QString &label, const boost::optional<QHash<QString, QVariant>> &otherKwargs = boost::none); ErrorbarContainer errorbar(const Mantid::API::MatrixWorkspace_sptr &workspace, - const size_t wkspIndex, const QString lineColour, - const QString label, + const size_t wkspIndex, const QString &lineColour, + const QString &label, const boost::optional<QHash<QString, QVariant>> &otherKwargs = boost::none); void pcolormesh(const Mantid::API::MatrixWorkspace_sptr &workspace, diff --git a/qt/widgets/mplcpp/src/Artist.cpp b/qt/widgets/mplcpp/src/Artist.cpp index e6044471c6b3c28b5a4d9d5568ea716d42f5683d..cb5ef776d850c25dd18a411d3ae70d71f39f3f9a 100644 --- a/qt/widgets/mplcpp/src/Artist.cpp +++ b/qt/widgets/mplcpp/src/Artist.cpp @@ -26,7 +26,7 @@ Artist::Artist(Python::Object obj) : InstanceHolder(std::move(obj), "draw") {} * Set properties on the Artist given by the dict of kwargs * @param kwargs A dict of known matplotlib.artist.Artist properties */ -void Artist::set(Python::Dict kwargs) { +void Artist::set(const Python::Dict &kwargs) { GlobalInterpreterLock lock; auto args = Python::NewRef(Py_BuildValue("()")); pyobj().attr("set")(*args, **kwargs); diff --git a/qt/widgets/mplcpp/src/Axes.cpp b/qt/widgets/mplcpp/src/Axes.cpp index e950f310831338be12a8b5056ba8e00c1a84bd83..09d8e8869eea22983a8b27c72dd76447f2cd61e2 100644 --- a/qt/widgets/mplcpp/src/Axes.cpp +++ b/qt/widgets/mplcpp/src/Axes.cpp @@ -85,7 +85,7 @@ void Axes::forEachArtist(const char *containerAttr, const ArtistOperation &op) { * @param containerAttr The name of the container attribute * @param label The label of the artists to remove */ -void Axes::removeArtists(const char *containerAttr, const QString label) { +void Axes::removeArtists(const char *containerAttr, const QString &label) { GlobalInterpreterLock lock; const auto lineNameAsUnicode = Python::NewRef(PyUnicode_FromString(label.toLatin1().constData())); @@ -166,7 +166,7 @@ Artist Axes::legendInstance() const { * the canvas as the vector data will be destroyed. */ Line2D Axes::plot(std::vector<double> xdata, std::vector<double> ydata, - const QString format, const QString label) { + const QString &format, const QString &label) { GlobalInterpreterLock lock; auto line2d = plot(std::move(xdata), std::move(ydata), format.toLatin1().constData()); @@ -221,7 +221,7 @@ Line2D Axes::plot(std::vector<double> xdata, std::vector<double> ydata, * @param horizontalAlignment A string indicating the horizontal * alignment of the string */ -Artist Axes::text(double x, double y, QString text, +Artist Axes::text(double x, double y, const QString &text, const char *horizontalAlignment) { GlobalInterpreterLock lock; auto args = diff --git a/qt/widgets/mplcpp/src/Colormap.cpp b/qt/widgets/mplcpp/src/Colormap.cpp index ba7d580526c7f3cb92e52b82b97aefe1e70bb850..8083106aa7009c2899b901dfa78876c5814599e3 100644 --- a/qt/widgets/mplcpp/src/Colormap.cpp +++ b/qt/widgets/mplcpp/src/Colormap.cpp @@ -4,6 +4,8 @@ // NScD Oak Ridge National Laboratory, European Spallation Source, // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + +#include <utility> + #include "MantidQtWidgets/MplCpp/Colormap.h" #include "MantidQtWidgets/MplCpp/Colors.h" @@ -21,7 +23,7 @@ namespace MplCpp { * @brief Construct a Colormap object given a name */ Colormap::Colormap(Python::Object obj) - : Python::InstanceHolder(obj, "is_gray") {} + : Python::InstanceHolder(std::move(obj), "is_gray") {} /** * @return A reference to the matplotlib.cm module diff --git a/qt/widgets/mplcpp/src/Cycler.cpp b/qt/widgets/mplcpp/src/Cycler.cpp index 50cb3ac14733644b3e9f15af1807d93211325832..d1c83065728f46da29486e00ddc8bbdbe9e2a2fe 100644 --- a/qt/widgets/mplcpp/src/Cycler.cpp +++ b/qt/widgets/mplcpp/src/Cycler.cpp @@ -40,7 +40,7 @@ Python::Object cycleIterator(const Python::Object &rawCycler) { * that produces an iterable * @param obj An existing instance of a Cycler object */ -Cycler::Cycler(Python::Object obj) +Cycler::Cycler(const Python::Object &obj) : Python::InstanceHolder(cycleIterator(std::move(obj))) {} /** diff --git a/qt/widgets/mplcpp/src/Figure.cpp b/qt/widgets/mplcpp/src/Figure.cpp index 2853d932e11e1cffb486fbf3c622cf1027e66c91..41f9d66d9e7ec5c425e21df9b57c4619e073cf16 100644 --- a/qt/widgets/mplcpp/src/Figure.cpp +++ b/qt/widgets/mplcpp/src/Figure.cpp @@ -58,7 +58,7 @@ QColor Figure::faceColor() const { * @param color A character string indicating the color. * See https://matplotlib.org/api/colors_api.html */ -void Figure::setFaceColor(const QColor color) { +void Figure::setFaceColor(const QColor &color) { callMethodNoCheck<void, const char *>( pyobj(), "set_facecolor", color.name(QColor::HexRgb).toLatin1().constData()); @@ -103,7 +103,7 @@ Axes Figure::addAxes(double left, double bottom, double width, double height) { * @param projection An optional string denoting the projection type * @return A wrapper around the Axes object */ -Axes Figure::addSubPlot(const int subplotspec, const QString projection) { +Axes Figure::addSubPlot(const int subplotspec, const QString &projection) { GlobalInterpreterLock lock; if (projection.isEmpty()) return Axes{pyobj().attr("add_subplot")(subplotspec)}; diff --git a/qt/widgets/mplcpp/src/FigureCanvasQt.cpp b/qt/widgets/mplcpp/src/FigureCanvasQt.cpp index c0edcadcb5e38ceb3183233c74536db44cda3d96..354d007dbf60adcc0ac06ba8340b918ed3139e9c 100644 --- a/qt/widgets/mplcpp/src/FigureCanvasQt.cpp +++ b/qt/widgets/mplcpp/src/FigureCanvasQt.cpp @@ -30,7 +30,7 @@ const char *DEFAULT_FACECOLOR = "w"; * @param fig An existing matplotlib Figure instance * @return A new FigureCanvasQT object */ -Python::Object createPyCanvasFromFigure(Figure fig) { +Python::Object createPyCanvasFromFigure(const Figure &fig) { GlobalInterpreterLock lock; return backendModule().attr("FigureCanvasQTAgg")(fig.pyobj()); } @@ -41,7 +41,8 @@ Python::Object createPyCanvasFromFigure(Figure fig) { * @param projection A string denoting the projection to use * @return A new FigureCanvasQT object */ -Python::Object createPyCanvas(const int subplotspec, const QString projection) { +Python::Object createPyCanvas(const int subplotspec, + const QString &projection) { Figure fig{true}; fig.setFaceColor(DEFAULT_FACECOLOR); @@ -73,7 +74,7 @@ QWidget *initLayout(FigureCanvasQt *cppCanvas) { * @param projection A string denoting the projection to use on the canvas * @param parent The owning parent widget */ -FigureCanvasQt::FigureCanvasQt(const int subplotspec, const QString projection, +FigureCanvasQt::FigureCanvasQt(const int subplotspec, const QString &projection, QWidget *parent) : QWidget(parent), InstanceHolder(createPyCanvas(subplotspec, projection), "draw"), diff --git a/qt/widgets/mplcpp/src/MantidAxes.cpp b/qt/widgets/mplcpp/src/MantidAxes.cpp index a16f33d4158f638ee52b1d12a03a9a96f270e4fa..81ad08271e79f81c78e7f72a03297613d07fb7f0 100644 --- a/qt/widgets/mplcpp/src/MantidAxes.cpp +++ b/qt/widgets/mplcpp/src/MantidAxes.cpp @@ -34,8 +34,8 @@ MantidAxes::MantidAxes(Python::Object pyObj) : Axes{std::move(pyObj)} {} */ Line2D MantidAxes::plot(const Mantid::API::MatrixWorkspace_sptr &workspace, - const size_t wkspIndex, const QString lineColour, - const QString label, + const size_t wkspIndex, const QString &lineColour, + const QString &label, const boost::optional<QHash<QString, QVariant>> &otherKwargs) { GlobalInterpreterLock lock; const auto wksp = Python::NewRef(MatrixWorkpaceToPython()(workspace)); @@ -61,7 +61,7 @@ MantidAxes::plot(const Mantid::API::MatrixWorkspace_sptr &workspace, */ ErrorbarContainer MantidAxes::errorbar( const Mantid::API::MatrixWorkspace_sptr &workspace, const size_t wkspIndex, - const QString lineColour, const QString label, + const QString &lineColour, const QString &label, const boost::optional<QHash<QString, QVariant>> &otherKwargs) { GlobalInterpreterLock lock; const auto wksp = Python::NewRef(MatrixWorkpaceToPython()(workspace)); diff --git a/qt/widgets/mplcpp/src/Plot.cpp b/qt/widgets/mplcpp/src/Plot.cpp index c9c989d4eb565825e14185aa8ee72158c9e9d3f1..cb324f79ad4e36dbf7d038fd3b8251b406749da5 100644 --- a/qt/widgets/mplcpp/src/Plot.cpp +++ b/qt/widgets/mplcpp/src/Plot.cpp @@ -5,12 +5,15 @@ // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + #include "MantidQtWidgets/MplCpp/Plot.h" + #include "MantidPythonInterface/core/CallMethod.h" #include "MantidPythonInterface/core/Converters/ToPyList.h" #include "MantidPythonInterface/core/GlobalInterpreterLock.h" #include "MantidQtWidgets/Common/Python/Object.h" #include "MantidQtWidgets/Common/Python/QHashToDict.h" #include "MantidQtWidgets/Common/Python/Sip.h" +#include "MantidQtWidgets/MplCpp/Plot.h" +#include <utility> using namespace Mantid::PythonInterface; using namespace MantidQt::Widgets::Common; @@ -102,9 +105,10 @@ Python::Object plot(const Python::Object &args, boost::optional<QHash<QString, QVariant>> axProperties, boost::optional<std::string> windowTitle, bool errors, bool overplot, bool tiled) { - const auto kwargs = - constructKwargs(spectrumNums, wkspIndices, fig, plotKwargs, axProperties, - windowTitle, errors, overplot, tiled); + const auto kwargs = constructKwargs( + std::move(spectrumNums), std::move(wkspIndices), std::move(fig), + std::move(plotKwargs), std::move(axProperties), std::move(windowTitle), + errors, overplot, tiled); try { return functionsModule().attr("plot")(*args, **kwargs); } catch (Python::ErrorAlreadySet &) { diff --git a/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Mpl/ContourPreviewPlot.h b/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Mpl/ContourPreviewPlot.h index fafd2d672cba9041159619aebaaa88a978dc6fe5..634c1b4aed2109ecedb655283e3f25a50d8f351b 100644 --- a/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Mpl/ContourPreviewPlot.h +++ b/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Mpl/ContourPreviewPlot.h @@ -39,7 +39,7 @@ public: void setCanvasColour(QColor const &colour); - void setWorkspace(Mantid::API::MatrixWorkspace_sptr workspace); + void setWorkspace(const Mantid::API::MatrixWorkspace_sptr &workspace); std::tuple<double, double> getAxisRange(AxisID axisID) const; diff --git a/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Mpl/PreviewPlot.h b/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Mpl/PreviewPlot.h index 4c07a0cd02708ec0753f578ff232696bb952c30c..a320af8b07b44318d7d4cd91fb00b4f7fcc66247 100644 --- a/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Mpl/PreviewPlot.h +++ b/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Mpl/PreviewPlot.h @@ -94,8 +94,8 @@ public slots: void clear(); void resizeX(); void resetView(); - void setCanvasColour(QColor colour); - void setLinesWithErrors(QStringList labels); + void setCanvasColour(const QColor &colour); + void setLinesWithErrors(const QStringList &labels); void showLegend(bool visible); void replot(); @@ -136,7 +136,7 @@ private: void switchPlotTool(QAction *selected); void setXScaleType(QAction *selected); void setYScaleType(QAction *selected); - void setScaleType(AxisID id, QString actionName); + void setScaleType(AxisID id, const QString &actionName); void toggleLegend(const bool checked); boost::optional<char const *> overrideAxisLabel(AxisID const &axisID); diff --git a/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Qwt/ContourPreviewPlot.h b/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Qwt/ContourPreviewPlot.h index 7e6e878cdd9f9168a6c94f76108c0f3cddeeb725..0ffe6150789bbe527bc91187033fa9c6c1ee9b8e 100644 --- a/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Qwt/ContourPreviewPlot.h +++ b/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Qwt/ContourPreviewPlot.h @@ -52,7 +52,7 @@ public: ~ContourPreviewPlot() override; Mantid::API::MatrixWorkspace_sptr getActiveWorkspace() const; - void setWorkspace(Mantid::API::MatrixWorkspace_sptr const workspace); + void setWorkspace(Mantid::API::MatrixWorkspace_sptr const &workspace); SafeQwtPlot *getPlot2D(); void setPlotVisible(bool const &visible); diff --git a/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Qwt/DisplayCurveFit.h b/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Qwt/DisplayCurveFit.h index dcbd15cfaf794ef1a00de26fd14415a2c23b2e5c..58f0c0091cf878702d607c11b517eee9ddbf46de 100644 --- a/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Qwt/DisplayCurveFit.h +++ b/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Qwt/DisplayCurveFit.h @@ -57,12 +57,12 @@ public: void setAxisRange(QPair<double, double> range, AxisID axisID = AxisID::XBottom); curveTypes - getCurvesForWorkspace(const Mantid::API::MatrixWorkspace_sptr workspace); + getCurvesForWorkspace(const Mantid::API::MatrixWorkspace_sptr &workspace); QPair<double, double> getCurveRange(const curveType &atype); QPair<double, double> - getCurveRange(const Mantid::API::MatrixWorkspace_sptr workspace); + getCurveRange(const Mantid::API::MatrixWorkspace_sptr &workspace); void addSpectrum(const curveType &aType, - const Mantid::API::MatrixWorkspace_sptr workspace, + const Mantid::API::MatrixWorkspace_sptr &workspace, const size_t specIndex = 0); void removeSpectrum(const curveType &aType); bool hasCurve(const curveType &aType); diff --git a/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Qwt/MWView.h b/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Qwt/MWView.h index 5e21b68f7366892c7d9ddc24e9298a70f77ebeb2..7b5fdca0c9c4ad951fefd30c8b79ed614d6728ab 100644 --- a/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Qwt/MWView.h +++ b/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Qwt/MWView.h @@ -58,8 +58,8 @@ class EXPORT_OPT_MANTIDQT_PLOTTING MWView public: MWView(QWidget *parent = nullptr); ~MWView() override; - void loadColorMap(QString filename = QString()); - void setWorkspace(Mantid::API::MatrixWorkspace_sptr ws); + void loadColorMap(const QString &filename = QString()); + void setWorkspace(const Mantid::API::MatrixWorkspace_sptr &ws); void updateDisplay(); SafeQwtPlot *getPlot2D(); diff --git a/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Qwt/PeakPicker.h b/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Qwt/PeakPicker.h index c8fbdbffa31cbad9e309d5256341ab2f236fdddd..a68fb643c69766291be97d78c588b70baabc4e1f 100644 --- a/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Qwt/PeakPicker.h +++ b/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Qwt/PeakPicker.h @@ -28,8 +28,8 @@ class EXPORT_OPT_MANTIDQT_PLOTTING PeakPicker : public QwtPlotPicker, public: /// Constructor - PeakPicker(QwtPlot *plot, QColor color); - PeakPicker(PreviewPlot *plot, QColor color); + PeakPicker(QwtPlot *plot, const QColor &color); + PeakPicker(PreviewPlot *plot, const QColor &color); /// Correct QwtPlotItem type info int rtti() const override { return QwtPlotItem::Rtti_PlotMarker; } diff --git a/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Qwt/PreviewPlot.h b/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Qwt/PreviewPlot.h index 8b7f9bb5b097b58bd3809bfca44b946851f77102..49b16a49db50eba65fab72edcee7918e91b8a258 100644 --- a/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Qwt/PreviewPlot.h +++ b/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Qwt/PreviewPlot.h @@ -73,7 +73,7 @@ public: getAxisRange(AxisID axisID = AxisID::XBottom) const; QPair<double, double> - getCurveRange(const Mantid::API::MatrixWorkspace_sptr ws); + getCurveRange(const Mantid::API::MatrixWorkspace_sptr &ws); QPair<double, double> getCurveRange(const QString &curveName); void addSpectrum( @@ -85,7 +85,7 @@ public: const QColor &curveColour = QColor(), const QHash<QString, QVariant> &plotKwargs = QHash<QString, QVariant>()); - void removeSpectrum(const Mantid::API::MatrixWorkspace_sptr ws); + void removeSpectrum(const Mantid::API::MatrixWorkspace_sptr &ws); void removeSpectrum(const QString &curveName); bool hasCurve(const QString &curveName); @@ -157,16 +157,19 @@ private: const QColor &curveColour, const QString &curveName = ""); void removeCurve(QwtPlotItem *curve); - QList<QAction *> addOptionsToMenus(QString menuName, QActionGroup *group, - QStringList items, QString defaultItem); + QList<QAction *> addOptionsToMenus(const QString &menuName, + QActionGroup *group, + const QStringList &items, + const QString &defaultItem); - QStringList getCurvesForWorkspace(const Mantid::API::MatrixWorkspace_sptr ws); + QStringList + getCurvesForWorkspace(const Mantid::API::MatrixWorkspace_sptr &ws); private slots: void showContextMenu(QPoint position); void handleViewToolSelect(); void handleAxisTypeSelect(); - void removeWorkspace(Mantid::API::MatrixWorkspace_sptr ws); + void removeWorkspace(const Mantid::API::MatrixWorkspace_sptr &ws); private: Ui::PreviewPlot m_uiForm; diff --git a/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Qwt/QwtHelper.h b/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Qwt/QwtHelper.h index 12eeac6d4b0b63bbf37d43983e993f51034f4751..17ce370ae64f8f5a2b323df3a39cf60b8dc7bae6 100644 --- a/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Qwt/QwtHelper.h +++ b/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Qwt/QwtHelper.h @@ -18,25 +18,27 @@ namespace API { namespace QwtHelper { /// Create Qwt curve data from a workspace EXPORT_OPT_MANTIDQT_PLOTTING boost::shared_ptr<QwtData> -curveDataFromWs(Mantid::API::MatrixWorkspace_const_sptr ws, size_t wsIndex); +curveDataFromWs(const Mantid::API::MatrixWorkspace_const_sptr &ws, + size_t wsIndex); /// Create vector of Qwt curve data from a workspace, used for EnggDiffraction /// GUI EXPORT_OPT_MANTIDQT_PLOTTING std::vector<boost::shared_ptr<QwtData>> -curveDataFromWs(Mantid::API::MatrixWorkspace_const_sptr ws); +curveDataFromWs(const Mantid::API::MatrixWorkspace_const_sptr &ws); /// Create error vector from a workspace EXPORT_OPT_MANTIDQT_PLOTTING std::vector<double> -curveErrorsFromWs(Mantid::API::MatrixWorkspace_const_sptr ws, size_t wsIndex); +curveErrorsFromWs(const Mantid::API::MatrixWorkspace_const_sptr &ws, + size_t wsIndex); /// Create Qwt curve data from a function EXPORT_OPT_MANTIDQT_PLOTTING boost::shared_ptr<QwtData> -curveDataFromFunction(Mantid::API::IFunction_const_sptr func, +curveDataFromFunction(const Mantid::API::IFunction_const_sptr &func, const std::vector<double> &xValues); /// Create workspace filled with function values EXPORT_OPT_MANTIDQT_PLOTTING Mantid::API::MatrixWorkspace_sptr -createWsFromFunction(Mantid::API::IFunction_const_sptr func, +createWsFromFunction(const Mantid::API::IFunction_const_sptr &func, const std::vector<double> &xValues); /// Creates empty Qwt curve data diff --git a/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Qwt/QwtRasterDataMD.h b/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Qwt/QwtRasterDataMD.h index 01d90f854a6bf57825ba48e588691f51300253cf..1aa5cf4eaf438acad30934c7f4d3891387fafeff 100644 --- a/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Qwt/QwtRasterDataMD.h +++ b/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Qwt/QwtRasterDataMD.h @@ -41,7 +41,7 @@ public: virtual void setWorkspace(Mantid::API::IMDWorkspace_const_sptr ws); Mantid::API::IMDWorkspace_const_sptr getWorkspace() const; - void setOverlayWorkspace(Mantid::API::IMDWorkspace_const_sptr ws); + void setOverlayWorkspace(const Mantid::API::IMDWorkspace_const_sptr &ws); QwtDoubleInterval range() const override; void setRange(const QwtDoubleInterval &range); diff --git a/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Qwt/RangeSelector.h b/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Qwt/RangeSelector.h index 37e57137f43e092e02fad75a2a56607f36a686d7..ab37db3277dd760ac5c3ed2a8b2058f4fae8bddd 100644 --- a/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Qwt/RangeSelector.h +++ b/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Qwt/RangeSelector.h @@ -56,7 +56,7 @@ public slots: void setMaximum(double /*val*/); ///< outside setting of value void reapply(); ///< re-apply the range selector lines void detach(); ///< Detach range selector lines from the plot - void setColour(QColor colour); + void setColour(const QColor &colour); void setInfoOnly(bool state); void setVisible(bool state); diff --git a/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Qwt/ScaleEngine.h b/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Qwt/ScaleEngine.h index 8a6667050281c60f343225f0c7afca1c7ae4f68a..937e569189b54c5c9f8c85a846c6db8494345b8e 100644 --- a/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Qwt/ScaleEngine.h +++ b/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Qwt/ScaleEngine.h @@ -45,8 +45,8 @@ public: : QwtScaleTransformation(Other), d_engine(engine){}; double xForm(double x, double /*s1*/, double /*s2*/, double p1, double p2) const override; - double invXForm(double x, double s1, double s2, double p1, - double p2) const override; + double invXForm(double p, double p1, double p2, double s1, + double s2) const override; QwtScaleTransformation *copy() const override; ~ScaleTransformation() override; diff --git a/qt/widgets/plotting/src/Mpl/ContourPreviewPlot.cpp b/qt/widgets/plotting/src/Mpl/ContourPreviewPlot.cpp index 599e863bfc554bd38ff9343eccfa2ae6f91ae4ba..ab7ddad5de5dc56f94ffa33e6d52aa543f8b568f 100644 --- a/qt/widgets/plotting/src/Mpl/ContourPreviewPlot.cpp +++ b/qt/widgets/plotting/src/Mpl/ContourPreviewPlot.cpp @@ -104,7 +104,7 @@ void ContourPreviewPlot::setCanvasColour(QColor const &colour) { * Sets the workspace for the contour plot * @param workspace The workspace to plot on the contour plot. */ -void ContourPreviewPlot::setWorkspace(MatrixWorkspace_sptr workspace) { +void ContourPreviewPlot::setWorkspace(const MatrixWorkspace_sptr &workspace) { if (workspace) { auto axes = m_canvas->gca<MantidAxes>(); axes.pcolormesh(workspace); diff --git a/qt/widgets/plotting/src/Mpl/PreviewPlot.cpp b/qt/widgets/plotting/src/Mpl/PreviewPlot.cpp index 8ede39c537e8f6a9651cfffe654448ab58f4ce26..08faa6ab84c6b9c86217ae909cb21984ad110e91 100644 --- a/qt/widgets/plotting/src/Mpl/PreviewPlot.cpp +++ b/qt/widgets/plotting/src/Mpl/PreviewPlot.cpp @@ -19,6 +19,7 @@ #include <QVBoxLayout> #include <algorithm> +#include <utility> using Mantid::API::AnalysisDataService; using Mantid::API::MatrixWorkspace; @@ -354,15 +355,15 @@ void PreviewPlot::resetView() { * Set the face colour for the canvas * @param colour A new colour for the figure facecolor */ -void PreviewPlot::setCanvasColour(QColor colour) { - m_canvas->gcf().setFaceColor(colour); +void PreviewPlot::setCanvasColour(const QColor &colour) { + m_canvas->gcf().setFaceColor(std::move(colour)); } /** * @brief PreviewPlot::setLinesWithErrors * @param labels A list of line labels where error bars should be shown */ -void PreviewPlot::setLinesWithErrors(QStringList labels) { +void PreviewPlot::setLinesWithErrors(const QStringList &labels) { for (const QString &label : labels) { m_lines[label] = true; } @@ -685,7 +686,7 @@ void PreviewPlot::setYScaleType(QAction *selected) { setScaleType(AxisID::YLeft, selected->text()); } -void PreviewPlot::setScaleType(AxisID id, QString actionName) { +void PreviewPlot::setScaleType(AxisID id, const QString &actionName) { auto scaleType = actionName.toLower().toLatin1(); auto axes = m_canvas->gca(); switch (id) { diff --git a/qt/widgets/plotting/src/Qwt/ContourPreviewPlot.cpp b/qt/widgets/plotting/src/Qwt/ContourPreviewPlot.cpp index 71b159b1fc9d1fa5db1ac88f765030a08495a7ca..7e2ac2f8c44553669c1f7f7ac132c744abba3a5c 100644 --- a/qt/widgets/plotting/src/Qwt/ContourPreviewPlot.cpp +++ b/qt/widgets/plotting/src/Qwt/ContourPreviewPlot.cpp @@ -31,7 +31,7 @@ namespace { Mantid::Kernel::Logger g_log("ContourPreviewPlot"); MatrixWorkspace_sptr -convertToMatrixWorkspace(boost::shared_ptr<Workspace> const workspace) { +convertToMatrixWorkspace(boost::shared_ptr<Workspace> const &workspace) { return boost::dynamic_pointer_cast<MatrixWorkspace>(workspace); } @@ -79,7 +79,7 @@ MatrixWorkspace_sptr ContourPreviewPlot::getActiveWorkspace() const { /** * Initialize objects after loading the workspace */ -void ContourPreviewPlot::setWorkspace(MatrixWorkspace_sptr const workspace) { +void ContourPreviewPlot::setWorkspace(MatrixWorkspace_sptr const &workspace) { m_workspace = workspace; this->checkRangeLimits(); m_data->setWorkspace(workspace); diff --git a/qt/widgets/plotting/src/Qwt/DisplayCurveFit.cpp b/qt/widgets/plotting/src/Qwt/DisplayCurveFit.cpp index dcfb2b3c6aefe584dea937faf9814a2c66dbca3e..c4ca4641697322eb3e555b7274e29c00ad00f36e 100644 --- a/qt/widgets/plotting/src/Qwt/DisplayCurveFit.cpp +++ b/qt/widgets/plotting/src/Qwt/DisplayCurveFit.cpp @@ -76,7 +76,7 @@ void DisplayCurveFit::setAxisRange(QPair<double, double> range, AxisID axisID) { * @return a std::vector containing the curve types */ DisplayCurveFit::curveTypes DisplayCurveFit::getCurvesForWorkspace( - const Mantid::API::MatrixWorkspace_sptr workspace) { + const Mantid::API::MatrixWorkspace_sptr &workspace) { QStringList curveNames = m_uiForm.fitPlot->getCurvesForWorkspace(workspace); curveNames = curveNames + m_uiForm.residualsPlot->getCurvesForWorkspace(workspace); @@ -103,7 +103,7 @@ QPair<double, double> DisplayCurveFit::getCurveRange(const curveType &atype) { * workspace */ QPair<double, double> DisplayCurveFit::getCurveRange( - const Mantid::API::MatrixWorkspace_sptr workspace) { + const Mantid::API::MatrixWorkspace_sptr &workspace) { curveTypes typesFound = this->getCurvesForWorkspace(workspace); if (typesFound.size() == 0) { throw std::runtime_error("No fitting curves associated to workspace" + @@ -119,7 +119,7 @@ QPair<double, double> DisplayCurveFit::getCurveRange( * @param specIndex Spectrum index of workspace argument. */ void DisplayCurveFit::addSpectrum( - const curveType &aType, const Mantid::API::MatrixWorkspace_sptr workspace, + const curveType &aType, const Mantid::API::MatrixWorkspace_sptr &workspace, const size_t specIndex) { const QString &curveName{m_curveTypeToQString.at(aType)}; const QColor curveColor(m_curveTypeToColor.at(aType)); diff --git a/qt/widgets/plotting/src/Qwt/MWView.cpp b/qt/widgets/plotting/src/Qwt/MWView.cpp index 2cd925473618e5e5f6a3d8bf32babffb76a07b8a..c7fea8b389f2196e66b1ee82abc2a15a6c77891a 100644 --- a/qt/widgets/plotting/src/Qwt/MWView.cpp +++ b/qt/widgets/plotting/src/Qwt/MWView.cpp @@ -63,7 +63,7 @@ MWView::~MWView() { * * @param filename :: file to open; empty to ask via a dialog box. */ -void MWView::loadColorMap(QString filename) { +void MWView::loadColorMap(const QString &filename) { QString fileselection; if (filename.isEmpty()) { fileselection = MantidColorMap::chooseColorMap(m_currentColorMapFile, this); @@ -81,7 +81,7 @@ void MWView::loadColorMap(QString filename) { /** * @brief Initialize objects after loading the workspace, and observe. */ -void MWView::setWorkspace(Mantid::API::MatrixWorkspace_sptr ws) { +void MWView::setWorkspace(const Mantid::API::MatrixWorkspace_sptr &ws) { m_workspace = ws; this->checkRangeLimits(); m_data->setWorkspace(ws); diff --git a/qt/widgets/plotting/src/Qwt/MantidQwtIMDWorkspaceData.cpp b/qt/widgets/plotting/src/Qwt/MantidQwtIMDWorkspaceData.cpp index 7e55f94fa6d0f1ef6138830cb2aea93bd805d21f..969ade58360305666ecfacd7189ae8e39d428a58 100644 --- a/qt/widgets/plotting/src/Qwt/MantidQwtIMDWorkspaceData.cpp +++ b/qt/widgets/plotting/src/Qwt/MantidQwtIMDWorkspaceData.cpp @@ -15,6 +15,7 @@ #include "MantidGeometry/MDGeometry/MDTypes.h" #include "MantidQtWidgets/Common/QStringUtils.h" #include <QStringBuilder> +#include <utility> using MantidQt::API::toQStringInternal; using namespace Mantid::Kernel; @@ -39,7 +40,7 @@ MantidQwtIMDWorkspaceData::MantidQwtIMDWorkspaceData( Mantid::API::IMDWorkspace_const_sptr workspace, const bool logScaleY, Mantid::Kernel::VMD start, Mantid::Kernel::VMD end, Mantid::API::MDNormalization normalize, bool isDistribution) - : MantidQwtWorkspaceData(logScaleY), m_workspace(workspace), + : MantidQwtWorkspaceData(logScaleY), m_workspace(std::move(workspace)), m_preview(false), m_start(start), m_end(end), m_normalization(normalize), m_isDistribution(isDistribution), m_transform(nullptr), m_plotAxis(PlotDistance), m_currentPlotAxis(PlotDistance) { diff --git a/qt/widgets/plotting/src/Qwt/PeakPicker.cpp b/qt/widgets/plotting/src/Qwt/PeakPicker.cpp index 62a5c8fc6275cae04c38b1b03515ee4bc70b80d8..0c00852b62e8fbc02f0f96cbadfc56339abd3533 100644 --- a/qt/widgets/plotting/src/Qwt/PeakPicker.cpp +++ b/qt/widgets/plotting/src/Qwt/PeakPicker.cpp @@ -24,7 +24,7 @@ const Qt::CursorShape PeakPicker::DEFAULT_CURSOR = Qt::PointingHandCursor; * @param plot :: A plot this peak picker should operate on * @param color :: Peak picker color */ -PeakPicker::PeakPicker(QwtPlot *plot, QColor color) +PeakPicker::PeakPicker(QwtPlot *plot, const QColor &color) : QwtPlotPicker(plot->canvas()), QwtPlotItem(), m_plot(plot), m_basePen(color, 0, Qt::SolidLine), m_widthPen(color, 0, Qt::DashLine), m_isMoving(false), m_isResizing(false), m_peak() { @@ -32,7 +32,7 @@ PeakPicker::PeakPicker(QwtPlot *plot, QColor color) plot->canvas()->setCursor(DEFAULT_CURSOR); } -PeakPicker::PeakPicker(PreviewPlot *plot, QColor color) +PeakPicker::PeakPicker(PreviewPlot *plot, const QColor &color) : QwtPlotPicker(plot->canvas()), QwtPlotItem(), m_plot(plot->getPlot()), m_basePen(color, 0, Qt::SolidLine), m_widthPen(color, 0, Qt::DashLine), m_isMoving(false), m_isResizing(false), m_peak() { diff --git a/qt/widgets/plotting/src/Qwt/PreviewPlot.cpp b/qt/widgets/plotting/src/Qwt/PreviewPlot.cpp index 7dd0ac92a87523298c5bac91b42864cea1ea933b..72333906a1fc96d001e1f1d30f58f2a8523e1663 100644 --- a/qt/widgets/plotting/src/Qwt/PreviewPlot.cpp +++ b/qt/widgets/plotting/src/Qwt/PreviewPlot.cpp @@ -17,6 +17,7 @@ #include <QAction> #include <QPalette> +#include <utility> #include <qwt_array.h> #include <qwt_data.h> @@ -240,7 +241,7 @@ std::tuple<double, double> PreviewPlot::getAxisRange(AxisID axisID) const { * @param ws Pointer to workspace */ QPair<double, double> -PreviewPlot::getCurveRange(const Mantid::API::MatrixWorkspace_sptr ws) { +PreviewPlot::getCurveRange(const Mantid::API::MatrixWorkspace_sptr &ws) { QStringList curveNames = getCurvesForWorkspace(ws); if (curveNames.size() == 0) @@ -365,7 +366,7 @@ void PreviewPlot::addSpectrum(const QString &curveName, const QString &wsName, * * @param ws Pointer to workspace */ -void PreviewPlot::removeSpectrum(const MatrixWorkspace_sptr ws) { +void PreviewPlot::removeSpectrum(const MatrixWorkspace_sptr &ws) { if (!ws) { g_log.error("Cannot remove curve for null workspace"); return; @@ -658,9 +659,9 @@ void PreviewPlot::handleRemoveEvent(WorkspacePreDeleteNotification_ptr pNf) { * * @param ws the workspace that is being removed. */ -void PreviewPlot::removeWorkspace(MatrixWorkspace_sptr ws) { +void PreviewPlot::removeWorkspace(const MatrixWorkspace_sptr &ws) { // Remove the workspace on the main GUI thread - removeSpectrum(ws); + removeSpectrum(std::move(ws)); emit needToReplot(); } @@ -820,10 +821,10 @@ void PreviewPlot::removeCurve(QwtPlotItem *curve) { * @param defaultItem Default item name * @return List of Actions added */ -QList<QAction *> PreviewPlot::addOptionsToMenus(QString menuName, +QList<QAction *> PreviewPlot::addOptionsToMenus(const QString &menuName, QActionGroup *group, - QStringList items, - QString defaultItem) { + const QStringList &items, + const QString &defaultItem) { auto *menu = new QMenu(m_contextMenu); for (auto &item : items) { @@ -880,7 +881,7 @@ QString PreviewPlot::getAxisType(int axisID) { * @param ws Pointer to workspace * @return List of curve names */ -QStringList PreviewPlot::getCurvesForWorkspace(const MatrixWorkspace_sptr ws) { +QStringList PreviewPlot::getCurvesForWorkspace(const MatrixWorkspace_sptr &ws) { QStringList curveNames; for (auto it = m_curves.begin(); it != m_curves.end(); ++it) { diff --git a/qt/widgets/plotting/src/Qwt/QwtHelper.cpp b/qt/widgets/plotting/src/Qwt/QwtHelper.cpp index 1b6f9c764a1e0b2cc68e673fe3d24a91a492ba18..b86a5762578b8dbf8de834ca823753d0c84bae7c 100644 --- a/qt/widgets/plotting/src/Qwt/QwtHelper.cpp +++ b/qt/widgets/plotting/src/Qwt/QwtHelper.cpp @@ -4,6 +4,8 @@ // NScD Oak Ridge National Laboratory, European Spallation Source, // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + +#include <utility> + #include "MantidQtWidgets/Plotting/Qwt/QwtHelper.h" #include "MantidAPI/AlgorithmManager.h" @@ -24,7 +26,7 @@ namespace QwtHelper { * @param wsIndex :: Workspace index to use * @return Pointer to created QwtData */ -boost::shared_ptr<QwtData> curveDataFromWs(MatrixWorkspace_const_sptr ws, +boost::shared_ptr<QwtData> curveDataFromWs(const MatrixWorkspace_const_sptr &ws, size_t wsIndex) { const double *x = &ws->x(wsIndex)[0]; const double *y = &ws->y(wsIndex)[0]; @@ -40,7 +42,7 @@ boost::shared_ptr<QwtData> curveDataFromWs(MatrixWorkspace_const_sptr ws, * @return Pointer to created Vector QwtData */ std::vector<boost::shared_ptr<QwtData>> -curveDataFromWs(MatrixWorkspace_const_sptr ws) { +curveDataFromWs(const MatrixWorkspace_const_sptr &ws) { std::vector<boost::shared_ptr<QwtData>> dataVector; auto histograms = ws->getNumberHistograms(); @@ -58,7 +60,7 @@ curveDataFromWs(MatrixWorkspace_const_sptr ws) { * @param wsIndex :: Workspace index to use * @return Vector of errors */ -std::vector<double> curveErrorsFromWs(MatrixWorkspace_const_sptr ws, +std::vector<double> curveErrorsFromWs(const MatrixWorkspace_const_sptr &ws, size_t wsIndex) { return ws->e(wsIndex).rawData(); } @@ -72,9 +74,9 @@ std::vector<double> curveErrorsFromWs(MatrixWorkspace_const_sptr ws, * @return Pointer to create QwtData */ boost::shared_ptr<QwtData> -curveDataFromFunction(IFunction_const_sptr func, +curveDataFromFunction(const IFunction_const_sptr &func, const std::vector<double> &xValues) { - MatrixWorkspace_sptr ws = createWsFromFunction(func, xValues); + MatrixWorkspace_sptr ws = createWsFromFunction(std::move(func), xValues); return curveDataFromWs(ws, 0); } @@ -85,7 +87,7 @@ curveDataFromFunction(IFunction_const_sptr func, * @param xValues :: X values to use * @return Single-spectrum workspace with calculated function values */ -MatrixWorkspace_sptr createWsFromFunction(IFunction_const_sptr func, +MatrixWorkspace_sptr createWsFromFunction(const IFunction_const_sptr &func, const std::vector<double> &xValues) { auto inputWs = boost::dynamic_pointer_cast<MatrixWorkspace>( WorkspaceFactory::Instance().create("Workspace2D", 1, xValues.size(), diff --git a/qt/widgets/plotting/src/Qwt/QwtRasterDataMD.cpp b/qt/widgets/plotting/src/Qwt/QwtRasterDataMD.cpp index 435e4a21be70de9b9be10f68ecefd4bf60c46d78..e4ebde8e8dcfd15580ba1fdb91e783d37b78bde9 100644 --- a/qt/widgets/plotting/src/Qwt/QwtRasterDataMD.cpp +++ b/qt/widgets/plotting/src/Qwt/QwtRasterDataMD.cpp @@ -10,6 +10,7 @@ #include "MantidGeometry/MDGeometry/IMDDimension.h" #include "MantidGeometry/MDGeometry/MDTypes.h" #include <cmath> +#include <utility> namespace MantidQt { namespace API { @@ -199,7 +200,7 @@ Mantid::API::IMDWorkspace_const_sptr QwtRasterDataMD::getWorkspace() const { * @param ws :: IMDWorkspace to show */ void QwtRasterDataMD::setOverlayWorkspace( - Mantid::API::IMDWorkspace_const_sptr ws) { + const Mantid::API::IMDWorkspace_const_sptr &ws) { if (!ws) { m_overlayWS.reset(); return; @@ -229,8 +230,8 @@ void QwtRasterDataMD::setSliceParams( "vector/number of dimensions size."); m_dimX = dimX; m_dimY = dimY; - m_X = X; - m_Y = Y; + m_X = std::move(X); + m_Y = std::move(Y); if (!m_X || !m_Y) throw std::runtime_error("QwtRasterDataMD::setSliceParams(): one of the " "input dimensions is NULL"); diff --git a/qt/widgets/plotting/src/Qwt/RangeSelector.cpp b/qt/widgets/plotting/src/Qwt/RangeSelector.cpp index 1f3a4fad886405cf71cc255ac9cae8b5434d2223..36e161d2fa2d4068f8da860513abeade1dcf5f68 100644 --- a/qt/widgets/plotting/src/Qwt/RangeSelector.cpp +++ b/qt/widgets/plotting/src/Qwt/RangeSelector.cpp @@ -305,7 +305,7 @@ void RangeSelector::detach() { m_mrkMax->attach(nullptr); } -void RangeSelector::setColour(QColor colour) { +void RangeSelector::setColour(const QColor &colour) { m_pen->setColor(colour); switch (m_type) { case XMINMAX: diff --git a/qt/widgets/plotting/src/Qwt/SafeQwtPlot.cpp b/qt/widgets/plotting/src/Qwt/SafeQwtPlot.cpp index f0f8f6dea3fea3e540f0193dbcf01f2ca3f56b57..fc2f6a8e8f64f9a4d6d923ff91090f058a255318 100644 --- a/qt/widgets/plotting/src/Qwt/SafeQwtPlot.cpp +++ b/qt/widgets/plotting/src/Qwt/SafeQwtPlot.cpp @@ -4,10 +4,12 @@ // NScD Oak Ridge National Laboratory, European Spallation Source, // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + -#include "MantidQtWidgets/Plotting/Qwt/SafeQwtPlot.h" +#include <utility> + #include "MantidAPI/Workspace.h" #include "MantidKernel/ReadLock.h" #include "MantidKernel/System.h" +#include "MantidQtWidgets/Plotting/Qwt/SafeQwtPlot.h" using namespace Mantid::Kernel; @@ -35,7 +37,9 @@ SafeQwtPlot::~SafeQwtPlot() {} * * @param ws :: shared ptr to workspace */ -void SafeQwtPlot::setWorkspace(Mantid::API::Workspace_sptr ws) { m_ws = ws; } +void SafeQwtPlot::setWorkspace(Mantid::API::Workspace_sptr ws) { + m_ws = std::move(ws); +} //---------------------------------------------------------------------------------------------- /** Overridden drawCanvas() that protects the diff --git a/qt/widgets/plugins/algorithm_dialogs/inc/MantidQtWidgets/Plugins/AlgorithmDialogs/PeriodicTableWidget.h b/qt/widgets/plugins/algorithm_dialogs/inc/MantidQtWidgets/Plugins/AlgorithmDialogs/PeriodicTableWidget.h index df543c96171990bdb5fd29291ab59726127d8e7c..3f6e331b6e90f1d9e205e0565b15fa7c42386aad 100644 --- a/qt/widgets/plugins/algorithm_dialogs/inc/MantidQtWidgets/Plugins/AlgorithmDialogs/PeriodicTableWidget.h +++ b/qt/widgets/plugins/algorithm_dialogs/inc/MantidQtWidgets/Plugins/AlgorithmDialogs/PeriodicTableWidget.h @@ -42,7 +42,8 @@ public: /// @return Comma-separated string of all the element buttons for one group /// that are currently checked - QString elementsSelectedToString(QVector<QPushButton *> elementsSelected); + QString + elementsSelectedToString(const QVector<QPushButton *> &elementsSelected); /// @return Comma-separated string of all element buttons that are checked in /// the whole PeriodicTableWidget @@ -55,12 +56,12 @@ public: void disableAllElementButtons(); /// Enables a button for an element by the element name i.e 'Au' for Gold. - void enableButtonByName(QString elementStr); + void enableButtonByName(const QString &elementStr); ///@return the result of the comparison between a string and the text of a /// button. bool compareButtonNameToStr(QPushButton *buttonToCompare, - QString stringToCompare); + const QString &stringToCompare); /// Displays or hides the Legend for the colour coding of periodic groups void showGroupLegend(bool checked); @@ -86,7 +87,7 @@ private: void ColourNobleGases(const QVector<QPushButton *> &nobleGases); /// Methods to colour single element button by setting styleSheet - void ColourButton(QPushButton *elementButton, QString colour); + void ColourButton(QPushButton *elementButton, const QString &colour); /// Method to populate Group Vectors with element QPushButtons void populateGroupVectors(); diff --git a/qt/widgets/plugins/algorithm_dialogs/inc/MantidQtWidgets/Plugins/AlgorithmDialogs/SampleShapeHelpers.h b/qt/widgets/plugins/algorithm_dialogs/inc/MantidQtWidgets/Plugins/AlgorithmDialogs/SampleShapeHelpers.h index 42105c79aad6eac4ef7364f6c5b452bb0bdfb0b6..cf97e72a5a9495d29485391008d0b11ecd56b133 100644 --- a/qt/widgets/plugins/algorithm_dialogs/inc/MantidQtWidgets/Plugins/AlgorithmDialogs/SampleShapeHelpers.h +++ b/qt/widgets/plugins/algorithm_dialogs/inc/MantidQtWidgets/Plugins/AlgorithmDialogs/SampleShapeHelpers.h @@ -74,7 +74,7 @@ struct Operation { Operation(int op = 0) : binaryop(op) {} /// Return the string that represnts the result of this operation - QString toString(QString left, QString right) const; + QString toString(const QString &left, const QString &right) const; /// The stored operation int binaryop; diff --git a/qt/widgets/plugins/algorithm_dialogs/src/ConvertTableToMatrixWorkspaceDialog.cpp b/qt/widgets/plugins/algorithm_dialogs/src/ConvertTableToMatrixWorkspaceDialog.cpp index c9a665b7e4557f14a16fe2c326040f1c39b1bc55..016e947c58a1b42946a39084cd0c8fabbe8f6a05 100644 --- a/qt/widgets/plugins/algorithm_dialogs/src/ConvertTableToMatrixWorkspaceDialog.cpp +++ b/qt/widgets/plugins/algorithm_dialogs/src/ConvertTableToMatrixWorkspaceDialog.cpp @@ -103,7 +103,9 @@ void ConvertTableToMatrixWorkspaceDialog::fillColumnNames( /// Initialize the layout void ConvertTableToMatrixWorkspaceDialog::initLayout() { m_form.setupUi(this); - ((QVBoxLayout *)this->layout())->addLayout(createDefaultButtonLayout()); + + static_cast<QVBoxLayout *>(this->layout()) + ->addLayout(createDefaultButtonLayout()); tie(m_form.cbInputWorkspace, "InputWorkspace", m_form.gridLayout); tie(m_form.leOutputWorkspace, "OutputWorkspace", m_form.gridLayout); tie(m_form.cbColumnX, "ColumnX", m_form.gridLayout); diff --git a/qt/widgets/plugins/algorithm_dialogs/src/FitDialog.cpp b/qt/widgets/plugins/algorithm_dialogs/src/FitDialog.cpp index f15fbd0863a17762be5ff41076374e624bcb35eb..81012058c5137588738285d65e3195d7f89bfbd4 100644 --- a/qt/widgets/plugins/algorithm_dialogs/src/FitDialog.cpp +++ b/qt/widgets/plugins/algorithm_dialogs/src/FitDialog.cpp @@ -514,7 +514,7 @@ namespace { * Helper function to check if a function is an MD one. * @param fun :: Function to check */ -bool isFunctionMD(Mantid::API::IFunction_sptr fun) { +bool isFunctionMD(const Mantid::API::IFunction_sptr &fun) { auto cf = boost::dynamic_pointer_cast<Mantid::API::CompositeFunction>(fun); if (!cf) return static_cast<bool>( diff --git a/qt/widgets/plugins/algorithm_dialogs/src/MantidGLWidget.cpp b/qt/widgets/plugins/algorithm_dialogs/src/MantidGLWidget.cpp index a76790c57a8c45ef8d38e83c317f9b20de1a2251..5ebeba86d624f9b21f91d1a4b5dbd37b51373df1 100644 --- a/qt/widgets/plugins/algorithm_dialogs/src/MantidGLWidget.cpp +++ b/qt/widgets/plugins/algorithm_dialogs/src/MantidGLWidget.cpp @@ -14,6 +14,7 @@ #include <QtOpenGL> #include <cfloat> +#include <utility> using namespace MantidQt::CustomDialogs; @@ -50,7 +51,7 @@ MantidGLWidget::~MantidGLWidget() { makeCurrent(); } */ void MantidGLWidget::setDisplayObject( boost::shared_ptr<Mantid::Geometry::IObject> object) { - m_display_object = object; + m_display_object = std::move(object); m_x_rot = 0.0; m_y_rot = 0.0; m_z_rot = 0.0; diff --git a/qt/widgets/plugins/algorithm_dialogs/src/PeriodicTableWidget.cpp b/qt/widgets/plugins/algorithm_dialogs/src/PeriodicTableWidget.cpp index 35bc73bc7b1f56f56d91161a6f620aecbcc4b457..d67146de96e35f110ed5bbe5c63c9982e5cb2969 100644 --- a/qt/widgets/plugins/algorithm_dialogs/src/PeriodicTableWidget.cpp +++ b/qt/widgets/plugins/algorithm_dialogs/src/PeriodicTableWidget.cpp @@ -131,7 +131,7 @@ void PeriodicTableWidget::ColourUnknownProperties( } } -void PeriodicTableWidget::enableButtonByName(QString elementStr) { +void PeriodicTableWidget::enableButtonByName(const QString &elementStr) { for (auto &AllElementButton : AllElementButtons) { for (auto btn_i = AllElementButton.begin(); btn_i != AllElementButton.end(); btn_i++) { @@ -142,8 +142,8 @@ void PeriodicTableWidget::enableButtonByName(QString elementStr) { } } -bool PeriodicTableWidget::compareButtonNameToStr(QPushButton *buttonToCompare, - QString stringToCompare) { +bool PeriodicTableWidget::compareButtonNameToStr( + QPushButton *buttonToCompare, const QString &stringToCompare) { return (strcmp(buttonToCompare->text().toStdString().c_str(), stringToCompare.toStdString().c_str()) == 0); } @@ -162,15 +162,15 @@ void PeriodicTableWidget::disableAllElementButtons() { disableButtons(UnknownProperties); } void PeriodicTableWidget::ColourButton(QPushButton *element, - QString colourStr) { + const QString &colourStr) { element->setStyleSheet( "QPushButton{border:1px solid rgb(0, 0, 0); " + colourStr + ";}" + "QPushButton:checked{ background-color:rgb(175,255,255)}" + "QPushButton:!enabled{background-color: rgb(204,204,204);" + "}"); } -QString -PeriodicTableWidget::elementsSelectedToString(QVector<QPushButton *> elements) { +QString PeriodicTableWidget::elementsSelectedToString( + const QVector<QPushButton *> &elements) { QString selectedElements = ""; /* Loop through QPushButtons and if they are checked * then retrieve the text on the button i.e the diff --git a/qt/widgets/plugins/algorithm_dialogs/src/SampleShapeHelpers.cpp b/qt/widgets/plugins/algorithm_dialogs/src/SampleShapeHelpers.cpp index 77103e3563b03c4eb3d9de1ddcb1ecf4c0eb3c30..14a7f1f5d7a1580651beed9743d7f72e4474ac6a 100644 --- a/qt/widgets/plugins/algorithm_dialogs/src/SampleShapeHelpers.cpp +++ b/qt/widgets/plugins/algorithm_dialogs/src/SampleShapeHelpers.cpp @@ -150,7 +150,7 @@ QString PointGroupBox::write3DElement(const QString &elem_name) const { * @param right Right-hand side of binary operation * @returns A string representing the result of the operation on the arguments */ -QString Operation::toString(QString left, QString right) const { +QString Operation::toString(const QString &left, const QString &right) const { QString result; switch (binaryop) { // union diff --git a/qt/widgets/refdetectorview/inc/MantidQtWidgets/RefDetectorView/RefMatrixWSImageView.h b/qt/widgets/refdetectorview/inc/MantidQtWidgets/RefDetectorView/RefMatrixWSImageView.h index 89be6c9787b2fa9165fbff5cdecdaa85b0cbc1c2..4511192c88eea95a2adfaaecef31aa2c94804e39 100644 --- a/qt/widgets/refdetectorview/inc/MantidQtWidgets/RefDetectorView/RefMatrixWSImageView.h +++ b/qt/widgets/refdetectorview/inc/MantidQtWidgets/RefDetectorView/RefMatrixWSImageView.h @@ -29,10 +29,10 @@ class EXPORT_OPT_MANTIDQT_REFDETECTORVIEWER RefMatrixWSImageView { public: /// Construct an image viewer for the specifed MatrixWorkspace - RefMatrixWSImageView(Mantid::API::MatrixWorkspace_sptr /*mat_ws*/); + RefMatrixWSImageView(const Mantid::API::MatrixWorkspace_sptr & /*mat_ws*/); - RefMatrixWSImageView(QString wpsName, int peakMin, int peakMax, int backMin, - int backMax, int tofMin, int tofMax); + RefMatrixWSImageView(const QString &wpsName, int peakMin, int peakMax, + int backMin, int backMax, int tofMin, int tofMax); RefIVConnections *getConnections(); diff --git a/qt/widgets/refdetectorview/src/RefImageView.cpp b/qt/widgets/refdetectorview/src/RefImageView.cpp index ca2e6436143b64d053a3b66bc3a5ca7019eb96a2..340f279f244ea98ddd7ff17fbadd9211bed329bf 100644 --- a/qt/widgets/refdetectorview/src/RefImageView.cpp +++ b/qt/widgets/refdetectorview/src/RefImageView.cpp @@ -15,6 +15,7 @@ #include <sstream> #include <string> +#include <utility> namespace MantidQt { namespace RefDetectorViewer { @@ -89,7 +90,7 @@ RefImageView::RefImageView(SpectrumView::SpectrumDataSource_sptr dataSource, m_imageDisplay->updateImage(); iv_connections->peakBackTofRangeUpdate(); - m_imageDisplay->setDataSource(dataSource); + m_imageDisplay->setDataSource(std::move(dataSource)); } RefImageView::~RefImageView() { diff --git a/qt/widgets/refdetectorview/src/RefMatrixWSImageView.cpp b/qt/widgets/refdetectorview/src/RefMatrixWSImageView.cpp index 52febb1c0371ec1640cfdce8e457f4022f401c00..5db995cd442f44b4e7c0f8f777bbb807d8af828b 100644 --- a/qt/widgets/refdetectorview/src/RefMatrixWSImageView.cpp +++ b/qt/widgets/refdetectorview/src/RefMatrixWSImageView.cpp @@ -21,7 +21,8 @@ using namespace Mantid::API; /** * Construct an ImageView for the specified matrix workspace */ -RefMatrixWSImageView::RefMatrixWSImageView(MatrixWorkspace_sptr /*mat_ws*/) +RefMatrixWSImageView::RefMatrixWSImageView( + const MatrixWorkspace_sptr & /*mat_ws*/) : m_imageView(nullptr) { return; // RefMatrixWSDataSource* source = new RefMatrixWSDataSource( mat_ws ); @@ -31,7 +32,7 @@ RefMatrixWSImageView::RefMatrixWSImageView(MatrixWorkspace_sptr /*mat_ws*/) // // is closed } -RefMatrixWSImageView::RefMatrixWSImageView(QString wpsName, int peakMin, +RefMatrixWSImageView::RefMatrixWSImageView(const QString &wpsName, int peakMin, int peakMax, int backMin, int backMax, int tofMin, int tofMax) { diff --git a/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/CompositePeaksPresenter.h b/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/CompositePeaksPresenter.h index aa7d682618113315acbe838ac1a9a2d0fd2a76f5..611b695daa72389d55e5fa85ea572035e59138bc 100644 --- a/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/CompositePeaksPresenter.h +++ b/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/CompositePeaksPresenter.h @@ -92,7 +92,7 @@ public: /// Destructor ~CompositePeaksPresenter() override; /// Add a peaks presenter onto the composite. - void addPeaksPresenter(PeaksPresenter_sptr presenter); + void addPeaksPresenter(const PeaksPresenter_sptr &presenter); /// Get the number of subjects. size_t size() const; /// Clear the owned presenters. @@ -107,43 +107,46 @@ public: double getPeakSizeIntoProjection() const override; /// Enter peak edit mode. void peakEditMode(EditMode mode) override; - void - setForegroundColor(boost::shared_ptr<const Mantid::API::IPeaksWorkspace> ws, - const PeakViewColor /*color*/); + void setForegroundColor( + const boost::shared_ptr<const Mantid::API::IPeaksWorkspace> &ws, + const PeakViewColor & /*color*/); /// Change the background representation for the peaks of this workspace - void - setBackgroundColor(boost::shared_ptr<const Mantid::API::IPeaksWorkspace> ws, - const PeakViewColor /*color*/); + void setBackgroundColor( + const boost::shared_ptr<const Mantid::API::IPeaksWorkspace> &ws, + const PeakViewColor & /*color*/); /// Get the foreground colour corresponding to the workspace PeakViewColor getForegroundPeakViewColor( - boost::shared_ptr<const Mantid::API::IPeaksWorkspace> ws) const; + const boost::shared_ptr<const Mantid::API::IPeaksWorkspace> &ws) const; /// Get the background colour corresponding to the workspace PeakViewColor getBackgroundPeakViewColor( - boost::shared_ptr<const Mantid::API::IPeaksWorkspace> ws) const; + const boost::shared_ptr<const Mantid::API::IPeaksWorkspace> &ws) const; /// Determine if the background is shown or not. bool getShowBackground( - boost::shared_ptr<const Mantid::API::IPeaksWorkspace> ws) const; + const boost::shared_ptr<const Mantid::API::IPeaksWorkspace> &ws) const; /// Get a copy of the palette in its current state. PeakPalette<PeakViewColor> getPalette() const; /// Setter for indicating whether the background radius will be shown. void setBackgroundRadiusShown( - boost::shared_ptr<const Mantid::API::IPeaksWorkspace> ws, + const boost::shared_ptr<const Mantid::API::IPeaksWorkspace> &ws, const bool shown); /// Remove the workspace and corresponding presenter. - void remove(boost::shared_ptr<const Mantid::API::IPeaksWorkspace> peaksWS); + void + remove(const boost::shared_ptr<const Mantid::API::IPeaksWorkspace> &peaksWS); /// Hide these peaks in the plot. - void setShown(boost::shared_ptr<const Mantid::API::IPeaksWorkspace> peaksWS, - const bool shown); + void + setShown(const boost::shared_ptr<const Mantid::API::IPeaksWorkspace> &peaksWS, + const bool shown); /// zoom in on a peak. - void zoomToPeak(boost::shared_ptr<const Mantid::API::IPeaksWorkspace> peaksWS, - const int peakIndex); + void zoomToPeak( + const boost::shared_ptr<const Mantid::API::IPeaksWorkspace> &peaksWS, + const int peakIndex); /// Get the named peaks presenter. PeaksPresenter *getPeaksPresenter(const QString &name); /// Register any owning presenter void registerOwningPresenter(UpdateableOnDemand *owner) override; /// Is the presenter hidden. - bool getIsHidden( - boost::shared_ptr<const Mantid::API::IPeaksWorkspace> peaksWS) const; + bool getIsHidden(const boost::shared_ptr<const Mantid::API::IPeaksWorkspace> + &peaksWS) const; /// Perform update on demand void performUpdate() override; /// Zoom to the rectangle @@ -162,8 +165,9 @@ public: /// Determine if the presenter contents are different. bool contentsDifferent(PeaksPresenter const *other) const override; /// Enter the requested edit mode for the peaks workspace. - void editCommand(EditMode editMode, - boost::weak_ptr<const Mantid::API::IPeaksWorkspace> target); + void editCommand( + EditMode editMode, + const boost::weak_ptr<const Mantid::API::IPeaksWorkspace> &target); private: /// Updateable on demand method. @@ -179,10 +183,10 @@ private: bool useDefault() const { return m_subjects.size() == 0; } /// Get the presenter for a given workspace. SubjectContainer::iterator getPresenterIteratorFromWorkspace( - boost::shared_ptr<const Mantid::API::IPeaksWorkspace> ws); + const boost::shared_ptr<const Mantid::API::IPeaksWorkspace> &ws); /// Get the presenter for a given workspace. SubjectContainer::const_iterator getPresenterIteratorFromWorkspace( - boost::shared_ptr<const Mantid::API::IPeaksWorkspace> ws) const; + const boost::shared_ptr<const Mantid::API::IPeaksWorkspace> &ws) const; /// Get the presenter from a workspace name. SubjectContainer::iterator getPresenterIteratorFromName(const QString &name); /// Color palette diff --git a/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/ConcretePeaksPresenter.h b/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/ConcretePeaksPresenter.h index ffa89dfef72aa7f0c78046afdb3c270a3511389a..867d6e2cee608e767e0b9a63df4d324c06e0a63c 100644 --- a/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/ConcretePeaksPresenter.h +++ b/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/ConcretePeaksPresenter.h @@ -36,9 +36,9 @@ class EXPORT_OPT_MANTIDQT_SLICEVIEWER ConcretePeaksPresenter public: ConcretePeaksPresenter( PeakOverlayViewFactory_sptr viewFactory, - Mantid::API::IPeaksWorkspace_sptr peaksWS, - boost::shared_ptr<Mantid::API::MDGeometry> mdWS, - Mantid::Geometry::PeakTransformFactory_sptr transformFactory); + const Mantid::API::IPeaksWorkspace_sptr &peaksWS, + const boost::shared_ptr<Mantid::API::MDGeometry> &mdWS, + const Mantid::Geometry::PeakTransformFactory_sptr &transformFactory); void reInitialize(Mantid::API::IPeaksWorkspace_sptr peaksWS) override; ~ConcretePeaksPresenter() override; void setNonOrthogonal(bool nonOrthogonalEnabled) override; @@ -107,7 +107,7 @@ private: void produceViews(); /// Check workspace compatibilities. void checkWorkspaceCompatibilities( - boost::shared_ptr<Mantid::API::MDGeometry> mdWS); + const boost::shared_ptr<Mantid::API::MDGeometry> &mdWS); /// Find peaks interacting with the slice and update the view. void doFindPeaksInRegion(); /// make owner update. diff --git a/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/LineOverlay.h b/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/LineOverlay.h index c953fecb6645cb03e9da48f5a6d3eb2e44ec67a7..3b9668f4ac581869624e6f80f27e7ca31bd7239b 100644 --- a/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/LineOverlay.h +++ b/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/LineOverlay.h @@ -92,7 +92,7 @@ private: int height() const; int width() const; - QRect drawHandle(QPainter &painter, QPointF coords, QColor brush); + QRect drawHandle(QPainter &painter, QPointF coords, const QColor &brush); void paintEvent(QPaintEvent *event) override; eHandleID mouseOverHandle(QPoint pos); diff --git a/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/LinePlotOptions.h b/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/LinePlotOptions.h index 9338f5749482b953598a7919742e53376e8195b3..9a367fbea56c47a7a9d8c40162f0bfccfb318453 100644 --- a/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/LinePlotOptions.h +++ b/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/LinePlotOptions.h @@ -19,7 +19,7 @@ public: LinePlotOptions(QWidget *parent = nullptr, bool logScaleOption = false); ~LinePlotOptions() override; - void setOriginalWorkspace(Mantid::API::IMDWorkspace_sptr ws); + void setOriginalWorkspace(const Mantid::API::IMDWorkspace_sptr &ws); int getPlotAxis() const; void setPlotAxis(int choice); diff --git a/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/LineViewer.h b/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/LineViewer.h index 36acf63665cd9c2612e7c4c6d4ac9c60c514a7a1..448a1dd234b1f40aecb4b7fc7fef10e8e9f214d9 100644 --- a/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/LineViewer.h +++ b/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/LineViewer.h @@ -28,11 +28,11 @@ public: LineViewer(QWidget *parent = nullptr); ~LineViewer() override; - void setWorkspace(Mantid::API::IMDWorkspace_sptr ws); + void setWorkspace(const Mantid::API::IMDWorkspace_sptr &ws); void setFreeDimensions(bool all, int dimX, int dimY); - void setStart(Mantid::Kernel::VMD start); - void setEnd(Mantid::Kernel::VMD end); - void setThickness(Mantid::Kernel::VMD width); + void setStart(const Mantid::Kernel::VMD &start); + void setEnd(const Mantid::Kernel::VMD &end); + void setThickness(const Mantid::Kernel::VMD &width); void setPlanarWidth(double width); void setNumBins(int numBins); void setFixedBinWidthMode(bool fixedWidth, double binWidth); @@ -97,9 +97,9 @@ signals: private: Mantid::API::IAlgorithm_sptr - applyMDWorkspace(Mantid::API::IMDWorkspace_sptr ws); + applyMDWorkspace(const Mantid::API::IMDWorkspace_sptr &ws); Mantid::API::IAlgorithm_sptr - applyMatrixWorkspace(Mantid::API::MatrixWorkspace_sptr ws); + applyMatrixWorkspace(const Mantid::API::MatrixWorkspace_sptr &ws); void setupScaleEngine(MantidQwtWorkspaceData &curveData); /// set the slice workspace from the ADS void setSliceWorkspace(const std::string &name); diff --git a/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/NonOrthogonalOverlay.h b/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/NonOrthogonalOverlay.h index 451284a726fcbb626ca1531d459a5d053ec8f140..5c8d363ae5b0a36e7ba0a451dd7a9a7f239be1a3 100644 --- a/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/NonOrthogonalOverlay.h +++ b/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/NonOrthogonalOverlay.h @@ -52,10 +52,10 @@ private: QPointF invTransform(QPoint pixels) const; void drawYLines(QPainter &painter, QPen &gridPen, int widthScreen, - QwtValueList yAxisTicks, double yAngle); + const QwtValueList &yAxisTicks, double yAngle); void drawXLines(QPainter &painter, QPen &gridPen, int heightScreen, - QwtValueList xAxisTicks, double xAngle); + const QwtValueList &xAxisTicks, double xAngle); void paintEvent(QPaintEvent *event) override; diff --git a/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/PeakBoundingBox.h b/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/PeakBoundingBox.h index dd7038bbfe94362155b04540d7ad5d569ea7c938..fc7eaf10c94e59eddf4ec2811b1d71e37604a54c 100644 --- a/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/PeakBoundingBox.h +++ b/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/PeakBoundingBox.h @@ -104,7 +104,7 @@ public: /// Serialize as set of comma separated values std::string toExtentsString() const; /// Transform the box. - void transformBox(Mantid::Geometry::PeakTransform_sptr transform); + void transformBox(const Mantid::Geometry::PeakTransform_sptr &transform); /// Make a new box based on the slice PeakBoundingBox makeSliceBox(const double &sliceDelta) const; }; diff --git a/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/PeakRepresentationEllipsoid.h b/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/PeakRepresentationEllipsoid.h index 33f1aeedb77e696655148724271a9b7eb6b6c072..edfb0ea865660afdc4cb634643bd8e6c75996a7f 100644 --- a/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/PeakRepresentationEllipsoid.h +++ b/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/PeakRepresentationEllipsoid.h @@ -18,10 +18,10 @@ class EXPORT_OPT_MANTIDQT_SLICEVIEWER PeakRepresentationEllipsoid : public PeakRepresentation { public: PeakRepresentationEllipsoid( - const Mantid::Kernel::V3D &origin, const std::vector<double> peakRadii, - const std::vector<double> backgroundInnerRadii, - const std::vector<double> backgroundOuterRadii, - const std::vector<Mantid::Kernel::V3D> directions, + const Mantid::Kernel::V3D &origin, const std::vector<double> &peakRadii, + const std::vector<double> &backgroundInnerRadii, + const std::vector<double> &backgroundOuterRadii, + const std::vector<Mantid::Kernel::V3D> &directions, std::shared_ptr<Mantid::SliceViewer::EllipsoidPlaneSliceCalculator> calculator); diff --git a/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/PeakViewColor.h b/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/PeakViewColor.h index c10442a46ce52cddb599f43ec2877279660b0fd7..be320a3aa467d0c1987134ec963f213559b28a26 100644 --- a/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/PeakViewColor.h +++ b/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/PeakViewColor.h @@ -22,8 +22,9 @@ * New peak types will need to have a color entry registered here. */ struct PeakViewColor { - PeakViewColor(QColor colorCross = QColor(), QColor colorSphere = QColor(), - QColor colorEllipsoid = QColor()) + PeakViewColor(const QColor &colorCross = QColor(), + const QColor &colorSphere = QColor(), + const QColor &colorEllipsoid = QColor()) : colorCross(colorCross), colorSphere(colorSphere), colorEllipsoid(colorEllipsoid) {} diff --git a/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/PeakViewFactory.h b/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/PeakViewFactory.h index 50103e19ce47da444217e228750e1055a409956a..4081b4e2b4a0573dcbfe355f57852ff6de0c7261 100644 --- a/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/PeakViewFactory.h +++ b/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/PeakViewFactory.h @@ -44,7 +44,7 @@ private: // Creates a cross-like representation PeakRepresentation_sptr createPeakRepresentationCross( Mantid::Kernel::V3D position, - Mantid::Geometry::PeakTransform_const_sptr transform) const; + const Mantid::Geometry::PeakTransform_const_sptr &transform) const; // Creates a spherical representation PeakRepresentation_sptr diff --git a/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/PeaksViewer.h b/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/PeaksViewer.h index 2f43b597c351937e4bc533594d48146a120f13e7..5b1c3ee32f2d2aa08e53416da5e3926311ea29fc 100644 --- a/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/PeaksViewer.h +++ b/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/PeaksViewer.h @@ -31,14 +31,15 @@ class EXPORT_OPT_MANTIDQT_SLICEVIEWER PeaksViewer : public QWidget, public: PeaksViewer(QWidget *parent = nullptr); void setPeaksWorkspaces(const SetPeaksWorkspaces &workspaces); - void setPresenter(boost::shared_ptr<ProxyCompositePeaksPresenter> presenter); + void setPresenter( + const boost::shared_ptr<ProxyCompositePeaksPresenter> &presenter); void performUpdate() override; void updatePeaksWorkspace(const std::string &toName, boost::shared_ptr<const Mantid::API::IPeaksWorkspace> toWorkspace) override; bool removePeaksWorkspace( - boost::shared_ptr<const Mantid::API::IPeaksWorkspace> toRemove); + const boost::shared_ptr<const Mantid::API::IPeaksWorkspace> &toRemove); bool removePeaksWorkspace(const std::string &toRemove); void hide(); ~PeaksViewer() override; @@ -61,7 +62,8 @@ public slots: void onBackgroundRadiusShown(Mantid::API::IPeaksWorkspace_const_sptr /*peaksWS*/, bool /*show*/); - void onRemoveWorkspace(Mantid::API::IPeaksWorkspace_const_sptr /*peaksWS*/); + void onRemoveWorkspace( + const Mantid::API::IPeaksWorkspace_const_sptr & /*peaksWS*/); void onHideInPlot(Mantid::API::IPeaksWorkspace_const_sptr peaksWS, bool /*hide*/); void onZoomToPeak(Mantid::API::IPeaksWorkspace_const_sptr peaksWS, @@ -82,8 +84,8 @@ private: /// Load a presented peaks workspace and settings from a project file void loadPresentedWorkspace(const std::string §ion); /// Save a presented peaks workspace and settings to a project file - std::string - savePresentedWorkspace(Mantid::API::IPeaksWorkspace_const_sptr ws) const; + std::string savePresentedWorkspace( + const Mantid::API::IPeaksWorkspace_const_sptr &ws) const; boost::shared_ptr<ProxyCompositePeaksPresenter> m_presenter; }; diff --git a/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/PeaksViewerOverlayDialog.h b/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/PeaksViewerOverlayDialog.h index 604913459cd39e84c3c85eb7389c26deeef23358..21514a8fabcb22b7e8289300437b53e045a589d2 100644 --- a/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/PeaksViewerOverlayDialog.h +++ b/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/PeaksViewerOverlayDialog.h @@ -20,7 +20,7 @@ class PeaksViewerOverlayDialog : public QDialog { Q_OBJECT public: - explicit PeaksViewerOverlayDialog(PeaksPresenter_sptr peaksPresenter, + explicit PeaksViewerOverlayDialog(const PeaksPresenter_sptr &peaksPresenter, QWidget *parent = nullptr); ~PeaksViewerOverlayDialog() override; diff --git a/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/PeaksWorkspaceWidget.h b/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/PeaksWorkspaceWidget.h index 88e6f5f5c0fdb5c0e7e092c5281f8b0310eee65a..1b71b2529991df19dad4c3b5aea0ed0bc9d2cb0c 100644 --- a/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/PeaksWorkspaceWidget.h +++ b/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/PeaksWorkspaceWidget.h @@ -37,7 +37,7 @@ public: void setHidden(bool isHidden); void setSelectedPeak(int index); std::string getWSName() const; - void workspaceUpdate(Mantid::API::IPeaksWorkspace_const_sptr ws = + void workspaceUpdate(const Mantid::API::IPeaksWorkspace_const_sptr &ws = Mantid::API::IPeaksWorkspace_const_sptr()); void exitClearPeaksMode(); void exitAddPeaksMode(); @@ -95,7 +95,7 @@ private slots: void onShowBackgroundChanged(bool /*show*/); void onRemoveWorkspaceClicked(); void onToggleHideInPlot(); - void onCurrentChanged(QModelIndex /*index*/, QModelIndex /*unused*/); + void onCurrentChanged(QModelIndex /*index*/, const QModelIndex & /*unused*/); void onClearPeaksToggled(bool /*on*/); void onAddPeaksToggled(bool /*on*/); }; diff --git a/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/ProxyCompositePeaksPresenter.h b/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/ProxyCompositePeaksPresenter.h index 3a75f574bed780373e479c6fcaeb5662063b7ee9..f0a774f2395c5dfa5aa682aa442973e19f9187dd 100644 --- a/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/ProxyCompositePeaksPresenter.h +++ b/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/ProxyCompositePeaksPresenter.h @@ -34,11 +34,11 @@ public: void setForegroundColor(boost::shared_ptr<const Mantid::API::IPeaksWorkspace> ws, - PeakViewColor /*color*/); + const PeakViewColor & /*color*/); /// Change the background representation for the peaks of this workspace void setBackgroundColor(boost::shared_ptr<const Mantid::API::IPeaksWorkspace> ws, - PeakViewColor /*color*/); + const PeakViewColor & /*color*/); /// Get the foreground colour corresponding to the workspace PeakViewColor getForegroundPeakViewColor( boost::shared_ptr<const Mantid::API::IPeaksWorkspace> ws) const; @@ -87,8 +87,9 @@ public: /// Get optional zoomed peak index. int getZoomedPeakIndex() const; /// Set the edit mode. - void editCommand(EditMode editMode, - boost::weak_ptr<const Mantid::API::IPeaksWorkspace> target); + void editCommand( + EditMode editMode, + const boost::weak_ptr<const Mantid::API::IPeaksWorkspace> &target); /// Set the peaks size within the current projection void setPeakSizeOnProjection(const double fraction); /// Set the peaks size into the current projection diff --git a/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/QwtScaleDrawNonOrthogonal.h b/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/QwtScaleDrawNonOrthogonal.h index 571f76e1941d3457da16c6d097767f5a0ceab399..b8ec1b0e3525394af6ac45929afce673f5dfc39a 100644 --- a/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/QwtScaleDrawNonOrthogonal.h +++ b/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/QwtScaleDrawNonOrthogonal.h @@ -20,7 +20,7 @@ public: QwtScaleDrawNonOrthogonal( QwtPlot *plot, ScreenDimension screenDimension, - Mantid::API::IMDWorkspace_sptr workspace, size_t dimX, size_t dimY, + const Mantid::API::IMDWorkspace_sptr &workspace, size_t dimX, size_t dimY, Mantid::Kernel::VMD slicePoint, MantidQt::SliceViewer::NonOrthogonalOverlay *gridPlot); @@ -32,7 +32,8 @@ public: void updateSlicePoint(Mantid::Kernel::VMD newSlicepoint); private: - void setTransformationMatrices(Mantid::API::IMDWorkspace_sptr workspace); + void + setTransformationMatrices(const Mantid::API::IMDWorkspace_sptr &workspace); qreal getScreenBottomInXyz() const; qreal getScreenLeftInXyz() const; diff --git a/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/SliceViewer.h b/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/SliceViewer.h index d4fa335b3712844b3e0f46560f0f942e70fa0cbd..66628a84527da9ca140217fc34e4f16d561d41ed 100644 --- a/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/SliceViewer.h +++ b/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/SliceViewer.h @@ -85,11 +85,11 @@ public: ~SliceViewer() override; void setWorkspace(const QString &wsName); - void setWorkspace(Mantid::API::IMDWorkspace_sptr ws); + void setWorkspace(const Mantid::API::IMDWorkspace_sptr &ws); Mantid::API::IMDWorkspace_sptr getWorkspace(); void showControls(bool visible); void zoomBy(double factor); - void loadColorMap(QString filename = QString()); + void loadColorMap(const QString &filename = QString()); LineOverlay *getLineOverlay() { return m_lineOverlay; } Mantid::Kernel::VMD getSlicePoint() const { return m_slicePoint; } int getDimX() const; diff --git a/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/SliceViewerWindow.h b/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/SliceViewerWindow.h index 31f29ddf333b0566997464217db5d278ff3f7030..f6d598531e6c11321abf2baa51c6b9786c13f320 100644 --- a/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/SliceViewerWindow.h +++ b/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/SliceViewerWindow.h @@ -36,7 +36,7 @@ class EXPORT_OPT_MANTIDQT_SLICEVIEWER SliceViewerWindow public: SliceViewerWindow(const QString &wsName, const QString &label = QString(), - Qt::WindowFlags f = nullptr); + const Qt::WindowFlags &f = nullptr); ~SliceViewerWindow() override; MantidQt::SliceViewer::SliceViewer *getSlicer(); MantidQt::SliceViewer::LineViewer *getLiner(); @@ -66,7 +66,7 @@ protected slots: void closeWindow(); void updateWorkspace(); void slicerWorkspaceChanged(); - void changedSlicePoint(Mantid::Kernel::VMD /*slice*/); + void changedSlicePoint(const Mantid::Kernel::VMD & /*slice*/); void lineChanging(QPointF start, QPointF end, double width); void lineChanged(QPointF start, QPointF end, double width); void changeStartOrEnd(Mantid::Kernel::VMD /*start*/, diff --git a/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/XYLimitsDialog.h b/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/XYLimitsDialog.h index 72cc991dab6370536fd51b8bb04bf5d8f3eb4a74..55c522ff6da335d25c67e0fd2fc47249a969bb4c 100644 --- a/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/XYLimitsDialog.h +++ b/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/XYLimitsDialog.h @@ -23,8 +23,8 @@ public: XYLimitsDialog(QWidget *parent = nullptr); ~XYLimitsDialog() override; - void setXDim(Mantid::Geometry::IMDDimension_const_sptr dim); - void setYDim(Mantid::Geometry::IMDDimension_const_sptr dim); + void setXDim(const Mantid::Geometry::IMDDimension_const_sptr &dim); + void setYDim(const Mantid::Geometry::IMDDimension_const_sptr &dim); void setLimits(double x0, double x1, double y0, double y1); double getXMin(); double getXMax(); diff --git a/qt/widgets/sliceviewer/src/CompositePeaksPresenter.cpp b/qt/widgets/sliceviewer/src/CompositePeaksPresenter.cpp index bac9535472a3b82f67d46528b720440fd694adb6..c9f010b773f6b9eaf258cf994602cb1237be14a1 100644 --- a/qt/widgets/sliceviewer/src/CompositePeaksPresenter.cpp +++ b/qt/widgets/sliceviewer/src/CompositePeaksPresenter.cpp @@ -7,6 +7,7 @@ #include "MantidQtWidgets/SliceViewer/CompositePeaksPresenter.h" #include "MantidAPI/IPeaksWorkspace.h" #include <stdexcept> +#include <utility> using Mantid::Geometry::PeakTransform_sptr; @@ -19,7 +20,8 @@ CompositePeaksPresenter::CompositePeaksPresenter( ZoomablePeaksView *const zoomablePlottingWidget, PeaksPresenter_sptr defaultPresenter) : m_zoomablePlottingWidget(zoomablePlottingWidget), - m_default(defaultPresenter), m_owner(nullptr), m_zoomedPeakIndex(-1) { + m_default(std::move(defaultPresenter)), m_owner(nullptr), + m_zoomedPeakIndex(-1) { if (m_zoomablePlottingWidget == nullptr) { throw std::runtime_error("Zoomable Plotting Widget is NULL"); } @@ -146,7 +148,8 @@ bool CompositePeaksPresenter::contentsDifferent( Add peaks presenter @param presenter : Subject peaks presenter */ -void CompositePeaksPresenter::addPeaksPresenter(PeaksPresenter_sptr presenter) { +void CompositePeaksPresenter::addPeaksPresenter( + const PeaksPresenter_sptr &presenter) { if (this->size() == 10) { throw std::invalid_argument("Maximum number of PeaksWorkspaces that can be " "simultaneously displayed is 10."); @@ -186,7 +189,7 @@ SetPeaksWorkspaces CompositePeaksPresenter::presentedWorkspaces() const { */ CompositePeaksPresenter::SubjectContainer::iterator CompositePeaksPresenter::getPresenterIteratorFromWorkspace( - boost::shared_ptr<const Mantid::API::IPeaksWorkspace> ws) { + const boost::shared_ptr<const Mantid::API::IPeaksWorkspace> &ws) { SubjectContainer::iterator presenterFound = m_subjects.end(); for (auto presenterIterator = m_subjects.begin(); presenterIterator != m_subjects.end(); ++presenterIterator) { @@ -206,7 +209,7 @@ CompositePeaksPresenter::getPresenterIteratorFromWorkspace( */ CompositePeaksPresenter::SubjectContainer::const_iterator CompositePeaksPresenter::getPresenterIteratorFromWorkspace( - boost::shared_ptr<const Mantid::API::IPeaksWorkspace> ws) const { + const boost::shared_ptr<const Mantid::API::IPeaksWorkspace> &ws) const { SubjectContainer::const_iterator presenterFound = m_subjects.end(); for (auto presenterIterator = m_subjects.begin(); presenterIterator != m_subjects.end(); ++presenterIterator) { @@ -226,9 +229,10 @@ Set the foreground colour of the peaks. @ colour to use for re-colouring */ void CompositePeaksPresenter::setForegroundColor( - boost::shared_ptr<const Mantid::API::IPeaksWorkspace> ws, - const PeakViewColor color) { - SubjectContainer::iterator iterator = getPresenterIteratorFromWorkspace(ws); + const boost::shared_ptr<const Mantid::API::IPeaksWorkspace> &ws, + const PeakViewColor &color) { + SubjectContainer::iterator iterator = + getPresenterIteratorFromWorkspace(std::move(ws)); // Update the palette the foreground colour const int pos = static_cast<int>(std::distance(m_subjects.begin(), iterator)); @@ -244,9 +248,10 @@ Set the background colour of the peaks. @ colour to use for re-colouring */ void CompositePeaksPresenter::setBackgroundColor( - boost::shared_ptr<const Mantid::API::IPeaksWorkspace> ws, - const PeakViewColor color) { - SubjectContainer::iterator iterator = getPresenterIteratorFromWorkspace(ws); + const boost::shared_ptr<const Mantid::API::IPeaksWorkspace> &ws, + const PeakViewColor &color) { + SubjectContainer::iterator iterator = + getPresenterIteratorFromWorkspace(std::move(ws)); // Update the palette background colour. const int pos = static_cast<int>(std::distance(m_subjects.begin(), iterator)); @@ -279,13 +284,13 @@ PeakPalette<PeakViewColor> CompositePeaksPresenter::getPalette() const { @return the foreground colour corresponding to the peaks workspace. */ PeakViewColor CompositePeaksPresenter::getForegroundPeakViewColor( - boost::shared_ptr<const Mantid::API::IPeaksWorkspace> ws) const { + const boost::shared_ptr<const Mantid::API::IPeaksWorkspace> &ws) const { if (useDefault()) { throw std::runtime_error("Foreground colours from palette cannot be " "fetched until nested presenters are added."); } SubjectContainer::const_iterator iterator = - getPresenterIteratorFromWorkspace(ws); + getPresenterIteratorFromWorkspace(std::move(ws)); const int pos = static_cast<int>(std::distance(m_subjects.begin(), iterator)); return m_palettePeakViewColor.foregroundIndexToColour(pos); } @@ -295,13 +300,13 @@ PeakViewColor CompositePeaksPresenter::getForegroundPeakViewColor( @return the background colour corresponding to the peaks workspace. */ PeakViewColor CompositePeaksPresenter::getBackgroundPeakViewColor( - boost::shared_ptr<const Mantid::API::IPeaksWorkspace> ws) const { + const boost::shared_ptr<const Mantid::API::IPeaksWorkspace> &ws) const { if (useDefault()) { throw std::runtime_error("Background colours from palette cannot be " "fetched until nested presenters are added."); } SubjectContainer::const_iterator iterator = - getPresenterIteratorFromWorkspace(ws); + getPresenterIteratorFromWorkspace(std::move(ws)); const int pos = static_cast<int>(std::distance(m_subjects.begin(), iterator)); return m_palettePeakViewColor.backgroundIndexToColour(pos); } @@ -313,12 +318,12 @@ PeakViewColor CompositePeaksPresenter::getBackgroundPeakViewColor( * @param shown : True to show. */ void CompositePeaksPresenter::setBackgroundRadiusShown( - boost::shared_ptr<const Mantid::API::IPeaksWorkspace> ws, + const boost::shared_ptr<const Mantid::API::IPeaksWorkspace> &ws, const bool shown) { if (useDefault()) { return m_default->showBackgroundRadius(shown); } - auto iterator = getPresenterIteratorFromWorkspace(ws); + auto iterator = getPresenterIteratorFromWorkspace(std::move(ws)); (*iterator)->showBackgroundRadius(shown); } @@ -327,11 +332,11 @@ void CompositePeaksPresenter::setBackgroundRadiusShown( * @param peaksWS : Peaks list to remove. */ void CompositePeaksPresenter::remove( - boost::shared_ptr<const Mantid::API::IPeaksWorkspace> peaksWS) { + const boost::shared_ptr<const Mantid::API::IPeaksWorkspace> &peaksWS) { if (useDefault()) { return; } - auto iterator = getPresenterIteratorFromWorkspace(peaksWS); + auto iterator = getPresenterIteratorFromWorkspace(std::move(peaksWS)); if (iterator != m_subjects.end()) { m_subjects.erase(iterator); } @@ -346,12 +351,12 @@ void CompositePeaksPresenter::remove( * @param shown : True to show. */ void CompositePeaksPresenter::setShown( - boost::shared_ptr<const Mantid::API::IPeaksWorkspace> peaksWS, + const boost::shared_ptr<const Mantid::API::IPeaksWorkspace> &peaksWS, const bool shown) { if (useDefault()) { return m_default->setShown(shown); } - auto iterator = getPresenterIteratorFromWorkspace(peaksWS); + auto iterator = getPresenterIteratorFromWorkspace(std::move(peaksWS)); if (iterator == m_subjects.end()) return; @@ -367,9 +372,9 @@ void CompositePeaksPresenter::setShown( * @param peakIndex : Index of the peak in the peaks list to zoom into. */ void CompositePeaksPresenter::zoomToPeak( - boost::shared_ptr<const Mantid::API::IPeaksWorkspace> peaksWS, + const boost::shared_ptr<const Mantid::API::IPeaksWorkspace> &peaksWS, const int peakIndex) { - auto iterator = getPresenterIteratorFromWorkspace(peaksWS); + auto iterator = getPresenterIteratorFromWorkspace(std::move(peaksWS)); auto subjectPresenter = *iterator; auto boundingBox = subjectPresenter->getBoundingBox(peakIndex); m_zoomablePlottingWidget->zoomToRectangle(boundingBox); @@ -460,13 +465,13 @@ double CompositePeaksPresenter::getPeakSizeIntoProjection() const { * @return */ bool CompositePeaksPresenter::getShowBackground( - boost::shared_ptr<const Mantid::API::IPeaksWorkspace> ws) const { + const boost::shared_ptr<const Mantid::API::IPeaksWorkspace> &ws) const { if (useDefault()) { throw std::runtime_error("Get show background cannot be fetched until " "nested presenters are added."); } SubjectContainer::const_iterator iterator = - getPresenterIteratorFromWorkspace(ws); + getPresenterIteratorFromWorkspace(std::move(ws)); return (*iterator)->getShowBackground(); } @@ -478,7 +483,7 @@ private: public: explicit MatchWorkspaceName(const QString &name) : m_wsName(name) {} - bool operator()(SetPeaksWorkspaces::value_type ws) { + bool operator()(const SetPeaksWorkspaces::value_type &ws) { const std::string &wsName = ws->getName(); const std::string toMatch = m_wsName.toStdString(); const bool result = (wsName == toMatch); @@ -557,7 +562,7 @@ private: public: explicit MatchPointer(PeaksPresenter *toFind) : m_toFind(toFind) {} - bool operator()(PeaksPresenter_sptr candidate) { + bool operator()(const PeaksPresenter_sptr &candidate) { return candidate.get() == m_toFind; } }; @@ -594,8 +599,9 @@ void CompositePeaksPresenter::zoomToPeak(PeaksPresenter *const presenter, * @return True if hidden. */ bool CompositePeaksPresenter::getIsHidden( - boost::shared_ptr<const Mantid::API::IPeaksWorkspace> peaksWS) const { - auto iterator = getPresenterIteratorFromWorkspace(peaksWS); + const boost::shared_ptr<const Mantid::API::IPeaksWorkspace> &peaksWS) + const { + auto iterator = getPresenterIteratorFromWorkspace(std::move(peaksWS)); auto subjectPresenter = *iterator; return subjectPresenter->isHidden(); } @@ -630,7 +636,7 @@ int CompositePeaksPresenter::getZoomedPeakIndex() const { void CompositePeaksPresenter::editCommand( EditMode editMode, - boost::weak_ptr<const Mantid::API::IPeaksWorkspace> target) { + const boost::weak_ptr<const Mantid::API::IPeaksWorkspace> &target) { if (auto ws = target.lock()) { // Change the right subject to the desired edit mode. diff --git a/qt/widgets/sliceviewer/src/ConcretePeaksPresenter.cpp b/qt/widgets/sliceviewer/src/ConcretePeaksPresenter.cpp index db85bdd976fc69233026b52d05f13ac4709b90f6..5aab97492e8d88558a9c3e29d527d733e4a381ce 100644 --- a/qt/widgets/sliceviewer/src/ConcretePeaksPresenter.cpp +++ b/qt/widgets/sliceviewer/src/ConcretePeaksPresenter.cpp @@ -21,6 +21,7 @@ #include "MantidQtWidgets/SliceViewer/UpdateableOnDemand.h" #include "MantidQtWidgets/SliceViewer/ZoomableOnDemand.h" #include <boost/regex.hpp> +#include <utility> using namespace Mantid::API; using namespace Mantid::Kernel; @@ -78,7 +79,7 @@ void ConcretePeaksPresenter::produceViews() { * @param mdWS : MDWorkspace currently plotted. */ void ConcretePeaksPresenter::checkWorkspaceCompatibilities( - boost::shared_ptr<Mantid::API::MDGeometry> mdWS) { + const boost::shared_ptr<Mantid::API::MDGeometry> &mdWS) { if (auto imdWS = boost::dynamic_pointer_cast<Mantid::API::IMDWorkspace>(mdWS)) { const SpecialCoordinateSystem coordSystMD = @@ -135,10 +136,11 @@ void ConcretePeaksPresenter::checkWorkspaceCompatibilities( interpreting the MODEL. */ ConcretePeaksPresenter::ConcretePeaksPresenter( - PeakOverlayViewFactory_sptr viewFactory, IPeaksWorkspace_sptr peaksWS, - boost::shared_ptr<MDGeometry> mdWS, - Mantid::Geometry::PeakTransformFactory_sptr transformFactory) - : m_viewFactory(viewFactory), m_peaksWS(peaksWS), + PeakOverlayViewFactory_sptr viewFactory, + const IPeaksWorkspace_sptr &peaksWS, + const boost::shared_ptr<MDGeometry> &mdWS, + const Mantid::Geometry::PeakTransformFactory_sptr &transformFactory) + : m_viewFactory(std::move(viewFactory)), m_peaksWS(peaksWS), m_transformFactory(transformFactory), m_transform(transformFactory->createDefaultTransform()), m_slicePoint(), m_owningPresenter(nullptr), m_isHidden(false), @@ -159,7 +161,7 @@ ConcretePeaksPresenter::ConcretePeaksPresenter( m_axisData.fromHklToXyz[8] = 1.0; // Check that the workspaces appear to be compatible. Log if otherwise. - checkWorkspaceCompatibilities(mdWS); + checkWorkspaceCompatibilities(std::move(mdWS)); this->initialize(); } diff --git a/qt/widgets/sliceviewer/src/DimensionSliceWidget.cpp b/qt/widgets/sliceviewer/src/DimensionSliceWidget.cpp index c4f21af99616e08a7988687a614d70aaf3dc85b1..cf5abdf884a40cda4159db37cf9570e9918443a9 100644 --- a/qt/widgets/sliceviewer/src/DimensionSliceWidget.cpp +++ b/qt/widgets/sliceviewer/src/DimensionSliceWidget.cpp @@ -9,6 +9,7 @@ #include "MantidQtWidgets/Common/QStringUtils.h" #include <QLayout> #include <iosfwd> +#include <utility> namespace MantidQt { using API::toQStringInternal; @@ -179,7 +180,7 @@ void DimensionSliceWidget::setMinMax(double min, double max) { /** Set the dimension to display */ void DimensionSliceWidget::setDimension( int index, Mantid::Geometry::IMDDimension_const_sptr dim) { - m_dim = dim; + m_dim = std::move(dim); m_dimIndex = index; // set the limits of the slider to be the bin centres and not // the edges of the bins diff --git a/qt/widgets/sliceviewer/src/EllipsoidPlaneSliceCalculator.cpp b/qt/widgets/sliceviewer/src/EllipsoidPlaneSliceCalculator.cpp index 91cbe5e151f0bb2fef05e1e4107c6e070a6b9da3..f1d8b04f6a697bff1d10ef0823e8fa42fefb8a2f 100644 --- a/qt/widgets/sliceviewer/src/EllipsoidPlaneSliceCalculator.cpp +++ b/qt/widgets/sliceviewer/src/EllipsoidPlaneSliceCalculator.cpp @@ -9,6 +9,8 @@ #include <algorithm> #include <cmath> +#include <utility> + /** * * The functions in this file intend to calculate the paramters of an ellipse @@ -94,8 +96,8 @@ namespace { * @param zVal: the z value (in the ellipse frame) * @return the origin of the ellipse */ -Mantid::Kernel::V3D getOrigin(Mantid::Kernel::DblMatrix AInverse, - Mantid::Kernel::DblMatrix B, +Mantid::Kernel::V3D getOrigin(const Mantid::Kernel::DblMatrix &AInverse, + const Mantid::Kernel::DblMatrix &B, Mantid::Kernel::V3D originEllipsoid, double zVal) { const auto multiplied = AInverse * B; @@ -167,16 +169,17 @@ getEigenVectorsForEllipse(const Mantid::Kernel::DblMatrix &MM, * @return radii and directions */ EigenSystemEllipse getAxesInformation(Mantid::Kernel::DblMatrix A, - Mantid::Kernel::DblMatrix AInverse, - Mantid::Kernel::DblMatrix B, - Mantid::Kernel::DblMatrix BT, double c) { + const Mantid::Kernel::DblMatrix &AInverse, + const Mantid::Kernel::DblMatrix &B, + const Mantid::Kernel::DblMatrix &BT, + double c) { // Calculate the denominator: (Transpose[B]*A^(-1)*B/4 - (c-1)) const auto temp1 = AInverse * B; const auto temp2 = BT * temp1; const auto denominator = 0.25 * temp2[0][0] - c + 1; // Calculate the MM matrix: A/(Transpose[B]*A^(-1)*B/4 - (c-1)) - auto MM = A; + auto MM = std::move(A); MM /= denominator; // Calculate the Eigenvalues: since we are dealing with EVs of a @@ -234,7 +237,8 @@ SliceEllipseInfo EllipsoidPlaneSliceCalculator::getSlicePlaneInfo( std::vector<Mantid::Kernel::V3D> directions, std::vector<double> radii, Mantid::Kernel::V3D originEllipsoid, double zPlane) const { // Setup the Ellipsoid Matrix - auto m = createEllipsoidMatrixInXYZFrame(directions, radii); + auto m = + createEllipsoidMatrixInXYZFrame(std::move(directions), std::move(radii)); auto isEllipsoid = checkIfIsEllipse(m); diff --git a/qt/widgets/sliceviewer/src/LineOverlay.cpp b/qt/widgets/sliceviewer/src/LineOverlay.cpp index 2ccd3c96939fb0af7acd1d2cb1e78b924b274302..5b2591c9968dda3b0c1f125cae2d645ff230513a 100644 --- a/qt/widgets/sliceviewer/src/LineOverlay.cpp +++ b/qt/widgets/sliceviewer/src/LineOverlay.cpp @@ -240,7 +240,8 @@ QPointF LineOverlay::snap(QPointF original) const { //---------------------------------------------------------------------------------------------- /** Draw a handle (for dragging) at the given plot coordinates */ -QRect LineOverlay::drawHandle(QPainter &painter, QPointF coords, QColor brush) { +QRect LineOverlay::drawHandle(QPainter &painter, QPointF coords, + const QColor &brush) { int size = 8; QPoint center = transform(coords); QRect marker(center.x() - size / 2, center.y() - size / 2, size, size); diff --git a/qt/widgets/sliceviewer/src/LinePlotOptions.cpp b/qt/widgets/sliceviewer/src/LinePlotOptions.cpp index 5c48a5f89b9cfa93823e0e132c7a99a25833d2ed..adb9a72406a749ee17bd91ca2eb1afc4f1fd02c5 100644 --- a/qt/widgets/sliceviewer/src/LinePlotOptions.cpp +++ b/qt/widgets/sliceviewer/src/LinePlotOptions.cpp @@ -64,7 +64,8 @@ void LinePlotOptions::addPlotRadioButton(const std::string &text, //------------------------------------------------------------------------------ /** Set the original workspace, to show the axes plot choice */ -void LinePlotOptions::setOriginalWorkspace(Mantid::API::IMDWorkspace_sptr ws) { +void LinePlotOptions::setOriginalWorkspace( + const Mantid::API::IMDWorkspace_sptr &ws) { if (!ws) return; diff --git a/qt/widgets/sliceviewer/src/LineViewer.cpp b/qt/widgets/sliceviewer/src/LineViewer.cpp index 084a6c933b2ab1f2a55cfb490e1c61985a94d669..66c1b8e0351ffd63b561b31b05a24e4b1c749206 100644 --- a/qt/widgets/sliceviewer/src/LineViewer.cpp +++ b/qt/widgets/sliceviewer/src/LineViewer.cpp @@ -75,8 +75,8 @@ Mantid::Kernel::Logger g_log("LineViewer"); * @param width : Default thickness (for non integrated dimensions) * @param thicknesses : Thickness vector to write to */ -void setThicknessUsingDimensionInfo(IMDWorkspace_sptr ws, size_t dimIndex, - double width, +void setThicknessUsingDimensionInfo(const IMDWorkspace_sptr &ws, + size_t dimIndex, double width, Mantid::Kernel::VMD &thicknesses) { auto currentDim = ws->getDimension(dimIndex); if (currentDim->getIsIntegrated()) { @@ -328,7 +328,7 @@ void LineViewer::readTextboxes() { * @param ws :: MatrixWorkspace to integrate */ IAlgorithm_sptr -LineViewer::applyMatrixWorkspace(Mantid::API::MatrixWorkspace_sptr ws) { +LineViewer::applyMatrixWorkspace(const Mantid::API::MatrixWorkspace_sptr &ws) { // (half-width in the plane) const double planeWidth = getPlanarWidth(); @@ -409,7 +409,7 @@ LineViewer::applyMatrixWorkspace(Mantid::API::MatrixWorkspace_sptr ws) { * @return the algorithm to run */ IAlgorithm_sptr -LineViewer::applyMDWorkspace(Mantid::API::IMDWorkspace_sptr ws) { +LineViewer::applyMDWorkspace(const Mantid::API::IMDWorkspace_sptr &ws) { bool adaptive = ui.chkAdaptiveBins->isChecked(); // (half-width in the plane) @@ -706,7 +706,7 @@ bool LineViewer::getFixedBinWidthMode() const { return m_fixedBinWidthMode; } /** Set the workspace being sliced * * @param ws :: IMDWorkspace */ -void LineViewer::setWorkspace(Mantid::API::IMDWorkspace_sptr ws) { +void LineViewer::setWorkspace(const Mantid::API::IMDWorkspace_sptr &ws) { if (!ws) throw std::runtime_error("LineViewer::setWorkspace(): Invalid workspace."); m_initFreeDimX = -1; @@ -720,7 +720,7 @@ void LineViewer::setWorkspace(Mantid::API::IMDWorkspace_sptr ws) { /** Set the start point of the line to integrate * @param start :: vector for the start point */ -void LineViewer::setStart(Mantid::Kernel::VMD start) { +void LineViewer::setStart(const Mantid::Kernel::VMD &start) { if (m_ws && start.getNumDims() != m_ws->getNumDims()) throw std::runtime_error("LineViewer::setStart(): Invalid number of " "dimensions in the start vector."); @@ -730,7 +730,7 @@ void LineViewer::setStart(Mantid::Kernel::VMD start) { /** Set the end point of the line to integrate * @param end :: vector for the end point */ -void LineViewer::setEnd(Mantid::Kernel::VMD end) { +void LineViewer::setEnd(const Mantid::Kernel::VMD &end) { if (m_ws && end.getNumDims() != m_ws->getNumDims()) throw std::runtime_error("LineViewer::setEnd(): Invalid number of " "dimensions in the end vector."); @@ -741,7 +741,7 @@ void LineViewer::setEnd(Mantid::Kernel::VMD end) { /** Set the width of the line in each dimensions * @param width :: vector for the width in each dimension. X dimension stands in * for the XY plane width */ -void LineViewer::setThickness(Mantid::Kernel::VMD width) { +void LineViewer::setThickness(const Mantid::Kernel::VMD &width) { if (m_ws && width.getNumDims() != m_ws->getNumDims()) throw std::runtime_error("LineViewer::setThickness(): Invalid number of " "dimensions in the width vector."); diff --git a/qt/widgets/sliceviewer/src/NonOrthogonalOverlay.cpp b/qt/widgets/sliceviewer/src/NonOrthogonalOverlay.cpp index 95b5cb431eeb55dd1453b201ade3131bc5485f2c..b809c442f2ce1afd6c97de4ef57b6cda754a4623 100644 --- a/qt/widgets/sliceviewer/src/NonOrthogonalOverlay.cpp +++ b/qt/widgets/sliceviewer/src/NonOrthogonalOverlay.cpp @@ -127,7 +127,8 @@ void NonOrthogonalOverlay::paintEvent(QPaintEvent * /*event*/) { } void NonOrthogonalOverlay::drawYLines(QPainter &painter, QPen &gridPen, - int widthScreen, QwtValueList yAxisTicks, + int widthScreen, + const QwtValueList &yAxisTicks, double yAngle) { auto offset = yAngle == 0. ? 0. : widthScreen * tan(yAngle); @@ -141,7 +142,8 @@ void NonOrthogonalOverlay::drawYLines(QPainter &painter, QPen &gridPen, } void NonOrthogonalOverlay::drawXLines(QPainter &painter, QPen &gridPen, - int heightScreen, QwtValueList xAxisTicks, + int heightScreen, + const QwtValueList &xAxisTicks, double xAngle) { xAngle *= -1.f; auto offset = xAngle == 0. ? 0. : heightScreen * tan(xAngle); diff --git a/qt/widgets/sliceviewer/src/PeakBoundingBox.cpp b/qt/widgets/sliceviewer/src/PeakBoundingBox.cpp index c200d724c7e4e3d2e06c4968aecb6640cf5a1959..39a844e5f9a2c419a7ad254b6a6b303612704dfa 100644 --- a/qt/widgets/sliceviewer/src/PeakBoundingBox.cpp +++ b/qt/widgets/sliceviewer/src/PeakBoundingBox.cpp @@ -213,7 +213,7 @@ std::string PeakBoundingBox::toExtentsString() const { * @param transform : Transform to use. */ void PeakBoundingBox::transformBox( - Mantid::Geometry::PeakTransform_sptr transform) { + const Mantid::Geometry::PeakTransform_sptr &transform) { using Mantid::Kernel::V3D; // Front bottom left V3D newBottomLeft = diff --git a/qt/widgets/sliceviewer/src/PeakRepresentationEllipsoid.cpp b/qt/widgets/sliceviewer/src/PeakRepresentationEllipsoid.cpp index fd496f5154e0f42a2f083fda05fd03e2b4b03388..03b75fc1c4767a693a6d5bbcb19bc07169cf491e 100644 --- a/qt/widgets/sliceviewer/src/PeakRepresentationEllipsoid.cpp +++ b/qt/widgets/sliceviewer/src/PeakRepresentationEllipsoid.cpp @@ -14,6 +14,7 @@ Mantid::Kernel::Logger g_log("PeakRepresentation"); } #include <QPainter> +#include <utility> namespace { @@ -62,10 +63,10 @@ namespace SliceViewer { const double PeakRepresentationEllipsoid::zeroRadius = 0.0; PeakRepresentationEllipsoid::PeakRepresentationEllipsoid( - const Mantid::Kernel::V3D &origin, const std::vector<double> peakRadii, - const std::vector<double> backgroundInnerRadii, - const std::vector<double> backgroundOuterRadii, - const std::vector<Mantid::Kernel::V3D> directions, + const Mantid::Kernel::V3D &origin, const std::vector<double> &peakRadii, + const std::vector<double> &backgroundInnerRadii, + const std::vector<double> &backgroundOuterRadii, + const std::vector<Mantid::Kernel::V3D> &directions, std::shared_ptr<Mantid::SliceViewer::EllipsoidPlaneSliceCalculator> calculator) : m_originalOrigin(origin), m_originalDirections(directions), @@ -73,7 +74,7 @@ PeakRepresentationEllipsoid::PeakRepresentationEllipsoid( m_backgroundInnerRadii(backgroundInnerRadii), m_backgroundOuterRadii(backgroundOuterRadii), m_opacityMax(0.8), m_opacityMin(0.0), m_cachedOpacityAtDistance(0.0), m_angleEllipse(-1.0), - m_showBackgroundRadii(false), m_calculator(calculator) { + m_showBackgroundRadii(false), m_calculator(std::move(calculator)) { // Get projection lengths onto the xyz axes of the ellipsoid axes auto projections = Mantid::SliceViewer::getProjectionLengths( directions, backgroundOuterRadii); diff --git a/qt/widgets/sliceviewer/src/PeakView.cpp b/qt/widgets/sliceviewer/src/PeakView.cpp index e0c121610fad8cdae47c3c2b3f6bdecd8ccf487a..ae6d3a6c97bfa72921e5adf911d56e1172acc7ad 100644 --- a/qt/widgets/sliceviewer/src/PeakView.cpp +++ b/qt/widgets/sliceviewer/src/PeakView.cpp @@ -8,6 +8,8 @@ #include "MantidQtWidgets/SliceViewer/SliceViewer.h" #include <QPainter> +#include <utility> + #include <qwt_double_interval.h> #include <qwt_plot.h> #include <qwt_scale_div.h> @@ -24,7 +26,8 @@ PeakView::PeakView(PeaksPresenter *const presenter, QwtPlot *plot, : PeakOverlayInteractive(presenter, plot, plotXIndex, plotYIndex, parent), m_peaks(vecPeakRepresentation), m_cachedOccupancyIntoView(0.015), m_cachedOccupancyInView(0.015), m_showBackground(false), - m_foregroundColor(foregroundColor), m_backgroundColor(backgroundColor), + m_foregroundColor(std::move(foregroundColor)), + m_backgroundColor(std::move(backgroundColor)), m_largestEffectiveRadius(largestEffectiveRadius) {} PeakView::~PeakView() {} diff --git a/qt/widgets/sliceviewer/src/PeakViewFactory.cpp b/qt/widgets/sliceviewer/src/PeakViewFactory.cpp index d48e7cb24b1168813c82f4278bcd4ce9318536c6..402ccb0c30b937c0a07e8cd74d73815accadacec 100644 --- a/qt/widgets/sliceviewer/src/PeakViewFactory.cpp +++ b/qt/widgets/sliceviewer/src/PeakViewFactory.cpp @@ -4,7 +4,8 @@ // NScD Oak Ridge National Laboratory, European Spallation Source, // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + -#include "MantidQtWidgets/SliceViewer/PeakViewFactory.h" +#include <utility> + #include "MantidDataObjects/PeakShapeEllipsoid.h" #include "MantidDataObjects/PeakShapeSpherical.h" #include "MantidGeometry/Crystal/IPeak.h" @@ -17,6 +18,7 @@ #include "MantidQtWidgets/SliceViewer/PeakRepresentationEllipsoid.h" #include "MantidQtWidgets/SliceViewer/PeakRepresentationSphere.h" #include "MantidQtWidgets/SliceViewer/PeakView.h" +#include "MantidQtWidgets/SliceViewer/PeakViewFactory.h" namespace { struct ZMinAndMax { @@ -24,8 +26,9 @@ struct ZMinAndMax { double zMin; }; -ZMinAndMax getZMinAndMax(Mantid::API::IMDWorkspace_sptr workspace, - Mantid::Geometry::PeakTransform_const_sptr transform) { +ZMinAndMax +getZMinAndMax(const Mantid::API::IMDWorkspace_sptr &workspace, + const Mantid::Geometry::PeakTransform_const_sptr &transform) { double zMax = 0.0; double zMin = 0.0; const auto numberOfDimensions = workspace->getNumDims(); @@ -79,7 +82,7 @@ PeakViewFactory::PeakViewFactory(Mantid::API::IMDWorkspace_sptr mdWS, const size_t colorNumber) : PeakOverlayViewFactoryBase(plot, parent, plotXIndex, plotYIndex, colorNumber), - m_mdWS(mdWS), m_peaksWS(peaksWS), + m_mdWS(std::move(mdWS)), m_peaksWS(std::move(peaksWS)), m_calculator(std::make_shared< Mantid::SliceViewer::EllipsoidPlaneSliceCalculator>()) { setForegroundAndBackgroundColors(colorNumber); @@ -127,15 +130,16 @@ PeakRepresentation_sptr PeakViewFactory::createSinglePeakRepresentation( Mantid::DataObjects::PeakShapeEllipsoid::ellipsoidShapeName()) { peakRepresentation = createPeakRepresentationEllipsoid(position, peak); } else { - peakRepresentation = createPeakRepresentationCross(position, transform); + peakRepresentation = + createPeakRepresentationCross(position, std::move(transform)); } return peakRepresentation; } PeakRepresentation_sptr PeakViewFactory::createPeakRepresentationCross( Mantid::Kernel::V3D position, - Mantid::Geometry::PeakTransform_const_sptr transform) const { - const auto zMinAndMax = getZMinAndMax(m_mdWS, transform); + const Mantid::Geometry::PeakTransform_const_sptr &transform) const { + const auto zMinAndMax = getZMinAndMax(m_mdWS, std::move(transform)); return std::make_shared<PeakRepresentationCross>(position, zMinAndMax.zMax, zMinAndMax.zMin); } diff --git a/qt/widgets/sliceviewer/src/PeaksViewer.cpp b/qt/widgets/sliceviewer/src/PeaksViewer.cpp index 1331feeaca96cb24d5475fdaf943e2ab869a7918..2c673a4fe642516e856a4b44f89aae64e24881b7 100644 --- a/qt/widgets/sliceviewer/src/PeaksViewer.cpp +++ b/qt/widgets/sliceviewer/src/PeaksViewer.cpp @@ -14,6 +14,7 @@ #include "MantidQtWidgets/SliceViewer/ProxyCompositePeaksPresenter.h" #include <QBoxLayout> #include <QLayoutItem> +#include <utility> namespace MantidQt { namespace SliceViewer { @@ -49,7 +50,7 @@ void removeLayout(QWidget *widget) { * @param presenter : Proxy through which all information can be fetched. */ void PeaksViewer::setPresenter( - boost::shared_ptr<ProxyCompositePeaksPresenter> presenter) { + const boost::shared_ptr<ProxyCompositePeaksPresenter> &presenter) { m_presenter = presenter; m_presenter->registerView(this); @@ -317,7 +318,7 @@ std::string PeaksViewer::saveToProject() const { * @return the state of the presented peaks workspace as a project file string */ std::string PeaksViewer::savePresentedWorkspace( - Mantid::API::IPeaksWorkspace_const_sptr ws) const { + const Mantid::API::IPeaksWorkspace_const_sptr &ws) const { API::TSVSerialiser tsv; tsv.writeLine("Name") << ws->getName(); tsv.writeLine("ShowBackground") << m_presenter->getShowBackground(ws); @@ -345,7 +346,7 @@ std::string PeaksViewer::savePresentedWorkspace( */ void PeaksViewer::onPeakColorChanged( Mantid::API::IPeaksWorkspace_const_sptr peaksWS, PeakViewColor newColor) { - m_presenter->setForegroundColor(peaksWS, newColor); + m_presenter->setForegroundColor(std::move(peaksWS), std::move(newColor)); } /** @@ -355,7 +356,7 @@ void PeaksViewer::onPeakColorChanged( */ void PeaksViewer::onBackgroundColorChanged( Mantid::API::IPeaksWorkspace_const_sptr peaksWS, PeakViewColor newColor) { - m_presenter->setBackgroundColor(peaksWS, newColor); + m_presenter->setBackgroundColor(std::move(peaksWS), std::move(newColor)); } /** @@ -365,7 +366,7 @@ void PeaksViewer::onBackgroundColorChanged( */ void PeaksViewer::onBackgroundRadiusShown( Mantid::API::IPeaksWorkspace_const_sptr peaksWS, bool show) { - m_presenter->setBackgroundRadiusShown(peaksWS, show); + m_presenter->setBackgroundRadiusShown(std::move(peaksWS), show); } /** @@ -373,8 +374,8 @@ void PeaksViewer::onBackgroundRadiusShown( * @param peaksWS : Workspace to remove */ void PeaksViewer::onRemoveWorkspace( - Mantid::API::IPeaksWorkspace_const_sptr peaksWS) { - this->removePeaksWorkspace(peaksWS); + const Mantid::API::IPeaksWorkspace_const_sptr &peaksWS) { + this->removePeaksWorkspace(std::move(peaksWS)); } /** @@ -384,7 +385,7 @@ void PeaksViewer::onRemoveWorkspace( */ void PeaksViewer::onHideInPlot(Mantid::API::IPeaksWorkspace_const_sptr peaksWS, bool hide) { - m_presenter->hideInPlot(peaksWS, hide); + m_presenter->hideInPlot(std::move(peaksWS), hide); } /** @@ -394,7 +395,7 @@ void PeaksViewer::onHideInPlot(Mantid::API::IPeaksWorkspace_const_sptr peaksWS, */ void PeaksViewer::onZoomToPeak(Mantid::API::IPeaksWorkspace_const_sptr peaksWS, int peakIndex) { - m_presenter->zoomToPeak(peaksWS, peakIndex); + m_presenter->zoomToPeak(std::move(peaksWS), peakIndex); } /** @@ -476,7 +477,7 @@ void PeaksViewer::updatePeaksWorkspace( } bool PeaksViewer::removePeaksWorkspace( - boost::shared_ptr<const Mantid::API::IPeaksWorkspace> toRemove) { + const boost::shared_ptr<const Mantid::API::IPeaksWorkspace> &toRemove) { bool somethingToRemove = false; if (m_presenter) { diff --git a/qt/widgets/sliceviewer/src/PeaksViewerOverlayDialog.cpp b/qt/widgets/sliceviewer/src/PeaksViewerOverlayDialog.cpp index c12e0d3dfba6d9d5e92b40613d136f86bf2e424c..a77f05cca5463e159261d97b38ede3433306cf49 100644 --- a/qt/widgets/sliceviewer/src/PeaksViewerOverlayDialog.cpp +++ b/qt/widgets/sliceviewer/src/PeaksViewerOverlayDialog.cpp @@ -62,7 +62,7 @@ QString formattedPercentageValue(double fraction) { * @param parent : Parent widget */ PeaksViewerOverlayDialog::PeaksViewerOverlayDialog( - PeaksPresenter_sptr peaksPresenter, QWidget *parent) + const PeaksPresenter_sptr &peaksPresenter, QWidget *parent) : QDialog(parent), ui(new Ui::PeaksViewerOverlayDialog), m_peaksPresenter(peaksPresenter) { ui->setupUi(this); diff --git a/qt/widgets/sliceviewer/src/PeaksWorkspaceWidget.cpp b/qt/widgets/sliceviewer/src/PeaksWorkspaceWidget.cpp index 8a413595174034b2774f9e2282cf3f07b62dc1ca..79b501194736ece7aad46cc205093f5a387404d3 100644 --- a/qt/widgets/sliceviewer/src/PeaksWorkspaceWidget.cpp +++ b/qt/widgets/sliceviewer/src/PeaksWorkspaceWidget.cpp @@ -12,6 +12,7 @@ #include <QColorDialog> #include <QPlastiqueStyle> #include <QSortFilterProxyModel> +#include <utility> namespace { QColor getSelectedColor() { @@ -40,9 +41,10 @@ PeaksWorkspaceWidget::PeaksWorkspaceWidget( const std::string &coordinateSystem, PeakViewColor defaultForegroundPeakViewColor, PeakViewColor defaultBackgroundPeakViewColor, PeaksViewer *parent) - : QWidget(parent), m_ws(ws), m_coordinateSystem(coordinateSystem), - m_foregroundPeakViewColor(defaultForegroundPeakViewColor), - m_backgroundPeakViewColor(defaultBackgroundPeakViewColor), + : QWidget(parent), m_ws(std::move(ws)), + m_coordinateSystem(coordinateSystem), + m_foregroundPeakViewColor(std::move(defaultForegroundPeakViewColor)), + m_backgroundPeakViewColor(std::move(defaultBackgroundPeakViewColor)), m_parent(parent) { ui.setupUi(this); @@ -340,7 +342,7 @@ std::string PeaksWorkspaceWidget::getWSName() const { * @param ws : Workspace to redisplay with */ void PeaksWorkspaceWidget::workspaceUpdate( - Mantid::API::IPeaksWorkspace_const_sptr ws) { + const Mantid::API::IPeaksWorkspace_const_sptr &ws) { // Only if we provide a peaks workspace for replacement. if (ws) { m_ws = ws; @@ -360,7 +362,7 @@ void PeaksWorkspaceWidget::workspaceUpdate( * @param index : Index of the table newly selected */ void PeaksWorkspaceWidget::onCurrentChanged(QModelIndex index, - QModelIndex /*unused*/) { + const QModelIndex & /*unused*/) { if (index.isValid()) { index = m_tableModel->mapToSource(index); emit zoomToPeak(this->m_ws, index.row()); diff --git a/qt/widgets/sliceviewer/src/ProxyCompositePeaksPresenter.cpp b/qt/widgets/sliceviewer/src/ProxyCompositePeaksPresenter.cpp index 348deaac6ab0848f4744ffe2594d258625f71116..69bd6210919ff953902976891626780e7c320d92 100644 --- a/qt/widgets/sliceviewer/src/ProxyCompositePeaksPresenter.cpp +++ b/qt/widgets/sliceviewer/src/ProxyCompositePeaksPresenter.cpp @@ -4,6 +4,8 @@ // NScD Oak Ridge National Laboratory, European Spallation Source, // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + +#include <utility> + #include "MantidQtWidgets/SliceViewer/ProxyCompositePeaksPresenter.h" namespace MantidQt { @@ -13,7 +15,7 @@ Constructor */ ProxyCompositePeaksPresenter::ProxyCompositePeaksPresenter( boost::shared_ptr<CompositePeaksPresenter> composite) - : m_compositePresenter(composite), m_updateableView(nullptr) { + : m_compositePresenter(std::move(composite)), m_updateableView(nullptr) { m_compositePresenter->registerOwningPresenter(this); } @@ -44,8 +46,8 @@ Set the foreground colour of the peaks. */ void ProxyCompositePeaksPresenter::setForegroundColor( boost::shared_ptr<const Mantid::API::IPeaksWorkspace> ws, - PeakViewColor color) { - m_compositePresenter->setForegroundColor(ws, color); + const PeakViewColor &color) { + m_compositePresenter->setForegroundColor(std::move(ws), std::move(color)); } /** @@ -55,23 +57,23 @@ Set the background colour of the peaks. */ void ProxyCompositePeaksPresenter::setBackgroundColor( boost::shared_ptr<const Mantid::API::IPeaksWorkspace> ws, - PeakViewColor color) { - m_compositePresenter->setBackgroundColor(ws, color); + const PeakViewColor &color) { + m_compositePresenter->setBackgroundColor(std::move(ws), std::move(color)); } PeakViewColor ProxyCompositePeaksPresenter::getBackgroundPeakViewColor( boost::shared_ptr<const Mantid::API::IPeaksWorkspace> ws) const { - return m_compositePresenter->getBackgroundPeakViewColor(ws); + return m_compositePresenter->getBackgroundPeakViewColor(std::move(ws)); } PeakViewColor ProxyCompositePeaksPresenter::getForegroundPeakViewColor( boost::shared_ptr<const Mantid::API::IPeaksWorkspace> ws) const { - return m_compositePresenter->getForegroundPeakViewColor(ws); + return m_compositePresenter->getForegroundPeakViewColor(std::move(ws)); } bool ProxyCompositePeaksPresenter::getShowBackground( boost::shared_ptr<const Mantid::API::IPeaksWorkspace> ws) const { - return m_compositePresenter->getShowBackground(ws); + return m_compositePresenter->getShowBackground(std::move(ws)); } /** @@ -91,24 +93,24 @@ std::string ProxyCompositePeaksPresenter::getTransformName() const { void ProxyCompositePeaksPresenter::setBackgroundRadiusShown( boost::shared_ptr<const Mantid::API::IPeaksWorkspace> ws, const bool shown) { - m_compositePresenter->setBackgroundRadiusShown(ws, shown); + m_compositePresenter->setBackgroundRadiusShown(std::move(ws), shown); } void ProxyCompositePeaksPresenter::remove( boost::shared_ptr<const Mantid::API::IPeaksWorkspace> peaksWS) { - m_compositePresenter->remove(peaksWS); + m_compositePresenter->remove(std::move(peaksWS)); } void ProxyCompositePeaksPresenter::hideInPlot( boost::shared_ptr<const Mantid::API::IPeaksWorkspace> peaksWS, const bool hide) { - m_compositePresenter->setShown(peaksWS, !hide); + m_compositePresenter->setShown(std::move(peaksWS), !hide); } void ProxyCompositePeaksPresenter::zoomToPeak( boost::shared_ptr<const Mantid::API::IPeaksWorkspace> peaksWS, const int peakIndex) { - m_compositePresenter->zoomToPeak(peaksWS, peakIndex); + m_compositePresenter->zoomToPeak(std::move(peaksWS), peakIndex); } PeaksPresenter * @@ -132,7 +134,7 @@ void ProxyCompositePeaksPresenter::updatePeaksWorkspace( bool ProxyCompositePeaksPresenter::getIsHidden( boost::shared_ptr<const Mantid::API::IPeaksWorkspace> peaksWS) const { - return m_compositePresenter->getIsHidden(peaksWS); + return m_compositePresenter->getIsHidden(std::move(peaksWS)); } void ProxyCompositePeaksPresenter::registerView( @@ -151,8 +153,8 @@ int ProxyCompositePeaksPresenter::getZoomedPeakIndex() const { void ProxyCompositePeaksPresenter::editCommand( EditMode editMode, - boost::weak_ptr<const Mantid::API::IPeaksWorkspace> target) { - m_compositePresenter->editCommand(editMode, target); + const boost::weak_ptr<const Mantid::API::IPeaksWorkspace> &target) { + m_compositePresenter->editCommand(editMode, std::move(target)); } void ProxyCompositePeaksPresenter::setPeakSizeOnProjection( diff --git a/qt/widgets/sliceviewer/src/QPeaksTableModel.cpp b/qt/widgets/sliceviewer/src/QPeaksTableModel.cpp index 0def403617738e297aa798e0936ee27047d6a0a5..0e7d10697dd8a5aa1b76b620023cd4dbf3c98015 100644 --- a/qt/widgets/sliceviewer/src/QPeaksTableModel.cpp +++ b/qt/widgets/sliceviewer/src/QPeaksTableModel.cpp @@ -14,6 +14,7 @@ #include "MantidKernel/InstrumentInfo.h" #include <QString> #include <boost/lexical_cast.hpp> +#include <utility> using namespace Mantid::API; using namespace Mantid::Geometry; @@ -152,7 +153,7 @@ Constructor */ QPeaksTableModel::QPeaksTableModel( boost::shared_ptr<const Mantid::API::IPeaksWorkspace> peaksWS) - : QAbstractTableModel(nullptr), m_peaksWS(peaksWS) { + : QAbstractTableModel(nullptr), m_peaksWS(std::move(peaksWS)) { m_columnNameMap = {{0, RUNNUMBER}, {1, DETID}, {2, H}, @@ -264,7 +265,7 @@ void QPeaksTableModel::setPeaksWorkspace( boost::shared_ptr<const Mantid::API::IPeaksWorkspace> peaksWS) { beginResetModel(); emit layoutAboutToBeChanged(); - m_peaksWS = peaksWS; + m_peaksWS = std::move(peaksWS); emit dataChanged(index(0, 0), index(rowCount() - 1, columnCount() - 1)); emit layoutChanged(); endResetModel(); diff --git a/qt/widgets/sliceviewer/src/QwtScaleDrawNonOrthogonal.cpp b/qt/widgets/sliceviewer/src/QwtScaleDrawNonOrthogonal.cpp index bf424782861eaa0f6b4f9eb9c3e5d5b70b7a9eba..f06198fa22f82401a2a3b15a1f344602bb61792d 100644 --- a/qt/widgets/sliceviewer/src/QwtScaleDrawNonOrthogonal.cpp +++ b/qt/widgets/sliceviewer/src/QwtScaleDrawNonOrthogonal.cpp @@ -15,18 +15,19 @@ #include <QMatrix> #include <QPainter> #include <QPalette> +#include <utility> QwtScaleDrawNonOrthogonal::QwtScaleDrawNonOrthogonal( QwtPlot *plot, ScreenDimension screenDimension, - Mantid::API::IMDWorkspace_sptr workspace, size_t dimX, size_t dimY, + const Mantid::API::IMDWorkspace_sptr &workspace, size_t dimX, size_t dimY, Mantid::Kernel::VMD slicePoint, MantidQt::SliceViewer::NonOrthogonalOverlay *gridPlot) : m_fromHklToXyz({{1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0}}), m_fromXyzToHkl({{1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0}}), m_plot(plot), m_screenDimension(screenDimension), m_dimX(dimX), - m_dimY(dimY), m_slicePoint(slicePoint), m_gridPlot(gridPlot) { + m_dimY(dimY), m_slicePoint(std::move(slicePoint)), m_gridPlot(gridPlot) { // Set up the transformation matrix - setTransformationMatrices(workspace); + setTransformationMatrices(std::move(workspace)); // Set up the angles // set the angles for the two dimensions @@ -289,7 +290,7 @@ QwtScaleDrawNonOrthogonal::fromHklToXyz(const Mantid::Kernel::VMD &hkl) const { } void QwtScaleDrawNonOrthogonal::setTransformationMatrices( - Mantid::API::IMDWorkspace_sptr workspace) { + const Mantid::API::IMDWorkspace_sptr &workspace) { m_missingDimension = MantidQt::API::getMissingHKLDimensionIndex(workspace, m_dimX, m_dimY); @@ -315,5 +316,5 @@ qreal QwtScaleDrawNonOrthogonal::getScreenLeftInXyz() const { void QwtScaleDrawNonOrthogonal::updateSlicePoint( Mantid::Kernel::VMD newSlicepoint) { - m_slicePoint = newSlicepoint; + m_slicePoint = std::move(newSlicepoint); } diff --git a/qt/widgets/sliceviewer/src/SliceViewer.cpp b/qt/widgets/sliceviewer/src/SliceViewer.cpp index fe03b73ec689caa37688622398d8026f99fe8e21..1569f9d4b7b7a79b439590040c378426f97de889 100644 --- a/qt/widgets/sliceviewer/src/SliceViewer.cpp +++ b/qt/widgets/sliceviewer/src/SliceViewer.cpp @@ -750,7 +750,7 @@ void SliceViewer::switchQWTRaster(bool useNonOrthogonal) { * * @param ws :: IMDWorkspace to show. */ -void SliceViewer::setWorkspace(Mantid::API::IMDWorkspace_sptr ws) { +void SliceViewer::setWorkspace(const Mantid::API::IMDWorkspace_sptr &ws) { struct ScopedFlag { explicit ScopedFlag(bool &b) : m_flag(b) { m_flag = true; } ~ScopedFlag() { m_flag = false; } @@ -913,7 +913,7 @@ Mantid::API::IMDWorkspace_sptr SliceViewer::getWorkspace() { return m_ws; } * * @param filename :: file to open; empty to ask via a dialog box. */ -void SliceViewer::loadColorMap(QString filename) { +void SliceViewer::loadColorMap(const QString &filename) { QString fileselection; if (filename.isEmpty()) { fileselection = MantidColorMap::chooseColorMap(m_currentColorMapFile, this); diff --git a/qt/widgets/sliceviewer/src/SliceViewerWindow.cpp b/qt/widgets/sliceviewer/src/SliceViewerWindow.cpp index 04b7ca66e87973130c90bd80d0e46cf59ba4811e..12ebfdbaf3c70de2f18eb552aaae8b079301b10c 100644 --- a/qt/widgets/sliceviewer/src/SliceViewerWindow.cpp +++ b/qt/widgets/sliceviewer/src/SliceViewerWindow.cpp @@ -37,7 +37,8 @@ namespace SliceViewer { * @return */ SliceViewerWindow::SliceViewerWindow(const QString &wsName, - const QString &label, Qt::WindowFlags f) + const QString &label, + const Qt::WindowFlags &f) : QMainWindow(nullptr, f), WorkspaceObserver(), m_lastLinerWidth(0), m_lastPeaksViewerWidth(0) { @@ -372,7 +373,7 @@ void SliceViewerWindow::lineChanged(QPointF start2D, QPointF end2D, /** Slot called when changing the slice point of the 2D view * (keeping the line in the same 2D point) */ -void SliceViewerWindow::changedSlicePoint(Mantid::Kernel::VMD slice) { +void SliceViewerWindow::changedSlicePoint(const Mantid::Kernel::VMD &slice) { UNUSED_ARG(slice); setLineViewerValues(m_slicer->getLineOverlay()->getPointA(), m_slicer->getLineOverlay()->getPointB(), diff --git a/qt/widgets/sliceviewer/src/XYLimitsDialog.cpp b/qt/widgets/sliceviewer/src/XYLimitsDialog.cpp index 35a4a5436ee005ea5b375215ac87e08181f0c8d6..af4f1d35411b1cb54d3a4ab1304821b74c1e4a94 100644 --- a/qt/widgets/sliceviewer/src/XYLimitsDialog.cpp +++ b/qt/widgets/sliceviewer/src/XYLimitsDialog.cpp @@ -27,14 +27,16 @@ XYLimitsDialog::~XYLimitsDialog() {} //------------------------------------------------------------------------------------------ /** Set the labels for the X dimensions * @param dim : IMDDimension */ -void XYLimitsDialog::setXDim(Mantid::Geometry::IMDDimension_const_sptr dim) { +void XYLimitsDialog::setXDim( + const Mantid::Geometry::IMDDimension_const_sptr &dim) { ui.lblXName->setText(QString::fromStdString(dim->getName())); ui.lblXUnits->setText(toQStringInternal(dim->getUnits().utf8())); } /** Set the labels for the Y dimensions * @param dim : IMDDimension */ -void XYLimitsDialog::setYDim(Mantid::Geometry::IMDDimension_const_sptr dim) { +void XYLimitsDialog::setYDim( + const Mantid::Geometry::IMDDimension_const_sptr &dim) { ui.lblYName->setText(QString::fromStdString(dim->getName())); ui.lblYUnits->setText(toQStringInternal(dim->getUnits().utf8())); } diff --git a/qt/widgets/sliceviewer/test/ConcretePeaksPresenterTest.h b/qt/widgets/sliceviewer/test/ConcretePeaksPresenterTest.h index cdc4686369f98a3d7bd3554b2a67b15938e783cd..ba7f4afd37513fe3206a254facdffebe0ad31e29 100644 --- a/qt/widgets/sliceviewer/test/ConcretePeaksPresenterTest.h +++ b/qt/widgets/sliceviewer/test/ConcretePeaksPresenterTest.h @@ -22,6 +22,7 @@ #include <boost/make_shared.hpp> #include <cxxtest/TestSuite.h> #include <string> +#include <utility> using namespace MantidQt::SliceViewer; using namespace Mantid::API; @@ -50,7 +51,7 @@ class ConcretePeaksPresenterTest : public CxxTest::TestSuite { } /// Helper method to create a mock MDDimension. - IMDDimension_sptr createExpectedMDDimension(const std::string returnLabel) { + IMDDimension_sptr createExpectedMDDimension(const std::string &returnLabel) { auto *pDim = new NiceMock<MockIMDDimension>; IMDDimension_sptr dim(pDim); EXPECT_CALL(*pDim, getName()).WillRepeatedly(Return(returnLabel)); @@ -100,12 +101,16 @@ class ConcretePeaksPresenterTest : public CxxTest::TestSuite { } void withViewFactory(PeakOverlayViewFactory_sptr val) { - m_viewFactory = val; + m_viewFactory = std::move(val); + } + void withPeaksWorkspace(IPeaksWorkspace_sptr val) { + m_peaksWS = std::move(val); + } + void withMDWorkspace(boost::shared_ptr<MDGeometry> val) { + m_mdWS = std::move(val); } - void withPeaksWorkspace(IPeaksWorkspace_sptr val) { m_peaksWS = val; } - void withMDWorkspace(boost::shared_ptr<MDGeometry> val) { m_mdWS = val; } void withTransformFactory(PeakTransformFactory_sptr val) { - m_transformFactory = val; + m_transformFactory = std::move(val); } ConcretePeaksPresenter_sptr create() { diff --git a/qt/widgets/sliceviewer/test/PeakRepresentationEllipsoidTest.h b/qt/widgets/sliceviewer/test/PeakRepresentationEllipsoidTest.h index 6d58882e1b3e1d7355cb0e6cafd713168373756b..bef73f4f1a6f31f066c8740ede13a9f54fbc3ef5 100644 --- a/qt/widgets/sliceviewer/test/PeakRepresentationEllipsoidTest.h +++ b/qt/widgets/sliceviewer/test/PeakRepresentationEllipsoidTest.h @@ -10,6 +10,8 @@ #include "MockObjects.h" #include <cxxtest/TestSuite.h> +#include <utility> + using namespace MantidQt::SliceViewer; using namespace testing; @@ -34,12 +36,12 @@ public: const Mantid::Kernel::V3D &origin, const std::vector<double> &peakRadius, const std::vector<double> &backgroundInnerRadius, const std::vector<double> &backgroundOuterRadius, - const std::vector<Mantid::Kernel::V3D> directions, + const std::vector<Mantid::Kernel::V3D> &directions, std::shared_ptr<Mantid::SliceViewer::EllipsoidPlaneSliceCalculator> calculator) : PeakRepresentationEllipsoid(origin, peakRadius, backgroundInnerRadius, backgroundOuterRadius, directions, - calculator) + std::move(calculator)) {} std::shared_ptr<PeakPrimitives> getDrawingInformationWrapper( diff --git a/qt/widgets/sliceviewer/test/SliceViewerFunctionsTest.h b/qt/widgets/sliceviewer/test/SliceViewerFunctionsTest.h index dff6162d9e878750847564c282a9337833fbd59c..50d77e46b41fd9b8d4671e4550748873e099e468 100644 --- a/qt/widgets/sliceviewer/test/SliceViewerFunctionsTest.h +++ b/qt/widgets/sliceviewer/test/SliceViewerFunctionsTest.h @@ -38,7 +38,7 @@ SliceDefinition get_slice_definition(const size_t numberOfDimensions, std::vector<Mantid::Geometry::MDHistoDimension_sptr> get_dimensions_collection( const size_t numberOfDimensions, const Mantid::Kernel::VMD_t minValue, - const Mantid::Kernel::VMD_t maxValue, const std::string sliceLies) { + const Mantid::Kernel::VMD_t maxValue, const std::string &sliceLies) { std::vector<Mantid::Geometry::MDHistoDimension_sptr> dimensions( numberOfDimensions); @@ -75,7 +75,7 @@ std::vector<Mantid::Geometry::MDHistoDimension_sptr> get_dimensions_collection( class SliceViewerFunctionsTest : public CxxTest::TestSuite { public: bool do_test_slice_lies_in_workspace_boundaries( - const std::string sliceLiesWithinWorkspaceBoundary) { + const std::string &sliceLiesWithinWorkspaceBoundary) { // Arrange const size_t numberOfDimensions = 3; Mantid::Kernel::VMD_t minValue = 1; diff --git a/qt/widgets/spectrumviewer/inc/MantidQtWidgets/SpectrumViewer/MatrixWSDataSource.h b/qt/widgets/spectrumviewer/inc/MantidQtWidgets/SpectrumViewer/MatrixWSDataSource.h index 57ee73206d72983f3032779f5c504a910641fecf..9b8e7ca0fd2878efbf3947999d7a7994bd2086da 100644 --- a/qt/widgets/spectrumviewer/inc/MantidQtWidgets/SpectrumViewer/MatrixWSDataSource.h +++ b/qt/widgets/spectrumviewer/inc/MantidQtWidgets/SpectrumViewer/MatrixWSDataSource.h @@ -41,7 +41,7 @@ class EXPORT_OPT_MANTIDQT_SPECTRUMVIEWER MatrixWSDataSource : public SpectrumDataSource { public: /// Construct a DataSource object around the specifed MatrixWorkspace - MatrixWSDataSource(Mantid::API::MatrixWorkspace_const_sptr matWs); + MatrixWSDataSource(const Mantid::API::MatrixWorkspace_const_sptr &matWs); ~MatrixWSDataSource() override; diff --git a/qt/widgets/spectrumviewer/inc/MantidQtWidgets/SpectrumViewer/SliderHandler.h b/qt/widgets/spectrumviewer/inc/MantidQtWidgets/SpectrumViewer/SliderHandler.h index 08b0dfbcba772ecc5da337ee769dfa9d83b315b8..65c07eb21b42a279ee8d5fee33a994219a491cf9 100644 --- a/qt/widgets/spectrumviewer/inc/MantidQtWidgets/SpectrumViewer/SliderHandler.h +++ b/qt/widgets/spectrumviewer/inc/MantidQtWidgets/SpectrumViewer/SliderHandler.h @@ -36,7 +36,8 @@ public: SpectrumDataSource_sptr dataSource) override; /// Configure the image scrollbars for the specified drawing area - void reConfigureSliders(QRect drawArea, SpectrumDataSource_sptr dataSource); + void reConfigureSliders(QRect drawArea, + const SpectrumDataSource_sptr &dataSource); /// Configure the horizontal scrollbar to cover the specified range void configureHSlider(int nDataSteps, int nPixels) override; diff --git a/qt/widgets/spectrumviewer/inc/MantidQtWidgets/SpectrumViewer/SpectrumPlotItem.h b/qt/widgets/spectrumviewer/inc/MantidQtWidgets/SpectrumViewer/SpectrumPlotItem.h index ec79009e063e32d59c5961b1219b100fcab478ee..9afb272f8e8390540d7e1fa50833248e037975b3 100644 --- a/qt/widgets/spectrumviewer/inc/MantidQtWidgets/SpectrumViewer/SpectrumPlotItem.h +++ b/qt/widgets/spectrumviewer/inc/MantidQtWidgets/SpectrumViewer/SpectrumPlotItem.h @@ -37,7 +37,7 @@ public: ~SpectrumPlotItem() override; /// Specify the data to be plotted and the color table to use - void setData(DataArray_const_sptr dataArray, + void setData(const DataArray_const_sptr &dataArray, std::vector<QRgb> *positiveColorTable, std::vector<QRgb> *negativeColorTable); diff --git a/qt/widgets/spectrumviewer/inc/MantidQtWidgets/SpectrumViewer/SpectrumView.h b/qt/widgets/spectrumviewer/inc/MantidQtWidgets/SpectrumViewer/SpectrumView.h index 5dc7dc559b315dcdb5c25198a4f0c4a8047dc913..bbc286f57ce40da916cc835fe00b77d1ef0632b8 100644 --- a/qt/widgets/spectrumviewer/inc/MantidQtWidgets/SpectrumViewer/SpectrumView.h +++ b/qt/widgets/spectrumviewer/inc/MantidQtWidgets/SpectrumViewer/SpectrumView.h @@ -56,7 +56,7 @@ public: SpectrumView(QWidget *parent = nullptr); ~SpectrumView() override; - void renderWorkspace(Mantid::API::MatrixWorkspace_const_sptr wksp); + void renderWorkspace(const Mantid::API::MatrixWorkspace_const_sptr &wksp); void renderWorkspace(const QString &wsName); QList<boost::shared_ptr<SpectrumDisplay>> getSpectrumDisplays() const { return m_spectrumDisplay; diff --git a/qt/widgets/spectrumviewer/src/ArrayDataSource.cpp b/qt/widgets/spectrumviewer/src/ArrayDataSource.cpp index ae9c8910e860ea6e3aca36628152aa815a2f8e6b..8323d504ba7496ef8bc0499e2367c8541429d984 100644 --- a/qt/widgets/spectrumviewer/src/ArrayDataSource.cpp +++ b/qt/widgets/spectrumviewer/src/ArrayDataSource.cpp @@ -5,6 +5,7 @@ // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + #include <cmath> +#include <utility> #include "MantidQtWidgets/SpectrumViewer/ArrayDataSource.h" #include "MantidQtWidgets/SpectrumViewer/SVUtils.h" @@ -38,7 +39,7 @@ ArrayDataSource::ArrayDataSource(double m_totalXMin, double m_totalXMax, std::vector<float> data) : SpectrumDataSource(m_totalXMin, m_totalXMax, m_totalYMin, m_totalYMax, m_totalRows, m_totalCols), - m_data(data) {} + m_data(std::move(data)) {} ArrayDataSource::~ArrayDataSource() {} diff --git a/qt/widgets/spectrumviewer/src/GraphDisplay.cpp b/qt/widgets/spectrumviewer/src/GraphDisplay.cpp index cb9ce8bdecfb99cb9ae5d82a3906a6a9f92b0173..69768e395e82b52a70f5c625fba64052a1758e25 100644 --- a/qt/widgets/spectrumviewer/src/GraphDisplay.cpp +++ b/qt/widgets/spectrumviewer/src/GraphDisplay.cpp @@ -13,6 +13,8 @@ #include <QString> #include <QVector> #include <boost/algorithm/clamp.hpp> +#include <utility> + #include <qwt_scale_engine.h> namespace MantidQt { @@ -56,7 +58,7 @@ GraphDisplay::~GraphDisplay() { clearCurves(); } * the table. */ void GraphDisplay::setDataSource(SpectrumDataSource_sptr dataSource) { - m_dataSource = dataSource; + m_dataSource = std::move(dataSource); } /** diff --git a/qt/widgets/spectrumviewer/src/MatrixWSDataSource.cpp b/qt/widgets/spectrumviewer/src/MatrixWSDataSource.cpp index 03a4824cdc7f085800105a69c326aa8d72cedec7..125f79a9b1274abf39bda2c6786094c5e4729b7e 100644 --- a/qt/widgets/spectrumviewer/src/MatrixWSDataSource.cpp +++ b/qt/widgets/spectrumviewer/src/MatrixWSDataSource.cpp @@ -46,7 +46,7 @@ namespace SpectrumView { * * @param matWs Shared pointer to the matrix workspace being "wrapped" */ -MatrixWSDataSource::MatrixWSDataSource(MatrixWorkspace_const_sptr matWs) +MatrixWSDataSource::MatrixWSDataSource(const MatrixWorkspace_const_sptr &matWs) : SpectrumDataSource(0.0, 1.0, 0.0, 1.0, 0, 0), m_matWs(matWs), m_emodeHandler(nullptr), m_spectrumInfo(m_matWs->spectrumInfo()) { m_totalXMin = matWs->getXMin(); diff --git a/qt/widgets/spectrumviewer/src/SliderHandler.cpp b/qt/widgets/spectrumviewer/src/SliderHandler.cpp index 8537256237f5f2375b40de0ea276b25f4ac1b5b6..90c5d1b58e01bc275535671eb8afd546f1122c55 100644 --- a/qt/widgets/spectrumviewer/src/SliderHandler.cpp +++ b/qt/widgets/spectrumviewer/src/SliderHandler.cpp @@ -27,8 +27,8 @@ SliderHandler::SliderHandler(Ui_SpectrumViewer *svUI) * be drawn * @param dataSource SpectrumDataSource that provides the data to be drawn */ -void SliderHandler::reConfigureSliders(QRect drawArea, - SpectrumDataSource_sptr dataSource) { +void SliderHandler::reConfigureSliders( + QRect drawArea, const SpectrumDataSource_sptr &dataSource) { QScrollBar *vScroll = m_svUI->imageVerticalScrollBar; int oldVValue = vScroll->value(); diff --git a/qt/widgets/spectrumviewer/src/SpectrumDisplay.cpp b/qt/widgets/spectrumviewer/src/SpectrumDisplay.cpp index a0a6741ca1ae3b2e66c56bc6490e72ed8e9ce97b..c4b581760c948ba5351adae53f3a573dd91d5e86 100644 --- a/qt/widgets/spectrumviewer/src/SpectrumDisplay.cpp +++ b/qt/widgets/spectrumviewer/src/SpectrumDisplay.cpp @@ -10,6 +10,8 @@ #include <QImage> #include <QString> #include <QVector> +#include <utility> + #include <qwt_scale_engine.h> #include "MantidQtWidgets/SpectrumViewer/ColorMaps.h" @@ -97,7 +99,7 @@ void SpectrumDisplay::setupSpectrumPlotItem() { * and information for the table. */ void SpectrumDisplay::setDataSource(SpectrumDataSource_sptr dataSource) { - m_dataSource = dataSource; + m_dataSource = std::move(dataSource); m_hGraphDisplay->setDataSource(m_dataSource); m_vGraphDisplay->setDataSource(m_dataSource); diff --git a/qt/widgets/spectrumviewer/src/SpectrumPlotItem.cpp b/qt/widgets/spectrumviewer/src/SpectrumPlotItem.cpp index 6cfb788c6803432b8fb974c270eb03bf2325100f..1404950528c973d5c051801baef2f9d69536e7e7 100644 --- a/qt/widgets/spectrumviewer/src/SpectrumPlotItem.cpp +++ b/qt/widgets/spectrumviewer/src/SpectrumPlotItem.cpp @@ -35,7 +35,7 @@ SpectrumPlotItem::~SpectrumPlotItem() {} * must have the same number of entries as the * positive color table. */ -void SpectrumPlotItem::setData(DataArray_const_sptr dataArray, +void SpectrumPlotItem::setData(const DataArray_const_sptr &dataArray, std::vector<QRgb> *positiveColorTable, std::vector<QRgb> *negativeColorTable) { if (m_bufferID == 0) { diff --git a/qt/widgets/spectrumviewer/src/SpectrumView.cpp b/qt/widgets/spectrumviewer/src/SpectrumView.cpp index 33daff0127b470427feb260e0d8f9e6d8949da75..c185ec691367d33a23c6c4556d6874dfd4c4bada 100644 --- a/qt/widgets/spectrumviewer/src/SpectrumView.cpp +++ b/qt/widgets/spectrumviewer/src/SpectrumView.cpp @@ -99,7 +99,7 @@ void SpectrumView::resizeEvent(QResizeEvent *event) { * @param wksp The matrix workspace to render */ void SpectrumView::renderWorkspace( - Mantid::API::MatrixWorkspace_const_sptr wksp) { + const Mantid::API::MatrixWorkspace_const_sptr &wksp) { // Handle rendering of a workspace we already track if (replaceExistingWorkspace(wksp->getName(), wksp)) diff --git a/scripts/Diffraction/isis_powder/polaris_routines/polaris_algs.py b/scripts/Diffraction/isis_powder/polaris_routines/polaris_algs.py index 835267e2eb45dc24b43e63db3f97e6e17dedbbeb..f8c015e93bde19eac665389bf7457391b6a15954 100644 --- a/scripts/Diffraction/isis_powder/polaris_routines/polaris_algs.py +++ b/scripts/Diffraction/isis_powder/polaris_routines/polaris_algs.py @@ -9,6 +9,7 @@ import numpy as np import math import mantid.simpleapi as mantid +from mantid.api import WorkspaceGroup from six import string_types from isis_powder.routines import absorb_corrections, common @@ -125,6 +126,17 @@ def generate_ts_pdf(run_number, focus_file_path, merge_banks=False, q_lims=None, pdf_output = mantid.Rebin(InputWorkspace=pdf_output, Params=output_binning) except RuntimeError: return pdf_output + # Rename output ws + if 'merged_ws' in locals(): + mantid.RenameWorkspace(InputWorkspace=merged_ws, OutputWorkspace=run_number + '_merged_Q') + mantid.RenameWorkspace(InputWorkspace='focused_ws', OutputWorkspace=run_number+'_focused_Q') + if isinstance(focused_ws, WorkspaceGroup): + for i in range(len(focused_ws)): + mantid.RenameWorkspace(InputWorkspace=focused_ws[i], OutputWorkspace=run_number+'_focused_Q_'+str(i+1)) + mantid.RenameWorkspace(InputWorkspace='pdf_output', OutputWorkspace=run_number+'_pdf_R') + if isinstance(pdf_output, WorkspaceGroup): + for i in range(len(pdf_output)): + mantid.RenameWorkspace(InputWorkspace=pdf_output[i], OutputWorkspace=run_number+'_pdf_R_'+str(i+1)) return pdf_output diff --git a/tools/Sanitizer/Address.supp b/tools/Sanitizer/Address.supp new file mode 100644 index 0000000000000000000000000000000000000000..ba6df22297f4694780b5f3578ddd9b4d277a7c7d --- /dev/null +++ b/tools/Sanitizer/Address.supp @@ -0,0 +1,2 @@ +# This file is a placeholder for future suppressions. It is passed through +# the ctest harness to the currently running test \ No newline at end of file diff --git a/tools/Sanitizer/Leak.supp b/tools/Sanitizer/Leak.supp new file mode 100644 index 0000000000000000000000000000000000000000..f900da7b50b962d2a515a997cd2d54e012b8cc05 --- /dev/null +++ b/tools/Sanitizer/Leak.supp @@ -0,0 +1,25 @@ +# NeXus has a known memory leak when reading attributes. +# It is fixed upstream but not made it to distribution packages +# Direct leak of 12114 byte(s) in 1346 object(s) allocated from: +# #0 0x7fb126db5538 in strdup (/usr/lib/x86_64-linux-gnu/libasan.so.4+0x77538) +# #1 0x7fb120a534cb (/usr/lib/libNeXus.so.0+0xc4cb) +# #2 0x7fb100000000 (<unknown module>) +leak:libNeXus + +# OpenCascade memory allocation seems to confuse ASAN +# Direct leak of 544 byte(s) in 1 object(s) allocated from: +# #0 0x7f77eec3a618 in operator new[](unsigned long) (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xe0618) +# #1 0x7f77e4141b08 (/usr/lib/x86_64-linux-gnu/libTKernel.so.11+0x7bb08) +leak:libTKernel + +# TBB leaks some memory allocated in singleton depending on deinitialization order +# Direct leak of 1560 byte(s) in 3 object(s) allocated from: +# #0 0x7f7ae72a80a0 in operator new[](unsigned long) (/usr/lib/x86_64-linux-gnu/libasan.so.3+0xc80a0) +# #1 0x7f7ae595d13e (/usr/lib/x86_64-linux-gnu/libtbb.so.2+0x2213e) +leak:libtbb + +# Python and associated libraries *appears* to leak memory. +leak:libpython +leak:umath +leak:multiarray +leak:_ctypes