ATLAS Offline Software
Loading...
Searching...
No Matches
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
11namespace 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
TransversePoint & operator+=(const TransversePoint &tp)
TransversePoint & operator-=(const TransversePoint &tp)
Point operator*(double scalar, const Point &p)
std::ostream & operator<<(std::ostream &, const Beamline &)
Point operator+(const Point &lhs, const Point &rhs)
Point operator-(const Point &lhs, const Point &rhs)