1 //Author: Anders Strand Vestbo
2 //Author: Uli Frankenfeld
3 //Last Modified: 06.03.2001
5 //____________________________________
8 // Base track class for L3
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.
17 #include "AliL3RootTypes.h"
19 #include "AliL3Defs.h"
20 #include "AliL3Logging.h"
21 #include "AliL3Track.h"
22 #include "AliL3Transform.h"
28 Float_t AliL3Track::BFACT = 0.0029980;
29 Float_t AliL3Track::bField = 0.2;
30 Double_t AliL3Track::pi=3.14159265358979323846;
32 AliL3Track::AliL3Track()
42 ComesFromMainVertex(false);
54 memset(fHitNumbers,0,174*sizeof(UInt_t));
57 void AliL3Track::Set(AliL3Track *tpt){
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());
66 SetPsi(tpt->GetPsi());
67 SetTgl(tpt->GetTgl());
68 SetCharge(tpt->GetCharge());
69 SetHits(tpt->GetNHits(),(UInt_t *)tpt->GetHitNumbers());
74 AliL3Track::~AliL3Track()
79 Double_t AliL3Track::GetP() const
81 // Returns total momentum.
83 return fabs(GetPt())*sqrt(1. + GetTgl()*GetTgl());
87 Double_t AliL3Track::GetPseudoRapidity() const
89 return 0.5 * log((GetP() + GetPz()) / (GetP() - GetPz()));
92 Double_t AliL3Track::GetEta() const
94 return GetPseudoRapidity();
97 Double_t AliL3Track::GetRapidity() const
99 Double_t m_pi = 0.13957;
100 return 0.5 * log((m_pi + GetPz()) / (m_pi - GetPz()));
103 void AliL3Track::Rotate(Int_t slice)
106 //Rotate track to global parameters
108 AliL3Transform *transform = new AliL3Transform();
110 Float_t psi[1] = {GetPsi()};
111 transform->Local2GlobalAngle(psi,slice);
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]);
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]);
130 void AliL3Track::CalculateHelix(){
131 //Calculate Radius, CenterX and Centery from Psi, X0, Y0
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;
139 fCenterX = fFirstPoint[0] - fRadius * cos(trackPhi0);
140 fCenterY = fFirstPoint[1] - fRadius * sin(trackPhi0);
143 Double_t AliL3Track::GetCrossingAngle(Int_t padrow)
145 //Calculate the crossing angle between track and given padrow.
149 printf("Track is not given in local coordinates\n");
154 if(!GetCrossingPoint(padrow,xyz))
155 printf("AliL3HoughTrack::GetCrossingPoint : Track does not cross line!!\n");
157 //Take the dot product of the tangent vector of the track, and
158 //vector perpendicular to the padrow.
161 tangent[1] = (xyz[0] - GetCenterX())/GetRadius();
162 tangent[0] = -1.*(xyz[1] - GetCenterY())/GetRadius();
164 Double_t perp_padrow[2] = {1,0}; //locally in slice
166 Double_t cos_beta = fabs(tangent[0]*perp_padrow[0] + tangent[1]*perp_padrow[1]);
167 return acos(cos_beta);
171 Bool_t AliL3Track::GetCrossingPoint(Int_t padrow,Float_t *xyz)
173 //Assumes the track is given in local coordinates
175 AliL3Transform *transform = new AliL3Transform();
178 printf("GetCrossingPoint: Track is given on global coordinates\n");
182 Double_t xHit = transform->Row2X(padrow);
185 Double_t aa = (xHit - GetCenterX())*(xHit - GetCenterX());
186 Double_t r2 = GetRadius()*GetRadius();
190 Double_t aa2 = sqrt(r2 - aa);
191 Double_t y1 = GetCenterY() + aa2;
192 Double_t y2 = GetCenterY() - aa2;
194 if(fabs(y2) < fabs(y1)) xyz[1] = y2;
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();
213 Bool_t AliL3Track::CalculateReferencePoint(Double_t angle){
214 // Global coordinate: crossing point with y = ax+ b; a=tan(angle-Pi/2);
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;
220 Double_t a = tan(angle-pi/2);
221 Double_t b = yr - a * xr;
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));
226 Double_t racine = pp*pp-qq;
227 if(racine<0) return IsPoint(kFALSE); //no Point
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;
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));
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;
253 Double_t stot = -fQ * (pointPhi0-trackPhi0) * fRadius ;
254 fPoint[2] = fFirstPoint[2] + stot * fTanl;
256 fPointPsi = pointPhi0 - fQ * 0.5 * pi;
257 if(fPointPsi<0.) fPointPsi+= 2*pi;
258 fPointPsi = fmod(fPointPsi, 2*pi);
260 return IsPoint(kTRUE);
263 Bool_t AliL3Track::CalculateEdgePoint(Double_t angle){
264 // Global coordinate: crossing point with y = ax; a=tan(angle);
266 Double_t rmin=80; //min Radius of TPC
267 Double_t rmax=260; //max Radius of TPC
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;
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
287 if(r0>rmin&&r0<rmax){
288 Double_t da=atan2(y0,x0);
290 if(fabs(da-angle)<0.5)
293 if(r1>rmin&&r1<rmax){
294 Double_t da=atan2(y1,x1);
296 if(fabs(da-angle)<0.5)
299 if(!(ok0||ok1)) return IsPoint(kFALSE); //no Point
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
307 if(ok0){fPoint[0]=x0; fPoint[1]=y0;}
308 else {fPoint[0]=x1; fPoint[1]=y1;}
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;
316 Double_t stot = -fQ * (pointPhi0-trackPhi0) * fRadius ;
317 fPoint[2] = fFirstPoint[2] + stot * fTanl;
319 fPointPsi = pointPhi0 - fQ * 0.5 * pi;
320 if(fPointPsi<0.) fPointPsi+= 2*pi;
321 fPointPsi = fmod(fPointPsi, 2*pi);
323 return IsPoint(kTRUE);
326 Bool_t AliL3Track::CalculatePoint(Double_t xplane){
327 // Local coordinate: crossing point with x plane
329 Double_t racine = pow(fRadius,2)-pow(xplane-fCenterX,2);
330 if(racine<0) return IsPoint(kFALSE);
331 Double_t rootRacine = sqrt(racine);
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]);
341 if(diff0<diff1) fPoint[1]=y0;
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;
350 Double_t stot = -fQ * (pointPhi0-trackPhi0) * fRadius ;
351 fPoint[2] = fFirstPoint[2] + stot * fTanl;
353 fPointPsi = pointPhi0 - fQ * 0.5 * pi;
354 if(fPointPsi<0.) fPointPsi+= 2*pi;
355 fPointPsi = fmod(fPointPsi, 2*pi);
357 return IsPoint(kTRUE);