ATLAS Offline Software
Public Member Functions | Private Member Functions | Private Attributes | List of all members
Trk::StraightLineIntersector Class Referencefinal

#include <StraightLineIntersector.h>

Inheritance diagram for Trk::StraightLineIntersector:
Collaboration diagram for Trk::StraightLineIntersector:

Public Member Functions

 StraightLineIntersector (const std::string &type, const std::string &name, const IInterface *parent)
 
virtual StatusCode finalize () override
 
virtual std::optional< TrackSurfaceIntersectionintersectSurface (const Surface &surface, const TrackSurfaceIntersection &trackTrackSurfaceIntersection, const double qOverP) const override
 IIntersector interface method for general Surface type. More...
 
virtual std::optional< TrackSurfaceIntersectionapproachPerigeeSurface (const PerigeeSurface &surface, const TrackSurfaceIntersection &trackTrackSurfaceIntersection, const double) const override
 IIntersector interface method for specific Surface type : PerigeeSurface. More...
 
virtual std::optional< TrackSurfaceIntersectionapproachStraightLineSurface (const StraightLineSurface &surface, const TrackSurfaceIntersection &trackTrackSurfaceIntersection, const double) const override
 IIntersector interface method for specific Surface type : StraightLineSurface. More...
 
virtual std::optional< TrackSurfaceIntersectionintersectCylinderSurface (const CylinderSurface &surface, const TrackSurfaceIntersection &trackTrackSurfaceIntersection, const double) const override
 IIntersector interface method for specific Surface type : CylinderSurface. More...
 
virtual std::optional< TrackSurfaceIntersectionintersectDiscSurface (const DiscSurface &surface, const TrackSurfaceIntersection &trackTrackSurfaceIntersection, const double) const override
 IIntersector interface method for specific Surface type : DiscSurface. More...
 
virtual std::optional< TrackSurfaceIntersectionintersectPlaneSurface (const PlaneSurface &surface, const TrackSurfaceIntersection &trackTrackSurfaceIntersection, const double) const override
 IIntersector interface method for specific Surface type : PlaneSurface. More...
 
virtual bool isValid (Amg::Vector3D, Amg::Vector3D) const override
 IIntersector interface method for validity check over a particular extrapolation range. More...
 

Private Member Functions

double distanceToCylinder (const TrackSurfaceIntersection &isect, const double cylinderRadius) const
 
double distanceToDisc (const TrackSurfaceIntersection &isect, const double discZ) const
 
double distanceToLine (const TrackSurfaceIntersection &isect, const Amg::Vector3D &linePosition, const Amg::Vector3D &lineDirection) const
 
double distanceToPlane (const TrackSurfaceIntersection &isect, const Amg::Vector3D &planePosition, const Amg::Vector3D &planeNormal) const
 
void step (TrackSurfaceIntersection &isect, double stepLength) const
 

Private Attributes

std::atomic< unsigned long long > m_countExtrapolations
 

Detailed Description

Definition at line 22 of file StraightLineIntersector.h.

Constructor & Destructor Documentation

◆ StraightLineIntersector()

Trk::StraightLineIntersector::StraightLineIntersector ( const std::string &  type,
const std::string &  name,
const IInterface *  parent 
)

Definition at line 26 of file StraightLineIntersector.cxx.

29  : base_class (type, name, parent),
31 {
32 }

Member Function Documentation

◆ approachPerigeeSurface()

std::optional< Trk::TrackSurfaceIntersection > Trk::StraightLineIntersector::approachPerigeeSurface ( const PerigeeSurface surface,
const TrackSurfaceIntersection trackTrackSurfaceIntersection,
const double   
) const
overridevirtual

IIntersector interface method for specific Surface type : PerigeeSurface.

Definition at line 78 of file StraightLineIntersector.cxx.

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 }

◆ approachStraightLineSurface()

std::optional< Trk::TrackSurfaceIntersection > Trk::StraightLineIntersector::approachStraightLineSurface ( const StraightLineSurface surface,
const TrackSurfaceIntersection trackTrackSurfaceIntersection,
const double   
) const
overridevirtual

IIntersector interface method for specific Surface type : StraightLineSurface.

Definition at line 95 of file StraightLineIntersector.cxx.

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 }

◆ distanceToCylinder()

double Trk::StraightLineIntersector::distanceToCylinder ( const TrackSurfaceIntersection isect,
const double  cylinderRadius 
) const
inlineprivate

Definition at line 95 of file StraightLineIntersector.h.

96  {
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 }

◆ distanceToDisc()

double Trk::StraightLineIntersector::distanceToDisc ( const TrackSurfaceIntersection isect,
const double  discZ 
) const
inlineprivate

