StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
TRungeKutta.h
1 #ifndef TRUNGEKUTTA_H
2 #define TRUNGEKUTTA_H
3 #include <assert.h>
4 #include <list>
5 #include "THelix3d.h"
6 
7 class TRKuttaMag
8 {
9  public:
10  TRKuttaMag (){;}
11  virtual ~TRKuttaMag(){}
12  // methods
13  virtual void operator()(const double X[3], double B[3])
14  { assert(0 && "Method not defined");};
15  protected:
16  // data members
17 };
18 #define kMicron 1e-4
19 
20 class TRungeKutta : public TObject
21 {
22 public:
23 class TRKutaPars_t { public: double X[3],D[3],P[3],Pinv;
24  void Update(){for (int i=0;i<3;i++){P[i]=D[i]/fabs(Pinv);}}
25  void Print(const char *tit) const;
26  };
27 class TRKutaPoint {public: double Len; TRKutaPars_t pars; double B[3];};
28 
29 
30 typedef std::list<TRKutaPoint> TRKutaList;
31 
32 
33  TRungeKutta();
34  TRungeKutta(int charge,const double xyz[3],const double mom[3],TRKuttaMag* mag=0);
35  TRungeKutta(const TRungeKutta &from);
36  TRungeKutta(const TRungeKutta *from); //Special ctr without errs
37  TRungeKutta(const THelixTrack_ &from,TRKuttaMag* mag =0);
38 virtual ~TRungeKutta();
39 TRungeKutta &operator=(const TRungeKutta &from);
40  void SetMag (TRKuttaMag* mag);
41  void ZetMag (const double *h);//init FbInp & fBOut by the same field
42 static void SetMAG (TRKuttaMag* mag){ fgMag = mag ;};
43  void Set (int charge,const double xyz[3],const double mom[3]);
44  void SetEmx(const double *err=0);
45  void SetEmx(const THEmx3d_t *err);
46  THEmx3d_t *Emx() const { return fEmx3d;}
47  void SetDerOn(int derOn=1){ fDerOn =derOn;}
48  int IsDerOn() const { return fDerOn;}
50  void Backward();
52  double Move(double step);
54  double Eval(double step, double xyz[3]=0, double mom[3]=0) const;
57  double Path(const double point[3], int idir=0,int ndca=3) const;
58 
60  double Path(double x,double y, int idir=0) const ;
62  double Move();
63 
65  double Dca(double x,double y,double *dcaErr=0) const ;
66  double Dca(const double point[3],double *dcaErr) const;
67 
68  const double *Pos() const {return fInp.X;}
69  const double *Dir() const {return fInp.D;}
70  const double *Mom() const {return fInp.P;}
71  const double *Mag() const {return fBOut ;}
72  double MomTot() const {return fabs(1./fInp.Pinv);}
73  double Pinv() const {return fInp.Pinv;}
74  void SetPinv(double Pinv) {fInp.Pinv=Pinv;fInp.Update();}
75  int Charge() const {return fCharge;}
76  double GetCurv() const; //Full curvature in current point
77  int GetDir() const; //0=Outside==>Inside
78 
79  const THDer3d_t *Der() const {return fDer3d;}
80  const TkDir_t &TkDir(int idx) const { return fDer3d->mTkDir[idx];}
81 
82  void Print(Option_t *opt="") const;
83 // statics
84 static void Test(int flag=3);
85 static void Test2();
86 static void Test3();
87 static void TestBak();
88 static void TestDer();
89 static void TestDer2();
90 static void TestErr (int charge=1);
91 static void TestErr2(int charge=1);
92 static void TestSign();
93 
94 
95 protected:
96  void MakeMtx();
97  void grkuta(double CHARGE,double STEP
98  ,const TRKutaPars_t &VECT,TRKutaPars_t &VOUT) const;
99 
100 protected:
101  char fBeg[1];
102  char fDerOn;
103  char fCharge;
104  TRKuttaMag *fGUFLD;
105  TRKutaPars_t fInp;
106  THEmx3d_t *fEmx3d;
107  THDer3d_t *fDer3d;
108  mutable int fNStps;
109  mutable double fLen;
110  mutable TRKutaPars_t fOut;
111  mutable double fBInp[3];
112  mutable double fBOut[3];
113 
114  char fEnd[1];
115 static TRKuttaMag *fgMag;
116 ClassDef(TRungeKutta,0)
117 };
118 
119 
120 #endif // TRUNGEKUTTA_H
double Move()
Move to point founded before.
double Eval(double step, double xyz[3]=0, double mom[3]=0) const
Evaluate params with given step along helix.
double Dca(double x, double y, double *dcaErr=0) const
DCA to given 2dim point (with error matrix)
static void TestErr(int charge=1)
void Backward()
Change direction.
double Path(const double point[3], int idir=0, int ndca=3) const