Jpp test-rotations-old
the software that should make you happy
Loading...
Searching...
No Matches
JPoint3DEstimator.hh
Go to the documentation of this file.
1#ifndef __JFIT__JPOINT3DESTIMATOR__
2#define __JFIT__JPOINT3DESTIMATOR__
3
4#include "JMath/JMatrix3S.hh"
5#include "JFit/JPoint3D.hh"
6#include "JFit/JEstimator.hh"
7
8
9/**
10 * \file
11 * Linear fit of JFIT::JPoint3D.
12 * \author mdejong
13 */
14namespace JFIT {}
15namespace JPP { using namespace JFIT; }
16
17namespace JFIT {
18
19 /**
20 * Linear fit of crossing point (position) between axes (objects with position and direction).
21 *
22 \f{center}\setlength{\unitlength}{0.6cm}\begin{picture}(12,12)
23
24 \put( 5.0, 5.0){\circle*{0.3}}
25 \put( 4.0, 5.0){\makebox(0,0)[r]{$(x_{0},y_{0},z_{0})$}}
26
27 \multiput( 5.0, 5.0)(+0.2, 0.0){18}{\makebox(0,0)[c]{.}}
28 \put( 9.0, 5.0){\circle*{0.2}}
29 \put( 9.0, 5.0){\vector(+1, 0){0.7}}
30 \put(10.0, 5.0){\makebox(0,0)[l]{$(\bar{x}_j,\hat{u}_j)$}}
31
32 \multiput( 5.0, 5.0)(-0.2,+0.2){18}{\makebox(0,0)[c]{.}}
33 \put( 1.0, 9.0){\circle*{0.2}}
34 \put( 1.0, 9.0){\vector(-1,+1){0.6}}
35 \put( 0.0,10.0){\makebox(0,0)[r]{$(\bar{x}_k,\hat{u}_k)$}}
36
37 \multiput( 5.0, 5.0)(-0.2,-0.2){18}{\makebox(0,0)[c]{.}}
38 \put( 1.0, 1.0){\circle*{0.2}}
39 \put( 1.0, 1.0){\vector(-1,-1){0.6}}
40 \put( 0.0, 0.0){\makebox(0,0)[r]{$(\bar{x}_i,\hat{u}_i)$}}
41
42 \end{picture}
43 \f}
44 *
45 * where:
46 *
47 \f{eqnarray*}{
48 \bar{x}_i & = & i^{th} \textrm{ position} \\
49 \hat{u}_i & = & i^{th} \textrm{ direction} \\
50 \f}
51 *
52 * The parameters \f$\{x_0, y_0, z_0\}\f$ are estimated in the constructor of this class.
53 */
54 template<>
56 public JPoint3D
57 {
58 public:
59 /**
60 * Constructor.
61 *
62 * The template argument <tt>T</tt> refers to an iterator of a data structure which should have the following member methods:
63 * - double %getX(); // [m]
64 * - double %getY(); // [m]
65 * - double %getZ(); // [m]
66 * - double %getDX(); // [u]
67 * - double %getDY(); // [u]
68 * - double %getDZ(); // [u]
69 *
70 * \param __begin begin of data
71 * \param __end end of data
72 */
73 template<class T>
74 JEstimator(T __begin, T __end)
75 {
76 using namespace std;
77
78 const int N = distance(__begin, __end);
79
80 if (N > 1) {
81
82 double x = 0;
83 double y = 0;
84 double z = 0;
85
86 V.reset();
87
88 for (T i = __begin; i != __end; ++i) {
89
90 const double xx = 1.0 - i->getDX() * i->getDX();
91 const double yy = 1.0 - i->getDY() * i->getDY();
92 const double zz = 1.0 - i->getDZ() * i->getDZ();
93
94 const double xy = -i->getDX() * i->getDY();
95 const double xz = -i->getDX() * i->getDZ();
96 const double yz = -i->getDY() * i->getDZ();
97
98 V.a00 += xx;
99 V.a01 += xy;
100 V.a02 += xz;
101
102 V.a11 += yy;
103 V.a12 += yz;
104
105 V.a22 += zz;
106
107 x += xx * i->getX() + xy * i->getY() + xz * i->getZ();
108 y += xy * i->getX() + yy * i->getY() + yz * i->getZ();
109 z += xz * i->getX() + yz * i->getY() + zz * i->getZ();
110 }
111
112 V.a10 = V.a01;
113 V.a20 = V.a02;
114 V.a21 = V.a12;
115
116 V.invert();
117
118 __x = V.a00 * x + V.a01 * y + V.a02 * z;
119 __y = V.a10 * x + V.a11 * y + V.a12 * z;
120 __z = V.a20 * x + V.a21 * y + V.a22 * z;
121
122 } else {
123 throw JValueOutOfRange("JEstimator<JPoint3D>::JEstimator(): Not enough data points.");
124 }
125 }
126
127
128 static const int NUMBER_OF_PARAMETERS = 3; //!< number of parameters of fit
129 JMATH::JMatrix3S V; //!< co-variance matrix of fit parameters
130 };
131}
132
133#endif
Linear fit methods.
std::vector< T >::difference_type distance(typename std::vector< T >::const_iterator first, typename PhysicsEvent::const_iterator< T > second)
Specialisation of STL distance.
JMATH::JMatrix3S V
co-variance matrix of fit parameters
JEstimator(T __begin, T __end)
Constructor.
Template definition of linear fit.
Definition JEstimator.hh:25
Data structure for position fit.
Definition JPoint3D.hh:24
Exception for accessing a value in a collection that is outside of its range.
3 x 3 symmetric matrix
Definition JMatrix3S.hh:31
Auxiliary classes and methods for linear and iterative data regression.
Definition JEnergy.hh:15
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).