]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliESDtrack.cxx
Modifications needed by the HBT analysis (P.Skowronski)
[u/mrichter/AliRoot.git] / STEER / AliESDtrack.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 //-----------------------------------------------------------------
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 //-----------------------------------------------------------------
23
24 #include "TMath.h"
25
26 #include "AliESDtrack.h"
27 #include "AliKalmanTrack.h"
28
29 ClassImp(AliESDtrack)
30
31 //_______________________________________________________________________
32 AliESDtrack::AliESDtrack() : 
33 fFlags(0),
34 fLabel(0),
35 fTrackLength(0),
36 fStopVertex(0),
37 fRalpha(0),
38 fRx(0),
39 fCalpha(0),
40 fCx(0),
41 fCchi2(1e10),
42 fIalpha(0),
43 fIx(0),
44 fOalpha(0),
45 fOx(0),
46 fITSchi2(0),
47 fITSncls(0),
48 fITSsignal(0),
49 fTPCchi2(0),
50 fTPCncls(0),
51 fTPCClusterMap(159),//number of padrows
52 fTPCsignal(0),
53 fTRDchi2(0),
54 fTRDncls(0),
55 fTRDsignal(0),
56 fTOFchi2(0),
57 fTOFindex(0),
58 fTOFsignal(-1)
59 {
60   //
61   // The default ESD constructor 
62   //
63   for (Int_t i=0; i<kSPECIES; i++) {
64     fTrackTime[i]=0;
65     fR[i]=0;
66     fITSr[i]=0;
67     fTPCr[i]=0;
68     fTRDr[i]=0;
69     fTOFr[i]=0;
70   }
71   Int_t i;
72   for (i=0; i<5; i++)  { fRp[i]=0.; fCp[i]=0.; fIp[i]=0.; fOp[i]=0.;}
73   for (i=0; i<15; i++) { fRc[i]=0.; fCc[i]=0.; fIc[i]=0.; fOc[i]=0.;   }
74   for (i=0; i<6; i++)  { fITSindex[i]=0; }
75   for (i=0; i<180; i++){ fTPCindex[i]=0; }
76   for (i=0; i<90; i++) { fTRDindex[i]=0; }
77 }
78
79 //_______________________________________________________________________
80 Float_t AliESDtrack::GetMass() const {
81   // Returns the mass of the most probable particle type
82   Float_t max=0.;
83   Int_t k=-1;
84   for (Int_t i=0; i<kSPECIES; i++) {
85     if (fR[i]>max) {k=i; max=fR[i];}
86   }
87   if (k==0) return 0.00051;
88   if (k==1) return 0.10566;
89   if (k==2||k==-1) return 0.13957;
90   if (k==3) return 0.49368;
91   if (k==4) return 0.93827;
92   Warning("GetMass()","Undefined mass !");
93   return 0.13957;
94 }
95
96 //_______________________________________________________________________
97 Bool_t AliESDtrack::UpdateTrackParams(AliKalmanTrack *t, ULong_t flags) {
98   //
99   // This function updates track's running parameters 
100   //
101   SetStatus(flags);
102   fLabel=t->GetLabel();
103
104   if (t->IsStartedTimeIntegral()) {
105     SetStatus(kTIME);
106     Double_t times[10];t->GetIntegratedTimes(times); SetIntegratedTimes(times);
107     SetIntegratedLength(t->GetIntegratedLength());
108   }
109
110   fRalpha=t->GetAlpha();
111   t->GetExternalParameters(fRx,fRp);
112   t->GetExternalCovariance(fRc);
113
114   switch (flags) {
115     
116   case kITSin: case kITSout: case kITSrefit:
117     fITSncls=t->GetNumberOfClusters();
118     fITSchi2=t->GetChi2();
119     for (Int_t i=0;i<fITSncls;i++) fITSindex[i]=t->GetClusterIndex(i);
120     fITSsignal=t->GetPIDsignal();
121     break;
122     
123   case kTPCin: case kTPCrefit:
124     fIalpha=fRalpha;
125     fIx=fRx;
126     {
127       Int_t i;
128       for (i=0; i<5; i++) fIp[i]=fRp[i];
129       for (i=0; i<15;i++) fIc[i]=fRc[i];
130     }
131   case kTPCout:
132   
133     fTPCncls=t->GetNumberOfClusters();
134     fTPCchi2=t->GetChi2();
135     
136      {//prevrow must be declared in separate namespace, otherwise compiler cries:
137       //"jump to case label crosses initialization of `Int_t prevrow'"
138        Int_t prevrow = -1;
139        for (Int_t i=0;i<fTPCncls;i++) 
140         {
141           fTPCindex[i]=t->GetClusterIndex(i);
142
143           // Piotr's Cluster Map for HBT  
144           // ### please change accordingly if cluster array is changing 
145           // to "New TPC Tracking" style (with gaps in array) 
146           Int_t idx = fTPCindex[i];
147           Int_t sect = (idx&0xff000000)>>24;
148           Int_t row = (idx&0x00ff0000)>>16;
149           if (sect > 18) row +=63; //if it is outer sector, add number of inner sectors
150
151           fTPCClusterMap.SetBitNumber(row,kTRUE);
152
153           //Fill the gap between previous row and this row with 0 bits
154           //In case  ###  pleas change it as well - just set bit 0 in case there 
155           //is no associated clusters for current "i"
156           if (prevrow < 0) 
157            {
158              prevrow = row;//if previous bit was not assigned yet == this is the first one
159            }
160           else
161            { //we don't know the order (inner to outer or reverse)
162              //just to be save in case it is going to change
163              Int_t n = 0, m = 0;
164              if (prevrow < row)
165               {
166                 n = prevrow;
167                 m = row;
168               }
169              else
170               {
171                 n = row;
172                 m = prevrow;
173               }
174
175              for (Int_t j = n+1; j < m; j++)
176               {
177                 fTPCClusterMap.SetBitNumber(j,kFALSE);
178               }
179              prevrow = row; 
180            }
181           // End Of Piotr's Cluster Map for HBT
182         }
183      }
184     fTPCsignal=t->GetPIDsignal();
185     {Double_t mass=t->GetMass();    // preliminary mass setting 
186     if (mass>0.5) fR[4]=1.;         //        used by
187     else if (mass<0.4) fR[2]=1.;    // the ITS reconstruction
188     else fR[3]=1.;}
189                      //
190     break;
191
192   case kTRDout:
193     { //requested by the PHOS  ("temporary solution")
194       Double_t r=474.;
195       t->PropagateTo(r,30.,0.);  
196       fOalpha=fRalpha;
197       fOx=fRx;
198       Int_t i;
199       for (i=0; i<5; i++) fOp[i]=fRp[i];
200       for (i=0; i<15;i++) fOc[i]=fRc[i];
201     }
202   case kTRDin: case kTRDrefit:
203     fTRDncls=t->GetNumberOfClusters();
204     fTRDchi2=t->GetChi2();
205     for (Int_t i=0;i<fTRDncls;i++) fTRDindex[i]=t->GetClusterIndex(i);
206     fTRDsignal=t->GetPIDsignal();
207     break;
208
209   default: 
210     Error("UpdateTrackParams()","Wrong flag !\n");
211     return kFALSE;
212   }
213
214   return kTRUE;
215 }
216
217 //_______________________________________________________________________
218 void 
219 AliESDtrack::SetConstrainedTrackParams(AliKalmanTrack *t, Double_t chi2) {
220   //
221   // This function sets the constrained track parameters 
222   //
223   fCalpha=t->GetAlpha();
224   t->GetExternalParameters(fCx,fCp);
225   t->GetExternalCovariance(fCc);
226   fCchi2=chi2;
227 }
228
229
230 //_______________________________________________________________________
231 void AliESDtrack::GetExternalParameters(Double_t &x, Double_t p[5]) const {
232   //---------------------------------------------------------------------
233   // This function returns external representation of the track parameters
234   //---------------------------------------------------------------------
235   x=fRx;
236   for (Int_t i=0; i<5; i++) p[i]=fRp[i];
237 }
238 //_______________________________________________________________________
239 void AliESDtrack::GetExternalCovariance(Double_t cov[15]) const {
240   //---------------------------------------------------------------------
241   // This function returns external representation of the cov. matrix
242   //---------------------------------------------------------------------
243   for (Int_t i=0; i<15; i++) cov[i]=fRc[i];
244 }
245
246
247 //_______________________________________________________________________
248 void 
249 AliESDtrack::GetConstrainedExternalParameters(Double_t &x, Double_t p[5])const{
250   //---------------------------------------------------------------------
251   // This function returns the constrained external track parameters
252   //---------------------------------------------------------------------
253   x=fCx;
254   for (Int_t i=0; i<5; i++) p[i]=fCp[i];
255 }
256 //_______________________________________________________________________
257 void 
258 AliESDtrack::GetConstrainedExternalCovariance(Double_t c[15]) const {
259   //---------------------------------------------------------------------
260   // This function returns the constrained external cov. matrix
261   //---------------------------------------------------------------------
262   for (Int_t i=0; i<15; i++) c[i]=fCc[i];
263 }
264
265
266 Double_t AliESDtrack::GetP() const {
267   //---------------------------------------------------------------------
268   // This function returns the track momentum
269   //---------------------------------------------------------------------
270   Double_t lam=TMath::ATan(fRp[3]);
271   Double_t pt=1./TMath::Abs(fRp[4]);
272   return pt/TMath::Cos(lam);
273 }
274
275 void AliESDtrack::GetConstrainedPxPyPz(Double_t *p) const {
276   //---------------------------------------------------------------------
277   // This function returns the constrained global track momentum components
278   //---------------------------------------------------------------------
279   Double_t phi=TMath::ASin(fCp[2]) + fCalpha;
280   Double_t pt=1./TMath::Abs(fCp[4]);
281   p[0]=pt*TMath::Cos(phi); p[1]=pt*TMath::Sin(phi); p[2]=pt*fCp[3]; 
282 }
283 void AliESDtrack::GetConstrainedXYZ(Double_t *xyz) const {
284   //---------------------------------------------------------------------
285   // This function returns the global track position
286   //---------------------------------------------------------------------
287   Double_t phi=TMath::ATan2(fCp[0],fCx) + fCalpha;
288   Double_t r=TMath::Sqrt(fCx*fCx + fCp[0]*fCp[0]);
289   xyz[0]=r*TMath::Cos(phi); xyz[1]=r*TMath::Sin(phi); xyz[2]=fCp[1]; 
290 }
291
292 void AliESDtrack::GetPxPyPz(Double_t *p) const {
293   //---------------------------------------------------------------------
294   // This function returns the global track momentum components
295   //---------------------------------------------------------------------
296   Double_t phi=TMath::ASin(fRp[2]) + fRalpha;
297   Double_t pt=1./TMath::Abs(fRp[4]);
298   p[0]=pt*TMath::Cos(phi); p[1]=pt*TMath::Sin(phi); p[2]=pt*fRp[3]; 
299 }
300 void AliESDtrack::GetXYZ(Double_t *xyz) const {
301   //---------------------------------------------------------------------
302   // This function returns the global track position
303   //---------------------------------------------------------------------
304   Double_t phi=TMath::ATan2(fRp[0],fRx) + fRalpha;
305   Double_t r=TMath::Sqrt(fRx*fRx + fRp[0]*fRp[0]);
306   xyz[0]=r*TMath::Cos(phi); xyz[1]=r*TMath::Sin(phi); xyz[2]=fRp[1]; 
307 }
308
309
310 void AliESDtrack::GetInnerPxPyPz(Double_t *p) const {
311   //---------------------------------------------------------------------
312   // This function returns the global track momentum components
313   // af the entrance of the TPC
314   //---------------------------------------------------------------------
315   Double_t phi=TMath::ASin(fIp[2]) + fIalpha;
316   Double_t pt=1./TMath::Abs(fIp[4]);
317   p[0]=pt*TMath::Cos(phi); p[1]=pt*TMath::Sin(phi); p[2]=pt*fIp[3]; 
318 }
319
320 void AliESDtrack::GetInnerXYZ(Double_t *xyz) const {
321   //---------------------------------------------------------------------
322   // This function returns the global track position
323   // af the entrance of the TPC
324   //---------------------------------------------------------------------
325   Double_t phi=TMath::ATan2(fIp[0],fIx) + fIalpha;
326   Double_t r=TMath::Sqrt(fIx*fIx + fIp[0]*fIp[0]);
327   xyz[0]=r*TMath::Cos(phi); xyz[1]=r*TMath::Sin(phi); xyz[2]=fIp[1]; 
328 }
329
330 void AliESDtrack::GetInnerExternalParameters(Double_t &x, Double_t p[5]) const 
331 {
332   //skowron
333  //---------------------------------------------------------------------
334   // This function returns external representation of the track parameters at Inner Layer of TPC
335   //---------------------------------------------------------------------
336   x=fIx;
337   for (Int_t i=0; i<5; i++) p[i]=fIp[i];
338 }
339 void AliESDtrack::GetInnerExternalCovariance(Double_t cov[15]) const
340 {
341  //skowron
342  //---------------------------------------------------------------------
343  // This function returns external representation of the cov. matrix at Inner Layer of TPC
344  //---------------------------------------------------------------------
345  for (Int_t i=0; i<15; i++) cov[i]=fIc[i];
346  
347 }
348
349 void AliESDtrack::GetOuterPxPyPz(Double_t *p) const {
350   //---------------------------------------------------------------------
351   // This function returns the global track momentum components
352   // af the radius of the PHOS
353   //---------------------------------------------------------------------
354   Double_t phi=TMath::ASin(fOp[2]) + fOalpha;
355   Double_t pt=1./TMath::Abs(fOp[4]);
356   p[0]=pt*TMath::Cos(phi); p[1]=pt*TMath::Sin(phi); p[2]=pt*fOp[3]; 
357 }
358
359 void AliESDtrack::GetOuterXYZ(Double_t *xyz) const {
360   //---------------------------------------------------------------------
361   // This function returns the global track position
362   // af the radius of the PHOS
363   //---------------------------------------------------------------------
364   Double_t phi=TMath::ATan2(fOp[0],fOx) + fOalpha;
365   Double_t r=TMath::Sqrt(fOx*fOx + fOp[0]*fOp[0]);
366   xyz[0]=r*TMath::Cos(phi); xyz[1]=r*TMath::Sin(phi); xyz[2]=fOp[1]; 
367 }
368
369 //_______________________________________________________________________
370 void AliESDtrack::GetIntegratedTimes(Double_t *times) const {
371   // Returns the array with integrated times for each particle hypothesis
372   for (Int_t i=0; i<kSPECIES; i++) times[i]=fTrackTime[i];
373 }
374
375 //_______________________________________________________________________
376 void AliESDtrack::SetIntegratedTimes(const Double_t *times) {
377   // Sets the array with integrated times for each particle hypotesis
378   for (Int_t i=0; i<kSPECIES; i++) fTrackTime[i]=times[i];
379 }
380
381 //_______________________________________________________________________
382 void AliESDtrack::SetITSpid(const Double_t *p) {
383   // Sets values for the probability of each particle type (in ITS)
384   for (Int_t i=0; i<kSPECIES; i++) fITSr[i]=p[i];
385   SetStatus(AliESDtrack::kITSpid);
386 }
387
388 //_______________________________________________________________________
389 void AliESDtrack::GetITSpid(Double_t *p) const {
390   // Gets the probability of each particle type (in ITS)
391   for (Int_t i=0; i<kSPECIES; i++) p[i]=fITSr[i];
392 }
393
394 //_______________________________________________________________________
395 Int_t AliESDtrack::GetITSclusters(UInt_t *idx) const {
396   //---------------------------------------------------------------------
397   // This function returns indices of the assgined ITS clusters 
398   //---------------------------------------------------------------------
399   for (Int_t i=0; i<fITSncls; i++) idx[i]=fITSindex[i];
400   return fITSncls;
401 }
402
403 //_______________________________________________________________________
404 Int_t AliESDtrack::GetTPCclusters(Int_t *idx) const {
405   //---------------------------------------------------------------------
406   // This function returns indices of the assgined ITS clusters 
407   //---------------------------------------------------------------------
408   for (Int_t i=0; i<180; i++) idx[i]=fTPCindex[i];  // MI I prefer some constant
409   return fTPCncls;
410 }
411
412 //_______________________________________________________________________
413 void AliESDtrack::SetTPCpid(const Double_t *p) {  
414   // Sets values for the probability of each particle type (in TPC)
415   for (Int_t i=0; i<kSPECIES; i++) fTPCr[i]=p[i];
416   SetStatus(AliESDtrack::kTPCpid);
417 }
418
419 //_______________________________________________________________________
420 void AliESDtrack::GetTPCpid(Double_t *p) const {
421   // Gets the probability of each particle type (in TPC)
422   for (Int_t i=0; i<kSPECIES; i++) p[i]=fTPCr[i];
423 }
424
425 //_______________________________________________________________________
426 Int_t AliESDtrack::GetTRDclusters(UInt_t *idx) const {
427   //---------------------------------------------------------------------
428   // This function returns indices of the assgined TRD clusters 
429   //---------------------------------------------------------------------
430   for (Int_t i=0; i<90; i++) idx[i]=fTRDindex[i];  // MI I prefer some constant
431   return fTRDncls;
432 }
433
434 //_______________________________________________________________________
435 void AliESDtrack::SetTRDpid(const Double_t *p) {  
436   // Sets values for the probability of each particle type (in TRD)
437   for (Int_t i=0; i<kSPECIES; i++) fTRDr[i]=p[i];
438   SetStatus(AliESDtrack::kTRDpid);
439 }
440
441 //_______________________________________________________________________
442 void AliESDtrack::GetTRDpid(Double_t *p) const {
443   // Gets the probability of each particle type (in TRD)
444   for (Int_t i=0; i<kSPECIES; i++) p[i]=fTRDr[i];
445 }
446
447 //_______________________________________________________________________
448 void    AliESDtrack::SetTRDpid(Int_t iSpecies, Float_t p)
449 {
450   // Sets the probability of particle type iSpecies to p (in TRD)
451   fTRDr[iSpecies] = p;
452 }
453
454 Float_t AliESDtrack::GetTRDpid(Int_t iSpecies) const
455 {
456   // Returns the probability of particle type iSpecies (in TRD)
457   return fTRDr[iSpecies];
458 }
459
460 //_______________________________________________________________________
461 void AliESDtrack::SetTOFpid(const Double_t *p) {  
462   // Sets the probability of each particle type (in TOF)
463   for (Int_t i=0; i<kSPECIES; i++) fTOFr[i]=p[i];
464   SetStatus(AliESDtrack::kTOFpid);
465 }
466
467 //_______________________________________________________________________
468 void AliESDtrack::GetTOFpid(Double_t *p) const {
469   // Gets probabilities of each particle type (in TOF)
470   for (Int_t i=0; i<kSPECIES; i++) p[i]=fTOFr[i];
471 }
472
473 //_______________________________________________________________________
474 void AliESDtrack::SetESDpid(const Double_t *p) {  
475   // Sets the probability of each particle type for the ESD track
476   for (Int_t i=0; i<kSPECIES; i++) fR[i]=p[i];
477   SetStatus(AliESDtrack::kESDpid);
478 }
479
480 //_______________________________________________________________________
481 void AliESDtrack::GetESDpid(Double_t *p) const {
482   // Gets probability of each particle type for the ESD track
483   for (Int_t i=0; i<kSPECIES; i++) p[i]=fR[i];
484 }
485