Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: brace-enclosed initializers for pair/tuple returns #3931

Merged
merged 5 commits into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Core/include/Acts/EventData/MultiComponentTrackParameters.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,11 @@ class MultiComponentBoundTrackParameters {

/// Get the weight and a GenericBoundTrackParameters object for one component
std::pair<double, Parameters> operator[](std::size_t i) const {
return std::make_pair(
return {
std::get<double>(m_components[i]),
Parameters(m_surface, std::get<BoundVector>(m_components[i]),
std::get<std::optional<BoundSquareMatrix>>(m_components[i]),
m_particleHypothesis));
m_particleHypothesis)};
}

/// Parameters vector.
Expand Down
2 changes: 1 addition & 1 deletion Core/include/Acts/Seeding/BinnedGroupIterator.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ Acts::BinnedGroupIterator<grid_t>::operator*() const {
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstringop-overread"
#endif
return std::make_tuple(std::move(bottoms), global_index, std::move(tops));
return {std::move(bottoms), global_index, std::move(tops)};
#if defined(__GNUC__) && __GNUC__ >= 12 && !defined(__clang__)
#pragma GCC diagnostic pop
#endif
Expand Down
7 changes: 3 additions & 4 deletions Core/include/Acts/Seeding/SeedFinder.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -839,7 +839,7 @@ std::pair<float, float> SeedFinder<external_spacepoint_t, grid_t, platform_t>::
const external_spacepoint_t& spM,
const Acts::Range1D<float>& rMiddleSPRange) const {
if (m_config.useVariableMiddleSPRange) {
return std::make_pair(rMiddleSPRange.min(), rMiddleSPRange.max());
return {rMiddleSPRange.min(), rMiddleSPRange.max()};
}
if (!m_config.rRangeMiddleSP.empty()) {
/// get zBin position of the middle SP
Expand All @@ -848,10 +848,9 @@ std::pair<float, float> SeedFinder<external_spacepoint_t, grid_t, platform_t>::
int zBin = std::distance(m_config.zBinEdges.begin(), pVal);
/// protects against zM at the limit of zBinEdges
zBin == 0 ? zBin : --zBin;
return std::make_pair(m_config.rRangeMiddleSP[zBin][0],
m_config.rRangeMiddleSP[zBin][1]);
return {m_config.rRangeMiddleSP[zBin][0], m_config.rRangeMiddleSP[zBin][1]};
}
return std::make_pair(m_config.rMinMiddle, m_config.rMaxMiddle);
return {m_config.rMinMiddle, m_config.rMaxMiddle};
}

} // namespace Acts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ globalTrackParametersCovariance(const traj_t& multiTraj,
prev_ts = ts;
});

