EICd
EIC data model
VectorXY.h
Go to the documentation of this file.
1 // AUTOMATICALLY GENERATED FILE - DO NOT EDIT
2 
3 #ifndef EICD_VectorXY_H
4 #define EICD_VectorXY_H
5 
6 #include <cmath>
7 #include <ostream>
8 
9 namespace eic {
10 
11 
12 class VectorXY {
13 public:
14  float x{}; ///< [mm] or [GeV]
15  float y{};
16 
17  VectorXY() : x{0}, y{0} {}
18  VectorXY(double xx, double yy) : x{static_cast<float>(xx)}, y{static_cast<float>(yy)} {}
19  float& operator[](unsigned i) {return *(&x + i);}
20  const float& operator[](unsigned i) const {return *(&x + i);}
21  float mag() const {return std::hypot(x, y);}
22  float r() const {return mag();}
23  float phi() const {return atan2(y, x);}
24  operator std::pair<float, float>() const {return {x, y};}
25  float dot(const VectorXY& rhs) const {return x*rhs.x + y*rhs.y;}
26  VectorXY add(const VectorXY& rhs) const {return {x+rhs.x, y+rhs.y};}
27  VectorXY subtract(const VectorXY& rhs) const {return {x-rhs.x, y-rhs.y};}
28  VectorXY scale(double f) const {return {f*x, f*y};}
29 
30 
31 };
32 
33 inline std::ostream& operator<<(std::ostream& o, const eic::VectorXY& value) {
34  o << value.x << " ";
35  o << value.y << " ";
36 
37  return o;
38 }
39 
40 } // namespace eic
41 
42 
43 
44 #endif
eic::operator<<
std::ostream & operator<<(std::ostream &o, const ConstBasicParticle &value)
Definition: BasicParticle.cc:102
eic::VectorXY::y
float y
Definition: VectorXY.h:15
eic::VectorXY::VectorXY
VectorXY()
Definition: VectorXY.h:17
eic
Definition: BasicParticle.cc:13
eic::VectorXY::operator[]
const float & operator[](unsigned i) const
Definition: VectorXY.h:20
eic::VectorXY::mag
float mag() const
Definition: VectorXY.h:21
eic::VectorXY::x
float x
[mm] or [GeV]
Definition: VectorXY.h:14
eic::VectorXY::phi
float phi() const
Definition: VectorXY.h:23
eic::VectorXY::VectorXY
VectorXY(double xx, double yy)
Definition: VectorXY.h:18
eic::VectorXY::r
float r() const
Definition: VectorXY.h:22
eic::VectorXY::dot
float dot(const VectorXY &rhs) const
Definition: VectorXY.h:25
eic::VectorXY
Definition: VectorXY.h:12
eic::VectorXY::subtract
VectorXY subtract(const VectorXY &rhs) const
Definition: VectorXY.h:27
eic::VectorXY::scale
VectorXY scale(double f) const
Definition: VectorXY.h:28
eic::VectorXY::operator[]
float & operator[](unsigned i)
Definition: VectorXY.h:19
eic::VectorXY::add
VectorXY add(const VectorXY &rhs) const
Definition: VectorXY.h:26