ATLAS Offline Software
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>
10 namespace FPTracker{
12  }
13  TransversePoint::TransversePoint(double x, double y):m_x(x), m_y(y){
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 }
FPTracker::TransversePoint::str
std::string str() const
Definition: FPTracker/src/TransversePoint.cxx:66
python.trigbs_prescaleL1.ost
ost
Definition: trigbs_prescaleL1.py:104
FPTracker::operator<<
std::ostream & operator<<(std::ostream &os, const Beamline &bl)
Definition: FPTracker/src/Beamline.cxx:163
FPTracker::TransversePoint::mag2
double mag2() const
Definition: FPTracker/src/TransversePoint.cxx:25
FPTracker::TransversePoint::mag
double mag() const
Definition: FPTracker/src/TransversePoint.cxx:27
FPTracker::TransversePoint::m_y
double m_y
Definition: FPTracker/FPTracker/TransversePoint.h:28
FPTracker::operator*
Point operator*(double, const Point &lhs)
Definition: FPTracker/src/Point.cxx:123
TransversePoint.h
FPTracker::TransversePoint::TransversePoint
TransversePoint()
Definition: FPTracker/src/TransversePoint.cxx:11
x
#define x
FPTracker::operator+
Point operator+(const Point &lhs, const Point &rhs)
Definition: FPTracker/src/Point.cxx:98
FPTracker::TransversePoint::m_x
double m_x
Definition: FPTracker/FPTracker/TransversePoint.h:27
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
FPTracker::TransversePoint::operator-=
TransversePoint & operator-=(const TransversePoint &rhs)
Definition: FPTracker/src/TransversePoint.cxx:61
FPTracker::TransversePoint::operator+=
TransversePoint & operator+=(const TransversePoint &rhs)
Definition: FPTracker/src/TransversePoint.cxx:56
FPTracker::TransversePoint::operator*=
TransversePoint & operator*=(double)
Definition: FPTracker/src/TransversePoint.cxx:19
lumiFormat.i
int i
Definition: lumiFormat.py:85
ReadFromCoolCompare.os
os
Definition: ReadFromCoolCompare.py:231
FPTracker::TransversePoint::x
double x() const
Definition: FPTracker/src/TransversePoint.cxx:16
y
#define y
FPTracker::operator-
Point operator-(const Point &lhs, const Point &rhs)
Definition: FPTracker/src/Point.cxx:103
FPTracker
Definition: FPTracker/FPTracker/Beamline.h:12
FPTracker::TransversePoint::y
double y() const
Definition: FPTracker/src/TransversePoint.cxx:17
FPTracker::TransversePoint::operator[]
double operator[](unsigned int) const
Definition: FPTracker/src/TransversePoint.cxx:32
FPTracker::TransversePoint
Definition: FPTracker/FPTracker/TransversePoint.h:12