9 #ifndef EVENTPRIMITIVES_AMGMATRIXBASEPLUGIN_H
10 #define EVENTPRIMITIVES_AMGMATRIXBASEPLUGIN_H
20 inline const PlainObject
unit()
const {
21 return (*this).normalized();
25 inline Scalar
mag()
const {
26 return (*this).norm();
30 inline Scalar
mag2()
const {
31 return (*this).squaredNorm();
35 inline Scalar
perp()
const {
38 return std::sqrt((*
this)[0] * (*
this)[0] + (*
this)[1] * (*
this)[1]);
45 return ((*
this)[0] * (*
this)[0] + (*
this)[1] * (*
this)[1]);
48 inline Scalar
perp2(
const MatrixBase<Derived>&
vec) {
53 Scalar
s = this->
dot(vec);
59 inline Scalar
perp(
const MatrixBase<Derived>&
vec) {
60 return std::sqrt(this->
perp2(vec));
64 inline Scalar
phi()
const {
67 return std::atan2((*
this)[1], (*
this)[0]);
75 std::sqrt((*
this)[0] * (*
this)[0] + (*
this)[1] * (*
this)[1]), (*
this)[2]);
79 inline Scalar
eta()
const {
80 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(MatrixBase, 3)
81 const Scalar
rho2 = (*this).x() * (*this).x() + (*this).y() * (*this).y();
82 const Scalar
z = (*this).z();
83 const Scalar z2 =
z *
z;
84 constexpr Scalar epsilon = 2. * std::numeric_limits<Scalar>::epsilon();
86 if (
rho2 > z2 * epsilon) {
87 const double m = std::sqrt(
rho2 + z2);
94 constexpr Scalar s_etaMax =
static_cast<Scalar
>(22756.0);
96 return (
z > 0) ?
z + s_etaMax :
z - s_etaMax;
99 inline Scalar
deltaR(
const MatrixBase<Derived>&
vec)
const {
100 if (this->
rows() < 2)
102 double a = this->
eta() - vec.eta();
104 return std::sqrt(
a *
a +
b *
b);
108 if (this->
rows() < 2)
110 double dphi =
vec.phi() - this->
phi();
113 }
else if (dphi <= -
M_PI) {
127 template <
typename OtherDerived>
128 inline Matrix<Scalar, OtherDerived::RowsAtCompileTime,
129 OtherDerived::RowsAtCompileTime>
131 return m * (this->derived() *
m.transpose());
135 template <
typename OtherDerived>
136 inline Matrix<Scalar, OtherDerived::RowsAtCompileTime,
137 OtherDerived::RowsAtCompileTime>
139 return m.transpose() * (this->derived() *
m);