ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
ForwardDetectors
FPTracker
src
FPTracker/src/Point.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
FPTracker/Point.h
"
6
#include "
FPTracker/TransversePoint.h
"
7
#include <sstream>
8
#include <cmath>
9
#include <stdexcept>
10
#include <iomanip>
11
namespace
FPTracker
{
12
Point::Point
():
m_x
(0.),
m_y
(0.),
m_z
(0.){
13
}
14
Point::Point
(
double
x
,
double
y
,
double
z
):
m_x
(
x
),
m_y
(
y
),
m_z
(
z
){
15
}
16
17
double
Point::x
()
const
{
return
m_x
;}
18
double
Point::y
()
const
{
return
m_y
;}
19
double
Point::z()
const
{
return
m_z
;}
20
21
double
Point::perp2()
const
{
return
m_x
*
m_x
+
m_y
*
m_y
;}
22
23
TransversePoint
Point::transverse()
const
{
return
TransversePoint
(
m_x
,
m_y
);}
24
25
Point
& Point::operator*=(
double
scalar) {
26
m_x
*= scalar;
27
m_y
*= scalar;
28
m_z
*= scalar;
29
return
*
this
;
30
}
31
32
double
Point::mag2()
const
{
return
m_x
*
m_x
+
m_y
*
m_y
+
m_z
*
m_z
;}
33
34
double
Point::mag()
const
{
35
return
std::sqrt(
mag2
());
36
}
37
38
double
Point::operator[](
unsigned
int
i)
const
{
39
40
if
( i>2 )
41
{
42
std::ostringstream ost;
43
ost<<
"TranversePoint index out of range: "
<<i<<
'\n'
;
44
throw
std::range_error(ost.str());
45
}
46
47
if
(i == 0){
return
m_x
;}
48
if
(i == 1){
return
m_y
;}
49
return
m_z
;
50
}
51
52
double
& Point::operator[](
unsigned
int
i){
53
54
if
( i>2 )
55
{
56
std::ostringstream ost;
57
ost<<
"TranversePoint index out of range: "
<<i<<
'\n'
;
58
throw
std::range_error(ost.str());
59
}
60
61
if
(i == 0){
return
m_x
;}
62
if
(i == 1){
return
m_y
;}
63
return
m_z
;
64
}
65
66
Point
& Point::operator+=(
const
Point
& rhs){
67
m_x
+= rhs.
m_x
;
68
m_y
+= rhs.
m_y
;
69
m_z
+= rhs.
m_z
;
70
return
*
this
;
71
}
72
73
Point
& Point::operator-=(
const
Point
& rhs){
74
m_x
-= rhs.
m_x
;
75
m_y
-= rhs.
m_y
;
76
m_z
-= rhs.
m_z
;
77
return
*
this
;
78
}
79
80
Point
& Point::operator+=(
const
TransversePoint
& rhs){
81
m_x
+= rhs.
x
();
82
m_y
+= rhs.
y
();
83
return
*
this
;
84
}
85
86
Point
& Point::operator-=(
const
TransversePoint
& rhs){
87
m_x
-= rhs.
x
();
88
m_y
-= rhs.
y
();
89
return
*
this
;
90
}
91
92
std::string Point::str()
const
{
93
std::ostringstream ost;
94
ost<<std::setprecision(3)<<std::scientific<<
"x\t"
<<
m_x
<<
" y\t"
<<
m_y
<<
" z\t"
<<
m_z
;
95
return
ost.str();
96
}
97
98
Point
operator+
(
const
Point
& lhs,
const
Point
& rhs){
99
Point
point(lhs);
100
return
point += rhs;
101
}
102
103
Point
operator-
(
const
Point
& lhs,
const
Point
& rhs){
104
Point
point(lhs);
105
return
point -= rhs;
106
}
107
108
Point
operator+
(
const
Point
& lhs,
const
TransversePoint
& rhs){
109
Point
point(lhs);
110
return
point += rhs;
111
}
112
113
Point
operator-
(
const
Point
& lhs,
const
TransversePoint
& rhs){
114
Point
point(lhs);
115
return
point -= rhs;
116
}
117
118
std::ostream&
operator<<
(std::ostream& os,
const
Point
& p){
119
os<<p.str();
120
return
os;
121
}
122
123
Point
operator*
(
double
scalar,
const
Point
& point) {
124
Point
p = point;
125
return
p*=scalar;
126
}
127
128
129
}
operator*
ElementConstReference operator*() const
Return a reference to the referenced element.
Point.h
TransversePoint.h
FPTracker::Point
Definition
FPTracker/FPTracker/Point.h:14
FPTracker::Point::mag2
double mag2() const
Definition
FPTracker/src/Point.cxx:32
FPTracker::Point::Point
Point()
Definition
FPTracker/src/Point.cxx:12
FPTracker::Point::m_y
double m_y
Definition
FPTracker/FPTracker/Point.h:35
FPTracker::Point::y
double y() const
Definition
FPTracker/src/Point.cxx:18
FPTracker::Point::x
double x() const
Definition
FPTracker/src/Point.cxx:17
FPTracker::Point::m_x
double m_x
Definition
FPTracker/FPTracker/Point.h:34
FPTracker::Point::z
double z() const
Definition
FPTracker/src/Point.cxx:19
FPTracker::Point::m_z
double m_z
Definition
FPTracker/FPTracker/Point.h:36
FPTracker::TransversePoint
Definition
FPTracker/FPTracker/TransversePoint.h:12
FPTracker::TransversePoint::y
double y() const
Definition
FPTracker/src/TransversePoint.cxx:17
FPTracker::TransversePoint::x
double x() const
Definition
FPTracker/src/TransversePoint.cxx:16
FPTracker
Definition
FPTracker/FPTracker/Beamline.h:12
FPTracker::operator-
Point operator-(const Point &lhs, const Point &rhs)
Definition
FPTracker/src/Point.cxx:103
FPTracker::operator+
Point operator+(const Point &lhs, const Point &rhs)
Definition
FPTracker/src/Point.cxx:98
FPTracker::operator<<
std::ostream & operator<<(std::ostream &os, const Beamline &bl)
Definition
FPTracker/src/Beamline.cxx:163
ChargedTracksWeightFilter::Spline::Point::y
double y
Definition
ChargedTracksWeightFilter.h:34
ChargedTracksWeightFilter::Spline::Point::Point
Point(double x_, double y_, double slope_)
Single point and slope to next point.
Definition
ChargedTracksWeightFilter.h:30
ChargedTracksWeightFilter::Spline::Point::x
double x
Definition
ChargedTracksWeightFilter.h:33
Generated on
for ATLAS Offline Software by
1.17.0