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