Belle II Software  release-08-01-10
B2Vector3< DataType > Class Template Reference

A fast and root compatible alternative to TVector3. More...

#include <B2Vector3.h>

Public Types

typedef DataType value_type
 storage type of the vector
 

Public Member Functions

 B2Vector3 (void)
 empty Constructor sets everything to 0
 
 B2Vector3 (const DataType xVal, const DataType yVal, const DataType zVal)
 Constructor expecting 3 coordinates.
 
 B2Vector3 (const DataType(&coords)[3])
 Constructor using a reference.
 
 B2Vector3 (const DataType(*coords)[3])
 Constructor using a pointer.
 
 B2Vector3 (const TVector3 &tVec3)
 Constructor expecting a TVector3.
 
 B2Vector3 (const TVector3 *tVec3)
 Constructor expecting a pointer to a TVector3.
 
 B2Vector3 (const B2Vector3< DataType > &b2Vec3)
 Constructor expecting a B2Vector3 of same type.
 
 B2Vector3 (const B2Vector3< DataType > *b2Vec3)
 Constructor expecting a pointer to a B2Vector3.
 
template<typename OtherType >
 B2Vector3 (const B2Vector3< OtherType > &b2Vec3)
 Constructor expecting a B2Vector3 of different type.
 
template<typename OtherType >
 B2Vector3 (const B2Vector3< OtherType > *b2Vec3)
 Constructor expecting a pointer to a B2Vector3 of different type.
 
 B2Vector3 (const ROOT::Math::XYZVector &xyzVec)
 Constructor expecting a XYZVector.
 
 B2Vector3 (const ROOT::Math::XYZVector *xyzVec)
 Constructor expecting a pointer to a XYZVector.
 
DataType operator() (unsigned i) const
 member access without boundary check
 
DataType operator[] (unsigned i) const
 member access without boundary check
 
DataType & operator() (unsigned i)
 member access without boundary check
 
DataType & operator[] (unsigned i)
 member access without boundary check
 
B2Vector3< DataType > & operator= (const B2Vector3< DataType > &b)
 Assignment via B2Vector3.
 
B2Vector3< DataType > & operator= (const TVector3 &b)
 Assignment via TVector3.
 
B2Vector3< DataType > & operator= (const ROOT::Math::XYZVector &b)
 Assignment via XYZVector.
 
 operator TVector3 () const
 type conversion in TVector3
 
 operator ROOT::Math::XYZVector () const
 type conversion in ROOT::Math::XYZVector
 
bool operator== (const B2Vector3< DataType > &b) const
 Comparison for equality with a B2Vector3.
 
bool operator== (const TVector3 &b) const
 Comparison for equality with a TVector3.
 
bool operator== (const ROOT::Math::XYZVector &b) const
 Comparison for equality with a XYZVector.
 
bool operator!= (const B2Vector3< DataType > &b) const
 Comparison != with a B2Vector3.
 
bool operator!= (const TVector3 &b) const
 Comparison != with a TVector3.
 
bool operator!= (const ROOT::Math::XYZVector &b) const
 Comparison != with a XYZVector.
 
B2Vector3< DataType > & operator+= (const B2Vector3< DataType > &b)
 addition
 
B2Vector3< DataType > & operator-= (const B2Vector3< DataType > &b)
 subtraction
 
B2Vector3< DataType > & operator*= (DataType a)
 scaling with real numbers More...
 
B2Vector3< DataType > operator- () const
 unary minus
 
B2Vector3< DataType > operator+ (const B2Vector3< DataType > &b) const
 Addition of 3-vectors.
 
B2Vector3< DataType > operator- (const B2Vector3< DataType > &b) const
 Subtraction of 3-vectors.
 
B2Vector3< DataType > operator* (DataType a) const
 Scaling of 3-vectors with a real number.
 
B2Vector3< DataType > operator/ (DataType a) const
 Scaling of 3-vectors with a real number.
 
DataType operator* (const B2Vector3< DataType > &b) const
 Scalar product of 3-vectors.
 
DataType Phi () const
 The azimuth angle. More...
 
DataType Theta () const
 The polar angle.
 
DataType CosTheta () const
 Cosine of the polar angle.
 
DataType Mag2 () const
 The magnitude squared (rho^2 in spherical coordinate system).
 
