14 #if defined(MKFIT_STANDALONE) 18 #ifdef RNT_DUMP_MkF_SelHitIdcs 20 #include "RecoTracker/MkFitCore/standalone/RntDumper/MkFinder_selectHitIndices.icc" 23 #include "vdt/atan2.h" 35 const std::vector<bool> *ihm,
69 #ifdef RNT_DUMP_MkF_SelHitIdcs 79 L.is_barrel() ? LI.
rin() : LI.
zmin(),
84 *rnt_shi.f = *rnt_shi.h;
89 #ifdef RNT_DUMP_MkF_SelHitIdcs 105 const int iI = inputProp ?
iP :
iC;
107 for (
int i = beg, imp = 0;
i < end; ++
i, ++imp) {
113 const std::vector<Track> &
tracks,
const std::vector<int> &idxs,
int beg,
int end,
bool inputProp,
int mp_offset) {
119 const int iI = inputProp ?
iP :
iC;
121 for (
int i = beg, imp = mp_offset;
i < end; ++
i, ++imp) {
136 const int iI = inputProp ?
iP :
iC;
138 for (
int i = beg, imp = 0;
i < end; ++
i, ++imp) {
151 const std::vector<UpdateIndices> &idxs,
160 const int iI = inputProp ?
iP :
iC;
162 for (
int i = beg, imp = 0;
i < end; ++
i, ++imp) {
178 const std::vector<std::pair<int, IdxChi2List>> &idxs,
187 const int iI = inputProp ?
iP :
iC;
189 for (
int i = beg, imp = 0;
i < end; ++
i, ++imp) {
204 const int iO = outputProp ?
iP :
iC;
206 for (
int i = beg, imp = 0;
i < end; ++
i, ++imp) {
212 std::vector<Track> &
tracks,
const std::vector<int> &idxs,
int beg,
int end,
bool outputProp)
const {
216 const int iO = outputProp ?
iP :
iC;
218 for (
int i = beg, imp = 0;
i < end; ++
i, ++imp) {
229 const float invpt,
const float theta,
float &min_dq,
float &max_dq,
float &min_dphi,
float &max_dphi) {
230 float max_invpt =
std::min(invpt, 10.0
f);
232 enum SelWinParameters_e { dp_sf = 0, dp_0, dp_1, dp_2, dq_sf, dq_0, dq_1, dq_2 };
237 float this_dq =
v[dq_sf] * (
v[dq_0] * max_invpt +
v[dq_1] *
theta +
v[dq_2]);
241 max_dq = 2.0f * min_dq;
245 float this_dphi =
v[dp_sf] * (
v[dp_0] * max_invpt +
v[dp_1] *
theta +
v[dp_2]);
247 if (this_dphi > min_dphi) {
248 min_dphi = this_dphi;
249 max_dphi = 2.0f * min_dphi;
261 const float invpt =
m_Par[ipar].At(itrk, 3, 0);
264 float max_invpt =
std::min(invpt, 10.0
f);
266 enum SelWinParameters_e { c2_sf = 8, c2_0, c2_1, c2_2 };
270 float this_c2 =
v[c2_sf] * (
v[c2_0] * max_invpt +
v[c2_1] *
theta +
v[c2_2]);
272 if (this_c2 > minChi2Cut)
292 const float nSigmaR = 3;
294 dprintf(
"LayerOfHits::SelectHitIndices %s layer=%d N_proc=%d\n",
295 L.is_barrel() ?
"barrel" :
"endcap",
299 float dqv[
NN], dphiv[
NN], qv[
NN], phiv[
NN];
300 bidx_t qb1v[
NN], qb2v[
NN], qbv[
NN], pb1v[
NN], pb2v[
NN];
302 const auto assignbins = [&](
int itrack,
311 dphi = std::clamp(
std::abs(dphi), min_dphi, max_dphi);
312 dq = std::clamp(dq, min_dq, max_dq);
316 dphiv[itrack] = dphi;
319 qbv[itrack] =
L.qBinChecked(
q);
320 qb1v[itrack] =
L.qBinChecked(
q - dq);
321 qb2v[itrack] =
L.qBinChecked(
q + dq) + 1;
322 pb1v[itrack] =
L.phiBinChecked(phi - dphi);
323 pb2v[itrack] =
L.phiMaskApply(
L.phiBin(phi + dphi) + 1);
326 const auto calcdphi2 = [&](
int itrack,
float dphidx,
float dphidy) {
327 return dphidx * dphidx *
m_Err[iI].constAt(itrack, 0, 0) + dphidy * dphidy *
m_Err[iI].constAt(itrack, 1, 1) +
328 2 * dphidx * dphidy *
m_Err[iI].constAt(itrack, 0, 1);
331 const auto calcdphi = [&](
float dphi2,
float min_dphi) {
341 #if !defined(__clang__) 344 for (
int itrack = 0; itrack <
NN; ++itrack) {
347 float min_dq = ILC.
min_dq();
348 float max_dq = ILC.
max_dq();
352 const float invpt =
m_Par[iI].At(itrack, 3, 0);
356 const float x =
m_Par[iI].constAt(itrack, 0, 0);
357 const float y =
m_Par[iI].constAt(itrack, 1, 0);
358 const float r2 =
x *
x + y * y;
359 const float dphidx = -y /
r2, dphidy =
x /
r2;
360 const float dphi2 = calcdphi2(itrack, dphidx, dphidy);
365 const float phi =
getPhi(
x, y);
366 float dphi = calcdphi(dphi2, min_dphi);
368 const float z =
m_Par[iI].constAt(itrack, 2, 0);
370 const float edgeCorr =
std::abs(0.5
f * (
L.layer_info()->rout() -
L.layer_info()->rin()) /
375 assignbins(itrack, z,
dz, phi, dphi, min_dq, max_dq, min_dphi, max_dphi);
385 const float layerD =
std::abs(
L.layer_info()->zmax() -
L.layer_info()->zmin()) * 0.5
f *
388 #if !defined(__clang__) 391 for (
int itrack = 0; itrack <
NN; ++itrack) {
394 float min_dq = ILC.
min_dq();
395 float max_dq = ILC.
max_dq();
399 const float invpt =
m_Par[iI].At(itrack, 3, 0);
403 const float x =
m_Par[iI].constAt(itrack, 0, 0);
404 const float y =
m_Par[iI].constAt(itrack, 1, 0);
405 const float r2 =
x *
x + y * y;
406 const float r2Inv = 1.f /
r2;
407 const float dphidx = -y * r2Inv, dphidy =
x * r2Inv;
408 const float phi =
getPhi(
x, y);
410 calcdphi2(itrack, dphidx, dphidy)
418 float dphi = calcdphi(dphi2, min_dphi);
422 y * y *
m_Err[iI].constAt(itrack, 1, 1) +
423 2 *
x * y *
m_Err[iI].constAt(itrack, 0, 1)) /
425 const float edgeCorr =
std::abs(0.5
f * (
L.layer_info()->zmax() -
L.layer_info()->zmin()) *
429 assignbins(itrack, r, dr, phi, dphi, min_dq, max_dq, min_dphi, max_dphi);
433 #ifdef RNT_DUMP_MkF_SelHitIdcs 434 if (fill_binsearch_only) {
436 for (
auto i : rnt_shi.f_h_idcs) {
437 CandInfo &ci = (*rnt_shi.ci)[rnt_shi.f_h_remap[
i]];
456 for (
int itrack = 0; itrack < N_proc; ++itrack) {
468 const bidx_t qb = qbv[itrack];
469 const bidx_t qb1 = qb1v[itrack];
470 const bidx_t qb2 = qb2v[itrack];
471 const bidx_t pb1 = pb1v[itrack];
472 const bidx_t pb2 = pb2v[itrack];
474 const float q = qv[itrack];
475 const float phi = phiv[itrack];
476 const float dphi = dphiv[itrack];
477 const float dq = dqv[itrack];
480 dprintf(
" %2d/%2d: %6.3f %6.3f %6.6f %7.5f %3u %3u %4u %4u\n",
481 L.layer_id(), itrack,
q, phi, dq, dphi,
485 #if defined(DUMPHITWINDOW) && defined(MKFIT_STANDALONE) 486 const auto ngr = [](
float f) {
return isFinite(
f) ?
f : -999.0f; };
493 for (bidx_t qi = qb1; qi != qb2; ++qi) {
494 for (bidx_t
pi = pb1;
pi != pb2;
pi =
L.phiMaskApply(
pi + 1)) {
496 if (qi == qb &&
L.isBinDead(
pi, qi) ==
true) {
497 dprint(
"dead module for track in layer=" <<
L.layer_id() <<
" qb=" << qi <<
" pi=" <<
pi <<
" q=" <<
q 510 auto pbi =
L.phiQBinContent(
pi, qi);
511 for (bcnt_t
hi = pbi.begin();
hi < pbi.end(); ++
hi) {
514 const unsigned int hi_orig =
L.getOriginalHitIndex(
hi);
518 "Yay, denying masked hit on layer %u, hi %u, orig idx %u\n",
L.layer_info()->layer_id(),
hi, hi_orig);
530 dprintf(
" SHI %3u %4u %5u %6.3f %6.3f %6.4f %7.5f %s\n",
532 ddq, ddphi, (ddq < dq && ddphi < dphi) ?
"PASS" :
"FAIL");
535 #if defined(DUMPHITWINDOW) && defined(MKFIT_STANDALONE) 541 int st_isfindable = 0;
542 int st_label = -999999;
549 float st_eta = -999.;
550 float st_phi = -999.;
554 st_label = simtrack.
label();
556 st_pt = simtrack.
pT();
557 st_eta = simtrack.
momEta();
558 st_phi = simtrack.
momPhi();
560 st_charge = simtrack.
charge();
561 st_r = simtrack.
posR();
565 const Hit &thishit =
L.refHit(hi_orig);
584 float hx = thishit.
x();
585 float hy = thishit.
y();
586 float hz = thishit.
z();
588 float hphi = std::atan2(hy, hx);
593 (hx * hx * thishit.
exx() + hy * hy * thishit.
eyy() + 2.0f * hx * hy *
m_msErr.At(itrack, 0, 1)) /
596 float hchi2 = ngr( thisOutChi2[itrack] );
597 float tx =
m_Par[iI].At(itrack, 0, 0);
598 float ty =
m_Par[iI].At(itrack, 1, 0);
599 float tz =
m_Par[iI].At(itrack, 2, 0);
601 float tphi = std::atan2(ty, tx);
607 (tx * tx *
tex *
tex + ty * ty * tey * tey + 2.0
f * tx * ty *
m_Err[iI].At(itrack, 0, 1)) /
610 (ty * ty *
tex *
tex + tx * tx * tey * tey - 2.0
f * tx * ty *
m_Err[iI].At(itrack, 0, 1)) /
611 (tr * tr * tr * tr)) );
613 float ht_dz = hz - tz;
616 static bool first =
true;
620 "evt_id/I:track_algo/I:" 621 "lyr_id/I:lyr_isbrl/I:hit_idx/I:" 622 "trk_cnt/I:trk_idx/I:trk_label/I:" 623 "trk_pt/F:trk_eta/F:trk_mphi/F:trk_chi2/F:" 625 "seed_idx/I:seed_label/I:seed_mcid/I:" 627 "st_isfindable/I:st_prodtype/I:st_label/I:" 628 "st_pt/F:st_eta/F:st_phi/F:" 629 "st_nhits/I:st_charge/I:st_r/F:st_z/F:" 630 "trk_q/F:hit_q/F:dq_trkhit/F:dq_cut/F:trk_phi/F:hit_phi/F:dphi_trkhit/F:dphi_cut/F:" 631 "t_x/F:t_y/F:t_r/F:t_phi/F:t_z/F:" 632 "t_ex/F:t_ey/F:t_er/F:t_ephi/F:t_ez/F:" 633 "h_x/F:h_y/F:h_r/F:h_phi/F:h_z/F:" 634 "h_ex/F:h_ey/F:h_er/F:h_ephi/F:h_ez/F:" 635 "ht_dxy/F:ht_dz/F:ht_dphi/F:" 643 printf(
"HITWINDOWSEL " 647 "%6.3f %6.3f %6.3f %6.3f " 654 "%6.3f %6.3f %6.3f %6.3f %6.3f %6.3f %6.3f %6.3f " 655 "%6.3f %6.3f %6.3f %6.3f %6.3f " 656 "%6.6f %6.6f %6.6f %6.6f %6.6f " 657 "%6.3f %6.3f %6.3f %6.3f %6.3f " 658 "%6.6f %6.6f %6.6f %6.6f %6.6f " 663 L.layer_id(),
L.is_barrel(), hi_orig,
665 1.0f /
m_Par[iI].At(itrack, 3, 0),
getEta(
m_Par[iI].At(itrack, 5, 0)),
m_Par[iI].At(itrack, 4, 0),
m_Chi2(itrack, 0, 0),
669 st_isfindable, st_prodtype, st_label,
670 st_pt, st_eta, st_phi,
671 st_nhits, st_charge, st_r, st_z,
672 q,
L.hit_q(
hi), ddq, dq, phi,
L.hit_phi(
hi), ddphi, dphi,
673 tx, ty, tr, tphi, tz,
674 tex, tey, ter, tephi, tez,
675 hx, hy, hr, hphi, hz,
676 hex, hey, her, hephi, hez,
677 ht_dxy, ht_dz, ht_dphi,
701 assert(
false &&
"this code has not been used in a while -- see comments in code");
726 dprintf(
"LayerOfHits::SelectHitIndicesV2 %s layer=%d N_proc=%d\n",
727 L.is_barrel() ?
"barrel" :
"endcap",
731 #ifdef RNT_DUMP_MkF_SelHitIdcs 732 rnt_shi.InnerIdcsReset(N_proc);
733 for (
int i = 0;
i < N_proc; ++
i) {
737 }
else if (slfh.is_set()) {
745 constexpr
int NEW_MAX_HIT = 6;
746 constexpr
float DDPHI_PRESEL_FAC = 2.0f;
747 constexpr
float DDQ_PRESEL_FAC = 1.2f;
748 constexpr
float PHI_BIN_EXTRA_FAC = 2.75f;
749 constexpr
float Q_BIN_EXTRA_FAC = 1.6f;
751 namespace mp = mini_propagators;
754 mp::InitialStatePlex isp;
755 mp::StatePlex sp1, sp2;
764 void prop_to_limits(
const LayerInfo &li) {
790 phi_c = 0.5f * (pmax +
pmin);
791 for (
int ii = 0;
ii < n_proc; ++
ii) {
811 for (
int i = 0;
i <
p1.kTotSize; ++
i) {
827 B.prop_to_limits(LI);
828 B.find_bin_ranges(LI,
L);
830 for (
int i = 0;
i < N_proc; ++
i) {
850 #ifdef RNT_DUMP_MkF_SelHitIdcs 851 for (
auto i : rnt_shi.f_h_idcs) {
852 CandInfo &ci = (*rnt_shi.ci)[rnt_shi.f_h_remap[
i]];
856 0.5f * (
B.q2[
i] -
B.q1[
i]),
864 ci.
ps_min = statep2propstate(
B.sp1,
i);
865 ci.
ps_max = statep2propstate(
B.sp2,
i);
871 unsigned int hit_index;
873 auto pqe_cmp = [](
const PQE &
a,
const PQE &
b) {
return a.score <
b.score; };
874 std::priority_queue<PQE, std::vector<PQE>, decltype(pqe_cmp)> pqueue(pqe_cmp);
879 for (
int itrack = 0; itrack < N_proc; ++itrack) {
891 const bidx_t qb =
B.q0[itrack];
892 const bidx_t qb1 =
B.q1[itrack];
893 const bidx_t qb2 =
B.q2[itrack];
894 const bidx_t pb1 =
B.p1[itrack];
895 const bidx_t pb2 =
B.p2[itrack];
898 dprintf(
" %2d/%2d: %6.3f %6.3f %6.6f %7.5f %3u %3u %4u %4u\n",
899 L.layer_id(), itrack, qv[itrack], phi[itrack], dqv[itrack], dphiv[itrack],
903 mp::InitialState mp_is(
m_Par[iI],
m_Chg, itrack);
906 for (bidx_t qi = qb1; qi != qb2; ++qi) {
907 for (bidx_t
pi = pb1;
pi != pb2;
pi =
L.phiMaskApply(
pi + 1)) {
909 if (qi == qb &&
L.isBinDead(
pi, qi) ==
true) {
910 dprint(
"dead module for track in layer=" <<
L.layer_id() <<
" qb=" << qi <<
" pi=" <<
pi <<
" q=" <<
q 921 auto pbi =
L.phiQBinContent(
pi, qi);
922 for (bcnt_t
hi = pbi.begin();
hi < pbi.end(); ++
hi) {
925 const unsigned int hi_orig =
L.getOriginalHitIndex(
hi);
929 "Yay, denying masked hit on layer %u, hi %u, orig idx %u\n",
L.layer_info()->layer_id(),
hi, hi_orig);
936 float new_q, new_phi, new_ddphi, new_ddq;
940 prop_fail = mp_is.propagate_to_r(
mp::PA_Exact,
L.hit_qbar(
hi), mp_s,
true);
943 prop_fail = mp_is.propagate_to_z(
mp::PA_Exact,
L.hit_qbar(
hi), mp_s,
true);
947 new_phi = vdt::fast_atan2f(mp_s.y, mp_s.x);
952 new_ddq < DDQ_PRESEL_FAC *
L.hit_q_half_length(
hi) && new_ddphi < DDPHI_PRESEL_FAC * 0.0123f;
955 dprintf(
" SHI %3u %4u %5u %6.3f %6.3f %6.4f %7.5f PROP-%s %s\n",
957 ddq, ddphi, prop_fail ?
"FAIL" :
"OK", dqdphi_presel ?
"PASS" :
"REJECT");
960 if (prop_fail || !dqdphi_presel)
962 if (pqueue_size < NEW_MAX_HIT) {
963 pqueue.push({new_ddphi, hi_orig});
965 }
else if (new_ddphi < pqueue.top().score) {
967 pqueue.push({new_ddphi, hi_orig});
973 dprintf(
" PQUEUE (%d)", pqueue_size);
976 while (pqueue_size) {
978 m_XHitArr.At(itrack, pqueue_size, 0) = pqueue.top().hit_index;
979 dprintf(
" %d: %f %d", pqueue_size, pqueue.top().score, pqueue.top().hit_index);
1001 for (
int it = 0; it <
NN; ++it) {
1012 for (
int hit_cnt = 0; hit_cnt <
maxSize; ++hit_cnt) {
1018 for (
int itrack = 0; itrack < N_proc; ++itrack) {
1020 mhp.addInputAt(itrack, layer_of_hits.
refHit(
m_XHitArr.At(itrack, hit_cnt, 0)));
1044 for (
int itrack = 0; itrack < N_proc; ++itrack) {
1050 bestHit[itrack] =
m_XHitArr.At(itrack, hit_cnt, 0);
1057 for (
int itrack = 0; itrack < N_proc; ++itrack) {
1060 m_msErr.setDiagonal3x3(itrack, 666);
1075 if (bestHit[itrack] >= 0) {
1076 const Hit &
hit = layer_of_hits.
refHit(bestHit[itrack]);
1079 dprint(
"ADD BEST HIT FOR TRACK #" 1080 << itrack << std::endl
1081 <<
"prop x=" <<
m_Par[
iP].constAt(itrack, 0, 0) <<
" y=" <<
m_Par[
iP].constAt(itrack, 1, 0) << std::endl
1082 <<
"copy in hit #" << bestHit[itrack] <<
" x=" <<
hit.position()[0] <<
" y=" <<
hit.position()[1]);
1102 m_msErr.setDiagonal3x3(itrack, 666);
1115 dprint(
"update parameters");
1129 dprint(
"m_Par[iP](0,0,0)=" <<
m_Par[
iP](0, 0, 0) <<
" m_Par[iC](0,0,0)=" <<
m_Par[
iC](0, 0, 0));
1139 const float res =
std::abs(msPar.constAt(itrack, 2, 0) - pPar.constAt(itrack, 2, 0));
1140 const float hitHL =
sqrt(msErr.constAt(itrack, 2, 2) * 3.f);
1141 const float qErr =
sqrt(pErr.constAt(itrack, 2, 2));
1142 dprint(
"qCompat " << hitHL <<
" + " << 3.
f * qErr <<
" vs " <<
res);
1145 const float res[2]{msPar.constAt(itrack, 0, 0) - pPar.constAt(itrack, 0, 0),
1146 msPar.constAt(itrack, 1, 0) - pPar.constAt(itrack, 1, 0)};
1147 const float hitT2 = msErr.constAt(itrack, 0, 0) + msErr.constAt(itrack, 1, 1);
1148 const float hitT2inv = 1.f / hitT2;
1149 const float proj[3] = {msErr.constAt(itrack, 0, 0) * hitT2inv,
1150 msErr.constAt(itrack, 0, 1) * hitT2inv,
1151 msErr.constAt(itrack, 1, 1) * hitT2inv};
1153 sqrt(
std::abs(pErr.constAt(itrack, 0, 0) *
proj[0] + 2.f * pErr.constAt(itrack, 0, 1) *
proj[1] +
1154 pErr.constAt(itrack, 1, 1) *
proj[2]));
1155 const float resProj =
1157 dprint(
"qCompat " <<
sqrt(hitT2 * 3.
f) <<
" + " << 3.
f * qErr <<
" vs " << resProj);
1168 int itrack,
bool isBarrel,
unsigned int pcm,
unsigned int pcmMin,
const MPlexLV &pPar,
const MPlexHS &msErr) {
1175 const float hitT2 = msErr.constAt(itrack, 0, 0) + msErr.constAt(itrack, 1, 1);
1176 const float hitT2inv = 1.f / hitT2;
1177 const float proj[3] = {msErr.constAt(itrack, 0, 0) * hitT2inv,
1178 msErr.constAt(itrack, 0, 1) * hitT2inv,
1179 msErr.constAt(itrack, 1, 1) * hitT2inv};
1180 const bool detXY_OK =
1182 const float cosP =
cos(pPar.constAt(itrack, 4, 0));
1183 const float sinP =
sin(pPar.constAt(itrack, 4, 0));
1184 const float sinT =
std::abs(
sin(pPar.constAt(itrack, 5, 0)));
1187 2.
f * cosP * sinP *
proj[1]))
1194 const float qCorr = pcm * qSF;
1195 dprint(
"pcm " << pcm <<
" * " << qSF <<
" = " << qCorr <<
" vs " << pcmMin);
1196 return qCorr > pcmMin;
1204 std::vector<std::vector<TrackCand>> &tmp_candidates,
1215 for (
int it = 0; it <
NN; ++it) {
1225 int nHitsAdded[
NN]{};
1226 bool isTooLargeCluster[
NN]{
false};
1228 for (
int hit_cnt = 0; hit_cnt <
maxSize; ++hit_cnt) {
1234 for (
int itrack = 0; itrack < N_proc; ++itrack) {
1237 mhp.addInputAt(itrack,
hit);
1238 charge_pcm[itrack] =
hit.chargePerCM();
1266 bool oneCandPassCut =
false;
1267 for (
int itrack = 0; itrack < N_proc; ++itrack) {
1273 if (
chi2 < max_c2) {
1274 bool isCompatible =
true;
1286 if (layer_of_hits.
refHit(
m_XHitArr.At(itrack, hit_cnt, 0)).spanRows() >=
1288 isTooLargeCluster[itrack] =
true;
1289 isCompatible =
false;
1294 oneCandPassCut =
true;
1301 if (oneCandPassCut) {
1316 dprint(
"update parameters" << std::endl
1317 <<
"propagated track parameters x=" <<
m_Par[
iP].constAt(0, 0, 0)
1318 <<
" y=" <<
m_Par[
iP].constAt(0, 1, 0) << std::endl
1319 <<
" hit position x=" <<
m_msPar.constAt(0, 0, 0)
1320 <<
" y=" <<
m_msPar.constAt(0, 1, 0) << std::endl
1321 <<
" updated track parameters x=" <<
m_Par[
iC].constAt(0, 0, 0)
1322 <<
" y=" <<
m_Par[
iC].constAt(0, 1, 0));
1326 for (
int itrack = 0; itrack < N_proc; ++itrack) {
1332 if (
chi2 < max_c2) {
1333 bool isCompatible =
true;
1345 if (layer_of_hits.
refHit(
m_XHitArr.At(itrack, hit_cnt, 0)).spanRows() >=
1347 isCompatible =
false;
1351 bool hitExists =
false;
1366 nHitsAdded[itrack]++;
1367 dprint(
"chi2 cut passed, creating new candidate");
1371 const int hit_idx =
m_XHitArr.At(itrack, hit_cnt, 0);
1375 newcand.
setCharge(tmpChg(itrack, 0, 0));
1384 if (
chi2 < max_c2) {
1386 ccand[
m_CandIdx(itrack, 0, 0)].considerHitForOverlap(
1394 tmp_candidates[
m_SeedIdx(itrack, 0, 0) -
offset].emplace_back(newcand);
1405 for (
int itrack = 0; itrack < N_proc; ++itrack) {
1422 else if (
m_XWsrResult[itrack].m_in_gap ==
true && nHitsAdded[itrack] == 0) {
1426 else if (isTooLargeCluster[itrack] ==
true && nHitsAdded[itrack] == 0) {
1441 tmp_candidates[
m_SeedIdx(itrack, 0, 0) -
offset].emplace_back(newcand);
1462 for (
int it = 0; it <
NN; ++it) {
1470 dprintf(
"FindCandidatesCloneEngine max hits to process=%d\n",
maxSize);
1472 int nHitsAdded[
NN]{};
1473 bool isTooLargeCluster[
NN]{
false};
1475 for (
int hit_cnt = 0; hit_cnt <
maxSize; ++hit_cnt) {
1481 for (
int itrack = 0; itrack < N_proc; ++itrack) {
1484 mhp.addInputAt(itrack,
hit);
1485 charge_pcm[itrack] =
hit.chargePerCM();
1508 for (
int itrack = 0; itrack < N_proc; ++itrack) {
1520 dprint(
"chi2=" <<
chi2 <<
" for trkIdx=" << itrack <<
" hitIdx=" <<
m_XHitArr.At(itrack, hit_cnt, 0));
1521 if (
chi2 < max_c2) {
1522 bool isCompatible =
true;
1535 if (layer_of_hits.
refHit(
m_XHitArr.At(itrack, hit_cnt, 0)).spanRows() >=
1537 isTooLargeCluster[itrack] =
true;
1538 isCompatible =
false;
1544 bool hitExists =
false;
1559 nHitsAdded[itrack]++;
1560 const int hit_idx =
m_XHitArr.At(itrack, hit_cnt, 0);
1564 if (
chi2 < max_c2) {
1565 ccand[
m_CandIdx(itrack, 0, 0)].considerHitForOverlap(
1571 tmpList.
hitIdx = hit_idx;
1583 dprint(
" adding hit with hit_cnt=" << hit_cnt <<
" for trkIdx=" << tmpList.
trkIdx 1584 <<
" orig Seed=" <<
m_Label(itrack, 0, 0));
1593 for (
int itrack = 0; itrack < N_proc; ++itrack) {
1612 else if (
m_XWsrResult[itrack].m_in_gap ==
true && nHitsAdded[itrack] == 0) {
1616 else if (isTooLargeCluster[itrack] ==
true && nHitsAdded[itrack] == 0) {
1629 tmpList.
hitIdx = fake_hit_idx;
1641 dprint(
"adding invalid hit " << fake_hit_idx);
1681 const int iO = outputProp ?
iP :
iC;
1683 for (
int i = 0;
i < N_proc; ++
i) {
1687 m_Err[iO].copyOut(
i,
cand.errors_nc().Array());
1688 m_Par[iO].copyOut(
i,
cand.parameters_nc().Array());
1691 dprint((outputProp ?
"propagated" :
"updated")
1692 <<
" track parameters x=" <<
cand.parameters()[0] <<
" y=" <<
cand.parameters()[1]
1693 <<
" z=" <<
cand.parameters()[2] <<
" pt=" << 1. /
cand.parameters()[3] <<
" posEta=" <<
cand.posEta());
1708 for (
int i = beg;
i < end; ++
i, ++itrack) {
1735 for (
int i = beg;
i < end; ++
i, ++itrack) {
1761 const int iO = outputProp ?
iP :
iC;
1764 for (
int i = beg;
i < end; ++
i, ++itrack) {
1782 const int iO = outputProp ?
iP :
iC;
1785 for (
int i = beg;
i < end; ++
i, ++itrack) {
1800 #if defined(DEBUG_BACKWARD_FIT) || defined(DEBUG_BACKWARD_FIT_BH) 1817 float tmp_err[6] = {666, 0, 666, 0, 0, 666};
1821 const int layer = lp_iter->m_layer;
1827 for (
int i = 0;
i < N_proc; ++
i) {
1885 for (
int n = 0;
n < N_proc; ++
n) {
1892 #ifdef DEBUG_BACKWARD_FIT_BH 1894 for (
int i = 0;
i < N_proc; ++
i) {
1903 "CHIHIT %3d %10g %10g %10g %10g %10g %11.5g %11.5g %11.5g %10g %10g %10g %10g %11.5g %11.5g %11.5g %10g " 1904 "%10g %10g %10g %10g %11.5g %11.5g\n",
1918 e2s(
m_Err[ti].At(
i, 0, 0)),
1919 e2s(
m_Err[ti].At(
i, 1, 1)),
1920 e2s(
m_Err[ti].At(
i, 2, 2)),
1921 1.0f /
m_Par[ti].At(
i, 3, 0),
1925 std::atan2(
m_Par[ti].At(
i, 1, 0),
m_Par[ti].At(
i, 0, 0)),
1945 printf(
"Parameters:\n");
1946 for (
int i = 0;
i < 6; ++
i) {
1947 printf(
" %12.4g",
m_Par[corp].constAt(mslot,
i, 0));
1949 printf(
"\nError matrix\n");
1950 for (
int i = 0;
i < 6; ++
i) {
1951 for (
int j = 0;
j < 6; ++
j) {
1952 printf(
" %12.4g",
m_Err[corp].constAt(mslot,
i,
j));
1973 float tmp_err[6] = {666, 0, 666, 0, 0, 666};
1976 #if defined(DEBUG_PROP_UPDATE) 1977 const int DSLOT = 0;
1978 printf(
"bkfit entry, track in slot %d\n", DSLOT);
1983 const int layer = lp_iter.layer();
1988 #if defined(DEBUG_BACKWARD_FIT) 1989 const Hit *last_hit_ptr[
NN];
1992 no_mat_effs.setVal(0);
1995 for (
int i = 0;
i < N_proc; ++
i) {
2015 #ifdef DEBUG_BACKWARD_FIT 2016 last_hit_ptr[
i] = &
hit;
2024 #ifdef DEBUG_BACKWARD_FIT 2025 last_hit_ptr[
i] =
nullptr;
2036 if (done_count == N_proc)
2038 if (here_count == 0)
2073 #if defined(DEBUG_PROP_UPDATE) 2074 printf(
"\nbkfit at layer %d, track in slot %d -- fail=%d, had hit=%d (%g, %g, %g)\n",
2078 1 - no_mat_effs[DSLOT],
2082 printf(
"Propagated:\n");
2084 printf(
"Updated:\n");
2089 for (
int i = 0;
i < N_proc; ++
i) {
2131 #if defined(DEBUG_BACKWARD_FIT) 2134 const char beg_cur_sep =
'/';
2135 for (
int i = 0;
i < N_proc; ++
i) {
2136 if (chiDebug && last_hit_ptr[
i]) {
2139 float chi = tmp_chi2.At(
i, 0, 0);
2140 float chi_prnt = std::isfinite(chi) ? chi : -9;
2142 #if defined(MKFIT_STANDALONE) 2145 dprintf(
"BKF_OVERLAP %d %d %d %d %d %d %d " 2146 "%f%c%f %f %f%c%f %f %f %f %d %d %d %d " 2150 dprintf(
"BKF_OVERLAP %d %d %d %d %d %d " 2151 "%f%c%f %f %f%c%f %f %f %f %d %d %d " 2155 layer,
L.is_stereo(),
L.is_barrel(),
2156 bb.
pT(), beg_cur_sep, 1.0f /
m_Par[ti].At(
i, 3, 0),
2162 std::isnan(chi), std::isfinite(chi), chi > 0,
2163 #if defined(MKFIT_STANDALONE)
void(* m_compute_chi2_foo)(const MPlexLS &, const MPlexLV &, const MPlexQI &, const MPlexHS &, const MPlexHV &, MPlexQF &, MPlexLV &, MPlexQI &, const int, const PropagationFlags &, const bool)
void setOriginIndex(int oi)
float getScoreCand(const track_score_func &score_func, const Track &cand1, bool penalizeTailMissHits=false, bool inFindCandidates=false)
void addHitIdx(int hitIdx, int hitLyr, float chi2)
unsigned int maxClusterSize
void copy_in(const Track &trk, const int mslot, const int tslot)
static constexpr int MPlexHitIdxMax
const SVector6 & parameters() const
MPlex< T, D1, D2, N > hypot(const MPlex< T, D1, D2, N > &a, const MPlex< T, D1, D2, N > &b)
const IterationLayerConfig * m_iteration_layer_config
const HitOnTrack * m_HoTArr[NN]
void kalmanOperationEndcap(const int kfOp, const MPlexLS &psErr, const MPlexLV &psPar, const MPlexHS &msErr, const MPlexHV &msPar, MPlexLS &outErr, MPlexLV &outPar, MPlexQF &outChi2, const int N_proc)
void copy_out(Track &trk, const int mslot, const int tslot) const
void outputTracksAndHitIdx(std::vector< Track > &tracks, int beg, int end, bool outputProp) const
void propagateTracksToHitZ(const MPlexHV &par, const int N_proc, const PropagationFlags &pf, const MPlexQI *noMatEffPtr=nullptr)
HitOnTrack m_HoTArrs[NN][Config::nMaxTrkHits]
bin_index_t qBinChecked(float q) const
const Hit * hitArray() const
void inputTracksAndHitIdx(const std::vector< Track > &tracks, int beg, int end, bool inputProp)
void bkFitInputTracks(TrackVec &cands, int beg, int end)
for(int i=first, nt=offsets[nh];i< nt;i+=gridDim.x *blockDim.x)
Matriplex::Matriplex< float, HH, 1, NN > MPlexHV
Matriplex::Matriplex< unsigned short, 1, 1, NN > MPlexQUH
Sin< T >::type sin(const T &t)
PropagationFlags backward_fit_pflags
void addInput(const T &item)
ProdType prodType() const
void selectHitIndices(const LayerOfHits &layer_of_hits, const int N_proc, bool fill_binsearch_only=false)
void setup(const PropagationConfig &pc, const IterationConfig &ic, const IterationParams &ip, const IterationLayerConfig &ilc, const SteeringParams &sp, const std::vector< bool > *ihm, const Event *ev, int region, bool infwd)
void bkFitPropTracksToPCA(const int N_proc)
SMatrixSym66 & errors_nc()
const IterationConfig * m_iteration_config
void inputTracksAndHits(const std::vector< CombCandidate > &tracks, const LayerOfHits &layer_of_hits, const std::vector< UpdateIndices > &idxs, int beg, int end, bool inputProp)
void add_hit(const int mslot, int index, int layer)
Matriplex::Matriplex< float, LL, 1, NN > MPlexLV
float getEta(float r, float z)
void swap(Association< C > &lhs, Association< C > &rhs)
const float * posArray() const
static unsigned int maxChargePerCM()
static constexpr int kHitStopIdx
const IterationParams * m_iteration_params
void kalmanOperation(const int kfOp, const MPlexLS &psErr, const MPlexLV &psPar, const MPlexHS &msErr, const MPlexHV &msPar, MPlexLS &outErr, MPlexLV &outPar, MPlexQF &outChi2, const int N_proc)
void findCandidates(const LayerOfHits &layer_of_hits, std::vector< std::vector< TrackCand >> &tmp_candidates, const int offset, const int N_proc, const FindingFoos &fnd_foos)
static constexpr int kHitInGapIdx
track_score_func m_track_scorer
constexpr bool usePhiQArrays
const HoTNode * hotsData() const
PropagationFlags finding_inter_layer_pflags
bool isStripQCompatible(int itrack, bool isBarrel, const MPlexLS &pErr, const MPlexLV &pPar, const MPlexHS &msErr, const MPlexHV &msPar)
float getScoreStruct(const track_score_func &score_func, const IdxChi2List &cand1)
const PropagationConfig * m_prop_config
iterator make_iterator(IterationType_e type) const
int num_all_minus_one_hits(const int mslot) const
unsigned int detIDinLayer() const
bin_index_t phiBinChecked(float phi) const
void(* m_update_param_foo)(const MPlexLS &, const MPlexLV &, MPlexQI &, const MPlexHS &, const MPlexHV &, MPlexLS &, MPlexLV &, MPlexQI &, const int, const PropagationFlags &, const bool)
const float * errArray() const
constexpr Matriplex::idx_t NN
unsigned int bin_content_t
Cos< T >::type cos(const T &t)
void setup_bkfit(const PropagationConfig &pc, const SteeringParams &sp, const Event *ev)
CombCandidate * combCandidate() const
Tan< T >::type tan(const T &t)
Abs< T >::type abs(const T &t)
void propagateTracksToHitR(const MPlexHV &par, const int N_proc, const PropagationFlags &pf, const MPlexQI *noMatEffPtr=nullptr)
MPlexQI m_NTailMinusOneHits
void min_max(const MPlex< T, D1, D2, N > &a, const MPlex< T, D1, D2, N > &b, MPlex< T, D1, D2, N > &min, MPlex< T, D1, D2, N > &max)
const HitOnTrack * getHitsOnTrackArray() const
MCHitInfoVec simHitsInfo_
PropagationFlags pca_prop_pflags
bool finding_requires_propagation_to_hit_pos
constexpr float nSigmaPhi
void begin_layer(const LayerOfHits &layer_of_hits)
void propagateTracksToPCAZ(const int N_proc, const PropagationFlags &pf)
Matriplex::Matriplex< int, 1, 1, NN > MPlexQI
TrackCand * m_TrkCand[NN]
void selectHitIndicesV2(const LayerOfHits &layer_of_hits, const int N_proc)
std::vector< Track > TrackVec
SimLabelFromHits simLabelForCurrentSeed(int i) const
Matriplex::Matriplex< float, 1, 1, NN > MPlexQF
WithinSensitiveRegion_e m_wsr
void pack(TMerr &err, TMpar &par)
void bkFitFitTracks(const EventOfHits &eventofhits, const SteeringParams &st_par, const int N_proc, bool chiDebug=false)
const SteeringParams * m_steering_params
static const FindingFoos & get_finding_foos(bool is_barrel)
void updateWithLoadedHit(int N_proc, const FindingFoos &fnd_foos)
std::vector< LayerControl > m_layer_plan
bool passStripChargePCMfromTrack(int itrack, bool isBarrel, unsigned int pcm, unsigned int pcmMin, const MPlexLV &pPar, const MPlexHS &msErr)
float getPhi(float x, float y)
const Track & currentSeed(int i) const
Matriplex::MatriplexSym< float, HH, NN > MPlexHS
static constexpr int kHitMaxClusterIdx
void bkFitOutputTracks(TrackVec &cands, int beg, int end, bool outputProp)
void bkFitFitTracksBH(const EventOfHits &eventofhits, const SteeringParams &st_par, const int N_proc, bool chiDebug=false)
const std::vector< float > & get_window_params(bool forward, bool fallback_to_other) const
HitOnTrack hot(int i) const
void copyOutParErr(std::vector< CombCandidate > &seed_cand_vec, int N_proc, bool outputProp) const
int num_inside_minus_one_hits(const int mslot) const
void findCandidatesCloneEngine(const LayerOfHits &layer_of_hits, CandCloner &cloner, const int offset, const int N_proc, const FindingFoos &fnd_foos)
Matriplex::MatriplexSym< float, LL, NN > MPlexLS
const std::vector< bool > * m_iteration_hit_mask
PropagationFlags finding_intra_layer_pflags
void add_cand(int idx, const IdxChi2List &cand_info)
float getHitSelDynamicChi2Cut(const int itrk, const int ipar)
MPF fast_atan2(const MPF &y, const MPF &x)
static constexpr int kHitMissIdx
const HoTNode * m_HoTNodeArr[NN]
unsigned short bin_index_t
WSR_Result m_XWsrResult[NN]
void getHitSelDynamicWindows(const float invpt, const float theta, float &min_dq, float &max_dq, float &min_dphi, float &max_dphi)
Geom::Theta< T > theta() const
static constexpr int kHitEdgeIdx
CombCandidate & combCandWithOriginalIndex(int idx)
static unsigned int minChargePerCM()
SVector6 & parameters_nc()
const Hit & refHit(int i) const
void print_par_err(int corp, int mslot) const
void addBestHit(const LayerOfHits &layer_of_hits, const int N_proc, const FindingFoos &fnd_foos)
constexpr bool isFinite(float x)