Skip to content

Commit a63f272

Browse files
committed
GPU: simplifaction, refactoring and some minor improvements
1 parent be06302 commit a63f272

File tree

5 files changed

+168
-191
lines changed

5 files changed

+168
-191
lines changed

GPU/GPUTracking/Definitions/GPUSettingsList.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ AddOptionRTC(nWays, uint8_t, 3, "", 0, "Do N fit passes in final fit of merger (
137137
AddOptionRTC(rebuildTrackInFit, uint8_t, 1, "", 0, "Rebuild track completely during fit based on clusters closed to interpolated track positions")
138138
AddOptionRTC(rebuildTrackInFitClusterCandidates, uint8_t, 3, "", 0, "Number of cluster candidates per row for rebuilt track")
139139
AddOptionRTC(rebuildTrackMaxSharedFraction, float, 0.1f, "", 0, "Max fraction of shared clusters for rebuilt tracks")
140-
AddOptionRTC(trackFitRejectMode, int8_t, 5, "", 0, "0: no limit on rejection or missed hits, >0: break after n rejected hits, <0: reject at max -n hits")
140+
AddOptionRTC(trackFitRejectMode, int8_t, 5, "", 0, "0: no limit on rejection or missed hits, >0: break after n rejected hits")
141141
AddOptionRTC(rejectIFCLowRadiusCluster, uint8_t, 1, "", 0, "Reject clusters that get the IFC mask error during refit")
142142
AddOptionRTC(dEdxTruncLow, uint8_t, 2, "", 0, "Low truncation threshold, fraction of 128")
143143
AddOptionRTC(dEdxTruncHigh, uint8_t, 77, "", 0, "High truncation threshold, fraction of 128")

GPU/GPUTracking/Merger/GPUTPCGMPropagator.cxx

Lines changed: 74 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -608,15 +608,15 @@ GPUd() float GPUTPCGMPropagator::PredictChi2(float posY, float posZ, float err2Y
608608
}
609609
}
610610

611-
GPUd() int32_t GPUTPCGMPropagator::Update(float posY, float posZ, int32_t iRow, const GPUParam& GPUrestrict() param, int16_t clusterState, int8_t rejectChi2, bool refit, int8_t sector, float time, float avgInvCharge, float invCharge)
611+
GPUd() int32_t GPUTPCGMPropagator::Update(float posY, float posZ, int32_t iRow, const GPUParam& GPUrestrict() param, int16_t clusterState, bool rejectChi2, bool refit, int8_t sector, float time, float avgInvCharge, float invCharge)
612612
{
613613
float err2Y, err2Z;
614614
GetErr2(err2Y, err2Z, param, posZ, iRow, clusterState, sector, time, avgInvCharge, invCharge);
615615

616616
return Update(posY, posZ, iRow, param, clusterState, rejectChi2, refit, err2Y, err2Z);
617617
}
618618

