forked from AliceO2Group/AliceO2
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathGPUTrackingRefit.cxx
More file actions
448 lines (424 loc) · 20.5 KB
/
GPUTrackingRefit.cxx
File metadata and controls
448 lines (424 loc) · 20.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
/// \file GPUTrackingRefit.cxx
/// \author David Rohr
#define GPUCA_CADEBUG 0
#include "GPUTrackingRefit.h"
#include "GPUO2DataTypes.h"
#include "GPUTPCGMTrackParam.h"
#include "GPUTPCGMMergedTrack.h"
#include "GPUTPCGMPropagator.h"
#include "GPUConstantMem.h"
#include "ReconstructionDataFormats/Track.h"
#include "CorrectionMapsHelper.h"
#include "DetectorsBase/Propagator.h"
#include "DataFormatsTPC/TrackTPC.h"
#include "GPUParam.inc"
#include "GPUCommonArray.h"
#include "GPUParam.h"
#include "GPUTrackParamConvert.h"
#ifndef GPUCA_GPUCODE_DEVICE
#include <type_traits>
#endif
using namespace o2::gpu;
using namespace o2::track;
using namespace o2::base;
using namespace o2::tpc;
static constexpr int32_t kIGNORE_ENDS = 3;
#define IgnoreErrors(SNP) \
if (mIgnoreErrorsOnTrackEnds) { \
if (abs(i - stop) <= kIGNORE_ENDS && (CAMath::Abs(SNP) >= Propagator::MAX_SIN_PHI || abs(start - stop) < 30)) { \
break; \
} \
if (abs(i - start) <= kIGNORE_ENDS && (CAMath::Abs(SNP) >= Propagator::MAX_SIN_PHI || abs(start - stop) < 30)) { \
continue; \
} \
}
// End IgnoreErrors
#ifndef GPUCA_GPUCODE
void GPUTrackingRefitProcessor::InitializeProcessor()
{
}
void GPUTrackingRefitProcessor::RegisterMemoryAllocation()
{
AllocateAndInitializeLate();
}
void GPUTrackingRefitProcessor::SetMaxData(const GPUTrackingInOutPointers& io)
{
}
#endif
namespace o2::gpu::internal
{
namespace // anonymous
{
template <class T>
struct refitTrackTypes;
template <>
struct refitTrackTypes<GPUTPCGMTrackParam> {
using propagator = GPUTPCGMPropagator;
};
template <>
struct refitTrackTypes<TrackParCov> {
using propagator = const Propagator*;
};
} // anonymous namespace
} // namespace o2::gpu::internal
template <>
GPUd() void GPUTrackingRefit::initProp<GPUgeneric() GPUTPCGMPropagator>(GPUTPCGMPropagator& prop) // FIXME: GPUgeneric() needed to make the clang spirv output link correctly
{
prop.SetMaterialTPC();
prop.SetMaxSinPhi(GPUCA_MAX_SIN_PHI);
prop.SetSeedingErrors(false);
prop.SetFitInProjections(mPparam->rec.fitInProjections != 0);
prop.SetPropagateBzOnly(false);
prop.SetPolynomialField(&mPparam->polynomialField);
prop.SetMatLUT(mPmatLUT);
}
template <>
GPUd() void GPUTrackingRefit::initProp<const Propagator * GPUgeneric()>(const Propagator*& prop) // FIXME: GPUgeneric() needed to make the clang spirv output link correctly
{
prop = mPpropagator;
}
template <class T, class S, class U>
GPUd() void GPUTrackingRefit::convertTrack(T& trk, const S& trkX, U& prop, float* chi2)
{
trk = trkX;
}
// Generic
template <>
GPUd() void GPUTrackingRefit::convertTrack<GPUTPCGMTrackParam, TrackParCov, GPUTPCGMPropagator>(GPUTPCGMTrackParam& trk, const TrackParCov& trkX, GPUTPCGMPropagator& prop, float* chi2)
{
convertTrackParam(trk, trkX);
prop.SetTrack(&trk, trkX.getAlpha());
}
template <>
GPUd() void GPUTrackingRefit::convertTrack<TrackParCov, GPUTPCGMTrackParam, GPUTPCGMPropagator>(TrackParCov& trk, const GPUTPCGMTrackParam& trkX, GPUTPCGMPropagator& prop, float* chi2)
{
convertTrackParam(trk, trkX);
trk.setAlpha(prop.GetAlpha());
}
// GPUTPCGMMergedTrack input
template <>
GPUd() void GPUTrackingRefit::convertTrack<TrackParCov, GPUTPCGMMergedTrack, const Propagator*>(TrackParCov& trk, const GPUTPCGMMergedTrack& trkX, const Propagator*& prop, float* chi2)
{
initProp(prop);
convertTrackParam(trk, trkX.GetParam());
trk.setAlpha(trkX.GetAlpha());
*chi2 = trkX.GetParam().GetChi2();
}
template <>
GPUd() void GPUTrackingRefit::convertTrack<GPUTPCGMMergedTrack, TrackParCov, const Propagator*>(GPUTPCGMMergedTrack& trk, const TrackParCov& trkX, const Propagator*& prop, float* chi2)
{
convertTrackParam(trk.Param(), trkX);
trk.SetAlpha(trkX.getAlpha());
trk.Param().SetChi2(*chi2);
}
template <>
GPUd() void GPUTrackingRefit::convertTrack<GPUTPCGMTrackParam, GPUTPCGMMergedTrack, GPUTPCGMPropagator>(GPUTPCGMTrackParam& trk, const GPUTPCGMMergedTrack& trkX, GPUTPCGMPropagator& prop, float* chi2)
{
initProp(prop);
trk = trkX.GetParam();
prop.SetTrack(&trk, trkX.GetAlpha());
}
template <>
GPUd() void GPUTrackingRefit::convertTrack<GPUTPCGMMergedTrack, GPUTPCGMTrackParam, GPUTPCGMPropagator>(GPUTPCGMMergedTrack& trk, const GPUTPCGMTrackParam& trkX, GPUTPCGMPropagator& prop, float* chi2)
{
trk.SetParam(trkX);
trk.SetAlpha(prop.GetAlpha());
}
// TrackTPC input
template <>
GPUd() void GPUTrackingRefit::convertTrack<TrackParCov, TrackTPC, const Propagator*>(TrackParCov& trk, const TrackTPC& trkX, const Propagator*& prop, float* chi2)
{
initProp(prop);
convertTrack<TrackParCov, TrackParCov, const Propagator*>(trk, trkX, prop, nullptr);
*chi2 = trkX.getChi2();
}
template <>
GPUd() void GPUTrackingRefit::convertTrack<TrackTPC, TrackParCov, const Propagator*>(TrackTPC& trk, const TrackParCov& trkX, const Propagator*& prop, float* chi2)
{
convertTrack<TrackParCov, TrackParCov, const Propagator*>(trk, trkX, prop, nullptr);
trk.setChi2(*chi2);
}
template <>
GPUd() void GPUTrackingRefit::convertTrack<GPUTPCGMTrackParam, TrackTPC, GPUTPCGMPropagator>(GPUTPCGMTrackParam& trk, const TrackTPC& trkX, GPUTPCGMPropagator& prop, float* chi2)
{
initProp(prop);
convertTrack<GPUTPCGMTrackParam, TrackParCov, GPUTPCGMPropagator>(trk, trkX, prop, nullptr);
trk.SetChi2(trkX.getChi2());
}
template <>
GPUd() void GPUTrackingRefit::convertTrack<TrackTPC, GPUTPCGMTrackParam, GPUTPCGMPropagator>(TrackTPC& trk, const GPUTPCGMTrackParam& trkX, GPUTPCGMPropagator& prop, float* chi2)
{
convertTrack<TrackParCov, GPUTPCGMTrackParam, GPUTPCGMPropagator>(trk, trkX, prop, nullptr);
trk.setChi2(trkX.GetChi2());
}
// TrackParCovWithArgs input
template <>
GPUd() void GPUTrackingRefit::convertTrack<TrackParCov, GPUTrackingRefit::TrackParCovWithArgs, const Propagator*>(TrackParCov& trk, const GPUTrackingRefit::TrackParCovWithArgs& trkX, const Propagator*& prop, float* chi2)
{
initProp(prop);
convertTrack<TrackParCov, TrackParCov, const Propagator*>(trk, trkX.trk, prop, nullptr);
*chi2 = trkX.chi2 ? *trkX.chi2 : 0.f;
}
template <>
GPUd() void GPUTrackingRefit::convertTrack<GPUTrackingRefit::TrackParCovWithArgs, TrackParCov, const Propagator*>(GPUTrackingRefit::TrackParCovWithArgs& trk, const TrackParCov& trkX, const Propagator*& prop, float* chi2)
{
convertTrack<TrackParCov, TrackParCov, const Propagator*>(trk.trk, trkX, prop, nullptr);
if (trk.chi2) {
*trk.chi2 = *chi2;
}
}
template <>
GPUd() void GPUTrackingRefit::convertTrack<GPUTPCGMTrackParam, GPUTrackingRefit::TrackParCovWithArgs, GPUTPCGMPropagator>(GPUTPCGMTrackParam& trk, const GPUTrackingRefit::TrackParCovWithArgs& trkX, GPUTPCGMPropagator& prop, float* chi2)
{
initProp(prop);
convertTrack<GPUTPCGMTrackParam, TrackParCov, GPUTPCGMPropagator>(trk, trkX.trk, prop, nullptr);
trk.SetChi2(trkX.chi2 ? *trkX.chi2 : 0.f);
}
template <>
GPUd() void GPUTrackingRefit::convertTrack<GPUTrackingRefit::TrackParCovWithArgs, GPUTPCGMTrackParam, GPUTPCGMPropagator>(GPUTrackingRefit::TrackParCovWithArgs& trk, const GPUTPCGMTrackParam& trkX, GPUTPCGMPropagator& prop, float* chi2)
{
convertTrack<TrackParCov, GPUTPCGMTrackParam, GPUTPCGMPropagator>(trk.trk, trkX, prop, chi2);
if (trk.chi2) {
*trk.chi2 = trkX.GetChi2();
}
}
GPUd() static const float* getPar(const GPUTPCGMTrackParam& trk) { return trk.GetPar(); }
GPUd() static const float* getPar(const TrackParCov& trk) { return trk.getParams(); }
template <class T, class S>
GPUd() int32_t GPUTrackingRefit::RefitTrack(T& trkX, bool outward, bool resetCov)
{
CADEBUG(int32_t ii; printf("\nRefitting track\n"));
typename internal::refitTrackTypes<S>::propagator prop;
S trk;
float TrackParCovChi2 = 0.f;
convertTrack<S, T, typename internal::refitTrackTypes<S>::propagator>(trk, trkX, prop, &TrackParCovChi2);
int32_t begin = 0, count;
float tOffset;
if constexpr (std::is_same_v<T, GPUTPCGMMergedTrack>) {
count = trkX.NClusters();
if (trkX.Looper()) {
int32_t leg = mPtrackHits[trkX.FirstClusterRef() + trkX.NClusters() - 1].leg;
for (int32_t i = trkX.NClusters() - 2; i > 0; i--) {
if (mPtrackHits[trkX.FirstClusterRef() + i].leg != leg) {
begin = i + 1;
break;
}
}
}
tOffset = trkX.GetParam().GetTZOffset();
} else if constexpr (std::is_same_v<T, TrackTPC>) {
count = trkX.getNClusters();
tOffset = trkX.getTime0();
} else if constexpr (std::is_same_v<T, TrackParCovWithArgs>) {
count = trkX.clusRef.getEntries();
tOffset = trkX.time0;
} else {
static_assert("Invalid template");
}
if constexpr (std::is_same_v<S, GPUTPCGMTrackParam>) {
CADEBUG(printf("\t%21sInit Alpha %8.3f , X %8.3f - Y %8.3f, Z %8.3f - QPt %7.2f (%7.2f), SP %5.2f (%5.2f) --- Cov sY %8.3f sZ %8.3f sSP %8.3f sPt %8.3f\n", "", prop.GetAlpha(), trk.GetX(), trk.Par()[0], trk.Par()[1], trk.Par()[4], prop.GetQPt0(), trk.Par()[2], prop.GetSinPhi0(), sqrtf(trk.Cov()[0]), sqrtf(trk.Cov()[2]), sqrtf(trk.Cov()[5]), sqrtf(trk.Cov()[14])));
}
int32_t direction = outward ? -1 : 1;
int32_t start = outward ? count - 1 : begin;
int32_t stop = outward ? begin - 1 : count;
const ClusterNative* cl = nullptr;
uint8_t sector = 255, row = 255;
int32_t lastSector = -1, currentSector = -1, currentRow = -1;
int16_t clusterState = 0, nextState = 0;
int32_t nFitted = 0;
float sumInvSqrtCharge = 0.f;
int32_t nAvgCharge = 0;
for (int32_t i = start; i != stop; i += cl ? 0 : direction) {
float x = 0, y = 0, z = 0, charge = 0; // FIXME: initialization unneeded, but GCC incorrectly produces uninitialized warnings otherwise
float time = 0.f, invCharge = 0.f, invSqrtCharge = 0.f; // Same here...
int32_t clusters = 0;
while (true) {
if (!cl) {
CADEBUG(ii = i);
if constexpr (std::is_same_v<T, GPUTPCGMMergedTrack>) {
const auto& hit = mPtrackHits[trkX.FirstClusterRef() + i];
cl = &mPclusterNative->clustersLinear[hit.num];
if (hit.state & (GPUTPCGMMergedTrackHit::flagReject | GPUTPCGMMergedTrackHit::flagHighIncl)) {
cl = nullptr;
if (i + direction != stop) {
i += direction;
continue;
}
break;
}
row = hit.row;
sector = hit.sector;
nextState = mPclusterState[hit.num];
} else if constexpr (std::is_same_v<T, TrackTPC>) {
cl = &trkX.getCluster(mPtrackHitReferences, i, *mPclusterNative, sector, row);
nextState = mPclusterState[cl - mPclusterNative->clustersLinear];
} else if constexpr (std::is_same_v<T, TrackParCovWithArgs>) {
cl = &TrackTPC::getCluster(mPtrackHitReferences, i, *mPclusterNative, sector, row, trkX.clusRef);
nextState = mPclusterState[cl - mPclusterNative->clustersLinear];
} else {
static_assert("Invalid template");
}
}
if (clusters == 0 || (row == currentRow && sector == currentSector)) {
if (clusters == 1) {
x *= charge;
y *= charge;
z *= charge;
}
if (clusters == 0) {
mPfastTransformHelper->Transform(sector, row, cl->getPad(), cl->getTime(), x, y, z, tOffset);
CADEBUG(printf("\tHit %3d/%3d Row %3d: Cluster Alpha %8.3f %3d, X %8.3f - Y %8.3f, Z %8.3f - State %d\n", ii, count, row, mPparam->Alpha(sector), (int32_t)sector, x, y, z, (int32_t)nextState));
currentRow = row;
currentSector = sector;
charge = cl->qTot;
clusterState = nextState;
time = cl->getTime();
invSqrtCharge = CAMath::InvSqrt(cl->qMax);
invCharge = (1.f / cl->qMax);
} else {
float xx, yy, zz;
mPfastTransformHelper->Transform(sector, row, cl->getPad(), cl->getTime(), xx, yy, zz, tOffset);
CADEBUG(printf("\tHit %3d/%3d Row %3d: Cluster Alpha %8.3f %3d, X %8.3f - Y %8.3f, Z %8.3f - State %d\n", ii, count, row, mPparam->Alpha(sector), (int32_t)sector, xx, yy, zz, (int32_t)nextState));
x += xx * cl->qTot;
y += yy * cl->qTot;
z += zz * cl->qTot;
charge += cl->qTot;
clusterState |= nextState;
}
cl = nullptr;
clusters++;
if (i + direction != stop) {
i += direction;
continue;
}
}
break;
}
if (clusters == 0) {
continue;
} else if (clusters > 1) {
x /= charge;
y /= charge;
z /= charge;
CADEBUG(printf("\tMerged Hit Row %3d: Cluster Alpha %8.3f %3d, X %8.3f - Y %8.3f, Z %8.3f - State %d\n", row, mPparam->Alpha(sector), (int32_t)sector, x, y, z, (int32_t)clusterState));
}
float invAvgCharge = (sumInvSqrtCharge += invSqrtCharge) / ++nAvgCharge;
invAvgCharge *= invAvgCharge;
if constexpr (std::is_same_v<S, GPUTPCGMTrackParam>) {
if (prop.PropagateToXAlpha(x, mPparam->Alpha(currentSector), !outward)) {
IgnoreErrors(trk.GetSinPhi());
return -2;
}
if (resetCov) {
trk.ResetCovariance();
} else if (lastSector != -1 && (lastSector < 18) != (sector < 18)) {
if (mPparam->rec.tpc.addErrorsCECrossing) {
if (mPparam->rec.tpc.addErrorsCECrossing >= 2) {
trk.AddCovDiagErrorsWithCorrelations(mPparam->rec.tpc.errorsCECrossing);
} else {
trk.AddCovDiagErrors(mPparam->rec.tpc.errorsCECrossing);
}
} else if (trk.Cov()[2] < 0.5f) {
trk.Cov()[2] = 0.5f;
}
}
CADEBUG(printf("\t%21sPropaga Alpha %8.3f , X %8.3f - Y %8.3f, Z %8.3f - QPt %7.2f (%7.2f), SP %5.2f (%5.2f) --- Res %8.3f %8.3f --- Cov sY %8.3f sZ %8.3f sSP %8.3f sPt %8.3f - YPt %8.3f\n", "", prop.GetAlpha(), x, trk.Par()[0], trk.Par()[1], trk.Par()[4], prop.GetQPt0(), trk.Par()[2], prop.GetSinPhi0(), trk.Par()[0] - y, trk.Par()[1] - z, sqrtf(trk.Cov()[0]), sqrtf(trk.Cov()[2]), sqrtf(trk.Cov()[5]), sqrtf(trk.Cov()[14]), trk.Cov()[10]));
lastSector = sector;
if (prop.Update(y, z, row, *mPparam, clusterState, 0, nullptr, true, sector, time, invAvgCharge, invCharge)) {
IgnoreErrors(trk.GetSinPhi());
return -3;
}
trk.ConstrainSinPhi();
CADEBUG(printf("\t%21sFit Alpha %8.3f , X %8.3f - Y %8.3f, Z %8.3f - QPt %7.2f (%7.2f), SP %5.2f (%5.2f), DzDs %5.2f %16s --- Cov sY %8.3f sZ %8.3f sSP %8.3f sPt %8.3f - YPt %8.3f\n", "", prop.GetAlpha(), x, trk.Par()[0], trk.Par()[1], trk.Par()[4], prop.GetQPt0(), trk.Par()[2], prop.GetSinPhi0(), trk.Par()[3], "", sqrtf(trk.Cov()[0]), sqrtf(trk.Cov()[2]), sqrtf(trk.Cov()[5]), sqrtf(trk.Cov()[14]), trk.Cov()[10]));
} else if constexpr (std::is_same_v<S, TrackParCov>) {
if (!trk.rotate(mPparam->Alpha(currentSector))) {
IgnoreErrors(trk.getSnp());
return -1;
}
if (!prop->PropagateToXBxByBz(trk, x, GPUCA_MAX_SIN_PHI_LOW)) {
IgnoreErrors(trk.getSnp());
return -2;
}
if (lastSector != -1 && (lastSector < 18) != (sector < 18)) {
if (mPparam->rec.tpc.addErrorsCECrossing) {
trk.updateCov(mPparam->rec.tpc.errorsCECrossing, mPparam->rec.tpc.addErrorsCECrossing >= 2);
} else if (trk.getCov()[2] < 0.5f) {
trk.setCov(0.5f, 2);
}
}
if (resetCov) {
trk.resetCovariance();
float bzkG = prop->getNominalBz(), qptB5Scale = CAMath::Abs(bzkG) > 0.1f ? CAMath::Abs(bzkG) / 5.006680f : 1.f;
float q2pt2 = trk.getQ2Pt() * trk.getQ2Pt(), q2pt2Wgh = q2pt2 * qptB5Scale * qptB5Scale;
float err2 = (100.f + q2pt2Wgh) / (1.f + q2pt2Wgh) * q2pt2; // -> 100 for high pTs, -> 1 for low pTs.
trk.setCov(err2, 14); // 100% error
TrackParCovChi2 = 0.f;
}
CADEBUG(printf("\t%21sPropaga Alpha %8.3f , X %8.3f - Y %8.3f, Z %8.3f - QPt %7.2f (%7.2f), SP %5.2f (%5.2f) --- Res %8.3f %8.3f --- Cov sY %8.3f sZ %8.3f sSP %8.3f sPt %8.3f - YPt %8.3f\n", "", trk.getAlpha(), x, trk.getParams()[0], trk.getParams()[1], trk.getParams()[4], trk.getParams()[4], trk.getParams()[2], trk.getParams()[2], trk.getParams()[0] - y, trk.getParams()[1] - z, sqrtf(trk.getCov()[0]), sqrtf(trk.getCov()[2]), sqrtf(trk.getCov()[5]), sqrtf(trk.getCov()[14]), trk.getCov()[10]));
std::array<float, 2> p = {y, z};
std::array<float, 3> c = {0, 0, 0};
GPUTPCGMPropagator::GetErr2(c[0], c[2], *mPparam, getPar(trk)[2], getPar(trk)[3], z, x, y, currentRow, clusterState, sector, time, invAvgCharge, invCharge, false);
TrackParCovChi2 += trk.getPredictedChi2(p, c);
if (!trk.update(p, c)) {
IgnoreErrors(trk.getSnp());
return -3;
}
CADEBUG(printf("\t%21sFit Alpha %8.3f , X %8.3f - Y %8.3f, Z %8.3f - QPt %7.2f (%7.2f), SP %5.2f (%5.2f), DzDs %5.2f %16s --- Cov sY %8.3f sZ %8.3f sSP %8.3f sPt %8.3f - YPt %8.3f\n", "", trk.getAlpha(), x, trk.getParams()[0], trk.getParams()[1], trk.getParams()[4], trk.getParams()[4], trk.getParams()[2], trk.getParams()[2], trk.getParams()[3], "", sqrtf(trk.getCov()[0]), sqrtf(trk.getCov()[2]), sqrtf(trk.getCov()[5]), sqrtf(trk.getCov()[14]), trk.getCov()[10]));
} else {
static_assert("Invalid template");
}
resetCov = false;
nFitted++;
}
if constexpr (std::is_same_v<S, GPUTPCGMTrackParam>) {
float alpha = prop.GetAlpha();
trk.MoveToReference(prop, *mPparam, alpha);
trk.NormalizeAlpha(alpha);
prop.SetAlpha(alpha);
} else if constexpr (std::is_same_v<S, TrackParCov>) {
static constexpr float kDeg2Rad = M_PI / 180.f;
static constexpr float kSectAngle = 2 * M_PI / 18.f;
if (mPparam->rec.tpc.trackReferenceX <= 500) {
if (prop->PropagateToXBxByBz(trk, mPparam->rec.tpc.trackReferenceX)) {
if (CAMath::Abs(trk.getY()) > trk.getX() * CAMath::Tan(kSectAngle / 2.f)) {
float newAlpha = trk.getAlpha() + CAMath::Round(CAMath::ATan2(trk.getY(), trk.getX()) / kDeg2Rad / 20.f) * kSectAngle;
GPUTPCGMTrackParam::NormalizeAlpha(newAlpha);
trk.rotate(newAlpha) && prop->PropagateToXBxByBz(trk, mPparam->rec.tpc.trackReferenceX);
}
}
}
} else {
static_assert("Invalid template");
}
convertTrack<T, S, typename internal::refitTrackTypes<S>::propagator>(trkX, trk, prop, &TrackParCovChi2);
return nFitted;
}
#if !defined(GPUCA_GPUCODE) || defined(GPUCA_GPUCODE_DEVICE) // FIXME: DR: WORKAROUND to avoid CUDA bug creating host symbols for device code.
template GPUdni() int32_t GPUTrackingRefit::RefitTrack<GPUTPCGMMergedTrack, TrackParCov>(GPUTPCGMMergedTrack& trk, bool outward, bool resetCov);
template GPUdni() int32_t GPUTrackingRefit::RefitTrack<GPUTPCGMMergedTrack, GPUTPCGMTrackParam>(GPUTPCGMMergedTrack& trk, bool outward, bool resetCov);
template GPUdni() int32_t GPUTrackingRefit::RefitTrack<TrackTPC, TrackParCov>(TrackTPC& trk, bool outward, bool resetCov);
template GPUdni() int32_t GPUTrackingRefit::RefitTrack<TrackTPC, GPUTPCGMTrackParam>(TrackTPC& trk, bool outward, bool resetCov);
template GPUdni() int32_t GPUTrackingRefit::RefitTrack<GPUTrackingRefit::TrackParCovWithArgs, TrackParCov>(GPUTrackingRefit::TrackParCovWithArgs& trk, bool outward, bool resetCov);
template GPUdni() int32_t GPUTrackingRefit::RefitTrack<GPUTrackingRefit::TrackParCovWithArgs, GPUTPCGMTrackParam>(GPUTrackingRefit::TrackParCovWithArgs& trk, bool outward, bool resetCov);
#endif
#ifndef GPUCA_GPUCODE
void GPUTrackingRefit::SetPtrsFromGPUConstantMem(const GPUConstantMem* v, GPUParam* p)
{
mPclusterState = v->ioPtrs.mergedTrackHitStates;
mPclusterNative = v->ioPtrs.clustersNative;
mPtrackHits = v->ioPtrs.mergedTrackHits;
mPfastTransformHelper = v->calibObjects.fastTransformHelper;
mPmatLUT = v->calibObjects.matLUT;
mPparam = p ? p : &v->param;
}
#endif