1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
16 //-----------------------------------------------------------------
17 // Implementation of the ESD track class
18 // ESD = Event Summary Data
19 // This is the class to deal with during the phisical analysis of data
20 // Origin: Iouri Belikov, CERN
21 // e-mail: Jouri.Belikov@cern.ch
22 //-----------------------------------------------------------------
26 #include "AliESDtrack.h"
27 #include "AliKalmanTrack.h"
31 //_______________________________________________________________________
32 AliESDtrack::AliESDtrack() :
51 fTPCClusterMap(159),//number of padrows
63 // The default ESD constructor
65 for (Int_t i=0; i<kSPECIES; i++) {
75 fPHOSpos[0]=fPHOSpos[1]=fPHOSpos[2]=0.;
77 for (i=0; i<5; i++) { fRp[i]=0.; fCp[i]=0.; fIp[i]=0.; fOp[i]=0.;}
78 for (i=0; i<15; i++) { fRc[i]=0.; fCc[i]=0.; fIc[i]=0.; fOc[i]=0.; }
79 for (i=0; i<6; i++) { fITSindex[i]=0; }
80 for (i=0; i<180; i++){ fTPCindex[i]=0; }
81 for (i=0; i<90; i++) { fTRDindex[i]=0; }
88 //_______________________________________________________________________
89 Double_t AliESDtrack::GetMass() const {
90 // Returns the mass of the most probable particle type
93 for (Int_t i=0; i<kSPECIES; i++) {
94 if (fR[i]>max) {k=i; max=fR[i];}
96 if (k==0) return 0.00051;
97 if (k==1) return 0.10566;
98 if (k==2||k==-1) return 0.13957;
99 if (k==3) return 0.49368;
100 if (k==4) return 0.93827;
101 Warning("GetMass()","Undefined mass !");
105 //_______________________________________________________________________
106 Bool_t AliESDtrack::UpdateTrackParams(AliKalmanTrack *t, ULong_t flags) {
108 // This function updates track's running parameters
111 fLabel=t->GetLabel();
113 if (t->IsStartedTimeIntegral()) {
115 Double_t times[10];t->GetIntegratedTimes(times); SetIntegratedTimes(times);
116 SetIntegratedLength(t->GetIntegratedLength());
119 fRalpha=t->GetAlpha();
120 t->GetExternalParameters(fRx,fRp);
121 t->GetExternalCovariance(fRc);
125 case kITSin: case kITSout: case kITSrefit:
126 fITSncls=t->GetNumberOfClusters();
127 fITSchi2=t->GetChi2();
128 for (Int_t i=0;i<fITSncls;i++) fITSindex[i]=t->GetClusterIndex(i);
129 fITSsignal=t->GetPIDsignal();
130 fITSLabel = t->GetLabel();
133 case kTPCin: case kTPCrefit:
134 fTPCLabel = t->GetLabel();
139 for (i=0; i<5; i++) fIp[i]=fRp[i];
140 for (i=0; i<15;i++) fIc[i]=fRc[i];
144 fTPCncls=t->GetNumberOfClusters();
145 fTPCchi2=t->GetChi2();
147 {//prevrow must be declared in separate namespace, otherwise compiler cries:
148 //"jump to case label crosses initialization of `Int_t prevrow'"
150 // for (Int_t i=0;i<fTPCncls;i++)
151 for (Int_t i=0;i<160;i++)
153 fTPCindex[i]=t->GetClusterIndex(i);
155 // Piotr's Cluster Map for HBT
156 // ### please change accordingly if cluster array is changing
157 // to "New TPC Tracking" style (with gaps in array)
158 Int_t idx = fTPCindex[i];
159 Int_t sect = (idx&0xff000000)>>24;
160 Int_t row = (idx&0x00ff0000)>>16;
161 if (sect > 18) row +=63; //if it is outer sector, add number of inner sectors
163 fTPCClusterMap.SetBitNumber(row,kTRUE);
165 //Fill the gap between previous row and this row with 0 bits
166 //In case ### pleas change it as well - just set bit 0 in case there
167 //is no associated clusters for current "i"
170 prevrow = row;//if previous bit was not assigned yet == this is the first one
173 { //we don't know the order (inner to outer or reverse)
174 //just to be save in case it is going to change
187 for (Int_t j = n+1; j < m; j++)
189 fTPCClusterMap.SetBitNumber(j,kFALSE);
193 // End Of Piotr's Cluster Map for HBT
196 fTPCsignal=t->GetPIDsignal();
197 {Double_t mass=t->GetMass(); // preliminary mass setting
198 if (mass>0.5) fR[4]=1.; // used by
199 else if (mass<0.4) fR[2]=1.; // the ITS reconstruction
205 { //requested by the PHOS ("temporary solution")
207 if (t->PropagateTo(r,30.,0.)) {
208 fOalpha=t->GetAlpha();
209 t->GetExternalParameters(fOx,fOp);
210 t->GetExternalCovariance(fOc);
213 case kTRDin: case kTRDrefit:
214 fTRDLabel = t->GetLabel();
216 fTRDncls=t->GetNumberOfClusters();
217 fTRDchi2=t->GetChi2();
218 for (Int_t i=0;i<fTRDncls;i++) fTRDindex[i]=t->GetClusterIndex(i);
219 fTRDsignal=t->GetPIDsignal();
224 Error("UpdateTrackParams()","Wrong flag !\n");
231 //_______________________________________________________________________
233 AliESDtrack::SetConstrainedTrackParams(AliKalmanTrack *t, Double_t chi2) {
235 // This function sets the constrained track parameters
237 fCalpha=t->GetAlpha();
238 t->GetExternalParameters(fCx,fCp);
239 t->GetExternalCovariance(fCc);
244 //_______________________________________________________________________
245 void AliESDtrack::GetExternalParameters(Double_t &x, Double_t p[5]) const {
246 //---------------------------------------------------------------------
247 // This function returns external representation of the track parameters
248 //---------------------------------------------------------------------
250 for (Int_t i=0; i<5; i++) p[i]=fRp[i];
252 //_______________________________________________________________________
253 void AliESDtrack::GetExternalCovariance(Double_t cov[15]) const {
254 //---------------------------------------------------------------------
255 // This function returns external representation of the cov. matrix
256 //---------------------------------------------------------------------
257 for (Int_t i=0; i<15; i++) cov[i]=fRc[i];
261 //_______________________________________________________________________
263 AliESDtrack::GetConstrainedExternalParameters(Double_t &x, Double_t p[5])const{
264 //---------------------------------------------------------------------
265 // This function returns the constrained external track parameters
266 //---------------------------------------------------------------------
268 for (Int_t i=0; i<5; i++) p[i]=fCp[i];
270 //_______________________________________________________________________
272 AliESDtrack::GetConstrainedExternalCovariance(Double_t c[15]) const {
273 //---------------------------------------------------------------------
274 // This function returns the constrained external cov. matrix
275 //---------------------------------------------------------------------
276 for (Int_t i=0; i<15; i++) c[i]=fCc[i];
280 Double_t AliESDtrack::GetP() const {
281 //---------------------------------------------------------------------
282 // This function returns the track momentum
283 //---------------------------------------------------------------------
284 Double_t lam=TMath::ATan(fRp[3]);
285 Double_t pt=1./TMath::Abs(fRp[4]);
286 return pt/TMath::Cos(lam);
289 void AliESDtrack::GetConstrainedPxPyPz(Double_t *p) const {
290 //---------------------------------------------------------------------
291 // This function returns the constrained global track momentum components
292 //---------------------------------------------------------------------
293 Double_t phi=TMath::ASin(fCp[2]) + fCalpha;
294 Double_t pt=1./TMath::Abs(fCp[4]);
295 p[0]=pt*TMath::Cos(phi); p[1]=pt*TMath::Sin(phi); p[2]=pt*fCp[3];
297 void AliESDtrack::GetConstrainedXYZ(Double_t *xyz) const {
298 //---------------------------------------------------------------------
299 // This function returns the global track position
300 //---------------------------------------------------------------------
301 Double_t phi=TMath::ATan2(fCp[0],fCx) + fCalpha;
302 Double_t r=TMath::Sqrt(fCx*fCx + fCp[0]*fCp[0]);
303 xyz[0]=r*TMath::Cos(phi); xyz[1]=r*TMath::Sin(phi); xyz[2]=fCp[1];
306 void AliESDtrack::GetPxPyPz(Double_t *p) const {
307 //---------------------------------------------------------------------
308 // This function returns the global track momentum components
309 //---------------------------------------------------------------------
310 Double_t phi=TMath::ASin(fRp[2]) + fRalpha;
311 Double_t pt=1./TMath::Abs(fRp[4]);
312 p[0]=pt*TMath::Cos(phi); p[1]=pt*TMath::Sin(phi); p[2]=pt*fRp[3];
314 void AliESDtrack::GetXYZ(Double_t *xyz) const {
315 //---------------------------------------------------------------------
316 // This function returns the global track position
317 //---------------------------------------------------------------------
318 Double_t phi=TMath::ATan2(fRp[0],fRx) + fRalpha;
319 Double_t r=TMath::Sqrt(fRx*fRx + fRp[0]*fRp[0]);
320 xyz[0]=r*TMath::Cos(phi); xyz[1]=r*TMath::Sin(phi); xyz[2]=fRp[1];
324 void AliESDtrack::GetInnerPxPyPz(Double_t *p) const {
325 //---------------------------------------------------------------------
326 // This function returns the global track momentum components
327 // af the entrance of the TPC
328 //---------------------------------------------------------------------
329 if (fIx==0) {p[0]=p[1]=p[2]=0.; return;}
330 Double_t phi=TMath::ASin(fIp[2]) + fIalpha;
331 Double_t pt=1./TMath::Abs(fIp[4]);
332 p[0]=pt*TMath::Cos(phi); p[1]=pt*TMath::Sin(phi); p[2]=pt*fIp[3];
335 void AliESDtrack::GetInnerXYZ(Double_t *xyz) const {
336 //---------------------------------------------------------------------
337 // This function returns the global track position
338 // af the entrance of the TPC
339 //---------------------------------------------------------------------
340 if (fIx==0) {xyz[0]=xyz[1]=xyz[2]=0.; return;}
341 Double_t phi=TMath::ATan2(fIp[0],fIx) + fIalpha;
342 Double_t r=TMath::Sqrt(fIx*fIx + fIp[0]*fIp[0]);
343 xyz[0]=r*TMath::Cos(phi); xyz[1]=r*TMath::Sin(phi); xyz[2]=fIp[1];
346 void AliESDtrack::GetInnerExternalParameters(Double_t &x, Double_t p[5]) const
349 //---------------------------------------------------------------------
350 // This function returns external representation of the track parameters at Inner Layer of TPC
351 //---------------------------------------------------------------------
353 for (Int_t i=0; i<5; i++) p[i]=fIp[i];
355 void AliESDtrack::GetInnerExternalCovariance(Double_t cov[15]) const
358 //---------------------------------------------------------------------
359 // This function returns external representation of the cov. matrix at Inner Layer of TPC
360 //---------------------------------------------------------------------
361 for (Int_t i=0; i<15; i++) cov[i]=fIc[i];
365 void AliESDtrack::GetOuterPxPyPz(Double_t *p) const {
366 //---------------------------------------------------------------------
367 // This function returns the global track momentum components
368 // af the radius of the PHOS
369 //---------------------------------------------------------------------
370 if (fOx==0) {p[0]=p[1]=p[2]=0.; return;}
371 Double_t phi=TMath::ASin(fOp[2]) + fOalpha;
372 Double_t pt=1./TMath::Abs(fOp[4]);
373 p[0]=pt*TMath::Cos(phi); p[1]=pt*TMath::Sin(phi); p[2]=pt*fOp[3];
376 void AliESDtrack::GetOuterXYZ(Double_t *xyz) const {
377 //---------------------------------------------------------------------
378 // This function returns the global track position
379 // af the radius of the PHOS
380 //---------------------------------------------------------------------
381 if (fOx==0) {xyz[0]=xyz[1]=xyz[2]=0.; return;}
382 Double_t phi=TMath::ATan2(fOp[0],fOx) + fOalpha;
383 Double_t r=TMath::Sqrt(fOx*fOx + fOp[0]*fOp[0]);
384 xyz[0]=r*TMath::Cos(phi); xyz[1]=r*TMath::Sin(phi); xyz[2]=fOp[1];
387 //_______________________________________________________________________
388 void AliESDtrack::GetIntegratedTimes(Double_t *times) const {
389 // Returns the array with integrated times for each particle hypothesis
390 for (Int_t i=0; i<kSPECIES; i++) times[i]=fTrackTime[i];
393 //_______________________________________________________________________
394 void AliESDtrack::SetIntegratedTimes(const Double_t *times) {
395 // Sets the array with integrated times for each particle hypotesis
396 for (Int_t i=0; i<kSPECIES; i++) fTrackTime[i]=times[i];
399 //_______________________________________________________________________
400 void AliESDtrack::SetITSpid(const Double_t *p) {
401 // Sets values for the probability of each particle type (in ITS)
402 for (Int_t i=0; i<kSPECIES; i++) fITSr[i]=p[i];
403 SetStatus(AliESDtrack::kITSpid);
406 //_______________________________________________________________________
407 void AliESDtrack::GetITSpid(Double_t *p) const {
408 // Gets the probability of each particle type (in ITS)
409 for (Int_t i=0; i<kSPECIES; i++) p[i]=fITSr[i];
412 //_______________________________________________________________________
413 Int_t AliESDtrack::GetITSclusters(UInt_t *idx) const {
414 //---------------------------------------------------------------------
415 // This function returns indices of the assgined ITS clusters
416 //---------------------------------------------------------------------
417 for (Int_t i=0; i<fITSncls; i++) idx[i]=fITSindex[i];
421 //_______________________________________________________________________
422 Int_t AliESDtrack::GetTPCclusters(Int_t *idx) const {
423 //---------------------------------------------------------------------
424 // This function returns indices of the assgined ITS clusters
425 //---------------------------------------------------------------------
427 for (Int_t i=0; i<180; i++) idx[i]=fTPCindex[i]; // MI I prefer some constant
431 //_______________________________________________________________________
432 void AliESDtrack::SetTPCpid(const Double_t *p) {
433 // Sets values for the probability of each particle type (in TPC)
434 for (Int_t i=0; i<kSPECIES; i++) fTPCr[i]=p[i];
435 SetStatus(AliESDtrack::kTPCpid);
438 //_______________________________________________________________________
439 void AliESDtrack::GetTPCpid(Double_t *p) const {
440 // Gets the probability of each particle type (in TPC)
441 for (Int_t i=0; i<kSPECIES; i++) p[i]=fTPCr[i];
444 //_______________________________________________________________________
445 Int_t AliESDtrack::GetTRDclusters(UInt_t *idx) const {
446 //---------------------------------------------------------------------
447 // This function returns indices of the assgined TRD clusters
448 //---------------------------------------------------------------------
450 for (Int_t i=0; i<90; i++) idx[i]=fTRDindex[i]; // MI I prefer some constant
454 //_______________________________________________________________________
455 void AliESDtrack::SetTRDpid(const Double_t *p) {
456 // Sets values for the probability of each particle type (in TRD)
457 for (Int_t i=0; i<kSPECIES; i++) fTRDr[i]=p[i];
458 SetStatus(AliESDtrack::kTRDpid);
461 //_______________________________________________________________________
462 void AliESDtrack::GetTRDpid(Double_t *p) const {
463 // Gets the probability of each particle type (in TRD)
464 for (Int_t i=0; i<kSPECIES; i++) p[i]=fTRDr[i];
467 //_______________________________________________________________________
468 void AliESDtrack::SetTRDpid(Int_t iSpecies, Float_t p)
470 // Sets the probability of particle type iSpecies to p (in TRD)
474 Float_t AliESDtrack::GetTRDpid(Int_t iSpecies) const
476 // Returns the probability of particle type iSpecies (in TRD)
477 return fTRDr[iSpecies];
480 //_______________________________________________________________________
481 void AliESDtrack::SetTOFpid(const Double_t *p) {
482 // Sets the probability of each particle type (in TOF)
483 for (Int_t i=0; i<kSPECIES; i++) fTOFr[i]=p[i];
484 SetStatus(AliESDtrack::kTOFpid);
487 //_______________________________________________________________________
488 void AliESDtrack::GetTOFpid(Double_t *p) const {
489 // Gets probabilities of each particle type (in TOF)
490 for (Int_t i=0; i<kSPECIES; i++) p[i]=fTOFr[i];
495 //_______________________________________________________________________
496 void AliESDtrack::SetPHOSpid(const Double_t *p) {
497 // Sets the probability of each particle type (in PHOS)
498 for (Int_t i=0; i<kSPECIES; i++) fPHOSr[i]=p[i];
499 SetStatus(AliESDtrack::kPHOSpid);
502 //_______________________________________________________________________
503 void AliESDtrack::GetPHOSpid(Double_t *p) const {
504 // Gets probabilities of each particle type (in PHOS)
505 for (Int_t i=0; i<kSPECIES; i++) p[i]=fPHOSr[i];
509 //_______________________________________________________________________
510 void AliESDtrack::SetRICHpid(const Double_t *p) {
511 // Sets the probability of each particle type (in RICH)
512 for (Int_t i=0; i<kSPECIES; i++) fRICHr[i]=p[i];
513 SetStatus(AliESDtrack::kRICHpid);
516 //_______________________________________________________________________
517 void AliESDtrack::GetRICHpid(Double_t *p) const {
518 // Gets probabilities of each particle type (in RICH)
519 for (Int_t i=0; i<kSPECIES; i++) p[i]=fRICHr[i];
524 //_______________________________________________________________________
525 void AliESDtrack::SetESDpid(const Double_t *p) {
526 // Sets the probability of each particle type for the ESD track
527 for (Int_t i=0; i<kSPECIES; i++) fR[i]=p[i];
528 SetStatus(AliESDtrack::kESDpid);
531 //_______________________________________________________________________
532 void AliESDtrack::GetESDpid(Double_t *p) const {
533 // Gets probability of each particle type for the ESD track
534 for (Int_t i=0; i<kSPECIES; i++) p[i]=fR[i];