diff --git a/Framework/Crystal/src/Cluster.cpp b/Framework/Crystal/src/Cluster.cpp index 9d79b4205466a2029addfff3bdb8138a9d0c7b61..0666dab699030448eae5a4d809fe76961926f2fd 100644 --- a/Framework/Crystal/src/Cluster.cpp +++ b/Framework/Crystal/src/Cluster.cpp @@ -59,9 +59,9 @@ void Cluster::addIndex(const size_t &index) { m_indexes.push_back(index); } */ void Cluster::writeTo(Mantid::API::IMDHistoWorkspace_sptr ws) const { const size_t label = this->getLabel(); - for (size_t i = 0; i < m_indexes.size(); ++i) { - ws->setSignalAt(m_indexes[i], static_cast<Mantid::signal_t>(label)); - ws->setErrorSquaredAt(m_indexes[i], 0); + for (unsigned long m_indexe : m_indexes) { + ws->setSignalAt(m_indexe, static_cast<Mantid::signal_t>(label)); + ws->setErrorSquaredAt(m_indexe, 0); } } @@ -75,9 +75,9 @@ Cluster::integrate(Mantid::API::IMDHistoWorkspace_const_sptr ws) const { double errorIntSQ = 0; double sigInt = 0; // Integrate accross indexes owned by this workspace. - for (size_t i = 0; i < m_indexes.size(); ++i) { - sigInt += ws->getSignalAt(m_indexes[i]); - double errorSQ = ws->getErrorAt(m_indexes[i]); + for (unsigned long m_indexe : m_indexes) { + sigInt += ws->getSignalAt(m_indexe); + double errorSQ = ws->getErrorAt(m_indexe); errorSQ *= errorSQ; errorIntSQ += errorSQ; } diff --git a/Framework/Crystal/src/ClusterRegister.cpp b/Framework/Crystal/src/ClusterRegister.cpp index dd105e27c7d38975f5e93461d3612e5691fe0013..90dd5d663a0b277265d45bf904c3e17f085cdf4a 100644 --- a/Framework/Crystal/src/ClusterRegister.cpp +++ b/Framework/Crystal/src/ClusterRegister.cpp @@ -55,8 +55,7 @@ public: GroupType containingAny; GroupType containingNone; // ------------- Find equivalent sets - for (auto i = m_groups.begin(); i != m_groups.end(); ++i) { - GroupType::value_type &cluster = *i; + for (auto &cluster : m_groups) { if (cluster.find(aLabel) != cluster.end()) { containingAny.push_back(cluster); } else if (cluster.find(bLabel) != cluster.end()) { @@ -83,8 +82,7 @@ public: GroupType::value_type masterSet; masterSet.insert(aLabel); // Incase it doesn't already contain a masterSet.insert(bLabel); // Incase it doesn't already contain b - for (auto i = containingAny.begin(); i != containingAny.end(); ++i) { - GroupType::value_type &childSet = *i; + for (auto &childSet : containingAny) { masterSet.insert(childSet.begin(), childSet.end()); // Build the master set. } @@ -101,11 +99,10 @@ public: */ std::list<boost::shared_ptr<CompositeCluster>> makeCompositeClusters() { std::list<boost::shared_ptr<CompositeCluster>> composites; - for (auto i = m_groups.begin(); i != m_groups.end(); ++i) { - GroupType::value_type &labelSet = *i; + for (auto &labelSet : m_groups) { auto composite = boost::make_shared<CompositeCluster>(); - for (auto j = labelSet.begin(); j != labelSet.end(); ++j) { - boost::shared_ptr<ICluster> &cluster = m_register[(*j)]; + for (value_type j : labelSet) { + boost::shared_ptr<ICluster> &cluster = m_register[j]; composite->add(cluster); } composites.push_back(composite); @@ -168,8 +165,7 @@ ClusterRegister::MapCluster ClusterRegister::clusters() const { MapCluster temp; temp.insert(m_Impl->m_unique.begin(), m_Impl->m_unique.end()); auto mergedClusters = m_Impl->makeCompositeClusters(); - for (auto i = mergedClusters.begin(); i != mergedClusters.end(); ++i) { - const auto &merged = *i; + for (auto &merged : mergedClusters) { temp.insert(std::make_pair(merged->getLabel(), merged)); } return temp; @@ -186,8 +182,7 @@ ClusterRegister::clusters(std::vector<DisjointElement> &elements) const { MapCluster temp; temp.insert(m_Impl->m_unique.begin(), m_Impl->m_unique.end()); auto mergedClusters = m_Impl->makeCompositeClusters(); - for (auto i = mergedClusters.begin(); i != mergedClusters.end(); ++i) { - const auto &merged = *i; + for (auto &merged : mergedClusters) { merged->toUniformMinimum(elements); temp.insert(std::make_pair(merged->getLabel(), merged)); } diff --git a/Framework/Crystal/src/CombinePeaksWorkspaces.cpp b/Framework/Crystal/src/CombinePeaksWorkspaces.cpp index 292aae1d67d38ee168bd0aa2412a7df56f3db1ab..56db99baf44b3c3c5431a09f4ca2c7ede28797eb 100644 --- a/Framework/Crystal/src/CombinePeaksWorkspaces.cpp +++ b/Framework/Crystal/src/CombinePeaksWorkspaces.cpp @@ -91,8 +91,8 @@ void CombinePeaksWorkspaces::exec() { if (!CombineMatchingPeaks) { // Loop over the peaks in the second workspace, appending each one to the // output - for (size_t i = 0; i < rhsPeaks.size(); ++i) { - output->addPeak(rhsPeaks[i]); + for (const auto &rhsPeak : rhsPeaks) { + output->addPeak(rhsPeak); progress.report(); } } else // Check for matching peaks @@ -105,15 +105,14 @@ void CombinePeaksWorkspaces::exec() { // Loop over the peaks in the second workspace, appending ones that don't // match any in first workspace - for (size_t i = 0; i < rhsPeaks.size(); ++i) { - const Peak ¤tPeak = rhsPeaks[i]; + for (const auto ¤tPeak : rhsPeaks) { // Now have to go through the first workspace checking for matches // Not doing anything clever as peaks workspace are typically not large - // just a linear search bool match = false; - for (size_t j = 0; j < lhsPeaks.size(); ++j) { + for (const auto &lhsPeak : lhsPeaks) { const V3D deltaQ = - currentPeak.getQSampleFrame() - lhsPeaks[j].getQSampleFrame(); + currentPeak.getQSampleFrame() - lhsPeak.getQSampleFrame(); if (deltaQ.nullVector( Tolerance)) // Using a V3D method that does the job { diff --git a/Framework/Crystal/src/CompositeCluster.cpp b/Framework/Crystal/src/CompositeCluster.cpp index b504298aea1a8ac8f831f97c25dfab80487736f5..727827467d326727bb4315c79df7bed82361bacf 100644 --- a/Framework/Crystal/src/CompositeCluster.cpp +++ b/Framework/Crystal/src/CompositeCluster.cpp @@ -41,8 +41,8 @@ ICluster::ClusterIntegratedValues CompositeCluster::integrate( double errorIntSQ = 0; double sigInt = 0; // Integrate owned clusters and add those results too. - for (size_t i = 0; i < m_ownedClusters.size(); ++i) { - auto integratedValues = m_ownedClusters[i]->integrate(ws); + for (const auto &m_ownedCluster : m_ownedClusters) { + auto integratedValues = m_ownedCluster->integrate(ws); sigInt += integratedValues.get<0>(); errorIntSQ += integratedValues.get<1>(); } @@ -55,8 +55,8 @@ ICluster::ClusterIntegratedValues CompositeCluster::integrate( */ void CompositeCluster::writeTo( boost::shared_ptr<Mantid::API::IMDHistoWorkspace> ws) const { - for (size_t i = 0; i < m_ownedClusters.size(); ++i) { - m_ownedClusters[i]->writeTo(ws); + for (const auto &m_ownedCluster : m_ownedClusters) { + m_ownedCluster->writeTo(ws); } } @@ -87,8 +87,8 @@ size_t CompositeCluster::getOriginalLabel() const { return getLabel(); } */ size_t CompositeCluster::size() const { size_t size = 0; - for (size_t i = 0; i < m_ownedClusters.size(); ++i) { - size += m_ownedClusters[i]->size(); + for (const auto &m_ownedCluster : m_ownedClusters) { + size += m_ownedCluster->size(); } return size; } @@ -133,9 +133,9 @@ void CompositeCluster::toUniformMinimum( } m_label = minLabel; - for (size_t i = 0; i < m_ownedClusters.size(); ++i) { - m_ownedClusters[i]->setRootCluster(minCluster); - m_ownedClusters[i]->toUniformMinimum(disjointSet); + for (auto &m_ownedCluster : m_ownedClusters) { + m_ownedCluster->setRootCluster(minCluster); + m_ownedCluster->toUniformMinimum(disjointSet); } } } @@ -153,8 +153,8 @@ size_t CompositeCluster::getRepresentitiveIndex() const { * @param root : Root cluster to use */ void CompositeCluster::setRootCluster(ICluster const *root) { - for (size_t i = 0; i < m_ownedClusters.size(); ++i) { - m_ownedClusters[i]->setRootCluster(root); + for (auto &m_ownedCluster : m_ownedClusters) { + m_ownedCluster->setRootCluster(root); } } diff --git a/Framework/Crystal/src/ConnectedComponentLabeling.cpp b/Framework/Crystal/src/ConnectedComponentLabeling.cpp index aa183dc399ab9514a9029b1936344a0b4db1a334..33799a633769a904172cb3d95e4a13fd206c56cc 100644 --- a/Framework/Crystal/src/ConnectedComponentLabeling.cpp +++ b/Framework/Crystal/src/ConnectedComponentLabeling.cpp @@ -134,8 +134,7 @@ size_t doConnectedComponentLabeling(IMDIterator *iterator, nonEmptyNeighbourIndexes.reserve(maxNeighbours); SetIds neighbourIds; // Discover non-empty neighbours - for (size_t i = 0; i < neighbourIndexes.size(); ++i) { - size_t neighIndex = neighbourIndexes[i]; + for (unsigned long neighIndex : neighbourIndexes) { if (!iterator->isWithinBounds(neighIndex)) { /* Record labels which appear to belong to the same cluster, but cannot be combined in this @@ -181,8 +180,7 @@ size_t doConnectedComponentLabeling(IMDIterator *iterator, DisjointElement &parentElement = neighbourElements[candidateSourceParentIndex]; // Union remainder parents with the chosen parent - for (size_t i = 0; i < nonEmptyNeighbourIndexes.size(); ++i) { - size_t neighIndex = nonEmptyNeighbourIndexes[i]; + for (unsigned long neighIndex : nonEmptyNeighbourIndexes) { if (neighIndex != candidateSourceParentIndex) { neighbourElements[neighIndex].unionWith(&parentElement); } @@ -346,9 +344,8 @@ ClusterMap ConnectedComponentLabeling::calculateDisjointTree( // equivalent clusters. Must be done in sequence. // Combine cluster maps processed by each thread. ClusterRegister clusterRegister; - for (auto it = parallelClusterMapVec.begin(); - it != parallelClusterMapVec.end(); ++it) { - for (auto itt = it->begin(); itt != it->end(); ++itt) { + for (auto &it : parallelClusterMapVec) { + for (auto itt = it.begin(); itt != it.end(); ++itt) { clusterRegister.add(itt->first, itt->second); } } @@ -357,11 +354,10 @@ ClusterMap ConnectedComponentLabeling::calculateDisjointTree( // ambiguity. g_log.debug("Percolate minimum label across boundaries"); - for (auto it = parallelEdgeVec.begin(); it != parallelEdgeVec.end(); ++it) { - VecEdgeIndexPair &indexPairVec = *it; - for (auto iit = indexPairVec.begin(); iit != indexPairVec.end(); ++iit) { - DisjointElement &a = neighbourElements[iit->get<0>()]; - DisjointElement &b = neighbourElements[iit->get<1>()]; + for (auto &indexPairVec : parallelEdgeVec) { + for (auto &iit : indexPairVec) { + DisjointElement &a = neighbourElements[iit.get<0>()]; + DisjointElement &b = neighbourElements[iit.get<1>()]; clusterRegister.merge(a, b); } } @@ -439,13 +435,13 @@ ClusterTuple ConnectedComponentLabeling::executeAndFetchClusters( // Get the keys (label ids) first in order to do the next stage in parallel. VecIndexes keys; keys.reserve(clusters.size()); - for (auto it = clusters.begin(); it != clusters.end(); ++it) { - keys.push_back(it->first); + for (auto &cluster : clusters) { + keys.push_back(cluster.first); } // Write each cluster out to the output workspace PARALLEL_FOR_NO_WSP_CHECK() - for (int i = 0; i < static_cast<int>(keys.size()); ++i) { - clusters[keys[i]]->writeTo(outWS); + for (unsigned long &key : keys) { + clusters[key]->writeTo(outWS); } return ClusterTuple(outWS, clusters); diff --git a/Framework/Crystal/src/DiffPeaksWorkspaces.cpp b/Framework/Crystal/src/DiffPeaksWorkspaces.cpp index 69d29d1048e3310fedb10ad5fb048c18709e266d..ef4c1358f43eb618ca68f0a4e5779333d139eb9d 100644 --- a/Framework/Crystal/src/DiffPeaksWorkspaces.cpp +++ b/Framework/Crystal/src/DiffPeaksWorkspaces.cpp @@ -84,8 +84,7 @@ void DiffPeaksWorkspaces::exec() { // Loop over the peaks in the second workspace, searching for a match in the // first - for (size_t i = 0; i < rhsPeaks.size(); ++i) { - const Peak ¤tPeak = rhsPeaks[i]; + for (const auto ¤tPeak : rhsPeaks) { // Now have to go through the first workspace checking for matches // Not doing anything clever as peaks workspace are typically not large - // just a linear search diff --git a/Framework/Crystal/src/FindClusterFaces.cpp b/Framework/Crystal/src/FindClusterFaces.cpp index f8baf134b37bd4091616c4ad0894db3ebebfcdb5..5ac372173d5805411d06e91ce32c0978778ee211 100644 --- a/Framework/Crystal/src/FindClusterFaces.cpp +++ b/Framework/Crystal/src/FindClusterFaces.cpp @@ -120,8 +120,7 @@ void findFacesAtIndex(const size_t linearIndex, IMDIterator *mdIterator, indexes); const auto neighbours = mdIterator->findNeighbourIndexesFaceTouching(); - for (size_t i = 0; i < neighbours.size(); ++i) { - size_t neighbourLinearIndex = neighbours[i]; + for (unsigned long neighbourLinearIndex : neighbours) { const int neighbourId = static_cast<int>(clusterImage->getSignalAt(neighbourLinearIndex)); @@ -372,11 +371,9 @@ void FindClusterFaces::exec() { for (int i = 0; i < nIterators; ++i) { const ClusterFaces &localClusterFaces = clusterFaces[i]; - for (auto it = localClusterFaces.begin(); it != localClusterFaces.end(); - ++it) { + for (const auto &clusterFace : localClusterFaces) { if (!limitRows || (out->rowCount() < size_t(maxRows))) { TableRow row = out->appendRow(); - const ClusterFace &clusterFace = *it; row << clusterFace.clusterId << double(clusterFace.workspaceIndex) << clusterFace.faceNormalDimension << clusterFace.maxEdge << clusterFace.radius; diff --git a/Framework/Crystal/src/FindSXPeaks.cpp b/Framework/Crystal/src/FindSXPeaks.cpp index a2cdbc16f408aba18adec1153b38260ee6183580..bf05957b9fc4d7c3afb41d6479b1a92792f3770b 100644 --- a/Framework/Crystal/src/FindSXPeaks.cpp +++ b/Framework/Crystal/src/FindSXPeaks.cpp @@ -212,26 +212,26 @@ void FindSXPeaks::reducePeakList(const peakvector &pcv) { double resol = getProperty("Resolution"); peakvector finalv; bool found = false; - for (std::size_t i = 0; i < pcv.size(); i++) { - for (std::size_t j = 0; j < finalv.size(); j++) { - if (pcv[i].compare(finalv[j], resol)) { - finalv[j] += pcv[i]; + for (const auto &i : pcv) { + for (auto &j : finalv) { + if (i.compare(j, resol)) { + j += i; found = true; break; } } if (!found) - finalv.push_back(pcv[i]); + finalv.push_back(i); found = false; } - for (std::size_t i = 0; i < finalv.size(); i++) { - finalv[i].reduce(); + for (auto &i : finalv) { + i.reduce(); try { - Geometry::IPeak *peak = m_peaks->createPeak(finalv[i].getQ()); + Geometry::IPeak *peak = m_peaks->createPeak(i.getQ()); if (peak) { - peak->setIntensity(finalv[i].getIntensity()); - peak->setDetectorID(finalv[i].getDetectorId()); + peak->setIntensity(i.getIntensity()); + peak->setDetectorID(i.getDetectorId()); m_peaks->addPeak(*peak); delete peak; } diff --git a/Framework/Crystal/src/GoniometerAnglesFromPhiRotation.cpp b/Framework/Crystal/src/GoniometerAnglesFromPhiRotation.cpp index 8f8e0f8e59466530bf596784d8bf106ebd6d8f74..e75e45f913a6a6f0d053d3582c8122d3d3136914 100644 --- a/Framework/Crystal/src/GoniometerAnglesFromPhiRotation.cpp +++ b/Framework/Crystal/src/GoniometerAnglesFromPhiRotation.cpp @@ -218,9 +218,8 @@ void GoniometerAnglesFromPhiRotation::exec() { API::FrameworkManager::Instance(); - for (size_t d = 0; d < directionList.size(); d++) + for (auto dir : directionList) for (int sgn = 1; sgn > -2; sgn -= 2) { - V3D dir = directionList[d]; dir.normalize(); Quat Q(sgn * dphi, dir); Q.normalize(); diff --git a/Framework/Crystal/src/IntegratePeakTimeSlices.cpp b/Framework/Crystal/src/IntegratePeakTimeSlices.cpp index 92558503c80fd9fed7c50e719f19c17ddd805321..0535a482dee7f1933b8204389431d643613e276a 100644 --- a/Framework/Crystal/src/IntegratePeakTimeSlices.cpp +++ b/Framework/Crystal/src/IntegratePeakTimeSlices.cpp @@ -127,8 +127,8 @@ IntegratePeakTimeSlices::IntegratePeakTimeSlices() // for (int i = 0; i < NAttributes; i++) // m_AttributeValues[i] = 0; - for (int i = 0; i < NParameters; i++) - m_ParameterValues[i] = 0; + for (double &m_ParameterValue : m_ParameterValues) + m_ParameterValue = 0; } double SQRT(double v) { diff --git a/Framework/Crystal/src/LoadIsawUB.cpp b/Framework/Crystal/src/LoadIsawUB.cpp index a4521d204b6970f6df29504e2e2e5b72d27c530c..c63ad864694e9dc470db2981513be0feb7d61475 100644 --- a/Framework/Crystal/src/LoadIsawUB.cpp +++ b/Framework/Crystal/src/LoadIsawUB.cpp @@ -90,12 +90,12 @@ void LoadIsawUB::exec() { readToEndOfLine(in, true); double latVals[6]; - for (size_t col = 0; col < 6; col++) { + for (double &latVal : latVals) { s = getWord(in, true); if (!convert(s, val)) throw std::runtime_error("The string '" + s + "' in the file was not understood as a number."); - latVals[col] = val; + latVal = val; } // Adjust the UB by transposing diff --git a/Framework/Crystal/src/MaskPeaksWorkspace.cpp b/Framework/Crystal/src/MaskPeaksWorkspace.cpp index af3e3935a41f4ddc6b0aeb3fac44ad13cc3a6d17..c28656cedf3da54e37dc36f6142e3f73a4ea4d26 100644 --- a/Framework/Crystal/src/MaskPeaksWorkspace.cpp +++ b/Framework/Crystal/src/MaskPeaksWorkspace.cpp @@ -94,9 +94,8 @@ void MaskPeaksWorkspace::exec() { // Loop over peaks const std::vector<Peak> &peaks = peaksW->getPeaks(); PARALLEL_FOR3(m_inputW, peaksW, tablews) - for (int i = 0; i < static_cast<int>(peaks.size()); i++) { + for (auto peak : peaks) { PARALLEL_START_INTERUPT_REGION - Peak peak = peaks[i]; // get the peak location on the detector double col = peak.getCol(); double row = peak.getRow(); diff --git a/Framework/Crystal/src/OptimizeCrystalPlacement.cpp b/Framework/Crystal/src/OptimizeCrystalPlacement.cpp index 50ae448509ae09fd7974be149b11de9e13edcd59..ca15afb33c57e930aff5f8401a02f20175b1849a 100644 --- a/Framework/Crystal/src/OptimizeCrystalPlacement.cpp +++ b/Framework/Crystal/src/OptimizeCrystalPlacement.cpp @@ -241,9 +241,7 @@ void OptimizeCrystalPlacement::exec() { //--------------- std::vector<std::string> ChRunNumList; std::string predChar = ""; - for (auto it = RunNumList.begin(); it != RunNumList.end(); ++it) { - int runNum = *it; - + for (int runNum : RunNumList) { auto it1 = NOoptimizeRuns.begin(); for (; it1 != NOoptimizeRuns.end() && *it1 != runNum; ++it1) { } diff --git a/Framework/Crystal/src/OptimizeExtinctionParameters.cpp b/Framework/Crystal/src/OptimizeExtinctionParameters.cpp index f52313952078931c092fb49f01d12b1a1282f2d5..3cee671c6b36214da5ee7692d4160289c32db528 100644 --- a/Framework/Crystal/src/OptimizeExtinctionParameters.cpp +++ b/Framework/Crystal/src/OptimizeExtinctionParameters.cpp @@ -84,8 +84,8 @@ void OptimizeExtinctionParameters::init() { "Becker-Coppens Crystallite Radius (micron)", Direction::InOut); std::vector<std::string> propOptions; - for (size_t i = 0; i < m_pointGroups.size(); ++i) - propOptions.push_back(m_pointGroups[i]->getName()); + for (auto &m_pointGroup : m_pointGroups) + propOptions.push_back(m_pointGroup->getName()); declareProperty("PointGroup", propOptions[0], boost::make_shared<StringListValidator>(propOptions), "Which point group applies to this crystal?"); diff --git a/Framework/Crystal/src/OptimizeLatticeForCellType.cpp b/Framework/Crystal/src/OptimizeLatticeForCellType.cpp index 99a521fda95ef83222a5d2d1c68a5c7a01b0011b..a739924e1af804febac81a5a7dd61bc073ceb8ba 100644 --- a/Framework/Crystal/src/OptimizeLatticeForCellType.cpp +++ b/Framework/Crystal/src/OptimizeLatticeForCellType.cpp @@ -100,26 +100,26 @@ void OptimizeLatticeForCellType::exec() { const std::vector<Peak> &peaks_all = ws->getPeaks(); int run = 0; int count = 0; - for (size_t i = 0; i < peaks_all.size(); i++) { - if (peaks_all[i].getRunNumber() != run) { + for (const auto &i : peaks_all) { + if (i.getRunNumber() != run) { count++; // first entry in runWS is input workspace DataObjects::PeaksWorkspace_sptr cloneWS(new PeaksWorkspace()); cloneWS->setInstrument(ws->getInstrument()); cloneWS->copyExperimentInfoFrom(ws.get()); runWS.push_back(cloneWS); - runWS[count]->addPeak(peaks_all[i]); - run = peaks_all[i].getRunNumber(); + runWS[count]->addPeak(i); + run = i.getRunNumber(); AnalysisDataService::Instance().addOrReplace( boost::lexical_cast<std::string>(run) + ws->getName(), runWS[count]); } else { - runWS[count]->addPeak(peaks_all[i]); + runWS[count]->addPeak(i); } } } // finally do the optimization - for (size_t i_run = 0; i_run < runWS.size(); i_run++) { - DataObjects::PeaksWorkspace_sptr peakWS(runWS[i_run]->clone().release()); + for (auto &i_run : runWS) { + DataObjects::PeaksWorkspace_sptr peakWS(i_run->clone().release()); AnalysisDataService::Instance().addOrReplace("_peaks", peakWS); const DblMatrix UB = peakWS->sample().getOrientedLattice().getUB(); std::vector<double> lat(6); @@ -174,16 +174,16 @@ void OptimizeLatticeForCellType::exec() { refinedCell.errorbeta(), refinedCell.errorgamma()); // Show the modified lattice parameters - g_log.notice() << runWS[i_run]->getName() << " " << o_lattice << "\n"; + g_log.notice() << i_run->getName() << " " << o_lattice << "\n"; - runWS[i_run]->mutableSample().setOrientedLattice(&o_lattice); + i_run->mutableSample().setOrientedLattice(&o_lattice); setProperty("OutputChi2", chisq); if (apply) { // Reindex peaks with new UB Mantid::API::IAlgorithm_sptr alg = createChildAlgorithm("IndexPeaks"); - alg->setPropertyValue("PeaksWorkspace", runWS[i_run]->getName()); + alg->setPropertyValue("PeaksWorkspace", i_run->getName()); alg->setProperty("Tolerance", tolerance); alg->executeAsChildAlg(); } @@ -195,25 +195,23 @@ void OptimizeLatticeForCellType::exec() { // Save Peaks Mantid::API::IAlgorithm_sptr savePks_alg = createChildAlgorithm("SaveIsawPeaks"); - savePks_alg->setPropertyValue("InputWorkspace", runWS[i_run]->getName()); - savePks_alg->setProperty("Filename", outputdir + "ls" + - runWS[i_run]->getName() + + savePks_alg->setPropertyValue("InputWorkspace", i_run->getName()); + savePks_alg->setProperty("Filename", outputdir + "ls" + i_run->getName() + ".integrate"); savePks_alg->executeAsChildAlg(); g_log.notice() << "See output file: " - << outputdir + "ls" + runWS[i_run]->getName() + - ".integrate" + << outputdir + "ls" + i_run->getName() + ".integrate" << "\n"; // Save UB Mantid::API::IAlgorithm_sptr saveUB_alg = createChildAlgorithm("SaveIsawUB"); - saveUB_alg->setPropertyValue("InputWorkspace", runWS[i_run]->getName()); - saveUB_alg->setProperty("Filename", outputdir + "ls" + - runWS[i_run]->getName() + ".mat"); + saveUB_alg->setPropertyValue("InputWorkspace", i_run->getName()); + saveUB_alg->setProperty("Filename", + outputdir + "ls" + i_run->getName() + ".mat"); saveUB_alg->executeAsChildAlg(); // Show the names of files written g_log.notice() << "See output file: " - << outputdir + "ls" + runWS[i_run]->getName() + ".mat" + << outputdir + "ls" + i_run->getName() + ".mat" << "\n"; } } diff --git a/Framework/Crystal/src/PeakHKLErrors.cpp b/Framework/Crystal/src/PeakHKLErrors.cpp index ca78c269c4114191893c765c5348b04ae9f6a967..4dc7d2149e4eeda2b93462e1f986addfe72b177d 100644 --- a/Framework/Crystal/src/PeakHKLErrors.cpp +++ b/Framework/Crystal/src/PeakHKLErrors.cpp @@ -71,12 +71,10 @@ void PeakHKLErrors::setUpOptRuns() { boost::split(OptRunNums, OptRunstemp, boost::is_any_of("/")); - for (size_t i = 0; i < OptRunNums.size(); i++) { - declareParameter("phi" + OptRunNums[i], 0.0, - "Phi sample orientation value"); - declareParameter("chi" + OptRunNums[i], 0.0, - "Chi sample orientation value"); - declareParameter("omega" + OptRunNums[i], 0.0, + for (auto &OptRunNum : OptRunNums) { + declareParameter("phi" + OptRunNum, 0.0, "Phi sample orientation value"); + declareParameter("chi" + OptRunNum, 0.0, "Chi sample orientation value"); + declareParameter("omega" + OptRunNum, 0.0, "Omega sample orientation value"); } } @@ -118,39 +116,39 @@ void PeakHKLErrors::cLone( if (component->isParametrized()) { std::set<std::string> nms = pmapSv->names(component.get()); - for (auto it = nms.begin(); it != nms.end(); ++it) { + for (const auto &nm : nms) { - if (pmapSv->contains(component.get(), *it, "double")) { + if (pmapSv->contains(component.get(), nm, "double")) { std::vector<double> dparams = - pmapSv->getDouble(component->getName(), *it); - pmap->addDouble(component.get(), *it, dparams[0]); + pmapSv->getDouble(component->getName(), nm); + pmap->addDouble(component.get(), nm, dparams[0]); continue; } - if (pmapSv->contains(component.get(), *it, "V3D")) { - std::vector<V3D> V3Dparams = pmapSv->getV3D(component->getName(), *it); - pmap->addV3D(component.get(), *it, V3Dparams[0]); + if (pmapSv->contains(component.get(), nm, "V3D")) { + std::vector<V3D> V3Dparams = pmapSv->getV3D(component->getName(), nm); + pmap->addV3D(component.get(), nm, V3Dparams[0]); continue; } - if (pmapSv->contains(component.get(), *it, "int")) { + if (pmapSv->contains(component.get(), nm, "int")) { std::vector<int> iparams = - pmapSv->getType<int>(component->getName(), *it); - pmap->addInt(component.get(), *it, iparams[0]); + pmapSv->getType<int>(component->getName(), nm); + pmap->addInt(component.get(), nm, iparams[0]); continue; } - if (pmapSv->contains(component.get(), *it, "string")) { + if (pmapSv->contains(component.get(), nm, "string")) { std::vector<std::string> sparams = - pmapSv->getString(component->getName(), *it); - pmap->addString(component.get(), *it, sparams[0]); + pmapSv->getString(component->getName(), nm); + pmap->addString(component.get(), nm, sparams[0]); continue; } - if (pmapSv->contains(component.get(), *it, "Quat")) { + if (pmapSv->contains(component.get(), nm, "Quat")) { std::vector<Kernel::Quat> sparams = - pmapSv->getType<Kernel::Quat>(component->getName(), *it); - pmap->addQuat(component.get(), *it, sparams[0]); + pmapSv->getType<Kernel::Quat>(component->getName(), nm); + pmap->addQuat(component.get(), nm, sparams[0]); continue; } } diff --git a/Framework/Crystal/src/PredictFractionalPeaks.cpp b/Framework/Crystal/src/PredictFractionalPeaks.cpp index d65ca2bc8c7edbb505cc74f95149572b571a8151..4952a0253081f695de814ddd5164846d2052a845 100644 --- a/Framework/Crystal/src/PredictFractionalPeaks.cpp +++ b/Framework/Crystal/src/PredictFractionalPeaks.cpp @@ -158,16 +158,16 @@ void PredictFractionalPeaks::exec() { bool done = false; int ErrPos = 1; // Used to determine position in code of a throw while (!done) { - for (size_t hoffset = 0; hoffset < hOffsets.size(); hoffset++) - for (size_t koffset = 0; koffset < kOffsets.size(); koffset++) - for (size_t loffset = 0; loffset < lOffsets.size(); loffset++) + for (double hOffset : hOffsets) + for (double kOffset : kOffsets) + for (double lOffset : lOffsets) try { V3D hkl1(hkl); ErrPos = 0; - hkl1[0] += hOffsets[hoffset]; - hkl1[1] += kOffsets[koffset]; - hkl1[2] += lOffsets[loffset]; + hkl1[0] += hOffset; + hkl1[1] += kOffset; + hkl1[2] += lOffset; Kernel::V3D Qs = UB * hkl1; Qs *= 2.0; diff --git a/Framework/Crystal/src/PredictPeaks.cpp b/Framework/Crystal/src/PredictPeaks.cpp index 1ec7d9f829616c41dec2059125a8f8d3699c5963..85be98a017fb7da93b30b5143e4cd027bb5584d0 100644 --- a/Framework/Crystal/src/PredictPeaks.cpp +++ b/Framework/Crystal/src/PredictPeaks.cpp @@ -67,8 +67,8 @@ void PredictPeaks::init() { // Build up a list of reflection conditions to use std::vector<std::string> propOptions; - for (size_t i = 0; i < m_refConds.size(); ++i) - propOptions.push_back(m_refConds[i]->getName()); + for (auto &m_refCond : m_refConds) + propOptions.push_back(m_refCond->getName()); declareProperty("ReflectionCondition", "Primitive", boost::make_shared<StringListValidator>(propOptions), "Which reflection condition applies to this crystal, " @@ -234,10 +234,9 @@ void PredictPeaks::exec() { Progress prog(this, 0.0, 1.0, possibleHKLs.size() * gonioVec.size()); prog.setNotifyStep(0.01); - for (auto goniometerMatrix = gonioVec.begin(); - goniometerMatrix != gonioVec.end(); ++goniometerMatrix) { + for (auto &goniometerMatrix : gonioVec) { // Final transformation matrix (HKL to Q in lab frame) - DblMatrix orientedUB = (*goniometerMatrix) * ub; + DblMatrix orientedUB = goniometerMatrix * ub; /* Because of the additional filtering step it's better to keep track of the * allowed peaks with a counter. */ @@ -245,10 +244,10 @@ void PredictPeaks::exec() { size_t allowedPeakCount = 0; - for (auto hkl = possibleHKLs.begin(); hkl != possibleHKLs.end(); ++hkl) { - if (lambdaFilter.isAllowed(*hkl)) { + for (auto &possibleHKL : possibleHKLs) { + if (lambdaFilter.isAllowed(possibleHKL)) { ++allowedPeakCount; - calculateQAndAddToOutput(*hkl, orientedUB, *goniometerMatrix); + calculateQAndAddToOutput(possibleHKL, orientedUB, goniometerMatrix); } prog.report(); } @@ -310,9 +309,9 @@ void PredictPeaks::fillPossibleHKLsUsingGenerator( ReflectionCondition_sptr refCond(new ReflectionConditionPrimitive()); // Get it from the property std::string refCondName = getPropertyValue("ReflectionCondition"); - for (size_t i = 0; i < m_refConds.size(); ++i) - if (m_refConds[i]->getName() == refCondName) - refCond = m_refConds[i]; + for (const auto &m_refCond : m_refConds) + if (m_refCond->getName() == refCondName) + refCond = m_refCond; HKLGenerator gen(orientedLattice, dMin); auto filter = diff --git a/Framework/Crystal/src/SCDCalibratePanels.cpp b/Framework/Crystal/src/SCDCalibratePanels.cpp index 97492f732b58115936396ab05bd61b71794f28f5..149f955b398ddfb8c4e0ff0f5d2c752286857ea7 100644 --- a/Framework/Crystal/src/SCDCalibratePanels.cpp +++ b/Framework/Crystal/src/SCDCalibratePanels.cpp @@ -183,8 +183,7 @@ void SCDCalibratePanels::CalculateGroups( Groups.clear(); if (Grouping == "OnePanelPerGroup") { - for (auto it = AllBankNames.begin(); it != AllBankNames.end(); ++it) { - string bankName = (*it); + for (auto bankName : AllBankNames) { vector<string> vbankName; vbankName.push_back(bankName); Groups.push_back(vbankName); @@ -193,9 +192,7 @@ void SCDCalibratePanels::CalculateGroups( } else if (Grouping == "AllPanelsInOneGroup") { vector<string> vbankName; - for (auto it = AllBankNames.begin(); it != AllBankNames.end(); ++it) { - string bankName = (*it); - + for (auto bankName : AllBankNames) { vbankName.push_back(bankName); } @@ -208,9 +205,7 @@ void SCDCalibratePanels::CalculateGroups( boost::split(GroupA, bankingCode, boost::is_any_of("]")); set<string> usedInts; - for (size_t Gr = 0; Gr < GroupA.size(); ++Gr) { - string S = GroupA[Gr]; - + for (auto S : GroupA) { boost::trim(S); if (S.empty()) @@ -226,9 +221,7 @@ void SCDCalibratePanels::CalculateGroups( boost::split(GroupB, S, boost::is_any_of(",")); vector<string> Group0; - for (size_t panelRange = 0; panelRange < GroupB.size(); ++panelRange) { - string rangeOfBanks = GroupB[panelRange]; - + for (auto rangeOfBanks : GroupB) { boost::trim(rangeOfBanks); vector<string> StrtStopStep; @@ -317,8 +310,7 @@ boost::shared_ptr<const Instrument> SCDCalibratePanels::GetNewCalibInstrument( boost::shared_ptr<const ParameterMap> pmap0 = instrument->getParameterMap(); boost::shared_ptr<ParameterMap> pmap1(new ParameterMap()); - for (auto vit = AllBankNames.begin(); vit != AllBankNames.end(); ++vit) { - string bankName = (*vit); + for (auto bankName : AllBankNames) { updateBankParams(instrument->getComponentByName(bankName), pmap1, pmap0); } @@ -617,8 +609,8 @@ void SCDCalibratePanels::exec() { PARALLEL_START_INTERUPT_REGION auto group = Groups.begin() + iGr; vector<string> banksVec; - for (auto bankName = group->begin(); bankName != group->end(); ++bankName) { - banksVec.push_back(*bankName); + for (auto &bankName : *group) { + banksVec.push_back(bankName); } if (!GoodStart(peaksWs, a, b, c, alpha, beta, gamma, tolerance)) { g_log.warning() << "**** Indexing is NOT compatible with given lattice " @@ -1234,9 +1226,7 @@ void SCDCalibratePanels::createResultWorkspace(const int numGroups, // determine the field names, the leading '_' is the break point vector<string> TableFieldNames; - for (size_t p = 0; p < names.size(); ++p) { - string fieldName = names[p]; - + for (auto fieldName : names) { size_t dotPos = fieldName.find('_'); if (dotPos < fieldName.size()) fieldName = fieldName.substr(dotPos + 1); @@ -1643,9 +1633,7 @@ void SCDCalibratePanels::FixUpBankParameterMap( boost::shared_ptr<const ParameterMap> const pmapOld, bool RotCenters) { boost::shared_ptr<ParameterMap> pmap = NewInstrument->getParameterMap(); - for (auto it1 = bankNames.cbegin(); it1 != bankNames.cend(); ++it1) { - - const string bankName = (*it1); + for (auto bankName : bankNames) { boost::shared_ptr<const IComponent> bank1 = NewInstrument->getComponentByName(bankName); @@ -1729,8 +1717,8 @@ void SCDCalibratePanels::saveXmlFile( ParameterMap_sptr pmap = instrument->getParameterMap(); // write out the detector banks - for (auto it = Groups.begin(); it != Groups.end(); ++it) { - for (auto it1 = (*it).begin(); it1 != (*it).end(); ++it1) { + for (const auto &Group : Groups) { + for (auto it1 = Group.begin(); it1 != Group.end(); ++it1) { string bankName = (*it1); oss3 << "<component-link name=\"" << bankName << "\">" << endl; diff --git a/Framework/Crystal/src/SCDPanelErrors.cpp b/Framework/Crystal/src/SCDPanelErrors.cpp index 55382fda2c827467508f1a4a5ac554ef6d45b738..694d6712c5560a8ff63c29d4a2ba1a8a57b43328 100644 --- a/Framework/Crystal/src/SCDPanelErrors.cpp +++ b/Framework/Crystal/src/SCDPanelErrors.cpp @@ -664,8 +664,7 @@ void SCDPanelErrors::functionDeriv1D(Jacobian *out, const double *xValues, AllBankNames.insert(m_peaks->getPeak(i).getBankName()); Instrument_sptr instrNew = getNewInstrument(m_peaks->getPeak(0)); - for (auto it = AllBankNames.begin(); it != AllBankNames.end(); ++it) { - std::string bankName = (*it); + for (auto bankName : AllBankNames) { boost::shared_ptr<const IComponent> panel = instrNew->getComponentByName(bankName); bankDetMap[bankName] = panel; @@ -778,8 +777,8 @@ void SCDPanelErrors::functionDeriv1D(Jacobian *out, const double *xValues, for (size_t gr = 0; gr < Groups.size(); ++gr) { vector<string> banknames; boost::split(banknames, Groups[gr], boost::is_any_of("/")); - for (auto it = banknames.begin(); it != banknames.end(); ++it) - bankName2Group[(*it)] = gr; + for (auto &bankname : banknames) + bankName2Group[bankname] = gr; } // derivative formulas documentation // Qvec=-K*Vvec +K*v_mag*beamDir @@ -1223,10 +1222,10 @@ SCDPanelErrors::calcWorkspace(DataObjects::PeaksWorkspace_sptr &pwks, Mantid::MantidVecPtr yvals; Mantid::MantidVec &yvalB = yvals.access(); - for (size_t k = 0; k < bankNames.size(); ++k) + for (auto &bankName : bankNames) for (size_t j = 0; j < pwks->rowCount(); ++j) { Geometry::IPeak &peak = pwks->getPeak((int)j); - if (peak.getBankName().compare(bankNames[k]) == 0) + if (peak.getBankName().compare(bankName) == 0) if (peak.getH() != 0 || peak.getK() != 0 || peak.getL() != 0) if (peak.getH() - floor(peak.getH()) < tolerance || floor(peak.getH() + 1) - peak.getH() < tolerance) diff --git a/Framework/Crystal/src/SaveIsawPeaks.cpp b/Framework/Crystal/src/SaveIsawPeaks.cpp index 957dc07f27a19753b15793e2b95d5de093d26ad0..f75e9d2937c50e0a2ccd844e4f40b36d531f3c40 100644 --- a/Framework/Crystal/src/SaveIsawPeaks.cpp +++ b/Framework/Crystal/src/SaveIsawPeaks.cpp @@ -298,8 +298,7 @@ void SaveIsawPeaks::exec() { out << header << std::endl; // Go through each peak at this run / bank - for (size_t i = 0; i < ids.size(); i++) { - size_t wi = ids[i]; + for (unsigned long wi : ids) { Peak &p = peaks[wi]; // Sequence (run) number diff --git a/Framework/Crystal/src/SelectCellWithForm.cpp b/Framework/Crystal/src/SelectCellWithForm.cpp index e8c7d98ba3742bb88d6650d5184f45d569a618cd..a458bbd57122c564efef6029663d9edc5d41e598 100644 --- a/Framework/Crystal/src/SelectCellWithForm.cpp +++ b/Framework/Crystal/src/SelectCellWithForm.cpp @@ -96,8 +96,8 @@ Kernel::Matrix<double> SelectCellWithForm::DetermineErrors( } if (!latErrorsValid) { - for (size_t i = 0; i < sigabc.size(); i++) - sigabc[i] = 0; + for (double &i : sigabc) + i = 0; return UB; } else diff --git a/Framework/Crystal/src/SortHKL.cpp b/Framework/Crystal/src/SortHKL.cpp index bb836f26613970f9f4aed38ba2a3b7844ecf40e1..f0e9185815500ea50348dc425b0e1e24937f05e3 100644 --- a/Framework/Crystal/src/SortHKL.cpp +++ b/Framework/Crystal/src/SortHKL.cpp @@ -45,15 +45,15 @@ void SortHKL::init() { /* TODO: These two properties with string lists keep appearing - * Probably there should be a dedicated Property type or validator. */ std::vector<std::string> pgOptions; - for (size_t i = 0; i < m_pointGroups.size(); ++i) - pgOptions.push_back(m_pointGroups[i]->getName()); + for (auto &m_pointGroup : m_pointGroups) + pgOptions.push_back(m_pointGroup->getName()); declareProperty("PointGroup", pgOptions[0], boost::make_shared<StringListValidator>(pgOptions), "Which point group applies to this crystal?"); std::vector<std::string> centeringOptions; - for (size_t i = 0; i < m_refConds.size(); ++i) - centeringOptions.push_back(m_refConds[i]->getName()); + for (auto &m_refCond : m_refConds) + centeringOptions.push_back(m_refCond->getName()); declareProperty("LatticeCentering", centeringOptions[0], boost::make_shared<StringListValidator>(centeringOptions), "Appropriate lattice centering for the peaks."); @@ -169,9 +169,9 @@ ReflectionCondition_sptr SortHKL::getCentering() const { boost::make_shared<ReflectionConditionPrimitive>(); std::string refCondName = getPropertyValue("LatticeCentering"); - for (size_t i = 0; i < m_refConds.size(); ++i) - if (m_refConds[i]->getName() == refCondName) - centering = m_refConds[i]; + for (const auto &m_refCond : m_refConds) + if (m_refCond->getName() == refCondName) + centering = m_refCond; return centering; } @@ -183,9 +183,9 @@ PointGroup_sptr SortHKL::getPointgroup() const { PointGroupFactory::Instance().createPointGroup("-1"); std::string pointGroupName = getPropertyValue("PointGroup"); - for (size_t i = 0; i < m_pointGroups.size(); ++i) - if (m_pointGroups[i]->getName() == pointGroupName) - pointGroup = m_pointGroups[i]; + for (const auto &m_pointGroup : m_pointGroups) + if (m_pointGroup->getName() == pointGroupName) + pointGroup = m_pointGroup; return pointGroup; } diff --git a/Framework/Crystal/src/StatisticsOfPeaksWorkspace.cpp b/Framework/Crystal/src/StatisticsOfPeaksWorkspace.cpp index 9d3bad70abbd14868b55d2d07c05e42205e9fbbb..4a7641946b1447ab538f649bcba2be93a46ad0ca 100644 --- a/Framework/Crystal/src/StatisticsOfPeaksWorkspace.cpp +++ b/Framework/Crystal/src/StatisticsOfPeaksWorkspace.cpp @@ -44,8 +44,8 @@ void StatisticsOfPeaksWorkspace::init() { Direction::Input), "An input PeaksWorkspace with an instrument."); std::vector<std::string> propOptions; - for (size_t i = 0; i < m_pointGroups.size(); ++i) - propOptions.push_back(m_pointGroups[i]->getName()); + for (auto &m_pointGroup : m_pointGroups) + propOptions.push_back(m_pointGroup->getName()); declareProperty("PointGroup", propOptions[0], boost::make_shared<StringListValidator>(propOptions), "Which point group applies to this crystal?"); @@ -53,8 +53,8 @@ void StatisticsOfPeaksWorkspace::init() { std::vector<std::string> centeringOptions; std::vector<ReflectionCondition_sptr> reflectionConditions = getAllReflectionConditions(); - for (size_t i = 0; i < reflectionConditions.size(); ++i) - centeringOptions.push_back(reflectionConditions[i]->getName()); + for (auto &reflectionCondition : reflectionConditions) + centeringOptions.push_back(reflectionCondition->getName()); declareProperty("LatticeCentering", centeringOptions[0], boost::make_shared<StringListValidator>(centeringOptions), "Appropriate lattice centering for the peaks.");