ATLAS Offline Software
Loading...
Searching...
No Matches
MTStraightLine.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3*/
4
6
7#include <iostream>
8
10#include "GaudiKernel/MsgStream.h"
11#include "cmath"
12using namespace MuonCalib;
13
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}
22
23void MTStraightLine::init(const Amg::Vector3D& r_position, const Amg::Vector3D& r_direction, const Amg::Vector3D& r_position_error,
24 const Amg::Vector3D& r_direction_error) {
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}
32
33void 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,
34 const double r_b_x1_err, const double r_a_x2_err, const double r_b_x2_err) {
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}
46double MTStraightLine::a_x1() const { return (m_direction.z() != 0.) ? m_direction.x() / m_direction.z() : 0.; }
47
49 return m_direction.z() != 0.
51 : 0.;
52}
53double MTStraightLine::b_x1() const {
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}
61
63 return std::hypot(m_position_error.x(), a_x1() * m_position_error.z(), m_position.z() * a_x1_error());
64}
65double MTStraightLine::a_x2() const { return (m_direction.z() == 0.0) ? 0. : m_direction.y() / m_direction.z(); }
67 return (m_direction.z() == 0)
68 ? 0.0
69 :
70
72}
73
74double MTStraightLine::b_x2() const {
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}
82
84 return std::hypot(m_position_error.y(), a_x2() * m_position_error.z(), m_position.z() * a_x2_error());
85}
86
87Amg::Vector3D MTStraightLine::pointOnLine(const double lambda) const { return m_position + lambda * m_direction; }
88
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}
119
120double MTStraightLine::distFromLine(const Amg::Vector3D& point) const {
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}
134void MTStraightLine::setChi2(double chi2) { m_chi2 = std::isnan(chi2) ? -1 : chi2; }
135double MTStraightLine::chi2() const { return m_chi2; }
136void MTStraightLine::setNumberOfTrackHits(unsigned int n_hits) { m_numTrkHits = n_hits; }
137unsigned int MTStraightLine::numberOfTrackHits() const { return m_numTrkHits; }
138
139double MTStraightLine::chi2PerDegreesOfFreedom() const { return m_chi2 / (m_numTrkHits > 2 ? m_numTrkHits - 2 : 0.01); }
140
#define endmsg
static Double_t a
Amg::Vector3D directionVector() const
get the direction vector of the straight line
MTStraightLine()
Default constructor: all internal parameters of the straight line are set to 0.
double distFromLine(const Amg::Vector3D &point) const
get the distance of point point from straight line
double b_x2() const
get the intercept of the straight line in the x2-x3 plane
double b_x1_error() const
get the error on the intercept of the straight line in the x1-x3 plane
const MdtHitVec & trackHits() const
Amg::Vector3D pointOnLine(const double lambda) const
get the point on the line for the given scale factor lambda, point=position_vector+lambda*direction_v...
double a_x2() const
get the slope of the straight line in the x2-x3 plane
Amg::Vector3D directionError() const
get the error on the direction vector of the straight line
double b_x1() const
get the intercept of the straight line in the x1-x3 plane
Amg::Vector3D positionVector() const
get the position vector of the straight line
Amg::Vector3D positionError() const
get the error on the position vector of the straight line
double chi2PerDegreesOfFreedom() const
Return chi2 / number of TrackHits - 2.
double a_x1() const
get the slope of the straight line in the x1-x3 plane
double b_x2_error() const
get the slope of the intercept of the straight line in the x2-x3 plane
MuonCalibSegment::MdtHitVec MdtHitVec
double a_x1_error() const
get the error on the slope of the straight line in the x1-x3 plane
void setUsedHits(const MdtHitVec &hits)
double signDistFrom(const MTStraightLine &h) const
get the signed distance of two lines (if both are parallel, dist>0)
double a_x2_error() const
get the error on the slope of the straight line in the x2-x3 plane
unsigned int numberOfTrackHits() const
void setChi2(double chi2)
Cache the chi2.
void setNumberOfTrackHits(unsigned int n_hits)
cache the number of track hits
singleton-like access to IMessageSvc via open function and helper
Eigen::Matrix< double, 3, 1 > Vector3D
IMessageSvc * getMessageSvc(bool quiet=false)
CscCalcPed - algorithm that finds the Cathode Strip Chamber pedestals from an RDO.
Definition dot.py:1