]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HMPID/AliHMPIDtrack.cxx
expert mode inserted
[u/mrichter/AliRoot.git] / HMPID / AliHMPIDtrack.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 #include "AliESDtrack.h" 
17 #include "AliTracker.h" 
18 #include "AliHMPIDtrack.h" 
19
20 ClassImp(AliHMPIDtrack)
21
22 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
23 AliHMPIDtrack::AliHMPIDtrack():AliKalmanTrack()
24 {
25   //
26   // def. ctor
27   //
28 }                                
29 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
30 AliHMPIDtrack::AliHMPIDtrack(const AliHMPIDtrack& t):AliKalmanTrack(t)
31 {
32   //
33   // cctor.
34   //
35  }                                
36 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
37 AliHMPIDtrack::AliHMPIDtrack(const AliESDtrack& t):AliKalmanTrack()
38 {
39   //
40   // Constructor from AliESDtrack
41   //
42   SetLabel(t.GetLabel());
43   SetChi2(0.);
44   SetMass(t.GetMass());
45
46   Set(t.GetX(),t.GetAlpha(),t.GetParameter(),t.GetCovariance());
47
48   if ((t.GetStatus()&AliESDtrack::kTIME) == 0) return;
49   StartTimeIntegral();
50   Double_t times[10]; t.GetIntegratedTimes(times); SetIntegratedTimes(times);
51   SetIntegratedLength(t.GetIntegratedLength());
52 }              
53 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
54 AliHMPIDtrack& AliHMPIDtrack::operator=(const AliHMPIDtrack &/*source*/)
55 {
56   // ass. op.
57   
58   return *this;
59 }
60 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
61 Bool_t AliHMPIDtrack::PropagateTo(Double_t xk, Double_t xx0, Double_t xrho)
62 {
63   //
64   // Propagates this track to a reference plane defined by "xk" [cm] 
65   // correcting for the mean crossed material.
66   // Arguments:
67   // "xx0"  - thickness/rad.length [units of the radiation length] 
68   // "xrho" - thickness*density    [g/cm^2] 
69   //  Returns: kTRUE if the track propagates to plane, else kFALSE
70  
71   if (xk == GetX()) {
72     return kTRUE;
73   }
74   Double_t bz   = GetBz();
75   if (!AliExternalTrackParam::PropagateTo(xk,bz)) {
76     return kFALSE;
77   }
78   if (!AliExternalTrackParam::CorrectForMeanMaterial(xx0,xrho,GetMass())) { 
79     return kFALSE;
80   }
81   return kTRUE;            
82 }//PropagateTo()  
83 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
84 Bool_t AliHMPIDtrack::Rotate(Double_t alpha, Bool_t absolute)
85 {
86   //
87   // Rotates track parameters in R*phi plane
88   // if absolute rotation alpha is in global system
89   // otherwise alpha rotation is relative to the current rotation angle
90   //  
91
92   if (absolute) {
93     alpha -= GetAlpha();
94   }
95  
96
97   return AliExternalTrackParam::Rotate(GetAlpha()+alpha);
98
99 }   
100 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++  
101 Int_t AliHMPIDtrack::GetProlongation(Double_t xk, Double_t &y, Double_t &z)
102 {
103   //
104   // Find a prolongation at given x
105   // Return 0 if it does not exist
106   //  
107
108   Double_t bz = GetBz();
109
110   if (!AliExternalTrackParam::GetYAt(xk,bz,y)) {
111     return 0;
112   }
113   if (!AliExternalTrackParam::GetZAt(xk,bz,z)) {
114     return 0;
115   }
116
117   return 1;  
118
119 }
120  
121 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
122 Int_t   AliHMPIDtrack::PropagateToR(Double_t r,Double_t step)
123 {
124   //
125   // Propagate track to the radial position
126   // Rotation always connected to the last track position
127   //
128
129   Double_t xyz0[3];
130   Double_t xyz1[3];
131   Double_t y;
132   Double_t z; 
133
134   Double_t radius = TMath::Sqrt(GetX()*GetX() + GetY()*GetY());
135   // Direction +-
136   Double_t dir    = (radius > r) ? -1.0 : 1.0;   
137
138   for (Double_t x = radius+dir*step; dir*x < dir*r; x += dir*step) {
139
140     GetXYZ(xyz0);       
141     Double_t alpha = TMath::ATan2(xyz0[1],xyz0[0]);
142     Rotate(alpha,kTRUE);
143     GetXYZ(xyz0);       
144     GetProlongation(x,y,z);
145     xyz1[0] = x * TMath::Cos(alpha) + y * TMath::Sin(alpha); 
146     xyz1[1] = x * TMath::Sin(alpha) - y * TMath::Cos(alpha);
147     xyz1[2] = z;
148     Double_t param[7];
149     AliTracker::MeanMaterialBudget(xyz0,xyz1,param);
150     if (param[1] <= 0) {
151       param[1] = 100000000;
152     }
153     PropagateTo(x,param[1],param[0]*param[4]);
154
155   } 
156
157   GetXYZ(xyz0); 
158   Double_t alpha = TMath::ATan2(xyz0[1],xyz0[0]);
159   Rotate(alpha,kTRUE);
160   GetXYZ(xyz0); 
161   GetProlongation(r,y,z);
162   xyz1[0] = r * TMath::Cos(alpha) + y * TMath::Sin(alpha); 
163   xyz1[1] = r * TMath::Sin(alpha) - y * TMath::Cos(alpha);
164   xyz1[2] = z;
165   Double_t param[7];
166   AliTracker::MeanMaterialBudget(xyz0,xyz1,param);
167
168   if (param[1] <= 0) {
169     param[1] = 100000000;
170   }
171   PropagateTo(r,param[1],param[0]*param[4]);
172
173   return 0;
174
175 }
176 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
177 Double_t AliHMPIDtrack::GetPredictedChi2(const AliCluster3D *c) const {
178   //
179   // Arguments: AliCluster3D
180   // Returns:   Chi2 of track for the cluster
181   Double_t      p[3]={c->GetX(),       c->GetY(),       c->GetZ()};
182   Double_t  covyz[3]={c->GetSigmaY2(), c->GetSigmaYZ(), c->GetSigmaZ2()};
183   Double_t covxyz[3]={c->GetSigmaX2(), c->GetSigmaXY(), c->GetSigmaXZ()};
184   return AliExternalTrackParam::GetPredictedChi2(p, covyz, covxyz);
185 }//GetPredictedChi2()
186 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
187 Bool_t AliHMPIDtrack::PropagateTo(const AliCluster3D *c) {
188   //
189   // Arguments: AliCluster3D
190   // Returns: kTRUE if the track propagates to the plane of the cluster
191   Double_t      oldX=GetX(),   oldY=GetY(), oldZ=GetZ();
192   Double_t      p[3]={c->GetX(), c->GetY(), c->GetZ()};
193   Double_t  covyz[3]={c->GetSigmaY2(), c->GetSigmaYZ(), c->GetSigmaZ2()};
194   Double_t covxyz[3]={c->GetSigmaX2(), c->GetSigmaXY(), c->GetSigmaXZ()};
195   Double_t bz=GetBz();
196   
197   if(!AliExternalTrackParam::PropagateTo(p, covyz, covxyz, bz)) return kFALSE;
198   if(IsStartedTimeIntegral()) 
199     {
200       Double_t d = TMath::Sqrt((GetX()-oldX)*(GetX()-oldX) + (GetY()-oldY)*(GetY()-oldY) + (GetZ()-oldZ)*(GetZ()-oldZ));
201       if (GetX()<oldX) d=-d;
202       AddTimeStep(d);
203   }
204   return kTRUE;
205 }//PropagateTo()
206 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
207 Double_t AliHMPIDtrack::GetBz() const {
208   // 
209   // Arguments: none
210   // Returns: Bz component of the magnetic field (kG)
211   //
212   if (AliTracker::UniformField()) return AliTracker::GetBz();
213   Double_t r[3]; GetXYZ(r);
214   return AliTracker::GetBz(r);
215 }//GetBz()
216 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
217 Bool_t AliHMPIDtrack::Intersect(Double_t pnt[3], Double_t norm[3], Double_t bz) const {
218   //+++++++++++++++++++++++++++++++++++++++++    
219   // Origin: K. Shileev (Kirill.Shileev@cern.ch)
220   // Finds point of intersection (if exists) of the helix with the plane. 
221   // Stores result in fX and fP.   
222   // Arguments: planePoint,planeNorm - the plane defined by any plane's point 
223   // and vector, normal to the plane
224   // Returns: kTrue if helix intersects the plane, kFALSE otherwise.
225   //+++++++++++++++++++++++++++++++++++++++++    
226   Double_t x0[3]; GetXYZ(x0); //get track position in MARS
227   //Printf("xxx Intersect OLD: bz: %lf xxx",bz);
228   
229   //estimates initial helix length up to plane
230   Double_t s=(pnt[0]-x0[0])*norm[0] + (pnt[1]-x0[1])*norm[1] + (pnt[2]-x0[2])*norm[2];
231   Double_t dist=99999,distPrev=dist;
232   Double_t x[3],p[3]; 
233   while(TMath::Abs(dist)>0.00001){
234     //calculates helix at the distance s from x0 ALONG the helix
235     Propagate(s,x,p,bz);
236     //distance between current helix position and plane
237     dist=(x[0]-pnt[0])*norm[0]+(x[1]-pnt[1])*norm[1]+(x[2]-pnt[2])*norm[2];  
238     if(TMath::Abs(dist) >= TMath::Abs(distPrev)) {return kFALSE;}
239     distPrev=dist;
240     s-=dist;
241   }
242   //on exit pnt is intersection point,norm is track vector at that point, 
243   //all in MARS
244   for (Int_t i=0; i<3; i++) {pnt[i]=x[i]; norm[i]=p[i];}
245   return kTRUE;
246 }//Intersect()
247 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
248 Bool_t AliHMPIDtrack::Intersect(AliHMPIDtrack *pTrk,Double_t pnt[3], Double_t norm[3]) {
249   // Finds point of intersection (if exists) of the helix with the plane. 
250   // Stores result in fX and fP.   
251   // Arguments: planePoint,planeNorm - the plane defined by any plane's point 
252   // and vector, normal to the plane
253   // Returns: kTrue if helix intersects the plane, kFALSE otherwise.
254   
255   //Printf(":::::: 111 :::::: pnt0: %lf pnt1: %lf pnt2: %lf norm0: %lf norm1: %lf norm2: %lf",pnt[0],pnt[1],pnt[2],norm[0],norm[1],norm[2]);
256   
257   Double_t bz=-1.0*GetBz();  
258   Double_t x0[3]; pTrk->GetXYZ(x0); //get track position in MARS
259   //Printf(":::::: 222 :::::: x0: %lf x1: %lf x2: %lf",x0[0],x0[1],x0[2]);
260
261   Double_t rad;
262   //estimates initial helix length up to plane
263   Double_t s=(pnt[0]-x0[0])*norm[0] + (pnt[1]-x0[1])*norm[1] + (pnt[2]-x0[2])*norm[2];
264   Double_t dist=99999,distPrev=dist;
265   Double_t x[3],p[3]; 
266   while(TMath::Abs(dist)>0.00001){
267     //calculates helix at the distance s from x0 ALONG the helix
268     Propagate(s,x,p,bz);
269     
270     //distance between current helix position and plane
271     dist=(x[0]-pnt[0])*norm[0]+(x[1]-pnt[1])*norm[1]+(x[2]-pnt[2])*norm[2];
272     if(TMath::Abs(dist) >= TMath::Abs(distPrev)) {return kFALSE;}
273     distPrev=dist;
274     s-=dist;
275   }
276    // Printf(":::::: 333 :::::: pnt0: %lf pnt1: %lf pnt2: %lf norm0: %lf norm1: %lf norm2: %lf",pnt[0],pnt[1],pnt[2],norm[0],norm[1],norm[2]);
277   //on exit pnt is intersection point,norm is track vector at that point, 
278   //all in MARS
279   rad=TMath::Sqrt(x[0]*x[0]+x[1]*x[1]); 
280   PropagateTo(rad);       //propagate with the average dens. rad. lenght
281   GetXYZAt(rad,bz,x); 
282   GetPxPyPz(p);                                                       //propagate to the radial distance of the PC or the Radiator    
283   for (Int_t i=0; i<3; i++) {pnt[i]=x[i]; norm[i]=p[i];}
284  // Printf(":::::: 444 :::::: pnt0: %lf pnt1: %lf pnt2: %lf norm0: %lf norm1: %lf norm2: %lf",pnt[0],pnt[1],pnt[2],norm[0],norm[1],norm[2]);
285  /*
286    pEsdTrk->SetHMPIDpx(p[0]);
287   pEsdTrk->SetHMPIDpy(p[1]);
288   pEsdTrk->SetHMPIDpz(p[2]);
289   */
290   
291   return kTRUE;
292 }//Intersect()
293 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
294 void AliHMPIDtrack::Propagate(Double_t len, Double_t x[3],Double_t p[3], Double_t bz) const {
295   //+++++++++++++++++++++++++++++++++++++++++    
296   // Origin: K. Shileev (Kirill.Shileev@cern.ch)
297   // Extrapolate track along simple helix in magnetic field
298   // Arguments: len -distance alogn helix, [cm]
299   //            bz  - mag field, [kGaus]   
300   // Returns: x and p contain extrapolated positon and momentum  
301   // The momentum returned for straight-line tracks is meaningless !
302   //+++++++++++++++++++++++++++++++++++++++++    
303   GetXYZ(x);    
304   if (OneOverPt() < kAlmost0 || TMath::Abs(bz) < kAlmost0Field ){ //straight-line tracks
305      Double_t unit[3]; GetDirection(unit);
306      x[0]+=unit[0]*len;   
307      x[1]+=unit[1]*len;   
308      x[2]+=unit[2]*len;
309
310      p[0]=unit[0]/kAlmost0;   
311      p[1]=unit[1]/kAlmost0;   
312      p[2]=unit[2]/kAlmost0;   
313   } else {
314      GetPxPyPz(p);
315      Double_t pp=GetP();
316      Double_t a = -kB2C*bz*GetSign(); ////////// what is kB2C
317      Double_t rho = a/pp;
318      x[0] += p[0]*TMath::Sin(rho*len)/a - p[1]*(1-TMath::Cos(rho*len))/a;
319      x[1] += p[1]*TMath::Sin(rho*len)/a + p[0]*(1-TMath::Cos(rho*len))/a;
320      x[2] += p[2]*len/pp;
321      Double_t p0=p[0];
322      p[0] = p0  *TMath::Cos(rho*len) - p[1]*TMath::Sin(rho*len);
323      p[1] = p[1]*TMath::Cos(rho*len) + p0  *TMath::Sin(rho*len);
324   }
325 }//Propagate()
326 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++