StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
THelix3d.h
1 #ifndef THELIX3D_H
2 #define THELIX3D_H
3 #include <assert.h>
4 #include "TObject.h"
5 #include "TArrayD.h"
6 
7 #include "THelixTrack_.h"
8 
9 enum THelix3dE {kU =0,kV =1, kFita =2 ,kLama =3,kPinv =4};
10 enum THelix3dE2{kKT=0,kKU=1,kKV=2, kKdDdL=3};
11 
12 typedef double Mtx33D_t[3][3];
13 typedef double Mtx43D_t[4][3];
14 
15 class TkDir_t
16 {
17  public:
18  TkDir_t() {Clear();}
19  TkDir_t(const TkDir_t &tkd) {*this = tkd;}
20  TkDir_t(const Mtx43D_t &tkd) {*this = tkd;}
21  void Clear() {memset(mTkd[0],0,sizeof(mTkd));
22  for(int i=0;i<3;i++){mTkd[i][i]=1;};}
23 operator const Mtx43D_t &() const {return mTkd;}
24 operator Mtx43D_t &() {return mTkd;};
25 TkDir_t &operator=(const TkDir_t &tkd)
26  {assert(mTkd!=tkd); memcpy(mTkd[0],tkd[0],sizeof(mTkd)); return *this;}
27 TkDir_t &operator=(const Mtx43D_t &tkd)
28  {assert(mTkd!=tkd); memcpy(mTkd[0],tkd[0],sizeof(mTkd)); return *this;}
29 const double* T() const {return mTkd[kKT];}
30 const double* U() const {return mTkd[kKU];}
31 const double* V() const {return mTkd[kKV];}
32  void Backward();
33  int Same(const TkDir_t &as) const;
34 protected:
35  Mtx43D_t mTkd;
36 
37 };
38 
39 
40 class THDer3d_t
41 {
42 public:
43 friend class THelix3d;
44 friend class TRungeKutta;
45 THDer3d_t() { Clear();}
46 void Clear();
47  operator const Mtx55D_t &() const { return mDer ;} //
48  operator Mtx55D_t &() { return mDer ;} //
49  const TkDir_t &TkDir(int idx) const { return mTkDir[idx];}
50  void SetTkDir(int idx, const TkDir_t& tkd) { mTkDir[idx]=tkd;}
51  double Len() const { return mLen ;}
52  void Backward();
53 THDer3d_t &operator*=(const THDer3d_t &by);
54 
55 
56 protected:
57 double mLen;
58 Mtx55D_t mDer;
59 TkDir_t mTkDir[2];
60 };
61 
62 class THEmx3d_t
63 {
64 public:
65  THEmx3d_t() { Clear();}
66  THEmx3d_t(double const err[15],TkDir_t *tkDir = 0) { Clear();Set(err,tkDir);}
67 operator const double* () const { return &mUU;}
68 operator double* () { return &mUU;}
69  THEmx3d_t &operator*=(double f)
70  { for (int i=0;i<15;i++) {(*this)[i]*=f;} return *this;}
71 void Clear();
72 const TkDir_t &TkDir() const { return mTkDir;}
73  TkDir_t &TkDir() { return mTkDir;}
74  void Set(double const err[15],TkDir_t *tkDir = 0);
75  void Set(double eUU,double eUV,double eVV);
76  void Set(const THelixTrack_ *ht);
77  void Add(double Theta2,double Orth2,double PinvRr);
78  void Move(const THDer3d_t *der);
79  void Backward();
80  void Update(const TkDir_t &tkDir);
81  void Print(const char *tit=0) const;
82 double Trace() const ;
83 double Sign() const;
84 double Len() const { return mLen;}
85  int Times(int jk) const { return mTimes[jk];}
86 public:
87 TkDir_t mTkDir;
88 // dU: along Ort to track and Z axis
89 // dV: along Ort to track and dU. When track Ort to Z then it is Zaxis
90 // dF == dFita
91 // dL == dLama
92 // dPinv Pinv = iQ/Ptot:
93 double
94 mUU,
95 mUV, mVV,
96 mUF, mVF, mFF,
97 mUL, mVL, mFL, mLL,
98 mUP, mVP, mFP, mLP, mPP;
99 double mLen;
100 int mTimes[2];
101 };
102 class THelix3d : public THelixTrack_
103 {
104 public:
105 
106  THelix3d();
107  THelix3d(int charge,const double xyz[3],const double mom[3],const double mag[3]);
108  THelix3d(const THelix3d &from);
109  THelix3d(const THelix3d *from); //Special ctr without errs
110 virtual ~THelix3d();
111  void Clear(const char* opt=0);
112 THelix3d &operator=(const THelix3d &from);
113  void Set (int charge,const double xyz[3],const double mom[3],const double bMag[3]=0);
114  THEmx3d_t *SetEmx(THEmx3d_t *emx=0);
115  THEmx3d_t *SetEmx(const double G[15]);
116  THEmx3d_t *Emx() const { return fEmx3d;}
117  void SetDerOn(int derOn=1) { fDerOn =derOn;}
118  int IsDerOn() const { return fDerOn;}
120  void Backward();
122  double Move(double step,double F[5][5]=0);
124  double Eval(double step, double xyz[3]=0, double mom[3]=0);
133 
135  double Path(const double point[3],double xyz[3]=0, double mom[3]=0);
137  double Dca(const double point[3],double *dcaErr=0);
138 
140  double Path(double x,double y);
142  double Dca(double x,double y,double *dcaErr=0) ;
143 
147 
148 // double Path(const THelix3d &hlx,double *s2=0) const ;
149 
154 // double PathX(const THelix3d &hlx,double *s2=0
155 // ,double *dist=0, double xyz[3]=0) const;
156 
158 // double Dca(const double point[3]
159 // ,double &dcaXY,double &dcaZ,double dcaEmx[3],int kind=3) const;
160 
161  const double *Pos() const {return fX3d;}
162  double *Pos() {return fX3d;}
163  const double *Dir() const {return fD3d;}
164  double *Dir() {return fD3d;}
165  const double *Mom() const {return fP3d;}
166  double MomTot() const {return fMom;}
167  const double *Mag() const {return fH3d;}
168  int Charge() const {return fCharge;}
169  double Pinv() const {return fPinv;}
170  const THDer3d_t *Der() const {return fDer3d;}
171  const TkDir_t &TkDir(int idx) const { return fDer3d->mTkDir[idx];}
172  void DoTkDir(TkDir_t &tkdir);
173 
174 // void Show(double len, const THelix3d *other=0) const;
175 // void Print(Option_t *opt="") const;
176 // statics
177 static void MakeTkDir( const double T[3],const double H[3],TkDir_t &tkd);
178 static void Test();
179 static void Test2();
180 static void TestDer();
181 static void TestDer2();
182 static void TestErr(int charge=-1);
183 static void TestErr2(int charge=-1);
184 static void TestErr3(int charge=-1);
185 static void ConvertErrs(const THelixTrack_ *he, const double Bz
186  ,double G[15],double D[5][5]=0,double Di[5][5]=0);
187 static void TestConvertErrs();
188 static void TestConvertDers();
189 protected:
190 static void MakeLocal( const double T[3],const double H[3],double sys[3][3]);
191 
192 
193 protected:
194  void MakeMtx();
195  void ToGlobal();
196  void ToLocal();
197  void ToGlobal(const double locX[3],const double locD[3]
198  , double gloX[3], double gloD[3],double gloP[3]) const;
199  void GetdDdL(double dDdL[3]) const;
200 
201 protected:
202  void Build();
203  char fBeg3d[1];
204  char fDerOn;
205  char fCharge;
206  double fX3d[3];
207  double fP3d[3]; // momentum
208  double fD3d[3]; // direction
209  double fPinv;
210  double fH3d[4]; //[0:2] mag field, [3]=module of the field
211  double fLoc[3][3];
212  double fMom; //full momentum
213  double fX3dPre[3]; // Previous position
214  double fD3dPre[3]; // Previous direction
215  double fP3dPre[3]; // Previous momentum
216  double fPpre[3]; // Previous direction in local
217 
218  mutable double fLen;
219  char fMed3d[1];
220 
221  THEmx3d_t *fEmx3d;
222  THDer3d_t *fDer3d;
223 
224  char fEnd3d[1];
225 ClassDef(THelix3d,0)
226 };
227 
228 
229 #endif // THELIX3D_H
double Eval(double step, double xyz[3]=0, double mom[3]=0)
Evaluate params with given step along helix.
Definition: THelix3d.cxx:304
void Backward()
Change direction.
const double * Pos() const
distance and DCAxy and DCAz to given space point (with error matrix)
Definition: THelix3d.h:161
void Backward()
Change direction.
Definition: THelix3d.cxx:269
double Move(double step, double F[5][5]=0)
Move along helix.
Definition: THelix3d.cxx:281
double Path(const double point[3], double xyz[3]=0, double mom[3]=0)
Distance to nearest point to given space point.
Definition: THelix3d.cxx:321
double Dca(const double point[3], double *dcaErr=0)
DCA to given space point (with error matrix)
Definition: THelix3d.cxx:339