EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ThreeDeePolySpace.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file ThreeDeePolySpace.h
1 /* -------------------------------------------------------------------------- */
2 /* ThreeDeePolySpace.h */
3 /* */
4 /* Fitting routines with orthogonal polynomials header file. */
5 /* */
6 /* A.Kisselev, PNPI, St.Petersburg, Russia. */
7 /* e-mail: kisselev@hermes.desy.de */
8 /* -------------------------------------------------------------------------- */
9 
10 #include <3d.h>
11 
12 #include <ThreeDeePolynomial.h>
13 
14 #ifndef _THREE_DEE_POLY_SPACE_H
15 #define _THREE_DEE_POLY_SPACE_H
16 
18  TVector3 xx;
19 
20  // NB: need to assign "weight" if ever want to use it!;
21  double f, weight;
22 } ;
23 
24 #define _ODD_ 0x01
25 #define _EVEN_ 0x02
26 #define _BOTH_ 0x03
27 
29  friend class ThreeDeePolynomial;
30 
31  public:
32  // Constructor; there is no good reason to split off 3D point allocation;
33  // as of conversion to C++ just put this part of code into constructor;
34  // this restricts the functionality a bit (no option to change/reallocate
35  // point set later), but I do not seem to need this anyway; also this
36  // solves a potential problem of inconsistency betwee "space" and "poly->space"
37  // pointers; fine;
38  ThreeDeePolySpace(int max_power[3], int _point_num, unsigned char _parity[3] = 0);
39 
40  // 3D point array; will move to private once convert mgrid routines to C++;
41  int point_num;
43 
44  // Fitting polynomial calculation using basis[] built on top of the 3D
45  // points[] set;
47 
48  // Orthogonal polynomial calculation for a given set of points[];
50 
51  // Naive fit error estimate;
52  double getNaivePolyFitError(double xx[3]);
53 
54  private:
55  // Max polynomial power in XYZ (1 means p0 only);
57 
58  // It can happen that in irregular case not all the expected
59  // basis polynomials are independent; prefer to introduce
60  // a cutoff parameter for these purposes; yes, it's a poor style;
61  // but it is not that easy to figure out number of independent
62  // linear combinations;
63  double norm_cutoff;
64 
65  // _ODD_/_EVEN_/_ANY_; not really used;
66  unsigned char parity[3];
67 
68  // Max number of independent polynomials;
69  int dim;
70  // Basis polynomials;
72  // Derivatives of basis polynomials; '3': db/d{XYZ};
74 
75  // Buffer polynomial for intermediate calculations;
77 
78  // Basically the difference between "point_num" and "dim";
79  int getNDF();
80 
81  // Polynomial copy, product and projection operations; do not
82  // bother to create overloaded operators for the first 2 functions;
83  void polyCopy(ThreeDeePolynomial *dest, ThreeDeePolynomial *source);
86 
87  // As the name says: calculate gradients of basis[] polynomials;
88  int buildBasisGradients();
89 
90  // chi^2 of a polynomial fit;
92 
93  // "Realistic" polynomial fit error;
94  double getRealisticPolyFitError(ThreeDeePolynomial *fit, double xx[3]);
95 } ;
96 
97 // Well, eventually PARITY_CHECK() loops must be optimized;
98 #define PARITY_CHECK(space, xyz, i) ((space)->parity[xyz] & ((i)%2 ? _ODD_ : _EVEN_))
99 
100 #endif