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