ATLAS Offline Software
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
MuonCalib::MTStraightLine Class Reference

#include <MTStraightLine.h>

Collaboration diagram for MuonCalib::MTStraightLine:

Public Types

using MdtHitVec = MuonCalibSegment::MdtHitVec
 
using MdtHitPtr = MuonCalibSegment::MdtHitPtr
 

Public Member Functions

 MTStraightLine ()
 Default constructor: all internal parameters of the straight line are set to 0. More...
 
 MTStraightLine (const Amg::Vector3D &r_position, const Amg::Vector3D &r_direction, const Amg::Vector3D &r_position_error, const Amg::Vector3D &r_direction_error)
 Constructor: r_position: position vector of the straight line; r_direction: direction vector of the straight line; r_position_error: error on the position vector; r_direction_error: error on the direction vector. More...
 
 MTStraightLine (const double &r_a_x1, const double &r_b_x1, const double &r_a_x2, const double &r_b_x2, const double &r_a_x1_err, const double &r_b_x1_err, const double &r_a_x2_err, const double &r_b_x2_err)
 Coordinates: x1, x2, x3. More...
 
Amg::Vector3D positionVector () const
 get the position vector of the straight line More...
 
Amg::Vector3D directionVector () const
 get the direction vector of the straight line More...
 
Amg::Vector3D positionError () const
 get the error on the position vector of the straight line More...
 
Amg::Vector3D directionError () const
 get the error on the direction vector of the straight line More...
 
double a_x1 () const
 get the slope of the straight line in the x1-x3 plane More...
 
double a_x1_error () const
 get the error on the slope of the straight line in the x1-x3 plane More...
 
double b_x1 () const
 get the intercept of the straight line in the x1-x3 plane More...
 
double b_x1_error () const
 get the error on the intercept of the straight line in the x1-x3 plane More...
 
double a_x2 () const
 get the slope of the straight line in the x2-x3 plane More...
 
double a_x2_error () const
 get the error on the slope of the straight line in the x2-x3 plane More...
 
double b_x2 () const
 get the intercept of the straight line in the x2-x3 plane More...
 
double b_x2_error () const
 get the slope of the intercept of the straight line in the x2-x3 plane More...
 
Amg::Vector3D pointOnLine (const double &lambda) const
 get the point on the line for the given scale factor lambda, point=position_vector+lambda*direction_vector More...
 
double signDistFrom (const MTStraightLine &h) const
 get the signed distance of two lines (if both are parallel, dist>0) More...
 
double distFromLine (const Amg::Vector3D &point) const
 get the distance of point point from straight line More...
 
void setChi2 (double chi2)
 Cache the chi2. More...
 
double chi2 () const
 
void setNumberOfTrackHits (unsigned int n_hits)
 cache the number of track hits More...
 
unsigned int numberOfTrackHits () const
 
double chi2PerDegreesOfFreedom () const
 Return chi2 / number of TrackHits - 2. More...
 
void setUsedHits (const MdtHitVec &hits)
 
const MdtHitVectrackHits () const
 

Private Member Functions

void init ()
 
void init (const Amg::Vector3D &r_position, const Amg::Vector3D &r_direction, const Amg::Vector3D &r_position_error, const Amg::Vector3D &r_direction_error)
 
void init (const double &r_a_x1, const double &r_b_x1, const double &r_a_x2, const double &r_b_x2, const double &r_a_x1_err, const double &r_b_x1_err, const double &r_a_x2_err, const double &r_b_x2_err)
 

Private Attributes

Amg::Vector3D m_position {0., 0., 0.}
 
Amg::Vector3D m_direction {0., 0., 0.}
 
Amg::Vector3D m_position_error {0., 0., 0.}
 
Amg::Vector3D m_direction_error {0., 0., 0.}
 
double m_chi2 {-1}
 
unsigned int m_numTrkHits {0}
 
MdtHitVec m_used_hits
 

Detailed Description

Definition at line 16 of file MTStraightLine.h.

Member Typedef Documentation

◆ MdtHitPtr

Definition at line 19 of file MTStraightLine.h.

◆ MdtHitVec

Definition at line 18 of file MTStraightLine.h.

Constructor & Destructor Documentation

◆ MTStraightLine() [1/3]

MuonCalib::MTStraightLine::MTStraightLine ( )
inline

Default constructor: all internal parameters of the straight line are set to 0.

Definition at line 22 of file MTStraightLine.h.

◆ MTStraightLine() [2/3]

MuonCalib::MTStraightLine::MTStraightLine ( const Amg::Vector3D r_position,
const Amg::Vector3D r_direction,
const Amg::Vector3D r_position_error,
const Amg::Vector3D r_direction_error 
)
inline

