18 limit_angle_2pi(
double x)
28 if (
x >= +1.0)
return 0.0;
29 if (
x <= -1.0)
return M_PI;
42 declareInterface<IMuonSegmentPairMatchingTool>(
this);
54 return StatusCode::SUCCESS;
71 if (chid1 == chid2)
return result;
72 if (station1 == station2)
return result;
88 if (station1 < station2) {
112 result.phiSector_a = phiSector_a;
113 result.phiSector_b = phiSector_b;
124 double sizeA = dir_a.mag();
125 double sizeB = dir_b.mag();
126 double cosAB = dir_a.dot(dir_b) / (sizeA * sizeB);
127 double angleAB = robust_acos(cosAB);
130 double sizeC = vecAB.mag();
131 double cosAC = dir_a.dot(vecAB) / (sizeA * sizeC);
132 double angleAC = robust_acos(cosAC);
135 double cosBC = dir_b.dot(vecAB) / (sizeB * sizeC);
136 double angleBC = robust_acos(cosBC);
139 if (angleAB >
M_PI / 2.) angleAB = fabs(angleAB -
M_PI);
140 if (angleAC >
M_PI / 2.) angleAC = fabs(angleAC -
M_PI);
141 if (angleBC >
M_PI / 2.) angleBC = fabs(angleBC -
M_PI);
155 double deltaTheta_a = limit_angle_2pi(dirTheta_a - dirPred_a.
angleYZ());
156 double deltaTheta_b = limit_angle_2pi(dirTheta_b - dirPred_b.
angleYZ());
160 if (std::abs(deltaTheta_a) > 0.5 *
M_PI && std::abs(deltaTheta_b) > 0.5 *
M_PI) {
164 deltaTheta_a = limit_angle_2pi(dirTheta_a - dirPred_a.
angleYZ());
165 deltaTheta_b = limit_angle_2pi(dirTheta_b - dirPred_b.
angleYZ());
170 bool flipped =
false;
173 double xAxisDotProduct = trf_a(0, 0) * trf_b(0, 0) + trf_a(1, 0) * trf_b(1, 0) + trf_a(2, 0) * trf_b(2, 0);
174 if (xAxisDotProduct < 0.0) flipped =
true;
176 double deltaTheta = 0.0;
178 deltaTheta = std::abs(limit_angle_2pi(deltaTheta_a - deltaTheta_b));
180 deltaTheta = std::abs(limit_angle_2pi(deltaTheta_a + deltaTheta_b));
183 result.deltaTheta_a = deltaTheta_a;
184 result.deltaTheta_b = deltaTheta_b;
185 result.deltaTheta = deltaTheta;
192 bool ContainPhiHits =
false;
193 std::vector<const Trk::MeasurementBase*>::const_iterator hit = seg_a.
containedMeasurements().begin();
194 std::vector<const Trk::MeasurementBase*>::const_iterator hit_end = seg_a.
containedMeasurements().end();
195 for (; hit != hit_end; ++hit) {
204 if (!
id.is_valid())
continue;
206 ContainPhiHits =
true;
211 if (ContainPhiHits) {
215 result.phiposerr_a = 99999.;
216 result.phidirerr_a = 99999.;
220 ContainPhiHits =
false;
223 for (; hit != hit_end; ++hit) {
232 if (!
id.is_valid())
continue;
234 ContainPhiHits =
true;
239 if (ContainPhiHits) {
243 result.phiposerr_b = 99999.;
244 result.phidirerr_b = 99999.;
247 result.shorttube_a = 99999.;
251 double shorttube_lx_a = stseg1.first.x();
252 double shorttube_ly_a = stseg1.first.y();
253 double shorttube_rx_a = stseg1.second.x();
254 double shorttube_ry_a = stseg1.second.y();
262 double dist_la = sqrt(dist_x_la * dist_x_la + dist_y_la * dist_y_la);
263 double dist_ra = sqrt(dist_x_ra * dist_x_ra + dist_y_ra * dist_y_ra);
265 if (dist_la >= dist_ra)
266 result.shorttube_a = dist_ra;
268 result.shorttube_a = dist_la;
271 result.shorttube_b = 99999.;
274 double shorttube_lx_b = stseg2.first.x();
275 double shorttube_ly_b = stseg2.first.y();
276 double shorttube_rx_b = stseg2.second.x();
277 double shorttube_ry_b = stseg2.second.y();
285 double dist_lb = sqrt(dist_x_lb * dist_x_lb + dist_y_lb * dist_y_lb);
286 double dist_rb = sqrt(dist_x_rb * dist_x_rb + dist_y_rb * dist_y_rb);
288 if (dist_lb >= dist_rb)
289 result.shorttube_b = dist_rb;
291 result.shorttube_b = dist_lb;
298 std::pair<Amg::Vector3D, Amg::Vector3D>
302 double storedLength = 999999;
307 std::vector<const Trk::MeasurementBase*>::const_iterator
it = rioVec.begin();
308 std::vector<const Trk::MeasurementBase*>::const_iterator it_end = rioVec.end();
310 for (;
it != it_end; ++
it) {
321 if (2 * halfLength > storedLength)
continue;
323 storedLength = halfLength;
326 std::pair<Amg::Vector3D, Amg::Vector3D> shortpos;
329 lp[1] = -storedLength;