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