Jpp 19.3.0-rc.3
the software that should make you happy
Loading...
Searching...
No Matches
JEigen2D.hh
Go to the documentation of this file.
1#ifndef __JEIGENVALUES2D__
2#define __JEIGENVALUES2D__
3
4#include <cmath>
5#include <map>
6#include <functional>
7
8#include "TMatrixDSymEigen.h"
9
12
13
14/**
15 * \author mdejong
16 */
17
18namespace JGEOMETRY2D {}
19namespace JPP { using namespace JGEOMETRY2D; }
20
21namespace JGEOMETRY2D {
22
23 /**
24 * Eigen values in 2D.
25 */
27 public std::map<double, JVector2D, std::greater<double> >
28 {
29 public:
30 /**
31 * Constructor.
32 *
33 * \param __begin begin of data
34 * \param __end end of data
35 */
36 template<class T>
37 JEigenValues2D(T __begin,
38 T __end)
39 {
40 const JCenter2D center(__begin, __end);
41
42 // RMS matrix
43
44 TMatrixDSym A(2);
45
46 A = 0.0;
47
48 for (T i = __begin; i != __end; ++i) {
49
50 const double dx = center.getX() - i->getX();
51 const double dy = center.getY() - i->getY();
52
53 A(0,0) += (dx * dx);
54 A(0,1) += (dx * dy);
55
56 A(1,1) += (dy * dy);
57 }
58
59 A(1,0) = A(0,1);
60
61 const TMatrixDSymEigen result(A);
62
63 const TVectorD& u = result.GetEigenValues();
64 const TMatrixD& V = result.GetEigenVectors();
65
66 for (Int_t i = 0; i != u.GetNoElements(); ++i) {
67 (*this)[u[i]] = JVector2D(V(0,i),
68 V(1,i));
69 }
70 }
71 };
72}
73
74#endif
Data structure for vector in two dimensions.
Definition JVector2D.hh:34
double getY() const
Get y position.
Definition JVector2D.hh:74
double getX() const
Get x position.
Definition JVector2D.hh:63
Auxiliary classes and methods for 2D geometrical objects and operations.
Definition JAngle2D.hh:19
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Eigen values in 2D.
Definition JEigen2D.hh:28
JEigenValues2D(T __begin, T __end)
Constructor.
Definition JEigen2D.hh:37