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

Class implementing a comparison function for sorting MeasurementBase objects. More...

#include <MeasurementBaseComparisonFunction.h>

Collaboration diagram for Trk::MeasurementBaseComparisonFunction:

Public Member Functions

 MeasurementBaseComparisonFunction ()=delete
 
 ~MeasurementBaseComparisonFunction ()=default
 
 MeasurementBaseComparisonFunction (const Amg::Vector3D &sp, const Amg::Vector3D &dir)
 Full relation definition using a straight line propagation. More...
 
 MeasurementBaseComparisonFunction (const MeasurementBaseComparisonFunction &MCF)=default
 
MeasurementBaseComparisonFunctionoperator= (MeasurementBaseComparisonFunction &MCF)=default
 
 MeasurementBaseComparisonFunction (MeasurementBaseComparisonFunction &&MCF)=default
 
MeasurementBaseComparisonFunctionoperator= (MeasurementBaseComparisonFunction &&MCF)=default
 
bool operator() (const Trk::MeasurementBase *one, const Trk::MeasurementBase *two) const
 The comparison function defining in what case a Measurement is 'smaller' than a second one. More...
 

Private Member Functions

double pathIntersectWithPlane (const Trk::PlaneSurface &psf) const
 
double pathIntersectWithLine (const Trk::StraightLineSurface &lsf) const
 
double pathIntersectWithLine (const Trk::PerigeeSurface &pgsf) const
 
double pathIntersectWithDisc (const Trk::DiscSurface &dsf) const
 
double pathIntersectWithCylinder (const Trk::CylinderSurface &csf, const Amg::Vector3D &globalHit) const
 

Private Attributes

Amg::Vector3D m_point
 
Amg::Vector3D m_direction
 

Detailed Description

Class implementing a comparison function for sorting MeasurementBase objects.

Definition at line 39 of file MeasurementBaseComparisonFunction.h.

Constructor & Destructor Documentation

◆ MeasurementBaseComparisonFunction() [1/4]

Trk::MeasurementBaseComparisonFunction::MeasurementBaseComparisonFunction ( )
delete

◆ ~MeasurementBaseComparisonFunction()

Trk::MeasurementBaseComparisonFunction::~MeasurementBaseComparisonFunction ( )
default

◆ MeasurementBaseComparisonFunction() [2/4]

Trk::MeasurementBaseComparisonFunction::MeasurementBaseComparisonFunction ( const Amg::Vector3D sp,
const Amg::Vector3D dir 
)
inline

Full relation definition using a straight line propagation.

Definition at line 45 of file MeasurementBaseComparisonFunction.h.

47  : m_point(sp)
48  , m_direction(dir.unit())
49  {}

◆ MeasurementBaseComparisonFunction() [3/4]

Trk::MeasurementBaseComparisonFunction::MeasurementBaseComparisonFunction ( const MeasurementBaseComparisonFunction MCF)
default

◆ MeasurementBaseComparisonFunction() [4/4]

Trk::MeasurementBaseComparisonFunction::MeasurementBaseComparisonFunction ( MeasurementBaseComparisonFunction &&  MCF)
default

Member Function Documentation

◆ operator()()

bool Trk::MeasurementBaseComparisonFunction::operator() ( const Trk::MeasurementBase one,
const Trk::MeasurementBase two 
) const
inline

The comparison function defining in what case a Measurement is 'smaller' than a second one.

Definition at line 65 of file MeasurementBaseComparisonFunction.h.

