Skip to content

Commit e0fefa5

Browse files
authored
TRK: add nELossSteps (#15703)
Signed-off-by: Felix Schlepper <felix.schlepper@cern.ch>
1 parent 5e03dcc commit e0fefa5

3 files changed

Lines changed: 35 additions & 13 deletions

File tree

DataFormats/Reconstruction/include/ReconstructionDataFormats/TrackParametrization.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,13 @@ class TrackParametrization
210210
GPUd() value_t getE() const;
211211
GPUdi() static value_t getdEdxBB(value_t betagamma) { return BetheBlochSolid(betagamma); }
212212
GPUdi() static value_t getdEdxBBOpt(value_t betagamma) { return BetheBlochSolidOpt(betagamma); }
213+
214+
GPUdi() int nELossSteps(value_T dE, value_T ekin) const noexcept
215+
{
216+
const int n = 1 + int(gpu::CAMath::Abs(dE) / ekin * ELoss2EKinThreshInv);
217+
return n > MaxELossIter ? MaxELossIter : n;
218+
}
219+
GPUd() int getELossSteps(value_t xrho, bool anglecorr) const;
213220
GPUdi() static value_t getBetheBlochSolidDerivativeApprox(value_T dedx, value_T bg) { return BetheBlochSolidDerivative(dedx, bg); }
214221

215222
GPUd() value_t getTheta() const;

DataFormats/Reconstruction/src/TrackParametrization.cxx

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -867,6 +867,30 @@ GPUd() bool TrackParametrization<value_T>::getXatLabR(value_t r, value_t& x, val
867867
return true;
868868
}
869869

870+
//______________________________________________
871+
template <typename value_T>
872+
GPUd() int TrackParametrization<value_T>::getELossSteps(value_t xrho, bool anglecorr) const
873+
{
874+
// Copied from correctForMaterial before entering its energy-loss loop
875+
const value_t m = getPID().getMass();
876+
if (!(m > 0) || xrho == 0.f) {
877+
return 0; // correctForMaterial skips the energy-loss block entirely
878+
}
879+
if (anglecorr) {
880+
const value_t csp2 = (1.f - getSnp()) * (1.f + getSnp()); // cos(phi)^2
881+
const value_t cst2I = (1.f + getTgl() * getTgl()); // 1/cos(lambda)^2
882+
xrho *= gpu::CAMath::Sqrt(cst2I / csp2);
883+
}
884+
const value_t p = getP(), massInv = 1.f / m;
885+
const value_t e = gpu::CAMath::Sqrt(p * p + getPID().getMass2()), ekin = e - m;
886+
value_t dedx = getdEdxBBOpt(p * massInv);
887+
const int charge2 = getAbsCharge() * getAbsCharge();
888+
if (charge2 != 1) {
889+
dedx *= charge2;
890+
}
891+
return nELossSteps(dedx * xrho, ekin);
892+
}
893+
870894
//______________________________________________
871895
template <typename value_T>
872896
GPUd() bool TrackParametrization<value_T>::correctForELoss(value_t xrho, bool anglecorr)
@@ -891,7 +915,7 @@ GPUd() bool TrackParametrization<value_T>::correctForELoss(value_t xrho, bool an
891915
xrho *= angle;
892916
}
893917
int charge2 = getAbsCharge() * getAbsCharge();
894-
value_t p = getP(), p0 = p, p2 = p * p, e2 = p2 + getPID().getMass2(), massInv = 1. / m, bg = p * massInv;
918+
value_t p = getP(), p0 = p, p2 = p * p, e2 = p2 + getPID().getMass2(), massInv = 1.f / m, bg = p * massInv;
895919
value_t e = gpu::CAMath::Sqrt(e2), ekin = e - m, dedx = getdEdxBBOpt(bg);
896920
#ifdef _BB_NONCONST_CORR_
897921
value_t dedxDer = 0., dedx1 = dedx;
@@ -900,10 +924,7 @@ GPUd() bool TrackParametrization<value_T>::correctForELoss(value_t xrho, bool an
900924
dedx *= charge2;
901925
}
902926
value_t dE = dedx * xrho;
903-
int na = 1 + int(gpu::CAMath::Abs(dE) / ekin * ELoss2EKinThreshInv);
904-
if (na > MaxELossIter) {
905-
na = MaxELossIter;
906-
}
927+
int na = nELossSteps(dE, ekin);
907928
if (na > 1) {
908929
dE /= na;
909930
xrho /= na;

DataFormats/Reconstruction/src/TrackParametrizationWithError.cxx

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1438,10 +1438,7 @@ GPUd() bool TrackParametrizationWithError<value_T>::correctForMaterial(value_t x
14381438
dedx *= charge2;
14391439
}
14401440
value_t dE = dedx * xrho;
1441-
int na = 1 + int(gpu::CAMath::Abs(dE) / ekin * ELoss2EKinThreshInv);
1442-
if (na > MaxELossIter) {
1443-
na = MaxELossIter;
1444-
}
1441+
int na = this->nELossSteps(dE, ekin);
14451442
if (na > 1) {
14461443
dE /= na;
14471444
xrho /= na;
@@ -1573,10 +1570,7 @@ GPUd() bool TrackParametrizationWithError<value_T>::correctForMaterial(TrackPara
15731570
dedx *= charge2;
15741571
}
15751572
value_t dE = dedx * xrho;
1576-
int na = 1 + int(gpu::CAMath::Abs(dE) / ekin * ELoss2EKinThreshInv);
1577-
if (na > MaxELossIter) {
1578-
na = MaxELossIter;
1579-
}
1573+
int na = this->nELossSteps(dE, ekin);
15801574
if (na > 1) {
15811575
dE /= na;
15821576
xrho /= na;

0 commit comments

Comments
 (0)