ATLAS Offline Software
ForwardTracker/ForwardTracker/TransversePoint.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef FORWARDTRACKER_TRANSVERSEPOINT_H
6 #define FORWARDTRACKER_TRANSVERSEPOINT_H
7 
8 #include <stdexcept>
9 #include <cmath>
10 
11 namespace ForwardTracker {
12 
14 
15  public:
16 
18  TransversePoint(double, double);
19 
20  double x() const { return m_x; }
21  double y() const { return m_y; }
22  double mag2() const { return m_x*m_x + m_y*m_y; }
23  double mag() const { return std::sqrt(mag2()); }
24 
25  TransversePoint& operator*=(double scalar) { m_x *= scalar; m_y *= scalar; return *this; }
26  TransversePoint& operator+=(const TransversePoint& tp) { m_x += tp.x(); m_y += tp.y(); return *this; }
27  TransversePoint& operator-=(const TransversePoint& tp) { m_x -= tp.x(); m_y -= tp.y(); return *this; }
28 
29  double operator[](unsigned int i) const { checkIndex(i); if (i == 0) return m_x; return m_y; }
30  double& operator[](unsigned int i) { checkIndex(i); if (i == 0) return m_x; return m_y; }
31 
32  std::string str() const;
33 
34  private:
35 
36  void checkIndex(unsigned int i) const { if (i>1) throw std::range_error("Index of TransversePoint is out of range"); }
37 
38  double m_x;
39  double m_y;
40  };
41 
45 
46  std::ostream& operator<<(std::ostream&, const TransversePoint&);
47 }
48 #endif
ForwardTracker::TransversePoint::operator+=
TransversePoint & operator+=(const TransversePoint &tp)
Definition: ForwardTracker/ForwardTracker/TransversePoint.h:26
ForwardTracker::operator-
Point operator-(const Point &lhs, const Point &rhs)
Definition: ForwardTracker/src/Point.cxx:36
ForwardTracker::TransversePoint::checkIndex
void checkIndex(unsigned int i) const
Definition: ForwardTracker/ForwardTracker/TransversePoint.h:36
ForwardTracker::TransversePoint::y
double y() const
Definition: ForwardTracker/ForwardTracker/TransversePoint.h:21
ForwardTracker::TransversePoint::m_x
double m_x
Definition: ForwardTracker/ForwardTracker/TransversePoint.h:38
ForwardTracker::TransversePoint::mag2
double mag2() const
Definition: ForwardTracker/ForwardTracker/TransversePoint.h:22
ParticleTest.tp
tp
Definition: ParticleTest.py:25
ForwardTracker::TransversePoint::mag
double mag() const
Definition: ForwardTracker/ForwardTracker/TransversePoint.h:23
ForwardTracker::operator<<
std::ostream & operator<<(std::ostream &, const Beamline &)
Definition: ForwardTracker/src/Beamline.cxx:105
lumiFormat.i
int i
Definition: lumiFormat.py:85
ForwardTracker::TransversePoint
Definition: ForwardTracker/ForwardTracker/TransversePoint.h:13
ForwardTracker::operator*
Point operator*(double scalar, const Point &p)
Definition: ForwardTracker/src/Point.cxx:34
ForwardTracker::TransversePoint::operator-=
TransversePoint & operator-=(const TransversePoint &tp)
Definition: ForwardTracker/ForwardTracker/TransversePoint.h:27
ForwardTracker::TransversePoint::operator[]
double & operator[](unsigned int i)
Definition: ForwardTracker/ForwardTracker/TransversePoint.h:30
ForwardTracker::TransversePoint::operator[]
double operator[](unsigned int i) const
Definition: ForwardTracker/ForwardTracker/TransversePoint.h:29
ForwardTracker::TransversePoint::x
double x() const
Definition: ForwardTracker/ForwardTracker/TransversePoint.h:20
ForwardTracker::TransversePoint::str
std::string str() const
Definition: ForwardTracker/src/TransversePoint.cxx:15
ForwardTracker::operator+
Point operator+(const Point &lhs, const Point &rhs)
Definition: ForwardTracker/src/Point.cxx:35
ForwardTracker::TransversePoint::m_y
double m_y
Definition: ForwardTracker/ForwardTracker/TransversePoint.h:39
ForwardTracker::TransversePoint::TransversePoint
TransversePoint()
Definition: ForwardTracker/src/TransversePoint.cxx:12
ForwardTracker
Definition: ForwardTracker/ForwardTracker/Beamline.h:12
ForwardTracker::TransversePoint::operator*=
TransversePoint & operator*=(double scalar)
Definition: ForwardTracker/ForwardTracker/TransversePoint.h:25