Jpp  18.0.0-rc.1
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 
10 #include "JGeometry2D/JVector2D.hh"
12 
13 
14 /**
15  * \author mdejong
16  */
17 
18 namespace JGEOMETRY2D {}
19 namespace JPP { using namespace JGEOMETRY2D; }
20 
21 namespace JGEOMETRY2D {
22 
23  /**
24  * Eigen values in 2D.
25  */
26  struct JEigenValues2D :
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:32
Eigen values in 2D.
Definition: JEigen2D.hh:26
V(JDAQEvent-JTriggerReprocessor)*1.0/(JDAQEvent+1.0e-10)
double getY() const
Get y position.
Definition: JVector2D.hh:74
double getX() const
Get x position.
Definition: JVector2D.hh:63
return result
Definition: JPolint.hh:764
do set_variable OUTPUT_DIRECTORY $WORKDIR T
JEigenValues2D(T __begin, T __end)
Constructor.
Definition: JEigen2D.hh:37
double u[N+1]
Definition: JPolint.hh:776
source $JPP_DIR setenv csh $JPP_DIR &dev null eval JShellParser o a A