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 **************************************************************************/
18 //-------------------------------------------------------------------------
19 // Implementation of the AliKalmanTrack class
20 // that is the base for AliTPCtrack, AliITStrackV2 and AliTRDtrack
21 // Origin: Iouri Belikov, CERN, Jouri.Belikov@cern.ch
22 //-------------------------------------------------------------------------
23 #include <TGeoManager.h>
25 #include "AliKalmanTrack.h"
27 ClassImp(AliKalmanTrack)
29 //_______________________________________________________________________
30 AliKalmanTrack::AliKalmanTrack():AliExternalTrackParam(),
34 fMass(AliPID::ParticleMass(AliPID::kPion)),
36 fStartTimeIntegral(kFALSE),
40 // Default constructor
43 for(Int_t i=0; i<AliPID::kSPECIES; i++) fIntegratedTime[i] = 0;
46 //_______________________________________________________________________
47 AliKalmanTrack::AliKalmanTrack(const AliKalmanTrack &t):
48 AliExternalTrackParam(t),
50 fFakeRatio(t.fFakeRatio),
54 fStartTimeIntegral(t.fStartTimeIntegral),
55 fIntegratedLength(t.fIntegratedLength)
61 for (Int_t i=0; i<AliPID::kSPECIES; i++)
62 fIntegratedTime[i] = t.fIntegratedTime[i];
65 //_______________________________________________________________________
66 void AliKalmanTrack::StartTimeIntegral()
68 // Sylwester Radomski, GSI
71 // Start time integration
72 // To be called at Vertex by ITS tracker
75 //if (fStartTimeIntegral)
76 // AliWarning("Reseting Recorded Time.");
78 fStartTimeIntegral = kTRUE;
79 for(Int_t i=0; i<AliPID::kSPECIES; i++) fIntegratedTime[i] = 0;
80 fIntegratedLength = 0;
83 //_______________________________________________________________________
84 void AliKalmanTrack:: AddTimeStep(Double_t length)
87 // Add step to integrated time
88 // this method should be called by a sublasses at the end
89 // of the PropagateTo function or by a tracker
90 // each time step is made.
92 // If integration not started function does nothing
95 // dt = dl * sqrt(p^2 + m^2) / p
96 // p = pT * (1 + tg^2 (lambda) )
98 // pt = 1/external parameter [4]
99 // tg lambda = external parameter [3]
102 // Sylwester Radomski, GSI
106 static const Double_t kcc = 2.99792458e-2;
108 if (!fStartTimeIntegral) return;
110 fIntegratedLength += length;
112 Double_t xr, param[5];
115 GetExternalParameters(xr, param);
119 Double_t p = TMath::Abs(pt * TMath::Sqrt(1+tgl*tgl));
121 if (length > 100) return;
123 for (Int_t i=0; i<AliPID::kSPECIES; i++) {
125 Double_t mass = AliPID::ParticleMass(i);
126 Double_t correction = TMath::Sqrt( pt*pt * (1 + tgl*tgl) + mass * mass ) / p;
127 Double_t time = length * correction / kcc;
129 fIntegratedTime[i] += time;
133 //_______________________________________________________________________
134 Double_t AliKalmanTrack::GetIntegratedTime(Int_t pdg) const
136 // Sylwester Radomski, GSI
139 // Return integrated time hypothesis for a given particle
143 // pdg - Pdg code of a particle type
147 if (!fStartTimeIntegral) {
148 AliWarning("Time integration not started");
152 for (Int_t i=0; i<AliPID::kSPECIES; i++)
153 if (AliPID::ParticleCode(i) == TMath::Abs(pdg)) return fIntegratedTime[i];
155 AliWarning(Form("Particle type [%d] not found", pdg));
159 void AliKalmanTrack::GetIntegratedTimes(Double_t *times) const {
160 for (Int_t i=0; i<AliPID::kSPECIES; i++) times[i]=fIntegratedTime[i];
163 void AliKalmanTrack::SetIntegratedTimes(const Double_t *times) {
164 for (Int_t i=0; i<AliPID::kSPECIES; i++) fIntegratedTime[i]=times[i];
167 Double_t AliKalmanTrack::MeanMaterialBudget(Double_t *start, Double_t *end, Double_t *mparam)
170 // calculate mean material budget and material properties beween point start and end
171 // mparam - returns parameters used for dEdx and multiple scatering
173 // mparam[0] - density mean
174 // mparam[1] - rad length
175 // mparam[2] - A mean
176 // mparam[3] - Z mean
177 // mparam[4] - length
178 // mparam[5] - Z/A mean
179 // mparam[6] - number of boundary crosses
181 mparam[0]=0; mparam[1]=1; mparam[2] =0; mparam[3] =0, mparam[4]=0, mparam[5]=0; mparam[6]=0;
183 Double_t bparam[6], lparam[6]; // bparam - total param - lparam - local parameters
184 for (Int_t i=0;i<6;i++) bparam[i]=0; //
187 printf("ERROR: no TGeo\n");
193 length = TMath::Sqrt((end[0]-start[0])*(end[0]-start[0])+
194 (end[1]-start[1])*(end[1]-start[1])+
195 (end[2]-start[2])*(end[2]-start[2]));
197 if (length<TGeoShape::Tolerance()) return 0.0;
198 Double_t invlen = 1./length;
199 dir[0] = (end[0]-start[0])*invlen;
200 dir[1] = (end[1]-start[1])*invlen;
201 dir[2] = (end[2]-start[2])*invlen;
202 // Initialize start point and direction
203 TGeoNode *currentnode = 0;
204 TGeoNode *startnode = gGeoManager->InitTrack(start, dir);
205 // printf("%s length=%f\n",gGeoManager->GetPath(),length);
207 printf("ERROR: start point out of geometry\n");
210 TGeoMaterial *material = startnode->GetVolume()->GetMedium()->GetMaterial();
211 lparam[0] = material->GetDensity();
212 lparam[1] = material->GetRadLen();
213 lparam[2] = material->GetA();
214 lparam[3] = material->GetZ();
216 lparam[5] = lparam[3]/lparam[2];
217 if (material->IsMixture()) {
218 lparam[1]*=lparam[0]; // different normalization in the modeler for mixture
219 TGeoMixture * mixture = (TGeoMixture*)material;
222 for (Int_t iel=0;iel<mixture->GetNelements();iel++){
223 sum += mixture->GetWmixt()[iel];
224 lparam[5]+= mixture->GetZmixt()[iel]*mixture->GetWmixt()[iel]/mixture->GetAmixt()[iel];
228 gGeoManager->FindNextBoundary(length);
229 Double_t snext = gGeoManager->GetStep();
231 // If no boundary within proposed length, return current density
233 for (Int_t ip=0;ip<5;ip++) mparam[ip] = lparam[ip];
236 // Try to cross the boundary and see what is next
237 while (length>TGeoShape::Tolerance()) {
239 currentnode = gGeoManager->Step();
241 bparam[1] += snext*lparam[1];
242 bparam[2] += snext*lparam[2];
243 bparam[3] += snext*lparam[3];
244 bparam[5] += snext*lparam[5];
245 bparam[0] += snext*lparam[0];
247 if (snext>=length) break;
248 if (!currentnode) break;
249 // printf("%s snext=%f density=%f bparam[0]=%f\n", gGeoManager->GetPath(),snext,density,bparam[0]);
250 if (!gGeoManager->IsEntering()) {
251 gGeoManager->SetStep(1.E-3);
252 currentnode = gGeoManager->Step();
253 if (!gGeoManager->IsEntering() || !currentnode) {
254 // printf("ERROR: cannot cross boundary\n");
255 mparam[0] = bparam[0]/step;
256 mparam[1] = bparam[1]/step;
257 mparam[2] = bparam[2]/step;
258 mparam[3] = bparam[3]/step;
259 mparam[5] = bparam[5]/step;
261 mparam[0] = 0.; // if crash of navigation take mean density 0
262 mparam[1] = 1000000; // and infinite rad length
263 return bparam[0]/step;
267 bparam[0] += lparam[0]*1.E-3;
268 bparam[1] += lparam[1]*1.E-3;
269 bparam[2] += lparam[2]*1.E-3;
270 bparam[3] += lparam[3]*1.E-3;
271 bparam[5] += lparam[5]*1.E-3;
274 material = currentnode->GetVolume()->GetMedium()->GetMaterial();
275 lparam[0] = material->GetDensity();
276 lparam[1] = material->GetRadLen();
277 lparam[2] = material->GetA();
278 lparam[3] = material->GetZ();
279 lparam[5] = lparam[3]/lparam[2];
280 if (material->IsMixture()) {
281 lparam[1]*=lparam[0];
282 TGeoMixture * mixture = (TGeoMixture*)material;
285 for (Int_t iel=0;iel<mixture->GetNelements();iel++){
286 sum+= mixture->GetWmixt()[iel];
287 lparam[5]+= mixture->GetZmixt()[iel]*mixture->GetWmixt()[iel]/mixture->GetAmixt()[iel];
291 gGeoManager->FindNextBoundary(length);
292 snext = gGeoManager->GetStep();
294 mparam[0] = bparam[0]/step;
295 mparam[1] = bparam[1]/step;
296 mparam[2] = bparam[2]/step;
297 mparam[3] = bparam[3]/step;
298 mparam[5] = bparam[5]/step;
299 return bparam[0]/step;