Constructor: r_position: position vector of the straight line; r_direction: direction vector of the straight line; r_position_error: error on the position vector; r_direction_error: error on the direction vector.

Definition at line 26 of file MTStraightLine.h.

◆ MTStraightLine() [3/3]

MuonCalib::MTStraightLine::MTStraightLine ( const double &  r_a_x1,
const double &  r_b_x1,
const double &  r_a_x2,
const double &  r_b_x2,
const double &  r_a_x1_err,
const double &  r_b_x1_err,
const double &  r_a_x2_err,
const double &  r_b_x2_err 
)
inline

Coordinates: x1, x2, x3.

Parametrization of the straight line: x1 = r_a_x1*x3 + r_b_x1; x2 = r_a_x2*x3 + r_b_x2; x3 arbitrary. r_a_x1_err: error on r_a_x1. r_b_x1_err: error on r_b_x1. r_a_x2_err: error on r_a_x2. r_b_x2_err: error on r_b_x2.

Definition at line 36 of file MTStraightLine.h.

Member Function Documentation

◆ a_x1()

double MTStraightLine::a_x1 ( ) const

get the slope of the straight line in the x1-x3 plane

Definition at line 46 of file MTStraightLine.cxx.

46 { return (m_direction.z() != 0.) ? m_direction.x() / m_direction.z() : 0.; }

◆ a_x1_error()

double MTStraightLine::a_x1_error ( ) const

get the error on the slope of the straight line in the x1-x3 plane

Definition at line 48 of file MTStraightLine.cxx.

48  {
49  return m_direction.z() != 0.
50  ? std::hypot(m_direction_error.x() / m_direction_error.z(), m_direction_error.y() * a_x1() / m_direction_error.z())
51  : 0.;
52 }

◆ a_x2()

double MTStraightLine::a_x2 ( ) const

get the slope of the straight line in the x2-x3 plane

Definition at line 65 of file MTStraightLine.cxx.

65 { return (m_direction.z() == 0.0) ? 0. : m_direction.y() / m_direction.z(); }

◆ a_x2_error()

double MTStraightLine::a_x2_error ( ) const

get the error on the slope of the straight line in the x2-x3 plane

Definition at line 66 of file MTStraightLine.cxx.

66  {
67  return (m_direction.z() == 0)
68  ? 0.0
69  :
70 
71  std::hypot(m_direction_error.y() / m_direction_error.z(), m_direction_error.y() * a_x2() / m_direction_error.z());
72 }

◆ b_x1()

double MTStraightLine::b_x1 ( ) const

get the intercept of the straight line in the x1-x3 plane

Definition at line 53 of file MTStraightLine.cxx.

53  {
54  if (m_direction.z() == 0.0) {
55  MsgStream log(Athena::getMessageSvc(), "MTStraightLine");
56  log << MSG::WARNING << "Class MTStraightLine, method b_x1: b_x1 not uniquely defined." << endmsg;
57  return m_position.x();
58  }
59  return (m_position.x() - m_position.z() * a_x1());
60 }

◆ b_x1_error()

double MTStraightLine::b_x1_error ( ) const

get the error on the intercept of the straight line in the x1-x3 plane

Definition at line 62 of file MTStraightLine.cxx.

62  {
63  return std::hypot(m_position_error.x(), a_x1() * m_position_error.z(), m_position.z() * a_x1_error());
64 }

◆ b_x2()

double MTStraightLine::b_x2 ( ) const

get the intercept of the straight line in the x2-x3 plane

Definition at line 74 of file MTStraightLine.cxx.

74  {
75  if (m_direction.z() == 0.0) {
76  MsgStream log(Athena::getMessageSvc(), "MTStraightLine");
77  log << MSG::WARNING << "Class MTStraightLine, method b_x2: b_x2 not uniquely defined." << endmsg;
78  return m_position.x();
79  }
80  return (m_position.y() - m_position.z() * a_x2());
81 }

◆ b_x2_error()

double MTStraightLine::b_x2_error ( ) const

get the slope of the intercept of the straight line in the x2-x3 plane

Definition at line 83 of file MTStraightLine.cxx.

83  {
84  return std::hypot(m_position_error.y(), a_x2() * m_position_error.z(), m_position.z() * a_x2_error());
85 }

◆ chi2()

double MTStraightLine::chi2 ( ) const

Definition at line 135 of file MTStraightLine.cxx.

135 { return m_chi2; }

◆ chi2PerDegreesOfFreedom()

double MTStraightLine::chi2PerDegreesOfFreedom ( ) const

Return chi2 / number of TrackHits - 2.

Definition at line 139 of file MTStraightLine.cxx.

139 { return m_chi2 / (m_numTrkHits > 2 ? m_numTrkHits - 2 : 0.01); }

◆ directionError()

