26 #include <type_traits>
33 template <
typename external_spacepo
int_t>
41 template <
typename external_spacepo
int_t>
49 template <
typename external_spacepo
int_t>
52 for (
const auto& FTF_sp : FTF_SP_vect) {
53 bool is_Pixel = FTF_sp.isPixel();
57 m_storage->addSpacePoint(FTF_sp, (m_config.m_useClusterWidth > 0));
60 m_config.m_nMaxPhiSlice = 1;
61 m_config.m_phiSliceWidth = 2 * M_PI / m_config.m_nMaxPhiSlice;
63 m_storage->sortByPhi();
65 m_storage->generatePhiIndexing(1.5 * m_config.m_phiSliceWidth);
68 template <
typename external_spacepo
int_t>
74 const int MaxEdges = 2000000;
76 const float cut_dphi_max = 0.012;
77 const float cut_dcurv_max = 0.001;
78 const float cut_tau_ratio_max = 0.007;
79 const float min_z0 = -2800;
81 const float max_z0 = 2800;
83 const float maxOuterRadius = 550.0;
84 const float cut_zMinU =
87 const float cut_zMaxU = max_z0 + maxOuterRadius * roi.
dzdrPlus();
92 const float maxKappa_high_eta = 0.8 / m_minR_squ;
93 const float maxKappa_low_eta = 0.6 / m_minR_squ;
101 std::vector<Acts::TrigFTF_GNN_Edge<external_spacepoint_t>> edgeStorage;
103 edgeStorage.reserve(MaxEdges);
107 for (std::map<
int, std::vector<FasTrackConnector::LayerGroup>>::const_iterator
112 for (
const auto& layerGroup : (*it).second) {
113 unsigned int dst = layerGroup.m_dst;
118 if (pL1 ==
nullptr) {
122 for (
const auto& conn :
123 layerGroup.m_sources) {
125 unsigned int src = conn->m_src;
130 if (pL2 ==
nullptr) {
133 int nDstBins = pL1->
m_bins.size();
134 int nSrcBins = pL2->
m_bins.size();
136 for (
int b1 = 0;
b1 < nDstBins;
b1++) {
139 m_storage->getEtaBin(pL1->
m_bins.at(
b1));
149 for (
int b2 = 0; b2 < nSrcBins; b2++) {
151 if (m_config.m_useEtaBinning && (nSrcBins + nDstBins > 2)) {
152 if (conn->m_binTable[
b1 + b2 * nDstBins] != 1) {
158 m_storage->getEtaBin(pL2->
m_bins.at(b2));
173 if (m_config.m_useEtaBinning) {
174 deltaPhi = 0.001f + m_maxCurv * std::fabs(rb2 - rb1);
177 unsigned int first_it = 0;
178 for (
typename std::vector<
180 n1It = B1.
m_vn.begin();
181 n1It != B1.
m_vn.end(); ++n1It) {
193 float phi1 = std::atan(x1 / y1);
198 for (
unsigned int n2PhiIdx = first_it;
226 if (dr < m_config.m_minDeltaRadius) {
234 float ftau = std::fabs(tau);
239 if (ftau < n1->m_minCutOnTau) {
242 if (ftau < n2->m_minCutOnTau) {
252 if (m_config.m_doubletFilterRZ) {
253 float z0 = z1 - r1 *
tau;
255 if (z0 < min_z0 || z0 > max_z0) {
259 float zouter = z0 + maxOuterRadius *
tau;
261 if (zouter < cut_zMinU || zouter > cut_zMaxU) {
269 float L2 = 1 / (dx * dx + dy *
dy);
275 float kappa = D * D * L2;
278 if (kappa > maxKappa_low_eta) {
283 if (kappa > maxKappa_high_eta) {
290 float exp_eta = std::sqrt(1 + tau * tau) -
tau;
297 float uat_1 = 1.0f / exp_eta;
299 for (
const auto& n2_in_idx : n2->
m_in) {
300 float tau2 = edgeStorage.at(n2_in_idx).m_p[0];
301 float tau_ratio = tau2 * uat_1 - 1.0f;
303 if (std::fabs(tau_ratio) > cut_tau_ratio_max) {
315 float curv = D * std::sqrt(L2);
316 float dPhi2 = std::asin(curv * r2);
317 float dPhi1 = std::asin(curv * r1);
319 if (nEdges < MaxEdges) {
320 edgeStorage.emplace_back(n1, n2, exp_eta, curv, phi1 + dPhi1,
336 std::vector<const TrigFTF_GNN_Node<external_spacepoint_t>*> vNodes;
338 m_storage->getConnectingNodes(vNodes);
340 if (vNodes.empty()) {
344 int nNodes = vNodes.size();
346 for (
int nodeIdx = 0; nodeIdx < nNodes; nodeIdx++) {
349 std::vector<std::pair<float, int>> in_sort, out_sort;
350 in_sort.resize(pN->
m_in.size());
351 out_sort.resize(pN->
m_out.size());
353 for (
int inIdx = 0; inIdx < static_cast<int>(pN->
m_in.size()); inIdx++) {
354 int inEdgeIdx = pN->
m_in.at(inIdx);
356 &(edgeStorage.at(inEdgeIdx));
357 in_sort[inIdx].second = inEdgeIdx;
358 in_sort[inIdx].first = pS->
m_p[0];
360 for (
int outIdx = 0; outIdx < static_cast<int>(pN->
m_out.size());
362 int outEdgeIdx = pN->
m_out.at(outIdx);
364 &(edgeStorage.at(outEdgeIdx));
365 out_sort[outIdx].second = outEdgeIdx;
366 out_sort[outIdx].first = pS->
m_p[0];
369 std::sort(in_sort.begin(), in_sort.end());
370 std::sort(out_sort.begin(), out_sort.end());
372 unsigned int last_out = 0;
374 for (
unsigned int in_idx = 0; in_idx < in_sort.size();
377 int inEdgeIdx = in_sort[in_idx].second;
380 &(edgeStorage.at(inEdgeIdx));
383 float tau1 = pS->
m_p[0];
384 float uat_1 = 1.0f / tau1;
385 float curv1 = pS->
m_p[1];
386 float Phi1 = pS->
m_p[2];
388 for (
unsigned int out_idx = last_out; out_idx < out_sort.size();
390 int outEdgeIdx = out_sort[out_idx].second;
393 &(edgeStorage.at(outEdgeIdx));
395 float tau2 = pNS->
m_p[0];
396 float tau_ratio = tau2 * uat_1 - 1.0f;
398 if (tau_ratio < -cut_tau_ratio_max) {
402 if (tau_ratio > cut_tau_ratio_max) {
406 float dPhi = pNS->
m_p[3] - Phi1;
410 }
else if (dPhi > M_PI) {
414 if (dPhi < -cut_dphi_max || dPhi > cut_dphi_max) {
418 float curv2 = pNS->
m_p[1];
419 float dcurv = curv2 - curv1;
421 if (dcurv < -cut_dcurv_max || dcurv > cut_dcurv_max) {
433 const int maxIter = 15;
439 std::vector<Acts::TrigFTF_GNN_Edge<external_spacepoint_t>*> v_old;
441 for (
int edgeIndex = 0; edgeIndex < nEdges; edgeIndex++) {
443 &(edgeStorage.at(edgeIndex));
451 for (; iter < maxIter; iter++) {
453 std::vector<Acts::TrigFTF_GNN_Edge<external_spacepoint_t>*> v_new;
456 for (
auto pS : v_old) {
457 int next_level = pS->m_level;
459 for (
int nIdx = 0; nIdx < pS->m_nNei; nIdx++) {
460 unsigned int nextEdgeIdx = pS->m_vNei[nIdx];
463 &(edgeStorage.at(nextEdgeIdx));
465 if (pS->m_level == pN->
m_level) {
472 pS->m_next = next_level;
478 for (
auto pS : v_new) {
479 if (pS->m_next != pS->m_level) {
481 pS->m_level = pS->m_next;
482 if (maxLevel < pS->m_level) {
483 maxLevel = pS->m_level;
498 std::vector<Acts::TrigFTF_GNN_Edge<external_spacepoint_t>*> vSeeds;
500 vSeeds.reserve(MaxEdges / 2);
502 for (
int edgeIndex = 0; edgeIndex < nEdges; edgeIndex++) {
504 &(edgeStorage.at(edgeIndex));
510 vSeeds.push_back(pS);
516 vSeeds.begin(), vSeeds.end(),
519 if (vSeeds.empty()) {
526 m_config.m_layerGeometry, edgeStorage);
528 for (
auto pS : vSeeds) {
529 if (pS->m_level == -1) {
541 if (static_cast<int>(rs.
m_vs.size()) < minLevel) {
545 std::vector<const FTF_SP<external_spacepoint_t>*> vSP;
548 reverse_iterator sIt = rs.
m_vs.rbegin();
549 sIt != rs.
m_vs.rend(); ++sIt) {
550 (*sIt)->m_level = -1;
552 if (sIt == rs.
m_vs.rbegin()) {
553 vSP.push_back(&(*sIt)->m_n1->m_sp_FTF);
555 vSP.push_back(&(*sIt)->m_n2->m_sp_FTF);
558 if (vSP.size() < 3) {
564 unsigned int nTriplets = 0;
566 std::vector<TrigInDetTriplet<external_spacepoint_t>>
output;
568 for (
unsigned int idx_m = 1; idx_m < vSP.size() - 1; idx_m++) {
570 const double pS_r = spM.
SP->r();
571 const double pS_x = spM.
SP->x();
572 const double pS_y = spM.
SP->y();
573 const double cosA = pS_x / pS_r;
574 const double sinA = pS_y / pS_r;
576 for (
unsigned int idx_o = idx_m + 1; idx_o < vSP.size(); idx_o++) {
579 double dx = spO.
SP->x() - pS_x;
580 double dy = spO.
SP->y() - pS_y;
581 double R2inv = 1.0 / (dx * dx + dy *
dy);
582 double xn = dx * cosA + dy * sinA;
583 double yn = -dx * sinA + dy * cosA;
585 const double uo = xn * R2inv;
586 const double vo = yn * R2inv;
588 for (
unsigned int idx_i = 0; idx_i < idx_m; idx_i++) {
591 dx = spI.
SP->x() - pS_x;
592 dy = spI.
SP->y() - pS_y;
593 R2inv = 1.0 / (dx * dx + dy *
dy);
595 xn = dx * cosA + dy * sinA;
596 yn = -dx * sinA + dy * cosA;
598 const double ui = xn * R2inv;
599 const double vi = yn * R2inv;
603 const double du = uo - ui;
607 const double A = (vo - vi) / du;
608 const double B = vi - A * ui;
609 const double R_squ = (1 + A *
A) / (B * B);
611 if (R_squ < m_minR_squ) {
617 const double fabs_d0 = std::abs(pS_r * (B * pS_r - A));
619 if (fabs_d0 > m_config.m_tripletD0Max) {
637 const double Q = fabs_d0 * fabs_d0;
639 output.emplace_back(spI, spM, spO, Q);
643 if (nTriplets >= m_config.m_maxTripletBufferLength) {
647 if (nTriplets >= m_config.m_maxTripletBufferLength) {
651 if (nTriplets >= m_config.m_maxTripletBufferLength) {
656 if (output.empty()) {
660 vTracks.emplace_back(vSP, output);
664 template <
typename external_spacepo
int_t>
668 std::vector<GNN_TrigTracklet<external_spacepoint_t>>
671 vTracks.reserve(5000);
673 runGNN_TrackFinder(vTracks, roi, gnngeo);
675 if (vTracks.empty()) {
681 for (
auto& track : vTracks) {
682 for (
auto&
seed : track.m_seeds) {
684 float newQ =
seed.Q();
685 if (m_config.m_LRTmode) {
687 if (
seed.s1().isPixel()) {
690 if (
seed.s2().isPixel()) {
693 if (
seed.s3().isPixel()) {
699 if (
seed.s3().isSCT()) {
700 newQ +=
seed.s1().isSCT() ? 1000.0 : 10000.0;
704 m_triplets.emplace_back(
seed);
711 template <
typename external_spacepo
int_t>
712 template <
typename input_container_t,
typename output_container_t,
716 const input_container_t& , output_container_t& ,
717 callable_t&& )
const {}
719 template <
typename external_spacepo
int_t>
720 template <
typename input_container_t,
typename callable_t>
721 std::vector<Seed<external_spacepoint_t>>
724 const input_container_t& spacePoints,
725 callable_t&& extract_coordinates)
const {
726 std::vector<seed_t>
r;
727 createSeeds_old(options, spacePoints, r,
728 std::forward<callable_t>(extract_coordinates));