1515#include " GPUTPCTrackLinearisation.h"
1616#include " GPUTPCTrackParam.h"
1717#include " GPUTPCGeometry.h"
18+ #include " wrapper.h"
1819
1920using 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>;
0 commit comments