Skip to content

Commit b4c185a

Browse files
committed
ITS: simplify buildTrackSeed
Signed-off-by: Felix Schlepper <felix.schlepper@cern.ch>
1 parent 8ee93b8 commit b4c185a

File tree

2 files changed

+43
-38
lines changed

2 files changed

+43
-38
lines changed

Detectors/ITSMFT/ITS/tracking/GPU/cuda/TrackingKernels.cu

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -129,34 +129,36 @@ GPUdii() o2::track::TrackParCov buildTrackSeed(const Cluster& cluster1,
129129
const float bz,
130130
const bool reverse = false)
131131
{
132-
const float ca = o2::gpu::CAMath::Cos(tf3.alphaTrackingFrame), sa = o2::gpu::CAMath::Sin(tf3.alphaTrackingFrame);
132+
const float sign = reverse ? -1.f : 1.f;
133+
134+
float ca, sa;
135+
o2::gpu::CAMath::SinCos(tf3.alphaTrackingFrame, sa, ca);
136+
133137
const float x1 = cluster1.xCoordinate * ca + cluster1.yCoordinate * sa;
134138
const float y1 = -cluster1.xCoordinate * sa + cluster1.yCoordinate * ca;
135-
const float z1 = cluster1.zCoordinate;
136139
const float x2 = cluster2.xCoordinate * ca + cluster2.yCoordinate * sa;
137140
const float y2 = -cluster2.xCoordinate * sa + cluster2.yCoordinate * ca;
138-
const float z2 = cluster2.zCoordinate;
139141
const float x3 = tf3.xTrackingFrame;
140142
const float y3 = tf3.positionTrackingFrame[0];
141-
const float z3 = tf3.positionTrackingFrame[1];
142-
143-
const bool zeroField{o2::gpu::CAMath::Abs(bz) < o2::constants::math::Almost0};
144-
const float sign = (reverse) ? -1.f : 1.f;
145-
const float tgp = zeroField ? sign * o2::gpu::CAMath::ATan2(y3 - y1, x3 - x1) : 1.f;
146-
const float crv = sign * (zeroField ? 1.f : math_utils::computeCurvature(x3, y3, x2, y2, x1, y1));
147-
const float snp = (zeroField ? tgp / o2::gpu::CAMath::Sqrt(1.f + tgp * tgp) : crv * (x3 - math_utils::computeCurvatureCentreX(x3, y3, x2, y2, x1, y1)));
148-
const float tgl12 = math_utils::computeTanDipAngle(x1, y1, x2, y2, z1, z2);
149-
const float tgl23 = math_utils::computeTanDipAngle(x2, y2, x3, y3, z2, z3);
150-
const float q2pt = zeroField ? sign / o2::track::kMostProbablePt : crv / (bz * o2::constants::math::B2C);
151-
const float q2pt2 = crv * crv;
152-
const float sg2q2pt = o2::track::kC1Pt2max * (q2pt2 > 0.0005 ? (q2pt2 < 1 ? q2pt2 : 1) : 0.0005);
153-
return track::TrackParCov(tf3.xTrackingFrame, tf3.alphaTrackingFrame,
154-
{y3, z3, snp, 0.5f * (tgl12 + tgl23), q2pt},
155-
{tf3.covarianceTrackingFrame[0],
156-
tf3.covarianceTrackingFrame[1], tf3.covarianceTrackingFrame[2],
157-
0.f, 0.f, track::kCSnp2max,
158-
0.f, 0.f, 0.f, track::kCTgl2max,
159-
0.f, 0.f, 0.f, 0.f, sg2q2pt});
143+
144+
float snp, q2pt, q2pt2;
145+
if (o2::gpu::CAMath::Abs(bz) < 0.01f) {
146+
const float tgp = o2::gpu::CAMath::ATan2(y3 - y1, x3 - x1);
147+
snp = sign * tgp / o2::gpu::CAMath::Sqrt(1.f + tgp * tgp);
148+
q2pt = sign / track::kMostProbablePt;
149+
q2pt2 = 1.f;
150+
} else {
151+
const float crv = math_utils::computeCurvature(x3, y3, x2, y2, x1, y1);
152+
snp = sign * crv * (x3 - math_utils::computeCurvatureCentreX(x3, y3, x2, y2, x1, y1));
153+
q2pt = sign * crv / (bz * o2::constants::math::B2C);
154+
q2pt2 = crv * crv;
155+
}
156+
157+
const float tgl = 0.5f * (math_utils::computeTanDipAngle(x1, y1, x2, y2, cluster1.zCoordinate, cluster2.zCoordinate) +
158+
math_utils::computeTanDipAngle(x2, y2, x3, y3, cluster2.zCoordinate, tf3.positionTrackingFrame[1]));
159+
const float sg2q2pt = track::kC1Pt2max * (q2pt2 > 0.0005f ? (q2pt2 < 1.f ? q2pt2 : 1.f) : 0.0005f);
160+
161+
return {x3, tf3.alphaTrackingFrame, {y3, tf3.positionTrackingFrame[1], snp, tgl, q2pt}, {tf3.covarianceTrackingFrame[0], tf3.covarianceTrackingFrame[1], tf3.covarianceTrackingFrame[2], 0.f, 0.f, track::kCSnp2max, 0.f, 0.f, 0.f, track::kCTgl2max, 0.f, 0.f, 0.f, 0.f, sg2q2pt}};
160162
}
161163

