2929
3030using namespace GPUCA_NAMESPACE ::gpu;
3131
32- GPUd () void GPUTPCGMPropagator::GetBxByBz (float Alpha , float X, float Y, float Z, float B[3 ]) const
32+ GPUd () void GPUTPCGMPropagator::GetBxByBzBase (float cosAlpha, float sinAlpha , float X, float Y, float Z, float B[3 ]) const
3333{
3434 // get global coordinates
3535
36- float cs = CAMath::Cos (Alpha );
37- float sn = CAMath::Sin (Alpha );
36+ float gx = getGlobalX (cosAlpha, sinAlpha, X, Y );
37+ float gy = getGlobalY (cosAlpha, sinAlpha, X, Y );
3838
3939#if defined(GPUCA_GM_USE_FULL_FIELD)
4040 const double kCLight = 0.000299792458 ;
41- double r[3 ] = {X * cs - Y * sn, X * sn + Y * cs , Z};
41+ double r[3 ] = {gx, gy , Z};
4242 double bb[3 ];
4343 AliTracker::GetBxByBz (r, bb);
4444 bb[0 ] *= kCLight ;
@@ -57,22 +57,22 @@ GPUd() void GPUTPCGMPropagator::GetBxByBz(float Alpha, float X, float Y, float Z
5757 float bb[3 ];
5858 switch (mFieldRegion ) {
5959 case ITS :
60- mField ->GetFieldIts (X * cs - Y * sn, X * sn + Y * cs , Z, bb);
60+ mField ->GetFieldIts (gx, gy , Z, bb);
6161 break ;
6262 case TRD :
63- mField ->GetFieldTrd (X * cs - Y * sn, X * sn + Y * cs , Z, bb);
63+ mField ->GetFieldTrd (gx, gy , Z, bb);
6464 break ;
6565 case TPC :
6666 default :
67- mField ->GetField (X * cs - Y * sn, X * sn + Y * cs , Z, bb);
67+ mField ->GetField (gx, gy , Z, bb);
6868 }
6969
7070#endif
7171
7272 // rotate field to local coordinates
7373
74- B[0 ] = bb[0 ] * cs + bb[1 ] * sn ;
75- B[1 ] = -bb[0 ] * sn + bb[1 ] * cs ;
74+ B[0 ] = bb[0 ] * cosAlpha + bb[1 ] * sinAlpha ;
75+ B[1 ] = -bb[0 ] * sinAlpha + bb[1 ] * cosAlpha ;
7676 B[2 ] = bb[2 ];
7777 /* if( mToyMCEvents ){ // special treatment for toy monte carlo
7878 B[0] = 0;
@@ -81,36 +81,35 @@ GPUd() void GPUTPCGMPropagator::GetBxByBz(float Alpha, float X, float Y, float Z
8181 }*/
8282}
8383
84- GPUd () float GPUTPCGMPropagator::GetBz (float Alpha , float X, float Y, float Z) const
84+ GPUd () float GPUTPCGMPropagator::GetBzBase (float cosAlpha, float sinAlpha , float X, float Y, float Z) const
8585{
8686 if (mToyMCEvents ) { // special treatment for toy monte carlo
8787 float B[3 ];
88- GetBxByBz (Alpha , X, Y, Z, B);
88+ GetBxByBzBase (cosAlpha, sinAlpha , X, Y, Z, B);
8989 return B[2 ];
9090 }
9191
9292 // get global coordinates
9393
94- float cs = CAMath::Cos (Alpha );
95- float sn = CAMath::Sin (Alpha );
94+ float gx = getGlobalX (cosAlpha, sinAlpha, X, Y );
95+ float gy = getGlobalY (cosAlpha, sinAlpha, X, Y );
9696
9797#if defined(GPUCA_GM_USE_FULL_FIELD)
9898 const double kCLight = 0.000299792458 ;
99- double r[3 ] = {X * cs - Y * sn, X * sn + Y * cs , Z};
99+ double r[3 ] = {gx, gy , Z};
100100 double bb[3 ];
101101 AliTracker::GetBxByBz (r, bb);
102102 return bb[2 ] * kCLight ;
103103#else
104104 switch (mFieldRegion ) {
105105 case ITS :
106- return mField ->GetFieldItsBz (X * cs - Y * sn, X * sn + Y * cs , Z);
106+ return mField ->GetFieldItsBz (gx, gy , Z);
107107 case TRD :
108- return mField ->GetFieldTrdBz (X * cs - Y * sn, X * sn + Y * cs , Z);
108+ return mField ->GetFieldTrdBz (gx, gy , Z);
109109 case TPC :
110110 default :
111- return mField ->GetFieldBz (X * cs - Y * sn, X * sn + Y * cs , Z);
111+ return mField ->GetFieldBz (gx, gy , Z);
112112 }
113-
114113#endif
115114}
116115
@@ -121,8 +120,11 @@ GPUd() int GPUTPCGMPropagator::RotateToAlpha(float newAlpha)
121120 // return value is error code (0==no error)
122121 //
123122
124- float cc = CAMath::Cos (newAlpha - mAlpha );
125- float ss = CAMath::Sin (newAlpha - mAlpha );
123+ float newCosAlpha = CAMath::Cos (newAlpha);
124+ float newSinAlpha = CAMath::Sin (newAlpha);
125+
126+ float cc = newCosAlpha * mCosAlpha + newSinAlpha * mSinAlpha ; // cos(newAlpha - mAlpha);
127+ float ss = newSinAlpha * mCosAlpha - newCosAlpha * mSinAlpha ; // sin(newAlpha - mAlpha);
126128
127129 GPUTPCGMPhysicalTrackModel t0 = mT0 ;
128130
@@ -271,6 +273,8 @@ GPUd() int GPUTPCGMPropagator::RotateToAlpha(float newAlpha)
271273 }
272274
273275 mAlpha = newAlpha;
276+ mCosAlpha = newCosAlpha;
277+ mSinAlpha = newSinAlpha;
274278 mT0 = t0;
275279
276280 return 0 ;
@@ -288,7 +292,7 @@ GPUd() int GPUTPCGMPropagator::PropagateToXAlpha(float posX, float posAlpha, boo
288292 }
289293
290294 float B[3 ];
291- GetBxByBz (mAlpha , mT0 .X (), mT0 .Y (), mT0 .Z (), B);
295+ GetBxByBz (mT0 .X (), mT0 .Y (), mT0 .Z (), B);
292296
293297 // propagate mT0 to t0e
294298
@@ -313,7 +317,7 @@ GPUd() int GPUTPCGMPropagator::PropagateToXAlphaBz(float posX, float posAlpha, b
313317 }
314318 }
315319
316- float Bz = GetBz (mAlpha , mT0 .X (), mT0 .Y (), mT0 .Z ());
320+ float Bz = GetBz (mT0 .X (), mT0 .Y (), mT0 .Z ());
317321
318322 // propagate mT0 to t0e
319323
@@ -375,6 +379,17 @@ GPUd() int GPUTPCGMPropagator::FollowLinearization(const GPUTPCGMPhysicalTrackMo
375379 return -4 ;
376380 }
377381
382+ if (mMatLUT ) {
383+ float xyz1[3 ] = {getGlobalX (mT0 .GetX (), mT0 .GetY ()), getGlobalY (mT0 .GetX (), mT0 .GetY ()), mT0 .GetZ ()};
384+ float xyz2[3 ] = {getGlobalX (t0e.GetX (), t0e.GetY ()), getGlobalY (t0e.GetX (), t0e.GetY ()), t0e.GetZ ()};
385+ o2::base::MatBudget mat = getMatBudget (xyz1, xyz2);
386+ if (mat.meanX2X0 > 1 .e -8 ) {
387+ SetMaterial (mat.length / mat.meanX2X0 , mat.meanRho );
388+ } else {
389+ SetMaterialTPC ();
390+ }
391+ }
392+
378393 mT0 = t0e;
379394 mT ->X () = t0e.GetX ();
380395 p[0 ] = t0e.GetY () + d0 + j02 * d2 + j04 * d4;
@@ -538,7 +553,7 @@ GPUd() int GPUTPCGMPropagator::FollowLinearization(const GPUTPCGMPhysicalTrackMo
538553
539554GPUd () int GPUTPCGMPropagator::GetPropagatedYZ(float x, float & GPUrestrict () projY, float& GPUrestrict() projZ)
540555{
541- float bz = GetBz (mAlpha , mT ->X (), mT ->Y (), mT ->Z ());
556+ float bz = GetBz (mT ->X (), mT ->Y (), mT ->Z ());
542557 float k = mT0 .QPt () * bz;
543558 float dx = x - mT ->X ();
544559 float kdx = k * dx;
@@ -882,7 +897,7 @@ GPUd() void GPUTPCGMPropagator::CalculateMaterialCorrection()
882897 float p2 = w2 / pti2; // impuls 2
883898 float betheRho = ApproximateBetheBloch (p2 / mass2) * mMaterial .rho ;
884899 float E = CAMath::Sqrt (p2 + mass2);
885- float theta2 = (14 .1f * 14 .1f / 1 .e6f ) / (beta2 * p2) * mMaterial .rhoOverRadLen ;
900+ float theta2 = (14 .1f * 14 .1f / 1 .e6f ) / (beta2 * p2) * mMaterial .radLenInv ;
886901
887902 mMaterial .EP2 = E / p2;
888903
@@ -923,6 +938,8 @@ GPUd() void GPUTPCGMPropagator::Rotate180()
923938 while (mAlpha < -M_PI ) {
924939 mAlpha += 2 * M_PI ;
925940 }
941+ mCosAlpha = -mCosAlpha ;
942+ mSinAlpha = -mSinAlpha ;
926943
927944 float * c = mT ->Cov ();
928945 c[6 ] = -c[6 ];
@@ -956,7 +973,7 @@ GPUd() void GPUTPCGMPropagator::Mirror(bool inFlyDirection)
956973{
957974 // mirror the track and the track approximation to the point which has the same X, but located on the other side of trajectory
958975 float B[3 ];
959- GetBxByBz (mAlpha , mT0 .X (), mT0 .Y (), mT0 .Z (), B);
976+ GetBxByBz (mT0 .X (), mT0 .Y (), mT0 .Z (), B);
960977 float Bz = B[2 ];
961978 if (CAMath::Abs (Bz) < 1 .e -8f ) {
962979 Bz = 1 .e -8f ;
@@ -1036,7 +1053,7 @@ GPUd() void GPUTPCGMPropagator::Mirror(bool inFlyDirection)
10361053 }
10371054}
10381055
1039- GPUd () o2::base::MatBudget GPUTPCGMPropagator::getMatBudget(float * p1, float * p2)
1056+ GPUd () o2::base::MatBudget GPUTPCGMPropagator::getMatBudget(const float * p1, const float * p2)
10401057{
10411058#ifdef HAVE_O2HEADERS
10421059 return mMatLUT ->getMatBudget (p1[0 ], p1[1 ], p1[2 ], p2[0 ], p2[1 ], p2[2 ]);
0 commit comments