ATLAS Offline Software
Loading...
Searching...
No Matches
Line.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef DCMATH_LINE_H
6#define DCMATH_LINE_H
7
8#include <cmath>
9#include <iostream>
10#include <ostream>
11
14
15namespace TrkDriftCircleMath {
16
17 class Line {
18 public:
22 Line(const LocVec2D& pos, const LocVec2D& dir) : Line{pos, std::atan2(dir.y(), dir.x())} {}
23
24 Line(const LocVec2D& pos, double phi) : m_phi{phi}, m_pos{pos} { updateLocalParameters(); }
25
26 Line(LocVec2D&& pos, const LocVec2D& dir) : Line{pos, std::atan2(dir.y(), dir.x())} {}
27
28 Line(LocVec2D&& pos, double phi) : m_phi{phi}, m_pos{pos} { updateLocalParameters(); }
29
30 Line(double x0, double y0, double phi) : m_phi{phi}, m_loc_pos{x0, y0} { updateGlobalParameters(); }
31
32 ~Line() = default;
33
35 void set(const LocVec2D& pos, const LocVec2D& dir) { set(pos, std::atan2(dir.y(), dir.x())); }
36
37 void set(const LocVec2D& pos, double phi) {
38 m_phi = phi;
39 m_pos = pos;
41 }
42
43 void set(double x0, double y0, double phi) {
44 m_phi = phi;
45 m_loc_pos.set(x0, y0);
47 }
48
50 RotPhi rot(m_phi);
51 m_dir.set(rot.cosphi(), rot.sinphi());
52 m_loc_pos = (rot * m_pos);
53 }
54
56 RotPhi rot{-m_phi};
57 m_pos = rot * m_loc_pos;
59 m_dir.set(rot.cosphi(), -rot.sinphi());
60 }
61
62 double phi() const { return m_phi; }
63 double x0() const { return m_loc_pos.x(); }
64 double y0() const { return m_loc_pos.y(); }
65 const LocVec2D& position() const { return m_pos; }
66 const LocVec2D& direction() const { return m_dir; }
67
68 private:
69 double m_phi{0};
70 LocVec2D m_pos{0., 0.};
71 LocVec2D m_dir{0., 0.};
73 };
74
75 std::ostream& operator<<(std::ostream& os, const TrkDriftCircleMath::Line& l);
76
77} // namespace TrkDriftCircleMath
78
79#endif
#define y
#define x
const LocVec2D & direction() const
Definition Line.h:66
double x0() const
Definition Line.h:63
Line(LocVec2D &&pos, double phi)
Definition Line.h:28
const LocVec2D & position() const
Definition Line.h:65
Line(const LocVec2D &pos, const LocVec2D &dir)
Constructors starting from the global parameters.
Definition Line.h:22
Line(LocVec2D &&pos, const LocVec2D &dir)
Definition Line.h:26
void set(const LocVec2D &pos, const LocVec2D &dir)
set methods to reduce copying of data
Definition Line.h:35
double phi() const
Definition Line.h:62
Line(const LocVec2D &pos, double phi)
Definition Line.h:24
void updateGlobalParameters()
Definition Line.h:55
void set(const LocVec2D &pos, double phi)
Definition Line.h:37
void updateLocalParameters()
Definition Line.h:49
Line(double x0, double y0, double phi)
Definition Line.h:30
double y0() const
Definition Line.h:64
void set(double x0, double y0, double phi)
Definition Line.h:43
Implementation of 2 dimensional vector class.
Definition LocVec2D.h:16
double cosphi() const
Definition RotPhi.h:25
double sinphi() const
Definition RotPhi.h:26
Function object to check whether two Segments are sub/super sets or different.
std::ostream & operator<<(std::ostream &os, const TrkDriftCircleMath::ClusterId &id)
Definition ClusterId.cxx:9
STL namespace.