Skip to content

Commit 631b47c

Browse files
Compiles with skeleton class
1 parent 85944a0 commit 631b47c

4 files changed

Lines changed: 65 additions & 35 deletions

File tree

GPU/GPUTracking/SectorTracker/GPUTPCBaseTrackParam.h

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020

2121
namespace o2::gpu
2222
{
23-
class GPUTPCTrackParam;
2423

2524
/**
2625
* @class GPUTPCBaseTrackParam
@@ -31,7 +30,7 @@ class GPUTPCTrackParam;
3130
*/
3231
template <template <class> class F>
3332
struct GPUTPCBaseTrackParamSkeleton {
34-
GPUd() F<float> X() const { return mX; }
33+
GPUd() float X() const { return mX; }
3534
GPUd() float Y() const { return mP[0]; }
3635
GPUd() float Z() const { return mP[1]; }
3736
GPUd() float SinPhi() const { return mP[2]; }
@@ -48,7 +47,7 @@ struct GPUTPCBaseTrackParamSkeleton {
4847
GPUd() float GetCov(int32_t i) const { return mC[i]; }
4948
GPUhd() void SetCov(int32_t i, float v) { mC[i] = v; }
5049

51-
GPUhd() F<float> GetX() const { return mX; }
50+
GPUhd() float GetX() const { return mX; }
5251
GPUhd() float GetY() const { return mP[0]; }
5352
GPUhd() float GetZ() const { return mP[1]; }
5453
GPUhd() float GetSinPhi() const { return mP[2]; }
@@ -64,7 +63,7 @@ struct GPUTPCBaseTrackParamSkeleton {
6463

6564
GPUhd() void SetPar(int32_t i, float v) { mP[i] = v; }
6665

67-
GPUd() void SetX(F<float> v) { mX = v; }
66+
GPUd() void SetX(float v) { mX = v; }
6867
GPUd() void SetY(float v) { mP[0] = v; }
6968
GPUd() void SetZ(float v) { mP[1] = v; }
7069
GPUd() void SetSinPhi(float v) { mP[2] = v; }
@@ -76,9 +75,9 @@ struct GPUTPCBaseTrackParamSkeleton {
7675
// This is neccessary for performance reasons!!!
7776
// Changes to Elements of this class therefore must also be applied to TrackletConstructor!!!
7877
F<float> mX; // x position
79-
float mC[15]; // the covariance matrix for Y,Z,SinPhi,..
80-
float mZOffset; // z offset
81-
float mP[5]; // 'active' track parameters: Y, Z, SinPhi, DzDs, q/Pt
78+
F<float[15]> mC; // the covariance matrix for Y,Z,SinPhi,..
79+
F<float> mZOffset; // z offset
80+
F<float[5]> mP; // 'active' track parameters: Y, Z, SinPhi, DzDs, q/Pt
8281
};
8382

8483
using GPUTPCBaseTrackParam = GPUTPCBaseTrackParamSkeleton<wrapper::value>;

GPU/GPUTracking/SectorTracker/GPUTPCTrackParam.cxx

Lines changed: 51 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "GPUTPCTrackLinearisation.h"
1616
#include "GPUTPCTrackParam.h"
1717
#include "GPUTPCGeometry.h"
18+
#include "wrapper.h"
1819

1920
using namespace o2::gpu;
2021

@@ -28,7 +29,8 @@ using namespace o2::gpu;
2829
// Yc = Y + CAMath::Cos(Phi)/Kappa;
2930
//
3031

31-
GPUd() float GPUTPCTrackParam::GetDist2(const GPUTPCTrackParam& GPUrestrict() t) const
32+
template <template <class> class F>
33+
GPUd() float GPUTPCTrackParamSkeleton<F>::GetDist2(const GPUTPCTrackParamSkeleton<F>& GPUrestrict() t) const
3234
{
3335
// get squared distance between tracks
3436

@@ -38,7 +40,8 @@ GPUd() float GPUTPCTrackParam::GetDist2(const GPUTPCTrackParam& GPUrestrict() t)
3840
return dx * dx + dy * dy + dz * dz;
3941
}
4042

41-
GPUd() float GPUTPCTrackParam::GetDistXZ2(const GPUTPCTrackParam& GPUrestrict() t) const
43+
template <template <class> class F>
44+
GPUd() float GPUTPCTrackParamSkeleton<F>::GetDistXZ2(const GPUTPCTrackParamSkeleton<F>& GPUrestrict() t) const
4245
{
4346
// get squared distance between tracks in X&Z
4447

@@ -47,7 +50,8 @@ GPUd() float GPUTPCTrackParam::GetDistXZ2(const GPUTPCTrackParam& GPUrestrict()
4750
return dx * dx + dz * dz;
4851
}
4952

50-
GPUd() float GPUTPCTrackParam::GetS(float x, float y, float Bz) const
53+
template <template <class> class F>
54+
GPUd() float GPUTPCTrackParamSkeleton<F>::GetS(float x, float y, float Bz) const
5155
{
5256
//* Get XY path length to the given point
5357

@@ -63,7 +67,8 @@ GPUd() float GPUTPCTrackParam::GetS(float x, float y, float Bz) const
6367
return dS;
6468
}
6569

66-
GPUd() void GPUTPCTrackParam::GetDCAPoint(float x, float y, float z, float& GPUrestrict() xp, float& GPUrestrict() yp, float& GPUrestrict() zp, float Bz) const
70+
template <template <class> class F>
71+
GPUd() void GPUTPCTrackParamSkeleton<F>::GetDCAPoint(float x, float y, float z, float& GPUrestrict() xp, float& GPUrestrict() yp, float& GPUrestrict() zp, float Bz) const
6772
{
6873
//* Get the track point closest to the (x,y,z)
6974

@@ -93,7 +98,8 @@ GPUd() void GPUTPCTrackParam::GetDCAPoint(float x, float y, float z, float& GPUr
9398
//* Transport routines
9499
//*
95100

96-
GPUd() bool GPUTPCTrackParam::TransportToX(float x, GPUTPCTrackLinearisation& GPUrestrict() t0, float Bz, float maxSinPhi, float* GPUrestrict() DL)
101+
template <template <class> class F>
102+
GPUd() bool GPUTPCTrackParamSkeleton<F>::TransportToX(float x, GPUTPCTrackLinearisation& GPUrestrict() t0, float Bz, float maxSinPhi, float* GPUrestrict() DL)
97103
{
98104
//* Transport the track parameters to X=x, using linearization at t0, and the field value Bz
99105
//* maxSinPhi is the max. allowed value for |t0.SinPhi()|
@@ -213,7 +219,8 @@ GPUd() bool GPUTPCTrackParam::TransportToX(float x, GPUTPCTrackLinearisation& GP
213219
return 1;
214220
}
215221

216-
GPUd() bool GPUTPCTrackParam::TransportToX(float x, float sinPhi0, float cosPhi0, float Bz, float maxSinPhi)
222+
template <template <class> class F>
223+
GPUd() bool GPUTPCTrackParamSkeleton<F>::TransportToX(float x, float sinPhi0, float cosPhi0, float Bz, float maxSinPhi)
217224
{
218225
//* Transport the track parameters to X=x, using linearization at phi0 with 0 curvature,
219226
//* and the field value Bz
@@ -293,14 +300,16 @@ GPUd() bool GPUTPCTrackParam::TransportToX(float x, float sinPhi0, float cosPhi0
293300
return 1;
294301
}
295302

296-
GPUd() bool GPUTPCTrackParam::TransportToX(float x, float Bz, float maxSinPhi)
303+
template <template <class> class F>
304+
GPUd() bool GPUTPCTrackParamSkeleton<F>::TransportToX(float x, float Bz, float maxSinPhi)
297305
{
298306
//* Transport the track parameters to X=x
299307
GPUTPCTrackLinearisation t0(*this);
300308
return TransportToX(x, t0, Bz, maxSinPhi);
301309
}
302310

303-
GPUd() bool GPUTPCTrackParam::TransportToXWithMaterial(float x, GPUTPCTrackLinearisation& GPUrestrict() t0, GPUTPCTrackFitParam& GPUrestrict() par, float Bz, float maxSinPhi)
311+
template <template <class> class F>
312+
GPUd() bool GPUTPCTrackParamSkeleton<F>::TransportToXWithMaterial(float x, GPUTPCTrackLinearisation& GPUrestrict() t0, GPUTPCTrackFitParam& GPUrestrict() par, float Bz, float maxSinPhi)
304313
{
305314
//* Transport the track parameters to X=x taking into account material budget
306315

@@ -318,15 +327,17 @@ GPUd() bool GPUTPCTrackParam::TransportToXWithMaterial(float x, GPUTPCTrackLinea
318327
return 1;
319328
}
320329

321-
GPUd() bool GPUTPCTrackParam::TransportToXWithMaterial(float x, GPUTPCTrackFitParam& GPUrestrict() par, float Bz, float maxSinPhi)
330+
template <template <class> class F>
331+
GPUd() bool GPUTPCTrackParamSkeleton<F>::TransportToXWithMaterial(float x, GPUTPCTrackFitParam& GPUrestrict() par, float Bz, float maxSinPhi)
322332
{
323333
//* Transport the track parameters to X=x taking into account material budget
324334

325335
GPUTPCTrackLinearisation t0(*this);
326336
return TransportToXWithMaterial(x, t0, par, Bz, maxSinPhi);
327337
}
328338

329-
GPUd() bool GPUTPCTrackParam::TransportToXWithMaterial(float x, float Bz, float maxSinPhi)
339+
template <template <class> class F>
340+
bool GPUTPCTrackParamSkeleton<F>::TransportToXWithMaterial(float x, float Bz, float maxSinPhi)
330341
{
331342
//* Transport the track parameters to X=x taking into account material budget
332343

@@ -338,7 +349,8 @@ GPUd() bool GPUTPCTrackParam::TransportToXWithMaterial(float x, float Bz, float
338349
//*
339350
//* Multiple scattering and energy losses
340351
//*
341-
GPUd() float GPUTPCTrackParam::BetheBlochGeant(float bg2, float kp0, float kp1, float kp2, float kp3, float kp4)
352+
template <template <class> class F>
353+
GPUd() float GPUTPCTrackParamSkeleton<F>::BetheBlochGeant(float bg2, float kp0, float kp1, float kp2, float kp3, float kp4)
342354
{
343355
//
344356
// This is the parameterization of the Bethe-Bloch formula inspired by Geant.
@@ -377,7 +389,8 @@ GPUd() float GPUTPCTrackParam::BetheBlochGeant(float bg2, float kp0, float kp1,
377389
return mK * mZA * (1 + bg2) / bg2 * (0.5f * CAMath::Log(2 * me * bg2 * maxT / (mI * mI)) - bg2 / (1 + bg2) - d2);
378390
}
379391

380-
GPUd() float GPUTPCTrackParam::BetheBlochSolid(float bg)
392+
template <template <class> class F>
393+
GPUd() float GPUTPCTrackParamSkeleton<F>::BetheBlochSolid(float bg)
381394
{
382395
//------------------------------------------------------------------
383396
// This is an approximation of the Bethe-Bloch formula,
@@ -389,7 +402,8 @@ GPUd() float GPUTPCTrackParam::BetheBlochSolid(float bg)
389402
return BetheBlochGeant(bg);
390403
}
391404

392-
GPUd() float GPUTPCTrackParam::BetheBlochGas(float bg)
405+
template <template <class> class F>
406+
GPUd() float GPUTPCTrackParamSkeleton<F>::BetheBlochGas(float bg)
393407
{
394408
//------------------------------------------------------------------
395409
// This is an approximation of the Bethe-Bloch formula,
@@ -407,7 +421,8 @@ GPUd() float GPUTPCTrackParam::BetheBlochGas(float bg)
407421
return BetheBlochGeant(bg, rho, x0, x1, mI, mZA);
408422
}
409423

410-
GPUd() float GPUTPCTrackParam::ApproximateBetheBloch(float beta2)
424+
template <template <class> class F>
425+
GPUd() float GPUTPCTrackParamSkeleton<F>::ApproximateBetheBloch(float beta2)
411426
{
412427
//------------------------------------------------------------------
413428
// This is an approximation of the Bethe-Bloch formula with
@@ -424,7 +439,8 @@ GPUd() float GPUTPCTrackParam::ApproximateBetheBloch(float beta2)
424439
return 0.153e-3f / beta2 * (CAMath::Log(5940 * beta2 / (1 - beta2)) - beta2);
425440
}
426441

427-
GPUd() void GPUTPCTrackParam::CalculateFitParameters(GPUTPCTrackFitParam& par, float mass)
442+
template <template <class> class F>
443+
GPUd() void GPUTPCTrackParamSkeleton<F>::CalculateFitParameters(GPUTPCTrackFitParam& par, float mass)
428444
{
429445
//*!
430446

@@ -458,7 +474,8 @@ GPUd() void GPUTPCTrackParam::CalculateFitParameters(GPUTPCTrackFitParam& par, f
458474
par.k44 = GetPar(3) * GetPar(3) * k2;
459475
}
460476

461-
GPUd() bool GPUTPCTrackParam::CorrectForMeanMaterial(float xOverX0, float xTimesRho, const GPUTPCTrackFitParam& par)
477+
template <template <class> class F>
478+
GPUd() bool GPUTPCTrackParamSkeleton<F>::CorrectForMeanMaterial(float xOverX0, float xTimesRho, const GPUTPCTrackFitParam& par)
462479
{
463480
//------------------------------------------------------------------
464481
// This function corrects the track parameters for the crossed material.
@@ -507,7 +524,8 @@ GPUd() bool GPUTPCTrackParam::CorrectForMeanMaterial(float xOverX0, float xTimes
507524
//*
508525
//* Rotation
509526
//*
510-
GPUd() bool GPUTPCTrackParam::Rotate(float alpha, float maxSinPhi)
527+
template <template <class> class F>
528+
GPUd() bool GPUTPCTrackParamSkeleton<F>::Rotate(float alpha, float maxSinPhi)
511529
{
512530
//* Rotate the coordinate system in XY on the angle alpha
513531

@@ -564,7 +582,8 @@ GPUd() bool GPUTPCTrackParam::Rotate(float alpha, float maxSinPhi)
564582
return 1;
565583
}
566584

567-
GPUd() bool GPUTPCTrackParam::Rotate(float alpha, GPUTPCTrackLinearisation& t0, float maxSinPhi)
585+
template <template <class> class F>
586+
GPUd() bool GPUTPCTrackParamSkeleton<F>::Rotate(float alpha, GPUTPCTrackLinearisation& t0, float maxSinPhi)
568587
{
569588
//* Rotate the coordinate system in XY on the angle alpha
570589

@@ -610,7 +629,8 @@ GPUd() bool GPUTPCTrackParam::Rotate(float alpha, GPUTPCTrackLinearisation& t0,
610629
return 1;
611630
}
612631

613-
GPUd() bool GPUTPCTrackParam::Filter(float y, float z, float err2Y, float err2Z, float maxSinPhi, bool paramOnly)
632+
template <template <class> class F>
633+
GPUd() bool GPUTPCTrackParamSkeleton<F>::Filter(float y, float z, float err2Y, float err2Z, float maxSinPhi, bool paramOnly)
614634
{
615635
//* Add the y,z measurement with the Kalman filter
616636

@@ -671,7 +691,8 @@ GPUd() bool GPUTPCTrackParam::Filter(float y, float z, float err2Y, float err2Z,
671691
return 1;
672692
}
673693

674-
GPUd() bool GPUTPCTrackParam::CheckNumericalQuality() const
694+
template <template <class> class F>
695+
GPUd() bool GPUTPCTrackParamSkeleton<F>::CheckNumericalQuality() const
675696
{
676697
//* Check that the track parameters and covariance matrix are reasonable
677698

@@ -707,7 +728,8 @@ GPUd() bool GPUTPCTrackParam::CheckNumericalQuality() const
707728
return ok;
708729
}
709730

710-
GPUd() void GPUTPCTrackParam::ConstrainZ(float& z, int32_t sector, float& z0, float& lastZ)
731+
template <template <class> class F>
732+
GPUd() void GPUTPCTrackParamSkeleton<F>::ConstrainZ(float& z, int32_t sector, float& z0, float& lastZ)
711733
{
712734
if (sector < GPUCA_NSECTORS / 2) {
713735
if (z < 0) {
@@ -742,7 +764,8 @@ GPUd() void GPUTPCTrackParam::ConstrainZ(float& z, int32_t sector, float& z0, fl
742764
}
743765
}
744766

745-
GPUd() void GPUTPCTrackParam::ShiftZ(float z1, float z2, float x1, float x2, float bz, float defaultZOffsetOverR)
767+
template <template <class> class F>
768+
GPUd() void GPUTPCTrackParamSkeleton<F>::ShiftZ(float z1, float z2, float x1, float x2, float bz, float defaultZOffsetOverR)
746769
{
747770
const float r1 = CAMath::Max(0.0001f, CAMath::Abs(mParam.mP[4] * bz));
748771

@@ -804,7 +827,8 @@ GPUd() void GPUTPCTrackParam::ShiftZ(float z1, float z2, float x1, float x2, flo
804827
#include <iostream>
805828
#endif
806829

807-
GPUd() void GPUTPCTrackParam::Print() const
830+
template <template <class> class F>
831+
GPUd() void GPUTPCTrackParamSkeleton<F>::Print() const
808832
{
809833
//* print parameters
810834

@@ -814,7 +838,8 @@ GPUd() void GPUTPCTrackParam::Print() const
814838
#endif
815839
}
816840

817-
GPUd() int32_t GPUTPCTrackParam::GetPropagatedYZ(float bz, float x, float& projY, float& projZ) const
841+
template <template <class> class F>
842+
GPUd() int32_t GPUTPCTrackParamSkeleton<F>::GetPropagatedYZ(float bz, float x, float& projY, float& projZ) const
818843
{
819844
float k = mParam.mP[4] * bz;
820845
float dx = x - mParam.mX;
@@ -850,3 +875,5 @@ GPUd() int32_t GPUTPCTrackParam::GetPropagatedYZ(float bz, float x, float& projY
850875
projZ = mParam.mP[1] + dz;
851876
return 1;
852877
}
878+
879+
template class GPUTPCTrackParamSkeleton<wrapper::value>;

GPU/GPUTracking/SectorTracker/GPUTPCTrackParam.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "GPUTPCBaseTrackParam.h"
1919
#include "GPUTPCDef.h"
2020
#include "GPUCommonMath.h"
21+
#include "wrapper.h"
2122

2223
namespace o2::gpu
2324
{
@@ -30,7 +31,8 @@ class GPUTPCTrackLinearisation;
3031
* which is used by the GPUTPCTracker sector tracker.
3132
*
3233
*/
33-
class GPUTPCTrackParam
34+
template <template <class> class F>
35+
class GPUTPCTrackParamSkeleton
3436
{
3537
public:
3638
struct GPUTPCTrackFitParam {
@@ -92,8 +94,8 @@ class GPUTPCTrackParam
9294
GPUd() void SetChi2(float v) { mChi2 = v; }
9395
GPUd() void SetNDF(int32_t v) { mNDF = v; }
9496

95-
GPUd() float GetDist2(const GPUTPCTrackParam& t) const;
96-
GPUd() float GetDistXZ2(const GPUTPCTrackParam& t) const;
97+
GPUd() float GetDist2(const GPUTPCTrackParamSkeleton<F>& t) const;
98+
GPUd() float GetDistXZ2(const GPUTPCTrackParamSkeleton<F>& t) const;
9799

98100
GPUd() float GetS(float x, float y, float Bz) const;
99101

@@ -153,6 +155,9 @@ class GPUTPCTrackParam
153155
int32_t mNDF; // the Number of Degrees of Freedom
154156
};
155157

158+
using GPUTPCTrackParam = GPUTPCTrackParamSkeleton<wrapper::value>;
159+
160+
template <>
156161
GPUdi() void GPUTPCTrackParam::InitParam()
157162
{
158163
// Initialize Tracklet Parameters using default values

GPU/GPUTracking/SectorTracker/GPUTPCTracker.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ namespace o2::gpu
3232
struct GPUTPCClusterData;
3333
struct GPUParam;
3434
class GPUTPCTrack;
35-
class GPUTPCTrackParam;
3635
class GPUTPCRow;
3736

3837
class GPUTPCTracker : public GPUProcessor

0 commit comments

Comments
 (0)