Definition at line 109 of file StraightLineIntersector.h.

110  {
111  const Amg::Vector3D& pos = isect.position();
112  const Amg::Vector3D& dir = isect.direction();
113  return (discZ - pos.z()) / dir.z();
114 }

◆ distanceToLine()

double Trk::StraightLineIntersector::distanceToLine ( const TrackSurfaceIntersection isect,
const Amg::Vector3D linePosition,
const Amg::Vector3D lineDirection 
) const
inlineprivate

Definition at line 116 of file StraightLineIntersector.h.

118  {
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 }

◆ distanceToPlane()

double Trk::StraightLineIntersector::distanceToPlane ( const TrackSurfaceIntersection isect,
const Amg::Vector3D planePosition,
const Amg::Vector3D planeNormal 
) const
inlineprivate

Definition at line 133 of file StraightLineIntersector.h.

135  {
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 }

◆ finalize()

StatusCode Trk::StraightLineIntersector::finalize ( )
overridevirtual

Definition at line 35 of file StraightLineIntersector.cxx.

36 {
37  ATH_MSG_DEBUG( "finalized after " << m_countExtrapolations << " extrapolations" );
38  return StatusCode::SUCCESS;
39 }

◆ intersectCylinderSurface()

std::optional< Trk::TrackSurfaceIntersection > Trk::StraightLineIntersector::intersectCylinderSurface ( const CylinderSurface surface,
const TrackSurfaceIntersection trackTrackSurfaceIntersection,
const double   
) const
overridevirtual

IIntersector interface method for specific Surface type : CylinderSurface.

Definition at line 112 of file StraightLineIntersector.cxx.

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 }

◆ intersectDiscSurface()

std::optional< Trk::TrackSurfaceIntersection > Trk::StraightLineIntersector::intersectDiscSurface ( const DiscSurface surface,
const TrackSurfaceIntersection trackTrackSurfaceIntersection,
const double   
) const
overridevirtual

IIntersector interface method for specific Surface type : DiscSurface.

Definition at line 129 of file StraightLineIntersector.cxx.

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 }

◆ intersectPlaneSurface()

std::optional< Trk::TrackSurfaceIntersection > Trk::StraightLineIntersector::intersectPlaneSurface ( const PlaneSurface surface,
const TrackSurfaceIntersection trackTrackSurfaceIntersection,
const double   
) const
overridevirtual

IIntersector interface method for specific Surface type : PlaneSurface.

Definition at line 145 of file StraightLineIntersector.cxx.

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 }

◆ intersectSurface()

std::optional< Trk::TrackSurfaceIntersection > Trk::StraightLineIntersector::intersectSurface ( const Surface surface,
const TrackSurfaceIntersection trackTrackSurfaceIntersection,
const double  qOverP 
) const
overridevirtual

IIntersector interface method for general Surface type.

Definition at line 43 of file StraightLineIntersector.cxx.

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 }

◆ isValid()

virtual bool Trk::StraightLineIntersector::isValid ( Amg::Vector3D  ,
Amg::Vector3D   
) const
inlineoverridevirtual

IIntersector interface method for validity check over a particular extrapolation range.

Definition at line 70 of file StraightLineIntersector.h.

71  {
72  return true;
73  }

◆ step()

void Trk::StraightLineIntersector::step ( TrackSurfaceIntersection isect,
double  stepLength 
) const
inlineprivate

Definition at line 144 of file StraightLineIntersector.h.

145  {
146  isect.position() += stepLength * isect.direction();
147  isect.pathlength() += stepLength;
148 }

Member Data Documentation

◆ m_countExtrapolations

std::atomic<unsigned long long> Trk::StraightLineIntersector::m_countExtrapolations
mutableprivate

Definition at line 90 of file StraightLineIntersector.h.


The documentation for this class was generated from the following files:
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::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::distanceToCylinder
double distanceToCylinder(const TrackSurfaceIntersection &isect, const double cylinderRadius) const
Definition: StraightLineIntersector.h:95
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::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
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::SurfaceType::Perigee
@ Perigee
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
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
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
Trk::qOverP
@ qOverP
perigee
Definition: ParamDefs.h:67
Trk::SurfaceType::Disc
@ Disc
Trk::SurfaceType::Cylinder
@ Cylinder
Trk::SurfaceType::Plane
@ Plane
Trk::SurfaceType::Line
@ Line
Trk::StraightLineIntersector::step
void step(TrackSurfaceIntersection &isect, double stepLength) const
Definition: StraightLineIntersector.h:144
Trk::StraightLineIntersector::m_countExtrapolations
std::atomic< unsigned long long > m_countExtrapolations
Definition: StraightLineIntersector.h:90