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