58 const double maxDistance,
59 const double maxAngleTheta2,
60 const double maxAnglePhi2) {
62 if ((pos1 - pos2).norm() > maxDistance) {
67 double phi1, theta1, phi2, theta2;
74 double diffTheta2 = (theta1 - theta2) * (theta1 - theta2);
75 if (diffTheta2 > maxAngleTheta2) {
80 double diffPhi2 = (phi1 - phi2) * (phi1 - phi2);
81 if (diffPhi2 > maxAnglePhi2) {
86 return diffTheta2 + diffPhi2;
99 auto& boundariesX = binData[0].boundaries();
100 auto& boundariesY = binData[1].boundaries();
103 size_t binX = binData[0].searchLocal(local);
104 size_t binY = binData[1].searchLocal(local);
107 std::pair<Vector2D, Vector2D> topBottomLocal;
109 if (boundariesX[binX + 1] - boundariesX[binX] <
110 boundariesY[binY + 1] - boundariesY[binY]) {
112 topBottomLocal.first = {(boundariesX[
binX] + boundariesX[binX + 1]) / 2,
113 boundariesY[binY + 1]};
114 topBottomLocal.second = {(boundariesX[
binX] + boundariesX[binX + 1]) / 2,
118 topBottomLocal.first = {boundariesX[
binX],
119 (boundariesY[
binY] + boundariesY[binY + 1]) / 2};
120 topBottomLocal.second = {boundariesX[binX + 1],
121 (boundariesY[
binY] + boundariesY[binY + 1]) / 2};
123 return topBottomLocal;
149 double qr = q.dot(r);
150 double denom = q.dot(q) - qr * qr;
153 if (fabs(denom) > 10
e-7) {
155 return (ac.dot(r) * qr - ac.dot(q) * r.dot(r)) / denom;
172 double stripLengthGapTolerance) {
175 if (stripLengthGapTolerance <= 0.) {
178 spaPoPa.
qmag = spaPoPa.
q.norm();
182 spaPoPa.
limit + stripLengthGapTolerance / spaPoPa.
qmag;
188 if (spaPoPa.
n == 0.) {
189 spaPoPa.
n = -spaPoPa.
t.dot(spaPoPa.
qs) / spaPoPa.
r.dot(spaPoPa.
qs);
216 double secOnFirstScale =
217 spaPoPa.
q.dot(spaPoPa.
r) / (spaPoPa.
qmag * spaPoPa.
qmag);
219 if (spaPoPa.
m > 1. && spaPoPa.
n > 1.) {
221 double mOvershoot = spaPoPa.
m - 1.;
223 (spaPoPa.
n - 1.) * secOnFirstScale;
225 double biggerOvershoot =
std::max(mOvershoot, nOvershoot);
227 spaPoPa.
m -= biggerOvershoot;
228 spaPoPa.
n -= (biggerOvershoot / secOnFirstScale);
230 return fabs(spaPoPa.
m) < spaPoPa.
limit && fabs(spaPoPa.
n) < spaPoPa.
limit;
233 if (spaPoPa.
m < -1. && spaPoPa.
n < -1.) {
235 double mOvershoot = -(spaPoPa.
m + 1.);
237 -(spaPoPa.
n + 1.) * secOnFirstScale;
239 double biggerOvershoot =
std::max(mOvershoot, nOvershoot);
241 spaPoPa.
m += biggerOvershoot;
242 spaPoPa.
n += (biggerOvershoot / secOnFirstScale);
244 return fabs(spaPoPa.
m) < spaPoPa.
limit && fabs(spaPoPa.
n) < spaPoPa.
limit;
264 const std::pair<Vector3D, Vector3D>& stripEnds2,
267 const double stripLengthTolerance) {
289 spaPoPa.
s = stripEnds1.first + stripEnds1.second - 2 * posVertex;
290 spaPoPa.
t = stripEnds2.first + stripEnds2.second - 2 * posVertex;
291 spaPoPa.
qs = spaPoPa.
q.cross(spaPoPa.
s);
292 spaPoPa.
rt = spaPoPa.
r.cross(spaPoPa.
t);
293 spaPoPa.
m = -spaPoPa.
s.dot(spaPoPa.
rt) / spaPoPa.
q.dot(spaPoPa.
rt);
296 if (spaPoPa.
limit == 1. && stripLengthTolerance != 0.) {
297 spaPoPa.
limit = 1. + stripLengthTolerance;
301 return (fabs(spaPoPa.
m) <= spaPoPa.
limit &&
302 fabs(spaPoPa.
n = -spaPoPa.
t.dot(spaPoPa.
qs) /
303 spaPoPa.
r.dot(spaPoPa.
qs)) <= spaPoPa.
limit);
311 template <
typename Cluster>
313 DoubleHitSpacePointConfig cfg)
314 : m_cfg(std::move(cfg)) {}
316 template <
typename Cluster>
318 const Cluster& cluster)
const {
320 auto par = cluster.parameters();
326 template <
typename Cluster>
330 auto& clusterSurface = cluster.referenceObject();
334 return clusterSurface.localToGlobal(gctx, localCoords(cluster),
mom);
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.referenceObject();
408 return std::make_pair(topGlobal, bottomGlobal);
411 template <
typename Cluster>
414 const std::vector<std::pair<const Cluster*, const Cluster*>>& clusterPairs,
418 detail::SpacePointParameters spaPoPa;
421 for (
const auto& cp : clusterPairs) {
423 const auto& ends1 = endsOfStrip(gctx, *(cp.first));
424 const auto& ends2 = endsOfStrip(gctx, *(cp.second));
426 spaPoPa.q = ends1.first - ends1.second;
427 spaPoPa.r = ends2.first - ends2.second;
430 double resultPerpProj;
431 if (m_cfg.usePerpProj) {
433 ends1.first, ends2.first, spaPoPa.q, spaPoPa.r);
434 if (resultPerpProj <= 0.) {
438 Vector3D pos = ends1.first + resultPerpProj * spaPoPa.q;
440 spacePoints.push_back(std::move(sp));
446 m_cfg.stripLengthTolerance)) {
451 Vector3D pos = 0.5 * (ends1.first + ends1.second + spaPoPa.m * spaPoPa.q);
454 spacePoints.push_back(std::move(sp));
468 0.5 * (ends1.first + ends1.second + spaPoPa.m * spaPoPa.q);
470 spacePoints.push_back(std::move(sp));