Added residual calc. and ntuppels
[u/mrichter/AliRoot.git] / HLT / src / AliL3Track.cxx
CommitLineData
108615fc 1//Author: Anders Strand Vestbo
2//Author: Uli Frankenfeld
3//Last Modified: 06.03.2001
4
5//____________________________________
6// AliL3Track
7//
8// Base track class for L3
9
10//Changes:
11
12//14.03.01: Moved fHitNumbers from protected to private.-ASV
13// Set memory to zero in ctor.
14// Moved fNHits 2 private. Protected data members not a good idea after all.
15//19.03.01: Made the method void Set(AliL3Track) virtual.
16
17#include "AliL3RootTypes.h"
18
19#include "AliL3Logging.h"
20#include "AliL3Track.h"
21#include <math.h>
22
23ClassImp(AliL3Track)
24
25Float_t AliL3Track::BFACT = 0.0029980;
26Float_t AliL3Track::bField = 0.2;
27Double_t AliL3Track::pi=3.14159265358979323846;
28
29AliL3Track::AliL3Track()
30{
31 //Constructor
32
33 fNHits = 0;
34 fMCid = -1;
35 fKappa=0;
36 fRadius=0;
37 fCenterX=0;
38 fCenterY=0;
39 ComesFromMainVertex(false);
40 fQ = 0;
41 fPhi0=0;
42 fPsi=0;
43 fR0=0;
44 fTanl=0;
45 fZ0=0;
46 fPt=0;
47 fLength=0;
48 fIsLocal=true;
49 fRowRange[0]=0;
50 fRowRange[1]=0;
51 memset(fHitNumbers,0,174*sizeof(UInt_t));
52}
53
54void AliL3Track::Set(AliL3Track *tpt){
55
3a735e00 56 SetRowRange(tpt->GetFirstRow(),tpt->GetLastRow());
57 SetPhi0(tpt->GetPhi0());
58 SetKappa(tpt->GetKappa());
59 SetNHits(tpt->GetNHits());
60 SetFirstPoint(tpt->GetFirstPointX(),tpt->GetFirstPointY(),tpt->GetFirstPointZ());
61 SetLastPoint(tpt->GetLastPointX(),tpt->GetLastPointY(),tpt->GetLastPointZ());
62 SetPt(tpt->GetPt());
63 SetPsi(tpt->GetPsi());
64 SetTgl(tpt->GetTgl());
65 SetCharge(tpt->GetCharge());
66 SetHits(tpt->GetNHits(),(UInt_t *)tpt->GetHitNumbers());
108615fc 67
108615fc 68
108615fc 69}
70
71
72AliL3Track::~AliL3Track()
73{
74
75}
76
77Double_t AliL3Track::GetP() const
78{
79 // Returns total momentum.
80
81 return fabs(GetPt())*sqrt(1. + GetTgl()*GetTgl());
82
83}
84
85Double_t AliL3Track::GetPseudoRapidity() const
86{
87 return 0.5 * log((GetP() + GetPz()) / (GetP() - GetPz()));
88}
89
90Double_t AliL3Track::GetEta() const
91{
92 return GetPseudoRapidity();
93}
94
95Double_t AliL3Track::GetRapidity() const
96{
97 Double_t m_pi = 0.13957;
98 return 0.5 * log((m_pi + GetPz()) / (m_pi - GetPz()));
99}
100
101void AliL3Track::CalculateHelix(){
102 //Calculate Radius, CenterX and Centery from Psi, X0, Y0
103 //
104
105 fRadius = fPt / (BFACT*bField);
106 if(fRadius) fKappa = 1./fRadius;
107 else fRadius = 999999; //just zero
108 Double_t trackPhi0 = fPsi + fQ *0.5 * pi;
109
110 fCenterX = fFirstPoint[0] - fRadius * cos(trackPhi0);
111 fCenterY = fFirstPoint[1] - fRadius * sin(trackPhi0);
112}
113
114Bool_t AliL3Track::CalculateReferencePoint(Double_t angle){
115 // Global coordinate: crossing point with y = ax+ b; a=tan(angle-Pi/2);
116 //
117 const Double_t rr=132; //position of referece plane
118 const Double_t xr = cos(angle) *rr;
119 const Double_t yr = sin(angle) *rr;
120
121 Double_t a = tan(angle-pi/2);
122 Double_t b = yr - a * xr;
123
124 Double_t pp=(fCenterX+a*fCenterY-a*b)/(1+pow(a,2));
125 Double_t qq=(pow(fCenterX,2)+pow(fCenterY,2)-2*fCenterY*b+pow(b,2)-pow(fRadius,2))/(1+pow(a,2));
126
127 Double_t racine = pp*pp-qq;
128 if(racine<0) return IsPoint(kFALSE); //no Point
129
130 Double_t rootRacine = sqrt(racine);
131 Double_t x0 = pp+rootRacine;
132 Double_t x1 = pp-rootRacine;
133 Double_t y0 = a*x0 + b;
134 Double_t y1 = a*x1 + b;
135
136 Double_t diff0 = sqrt(pow(x0-xr,2)+pow(y0-yr,2));
137 Double_t diff1 = sqrt(pow(x1-xr,2)+pow(y1-yr,2));
138
139 if(diff0<diff1){
140 fPoint[0]=x0;
141 fPoint[1]=y0;
142 }
143 else{
144 fPoint[0]=x1;
145 fPoint[1]=y1;
146 }
147
148 Double_t pointPhi0 = atan2(fPoint[1]-fCenterY,fPoint[0]-fCenterX);
149 Double_t trackPhi0 = atan2(fFirstPoint[1]-fCenterY,fFirstPoint[0]-fCenterX);
150 if(fabs(trackPhi0-pointPhi0)>pi){
151 if(trackPhi0<pointPhi0) trackPhi0 += 2*pi;
152 else pointPhi0 += 2*pi;
153 }
154 Double_t stot = -fQ * (pointPhi0-trackPhi0) * fRadius ;
155 fPoint[2] = fFirstPoint[2] + stot * fTanl;
156
157 fPointPsi = pointPhi0 - fQ * 0.5 * pi;
158 if(fPointPsi<0.) fPointPsi+= 2*pi;
159 fPointPsi = fmod(fPointPsi, 2*pi);
160
161 return IsPoint(kTRUE);
162}
163
164Bool_t AliL3Track::CalculateEdgePoint(Double_t angle){
165 // Global coordinate: crossing point with y = ax; a=tan(angle);
166 //
167 Double_t rmin=80; //min Radius of TPC
168 Double_t rmax=260; //max Radius of TPC
169
170 Double_t a = tan(angle);
171 Double_t pp=(fCenterX+a*fCenterY)/(1+pow(a,2));
172 Double_t qq=(pow(fCenterX,2)+pow(fCenterY,2)-pow(fRadius,2))/(1+pow(a,2));
173 Double_t racine = pp*pp-qq;
174 if(racine<0) return IsPoint(kFALSE); //no Point
175 Double_t rootRacine = sqrt(racine);
176 Double_t x0 = pp+rootRacine;
177 Double_t x1 = pp-rootRacine;
178 Double_t y0 = a*x0;
179 Double_t y1 = a*x1;
180
181 Double_t r0 = sqrt(pow(x0,2)+pow(y0,2));
182 Double_t r1 = sqrt(pow(x1,2)+pow(y1,2));
183 //find the right crossing point:
184 //inside the TPC modules
185 Bool_t ok0 = kFALSE;
186 Bool_t ok1 = kFALSE;
187 if(r0>rmin&&r0<rmax){
188 Double_t da=atan2(y0,x0);
189 if(da<0) da+=pi;
190 if(fabs(da-angle)<0.5)
191 ok0 = kTRUE;
192 }
193 if(r1>rmin&&r1<rmax){
194 Double_t da=atan2(y1,y1);
195 if(da<0) da+=pi;
196 if(fabs(da-angle)<0.5)
197 ok1 = kTRUE;
198 }
199 if(!(ok0||ok1)) return IsPoint(kFALSE); //no Point
200
201 if(ok0&&ok1){
202 Double_t diff0 = sqrt(pow(fFirstPoint[0]-x0,2)+pow(fFirstPoint[1]-y0,2));
203 Double_t diff1 = sqrt(pow(fFirstPoint[0]-x1,2)+pow(fFirstPoint[1]-y1,2));
204 if(diff0<diff1) ok1 = kFALSE; //use ok0
205 else ok0 = kFALSE; //use ok1
206 }
207 if(ok0){fPoint[0]=x0; fPoint[1]=y0;}
208 else {fPoint[0]=x1; fPoint[1]=y1;}
209
210 Double_t pointPhi0 = atan2(fPoint[1]-fCenterY,fPoint[0]-fCenterX);
211 Double_t trackPhi0 = atan2(fFirstPoint[1]-fCenterY,fFirstPoint[0]-fCenterX);
212 if(fabs(trackPhi0-pointPhi0)>pi){
213 if(trackPhi0<pointPhi0) trackPhi0 += 2*pi;
214 else pointPhi0 += 2*pi;
215 }
216 Double_t stot = -fQ * (pointPhi0-trackPhi0) * fRadius ;
217 fPoint[2] = fFirstPoint[2] + stot * fTanl;
218
219 fPointPsi = pointPhi0 - fQ * 0.5 * pi;
220 if(fPointPsi<0.) fPointPsi+= 2*pi;
221 fPointPsi = fmod(fPointPsi, 2*pi);
222
223 return IsPoint(kTRUE);
224}
225
226Bool_t AliL3Track::CalculatePoint(Double_t xplane){
227 // Local coordinate: crossing point with x plane
228 //
229 Double_t racine = pow(fRadius,2)-pow(xplane-fCenterX,2);
230 if(racine<0) return IsPoint(kFALSE);
231 Double_t rootRacine = sqrt(racine);
232
233 Double_t y0 = fCenterY + rootRacine;
234 Double_t y1 = fCenterY - rootRacine;
235 //Double_t diff0 = sqrt(pow(fFirstPoint[0]-xplane)+pow(fFirstPoint[1]-y0));
236 //Double_t diff1 = sqrt(pow(fFirstPoint[0]-xplane)+pow(fFirstPoint[1]-y1));
237 Double_t diff0 = fabs(y0-fFirstPoint[1]);
238 Double_t diff1 = fabs(y1-fFirstPoint[1]);
239
240 fPoint[0]=xplane;
241 if(diff0<diff1) fPoint[1]=y0;
242 else fPoint[1]=y1;
243
244 Double_t pointPhi0 = atan2(fPoint[1]-fCenterY,fPoint[0]-fCenterX);
245 Double_t trackPhi0 = atan2(fFirstPoint[1]-fCenterY,fFirstPoint[0]-fCenterX);
246 if(fabs(trackPhi0-pointPhi0)>pi){
247 if(trackPhi0<pointPhi0) trackPhi0 += 2*pi;
248 else pointPhi0 += 2*pi;
249 }
250 Double_t stot = -fQ * (pointPhi0-trackPhi0) * fRadius ;
251 fPoint[2] = fFirstPoint[2] + stot * fTanl;
252
253 fPointPsi = pointPhi0 - fQ * 0.5 * pi;
254 if(fPointPsi<0.) fPointPsi+= 2*pi;
255 fPointPsi = fmod(fPointPsi, 2*pi);
256
257 return IsPoint(kTRUE);
258}
259