Skip to content

Commit 7b75bac

Browse files
committed
code-checker fixes
1 parent 6344432 commit 7b75bac

1 file changed

Lines changed: 23 additions & 15 deletions

File tree

PWGDQ/Tasks/global-muon-matcher.cxx

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
#include <array>
6161
#include <chrono>
6262
#include <cmath>
63+
#include <cstddef>
6364
#include <cstdint>
6465
#include <exception>
6566
#include <functional>
@@ -288,7 +289,10 @@ struct GlobalMuonMatching {
288289
void setRemovable() { removable = true; }
289290
[[nodiscard]] bool isRemovable() const { return removable; }
290291

291-
[[nodiscard]] o2::track::TrackParCovFwd asTrackParCovFwd() const { return *this; }
292+
[[nodiscard]] o2::track::TrackParCovFwd asTrackParCovFwd() const
293+
{
294+
return o2::track::TrackParCovFwd(static_cast<const o2::track::TrackParCovFwd&>(*this));
295+
}
292296

293297
private:
294298
int nClusters{-1};
@@ -957,7 +961,7 @@ struct GlobalMuonMatching {
957961
using o2::aod::fwdtrack::ForwardTrackTypeEnum;
958962
using o2::aod::fwdtrackutils::propagationPoint;
959963

960-
constexpr uint8_t CandidateTrackType = static_cast<uint8_t>(ForwardTrackTypeEnum::GlobalForwardTrack);
964+
constexpr auto CandidateTrackType = static_cast<uint8_t>(ForwardTrackTypeEnum::GlobalForwardTrack);
961965

962966
auto propmuonAtMft = fwdToMch(mchPar);
963967
o2::mch::TrackExtrap::extrapToVertex(propmuonAtMft,
@@ -971,7 +975,7 @@ struct GlobalMuonMatching {
971975

972976
const auto nClusters = static_cast<int8_t>(std::min(127, mchPar.getNClusters() + mftPar.getNClusters()));
973977

974-
const float chi2 = static_cast<float>(mchTrack.chi2());
978+
const auto chi2 = static_cast<float>(mchTrack.chi2());
975979
const int32_t collisionId = mchTrack.collisionId();
976980
bool hasBcSlice = false;
977981
std::array<int32_t, 2> bcSlice{};
@@ -1547,14 +1551,16 @@ struct GlobalMuonMatching {
15471551
}
15481552

15491553
const int maxCandidates = configMatching.cfgMaxCandidatesPerMchTrack.value;
1550-
const size_t nToStore = (maxCandidates >= 0)
1551-
? std::min(groupResults.size(), static_cast<size_t>(maxCandidates))
1552-
: groupResults.size();
15531554

15541555
auto& storedCandidates = newMatchingCandidates[mchIndex];
1555-
for (size_t i = 0; i < nToStore; ++i) {
1556-
groupResults[i].mixedGroupIndex = useMixedMatchingCandidates ? mixedGroupIndex : -1;
1557-
storedCandidates.push_back(std::move(groupResults[i]));
1556+
size_t nStoredThisGroup = 0;
1557+
for (auto& result : groupResults) { // o2-linter: disable=const-ref-in-for-loop (object is modified in loop)
1558+
if (maxCandidates >= 0 && nStoredThisGroup >= static_cast<size_t>(maxCandidates)) {
1559+
break;
1560+
}
1561+
result.mixedGroupIndex = useMixedMatchingCandidates ? mixedGroupIndex : -1;
1562+
storedCandidates.push_back(result);
1563+
++nStoredThisGroup;
15581564
}
15591565
};
15601566

@@ -1638,14 +1644,16 @@ struct GlobalMuonMatching {
16381644
}
16391645

16401646
const int maxCandidates = configMatching.cfgMaxCandidatesPerMchTrack.value;
1641-
const size_t nToStore = (maxCandidates >= 0)
1642-
? std::min(groupResults.size(), static_cast<size_t>(maxCandidates))
1643-
: groupResults.size();
16441647

16451648
auto& storedCandidates = newMatchingCandidates[mchIndex];
1646-
for (size_t i = 0; i < nToStore; ++i) {
1647-
groupResults[i].mixedGroupIndex = useMixedMatchingCandidates ? mixedGroupIndex : -1;
1648-
storedCandidates.push_back(std::move(groupResults[i]));
1649+
size_t nStoredThisGroup = 0;
1650+
for (auto& result : groupResults) { // o2-linter: disable=const-ref-in-for-loop (object is modified in loop)
1651+
if (maxCandidates >= 0 && nStoredThisGroup >= static_cast<size_t>(maxCandidates)) {
1652+
break;
1653+
}
1654+
result.mixedGroupIndex = useMixedMatchingCandidates ? mixedGroupIndex : -1;
1655+
storedCandidates.push_back(result);
1656+
++nStoredThisGroup;
16491657
}
16501658
};
16511659

0 commit comments

Comments
 (0)