]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/AliKalmanTrack.cxx
Storing the alignable volume matrices. The matrixes transform from the tracking V2...
[u/mrichter/AliRoot.git] / STEER / AliKalmanTrack.cxx
CommitLineData
87594435 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
acd84897 16/* $Id$ */
fb17acd4 17
87594435 18//-------------------------------------------------------------------------
19// Implementation of the AliKalmanTrack class
066782e8 20// that is the base for AliTPCtrack, AliITStrackV2 and AliTRDtrack
87594435 21// Origin: Iouri Belikov, CERN, Jouri.Belikov@cern.ch
22//-------------------------------------------------------------------------
6c94f330 23#include <TGeoManager.h>
87594435 24#include "AliKalmanTrack.h"
87594435 25
26ClassImp(AliKalmanTrack)
27
e2afb3b6 28//_______________________________________________________________________
6c94f330 29 AliKalmanTrack::AliKalmanTrack():AliExternalTrackParam(),
e2afb3b6 30 fLab(-3141593),
68b8060b 31 fFakeRatio(0),
e2afb3b6 32 fChi2(0),
304864ab 33 fMass(AliPID::ParticleMass(AliPID::kPion)),
90e48c0c 34 fN(0),
35 fStartTimeIntegral(kFALSE),
36 fIntegratedLength(0)
e2afb3b6 37{
116cbefd 38 //
39 // Default constructor
40 //
c84a5e9e 41
7d0f8548 42 for(Int_t i=0; i<AliPID::kSPECIES; i++) fIntegratedTime[i] = 0;
e2afb3b6 43}
44
45//_______________________________________________________________________
46AliKalmanTrack::AliKalmanTrack(const AliKalmanTrack &t):
6c94f330 47 AliExternalTrackParam(t),
e2afb3b6 48 fLab(t.fLab),
babd135a 49 fFakeRatio(t.fFakeRatio),
e2afb3b6 50 fChi2(t.fChi2),
51 fMass(t.fMass),
90e48c0c 52 fN(t.fN),
53 fStartTimeIntegral(t.fStartTimeIntegral),
54 fIntegratedLength(t.fIntegratedLength)
e2afb3b6 55{
116cbefd 56 //
57 // Copy constructor
58 //
74f9526e 59
c84a5e9e 60 for (Int_t i=0; i<AliPID::kSPECIES; i++)
61 fIntegratedTime[i] = t.fIntegratedTime[i];
74f9526e 62}
c5507f6d 63
74f9526e 64//_______________________________________________________________________
65void AliKalmanTrack::StartTimeIntegral()
66{
49a7a79a 67 // Sylwester Radomski, GSI
68 // S.Radomski@gsi.de
74f9526e 69 //
70 // Start time integration
71 // To be called at Vertex by ITS tracker
72 //
73
74 //if (fStartTimeIntegral)
f37d970d 75 // AliWarning("Reseting Recorded Time.");
74f9526e 76
77 fStartTimeIntegral = kTRUE;
304864ab 78 for(Int_t i=0; i<AliPID::kSPECIES; i++) fIntegratedTime[i] = 0;
74f9526e 79 fIntegratedLength = 0;
80}
7d0f8548 81
74f9526e 82//_______________________________________________________________________
83void AliKalmanTrack:: AddTimeStep(Double_t length)
84{
85 //
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.
90 //
91 // If integration not started function does nothing
92 //
93 // Formula
94 // dt = dl * sqrt(p^2 + m^2) / p
95 // p = pT * (1 + tg^2 (lambda) )
96 //
97 // pt = 1/external parameter [4]
98 // tg lambda = external parameter [3]
99 //
100 //
101 // Sylwester Radomski, GSI
102 // S.Radomski@gsi.de
103 //
104
5d8718b8 105 static const Double_t kcc = 2.99792458e-2;
74f9526e 106
107 if (!fStartTimeIntegral) return;
108
109 fIntegratedLength += length;
110
74f9526e 111 Double_t xr, param[5];
112 Double_t pt, tgl;
113
114 GetExternalParameters(xr, param);
115 pt = 1/param[4] ;
116 tgl = param[3];
117
118 Double_t p = TMath::Abs(pt * TMath::Sqrt(1+tgl*tgl));
119
120 if (length > 100) return;
121
304864ab 122 for (Int_t i=0; i<AliPID::kSPECIES; i++) {
74f9526e 123
304864ab 124 Double_t mass = AliPID::ParticleMass(i);
74f9526e 125 Double_t correction = TMath::Sqrt( pt*pt * (1 + tgl*tgl) + mass * mass ) / p;
5d8718b8 126 Double_t time = length * correction / kcc;
74f9526e 127
74f9526e 128 fIntegratedTime[i] += time;
129 }
e2afb3b6 130}
131
74f9526e 132//_______________________________________________________________________
74f9526e 133Double_t AliKalmanTrack::GetIntegratedTime(Int_t pdg) const
134{
49a7a79a 135 // Sylwester Radomski, GSI
136 // S.Radomski@gsi.de
74f9526e 137 //
138 // Return integrated time hypothesis for a given particle
139 // type assumption.
140 //
141 // Input parameter:
142 // pdg - Pdg code of a particle type
143 //
144
145
146 if (!fStartTimeIntegral) {
f37d970d 147 AliWarning("Time integration not started");
74f9526e 148 return 0.;
149 }
150
304864ab 151 for (Int_t i=0; i<AliPID::kSPECIES; i++)
152 if (AliPID::ParticleCode(i) == TMath::Abs(pdg)) return fIntegratedTime[i];
74f9526e 153
f37d970d 154 AliWarning(Form("Particle type [%d] not found", pdg));
74f9526e 155 return 0;
156}
ae982df3 157
158void AliKalmanTrack::GetIntegratedTimes(Double_t *times) const {
304864ab 159 for (Int_t i=0; i<AliPID::kSPECIES; i++) times[i]=fIntegratedTime[i];
ae982df3 160}
161
162void AliKalmanTrack::SetIntegratedTimes(const Double_t *times) {
304864ab 163 for (Int_t i=0; i<AliPID::kSPECIES; i++) fIntegratedTime[i]=times[i];
ae982df3 164}
165
4557b520 166Double_t AliKalmanTrack::MeanMaterialBudget(Double_t *start, Double_t *end, Double_t *mparam)
167{
6c94f330 168 //
4557b520 169 // calculate mean material budget and material properties beween point start and end
170 // mparam - returns parameters used for dEdx and multiple scatering
171 //
6c94f330 172 // mparam[0] - density mean
4557b520 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
179 //
6c94f330 180 mparam[0]=0; mparam[1]=1; mparam[2] =0; mparam[3] =0, mparam[4]=0, mparam[5]=0; mparam[6]=0;
4557b520 181 //
182 Double_t bparam[6], lparam[6]; // bparam - total param - lparam - local parameters
6c94f330 183 for (Int_t i=0;i<6;i++) bparam[i]=0; //
4557b520 184
185 if (!gGeoManager) {
186 printf("ERROR: no TGeo\n");
187 return 0.;
188 }
189 //
190 Double_t length;
191 Double_t dir[3];
192 length = TMath::Sqrt((end[0]-start[0])*(end[0]-start[0])+
6c94f330 193 (end[1]-start[1])*(end[1]-start[1])+
194 (end[2]-start[2])*(end[2]-start[2]));
4557b520 195 mparam[4]=length;
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);
205 if (!startnode) {
206 printf("ERROR: start point out of geometry\n");
207 return 0.0;
208 }
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();
6c94f330 214 lparam[4] = length;
4557b520 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;
219 lparam[5] =0;
220 Double_t sum =0;
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];
224 }
225 lparam[5]/=sum;
226 }
227 gGeoManager->FindNextBoundary(length);
228 Double_t snext = gGeoManager->GetStep();
229 Double_t step = 0.0;
230 // If no boundary within proposed length, return current density
231 if (snext>=length) {
6c94f330 232 for (Int_t ip=0;ip<5;ip++) mparam[ip] = lparam[ip];
4557b520 233 return lparam[0];
234 }
235 // Try to cross the boundary and see what is next
236 while (length>TGeoShape::Tolerance()) {
237 mparam[6]+=1.;
238 currentnode = gGeoManager->Step();
239 step += snext+1.E-6;
240 bparam[1] += snext*lparam[1];
241 bparam[2] += snext*lparam[2];
242 bparam[3] += snext*lparam[3];
6c94f330 243 bparam[5] += snext*lparam[5];
4557b520 244 bparam[0] += snext*lparam[0];
245
246 if (snext>=length) break;
58d96064 247 if (!currentnode) break;
4557b520 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) {
6c94f330 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;
259 mparam[4] = step;
260 mparam[0] = 0.; // if crash of navigation take mean density 0
261 mparam[1] = 1000000; // and infinite rad length
4557b520 262 return bparam[0]/step;
263 }
264 step += 1.E-3;
265 snext += 1.E-3;
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;
271 }
272 length -= snext;
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;
6c94f330 282 lparam[5]=0;
4557b520 283 Double_t sum =0;
284 for (Int_t iel=0;iel<mixture->GetNelements();iel++){
6c94f330 285 sum+= mixture->GetWmixt()[iel];
286 lparam[5]+= mixture->GetZmixt()[iel]*mixture->GetWmixt()[iel]/mixture->GetAmixt()[iel];
4557b520 287 }
288 lparam[5]/=sum;
289 }
290 gGeoManager->FindNextBoundary(length);
291 snext = gGeoManager->GetStep();
6c94f330 292 }
4557b520 293 mparam[0] = bparam[0]/step;
294 mparam[1] = bparam[1]/step;
295 mparam[2] = bparam[2]/step;
6c94f330 296 mparam[3] = bparam[3]/step;
297 mparam[5] = bparam[5]/step;
298 return bparam[0]/step;
7d0f8548 299
7d0f8548 300}
301