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 | |
0391971c |
19 | #include "AliL3Defs.h" |
108615fc |
20 | #include "AliL3Logging.h" |
21 | #include "AliL3Track.h" |
0391971c |
22 | #include "AliL3Transform.h" |
108615fc |
23 | #include <math.h> |
24 | |
0391971c |
25 | |
108615fc |
26 | ClassImp(AliL3Track) |
27 | |
28 | Float_t AliL3Track::BFACT = 0.0029980; |
29 | Float_t AliL3Track::bField = 0.2; |
30 | Double_t AliL3Track::pi=3.14159265358979323846; |
31 | |
32 | AliL3Track::AliL3Track() |
33 | { |
34 | //Constructor |
35 | |
36 | fNHits = 0; |
37 | fMCid = -1; |
38 | fKappa=0; |
39 | fRadius=0; |
40 | fCenterX=0; |
41 | fCenterY=0; |
42 | ComesFromMainVertex(false); |
43 | fQ = 0; |
44 | fPhi0=0; |
45 | fPsi=0; |
46 | fR0=0; |
47 | fTanl=0; |
48 | fZ0=0; |
49 | fPt=0; |
50 | fLength=0; |
51 | fIsLocal=true; |
52 | fRowRange[0]=0; |
53 | fRowRange[1]=0; |
54 | memset(fHitNumbers,0,174*sizeof(UInt_t)); |
55 | } |
56 | |
57 | void AliL3Track::Set(AliL3Track *tpt){ |
58 | |
3a735e00 |
59 | SetRowRange(tpt->GetFirstRow(),tpt->GetLastRow()); |
60 | SetPhi0(tpt->GetPhi0()); |
61 | SetKappa(tpt->GetKappa()); |
62 | SetNHits(tpt->GetNHits()); |
63 | SetFirstPoint(tpt->GetFirstPointX(),tpt->GetFirstPointY(),tpt->GetFirstPointZ()); |
64 | SetLastPoint(tpt->GetLastPointX(),tpt->GetLastPointY(),tpt->GetLastPointZ()); |
65 | SetPt(tpt->GetPt()); |
66 | SetPsi(tpt->GetPsi()); |
67 | SetTgl(tpt->GetTgl()); |
68 | SetCharge(tpt->GetCharge()); |
69 | SetHits(tpt->GetNHits(),(UInt_t *)tpt->GetHitNumbers()); |
108615fc |
70 | |
108615fc |
71 | } |
72 | |
73 | |
74 | AliL3Track::~AliL3Track() |
75 | { |
76 | |
77 | } |
78 | |
79 | Double_t AliL3Track::GetP() const |
80 | { |
81 | // Returns total momentum. |
82 | |
83 | return fabs(GetPt())*sqrt(1. + GetTgl()*GetTgl()); |
84 | |
85 | } |
86 | |
87 | Double_t AliL3Track::GetPseudoRapidity() const |
88 | { |
89 | return 0.5 * log((GetP() + GetPz()) / (GetP() - GetPz())); |
90 | } |
91 | |
92 | Double_t AliL3Track::GetEta() const |
93 | { |
94 | return GetPseudoRapidity(); |
95 | } |
96 | |
97 | Double_t AliL3Track::GetRapidity() const |
98 | { |
99 | Double_t m_pi = 0.13957; |
100 | return 0.5 * log((m_pi + GetPz()) / (m_pi - GetPz())); |
101 | } |
102 | |
0391971c |
103 | void AliL3Track::Rotate(Int_t slice) |
104 | { |
105 | |
106 | //Rotate track to global parameters |
107 | |
108 | AliL3Transform *transform = new AliL3Transform(); |
109 | |
110 | Float_t psi[1] = {GetPsi()}; |
111 | transform->Local2GlobalAngle(psi,slice); |
112 | SetPsi(psi[0]); |
113 | Float_t first[3]; |
114 | first[0] = GetFirstPointX(); |
115 | first[1] = GetFirstPointY(); |
116 | first[2] = GetFirstPointZ(); |
117 | transform->Local2Global(first,slice); |
118 | SetFirstPoint(first[0],first[1],first[2]); |
119 | Float_t last[3]; |
120 | last[0] = GetLastPointX(); |
121 | last[1] = GetLastPointY(); |
122 | last[2] = GetLastPointZ(); |
123 | transform->Local2Global(last,slice); |
124 | SetLastPoint(last[0],last[1],last[2]); |
125 | |
126 | fIsLocal=false; |
127 | delete transform; |
128 | } |
129 | |
108615fc |
130 | void AliL3Track::CalculateHelix(){ |
131 | //Calculate Radius, CenterX and Centery from Psi, X0, Y0 |
132 | // |
133 | |
134 | fRadius = fPt / (BFACT*bField); |
135 | if(fRadius) fKappa = 1./fRadius; |
136 | else fRadius = 999999; //just zero |
137 | Double_t trackPhi0 = fPsi + fQ *0.5 * pi; |
138 | |
139 | fCenterX = fFirstPoint[0] - fRadius * cos(trackPhi0); |
140 | fCenterY = fFirstPoint[1] - fRadius * sin(trackPhi0); |
141 | } |
142 | |
0391971c |
143 | Double_t AliL3Track::GetCrossingAngle(Int_t padrow) |
144 | { |
145 | //Calculate the crossing angle between track and given padrow. |
146 | |
147 | if(!IsLocal()) |
148 | { |
149 | printf("Track is not given in local coordinates\n"); |
150 | return 0; |
151 | } |
152 | |
153 | Float_t xyz[3]; |
154 | if(!GetCrossingPoint(padrow,xyz)) |
155 | printf("AliL3HoughTrack::GetCrossingPoint : Track does not cross line!!\n"); |
156 | |
157 | //Take the dot product of the tangent vector of the track, and |
158 | //vector perpendicular to the padrow. |
159 | |
160 | Double_t tangent[2]; |
161 | tangent[1] = (xyz[0] - GetCenterX())/GetRadius(); |
162 | tangent[0] = -1.*(xyz[1] - GetCenterY())/GetRadius(); |
163 | |
164 | Double_t perp_padrow[2] = {1,0}; //locally in slice |
165 | |
166 | Double_t cos_beta = fabs(tangent[0]*perp_padrow[0] + tangent[1]*perp_padrow[1]); |
167 | return acos(cos_beta); |
168 | |
169 | } |
170 | |
171 | Bool_t AliL3Track::GetCrossingPoint(Int_t padrow,Float_t *xyz) |
172 | { |
173 | //Assumes the track is given in local coordinates |
174 | |
175 | AliL3Transform *transform = new AliL3Transform(); |
176 | if(!IsLocal()) |
177 | { |
178 | printf("GetCrossingPoint: Track is given on global coordinates\n"); |
179 | return false; |
180 | } |
181 | |
182 | Double_t xHit = transform->Row2X(padrow); |
183 | |
184 | xyz[0] = xHit; |
185 | Double_t aa = (xHit - GetCenterX())*(xHit - GetCenterX()); |
186 | Double_t r2 = GetRadius()*GetRadius(); |
187 | if(aa > r2) |
188 | return false; |
189 | |
190 | Double_t aa2 = sqrt(r2 - aa); |
191 | Double_t y1 = GetCenterY() + aa2; |
192 | Double_t y2 = GetCenterY() - aa2; |
193 | xyz[1] = y1; |
194 | if(fabs(y2) < fabs(y1)) xyz[1] = y2; |
195 | |
196 | Double_t yHit = xyz[1]; |
197 | Double_t angle1 = atan2((yHit - GetCenterY()),(xHit - GetCenterX())); |
198 | if(angle1 < 0) angle1 += 2.*Pi; |
199 | Double_t angle2 = atan2((GetFirstPointY() - GetCenterY()),(GetFirstPointX() - GetCenterX())); |
200 | if(angle2 < 0) angle2 += 2.*Pi; |
201 | Double_t diff_angle = angle1 - angle2; |
202 | diff_angle = fmod(diff_angle,2*Pi); |
203 | if((GetCharge()*diff_angle) > 0) diff_angle = diff_angle - GetCharge()*2.*Pi; |
204 | Double_t s_tot = fabs(diff_angle)*GetRadius(); |
205 | Double_t zHit = GetFirstPointZ() + s_tot*GetTgl(); |
206 | xyz[2] = zHit; |
207 | |
208 | delete transform; |
209 | return true; |
210 | } |
211 | |
212 | |
108615fc |
213 | Bool_t AliL3Track::CalculateReferencePoint(Double_t angle){ |
214 | // Global coordinate: crossing point with y = ax+ b; a=tan(angle-Pi/2); |
215 | // |
216 | const Double_t rr=132; //position of referece plane |
217 | const Double_t xr = cos(angle) *rr; |
218 | const Double_t yr = sin(angle) *rr; |
219 | |
220 | Double_t a = tan(angle-pi/2); |
221 | Double_t b = yr - a * xr; |
222 | |
223 | Double_t pp=(fCenterX+a*fCenterY-a*b)/(1+pow(a,2)); |
224 | Double_t qq=(pow(fCenterX,2)+pow(fCenterY,2)-2*fCenterY*b+pow(b,2)-pow(fRadius,2))/(1+pow(a,2)); |
225 | |
226 | Double_t racine = pp*pp-qq; |
227 | if(racine<0) return IsPoint(kFALSE); //no Point |
228 | |
229 | Double_t rootRacine = sqrt(racine); |
230 | Double_t x0 = pp+rootRacine; |
231 | Double_t x1 = pp-rootRacine; |
232 | Double_t y0 = a*x0 + b; |
233 | Double_t y1 = a*x1 + b; |
234 | |
235 | Double_t diff0 = sqrt(pow(x0-xr,2)+pow(y0-yr,2)); |
236 | Double_t diff1 = sqrt(pow(x1-xr,2)+pow(y1-yr,2)); |
237 | |
238 | if(diff0<diff1){ |
239 | fPoint[0]=x0; |
240 | fPoint[1]=y0; |
241 | } |
242 | else{ |
243 | fPoint[0]=x1; |
244 | fPoint[1]=y1; |
245 | } |
246 | |
247 | Double_t pointPhi0 = atan2(fPoint[1]-fCenterY,fPoint[0]-fCenterX); |
248 | Double_t trackPhi0 = atan2(fFirstPoint[1]-fCenterY,fFirstPoint[0]-fCenterX); |
249 | if(fabs(trackPhi0-pointPhi0)>pi){ |
250 | if(trackPhi0<pointPhi0) trackPhi0 += 2*pi; |
251 | else pointPhi0 += 2*pi; |
252 | } |
253 | Double_t stot = -fQ * (pointPhi0-trackPhi0) * fRadius ; |
254 | fPoint[2] = fFirstPoint[2] + stot * fTanl; |
255 | |
256 | fPointPsi = pointPhi0 - fQ * 0.5 * pi; |
257 | if(fPointPsi<0.) fPointPsi+= 2*pi; |
258 | fPointPsi = fmod(fPointPsi, 2*pi); |
259 | |
260 | return IsPoint(kTRUE); |
261 | } |
262 | |
263 | Bool_t AliL3Track::CalculateEdgePoint(Double_t angle){ |
264 | // Global coordinate: crossing point with y = ax; a=tan(angle); |
265 | // |
266 | Double_t rmin=80; //min Radius of TPC |
267 | Double_t rmax=260; //max Radius of TPC |
268 | |
269 | Double_t a = tan(angle); |
270 | Double_t pp=(fCenterX+a*fCenterY)/(1+pow(a,2)); |
271 | Double_t qq=(pow(fCenterX,2)+pow(fCenterY,2)-pow(fRadius,2))/(1+pow(a,2)); |
272 | Double_t racine = pp*pp-qq; |
273 | if(racine<0) return IsPoint(kFALSE); //no Point |
274 | Double_t rootRacine = sqrt(racine); |
275 | Double_t x0 = pp+rootRacine; |
276 | Double_t x1 = pp-rootRacine; |
277 | Double_t y0 = a*x0; |
278 | Double_t y1 = a*x1; |
279 | |
280 | Double_t r0 = sqrt(pow(x0,2)+pow(y0,2)); |
281 | Double_t r1 = sqrt(pow(x1,2)+pow(y1,2)); |
282 | //find the right crossing point: |
283 | //inside the TPC modules |
284 | Bool_t ok0 = kFALSE; |
285 | Bool_t ok1 = kFALSE; |
472d9e24 |
286 | |
108615fc |
287 | if(r0>rmin&&r0<rmax){ |
288 | Double_t da=atan2(y0,x0); |
472d9e24 |
289 | if(da<0) da+=2*pi; |
108615fc |
290 | if(fabs(da-angle)<0.5) |
291 | ok0 = kTRUE; |
292 | } |
293 | if(r1>rmin&&r1<rmax){ |
472d9e24 |
294 | Double_t da=atan2(y1,x1); |
295 | if(da<0) da+=2*pi; |
108615fc |
296 | if(fabs(da-angle)<0.5) |
297 | ok1 = kTRUE; |
298 | } |
299 | if(!(ok0||ok1)) return IsPoint(kFALSE); //no Point |
300 | |
301 | if(ok0&&ok1){ |
302 | Double_t diff0 = sqrt(pow(fFirstPoint[0]-x0,2)+pow(fFirstPoint[1]-y0,2)); |
303 | Double_t diff1 = sqrt(pow(fFirstPoint[0]-x1,2)+pow(fFirstPoint[1]-y1,2)); |
304 | if(diff0<diff1) ok1 = kFALSE; //use ok0 |
305 | else ok0 = kFALSE; //use ok1 |
306 | } |
307 | if(ok0){fPoint[0]=x0; fPoint[1]=y0;} |
308 | else {fPoint[0]=x1; fPoint[1]=y1;} |
309 | |
310 | Double_t pointPhi0 = atan2(fPoint[1]-fCenterY,fPoint[0]-fCenterX); |
311 | Double_t trackPhi0 = atan2(fFirstPoint[1]-fCenterY,fFirstPoint[0]-fCenterX); |
312 | if(fabs(trackPhi0-pointPhi0)>pi){ |
313 | if(trackPhi0<pointPhi0) trackPhi0 += 2*pi; |
314 | else pointPhi0 += 2*pi; |
315 | } |
316 | Double_t stot = -fQ * (pointPhi0-trackPhi0) * fRadius ; |
317 | fPoint[2] = fFirstPoint[2] + stot * fTanl; |
318 | |
319 | fPointPsi = pointPhi0 - fQ * 0.5 * pi; |
320 | if(fPointPsi<0.) fPointPsi+= 2*pi; |
321 | fPointPsi = fmod(fPointPsi, 2*pi); |
322 | |
323 | return IsPoint(kTRUE); |
324 | } |
325 | |
326 | Bool_t AliL3Track::CalculatePoint(Double_t xplane){ |
327 | // Local coordinate: crossing point with x plane |
328 | // |
329 | Double_t racine = pow(fRadius,2)-pow(xplane-fCenterX,2); |
330 | if(racine<0) return IsPoint(kFALSE); |
331 | Double_t rootRacine = sqrt(racine); |
332 | |
333 | Double_t y0 = fCenterY + rootRacine; |
334 | Double_t y1 = fCenterY - rootRacine; |
335 | //Double_t diff0 = sqrt(pow(fFirstPoint[0]-xplane)+pow(fFirstPoint[1]-y0)); |
336 | //Double_t diff1 = sqrt(pow(fFirstPoint[0]-xplane)+pow(fFirstPoint[1]-y1)); |
337 | Double_t diff0 = fabs(y0-fFirstPoint[1]); |
338 | Double_t diff1 = fabs(y1-fFirstPoint[1]); |
339 | |
340 | fPoint[0]=xplane; |
341 | if(diff0<diff1) fPoint[1]=y0; |
342 | else fPoint[1]=y1; |
343 | |
344 | Double_t pointPhi0 = atan2(fPoint[1]-fCenterY,fPoint[0]-fCenterX); |
345 | Double_t trackPhi0 = atan2(fFirstPoint[1]-fCenterY,fFirstPoint[0]-fCenterX); |
346 | if(fabs(trackPhi0-pointPhi0)>pi){ |
347 | if(trackPhi0<pointPhi0) trackPhi0 += 2*pi; |
348 | else pointPhi0 += 2*pi; |
349 | } |
350 | Double_t stot = -fQ * (pointPhi0-trackPhi0) * fRadius ; |
351 | fPoint[2] = fFirstPoint[2] + stot * fTanl; |
352 | |
353 | fPointPsi = pointPhi0 - fQ * 0.5 * pi; |
354 | if(fPointPsi<0.) fPointPsi+= 2*pi; |
355 | fPointPsi = fmod(fPointPsi, 2*pi); |
356 | |
357 | return IsPoint(kTRUE); |
358 | } |
359 | |