]> git.uio.no Git - u/mrichter/AliRoot.git/blame_incremental - ITS/AliITSV0Finder.cxx
Coverity fix
[u/mrichter/AliRoot.git] / ITS / AliITSV0Finder.cxx
... / ...
CommitLineData
1/**************************************************************************\r
2 * Copyright(c) 2007-2009, ALICE Experiment at CERN, All rights reserved. *\r
3 * *\r
4 * Author: The ALICE Off-line Project. *\r
5 * Contributors are mentioned in the code where appropriate. *\r
6 * *\r
7 * Permission to use, copy, modify and distribute this software and its *\r
8 * documentation strictly for non-commercial purposes is hereby granted *\r
9 * without fee, provided that the above copyright notice appears in all *\r
10 * copies and that both the copyright notice and this permission notice *\r
11 * appear in the supporting documentation. The authors make no claims *\r
12 * about the suitability of this software for any purpose. It is *\r
13 * provided "as is" without express or implied warranty. *\r
14 **************************************************************************/\r
15/* $Id$ */\r
16\r
17//-------------------------------------------------------------------------\r
18// Implementation of the on-the-fly v0 finder for ITS tracker MI\r
19// Origin: Marian Ivanov, CERN, Marian.Ivanov@cern.ch \r
20// Extraction from AliITStrackerMI: Andrea Dainese\r
21// Current support and development: \r
22//-------------------------------------------------------------------------\r
23\r
24#include <TMatrixD.h>\r
25#include <TTree.h>\r
26#include <TString.h>\r
27#include <TRandom.h>\r
28#include <TTreeStream.h>\r
29\r
30\r
31#include "AliLog.h"\r
32#include "AliESDVertex.h"\r
33#include "AliESDEvent.h"\r
34#include "AliESDtrack.h"\r
35#include "AliESDV0Params.h"\r
36#include "AliV0.h"\r
37#include "AliHelix.h"\r
38#include "AliITSRecPoint.h"\r
39#include "AliITSReconstructor.h"\r
40#include "AliITStrackerMI.h"\r
41#include "AliITSV0Finder.h"\r
42#include "AliKFParticle.h"\r
43#include "AliKFVertex.h"\r
44\r
45ClassImp(AliITSV0Finder)\r
46\r
47\r
48AliITSV0Finder::AliITSV0Finder():\r
49fDebugStreamer(0)\r
50 {\r
51 //Default constructor\r
52\r
53 if (AliITSReconstructor::GetRecoParam()->GetESDV0Params()->StreamLevel()>0)\r
54 fDebugStreamer = new TTreeSRedirector("ITSdebug.root");\r
55} \r
56\r
57//------------------------------------------------------------------------\r
58void AliITSV0Finder::UpdateTPCV0(const AliESDEvent *event,\r
59 AliITStrackerMI *tracker)\r
60{\r
61 //\r
62 //try to update, or reject TPC V0s\r
63 //\r
64 const Float_t kMinTgl2= AliITSReconstructor::GetRecoParam()->GetESDV0Params()->GetMinTgl2();\r
65\r
66 TObjArray *trackHypothesys = tracker->GetTrackHypothesys();\r
67\r
68 Int_t nv0s = event->GetNumberOfV0s();\r
69 Int_t nitstracks = trackHypothesys->GetEntriesFast();\r
70\r
71 for (Int_t i=0;i<nv0s;i++){\r
72 AliESDv0 * vertex = event->GetV0(i);\r
73 Int_t ip = vertex->GetIndex(0);\r
74 Int_t im = vertex->GetIndex(1);\r
75 //\r
76 TObjArray * arrayp = (ip<nitstracks) ? (TObjArray*)trackHypothesys->At(ip):0;\r
77 TObjArray * arraym = (im<nitstracks) ? (TObjArray*)trackHypothesys->At(im):0;\r
78 AliITStrackMI * trackp = (arrayp!=0) ? (AliITStrackMI*)arrayp->At(0):0;\r
79 AliITStrackMI * trackm = (arraym!=0) ? (AliITStrackMI*)arraym->At(0):0;\r
80 //\r
81 //\r
82 if (trackp){\r
83 if (trackp->GetNumberOfClusters()+trackp->GetNDeadZone()>5.5){\r
84 if (trackp->GetConstrain()&&trackp->GetChi2MIP(0)<3) vertex->SetStatus(-100);\r
85 if (!trackp->GetConstrain()&&trackp->GetChi2MIP(0)<2) vertex->SetStatus(-100); \r
86 }\r
87 }\r
88\r
89 if (trackm){\r
90 if (trackm->GetNumberOfClusters()+trackm->GetNDeadZone()>5.5){\r
91 if (trackm->GetConstrain()&&trackm->GetChi2MIP(0)<3) vertex->SetStatus(-100);\r
92 if (!trackm->GetConstrain()&&trackm->GetChi2MIP(0)<2) vertex->SetStatus(-100); \r
93 }\r
94 }\r
95 if (vertex->GetStatus()==-100) continue;\r
96 //\r
97 Double_t xrp[3]; vertex->GetXYZ(xrp[0],xrp[1],xrp[2]); //I.B.\r
98 Int_t clayer = tracker->GetNearestLayer(xrp); //I.B.\r
99 vertex->SetNBefore(clayer); //\r
100 vertex->SetChi2Before(9*clayer); //\r
101 vertex->SetNAfter(6-clayer); //\r
102 vertex->SetChi2After(0); //\r
103 //\r
104 if (clayer >1 ){ // calculate chi2 before vertex\r
105 Float_t chi2p = 0, chi2m=0; \r
106 //\r
107 if (trackp){\r
108 for (Int_t ilayer=0;ilayer<clayer;ilayer++){\r
109 if (trackp->GetClIndex(ilayer)>=0){\r
110 chi2p+=trackp->GetDy(ilayer)*trackp->GetDy(ilayer)/(trackp->GetSigmaY(ilayer)*trackp->GetSigmaY(ilayer))+\r
111 trackp->GetDz(ilayer)*trackp->GetDz(ilayer)/(trackp->GetSigmaZ(ilayer)*trackp->GetSigmaZ(ilayer));\r
112 }\r
113 else{\r
114 chi2p+=9;\r
115 }\r
116 }\r
117 }else{\r
118 chi2p = 9*clayer;\r
119 }\r
120 //\r
121 if (trackm){\r
122 for (Int_t ilayer=0;ilayer<clayer;ilayer++){\r
123 if (trackm->GetClIndex(ilayer)>=0){\r
124 chi2m+=trackm->GetDy(ilayer)*trackm->GetDy(ilayer)/(trackm->GetSigmaY(ilayer)*trackm->GetSigmaY(ilayer))+\r
125 trackm->GetDz(ilayer)*trackm->GetDz(ilayer)/(trackm->GetSigmaZ(ilayer)*trackm->GetSigmaZ(ilayer));\r
126 }\r
127 else{\r
128 chi2m+=9;\r
129 }\r
130 }\r
131 }else{\r
132 chi2m = 9*clayer;\r
133 }\r
134 vertex->SetChi2Before(TMath::Min(chi2p,chi2m));\r
135 if (TMath::Min(chi2p,chi2m)/Float_t(clayer)<4) vertex->SetStatus(-10); // track exist before vertex\r
136 }\r
137 \r
138 if (clayer < 5 ){ // calculate chi2 after vertex\r
139 Float_t chi2p = 0, chi2m=0; \r
140 //\r
141 if (trackp&&TMath::Abs(trackp->GetTgl())<kMinTgl2){\r
142 for (Int_t ilayer=clayer;ilayer<6;ilayer++){\r
143 if (trackp->GetClIndex(ilayer)>=0){\r
144 chi2p+=trackp->GetDy(ilayer)*trackp->GetDy(ilayer)/(trackp->GetSigmaY(ilayer)*trackp->GetSigmaY(ilayer))+\r
145 trackp->GetDz(ilayer)*trackp->GetDz(ilayer)/(trackp->GetSigmaZ(ilayer)*trackp->GetSigmaZ(ilayer));\r
146 }\r
147 else{\r
148 chi2p+=9;\r
149 }\r
150 }\r
151 }else{\r
152 chi2p = 0;\r
153 }\r
154 //\r
155 if (trackm&&TMath::Abs(trackm->GetTgl())<kMinTgl2){\r
156 for (Int_t ilayer=clayer;ilayer<6;ilayer++){\r
157 if (trackm->GetClIndex(ilayer)>=0){\r
158 chi2m+=trackm->GetDy(ilayer)*trackm->GetDy(ilayer)/(trackm->GetSigmaY(ilayer)*trackm->GetSigmaY(ilayer))+\r
159 trackm->GetDz(ilayer)*trackm->GetDz(ilayer)/(trackm->GetSigmaZ(ilayer)*trackm->GetSigmaZ(ilayer));\r
160 }\r
161 else{\r
162 chi2m+=9;\r
163 }\r
164 }\r
165 }else{\r
166 chi2m = 0;\r
167 }\r
168 vertex->SetChi2After(TMath::Max(chi2p,chi2m));\r
169 if (TMath::Max(chi2m,chi2p)/Float_t(6-clayer)>9) vertex->SetStatus(-20); // track not found in ITS\r
170 }\r
171 }\r
172 //\r
173}\r
174//------------------------------------------------------------------------\r
175void AliITSV0Finder::FindV02(AliESDEvent *event,\r
176 AliITStrackerMI *tracker) \r
177{\r
178 //\r
179 // V0 finder\r
180 //\r
181 // Cuts on DCA - R dependent\r
182 // max distance DCA between 2 tracks cut \r
183 // maxDist = TMath::Min(kMaxDist,kMaxDist0+pvertex->GetRr()*kMaxDist);\r
184 //\r
185 const Bool_t kCheckPropagate = kFALSE;\r
186 const Float_t kMaxDist0 = AliITSReconstructor::GetRecoParam()->GetESDV0Params()->GetMaxDist0();\r
187 const Float_t kMaxDist1 = AliITSReconstructor::GetRecoParam()->GetESDV0Params()->GetMaxDist1();\r
188 const Float_t kMaxDist = AliITSReconstructor::GetRecoParam()->GetESDV0Params()->GetMaxDist();\r
189 const Float_t kMinPointAngle = AliITSReconstructor::GetRecoParam()->GetESDV0Params()->GetMinPointAngle();\r
190 const Float_t kMinPointAngle2 = AliITSReconstructor::GetRecoParam()->GetESDV0Params()->GetMinPointAngle2();\r
191 const Float_t kMinR = AliITSReconstructor::GetRecoParam()->GetESDV0Params()->GetMinR();\r
192 const Float_t kMaxR = AliITSReconstructor::GetRecoParam()->GetESDV0Params()->GetMaxR();\r
193 const Float_t kMinPABestConst = AliITSReconstructor::GetRecoParam()->GetESDV0Params()->GetMinPABestConst();\r
194 const Float_t kMaxRBestConst = AliITSReconstructor::GetRecoParam()->GetESDV0Params()->GetMaxRBestConst();\r
195 const Float_t kCausality0Cut = AliITSReconstructor::GetRecoParam()->GetESDV0Params()->GetCausality0Cut();\r
196 const Float_t kLikelihood01Cut = AliITSReconstructor::GetRecoParam()->GetESDV0Params()->GetLikelihood01Cut();\r
197 const Float_t kLikelihood1Cut = AliITSReconstructor::GetRecoParam()->GetESDV0Params()->GetLikelihood1Cut();\r
198 const Float_t kCombinedCut = AliITSReconstructor::GetRecoParam()->GetESDV0Params()->GetCombinedCut();\r
199 const Float_t kMinClFullTrk= AliITSReconstructor::GetRecoParam()->GetESDV0Params()->GetMinClFullTrk();\r
200 const Float_t kMinTgl0= AliITSReconstructor::GetRecoParam()->GetESDV0Params()->GetMinTgl0();\r
201 const Float_t kMinRTgl0= AliITSReconstructor::GetRecoParam()->GetESDV0Params()->GetMinRTgl0();\r
202\r
203 const Float_t kMinNormDistForbTgl0= AliITSReconstructor::GetRecoParam()->GetESDV0Params()->GetMinNormDistForbTgl0();\r
204 const Float_t kMinClForb0= AliITSReconstructor::GetRecoParam()->GetESDV0Params()->GetMinClForb0();\r
205 const Float_t kMinNormDistForb1= AliITSReconstructor::GetRecoParam()->GetESDV0Params()->GetMinNormDistForb1();\r
206 const Float_t kMinNormDistForb2= AliITSReconstructor::GetRecoParam()->GetESDV0Params()->GetMinNormDistForb2();\r
207 const Float_t kMinNormDistForb3= AliITSReconstructor::GetRecoParam()->GetESDV0Params()->GetMinNormDistForb3();\r
208 const Float_t kMinNormDistForb4= AliITSReconstructor::GetRecoParam()->GetESDV0Params()->GetMinNormDistForb4();\r
209 const Float_t kMinNormDistForb5= AliITSReconstructor::GetRecoParam()->GetESDV0Params()->GetMinNormDistForb5();\r
210 const Float_t kMinNormDistForbProt= AliITSReconstructor::GetRecoParam()->GetESDV0Params()->GetMinNormDistForbProt();\r
211 const Float_t kMaxPidProbPionForb= AliITSReconstructor::GetRecoParam()->GetESDV0Params()->GetMaxPidProbPionForb();\r
212\r
213 const Float_t kMinRTPCdensity= AliITSReconstructor::GetRecoParam()->GetESDV0Params()->GetMinRTPCdensity();\r
214 const Float_t kMaxRTPCdensity0= AliITSReconstructor::GetRecoParam()->GetESDV0Params()->GetMaxRTPCdensity0();\r
215 const Float_t kMaxRTPCdensity10= AliITSReconstructor::GetRecoParam()->GetESDV0Params()->GetMaxRTPCdensity10();\r
216 const Float_t kMaxRTPCdensity20= AliITSReconstructor::GetRecoParam()->GetESDV0Params()->GetMaxRTPCdensity20();\r
217 const Float_t kMaxRTPCdensity30= AliITSReconstructor::GetRecoParam()->GetESDV0Params()->GetMaxRTPCdensity30();\r
218\r
219\r
220 const Float_t kMinTPCdensity= AliITSReconstructor::GetRecoParam()->GetESDV0Params()->GetMinTPCdensity();\r
221 const Float_t kMinTgl1= AliITSReconstructor::GetRecoParam()->GetESDV0Params()->GetMinTgl1();\r
222\r
223 const Float_t kMinchi2before0= AliITSReconstructor::GetRecoParam()->GetESDV0Params()->GetMinchi2before0();\r
224 const Float_t kMinchi2before1= AliITSReconstructor::GetRecoParam()->GetESDV0Params()->GetMinchi2before1();\r
225 const Float_t kMinchi2after0= AliITSReconstructor::GetRecoParam()->GetESDV0Params()->GetMinchi2after0();\r
226 const Float_t kMinchi2after1= AliITSReconstructor::GetRecoParam()->GetESDV0Params()->GetMinchi2after1();\r
227 const Float_t kAddchi2SharedCl= AliITSReconstructor::GetRecoParam()->GetESDV0Params()->GetAddchi2SharedCl();\r
228 const Float_t kAddchi2NegCl0= AliITSReconstructor::GetRecoParam()->GetESDV0Params()->GetAddchi2NegCl0();\r
229 const Float_t kAddchi2NegCl1= AliITSReconstructor::GetRecoParam()->GetESDV0Params()->GetAddchi2NegCl1();\r
230\r
231 const Float_t kSigp0Par0= AliITSReconstructor::GetRecoParam()->GetESDV0Params()->GetSigp0Par0();\r
232 const Float_t kSigp0Par1= AliITSReconstructor::GetRecoParam()->GetESDV0Params()->GetSigp0Par1();\r
233 const Float_t kSigp0Par2= AliITSReconstructor::GetRecoParam()->GetESDV0Params()->GetSigp0Par2();\r
234\r
235 const Float_t kSigpPar0= AliITSReconstructor::GetRecoParam()->GetESDV0Params()->GetSigpPar0();\r
236 const Float_t kSigpPar1= AliITSReconstructor::GetRecoParam()->GetESDV0Params()->GetSigpPar1();\r
237 const Float_t kSigpPar2= AliITSReconstructor::GetRecoParam()->GetESDV0Params()->GetSigpPar2();\r
238 const Float_t kMaxDcaLh0= AliITSReconstructor::GetRecoParam()->GetESDV0Params()->GetMaxDcaLh0();\r
239\r
240\r
241 TObjArray *trackHypothesys = tracker->GetTrackHypothesys();\r
242 TObjArray *bestHypothesys = tracker->GetBestHypothesys();\r
243 TObjArray *originalTracks = tracker->GetOriginal();\r
244 //\r
245 //\r
246 TTreeSRedirector &cstream = *(tracker->GetDebugStreamer());\r
247 Int_t ntracks = event->GetNumberOfTracks(); \r
248 Int_t nitstracks = trackHypothesys->GetEntriesFast();\r
249 originalTracks->Expand(ntracks);\r
250 trackHypothesys->Expand(ntracks);\r
251 bestHypothesys->Expand(ntracks);\r
252 //\r
253 AliHelix * helixes = new AliHelix[ntracks+2];\r
254 TObjArray trackarray(ntracks+2); //array with tracks - with vertex constrain\r
255 TObjArray trackarrayc(ntracks+2); //array of "best tracks" - without vertex constrain\r
256 TObjArray trackarrayl(ntracks+2); //array of "longest tracks" - without vertex constrain\r
257 //Change from Bool_t to Int_t for optimization\r
258 // Int_t forbN=0;\r
259 // Int_t * forbidden = new Int_t [ntracks+2];\r
260 Bool_t * forbidden = new Bool_t [ntracks+2];\r
261 Int_t *itsmap = new Int_t [ntracks+2];\r
262 Float_t *dist = new Float_t[ntracks+2];\r
263 Float_t *normdist0 = new Float_t[ntracks+2];\r
264 Float_t *normdist1 = new Float_t[ntracks+2];\r
265 Float_t *normdist = new Float_t[ntracks+2];\r
266 Float_t *norm = new Float_t[ntracks+2];\r
267 Float_t *maxr = new Float_t[ntracks+2];\r
268 Float_t *minr = new Float_t[ntracks+2];\r
269 Float_t *minPointAngle= new Float_t[ntracks+2];\r
270 //\r
271 AliV0 *pvertex = new AliV0;\r
272 AliITStrackMI * dummy= new AliITStrackMI;\r
273 dummy->SetLabel(0);\r
274 AliITStrackMI trackat0; //temporary track for DCA calculation\r
275 //\r
276 Float_t primvertex[3]={tracker->GetX(),tracker->GetY(),tracker->GetZ()};\r
277 //\r
278 // make ITS - ESD map\r
279 //\r
280 for (Int_t itrack=0;itrack<ntracks+2;itrack++) {\r
281 itsmap[itrack] = -1;\r
282 // forbidden[itrack] = 0;\r
283 forbidden[itrack] = kFALSE;\r
284 maxr[itrack] = kMaxR;\r
285 minr[itrack] = kMinR;\r
286 minPointAngle[itrack] = kMinPointAngle;\r
287 }\r
288 for (Int_t itrack=0;itrack<nitstracks;itrack++){\r
289 AliITStrackMI * original = (AliITStrackMI*)(originalTracks->At(itrack));\r
290 Int_t esdindex = original->GetESDtrack()->GetID();\r
291 itsmap[esdindex] = itrack;\r
292 }\r
293 //\r
294 // create ITS tracks from ESD tracks if not done before\r
295 //\r
296 for (Int_t itrack=0;itrack<ntracks;itrack++){\r
297 if (itsmap[itrack]>=0) continue;\r
298 AliITStrackMI * tpctrack = new AliITStrackMI(*(event->GetTrack(itrack)));\r
299 //tpctrack->fD[0] = tpctrack->GetD(GetX(),GetY());\r
300 //tpctrack->fD[1] = tpctrack->GetZat(GetX())-GetZ(); \r
301 tpctrack->GetDZ(tracker->GetX(),tracker->GetY(),tracker->GetZ(),tpctrack->GetDP()); //I.B.\r
302 if (tpctrack->GetD(0)<20 && tpctrack->GetD(1)<20){\r
303 // tracks which can reach inner part of ITS\r
304 // propagate track to outer its volume - with correction for material\r
305 AliITStrackerMI::CorrectForTPCtoITSDeadZoneMaterial(tpctrack); \r
306 }\r
307 itsmap[itrack] = nitstracks;\r
308 originalTracks->AddAt(tpctrack,nitstracks);\r
309 nitstracks++;\r
310 }\r
311 //\r
312 // fill temporary arrays\r
313 //\r
314 for (Int_t itrack=0;itrack<ntracks;itrack++){\r
315 AliESDtrack * esdtrack = event->GetTrack(itrack);\r
316 Int_t itsindex = itsmap[itrack];\r
317 AliITStrackMI *original = (AliITStrackMI*)originalTracks->At(itsmap[itrack]);\r
318 if (!original) continue;\r
319 AliITStrackMI *bestConst = 0;\r
320 AliITStrackMI *bestLong = 0;\r
321 AliITStrackMI *best = 0; \r
322 //\r
323 //\r
324 TObjArray * array = (TObjArray*) trackHypothesys->At(itsindex);\r
325 Int_t hentries = (array==0) ? 0 : array->GetEntriesFast();\r
326 // Get best track with vertex constrain\r
327 for (Int_t ih=0;ih<hentries;ih++){\r
328 AliITStrackMI * trackh = (AliITStrackMI*)array->At(ih);\r
329 if (!trackh->GetConstrain()) continue;\r
330 if (!bestConst) bestConst = trackh;\r
331 if (trackh->GetNumberOfClusters()>kMinClFullTrk ){\r
332 bestConst = trackh; // full track - with minimal chi2\r
333 break;\r
334 }\r
335 if (trackh->GetNumberOfClusters()+trackh->GetNDeadZone()<=bestConst->GetNumberOfClusters()+bestConst->GetNDeadZone()) continue; \r
336 bestConst = trackh;\r
337 break;\r
338 }\r
339 // Get best long track without vertex constrain and best track without vertex constrain\r
340 for (Int_t ih=0;ih<hentries;ih++){\r
341 AliITStrackMI * trackh = (AliITStrackMI*)array->At(ih);\r
342 if (trackh->GetConstrain()) continue;\r
343 if (!best) best = trackh;\r
344 if (!bestLong) bestLong = trackh;\r
345 if (trackh->GetNumberOfClusters()>kMinClFullTrk){\r
346 bestLong = trackh; // full track - with minimal chi2\r
347 break;\r
348 }\r
349 if (trackh->GetNumberOfClusters()+trackh->GetNDeadZone()<=bestLong->GetNumberOfClusters()+bestLong->GetNDeadZone()) continue; \r
350 bestLong = trackh; \r
351 }\r
352 if (!best) {\r
353 best = original;\r
354 bestLong = original;\r
355 }\r
356 //I.B. trackat0 = *bestLong;\r
357 new (&trackat0) AliITStrackMI(*bestLong);\r
358 Double_t xx,yy,zz,alpha; \r
359 if (!bestLong->GetGlobalXYZat(bestLong->GetX(),xx,yy,zz)) continue;\r
360 \r
361\r
362 alpha = TMath::ATan2(yy,xx); \r
363 // if (!trackat0.Propagate(alpha,0)) continue; \r
364 // trackat0.Propagate(alpha,0); //PH The check on the return value is temporarily disabled (bug 45751) \r
365 if(!trackat0.Propagate(alpha,0) && kCheckPropagate)continue;\r
366 // calculate normalized distances to the vertex \r
367 //\r
368 Float_t ptfac = (1.+100.*TMath::Abs(trackat0.GetC()));\r
369 if ( bestLong->GetNumberOfClusters()>3 ){ \r
370 dist[itsindex] = trackat0.GetY();\r
371 norm[itsindex] = ptfac*TMath::Sqrt(trackat0.GetSigmaY2());\r
372 normdist0[itsindex] = TMath::Abs(trackat0.GetY()/norm[itsindex]);\r
373 normdist1[itsindex] = TMath::Abs((trackat0.GetZ()-primvertex[2])/(ptfac*TMath::Sqrt(trackat0.GetSigmaZ2())));\r
374 normdist[itsindex] = TMath::Sqrt(normdist0[itsindex]*normdist0[itsindex]+normdist1[itsindex]*normdist1[itsindex]);\r
375 if (!bestConst){\r
376 if (bestLong->GetNumberOfClusters()+bestLong->GetNDeadZone()<6) normdist[itsindex]*=2.;\r
377 if (bestLong->GetNumberOfClusters()+bestLong->GetNDeadZone()<5) normdist[itsindex]*=2.;\r
378 if (bestLong->GetNumberOfClusters()+bestLong->GetNDeadZone()<4) normdist[itsindex]*=2.;\r
379 }else{\r
380 if (bestConst->GetNumberOfClusters()+bestConst->GetNDeadZone()<6) normdist[itsindex]*=1.5;\r
381 if (bestConst->GetNumberOfClusters()+bestConst->GetNDeadZone()<5) normdist[itsindex]*=1.5;\r
382 }\r
383 }\r
384 else{ \r
385 if (bestConst&&bestConst->GetNumberOfClusters()+bestConst->GetNDeadZone()>4.5){\r
386 dist[itsindex] = bestConst->GetD(0);\r
387 norm[itsindex] = bestConst->GetDnorm(0);\r
388 normdist0[itsindex] = TMath::Abs(bestConst->GetD(0)/norm[itsindex]);\r
389 normdist1[itsindex] = TMath::Abs(bestConst->GetD(0)/norm[itsindex]);\r
390 normdist[itsindex] = TMath::Sqrt(normdist0[itsindex]*normdist0[itsindex]+normdist1[itsindex]*normdist1[itsindex]);\r
391 }else{\r
392 dist[itsindex] = trackat0.GetY();\r
393 norm[itsindex] = ptfac*TMath::Sqrt(trackat0.GetSigmaY2());\r
394 normdist0[itsindex] = TMath::Abs(trackat0.GetY()/norm[itsindex]);\r
395 normdist1[itsindex] = TMath::Abs((trackat0.GetZ()-primvertex[2])/(ptfac*TMath::Sqrt(trackat0.GetSigmaZ2())));\r
396 normdist[itsindex] = TMath::Sqrt(normdist0[itsindex]*normdist0[itsindex]+normdist1[itsindex]*normdist1[itsindex]);\r
397 if (TMath::Abs(trackat0.GetTgl())>kMinTgl0){\r
398 if (normdist[itsindex]<kMinNormDistForbTgl0){\r
399 // forbN=1;\r
400 // forbidden[itsindex]+=1<<forbN;\r
401 forbidden[itsindex]=kTRUE;\r
402 }\r
403 if (normdist[itsindex]>kMinNormDistForbTgl0) {\r
404 minr[itsindex] = TMath::Max(kMinRTgl0,minr[itsindex]);\r
405 }\r
406 }\r
407 }\r
408 }\r
409\r
410\r
411 //\r
412 //-----------------------------------------------------------\r
413 //Forbid primary track candidates - \r
414 //\r
415 //treetr->SetAlias("forbidden0","Tr0.fN<4&&Tr1.fN+Tr1.fNDeadZone>4.5");\r
416 //treetr->SetAlias("forbidden1","ND<3&&Tr1.fN+Tr1.fNDeadZone>5.5");\r
417 //treetr->SetAlias("forbidden2","ND<2&&Tr1.fClIndex[0]>0&&Tr1.fClIndex[0]>0");\r
418 //treetr->SetAlias("forbidden3","ND<1&&Tr1.fClIndex[0]>0");\r
419 //treetr->SetAlias("forbidden4","ND<4&&Tr1.fNormChi2[0]<2");\r
420 //treetr->SetAlias("forbidden5","ND<5&&Tr1.fNormChi2[0]<1");\r
421 //-----------------------------------------------------------\r
422 if (bestConst){\r
423 if (bestLong->GetNumberOfClusters()<4 && bestConst->GetNumberOfClusters()+bestConst->GetNDeadZone()>kMinClForb0){\r
424 // forbN=2;\r
425 // forbidden[itsindex]+=1<<forbN;\r
426 forbidden[itsindex]=kTRUE;\r
427 }\r
428 if (normdist[itsindex]<kMinNormDistForb1 && bestConst->GetNumberOfClusters()+bestConst->GetNDeadZone()>5.5){\r
429 // forbN=3;\r
430 // forbidden[itsindex]+=1<<forbN;\r
431 forbidden[itsindex]=kTRUE;\r
432 }\r
433 if (normdist[itsindex]<kMinNormDistForb2 && bestConst->GetClIndex(0)>=0 && bestConst->GetClIndex(1)>=0 ){\r
434 // forbN=4;\r
435 // forbidden[itsindex]+=1<<forbN;\r
436 forbidden[itsindex]=kTRUE;\r
437 }\r
438 if (normdist[itsindex]<kMinNormDistForb3 && bestConst->GetClIndex(0)>=0){\r
439 // forbN=5;\r
440 // forbidden[itsindex]+=1<<forbN;\r
441 forbidden[itsindex]=kTRUE;\r
442 }\r
443 if (normdist[itsindex]<kMinNormDistForb4 && bestConst->GetNormChi2(0)<2){\r
444 // forbN=6;\r
445 // forbidden[itsindex]+=1<<forbN;\r
446 forbidden[itsindex]=kTRUE;\r
447 }\r
448 if (normdist[itsindex]<kMinNormDistForb5 && bestConst->GetNormChi2(0)<1){\r
449 // forbN=7;\r
450 // forbidden[itsindex]+=1<<forbN;\r
451 forbidden[itsindex]=kTRUE;\r
452 }\r
453 if (bestConst->GetNormChi2(0)<2.5) {\r
454 minPointAngle[itsindex]= kMinPABestConst;\r
455 maxr[itsindex] = kMaxRBestConst;\r
456 }\r
457 }\r
458 //\r
459 //forbid daughter kink candidates\r
460 //\r
461 if (esdtrack->GetKinkIndex(0)>0) forbidden[itsindex] = kTRUE;\r
462 Bool_t isElectron = kTRUE;\r
463 Bool_t isProton = kTRUE;\r
464 Double_t pid[5];\r
465 esdtrack->GetESDpid(pid);\r
466 for (Int_t i=1;i<5;i++){\r
467 if (pid[0]<pid[i]) isElectron= kFALSE;\r
468 if (pid[4]<pid[i]) isProton= kFALSE;\r
469 }\r
470 if (isElectron){\r
471 forbidden[itsindex]=kFALSE; \r
472 normdist[itsindex]*=-1;\r
473 }\r
474 if (isProton){\r
475 if (normdist[itsindex]>kMinNormDistForbProt) forbidden[itsindex]=kFALSE; \r
476 normdist[itsindex]*=-1;\r
477 }\r
478\r
479 // We allow all tracks that are not pions\r
480 if( (pid[1]+pid[2])< kMaxPidProbPionForb ){\r
481 forbidden[itsindex]=kFALSE;\r
482 }\r
483\r
484 //\r
485 // Causality cuts in TPC volume\r
486 //\r
487 if (esdtrack->GetTPCdensity(0,10) >kMinTPCdensity) maxr[itsindex] = TMath::Min(Float_t(kMaxRTPCdensity0),maxr[itsindex]);\r
488 if (esdtrack->GetTPCdensity(10,30)>kMinTPCdensity) maxr[itsindex] = TMath::Min(Float_t(kMaxRTPCdensity10),maxr[itsindex]);\r
489 if (esdtrack->GetTPCdensity(20,40)>kMinTPCdensity) maxr[itsindex] = TMath::Min(Float_t(kMaxRTPCdensity20),maxr[itsindex]);\r
490 if (esdtrack->GetTPCdensity(30,50)>kMinTPCdensity) maxr[itsindex] = TMath::Min(Float_t(kMaxRTPCdensity30),maxr[itsindex]);\r
491 //\r
492 if (esdtrack->GetTPCdensity(0,60)<0.4&&bestLong->GetNumberOfClusters()<3) minr[itsindex]=kMinRTPCdensity; \r
493 //\r
494 //\r
495\r
496 if (AliITSReconstructor::GetRecoParam()->GetESDV0Params()->StreamLevel()>0){\r
497 cstream<<"Track"<<\r
498 "Tr0.="<<best<<\r
499 "Tr1.="<<((bestConst)? bestConst:dummy)<<\r
500 "Tr2.="<<bestLong<<\r
501 "Tr3.="<<&trackat0<<\r
502 "Esd.="<<esdtrack<<\r
503 "Dist="<<dist[itsindex]<<\r
504 "ND0="<<normdist0[itsindex]<<\r
505 "ND1="<<normdist1[itsindex]<<\r
506 "ND="<<normdist[itsindex]<<\r
507 "Pz="<<primvertex[2]<<\r
508 "Forbid="<<forbidden[itsindex]<<\r
509 "\n";\r
510 //\r
511 }\r
512 trackarray.AddAt(best,itsindex);\r
513 trackarrayc.AddAt(bestConst,itsindex);\r
514 trackarrayl.AddAt(bestLong,itsindex);\r
515 new (&helixes[itsindex]) AliHelix(*best);\r
516 }\r
517 //\r
518 //\r
519 //\r
520 // first iterration of V0 finder\r
521 //\r
522 // AM Comment out for optimization\r
523 // Int_t rejectBase=0;\r
524 // Int_t cutN=0;\r
525\r
526 for (Int_t iesd0=0;iesd0<ntracks;iesd0++){\r
527 Int_t itrack0 = itsmap[iesd0];\r
528 //-AM comment for optimization and store the forbidden value in the debug streamer\r
529 if (forbidden[itrack0]) continue;\r
530 AliITStrackMI * btrack0 = (AliITStrackMI*)trackarray.At(itrack0);\r
531 if (!btrack0) continue; \r
532 AliITStrackMI *trackc0 = (AliITStrackMI*)trackarrayc.At(itrack0);\r
533 //\r
534 for (Int_t iesd1=iesd0+1;iesd1<ntracks;iesd1++){\r
535 Int_t itrack1 = itsmap[iesd1];\r
536 //-AM comment for optimization and store the forbidden value in the debug streamer\r
537 if (forbidden[itrack1]) continue;\r
538\r
539 AliITStrackMI * btrack1 = (AliITStrackMI*)trackarray.At(itrack1); \r
540 if (!btrack1) continue;\r
541\r
542 if ( (btrack0->GetSign()==btrack1->GetSign()) && !AliITSReconstructor::GetRecoParam()->GetStoreLikeSignV0s()) continue;\r
543\r
544 Bool_t isGold = kFALSE;\r
545 if (TMath::Abs(TMath::Abs(btrack0->GetLabel())-TMath::Abs(btrack1->GetLabel()))==1){\r
546 isGold = kTRUE;\r
547 }\r
548 // rejectBase=0;\r
549 AliITStrackMI *trackc1 = (AliITStrackMI*)trackarrayc.At(itrack1);\r
550 AliHelix &h1 = helixes[itrack0];\r
551 AliHelix &h2 = helixes[itrack1];\r
552 //\r
553 // find linear distance\r
554 Double_t rmin =0;\r
555 //\r
556 //\r
557 //\r
558 Double_t phase[2][2],radius[2];\r
559 Int_t points = h1.GetRPHIintersections(h2, phase, radius);\r
560 if (points==0) {\r
561 // cutN=1;\r
562 // rejectBase+=1<<cutN;\r
563 continue;\r
564 }\r
565 Double_t delta[2]={1000000,1000000}; \r
566 rmin = radius[0];\r
567 h1.ParabolicDCA(h2,phase[0][0],phase[0][1],radius[0],delta[0]);\r
568 if (points==2){ \r
569 if (radius[1]<rmin) rmin = radius[1];\r
570 h1.ParabolicDCA(h2,phase[1][0],phase[1][1],radius[1],delta[1]);\r
571 }\r
572 rmin = TMath::Sqrt(rmin);\r
573 Double_t distance = 0;\r
574 Double_t radiusC = 0;\r
575 Int_t iphase = 0;\r
576 if (points==1 || delta[0]<delta[1]){\r
577 distance = TMath::Sqrt(delta[0]);\r
578 radiusC = TMath::Sqrt(radius[0]);\r
579 }else{\r
580 distance = TMath::Sqrt(delta[1]);\r
581 radiusC = TMath::Sqrt(radius[1]);\r
582 iphase=1;\r
583 }\r
584 if (radiusC<TMath::Max(minr[itrack0],minr[itrack1])){\r
585 // cutN=2;\r
586 //rejectBase+=1<<cutN;\r
587 continue;\r
588 }\r
589 if (radiusC>TMath::Min(maxr[itrack0],maxr[itrack1])){\r
590 // cutN=3;\r
591 // rejectBase+=1<<cutN;\r
592 continue;\r
593 } \r
594 Float_t maxDist = TMath::Min(kMaxDist,Float_t(kMaxDist0+radiusC*kMaxDist1)); \r
595 if (distance>maxDist){\r
596 // cutN=4;\r
597 // rejectBase+=1<<cutN;\r
598 continue;\r
599 }\r
600 Float_t pointAngle = h1.GetPointAngle(h2,phase[iphase],primvertex);\r
601 if (pointAngle<TMath::Max(minPointAngle[itrack0],minPointAngle[itrack1])) {\r
602 // cutN=5;\r
603 // rejectBase+=1<<cutN;\r
604 continue;\r
605 }\r
606 //\r
607 //\r
608 // Double_t distance = TestV0(h1,h2,pvertex,rmin);\r
609 //\r
610 // if (distance>maxDist) continue;\r
611 // if (pvertex->GetRr()<kMinR) continue;\r
612 // if (pvertex->GetRr()>kMaxR) continue;\r
613 AliITStrackMI * track0=btrack0;\r
614 AliITStrackMI * track1=btrack1;\r
615 // if (pvertex->GetRr()<3.5){ \r
616 if (radiusC<3.5){ \r
617 //use longest tracks inside the pipe\r
618 track0 = (AliITStrackMI*)trackarrayl.At(itrack0);\r
619 track1 = (AliITStrackMI*)trackarrayl.At(itrack1);\r
620 } \r
621 //\r
622 //\r
623 \r
624\r
625 \r
626 pvertex->SetParamN(*track0);\r
627 pvertex->SetParamP(*track1);\r
628 pvertex->Update(primvertex);\r
629 pvertex->SetClusters(track0->ClIndex(),track1->ClIndex()); // register clusters\r
630\r
631 // Define gamma, K0, lambda and lambda_bar from the decay particles and calculate the chi2 \r
632 AliKFVertex vertexKF;\r
633\r
634 vertexKF.X() = tracker->GetX();\r
635 vertexKF.Y() = tracker->GetY();\r
636 vertexKF.Z() = tracker->GetZ();\r
637 vertexKF.Covariance(0,0) = tracker->GetSigmaX()*tracker->GetSigmaX();\r
638 vertexKF.Covariance(1,2) = tracker->GetSigmaY()*tracker->GetSigmaY();\r
639 vertexKF.Covariance(2,2) = tracker->GetSigmaZ()*tracker->GetSigmaZ();\r
640 \r
641 AliKFParticle elecKF( *(pvertex->GetParamN()) ,11);\r
642 AliKFParticle posiKF( *(pvertex->GetParamP()) ,-11);\r
643 AliKFParticle pipKF( *(pvertex->GetParamN()) , 211);\r
644 AliKFParticle pinKF( *(pvertex->GetParamP()) ,-211);\r
645 AliKFParticle protKF( *(pvertex->GetParamP()) ,2212);\r
646 AliKFParticle aproKF ( *(pvertex->GetParamN()) ,-2212);\r
647\r
648\r
649 // Gamma\r
650 AliKFParticle gamKF(elecKF,posiKF);\r
651 gamKF.SetProductionVertex(vertexKF);\r
652\r
653 Float_t gamKFchi2 = 1000;\r
654 if ( gamKF.GetNDF()!=0 ){\r
655 gamKFchi2 = gamKF.GetChi2()/gamKF.GetNDF();\r
656 }\r
657\r
658 Float_t massG=0.;\r
659 Float_t sigmaMG=0.001;\r
660 gamKF.SetMassConstraint(massG,sigmaMG);\r
661\r
662 Float_t gamKFchi2C = 1000;\r
663 if ( gamKF.GetNDF()!=0 ){\r
664 gamKFchi2C = gamKF.GetChi2()/gamKF.GetNDF();\r
665 }\r
666\r
667 //K0 short\r
668 AliKFParticle k0KF(pipKF,pinKF);\r
669 k0KF.SetProductionVertex(vertexKF);\r
670\r
671 Float_t k0KFchi2 = 1000;\r
672 if ( k0KF.GetNDF()!=0 ){\r
673 k0KFchi2 = k0KF.GetChi2()/k0KF.GetNDF();\r
674 }\r
675\r
676 //Lambda\r
677 AliKFParticle lambdaKF(protKF,pinKF);\r
678 lambdaKF.SetProductionVertex(vertexKF);\r
679\r
680 Float_t lambdaKFchi2 = 1000;\r
681 if ( lambdaKF.GetNDF()!=0 ){\r
682 lambdaKFchi2 = lambdaKF.GetChi2()/lambdaKF.GetNDF();\r
683 }\r
684\r
685 //Lambda_bar\r
686 AliKFParticle alambKF(aproKF,pipKF);\r
687 alambKF.SetProductionVertex(vertexKF);\r
688\r
689 Float_t alambKFchi2 = 1000;\r
690 if ( alambKF.GetNDF()!=0 ){\r
691 alambKFchi2 = alambKF.GetChi2()/alambKF.GetNDF();\r
692 }\r
693\r
694\r
695\r
696\r
697\r
698 if (pvertex->GetRr()<kMinR){\r
699 // cutN=6;\r
700 // rejectBase+=1<<cutN;\r
701 continue;\r
702 }\r
703 if (pvertex->GetRr()>kMaxR){\r
704 // cutN=7;\r
705 // rejectBase+=1<<cutN;\r
706 continue;\r
707 }\r
708 if (pvertex->GetV0CosineOfPointingAngle()<kMinPointAngle){\r
709 // cutN=8;\r
710 // rejectBase+=1<<cutN;\r
711 continue;\r
712 }\r
713//Bo: if (pvertex->GetDist2()>maxDist) continue;\r
714\r
715 if (pvertex->GetDcaV0Daughters()>maxDist){\r
716 // cutN=9;\r
717 // rejectBase+=1<<cutN;\r
718 continue;\r
719 }\r
720//Bo: pvertex->SetLab(0,track0->GetLabel());\r
721//Bo: pvertex->SetLab(1,track1->GetLabel());\r
722 pvertex->SetIndex(0,track0->GetESDtrack()->GetID());\r
723 pvertex->SetIndex(1,track1->GetESDtrack()->GetID());\r
724 // \r
725 AliITStrackMI * htrackc0 = trackc0 ? trackc0:dummy; \r
726 AliITStrackMI * htrackc1 = trackc1 ? trackc1:dummy;\r
727\r
728 //\r
729 //\r
730 TObjArray * array0b = (TObjArray*)bestHypothesys->At(itrack0);\r
731 if (!array0b&&pvertex->GetRr()<40 && TMath::Abs(track0->GetTgl())<kMinTgl1) {\r
732 tracker->SetCurrentEsdTrack(itrack0);\r
733 tracker->FollowProlongationTree((AliITStrackMI*)originalTracks->At(itrack0),itrack0, kFALSE);\r
734 }\r
735 TObjArray * array1b = (TObjArray*)bestHypothesys->At(itrack1);\r
736 if (!array1b&&pvertex->GetRr()<40 && TMath::Abs(track1->GetTgl())<kMinTgl1) { \r
737 tracker->SetCurrentEsdTrack(itrack1);\r
738 tracker->FollowProlongationTree((AliITStrackMI*)originalTracks->At(itrack1),itrack1, kFALSE);\r
739 }\r
740 //\r
741 AliITStrackMI * track0b = (AliITStrackMI*)originalTracks->At(itrack0);\r
742 AliITStrackMI * track1b = (AliITStrackMI*)originalTracks->At(itrack1);\r
743 AliITStrackMI * track0l = (AliITStrackMI*)originalTracks->At(itrack0);\r
744 AliITStrackMI * track1l = (AliITStrackMI*)originalTracks->At(itrack1);\r
745 \r
746 Float_t minchi2before0=kMinchi2before0;\r
747 Float_t minchi2before1=kMinchi2before1;\r
748 Float_t minchi2after0 =kMinchi2after0;\r
749 Float_t minchi2after1 =kMinchi2after1;\r
750 Double_t xrp[3]; pvertex->GetXYZ(xrp[0],xrp[1],xrp[2]); //I.B.\r
751 Int_t maxLayer = tracker->GetNearestLayer(xrp); //I.B.\r
752 \r
753 if (array0b) for (Int_t i=0;i<5;i++){\r
754 // best track after vertex\r
755 AliITStrackMI * btrack = (AliITStrackMI*)array0b->At(i);\r
756 if (!btrack) continue;\r
757 if (btrack->GetNumberOfClusters()>track0l->GetNumberOfClusters()) track0l = btrack; \r
758 // if (btrack->fX<pvertex->GetRr()-2.-0.5/(0.1+pvertex->GetAnglep()[2])) {\r
759 if (btrack->GetX()<pvertex->GetRr()-2.) {\r
760 if ( (maxLayer>i+2|| (i==0)) && btrack->GetNumberOfClusters()==(6-i)&&i<3){\r
761 Float_t sumchi2= 0;\r
762 Float_t sumn = 0;\r
763 if (maxLayer<3){ // take prim vertex as additional measurement\r
764 if (normdist[itrack0]>0 && htrackc0){\r
765 sumchi2 += TMath::Min((3.-maxLayer)*normdist[itrack0]*normdist[itrack0],16.);\r
766 }else{\r
767 sumchi2 += TMath::Min((3.-maxLayer)*(3*normdist[itrack0]*normdist[itrack0]+3.),16.);\r
768 }\r
769 sumn += 3-maxLayer;\r
770 }\r
771 for (Int_t ilayer=i;ilayer<maxLayer;ilayer++){\r
772 sumn+=1.; \r
773 if (btrack->GetClIndex(ilayer)<0){\r
774 sumchi2+=kAddchi2NegCl0;\r
775 continue;\r
776 }else{\r
777 Int_t c=( btrack->GetClIndex(ilayer) & 0x0fffffff);\r
778 for (Int_t itrack=0;itrack<4;itrack++){\r
779 AliITStrackerMI::AliITSlayer &layer=tracker->GetLayer(ilayer);\r
780 if (layer.GetClusterTracks(itrack,c)>=0 && layer.GetClusterTracks(itrack,c)!=itrack0){\r
781 sumchi2+=kAddchi2SharedCl; //shared cluster\r
782 break;\r
783 }\r
784 }\r
785 sumchi2+=btrack->GetDy(ilayer)*btrack->GetDy(ilayer)/(btrack->GetSigmaY(ilayer)*btrack->GetSigmaY(ilayer));\r
786 sumchi2+=btrack->GetDz(ilayer)*btrack->GetDz(ilayer)/(btrack->GetSigmaZ(ilayer)*btrack->GetSigmaZ(ilayer)); \r
787 }\r
788 }\r
789 sumchi2/=sumn;\r
790 if (sumchi2<minchi2before0) minchi2before0=sumchi2; \r
791 }\r
792 continue; //safety space - Geo manager will give exact layer\r
793 }\r
794 track0b = btrack;\r
795 minchi2after0 = btrack->GetNormChi2(i);\r
796 break;\r
797 }\r
798 if (array1b) for (Int_t i=0;i<5;i++){\r
799 // best track after vertex\r
800 AliITStrackMI * btrack = (AliITStrackMI*)array1b->At(i);\r
801 if (!btrack) continue;\r
802 if (btrack->GetNumberOfClusters()>track1l->GetNumberOfClusters()) track1l = btrack; \r
803 // if (btrack->fX<pvertex->GetRr()-2-0.5/(0.1+pvertex->GetAnglep()[2])){\r
804 if (btrack->GetX()<pvertex->GetRr()-2){\r
805 if ((maxLayer>i+2 || (i==0))&&btrack->GetNumberOfClusters()==(6-i)&&(i<3)){\r
806 Float_t sumchi2= 0;\r
807 Float_t sumn = 0;\r
808 if (maxLayer<3){ // take prim vertex as additional measurement\r
809 if (normdist[itrack1]>0 && htrackc1){\r
810 sumchi2 += TMath::Min((3.-maxLayer)*normdist[itrack1]*normdist[itrack1],16.);\r
811 }else{\r
812 sumchi2 += TMath::Min((3.-maxLayer)*(3*normdist[itrack1]*normdist[itrack1]+3.),16.);\r
813 }\r
814 sumn += 3-maxLayer;\r
815 }\r
816 for (Int_t ilayer=i;ilayer<maxLayer;ilayer++){\r
817 sumn+=1.;\r
818 if (btrack->GetClIndex(ilayer)<0){\r
819 sumchi2+=kAddchi2NegCl1;\r
820 continue;\r
821 }else{\r
822 Int_t c=( btrack->GetClIndex(ilayer) & 0x0fffffff);\r
823 for (Int_t itrack=0;itrack<4;itrack++){\r
824 AliITStrackerMI::AliITSlayer &layer=tracker->GetLayer(ilayer);\r
825 if (layer.GetClusterTracks(itrack,c)>=0 && layer.GetClusterTracks(itrack,c)!=itrack1){\r
826 sumchi2+=kAddchi2SharedCl; //shared cluster\r
827 break;\r
828 }\r
829 }\r
830 sumchi2+=btrack->GetDy(ilayer)*btrack->GetDy(ilayer)/(btrack->GetSigmaY(ilayer)*btrack->GetSigmaY(ilayer));\r
831 sumchi2+=btrack->GetDz(ilayer)*btrack->GetDz(ilayer)/(btrack->GetSigmaZ(ilayer)*btrack->GetSigmaZ(ilayer)); \r
832 }\r
833 }\r
834 sumchi2/=sumn;\r
835 if (sumchi2<minchi2before1) minchi2before1=sumchi2; \r
836 }\r
837 continue; //safety space - Geo manager will give exact layer \r
838 }\r
839 track1b = btrack;\r
840 minchi2after1 = btrack->GetNormChi2(i);\r
841 break;\r
842 }\r
843 //\r
844 // position resolution - used for DCA cut\r
845 Float_t sigmad = track0b->GetSigmaY2()+track0b->GetSigmaZ2()+track1b->GetSigmaY2()+track1b->GetSigmaZ2()+\r
846 (track0b->GetX()-pvertex->GetRr())*(track0b->GetX()-pvertex->GetRr())*(track0b->GetSigmaSnp2()+track0b->GetSigmaTgl2())+\r
847 (track1b->GetX()-pvertex->GetRr())*(track1b->GetX()-pvertex->GetRr())*(track1b->GetSigmaSnp2()+track1b->GetSigmaTgl2());\r
848 sigmad =TMath::Sqrt(sigmad)+0.04;\r
849 if (pvertex->GetRr()>50){\r
850 Double_t cov0[15],cov1[15];\r
851 track0b->GetESDtrack()->GetInnerExternalCovariance(cov0);\r
852 track1b->GetESDtrack()->GetInnerExternalCovariance(cov1);\r
853 sigmad = cov0[0]+cov0[2]+cov1[0]+cov1[2]+\r
854 (80.-pvertex->GetRr())*(80.-pvertex->GetRr())*(cov0[5]+cov0[9])+\r
855 (80.-pvertex->GetRr())*(80.-pvertex->GetRr())*(cov1[5]+cov1[9]);\r
856 sigmad =TMath::Sqrt(sigmad)+0.05;\r
857 }\r
858 // \r
859 AliV0 vertex2;\r
860 vertex2.SetParamN(*track0b);\r
861 vertex2.SetParamP(*track1b);\r
862 vertex2.Update(primvertex);\r
863 //Bo: if (vertex2.GetDist2()<=pvertex->GetDist2()&&(vertex2.GetV0CosineOfPointingAngle()>=pvertex->GetV0CosineOfPointingAngle())){\r
864 if (vertex2.GetDcaV0Daughters()<=pvertex->GetDcaV0Daughters()&&(vertex2.GetV0CosineOfPointingAngle()>=pvertex->GetV0CosineOfPointingAngle())){\r
865 pvertex->SetParamN(*track0b);\r
866 pvertex->SetParamP(*track1b);\r
867 pvertex->Update(primvertex);\r
868 pvertex->SetClusters(track0b->ClIndex(),track1b->ClIndex()); // register clusters\r
869 pvertex->SetIndex(0,track0->GetESDtrack()->GetID());\r
870 pvertex->SetIndex(1,track1->GetESDtrack()->GetID());\r
871 }\r
872 pvertex->SetDistSigma(sigmad);\r
873 //Bo: pvertex->SetDistNorm(pvertex->GetDist2()/sigmad); \r
874 pvertex->SetNormDCAPrim(normdist[itrack0],normdist[itrack1]);\r
875 //\r
876 // define likelihhod and causalities\r
877 //\r
878 Float_t pa0=1, pa1=1, pb0=0.26, pb1=0.26; \r
879 if (maxLayer<1){\r
880 Float_t fnorm0 = normdist[itrack0];\r
881 if (fnorm0<0) fnorm0*=-3;\r
882 Float_t fnorm1 = normdist[itrack1];\r
883 if (fnorm1<0) fnorm1*=-3;\r
884 if ((pvertex->GetAnglep()[2]>0.1) || ( (pvertex->GetRr()<10.5)&& pvertex->GetAnglep()[2]>0.05 ) || (pvertex->GetRr()<3)){\r
885 pb0 = TMath::Exp(-TMath::Min(fnorm0,Float_t(16.))/12.);\r
886 pb1 = TMath::Exp(-TMath::Min(fnorm1,Float_t(16.))/12.);\r
887 }\r
888 pvertex->SetChi2Before(normdist[itrack0]);\r
889 pvertex->SetChi2After(normdist[itrack1]); \r
890 pvertex->SetNAfter(0);\r
891 pvertex->SetNBefore(0);\r
892 }else{\r
893 pvertex->SetChi2Before(minchi2before0);\r
894 pvertex->SetChi2After(minchi2before1);\r
895 if (pvertex->GetAnglep()[2]>0.1 || ( pvertex->GetRr()<10.5 && pvertex->GetAnglep()[2]>0.05) || pvertex->GetRr()<3){\r
896 pb0 = TMath::Exp(-TMath::Min(minchi2before0,Float_t(16))/12.);\r
897 pb1 = TMath::Exp(-TMath::Min(minchi2before1,Float_t(16))/12.);\r
898 }\r
899 pvertex->SetNAfter(maxLayer);\r
900 pvertex->SetNBefore(maxLayer); \r
901 }\r
902 if (pvertex->GetRr()<90){\r
903 pa0 *= TMath::Min(track0->GetESDtrack()->GetTPCdensity(0,60),Double_t(1.));\r
904 pa1 *= TMath::Min(track1->GetESDtrack()->GetTPCdensity(0,60),Double_t(1.));\r
905 }\r
906 if (pvertex->GetRr()<20){\r
907 pa0 *= (0.2+TMath::Exp(-TMath::Min(minchi2after0,Float_t(16))/8.))/1.2;\r
908 pa1 *= (0.2+TMath::Exp(-TMath::Min(minchi2after1,Float_t(16))/8.))/1.2;\r
909 }\r
910 //\r
911 pvertex->SetCausality(pb0,pb1,pa0,pa1);\r
912 //\r
913 // Likelihood calculations - apply cuts\r
914 // \r
915 \r
916 // AM - Comment out for optimization and store the v0OK value\r
917 // Int_t v0OK = 0;\r
918 // Int_t cutOKN=0;\r
919 Bool_t v0OK = kTRUE;\r
920\r
921\r
922 Float_t p12 = pvertex->GetParamP()->GetParameter()[4]*pvertex->GetParamP()->GetParameter()[4];\r
923 p12 += pvertex->GetParamN()->GetParameter()[4]*pvertex->GetParamN()->GetParameter()[4];\r
924 p12 = TMath::Sqrt(p12); // "mean" momenta\r
925\r
926 Float_t sigmap0 = kSigp0Par0+kSigp0Par1/(kSigp0Par2+pvertex->GetRr()); \r
927 Float_t sigmap = kSigpPar0*sigmap0*(kSigpPar1+kSigpPar2*p12); // "resolution: of point angle - as a function of radius and momenta\r
928\r
929\r
930 Float_t causalityA = (1.0-pvertex->GetCausalityP()[0])*(1.0-pvertex->GetCausalityP()[1]);\r
931 Float_t causalityB = TMath::Sqrt(TMath::Min(pvertex->GetCausalityP()[2],Double_t(0.7))*\r
932 TMath::Min(pvertex->GetCausalityP()[3],Double_t(0.7)));\r
933 //\r
934 //Bo: Float_t likelihood0 = (TMath::Exp(-pvertex->GetDistNorm())+0.1) *(pvertex->GetDist2()<0.5)*(pvertex->GetDistNorm()<5);\r
935 Float_t lDistNorm = pvertex->GetDcaV0Daughters()/pvertex->GetDistSigma();\r
936 Float_t likelihood0 = (TMath::Exp(-lDistNorm)+0.1) *(pvertex->GetDcaV0Daughters()<kMaxDcaLh0)*(lDistNorm<5);\r
937\r
938 Float_t likelihood1 = TMath::Exp(-(1.0001-pvertex->GetV0CosineOfPointingAngle())/sigmap)+\r
939 0.4*TMath::Exp(-(1.0001-pvertex->GetV0CosineOfPointingAngle())/(4.*sigmap))+\r
940 0.4*TMath::Exp(-(1.0001-pvertex->GetV0CosineOfPointingAngle())/(8.*sigmap))+\r
941 0.1*TMath::Exp(-(1.0001-pvertex->GetV0CosineOfPointingAngle())/0.01);\r
942 //\r
943 if (causalityA<kCausality0Cut){\r
944 // cutOKN=1;\r
945 // v0OK += 1<<cutOKN;\r
946 v0OK = kFALSE;\r
947 }\r
948 if (TMath::Sqrt(likelihood0*likelihood1)<kLikelihood01Cut){\r
949 // cutOKN=2;\r
950 // v0OK += 1<<cutOKN;\r
951 v0OK = kFALSE;\r
952 }\r
953 if (likelihood1<kLikelihood1Cut){\r
954 // cutOKN=3;\r
955 // v0OK += 1<<cutOKN;\r
956 v0OK = kFALSE;\r
957 }\r
958 if (TMath::Power(likelihood0*likelihood1*causalityB,0.33)<kCombinedCut){\r
959 // cutOKN=4;\r
960 // v0OK += 1<<cutOKN;\r
961 v0OK = kFALSE;\r
962 }\r
963 //\r
964 //\r
965 if (AliITSReconstructor::GetRecoParam()->GetESDV0Params()->StreamLevel()>0){ \r
966 Bool_t gold = TMath::Abs(TMath::Abs(track0->GetLabel())-TMath::Abs(track1->GetLabel()))==1;\r
967 cstream<<"It0"<<\r
968 "Tr0.="<<track0<< //best without constrain\r
969 "Tr1.="<<track1<< //best without constrain \r
970 "posiKF.="<<&posiKF<< //KF from track0\r
971 "elecKF.="<<&elecKF<< //KF from track1\r
972 "Tr0B.="<<track0b<< //best without constrain after vertex\r
973 "Tr1B.="<<track1b<< //best without constrain after vertex \r
974 "Tr0C.="<<htrackc0<< //best with constrain if exist\r
975 "Tr1C.="<<htrackc1<< //best with constrain if exist\r
976 "Tr0L.="<<track0l<< //longest best \r
977 "Tr1L.="<<track1l<< //longest best\r
978 "Esd0.="<<track0->GetESDtrack()<< // esd track0 params\r
979 "Esd1.="<<track1->GetESDtrack()<< // esd track1 params\r
980 "V0.="<<pvertex<< //vertex properties\r
981 "V0b.="<<&vertex2<< //vertex properties at "best" track\r
982 "gamKF.="<<&gamKF<< //KF from pvertex\r
983 "k0KF.="<<&k0KF<< //KF from pvertex\r
984 "lambdaKF.="<<&lambdaKF<< //KF from pvertex\r
985 "alambKF.="<<&lambdaKF<< //KF from pvertex\r
986 "gamKFchi2="<<gamKFchi2<< //Normalized chi2 from KF assuming gamma momther\r
987 "gamKFchi2C="<<gamKFchi2C<< //Normalized chi2 from KF assuming gamma mother+mass constraint\r
988 "k0KFchi2="<<k0KFchi2<< //Normalized chi2 from KF assuming K0 mother\r
989 "lambdaKFchi2="<<lambdaKFchi2<< //Normalized chi2 from KF assuming Lambda mother\r
990 "alambKFchi2="<<alambKFchi2<< //Normalized chi2 from KF assuming lambda_bar mother\r
991 "ND0="<<normdist[itrack0]<< //normalize distance for track0\r
992 "ND1="<<normdist[itrack1]<< //normalize distance for track1\r
993 "Gold="<<gold<< //\r
994 // "RejectBase="<<rejectBase<< //rejection in First itteration\r
995 "OK="<<v0OK<<\r
996 "rmin="<<rmin<<\r
997 "sigmad="<<sigmad<<\r
998 "Forbid0="<<forbidden[itrack0]<<\r
999 "Forbid1="<<forbidden[itrack1]<<\r
1000 "\n";\r
1001 } \r
1002 // if (rejectBase>0) continue;\r
1003 //if (forbidden[itrack0]>0 ||forbidden[itrack1]>0) continue; \r
1004 //\r
1005 pvertex->SetStatus(0);\r
1006 // if (rejectBase) {\r
1007 // pvertex->SetStatus(-100);\r
1008 //}\r
1009 if (pvertex->GetV0CosineOfPointingAngle()>kMinPointAngle2) {\r
1010 //Bo: pvertex->SetESDindexes(track0->GetESDtrack()->GetID(),track1->GetESDtrack()->GetID());\r
1011 pvertex->SetIndex(0,track0->GetESDtrack()->GetID());//Bo: consistency 0 for neg\r
1012 pvertex->SetIndex(1,track1->GetESDtrack()->GetID());//Bo: consistency 1 for pos\r
1013 // if (v0OK==0){\r
1014 if (v0OK){\r
1015 // AliV0vertex vertexjuri(*track0,*track1);\r
1016 // vertexjuri.SetESDindexes(track0->fESDtrack->GetID(),track1->fESDtrack->GetID());\r
1017 // event->AddV0(&vertexjuri);\r
1018 pvertex->SetStatus(100);\r
1019 }\r
1020 pvertex->SetOnFlyStatus(kTRUE);\r
1021 pvertex->ChangeMassHypothesis(kK0Short);\r
1022 event->AddV0(pvertex);\r
1023 }\r
1024 }\r
1025 }\r
1026 //\r
1027 //\r
1028 // delete temporary arrays\r
1029 // \r
1030 delete[] forbidden;\r
1031 delete[] minPointAngle;\r
1032 delete[] maxr;\r
1033 delete[] minr;\r
1034 delete[] norm;\r
1035 delete[] normdist;\r
1036 delete[] normdist1;\r
1037 delete[] normdist0;\r
1038 delete[] dist;\r
1039 delete[] itsmap;\r
1040 delete[] helixes;\r
1041 delete pvertex;\r
1042}\r
1043//------------------------------------------------------------------------\r
1044void AliITSV0Finder::RefitV02(const AliESDEvent *event,\r
1045 AliITStrackerMI *tracker) \r
1046{\r
1047 //\r
1048 //try to refit V0s in the third path of the reconstruction\r
1049 //\r
1050 TTreeSRedirector &cstream = *(tracker->GetDebugStreamer());\r
1051 //\r
1052 Int_t nv0s = event->GetNumberOfV0s();\r
1053 Float_t primvertex[3]={tracker->GetX(),tracker->GetY(),tracker->GetZ()};\r
1054 AliV0 v0temp;\r
1055 for (Int_t iv0 = 0; iv0<nv0s;iv0++){\r
1056 AliV0 * v0mi = (AliV0*)event->GetV0(iv0);\r
1057 if (!v0mi) continue;\r
1058 Int_t itrack0 = v0mi->GetIndex(0);\r
1059 Int_t itrack1 = v0mi->GetIndex(1);\r
1060 AliESDtrack *esd0 = event->GetTrack(itrack0);\r
1061 AliESDtrack *esd1 = event->GetTrack(itrack1);\r
1062 if (!esd0||!esd1) continue;\r
1063 AliITStrackMI tpc0(*esd0); \r
1064 AliITStrackMI tpc1(*esd1);\r
1065 Double_t x,y,z; v0mi->GetXYZ(x,y,z); //I.B. \r
1066 Double_t alpha =TMath::ATan2(y,x); //I.B.\r
1067 if (v0mi->GetRr()>85){\r
1068 if (tpc0.Propagate(alpha,v0mi->GetRr())&&tpc1.Propagate(alpha,v0mi->GetRr())){\r
1069 v0temp.SetParamN(tpc0);\r
1070 v0temp.SetParamP(tpc1);\r
1071 v0temp.Update(primvertex);\r
1072 if (AliITSReconstructor::GetRecoParam()->GetESDV0Params()->StreamLevel()>0) cstream<<"Refit"<<\r
1073 "V0.="<<v0mi<<\r
1074 "V0refit.="<<&v0temp<<\r
1075 "Tr0.="<<&tpc0<<\r
1076 "Tr1.="<<&tpc1<<\r
1077 "\n";\r
1078 //Bo: if (v0temp.GetDist2()<v0mi->GetDist2() || v0temp.GetV0CosineOfPointingAngle()>v0mi->GetV0CosineOfPointingAngle()){\r
1079 if (v0temp.GetDcaV0Daughters()<v0mi->GetDcaV0Daughters() || v0temp.GetV0CosineOfPointingAngle()>v0mi->GetV0CosineOfPointingAngle()){\r
1080 v0mi->SetParamN(tpc0);\r
1081 v0mi->SetParamP(tpc1);\r
1082 v0mi->Update(primvertex);\r
1083 }\r
1084 }\r
1085 continue;\r
1086 }\r
1087 if (v0mi->GetRr()>35){\r
1088 AliITStrackerMI::CorrectForTPCtoITSDeadZoneMaterial(&tpc0);\r
1089 AliITStrackerMI::CorrectForTPCtoITSDeadZoneMaterial(&tpc1);\r
1090 if (tpc0.Propagate(alpha,v0mi->GetRr())&&tpc1.Propagate(alpha,v0mi->GetRr())){\r
1091 v0temp.SetParamN(tpc0);\r
1092 v0temp.SetParamP(tpc1);\r
1093 v0temp.Update(primvertex);\r
1094 if (AliITSReconstructor::GetRecoParam()->GetESDV0Params()->StreamLevel()>0) cstream<<"Refit"<<\r
1095 "V0.="<<v0mi<<\r
1096 "V0refit.="<<&v0temp<<\r
1097 "Tr0.="<<&tpc0<<\r
1098 "Tr1.="<<&tpc1<<\r
1099 "\n";\r
1100 //Bo: if (v0temp.GetDist2()<v0mi->GetDist2() || v0temp.GetV0CosineOfPointingAngle()>v0mi->GetV0CosineOfPointingAngle()){\r
1101 if (v0temp.GetDcaV0Daughters()<v0mi->GetDcaV0Daughters() || v0temp.GetV0CosineOfPointingAngle()>v0mi->GetV0CosineOfPointingAngle()){\r
1102 v0mi->SetParamN(tpc0);\r
1103 v0mi->SetParamP(tpc1);\r
1104 v0mi->Update(primvertex);\r
1105 } \r
1106 }\r
1107 continue;\r
1108 }\r
1109 AliITStrackerMI::CorrectForTPCtoITSDeadZoneMaterial(&tpc0);\r
1110 AliITStrackerMI::CorrectForTPCtoITSDeadZoneMaterial(&tpc1); \r
1111 // if (tpc0.Propagate(alpha,v0mi->GetRr())&&tpc1.Propagate(alpha,v0mi->GetRr())){\r
1112 if (tracker->RefitAt(v0mi->GetRr(),&tpc0, v0mi->GetClusters(0)) && \r
1113 tracker->RefitAt(v0mi->GetRr(),&tpc1, v0mi->GetClusters(1))){\r
1114 v0temp.SetParamN(tpc0);\r
1115 v0temp.SetParamP(tpc1);\r
1116 v0temp.Update(primvertex);\r
1117 if (AliITSReconstructor::GetRecoParam()->GetESDV0Params()->StreamLevel()>0) cstream<<"Refit"<<\r
1118 "V0.="<<v0mi<<\r
1119 "V0refit.="<<&v0temp<<\r
1120 "Tr0.="<<&tpc0<<\r
1121 "Tr1.="<<&tpc1<<\r
1122 "\n";\r
1123 //Bo: if (v0temp.GetDist2()<v0mi->GetDist2() || v0temp.GetV0CosineOfPointingAngle()>v0mi->GetV0CosineOfPointingAngle()){\r
1124 if (v0temp.GetDcaV0Daughters()<v0mi->GetDcaV0Daughters() || v0temp.GetV0CosineOfPointingAngle()>v0mi->GetV0CosineOfPointingAngle()){\r
1125 v0mi->SetParamN(tpc0);\r
1126 v0mi->SetParamP(tpc1);\r
1127 v0mi->Update(primvertex);\r
1128 } \r
1129 } \r
1130 }\r
1131}\r
1132//------------------------------------------------------------------------\r
1133\r
1134\r
1135AliITSV0Finder::~AliITSV0Finder()\r
1136{\r
1137 //\r
1138 //destructor\r
1139 //\r
1140 if (fDebugStreamer) {\r
1141 //fDebugStreamer->Close();\r
1142 delete fDebugStreamer;\r
1143 }\r
1144\r
1145}\r