]> git.uio.no Git - u/mrichter/AliRoot.git/blame - RICH/AliRICHHelix.h
Additional protection. This code should be revised carefully
[u/mrichter/AliRoot.git] / RICH / AliRICHHelix.h
CommitLineData
998b831f 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
9class AliRICHHelix: public TObject
10{
11public:
d3eb6079 12 AliRICHHelix():TObject() {;}
13 AliRICHHelix(const TVector3 &x0,const TVector3 &p0,Int_t q=1,Double_t b=0.2):TObject(),fX0(x0),fP0(p0),fX(x0),fP(p0),
14 fLen(0),fQ(q),fBz(b) {;}
15 virtual ~AliRICHHelix() {;}
16
17 inline void Propagate(Double_t len); //propogate helix by length len along it
18 inline Int_t RichIntersect(AliRICHParam *pParam); //search intersection with any RICH chamber
19 inline Bool_t Intersection(TVector3 planePnt,TVector3 planeNorm); //intersection with plane given by point and normal vector
20 Bool_t Intersection(TVector3 pl) {return Intersection(pl,pl.Unit());} // special plane given by point only
21 TVector2 PosRad() const{return fPosRad;} //returns position of intersection with radiator (local system)
22 TVector2 PosAnod() const{return fPosAnod;} //returns position of intersection with anod wires plane (local system)
23 TVector2 PosPc() const{return fPosPc;} //returns position of intersection with PC (local system)
24 TVector3 Ploc() const{return fPloc;} //returns momentum at the position of intersection with radiator
25 void Print(Option_t *sOption)const; //virtual interface from TObject
998b831f 26protected:
27 TVector3 fX0; //helix position in parametrised point, cm in MRS
28 TVector3 fP0; //helix momentum in parametrised point, GeV/c in MRS
29 TVector3 fX; //helix position in point of interest, cm in MRS
30 TVector3 fP; //helix momentum in point of interest, GeV/c in MRS
d3eb6079 31 Double_t fLen; //helix length in point of interest
998b831f 32 Int_t fQ; //sign of track charge (value not provided by current ESD)
33 Double_t fBz; //magnetic field along z value in Tesla under assumption of uniformity
d3eb6079 34 TVector2 fPosRad; //track intersection with radiator (local system)
35 TVector2 fPosAnod; //track intersection with anod wires plane (local system)
36 TVector2 fPosPc; //track intersection with PC (local system)
998b831f 37 TVector3 fPloc; //momentum in local system
38 ClassDef(AliRICHHelix,0) //General helix
39};//class AliRICHHelix
40//__________________________________________________________________________________________________
d3eb6079 41void AliRICHHelix::Propagate(Double_t len)
998b831f 42{
43// Propogates the helix to the position of interest defined by helix length s
44// Assumes uniform magnetic field along z direction.
45 const Double_t c = 0.00299792458;//this value provides that coordinates are in cm momentum in GeV/c
46 Double_t a = -c*fBz*fQ;
47
48 Double_t rho = a/fP0.Mag();
d3eb6079 49 fX.SetX( fX0.X()+fP0.X()*TMath::Sin(rho*len)/a-fP0.Y()*(1-TMath::Cos(rho*len))/a );
50 fX.SetY( fX0.Y()+fP0.Y()*TMath::Sin(rho*len)/a+fP0.X()*(1-TMath::Cos(rho*len))/a );
51 fX.SetZ( fX0.Z()+fP0.Z()*len/fP0.Mag() );
52 fP.SetX( fP0.X()*TMath::Cos(rho*len)-fP0.Y()*TMath::Sin(rho*len) );
53 fP.SetY( fP0.Y()*TMath::Cos(rho*len)+fP0.X()*TMath::Sin(rho*len) );
54 fP.SetZ( fP0.Z() );
55 fLen=len;
998b831f 56}
57//__________________________________________________________________________________________________
58Bool_t AliRICHHelix::Intersection(TVector3 planePoint,TVector3 planeNorm)
59{
60// Finds point of intersection (if exists) of the helix to the plane given by point and normal vector.
61// Returns kTrue if helix intersects the plane, kFALSE otherwise.
62// Stores result in current helix fields fX and fP.
63
d3eb6079 64 Double_t s=(planePoint-fX0)*planeNorm,dist=99999,distPrev=dist;//estimates initial distance to plane
998b831f 65
d3eb6079 66 while(TMath::Abs(dist)>0.00001){
998b831f 67 Propagate(s); //calculates helix at the distance s from x0 ALONG the helix
68 dist=(fX-planePoint)*planeNorm; //distance between current helix position and plane
e84e7c82 69 if(TMath::Abs(dist) >= TMath::Abs(distPrev)) { return kFALSE;}
998b831f 70 distPrev=dist;
71 s-=dist;
72 }
73 return kTRUE;
74}
75//__________________________________________________________________________________________________
76Int_t AliRICHHelix::RichIntersect(AliRICHParam *pParam)
77{
78// Searchs for intersection of this helix with all RICH chambers, returns chamber number or 0 if no intersection
79// On exit fPosRad contain position of intersection in Local System with radiator
80// fPosPc contains the same for photocathode
81 for(Int_t iChamberN=1;iChamberN<=kNchambers;iChamberN++){//chamber loop
82 if(Intersection(pParam->C(iChamberN)->Rad())){//there is intersection with radiator plane
83 fPosRad=pParam->C(iChamberN)->Mrs2Rad(fX);//position on radiator plane
84 if(pParam->IsAccepted(fPosRad)){//intersection within radiator (even if in dead zone)
d3eb6079 85
998b831f 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)
d3eb6079 89
90 Intersection(pParam->C(iChamberN)->Anod()); //search for anod intersection position
91 fPosAnod=pParam->C(iChamberN)->Mrs2Anod(fX);
92
93 fPloc=pParam->C(iChamberN)->PMrs2Loc(fP);//trasform p to local system
998b831f 94 return iChamberN;
95 }//if inside PC
d3eb6079 96 }//if intersects PC
97
998b831f 98 }//if inside radiator
99 }//if for radiator
100 }//chamber loop
101 return 0;
102}
103//__________________________________________________________________________________________________
104#endif