]> git.uio.no Git - u/mrichter/AliRoot.git/blame - RICH/AliRICHHelix.h
o) Adding time out to the execution of the preprocessors: The Shuttle forks and the...
[u/mrichter/AliRoot.git] / RICH / AliRICHHelix.h
CommitLineData
998b831f 1#ifndef AliRICHHelix_h
2#define AliRICHHelix_h
3
db910db9 4#include <TObject.h> //base class
5#include <TVector3.h> //used extensively
6#include "AliRICHParam.h" //RichIntersect()
998b831f 7
8class AliRICHHelix: public TObject
9{
10public:
4c3a1f92 11 AliRICHHelix():TObject(),
12 fX0(TVector3(0,0,0)),
13 fP0(TVector3(0,0,0)),
14 fX(TVector3(0,0,0)),
15 fP(TVector3(0,0,0)),
16 fLen(0),
17 fQ(0),
18 fBz(0),
19 fPosRad(TVector2(0,0)),
20 fPosPc(TVector2(0,0)),
21 fPloc(TVector3(0,0,0)) {}
db910db9 22 AliRICHHelix(Double_t p,Double_t theta,Double_t phi,Double_t bz=0.2);//p [GeV], theta,phi [deg], Bz [Tesla];
4c3a1f92 23 AliRICHHelix(const TVector3 &x0,const TVector3 &p0,Int_t q=1,Double_t b=0.2):TObject(),
24 fX0(x0),
25 fP0(p0),
26 fX(x0),
27 fP(p0),
28 fLen(0),
29 fQ(q),
30 fBz(b),
31 fPosRad(TVector2(0,0)),
32 fPosPc(TVector2(0,0)),
33 fPloc(TVector3(0,0,0)) {}
db910db9 34 virtual ~AliRICHHelix() {}
d3eb6079 35
db910db9 36 void Draw (const Option_t *opt="" ); //from TObject, draw helix
37 void Print (const Option_t *opt="" )const; //from TObject, print status
38//private part++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
39 inline Bool_t Intersection (TVector3 planePnt,TVector3 planeNorm); //intersection with plane given by point and normal vector
40 inline void Propagate (Double_t len ); //propogate helix by given length along it
41 inline Int_t RichIntersect (AliRICHParam *pParam ); //search intersection with any RICH chamber
42 TVector2 PosRad ( )const{return fPosRad;} //intersection with radiator LORS
43 TVector2 PosPc ( )const{return fPosPc;} //returns position of intersection with PC (local system)
44 TVector3 Ploc ( )const{return fPloc;} //returns momentum at the position of intersection with radiator
45// Double_t Length () const{return fLen;} //returns length of the track from initial point to RICH
46 TVector3 X ( )const{return fX;}
998b831f 47protected:
db910db9 48 TVector3 fX0; //helix position in point of definition, [cm] in MARS
49 TVector3 fP0; //helix momentum in point of definition, [GeV/c] in MARS
50 TVector3 fX; //helix position in point of interest, [cm] in MARS
51 TVector3 fP; //helix momentum in point of interest, [GeV/c] in MARS
52 Double_t fLen; //helix length from point of definition to point of interest, [cm]
998b831f 53 Int_t fQ; //sign of track charge (value not provided by current ESD)
db910db9 54 Double_t fBz; //magnetic field along z, [Tesla]
55 TVector2 fPosRad; //helix intersection with radiator entrance, LORS [cm]
56 TVector2 fPosPc; //helix intersection with PC, LORS [cm]
57 TVector3 fPloc; //helix momentum, LORS [GeV/c]
998b831f 58 ClassDef(AliRICHHelix,0) //General helix
59};//class AliRICHHelix
db910db9 60//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
d3eb6079 61void AliRICHHelix::Propagate(Double_t len)
998b831f 62{
db910db9 63// Propogates the helix from inintial point by a given distance along helix. Assumes uniform magnetic field along z direction.
64// Arguments: len - distance to propagate by, [cm]
65// Returns: none
66 if(fBz==0){//no magnetic field->straight line
67 fX=fX0+fP0.Unit()*len;
68 }else{
69 const Double_t c = 0.00299792458;//this speed of light value provides that coordinates are in cm momentum in GeV/c
70 Double_t a = -c*fBz*fQ;
71 Double_t rho = a/fP0.Mag();
72 fX.SetX( fX0.X()+fP0.X()*TMath::Sin(rho*len)/a-fP0.Y()*(1-TMath::Cos(rho*len))/a );
73 fX.SetY( fX0.Y()+fP0.Y()*TMath::Sin(rho*len)/a+fP0.X()*(1-TMath::Cos(rho*len))/a );
74 fX.SetZ( fX0.Z()+fP0.Z()*len/fP0.Mag() );
75 fP.SetX( fP0.X()*TMath::Cos(rho*len)-fP0.Y()*TMath::Sin(rho*len) );
76 fP.SetY( fP0.Y()*TMath::Cos(rho*len)+fP0.X()*TMath::Sin(rho*len) );
77 fP.SetZ( fP0.Z() );
78 fLen=len;
79 }
998b831f 80}
db910db9 81//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
998b831f 82Bool_t AliRICHHelix::Intersection(TVector3 planePoint,TVector3 planeNorm)
83{
db910db9 84// Finds point of intersection (if exists) of the helix with the plane. Stores result in fX and fP.
85// Arguments: planePoint,planeNorm - the plane defined by any plane's point and vector, normal to the plane
86// Returns: kTrue if helix intersects the plane, kFALSE otherwise.
998b831f 87
d3eb6079 88 Double_t s=(planePoint-fX0)*planeNorm,dist=99999,distPrev=dist;//estimates initial distance to plane
998b831f 89
d3eb6079 90 while(TMath::Abs(dist)>0.00001){
998b831f 91 Propagate(s); //calculates helix at the distance s from x0 ALONG the helix
92 dist=(fX-planePoint)*planeNorm; //distance between current helix position and plane
e84e7c82 93 if(TMath::Abs(dist) >= TMath::Abs(distPrev)) { return kFALSE;}
998b831f 94 distPrev=dist;
95 s-=dist;
96 }
97 return kTRUE;
98}
db910db9 99//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
998b831f 100Int_t AliRICHHelix::RichIntersect(AliRICHParam *pParam)
101{
102// Searchs for intersection of this helix with all RICH chambers, returns chamber number or 0 if no intersection
db910db9 103// On exit fPosRad contain position of intersection in radiator LORS (cm)
998b831f 104// fPosPc contains the same for photocathode
cb801d41 105 for(Int_t iCh=1;iCh<=AliRICHParam::kNch;iCh++){//chambers loop
106 TVector3 norm =pParam->Lors2MarsVec(iCh,TVector3(0,0,1));
107 if(Intersection(pParam->Lors2Mars(iCh,0,0,AliRICHParam::kRad),norm)){//there is intersection with radiator plane
108 fPosRad=pParam->Mars2Lors(iCh,fX,AliRICHParam::kRad);//position on radiator plane
998b831f 109 if(pParam->IsAccepted(fPosRad)){//intersection within radiator (even if in dead zone)
d3eb6079 110
cb801d41 111 if(Intersection(pParam->Lors2Mars(iCh,0,0,AliRICHParam::kPc),norm)){//there is intersection with photocathode
112 fPosPc=pParam->Mars2Lors(iCh,fX,AliRICHParam::kPc);//position on radiator plane
998b831f 113 if(pParam->IsAccepted(fPosPc)){//intersection within pc (even if in dead zone)
d3eb6079 114
cb801d41 115 fPloc=pParam->Mars2LorsVec(iCh,fP);//trasform p to local system
116 return iCh;
998b831f 117 }//if inside PC
d3eb6079 118 }//if intersects PC
119
998b831f 120 }//if inside radiator
121 }//if for radiator
cb801d41 122 }//chambers loop
998b831f 123 return 0;
124}
db910db9 125//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
998b831f 126#endif