]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/AliITStrackerV2.cxx
Inverted logics (Panos)
[u/mrichter/AliRoot.git] / ITS / AliITStrackerV2.cxx
CommitLineData
006b5f7f 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
16//-------------------------------------------------------------------------
17// Implementation of the ITS tracker class
00a7cc50 18// It reads AliITSRecPoint clusters and creates AliITStrackV2 tracks
18856a77 19// and fills with them the ESD
006b5f7f 20// Origin: Iouri Belikov, CERN, Jouri.Belikov@cern.ch
a9a2d814 21// dEdx analysis by: Boris Batyunya, JINR, Boris.Batiounia@cern.ch
006b5f7f 22//-------------------------------------------------------------------------
1f9a65c4 23
9c369bfe 24#include <new>
25
75fb37cc 26#include <TError.h>
006b5f7f 27#include <TFile.h>
28#include <TTree.h>
29#include <TRandom.h>
a504d56f 30#include <TGeoMatrix.h>
006b5f7f 31
e341247d 32#include "AliITSgeomTGeo.h"
a504d56f 33#include "AliAlignObj.h"
006b5f7f 34#include "AliITSRecPoint.h"
af885e0f 35#include "AliESDEvent.h"
aad72f45 36#include "AliESDtrack.h"
00a7cc50 37#include "AliITSRecPoint.h"
44347160 38#include "AliITSReconstructor.h"
006b5f7f 39#include "AliITStrackerV2.h"
40
8676d691 41ClassImp(AliITStrackerV2)
006b5f7f 42
e50912db 43AliITStrackerV2::AliITSlayer AliITStrackerV2::fgLayers[AliITSgeomTGeo::kNLayers]; //ITS layers
006b5f7f 44
6c94f330 45AliITStrackerV2::AliITStrackerV2():
46 AliTracker(),
e50912db 47 fI(AliITSgeomTGeo::GetNLayers()),
6c94f330 48 fBestTrack(),
49 fTrackToFollow(),
50 fPass(0),
e50912db 51 fLastLayerToTrackTo(AliITSRecoParam::GetLastLayerToTrackTo())
6c94f330 52{
53 //--------------------------------------------------------------------
54 //This is the AliITStrackerV2 default constructor
55 //--------------------------------------------------------------------
56
e50912db 57 for (Int_t i=1; i<AliITSgeomTGeo::GetNLayers()+1; i++) new(fgLayers+i-1) AliITSlayer();
6c94f330 58
59 fConstraint[0]=1; fConstraint[1]=0;
60
44347160 61 Double_t xyz[]={AliITSReconstructor::GetRecoParam()->GetXVdef(),
62 AliITSReconstructor::GetRecoParam()->GetYVdef(),
63 AliITSReconstructor::GetRecoParam()->GetZVdef()};
64 Double_t ers[]={AliITSReconstructor::GetRecoParam()->GetSigmaXVdef(),
65 AliITSReconstructor::GetRecoParam()->GetSigmaYVdef(),
66 AliITSReconstructor::GetRecoParam()->GetSigmaZVdef()};
6c94f330 67 SetVertex(xyz,ers);
68
e50912db 69 for (Int_t i=0; i<AliITSgeomTGeo::GetNLayers(); i++) fLayersNotToSkip[i]=AliITSRecoParam::GetLayersNotToSkip(i);
6c94f330 70
71}
72
73AliITStrackerV2::AliITStrackerV2(const AliITStrackerV2 &t):
74 AliTracker(t),
75 fI(t.fI),
76 fBestTrack(t.fBestTrack),
77 fTrackToFollow(t.fTrackToFollow),
78 fPass(t.fPass),
79 fLastLayerToTrackTo(t.fLastLayerToTrackTo)
80{
81 //--------------------------------------------------------------------
82 //This is the AliITStrackerV2 copy constructor
83 //--------------------------------------------------------------------
84
e50912db 85 //for (Int_t i=1; i<AliITSgeomTGeo::GetNLayers()+1; i++) new(fgLayers+i-1) AliITSlayer();
6c94f330 86
87 fConstraint[0]=t.fConstraint[0]; fConstraint[1]=t.fConstraint[1];
88
44347160 89 Double_t xyz[]={AliITSReconstructor::GetRecoParam()->GetXVdef(),
90 AliITSReconstructor::GetRecoParam()->GetYVdef(),
91 AliITSReconstructor::GetRecoParam()->GetZVdef()};
92 Double_t ers[]={AliITSReconstructor::GetRecoParam()->GetSigmaXVdef(),
93 AliITSReconstructor::GetRecoParam()->GetSigmaYVdef(),
94 AliITSReconstructor::GetRecoParam()->GetSigmaZVdef()};
6c94f330 95 xyz[0]=t.GetX(); xyz[1]=t.GetY(); xyz[2]=t.GetZ();
96 ers[0]=t.GetSigmaX(); ers[1]=t.GetSigmaY(); ers[2]=t.GetSigmaZ();
97 SetVertex(xyz,ers);
98
e50912db 99 for (Int_t i=0; i<AliITSgeomTGeo::GetNLayers(); i++) fLayersNotToSkip[i]=t.fLayersNotToSkip[i];
6c94f330 100
101}
102
1f3e997f 103AliITStrackerV2::AliITStrackerV2(const Char_t *geom) :
6c94f330 104 AliTracker(),
e50912db 105 fI(AliITSgeomTGeo::GetNLayers()),
6c94f330 106 fBestTrack(),
107 fTrackToFollow(),
108 fPass(0),
e50912db 109 fLastLayerToTrackTo(AliITSRecoParam::GetLastLayerToTrackTo())
6c94f330 110{
006b5f7f 111 //--------------------------------------------------------------------
61ab8ea8 112 //This is the AliITStrackerV2 constructor
006b5f7f 113 //--------------------------------------------------------------------
e341247d 114 if (geom) {
115 AliWarning("\"geom\" is actually a dummy argument !");
116 }
006b5f7f 117
e50912db 118 for (Int_t i=1; i<AliITSgeomTGeo::GetNLayers()+1; i++) {
e341247d 119 Int_t nlad=AliITSgeomTGeo::GetNLadders(i);
120 Int_t ndet=AliITSgeomTGeo::GetNDetectors(i);
006b5f7f 121
e341247d 122 Double_t xyz[3], &x=xyz[0], &y=xyz[1], &z=xyz[2];
123 AliITSgeomTGeo::GetOrigTranslation(i,1,1,xyz);
006b5f7f 124 Double_t poff=TMath::ATan2(y,x);
125 Double_t zoff=z;
a504d56f 126 Double_t r=TMath::Sqrt(x*x + y*y);
006b5f7f 127
e341247d 128 AliITSgeomTGeo::GetOrigTranslation(i,1,2,xyz);
006b5f7f 129 r += TMath::Sqrt(x*x + y*y);
e341247d 130 AliITSgeomTGeo::GetOrigTranslation(i,2,1,xyz);
006b5f7f 131 r += TMath::Sqrt(x*x + y*y);
e341247d 132 AliITSgeomTGeo::GetOrigTranslation(i,2,2,xyz);
006b5f7f 133 r += TMath::Sqrt(x*x + y*y);
134 r*=0.25;
135
18856a77 136 new (fgLayers+i-1) AliITSlayer(r,poff,zoff,nlad,ndet);
006b5f7f 137
138 for (Int_t j=1; j<nlad+1; j++) {
139 for (Int_t k=1; k<ndet+1; k++) { //Fill this layer with detectors
e341247d 140 TGeoHMatrix m; AliITSgeomTGeo::GetOrigMatrix(i,j,k,m);
1f3e997f 141 const TGeoHMatrix *tm=AliITSgeomTGeo::GetTracking2LocalMatrix(i,j,k);
142 m.Multiply(tm);
143 Double_t txyz[3]={0.}, xyz[3]={0.};
144 m.LocalToMaster(txyz,xyz);
145 Double_t r=TMath::Sqrt(xyz[0]*xyz[0] + xyz[1]*xyz[1]);
146 Double_t phi=TMath::ATan2(xyz[1],xyz[0]);
c219fd63 147
148 if (phi<0) phi+=TMath::TwoPi();
149 else if (phi>=TMath::TwoPi()) phi-=TMath::TwoPi();
150
18856a77 151 AliITSdetector &det=fgLayers[i-1].GetDetector((j-1)*ndet + k-1);
006b5f7f 152 new(&det) AliITSdetector(r,phi);
153 }
154 }
c630aafd 155
006b5f7f 156 }
157
c219fd63 158 fConstraint[0]=1; fConstraint[1]=0;
8676d691 159
44347160 160 Double_t xyz[]={AliITSReconstructor::GetRecoParam()->GetXVdef(),
161 AliITSReconstructor::GetRecoParam()->GetYVdef(),
162 AliITSReconstructor::GetRecoParam()->GetZVdef()};
163 Double_t ers[]={AliITSReconstructor::GetRecoParam()->GetSigmaXVdef(),
164 AliITSReconstructor::GetRecoParam()->GetSigmaYVdef(),
165 AliITSReconstructor::GetRecoParam()->GetSigmaZVdef()};
8676d691 166 SetVertex(xyz,ers);
c0dd5278 167
e50912db 168 for (Int_t i=0; i<AliITSgeomTGeo::GetNLayers(); i++) fLayersNotToSkip[i]=AliITSRecoParam::GetLayersNotToSkip(i);
c0dd5278 169
170}
171
172void AliITStrackerV2::SetLayersNotToSkip(Int_t *l) {
173 //--------------------------------------------------------------------
174 //This function set masks of the layers which must be not skipped
175 //--------------------------------------------------------------------
e50912db 176 for (Int_t i=0; i<AliITSgeomTGeo::GetNLayers(); i++) fLayersNotToSkip[i]=l[i];
61ab8ea8 177}
006b5f7f 178
c630aafd 179Int_t AliITStrackerV2::LoadClusters(TTree *cTree) {
61ab8ea8 180 //--------------------------------------------------------------------
181 //This function loads ITS clusters
182 //--------------------------------------------------------------------
00a7cc50 183 TBranch *branch=cTree->GetBranch("ITSRecPoints");
61ab8ea8 184 if (!branch) {
c630aafd 185 Error("LoadClusters"," can't get the branch !\n");
8676d691 186 return 1;
61ab8ea8 187 }
006b5f7f 188
00a7cc50 189 TClonesArray dummy("AliITSRecPoint",10000), *clusters=&dummy;
61ab8ea8 190 branch->SetAddress(&clusters);
006b5f7f 191
61ab8ea8 192 Int_t j=0;
e50912db 193 for (Int_t i=0; i<AliITSgeomTGeo::GetNLayers(); i++) {
18856a77 194 Int_t ndet=fgLayers[i].GetNdetectors();
195 Int_t jmax = j + fgLayers[i].GetNladders()*ndet;
c219fd63 196
197 Double_t r=fgLayers[i].GetR();
198 Double_t circ=TMath::TwoPi()*r;
199
61ab8ea8 200 for (; j<jmax; j++) {
201 if (!cTree->GetEvent(j)) continue;
202 Int_t ncl=clusters->GetEntriesFast();
1f3e997f 203
61ab8ea8 204 while (ncl--) {
00a7cc50 205 AliITSRecPoint *c=(AliITSRecPoint*)clusters->UncheckedAt(ncl);
c219fd63 206
75fb37cc 207 if (!c->Misalign()) AliWarning("Can't misalign this cluster !");
1f3e997f 208
c219fd63 209 Int_t idx=c->GetDetectorIndex();
a504d56f 210 AliITSdetector &det=fgLayers[i].GetDetector(idx);
211
a504d56f 212 Double_t y=r*det.GetPhi()+c->GetY();
c219fd63 213 if (y>circ) y-=circ; else if (y<0) y+=circ;
214 c->SetPhiR(y);
215
00a7cc50 216 fgLayers[i].InsertCluster(new AliITSRecPoint(*c));
61ab8ea8 217 }
218 clusters->Delete();
219 }
18856a77 220 fgLayers[i].ResetRoad(); //road defined by the cluster density
006b5f7f 221 }
c630aafd 222
8676d691 223 return 0;
61ab8ea8 224}
006b5f7f 225
61ab8ea8 226void AliITStrackerV2::UnloadClusters() {
227 //--------------------------------------------------------------------
228 //This function unloads ITS clusters
229 //--------------------------------------------------------------------
e50912db 230 for (Int_t i=0; i<AliITSgeomTGeo::GetNLayers(); i++) fgLayers[i].ResetClusters();
006b5f7f 231}
232
880f41b9 233static Int_t CorrectForDeadZoneMaterial(AliITStrackV2 *t) {
234 //--------------------------------------------------------------------
235 // Correction for the material between the TPC and the ITS
236 // (should it belong to the TPC code ?)
237 //--------------------------------------------------------------------
238 Double_t riw=80., diw=0.0053, x0iw=30; // TPC inner wall ?
239 Double_t rcd=61., dcd=0.0053, x0cd=30; // TPC "central drum" ?
240 Double_t yr=12.8, dr=0.03; // rods ?
241 Double_t zm=0.2, dm=0.40; // membrane
242 //Double_t rr=52., dr=0.19, x0r=24., yyr=7.77; //rails
243 Double_t rs=50., ds=0.001; // something belonging to the ITS (screen ?)
244
245 if (t->GetX() > riw) {
246 if (!t->PropagateTo(riw,diw,x0iw)) return 1;
247 if (TMath::Abs(t->GetY())>yr) t->CorrectForMaterial(dr);
248 if (TMath::Abs(t->GetZ())<zm) t->CorrectForMaterial(dm);
249 if (!t->PropagateTo(rcd,dcd,x0cd)) return 1;
250 //Double_t x,y,z; t->GetGlobalXYZat(rr,x,y,z);
251 //if (TMath::Abs(y)<yyr) t->PropagateTo(rr,dr,x0r);
252 if (!t->PropagateTo(rs,ds)) return 1;
253 } else if (t->GetX() < rs) {
254 if (!t->PropagateTo(rs,-ds)) return 1;
255 //Double_t x,y,z; t->GetGlobalXYZat(rr,x,y,z);
256 //if (TMath::Abs(y)<yyr) t->PropagateTo(rr,-dr,x0r);
257 if (!t->PropagateTo(rcd,-dcd,x0cd)) return 1;
ba1a3e1a 258 if (!t->PropagateTo(riw+0.001,-diw,x0iw)) return 1;
880f41b9 259 } else {
260 ::Error("CorrectForDeadZoneMaterial","track is already in the dead zone !");
261 return 1;
262 }
263
264 return 0;
265}
266
af885e0f 267Int_t AliITStrackerV2::Clusters2Tracks(AliESDEvent *event) {
006b5f7f 268 //--------------------------------------------------------------------
c630aafd 269 // This functions reconstructs ITS tracks
270 // The clusters must be already loaded !
006b5f7f 271 //--------------------------------------------------------------------
c630aafd 272 TObjArray itsTracks(15000);
006b5f7f 273
c630aafd 274 {/* Read ESD tracks */
275 Int_t nentr=event->GetNumberOfTracks();
276 Info("Clusters2Tracks", "Number of ESD tracks: %d\n", nentr);
277 while (nentr--) {
278 AliESDtrack *esd=event->GetTrack(nentr);
279
ba1a3e1a 280 if ((esd->GetStatus()&AliESDtrack::kTPCin)==0) continue;
281 if (esd->GetStatus()&AliESDtrack::kTPCout) continue;
282 if (esd->GetStatus()&AliESDtrack::kITSin) continue;
c630aafd 283
284 AliITStrackV2 *t=0;
285 try {
286 t=new AliITStrackV2(*esd);
287 } catch (const Char_t *msg) {
288 Warning("Clusters2Tracks",msg);
289 delete t;
290 continue;
291 }
6c94f330 292 if (TMath::Abs(t->GetD(GetX(),GetY()))>4) {
ebd8369c 293 delete t;
294 continue;
295 }
006b5f7f 296
c630aafd 297 if (CorrectForDeadZoneMaterial(t)!=0) {
298 Warning("Clusters2Tracks",
299 "failed to correct for the material in the dead zone !\n");
300 delete t;
301 continue;
302 }
303 itsTracks.AddLast(t);
304 }
305 } /* End Read ESD tracks */
306
307 itsTracks.Sort();
308 Int_t nentr=itsTracks.GetEntriesFast();
15dd636f 309
c630aafd 310 Int_t ntrk=0;
311 for (fPass=0; fPass<2; fPass++) {
312 Int_t &constraint=fConstraint[fPass]; if (constraint<0) continue;
313 for (Int_t i=0; i<nentr; i++) {
314 AliITStrackV2 *t=(AliITStrackV2*)itsTracks.UncheckedAt(i);
15dd636f 315 if (t==0) continue; //this track has been already tracked
c630aafd 316 Int_t tpcLabel=t->GetLabel(); //save the TPC track label
317
318 ResetTrackToFollow(*t);
319 ResetBestTrack();
320
e50912db 321 for (FollowProlongation(); fI<AliITSgeomTGeo::GetNLayers(); fI++) {
15dd636f 322 while (TakeNextProlongation()) FollowProlongation();
c630aafd 323 }
324
de5d3595 325 if (fBestTrack.GetNumberOfClusters() == 0) continue;
15dd636f 326
c630aafd 327 if (fConstraint[fPass]) {
15dd636f 328 ResetTrackToFollow(*t);
329 if (!RefitAt(3.7, &fTrackToFollow, &fBestTrack)) continue;
330 ResetBestTrack();
331 }
332
c630aafd 333 fBestTrack.SetLabel(tpcLabel);
334 fBestTrack.CookdEdx();
335 CookLabel(&fBestTrack,0.); //For comparison only
336 fBestTrack.UpdateESDtrack(AliESDtrack::kITSin);
15dd636f 337 UseClusters(&fBestTrack);
c630aafd 338 delete itsTracks.RemoveAt(i);
339 ntrk++;
340 }
341 }
babd135a 342
c630aafd 343 itsTracks.Delete();
2257f27e 344
c630aafd 345 Info("Clusters2Tracks","Number of prolonged tracks: %d\n",ntrk);
346
347 return 0;
348}
349
af885e0f 350Int_t AliITStrackerV2::PropagateBack(AliESDEvent *event) {
c630aafd 351 //--------------------------------------------------------------------
352 // This functions propagates reconstructed ITS tracks back
353 // The clusters must be loaded !
354 //--------------------------------------------------------------------
355 Int_t nentr=event->GetNumberOfTracks();
356 Info("PropagateBack", "Number of ESD tracks: %d\n", nentr);
357
358 Int_t ntrk=0;
359 for (Int_t i=0; i<nentr; i++) {
360 AliESDtrack *esd=event->GetTrack(i);
361
ba1a3e1a 362 if ((esd->GetStatus()&AliESDtrack::kITSin)==0) continue;
363 if (esd->GetStatus()&AliESDtrack::kITSout) continue;
c630aafd 364
365 AliITStrackV2 *t=0;
366 try {
367 t=new AliITStrackV2(*esd);
368 } catch (const Char_t *msg) {
369 Warning("PropagateBack",msg);
370 delete t;
371 continue;
372 }
373
374 ResetTrackToFollow(*t);
375
376 // propagete to vertex [SR, GSI 17.02.2003]
a9459f9c 377 // Start Time measurement [SR, GSI 17.02.2003], corrected by I.Belikov
378 if (fTrackToFollow.PropagateTo(3.,0.0028,65.19)) {
6c94f330 379 if (fTrackToFollow.PropagateToVertex(event->GetVertex())) {
a9459f9c 380 fTrackToFollow.StartTimeIntegral();
381 }
382 fTrackToFollow.PropagateTo(3.,-0.0028,65.19);
383 }
c630aafd 384
6c94f330 385 fTrackToFollow.ResetCovariance(10.); fTrackToFollow.ResetClusters();
c630aafd 386 if (RefitAt(49.,&fTrackToFollow,t)) {
387 if (CorrectForDeadZoneMaterial(&fTrackToFollow)!=0) {
388 Warning("PropagateBack",
389 "failed to correct for the material in the dead zone !\n");
390 delete t;
391 continue;
392 }
393 fTrackToFollow.SetLabel(t->GetLabel());
ba1a3e1a 394 //fTrackToFollow.CookdEdx();
c630aafd 395 CookLabel(&fTrackToFollow,0.); //For comparison only
396 fTrackToFollow.UpdateESDtrack(AliESDtrack::kITSout);
15dd636f 397 UseClusters(&fTrackToFollow);
c630aafd 398 ntrk++;
399 }
400 delete t;
401 }
402
403 Info("PropagateBack","Number of back propagated ITS tracks: %d\n",ntrk);
61ab8ea8 404
83d73500 405 return 0;
406}
407
af885e0f 408Int_t AliITStrackerV2::RefitInward(AliESDEvent *event) {
83d73500 409 //--------------------------------------------------------------------
410 // This functions refits ITS tracks using the
411 // "inward propagated" TPC tracks
c630aafd 412 // The clusters must be loaded !
83d73500 413 //--------------------------------------------------------------------
c630aafd 414 Int_t nentr=event->GetNumberOfTracks();
415 Info("RefitInward", "Number of ESD tracks: %d\n", nentr);
416
417 Int_t ntrk=0;
418 for (Int_t i=0; i<nentr; i++) {
419 AliESDtrack *esd=event->GetTrack(i);
420
ba1a3e1a 421 if ((esd->GetStatus()&AliESDtrack::kITSout) == 0) continue;
422 if (esd->GetStatus()&AliESDtrack::kITSrefit) continue;
423 if (esd->GetStatus()&AliESDtrack::kTPCout)
15dd636f 424 if ((esd->GetStatus()&AliESDtrack::kTPCrefit)==0) continue;
c630aafd 425
426 AliITStrackV2 *t=0;
427 try {
428 t=new AliITStrackV2(*esd);
429 } catch (const Char_t *msg) {
430 Warning("RefitInward",msg);
431 delete t;
432 continue;
433 }
434
435 if (CorrectForDeadZoneMaterial(t)!=0) {
436 Warning("RefitInward",
437 "failed to correct for the material in the dead zone !\n");
438 delete t;
439 continue;
440 }
441
442 ResetTrackToFollow(*t);
443 fTrackToFollow.ResetClusters();
444
445 //Refitting...
ef7253ac 446 if (RefitAt(3.7, &fTrackToFollow, t, kTRUE)) {
c630aafd 447 fTrackToFollow.SetLabel(t->GetLabel());
448 fTrackToFollow.CookdEdx();
15dd636f 449 CookLabel(&fTrackToFollow,0.); //For comparison only
18856a77 450
49d13e89 451 if (fTrackToFollow.PropagateTo(3.,0.0028,65.19)) {//The beam pipe
452 AliESDtrack *esdTrack =fTrackToFollow.GetESDtrack();
453 esdTrack->UpdateTrackParams(&fTrackToFollow,AliESDtrack::kITSrefit);
454 Float_t r[3]={0.,0.,0.};
455 Double_t maxD=3.;
456 esdTrack->RelateToVertex(event->GetVertex(),GetBz(r),maxD);
457 ntrk++;
67c3dcbe 458 }
c630aafd 459 }
460 delete t;
461 }
462
463 Info("RefitInward","Number of refitted tracks: %d\n",ntrk);
83d73500 464
c630aafd 465 return 0;
466}
83d73500 467
006b5f7f 468AliCluster *AliITStrackerV2::GetCluster(Int_t index) const {
469 //--------------------------------------------------------------------
470 // Return pointer to a given cluster
471 //--------------------------------------------------------------------
472 Int_t l=(index & 0xf0000000) >> 28;
473 Int_t c=(index & 0x0fffffff) >> 00;
18856a77 474 return fgLayers[l].GetCluster(c);
006b5f7f 475}
476
477
478void AliITStrackerV2::FollowProlongation() {
479 //--------------------------------------------------------------------
480 //This function finds a track prolongation
481 //--------------------------------------------------------------------
c0dd5278 482 while (fI>fLastLayerToTrackTo) {
a9a2d814 483 Int_t i=fI-1;
8676d691 484
18856a77 485 AliITSlayer &layer=fgLayers[i];
a9a2d814 486 AliITStrackV2 &track=fTracks[i];
006b5f7f 487
14825d5a 488 Double_t r=layer.GetR();
61ab8ea8 489
a9a2d814 490 if (i==3 || i==1) {
18856a77 491 Double_t rs=0.5*(fgLayers[i+1].GetR() + r);
61ab8ea8 492 Double_t d=0.0034, x0=38.6;
493 if (i==1) {rs=9.; d=0.0097; x0=42;}
494 if (!fTrackToFollow.PropagateTo(rs,d,x0)) {
8676d691 495 //Warning("FollowProlongation","propagation failed !\n");
c0dd5278 496 return;
a9a2d814 497 }
006b5f7f 498 }
499
500 //find intersection
8602c008 501 Double_t phi,z;
502 if (!fTrackToFollow.GetPhiZat(r,phi,z)) {
8676d691 503 //Warning("FollowProlongation","failed to estimate track !\n");
c0dd5278 504 return;
006b5f7f 505 }
f363d377 506
006b5f7f 507 Int_t idet=layer.FindDetectorIndex(phi,z);
508 if (idet<0) {
8676d691 509 //Warning("FollowProlongation","failed to find a detector !\n");
c0dd5278 510 return;
006b5f7f 511 }
512
513 //propagate to the intersection
514 const AliITSdetector &det=layer.GetDetector(idet);
14825d5a 515 phi=det.GetPhi();
a9a2d814 516 if (!fTrackToFollow.Propagate(phi,det.GetR())) {
8676d691 517 //Warning("FollowProlongation","propagation failed !\n");
c0dd5278 518 return;
006b5f7f 519 }
520 fTrackToFollow.SetDetectorIndex(idet);
521
522 //Select possible prolongations and store the current track estimation
523 track.~AliITStrackV2(); new(&track) AliITStrackV2(fTrackToFollow);
44347160 524 Double_t dz=7*TMath::Sqrt(track.GetSigmaZ2() + AliITSReconstructor::GetRecoParam()->GetSigmaZ2(i));
525 Double_t dy=7*TMath::Sqrt(track.GetSigmaY2() + AliITSReconstructor::GetRecoParam()->GetSigmaY2(i));
8676d691 526 Double_t road=layer.GetRoad();
527 if (dz*dy>road*road) {
528 Double_t dd=TMath::Sqrt(dz*dy), scz=dz/dd, scy=dy/dd;
529 dz=road*scz; dy=road*scy;
530 }
b87bd7cd 531
44347160 532 //Double_t dz=4*TMath::Sqrt(track.GetSigmaZ2() + AliITSReconstructor::GetRecoParam()->GetSigmaZ2(i));
14825d5a 533 if (dz < 0.5*TMath::Abs(track.GetTgl())) dz=0.5*TMath::Abs(track.GetTgl());
44347160 534 if (dz > AliITSReconstructor::GetRecoParam()->GetMaxRoad()) {
8676d691 535 //Warning("FollowProlongation","too broad road in Z !\n");
c0dd5278 536 return;
006b5f7f 537 }
a9a2d814 538
15dd636f 539 if (TMath::Abs(fTrackToFollow.GetZ()-GetZ()) > r+dz) return;
a9a2d814 540
44347160 541 //Double_t dy=4*TMath::Sqrt(track.GetSigmaY2() + AliITSReconstructor::GetRecoParam()->GetSigmaY2(i));
14825d5a 542 if (dy < 0.5*TMath::Abs(track.GetSnp())) dy=0.5*TMath::Abs(track.GetSnp());
44347160 543 if (dy > AliITSReconstructor::GetRecoParam()->GetMaxRoad()) {
8676d691 544 //Warning("FollowProlongation","too broad road in Y !\n");
c0dd5278 545 return;
006b5f7f 546 }
a9a2d814 547
c219fd63 548 fI--;
549
7f6ddf58 550 Double_t zmin=track.GetZ() - dz;
006b5f7f 551 Double_t zmax=track.GetZ() + dz;
14825d5a 552 Double_t ymin=track.GetY() + r*phi - dy;
553 Double_t ymax=track.GetY() + r*phi + dy;
c219fd63 554 if (layer.SelectClusters(zmin,zmax,ymin,ymax)==0)
555 if (fLayersNotToSkip[fI]) return;
006b5f7f 556
15dd636f 557 if (!TakeNextProlongation())
558 if (fLayersNotToSkip[fI]) return;
559
006b5f7f 560 }
561
562 //deal with the best track
563 Int_t ncl=fTrackToFollow.GetNumberOfClusters();
564 Int_t nclb=fBestTrack.GetNumberOfClusters();
15dd636f 565 if (ncl)
566 if (ncl >= nclb) {
567 Double_t chi2=fTrackToFollow.GetChi2();
44347160 568 if (chi2/ncl < AliITSReconstructor::GetRecoParam()->GetChi2PerCluster()) {
15dd636f 569 if (ncl > nclb || chi2 < fBestTrack.GetChi2()) {
570 ResetBestTrack();
006b5f7f 571 }
15dd636f 572 }
006b5f7f 573 }
15dd636f 574
006b5f7f 575}
576
006b5f7f 577Int_t AliITStrackerV2::TakeNextProlongation() {
578 //--------------------------------------------------------------------
a9a2d814 579 // This function takes another track prolongation
580 //
581 // dEdx analysis by: Boris Batyunya, JINR, Boris.Batiounia@cern.ch
006b5f7f 582 //--------------------------------------------------------------------
18856a77 583 AliITSlayer &layer=fgLayers[fI];
4ab260d6 584 ResetTrackToFollow(fTracks[fI]);
006b5f7f 585
44347160 586 Double_t dz=7*TMath::Sqrt(fTrackToFollow.GetSigmaZ2() + AliITSReconstructor::GetRecoParam()->GetSigmaZ2(fI));
587 Double_t dy=7*TMath::Sqrt(fTrackToFollow.GetSigmaY2() + AliITSReconstructor::GetRecoParam()->GetSigmaY2(fI));
8676d691 588 Double_t road=layer.GetRoad();
589 if (dz*dy>road*road) {
590 Double_t dd=TMath::Sqrt(dz*dy), scz=dz/dd, scy=dy/dd;
591 dz=road*scz; dy=road*scy;
592 }
006b5f7f 593
00a7cc50 594 const AliITSRecPoint *c=0; Int_t ci=-1;
595 const AliITSRecPoint *cc=0; Int_t cci=-1;
44347160 596 Double_t chi2=AliITSReconstructor::GetRecoParam()->GetMaxChi2();
006b5f7f 597 while ((c=layer.GetNextCluster(ci))!=0) {
006b5f7f 598 Int_t idet=c->GetDetectorIndex();
15dd636f 599
4ab260d6 600 if (fTrackToFollow.GetDetectorIndex()!=idet) {
006b5f7f 601 const AliITSdetector &det=layer.GetDetector(idet);
4ab260d6 602 ResetTrackToFollow(fTracks[fI]);
603 if (!fTrackToFollow.Propagate(det.GetPhi(),det.GetR())) {
8676d691 604 //Warning("TakeNextProlongation","propagation failed !\n");
006b5f7f 605 continue;
606 }
4ab260d6 607 fTrackToFollow.SetDetectorIndex(idet);
608 if (TMath::Abs(fTrackToFollow.GetZ()-GetZ())>layer.GetR()+dz) continue;
006b5f7f 609 }
610
4ab260d6 611 if (TMath::Abs(fTrackToFollow.GetZ() - c->GetZ()) > dz) continue;
612 if (TMath::Abs(fTrackToFollow.GetY() - c->GetY()) > dy) continue;
006b5f7f 613
c219fd63 614 Double_t ch2=fTrackToFollow.GetPredictedChi2(c);
615 if (ch2 > chi2) continue;
616 chi2=ch2;
617 cc=c; cci=ci;
618 break;
006b5f7f 619 }
620
c219fd63 621 if (!cc) return 0;
006b5f7f 622
1f3e997f 623 {// Take into account the mis-alignment
624 Double_t x = fTrackToFollow.GetX() + cc->GetX();
625 if (!fTrackToFollow.PropagateTo(x,0.,0.)) return 0;
626 }
c219fd63 627 if (!fTrackToFollow.Update(cc,chi2,(fI<<28)+cci)) {
8676d691 628 //Warning("TakeNextProlongation","filtering failed !\n");
006b5f7f 629 return 0;
630 }
15dd636f 631
4ab260d6 632 if (fTrackToFollow.GetNumberOfClusters()>1)
6c94f330 633 if (TMath::Abs(fTrackToFollow.GetD(GetX(),GetY()))>4) return 0;
4ab260d6 634
a9a2d814 635 fTrackToFollow.
c219fd63 636 SetSampledEdx(cc->GetQ(),fTrackToFollow.GetNumberOfClusters()-1); //b.b.
a9a2d814 637
638 {
880f41b9 639 Double_t x0;
61ab8ea8 640 Double_t d=layer.GetThickness(fTrackToFollow.GetY(),fTrackToFollow.GetZ(),x0);
880f41b9 641 fTrackToFollow.CorrectForMaterial(d,x0);
a9a2d814 642 }
4ab260d6 643
a9a2d814 644 if (fConstraint[fPass]) {
4ab260d6 645 Double_t d=GetEffectiveThickness(0,0); //Think of this !!!!
8676d691 646 Double_t xyz[]={GetX(),GetY(),GetZ()};
647 Double_t ers[]={GetSigmaX(),GetSigmaY(),GetSigmaZ()};
648 fTrackToFollow.Improve(d,xyz,ers);
a9a2d814 649 }
006b5f7f 650
006b5f7f 651 return 1;
652}
653
654
6c94f330 655AliITStrackerV2::AliITSlayer::AliITSlayer():
656 fR(0.),
657 fPhiOffset(0.),
658 fNladders(0),
659 fZOffset(0.),
660 fNdetectors(0),
661 fDetectors(0),
662 fNsel(0),
663 fRoad(2*fR*TMath::Sqrt(3.14/1.)) //assuming that there's only one cluster
664{
006b5f7f 665 //--------------------------------------------------------------------
666 //default AliITSlayer constructor
667 //--------------------------------------------------------------------
c219fd63 668
669 for (Int_t i=0; i<kNsector; i++) fN[i]=0;
c219fd63 670
006b5f7f 671}
672
673AliITStrackerV2::AliITSlayer::
6c94f330 674AliITSlayer(Double_t r,Double_t p,Double_t z,Int_t nl,Int_t nd):
675 fR(r),
676 fPhiOffset(p),
677 fNladders(nl),
678 fZOffset(z),
679 fNdetectors(nd),
680 fDetectors(new AliITSdetector[nl*nd]),
681 fNsel(0),
682 fRoad(2*r*TMath::Sqrt(3.14/1.)) //assuming that there's only one cluster
683{
006b5f7f 684 //--------------------------------------------------------------------
685 //main AliITSlayer constructor
686 //--------------------------------------------------------------------
006b5f7f 687
c219fd63 688 for (Int_t i=0; i<kNsector; i++) fN[i]=0;
c219fd63 689
e50912db 690 for (Int_t i=0; i<AliITSRecoParam::fgkMaxClusterPerLayer; i++) fClusters[i]=0;
b87bd7cd 691
006b5f7f 692}
693
694AliITStrackerV2::AliITSlayer::~AliITSlayer() {
695 //--------------------------------------------------------------------
696 // AliITSlayer destructor
697 //--------------------------------------------------------------------
698 delete[] fDetectors;
c219fd63 699 ResetClusters();
006b5f7f 700}
701
61ab8ea8 702void AliITStrackerV2::AliITSlayer::ResetClusters() {
703 //--------------------------------------------------------------------
704 // This function removes loaded clusters
705 //--------------------------------------------------------------------
c219fd63 706 for (Int_t s=0; s<kNsector; s++) {
707 Int_t &n=fN[s];
708 while (n) {
709 n--;
710 delete fClusters[s*kMaxClusterPerSector+n];
711 }
712 }
61ab8ea8 713}
714
b87bd7cd 715void AliITStrackerV2::AliITSlayer::ResetRoad() {
716 //--------------------------------------------------------------------
717 // This function calculates the road defined by the cluster density
718 //--------------------------------------------------------------------
719 Int_t n=0;
c219fd63 720 for (Int_t s=0; s<kNsector; s++) {
721 Int_t i=fN[s];
722 while (i--)
723 if (TMath::Abs(fClusters[s*kMaxClusterPerSector+i]->GetZ())<fR) n++;
b87bd7cd 724 }
725 if (n>1) fRoad=2*fR*TMath::Sqrt(3.14/n);
726}
727
00a7cc50 728Int_t AliITStrackerV2::AliITSlayer::InsertCluster(AliITSRecPoint *c) {
006b5f7f 729 //--------------------------------------------------------------------
c219fd63 730 // This function inserts a cluster to this layer in increasing
731 // order of the cluster's fZ
006b5f7f 732 //--------------------------------------------------------------------
c219fd63 733 Float_t circ=TMath::TwoPi()*fR;
734 Int_t sec=Int_t(kNsector*c->GetPhiR()/circ);
81e97e0d 735 if (sec>=kNsector) {
736 ::Error("InsertCluster","Wrong sector !\n");
737 return 1;
738 }
c219fd63 739 Int_t &n=fN[sec];
740 if (n>=kMaxClusterPerSector) {
741 ::Error("InsertCluster","Too many clusters !\n");
742 return 1;
006b5f7f 743 }
c219fd63 744 if (n==0) fClusters[sec*kMaxClusterPerSector]=c;
745 else {
746 Int_t i=FindClusterIndex(c->GetZ(),sec);
747 Int_t k=n-i+sec*kMaxClusterPerSector;
00a7cc50 748 memmove(fClusters+i+1 ,fClusters+i,k*sizeof(AliITSRecPoint*));
c219fd63 749 fClusters[i]=c;
750 }
751 n++;
006b5f7f 752 return 0;
753}
754
c219fd63 755Int_t
756AliITStrackerV2::AliITSlayer::FindClusterIndex(Float_t z,Int_t s) const {
006b5f7f 757 //--------------------------------------------------------------------
c219fd63 758 // For the sector "s", this function returns the index of the first
759 // with its fZ >= "z".
006b5f7f 760 //--------------------------------------------------------------------
c219fd63 761 Int_t nc=fN[s];
762 if (nc==0) return kMaxClusterPerSector*s;
763
764 Int_t b=kMaxClusterPerSector*s;
765 if (z <= fClusters[b]->GetZ()) return b;
766
767 Int_t e=b+nc-1;
768 if (z > fClusters[e]->GetZ()) return e+1;
769
770 Int_t m=(b+e)/2;
006b5f7f 771 for (; b<e; m=(b+e)/2) {
772 if (z > fClusters[m]->GetZ()) b=m+1;
773 else e=m;
774 }
775 return m;
776}
777
c219fd63 778Int_t AliITStrackerV2::AliITSlayer::
779SelectClusters(Float_t zmin,Float_t zmax,Float_t ymin, Float_t ymax) {
006b5f7f 780 //--------------------------------------------------------------------
c219fd63 781 // This function selects clusters within the "window"
006b5f7f 782 //--------------------------------------------------------------------
c219fd63 783 Float_t circ=fR*TMath::TwoPi();
784
785 if (ymin>circ) ymin-=circ; else if (ymin<0) ymin+=circ;
786 if (ymax>circ) ymax-=circ; else if (ymax<0) ymax+=circ;
787
521f4796 788 Int_t i1=Int_t(kNsector*ymin/circ); if (i1==kNsector) i1--;
c219fd63 789 if (fN[i1]!=0) {
790 Float_t ym = (ymax<ymin) ? ymax+circ : ymax;
791 Int_t i=FindClusterIndex(zmin,i1), imax=i1*kMaxClusterPerSector+fN[i1];
792 for (; i<imax; i++) {
00a7cc50 793 AliITSRecPoint *c=fClusters[i];
c219fd63 794 if (c->IsUsed()) continue;
795 if (c->GetZ()>zmax) break;
796 if (c->GetPhiR()<=ymin) continue;
797 if (c->GetPhiR()>ym) continue;
798 fIndex[fNsel++]=i;
799 }
800 }
801
521f4796 802 Int_t i2=Int_t(kNsector*ymax/circ); if (i2==kNsector) i2--;
c219fd63 803 if (i2==i1) return fNsel;
804
805 if (fN[i2]!=0) {
806 Float_t ym = (ymin>ymax) ? ymin-circ : ymin;
807 Int_t i=FindClusterIndex(zmin,i2), imax=i2*kMaxClusterPerSector+fN[i2];
808 for (; i<imax; i++) {
00a7cc50 809 AliITSRecPoint *c=fClusters[i];
c219fd63 810 if (c->IsUsed()) continue;
811 if (c->GetZ()>zmax) break;
812 if (c->GetPhiR()<=ym) continue;
813 if (c->GetPhiR()>ymax) continue;
814 fIndex[fNsel++]=i;
815 }
816 }
817
818 return fNsel;
006b5f7f 819}
820
00a7cc50 821const AliITSRecPoint *AliITStrackerV2::AliITSlayer::GetNextCluster(Int_t &ci){
006b5f7f 822 //--------------------------------------------------------------------
823 // This function returns clusters within the "window"
824 //--------------------------------------------------------------------
00a7cc50 825 AliITSRecPoint *c=0;
c219fd63 826 ci=-1;
827 if (fNsel) {
828 fNsel--;
829 ci=fIndex[fNsel];
830 c=fClusters[ci];
006b5f7f 831 }
c219fd63 832 return c;
833}
7f6ddf58 834
c219fd63 835Int_t AliITStrackerV2::AliITSlayer::GetNumberOfClusters() const {
836 Int_t n=0;
837 for (Int_t s=0; s<kNsector; s++) n+=fN[s];
838 return n;
006b5f7f 839}
840
c219fd63 841Int_t
842AliITStrackerV2::AliITSlayer::FindDetectorIndex(Double_t phi,Double_t z)const {
006b5f7f 843 //--------------------------------------------------------------------
844 //This function finds the detector crossed by the track
845 //--------------------------------------------------------------------
31fb8575 846 Double_t dphi;
847 if (fZOffset<0) // old geometry
848 dphi = -(phi-fPhiOffset);
849 else // new geometry
850 dphi = phi-fPhiOffset;
851
006b5f7f 852 if (dphi < 0) dphi += 2*TMath::Pi();
853 else if (dphi >= 2*TMath::Pi()) dphi -= 2*TMath::Pi();
854 Int_t np=Int_t(dphi*fNladders*0.5/TMath::Pi()+0.5);
3e3e8427 855 if (np>=fNladders) np-=fNladders;
856 if (np<0) np+=fNladders;
006b5f7f 857
858 Double_t dz=fZOffset-z;
859 Int_t nz=Int_t(dz*(fNdetectors-1)*0.5/fZOffset+0.5);
3e3e8427 860 if (nz>=fNdetectors) return -1;
861 if (nz<0) return -1;
006b5f7f 862
006b5f7f 863 return np*fNdetectors + nz;
864}
865
866Double_t
61ab8ea8 867AliITStrackerV2::AliITSlayer::GetThickness(Double_t y,Double_t z,Double_t &x0)
868const {
a9a2d814 869 //--------------------------------------------------------------------
870 //This function returns the layer thickness at this point (units X0)
871 //--------------------------------------------------------------------
872 Double_t d=0.0085;
61ab8ea8 873 x0=21.82;
a9a2d814 874
875 if (43<fR&&fR<45) { //SSD2
61ab8ea8 876 Double_t dd=0.0034;
877 d=dd;
878 if (TMath::Abs(y-0.00)>3.40) d+=dd;
879 if (TMath::Abs(y-1.90)<0.45) {d+=(0.013-0.0034);}
880 if (TMath::Abs(y+1.90)<0.45) {d+=(0.013-0.0034);}
a9a2d814 881 for (Int_t i=0; i<12; i++) {
61ab8ea8 882 if (TMath::Abs(z-3.9*(i+0.5))<0.15) {
883 if (TMath::Abs(y-0.00)>3.40) d+=dd;
884 d+=0.0034;
885 break;
886 }
887 if (TMath::Abs(z+3.9*(i+0.5))<0.15) {
888 if (TMath::Abs(y-0.00)>3.40) d+=dd;
889 d+=0.0034;
890 break;
891 }
892 if (TMath::Abs(z-3.4-3.9*i)<0.50) {d+=(0.016-0.0034); break;}
893 if (TMath::Abs(z+0.5+3.9*i)<0.50) {d+=(0.016-0.0034); break;}
a9a2d814 894 }
895 } else
896 if (37<fR&&fR<41) { //SSD1
61ab8ea8 897 Double_t dd=0.0034;
898 d=dd;
899 if (TMath::Abs(y-0.00)>3.40) d+=dd;
900 if (TMath::Abs(y-1.90)<0.45) {d+=(0.013-0.0034);}
901 if (TMath::Abs(y+1.90)<0.45) {d+=(0.013-0.0034);}
a9a2d814 902 for (Int_t i=0; i<11; i++) {
61ab8ea8 903 if (TMath::Abs(z-3.9*i)<0.15) {
904 if (TMath::Abs(y-0.00)>3.40) d+=dd;
905 d+=dd;
906 break;
907 }
908 if (TMath::Abs(z+3.9*i)<0.15) {
909 if (TMath::Abs(y-0.00)>3.40) d+=dd;
910 d+=dd;
911 break;
912 }
913 if (TMath::Abs(z-1.85-3.9*i)<0.50) {d+=(0.016-0.0034); break;}
914 if (TMath::Abs(z+2.05+3.9*i)<0.50) {d+=(0.016-0.0034); break;}
a9a2d814 915 }
916 } else
917 if (13<fR&&fR<26) { //SDD
61ab8ea8 918 Double_t dd=0.0033;
919 d=dd;
920 if (TMath::Abs(y-0.00)>3.30) d+=dd;
921
922 if (TMath::Abs(y-1.80)<0.55) {
923 d+=0.016;
924 for (Int_t j=0; j<20; j++) {
925 if (TMath::Abs(z+0.7+1.47*j)<0.12) {d+=0.08; x0=9.; break;}
926 if (TMath::Abs(z-0.7-1.47*j)<0.12) {d+=0.08; x0=9.; break;}
927 }
928 }
929 if (TMath::Abs(y+1.80)<0.55) {
930 d+=0.016;
931 for (Int_t j=0; j<20; j++) {
932 if (TMath::Abs(z-0.7-1.47*j)<0.12) {d+=0.08; x0=9.; break;}
933 if (TMath::Abs(z+0.7+1.47*j)<0.12) {d+=0.08; x0=9.; break;}
934 }
935 }
936
937 for (Int_t i=0; i<4; i++) {
938 if (TMath::Abs(z-7.3*i)<0.60) {
939 d+=dd;
940 if (TMath::Abs(y-0.00)>3.30) d+=dd;
941 break;
942 }
943 if (TMath::Abs(z+7.3*i)<0.60) {
944 d+=dd;
945 if (TMath::Abs(y-0.00)>3.30) d+=dd;
946 break;
947 }
a9a2d814 948 }
949 } else
950 if (6<fR&&fR<8) { //SPD2
61ab8ea8 951 Double_t dd=0.0063; x0=21.5;
952 d=dd;
953 if (TMath::Abs(y-3.08)>0.5) d+=dd;
954 //if (TMath::Abs(y-3.08)>0.45) d+=dd;
955 if (TMath::Abs(y-3.03)<0.10) {d+=0.014;}
a9a2d814 956 } else
957 if (3<fR&&fR<5) { //SPD1
61ab8ea8 958 Double_t dd=0.0063; x0=21.5;
959 d=dd;
960 if (TMath::Abs(y+0.21)>0.6) d+=dd;
961 //if (TMath::Abs(y+0.21)>0.45) d+=dd;
962 if (TMath::Abs(y+0.10)<0.10) {d+=0.014;}
a9a2d814 963 }
964
a9a2d814 965 return d;
966}
006b5f7f 967
a9a2d814 968Double_t AliITStrackerV2::GetEffectiveThickness(Double_t y,Double_t z) const
006b5f7f 969{
970 //--------------------------------------------------------------------
a9a2d814 971 //Returns the thickness between the current layer and the vertex (units X0)
006b5f7f 972 //--------------------------------------------------------------------
61ab8ea8 973 Double_t d=0.0028*3*3; //beam pipe
974 Double_t x0=0;
006b5f7f 975
18856a77 976 Double_t xn=fgLayers[fI].GetR();
006b5f7f 977 for (Int_t i=0; i<fI; i++) {
18856a77 978 Double_t xi=fgLayers[i].GetR();
979 d+=fgLayers[i].GetThickness(y,z,x0)*xi*xi;
006b5f7f 980 }
981
982 if (fI>1) {
61ab8ea8 983 Double_t xi=9.;
984 d+=0.0097*xi*xi;
006b5f7f 985 }
986
987 if (fI>3) {
18856a77 988 Double_t xi=0.5*(fgLayers[3].GetR()+fgLayers[4].GetR());
61ab8ea8 989 d+=0.0034*xi*xi;
006b5f7f 990 }
61ab8ea8 991
006b5f7f 992 return d/(xn*xn);
993}
994
ef7253ac 995Bool_t AliITStrackerV2::RefitAt(Double_t xx,AliITStrackV2 *t,
996 const AliITStrackV2 *c, Bool_t extra) {
4ab260d6 997 //--------------------------------------------------------------------
c630aafd 998 // This function refits the track "t" at the position "x" using
999 // the clusters from "c"
ef7253ac 1000 // If "extra"==kTRUE,
1001 // the clusters from overlapped modules get attached to "t"
4ab260d6 1002 //--------------------------------------------------------------------
e50912db 1003 Int_t index[AliITSgeomTGeo::kNLayers];
880f41b9 1004 Int_t k;
e50912db 1005 for (k=0; k<AliITSgeomTGeo::GetNLayers(); k++) index[k]=-1;
c630aafd 1006 Int_t nc=c->GetNumberOfClusters();
880f41b9 1007 for (k=0; k<nc; k++) {
c630aafd 1008 Int_t idx=c->GetClusterIndex(k),nl=(idx&0xf0000000)>>28;
880f41b9 1009 index[nl]=idx;
1010 }
880f41b9 1011
4ab260d6 1012 Int_t from, to, step;
ee34184f 1013 if (xx > t->GetX()) {
e50912db 1014 from=0; to=AliITSgeomTGeo::GetNLayers();
4ab260d6 1015 step=+1;
1016 } else {
e50912db 1017 from=AliITSgeomTGeo::GetNLayers()-1; to=-1;
4ab260d6 1018 step=-1;
1019 }
1020
1021 for (Int_t i=from; i != to; i += step) {
18856a77 1022 AliITSlayer &layer=fgLayers[i];
4ab260d6 1023 Double_t r=layer.GetR();
1024
1025 {
1026 Double_t hI=i-0.5*step;
880f41b9 1027 if (TMath::Abs(hI-1.5)<0.01 || TMath::Abs(hI-3.5)<0.01) {
18856a77 1028 Double_t rs=0.5*(fgLayers[i-step].GetR() + r);
61ab8ea8 1029 Double_t d=0.0034, x0=38.6;
880f41b9 1030 if (TMath::Abs(hI-1.5)<0.01) {rs=9.; d=0.0097; x0=42;}
1031 if (!t->PropagateTo(rs,-step*d,x0)) {
4ab260d6 1032 return kFALSE;
1033 }
1034 }
1035 }
1036
880f41b9 1037 // remember old position [SR, GSI 18.02.2003]
1038 Double_t oldX=0., oldY=0., oldZ=0.;
1039 if (t->IsStartedTimeIntegral() && step==1) {
1040 t->GetGlobalXYZat(t->GetX(),oldX,oldY,oldZ);
1041 }
1042 //
1043
8602c008 1044 Double_t phi,z;
1045 if (!t->GetPhiZat(r,phi,z)) {
4ab260d6 1046 return kFALSE;
1047 }
8602c008 1048
4ab260d6 1049 Int_t idet=layer.FindDetectorIndex(phi,z);
1050 if (idet<0) {
1051 return kFALSE;
1052 }
1053 const AliITSdetector &det=layer.GetDetector(idet);
1054 phi=det.GetPhi();
1055 if (!t->Propagate(phi,det.GetR())) {
1056 return kFALSE;
1057 }
1058 t->SetDetectorIndex(idet);
1059
00a7cc50 1060 const AliITSRecPoint *cl=0;
44347160 1061 Double_t maxchi2=AliITSReconstructor::GetRecoParam()->GetMaxChi2();
4ab260d6 1062
1063 Int_t idx=index[i];
c0342e67 1064 if (idx>=0) {
00a7cc50 1065 const AliITSRecPoint *c=(AliITSRecPoint *)GetCluster(idx);
4ab260d6 1066 if (idet != c->GetDetectorIndex()) {
1067 idet=c->GetDetectorIndex();
1068 const AliITSdetector &det=layer.GetDetector(idet);
1069 if (!t->Propagate(det.GetPhi(),det.GetR())) {
1070 return kFALSE;
1071 }
1072 t->SetDetectorIndex(idet);
1073 }
1074 Double_t chi2=t->GetPredictedChi2(c);
c630aafd 1075 if (chi2<maxchi2) {
1076 cl=c;
1077 maxchi2=chi2;
1078 } else {
1079 return kFALSE;
1080 }
4ab260d6 1081 }
ef7253ac 1082
4ab260d6 1083 if (cl) {
1f3e997f 1084 // Take into account the mis-alignment
1085 Double_t x=t->GetX()+cl->GetX();
1086 if (!t->PropagateTo(x,0.,0.)) return kFALSE;
4ab260d6 1087 if (!t->Update(cl,maxchi2,idx)) {
1088 return kFALSE;
1089 }
880f41b9 1090 t->SetSampledEdx(cl->GetQ(),t->GetNumberOfClusters()-1);
4ab260d6 1091 }
1092
1093 {
61ab8ea8 1094 Double_t x0;
1095 Double_t d=layer.GetThickness(t->GetY(),t->GetZ(),x0);
1096 t->CorrectForMaterial(-step*d,x0);
4ab260d6 1097 }
880f41b9 1098
ef7253ac 1099 if (extra) { //search for extra clusters
1100 AliITStrackV2 tmp(*t);
44347160 1101 Double_t dz=4*TMath::Sqrt(tmp.GetSigmaZ2()+AliITSReconstructor::GetRecoParam()->GetSigmaZ2(i));
ef7253ac 1102 if (dz < 0.5*TMath::Abs(tmp.GetTgl())) dz=0.5*TMath::Abs(tmp.GetTgl());
44347160 1103 Double_t dy=4*TMath::Sqrt(t->GetSigmaY2()+AliITSReconstructor::GetRecoParam()->GetSigmaY2(i));
ef7253ac 1104 if (dy < 0.5*TMath::Abs(tmp.GetSnp())) dy=0.5*TMath::Abs(tmp.GetSnp());
1105 Double_t zmin=t->GetZ() - dz;
1106 Double_t zmax=t->GetZ() + dz;
1107 Double_t ymin=t->GetY() + phi*r - dy;
1108 Double_t ymax=t->GetY() + phi*r + dy;
1109 layer.SelectClusters(zmin,zmax,ymin,ymax);
1110
1111 const AliITSRecPoint *c=0; Int_t ci=-1,cci=-1;
44347160 1112 Double_t maxchi2=1000.*AliITSReconstructor::GetRecoParam()->GetMaxChi2(), tolerance=0.1;
ef7253ac 1113 while ((c=layer.GetNextCluster(ci))!=0) {
1114 if (idet == c->GetDetectorIndex()) continue;
1115
1116 const AliITSdetector &det=layer.GetDetector(c->GetDetectorIndex());
1117
1118 if (!tmp.Propagate(det.GetPhi(),det.GetR())) continue;
1119
1120 if (TMath::Abs(tmp.GetZ() - c->GetZ()) > tolerance) continue;
1121 if (TMath::Abs(tmp.GetY() - c->GetY()) > tolerance) continue;
1122
1123 Double_t chi2=tmp.GetPredictedChi2(c);
1124 if (chi2<maxchi2) { maxchi2=chi2; cci=ci; }
1125 }
1126 if (cci>=0) t->SetExtraCluster(i,(i<<28)+cci);
1127 }
1128
880f41b9 1129 // track time update [SR, GSI 17.02.2003]
1130 if (t->IsStartedTimeIntegral() && step==1) {
1131 Double_t newX, newY, newZ;
1132 t->GetGlobalXYZat(t->GetX(),newX,newY,newZ);
1133 Double_t dL2 = (oldX-newX)*(oldX-newX) + (oldY-newY)*(oldY-newY) +
1134 (oldZ-newZ)*(oldZ-newZ);
1135 t->AddTimeStep(TMath::Sqrt(dL2));
1136 }
1137 //
4ab260d6 1138
1139 }
1140
ee34184f 1141 if (!t->PropagateTo(xx,0.,0.)) return kFALSE;
4ab260d6 1142 return kTRUE;
1143}
1144
b87bd7cd 1145void AliITStrackerV2::UseClusters(const AliKalmanTrack *t, Int_t from) const {
1146 //--------------------------------------------------------------------
1147 // This function marks clusters assigned to the track
1148 //--------------------------------------------------------------------
1149 AliTracker::UseClusters(t,from);
880f41b9 1150
5482d29d 1151 Int_t clusterIndex = t->GetClusterIndex(0);
1152 AliITSRecPoint *c= 0x0;
1153
1154 if (clusterIndex>-1)
1155 c = (AliITSRecPoint *)GetCluster(clusterIndex);
d920bdee 1156 if (c && c->GetSigmaZ2()>0.1) c->UnUse();
5482d29d 1157
1158 c = 0x0;
1159 clusterIndex = t->GetClusterIndex(1);
1160 if (clusterIndex>-1)
1161 c=(AliITSRecPoint *)GetCluster(clusterIndex);
d920bdee 1162 if (c && c->GetSigmaZ2()>0.1) c->UnUse();
880f41b9 1163
b87bd7cd 1164}