ATLAS Offline Software
StraightLineIntersector.cxx
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 #include <cmath>
12 #include "CLHEP/Units/SystemOfUnits.h"
21 #include "TrkSurfaces/Surface.h"
22 
23 namespace Trk
24 {
25 
27  const std::string& name,
28  const IInterface* parent)
29  : base_class (type, name, parent),
30  m_countExtrapolations (0)
31 {
32 }
33 
36 {
37  ATH_MSG_DEBUG( "finalized after " << m_countExtrapolations << " extrapolations" );
38  return StatusCode::SUCCESS;
39 }
40 
42 std::optional<Trk::TrackSurfaceIntersection>
44  const TrackSurfaceIntersection& trackIntersection,
45  const double qOverP) const
46 {
47 
48  const auto surfaceType = surface.type();
49  if (surfaceType == Trk::SurfaceType::Plane) {
50  return intersectPlaneSurface(static_cast<const PlaneSurface&>(surface),
51  trackIntersection, qOverP);
52  }
53  if (surfaceType == Trk::SurfaceType::Line) {
55  static_cast<const StraightLineSurface&>(surface), trackIntersection,
56  qOverP);
57  }
58  if (surfaceType == Trk::SurfaceType::Cylinder) {
60  static_cast<const CylinderSurface&>(surface), trackIntersection,
61  qOverP);
62  }
63  if (surfaceType == Trk::SurfaceType::Disc) {
64  return intersectDiscSurface(static_cast<const DiscSurface&>(surface),
65  trackIntersection, qOverP);
66  }
67  if (surfaceType == Trk::SurfaceType::Perigee) {
68  return approachPerigeeSurface(static_cast<const PerigeeSurface&>(surface),
69  trackIntersection, qOverP);
70  }
71 
72  ATH_MSG_WARNING( " unrecognized Surface" );
73  return std::nullopt;
74 }
75 
77 std::optional<Trk::TrackSurfaceIntersection>
79  const TrackSurfaceIntersection& trackIntersection,
80  const double /*qOverP*/) const
81 {
82  TrackSurfaceIntersection isect = trackIntersection;
84 
85  // straight line distance along track to closest approach to line
86  const Amg::Vector3D& lineDirection = surface.transform().rotation().col(2);
87  double stepLength = distanceToLine (isect, surface.center(),lineDirection);
88  step(isect, stepLength);
89 
90  return isect;
91 }
92 
94 std::optional<Trk::TrackSurfaceIntersection>
96  const TrackSurfaceIntersection& trackIntersection,
97  const double /*qOverP*/) const
98 {
99  TrackSurfaceIntersection isect = trackIntersection;
101 
102  // straight line distance along track to closest approach to line
103  const Amg::Vector3D& lineDirection = surface.transform().rotation().col(2);
104  double stepLength = distanceToLine (isect, surface.center(),lineDirection);
105  step(isect, stepLength);
106 
107  return isect;
108 }
109 
111 std::optional<Trk::TrackSurfaceIntersection>
113  const TrackSurfaceIntersection& trackIntersection,
114  const double /*qOverP*/) const
115 {
116  TrackSurfaceIntersection isect = trackIntersection;
118 
119  // calculate straight line distance along track to intersect with cylinder radius
120  double cylinderRadius = surface.globalReferencePoint().perp();
121  double stepLength = distanceToCylinder(isect, cylinderRadius);
122  step(isect, stepLength);
123 
124  return isect;
125 }
126 
128 std::optional<Trk::TrackSurfaceIntersection>
130  const TrackSurfaceIntersection& trackIntersection,
131  const double /*qOverP*/) const
132 {
133  TrackSurfaceIntersection isect = trackIntersection;
135 
136  // straight line distance along track to intersect with disc
137  double stepLength = distanceToDisc(isect, surface.center().z());
138  step(isect, stepLength);
139 
140  return isect;
141 }
142 
144 std::optional<Trk::TrackSurfaceIntersection>
146  const TrackSurfaceIntersection& trackIntersection,
147  const double /*qOverP*/) const
148 {
149  TrackSurfaceIntersection isect = trackIntersection;
151 
152  // straight line distance along track to intersect with plane
153  double stepLength = distanceToPlane (isect, surface.center(),surface.normal());
154  step(isect, stepLength);
155  stepLength = distanceToPlane (isect, surface.center(),surface.normal());
156 
157  return isect;
158 }
159 
160 } // end of namespace
StraightLineSurface.h
TrackParameters.h
PerigeeSurface.h
Surface.h
Trk::PerigeeSurface
Definition: PerigeeSurface.h:43
StraightLineIntersector.h
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::Surface::center
const Amg::Vector3D & center() const
Returns the center position of the Surface.
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::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
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
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
CylinderSurface.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::Surface::normal
virtual const Amg::Vector3D & normal() const
Returns the normal vector of the Surface (i.e.
Trk::StraightLineIntersector::distanceToLine
double distanceToLine(const TrackSurfaceIntersection &isect, const Amg::Vector3D &linePosition, const Amg::Vector3D &lineDirection) const
Definition: StraightLineIntersector.h:116
Trk
Ensure that the ATLAS eigen extensions are properly loaded.
Definition: FakeTrackBuilder.h:9
Trk::SurfaceType::Perigee
@ Perigee
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
Trk::StraightLineIntersector::distanceToPlane
double distanceToPlane(const TrackSurfaceIntersection &isect, const Amg::Vector3D &planePosition, const Amg::Vector3D &planeNormal) const
Definition: StraightLineIntersector.h:133
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
Trk::PlaneSurface
Definition: PlaneSurface.h:64
PlaneSurface.h
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
Trk::qOverP
@ qOverP
perigee
Definition: ParamDefs.h:73
Trk::SurfaceType::Disc
@ Disc
Trk::SurfaceType::Cylinder
@ Cylinder
DiscSurface.h
Trk::SurfaceType::Plane
@ Plane
Trk::SurfaceType::Line
@ Line
Trk::CylinderSurface::globalReferencePoint
virtual const Amg::Vector3D & globalReferencePoint() const override final
Returns a global reference point: For the Cylinder this is Where denotes the averagePhi() of the cy...
Definition: CylinderSurface.cxx:167
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::Surface::transform
const Amg::Transform3D & transform() const
Returns HepGeom::Transform3D by reference.
Trk::Surface::type
constexpr virtual SurfaceType type() const =0
Returns the Surface type to avoid dynamic casts.
Trk::StraightLineIntersector::m_countExtrapolations
std::atomic< unsigned long long > m_countExtrapolations
Definition: StraightLineIntersector.h:90
Trk::StraightLineSurface
Definition: StraightLineSurface.h:51