ATLAS Offline Software
Public Member Functions | Private Attributes | List of all members
Trk::ComparisonFunction< T > Class Template Reference

#include <ComparisonFunction.h>

Collaboration diagram for Trk::ComparisonFunction< T >:

Public Member Functions

 ComparisonFunction ()=default
 Default. More...
 
 ComparisonFunction (const ComparisonFunction &cpf)=default
 
 ComparisonFunction (ComparisonFunction &&cpf)=default
 
ComparisonFunctionoperator= (const ComparisonFunction &cpf)=default
 
ComparisonFunctionoperator= (ComparisonFunction &&cpf)=default
 
 ~ComparisonFunction ()=default
 
 ComparisonFunction (const Amg::Vector3D &sp)
 Constructor for pointlike Search. More...
 
 ComparisonFunction (const Amg::Vector3D &sp, const Amg::Vector3D &dir)
 Constructor with point and line, search with direction. More...
 
 ComparisonFunction (double cradius)
 Search wrt to distance wrt to radius. More...
 
bool operator() (const T *one, const T *two) const
 
bool operator() (const std::unique_ptr< T > &one, const std::unique_ptr< T > &two) const
 

Private Attributes

Amg::Vector3D m_point
 
Amg::Vector3D m_line
 
double m_radius = 0.
 
int8_t m_hasPointAndLine = 0
 

Detailed Description

template<class T>
class Trk::ComparisonFunction< T >

this functor is used to find the closest objects:

Author
Andre.nosp@m.as.S.nosp@m.alzbu.nosp@m.rger.nosp@m.@cern.nosp@m..ch
Christos Anastopoulos (MT cleanup)

Definition at line 33 of file ComparisonFunction.h.

Constructor & Destructor Documentation

◆ ComparisonFunction() [1/6]

template<class T >
Trk::ComparisonFunction< T >::ComparisonFunction ( )
default

◆ ComparisonFunction() [2/6]

template<class T >
Trk::ComparisonFunction< T >::ComparisonFunction ( const ComparisonFunction< T > &  cpf)
default

◆ ComparisonFunction() [3/6]

template<class T >
Trk::ComparisonFunction< T >::ComparisonFunction ( ComparisonFunction< T > &&  cpf)
default

◆ ~ComparisonFunction()

template<class T >
Trk::ComparisonFunction< T >::~ComparisonFunction ( )
default

◆ ComparisonFunction() [4/6]

template<class T >
Trk::ComparisonFunction< T >::ComparisonFunction ( const Amg::Vector3D sp)
inline

Constructor for pointlike Search.

Definition at line 45 of file ComparisonFunction.h.

46  : m_point(sp)
47  , m_line{}
48  , m_radius{ 0 }
49  , m_hasPointAndLine{ 1 }
50  {
51  m_line.setZero();
52  }

◆ ComparisonFunction() [5/6]

template<class T >
Trk::ComparisonFunction< T >::ComparisonFunction ( const Amg::Vector3D sp,
const Amg::Vector3D dir 
)
inline

Constructor with point and line, search with direction.

Definition at line 55 of file ComparisonFunction.h.

56  : m_point(sp)
57  , m_line(dir)
58  , m_radius{ 0. }
59  , m_hasPointAndLine{ 2 }
60  {}

◆ ComparisonFunction() [6/6]

template<class T >
Trk::ComparisonFunction< T >::ComparisonFunction ( double  cradius)
inline

Search wrt to distance wrt to radius.

Definition at line 63 of file ComparisonFunction.h.

64  : m_point{}
65  , m_line{}
66  , m_radius{ std::abs(cradius) }
67  , m_hasPointAndLine{ 0 }
68  {
69  m_point.setZero();
70  m_line.setZero();
71  }

Member Function Documentation

◆ operator()() [1/2]

template<class T >
bool Trk::ComparisonFunction< T >::operator() ( const std::unique_ptr< T > &  one,
const std::unique_ptr< T > &  two 
) const
inline

Definition at line 102 of file ComparisonFunction.h.

103  {
104  return this->operator()(one.get(), two.get());
105  }

◆ operator()() [2/2]

template<class T >
bool Trk::ComparisonFunction< T >::operator() ( const T *  one,
const T *  two 
) const
inline

Definition at line 73 of file ComparisonFunction.h.

74  {
75  if (m_hasPointAndLine == 0) {
76  return (fabs(one->position().perp() - m_radius) <
77  fabs(two->position().perp() - m_radius));
78  }
79  if (m_hasPointAndLine == 1) {
80  return ((one->position() - m_point).mag() <
81  (two->position() - m_point).mag());
82  }
83  Amg::Vector3D distPosOne((one->position()) - m_point);
84  double lmag2 = m_line.mag();
85  lmag2 *= lmag2;
86  double dp1_mag2 = distPosOne.mag();
87  dp1_mag2 *= dp1_mag2;
88  double pl1_2 = m_line.dot(distPosOne);
89  pl1_2 *= pl1_2;
90  double distOne = (lmag2 * dp1_mag2 - pl1_2) / dp1_mag2;
91 
92  Amg::Vector3D distPosTwo((two->position()) - m_point);
93  double dp2_mag2 = distPosTwo.mag();
94  dp1_mag2 *= dp1_mag2;
95  double pl2_2 = m_line.dot(distPosTwo);
96  pl1_2 *= pl1_2;
97  double distTwo = (lmag2 * dp2_mag2 - pl2_2) / dp2_mag2;
98 
99  return (fabs(distOne) < fabs(distTwo));
100  }

◆ operator=() [1/2]

template<class T >
ComparisonFunction& Trk::ComparisonFunction< T >::operator= ( ComparisonFunction< T > &&  cpf)
default

◆ operator=() [2/2]

template<class T >
ComparisonFunction& Trk::ComparisonFunction< T >::operator= ( const ComparisonFunction< T > &  cpf)
default

Member Data Documentation

◆ m_hasPointAndLine

template<class T >
int8_t Trk::ComparisonFunction< T >::m_hasPointAndLine = 0
private

Definition at line 112 of file ComparisonFunction.h.

◆ m_line

template<class T >
Amg::Vector3D Trk::ComparisonFunction< T >::m_line
private

Definition at line 109 of file ComparisonFunction.h.

◆ m_point

template<class T >
Amg::Vector3D Trk::ComparisonFunction< T >::m_point
private

Definition at line 108 of file ComparisonFunction.h.

◆ m_radius

template<class T >
double Trk::ComparisonFunction< T >::m_radius = 0.
private

Definition at line 110 of file ComparisonFunction.h.


The documentation for this class was generated from the following file:
Trk::ComparisonFunction::m_line
Amg::Vector3D m_line
Definition: ComparisonFunction.h:109
Trk::ComparisonFunction::operator()
bool operator()(const T *one, const T *two) const
Definition: ComparisonFunction.h:73
Trk::ComparisonFunction::m_hasPointAndLine
int8_t m_hasPointAndLine
Definition: ComparisonFunction.h:112
Trk::one
@ one
Definition: TrkDetDescr/TrkSurfaces/TrkSurfaces/RealQuadraticEquation.h:22
Trk::ComparisonFunction::m_point
Amg::Vector3D m_point
Definition: ComparisonFunction.h:108
Trk::two
@ two
Definition: TrkDetDescr/TrkSurfaces/TrkSurfaces/RealQuadraticEquation.h:23
beamspotman.dir
string dir
Definition: beamspotman.py:623
Trk::ComparisonFunction::m_radius
double m_radius
Definition: ComparisonFunction.h:110
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47