57 const double maxDistance,
58 const double maxAngleTheta2,
59 const double maxAnglePhi2) {
61 if ((pos1 - pos2).
norm() > maxDistance) {
66 double phi1, theta1, phi2, theta2;
73 double diffTheta2 = (theta1 - theta2) * (theta1 - theta2);
74 if (diffTheta2 > maxAngleTheta2) {
79 double diffPhi2 = (phi1 - phi2) * (phi1 - phi2);
80 if (diffPhi2 > maxAnglePhi2) {
85 return diffTheta2 + diffPhi2;
98 auto& boundariesX = binData[0].boundaries();
99 auto& boundariesY = binData[1].boundaries();
102 size_t binX = binData[0].searchLocal(local);
103 size_t binY = binData[1].searchLocal(local);
106 std::pair<Vector2D, Vector2D> topBottomLocal;
108 if (boundariesX[binX + 1] - boundariesX[binX] <
109 boundariesY[binY + 1] - boundariesY[binY]) {
111 topBottomLocal.first = {(boundariesX[
binX] + boundariesX[binX + 1]) / 2,
112 boundariesY[binY + 1]};
113 topBottomLocal.second = {(boundariesX[
binX] + boundariesX[binX + 1]) / 2,
117 topBottomLocal.first = {boundariesX[
binX],
118 (boundariesY[
binY] + boundariesY[binY + 1]) / 2};
119 topBottomLocal.second = {boundariesX[binX + 1],
120 (boundariesY[
binY] + boundariesY[binY + 1]) / 2};
122 return topBottomLocal;
148 double qr = q.dot(r);
149 double denom = q.dot(q) - qr * qr;
152 if (fabs(denom) > 10
e-7) {
154 return (ac.dot(r) * qr - ac.dot(q) * r.dot(r)) / denom;
171 double stripLengthGapTolerance) {
174 if (stripLengthGapTolerance <= 0.) {
177 spaPoPa.
qmag = spaPoPa.
q.norm();
181 spaPoPa.
limit + stripLengthGapTolerance / spaPoPa.
qmag;
187 if (spaPoPa.
n == 0.) {
188 spaPoPa.
n = -spaPoPa.
t.dot(spaPoPa.
qs) / spaPoPa.
r.dot(spaPoPa.
qs);
215 double secOnFirstScale =
216 spaPoPa.
q.dot(spaPoPa.
r) / (spaPoPa.
qmag * spaPoPa.
qmag);
218 if (spaPoPa.
m > 1. && spaPoPa.
n > 1.) {
220 double mOvershoot = spaPoPa.
m - 1.;
222 (spaPoPa.
n - 1.) * secOnFirstScale;
224 double biggerOvershoot =
std::max(mOvershoot, nOvershoot);
226 spaPoPa.
m -= biggerOvershoot;
227 spaPoPa.
n -= (biggerOvershoot / secOnFirstScale);
229 return fabs(spaPoPa.
m) < spaPoPa.
limit && fabs(spaPoPa.
n) < spaPoPa.
limit;
232 if (spaPoPa.
m < -1. && spaPoPa.
n < -1.) {
234 double mOvershoot = -(spaPoPa.
m + 1.);
236 -(spaPoPa.
n + 1.) * secOnFirstScale;
238 double biggerOvershoot =
std::max(mOvershoot, nOvershoot);
240 spaPoPa.
m += biggerOvershoot;
241 spaPoPa.
n += (biggerOvershoot / secOnFirstScale);
243 return fabs(spaPoPa.
m) < spaPoPa.
limit && fabs(spaPoPa.
n) < spaPoPa.
limit;
263 const std::pair<Vector3D, Vector3D>& stripEnds2,
266 const double stripLengthTolerance) {
288 spaPoPa.
s = stripEnds1.first + stripEnds1.second - 2 * posVertex;
289 spaPoPa.
t = stripEnds2.first + stripEnds2.second - 2 * posVertex;
290 spaPoPa.
qs = spaPoPa.
q.cross(spaPoPa.
s);
291 spaPoPa.
rt = spaPoPa.
r.cross(spaPoPa.
t);
292 spaPoPa.
m = -spaPoPa.
s.dot(spaPoPa.
rt) / spaPoPa.
q.dot(spaPoPa.
rt);
295 if (spaPoPa.
limit == 1. && stripLengthTolerance != 0.) {
296 spaPoPa.
limit = 1. + stripLengthTolerance;
300 return (fabs(spaPoPa.
m) <= spaPoPa.
limit &&
301 fabs(spaPoPa.
n = -spaPoPa.
t.dot(spaPoPa.
qs) /
302 spaPoPa.
r.dot(spaPoPa.
qs)) <= spaPoPa.
limit);
310 template <
typename Cluster>
312 DoubleHitSpacePointConfig cfg)
313 : m_cfg(std::move(cfg)) {}
315 template <
typename Cluster>
317 const Cluster& cluster)
const {
319 auto par = cluster.parameters();
324 template <
typename Cluster>
328 auto& clusterSurface = cluster.referenceSurface();
332 clusterSurface.localToGlobal(gctx, localCoords(cluster), mom, pos);
337 template <
typename Cluster>
340 const std::vector<const Cluster*>& clustersFront,
341 const std::vector<const Cluster*>& clustersBack,
342 std::vector<std::pair<const Cluster*, const Cluster*>>& clusterPairs)
345 if (clustersFront.empty() || clustersBack.empty()) {
352 unsigned int clusterMinDist;
355 for (
unsigned int iClustersFront = 0; iClustersFront < clustersFront.size();
360 clusterMinDist = clustersBack.size();
361 for (
unsigned int iClustersBack = 0; iClustersBack < clustersBack.size();
365 globalCoords(gctx, *(clustersFront[iClustersFront])),
366 globalCoords(gctx, *(clustersBack[iClustersBack])), m_cfg.vertex,
367 m_cfg.diffDist, m_cfg.diffPhi2, m_cfg.diffTheta2);
369 if (currentDiff < diffMin && currentDiff >= 0.) {
370 diffMin = currentDiff;
371 clusterMinDist = iClustersBack;
376 if (clusterMinDist < clustersBack.size()) {
377 std::pair<const Cluster*, const Cluster*> clusterPair;
378 clusterPair = std::make_pair(clustersFront[iClustersFront],
379 clustersBack[clusterMinDist]);
380 clusterPairs.push_back(clusterPair);
385 template <
typename Cluster>
386 std::pair<Acts::Vector3D, Acts::Vector3D>
394 &(cluster.digitizationModule()->segmentation()));
396 std::pair<Vector2D, Vector2D> topBottomLocal =
401 const auto*
sur = &cluster.referenceSurface();
406 return std::make_pair(topGlobal, bottomGlobal);
409 template <
typename Cluster>
412 const std::vector<std::pair<const Cluster*, const Cluster*>>& clusterPairs,
416 detail::SpacePointParameters spaPoPa;
419 for (
const auto&
cp : clusterPairs) {
421 const auto& ends1 = endsOfStrip(gctx, *(
cp.first));
422 const auto& ends2 = endsOfStrip(gctx, *(
cp.second));
424 spaPoPa.q = ends1.first - ends1.second;
425 spaPoPa.r = ends2.first - ends2.second;
428 double resultPerpProj;
429 if (m_cfg.usePerpProj) {
431 ends1.first, ends2.first, spaPoPa.q, spaPoPa.r);
432 if (resultPerpProj <= 0.) {
436 Vector3D pos = ends1.first + resultPerpProj * spaPoPa.q;
438 spacePoints.push_back(std::move(sp));
444 m_cfg.stripLengthTolerance)) {
449 Vector3D pos = 0.5 * (ends1.first + ends1.second + spaPoPa.m * spaPoPa.q);
452 spacePoints.push_back(std::move(sp));
466 0.5 * (ends1.first + ends1.second + spaPoPa.m * spaPoPa.q);
468 spacePoints.push_back(std::move(sp));