37 if (conn_fileName.empty()) {
38 ATH_MSG_FATAL(
"Cannot find layer connections file " << conn_fileName);
39 return StatusCode::FAILURE;
43 std::ifstream ifs(conn_fileName.c_str());
50 ATH_MSG_INFO(
"Layer connections are initialized from file " << conn_fileName);
55 std::copy(pVL->begin(),pVL->end(), std::back_inserter(
m_layerGeometry));
62 if (lut_fileName.empty()) {
63 ATH_MSG_FATAL(
"Cannot find ML predictor LUT file " << lut_fileName);
64 return StatusCode::FAILURE;
68 std::ifstream ifs(lut_fileName.c_str());
70 float cl_width, min1, max1, min2, max2;
71 ifs >> cl_width >> min1 >> max1 >> min2 >> max2;
73 std::array<float, 5> lut_line = {cl_width, min1, max1, min2, max2};
77 ATH_MSG_INFO(
"ML predictor is initialized from file " << lut_fileName<<
" LUT has "<<
m_mlLUT.size()<<
" entries");
90 return StatusCode::SUCCESS;
101 struct GBTS_SlidingWindow {
103 GBTS_SlidingWindow() : m_first_it(0), m_deltaPhi(0.0), m_has_nodes(
false), m_bin(
nullptr) {};
105 unsigned int m_first_it;
114 const float cut_dphi_max =
m_LRTmode ? 0.07f : 0.012f;
115 const float cut_dcurv_max =
m_LRTmode ? 0.015f : 0.001f;
119 const float min_deltaPhi =
m_LRTmode ? 0.01f : 0.001f;
120 const float tau_ratio_precut = 0.009f;
122 const float maxOuterRadius =
m_LRTmode ? 1050.0 : 550.0;
124 const float cut_zMinU = min_z0 + maxOuterRadius*roi.
dzdrMinus();
125 const float cut_zMaxU = max_z0 + maxOuterRadius*roi.
dzdrPlus();
127 constexpr float ptCoeff = 0.29997*1.9972/2.0;
129 float tripletPtMin = 0.8f*
m_minPt;
130 const float pt_scale = 900.0f/
m_minPt;
132 float maxCurv = ptCoeff/tripletPtMin;
134 float maxKappa_high_eta =
m_LRTmode ? 1.0f*maxCurv : std::sqrt(0.8f)*maxCurv;
135 float maxKappa_low_eta =
m_LRTmode ? 1.0f*maxCurv : std::sqrt(0.6f)*maxCurv;
138 maxKappa_high_eta = 4.75e-4f*pt_scale;
139 maxKappa_low_eta = 3.75e-4f*pt_scale;
142 const float dphi_coeff =
m_LRTmode ? 1.0f*maxCurv : 0.68f*maxCurv;
144 const float minDeltaRadius = 2.0;
148 unsigned int nConnections = 0;
154 for(
const auto& bg :
m_geo->bin_groups()) {
158 if(B1.
empty())
continue;
166 std::vector<GBTS_SlidingWindow> vSLW;
168 vSLW.resize(bg.second.size());
172 for(
const auto& b2_idx : bg.second) {
186 float abs_dr = std::fabs(rb2-rb1);
188 deltaPhi = min_deltaPhi + dphi_coeff*abs_dr;
192 deltaPhi = 0.002f + 4.33e-4f*pt_scale*abs_dr;
194 deltaPhi = 0.015f + 2.2e-4f*pt_scale*abs_dr;
199 vSLW[win_idx].m_bin = &B2;
200 vSLW[win_idx].m_has_nodes =
true;
201 vSLW[win_idx].m_deltaPhi =
deltaPhi;
205 for(
unsigned int n1Idx = 0;n1Idx<B1.
m_vn.size();n1Idx++) {
209 unsigned short num_created_edges = 0;
211 bool is_connected =
false;
213 const std::array<float, 5>& n1pars = B1.
m_params[n1Idx];
215 float phi1 = n1pars[2];
216 float r1 = n1pars[3];
217 float z1 = n1pars[4];
219 for(
unsigned int winIdx = 0; winIdx < vSLW.size(); winIdx++) {
221 GBTS_SlidingWindow& slw = vSLW[winIdx];
223 if (!slw.m_has_nodes)
continue;
234 for(
unsigned int n2PhiIdx = slw.m_first_it; n2PhiIdx<B2.
m_vPhiNodes.size();n2PhiIdx++) {
239 slw.m_first_it = n2PhiIdx;
242 if(phi2 > maxPhi)
break;
244 unsigned int n2Idx = B2.
m_vPhiNodes[n2PhiIdx].second;
249 unsigned short n2_num_edges = B2.
m_vNumEdges[n2Idx];
250 unsigned int n2_last_edge = n2_first_edge + n2_num_edges;
252 const std::array<float, 5>& n2pars = B2.
m_params[n2Idx];
254 float r2 = n2pars[3];
258 if(dr < minDeltaRadius) {
262 float z2 = n2pars[4];
266 float ftau = std::fabs(tau);
271 if(ftau < n1pars[0])
continue;
272 if(ftau > n1pars[1])
continue;
274 if(ftau < n2pars[0])
continue;
275 if(ftau > n2pars[1])
continue;
279 float z0 = z1 - r1*tau;
281 if(z0 < min_z0 || z0 > max_z0)
continue;
283 float zouter = z0 + maxOuterRadius*tau;
285 if(zouter < cut_zMinU || zouter > cut_zMaxU)
continue;
288 float curv = (phi2-phi1)/dr;
289 float abs_curv = std::abs(curv);
292 if(abs_curv > maxKappa_low_eta) {
297 if(abs_curv > maxKappa_high_eta) {
302 float exp_eta = std::sqrt(1.f+tau*tau) - tau;
306 bool isGood = n2_num_edges <= 2;
310 float uat_1 = 1.0f/exp_eta;
312 for(
unsigned int n2_in_idx = n2_first_edge; n2_in_idx < n2_last_edge; n2_in_idx++) {
314 float tau2 = edgeStorage.at(n2_in_idx).m_p[0];
315 float tau_ratio = tau2*uat_1 - 1.0f;
317 if(std::fabs(tau_ratio) > tau_ratio_precut){
330 float dPhi2 = curv*r2;
331 float dPhi1 = curv*r1;
335 edgeStorage.emplace_back(B1.
m_vn[n1Idx], B2.
m_vn[n2Idx], exp_eta, curv, phi1 + dPhi1);
339 int outEdgeIdx = nEdges;
341 float uat_2 = 1.f/exp_eta;
342 float Phi2 = phi2 + dPhi2;
345 for(
unsigned int inEdgeIdx = n2_first_edge; inEdgeIdx < n2_last_edge; inEdgeIdx++) {
351 float tau_ratio = pS->
m_p[0]*uat_2 - 1.0f;
353 if(std::abs(tau_ratio) > cut_tau_ratio_max){
357 float dPhi = Phi2 - pS->
m_p[2];
362 if(std::abs(dPhi) > cut_dphi_max) {
366 float dcurv = curv2 - pS->
m_p[1];
368 if(dcurv < -cut_dcurv_max || dcurv > cut_dcurv_max) {
395 ATH_MSG_WARNING(
"Maximum number of graph edges exceeded - possible efficiency loss "<< nEdges);
398 return std::make_pair(nEdges, nConnections);
403 constexpr int maxIter = 15;
409 std::vector<TrigFTF_GNN_Edge*> v_old;
411 for(
int edgeIndex=0;edgeIndex<nEdges;edgeIndex++) {
414 if(pS->
m_nNei == 0)
continue;
419 std::vector<TrigFTF_GNN_Edge*> v_new;
420 v_new.reserve(v_old.size());
422 for(;iter<maxIter;iter++) {
427 for(
auto pS : v_old) {
429 int next_level = pS->m_level;
431 for(
int nIdx=0;nIdx<pS->m_nNei;nIdx++) {
433 unsigned int nextEdgeIdx = pS->m_vNei[nIdx];
437 if(pS->m_level == pN->
m_level) {
438 next_level = pS->m_level + 1;
444 pS->m_next = next_level;
451 for(
auto pS : v_new) {
452 if(pS->m_next != pS->m_level) {
454 pS->m_level = pS->m_next;
455 if(maxLevel < pS->m_level) maxLevel = pS->m_level;
459 if(nChanges == 0)
break;
471 const float edge_mask_min_eta = 1.5;
472 const float hit_share_threshold = 0.49;
474 vSeedCandidates.clear();
482 if(maxLevel < minLevel)
return;
484 std::vector<GNN_Edge*> vSeeds;
486 vSeeds.reserve(nEdges/2);
488 for(
int edgeIndex = 0; edgeIndex < nEdges; edgeIndex++) {
490 GNN_Edge* pS = &(edgeStorage.at(edgeIndex));
492 if(pS->
m_level < minLevel)
continue;
494 vSeeds.push_back(pS);
497 if(vSeeds.empty())
return;
503 vSeedCandidates.reserve(vSeeds.size());
505 auto tFilter = std::make_unique<TrigFTF_GNN_TrackingFilter>(
m_layerGeometry, edgeStorage);
507 for(
auto pS : vSeeds) {
509 if(pS->m_level == -1)
continue;
513 tFilter->followTrack(pS,
rs);
515 if(!
rs.m_initialized) {
519 if(
static_cast<int>(
rs.m_vs.size()) < minLevel)
continue;
521 float seed_eta = std::abs(-std::log(pS->m_p[0]));
523 std::vector<const GNN_Node*> vN;
525 for(std::vector<GNN_Edge*>::reverse_iterator sIt=
rs.m_vs.rbegin();sIt!=
rs.m_vs.rend();++sIt) {
527 if (seed_eta > edge_mask_min_eta) {
528 (*sIt)->m_level = -1;
531 if(sIt ==
rs.m_vs.rbegin()) {
532 vN.push_back((*sIt)->m_n1);
535 vN.push_back((*sIt)->m_n2);
539 if(vN.size()<3)
continue;
541 std::vector<unsigned int> vSpIdx;
543 vSpIdx.resize(vN.size());
545 for(
unsigned int k = 0; k < vN.size(); k++) {
546 vSpIdx[k] = vN[k]->sp_idx();
549 vSeedCandidates.emplace_back(-
rs.m_J/vN.size(), 0, vSpIdx);
555 std::sort(vSeedCandidates.begin(), vSeedCandidates.end());
557 std::vector<int> H2T(
nHits + 1, 0);
561 for(
const auto& seed : vSeedCandidates) {
565 for(
const auto&
h : std::get<2>(seed) ) {
567 unsigned int hit_id =
h + 1;
569 int tid = H2T[hit_id];
571 if(tid == 0 || tid > trackId) {
573 H2T[hit_id] = trackId;
579 for(
unsigned int trackIdx = 0; trackIdx < vSeedCandidates.size(); trackIdx++) {
581 int nTotal = std::get<2>(vSeedCandidates[trackIdx]).size();
584 int trackId = trackIdx + 1;
586 for(
const auto&
h : std::get<2>(vSeedCandidates[trackIdx]) ) {
588 unsigned int hit_id =
h + 1;
590 int tid = H2T[hit_id];
597 if (nOther > hit_share_threshold*nTotal) {
598 std::get<1>(vSeedCandidates[trackIdx]) = -1;