619-
GPUd() int32_t GPUTPCGMPropagator::Update(float posY, float posZ, int32_t iRow, const GPUParam& GPUrestrict() param, int16_t clusterState, int8_t rejectChi2, bool refit, float err2Y, float err2Z)
619+
GPUd() int32_t GPUTPCGMPropagator::Update(float posY, float posZ, int32_t iRow, const GPUParam& GPUrestrict() param, int16_t clusterState, bool rejectChi2, bool refit, float err2Y, float err2Z)
620620
{
621621
if (mT->NDF() == -5) { // first measurement: no need to filter, as the result is known in advance. just set it.
622622
mT->ResetCovariance();
@@ -635,80 +635,83 @@ GPUd() int32_t GPUTPCGMPropagator::Update(float posY, float posZ, int32_t iRow,
635635
return 0;
636636
}
637637

638-
return Update(posY, posZ, clusterState, rejectChi2 == rejectDirect, err2Y, err2Z, &param);
638+
return Update(posY, posZ, clusterState, rejectChi2, err2Y, err2Z, &param);
639639
}
640640

641-
GPUd() int32_t GPUTPCGMPropagator::InterpolateReject(const GPUParam& GPUrestrict() param, float posY, float posZ, int16_t clusterState, int8_t rejectChi2, gputpcgmmergertypes::InterpolationErrorHit* inter, float err2Y, float err2Z, float deltaZ)
641+
GPUd() void GPUTPCGMPropagator::InterpolateFill(float posY, float posZ, gputpcgmmergertypes::InterpolationErrorHit* inter)
642642
{
643643
float* GPUrestrict() mC = mT->Cov();
644644
float* GPUrestrict() mP = mT->Par();
645-
if (rejectChi2 == rejectInterFill) {
646-
inter->posY = mP[0];
647-
inter->posZ = mP[1];
648-
if (mT->NDF() <= 0) {
649-
inter->errorY = inter->errorZ = 100.f;
650-
} else {
651-
inter->errorY = mC[0];
652-
inter->errorZ = mC[2];
653-
}
654-
} else if (rejectChi2 == rejectInterReject) {
655-
float chi2Y, chi2Z;
656-
if (mT->NDF() <= 0) {
657-
chi2Y = CAMath::Square((float)inter->posY - posY) / ((float)inter->errorY + err2Y);
658-
chi2Z = CAMath::Square((float)inter->posZ + deltaZ - posZ) / ((float)inter->errorZ + err2Z);
659-
} else if (mFitInProjections) {
660-
const float Iz0 = inter->posY - mP[0];
661-
const float Iz1 = inter->posZ + deltaZ - mP[1];
662-
const float Iw0 = 1.f / (mC[0] + (float)inter->errorY);
663-
const float Iw2 = 1.f / (mC[2] + (float)inter->errorZ);
664-
const float Ik00 = mC[0] * Iw0;
665-
const float Ik11 = mC[2] * Iw2;
666-
const float ImP0 = mP[0] + Ik00 * Iz0;
667-
const float ImP1 = mP[1] + Ik11 * Iz1;
668-
const float ImC0 = mC[0] - Ik00 * mC[0];
669-
const float ImC2 = mC[2] - Ik11 * mC[2];
670-
// printf("\t%21sInterpo ----- abde artaf%16s Y %8.3f, Z %8.3f (Errors %f <-- (%f, %f) %f <-- (%f, %f))\n", "", "", ImP0, ImP1, sqrtf(ImC0), sqrtf(mC[0]), sqrtf(inter->errorY), sqrtf(ImC2), sqrtf(mC[2]), sqrtf(inter->errorZ));
671-
const float Jz0 = posY - ImP0;
672-
const float Jz1 = posZ - ImP1;
673-
const float Jw0 = 1.f / (ImC0 + err2Y);
674-
const float Jw2 = 1.f / (ImC2 + err2Z);
675-
chi2Y = Jw0 * Jz0 * Jz0;
676-
chi2Z = Jw2 * Jz1 * Jz1;
677-
} else {
678-
const float Iz0 = inter->posY - mP[0];
679-
const float Iz1 = inter->posZ + deltaZ - mP[1];
680-
float Iw0 = mC[2] + (float)inter->errorZ;
681-
float Iw2 = mC[0] + (float)inter->errorY;
682-
float Idet = CAMath::Max(1e-10f, Iw0 * Iw2 - mC[1] * mC[1]);
683-
Idet = 1.f / Idet;
684-
Iw0 *= Idet;
685-
const float Iw1 = mC[1] * Idet;
686-
Iw2 *= Idet;
687-
const float Ik00 = mC[0] * Iw0 + mC[1] * Iw1;
688-
const float Ik01 = mC[0] * Iw1 + mC[1] * Iw2;
689-
const float Ik10 = mC[1] * Iw0 + mC[2] * Iw1;
690-
const float Ik11 = mC[1] * Iw1 + mC[2] * Iw2;
691-
const float ImP0 = mP[0] + Ik00 * Iz0 + Ik01 * Iz1;
692-
const float ImP1 = mP[1] + Ik10 * Iz0 + Ik11 * Iz1;
693-
const float ImC0 = mC[0] - Ik00 * mC[0] + Ik01 * mC[1];
694-
const float ImC1 = mC[1] - Ik10 * mC[0] + Ik11 * mC[1];
695-
const float ImC2 = mC[2] - Ik10 * mC[1] + Ik11 * mC[2];
696-
const float Jz0 = posY - ImP0;
697-
const float Jz1 = posZ - ImP1;
698-
float Jw0 = ImC2 + err2Z;
699-
float Jw2 = ImC0 + err2Y;
700-
float Jdet = CAMath::Max(1e-10f, Jw0 * Jw2 - ImC1 * ImC1);
701-
Jdet = 1.f / Jdet;
702-
Jw0 *= Jdet;
703-
const float Jw1 = ImC1 * Jdet;
704-
Jw2 *= Jdet;
705-
chi2Y = CAMath::Abs((Jw0 * Jz0 + Jw1 * Jz1) * Jz0);
706-
chi2Z = CAMath::Abs((Jw1 * Jz0 + Jw2 * Jz1) * Jz1);
707-
}
708-
if (RejectCluster(chi2Y * param.rec.tpc.clusterRejectChi2TolleranceY, chi2Z * param.rec.tpc.clusterRejectChi2TolleranceZ, clusterState)) { // TODO: Relative Pt resolution decreases slightly, why?
709-
// printf("Reject Cluster chiy2 %f chiz2 %f (Pos Y: %f - %f %f ; Pos Z: %f - %f %f)\n", chi2Y, chi2Z, posY, mP[0], (float)inter->posY, posZ, mP[1], (float)inter->posZ + deltaZ);
710-
return updateErrorClusterRejectedInInterpolation;
711-
}
645+
inter->posY = mP[0];
646+
inter->posZ = mP[1];
647+
if (mT->NDF() <= 0) {
648+
inter->errorY = inter->errorZ = 100.f;
649+
} else {
650+
inter->errorY = mC[0];
651+
inter->errorZ = mC[2];
652+
}
653+
}
654+
655+
GPUd() int32_t GPUTPCGMPropagator::InterpolateReject(const GPUParam& GPUrestrict() param, float posY, float posZ, int16_t clusterState, gputpcgmmergertypes::InterpolationErrorHit* inter, float err2Y, float err2Z, float deltaZ)
656+
{
657+
float* GPUrestrict() mC = mT->Cov();
658+
float* GPUrestrict() mP = mT->Par();
659+
float chi2Y, chi2Z;
660+
if (mT->NDF() <= 0) {
661+
chi2Y = CAMath::Square((float)inter->posY - posY) / ((float)inter->errorY + err2Y);
662+
chi2Z = CAMath::Square((float)inter->posZ + deltaZ - posZ) / ((float)inter->errorZ + err2Z);
663+
} else if (mFitInProjections) {
664+
const float Iz0 = inter->posY - mP[0];
665+
const float Iz1 = inter->posZ + deltaZ - mP[1];
666+
const float Iw0 = 1.f / (mC[0] + (float)inter->errorY);
667+
const float Iw2 = 1.f / (mC[2] + (float)inter->errorZ);
668+
const float Ik00 = mC[0] * Iw0;
669+
const float Ik11 = mC[2] * Iw2;
670+
const float ImP0 = mP[0] + Ik00 * Iz0;
671+
const float ImP1 = mP[1] + Ik11 * Iz1;
672+
const float ImC0 = mC[0] - Ik00 * mC[0];
673+
const float ImC2 = mC[2] - Ik11 * mC[2];
674+
// printf("\t%21sInterpo ----- abde artaf%16s Y %8.3f, Z %8.3f (Errors %f <-- (%f, %f) %f <-- (%f, %f))\n", "", "", ImP0, ImP1, sqrtf(ImC0), sqrtf(mC[0]), sqrtf(inter->errorY), sqrtf(ImC2), sqrtf(mC[2]), sqrtf(inter->errorZ));
675+
const float Jz0 = posY - ImP0;
676+
const float Jz1 = posZ - ImP1;
677+
const float Jw0 = 1.f / (ImC0 + err2Y);
678+
const float Jw2 = 1.f / (ImC2 + err2Z);
679+
chi2Y = Jw0 * Jz0 * Jz0;
680+
chi2Z = Jw2 * Jz1 * Jz1;
681+
} else {
682+
const float Iz0 = inter->posY - mP[0];
683+
const float Iz1 = inter->posZ + deltaZ - mP[1];
684+
float Iw0 = mC[2] + (float)inter->errorZ;
685+
float Iw2 = mC[0] + (float)inter->errorY;
686+
float Idet = CAMath::Max(1e-10f, Iw0 * Iw2 - mC[1] * mC[1]);
687+
Idet = 1.f / Idet;
688+
Iw0 *= Idet;
689+
const float Iw1 = mC[1] * Idet;
690+
Iw2 *= Idet;
691+
const float Ik00 = mC[0] * Iw0 + mC[1] * Iw1;
692+
const float Ik01 = mC[0] * Iw1 + mC[1] * Iw2;
693+
const float Ik10 = mC[1] * Iw0 + mC[2] * Iw1;
694+
const float Ik11 = mC[1] * Iw1 + mC[2] * Iw2;
695+
const float ImP0 = mP[0] + Ik00 * Iz0 + Ik01 * Iz1;
696+
const float ImP1 = mP[1] + Ik10 * Iz0 + Ik11 * Iz1;
697+
const float ImC0 = mC[0] - Ik00 * mC[0] + Ik01 * mC[1];
698+
const float ImC1 = mC[1] - Ik10 * mC[0] + Ik11 * mC[1];
699+
const float ImC2 = mC[2] - Ik10 * mC[1] + Ik11 * mC[2];
700+
const float Jz0 = posY - ImP0;
701+
const float Jz1 = posZ - ImP1;
702+
float Jw0 = ImC2 + err2Z;
703+
float Jw2 = ImC0 + err2Y;
704+
float Jdet = CAMath::Max(1e-10f, Jw0 * Jw2 - ImC1 * ImC1);
705+
Jdet = 1.f / Jdet;
706+
Jw0 *= Jdet;
707+
const float Jw1 = ImC1 * Jdet;
708+
Jw2 *= Jdet;
709+
chi2Y = CAMath::Abs((Jw0 * Jz0 + Jw1 * Jz1) * Jz0);
710+
chi2Z = CAMath::Abs((Jw1 * Jz0 + Jw2 * Jz1) * Jz1);
711+
}
712+
if (RejectCluster(chi2Y * param.rec.tpc.clusterRejectChi2TolleranceY, chi2Z * param.rec.tpc.clusterRejectChi2TolleranceZ, clusterState)) { // TODO: Relative Pt resolution decreases slightly, why?
713+
// printf("Reject Cluster chiy2 %f chiz2 %f (Pos Y: %f - %f %f ; Pos Z: %f - %f %f)\n", chi2Y, chi2Z, posY, mP[0], (float)inter->posY, posZ, mP[1], (float)inter->posZ + deltaZ);
714+
return updateErrorClusterRejectedInInterpolation;
712715
}
713716
return 0;
714717
}

GPU/GPUTracking/Merger/GPUTPCGMPropagator.h

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,6 @@ class GPUTPCGMPropagator
5757
updateErrorClusterRejectedInUpdate = 4,
5858
updateErrorClusterRejectedEdge = 5
5959
};
60-
enum RejectChi2Mode {
61-
rejectDirect = 1,
62-
rejectInterFill = 2,
63-
rejectInterReject = 3
64-
};
6560

6661
GPUdDefault() GPUTPCGMPropagator() = default;
6762

@@ -104,10 +99,11 @@ class GPUTPCGMPropagator
10499

105100
GPUd() int32_t PropagateToXAlphaBz(float posX, float posAlpha, bool inFlyDirection);
106101

107-
GPUd() int32_t Update(float posY, float posZ, int32_t iRow, const GPUParam& param, int16_t clusterState, int8_t rejectChi2, bool refit, int8_t sector, float time, float avgInvCharge, float invCharge);
108-
GPUd() int32_t Update(float posY, float posZ, int32_t iRow, const GPUParam& param, int16_t clusterState, int8_t rejectChi2, bool refit, float err2Y, float err2Z);
102+
GPUd() int32_t Update(float posY, float posZ, int32_t iRow, const GPUParam& param, int16_t clusterState, bool rejectChi2, bool refit, int8_t sector, float time, float avgInvCharge, float invCharge);
103+
GPUd() int32_t Update(float posY, float posZ, int32_t iRow, const GPUParam& param, int16_t clusterState, bool rejectChi2, bool refit, float err2Y, float err2Z);
109104
GPUd() int32_t Update(float posY, float posZ, int16_t clusterState, bool rejectChi2, float err2Y, float err2Z, const GPUParam* param = nullptr);
110-
GPUd() int32_t InterpolateReject(const GPUParam& param, float posY, float posZ, int16_t clusterState, int8_t rejectChi2, gputpcgmmergertypes::InterpolationErrorHit* inter, float err2Y, float err2Z, float deltaZ);
105+
GPUd() void InterpolateFill(float posY, float posZ, gputpcgmmergertypes::InterpolationErrorHit* inter);
106+
GPUd() int32_t InterpolateReject(const GPUParam& param, float posY, float posZ, int16_t clusterState, gputpcgmmergertypes::InterpolationErrorHit* inter, float err2Y, float err2Z, float deltaZ);
111107
GPUd() float PredictChi2(float posY, float posZ, int32_t iRow, const GPUParam& param, int16_t clusterState, int8_t sideC, float time, float avgCharge, float charge) const;
112108
GPUd() float PredictChi2(float posY, float posZ, float err2Y, float err2Z) const;
113109
GPUd() static int32_t RejectCluster(float chiY, float chiZ, uint8_t clusterState)

0 commit comments

Comments
 (0)