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