ATLAS Offline Software
Loading...
Searching...
No Matches
AmgMatrixBasePlugin.h File Reference
#include <cmath>
Include dependency graph for AmgMatrixBasePlugin.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

const PlainObject unit () const
 This is a plugin that makes Eigen look like CLHEP & defines some convenience methods.
Scalar mag () const
 mag method
Scalar mag2 () const
 mag2 method - forward to squaredNorm()
Scalar perp2 () const
 perp2 method - perpendicular length squared
Scalar perp () const
 perp method - perpendicular length
Scalar perp2 (const MatrixBase< Derived > &vec)
 perp2 method wrt another vector
Scalar perp (const MatrixBase< Derived > &vec)
 perp2 method wrt another vector
Scalar phi () const
 phi method
Scalar theta () const
 theta method
Scalar eta () const
 pseudorapidity method
Scalar deltaR (const MatrixBase< Derived > &vec) const
Scalar deltaPhi (const MatrixBase< Derived > &vec) const
void fillSymmetric (size_t i, size_t j, Scalar value)
 method to fill elements for a symmetric matrix
template<typename OtherDerived>
Matrix< Scalar, OtherDerived::RowsAtCompileTime, OtherDerived::RowsAtCompileTime > similarity (const MatrixBase< OtherDerived > &m) const
 similarity method : yields ms = m*s*m^T
template<typename OtherDerived>
Matrix< Scalar, OtherDerived::RowsAtCompileTime, OtherDerived::RowsAtCompileTime > similarityT (const MatrixBase< OtherDerived > &m) const
 similarityT method : yields ms = m^T*s*m

Function Documentation

◆ deltaPhi()

Scalar deltaPhi ( const MatrixBase< Derived > & vec) const
inline

Definition at line 112 of file AmgMatrixBasePlugin.h.

112 {
113 //we assert in eta/phi methods
114 double dphi = vec.phi() - this->phi();
115 if (dphi > M_PI) {
116 dphi -= M_PI * 2;
117 } else if (dphi <= -M_PI) {
118 dphi += M_PI * 2;
119 }
120 return dphi;
121}
#define M_PI
Scalar phi() const
phi method
std::vector< size_t > vec

◆ deltaR()

Scalar deltaR ( const MatrixBase< Derived > & vec) const
inline

Definition at line 105 of file AmgMatrixBasePlugin.h.

105 {
106 //we assert in eta/phi methods
107 double a = this->eta() - vec.eta();
108 double b = this->deltaPhi(vec);
109 return std::sqrt(a * a + b * b);
110}
Scalar eta() const
pseudorapidity method
Scalar deltaPhi(const MatrixBase< Derived > &vec) const
static Double_t a

◆ eta()

Scalar eta ( ) const
inline

pseudorapidity method

Definition at line 83 of file AmgMatrixBasePlugin.h.

83 {
84 constexpr int size = Eigen::MatrixBase<Derived>::SizeAtCompileTime;
85 constexpr int isVector = Eigen::MatrixBase<Derived>::IsVectorAtCompileTime;
86 static_assert(isVector && size>=3, "Method applicable for vectors of size >=3");
87 const Scalar rho2 = (*this).x() * (*this).x() + (*this).y() * (*this).y();
88 const Scalar z = (*this).z();
89 const Scalar z2 = z * z;
90 constexpr Scalar epsilon = 2. * std::numeric_limits<Scalar>::epsilon();
91 // avoid magnitude being parallel to z
92 if (rho2 > z2 * epsilon) {
93 const double m = std::sqrt(rho2 + z2);
94 return 0.5 * std::log((m + z) / (m - z));
95 }
96 if (z == 0) {
97 return 0.0;
98 }
99 // Following math/genvector/inc/Math/GenVector/etaMax.h in ROOT 6.26
100 constexpr Scalar s_etaMax = static_cast<Scalar>(22756.0);
101 // Following math/genvector/inc/Math/GenVector/eta.h in ROOT 6.26
102 return (z > 0) ? z + s_etaMax : z - s_etaMax;
103}
#define z

◆ fillSymmetric()

void fillSymmetric ( size_t i,
size_t j,
Scalar value )
inline

method to fill elements for a symmetric matrix

Definition at line 124 of file AmgMatrixBasePlugin.h.

124 {
125 (*this)(i, j) = value;
126 (*this)(j, i) = value;
127}

◆ mag()

Scalar mag ( ) const
inline

mag method

