17     : base_class(ty, na, pa) {
 
   18     declareProperty(
"UseCosmicsSettings", 
m_isCosmics = 
false, 
"Pick up settings for cosmics");
 
   20                     "Perform matching for segments in a small/large overlap");
 
   22                     "Perform matching for segments in regions without field");
 
   23     declareProperty(
"DoCurvedMatch", 
m_doCurvedMatch = 
true, 
"Perform matching for segments in a field regions");
 
   24     declareProperty(
"doThetaMatching", 
m_thetaMatch = 
false, 
"Pre-matching in theta");
 
   25     declareProperty(
"doPhiMatching", 
m_phiMatch = 
false, 
"Pre-matching in phi");
 
   29         "Cut on the angular difference between the best phi and the one consistent with the chamber bounds");
 
   32         "Cut on the angular difference between the best phi and the one consistent with the chamber bounds");
 
   34                     "Cut on the distance of recalculated position to the tube edge");
 
   36                     "Cut on the segment position residual after recalculation of the paramters");
 
   38                     "Cut on the average pull of the phi hits with the new segment parameters");
 
   41                     "Cut on the angular difference between the extrapolated segment angle and reference");
 
   43                     "Cut on the distance of extrapolated segment position and reference");
 
   45                     "If the two segments are further apart than this distance, they are considered to not match");
 
   48                     "Accept only segments that are in the same sector for tight matching");
 
   50                     "Use tight selection for busy event to suppress combinatorics and improve CPU");
 
   53                     "Cut on sumDeltaYZ, segments in BI and BM, small phi sec");
 
   55                     "Cut on sumDeltaYZ, segments in BI and BO, small phi sec");
 
   57                     "Cut on sumDeltaYZ, segments in BM and BO, small phi sec");
 
   59                     "Cut on sumDeltaYZ, segments in EI and EM, small phi sec");
 
   61                     "Cut on sumDeltaYZ, segments in EI and EO, small phi sec");
 
   63                     "Cut on sumDeltaYZ, segments in EM and EO, small phi sec");
 
   65                     "Cut on sumDeltaYZ, segments in BI and BM, large phi sec");
 
   67                     "Cut on sumDeltaYZ, segments in BI and BO, large phi sec");
 
   69                     "Cut on sumDeltaYZ, segments in BM and BO, large phi sec");
 
   71                     "Cut on sumDeltaYZ, segments in EI and EM, large phi sec");
 
   73                     "Cut on sumDeltaYZ, segments in EI and EO, large phi sec");
 
   75                     "Cut on sumDeltaYZ, segments in EM and EO, large phi sec");
 
   91     return StatusCode::SUCCESS;
 
   97     double goodOverlapMatchFraction =
 
  102     double goodStraightLineMatchFraction =
 
  106                                                 << goodStraightLineMatchFraction);
 
  108     double goodCurvedMatchFraction =
 
  116     return StatusCode::SUCCESS;
 
  126     if (chid1 == chid2) 
return false;
 
  135         if (stIndex1 == stIndex2) {
 
  145                     && ( std::abs(phi1 - phi2) == 1 || (phi1 == 1 && phi2 == 16)
 
  146                         || (phi1 == 16 && phi2 == 1)))
 
  155         if (stIndex1 == stIndex2) 
return false;
 
  162     if (stIndex1 == stIndex2) 
return false;
 
  239     if (!
result.goodMatch()) {
 
  249                                                       << 
result.phiResult.deltaYZ);
 
  256         ATH_MSG_DEBUG(
" failed phi hit pull cut: seg1 " << 
result.averagePhiHitPullSegment1 << 
"  seg2 " 
  257                                                         << 
result.averagePhiHitPullSegment2);
 
  271         ATH_MSG_DEBUG(
" failed position residual cut: seg1 " << 
result.segmentResult1.positionResidual << 
"  seg2 " 
  272                                                              << 
result.segmentResult2.positionResidual);
 
  291     if (stIndex1 == stIndex2) 
return true;
 
  310     if (phi1 != phi2) 
return true;
 
  316     return isSmallChamber1 != isSmallChamber2;
 
  347                   << 
result.phiSector_b << 
" " << 
result.deltaTheta_a << 
" " << 
result.deltaTheta_b << 
" " 
  353                                 << 
" " << 
result.phiSector_b << 
" thetas " << 
result.deltaTheta_a << 
" " 
  354                                 << 
