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