diff --git a/Framework/MDAlgorithms/src/AccumulateMD.cpp b/Framework/MDAlgorithms/src/AccumulateMD.cpp index 3d5d6f705f6e406035d704069209c387e41491dd..9c72eb9be6a92e6644c01b65ec89ff9b0f942925 100644 --- a/Framework/MDAlgorithms/src/AccumulateMD.cpp +++ b/Framework/MDAlgorithms/src/AccumulateMD.cpp @@ -149,14 +149,13 @@ getHistoricalDataSources(const WorkspaceHistory &ws_history, auto view = ws_history.createView(); view->unrollAll(); const std::vector<HistoryItem> history_items = view->getAlgorithmsList(); - for (auto iter = history_items.begin(); iter != history_items.end(); ++iter) { - auto alg_history = iter->getAlgorithmHistory(); + for (const auto &history_item : history_items) { + auto alg_history = history_item.getAlgorithmHistory(); if (alg_history->name() == create_alg_name || alg_history->name() == accumulate_alg_name) { auto props = alg_history->getProperties(); - for (auto prop_iter = props.begin(); prop_iter != props.end(); - ++prop_iter) { - PropertyHistory_const_sptr prop_history = *prop_iter; + for (auto &prop : props) { + PropertyHistory_const_sptr prop_history = prop; if (prop_history->name() == "DataSources") { insertDataSources(prop_history->value(), historical_data_sources); } @@ -188,8 +187,8 @@ void insertDataSources(const std::string &data_sources, boost::bind(boost::algorithm::trim<std::string>, _1, std::locale())); // Insert each data source into our complete set of historical data sources - for (auto it = data_split.begin(); it != data_split.end(); ++it) { - historical_data_sources.insert(*it); + for (auto &it : data_split) { + historical_data_sources.insert(it); } } diff --git a/Framework/MDAlgorithms/src/BinMD.cpp b/Framework/MDAlgorithms/src/BinMD.cpp index b7ae382f0ba8b0f349796797cd6911e43f639847..0d64f9ec1b9bd3a8cba2bbd0dc3e7c913e12aec0 100644 --- a/Framework/MDAlgorithms/src/BinMD.cpp +++ b/Framework/MDAlgorithms/src/BinMD.cpp @@ -332,8 +332,8 @@ void BinMD::binByIterating(typename MDEventWorkspace<MDE, nd>::sptr ws) { } // Go through every box for this chunk. - for (size_t i = 0; i < boxes.size(); i++) { - MDBox<MDE, nd> *box = dynamic_cast<MDBox<MDE, nd> *>(boxes[i]); + for (auto &boxe : boxes) { + MDBox<MDE, nd> *box = dynamic_cast<MDBox<MDE, nd> *>(boxe); // Perform the binning in this separate method. if (box) this->binMDBox(box, chunkMin.data(), chunkMax.data()); diff --git a/Framework/MDAlgorithms/src/BoxControllerSettingsAlgorithm.cpp b/Framework/MDAlgorithms/src/BoxControllerSettingsAlgorithm.cpp index 8fe24a9e938278b945a1b993cc69bbd7e03a7e8f..c12ab5e2eeb2c7d10f3538146be97f0e8aefb2fd 100644 --- a/Framework/MDAlgorithms/src/BoxControllerSettingsAlgorithm.cpp +++ b/Framework/MDAlgorithms/src/BoxControllerSettingsAlgorithm.cpp @@ -41,8 +41,8 @@ void BoxControllerSettingsAlgorithm::initBoxControllerProps( tokenizer::TOK_IGNORE_EMPTY | tokenizer::TOK_TRIM); value.clear(); value.reserve(values.count()); - for (auto it = values.begin(); it != values.end(); ++it) - value.push_back(boost::lexical_cast<int>(*it)); + for (const auto &it : values) + value.push_back(boost::lexical_cast<int>(it)); declareProperty( new ArrayProperty<int>("SplitInto", value), diff --git a/Framework/MDAlgorithms/src/CalculateCoverageDGS.cpp b/Framework/MDAlgorithms/src/CalculateCoverageDGS.cpp index 314e164716b3e9d5fe7bb3da0486358ab3b8567f..0b3b09072d68fe100fa37303c0a5c6d45d8baad9 100644 --- a/Framework/MDAlgorithms/src/CalculateCoverageDGS.cpp +++ b/Framework/MDAlgorithms/src/CalculateCoverageDGS.cpp @@ -171,8 +171,8 @@ void CalculateCoverageDGS::exec() { auto instrument = inputWS->getInstrument(); std::vector<detid_t> detIDS = instrument->getDetectorIDs(true); std::vector<double> tt, phi; - for (int i = 0; i < static_cast<int>(detIDS.size()); i++) { - auto detector = instrument->getDetector(detIDS[i]); + for (int &i : detIDS) { + auto detector = instrument->getDetector(i); if (!detector->isMasked()) { tt.push_back(detector->getTwoTheta(V3D(0, 0, 0), V3D(0, 0, 1))); phi.push_back(detector->getPhi()); diff --git a/Framework/MDAlgorithms/src/ConvertCWPDMDToSpectra.cpp b/Framework/MDAlgorithms/src/ConvertCWPDMDToSpectra.cpp index e8ad2b749266bc307792ebb08d5f460f5372d0cf..21f4c1157c1a942ff5e57b723a164c1d3e35f3cd 100644 --- a/Framework/MDAlgorithms/src/ConvertCWPDMDToSpectra.cpp +++ b/Framework/MDAlgorithms/src/ConvertCWPDMDToSpectra.cpp @@ -695,8 +695,7 @@ void ConvertCWPDMDToSpectra::setupSampleLogs( const Run &srcrun = lastexpinfo->run(); const std::vector<Kernel::Property *> &vec_srcprop = srcrun.getProperties(); - for (size_t i = 0; i < vec_srcprop.size(); ++i) { - Property *p = vec_srcprop[i]; + for (auto p : vec_srcprop) { targetrun.addProperty(p->clone()); g_log.debug() << "Cloned property " << p->name() << "\n"; } diff --git a/Framework/MDAlgorithms/src/ConvertCWSDExpToMomentum.cpp b/Framework/MDAlgorithms/src/ConvertCWSDExpToMomentum.cpp index 746eb498bc4ad870cb81ff6452f4c2cce3ab69e5..0160145e6052507ab68fc1b3edfc3c44ea27c54c 100644 --- a/Framework/MDAlgorithms/src/ConvertCWSDExpToMomentum.cpp +++ b/Framework/MDAlgorithms/src/ConvertCWSDExpToMomentum.cpp @@ -421,8 +421,8 @@ void ConvertCWSDExpToMomentum::convertSpiceMatrixToMomentumMDEvents( // Add all the other propertys from original data workspace const std::vector<Kernel::Property *> vec_property = dataws->run().getProperties(); - for (size_t i = 0; i < vec_property.size(); ++i) { - expinfo->mutableRun().addProperty(vec_property[i]->clone()); + for (auto i : vec_property) { + expinfo->mutableRun().addProperty(i->clone()); } m_outputWS->addExperimentInfo(expinfo); diff --git a/Framework/MDAlgorithms/src/ConvertSpiceDataToRealSpace.cpp b/Framework/MDAlgorithms/src/ConvertSpiceDataToRealSpace.cpp index 7d83278d8be0a44923d5205094f5262cb0a36a13..c33cb01c58c0476de6b75edee2f67f402aea795d 100644 --- a/Framework/MDAlgorithms/src/ConvertSpiceDataToRealSpace.cpp +++ b/Framework/MDAlgorithms/src/ConvertSpiceDataToRealSpace.cpp @@ -555,14 +555,13 @@ void ConvertSpiceDataToRealSpace::addExperimentInfos( API::IMDEventWorkspace_sptr mdws, const std::vector<API::MatrixWorkspace_sptr> vec_ws2d) { // Add N experiment info as there are N measurment points - for (size_t i = 0; i < vec_ws2d.size(); ++i) { + for (const auto &i : vec_ws2d) { // Create an ExperimentInfo object ExperimentInfo_sptr tmp_expinfo = boost::make_shared<ExperimentInfo>(); - Geometry::Instrument_const_sptr tmp_inst = vec_ws2d[i]->getInstrument(); + Geometry::Instrument_const_sptr tmp_inst = i->getInstrument(); tmp_expinfo->setInstrument(tmp_inst); - int runnumber = - atoi(vec_ws2d[i]->run().getProperty("run_number")->value().c_str()); + int runnumber = atoi(i->run().getProperty("run_number")->value().c_str()); tmp_expinfo->mutableRun().addProperty( new PropertyWithValue<int>("run_number", runnumber)); @@ -631,8 +630,7 @@ IMDEventWorkspace_sptr ConvertSpiceDataToRealSpace::createDataMDWorkspace( MDEventInserter<MDEventWorkspace<MDEvent<3>, 3>::sptr> inserter( MDEW_MDEVENT_3); - for (size_t iws = 0; iws < vec_ws2d.size(); ++iws) { - API::MatrixWorkspace_sptr thisWorkspace = vec_ws2d[iws]; + for (auto thisWorkspace : vec_ws2d) { short unsigned int runnumber = static_cast<short unsigned int>( atoi(thisWorkspace->run().getProperty("run_number")->value().c_str())); diff --git a/Framework/MDAlgorithms/src/ConvertToDetectorFaceMD.cpp b/Framework/MDAlgorithms/src/ConvertToDetectorFaceMD.cpp index 045541cc996093242e9052fa213df2109e7e4b3d..1e8bfd131b01ea005cd8ca84ac9b891cbb750ef6 100644 --- a/Framework/MDAlgorithms/src/ConvertToDetectorFaceMD.cpp +++ b/Framework/MDAlgorithms/src/ConvertToDetectorFaceMD.cpp @@ -140,10 +140,10 @@ ConvertToDetectorFaceMD::getBanks() { std::vector<IComponent_const_sptr> comps; inst->getChildren(comps, true); - for (size_t i = 0; i < comps.size(); i++) { + for (auto &comp : comps) { // Retrieve it RectangularDetector_const_sptr det = - boost::dynamic_pointer_cast<const RectangularDetector>(comps[i]); + boost::dynamic_pointer_cast<const RectangularDetector>(comp); if (det) { std::string name = det->getName(); if (name.size() < 5) @@ -157,20 +157,19 @@ ConvertToDetectorFaceMD::getBanks() { } } else { // -- Find detectors using the numbers given --- - for (auto bankNum = bankNums.begin(); bankNum != bankNums.end(); - bankNum++) { + for (int &bankNum : bankNums) { std::string bankName = - "bank" + Mantid::Kernel::Strings::toString(*bankNum); + "bank" + Mantid::Kernel::Strings::toString(bankNum); IComponent_const_sptr comp = inst->getComponentByName(bankName); RectangularDetector_const_sptr det = boost::dynamic_pointer_cast<const RectangularDetector>(comp); if (det) - banks[*bankNum] = det; + banks[bankNum] = det; } } - for (auto bank = banks.begin(); bank != banks.end(); bank++) { - RectangularDetector_const_sptr det = bank->second; + for (auto &bank : banks) { + RectangularDetector_const_sptr det = bank.second; // Track the largest detector if (det->xpixels() > m_numXPixels) m_numXPixels = det->xpixels(); @@ -268,9 +267,9 @@ void ConvertToDetectorFaceMD::exec() { uint16_t runIndex = outWS->addExperimentInfo(ei); // ---------------- Convert each bank -------------------------------------- - for (auto it = banks.begin(); it != banks.end(); it++) { - int bankNum = it->first; - RectangularDetector_const_sptr det = it->second; + for (auto &bank : banks) { + int bankNum = bank.first; + RectangularDetector_const_sptr det = bank.second; for (int x = 0; x < det->xpixels(); x++) for (int y = 0; y < det->ypixels(); y++) { // Find the workspace index for this pixel coordinate diff --git a/Framework/MDAlgorithms/src/ConvertToDiffractionMDWorkspace.cpp b/Framework/MDAlgorithms/src/ConvertToDiffractionMDWorkspace.cpp index 2c839eee383f057731af43d98907f94097c2fe8b..9bcccb92d735d2db590f0eb8f28de901609a713e 100644 --- a/Framework/MDAlgorithms/src/ConvertToDiffractionMDWorkspace.cpp +++ b/Framework/MDAlgorithms/src/ConvertToDiffractionMDWorkspace.cpp @@ -616,8 +616,8 @@ void ConvertToDiffractionMDWorkspace::exec() { << " events. This took " << cputimtotal << " in total.\n"; std::vector<std::string> stats = ws->getBoxControllerStats(); - for (size_t i = 0; i < stats.size(); ++i) - g_log.information() << stats[i] << "\n"; + for (auto &stat : stats) + g_log.information() << stat << "\n"; g_log.information() << std::endl; } diff --git a/Framework/MDAlgorithms/src/ConvertToMD.cpp b/Framework/MDAlgorithms/src/ConvertToMD.cpp index 7cdeff300d7abe76168a2a1e2658ce0394e1b5c5..704cd0867e9905083d2889bba07c0fe61f660d47 100644 --- a/Framework/MDAlgorithms/src/ConvertToMD.cpp +++ b/Framework/MDAlgorithms/src/ConvertToMD.cpp @@ -302,8 +302,8 @@ void ConvertToMD::copyMetaData(API::IMDEventWorkspace_sptr &mdEventWS) const { UnitsConversionHelper &unitConv = m_Convertor->getUnitConversionHelper(); unitConv.updateConversion(spectra_index); - for (size_t i = 0; i < binBoundaries.size(); i++) { - binBoundaries[i] = unitConv.convertUnits(binBoundaries[i]); + for (double &binBoundarie : binBoundaries) { + binBoundarie = unitConv.convertUnits(binBoundarie); } } // sort bin boundaries in case if unit transformation have swapped them. diff --git a/Framework/MDAlgorithms/src/ConvertToMDMinMaxGlobal.cpp b/Framework/MDAlgorithms/src/ConvertToMDMinMaxGlobal.cpp index b664e1346cfec9abe667a210103b79111bf0ddae..071d6544d16aefea6a3ff6e8c8f024d7bd080b31 100644 --- a/Framework/MDAlgorithms/src/ConvertToMDMinMaxGlobal.cpp +++ b/Framework/MDAlgorithms/src/ConvertToMDMinMaxGlobal.cpp @@ -266,13 +266,13 @@ void ConvertToMDMinMaxGlobal::exec() { } } - for (size_t i = 0; i < OtherDimensions.size(); ++i) { - if (!ws->run().hasProperty(OtherDimensions[i])) { + for (auto &OtherDimension : OtherDimensions) { + if (!ws->run().hasProperty(OtherDimension)) { g_log.error() << "The workspace does not have a property " - << OtherDimensions[i] << std::endl; + << OtherDimension << std::endl; throw std::invalid_argument("Property not found. Please see error log."); } - Kernel::Property *pProperty = (ws->run().getProperty(OtherDimensions[i])); + Kernel::Property *pProperty = (ws->run().getProperty(OtherDimension)); TimeSeriesProperty<double> *p = dynamic_cast<TimeSeriesProperty<double> *>(pProperty); if (p) { @@ -285,8 +285,8 @@ void ConvertToMDMinMaxGlobal::exec() { if (!p) { std::string ERR = " Can not interpret property, used as dimension.\n Property: " + - OtherDimensions[i] + " is neither a time series (run) property nor " - "a property with value<double>"; + OtherDimension + " is neither a time series (run) property nor " + "a property with value<double>"; throw(std::invalid_argument(ERR)); } double val = *p; diff --git a/Framework/MDAlgorithms/src/ConvertToMDMinMaxLocal.cpp b/Framework/MDAlgorithms/src/ConvertToMDMinMaxLocal.cpp index fa4fb038b54237325307a6b358779f25527c9e84..e911eb0965d84b00b4526b71551f6a06bc71f6f1 100644 --- a/Framework/MDAlgorithms/src/ConvertToMDMinMaxLocal.cpp +++ b/Framework/MDAlgorithms/src/ConvertToMDMinMaxLocal.cpp @@ -176,9 +176,9 @@ void ConvertToMDMinMaxLocal::findMinMaxValues(MDWSDescription &WSDescription, std::vector<double> range = pQtransf->getExtremumPoints(x1, x2, iSpctr); // transform coordinates - for (size_t k = 0; k < range.size(); k++) { + for (double &k : range) { - pQtransf->calcMatrixCoord(range[k], locCoord, signal, errorSq); + pQtransf->calcMatrixCoord(k, locCoord, signal, errorSq); // identify min-max ranges for current spectrum for (size_t j = 0; j < nDims; j++) { if (locCoord[j] < MinValues[j]) diff --git a/Framework/MDAlgorithms/src/CreateMD.cpp b/Framework/MDAlgorithms/src/CreateMD.cpp index 6e7609674984b529585c51c8b15a98b7a427be6d..d7b3403eed19c36bbd88cadadb89f622e28f97d8 100644 --- a/Framework/MDAlgorithms/src/CreateMD.cpp +++ b/Framework/MDAlgorithms/src/CreateMD.cpp @@ -40,8 +40,8 @@ void padParameterVector(std::vector<double> ¶m_vector, */ bool any_given(const std::vector<std::vector<double>> ¶ms) { std::vector<double> param; - for (auto iter = params.begin(); iter != params.end(); ++iter) { - param = *iter; + for (const auto &iter : params) { + param = iter; if (!param.empty()) { return true; } @@ -57,8 +57,8 @@ bool any_given(const std::vector<std::vector<double>> ¶ms) { */ bool all_given(const std::vector<std::vector<double>> ¶ms) { std::vector<double> param; - for (auto iter = params.begin(); iter != params.end(); ++iter) { - param = *iter; + for (const auto &iter : params) { + param = iter; if (param.empty()) { return false; } @@ -244,9 +244,8 @@ void CreateMD::exec() { } // Clean up temporary workspaces - for (auto ws_iter = to_merge_names.begin(); ws_iter != to_merge_names.end(); - ++ws_iter) { - AnalysisDataService::Instance().remove(*ws_iter); + for (auto &to_merge_name : to_merge_names) { + AnalysisDataService::Instance().remove(to_merge_name); } this->setProperty("OutputWorkspace", output_workspace); diff --git a/Framework/MDAlgorithms/src/CreateMDWorkspace.cpp b/Framework/MDAlgorithms/src/CreateMDWorkspace.cpp index 129dbe5e18102fb1b7d4243997edb1b845dc2d72..21d91bbfc180063573cc75a4182fdc539ef0adb9 100644 --- a/Framework/MDAlgorithms/src/CreateMDWorkspace.cpp +++ b/Framework/MDAlgorithms/src/CreateMDWorkspace.cpp @@ -236,8 +236,8 @@ std::map<std::string, std::string> CreateMDWorkspace::validateInputs() { targetFrames.push_back(Mantid::Geometry::QSample::QSampleName); auto isValidFrame = true; - for (auto it = frames.begin(); it != frames.end(); ++it) { - auto result = checkIfFrameValid(*it, targetFrames); + for (auto &frame : frames) { + auto result = checkIfFrameValid(frame, targetFrames); if (!result) { isValidFrame = result; } @@ -264,9 +264,8 @@ std::map<std::string, std::string> CreateMDWorkspace::validateInputs() { */ bool CreateMDWorkspace::checkIfFrameValid( const std::string &frame, const std::vector<std::string> &targetFrames) { - for (auto targetFrame = targetFrames.begin(); - targetFrame != targetFrames.end(); ++targetFrame) { - if (*targetFrame == frame) { + for (const auto &targetFrame : targetFrames) { + if (targetFrame == frame) { return true; } } diff --git a/Framework/MDAlgorithms/src/CutMD.cpp b/Framework/MDAlgorithms/src/CutMD.cpp index ecb5bc0a19141cbf256c7a709080501388031009..7ac96ae746d574a445c031ae767b7bef1adca53b 100644 --- a/Framework/MDAlgorithms/src/CutMD.cpp +++ b/Framework/MDAlgorithms/src/CutMD.cpp @@ -88,10 +88,10 @@ std::vector<MinMax> calculateExtents(const DblMatrix &inMatrix, const double maxDbl = std::numeric_limits<double>::max(); std::vector<MinMax> extents(3, std::make_pair(maxDbl, maxDbl)); - for (auto hIt = hRange.begin(); hIt != hRange.end(); ++hIt) { - for (auto kIt = kRange.begin(); kIt != kRange.end(); ++kIt) { - for (auto lIt = lRange.begin(); lIt != lRange.end(); ++lIt) { - V3D origPos(*hIt, *kIt, *lIt); + for (double &hIt : hRange) { + for (double &kIt : kRange) { + for (double &lIt : lRange) { + V3D origPos(hIt, kIt, lIt); for (size_t i = 0; i < 3; ++i) { const V3D other(invMat[i][0], invMat[i][1], invMat[i][2]); double val = origPos.scalar_prod(other); diff --git a/Framework/MDAlgorithms/src/DivideMD.cpp b/Framework/MDAlgorithms/src/DivideMD.cpp index 23c762fcd57067b0889ac3b13bcdad8c95b44d36..efbb9a17ad33ced93fe9cfde59bbcca79af48067 100644 --- a/Framework/MDAlgorithms/src/DivideMD.cpp +++ b/Framework/MDAlgorithms/src/DivideMD.cpp @@ -73,8 +73,8 @@ void DivideMD::execEventScalar(typename MDEventWorkspace<MDE, nd>::sptr ws) { dbuff = ws->getBoxController()->getFileIO(); } - for (size_t i = 0; i < boxes.size(); i++) { - MDBox<MDE, nd> *box = dynamic_cast<MDBox<MDE, nd> *>(boxes[i]); + for (auto &boxe : boxes) { + MDBox<MDE, nd> *box = dynamic_cast<MDBox<MDE, nd> *>(boxe); if (box) { size_t ic(0); typename std::vector<MDE> &events = box->getEvents(); diff --git a/Framework/MDAlgorithms/src/FindPeaksMD.cpp b/Framework/MDAlgorithms/src/FindPeaksMD.cpp index 5f26a22c472e57a7aba84ff4b55a8bf8e5674d42..462d13073d2a06cfc02b80ea260e57f7cf9fdefe 100644 --- a/Framework/MDAlgorithms/src/FindPeaksMD.cpp +++ b/Framework/MDAlgorithms/src/FindPeaksMD.cpp @@ -341,13 +341,13 @@ void FindPeaksMD::findPeaks(typename MDEventWorkspace<MDE, nd>::sptr ws) { // Compare to all boxes already picked. bool badBox = false; - for (auto it3 = peakBoxes.begin(); it3 != peakBoxes.end(); it3++) { + for (auto &peakBoxe : peakBoxes) { #ifndef MDBOX_TRACK_CENTROID coord_t otherCenter[nd]; (*it3)->calculateCentroid(otherCenter); #else - const coord_t *otherCenter = (*it3)->getCentroid(); + const coord_t *otherCenter = peakBoxe->getCentroid(); #endif // Distance between this box and a box we already put in. @@ -386,9 +386,9 @@ void FindPeaksMD::findPeaks(typename MDEventWorkspace<MDE, nd>::sptr ws) { prog->resetNumSteps(numBoxesFound, 0.95, 1.0); // --- Convert the "boxes" to peaks ---- - for (auto it3 = peakBoxes.begin(); it3 != peakBoxes.end(); it3++) { + for (auto box : peakBoxes) { // The center of the box = Q in the lab frame - boxPtr box = *it3; + #ifndef MDBOX_TRACK_CENTROID coord_t boxCenter[nd]; box->calculateCentroid(boxCenter); @@ -515,8 +515,8 @@ void FindPeaksMD::findPeaksHisto( // Compare to all boxes already picked. bool badBox = false; - for (auto it3 = peakBoxes.begin(); it3 != peakBoxes.end(); ++it3) { - VMD otherCenter = ws->getCenter(*it3); + for (unsigned long &peakBoxe : peakBoxes) { + VMD otherCenter = ws->getCenter(peakBoxe); // Distance between this box and a box we already put in. coord_t distSquared = 0.0; @@ -549,8 +549,7 @@ void FindPeaksMD::findPeaksHisto( } } // --- Convert the "boxes" to peaks ---- - for (auto it3 = peakBoxes.begin(); it3 != peakBoxes.end(); ++it3) { - size_t index = *it3; + for (unsigned long index : peakBoxes) { // The center of the box = Q in the lab frame VMD boxCenter = ws->getCenter(index); diff --git a/Framework/MDAlgorithms/src/ImportMDHistoWorkspaceBase.cpp b/Framework/MDAlgorithms/src/ImportMDHistoWorkspaceBase.cpp index 84b71925e96cf0248b92685893a9841d741fc10f..6a396d4a3bc8d181917ae411212a1c4ea288c0b9 100644 --- a/Framework/MDAlgorithms/src/ImportMDHistoWorkspaceBase.cpp +++ b/Framework/MDAlgorithms/src/ImportMDHistoWorkspaceBase.cpp @@ -172,8 +172,8 @@ ImportMDHistoWorkspaceBase::validateInputs() { targetFrames.push_back(Mantid::Geometry::QSample::QSampleName); auto isValidFrame = true; - for (auto it = frames.begin(); it != frames.end(); ++it) { - auto result = checkIfFrameValid(*it, targetFrames); + for (auto &frame : frames) { + auto result = checkIfFrameValid(frame, targetFrames); if (!result) { isValidFrame = result; } @@ -200,9 +200,8 @@ ImportMDHistoWorkspaceBase::validateInputs() { */ bool ImportMDHistoWorkspaceBase::checkIfFrameValid( const std::string &frame, const std::vector<std::string> &targetFrames) { - for (auto targetFrame = targetFrames.begin(); - targetFrame != targetFrames.end(); ++targetFrame) { - if (*targetFrame == frame) { + for (const auto &targetFrame : targetFrames) { + if (targetFrame == frame) { return true; } } diff --git a/Framework/MDAlgorithms/src/Integrate3DEvents.cpp b/Framework/MDAlgorithms/src/Integrate3DEvents.cpp index 65fc845b427c643b931118c62249d706db20a4f0..18f1a13fec968156cce374f81bda3cf8975244b6 100644 --- a/Framework/MDAlgorithms/src/Integrate3DEvents.cpp +++ b/Framework/MDAlgorithms/src/Integrate3DEvents.cpp @@ -69,8 +69,8 @@ Integrate3DEvents::~Integrate3DEvents() {} */ void Integrate3DEvents::addEvents( std::vector<std::pair<double, V3D>> const &event_qs, bool hkl_integ) { - for (size_t i = 0; i < event_qs.size(); i++) { - addEvent(event_qs[i], hkl_integ); + for (const auto &event_q : event_qs) { + addEvent(event_q, hkl_integ); } } @@ -183,14 +183,14 @@ double Integrate3DEvents::numInEllipsoid( std::vector<std::pair<double, V3D>> const &events, std::vector<V3D> const &directions, std::vector<double> const &sizes) { double count = 0; - for (size_t i = 0; i < events.size(); i++) { + for (const auto &event : events) { double sum = 0; for (size_t k = 0; k < 3; k++) { - double comp = events[i].second.scalar_prod(directions[k]) / sizes[k]; + double comp = event.second.scalar_prod(directions[k]) / sizes[k]; sum += comp * comp; } if (sum <= 1) - count += events[i].first; + count += event.first; } return count; @@ -216,17 +216,17 @@ double Integrate3DEvents::numInEllipsoidBkg( std::vector<double> const &sizesIn) { double count = 0; std::vector<double> eventVec; - for (size_t i = 0; i < events.size(); i++) { + for (const auto &event : events) { double sum = 0; double sumIn = 0; for (size_t k = 0; k < 3; k++) { - double comp = events[i].second.scalar_prod(directions[k]) / sizes[k]; + double comp = event.second.scalar_prod(directions[k]) / sizes[k]; sum += comp * comp; - comp = events[i].second.scalar_prod(directions[k]) / sizesIn[k]; + comp = event.second.scalar_prod(directions[k]) / sizesIn[k]; sumIn += comp * comp; } if (sum <= 1 && sumIn >= 1) - eventVec.push_back(events[i].first); + eventVec.push_back(event.first); } std::sort(eventVec.begin(), eventVec.end()); // Remove top 1% of background @@ -272,8 +272,8 @@ void Integrate3DEvents::makeCovarianceMatrix( for (int row = 0; row < 3; row++) { for (int col = 0; col < 3; col++) { double sum = 0; - for (size_t i = 0; i < events.size(); i++) { - auto event = events[i].second; + for (const auto &i : events) { + auto event = i.second; if (event.norm() <= radius) { sum += event[row] * event[col]; } @@ -342,8 +342,8 @@ Integrate3DEvents::stdDev(std::vector<std::pair<double, V3D>> const &events, double stdev = 0; int count = 0; - for (size_t i = 0; i < events.size(); i++) { - auto event = events[i].second; + for (const auto &i : events) { + auto event = i.second; if (event.norm() <= radius) { double dot_prod = event.scalar_prod(direction); sum += dot_prod; @@ -588,10 +588,10 @@ double Integrate3DEvents::detectorQ(std::vector<Kernel::V3D> E1Vec, const Mantid::Kernel::V3D QLabFrame, std::vector<double> &r) { double quot = 1.0; - for (auto E1 = E1Vec.begin(); E1 != E1Vec.end(); ++E1) { + for (auto &E1 : E1Vec) { V3D distv = QLabFrame - - *E1 * (QLabFrame.scalar_prod( - *E1)); // distance to the trajectory as a vector + E1 * (QLabFrame.scalar_prod( + E1)); // distance to the trajectory as a vector double quot0 = distv.norm() / *(std::min_element(r.begin(), r.end())); if (quot0 < quot) { quot = quot0; diff --git a/Framework/MDAlgorithms/src/IntegrateEllipsoids.cpp b/Framework/MDAlgorithms/src/IntegrateEllipsoids.cpp index 13d8f8313c4f7e03e5c725674da63a3a0312dbdd..c0e703741c0d6fa8c7ce1ea629b1b19e88c2b389 100644 --- a/Framework/MDAlgorithms/src/IntegrateEllipsoids.cpp +++ b/Framework/MDAlgorithms/src/IntegrateEllipsoids.cpp @@ -89,8 +89,8 @@ void IntegrateEllipsoids::qListFromEventWS(Integrate3DEvents &integrator, const std::vector<WeightedEventNoTime> &raw_events = events.getWeightedEventsNoTime(); std::vector<std::pair<double, V3D>> qList; - for (auto event = raw_events.begin(); event != raw_events.end(); ++event) { - double val = unitConverter.convertUnits(event->tof()); + for (const auto &raw_event : raw_events) { + double val = unitConverter.convertUnits(raw_event.tof()); qConverter.calcMatrixCoord(val, locCoord, signal, errorSq); for (size_t dim = 0; dim < DIMS; ++dim) { buffer[dim] = locCoord[dim]; @@ -98,7 +98,7 @@ void IntegrateEllipsoids::qListFromEventWS(Integrate3DEvents &integrator, V3D qVec(buffer[0], buffer[1], buffer[2]); if (hkl_integ) qVec = UBinv * qVec; - qList.push_back(std::make_pair(event->m_weight, qVec)); + qList.push_back(std::make_pair(raw_event.m_weight, qVec)); } // end of loop over events in list PARALLEL_CRITICAL(addEvents) { integrator.addEvents(qList, hkl_integ); } @@ -596,8 +596,8 @@ void IntegrateEllipsoids::initTargetWSDescr(MatrixWorkspace_sptr &wksp) { void IntegrateEllipsoids::calculateE1(Geometry::Instrument_const_sptr inst) { std::vector<detid_t> detectorIDs = inst->getDetectorIDs(); - for (auto detID = detectorIDs.begin(); detID != detectorIDs.end(); ++detID) { - Mantid::Geometry::IDetector_const_sptr det = inst->getDetector(*detID); + for (int &detectorID : detectorIDs) { + Mantid::Geometry::IDetector_const_sptr det = inst->getDetector(detectorID); if (det->isMonitor()) continue; // skip monitor if (!det->isMasked()) diff --git a/Framework/MDAlgorithms/src/IntegrateMDHistoWorkspace.cpp b/Framework/MDAlgorithms/src/IntegrateMDHistoWorkspace.cpp index 0557a9a29dfe8e18cf489ac79eb7a7412cbd4eca..44c0a3995e2aff95cd71561b615c4deff87c35f5 100644 --- a/Framework/MDAlgorithms/src/IntegrateMDHistoWorkspace.cpp +++ b/Framework/MDAlgorithms/src/IntegrateMDHistoWorkspace.cpp @@ -355,11 +355,11 @@ void IntegrateMDHistoWorkspace::exec() { auto outIterators = outWS->createIterators(nThreads, NULL); PARALLEL_FOR_NO_WSP_CHECK() - for (int i = 0; i < int(outIterators.size()); ++i) { + for (auto &i : outIterators) { PARALLEL_START_INTERUPT_REGION boost::scoped_ptr<MDHistoWorkspaceIterator> outIterator( - dynamic_cast<MDHistoWorkspaceIterator *>(outIterators[i])); + dynamic_cast<MDHistoWorkspaceIterator *>(i)); if (!outIterator) { throw std::logic_error( @@ -408,8 +408,8 @@ void IntegrateMDHistoWorkspace::exec() { // calculated what the width vector would need to be. auto neighbourIndexes = inIterator->findNeighbourIndexesByWidth(widthVector); - for (size_t i = 0; i < neighbourIndexes.size(); ++i) { - inIterator->jumpTo(neighbourIndexes[i]); // Go to that neighbour + for (unsigned long neighbourIndexe : neighbourIndexes) { + inIterator->jumpTo(neighbourIndexe); // Go to that neighbour performWeightedSum(inIterator.get(), box, sumSignal, sumSQErrors, sumNEvents); } diff --git a/Framework/MDAlgorithms/src/IntegratePeaksMD2.cpp b/Framework/MDAlgorithms/src/IntegratePeaksMD2.cpp index e1f350b33d398f7d3a852930a9b3bcdebea4ca87..222db96ef57eddbc4816897fd0817cf8a2411725 100644 --- a/Framework/MDAlgorithms/src/IntegratePeaksMD2.cpp +++ b/Framework/MDAlgorithms/src/IntegratePeaksMD2.cpp @@ -678,8 +678,8 @@ void IntegratePeaksMD2::integrate(typename MDEventWorkspace<MDE, nd>::sptr ws) { void IntegratePeaksMD2::calculateE1(Geometry::Instrument_const_sptr inst) { std::vector<detid_t> detectorIDs = inst->getDetectorIDs(); - for (auto detID = detectorIDs.begin(); detID != detectorIDs.end(); ++detID) { - Mantid::Geometry::IDetector_const_sptr det = inst->getDetector(*detID); + for (int &detectorID : detectorIDs) { + Mantid::Geometry::IDetector_const_sptr det = inst->getDetector(detectorID); if (det->isMonitor()) continue; // skip monitor if (!det->isMasked()) @@ -705,10 +705,10 @@ void IntegratePeaksMD2::calculateE1(Geometry::Instrument_const_sptr inst) { */ bool IntegratePeaksMD2::detectorQ(Mantid::Kernel::V3D QLabFrame, double r) { - for (auto E1 = E1Vec.begin(); E1 != E1Vec.end(); ++E1) { + for (auto &E1 : E1Vec) { V3D distv = QLabFrame - - *E1 * (QLabFrame.scalar_prod( - *E1)); // distance to the trajectory as a vector + E1 * (QLabFrame.scalar_prod( + E1)); // distance to the trajectory as a vector if (distv.norm() < r) { return false; } diff --git a/Framework/MDAlgorithms/src/LoadILLAscii.cpp b/Framework/MDAlgorithms/src/LoadILLAscii.cpp index 8ae270173c9013be91b92dd7183e96a7b41bb3f5..1afa198c97a19561f2bbaf238925dbca3a63a35e 100644 --- a/Framework/MDAlgorithms/src/LoadILLAscii.cpp +++ b/Framework/MDAlgorithms/src/LoadILLAscii.cpp @@ -248,16 +248,16 @@ void LoadILLAscii::loadsDataIntoTheWS(API::MatrixWorkspace_sptr &thisWorkspace, thisWorkspace->dataX(0)[1] = m_wavelength + 0.001; size_t spec = 0; - for (size_t i = 0; i < thisSpectrum.size(); ++i) { + for (int i : thisSpectrum) { if (spec > 0) { // just copy the time binning axis to every spectra thisWorkspace->dataX(spec) = thisWorkspace->readX(0); } // Assign Y - thisWorkspace->dataY(spec)[0] = thisSpectrum[i]; + thisWorkspace->dataY(spec)[0] = i; // Assign Error - thisWorkspace->dataE(spec)[0] = thisSpectrum[i] * thisSpectrum[i]; + thisWorkspace->dataE(spec)[0] = i * i; ++spec; } diff --git a/Framework/MDAlgorithms/src/LoadILLAsciiHelper.cpp b/Framework/MDAlgorithms/src/LoadILLAsciiHelper.cpp index b42f1fe655f48dd622d13dc79fc4e6dfab8f1a4b..d2adb4c8f7440241d3de13416a081bd039d32411 100644 --- a/Framework/MDAlgorithms/src/LoadILLAsciiHelper.cpp +++ b/Framework/MDAlgorithms/src/LoadILLAsciiHelper.cpp @@ -302,8 +302,8 @@ void ILLParser::parseFieldNumeric(std::map<std::string, std::string> &header, for (int i = 0; i < nTextLines; i++) { std::getline(fin, line); std::vector<std::string> s = splitLineInFixedWithFields(line, fieldWith); - for (auto it = s.begin(); it != s.end(); ++it) { - keys[index] = *it; + for (auto &it : s) { + keys[index] = it; index += 1; } } @@ -314,8 +314,8 @@ void ILLParser::parseFieldNumeric(std::map<std::string, std::string> &header, std::getline(fin, line); std::vector<std::string> s = splitLineInFixedWithFields(line, fieldWith); pos += s.size(); - for (auto it = s.begin(); it != s.end(); ++it) { - values[index] = *it; + for (auto &it : s) { + values[index] = it; index += 1; } } @@ -346,9 +346,9 @@ std::vector<int> ILLParser::parseFieldISpec(int fieldWith) { std::getline(fin, line); std::vector<std::string> s = splitLineInFixedWithFields(line, fieldWith); nSpectraRead += static_cast<int>(s.size()); - for (auto it = s.begin(); it != s.end(); ++it) { + for (auto &it : s) { // sscanf is much faster than lexical_cast / erase_spaces - sscanf(it->c_str(), "%8d", &spectrumValues[index]); + sscanf(it.c_str(), "%8d", &spectrumValues[index]); index += 1; } } @@ -361,8 +361,8 @@ std::vector<int> ILLParser::parseFieldISpec(int fieldWith) { */ void ILLParser::showHeader() { std::cout << "* Global header" << '\n'; - for (auto it = header.begin(); it != header.end(); ++it) - std::cout << it->first << " => " << it->second << '\n'; + for (auto &it : header) + std::cout << it.first << " => " << it.second << '\n'; std::cout << "* Spectrum header" << '\n'; int i = 0; @@ -458,12 +458,12 @@ T ILLParser::getValue(const std::string &field, T ret = std::numeric_limits<T>::infinity(); - for (auto it = thisHeader.begin(); it != thisHeader.end(); ++it) { + for (const auto &it : thisHeader) { // std::cout << it->first << "=>" << it->second << '\n'; - std::size_t pos = it->first.find(field); + std::size_t pos = it.first.find(field); if (pos != std::string::npos) { // std::cout << "Found field: " << field << "=>" << it->second << '\n'; - ret = evaluate<T>(it->second); + ret = evaluate<T>(it.second); } } diff --git a/Framework/MDAlgorithms/src/LoadMD.cpp b/Framework/MDAlgorithms/src/LoadMD.cpp index 37726c4a957d9604d53fc96f044eccc8449f981e..15d9ea6129522e80b706611a7fd0434637f70984 100644 --- a/Framework/MDAlgorithms/src/LoadMD.cpp +++ b/Framework/MDAlgorithms/src/LoadMD.cpp @@ -666,10 +666,9 @@ void LoadMD::setMDFrameOnWorkspaceFromLegacyFile(API::IMDWorkspace_sptr ws) { // Set the MDFrames for each axes Algorithm_sptr setMDFrameAlg = this->createChildAlgorithm("SetMDFrame"); int axesCounter = 0; - for (auto frame = framesToSet.begin(); frame != framesToSet.end(); - ++frame) { + for (auto &frame : framesToSet) { setMDFrameAlg->setProperty("InputWorkspace", ws); - setMDFrameAlg->setProperty("MDFrame", *frame); + setMDFrameAlg->setProperty("MDFrame", frame); setMDFrameAlg->setProperty("Axes", std::vector<int>(1, axesCounter)); ++axesCounter; setMDFrameAlg->executeAsChildAlg(); @@ -680,9 +679,9 @@ void LoadMD::setMDFrameOnWorkspaceFromLegacyFile(API::IMDWorkspace_sptr ws) { // Revert to the old frames. Algorithm_sptr setMDFrameAlg = this->createChildAlgorithm("SetMDFrame"); int axesCounter = 0; - for (auto frame = oldFrames.begin(); frame != oldFrames.end(); ++frame) { + for (auto &oldFrame : oldFrames) { setMDFrameAlg->setProperty("InputWorkspace", ws); - setMDFrameAlg->setProperty("MDFrame", *frame); + setMDFrameAlg->setProperty("MDFrame", oldFrame); setMDFrameAlg->setProperty("Axes", std::vector<int>(1, axesCounter)); ++axesCounter; setMDFrameAlg->executeAsChildAlg(); diff --git a/Framework/MDAlgorithms/src/MDNormDirectSC.cpp b/Framework/MDAlgorithms/src/MDNormDirectSC.cpp index efc710413ea131fd80af16c803aac3de848021df..8d265e1b9cbc7afd1902b0e40d56b49aa8d43c93 100644 --- a/Framework/MDAlgorithms/src/MDNormDirectSC.cpp +++ b/Framework/MDAlgorithms/src/MDNormDirectSC.cpp @@ -212,9 +212,9 @@ std::string MDNormDirectSC::inputEnergyMode() const { // get dEAnalysisMode PropertyHistories histvec = hist.getAlgorithmHistory(nalgs - 2)->getProperties(); - for (auto it = histvec.begin(); it != histvec.end(); ++it) { - if ((*it)->name() == "dEAnalysisMode") { - emode = (*it)->value(); + for (auto &it : histvec) { + if (it->name() == "dEAnalysisMode") { + emode = it->value(); break; } } @@ -234,11 +234,11 @@ MDHistoWorkspace_sptr MDNormDirectSC::binInputWS() { const auto &props = getProperties(); IAlgorithm_sptr binMD = createChildAlgorithm("BinMD", 0.0, 0.3); binMD->setPropertyValue("AxisAligned", "1"); - for (auto it = props.begin(); it != props.end(); ++it) { - const auto &propName = (*it)->name(); + for (auto prop : props) { + const auto &propName = prop->name(); if (propName != "SolidAngleWorkspace" && propName != "OutputNormalizationWorkspace") { - binMD->setPropertyValue(propName, (*it)->value()); + binMD->setPropertyValue(propName, prop->value()); } } binMD->executeAsChildAlg(); @@ -552,8 +552,7 @@ MDNormDirectSC::removeGroupedIDs(const ExperimentInfo &exptInfo, // double to the correct size once std::set<detid_t> groupedIDs; - for (auto iter = detIDs.begin(); iter != detIDs.end(); ++iter) { - detid_t curID = *iter; + for (int curID : detIDs) { if (groupedIDs.count(curID) == 1) continue; // Already been processed diff --git a/Framework/MDAlgorithms/src/MDNormSCD.cpp b/Framework/MDAlgorithms/src/MDNormSCD.cpp index 665807725fa4ce720c79046990b032f45b559e0e..1a0986e0a1b3664a78232cc905183a4a81f995f2 100644 --- a/Framework/MDAlgorithms/src/MDNormSCD.cpp +++ b/Framework/MDAlgorithms/src/MDNormSCD.cpp @@ -183,9 +183,9 @@ std::string MDNormSCD::inputEnergyMode() const { // get dEAnalysisMode PropertyHistories histvec = hist.getAlgorithmHistory(nalgs - 2)->getProperties(); - for (auto it = histvec.begin(); it != histvec.end(); ++it) { - if ((*it)->name() == "dEAnalysisMode") { - emode = (*it)->value(); + for (auto &it : histvec) { + if (it->name() == "dEAnalysisMode") { + emode = it->value(); break; } } @@ -205,11 +205,11 @@ MDHistoWorkspace_sptr MDNormSCD::binInputWS() { const auto &props = getProperties(); IAlgorithm_sptr binMD = createChildAlgorithm("BinMD", 0.0, 0.3); binMD->setPropertyValue("AxisAligned", "1"); - for (auto it = props.begin(); it != props.end(); ++it) { - const auto &propName = (*it)->name(); + for (auto prop : props) { + const auto &propName = prop->name(); if (propName != "FluxWorkspace" && propName != "SolidAngleWorkspace" && propName != "OutputNormalizationWorkspace") { - binMD->setPropertyValue(propName, (*it)->value()); + binMD->setPropertyValue(propName, prop->value()); } } binMD->executeAsChildAlg(); @@ -588,8 +588,7 @@ MDNormSCD::removeGroupedIDs(const ExperimentInfo &exptInfo, // double to the correct size once std::set<detid_t> groupedIDs; - for (auto iter = detIDs.begin(); iter != detIDs.end(); ++iter) { - detid_t curID = *iter; + for (int curID : detIDs) { if (groupedIDs.count(curID) == 1) continue; // Already been processed diff --git a/Framework/MDAlgorithms/src/MergeMD.cpp b/Framework/MDAlgorithms/src/MergeMD.cpp index 5965871db3af61c45055b4aabcdbaa51e02b12de..feb8902f24e656aa0fde288509f1f7f211b6cb05 100644 --- a/Framework/MDAlgorithms/src/MergeMD.cpp +++ b/Framework/MDAlgorithms/src/MergeMD.cpp @@ -91,8 +91,8 @@ void MergeMD::createOutputWorkspace(std::vector<std::string> &inputs) { std::vector<coord_t> dimMax(numDims, -1e30f); // Validate each workspace - for (size_t i = 0; i < m_workspaces.size(); i++) { - IMDEventWorkspace_const_sptr ws = m_workspaces[i]; + for (auto &m_workspace : m_workspaces) { + IMDEventWorkspace_const_sptr ws = m_workspace; if (ws->getNumDims() != numDims) throw std::invalid_argument( "Workspace " + ws->name() + @@ -243,16 +243,15 @@ void MergeMD::exec() { // This will hold the inputs, with the groups separated off std::vector<std::string> inputs; - for (size_t i = 0; i < inputs_orig.size(); i++) { + for (const auto &i : inputs_orig) { WorkspaceGroup_sptr wsgroup = - AnalysisDataService::Instance().retrieveWS<WorkspaceGroup>( - inputs_orig[i]); + AnalysisDataService::Instance().retrieveWS<WorkspaceGroup>(i); if (wsgroup) { // Workspace group std::vector<std::string> group = wsgroup->getNames(); inputs.insert(inputs.end(), group.begin(), group.end()); } else { // Single workspace - inputs.push_back(inputs_orig[i]); + inputs.push_back(i); } } diff --git a/Framework/MDAlgorithms/src/MergeMDFiles.cpp b/Framework/MDAlgorithms/src/MergeMDFiles.cpp index 052b710d6aac8926929fa4a23ca54e3f739439a6..bddd71ac1268b6c30e97aa19ff817b67da5bd718 100644 --- a/Framework/MDAlgorithms/src/MergeMDFiles.cpp +++ b/Framework/MDAlgorithms/src/MergeMDFiles.cpp @@ -125,8 +125,7 @@ void MergeMDFiles::loadBoxData() { const std::vector<int> &boxType = m_BoxStruct.getBoxType(); // calculate event positions in the target file. uint64_t eventsStart = 0; - for (size_t i = 0; i < Boxes.size(); i++) { - API::IMDNode *mdBox = Boxes[i]; + for (auto mdBox : Boxes) { mdBox->clear(); size_t ID = mdBox->getID(); @@ -399,10 +398,10 @@ void MergeMDFiles::exec() { } /**Delete all event loaders */ void MergeMDFiles::clearEventLoaders() { - for (size_t i = 0; i < m_EventLoader.size(); i++) { - if (m_EventLoader[i]) { - delete m_EventLoader[i]; - m_EventLoader[i] = NULL; + for (auto &i : m_EventLoader) { + if (i) { + delete i; + i = NULL; } } } diff --git a/Framework/MDAlgorithms/src/MultiplyMD.cpp b/Framework/MDAlgorithms/src/MultiplyMD.cpp index c9352192194e4a1b8d52a1e4f07de47a4c152438..5689524bc8d6924bd2c2ecd672491a347ebab024 100644 --- a/Framework/MDAlgorithms/src/MultiplyMD.cpp +++ b/Framework/MDAlgorithms/src/MultiplyMD.cpp @@ -74,8 +74,8 @@ void MultiplyMD::execEventScalar(typename MDEventWorkspace<MDE, nd>::sptr ws) { dbuff = ws->getBoxController()->getFileIO(); } - for (size_t i = 0; i < boxes.size(); i++) { - MDBox<MDE, nd> *box = dynamic_cast<MDBox<MDE, nd> *>(boxes[i]); + for (auto &boxe : boxes) { + MDBox<MDE, nd> *box = dynamic_cast<MDBox<MDE, nd> *>(boxe); if (box) { typename std::vector<MDE> &events = box->getEvents(); size_t ic(events.size()); diff --git a/Framework/MDAlgorithms/src/Quantification/Models/MullerAnsatz.cpp b/Framework/MDAlgorithms/src/Quantification/Models/MullerAnsatz.cpp index 708ae56914c03ee9ad4938bfa320723d869616d1..76dc3d9b0f898b2967da4d323beb804a229829e1 100644 --- a/Framework/MDAlgorithms/src/Quantification/Models/MullerAnsatz.cpp +++ b/Framework/MDAlgorithms/src/Quantification/Models/MullerAnsatz.cpp @@ -51,8 +51,8 @@ void MullerAnsatz::init() { // setFormFactorIon("Cu2"); // Declare parameters that participate in fitting - for (unsigned int i = 0; i < AnsatzParameters::NPARAMS; ++i) { - declareParameter(AnsatzParameters::PAR_NAMES[i], 0.0); + for (auto &i : AnsatzParameters::PAR_NAMES) { + declareParameter(i, 0.0); } // Declare fixed attributes defaults diff --git a/Framework/MDAlgorithms/src/Quantification/Models/Strontium122.cpp b/Framework/MDAlgorithms/src/Quantification/Models/Strontium122.cpp index d613b2059c84197dbca84c2f6c78568f2de031cc..98e5bbcaa5c9cf59fd20a42c14fcce9e58ad218c 100644 --- a/Framework/MDAlgorithms/src/Quantification/Models/Strontium122.cpp +++ b/Framework/MDAlgorithms/src/Quantification/Models/Strontium122.cpp @@ -34,13 +34,13 @@ void Strontium122::init() { setFormFactorIon("Fe2"); // Declare parameters that participate in fitting - for (unsigned int i = 0; i < NPARAMS; ++i) { - declareParameter(PAR_NAMES[i], 0.0); + for (auto &i : PAR_NAMES) { + declareParameter(i, 0.0); } // Declare fixed attributes - for (unsigned int i = 0; i < NATTS; ++i) { - declareAttribute(ATTR_NAMES[i], API::IFunction::Attribute(1)); + for (auto &i : ATTR_NAMES) { + declareAttribute(i, API::IFunction::Attribute(1)); } } diff --git a/Framework/MDAlgorithms/src/Quantification/Resolution/TobyFitResolutionModel.cpp b/Framework/MDAlgorithms/src/Quantification/Resolution/TobyFitResolutionModel.cpp index 2e046ad19f749acd6bd68f0caca7028a4f4bcda8..744eb82235e6c70135423094dbc12c6c14df7243 100644 --- a/Framework/MDAlgorithms/src/Quantification/Resolution/TobyFitResolutionModel.cpp +++ b/Framework/MDAlgorithms/src/Quantification/Resolution/TobyFitResolutionModel.cpp @@ -268,8 +268,8 @@ void TobyFitResolutionModel::setAttribute( } else if (name == FOREGROUNDONLY_NAME) { m_foregroundOnly = (value.asInt() != 0); } else { - for (auto iter = m_yvector.begin(); iter != m_yvector.end(); ++iter) { - iter->setAttribute(name, value); + for (auto &iter : m_yvector) { + iter.setAttribute(name, value); } } } diff --git a/Framework/MDAlgorithms/src/Quantification/ResolutionConvolvedCrossSection.cpp b/Framework/MDAlgorithms/src/Quantification/ResolutionConvolvedCrossSection.cpp index dddeb6e4a76bb009a036ef7b0f824b5e10e82b12..d0d850e07eaf08e35732dbb740df5121b80d852b 100644 --- a/Framework/MDAlgorithms/src/Quantification/ResolutionConvolvedCrossSection.cpp +++ b/Framework/MDAlgorithms/src/Quantification/ResolutionConvolvedCrossSection.cpp @@ -142,8 +142,7 @@ void ResolutionConvolvedCrossSection::function( } CHECK_PARALLEL_EXCEPTIONS // Not standard macros. See top of file for reason - for (auto it = iterators.begin(); it != iterators.end(); ++it) { - API::IMDIterator *boxIterator = *it; + for (auto boxIterator : iterators) { delete boxIterator; } } @@ -302,8 +301,8 @@ void ResolutionConvolvedCrossSection::setupResolutionFunction( name, fgModelName, *this); // Pass on the attributes auto names = m_convolution->getAttributeNames(); - for (auto iter = names.begin(); iter != names.end(); ++iter) { - this->declareAttribute(*iter, m_convolution->getAttribute(*iter)); + for (auto &name : names) { + this->declareAttribute(name, m_convolution->getAttribute(name)); } // Pull the foreground parameters on to here const ForegroundModel &fgModel = m_convolution->foregroundModel(); @@ -315,8 +314,8 @@ void ResolutionConvolvedCrossSection::setupResolutionFunction( } // Pull the foreground attributes on to here names = fgModel.getAttributeNames(); - for (auto iter = names.begin(); iter != names.end(); ++iter) { - this->declareAttribute(*iter, fgModel.getAttribute(*iter)); + for (auto &name : names) { + this->declareAttribute(name, fgModel.getAttribute(name)); } } diff --git a/Framework/MDAlgorithms/src/QueryMDWorkspace.cpp b/Framework/MDAlgorithms/src/QueryMDWorkspace.cpp index 6d6f25d2aa3ccf6458d9cc302ff3a589158182a9..d8febfde23151ae93eaf7e49a7d6930110820239 100644 --- a/Framework/MDAlgorithms/src/QueryMDWorkspace.cpp +++ b/Framework/MDAlgorithms/src/QueryMDWorkspace.cpp @@ -148,8 +148,8 @@ void QueryMDWorkspace::getBoxData( std::vector<API::IMDNode *> boxes; ws->getBox()->getBoxes(boxes, depth, true); - for (size_t i = 0; i < boxes.size(); i++) { - MDBoxBase<MDE, nd> *box = dynamic_cast<MDBoxBase<MDE, nd> *>(boxes[i]); + for (auto &boxe : boxes) { + MDBoxBase<MDE, nd> *box = dynamic_cast<MDBoxBase<MDE, nd> *>(boxe); if (!box) throw(std::runtime_error("Can not cast IMDNode to any type of boxes")); size_t d = box->getDepth(); diff --git a/Framework/MDAlgorithms/src/ReplicateMD.cpp b/Framework/MDAlgorithms/src/ReplicateMD.cpp index 340f280f2be73d7d0c4505096f3067d8e57d3802..e83ee390befb9d8464791a33ecb90329591840ea 100644 --- a/Framework/MDAlgorithms/src/ReplicateMD.cpp +++ b/Framework/MDAlgorithms/src/ReplicateMD.cpp @@ -329,11 +329,11 @@ void ReplicateMD::exec() { auto iterators = outputWS->createIterators(nThreads, NULL); PARALLEL_FOR_NO_WSP_CHECK() - for (int it = 0; it < int(iterators.size()); ++it) { + for (auto &iterator : iterators) { PARALLEL_START_INTERUPT_REGION auto outIt = std::unique_ptr<MDHistoWorkspaceIterator>( - dynamic_cast<MDHistoWorkspaceIterator *>(iterators[it])); + dynamic_cast<MDHistoWorkspaceIterator *>(iterator)); // Iterate over the output workspace do { diff --git a/Framework/MDAlgorithms/src/SaveIsawQvector.cpp b/Framework/MDAlgorithms/src/SaveIsawQvector.cpp index eea9d5a7e2d466670e93338649da04d4df341de2..72b9775510f6cac426a4c6cf83c42efff554fd1f 100644 --- a/Framework/MDAlgorithms/src/SaveIsawQvector.cpp +++ b/Framework/MDAlgorithms/src/SaveIsawQvector.cpp @@ -126,8 +126,8 @@ void SaveIsawQvector::exec() { coord_map[2] = 1; } if (this->getProperty("RightHanded")) { - for (size_t dim = 0; dim < DIMS; ++dim) - coord_signs[dim] *= -1.; // everything changes sign + for (double &coord_sign : coord_signs) + coord_sign *= -1.; // everything changes sign } // units conersion helper @@ -165,8 +165,8 @@ void SaveIsawQvector::exec() { double signal(1.); // ignorable garbage double errorSq(1.); // ignorable garbage const std::vector<TofEvent> &raw_events = events.getEvents(); - for (auto event = raw_events.begin(); event != raw_events.end(); ++event) { - double val = unitConv.convertUnits(event->tof()); + for (const auto &raw_event : raw_events) { + double val = unitConv.convertUnits(raw_event.tof()); q_converter->calcMatrixCoord(val, locCoord, signal, errorSq); for (size_t dim = 0; dim < DIMS; ++dim) { buffer[dim] = diff --git a/Framework/MDAlgorithms/src/SaveMD.cpp b/Framework/MDAlgorithms/src/SaveMD.cpp index f6e809ee9b697e2bb483dc29951b14878aefed09..99c7be7b11bec29b4423440794a3749f776eb673 100644 --- a/Framework/MDAlgorithms/src/SaveMD.cpp +++ b/Framework/MDAlgorithms/src/SaveMD.cpp @@ -161,12 +161,12 @@ void SaveMD::doSaveEvents(typename MDEventWorkspace<MDE, nd>::sptr ws) { // saveable and that the boxes were not saved. BoxFlatStruct.setBoxesFilePositions(true); prog->resetNumSteps(boxes.size(), 0.06, 0.90); - for (size_t i = 0; i < boxes.size(); i++) { - auto saveableTag = boxes[i]->getISaveable(); + for (auto &boxe : boxes) { + auto saveableTag = boxe->getISaveable(); if (saveableTag) // only boxes can be saveable { // do not spend time on empty boxes - if (boxes[i]->getDataInMemorySize() == 0) + if (boxe->getDataInMemorySize() == 0) continue; // save boxes directly using the boxes file postion, precalculated in // boxFlatStructure. diff --git a/Framework/MDAlgorithms/src/SetMDFrame.cpp b/Framework/MDAlgorithms/src/SetMDFrame.cpp index df48ff24fee6bebe9fa8f818686d58552f5042e3..36d029847a0290d105e0b217cf21966dc5572bec 100644 --- a/Framework/MDAlgorithms/src/SetMDFrame.cpp +++ b/Framework/MDAlgorithms/src/SetMDFrame.cpp @@ -109,9 +109,9 @@ void SetMDFrame::exec() { return; } - for (auto index = axes.begin(); index != axes.end(); ++index) { + for (unsigned long &axe : axes) { // Get associated dimension - auto dimension = inputWorkspace->getDimension(*index); + auto dimension = inputWorkspace->getDimension(axe); // Provide a new MDFrame std::string frameSelection = getProperty(mdFrameSpecifier); @@ -150,8 +150,8 @@ std::map<std::string, std::string> SetMDFrame::validateInputs() { std::vector<int> axesInts = this->getProperty("Axes"); Kernel::MDAxisValidator axisChecker(axesInts, ws->getNumDims(), true); auto axisErrors = axisChecker.validate(); - for (auto iter = axisErrors.begin(); iter != axisErrors.end(); iter++) { - invalidProperties.insert(*iter); + for (auto &axisError : axisErrors) { + invalidProperties.insert(axisError); } return invalidProperties; diff --git a/Framework/MDAlgorithms/src/SliceMD.cpp b/Framework/MDAlgorithms/src/SliceMD.cpp index ae371f90a4f832269c7f7477923d27665df0bf6b..e2a4569ca2f590667e4d5c3b5be6d0f1244c461a 100644 --- a/Framework/MDAlgorithms/src/SliceMD.cpp +++ b/Framework/MDAlgorithms/src/SliceMD.cpp @@ -121,8 +121,8 @@ void SliceMD::slice(typename MDEventWorkspace<MDE, nd>::sptr ws) { // Create the ouput workspace typename MDEventWorkspace<OMDE, ond>::sptr outWS( new MDEventWorkspace<OMDE, ond>()); - for (size_t od = 0; od < m_binDimensions.size(); od++) { - outWS->addDimension(m_binDimensions[od]); + for (auto &m_binDimension : m_binDimensions) { + outWS->addDimension(m_binDimension); } outWS->setCoordinateSystem(ws->getSpecialCoordinateSystem()); outWS->initialize(); diff --git a/Framework/MDAlgorithms/src/SlicingAlgorithm.cpp b/Framework/MDAlgorithms/src/SlicingAlgorithm.cpp index f444e2555b3dd90dd3d2b722bb71a45411352e68..6b35162dfebbaf5c417e20b9fdedfb3de9d84b2c 100644 --- a/Framework/MDAlgorithms/src/SlicingAlgorithm.cpp +++ b/Framework/MDAlgorithms/src/SlicingAlgorithm.cpp @@ -275,9 +275,9 @@ void SlicingAlgorithm::processGeneralTransformProperties() { // Count the number of output dimensions m_outD = 0; std::string dimChars = this->getDimensionChars(); - for (size_t i = 0; i < dimChars.size(); i++) { + for (char dimChar : dimChars) { std::string propName = "BasisVector0"; - propName[11] = dimChars[i]; + propName[11] = dimChar; if (!Strings::strip(this->getPropertyValue(propName)).empty()) m_outD++; } @@ -306,9 +306,9 @@ void SlicingAlgorithm::processGeneralTransformProperties() { m_transformScaling.clear(); // Create the dimensions based on the strings from the user - for (size_t i = 0; i < dimChars.size(); i++) { + for (char dimChar : dimChars) { std::string propName = "BasisVector0"; - propName[11] = dimChars[i]; + propName[11] = dimChar; try { makeBasisVectorFromString(getPropertyValue(propName)); } catch (std::exception &e) { @@ -373,8 +373,8 @@ void SlicingAlgorithm::createGeneralTransform() { ortho.resize(m_bases.size(), VMD(3)); m_bases = ortho; g_log.information() << "Basis vectors forced to be orthogonal: "; - for (size_t i = 0; i < m_bases.size(); i++) - g_log.information() << m_bases[i].toString(",") << "; "; + for (auto &m_base : m_bases) + g_log.information() << m_base.toString(",") << "; "; g_log.information() << std::endl; } @@ -529,9 +529,9 @@ void SlicingAlgorithm::createAlignedTransform() { // Validate inputs bool previousWasEmpty = false; size_t numDims = 0; - for (size_t i = 0; i < dimChars.size(); i++) { + for (char dimChar : dimChars) { std::string propName = "AlignedDim0"; - propName[10] = dimChars[i]; + propName[10] = dimChar; std::string prop = Strings::strip(getPropertyValue(propName)); if (!prop.empty()) numDims++; @@ -947,11 +947,11 @@ SlicingAlgorithm::getGeneralImplicitFunction(const size_t *const chunkMin, // Last-resort, totally general case // 2*N planes defined by N basis vectors, in any dimensionality workspace. // Assumes orthogonality! - for (size_t i = 0; i < bases.size(); i++) { + for (auto &base : bases) { // For each basis vector, make two planes, perpendicular to it and facing // inwards - func->addPlane(MDPlane(bases[i], o1)); - func->addPlane(MDPlane(bases[i] * -1.0, o2)); + func->addPlane(MDPlane(base, o1)); + func->addPlane(MDPlane(base * -1.0, o2)); } } @@ -1080,9 +1080,8 @@ SlicingAlgorithm::extractMDFrameForNonAxisAligned( const auto &referenceMDFrame = m_inWS->getDimension(indicesWithProjection[0])->getMDFrame(); - for (auto it = indicesWithProjection.begin(); - it != indicesWithProjection.end(); ++it) { - const auto &toCheckMDFrame = m_inWS->getDimension(*it)->getMDFrame(); + for (unsigned long &it : indicesWithProjection) { + const auto &toCheckMDFrame = m_inWS->getDimension(it)->getMDFrame(); if (!referenceMDFrame.isSameType(toCheckMDFrame)) { g_log.warning() << "Slicing Algorithm: New basis vector tries to " "mix un-mixable MDFrame types."; diff --git a/Framework/MDAlgorithms/src/SmoothMD.cpp b/Framework/MDAlgorithms/src/SmoothMD.cpp index 72243e086fd5a54ed67000d57740ccc6d2bf5ce2..24e570e7d81d6435fd62dbc95f5f0f8688aefb32 100644 --- a/Framework/MDAlgorithms/src/SmoothMD.cpp +++ b/Framework/MDAlgorithms/src/SmoothMD.cpp @@ -129,11 +129,11 @@ SmoothMD::hatSmooth(IMDHistoWorkspace_const_sptr toSmooth, auto iterators = toSmooth->createIterators(nThreads, NULL); PARALLEL_FOR_NO_WSP_CHECK() - for (int it = 0; it < int(iterators.size()); ++it) { + for (auto &it : iterators) { PARALLEL_START_INTERUPT_REGION boost::scoped_ptr<MDHistoWorkspaceIterator> iterator( - dynamic_cast<MDHistoWorkspaceIterator *>(iterators[it])); + dynamic_cast<MDHistoWorkspaceIterator *>(it)); if (!iterator) { throw std::logic_error( @@ -165,16 +165,16 @@ SmoothMD::hatSmooth(IMDHistoWorkspace_const_sptr toSmooth, size_t nNeighbours = neighbourIndexes.size(); double sumSignal = iterator->getSignal(); double sumSqError = iterator->getError(); - for (size_t i = 0; i < neighbourIndexes.size(); ++i) { + for (unsigned long neighbourIndexe : neighbourIndexes) { if (useWeights) { - if ((*weightingWS)->getSignalAt(neighbourIndexes[i]) == 0) { + if ((*weightingWS)->getSignalAt(neighbourIndexe) == 0) { // Nothing measured here. We cannot use that neighbouring point. nNeighbours -= 1; continue; } } - sumSignal += toSmooth->getSignalAt(neighbourIndexes[i]); - double error = toSmooth->getErrorAt(neighbourIndexes[i]); + sumSignal += toSmooth->getSignalAt(neighbourIndexe); + double error = toSmooth->getErrorAt(neighbourIndexe); sumSqError += (error * error); } @@ -293,8 +293,7 @@ std::map<std::string, std::string> SmoothMD::validateInputs() { "have entries for each dimension of the " "InputWorkspace.")); } else { - for (auto it = widthVector.begin(); it != widthVector.end(); ++it) { - const int widthEntry = *it; + for (int widthEntry : widthVector) { if (widthEntry % 2 == 0) { std::stringstream message; message << widthVectorPropertyName diff --git a/Framework/MDAlgorithms/src/TransformMD.cpp b/Framework/MDAlgorithms/src/TransformMD.cpp index cb4f2fed3ff3ca4ade2b2639d73b3b212f29d05d..e92f0eaea6a825adeefa751a99e6ac7cacfbd686 100644 --- a/Framework/MDAlgorithms/src/TransformMD.cpp +++ b/Framework/MDAlgorithms/src/TransformMD.cpp @@ -81,9 +81,9 @@ void TransformMD::doTransform( API::IMDNode::sortObjByID(boxes); PARALLEL_FOR_IF(!ws->isFileBacked()) - for (int i = 0; i < int(boxes.size()); i++) { + for (auto &boxe : boxes) { PARALLEL_START_INTERUPT_REGION - MDBoxBase<MDE, nd> *box = dynamic_cast<MDBoxBase<MDE, nd> *>(boxes[i]); + MDBoxBase<MDE, nd> *box = dynamic_cast<MDBoxBase<MDE, nd> *>(boxe); if (box) { box->transformDimensions(m_scaling, m_offset); } diff --git a/Framework/MDAlgorithms/src/TransposeMD.cpp b/Framework/MDAlgorithms/src/TransposeMD.cpp index 0a2f355fdd10dbdf517d93e1d9fe24227b500bed..598fb2c31cfe34bb17debeaea64b2bfd2ad471be 100644 --- a/Framework/MDAlgorithms/src/TransposeMD.cpp +++ b/Framework/MDAlgorithms/src/TransposeMD.cpp @@ -138,10 +138,10 @@ void TransposeMD::exec() { auto iterators = inWS->createIterators(nThreads, NULL); PARALLEL_FOR_NO_WSP_CHECK() - for (int it = 0; it < int(iterators.size()); ++it) { + for (auto &iterator : iterators) { PARALLEL_START_INTERUPT_REGION - auto inIterator = std::unique_ptr<IMDIterator>(iterators[it]); + auto inIterator = std::unique_ptr<IMDIterator>(iterator); do { auto center = inIterator->getCenter(); const coord_t *incoords = center.getBareArray(); diff --git a/Framework/MDAlgorithms/src/UnaryOperationMD.cpp b/Framework/MDAlgorithms/src/UnaryOperationMD.cpp index cf04da6df00755ce518c61ba897fcb95e827d910..1f0e786d9549d7f73335ebe85458824227303481 100644 --- a/Framework/MDAlgorithms/src/UnaryOperationMD.cpp +++ b/Framework/MDAlgorithms/src/UnaryOperationMD.cpp @@ -69,8 +69,7 @@ void UnaryOperationMD::exec() { IAlgorithm_sptr alg = this->createChildAlgorithm(matrixAlg); // Copy all properties from THIS to the non-MD version std::vector<Property *> props = this->getProperties(); - for (size_t i = 0; i < props.size(); i++) { - Property *prop = props[i]; + for (auto prop : props) { alg->setPropertyValue(prop->name(), prop->value()); } alg->execute(); diff --git a/Framework/RemoteJobManagers/src/LSFJobManager.cpp b/Framework/RemoteJobManagers/src/LSFJobManager.cpp index b878a20fb342d556a3623b05cf77e3674d90230a..8023c30387e02659da91237c8e2e8082f6ee9550 100644 --- a/Framework/RemoteJobManagers/src/LSFJobManager.cpp +++ b/Framework/RemoteJobManagers/src/LSFJobManager.cpp @@ -460,8 +460,8 @@ void LSFJobManager::stopRemoteTransaction(const std::string &transactionID) { it->second.stopped = true; std::vector<std::string> jobs = it->second.jobIDs; - for (size_t i = 0; i < jobs.size(); i++) { - abortRemoteJob(jobs[i]); + for (auto &job : jobs) { + abortRemoteJob(job); } g_transactions.erase(it); } @@ -1223,8 +1223,8 @@ void LSFJobManager::getAllJobFiles(const std::string &jobId, while (std::getline(ss, PACname, ';')) { filePACNames.push_back(PACname); } - for (size_t i = 0; i < filePACNames.size(); i++) { - getOneJobFile(jobId, filePACNames[i], localDir, t); + for (auto &filePACName : filePACNames) { + getOneJobFile(jobId, filePACName, localDir, t); } } } else { diff --git a/Framework/RemoteJobManagers/src/MantidWebServiceAPIJobManager.cpp b/Framework/RemoteJobManagers/src/MantidWebServiceAPIJobManager.cpp index 5697870ce5ed1d68392273edd513b66d5ecdfb40..e0c6e0750c21e555dd880b0abb87fbfc060792f0 100644 --- a/Framework/RemoteJobManagers/src/MantidWebServiceAPIJobManager.cpp +++ b/Framework/RemoteJobManagers/src/MantidWebServiceAPIJobManager.cpp @@ -255,8 +255,8 @@ std::vector<std::string> MantidWebServiceAPIJobManager::queryRemoteFile( JSONArray files; std::string oneFile; resp["Files"].getValue(files); - for (unsigned int i = 0; i < files.size(); i++) { - files[i].getValue(oneFile); + for (auto &file : files) { + file.getValue(oneFile); filenames.push_back(oneFile); } diff --git a/Framework/RemoteJobManagers/src/SCARFLSFJobManager.cpp b/Framework/RemoteJobManagers/src/SCARFLSFJobManager.cpp index 3d9f32c924bbb7ff790410a24f9efabd0e39fce5..8e5eb561d93cac862c454d4d0d7a6051dce60296 100644 --- a/Framework/RemoteJobManagers/src/SCARFLSFJobManager.cpp +++ b/Framework/RemoteJobManagers/src/SCARFLSFJobManager.cpp @@ -224,8 +224,7 @@ std::string SCARFLSFJobManager::urlComponentEncode(const std::string &in) { out.fill('0'); out << std::hex; - for (std::string::const_iterator i = in.begin(), n = in.end(); i != n; ++i) { - std::string::value_type c = (*i); + for (char c : in) { // unreserved characters go through, where: // unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~" if (isalnum(c) || c == '-' || c == '_' || c == '.' || c == '~') { diff --git a/Framework/SINQ/src/PoldiAnalyseResiduals.cpp b/Framework/SINQ/src/PoldiAnalyseResiduals.cpp index cd9b37b2e687c9f63c372b4a7c02e6516c4f850d..06d7ccb3a0c3ff17912f7bca61c1147a86948ae6 100644 --- a/Framework/SINQ/src/PoldiAnalyseResiduals.cpp +++ b/Framework/SINQ/src/PoldiAnalyseResiduals.cpp @@ -53,8 +53,8 @@ double PoldiAnalyseResiduals::sumCounts( const DataObjects::Workspace2D_sptr &workspace, const std::vector<int> &workspaceIndices) const { double sum = 0.0; - for (size_t i = 0; i < workspaceIndices.size(); ++i) { - const MantidVec &counts = workspace->readY(workspaceIndices[i]); + for (int workspaceIndice : workspaceIndices) { + const MantidVec &counts = workspace->readY(workspaceIndice); sum += std::accumulate(counts.begin(), counts.end(), 0.0); } @@ -67,8 +67,8 @@ size_t PoldiAnalyseResiduals::numberOfPoints( const DataObjects::Workspace2D_sptr &workspace, const std::vector<int> &workspaceIndices) const { size_t sum = 0; - for (size_t i = 0; i < workspaceIndices.size(); ++i) { - const MantidVec &counts = workspace->readY(workspaceIndices[i]); + for (int workspaceIndice : workspaceIndices) { + const MantidVec &counts = workspace->readY(workspaceIndice); sum += counts.size(); } @@ -80,10 +80,10 @@ size_t PoldiAnalyseResiduals::numberOfPoints( void PoldiAnalyseResiduals::addValue( DataObjects::Workspace2D_sptr &workspace, double value, const std::vector<int> &workspaceIndices) const { - for (size_t i = 0; i < workspaceIndices.size(); ++i) { - MantidVec &counts = workspace->dataY(workspaceIndices[i]); - for (size_t j = 0; j < counts.size(); ++j) { - counts[j] += value; + for (int workspaceIndice : workspaceIndices) { + MantidVec &counts = workspace->dataY(workspaceIndice); + for (double &count : counts) { + count += value; } } } @@ -196,8 +196,8 @@ double PoldiAnalyseResiduals::relativeCountChange( const DataObjects::Workspace2D_sptr &sum, double totalMeasuredCounts) { const MantidVec &corrCounts = sum->readY(0); double csum = 0.0; - for (auto it = corrCounts.begin(); it != corrCounts.end(); ++it) { - csum += fabs(*it); + for (double corrCount : corrCounts) { + csum += fabs(corrCount); } return csum / totalMeasuredCounts * 100.0; diff --git a/Framework/SINQ/src/PoldiAutoCorrelation5.cpp b/Framework/SINQ/src/PoldiAutoCorrelation5.cpp index 19268cd7d020a1615891a1f48cae15cb119579bb..ea0e03f729ea6f549a314babf785f00a4abc6a96 100644 --- a/Framework/SINQ/src/PoldiAutoCorrelation5.cpp +++ b/Framework/SINQ/src/PoldiAutoCorrelation5.cpp @@ -153,8 +153,8 @@ void PoldiAutoCorrelation5::logConfigurationInformation( g_log.information() << "_Poldi - Number of dead wires: " << deadWires.size() << std::endl; g_log.information() << "_Poldi - Wire indices: "; - for (auto dw = deadWires.cbegin(); dw != deadWires.cend(); ++dw) { - g_log.information() << *dw << " "; + for (value_type deadWire : deadWires) { + g_log.information() << deadWire << " "; } g_log.information() << std::endl; } diff --git a/Framework/SINQ/src/PoldiFitPeaks1D2.cpp b/Framework/SINQ/src/PoldiFitPeaks1D2.cpp index f5f89dcb7ad90eaa1b1b9be280bd1612a47479c8..421338f044b7b79449b08a563e8641e7e6f05e5a 100644 --- a/Framework/SINQ/src/PoldiFitPeaks1D2.cpp +++ b/Framework/SINQ/src/PoldiFitPeaks1D2.cpp @@ -231,8 +231,8 @@ PoldiFitPeaks1D2::getRangeProfile(const RefinedRange_sptr &range, int n) const { totalProfile->initialize(); std::vector<PoldiPeak_sptr> peaks = range->getPeaks(); - for (auto it = peaks.begin(); it != peaks.end(); ++it) { - totalProfile->addFunction(getPeakProfile(*it)); + for (auto &peak : peaks) { + totalProfile->addFunction(getPeakProfile(peak)); } totalProfile->addFunction(FunctionFactory::Instance().createInitialized( @@ -288,8 +288,7 @@ PoldiFitPeaks1D2::fitPeaks(const PoldiPeakCollection_sptr &peaks) { Workspace2D_sptr dataWorkspace = getProperty("InputWorkspace"); m_fitplots->removeAll(); - for (size_t i = 0; i < reducedRanges.size(); ++i) { - RefinedRange_sptr currentRange = reducedRanges[i]; + for (auto currentRange : reducedRanges) { int nMin = getBestChebyshevPolynomialDegree(dataWorkspace, currentRange); if (nMin > -1) { diff --git a/Framework/SINQ/src/PoldiFitPeaks2D.cpp b/Framework/SINQ/src/PoldiFitPeaks2D.cpp index 4da20abea08a71634ecedcaa74a59d80ac31c884..42d4ebe9bfea03addf787e152ba6a434ebe8e001 100644 --- a/Framework/SINQ/src/PoldiFitPeaks2D.cpp +++ b/Framework/SINQ/src/PoldiFitPeaks2D.cpp @@ -160,10 +160,10 @@ PoldiFitPeaks2D::getNormalizedPeakCollections( std::vector<PoldiPeakCollection_sptr> normalizedPeakCollections; - for (auto pc = peakCollections.begin(); pc != peakCollections.end(); ++pc) { + for (const auto &peakCollection : peakCollections) { // First integrate peak collection, then normalize and append to vector PoldiPeakCollection_sptr integratedPeakCollection = - getIntegratedPeakCollection(*pc); + getIntegratedPeakCollection(peakCollection); normalizedPeakCollections.push_back( getNormalizedPeakCollection(integratedPeakCollection)); @@ -671,21 +671,20 @@ PoldiFitPeaks2D::getUserSpecifiedTies(const IFunction_sptr &poldiFn) { std::vector<std::string> parameters = poldiFn->getParameterNames(); std::vector<std::string> tieComponents; - for (auto it = tieParameters.begin(); it != tieParameters.end(); ++it) { - if (!(*it).empty()) { + for (auto &tieParameter : tieParameters) { + if (!tieParameter.empty()) { std::vector<std::string> matchedParameters; - for (auto parName = parameters.begin(); parName != parameters.end(); - ++parName) { - if (boost::algorithm::ends_with(*parName, *it)) { - matchedParameters.push_back(*parName); + for (auto ¶meter : parameters) { + if (boost::algorithm::ends_with(parameter, tieParameter)) { + matchedParameters.push_back(parameter); } } switch (matchedParameters.size()) { case 0: - g_log.warning("Function does not have a parameter called '" + *it + - "', ignoring."); + g_log.warning("Function does not have a parameter called '" + + tieParameter + "', ignoring."); break; case 1: g_log.warning("There is only one peak, no ties necessary."); @@ -983,9 +982,9 @@ IAlgorithm_sptr PoldiFitPeaks2D::calculateSpectrum( Poldi2DFunction_sptr mdFunction(new Poldi2DFunction); // Add one Poldi2DFunction for each peak collection - for (auto pc = normalizedPeakCollections.begin(); - pc != normalizedPeakCollections.end(); ++pc) { - mdFunction->addFunction(getFunctionFromPeakCollection(*pc)); + for (auto &normalizedPeakCollection : normalizedPeakCollections) { + mdFunction->addFunction( + getFunctionFromPeakCollection(normalizedPeakCollection)); } // And finally background terms @@ -1267,8 +1266,8 @@ void PoldiFitPeaks2D::exec() { Property *profileFunctionProperty = getPointerToProperty("PeakProfileFunction"); if (!profileFunctionProperty->isDefault()) { - for (auto pc = peakCollections.begin(); pc != peakCollections.end(); ++pc) { - (*pc)->setProfileFunctionName(profileFunctionProperty->value()); + for (auto &peakCollection : peakCollections) { + peakCollection->setProfileFunctionName(profileFunctionProperty->value()); } } @@ -1299,8 +1298,8 @@ void PoldiFitPeaks2D::exec() { } else { WorkspaceGroup_sptr peaksGroup = boost::make_shared<WorkspaceGroup>(); - for (auto pc = integralPeaks.begin(); pc != integralPeaks.end(); ++pc) { - peaksGroup->addWorkspace((*pc)->asTableWorkspace()); + for (auto &integralPeak : integralPeaks) { + peaksGroup->addWorkspace(integralPeak->asTableWorkspace()); } setProperty("RefinedPoldiPeakWorkspace", peaksGroup); @@ -1333,8 +1332,8 @@ void PoldiFitPeaks2D::exec() { } else { WorkspaceGroup_sptr cellsGroup = boost::make_shared<WorkspaceGroup>(); - for (auto it = cells.begin(); it != cells.end(); ++it) { - cellsGroup->addWorkspace(*it); + for (auto &cell : cells) { + cellsGroup->addWorkspace(cell); } setProperty("RefinedCellParameters", cellsGroup); diff --git a/Framework/SINQ/src/PoldiIndexKnownCompounds.cpp b/Framework/SINQ/src/PoldiIndexKnownCompounds.cpp index 1622defb7487a3a865b0abd7f8badde466c7688b..324505a5acc0c2f4870ae0e2af79cb57cb5bbb49 100644 --- a/Framework/SINQ/src/PoldiIndexKnownCompounds.cpp +++ b/Framework/SINQ/src/PoldiIndexKnownCompounds.cpp @@ -163,11 +163,11 @@ void PoldiIndexKnownCompounds::initializeIndexedPeaks( m_indexedPeaks.clear(); - for (size_t i = 0; i < expectedPhases.size(); ++i) { + for (const auto &expectedPhase : expectedPhases) { PoldiPeakCollection_sptr newCollection = boost::make_shared<PoldiPeakCollection>( m_measuredPeaks->intensityType()); - newCollection->setPointGroup(expectedPhases[i]->pointGroup()); + newCollection->setPointGroup(expectedPhase->pointGroup()); newCollection->setProfileFunctionName( m_measuredPeaks->getProfileFunctionName()); @@ -200,10 +200,10 @@ std::vector<Workspace_sptr> PoldiIndexKnownCompounds::getWorkspaces( const std::vector<std::string> &workspaceNames) const { std::vector<Workspace_sptr> workspaces; - for (auto it = workspaceNames.begin(); it != workspaceNames.end(); ++it) { + for (const auto &workspaceName : workspaceNames) { try { Workspace_sptr currentWorkspace = - AnalysisDataService::Instance().retrieveWS<Workspace>(*it); + AnalysisDataService::Instance().retrieveWS<Workspace>(workspaceName); WorkspaceGroup_sptr groupTest = boost::dynamic_pointer_cast<WorkspaceGroup>(currentWorkspace); @@ -231,9 +231,9 @@ std::vector<PoldiPeakCollection_sptr> PoldiIndexKnownCompounds::getPeakCollections( const std::vector<Workspace_sptr> &workspaces) const { std::vector<PoldiPeakCollection_sptr> peakCollections; - for (auto it = workspaces.begin(); it != workspaces.end(); ++it) { + for (const auto &workspace : workspaces) { TableWorkspace_sptr tableWs = - boost::dynamic_pointer_cast<TableWorkspace>(*it); + boost::dynamic_pointer_cast<TableWorkspace>(workspace); if (!tableWs) { throw std::invalid_argument( @@ -251,8 +251,8 @@ std::vector<std::string> PoldiIndexKnownCompounds::getWorkspaceNames( const std::vector<Workspace_sptr> &workspaces) const { std::vector<std::string> names; - for (auto it = workspaces.begin(); it != workspaces.end(); ++it) { - names.push_back((*it)->getName()); + for (const auto &workspace : workspaces) { + names.push_back(workspace->getName()); } return names; @@ -333,12 +333,12 @@ std::vector<double> PoldiIndexKnownCompounds::getNormalizedContributions( } std::vector<double> normalizedContributions; - for (auto it = contributions.begin(); it != contributions.end(); ++it) { - if (*it < 0.0) { + for (double contribution : contributions) { + if (contribution < 0.0) { throw std::invalid_argument("Contributions less than 0 are not allowed."); } - normalizedContributions.push_back(*it / sum); + normalizedContributions.push_back(contribution / sum); } return normalizedContributions; @@ -394,9 +394,9 @@ void PoldiIndexKnownCompounds::scaleToExperimentalValues( double maximumExperimentalIntensity = getMaximumIntensity(measuredPeaks); double maximumCalculatedIntensity = 0.0; - for (auto it = peakCollections.begin(); it != peakCollections.end(); ++it) { - maximumCalculatedIntensity = - std::max(getMaximumIntensity(*it), maximumCalculatedIntensity); + for (const auto &peakCollection : peakCollections) { + maximumCalculatedIntensity = std::max(getMaximumIntensity(peakCollection), + maximumCalculatedIntensity); } scaleIntensityEstimates(peakCollections, @@ -705,9 +705,8 @@ void PoldiIndexKnownCompounds::assignCandidates( * inserted into the * peak collection that holds unindexed peaks. */ - for (auto it = unassignedMeasuredPeaks.begin(); - it != unassignedMeasuredPeaks.end(); ++it) { - collectUnindexedPeak(*it); + for (const auto &unassignedMeasuredPeak : unassignedMeasuredPeaks) { + collectUnindexedPeak(unassignedMeasuredPeak); } } @@ -738,8 +737,8 @@ PoldiIndexKnownCompounds::getIntensitySortedPeakCollection( PoldiPeakCollection_sptr sortedPeaks = boost::make_shared<PoldiPeakCollection>(peaks->intensityType()); - for (size_t i = 0; i < peakVector.size(); ++i) { - sortedPeaks->addPeak(peakVector[i]->clone()); + for (auto &i : peakVector) { + sortedPeaks->addPeak(i->clone()); } return sortedPeaks; diff --git a/Framework/SINQ/src/PoldiUtilities/PoldiAutoCorrelationCore.cpp b/Framework/SINQ/src/PoldiUtilities/PoldiAutoCorrelationCore.cpp index fbc92a1f93d215150e4d9bbad871d86e3a8ea156..5fff9cad421dfc1c253d5a57e7d67e11249b4789 100644 --- a/Framework/SINQ/src/PoldiUtilities/PoldiAutoCorrelationCore.cpp +++ b/Framework/SINQ/src/PoldiUtilities/PoldiAutoCorrelationCore.cpp @@ -267,9 +267,8 @@ std::vector<double> PoldiAutoCorrelationCore::calculateDWeights( std::vector<double> tofs; tofs.reserve(tofsFor1Angstrom.size()); - for (auto tofFor1Angstrom = tofsFor1Angstrom.cbegin(); - tofFor1Angstrom != tofsFor1Angstrom.cend(); ++tofFor1Angstrom) { - tofs.push_back(*tofFor1Angstrom * deltaD); + for (double tofFor1Angstrom : tofsFor1Angstrom) { + tofs.push_back(tofFor1Angstrom * deltaD); } double sum = std::accumulate(tofs.begin(), tofs.end(), 0.0); @@ -301,8 +300,7 @@ PoldiAutoCorrelationCore::getRawCorrelatedIntensity(double dValue, std::vector<UncertainValue> current; current.reserve(m_chopper->slitTimes().size()); - for (auto slitOffset = m_chopper->slitTimes().cbegin(); - slitOffset != m_chopper->slitTimes().cend(); ++slitOffset) { + for (double slitOffset : m_chopper->slitTimes()) { /* For each offset, the sum of correlation intensity and error (for each * detector element) * is computed from the counts in the space/time location possible for @@ -314,7 +312,7 @@ PoldiAutoCorrelationCore::getRawCorrelatedIntensity(double dValue, std::vector<UncertainValue> cmess(m_detector->elementCount()); std::transform(m_indices.begin(), m_indices.end(), cmess.begin(), boost::bind(&PoldiAutoCorrelationCore::getCMessAndCSigma, - this, dValue, *slitOffset, _1)); + this, dValue, slitOffset, _1)); UncertainValue sum = std::accumulate(cmess.begin(), cmess.end(), UncertainValue(0.0, 0.0), @@ -574,10 +572,9 @@ PoldiAutoCorrelationCore::getDistances(const std::vector<int> &elements) const { std::vector<double> distances; distances.reserve(elements.size()); - for (auto element = elements.cbegin(); element != elements.cend(); - ++element) { + for (int element : elements) { distances.push_back(chopperDistance + - m_detector->distanceFromSample(*element)); + m_detector->distanceFromSample(element)); } return distances; @@ -684,9 +681,8 @@ double PoldiAutoCorrelationCore::getSumOfCounts( double sum = 0.0; for (int t = 0; t < timeBinCount; ++t) { - for (auto e = detectorElements.cbegin(); e != detectorElements.cend(); - ++e) { - sum += getCounts(*e, t); + for (int detectorElement : detectorElements) { + sum += getCounts(detectorElement, t); } } diff --git a/Framework/SINQ/src/PoldiUtilities/PoldiPeakCollection.cpp b/Framework/SINQ/src/PoldiUtilities/PoldiPeakCollection.cpp index 46ecefa2b6090f3c444b84eb3f9774b7a73c43d8..e8004237d91a582ba1aa1607810479762ab298b7 100644 --- a/Framework/SINQ/src/PoldiUtilities/PoldiPeakCollection.cpp +++ b/Framework/SINQ/src/PoldiUtilities/PoldiPeakCollection.cpp @@ -60,8 +60,8 @@ PoldiPeakCollection_sptr PoldiPeakCollection::clone() { clone->setPointGroup(m_pointGroup); clone->setUnitCell(m_unitCell); - for (size_t i = 0; i < m_peaks.size(); ++i) { - clone->addPeak(m_peaks[i]->clone()); + for (auto &m_peak : m_peaks) { + clone->addPeak(m_peak->clone()); } return clone; diff --git a/Framework/SINQ/src/PoldiUtilities/PoldiResidualCorrelationCore.cpp b/Framework/SINQ/src/PoldiUtilities/PoldiResidualCorrelationCore.cpp index 665b2f1eefa67af58661bb36d0e4c8d86b5c6904..02a0419f7e10dfdffb90fee11f0a10ef75e07194 100644 --- a/Framework/SINQ/src/PoldiUtilities/PoldiResidualCorrelationCore.cpp +++ b/Framework/SINQ/src/PoldiUtilities/PoldiResidualCorrelationCore.cpp @@ -85,9 +85,8 @@ void PoldiResidualCorrelationCore::distributeCorrelationCounts( double deltaForD = -dInt / m_weightsForD[i] / static_cast<double>(chopperSlits.size()); - for (auto offset = chopperSlits.begin(); offset != chopperSlits.end(); - ++offset) { - CountLocator locator = getCountLocator(d, *offset, m_indices[k]); + for (double chopperSlit : chopperSlits) { + CountLocator locator = getCountLocator(d, chopperSlit, m_indices[k]); int indexDifference = locator.icmax - locator.icmin; @@ -135,8 +134,7 @@ void PoldiResidualCorrelationCore::correctCountData() const { double ratio = sumOfResiduals / numberOfCells; PARALLEL_FOR_NO_WSP_CHECK() - for (int i = 0; i < static_cast<int>(m_detectorElements.size()); ++i) { - int element = m_detectorElements[i]; + for (int element : m_detectorElements) { for (int j = 0; j < m_timeBinCount; ++j) { addToCountData(element, j, -ratio); } diff --git a/Framework/SINQ/src/PoldiUtilities/PoldiSpectrumDomainFunction.cpp b/Framework/SINQ/src/PoldiUtilities/PoldiSpectrumDomainFunction.cpp index eb6bf20858f5996e6b53dbee65591a9d54e05716..11e33ba30f76c4f3a99cc2526536c82eb620c531 100644 --- a/Framework/SINQ/src/PoldiUtilities/PoldiSpectrumDomainFunction.cpp +++ b/Framework/SINQ/src/PoldiUtilities/PoldiSpectrumDomainFunction.cpp @@ -164,14 +164,14 @@ void PoldiSpectrumDomainFunction::poldiFunction1D( double chopperSlitCount = static_cast<double>(m_chopperSlitOffsets.size()); - for (auto index = indices.begin(); index != indices.end(); ++index) { + for (int indice : indices) { std::vector<double> factors(domain.size()); for (size_t i = 0; i < factors.size(); ++i) { values.addToCalculated(i, chopperSlitCount * localValues[i] * m_timeTransformer->detectorElementIntensity( - domain[i], static_cast<size_t>(*index))); + domain[i], static_cast<size_t>(indice))); } } } @@ -271,9 +271,8 @@ std::vector<double> PoldiSpectrumDomainFunction::getChopperSlitOffsets( const std::vector<double> &chopperSlitTimes = chopper->slitTimes(); std::vector<double> offsets; offsets.reserve(chopperSlitTimes.size()); - for (auto time = chopperSlitTimes.cbegin(); time != chopperSlitTimes.cend(); - ++time) { - offsets.push_back(*time + chopper->zeroOffset()); + for (double chopperSlitTime : chopperSlitTimes) { + offsets.push_back(chopperSlitTime + chopper->zeroOffset()); } return offsets; diff --git a/Framework/SINQ/src/PoldiUtilities/PoldiSpectrumPawleyFunction.cpp b/Framework/SINQ/src/PoldiUtilities/PoldiSpectrumPawleyFunction.cpp index 809e96b7e71ab20c41d47d2d6d6a18098c09f757..998f551a5255640a6af3fa7c788d93fe66571782 100644 --- a/Framework/SINQ/src/PoldiUtilities/PoldiSpectrumPawleyFunction.cpp +++ b/Framework/SINQ/src/PoldiUtilities/PoldiSpectrumPawleyFunction.cpp @@ -67,14 +67,14 @@ void PoldiSpectrumPawleyFunction::poldiFunction1D( double chopperSlitCount = static_cast<double>(m_chopperSlitOffsets.size()); - for (auto index = indices.begin(); index != indices.end(); ++index) { + for (int indice : indices) { std::vector<double> factors(domain.size()); for (size_t i = 0; i < factors.size(); ++i) { values.addToCalculated(i, chopperSlitCount * localValues[i] * m_timeTransformer->detectorElementIntensity( - domain[i], static_cast<size_t>(*index))); + domain[i], static_cast<size_t>(indice))); } } }