Skip to content

Commit 7a53a11

Browse files
committed
Use compile time constants instead of calling size() on arrays
1 parent c9f8cb0 commit 7a53a11

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

PWGHF/TableProducer/candidateCreatorXicToXiPiPi.cxx

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -243,10 +243,11 @@ struct HfCandidateCreatorXicToXiPiPi {
243243
std::array<float, 21> covCasc = {0.};
244244

245245
//----------------create cascade track------------------------------------------------------------
246-
constexpr std::array<int, 6> MomInd = {9, 13, 14, 18, 19, 20}; // cov matrix elements for momentum component
247-
for (auto i = 0u; i < MomInd.size(); i++) {
248-
covCasc[MomInd[i]] = casc.momentumCovMat()[i];
246+
constexpr std::size_t NElementsCovMatrix{6u};
247+
constexpr std::array<int, NElementsCovMatrix> MomInd = {9, 13, 14, 18, 19, 20}; // cov matrix elements for momentum component
248+
for (auto i = 0u; i < NElementsCovMatrix; i++) {
249249
covCasc[i] = casc.positionCovMat()[i];
250+
covCasc[MomInd[i]] = casc.momentumCovMat()[i];
250251
}
251252
// create cascade track
252253
o2::track::TrackParCov trackCasc;
@@ -496,11 +497,10 @@ struct HfCandidateCreatorXicToXiPiPi {
496497

497498
// create Xi as KFParticle object
498499
// read {X,Y,Z,Px,Py,Pz} and corresponding covariance matrix from KF cascade Tables
499-
std::array<float, 6> xyzpxpypz = {casc.x(), casc.y(), casc.z(), casc.px(), casc.py(), casc.pz()};
500-
float parPosMom[6];
501-
for (auto i = 0u; i < xyzpxpypz.size(); ++i) {
502-
parPosMom[i] = xyzpxpypz[i];
503-
}
500+
constexpr std::size_t NElementsStateVector{6};
501+
std::array<float, NElementsStateVector> xyzpxpypz = {casc.x(), casc.y(), casc.z(), casc.px(), casc.py(), casc.pz()};
502+
float parPosMom[NElementsStateVector];
503+
std::copy(xyzpxpypz.begin(), xyzpxpypz.end(), parPosMom);
504504
// create KFParticle
505505
KFParticle kfXi;
506506
float massXi = casc.mXi();
@@ -901,8 +901,9 @@ struct HfCandidateCreatorXicToXiPiPiExpressions {
901901
int8_t debug = 0;
902902
// for resonance matching:
903903
std::vector<int> arrDaughIndex;
904-
std::array<int, 2> arrPDGDaugh;
905-
std::array<int, 2> arrXiResonance = {3324, kPiPlus}; // 3324: Ξ(1530)
904+
constexpr std::size_t NDaughtersResonant{2u};
905+
std::array<int, NDaughtersResonant> arrPDGDaugh;
906+
std::array<int, NDaughtersResonant> arrXiResonance = {3324, kPiPlus}; // 3324: Ξ(1530)
906907

907908
// Match reconstructed candidates.
908909
for (const auto& candidate : *rowCandidateXic) {
@@ -943,8 +944,8 @@ struct HfCandidateCreatorXicToXiPiPiExpressions {
943944
}
944945
if (indexRec > -1) {
945946
RecoDecay::getDaughters(mcParticles.rawIteratorAt(indexRecXicPlus), &arrDaughIndex, std::array{0}, 1);
946-
if (arrDaughIndex.size() == arrXiResonance.size()) {
947-
for (auto iProng = 0u; iProng < arrDaughIndex.size(); ++iProng) {
947+
if (arrDaughIndex.size() == NDaughtersResonant) {
948+
for (auto iProng = 0u; iProng < NDaughtersResonant; ++iProng) {
948949
auto daughI = mcParticles.rawIteratorAt(arrDaughIndex[iProng]);
949950
arrPDGDaugh[iProng] = std::abs(daughI.pdgCode());
950951
}
@@ -1011,7 +1012,7 @@ struct HfCandidateCreatorXicToXiPiPiExpressions {
10111012
auto cascMC = mcParticles.rawIteratorAt(particle.daughtersIds().front());
10121013
// Find Xi- from Xi(1530) -> Xi pi in case of resonant decay
10131014
RecoDecay::getDaughters(particle, &arrDaughIndex, std::array{0}, 1);
1014-
if (arrDaughIndex.size() == arrXiResonance.size()) {
1015+
if (arrDaughIndex.size() == NDaughtersResonant) {
10151016
auto cascStarMC = mcParticles.rawIteratorAt(particle.daughtersIds().front());
10161017
if (RecoDecay::isMatchedMCGen<false, true>(mcParticles, cascStarMC, +3324, std::array{+kXiMinus, +kPiPlus}, true)) {
10171018
cascMC = mcParticles.rawIteratorAt(cascStarMC.daughtersIds().front());
@@ -1023,8 +1024,8 @@ struct HfCandidateCreatorXicToXiPiPiExpressions {
10231024
auto v0MC = mcParticles.rawIteratorAt(cascMC.daughtersIds().front());
10241025
if (RecoDecay::isMatchedMCGen<false, true>(mcParticles, v0MC, +kLambda0, std::array{+kProton, +kPiMinus}, true)) {
10251026
debug = 3;
1026-
if (arrDaughIndex.size() == arrXiResonance.size()) {
1027-
for (auto iProng = 0u; iProng < arrDaughIndex.size(); ++iProng) {
1027+
if (arrDaughIndex.size() == NDaughtersResonant) {
1028+
for (auto iProng = 0u; iProng < NDaughtersResonant; ++iProng) {
10281029
auto daughI = mcParticles.rawIteratorAt(arrDaughIndex[iProng]);
10291030
arrPDGDaugh[iProng] = std::abs(daughI.pdgCode());
10301031
}

0 commit comments

Comments
 (0)