Amg::Vector3D MTStraightLine::directionError ( ) const

get the error on the direction vector of the straight line

Definition at line 45 of file MTStraightLine.cxx.

45 { return m_direction_error; }

◆ directionVector()

Amg::Vector3D MTStraightLine::directionVector ( ) const

get the direction vector of the straight line

Definition at line 43 of file MTStraightLine.cxx.

43 { return m_direction; }

◆ distFromLine()

double MTStraightLine::distFromLine ( const Amg::Vector3D point) const

get the distance of point point from straight line

Definition at line 120 of file MTStraightLine.cxx.

120  {
121  //:::::::::::::::::::::::::
122  //:: AUXILIARY VARIABLES ::
123  //:::::::::::::::::::::::::
124 
126 
127  //::::::::::::::::::::::::
128  //:: CALCULATE DISTANCE ::
129  //::::::::::::::::::::::::
130 
131  return std::sqrt((point - m_position).dot(point - m_position) -
132  ((point - m_position).dot(u.unit())) * ((point - m_position).dot(u.unit())));
133 }

◆ init() [1/3]

void MTStraightLine::init ( )
private

Definition at line 14 of file MTStraightLine.cxx.

14  {
15  m_position = Amg::Vector3D(0.0, 0.0, 0.0);
16  m_direction = Amg::Vector3D(0.0, 0.0, 0.0);
17  m_position_error = Amg::Vector3D(0.0, 0.0, 0.0);
18  m_direction_error = Amg::Vector3D(0.0, 0.0, 0.0);
19 
20  return;
21 }

◆ init() [2/3]

void MTStraightLine::init ( const Amg::Vector3D r_position,
const Amg::Vector3D r_direction,
const Amg::Vector3D r_position_error,
const Amg::Vector3D r_direction_error 
)
private

Definition at line 23 of file MTStraightLine.cxx.

24  {
25  m_position = r_position;
26  m_direction = r_direction;
27  m_position_error = r_position_error;
28  m_direction_error = r_direction_error;
29 
30  return;
31 }

◆ init() [3/3]

void MTStraightLine::init ( const double &  r_a_x1,
const double &  r_b_x1,
const double &  r_a_x2,
const double &  r_b_x2,
const double &  r_a_x1_err,
const double &  r_b_x1_err,
const double &  r_a_x2_err,
const double &  r_b_x2_err 
)
private

Definition at line 33 of file MTStraightLine.cxx.

34  {
35  m_position = Amg::Vector3D(r_b_x1, r_b_x2, 0.0);
36  m_direction = Amg::Vector3D(r_a_x1, r_a_x2, 1.0);
37  m_position_error = Amg::Vector3D(r_b_x1_err, r_b_x2_err, 0.0);
38  m_direction_error = Amg::Vector3D(r_a_x1_err, r_a_x2_err, 1.0);
39 
40  return;
41 }

◆ numberOfTrackHits()

unsigned int MTStraightLine::numberOfTrackHits ( ) const

Definition at line 137 of file MTStraightLine.cxx.

137 { return m_numTrkHits; }

◆ pointOnLine()

Amg::Vector3D MTStraightLine::pointOnLine ( const double &  lambda) const

get the point on the line for the given scale factor lambda, point=position_vector+lambda*direction_vector

Definition at line 87 of file MTStraightLine.cxx.

87 { return m_position + lambda * m_direction; }

◆ positionError()

Amg::Vector3D MTStraightLine::positionError ( ) const

get the error on the position vector of the straight line

Definition at line 44 of file MTStraightLine.cxx.

44 { return m_position_error; }

◆ positionVector()

Amg::Vector3D MTStraightLine::positionVector ( ) const

get the position vector of the straight line

Definition at line 42 of file MTStraightLine.cxx.

42 { return m_position; }

◆ setChi2()

void MTStraightLine::setChi2 ( double  chi2)

Cache the chi2.

Definition at line 134 of file MTStraightLine.cxx.

134 { m_chi2 = std::isnan(chi2) ? -1 : chi2; }

◆ setNumberOfTrackHits()

void MTStraightLine::setNumberOfTrackHits ( unsigned int  n_hits)

cache the number of track hits

Definition at line 136 of file MTStraightLine.cxx.

136 { m_numTrkHits = n_hits; }

◆ setUsedHits()

void MTStraightLine::setUsedHits ( const MdtHitVec hits)

Definition at line 141 of file MTStraightLine.cxx.

141 { m_used_hits = hits; }

◆ signDistFrom()

double MTStraightLine::signDistFrom ( const MTStraightLine h) const

get the signed distance of two lines (if both are parallel, dist>0)

Definition at line 89 of file MTStraightLine.cxx.

