Jpp
software
JGeometry3D
JEigenValues3D.hh
Go to the documentation of this file.
1
#ifndef __JEIGENVALUES3D__
2
#define __JEIGENVALUES3D__
3
4
#include <cmath>
5
6
#include "TMatrixDSymEigen.h"
7
8
#include "
JGeometry3D/JVector3D.hh
"
9
#include "
JGeometry3D/JGeometry3DToolkit.hh
"
10
11
12
/**
13
* \author mdejong
14
*/
15
16
namespace
JGEOMETRY3D
{}
17
namespace
JPP
{
using namespace
JGEOMETRY3D
; }
18
19
namespace
JGEOMETRY3D
{
20
21
/**
22
* Eigen values in 3D.
23
*/
24
class
JEigenValues3D
:
25
public
JVector3D
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
JEigenValues3D
(T __begin,
36
T __end) :
37
JVector3D
(),
38
N
(0)
39
{
40
const
JCenter3D
center(__begin, __end);
41
42
// RMS matrix
43
44
TMatrixDSym A(3);
45
46
for
(
int
i = 0; i != 3; ++i) {
47
for
(
int
j
= 0;
j
!= 3; ++
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
const
double
dz = center.
getZ
() - i->getZ();
57
58
A(0,0) += (dx * dx);
59
A(0,1) += (dx * dy);
60
A(0,2) += (dx * dz);
61
62
A(1,1) += (dy * dy);
63
A(1,2) += (dy * dz);
64
65
A(2,2) += (dz * dz);
66
}
67
68
A(1,0) = A(0,1);
69
A(2,0) = A(0,2);
70
A(2,1) = A(1,2);
71
72
const
TVectorD V = TMatrixDSymEigen(A).GetEigenValues();
// copy!
73
74
N
= V.GetNoElements();
75
76
switch
(
N
) {
77
78
case
3:
79
__z
= V[2];
80
81
case
2:
82
__y
= V[1];
83
84
case
1:
85
__x
= V[0];
86
break
;
87
88
default
:
89
break
;
90
}
91
}
92
93
94
/**
95
* Get number of eigen values.
96
*
97
* \return number of eigen values
98
*/
99
int
getN
()
const
100
{
101
return
N
;
102
}
103
104
105
/**
106
* Get number of eigen values with minimal value.
107
*
108
* \param precision minimal value
109
* \return number of eigen values
110
*/
111
int
getN
(
double
precision)
const
112
{
113
int
n
= 0;
114
115
if
(fabs(
getX
()) >= precision) ++
n
;
116
if
(fabs(
getY
()) >= precision) ++
n
;
117
if
(fabs(
getZ
()) >= precision) ++
n
;
118
119
if
(
n
>
N
)
120
return
N
;
121
else
122
return
n
;
123
}
124
125
protected
:
126
int
N
;
127
};
128
}
129
130
#endif
JVector3D.hh
JGEOMETRY3D::JCenter3D
Center.
Definition:
JGeometry3DToolkit.hh:29
JGEOMETRY3D::JVector3D::__y
double __y
Definition:
JVector3D.hh:310
JGEOMETRY3D::JVector3D::getZ
double getZ() const
Get z position.
Definition:
JVector3D.hh:114
JTOOLS::n
const int n
Definition:
JPolint.hh:628
JTOOLS::j
int j
Definition:
JPolint.hh:634
JGEOMETRY3D::JEigenValues3D
Eigen values in 3D.
Definition:
JEigenValues3D.hh:24
JPP
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Definition:
JAAnetToolkit.hh:37
JGEOMETRY3D::JVector3D
Data structure for vector in three dimensions.
Definition:
JVector3D.hh:33
JGEOMETRY3D::JEigenValues3D::JEigenValues3D
JEigenValues3D(T __begin, T __end)
Constructor.
Definition:
JEigenValues3D.hh:35
JGEOMETRY3D::JEigenValues3D::N
int N
Definition:
JEigenValues3D.hh:126
JGEOMETRY3D::JEigenValues3D::getN
int getN(double precision) const
Get number of eigen values with minimal value.
Definition:
JEigenValues3D.hh:111
JGEOMETRY3D::JVector3D::getY
double getY() const
Get y position.
Definition:
JVector3D.hh:103
JGEOMETRY3D
Auxiliary classes and methods for 3D geometrical objects and operations.
Definition:
JAngle3D.hh:18
JGEOMETRY3D::JVector3D::__z
double __z
Definition:
JVector3D.hh:311
JGEOMETRY3D::JVector3D::__x
double __x
Definition:
JVector3D.hh:309
JGEOMETRY3D::JVector3D::getX
double getX() const
Get x position.
Definition:
JVector3D.hh:93
JGEOMETRY3D::JEigenValues3D::getN
int getN() const
Get number of eigen values.
Definition:
JEigenValues3D.hh:99
JGeometry3DToolkit.hh
Generated by
1.8.16