DataType Mag () const
 The magnitude (rho in spherical coordinate system).
 
void SetPhi (DataType phi)
 Set phi keeping mag and theta constant.
 
void SetTheta (DataType theta)
 Set theta keeping mag and phi constant.
 
void SetMag (DataType mag)
 Set magnitude keeping theta and phi constant.
 
DataType Perp2 () const
 The transverse component squared (R^2 in cylindrical coordinate system).
 
DataType Pt () const
 The transverse component (R in cylindrical coordinate system).
 
DataType Perp () const
 The transverse component (R in cylindrical coordinate system).
 
void SetPerp (DataType r)
 Set the transverse component keeping phi and z constant.
 
DataType Perp2 (const B2Vector3< DataType > &axis) const
 The transverse component w.r.t. More...
 
DataType Pt (const B2Vector3< DataType > &axis) const
 The transverse component w.r.t. More...
 
DataType Perp (const B2Vector3< DataType > &axis) const
 The transverse component w.r.t. More...
 
DataType DeltaPhi (const B2Vector3< DataType > &v) const
 returns phi in the interval [-PI,PI)
 
DataType DeltaR (const B2Vector3< DataType > &v) const
 return deltaR with respect to input-vector
 
DataType DrEtaPhi (const B2Vector3< DataType > &v) const
 return DrEtaPhi with respect to input-vector
 
void SetMagThetaPhi (DataType mag, DataType theta, DataType phi)
 setter with mag, theta, phi
 
B2Vector3< DataType > Unit () const
 Unit vector parallel to this.
 
B2Vector3< DataType > Orthogonal () const
 Vector orthogonal to this one.
 
DataType Dot (const B2Vector3< DataType > &p) const
 Scalar product.
 
B2Vector3< DataType > Cross (const B2Vector3< DataType > &p) const
 Cross product.
 
DataType Angle (const B2Vector3< DataType > &q) const
 The angle w.r.t. More...
 
DataType PseudoRapidity () const
 Returns the pseudo-rapidity, i.e. More...
 
DataType Eta () const
 Returns the pseudo-rapidity.
 
void RotateX (DataType angle)
 Rotates the B2Vector3 around the x-axis.
 
void RotateY (DataType angle)
 Rotates the B2Vector3 around the y-axis.
 
void RotateZ (DataType angle)
 Rotates the B2Vector3 around the z-axis.
 
void RotateUz (const B2Vector3< DataType > &NewUzVector)
 Rotates reference frame from Uz to newUz (unit vector).
 
void Rotate (DataType alpha, const B2Vector3< DataType > &v)
 Rotation around an arbitrary axis v with angle alpha. More...
 
void Abs ()
 calculates the absolute value of the coordinates element-wise
 
void Sqrt ()
 calculates the square root of the absolute values of the coordinates element-wise
 
DataType at (unsigned i) const
 safe member access (with boundary check!) More...
 
DataType x () const
 access variable X (= .at(0) without boundary check)
 
DataType y () const
 access variable Y (= .at(1) without boundary check)
 
DataType z () const
 access variable Z (= .at(2) without boundary check)
 
DataType X () const
 access variable X (= .at(0) without boundary check)
 
DataType Y () const
 access variable Y (= .at(1) without boundary check)
 
DataType Z () const
 access variable Z (= .at(2) without boundary check)
 
DataType Px () const
 access variable X (= .at(0) without boundary check)
 
DataType Py () const
 access variable Y (= .at(1) without boundary check)
 
DataType Pz () const
 access variable Z (= .at(2) without boundary check)
 
void GetXYZ (Double_t *carray) const
 directly copies coordinates to an array of double
 
void GetXYZ (Float_t *carray) const
 directly copies coordinates to an array of float
 
void GetXYZ (TVector3 *tVec) const
 directly copies coordinates to a TVector3
 
void GetXYZ (ROOT::Math::XYZVector *xyzVec) const
 directly copies coordinates to a XYZVector
 
TVector3 GetTVector3 () const
 returns a TVector3 containing the same coordinates
 
ROOT::Math::XYZVector GetXYZVector () const
 returns a XYZVector containing the same coordinates More...
 
void SetX (DataType x)
 set X/1st-coordinate
 
void SetY (DataType y)
 set Y/2nd-coordinate
 
