StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
THelixTrack_.h
1 #ifndef THELIXTRACK__H
2 #define THELIXTRACK__H
3 #include <assert.h>
4 #include "TObject.h"
5 #include "TArrayD.h"
6 #include "TPolinom.h"
7 typedef double Mtx33D_t[3][3];
8 typedef double Mtx55D_t[5][5];
9 
10 class TCEmx_t_
11 {
12 public:
13 const double *Arr() const { return &mHH;}
14  double *Arr() { return &mHH;}
15 const double &operator[](int idx) const { return (&mHH)[idx];}
16  double &operator[](int idx) { return (&mHH)[idx];}
17 void Clear() { memset(this,0,sizeof(*this));}
18  TCEmx_t_() { Clear();}
19 void Set(const double *err);
20 void Move(double const F[3][3]);
21 double Sign() const;
22 void Backward();
23 public:
24 
25 double
26 mHH,
27 mHA, mAA,
28 mHC, mAC, mCC;
29 };
30 
31 class THEmx_t_
32 {
33 public:
34  THEmx_t_() { Clear();}
35 const double *Arr() const { return &mHH;}
36  double *Arr() { return &mHH;}
37 operator const double* () { return &mHH;}
38 operator double* () { return &mHH;}
39  THEmx_t_ &operator*=(double f)
40  { for (int i=0;i<15;i++) {Arr()[i]*=f;} return *this;}
41 void Clear() { memset(this,0,sizeof(*this));}
42 void Set(const double *err);
43 void Set(const double *errxy,const double *errz);
44 void Move(double const F[5][5]);
45 void Backward();
46 void Print(const char *tit=0) const;
47 double Sign() const;
48 public:
49 // Let Dx,Dy,Dz direction of track
50 // dH: along vector (-Dy,Dx,0)
51 // dZ: along Zaxis
52 // dA: delta azimuth angle (in X,Y plane;
53 // dC: delta of curvature;
54 // dL = dLambda, angle between track and X,Y plane
55 double
56 mHH,
57 mHA, mAA,
58 mHC, mAC, mCC,
59 mHZ, mAZ, mCZ, mZZ,
60 mHL, mAL, mCL, mZL, mLL;
61 };
62 
63 
64 class TCircle_: public TObject
65 {
66 friend class THelixTrack_;
67 friend class TCircleFitter_;
68 public:
69  TCircle_();
70  TCircle_(const double *x,const double *dir,double rho);
71  TCircle_(const TCircle_& fr);
72  TCircle_(const TCircle_* fr); //special ctr without errors
73 ~TCircle_();
74 TCircle_ &operator=(const TCircle_& fr);
75  void Set(const double *x=0,const double *dir=0,const double rho=0);
76 virtual void Clear(const char *opt="");
77 const double* Pos() const {return fX; }
78  double* Pos() {return fX; }
79 const double* Dir() const {return fD; }
80  double* Dir() {return fD; }
81  double Rho() const {return fRho;}
82  double& Rho() {return fRho;}
83  void Nor(double *norVec) const;
84  void SetEmx(const double *err=0);
85 const TCEmx_t_ *Emx() const {return fEmx;}
86  TCEmx_t_ *Emx() {return fEmx;}
87  void GetCenter(double center[2]) const;
88 double Path(const double pnt[2]) const;
89 double Path(const double pnt[2], const double exy[3]) const;
90 double Path(const TCircle_ &tc,double *s2=0) const;
91 double Move(double step);
92 void Rot(double angle);
93 void Rot(double cosa,double sina);
94 void Backward();
95 double Eval(double step,double *xy,double *dir=0) const;
96 void Show(int nPts,const double *Pts,int pstep=2);
97 virtual void Print(const char* chopt = "") const;
98 void SetStrait(int strait=1) {SetBit(1,strait) ;}
99 int IsStrait() {return TestBit(1);}
100 
101 // static funs
102 static void Test2();
103 static void Test3();
104 static void Test4();
105 static void TestMtx();
106 
107 private:
108 void MoveErrs(double l);
109 void MakeMtx (double l,double F[3][3]);
110 
111 protected:
112 double fX[2];
113 double fD[2];
114 double fRho;
115 TCEmx_t_ *fEmx; //let h = fX[1]*fD[0], a=atan2(fD[1],fD[0]),c=fRho
116  // hh,
117  // ah,aa,
118  // ch,ca,cc
119 ClassDef(TCircle_,0)
120 };
122 {
123  public:
124  static int dSize() {return sizeof(TCircleFitterAux_)/sizeof(double);}
125  public:
126  double x,y,z; //x,y,z of measured point
127  double exy[3]; //err matrix(xx,xy,yy) of x,y
128  double ezz; //error of z
129  double wt; //calculated weight
130 
131 };
133 {
134 public:
135  TCircleFitter_();
136 int Size() const {return fN;}
137 int Used() const {return fNuse;}
138 void Add (double x,double y,const double *errs=0);
139 void Add (double x,double y,double z);
140 void AddErr(const double *errs,double errz=0);
141 void AddErr(double errh,double errz=0);
142 void AddZ(double z,double err2z=0);
143 double Fit();
144 void MakeErrs();
145 double FixAt(const double vals[5],int flag);
146 void Skip(int idx);
147 double GetZ0() const {return fZ0 ;}
148 double GetTanL() const {return fTanL ;}
149 void SetCase(int kase=0) {fCase=kase ;}
150 int GetCase() const {return fKase ;}
151 double Chi2() const {return fChi2 ;}
152 int Ndf() const {return fNdf ;}
153 double Chi2Z () const {return fChi2Z ;}
154 void SetNdf(int ndf);
155 double EvalChi2();
156 void Clear(const char *opt ="");
157 void Print(const char* chopt = "") const;
158 const double *GetX(int i=0) const;
159  double *GetX(int i=0);
160 TCircleFitterAux_* GetAux(int i) const;
161 
162 static void Test(int iTest=0);
163 static void TestCorr(int kode=0);
164 private:
165 double f();
166 double df(int i);
167 double d2f(int i,int j);
168 double Rho2();
169 double dRho2(int i);
170 double d2Rho2(int i,int j);
171 double F();
172 double dF(int i);
173 double d2F(int i,int j);
174 
175 private:
176 TArrayD fArr;
177 char fBeg[1];
178 int fN;
179 int fNuse;
180 int fCase; //default case 0=automatic,1=small angle,2=Chernov/Ososkov
181 int fKase; //used case
182 int fBack;
183 TCircleFitterAux_* fAux;
184 double fCos,fSin; //Direction of local coordinate
185 double fNor[2];
186 double fPol[6];
187 double fXgravity;
188 double fYgravity;
189 double fXx;
190 double fYy;//?????????????????????????
191 double fXy;
192 double fXrr;
193 double fYrr;
194 double fRrrr;
195 double fRr;
196 double fWtot;
197 double fRadius2;
198 double fXd, fYd, fG1; //fXd,fYd coordianate of circle center in local sys
199 double fNx, fNy; //Direction from circle center to point on circle in local sys
200 double fXCenter,fYCenter; //coordianate of circle center in globa
201 double fCov[6],fA,fB,fC,fH;
202 double fR; //radius of curvatur
203 double fRd; //distance to center in local system
204 double fCorrR,fCorrB;
205 double fChi2;
206 int fNdf;
207 double fZ0,fTanL;
208 double fChi2Z;
209 char fEnd[1];
210 ClassDef(TCircleFitter_,0)
211 };
212 
213 
214 class THelixTrack_ : public TObject
215 {
216 public:
217 
218  THelixTrack_();
219  THelixTrack_(const double *xyz,const double *dir,double rho);
220  THelixTrack_(const THelixTrack_ &from);
221  THelixTrack_(const THelixTrack_ *from); //Special ctr without errs
222 virtual ~THelixTrack_();
223 THelixTrack_ &operator=(const THelixTrack_ &from);
224  void Set (const double *xyz,const double *dir,double rho);
225  void Set (double rho){ fRho = rho;}
226  void SetEmx(const double* err2xy,const double* err2z);
227  void SetEmx(const double* err=0);
228  THEmx_t_ *Emx() const {return fEmx;}
229  void StiEmx(double emx[21]) const;
230  void GetSpot(const double axis[3][3],double emx[3]) const;
231  void Fill (TCircle_ &circ) const;
233  void Backward();
235  double Move(double step);
236  double Move(double step,double F[5][5]);
238  double Eval(double step, double *xyz, double *dir=0,double *rho=0) const;
245  double Path(double stmax, const double *surf, int nsurf
246  ,double *x=0, double *dir=0, int nearest=0) const;
247 
249  double Path(const double point[3],double *xyz=0, double *dir=0) const;
251  double Dca(const double point[3],double *dcaErr=0) const;
252 
254  double Path(double x,double y) const ;
256  double Dca(double x,double y,double *dcaErr=0) const ;
257 
261 
262  double Path(const THelixTrack_ &hlx,double *s2=0) const ;
263 
268  double PathX(const THelixTrack_ &hlx,double *s2=0
269  ,double *dist=0, double *xyz=0) const;
270 
272  double Dca(const double point[3]
273  ,double &dcaXY,double &dcaZ,double dcaEmx[3],int kind=3) const;
274 
275  const double *GetXYZ() const {return fX;}
276  const double *Pos() const {return fX;}
277  double *Pos() {return fX;}
278  const double *Dir() const {return fP;}
279  double *Dir() {return fP;}
280  double GetRho() const {return fRho ;}
281  double GetCos() const {return fCosL;}
282  double GetSin() const {return fP[2];}
283  double GetTan() const {return fP[2]/fCosL;}
284  double GetPeriod() const ;
285  void Rot(double angle);
286  void Rot(double cosa,double sina);
287 
288  void Show(double len, const THelixTrack_ *other=0) const;
289  void Print(Option_t *opt="") const;
290 // statics
291 static void InvertMtx(double derivs[5][5]);
292 static void Test1();
293 static void Test2();
294 static void Test3();
295 static void Test4();
296 static void Test5();
297 static void TestMtx();
298 static void TestDer();
299 static void TestErr();
300 static void TestTwoHlx();
301 static void TestBak();
302 protected:
305  void MakeMtx(double step,double F[5][5]);
306 protected:
307  double Path(double stmin,double stmax, const double *surf, int nsurf
308  ,double *x=0, double *dir=0,int nearest=0) const;
309  double PathHZ(const double *surf, int nsurf
310  ,double *x=0, double *dir=0,int nearest=0) const;
311  void Build();
312  char fBeg[1];
313  double fX[3];
314  double fP[3];
315  double fRho;
316  double fCosL;
317  THEmx_t_ *fEmx;
318  char fEnd[1];
319 ClassDef(THelixTrack_,0)
320 };
322 {
323 public:
324  THelixFitter_();
325  ~THelixFitter_();
326 int Size() const {return fCircleFitter.Size();}
327 int Used() const {return fCircleFitter.Used();}
328 void Add (double x,double y,double z);
329 void AddErr(const double *err2xy,double err2z);
330 void AddErr(double errhh,double errzz);
331 double Fit();
332 void MakeErrs();
333 double FixAt(const double vals[5],int flag=1);
334 void Skip(int idx);
335 void SetCase(int kase=0) {fCircleFitter.SetCase(kase);}
336 int GetCase() const {return fCircleFitter.GetCase();}
337 double Chi2() const {return fChi2;}
338 int Ndf() const {return fCircleFitter.Ndf()+fPoli1Fitter.Ndf();}
339 double Chi2XY () const {return fCircleFitter.Chi2();}
340 double Chi2SZ () const {return fPoli1Fitter.Chi2() ;}
341 int NdfXY () const {return fCircleFitter.Ndf();}
342 int NdfSZ () const {return fPoli1Fitter.Ndf() ;}
343 TCircleFitterAux_* GetAux(int i) const {return fCircleFitter.GetAux(i);}
344 double EvalChi2();
345 void Clear(const char *opt ="");
346 void Print(const char* chopt = "") const;
347 void Show() const;
348 
349 static void Test(int kase=0);
350 private:
351 void Update(int kase);
352 private:
353 TCircleFitter_ fCircleFitter;
354 TPoliFitter fPoli1Fitter;
355 double fChi2;
356 ClassDef(THelixFitter_,0)
357 };
358 
359 #endif // THELIXTRACK_H
static void TestDer()
void Backward()
Change direction.
double PathX(const THelixTrack_ &hlx, double *s2=0, double *dist=0, double *xyz=0) const
void GetSpot(const double axis[3][3], double emx[3]) const
double FixAt(const double vals[5], int flag)
double Path(double stmax, const double *surf, int nsurf, double *x=0, double *dir=0, int nearest=0) const
double Move(double step)
Move along helix.
void MakeMtx(double step, double F[5][5])
double Eval(double step, double *xyz, double *dir=0, double *rho=0) const
Evaluate params with given step along helix.
double Dca(const double point[3], double *dcaErr=0) const
DCA to given space point (with error matrix)