1010
1111#include " DetectorsBase/Propagator.h"
1212#include " GPUCommonLogger.h"
13+ #include " GPUCommonMath.h"
1314#include " GPUTPCGMPolynomialField.h"
1415#include " MathUtils/Utils.h"
1516#include " ReconstructionDataFormats/Vertex.h"
1617
1718using namespace o2 ::base;
19+ using namespace o2 ::gpu;
1820
1921#if !defined(GPUCA_GPUCODE)
2022#include " Field/MagFieldFast.h" // Don't use this on the GPU
@@ -122,8 +124,8 @@ GPUd() bool Propagator::PropagateToXBxByBz(o2::track::TrackParCov& track, float
122124 }
123125
124126 gpu::gpustd::array<float , 3 > b;
125- while (std::abs (dx) > Epsilon) {
126- auto step = std::min ( std::abs (dx), maxStep);
127+ while (CAMath::Abs (dx) > Epsilon) {
128+ auto step = CAMath::Min ( CAMath::Abs (dx), maxStep);
127129 if (dir < 0 ) {
128130 step = -step;
129131 }
@@ -134,7 +136,7 @@ GPUd() bool Propagator::PropagateToXBxByBz(o2::track::TrackParCov& track, float
134136 if (!track.propagateTo (x, b)) {
135137 return false ;
136138 }
137- if (maxSnp > 0 && std::abs (track.getSnp ()) >= maxSnp) {
139+ if (maxSnp > 0 && CAMath::Abs (track.getSnp ()) >= maxSnp) {
138140 return false ;
139141 }
140142 if (matCorr != MatCorrType::USEMatCorrNONE) {
@@ -181,8 +183,8 @@ GPUd() bool Propagator::PropagateToXBxByBz(o2::track::TrackPar& track, float xTo
181183 }
182184
183185 gpu::gpustd::array<float , 3 > b;
184- while (std::abs (dx) > Epsilon) {
185- auto step = std::min ( std::abs (dx), maxStep);
186+ while (CAMath::Abs (dx) > Epsilon) {
187+ auto step = CAMath::Min ( CAMath::Abs (dx), maxStep);
186188 if (dir < 0 ) {
187189 step = -step;
188190 }
@@ -193,7 +195,7 @@ GPUd() bool Propagator::PropagateToXBxByBz(o2::track::TrackPar& track, float xTo
193195 if (!track.propagateParamTo (x, b)) {
194196 return false ;
195197 }
196- if (maxSnp > 0 && std::abs (track.getSnp ()) >= maxSnp) {
198+ if (maxSnp > 0 && CAMath::Abs (track.getSnp ()) >= maxSnp) {
197199 return false ;
198200 }
199201 if (matCorr != MatCorrType::USEMatCorrNONE) {
@@ -238,8 +240,8 @@ GPUd() bool Propagator::propagateToX(o2::track::TrackParCov& track, float xToGo,
238240 signCorr = -dir; // sign of eloss correction is not imposed
239241 }
240242
241- while (std::abs (dx) > Epsilon) {
242- auto step = std::min ( std::abs (dx), maxStep);
243+ while (CAMath::Abs (dx) > Epsilon) {
244+ auto step = CAMath::Min ( CAMath::Abs (dx), maxStep);
243245 if (dir < 0 ) {
244246 step = -step;
245247 }
@@ -249,7 +251,7 @@ GPUd() bool Propagator::propagateToX(o2::track::TrackParCov& track, float xToGo,
249251 if (!track.propagateTo (x, bZ)) {
250252 return false ;
251253 }
252- if (maxSnp > 0 && std::abs (track.getSnp ()) >= maxSnp) {
254+ if (maxSnp > 0 && CAMath::Abs (track.getSnp ()) >= maxSnp) {
253255 return false ;
254256 }
255257 if (matCorr != MatCorrType::USEMatCorrNONE) {
@@ -296,8 +298,8 @@ GPUd() bool Propagator::propagateToX(o2::track::TrackPar& track, float xToGo, fl
296298 signCorr = -dir; // sign of eloss correction is not imposed
297299 }
298300
299- while (std::abs (dx) > Epsilon) {
300- auto step = std::min ( std::abs (dx), maxStep);
301+ while (CAMath::Abs (dx) > Epsilon) {
302+ auto step = CAMath::Min ( CAMath::Abs (dx), maxStep);
301303 if (dir < 0 ) {
302304 step = -step;
303305 }
@@ -307,7 +309,7 @@ GPUd() bool Propagator::propagateToX(o2::track::TrackPar& track, float xToGo, fl
307309 if (!track.propagateParamTo (x, bZ)) {
308310 return false ;
309311 }
310- if (maxSnp > 0 && std::abs (track.getSnp ()) >= maxSnp) {
312+ if (maxSnp > 0 && CAMath::Abs (track.getSnp ()) >= maxSnp) {
311313 return false ;
312314 }
313315 if (matCorr != MatCorrType::USEMatCorrNONE) {
@@ -341,27 +343,27 @@ GPUd() bool Propagator::propagateToDCA(const o2::dataformats::VertexBase& vtx, o
341343 // propagate track to DCA to the vertex
342344 float sn, cs, alp = track.getAlpha ();
343345 o2::math_utils::sincos (alp, sn, cs);
344- float x = track.getX (), y = track.getY (), snp = track.getSnp (), csp = std::sqrt ((1 .f - snp) * (1 .f + snp));
346+ float x = track.getX (), y = track.getY (), snp = track.getSnp (), csp = CAMath::Sqrt ((1 .f - snp) * (1 .f + snp));
345347 float xv = vtx.getX () * cs + vtx.getY () * sn, yv = -vtx.getX () * sn + vtx.getY () * cs, zv = vtx.getZ ();
346348 x -= xv;
347349 y -= yv;
348350 // Estimate the impact parameter neglecting the track curvature
349- float d = std::abs (x * snp - y * csp);
351+ float d = CAMath::Abs (x * snp - y * csp);
350352 if (d > maxD) {
351353 return false ;
352354 }
353355 float crv = track.getCurvature (bZ);
354356 float tgfv = -(crv * x - snp) / (crv * y + csp);
355- sn = tgfv / std::sqrt (1 .f + tgfv * tgfv);
356- cs = std::sqrt ((1 . - sn) * (1 . + sn));
357- cs = (std::abs (tgfv) > o2::constants::math::Almost0) ? sn / tgfv : o2::constants::math::Almost1;
357+ sn = tgfv / CAMath::Sqrt (1 .f + tgfv * tgfv);
358+ cs = CAMath::Sqrt ((1 . - sn) * (1 . + sn));
359+ cs = (CAMath::Abs (tgfv) > o2::constants::math::Almost0) ? sn / tgfv : o2::constants::math::Almost1;
358360
359361 x = xv * cs + yv * sn;
360362 yv = -xv * sn + yv * cs;
361363 xv = x;
362364
363365 auto tmpT (track); // operate on the copy to recover after the failure
364- alp += std::asin (sn);
366+ alp += CAMath::ASin (sn);
365367 if (!tmpT.rotate (alp) || !propagateToX (tmpT, xv, bZ, 0.85 , maxStep, matCorr, tofInfo, signCorr)) {
366368 LOG (WARNING) << " failed to propagate to alpha=" << alp << " X=" << xv << vtx << " | Track is: " ;
367369 tmpT.print ();
@@ -386,27 +388,27 @@ GPUd() bool Propagator::propagateToDCABxByBz(const o2::dataformats::VertexBase&
386388 // propagate track to DCA to the vertex
387389 float sn, cs, alp = track.getAlpha ();
388390 o2::math_utils::sincos (alp, sn, cs);
389- float x = track.getX (), y = track.getY (), snp = track.getSnp (), csp = std::sqrt ((1 .f - snp) * (1 .f + snp));
391+ float x = track.getX (), y = track.getY (), snp = track.getSnp (), csp = CAMath::Sqrt ((1 .f - snp) * (1 .f + snp));
390392 float xv = vtx.getX () * cs + vtx.getY () * sn, yv = -vtx.getX () * sn + vtx.getY () * cs, zv = vtx.getZ ();
391393 x -= xv;
392394 y -= yv;
393395 // Estimate the impact parameter neglecting the track curvature
394- float d = std::abs (x * snp - y * csp);
396+ float d = CAMath::Abs (x * snp - y * csp);
395397 if (d > maxD) {
396398 return false ;
397399 }
398400 float crv = track.getCurvature (mBz );
399401 float tgfv = -(crv * x - snp) / (crv * y + csp);
400- sn = tgfv / std::sqrt (1 .f + tgfv * tgfv);
401- cs = std::sqrt ((1 . - sn) * (1 . + sn));
402- cs = (std::abs (tgfv) > o2::constants::math::Almost0) ? sn / tgfv : o2::constants::math::Almost1;
402+ sn = tgfv / CAMath::Sqrt (1 .f + tgfv * tgfv);
403+ cs = CAMath::Sqrt ((1 . - sn) * (1 . + sn));
404+ cs = (CAMath::Abs (tgfv) > o2::constants::math::Almost0) ? sn / tgfv : o2::constants::math::Almost1;
403405
404406 x = xv * cs + yv * sn;
405407 yv = -xv * sn + yv * cs;
406408 xv = x;
407409
408410 auto tmpT (track); // operate on the copy to recover after the failure
409- alp += std::asin (sn);
411+ alp += CAMath::ASin (sn);
410412 if (!tmpT.rotate (alp) || !PropagateToXBxByBz (tmpT, xv, 0.85 , maxStep, matCorr, tofInfo, signCorr)) {
411413 LOG (WARNING) << " failed to propagate to alpha=" << alp << " X=" << xv << vtx << " | Track is: " ;
412414 tmpT.print ();
@@ -431,27 +433,27 @@ GPUd() bool Propagator::propagateToDCA(const math_utils::Point3D<float>& vtx, o2
431433 // propagate track to DCA to the vertex
432434 float sn, cs, alp = track.getAlpha ();
433435 o2::math_utils::sincos (alp, sn, cs);
434- float x = track.getX (), y = track.getY (), snp = track.getSnp (), csp = std::sqrt ((1 .f - snp) * (1 .f + snp));
436+ float x = track.getX (), y = track.getY (), snp = track.getSnp (), csp = CAMath::Sqrt ((1 .f - snp) * (1 .f + snp));
435437 float xv = vtx.X () * cs + vtx.Y () * sn, yv = -vtx.X () * sn + vtx.Y () * cs, zv = vtx.Z ();
436438 x -= xv;
437439 y -= yv;
438440 // Estimate the impact parameter neglecting the track curvature
439- float d = std::abs (x * snp - y * csp);
441+ float d = CAMath::Abs (x * snp - y * csp);
440442 if (d > maxD) {
441443 return false ;
442444 }
443445 float crv = track.getCurvature (bZ);
444446 float tgfv = -(crv * x - snp) / (crv * y + csp);
445- sn = tgfv / std::sqrt (1 .f + tgfv * tgfv);
446- cs = std::sqrt ((1 . - sn) * (1 . + sn));
447- cs = (std::abs (tgfv) > o2::constants::math::Almost0) ? sn / tgfv : o2::constants::math::Almost1;
447+ sn = tgfv / CAMath::Sqrt (1 .f + tgfv * tgfv);
448+ cs = CAMath::Sqrt ((1 . - sn) * (1 . + sn));
449+ cs = (CAMath::Abs (tgfv) > o2::constants::math::Almost0) ? sn / tgfv : o2::constants::math::Almost1;
448450
449451 x = xv * cs + yv * sn;
450452 yv = -xv * sn + yv * cs;
451453 xv = x;
452454
453455 auto tmpT (track); // operate on the copy to recover after the failure
454- alp += std::asin (sn);
456+ alp += CAMath::ASin (sn);
455457 if (!tmpT.rotateParam (alp) || !propagateToX (tmpT, xv, bZ, 0.85 , maxStep, matCorr, tofInfo, signCorr)) {
456458 LOG (WARNING) << " failed to propagate to alpha=" << alp << " X=" << xv << " for vertex "
457459 << vtx.X () << ' ' << vtx.Y () << ' ' << vtx.Z () << " | Track is: " ;
@@ -475,27 +477,27 @@ GPUd() bool Propagator::propagateToDCABxByBz(const math_utils::Point3D<float>& v
475477 // propagate track to DCA to the vertex
476478 float sn, cs, alp = track.getAlpha ();
477479 o2::math_utils::sincos (alp, sn, cs);
478- float x = track.getX (), y = track.getY (), snp = track.getSnp (), csp = std::sqrt ((1 .f - snp) * (1 .f + snp));
480+ float x = track.getX (), y = track.getY (), snp = track.getSnp (), csp = CAMath::Sqrt ((1 .f - snp) * (1 .f + snp));
479481 float xv = vtx.X () * cs + vtx.Y () * sn, yv = -vtx.X () * sn + vtx.Y () * cs, zv = vtx.Z ();
480482 x -= xv;
481483 y -= yv;
482484 // Estimate the impact parameter neglecting the track curvature
483- float d = std::abs (x * snp - y * csp);
485+ float d = CAMath::Abs (x * snp - y * csp);
484486 if (d > maxD) {
485487 return false ;
486488 }
487489 float crv = track.getCurvature (mBz );
488490 float tgfv = -(crv * x - snp) / (crv * y + csp);
489- sn = tgfv / std::sqrt (1 .f + tgfv * tgfv);
490- cs = std::sqrt ((1 . - sn) * (1 . + sn));
491- cs = (std::abs (tgfv) > o2::constants::math::Almost0) ? sn / tgfv : o2::constants::math::Almost1;
491+ sn = tgfv / CAMath::Sqrt (1 .f + tgfv * tgfv);
492+ cs = CAMath::Sqrt ((1 . - sn) * (1 . + sn));
493+ cs = (CAMath::Abs (tgfv) > o2::constants::math::Almost0) ? sn / tgfv : o2::constants::math::Almost1;
492494
493495 x = xv * cs + yv * sn;
494496 yv = -xv * sn + yv * cs;
495497 xv = x;
496498
497499 auto tmpT (track); // operate on the copy to recover after the failure
498- alp += std::asin (sn);
500+ alp += CAMath::ASin (sn);
499501 if (!tmpT.rotateParam (alp) || !PropagateToXBxByBz (tmpT, xv, 0.85 , maxStep, matCorr, tofInfo, signCorr)) {
500502 LOG (WARNING) << " failed to propagate to alpha=" << alp << " X=" << xv << " for vertex "
501503 << vtx.X () << ' ' << vtx.Y () << ' ' << vtx.Z () << " | Track is: " ;
@@ -513,7 +515,7 @@ GPUd() bool Propagator::propagateToDCABxByBz(const math_utils::Point3D<float>& v
513515// ____________________________________________________________
514516GPUd () MatBudget Propagator::getMatBudget(Propagator::MatCorrType corrType, const math_utils::Point3D<float >& p0, const math_utils::Point3D<float >& p1) const
515517{
516- #ifndef GPUCA_STANDALONE
518+ #if !defined( GPUCA_STANDALONE) && !defined(GPUCA_GPUCODE)
517519 if (corrType == MatCorrType::USEMatCorrTGeo) {
518520 return GeometryManager::meanMaterialBudget (p0, p1);
519521 }
0 commit comments