Definition at line 26 of file AmgMatrixBasePlugin.h.

26 {
27 return (*this).norm();
28}

◆ mag2()

Scalar mag2 ( ) const
inline

mag2 method - forward to squaredNorm()

Definition at line 31 of file AmgMatrixBasePlugin.h.

31 {
32 return (*this).squaredNorm();
33}

◆ perp() [1/2]

Scalar perp ( ) const
inline

perp method - perpendicular length

Definition at line 44 of file AmgMatrixBasePlugin.h.

44 {
45 constexpr int size = Eigen::MatrixBase<Derived>::SizeAtCompileTime;
46 constexpr int isVector = Eigen::MatrixBase<Derived>::IsVectorAtCompileTime;
47 static_assert(isVector && size>=2, "Method applicable for vectors of size >=2");
48 return std::sqrt(this->perp2());
49}
Scalar perp2() const
perp2 method - perpendicular length squared

◆ perp() [2/2]

Scalar perp ( const MatrixBase< Derived > & vec)
inline

perp2 method wrt another vector

Definition at line 62 of file AmgMatrixBasePlugin.h.

62 {
63 return std::sqrt(this->perp2(vec));
64}

◆ perp2() [1/2]

Scalar perp2 ( ) const
inline

perp2 method - perpendicular length squared

Definition at line 36 of file AmgMatrixBasePlugin.h.

36 {
37 constexpr int size = Eigen::MatrixBase<Derived>::SizeAtCompileTime;
38 constexpr int isVector = Eigen::MatrixBase<Derived>::IsVectorAtCompileTime;
39 static_assert(isVector && size>=2, "Method applicable for vectors of size >=2");
40 return ((*this)[0] * (*this)[0] + (*this)[1] * (*this)[1]);
41}

◆ perp2() [2/2]

Scalar perp2 ( const MatrixBase< Derived > & vec)
inline

perp2 method wrt another vector

Definition at line 52 of file AmgMatrixBasePlugin.h.

52 {
53 Scalar tot = vec.mag2();
54 if (tot > 0) {
55 Scalar s = this->dot(vec);
56 return this->mag2() - s * s / tot;
57 }
58 return this->mag2();
59}
Scalar mag2() const
mag2 method - forward to squaredNorm()
Definition dot.py:1

◆ phi()

Scalar phi ( ) const
inline

phi method

Definition at line 67 of file AmgMatrixBasePlugin.h.

67 {
68 constexpr int size = Eigen::MatrixBase<Derived>::SizeAtCompileTime;
69 constexpr int isVector = Eigen::MatrixBase<Derived>::IsVectorAtCompileTime;
70 static_assert(isVector && size>=2, "Method applicable for vectors of size >=2");
71 return std::atan2((*this)[1], (*this)[0]);
72}

◆ similarity()

template<typename OtherDerived>
Matrix< Scalar, OtherDerived::RowsAtCompileTime, OtherDerived::RowsAtCompileTime > similarity ( const MatrixBase< OtherDerived > & m) const
inline

similarity method : yields ms = m*s*m^T

Definition at line 133 of file AmgMatrixBasePlugin.h.

133 {
134 return m * (this->derived() * m.transpose());
135}

◆ similarityT()

template<typename OtherDerived>
Matrix< Scalar, OtherDerived::RowsAtCompileTime, OtherDerived::RowsAtCompileTime > similarityT ( const MatrixBase< OtherDerived > & m) const
inline

similarityT method : yields ms = m^T*s*m

Definition at line 141 of file AmgMatrixBasePlugin.h.

141 {
142 return m.transpose() * (this->derived() * m);
143}

◆ theta()

Scalar theta ( ) const
inline

theta method

Definition at line 75 of file AmgMatrixBasePlugin.h.

75 {
76 constexpr int size = Eigen::MatrixBase<Derived>::SizeAtCompileTime;
77 constexpr int isVector = Eigen::MatrixBase<Derived>::IsVectorAtCompileTime;
78 static_assert(isVector && size>=3, "Method applicable for vectors of size >=3");
79 return std::atan2(this->perp(), (*this)[2]);
80}
Scalar perp() const
perp method - perpendicular length

◆ unit()

const PlainObject unit ( ) const
inline

This is a plugin that makes Eigen look like CLHEP & defines some convenience methods.

unit method - forward normalized()

Definition at line 21 of file AmgMatrixBasePlugin.h.

21 {
22 return (*this).normalized();
23}