result.deltaTheta_b << 
" thetaSum " << 
result.deltaTheta << 
" tight cuts " 
  358     if (
result.angleAB > 1.0) 
return false;
 
  363         if (isCSC_a || isCSC_b) {
 
  368             if ((isCSC_a && !isEndcap_b) || (isCSC_b && !isEndcap_a)) 
return false;
 
  372         else if (isBEE_a || isBEE_b)
 
  375             return result.deltaTheta <= 0.300;
 
  378         else if (isEndcap_a != isEndcap_b)
 
  381             return result.deltaTheta <= 0.300;
 
  387             if (
result.deltaTheta > 0.300) {
 
  398             if (
result.phiSector_a % 2 == 0) {
 
  400             } 
else if (
result.phiSector_a % 2 == 1) {
 
  408             if (
result.phiSector_a % 2 == 0) {
 
  410             } 
else if (
result.phiSector_a % 2 == 1) {
 
  419             if (
result.phiSector_a % 2 == 0) {
 
  421             } 
else if (
result.phiSector_a % 2 == 1) {
 
  429             if (
result.phiSector_a % 2 == 0) {
 
  436             } 
else if (
result.phiSector_a % 2 == 1) {
 
  449             if (
result.phiSector_a % 2 == 0) {
 
  456             } 
else if (
result.phiSector_a % 2 == 1) {
 
  470             if (
result.phiSector_a % 2 == 0) {
 
  472             } 
else if (
result.phiSector_a % 2 == 1) {
 
  484         ATH_MSG_VERBOSE(
" rejection pair as in different sector and using tight cuts");
 
  487     if (isCSC_a || isCSC_b) {
 
  491             if (
result.deltaTheta > 0.100) {
 
  494                 if ((isCSC_a && !isEndcap_b) || (isCSC_b && !isEndcap_a)) 
return false;
 
  502     else if (isBEE_a || isBEE_b)
 
  504         return result.deltaTheta <= 0.200;
 
  509         return result.deltaTheta <= 0.150;
 
  512     else if (isEndcap_a != isEndcap_b)
 
  514         return result.deltaTheta <= 0.150;
 
  519         if (
result.phiSector_a % 2 == 0) {
 
  521         } 
else if (
result.phiSector_a % 2 == 1) {
 
  528         if (
result.phiSector_a % 2 == 0) {
 
  530         } 
else if (
result.phiSector_a % 2 == 1) {
 
  537         if (
result.phiSector_a % 2 == 0) {
 
  539         } 
else if (
result.phiSector_a % 2 == 1) {
 
  547         if (
result.phiSector_a % 2 == 0) {
 
  553         } 
else if (
result.phiSector_a % 2 == 1) {
 
  564         if (
result.phiSector_a % 2 == 0) {
 
  570         } 
else if (
result.phiSector_a % 2 == 1) {
 
  581         if (
result.phiSector_a % 2 == 0) {
 
  583         } 
else if (
result.phiSector_a % 2 == 1) {
 
  593                                           const bool& useTightCuts)
 const 
  609                   << 
" deltaPhidir " << 
result.deltaPhidir << 
" phiposerr_a " << 
result.phiposerr_a << 
" phiposerr_b " 
  610                   << 
result.phiposerr_b << 
" phidirerr_a " << 
result.phidirerr_a << 
" phidirerr_b " 
  611                   << 
result.phidirerr_b << 
" shorttube_a " << 
result.shorttube_a << 
" shorttube_b " 
  616         && ((
result.phiSector_a != 16 && 
result.phiSector_b != 1)
 
  617             && (
result.phiSector_a != 1 && 
result.phiSector_b != 16))
 
  625             if (
result.phiposerr_a < 10001.000 && 
result.phiposerr_b < 10001.000) {
 
  627                 if (!isEndcap_a && !isEndcap_b) {
 
  628                     return result.deltaPhipos <= 0.1;
 
  630                 if (isEndcap_a && isEndcap_b) {
 
  632                     if (
result.phiSector_a % 2 == 0) {
 
  633                         return result.deltaPhipos <= 0.1;
 
  636                     if (
result.phiSector_a % 2 == 1) {
 
  637                         return result.deltaPhipos <= 0.2;
 
  644             if (
result.phiposerr_a < 10001.000 && 
result.phiposerr_b < 10001.000) {
 
  645                 if (!isEndcap_a && !isEndcap_b) {
 
  646                     return result.deltaPhipos <= 0.1;
 
  648                 if (isEndcap_a && isEndcap_b) {
 
  649                     return result.deltaPhipos <= 0.2;
 
  658             if (
result.phiposerr_a < 10001.000) {
 
  660                     return result.shorttube_a <= 800;
 
  664                     return result.shorttube_a <= 3500 || 
result.shorttube_a == 99999.;
 
  667                     return result.shorttube_a <= 3500 || 
result.shorttube_a == 99999.;
 
  670                     return result.shorttube_a <= 800;
 
  674             if (
result.phiposerr_b < 10001.000) {
 
  676                     return result.shorttube_b <= 800;
 
  679                     return result.shorttube_b <= 800;
 
  682                     return result.shorttube_b <= 800;
 
  685                     return result.shorttube_b <= 1400;
 
  696         if (
result.phiposerr_a < 10001.000 && 
result.phiposerr_b < 10001.000) {
 
  697             if (!isEndcap_a && !isEndcap_b) {
 
  698                 return result.deltaPhipos <= 0.1;
 
  700             if (isEndcap_a && isEndcap_b) {
 
  702                 if (
result.phiSector_a % 2 == 0) {
 
  703                     return result.deltaPhipos <= 0.08;
 
  706                 if (
result.phiSector_a % 2 == 1) {
 
  707                     return result.deltaPhipos <= 0.1;
 
  715         if (
result.phiposerr_a < 10001.000 && 
result.phiposerr_b < 10001.000) {
 
  716             if (!isEndcap_a && !isEndcap_b) {
 
  717                 return result.deltaPhipos <= 0.05;
 
  719             if (isEndcap_a && isEndcap_b) {
 
  720                 return result.deltaPhipos <= 0.1;
 
  726         if (
result.phiposerr_a < 10001.000) {
 
  728                 return result.shorttube_a <= 600;
 
  731                 return result.shorttube_a <= 3500 || 
result.shorttube_a == 99999.;
 
  734                 return result.shorttube_a <= 3500 || 
result.shorttube_a == 99999.;
 
  737                 return result.shorttube_a <= 500;
 
  741         if (
result.phiposerr_b < 10001.000) {
 
  743                 return result.shorttube_b <= 600;
 
  746                 return result.shorttube_b <= 700;
 
  749                 return result.shorttube_b <= 700;
 
  752                 return result.shorttube_b <= 700;
 
  763                                                   bool useTightCuts)
 const 
  770     if (chid1 == chid2) 
return false;
 
  774     if (stIndex1 == stIndex2) 
return false;
 
  784     if (!segInner || !segOuter) {
 
  793     double r_expected{0.}, theta_expected{0.}, rhoInv{0.};
 
  794     simpleEndcapExtrapolate(pos1.x(), pos1.y(), pos1.z(), dir1.theta(), pos2.z(), r_expected, theta_expected, rhoInv);
 
  796     if (rhoInv < 0) rhoInv *= -1.;
 
  797     double dr     = pos2.perp() - r_expected;
 
  798     double dtheta = dir2.theta() - theta_expected;
 
  822                                      << 
"              " << 
m_printer->print(seg2) << std::endl
 
  823                                      << 
" dr " << 
dr << 
" cut " << drCut << 
" dtheta " << dtheta << 
" cut " << dthetaCut
 
  824                                      << 
" rhoInv " << 1e6 * rhoInv);
 
  826     if (std::abs(
dr) > drCut) 
return false;
 
  827     if (std::abs(dtheta) > dthetaCut) 
return false;
 
  834                                                  double theta_segment, 
double z_extrapolated, 
double& r_expected,
 
  835                                                  double& theta_expected, 
double& rhoInv)
 const 
  848     double z_start = 7000.;
 
  849     double z_end   = 12000.;
 
  851     if (z_extrapolated < 0) z_start = -z_start;
 
  854     double r_segment = std::hypot(x_segment , y_segment);
 
  856     if (std::abs(z_extrapolated) > std::abs(z_segment)) {
 
  857         ATH_MSG_WARNING(
" extrapolate outwards is not implemented for z " << z_extrapolated);
 
  862     if (std::abs(z_segment) < std::abs(
z_end)) {
 
  863         ATH_MSG_WARNING(
" segment before end of Toroid: SL extrapolation is used implemented " << z_segment);
 
  867     const double tan_seg = 
std::tan(theta_segment);
 
  869     double r_end = r_segment + (
z_end - z_segment) * tan_seg;
 
  872     rhoInv          = (r_end - 
z_end * tan_seg) / zgeo;
 
  873     double tantheta = tan_seg - 2 * (
z_end - z_start) * rhoInv;
 
  874     r_expected      = z_extrapolated * tantheta + (z_extrapolated - z_start) * (z_extrapolated - z_start) * rhoInv;
 
  878     double r_SL    = r_segment + (z_extrapolated - z_segment) * tan_seg;
 
  879     r_expected     = r_expected + 0.3 * (r_expected - r_SL);
 
  880     theta_expected = 
std::atan(tantheta + 2 * (z_extrapolated - z_start) * rhoInv);
 
  882     if (tan_seg < 0 && theta_expected < 0) theta_expected += 
M_PI;
 
  883     if (tan_seg > 0 && theta_expected < 0) theta_expected = -theta_expected;