return std::make_pair(fullGlobalTrackParamsCov, stateRowIndices);
return {fullGlobalTrackParamsCov, stateRowIndices};
}

} // namespace Acts::detail
4 changes: 2 additions & 2 deletions Core/include/Acts/Utilities/GridBinFinder.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ std::array<std::pair<int, int>, DIM> Acts::GridBinFinder<DIM>::getSizePerAxis(
using value_t = typename std::decay_t<decltype(val)>;
if constexpr (std::is_same_v<int, value_t>) {
assert(val >= 0);
return std::make_pair(-val, val);
return {-val, val};
} else if constexpr (std::is_same_v<std::pair<int, int>, value_t>) {
return std::make_pair(-val.first, val.second);
return {-val.first, val.second};
} else {
assert(locPosition.size() > i);
assert(locPosition[i] > 0ul);
Expand Down
14 changes: 7 additions & 7 deletions Core/include/Acts/Utilities/TrackHelpers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ findTrackStateForExtrapolation(
}

ACTS_VERBOSE("found intersection at " << intersection.pathLength());
return std::make_pair(*first, intersection.pathLength());
return std::pair(*first, intersection.pathLength());
}

case TrackExtrapolationStrategy::last: {
Expand All @@ -229,7 +229,7 @@ findTrackStateForExtrapolation(
}

ACTS_VERBOSE("found intersection at " << intersection.pathLength());
return std::make_pair(*last, intersection.pathLength());
return std::pair(*last, intersection.pathLength());
}

case TrackExtrapolationStrategy::firstOrLast: {
Expand All @@ -256,13 +256,13 @@ findTrackStateForExtrapolation(
if (intersectionFirst.isValid() && absDistanceFirst <= absDistanceLast) {
ACTS_VERBOSE("using first track state with intersection at "
<< intersectionFirst.pathLength());
return std::make_pair(*first, intersectionFirst.pathLength());
return std::pair(*first, intersectionFirst.pathLength());
}

if (intersectionLast.isValid() && absDistanceLast <= absDistanceFirst) {
ACTS_VERBOSE("using last track state with intersection at "
<< intersectionLast.pathLength());
return std::make_pair(*last, intersectionLast.pathLength());
return std::pair(*last, intersectionLast.pathLength());
}

ACTS_ERROR("no intersection found");
Expand Down Expand Up @@ -530,7 +530,7 @@ calculatePredictedResidual(track_state_proxy_t trackState) {
MeasurementMatrix residualCovariance =
measurementCovariance + predictedCovariance;

return std::pair(residual, residualCovariance);
return {residual, residualCovariance};
}

/// Helper function to calculate the filtered residual and its covariance
Expand Down Expand Up @@ -566,7 +566,7 @@ calculateFilteredResidual(track_state_proxy_t trackState) {
MeasurementMatrix residualCovariance =
measurementCovariance + filteredCovariance;

return std::pair(residual, residualCovariance);
return {residual, residualCovariance};
}

/// Helper function to calculate the smoothed residual and its covariance
Expand Down Expand Up @@ -602,7 +602,7 @@ calculateSmoothedResidual(track_state_proxy_t trackState) {
MeasurementMatrix residualCovariance =
measurementCovariance + smoothedCovariance;

return std::pair(residual, residualCovariance);
return {residual, residualCovariance};
}

/// Helper function to calculate the predicted chi2
Expand Down
3 changes: 1 addition & 2 deletions Core/src/Propagator/detail/CovarianceEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,7 @@ CurvilinearState detail::curvilinearState(
pos4, direction, freeParameters[eFreeQOverP], std::move(cov),
particleHypothesis);
// Create the curvilinear state
return std::make_tuple(std::move(curvilinearParams), fullTransportJacobian,
accumulatedPath);
return {std::move(curvilinearParams), fullTransportJacobian, accumulatedPath};
}

void detail::transportCovarianceToBound(
Expand Down
3 changes: 1 addition & 2 deletions Core/src/Propagator/detail/SympyCovarianceEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,7 @@ CurvilinearState sympy::curvilinearState(
pos4, direction, freeParameters[eFreeQOverP], std::move(cov),
particleHypothesis);
// Create the curvilinear state
return std::make_tuple(std::move(curvilinearParams), fullTransportJacobian,
accumulatedPath);
return {std::move(curvilinearParams), fullTransportJacobian, accumulatedPath};
}

void sympy::transportCovarianceToBound(
Expand Down
4 changes: 2 additions & 2 deletions Core/src/Surfaces/detail/AlignmentHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,6 @@ Acts::detail::RotationToAxes Acts::detail::rotationToLocalAxesDerivative(
rotToCompositeLocalYAxis * relRotation(1, 2) +
rotToCompositeLocalZAxis * relRotation(2, 2);

return std::make_tuple(std::move(rotToLocalXAxis), std::move(rotToLocalYAxis),
std::move(rotToLocalZAxis));
return {std::move(rotToLocalXAxis), std::move(rotToLocalYAxis),
std::move(rotToLocalZAxis)};
}
2 changes: 1 addition & 1 deletion Core/src/Surfaces/detail/AnnulusBoundsHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,5 @@ Acts::detail::AnnulusBoundsHelper::create(const Transform3& transform,
auto annulusBounds = std::make_shared<AnnulusBounds>(
rMin, rMax, phiMin, phiMax, originShift, phiShift);

return std::make_tuple(annulusBounds, boundsTransform);
return {annulusBounds, boundsTransform};
}
2 changes: 1 addition & 1 deletion Core/src/Utilities/SpacePointUtility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ SpacePointUtility::globalCoords(
tcov = std::nullopt;
}

return std::make_tuple(globalPos, globalTime, gcov, tcov);
return {globalPos, globalTime, gcov, tcov};
}

Vector2 SpacePointUtility::calcRhoZVars(
Expand Down
2 changes: 1 addition & 1 deletion Core/src/Vertexing/AdaptiveGridTrackDensity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ AdaptiveGridTrackDensity::getMaxZTPosition(DensityMap& densityMap) const {
double maxZ = getSpatialBinCenter(bin.first);
double maxT = getTemporalBinCenter(bin.second);

return std::make_pair(maxZ, maxT);
return std::pair(maxZ, maxT);
}

Result<AdaptiveGridTrackDensity::ZTPositionAndWidth>
Expand Down
4 changes: 2 additions & 2 deletions Core/src/Vertexing/ImpactPointEstimator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ Result<std::pair<Vector4, Vector3>> getDistanceAndMomentumImpl(
Vector4 deltaRStraightTrack{Vector4::Zero()};
deltaRStraightTrack.head<nDim>() = pcaStraightTrack - vtxPos;

return std::make_pair(deltaRStraightTrack, momDirStraightTrack);
return std::pair(deltaRStraightTrack, momDirStraightTrack);
}

// Charged particles in a constant B field follow a helical trajectory. In
Expand Down Expand Up @@ -291,7 +291,7 @@ Result<std::pair<Vector4, Vector3>> getDistanceAndMomentumImpl(
Vector4 deltaR{Vector4::Zero()};
deltaR.head<nDim>() = pca - vtxPos;

return std::make_pair(deltaR, momDir);
return std::pair(deltaR, momDir);
}

} // namespace
Expand Down
2 changes: 1 addition & 1 deletion Core/src/Vertexing/Vertex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ const std::vector<TrackAtVertex>& Vertex::tracks() const {
}

std::pair<double, double> Vertex::fitQuality() const {
return std::pair<double, double>(m_chiSquared, m_numberDoF);
return {m_chiSquared, m_numberDoF};
}

void Vertex::setPosition(const Vector3& position) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,7 @@ auto AlignedDetector::finalize(
}

// return the pair of geometry and the alignment decorator(s)
return std::make_pair<TrackingGeometryPtr, ContextDecorators>(
std::move(aTrackingGeometry), std::move(aContextDecorators));
return {std::move(aTrackingGeometry), std::move(aContextDecorators)};
}

} // namespace ActsExamples
3 changes: 1 addition & 2 deletions Examples/Detectors/DD4hepDetector/src/DD4hepDetector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ auto DD4hepDetector::finalize(
}
ContextDecorators dd4ContextDecorators = {};
// return the pair of geometry and empty decorators
return std::make_pair<TrackingGeometryPtr, ContextDecorators>(
std::move(dd4tGeometry), std::move(dd4ContextDecorators));
return {std::move(dd4tGeometry), std::move(dd4ContextDecorators)};
}

