]>
Commit | Line | Data |
---|---|---|
e43c066c | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
bf6adc12 | 16 | /* $Id$ */ |
17 | ||
e43c066c | 18 | //------------------------------------------------------------------------- |
19 | // Implementation of the ITS tracker class | |
00a7cc50 | 20 | // It reads AliITSRecPoint clusters and creates AliITStrackMI tracks |
e43c066c | 21 | // and fills with them the ESD |
15dd636f | 22 | // Origin: Marian Ivanov, CERN, Marian.Ivanov@cern.ch |
e43c066c | 23 | // dEdx analysis by: Boris Batyunya, JINR, Boris.Batiounia@cern.ch |
f43e383b | 24 | // |
e43c066c | 25 | //------------------------------------------------------------------------- |
bf6adc12 | 26 | |
27 | #include <TMatrixD.h> | |
e43c066c | 28 | #include <TTree.h> |
bf6adc12 | 29 | #include <TTreeStream.h> |
30 | #include <TTree.h> | |
31 | ||
e43c066c | 32 | #include "AliESD.h" |
bf6adc12 | 33 | #include "AliESDV0MI.h" |
34 | #include "AliHelix.h" | |
00a7cc50 | 35 | #include "AliITSRecPoint.h" |
bf6adc12 | 36 | #include "AliITSgeom.h" |
e43c066c | 37 | #include "AliITStrackerMI.h" |
df29e9a4 | 38 | #include "AliTrackPointArray.h" |
39 | #include "AliAlignObj.h" | |
e43c066c | 40 | |
41 | ClassImp(AliITStrackerMI) | |
e43c066c | 42 | |
43 | ||
44 | ||
45 | AliITStrackerMI::AliITSlayer AliITStrackerMI::fgLayers[kMaxLayer]; // ITS layers | |
46 | ||
47 | AliITStrackerMI::AliITStrackerMI(const AliITSgeom *geom) : AliTracker() { | |
48 | //-------------------------------------------------------------------- | |
49 | //This is the AliITStrackerMI constructor | |
50 | //-------------------------------------------------------------------- | |
628e7bb0 | 51 | fCoeficients = 0; |
52 | fAfterV0 = kFALSE; | |
e43c066c | 53 | AliITSgeom *g=(AliITSgeom*)geom; |
e43c066c | 54 | Float_t x,y,z; |
55 | Int_t i; | |
56 | for (i=1; i<kMaxLayer+1; i++) { | |
57 | Int_t nlad=g->GetNladders(i); | |
58 | Int_t ndet=g->GetNdetectors(i); | |
59 | ||
60 | g->GetTrans(i,1,1,x,y,z); | |
61 | Double_t r=TMath::Sqrt(x*x + y*y); | |
62 | Double_t poff=TMath::ATan2(y,x); | |
63 | Double_t zoff=z; | |
64 | ||
65 | g->GetTrans(i,1,2,x,y,z); | |
66 | r += TMath::Sqrt(x*x + y*y); | |
67 | g->GetTrans(i,2,1,x,y,z); | |
68 | r += TMath::Sqrt(x*x + y*y); | |
69 | g->GetTrans(i,2,2,x,y,z); | |
70 | r += TMath::Sqrt(x*x + y*y); | |
71 | r*=0.25; | |
72 | ||
73 | new (fgLayers+i-1) AliITSlayer(r,poff,zoff,nlad,ndet); | |
74 | ||
75 | for (Int_t j=1; j<nlad+1; j++) { | |
76 | for (Int_t k=1; k<ndet+1; k++) { //Fill this layer with detectors | |
77 | Float_t x,y,zshift; g->GetTrans(i,j,k,x,y,zshift); | |
78 | Double_t rot[9]; g->GetRotMatrix(i,j,k,rot); | |
79 | ||
80 | Double_t phi=TMath::ATan2(rot[1],rot[0])+TMath::Pi(); | |
81 | phi+=TMath::Pi()/2; | |
82 | if (i==1) phi+=TMath::Pi(); | |
83 | Double_t cp=TMath::Cos(phi), sp=TMath::Sin(phi); | |
84 | Double_t r=x*cp+y*sp; | |
85 | ||
86 | AliITSdetector &det=fgLayers[i-1].GetDetector((j-1)*ndet + k-1); | |
87 | new(&det) AliITSdetector(r,phi); | |
88 | } | |
89 | } | |
90 | ||
91 | } | |
92 | ||
93 | fI=kMaxLayer; | |
94 | ||
95 | fPass=0; | |
96 | fConstraint[0]=1; fConstraint[1]=0; | |
97 | ||
98 | Double_t xyz[]={kXV,kYV,kZV}, ers[]={kSigmaXV,kSigmaYV,kSigmaZV}; | |
99 | SetVertex(xyz,ers); | |
100 | ||
101 | for (Int_t i=0; i<kMaxLayer; i++) fLayersNotToSkip[i]=kLayersNotToSkip[i]; | |
102 | fLastLayerToTrackTo=kLastLayerToTrackTo; | |
628e7bb0 | 103 | for (Int_t i=0;i<100000;i++){ |
104 | fBestTrackIndex[i]=0; | |
105 | } | |
81e97e0d | 106 | // |
107 | fDebugStreamer = new TTreeSRedirector("ITSdebug.root"); | |
108 | ||
628e7bb0 | 109 | } |
e43c066c | 110 | |
628e7bb0 | 111 | AliITStrackerMI::~AliITStrackerMI() |
112 | { | |
113 | // | |
114 | //destructor | |
115 | // | |
116 | if (fCoeficients) delete []fCoeficients; | |
81e97e0d | 117 | if (fDebugStreamer) { |
118 | //fDebugStreamer->Close(); | |
119 | delete fDebugStreamer; | |
120 | } | |
e43c066c | 121 | } |
122 | ||
123 | void AliITStrackerMI::SetLayersNotToSkip(Int_t *l) { | |
124 | //-------------------------------------------------------------------- | |
125 | //This function set masks of the layers which must be not skipped | |
126 | //-------------------------------------------------------------------- | |
127 | for (Int_t i=0; i<kMaxLayer; i++) fLayersNotToSkip[i]=l[i]; | |
128 | } | |
129 | ||
130 | Int_t AliITStrackerMI::LoadClusters(TTree *cTree) { | |
131 | //-------------------------------------------------------------------- | |
132 | //This function loads ITS clusters | |
133 | //-------------------------------------------------------------------- | |
00a7cc50 | 134 | TBranch *branch=cTree->GetBranch("ITSRecPoints"); |
e43c066c | 135 | if (!branch) { |
136 | Error("LoadClusters"," can't get the branch !\n"); | |
137 | return 1; | |
138 | } | |
139 | ||
00a7cc50 | 140 | TClonesArray dummy("AliITSRecPoint",10000), *clusters=&dummy; |
e43c066c | 141 | branch->SetAddress(&clusters); |
142 | ||
143 | Int_t j=0; | |
144 | Int_t detector=0; | |
145 | for (Int_t i=0; i<kMaxLayer; i++) { | |
146 | Int_t ndet=fgLayers[i].GetNdetectors(); | |
147 | Int_t jmax = j + fgLayers[i].GetNladders()*ndet; | |
148 | for (; j<jmax; j++) { | |
149 | if (!cTree->GetEvent(j)) continue; | |
150 | Int_t ncl=clusters->GetEntriesFast(); | |
151 | SignDeltas(clusters,GetZ()); | |
152 | while (ncl--) { | |
00a7cc50 | 153 | AliITSRecPoint *c=(AliITSRecPoint*)clusters->UncheckedAt(ncl); |
e43c066c | 154 | detector = c->GetDetectorIndex(); |
00a7cc50 | 155 | fgLayers[i].InsertCluster(new AliITSRecPoint(*c)); |
e43c066c | 156 | } |
157 | clusters->Delete(); | |
158 | //add dead zone virtual "cluster" | |
159 | if (i<2){ | |
160 | for (Float_t ydead = 0; ydead < 1.31 ; ydead+=(i+1.)*0.018){ | |
161 | Int_t lab[4] = {0,0,0,detector}; | |
162 | Int_t info[3] = {0,0,0}; | |
163 | Float_t hit[5]={0,0,0.004/12.,0.001/12.,0}; | |
164 | if (i==0) hit[0] =ydead-0.4; | |
165 | if (i==1) hit[0]=ydead-3.75; | |
166 | hit[1] =-0.04; | |
167 | if (TMath::Abs(fgLayers[i].GetDetector(detector).GetZmax()-hit[1])<2.) | |
00a7cc50 | 168 | fgLayers[i].InsertCluster(new AliITSRecPoint(lab, hit, info)); |
e43c066c | 169 | hit[1]=-7.05; |
170 | if (TMath::Abs(fgLayers[i].GetDetector(detector).GetZmax()-hit[1])<2.) | |
00a7cc50 | 171 | fgLayers[i].InsertCluster(new AliITSRecPoint(lab, hit, info)); |
e43c066c | 172 | hit[1]=-7.15; |
173 | if (TMath::Abs(fgLayers[i].GetDetector(detector).GetZmax()-hit[1])<2.) | |
00a7cc50 | 174 | fgLayers[i].InsertCluster(new AliITSRecPoint(lab, hit, info)); |
e43c066c | 175 | hit[1] =0.06; |
176 | if (TMath::Abs(fgLayers[i].GetDetector(detector).GetZmax()-hit[1])<2.) | |
00a7cc50 | 177 | fgLayers[i].InsertCluster(new AliITSRecPoint(lab, hit, info)); |
e43c066c | 178 | hit[1]=7.05; |
179 | if (TMath::Abs(fgLayers[i].GetDetector(detector).GetZmax()-hit[1])<2.) | |
00a7cc50 | 180 | fgLayers[i].InsertCluster(new AliITSRecPoint(lab, hit, info)); |
e43c066c | 181 | hit[1]=7.25; |
182 | if (TMath::Abs(fgLayers[i].GetDetector(detector).GetZmax()-hit[1])<2.) | |
00a7cc50 | 183 | fgLayers[i].InsertCluster(new AliITSRecPoint(lab, hit, info)); |
e43c066c | 184 | } |
185 | } | |
186 | ||
187 | } | |
188 | // | |
189 | fgLayers[i].ResetRoad(); //road defined by the cluster density | |
190 | fgLayers[i].SortClusters(); | |
191 | } | |
192 | ||
193 | return 0; | |
194 | } | |
195 | ||
196 | void AliITStrackerMI::UnloadClusters() { | |
197 | //-------------------------------------------------------------------- | |
198 | //This function unloads ITS clusters | |
199 | //-------------------------------------------------------------------- | |
200 | for (Int_t i=0; i<kMaxLayer; i++) fgLayers[i].ResetClusters(); | |
201 | } | |
202 | ||
15dd636f | 203 | static Int_t CorrectForDeadZoneMaterial(AliITStrackMI *t) { |
e43c066c | 204 | //-------------------------------------------------------------------- |
205 | // Correction for the material between the TPC and the ITS | |
206 | // (should it belong to the TPC code ?) | |
207 | //-------------------------------------------------------------------- | |
208 | Double_t riw=80., diw=0.0053, x0iw=30; // TPC inner wall ? | |
209 | Double_t rcd=61., dcd=0.0053, x0cd=30; // TPC "central drum" ? | |
210 | Double_t yr=12.8, dr=0.03; // rods ? | |
211 | Double_t zm=0.2, dm=0.40; // membrane | |
212 | //Double_t rr=52., dr=0.19, x0r=24., yyr=7.77; //rails | |
213 | Double_t rs=50., ds=0.001; // something belonging to the ITS (screen ?) | |
214 | ||
215 | if (t->GetX() > riw) { | |
216 | if (!t->PropagateTo(riw,diw,x0iw)) return 1; | |
217 | if (TMath::Abs(t->GetY())>yr) t->CorrectForMaterial(dr); | |
218 | if (TMath::Abs(t->GetZ())<zm) t->CorrectForMaterial(dm); | |
219 | if (!t->PropagateTo(rcd,dcd,x0cd)) return 1; | |
220 | //Double_t x,y,z; t->GetGlobalXYZat(rr,x,y,z); | |
221 | //if (TMath::Abs(y)<yyr) t->PropagateTo(rr,dr,x0r); | |
222 | if (!t->PropagateTo(rs,ds)) return 1; | |
223 | } else if (t->GetX() < rs) { | |
224 | if (!t->PropagateTo(rs,-ds)) return 1; | |
225 | //Double_t x,y,z; t->GetGlobalXYZat(rr,x,y,z); | |
226 | //if (TMath::Abs(y)<yyr) t->PropagateTo(rr,-dr,x0r); | |
227 | if (!t->PropagateTo(rcd,-dcd,x0cd)) return 1; | |
228 | if (!t->PropagateTo(riw+0.001,-diw,x0iw)) return 1; | |
229 | } else { | |
230 | ::Error("CorrectForDeadZoneMaterial","track is already in the dead zone !"); | |
231 | return 1; | |
232 | } | |
233 | ||
234 | return 0; | |
235 | } | |
236 | ||
237 | Int_t AliITStrackerMI::Clusters2Tracks(AliESD *event) { | |
238 | //-------------------------------------------------------------------- | |
239 | // This functions reconstructs ITS tracks | |
240 | // The clusters must be already loaded ! | |
241 | //-------------------------------------------------------------------- | |
242 | TObjArray itsTracks(15000); | |
628e7bb0 | 243 | fOriginal.Clear(); |
81e97e0d | 244 | fEsd = event; // store pointer to the esd |
e43c066c | 245 | {/* Read ESD tracks */ |
246 | Int_t nentr=event->GetNumberOfTracks(); | |
247 | Info("Clusters2Tracks", "Number of ESD tracks: %d\n", nentr); | |
248 | while (nentr--) { | |
249 | AliESDtrack *esd=event->GetTrack(nentr); | |
250 | ||
251 | if ((esd->GetStatus()&AliESDtrack::kTPCin)==0) continue; | |
252 | if (esd->GetStatus()&AliESDtrack::kTPCout) continue; | |
253 | if (esd->GetStatus()&AliESDtrack::kITSin) continue; | |
51ad6848 | 254 | if (esd->GetKinkIndex(0)>0) continue; //kink daughter |
15dd636f | 255 | AliITStrackMI *t=0; |
e43c066c | 256 | try { |
15dd636f | 257 | t=new AliITStrackMI(*esd); |
e43c066c | 258 | } catch (const Char_t *msg) { |
628e7bb0 | 259 | //Warning("Clusters2Tracks",msg); |
e43c066c | 260 | delete t; |
261 | continue; | |
262 | } | |
263 | t->fD[0] = t->GetD(GetX(),GetY()); | |
264 | t->fD[1] = t->GetZat(GetX())-GetZ(); | |
265 | Double_t vdist = TMath::Sqrt(t->fD[0]*t->fD[0]+t->fD[1]*t->fD[1]); | |
628e7bb0 | 266 | if (t->GetMass()<0.13) t->SetMass(0.13957); // MI look to the esd - mass hypothesys !!!!!!!!!!! |
e43c066c | 267 | // write expected q |
268 | t->fExpQ = TMath::Max(0.8*t->fESDtrack->GetTPCsignal(),30.); | |
269 | ||
81e97e0d | 270 | if (esd->GetV0Index(0)>0 && t->fD[0]<30){ |
271 | //track - can be V0 according to TPC | |
e43c066c | 272 | } |
81e97e0d | 273 | else{ |
274 | if (TMath::Abs(t->fD[0])>10) { | |
275 | delete t; | |
276 | continue; | |
277 | } | |
278 | ||
279 | if (TMath::Abs(vdist)>20) { | |
280 | delete t; | |
281 | continue; | |
282 | } | |
283 | if (TMath::Abs(1/t->Get1Pt())<0.120) { | |
284 | delete t; | |
285 | continue; | |
286 | } | |
287 | ||
288 | if (CorrectForDeadZoneMaterial(t)!=0) { | |
289 | //Warning("Clusters2Tracks", | |
290 | // "failed to correct for the material in the dead zone !\n"); | |
291 | delete t; | |
292 | continue; | |
293 | } | |
e43c066c | 294 | } |
295 | t->fReconstructed = kFALSE; | |
296 | itsTracks.AddLast(t); | |
628e7bb0 | 297 | fOriginal.AddLast(t); |
e43c066c | 298 | } |
299 | } /* End Read ESD tracks */ | |
300 | ||
301 | itsTracks.Sort(); | |
628e7bb0 | 302 | fOriginal.Sort(); |
e43c066c | 303 | Int_t nentr=itsTracks.GetEntriesFast(); |
304 | fTrackHypothesys.Expand(nentr); | |
81e97e0d | 305 | fBestHypothesys.Expand(nentr); |
e43c066c | 306 | MakeCoeficients(nentr); |
307 | Int_t ntrk=0; | |
308 | for (fPass=0; fPass<2; fPass++) { | |
309 | Int_t &constraint=fConstraint[fPass]; if (constraint<0) continue; | |
310 | for (Int_t i=0; i<nentr; i++) { | |
4c53440c | 311 | // cerr<<fPass<<" "<<i<<'\r'; |
e43c066c | 312 | fCurrentEsdTrack = i; |
15dd636f | 313 | AliITStrackMI *t=(AliITStrackMI*)itsTracks.UncheckedAt(i); |
e43c066c | 314 | if (t==0) continue; //this track has been already tracked |
315 | if (t->fReconstructed&&(t->fNUsed<1.5)) continue; //this track was already "succesfully" reconstructed | |
316 | if ( (TMath::Abs(t->GetD(GetX(),GetY())) >3.) && fConstraint[fPass]) continue; | |
317 | if ( (TMath::Abs(t->GetZat(GetX())-GetZ())>3.) && fConstraint[fPass]) continue; | |
318 | ||
319 | Int_t tpcLabel=t->GetLabel(); //save the TPC track label | |
320 | fI = 6; | |
321 | ResetTrackToFollow(*t); | |
322 | ResetBestTrack(); | |
81e97e0d | 323 | FollowProlongationTree(t,i,fConstraint[fPass]); |
e43c066c | 324 | |
325 | SortTrackHypothesys(fCurrentEsdTrack,20,0); //MI change | |
326 | // | |
15dd636f | 327 | AliITStrackMI * besttrack = GetBestHypothesys(fCurrentEsdTrack,t,15); |
e43c066c | 328 | if (!besttrack) continue; |
329 | besttrack->SetLabel(tpcLabel); | |
330 | // besttrack->CookdEdx(); | |
331 | CookdEdx(besttrack); | |
332 | besttrack->fFakeRatio=1.; | |
333 | CookLabel(besttrack,0.); //For comparison only | |
e43c066c | 334 | UpdateESDtrack(besttrack,AliESDtrack::kITSin); |
628e7bb0 | 335 | |
336 | /* | |
337 | if ( besttrack->GetNumberOfClusters()<6 && fConstraint[fPass]) { | |
e43c066c | 338 | continue; |
339 | } | |
340 | if (besttrack->fChi2MIP[0]+besttrack->fNUsed>3.5) continue; | |
341 | if ( (TMath::Abs(besttrack->fD[0]*besttrack->fD[0]+besttrack->fD[1]*besttrack->fD[1])>0.1) && fConstraint[fPass]) continue; | |
342 | //delete itsTracks.RemoveAt(i); | |
628e7bb0 | 343 | */ |
344 | if (fConstraint[fPass]&&(!besttrack->IsGoldPrimary())) continue; //to be tracked also without vertex constrain | |
345 | ||
346 | ||
e43c066c | 347 | t->fReconstructed = kTRUE; |
348 | ntrk++; | |
349 | } | |
350 | GetBestHypothesysMIP(itsTracks); | |
351 | } | |
352 | ||
353 | //GetBestHypothesysMIP(itsTracks); | |
81e97e0d | 354 | UpdateTPCV0(event); |
355 | FindV02(event); | |
628e7bb0 | 356 | fAfterV0 = kTRUE; |
357 | //GetBestHypothesysMIP(itsTracks); | |
358 | // | |
e43c066c | 359 | itsTracks.Delete(); |
360 | // | |
361 | Int_t entries = fTrackHypothesys.GetEntriesFast(); | |
362 | for (Int_t ientry=0;ientry<entries;ientry++){ | |
363 | TObjArray * array =(TObjArray*)fTrackHypothesys.UncheckedAt(ientry); | |
364 | if (array) array->Delete(); | |
365 | delete fTrackHypothesys.RemoveAt(ientry); | |
366 | } | |
367 | ||
368 | fTrackHypothesys.Delete(); | |
81e97e0d | 369 | fBestHypothesys.Delete(); |
628e7bb0 | 370 | fOriginal.Clear(); |
371 | delete []fCoeficients; | |
372 | fCoeficients=0; | |
e43c066c | 373 | Info("Clusters2Tracks","Number of prolonged tracks: %d\n",ntrk); |
628e7bb0 | 374 | |
e43c066c | 375 | return 0; |
376 | } | |
377 | ||
378 | ||
e43c066c | 379 | Int_t AliITStrackerMI::PropagateBack(AliESD *event) { |
380 | //-------------------------------------------------------------------- | |
381 | // This functions propagates reconstructed ITS tracks back | |
382 | // The clusters must be loaded ! | |
383 | //-------------------------------------------------------------------- | |
384 | Int_t nentr=event->GetNumberOfTracks(); | |
385 | Info("PropagateBack", "Number of ESD tracks: %d\n", nentr); | |
386 | ||
387 | Int_t ntrk=0; | |
388 | for (Int_t i=0; i<nentr; i++) { | |
389 | AliESDtrack *esd=event->GetTrack(i); | |
390 | ||
391 | if ((esd->GetStatus()&AliESDtrack::kITSin)==0) continue; | |
392 | if (esd->GetStatus()&AliESDtrack::kITSout) continue; | |
393 | ||
15dd636f | 394 | AliITStrackMI *t=0; |
e43c066c | 395 | try { |
15dd636f | 396 | t=new AliITStrackMI(*esd); |
e43c066c | 397 | } catch (const Char_t *msg) { |
628e7bb0 | 398 | //Warning("PropagateBack",msg); |
e43c066c | 399 | delete t; |
400 | continue; | |
401 | } | |
402 | t->fExpQ = TMath::Max(0.8*t->fESDtrack->GetTPCsignal(),30.); | |
403 | ||
404 | ResetTrackToFollow(*t); | |
405 | ||
406 | // propagete to vertex [SR, GSI 17.02.2003] | |
407 | // Start Time measurement [SR, GSI 17.02.2003], corrected by I.Belikov | |
408 | if (fTrackToFollow.PropagateTo(3.,0.0028,65.19)) { | |
409 | if (fTrackToFollow.PropagateToVertex()) { | |
410 | fTrackToFollow.StartTimeIntegral(); | |
411 | } | |
412 | fTrackToFollow.PropagateTo(3.,-0.0028,65.19); | |
413 | } | |
414 | ||
415 | fTrackToFollow.ResetCovariance(); fTrackToFollow.ResetClusters(); | |
416 | if (RefitAt(49.,&fTrackToFollow,t)) { | |
417 | if (CorrectForDeadZoneMaterial(&fTrackToFollow)!=0) { | |
628e7bb0 | 418 | //Warning("PropagateBack", |
419 | // "failed to correct for the material in the dead zone !\n"); | |
e43c066c | 420 | delete t; |
421 | continue; | |
422 | } | |
423 | fTrackToFollow.SetLabel(t->GetLabel()); | |
424 | //fTrackToFollow.CookdEdx(); | |
425 | CookLabel(&fTrackToFollow,0.); //For comparison only | |
426 | fTrackToFollow.UpdateESDtrack(AliESDtrack::kITSout); | |
427 | //UseClusters(&fTrackToFollow); | |
428 | ntrk++; | |
429 | } | |
430 | delete t; | |
431 | } | |
432 | ||
433 | Info("PropagateBack","Number of back propagated ITS tracks: %d\n",ntrk); | |
434 | ||
435 | return 0; | |
436 | } | |
437 | ||
438 | Int_t AliITStrackerMI::RefitInward(AliESD *event) { | |
439 | //-------------------------------------------------------------------- | |
440 | // This functions refits ITS tracks using the | |
441 | // "inward propagated" TPC tracks | |
442 | // The clusters must be loaded ! | |
443 | //-------------------------------------------------------------------- | |
67c1e979 | 444 | RefitV02(event); |
e43c066c | 445 | Int_t nentr=event->GetNumberOfTracks(); |
446 | Info("RefitInward", "Number of ESD tracks: %d\n", nentr); | |
447 | ||
448 | Int_t ntrk=0; | |
449 | for (Int_t i=0; i<nentr; i++) { | |
450 | AliESDtrack *esd=event->GetTrack(i); | |
451 | ||
452 | if ((esd->GetStatus()&AliESDtrack::kITSout) == 0) continue; | |
453 | if (esd->GetStatus()&AliESDtrack::kITSrefit) continue; | |
454 | if (esd->GetStatus()&AliESDtrack::kTPCout) | |
455 | if ((esd->GetStatus()&AliESDtrack::kTPCrefit)==0) continue; | |
456 | ||
15dd636f | 457 | AliITStrackMI *t=0; |
e43c066c | 458 | try { |
15dd636f | 459 | t=new AliITStrackMI(*esd); |
e43c066c | 460 | } catch (const Char_t *msg) { |
628e7bb0 | 461 | //Warning("RefitInward",msg); |
e43c066c | 462 | delete t; |
463 | continue; | |
464 | } | |
465 | t->fExpQ = TMath::Max(0.8*t->fESDtrack->GetTPCsignal(),30.); | |
466 | if (CorrectForDeadZoneMaterial(t)!=0) { | |
628e7bb0 | 467 | //Warning("RefitInward", |
468 | // "failed to correct for the material in the dead zone !\n"); | |
e43c066c | 469 | delete t; |
470 | continue; | |
471 | } | |
472 | ||
473 | ResetTrackToFollow(*t); | |
474 | fTrackToFollow.ResetClusters(); | |
475 | ||
476 | if ((esd->GetStatus()&AliESDtrack::kTPCin)==0) | |
477 | fTrackToFollow.ResetCovariance(); | |
478 | ||
479 | //Refitting... | |
ef7253ac | 480 | if (RefitAt(3.7, &fTrackToFollow, t,kTRUE)) { |
e43c066c | 481 | fTrackToFollow.SetLabel(t->GetLabel()); |
482 | // fTrackToFollow.CookdEdx(); | |
483 | CookdEdx(&fTrackToFollow); | |
484 | ||
485 | CookLabel(&fTrackToFollow,0.0); //For comparison only | |
486 | ||
487 | if (fTrackToFollow.PropagateTo(3.,0.0028,65.19)) {//The beam pipe | |
49d13e89 | 488 | AliESDtrack *esdTrack =fTrackToFollow.GetESDtrack(); |
489 | esdTrack->UpdateTrackParams(&fTrackToFollow,AliESDtrack::kITSrefit); | |
490 | Float_t r[3]={0.,0.,0.}; | |
491 | Double_t maxD=3.; | |
492 | esdTrack->RelateToVertex(event->GetVertex(),GetBz(r),maxD); | |
493 | ntrk++; | |
e43c066c | 494 | } |
495 | } | |
496 | delete t; | |
497 | } | |
498 | ||
499 | Info("RefitInward","Number of refitted tracks: %d\n",ntrk); | |
500 | ||
501 | return 0; | |
502 | } | |
503 | ||
504 | AliCluster *AliITStrackerMI::GetCluster(Int_t index) const { | |
505 | //-------------------------------------------------------------------- | |
506 | // Return pointer to a given cluster | |
507 | //-------------------------------------------------------------------- | |
508 | Int_t l=(index & 0xf0000000) >> 28; | |
509 | Int_t c=(index & 0x0fffffff) >> 00; | |
510 | return fgLayers[l].GetCluster(c); | |
511 | } | |
512 | ||
df29e9a4 | 513 | Bool_t AliITStrackerMI::GetTrackPoint(Int_t index, AliTrackPoint& p) const { |
514 | // | |
515 | // Get track space point with index i | |
516 | // | |
78b03929 | 517 | Int_t l=(index & 0xf0000000) >> 28; |
518 | Int_t c=(index & 0x0fffffff) >> 00; | |
00a7cc50 | 519 | AliITSRecPoint *cl = fgLayers[l].GetCluster(c); |
df29e9a4 | 520 | Int_t idet = cl->GetDetectorIndex(); |
521 | const AliITSdetector &det = fgLayers[l].GetDetector(idet); | |
522 | Float_t phi = det.GetPhi(); | |
523 | Float_t r = det.GetR(); | |
524 | Float_t cp=TMath::Cos(phi), sp=TMath::Sin(phi); | |
525 | Float_t xyz[3]; | |
526 | xyz[0] = r*cp - cl->GetY()*sp; | |
527 | xyz[1] = r*sp + cl->GetY()*cp; | |
528 | xyz[2] = cl->GetZ(); | |
28469fac | 529 | Float_t cov[6]; |
530 | cov[0] = sp*sp*cl->GetSigmaY2(); | |
531 | cov[1] = -sp*cp*cl->GetSigmaY2(); | |
532 | cov[2] = 0.; | |
533 | cov[3] = cp*cp*cl->GetSigmaY2(); | |
534 | cov[4] = 0.; | |
535 | cov[5] = cl->GetSigmaZ2(); | |
536 | p.SetXYZ(xyz[0],xyz[1],xyz[2],cov); | |
df29e9a4 | 537 | AliAlignObj::ELayerID iLayer = AliAlignObj::kInvalidLayer; |
538 | switch (l) { | |
539 | case 0: | |
540 | iLayer = AliAlignObj::kSPD1; | |
541 | break; | |
542 | case 1: | |
543 | iLayer = AliAlignObj::kSPD2; | |
544 | break; | |
545 | case 2: | |
546 | iLayer = AliAlignObj::kSDD1; | |
547 | break; | |
548 | case 3: | |
549 | iLayer = AliAlignObj::kSDD2; | |
550 | break; | |
551 | case 4: | |
552 | iLayer = AliAlignObj::kSSD1; | |
553 | break; | |
554 | case 5: | |
555 | iLayer = AliAlignObj::kSSD2; | |
556 | break; | |
557 | default: | |
558 | AliWarning(Form("Wrong layer index in ITS (%d) !",l)); | |
559 | break; | |
560 | }; | |
561 | UShort_t volid = AliAlignObj::LayerToVolUID(iLayer,idet); | |
562 | p.SetVolumeID((UShort_t)volid); | |
563 | return kTRUE; | |
564 | } | |
e43c066c | 565 | |
81e97e0d | 566 | void AliITStrackerMI::FollowProlongationTree(AliITStrackMI * otrack, Int_t esdindex, Bool_t constrain) |
e43c066c | 567 | { |
568 | //-------------------------------------------------------------------- | |
569 | // Follow prolongation tree | |
570 | //-------------------------------------------------------------------- | |
81e97e0d | 571 | // |
572 | AliESDtrack * esd = otrack->fESDtrack; | |
573 | if (esd->GetV0Index(0)>0){ | |
574 | // | |
575 | // TEMPORARY SOLLUTION: map V0 indexes to point to proper track | |
576 | // mapping of esd track is different as its track in Containers | |
577 | // Need something more stable | |
578 | // Indexes are set back againg to the ESD track indexes in UpdateTPCV0 | |
579 | for (Int_t i=0;i<3;i++){ | |
580 | Int_t index = esd->GetV0Index(i); | |
581 | if (index==0) break; | |
582 | AliESDV0MI * vertex = fEsd->GetV0MI(index); | |
583 | if (vertex->GetStatus()<0) continue; // rejected V0 | |
584 | // | |
585 | if (esd->GetSign()>0) { | |
586 | vertex->SetIndex(0,esdindex); | |
587 | } | |
588 | else{ | |
589 | vertex->SetIndex(1,esdindex); | |
590 | } | |
591 | } | |
592 | } | |
593 | TObjArray *bestarray = (TObjArray*)fBestHypothesys.At(esdindex); | |
594 | if (!bestarray){ | |
595 | bestarray = new TObjArray(5); | |
596 | fBestHypothesys.AddAt(bestarray,esdindex); | |
597 | } | |
e43c066c | 598 | |
81e97e0d | 599 | // |
e43c066c | 600 | //setup tree of the prolongations |
601 | // | |
15dd636f | 602 | static AliITStrackMI tracks[7][100]; |
603 | AliITStrackMI *currenttrack; | |
604 | static AliITStrackMI currenttrack1; | |
605 | static AliITStrackMI currenttrack2; | |
606 | static AliITStrackMI backuptrack; | |
e43c066c | 607 | Int_t ntracks[7]; |
608 | Int_t nindexes[7][100]; | |
609 | Float_t normalizedchi2[100]; | |
610 | for (Int_t ilayer=0;ilayer<6;ilayer++) ntracks[ilayer]=0; | |
611 | otrack->fNSkipped=0; | |
15dd636f | 612 | new (&(tracks[6][0])) AliITStrackMI(*otrack); |
e43c066c | 613 | ntracks[6]=1; |
81e97e0d | 614 | for (Int_t i=0;i<7;i++) nindexes[i][0]=0; |
e43c066c | 615 | // |
616 | // | |
617 | // follow prolongations | |
618 | for (Int_t ilayer=5;ilayer>=0;ilayer--){ | |
619 | // | |
620 | AliITSlayer &layer=fgLayers[ilayer]; | |
621 | Double_t r=layer.GetR(); | |
622 | ntracks[ilayer]=0; | |
623 | // | |
624 | // | |
625 | Int_t nskipped=0; | |
626 | Float_t nused =0; | |
627 | for (Int_t itrack =0;itrack<ntracks[ilayer+1];itrack++){ | |
628 | //set current track | |
629 | if (ntracks[ilayer]>=100) break; | |
630 | if (tracks[ilayer+1][nindexes[ilayer+1][itrack]].fNSkipped>0) nskipped++; | |
631 | if (tracks[ilayer+1][nindexes[ilayer+1][itrack]].fNUsed>2.) nused++; | |
632 | if (ntracks[ilayer]>15+ilayer){ | |
633 | if (itrack>1&&tracks[ilayer+1][nindexes[ilayer+1][itrack]].fNSkipped>0 && nskipped>4+ilayer) continue; | |
634 | if (itrack>1&&tracks[ilayer+1][nindexes[ilayer+1][itrack]].fNUsed>2. && nused>3) continue; | |
635 | } | |
636 | ||
15dd636f | 637 | new(¤ttrack1) AliITStrackMI(tracks[ilayer+1][nindexes[ilayer+1][itrack]]); |
e43c066c | 638 | if (ilayer==3 || ilayer==1) { |
639 | Double_t rs=0.5*(fgLayers[ilayer+1].GetR() + r); | |
640 | Double_t d=0.0034, x0=38.6; | |
641 | if (ilayer==1) {rs=9.; d=0.0097; x0=42;} | |
642 | if (!currenttrack1.PropagateTo(rs,d,x0)) { | |
643 | continue; | |
644 | } | |
645 | } | |
646 | // | |
647 | //find intersection with layer | |
648 | Double_t x,y,z; | |
649 | if (!currenttrack1.GetGlobalXYZat(r,x,y,z)) { | |
650 | continue; | |
651 | } | |
652 | Double_t phi=TMath::ATan2(y,x); | |
653 | Int_t idet=layer.FindDetectorIndex(phi,z); | |
654 | if (idet<0) { | |
655 | continue; | |
656 | } | |
657 | //propagate to the intersection | |
658 | const AliITSdetector &det=layer.GetDetector(idet); | |
659 | phi=det.GetPhi(); | |
15dd636f | 660 | new(¤ttrack2) AliITStrackMI(currenttrack1); |
e43c066c | 661 | if (!currenttrack1.Propagate(phi,det.GetR())) { |
662 | continue; | |
663 | } | |
664 | currenttrack2.Propagate(phi,det.GetR()); // | |
665 | currenttrack1.SetDetectorIndex(idet); | |
666 | currenttrack2.SetDetectorIndex(idet); | |
667 | ||
668 | // | |
669 | // | |
670 | Double_t dz=7.5*TMath::Sqrt(currenttrack1.GetSigmaZ2() + 16.*kSigmaZ2[ilayer]); | |
671 | Double_t dy=7.5*TMath::Sqrt(currenttrack1.GetSigmaY2() + 16.*kSigmaY2[ilayer]); | |
672 | // | |
673 | Bool_t isBoundary=kFALSE; | |
674 | if (currenttrack1.GetY()-dy< det.GetYmin()+0.2) isBoundary = kTRUE; | |
675 | if (currenttrack1.GetY()+dy> det.GetYmax()-0.2) isBoundary = kTRUE; | |
676 | if (currenttrack1.GetZ()-dz< det.GetZmin()+0.2) isBoundary = kTRUE; | |
677 | if (currenttrack1.GetZ()+dz> det.GetZmax()-0.2) isBoundary = kTRUE; | |
678 | ||
679 | if (isBoundary){ // track at boundary between detectors | |
680 | Float_t maxtgl = TMath::Abs(currenttrack1.GetTgl()); | |
681 | if (maxtgl>1) maxtgl=1; | |
682 | dz = TMath::Sqrt(dz*dz+0.25*maxtgl*maxtgl); | |
683 | // | |
684 | Float_t maxsnp = TMath::Abs(currenttrack1.GetSnp()); | |
685 | if (maxsnp>0.95) continue; | |
686 | //if (maxsnp>0.5) maxsnp=0.5; | |
687 | dy=TMath::Sqrt(dy*dy+0.25*maxsnp*maxsnp); | |
688 | } | |
689 | ||
690 | Double_t zmin=currenttrack1.GetZ() - dz; | |
691 | Double_t zmax=currenttrack1.GetZ() + dz; | |
692 | Double_t ymin=currenttrack1.GetY() + r*phi - dy; | |
693 | Double_t ymax=currenttrack1.GetY() + r*phi + dy; | |
694 | layer.SelectClusters(zmin,zmax,ymin,ymax); | |
695 | // | |
696 | // loop over all possible prolongations | |
697 | // | |
698 | Double_t msz=1./((currenttrack1.GetSigmaZ2() + 16.*kSigmaZ2[ilayer])); | |
699 | Double_t msy=1./((currenttrack1.GetSigmaY2() + 16.*kSigmaY2[ilayer])); | |
81e97e0d | 700 | if (constrain){ |
e43c066c | 701 | msy/=60; msz/=60.; |
702 | } | |
703 | else{ | |
704 | msy/=50; msz/=50.; | |
705 | } | |
706 | // | |
00a7cc50 | 707 | const AliITSRecPoint *c=0; Int_t ci=-1; |
e43c066c | 708 | Double_t chi2=12345.; |
709 | Int_t deadzone=0; | |
710 | currenttrack = ¤ttrack1; | |
711 | while ((c=layer.GetNextCluster(ci))!=0) { | |
712 | if (ntracks[ilayer]>95) break; //space for skipped clusters | |
713 | Bool_t change =kFALSE; | |
714 | if (c->GetQ()==0 && (deadzone==1)) continue; | |
715 | Int_t idet=c->GetDetectorIndex(); | |
716 | if (currenttrack->GetDetectorIndex()!=idet) { | |
717 | const AliITSdetector &det=layer.GetDetector(idet); | |
718 | Double_t y,z; | |
719 | if (!currenttrack2.GetProlongationFast(det.GetPhi(),det.GetR(),y,z)) continue; | |
720 | Float_t pz = (z - c->GetZ()) , py=(y - c->GetY()); | |
721 | if (pz*pz*msz+py*py*msy>1.) continue; | |
722 | // | |
15dd636f | 723 | new (&backuptrack) AliITStrackMI(currenttrack2); |
e43c066c | 724 | change = kTRUE; |
725 | currenttrack =¤ttrack2; | |
726 | if (!currenttrack->Propagate(det.GetPhi(),det.GetR())) { | |
15dd636f | 727 | new (currenttrack) AliITStrackMI(backuptrack); |
e43c066c | 728 | change = kFALSE; |
729 | continue; | |
730 | } | |
731 | currenttrack->SetDetectorIndex(idet); | |
732 | } | |
733 | else{ | |
734 | Float_t pz = (currenttrack->GetZ() - c->GetZ()) , py=(currenttrack->GetY() - c->GetY()); | |
735 | if (pz*pz*msz+py*py*msy>1.) continue; | |
736 | } | |
737 | ||
738 | chi2=GetPredictedChi2MI(currenttrack,c,ilayer); | |
739 | if (chi2<kMaxChi2s[ilayer]){ | |
740 | if (c->GetQ()==0) deadzone=1; // take dead zone only once | |
741 | if (ntracks[ilayer]>=100) continue; | |
15dd636f | 742 | AliITStrackMI * updatetrack = new (&tracks[ilayer][ntracks[ilayer]]) AliITStrackMI(*currenttrack); |
e43c066c | 743 | updatetrack->fClIndex[ilayer]=0; |
744 | if (change){ | |
15dd636f | 745 | new (¤ttrack2) AliITStrackMI(backuptrack); |
e43c066c | 746 | } |
747 | if (c->GetQ()!=0){ | |
748 | if (!UpdateMI(updatetrack,c,chi2,(ilayer<<28)+ci)) continue; | |
749 | updatetrack->SetSampledEdx(c->GetQ(),updatetrack->GetNumberOfClusters()-1); //b.b. | |
750 | } | |
751 | else { | |
752 | updatetrack->fNDeadZone++; | |
753 | updatetrack->fDeadZoneProbability=GetDeadZoneProbability(updatetrack->GetZ(),TMath::Sqrt(updatetrack->GetSigmaZ2())); | |
754 | } | |
755 | if (c->IsUsed()){ | |
756 | updatetrack->fNUsed++; | |
757 | } | |
758 | Double_t x0; | |
759 | Double_t d=layer.GetThickness(updatetrack->GetY(),updatetrack->GetZ(),x0); | |
760 | updatetrack->CorrectForMaterial(d,x0); | |
81e97e0d | 761 | if (constrain) { |
762 | updatetrack->fConstrain = constrain; | |
e43c066c | 763 | fI = ilayer; |
764 | Double_t d=GetEffectiveThickness(0,0); //Think of this !!!! | |
765 | Double_t xyz[]={GetX(),GetY(),GetZ()}; | |
766 | Double_t ptfactor = 1; | |
767 | Double_t ers[]={GetSigmaX()*ptfactor,GetSigmaY()*ptfactor,GetSigmaZ()}; | |
768 | Bool_t isPrim = kTRUE; | |
769 | if (ilayer<4){ | |
770 | updatetrack->fD[0] = updatetrack->GetD(GetX(),GetY()); | |
771 | updatetrack->fD[1] = updatetrack->GetZat(GetX())-GetZ(); | |
772 | if ( TMath::Abs(updatetrack->fD[0]/(1.+ilayer))>0.4 || TMath::Abs(updatetrack->fD[1]/(1.+ilayer))>0.4) isPrim=kFALSE; | |
773 | } | |
774 | if (isPrim) updatetrack->Improve(d,xyz,ers); | |
775 | } //apply vertex constrain | |
776 | ntracks[ilayer]++; | |
777 | } // create new hypothesy | |
778 | } // loop over possible cluster prolongation | |
81e97e0d | 779 | // if (constrain&&itrack<2&¤ttrack1.fNSkipped==0 && deadzone==0){ |
780 | if (constrain&&itrack<2&¤ttrack1.fNSkipped==0 && deadzone==0&&ntracks[ilayer]<100){ | |
15dd636f | 781 | AliITStrackMI* vtrack = new (&tracks[ilayer][ntracks[ilayer]]) AliITStrackMI(currenttrack1); |
e43c066c | 782 | vtrack->fClIndex[ilayer]=0; |
783 | fI = ilayer; | |
784 | Double_t d=GetEffectiveThickness(0,0); //Think of this !!!! | |
785 | Double_t xyz[]={GetX(),GetY(),GetZ()}; | |
786 | Double_t ers[]={GetSigmaX(),GetSigmaY(),GetSigmaZ()}; | |
787 | vtrack->Improve(d,xyz,ers); | |
788 | vtrack->fNSkipped++; | |
789 | ntracks[ilayer]++; | |
790 | } | |
628e7bb0 | 791 | |
81e97e0d | 792 | if (constrain&&itrack<1&&TMath::Abs(currenttrack1.fP3)>1.1){ //big theta -- for low mult. runs |
628e7bb0 | 793 | AliITStrackMI* vtrack = new (&tracks[ilayer][ntracks[ilayer]]) AliITStrackMI(currenttrack1); |
794 | vtrack->fClIndex[ilayer]=0; | |
795 | fI = ilayer; | |
796 | Double_t d=GetEffectiveThickness(0,0); //Think of this !!!! | |
797 | Double_t xyz[]={GetX(),GetY(),GetZ()}; | |
798 | Double_t ers[]={GetSigmaX(),GetSigmaY(),GetSigmaZ()}; | |
799 | vtrack->Improve(d,xyz,ers); | |
800 | vtrack->fNDeadZone++; | |
801 | ntracks[ilayer]++; | |
802 | } | |
803 | ||
e43c066c | 804 | |
805 | } //loop over track candidates | |
806 | // | |
807 | // | |
808 | Int_t accepted=0; | |
809 | ||
810 | Int_t golds=0; | |
811 | for (Int_t itrack=0;itrack<ntracks[ilayer];itrack++){ | |
812 | normalizedchi2[itrack] = NormalizedChi2(&tracks[ilayer][itrack],ilayer); | |
813 | if ( normalizedchi2[itrack]<3+0.5*ilayer) golds++; | |
814 | if (ilayer>4) accepted++; | |
815 | else{ | |
81e97e0d | 816 | if ( constrain && normalizedchi2[itrack]<kMaxNormChi2C[ilayer]+1) accepted++; |
817 | if (!constrain && normalizedchi2[itrack]<kMaxNormChi2NonC[ilayer]+1) accepted++; | |
e43c066c | 818 | } |
819 | } | |
820 | TMath::Sort(ntracks[ilayer],normalizedchi2,nindexes[ilayer],kFALSE); | |
821 | ntracks[ilayer] = TMath::Min(accepted,7+2*ilayer); | |
822 | if (ntracks[ilayer]<golds+2+ilayer) ntracks[ilayer]=TMath::Min(golds+2+ilayer,accepted); | |
823 | if (ntracks[ilayer]>90) ntracks[ilayer]=90; | |
824 | } //loop over layers | |
825 | //printf("%d\t%d\t%d\t%d\t%d\t%d\n",ntracks[0],ntracks[1],ntracks[2],ntracks[3],ntracks[4],ntracks[5]); | |
81e97e0d | 826 | Int_t max = constrain? 20: 5; |
e43c066c | 827 | |
628e7bb0 | 828 | for (Int_t i=0;i<TMath::Min(max,ntracks[0]);i++) { |
15dd636f | 829 | AliITStrackMI & track= tracks[0][nindexes[0][i]]; |
628e7bb0 | 830 | if (track.GetNumberOfClusters()<2) continue; |
81e97e0d | 831 | if (!constrain&&track.fNormChi2[0]>7.)continue; |
15dd636f | 832 | AddTrackHypothesys(new AliITStrackMI(track), esdindex); |
e43c066c | 833 | } |
628e7bb0 | 834 | for (Int_t i=0;i<TMath::Min(2,ntracks[1]);i++) { |
15dd636f | 835 | AliITStrackMI & track= tracks[1][nindexes[1][i]]; |
e43c066c | 836 | if (track.GetNumberOfClusters()<4) continue; |
81e97e0d | 837 | if (!constrain&&track.fNormChi2[1]>7.)continue; |
838 | if (constrain) track.fNSkipped+=1; | |
839 | if (!constrain) { | |
e43c066c | 840 | track.fD[0] = track.GetD(GetX(),GetY()); |
4c53440c | 841 | track.fNSkipped+=4./(4.+8.*TMath::Abs(track.fD[0])); |
e43c066c | 842 | if (track.fN+track.fNDeadZone+track.fNSkipped>6) { |
843 | track.fNSkipped = 6-track.fN+track.fNDeadZone; | |
844 | } | |
845 | } | |
15dd636f | 846 | AddTrackHypothesys(new AliITStrackMI(track), esdindex); |
e43c066c | 847 | } |
848 | //} | |
849 | ||
81e97e0d | 850 | if (!constrain){ |
628e7bb0 | 851 | for (Int_t i=0;i<TMath::Min(2,ntracks[2]);i++) { |
15dd636f | 852 | AliITStrackMI & track= tracks[2][nindexes[2][i]]; |
628e7bb0 | 853 | if (track.GetNumberOfClusters()<3) continue; |
81e97e0d | 854 | if (!constrain&&track.fNormChi2[2]>7.)continue; |
855 | if (constrain) track.fNSkipped+=2; | |
856 | if (!constrain){ | |
e43c066c | 857 | track.fD[0] = track.GetD(GetX(),GetY()); |
4c53440c | 858 | track.fNSkipped+= 7./(7.+8.*TMath::Abs(track.fD[0])); |
e43c066c | 859 | if (track.fN+track.fNDeadZone+track.fNSkipped>6) { |
860 | track.fNSkipped = 6-track.fN+track.fNDeadZone; | |
861 | } | |
862 | } | |
15dd636f | 863 | AddTrackHypothesys(new AliITStrackMI(track), esdindex); |
e43c066c | 864 | } |
865 | } | |
81e97e0d | 866 | |
867 | if (!constrain){ | |
868 | // | |
869 | // register best tracks - important for V0 finder | |
870 | // | |
871 | for (Int_t ilayer=0;ilayer<5;ilayer++){ | |
872 | if (ntracks[ilayer]==0) continue; | |
873 | AliITStrackMI & track= tracks[ilayer][nindexes[ilayer][0]]; | |
874 | if (track.GetNumberOfClusters()<1) continue; | |
875 | CookLabel(&track,0); | |
876 | bestarray->AddAt(new AliITStrackMI(track),ilayer); | |
877 | } | |
878 | } | |
879 | // | |
880 | // update TPC V0 information | |
881 | // | |
882 | if (otrack->fESDtrack->GetV0Index(0)>0){ | |
883 | Float_t fprimvertex[3]={GetX(),GetY(),GetZ()}; | |
884 | for (Int_t i=0;i<3;i++){ | |
885 | Int_t index = otrack->fESDtrack->GetV0Index(i); | |
886 | if (index==0) break; | |
887 | AliESDV0MI * vertex = fEsd->GetV0MI(index); | |
888 | if (vertex->GetStatus()<0) continue; // rejected V0 | |
889 | // | |
890 | if (otrack->fP4>0) { | |
891 | vertex->SetIndex(0,esdindex); | |
892 | } | |
893 | else{ | |
894 | vertex->SetIndex(1,esdindex); | |
895 | } | |
896 | //find nearest layer with track info | |
897 | Int_t nearestold = GetNearestLayer(vertex->GetXrp()); | |
898 | Int_t nearest = nearestold; | |
899 | for (Int_t ilayer =nearest;ilayer<8;ilayer++){ | |
900 | if (ntracks[nearest]==0){ | |
901 | nearest = ilayer; | |
902 | } | |
903 | } | |
904 | // | |
905 | AliITStrackMI & track= tracks[nearest][nindexes[nearest][0]]; | |
906 | if (nearestold<5&&nearest<5){ | |
907 | Bool_t accept = track.fNormChi2[nearest]<10; | |
908 | if (accept){ | |
909 | if (track.fP4>0) { | |
910 | vertex->SetP(track); | |
911 | vertex->Update(fprimvertex); | |
912 | // vertex->SetIndex(0,track.fESDtrack->GetID()); | |
913 | if (track.GetNumberOfClusters()>2) AddTrackHypothesys(new AliITStrackMI(track), esdindex); | |
914 | }else{ | |
915 | vertex->SetM(track); | |
916 | vertex->Update(fprimvertex); | |
917 | //vertex->SetIndex(1,track.fESDtrack->GetID()); | |
918 | if (track.GetNumberOfClusters()>2) AddTrackHypothesys(new AliITStrackMI(track), esdindex); | |
919 | } | |
920 | vertex->SetStatus(vertex->GetStatus()+1); | |
921 | }else{ | |
922 | // vertex->SetStatus(-2); // reject V0 - not enough clusters | |
923 | } | |
924 | } | |
925 | // if (nearestold>3){ | |
926 | // Int_t indexlayer = (ntracks[0]>0)? 0:1; | |
927 | // if (ntracks[indexlayer]>0){ | |
928 | // AliITStrackMI & track= tracks[indexlayer][nindexes[indexlayer][0]]; | |
929 | // if (track.GetNumberOfClusters()>4&&track.fNormChi2[indexlayer]<4){ | |
930 | // vertex->SetStatus(-1); // reject V0 - clusters before | |
931 | // } | |
932 | // } | |
933 | // } | |
934 | } | |
935 | } | |
e43c066c | 936 | } |
937 | ||
938 | ||
939 | AliITStrackerMI::AliITSlayer & AliITStrackerMI::GetLayer(Int_t layer) const | |
940 | { | |
941 | //-------------------------------------------------------------------- | |
942 | // | |
943 | // | |
944 | return fgLayers[layer]; | |
945 | } | |
946 | AliITStrackerMI::AliITSlayer::AliITSlayer() { | |
947 | //-------------------------------------------------------------------- | |
948 | //default AliITSlayer constructor | |
949 | //-------------------------------------------------------------------- | |
950 | fN=0; | |
951 | fDetectors=0; | |
952 | fSkip = 0; | |
953 | fCurrentSlice=-1; | |
954 | for (Int_t i=0; i<kMaxClusterPerLayer;i++) { | |
955 | fClusterWeight[i]=0; | |
956 | fClusterTracks[0][i]=-1; | |
957 | fClusterTracks[1][i]=-1; | |
958 | fClusterTracks[2][i]=-1; | |
959 | fClusterTracks[3][i]=-1; | |
960 | } | |
961 | } | |
962 | ||
963 | AliITStrackerMI::AliITSlayer:: | |
964 | AliITSlayer(Double_t r,Double_t p,Double_t z,Int_t nl,Int_t nd) { | |
965 | //-------------------------------------------------------------------- | |
966 | //main AliITSlayer constructor | |
967 | //-------------------------------------------------------------------- | |
968 | fR=r; fPhiOffset=p; fZOffset=z; | |
969 | fNladders=nl; fNdetectors=nd; | |
970 | fDetectors=new AliITSdetector[fNladders*fNdetectors]; | |
971 | ||
972 | fN=0; | |
973 | fI=0; | |
974 | fSkip = 0; | |
975 | fRoad=2*fR*TMath::Sqrt(3.14/1.);//assuming that there's only one cluster | |
976 | } | |
977 | ||
978 | AliITStrackerMI::AliITSlayer::~AliITSlayer() { | |
979 | //-------------------------------------------------------------------- | |
980 | // AliITSlayer destructor | |
981 | //-------------------------------------------------------------------- | |
982 | delete[] fDetectors; | |
983 | for (Int_t i=0; i<fN; i++) delete fClusters[i]; | |
984 | for (Int_t i=0; i<kMaxClusterPerLayer;i++) { | |
985 | fClusterWeight[i]=0; | |
986 | fClusterTracks[0][i]=-1; | |
987 | fClusterTracks[1][i]=-1; | |
988 | fClusterTracks[2][i]=-1; | |
989 | fClusterTracks[3][i]=-1; | |
990 | } | |
991 | } | |
992 | ||
993 | void AliITStrackerMI::AliITSlayer::ResetClusters() { | |
994 | //-------------------------------------------------------------------- | |
995 | // This function removes loaded clusters | |
996 | //-------------------------------------------------------------------- | |
997 | for (Int_t i=0; i<fN; i++) delete fClusters[i]; | |
998 | for (Int_t i=0; i<kMaxClusterPerLayer;i++){ | |
999 | fClusterWeight[i]=0; | |
1000 | fClusterTracks[0][i]=-1; | |
1001 | fClusterTracks[1][i]=-1; | |
1002 | fClusterTracks[2][i]=-1; | |
1003 | fClusterTracks[3][i]=-1; | |
1004 | } | |
1005 | ||
1006 | fN=0; | |
1007 | fI=0; | |
1008 | } | |
1009 | ||
1010 | void AliITStrackerMI::AliITSlayer::ResetWeights() { | |
1011 | //-------------------------------------------------------------------- | |
1012 | // This function reset weights of the clusters | |
1013 | //-------------------------------------------------------------------- | |
1014 | for (Int_t i=0; i<kMaxClusterPerLayer;i++) { | |
1015 | fClusterWeight[i]=0; | |
1016 | fClusterTracks[0][i]=-1; | |
1017 | fClusterTracks[1][i]=-1; | |
1018 | fClusterTracks[2][i]=-1; | |
1019 | fClusterTracks[3][i]=-1; | |
1020 | } | |
1021 | for (Int_t i=0; i<fN;i++) { | |
00a7cc50 | 1022 | AliITSRecPoint * cl = (AliITSRecPoint*)GetCluster(i); |
e43c066c | 1023 | if (cl&&cl->IsUsed()) cl->Use(); |
1024 | } | |
1025 | ||
1026 | } | |
1027 | ||
1028 | void AliITStrackerMI::AliITSlayer::ResetRoad() { | |
1029 | //-------------------------------------------------------------------- | |
1030 | // This function calculates the road defined by the cluster density | |
1031 | //-------------------------------------------------------------------- | |
1032 | Int_t n=0; | |
1033 | for (Int_t i=0; i<fN; i++) { | |
1034 | if (TMath::Abs(fClusters[i]->GetZ())<fR) n++; | |
1035 | } | |
1036 | //if (n>1) fRoad=2*fR*TMath::Sqrt(3.14/n); | |
1037 | if (n>1) fRoad=2*fR*TMath::Sqrt(3.14/n); | |
1038 | } | |
1039 | ||
628e7bb0 | 1040 | |
00a7cc50 | 1041 | Int_t AliITStrackerMI::AliITSlayer::InsertCluster(AliITSRecPoint *c) { |
e43c066c | 1042 | //-------------------------------------------------------------------- |
1043 | //This function adds a cluster to this layer | |
1044 | //-------------------------------------------------------------------- | |
1045 | if (fN==kMaxClusterPerLayer) { | |
1046 | ::Error("InsertCluster","Too many clusters !\n"); | |
1047 | return 1; | |
1048 | } | |
1049 | fCurrentSlice=-1; | |
1d4090b7 | 1050 | fClusters[fN]=c; |
1051 | fN++; | |
e43c066c | 1052 | AliITSdetector &det=GetDetector(c->GetDetectorIndex()); |
e43c066c | 1053 | if (c->GetY()<det.GetYmin()) det.SetYmin(c->GetY()); |
1054 | if (c->GetY()>det.GetYmax()) det.SetYmax(c->GetY()); | |
1055 | if (c->GetZ()<det.GetZmin()) det.SetZmin(c->GetZ()); | |
1056 | if (c->GetZ()>det.GetZmax()) det.SetZmax(c->GetZ()); | |
1057 | ||
1058 | return 0; | |
1059 | } | |
1060 | ||
1061 | void AliITStrackerMI::AliITSlayer::SortClusters() | |
1062 | { | |
1063 | // | |
1064 | //sort clusters | |
1065 | // | |
00a7cc50 | 1066 | AliITSRecPoint **clusters = new AliITSRecPoint*[fN]; |
1d4090b7 | 1067 | Float_t *z = new Float_t[fN]; |
1068 | Int_t * index = new Int_t[fN]; | |
1069 | // | |
1070 | for (Int_t i=0;i<fN;i++){ | |
1071 | z[i] = fClusters[i]->GetZ(); | |
1072 | } | |
1073 | TMath::Sort(fN,z,index,kFALSE); | |
1074 | for (Int_t i=0;i<fN;i++){ | |
1075 | clusters[i] = fClusters[index[i]]; | |
1076 | } | |
1077 | // | |
1078 | for (Int_t i=0;i<fN;i++){ | |
1079 | fClusters[i] = clusters[i]; | |
1080 | fZ[i] = fClusters[i]->GetZ(); | |
1081 | AliITSdetector &det=GetDetector(fClusters[i]->GetDetectorIndex()); | |
1082 | Double_t y=fR*det.GetPhi() + fClusters[i]->GetY(); | |
1083 | if (y>2.*fR*TMath::Pi()) y -= 2.*fR*TMath::Pi(); | |
1084 | fY[i] = y; | |
1085 | } | |
1086 | delete[] index; | |
1087 | delete[] z; | |
1088 | delete[] clusters; | |
1089 | // | |
1090 | ||
e43c066c | 1091 | fYB[0]=10000000; |
1092 | fYB[1]=-10000000; | |
1093 | for (Int_t i=0;i<fN;i++){ | |
1094 | if (fY[i]<fYB[0]) fYB[0]=fY[i]; | |
1095 | if (fY[i]>fYB[1]) fYB[1]=fY[i]; | |
1096 | fClusterIndex[i] = i; | |
1097 | } | |
1098 | // | |
1099 | // fill slices | |
1100 | fDy5 = (fYB[1]-fYB[0])/5.; | |
1101 | fDy10 = (fYB[1]-fYB[0])/10.; | |
1102 | fDy20 = (fYB[1]-fYB[0])/20.; | |
1103 | for (Int_t i=0;i<6;i++) fN5[i] =0; | |
1104 | for (Int_t i=0;i<11;i++) fN10[i]=0; | |
1105 | for (Int_t i=0;i<21;i++) fN20[i]=0; | |
1106 | // | |
1107 | for (Int_t i=0;i<6;i++) {fBy5[i][0] = fYB[0]+(i-0.75)*fDy5; fBy5[i][1] = fYB[0]+(i+0.75)*fDy5;} | |
1108 | for (Int_t i=0;i<11;i++) {fBy10[i][0] = fYB[0]+(i-0.75)*fDy10; fBy10[i][1] = fYB[0]+(i+0.75)*fDy10;} | |
1109 | for (Int_t i=0;i<21;i++) {fBy20[i][0] = fYB[0]+(i-0.75)*fDy20; fBy20[i][1] = fYB[0]+(i+0.75)*fDy20;} | |
1110 | // | |
1111 | // | |
1d4090b7 | 1112 | for (Int_t i=0;i<fN;i++) |
1113 | for (Int_t irot=-1;irot<=1;irot++){ | |
1114 | Float_t curY = fY[i]+irot*TMath::TwoPi()*fR; | |
1115 | // slice 5 | |
1116 | for (Int_t slice=0; slice<6;slice++){ | |
1117 | if (fBy5[slice][0]<curY && curY<fBy5[slice][1]&&fN5[slice]<kMaxClusterPerLayer5){ | |
1118 | fClusters5[slice][fN5[slice]] = fClusters[i]; | |
1119 | fY5[slice][fN5[slice]] = curY; | |
1120 | fZ5[slice][fN5[slice]] = fZ[i]; | |
1121 | fClusterIndex5[slice][fN5[slice]]=i; | |
1122 | fN5[slice]++; | |
1123 | } | |
e43c066c | 1124 | } |
1d4090b7 | 1125 | // slice 10 |
1126 | for (Int_t slice=0; slice<11;slice++){ | |
1127 | if (fBy10[slice][0]<curY && curY<fBy10[slice][1]&&fN10[slice]<kMaxClusterPerLayer10){ | |
1128 | fClusters10[slice][fN10[slice]] = fClusters[i]; | |
1129 | fY10[slice][fN10[slice]] = curY; | |
1130 | fZ10[slice][fN10[slice]] = fZ[i]; | |
1131 | fClusterIndex10[slice][fN10[slice]]=i; | |
1132 | fN10[slice]++; | |
1133 | } | |
e43c066c | 1134 | } |
1d4090b7 | 1135 | // slice 20 |
1136 | for (Int_t slice=0; slice<21;slice++){ | |
1137 | if (fBy20[slice][0]<curY && curY<fBy20[slice][1]&&fN20[slice]<kMaxClusterPerLayer20){ | |
1138 | fClusters20[slice][fN20[slice]] = fClusters[i]; | |
1139 | fY20[slice][fN20[slice]] = curY; | |
1140 | fZ20[slice][fN20[slice]] = fZ[i]; | |
1141 | fClusterIndex20[slice][fN20[slice]]=i; | |
1142 | fN20[slice]++; | |
1143 | } | |
1144 | } | |
e43c066c | 1145 | } |
1d4090b7 | 1146 | |
1147 | // | |
1148 | // consistency check | |
1149 | // | |
1150 | for (Int_t i=0;i<fN-1;i++){ | |
1151 | if (fZ[i]>fZ[i+1]){ | |
1152 | printf("Bugg\n"); | |
e43c066c | 1153 | } |
1154 | } | |
1d4090b7 | 1155 | // |
1156 | for (Int_t slice=0;slice<21;slice++) | |
1157 | for (Int_t i=0;i<fN20[slice]-1;i++){ | |
1158 | if (fZ20[slice][i]>fZ20[slice][i+1]){ | |
1159 | printf("Bugg\n"); | |
1160 | } | |
1161 | } | |
1162 | ||
1163 | ||
e43c066c | 1164 | } |
1165 | ||
1166 | ||
e43c066c | 1167 | Int_t AliITStrackerMI::AliITSlayer::FindClusterIndex(Float_t z) const { |
1168 | //-------------------------------------------------------------------- | |
1169 | // This function returns the index of the nearest cluster | |
1170 | //-------------------------------------------------------------------- | |
1171 | Int_t ncl=0; | |
1172 | const Float_t *zcl; | |
1173 | if (fCurrentSlice<0) { | |
1174 | ncl = fN; | |
1175 | zcl = fZ; | |
1176 | } | |
1177 | else{ | |
1178 | ncl = fNcs; | |
1179 | zcl = fZcs;; | |
1180 | } | |
1181 | ||
1182 | if (ncl==0) return 0; | |
1183 | Int_t b=0, e=ncl-1, m=(b+e)/2; | |
1184 | for (; b<e; m=(b+e)/2) { | |
1185 | // if (z > fClusters[m]->GetZ()) b=m+1; | |
1186 | if (z > zcl[m]) b=m+1; | |
1187 | else e=m; | |
1188 | } | |
1189 | return m; | |
1190 | } | |
e43c066c | 1191 | |
1192 | ||
1193 | void AliITStrackerMI::AliITSlayer:: | |
1194 | SelectClusters(Double_t zmin,Double_t zmax,Double_t ymin, Double_t ymax) { | |
1195 | //-------------------------------------------------------------------- | |
1196 | // This function sets the "window" | |
1197 | //-------------------------------------------------------------------- | |
1198 | ||
628e7bb0 | 1199 | Double_t circle=2*TMath::Pi()*fR; |
e43c066c | 1200 | fYmin = ymin; fYmax =ymax; |
1201 | Float_t ymiddle = (fYmin+fYmax)*0.5; | |
1202 | if (ymiddle<fYB[0]) {fYmin+=circle; fYmax+=circle;ymiddle+=circle;} | |
1203 | else{ | |
1204 | if (ymiddle>fYB[1]) {fYmin-=circle; fYmax-=circle;ymiddle-=circle;} | |
1205 | } | |
1206 | // | |
1207 | fCurrentSlice =-1; | |
1208 | // defualt take all | |
1209 | fClustersCs = fClusters; | |
1210 | fClusterIndexCs = fClusterIndex; | |
1211 | fYcs = fY; | |
1212 | fZcs = fZ; | |
1213 | fNcs = fN; | |
628e7bb0 | 1214 | // |
e43c066c | 1215 | //is in 20 slice? |
1216 | if (fCurrentSlice<0&&TMath::Abs(fYmax-fYmin)<1.49*fDy20){ | |
1217 | Int_t slice = int(0.5+(ymiddle-fYB[0])/fDy20); | |
1218 | if (slice<0) slice=0; | |
1219 | if (slice>20) slice=20; | |
1220 | Bool_t isOK = (fYmin>fBy20[slice][0]&&fYmax<fBy20[slice][1]); | |
1221 | if (isOK) { | |
1222 | fCurrentSlice=slice; | |
1223 | fClustersCs = fClusters20[fCurrentSlice]; | |
1224 | fClusterIndexCs = fClusterIndex20[fCurrentSlice]; | |
1225 | fYcs = fY20[fCurrentSlice]; | |
1226 | fZcs = fZ20[fCurrentSlice]; | |
1227 | fNcs = fN20[fCurrentSlice]; | |
1228 | } | |
1229 | } | |
1230 | // | |
1231 | //is in 10 slice? | |
1232 | if (fCurrentSlice<0&&TMath::Abs(fYmax-fYmin)<1.49*fDy10){ | |
1233 | Int_t slice = int(0.5+(ymiddle-fYB[0])/fDy10); | |
1234 | if (slice<0) slice=0; | |
1235 | if (slice>10) slice=10; | |
1236 | Bool_t isOK = (fYmin>fBy10[slice][0]&&fYmax<fBy10[slice][1]); | |
1237 | if (isOK) { | |
1238 | fCurrentSlice=slice; | |
1239 | fClustersCs = fClusters10[fCurrentSlice]; | |
1240 | fClusterIndexCs = fClusterIndex10[fCurrentSlice]; | |
1241 | fYcs = fY10[fCurrentSlice]; | |
1242 | fZcs = fZ10[fCurrentSlice]; | |
1243 | fNcs = fN10[fCurrentSlice]; | |
1244 | } | |
1245 | } | |
1246 | // | |
1247 | //is in 5 slice? | |
1248 | if (fCurrentSlice<0&&TMath::Abs(fYmax-fYmin)<1.49*fDy5){ | |
1249 | Int_t slice = int(0.5+(ymiddle-fYB[0])/fDy5); | |
1250 | if (slice<0) slice=0; | |
1251 | if (slice>5) slice=5; | |
1252 | Bool_t isOK = (fYmin>fBy5[slice][0]&&fYmax<fBy5[slice][1]); | |
1253 | if ( isOK){ | |
1254 | fCurrentSlice=slice; | |
1255 | fClustersCs = fClusters5[fCurrentSlice]; | |
1256 | fClusterIndexCs = fClusterIndex5[fCurrentSlice]; | |
1257 | fYcs = fY5[fCurrentSlice]; | |
1258 | fZcs = fZ5[fCurrentSlice]; | |
1259 | fNcs = fN5[fCurrentSlice]; | |
1260 | } | |
1261 | } | |
628e7bb0 | 1262 | // |
e43c066c | 1263 | fI=FindClusterIndex(zmin); fZmax=zmax; |
1264 | fImax = TMath::Min(FindClusterIndex(zmax)+1,fNcs); | |
1265 | fSkip = 0; | |
1266 | fAccepted =0; | |
1267 | } | |
1268 | ||
e43c066c | 1269 | |
628e7bb0 | 1270 | |
1271 | ||
1272 | Int_t AliITStrackerMI::AliITSlayer:: | |
1273 | FindDetectorIndex(Double_t phi, Double_t z) const { | |
1274 | //-------------------------------------------------------------------- | |
1275 | //This function finds the detector crossed by the track | |
1276 | //-------------------------------------------------------------------- | |
1277 | Double_t dphi=-(phi-fPhiOffset); | |
1278 | if (dphi < 0) dphi += 2*TMath::Pi(); | |
1279 | else if (dphi >= 2*TMath::Pi()) dphi -= 2*TMath::Pi(); | |
1280 | Int_t np=Int_t(dphi*fNladders*0.5/TMath::Pi()+0.5); | |
1281 | if (np>=fNladders) np-=fNladders; | |
1282 | if (np<0) np+=fNladders; | |
1283 | ||
1284 | Double_t dz=fZOffset-z; | |
1285 | Int_t nz=Int_t(dz*(fNdetectors-1)*0.5/fZOffset+0.5); | |
1286 | if (nz>=fNdetectors) return -1; | |
1287 | if (nz<0) return -1; | |
1288 | ||
1289 | return np*fNdetectors + nz; | |
1290 | } | |
1291 | ||
1292 | ||
00a7cc50 | 1293 | const AliITSRecPoint *AliITStrackerMI::AliITSlayer::GetNextCluster(Int_t &ci){ |
e43c066c | 1294 | //-------------------------------------------------------------------- |
1295 | // This function returns clusters within the "window" | |
1296 | //-------------------------------------------------------------------- | |
1297 | ||
1298 | if (fCurrentSlice<0){ | |
1299 | Double_t rpi2 = 2.*fR*TMath::Pi(); | |
1300 | for (Int_t i=fI; i<fImax; i++) { | |
1301 | Double_t y = fY[i]; | |
1302 | if (fYmax<y) y -= rpi2; | |
1d4090b7 | 1303 | if (fYmin>y) y += rpi2; |
e43c066c | 1304 | if (y<fYmin) continue; |
1305 | if (y>fYmax) continue; | |
1306 | if (fClusters[i]->GetQ()==0&&fSkip==2) continue; | |
1307 | ci=i; | |
1308 | fI=i+1; | |
1309 | return fClusters[i]; | |
1310 | } | |
1311 | } | |
1312 | else{ | |
1313 | for (Int_t i=fI; i<fImax; i++) { | |
1314 | if (fYcs[i]<fYmin) continue; | |
1315 | if (fYcs[i]>fYmax) continue; | |
1316 | if (fClustersCs[i]->GetQ()==0&&fSkip==2) continue; | |
1317 | ci=fClusterIndexCs[i]; | |
1318 | fI=i+1; | |
1319 | return fClustersCs[i]; | |
1320 | } | |
1321 | } | |
1322 | return 0; | |
1323 | } | |
1324 | ||
1325 | ||
1326 | ||
e43c066c | 1327 | Double_t AliITStrackerMI::AliITSlayer::GetThickness(Double_t y,Double_t z,Double_t &x0) |
1328 | const { | |
1329 | //-------------------------------------------------------------------- | |
1330 | //This function returns the layer thickness at this point (units X0) | |
1331 | //-------------------------------------------------------------------- | |
1332 | Double_t d=0.0085; | |
1333 | x0=21.82; | |
1334 | if (43<fR&&fR<45) { //SSD2 | |
1335 | Double_t dd=0.0034; | |
1336 | d=dd; | |
1337 | if (TMath::Abs(y-0.00)>3.40) d+=dd; | |
1338 | if (TMath::Abs(y-1.90)<0.45) {d+=(0.013-0.0034);} | |
1339 | if (TMath::Abs(y+1.90)<0.45) {d+=(0.013-0.0034);} | |
1340 | for (Int_t i=0; i<12; i++) { | |
1341 | if (TMath::Abs(z-3.9*(i+0.5))<0.15) { | |
1342 | if (TMath::Abs(y-0.00)>3.40) d+=dd; | |
1343 | d+=0.0034; | |
1344 | break; | |
1345 | } | |
1346 | if (TMath::Abs(z+3.9*(i+0.5))<0.15) { | |
1347 | if (TMath::Abs(y-0.00)>3.40) d+=dd; | |
1348 | d+=0.0034; | |
1349 | break; | |
1350 | } | |
1351 | if (TMath::Abs(z-3.4-3.9*i)<0.50) {d+=(0.016-0.0034); break;} | |
1352 | if (TMath::Abs(z+0.5+3.9*i)<0.50) {d+=(0.016-0.0034); break;} | |
1353 | } | |
1354 | } else | |
1355 | if (37<fR&&fR<41) { //SSD1 | |
1356 | Double_t dd=0.0034; | |
1357 | d=dd; | |
1358 | if (TMath::Abs(y-0.00)>3.40) d+=dd; | |
1359 | if (TMath::Abs(y-1.90)<0.45) {d+=(0.013-0.0034);} | |
1360 | if (TMath::Abs(y+1.90)<0.45) {d+=(0.013-0.0034);} | |
1361 | for (Int_t i=0; i<11; i++) { | |
1362 | if (TMath::Abs(z-3.9*i)<0.15) { | |
1363 | if (TMath::Abs(y-0.00)>3.40) d+=dd; | |
1364 | d+=dd; | |
1365 | break; | |
1366 | } | |
1367 | if (TMath::Abs(z+3.9*i)<0.15) { | |
1368 | if (TMath::Abs(y-0.00)>3.40) d+=dd; | |
1369 | d+=dd; | |
1370 | break; | |
1371 | } | |
1372 | if (TMath::Abs(z-1.85-3.9*i)<0.50) {d+=(0.016-0.0034); break;} | |
1373 | if (TMath::Abs(z+2.05+3.9*i)<0.50) {d+=(0.016-0.0034); break;} | |
1374 | } | |
1375 | } else | |
1376 | if (13<fR&&fR<26) { //SDD | |
1377 | Double_t dd=0.0033; | |
1378 | d=dd; | |
1379 | if (TMath::Abs(y-0.00)>3.30) d+=dd; | |
1380 | ||
1381 | if (TMath::Abs(y-1.80)<0.55) { | |
1382 | d+=0.016; | |
1383 | for (Int_t j=0; j<20; j++) { | |
1384 | if (TMath::Abs(z+0.7+1.47*j)<0.12) {d+=0.08; x0=9.; break;} | |
1385 | if (TMath::Abs(z-0.7-1.47*j)<0.12) {d+=0.08; x0=9.; break;} | |
1386 | } | |
1387 | } | |
1388 | if (TMath::Abs(y+1.80)<0.55) { | |
1389 | d+=0.016; | |
1390 | for (Int_t j=0; j<20; j++) { | |
1391 | if (TMath::Abs(z-0.7-1.47*j)<0.12) {d+=0.08; x0=9.; break;} | |
1392 | if (TMath::Abs(z+0.7+1.47*j)<0.12) {d+=0.08; x0=9.; break;} | |
1393 | } | |
1394 | } | |
1395 | ||
1396 | for (Int_t i=0; i<4; i++) { | |
1397 | if (TMath::Abs(z-7.3*i)<0.60) { | |
1398 | d+=dd; | |
1399 | if (TMath::Abs(y-0.00)>3.30) d+=dd; | |
1400 | break; | |
1401 | } | |
1402 | if (TMath::Abs(z+7.3*i)<0.60) { | |
1403 | d+=dd; | |
1404 | if (TMath::Abs(y-0.00)>3.30) d+=dd; | |
1405 | break; | |
1406 | } | |
1407 | } | |
1408 | } else | |
1409 | if (6<fR&&fR<8) { //SPD2 | |
1410 | Double_t dd=0.0063; x0=21.5; | |
1411 | d=dd; | |
1412 | if (TMath::Abs(y-3.08)>0.5) d+=dd; | |
1413 | //if (TMath::Abs(y-3.08)>0.45) d+=dd; | |
1414 | if (TMath::Abs(y-3.03)<0.10) {d+=0.014;} | |
1415 | } else | |
1416 | if (3<fR&&fR<5) { //SPD1 | |
1417 | Double_t dd=0.0063; x0=21.5; | |
1418 | d=dd; | |
1419 | if (TMath::Abs(y+0.21)>0.6) d+=dd; | |
1420 | //if (TMath::Abs(y+0.21)>0.45) d+=dd; | |
1421 | if (TMath::Abs(y+0.10)<0.10) {d+=0.014;} | |
1422 | } | |
1423 | ||
1424 | return d; | |
1425 | } | |
1426 | ||
1427 | Double_t AliITStrackerMI::GetEffectiveThickness(Double_t y,Double_t z) const | |
1428 | { | |
1429 | //-------------------------------------------------------------------- | |
1430 | //Returns the thickness between the current layer and the vertex (units X0) | |
1431 | //-------------------------------------------------------------------- | |
1432 | Double_t d=0.0028*3*3; //beam pipe | |
1433 | Double_t x0=0; | |
1434 | ||
1435 | Double_t xn=fgLayers[fI].GetR(); | |
1436 | for (Int_t i=0; i<fI; i++) { | |
1437 | Double_t xi=fgLayers[i].GetR(); | |
1438 | d+=fgLayers[i].GetThickness(y,z,x0)*xi*xi; | |
1439 | } | |
1440 | ||
1441 | if (fI>1) { | |
1442 | Double_t xi=9.; | |
1443 | d+=0.0097*xi*xi; | |
1444 | } | |
1445 | ||
1446 | if (fI>3) { | |
1447 | Double_t xi=0.5*(fgLayers[3].GetR()+fgLayers[4].GetR()); | |
1448 | d+=0.0034*xi*xi; | |
1449 | } | |
1450 | ||
1451 | return d/(xn*xn); | |
1452 | } | |
1453 | ||
1454 | Int_t AliITStrackerMI::AliITSlayer::InRoad() const { | |
1455 | //-------------------------------------------------------------------- | |
1456 | // This function returns number of clusters within the "window" | |
1457 | //-------------------------------------------------------------------- | |
1458 | Int_t ncl=0; | |
1459 | for (Int_t i=fI; i<fN; i++) { | |
00a7cc50 | 1460 | const AliITSRecPoint *c=fClusters[i]; |
e43c066c | 1461 | if (c->GetZ() > fZmax) break; |
1462 | if (c->IsUsed()) continue; | |
1463 | const AliITSdetector &det=GetDetector(c->GetDetectorIndex()); | |
1464 | Double_t y=fR*det.GetPhi() + c->GetY(); | |
1465 | ||
1466 | if (y>2.*fR*TMath::Pi()) y -= 2*fR*TMath::Pi(); | |
1467 | if (y>1.*fR*TMath::Pi() && fYmax<y) y -= 2*fR*TMath::Pi(); | |
1468 | ||
1469 | if (y<fYmin) continue; | |
1470 | if (y>fYmax) continue; | |
1471 | ncl++; | |
1472 | } | |
1473 | return ncl; | |
1474 | } | |
1475 | ||
ef7253ac | 1476 | Bool_t AliITStrackerMI::RefitAt(Double_t xx,AliITStrackMI *t, |
1477 | const AliITStrackMI *c, Bool_t extra) { | |
e43c066c | 1478 | //-------------------------------------------------------------------- |
1479 | // This function refits the track "t" at the position "x" using | |
1480 | // the clusters from "c" | |
ef7253ac | 1481 | // If "extra"==kTRUE, |
1482 | // the clusters from overlapped modules get attached to "t" | |
e43c066c | 1483 | //-------------------------------------------------------------------- |
1484 | Int_t index[kMaxLayer]; | |
1485 | Int_t k; | |
1486 | for (k=0; k<kMaxLayer; k++) index[k]=-1; | |
1487 | Int_t nc=c->GetNumberOfClusters(); | |
1488 | for (k=0; k<nc; k++) { | |
1489 | Int_t idx=c->GetClusterIndex(k),nl=(idx&0xf0000000)>>28; | |
1490 | index[nl]=idx; | |
1491 | } | |
1492 | ||
1493 | Int_t from, to, step; | |
1494 | if (xx > t->GetX()) { | |
1495 | from=0; to=kMaxLayer; | |
1496 | step=+1; | |
1497 | } else { | |
1498 | from=kMaxLayer-1; to=-1; | |
1499 | step=-1; | |
1500 | } | |
1501 | ||
1502 | for (Int_t i=from; i != to; i += step) { | |
1503 | AliITSlayer &layer=fgLayers[i]; | |
1504 | Double_t r=layer.GetR(); | |
1505 | ||
1506 | { | |
1507 | Double_t hI=i-0.5*step; | |
1508 | if (TMath::Abs(hI-1.5)<0.01 || TMath::Abs(hI-3.5)<0.01) { | |
1509 | Double_t rs=0.5*(fgLayers[i-step].GetR() + r); | |
1510 | Double_t d=0.0034, x0=38.6; | |
1511 | if (TMath::Abs(hI-1.5)<0.01) {rs=9.; d=0.0097; x0=42;} | |
1512 | if (!t->PropagateTo(rs,-step*d,x0)) { | |
1513 | return kFALSE; | |
1514 | } | |
1515 | } | |
1516 | } | |
1517 | ||
1518 | // remember old position [SR, GSI 18.02.2003] | |
1519 | Double_t oldX=0., oldY=0., oldZ=0.; | |
1520 | if (t->IsStartedTimeIntegral() && step==1) { | |
1521 | t->GetGlobalXYZat(t->GetX(),oldX,oldY,oldZ); | |
1522 | } | |
1523 | // | |
1524 | ||
1525 | Double_t x,y,z; | |
1526 | if (!t->GetGlobalXYZat(r,x,y,z)) { | |
1527 | return kFALSE; | |
1528 | } | |
1529 | Double_t phi=TMath::ATan2(y,x); | |
1530 | Int_t idet=layer.FindDetectorIndex(phi,z); | |
1531 | if (idet<0) { | |
1532 | return kFALSE; | |
1533 | } | |
1534 | const AliITSdetector &det=layer.GetDetector(idet); | |
1535 | phi=det.GetPhi(); | |
1536 | if (!t->Propagate(phi,det.GetR())) { | |
1537 | return kFALSE; | |
1538 | } | |
1539 | t->SetDetectorIndex(idet); | |
1540 | ||
00a7cc50 | 1541 | const AliITSRecPoint *cl=0; |
e43c066c | 1542 | Double_t maxchi2=1000.*kMaxChi2; |
1543 | ||
1544 | Int_t idx=index[i]; | |
1545 | if (idx>0) { | |
00a7cc50 | 1546 | const AliITSRecPoint *c=(AliITSRecPoint *)GetCluster(idx); |
67c1e979 | 1547 | if (c){ |
1548 | if (idet != c->GetDetectorIndex()) { | |
1549 | idet=c->GetDetectorIndex(); | |
1550 | const AliITSdetector &det=layer.GetDetector(idet); | |
1551 | if (!t->Propagate(det.GetPhi(),det.GetR())) { | |
1552 | return kFALSE; | |
1553 | } | |
1554 | t->SetDetectorIndex(idet); | |
1555 | } | |
1556 | //Double_t chi2=t->GetPredictedChi2(c); | |
1557 | Int_t layer = (idx & 0xf0000000) >> 28;; | |
1558 | Double_t chi2=GetPredictedChi2MI(t,c,layer); | |
1559 | if (chi2<maxchi2) { | |
1560 | cl=c; | |
1561 | maxchi2=chi2; | |
1562 | } else { | |
1563 | return kFALSE; | |
1564 | } | |
1565 | } | |
1566 | } | |
67c1e979 | 1567 | |
67c1e979 | 1568 | if (cl) { |
1569 | //if (!t->Update(cl,maxchi2,idx)) { | |
1570 | if (!UpdateMI(t,cl,maxchi2,idx)) { | |
1571 | return kFALSE; | |
1572 | } | |
1573 | t->SetSampledEdx(cl->GetQ(),t->GetNumberOfClusters()-1); | |
1574 | } | |
1575 | ||
1576 | { | |
1577 | Double_t x0; | |
1578 | Double_t d=layer.GetThickness(t->GetY(),t->GetZ(),x0); | |
1579 | t->CorrectForMaterial(-step*d,x0); | |
1580 | } | |
1581 | ||
ef7253ac | 1582 | if (extra) { //search for extra clusters |
1583 | AliITStrackV2 tmp(*t); | |
1584 | Double_t dz=4*TMath::Sqrt(tmp.GetSigmaZ2()+kSigmaZ2[i]); | |
1585 | if (dz < 0.5*TMath::Abs(tmp.GetTgl())) dz=0.5*TMath::Abs(tmp.GetTgl()); | |
1586 | Double_t dy=4*TMath::Sqrt(t->GetSigmaY2()+kSigmaY2[i]); | |
1587 | if (dy < 0.5*TMath::Abs(tmp.GetSnp())) dy=0.5*TMath::Abs(tmp.GetSnp()); | |
1588 | Double_t zmin=t->GetZ() - dz; | |
1589 | Double_t zmax=t->GetZ() + dz; | |
1590 | Double_t ymin=t->GetY() + phi*r - dy; | |
1591 | Double_t ymax=t->GetY() + phi*r + dy; | |
1592 | layer.SelectClusters(zmin,zmax,ymin,ymax); | |
1593 | ||
1594 | const AliITSRecPoint *c=0; Int_t ci=-1,cci=-1; | |
1595 | Double_t maxchi2=1000.*kMaxChi2, tolerance=0.1; | |
1596 | while ((c=layer.GetNextCluster(ci))!=0) { | |
1597 | if (idet == c->GetDetectorIndex()) continue; | |
1598 | ||
1599 | const AliITSdetector &det=layer.GetDetector(c->GetDetectorIndex()); | |
1600 | ||
1601 | if (!tmp.Propagate(det.GetPhi(),det.GetR())) continue; | |
1602 | ||
1603 | if (TMath::Abs(tmp.GetZ() - c->GetZ()) > tolerance) continue; | |
1604 | if (TMath::Abs(tmp.GetY() - c->GetY()) > tolerance) continue; | |
1605 | ||
1606 | Double_t chi2=tmp.GetPredictedChi2(c); | |
1607 | if (chi2<maxchi2) { maxchi2=chi2; cci=ci; } | |
1608 | } | |
1609 | if (cci>=0) t->SetExtraCluster(i,(i<<28)+cci); | |
1610 | } | |
1611 | ||
67c1e979 | 1612 | // track time update [SR, GSI 17.02.2003] |
1613 | if (t->IsStartedTimeIntegral() && step==1) { | |
1614 | Double_t newX, newY, newZ; | |
1615 | t->GetGlobalXYZat(t->GetX(),newX,newY,newZ); | |
1616 | Double_t dL2 = (oldX-newX)*(oldX-newX) + (oldY-newY)*(oldY-newY) + | |
1617 | (oldZ-newZ)*(oldZ-newZ); | |
1618 | t->AddTimeStep(TMath::Sqrt(dL2)); | |
1619 | } | |
1620 | // | |
1621 | ||
1622 | } | |
1623 | ||
1624 | if (!t->PropagateTo(xx,0.,0.)) return kFALSE; | |
1625 | return kTRUE; | |
1626 | } | |
1627 | ||
67c1e979 | 1628 | Bool_t |
1629 | AliITStrackerMI::RefitAt(Double_t xx,AliITStrackMI *t,const Int_t *clindex) { | |
1630 | //-------------------------------------------------------------------- | |
1631 | // This function refits the track "t" at the position "x" using | |
1632 | // the clusters from array | |
1633 | //-------------------------------------------------------------------- | |
1634 | Int_t index[kMaxLayer]; | |
1635 | Int_t k; | |
1636 | for (k=0; k<kMaxLayer; k++) index[k]=-1; | |
1637 | // | |
1638 | for (k=0; k<kMaxLayer; k++) { | |
1639 | index[k]=clindex[k]; | |
1640 | } | |
1641 | ||
1642 | Int_t from, to, step; | |
1643 | if (xx > t->GetX()) { | |
1644 | from=0; to=kMaxLayer; | |
1645 | step=+1; | |
1646 | } else { | |
1647 | from=kMaxLayer-1; to=-1; | |
1648 | step=-1; | |
1649 | } | |
1650 | ||
1651 | for (Int_t i=from; i != to; i += step) { | |
1652 | AliITSlayer &layer=fgLayers[i]; | |
1653 | Double_t r=layer.GetR(); | |
1654 | if (step<0 && xx>r) break; // | |
1655 | { | |
1656 | Double_t hI=i-0.5*step; | |
1657 | if (TMath::Abs(hI-1.5)<0.01 || TMath::Abs(hI-3.5)<0.01) { | |
1658 | Double_t rs=0.5*(fgLayers[i-step].GetR() + r); | |
1659 | Double_t d=0.0034, x0=38.6; | |
1660 | if (TMath::Abs(hI-1.5)<0.01) {rs=9.; d=0.0097; x0=42;} | |
1661 | if (!t->PropagateTo(rs,-step*d,x0)) { | |
1662 | return kFALSE; | |
e43c066c | 1663 | } |
67c1e979 | 1664 | } |
1665 | } | |
1666 | ||
1667 | // remember old position [SR, GSI 18.02.2003] | |
1668 | Double_t oldX=0., oldY=0., oldZ=0.; | |
1669 | if (t->IsStartedTimeIntegral() && step==1) { | |
1670 | t->GetGlobalXYZat(t->GetX(),oldX,oldY,oldZ); | |
1671 | } | |
1672 | // | |
1673 | ||
1674 | Double_t x,y,z; | |
1675 | if (!t->GetGlobalXYZat(r,x,y,z)) { | |
1676 | return kFALSE; | |
1677 | } | |
1678 | Double_t phi=TMath::ATan2(y,x); | |
1679 | Int_t idet=layer.FindDetectorIndex(phi,z); | |
1680 | if (idet<0) { | |
1681 | return kFALSE; | |
1682 | } | |
1683 | const AliITSdetector &det=layer.GetDetector(idet); | |
1684 | phi=det.GetPhi(); | |
1685 | if (!t->Propagate(phi,det.GetR())) { | |
1686 | return kFALSE; | |
1687 | } | |
1688 | t->SetDetectorIndex(idet); | |
1689 | ||
00a7cc50 | 1690 | const AliITSRecPoint *cl=0; |
67c1e979 | 1691 | Double_t maxchi2=1000.*kMaxChi2; |
1692 | ||
1693 | Int_t idx=index[i]; | |
1694 | if (idx>0) { | |
00a7cc50 | 1695 | const AliITSRecPoint *c=(AliITSRecPoint *)GetCluster(idx); |
67c1e979 | 1696 | if (c){ |
1697 | if (idet != c->GetDetectorIndex()) { | |
1698 | idet=c->GetDetectorIndex(); | |
1699 | const AliITSdetector &det=layer.GetDetector(idet); | |
1700 | if (!t->Propagate(det.GetPhi(),det.GetR())) { | |
1701 | return kFALSE; | |
1702 | } | |
1703 | t->SetDetectorIndex(idet); | |
1704 | } | |
1705 | //Double_t chi2=t->GetPredictedChi2(c); | |
1706 | Int_t layer = (idx & 0xf0000000) >> 28;; | |
1707 | Double_t chi2=GetPredictedChi2MI(t,c,layer); | |
1708 | if (chi2<maxchi2) { | |
1709 | cl=c; | |
1710 | maxchi2=chi2; | |
1711 | } else { | |
1712 | return kFALSE; | |
1713 | } | |
e43c066c | 1714 | } |
1715 | } | |
1716 | /* | |
1717 | if (cl==0) | |
1718 | if (t->GetNumberOfClusters()>2) { | |
1719 | Double_t dz=4*TMath::Sqrt(t->GetSigmaZ2()+kSigmaZ2[i]); | |
1720 | Double_t dy=4*TMath::Sqrt(t->GetSigmaY2()+kSigmaY2[i]); | |
1721 | Double_t zmin=t->GetZ() - dz; | |
1722 | Double_t zmax=t->GetZ() + dz; | |
1723 | Double_t ymin=t->GetY() + phi*r - dy; | |
1724 | Double_t ymax=t->GetY() + phi*r + dy; | |
1725 | layer.SelectClusters(zmin,zmax,ymin,ymax); | |
1726 | ||
00a7cc50 | 1727 | const AliITSRecPoint *c=0; Int_t ci=-1; |
e43c066c | 1728 | while ((c=layer.GetNextCluster(ci))!=0) { |
1729 | if (idet != c->GetDetectorIndex()) continue; | |
1730 | Double_t chi2=t->GetPredictedChi2(c); | |
1731 | if (chi2<maxchi2) { cl=c; maxchi2=chi2; idx=ci; } | |
1732 | } | |
1733 | } | |
1734 | */ | |
1735 | if (cl) { | |
1736 | //if (!t->Update(cl,maxchi2,idx)) { | |
1737 | if (!UpdateMI(t,cl,maxchi2,idx)) { | |
1738 | return kFALSE; | |
1739 | } | |
1740 | t->SetSampledEdx(cl->GetQ(),t->GetNumberOfClusters()-1); | |
1741 | } | |
1742 | ||
1743 | { | |
1744 | Double_t x0; | |
1745 | Double_t d=layer.GetThickness(t->GetY(),t->GetZ(),x0); | |
1746 | t->CorrectForMaterial(-step*d,x0); | |
1747 | } | |
1748 | ||
1749 | // track time update [SR, GSI 17.02.2003] | |
1750 | if (t->IsStartedTimeIntegral() && step==1) { | |
1751 | Double_t newX, newY, newZ; | |
1752 | t->GetGlobalXYZat(t->GetX(),newX,newY,newZ); | |
1753 | Double_t dL2 = (oldX-newX)*(oldX-newX) + (oldY-newY)*(oldY-newY) + | |
1754 | (oldZ-newZ)*(oldZ-newZ); | |
1755 | t->AddTimeStep(TMath::Sqrt(dL2)); | |
1756 | } | |
1757 | // | |
1758 | ||
1759 | } | |
1760 | ||
1761 | if (!t->PropagateTo(xx,0.,0.)) return kFALSE; | |
1762 | return kTRUE; | |
1763 | } | |
1764 | ||
15dd636f | 1765 | Double_t AliITStrackerMI::GetNormalizedChi2(AliITStrackMI * track, Int_t mode) |
e43c066c | 1766 | { |
1767 | // | |
1768 | // calculate normalized chi2 | |
1769 | // return NormalizedChi2(track,0); | |
1770 | Float_t chi2 = 0; | |
1771 | Float_t sum=0; | |
1772 | Float_t *erry = GetErrY(fCurrentEsdTrack), *errz = GetErrZ(fCurrentEsdTrack); | |
1773 | // track->fdEdxMismatch=0; | |
1774 | Float_t dedxmismatch =0; | |
1775 | Float_t *ny = GetNy(fCurrentEsdTrack), *nz = GetNz(fCurrentEsdTrack); | |
1776 | if (mode<100){ | |
1777 | for (Int_t i = 0;i<6;i++){ | |
1778 | if (track->fClIndex[i]>0){ | |
1779 | Float_t cerry, cerrz; | |
1780 | if (ny[i]>0) {cerry = erry[i]; cerrz=errz[i];} | |
1781 | else | |
1782 | { cerry= track->fSigmaY[i]; cerrz = track->fSigmaZ[i];} | |
1783 | cerry*=cerry; | |
1784 | cerrz*=cerrz; | |
1785 | Float_t cchi2 = (track->fDy[i]*track->fDy[i]/cerry)+(track->fDz[i]*track->fDz[i]/cerrz); | |
1786 | if (i>1){ | |
1787 | Float_t ratio = track->fNormQ[i]/track->fExpQ; | |
1788 | if (ratio<0.5) { | |
1789 | cchi2+=(0.5-ratio)*10.; | |
1790 | //track->fdEdxMismatch+=(0.5-ratio)*10.; | |
1791 | dedxmismatch+=(0.5-ratio)*10.; | |
1792 | } | |
1793 | } | |
1794 | if (i<2 ||i>3){ | |
00a7cc50 | 1795 | AliITSRecPoint * cl = (AliITSRecPoint*)GetCluster( track->fClIndex[i]); |
e43c066c | 1796 | Double_t delta = cl->GetNy()+cl->GetNz()-ny[i]-nz[i]; |
1797 | if (delta>1) chi2 +=0.5*TMath::Min(delta/2,2.); | |
1798 | if (i<2) chi2+=2*cl->GetDeltaProbability(); | |
1799 | } | |
1800 | chi2+=cchi2; | |
1801 | sum++; | |
1802 | } | |
1803 | } | |
1804 | if (TMath::Abs(track->fdEdxMismatch-dedxmismatch)>0.0001){ | |
1805 | track->fdEdxMismatch = dedxmismatch; | |
1806 | } | |
1807 | } | |
1808 | else{ | |
1809 | for (Int_t i = 0;i<4;i++){ | |
1810 | if (track->fClIndex[i]>0){ | |
1811 | Float_t cerry, cerrz; | |
1812 | if (ny[i]>0) {cerry = erry[i]; cerrz=errz[i];} | |
1813 | else { cerry= track->fSigmaY[i]; cerrz = track->fSigmaZ[i];} | |
1814 | cerry*=cerry; | |
1815 | cerrz*=cerrz; | |
1816 | chi2+= (track->fDy[i]*track->fDy[i]/cerry); | |
1817 | chi2+= (track->fDz[i]*track->fDz[i]/cerrz); | |
1818 | sum++; | |
1819 | } | |
1820 | } | |
1821 | for (Int_t i = 4;i<6;i++){ | |
1822 | if (track->fClIndex[i]>0){ | |
1823 | Float_t cerry, cerrz; | |
1824 | if (ny[i]>0) {cerry = erry[i]; cerrz=errz[i];} | |
1825 | else { cerry= track->fSigmaY[i]; cerrz = track->fSigmaZ[i];} | |
1826 | cerry*=cerry; | |
1827 | cerrz*=cerrz; | |
1828 | Float_t cerryb, cerrzb; | |
1829 | if (ny[i+6]>0) {cerryb = erry[i+6]; cerrzb=errz[i+6];} | |
1830 | else { cerryb= track->fSigmaY[i+6]; cerrzb = track->fSigmaZ[i+6];} | |
1831 | cerryb*=cerryb; | |
1832 | cerrzb*=cerrzb; | |
1833 | chi2+= TMath::Min((track->fDy[i+6]*track->fDy[i+6]/cerryb),track->fDy[i]*track->fDy[i]/cerry); | |
1834 | chi2+= TMath::Min((track->fDz[i+6]*track->fDz[i+6]/cerrzb),track->fDz[i]*track->fDz[i]/cerrz); | |
1835 | sum++; | |
1836 | } | |
1837 | } | |
1838 | } | |
1839 | if (track->fESDtrack->GetTPCsignal()>85){ | |
1840 | Float_t ratio = track->fdEdx/track->fESDtrack->GetTPCsignal(); | |
1841 | if (ratio<0.5) { | |
1842 | chi2+=(0.5-ratio)*5.; | |
1843 | } | |
1844 | if (ratio>2){ | |
1845 | chi2+=(ratio-2.0)*3; | |
1846 | } | |
1847 | } | |
1848 | // | |
1849 | Double_t match = TMath::Sqrt(track->fChi22); | |
1850 | if (track->fConstrain) match/=track->GetNumberOfClusters(); | |
1851 | if (!track->fConstrain) match/=track->GetNumberOfClusters()-2.; | |
1852 | if (match<0) match=0; | |
1853 | Float_t deadzonefactor = (track->fNDeadZone>0) ? 3*(1.1-track->fDeadZoneProbability):0.; | |
1854 | Double_t normchi2 = 2*track->fNSkipped+match+deadzonefactor+(1+(2*track->fNSkipped+deadzonefactor)/track->GetNumberOfClusters())* | |
1855 | (chi2)/TMath::Max(double(sum-track->fNSkipped), | |
1856 | 1./(1.+track->fNSkipped)); | |
1857 | ||
1858 | return normchi2; | |
1859 | } | |
1860 | ||
1861 | ||
15dd636f | 1862 | Double_t AliITStrackerMI::GetMatchingChi2(AliITStrackMI * track1, AliITStrackMI * track2) |
e43c066c | 1863 | { |
1864 | // | |
1865 | // return matching chi2 between two tracks | |
15dd636f | 1866 | AliITStrackMI track3(*track2); |
e43c066c | 1867 | track3.Propagate(track1->GetAlpha(),track1->GetX()); |
1868 | TMatrixD vec(5,1); | |
1869 | vec(0,0)=track1->fP0-track3.fP0; | |
1870 | vec(1,0)=track1->fP1-track3.fP1; | |
1871 | vec(2,0)=track1->fP2-track3.fP2; | |
1872 | vec(3,0)=track1->fP3-track3.fP3; | |
1873 | vec(4,0)=track1->fP4-track3.fP4; | |
1874 | // | |
1875 | TMatrixD cov(5,5); | |
1876 | cov(0,0) = track1->fC00+track3.fC00; | |
1877 | cov(1,1) = track1->fC11+track3.fC11; | |
1878 | cov(2,2) = track1->fC22+track3.fC22; | |
1879 | cov(3,3) = track1->fC33+track3.fC33; | |
1880 | cov(4,4) = track1->fC44+track3.fC44; | |
1881 | ||
1882 | cov(0,1)=cov(1,0) = track1->fC10+track3.fC10; | |
1883 | cov(0,2)=cov(2,0) = track1->fC20+track3.fC20; | |
1884 | cov(0,3)=cov(3,0) = track1->fC30+track3.fC30; | |
1885 | cov(0,4)=cov(4,0) = track1->fC40+track3.fC40; | |
1886 | // | |
1887 | cov(1,2)=cov(2,1) = track1->fC21+track3.fC21; | |
1888 | cov(1,3)=cov(3,1) = track1->fC31+track3.fC31; | |
1889 | cov(1,4)=cov(4,1) = track1->fC41+track3.fC41; | |
1890 | // | |
1891 | cov(2,3)=cov(3,2) = track1->fC32+track3.fC32; | |
1892 | cov(2,4)=cov(4,2) = track1->fC42+track3.fC42; | |
1893 | // | |
1894 | cov(3,4)=cov(4,3) = track1->fC43+track3.fC43; | |
1895 | ||
1896 | cov.Invert(); | |
1897 | TMatrixD vec2(cov,TMatrixD::kMult,vec); | |
1898 | TMatrixD chi2(vec2,TMatrixD::kTransposeMult,vec); | |
1899 | return chi2(0,0); | |
1900 | } | |
1901 | ||
1902 | Double_t AliITStrackerMI::GetDeadZoneProbability(Double_t zpos, Double_t zerr) | |
1903 | { | |
1904 | // | |
1905 | // return probability that given point - characterized by z position and error is in dead zone | |
1906 | // | |
1907 | Double_t probability =0; | |
1908 | Double_t absz = TMath::Abs(zpos); | |
1909 | Double_t nearestz = (absz<2)? 0.:7.1; | |
1910 | if (TMath::Abs(absz-nearestz)>0.25+3*zerr) return 0; | |
1911 | Double_t zmin=0, zmax=0; | |
1912 | if (zpos<-6.){ | |
1913 | zmin = -7.25; zmax = -6.95; | |
1914 | } | |
1915 | if (zpos>6){ | |
1916 | zmin = 7.0; zmax =7.3; | |
1917 | } | |
1918 | if (absz<2){ | |
1919 | zmin = -0.75; zmax = 1.5; | |
1920 | } | |
1921 | probability = (TMath::Erf((zpos-zmin)/zerr) - TMath::Erf((zpos-zmax)/zerr))*0.5; | |
1922 | return probability; | |
1923 | } | |
1924 | ||
1925 | ||
15dd636f | 1926 | Double_t AliITStrackerMI::GetTruncatedChi2(AliITStrackMI * track, Float_t fac) |
e43c066c | 1927 | { |
1928 | // | |
1929 | // calculate normalized chi2 | |
1930 | Float_t chi2[6]; | |
1931 | Float_t *erry = GetErrY(fCurrentEsdTrack), *errz = GetErrZ(fCurrentEsdTrack); | |
1932 | Float_t ncl = 0; | |
1933 | for (Int_t i = 0;i<6;i++){ | |
1934 | if (TMath::Abs(track->fDy[i])>0){ | |
1935 | chi2[i]= (track->fDy[i]/erry[i])*(track->fDy[i]/erry[i]); | |
1936 | chi2[i]+= (track->fDz[i]/errz[i])*(track->fDz[i]/errz[i]); | |
1937 | ncl++; | |
1938 | } | |
1939 | else{chi2[i]=10000;} | |
1940 | } | |
1941 | Int_t index[6]; | |
1942 | TMath::Sort(6,chi2,index,kFALSE); | |
1943 | Float_t max = float(ncl)*fac-1.; | |
1944 | Float_t sumchi=0, sumweight=0; | |
1945 | for (Int_t i=0;i<max+1;i++){ | |
1946 | Float_t weight = (i<max)?1.:(max+1.-i); | |
1947 | sumchi+=weight*chi2[index[i]]; | |
1948 | sumweight+=weight; | |
1949 | } | |
1950 | Double_t normchi2 = sumchi/sumweight; | |
1951 | return normchi2; | |
1952 | } | |
1953 | ||
1954 | ||
15dd636f | 1955 | Double_t AliITStrackerMI::GetInterpolatedChi2(AliITStrackMI * forwardtrack, AliITStrackMI * backtrack) |
e43c066c | 1956 | { |
1957 | // | |
1958 | // calculate normalized chi2 | |
1959 | // if (forwardtrack->fNUsed>0.3*float(forwardtrack->GetNumberOfClusters())) return 10000; | |
1960 | Int_t npoints = 0; | |
1961 | Double_t res =0; | |
1962 | for (Int_t i=0;i<6;i++){ | |
1963 | if ( (backtrack->fSigmaY[i]<0.000000001) || (forwardtrack->fSigmaY[i]<0.000000001)) continue; | |
1964 | Double_t sy1 = forwardtrack->fSigmaY[i]; | |
1965 | Double_t sz1 = forwardtrack->fSigmaZ[i]; | |
1966 | Double_t sy2 = backtrack->fSigmaY[i]; | |
1967 | Double_t sz2 = backtrack->fSigmaZ[i]; | |
1968 | if (i<2){ sy2=1000.;sz2=1000;} | |
1969 | // | |
1970 | Double_t dy0 = (forwardtrack->fDy[i]/(sy1*sy1) +backtrack->fDy[i]/(sy2*sy2))/(1./(sy1*sy1)+1./(sy2*sy2)); | |
1971 | Double_t dz0 = (forwardtrack->fDz[i]/(sz1*sz1) +backtrack->fDz[i]/(sz2*sz2))/(1./(sz1*sz1)+1./(sz2*sz2)); | |
1972 | // | |
1973 | Double_t nz0 = dz0*TMath::Sqrt((1./(sz1*sz1)+1./(sz2*sz2))); | |
1974 | Double_t ny0 = dy0*TMath::Sqrt((1./(sy1*sy1)+1./(sy2*sy2))); | |
1975 | // | |
1976 | res+= nz0*nz0+ny0*ny0; | |
1977 | npoints++; | |
1978 | } | |
1979 | if (npoints>1) return | |
1980 | TMath::Max(TMath::Abs(0.3*forwardtrack->Get1Pt())-0.5,0.)+ | |
1981 | //2*forwardtrack->fNUsed+ | |
1982 | res/TMath::Max(double(npoints-forwardtrack->fNSkipped), | |
1983 | 1./(1.+forwardtrack->fNSkipped)); | |
1984 | return 1000; | |
1985 | } | |
1986 | ||
1987 | ||
1988 | ||
1989 | ||
1990 | ||
1991 | Float_t *AliITStrackerMI::GetWeight(Int_t index) { | |
1992 | //-------------------------------------------------------------------- | |
1993 | // Return pointer to a given cluster | |
1994 | //-------------------------------------------------------------------- | |
1995 | Int_t l=(index & 0xf0000000) >> 28; | |
1996 | Int_t c=(index & 0x0fffffff) >> 00; | |
1997 | return fgLayers[l].GetWeight(c); | |
1998 | } | |
1999 | ||
15dd636f | 2000 | void AliITStrackerMI::RegisterClusterTracks(AliITStrackMI* track,Int_t id) |
e43c066c | 2001 | { |
2002 | //--------------------------------------------- | |
2003 | // register track to the list | |
628e7bb0 | 2004 | // |
2005 | if (track->fESDtrack->GetKinkIndex(0)!=0) return; //don't register kink tracks | |
2006 | // | |
2007 | // | |
e43c066c | 2008 | for (Int_t icluster=0;icluster<track->GetNumberOfClusters();icluster++){ |
2009 | Int_t index = track->GetClusterIndex(icluster); | |
2010 | Int_t l=(index & 0xf0000000) >> 28; | |
2011 | Int_t c=(index & 0x0fffffff) >> 00; | |
2012 | if (c>fgLayers[l].fN) continue; | |
2013 | for (Int_t itrack=0;itrack<4;itrack++){ | |
2014 | if (fgLayers[l].fClusterTracks[itrack][c]<0){ | |
2015 | fgLayers[l].fClusterTracks[itrack][c]=id; | |
2016 | break; | |
2017 | } | |
2018 | } | |
2019 | } | |
2020 | } | |
15dd636f | 2021 | void AliITStrackerMI::UnRegisterClusterTracks(AliITStrackMI* track, Int_t id) |
e43c066c | 2022 | { |
2023 | //--------------------------------------------- | |
2024 | // unregister track from the list | |
2025 | for (Int_t icluster=0;icluster<track->GetNumberOfClusters();icluster++){ | |
2026 | Int_t index = track->GetClusterIndex(icluster); | |
2027 | Int_t l=(index & 0xf0000000) >> 28; | |
2028 | Int_t c=(index & 0x0fffffff) >> 00; | |
2029 | if (c>fgLayers[l].fN) continue; | |
2030 | for (Int_t itrack=0;itrack<4;itrack++){ | |
2031 | if (fgLayers[l].fClusterTracks[itrack][c]==id){ | |
2032 | fgLayers[l].fClusterTracks[itrack][c]=-1; | |
2033 | } | |
2034 | } | |
2035 | } | |
2036 | } | |
00a7cc50 | 2037 | Float_t AliITStrackerMI::GetNumberOfSharedClusters(AliITStrackMI* track,Int_t id, Int_t list[6], AliITSRecPoint *clist[6]) |
e43c066c | 2038 | { |
2039 | //------------------------------------------------------------- | |
2040 | //get number of shared clusters | |
2041 | //------------------------------------------------------------- | |
2042 | Float_t shared=0; | |
2043 | for (Int_t i=0;i<6;i++) { list[i]=-1, clist[i]=0;} | |
2044 | // mean number of clusters | |
2045 | Float_t *ny = GetNy(id), *nz = GetNz(id); | |
2046 | ||
2047 | ||
2048 | for (Int_t icluster=0;icluster<track->GetNumberOfClusters();icluster++){ | |
2049 | Int_t index = track->GetClusterIndex(icluster); | |
2050 | Int_t l=(index & 0xf0000000) >> 28; | |
2051 | Int_t c=(index & 0x0fffffff) >> 00; | |
2052 | if (c>fgLayers[l].fN) continue; | |
2053 | if (ny[l]==0){ | |
2054 | printf("problem\n"); | |
2055 | } | |
00a7cc50 | 2056 | AliITSRecPoint *cl = (AliITSRecPoint*)GetCluster(index); |
e43c066c | 2057 | Float_t weight=1; |
2058 | // | |
2059 | Float_t deltan = 0; | |
2060 | if (l>3&&cl->GetNy()+cl->GetNz()>6) continue; | |
2061 | if (l>2&&track->fNormQ[l]/track->fExpQ>3.5) continue; | |
2062 | if (l<2 || l>3){ | |
2063 | deltan = (cl->GetNy()+cl->GetNz()-ny[l]-nz[l]); | |
2064 | } | |
2065 | else{ | |
2066 | deltan = (cl->GetNz()-nz[l]); | |
2067 | } | |
2068 | if (deltan>2.0) continue; // extended - highly probable shared cluster | |
2069 | weight = 2./TMath::Max(3.+deltan,2.); | |
2070 | // | |
2071 | for (Int_t itrack=0;itrack<4;itrack++){ | |
2072 | if (fgLayers[l].fClusterTracks[itrack][c]>=0 && fgLayers[l].fClusterTracks[itrack][c]!=id){ | |
2073 | list[l]=index; | |
00a7cc50 | 2074 | clist[l] = (AliITSRecPoint*)GetCluster(index); |
e43c066c | 2075 | shared+=weight; |
2076 | break; | |
2077 | } | |
2078 | } | |
2079 | } | |
2080 | track->fNUsed=shared; | |
2081 | return shared; | |
2082 | } | |
2083 | ||
15dd636f | 2084 | Int_t AliITStrackerMI::GetOverlapTrack(AliITStrackMI *track, Int_t trackID, Int_t &shared, Int_t clusterlist[6],Int_t overlist[6]) |
e43c066c | 2085 | { |
2086 | // | |
2087 | // find first shared track | |
2088 | // | |
2089 | // mean number of clusters | |
2090 | Float_t *ny = GetNy(trackID), *nz = GetNz(trackID); | |
2091 | // | |
2092 | for (Int_t i=0;i<6;i++) overlist[i]=-1; | |
2093 | Int_t sharedtrack=100000; | |
2094 | Int_t tracks[24],trackindex=0; | |
2095 | for (Int_t i=0;i<24;i++) {tracks[i]=-1;} | |
2096 | // | |
2097 | for (Int_t icluster=0;icluster<6;icluster++){ | |
2098 | if (clusterlist[icluster]<0) continue; | |
2099 | Int_t index = clusterlist[icluster]; | |
2100 | Int_t l=(index & 0xf0000000) >> 28; | |
2101 | Int_t c=(index & 0x0fffffff) >> 00; | |
2102 | if (ny[l]==0){ | |
2103 | printf("problem\n"); | |
2104 | } | |
2105 | if (c>fgLayers[l].fN) continue; | |
2106 | //if (l>3) continue; | |
00a7cc50 | 2107 | AliITSRecPoint *cl = (AliITSRecPoint*)GetCluster(index); |
e43c066c | 2108 | // |
2109 | Float_t deltan = 0; | |
2110 | if (l>3&&cl->GetNy()+cl->GetNz()>6) continue; | |
2111 | if (l>2&&track->fNormQ[l]/track->fExpQ>3.5) continue; | |
2112 | if (l<2 || l>3){ | |
2113 | deltan = (cl->GetNy()+cl->GetNz()-ny[l]-nz[l]); | |
2114 | } | |
2115 | else{ | |
2116 | deltan = (cl->GetNz()-nz[l]); | |
2117 | } | |
2118 | if (deltan>2.0) continue; // extended - highly probable shared cluster | |
2119 | // | |
2120 | for (Int_t itrack=3;itrack>=0;itrack--){ | |
2121 | if (fgLayers[l].fClusterTracks[itrack][c]<0) continue; | |
2122 | if (fgLayers[l].fClusterTracks[itrack][c]!=trackID){ | |
2123 | tracks[trackindex] = fgLayers[l].fClusterTracks[itrack][c]; | |
2124 | trackindex++; | |
2125 | } | |
2126 | } | |
2127 | } | |
2128 | if (trackindex==0) return -1; | |
2129 | if (trackindex==1){ | |
2130 | sharedtrack = tracks[0]; | |
2131 | }else{ | |
2132 | if (trackindex==2) sharedtrack =TMath::Min(tracks[0],tracks[1]); | |
2133 | else{ | |
2134 | // | |
2135 | Int_t track[24], cluster[24]; | |
2136 | for (Int_t i=0;i<trackindex;i++){ track[i]=-1; cluster[i]=0;} | |
2137 | Int_t index =0; | |
2138 | // | |
2139 | for (Int_t i=0;i<trackindex;i++){ | |
2140 | if (tracks[i]<0) continue; | |
2141 | track[index] = tracks[i]; | |
2142 | cluster[index]++; | |
2143 | for (Int_t j=i+1;j<trackindex;j++){ | |
2144 | if (tracks[j]<0) continue; | |
2145 | if (tracks[j]==tracks[i]){ | |
2146 | cluster[index]++; | |
2147 | tracks[j]=-1; | |
2148 | } | |
2149 | } | |
2150 | index++; | |
2151 | } | |
2152 | Int_t max=0; | |
2153 | for (Int_t i=0;i<index;i++){ | |
2154 | if (cluster[index]>max) { | |
2155 | sharedtrack=track[index]; | |
2156 | max=cluster[index]; | |
2157 | } | |
2158 | } | |
2159 | } | |
2160 | } | |
2161 | ||
2162 | if (sharedtrack>=100000) return -1; | |
2163 | // | |
2164 | // make list of overlaps | |
2165 | shared =0; | |
2166 | for (Int_t icluster=0;icluster<6;icluster++){ | |
2167 | if (clusterlist[icluster]<0) continue; | |
2168 | Int_t index = clusterlist[icluster]; | |
2169 | Int_t l=(index & 0xf0000000) >> 28; | |
2170 | Int_t c=(index & 0x0fffffff) >> 00; | |
2171 | if (c>fgLayers[l].fN) continue; | |
00a7cc50 | 2172 | AliITSRecPoint *cl = (AliITSRecPoint*)GetCluster(index); |
e43c066c | 2173 | if (l==0 || l==1){ |
2174 | if (cl->GetNy()>2) continue; | |
2175 | if (cl->GetNz()>2) continue; | |
2176 | } | |
2177 | if (l==4 || l==5){ | |
2178 | if (cl->GetNy()>3) continue; | |
2179 | if (cl->GetNz()>3) continue; | |
2180 | } | |
2181 | // | |
2182 | for (Int_t itrack=3;itrack>=0;itrack--){ | |
2183 | if (fgLayers[l].fClusterTracks[itrack][c]<0) continue; | |
2184 | if (fgLayers[l].fClusterTracks[itrack][c]==sharedtrack){ | |
2185 | overlist[l]=index; | |
2186 | shared++; | |
2187 | } | |
2188 | } | |
2189 | } | |
2190 | return sharedtrack; | |
2191 | } | |
2192 | ||
2193 | ||
15dd636f | 2194 | AliITStrackMI * AliITStrackerMI::GetBest2Tracks(Int_t trackID1, Int_t trackID2, Float_t th0, Float_t th1){ |
e43c066c | 2195 | // |
2196 | // try to find track hypothesys without conflicts | |
2197 | // with minimal chi2; | |
2198 | TClonesArray *arr1 = (TClonesArray*)fTrackHypothesys.At(trackID1); | |
2199 | Int_t entries1 = arr1->GetEntriesFast(); | |
2200 | TClonesArray *arr2 = (TClonesArray*)fTrackHypothesys.At(trackID2); | |
15dd636f | 2201 | if (!arr2) return (AliITStrackMI*) arr1->UncheckedAt(0); |
e43c066c | 2202 | Int_t entries2 = arr2->GetEntriesFast(); |
15dd636f | 2203 | if (entries2<=0) return (AliITStrackMI*) arr1->UncheckedAt(0); |
e43c066c | 2204 | // |
15dd636f | 2205 | AliITStrackMI * track10=(AliITStrackMI*) arr1->UncheckedAt(0); |
2206 | AliITStrackMI * track20=(AliITStrackMI*) arr2->UncheckedAt(0); | |
e43c066c | 2207 | if (TMath::Abs(1./track10->Get1Pt())>0.5+TMath::Abs(1/track20->Get1Pt())) return track10; |
2208 | ||
2209 | for (Int_t itrack=0;itrack<entries1;itrack++){ | |
15dd636f | 2210 | AliITStrackMI * track=(AliITStrackMI*) arr1->UncheckedAt(itrack); |
e43c066c | 2211 | UnRegisterClusterTracks(track,trackID1); |
2212 | } | |
2213 | // | |
2214 | for (Int_t itrack=0;itrack<entries2;itrack++){ | |
15dd636f | 2215 | AliITStrackMI * track=(AliITStrackMI*) arr2->UncheckedAt(itrack); |
e43c066c | 2216 | UnRegisterClusterTracks(track,trackID2); |
2217 | } | |
2218 | Int_t index1=0; | |
2219 | Int_t index2=0; | |
2220 | Float_t maxconflicts=6; | |
2221 | Double_t maxchi2 =1000.; | |
2222 | // | |
2223 | // get weight of hypothesys - using best hypothesy | |
2224 | Double_t w1,w2; | |
2225 | ||
2226 | Int_t list1[6],list2[6]; | |
00a7cc50 | 2227 | AliITSRecPoint *clist1[6], *clist2[6] ; |
e43c066c | 2228 | RegisterClusterTracks(track10,trackID1); |
2229 | RegisterClusterTracks(track20,trackID2); | |
2230 | Float_t conflict1 = GetNumberOfSharedClusters(track10,trackID1,list1,clist1); | |
2231 | Float_t conflict2 = GetNumberOfSharedClusters(track20,trackID2,list2,clist2); | |
2232 | UnRegisterClusterTracks(track10,trackID1); | |
2233 | UnRegisterClusterTracks(track20,trackID2); | |
2234 | // | |
2235 | // normalized chi2 | |
2236 | Float_t chi21 =0,chi22=0,ncl1=0,ncl2=0; | |
2237 | Float_t nerry[6],nerrz[6]; | |
2238 | Float_t *erry1=GetErrY(trackID1),*errz1 = GetErrZ(trackID1); | |
2239 | Float_t *erry2=GetErrY(trackID2),*errz2 = GetErrZ(trackID2); | |
2240 | for (Int_t i=0;i<6;i++){ | |
2241 | if ( (erry1[i]>0) && (erry2[i]>0)) { | |
2242 | nerry[i] = TMath::Min(erry1[i],erry2[i]); | |
2243 | nerrz[i] = TMath::Min(errz1[i],errz2[i]); | |
2244 | }else{ | |
2245 | nerry[i] = TMath::Max(erry1[i],erry2[i]); | |
2246 | nerrz[i] = TMath::Max(errz1[i],errz2[i]); | |
2247 | } | |
2248 | if (TMath::Abs(track10->fDy[i])>0.000000000000001){ | |
2249 | chi21 += track10->fDy[i]*track10->fDy[i]/(nerry[i]*nerry[i]); | |
2250 | chi21 += track10->fDz[i]*track10->fDz[i]/(nerrz[i]*nerrz[i]); | |
2251 | ncl1++; | |
2252 | } | |
2253 | if (TMath::Abs(track20->fDy[i])>0.000000000000001){ | |
2254 | chi22 += track20->fDy[i]*track20->fDy[i]/(nerry[i]*nerry[i]); | |
2255 | chi22 += track20->fDz[i]*track20->fDz[i]/(nerrz[i]*nerrz[i]); | |
2256 | ncl2++; | |
2257 | } | |
2258 | } | |
2259 | chi21/=ncl1; | |
2260 | chi22/=ncl2; | |
2261 | // | |
2262 | // | |
2263 | Float_t d1 = TMath::Sqrt(track10->fD[0]*track10->fD[0]+track10->fD[1]*track10->fD[1])+0.1; | |
2264 | Float_t d2 = TMath::Sqrt(track20->fD[0]*track20->fD[0]+track20->fD[1]*track20->fD[1])+0.1; | |
2265 | Float_t s1 = TMath::Sqrt(track10->GetSigmaY2()*track10->GetSigmaZ2()); | |
2266 | Float_t s2 = TMath::Sqrt(track20->GetSigmaY2()*track20->GetSigmaZ2()); | |
2267 | // | |
2268 | w1 = (d2/(d1+d2)+ 2*s2/(s1+s2)+ | |
2269 | +s2/(s1+s2)*0.5*(chi22+2.)/(chi21+chi22+4.) | |
2270 | +1.*TMath::Abs(1./track10->Get1Pt())/(TMath::Abs(1./track10->Get1Pt())+TMath::Abs(1./track20->Get1Pt())) | |
2271 | ); | |
2272 | w2 = (d1/(d1+d2)+ 2*s1/(s1+s2)+ | |
2273 | s1/(s1+s2)*0.5*(chi21+2.)/(chi21+chi22+4.) | |
2274 | +1.*TMath::Abs(1./track20->Get1Pt())/(TMath::Abs(1./track10->Get1Pt())+TMath::Abs(1./track20->Get1Pt())) | |
2275 | ); | |
2276 | ||
2277 | Double_t sumw = w1+w2; | |
2278 | w1/=sumw; | |
2279 | w2/=sumw; | |
2280 | if (w1<w2*0.5) { | |
2281 | w1 = (d2+0.5)/(d1+d2+1.); | |
2282 | w2 = (d1+0.5)/(d1+d2+1.); | |
2283 | } | |
2284 | // Float_t maxmax = w1*track10->fChi2MIP[0]+w2*track20->fChi2MIP[0]+w1*conflict1+w2*conflict2+1.; | |
2285 | //Float_t maxconflicts0 = w1*conflict1+w2*conflict2; | |
2286 | // | |
2287 | // get pair of "best" hypothesys | |
2288 | // | |
2289 | Float_t * ny1 = GetNy(trackID1), * nz1 = GetNz(trackID1); | |
2290 | Float_t * ny2 = GetNy(trackID2), * nz2 = GetNz(trackID2); | |
2291 | ||
2292 | for (Int_t itrack1=0;itrack1<entries1;itrack1++){ | |
15dd636f | 2293 | AliITStrackMI * track1=(AliITStrackMI*) arr1->UncheckedAt(itrack1); |
e43c066c | 2294 | //if (track1->fFakeRatio>0) continue; |
2295 | RegisterClusterTracks(track1,trackID1); | |
2296 | for (Int_t itrack2=0;itrack2<entries2;itrack2++){ | |
15dd636f | 2297 | AliITStrackMI * track2=(AliITStrackMI*) arr2->UncheckedAt(itrack2); |
e43c066c | 2298 | |
2299 | // Float_t current = w1*track1->fChi2MIP[0]+w2*track2->fChi2MIP[0]; | |
2300 | //if (track2->fFakeRatio>0) continue; | |
2301 | Float_t nskipped=0; | |
2302 | RegisterClusterTracks(track2,trackID2); | |
2303 | Int_t list1[6],list2[6]; | |
00a7cc50 | 2304 | AliITSRecPoint *clist1[6], *clist2[6] ; |
e43c066c | 2305 | Float_t cconflict1 = GetNumberOfSharedClusters(track1,trackID1,list1,clist1); |
2306 | Float_t cconflict2 = GetNumberOfSharedClusters(track2,trackID2,list2,clist2); | |
2307 | UnRegisterClusterTracks(track2,trackID2); | |
2308 | // | |
2309 | if (track1->fConstrain) nskipped+=w1*track1->fNSkipped; | |
2310 | if (track2->fConstrain) nskipped+=w2*track2->fNSkipped; | |
2311 | if (nskipped>0.5) continue; | |
2312 | // | |
2313 | //if ( w1*conflict1+w2*conflict2>maxconflicts0) continue; | |
2314 | if (conflict1+1<cconflict1) continue; | |
2315 | if (conflict2+1<cconflict2) continue; | |
2316 | Float_t conflict=0; | |
2317 | Float_t sumchi2=0; | |
2318 | Float_t sum=0; | |
2319 | for (Int_t i=0;i<6;i++){ | |
2320 | // | |
2321 | Float_t c1 =0.; // conflict coeficients | |
2322 | Float_t c2 =0.; | |
2323 | if (clist1[i]&&clist2[i]){ | |
2324 | Float_t deltan = 0; | |
2325 | if (i<2 || i>3){ | |
2326 | deltan = (clist1[i]->GetNy()+clist1[i]->GetNz()-TMath::Max(ny1[i],ny2[i])-TMath::Max(nz1[i],nz2[i])); | |
2327 | } | |
2328 | else{ | |
2329 | deltan = (clist1[i]->GetNz()-TMath::Max(nz1[i],nz2[i])); | |
2330 | } | |
2331 | c1 = 2./TMath::Max(3.+deltan,2.); | |
2332 | c2 = 2./TMath::Max(3.+deltan,2.); | |
2333 | } | |
2334 | else{ | |
2335 | if (clist1[i]){ | |
2336 | Float_t deltan = 0; | |
2337 | if (i<2 || i>3){ | |
2338 | deltan = (clist1[i]->GetNy()+clist1[i]->GetNz()-ny1[i]-nz1[i]); | |
2339 | } | |
2340 | else{ | |
2341 | deltan = (clist1[i]->GetNz()-nz1[i]); | |
2342 | } | |
2343 | c1 = 2./TMath::Max(3.+deltan,2.); | |
2344 | c2 = 0; | |
2345 | } | |
2346 | ||
2347 | if (clist2[i]){ | |
2348 | Float_t deltan = 0; | |
2349 | if (i<2 || i>3){ | |
2350 | deltan = (clist2[i]->GetNy()+clist2[i]->GetNz()-ny2[i]-nz2[i]); | |
2351 | } | |
2352 | else{ | |
2353 | deltan = (clist2[i]->GetNz()-nz2[i]); | |
2354 | } | |
2355 | c2 = 2./TMath::Max(3.+deltan,2.); | |
2356 | c1 = 0; | |
2357 | } | |
2358 | } | |
2359 | // | |
2360 | Double_t chi21=0,chi22=0; | |
2361 | if (TMath::Abs(track1->fDy[i])>0.) { | |
2362 | chi21 = (track1->fDy[i]/track1->fSigmaY[i])*(track1->fDy[i]/track1->fSigmaY[i])+ | |
2363 | (track1->fDz[i]/track1->fSigmaZ[i])*(track1->fDz[i]/track1->fSigmaZ[i]); | |
2364 | //chi21 = (track1->fDy[i]*track1->fDy[i])/(nerry[i]*nerry[i])+ | |
2365 | // (track1->fDz[i]*track1->fDz[i])/(nerrz[i]*nerrz[i]); | |
2366 | }else{ | |
2367 | if (TMath::Abs(track1->fSigmaY[i]>0.)) c1=1; | |
2368 | } | |
2369 | // | |
2370 | if (TMath::Abs(track2->fDy[i])>0.) { | |
2371 | chi22 = (track2->fDy[i]/track2->fSigmaY[i])*(track2->fDy[i]/track2->fSigmaY[i])+ | |
2372 | (track2->fDz[i]/track2->fSigmaZ[i])*(track2->fDz[i]/track2->fSigmaZ[i]); | |
2373 | //chi22 = (track2->fDy[i]*track2->fDy[i])/(nerry[i]*nerry[i])+ | |
2374 | // (track2->fDz[i]*track2->fDz[i])/(nerrz[i]*nerrz[i]); | |
2375 | } | |
2376 | else{ | |
2377 | if (TMath::Abs(track2->fSigmaY[i]>0.)) c2=1; | |
2378 | } | |
2379 | sumchi2+=w1*(1.+c1)*(1+c1)*(chi21+c1)+w2*(1.+c2)*(1+c2)*(chi22+c2); | |
2380 | if (chi21>0) sum+=w1; | |
2381 | if (chi22>0) sum+=w2; | |
2382 | conflict+=(c1+c2); | |
2383 | } | |
2384 | Double_t norm = sum-w1*track1->fNSkipped-w2*track2->fNSkipped; | |
2385 | if (norm<0) norm =1/(w1*track1->fNSkipped+w2*track2->fNSkipped); | |
2386 | Double_t normchi2 = 2*conflict+sumchi2/sum; | |
2387 | if ( normchi2 <maxchi2 ){ | |
2388 | index1 = itrack1; | |
2389 | index2 = itrack2; | |
2390 | maxconflicts = conflict; | |
2391 | maxchi2 = normchi2; | |
2392 | } | |
2393 | } | |
2394 | UnRegisterClusterTracks(track1,trackID1); | |
2395 | } | |
2396 | // | |
2397 | // if (maxconflicts<4 && maxchi2<th0){ | |
2398 | if (maxchi2<th0*2.){ | |
2399 | Float_t orig = track10->fFakeRatio*track10->GetNumberOfClusters(); | |
15dd636f | 2400 | AliITStrackMI* track1=(AliITStrackMI*) arr1->UncheckedAt(index1); |
e43c066c | 2401 | track1->fChi2MIP[5] = maxconflicts; |
2402 | track1->fChi2MIP[6] = maxchi2; | |
2403 | track1->fChi2MIP[7] = 0.01+orig-(track1->fFakeRatio*track1->GetNumberOfClusters()); | |
2404 | // track1->UpdateESDtrack(AliESDtrack::kITSin); | |
2405 | track1->fChi2MIP[8] = index1; | |
2406 | fBestTrackIndex[trackID1] =index1; | |
2407 | UpdateESDtrack(track1, AliESDtrack::kITSin); | |
2408 | } | |
2409 | else if (track10->fChi2MIP[0]<th1){ | |
2410 | track10->fChi2MIP[5] = maxconflicts; | |
2411 | track10->fChi2MIP[6] = maxchi2; | |
2412 | // track10->UpdateESDtrack(AliESDtrack::kITSin); | |
2413 | UpdateESDtrack(track10,AliESDtrack::kITSin); | |
2414 | } | |
2415 | ||
2416 | for (Int_t itrack=0;itrack<entries1;itrack++){ | |
15dd636f | 2417 | AliITStrackMI * track=(AliITStrackMI*) arr1->UncheckedAt(itrack); |
e43c066c | 2418 | UnRegisterClusterTracks(track,trackID1); |
2419 | } | |
2420 | // | |
2421 | for (Int_t itrack=0;itrack<entries2;itrack++){ | |
15dd636f | 2422 | AliITStrackMI * track=(AliITStrackMI*) arr2->UncheckedAt(itrack); |
e43c066c | 2423 | UnRegisterClusterTracks(track,trackID2); |
2424 | } | |
2425 | ||
2426 | if (track10->fConstrain&&track10->fChi2MIP[0]<kMaxChi2PerCluster[0]&&track10->fChi2MIP[1]<kMaxChi2PerCluster[1] | |
2427 | &&track10->fChi2MIP[2]<kMaxChi2PerCluster[2]&&track10->fChi2MIP[3]<kMaxChi2PerCluster[3]){ | |
2428 | // if (track10->fChi2MIP[0]<kMaxChi2PerCluster[0]&&track10->fChi2MIP[1]<kMaxChi2PerCluster[1] | |
2429 | // &&track10->fChi2MIP[2]<kMaxChi2PerCluster[2]&&track10->fChi2MIP[3]<kMaxChi2PerCluster[3]){ | |
2430 | RegisterClusterTracks(track10,trackID1); | |
2431 | } | |
2432 | if (track20->fConstrain&&track20->fChi2MIP[0]<kMaxChi2PerCluster[0]&&track20->fChi2MIP[1]<kMaxChi2PerCluster[1] | |
2433 | &&track20->fChi2MIP[2]<kMaxChi2PerCluster[2]&&track20->fChi2MIP[3]<kMaxChi2PerCluster[3]){ | |
2434 | //if (track20->fChi2MIP[0]<kMaxChi2PerCluster[0]&&track20->fChi2MIP[1]<kMaxChi2PerCluster[1] | |
2435 | // &&track20->fChi2MIP[2]<kMaxChi2PerCluster[2]&&track20->fChi2MIP[3]<kMaxChi2PerCluster[3]){ | |
2436 | RegisterClusterTracks(track20,trackID2); | |
2437 | } | |
2438 | return track10; | |
2439 | ||
2440 | } | |
2441 | ||
2442 | void AliITStrackerMI::UseClusters(const AliKalmanTrack *t, Int_t from) const { | |
2443 | //-------------------------------------------------------------------- | |
2444 | // This function marks clusters assigned to the track | |
2445 | //-------------------------------------------------------------------- | |
2446 | AliTracker::UseClusters(t,from); | |
2447 | ||
00a7cc50 | 2448 | AliITSRecPoint *c=(AliITSRecPoint *)GetCluster(t->GetClusterIndex(0)); |
e43c066c | 2449 | //if (c->GetQ()>2) c->Use(); |
2450 | if (c->GetSigmaZ2()>0.1) c->Use(); | |
00a7cc50 | 2451 | c=(AliITSRecPoint *)GetCluster(t->GetClusterIndex(1)); |
e43c066c | 2452 | //if (c->GetQ()>2) c->Use(); |
2453 | if (c->GetSigmaZ2()>0.1) c->Use(); | |
2454 | ||
2455 | } | |
2456 | ||
2457 | ||
15dd636f | 2458 | void AliITStrackerMI::AddTrackHypothesys(AliITStrackMI * track, Int_t esdindex) |
e43c066c | 2459 | { |
2460 | //------------------------------------------------------------------ | |
2461 | // add track to the list of hypothesys | |
2462 | //------------------------------------------------------------------ | |
2463 | ||
2464 | if (esdindex>=fTrackHypothesys.GetEntriesFast()) fTrackHypothesys.Expand(esdindex*2+10); | |
2465 | // | |
2466 | TObjArray * array = (TObjArray*) fTrackHypothesys.At(esdindex); | |
2467 | if (!array) { | |
2468 | array = new TObjArray(10); | |
2469 | fTrackHypothesys.AddAt(array,esdindex); | |
2470 | } | |
2471 | array->AddLast(track); | |
2472 | } | |
2473 | ||
2474 | void AliITStrackerMI::SortTrackHypothesys(Int_t esdindex, Int_t maxcut, Int_t mode) | |
2475 | { | |
2476 | //------------------------------------------------------------------- | |
2477 | // compress array of track hypothesys | |
2478 | // keep only maxsize best hypothesys | |
2479 | //------------------------------------------------------------------- | |
2480 | if (esdindex>fTrackHypothesys.GetEntriesFast()) return; | |
2481 | if (! (fTrackHypothesys.At(esdindex)) ) return; | |
2482 | TObjArray * array = (TObjArray*) fTrackHypothesys.At(esdindex); | |
2483 | Int_t entries = array->GetEntriesFast(); | |
2484 | // | |
2485 | //- find preliminary besttrack as a reference | |
2486 | Float_t minchi2=10000; | |
2487 | Int_t maxn=0; | |
15dd636f | 2488 | AliITStrackMI * besttrack=0; |
e43c066c | 2489 | for (Int_t itrack=0;itrack<array->GetEntriesFast();itrack++){ |
15dd636f | 2490 | AliITStrackMI * track = (AliITStrackMI*)array->At(itrack); |
e43c066c | 2491 | if (!track) continue; |
2492 | Float_t chi2 = NormalizedChi2(track,0); | |
2493 | // | |
2494 | Int_t tpcLabel=track->fESDtrack->GetTPCLabel(); | |
2495 | track->SetLabel(tpcLabel); | |
2496 | CookdEdx(track); | |
2497 | track->fFakeRatio=1.; | |
2498 | CookLabel(track,0.); //For comparison only | |
2499 | // | |
2500 | //if (chi2<kMaxChi2PerCluster[0]&&track->fFakeRatio==0){ | |
2501 | if (chi2<kMaxChi2PerCluster[0]){ | |
2502 | if (track->GetNumberOfClusters()<maxn) continue; | |
2503 | maxn = track->GetNumberOfClusters(); | |
2504 | if (chi2<minchi2){ | |
2505 | minchi2=chi2; | |
2506 | besttrack=track; | |
2507 | } | |
2508 | } | |
2509 | else{ | |
628e7bb0 | 2510 | if (track->fConstrain || track->fN>5){ //keep best short tracks - without vertex constrain |
2511 | delete array->RemoveAt(itrack); | |
2512 | } | |
e43c066c | 2513 | } |
2514 | } | |
2515 | if (!besttrack) return; | |
2516 | // | |
2517 | // | |
2518 | //take errors of best track as a reference | |
2519 | Float_t *erry = GetErrY(esdindex), *errz = GetErrZ(esdindex); | |
2520 | Float_t *ny = GetNy(esdindex), *nz = GetNz(esdindex); | |
2521 | for (Int_t i=0;i<6;i++) { | |
2522 | if (besttrack->fClIndex[i]>0){ | |
2523 | erry[i] = besttrack->fSigmaY[i]; erry[i+6] = besttrack->fSigmaY[i+6]; | |
2524 | errz[i] = besttrack->fSigmaZ[i]; errz[i+6] = besttrack->fSigmaZ[i+6]; | |
2525 | ny[i] = besttrack->fNy[i]; | |
2526 | nz[i] = besttrack->fNz[i]; | |
2527 | } | |
2528 | } | |
2529 | // | |
2530 | // calculate normalized chi2 | |
2531 | // | |
2532 | Float_t * chi2 = new Float_t[entries]; | |
2533 | Int_t * index = new Int_t[entries]; | |
2534 | for (Int_t i=0;i<entries;i++) chi2[i] =10000; | |
2535 | for (Int_t itrack=0;itrack<entries;itrack++){ | |
15dd636f | 2536 | AliITStrackMI * track = (AliITStrackMI*)array->At(itrack); |
e43c066c | 2537 | if (track){ |
2538 | track->fChi2MIP[0] = GetNormalizedChi2(track, mode); | |
2539 | if (track->fChi2MIP[0]<kMaxChi2PerCluster[0]) | |
2540 | chi2[itrack] = track->fChi2MIP[0]; | |
628e7bb0 | 2541 | else{ |
2542 | if (track->fConstrain || track->fN>5){ //keep best short tracks - without vertex constrain | |
2543 | delete array->RemoveAt(itrack); | |
2544 | } | |
2545 | } | |
e43c066c | 2546 | } |
2547 | } | |
2548 | // | |
2549 | TMath::Sort(entries,chi2,index,kFALSE); | |
15dd636f | 2550 | besttrack = (AliITStrackMI*)array->At(index[0]); |
e43c066c | 2551 | if (besttrack&&besttrack->fChi2MIP[0]<kMaxChi2PerCluster[0]){ |
2552 | for (Int_t i=0;i<6;i++){ | |
2553 | if (besttrack->fClIndex[i]>0){ | |
2554 | erry[i] = besttrack->fSigmaY[i]; erry[i+6] = besttrack->fSigmaY[i+6]; | |
2555 | errz[i] = besttrack->fSigmaZ[i]; erry[i+6] = besttrack->fSigmaY[i+6]; | |
2556 | ny[i] = besttrack->fNy[i]; | |
2557 | nz[i] = besttrack->fNz[i]; | |
2558 | } | |
2559 | } | |
2560 | } | |
2561 | // | |
2562 | // calculate one more time with updated normalized errors | |
2563 | for (Int_t i=0;i<entries;i++) chi2[i] =10000; | |
2564 | for (Int_t itrack=0;itrack<entries;itrack++){ | |
15dd636f | 2565 | AliITStrackMI * track = (AliITStrackMI*)array->At(itrack); |
e43c066c | 2566 | if (track){ |
2567 | track->fChi2MIP[0] = GetNormalizedChi2(track,mode); | |
2568 | if (track->fChi2MIP[0]<kMaxChi2PerCluster[0]) | |
2569 | chi2[itrack] = track->fChi2MIP[0]-0*(track->GetNumberOfClusters()+track->fNDeadZone); | |
628e7bb0 | 2570 | else |
2571 | { | |
2572 | if (track->fConstrain || track->fN>5){ //keep best short tracks - without vertex constrain | |
2573 | delete array->RemoveAt(itrack); | |
2574 | } | |
2575 | } | |
e43c066c | 2576 | } |
2577 | } | |
2578 | entries = array->GetEntriesFast(); | |
2579 | // | |
628e7bb0 | 2580 | // |
e43c066c | 2581 | if (entries>0){ |
2582 | TObjArray * newarray = new TObjArray(); | |
2583 | TMath::Sort(entries,chi2,index,kFALSE); | |
15dd636f | 2584 | besttrack = (AliITStrackMI*)array->At(index[0]); |
e43c066c | 2585 | if (besttrack){ |
2586 | // | |
2587 | for (Int_t i=0;i<6;i++){ | |
2588 | if (besttrack->fNz[i]>0&&besttrack->fNy[i]>0){ | |
2589 | erry[i] = besttrack->fSigmaY[i]; erry[i+6] = besttrack->fSigmaY[i+6]; | |
2590 | errz[i] = besttrack->fSigmaZ[i]; errz[i+6] = besttrack->fSigmaZ[i+6]; | |
2591 | ny[i] = besttrack->fNy[i]; | |
2592 | nz[i] = besttrack->fNz[i]; | |
2593 | } | |
2594 | } | |
2595 | besttrack->fChi2MIP[0] = GetNormalizedChi2(besttrack,mode); | |
2596 | Float_t minchi2 = TMath::Min(besttrack->fChi2MIP[0]+5.+besttrack->fNUsed, double(kMaxChi2PerCluster[0])); | |
2597 | Float_t minn = besttrack->GetNumberOfClusters()-3; | |
2598 | Int_t accepted=0; | |
2599 | for (Int_t i=0;i<entries;i++){ | |
15dd636f | 2600 | AliITStrackMI * track = (AliITStrackMI*)array->At(index[i]); |
e43c066c | 2601 | if (!track) continue; |
2602 | if (accepted>maxcut) break; | |
2603 | track->fChi2MIP[0] = GetNormalizedChi2(track,mode); | |
628e7bb0 | 2604 | if (track->fConstrain || track->fN>5){ //keep best short tracks - without vertex constrain |
2605 | if (track->GetNumberOfClusters()<6 && (track->fChi2MIP[0]+track->fNUsed>minchi2)){ | |
2606 | delete array->RemoveAt(index[i]); | |
2607 | continue; | |
2608 | } | |
e43c066c | 2609 | } |
628e7bb0 | 2610 | Bool_t shortbest = !track->fConstrain && track->fN<6; |
2611 | if ((track->fChi2MIP[0]+track->fNUsed<minchi2 && track->GetNumberOfClusters()>=minn) ||shortbest){ | |
2612 | if (!shortbest) accepted++; | |
e43c066c | 2613 | // |
2614 | newarray->AddLast(array->RemoveAt(index[i])); | |
2615 | for (Int_t i=0;i<6;i++){ | |
2616 | if (nz[i]==0){ | |
2617 | erry[i] = track->fSigmaY[i]; erry[i+6] = track->fSigmaY[i+6]; | |
2618 | errz[i] = track->fSigmaZ[i]; errz[i] = track->fSigmaZ[i+6]; | |
2619 | ny[i] = track->fNy[i]; | |
2620 | nz[i] = track->fNz[i]; | |
2621 | } | |
2622 | } | |
2623 | } | |
2624 | else{ | |
2625 | delete array->RemoveAt(index[i]); | |
2626 | } | |
2627 | } | |
2628 | array->Delete(); | |
2629 | delete fTrackHypothesys.RemoveAt(esdindex); | |
2630 | fTrackHypothesys.AddAt(newarray,esdindex); | |
2631 | } | |
2632 | else{ | |
2633 | array->Delete(); | |
2634 | delete fTrackHypothesys.RemoveAt(esdindex); | |
2635 | } | |
2636 | } | |
2637 | delete [] chi2; | |
2638 | delete [] index; | |
2639 | } | |
2640 | ||
2641 | ||
2642 | ||
15dd636f | 2643 | AliITStrackMI * AliITStrackerMI::GetBestHypothesys(Int_t esdindex, AliITStrackMI * original, Int_t checkmax) |
e43c066c | 2644 | { |
2645 | //------------------------------------------------------------- | |
2646 | // try to find best hypothesy | |
2647 | // currently - minimal chi2 of track+backpropagated track+matching to the tpc track | |
2648 | //------------------------------------------------------------- | |
2649 | if (fTrackHypothesys.GetEntriesFast()<=esdindex) return 0; | |
2650 | TObjArray * array = (TObjArray*) fTrackHypothesys.At(esdindex); | |
2651 | if (!array) return 0; | |
2652 | Int_t entries = array->GetEntriesFast(); | |
2653 | if (!entries) return 0; | |
2654 | Float_t minchi2 = 100000; | |
15dd636f | 2655 | AliITStrackMI * besttrack=0; |
e43c066c | 2656 | // |
15dd636f | 2657 | AliITStrackMI * backtrack = new AliITStrackMI(*original); |
2658 | AliITStrackMI * forwardtrack = new AliITStrackMI(*original); | |
628e7bb0 | 2659 | Double_t xyzv[]={GetX(),GetY(),GetZ()}; |
2660 | Double_t ersv[]={GetSigmaX()/3.,GetSigmaY()/3.,GetSigmaZ()/3.}; | |
e43c066c | 2661 | // |
2662 | for (Int_t i=0;i<entries;i++){ | |
15dd636f | 2663 | AliITStrackMI * track = (AliITStrackMI*)array->At(i); |
e43c066c | 2664 | if (!track) continue; |
628e7bb0 | 2665 | Float_t sigmarfi,sigmaz; |
2666 | GetDCASigma(track,sigmarfi,sigmaz); | |
2667 | track->fDnorm[0] = sigmarfi; | |
2668 | track->fDnorm[1] = sigmaz; | |
2669 | // | |
e43c066c | 2670 | track->fChi2MIP[1] = 1000000; |
2671 | track->fChi2MIP[2] = 1000000; | |
2672 | track->fChi2MIP[3] = 1000000; | |
2673 | // | |
2674 | // backtrack | |
15dd636f | 2675 | backtrack = new(backtrack) AliITStrackMI(*track); |
628e7bb0 | 2676 | if (track->fConstrain){ |
2677 | if (!backtrack->PropagateTo(3.,0.0028,65.19)) continue; | |
2678 | if (!backtrack->Improve(0,xyzv,ersv)) continue; | |
2679 | if (!backtrack->PropagateTo(2.,0.0028,0)) continue; | |
2680 | if (!backtrack->Improve(0,xyzv,ersv)) continue; | |
2681 | if (!backtrack->PropagateTo(1.,0.0028,0)) continue; | |
2682 | if (!backtrack->Improve(0,xyzv,ersv)) continue; | |
2683 | if (!backtrack->PropagateToVertex()) continue; | |
2684 | backtrack->ResetCovariance(); | |
81e97e0d | 2685 | if (!backtrack->Improve(0,xyzv,ersv)) continue; |
628e7bb0 | 2686 | }else{ |
2687 | backtrack->ResetCovariance(); | |
2688 | } | |
e43c066c | 2689 | backtrack->ResetClusters(); |
628e7bb0 | 2690 | |
e43c066c | 2691 | Double_t x = original->GetX(); |
2692 | if (!RefitAt(x,backtrack,track)) continue; | |
628e7bb0 | 2693 | // |
e43c066c | 2694 | track->fChi2MIP[1] = NormalizedChi2(backtrack,0); |
2695 | //for (Int_t i=2;i<6;i++){track->fDy[i]+=backtrack->fDy[i]; track->fDz[i]+=backtrack->fDz[i];} | |
2696 | if (track->fChi2MIP[1]>kMaxChi2PerCluster[1]*6.) continue; | |
2697 | track->fChi22 = GetMatchingChi2(backtrack,original); | |
2698 | ||
2699 | if ((track->fConstrain) && track->fChi22>90.) continue; | |
2700 | if ((!track->fConstrain) && track->fChi22>30.) continue; | |
2701 | if ( track->fChi22/track->GetNumberOfClusters()>11.) continue; | |
2702 | ||
2703 | ||
2704 | if (!(track->fConstrain)&&track->fChi2MIP[1]>kMaxChi2PerCluster[1]) continue; | |
2705 | Bool_t isOK=kTRUE; | |
e43c066c | 2706 | if(!isOK) continue; |
2707 | // | |
2708 | //forward track - without constraint | |
15dd636f | 2709 | forwardtrack = new(forwardtrack) AliITStrackMI(*original); |
e43c066c | 2710 | forwardtrack->ResetClusters(); |
2711 | x = track->GetX(); | |
628e7bb0 | 2712 | RefitAt(x,forwardtrack,track); |
e43c066c | 2713 | track->fChi2MIP[2] = NormalizedChi2(forwardtrack,0); |
2714 | if (track->fChi2MIP[2]>kMaxChi2PerCluster[2]*6.0) continue; | |
2715 | if (!(track->fConstrain)&&track->fChi2MIP[2]>kMaxChi2PerCluster[2]) continue; | |
2716 | ||
2717 | track->fD[0] = forwardtrack->GetD(GetX(),GetY()); | |
2718 | track->fD[1] = forwardtrack->GetZat(GetX())-GetZ(); | |
2719 | forwardtrack->fD[0] = track->fD[0]; | |
2720 | forwardtrack->fD[1] = track->fD[1]; | |
2721 | { | |
2722 | Int_t list[6]; | |
00a7cc50 | 2723 | AliITSRecPoint* clist[6]; |
e43c066c | 2724 | track->fChi2MIP[4] = GetNumberOfSharedClusters(track,esdindex,list,clist); |
2725 | if ( (!track->fConstrain) && track->fChi2MIP[4]>1.0) continue; | |
2726 | } | |
2727 | ||
2728 | track->fChi2MIP[3] = GetInterpolatedChi2(forwardtrack,backtrack); | |
2729 | if ( (track->fChi2MIP[3]>6.*kMaxChi2PerCluster[3])) continue; | |
2730 | if ( (!track->fConstrain) && (track->fChi2MIP[3]>2*kMaxChi2PerCluster[3])) { | |
2731 | track->fChi2MIP[3]=1000; | |
2732 | continue; | |
2733 | } | |
2734 | Double_t chi2 = track->fChi2MIP[0]+track->fNUsed; | |
2735 | // | |
2736 | for (Int_t ichi=0;ichi<5;ichi++){ | |
2737 | forwardtrack->fChi2MIP[ichi] = track->fChi2MIP[ichi]; | |
2738 | } | |
2739 | if (chi2 < minchi2){ | |
15dd636f | 2740 | //besttrack = new AliITStrackMI(*forwardtrack); |
99c2ee26 | 2741 | besttrack = track; |
e43c066c | 2742 | besttrack->SetLabel(track->GetLabel()); |
2743 | besttrack->fFakeRatio = track->fFakeRatio; | |
2744 | minchi2 = chi2; | |
2745 | original->fD[0] = forwardtrack->GetD(GetX(),GetY()); | |
2746 | original->fD[1] = forwardtrack->GetZat(GetX())-GetZ(); | |
2747 | } | |
2748 | } | |
2749 | delete backtrack; | |
2750 | delete forwardtrack; | |
2751 | Int_t accepted=0; | |
2752 | for (Int_t i=0;i<entries;i++){ | |
15dd636f | 2753 | AliITStrackMI * track = (AliITStrackMI*)array->At(i); |
e43c066c | 2754 | if (!track) continue; |
628e7bb0 | 2755 | |
e43c066c | 2756 | if (accepted>checkmax || track->fChi2MIP[3]>kMaxChi2PerCluster[3]*6. || |
2757 | (track->GetNumberOfClusters()<besttrack->GetNumberOfClusters()-1.)|| | |
2758 | track->fChi2MIP[0]>besttrack->fChi2MIP[0]+2.*besttrack->fNUsed+3.){ | |
628e7bb0 | 2759 | if (track->fConstrain || track->fN>5){ //keep best short tracks - without vertex constrain |
2760 | delete array->RemoveAt(i); | |
2761 | continue; | |
2762 | } | |
e43c066c | 2763 | } |
2764 | else{ | |
2765 | accepted++; | |
2766 | } | |
2767 | } | |
2768 | // | |
2769 | array->Compress(); | |
2770 | SortTrackHypothesys(esdindex,checkmax,1); | |
2771 | array = (TObjArray*) fTrackHypothesys.At(esdindex); | |
afdf9b9c | 2772 | if (!array) return 0; // PH What can be the reason? Check SortTrackHypothesys |
15dd636f | 2773 | besttrack = (AliITStrackMI*)array->At(0); |
e43c066c | 2774 | if (!besttrack) return 0; |
2775 | besttrack->fChi2MIP[8]=0; | |
2776 | fBestTrackIndex[esdindex]=0; | |
2777 | entries = array->GetEntriesFast(); | |
15dd636f | 2778 | AliITStrackMI *longtrack =0; |
e43c066c | 2779 | minchi2 =1000; |
2780 | Float_t minn=besttrack->GetNumberOfClusters()+besttrack->fNDeadZone; | |
2781 | for (Int_t itrack=entries-1;itrack>0;itrack--){ | |
15dd636f | 2782 | AliITStrackMI * track = (AliITStrackMI*)array->At(itrack); |
e43c066c | 2783 | if (!track->fConstrain) continue; |
2784 | if (track->GetNumberOfClusters()+track->fNDeadZone<minn) continue; | |
2785 | if (track->fChi2MIP[0]-besttrack->fChi2MIP[0]>0.0) continue; | |
2786 | if (track->fChi2MIP[0]>4.) continue; | |
2787 | minn = track->GetNumberOfClusters()+track->fNDeadZone; | |
2788 | longtrack =track; | |
2789 | } | |
2790 | //if (longtrack) besttrack=longtrack; | |
2791 | ||
2792 | Int_t list[6]; | |
00a7cc50 | 2793 | AliITSRecPoint * clist[6]; |
e43c066c | 2794 | Float_t shared = GetNumberOfSharedClusters(besttrack,esdindex,list,clist); |
2795 | if (besttrack->fConstrain&&besttrack->fChi2MIP[0]<kMaxChi2PerCluster[0]&&besttrack->fChi2MIP[1]<kMaxChi2PerCluster[1] | |
2796 | &&besttrack->fChi2MIP[2]<kMaxChi2PerCluster[2]&&besttrack->fChi2MIP[3]<kMaxChi2PerCluster[3]){ | |
e43c066c | 2797 | RegisterClusterTracks(besttrack,esdindex); |
2798 | } | |
2799 | // | |
2800 | // | |
2801 | if (shared>0.0){ | |
2802 | Int_t nshared; | |
2803 | Int_t overlist[6]; | |
2804 | Int_t sharedtrack = GetOverlapTrack(besttrack, esdindex, nshared, list, overlist); | |
2805 | if (sharedtrack>=0){ | |
2806 | // | |
2807 | besttrack = GetBest2Tracks(esdindex,sharedtrack,10,5.5); | |
2808 | if (besttrack){ | |
2809 | shared = GetNumberOfSharedClusters(besttrack,esdindex,list,clist); | |
2810 | } | |
2811 | else return 0; | |
2812 | } | |
2813 | } | |
2814 | ||
2815 | if (shared>2.5) return 0; | |
2816 | if (shared>1.0) return besttrack; | |
2817 | // | |
628e7bb0 | 2818 | // Don't sign clusters if not gold track |
2819 | // | |
2820 | if (!besttrack->IsGoldPrimary()) return besttrack; | |
2821 | if (besttrack->fESDtrack->GetKinkIndex(0)!=0) return besttrack; //track belong to kink | |
2822 | // | |
e43c066c | 2823 | if (fConstraint[fPass]){ |
2824 | // | |
2825 | // sign clusters | |
2826 | // | |
2827 | Float_t *ny = GetNy(esdindex), *nz = GetNz(esdindex); | |
2828 | for (Int_t i=0;i<6;i++){ | |
2829 | Int_t index = besttrack->fClIndex[i]; | |
2830 | if (index<=0) continue; | |
2831 | Int_t ilayer = (index & 0xf0000000) >> 28; | |
2832 | if (besttrack->fSigmaY[ilayer]<0.00000000001) continue; | |
00a7cc50 | 2833 | AliITSRecPoint *c = (AliITSRecPoint*)GetCluster(index); |
e43c066c | 2834 | if (!c) continue; |
2835 | if (ilayer>3&&c->GetNy()+c->GetNz()>6) continue; | |
2836 | if ( (c->GetNy()+c->GetNz() )> ny[i]+nz[i]+0.7) continue; //shared track | |
2837 | if ( c->GetNz()> nz[i]+0.7) continue; //shared track | |
2838 | if ( ilayer>2&& besttrack->fNormQ[ilayer]/besttrack->fExpQ>1.5) continue; | |
2839 | //if ( c->GetNy()> ny[i]+0.7) continue; //shared track | |
2840 | ||
2841 | Bool_t cansign = kTRUE; | |
2842 | for (Int_t itrack=0;itrack<entries; itrack++){ | |
15dd636f | 2843 | AliITStrackMI * track = (AliITStrackMI*)array->At(i); |
e43c066c | 2844 | if (!track) continue; |
2845 | if (track->fChi2MIP[0]>besttrack->fChi2MIP[0]+2.*shared+1.) break; | |
2846 | if ( (track->fClIndex[ilayer]>0) && (track->fClIndex[ilayer]!=besttrack->fClIndex[ilayer])){ | |
2847 | cansign = kFALSE; | |
2848 | break; | |
2849 | } | |
2850 | } | |
2851 | if (cansign){ | |
2852 | if (TMath::Abs(besttrack->fDy[ilayer]/besttrack->fSigmaY[ilayer])>3.) continue; | |
2853 | if (TMath::Abs(besttrack->fDz[ilayer]/besttrack->fSigmaZ[ilayer])>3.) continue; | |
2854 | if (!c->IsUsed()) c->Use(); | |
2855 | } | |
2856 | } | |
2857 | } | |
2858 | return besttrack; | |
2859 | } | |
2860 | ||
2861 | ||
2862 | ||
2863 | void AliITStrackerMI::GetBestHypothesysMIP(TObjArray &itsTracks) | |
2864 | { | |
2865 | // | |
2866 | // get "best" hypothesys | |
628e7bb0 | 2867 | // |
e43c066c | 2868 | |
2869 | Int_t nentries = itsTracks.GetEntriesFast(); | |
2870 | for (Int_t i=0;i<nentries;i++){ | |
15dd636f | 2871 | AliITStrackMI* track = (AliITStrackMI*)itsTracks.At(i); |
e43c066c | 2872 | if (!track) continue; |
2873 | TObjArray * array = (TObjArray*) fTrackHypothesys.At(i); | |
2874 | if (!array) continue; | |
2875 | if (array->GetEntriesFast()<=0) continue; | |
2876 | // | |
15dd636f | 2877 | AliITStrackMI* longtrack=0; |
e43c066c | 2878 | Float_t minn=0; |
2879 | Float_t maxchi2=1000; | |
2880 | for (Int_t j=0;j<array->GetEntriesFast();j++){ | |
15dd636f | 2881 | AliITStrackMI* track = (AliITStrackMI*)array->At(j); |
e43c066c | 2882 | if (!track) continue; |
628e7bb0 | 2883 | if (track->fGoldV0) { |
2884 | longtrack = track; //gold V0 track taken | |
2885 | break; | |
2886 | } | |
e43c066c | 2887 | if (track->GetNumberOfClusters()+track->fNDeadZone<minn) continue; |
628e7bb0 | 2888 | Float_t chi2 = track->fChi2MIP[0]; |
2889 | if (fAfterV0){ | |
2890 | if (!track->fGoldV0&&track->fConstrain==kFALSE) chi2+=5; | |
2891 | } | |
2892 | if (track->GetNumberOfClusters()+track->fNDeadZone>minn) maxchi2 = track->fChi2MIP[0]; | |
2893 | // | |
2894 | if (chi2 > maxchi2) continue; | |
e43c066c | 2895 | minn= track->GetNumberOfClusters()+track->fNDeadZone; |
628e7bb0 | 2896 | maxchi2 = chi2; |
e43c066c | 2897 | longtrack=track; |
e43c066c | 2898 | } |
628e7bb0 | 2899 | // |
2900 | // | |
2901 | // | |
15dd636f | 2902 | AliITStrackMI * besttrack = (AliITStrackMI*)array->At(0); |
e43c066c | 2903 | if (!longtrack) {longtrack = besttrack;} |
2904 | else besttrack= longtrack; | |
628e7bb0 | 2905 | // |
e43c066c | 2906 | if (besttrack){ |
2907 | Int_t list[6]; | |
00a7cc50 | 2908 | AliITSRecPoint * clist[6]; |
e43c066c | 2909 | Float_t shared = GetNumberOfSharedClusters(longtrack,i,list,clist); |
2910 | // | |
2911 | track->fNUsed = shared; | |
2912 | track->fNSkipped = besttrack->fNSkipped; | |
2913 | track->fChi2MIP[0] = besttrack->fChi2MIP[0]; | |
2914 | if (shared>0){ | |
2915 | Int_t nshared; | |
2916 | Int_t overlist[6]; | |
2917 | // | |
2918 | Int_t sharedtrack = GetOverlapTrack(longtrack, i, nshared, list, overlist); | |
2919 | //if (sharedtrack==-1) sharedtrack=0; | |
2920 | if (sharedtrack>=0){ | |
2921 | besttrack = GetBest2Tracks(i,sharedtrack,10,5.5); | |
2922 | } | |
2923 | } | |
628e7bb0 | 2924 | if (besttrack&&fAfterV0){ |
2925 | UpdateESDtrack(besttrack,AliESDtrack::kITSin); | |
2926 | } | |
e43c066c | 2927 | if (besttrack&&fConstraint[fPass]) |
2928 | UpdateESDtrack(besttrack,AliESDtrack::kITSin); | |
2929 | //if (besttrack&&besttrack->fConstrain) | |
2930 | // UpdateESDtrack(besttrack,AliESDtrack::kITSin); | |
2931 | if (besttrack->fChi2MIP[0]+besttrack->fNUsed>1.5){ | |
2932 | if ( (TMath::Abs(besttrack->fD[0])>0.1) && fConstraint[fPass]) { | |
2933 | track->fReconstructed= kFALSE; | |
2934 | } | |
2935 | if ( (TMath::Abs(besttrack->fD[1])>0.1) && fConstraint[fPass]){ | |
2936 | track->fReconstructed= kFALSE; | |
2937 | } | |
2938 | } | |
2939 | ||
2940 | } | |
2941 | } | |
2942 | } | |
2943 | ||
2944 | ||
15dd636f | 2945 | void AliITStrackerMI::CookLabel(AliITStrackMI *track,Float_t wrong) const { |
e43c066c | 2946 | //-------------------------------------------------------------------- |
2947 | //This function "cooks" a track label. If label<0, this track is fake. | |
2948 | //-------------------------------------------------------------------- | |
2949 | Int_t tpcLabel=-1; | |
2950 | ||
2951 | if ( track->fESDtrack) tpcLabel = TMath::Abs(track->fESDtrack->GetTPCLabel()); | |
2952 | ||
2953 | track->fChi2MIP[9]=0; | |
2954 | Int_t nwrong=0; | |
2955 | for (Int_t i=0;i<track->GetNumberOfClusters();i++){ | |
2956 | Int_t cindex = track->GetClusterIndex(i); | |
2957 | Int_t l=(cindex & 0xf0000000) >> 28; | |
00a7cc50 | 2958 | AliITSRecPoint *cl = (AliITSRecPoint*)GetCluster(cindex); |
e43c066c | 2959 | Int_t isWrong=1; |
2960 | for (Int_t ind=0;ind<3;ind++){ | |
2961 | if (tpcLabel>0) | |
2962 | if (cl->GetLabel(ind)==tpcLabel) isWrong=0; | |
2963 | } | |
2964 | track->fChi2MIP[9]+=isWrong*(2<<l); | |
2965 | nwrong+=isWrong; | |
2966 | } | |
2967 | track->fFakeRatio = double(nwrong)/double(track->GetNumberOfClusters()); | |
2968 | if (tpcLabel>0){ | |
2969 | if (track->fFakeRatio>wrong) track->fLab = -tpcLabel; | |
2970 | else | |
2971 | track->fLab = tpcLabel; | |
2972 | } | |
2973 | ||
2974 | } | |
2975 | ||
2976 | ||
2977 | ||
15dd636f | 2978 | void AliITStrackerMI::CookdEdx(AliITStrackMI* track) |
e43c066c | 2979 | { |
2980 | // | |
2981 | // | |
2982 | // Int_t list[6]; | |
00a7cc50 | 2983 | //AliITSRecPoint * clist[6]; |
e43c066c | 2984 | // Int_t shared = GetNumberOfSharedClusters(track,index,list,clist); |
2985 | Float_t dedx[4]; | |
2986 | Int_t accepted=0; | |
2987 | track->fChi2MIP[9]=0; | |
2988 | for (Int_t i=0;i<track->GetNumberOfClusters();i++){ | |
2989 | Int_t cindex = track->GetClusterIndex(i); | |
2990 | Int_t l=(cindex & 0xf0000000) >> 28; | |
00a7cc50 | 2991 | AliITSRecPoint *cl = (AliITSRecPoint*)GetCluster(cindex); |
e43c066c | 2992 | Int_t lab = TMath::Abs(track->fESDtrack->GetTPCLabel()); |
2993 | Int_t isWrong=1; | |
2994 | for (Int_t ind=0;ind<3;ind++){ | |
2995 | if (cl->GetLabel(ind)==lab) isWrong=0; | |
2996 | } | |
2997 | track->fChi2MIP[9]+=isWrong*(2<<l); | |
2998 | if (l<2) continue; | |
2999 | //if (l>3 && (cl->GetNy()>4) || (cl->GetNz()>4)) continue; //shared track | |
3000 | //if (l>3&& !(cl->GetType()==1||cl->GetType()==10)) continue; | |
3001 | //if (l<4&& !(cl->GetType()==1)) continue; | |
3002 | dedx[accepted]= track->fdEdxSample[i]; | |
3003 | //dedx[accepted]= track->fNormQ[l]; | |
3004 | accepted++; | |
3005 | } | |
3006 | if (accepted<1) { | |
3007 | track->SetdEdx(0); | |
3008 | return; | |
3009 | } | |
3010 | Int_t indexes[4]; | |
3011 | TMath::Sort(accepted,dedx,indexes,kFALSE); | |
3012 | Double_t low=0.; | |
3013 | Double_t up=0.51; | |
3014 | Double_t nl=low*accepted, nu =up*accepted; | |
3015 | Float_t sumamp = 0; | |
3016 | Float_t sumweight =0; | |
3017 | for (Int_t i=0; i<accepted; i++) { | |
3018 | Float_t weight =1; | |
3019 | if (i<nl+0.1) weight = TMath::Max(1.-(nl-i),0.); | |
3020 | if (i>nu-1) weight = TMath::Max(nu-i,0.); | |
3021 | sumamp+= dedx[indexes[i]]*weight; | |
3022 | sumweight+=weight; | |
3023 | } | |
3024 | track->SetdEdx(sumamp/sumweight); | |
3025 | } | |
3026 | ||
3027 | ||
3028 | void AliITStrackerMI::MakeCoeficients(Int_t ntracks){ | |
3029 | // | |
3030 | // | |
628e7bb0 | 3031 | if (fCoeficients) delete []fCoeficients; |
e43c066c | 3032 | fCoeficients = new Float_t[ntracks*48]; |
3033 | for (Int_t i=0;i<ntracks*48;i++) fCoeficients[i]=-1.; | |
3034 | } | |
3035 | ||
3036 | ||
00a7cc50 | 3037 | Double_t AliITStrackerMI::GetPredictedChi2MI(AliITStrackMI* track, const AliITSRecPoint *cluster,Int_t layer) |
e43c066c | 3038 | { |
3039 | // | |
3040 | // | |
3041 | // | |
3042 | Float_t erry,errz; | |
3043 | Float_t theta = track->GetTgl(); | |
3044 | Float_t phi = track->GetSnp(); | |
3045 | phi = TMath::Sqrt(phi*phi/(1.-phi*phi)); | |
3046 | GetError(layer,cluster,theta,phi,track->fExpQ,erry,errz); | |
3047 | Double_t chi2 = track->GetPredictedChi2MI(cluster->GetY(),cluster->GetZ(),erry,errz); | |
3048 | Float_t ny,nz; | |
3049 | GetNTeor(layer,cluster, theta,phi,ny,nz); | |
3050 | Double_t delta = cluster->GetNy()+cluster->GetNz()-nz-ny; | |
3051 | if (delta>1){ | |
3052 | chi2+=0.5*TMath::Min(delta/2,2.); | |
3053 | chi2+=2.*cluster->GetDeltaProbability(); | |
3054 | } | |
3055 | // | |
3056 | track->fNy[layer] =ny; | |
3057 | track->fNz[layer] =nz; | |
3058 | track->fSigmaY[layer] = erry; | |
3059 | track->fSigmaZ[layer] = errz; | |
3060 | //track->fNormQ[layer] = cluster->GetQ()/TMath::Sqrt(1+theta*theta+phi*phi); | |
3061 | track->fNormQ[layer] = cluster->GetQ()/TMath::Sqrt((1.+ track->fP3*track->fP3)/(1.- track->fP2*track->fP2)); | |
3062 | return chi2; | |
3063 | ||
3064 | } | |
3065 | ||
00a7cc50 | 3066 | Int_t AliITStrackerMI::UpdateMI(AliITStrackMI* track, const AliITSRecPoint* cl,Double_t chi2,Int_t index) const |
e43c066c | 3067 | { |
3068 | // | |
3069 | // | |
3070 | // | |
3071 | Int_t layer = (index & 0xf0000000) >> 28; | |
3072 | track->fClIndex[layer] = index; | |
3073 | if ( (layer>1) &&track->fNormQ[layer]/track->fExpQ<0.5 ) { | |
3074 | chi2+= (0.5-track->fNormQ[layer]/track->fExpQ)*10.; | |
3075 | track->fdEdxMismatch+=(0.5-track->fNormQ[layer]/track->fExpQ)*10.; | |
3076 | } | |
3077 | return track->UpdateMI(cl->GetY(),cl->GetZ(),track->fSigmaY[layer],track->fSigmaZ[layer],chi2,index); | |
3078 | } | |
3079 | ||
00a7cc50 | 3080 | void AliITStrackerMI::GetNTeor(Int_t layer, const AliITSRecPoint* /*cl*/, Float_t theta, Float_t phi, Float_t &ny, Float_t &nz) |
e43c066c | 3081 | { |
3082 | // | |
3083 | //get "mean shape" | |
3084 | // | |
3085 | if (layer==0){ | |
3086 | ny = 1.+TMath::Abs(phi)*3.2; | |
3087 | nz = 1.+TMath::Abs(theta)*0.34; | |
3088 | return; | |
3089 | } | |
3090 | if (layer==1){ | |
3091 | ny = 1.+TMath::Abs(phi)*3.2; | |
3092 | nz = 1.+TMath::Abs(theta)*0.28; | |
3093 | return; | |
3094 | } | |
3095 | ||
3096 | if (layer>3){ | |
3097 | ny = 2.02+TMath::Abs(phi)*1.95; | |
3098 | nz = 2.02+TMath::Abs(phi)*2.35; | |
3099 | return; | |
3100 | } | |
4c53440c | 3101 | ny = 6.6-2.7*TMath::Abs(phi); |
e43c066c | 3102 | nz = 2.8-3.11*TMath::Abs(phi)+0.45*TMath::Abs(theta); |
3103 | } | |
3104 | ||
3105 | ||
3106 | ||
00a7cc50 | 3107 | Int_t AliITStrackerMI::GetError(Int_t layer, const AliITSRecPoint*cl, Float_t theta, Float_t phi,Float_t expQ, Float_t &erry, Float_t &errz) |
e43c066c | 3108 | { |
3109 | //calculate cluster position error | |
3110 | // | |
3111 | Float_t nz,ny; | |
3112 | GetNTeor(layer, cl,theta,phi,ny,nz); | |
3113 | erry = TMath::Sqrt(cl->GetSigmaY2()); | |
3114 | errz = TMath::Sqrt(cl->GetSigmaZ2()); | |
3115 | // | |
3116 | // PIXELS | |
3117 | if (layer<2){ | |
3118 | ||
3119 | if (TMath::Abs(ny-cl->GetNy())>0.6) { | |
3120 | if (ny<cl->GetNy()){ | |
3121 | erry*=0.4+TMath::Abs(ny-cl->GetNy()); | |
3122 | errz*=0.4+TMath::Abs(ny-cl->GetNy()); | |
3123 | }else{ | |
3124 | erry*=0.7+0.5*TMath::Abs(ny-cl->GetNy()); | |
3125 | errz*=0.7+0.5*TMath::Abs(ny-cl->GetNy()); | |
3126 | } | |
3127 | } | |
3128 | if (TMath::Abs(nz-cl->GetNz())>1.) { | |
3129 | erry*=TMath::Abs(nz-cl->GetNz()); | |
3130 | errz*=TMath::Abs(nz-cl->GetNz()); | |
3131 | } | |
3132 | erry*=0.85; | |
3133 | errz*=0.85; | |
3134 | erry= TMath::Min(erry,float(0.005)); | |
3135 | errz= TMath::Min(errz,float(0.03)); | |
3136 | return 10; | |
3137 | } | |
3138 | ||
3139 | //STRIPS | |
3140 | if (layer>3){ | |
1d4090b7 | 3141 | //factor 1.8 appears in new simulation |
3142 | // | |
3143 | Float_t scale=1.8; | |
e43c066c | 3144 | if (cl->GetNy()==100||cl->GetNz()==100){ |
1d4090b7 | 3145 | erry = 0.004*scale; |
3146 | errz = 0.2*scale; | |
e43c066c | 3147 | return 100; |
3148 | } | |
3149 | if (cl->GetNy()+cl->GetNz()>12){ | |
1d4090b7 | 3150 | erry = 0.06*scale; |
3151 | errz = 0.57*scale; | |
e43c066c | 3152 | return 100; |
3153 | } | |
3154 | Float_t normq = cl->GetQ()/(TMath::Sqrt(1+theta*theta+phi*phi)); | |
3155 | Float_t chargematch = TMath::Max(double(normq/expQ),2.); | |
3156 | // | |
3157 | if (cl->GetType()==1 || cl->GetType()==10 ){ | |
3158 | if (chargematch<1.0 || (cl->GetNy()+cl->GetNz()<nz+ny+0.5)){ | |
1d4090b7 | 3159 | errz = 0.043*scale; |
3160 | erry = 0.00094*scale; | |
e43c066c | 3161 | return 101; |
3162 | } | |
3163 | if (cl->GetNy()+cl->GetNz()<nz+ny+1.2){ | |
1d4090b7 | 3164 | errz = 0.06*scale; |
3165 | erry =0.0013*scale; | |
e43c066c | 3166 | return 102; |
3167 | } | |
1d4090b7 | 3168 | erry = 0.0027*scale; |
3169 | errz = TMath::Min(0.028*(chargematch+cl->GetNy()+cl->GetNz()-nz+ny),0.15)*scale; | |
e43c066c | 3170 | return 103; |
3171 | } | |
3172 | if (cl->GetType()==2 || cl->GetType()==11 ){ | |
1d4090b7 | 3173 | erry = TMath::Min(0.0010*(1+chargematch+cl->GetNy()+cl->GetNz()-nz+ny),0.05)*scale; |
3174 | errz = TMath::Min(0.025*(1+chargematch+cl->GetNy()+cl->GetNz()-nz+ny),0.5)*scale; | |
e43c066c | 3175 | return 104; |
3176 | } | |
3177 | ||
3178 | if (cl->GetType()>100 ){ | |
3179 | if ((chargematch+cl->GetNy()+cl->GetNz()-nz-ny<1.5)){ | |
1d4090b7 | 3180 | errz = 0.05*scale; |
3181 | erry = 0.00096*scale; | |
e43c066c | 3182 | return 105; |
3183 | } | |
3184 | if (cl->GetNy()+cl->GetNz()-nz-ny<1){ | |
1d4090b7 | 3185 | errz = 0.10*scale; |
3186 | erry = 0.0025*scale; | |
e43c066c | 3187 | return 106; |
3188 | } | |
3189 | ||
1d4090b7 | 3190 | errz = TMath::Min(0.05*(chargematch+cl->GetNy()+cl->GetNz()-nz-ny),0.4)*scale; |
3191 | erry = TMath::Min(0.003*(chargematch+cl->GetNy()+cl->GetNz()-nz-ny),0.05)*scale; | |
e43c066c | 3192 | return 107; |
3193 | } | |
3194 | Float_t diff = cl->GetNy()+cl->GetNz()-ny-nz; | |
3195 | if (diff<1) diff=1; | |
3196 | if (diff>4) diff=4; | |
3197 | ||
3198 | if (cl->GetType()==5||cl->GetType()==6||cl->GetType()==7||cl->GetType()==8){ | |
3199 | errz = 0.14*diff; | |
3200 | erry = 0.003*diff; | |
3201 | return 108; | |
3202 | } | |
3203 | erry = 0.04*diff; | |
3204 | errz = 0.06*diff; | |
3205 | return 109; | |
3206 | } | |
3207 | //DRIFTS | |
3208 | Float_t normq = cl->GetQ()/(TMath::Sqrt(1+theta*theta+phi*phi)); | |
3209 | Float_t chargematch = normq/expQ; | |
3210 | Float_t factorz=1; | |
3211 | Int_t cnz = cl->GetNz()%10; | |
3212 | //charge match | |
3213 | if (cl->GetType()==1){ | |
3214 | if (chargematch<1.25){ | |
3215 | erry = 0.0028*(1.+6./cl->GetQ()); // gold clusters | |
3216 | } | |
3217 | else{ | |
3218 | erry = 0.003*chargematch; | |
3219 | if (cl->GetNz()==3) erry*=1.5; | |
3220 | } | |
3221 | if (chargematch<1.0){ | |
3222 | errz = 0.0011*(1.+6./cl->GetQ()); | |
3223 | } | |
3224 | else{ | |
3225 | errz = 0.002*(1+2*(chargematch-1.)); | |
3226 | } | |
3227 | if (cnz>nz+0.6) { | |
3228 | erry*=(cnz-nz+0.5); | |
3229 | errz*=1.4*(cnz-nz+0.5); | |
3230 | } | |
3231 | } | |
3232 | if (cl->GetType()>1){ | |
3233 | if (chargematch<1){ | |
3234 | erry = 0.00385*(1.+6./cl->GetQ()); // gold clusters | |
3235 | errz = 0.0016*(1.+6./cl->GetQ()); | |
3236 | } | |
3237 | else{ | |
3238 | errz = 0.0014*(1+3*(chargematch-1.)); | |
3239 | erry = 0.003*(1+3*(chargematch-1.)); | |
3240 | } | |
3241 | if (cnz>nz+0.6) { | |
3242 | erry*=(cnz-nz+0.5); | |
3243 | errz*=1.4*(cnz-nz+0.5); | |
3244 | } | |
3245 | } | |
3246 | ||
3247 | if (TMath::Abs(cl->GetY())>2.5){ | |
3248 | factorz*=1+2*(TMath::Abs(cl->GetY())-2.5); | |
3249 | } | |
3250 | if (TMath::Abs(cl->GetY())<1){ | |
3251 | factorz*=1.+0.5*TMath::Abs(TMath::Abs(cl->GetY())-1.); | |
3252 | } | |
3253 | factorz= TMath::Min(factorz,float(4.)); | |
3254 | errz*=factorz; | |
3255 | ||
3256 | erry= TMath::Min(erry,float(0.05)); | |
3257 | errz= TMath::Min(errz,float(0.05)); | |
3258 | return 200; | |
3259 | } | |
3260 | ||
3261 | ||
3262 | ||
628e7bb0 | 3263 | void AliITStrackerMI::GetDCASigma(AliITStrackMI* track, Float_t & sigmarfi, Float_t &sigmaz) |
3264 | { | |
3265 | // | |
3266 | //DCA sigmas parameterization | |
3267 | //to be paramterized using external parameters in future | |
3268 | // | |
3269 | // | |
3270 | sigmarfi = 0.004+1.4 *TMath::Abs(track->fP4)+332.*track->fP4*track->fP4; | |
3271 | sigmaz = 0.011+4.37*TMath::Abs(track->fP4); | |
628e7bb0 | 3272 | } |
3273 | ||
3274 | ||
e43c066c | 3275 | void AliITStrackerMI::SignDeltas( TObjArray *ClusterArray, Float_t vz) |
3276 | { | |
3277 | // | |
3278 | // | |
3279 | Int_t entries = ClusterArray->GetEntriesFast(); | |
3280 | if (entries<4) return; | |
00a7cc50 | 3281 | AliITSRecPoint* cluster = (AliITSRecPoint*)ClusterArray->At(0); |
e43c066c | 3282 | Int_t layer = cluster->GetLayer(); |
3283 | if (layer>1) return; | |
3284 | Int_t index[10000]; | |
3285 | Int_t ncandidates=0; | |
3286 | Float_t r = (layer>0)? 7:4; | |
3287 | // | |
3288 | for (Int_t i=0;i<entries;i++){ | |
00a7cc50 | 3289 | AliITSRecPoint* cl0 = (AliITSRecPoint*)ClusterArray->At(i); |
e43c066c | 3290 | Float_t nz = 1+TMath::Abs((cl0->GetZ()-vz)/r); |
3291 | if (cl0->GetNy()+cl0->GetNz()<=5+2*layer+nz) continue; | |
3292 | index[ncandidates] = i; //candidate to belong to delta electron track | |
3293 | ncandidates++; | |
3294 | if (cl0->GetNy()+cl0->GetNz()>9+2*layer+nz) { | |
3295 | cl0->SetDeltaProbability(1); | |
3296 | } | |
3297 | } | |
3298 | // | |
3299 | // | |
3300 | // | |
3301 | for (Int_t i=0;i<ncandidates;i++){ | |
00a7cc50 | 3302 | AliITSRecPoint* cl0 = (AliITSRecPoint*)ClusterArray->At(index[i]); |
e43c066c | 3303 | if (cl0->GetDeltaProbability()>0.8) continue; |
3304 | // | |
3305 | Int_t ncl = 0; | |
3306 | Float_t y[100],z[100],sumy,sumz,sumy2, sumyz, sumw; | |
3307 | sumy=sumz=sumy2=sumyz=sumw=0.0; | |
3308 | for (Int_t j=0;j<ncandidates;j++){ | |
3309 | if (i==j) continue; | |
00a7cc50 | 3310 | AliITSRecPoint* cl1 = (AliITSRecPoint*)ClusterArray->At(index[j]); |
e43c066c | 3311 | // |
3312 | Float_t dz = cl0->GetZ()-cl1->GetZ(); | |
3313 | Float_t dy = cl0->GetY()-cl1->GetY(); | |
3314 | if (TMath::Sqrt(dz*dz+dy*dy)<0.2){ | |
3315 | Float_t weight = cl1->GetNy()+cl1->GetNz()-2; | |
3316 | y[ncl] = cl1->GetY(); | |
3317 | z[ncl] = cl1->GetZ(); | |
3318 | sumy+= y[ncl]*weight; | |
3319 | sumz+= z[ncl]*weight; | |
3320 | sumy2+=y[ncl]*y[ncl]*weight; | |
3321 | sumyz+=y[ncl]*z[ncl]*weight; | |
3322 | sumw+=weight; | |
3323 | ncl++; | |
3324 | } | |
3325 | } | |
3326 | if (ncl<4) continue; | |
3327 | Float_t det = sumw*sumy2 - sumy*sumy; | |
3328 | Float_t delta=1000; | |
3329 | if (TMath::Abs(det)>0.01){ | |
3330 | Float_t z0 = (sumy2*sumz - sumy*sumyz)/det; | |
3331 | Float_t k = (sumyz*sumw - sumy*sumz)/det; | |
3332 | delta = TMath::Abs(cl0->GetZ()-(z0+k*cl0->GetY())); | |
3333 | } | |
3334 | else{ | |
3335 | Float_t z0 = sumyz/sumy; | |
3336 | delta = TMath::Abs(cl0->GetZ()-z0); | |
3337 | } | |
3338 | if ( delta<0.05) { | |
3339 | cl0->SetDeltaProbability(1-20.*delta); | |
3340 | } | |
3341 | } | |
3342 | } | |
3343 | ||
3344 | ||
15dd636f | 3345 | void AliITStrackerMI::UpdateESDtrack(AliITStrackMI* track, ULong_t flags) const |
e43c066c | 3346 | { |
3347 | // | |
3348 | // | |
3349 | track->UpdateESDtrack(flags); | |
15dd636f | 3350 | AliITStrackMI * oldtrack = (AliITStrackMI*)(track->fESDtrack->GetITStrack()); |
99c2ee26 | 3351 | if (oldtrack) delete oldtrack; |
15dd636f | 3352 | track->fESDtrack->SetITStrack(new AliITStrackMI(*track)); |
628e7bb0 | 3353 | if (TMath::Abs(track->fDnorm[1])<0.000000001){ |
3354 | printf("Problem\n"); | |
3355 | } | |
e43c066c | 3356 | } |
3357 | ||
3358 | ||
3359 | ||
81e97e0d | 3360 | Int_t AliITStrackerMI::GetNearestLayer(const Double_t *xr) const{ |
3361 | // | |
3362 | //Get nearest upper layer close to the point xr. | |
3363 | // rough approximation | |
3364 | // | |
bf6adc12 | 3365 | const Float_t kRadiuses[6]={4,6.5,15.03,24.,38.5,43.7}; |
81e97e0d | 3366 | Float_t radius = TMath::Sqrt(xr[0]*xr[0]+xr[1]*xr[1]); |
3367 | Int_t res =6; | |
3368 | for (Int_t i=0;i<6;i++){ | |
bf6adc12 | 3369 | if (radius<kRadiuses[i]){ |
81e97e0d | 3370 | res =i; |
3371 | break; | |
3372 | } | |
3373 | } | |
3374 | return res; | |
3375 | } | |
e43c066c | 3376 | |
51ad6848 | 3377 | |
81e97e0d | 3378 | void AliITStrackerMI::UpdateTPCV0(AliESD *event){ |
3379 | // | |
3380 | //try to update, or reject TPC V0s | |
3381 | // | |
3382 | Int_t nv0s = event->GetNumberOfV0MIs(); | |
3383 | Int_t nitstracks = fTrackHypothesys.GetEntriesFast(); | |
51ad6848 | 3384 | |
81e97e0d | 3385 | for (Int_t i=0;i<nv0s;i++){ |
3386 | AliESDV0MI * vertex = event->GetV0MI(i); | |
3387 | Int_t ip = vertex->GetIndex(0); | |
3388 | Int_t im = vertex->GetIndex(1); | |
3389 | // | |
3390 | TObjArray * arrayp = (ip<nitstracks) ? (TObjArray*)fTrackHypothesys.At(ip):0; | |
3391 | TObjArray * arraym = (im<nitstracks) ? (TObjArray*)fTrackHypothesys.At(im):0; | |
3392 | AliITStrackMI * trackp = (arrayp!=0) ? (AliITStrackMI*)arrayp->At(0):0; | |
3393 | AliITStrackMI * trackm = (arraym!=0) ? (AliITStrackMI*)arraym->At(0):0; | |
3394 | // | |
3395 | // | |
3396 | if (trackp){ | |
3397 | if (trackp->fN+trackp->fNDeadZone>5.5){ | |
3398 | if (trackp->fConstrain&&trackp->fChi2MIP[0]<3) vertex->SetStatus(-100); | |
3399 | if (!trackp->fConstrain&&trackp->fChi2MIP[0]<2) vertex->SetStatus(-100); | |
3400 | } | |
3401 | } | |
51ad6848 | 3402 | |
81e97e0d | 3403 | if (trackm){ |
3404 | if (trackm->fN+trackm->fNDeadZone>5.5){ | |
3405 | if (trackm->fConstrain&&trackm->fChi2MIP[0]<3) vertex->SetStatus(-100); | |
3406 | if (!trackm->fConstrain&&trackm->fChi2MIP[0]<2) vertex->SetStatus(-100); | |
3407 | } | |
3408 | } | |
3409 | if (vertex->GetStatus()==-100) continue; | |
3410 | // | |
3411 | Int_t clayer = GetNearestLayer(vertex->GetXrp()); | |
3412 | vertex->SetNBefore(clayer); // | |
3413 | vertex->SetChi2Before(9*clayer); // | |
3414 | vertex->SetNAfter(6-clayer); // | |
3415 | vertex->SetChi2After(0); // | |
3416 | // | |
3417 | if (clayer >1 ){ // calculate chi2 before vertex | |
3418 | Float_t chi2p = 0, chi2m=0; | |
3419 | // | |
3420 | if (trackp){ | |
3421 | for (Int_t ilayer=0;ilayer<clayer;ilayer++){ | |
3422 | if (trackp->fClIndex[ilayer]>0){ | |
3423 | chi2p+=trackp->fDy[ilayer]*trackp->fDy[ilayer]/(trackp->fSigmaY[ilayer]*trackp->fSigmaY[ilayer])+ | |
3424 | trackp->fDz[ilayer]*trackp->fDz[ilayer]/(trackp->fSigmaZ[ilayer]*trackp->fSigmaZ[ilayer]); | |
3425 | } | |
3426 | else{ | |
3427 | chi2p+=9; | |
3428 | } | |
3429 | } | |
3430 | }else{ | |
3431 | chi2p = 9*clayer; | |
3432 | } | |
3433 | // | |
3434 | if (trackm){ | |
3435 | for (Int_t ilayer=0;ilayer<clayer;ilayer++){ | |
3436 | if (trackm->fClIndex[ilayer]>0){ | |
3437 | chi2m+=trackm->fDy[ilayer]*trackm->fDy[ilayer]/(trackm->fSigmaY[ilayer]*trackm->fSigmaY[ilayer])+ | |
3438 | trackm->fDz[ilayer]*trackm->fDz[ilayer]/(trackm->fSigmaZ[ilayer]*trackm->fSigmaZ[ilayer]); | |
3439 | } | |
3440 | else{ | |
3441 | chi2m+=9; | |
3442 | } | |
3443 | } | |
3444 | }else{ | |
3445 | chi2m = 9*clayer; | |
3446 | } | |
3447 | vertex->SetChi2Before(TMath::Min(chi2p,chi2m)); | |
3448 | if (TMath::Min(chi2p,chi2m)/Float_t(clayer)<4) vertex->SetStatus(-10); // track exist before vertex | |
3449 | } | |
3450 | ||
3451 | if (clayer < 5 ){ // calculate chi2 after vertex | |
3452 | Float_t chi2p = 0, chi2m=0; | |
3453 | // | |
3454 | if (trackp&&TMath::Abs(trackp->fP3)<1.){ | |
3455 | for (Int_t ilayer=clayer;ilayer<6;ilayer++){ | |
3456 | if (trackp->fClIndex[ilayer]>0){ | |
3457 | chi2p+=trackp->fDy[ilayer]*trackp->fDy[ilayer]/(trackp->fSigmaY[ilayer]*trackp->fSigmaY[ilayer])+ | |
3458 | trackp->fDz[ilayer]*trackp->fDz[ilayer]/(trackp->fSigmaZ[ilayer]*trackp->fSigmaZ[ilayer]); | |
3459 | } | |
3460 | else{ | |
3461 | chi2p+=9; | |
3462 | } | |
3463 | } | |
3464 | }else{ | |
3465 | chi2p = 0; | |
3466 | } | |
3467 | // | |
3468 | if (trackm&&TMath::Abs(trackm->fP3)<1.){ | |
3469 | for (Int_t ilayer=clayer;ilayer<6;ilayer++){ | |
3470 | if (trackm->fClIndex[ilayer]>0){ | |
3471 | chi2m+=trackm->fDy[ilayer]*trackm->fDy[ilayer]/(trackm->fSigmaY[ilayer]*trackm->fSigmaY[ilayer])+ | |
3472 | trackm->fDz[ilayer]*trackm->fDz[ilayer]/(trackm->fSigmaZ[ilayer]*trackm->fSigmaZ[ilayer]); | |
3473 | } | |
3474 | else{ | |
3475 | chi2m+=9; | |
3476 | } | |
3477 | } | |
3478 | }else{ | |
3479 | chi2m = 0; | |
3480 | } | |
3481 | vertex->SetChi2After(TMath::Max(chi2p,chi2m)); | |
3482 | if (TMath::Max(chi2m,chi2p)/Float_t(6-clayer)>9) vertex->SetStatus(-20); // track not found in ITS | |
3483 | } | |
3484 | } | |
3485 | // | |
3486 | } | |
51ad6848 | 3487 | |
67c1e979 | 3488 | |
3489 | ||
81e97e0d | 3490 | void AliITStrackerMI::FindV02(AliESD *event) |
e43c066c | 3491 | { |
3492 | // | |
81e97e0d | 3493 | // V0 finder |
3494 | // | |
3495 | // Cuts on DCA - R dependent | |
3496 | // max distance DCA between 2 tracks cut | |
3497 | // maxDist = TMath::Min(kMaxDist,kMaxDist0+pvertex->GetRr()*kMaxDist); | |
3498 | // | |
3499 | const Float_t kMaxDist0 = 0.1; | |
3500 | const Float_t kMaxDist1 = 0.1; | |
3501 | const Float_t kMaxDist = 1; | |
3502 | const Float_t kMinPointAngle = 0.85; | |
3503 | const Float_t kMinPointAngle2 = 0.99; | |
3504 | const Float_t kMinR = 0.5; | |
3505 | const Float_t kMaxR = 220; | |
3506 | //const Float_t kCausality0Cut = 0.19; | |
3507 | //const Float_t kLikelihood01Cut = 0.25; | |
3508 | //const Float_t kPointAngleCut = 0.9996; | |
3509 | const Float_t kCausality0Cut = 0.19; | |
3510 | const Float_t kLikelihood01Cut = 0.45; | |
3511 | const Float_t kLikelihood1Cut = 0.5; | |
3512 | const Float_t kCombinedCut = 0.55; | |
3513 | ||
3514 | // | |
3515 | // | |
3516 | TTreeSRedirector &cstream = *fDebugStreamer; | |
3517 | Int_t ntracks = event->GetNumberOfTracks(); | |
3518 | Int_t nitstracks = fTrackHypothesys.GetEntriesFast(); | |
3519 | fOriginal.Expand(ntracks); | |
3520 | fTrackHypothesys.Expand(ntracks); | |
3521 | fBestHypothesys.Expand(ntracks); | |
3522 | // | |
3523 | AliHelix * helixes = new AliHelix[ntracks+2]; | |
3524 | TObjArray trackarray(ntracks+2); //array with tracks - with vertex constrain | |
3525 | TObjArray trackarrayc(ntracks+2); //array of "best tracks" - without vertex constrain | |
3526 | TObjArray trackarrayl(ntracks+2); //array of "longest tracks" - without vertex constrain | |
3527 | Bool_t * forbidden = new Bool_t [ntracks+2]; | |
3528 | Int_t *itsmap = new Int_t [ntracks+2]; | |
3529 | Float_t *dist = new Float_t[ntracks+2]; | |
3530 | Float_t *normdist0 = new Float_t[ntracks+2]; | |
3531 | Float_t *normdist1 = new Float_t[ntracks+2]; | |
3532 | Float_t *normdist = new Float_t[ntracks+2]; | |
3533 | Float_t *norm = new Float_t[ntracks+2]; | |
3534 | Float_t *maxr = new Float_t[ntracks+2]; | |
3535 | Float_t *minr = new Float_t[ntracks+2]; | |
3536 | Float_t *minPointAngle= new Float_t[ntracks+2]; | |
3537 | // | |
3538 | AliESDV0MI *pvertex = new AliESDV0MI; | |
3539 | AliITStrackMI * dummy= new AliITStrackMI; | |
3540 | dummy->SetLabel(0); | |
3541 | AliITStrackMI trackat0; //temporary track for DCA calculation | |
e43c066c | 3542 | // |
81e97e0d | 3543 | Float_t primvertex[3]={GetX(),GetY(),GetZ()}; |
628e7bb0 | 3544 | // |
81e97e0d | 3545 | // make its - esd map |
e43c066c | 3546 | // |
81e97e0d | 3547 | for (Int_t itrack=0;itrack<ntracks+2;itrack++) { |
3548 | itsmap[itrack] = -1; | |
3549 | forbidden[itrack] = kFALSE; | |
3550 | maxr[itrack] = kMaxR; | |
3551 | minr[itrack] = kMinR; | |
3552 | minPointAngle[itrack] = kMinPointAngle; | |
3553 | } | |
3554 | for (Int_t itrack=0;itrack<nitstracks;itrack++){ | |
3555 | AliITStrackMI * original = (AliITStrackMI*)(fOriginal.At(itrack)); | |
3556 | Int_t esdindex = original->fESDtrack->GetID(); | |
3557 | itsmap[esdindex] = itrack; | |
3558 | } | |
3559 | // | |
3560 | // create its tracks from esd tracks if not done before | |
3561 | // | |
3562 | for (Int_t itrack=0;itrack<ntracks;itrack++){ | |
3563 | if (itsmap[itrack]>=0) continue; | |
3564 | AliITStrackMI * tpctrack = new AliITStrackMI(*(event->GetTrack(itrack))); | |
3565 | tpctrack->fD[0] = tpctrack->GetD(GetX(),GetY()); | |
3566 | tpctrack->fD[1] = tpctrack->GetZat(GetX())-GetZ(); | |
3567 | if (tpctrack->fD[0]<20 && tpctrack->fD[1]<20){ | |
3568 | // tracks which can reach inner part of ITS | |
3569 | // propagate track to outer its volume - with correction for material | |
3570 | CorrectForDeadZoneMaterial(tpctrack); | |
3571 | } | |
3572 | itsmap[itrack] = nitstracks; | |
3573 | fOriginal.AddAt(tpctrack,nitstracks); | |
3574 | nitstracks++; | |
3575 | } | |
3576 | // | |
3577 | // fill temporary arrays | |
3578 | // | |
3579 | for (Int_t itrack=0;itrack<ntracks;itrack++){ | |
3580 | AliESDtrack * esdtrack = event->GetTrack(itrack); | |
3581 | Int_t itsindex = itsmap[itrack]; | |
3582 | AliITStrackMI *original = (AliITStrackMI*)fOriginal.At(itsmap[itrack]); | |
3583 | if (!original) continue; | |
3584 | AliITStrackMI *bestConst = 0; | |
3585 | AliITStrackMI *bestLong = 0; | |
3586 | AliITStrackMI *best = 0; | |
3587 | // | |
628e7bb0 | 3588 | // |
81e97e0d | 3589 | TObjArray * array = (TObjArray*) fTrackHypothesys.At(itsindex); |
3590 | Int_t hentries = (array==0) ? 0 : array->GetEntriesFast(); | |
3591 | // Get best track with vertex constrain | |
628e7bb0 | 3592 | for (Int_t ih=0;ih<hentries;ih++){ |
3593 | AliITStrackMI * trackh = (AliITStrackMI*)array->At(ih); | |
3594 | if (!trackh->fConstrain) continue; | |
81e97e0d | 3595 | if (!bestConst) bestConst = trackh; |
3596 | if (trackh->fN>5.0){ | |
3597 | bestConst = trackh; // full track - with minimal chi2 | |
3598 | break; | |
3599 | } | |
3600 | if (trackh->fN+trackh->fNDeadZone<=bestConst->fN+bestConst->fNDeadZone) continue; | |
3601 | bestConst = trackh; | |
628e7bb0 | 3602 | break; |
81e97e0d | 3603 | } |
3604 | // Get best long track without vertex constrain and best track without vertex constrain | |
628e7bb0 | 3605 | for (Int_t ih=0;ih<hentries;ih++){ |
3606 | AliITStrackMI * trackh = (AliITStrackMI*)array->At(ih); | |
3607 | if (trackh->fConstrain) continue; | |
81e97e0d | 3608 | if (!best) best = trackh; |
3609 | if (!bestLong) bestLong = trackh; | |
3610 | if (trackh->fN>5.0){ | |
3611 | bestLong = trackh; // full track - with minimal chi2 | |
3612 | break; | |
3613 | } | |
3614 | if (trackh->fN+trackh->fNDeadZone<=bestLong->fN+bestLong->fNDeadZone) continue; | |
3615 | bestLong = trackh; | |
628e7bb0 | 3616 | } |
81e97e0d | 3617 | if (!best) { |
3618 | best = original; | |
3619 | bestLong = original; | |
628e7bb0 | 3620 | } |
81e97e0d | 3621 | trackat0 = *bestLong; |
3622 | Double_t xx,yy,zz,alpha; | |
3623 | bestLong->GetGlobalXYZat(bestLong->GetX(),xx,yy,zz); | |
3624 | alpha = TMath::ATan2(yy,xx); | |
3625 | trackat0.Propagate(alpha,0); | |
3626 | // calculate normalized distances to the vertex | |
628e7bb0 | 3627 | // |
29641977 | 3628 | Float_t ptfac = (1.+100.*TMath::Abs(trackat0.fP4)); |
3629 | if ( bestLong->fN>3 ){ | |
81e97e0d | 3630 | dist[itsindex] = trackat0.fP0; |
29641977 | 3631 | norm[itsindex] = ptfac*TMath::Sqrt(trackat0.fC00); |
81e97e0d | 3632 | normdist0[itsindex] = TMath::Abs(trackat0.fP0/norm[itsindex]); |
29641977 | 3633 | normdist1[itsindex] = TMath::Abs((trackat0.fP1-primvertex[2])/(ptfac*TMath::Sqrt(trackat0.fC11))); |
81e97e0d | 3634 | normdist[itsindex] = TMath::Sqrt(normdist0[itsindex]*normdist0[itsindex]+normdist1[itsindex]*normdist1[itsindex]); |
29641977 | 3635 | if (!bestConst){ |
3636 | if (bestLong->fN+bestLong->fNDeadZone<6) normdist[itsindex]*=2.; | |
3637 | if (bestLong->fN+bestLong->fNDeadZone<5) normdist[itsindex]*=2.; | |
3638 | if (bestLong->fN+bestLong->fNDeadZone<4) normdist[itsindex]*=2.; | |
3639 | }else{ | |
3640 | if (bestConst->fN+bestConst->fNDeadZone<6) normdist[itsindex]*=1.5; | |
3641 | if (bestConst->fN+bestConst->fNDeadZone<5) normdist[itsindex]*=1.5; | |
3642 | } | |
81e97e0d | 3643 | } |
3644 | else{ | |
3645 | if (bestConst&&bestConst->fN+bestConst->fNDeadZone>4.5){ | |
3646 | dist[itsindex] = bestConst->fD[0]; | |
3647 | norm[itsindex] = bestConst->fDnorm[0]; | |
3648 | normdist0[itsindex] = TMath::Abs(bestConst->fD[0]/norm[itsindex]); | |
3649 | normdist1[itsindex] = TMath::Abs(bestConst->fD[0]/norm[itsindex]); | |
3650 | normdist[itsindex] = TMath::Sqrt(normdist0[itsindex]*normdist0[itsindex]+normdist1[itsindex]*normdist1[itsindex]); | |
3651 | }else{ | |
3652 | dist[itsindex] = trackat0.fP0; | |
29641977 | 3653 | norm[itsindex] = ptfac*TMath::Sqrt(trackat0.fC00); |
81e97e0d | 3654 | normdist0[itsindex] = TMath::Abs(trackat0.fP0/norm[itsindex]); |
29641977 | 3655 | normdist1[itsindex] = TMath::Abs((trackat0.fP1-primvertex[2])/(ptfac*TMath::Sqrt(trackat0.fC11))); |
81e97e0d | 3656 | normdist[itsindex] = TMath::Sqrt(normdist0[itsindex]*normdist0[itsindex]+normdist1[itsindex]*normdist1[itsindex]); |
67c1e979 | 3657 | if (TMath::Abs(trackat0.fP3)>1.05){ |
3658 | if (normdist[itsindex]<3) forbidden[itsindex]=kTRUE; | |
3659 | if (normdist[itsindex]>3) { | |
3660 | minr[itsindex] = TMath::Max(Float_t(40.),minr[itsindex]); | |
3661 | } | |
81e97e0d | 3662 | } |
3663 | } | |
3664 | } | |
628e7bb0 | 3665 | // |
81e97e0d | 3666 | //----------------------------------------------------------- |
3667 | //Forbid primary track candidates - | |
628e7bb0 | 3668 | // |
81e97e0d | 3669 | //treetr->SetAlias("forbidden0","Tr0.fN<4&&Tr1.fN+Tr1.fNDeadZone>4.5"); |
3670 | //treetr->SetAlias("forbidden1","ND<3&&Tr1.fN+Tr1.fNDeadZone>5.5"); | |
3671 | //treetr->SetAlias("forbidden2","ND<2&&Tr1.fClIndex[0]>0&&Tr1.fClIndex[0]>0"); | |
3672 | //treetr->SetAlias("forbidden3","ND<1&&Tr1.fClIndex[0]>0"); | |
3673 | //treetr->SetAlias("forbidden4","ND<4&&Tr1.fNormChi2[0]<2"); | |
3674 | //treetr->SetAlias("forbidden5","ND<5&&Tr1.fNormChi2[0]<1"); | |
3675 | //----------------------------------------------------------- | |
3676 | if (bestConst){ | |
3677 | if (bestLong->fN<4 && bestConst->fN+bestConst->fNDeadZone>4.5) forbidden[itsindex]=kTRUE; | |
3678 | if (normdist[itsindex]<3 && bestConst->fN+bestConst->fNDeadZone>5.5) forbidden[itsindex]=kTRUE; | |
3679 | if (normdist[itsindex]<2 && bestConst->fClIndex[0]>0 && bestConst->fClIndex[1]>0 ) forbidden[itsindex]=kTRUE; | |
3680 | if (normdist[itsindex]<1 && bestConst->fClIndex[0]>0) forbidden[itsindex]=kTRUE; | |
3681 | if (normdist[itsindex]<4 && bestConst->fNormChi2[0]<2) forbidden[itsindex]=kTRUE; | |
3682 | if (normdist[itsindex]<5 && bestConst->fNormChi2[0]<1) forbidden[itsindex]=kTRUE; | |
3683 | if (bestConst->fNormChi2[0]<2.5) { | |
3684 | minPointAngle[itsindex]= 0.9999; | |
3685 | maxr[itsindex] = 10; | |
628e7bb0 | 3686 | } |
e43c066c | 3687 | } |
81e97e0d | 3688 | // |
3689 | //forbid daughter kink candidates | |
3690 | // | |
3691 | if (esdtrack->GetKinkIndex(0)>0) forbidden[itsindex] = kTRUE; | |
3692 | Bool_t isElectron = kTRUE; | |
29641977 | 3693 | Bool_t isProton = kTRUE; |
81e97e0d | 3694 | Double_t pid[5]; |
3695 | esdtrack->GetESDpid(pid); | |
3696 | for (Int_t i=1;i<5;i++){ | |
3697 | if (pid[0]<pid[i]) isElectron= kFALSE; | |
29641977 | 3698 | if (pid[4]<pid[i]) isProton= kFALSE; |
81e97e0d | 3699 | } |
3700 | if (isElectron){ | |
3701 | forbidden[itsindex]=kFALSE; | |
29641977 | 3702 | normdist[itsindex]*=-1; |
3703 | } | |
3704 | if (isProton){ | |
3705 | if (normdist[itsindex]>2) forbidden[itsindex]=kFALSE; | |
3706 | normdist[itsindex]*=-1; | |
81e97e0d | 3707 | } |
29641977 | 3708 | |
81e97e0d | 3709 | // |
3710 | // Causality cuts in TPC volume | |
3711 | // | |
3712 | if (esdtrack->GetTPCdensity(0,10) >0.6) maxr[itsindex] = TMath::Min(Float_t(110),maxr[itsindex]); | |
3713 | if (esdtrack->GetTPCdensity(10,30)>0.6) maxr[itsindex] = TMath::Min(Float_t(120),maxr[itsindex]); | |
3714 | if (esdtrack->GetTPCdensity(20,40)>0.6) maxr[itsindex] = TMath::Min(Float_t(130),maxr[itsindex]); | |
3715 | if (esdtrack->GetTPCdensity(30,50)>0.6) maxr[itsindex] = TMath::Min(Float_t(140),maxr[itsindex]); | |
3716 | // | |
3717 | if (esdtrack->GetTPCdensity(0,60)<0.4&&bestLong->fN<3) minr[itsindex]=100; | |
3718 | // | |
3719 | // | |
29641977 | 3720 | if (kFALSE){ |
81e97e0d | 3721 | cstream<<"Track"<< |
3722 | "Tr0.="<<best<< | |
3723 | "Tr1.="<<((bestConst)? bestConst:dummy)<< | |
3724 | "Tr2.="<<bestLong<< | |
3725 | "Tr3.="<<&trackat0<< | |
3726 | "Esd.="<<esdtrack<< | |
3727 | "Dist="<<dist[itsindex]<< | |
3728 | "ND0="<<normdist0[itsindex]<< | |
3729 | "ND1="<<normdist1[itsindex]<< | |
3730 | "ND="<<normdist[itsindex]<< | |
3731 | "Pz="<<primvertex[2]<< | |
3732 | "Forbid="<<forbidden[itsindex]<< | |
3733 | "\n"; | |
3734 | // | |
3735 | } | |
3736 | trackarray.AddAt(best,itsindex); | |
3737 | trackarrayc.AddAt(bestConst,itsindex); | |
3738 | trackarrayl.AddAt(bestLong,itsindex); | |
3739 | new (&helixes[itsindex]) AliHelix(*best); | |
e43c066c | 3740 | } |
628e7bb0 | 3741 | // |
3742 | // | |
81e97e0d | 3743 | // |
3744 | // first iterration of V0 finder | |
3745 | // | |
3746 | for (Int_t iesd0=0;iesd0<ntracks;iesd0++){ | |
3747 | Int_t itrack0 = itsmap[iesd0]; | |
3748 | if (forbidden[itrack0]) continue; | |
3749 | AliITStrackMI * btrack0 = (AliITStrackMI*)trackarray.At(itrack0); | |
3750 | if (!btrack0) continue; | |
3751 | if (btrack0->fP4>0) continue; | |
628e7bb0 | 3752 | AliITStrackMI *trackc0 = (AliITStrackMI*)trackarrayc.At(itrack0); |
3753 | // | |
81e97e0d | 3754 | for (Int_t iesd1=0;iesd1<ntracks;iesd1++){ |
3755 | Int_t itrack1 = itsmap[iesd1]; | |
3756 | if (forbidden[itrack1]) continue; | |
3757 | ||
3758 | AliITStrackMI * btrack1 = (AliITStrackMI*)trackarray.At(itrack1); | |
3759 | if (!btrack1) continue; | |
3760 | if (btrack1->fP4<0) continue; | |
3761 | Bool_t isGold = kFALSE; | |
3762 | if (TMath::Abs(TMath::Abs(btrack0->GetLabel())-TMath::Abs(btrack1->GetLabel()))==1){ | |
3763 | isGold = kTRUE; | |
628e7bb0 | 3764 | } |
81e97e0d | 3765 | AliITStrackMI *trackc1 = (AliITStrackMI*)trackarrayc.At(itrack1); |
3766 | AliHelix &h1 = helixes[itrack0]; | |
3767 | AliHelix &h2 = helixes[itrack1]; | |
628e7bb0 | 3768 | // |
81e97e0d | 3769 | // find linear distance |
3770 | Double_t rmin =0; | |
628e7bb0 | 3771 | // |
51ad6848 | 3772 | // |
51ad6848 | 3773 | // |
81e97e0d | 3774 | Double_t phase[2][2],radius[2]; |
3775 | Int_t points = h1.GetRPHIintersections(h2, phase, radius); | |
3776 | if (points==0) continue; | |
c49fe0bf | 3777 | Double_t delta[2]={1000000,1000000}; |
81e97e0d | 3778 | rmin = radius[0]; |
3779 | h1.ParabolicDCA(h2,phase[0][0],phase[0][1],radius[0],delta[0]); | |
3780 | if (points==2){ | |
3781 | if (radius[1]<rmin) rmin = radius[1]; | |
3782 | h1.ParabolicDCA(h2,phase[1][0],phase[1][1],radius[1],delta[1]); | |
3783 | } | |
3784 | rmin = TMath::Sqrt(rmin); | |
3785 | Double_t distance = 0; | |
3786 | Double_t radiusC = 0; | |
3787 | Int_t iphase = 0; | |
c49fe0bf | 3788 | if (points==1 || delta[0]<delta[1]){ |
81e97e0d | 3789 | distance = TMath::Sqrt(delta[0]); |
3790 | radiusC = TMath::Sqrt(radius[0]); | |
3791 | }else{ | |
3792 | distance = TMath::Sqrt(delta[1]); | |
3793 | radiusC = TMath::Sqrt(radius[1]); | |
3794 | iphase=1; | |
3795 | } | |
3796 | if (radiusC<TMath::Max(minr[itrack0],minr[itrack1])) continue; | |
3797 | if (radiusC>TMath::Min(maxr[itrack0],maxr[itrack1])) continue; | |
3798 | Float_t maxDist = TMath::Min(kMaxDist,Float_t(kMaxDist0+radiusC*kMaxDist1)); | |
3799 | if (distance>maxDist) continue; | |
3800 | Float_t pointAngle = h1.GetPointAngle(h2,phase[iphase],primvertex); | |
3801 | if (pointAngle<TMath::Max(minPointAngle[itrack0],minPointAngle[itrack1])) continue; | |
628e7bb0 | 3802 | // |
51ad6848 | 3803 | // |
81e97e0d | 3804 | // Double_t distance = TestV0(h1,h2,pvertex,rmin); |
51ad6848 | 3805 | // |
81e97e0d | 3806 | // if (distance>maxDist) continue; |
3807 | // if (pvertex->GetRr()<kMinR) continue; | |
3808 | // if (pvertex->GetRr()>kMaxR) continue; | |
3809 | AliITStrackMI * track0=btrack0; | |
3810 | AliITStrackMI * track1=btrack1; | |
3811 | // if (pvertex->GetRr()<3.5){ | |
3812 | if (radiusC<3.5){ | |
3813 | //use longest tracks inside the pipe | |
3814 | track0 = (AliITStrackMI*)trackarrayl.At(itrack0); | |
3815 | track1 = (AliITStrackMI*)trackarrayl.At(itrack1); | |
3816 | } | |
51ad6848 | 3817 | // |
3818 | // | |
81e97e0d | 3819 | pvertex->SetM(*track0); |
3820 | pvertex->SetP(*track1); | |
3821 | pvertex->Update(primvertex); | |
67c1e979 | 3822 | pvertex->SetClusters(track0->fClIndex,track1->fClIndex); // register clusters |
3823 | ||
81e97e0d | 3824 | if (pvertex->GetRr()<kMinR) continue; |
3825 | if (pvertex->GetRr()>kMaxR) continue; | |
3826 | if (pvertex->GetPointAngle()<kMinPointAngle) continue; | |
3827 | if (pvertex->GetDist2()>maxDist) continue; | |
0703142d | 3828 | pvertex->SetLab(0,track0->GetLabel()); |
3829 | pvertex->SetLab(1,track1->GetLabel()); | |
67c1e979 | 3830 | pvertex->SetIndex(0,track0->fESDtrack->GetID()); |
3831 | pvertex->SetIndex(1,track1->fESDtrack->GetID()); | |
e43c066c | 3832 | |
81e97e0d | 3833 | // |
3834 | AliITStrackMI * htrackc0 = trackc0 ? trackc0:dummy; | |
3835 | AliITStrackMI * htrackc1 = trackc1 ? trackc1:dummy; | |
51ad6848 | 3836 | |
81e97e0d | 3837 | // |
3838 | // | |
3839 | TObjArray * array0b = (TObjArray*)fBestHypothesys.At(itrack0); | |
3840 | if (!array0b&&pvertex->GetRr()<40 && TMath::Abs(track0->fP3)<1.1) | |
3841 | FollowProlongationTree((AliITStrackMI*)fOriginal.At(itrack0),itrack0, kFALSE); | |
3842 | TObjArray * array1b = (TObjArray*)fBestHypothesys.At(itrack1); | |
3843 | if (!array1b&&pvertex->GetRr()<40 && TMath::Abs(track1->fP3)<1.1) | |
3844 | FollowProlongationTree((AliITStrackMI*)fOriginal.At(itrack1),itrack1, kFALSE); | |
3845 | // | |
3846 | AliITStrackMI * track0b = (AliITStrackMI*)fOriginal.At(itrack0); | |
3847 | AliITStrackMI * track1b = (AliITStrackMI*)fOriginal.At(itrack1); | |
3848 | AliITStrackMI * track0l = (AliITStrackMI*)fOriginal.At(itrack0); | |
3849 | AliITStrackMI * track1l = (AliITStrackMI*)fOriginal.At(itrack1); | |
3850 | ||
3851 | Float_t minchi2before0=16; | |
3852 | Float_t minchi2before1=16; | |
3853 | Float_t minchi2after0 =16; | |
3854 | Float_t minchi2after1 =16; | |
3855 | Int_t maxLayer = GetNearestLayer(pvertex->GetXrp()); | |
3856 | ||
3857 | if (array0b) for (Int_t i=0;i<5;i++){ | |
3858 | // best track after vertex | |
3859 | AliITStrackMI * btrack = (AliITStrackMI*)array0b->At(i); | |
3860 | if (!btrack) continue; | |
3861 | if (btrack->fN>track0l->fN) track0l = btrack; | |
29641977 | 3862 | // if (btrack->fX<pvertex->GetRr()-2.-0.5/(0.1+pvertex->GetAnglep()[2])) { |
3863 | if (btrack->fX<pvertex->GetRr()-2.) { | |
97f754fa | 3864 | if ( (maxLayer>i+2|| (i==0)) && btrack->fN==(6-i)&&i<3){ |
81e97e0d | 3865 | Float_t sumchi2= 0; |
3866 | Float_t sumn = 0; | |
29641977 | 3867 | if (maxLayer<3){ // take prim vertex as additional measurement |
3868 | if (normdist[itrack0]>0 && htrackc0){ | |
97f754fa | 3869 | sumchi2 += TMath::Min((3.-maxLayer)*normdist[itrack0]*normdist[itrack0],16.); |
29641977 | 3870 | }else{ |
97f754fa | 3871 | sumchi2 += TMath::Min((3.-maxLayer)*(3*normdist[itrack0]*normdist[itrack0]+3.),16.); |
29641977 | 3872 | } |
3873 | sumn += 3-maxLayer; | |
3874 | } | |
81e97e0d | 3875 | for (Int_t ilayer=i;ilayer<maxLayer;ilayer++){ |
97f754fa | 3876 | sumn+=1.; |
81e97e0d | 3877 | if (!btrack->fClIndex[ilayer]){ |
3878 | sumchi2+=25; | |
3879 | continue; | |
3880 | }else{ | |
97f754fa | 3881 | Int_t c=( btrack->fClIndex[ilayer] & 0x0fffffff); |
3882 | for (Int_t itrack=0;itrack<4;itrack++){ | |
3883 | if (fgLayers[ilayer].fClusterTracks[itrack][c]>=0 && fgLayers[ilayer].fClusterTracks[itrack][c]!=itrack0){ | |
3884 | sumchi2+=18.; //shared cluster | |
3885 | break; | |
3886 | } | |
3887 | } | |
81e97e0d | 3888 | sumchi2+=btrack->fDy[ilayer]*btrack->fDy[ilayer]/(btrack->fSigmaY[ilayer]*btrack->fSigmaY[ilayer]); |
3889 | sumchi2+=btrack->fDz[ilayer]*btrack->fDz[ilayer]/(btrack->fSigmaZ[ilayer]*btrack->fSigmaZ[ilayer]); | |
3890 | } | |
3891 | } | |
3892 | sumchi2/=sumn; | |
3893 | if (sumchi2<minchi2before0) minchi2before0=sumchi2; | |
51ad6848 | 3894 | } |
81e97e0d | 3895 | continue; //safety space - Geo manager will give exact layer |
51ad6848 | 3896 | } |
81e97e0d | 3897 | track0b = btrack; |
3898 | minchi2after0 = btrack->fNormChi2[i]; | |
3899 | break; | |
3900 | } | |
3901 | if (array1b) for (Int_t i=0;i<5;i++){ | |
3902 | // best track after vertex | |
3903 | AliITStrackMI * btrack = (AliITStrackMI*)array1b->At(i); | |
3904 | if (!btrack) continue; | |
3905 | if (btrack->fN>track1l->fN) track1l = btrack; | |
29641977 | 3906 | // if (btrack->fX<pvertex->GetRr()-2-0.5/(0.1+pvertex->GetAnglep()[2])){ |
81e97e0d | 3907 | if (btrack->fX<pvertex->GetRr()-2){ |
97f754fa | 3908 | if ((maxLayer>i+2 || (i==0))&&btrack->fN==(6-i)&&(i<3)){ |
81e97e0d | 3909 | Float_t sumchi2= 0; |
3910 | Float_t sumn = 0; | |
29641977 | 3911 | if (maxLayer<3){ // take prim vertex as additional measurement |
3912 | if (normdist[itrack1]>0 && htrackc1){ | |
97f754fa | 3913 | sumchi2 += TMath::Min((3.-maxLayer)*normdist[itrack1]*normdist[itrack1],16.); |
29641977 | 3914 | }else{ |
97f754fa | 3915 | sumchi2 += TMath::Min((3.-maxLayer)*(3*normdist[itrack1]*normdist[itrack1]+3.),16.); |
29641977 | 3916 | } |
3917 | sumn += 3-maxLayer; | |
3918 | } | |
81e97e0d | 3919 | for (Int_t ilayer=i;ilayer<maxLayer;ilayer++){ |
3920 | sumn+=1.; | |
3921 | if (!btrack->fClIndex[ilayer]){ | |
3922 | sumchi2+=30; | |
3923 | continue; | |
3924 | }else{ | |
97f754fa | 3925 | Int_t c=( btrack->fClIndex[ilayer] & 0x0fffffff); |
3926 | for (Int_t itrack=0;itrack<4;itrack++){ | |
3927 | if (fgLayers[ilayer].fClusterTracks[itrack][c]>=0 && fgLayers[ilayer].fClusterTracks[itrack][c]!=itrack1){ | |
3928 | sumchi2+=18.; //shared cluster | |
3929 | break; | |
3930 | } | |
3931 | } | |
81e97e0d | 3932 | sumchi2+=btrack->fDy[ilayer]*btrack->fDy[ilayer]/(btrack->fSigmaY[ilayer]*btrack->fSigmaY[ilayer]); |
3933 | sumchi2+=btrack->fDz[ilayer]*btrack->fDz[ilayer]/(btrack->fSigmaZ[ilayer]*btrack->fSigmaZ[ilayer]); | |
3934 | } | |
3935 | } | |
3936 | sumchi2/=sumn; | |
3937 | if (sumchi2<minchi2before1) minchi2before1=sumchi2; | |
51ad6848 | 3938 | } |
81e97e0d | 3939 | continue; //safety space - Geo manager will give exact layer |
51ad6848 | 3940 | } |
81e97e0d | 3941 | track1b = btrack; |
3942 | minchi2after1 = btrack->fNormChi2[i]; | |
3943 | break; | |
e43c066c | 3944 | } |
628e7bb0 | 3945 | // |
81e97e0d | 3946 | // position resolution - used for DCA cut |
3947 | Float_t sigmad = track0b->fC00+track0b->fC11+track1b->fC00+track1b->fC11+ | |
3948 | (track0b->fX-pvertex->GetRr())*(track0b->fX-pvertex->GetRr())*(track0b->fC22+track0b->fC33)+ | |
3949 | (track1b->fX-pvertex->GetRr())*(track1b->fX-pvertex->GetRr())*(track1b->fC22+track1b->fC33); | |
3950 | sigmad =TMath::Sqrt(sigmad)+0.04; | |
3951 | if (pvertex->GetRr()>50){ | |
3952 | Double_t cov0[15],cov1[15]; | |
3953 | track0b->fESDtrack->GetInnerExternalCovariance(cov0); | |
3954 | track1b->fESDtrack->GetInnerExternalCovariance(cov1); | |
3955 | sigmad = cov0[0]+cov0[2]+cov1[0]+cov1[2]+ | |
3956 | (80.-pvertex->GetRr())*(80.-pvertex->GetRr())*(cov0[5]+cov0[9])+ | |
3957 | (80.-pvertex->GetRr())*(80.-pvertex->GetRr())*(cov1[5]+cov1[9]); | |
3958 | sigmad =TMath::Sqrt(sigmad)+0.05; | |
3959 | } | |
3960 | // | |
3961 | AliESDV0MI vertex2; | |
3962 | vertex2.SetM(*track0b); | |
3963 | vertex2.SetP(*track1b); | |
3964 | vertex2.Update(primvertex); | |
3965 | if (vertex2.GetDist2()<=pvertex->GetDist2()&&(vertex2.GetPointAngle()>=pvertex->GetPointAngle())){ | |
3966 | pvertex->SetM(*track0b); | |
3967 | pvertex->SetP(*track1b); | |
3968 | pvertex->Update(primvertex); | |
67c1e979 | 3969 | pvertex->SetClusters(track0b->fClIndex,track1b->fClIndex); // register clusters |
3970 | pvertex->SetIndex(0,track0->fESDtrack->GetID()); | |
3971 | pvertex->SetIndex(1,track1->fESDtrack->GetID()); | |
81e97e0d | 3972 | } |
3973 | pvertex->SetDistSigma(sigmad); | |
3974 | pvertex->SetDistNorm(pvertex->GetDist2()/sigmad); | |
29641977 | 3975 | pvertex->SetNormDCAPrim(normdist[itrack0],normdist[itrack1]); |
628e7bb0 | 3976 | // |
81e97e0d | 3977 | // define likelihhod and causalities |
628e7bb0 | 3978 | // |
81e97e0d | 3979 | Float_t pa0=1, pa1=1, pb0=0.26, pb1=0.26; |
29641977 | 3980 | if (maxLayer<1){ |
3981 | Float_t fnorm0 = normdist[itrack0]; | |
3982 | if (fnorm0<0) fnorm0*=-3; | |
3983 | Float_t fnorm1 = normdist[itrack1]; | |
3984 | if (fnorm1<0) fnorm1*=-3; | |
3985 | if (pvertex->GetAnglep()[2]>0.1 || (pvertex->GetRr()<10.5)&& pvertex->GetAnglep()[2]>0.05 || pvertex->GetRr()<3){ | |
3986 | pb0 = TMath::Exp(-TMath::Min(fnorm0,Float_t(16.))/12.); | |
3987 | pb1 = TMath::Exp(-TMath::Min(fnorm1,Float_t(16.))/12.); | |
67c1e979 | 3988 | } |
81e97e0d | 3989 | pvertex->SetChi2Before(normdist[itrack0]); |
3990 | pvertex->SetChi2After(normdist[itrack1]); | |
3991 | pvertex->SetNAfter(0); | |
3992 | pvertex->SetNBefore(0); | |
3993 | }else{ | |
3994 | pvertex->SetChi2Before(minchi2before0); | |
3995 | pvertex->SetChi2After(minchi2before1); | |
29641977 | 3996 | if (pvertex->GetAnglep()[2]>0.1 || ( pvertex->GetRr()<10.5 && pvertex->GetAnglep()[2]>0.05) || pvertex->GetRr()<3){ |
3997 | pb0 = TMath::Exp(-TMath::Min(minchi2before0,Float_t(16))/12.); | |
3998 | pb1 = TMath::Exp(-TMath::Min(minchi2before1,Float_t(16))/12.); | |
3999 | } | |
4000 | pvertex->SetNAfter(maxLayer); | |
4001 | pvertex->SetNBefore(maxLayer); | |
628e7bb0 | 4002 | } |
81e97e0d | 4003 | if (pvertex->GetRr()<90){ |
4004 | pa0 *= TMath::Min(track0->fESDtrack->GetTPCdensity(0,60),Float_t(1.)); | |
4005 | pa1 *= TMath::Min(track1->fESDtrack->GetTPCdensity(0,60),Float_t(1.)); | |
628e7bb0 | 4006 | } |
81e97e0d | 4007 | if (pvertex->GetRr()<20){ |
4008 | pa0 *= (0.2+TMath::Exp(-TMath::Min(minchi2after0,Float_t(16))/8.))/1.2; | |
4009 | pa1 *= (0.2+TMath::Exp(-TMath::Min(minchi2after1,Float_t(16))/8.))/1.2; | |
e43c066c | 4010 | } |
628e7bb0 | 4011 | // |
81e97e0d | 4012 | pvertex->SetCausality(pb0,pb1,pa0,pa1); |
628e7bb0 | 4013 | // |
81e97e0d | 4014 | // Likelihood calculations - apply cuts |
4015 | // | |
4016 | Bool_t v0OK = kTRUE; | |
4017 | Float_t p12 = pvertex->GetParamP()->GetParameter()[4]*pvertex->GetParamP()->GetParameter()[4]; | |
4018 | p12 += pvertex->GetParamM()->GetParameter()[4]*pvertex->GetParamM()->GetParameter()[4]; | |
4019 | p12 = TMath::Sqrt(p12); // "mean" momenta | |
4020 | Float_t sigmap0 = 0.0001+0.001/(0.1+pvertex->GetRr()); | |
4021 | Float_t sigmap = 0.5*sigmap0*(0.6+0.4*p12); // "resolution: of point angle - as a function of radius and momenta | |
4022 | ||
bf6adc12 | 4023 | Float_t causalityA = (1.0-pvertex->GetCausalityP()[0])*(1.0-pvertex->GetCausalityP()[1]); |
4024 | Float_t causalityB = TMath::Sqrt(TMath::Min(pvertex->GetCausalityP()[2],Float_t(0.7))* | |
81e97e0d | 4025 | TMath::Min(pvertex->GetCausalityP()[3],Float_t(0.7))); |
628e7bb0 | 4026 | // |
bf6adc12 | 4027 | Float_t likelihood0 = (TMath::Exp(-pvertex->GetDistNorm())+0.1) *(pvertex->GetDist2()<0.5)*(pvertex->GetDistNorm()<5); |
81e97e0d | 4028 | |
bf6adc12 | 4029 | Float_t likelihood1 = TMath::Exp(-(1.0001-pvertex->GetPointAngle())/sigmap)+ |
81e97e0d | 4030 | 0.4*TMath::Exp(-(1.0001-pvertex->GetPointAngle())/(4.*sigmap))+ |
4031 | 0.4*TMath::Exp(-(1.0001-pvertex->GetPointAngle())/(8.*sigmap))+ | |
4032 | 0.1*TMath::Exp(-(1.0001-pvertex->GetPointAngle())/0.01); | |
628e7bb0 | 4033 | // |
bf6adc12 | 4034 | if (causalityA<kCausality0Cut) v0OK = kFALSE; |
4035 | if (TMath::Sqrt(likelihood0*likelihood1)<kLikelihood01Cut) v0OK = kFALSE; | |
4036 | if (likelihood1<kLikelihood1Cut) v0OK = kFALSE; | |
4037 | if (TMath::Power(likelihood0*likelihood1*causalityB,0.33)<kCombinedCut) v0OK = kFALSE; | |
81e97e0d | 4038 | |
628e7bb0 | 4039 | // |
628e7bb0 | 4040 | // |
67c1e979 | 4041 | if (kFALSE){ |
81e97e0d | 4042 | Bool_t gold = TMath::Abs(TMath::Abs(track0->GetLabel())-TMath::Abs(track1->GetLabel()))==1; |
4043 | cstream<<"It0"<< | |
4044 | "Tr0.="<<track0<< //best without constrain | |
4045 | "Tr1.="<<track1<< //best without constrain | |
4046 | "Tr0B.="<<track0b<< //best without constrain after vertex | |
4047 | "Tr1B.="<<track1b<< //best without constrain after vertex | |
4048 | "Tr0C.="<<htrackc0<< //best with constrain if exist | |
4049 | "Tr1C.="<<htrackc1<< //best with constrain if exist | |
4050 | "Tr0L.="<<track0l<< //longest best | |
4051 | "Tr1L.="<<track1l<< //longest best | |
4052 | "Esd0.="<<track0->fESDtrack<< // esd track0 params | |
4053 | "Esd1.="<<track1->fESDtrack<< // esd track1 params | |
4054 | "V0.="<<pvertex<< //vertex properties | |
4055 | "V0b.="<<&vertex2<< //vertex properties at "best" track | |
4056 | "ND0="<<normdist[itrack0]<< //normalize distance for track0 | |
4057 | "ND1="<<normdist[itrack1]<< //normalize distance for track1 | |
4058 | "Gold="<<gold<< // | |
4059 | // "RejectBase="<<rejectBase<< //rejection in First itteration | |
4060 | "OK="<<v0OK<< | |
4061 | "rmin="<<rmin<< | |
4062 | "sigmad="<<sigmad<< | |
4063 | "\n"; | |
4064 | } | |
4065 | //if (rejectBase) continue; | |
628e7bb0 | 4066 | // |
81e97e0d | 4067 | pvertex->SetStatus(0); |
4068 | // if (rejectBase) { | |
4069 | // pvertex->SetStatus(-100); | |
4070 | //} | |
4071 | if (pvertex->GetPointAngle()>kMinPointAngle2) { | |
81e97e0d | 4072 | pvertex->SetESDindexes(track0->fESDtrack->GetID(),track1->fESDtrack->GetID()); |
67c1e979 | 4073 | if (v0OK){ |
4074 | // AliV0vertex vertexjuri(*track0,*track1); | |
4075 | // vertexjuri.SetESDindexes(track0->fESDtrack->GetID(),track1->fESDtrack->GetID()); | |
4076 | // event->AddV0(&vertexjuri); | |
81e97e0d | 4077 | pvertex->SetStatus(100); |
4078 | } | |
4079 | event->AddV0MI(pvertex); | |
628e7bb0 | 4080 | } |
51ad6848 | 4081 | } |
4082 | } | |
628e7bb0 | 4083 | // |
4084 | // | |
81e97e0d | 4085 | // delete temporary arrays |
4086 | // | |
4087 | delete[] minPointAngle; | |
4088 | delete[] maxr; | |
4089 | delete[] minr; | |
4090 | delete[] norm; | |
4091 | delete[] normdist; | |
4092 | delete[] normdist1; | |
4093 | delete[] normdist0; | |
4094 | delete[] dist; | |
4095 | delete[] itsmap; | |
4096 | delete[] helixes; | |
4097 | delete pvertex; | |
e43c066c | 4098 | } |
4099 | ||
4100 | ||
67c1e979 | 4101 | void AliITStrackerMI::RefitV02(AliESD *event) |
4102 | { | |
4103 | // | |
4104 | //try to refit V0s in the third path of the reconstruction | |
4105 | // | |
4106 | TTreeSRedirector &cstream = *fDebugStreamer; | |
4107 | // | |
4108 | Int_t nv0s = event->GetNumberOfV0MIs(); | |
4109 | Float_t primvertex[3]={GetX(),GetY(),GetZ()}; | |
4110 | AliESDV0MI v0temp; | |
4111 | for (Int_t iv0 = 0; iv0<nv0s;iv0++){ | |
4112 | AliESDV0MI * v0mi = event->GetV0MI(iv0); | |
4113 | if (!v0mi) continue; | |
4114 | Int_t itrack0 = v0mi->GetIndex(0); | |
4115 | Int_t itrack1 = v0mi->GetIndex(1); | |
4116 | AliESDtrack *esd0 = event->GetTrack(itrack0); | |
4117 | AliESDtrack *esd1 = event->GetTrack(itrack1); | |
4118 | if (!esd0||!esd1) continue; | |
4119 | AliITStrackMI tpc0(*esd0); | |
4120 | AliITStrackMI tpc1(*esd1); | |
4121 | Double_t alpha =TMath::ATan2(v0mi->GetXr(1),v0mi->GetXr(0)); | |
4122 | if (v0mi->GetRr()>85){ | |
4123 | if (tpc0.Propagate(alpha,v0mi->GetRr())&&tpc1.Propagate(alpha,v0mi->GetRr())){ | |
4124 | v0temp.SetM(tpc0); | |
4125 | v0temp.SetP(tpc1); | |
4126 | v0temp.Update(primvertex); | |
29641977 | 4127 | if (kFALSE) cstream<<"Refit"<< |
67c1e979 | 4128 | "V0.="<<v0mi<< |
4129 | "V0refit.="<<&v0temp<< | |
4130 | "Tr0.="<<&tpc0<< | |
4131 | "Tr1.="<<&tpc1<< | |
4132 | "\n"; | |
4133 | if (v0temp.GetDist2()<v0mi->GetDist2() || v0temp.GetPointAngle()>v0mi->GetPointAngle()){ | |
4134 | v0mi->SetM(tpc0); | |
4135 | v0mi->SetP(tpc1); | |
4136 | v0mi->Update(primvertex); | |
4137 | } | |
4138 | } | |
4139 | continue; | |
4140 | } | |
4141 | if (v0mi->GetRr()>35){ | |
4142 | CorrectForDeadZoneMaterial(&tpc0); | |
4143 | CorrectForDeadZoneMaterial(&tpc1); | |
4144 | if (tpc0.Propagate(alpha,v0mi->GetRr())&&tpc1.Propagate(alpha,v0mi->GetRr())){ | |
4145 | v0temp.SetM(tpc0); | |
4146 | v0temp.SetP(tpc1); | |
4147 | v0temp.Update(primvertex); | |
29641977 | 4148 | if (kFALSE) cstream<<"Refit"<< |
67c1e979 | 4149 | "V0.="<<v0mi<< |
4150 | "V0refit.="<<&v0temp<< | |
4151 | "Tr0.="<<&tpc0<< | |
4152 | "Tr1.="<<&tpc1<< | |
4153 | "\n"; | |
4154 | if (v0temp.GetDist2()<v0mi->GetDist2() || v0temp.GetPointAngle()>v0mi->GetPointAngle()){ | |
4155 | v0mi->SetM(tpc0); | |
4156 | v0mi->SetP(tpc1); | |
4157 | v0mi->Update(primvertex); | |
4158 | } | |
4159 | } | |
4160 | continue; | |
4161 | } | |
4162 | CorrectForDeadZoneMaterial(&tpc0); | |
4163 | CorrectForDeadZoneMaterial(&tpc1); | |
4164 | // if (tpc0.Propagate(alpha,v0mi->GetRr())&&tpc1.Propagate(alpha,v0mi->GetRr())){ | |
4165 | if (RefitAt(v0mi->GetRr(),&tpc0, v0mi->GetClusters(0)) && RefitAt(v0mi->GetRr(),&tpc1, v0mi->GetClusters(1))){ | |
4166 | v0temp.SetM(tpc0); | |
4167 | v0temp.SetP(tpc1); | |
4168 | v0temp.Update(primvertex); | |
29641977 | 4169 | if (kFALSE) cstream<<"Refit"<< |
67c1e979 | 4170 | "V0.="<<v0mi<< |
4171 | "V0refit.="<<&v0temp<< | |
4172 | "Tr0.="<<&tpc0<< | |
4173 | "Tr1.="<<&tpc1<< | |
4174 | "\n"; | |
4175 | if (v0temp.GetDist2()<v0mi->GetDist2() || v0temp.GetPointAngle()>v0mi->GetPointAngle()){ | |
4176 | v0mi->SetM(tpc0); | |
4177 | v0mi->SetP(tpc1); | |
4178 | v0mi->Update(primvertex); | |
4179 | } | |
4180 | } | |
4181 | } | |
4182 | } | |
e43c066c | 4183 | |
51ad6848 | 4184 | |
4185 | ||
4186 | ||
4187 | ||
4188 | ||
4189 |