89  {
90  //:::::::::::::::::::::::::
91  //:: AUXILIARY VARIABLES ::
92  //:::::::::::::::::::::::::
93 
95  // position and direction vectors of g
96  Amg::Vector3D b = h.positionVector(), v = h.directionVector();
97  // position and direction vectors of h
98  Amg::Vector3D n; // normal vector of plane spanned by g and h
99  Amg::Vector3D d; // distance vector
100 
101  //:::::::::::::
102  //:: PROGRAM ::
103  //:::::::::::::
104 
105  //::::::::::::::::::::::::
106  //:: collinearity check ::
107  //::::::::::::::::::::::::
108 
109  n = u.cross(v);
110  d = a - b;
111  if (n.dot(n) == 0.0) {
112  // straight lines are parallel
113  // no sign given
114  return std::sqrt(d.dot(d) - (u.unit().dot(d)) * (u.unit().dot(d)));
115  }
116 
117  return (d.dot(n.unit()));
118 }

◆ trackHits()

const MTStraightLine::MdtHitVec & MTStraightLine::trackHits ( ) const

Definition at line 142 of file MTStraightLine.cxx.

142 { return m_used_hits; }

Member Data Documentation

◆ m_chi2

double MuonCalib::MTStraightLine::m_chi2 {-1}
private

Definition at line 123 of file MTStraightLine.h.

◆ m_direction

Amg::Vector3D MuonCalib::MTStraightLine::m_direction {0., 0., 0.}
private

Definition at line 117 of file MTStraightLine.h.

◆ m_direction_error

Amg::Vector3D MuonCalib::MTStraightLine::m_direction_error {0., 0., 0.}
private

Definition at line 121 of file MTStraightLine.h.

◆ m_numTrkHits

unsigned int MuonCalib::MTStraightLine::m_numTrkHits {0}
private

Definition at line 124 of file MTStraightLine.h.

◆ m_position

Amg::Vector3D MuonCalib::MTStraightLine::m_position {0., 0., 0.}
private

Definition at line 116 of file MTStraightLine.h.

◆ m_position_error

Amg::Vector3D MuonCalib::MTStraightLine::m_position_error {0., 0., 0.}
private

Definition at line 120 of file MTStraightLine.h.

◆ m_used_hits

MdtHitVec MuonCalib::MTStraightLine::m_used_hits
private

Definition at line 125 of file MTStraightLine.h.


The documentation for this class was generated from the following files:
MuonCalib::MTStraightLine::a_x1
double a_x1() const
get the slope of the straight line in the x1-x3 plane
Definition: MTStraightLine.cxx:46
MuonCalib::MTStraightLine::m_numTrkHits
unsigned int m_numTrkHits
Definition: MTStraightLine.h:124
MuonCalib::MTStraightLine::m_direction
Amg::Vector3D m_direction
Definition: MTStraightLine.h:117
hist_file_dump.d
d
Definition: hist_file_dump.py:137
MuonCalib::MTStraightLine::a_x2
double a_x2() const
get the slope of the straight line in the x2-x3 plane
Definition: MTStraightLine.cxx:65
Trk::u
@ u
Enums for curvilinear frames.
Definition: ParamDefs.h:83
Athena::getMessageSvc
IMessageSvc * getMessageSvc(bool quiet=false)
Definition: getMessageSvc.cxx:20
MuonCalib::MTStraightLine::m_direction_error
Amg::Vector3D m_direction_error
Definition: MTStraightLine.h:121
MuonCalib::MTStraightLine::a_x2_error
double a_x2_error() const
get the error on the slope of the straight line in the x2-x3 plane
Definition: MTStraightLine.cxx:66
MuonCalib::MTStraightLine::a_x1_error
double a_x1_error() const
get the error on the slope of the straight line in the x1-x3 plane
Definition: MTStraightLine.cxx:48
h
beamspotman.n
n
Definition: beamspotman.py:731
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
LArG4ShowerLibProcessing.hits
hits
Definition: LArG4ShowerLibProcessing.py:136
MuonCalib::MTStraightLine::m_chi2
double m_chi2
Definition: MTStraightLine.h:123
MuonCalib::MTStraightLine::m_position
Amg::Vector3D m_position
Definition: MTStraightLine.h:116
MuonCalib::MTStraightLine::chi2
double chi2() const
Definition: MTStraightLine.cxx:135
dot.dot
def dot(G, fn, nodesToHighlight=[])
Definition: dot.py:5
MuonCalib::MTStraightLine::m_position_error
Amg::Vector3D m_position_error
Definition: MTStraightLine.h:120
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
python.PyAthena.v
v
Definition: PyAthena.py:157
a
TList * a
Definition: liststreamerinfos.cxx:10
MuonCalib::MTStraightLine::m_used_hits
MdtHitVec m_used_hits
Definition: MTStraightLine.h:125
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20