162164
template <int nLayers>

Detectors/ITSMFT/ITS/tracking/src/TrackerTraits.cxx

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1248,33 +1248,36 @@ TrackITSExt TrackerTraits<nLayers>::seedTrackForRefit(const CellSeedN& seed)
12481248
template <int nLayers>
12491249
track::TrackParCov TrackerTraits<nLayers>::buildTrackSeed(const Cluster& cluster1, const Cluster& cluster2, const TrackingFrameInfo& tf3, bool reverse)
12501250
{
1251-
float ca{-999.f}, sa{-999.f};
1251+
const float sign = reverse ? -1.f : 1.f;
1252+
1253+
float ca, sa;
12521254
o2::gpu::CAMath::SinCos(tf3.alphaTrackingFrame, sa, ca);
1255+
12531256
const float x1 = cluster1.xCoordinate * ca + cluster1.yCoordinate * sa;
12541257
const float y1 = -cluster1.xCoordinate * sa + cluster1.yCoordinate * ca;
1255-
const float z1 = cluster1.zCoordinate;
12561258
const float x2 = cluster2.xCoordinate * ca + cluster2.yCoordinate * sa;
12571259
const float y2 = -cluster2.xCoordinate * sa + cluster2.yCoordinate * ca;
1258-
const float z2 = cluster2.zCoordinate;
12591260
const float x3 = tf3.xTrackingFrame;
12601261
const float y3 = tf3.positionTrackingFrame[0];
1261-
const float z3 = tf3.positionTrackingFrame[1];
1262-
const float sign = (reverse) ? -1.f : 1.f;
1263-
float tgp{1.f}, crv{1.f}, snp{-999.f}, tgl12{-999.f}, tgl23{-999.f}, q2pt{1.f / track::kMostProbablePt}, q2pt2{1.f}, sg2q2pt{-999.f};
1262+
1263+
float snp, q2pt, q2pt2;
12641264
if (mIsZeroField) {
1265-
tgp = sign * o2::gpu::CAMath::ATan2(y3 - y1, x3 - x1);
1266-
snp = tgp / o2::gpu::CAMath::Sqrt(1.f + tgp * tgp);
1267-
q2pt *= sign;
1265+
const float tgp = o2::gpu::CAMath::ATan2(y3 - y1, x3 - x1);
1266+
snp = sign * tgp / o2::gpu::CAMath::Sqrt(1.f + tgp * tgp);
1267+
q2pt = sign / track::kMostProbablePt;
1268+
q2pt2 = 1.f;
12681269
} else {
1269-
crv = sign * math_utils::computeCurvature(x3, y3, x2, y2, x1, y1);
1270-
snp = crv * (x3 - math_utils::computeCurvatureCentreX(x3, y3, x2, y2, x1, y1));
1271-
q2pt = crv / (mBz * o2::constants::math::B2C);
1270+
const float crv = math_utils::computeCurvature(x3, y3, x2, y2, x1, y1);
1271+
snp = sign * crv * (x3 - math_utils::computeCurvatureCentreX(x3, y3, x2, y2, x1, y1));
1272+
q2pt = sign * crv / (mBz * o2::constants::math::B2C);
12721273
q2pt2 = crv * crv;
12731274
}
1274-
tgl12 = math_utils::computeTanDipAngle(x1, y1, x2, y2, z1, z2);
1275-
tgl23 = math_utils::computeTanDipAngle(x2, y2, x3, y3, z2, z3);
1276-
sg2q2pt = track::kC1Pt2max * (q2pt2 > 0.0005f ? (q2pt2 < 1.f ? q2pt2 : 1.f) : 0.0005f);
1277-
return {tf3.xTrackingFrame, tf3.alphaTrackingFrame, {y3, z3, snp, 0.5f * (tgl12 + tgl23), q2pt}, {tf3.covarianceTrackingFrame[0], tf3.covarianceTrackingFrame[1], tf3.covarianceTrackingFrame[2], 0.f, 0.f, track::kCSnp2max, 0.f, 0.f, 0.f, track::kCTgl2max, 0.f, 0.f, 0.f, 0.f, sg2q2pt}};
1275+
1276+
const float tgl = 0.5f * (math_utils::computeTanDipAngle(x1, y1, x2, y2, cluster1.zCoordinate, cluster2.zCoordinate) +
1277+
math_utils::computeTanDipAngle(x2, y2, x3, y3, cluster2.zCoordinate, tf3.positionTrackingFrame[1]));
1278+
const float sg2q2pt = track::kC1Pt2max * (q2pt2 > 0.0005f ? (q2pt2 < 1.f ? q2pt2 : 1.f) : 0.0005f);
1279+
1280+
return {x3, tf3.alphaTrackingFrame, {y3, tf3.positionTrackingFrame[1], snp, tgl, q2pt}, {tf3.covarianceTrackingFrame[0], tf3.covarianceTrackingFrame[1], tf3.covarianceTrackingFrame[2], 0.f, 0.f, track::kCSnp2max, 0.f, 0.f, 0.f, track::kCTgl2max, 0.f, 0.f, 0.f, 0.f, sg2q2pt}};
12781281
}
12791282

12801283
template <int nLayers>

0 commit comments

Comments
 (0)