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 **************************************************************************/
15 //-----------------------------------------------------------------
16 // Implementation of the ESD track class
17 // ESD = Event Summary Data
18 // This is the class to deal with during the phisical analysis of data
19 // Origin: Iouri Belikov, CERN
20 // e-mail: Jouri.Belikov@cern.ch
21 //-----------------------------------------------------------------
25 #include "AliESDtrack.h"
26 #include "AliKalmanTrack.h"
30 //_______________________________________________________________________
31 AliESDtrack::AliESDtrack() :
50 fTPCClusterMap(159),//number of padrows
62 // The default ESD constructor
64 for (Int_t i=0; i<kSPECIES; i++) {
74 for (Int_t i=0; i<kSPECIESN; i++)
77 fPHOSpos[0]=fPHOSpos[1]=fPHOSpos[2]=0.;
79 for (i=0; i<5; i++) { fRp[i]=0.; fCp[i]=0.; fIp[i]=0.; fOp[i]=0.;}
80 for (i=0; i<15; i++) { fRc[i]=0.; fCc[i]=0.; fIc[i]=0.; fOc[i]=0.; }
81 for (i=0; i<6; i++) { fITSindex[i]=0; }
82 for (i=0; i<180; i++){ fTPCindex[i]=0; }
83 for (i=0; i<90; i++) { fTRDindex[i]=0; }
90 //_______________________________________________________________________
91 Double_t AliESDtrack::GetMass() const {
92 // Returns the mass of the most probable particle type
95 for (Int_t i=0; i<kSPECIES; i++) {
96 if (fR[i]>max) {k=i; max=fR[i];}
98 if (k==0) return 0.00051;
99 if (k==1) return 0.10566;
100 if (k==2||k==-1) return 0.13957;
101 if (k==3) return 0.49368;
102 if (k==4) return 0.93827;
103 Warning("GetMass()","Undefined mass !");
107 //_______________________________________________________________________
108 Bool_t AliESDtrack::UpdateTrackParams(AliKalmanTrack *t, ULong_t flags) {
110 // This function updates track's running parameters
113 fLabel=t->GetLabel();
115 if (t->IsStartedTimeIntegral()) {
117 Double_t times[10];t->GetIntegratedTimes(times); SetIntegratedTimes(times);
118 SetIntegratedLength(t->GetIntegratedLength());
121 fRalpha=t->GetAlpha();
122 t->GetExternalParameters(fRx,fRp);
123 t->GetExternalCovariance(fRc);
127 case kITSin: case kITSout: case kITSrefit:
128 fITSncls=t->GetNumberOfClusters();
129 fITSchi2=t->GetChi2();
130 for (Int_t i=0;i<fITSncls;i++) fITSindex[i]=t->GetClusterIndex(i);
131 fITSsignal=t->GetPIDsignal();
132 fITSLabel = t->GetLabel();
133 fITSFakeRatio = t->GetFakeRatio();
136 case kTPCin: case kTPCrefit:
137 fTPCLabel = t->GetLabel();
142 for (i=0; i<5; i++) fIp[i]=fRp[i];
143 for (i=0; i<15;i++) fIc[i]=fRc[i];
147 fTPCncls=t->GetNumberOfClusters();
148 fTPCchi2=t->GetChi2();
150 {//prevrow must be declared in separate namespace, otherwise compiler cries:
151 //"jump to case label crosses initialization of `Int_t prevrow'"
153 // for (Int_t i=0;i<fTPCncls;i++)
154 for (Int_t i=0;i<160;i++)
156 fTPCindex[i]=t->GetClusterIndex(i);
158 // Piotr's Cluster Map for HBT
159 // ### please change accordingly if cluster array is changing
160 // to "New TPC Tracking" style (with gaps in array)
161 Int_t idx = fTPCindex[i];
162 Int_t sect = (idx&0xff000000)>>24;
163 Int_t row = (idx&0x00ff0000)>>16;
164 if (sect > 18) row +=63; //if it is outer sector, add number of inner sectors
166 fTPCClusterMap.SetBitNumber(row,kTRUE);
168 //Fill the gap between previous row and this row with 0 bits
169 //In case ### pleas change it as well - just set bit 0 in case there
170 //is no associated clusters for current "i"
173 prevrow = row;//if previous bit was not assigned yet == this is the first one
176 { //we don't know the order (inner to outer or reverse)
177 //just to be save in case it is going to change
190 for (Int_t j = n+1; j < m; j++)
192 fTPCClusterMap.SetBitNumber(j,kFALSE);
196 // End Of Piotr's Cluster Map for HBT
199 fTPCsignal=t->GetPIDsignal();
200 {Double_t mass=t->GetMass(); // preliminary mass setting
201 if (mass>0.5) fR[4]=1.; // used by
202 else if (mass<0.4) fR[2]=1.; // the ITS reconstruction
208 { //requested by the PHOS ("temporary solution")
210 if (t->PropagateTo(r,30.,0.)) {
211 fOalpha=t->GetAlpha();
212 t->GetExternalParameters(fOx,fOp);
213 t->GetExternalCovariance(fOc);
220 case kTRDin: case kTRDrefit:
221 fTRDLabel = t->GetLabel();
223 fTRDncls=t->GetNumberOfClusters();
224 fTRDchi2=t->GetChi2();
225 for (Int_t i=0;i<fTRDncls;i++) fTRDindex[i]=t->GetClusterIndex(i);
226 fTRDsignal=t->GetPIDsignal();
231 Error("UpdateTrackParams()","Wrong flag !\n");
238 //_______________________________________________________________________
240 AliESDtrack::SetConstrainedTrackParams(AliKalmanTrack *t, Double_t chi2) {
242 // This function sets the constrained track parameters
244 fCalpha=t->GetAlpha();
245 t->GetExternalParameters(fCx,fCp);
246 t->GetExternalCovariance(fCc);
251 //_______________________________________________________________________
252 void AliESDtrack::GetExternalParameters(Double_t &x, Double_t p[5]) const {
253 //---------------------------------------------------------------------
254 // This function returns external representation of the track parameters
255 //---------------------------------------------------------------------
257 for (Int_t i=0; i<5; i++) p[i]=fRp[i];
259 //_______________________________________________________________________
260 void AliESDtrack::GetExternalCovariance(Double_t cov[15]) const {
261 //---------------------------------------------------------------------
262 // This function returns external representation of the cov. matrix
263 //---------------------------------------------------------------------
264 for (Int_t i=0; i<15; i++) cov[i]=fRc[i];
268 //_______________________________________________________________________
270 AliESDtrack::GetConstrainedExternalParameters(Double_t &x, Double_t p[5])const{
271 //---------------------------------------------------------------------
272 // This function returns the constrained external track parameters
273 //---------------------------------------------------------------------
275 for (Int_t i=0; i<5; i++) p[i]=fCp[i];
277 //_______________________________________________________________________
279 AliESDtrack::GetConstrainedExternalCovariance(Double_t c[15]) const {
280 //---------------------------------------------------------------------
281 // This function returns the constrained external cov. matrix
282 //---------------------------------------------------------------------
283 for (Int_t i=0; i<15; i++) c[i]=fCc[i];
287 Double_t AliESDtrack::GetP() const {
288 //---------------------------------------------------------------------
289 // This function returns the track momentum
290 //---------------------------------------------------------------------
291 if (TMath::Abs(fRp[4])<=0) return 0;
292 Double_t pt=1./TMath::Abs(fRp[4]);
293 return pt*TMath::Sqrt(1.+ fRp[3]*fRp[3]);
296 void AliESDtrack::GetConstrainedPxPyPz(Double_t *p) const {
297 //---------------------------------------------------------------------
298 // This function returns the constrained global track momentum components
299 //---------------------------------------------------------------------
300 if (TMath::Abs(fCp[4])<=0) {
304 Double_t phi=TMath::ASin(fCp[2]) + fCalpha;
305 Double_t pt=1./TMath::Abs(fCp[4]);
306 p[0]=pt*TMath::Cos(phi); p[1]=pt*TMath::Sin(phi); p[2]=pt*fCp[3];
308 void AliESDtrack::GetConstrainedXYZ(Double_t *xyz) const {
309 //---------------------------------------------------------------------
310 // This function returns the global track position
311 //---------------------------------------------------------------------
312 Double_t phi=TMath::ATan2(fCp[0],fCx) + fCalpha;
313 Double_t r=TMath::Sqrt(fCx*fCx + fCp[0]*fCp[0]);
314 xyz[0]=r*TMath::Cos(phi); xyz[1]=r*TMath::Sin(phi); xyz[2]=fCp[1];
317 void AliESDtrack::GetPxPyPz(Double_t *p) const {
318 //---------------------------------------------------------------------
319 // This function returns the global track momentum components
320 //---------------------------------------------------------------------
321 if (TMath::Abs(fRp[4])<=0) {
325 Double_t phi=TMath::ASin(fRp[2]) + fRalpha;
326 Double_t pt=1./TMath::Abs(fRp[4]);
327 p[0]=pt*TMath::Cos(phi); p[1]=pt*TMath::Sin(phi); p[2]=pt*fRp[3];
329 void AliESDtrack::GetXYZ(Double_t *xyz) const {
330 //---------------------------------------------------------------------
331 // This function returns the global track position
332 //---------------------------------------------------------------------
333 Double_t phi=TMath::ATan2(fRp[0],fRx) + fRalpha;
334 Double_t r=TMath::Sqrt(fRx*fRx + fRp[0]*fRp[0]);
335 xyz[0]=r*TMath::Cos(phi); xyz[1]=r*TMath::Sin(phi); xyz[2]=fRp[1];
339 void AliESDtrack::GetInnerPxPyPz(Double_t *p) const {
340 //---------------------------------------------------------------------
341 // This function returns the global track momentum components
342 // af the entrance of the TPC
343 //---------------------------------------------------------------------
344 if (fIx==0) {p[0]=p[1]=p[2]=0.; return;}
345 Double_t phi=TMath::ASin(fIp[2]) + fIalpha;
346 Double_t pt=1./TMath::Abs(fIp[4]);
347 p[0]=pt*TMath::Cos(phi); p[1]=pt*TMath::Sin(phi); p[2]=pt*fIp[3];
350 void AliESDtrack::GetInnerXYZ(Double_t *xyz) const {
351 //---------------------------------------------------------------------
352 // This function returns the global track position
353 // af the entrance of the TPC
354 //---------------------------------------------------------------------
355 if (fIx==0) {xyz[0]=xyz[1]=xyz[2]=0.; return;}
356 Double_t phi=TMath::ATan2(fIp[0],fIx) + fIalpha;
357 Double_t r=TMath::Sqrt(fIx*fIx + fIp[0]*fIp[0]);
358 xyz[0]=r*TMath::Cos(phi); xyz[1]=r*TMath::Sin(phi); xyz[2]=fIp[1];
361 void AliESDtrack::GetInnerExternalParameters(Double_t &x, Double_t p[5]) const
364 //---------------------------------------------------------------------
365 // This function returns external representation of the track parameters at Inner Layer of TPC
366 //---------------------------------------------------------------------
368 for (Int_t i=0; i<5; i++) p[i]=fIp[i];
370 void AliESDtrack::GetInnerExternalCovariance(Double_t cov[15]) const
373 //---------------------------------------------------------------------
374 // This function returns external representation of the cov. matrix at Inner Layer of TPC
375 //---------------------------------------------------------------------
376 for (Int_t i=0; i<15; i++) cov[i]=fIc[i];
380 void AliESDtrack::GetOuterPxPyPz(Double_t *p) const {
381 //---------------------------------------------------------------------
382 // This function returns the global track momentum components
383 // af the radius of the PHOS
384 //---------------------------------------------------------------------
385 if (fOx==0) {p[0]=p[1]=p[2]=0.; return;}
386 Double_t phi=TMath::ASin(fOp[2]) + fOalpha;
387 Double_t pt=1./TMath::Abs(fOp[4]);
388 p[0]=pt*TMath::Cos(phi); p[1]=pt*TMath::Sin(phi); p[2]=pt*fOp[3];
391 void AliESDtrack::GetOuterXYZ(Double_t *xyz) const {
392 //---------------------------------------------------------------------
393 // This function returns the global track position
394 // af the radius of the PHOS
395 //---------------------------------------------------------------------
396 if (fOx==0) {xyz[0]=xyz[1]=xyz[2]=0.; return;}
397 Double_t phi=TMath::ATan2(fOp[0],fOx) + fOalpha;
398 Double_t r=TMath::Sqrt(fOx*fOx + fOp[0]*fOp[0]);
399 xyz[0]=r*TMath::Cos(phi); xyz[1]=r*TMath::Sin(phi); xyz[2]=fOp[1];
402 //_______________________________________________________________________
403 void AliESDtrack::GetIntegratedTimes(Double_t *times) const {
404 // Returns the array with integrated times for each particle hypothesis
405 for (Int_t i=0; i<kSPECIES; i++) times[i]=fTrackTime[i];
408 //_______________________________________________________________________
409 void AliESDtrack::SetIntegratedTimes(const Double_t *times) {
410 // Sets the array with integrated times for each particle hypotesis
411 for (Int_t i=0; i<kSPECIES; i++) fTrackTime[i]=times[i];
414 //_______________________________________________________________________
415 void AliESDtrack::SetITSpid(const Double_t *p) {
416 // Sets values for the probability of each particle type (in ITS)
417 for (Int_t i=0; i<kSPECIES; i++) fITSr[i]=p[i];
418 SetStatus(AliESDtrack::kITSpid);
421 void AliESDtrack::SetITSChi2MIP(const Float_t *chi2mip){
422 for (Int_t i=0; i<6; i++) fITSchi2MIP[i]=chi2mip[i];
424 //_______________________________________________________________________
425 void AliESDtrack::GetITSpid(Double_t *p) const {
426 // Gets the probability of each particle type (in ITS)
427 for (Int_t i=0; i<kSPECIES; i++) p[i]=fITSr[i];
430 //_______________________________________________________________________
431 Int_t AliESDtrack::GetITSclusters(UInt_t *idx) const {
432 //---------------------------------------------------------------------
433 // This function returns indices of the assgined ITS clusters
434 //---------------------------------------------------------------------
435 for (Int_t i=0; i<fITSncls; i++) idx[i]=fITSindex[i];
439 //_______________________________________________________________________
440 Int_t AliESDtrack::GetTPCclusters(Int_t *idx) const {
441 //---------------------------------------------------------------------
442 // This function returns indices of the assgined ITS clusters
443 //---------------------------------------------------------------------
445 for (Int_t i=0; i<180; i++) idx[i]=fTPCindex[i]; // MI I prefer some constant
449 //_______________________________________________________________________
450 void AliESDtrack::SetTPCpid(const Double_t *p) {
451 // Sets values for the probability of each particle type (in TPC)
452 for (Int_t i=0; i<kSPECIES; i++) fTPCr[i]=p[i];
453 SetStatus(AliESDtrack::kTPCpid);
456 //_______________________________________________________________________
457 void AliESDtrack::GetTPCpid(Double_t *p) const {
458 // Gets the probability of each particle type (in TPC)
459 for (Int_t i=0; i<kSPECIES; i++) p[i]=fTPCr[i];
462 //_______________________________________________________________________
463 Int_t AliESDtrack::GetTRDclusters(UInt_t *idx) const {
464 //---------------------------------------------------------------------
465 // This function returns indices of the assgined TRD clusters
466 //---------------------------------------------------------------------
468 for (Int_t i=0; i<90; i++) idx[i]=fTRDindex[i]; // MI I prefer some constant
472 //_______________________________________________________________________
473 void AliESDtrack::SetTRDpid(const Double_t *p) {
474 // Sets values for the probability of each particle type (in TRD)
475 for (Int_t i=0; i<kSPECIES; i++) fTRDr[i]=p[i];
476 SetStatus(AliESDtrack::kTRDpid);
479 //_______________________________________________________________________
480 void AliESDtrack::GetTRDpid(Double_t *p) const {
481 // Gets the probability of each particle type (in TRD)
482 for (Int_t i=0; i<kSPECIES; i++) p[i]=fTRDr[i];
485 //_______________________________________________________________________
486 void AliESDtrack::SetTRDpid(Int_t iSpecies, Float_t p)
488 // Sets the probability of particle type iSpecies to p (in TRD)
492 Float_t AliESDtrack::GetTRDpid(Int_t iSpecies) const
494 // Returns the probability of particle type iSpecies (in TRD)
495 return fTRDr[iSpecies];
498 //_______________________________________________________________________
499 void AliESDtrack::SetTOFpid(const Double_t *p) {
500 // Sets the probability of each particle type (in TOF)
501 for (Int_t i=0; i<kSPECIES; i++) fTOFr[i]=p[i];
502 SetStatus(AliESDtrack::kTOFpid);
505 //_______________________________________________________________________
506 void AliESDtrack::GetTOFpid(Double_t *p) const {
507 // Gets probabilities of each particle type (in TOF)
508 for (Int_t i=0; i<kSPECIES; i++) p[i]=fTOFr[i];
513 //_______________________________________________________________________
514 void AliESDtrack::SetPHOSpid(const Double_t *p) {
515 // Sets the probability of each particle type (in PHOS)
516 for (Int_t i=0; i<kSPECIESN; i++) fPHOSr[i]=p[i];
517 SetStatus(AliESDtrack::kPHOSpid);
520 //_______________________________________________________________________
521 void AliESDtrack::GetPHOSpid(Double_t *p) const {
522 // Gets probabilities of each particle type (in PHOS)
523 for (Int_t i=0; i<kSPECIESN; i++) p[i]=fPHOSr[i];
527 //_______________________________________________________________________
528 void AliESDtrack::SetRICHpid(const Double_t *p) {
529 // Sets the probability of each particle type (in RICH)
530 for (Int_t i=0; i<kSPECIES; i++) fRICHr[i]=p[i];
531 SetStatus(AliESDtrack::kRICHpid);
534 //_______________________________________________________________________
535 void AliESDtrack::GetRICHpid(Double_t *p) const {
536 // Gets probabilities of each particle type (in RICH)
537 for (Int_t i=0; i<kSPECIES; i++) p[i]=fRICHr[i];
542 //_______________________________________________________________________
543 void AliESDtrack::SetESDpid(const Double_t *p) {
544 // Sets the probability of each particle type for the ESD track
545 for (Int_t i=0; i<kSPECIES; i++) fR[i]=p[i];
546 SetStatus(AliESDtrack::kESDpid);
549 //_______________________________________________________________________
550 void AliESDtrack::GetESDpid(Double_t *p) const {
551 // Gets probability of each particle type for the ESD track
552 for (Int_t i=0; i<kSPECIES; i++) p[i]=fR[i];
555 //_______________________________________________________________________
556 void AliESDtrack::Print(Option_t *) const {
557 // Prints info on the track
559 Info("Print","Track info") ;
560 Double_t p[kSPECIESN] ;
563 printf("From ITS: ") ;
565 for(index = 0 ; index < kSPECIES; index++)
566 printf("%f, ", p[index]) ;
567 printf("\n signal = %f\n", GetITSsignal()) ;
570 printf("From TPC: ") ;
572 for(index = 0 ; index < kSPECIES; index++)
573 printf("%f, ", p[index]) ;
574 printf("\n signal = %f\n", GetTPCsignal()) ;
577 printf("From TRD: ") ;
579 for(index = 0 ; index < kSPECIES; index++)
580 printf("%f, ", p[index]) ;
581 printf("\n signal = %f\n", GetTRDsignal()) ;
584 printf("From TOF: ") ;
586 for(index = 0 ; index < kSPECIES; index++)
587 printf("%f, ", p[index]) ;
588 printf("\n signal = %f\n", GetTOFsignal()) ;
590 if( IsOn(kRICHpid) ){
591 printf("From TOF: ") ;
593 for(index = 0 ; index < kSPECIES; index++)
594 printf("%f, ", p[index]) ;
595 printf("\n signal = %f\n", GetRICHsignal()) ;
597 if( IsOn(kPHOSpid) ){
598 printf("From PHOS: ") ;
600 for(index = 0 ; index < kSPECIESN; index++)
601 printf("%f, ", p[index]) ;
602 printf("\n signal = %f\n", GetPHOSsignal()) ;