auto DD4hepDetector::finalize(
Expand Down
3 changes: 1 addition & 2 deletions Examples/Detectors/GenericDetector/src/GenericDetector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ auto GenericDetector::finalize(
cfg.volumeLogLevel);
ContextDecorators gContextDecorators = {};
// return the pair of geometry and empty decorators
return std::make_pair<TrackingGeometryPtr, ContextDecorators>(
std::move(gGeometry), std::move(gContextDecorators));
return {std::move(gGeometry), std::move(gContextDecorators)};
}

} // namespace ActsExamples
3 changes: 1 addition & 2 deletions Examples/Detectors/TGeoDetector/src/TGeoDetector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -375,8 +375,7 @@ auto TGeoDetector::finalize(

ContextDecorators tgeoContextDecorators = {};
// Return the pair of geometry and empty decorators
return std::make_pair<TrackingGeometryPtr, ContextDecorators>(
std::move(tgeoTrackingGeometry), std::move(tgeoContextDecorators));
return {std::move(tgeoTrackingGeometry), std::move(tgeoContextDecorators)};
}

void TGeoDetector::Config::readJson(const std::string& jsonFile) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ auto TelescopeDetector::finalize(
static_cast<Acts::BinningValue>(cfg.binValue));
ContextDecorators gContextDecorators = {};
// return the pair of geometry and empty decorators
return std::make_pair<TrackingGeometryPtr, ContextDecorators>(
std::move(gGeometry), std::move(gContextDecorators));
return {std::move(gGeometry), std::move(gContextDecorators)};
}

} // namespace ActsExamples
26 changes: 13 additions & 13 deletions Examples/Framework/src/EventData/ScalingCalibrator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,22 +52,22 @@ std::pair<Acts::GeometryIdentifier, std::string> parseMapKey(
std::regex reg("^map_([0-9]+)-([0-9]+)-([0-9]+)_([xy]_.*)$");
std::smatch matches;

if (std::regex_search(mapkey, matches, reg) && matches.size() == 5) {
std::size_t vol = std::stoull(matches[1].str());
std::size_t lyr = std::stoull(matches[2].str());
std::size_t mod = std::stoull(matches[3].str());
if (!std::regex_search(mapkey, matches, reg) || matches.size() != 5) {
throw std::runtime_error("Invalid map key: " + mapkey);
}

Acts::GeometryIdentifier geoId;
geoId.setVolume(vol);
geoId.setLayer(lyr);
geoId.setSensitive(mod);
std::size_t vol = std::stoull(matches[1].str());
std::size_t lyr = std::stoull(matches[2].str());
std::size_t mod = std::stoull(matches[3].str());

std::string var(matches[4].str());
Acts::GeometryIdentifier geoId;
geoId.setVolume(vol);
geoId.setLayer(lyr);
geoId.setSensitive(mod);

return std::make_pair(geoId, var);
} else {
throw std::runtime_error("Invalid map key: " + mapkey);
}
std::string var(matches[4].str());

return {geoId, var};
}