67  {
68 
69  // --- flexible sorting along a predicted direction
70  double path1 = 0;
71  const Trk::Surface& sf1 = one->associatedSurface();
72  const Trk::SurfaceType surfType1 = sf1.type();
73  switch (surfType1) {
75  const Trk::PlaneSurface& opsf =
76  static_cast<const Trk::PlaneSurface&>(sf1);
77  path1 = this->pathIntersectWithPlane(opsf);
78  } break;
80  const Trk::StraightLineSurface& ossf =
81  static_cast<const Trk::StraightLineSurface&>(sf1);
82  path1 = this->pathIntersectWithLine(ossf);
83  } break;
85  const Trk::DiscSurface& odsf =
86  static_cast<const Trk::DiscSurface&>(sf1);
87  path1 = this->pathIntersectWithDisc(odsf);
88  } break;
90  const Trk::CylinderSurface& ocsf =
91  static_cast<const Trk::CylinderSurface&>(sf1);
92  path1 = this->pathIntersectWithCylinder(ocsf, one->globalPosition());
93  } break;
95  const Trk::PerigeeSurface& ogsf =
96  static_cast<const Trk::PerigeeSurface&>(sf1);
97  path1 = this->pathIntersectWithLine(ogsf);
98  } break;
99  default: {
100  throw std::runtime_error(
101  "MeasurementBaseComparisonFunction: surface type error for Sf1!");
102  }
103  }
104 
105  // --- identify the 2nd surface type and get intersection path for surface 1
106  double path2 = 0;
107  const Trk::Surface& sf2 = two->associatedSurface();
108  const Trk::SurfaceType surfType2 = sf2.type();
109  switch (surfType2) {
111  const Trk::PlaneSurface& tpsf =
112  static_cast<const Trk::PlaneSurface&>(sf2);
113  path2 = this->pathIntersectWithPlane(tpsf);
114  } break;
115  case Trk::SurfaceType::Line: {
116  const Trk::StraightLineSurface& tssf =
117  static_cast<const Trk::StraightLineSurface&>(sf2);
118  path2 = this->pathIntersectWithLine(tssf);
119  } break;
120  case Trk::SurfaceType::Disc: {
121  const Trk::DiscSurface& tdsf =
122  static_cast<const Trk::DiscSurface&>(sf2);
123  path2 = this->pathIntersectWithDisc(tdsf);
124  } break;
126  const Trk::CylinderSurface& tcsf =
127  static_cast<const Trk::CylinderSurface&>(sf2);
128  path2 = this->pathIntersectWithCylinder(tcsf, two->globalPosition());
129  } break;
131  const Trk::PerigeeSurface& tgsf =
132  static_cast<const Trk::PerigeeSurface&>(sf2);
133  path2 = this->pathIntersectWithLine(tgsf);
134  } break;
135  default: {
136  throw std::runtime_error(
137  "MeasurementBaseComparisonFunction: surface type error for Sf2!");
138  }
139  }
140  return path1 < path2;
141  }

◆ operator=() [1/2]

MeasurementBaseComparisonFunction& Trk::MeasurementBaseComparisonFunction::operator= ( MeasurementBaseComparisonFunction &&  MCF)
default

◆ operator=() [2/2]

MeasurementBaseComparisonFunction& Trk::MeasurementBaseComparisonFunction::operator= ( MeasurementBaseComparisonFunction MCF)
default

◆ pathIntersectWithCylinder()

double Trk::MeasurementBaseComparisonFunction::pathIntersectWithCylinder ( const Trk::CylinderSurface csf,
const Amg::Vector3D globalHit 
) const
inlineprivate

Definition at line 183 of file MeasurementBaseComparisonFunction.h.

