1 /**************************************************************************
2 * Copyright(c) 1998-2003, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
18 ////////////////////////////////////////////////////
19 // Stand alone tracker class //
20 // Origin: Elisabetta Crescio //
21 // e-mail: crescio@to.infn.it //
22 // tracks are saved as AliITStrackV2 objects //
23 ////////////////////////////////////////////////////
29 #include <TObjArray.h>
33 #include "AliESDVertex.h"
34 #include "AliESDtrack.h"
35 #include "AliITSVertexer.h"
36 #include "AliITSclusterTable.h"
37 #include "AliITSRecPoint.h"
38 #include "AliITSgeom.h"
39 #include "AliITStrackSA.h"
40 #include "AliITStrackerSA.h"
43 ClassImp(AliITStrackerSA)
45 //____________________________________________________________________________
46 AliITStrackerSA::AliITStrackerSA():AliITStrackerMI(){
47 // Default constructor
51 //____________________________________________________________________________
52 AliITStrackerSA::AliITStrackerSA(AliITSgeom *geom):AliITStrackerMI(geom)
54 // Standard constructor (Vertex is known and passed to this obj.)
61 //____________________________________________________________________________
62 AliITStrackerSA::AliITStrackerSA(AliITSgeom *geom, AliESDVertex *vert):AliITStrackerMI(geom)
64 // Standard constructor (Vertex is known and passed to this obj.)
71 //____________________________________________________________________________
72 AliITStrackerSA::AliITStrackerSA(AliITSgeom *geom, AliITSVertexer *vertexer):AliITStrackerMI(geom)
74 // Standard constructor (Vertex is unknown - vertexer is passed to this obj)
81 //____________________________________________________________________________
82 AliITStrackerSA::AliITStrackerSA(const AliITStrackerSA& tracker):AliITStrackerMI(){
84 fPhiEstimate = tracker.fPhiEstimate;
85 for(Int_t i=0;i<2;i++){
86 fPoint1[i]=tracker.fPoint1[i];
87 fPoint2[i]=tracker.fPoint2[i];
88 fPoint3[i]=tracker.fPoint3[i];
89 fPointc[i]=tracker.fPointc[i];
91 fLambdac = tracker.fLambdac;
92 fPhic = tracker.fPhic;
93 fCoef1 = tracker.fCoef1;
94 fCoef2 = tracker.fCoef2;
95 fCoef3 = tracker.fCoef3;
96 fNloop = tracker.fNloop;
97 fPhiWin = tracker.fPhiWin;
98 fLambdaWin = tracker.fLambdaWin;
99 if(tracker.fVertexer && tracker.fVert){
100 fVert = new AliESDVertex(*tracker.fVert);
103 fVert = tracker.fVert;
105 fVertexer = tracker.fVertexer;
106 fGeom = tracker.fGeom;
107 fListOfTracks = tracker.fListOfTracks;
108 for(Int_t i=0;i<fGeom->GetNlayers();i++){
109 fCluLayer[i] = tracker.fCluLayer[i];
110 fCluCoord[i] = tracker.fCluCoord[i];
113 //______________________________________________________________________
114 AliITStrackerSA& AliITStrackerSA::operator=(const AliITStrackerSA& /*source*/){
115 // Assignment operator. This is a function which is not allowed to be
117 Error("operator=","Assignment operator not allowed\n");
121 //____________________________________________________________________________
122 AliITStrackerSA::~AliITStrackerSA(){
124 // if fVertexer is not null, the AliESDVertex obj. is owned by this class
125 // and is deleted here
127 if(fVert)delete fVert;
132 if(fPhiWin)delete []fPhiWin;
133 if(fLambdaWin)delete []fLambdaWin;
134 fListOfTracks->Delete();
136 for(Int_t i=0;i<fGeom->GetNlayers();i++){
138 fCluLayer[i]->Delete();
145 for(Int_t i=0;i<fGeom->GetNlayers();i++){
147 fCluCoord[i]->Delete();
157 //____________________________________________________________________________
158 void AliITStrackerSA::Init(){
159 // Reset all data members
161 for(Int_t i=0;i<3;i++){fPoint1[i]=0;fPoint2[i]=0;fPoint3[i]=0;}
175 fListOfTracks=new TObjArray(0,0);
179 //_______________________________________________________________________
180 void AliITStrackerSA::ResetForFinding(){
181 // Reset data members used in all loops during track finding
183 for(Int_t i=0;i<3;i++){fPoint1[i]=0;fPoint2[i]=0;fPoint3[i]=0;}
191 fListOfTracks->Delete();
196 //______________________________________________________________________
197 Int_t AliITStrackerSA::FindTracks(AliESD* event){
199 // Track finder using the ESD object
202 //controllare numero cluster sui layer1 e 2 (morti?)
203 //non trova tracce...controllare..
206 Fatal("FindTracks","ITS cluster tree is not accessed - Abort!!!\n Please use method SetClusterTree to pass the pointer to the tree\n");
211 //Reads event and mark clusters of traks already found, with flag kITSin
212 Int_t nentr=event->GetNumberOfTracks();
214 AliESDtrack *track=event->GetTrack(nentr);
215 if (track->GetStatus()&AliESDtrack::kITSin==AliESDtrack::kITSin){
217 Int_t ncl = track->GetITSclusters(idx);
218 for(Int_t k=0;k<ncl;k++){
219 AliITSRecPoint* cll = (AliITSRecPoint*)GetCluster(idx[k]);
220 cll->SetBit(kSAflag);
225 Double_t primaryVertex[3];
226 event->GetVertex()->GetXYZ(primaryVertex);
227 //Creates TClonesArray with clusters for each layer. The clusters already used
228 //by AliITStrackerMI are not considered
230 Int_t nclusters[6]={0,0,0,0,0,0};
231 Int_t dmar[6]={0,0,0,0,0,0};
232 fCluLayer = new TClonesArray*[fGeom->GetNlayers()];
233 fCluCoord = new TClonesArray*[fGeom->GetNlayers()];
235 for(Int_t i=0;i<fGeom->GetNlayers();i++){
236 AliITSlayer &layer=fgLayers[i];
237 for(Int_t cli=0;cli<layer.GetNumberOfClusters();cli++){
238 AliITSRecPoint* cls = (AliITSRecPoint*)layer.GetCluster(cli);
239 if(cls->TestBit(kSAflag)==kTRUE) continue; //clusters used by TPC prol.
240 if(cls->GetQ()==0) continue; //fake clusters dead zones
244 fCluLayer[i] = new TClonesArray("AliITSRecPoint",nclusters[i]);
245 fCluCoord[i] = new TClonesArray("AliITSclusterTable",nclusters[i]);
249 Int_t * firstmod = new Int_t[fGeom->GetNlayers()];
250 for(Int_t i=0;i<fGeom->GetNlayers();i++){
251 firstmod[i]=fGeom->GetModuleIndex(i+1,1,1);
254 for(Int_t ilay=0;ilay<fGeom->GetNlayers();ilay++){
255 TClonesArray &clulay = *fCluLayer[ilay];
256 TClonesArray &clucoo = *fCluCoord[ilay];
257 AliITSlayer &layer=fgLayers[ilay];
258 for(Int_t cli=0;cli<layer.GetNumberOfClusters();cli++){
259 AliITSRecPoint* cls = (AliITSRecPoint*)layer.GetCluster(cli);
260 if(cls->TestBit(kSAflag)==kTRUE) continue;
261 if(cls->GetQ()==0) continue;
262 Double_t phi=0;Double_t lambda=0;
263 Float_t x=0;Float_t y=0;Float_t z=0;
264 Float_t sx=0;Float_t sy=0;Float_t sz=0;
265 Int_t module = cls->GetDetectorIndex()+firstmod[ilay];
266 GetCoorAngles(cls,module,phi,lambda,x,y,z,primaryVertex);
267 GetCoorErrors(cls,module,sx,sy,sz);
268 new (clulay[dmar[ilay]]) AliITSRecPoint(*cls);
269 new (clucoo[dmar[ilay]]) AliITSclusterTable(x,y,z,sx,sy,sz,phi,lambda,cli);
278 //loop on the different windows
279 for(Int_t nloop=0;nloop<fNloop;nloop++){
280 for(Int_t ncl=0;ncl<fCluLayer[0]->GetEntries();ncl++){ //loop starting from layer 0
285 AliITSRecPoint* cl = (AliITSRecPoint*)fCluLayer[0]->At(ncl);
290 if (cl->GetQ()<=0) continue;
292 AliITSclusterTable* arr = (AliITSclusterTable*)GetClusterCoord(0,ncl);
293 fPhic = arr->GetPhi();
294 fLambdac = arr->GetLambda();
295 if (TMath::Abs(fLambdac)>0.26*TMath::Pi()) continue;
296 fPhiEstimate = fPhic;
297 AliITStrackSA* trs = new AliITStrackSA();
298 fPoint1[0]=primaryVertex[0];
299 fPoint1[1]=primaryVertex[1];
302 fPoint2[0]=arr->GetX();
303 fPoint2[1]=arr->GetY();
304 Int_t * nn = new Int_t[fGeom->GetNlayers()];//counter for clusters on each layer
305 for(Int_t i=0;i<fGeom->GetNlayers();i++){ nn[i]=0;}
306 nn[0] = SearchClusters(0,fPhiWin[nloop],fLambdaWin[nloop],trs,primaryVertex[2],pflag);
308 nn[1] = SearchClusters(1,fPhiWin[nloop],fLambdaWin[nloop],trs,primaryVertex[2],pflag);
311 fPoint3[0] = fPointc[0];
312 fPoint3[1] = fPointc[1];
314 nn[2] = SearchClusters(2,fPhiWin[nloop],fLambdaWin[nloop],trs,primaryVertex[2],pflag);
315 if(nn[1]==0 && nn[2]==0) pflag=0;
316 if(nn[2]!=0 && nn[1]!=0){ pflag=1; UpdatePoints();}
317 if(nn[2]!=0 && nn[1]==0){
319 fPoint3[0]=fPointc[0];
320 fPoint3[1]=fPointc[1];
323 nn[3] = SearchClusters(3,fPhiWin[nloop],fLambdaWin[nloop],trs,primaryVertex[2],pflag);
325 if(nn[3]!=0) UpdatePoints();
326 nn[4] = SearchClusters(4,fPhiWin[nloop],fLambdaWin[nloop],trs,primaryVertex[2],pflag);
328 if(nn[4]!=0) UpdatePoints();
329 nn[5] = SearchClusters(5,fPhiWin[nloop],fLambdaWin[nloop],trs,primaryVertex[2],pflag);
333 Int_t numberofpoints;
334 if(fSixPoints) numberofpoints=6; //check of the candidate track
335 else numberofpoints=5; //if track is good (with the required number
336 for(Int_t nnp=0;nnp<fGeom->GetNlayers();nnp++){ //of points) it is written on file
337 if(nn[nnp]!=0) layOK+=1;
339 if(layOK>=numberofpoints){
341 AliITStrackV2* tr2 = FitTrack(trs,primaryVertex);
345 AliESDtrack outtrack;
346 outtrack.UpdateTrackParams(tr2,AliESDtrack::kITSin);
347 event->AddTrack(&outtrack);
356 }//end loop on clusters of layer1
361 //if 5/6 points are required, second loop starting
362 //from second layer, to find tracks with point of
366 // counter for clusters on each layer
367 Int_t * nn = new Int_t[fGeom->GetNlayers()-1];
368 for(Int_t nloop=0;nloop<fNloop;nloop++){
369 Int_t ncl2=fCluLayer[1]->GetEntries();
370 while(ncl2--){ //loop starting from layer 2
373 AliITSRecPoint* cl = (AliITSRecPoint*)fCluLayer[1]->At(ncl2);
376 AliITSclusterTable* arr = (AliITSclusterTable*)GetClusterCoord(1,ncl2);
377 fPhic = arr->GetPhi();
378 fLambdac = arr->GetLambda();
379 fPhiEstimate = fPhic;
381 AliITStrackSA* trs = new AliITStrackSA();
382 fPoint1[0]=primaryVertex[0];
383 fPoint1[1]=primaryVertex[1];
385 fPoint2[0]=arr->GetX();
386 fPoint2[1]=arr->GetY();
387 for(Int_t kk=0;kk<fGeom->GetNlayers()-1;kk++)nn[kk] = 0;
388 nn[0] = SearchClusters(1,fPhiWin[nloop],fLambdaWin[nloop],
389 trs,primaryVertex[2],pflag);
390 nn[1] = SearchClusters(2,fPhiWin[nloop],fLambdaWin[nloop],
391 trs,primaryVertex[2],pflag);
394 fPoint3[0]=fPointc[0];
395 fPoint3[1]=fPointc[1];
397 nn[2]= SearchClusters(3,fPhiWin[nloop],fLambdaWin[nloop],
398 trs,primaryVertex[2],pflag);
403 nn[3]= SearchClusters(4,fPhiWin[nloop],fLambdaWin[nloop],
404 trs,primaryVertex[2],pflag);
409 nn[4]=SearchClusters(5,fPhiWin[nloop],fLambdaWin[nloop],
410 trs,primaryVertex[2],pflag);
413 for(Int_t nnp=0;nnp<fGeom->GetNlayers()-1;nnp++){
414 if(nn[nnp]!=0) fl+=1;
417 AliITStrackV2* tr2 = FitTrack(trs,primaryVertex);
422 AliESDtrack outtrack;
423 outtrack.UpdateTrackParams(tr2,AliESDtrack::kITSin);
424 event->AddTrack(&outtrack);
431 }//end loop on clusters of layer2
438 Info("FindTracks","Number of found tracks: %d",event->GetNumberOfTracks());
447 //________________________________________________________________________
449 AliITStrackV2* AliITStrackerSA::FitTrack(AliITStrackSA* tr,Double_t *primaryVertex){
450 //fit of the found track
453 Int_t * firstmod = new Int_t[fGeom->GetNlayers()];
454 for(Int_t i=0;i<fGeom->GetNlayers();i++){
455 firstmod[i]=fGeom->GetModuleIndex(i+1,1,1);
458 Int_t nclusters = tr->GetNumberOfClustersSA();
459 TObjArray** listlayer = new TObjArray*[fGeom->GetNlayers()];
460 for(Int_t i=0;i<fGeom->GetNlayers();i++){
461 listlayer[i] = new TObjArray(0,0);
479 Int_t * nnn = new Int_t[fGeom->GetNlayers()];
480 Int_t * kkk = new Int_t[fGeom->GetNlayers()];
481 for(Int_t i=0;i<fGeom->GetNlayers();i++) {nnn[i]=0;kkk[i]=0;}
483 for(Int_t ncl=0;ncl<nclusters;ncl++){
484 Int_t index = tr->GetClusterIndexSA(ncl);
485 AliITSRecPoint* cl = (AliITSRecPoint*)GetCluster(index);
486 if(cl->TestBit(kSAflag)==kTRUE) cl->ResetBit(kSAflag);
487 Int_t lay = (index & 0xf0000000) >> 28;
488 if(lay==0) { listlayer[0]->AddLast(cl); clind0[nnn[0]]=index;nnn[0]++;}
489 if(lay==1) { listlayer[1]->AddLast(cl); clind1[nnn[1]]=index;nnn[1]++;}
490 if(lay==2) { listlayer[2]->AddLast(cl); clind2[nnn[2]]=index;nnn[2]++;}
491 if(lay==3) { listlayer[3]->AddLast(cl); clind3[nnn[3]]=index;nnn[3]++;}
492 if(lay==4) { listlayer[4]->AddLast(cl); clind4[nnn[4]]=index;nnn[4]++;}
493 if(lay==5) { listlayer[5]->AddLast(cl); clind5[nnn[5]]=index;nnn[5]++;}
497 for(Int_t nlay=0;nlay<fGeom->GetNlayers();nlay++){
498 for(Int_t ncl=0;ncl<tr->GetNumberOfMarked(nlay);ncl++){
499 Int_t mark = tr->GetClusterMark(nlay,ncl);
500 if(nlay==0) { mark0[kkk[0]]=mark;kkk[0]++;}
501 if(nlay==1) { mark1[kkk[1]]=mark;kkk[1]++;}
502 if(nlay==2) { mark2[kkk[2]]=mark;kkk[2]++;}
503 if(nlay==3) { mark3[kkk[3]]=mark;kkk[3]++;}
504 if(nlay==4) { mark4[kkk[4]]=mark;kkk[4]++;}
505 if(nlay==5) { mark5[kkk[5]]=mark;kkk[5]++;}
513 Int_t * end = new Int_t[fGeom->GetNlayers()];
514 for(Int_t i=0;i<fGeom->GetNlayers();i++){
515 if(listlayer[i]->GetEntries()==0) end[i]=1;
516 else end[i]=listlayer[i]->GetEntries();
519 TClonesArray* listSA = new TClonesArray("AliITStrackSA");
520 TClonesArray &tri = *listSA;
523 if(end[0]==0) end[0]=1; //for tracks with cluster on layer 0 missing
524 for(Int_t l1=0;l1<end[0];l1++){//loop on layer 1
525 AliITSRecPoint* cl0 = (AliITSRecPoint*)listlayer[0]->At(l1);
526 Double_t x1,y1,z1,sx1,sy1,sz1;
527 Double_t x2,y2,z2,sx2,sy2,sz2;
528 AliITSRecPoint* p1=0;
529 AliITSRecPoint* p2=0;
530 Int_t index1=clind0[l1];
532 Int_t mrk1 = mark0[l1];
537 for(Int_t l2=0;l2<end[1];l2++){//loop on layer 2
538 AliITSRecPoint* cl1 = (AliITSRecPoint*)listlayer[1]->At(l2);
541 for(Int_t l3=0;l3<end[2];l3++){ //loop on layer 3
542 AliITSRecPoint* cl2 = (AliITSRecPoint*)listlayer[2]->At(l3);
544 if(cl0==0 && cl1!=0) {
545 p2 = cl2;index1=clind2[l3];mrk1=mark2[l3];lay1=2;
547 module1 = p1->GetDetectorIndex()+firstmod[1];
549 if(cl0!=0 && cl1==0){
551 p2=cl2;index2=clind2[l3];mrk2=mark2[l3];lay2=2;
552 module1 = p1->GetDetectorIndex()+firstmod[0];
554 if(cl0!=0 && cl1!=0){
557 module1 = p1->GetDetectorIndex()+firstmod[0];
562 AliITSclusterTable* arr = (AliITSclusterTable*)GetClusterCoord(lay1,cln1);
563 AliITSclusterTable* arr1= (AliITSclusterTable*)GetClusterCoord(lay2,cln2);
577 Int_t layer,ladder,detector;
578 fGeom->GetModuleId(module1,layer,ladder,detector);
579 Float_t yclu1 = p1->GetY();
580 Float_t zclu1 = p1->GetZ();
581 Double_t cv=Curvature(primaryVertex[0],primaryVertex[1],x1,y1,x2,y2);
583 Double_t tgl2 = (z2-z1)/TMath::Sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
584 Double_t phi2 = TMath::ATan2((y2-y1),(x2-x1));
586 for(Int_t l4=0;l4<end[3];l4++){ //loop on layer 4
587 AliITSRecPoint* cl3 = (AliITSRecPoint*)listlayer[3]->At(l4);
588 for(Int_t l5=0;l5<end[4];l5++){ //loop on layer 5
589 AliITSRecPoint* cl4 = (AliITSRecPoint*)listlayer[4]->At(l5);
590 for(Int_t l6=0;l6<end[5];l6++){ //loop on layer 6
591 AliITSRecPoint* cl5 = (AliITSRecPoint*)listlayer[5]->At(l6);
592 AliITStrackSA* trac = new AliITStrackSA(fGeom,layer,ladder,detector,yclu1,zclu1,phi2,tgl2,cv,1);
595 trac->AddClusterV2(5,(clind5[l6] & 0x0fffffff)>>0);
596 trac->AddClusterMark(5,mark5[l6]);
599 trac->AddClusterV2(4,(clind4[l5] & 0x0fffffff)>>0);
600 trac->AddClusterMark(4,mark4[l5]);
603 trac->AddClusterV2(3,(clind3[l4] & 0x0fffffff)>>0);
604 trac->AddClusterMark(3,mark3[l4]);
607 trac->AddClusterV2(2,(clind2[l3] & 0x0fffffff)>>0);
608 trac->AddClusterMark(2,mark2[l3]);
611 trac->AddClusterV2(1,(clind1[l2] & 0x0fffffff)>>0);
612 trac->AddClusterMark(1,mark1[l2]);
615 trac->AddClusterV2(0,(clind0[l1] & 0x0fffffff)>>0);
616 trac->AddClusterMark(0,mark0[l1]);
618 //fit with Kalman filter using AliITStrackerMI::RefitAt()
621 AliITStrackMI* ot = new AliITStrackSA(*trac);
623 ot->ResetCovariance();
626 if(RefitAt(49.,ot,trac)){ //fit from layer 1 to layer 6
627 AliITStrackMI *otrack2 = new AliITStrackMI(*ot);
628 otrack2->ResetCovariance();
629 otrack2->ResetClusters();
630 //fit from layer 6 to layer 1
631 if(RefitAt(3.7,otrack2,ot)) {
632 fListOfTracks->AddLast(otrack2);
633 new (tri[nlist]) AliITStrackSA(*trac);
655 Int_t dim=fListOfTracks->GetEntries();
657 for(Int_t i=0;i<fGeom->GetNlayers();i++){
667 Int_t lowchi2 = FindTrackLowChiSquare(fListOfTracks,dim);
668 AliITStrackV2* otrack =(AliITStrackV2*)fListOfTracks->At(lowchi2);
669 AliITStrackSA* trsa = (AliITStrackSA*)listSA->At(lowchi2);
672 for(Int_t i=0;i<fGeom->GetNlayers();i++){
681 Int_t * indexc = new Int_t[fGeom->GetNlayers()];
682 for(Int_t i=0;i<fGeom->GetNlayers();i++) indexc[i]=0;
683 for(Int_t nind=0;nind<otrack->GetNumberOfClusters();nind++){
684 indexc[nind] = otrack->GetClusterIndex(nind);
686 AliITSRecPoint* cl0 = (AliITSRecPoint*)GetCluster(indexc[0]);
687 AliITSRecPoint* cl1 = (AliITSRecPoint*)GetCluster(indexc[1]);
688 AliITSRecPoint* cl2 = (AliITSRecPoint*)GetCluster(indexc[2]);
689 AliITSRecPoint* cl3 = (AliITSRecPoint*)GetCluster(indexc[3]);
690 AliITSRecPoint* cl4 = (AliITSRecPoint*)GetCluster(indexc[4]);
691 Int_t labl[3]={-1,-1,-1};
692 if(otrack->GetNumberOfClusters()==fGeom->GetNlayers()){
693 AliITSRecPoint* cl5 = (AliITSRecPoint*)GetCluster(indexc[5]);
694 labl[0]=cl5->GetLabel(0);
695 labl[1]=cl5->GetLabel(1);
696 labl[2]=cl5->GetLabel(2);
699 if(otrack->GetNumberOfClusters()==(fGeom->GetNlayers()-1)){
704 Int_t numberofpoints;
705 if(fSixPoints) numberofpoints=6;
706 else numberofpoints=5;
707 CookLabel(otrack,0.); //MI change - to see fake ratio
708 Int_t label = Label(cl0->GetLabel(0),cl1->GetLabel(0),
709 cl2->GetLabel(0),cl3->GetLabel(0),
710 cl4->GetLabel(0),labl[0],
711 cl0->GetLabel(1),cl1->GetLabel(1),
712 cl2->GetLabel(1),cl3->GetLabel(1),
713 cl4->GetLabel(1),labl[1],
714 cl0->GetLabel(2),cl1->GetLabel(2),
715 cl2->GetLabel(2),cl3->GetLabel(2),
716 cl4->GetLabel(2),labl[2],numberofpoints);
718 otrack->SetLabel(label);
719 //remove clusters of found track
721 for(Int_t nlay=0;nlay<fGeom->GetNlayers();nlay++){
722 for(Int_t cln=0;cln<trsa->GetNumberOfMarked(nlay);cln++){
723 Int_t index = trsa->GetClusterMark(nlay,cln);
724 fCluLayer[nlay]->RemoveAt(index);
725 RemoveClusterCoord(nlay,index);
726 fCluLayer[nlay]->Compress();
732 for(Int_t i=0;i<fGeom->GetNlayers();i++){
743 //_______________________________________________________
744 Int_t AliITStrackerSA::SearchClusters(Int_t layer,Double_t phiwindow,Double_t lambdawindow, AliITStrackSA* trs,Double_t /*zvertex*/,Int_t pflag){
745 //function used to to find the clusters associated to the track
747 AliITSlayer &lay = fgLayers[layer];
748 Double_t r=lay.GetR();
750 Float_t cx1,cx2,cy1,cy2;
751 FindEquation(fPoint1[0],fPoint1[1],fPoint2[0],fPoint2[1],fPoint3[0],fPoint3[1],fCoef1,fCoef2,fCoef3);
752 if (FindIntersection(fCoef1,fCoef2,fCoef3,-r*r,cx1,cy1,cx2,cy2)==0)
754 Double_t fi1=TMath::ATan2(cy1,cx1);
755 Double_t fi2=TMath::ATan2(cy2,cx2);
756 fPhiEstimate=ChoosePoint(fi1,fi2,fPhic);
760 Int_t ncl = fCluLayer[layer]->GetEntries();
761 for (Int_t index=0; index<ncl; index++) {
762 AliITSRecPoint *c = (AliITSRecPoint*)fCluLayer[layer]->At(index);
764 if (c->GetQ()<=0) continue;
766 AliITSclusterTable* arr = (AliITSclusterTable*)GetClusterCoord(layer,index);
767 Double_t phi = arr->GetPhi();
768 if (TMath::Abs(phi-fPhiEstimate)>phiwindow) continue;
770 Double_t lambda = arr->GetLambda();
771 if (TMath::Abs(lambda-fLambdac)>lambdawindow) continue;
773 if(trs->GetNumberOfClustersSA()==trs->GetMaxNumberOfClusters()) return 0;
774 if(trs->GetNumberOfMarked(layer)==trs->GetMaxNMarkedPerLayer()) return 0;
775 Int_t orind = arr->GetOrInd();
776 trs->AddClusterSA(layer,orind);
777 trs->AddClusterMark(layer,index);
783 fPointc[0]=arr->GetX();
784 fPointc[1]=arr->GetY();
790 //________________________________________________________________
791 void AliITStrackerSA::UpdatePoints(){
792 //update of points for the estimation of the curvature
794 fPoint2[0]=fPoint3[0];
795 fPoint2[1]=fPoint3[1];
796 fPoint3[0]=fPointc[0];
797 fPoint3[1]=fPointc[1];
802 //___________________________________________________________________
803 Int_t AliITStrackerSA::FindEquation(Float_t x1, Float_t y1, Float_t x2, Float_t y2, Float_t x3, Float_t y3,Float_t& a, Float_t& b, Float_t& c){
805 //given (x,y) of three recpoints (in global coordinates)
806 //returns the parameters a,b,c of circonference x*x + y*y +a*x + b*y +c
808 Float_t den = (x3-x1)*(y2-y1)-(x2-x1)*(y3-y1);
810 a = ((y3-y1)*(x2*x2+y2*y2-x1*x1-y1*y1)-(y2-y1)*(x3*x3+y3*y3-x1*x1-y1*y1))/den;
811 b = -(x2*x2-x1*x1+y2*y2-y1*y1+a*(x2-x1))/(y2-y1);
812 c = -x1*x1-y1*y1-a*x1-b*y1;
815 //__________________________________________________________________________
816 Int_t AliITStrackerSA::FindIntersection(Float_t a1, Float_t b1, Float_t c1, Float_t c2,Float_t& x1,Float_t& y1, Float_t& x2, Float_t& y2){
818 //Finds the intersection between the circonference of the track and the circonference centered in (0,0) represented by one layer
819 //c2 is -rlayer*rlayer
823 Double_t aA = (b1*b1)/(a1*a1)+1;
824 Double_t bB = (-2*m*b1/(a1*a1));
825 Double_t cC = c2+(m*m)/(a1*a1);
826 Double_t dD = bB*bB-4*aA*cC;
829 y1 = (-bB+TMath::Sqrt(dD))/(2*aA);
830 y2 = (-bB-TMath::Sqrt(dD))/(2*aA);
831 x1 = (c2-c1-b1*y1)/a1;
832 x2 = (c2-c1-b1*y2)/a1;
836 //____________________________________________________________________
837 Double_t AliITStrackerSA::Curvature(Double_t x1,Double_t y1,Double_t
838 x2,Double_t y2,Double_t x3,Double_t y3){
840 //calculates the curvature of track
841 Double_t den = (x3-x1)*(y2-y1)-(x2-x1)*(y3-y1);
843 Double_t a = ((y3-y1)*(x2*x2+y2*y2-x1*x1-y1*y1)-(y2-y1)*(x3*x3+y3*y3-x1*x1-y1*y1))/den;
844 Double_t b = -(x2*x2-x1*x1+y2*y2-y1*y1+a*(x2-x1))/(y2-y1);
845 Double_t c = -x1*x1-y1*y1-a*x1-b*y1;
848 if((a*a+b*b-4*c)<0) return 0;
849 Double_t rad = TMath::Sqrt(a*a+b*b-4*c)/2.;
852 if((x1>0 && y1>0 && x1<xc)) rad*=-1;
853 if((x1<0 && y1>0 && x1<xc)) rad*=-1;
854 // if((x1<0 && y1<0 && x1<xc)) rad*=-1;
855 // if((x1>0 && y1<0 && x1<xc)) rad*=-1;
862 //____________________________________________________________________
863 Double_t AliITStrackerSA::ChoosePoint(Double_t p1, Double_t p2, Double_t pp){
865 //Returns the point closest to pp
867 Double_t diff1 = p1-pp;
868 Double_t diff2 = p2-pp;
870 if(TMath::Abs(diff1)<TMath::Abs(diff2)) fPhiEstimate=p1;
871 else fPhiEstimate=p2;
877 //_________________________________________________________________
878 Int_t AliITStrackerSA::FindTrackLowChiSquare(TObjArray* tracklist, Int_t dim) const {
879 // returns track with lowes chi square
881 //AliITStrackV2* trk = (AliITStrackV2*)tracklist->At(0);
885 //if(dim==0) return 0;
886 Double_t * chi2 = new Double_t[dim];
887 Int_t * index = new Int_t[dim];
888 for(Int_t i=0;i<dim;i++){
889 AliITStrackV2* trk = (AliITStrackV2*)tracklist->At(i);
890 chi2[i]=trk->GetChi2();
894 Int_t w=0;Double_t value;
897 for(Int_t j=w+1;j<dim;j++){
915 //__________________________________________________________
916 Int_t AliITStrackerSA::FindLabel(Int_t l1, Int_t l2, Int_t l3, Int_t l4, Int_t l5, Int_t l6){
918 //function used to determine the track label
920 Int_t lb[6] = {l1,l2,l3,l4,l5,l6};
921 Int_t aa[6]={1,1,1,1,1,1};
924 Int_t k=0;Int_t w=0;Int_t num=6;
929 for(Int_t i=k+1;i<num;i++){
931 if(lb[k]==lb[i] && aa[k]!=0){
942 for(Int_t j=0;j<6;j++){
954 if(num==6) return lb[5];
958 //_____________________________________________________________________________
959 Int_t AliITStrackerSA::Label(Int_t gl1, Int_t gl2, Int_t gl3, Int_t gl4, Int_t gl5, Int_t gl6,Int_t gl7, Int_t gl8, Int_t gl9, Int_t gl10,Int_t gl11,
960 Int_t gl12, Int_t gl13, Int_t gl14,Int_t gl15, Int_t gl16, Int_t gl17, Int_t gl18, Int_t numberofpoints){
963 //function used to assign label to the found track. If track is fake, the label is negative
965 Int_t lb0[6] = {gl1,gl2,gl3,gl4,gl5,gl6};
966 Int_t lb1[6] = {gl7,gl8,gl9,gl10,gl11,gl12};
967 Int_t lb2[6] = {gl13,gl14,gl15,gl16,gl17,gl18};
968 Int_t ll=FindLabel(lb0[0],lb0[1],lb0[2],lb0[3],lb0[4],lb0[5]);
969 Int_t lflag=0;Int_t num=6;
970 if(lb0[5]==-1 && lb1[5]==-1 && lb2[5]==-1) num=5;
972 for(Int_t i=0;i<num;i++){
973 if(lb0[i]==ll || lb1[i]==ll || lb2[i]==ll) lflag+=1;
976 if(lflag>=numberofpoints) return ll;
982 //_____________________________________________________________________________
983 void AliITStrackerSA::SetWindowSizes(Int_t n, Double_t *phi, Double_t *lam){
984 // Set sizes of the phi and lambda windows used for track finding
986 if(phi){ // user defined values
987 fPhiWin = new Double_t[fNloop];
988 fLambdaWin = new Double_t[fNloop];
989 for(Int_t k=0;k<fNloop;k++){
991 fLambdaWin[k]=lam[k];
994 else { // default values
996 Double_t phid[33] = {0.002,0.003,0.004,0.0045,0.0047,
998 0.006,0.0063,0.0065,0.007,0.0073,0.0075,0.0077,
999 0.008,0.0083,0.0085,0.0087,0.009,0.0095,0.0097,
1000 0.01,0.0105,0.011,0.0115,0.012,0.0125,0.013,0.0135,0.0140,0.0145};
1001 Double_t lambdad[33] = {0.003,0.004,0.005,0.005,0.005,
1003 0.006,0.006,0.006,0.007,0.007,0.007,0.007,
1004 0.007,0.007,0.007,0.007,0.007,0.007,0.007,
1005 0.008,0.008,0.008,0.008,0.008,0.008,0.008,0.008,0.008,0.008};
1012 fPhiWin = new Double_t[fNloop];
1013 fLambdaWin = new Double_t[fNloop];
1015 for(Int_t k=0;k<fNloop;k++){
1017 fLambdaWin[k]=lambdad[k];
1023 //_______________________________________________________________________
1024 void AliITStrackerSA::GetCoorAngles(AliITSRecPoint* cl,Int_t module,Double_t &phi,Double_t &lambda, Float_t &x, Float_t &y,Float_t &z,Double_t* vertex){
1025 //Returns values of phi (azimuthal) and lambda angles for a given cluster
1027 Double_t rot[9]; fGeom->GetRotMatrix(module,rot);
1028 Int_t lay,lad,det; fGeom->GetModuleId(module,lay,lad,det);
1029 Float_t tx,ty,tz; fGeom->GetTrans(lay,lad,det,tx,ty,tz);
1031 Double_t alpha=TMath::ATan2(rot[1],rot[0])+TMath::Pi();
1032 Double_t phi1=TMath::Pi()/2+alpha;
1033 if (lay==1) phi1+=TMath::Pi();
1035 Float_t cp=TMath::Cos(phi1), sp=TMath::Sin(phi1);
1036 Float_t r=tx*cp+ty*sp;
1038 x= r*cp - cl->GetY()*sp;
1039 y= r*sp + cl->GetY()*cp;
1042 phi=TMath::ATan2(y,x);
1043 lambda=TMath::ATan2(z-vertex[2],TMath::Sqrt((x-vertex[0])*(x-vertex[0])+(y-vertex[1])*(y-vertex[1])));
1046 //________________________________________________________________________
1047 void AliITStrackerSA::GetCoorErrors(AliITSRecPoint* cl, Int_t module,Float_t &sx,Float_t &sy, Float_t &sz){
1049 //returns x,y,z of cluster in global coordinates
1051 Double_t rot[9]; fGeom->GetRotMatrix(module,rot);
1052 Int_t lay,lad,det; fGeom->GetModuleId(module,lay,lad,det);
1054 Double_t alpha=TMath::ATan2(rot[1],rot[0])+TMath::Pi();
1055 Double_t phi=TMath::Pi()/2+alpha;
1056 if (lay==1) phi+=TMath::Pi();
1058 Float_t cp=TMath::Cos(phi), sp=TMath::Sin(phi);
1060 sx = TMath::Sqrt(sp*sp*cl->GetSigmaY2());
1061 sy = TMath::Sqrt(cp*cp*cl->GetSigmaY2());
1062 sz = TMath::Sqrt(cl->GetSigmaZ2());