]>
Commit | Line | Data |
---|---|---|
be9c5115 | 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 | |
be9c5115 | 18 | //------------------------------------------------------------------------- |
19 | // Implementation of the AliTracker class | |
9b83b8cc | 20 | // that is the base for AliTPCtracker, AliITStrackerV2 and AliTRDtracker |
21 | // Origin: Iouri Belikov, CERN, Jouri.Belikov@cern.ch | |
be9c5115 | 22 | //------------------------------------------------------------------------- |
7d0f8548 | 23 | #include <TClass.h> |
be9c5115 | 24 | #include <TMath.h> |
e23a38cb | 25 | #include <TH1F.h> |
6e440ee5 | 26 | #include <TGeoManager.h> |
9efabefd | 27 | #include <TGeoMatrix.h> |
be9c5115 | 28 | |
7b5ef2e6 | 29 | #include "AliMagF.h" |
be9c5115 | 30 | #include "AliTracker.h" |
e23a38cb | 31 | #include "AliGeomManager.h" |
c84a5e9e | 32 | #include "AliCluster.h" |
7d0f8548 | 33 | #include "AliKalmanTrack.h" |
41377c29 | 34 | |
6e440ee5 | 35 | extern TGeoManager *gGeoManager; |
36 | ||
e23a38cb | 37 | Bool_t AliTracker::fFillResiduals=kFALSE; |
57acd2d2 | 38 | TObjArray **AliTracker::fResiduals=NULL; |
39 | AliRecoParam::EventSpecie_t AliTracker::fEventSpecie=AliRecoParam::kDefault; | |
3b242889 | 40 | |
be9c5115 | 41 | ClassImp(AliTracker) |
42 | ||
3b242889 | 43 | AliTracker::AliTracker(): |
fe12e09c | 44 | TObject(), |
3b242889 | 45 | fX(0), |
46 | fY(0), | |
47 | fZ(0), | |
48 | fSigmaX(0.005), | |
49 | fSigmaY(0.005), | |
57acd2d2 | 50 | fSigmaZ(0.010) |
3b242889 | 51 | { |
52 | //-------------------------------------------------------------------- | |
53 | // The default constructor. | |
54 | //-------------------------------------------------------------------- | |
f7a1cc68 | 55 | if (!TGeoGlobalMagField::Instance()->GetField()) |
56 | AliWarning("Field map is not set."); | |
3b242889 | 57 | } |
58 | ||
fe12e09c | 59 | //__________________________________________________________________________ |
60 | AliTracker::AliTracker(const AliTracker &atr): | |
61 | TObject(atr), | |
62 | fX(atr.fX), | |
63 | fY(atr.fY), | |
64 | fZ(atr.fZ), | |
65 | fSigmaX(atr.fSigmaX), | |
66 | fSigmaY(atr.fSigmaY), | |
67 | fSigmaZ(atr.fSigmaZ) | |
68 | { | |
69 | //-------------------------------------------------------------------- | |
70 | // The default constructor. | |
71 | //-------------------------------------------------------------------- | |
f7a1cc68 | 72 | if (!TGeoGlobalMagField::Instance()->GetField()) |
73 | AliWarning("Field map is not set."); | |
fe12e09c | 74 | } |
75 | ||
76 | //__________________________________________________________________________ | |
f7a1cc68 | 77 | Double_t AliTracker::GetBz() |
78 | { | |
79 | AliMagF* fld = (AliMagF*)TGeoGlobalMagField::Instance()->GetField(); | |
80 | if (!fld) return kAlmost0Field; | |
81 | Double_t bz = -fld->SolenoidField(); | |
82 | return TMath::Sign(kAlmost0Field,bz) + bz; | |
83 | } | |
7d0f8548 | 84 | |
f7a1cc68 | 85 | //__________________________________________________________________________ |
86 | Double_t AliTracker::GetBz(const Double_t *r) { | |
87 | //------------------------------------------------------------------ | |
88 | // Returns Bz (kG) at the point "r" . | |
89 | //------------------------------------------------------------------ | |
90 | AliMagF* fld = (AliMagF*)TGeoGlobalMagField::Instance()->GetField(); | |
91 | if (!fld) return kAlmost0Field; | |
92 | Double_t bz = -fld->GetBz(r); | |
93 | return TMath::Sign(kAlmost0Field,bz) + bz; | |
7d0f8548 | 94 | } |
95 | ||
2f4c86d7 | 96 | //__________________________________________________________________________ |
97 | void AliTracker::FillClusterArray(TObjArray* /*array*/) const | |
98 | { | |
99 | // Publishes all pointers to clusters known to the tracker into the | |
100 | // passed object array. | |
101 | // The ownership is not transfered - the caller is not expected to delete | |
102 | // the clusters. | |
103 | ||
104 | AliWarning("should be overriden by a sub-class."); | |
105 | } | |
106 | ||
be9c5115 | 107 | //__________________________________________________________________________ |
108 | void AliTracker::CookLabel(AliKalmanTrack *t, Float_t wrong) const { | |
109 | //-------------------------------------------------------------------- | |
110 | //This function "cooks" a track label. If label<0, this track is fake. | |
111 | //-------------------------------------------------------------------- | |
112 | Int_t noc=t->GetNumberOfClusters(); | |
9b4aca55 | 113 | if (noc<1) return; |
be9c5115 | 114 | Int_t *lb=new Int_t[noc]; |
115 | Int_t *mx=new Int_t[noc]; | |
116 | AliCluster **clusters=new AliCluster*[noc]; | |
117 | ||
118 | Int_t i; | |
119 | for (i=0; i<noc; i++) { | |
120 | lb[i]=mx[i]=0; | |
121 | Int_t index=t->GetClusterIndex(i); | |
122 | clusters[i]=GetCluster(index); | |
123 | } | |
124 | ||
125 | Int_t lab=123456789; | |
126 | for (i=0; i<noc; i++) { | |
127 | AliCluster *c=clusters[i]; | |
128 | lab=TMath::Abs(c->GetLabel(0)); | |
129 | Int_t j; | |
130 | for (j=0; j<noc; j++) if (lb[j]==lab || mx[j]==0) break; | |
131 | lb[j]=lab; | |
132 | (mx[j])++; | |
133 | } | |
134 | ||
135 | Int_t max=0; | |
136 | for (i=0; i<noc; i++) if (mx[i]>max) {max=mx[i]; lab=lb[i];} | |
137 | ||
138 | for (i=0; i<noc; i++) { | |
139 | AliCluster *c=clusters[i]; | |
babd135a | 140 | //if (TMath::Abs(c->GetLabel(1)) == lab || |
141 | // TMath::Abs(c->GetLabel(2)) == lab ) max++; | |
142 | if (TMath::Abs(c->GetLabel(0)!=lab)) | |
143 | if (TMath::Abs(c->GetLabel(1)) == lab || | |
144 | TMath::Abs(c->GetLabel(2)) == lab ) max++; | |
be9c5115 | 145 | } |
146 | ||
147 | if ((1.- Float_t(max)/noc) > wrong) lab=-lab; | |
babd135a | 148 | t->SetFakeRatio((1.- Float_t(max)/noc)); |
be9c5115 | 149 | t->SetLabel(lab); |
150 | ||
151 | delete[] lb; | |
152 | delete[] mx; | |
153 | delete[] clusters; | |
154 | } | |
155 | ||
156 | //____________________________________________________________________________ | |
157 | void AliTracker::UseClusters(const AliKalmanTrack *t, Int_t from) const { | |
158 | //------------------------------------------------------------------ | |
159 | //This function marks clusters associated with the track. | |
160 | //------------------------------------------------------------------ | |
161 | Int_t noc=t->GetNumberOfClusters(); | |
162 | for (Int_t i=from; i<noc; i++) { | |
163 | Int_t index=t->GetClusterIndex(i); | |
164 | AliCluster *c=GetCluster(index); | |
165 | c->Use(); | |
166 | } | |
167 | } | |
7b5ef2e6 | 168 | |
f7a1cc68 | 169 | Double_t AliTracker::MeanMaterialBudget(const Double_t *start, const Double_t *end, Double_t *mparam) |
6e440ee5 | 170 | { |
171 | // | |
172 | // Calculate mean material budget and material properties between | |
173 | // the points "start" and "end". | |
174 | // | |
175 | // "mparam" - parameters used for the energy and multiple scattering | |
176 | // corrections: | |
177 | // | |
178 | // mparam[0] - mean density: sum(x_i*rho_i)/sum(x_i) [g/cm3] | |
179 | // mparam[1] - equivalent rad length fraction: sum(x_i/X0_i) [adimensional] | |
180 | // mparam[2] - mean A: sum(x_i*A_i)/sum(x_i) [adimensional] | |
181 | // mparam[3] - mean Z: sum(x_i*Z_i)/sum(x_i) [adimensional] | |
182 | // mparam[4] - length: sum(x_i) [cm] | |
183 | // mparam[5] - Z/A mean: sum(x_i*Z_i/A_i)/sum(x_i) [adimensional] | |
184 | // mparam[6] - number of boundary crosses | |
185 | // | |
0c4ea33b | 186 | // Origin: Marian Ivanov, Marian.Ivanov@cern.ch |
187 | // | |
188 | // Corrections and improvements by | |
189 | // Andrea Dainese, Andrea.Dainese@lnl.infn.it, | |
190 | // Andrei Gheata, Andrei.Gheata@cern.ch | |
191 | // | |
6e440ee5 | 192 | |
193 | mparam[0]=0; mparam[1]=1; mparam[2] =0; mparam[3] =0; | |
194 | mparam[4]=0; mparam[5]=0; mparam[6]=0; | |
195 | // | |
196 | Double_t bparam[6]; // total parameters | |
197 | Double_t lparam[6]; // local parameters | |
198 | ||
199 | for (Int_t i=0;i<6;i++) bparam[i]=0; | |
200 | ||
201 | if (!gGeoManager) { | |
202 | printf("ERROR: no TGeo\n"); | |
203 | return 0.; | |
204 | } | |
205 | // | |
206 | Double_t length; | |
207 | Double_t dir[3]; | |
208 | length = TMath::Sqrt((end[0]-start[0])*(end[0]-start[0])+ | |
209 | (end[1]-start[1])*(end[1]-start[1])+ | |
210 | (end[2]-start[2])*(end[2]-start[2])); | |
211 | mparam[4]=length; | |
212 | if (length<TGeoShape::Tolerance()) return 0.0; | |
213 | Double_t invlen = 1./length; | |
214 | dir[0] = (end[0]-start[0])*invlen; | |
215 | dir[1] = (end[1]-start[1])*invlen; | |
216 | dir[2] = (end[2]-start[2])*invlen; | |
217 | ||
218 | // Initialize start point and direction | |
219 | TGeoNode *currentnode = 0; | |
220 | TGeoNode *startnode = gGeoManager->InitTrack(start, dir); | |
221 | //printf("%s length=%f\n",gGeoManager->GetPath(),length); | |
222 | if (!startnode) { | |
f3b4b060 | 223 | AliErrorClass(Form("start point out of geometry: x %f, y %f, z %f", |
ff0051ed | 224 | start[0],start[1],start[2])); |
6e440ee5 | 225 | return 0.0; |
226 | } | |
227 | TGeoMaterial *material = startnode->GetVolume()->GetMedium()->GetMaterial(); | |
228 | lparam[0] = material->GetDensity(); | |
229 | lparam[1] = material->GetRadLen(); | |
230 | lparam[2] = material->GetA(); | |
231 | lparam[3] = material->GetZ(); | |
232 | lparam[4] = length; | |
233 | lparam[5] = lparam[3]/lparam[2]; | |
234 | if (material->IsMixture()) { | |
235 | TGeoMixture * mixture = (TGeoMixture*)material; | |
236 | lparam[5] =0; | |
237 | Double_t sum =0; | |
238 | for (Int_t iel=0;iel<mixture->GetNelements();iel++){ | |
239 | sum += mixture->GetWmixt()[iel]; | |
240 | lparam[5]+= mixture->GetZmixt()[iel]*mixture->GetWmixt()[iel]/mixture->GetAmixt()[iel]; | |
241 | } | |
242 | lparam[5]/=sum; | |
243 | } | |
244 | ||
245 | // Locate next boundary within length without computing safety. | |
246 | // Propagate either with length (if no boundary found) or just cross boundary | |
247 | gGeoManager->FindNextBoundaryAndStep(length, kFALSE); | |
248 | Double_t step = 0.0; // Step made | |
249 | Double_t snext = gGeoManager->GetStep(); | |
250 | // If no boundary within proposed length, return current density | |
251 | if (!gGeoManager->IsOnBoundary()) { | |
252 | mparam[0] = lparam[0]; | |
253 | mparam[1] = lparam[4]/lparam[1]; | |
254 | mparam[2] = lparam[2]; | |
255 | mparam[3] = lparam[3]; | |
256 | mparam[4] = lparam[4]; | |
257 | return lparam[0]; | |
258 | } | |
259 | // Try to cross the boundary and see what is next | |
260 | Int_t nzero = 0; | |
261 | while (length>TGeoShape::Tolerance()) { | |
262 | currentnode = gGeoManager->GetCurrentNode(); | |
263 | if (snext<2.*TGeoShape::Tolerance()) nzero++; | |
264 | else nzero = 0; | |
265 | if (nzero>3) { | |
266 | // This means navigation has problems on one boundary | |
267 | // Try to cross by making a small step | |
268 | printf("ERROR: cannot cross boundary\n"); | |
269 | mparam[0] = bparam[0]/step; | |
270 | mparam[1] = bparam[1]; | |
271 | mparam[2] = bparam[2]/step; | |
272 | mparam[3] = bparam[3]/step; | |
273 | mparam[5] = bparam[5]/step; | |
274 | mparam[4] = step; | |
275 | mparam[0] = 0.; // if crash of navigation take mean density 0 | |
276 | mparam[1] = 1000000; // and infinite rad length | |
277 | return bparam[0]/step; | |
278 | } | |
279 | mparam[6]+=1.; | |
280 | step += snext; | |
281 | bparam[1] += snext/lparam[1]; | |
282 | bparam[2] += snext*lparam[2]; | |
283 | bparam[3] += snext*lparam[3]; | |
284 | bparam[5] += snext*lparam[5]; | |
285 | bparam[0] += snext*lparam[0]; | |
286 | ||
287 | if (snext>=length) break; | |
288 | if (!currentnode) break; | |
289 | length -= snext; | |
290 | //printf("%s snext=%f length=%f\n", currentnode->GetName(),snext,length); | |
291 | material = currentnode->GetVolume()->GetMedium()->GetMaterial(); | |
292 | lparam[0] = material->GetDensity(); | |
293 | lparam[1] = material->GetRadLen(); | |
294 | lparam[2] = material->GetA(); | |
295 | lparam[3] = material->GetZ(); | |
296 | //printf(" %f %f %f %f\n",lparam[0],lparam[1],lparam[2],lparam[3]); | |
297 | lparam[5] = lparam[3]/lparam[2]; | |
298 | if (material->IsMixture()) { | |
299 | TGeoMixture * mixture = (TGeoMixture*)material; | |
300 | lparam[5]=0; | |
301 | Double_t sum =0; | |
302 | for (Int_t iel=0;iel<mixture->GetNelements();iel++){ | |
303 | sum+= mixture->GetWmixt()[iel]; | |
304 | lparam[5]+= mixture->GetZmixt()[iel]*mixture->GetWmixt()[iel]/mixture->GetAmixt()[iel]; | |
305 | } | |
306 | lparam[5]/=sum; | |
307 | } | |
308 | gGeoManager->FindNextBoundaryAndStep(length, kFALSE); | |
309 | snext = gGeoManager->GetStep(); | |
310 | //printf("snext %f\n",snext); | |
311 | } | |
312 | mparam[0] = bparam[0]/step; | |
313 | mparam[1] = bparam[1]; | |
314 | mparam[2] = bparam[2]/step; | |
315 | mparam[3] = bparam[3]/step; | |
316 | mparam[5] = bparam[5]/step; | |
317 | return bparam[0]/step; | |
318 | } | |
0c4ea33b | 319 | |
320 | ||
321 | Bool_t | |
322 | AliTracker::PropagateTrackTo(AliExternalTrackParam *track, Double_t xToGo, | |
323 | Double_t mass, Double_t maxStep, Bool_t rotateTo, Double_t maxSnp){ | |
324 | //---------------------------------------------------------------- | |
325 | // | |
326 | // Propagates the track to the plane X=xk (cm) using the magnetic field map | |
327 | // and correcting for the crossed material. | |
328 | // | |
329 | // mass - mass used in propagation - used for energy loss correction | |
330 | // maxStep - maximal step for propagation | |
331 | // | |
332 | // Origin: Marian Ivanov, Marian.Ivanov@cern.ch | |
333 | // | |
334 | //---------------------------------------------------------------- | |
335 | const Double_t kEpsilon = 0.00001; | |
336 | Double_t xpos = track->GetX(); | |
337 | Double_t dir = (xpos<xToGo) ? 1.:-1.; | |
338 | // | |
339 | while ( (xToGo-xpos)*dir > kEpsilon){ | |
340 | Double_t step = dir*TMath::Min(TMath::Abs(xToGo-xpos), maxStep); | |
341 | Double_t x = xpos+step; | |
342 | Double_t xyz0[3],xyz1[3],param[7]; | |
343 | track->GetXYZ(xyz0); //starting global position | |
344 | ||
345 | Double_t bz=GetBz(xyz0); // getting the local Bz | |
346 | ||
347 | if (!track->GetXYZAt(x,bz,xyz1)) return kFALSE; // no prolongation | |
348 | xyz1[2]+=kEpsilon; // waiting for bug correction in geo | |
349 | ||
350 | if (TMath::Abs(track->GetSnpAt(x,bz)) >= maxSnp) return kFALSE; | |
351 | if (!track->PropagateTo(x,bz)) return kFALSE; | |
352 | ||
353 | MeanMaterialBudget(xyz0,xyz1,param); | |
354 | Double_t xrho=param[0]*param[4], xx0=param[1]; | |
355 | ||
356 | if (!track->CorrectForMeanMaterial(xx0,xrho,mass)) return kFALSE; | |
357 | if (rotateTo){ | |
358 | if (TMath::Abs(track->GetSnp()) >= maxSnp) return kFALSE; | |
359 | track->GetXYZ(xyz0); // global position | |
360 | Double_t alphan = TMath::ATan2(xyz0[1], xyz0[0]); | |
361 | // | |
362 | Double_t ca=TMath::Cos(alphan-track->GetAlpha()), | |
363 | sa=TMath::Sin(alphan-track->GetAlpha()); | |
60e55aee | 364 | Double_t sf=track->GetSnp(), cf=TMath::Sqrt((1.-sf)*(1.+sf)); |
0c4ea33b | 365 | Double_t sinNew = sf*ca - cf*sa; |
366 | if (TMath::Abs(sinNew) >= maxSnp) return kFALSE; | |
367 | if (!track->Rotate(alphan)) return kFALSE; | |
368 | } | |
369 | xpos = track->GetX(); | |
370 | } | |
371 | return kTRUE; | |
372 | } | |
373 | ||
e23a38cb | 374 | void AliTracker::FillResiduals(const AliExternalTrackParam *t, |
375 | Double_t *p, Double_t *cov, | |
376 | UShort_t id, Bool_t updated) { | |
377 | // | |
378 | // This function fills the histograms of residuals | |
379 | // The array of these histos is external for this AliTracker class. | |
380 | // Normally, this array belong to AliGlobalQADataMaker class. | |
381 | // | |
382 | if (!fFillResiduals) return; | |
383 | if (!fResiduals) return; | |
384 | ||
385 | const Double_t *residuals=t->GetResiduals(p,cov,updated); | |
386 | if (!residuals) return; | |
387 | ||
388 | TH1F *h=0; | |
389 | AliGeomManager::ELayerID layer=AliGeomManager::VolUIDToLayer(id); | |
57acd2d2 | 390 | h=(TH1F*)fResiduals[fEventSpecie]->At(2*layer-2); |
e23a38cb | 391 | h->Fill(residuals[0]); |
57acd2d2 | 392 | h=(TH1F*)fResiduals[fEventSpecie]->At(2*layer-1); |
e23a38cb | 393 | h->Fill(residuals[1]); |
a935c6c0 | 394 | |
395 | if (layer==5) { | |
49ab451d | 396 | if (p[1]<0) { // SSD1 absolute residuals |
57acd2d2 | 397 | ((TH1F*)fResiduals[fEventSpecie]->At(40))->Fill(t->GetY()-p[0]); //C side |
398 | ((TH1F*)fResiduals[fEventSpecie]->At(41))->Fill(t->GetZ()-p[1]); | |
49ab451d | 399 | } else { |
57acd2d2 | 400 | ((TH1F*)fResiduals[fEventSpecie]->At(42))->Fill(t->GetY()-p[0]); //A side |
401 | ((TH1F*)fResiduals[fEventSpecie]->At(43))->Fill(t->GetZ()-p[1]); | |
49ab451d | 402 | } |
a935c6c0 | 403 | } |
49ab451d | 404 | if (layer==6) { // SSD2 absolute residuals |
405 | if (p[1]<0) { | |
57acd2d2 | 406 | ((TH1F*)fResiduals[fEventSpecie]->At(44))->Fill(t->GetY()-p[0]); //C side |
407 | ((TH1F*)fResiduals[fEventSpecie]->At(45))->Fill(t->GetZ()-p[1]); | |
49ab451d | 408 | } else { |
57acd2d2 | 409 | ((TH1F*)fResiduals[fEventSpecie]->At(46))->Fill(t->GetY()-p[0]); //A side |
410 | ((TH1F*)fResiduals[fEventSpecie]->At(47))->Fill(t->GetZ()-p[1]); | |
49ab451d | 411 | } |
a935c6c0 | 412 | } |
413 | ||
e23a38cb | 414 | } |
415 | ||
9efabefd | 416 | void AliTracker::FillResiduals(const AliExternalTrackParam *t, |
417 | const AliCluster *c, Bool_t /*updated*/) { | |
418 | // | |
419 | // This function fills the histograms of residuals | |
420 | // The array of these histos is external for this AliTracker class. | |
421 | // Normally, this array belong to AliGlobalQADataMaker class. | |
422 | // | |
423 | // For the moment, the residuals are absolute ! | |
424 | // | |
425 | ||
426 | if (!fFillResiduals) return; | |
427 | if (!fResiduals) return; | |
428 | ||
429 | UShort_t id=c->GetVolumeId(); | |
430 | const TGeoHMatrix *matrixT2L=AliGeomManager::GetTracking2LocalMatrix(id); | |
431 | ||
432 | // Position of the cluster in the tracking c.s. | |
433 | Double_t clsTrk[3]={c->GetX(), c->GetY(), c->GetZ()}; | |
434 | // Position of the cluster in the local module c.s. | |
435 | Double_t clsLoc[3]={0.,0.,0.}; | |
436 | matrixT2L->LocalToMaster(clsTrk,clsLoc); | |
437 | ||
438 | ||
439 | // Position of the intersection point in the tracking c.s. | |
440 | Double_t trkTrk[3]={t->GetX(),t->GetY(),t->GetZ()}; | |
441 | // Position of the intersection point in the local module c.s. | |
442 | Double_t trkLoc[3]={0.,0.,0.}; | |
443 | matrixT2L->LocalToMaster(trkTrk,trkLoc); | |
444 | ||
445 | Double_t residuals[2]={trkLoc[0]-clsLoc[0], trkLoc[2]-clsLoc[2]}; | |
446 | ||
447 | TH1F *h=0; | |
448 | AliGeomManager::ELayerID layer=AliGeomManager::VolUIDToLayer(id); | |
449 | h=(TH1F*)fResiduals[fEventSpecie]->At(2*layer-2); | |
450 | h->Fill(residuals[0]); | |
451 | h=(TH1F*)fResiduals[fEventSpecie]->At(2*layer-1); | |
452 | h->Fill(residuals[1]); | |
453 | ||
454 | } |