ATLAS Offline Software
Functions
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. More...
 
Scalar mag () const
 mag method
More...
 
Scalar mag2 () const
 mag2 method - forward to squaredNorm() More...
 
Scalar perp () const
 perp method - perpenticular length More...
 
Scalar perp2 () const
 perp2 method - perpendicular length squared More...
 
Scalar perp2 (const MatrixBase< Derived > &vec)
 
Scalar perp (const MatrixBase< Derived > &vec)
 
Scalar phi () const
 phi method More...
 
Scalar theta () const
 theta method More...
 
Scalar eta () const
 pseudorapidity method More...
 
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 symmetrically elments More...
 
template<typename OtherDerived >
Matrix< Scalar, OtherDerived::RowsAtCompileTime, OtherDerived::RowsAtCompileTime > similarity (const MatrixBase< OtherDerived > &m) const
 
template<typename OtherDerived >
Matrix< Scalar, OtherDerived::RowsAtCompileTime, OtherDerived::RowsAtCompileTime > similarityT (const MatrixBase< OtherDerived > &m) const
 similarityT method : yields ms = m^T*s*m More...
 

Function Documentation

◆ deltaPhi()

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

Definition at line 107 of file AmgMatrixBasePlugin.h.

107  {
108  if (this->rows() < 2)
109  return 0.;
110  double dphi = vec.phi() - this->phi();
111  if (dphi > M_PI) {
112  dphi -= M_PI * 2;
113  } else if (dphi <= -M_PI) {
114  dphi += M_PI * 2;
115  }
116  return dphi;
117 }

◆ deltaR()

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

Definition at line 99 of file AmgMatrixBasePlugin.h.

99  {
100  if (this->rows() < 2)
101  return 0.;
102  double a = this->eta() - vec.eta();
103  double b = this->deltaPhi(vec);
104  return std::sqrt(a * a + b * b);
105 }

◆ eta()

Scalar eta ( ) const
inline

pseudorapidity method

Definition at line 79 of file AmgMatrixBasePlugin.h.

79  {
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();
85  // avoid magnitude being parallel to z
86  if (rho2 > z2 * epsilon) {
87  const double m = std::sqrt(rho2 + z2);
88  return 0.5 * std::log((m + z) / (m - z));
89  }
90  if (z == 0) {
91  return 0.0;
92  }
93  // Following math/genvector/inc/Math/GenVector/etaMax.h in ROOT 6.26
94  constexpr Scalar s_etaMax = static_cast<Scalar>(22756.0);
95  // Following math/genvector/inc/Math/GenVector/eta.h in ROOT 6.26
96  return (z > 0) ? z + s_etaMax : z - s_etaMax;
97 }

◆ fillSymmetric()

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

method to fill symmetrically elments

Definition at line 121 of file AmgMatrixBasePlugin.h.

121  {
122  (*this)(i, j) = value;
123  (*this)(j, i) = value;
124 }

◆ mag()

Scalar mag ( ) const
inline

mag method

Definition at line 25 of file AmgMatrixBasePlugin.h.

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

◆ mag2()

Scalar mag2 ( ) const
inline

mag2 method - forward to squaredNorm()

Definition at line 30 of file AmgMatrixBasePlugin.h.

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

◆ perp() [1/2]

Scalar perp ( ) const
inline

perp method - perpenticular length

Definition at line 35 of file AmgMatrixBasePlugin.h.

35  {
36  if (this->rows() < 2)
37  return 0.;
38  return std::sqrt((*this)[0] * (*this)[0] + (*this)[1] * (*this)[1]);
39 }

◆ perp() [2/2]

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

Definition at line 59 of file AmgMatrixBasePlugin.h.

59  {
60  return std::sqrt(this->perp2(vec));
61 }

◆ perp2() [1/2]

Scalar perp2 ( ) const
inline

perp2 method - perpendicular length squared

Definition at line 42 of file AmgMatrixBasePlugin.h.

42  {
43  if (this->rows() < 2)
44  return 0.;
45  return ((*this)[0] * (*this)[0] + (*this)[1] * (*this)[1]);
46 }

◆ perp2() [2/2]

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

Definition at line 48 of file AmgMatrixBasePlugin.h.

48  {
49  if (this->rows() < 2)
50  return 0.;
51  Scalar tot = vec.mag2();
52  if (tot > 0) {
53  Scalar s = this->dot(vec);
54  return this->mag2() - s * s / tot;
55  }
56  return this->mag2();
57 }

◆ phi()

Scalar phi ( ) const
inline

phi method

Definition at line 64 of file AmgMatrixBasePlugin.h.

64  {
65  if (this->rows() < 2)
66  return 0.;
67  return std::atan2((*this)[1], (*this)[0]);
68 }

◆ similarity()

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

Definition at line 130 of file AmgMatrixBasePlugin.h.

130  {
131  return m * (this->derived() * m.transpose());
132 }

◆ 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 138 of file AmgMatrixBasePlugin.h.

138  {
139  return m.transpose() * (this->derived() * m);
140 }

◆ theta()

Scalar theta ( ) const
inline

theta method

Definition at line 71 of file AmgMatrixBasePlugin.h.

71  {
72  if (this->rows() < 3)
73  return 0.;
74  return std::atan2(
75  std::sqrt((*this)[0] * (*this)[0] + (*this)[1] * (*this)[1]), (*this)[2]);
76 }

◆ 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 20 of file AmgMatrixBasePlugin.h.

20  {
21  return (*this).normalized();
22 }
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
python.SystemOfUnits.m
int m
Definition: SystemOfUnits.py:91
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:64
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:79
M_PI
#define M_PI
Definition: ActiveFraction.h:11
athena.value
value
Definition: athena.py:122
vec
std::vector< size_t > vec
Definition: CombinationsGeneratorTest.cxx:12
perp2
Scalar perp2() const
perp2 method - perpendicular length squared
Definition: AmgMatrixBasePlugin.h:42
const
bool const RAWDATA *ch2 const
Definition: LArRodBlockPhysicsV0.cxx:562
fitman.rho2
rho2
Definition: fitman.py:544
x
#define x
lumiFormat.i
int i
Definition: lumiFormat.py:92
z
#define z
deltaPhi
Scalar deltaPhi(const MatrixBase< Derived > &vec) const
Definition: AmgMatrixBasePlugin.h:107
beamspotnt.rows
list rows
Definition: bin/beamspotnt.py:1112
LB_AnalMapSplitter.tot
tot
Definition: LB_AnalMapSplitter.py:46
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
a
TList * a
Definition: liststreamerinfos.cxx:10
y
#define y
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
if
if(febId1==febId2)
Definition: LArRodBlockPhysicsV0.cxx:569
mag2
Scalar mag2() const
mag2 method - forward to squaredNorm()
Definition: AmgMatrixBasePlugin.h:30
GlobalSim::dot
void dot(const Digraph &G, const std::string &fn)
Definition: dot.cxx:10