Skip to content

Commit e716a12

Browse files
authored
Use of material map in the track propagator (#3682)
1 parent edef89d commit e716a12

11 files changed

Lines changed: 137 additions & 62 deletions

File tree

GPU/GPUTracking/DataCompression/AliHLTTPCClusterStatComponent.cxx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -315,10 +315,8 @@ int AliHLTTPCClusterStatComponent::DoEvent(const AliHLTComponentEventData& evtDa
315315
const AliHLTUInt8_t* pCurrent = reinterpret_cast<const AliHLTUInt8_t*>(tracks->fTracklets);
316316
if (fCompressionStudy) {
317317
GPUTPCGMPropagator prop;
318-
const float kRho = 1.025e-3; // 0.9e-3;
319-
const float kRadLen = 29.532; // 28.94;
320318
prop.SetMaxSinPhi(.999);
321-
prop.SetMaterial(kRadLen, kRho);
319+
prop.SetMaterialTPC();
322320
GPUTPCGMPolynomialField field;
323321
int err = GPUTPCGMPolynomialFieldManager::GetPolynomialField(field);
324322
if (err != 0) {

GPU/GPUTracking/DataCompression/GPUTPCCompressionTrackModel.cxx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@ using namespace GPUCA_NAMESPACE::gpu;
2424
#ifdef GPUCA_COMPRESSION_TRACK_MODEL_MERGER
2525
GPUd() void GPUTPCCompressionTrackModel::Init(float x, float y, float z, float alpha, unsigned char qPt, const GPUParam& GPUrestrict() param)
2626
{
27-
static constexpr float kRho = 1.025e-3f; // 0.9e-3;
28-
static constexpr float kRadLen = 29.532f; // 28.94;
29-
mProp.SetMaterial(kRadLen, kRho);
27+
mProp.SetMaterialTPC();
3028
mProp.SetMaxSinPhi(GPUCA_MAX_SIN_PHI);
3129
mProp.SetToyMCEventsFlag(false);
3230
mProp.SetSeedingErrors(true); // Larger errors for seeds, better since we don't start with good hypothesis

GPU/GPUTracking/Merger/GPUTPCGMMerger.cxx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -342,10 +342,8 @@ GPUd() void GPUTPCGMMerger::ClearTrackLinks(int nBlocks, int nThreads, int iBloc
342342

343343
GPUd() int GPUTPCGMMerger::RefitSliceTrack(GPUTPCGMSliceTrack& sliceTrack, const GPUTPCTrack* inTrack, float alpha, int slice)
344344
{
345-
static constexpr float kRho = 1.025e-3f; // 0.9e-3;
346-
static constexpr float kRadLen = 29.532f; // 28.94;
347345
GPUTPCGMPropagator prop;
348-
prop.SetMaterial(kRadLen, kRho);
346+
prop.SetMaterialTPC();
349347
prop.SetMaxSinPhi(GPUCA_MAX_SIN_PHI);
350348
prop.SetToyMCEventsFlag(false);
351349
prop.SetSeedingErrors(true); // Larger errors for seeds, better since we don't start with good hypothesis
@@ -1747,7 +1745,8 @@ void GPUCA_KRNL_BACKEND_CLASS::runKernelBackendInternal<GPUTPCGMMergerSortTracks
17471745

17481746
GPUd() void GPUTPCGMMerger::SortTracks(int nBlocks, int nThreads, int iBlock, int iThread)
17491747
{
1750-
auto comp = [cmp = mOutputTracks](const int aa, const int bb) { // Have to duplicate sort comparison: Thrust cannot use the Lambda but OpenCL cannot use the object
1748+
// Have to duplicate sort comparison: Thrust cannot use the Lambda but OpenCL cannot use the object
1749+
auto comp = [cmp = mOutputTracks](const int aa, const int bb) {
17511750
const GPUTPCGMMergedTrack& GPUrestrict() a = cmp[aa];
17521751
const GPUTPCGMMergedTrack& GPUrestrict() b = cmp[bb];
17531752
if (a.CCE() != b.CCE()) {
@@ -1765,7 +1764,8 @@ GPUd() void GPUTPCGMMerger::SortTracks(int nBlocks, int nThreads, int iBlock, in
17651764
GPUd() void GPUTPCGMMerger::SortTracksQPt(int nBlocks, int nThreads, int iBlock, int iThread)
17661765
{
17671766
unsigned int* trackSort = (unsigned int*)mTmpMem;
1768-
auto comp = [cmp = mOutputTracks](const int aa, const int bb) { // Have to duplicate sort comparison: Thrust cannot use the Lambda but OpenCL cannot use the object
1767+
// Have to duplicate sort comparison: Thrust cannot use the Lambda but OpenCL cannot use the object
1768+
auto comp = [cmp = mOutputTracks](const int aa, const int bb) {
17691769
const GPUTPCGMMergedTrack& GPUrestrict() a = cmp[aa];
17701770
const GPUTPCGMMergedTrack& GPUrestrict() b = cmp[bb];
17711771
return (CAMath::Abs(a.GetParam().GetQPt()) > CAMath::Abs(b.GetParam().GetQPt()));

GPU/GPUTracking/Merger/GPUTPCGMPropagator.cxx

Lines changed: 43 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,16 @@
2929

3030
using 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

539554
GPUd() 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]);

GPU/GPUTracking/Merger/GPUTPCGMPropagator.h

Lines changed: 76 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,17 @@ class GPUTPCGMPropagator
5555
GPUdDefault() GPUTPCGMPropagator() CON_DEFAULT;
5656

5757
struct MaterialCorrection {
58-
GPUhd() MaterialCorrection() : radLen(29.532f), rho(1.025e-3f), rhoOverRadLen(rho / radLen), DLMax(0.f), EP2(0.f), sigmadE2(0.f), k22(0.f), k33(0.f), k43(0.f), k44(0.f) {}
58+
GPUhd() MaterialCorrection() : radLen(28811.7f), rho(1.025e-3f), radLenInv(1.f / radLen), DLMax(0.f), EP2(0.f), sigmadE2(0.f), k22(0.f), k33(0.f), k43(0.f), k44(0.f) {}
5959

60-
float radLen, rho, rhoOverRadLen, DLMax, EP2, sigmadE2, k22, k33, k43, k44; // precalculated values for MS and EnergyLoss correction
60+
float radLen; // [cm]
61+
float rho; // [g/cm^3]
62+
float radLenInv, DLMax, EP2, sigmadE2, k22, k33, k43, k44; // precalculated values for MS and EnergyLoss correction
6163
};
6264

6365
GPUd() void SetMaterial(float radLen, float rho);
64-
GPUd() o2::base::MatBudget getMatBudget(float* p1, float* p2);
66+
GPUd() void SetMaterialTPC() { SetMaterial(28811.7f, 1.025e-3f); }
67+
68+
GPUd() o2::base::MatBudget getMatBudget(const float* p1, const float* p2);
6569

6670
GPUd() void SetPolynomialField(const GPUTPCGMPolynomialField* field) { mField = field; }
6771

@@ -109,7 +113,14 @@ class GPUTPCGMPropagator
109113
return 0;
110114
}
111115

116+
/// Bz in local coordinates rotated to mAlpha
117+
GPUd() float GetBz(float X, float Y, float Z) const;
118+
/// Bx,By,Bz in local coordinates rotated to mAlpha
119+
GPUd() void GetBxByBz(float X, float Y, float Z, float B[3]) const;
120+
121+
/// Bz in local coordinates rotated to Alpha
112122
GPUd() float GetBz(float Alpha, float X, float Y, float Z) const;
123+
/// Bx,By,Bz in local coordinates rotated to Alpha
113124
GPUd() void GetBxByBz(float Alpha, float X, float Y, float Z, float B[3]) const;
114125

115126
GPUd() void GetErr2(float& err2Y, float& err2Z, const GPUParam& param, float posZ, int iRow, short clusterState) const;
@@ -137,11 +148,26 @@ class GPUTPCGMPropagator
137148
GPUd() static float ApproximateBetheBloch(float beta2);
138149
GPUd() int FollowLinearization(const GPUTPCGMPhysicalTrackModel& t0e, float Bz, float dLp, bool inFlyDirection);
139150

151+
/// Bz in local coordinates rotated to cosAlpha, sinAlpha
152+
GPUd() float GetBzBase(float cosAlpha, float sinAlpha, float X, float Y, float Z) const;
153+
/// Bx,By,Bz in local coordinates rotated to cosAlpha, sinAlpha
154+
GPUd() void GetBxByBzBase(float cosAlpha, float sinAlpha, float X, float Y, float Z, float B[3]) const;
155+
// X in global coordinates
156+
GPUd() float getGlobalX(float cosAlpha, float sinAlpha, float X, float Y) const;
157+
// Y in global coordinates
158+
GPUd() float getGlobalY(float cosAlpha, float sinAlpha, float X, float Y) const;
159+
// X in global coordinates
160+
GPUd() float getGlobalX(float X, float Y) const;
161+
// Y in global coordinates
162+
GPUd() float getGlobalY(float X, float Y) const;
163+
140164
const GPUTPCGMPolynomialField* mField = nullptr;
141165
FieldRegion mFieldRegion = TPC;
142166

143167
GPUTPCGMTrackParam* mT = nullptr;
144-
float mAlpha = 0; // rotation angle of the track coordinate system
168+
float mAlpha = 0.f; // rotation angle of the track coordinate system
169+
float mCosAlpha = 1.f; // cos of the rotation angle
170+
float mSinAlpha = 0.f; // sin of the rotation angle
145171
GPUTPCGMPhysicalTrackModel mT0;
146172
MaterialCorrection mMaterial;
147173
bool mSeedingErrors = 0;
@@ -154,11 +180,31 @@ class GPUTPCGMPropagator
154180
const o2::base::MatLayerCylSet* mMatLUT = nullptr;
155181
};
156182

183+
GPUdi() void GPUTPCGMPropagator::GetBxByBz(float Alpha, float X, float Y, float Z, float B[3]) const
184+
{
185+
GetBxByBzBase(CAMath::Cos(Alpha), CAMath::Sin(Alpha), X, Y, Z, B);
186+
}
187+
188+
GPUdi() float GPUTPCGMPropagator::GetBz(float Alpha, float X, float Y, float Z) const
189+
{
190+
return GetBzBase(CAMath::Cos(Alpha), CAMath::Sin(Alpha), X, Y, Z);
191+
}
192+
193+
GPUdi() void GPUTPCGMPropagator::GetBxByBz(float X, float Y, float Z, float B[3]) const
194+
{
195+
GetBxByBzBase(mCosAlpha, mSinAlpha, X, Y, Z, B);
196+
}
197+
198+
GPUdi() float GPUTPCGMPropagator::GetBz(float X, float Y, float Z) const
199+
{
200+
return GetBzBase(mCosAlpha, mSinAlpha, X, Y, Z);
201+
}
202+
157203
GPUdi() void GPUTPCGMPropagator::SetMaterial(float radLen, float rho)
158204
{
159205
mMaterial.rho = rho;
160206
mMaterial.radLen = radLen;
161-
mMaterial.rhoOverRadLen = (radLen > 1.e-4f) ? rho / radLen : 0.f;
207+
mMaterial.radLenInv = (radLen > 1.e-4f) ? 1.f / radLen : 0.f;
162208
CalculateMaterialCorrection();
163209
}
164210

@@ -170,12 +216,14 @@ GPUdi() void GPUTPCGMPropagator::SetTrack(GPUTPCGMTrackParam* GPUrestrict() trac
170216
}
171217
mT0.Set(*mT);
172218
mAlpha = Alpha;
219+
mCosAlpha = CAMath::Cos(mAlpha);
220+
mSinAlpha = CAMath::Sin(mAlpha);
173221
CalculateMaterialCorrection();
174222
}
175223

176224
GPUdi() float GPUTPCGMPropagator::GetMirroredYModel() const
177225
{
178-
float Bz = GetBz(mAlpha, mT0.GetX(), mT0.GetY(), mT0.GetZ());
226+
float Bz = GetBz(mT0.GetX(), mT0.GetY(), mT0.GetZ());
179227
return mT0.GetMirroredY(Bz);
180228
}
181229

@@ -184,9 +232,30 @@ GPUdi() float GPUTPCGMPropagator::GetMirroredYTrack() const
184232
if (!mT) {
185233
return -1.E10f;
186234
}
187-
float Bz = GetBz(mAlpha, mT->GetX(), mT->GetY(), mT->GetZ());
235+
float Bz = GetBz(mT->GetX(), mT->GetY(), mT->GetZ());
188236
return mT->GetMirroredY(Bz);
189237
}
238+
239+
GPUdi() float GPUTPCGMPropagator::getGlobalX(float cosAlpha, float sinAlpha, float X, float Y) const
240+
{
241+
return X * cosAlpha - Y * sinAlpha;
242+
}
243+
244+
GPUdi() float GPUTPCGMPropagator::getGlobalY(float cosAlpha, float sinAlpha, float X, float Y) const
245+
{
246+
return X * sinAlpha + Y * cosAlpha;
247+
}
248+
249+
GPUdi() float GPUTPCGMPropagator::getGlobalX(float X, float Y) const
250+
{
251+
return getGlobalX(mCosAlpha, mSinAlpha, X, Y);
252+
}
253+
254+
GPUdi() float GPUTPCGMPropagator::getGlobalY(float X, float Y) const
255+
{
256+
return getGlobalY(mCosAlpha, mSinAlpha, X, Y);
257+
}
258+
190259
} // namespace gpu
191260
} // namespace GPUCA_NAMESPACE
192261

0 commit comments

Comments
 (0)