Commit 146c0c77 authored by Hahn, Steven's avatar Hahn, Steven
Browse files

Refs #14764. Reviewed changes through Framework/DataObjects/src/CoordTransformDistanceParser.cpp

parent 383f0acd
......@@ -367,7 +367,7 @@ void AbsorptionCorrection::calculateDistances(
// AbsorptionCorrection::calculateDistances");
} else // The normal situation
{
L2s[i] = outgoing.begin()->distFromStart;
L2s[i] = outgoing.cbegin()->distFromStart;
}
}
}
......
......@@ -102,7 +102,7 @@ void AnyShapeAbsorption::initialiseCachedDistances() {
// This will also throw away points that are inside a gauge volume but
// outside the sample
if (m_sampleObject->interceptSurface(incoming) > 0) {
m_L1s.push_back(incoming.begin()->distFromStart);
m_L1s.push_back(incoming.cbegin()->distFromStart);
m_elementPositions.push_back(currentPosition);
// Also calculate element volume here
m_elementVolumes.push_back(XSliceThickness * YSliceThickness *
......
......@@ -119,7 +119,7 @@ void CylinderAbsorption::initialiseCachedDistances() {
Track incoming(m_elementPositions[counter], m_beamDirection * -1.0);
m_sampleObject->interceptSurface(incoming);
m_L1s[counter] = incoming.begin()->distFromStart;
m_L1s[counter] = incoming.cbegin()->distFromStart;
// Also calculate element volumes here
const double outerR = R + (m_deltaR / 2.0);
......
......@@ -383,7 +383,7 @@ double DetectorEfficiencyCor::distToSurface(const V3D &start,
}
// the first part of the track will be the part inside the shape, return its
// length
return track.begin()->distInsideObject;
return track.cbegin()->distInsideObject;
}
/** Calculates detector efficiency, copied from the fortran code in
......
......@@ -124,7 +124,7 @@ void FlatPlateAbsorption::initialiseCachedDistances() {
// Create track for distance in sample before scattering point
Track incoming(m_elementPositions[counter], m_beamDirection * -1.0);
m_sampleObject->interceptSurface(incoming);
m_L1s[counter] = incoming.begin()->distFromStart;
m_L1s[counter] = incoming.cbegin()->distFromStart;
// Also calculate element volume here
m_elementVolumes[counter] =
......
......@@ -49,11 +49,9 @@ void GroupWorkspaces::exec() {
* @param names The list of names to add from the ADS
*/
void GroupWorkspaces::addToGroup(const std::vector<std::string> &names) {
typedef std::vector<std::string>::const_iterator const_vector_iterator;
AnalysisDataServiceImpl &ads = AnalysisDataService::Instance();
auto cend = names.end();
for (auto citr = names.begin(); citr != cend; ++citr) {
for (auto citr = names.cbegin(); citr != names.cend(); ++citr) {
auto workspace = ads.retrieve(*citr);
addToGroup(workspace);
}
......
......@@ -169,10 +169,9 @@ void He3TubeEfficiency::correctForEfficiency(std::size_t spectraIndex) {
const Mantid::MantidVec yValues = this->inputWS->readY(spectraIndex);
const Mantid::MantidVec eValues = this->inputWS->readE(spectraIndex);
auto yinItr = yValues.begin();
auto einItr = eValues.begin();
auto xItr =
this->inputWS->readX(spectraIndex).begin();
auto yinItr = yValues.cbegin();
auto einItr = eValues.cbegin();
auto xItr = this->inputWS->readX(spectraIndex).cbegin();
auto youtItr = yout.begin();
auto eoutItr = eout.begin();
......@@ -343,7 +342,7 @@ double He3TubeEfficiency::distToSurface(const Kernel::V3D start,
}
// the first part of the track will be the part inside the shape,
// return its length
return track.begin()->distInsideObject;
return track.cbegin()->distInsideObject;
}
/**
......
......@@ -236,13 +236,14 @@ void MaskBins::execEvent() {
void MaskBins::findIndices(const MantidVec &X,
MantidVec::difference_type &startBin,
MantidVec::difference_type &endBin) {
startBin = std::upper_bound(X.begin(), X.end(), m_startX) - X.begin();
startBin = std::distance(X.begin(),
std::upper_bound(X.cbegin(), X.cend(), m_startX));
if (startBin != 0)
--startBin;
auto last = std::lower_bound(X.begin(), X.end(), m_endX);
if (last == X.end())
auto last = std::lower_bound(X.cbegin(), X.cend(), m_endX);
if (last == X.cend())
--last;
endBin = last - X.begin();
endBin = std::distance(X.cbegin(), last);
}
} // namespace Algorithms
......
......@@ -78,8 +78,7 @@ void MaskDetectorsIf::exec() {
else {
double val = inputW->readY(i)[0];
if (compar_f(val, value)) {
auto it = dets.begin();
for (; it != dets.end(); ++it)
for (auto it = dets.cbegin(); it != dets.cend(); ++it)
umap.insert(std::make_pair(*it, select_on));
}
}
......
......@@ -196,7 +196,7 @@ void MergeRuns::buildAdditionTables() {
// and rhs have 1 detector per pixel
detid2index_map::const_iterator map_it =
lhs_det_to_wi.find(rhs_detector_ID);
if (map_it != lhs_det_to_wi.end()) {
if (map_it != lhs_det_to_wi.cend()) {
outWI = static_cast<int>(map_it->second); // This is the workspace
// index in the LHS that
// matched rhs_detector_ID
......
......@@ -288,7 +288,7 @@ bool MonteCarloAbsorption::attenuationFactor(const V3D &startPos,
return false;
}
double length = beforeScatter.begin()->distInsideObject;
double length = beforeScatter.cbegin()->distInsideObject;
factor *= attenuation(length, *m_sampleMaterial, lambda);
beforeScatter.clearIntersectionResults();
......@@ -296,14 +296,13 @@ bool MonteCarloAbsorption::attenuationFactor(const V3D &startPos,
m_container->interceptSurfaces(beforeScatter);
}
// Attenuation factor is product of factor for each material
auto cend = beforeScatter.end();
for (auto citr = beforeScatter.begin(); citr != cend;
for (auto citr = beforeScatter.cbegin(); citr != beforeScatter.cend();
++citr) {
length = citr->distInsideObject;
factor *= attenuation(length, citr->object->material(), lambda);
}
length = afterScatter.begin()->distInsideObject;
length = afterScatter.cbegin()->distInsideObject;
factor *= attenuation(length, *m_sampleMaterial, lambda);
afterScatter.clearIntersectionResults();
......@@ -311,9 +310,7 @@ bool MonteCarloAbsorption::attenuationFactor(const V3D &startPos,
m_container->interceptSurfaces(afterScatter);
}
// Attenuation factor is product of factor for each material
cend = afterScatter.end();
for (auto citr = afterScatter.begin(); citr != cend;
++citr) {
for (auto citr = afterScatter.cbegin(); citr != afterScatter.cend(); ++citr) {
length = citr->distInsideObject;
factor *= attenuation(length, citr->object->material(), lambda);
}
......
......@@ -201,8 +201,8 @@ void Q1D2::exec() {
convertWavetoQ(i, doGravity, wavStart, QIn, getProperty("ExtraLength"));
// Pointers to the counts data and it's error
auto YIn = m_dataWS->readY(i).begin() + wavStart;
auto EIn = m_dataWS->readE(i).begin() + wavStart;
auto YIn = m_dataWS->readY(i).cbegin() + wavStart;
auto EIn = m_dataWS->readE(i).cbegin() + wavStart;
// Pointers to the QResolution data. Note that the xdata was initially the
// same, hence
......@@ -211,14 +211,14 @@ void Q1D2::exec() {
// that does not matter, as
// we won't use it
auto QResIn =
useQResolution ? (qResolution->readY(i).begin() + wavStart) : YIn;
useQResolution ? (qResolution->readY(i).cbegin() + wavStart) : YIn;
// when finding the output Q bin remember that the input Q bins (from the
// convert to wavelength) start high and reduce
auto loc = QOut.end();
auto loc = QOut.cend();
// sum the Q contributions from each individual spectrum into the output
// array
const MantidVec::const_iterator end = m_dataWS->readY(i).end();
const auto end = m_dataWS->readY(i).cend();
for (; YIn != end; ++YIn, ++EIn, ++QIn, ++norms, ++normETo2s) {
// find the output bin that each input y-value will fall into, remembering
// there is one more bin boundary than bins
......@@ -267,7 +267,7 @@ void Q1D2::exec() {
// The number of Q (x)_ values is N, while the number of DeltaQ values is
// N-1,
// Richard Heenan suggested to duplicate the last entry of DeltaQ
Mantid::MantidVec::const_iterator countsIterator = YOut.begin();
auto countsIterator = YOut.cbegin();
auto qResolutionIterator = qResolutionOut.begin();
for (; countsIterator != YOut.end();
++countsIterator, ++qResolutionIterator) {
......@@ -570,7 +570,7 @@ void Q1D2::convertWavetoQ(const size_t specInd, const bool doGravity,
IDetector_const_sptr det = m_dataWS->getDetector(specInd);
// wavelengths (lamda) to be converted to Q
auto waves = m_dataWS->readX(specInd).begin() + offset;
auto waves = m_dataWS->readX(specInd).cbegin() + offset;
// going from bin boundaries to bin centered x-values the size goes down one
const MantidVec::const_iterator end = m_dataWS->readX(specInd).end() - 1;
if (doGravity) {
......
......@@ -38,8 +38,8 @@ void Qhelper::examineInput(API::MatrixWorkspace_const_sptr dataWS,
// We require the same binning for the input workspace and the q resolution
// workspace
auto reqX = dataWS->readX(0).begin();
auto qResX = qResolution->readX(0).begin();
auto reqX = dataWS->readX(0).cbegin();
auto qResX = qResolution->readX(0).cbegin();
for (; reqX != dataWS->readX(0).end(); ++reqX, ++qResX) {
if (*reqX != *qResX) {
throw std::invalid_argument(
......@@ -77,9 +77,9 @@ void Qhelper::examineInput(API::MatrixWorkspace_const_sptr dataWS,
throw std::invalid_argument("The WavelengthAdj workspace's bins must "
"match those of the detector bank workspace");
}
auto reqX = dataWS->readX(0).begin();
auto testX = binAdj->readX(0).begin();
for (; reqX != dataWS->readX(0).end(); ++reqX, ++testX) {
auto reqX = dataWS->readX(0).cbegin();
auto testX = binAdj->readX(0).cbegin();
for (; reqX != dataWS->readX(0).cend(); ++reqX, ++testX) {
if (*reqX != *testX) {
throw std::invalid_argument("The WavelengthAdj workspace must have "
"matching bins with the detector bank "
......
......@@ -356,7 +356,7 @@ void Rebin::propagateMasks(API::MatrixWorkspace_const_sptr inputWS,
// Get a reference to the list of masked bins for this spectrum
const MatrixWorkspace::MaskList &mask = inputWS->maskedBins(hist);
// Now iterate over the list, building up a vector of the masked bins
auto it = mask.begin();
auto it = mask.cbegin();
const MantidVec &XValues = inputWS->readX(hist);
masked_bins.push_back(XValues[(*it).first]);
weights.push_back((*it).second);
......
......@@ -193,9 +193,8 @@ int Regroup::newAxis(const std::vector<double> &params,
int isteps = ibounds - 1; // highest index in params array containing a step
xcurr = params[0];
auto iup =
std::find_if(xold.begin(), xold.end(),
std::bind2nd(std::greater_equal<double>(), xcurr));
auto iup = std::find_if(xold.cbegin(), xold.cend(),
std::bind2nd(std::greater_equal<double>(), xcurr));
if (iup != xold.end()) {
xcurr = *iup;
xnew.push_back(xcurr);
......
......@@ -304,9 +304,8 @@ void RemoveBins::calculateDetectorPosition(const int &index, double &l1,
* the vector)
*/
int RemoveBins::findIndex(const double &value, const MantidVec &vec) {
auto pos =
std::lower_bound(vec.begin(), vec.end(), value);
return static_cast<int>(pos - vec.begin());
auto pos = std::lower_bound(vec.cbegin(), vec.cend(), value);
return static_cast<int>(std::distance(vec.cbegin(), pos));
}
/** Zeroes data (Y/E) at the end of a spectrum
......
......@@ -148,8 +148,7 @@ void RemoveLowResTOF::exec() {
// calculate where to zero out to
double tofMin = this->calcTofMin(workspaceIndex);
const MantidVec &X = m_inputWS->readX(0);
auto last =
std::lower_bound(X.begin(), X.end(), tofMin);
auto last = std::lower_bound(X.cbegin(), X.cend(), tofMin);
if (last == X.end())
--last;
size_t endBin = last - X.begin();
......@@ -309,8 +308,7 @@ double RemoveLowResTOF::calcTofMin(const std::size_t workspaceIndex) {
}
} else {
double l2 = 0;
for (auto it = detSet.begin();
it != detSet.end(); ++it) {
for (auto it = detSet.cbegin(); it != detSet.cend(); ++it) {
l2 += m_instrument->getDetector(*it)->getDistance(*m_sample);
}
l2 /= static_cast<double>(detSet.size());
......
......@@ -170,7 +170,7 @@ int SmoothData::validateSpectrumInGroup(size_t wi) {
return -1;
}
auto it = dets.begin();
auto it = dets.cbegin();
if (*it < 0) // bad pixel id
return -1;
......
......@@ -543,8 +543,7 @@ Check whether the properties provided are all in their default state.
*/
bool areAllDefault(ConstVecProperties &properties) {
bool areAllDefault = false;
for (auto it = properties.begin();
it != properties.end(); ++it) {
for (auto it = properties.cbegin(); it != properties.cend(); ++it) {
if (!(*it)->isDefault()) {
return areAllDefault;
}
......
......@@ -176,8 +176,7 @@ void SpatialGrouping::exec() {
inputWorkspace->getIndexFromSpectrumNumber((*grpIt)[i]);
const std::set<detid_t> &detIds =
inputWorkspace->getSpectrum(workspaceIndex)->getDetectorIDs();
for (auto it = detIds.begin();
it != detIds.end(); ++it) {
for (auto it = detIds.cbegin(); it != detIds.cend(); ++it) {
xml << "," << (*it);
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment