Belle II Software  release-08-01-10
Vector3D.cc
1 /**************************************************************************
2  * basf2 (Belle II Analysis Software Framework) *
3  * Author: The Belle II Collaboration *
4  * *
5  * See git log for contributors and copyright holders. *
6  * This file is licensed under LGPL-3.0, see LICENSE.md. *
7  **************************************************************************/
8 #include <tracking/trackFindingCDC/geometry/Vector3D.h>
9 
10 #include <tracking/trackFindingCDC/geometry/Vector2D.h>
11 
12 #include <TVector3.h>
13 
14 #include <sstream>
15 #include <ostream>
16 
17 using namespace Belle2;
18 using namespace TrackFindingCDC;
19 
20 Vector3D::Vector3D(const TVector3& tVector3)
21  : m_xy(tVector3.X(), tVector3.Y())
22  , m_z(tVector3.Z())
23 {
24 }
25 
26 Vector3D::Vector3D(const B2Vector3D& b2Vector3)
27  : m_xy(b2Vector3.X(), b2Vector3.Y())
28  , m_z(b2Vector3.Z())
29 {
30 }
31 
32 Vector3D::Vector3D(const ROOT::Math::XYZVector& xyzVector3)
33  : m_xy(xyzVector3.X(), xyzVector3.Y())
34  , m_z(xyzVector3.Z())
35 {
36 }
37 
38 Vector3D& Vector3D::operator=(const TVector3& tVector3)
39 {
40  m_xy.setX(tVector3.X());
41  m_xy.setY(tVector3.Y());
42  m_z = tVector3.Z();
43  return *this;
44 }
45 
47 {
48  m_xy.setX(b2Vector3.X());
49  m_xy.setY(b2Vector3.Y());
50  m_z = b2Vector3.Z();
51  return *this;
52 }
53 
54 Vector3D& Vector3D::operator=(const ROOT::Math::XYZVector& xyzVector3)
55 {
56  m_xy.setX(xyzVector3.X());
57  m_xy.setY(xyzVector3.Y());
58  m_z = xyzVector3.Z();
59  return *this;
60 }
61 
62 Vector3D::operator const TVector3() const
63 {
64  return TVector3(x(), y(), z());
65 }
66 
67 Vector3D::operator const B2Vector3D() const
68 {
69  return B2Vector3D(x(), y(), z());
70 }
71 
72 Vector3D::operator const ROOT::Math::XYZVector() const
73 {
74  return ROOT::Math::XYZVector(x(), y(), z());
75 }
76 
77 std::ostream& TrackFindingCDC::operator<<(std::ostream& output, const Vector3D& vector3D)
78 {
79  return output << "Vector3D(" << vector3D.x() << "," << vector3D.y() << "," << vector3D.z() << ")";
80 }
81 
82 std::string Vector3D::__str__() const
83 {
84  std::stringstream sstream;
85  sstream << *this;
86  return sstream.str();
87 }
DataType Z() const
access variable Z (= .at(2) without boundary check)
Definition: B2Vector3.h:435
DataType X() const
access variable X (= .at(0) without boundary check)
Definition: B2Vector3.h:431
DataType Y() const
access variable Y (= .at(1) without boundary check)
Definition: B2Vector3.h:433
void setY(const double y)
Setter for the y coordinate.
Definition: Vector2D.h:622
void setX(const double x)
Setter for the x coordinate.
Definition: Vector2D.h:612
A three dimensional vector.
Definition: Vector3D.h:33
Vector3D & operator=(const TVector3 &tVector3)
Assignment translating from a TVector3 instance.
Definition: Vector3D.cc:38
std::string __str__() const
Output operator for python.
Definition: Vector3D.cc:82
Vector2D m_xy
Memory for the first and second coordinate available as a vector.
Definition: Vector3D.h:571
double x() const
Getter for the x coordinate.
Definition: Vector3D.h:472
double y() const
Getter for the y coordinate.
Definition: Vector3D.h:484
double m_z
Memory for the third coordinate.
Definition: Vector3D.h:574
double z() const
Getter for the z coordinate.
Definition: Vector3D.h:496
Vector3D()
Default constructor for ROOT compatibility.
Definition: Vector3D.h:37
std::ostream & operator<<(std::ostream &output, const IntervalOfValidity &iov)
B2Vector3< double > B2Vector3D
typedef for common usage with double
Definition: B2Vector3.h:516
Abstract base class for different kinds of events.