std::map<Acts::GeometryIdentifier, ActsExamples::ScalingCalibrator::MapTuple>
Expand Down
4 changes: 2 additions & 2 deletions Examples/Framework/src/Utilities/Paths.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ std::pair<std::size_t, std::size_t> ActsExamples::determineEventFilesRange(

// should only occur if no files matched and the initial values persisted.
if (eventMax < eventMin) {
return std::make_pair(0u, 0u);
return {0u, 0u};
}
return std::make_pair(eventMin, eventMax + 1);
return {eventMin, eventMax + 1};
}
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ class RootMaterialDecorator : public Acts::IMaterialDecorator {

/// Return the maps
const Acts::DetectorMaterialMaps materialMaps() const {
return std::make_pair(m_surfaceMaterialMap, m_volumeMaterialMap);
return {m_surfaceMaterialMap, m_volumeMaterialMap};
}

/// Get readonly access to the config parameters
Expand Down
12 changes: 6 additions & 6 deletions Examples/Io/Root/src/RootNuclearInteractionParametersWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ buildNotNormalisedMap(TH1F const* hist) {
if (integral == 0.) {
histoBorders.clear();
temp_HistoContents.clear();
return std::make_tuple(histoBorders, temp_HistoContents, integral);
return {histoBorders, temp_HistoContents, integral};
}

// Set the bin borders
Expand All @@ -130,7 +130,7 @@ buildNotNormalisedMap(TH1F const* hist) {
}
histoBorders[nBins] = hist->GetXaxis()->GetXmax();

return std::make_tuple(histoBorders, temp_HistoContents, integral);
return {histoBorders, temp_HistoContents, integral};
}

/// @brief This function combines neighbouring bins with the same value
Expand Down Expand Up @@ -169,7 +169,7 @@ std::pair<std::vector<float>, std::vector<std::uint32_t>> buildMap(

// Fast exit if the histogram is empty
if (histoContents.empty()) {
return std::make_pair(std::get<0>(map), std::vector<std::uint32_t>());
return {std::get<0>(map), std::vector<std::uint32_t>()};
}

// Set the bin content
Expand All @@ -183,7 +183,7 @@ std::pair<std::vector<float>, std::vector<std::uint32_t>> buildMap(

auto histoBorders = std::get<0>(map);
reduceMap(histoBorders, normalisedHistoContents);
return std::make_pair(histoBorders, normalisedHistoContents);
return {histoBorders, normalisedHistoContents};
}

/// @brief This method transforms a probability distribution into components
Expand All @@ -208,7 +208,7 @@ std::pair<std::vector<float>, std::vector<std::uint32_t>> buildMap(

// Fast exit if the histogram is empty
if (histoContents.empty()) {
return std::make_pair(std::get<0>(map), std::vector<std::uint32_t>());
return {std::get<0>(map), std::vector<std::uint32_t>()};
}

// Set the bin content
Expand All @@ -223,7 +223,7 @@ std::pair<std::vector<float>, std::vector<std::uint32_t>> buildMap(
std::vector<float> histoBorders = std::get<0>(map);
reduceMap(histoBorders, normalisedHistoContents);

return std::make_pair(histoBorders, normalisedHistoContents);
return {histoBorders, normalisedHistoContents};
}

/// @brief This method builds decomposed cumulative probability distributions
Expand Down
6 changes: 3 additions & 3 deletions Examples/Io/Root/src/RootTrackStatesWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -471,13 +471,13 @@ ProcessCode RootTrackStatesWriter::writeT(const AlgorithmContext& ctx,
auto getTrackParams = [&](unsigned int ipar)
-> std::optional<std::pair<Acts::BoundVector, Acts::BoundMatrix>> {
if (ipar == ePredicted && state.hasPredicted()) {
return std::make_pair(state.predicted(), state.predictedCovariance());
return std::pair(state.predicted(), state.predictedCovariance());
}
if (ipar == eFiltered && state.hasFiltered()) {
return std::make_pair(state.filtered(), state.filteredCovariance());
return std::pair(state.filtered(), state.filteredCovariance());
}
if (ipar == eSmoothed && state.hasSmoothed()) {
return std::make_pair(state.smoothed(), state.smoothedCovariance());
return std::pair(state.smoothed(), state.smoothedCovariance());
}
if (ipar == eUnbiased && state.hasSmoothed() && state.hasProjector() &&
state.hasCalibrated()) {
Expand Down
Loading
Loading