ATLAS Offline Software
Loading...
Searching...
No Matches
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
13namespace 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
double angle(const GeoTrf::Vector2D &a, const GeoTrf::Vector2D &b)
void rotat(double angle, bool bendplane)
double operator[](unsigned int i) const
Point & operator-=(const TransversePoint &p)
Point & operator+=(const TransversePoint &p)
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)