32 if (conn_fileName.empty()) {
33 ATH_MSG_FATAL(
"Cannot find layer connections file " << conn_fileName);
34 return StatusCode::FAILURE;
38 std::ifstream ifs(conn_fileName.c_str());
45 ATH_MSG_INFO(
"Layer connections are initialized from file " << conn_fileName);
57 if (lut_fileName.empty()) {
58 ATH_MSG_FATAL(
"Cannot find ML predictor LUT file " << lut_fileName);
59 return StatusCode::FAILURE;
63 std::ifstream ifs(lut_fileName.c_str());
65 float cl_width, min1,
max1, min2, max2;
66 ifs >> cl_width >> min1 >>
max1 >> min2 >> max2;
68 std::array<float, 5> lut_line = {cl_width, min1,
max1, min2, max2};
72 ATH_MSG_INFO(
"ML predictor is initialized from file " << lut_fileName<<
" LUT has "<<
m_mlLUT.size()<<
" entries");
85 return StatusCode::SUCCESS;
97 const float cut_dphi_max =
m_LRTmode ? 0.07f : 0.012f;
98 const float cut_dcurv_max =
m_LRTmode ? 0.015f : 0.001f;
102 const float min_deltaPhi =
m_LRTmode ? 0.01f : 0.001f;
104 const float maxOuterRadius =
m_LRTmode ? 1050.0 : 550.0;
106 const float cut_zMinU = min_z0 + maxOuterRadius*roi.
dzdrMinus();
107 const float cut_zMaxU = max_z0 + maxOuterRadius*roi.
dzdrPlus();
109 constexpr
float ptCoeff = 0.29997*1.9972/2.0;
111 float tripletPtMin = 0.8f*
m_minPt;
112 const float pt_scale = 900.0f/
m_minPt;
114 float maxCurv = ptCoeff/tripletPtMin;
116 float maxKappa_high_eta =
m_LRTmode ? 1.0f*maxCurv : std::sqrt(0.8
f)*maxCurv;
117 float maxKappa_low_eta =
m_LRTmode ? 1.0f*maxCurv : std::sqrt(0.6
f)*maxCurv;
120 maxKappa_high_eta = 4.75e-4
f*pt_scale;
121 maxKappa_low_eta = 3.75e-4
f*pt_scale;
124 const float dphi_coeff =
m_LRTmode ? 1.0f*maxCurv : 0.68f*maxCurv;
126 const float minDeltaRadius = 2.0;
130 unsigned int nConnections = 0;
136 for(
const auto&
bg :
m_geo->bin_groups()) {
140 if(B1.
empty())
continue;
144 for(
const auto& b2_idx :
bg.second) {
148 if(B2.
empty())
continue;
153 float abs_dr = std::fabs(rb2-rb1);
155 deltaPhi = min_deltaPhi + dphi_coeff*abs_dr;
159 deltaPhi = 0.002f + 4.33e-4
f*pt_scale*abs_dr;
161 deltaPhi = 0.015f + 2.2e-4
f*pt_scale*abs_dr;
166 unsigned int first_it = 0;
168 for(
unsigned int n1Idx = 0;n1Idx<B1.
m_vn.size();n1Idx++) {
170 std::vector<unsigned int>& v1In = B1.
m_in[n1Idx];
174 const std::array<float, 5>& n1pars = B1.
m_params[n1Idx];
176 float phi1 = n1pars[2];
177 float r1 = n1pars[3];
178 float z1 = n1pars[4];
185 for(
unsigned int n2PhiIdx = first_it; n2PhiIdx<B2.
m_vPhiNodes.size();n2PhiIdx++) {
193 if(phi2 > maxPhi)
break;
195 unsigned int n2Idx = B2.
m_vPhiNodes[n2PhiIdx].second;
197 const std::vector<unsigned int>& v2In = B2.
m_in[n2Idx];
201 const std::array<float, 5>& n2pars = B2.
m_params[n2Idx];
203 float r2 = n2pars[3];
207 if(
dr < minDeltaRadius) {
211 float z2 = n2pars[4];
215 float ftau = std::fabs(tau);
220 if(ftau < n1pars[0])
continue;
221 if(ftau > n1pars[1])
continue;
223 if(ftau < n2pars[0])
continue;
224 if(ftau > n2pars[1])
continue;
228 float z0 = z1 - r1*tau;
230 if(z0 < min_z0 || z0 > max_z0)
continue;
232 float zouter =
z0 + maxOuterRadius*tau;
234 if(zouter < cut_zMinU || zouter > cut_zMaxU)
continue;
237 float curv = (phi2-phi1)/
dr;
238 float abs_curv = std::abs(curv);
241 if(abs_curv > maxKappa_low_eta) {
246 if(abs_curv > maxKappa_high_eta) {
251 float exp_eta = std::sqrt(1.
f+tau*tau)-tau;
255 bool isGood = v2In.size() <= 2;
259 float uat_1 = 1.0f/exp_eta;
261 for(
const auto& n2_in_idx : v2In) {
263 float tau2 = edgeStorage.at(n2_in_idx).m_p[0];
264 float tau_ratio = tau2*uat_1 - 1.0f;
266 if(std::fabs(tau_ratio) > cut_tau_ratio_max){
279 float dPhi2 = curv*r2;
280 float dPhi1 = curv*r1;
284 edgeStorage.emplace_back(B1.
m_vn[n1Idx], B2.
m_vn[n2Idx], exp_eta, curv, phi1 + dPhi1);
288 int outEdgeIdx = nEdges;
290 float uat_2 = 1.f/exp_eta;
291 float Phi2 = phi2 + dPhi2;
294 for(
const auto& inEdgeIdx : v2In) {
300 float tau_ratio = pS->
m_p[0]*uat_2 - 1.0f;
302 if(std::abs(tau_ratio) > cut_tau_ratio_max){
306 float dPhi = Phi2 - pS->
m_p[2];
311 if(dPhi < -cut_dphi_max || dPhi > cut_dphi_max) {
315 float dcurv = curv2 - pS->
m_p[1];
317 if(dcurv < -cut_dcurv_max || dcurv > cut_dcurv_max) {
334 ATH_MSG_WARNING(
"Maximum number of graph edges exceeded - possible efficiency loss "<< nEdges);
337 return std::make_pair(nEdges, nConnections);
342 constexpr
int maxIter = 15;
348 std::vector<TrigFTF_GNN_Edge*> v_old;
350 for(
int edgeIndex=0;edgeIndex<nEdges;edgeIndex++) {
353 if(pS->
m_nNei == 0)
continue;
358 std::vector<TrigFTF_GNN_Edge*> v_new;
359 v_new.reserve(v_old.size());
366 for(
auto pS : v_old) {
368 int next_level = pS->m_level;
370 for(
int nIdx=0;nIdx<pS->m_nNei;nIdx++) {
372 unsigned int nextEdgeIdx = pS->m_vNei[nIdx];
376 if(pS->m_level == pN->
m_level) {
383 pS->m_next = next_level;
390 for(
auto pS : v_new) {
391 if(pS->m_next != pS->m_level) {
393 pS->m_level = pS->m_next;
394 if(maxLevel < pS->m_level) maxLevel = pS->m_level;
398 if(nChanges == 0)
break;