Skip to content

Commit e5843f5

Browse files
committed
some modernize-avoid-c-arrays
1 parent 6d07275 commit e5843f5

1 file changed

Lines changed: 16 additions & 22 deletions

File tree

PWGDQ/Core/VarManager.h

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1661,15 +1661,12 @@ KFPTrack VarManager::createKFPTrackFromTrack(const T& track)
16611661
trackparCov.getXYZGlo(trkpos_par);
16621662
trackparCov.getPxPyPzGlo(trkmom_par);
16631663
trackparCov.getCovXYZPxPyPzGlo(trk_cov);
1664-
float trkpar_KF[6] = {trkpos_par[0], trkpos_par[1], trkpos_par[2],
1665-
trkmom_par[0], trkmom_par[1], trkmom_par[2]};
1666-
float trkcov_KF[21];
1667-
for (int i = 0; i < 21; i++) {
1668-
trkcov_KF[i] = trk_cov[i];
1669-
}
1664+
std::array<float, 6> trkpar_KF = {trkpos_par[0], trkpos_par[1], trkpos_par[2],
1665+
trkmom_par[0], trkmom_par[1], trkmom_par[2]};
1666+
std::array<float, 21> trkcov_KF = trk_cov;
16701667
KFPTrack kfpTrack;
1671-
kfpTrack.SetParameters(trkpar_KF);
1672-
kfpTrack.SetCovarianceMatrix(trkcov_KF);
1668+
kfpTrack.SetParameters(trkpar_KF.data());
1669+
kfpTrack.SetCovarianceMatrix(trkcov_KF.data());
16731670
kfpTrack.SetCharge(track.sign());
16741671
kfpTrack.SetNDF(track.tpcNClsFound() - 5);
16751672
kfpTrack.SetChi2(track.tpcChi2NCl() * track.tpcNClsFound());
@@ -1683,15 +1680,12 @@ KFPTrack VarManager::createKFPFwdTrackFromFwdTrack(const T& muon)
16831680

16841681
std::array<float, 21> trk_cov{};
16851682
trackparCov.getCovXYZPxPyPzGlo(trk_cov);
1686-
double trkpar_KF[6] = {trackparCov.getX(), trackparCov.getY(), trackparCov.getZ(),
1687-
trackparCov.getPx(), trackparCov.getPy(), trackparCov.getPz()};
1688-
float trkcov_KF[21];
1689-
for (int i = 0; i < 21; i++) {
1690-
trkcov_KF[i] = trk_cov[i];
1691-
}
1683+
std::array<double, 6> trkpar_KF = {trackparCov.getX(), trackparCov.getY(), trackparCov.getZ(),
1684+
trackparCov.getPx(), trackparCov.getPy(), trackparCov.getPz()};
1685+
std::array<float, 21> trkcov_KF = trk_cov;
16921686
KFPTrack kfpTrack;
1693-
kfpTrack.SetParameters(trkpar_KF);
1694-
kfpTrack.SetCovarianceMatrix(trkcov_KF);
1687+
kfpTrack.SetParameters(trkpar_KF.data());
1688+
kfpTrack.SetCovarianceMatrix(trkcov_KF.data());
16951689
kfpTrack.SetCharge(muon.sign());
16961690
kfpTrack.SetNDF(muon.nClusters() - 5);
16971691
kfpTrack.SetChi2(muon.chi2());
@@ -3487,7 +3481,7 @@ void VarManager::FillTrackCollisionMC(T1 const& track, T2 const& MotherTrack, C
34873481
}
34883482

34893483
// Extract the collision primary vertex position using constexpr, since the collision type may be CollisionMC or ReducedMCEvent
3490-
double collPos[3] = {0.0, 0.0, 0.0};
3484+
std::array<double, 3> collPos = {0.0, 0.0, 0.0};
34913485
if constexpr (fillMap & ObjTypes::CollisionMC) {
34923486
collPos[0] = collision.posX();
34933487
collPos[1] = collision.posY();
@@ -5109,9 +5103,9 @@ void VarManager::FillPairVertexing(C const& collision, T const& t1, T const& t2,
51095103
auto geoMan2 = o2::base::GeometryManager::meanMaterialBudget(t2.x(), t2.y(), t2.z(), KFGeoTwoProng.GetX(), KFGeoTwoProng.GetY(), KFGeoTwoProng.GetZ());
51105104
auto x2x01 = static_cast<float>(geoMan1.meanX2X0);
51115105
auto x2x02 = static_cast<float>(geoMan2.meanX2X0);
5112-
float B[3];
5113-
float xyz[3] = {0, 0, 0};
5114-
KFGeoTwoProng.GetFieldValue(xyz, B);
5106+
std::array<float, 3> B{};
5107+
std::array<float, 3> xyz = {0.f, 0.f, 0.f};
5108+
KFGeoTwoProng.GetFieldValue(xyz.data(), B.data());
51155109
// TODO: find better soluton to handle cases where KF outputs negative variances
51165110
/*float covXX = 0.1;
51175111
float covYY = 0.1;
@@ -5963,8 +5957,8 @@ void VarManager::FillSpectatorPlane(C const& collision, float* values)
59635957
values[kTimeZPC] = collision.timeZPC();
59645958

59655959
constexpr float beamEne = 5.36 * 0.5;
5966-
constexpr float x[4] = {-1.75, 1.75, -1.75, 1.75};
5967-
constexpr float y[4] = {-1.75, -1.75, 1.75, 1.75};
5960+
constexpr std::array<float, 4> x = {-1.75f, 1.75f, -1.75f, 1.75f};
5961+
constexpr std::array<float, 4> y = {-1.75f, -1.75f, 1.75f, 1.75f};
59685962
// constexpr float intcalibZNA[4] = {0.7997028, 0.8453715, 0.7879917, 0.7695486};
59695963
// constexpr float intcalibZNC[4] = {0.7631577, 0.8408003, 0.7083920, 0.7731769};
59705964
// constexpr float alpha = 0.395; // WARNING: Run 2 coorection, to be checked

0 commit comments

Comments
 (0)