to allow reading digits only w/o sdigits
[u/mrichter/AliRoot.git] / TOF / AliTOFtrack.cxx
CommitLineData
74ea065c 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 **************************************************************************/
74ea065c 15
0e46b9ae 16/* $Id$ */
d3c7bfac 17
0e46b9ae 18/////////////////////////////////////////////////////////////////////////////
19// //
20// AliTOFtrack class //
21// //
22// Authors: Bologna-CERN-ITEP-Salerno Group //
23// //
24// Description: class for handling ESD extracted tracks for TOF matching. //
25// //
26/////////////////////////////////////////////////////////////////////////////
d3c7bfac 27
74ea065c 28#include "AliESDtrack.h"
6c94f330 29#include "AliTracker.h"
74ea065c 30
0e46b9ae 31#include "AliTOFGeometry.h"
d3c7bfac 32#include "AliTOFtrack.h"
33
74ea065c 34ClassImp(AliTOFtrack)
35
36//_____________________________________________________________________________
655e379f 37AliTOFtrack::AliTOFtrack() :
38 AliKalmanTrack(),
39 fSeedInd(-1),
ba66add8 40 fSeedLab(-1)
6c94f330 41{
74ea065c 42 //
6c94f330 43 // Default constructor.
74ea065c 44 //
6c94f330 45}
74ea065c 46
6c94f330 47//_____________________________________________________________________________
48AliTOFtrack::AliTOFtrack(const AliTOFtrack& t) :
49 AliKalmanTrack(t),
50 fSeedInd(t.fSeedInd),
ba66add8 51 fSeedLab(t.fSeedLab)
6c94f330 52{
53 //
54 // Copy constructor.
55 //
74ea065c 56}
57
58//_____________________________________________________________________________
6c94f330 59AliTOFtrack::AliTOFtrack(const AliESDtrack& t) :
60 AliKalmanTrack(),
655e379f 61 fSeedInd(-1),
ba66add8 62 fSeedLab(-1)
6c94f330 63{
74ea065c 64 //
65 // Constructor from AliESDtrack
66 //
74ea065c 67 SetLabel(t.GetLabel());
68 SetChi2(0.);
69 SetMass(t.GetMass());
70
6c94f330 71 Set(t.GetX(),t.GetAlpha(),t.GetParameter(),t.GetCovariance());
74ea065c 72
73 if ((t.GetStatus()&AliESDtrack::kTIME) == 0) return;
74 StartTimeIntegral();
115179c6 75 Double_t times[10];
76 for(Int_t isp=0;isp<AliPID::kSPECIESC;isp++){
77 times[isp] = t.GetIntegratedTimesOld(isp); // in ps
78 }
79
80 SetIntegratedTimes(times);
81 SetIntegratedLength(t.GetIntegratedLengthOld());
74ea065c 82
74ea065c 83}
7aeeaf38 84
85//____________________________________________________________________________
2f584d46 86AliTOFtrack& AliTOFtrack::operator=(const AliTOFtrack &/*source*/)
7aeeaf38 87{
88 // ass. op.
89
7aeeaf38 90 return *this;
91
92}
93
74ea065c 94//_____________________________________________________________________________
35b6d6a6 95Bool_t AliTOFtrack::PropagateTo(Double_t xk,Double_t /*x0*/,Double_t /*rho*/)
18f005ac 96 {
97 //
74ea065c 98 // Propagates a track of particle with mass=pm to a reference plane
99 // defined by x=xk through media of density=rho and radiationLength=x0
18f005ac 100 //
74ea065c 101
6c94f330 102 if (xk == GetX()) return kTRUE;
74ea065c 103
35b6d6a6 104 Double_t oldX=GetX();//, oldY=GetY(), oldZ=GetZ();
105 Double_t start[3], end[3], mparam[7];
74ea065c 106
5a388465 107 /* get start position */
108 GetXYZ(start);
109
110 /* propagate the track */
c4eac485 111 Double_t b[3];GetBxByBz(b);
112 if (!AliExternalTrackParam::PropagateToBxByBz(xk,b)) return kFALSE;
113 // OLD used code
114 //Double_t bz=GetBz();
115 //if (!AliExternalTrackParam::PropagateTo(xk,bz)) return kFALSE;
74ea065c 116
5a388465 117 /* get end position */
118 GetXYZ(end);
119
120 /* add time step to integral */
121#if 0 /*** OLD ***/
6c94f330 122 Double_t d = TMath::Sqrt((GetX()-oldX)*(GetX()-oldX) +
123 (GetY()-oldY)*(GetY()-oldY) +
124 (GetZ()-oldZ)*(GetZ()-oldZ));
125 if (IsStartedTimeIntegral() && GetX()>oldX) AddTimeStep(d);
5a388465 126#endif
127 Double_t d = TMath::Sqrt((end[0]-start[0])*(end[0]-start[0]) +
128 (end[1]-start[1])*(end[1]-start[1]) +
129 (end[2]-start[2])*(end[2]-start[2]));
130 if (IsStartedTimeIntegral() && GetX()>oldX) AddTimeStep(d);
131
132 /* get material budget from tracker */
133 AliTracker::MeanMaterialBudget(start, end, mparam);
134 Double_t xTimesRho = mparam[4]*mparam[0];
78c25bbc 135 if (oldX < xk) { // CZ
136 xTimesRho = -xTimesRho; // it should be negative in case of outward
137 // propagation (--> energy decreases)
138 } // CZ
5a388465 139 Double_t xOverX0 = mparam[1];
6c94f330 140
5a388465 141 /* correct for mean material */
142 if (!AliExternalTrackParam::CorrectForMeanMaterial(xOverX0,xTimesRho,GetMass())) return kFALSE;
143
144
145#if 0 /*** OLD ***/
6c94f330 146 if (!AliExternalTrackParam::CorrectForMaterial(d*rho/x0,x0,GetMass()))
147 return kFALSE;
5a388465 148#endif
74ea065c 149
74ea065c 150 /*
74ea065c 151 //Energy losses************************
152 if((5940*beta2/(1-beta2+1e-10) - beta2) < 0){return 0;}
153
154 Double_t dE=0.153e-3/beta2*(log(5940*beta2/(1-beta2+1e-10)) - beta2)*d*rho;
983ebc4f 155 //
156 // suspicious part - think about it ?
157 Double_t kinE = TMath::Sqrt(p2);
158 if (dE>0.8*kinE) dE = 0.8*kinE; //
159 if (dE<0) dE = 0.0; // not valid region for Bethe bloch
6c94f330 160 */
74ea065c 161
6c94f330 162 return kTRUE;
74ea065c 163}
164
165//_____________________________________________________________________________
ba4161e8 166Bool_t AliTOFtrack::PropagateToInnerTOF()
74ea065c 167{
168 // Propagates a track of particle with mass=pm to a reference plane
169 // defined by x=xk through media of density=rho and radiationLength=x0
170
78c25bbc 171 //const Double_t kAlphac = TMath::Pi()/9.0; // 20 degree
172 const Double_t kAlphac = AliTOFGeometry::GetAlpha(); // 20 degree
173 const Double_t kTalphac = TMath::Tan(kAlphac*0.5);
174
175 //const Double_t kStepSize = 0.1; // [cm] Step size
176 const Double_t kStepSize = 0.5; // [cm] Step size
177
178 Double_t x = GetX();
179 //Double_t bz = GetBz();
180
181 //Double_t xyz0[3];
182 //Double_t xyz1[3];
183 //Double_t y;
184 //Double_t z;
185
186 Int_t nsteps = (Int_t)((AliTOFGeometry::Rmin()-x)/kStepSize);
187 for (Int_t istep=0; istep<nsteps; istep++){
188
189 // Critical alpha - cross sector indication
190
191 Double_t dir = (GetX() > AliTOFGeometry::Rmin()) ? -1.0 : 1.0;
192
193 x = GetX()+dir*kStepSize;
194 if ( x<GetX() && GetX()<AliTOFGeometry::Rmin()) {
195 AliDebug(1,Form("Track doesn't reach rho=%f",AliTOFGeometry::Rmin()));
196 return kFALSE;
197 }
198
199 //GetXYZ(xyz0);
200 //bz = GetBz();
201 //GetXYZAt(x,bz,xyz1);
202 //AliExternalTrackParam::GetYAt(x,bz,y);
203 //AliExternalTrackParam::GetZAt(x,bz,z);
204
9a4d9088 205 if (!(PropagateTo(x,0.,0.))) { /* passing 0.,0. as arguments since now
206 this method queries TGeo for material budget
207 */
208 return kFALSE;
209 }
78c25bbc 210
9a4d9088 211 if (GetY() > GetX()*kTalphac) {
212 if (!(Rotate(kAlphac))) return kFALSE;
213 } else if (GetY() < -GetX()*kTalphac) {
214 if (!(Rotate(-kAlphac))) return kFALSE;
215 }
78c25bbc 216
217 }
218
219 //Bool_t check = PropagateTo(AliTOFGeometry::RinTOF());
220 Bool_t check = PropagateTo(AliTOFGeometry::RinTOF(),0.,0.); /* passing 0.,0. as arguments since now
221 this method queries TGeo for material budget
222 */
223
224 if (!check) return kFALSE;
225
9a4d9088 226 if (GetY() > GetX()*kTalphac) {
227 if (!(Rotate(kAlphac))) return kFALSE;
228 } else if (GetY() < -GetX()*kTalphac) {
229 if (!(Rotate(-kAlphac))) return kFALSE;
230 }
78c25bbc 231
232 return kTRUE;
233
234}
235
236//_____________________________________________________________________________
237Bool_t AliTOFtrack::PropagateToInnerTOFold()
238{
239 // Propagates a track of particle with mass=pm to a reference plane
240 // defined by x=xk through media of density=rho and radiationLength=x0
241
74ea065c 242
ba66add8 243 Double_t ymax=AliTOFGeometry::RinTOF()*TMath::Tan(0.5*AliTOFGeometry::GetAlpha());
74ea065c 244 Bool_t skip = kFALSE;
ba66add8 245 Double_t y=GetYat(AliTOFGeometry::RinTOF(),skip);
6c94f330 246 if (skip) {
247 return kFALSE;
74ea065c 248 }
249 if (y > ymax) {
9a4d9088 250 if (!Rotate(AliTOFGeometry::GetAlpha())) return kFALSE;
74ea065c 251 } else if (y <-ymax) {
9a4d9088 252 if (!Rotate(-AliTOFGeometry::GetAlpha())) return kFALSE;
74ea065c 253 }
254
2c770f53 255 Double_t x = GetX();
b3e52baa 256 Int_t nsteps=Int_t((AliTOFGeometry::Rmin()-x)/0.5); // 0.5 cm Steps
74ea065c 257 for (Int_t istep=0;istep<nsteps;istep++){
258 Float_t xp = x+istep*0.5;
5a388465 259 // GetPropagationParameters(param);
9a4d9088 260 if (!(PropagateTo(xp,0.,0.))) { /* passing 0.,0. as arguments since now
261 this method queries TGeo for material budget
262 */
263 return kFALSE;
264 }
74ea065c 265
266 }
267
9a4d9088 268 if (!(PropagateTo(AliTOFGeometry::RinTOF()))) return kFALSE;
269
6c94f330 270 return kTRUE;
74ea065c 271
272}
273
2c770f53 274//_________________________________________________________________________
ac359ffe 275Double_t AliTOFtrack::GetPredictedChi2(const AliCluster3D *c) const {
276 //
18f005ac 277 // Estimate the chi2 of the space point "c" with its cov. matrix elements
ac359ffe 278 //
18f005ac 279
ac359ffe 280 Double_t p[3]={c->GetX(), c->GetY(), c->GetZ()};
281 Double_t covyz[3]={c->GetSigmaY2(), c->GetSigmaYZ(), c->GetSigmaZ2()};
282 Double_t covxyz[3]={c->GetSigmaX2(), c->GetSigmaXY(), c->GetSigmaXZ()};
283 return AliExternalTrackParam::GetPredictedChi2(p, covyz, covxyz);
284}
285//_________________________________________________________________________
286Bool_t AliTOFtrack::PropagateTo(const AliCluster3D *c) {
287 //
18f005ac 288 // Propagates a track to the plane containing cluster 'c'
ac359ffe 289 //
290 Double_t oldX=GetX(), oldY=GetY(), oldZ=GetZ();
291 Double_t p[3]={c->GetX(), c->GetY(), c->GetZ()};
292 Double_t covyz[3]={c->GetSigmaY2(), c->GetSigmaYZ(), c->GetSigmaZ2()};
293 Double_t covxyz[3]={c->GetSigmaX2(), c->GetSigmaXY(), c->GetSigmaXZ()};
294 Double_t bz=GetBz();
295 if (!AliExternalTrackParam::PropagateTo(p, covyz, covxyz, bz)) return kFALSE;
296 if (IsStartedTimeIntegral()) {
297 Double_t d = TMath::Sqrt((GetX()-oldX)*(GetX()-oldX) +
298 (GetY()-oldY)*(GetY()-oldY) +
299 (GetZ()-oldZ)*(GetZ()-oldZ));
300 if (GetX()<oldX) d=-d;
301 AddTimeStep(d);
78c25bbc 302
ac359ffe 303 }
78c25bbc 304
9a4d9088 305 if (GetY() > GetX()*TMath::Tan(0.5*AliTOFGeometry::GetAlpha())) {
306 if (!(Rotate(AliTOFGeometry::GetAlpha()))) return kFALSE;
307 } else if (GetY() < -GetX()*TMath::Tan(0.5*AliTOFGeometry::GetAlpha())) {
308 if (!(Rotate(-AliTOFGeometry::GetAlpha()))) return kFALSE;
309 }
78c25bbc 310
ac359ffe 311 return kTRUE;
312}
313//_________________________________________________________________________
4668c628 314Double_t AliTOFtrack::GetYat(Double_t xk, Bool_t & skip) const {
2c770f53 315//-----------------------------------------------------------------
316// This function calculates the Y-coordinate of a track at the plane x=xk.
317// Needed for matching with the TOF (I.Belikov)
318//-----------------------------------------------------------------
6c94f330 319 Double_t y=0.;
320 skip=(!GetYAt(xk,GetBz(),y));
321 return y;
2c770f53 322}
74ea065c 323
324//_____________________________________________________________________________
325Int_t AliTOFtrack::Compare(const TObject *o) const {
326 //-----------------------------------------------------------------
327 // This function compares tracks according to the their curvature
328 //-----------------------------------------------------------------
329 AliTOFtrack *t=(AliTOFtrack*)o;
330 Double_t co=t->GetSigmaY2()*t->GetSigmaZ2();
331 Double_t c =GetSigmaY2()*GetSigmaZ2();
332 if (c>co) return 1;
333 else if (c<co) return -1;
334 return 0;
335}
336
6c94f330 337
74ea065c 338//_____________________________________________________________________________
ba4161e8 339void AliTOFtrack::GetPropagationParameters(Double_t *param) {
74ea065c 340
2c770f53 341 //Get average medium density, x0 while propagating the track
342
343 //For TRD holes description
ba4161e8 344 /*
74ea065c 345 Double_t thetamin = (90.-31.1) * TMath::Pi()/180.;
346 Double_t thetamax = (90.+31.1) * TMath::Pi()/180.;
347
348 Double_t zmin = -55.;
349 Double_t zmax = 55.;
ba4161e8 350 */
74ea065c 351
2c770f53 352 // Detector inner/outer radii
74ea065c 353 Double_t rTPC = 261.53;
354 Double_t rTPCTRD = 294.5;
355 Double_t rTRD = 369.1;
356
2c770f53 357 // Medium parameters
74ea065c 358 Double_t x0TPC = 40.;
359 Double_t rhoTPC =0.06124;
360
361 Double_t x0Air = 36.66;
362 Double_t rhoAir =1.2931e-3;
363
364 Double_t x0TRD = 171.7;
365 Double_t rhoTRD =0.33;
366
ba4161e8 367 // Int_t isec = GetSector();
6c94f330 368 Double_t r[3]; GetXYZ(r);
ba4161e8 369 // Float_t thetatr = TMath::ATan2(TMath::Sqrt(r[0]*r[0]+r[1]*r[1]),r[2]);
74ea065c 370
ba4161e8 371 /*
74ea065c 372 if(holes){
373 if (isec == 0 || isec == 1 || isec == 2 ) {
374 if( thetatr>=thetamin && thetatr<=thetamax){
375 x0TRD= x0Air;
376 rhoTRD = rhoAir;
377 }
378 }
379 if (isec == 11 || isec == 12 || isec == 13 || isec == 14 || isec == 15 ) {
6c94f330 380 if( r[2]>=zmin && r[2]<=zmax){
74ea065c 381 x0TRD= x0Air;
382 rhoTRD = rhoAir;
383 }
384 }
385 }
ba4161e8 386 */
2c770f53 387 if(GetX() <= rTPC)
74ea065c 388 {param[0]=x0TPC;param[1]=rhoTPC;}
2c770f53 389 else if(GetX() > rTPC && GetX() < rTPCTRD)
74ea065c 390 {param[0]=x0Air;param[1]=rhoAir;}
2c770f53 391 else if(GetX() >= rTPCTRD && GetX() < rTRD)
74ea065c 392 {param[0]=x0TRD;param[1]=rhoTRD;}
2c770f53 393 else if(GetX() >= rTRD )
74ea065c 394 {param[0]=x0Air;param[1]=rhoAir;}
74ea065c 395}