Commit 8de22e32 authored by Matthew Bowles's avatar Matthew Bowles
Browse files

initial fit for single/multi ion/spectra Re #20358

parent c3d1dd66
......@@ -114,8 +114,21 @@ map<string, string> ResampleX::validateInputs() {
*/
string determineXMinMax(MatrixWorkspace_sptr inputWS, vector<double> &xmins,
vector<double> &xmaxs) {
bool updateXMins = xmins.empty(); // they weren't set
bool updateXMaxs = xmaxs.empty(); // they weren't set
const size_t numSpectra = inputWS->getNumberHistograms();
// pad out the ranges by copying the first value to the rest that are needed
if (xmins.size() == 1 && numSpectra > xmins.size()) {
const double value = xmins.front();
xmins.insert(xmins.end(), numSpectra - xmins.size(), value);
}
if (xmaxs.size() == 1 && numSpectra > xmaxs.size()) {
const double value = xmaxs.front();
xmaxs.insert(xmaxs.end(), numSpectra - xmaxs.size(), value);
}
// should the individiual values be calculated?
const bool updateXMins = xmins.empty(); // they weren't set
const bool updateXMaxs = xmaxs.empty(); // they weren't set
stringstream msg;
......@@ -129,7 +142,6 @@ string determineXMinMax(MatrixWorkspace_sptr inputWS, vector<double> &xmins,
xmax_wksp = inputEventWS->getTofMax();
}
size_t numSpectra = inputWS->getNumberHistograms();
for (size_t i = 0; i < numSpectra; ++i) {
// determine ranges if necessary
if (updateXMins || updateXMaxs) {
......@@ -283,7 +295,7 @@ void ResampleX::exec() {
bool inPlace = (inputWS == outputWS); // Rebinning in-place
m_isDistribution = inputWS->isDistribution();
m_isHistogram = inputWS->isHistogramData();
int numSpectra = static_cast<int>(inputWS->getNumberHistograms());
const int numSpectra = static_cast<int>(inputWS->getNumberHistograms());
// the easy parameters
m_useLogBinning = getProperty("LogBinning");
......@@ -335,8 +347,8 @@ void ResampleX::exec() {
if (common_limits) {
// get the delta from the first since they are all the same
BinEdges xValues(0);
double delta = this->determineBinning(xValues.mutableRawData(),
xmins[0], xmaxs[0]);
const double delta = this->determineBinning(xValues.mutableRawData(),
xmins[0], xmaxs[0]);
g_log.debug() << "delta = " << delta << "\n";
outputEventWS->setAllX(xValues);
} else {
......@@ -348,7 +360,7 @@ void ResampleX::exec() {
for (int wkspIndex = 0; wkspIndex < numSpectra; ++wkspIndex) {
PARALLEL_START_INTERUPT_REGION
BinEdges xValues(0);
double delta = this->determineBinning(
const double delta = this->determineBinning(
xValues.mutableRawData(), xmins[wkspIndex], xmaxs[wkspIndex]);
g_log.debug() << "delta[wkspindex=" << wkspIndex << "] = " << delta
<< " xmin=" << xmins[wkspIndex]
......@@ -378,7 +390,7 @@ void ResampleX::exec() {
// Set the X axis for each output histogram
MantidVec xValues;
double delta =
const double delta =
this->determineBinning(xValues, xmins[wkspIndex], xmaxs[wkspIndex]);
g_log.debug() << "delta[wkspindex=" << wkspIndex << "] = " << delta
<< "\n";
......@@ -458,8 +470,8 @@ void ResampleX::exec() {
// create new output X axis
MantidVec XValues_new;
double delta = this->determineBinning(XValues_new, xmins[wkspIndex],
xmaxs[wkspIndex]);
const double delta = this->determineBinning(XValues_new, xmins[wkspIndex],
xmaxs[wkspIndex]);
g_log.debug() << "delta[wkspindex=" << wkspIndex << "] = " << delta
<< "\n";
......
......@@ -205,7 +205,7 @@ void Stitch1DMany::validateGroupWorkspacesInputs() {
// Log all errors and throw a runtime error if an error is found
validateCommonInputs(errors);
if (errors.size() > 0) {
if (!errors.empty()) {
auto &warnLog = getLogger().warning();
for (const auto &error : errors) {
warnLog << "Invalid value for " << error.first << ": " << error.second
......@@ -241,7 +241,7 @@ void Stitch1DMany::validateCommonInputs(
m_useManualScaleFactors = this->getProperty("UseManualScaleFactors");
m_manualScaleFactors = this->getProperty("ManualScaleFactors");
if (m_manualScaleFactors.size() > 0) {
if (!m_manualScaleFactors.empty()) {
if (m_manualScaleFactors.size() == 1) {
// Single value: fill with list of the same scale factor value
m_manualScaleFactors = std::vector<double>(numStitchableWS - 1,
......
......@@ -18,6 +18,7 @@ using namespace WorkspaceCreationHelper;
class ReflectometryReductionOne2Test : public CxxTest::TestSuite {
private:
MatrixWorkspace_sptr m_singleDetectorWS;
MatrixWorkspace_sptr m_multiDetectorWS;
MatrixWorkspace_sptr m_transmissionWS;
......@@ -33,6 +34,8 @@ public:
ReflectometryReductionOne2Test() {
FrameworkManager::Instance();
// A single detector ws
m_singleDetectorWS = create2DWorkspaceWithReflectometryInstrument(0);
// A multi detector ws
m_multiDetectorWS =
create2DWorkspaceWithReflectometryInstrumentMultiDetector(0, 0.1);
......@@ -447,12 +450,12 @@ public:
alg.setProperty("ThetaIn", 25.0);
MatrixWorkspace_sptr outLam = runAlgorithmLam(alg, 12);
TS_ASSERT_DELTA(outLam->x(0)[0], 0.927132, 1e-6);
TS_ASSERT_DELTA(outLam->x(0)[3], 5.165740, 1e-6);
TS_ASSERT_DELTA(outLam->x(0)[7], 10.817217, 1e-6);
TS_ASSERT_DELTA(outLam->y(0)[0], 2.773699, 1e-6);
TS_ASSERT_DELTA(outLam->y(0)[3], 2.828460, 1e-6);
TS_ASSERT_DELTA(outLam->y(0)[7], 2.816935, 1e-6);
TS_ASSERT_DELTA(outLam->x(0)[0], 0.934991, 1e-6);
TS_ASSERT_DELTA(outLam->x(0)[3], 5.173599, 1e-6);
TS_ASSERT_DELTA(outLam->x(0)[7], 10.825076, 1e-6);
TS_ASSERT_DELTA(outLam->y(0)[0], 2.768185, 1e-6);
TS_ASSERT_DELTA(outLam->y(0)[3], 2.792649, 1e-6);
TS_ASSERT_DELTA(outLam->y(0)[7], 2.787410, 1e-6);
}
void test_sum_in_q_non_flat_sample() {
......@@ -469,12 +472,12 @@ public:
alg.setProperty("ReductionType", "NonFlatSample");
MatrixWorkspace_sptr outLam = runAlgorithmLam(alg, 10);
TS_ASSERT_DELTA(outLam->x(0)[0], 0.822974, 1e-6);
TS_ASSERT_DELTA(outLam->x(0)[3], 5.061582, 1e-6);
TS_ASSERT_DELTA(outLam->x(0)[7], 10.713059, 1e-6);
TS_ASSERT_DELTA(outLam->y(0)[0], 3.140302, 1e-6);
TS_ASSERT_DELTA(outLam->y(0)[3], 3.140457, 1e-6);
TS_ASSERT_DELTA(outLam->y(0)[7], 3.140644, 1e-6);
TS_ASSERT_DELTA(outLam->x(0)[0], 0.825488, 1e-6);
TS_ASSERT_DELTA(outLam->x(0)[3], 5.064095, 1e-6);
TS_ASSERT_DELTA(outLam->x(0)[7], 10.715573, 1e-6);
TS_ASSERT_DELTA(outLam->y(0)[0], 3.141858, 1e-6);
TS_ASSERT_DELTA(outLam->y(0)[3], 3.141885, 1e-6);
TS_ASSERT_DELTA(outLam->y(0)[7], 3.141920, 1e-6);
}
void test_sum_in_q_direct_beam() {
......@@ -492,12 +495,12 @@ public:
alg.setProperty("ThetaIn", 25.0);
MatrixWorkspace_sptr outLam = runAlgorithmLam(alg, 11);
TS_ASSERT_DELTA(outLam->x(0)[0], 0.913144, 1e-6);
TS_ASSERT_DELTA(outLam->x(0)[3], 5.151752, 1e-6);
TS_ASSERT_DELTA(outLam->x(0)[7], 10.803229, 1e-6);
TS_ASSERT_DELTA(outLam->y(0)[0], 0.447237, 1e-6);
TS_ASSERT_DELTA(outLam->y(0)[3], 0.454605, 1e-6);
TS_ASSERT_DELTA(outLam->y(0)[7], 0.451946, 1e-6);
TS_ASSERT_DELTA(outLam->x(0)[0], 0.920496, 1e-6);
TS_ASSERT_DELTA(outLam->x(0)[3], 5.159104, 1e-6);
TS_ASSERT_DELTA(outLam->x(0)[7], 10.810581, 1e-6);
TS_ASSERT_DELTA(outLam->y(0)[0], 0.446571, 1e-6);
TS_ASSERT_DELTA(outLam->y(0)[3], 0.449843, 1e-6);
TS_ASSERT_DELTA(outLam->y(0)[7], 0.448591, 1e-6);
}
void test_sum_in_q_monitor_normalization() {
......@@ -527,12 +530,12 @@ public:
alg.setProperty("ThetaIn", 25.0);
MatrixWorkspace_sptr outLam = runAlgorithmLam(alg, 13);
TS_ASSERT_DELTA(outLam->x(0)[0], -0.742692, 1e-6);
TS_ASSERT_DELTA(outLam->x(0)[5], 6.321654, 1e-6);
TS_ASSERT_DELTA(outLam->x(0)[9], 11.973131, 1e-6);
TS_ASSERT_DELTA(outLam->y(0)[0], 5.044175, 1e-6);
TS_ASSERT_DELTA(outLam->y(0)[5], 2.118472, 1e-6);
TS_ASSERT_DELTA(outLam->y(0)[9], 2.280546, 1e-6);
TS_ASSERT_DELTA(outLam->x(0)[0], -0.748671, 1e-6);
TS_ASSERT_DELTA(outLam->x(0)[5], 6.315674, 1e-6);
TS_ASSERT_DELTA(outLam->x(0)[9], 11.967151, 1e-6);
TS_ASSERT_DELTA(outLam->y(0)[0], 5.040302, 1e-6);
TS_ASSERT_DELTA(outLam->y(0)[5], 2.193649, 1e-6);
TS_ASSERT_DELTA(outLam->y(0)[9], 2.255101, 1e-6);
}
void test_sum_in_q_transmission_correction_run() {
......@@ -546,12 +549,12 @@ public:
alg.setProperty("ThetaIn", 25.0);
MatrixWorkspace_sptr outLam = runAlgorithmLam(alg, 12);
TS_ASSERT_DELTA(outLam->x(0)[0], 0.927132, 1e-6);
TS_ASSERT_DELTA(outLam->x(0)[3], 5.165740, 1e-6);
TS_ASSERT_DELTA(outLam->x(0)[7], 10.817217, 1e-6);
TS_ASSERT_DELTA(outLam->y(0)[0], 0.620714, 1e-6);
TS_ASSERT_DELTA(outLam->y(0)[3], 0.899935, 1e-6);
TS_ASSERT_DELTA(outLam->y(0)[7], 0.896268, 1e-6);
TS_ASSERT_DELTA(outLam->x(0)[0], 0.934991, 1e-6);
TS_ASSERT_DELTA(outLam->x(0)[3], 5.173599, 1e-6);
TS_ASSERT_DELTA(outLam->x(0)[7], 10.825076, 1e-6);
TS_ASSERT_DELTA(outLam->y(0)[0], 0.631775, 1e-6);
TS_ASSERT_DELTA(outLam->y(0)[3], 0.888541, 1e-6);
TS_ASSERT_DELTA(outLam->y(0)[7], 0.886874, 1e-6);
}
void test_sum_in_q_exponential_correction() {
......@@ -567,12 +570,12 @@ public:
alg.setProperty("C1", 0.1);
MatrixWorkspace_sptr outLam = runAlgorithmLam(alg, 11);
TS_ASSERT_DELTA(outLam->x(0)[0], 0.913144, 1e-6);
TS_ASSERT_DELTA(outLam->x(0)[3], 5.151752, 1e-6);
TS_ASSERT_DELTA(outLam->x(0)[7], 10.803229, 1e-6);
TS_ASSERT_DELTA(outLam->y(0)[0], 16.353662, 1e-6);
TS_ASSERT_DELTA(outLam->y(0)[3], 24.261270, 1e-6);
TS_ASSERT_DELTA(outLam->y(0)[7], 39.844321, 1e-6);
TS_ASSERT_DELTA(outLam->x(0)[0], 0.920496, 1e-6);
TS_ASSERT_DELTA(outLam->x(0)[3], 5.159104, 1e-6);
TS_ASSERT_DELTA(outLam->x(0)[7], 10.810581, 1e-6);
TS_ASSERT_DELTA(outLam->y(0)[0], 16.351599, 1e-6);
TS_ASSERT_DELTA(outLam->y(0)[3], 23.963539, 1e-6);
TS_ASSERT_DELTA(outLam->y(0)[7], 39.756738, 1e-6);
}
void test_sum_in_q_IvsQ() {
......@@ -590,13 +593,38 @@ public:
MatrixWorkspace_sptr outQ = runAlgorithmQ(alg, 11);
// X range in outQ
TS_ASSERT_DELTA(outQ->x(0)[0], 0.292253, 1e-6);
TS_ASSERT_DELTA(outQ->x(0)[3], 0.393656, 1e-6);
TS_ASSERT_DELTA(outQ->x(0)[7], 0.732554, 1e-6);
TS_ASSERT_DELTA(outQ->x(0)[0], 0.292122, 1e-6);
TS_ASSERT_DELTA(outQ->x(0)[3], 0.393419, 1e-6);
TS_ASSERT_DELTA(outQ->x(0)[7], 0.731734, 1e-6);
// Y counts
TS_ASSERT_DELTA(outQ->y(0)[0], 2.891639, 1e-6);
TS_ASSERT_DELTA(outQ->y(0)[3], 2.854571, 1e-6);
TS_ASSERT_DELTA(outQ->y(0)[7], 2.871364, 1e-6);
TS_ASSERT_DELTA(outQ->y(0)[0], 2.852088, 1e-6);
TS_ASSERT_DELTA(outQ->y(0)[3], 2.833380, 1e-6);
TS_ASSERT_DELTA(outQ->y(0)[7], 2.841288, 1e-6);
}
void test_sum_in_q_IvsQ_point_detector() {
// Test IvsQ workspace for a point detector
// No monitor normalization
// No direct beam normalization
// No transmission correction
// Processing instructions : 0
ReflectometryReductionOne2 alg;
setupAlgorithm(alg, 1.5, 15.0, "0");
alg.setProperty("InputWorkspace", m_singleDetectorWS);
alg.setProperty("SummationType", "SumInQ");
alg.setProperty("ReductionType", "DivergentBeam");
alg.setProperty("ThetaIn", 25.0);
MatrixWorkspace_sptr outQ = runAlgorithmQ(alg, 28);
// X range in outQ
TS_ASSERT_DELTA(outQ->x(0)[0], 0.279882, 1e-6);
TS_ASSERT_DELTA(outQ->x(0)[3], 0.310524, 1e-6);
TS_ASSERT_DELTA(outQ->x(0)[7], 0.363599, 1e-6);
// Y counts
TS_ASSERT_DELTA(outQ->y(0)[0], 2.900305, 1e-6);
TS_ASSERT_DELTA(outQ->y(0)[3], 2.886947, 1e-6);
TS_ASSERT_DELTA(outQ->y(0)[7], 2.607359, 1e-6);
}
private:
......
......@@ -39,6 +39,7 @@ private:
void integrateEvent();
int findPixelID(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;
/// Input 2D Workspace
......
......@@ -5,6 +5,8 @@
#include "MantidKernel/VectorHelper.h"
#include "MantidGeometry/Crystal/OrientedLattice.h"
#include "MantidGeometry/Crystal/EdgePixel.h"
#include "MantidGeometry/Instrument/ComponentInfo.h"
#include <boost/algorithm/clamp.hpp>
using Mantid::DataObjects::PeaksWorkspace;
......@@ -106,6 +108,8 @@ void CentroidPeaks::integrate() {
const auto &X = inWS->x(workspaceIndex);
int chan = Kernel::VectorHelper::getBinIndex(X.rawData(), TOFPeakd);
std::string bankName = peak.getBankName();
int nCols = 0, nRows = 0;
sizeBanks(bankName, nCols, nRows);
double intensity = 0.0;
double chancentroid = 0.0;
......@@ -114,10 +118,10 @@ void CentroidPeaks::integrate() {
int chanend = std::min(static_cast<int>(X.size()), chan + PeakRadius);
double rowcentroid = 0.0;
int rowstart = std::max(0, row - PeakRadius);
int rowend = row + PeakRadius;
int rowend = std::min(nRows - 1, row + PeakRadius);
double colcentroid = 0.0;
int colstart = col - PeakRadius;
int colend = col + PeakRadius;
int colstart = std::max(0, col - PeakRadius);
int colend = std::min(nCols - 1, col + PeakRadius);
for (int ichan = chanstart; ichan <= chanend; ++ichan) {
for (int irow = rowstart; irow <= rowend; ++irow) {
for (int icol = colstart; icol <= colend; ++icol) {
......@@ -140,16 +144,15 @@ void CentroidPeaks::integrate() {
}
// Set pixelID to change row and col
row = int(rowcentroid / intensity);
row = std::max(0, row);
boost::algorithm::clamp(row, 0, nRows - 1);
col = int(colcentroid / intensity);
col = std::max(0, col);
boost::algorithm::clamp(col, 0, nCols - 1);
chan = int(chancentroid / intensity);
chan = std::max(0, chan);
chan = std::min(static_cast<int>(inWS->blocksize()), chan);
boost::algorithm::clamp(chan, 0, static_cast<int>(inWS->blocksize()));
peak.setDetectorID(findPixelID(bankName, col, row));
// Set wavelength to change tof for peak object
if (!edgePixel(inst, bankName, col, row, Edge)) {
peak.setDetectorID(findPixelID(bankName, col, row));
it = wi_to_detid_map.find(findPixelID(bankName, col, row));
workspaceIndex = (it->second);
Mantid::Kernel::Units::Wavelength wl;
......@@ -224,6 +227,8 @@ void CentroidPeaks::integrateEvent() {
int row = peak.getRow();
double TOFPeakd = peak.getTOF();
std::string bankName = peak.getBankName();
int nCols = 0, nRows = 0;
sizeBanks(bankName, nCols, nRows);
double intensity = 0.0;
double tofcentroid = 0.0;
......@@ -234,10 +239,10 @@ void CentroidPeaks::integrateEvent() {
double tofend = TOFPeakd * std::pow(1.004, PeakRadius);
double rowcentroid = 0.0;
int rowstart = std::max(0, row - PeakRadius);
int rowend = row + PeakRadius;
int rowend = std::min(nRows - 1, row + PeakRadius);
double colcentroid = 0.0;
int colstart = std::max(0, col - PeakRadius);
int colend = col + PeakRadius;
int colend = std::min(nCols - 1, col + PeakRadius);
for (int irow = rowstart; irow <= rowend; ++irow) {
for (int icol = colstart; icol <= colend; ++icol) {
if (edgePixel(inst, bankName, icol, irow, Edge))
......@@ -263,9 +268,9 @@ void CentroidPeaks::integrateEvent() {
}
// Set pixelID to change row and col
row = int(rowcentroid / intensity);
row = std::max(0, row);
boost::algorithm::clamp(row, 0, nRows - 1);
col = int(colcentroid / intensity);
col = std::max(0, col);
boost::algorithm::clamp(col, 0, nCols - 1);
if (!edgePixel(inst, bankName, col, row, Edge)) {
peak.setDetectorID(findPixelID(bankName, col, row));
......@@ -340,7 +345,7 @@ void CentroidPeaks::removeEdgePeaks(
Mantid::DataObjects::PeaksWorkspace &peakWS) {
int Edge = getProperty("EdgePixels");
std::vector<int> badPeaks;
size_t numPeaks = peakWS.getNumberPeaks() - 1;
size_t numPeaks = peakWS.getNumberPeaks();
for (int i = 0; i < static_cast<int>(numPeaks); i++) {
// Get a direct ref to that peak.
const auto &peak = peakWS.getPeak(i);
......@@ -355,5 +360,33 @@ void CentroidPeaks::removeEdgePeaks(
peakWS.removePeaks(std::move(badPeaks));
}
void CentroidPeaks::sizeBanks(const std::string &bankName, int &nCols,
int &nRows) {
if (bankName == "None")
return;
ExperimentInfo expInfo;
expInfo.setInstrument(inst);
const auto &compInfo = expInfo.componentInfo();
// Get a single bank
auto bank = inst->getComponentByName(bankName);
auto bankID = bank->getComponentID();
auto allBankDetectorIndexes =
compInfo.detectorsInSubtree(compInfo.indexOf(bankID));
nRows = static_cast<int>(
compInfo.componentsInSubtree(compInfo.indexOf(bankID)).size() -
allBankDetectorIndexes.size() - 1);
nCols = static_cast<int>(allBankDetectorIndexes.size()) / nRows;
if (nCols * nRows != static_cast<int>(allBankDetectorIndexes.size())) {
// Need grandchild instead of child
nRows = static_cast<int>(
compInfo.componentsInSubtree(compInfo.indexOf(bankID)).size() -
allBankDetectorIndexes.size() - 2);
nCols = static_cast<int>(allBankDetectorIndexes.size()) / nRows;
}
}
} // namespace Mantid
} // namespace Crystal
......@@ -51,7 +51,7 @@ void PeakHKLErrors::init() {
declareParameter("GonRotz", 0.0,
"1st Rotation of Goniometer about the z axis");
initMode = 1;
if (OptRuns == "")
if (OptRuns.empty())
return;
initMode = 2;
......
......@@ -263,7 +263,7 @@ void SCDPanelErrors::setAttribute(const std::string &attName,
}
FileValidator fval;
std::string error = fval.isValid(fileName);
if (error == "") {
if (error.empty()) {
storeAttributeValue(attName, Attribute(fileName, true));
storeAttributeValue("Workspace", Attribute(""));
} else {
......
......@@ -139,10 +139,14 @@ public:
PeaksWorkspace_sptr pkws(new PeaksWorkspace());
// pkws->setName("TOPAZ");
// Create a single peak on that particular detector
Peak PeakObj(in_ws->getInstrument(), 5050, 2., V3D(1, 1, 1));
// Create two peaks on that particular detector
// First peak is at edge to check EdgePixels option
Peak PeakObj(in_ws->getInstrument(), 0, 2., V3D(1, 1, 1));
PeakObj.setRunNumber(3007);
pkws->addPeak(PeakObj);
Peak PeakObj2(in_ws->getInstrument(), 5050, 2., V3D(1, 1, 1));
PeakObj2.setRunNumber(3007);
pkws->addPeak(PeakObj2);
AnalysisDataService::Instance().addOrReplace("TOPAZ", pkws);
inputW->mutableRun().addProperty("run_number", 3007);
......
......@@ -289,7 +289,7 @@ void ConvertToYSpace::createOutputWorkspace() {
m_outputWS->setYUnitLabel("");
// q-Space output workspace
if (getPropertyValue("QWorkspace") != "") {
if (!getPropertyValue("QWorkspace").empty()) {
m_qOutputWS = WorkspaceFactory::Instance().create(m_inputWS);
m_qOutputWS->getAxis(0)->unit() = xLabel;
......
......@@ -138,7 +138,7 @@ void Fit::copyMinimizerOutput(const API::IFuncMinimizer &minimizer) {
auto &properties = minimizer.getProperties();
for (auto property : properties) {
if ((*property).direction() == Kernel::Direction::Output &&
(*property).isValid() == "") {
(*property).isValid().empty()) {
auto clonedProperty =
std::unique_ptr<Kernel::Property>((*property).clone());
declareProperty(std::move(clonedProperty));
......
......@@ -646,7 +646,7 @@ std::string PlotPeakByLogValue::getMinimizerString(const std::string &wsName,
dynamic_cast<Mantid::API::WorkspaceProperty<> *>(minimizerProp);
if (wsProp) {
const std::string &wsPropValue = minimizerProp->value();
if (wsPropValue != "") {
if (!wsPropValue.empty()) {
const std::string &wsPropName = minimizerProp->name();
m_minimizerWorkspaces[wsPropName].push_back(wsPropValue);
}
......
......@@ -223,7 +223,7 @@ void SplineInterpolation::exec() {
}
// Store the output workspaces
std::string derivWsName = getPropertyValue("OutputWorkspaceDeriv");
if (order > 0 && derivWsName != "") {
if (order > 0 && !derivWsName.empty()) {
// Store derivatives in a grouped workspace
WorkspaceGroup_sptr wsg = WorkspaceGroup_sptr(new WorkspaceGroup);
for (size_t i = 0; i < histNo; ++i) {
......
......@@ -266,7 +266,7 @@ void CrystalFieldMultiSpectrum::calcExcitations(
// using an index instead of a name for performance reasons
auto &source = dynamic_cast<Peaks &>(*m_source);
double intensityScaling;
if (source.m_IntensityScalingIdx.size() == 0) {
if (source.m_IntensityScalingIdx.empty()) {
intensityScaling = getParameter(m_nOwnParams - nSpec + iSpec);
} else {
intensityScaling = getParameter(source.m_IntensityScalingIdx[iSpec]);
......
......@@ -174,7 +174,7 @@ void TabulatedFunction::setAttribute(const std::string &attName,
}
FileValidator fval;
std::string error = fval.isValid(fileName);
if (error == "") {
if (error.empty()) {
storeAttributeValue(attName, Attribute(fileName, true));
storeAttributeValue("Workspace", Attribute(""));
} else {
......
......@@ -412,6 +412,7 @@ void DataBlockComposite::removeSpectra(DataBlockComposite &toRemove) {
// Get intervals for the data blocks which should be removed
auto removeBlocks = toRemove.getDataBlocks();
std::vector<std::pair<int64_t, int64_t>> toRemoveIntervals;
toRemoveIntervals.reserve(removeBlocks.size());
for (const auto &dataBlock : removeBlocks) {
toRemoveIntervals.emplace_back(dataBlock.getMinSpectrumID(),
dataBlock.getMaxSpectrumID());
......
......@@ -204,7 +204,7 @@ DownloadInstrument::StringToStringMap DownloadInstrument::processRepository() {
if ((sha != installSha) && (sha != localSha)) {
fileMap.emplace(htmlUrl,
filePath.toString()); // ACTION - DOWNLOAD to localPath
} else if ((localSha != "") && (sha == installSha) &&
} else if ((!localSha.empty()) && (sha == installSha) &&
(sha != localSha)) // matches install, but different local
{
fileMap.emplace(
......
......@@ -671,7 +671,7 @@ void LoadAscii2::exec() {
std::string sep;
// If the custom separator property is not empty, then we use that under any
// circumstance.
if (custom != "") {
if (!custom.empty()) {
sep = custom;
}
// Else if the separator drop down choice is not UserDefined then we use that.
......
......@@ -293,7 +293,7 @@ void LoadFITS::loadHeader(const std::string &filePath, FITSInfo &header) {
}
// scale parameter, header BSCALE in the fits standard
if ("" == header.headerKeys[m_headerScaleKey]) {
if (header.headerKeys[m_headerScaleKey].empty()) {
header.scale = 1;
} else {
try {
......@@ -308,7 +308,7 @@ void LoadFITS::loadHeader(const std::string &filePath, FITSInfo &header) {
}
// data offsset parameter, header BZERO in the fits standard
if ("" == header.headerKeys[m_headerOffsetKey]) {
if (header.headerKeys[m_headerOffsetKey].empty()) {
header.offset = 0;
} else {
try {
......@@ -361,7 +361,7 @@ void LoadFITS::loadHeader(const std::string &filePath, FITSInfo &header) {
void LoadFITS::headerSanityCheck(const FITSInfo &hdr,
const FITSInfo &hdrFirst) {
bool valid = true;
if (hdr.extension != "") {
if (!hdr.extension.empty()) {
valid = false;
g_log.error() << "File " << hdr.filePath
<< ": extensions found in the header.\n";
......@@ -625,7 +625,7 @@ void LoadFITS::parseHeader(FITSInfo &headerInfo) {
if (key == g_END_KEYNAME)
endFound = true;
if (key != "")
if (!key.empty())
headerInfo.headerKeys[key] = value;
}
}
......@@ -1141,7 +1141,7 @@ void LoadFITS::setupDefaultKeywordNames() {