Jpp
software
JGeometry2D
JEigenValues2D.hh
Go to the documentation of this file.
1
#ifndef __JEIGENVALUES2D__
2
#define __JEIGENVALUES2D__
3
4
#include <cmath>
5
6
#include "TMatrixDSymEigen.h"
7
8
#include "
JGeometry2D/JVector2D.hh
"
9
#include "
JGeometry2D/JGeometry2DToolkit.hh
"
10
11
12
/**
13
* \author mdejong
14
*/
15
16
namespace
JGEOMETRY2D
{}
17
namespace
JPP
{
using namespace
JGEOMETRY2D
; }
18
19
namespace
JGEOMETRY2D
{
20
21
/**
22
* Eigen values in 2D.
23
*/
24
class
JEigenValues2D
:
25
public
JVector2D
26
{
27
public
:
28
/**
29
* Constructor.
30
*
31
* \param __begin begin of data
32
* \param __end end of data
33
*/
34
template
<
class
T>
35
JEigenValues2D
(T __begin,
36
T __end) :
37
JVector2D
(),
38
N
(0)
39
{
40
const
JCenter2D
center(__begin, __end);
41
42
// RMS matrix
43
44
TMatrixDSym A(2);
45
46
for
(
int
i = 0; i != 2; ++i) {
47
for
(
int
j
= 0;
j
!= 2; ++
j
) {
48
A(i,
j
) = 0.0;
49
}
50
}
51
52
for
(T i = __begin; i != __end; ++i) {
53
54
const
double
dx = center.
getX
() - i->getX();
55
const
double
dy = center.
getY
() - i->getY();
56
57
A(0,0) += (dx * dx);
58
A(0,1) += (dx * dy);
59
60
A(1,1) += (dy * dy);
61
}
62
63
A(1,0) = A(0,1);
64
65
const
TVectorD V = TMatrixDSymEigen(A).GetEigenValues();
// copy!
66
67
N
= V.GetNoElements();
68
69
switch
(
N
) {
70
71
case
2:
72
__y
= V[1];
73
74
case
1:
75
__x
= V[0];
76
break
;
77
78
default
:
79
break
;
80
}
81
}
82
83
84
/**
85
* Get number of eigen values.
86
*
87
* \return number of eigen values
88
*/
89
int
getN
()
const
90
{
91
return
N
;
92
}
93
94
95
/**
96
* Get number of eigen values with minimal value.
97
*
98
* \param precision minimal value
99
* \return number of eigen values
100
*/
101
int
getN
(
double
precision)
const
102
{
103
int
n
= 0;
104
105
if
(fabs(
getX
()) >= precision) ++
n
;
106
if
(fabs(
getY
()) >= precision) ++
n
;
107
108
if
(
n
>
N
)
109
return
N
;
110
else
111
return
n
;
112
}
113
114
115
protected
:
116
int
N
;
117
};
118
}
119
120
#endif
JGEOMETRY2D::JEigenValues2D::N
int N
Definition:
JEigenValues2D.hh:116
JTOOLS::n
const int n
Definition:
JPolint.hh:628
JTOOLS::j
int j
Definition:
JPolint.hh:634
JGeometry2DToolkit.hh
JGEOMETRY2D
Auxiliary classes and methods for 2D geometrical objects and operations.
Definition:
JAngle2D.hh:18
JGEOMETRY2D::JEigenValues2D
Eigen values in 2D.
Definition:
JEigenValues2D.hh:24
JPP
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Definition:
JAAnetToolkit.hh:37
JGEOMETRY2D::JEigenValues2D::getN
int getN(double precision) const
Get number of eigen values with minimal value.
Definition:
JEigenValues2D.hh:101
JGEOMETRY2D::JVector2D::__x
double __x
Definition:
JVector2D.hh:255
JGEOMETRY2D::JCenter2D
Center.
Definition:
JGeometry2DToolkit.hh:52
JVector2D.hh
JGEOMETRY2D::JEigenValues2D::JEigenValues2D
JEigenValues2D(T __begin, T __end)
Constructor.
Definition:
JEigenValues2D.hh:35
JGEOMETRY2D::JVector2D::getX
double getX() const
Get x position.
Definition:
JVector2D.hh:62
JGEOMETRY2D::JVector2D::getY
double getY() const
Get y position.
Definition:
JVector2D.hh:73
JGEOMETRY2D::JVector2D::__y
double __y
Definition:
JVector2D.hh:256
JGEOMETRY2D::JEigenValues2D::getN
int getN() const
Get number of eigen values.
Definition:
JEigenValues2D.hh:89
JGEOMETRY2D::JVector2D
Data structure for vector in two dimensions.
Definition:
JVector2D.hh:31
Generated by
1.8.16