void SetZ (DataType z)
 set Z/3rd-coordinate
 
void SetXYZ (DataType x, DataType y, DataType z)
 set all coordinates using data type
 
void SetXYZ (const TVector3 &tVec)
 set all coordinates using a reference to TVector3
 
void SetXYZ (const TVector3 *tVec)
 set all coordinates using a pointer to TVector3
 
void SetXYZ (const ROOT::Math::XYZVector &xyzVec)
 set all coordinates using a reference to XYZVector
 
void SetXYZ (const ROOT::Math::XYZVector *xyzVec)
 set all coordinates using a pointer to XYZVector
 
std::string PrintString (unsigned precision=4) const
 create a string containing vector in cartesian and spherical coordinates
 
std::string PrintStringXYZ (unsigned precision=4) const
 create a string containing vector in cartesian coordinates
 
std::string PrintStringCyl (unsigned precision=4) const
 create a string containing vector in spherical coordinates
 
void Print ()
 just for backward compatibility, should not be used with new code
 

Static Public Member Functions

static DataType Mpi_pi (DataType angle)
 returns given angle in the interval [-PI,PI)
 
static std::string name ()
 Returns the name of the B2Vector. More...
 

Protected Attributes

DataType m_coordinates [3]
 Make sure that we only have floating point vectors. More...
 

Detailed Description

template<typename DataType>
class Belle2::B2Vector3< DataType >

A fast and root compatible alternative to TVector3.

Goals:

  • vectorizable
  • root compatible
  • fixed size
  • featureset comparable to TVector3 (long term goal)
  • interface/member functions compatible to TVector3

DataType: shall be the data type one wants to store in the B2Vector (e.g. double)

Definition at line 42 of file B2Vector3.h.

Member Function Documentation

◆ Angle()

DataType Angle ( const B2Vector3< DataType > &  q) const
inline

The angle w.r.t.

another B2Vector3.

Definition at line 302 of file B2Vector3.h.

◆ Perp()

DataType Perp ( const B2Vector3< DataType > &  axis) const
inline

The transverse component w.r.t.

given axis.

Definition at line 226 of file B2Vector3.h.

◆ Perp2()

DataType Perp2 ( const B2Vector3< DataType > &  axis) const
inline

The transverse component w.r.t.

given axis squared.

Definition at line 213 of file B2Vector3.h.

◆ Phi()

DataType Phi ( ) const
inline

The azimuth angle.

returns phi from -pi to pi

Definition at line 151 of file B2Vector3.h.

◆ PseudoRapidity()

DataType PseudoRapidity ( ) const
inline

Returns the pseudo-rapidity, i.e.

-ln(tan(theta/2)).

for the sake of keeping compatibility to TVector3, the hardcoded values are not replaced by something more intelligent

Definition at line 319 of file B2Vector3.h.

◆ Pt()

DataType Pt ( const B2Vector3< DataType > &  axis) const
inline

The transverse component w.r.t.

given axis.

Definition at line 224 of file B2Vector3.h.

◆ Rotate()

void Rotate ( DataType  alpha,
const B2Vector3< DataType > &  v 
)
inline

Rotation around an arbitrary axis v with angle alpha.

With n = (n1, n2, n3)^T being the unit vector of v, the rotation matrix R(n, alpha) with ca = cos(alpha) and sa = sin(alpha) reads / n1^2*(1-ca)+ca n1*n2*(1-ca)-n3*sa n1*n3*(1-ca)+n2*sa \ R(n, alpha) = | n2*n1*(1-ca)+n3*sa n2^2*(1-ca)+ca n2*n3*(1-ca)-n1*sa | \ n3*n1*(1-ca)-n2*sa n3*n2*(1-ca)+n1*sa n3^2*(1-ca)+ca / . Using this rotation matrix, the full rotation of a vector b (= this) around the axis v by angle alpha can be written as R(n, alpha)*b = n(n*b) + cos(alpha) * (n x b) x n + sin(alpha) * (n x b).

Definition at line 399 of file B2Vector3.h.

Member Data Documentation

◆ m_coordinates

DataType m_coordinates[3]
protected

Make sure that we only have floating point vectors.

contains the coordinates in given data type

Definition at line 47 of file B2Vector3.h.


The documentation for this class was generated from the following file: