Skip to content

Commit 78d5777

Browse files
committed
ReconstructionDataFormats: express the SMatrix aliases in GPUdoubleCalc
MatrixDSym5 and MatrixD5 were kept off Metal because SMatrix<double> cannot be named there, which left the track-to-track chi2 and update out of the device build. Spelling them in GPUdoubleCalc brings them back: it is double on every other backend and on the host, so the aliases and everything using them are unchanged there, and on Metal they become the compensated two-float type that the rest of this file already uses. The two remaining explicit doubles go the same way, and the SMatrix written out in full is just MatrixD5.
1 parent bc8eedf commit 78d5777

2 files changed

Lines changed: 5 additions & 12 deletions

File tree

‎DataFormats/Reconstruction/include/ReconstructionDataFormats/TrackParametrizationWithError.h‎

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#ifndef INCLUDE_RECONSTRUCTIONDATAFORMATS_TRACKPARAMETRIZATIONWITHERROR_H_
1818
#define INCLUDE_RECONSTRUCTIONDATAFORMATS_TRACKPARAMETRIZATIONWITHERROR_H_
1919

20+
#include "GPUCommonDouble.h"
2021
#include "ReconstructionDataFormats/TrackParametrization.h"
2122
#include <MathUtils/Cartesian.h>
2223

@@ -41,10 +42,8 @@ class TrackParametrizationWithError : public TrackParametrization<value_T>
4142
#endif
4243

4344
using covMat_t = std::array<value_t, kCovMatSize>;
44-
#ifndef __METAL__
45-
using MatrixDSym5 = o2::math_utils::SMatrix<double, kNParams, kNParams, o2::math_utils::MatRepSym<double, kNParams>>;
46-
using MatrixD5 = o2::math_utils::SMatrix<double, kNParams, kNParams, o2::math_utils::MatRepStd<double, kNParams, kNParams>>;
47-
#endif
45+
using MatrixDSym5 = o2::math_utils::SMatrix<o2::gpu::GPUdoubleCalc, kNParams, kNParams, o2::math_utils::MatRepSym<o2::gpu::GPUdoubleCalc, kNParams>>;
46+
using MatrixD5 = o2::math_utils::SMatrix<o2::gpu::GPUdoubleCalc, kNParams, kNParams, o2::math_utils::MatRepStd<o2::gpu::GPUdoubleCalc, kNParams, kNParams>>;
4847

4948
GPUhd() TrackParametrizationWithError();
5049
GPUd() TrackParametrizationWithError(value_t x, value_t alpha, const params_t& par, const covMat_t& cov, int charge = 1, const PID pid = PID::Pion);
@@ -113,18 +112,12 @@ class TrackParametrizationWithError : public TrackParametrization<value_T>
113112
template <typename T>
114113
GPUd() value_t getPredictedChi2Quiet(const BaseCluster<T>& p) const;
115114

116-
#ifndef __METAL__
117115
GPUd() void buildCombinedCovMatrix(const TrackParametrizationWithError& rhs, MatrixDSym5& cov) const;
118-
#endif
119-
#ifndef __METAL__
120116
GPUd() value_t getPredictedChi2(const TrackParametrizationWithError& rhs, MatrixDSym5& covToSet) const;
121-
#endif
122117
GPUd() value_t getPredictedChi2(const TrackParametrizationWithError& rhs) const;
123118
GPUd() value_t getPredictedChi2Fast(const TrackParametrizationWithError& rhs) const;
124119
GPUd() value_t getPredictedChi2Quiet(const TrackParametrizationWithError& rhs) const;
125-
#ifndef __METAL__
126120
GPUd() bool update(const TrackParametrizationWithError& rhs, const MatrixDSym5& covInv);
127-
#endif
128121
GPUd() bool update(const TrackParametrizationWithError& rhs);
129122

130123
GPUd() bool update(const dim2_t& p, const dim3_t& cov);

‎DataFormats/Reconstruction/src/TrackParametrizationWithError.cxx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1174,7 +1174,7 @@ GPUd() auto TrackParametrizationWithError<value_T>::getPredictedChi2Fast(const T
11741174
// chi2 = d^T C^-1 d = sum_i y_i^2 / D_i with y from the forward substitution L y = d
11751175
GPUdoubleCalc chi2 = 0., y[kNParams];
11761176
for (int i = 0; i < kNParams; i++) {
1177-
GPUdoubleCalc s = double(this->getParam(i)) - double(rhs.getParam(i));
1177+
GPUdoubleCalc s = GPUdoubleCalc(this->getParam(i)) - GPUdoubleCalc(rhs.getParam(i));
11781178
for (int k = 0; k < i; k++) {
11791179
s -= lmat[i][k] * y[k];
11801180
}
@@ -1287,7 +1287,7 @@ GPUd() bool TrackParametrizationWithError<value_T>::update(const TrackParametriz
12871287
}
12881288

12891289
// updated covariance: Cov0 = Cov0 - K*Cov0
1290-
matK *= o2::math_utils::SMatrix<double, kNParams, kNParams, o2::math_utils::MatRepStd<double, kNParams>>(matC0);
1290+
matK *= MatrixD5(matC0);
12911291
mC[kSigY2] -= matK(kY, kY);
12921292
mC[kSigZY] -= matK(kZ, kY);
12931293
mC[kSigZ2] -= matK(kZ, kZ);

0 commit comments

Comments
 (0)