20 m_minDeltaRadius(10.0),
38 const double radLen = 0.036;
40 const double ptCoeff = 0.29997*1.9972/2.0;
67 for(std::vector<TrigSiSpacePointBase>::const_iterator
it = vSP.begin();
it != vSP.end();++
it) {
68 int layerId = (*it).layer();
73 bool updateTauRange =
false;
88 updateTauRange = LUT.
getValidRange(cluster_width, minTau, maxTau);
97 else if (phiIdx < 0) {
137 for(
int layerI=1;layerI<nLayers;layerI++) {
140 if(
S.m_nSP==0)
continue;
146 for(
auto spm :
S.m_phiSlices[phiI]) {
148 float zm = spm->m_pSP->z();
149 float rm = spm->m_pSP->r();
157 for(
int layerJ=0;layerJ<nLayers;layerJ++) {
162 if(checkPSS)
continue;
164 if((!isSct) && (!isPixel2)) {
173 const std::vector<const INDEXED_SP*>& spVec =
m_pStore->
m_layers[layerJ].m_phiThreeSlices.at(phiI);
175 if(spVec.empty())
continue;
193 std::vector<TrigInDetTriplet> tripletVec;
213 if(vZv.empty())
return;
218 float roiZMinus = -225;
219 float roiZPlus = 225;
224 for(
int layerI=1;layerI<nLayers;layerI++) {
227 if(
S.m_nSP==0)
continue;
236 for(
auto spm :
S.m_phiSlices[phiI]) {
238 float zm = spm->m_pSP->z();
239 float rm = spm->m_pSP->r();
242 float maxTau = 100.0;
249 std::vector<TrigInDetTriplet> tripletVec;
251 for(
const auto zVertex : vZv) {
261 for(
int layerJ=0;layerJ<nLayers;layerJ++) {
266 if(isSct && isPixel2)
continue;
267 if((!isSct) && (!isPixel2))
continue;
275 const std::vector<const INDEXED_SP*>& spVec =
m_pStore->
m_layers[layerJ].m_phiThreeSlices.at(phiI);
277 if(spVec.empty())
continue;
301 const float deltaRefCoord = 5.0;
303 if(layerJ==layerI)
return false;
315 if((typeI!=0) && (typeJ!=0) && refCoordI*refCoordJ<0.0)
return false;
348 if(maxB<=rm)
return false;
355 float zMax = (zm*maxB-rm*refCoordJ)/(maxB-rm);
358 float zMin = (zm*minB-rm*refCoordJ)/(minB-rm);
374 if(minB == rm)
return false;
375 float zMax = (zm*minB-rm*refCoordJ)/(minB-rm);
378 float zMin = (zm*maxB-rm*refCoordJ)/(maxB-rm);
393 float zMin = (zm*maxB-rm*refCoordJ)/(maxB-rm);
396 float zMax = (zm*minB-rm*refCoordJ)/(minB-rm);
410 if(minB == rm)
return false;
411 float zMin = (zm*minB-rm*refCoordJ)/(minB-rm);
414 float zMax = (zm*maxB-rm*refCoordJ)/(maxB-rm);
428 if(maxBoundJ<m_minCoord || minBoundJ>
m_maxCoord)
return false;
439 float minSpCoord = (
isBarrel) ? (*spVec.begin())->m_pSP->z() : (*spVec.begin())->m_pSP->r();
440 float maxSpCoord = (
isBarrel) ? (*spVec.rbegin())->m_pSP->z() : (*spVec.rbegin())->m_pSP->r();
443 float tmp = minSpCoord;minSpCoord = maxSpCoord;maxSpCoord =
tmp;
451 std::vector<const INDEXED_SP*>::const_iterator
it1 = spVec.end();
452 std::vector<const INDEXED_SP*>::const_iterator it2 = spVec.end();
471 delta.first =
it1;delta.second = it2;
483 float rm = spm->
m_pSP->
r();
484 float zm = spm->
m_pSP->
z();
486 float dZ = refCoord-zm;
487 float dR_i =
isBarrel ? 1.0/(refCoord-rm) : 1.0;
491 for(std::vector<const INDEXED_SP*>::const_iterator spIt=delta.first; spIt!=delta.second; ++spIt) {
493 float zsp = (*spIt)->m_pSP->z();
494 float rsp = (*spIt)->m_pSP->r();
501 if(isPixel && !(*spIt)->m_pSP->isPixel()) {
510 if (
dr<0 && checkPSS)
continue;
514 float ftau = std::fabs(tau);
515 if (ftau > 7.41)
continue;
517 if(isPixel && SeedML > 0) {
522 float z0 = zm - rm*tau;
530 if(
isBarrel && (*spIt)->m_pSP->isPixel()) {
531 if(SeedML == 3 || SeedML == 4) {
532 if(ftau <
m_minTau[(*spIt)->m_idx] || ftau >
m_maxTau[(*spIt)->m_idx])
continue;
540 if(
isBarrel && (*spIt)->m_pSP->isPixel()) {
541 if(SeedML == 2 || SeedML == 4) {
542 if(ftau <
m_minTau[(*spIt)->m_idx] || ftau >
m_maxTau[(*spIt)->m_idx])
continue;
559 float rm = spm->
m_pSP->
r();
560 float zm = spm->
m_pSP->
z();
564 for(std::vector<const INDEXED_SP*>::const_iterator spIt=delta.first; spIt!=delta.second; ++spIt) {
566 float rsp = (*spIt)->m_pSP->r();
567 float zsp = (*spIt)->m_pSP->z();
575 if (
dr<0 && checkPSS)
continue;
579 float ftau = std::fabs(tau);
581 if (ftau > 7.41)
continue;
584 if(ftau < minTau || ftau > maxTau)
continue;
588 if((*spIt)->m_pSP->isPixel()) {
589 if(SeedML == 3 || SeedML == 4) {
590 if(ftau <
m_minTau[(*spIt)->m_idx] || ftau >
m_maxTau[(*spIt)->m_idx])
continue;
596 if((*spIt)->m_pSP->isPixel()) {
597 if(SeedML == 2 || SeedML == 4) {
598 if(ftau <
m_minTau[(*spIt)->m_idx] || ftau >
m_maxTau[(*spIt)->m_idx])
continue;
613 if(nInner==0 || nOuter==0)
return;
621 int nSP = nInner + nOuter;
623 const double pS_r = pS->
r();
624 const double pS_x = pS->
x();
625 const double pS_y = pS->
y();
626 const double pS_dr = pS->
dr();
627 const double pS_dz = pS->
dz();
628 const double cosA = pS_x/pS_r;
629 const double sinA = pS_y/pS_r;
630 const double covZ = pS_dz*pS_dz;
631 const double covR = pS_dr*pS_dr;
632 const bool isPixel = pS->
isPixel();
640 const double dx = pSP->
x() - pS_x;
641 const double dy = pSP->
y() - pS_y;
642 const double R2inv = 1.0/(
dx*
dx+
dy*
dy);
643 const double Rinv = std::sqrt(R2inv);
644 const double xn =
dx*cosA +
dy*sinA;
645 const double yn =-
dx*sinA +
dy*cosA;
646 const double dz = pSP->
z() - pS->
z();
647 const double t = Rinv*dz;
657 const double covZP = pSP->
dz()*pSP->
dz();
658 const double covRP = pSP->
dr()*pSP->
dr();
664 for(
int k=0;
k<nOuter;
k++,
idx++) {
669 const double dx = pSP->
x() - pS_x;
670 const double dy = pSP->
y() - pS_y;
671 const double R2inv = 1.0/(
dx*
dx+
dy*
dy);
672 const double Rinv = std::sqrt(R2inv);
673 const double xn =
dx*cosA +
dy*sinA;
674 const double yn =-
dx*sinA +
dy*cosA;
675 const double dz = -pSP->
z() + pS->
z();
676 const double t = Rinv*dz;
686 const double covZP = pSP->
dz()*pSP->
dz();
687 const double covRP = pSP->
dr()*pSP->
dr();
695 for(
int innIdx=0;innIdx<nInner;innIdx++) {
699 const double r_inn =
m_SoA.
m_r[innIdx];
700 const double t_inn =
m_SoA.
m_t[innIdx];
701 const double v_inn =
m_SoA.
m_v[innIdx];
702 const double u_inn =
m_SoA.
m_u[innIdx];
704 const double dCov =
m_CovMS*(1+t_inn*t_inn);
707 for(
int outIdx=nInner;outIdx<nSP;outIdx++) {
710 const double t_out =
m_SoA.
m_t[outIdx];
714 const double dt2 =
std::pow((t_inn - t_out), 2)*(1.0/9.0);
717 double covdt = (t_inn*t_out*covR + covZ);
721 if(dt2 > covdt+dCov)
continue;
725 const double du =
m_SoA.
m_u[outIdx] - u_inn;
726 if(du==0.0)
continue;
727 const double A = (
m_SoA.
m_v[outIdx] - v_inn)/du;
728 const double B = v_inn -
A*u_inn;
729 const double R_squ = (1 +
A*
A)/(
B*
B);
736 if(dt2 > covdt+
frac*dCov)
continue;
740 const double fabs_d0 = std::fabs(pS_r*(
B*pS_r -
A));
751 const double uc = 2*
B*pS_r -
A;
752 const double phi0 = atan2(sinA - uc*cosA, cosA + uc*sinA);
770 return A.Q() > B.Q();
775 if( Q >= (*it).Q()) {
789 if(nInner==0 || nOuter==0)
return;
795 int nSP = nInner + nOuter;
833 for(
int k=0;
k<nL;
k++) {
844 double min_el=1000.0;
846 for(
int k=0;
k<nL;
k++) {
847 if(nleft[
k]==0)
continue;
857 int i_min = iter[k_min];
869 iter[k_min] +=
dirs[k_min];
871 if(nleft[k_min]==0) {
878 const double pS_r = pS->
r();
879 const double pS_x = pS->
x();
880 const double pS_y = pS->
y();
882 const double pS_dr = pS->
dr();
883 const double pS_dz = pS->
dz();
884 const double cosA = pS_x/pS_r;
885 const double sinA = pS_y/pS_r;
886 const double covZ = pS_dz*pS_dz;
887 const double covR = pS_dr*pS_dr;
888 const bool isPixel = pS->
isPixel();
896 const double dx = pSP->
x() - pS_x;
897 const double dy = pSP->
y() - pS_y;
898 const double R2inv = 1.0/(
dx*
dx+
dy*
dy);
899 const double Rinv = std::sqrt(R2inv);
900 const double xn =
dx*cosA +
dy*sinA;
901 const double yn =-
dx*sinA +
dy*cosA;
904 const double t = Rinv*dz;
914 const double covZP = pSP->
dz()*pSP->
dz();
915 const double covRP = pSP->
dr()*pSP->
dr();
933 const double r_inn =
m_SoA.
m_r[iter1];
934 const double t_inn =
m_SoA.
m_t[iter1];
935 const double v_inn =
m_SoA.
m_v[iter1];
936 const double u_inn =
m_SoA.
m_u[iter1];
938 const double dCov =
m_CovMS*(1+t_inn*t_inn);
940 for(
int iter2=iter1+1;iter2<nSP;iter2++) {
947 const double t_out =
m_SoA.
m_t[iter2];
949 const double dt2 =
std::pow((t_inn - t_out), 2)*(1.0/9.0);
951 double covdt = (t_inn*t_out*covR + covZ);
955 if(dt2 > covdt+dCov)
continue;
959 const double du =
m_SoA.
m_u[iter2] - u_inn;
960 if(du==0.0)
continue;
962 const double A = (
m_SoA.
m_v[iter2] - v_inn)/du;
964 const double B = (1-type1)*(v_inn -
A*u_inn) + type1*(
m_SoA.
m_v[iter2] -
A*
m_SoA.
m_u[iter2]);
965 const double R_squ = (1 +
A*
A)/(
B*
B);
972 if(dt2 > covdt+
frac*dCov)
continue;
975 const double B_pS_r =
B*pS_r;
976 const double fabs_d0 = std::fabs(pS_r*(B_pS_r -
A));
983 if (isSCT && isPixel) {
991 double uc = 2*B_pS_r -
A;
993 const double phi0 = atan2(sinA - uc*cosA, cosA + uc*sinA);
1002 const double Q = fabs_d0*fabs_d0;
1007 return A.Q() > B.Q();
1012 if( Q >= (*it).Q()) {
1022 output.emplace_back(*pSPI, *pS, *pSPO, Q);
1037 ProtoSeed(
const ProtoSeed& ps) : m_sp(ps.m_sp), m_curv(ps.m_curv), m_Q(ps.m_Q), m_confirmed(ps.m_confirmed) {};
1043 if(nInner==0 || nOuter==0)
return;
1049 int nSP = nInner + nOuter;
1051 const double pS_r = pS->
r();
1052 const double pS_x = pS->
x();
1053 const double pS_y = pS->
y();
1054 const double pS_dr = pS->
dr();
1055 const double pS_dz = pS->
dz();
1056 const double cosA = pS_x/pS_r;
1057 const double sinA = pS_y/pS_r;
1058 const double covZ = pS_dz*pS_dz;
1059 const double covR = pS_dr*pS_dr;
1060 const bool isPixel = pS->
isPixel();
1072 const double dx = pSP->
x() - pS_x;
1073 const double dy = pSP->
y() - pS_y;
1074 const double R2inv = 1.0/(
dx*
dx+
dy*
dy);
1075 const double Rinv = std::sqrt(R2inv);
1076 const double xn =
dx*cosA +
dy*sinA;
1077 const double yn =-
dx*sinA +
dy*cosA;
1078 const double dz = pSP->
z() - pS->
z();
1079 const double t = Rinv*dz;
1089 const double covZP = pSP->
dz()*pSP->
dz();
1090 const double covRP = pSP->
dr()*pSP->
dr();
1096 for(
int k=0;
k<nOuter;
k++,
idx++) {
1101 const double dx = pSP->
x() - pS_x;
1102 const double dy = pSP->
y() - pS_y;
1103 const double R2inv = 1.0/(
dx*
dx+
dy*
dy);
1104 const double Rinv = std::sqrt(R2inv);
1105 const double xn =
dx*cosA +
dy*sinA;
1106 const double yn =-
dx*sinA +
dy*cosA;
1107 const double dz = -pSP->
z() + pS->
z();
1108 const double t = Rinv*dz;
1118 const double covZP = pSP->
dz()*pSP->
dz();
1119 const double covRP = pSP->
dr()*pSP->
dr();
1127 for(
int innIdx=0;innIdx<nInner;innIdx++) {
1131 const double r_inn =
m_SoA.
m_r[innIdx];
1132 const double t_inn =
m_SoA.
m_t[innIdx];
1133 const double v_inn =
m_SoA.
m_v[innIdx];
1134 const double u_inn =
m_SoA.
m_u[innIdx];
1136 const double dCov =
m_CovMS*(1+t_inn*t_inn);
1138 std::vector<ProtoSeed> vPro;
1141 for(
int outIdx=nInner;outIdx<nSP;outIdx++) {
1144 const double t_out =
m_SoA.
m_t[outIdx];
1146 const double dt2 =
std::pow((t_inn - t_out), 2)*(1.0/9.0);
1149 double covdt = (t_inn*t_out*covR + covZ);
1150 covdt *= 2*r_inn*
m_SoA.
m_r[outIdx];
1153 if(dt2 > covdt+dCov)
continue;
1157 const double du =
m_SoA.
m_u[outIdx] - u_inn;
1158 if(du==0.0)
continue;
1159 const double A = (
m_SoA.
m_v[outIdx] - v_inn)/du;
1160 const double B = v_inn -
A*u_inn;
1161 const double R_squ = (1 +
A*
A)/(
B*
B);
1169 if(dt2 > covdt+
frac*dCov)
continue;
1173 const double fabs_d0 = std::fabs(pS_r*(
B*pS_r -
A));
1188 if (isOuterPixel && (bestQ < Q))
continue;
1194 const double uc = 2*
B*pS_r -
A;
1195 const double phi0 = atan2(sinA - uc*cosA, cosA + uc*sinA);
1204 const double Curv =
B/std::sqrt(1+
A*
A);
1207 bool isConfirmed =
false;
1209 for(
auto& ps : vPro) {
1210 double diffC = 1 - Curv/ps.m_curv;
1212 ps.m_confirmed =
true;
1221 vPro.emplace_back(ProtoSeed(
m_SoA.
m_spo[outIdx-nInner], Curv, Q, isConfirmed));
1225 for(
const auto& ps : vPro) {
1226 if(!ps.m_confirmed)
continue;
1235 return A.Q() < B.Q();
1238 double QL =
output.back().Q();
1258 float newQ = (*it).Q();
1262 newQ += (*it).s1().isSCT() ? 1000.0 : 10000.0;
1273 return A.Q() < B.Q();