MarlinUtil  1.12.1
WeightedPoints3D.h
1 #ifndef WeightedPoints3D_h
2 #define WeightedPoints3D_h
3 
4 
5 #include <stdio.h>
6 #include <iostream>
7 #include <iomanip>
8 #include <string>
9 #include <sstream>
10 #include <cstdlib>
11 #include <math.h>
12 #include<vector>
13 
14 
25 
26 public:
27 
39  WeightedPoints3D(int nhits, double* a, double* x, double* y, double* z);
40  WeightedPoints3D(const std::vector<double> &cog,
41  const std::vector<double> &cov, const std::vector<double> &mayor_axis_error = std::vector<double>() ,
42  int npnt = 0 ,double wgtsum =0.0 , double wgt2sum=0.0 , double wgt4sum=0.0 );
43 
48 
52  void setErrors(double *ex, double* ey, double *ez);
53 
54 
55 
59  int getNumberOfPoints();
60 
64  double getTotalWeight();
65 
69  double getTotalSquaredWeight();
70 
74  double getTotalQuarticWeight();
75 
81  double* getCentreOfGravity();
82 
88  double* getCentreOfGravityErrors();
89 
91  inline double* getCenterOfGravity() { return getCentreOfGravity() ; }
92  inline double* getCenterOfGravityErrors() { return getCentreOfGravityErrors() ; }
93 
97  double* getEigenVal();
98 
103  double* getEigenValErrors();
104 
114  double* getEigenVecCartesian();
115 
120  double* getEigenVecPolar();
121 
127  double* getEigenVecCartesianErrors();
128  double* getEigenVecPolarErrors();
129 
137  double getWidth();
138 
139 
144  inline double radius() { return _radius; }
145 
146 
147 private:
148 
149  int _nPoints;
150 
151  double* _Wgt;
152  double* _x;
153  double* _y;
154  double* _z;
155  double* _ex;
156  double* _ey;
157  double* _ez;
158  double* _xl;
159  double* _xt;
160  double* _t;
161  double* _s;
162 
163  int _ifNotPointsGiven;
164  int _ifNotCOG;
165  int _ifNotCOGErrors;
166  double _sumWgt;
167  double _wgt_sqr_sum ;
168  double _wgt_4_sum ;
169  double _radius;
170  double _xgr;
171  double _ygr;
172  double _zgr;
173  double _COG[3];
174  double _COGCov[3][3];
175  double _COGCovCov[6][6];
176 
177 
178  int _ifNotWidth;
179  double _Width;
180 
181 
182  int _ifNotEigenSolved;
183  int _ifNotEigenToPolarDone ;
184  int _ifNotCovErrors;
185  int _ifNotVecErrorsPolarPropagated;
186  int _ifNotVecErrorsCartesianPropagated;
187  int _ifNotValErrorsPropagated;
188  int _ifNot_dVec_dCov;
189  int _ifNot_fourthmom;
190  int _last_evec_to_error_propagate;
191  double _EigenVal[3];
192  double _EigenValCov[3][3];
193  double _EigenVec[3][3];
194  double _EigenVecAngle[2][3];
195  double _EigenVecCov[9][9];
196  double _theta_phi_cov[2][2][3];
197  double _xyz_cov[3][3][3];
198  double _var_lam[3];
199  double _nfact1;
200  double _nfact2;
201  double _nfact3;
202  double _nfact4;
203  double _fourth_mom[3][3][3][3];
204  double dang[6][2][3];
205 
206 
207 
208  void findCOG();
209  void findCOGErrors();
210  double findDistance(int i);
211  void solveEigenValEq();
212  void findCovErrors();
213  void findWidth();
214  void propagateVecErrorsPolar();
215  void propagateVecErrorsCartesian();
216  void propagateValErrors();
217  void find_dVec_dCov();
218 
219 };
220 
221 
222 #endif
double getTotalWeight()
returns the summed weight for the whole set of points.
Definition: WeightedPoints3D.cc:193
double * getEigenValErrors()
Retuns a vector containing the variances of the three eigen-values.
Definition: WeightedPoints3D.cc:229
double getTotalSquaredWeight()
returns the sum of weight^2 for the whole set of points.
Definition: WeightedPoints3D.cc:200
double * getEigenVecPolar()
The same in polar.
Definition: WeightedPoints3D.cc:240
~WeightedPoints3D()
Destructor.
Definition: WeightedPoints3D.cc:146
double * getEigenVecCartesian()
array of the three main axes of the covariance matrix, starting with the axis corresponding to the sm...
Definition: WeightedPoints3D.cc:236
double * getEigenVal()
array of the eigen-values of the covariance matrix, sorted in ascending size.
Definition: WeightedPoints3D.cc:225
int getNumberOfPoints()
returns the number of elements of the set of points
Definition: WeightedPoints3D.cc:187
double radius()
distance to the centre of gravity measured from IP (absolut value of the vector to the centre of grav...
Definition: WeightedPoints3D.h:144
double * getCenterOfGravity()
US spelling of getCentreOfGravity.
Definition: WeightedPoints3D.h:91
WeightedPoints3D(int nhits, double *a, double *x, double *y, double *z)
Constructor.
Definition: WeightedPoints3D.cc:96
double getTotalQuarticWeight()
returns the sum of weight^4 for the whole set of points.
Definition: WeightedPoints3D.cc:206
double getWidth()
'mean' width of the cluster perpendicular to the main principal axis, defined as: width := sqrt( 1/Su...
Definition: WeightedPoints3D.cc:263
double * getEigenVecCartesianErrors()
The covariance matrix of the eigen-vectors, one matrix/eigen-vector, so it is a (2/3) x (2/3) x 3 mat...
Definition: WeightedPoints3D.cc:252
void setErrors(double *ex, double *ey, double *ez)
Defining position errors.
Definition: WeightedPoints3D.cc:165
Utility class to derive properties of a set od weighted points in 3D, such as centre of gravity...
Definition: WeightedPoints3D.h:24
double * getCentreOfGravity()
returns an array, which represents a vector from the origin of the coordiante system, i. e. IP, to average (aka the centre of gravity) of the set of points, with the weighs of each point taken into account.
Definition: WeightedPoints3D.cc:213
double * getCentreOfGravityErrors()
returns the covarinace matrix between the three coordinates of the centre of gravity.
Definition: WeightedPoints3D.cc:217