ATLAS Offline Software
Loading...
Searching...
No Matches
FPTracker/src/TransversePoint.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3*/
4
6#include <sstream>
7#include <cmath>
8#include <iomanip>
9#include <stdexcept>
10namespace FPTracker{
14 }
15
16 double TransversePoint::x() const {return m_x;}
17 double TransversePoint::y() const {return m_y;}
18
20 m_x *= scalar;
21 m_y *= scalar;
22 return *this;
23 }
24
25 double TransversePoint::mag2() const {return m_x*m_x+m_y*m_y;}
26
27 double TransversePoint::mag() const
28 {
29 return std::sqrt(mag2());
30 }
31
32 double TransversePoint::operator[](unsigned int i) const
33 {
34 if (i>1)
35 {
36 std::ostringstream ost;
37 ost<<"TranversePoint index out of range: "<<i<<'\n';
38 throw std::range_error(ost.str());
39 }
40 if(i == 0){return m_x;}
41 return m_y;
42 }
43
44 double& TransversePoint::operator[](unsigned int i){
45 if ( i>1)
46 {
47 std::ostringstream ost;
48 ost<<"TranversePoint index out of range: "<<i<<'\n';
49 throw std::range_error(ost.str());
50 }
51
52 if(i == 0){return m_x;}
53 return m_y;
54 }
55
57 m_x += rhs.m_x;
58 m_y += rhs.m_y;
59 return *this;
60 }
62 m_x -= rhs.m_x;
63 m_y -= rhs.m_y;
64 return *this;
65 }
66 std::string TransversePoint::str() const{
67 std::ostringstream ost;
68 ost<<std::setprecision(3)<<std::scientific<<"x\t"<<m_x<<" y\t"<<m_y;
69 return ost.str();
70 }
72 TransversePoint point(lhs);
73 return point += rhs;
74 }
75
77 TransversePoint point(lhs);
78 return point -= rhs;
79 }
80 std::ostream& operator<<(std::ostream& os, const TransversePoint& p){
81 os<<p.str();
82 return os;
83 }
84
85 TransversePoint operator*(double scalar, const TransversePoint& point) {
86 TransversePoint p = point;
87 return p*=scalar;
88 }
89
90
91}
TransversePoint & operator-=(const TransversePoint &rhs)
TransversePoint & operator+=(const TransversePoint &rhs)
Point operator-(const Point &lhs, const Point &rhs)
Point operator+(const Point &lhs, const Point &rhs)
Point operator*(double, const Point &lhs)
std::ostream & operator<<(std::ostream &os, const Beamline &bl)