]> git.uio.no Git - u/mrichter/AliRoot.git/blob - RICH/AliRICHHelix.h
adding entries parameter to execute function
[u/mrichter/AliRoot.git] / RICH / AliRICHHelix.h
1 #ifndef AliRICHHelix_h
2 #define AliRICHHelix_h
3
4 #include <TObject.h>              //base class
5 #include <TVector3.h>             //used extensively
6
7 class AliRICHHelix: public TObject
8 {
9 public:
10   AliRICHHelix(                                                            ):TObject(),fX0(TVector3(0,0,0)),fP0(TVector3(0,0,0)),fQ(0),fBz(0 )  {}
11   AliRICHHelix(const TVector3 &x0,const TVector3 &p0,Int_t q=1,Double_t b=2):TObject(),fX0(x0             ),fP0(p0             ),fQ(q),fBz(b )  {}
12   AliRICHHelix(Double_t p,Double_t theta,Double_t phi,Double_t bz=2        ):TObject(),fX0(TVector3(0,0,0)),fP0(TVector3(0,0,0)),fQ(0),fBz(bz)  
13                    {fP0.SetMagThetaPhi(p,theta*TMath::DegToRad(),phi*TMath::DegToRad());} //p [GeV], theta,phi [deg], Bz [Tesla];
14   virtual ~AliRICHHelix()                                                                                                                   {}        
15            
16          void     Draw          (const Option_t *opt=""              );                              //from TObject, draw helix
17          void     Print    (const Option_t *opt=""              )const;                         //from TObject, print status
18 //private part++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
19   inline Bool_t   Intersect(            TVector3 &pnt,TVector3 &norm );          //intersection with plane given by point and normal vector
20   inline void     Propagate(Float_t len,TVector3 &x,  TVector3 &p    );          //propogate helix by given length along it            
21 protected:
22   TVector3 fX0;            //helix position in point of definition, [cm]    in MARS
23   TVector3 fP0;            //helix momentum in point of definition, [GeV/c] in MARS
24   Int_t    fQ;             //sign of track charge  
25   Float_t  fBz;            //magnetic field along z, [kGaus] 
26   ClassDef(AliRICHHelix,0) //General helix
27 };//class AliRICHHelix
28 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
29 void AliRICHHelix::Propagate(Float_t len,TVector3 &x,TVector3 &p)
30 {
31 // Propogates the helix from inintial point by a given distance along helix. Assumes uniform magnetic field along z direction.  
32 // Arguments: len - distance to propagate by, [cm]
33 //   Returns: none    
34   if(fBz==0){//no magnetic field->straight line
35     x=fX0+fP0.Unit()*len;   
36     p=fP0;
37   }else{
38     const Float_t c = 0.000299792458;//this speed of light value provides that coordinates are in [cm] momentum in [GeV/c] field in [kGaus]
39     Float_t a = -c*fBz*fQ;
40     Float_t rho = a/fP0.Mag();
41     x.SetX( fX0.X()+fP0.X()*TMath::Sin(rho*len)/a-fP0.Y()*(1-TMath::Cos(rho*len))/a  );
42     x.SetY( fX0.Y()+fP0.Y()*TMath::Sin(rho*len)/a+fP0.X()*(1-TMath::Cos(rho*len))/a  ); 
43     x.SetZ( fX0.Z()+fP0.Z()*len/fP0.Mag()                                            );
44     x.SetX( fP0.X()*TMath::Cos(rho*len)-fP0.Y()*TMath::Sin(rho*len)                  );
45     p.SetY( fP0.Y()*TMath::Cos(rho*len)+fP0.X()*TMath::Sin(rho*len)                  );
46     p.SetZ( fP0.Z()                                                                  );
47   }
48 }//Propagate()
49 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
50 Bool_t AliRICHHelix::Intersect(TVector3 &pnt,TVector3 &norm)
51 {
52 // Finds point of intersection (if exists) of the helix with the plane. Stores result in fX and fP.   
53 // Arguments: pnt  - arbitrary point of the plane, [cm] in MARS
54 //            norm - vector, normal to the plane, [cm] in MARS
55 //   Returns:      - kTrue if helix intersects the plane, kFALSE otherwise.
56 //                 - pnt contains the point of intersection, [cm] in MARS  
57   TVector3 x,p;                                                    //current helix position and momentum
58   Double_t s=(pnt-fX0)*norm,dist=99999,distPrev=dist;              //estimates initial distance to plane
59   while(TMath::Abs(dist)>0.00001){                                 //loop while the distance is less then precision   
60     Propagate(s,x,p);                                              //calculates helix at the distance s from x0 ALONG the helix
61     dist=(x-pnt)*norm;                                             //distance between current helix position and plane
62     if(TMath::Abs(dist) >= TMath::Abs(distPrev)) { return kFALSE;} //if distance increases then no intersection 
63     distPrev=dist;
64     s-=dist;
65   }  
66   norm=p;
67   pnt=x;                                    
68   return kTRUE;
69 }//Intersect()
70 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
71 #endif