]> git.uio.no Git - u/mrichter/AliRoot.git/blob - RICH/AliRICHHelix.h
Additional protection in case of zero magnetic field (Yu.Belikov)
[u/mrichter/AliRoot.git] / RICH / AliRICHHelix.h
1 #ifndef AliRICHHelix_h
2 #define AliRICHHelix_h
3
4 #include <TObject.h>
5 #include <TVector3.h>
6 #include "AliRICHParam.h"
7 #include "AliRICHChamber.h"
8
9 class AliRICHHelix: public TObject
10 {
11 public:
12            AliRICHHelix()                                              {;}
13            AliRICHHelix(TVector3 x0,TVector3 p0,Int_t q,Double_t b=0.4)  {fX0=x0;fP0=p0;fQ=q;fBz=b;} //takes position and momentum at parametrised point
14   virtual ~AliRICHHelix()                                              {;}        
15   inline void   Propagate(Double_t lenght);
16          Bool_t Intersection(TVector3 plane)          {return Intersection(plane,plane.Unit());} // special plane given by point only
17   inline Bool_t Intersection(TVector3 planePoint,TVector3 planeNorm); //intersection with plane given by point and normal vector
18   inline Int_t  RichIntersect(AliRICHParam *pParam);
19   TVector3 X()const {return fX;}
20   TVector3 P()const {return fP;}
21   TVector3 X0()const {return fX0;}
22   TVector3 P0()const {return fP0;}
23   TVector2 PosPc() const {return fPosPc;}           //returns position of intersection with PC
24   TVector2 PosRad()const {return fPosRad;}          //returns position of intersection with radiator 
25   TVector3 Ploc()const   {return fPloc;}            //returns momentum at the position of intersection with radiator 
26   
27          void   Print(Option_t *sOption)const; //virtual interface from TObject
28 protected:
29   TVector3 fX0;            //helix position in parametrised point, cm    in MRS
30   TVector3 fP0;            //helix momentum in parametrised point, GeV/c in MRS
31   TVector3 fX;             //helix position in point of interest,  cm    in MRS
32   TVector3 fP;             //helix momentum in point of interest,  GeV/c in MRS
33   Double_t fLength;        //helix length in point of interest    
34   Int_t    fQ;             //sign of track charge (value not provided by current ESD)  
35   Double_t fBz;            //magnetic field along z value in Tesla under assumption of uniformity 
36   TVector2 fPosPc;         //position on PC in local system
37   TVector2 fPosRad;        //position on radiator in local system 
38   TVector3 fPloc;          //momentum in local system
39   ClassDef(AliRICHHelix,0) //General helix
40 };//class AliRICHHelix
41 //__________________________________________________________________________________________________
42 void AliRICHHelix::Propagate(Double_t length)
43 {
44 // Propogates the helix to the position of interest defined by helix length s  
45 // Assumes uniform magnetic field along z direction.  
46   const Double_t c = 0.00299792458;//this value provides that coordinates are in cm momentum in GeV/c
47   Double_t a = -c*fBz*fQ;
48  
49   Double_t rho = a/fP0.Mag();
50   fX.SetX( fX0.X()+fP0.X()*TMath::Sin(rho*length)/a-fP0.Y()*(1-TMath::Cos(rho*length))/a  );
51   fX.SetY( fX0.Y()+fP0.Y()*TMath::Sin(rho*length)/a+fP0.X()*(1-TMath::Cos(rho*length))/a  ); 
52   fX.SetZ( fX0.Z()+fP0.Z()*length/fP0.Mag()                                               );
53   fP.SetX( fP0.X()*TMath::Cos(rho*length)-fP0.Y()*TMath::Sin(rho*length)                  );
54   fP.SetY( fP0.Y()*TMath::Cos(rho*length)+fP0.X()*TMath::Sin(rho*length)                  );
55   fP.SetZ( fP0.Z()                                                                        );
56   fLength=length;
57 }
58 //__________________________________________________________________________________________________
59 Bool_t AliRICHHelix::Intersection(TVector3 planePoint,TVector3 planeNorm)
60 {
61 // Finds point of intersection (if exists) of the helix to the plane given by point and normal vector.
62 // Returns kTrue if helix intersects the plane, kFALSE otherwise.
63 // Stores result in current helix fields fX and fP.   
64   
65   Double_t s=(planePoint-fX0)*planeNorm,dist=99999,distPrev=dist;
66
67   while(TMath::Abs(dist)>0.0001){
68     Propagate(s);                        //calculates helix at the distance s from x0 ALONG the helix
69     dist=(fX-planePoint)*planeNorm;      //distance between current helix position and plane
70     if(TMath::Abs(dist) > TMath::Abs(distPrev)) { return kFALSE;}
71     distPrev=dist;
72     s-=dist;
73   }
74   return kTRUE;
75 }
76 //__________________________________________________________________________________________________
77 Int_t AliRICHHelix::RichIntersect(AliRICHParam *pParam)
78 {
79 // Searchs for intersection of this helix with all RICH chambers, returns chamber number or 0 if no intersection
80 // On exit fPosRad contain position of intersection in Local System with radiator     
81 //         fPosPc  contains the same for photocathode  
82   for(Int_t iChamberN=1;iChamberN<=kNchambers;iChamberN++){//chamber loop
83     if(Intersection(pParam->C(iChamberN)->Rad())){//there is intersection with radiator plane
84       fPosRad=pParam->C(iChamberN)->Mrs2Rad(fX);//position on radiator plane
85       if(pParam->IsAccepted(fPosRad)){//intersection within radiator (even if in dead zone)
86         if(Intersection(pParam->C(iChamberN)->Pc())){//there is intersection with photocathode
87           fPosPc=pParam->C(iChamberN)->Mrs2Pc(fX);//position on photcathode plane
88           if(pParam->IsAccepted(fPosPc)){//intersection within pc (even if in dead zone)
89             fPloc=pParam->C(iChamberN)->PMrs2Loc(fP);
90             return iChamberN;
91           }//if inside PC
92         }//if for PC
93       }//if inside radiator
94     }//if for radiator       
95   }//chamber loop
96   return 0;
97 }
98 //__________________________________________________________________________________________________    
99 #endif