]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TOF/AliTOFtrack.cxx
Fix for #83391 printings from AliTPCQADataMakerSim polluting sim.log
[u/mrichter/AliRoot.git] / TOF / AliTOFtrack.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 /* $Id$ */
17
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 /////////////////////////////////////////////////////////////////////////////
27
28 #include "AliESDtrack.h" 
29 #include "AliTracker.h" 
30
31 #include "AliTOFGeometry.h"
32 #include "AliTOFtrack.h" 
33
34 ClassImp(AliTOFtrack)
35
36 //_____________________________________________________________________________
37 AliTOFtrack::AliTOFtrack() : 
38   AliKalmanTrack(),
39   fSeedInd(-1),
40   fSeedLab(-1)
41 {
42   //
43   // Default constructor.
44   //
45 }                                
46
47 //_____________________________________________________________________________
48 AliTOFtrack::AliTOFtrack(const AliTOFtrack& t) : 
49   AliKalmanTrack(t),
50   fSeedInd(t.fSeedInd),
51   fSeedLab(t.fSeedLab) 
52 {
53   //
54   // Copy constructor.
55   //
56 }                                
57
58 //_____________________________________________________________________________
59 AliTOFtrack::AliTOFtrack(const AliESDtrack& t) :
60   AliKalmanTrack(), 
61   fSeedInd(-1),
62   fSeedLab(-1) 
63 {
64   //
65   // Constructor from AliESDtrack
66   //
67   SetLabel(t.GetLabel());
68   SetChi2(0.);
69   SetMass(t.GetMass());
70
71   Set(t.GetX(),t.GetAlpha(),t.GetParameter(),t.GetCovariance());
72
73   if ((t.GetStatus()&AliESDtrack::kTIME) == 0) return;
74   StartTimeIntegral();
75   Double_t times[10]; t.GetIntegratedTimes(times); SetIntegratedTimes(times);
76   SetIntegratedLength(t.GetIntegratedLength());
77
78 }              
79
80 //____________________________________________________________________________
81 AliTOFtrack& AliTOFtrack::operator=(const AliTOFtrack &/*source*/)
82 {
83   // ass. op.
84
85   return *this;
86
87 }
88
89 //_____________________________________________________________________________
90 Bool_t AliTOFtrack::PropagateTo(Double_t xk,Double_t /*x0*/,Double_t /*rho*/)
91  {
92   //
93   // Propagates a track of particle with mass=pm to a reference plane 
94   // defined by x=xk through media of density=rho and radiationLength=x0
95   //
96
97   if (xk == GetX()) return kTRUE;
98   
99   Double_t oldX=GetX();//, oldY=GetY(), oldZ=GetZ();
100   Double_t start[3], end[3], mparam[7];
101
102   /* get start position */
103   GetXYZ(start);
104
105   /* propagate the track */
106   Double_t b[3];GetBxByBz(b);
107   if (!AliExternalTrackParam::PropagateToBxByBz(xk,b)) return kFALSE;
108   // OLD used code
109   //Double_t bz=GetBz();
110   //if (!AliExternalTrackParam::PropagateTo(xk,bz)) return kFALSE;
111
112   /* get end position */
113   GetXYZ(end);
114
115   /* add time step to integral */
116 #if 0 /*** OLD ***/
117   Double_t d = TMath::Sqrt((GetX()-oldX)*(GetX()-oldX) + 
118                            (GetY()-oldY)*(GetY()-oldY) + 
119                            (GetZ()-oldZ)*(GetZ()-oldZ));
120   if (IsStartedTimeIntegral() && GetX()>oldX) AddTimeStep(d);
121 #endif
122   Double_t d = TMath::Sqrt((end[0]-start[0])*(end[0]-start[0]) + 
123                            (end[1]-start[1])*(end[1]-start[1]) + 
124                            (end[2]-start[2])*(end[2]-start[2]));
125   if (IsStartedTimeIntegral() && GetX()>oldX) AddTimeStep(d);
126
127   /* get material budget from tracker */
128   AliTracker::MeanMaterialBudget(start, end, mparam);
129   Double_t xTimesRho = mparam[4]*mparam[0];
130   Double_t xOverX0   = mparam[1];
131
132   if (oldX < xk) {
133           xTimesRho = -xTimesRho;  // should be negative in case of outward propagation (--> energy decreases)
134   }
135
136   /* correct for mean material */
137   if (!AliExternalTrackParam::CorrectForMeanMaterial(xOverX0,xTimesRho,GetMass())) return kFALSE;
138
139
140 #if 0 /*** OLD ***/
141   if (!AliExternalTrackParam::CorrectForMaterial(d*rho/x0,x0,GetMass())) 
142      return kFALSE;
143 #endif
144
145   /*
146   //Energy losses************************
147   if((5940*beta2/(1-beta2+1e-10) - beta2) < 0){return 0;}
148
149   Double_t dE=0.153e-3/beta2*(log(5940*beta2/(1-beta2+1e-10)) - beta2)*d*rho;
150   //
151   // suspicious part - think about it ?
152   Double_t kinE =  TMath::Sqrt(p2);
153   if (dE>0.8*kinE) dE = 0.8*kinE;  //      
154   if (dE<0)        dE = 0.0;       // not valid region for Bethe bloch 
155   */
156
157   return kTRUE;            
158 }     
159
160 //_____________________________________________________________________________
161 Bool_t AliTOFtrack::PropagateToInnerTOF()
162 {
163   // Propagates a track of particle with mass=pm to a reference plane 
164   // defined by x=xk through media of density=rho and radiationLength=x0
165
166
167   Double_t ymax=AliTOFGeometry::RinTOF()*TMath::Tan(0.5*AliTOFGeometry::GetAlpha());
168   Bool_t skip = kFALSE;
169   Double_t y=GetYat(AliTOFGeometry::RinTOF(),skip);
170   if (skip) {
171     return kFALSE;
172   }
173   if (y > ymax) {
174     if (!Rotate(AliTOFGeometry::GetAlpha())) {
175       return kFALSE;
176     }
177   } else if (y <-ymax) {
178     if (!Rotate(-AliTOFGeometry::GetAlpha())) {
179       return kFALSE;
180     }
181   }
182   
183   Double_t x = GetX();
184   Int_t nsteps=Int_t((AliTOFGeometry::Rmin()-x)/0.5); // 0.5 cm Steps
185   for (Int_t istep=0;istep<nsteps;istep++){
186     Float_t xp = x+istep*0.5; 
187     //    GetPropagationParameters(param);  
188     PropagateTo(xp,0.,0.); /* passing 0.,0. as arguments since now
189                               this method queries TGeo for material budget
190                            */
191     
192   }
193   
194   if(!PropagateTo(AliTOFGeometry::RinTOF()))return 0;
195   
196   return kTRUE;
197   
198 }     
199
200 //_________________________________________________________________________
201 Double_t AliTOFtrack::GetPredictedChi2(const AliCluster3D *c) const {
202   //
203   // Estimate the chi2 of the space point "c" with its cov. matrix elements
204   //
205
206   Double_t p[3]={c->GetX(), c->GetY(), c->GetZ()};
207   Double_t covyz[3]={c->GetSigmaY2(), c->GetSigmaYZ(), c->GetSigmaZ2()};
208   Double_t covxyz[3]={c->GetSigmaX2(), c->GetSigmaXY(), c->GetSigmaXZ()};
209   return AliExternalTrackParam::GetPredictedChi2(p, covyz, covxyz);
210 }
211 //_________________________________________________________________________
212 Bool_t AliTOFtrack::PropagateTo(const AliCluster3D *c) {
213   //
214   // Propagates a track to the plane containing cluster 'c'
215   //
216   Double_t oldX=GetX(), oldY=GetY(), oldZ=GetZ();
217   Double_t p[3]={c->GetX(), c->GetY(), c->GetZ()};
218   Double_t covyz[3]={c->GetSigmaY2(), c->GetSigmaYZ(), c->GetSigmaZ2()};
219   Double_t covxyz[3]={c->GetSigmaX2(), c->GetSigmaXY(), c->GetSigmaXZ()};
220   Double_t bz=GetBz();
221   if (!AliExternalTrackParam::PropagateTo(p, covyz, covxyz, bz)) return kFALSE;
222   if (IsStartedTimeIntegral()) {
223     Double_t d = TMath::Sqrt((GetX()-oldX)*(GetX()-oldX) +
224                              (GetY()-oldY)*(GetY()-oldY) +
225                              (GetZ()-oldZ)*(GetZ()-oldZ));
226     if (GetX()<oldX) d=-d;
227     AddTimeStep(d);
228   }
229   return kTRUE;
230 }
231 //_________________________________________________________________________
232 Double_t AliTOFtrack::GetYat(Double_t xk, Bool_t & skip) const {     
233 //-----------------------------------------------------------------
234 // This function calculates the Y-coordinate of a track at the plane x=xk.
235 // Needed for matching with the TOF (I.Belikov)
236 //-----------------------------------------------------------------
237      Double_t y=0.;
238      skip=(!GetYAt(xk,GetBz(),y));
239      return y;
240 }
241
242 //_____________________________________________________________________________
243 Int_t AliTOFtrack::Compare(const TObject *o) const {
244   //-----------------------------------------------------------------
245   // This function compares tracks according to the their curvature
246   //-----------------------------------------------------------------
247   AliTOFtrack *t=(AliTOFtrack*)o;
248   Double_t co=t->GetSigmaY2()*t->GetSigmaZ2();
249   Double_t c =GetSigmaY2()*GetSigmaZ2();
250   if (c>co) return 1;
251   else if (c<co) return -1;
252   return 0;
253 }
254
255
256 //_____________________________________________________________________________
257 void AliTOFtrack::GetPropagationParameters(Double_t *param) {
258
259  //Get average medium density, x0 while propagating the track
260
261   //For TRD holes description
262   /*
263   Double_t thetamin = (90.-31.1) * TMath::Pi()/180.;
264   Double_t thetamax = (90.+31.1) * TMath::Pi()/180.;
265
266   Double_t zmin = -55.;
267   Double_t zmax =  55.;
268   */
269
270   // Detector inner/outer radii
271   Double_t rTPC    = 261.53;
272   Double_t rTPCTRD = 294.5;
273   Double_t rTRD    = 369.1;
274
275   // Medium parameters
276   Double_t x0TPC = 40.;
277   Double_t rhoTPC =0.06124;
278
279   Double_t x0Air = 36.66;
280   Double_t rhoAir =1.2931e-3;
281
282   Double_t x0TRD = 171.7;
283   Double_t rhoTRD =0.33;
284
285   //  Int_t isec = GetSector();
286   Double_t r[3]; GetXYZ(r);
287   //  Float_t thetatr = TMath::ATan2(TMath::Sqrt(r[0]*r[0]+r[1]*r[1]),r[2]);
288
289   /*
290   if(holes){
291     if (isec == 0 || isec == 1 || isec == 2 ) {
292       if( thetatr>=thetamin && thetatr<=thetamax){ 
293         x0TRD= x0Air;
294         rhoTRD = rhoAir;
295       }
296     }
297     if (isec == 11 || isec == 12 || isec == 13 || isec == 14 || isec == 15 ) {
298       if( r[2]>=zmin && r[2]<=zmax){ 
299         x0TRD= x0Air;
300         rhoTRD = rhoAir;
301       }
302     }
303   }
304   */
305   if(GetX() <= rTPC)
306     {param[0]=x0TPC;param[1]=rhoTPC;}
307   else if(GetX() > rTPC &&  GetX() < rTPCTRD)
308     {param[0]=x0Air;param[1]=rhoAir;}
309   else if(GetX() >= rTPCTRD &&  GetX() < rTRD)
310     {param[0]=x0TRD;param[1]=rhoTRD;}
311   else if(GetX() >= rTRD )
312     {param[0]=x0Air;param[1]=rhoAir;}
313 }