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