ATLAS Offline Software
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 
15 namespace 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 
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
TrkDriftCircleMath::Line::Line
Line(const LocVec2D &pos, double phi)
Definition: Line.h:24
TrkDriftCircleMath::Line::position
const LocVec2D & position() const
Definition: Line.h:65
TrkDriftCircleMath::Line::Line
Line(LocVec2D &&pos, const LocVec2D &dir)
Definition: Line.h:26
TrkDriftCircleMath::RotPhi::cosphi
double cosphi() const
Definition: RotPhi.h:25
TrkDriftCircleMath::Line::m_dir
LocVec2D m_dir
Definition: Line.h:71
TrkDriftCircleMath::Line::set
void set(const LocVec2D &pos, const LocVec2D &dir)
set methods to reduce copying of data
Definition: Line.h:35
TrkDriftCircleMath::Line::set
void set(const LocVec2D &pos, double phi)
Definition: Line.h:37
TrkDriftCircleMath::RotPhi
Definition: RotPhi.h:14
TrkDriftCircleMath
Function object to check whether two Segments are sub/super sets or different.
Definition: IMdtSegmentFinder.h:13
UploadAMITag.l
list l
Definition: UploadAMITag.larcaf.py:158
TrkDriftCircleMath::Line::m_phi
double m_phi
Definition: Line.h:69
TrkDriftCircleMath::LocVec2D::x
double x() const
Returns the x coordinate of the vector.
Definition: LocVec2D.h:27
TrkDriftCircleMath::Line::y0
double y0() const
Definition: Line.h:64
TrkDriftCircleMath::RotPhi::sinphi
double sinphi() const
Definition: RotPhi.h:26
TrkDriftCircleMath::LocVec2D::set
void set(const LocVec2D &vec)
Setter function using another vector.
Definition: LocVec2D.h:32
TrkDriftCircleMath::LocVec2D
Implementation of 2 dimensional vector class.
Definition: LocVec2D.h:16
TrkDriftCircleMath::Line
Definition: Line.h:17
TrkDriftCircleMath::operator<<
std::ostream & operator<<(std::ostream &os, const TrkDriftCircleMath::ClusterId &id)
Definition: ClusterId.cxx:9
TrkDriftCircleMath::Line::Line
Line(const LocVec2D &pos, const LocVec2D &dir)
Constructors starting from the global parameters.
Definition: Line.h:22
TrkDriftCircleMath::Line::x0
double x0() const
Definition: Line.h:63
TrkDriftCircleMath::LocVec2D::y
double y() const
Returns the y coordinate of the vector.
Definition: LocVec2D.h:29
TrkDriftCircleMath::Line::Line
Line(double x0, double y0, double phi)
Definition: Line.h:30
ReadFromCoolCompare.os
os
Definition: ReadFromCoolCompare.py:231
beamspotman.dir
string dir
Definition: beamspotman.py:623
TrkDriftCircleMath::Line::direction
const LocVec2D & direction() const
Definition: Line.h:66
TrkDriftCircleMath::Line::m_loc_pos
LocVec2D m_loc_pos
Definition: Line.h:72
TrkDriftCircleMath::Line::Line
Line(LocVec2D &&pos, double phi)
Definition: Line.h:28
TrkDriftCircleMath::Line::~Line
~Line()=default
TrkDriftCircleMath::Line::updateLocalParameters
void updateLocalParameters()
Definition: Line.h:49
TrkDriftCircleMath::Line::updateGlobalParameters
void updateGlobalParameters()
Definition: Line.h:55
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
TrkDriftCircleMath::Line::set
void set(double x0, double y0, double phi)
Definition: Line.h:43
TrkDriftCircleMath::Line::phi
double phi() const
Definition: Line.h:62
RotPhi.h
LocVec2D.h
TrkDriftCircleMath::Line::m_pos
LocVec2D m_pos
Definition: Line.h:70