185  { // --- code from TrkExSlPropagator/LineCylinderIntersection.cxx
186 
187  // get the rotation by reference
188  const Amg::Transform3D& locTrans = csf.transform();
189  // take two points of line and calculate them to the 3D frame of the
190  // cylinder
191  Amg::Vector3D point1(locTrans.inverse() * m_point);
192  Amg::Vector3D point2raw = m_point + m_direction;
193  Amg::Vector3D point2(locTrans.inverse() * point2raw); // do it in two steps
194 
195  // new direction in 3D frame of cylinder
196  Amg::Vector3D direc((point2 - point1).unit());
197 
198  if (!direc.x()) {
199  return 0.;
200  } else {
201  // get line and circle constants
202  double k = (direc.y()) / (direc.x());
203  double d = (point2.x() * point1.y() - point1.x() * point2.y()) /
204  (point2.x() - point1.x());
205  double R = csf.bounds().r();
206  double first = 0.;
207  double second = 0.;
208 
209  // and solve the quadratic equation Trk::RealQuadraticEquation
210  // pquad(1+k*k, 2*k*d, d*d-R*R);
211  double a = 1 + k * k;
212  double p = 2 * k * d;
213  double q = d * d - R * R;
214  double discriminant = p * p - 4 * a * q;
215  if (discriminant < 0) {
216  return 0.;
217  } else {
218  // solutions = (discriminant==0) ? one : two;
219  double x0 =
220  -0.5 * (p + (p > 0 ? sqrt(discriminant) : -sqrt(discriminant)));
221  first = x0 / a;
222  second = q / x0;
223  }
224  double t1 = (first - point1.x()) / direc.x();
225  double t2 = (second - point1.x()) / direc.x();
226  // the solutions in the 3D frame of the cylinder
227  Amg::Vector3D dist1raw(point1 + t1 * direc - globalHit);
228  Amg::Vector3D dist2raw(point1 + t2 * direc - globalHit);
229  // return the solution which is closer to Meas'Base's global coordinates
230  if (dist1raw.mag() < dist2raw.mag()) {
231  return t1;
232  } else {
233  return t2;
234  }
235  }
236  }

◆ pathIntersectWithDisc()

double Trk::MeasurementBaseComparisonFunction::pathIntersectWithDisc ( const Trk::DiscSurface dsf) const
inlineprivate

Definition at line 177 of file MeasurementBaseComparisonFunction.h.

178  {
179  double denom = m_direction.dot(dsf.normal());
180  return (denom) ? dsf.normal().dot(dsf.center() - m_point) / (denom) : denom;
181  }

◆ pathIntersectWithLine() [1/2]

double Trk::MeasurementBaseComparisonFunction::pathIntersectWithLine ( const Trk::PerigeeSurface pgsf) const
inlineprivate

Definition at line 165 of file MeasurementBaseComparisonFunction.h.

166  {
167  Amg::Vector3D trackToWire(pgsf.center() - m_point);
168  double parallelity = m_direction.dot(Trk::s_zAxis);
169  double denom = 1 - parallelity * parallelity;
170  return (fabs(denom) > 10e-7)
171  ? (trackToWire.dot(m_direction) -
172  trackToWire.dot(Trk::s_zAxis) * parallelity) /
173  denom
174  : 0.;
175  }

◆ pathIntersectWithLine() [2/2]

double Trk::MeasurementBaseComparisonFunction::pathIntersectWithLine ( const Trk::StraightLineSurface lsf) const
inlineprivate

Definition at line 153 of file MeasurementBaseComparisonFunction.h.

154  {
155  const Amg::Vector3D& dirWire = lsf.lineDirection().normalized();
156  Amg::Vector3D trackToWire(lsf.center() - m_point);
157  double parallelity = m_direction.dot(dirWire);
158  double denom = 1 - parallelity * parallelity;
159  return (fabs(denom) > 10e-7) ? (trackToWire.dot(m_direction) -
160  trackToWire.dot(dirWire) * parallelity) /
161  denom
162  : 0.;
163  }

◆ pathIntersectWithPlane()

double Trk::MeasurementBaseComparisonFunction::pathIntersectWithPlane ( const Trk::PlaneSurface psf) const
inlineprivate

Definition at line 147 of file MeasurementBaseComparisonFunction.h.

148  {
149  double denom = m_direction.dot(psf.normal());
150  return (denom) ? psf.normal().dot(psf.center() - m_point) / (denom) : denom;
151  }

Member Data Documentation

◆ m_direction

Amg::Vector3D Trk::MeasurementBaseComparisonFunction::m_direction
private

Definition at line 145 of file MeasurementBaseComparisonFunction.h.

◆ m_point

Amg::Vector3D Trk::MeasurementBaseComparisonFunction::m_point
private

Definition at line 144 of file MeasurementBaseComparisonFunction.h.


