]>
Commit | Line | Data |
---|---|---|
1d9af2d5 | 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 | ||
16 | /* $Id$ */ | |
17 | ||
18 | //////////////////////////////////////////////////// | |
19 | // ITS Upgrade Stand alone tracker class // | |
20 | // Authors: A.Mastroserio C.Terrevoli // | |
21 | // e-mail:annalisa.mastroserio@cern.ch // | |
22 | // cristina.terrevoli@ba.infn.it // | |
23 | //////////////////////////////////////////////////// | |
24 | ||
25 | #include <stdlib.h> | |
26 | ||
27 | #include <TArrayI.h> | |
28 | #include <TBranch.h> | |
29 | #include <TObjArray.h> | |
30 | #include <TTree.h> | |
31 | #include "AliRunLoader.h" | |
32 | #include "AliITSLoader.h" | |
33 | #include "AliESDEvent.h" | |
34 | #include "AliESDVertex.h" | |
35 | #include "AliESDtrack.h" | |
36 | #include "AliITSVertexer.h" | |
37 | #include "AliITSclusterTable.h" | |
0ac80088 | 38 | #include "AliITSRecPointU.h" |
0b255a22 | 39 | #include "AliITStrackU.h" |
1d9af2d5 | 40 | #include "AliITStrackerMI.h" |
41 | #include "AliITSlayerUpgrade.h" | |
42 | #include "AliITSsegmentationUpgrade.h" | |
43 | #include "AliITStrackerUpgrade.h" | |
44 | #include "AliITSReconstructor.h" | |
45 | #include "AliLog.h" | |
46 | #include "AliRun.h" | |
47 | ||
48 | ClassImp(AliITStrackerUpgrade) | |
49 | ||
50 | //____________________________________________________________________________ | |
556b741c | 51 | AliITStrackerUpgrade::AliITStrackerUpgrade(): |
52 | AliITStrackerMI(), | |
53 | fNLayers(), fPhiEstimate(0), fITSStandAlone(0), fLambdac(0), | |
54 | fPhic(0), fCoef1(0), fCoef2(0), fCoef3(0), fNloop(0), | |
55 | fPhiWin(0), fLambdaWin(0), fVert(0), fVertexer(0), | |
56 | fListOfTracks(0), fListOfUTracks(0), fITSclusters(0), | |
57 | fInwardFlag(0), fOuterStartLayer(0), fInnerStartLayer(0), | |
58 | fMinNPoints(0), fMinQ(0), fTrackToFollow(), fLayers(0), fSegmentation(0x0), | |
59 | fCluLayer(0), fCluCoord(0) | |
4211bbc5 | 60 | { |
61 | // Default constructor | |
62 | Init(); | |
665c0bc7 | 63 | |
4211bbc5 | 64 | } |
65 | //____________________________________________________________________________ | |
556b741c | 66 | AliITStrackerUpgrade::AliITStrackerUpgrade(Int_t nLay): |
67 | AliITStrackerMI(), | |
68 | fNLayers(nLay), fPhiEstimate(0), fITSStandAlone(0), fLambdac(0), | |
69 | fPhic(0), fCoef1(0), fCoef2(0), fCoef3(0), fNloop(0), | |
70 | fPhiWin(0), fLambdaWin(0), fVert(0), fVertexer(0), | |
71 | fListOfTracks(0), fListOfUTracks(0), fITSclusters(0), | |
72 | fInwardFlag(0), fOuterStartLayer(0), fInnerStartLayer(nLay), | |
73 | fMinNPoints(0), fMinQ(0), fTrackToFollow(), fLayers(0), fSegmentation(0x0), | |
74 | fCluLayer(0), fCluCoord(0) | |
4211bbc5 | 75 | { |
76 | // | |
77 | // constructor | |
78 | // | |
79 | Init(); | |
1d9af2d5 | 80 | |
4211bbc5 | 81 | } |
1d9af2d5 | 82 | //____________________________________________________________________________ |
83 | AliITStrackerUpgrade::~AliITStrackerUpgrade(){ | |
84 | // destructor | |
85 | // if fVertexer is not null, the AliESDVertex obj. is owned by this class | |
86 | // and is deleted here | |
87 | if(fVertexer){ | |
88 | if(fVert)delete fVert; | |
89 | } | |
90 | fVert = 0; | |
91 | fVertexer = 0; | |
92 | ||
93 | if(fPhiWin)delete []fPhiWin; | |
94 | if(fLambdaWin)delete []fLambdaWin; | |
95 | fListOfTracks->Delete(); | |
96 | delete fListOfTracks; | |
0b255a22 | 97 | fListOfUTracks->Delete(); |
98 | delete fListOfUTracks; | |
1d9af2d5 | 99 | if(fCluLayer){ |
665c0bc7 | 100 | for(Int_t i=0;i<fNLayers;i++){ |
1d9af2d5 | 101 | if(fCluLayer[i]){ |
102 | fCluLayer[i]->Delete(); | |
103 | delete fCluLayer[i]; | |
104 | } | |
105 | } | |
106 | delete [] fCluLayer; | |
107 | } | |
108 | if(fCluCoord){ | |
665c0bc7 | 109 | for(Int_t i=0;i<fNLayers;i++){ |
1d9af2d5 | 110 | if(fCluCoord[i]){ |
111 | fCluCoord[i]->Delete(); | |
112 | delete fCluCoord[i]; | |
113 | } | |
114 | } | |
115 | delete [] fCluCoord; | |
116 | } | |
117 | ||
f059e2be | 118 | if(fSegmentation) delete fSegmentation; |
1d9af2d5 | 119 | } |
120 | ||
121 | //____________________________________________________________________________ | |
122 | Int_t AliITStrackerUpgrade::Clusters2Tracks(AliESDEvent *event){ | |
123 | // This method is used to find and fit the tracks. By default the corresponding | |
124 | // method in the parent class is invoked. In this way a combined tracking | |
125 | // TPC+ITS is performed. If the flag fITSStandAlone is true, the tracking | |
126 | // is done in the ITS only. In the standard reconstruction chain this option | |
127 | // can be set via AliReconstruction::SetOption("ITS","onlyITS") | |
128 | Int_t rc=0; | |
129 | if(!fITSStandAlone){ | |
9b615954 | 130 | rc=AliITStrackerMI::Clusters2Tracks(event); // should not be used !! |
131 | // Note standalone tracking is implememted in "AliITStrackerU" | |
1d9af2d5 | 132 | } |
133 | else { | |
134 | AliDebug(1,"Stand Alone flag set: doing tracking in ITS alone\n"); | |
135 | } | |
136 | if(!rc){ | |
137 | rc=FindTracks(event,kFALSE); | |
138 | if(AliITSReconstructor::GetRecoParam()->GetSAUseAllClusters()==kTRUE) { | |
9b615954 | 139 | rc=FindTracks(event,kTRUE); // eventually a 2nd time ?????? |
1d9af2d5 | 140 | } |
141 | } | |
142 | return rc; | |
143 | } | |
144 | //_________________________________________________- | |
145 | void AliITStrackerUpgrade::Init(){ | |
146 | // Reset all data members | |
665c0bc7 | 147 | const Int_t nL = fNLayers; |
1d9af2d5 | 148 | fPhiEstimate=0; |
3e1215c5 | 149 | for(Int_t i=0;i<2;i++){fPoint1[i]=0;fPoint2[i]=0;fPoint3[i]=0;} |
1d9af2d5 | 150 | fLambdac=0; |
151 | fPhic=0; | |
152 | fCoef1=0; | |
153 | fCoef2=0; | |
154 | fCoef3=0; | |
155 | fPointc[0]=0; | |
156 | fPointc[1]=0; | |
157 | fVert = 0; | |
158 | fVertexer = 0; | |
159 | Int_t nLoops=AliITSReconstructor::GetRecoParam()->GetNLoopsSA(); | |
160 | if(nLoops==33){ | |
161 | SetFixedWindowSizes(); | |
162 | }else{ | |
163 | Double_t phimin=AliITSReconstructor::GetRecoParam()->GetMinPhiSA(); | |
164 | Double_t phimax=AliITSReconstructor::GetRecoParam()->GetMaxPhiSA(); | |
165 | Double_t lambmin=AliITSReconstructor::GetRecoParam()->GetMinLambdaSA(); | |
166 | Double_t lambmax=AliITSReconstructor::GetRecoParam()->GetMaxLambdaSA(); | |
167 | SetCalculatedWindowSizes(nLoops,phimin,phimax,lambmin,lambmax); | |
168 | } | |
169 | fMinQ=AliITSReconstructor::GetRecoParam()->GetSAMinClusterCharge(); | |
170 | fITSclusters = 0; | |
171 | SetOuterStartLayer(1); | |
172 | SetSAFlag(kFALSE); | |
4211bbc5 | 173 | fListOfTracks=new TClonesArray("AliITStrackU",100); |
0b255a22 | 174 | fListOfUTracks=new TClonesArray("AliITStrackU",100); |
665c0bc7 | 175 | fLayers=new AliITSlayerUpgrade*[nL];//to be fixed |
1d9af2d5 | 176 | fCluLayer = 0; |
177 | fCluCoord = 0; | |
178 | fMinNPoints = 3; | |
665c0bc7 | 179 | for(Int_t layer=0; layer<fNLayers; layer++){ |
1d9af2d5 | 180 | Double_t p=0.; |
181 | Double_t zC= 0.; | |
182 | fLayers[layer] = new AliITSlayerUpgrade(p,zC); | |
183 | } | |
184 | ||
db688ae2 | 185 | fSegmentation = new AliITSsegmentationUpgrade(); |
1d9af2d5 | 186 | |
187 | } | |
188 | //_______________________________________________________________________ | |
189 | Int_t AliITStrackerUpgrade::LoadClusters(TTree *clusTree){ | |
f059e2be | 190 | // |
191 | // Load clusters for tracking | |
192 | // | |
8d499867 | 193 | |
0ac80088 | 194 | TClonesArray statITSCluster("AliITSRecPointU"); |
9e7c5dbf | 195 | TClonesArray *itsCluster = &statITSCluster; |
8d499867 | 196 | |
f059e2be | 197 | TBranch* itsClusterBranch=clusTree->GetBranch("ITSRecPoints"); |
198 | if (!itsClusterBranch){ | |
199 | AliError("can't get the branch with the ITS clusters ! \n"); | |
200 | return 1; | |
201 | } | |
9e7c5dbf | 202 | itsClusterBranch->SetAddress(&itsCluster); |
f059e2be | 203 | clusTree->GetEvent(0); |
9e7c5dbf | 204 | Int_t nCluster = itsCluster->GetEntriesFast(); |
f059e2be | 205 | for(Int_t i=0; i<nCluster; i++){ |
9e7c5dbf | 206 | AliITSRecPointU *recp = (AliITSRecPointU*)itsCluster->UncheckedAt(i); |
0ac80088 | 207 | fLayers[recp->GetLayer()]->InsertCluster(new AliITSRecPointU(*recp)); |
f059e2be | 208 | }//loop clusters |
8d499867 | 209 | |
1d9af2d5 | 210 | SetClusterTree(clusTree); |
211 | return 0; | |
212 | } | |
213 | ||
214 | //_______________________________________________________ | |
215 | void AliITStrackerUpgrade::ResetForFinding(){ | |
216 | // Reset data members used in all loops during track finding | |
217 | fPhiEstimate=0; | |
3e1215c5 | 218 | for(Int_t i=0;i<2;i++){fPoint1[i]=0;fPoint2[i]=0;fPoint3[i]=0;} |
1d9af2d5 | 219 | fLambdac=0; |
220 | fPhic=0; | |
221 | fCoef1=0; | |
222 | fCoef2=0; | |
223 | fCoef3=0; | |
224 | fPointc[0]=0; | |
225 | fPointc[1]=0; | |
226 | fListOfTracks->Clear(); | |
0b255a22 | 227 | fListOfUTracks->Clear(); |
1d9af2d5 | 228 | } |
229 | ||
1d9af2d5 | 230 | //______________________________________________________________________ |
231 | Int_t AliITStrackerUpgrade::FindTracks(AliESDEvent* event,Bool_t useAllClusters){ | |
232 | ||
233 | // Track finder using the ESD object | |
234 | AliDebug(2,Form(" field is %f",event->GetMagneticField())); | |
9b615954 | 235 | |
1d9af2d5 | 236 | if(!fITSclusters){ |
237 | Fatal("FindTracks","ITS cluster tree is not accessed - Abort!!!\n Please use method SetClusterTree to pass the pointer to the tree\n"); | |
238 | return -1; | |
239 | } | |
240 | ||
9b615954 | 241 | // Reads event and mark clusters of tracks already found, with flag kITSin |
1d9af2d5 | 242 | Int_t nentr=event->GetNumberOfTracks(); |
243 | if(!useAllClusters) { | |
244 | while (nentr--) { | |
245 | AliESDtrack *track=event->GetTrack(nentr); | |
246 | if ((track->GetStatus()&AliESDtrack::kITSin) == AliESDtrack::kITSin){ | |
247 | Int_t idx[12]; | |
248 | Int_t ncl = track->GetITSclusters(idx); | |
249 | for(Int_t k=0;k<ncl;k++){ | |
0ac80088 | 250 | AliITSRecPointU* cll = (AliITSRecPointU*)GetCluster(idx[k]); |
1d9af2d5 | 251 | cll->SetBit(kSAflag); |
252 | } | |
253 | } | |
254 | } | |
255 | }else{ | |
256 | while (nentr--) { | |
257 | AliESDtrack *track=event->GetTrack(nentr); | |
258 | if ((track->GetStatus()&AliESDtrack::kITSin) == AliESDtrack::kITSin){ | |
259 | Int_t idx[12]; | |
260 | Int_t ncl = track->GetITSclusters(idx); | |
261 | for(Int_t k=0;k<ncl;k++){ | |
0ac80088 | 262 | AliITSRecPointU* cll = (AliITSRecPointU*)GetCluster(idx[k]); |
1d9af2d5 | 263 | cll->ResetBit(kSAflag); |
264 | } | |
265 | } | |
266 | } | |
267 | } | |
268 | //Get primary vertex | |
269 | Double_t primaryVertex[3]; | |
270 | event->GetVertex()->GetXYZ(primaryVertex); | |
4211bbc5 | 271 | Int_t nclusters[fNLayers]; |
665c0bc7 | 272 | for(Int_t i=0; i<fNLayers; i++){ |
0b255a22 | 273 | nclusters[i]=0; |
274 | } | |
275 | ||
4211bbc5 | 276 | Int_t dmar[fNLayers]; |
665c0bc7 | 277 | for(Int_t i=0; i<fNLayers; i++){ |
0b255a22 | 278 | dmar[i]=0; |
279 | } | |
280 | ||
1d9af2d5 | 281 | if (fCluLayer == 0) { |
665c0bc7 | 282 | fCluLayer = new TClonesArray*[fNLayers]; |
283 | fCluCoord = new TClonesArray*[fNLayers]; | |
284 | for(Int_t i=0;i<fNLayers;i++) { | |
1d9af2d5 | 285 | fCluLayer[i]=0; |
286 | fCluCoord[i]=0; | |
287 | } | |
288 | } | |
665c0bc7 | 289 | for(Int_t i=0;i<fNLayers;i++){ |
1d9af2d5 | 290 | if (!ForceSkippingOfLayer(i)) { |
291 | for(Int_t cli=0;cli<fLayers[i]->GetNumberOfClusters();cli++){ | |
0ac80088 | 292 | AliITSRecPointU* cls = (AliITSRecPointU*)fLayers[i]->GetCluster(cli); |
1d9af2d5 | 293 | if(cls->TestBit(kSAflag)==kTRUE) continue; //clusters used by TPC prol. |
294 | if(cls->GetQ()==0) continue; //fake clusters dead zones | |
295 | if(i>1 && cls->GetQ()<=fMinQ) continue; // cut on SDD and SSD cluster charge | |
296 | nclusters[i]++; | |
297 | } | |
298 | } | |
299 | dmar[i]=0; | |
300 | if(!fCluLayer[i]){ | |
0ac80088 | 301 | fCluLayer[i] = new TClonesArray("AliITSRecPointU",nclusters[i]); |
1d9af2d5 | 302 | }else{ |
303 | fCluLayer[i]->Delete(); | |
304 | fCluLayer[i]->Expand(nclusters[i]); | |
305 | } | |
306 | if(!fCluCoord[i]){ | |
307 | fCluCoord[i] = new TClonesArray("AliITSclusterTable",nclusters[i]); | |
308 | }else{ | |
309 | fCluCoord[i]->Delete(); | |
310 | fCluCoord[i]->Expand(nclusters[i]); | |
311 | } | |
312 | } | |
665c0bc7 | 313 | for(Int_t ilay=0;ilay<fNLayers;ilay++){ |
1d9af2d5 | 314 | TClonesArray &clulay = *fCluLayer[ilay]; |
315 | TClonesArray &clucoo = *fCluCoord[ilay]; | |
316 | if (!ForceSkippingOfLayer(ilay)){ | |
f059e2be | 317 | AliDebug(2,Form("number of clusters in layer %i : %i",ilay,fLayers[ilay]->GetNumberOfClusters())); |
1d9af2d5 | 318 | for(Int_t cli=0;cli<fLayers[ilay]->GetNumberOfClusters();cli++){ |
0ac80088 | 319 | AliITSRecPointU* cls = (AliITSRecPointU*)fLayers[ilay]->GetCluster(cli); |
1d9af2d5 | 320 | if(cls->TestBit(kSAflag)==kTRUE) continue; |
321 | if(cls->GetQ()==0) continue; | |
322 | Double_t phi=0;Double_t lambda=0; | |
323 | Double_t x=0;Double_t y=0;Double_t z=0; | |
324 | Float_t sx=0;Float_t sy=0;Float_t sz=0; | |
325 | GetCoorAngles(cls,phi,lambda,x,y,z,primaryVertex); | |
326 | GetCoorErrors(cls,sx,sy,sz); | |
327 | new (clulay[dmar[ilay]]) AliITSRecPoint(*cls); | |
328 | new (clucoo[dmar[ilay]]) AliITSclusterTable(x,y,z,sx,sy,sz,phi,lambda,cli); | |
329 | dmar[ilay]++; | |
330 | } | |
db688ae2 | 331 | } else AliDebug(2,Form("Force skipping layer %i",ilay)); |
1d9af2d5 | 332 | } |
333 | ||
334 | ||
335 | // track counter | |
336 | Int_t ntrack=0; | |
337 | ||
4211bbc5 | 338 | static Int_t nClusLay[fgMaxNLayer];//counter for clusters on each layer |
1d9af2d5 | 339 | Int_t startLayForSeed=0; |
340 | Int_t lastLayForSeed=fOuterStartLayer; | |
341 | Int_t nSeedSteps=lastLayForSeed-startLayForSeed; | |
342 | Int_t seedStep=1; | |
343 | if(fInwardFlag){ | |
665c0bc7 | 344 | startLayForSeed=fNLayers-1; |
1d9af2d5 | 345 | lastLayForSeed=fInnerStartLayer; |
346 | nSeedSteps=startLayForSeed-lastLayForSeed; | |
347 | seedStep=-1; | |
348 | } | |
349 | // loop on minimum number of points | |
665c0bc7 | 350 | for(Int_t iMinNPoints=fNLayers; iMinNPoints>=fMinNPoints; iMinNPoints--) { |
1d9af2d5 | 351 | // loop on starting layer for track finding |
352 | for(Int_t iSeedLay=0; iSeedLay<=nSeedSteps; iSeedLay++) { | |
353 | Int_t theLay=startLayForSeed+iSeedLay*seedStep; | |
354 | if(ForceSkippingOfLayer(theLay)) continue; | |
355 | Int_t minNPoints=iMinNPoints-theLay; | |
665c0bc7 | 356 | if(fInwardFlag) minNPoints=iMinNPoints-(fNLayers-1-theLay); |
357 | for(Int_t i=theLay+1;i<fNLayers;i++) | |
1d9af2d5 | 358 | if(ForceSkippingOfLayer(i)) |
359 | minNPoints--; | |
360 | if(minNPoints<fMinNPoints) continue; | |
361 | ||
362 | // loop on phi and lambda window size | |
363 | for(Int_t nloop=0;nloop<fNloop;nloop++){ | |
eaaed734 | 364 | Int_t nclTheLay=fCluLayer[theLay]->GetEntriesFast(); |
1d9af2d5 | 365 | while(nclTheLay--){ |
366 | ResetForFinding(); | |
367 | Bool_t useRP=SetFirstPoint(theLay,nclTheLay,primaryVertex); | |
368 | if(!useRP) continue; | |
665c0bc7 | 369 | AliITStrackU trs(fNLayers); |
1d9af2d5 | 370 | |
371 | Int_t pflag=0; | |
372 | Int_t kk; | |
665c0bc7 | 373 | for(kk=0;kk<fNLayers;kk++) nClusLay[kk] = 0; |
1d9af2d5 | 374 | kk=0; |
375 | nClusLay[kk] = SearchClusters(theLay,fPhiWin[nloop],fLambdaWin[nloop], | |
376 | &trs,primaryVertex[2],pflag); | |
377 | Int_t nextLay=theLay+seedStep; | |
dd290e92 | 378 | if(nextLay<0){ |
379 | AliWarning("Negative layer id. Please check!"); | |
380 | continue; | |
381 | } | |
1d9af2d5 | 382 | Bool_t goon=kTRUE; |
383 | while(goon){ | |
384 | ||
385 | kk++; | |
386 | nClusLay[kk] = SearchClusters(nextLay,fPhiWin[nloop],fLambdaWin[nloop], | |
387 | &trs,primaryVertex[2],pflag); | |
388 | if(nClusLay[kk]!=0){ | |
389 | ||
390 | pflag=1; | |
391 | if(kk==1) { | |
392 | fPoint3[0]=fPointc[0]; | |
393 | fPoint3[1]=fPointc[1]; | |
394 | } else { | |
395 | UpdatePoints(); | |
396 | } | |
397 | } | |
398 | nextLay+=seedStep; | |
665c0bc7 | 399 | if(nextLay<0 || nextLay==fNLayers) goon=kFALSE; |
1d9af2d5 | 400 | } |
401 | ||
402 | ||
403 | Int_t layOK=0; | |
404 | if(!fInwardFlag){ | |
665c0bc7 | 405 | for(Int_t nnp=0;nnp<fNLayers-theLay;nnp++){ |
1d9af2d5 | 406 | if(nClusLay[nnp]!=0) layOK+=1; |
407 | } | |
408 | }else{ | |
409 | for(Int_t nnp=theLay; nnp>=0; nnp--){ | |
410 | if(nClusLay[nnp]!=0) layOK+=1; | |
411 | } | |
412 | } | |
413 | if(layOK>=minNPoints){ | |
9b615954 | 414 | // AliDebug(2,Form("---NPOINTS: %d; MAP: %d %d %d %d %d %d %d\n",layOK,nClusLay[0],nClusLay[1],nClusLay[2],nClusLay[3],nClusLay[4],nClusLay[5],nClusLay[6])); |
1d9af2d5 | 415 | AliITStrackV2* tr2 = 0; |
416 | Bool_t onePoint = kFALSE; | |
4211bbc5 | 417 | tr2 = FitTrack(&trs,primaryVertex,onePoint); |
418 | if(!tr2){ | |
419 | continue; | |
420 | } | |
9b615954 | 421 | // AliDebug(2,Form("---NPOINTS fit: %d\n",tr2->GetNumberOfClusters())); |
1d9af2d5 | 422 | |
4211bbc5 | 423 | StoreTrack(tr2,event,useAllClusters); |
424 | ntrack++; | |
425 | ||
426 | } | |
1d9af2d5 | 427 | |
428 | }//end loop on clusters of theLay | |
429 | } //end loop on window sizes | |
430 | } //end loop on theLay | |
431 | }//end loop on min points | |
432 | if(!useAllClusters) AliInfo(Form("Number of found tracks: %d",event->GetNumberOfTracks())); | |
433 | ||
434 | ResetForFinding(); | |
435 | return 0; | |
436 | ||
437 | } | |
438 | ||
439 | //________________________________________________________________________ | |
440 | ||
0b255a22 | 441 | AliITStrackV2* AliITStrackerUpgrade::FitTrack(AliITStrackU* tr,Double_t *primaryVertex,Bool_t onePoint) { |
1d9af2d5 | 442 | |
0b255a22 | 443 | const Int_t kMaxClu=AliITStrackU::kMaxNumberOfClusters; |
1d9af2d5 | 444 | |
4211bbc5 | 445 | static Int_t clind[fgMaxNLayer][kMaxClu]; |
446 | static Int_t clmark[fgMaxNLayer][kMaxClu]; | |
447 | static Int_t end[fgMaxNLayer]; | |
0ac80088 | 448 | static AliITSRecPointU *listlayer[fgMaxNLayer][kMaxClu]; |
556b741c | 449 | static Int_t indices[fgMaxNLayer]; |
450 | ||
4211bbc5 | 451 | for(Int_t k=0;k<fgMaxNLayer; k++)end[k]=0; |
1d9af2d5 | 452 | |
665c0bc7 | 453 | for(Int_t i=0;i<fNLayers;i++) { |
1d9af2d5 | 454 | for(Int_t j=0;j<kMaxClu; j++){ |
455 | clind[i][j]=0; | |
456 | clmark[i][j]=0; | |
457 | listlayer[i][j]=0; | |
458 | } | |
459 | } | |
665c0bc7 | 460 | Int_t inx[fNLayers]; |
461 | for (Int_t k=0; k<fNLayers; k++) inx[k]=-1; | |
0b255a22 | 462 | Int_t nclusters = tr->GetNumberOfClustersU(); |
1d9af2d5 | 463 | for(Int_t ncl=0;ncl<nclusters;ncl++){ |
0b255a22 | 464 | Int_t index = tr->GetClusterIndexU(ncl); |
1d9af2d5 | 465 | Int_t lay = (index & 0xf0000000) >> 28; |
7dc6449a | 466 | //Int_t cli = index&0x0fffffff; |
9e396337 | 467 | //AliITSRecPoint* cl = (AliITSRecPoint*)fLayers[lay]->GetCluster(cli); |
0ac80088 | 468 | AliITSRecPointU* cl = (AliITSRecPointU*)GetCluster(index); |
1d9af2d5 | 469 | if(cl->TestBit(kSAflag)==kTRUE) cl->ResetBit(kSAflag); |
470 | inx[lay]=index; | |
471 | ||
472 | Int_t nInLay=end[lay]; | |
473 | listlayer[lay][nInLay]=cl; | |
474 | clind[lay][nInLay]=index; | |
475 | end[lay]++; | |
476 | } | |
477 | ||
665c0bc7 | 478 | for(Int_t nlay=0;nlay<fNLayers;nlay++){ |
1d9af2d5 | 479 | for(Int_t ncl=0;ncl<tr->GetNumberOfMarked(nlay);ncl++){ |
480 | Int_t mark = tr->GetClusterMark(nlay,ncl); | |
481 | clmark[nlay][ncl]=mark; | |
482 | } | |
483 | } | |
484 | ||
485 | ||
486 | Int_t firstLay=-1,secondLay=-1; | |
665c0bc7 | 487 | for(Int_t i=0;i<fNLayers;i++) { |
1d9af2d5 | 488 | if(end[i]==0) { |
489 | end[i]=1; | |
490 | }else{ | |
491 | if(firstLay==-1) { | |
492 | firstLay=i; | |
493 | } else if(secondLay==-1) { | |
494 | secondLay=i; | |
495 | } | |
496 | } | |
497 | } | |
498 | ||
4211bbc5 | 499 | //---adding initialization for non existent layers |
500 | for(Int_t i=fNLayers;i<fgMaxNLayer;i++) { | |
501 | if(end[i]==0) { | |
502 | end[i]=1; | |
503 | } | |
504 | } | |
505 | ||
506 | ||
507 | ||
1d9af2d5 | 508 | if(firstLay==-1 || (secondLay==-1 && !onePoint)) return 0; |
4211bbc5 | 509 | |
0b255a22 | 510 | TClonesArray &arrSA= *fListOfUTracks; |
1d9af2d5 | 511 | Int_t nFoundTracks=0; |
512 | ||
4211bbc5 | 513 | |
1d9af2d5 | 514 | for(Int_t l0=0;l0<end[0];l0++){ //loop on layer 1 |
556b741c | 515 | indices[0]=l0; |
1d9af2d5 | 516 | for(Int_t l1=0;l1<end[1];l1++){ //loop on layer 2 |
556b741c | 517 | indices[1]=l1; |
1d9af2d5 | 518 | for(Int_t l2=0;l2<end[2];l2++){ //loop on layer 3 |
556b741c | 519 | indices[2]=l2; |
1d9af2d5 | 520 | for(Int_t l3=0;l3<end[3];l3++){ //loop on layer 4 |
556b741c | 521 | indices[3]=l3; |
1d9af2d5 | 522 | for(Int_t l4=0;l4<end[4];l4++){ //loop on layer 5 |
556b741c | 523 | indices[4]=l4; |
1d9af2d5 | 524 | for(Int_t l5=0;l5<end[5];l5++){ //loop on layer 6 |
556b741c | 525 | indices[5]=l5; |
4211bbc5 | 526 | for(Int_t l6=0;l6<end[6];l6++){//loop on layer 7 |
556b741c | 527 | indices[6]=l6; |
4211bbc5 | 528 | for(Int_t l7=0;l7<end[7];l7++){ //loop on layer 8 |
556b741c | 529 | indices[7]=l7; |
530 | ||
531 | Int_t iFirstLay=indices[firstLay]; | |
532 | Int_t mrk1=clmark[firstLay][iFirstLay]; | |
533 | ||
4211bbc5 | 534 | Double_t x1,y1,z1,sx1,sy1,sz1; |
535 | Double_t x2,y2,z2,sx2,sy2,sz2; | |
556b741c | 536 | AliITSRecPointU* p1=(AliITSRecPointU*)listlayer[firstLay][iFirstLay]; |
4211bbc5 | 537 | Int_t layer = 0; |
538 | Double_t radius = 0.; | |
539 | Double_t yclu1 = p1->GetY(); | |
540 | Double_t zclu1 = p1->GetZ(); | |
541 | layer=p1->GetLayer(); | |
542 | radius = fSegmentation->GetRadius(layer); | |
543 | Double_t cv=0.,tgl2=0.,phi2=0.; | |
556b741c | 544 | AliITSclusterTable* arr1 = (AliITSclusterTable*)GetClusterCoord(firstLay,mrk1); |
4211bbc5 | 545 | x1 = arr1->GetX(); |
546 | y1 = arr1->GetY(); | |
547 | z1 = arr1->GetZ(); | |
548 | sx1 = arr1->GetSx(); | |
549 | sy1 = arr1->GetSy(); | |
550 | sz1 = arr1->GetSz(); | |
551 | ||
552 | if(secondLay>0) { | |
556b741c | 553 | Int_t iSecondLay=indices[secondLay]; |
554 | Int_t mrk2=clmark[secondLay][iSecondLay]; | |
555 | AliITSclusterTable* arr2 = (AliITSclusterTable*)GetClusterCoord(secondLay,mrk2); | |
4211bbc5 | 556 | x2 = arr2->GetX(); |
557 | y2 = arr2->GetY(); | |
558 | z2 = arr2->GetZ(); | |
559 | sx2 = arr2->GetSx(); | |
560 | sy2 = arr2->GetSy(); | |
561 | sz2 = arr2->GetSz(); | |
562 | cv = Curvature(primaryVertex[0],primaryVertex[1],x1,y1,x2,y2); | |
563 | tgl2 = (z2-z1)/TMath::Sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)); | |
564 | phi2 = TMath::ATan2((y2-y1),(x2-x1)); | |
565 | } | |
556b741c | 566 | |
4211bbc5 | 567 | Double_t x,y,z = 0.; |
568 | Double_t xz[2]; | |
556b741c | 569 | xz[0]= p1->GetDetLocalX(); |
570 | xz[1]= p1->GetDetLocalZ(); | |
571 | fSegmentation->DetToGlobal(layer,p1->GetModule(),xz[0], xz[1],x,y,z); | |
4211bbc5 | 572 | |
573 | ||
0ac80088 | 574 | Double_t phiclrad; |
4211bbc5 | 575 | phiclrad=TMath::ATan2(y,x); |
576 | if (phiclrad<0) phiclrad+=TMath::TwoPi(); | |
577 | else if (phiclrad>=TMath::TwoPi()) phiclrad-=TMath::TwoPi(); | |
578 | ||
556b741c | 579 | Double_t alpha = fSegmentation->GetAlpha(fSegmentation->GetModule(phiclrad)); |
317075a3 | 580 | |
581 | Int_t clIndice[fNLayers]; | |
582 | for (Int_t k=0; k<fNLayers; k++) clIndice[k]=-1; | |
0ac80088 | 583 | |
4211bbc5 | 584 | AliITStrackU trac(alpha,radius,yclu1,zclu1,phi2,tgl2,cv,1,fNLayers); |
317075a3 | 585 | for(Int_t iLay=fNLayers-1; iLay>=0; iLay--){ |
556b741c | 586 | Int_t iInLay=indices[iLay]; |
587 | AliITSRecPointU* cl=(AliITSRecPointU*)listlayer[iLay][iInLay]; | |
588 | if(cl!=0){ | |
589 | trac.AddClusterV2(iLay,(clind[iLay][iInLay] & 0x0fffffff)>>0); | |
590 | trac.AddClusterMark(iLay,clmark[iLay][iInLay]); | |
317075a3 | 591 | clIndice[iLay] = clind[iLay][iInLay]; |
556b741c | 592 | } |
4211bbc5 | 593 | } |
556b741c | 594 | |
4211bbc5 | 595 | //fit with Kalman filter using RefitAtBase() |
596 | AliITStrackU ot(trac, kFALSE); | |
597 | ot.ResetCovariance(10.); | |
598 | ot.ResetClusters(); | |
1d9af2d5 | 599 | |
4211bbc5 | 600 | // Propagate inside the innermost layer with a cluster |
601 | if(ot.Propagate(ot.GetX()-0.1*ot.GetX())) { | |
317075a3 | 602 | if(RefitAtBase(AliITSRecoParam::GetrInsideITSscreen(),&ot,clIndice)){ //fit from layer 1 to layer N |
4211bbc5 | 603 | AliITStrackU otrack2(ot,kFALSE); |
604 | otrack2.ResetCovariance(10.); | |
605 | otrack2.ResetClusters(); | |
4211bbc5 | 606 | //fit from last layer to layer 1 |
317075a3 | 607 | if(RefitAtBase(fSegmentation->GetRadius(0)-0.1,&otrack2,clIndice)) { |
4211bbc5 | 608 | new(arrSA[nFoundTracks]) AliITStrackU(otrack2); |
609 | ++nFoundTracks; | |
610 | } | |
1d9af2d5 | 611 | |
4211bbc5 | 612 | } |
613 | } | |
614 | ||
4211bbc5 | 615 | }//end loop layer 8 |
616 | }//end loop layer 7 | |
1d9af2d5 | 617 | }//end loop layer 6 |
618 | }//end loop layer 5 | |
619 | }//end loop layer 4 | |
620 | }//end loop layer 3 | |
621 | }//end loop layer 2 | |
622 | }//end loop layer 1 | |
623 | ||
624 | ||
625 | ||
626 | ||
4211bbc5 | 627 | if(fListOfUTracks->GetEntries()==0) return 0; |
1d9af2d5 | 628 | |
629 | Int_t lowchi2 = FindTrackLowChiSquare(); | |
4211bbc5 | 630 | AliITStrackU* otrack = (AliITStrackU*)fListOfUTracks->At(lowchi2); |
631 | ||
1d9af2d5 | 632 | if(otrack==0) { |
633 | return 0; | |
634 | } | |
0a64515a | 635 | |
9b615954 | 636 | // CookLabel(otrack,0.); //MI change - to see fake ratio |
637 | // printf(" label from CookLabel: %d \n ",otrack->GetLabel()); | |
638 | ||
0a64515a | 639 | Int_t label=FindLabel(otrack); |
640 | otrack->SetLabel(label); | |
9b615954 | 641 | // printf(" label from FindLabel: %d \n ",otrack->GetLabel()); |
0a64515a | 642 | |
665c0bc7 | 643 | Int_t indexc[fNLayers]; |
644 | for(Int_t i=0;i<fNLayers;i++) indexc[i]=0; | |
1d9af2d5 | 645 | for(Int_t nind=0;nind<otrack->GetNumberOfClusters();nind++){ |
646 | indexc[nind] = otrack->GetClusterIndex(nind); | |
647 | } | |
9b615954 | 648 | |
649 | ||
1d9af2d5 | 650 | //remove clusters of found track |
665c0bc7 | 651 | for(Int_t nlay=0;nlay<fNLayers;nlay++){ |
4211bbc5 | 652 | for(Int_t cln=0;cln<otrack->GetNumberOfMarked(nlay);cln++){ |
653 | Int_t index = otrack->GetClusterMark(nlay,cln); | |
1d9af2d5 | 654 | fCluLayer[nlay]->RemoveAt(index); |
655 | RemoveClusterCoord(nlay,index); | |
656 | fCluLayer[nlay]->Compress(); | |
657 | } | |
658 | } | |
9b615954 | 659 | |
1d9af2d5 | 660 | return otrack; |
661 | ||
662 | } | |
663 | ||
664 | //_______________________________________________________ | |
665 | void AliITStrackerUpgrade::StoreTrack(AliITStrackV2 *t,AliESDEvent *event, Bool_t pureSA) /*const*/ | |
666 | { | |
667 | // | |
668 | // Add new track to the ESD | |
669 | // | |
670 | AliESDtrack outtrack; | |
671 | outtrack.UpdateTrackParams(t,AliESDtrack::kITSin); | |
672 | if(pureSA) outtrack.SetStatus(AliESDtrack::kITSpureSA); | |
673 | outtrack.SetStatus(AliESDtrack::kITSout); | |
674 | outtrack.SetStatus(AliESDtrack::kITSrefit); | |
675 | Double_t sdedx[4]={0.,0.,0.,0.}; | |
676 | for(Int_t i=0; i<4; i++) sdedx[i]=t->GetSampledEdx(i); | |
677 | outtrack.SetITSdEdxSamples(sdedx); | |
678 | event->AddTrack(&outtrack); | |
679 | return; | |
680 | } | |
681 | ||
682 | ||
683 | //_______________________________________________________ | |
0b255a22 | 684 | Int_t AliITStrackerUpgrade::SearchClusters(Int_t layer,Double_t phiwindow,Double_t lambdawindow, AliITStrackU* trs,Double_t /*zvertex*/,Int_t pflag){ |
1d9af2d5 | 685 | //function used to to find the clusters associated to the track |
686 | ||
8d499867 | 687 | AliDebug(2,"Starting..."); |
688 | if(ForceSkippingOfLayer(layer)) { | |
f059e2be | 689 | AliDebug(2,Form("Forcing skipping of layer %i. Exiting",layer)); |
690 | return 0; | |
8d499867 | 691 | } |
1d9af2d5 | 692 | |
693 | Int_t nc=0; | |
db688ae2 | 694 | Double_t r=fSegmentation->GetRadius(layer); |
1d9af2d5 | 695 | if(pflag==1){ |
696 | Float_t cx1,cx2,cy1,cy2; | |
697 | FindEquation(fPoint1[0],fPoint1[1],fPoint2[0],fPoint2[1],fPoint3[0],fPoint3[1],fCoef1,fCoef2,fCoef3); | |
698 | if (FindIntersection(fCoef1,fCoef2,fCoef3,-r*r,cx1,cy1,cx2,cy2)==0) | |
699 | return 0; | |
700 | Double_t fi1=TMath::ATan2(cy1-fPoint1[1],cx1-fPoint1[0]); | |
701 | Double_t fi2=TMath::ATan2(cy2-fPoint1[1],cx2-fPoint1[0]); | |
702 | fPhiEstimate=ChoosePoint(fi1,fi2,fPhic); | |
703 | } | |
704 | ||
eaaed734 | 705 | |
706 | Double_t phiExpect=fPhiEstimate; | |
707 | Double_t lamExpect=fLambdac; | |
708 | ||
709 | Int_t ncl = fCluLayer[layer]->GetEntriesFast(); | |
1d9af2d5 | 710 | for (Int_t index=0; index<ncl; index++) { |
eaaed734 | 711 | |
1d9af2d5 | 712 | AliITSclusterTable* arr = (AliITSclusterTable*)GetClusterCoord(layer,index); |
1d9af2d5 | 713 | |
714 | Double_t lambda = arr->GetLambda(); | |
eaaed734 | 715 | if (TMath::Abs(lambda-lamExpect)>lambdawindow) continue; |
716 | ||
717 | Double_t phi = arr->GetPhi(); | |
718 | Double_t deltaPhi = phi-phiExpect; | |
719 | if(deltaPhi>TMath::Pi()) deltaPhi-=2*TMath::Pi(); | |
720 | else if(deltaPhi<-TMath::Pi()) deltaPhi+=2*TMath::Pi(); | |
721 | if (TMath::Abs(deltaPhi)>phiwindow) continue; | |
1d9af2d5 | 722 | |
0b255a22 | 723 | if(trs->GetNumberOfClustersU()==trs->GetMaxNumberOfClusters()) return 0; |
1d9af2d5 | 724 | if(trs->GetNumberOfMarked(layer)==trs->GetMaxNMarkedPerLayer()) return 0; |
725 | Int_t orind = arr->GetOrInd(); | |
0b255a22 | 726 | trs->AddClusterU(layer,orind); |
1d9af2d5 | 727 | trs->AddClusterMark(layer,index); |
1d9af2d5 | 728 | nc++; |
729 | fLambdac=lambda; | |
730 | fPhiEstimate=phi; | |
731 | ||
732 | fPointc[0]=arr->GetX(); | |
733 | fPointc[1]=arr->GetY(); | |
eaaed734 | 734 | |
1d9af2d5 | 735 | } |
736 | return nc; | |
eaaed734 | 737 | |
1d9af2d5 | 738 | } |
739 | ||
740 | //________________________________________________________________ | |
741 | Bool_t AliITStrackerUpgrade::SetFirstPoint(Int_t lay, Int_t clu, Double_t* primaryVertex){ | |
742 | // Sets the first point (seed) for tracking | |
743 | ||
0ac80088 | 744 | AliITSRecPointU* cl = (AliITSRecPointU*)fCluLayer[lay]->At(clu); |
1d9af2d5 | 745 | if(!cl) return kFALSE; |
746 | if (cl->GetQ()<=0) return kFALSE; | |
747 | if(lay>1 && cl->GetQ()<=fMinQ) return kFALSE; | |
748 | AliITSclusterTable* arr = (AliITSclusterTable*)GetClusterCoord(lay,clu); | |
749 | fPhic = arr->GetPhi(); | |
750 | fLambdac = arr->GetLambda(); | |
751 | fPhiEstimate = fPhic; | |
752 | fPoint1[0]=primaryVertex[0]; | |
753 | fPoint1[1]=primaryVertex[1]; | |
754 | fPoint2[0]=arr->GetX(); | |
755 | fPoint2[1]=arr->GetY(); | |
756 | return kTRUE; | |
757 | } | |
758 | ||
759 | //________________________________________________________________ | |
760 | void AliITStrackerUpgrade::UpdatePoints(){ | |
761 | //update of points for the estimation of the curvature | |
762 | ||
763 | fPoint2[0]=fPoint3[0]; | |
764 | fPoint2[1]=fPoint3[1]; | |
765 | fPoint3[0]=fPointc[0]; | |
766 | fPoint3[1]=fPointc[1]; | |
1d9af2d5 | 767 | } |
1d9af2d5 | 768 | //___________________________________________________________________ |
769 | Int_t AliITStrackerUpgrade::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){ | |
770 | ||
771 | //given (x,y) of three recpoints (in global coordinates) | |
772 | //returns the parameters a,b,c of circonference x*x + y*y +a*x + b*y +c | |
773 | ||
774 | Float_t den = (x3-x1)*(y2-y1)-(x2-x1)*(y3-y1); | |
775 | if(den==0) return 0; | |
776 | a = ((y3-y1)*(x2*x2+y2*y2-x1*x1-y1*y1)-(y2-y1)*(x3*x3+y3*y3-x1*x1-y1*y1))/den; | |
777 | b = -(x2*x2-x1*x1+y2*y2-y1*y1+a*(x2-x1))/(y2-y1); | |
778 | c = -x1*x1-y1*y1-a*x1-b*y1; | |
779 | return 1; | |
780 | } | |
781 | //__________________________________________________________________________ | |
782 | Int_t AliITStrackerUpgrade::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){ | |
783 | ||
784 | //Finds the intersection between the circonference of the track and the circonference centered in (0,0) represented by one layer | |
785 | //c2 is -rlayer*rlayer | |
786 | ||
787 | if(a1==0) return 0; | |
788 | Double_t m = c2-c1; | |
789 | Double_t aA = (b1*b1)/(a1*a1)+1; | |
790 | Double_t bB = (-2*m*b1/(a1*a1)); | |
791 | Double_t cC = c2+(m*m)/(a1*a1); | |
792 | Double_t dD = bB*bB-4*aA*cC; | |
793 | if(dD<0) return 0; | |
794 | ||
795 | y1 = (-bB+TMath::Sqrt(dD))/(2*aA); | |
796 | y2 = (-bB-TMath::Sqrt(dD))/(2*aA); | |
797 | x1 = (c2-c1-b1*y1)/a1; | |
798 | x2 = (c2-c1-b1*y2)/a1; | |
799 | ||
800 | return 1; | |
801 | } | |
802 | //____________________________________________________________________ | |
803 | Double_t AliITStrackerUpgrade::Curvature(Double_t x1,Double_t y1,Double_t | |
804 | x2,Double_t y2,Double_t x3,Double_t y3){ | |
805 | ||
806 | //calculates the curvature of track | |
807 | Double_t den = (x3-x1)*(y2-y1)-(x2-x1)*(y3-y1); | |
808 | if(den==0) return 0; | |
809 | Double_t a = ((y3-y1)*(x2*x2+y2*y2-x1*x1-y1*y1)-(y2-y1)*(x3*x3+y3*y3-x1*x1-y1*y1))/den; | |
810 | Double_t b = -(x2*x2-x1*x1+y2*y2-y1*y1+a*(x2-x1))/(y2-y1); | |
811 | Double_t c = -x1*x1-y1*y1-a*x1-b*y1; | |
812 | Double_t xc=-a/2.; | |
813 | ||
814 | if((a*a+b*b-4*c)<0) return 0; | |
815 | Double_t rad = TMath::Sqrt(a*a+b*b-4*c)/2.; | |
816 | if(rad==0) return 0; | |
817 | ||
818 | if((x1>0 && y1>0 && x1<xc)) rad*=-1; | |
819 | if((x1<0 && y1>0 && x1<xc)) rad*=-1; | |
820 | // if((x1<0 && y1<0 && x1<xc)) rad*=-1; | |
821 | // if((x1>0 && y1<0 && x1<xc)) rad*=-1; | |
822 | ||
823 | return 1/rad; | |
824 | ||
825 | } | |
1d9af2d5 | 826 | //____________________________________________________________________ |
827 | Double_t AliITStrackerUpgrade::ChoosePoint(Double_t p1, Double_t p2, Double_t pp){ | |
828 | ||
829 | //Returns the point closest to pp | |
830 | ||
831 | Double_t diff1 = p1-pp; | |
832 | Double_t diff2 = p2-pp; | |
833 | ||
834 | if(TMath::Abs(diff1)<TMath::Abs(diff2)) fPhiEstimate=p1; | |
835 | else fPhiEstimate=p2; | |
836 | return fPhiEstimate; | |
837 | ||
838 | } | |
1d9af2d5 | 839 | //_________________________________________________________________ |
840 | Int_t AliITStrackerUpgrade::FindTrackLowChiSquare() const { | |
9e7c5dbf | 841 | |
1d9af2d5 | 842 | // returns track with lowest chi square |
9e7c5dbf | 843 | |
844 | Int_t dim=fListOfUTracks->GetEntries(); | |
1d9af2d5 | 845 | if(dim<=1) return 0; |
4211bbc5 | 846 | AliITStrackV2* trk = (AliITStrackV2*)fListOfUTracks->At(0); |
9e7c5dbf | 847 | Double_t minChi2=trk->GetChi2()/trk->GetNumberOfClusters(); |
1d9af2d5 | 848 | Int_t index=0; |
849 | for(Int_t i=1;i<dim;i++){ | |
4211bbc5 | 850 | trk = (AliITStrackV2*)fListOfUTracks->At(i); |
9e7c5dbf | 851 | Double_t chi2=trk->GetChi2()/trk->GetNumberOfClusters(); |
1d9af2d5 | 852 | if(chi2<minChi2){ |
853 | minChi2=chi2; | |
854 | index=i; | |
855 | } | |
856 | } | |
857 | return index; | |
9e7c5dbf | 858 | |
1d9af2d5 | 859 | } |
860 | ||
861 | //__________________________________________________________ | |
0a64515a | 862 | Int_t AliITStrackerUpgrade::FindLabel(AliITStrackV2* track) const { |
863 | // | |
9b615954 | 864 | // max number of labels in AliITSRecPointU is 24; |
865 | enum {kMaxLab=24}; | |
1d9af2d5 | 866 | |
9b615954 | 867 | Int_t labl[fNLayers][kMaxLab]; |
868 | Int_t cnts[fNLayers][kMaxLab]; | |
665c0bc7 | 869 | for(Int_t j=0;j<fNLayers;j++){ |
9b615954 | 870 | for(Int_t k=0;k<kMaxLab;k++){ |
0a64515a | 871 | labl[j][k]=-2; |
872 | cnts[j][k]=1; | |
873 | } | |
874 | } | |
875 | Int_t iNotLabel=0; | |
876 | for(Int_t i=0;i<track->GetNumberOfClusters(); i++) { | |
877 | Int_t indexc = track->GetClusterIndex(i); | |
0ac80088 | 878 | AliITSRecPointU* cl = (AliITSRecPointU*)GetCluster(indexc); |
9b615954 | 879 | // AliDebug(2,Form("Layer %d; cluster index %i; MClabels=(%d,%d,%d) ", |
880 | // cl->GetLayer(),indexc,cl->GetLabel(0),cl->GetLabel(1),cl->GetLabel(2))); | |
0a64515a | 881 | Int_t iLayer=cl->GetLayer(); |
9b615954 | 882 | for(Int_t k=0;k<kMaxLab;k++){ |
883 | labl[iLayer][k]=cl->GetTrackID(k); | |
0a64515a | 884 | if(labl[iLayer][k]<0) iNotLabel++; |
885 | } | |
886 | } | |
9b615954 | 887 | if(iNotLabel==kMaxLab*track->GetNumberOfClusters()) return -2; // No MC label found at all |
0a64515a | 888 | |
665c0bc7 | 889 | for(Int_t j1=0;j1<fNLayers; j1++) { |
0a64515a | 890 | for(Int_t j2=0; j2<j1; j2++){ |
9b615954 | 891 | for(Int_t k1=0; k1<kMaxLab; k1++){ |
892 | for(Int_t k2=0; k2<kMaxLab; k2++){ | |
0a64515a | 893 | if(labl[j1][k1]>=0 && labl[j1][k1]==labl[j2][k2] && cnts[j2][k2]>0){ |
894 | cnts[j2][k2]++; | |
895 | cnts[j1][k1]=0; | |
896 | } | |
897 | } | |
898 | } | |
899 | } | |
900 | } | |
1d9af2d5 | 901 | |
0a64515a | 902 | |
903 | Int_t cntMax=0; | |
904 | Int_t label=-1; | |
665c0bc7 | 905 | for(Int_t j=0;j<fNLayers;j++){ |
9b615954 | 906 | for(Int_t k=0;k<kMaxLab;k++){ |
0a64515a | 907 | if(cnts[j][k]>cntMax && labl[j][k]>=0){ |
908 | cntMax=cnts[j][k]; | |
909 | label=labl[j][k]; | |
910 | } | |
911 | } | |
912 | } | |
913 | ||
914 | Int_t lflag=0; | |
9b615954 | 915 | for(Int_t i=0;i<fNLayers;i++) { |
916 | Bool_t labelOkInLayer = kFALSE; | |
917 | for(Int_t k=0;k<kMaxLab;k++){ | |
918 | if (labl[i][k]==label) { | |
919 | labelOkInLayer=kTRUE; | |
920 | break; | |
921 | } | |
922 | } | |
923 | if(labelOkInLayer) lflag++; | |
924 | } | |
925 | if(lflag<track->GetNumberOfClusters()) { | |
926 | if (label==0) { | |
927 | label = -1; // to avoid label 0 which can not be identified as as fake with -0 | |
928 | } else { | |
929 | label = -label; | |
930 | } | |
931 | } | |
932 | if (label<0) { | |
933 | for(Int_t i=0;i<track->GetNumberOfClusters(); i++) { | |
934 | Int_t indexc = track->GetClusterIndex(i); | |
935 | AliITSRecPointU* cl = (AliITSRecPointU*)GetCluster(indexc); | |
936 | AliDebug(2,Form("Layer %d; cluster index %i; MClabels=(%d,%d,%d...) ", | |
937 | cl->GetLayer(),indexc,cl->GetTrackID(0),cl->GetTrackID(1),cl->GetTrackID(2))); | |
938 | } | |
939 | } | |
940 | ||
941 | ||
0a64515a | 942 | return label; |
1d9af2d5 | 943 | } |
9b615954 | 944 | |
1d9af2d5 | 945 | //_____________________________________________________________________________ |
1d9af2d5 | 946 | void AliITStrackerUpgrade::SetCalculatedWindowSizes(Int_t n, Float_t phimin, Float_t phimax, Float_t lambdamin, Float_t lambdamax){ |
947 | // Set sizes of the phi and lambda windows used for track finding | |
948 | fNloop = n; | |
949 | if(fPhiWin) delete [] fPhiWin; | |
950 | if(fLambdaWin) delete [] fLambdaWin; | |
951 | fPhiWin = new Double_t[fNloop]; | |
952 | fLambdaWin = new Double_t[fNloop]; | |
953 | Float_t stepPhi=(phimax-phimin)/(Float_t)(fNloop-1); | |
954 | Float_t stepLambda=(lambdamax-lambdamin)/(Float_t)(fNloop-1); | |
955 | for(Int_t k=0;k<fNloop;k++){ | |
956 | Float_t phi=phimin+k*stepPhi; | |
957 | Float_t lam=lambdamin+k*stepLambda; | |
958 | fPhiWin[k]=phi; | |
959 | fLambdaWin[k]=lam; | |
960 | } | |
961 | } | |
962 | //_____________________________________________________________________________ | |
963 | void AliITStrackerUpgrade::SetFixedWindowSizes(Int_t n, Double_t *phi, Double_t *lam){ | |
964 | // Set sizes of the phi and lambda windows used for track finding | |
965 | fNloop = n; | |
966 | if(phi){ // user defined values | |
967 | fPhiWin = new Double_t[fNloop]; | |
968 | fLambdaWin = new Double_t[fNloop]; | |
969 | for(Int_t k=0;k<fNloop;k++){ | |
970 | fPhiWin[k]=phi[k]; | |
971 | fLambdaWin[k]=lam[k]; | |
972 | } | |
973 | } | |
974 | else { // default values | |
975 | ||
976 | Double_t phid[33] = {0.002,0.003,0.004,0.0045,0.0047, | |
977 | 0.005,0.0053,0.0055, | |
978 | 0.006,0.0063,0.0065,0.007,0.0073,0.0075,0.0077, | |
979 | 0.008,0.0083,0.0085,0.0087,0.009,0.0095,0.0097, | |
980 | 0.01,0.0105,0.011,0.0115,0.012,0.0125,0.013,0.0135,0.0140,0.0145}; | |
981 | Double_t lambdad[33] = {0.003,0.004,0.005,0.005,0.005, | |
982 | 0.005,0.005,0.006, | |
983 | 0.006,0.006,0.006,0.007,0.007,0.007,0.007, | |
984 | 0.007,0.007,0.007,0.007,0.007,0.007,0.007, | |
985 | 0.008,0.008,0.008,0.008,0.008,0.008,0.008,0.008,0.008,0.008}; | |
986 | ||
987 | if(fNloop!=33){ | |
988 | fNloop = 33; | |
989 | } | |
990 | ||
991 | ||
992 | fPhiWin = new Double_t[fNloop]; | |
993 | fLambdaWin = new Double_t[fNloop]; | |
994 | ||
995 | Double_t factor=AliITSReconstructor::GetRecoParam()->GetFactorSAWindowSizes(); | |
996 | ||
997 | for(Int_t k=0;k<fNloop;k++){ | |
998 | fPhiWin[k]=phid[k]*factor; | |
999 | fLambdaWin[k]=lambdad[k]*factor; | |
1000 | } | |
1001 | ||
1002 | } | |
1003 | ||
1004 | } | |
1005 | //_______________________________________________________________________ | |
0ac80088 | 1006 | void AliITStrackerUpgrade::GetCoorAngles(AliITSRecPointU* cl,Double_t &phi,Double_t &lambda, Double_t &x, Double_t &y,Double_t &z,Double_t* vertex){ |
1d9af2d5 | 1007 | //Returns values of phi (azimuthal) and lambda angles for a given cluster |
1d9af2d5 | 1008 | |
1009 | Double_t xz[2]; | |
1010 | xz[0]= cl->GetDetLocalX(); | |
1011 | xz[1]= cl->GetDetLocalZ() ; | |
1d9af2d5 | 1012 | Int_t ilayer; |
1013 | ilayer = cl->GetLayer(); | |
556b741c | 1014 | fSegmentation->DetToGlobal(ilayer,cl->GetModule(),xz[0], xz[1],x,y,z); |
1d9af2d5 | 1015 | |
1016 | if(x!=0 && y!=0) | |
1017 | phi=TMath::ATan2(y-vertex[1],x-vertex[0]); | |
1018 | lambda=TMath::ATan2(z-vertex[2],TMath::Sqrt((x-vertex[0])*(x-vertex[0])+(y-vertex[1])*(y-vertex[1]))); | |
1019 | } | |
1020 | ||
1021 | //________________________________________________________________________ | |
0ac80088 | 1022 | void AliITStrackerUpgrade::GetCoorErrors(AliITSRecPointU* cl,Float_t &sx,Float_t &sy, Float_t &sz){ |
1d9af2d5 | 1023 | |
1024 | //returns sigmax, y, z of cluster in global coordinates | |
1025 | /* | |
1026 | Double_t rot[9]; fGeom->GetRotMatrix(module,rot); | |
1027 | Int_t lay,lad,det; | |
1028 | AliITSgeomTGeo::GetModuleId(module,lay,lad,det); | |
1029 | ||
1030 | Double_t alpha=TMath::ATan2(rot[1],rot[0])+TMath::Pi(); | |
1031 | Double_t phi=TMath::Pi()/2+alpha; | |
1032 | if (lay==1) phi+=TMath::Pi(); | |
1033 | ||
1034 | Float_t cp=TMath::Cos(phi), sp=TMath::Sin(phi); | |
1035 | */ | |
1036 | Float_t covm[6]; | |
1037 | cl->GetGlobalCov(covm); | |
1038 | sx=TMath::Sqrt(covm[0]); | |
1039 | sy=TMath::Sqrt(covm[3]); | |
1040 | sz=TMath::Sqrt(covm[5]); | |
1041 | ||
1042 | ||
1043 | ||
1044 | // Float_t covm[6]; | |
1045 | // cl->GetGlobalCov(covm); | |
1046 | // sx=12*1e-04;//TMath::Sqrt(covm[0]); | |
1047 | // sy=12*1e-04;//TMath::Sqrt(covm[3]); | |
1048 | // sz=40*1e-04;//TMath::Sqrt(covm[5]); | |
1049 | /* | |
1050 | sx = TMath::Sqrt(sp*sp*cl->GetSigmaY2()); | |
1051 | sy = TMath::Sqrt(cp*cp*cl->GetSigmaY2()); | |
1052 | sz = TMath::Sqrt(cl->GetSigmaZ2()); | |
1053 | */ | |
1054 | } | |
1055 | //_____________________________________________________________ | |
1056 | void AliITStrackerUpgrade::UnloadClusters() { | |
1057 | //-------------------------------------------------------------------- | |
1058 | //This function unloads ITS clusters | |
1059 | //-------------------------------------------------------------------- | |
665c0bc7 | 1060 | for (Int_t i=0; i<fNLayers; i++) fLayers[i]->ResetClusters(); |
1d9af2d5 | 1061 | } |
1062 | //______________________________________________________________________ | |
4211bbc5 | 1063 | Bool_t AliITStrackerUpgrade::RefitAtBase(Double_t xx,AliITStrackU *track, |
1d9af2d5 | 1064 | const Int_t *clusters) |
1065 | { | |
1066 | //-------------------------------------------------------------------- | |
1067 | // Simplified version for ITS upgrade studies -- does not use module info | |
1068 | //-------------------------------------------------------------------- | |
665c0bc7 | 1069 | Int_t index[fNLayers]; |
1d9af2d5 | 1070 | Int_t k; |
665c0bc7 | 1071 | for (k=0; k<fNLayers; k++) index[k]=-1; |
1d9af2d5 | 1072 | // |
665c0bc7 | 1073 | for (k=0; k<fNLayers; k++) { |
1d9af2d5 | 1074 | index[k]=clusters[k]; |
1075 | } | |
1d9af2d5 | 1076 | |
1077 | ULong_t trStatus=0; | |
1078 | if(track->GetESDtrack()) trStatus=track->GetStatus(); | |
1079 | Int_t innermostlayer=0; | |
1080 | if(trStatus&AliESDtrack::kTPCin) { | |
665c0bc7 | 1081 | innermostlayer=fNLayers-1; |
1d9af2d5 | 1082 | Double_t drphi = TMath::Abs(track->GetD(0.,0.)); |
665c0bc7 | 1083 | for(innermostlayer=0; innermostlayer<fNLayers; innermostlayer++) { |
db688ae2 | 1084 | if( (drphi < (fSegmentation->GetRadius(innermostlayer)+1.)) || |
1d9af2d5 | 1085 | index[innermostlayer] >= 0 ) break; |
1086 | } | |
1087 | AliDebug(2,Form(" drphi %f innermost %d",drphi,innermostlayer)); | |
1088 | } | |
1089 | ||
1090 | Int_t from, to, step; | |
1091 | if (xx > track->GetX()) { | |
665c0bc7 | 1092 | from=innermostlayer; to=fNLayers; |
1d9af2d5 | 1093 | step=+1; |
1094 | } else { | |
665c0bc7 | 1095 | from=fNLayers-1; to=innermostlayer-1; |
1d9af2d5 | 1096 | step=-1; |
1097 | } | |
1098 | TString dir = (step>0 ? "outward" : "inward"); | |
1099 | ||
1100 | for (Int_t ilayer = from; ilayer != to; ilayer += step) { | |
1101 | Double_t r=0.; | |
db688ae2 | 1102 | r=fSegmentation->GetRadius(ilayer); |
1d9af2d5 | 1103 | |
1104 | if (step<0 && xx>r){ | |
1105 | break; | |
1106 | } | |
1107 | ||
1d9af2d5 | 1108 | |
1109 | Double_t oldGlobXYZ[3]; | |
1110 | ||
1111 | if (!track->GetXYZ(oldGlobXYZ)) { | |
1112 | return kFALSE; | |
1113 | } | |
1114 | // continue if we are already beyond this layer | |
1115 | Double_t oldGlobR = TMath::Sqrt(oldGlobXYZ[0]*oldGlobXYZ[0]+oldGlobXYZ[1]*oldGlobXYZ[1]); | |
1116 | if(step>0 && oldGlobR > r){ | |
1117 | continue; // going outward | |
1118 | } | |
1119 | if(step<0 && oldGlobR < r) { | |
1120 | continue; // going inward | |
1121 | } | |
1122 | Double_t phi,z; | |
1123 | if (!track->GetPhiZat(r,phi,z)){ | |
1124 | return kFALSE; | |
556b741c | 1125 | } // only for ITS-SA tracks refit |
1d9af2d5 | 1126 | track->SetCheckInvariant(kFALSE); |
1127 | ||
1128 | if (phi<0) phi+=TMath::TwoPi();//from 0 to 360 (rad) | |
1129 | else if (phi>=TMath::TwoPi()) phi-=TMath::TwoPi();// | |
0ac80088 | 1130 | |
9b615954 | 1131 | Int_t trkModule = fSegmentation->GetModule(phi); |
1132 | ||
1133 | Double_t alpha = fSegmentation->GetAlpha(trkModule); | |
1d9af2d5 | 1134 | if (!track->Propagate(alpha,r)) { |
1d9af2d5 | 1135 | return kFALSE; |
1136 | } | |
1137 | ||
0ac80088 | 1138 | const AliITSRecPointU *clAcc=0; |
1d9af2d5 | 1139 | Double_t maxchi2=1000.*AliITSReconstructor::GetRecoParam()->GetMaxChi2(); |
1140 | ||
1141 | Int_t idx=index[ilayer]; | |
1142 | if (idx>=0) { // cluster in this layer | |
1143 | Int_t cli = idx&0x0fffffff; | |
9b615954 | 1144 | AliITSRecPointU *cl=(AliITSRecPointU *)fLayers[ilayer]->GetCluster(cli); |
1d9af2d5 | 1145 | |
1146 | if (cl) { | |
1147 | Int_t cllayer = (idx & 0xf0000000) >> 28;; | |
9b615954 | 1148 | // edge effect correction |
9b615954 | 1149 | if(trkModule!=cl->GetModule()){ |
1150 | if (!track->Propagate(fSegmentation->GetAlpha(cl->GetModule()),fSegmentation->GetRadius(ilayer))) return kFALSE; | |
1151 | } | |
1d9af2d5 | 1152 | Double_t chi2=GetPredictedChi2MI(track,cl,cllayer); |
1153 | if (chi2<maxchi2) { | |
1154 | clAcc=cl; | |
1155 | maxchi2=chi2; | |
1156 | } else { | |
f059e2be | 1157 | return kFALSE; |
1d9af2d5 | 1158 | } |
1159 | } | |
1160 | } | |
1161 | ||
1162 | if (clAcc) { | |
1163 | if (!UpdateMI(track,clAcc,maxchi2,idx)){ | |
1164 | return kFALSE; | |
1165 | } | |
1166 | track->SetSampledEdx(clAcc->GetQ(),ilayer-2); | |
1167 | } | |
1168 | ||
1169 | ||
1170 | // Correct for material of the current layer | |
1171 | // cross material | |
1172 | // add time if going outward | |
1173 | if(!CorrectForLayerMaterial(track,ilayer,oldGlobXYZ,dir)){ | |
1174 | return kFALSE; | |
1175 | } | |
1176 | track->SetCheckInvariant(kFALSE); | |
1177 | } // end loop on layers | |
1178 | ||
1179 | if (!track->PropagateTo(xx,0.,0.)){ | |
1180 | return kFALSE; | |
8d499867 | 1181 | } |
556b741c | 1182 | |
1d9af2d5 | 1183 | return kTRUE; |
1184 | } | |
1185 | ||
1186 | //_____________________________________________________________________ | |
0ac80088 | 1187 | Int_t AliITStrackerUpgrade::UpdateMI(AliITStrackU* track, const AliITSRecPointU* cl,Double_t chi2,Int_t index) const |
1d9af2d5 | 1188 | { |
1189 | // | |
1190 | // Update ITS track | |
1191 | // | |
1192 | Int_t layer = (index & 0xf0000000) >> 28; | |
1193 | track->SetClIndex(layer, index); | |
1194 | if (TMath::Abs(cl->GetQ())<1.e-13) return 0; // ingore the "virtual" clusters | |
1195 | ||
1196 | ||
1197 | // Take into account the mis-alignment (bring track to cluster plane) | |
1198 | Double_t xTrOrig=track->GetX(); | |
1199 | Double_t trxyz[3]; track->GetXYZ(trxyz); | |
1200 | Float_t xclu1 = cl->GetX();//upgrade clusters tracking coordinate | |
1201 | //Float_t yclu1 = cl->GetY(); | |
1202 | //Float_t zclu1 = cl->GetZ(); | |
1203 | if (!track->Propagate(xTrOrig+xclu1)){ | |
1204 | return 0; | |
1205 | } | |
1206 | AliCluster c(*cl); | |
1207 | c.SetSigmaY2(track->GetSigmaY(layer)*track->GetSigmaY(layer)); | |
1208 | c.SetSigmaZ2(track->GetSigmaZ(layer)*track->GetSigmaZ(layer)); | |
1209 | c.SetSigmaYZ(track->GetSigmaYZ(layer)); | |
1210 | ||
1211 | // Bring the track back to detector plane in ideal geometry | |
1212 | Int_t updated = track->UpdateMI(&c,chi2,index); | |
1213 | if (!track->Propagate(xTrOrig)) { | |
1214 | return 0; | |
1215 | } | |
1216 | if(!updated){ | |
1217 | AliDebug(2,"update failed"); | |
1218 | } | |
1219 | return updated; | |
1220 | } | |
1221 | //____________________________________________________________________- | |
4211bbc5 | 1222 | Int_t AliITStrackerUpgrade::CorrectForLayerMaterial(AliITStrackU *t, |
1d9af2d5 | 1223 | Int_t layerindex, |
1224 | Double_t oldGlobXYZ[3], | |
1225 | TString direction) { | |
1226 | //------------------------------------------------------------------- | |
1227 | // Propagate beyond layer and correct for material | |
1228 | // (material budget in different ways according to fUseTGeo value) | |
1229 | // Add time if going outward (PropagateTo or PropagateToTGeo) | |
1230 | //------------------------------------------------------------------- | |
1231 | ||
1232 | // Define budget mode: | |
1233 | // 0: material from AliITSRecoParam (hard coded) | |
1234 | // 1: material from TGeo in stepsof X cm (on the fly) | |
1235 | // X = AliITSRecoParam::GetStepSizeTGeo() | |
1236 | // 2: material from lut | |
1237 | // 3: material from TGeo in one step (same for all hypotheses) | |
1238 | Int_t mode; | |
1239 | switch(fUseTGeo) { | |
1240 | case 0: | |
1241 | mode=0; | |
1242 | break; | |
1243 | case 1: | |
1244 | mode=1; | |
1245 | break; | |
1246 | case 2: | |
1247 | mode=2; | |
1248 | break; | |
1249 | case 3: | |
1250 | if(fTrackingPhase.Contains("Clusters2Tracks")) | |
1251 | { mode=3; } else { mode=1; } | |
1252 | break; | |
1253 | case 4: | |
1254 | if(fTrackingPhase.Contains("Clusters2Tracks")) | |
1255 | { mode=3; } else { mode=2; } | |
1256 | break; | |
1257 | default: | |
1258 | mode=0; | |
1259 | break; | |
1260 | } | |
1261 | if(fTrackingPhase.Contains("Default")) { | |
1262 | mode=0; | |
1263 | } | |
1264 | Float_t dir = (direction.Contains("inward") ? 1. : -1.); | |
317075a3 | 1265 | //Double_t r = fSegmentation->GetRadius(layerindex); |
1266 | //Double_t deltar=(layerindex<2 ? 0.10*r : 0.05*r); | |
1267 | Double_t deltar=0.05; | |
1d9af2d5 | 1268 | Double_t rToGo=TMath::Sqrt(t->GetX()*t->GetX()+t->GetY()*t->GetY())-deltar*dir; |
1269 | Double_t xToGo; | |
1270 | if (!t->GetLocalXat(rToGo,xToGo)) { | |
1271 | return 0; | |
1272 | } | |
665c0bc7 | 1273 | Int_t index=fNLayers*fCurrentEsdTrack+layerindex; |
1d9af2d5 | 1274 | |
1d9af2d5 | 1275 | Double_t xOverX0=0.0,x0=0.0,lengthTimesMeanDensity=0.0; |
1276 | Int_t nsteps=1; | |
1277 | // back before material (no correction) | |
1278 | Double_t rOld,xOld; | |
1279 | rOld=TMath::Sqrt(oldGlobXYZ[0]*oldGlobXYZ[0]+oldGlobXYZ[1]*oldGlobXYZ[1]); | |
1280 | if (!t->GetLocalXat(rOld,xOld)) return 0; | |
1281 | if (!t->Propagate(xOld)) return 0; | |
1282 | ||
1283 | switch(mode) { | |
1284 | case 1: | |
1285 | x0=21.82; | |
db688ae2 | 1286 | xOverX0 = fSegmentation->GetThickness(layerindex)/x0; |
1d9af2d5 | 1287 | |
1288 | lengthTimesMeanDensity = xOverX0*x0; | |
1289 | lengthTimesMeanDensity *= dir; | |
1290 | // Bring the track beyond the material | |
1291 | if (!t->PropagateTo(xToGo,xOverX0,lengthTimesMeanDensity/xOverX0)){ | |
1292 | return 0; | |
1293 | } | |
1294 | break; | |
1295 | case 0: | |
1296 | nsteps = (Int_t)(TMath::Abs(xOld-xToGo)/AliITSReconstructor::GetRecoParam()->GetStepSizeTGeo())+1; | |
1297 | if (!t->PropagateToTGeo(xToGo,nsteps)) return 0; // cross the material and apply correction | |
1298 | break; | |
1299 | case 2: | |
1300 | if(fxOverX0Layer[layerindex]<0) BuildMaterialLUT("Layers"); | |
1301 | xOverX0 = fxOverX0Layer[layerindex]; | |
1302 | lengthTimesMeanDensity = fxTimesRhoLayer[layerindex]; | |
1303 | lengthTimesMeanDensity *= dir; | |
1304 | // Bring the track beyond the material | |
1305 | if (!t->PropagateTo(xToGo,xOverX0,lengthTimesMeanDensity/xOverX0)) return 0; | |
1306 | break; | |
1307 | case 3: | |
665c0bc7 | 1308 | if(!fxOverX0LayerTrks || index<0 || index>=fNLayers*fNtracks) Error("CorrectForLayerMaterial","Incorrect usage of UseTGeo option!\n"); |
1d9af2d5 | 1309 | if(fxOverX0LayerTrks[index]<0) { |
1310 | nsteps = (Int_t)(TMath::Abs(xOld-xToGo)/AliITSReconstructor::GetRecoParam()->GetStepSizeTGeo())+1; | |
1311 | if (!t->PropagateToTGeo(xToGo,nsteps,xOverX0,lengthTimesMeanDensity)) return 0; | |
1312 | Double_t angle=TMath::Sqrt((1.+t->GetTgl()*t->GetTgl())/ | |
1313 | ((1.-t->GetSnp())*(1.+t->GetSnp()))); | |
1314 | fxOverX0LayerTrks[index] = TMath::Abs(xOverX0)/angle; | |
1315 | fxTimesRhoLayerTrks[index] = TMath::Abs(lengthTimesMeanDensity)/angle; | |
1316 | return 1; | |
1317 | } | |
1318 | xOverX0 = fxOverX0LayerTrks[index]; | |
1319 | lengthTimesMeanDensity = fxTimesRhoLayerTrks[index]; | |
1320 | lengthTimesMeanDensity *= dir; | |
1321 | // Bring the track beyond the material | |
1322 | if (!t->PropagateTo(xToGo,xOverX0,lengthTimesMeanDensity/xOverX0)){ | |
1323 | return 0; | |
1324 | } | |
1325 | break; | |
1326 | } | |
1327 | ||
1328 | ||
1329 | return 1; | |
1330 | } | |
1331 | ||
1332 | ||
1333 | //_____________________________________________________________________________ | |
0ac80088 | 1334 | Double_t AliITStrackerUpgrade::GetPredictedChi2MI(AliITStrackU* track, const AliITSRecPointU *cluster,Int_t layer) |
1d9af2d5 | 1335 | { |
1336 | // | |
1337 | // Compute predicted chi2 | |
1338 | // | |
1339 | Float_t erry,errz,covyz; | |
1340 | Float_t theta = track->GetTgl(); | |
1341 | Float_t phi = track->GetSnp(); | |
1342 | phi = TMath::Abs(phi)*TMath::Sqrt(1./((1.-phi)*(1.+phi))); | |
1343 | GetError(layer,cluster,theta,phi,track->GetExpQ(),erry,errz,covyz); | |
9b615954 | 1344 | AliDebug(3,Form(" chi2: tr-cl %f %f tr X %f cl X %f",track->GetY()-cluster->GetY(),track->GetZ()-cluster->GetZ(),track->GetX(),cluster->GetX())); |
1d9af2d5 | 1345 | // Take into account the mis-alignment (bring track to cluster plane) |
1346 | Double_t xTrOrig=track->GetX(); | |
1347 | if (!track->Propagate(xTrOrig+cluster->GetX())) return 1000.; | |
9b615954 | 1348 | AliDebug(3,Form(" chi2: tr-cl %f %f tr X %f cl X %f",track->GetY()-cluster->GetY(),track->GetZ()-cluster->GetZ(),track->GetX(),cluster->GetX())); |
1d9af2d5 | 1349 | Double_t chi2 = track->GetPredictedChi2MI(cluster->GetY(),cluster->GetZ(),erry,errz,covyz); |
1350 | // Bring the track back to detector plane in ideal geometry | |
1351 | // [mis-alignment will be accounted for in UpdateMI()] | |
1352 | if (!track->Propagate(xTrOrig)) return 1000.; | |
1353 | Float_t ny=0.,nz=0.; | |
1354 | //GetNTeor(layer,cluster,theta,phi,ny,nz); | |
1355 | Double_t delta = cluster->GetNy()+cluster->GetNz()-nz-ny; | |
1356 | if (delta>1){ | |
1357 | chi2+=0.5*TMath::Min(delta/2,2.); | |
1358 | chi2+=2.*cluster->GetDeltaProbability(); | |
1359 | } | |
1360 | // | |
1361 | track->SetNy(layer,ny); | |
1362 | track->SetNz(layer,nz); | |
1363 | track->SetSigmaY(layer,erry); | |
1364 | track->SetSigmaZ(layer, errz); | |
1365 | track->SetSigmaYZ(layer,covyz); | |
4211bbc5 | 1366 | |
1d9af2d5 | 1367 | track->SetNormQ(layer,cluster->GetQ()/TMath::Sqrt((1.+ track->GetTgl()*track->GetTgl())/((1.-track->GetSnp())*(1.+track->GetSnp())))); |
1368 | return chi2; | |
1369 | } | |
1370 | //________________________________________________________________ | |
1371 | Int_t AliITStrackerUpgrade::GetError(Int_t /*layer*/, | |
0ac80088 | 1372 | const AliITSRecPointU *cl, |
1d9af2d5 | 1373 | Float_t /*tgl*/,Float_t /*tgphitr*/,Float_t /*expQ*/, |
1374 | Float_t &erry,Float_t &errz,Float_t &covyz, | |
1375 | Bool_t /*addMisalErr*/) | |
1376 | { | |
1377 | // | |
1378 | // Calculate cluster position error for the upgrade | |
1379 | // | |
1380 | Int_t retval=0; | |
1381 | covyz=0.; | |
1382 | retval = GetErrorOrigRecPoint(cl,erry,errz,covyz); | |
1383 | ||
1384 | ||
1385 | ||
1386 | return retval; | |
1387 | ||
1388 | } | |
1389 | //____________________________________________________________________- | |
1390 | ||
0ac80088 | 1391 | Int_t AliITStrackerUpgrade::GetErrorOrigRecPoint(const AliITSRecPointU *cl, |
1d9af2d5 | 1392 | Float_t &erry,Float_t &errz,Float_t &covyz) |
1393 | { | |
1394 | // | |
1395 | // Calculate cluster position error (just take error from AliITSRecPoint) | |
1396 | // | |
1397 | erry = TMath::Sqrt(cl->GetSigmaY2()); | |
1398 | errz = TMath::Sqrt(cl->GetSigmaZ2()); | |
1399 | covyz = cl->GetSigmaYZ(); | |
1400 | return 1; | |
1401 | } | |
1402 | //__________________________ | |
9b615954 | 1403 | //void AliITStrackerUpgrade::GetNTeor(Int_t layer,const AliITSRecPointU* /*cl*/, |
1404 | /* Float_t tgl,Float_t tgphitr, | |
1d9af2d5 | 1405 | Float_t &ny,Float_t &nz) |
1406 | { | |
1407 | // | |
1408 | // Get "mean shape" (original parametrization from AliITStrackerMI) | |
1409 | // | |
1410 | tgl = TMath::Abs(tgl); | |
1411 | tgphitr = TMath::Abs(tgphitr); | |
1412 | ||
1413 | // SPD | |
1414 | if (layer==0) { | |
1415 | ny = 1.+tgphitr*3.2; | |
1416 | nz = 1.+tgl*0.34; | |
1417 | return; | |
1418 | } | |
1419 | if (layer==1) { | |
1420 | ny = 1.+tgphitr*3.2; | |
1421 | nz = 1.+tgl*0.28; | |
1422 | return; | |
1423 | } | |
1424 | // SSD | |
1425 | if (layer==4 || layer==5) { | |
1426 | ny = 2.02+tgphitr*1.95; | |
1427 | nz = 2.02+tgphitr*2.35; | |
1428 | return; | |
1429 | } | |
1430 | // SDD | |
1431 | ny = 6.6-2.7*tgphitr; | |
1432 | nz = 2.8-3.11*tgphitr+0.45*tgl; | |
1433 | return; | |
9b615954 | 1434 | }*/ |
1435 | ||
1d9af2d5 | 1436 | //_________________________________________________________________ |
1437 | Int_t AliITStrackerUpgrade::PropagateBack(AliESDEvent *event) { | |
1438 | //-------------------------------------------------------------------- | |
1439 | // This functions propagates reconstructed ITS tracks back | |
1440 | // The clusters must be loaded ! | |
1441 | //-------------------------------------------------------------------- | |
1442 | fTrackingPhase="PropagateBack"; | |
1443 | Int_t nentr=event->GetNumberOfTracks(); | |
1444 | Info("PropagateBack", "Number of ESD tracks: %d\n", nentr); | |
1445 | Int_t ntrk=0; | |
1446 | for (Int_t i=0; i<nentr; i++) { | |
1447 | AliESDtrack *esd=event->GetTrack(i); | |
1448 | ||
1449 | if ((esd->GetStatus()&AliESDtrack::kITSin)==0) continue; | |
1450 | if (esd->GetStatus()&AliESDtrack::kITSout) continue; | |
1451 | ||
f059e2be | 1452 | /* |
1453 | AliITStrackMI *t=0; | |
1454 | try { | |
1d9af2d5 | 1455 | t=new AliITStrackMI(*esd); |
f059e2be | 1456 | } catch (const Char_t *msg) { |
1d9af2d5 | 1457 | //Warning("PropagateBack",msg); |
1458 | delete t; | |
1459 | continue; | |
f059e2be | 1460 | } |
1461 | */ | |
4211bbc5 | 1462 | AliITStrackU *t = new AliITStrackU(*esd); |
1d9af2d5 | 1463 | t->SetExpQ(TMath::Max(0.8*t->GetESDtrack()->GetTPCsignal(),30.)); |
1464 | ||
1465 | ResetTrackToFollow(*t); | |
1466 | ||
1467 | /* | |
1468 | // propagate to vertex [SR, GSI 17.02.2003] | |
1469 | // Start Time measurement [SR, GSI 17.02.2003], corrected by I.Belikov | |
1470 | if (CorrectForPipeMaterial(&fTrackToFollow,"inward")) { | |
1471 | if (fTrackToFollow.PropagateToVertex(event->GetVertex())) | |
1472 | fTrackToFollow.StartTimeIntegral(); | |
1473 | // from vertex to outside pipe | |
1474 | CorrectForPipeMaterial(&fTrackToFollow,"outward"); | |
1475 | }*/ | |
1476 | // Start time integral and add distance from current position to vertex | |
1477 | Double_t xyzTrk[3],xyzVtx[3]={GetX(),GetY(),GetZ()}; | |
1478 | fTrackToFollow.GetXYZ(xyzTrk); | |
1479 | Double_t dst2 = 0.; | |
1480 | for (Int_t icoord=0; icoord<3; icoord++) { | |
1481 | Double_t di = xyzTrk[icoord] - xyzVtx[icoord]; | |
1482 | dst2 += di*di; | |
1483 | } | |
1484 | fTrackToFollow.StartTimeIntegral(); | |
1485 | fTrackToFollow.AddTimeStep(TMath::Sqrt(dst2)); | |
1486 | ||
1487 | fTrackToFollow.ResetCovariance(10.); | |
1488 | fTrackToFollow.ResetClusters(); | |
1489 | // | |
665c0bc7 | 1490 | Int_t inx[fNLayers]; |
1491 | for (Int_t k=0; k<fNLayers; k++) inx[k]=-1; | |
1d9af2d5 | 1492 | Int_t nclusters = t->GetNumberOfClusters(); |
1493 | for(Int_t ncl=0;ncl<nclusters;ncl++){ | |
1494 | Int_t index = t-> GetClIndex(ncl); | |
1495 | Int_t lay = (index & 0xf0000000) >> 28; | |
1496 | inx[lay]=index; | |
1497 | } | |
1498 | // | |
665c0bc7 | 1499 | if (RefitAtBase(fSegmentation->GetRadius(fNLayers-1),&fTrackToFollow,inx)) { |
1d9af2d5 | 1500 | //fTrackToFollow.SetLabel(t->GetLabel());// |
1501 | //fTrackToFollow.CookdEdx(); | |
1502 | //CookLabel(&fTrackToFollow,0.); //For comparison only | |
1503 | fTrackToFollow.UpdateESDtrack(AliESDtrack::kITSout); | |
db688ae2 | 1504 | //UseClusters(&fTrackToFollow); |
1d9af2d5 | 1505 | ntrk++; |
1506 | } | |
1507 | delete t; | |
1508 | } | |
1509 | ||
1d9af2d5 | 1510 | fTrackingPhase="Default"; |
1511 | ||
1512 | return 0; | |
1513 | } | |
1514 | //_________________________________________________________________________ | |
1515 | AliCluster *AliITStrackerUpgrade::GetCluster(Int_t index) const { | |
1516 | //-------------------------------------------------------------------- | |
1517 | // Return pointer to a given cluster | |
1518 | //-------------------------------------------------------------------- | |
1519 | Int_t l=(index & 0xf0000000) >> 28; | |
0a64515a | 1520 | Int_t c=(index & 0x0fffffff) >> 0; |
9b615954 | 1521 | |
1522 | AliCluster *cl = fLayers[l]->GetCluster(c); | |
1523 | ||
1524 | // AliDebug(2,Form("index %i; cluster index %i; layer %i; Pointer to cluster:%p", index,c,l,cl)); | |
1525 | ||
1526 | return cl; | |
1d9af2d5 | 1527 | } |
1528 | //______________________________________________________________________________ | |
4211bbc5 | 1529 | Int_t AliITStrackerUpgrade::CorrectForPipeMaterial(AliITStrackU *t, TString direction) { |
f059e2be | 1530 | //------------------------------------------------------------------- |
1531 | // Propagate beyond beam pipe and correct for material | |
1532 | // (material budget in different ways according to fUseTGeo value) | |
1533 | // Add time if going outward (PropagateTo or PropagateToTGeo) | |
1534 | //------------------------------------------------------------------- | |
1535 | ||
1536 | // Define budget mode: | |
1537 | // 0: material from AliITSRecoParam (hard coded) | |
1538 | // 1: material from TGeo in one step (on the fly) | |
1539 | // 2: material from lut | |
1540 | // 3: material from TGeo in one step (same for all hypotheses) | |
1541 | Int_t mode; | |
1542 | switch(fUseTGeo) { | |
1543 | case 0: | |
1544 | mode=0; | |
1545 | break; | |
1546 | case 1: | |
1547 | mode=1; | |
1548 | break; | |
1549 | case 2: | |
1550 | mode=2; | |
1551 | break; | |
1552 | case 3: | |
1553 | if(fTrackingPhase.Contains("Clusters2Tracks")) | |
1554 | { mode=3; } else { mode=1; } | |
1555 | break; | |
1556 | case 4: | |
1557 | if(fTrackingPhase.Contains("Clusters2Tracks")) | |
1558 | { mode=3; } else { mode=2; } | |
1559 | break; | |
1560 | default: | |
1561 | mode=0; | |
1562 | break; | |
1563 | } | |
1564 | if(fTrackingPhase.Contains("Default")) mode=0; | |
1565 | Int_t index=fCurrentEsdTrack; | |
1566 | ||
1567 | Float_t dir = (direction.Contains("inward") ? 1. : -1.); | |
1568 | Double_t rToGo=(dir>0 ? AliITSRecoParam::GetrInsidePipe() : AliITSRecoParam::GetrOutsidePipe()); | |
1569 | Double_t xToGo; | |
1570 | if (!t->GetLocalXat(rToGo,xToGo)) return 0; | |
1571 | ||
1572 | Double_t xOverX0,x0,lengthTimesMeanDensity; | |
1573 | ||
1574 | switch(mode) { | |
1575 | case 0: | |
1576 | xOverX0 = AliITSRecoParam::GetdPipe(); | |
1577 | x0 = AliITSRecoParam::GetX0Be(); | |
1578 | lengthTimesMeanDensity = xOverX0*x0; | |
1579 | lengthTimesMeanDensity *= dir; | |
1580 | if (!t->PropagateTo(xToGo,xOverX0,lengthTimesMeanDensity/xOverX0)) return 0; | |
1581 | break; | |
1582 | case 1: | |
1583 | if (!t->PropagateToTGeo(xToGo,1)) return 0; | |
1584 | break; | |
1585 | case 2: | |
1586 | if(fxOverX0Pipe<0) BuildMaterialLUT("Pipe"); | |
1587 | xOverX0 = fxOverX0Pipe; | |
1588 | lengthTimesMeanDensity = fxTimesRhoPipe; | |
1589 | lengthTimesMeanDensity *= dir; | |
1590 | if (!t->PropagateTo(xToGo,xOverX0,lengthTimesMeanDensity/xOverX0)) return 0; | |
1591 | break; | |
1592 | case 3: | |
1593 | if(!fxOverX0PipeTrks || index<0 || index>=fNtracks) Error("CorrectForPipeMaterial","Incorrect usage of UseTGeo option!\n"); | |
1594 | if(fxOverX0PipeTrks[index]<0) { | |
1595 | if (!t->PropagateToTGeo(xToGo,1,xOverX0,lengthTimesMeanDensity)) return 0; | |
1596 | Double_t angle=TMath::Sqrt((1.+t->GetTgl()*t->GetTgl())/ | |
1597 | ((1.-t->GetSnp())*(1.+t->GetSnp()))); | |
1598 | fxOverX0PipeTrks[index] = TMath::Abs(xOverX0)/angle; | |
1599 | fxTimesRhoPipeTrks[index] = TMath::Abs(lengthTimesMeanDensity)/angle; | |
1600 | return 1; | |
1601 | } | |
1602 | xOverX0 = fxOverX0PipeTrks[index]; | |
1603 | lengthTimesMeanDensity = fxTimesRhoPipeTrks[index]; | |
1604 | lengthTimesMeanDensity *= dir; | |
1605 | if (!t->PropagateTo(xToGo,xOverX0,lengthTimesMeanDensity/xOverX0)) return 0; | |
1606 | break; | |
1607 | } | |
1608 | ||
1609 | return 1; | |
1d9af2d5 | 1610 | } |
1611 | //__________________________________________________________________________ | |
1612 | Int_t AliITStrackerUpgrade::RefitInward(AliESDEvent *event) { | |
1613 | //-------------------------------------------------------------------- | |
1614 | // This functions refits ITS tracks using the | |
1615 | // "inward propagated" TPC tracks | |
1616 | // The clusters must be loaded ! | |
1617 | //-------------------------------------------------------------------- | |
1618 | fTrackingPhase="RefitInward"; | |
1619 | Int_t nentr=event->GetNumberOfTracks(); | |
1620 | for (Int_t i=0; i<nentr; i++) { | |
1621 | AliESDtrack *esd=event->GetTrack(i); | |
1622 | ||
1623 | // if ((esd->GetStatus()&AliESDtrack::kITSout) == 0) continue; | |
1624 | // if (esd->GetStatus()&AliESDtrack::kITSrefit) continue; | |
1625 | //if (esd->GetStatus()&AliESDtrack::kTPCout) | |
1626 | // if ((esd->GetStatus()&AliESDtrack::kTPCrefit)==0) continue; | |
4211bbc5 | 1627 | AliITStrackU *t=0; |
1d9af2d5 | 1628 | try { |
4211bbc5 | 1629 | t=new AliITStrackU(*esd); |
1d9af2d5 | 1630 | } catch (const Char_t *msg) { |
1631 | //Warning("RefitInward",msg); | |
1632 | delete t; | |
1633 | continue; | |
1634 | } | |
1635 | ||
1636 | ResetTrackToFollow(*t); | |
1637 | // fTrackToFollow.ResetClusters(); | |
1638 | // if ((esd->GetStatus()&AliESDtrack::kTPCin)==0) | |
1639 | // fTrackToFollow.ResetCovariance(10.); | |
1640 | //Refitting... | |
1641 | //The beam pipe | |
f059e2be | 1642 | if (CorrectForPipeMaterial(&fTrackToFollow,"inward")) { |
1643 | fTrackToFollow.UpdateESDtrack(AliESDtrack::kITSrefit); | |
1644 | AliESDtrack *esdTrack =fTrackToFollow.GetESDtrack(); | |
1645 | Double_t r[3]={0.,0.,0.}; | |
1646 | Double_t maxD=3.; | |
1647 | esdTrack->RelateToVertex(event->GetVertex(),GetBz(r),maxD); | |
1648 | } | |
1d9af2d5 | 1649 | delete t; |
1650 | } | |
1651 | ||
1652 | fTrackingPhase="Default"; | |
1653 | return 0; | |
1654 | } | |
1655 | ||
1656 | ||
1657 |