ATLAS Offline Software
TangentToCircles.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
7 #include <iostream>
8 
9 namespace TrkDriftCircleMath {
10 
12  LineVec lines;
13  lines.reserve(4);
14 
15  double DeltaX = dc2.x() - dc1.x();
16  double DeltaY = dc2.y() - dc1.y();
17  double DistanceOfCenters = std::hypot(DeltaX, DeltaY);
18  if (DistanceOfCenters == 0.) {
19  std::cout << " TangentToCircles::tangentLines >>> ERROR same tube on input " << std::endl;
20  return lines;
21  }
22  double Alpha0 = std::atan2(DeltaY, DeltaX);
23 
24  // Case of 0 drift distances, only 1 line
25  if (dc1.r() == 0. && dc2.r() == 0.) {
26  lines.emplace_back(dc1.position(), Alpha0);
27  return lines;
28  }
29 
30  // Here are the first 2 "inner" lines ....
31  double RSum = dc1.r() + dc2.r();
32 
33  double ratio = RSum / DistanceOfCenters;
34  if (std::abs(ratio) > 1.) return lines;
35 
36  double Alpha1 = std::asin(ratio);
37 
38  double line_phi = Alpha0 + Alpha1;
39  LocVec2D pos1(dc1.x() + dc1.r() * std::sin(line_phi), dc1.y() - dc1.r() * std::cos(line_phi));
40  lines.emplace_back(pos1, line_phi);
41 
42  line_phi = Alpha0 - Alpha1;
43  LocVec2D pos2(dc1.x() - dc1.r() * std::sin(line_phi), dc1.y() + dc1.r() * std::cos(line_phi));
44  lines.emplace_back(pos2, line_phi);
45 
46  // Case where one of the drifts is 0 ==> Only two lines
47  if (dc1.r() == 0. || dc2.r() == 0.) return lines;
48 
49  // ... and here are the other 2 "outer" lines
50  double DeltaR = std::abs(dc2.r() - dc1.r());
51 
52  ratio = DeltaR / DistanceOfCenters;
53  if (std::abs(ratio) > 1.) return lines;
54 
55  double Alpha2 = asin(ratio);
56 
57  if (dc1.r() < dc2.r()) {
58  line_phi = Alpha0 + Alpha2;
59  LocVec2D pos3(dc1.x() - dc1.r() * sin(line_phi), dc1.y() + dc1.r() * cos(line_phi));
60  lines.emplace_back(pos3, line_phi);
61 
62  line_phi = Alpha0 - Alpha2;
63  LocVec2D pos4(dc1.x() + dc1.r() * std::sin(line_phi), dc1.y() - dc1.r() * std::cos(line_phi));
64  lines.emplace_back(pos4, line_phi);
65 
66  } else {
67  line_phi = Alpha0 + Alpha2;
68  LocVec2D pos3(dc1.x() + dc1.r() * std::sin(line_phi), dc1.y() - dc1.r() * std::cos(line_phi));
69  lines.emplace_back(pos3, line_phi);
70 
71  line_phi = Alpha0 - Alpha2;
72  LocVec2D pos4(dc1.x() - dc1.r() * std::sin(line_phi), dc1.y() + dc1.r() * std::cos(line_phi));
73  lines.emplace_back(pos4, line_phi);
74  }
75  return lines;
76  }
77 
78 } // namespace TrkDriftCircleMath
met::DeltaR
@ DeltaR
Definition: METRecoCommon.h:11
TrkDriftCircleMath::DriftCircle::position
const LocVec2D & position() const
access to local position
Definition: DriftCircle.h:74
TrkDriftCircleMath
Function object to check whether two Segments are sub/super sets or different.
Definition: IMdtSegmentFinder.h:13
TangentToCircles.h
TrkDriftCircleMath::TangentToCircles::tangentLines
static LineVec tangentLines(const DriftCircle &dc1, const DriftCircle &dc2)
Definition: TangentToCircles.cxx:11
TrkDriftCircleMath::DriftCircle::x
double x() const
direct access to local x position
Definition: DriftCircle.h:80
TrkDriftCircleMath::DriftCircle
This class represents a drift time measurement.
Definition: DriftCircle.h:22
drawFromPickle.cos
cos
Definition: drawFromPickle.py:36
TrkDriftCircleMath::DriftCircle::r
double r() const
access to drift radius
Definition: DriftCircle.h:86
TrkDriftCircleMath::LocVec2D
Implementation of 2 dimensional vector class.
Definition: LocVec2D.h:16
CaloCondBlobAlgs_fillNoiseFromASCII.lines
lines
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:104
python.compareTCTs.ratio
ratio
Definition: compareTCTs.py:295
drawFromPickle.sin
sin
Definition: drawFromPickle.py:36
TrkDriftCircleMath::DriftCircle::y
double y() const
direct access to local y position
Definition: DriftCircle.h:83
TrkDriftCircleMath::TangentToCircles::LineVec
std::vector< Line > LineVec
Definition: TangentToCircles.h:18