Skip to content

Commit

Permalink
Merge pull request #44471 from aehart/stub_z_fix
Browse files Browse the repository at this point in the history
Numerical stability fix for Phase 2 L1 tracking
  • Loading branch information
cmsbuild authored Mar 27, 2024
2 parents b9fcd5b + 94f9f4e commit 625d0bd
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions L1Trigger/TrackFindingTracklet/src/PurgeDuplicate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -672,12 +672,23 @@ std::vector<double> PurgeDuplicate::getInventedCoordsExtended(unsigned int iSect
if (st->isBarrel()) {
stub_r = settings_.rmean(stubLayer - 1);

double sin_val = (stub_r * stub_r + rho_minus_d0 * rho_minus_d0 - rho * rho) / (2 * stub_r * rho_minus_d0);
// The expanded version of this expression is more stable for very low-pT
// (high-rho) tracks. But we also explicitly restrict sin_val to the domain
// of asin.
double sin_val =
0.5 * (stub_r / rho_minus_d0) + 0.5 * (rho_minus_d0 / stub_r) - 0.5 * ((rho * rho) / (rho_minus_d0 * stub_r));
sin_val = std::max(std::min(sin_val, 1.0), -1.0);
stub_phi = tracklet->phi0() - std::asin(sin_val);
stub_phi = stub_phi + iSector * settings_.dphisector() - 0.5 * settings_.dphisectorHG();
stub_phi = reco::reduceRange(stub_phi);

double beta = std::acos((rho * rho + rho_minus_d0 * rho_minus_d0 - stub_r * stub_r) / (2 * rho * rho_minus_d0));
// The expanded version of this expression is more stable for very low-pT
// (high-rho) tracks. But we also explicitly restrict cos_val to the domain
// of acos.
double cos_val =
0.5 * (rho / rho_minus_d0) + 0.5 * (rho_minus_d0 / rho) - 0.5 * ((stub_r * stub_r) / (rho * rho_minus_d0));
cos_val = std::max(std::min(cos_val, 1.0), -1.0);
double beta = std::acos(cos_val);
stub_z = tracklet->z0() + tracklet->t() * std::abs(rho * beta);
} else {
stub_z = settings_.zmean(stubDisk - 1) * tracklet->disk() / abs(tracklet->disk());
Expand All @@ -686,7 +697,12 @@ std::vector<double> PurgeDuplicate::getInventedCoordsExtended(unsigned int iSect
double r_square = -2 * rho * rho_minus_d0 * std::cos(beta) + rho * rho + rho_minus_d0 * rho_minus_d0;
stub_r = sqrt(r_square);

double sin_val = (stub_r * stub_r + rho_minus_d0 * rho_minus_d0 - rho * rho) / (2 * stub_r * rho_minus_d0);
// The expanded version of this expression is more stable for very low-pT
// (high-rho) tracks. But we also explicitly restrict sin_val to the domain
// of asin.
double sin_val =
0.5 * (stub_r / rho_minus_d0) + 0.5 * (rho_minus_d0 / stub_r) - 0.5 * ((rho * rho) / (rho_minus_d0 * stub_r));
sin_val = std::max(std::min(sin_val, 1.0), -1.0);
stub_phi = tracklet->phi0() - std::asin(sin_val);
stub_phi = stub_phi + iSector * settings_.dphisector() - 0.5 * settings_.dphisectorHG();
stub_phi = reco::reduceRange(stub_phi);
Expand Down

0 comments on commit 625d0bd

Please sign in to comment.