The documentation for this class was generated from the following file:
Trk::MeasurementBaseComparisonFunction::m_point
Amg::Vector3D m_point
Definition: MeasurementBaseComparisonFunction.h:144
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
python.SystemOfUnits.second
int second
Definition: SystemOfUnits.py:120
Trk::MeasurementBaseComparisonFunction::pathIntersectWithPlane
double pathIntersectWithPlane(const Trk::PlaneSurface &psf) const
Definition: MeasurementBaseComparisonFunction.h:147
Trk::PerigeeSurface
Definition: PerigeeSurface.h:43
hist_file_dump.d
d
Definition: hist_file_dump.py:137
ALFA_EventTPCnv_Dict::t1
std::vector< ALFA_RawDataCollection_p1 > t1
Definition: ALFA_EventTPCnvDict.h:43
Trk::one
@ one
Definition: TrkDetDescr/TrkSurfaces/TrkSurfaces/RealQuadraticEquation.h:22
Trk::MeasurementBaseComparisonFunction::pathIntersectWithDisc
double pathIntersectWithDisc(const Trk::DiscSurface &dsf) const
Definition: MeasurementBaseComparisonFunction.h:177
Trk::CylinderSurface::bounds
virtual const CylinderBounds & bounds() const override final
This method returns the CylinderBounds by reference (NoBounds is not possible for cylinder)
Trk::SurfaceType
SurfaceType
Definition: SurfaceTypes.h:17
Trk::MeasurementBaseComparisonFunction::m_direction
Amg::Vector3D m_direction
Definition: MeasurementBaseComparisonFunction.h:145
Trk::DiscSurface
Definition: DiscSurface.h:54
Trk::Surface::center
const Amg::Vector3D & center() const
Returns the center position of the Surface.
Trk::MeasurementBaseComparisonFunction::pathIntersectWithLine
double pathIntersectWithLine(const Trk::StraightLineSurface &lsf) const
Definition: MeasurementBaseComparisonFunction.h:153
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
Trk::two
@ two
Definition: TrkDetDescr/TrkSurfaces/TrkSurfaces/RealQuadraticEquation.h:23
Trk::CylinderSurface
Definition: CylinderSurface.h:55
Amg::Transform3D
Eigen::Affine3d Transform3D
Definition: GeoPrimitives.h:46
Trk::Surface::normal
virtual const Amg::Vector3D & normal() const
Returns the normal vector of the Surface (i.e.
AnalysisUtils::Delta::R
double R(const INavigable4Momentum *p1, const double v_eta, const double v_phi)
Definition: AnalysisMisc.h:49
MuonR4::SegmentFit::ParamDefs::x0
@ x0
compute_lumi.denom
denom
Definition: compute_lumi.py:76
beamspotman.dir
string dir
Definition: beamspotman.py:623
Trk::SurfaceType::Perigee
@ Perigee
TauJetParameters::discriminant
@ discriminant
Definition: TauJetParameters.h:166
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
ALFA_EventTPCnv_Dict::t2
std::vector< ALFA_RawDataContainer_p1 > t2
Definition: ALFA_EventTPCnvDict.h:44
a
TList * a
Definition: liststreamerinfos.cxx:10
Trk::PlaneSurface
Definition: PlaneSurface.h:64
unit
const PlainObject unit() const
This is a plugin that makes Eigen look like CLHEP & defines some convenience methods.
Definition: AmgMatrixBasePlugin.h:21
DeMoScan.first
bool first
Definition: DeMoScan.py:536
Trk::SurfaceType::Disc
@ Disc
Trk::StraightLineSurface::lineDirection
const Amg::Vector3D & lineDirection() const
Special method for StraightLineSurface - provides the Line direction from cache: speedup.
Trk::SurfaceType::Cylinder
@ Cylinder
extractSporadic.q
list q
Definition: extractSporadic.py:98
Trk::SurfaceType::Plane
@ Plane
Trk::SurfaceType::Line
@ Line
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::MeasurementBaseComparisonFunction::pathIntersectWithCylinder
double pathIntersectWithCylinder(const Trk::CylinderSurface &csf, const Amg::Vector3D &globalHit) const
Definition: MeasurementBaseComparisonFunction.h:183
Trk::StraightLineSurface
Definition: StraightLineSurface.h:51
fitman.k
k
Definition: fitman.py:528
Trk::CylinderBounds::r
virtual double r() const override final
This method returns the radius.