ATLAS Offline Software
StraightLineIntersector.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 // provide straight line intersection to a surface
7 // (useful for abstract interfaces in track/segment fitters)
8 // (c) ATLAS Tracking software
10 
11 #ifndef TRKEXSTRAIGHTLINEINTERSECTOR_STRAIGHTLINEINTERSECTOR_H
12 #define TRKEXSTRAIGHTLINEINTERSECTOR_STRAIGHTLINEINTERSECTOR_H
13 
14 #include <atomic>
15 
19 
20 namespace Trk {
21 
22 class StraightLineIntersector final: public extends<AthAlgTool, IIntersector> {
23 
24  public:
25  StraightLineIntersector(const std::string& type, const std::string& name,
26  const IInterface* parent);
27 
28  virtual StatusCode finalize() override;
29 
31  virtual std::optional<TrackSurfaceIntersection> intersectSurface(
32  const Surface& surface,
33  const TrackSurfaceIntersection& trackTrackSurfaceIntersection,
34  const double qOverP) const override;
35 
37  virtual std::optional<TrackSurfaceIntersection> approachPerigeeSurface(
38  const PerigeeSurface& surface,
39  const TrackSurfaceIntersection& trackTrackSurfaceIntersection,
40  const double /*qOverP*/) const override;
41 
44  virtual std::optional<TrackSurfaceIntersection> approachStraightLineSurface(
45  const StraightLineSurface& surface,
46  const TrackSurfaceIntersection& trackTrackSurfaceIntersection,
47  const double /*qOverP*/) const override;
48 
51  virtual std::optional<TrackSurfaceIntersection> intersectCylinderSurface(
52  const CylinderSurface& surface,
53  const TrackSurfaceIntersection& trackTrackSurfaceIntersection,
54  const double /*qOverP*/) const override;
55 
57  virtual std::optional<TrackSurfaceIntersection> intersectDiscSurface(
58  const DiscSurface& surface,
59  const TrackSurfaceIntersection& trackTrackSurfaceIntersection,
60  const double /*qOverP*/) const override;
61 
63  virtual std::optional<TrackSurfaceIntersection> intersectPlaneSurface(
64  const PlaneSurface& surface,
65  const TrackSurfaceIntersection& trackTrackSurfaceIntersection,
66  const double /*qOverP*/) const override;
67 
70  virtual bool isValid(Amg::Vector3D /*startPosition*/,
71  Amg::Vector3D /*endPosition*/) const override {
72  return true;
73  }
74 
75  private:
76  // private methods
77  double distanceToCylinder(const TrackSurfaceIntersection& isect,
78  const double cylinderRadius) const;
79  double distanceToDisc(const TrackSurfaceIntersection& isect,
80  const double discZ) const;
81  double distanceToLine(const TrackSurfaceIntersection& isect,
82  const Amg::Vector3D& linePosition,
83  const Amg::Vector3D& lineDirection) const;
84  double distanceToPlane(const TrackSurfaceIntersection& isect,
85  const Amg::Vector3D& planePosition,
86  const Amg::Vector3D& planeNormal) const;
87  void step(TrackSurfaceIntersection& isect, double stepLength) const;
88 
89  // counters
90  mutable std::atomic<unsigned long long> m_countExtrapolations;
91 };
92 
93 //<<<<<< INLINE PRIVATE MEMBER FUNCTIONS >>>>>>
94 
96  const TrackSurfaceIntersection& isect, const double cylinderRadius) const {
97  const Amg::Vector3D& pos = isect.position();
98  const Amg::Vector3D& dir = isect.direction();
99  double sinThsqinv = 1. / dir.perp2();
100  double stepLength = (-pos.x() * dir.x() - pos.y() * dir.y()) * sinThsqinv;
101  double deltaRSq =
102  (cylinderRadius * cylinderRadius - pos.perp2()) * sinThsqinv +
103  stepLength * stepLength;
104  if (deltaRSq > 0.)
105  stepLength += sqrt(deltaRSq);
106  return stepLength;
107 }
108 
110  const TrackSurfaceIntersection& isect, const double discZ) const {
111  const Amg::Vector3D& pos = isect.position();
112  const Amg::Vector3D& dir = isect.direction();
113  return (discZ - pos.z()) / dir.z();
114 }
115 
117  const TrackSurfaceIntersection& isect, const Amg::Vector3D& linePosition,
118  const Amg::Vector3D& lineDirection) const {
119  // offset joining track to line is given by
120  // offset = linePosition + a*lineDirection - trackPosition -
121  // b*trackDirection
122  //
123  // offset is perpendicular to both line and track at solution i.e.
124  // lineDirection.dot(offset) = 0
125  // trackDirection.dot(offset) = 0
126  const Amg::Vector3D& pos = isect.position();
127  const Amg::Vector3D& dir = isect.direction();
128  double cosAngle = lineDirection.dot(dir);
129  return (linePosition - pos).dot(dir - lineDirection * cosAngle) /
130  (1. - cosAngle * cosAngle);
131 }
132 
134  const TrackSurfaceIntersection& isect, const Amg::Vector3D& planePosition,
135  const Amg::Vector3D& planeNormal) const {
136  // take the normal component of the offset from track position to plane
137  // position this is equal to the normal component of the required distance
138  // along the track direction
139  const Amg::Vector3D& pos = isect.position();
140  const Amg::Vector3D& dir = isect.direction();
141  return planeNormal.dot(planePosition - pos) / planeNormal.dot(dir);
142 }
143 
145  double stepLength) const {
146  isect.position() += stepLength * isect.direction();
147  isect.pathlength() += stepLength;
148 }
149 
150 } // namespace Trk
151 
152 #endif // TRKEXSTRAIGHTLINEINTERSECTOR_STRAIGHTLINEINTERSECTOR_H
Trk::PerigeeSurface
Definition: PerigeeSurface.h:43
Trk::StraightLineIntersector::approachPerigeeSurface
virtual std::optional< TrackSurfaceIntersection > approachPerigeeSurface(const PerigeeSurface &surface, const TrackSurfaceIntersection &trackTrackSurfaceIntersection, const double) const override
IIntersector interface method for specific Surface type : PerigeeSurface.
Definition: StraightLineIntersector.cxx:78
Trk::StraightLineIntersector::distanceToDisc
double distanceToDisc(const TrackSurfaceIntersection &isect, const double discZ) const
Definition: StraightLineIntersector.h:109
Trk::TrackSurfaceIntersection
Definition: TrackSurfaceIntersection.h:32
Trk::StraightLineIntersector::finalize
virtual StatusCode finalize() override
Definition: StraightLineIntersector.cxx:35
Trk::DiscSurface
Definition: DiscSurface.h:54
Trk::TrackSurfaceIntersection::pathlength
double pathlength() const
Method to retrieve the pathlength propagated till the Intersection.
Definition: TrackSurfaceIntersection.h:96
Trk::StraightLineIntersector::intersectPlaneSurface
virtual std::optional< TrackSurfaceIntersection > intersectPlaneSurface(const PlaneSurface &surface, const TrackSurfaceIntersection &trackTrackSurfaceIntersection, const double) const override
IIntersector interface method for specific Surface type : PlaneSurface.
Definition: StraightLineIntersector.cxx:145
Trk::StraightLineIntersector::intersectSurface
virtual std::optional< TrackSurfaceIntersection > intersectSurface(const Surface &surface, const TrackSurfaceIntersection &trackTrackSurfaceIntersection, const double qOverP) const override
IIntersector interface method for general Surface type.
Definition: StraightLineIntersector.cxx:43
Trk::StraightLineIntersector::StraightLineIntersector
StraightLineIntersector(const std::string &type, const std::string &name, const IInterface *parent)
Definition: StraightLineIntersector.cxx:26
Trk::StraightLineIntersector
Definition: StraightLineIntersector.h:22
Trk::TrackSurfaceIntersection::position
const Amg::Vector3D & position() const
Method to retrieve the position of the Intersection.
Definition: TrackSurfaceIntersection.h:80
Trk::StraightLineIntersector::distanceToCylinder
double distanceToCylinder(const TrackSurfaceIntersection &isect, const double cylinderRadius) const
Definition: StraightLineIntersector.h:95
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
Trk::StraightLineIntersector::intersectCylinderSurface
virtual std::optional< TrackSurfaceIntersection > intersectCylinderSurface(const CylinderSurface &surface, const TrackSurfaceIntersection &trackTrackSurfaceIntersection, const double) const override
IIntersector interface method for specific Surface type : CylinderSurface.
Definition: StraightLineIntersector.cxx:112
Trk::CylinderSurface
Definition: CylinderSurface.h:55
Trk::StraightLineIntersector::approachStraightLineSurface
virtual std::optional< TrackSurfaceIntersection > approachStraightLineSurface(const StraightLineSurface &surface, const TrackSurfaceIntersection &trackTrackSurfaceIntersection, const double) const override
IIntersector interface method for specific Surface type : StraightLineSurface.
Definition: StraightLineIntersector.cxx:95
AthAlgTool.h
Trk::StraightLineIntersector::intersectDiscSurface
virtual std::optional< TrackSurfaceIntersection > intersectDiscSurface(const DiscSurface &surface, const TrackSurfaceIntersection &trackTrackSurfaceIntersection, const double) const override
IIntersector interface method for specific Surface type : DiscSurface.
Definition: StraightLineIntersector.cxx:129
test_pyathena.parent
parent
Definition: test_pyathena.py:15
Trk::StraightLineIntersector::distanceToLine
double distanceToLine(const TrackSurfaceIntersection &isect, const Amg::Vector3D &linePosition, const Amg::Vector3D &lineDirection) const
Definition: StraightLineIntersector.h:116
beamspotman.dir
string dir
Definition: beamspotman.py:623
Trk
Ensure that the ATLAS eigen extensions are properly loaded.
Definition: FakeTrackBuilder.h:9
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
IIntersector.h
Trk::TrackSurfaceIntersection::direction
const Amg::Vector3D & direction() const
Method to retrieve the direction at the Intersection.
Definition: TrackSurfaceIntersection.h:88
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
Trk::StraightLineIntersector::distanceToPlane
double distanceToPlane(const TrackSurfaceIntersection &isect, const Amg::Vector3D &planePosition, const Amg::Vector3D &planeNormal) const
Definition: StraightLineIntersector.h:133
Trk::PlaneSurface
Definition: PlaneSurface.h:64
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
Trk::qOverP
@ qOverP
perigee
Definition: ParamDefs.h:67
Trk::StraightLineIntersector::isValid
virtual bool isValid(Amg::Vector3D, Amg::Vector3D) const override
IIntersector interface method for validity check over a particular extrapolation range.
Definition: StraightLineIntersector.h:70
TrackSurfaceIntersection.h
Trk::StraightLineIntersector::step
void step(TrackSurfaceIntersection &isect, double stepLength) const
Definition: StraightLineIntersector.h:144
Trk::Surface
Definition: Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/Surface.h:75
Trk::StraightLineIntersector::m_countExtrapolations
std::atomic< unsigned long long > m_countExtrapolations
Definition: StraightLineIntersector.h:90
Trk::StraightLineSurface
Definition: StraightLineSurface.h:51