ATLAS Offline Software
ForwardTracker/ForwardTracker/Point.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_POINT_H
6 #define FORWARDTRACKER_POINT_H
7 
8 #include "TransversePoint.h"
9 
10 #include <sstream>
11 #include <iomanip>
12 
13 namespace ForwardTracker {
14 
15  class Point {
16 
17  public:
18 
19  Point();
20  Point(double, double, double);
21 
22  double x() const { return m_x; }
23  double y() const { return m_y; }
24  double z() const { return m_z; }
25  double perp2() const { return m_x*m_x + m_y*m_y; }
26  double mag2() const { return m_x*m_x + m_y*m_y + m_z*m_z; }
27  double mag() const { return std::sqrt(mag2()); }
29 
30  Point& operator*=(double scalar) { m_x *= scalar; m_y *= scalar; m_z *= scalar; return *this; }
31  Point& operator+=(const Point& p) { m_x += p.x(); m_y += p.y(); m_z += p.z(); return *this; }
32  Point& operator-=(const Point& p) { m_x -= p.x(); m_y -= p.y(); m_z -= p.z(); return *this; }
33  Point& operator+=(const TransversePoint& p) { m_x += p.x(); m_y += p.y(); return *this; }
34  Point& operator-=(const TransversePoint& p) { m_x -= p.x(); m_y -= p.y(); return *this; }
35 
36  double operator[](unsigned int i) const { checkIndex(i); if (i == 0) return m_x; if (i == 1) return m_y; return m_z; }
37  double& operator[](unsigned int i) { checkIndex(i); if (i == 0) return m_x; if (i == 1) return m_y; return m_z; }
38 
39  void rotat(double angle, bool bendplane);
40 
41  std::string str() const;
42 
43  private:
44 
45  void checkIndex(unsigned int i) const { if (i>2) throw std::range_error("Index of Point is out of range"); }
46 
47  double m_x;
48  double m_y;
49  double m_z;
50  };
51 
52  Point operator*(double scalar, const Point& p);
53  Point operator+(const Point& lhs, const Point& rhs);
54  Point operator-(const Point& lhs, const Point& rhs);
55  Point operator+(const Point& lhs, const TransversePoint& rhs);
56  Point operator-(const Point& lhs, const TransversePoint& rhs);
57 
58  std::ostream& operator<<(std::ostream&, const Point&);
59 }
60 
61 #endif
ForwardTracker::operator-
Point operator-(const Point &lhs, const Point &rhs)
Definition: ForwardTracker/src/Point.cxx:36
ForwardTracker::Point::m_x
double m_x
Definition: ForwardTracker/ForwardTracker/Point.h:47
ForwardTracker::Point::y
double y() const
Definition: ForwardTracker/ForwardTracker/Point.h:23
ForwardTracker::Point::mag2
double mag2() const
Definition: ForwardTracker/ForwardTracker/Point.h:26
TransversePoint.h
ForwardTracker::Point
Definition: ForwardTracker/ForwardTracker/Point.h:15
ForwardTracker::operator<<
std::ostream & operator<<(std::ostream &, const Beamline &)
Definition: ForwardTracker/src/Beamline.cxx:105
ForwardTracker::Point::m_y
double m_y
Definition: ForwardTracker/ForwardTracker/Point.h:48
ForwardTracker::Point::z
double z() const
Definition: ForwardTracker/ForwardTracker/Point.h:24
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
ForwardTracker::Point::m_z
double m_z
Definition: ForwardTracker/ForwardTracker/Point.h:49
lumiFormat.i
int i
Definition: lumiFormat.py:85
ForwardTracker::Point::perp2
double perp2() const
Definition: ForwardTracker/ForwardTracker/Point.h:25
angle
double angle(const GeoTrf::Vector2D &a, const GeoTrf::Vector2D &b)
Definition: TRTDetectorFactory_Full.cxx:73
ForwardTracker::Point::str
std::string str() const
Definition: ForwardTracker/src/Point.cxx:21
ForwardTracker::TransversePoint
Definition: ForwardTracker/ForwardTracker/TransversePoint.h:13
ForwardTracker::operator*
Point operator*(double scalar, const Point &p)
Definition: ForwardTracker/src/Point.cxx:34
ForwardTracker::Point::operator*=
Point & operator*=(double scalar)
Definition: ForwardTracker/ForwardTracker/Point.h:30
ForwardTracker::Point::transverse
TransversePoint transverse() const
Definition: ForwardTracker/ForwardTracker/Point.h:28
ForwardTracker::Point::x
double x() const
Definition: ForwardTracker/ForwardTracker/Point.h:22
ForwardTracker::Point::operator-=
Point & operator-=(const Point &p)
Definition: ForwardTracker/ForwardTracker/Point.h:32
ForwardTracker::Point::mag
double mag() const
Definition: ForwardTracker/ForwardTracker/Point.h:27
ForwardTracker::Point::operator+=
Point & operator+=(const Point &p)
Definition: ForwardTracker/ForwardTracker/Point.h:31
ForwardTracker::Point::operator-=
Point & operator-=(const TransversePoint &p)
Definition: ForwardTracker/ForwardTracker/Point.h:34
ForwardTracker::Point::rotat
void rotat(double angle, bool bendplane)
Definition: ForwardTracker/src/Point.cxx:12
ForwardTracker::Point::operator[]
double operator[](unsigned int i) const
Definition: ForwardTracker/ForwardTracker/Point.h:36
ForwardTracker::operator+
Point operator+(const Point &lhs, const Point &rhs)
Definition: ForwardTracker/src/Point.cxx:35
ForwardTracker::Point::operator+=
Point & operator+=(const TransversePoint &p)
Definition: ForwardTracker/ForwardTracker/Point.h:33
ForwardTracker::Point::Point
Point()
Definition: ForwardTracker/src/Point.cxx:9
ForwardTracker::Point::checkIndex
void checkIndex(unsigned int i) const
Definition: ForwardTracker/ForwardTracker/Point.h:45
ForwardTracker
Definition: ForwardTracker/ForwardTracker/Beamline.h:12
ForwardTracker::Point::operator[]
double & operator[](unsigned int i)
Definition: ForwardTracker/ForwardTracker/Point.h:37