]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/AliITStrackerSA.cxx
Add the possibiloity to save cut settings in the ROOT file
[u/mrichter/AliRoot.git] / ITS / AliITStrackerSA.cxx
CommitLineData
13918578 1/**************************************************************************
2 * Copyright(c) 1998-2003, 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
bf6adc12 16/* $Id$ */
17
13918578 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////////////////////////////////////////////////////
24
aa4b78e1 25#include <stdlib.h>
bf6adc12 26
27#include <TArrayI.h>
13918578 28#include <TBranch.h>
13918578 29#include <TObjArray.h>
30#include <TTree.h>
bf6adc12 31
32#include "AliESD.h"
33#include "AliESDVertex.h"
34#include "AliESDtrack.h"
bf6adc12 35#include "AliITSVertexer.h"
13918578 36#include "AliITSclusterTable.h"
00a7cc50 37#include "AliITSRecPoint.h"
cc088660 38#include "AliITSgeomTGeo.h"
13918578 39#include "AliITStrackSA.h"
bf6adc12 40#include "AliITStrackerSA.h"
41#include "AliRun.h"
13918578 42
43ClassImp(AliITStrackerSA)
44
45//____________________________________________________________________________
e399f961 46AliITStrackerSA::AliITStrackerSA():AliITStrackerMI(),
47fPhiEstimate(0),
1966f03c 48fITSStandAlone(0),
e399f961 49fLambdac(0),
50fPhic(0),
51fCoef1(0),
52fCoef2(0),
53fCoef3(0),
54fNloop(0),
55fPhiWin(0),
56fLambdaWin(0),
57fVert(0),
58fVertexer(0),
e399f961 59fListOfTracks(0),
60fITSclusters(0),
61fSixPoints(0),
62fCluLayer(0),
63fCluCoord(0){
13918578 64 // Default constructor
65 Init();
627b6db6 66
13918578 67}
2257f27e 68//____________________________________________________________________________
cc088660 69AliITStrackerSA::AliITStrackerSA(const Char_t *geom):AliITStrackerMI(0),
e399f961 70fPhiEstimate(0),
1966f03c 71fITSStandAlone(0),
e399f961 72fLambdac(0),
73fPhic(0),
74fCoef1(0),
75fCoef2(0),
76fCoef3(0),
77fNloop(0),
78fPhiWin(0),
79fLambdaWin(0),
80fVert(0),
81fVertexer(0),
e399f961 82fListOfTracks(0),
83fITSclusters(0),
84fSixPoints(0),
85fCluLayer(0),
86fCluCoord(0)
2257f27e 87{
88 // Standard constructor (Vertex is known and passed to this obj.)
cc088660 89 if (geom) {
90 AliWarning("\"geom\" is actually a dummy argument !");
91 }
92
2257f27e 93 Init();
94 fVert = 0;
627b6db6 95
2257f27e 96}
97
13918578 98//____________________________________________________________________________
cc088660 99AliITStrackerSA::AliITStrackerSA(const Char_t *geom, AliESDVertex *vert):AliITStrackerMI(0),
e399f961 100fPhiEstimate(0),
1966f03c 101fITSStandAlone(0),
e399f961 102fLambdac(0),
103fPhic(0),
104fCoef1(0),
105fCoef2(0),
106fCoef3(0),
107fNloop(0),
108fPhiWin(0),
109fLambdaWin(0),
110fVert(vert),
111fVertexer(0),
e399f961 112fListOfTracks(0),
113fITSclusters(0),
114fSixPoints(0),
115fCluLayer(0),
1966f03c 116fCluCoord(0)
13918578 117{
118 // Standard constructor (Vertex is known and passed to this obj.)
cc088660 119 if (geom) {
120 AliWarning("\"geom\" is actually a dummy argument !");
121 }
13918578 122 Init();
627b6db6 123
13918578 124}
125
13918578 126//____________________________________________________________________________
cc088660 127AliITStrackerSA::AliITStrackerSA(const Char_t *geom, AliITSVertexer *vertexer):AliITStrackerMI(0),
e399f961 128fPhiEstimate(0),
1966f03c 129fITSStandAlone(0),
e399f961 130fLambdac(0),
131fPhic(0),
132fCoef1(0),
133fCoef2(0),
134fCoef3(0),
135fNloop(0),
136fPhiWin(0),
137fLambdaWin(0),
138fVert(),
139fVertexer(vertexer),
e399f961 140fListOfTracks(0),
141fITSclusters(0),
142fSixPoints(0),
143fCluLayer(0),
1966f03c 144fCluCoord(0)
13918578 145{
146 // Standard constructor (Vertex is unknown - vertexer is passed to this obj)
cc088660 147 if (geom) {
148 AliWarning("\"geom\" is actually a dummy argument !");
149 }
13918578 150 Init();
151 fVertexer = vertexer;
627b6db6 152
13918578 153}
154
155//____________________________________________________________________________
e399f961 156AliITStrackerSA::AliITStrackerSA(const AliITStrackerSA& tracker):AliITStrackerMI(),
157fPhiEstimate(tracker.fPhiEstimate),
1966f03c 158fITSStandAlone(tracker.fITSStandAlone),
e399f961 159fLambdac(tracker.fLambdac),
160fPhic(tracker.fPhic),
161fCoef1(tracker.fCoef1),
162fCoef2(tracker.fCoef2),
163fCoef3(tracker.fCoef3),
164fNloop(tracker.fNloop),
165fPhiWin(tracker.fPhiWin),
166fLambdaWin(tracker.fLambdaWin),
167fVert(tracker.fVert),
168fVertexer(tracker.fVertexer),
e399f961 169fListOfTracks(tracker.fListOfTracks),
170fITSclusters(tracker.fITSclusters),
171fSixPoints(tracker.fSixPoints),
172fCluLayer(tracker.fCluLayer),
173fCluCoord(tracker.fCluCoord) {
13918578 174 // Copy constructor
13918578 175 for(Int_t i=0;i<2;i++){
176 fPoint1[i]=tracker.fPoint1[i];
177 fPoint2[i]=tracker.fPoint2[i];
178 fPoint3[i]=tracker.fPoint3[i];
179 fPointc[i]=tracker.fPointc[i];
180 }
13918578 181 if(tracker.fVertexer && tracker.fVert){
d681bb2d 182 fVert = new AliESDVertex(*tracker.fVert);
13918578 183 }
184 else {
185 fVert = tracker.fVert;
186 }
cc088660 187 for(Int_t i=0;i<AliITSgeomTGeo::GetNLayers();i++){
7e5bf5af 188 fCluLayer[i] = tracker.fCluLayer[i];
189 fCluCoord[i] = tracker.fCluCoord[i];
190 }
13918578 191}
7d62fb64 192//______________________________________________________________________
e399f961 193AliITStrackerSA& AliITStrackerSA::operator=(const AliITStrackerSA& source){
194 // Assignment operator.
195 this->~AliITStrackerSA();
196 new(this) AliITStrackerSA(source);
197 return *this;
198
7d62fb64 199}
13918578 200
201//____________________________________________________________________________
202AliITStrackerSA::~AliITStrackerSA(){
203 // destructor
d681bb2d 204 // if fVertexer is not null, the AliESDVertex obj. is owned by this class
13918578 205 // and is deleted here
206 if(fVertexer){
207 if(fVert)delete fVert;
208 }
209 fVert = 0;
210 fVertexer = 0;
7e5bf5af 211
13918578 212 if(fPhiWin)delete []fPhiWin;
213 if(fLambdaWin)delete []fLambdaWin;
4e05ab9a 214 fListOfTracks->Delete();
7e5bf5af 215 if(fCluLayer){
cc088660 216 for(Int_t i=0;i<AliITSgeomTGeo::GetNLayers();i++){
7e5bf5af 217 if(fCluLayer[i]){
218 fCluLayer[i]->Delete();
219 delete fCluLayer[i];
220 }
221 }
222 delete [] fCluLayer;
223 }
224 if(fCluCoord){
cc088660 225 for(Int_t i=0;i<AliITSgeomTGeo::GetNLayers();i++){
7e5bf5af 226 if(fCluCoord[i]){
227 fCluCoord[i]->Delete();
228 delete fCluCoord[i];
229 }
230 }
231 delete [] fCluCoord;
627b6db6 232 }
7e5bf5af 233
7e5bf5af 234}
13918578 235
1966f03c 236//____________________________________________________________________________
237Int_t AliITStrackerSA::Clusters2Tracks(AliESD *event){
238// This method is used to find and fit the tracks. By default the corresponding
239// method in the parent class is invoked. In this way a combined tracking
240// TPC+ITS is performed. If the flag fITSStandAlone is true, the tracking
241// is done in the ITS only. In the standard reconstruction chain this option
242// can be set via AliReconstruction::SetOption("ITS","onlyITS")
243 Int_t rc=0;
244 if(!fITSStandAlone){
245 rc=AliITStrackerMI::Clusters2Tracks(event);
246 }
247 else {
248 AliDebug(1,"Stand Alone flag set: doing tracking in ITS alone\n");
249 }
250 if(!rc) rc=FindTracks(event);
251 return rc;
252}
253
13918578 254//____________________________________________________________________________
255void AliITStrackerSA::Init(){
256 // Reset all data members
257 fPhiEstimate=0;
258 for(Int_t i=0;i<3;i++){fPoint1[i]=0;fPoint2[i]=0;fPoint3[i]=0;}
259 fLambdac=0;
260 fPhic=0;
261 fCoef1=0;
262 fCoef2=0;
263 fCoef3=0;
264 fPointc[0]=0;
265 fPointc[1]=0;
266 fVert = 0;
267 fVertexer = 0;
13918578 268 SetWindowSizes();
2257f27e 269 fITSclusters = 0;
270 SetSixPoints();
1966f03c 271 SetSAFlag(kFALSE);
4e05ab9a 272 fListOfTracks=new TObjArray(0,0);
7e5bf5af 273 fCluLayer = 0;
274 fCluCoord = 0;
627b6db6 275 }
13918578 276//_______________________________________________________________________
277void AliITStrackerSA::ResetForFinding(){
278 // Reset data members used in all loops during track finding
279 fPhiEstimate=0;
280 for(Int_t i=0;i<3;i++){fPoint1[i]=0;fPoint2[i]=0;fPoint3[i]=0;}
281 fLambdac=0;
282 fPhic=0;
283 fCoef1=0;
284 fCoef2=0;
285 fCoef3=0;
286 fPointc[0]=0;
287 fPointc[1]=0;
4e05ab9a 288 fListOfTracks->Delete();
13918578 289}
bef31448 290
7e5bf5af 291
2257f27e 292
bef31448 293//______________________________________________________________________
2257f27e 294Int_t AliITStrackerSA::FindTracks(AliESD* event){
bef31448 295
7e5bf5af 296// Track finder using the ESD object
297
2257f27e 298
7e5bf5af 299 //controllare numero cluster sui layer1 e 2 (morti?)
300 //non trova tracce...controllare..
4e05ab9a 301
2257f27e 302 if(!fITSclusters){
303 Fatal("FindTracks","ITS cluster tree is not accessed - Abort!!!\n Please use method SetClusterTree to pass the pointer to the tree\n");
304 return -1;
bef31448 305 }
7e5bf5af 306
307
308 //Reads event and mark clusters of traks already found, with flag kITSin
309 Int_t nentr=event->GetNumberOfTracks();
310 while (nentr--) {
311 AliESDtrack *track=event->GetTrack(nentr);
312 if (track->GetStatus()&AliESDtrack::kITSin==AliESDtrack::kITSin){
ef7253ac 313 Int_t idx[12];
7e5bf5af 314 Int_t ncl = track->GetITSclusters(idx);
315 for(Int_t k=0;k<ncl;k++){
00a7cc50 316 AliITSRecPoint* cll = (AliITSRecPoint*)GetCluster(idx[k]);
7e5bf5af 317 cll->SetBit(kSAflag);
318 }
319 }
320 }
321
322 Double_t primaryVertex[3];
323 event->GetVertex()->GetXYZ(primaryVertex);
324 //Creates TClonesArray with clusters for each layer. The clusters already used
325 //by AliITStrackerMI are not considered
326
327 Int_t nclusters[6]={0,0,0,0,0,0};
328 Int_t dmar[6]={0,0,0,0,0,0};
cc088660 329 fCluLayer = new TClonesArray*[AliITSgeomTGeo::GetNLayers()];
330 fCluCoord = new TClonesArray*[AliITSgeomTGeo::GetNLayers()];
7e5bf5af 331
cc088660 332 for(Int_t i=0;i<AliITSgeomTGeo::GetNLayers();i++){
7e5bf5af 333 AliITSlayer &layer=fgLayers[i];
334 for(Int_t cli=0;cli<layer.GetNumberOfClusters();cli++){
00a7cc50 335 AliITSRecPoint* cls = (AliITSRecPoint*)layer.GetCluster(cli);
7e5bf5af 336 if(cls->TestBit(kSAflag)==kTRUE) continue; //clusters used by TPC prol.
337 if(cls->GetQ()==0) continue; //fake clusters dead zones
338 nclusters[i]++;
339 }
340 dmar[i]=0;
00a7cc50 341 fCluLayer[i] = new TClonesArray("AliITSRecPoint",nclusters[i]);
7e5bf5af 342 fCluCoord[i] = new TClonesArray("AliITSclusterTable",nclusters[i]);
343 }
344
345
cc088660 346 Int_t * firstmod = new Int_t[AliITSgeomTGeo::GetNLayers()];
347 for(Int_t i=0;i<AliITSgeomTGeo::GetNLayers();i++){
348 firstmod[i]=AliITSgeomTGeo::GetModuleIndex(i+1,1,1);
7e5bf5af 349 }
350
cc088660 351 for(Int_t ilay=0;ilay<AliITSgeomTGeo::GetNLayers();ilay++){
7e5bf5af 352 TClonesArray &clulay = *fCluLayer[ilay];
353 TClonesArray &clucoo = *fCluCoord[ilay];
354 AliITSlayer &layer=fgLayers[ilay];
355 for(Int_t cli=0;cli<layer.GetNumberOfClusters();cli++){
00a7cc50 356 AliITSRecPoint* cls = (AliITSRecPoint*)layer.GetCluster(cli);
7e5bf5af 357 if(cls->TestBit(kSAflag)==kTRUE) continue;
358 if(cls->GetQ()==0) continue;
359 Double_t phi=0;Double_t lambda=0;
360 Float_t x=0;Float_t y=0;Float_t z=0;
361 Float_t sx=0;Float_t sy=0;Float_t sz=0;
cc088660 362 GetCoorAngles(cls,phi,lambda,x,y,z,primaryVertex);
363 GetCoorErrors(cls,sx,sy,sz);
00a7cc50 364 new (clulay[dmar[ilay]]) AliITSRecPoint(*cls);
7e5bf5af 365 new (clucoo[dmar[ilay]]) AliITSclusterTable(x,y,z,sx,sy,sz,phi,lambda,cli);
366 dmar[ilay]++;
367 }
368 }
369
2257f27e 370
371 //Get primary vertex
7e5bf5af 372
373 Int_t ntrack=0;
374 //loop on the different windows
375 for(Int_t nloop=0;nloop<fNloop;nloop++){
376 for(Int_t ncl=0;ncl<fCluLayer[0]->GetEntries();ncl++){ //loop starting from layer 0
377
378 ResetForFinding();
379 Int_t pflag=0;
380
00a7cc50 381 AliITSRecPoint* cl = (AliITSRecPoint*)fCluLayer[0]->At(ncl);
7e5bf5af 382
383 if(!cl) continue;
384
385
386 if (cl->GetQ()<=0) continue;
387
388 AliITSclusterTable* arr = (AliITSclusterTable*)GetClusterCoord(0,ncl);
389 fPhic = arr->GetPhi();
390 fLambdac = arr->GetLambda();
391 if (TMath::Abs(fLambdac)>0.26*TMath::Pi()) continue;
392 fPhiEstimate = fPhic;
393 AliITStrackSA* trs = new AliITStrackSA();
394 fPoint1[0]=primaryVertex[0];
395 fPoint1[1]=primaryVertex[1];
396
397
398 fPoint2[0]=arr->GetX();
399 fPoint2[1]=arr->GetY();
cc088660 400 Int_t * nn = new Int_t[AliITSgeomTGeo::GetNLayers()];//counter for clusters on each layer
401 for(Int_t i=0;i<AliITSgeomTGeo::GetNLayers();i++){ nn[i]=0;}
7e5bf5af 402 nn[0] = SearchClusters(0,fPhiWin[nloop],fLambdaWin[nloop],trs,primaryVertex[2],pflag);
403
404 nn[1] = SearchClusters(1,fPhiWin[nloop],fLambdaWin[nloop],trs,primaryVertex[2],pflag);
bef31448 405 if(nn[1]>0){
406 pflag=1;
407 fPoint3[0] = fPointc[0];
408 fPoint3[1] = fPointc[1];
409 }
cfe729e0 410 nn[2] = SearchClusters(2,fPhiWin[nloop],fLambdaWin[nloop],trs,primaryVertex[2],pflag);
bef31448 411 if(nn[1]==0 && nn[2]==0) pflag=0;
412 if(nn[2]!=0 && nn[1]!=0){ pflag=1; UpdatePoints();}
413 if(nn[2]!=0 && nn[1]==0){
414 pflag=1;
415 fPoint3[0]=fPointc[0];
416 fPoint3[1]=fPointc[1];
417 }
13918578 418
cfe729e0 419 nn[3] = SearchClusters(3,fPhiWin[nloop],fLambdaWin[nloop],trs,primaryVertex[2],pflag);
bef31448 420 pflag=1;
421 if(nn[3]!=0) UpdatePoints();
cfe729e0 422 nn[4] = SearchClusters(4,fPhiWin[nloop],fLambdaWin[nloop],trs,primaryVertex[2],pflag);
bef31448 423 pflag=1;
424 if(nn[4]!=0) UpdatePoints();
cfe729e0 425 nn[5] = SearchClusters(5,fPhiWin[nloop],fLambdaWin[nloop],trs,primaryVertex[2],pflag);
bef31448 426
427
428 Int_t layOK=0;
429 Int_t numberofpoints;
2257f27e 430 if(fSixPoints) numberofpoints=6; //check of the candidate track
bef31448 431 else numberofpoints=5; //if track is good (with the required number
cc088660 432 for(Int_t nnp=0;nnp<AliITSgeomTGeo::GetNLayers();nnp++){ //of points) it is written on file
bef31448 433 if(nn[nnp]!=0) layOK+=1;
434 }
435 if(layOK>=numberofpoints){
7e5bf5af 436
437 AliITStrackV2* tr2 = FitTrack(trs,primaryVertex);
bef31448 438
7e5bf5af 439 if(tr2==0) continue;
440
bef31448 441 AliESDtrack outtrack;
442 outtrack.UpdateTrackParams(tr2,AliESDtrack::kITSin);
443 event->AddTrack(&outtrack);
bef31448 444 ntrack++;
bef31448 445 }
7e5bf5af 446
447
bef31448 448 delete trs;
2257f27e 449 delete[] nn;
627b6db6 450
7e5bf5af 451 }//end loop on clusters of layer1
627b6db6 452
7e5bf5af 453 //end loop2
454 }
bef31448 455
7e5bf5af 456 //if 5/6 points are required, second loop starting
457 //from second layer, to find tracks with point of
458 //layer 1 missing
bef31448 459
7e5bf5af 460 if(!fSixPoints){
461 // counter for clusters on each layer
cc088660 462 Int_t * nn = new Int_t[AliITSgeomTGeo::GetNLayers()-1];
7e5bf5af 463 for(Int_t nloop=0;nloop<fNloop;nloop++){
464 Int_t ncl2=fCluLayer[1]->GetEntries();
465 while(ncl2--){ //loop starting from layer 2
466 ResetForFinding();
467 Int_t pflag=0;
00a7cc50 468 AliITSRecPoint* cl = (AliITSRecPoint*)fCluLayer[1]->At(ncl2);
7e5bf5af 469
470 if(!cl) continue;
471 AliITSclusterTable* arr = (AliITSclusterTable*)GetClusterCoord(1,ncl2);
472 fPhic = arr->GetPhi();
473 fLambdac = arr->GetLambda();
474 fPhiEstimate = fPhic;
475
476 AliITStrackSA* trs = new AliITStrackSA();
477 fPoint1[0]=primaryVertex[0];
478 fPoint1[1]=primaryVertex[1];
479
480 fPoint2[0]=arr->GetX();
481 fPoint2[1]=arr->GetY();
cc088660 482 for(Int_t kk=0;kk<AliITSgeomTGeo::GetNLayers()-1;kk++)nn[kk] = 0;
7e5bf5af 483 nn[0] = SearchClusters(1,fPhiWin[nloop],fLambdaWin[nloop],
484 trs,primaryVertex[2],pflag);
485 nn[1] = SearchClusters(2,fPhiWin[nloop],fLambdaWin[nloop],
486 trs,primaryVertex[2],pflag);
487 if(nn[1]!=0){
488 pflag=1;
489 fPoint3[0]=fPointc[0];
490 fPoint3[1]=fPointc[1];
491 }
492 nn[2]= SearchClusters(3,fPhiWin[nloop],fLambdaWin[nloop],
493 trs,primaryVertex[2],pflag);
494 if(nn[2]!=0){
495 pflag=1;
496 UpdatePoints();
497 }
498 nn[3]= SearchClusters(4,fPhiWin[nloop],fLambdaWin[nloop],
499 trs,primaryVertex[2],pflag);
500 if(nn[3]!=0){
501 pflag=1;
502 UpdatePoints();
503 }
504 nn[4]=SearchClusters(5,fPhiWin[nloop],fLambdaWin[nloop],
505 trs,primaryVertex[2],pflag);
506
507 Int_t fl=0;
cc088660 508 for(Int_t nnp=0;nnp<AliITSgeomTGeo::GetNLayers()-1;nnp++){
7e5bf5af 509 if(nn[nnp]!=0) fl+=1;
510 }
511 if(fl>=5){ // 5/6
512 AliITStrackV2* tr2 = FitTrack(trs,primaryVertex);
513 if(tr2==0){
514 continue;
515 }
516
517 AliESDtrack outtrack;
518 outtrack.UpdateTrackParams(tr2,AliESDtrack::kITSin);
519 event->AddTrack(&outtrack);
520 ntrack++;
521
522 }
523
524
bef31448 525 delete trs;
526 }//end loop on clusters of layer2
7e5bf5af 527 }
528
bef31448 529 delete [] nn;
530 } //end opt="5/6"
7e5bf5af 531
bef31448 532 delete [] firstmod;
bef31448 533 Info("FindTracks","Number of found tracks: %d",event->GetNumberOfTracks());
2257f27e 534 return 0;
bef31448 535
536}
7e5bf5af 537
538
539
2257f27e 540
541
13918578 542//________________________________________________________________________
543
7e5bf5af 544AliITStrackV2* AliITStrackerSA::FitTrack(AliITStrackSA* tr,Double_t *primaryVertex){
13918578 545 //fit of the found track
546
13918578 547
cc088660 548 Int_t * firstmod = new Int_t[AliITSgeomTGeo::GetNLayers()];
549 for(Int_t i=0;i<AliITSgeomTGeo::GetNLayers();i++){
550 firstmod[i]=AliITSgeomTGeo::GetModuleIndex(i+1,1,1);
13918578 551 }
15dd636f 552
13918578 553 Int_t nclusters = tr->GetNumberOfClustersSA();
cc088660 554 TObjArray** listlayer = new TObjArray*[AliITSgeomTGeo::GetNLayers()];
555 for(Int_t i=0;i<AliITSgeomTGeo::GetNLayers();i++){
13918578 556 listlayer[i] = new TObjArray(0,0);
557 }
558
559 TArrayI clind0(20);
560 TArrayI clind1(20);
561 TArrayI clind2(20);
562 TArrayI clind3(20);
563 TArrayI clind4(20);
564 TArrayI clind5(20);
565
7e5bf5af 566 TArrayI mark0(20);
567 TArrayI mark1(20);
568 TArrayI mark2(20);
569 TArrayI mark3(20);
570 TArrayI mark4(20);
571 TArrayI mark5(20);
572
573
cc088660 574 Int_t * nnn = new Int_t[AliITSgeomTGeo::GetNLayers()];
575 Int_t * kkk = new Int_t[AliITSgeomTGeo::GetNLayers()];
576 for(Int_t i=0;i<AliITSgeomTGeo::GetNLayers();i++) {nnn[i]=0;kkk[i]=0;}
13918578 577
578 for(Int_t ncl=0;ncl<nclusters;ncl++){
7e5bf5af 579 Int_t index = tr->GetClusterIndexSA(ncl);
00a7cc50 580 AliITSRecPoint* cl = (AliITSRecPoint*)GetCluster(index);
627b6db6 581 if(cl->TestBit(kSAflag)==kTRUE) cl->ResetBit(kSAflag);
13918578 582 Int_t lay = (index & 0xf0000000) >> 28;
583 if(lay==0) { listlayer[0]->AddLast(cl); clind0[nnn[0]]=index;nnn[0]++;}
584 if(lay==1) { listlayer[1]->AddLast(cl); clind1[nnn[1]]=index;nnn[1]++;}
585 if(lay==2) { listlayer[2]->AddLast(cl); clind2[nnn[2]]=index;nnn[2]++;}
586 if(lay==3) { listlayer[3]->AddLast(cl); clind3[nnn[3]]=index;nnn[3]++;}
587 if(lay==4) { listlayer[4]->AddLast(cl); clind4[nnn[4]]=index;nnn[4]++;}
588 if(lay==5) { listlayer[5]->AddLast(cl); clind5[nnn[5]]=index;nnn[5]++;}
589 }
037efb75 590 delete [] nnn;
13918578 591
cc088660 592 for(Int_t nlay=0;nlay<AliITSgeomTGeo::GetNLayers();nlay++){
7e5bf5af 593 for(Int_t ncl=0;ncl<tr->GetNumberOfMarked(nlay);ncl++){
594 Int_t mark = tr->GetClusterMark(nlay,ncl);
595 if(nlay==0) { mark0[kkk[0]]=mark;kkk[0]++;}
596 if(nlay==1) { mark1[kkk[1]]=mark;kkk[1]++;}
597 if(nlay==2) { mark2[kkk[2]]=mark;kkk[2]++;}
598 if(nlay==3) { mark3[kkk[3]]=mark;kkk[3]++;}
599 if(nlay==4) { mark4[kkk[4]]=mark;kkk[4]++;}
600 if(nlay==5) { mark5[kkk[5]]=mark;kkk[5]++;}
601
602 }
603 }
604
605 delete [] kkk;
606
13918578 607
cc088660 608 Int_t * end = new Int_t[AliITSgeomTGeo::GetNLayers()];
609 for(Int_t i=0;i<AliITSgeomTGeo::GetNLayers();i++){
13918578 610 if(listlayer[i]->GetEntries()==0) end[i]=1;
611 else end[i]=listlayer[i]->GetEntries();
612 }
613
7e5bf5af 614 TClonesArray* listSA = new TClonesArray("AliITStrackSA");
615 TClonesArray &tri = *listSA;
616 Int_t nlist=0;
617
618 if(end[0]==0) end[0]=1; //for tracks with cluster on layer 0 missing
13918578 619 for(Int_t l1=0;l1<end[0];l1++){//loop on layer 1
00a7cc50 620 AliITSRecPoint* cl0 = (AliITSRecPoint*)listlayer[0]->At(l1);
13918578 621 Double_t x1,y1,z1,sx1,sy1,sz1;
622 Double_t x2,y2,z2,sx2,sy2,sz2;
00a7cc50 623 AliITSRecPoint* p1=0;
624 AliITSRecPoint* p2=0;
bef31448 625 Int_t index1=clind0[l1];
626 Int_t index2=0;
7e5bf5af 627 Int_t mrk1 = mark0[l1];
628 Int_t mrk2 = 0;
629 Int_t lay1=0;
630 Int_t lay2=1;
631 Int_t module1=-1;
13918578 632 for(Int_t l2=0;l2<end[1];l2++){//loop on layer 2
00a7cc50 633 AliITSRecPoint* cl1 = (AliITSRecPoint*)listlayer[1]->At(l2);
bef31448 634 index2=clind1[l2];
7e5bf5af 635 mrk2 = mark1[l2];
13918578 636 for(Int_t l3=0;l3<end[2];l3++){ //loop on layer 3
00a7cc50 637 AliITSRecPoint* cl2 = (AliITSRecPoint*)listlayer[2]->At(l3);
bef31448 638
639 if(cl0==0 && cl1!=0) {
7e5bf5af 640 p2 = cl2;index1=clind2[l3];mrk1=mark2[l3];lay1=2;
bef31448 641 p1=cl1;
7e5bf5af 642 module1 = p1->GetDetectorIndex()+firstmod[1];
bef31448 643 }
644 if(cl0!=0 && cl1==0){
645 p1=cl0;
7e5bf5af 646 p2=cl2;index2=clind2[l3];mrk2=mark2[l3];lay2=2;
647 module1 = p1->GetDetectorIndex()+firstmod[0];
bef31448 648 }
649 if(cl0!=0 && cl1!=0){
650 p1=cl0;
651 p2=cl1;
7e5bf5af 652 module1 = p1->GetDetectorIndex()+firstmod[0];
bef31448 653 }
7e5bf5af 654
655 Int_t cln1=mrk1;
656 Int_t cln2=mrk2;
657 AliITSclusterTable* arr = (AliITSclusterTable*)GetClusterCoord(lay1,cln1);
658 AliITSclusterTable* arr1= (AliITSclusterTable*)GetClusterCoord(lay2,cln2);
659 x1 = arr->GetX();
660 x2 = arr1->GetX();
661 y1 = arr->GetY();
662 y2 = arr1->GetY();
663 z1 = arr->GetZ();
664 z2 = arr1->GetZ();
665 sx1 = arr->GetSx();
666 sx2 = arr1->GetSx();
667 sy1 = arr->GetSy();
668 sy2 = arr1->GetSy();
669 sz1 = arr->GetSz();
670 sz2 = arr1->GetSz();
671
13918578 672 Int_t layer,ladder,detector;
cc088660 673 AliITSgeomTGeo::GetModuleId(module1,layer,ladder,detector);
bef31448 674 Float_t yclu1 = p1->GetY();
675 Float_t zclu1 = p1->GetZ();
676 Double_t cv=Curvature(primaryVertex[0],primaryVertex[1],x1,y1,x2,y2);
7e5bf5af 677
678 Double_t tgl2 = (z2-z1)/TMath::Sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
679 Double_t phi2 = TMath::ATan2((y2-y1),(x2-x1));
680
bef31448 681 for(Int_t l4=0;l4<end[3];l4++){ //loop on layer 4
00a7cc50 682 AliITSRecPoint* cl3 = (AliITSRecPoint*)listlayer[3]->At(l4);
bef31448 683 for(Int_t l5=0;l5<end[4];l5++){ //loop on layer 5
00a7cc50 684 AliITSRecPoint* cl4 = (AliITSRecPoint*)listlayer[4]->At(l5);
bef31448 685 for(Int_t l6=0;l6<end[5];l6++){ //loop on layer 6
00a7cc50 686 AliITSRecPoint* cl5 = (AliITSRecPoint*)listlayer[5]->At(l6);
cc088660 687 AliITStrackSA* trac = new AliITStrackSA(layer,ladder,detector,yclu1,zclu1,phi2,tgl2,cv,1);
bef31448 688
7e5bf5af 689 if(cl5!=0) {
690 trac->AddClusterV2(5,(clind5[l6] & 0x0fffffff)>>0);
691 trac->AddClusterMark(5,mark5[l6]);
692 }
693 if(cl4!=0){
694 trac->AddClusterV2(4,(clind4[l5] & 0x0fffffff)>>0);
695 trac->AddClusterMark(4,mark4[l5]);
696 }
697 if(cl3!=0){
698 trac->AddClusterV2(3,(clind3[l4] & 0x0fffffff)>>0);
699 trac->AddClusterMark(3,mark3[l4]);
700 }
701 if(cl2!=0){
702 trac->AddClusterV2(2,(clind2[l3] & 0x0fffffff)>>0);
703 trac->AddClusterMark(2,mark2[l3]);
704 }
705 if(cl1!=0){
706 trac->AddClusterV2(1,(clind1[l2] & 0x0fffffff)>>0);
707 trac->AddClusterMark(1,mark1[l2]);
708 }
709 if(cl0!=0){
710 trac->AddClusterV2(0,(clind0[l1] & 0x0fffffff)>>0);
711 trac->AddClusterMark(0,mark0[l1]);
712 }
e43c066c 713 //fit with Kalman filter using AliITStrackerMI::RefitAt()
bef31448 714
7e5bf5af 715
15dd636f 716 AliITStrackMI* ot = new AliITStrackSA(*trac);
bef31448 717
6c94f330 718 ot->ResetCovariance(10.);
bef31448 719 ot->ResetClusters();
720
721 if(RefitAt(49.,ot,trac)){ //fit from layer 1 to layer 6
15dd636f 722 AliITStrackMI *otrack2 = new AliITStrackMI(*ot);
6c94f330 723 otrack2->ResetCovariance(10.);
bef31448 724 otrack2->ResetClusters();
725 //fit from layer 6 to layer 1
73f446a0 726 if(RefitAt(3.7,otrack2,ot)) {
727 fListOfTracks->AddLast(otrack2);
7e5bf5af 728 new (tri[nlist]) AliITStrackSA(*trac);
729 nlist++;
73f446a0 730 } else {
731 delete otrack2;
732 }
bef31448 733
734 }
735
736 delete ot;
737 delete trac;
738 }//end loop layer 6
739 }//end loop layer 5
740 }//end loop layer 4
741
13918578 742 }//end loop layer 3
bef31448 743 }//end loop layer 2
13918578 744 }//end loop layer 1
745
037efb75 746 delete [] end;
747
7e5bf5af 748
749
4e05ab9a 750 Int_t dim=fListOfTracks->GetEntries();
13918578 751 if(dim==0){
cc088660 752 for(Int_t i=0;i<AliITSgeomTGeo::GetNLayers();i++){
13918578 753 delete listlayer[i];
754 }
c09cece6 755 delete [] listlayer;
00a7cc50 756 listSA->Delete();
757 delete listSA;
73f446a0 758 delete [] firstmod;
13918578 759 return 0;
760 }
761
7e5bf5af 762 Int_t lowchi2 = FindTrackLowChiSquare(fListOfTracks,dim);
763 AliITStrackV2* otrack =(AliITStrackV2*)fListOfTracks->At(lowchi2);
764 AliITStrackSA* trsa = (AliITStrackSA*)listSA->At(lowchi2);
765
73f446a0 766 if(otrack==0) {
cc088660 767 for(Int_t i=0;i<AliITSgeomTGeo::GetNLayers();i++){
73f446a0 768 delete listlayer[i];
769 }
c09cece6 770 delete [] listlayer;
00a7cc50 771 listSA->Delete();
772 delete listSA;
73f446a0 773 delete [] firstmod;
774 return 0;
775 }
cc088660 776 Int_t * indexc = new Int_t[AliITSgeomTGeo::GetNLayers()];
777 for(Int_t i=0;i<AliITSgeomTGeo::GetNLayers();i++) indexc[i]=0;
13918578 778 for(Int_t nind=0;nind<otrack->GetNumberOfClusters();nind++){
779 indexc[nind] = otrack->GetClusterIndex(nind);
780 }
00a7cc50 781 AliITSRecPoint* cl0 = (AliITSRecPoint*)GetCluster(indexc[0]);
782 AliITSRecPoint* cl1 = (AliITSRecPoint*)GetCluster(indexc[1]);
783 AliITSRecPoint* cl2 = (AliITSRecPoint*)GetCluster(indexc[2]);
784 AliITSRecPoint* cl3 = (AliITSRecPoint*)GetCluster(indexc[3]);
785 AliITSRecPoint* cl4 = (AliITSRecPoint*)GetCluster(indexc[4]);
13918578 786 Int_t labl[3]={-1,-1,-1};
cc088660 787 if(otrack->GetNumberOfClusters()==AliITSgeomTGeo::GetNLayers()){
00a7cc50 788 AliITSRecPoint* cl5 = (AliITSRecPoint*)GetCluster(indexc[5]);
13918578 789 labl[0]=cl5->GetLabel(0);
790 labl[1]=cl5->GetLabel(1);
791 labl[2]=cl5->GetLabel(2);
792 }
037efb75 793 delete [] indexc;
cc088660 794 if(otrack->GetNumberOfClusters()==(AliITSgeomTGeo::GetNLayers()-1)){
13918578 795 labl[0]=-1;
796 labl[1]=-1;
797 labl[2]=-1;
798 }
799 Int_t numberofpoints;
2257f27e 800 if(fSixPoints) numberofpoints=6;
13918578 801 else numberofpoints=5;
e43c066c 802 CookLabel(otrack,0.); //MI change - to see fake ratio
13918578 803 Int_t label = Label(cl0->GetLabel(0),cl1->GetLabel(0),
bef31448 804 cl2->GetLabel(0),cl3->GetLabel(0),
805 cl4->GetLabel(0),labl[0],
806 cl0->GetLabel(1),cl1->GetLabel(1),
807 cl2->GetLabel(1),cl3->GetLabel(1),
808 cl4->GetLabel(1),labl[1],
809 cl0->GetLabel(2),cl1->GetLabel(2),
810 cl2->GetLabel(2),cl3->GetLabel(2),
811 cl4->GetLabel(2),labl[2],numberofpoints);
13918578 812
813 otrack->SetLabel(label);
7e5bf5af 814 //remove clusters of found track
815
cc088660 816 for(Int_t nlay=0;nlay<AliITSgeomTGeo::GetNLayers();nlay++){
7e5bf5af 817 for(Int_t cln=0;cln<trsa->GetNumberOfMarked(nlay);cln++){
818 Int_t index = trsa->GetClusterMark(nlay,cln);
819 fCluLayer[nlay]->RemoveAt(index);
820 RemoveClusterCoord(nlay,index);
821 fCluLayer[nlay]->Compress();
822 }
823 }
824 listSA->Delete();
825 delete listSA;
826
cc088660 827 for(Int_t i=0;i<AliITSgeomTGeo::GetNLayers();i++){
13918578 828 delete listlayer[i];
829 }
c09cece6 830 delete [] listlayer;
037efb75 831 delete [] firstmod;
13918578 832 return otrack;
833
834}
835
bef31448 836
4e05ab9a 837
bef31448 838//_______________________________________________________
7e5bf5af 839Int_t AliITStrackerSA::SearchClusters(Int_t layer,Double_t phiwindow,Double_t lambdawindow, AliITStrackSA* trs,Double_t /*zvertex*/,Int_t pflag){
13918578 840 //function used to to find the clusters associated to the track
841 Int_t nc=0;
842 AliITSlayer &lay = fgLayers[layer];
7e5bf5af 843 Double_t r=lay.GetR();
844 if(pflag==1){
cfe729e0 845 Float_t cx1,cx2,cy1,cy2;
846 FindEquation(fPoint1[0],fPoint1[1],fPoint2[0],fPoint2[1],fPoint3[0],fPoint3[1],fCoef1,fCoef2,fCoef3);
847 if (FindIntersection(fCoef1,fCoef2,fCoef3,-r*r,cx1,cy1,cx2,cy2)==0)
848 return 0;
1966f03c 849 Double_t fi1=TMath::ATan2(cy1-fPoint1[1],cx1-fPoint1[0]);
850 Double_t fi2=TMath::ATan2(cy2-fPoint1[1],cx2-fPoint1[0]);
cfe729e0 851 fPhiEstimate=ChoosePoint(fi1,fi2,fPhic);
852 }
13918578 853
7e5bf5af 854
855 Int_t ncl = fCluLayer[layer]->GetEntries();
856 for (Int_t index=0; index<ncl; index++) {
00a7cc50 857 AliITSRecPoint *c = (AliITSRecPoint*)fCluLayer[layer]->At(index);
7e5bf5af 858 if (!c) continue;
859 if (c->GetQ()<=0) continue;
860
861 AliITSclusterTable* arr = (AliITSclusterTable*)GetClusterCoord(layer,index);
862 Double_t phi = arr->GetPhi();
cfe729e0 863 if (TMath::Abs(phi-fPhiEstimate)>phiwindow) continue;
494fda7c 864
7e5bf5af 865 Double_t lambda = arr->GetLambda();
cfe729e0 866 if (TMath::Abs(lambda-fLambdac)>lambdawindow) continue;
867
7e5bf5af 868 if(trs->GetNumberOfClustersSA()==trs->GetMaxNumberOfClusters()) return 0;
869 if(trs->GetNumberOfMarked(layer)==trs->GetMaxNMarkedPerLayer()) return 0;
870 Int_t orind = arr->GetOrInd();
871 trs->AddClusterSA(layer,orind);
872 trs->AddClusterMark(layer,index);
873
cfe729e0 874 nc++;
875 fLambdac=lambda;
876 fPhiEstimate=phi;
cfe729e0 877
7e5bf5af 878 fPointc[0]=arr->GetX();
879 fPointc[1]=arr->GetY();
880
cfe729e0 881 }
882 return nc;
883}
13918578 884
bef31448 885//________________________________________________________________
886void AliITStrackerSA::UpdatePoints(){
887 //update of points for the estimation of the curvature
13918578 888
bef31448 889 fPoint2[0]=fPoint3[0];
890 fPoint2[1]=fPoint3[1];
891 fPoint3[0]=fPointc[0];
892 fPoint3[1]=fPointc[1];
13918578 893
894
13918578 895}
13918578 896
13918578 897//___________________________________________________________________
898Int_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){
899
900 //given (x,y) of three recpoints (in global coordinates)
901 //returns the parameters a,b,c of circonference x*x + y*y +a*x + b*y +c
902
903 Float_t den = (x3-x1)*(y2-y1)-(x2-x1)*(y3-y1);
904 if(den==0) return 0;
905 a = ((y3-y1)*(x2*x2+y2*y2-x1*x1-y1*y1)-(y2-y1)*(x3*x3+y3*y3-x1*x1-y1*y1))/den;
906 b = -(x2*x2-x1*x1+y2*y2-y1*y1+a*(x2-x1))/(y2-y1);
907 c = -x1*x1-y1*y1-a*x1-b*y1;
908 return 1;
909 }
910//__________________________________________________________________________
911 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){
912
913 //Finds the intersection between the circonference of the track and the circonference centered in (0,0) represented by one layer
914 //c2 is -rlayer*rlayer
915
916 if(a1==0) return 0;
3a2f227d 917 Double_t m = c2-c1;
918 Double_t aA = (b1*b1)/(a1*a1)+1;
919 Double_t bB = (-2*m*b1/(a1*a1));
920 Double_t cC = c2+(m*m)/(a1*a1);
921 Double_t dD = bB*bB-4*aA*cC;
922 if(dD<0) return 0;
13918578 923
3a2f227d 924 y1 = (-bB+TMath::Sqrt(dD))/(2*aA);
925 y2 = (-bB-TMath::Sqrt(dD))/(2*aA);
13918578 926 x1 = (c2-c1-b1*y1)/a1;
927 x2 = (c2-c1-b1*y2)/a1;
928
929 return 1;
930}
931//____________________________________________________________________
932Double_t AliITStrackerSA::Curvature(Double_t x1,Double_t y1,Double_t
933x2,Double_t y2,Double_t x3,Double_t y3){
934
935 //calculates the curvature of track
936 Double_t den = (x3-x1)*(y2-y1)-(x2-x1)*(y3-y1);
937 if(den==0) return 0;
938 Double_t a = ((y3-y1)*(x2*x2+y2*y2-x1*x1-y1*y1)-(y2-y1)*(x3*x3+y3*y3-x1*x1-y1*y1))/den;
939 Double_t b = -(x2*x2-x1*x1+y2*y2-y1*y1+a*(x2-x1))/(y2-y1);
940 Double_t c = -x1*x1-y1*y1-a*x1-b*y1;
941 Double_t xc=-a/2.;
942
943 if((a*a+b*b-4*c)<0) return 0;
944 Double_t rad = TMath::Sqrt(a*a+b*b-4*c)/2.;
945 if(rad==0) return 0;
946
947 if((x1>0 && y1>0 && x1<xc)) rad*=-1;
948 if((x1<0 && y1>0 && x1<xc)) rad*=-1;
949 // if((x1<0 && y1<0 && x1<xc)) rad*=-1;
950 // if((x1>0 && y1<0 && x1<xc)) rad*=-1;
951
952 return 1/rad;
953
954}
7e5bf5af 955
956
13918578 957//____________________________________________________________________
958Double_t AliITStrackerSA::ChoosePoint(Double_t p1, Double_t p2, Double_t pp){
959
960 //Returns the point closest to pp
961
962 Double_t diff1 = p1-pp;
963 Double_t diff2 = p2-pp;
964
965 if(TMath::Abs(diff1)<TMath::Abs(diff2)) fPhiEstimate=p1;
966 else fPhiEstimate=p2;
967 return fPhiEstimate;
968
969}
970
971
972//_________________________________________________________________
7e5bf5af 973Int_t AliITStrackerSA::FindTrackLowChiSquare(TObjArray* tracklist, Int_t dim) const {
13918578 974 // returns track with lowes chi square
975 if(dim==1){
7e5bf5af 976 //AliITStrackV2* trk = (AliITStrackV2*)tracklist->At(0);
977 //return trk;
978 return 0;
13918578 979 }
7e5bf5af 980 //if(dim==0) return 0;
037efb75 981 Double_t * chi2 = new Double_t[dim];
982 Int_t * index = new Int_t[dim];
13918578 983 for(Int_t i=0;i<dim;i++){
984 AliITStrackV2* trk = (AliITStrackV2*)tracklist->At(i);
985 chi2[i]=trk->GetChi2();
986 index[i]=i;
987 }
988
989 Int_t w=0;Double_t value;
990 Int_t lp;
991 while(w<dim){
992 for(Int_t j=w+1;j<dim;j++){
993 if(chi2[w]<chi2[j]){
bef31448 994 value=chi2[w];
995 chi2[w]=chi2[j];
996 chi2[j]=value;
997 lp=index[w];
998 index[w]=index[j];
999 index[j]=lp;
13918578 1000 }
1001 }
1002 w++;
1003 }
1004
037efb75 1005 delete [] chi2;
1006 delete [] index;
7e5bf5af 1007 return index[dim-1];
13918578 1008}
1009
1010//__________________________________________________________
1011Int_t AliITStrackerSA::FindLabel(Int_t l1, Int_t l2, Int_t l3, Int_t l4, Int_t l5, Int_t l6){
1012
1013 //function used to determine the track label
1014
1015 Int_t lb[6] = {l1,l2,l3,l4,l5,l6};
1016 Int_t aa[6]={1,1,1,1,1,1};
1017 Int_t ff=0;
1018 Int_t ll=0;
1019 Int_t k=0;Int_t w=0;Int_t num=6;
1020 if(lb[5]==-1) num=5;
1021
1022 while(k<num){
1023
1024 for(Int_t i=k+1;i<num;i++){
1025
1026 if(lb[k]==lb[i] && aa[k]!=0){
1027
1028 aa[k]+=1;
1029 aa[i]=0;
1030 }
1031 }
1032 k++;
1033 }
1034
1035 while(w<num){
1036
1037 for(Int_t j=0;j<6;j++){
1038 if(aa[w]<aa[j]){
1039 ff=aa[w];
1040 aa[w]=aa[j];
1041 aa[j]=ff;
1042 ll=lb[w];
1043 lb[w]=lb[j];
1044 lb[j]=ll;
1045 }
1046 }
1047 w++;
1048 }
1049 if(num==6) return lb[5];
1050 else return lb[4];
1051}
1052
1053//_____________________________________________________________________________
1054Int_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,
1055Int_t gl12, Int_t gl13, Int_t gl14,Int_t gl15, Int_t gl16, Int_t gl17, Int_t gl18, Int_t numberofpoints){
1056
1057
1058 //function used to assign label to the found track. If track is fake, the label is negative
1059
1060 Int_t lb0[6] = {gl1,gl2,gl3,gl4,gl5,gl6};
1061 Int_t lb1[6] = {gl7,gl8,gl9,gl10,gl11,gl12};
1062 Int_t lb2[6] = {gl13,gl14,gl15,gl16,gl17,gl18};
1063 Int_t ll=FindLabel(lb0[0],lb0[1],lb0[2],lb0[3],lb0[4],lb0[5]);
1064 Int_t lflag=0;Int_t num=6;
1065 if(lb0[5]==-1 && lb1[5]==-1 && lb2[5]==-1) num=5;
1066
1067 for(Int_t i=0;i<num;i++){
1068 if(lb0[i]==ll || lb1[i]==ll || lb2[i]==ll) lflag+=1;
1069 }
1070
1071 if(lflag>=numberofpoints) return ll;
1072 else return -ll;
1073
1074
1075}
1076
1077//_____________________________________________________________________________
1078void AliITStrackerSA::SetWindowSizes(Int_t n, Double_t *phi, Double_t *lam){
1079 // Set sizes of the phi and lambda windows used for track finding
1080 fNloop = n;
1081 if(phi){ // user defined values
1082 fPhiWin = new Double_t[fNloop];
1083 fLambdaWin = new Double_t[fNloop];
1084 for(Int_t k=0;k<fNloop;k++){
1085 fPhiWin[k]=phi[k];
1086 fLambdaWin[k]=lam[k];
1087 }
1088 }
1089 else { // default values
627b6db6 1090
1091 Double_t phid[33] = {0.002,0.003,0.004,0.0045,0.0047,
bef31448 1092 0.005,0.0053,0.0055,
1093 0.006,0.0063,0.0065,0.007,0.0073,0.0075,0.0077,
1094 0.008,0.0083,0.0085,0.0087,0.009,0.0095,0.0097,
627b6db6 1095 0.01,0.0105,0.011,0.0115,0.012,0.0125,0.013,0.0135,0.0140,0.0145};
1096 Double_t lambdad[33] = {0.003,0.004,0.005,0.005,0.005,
1097 0.005,0.005,0.006,
1098 0.006,0.006,0.006,0.007,0.007,0.007,0.007,
1099 0.007,0.007,0.007,0.007,0.007,0.007,0.007,
1100 0.008,0.008,0.008,0.008,0.008,0.008,0.008,0.008,0.008,0.008};
bef31448 1101
627b6db6 1102 if(fNloop!=33){
1103 fNloop = 33;
13918578 1104 }
627b6db6 1105
1106
13918578 1107 fPhiWin = new Double_t[fNloop];
1108 fLambdaWin = new Double_t[fNloop];
1109
1110 for(Int_t k=0;k<fNloop;k++){
1111 fPhiWin[k]=phid[k];
1112 fLambdaWin[k]=lambdad[k];
1113 }
1114
1115 }
1116
1117}
7e5bf5af 1118//_______________________________________________________________________
cc088660 1119void AliITStrackerSA::GetCoorAngles(AliITSRecPoint* cl,Double_t &phi,Double_t &lambda, Float_t &x, Float_t &y,Float_t &z,Double_t* vertex){
7e5bf5af 1120 //Returns values of phi (azimuthal) and lambda angles for a given cluster
cc088660 1121/*
7e5bf5af 1122 Double_t rot[9]; fGeom->GetRotMatrix(module,rot);
1123 Int_t lay,lad,det; fGeom->GetModuleId(module,lay,lad,det);
1124 Float_t tx,ty,tz; fGeom->GetTrans(lay,lad,det,tx,ty,tz);
1125
1126 Double_t alpha=TMath::ATan2(rot[1],rot[0])+TMath::Pi();
1127 Double_t phi1=TMath::Pi()/2+alpha;
1128 if (lay==1) phi1+=TMath::Pi();
1129
1130 Float_t cp=TMath::Cos(phi1), sp=TMath::Sin(phi1);
1131 Float_t r=tx*cp+ty*sp;
1132
cc088660 1133 xyz= r*cp - cl->GetY()*sp;
7e5bf5af 1134 y= r*sp + cl->GetY()*cp;
1135 z=cl->GetZ();
cc088660 1136*/
1137 Float_t xyz[3];
1138 cl->GetGlobalXYZ(xyz);
1139 x=xyz[0];
1140 y=xyz[1];
1141 z=xyz[2];
1142
1966f03c 1143 phi=TMath::ATan2(y-vertex[1],x-vertex[0]);
7e5bf5af 1144 lambda=TMath::ATan2(z-vertex[2],TMath::Sqrt((x-vertex[0])*(x-vertex[0])+(y-vertex[1])*(y-vertex[1])));
1145}
13918578 1146
7e5bf5af 1147//________________________________________________________________________
cc088660 1148void AliITStrackerSA::GetCoorErrors(AliITSRecPoint* cl,Float_t &sx,Float_t &sy, Float_t &sz){
7e5bf5af 1149
cc088660 1150 //returns sigmax, y, z of cluster in global coordinates
1151/*
7e5bf5af 1152 Double_t rot[9]; fGeom->GetRotMatrix(module,rot);
cc088660 1153 Int_t lay,lad,det;
1154 AliITSgeomTGeo::GetModuleId(module,lay,lad,det);
7e5bf5af 1155
1156 Double_t alpha=TMath::ATan2(rot[1],rot[0])+TMath::Pi();
1157 Double_t phi=TMath::Pi()/2+alpha;
1158 if (lay==1) phi+=TMath::Pi();
1159
1160 Float_t cp=TMath::Cos(phi), sp=TMath::Sin(phi);
cc088660 1161*/
1162 Float_t covm[6];
1163 cl->GetGlobalCov(covm);
1164 sx=TMath::Sqrt(covm[0]);
1165 sy=TMath::Sqrt(covm[3]);
1166 sz=TMath::Sqrt(covm[5]);
1167/*
7e5bf5af 1168 sx = TMath::Sqrt(sp*sp*cl->GetSigmaY2());
1169 sy = TMath::Sqrt(cp*cp*cl->GetSigmaY2());
1170 sz = TMath::Sqrt(cl->GetSigmaZ2());
cc088660 1171*/
7e5bf5af 1172}
cc088660 1173
1174