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>
24 #include "AliKalmanTrack.h"
26 ClassImp(AliKalmanTrack)
28 //_______________________________________________________________________
29 AliKalmanTrack::AliKalmanTrack():AliExternalTrackParam(),
33 fMass(AliPID::ParticleMass(AliPID::kPion)),
35 fStartTimeIntegral(kFALSE),
39 // Default constructor
42 for(Int_t i=0; i<AliPID::kSPECIES; i++) fIntegratedTime[i] = 0;
45 //_______________________________________________________________________
46 AliKalmanTrack::AliKalmanTrack(const AliKalmanTrack &t):
47 AliExternalTrackParam(t),
49 fFakeRatio(t.fFakeRatio),
53 fStartTimeIntegral(t.fStartTimeIntegral),
54 fIntegratedLength(t.fIntegratedLength)
60 for (Int_t i=0; i<AliPID::kSPECIES; i++)
61 fIntegratedTime[i] = t.fIntegratedTime[i];
64 //_______________________________________________________________________
65 void AliKalmanTrack::StartTimeIntegral()
67 // Sylwester Radomski, GSI
70 // Start time integration
71 // To be called at Vertex by ITS tracker
74 //if (fStartTimeIntegral)
75 // AliWarning("Reseting Recorded Time.");
77 fStartTimeIntegral = kTRUE;
78 for(Int_t i=0; i<AliPID::kSPECIES; i++) fIntegratedTime[i] = 0;
79 fIntegratedLength = 0;
82 //_______________________________________________________________________
83 void AliKalmanTrack:: AddTimeStep(Double_t length)
86 // Add step to integrated time
87 // this method should be called by a sublasses at the end
88 // of the PropagateTo function or by a tracker
89 // each time step is made.
91 // If integration not started function does nothing
94 // dt = dl * sqrt(p^2 + m^2) / p
95 // p = pT * (1 + tg^2 (lambda) )
97 // pt = 1/external parameter [4]
98 // tg lambda = external parameter [3]
101 // Sylwester Radomski, GSI
105 static const Double_t kcc = 2.99792458e-2;
107 if (!fStartTimeIntegral) return;
109 fIntegratedLength += length;
111 Double_t xr, param[5];
114 GetExternalParameters(xr, param);
118 Double_t p = TMath::Abs(pt * TMath::Sqrt(1+tgl*tgl));
120 if (length > 100) return;
122 for (Int_t i=0; i<AliPID::kSPECIES; i++) {
124 Double_t mass = AliPID::ParticleMass(i);
125 Double_t correction = TMath::Sqrt( pt*pt * (1 + tgl*tgl) + mass * mass ) / p;
126 Double_t time = length * correction / kcc;
128 fIntegratedTime[i] += time;
132 //_______________________________________________________________________
133 Double_t AliKalmanTrack::GetIntegratedTime(Int_t pdg) const
135 // Sylwester Radomski, GSI
138 // Return integrated time hypothesis for a given particle
142 // pdg - Pdg code of a particle type
146 if (!fStartTimeIntegral) {
147 AliWarning("Time integration not started");
151 for (Int_t i=0; i<AliPID::kSPECIES; i++)
152 if (AliPID::ParticleCode(i) == TMath::Abs(pdg)) return fIntegratedTime[i];
154 AliWarning(Form("Particle type [%d] not found", pdg));
158 void AliKalmanTrack::GetIntegratedTimes(Double_t *times) const {
159 for (Int_t i=0; i<AliPID::kSPECIES; i++) times[i]=fIntegratedTime[i];
162 void AliKalmanTrack::SetIntegratedTimes(const Double_t *times) {
163 for (Int_t i=0; i<AliPID::kSPECIES; i++) fIntegratedTime[i]=times[i];
166 Double_t AliKalmanTrack::MeanMaterialBudget(Double_t *start, Double_t *end, Double_t *mparam)
169 // calculate mean material budget and material properties beween point start and end
170 // mparam - returns parameters used for dEdx and multiple scatering
172 // mparam[0] - density mean
173 // mparam[1] - rad length
174 // mparam[2] - A mean
175 // mparam[3] - Z mean
176 // mparam[4] - length
177 // mparam[5] - Z/A mean
178 // mparam[6] - number of boundary crosses
180 mparam[0]=0; mparam[1]=1; mparam[2] =0; mparam[3] =0, mparam[4]=0, mparam[5]=0; mparam[6]=0;
182 Double_t bparam[6], lparam[6]; // bparam - total param - lparam - local parameters
183 for (Int_t i=0;i<6;i++) bparam[i]=0; //
186 printf("ERROR: no TGeo\n");
192 length = TMath::Sqrt((end[0]-start[0])*(end[0]-start[0])+
193 (end[1]-start[1])*(end[1]-start[1])+
194 (end[2]-start[2])*(end[2]-start[2]));
196 if (length<TGeoShape::Tolerance()) return 0.0;
197 Double_t invlen = 1./length;
198 dir[0] = (end[0]-start[0])*invlen;
199 dir[1] = (end[1]-start[1])*invlen;
200 dir[2] = (end[2]-start[2])*invlen;
201 // Initialize start point and direction
202 TGeoNode *currentnode = 0;
203 TGeoNode *startnode = gGeoManager->InitTrack(start, dir);
204 // printf("%s length=%f\n",gGeoManager->GetPath(),length);
206 printf("ERROR: start point out of geometry\n");
209 TGeoMaterial *material = startnode->GetVolume()->GetMedium()->GetMaterial();
210 lparam[0] = material->GetDensity();
211 lparam[1] = material->GetRadLen();
212 lparam[2] = material->GetA();
213 lparam[3] = material->GetZ();
215 lparam[5] = lparam[3]/lparam[2];
216 if (material->IsMixture()) {
217 lparam[1]*=lparam[0]; // different normalization in the modeler for mixture
218 TGeoMixture * mixture = (TGeoMixture*)material;
221 for (Int_t iel=0;iel<mixture->GetNelements();iel++){
222 sum += mixture->GetWmixt()[iel];
223 lparam[5]+= mixture->GetZmixt()[iel]*mixture->GetWmixt()[iel]/mixture->GetAmixt()[iel];
227 gGeoManager->FindNextBoundary(length);
228 Double_t snext = gGeoManager->GetStep();
230 // If no boundary within proposed length, return current density
232 for (Int_t ip=0;ip<5;ip++) mparam[ip] = lparam[ip];
235 // Try to cross the boundary and see what is next
236 while (length>TGeoShape::Tolerance()) {
238 currentnode = gGeoManager->Step();
240 bparam[1] += snext*lparam[1];
241 bparam[2] += snext*lparam[2];
242 bparam[3] += snext*lparam[3];
243 bparam[5] += snext*lparam[5];
244 bparam[0] += snext*lparam[0];
246 if (snext>=length) break;
247 if (!currentnode) break;
248 // printf("%s snext=%f density=%f bparam[0]=%f\n", gGeoManager->GetPath(),snext,density,bparam[0]);
249 if (!gGeoManager->IsEntering()) {
250 gGeoManager->SetStep(1.E-3);
251 currentnode = gGeoManager->Step();
252 if (!gGeoManager->IsEntering() || !currentnode) {
253 // printf("ERROR: cannot cross boundary\n");
254 mparam[0] = bparam[0]/step;
255 mparam[1] = bparam[1]/step;
256 mparam[2] = bparam[2]/step;
257 mparam[3] = bparam[3]/step;
258 mparam[5] = bparam[5]/step;
260 mparam[0] = 0.; // if crash of navigation take mean density 0
261 mparam[1] = 1000000; // and infinite rad length
262 return bparam[0]/step;
266 bparam[0] += lparam[0]*1.E-3;
267 bparam[1] += lparam[1]*1.E-3;
268 bparam[2] += lparam[2]*1.E-3;
269 bparam[3] += lparam[3]*1.E-3;
270 bparam[5] += lparam[5]*1.E-3;
273 material = currentnode->GetVolume()->GetMedium()->GetMaterial();
274 lparam[0] = material->GetDensity();
275 lparam[1] = material->GetRadLen();
276 lparam[2] = material->GetA();
277 lparam[3] = material->GetZ();
278 lparam[5] = lparam[3]/lparam[2];
279 if (material->IsMixture()) {
280 lparam[1]*=lparam[0];
281 TGeoMixture * mixture = (TGeoMixture*)material;
284 for (Int_t iel=0;iel<mixture->GetNelements();iel++){
285 sum+= mixture->GetWmixt()[iel];
286 lparam[5]+= mixture->GetZmixt()[iel]*mixture->GetWmixt()[iel]/mixture->GetAmixt()[iel];
290 gGeoManager->FindNextBoundary(length);
291 snext = gGeoManager->GetStep();
293 mparam[0] = bparam[0]/step;
294 mparam[1] = bparam[1]/step;
295 mparam[2] = bparam[2]/step;
296 mparam[3] = bparam[3]/step;
297 mparam[5] = bparam[5]/step;
298 return bparam[0]/step;