]>
Commit | Line | Data |
---|---|---|
6d4f1901 | 1 | //$Id$ |
2 | ||
2d04dcbf | 3 | // Author: Anders Vestbo <mailto:vestbo$fi.uib.no>, Uli Frankenfeld <mailto:franken@fi.uib.no> |
4 | //*-- Copyright © ASV | |
108615fc | 5 | |
108615fc | 6 | |
7 | #include "AliL3RootTypes.h" | |
8 | ||
0391971c | 9 | #include "AliL3Defs.h" |
108615fc | 10 | #include "AliL3Logging.h" |
11 | #include "AliL3Track.h" | |
0391971c | 12 | #include "AliL3Transform.h" |
6d4f1901 | 13 | #include "AliL3Vertex.h" |
108615fc | 14 | #include <math.h> |
15 | ||
2d04dcbf | 16 | //_____________________________________________________________ |
17 | // AliL3Track | |
18 | // | |
19 | // Track base class | |
02cb36b2 | 20 | //Begin_Html |
21 | /* | |
22 | <img src="track_coordinates.gif"> | |
23 | */ | |
24 | //End_Html | |
0391971c | 25 | |
108615fc | 26 | ClassImp(AliL3Track) |
27 | ||
28 | Float_t AliL3Track::BFACT = 0.0029980; | |
108615fc | 29 | Double_t AliL3Track::pi=3.14159265358979323846; |
30 | ||
31 | AliL3Track::AliL3Track() | |
32 | { | |
33 | //Constructor | |
34 | ||
35 | fNHits = 0; | |
36 | fMCid = -1; | |
37 | fKappa=0; | |
38 | fRadius=0; | |
39 | fCenterX=0; | |
40 | fCenterY=0; | |
41 | ComesFromMainVertex(false); | |
42 | fQ = 0; | |
43 | fPhi0=0; | |
44 | fPsi=0; | |
45 | fR0=0; | |
46 | fTanl=0; | |
47 | fZ0=0; | |
48 | fPt=0; | |
49 | fLength=0; | |
50 | fIsLocal=true; | |
51 | fRowRange[0]=0; | |
52 | fRowRange[1]=0; | |
ae97a0b9 | 53 | memset(fHitNumbers,0,176*sizeof(UInt_t)); |
108615fc | 54 | } |
55 | ||
56 | void AliL3Track::Set(AliL3Track *tpt){ | |
57 | ||
3a735e00 | 58 | SetRowRange(tpt->GetFirstRow(),tpt->GetLastRow()); |
59 | SetPhi0(tpt->GetPhi0()); | |
60 | SetKappa(tpt->GetKappa()); | |
61 | SetNHits(tpt->GetNHits()); | |
62 | SetFirstPoint(tpt->GetFirstPointX(),tpt->GetFirstPointY(),tpt->GetFirstPointZ()); | |
63 | SetLastPoint(tpt->GetLastPointX(),tpt->GetLastPointY(),tpt->GetLastPointZ()); | |
64 | SetPt(tpt->GetPt()); | |
65 | SetPsi(tpt->GetPsi()); | |
66 | SetTgl(tpt->GetTgl()); | |
67 | SetCharge(tpt->GetCharge()); | |
68 | SetHits(tpt->GetNHits(),(UInt_t *)tpt->GetHitNumbers()); | |
108615fc | 69 | |
108615fc | 70 | } |
71 | ||
203925a9 | 72 | Int_t AliL3Track::Compare(const AliL3Track *track) const |
73 | { | |
74 | if(track->GetNHits() < GetNHits()) return 1; | |
75 | if(track->GetNHits() > GetNHits()) return -1; | |
76 | return 0; | |
77 | } | |
108615fc | 78 | |
79 | AliL3Track::~AliL3Track() | |
80 | { | |
203925a9 | 81 | //Nothing to do |
108615fc | 82 | } |
83 | ||
84 | Double_t AliL3Track::GetP() const | |
85 | { | |
203925a9 | 86 | // Returns total momentum. |
108615fc | 87 | return fabs(GetPt())*sqrt(1. + GetTgl()*GetTgl()); |
88 | ||
89 | } | |
90 | ||
91 | Double_t AliL3Track::GetPseudoRapidity() const | |
92 | { | |
93 | return 0.5 * log((GetP() + GetPz()) / (GetP() - GetPz())); | |
94 | } | |
203925a9 | 95 | /* |
108615fc | 96 | Double_t AliL3Track::GetEta() const |
97 | { | |
98 | return GetPseudoRapidity(); | |
99 | } | |
203925a9 | 100 | */ |
108615fc | 101 | Double_t AliL3Track::GetRapidity() const |
102 | { | |
103 | Double_t m_pi = 0.13957; | |
104 | return 0.5 * log((m_pi + GetPz()) / (m_pi - GetPz())); | |
105 | } | |
106 | ||
203925a9 | 107 | void AliL3Track::Rotate(Int_t slice,Bool_t tolocal) |
0391971c | 108 | { |
0391971c | 109 | //Rotate track to global parameters |
203925a9 | 110 | //If flag tolocal is set, the track is rotated |
111 | //to local coordinates. | |
0391971c | 112 | |
0391971c | 113 | |
114 | Float_t psi[1] = {GetPsi()}; | |
203925a9 | 115 | if(!tolocal) |
494fad94 | 116 | AliL3Transform::Local2GlobalAngle(psi,slice); |
203925a9 | 117 | else |
494fad94 | 118 | AliL3Transform::Global2LocalAngle(psi,slice); |
0391971c | 119 | SetPsi(psi[0]); |
120 | Float_t first[3]; | |
121 | first[0] = GetFirstPointX(); | |
122 | first[1] = GetFirstPointY(); | |
123 | first[2] = GetFirstPointZ(); | |
203925a9 | 124 | if(!tolocal) |
494fad94 | 125 | AliL3Transform::Local2Global(first,slice); |
203925a9 | 126 | else |
494fad94 | 127 | AliL3Transform::Global2Local(first,slice,kTRUE); |
203925a9 | 128 | |
0391971c | 129 | SetFirstPoint(first[0],first[1],first[2]); |
130 | Float_t last[3]; | |
131 | last[0] = GetLastPointX(); | |
132 | last[1] = GetLastPointY(); | |
133 | last[2] = GetLastPointZ(); | |
203925a9 | 134 | if(!tolocal) |
494fad94 | 135 | AliL3Transform::Local2Global(last,slice); |
203925a9 | 136 | else |
494fad94 | 137 | AliL3Transform::Global2Local(last,slice,kTRUE); |
0391971c | 138 | SetLastPoint(last[0],last[1],last[2]); |
203925a9 | 139 | |
6d4f1901 | 140 | Float_t center[3] = {GetCenterX(),GetCenterY(),0}; |
141 | if(!tolocal) | |
494fad94 | 142 | AliL3Transform::Local2Global(center,slice); |
6d4f1901 | 143 | else |
494fad94 | 144 | AliL3Transform::Global2Local(center,slice,kTRUE); |
6d4f1901 | 145 | SetCenterX(center[0]); |
146 | SetCenterY(center[1]); | |
147 | ||
203925a9 | 148 | if(!tolocal) |
149 | fIsLocal=kFALSE; | |
150 | else | |
151 | fIsLocal=kTRUE; | |
0391971c | 152 | } |
153 | ||
108615fc | 154 | void AliL3Track::CalculateHelix(){ |
155 | //Calculate Radius, CenterX and Centery from Psi, X0, Y0 | |
156 | // | |
157 | ||
ef79795d | 158 | fRadius = fPt / (BFACT*AliL3Transform::GetBField()); |
3ceb3fe1 | 159 | if(fRadius) fKappa = -fQ*1./fRadius; |
108615fc | 160 | else fRadius = 999999; //just zero |
161 | Double_t trackPhi0 = fPsi + fQ *0.5 * pi; | |
162 | ||
163 | fCenterX = fFirstPoint[0] - fRadius * cos(trackPhi0); | |
164 | fCenterY = fFirstPoint[1] - fRadius * sin(trackPhi0); | |
165 | } | |
166 | ||
2d04dcbf | 167 | Double_t AliL3Track::GetCrossingAngle(Int_t padrow) |
0391971c | 168 | { |
169 | //Calculate the crossing angle between track and given padrow. | |
2d04dcbf | 170 | |
0391971c | 171 | if(!IsLocal()) |
172 | { | |
173 | printf("Track is not given in local coordinates\n"); | |
174 | return 0; | |
175 | } | |
2d04dcbf | 176 | |
0391971c | 177 | Float_t xyz[3]; |
178 | if(!GetCrossingPoint(padrow,xyz)) | |
179 | printf("AliL3HoughTrack::GetCrossingPoint : Track does not cross line!!\n"); | |
180 | ||
181 | //Take the dot product of the tangent vector of the track, and | |
182 | //vector perpendicular to the padrow. | |
183 | ||
184 | Double_t tangent[2]; | |
185 | tangent[1] = (xyz[0] - GetCenterX())/GetRadius(); | |
186 | tangent[0] = -1.*(xyz[1] - GetCenterY())/GetRadius(); | |
187 | ||
188 | Double_t perp_padrow[2] = {1,0}; //locally in slice | |
189 | ||
190 | Double_t cos_beta = fabs(tangent[0]*perp_padrow[0] + tangent[1]*perp_padrow[1]); | |
191 | return acos(cos_beta); | |
192 | ||
193 | } | |
194 | ||
2d04dcbf | 195 | Bool_t AliL3Track::GetCrossingPoint(Int_t padrow,Float_t *xyz) |
0391971c | 196 | { |
197 | //Assumes the track is given in local coordinates | |
198 | ||
0391971c | 199 | if(!IsLocal()) |
200 | { | |
201 | printf("GetCrossingPoint: Track is given on global coordinates\n"); | |
202 | return false; | |
203 | } | |
204 | ||
494fad94 | 205 | Double_t xHit = AliL3Transform::Row2X(padrow); |
0391971c | 206 | |
207 | xyz[0] = xHit; | |
208 | Double_t aa = (xHit - GetCenterX())*(xHit - GetCenterX()); | |
209 | Double_t r2 = GetRadius()*GetRadius(); | |
210 | if(aa > r2) | |
211 | return false; | |
212 | ||
213 | Double_t aa2 = sqrt(r2 - aa); | |
214 | Double_t y1 = GetCenterY() + aa2; | |
215 | Double_t y2 = GetCenterY() - aa2; | |
216 | xyz[1] = y1; | |
217 | if(fabs(y2) < fabs(y1)) xyz[1] = y2; | |
218 | ||
219 | Double_t yHit = xyz[1]; | |
220 | Double_t angle1 = atan2((yHit - GetCenterY()),(xHit - GetCenterX())); | |
221 | if(angle1 < 0) angle1 += 2.*Pi; | |
222 | Double_t angle2 = atan2((GetFirstPointY() - GetCenterY()),(GetFirstPointX() - GetCenterX())); | |
223 | if(angle2 < 0) angle2 += 2.*Pi; | |
224 | Double_t diff_angle = angle1 - angle2; | |
225 | diff_angle = fmod(diff_angle,2*Pi); | |
226 | if((GetCharge()*diff_angle) > 0) diff_angle = diff_angle - GetCharge()*2.*Pi; | |
227 | Double_t s_tot = fabs(diff_angle)*GetRadius(); | |
228 | Double_t zHit = GetFirstPointZ() + s_tot*GetTgl(); | |
229 | xyz[2] = zHit; | |
230 | ||
0391971c | 231 | return true; |
232 | } | |
233 | ||
234 | ||
6d4f1901 | 235 | Bool_t AliL3Track::CalculateReferencePoint(Double_t angle,Double_t radius){ |
108615fc | 236 | // Global coordinate: crossing point with y = ax+ b; a=tan(angle-Pi/2); |
237 | // | |
6d4f1901 | 238 | const Double_t rr=radius;//132; //position of referece plane |
108615fc | 239 | const Double_t xr = cos(angle) *rr; |
240 | const Double_t yr = sin(angle) *rr; | |
6d4f1901 | 241 | |
108615fc | 242 | Double_t a = tan(angle-pi/2); |
243 | Double_t b = yr - a * xr; | |
244 | ||
245 | Double_t pp=(fCenterX+a*fCenterY-a*b)/(1+pow(a,2)); | |
246 | Double_t qq=(pow(fCenterX,2)+pow(fCenterY,2)-2*fCenterY*b+pow(b,2)-pow(fRadius,2))/(1+pow(a,2)); | |
247 | ||
248 | Double_t racine = pp*pp-qq; | |
249 | if(racine<0) return IsPoint(kFALSE); //no Point | |
250 | ||
251 | Double_t rootRacine = sqrt(racine); | |
252 | Double_t x0 = pp+rootRacine; | |
253 | Double_t x1 = pp-rootRacine; | |
254 | Double_t y0 = a*x0 + b; | |
255 | Double_t y1 = a*x1 + b; | |
256 | ||
257 | Double_t diff0 = sqrt(pow(x0-xr,2)+pow(y0-yr,2)); | |
258 | Double_t diff1 = sqrt(pow(x1-xr,2)+pow(y1-yr,2)); | |
259 | ||
260 | if(diff0<diff1){ | |
261 | fPoint[0]=x0; | |
262 | fPoint[1]=y0; | |
263 | } | |
264 | else{ | |
265 | fPoint[0]=x1; | |
266 | fPoint[1]=y1; | |
267 | } | |
268 | ||
269 | Double_t pointPhi0 = atan2(fPoint[1]-fCenterY,fPoint[0]-fCenterX); | |
270 | Double_t trackPhi0 = atan2(fFirstPoint[1]-fCenterY,fFirstPoint[0]-fCenterX); | |
271 | if(fabs(trackPhi0-pointPhi0)>pi){ | |
272 | if(trackPhi0<pointPhi0) trackPhi0 += 2*pi; | |
273 | else pointPhi0 += 2*pi; | |
274 | } | |
275 | Double_t stot = -fQ * (pointPhi0-trackPhi0) * fRadius ; | |
276 | fPoint[2] = fFirstPoint[2] + stot * fTanl; | |
277 | ||
278 | fPointPsi = pointPhi0 - fQ * 0.5 * pi; | |
279 | if(fPointPsi<0.) fPointPsi+= 2*pi; | |
280 | fPointPsi = fmod(fPointPsi, 2*pi); | |
281 | ||
282 | return IsPoint(kTRUE); | |
283 | } | |
284 | ||
285 | Bool_t AliL3Track::CalculateEdgePoint(Double_t angle){ | |
286 | // Global coordinate: crossing point with y = ax; a=tan(angle); | |
287 | // | |
288 | Double_t rmin=80; //min Radius of TPC | |
289 | Double_t rmax=260; //max Radius of TPC | |
290 | ||
291 | Double_t a = tan(angle); | |
292 | Double_t pp=(fCenterX+a*fCenterY)/(1+pow(a,2)); | |
293 | Double_t qq=(pow(fCenterX,2)+pow(fCenterY,2)-pow(fRadius,2))/(1+pow(a,2)); | |
294 | Double_t racine = pp*pp-qq; | |
295 | if(racine<0) return IsPoint(kFALSE); //no Point | |
296 | Double_t rootRacine = sqrt(racine); | |
297 | Double_t x0 = pp+rootRacine; | |
298 | Double_t x1 = pp-rootRacine; | |
299 | Double_t y0 = a*x0; | |
300 | Double_t y1 = a*x1; | |
301 | ||
302 | Double_t r0 = sqrt(pow(x0,2)+pow(y0,2)); | |
303 | Double_t r1 = sqrt(pow(x1,2)+pow(y1,2)); | |
304 | //find the right crossing point: | |
305 | //inside the TPC modules | |
306 | Bool_t ok0 = kFALSE; | |
307 | Bool_t ok1 = kFALSE; | |
472d9e24 | 308 | |
108615fc | 309 | if(r0>rmin&&r0<rmax){ |
310 | Double_t da=atan2(y0,x0); | |
472d9e24 | 311 | if(da<0) da+=2*pi; |
108615fc | 312 | if(fabs(da-angle)<0.5) |
313 | ok0 = kTRUE; | |
314 | } | |
315 | if(r1>rmin&&r1<rmax){ | |
472d9e24 | 316 | Double_t da=atan2(y1,x1); |
317 | if(da<0) da+=2*pi; | |
108615fc | 318 | if(fabs(da-angle)<0.5) |
319 | ok1 = kTRUE; | |
320 | } | |
321 | if(!(ok0||ok1)) return IsPoint(kFALSE); //no Point | |
322 | ||
323 | if(ok0&&ok1){ | |
324 | Double_t diff0 = sqrt(pow(fFirstPoint[0]-x0,2)+pow(fFirstPoint[1]-y0,2)); | |
325 | Double_t diff1 = sqrt(pow(fFirstPoint[0]-x1,2)+pow(fFirstPoint[1]-y1,2)); | |
326 | if(diff0<diff1) ok1 = kFALSE; //use ok0 | |
327 | else ok0 = kFALSE; //use ok1 | |
328 | } | |
329 | if(ok0){fPoint[0]=x0; fPoint[1]=y0;} | |
330 | else {fPoint[0]=x1; fPoint[1]=y1;} | |
331 | ||
332 | Double_t pointPhi0 = atan2(fPoint[1]-fCenterY,fPoint[0]-fCenterX); | |
333 | Double_t trackPhi0 = atan2(fFirstPoint[1]-fCenterY,fFirstPoint[0]-fCenterX); | |
334 | if(fabs(trackPhi0-pointPhi0)>pi){ | |
335 | if(trackPhi0<pointPhi0) trackPhi0 += 2*pi; | |
336 | else pointPhi0 += 2*pi; | |
337 | } | |
338 | Double_t stot = -fQ * (pointPhi0-trackPhi0) * fRadius ; | |
339 | fPoint[2] = fFirstPoint[2] + stot * fTanl; | |
340 | ||
341 | fPointPsi = pointPhi0 - fQ * 0.5 * pi; | |
342 | if(fPointPsi<0.) fPointPsi+= 2*pi; | |
343 | fPointPsi = fmod(fPointPsi, 2*pi); | |
344 | ||
345 | return IsPoint(kTRUE); | |
346 | } | |
347 | ||
348 | Bool_t AliL3Track::CalculatePoint(Double_t xplane){ | |
349 | // Local coordinate: crossing point with x plane | |
350 | // | |
351 | Double_t racine = pow(fRadius,2)-pow(xplane-fCenterX,2); | |
352 | if(racine<0) return IsPoint(kFALSE); | |
353 | Double_t rootRacine = sqrt(racine); | |
354 | ||
355 | Double_t y0 = fCenterY + rootRacine; | |
356 | Double_t y1 = fCenterY - rootRacine; | |
357 | //Double_t diff0 = sqrt(pow(fFirstPoint[0]-xplane)+pow(fFirstPoint[1]-y0)); | |
358 | //Double_t diff1 = sqrt(pow(fFirstPoint[0]-xplane)+pow(fFirstPoint[1]-y1)); | |
359 | Double_t diff0 = fabs(y0-fFirstPoint[1]); | |
360 | Double_t diff1 = fabs(y1-fFirstPoint[1]); | |
361 | ||
362 | fPoint[0]=xplane; | |
363 | if(diff0<diff1) fPoint[1]=y0; | |
364 | else fPoint[1]=y1; | |
365 | ||
366 | Double_t pointPhi0 = atan2(fPoint[1]-fCenterY,fPoint[0]-fCenterX); | |
367 | Double_t trackPhi0 = atan2(fFirstPoint[1]-fCenterY,fFirstPoint[0]-fCenterX); | |
368 | if(fabs(trackPhi0-pointPhi0)>pi){ | |
369 | if(trackPhi0<pointPhi0) trackPhi0 += 2*pi; | |
370 | else pointPhi0 += 2*pi; | |
371 | } | |
372 | Double_t stot = -fQ * (pointPhi0-trackPhi0) * fRadius ; | |
373 | fPoint[2] = fFirstPoint[2] + stot * fTanl; | |
374 | ||
375 | fPointPsi = pointPhi0 - fQ * 0.5 * pi; | |
376 | if(fPointPsi<0.) fPointPsi+= 2*pi; | |
377 | fPointPsi = fmod(fPointPsi, 2*pi); | |
378 | ||
379 | return IsPoint(kTRUE); | |
380 | } | |
381 | ||
6d4f1901 | 382 | void AliL3Track::GetClosestPoint(AliL3Vertex *vertex,Double_t &closest_x,Double_t &closest_y,Double_t &closest_z) |
383 | { | |
384 | //Calculate the point of closest approach to the vertex | |
385 | ||
386 | ||
387 | Double_t xc = GetCenterX() - vertex->GetX();//Shift the center of curvature with respect to the vertex | |
388 | Double_t yc = GetCenterY() - vertex->GetY(); | |
389 | ||
390 | Double_t dist_x1 = xc*(1 + GetRadius()/sqrt(xc*xc + yc*yc)); | |
391 | Double_t dist_y1 = yc*(1 + GetRadius()/sqrt(xc*xc + yc*yc)); | |
392 | Double_t distance1 = sqrt(dist_x1*dist_x1 + dist_y1*dist_y1); | |
393 | ||
394 | Double_t dist_x2 = xc*(1 - GetRadius()/sqrt(xc*xc + yc*yc)); | |
395 | Double_t dist_y2 = yc*(1 - GetRadius()/sqrt(xc*xc + yc*yc)); | |
396 | Double_t distance2 = sqrt(dist_x2*dist_x2 + dist_y2*dist_y2); | |
397 | ||
398 | //Choose the closest: | |
399 | if(distance1 < distance2) | |
400 | { | |
401 | closest_x = dist_x1 + vertex->GetX(); | |
402 | closest_y = dist_y1 + vertex->GetY(); | |
403 | } | |
404 | else | |
405 | { | |
406 | closest_x = dist_x2 + vertex->GetX(); | |
407 | closest_y = dist_y2 + vertex->GetY(); | |
408 | } | |
409 | ||
410 | //Get the z coordinate: | |
411 | Double_t angle1 = atan2((closest_y-GetCenterY()),(closest_x-GetCenterX())); | |
412 | if(angle1 < 0) angle1 = angle1 + 2*Pi; | |
413 | ||
414 | Double_t angle2 = atan2((GetFirstPointY()-GetCenterY()),(GetFirstPointX()-GetCenterX())); | |
415 | if(angle2 < 0) angle2 = angle2 + 2*Pi; | |
416 | ||
417 | Double_t diff_angle = angle1 - angle2; | |
418 | diff_angle = fmod(diff_angle,2*Pi); | |
419 | ||
420 | if((GetCharge()*diff_angle) < 0) diff_angle = diff_angle + GetCharge()*2*Pi; | |
421 | Double_t s_tot = fabs(diff_angle)*GetRadius(); | |
422 | ||
423 | closest_z = GetFirstPointZ() - s_tot*GetTgl(); | |
424 | } |