e43c066c |
1 | /************************************************************************** |
9a5326b1 |
2 | * Copyright(c) 2007-2009, ALICE Experiment at CERN, All rights reserved. * |
e43c066c |
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 | **************************************************************************/ |
9a5326b1 |
15 | /* $Id$ */ |
bf6adc12 |
16 | |
e43c066c |
17 | //------------------------------------------------------------------------- |
18 | // Implementation of the ITS tracker class |
00a7cc50 |
19 | // It reads AliITSRecPoint clusters and creates AliITStrackMI tracks |
e43c066c |
20 | // and fills with them the ESD |
15dd636f |
21 | // Origin: Marian Ivanov, CERN, Marian.Ivanov@cern.ch |
afd25725 |
22 | // dE/dx analysis by: Boris Batyunya, JINR, Boris.Batiounia@cern.ch |
23 | // Params moved to AliITSRecoParam by: Andrea Dainese, INFN |
24 | // Material budget from TGeo by: Ludovic Gaudichet & Andrea Dainese, INFN |
e43c066c |
25 | //------------------------------------------------------------------------- |
bf6adc12 |
26 | |
27 | #include <TMatrixD.h> |
e43c066c |
28 | #include <TTree.h> |
bf6adc12 |
29 | #include <TTreeStream.h> |
afd25725 |
30 | #include <TDatabasePDG.h> |
9a5326b1 |
31 | #include <TString.h> |
e50912db |
32 | #include <TRandom.h> |
afd25725 |
33 | |
bf6adc12 |
34 | |
af885e0f |
35 | #include "AliESDEvent.h" |
aad72f45 |
36 | #include "AliESDtrack.h" |
9a5326b1 |
37 | #include "AliESDVertex.h" |
6c94f330 |
38 | #include "AliV0.h" |
bf6adc12 |
39 | #include "AliHelix.h" |
00a7cc50 |
40 | #include "AliITSRecPoint.h" |
e341247d |
41 | #include "AliITSgeomTGeo.h" |
e43c066c |
42 | #include "AliITStrackerMI.h" |
44347160 |
43 | #include "AliITSReconstructor.h" |
df29e9a4 |
44 | #include "AliTrackPointArray.h" |
45 | #include "AliAlignObj.h" |
572f41f9 |
46 | #include "AliITSClusterParam.h" |
4a66240a |
47 | #include "AliITSPlaneEff.h" |
e43c066c |
48 | |
49 | ClassImp(AliITStrackerMI) |
e43c066c |
50 | |
e50912db |
51 | AliITStrackerMI::AliITSlayer AliITStrackerMI::fgLayers[AliITSgeomTGeo::kNLayers]; // ITS layers |
44347160 |
52 | |
8221b41b |
53 | AliITStrackerMI::AliITStrackerMI():AliTracker(), |
54 | fI(0), |
55 | fBestTrack(), |
56 | fTrackToFollow(), |
57 | fTrackHypothesys(), |
58 | fBestHypothesys(), |
59 | fOriginal(), |
60 | fCurrentEsdTrack(), |
61 | fPass(0), |
62 | fAfterV0(kFALSE), |
63 | fLastLayerToTrackTo(0), |
afd25725 |
64 | fCoefficients(0), |
8221b41b |
65 | fEsd(0), |
e50912db |
66 | fTrackingPhase("Default"), |
6518a6c5 |
67 | fUseTGeo(3), |
e50912db |
68 | fNtracks(0), |
69 | fxOverX0Pipe(-1.), |
70 | fxTimesRhoPipe(-1.), |
71 | fxOverX0PipeTrks(0), |
72 | fxTimesRhoPipeTrks(0), |
73 | fxOverX0ShieldTrks(0), |
74 | fxTimesRhoShieldTrks(0), |
75 | fxOverX0LayerTrks(0), |
76 | fxTimesRhoLayerTrks(0), |
4a66240a |
77 | fDebugStreamer(0), |
78 | fPlaneEff(0){ |
8221b41b |
79 | //Default constructor |
e50912db |
80 | Int_t i; |
81 | for(i=0;i<4;i++) fSPDdetzcentre[i]=0.; |
82 | for(i=0;i<2;i++) {fxOverX0Shield[i]=-1.;fxTimesRhoShield[i]=-1.;} |
83 | for(i=0;i<6;i++) {fxOverX0Layer[i]=-1.;fxTimesRhoLayer[i]=-1.;} |
8221b41b |
84 | } |
44347160 |
85 | //------------------------------------------------------------------------ |
1f3e997f |
86 | AliITStrackerMI::AliITStrackerMI(const Char_t *geom) : AliTracker(), |
e50912db |
87 | fI(AliITSgeomTGeo::GetNLayers()), |
8221b41b |
88 | fBestTrack(), |
89 | fTrackToFollow(), |
90 | fTrackHypothesys(), |
91 | fBestHypothesys(), |
92 | fOriginal(), |
93 | fCurrentEsdTrack(), |
94 | fPass(0), |
95 | fAfterV0(kFALSE), |
e50912db |
96 | fLastLayerToTrackTo(AliITSRecoParam::GetLastLayerToTrackTo()), |
afd25725 |
97 | fCoefficients(0), |
8221b41b |
98 | fEsd(0), |
e50912db |
99 | fTrackingPhase("Default"), |
6518a6c5 |
100 | fUseTGeo(3), |
e50912db |
101 | fNtracks(0), |
102 | fxOverX0Pipe(-1.), |
103 | fxTimesRhoPipe(-1.), |
104 | fxOverX0PipeTrks(0), |
105 | fxTimesRhoPipeTrks(0), |
106 | fxOverX0ShieldTrks(0), |
107 | fxTimesRhoShieldTrks(0), |
108 | fxOverX0LayerTrks(0), |
109 | fxTimesRhoLayerTrks(0), |
4a66240a |
110 | fDebugStreamer(0), |
111 | fPlaneEff(0){ |
e43c066c |
112 | //-------------------------------------------------------------------- |
113 | //This is the AliITStrackerMI constructor |
114 | //-------------------------------------------------------------------- |
e341247d |
115 | if (geom) { |
116 | AliWarning("\"geom\" is actually a dummy argument !"); |
117 | } |
118 | |
afd25725 |
119 | fCoefficients = 0; |
628e7bb0 |
120 | fAfterV0 = kFALSE; |
e341247d |
121 | |
e50912db |
122 | for (Int_t i=1; i<AliITSgeomTGeo::GetNLayers()+1; i++) { |
e341247d |
123 | Int_t nlad=AliITSgeomTGeo::GetNLadders(i); |
124 | Int_t ndet=AliITSgeomTGeo::GetNDetectors(i); |
125 | |
126 | Double_t xyz[3], &x=xyz[0], &y=xyz[1], &z=xyz[2]; |
127 | AliITSgeomTGeo::GetOrigTranslation(i,1,1,xyz); |
e43c066c |
128 | Double_t poff=TMath::ATan2(y,x); |
129 | Double_t zoff=z; |
e341247d |
130 | Double_t r=TMath::Sqrt(x*x + y*y); |
e43c066c |
131 | |
e341247d |
132 | AliITSgeomTGeo::GetOrigTranslation(i,1,2,xyz); |
e43c066c |
133 | r += TMath::Sqrt(x*x + y*y); |
e341247d |
134 | AliITSgeomTGeo::GetOrigTranslation(i,2,1,xyz); |
e43c066c |
135 | r += TMath::Sqrt(x*x + y*y); |
e341247d |
136 | AliITSgeomTGeo::GetOrigTranslation(i,2,2,xyz); |
e43c066c |
137 | r += TMath::Sqrt(x*x + y*y); |
138 | r*=0.25; |
139 | |
140 | new (fgLayers+i-1) AliITSlayer(r,poff,zoff,nlad,ndet); |
141 | |
142 | for (Int_t j=1; j<nlad+1; j++) { |
143 | for (Int_t k=1; k<ndet+1; k++) { //Fill this layer with detectors |
e341247d |
144 | TGeoHMatrix m; AliITSgeomTGeo::GetOrigMatrix(i,j,k,m); |
1f3e997f |
145 | const TGeoHMatrix *tm=AliITSgeomTGeo::GetTracking2LocalMatrix(i,j,k); |
146 | m.Multiply(tm); |
147 | Double_t txyz[3]={0.}, xyz[3]={0.}; |
148 | m.LocalToMaster(txyz,xyz); |
149 | Double_t r=TMath::Sqrt(xyz[0]*xyz[0] + xyz[1]*xyz[1]); |
150 | Double_t phi=TMath::ATan2(xyz[1],xyz[0]); |
e341247d |
151 | |
152 | if (phi<0) phi+=TMath::TwoPi(); |
153 | else if (phi>=TMath::TwoPi()) phi-=TMath::TwoPi(); |
154 | |
e43c066c |
155 | AliITSdetector &det=fgLayers[i-1].GetDetector((j-1)*ndet + k-1); |
156 | new(&det) AliITSdetector(r,phi); |
157 | } |
158 | } |
159 | |
160 | } |
161 | |
e50912db |
162 | fI=AliITSgeomTGeo::GetNLayers(); |
e43c066c |
163 | |
164 | fPass=0; |
165 | fConstraint[0]=1; fConstraint[1]=0; |
166 | |
afd25725 |
167 | Double_t xyzVtx[]={AliITSReconstructor::GetRecoParam()->GetXVdef(), |
168 | AliITSReconstructor::GetRecoParam()->GetYVdef(), |
169 | AliITSReconstructor::GetRecoParam()->GetZVdef()}; |
170 | Double_t ersVtx[]={AliITSReconstructor::GetRecoParam()->GetSigmaXVdef(), |
171 | AliITSReconstructor::GetRecoParam()->GetSigmaYVdef(), |
172 | AliITSReconstructor::GetRecoParam()->GetSigmaZVdef()}; |
173 | SetVertex(xyzVtx,ersVtx); |
e43c066c |
174 | |
e50912db |
175 | for (Int_t i=0; i<AliITSgeomTGeo::GetNLayers(); i++) fLayersNotToSkip[i]=AliITSRecoParam::GetLayersNotToSkip(i); |
176 | fLastLayerToTrackTo=AliITSRecoParam::GetLastLayerToTrackTo(); |
628e7bb0 |
177 | for (Int_t i=0;i<100000;i++){ |
178 | fBestTrackIndex[i]=0; |
179 | } |
afd25725 |
180 | |
181 | // store positions of centre of SPD modules (in z) |
182 | Double_t tr[3]; |
183 | AliITSgeomTGeo::GetTranslation(1,1,1,tr); |
184 | fSPDdetzcentre[0] = tr[2]; |
185 | AliITSgeomTGeo::GetTranslation(1,1,2,tr); |
186 | fSPDdetzcentre[1] = tr[2]; |
187 | AliITSgeomTGeo::GetTranslation(1,1,3,tr); |
188 | fSPDdetzcentre[2] = tr[2]; |
189 | AliITSgeomTGeo::GetTranslation(1,1,4,tr); |
190 | fSPDdetzcentre[3] = tr[2]; |
191 | |
afd25725 |
192 | fUseTGeo = AliITSReconstructor::GetRecoParam()->GetUseTGeoInTracker(); |
6518a6c5 |
193 | if(AliITSReconstructor::GetRecoParam()->GetExtendedEtaAcceptance() && fUseTGeo!=1 && fUseTGeo!=3) { |
194 | AliWarning("fUseTGeo changed to 3 because fExtendedEtaAcceptance is kTRUE"); |
195 | fUseTGeo = 3; |
196 | } |
e50912db |
197 | |
198 | for(Int_t i=0;i<2;i++) {fxOverX0Shield[i]=-1.;fxTimesRhoShield[i]=-1.;} |
199 | for(Int_t i=0;i<6;i++) {fxOverX0Layer[i]=-1.;fxTimesRhoLayer[i]=-1.;} |
200 | |
81e97e0d |
201 | fDebugStreamer = new TTreeSRedirector("ITSdebug.root"); |
202 | |
628e7bb0 |
203 | } |
44347160 |
204 | //------------------------------------------------------------------------ |
8221b41b |
205 | AliITStrackerMI::AliITStrackerMI(const AliITStrackerMI &tracker):AliTracker(tracker), |
206 | fI(tracker.fI), |
207 | fBestTrack(tracker.fBestTrack), |
208 | fTrackToFollow(tracker.fTrackToFollow), |
209 | fTrackHypothesys(tracker.fTrackHypothesys), |
210 | fBestHypothesys(tracker.fBestHypothesys), |
211 | fOriginal(tracker.fOriginal), |
212 | fCurrentEsdTrack(tracker.fCurrentEsdTrack), |
213 | fPass(tracker.fPass), |
214 | fAfterV0(tracker.fAfterV0), |
215 | fLastLayerToTrackTo(tracker.fLastLayerToTrackTo), |
afd25725 |
216 | fCoefficients(tracker.fCoefficients), |
8221b41b |
217 | fEsd(tracker.fEsd), |
e50912db |
218 | fTrackingPhase(tracker.fTrackingPhase), |
afd25725 |
219 | fUseTGeo(tracker.fUseTGeo), |
e50912db |
220 | fNtracks(tracker.fNtracks), |
221 | fxOverX0Pipe(tracker.fxOverX0Pipe), |
222 | fxTimesRhoPipe(tracker.fxTimesRhoPipe), |
223 | fxOverX0PipeTrks(0), |
224 | fxTimesRhoPipeTrks(0), |
225 | fxOverX0ShieldTrks(0), |
226 | fxTimesRhoShieldTrks(0), |
227 | fxOverX0LayerTrks(0), |
228 | fxTimesRhoLayerTrks(0), |
4a66240a |
229 | fDebugStreamer(tracker.fDebugStreamer), |
230 | fPlaneEff(tracker.fPlaneEff){ |
8221b41b |
231 | //Copy constructor |
e50912db |
232 | Int_t i; |
233 | for(i=0;i<4;i++) { |
234 | fSPDdetzcentre[i]=tracker.fSPDdetzcentre[i]; |
235 | } |
236 | for(i=0;i<6;i++) { |
237 | fxOverX0Layer[i]=tracker.fxOverX0Layer[i]; |
238 | fxTimesRhoLayer[i]=tracker.fxTimesRhoLayer[i]; |
239 | } |
240 | for(i=0;i<2;i++) { |
241 | fxOverX0Shield[i]=tracker.fxOverX0Shield[i]; |
242 | fxTimesRhoShield[i]=tracker.fxTimesRhoShield[i]; |
243 | } |
8221b41b |
244 | } |
44347160 |
245 | //------------------------------------------------------------------------ |
8221b41b |
246 | AliITStrackerMI & AliITStrackerMI::operator=(const AliITStrackerMI &tracker){ |
247 | //Assignment operator |
248 | this->~AliITStrackerMI(); |
249 | new(this) AliITStrackerMI(tracker); |
250 | return *this; |
251 | } |
44347160 |
252 | //------------------------------------------------------------------------ |
628e7bb0 |
253 | AliITStrackerMI::~AliITStrackerMI() |
254 | { |
255 | // |
256 | //destructor |
257 | // |
e50912db |
258 | if (fCoefficients) delete [] fCoefficients; |
259 | DeleteTrksMaterialLUT(); |
81e97e0d |
260 | if (fDebugStreamer) { |
261 | //fDebugStreamer->Close(); |
262 | delete fDebugStreamer; |
263 | } |
e43c066c |
264 | } |
44347160 |
265 | //------------------------------------------------------------------------ |
e43c066c |
266 | void AliITStrackerMI::SetLayersNotToSkip(Int_t *l) { |
267 | //-------------------------------------------------------------------- |
268 | //This function set masks of the layers which must be not skipped |
269 | //-------------------------------------------------------------------- |
e50912db |
270 | for (Int_t i=0; i<AliITSgeomTGeo::GetNLayers(); i++) fLayersNotToSkip[i]=l[i]; |
e43c066c |
271 | } |
44347160 |
272 | //------------------------------------------------------------------------ |
e43c066c |
273 | Int_t AliITStrackerMI::LoadClusters(TTree *cTree) { |
274 | //-------------------------------------------------------------------- |
275 | //This function loads ITS clusters |
276 | //-------------------------------------------------------------------- |
00a7cc50 |
277 | TBranch *branch=cTree->GetBranch("ITSRecPoints"); |
e43c066c |
278 | if (!branch) { |
279 | Error("LoadClusters"," can't get the branch !\n"); |
280 | return 1; |
281 | } |
282 | |
00a7cc50 |
283 | TClonesArray dummy("AliITSRecPoint",10000), *clusters=&dummy; |
e43c066c |
284 | branch->SetAddress(&clusters); |
285 | |
286 | Int_t j=0; |
287 | Int_t detector=0; |
e50912db |
288 | for (Int_t i=0; i<AliITSgeomTGeo::GetNLayers(); i++) { |
e43c066c |
289 | Int_t ndet=fgLayers[i].GetNdetectors(); |
290 | Int_t jmax = j + fgLayers[i].GetNladders()*ndet; |
291 | for (; j<jmax; j++) { |
292 | if (!cTree->GetEvent(j)) continue; |
293 | Int_t ncl=clusters->GetEntriesFast(); |
294 | SignDeltas(clusters,GetZ()); |
1f3e997f |
295 | |
e43c066c |
296 | while (ncl--) { |
00a7cc50 |
297 | AliITSRecPoint *c=(AliITSRecPoint*)clusters->UncheckedAt(ncl); |
75fb37cc |
298 | detector=c->GetDetectorIndex(); |
a504d56f |
299 | |
75fb37cc |
300 | if (!c->Misalign()) AliWarning("Can't misalign this cluster !"); |
a504d56f |
301 | |
00a7cc50 |
302 | fgLayers[i].InsertCluster(new AliITSRecPoint(*c)); |
e43c066c |
303 | } |
304 | clusters->Delete(); |
afd25725 |
305 | // add dead zone "virtual" cluster in SPD, if there is a cluster within |
306 | // zwindow cm from the dead zone |
307 | if (i<2 && AliITSReconstructor::GetRecoParam()->GetAddVirtualClustersInDeadZone()) { |
e50912db |
308 | for (Float_t xdead = 0; xdead < AliITSRecoParam::GetSPDdetxlength(); xdead += (i+1.)*AliITSReconstructor::GetRecoParam()->GetXPassDeadZoneHits()) { |
afd25725 |
309 | Int_t lab[4] = {0,0,0,detector}; |
310 | Int_t info[3] = {0,0,i}; |
6518a6c5 |
311 | Float_t q = 0.; // this identifies virtual clusters |
afd25725 |
312 | Float_t hit[5] = {xdead, |
313 | 0., |
314 | AliITSReconstructor::GetRecoParam()->GetSigmaXDeadZoneHit2(), |
315 | AliITSReconstructor::GetRecoParam()->GetSigmaZDeadZoneHit2(), |
316 | q}; |
317 | Bool_t local = kTRUE; |
318 | Double_t zwindow = AliITSReconstructor::GetRecoParam()->GetZWindowDeadZone(); |
e50912db |
319 | hit[1] = fSPDdetzcentre[0]+0.5*AliITSRecoParam::GetSPDdetzlength(); |
afd25725 |
320 | if (TMath::Abs(fgLayers[i].GetDetector(detector).GetZmax()-hit[1])<zwindow) |
321 | fgLayers[i].InsertCluster(new AliITSRecPoint(lab,hit,info,local)); |
e50912db |
322 | hit[1] = fSPDdetzcentre[1]-0.5*AliITSRecoParam::GetSPDdetzlength(); |
afd25725 |
323 | if (TMath::Abs(fgLayers[i].GetDetector(detector).GetZmax()-hit[1])<zwindow) |
324 | fgLayers[i].InsertCluster(new AliITSRecPoint(lab,hit,info,local)); |
e50912db |
325 | hit[1] = fSPDdetzcentre[1]+0.5*AliITSRecoParam::GetSPDdetzlength(); |
afd25725 |
326 | if (TMath::Abs(fgLayers[i].GetDetector(detector).GetZmax()-hit[1])<zwindow) |
327 | fgLayers[i].InsertCluster(new AliITSRecPoint(lab,hit,info,local)); |
e50912db |
328 | hit[1] = fSPDdetzcentre[2]-0.5*AliITSRecoParam::GetSPDdetzlength(); |
afd25725 |
329 | if (TMath::Abs(fgLayers[i].GetDetector(detector).GetZmax()-hit[1])<zwindow) |
330 | fgLayers[i].InsertCluster(new AliITSRecPoint(lab,hit,info,local)); |
e50912db |
331 | hit[1] = fSPDdetzcentre[2]+0.5*AliITSRecoParam::GetSPDdetzlength(); |
afd25725 |
332 | if (TMath::Abs(fgLayers[i].GetDetector(detector).GetZmax()-hit[1])<zwindow) |
333 | fgLayers[i].InsertCluster(new AliITSRecPoint(lab,hit,info,local)); |
e50912db |
334 | hit[1] = fSPDdetzcentre[3]-0.5*AliITSRecoParam::GetSPDdetzlength(); |
afd25725 |
335 | if (TMath::Abs(fgLayers[i].GetDetector(detector).GetZmax()-hit[1])<zwindow) |
336 | fgLayers[i].InsertCluster(new AliITSRecPoint(lab,hit,info,local)); |
e43c066c |
337 | } |
6518a6c5 |
338 | } // "virtual" clusters in SPD |
e43c066c |
339 | |
340 | } |
341 | // |
342 | fgLayers[i].ResetRoad(); //road defined by the cluster density |
343 | fgLayers[i].SortClusters(); |
344 | } |
345 | |
346 | return 0; |
347 | } |
44347160 |
348 | //------------------------------------------------------------------------ |
e43c066c |
349 | void AliITStrackerMI::UnloadClusters() { |
350 | //-------------------------------------------------------------------- |
351 | //This function unloads ITS clusters |
352 | //-------------------------------------------------------------------- |
e50912db |
353 | for (Int_t i=0; i<AliITSgeomTGeo::GetNLayers(); i++) fgLayers[i].ResetClusters(); |
e43c066c |
354 | } |
44347160 |
355 | //------------------------------------------------------------------------ |
afd25725 |
356 | static Int_t CorrectForTPCtoITSDeadZoneMaterial(AliITStrackMI *t) { |
e43c066c |
357 | //-------------------------------------------------------------------- |
358 | // Correction for the material between the TPC and the ITS |
e43c066c |
359 | //-------------------------------------------------------------------- |
e50912db |
360 | if (t->GetX() > AliITSRecoParam::Getriw()) { // inward direction |
361 | if (!t->PropagateToTGeo(AliITSRecoParam::Getriw(),1)) return 0;// TPC inner wall |
362 | if (!t->PropagateToTGeo(AliITSRecoParam::Getrcd(),1)) return 0;// TPC central drum |
363 | if (!t->PropagateToTGeo(AliITSRecoParam::Getrs(),1)) return 0;// ITS screen |
364 | } else if (t->GetX() < AliITSRecoParam::Getrs()) { // outward direction |
365 | if (!t->PropagateToTGeo(AliITSRecoParam::Getrs(),1)) return 0;// ITS screen |
366 | if (!t->PropagateToTGeo(AliITSRecoParam::Getrcd(),1)) return 0;// TPC central drum |
367 | if (!t->PropagateToTGeo(AliITSRecoParam::Getriw()+0.001,1)) return 0;// TPC inner wall |
e43c066c |
368 | } else { |
afd25725 |
369 | Error("CorrectForTPCtoITSDeadZoneMaterial","Track is already in the dead zone !"); |
e50912db |
370 | return 0; |
e43c066c |
371 | } |
372 | |
e50912db |
373 | return 1; |
e43c066c |
374 | } |
44347160 |
375 | //------------------------------------------------------------------------ |
af885e0f |
376 | Int_t AliITStrackerMI::Clusters2Tracks(AliESDEvent *event) { |
e43c066c |
377 | //-------------------------------------------------------------------- |
378 | // This functions reconstructs ITS tracks |
379 | // The clusters must be already loaded ! |
380 | //-------------------------------------------------------------------- |
e50912db |
381 | fTrackingPhase="Clusters2Tracks"; |
382 | |
e43c066c |
383 | TObjArray itsTracks(15000); |
628e7bb0 |
384 | fOriginal.Clear(); |
81e97e0d |
385 | fEsd = event; // store pointer to the esd |
afd25725 |
386 | |
9a5326b1 |
387 | // temporary (for cosmics) |
388 | if(event->GetVertex()) { |
389 | TString title = event->GetVertex()->GetTitle(); |
390 | if(title.Contains("cosmics")) { |
391 | Double_t xyz[3]={GetX(),GetY(),GetZ()}; |
392 | Double_t exyz[3]={0.1,0.1,0.1}; |
393 | SetVertex(xyz,exyz); |
394 | } |
395 | } |
396 | // temporary |
afd25725 |
397 | |
e43c066c |
398 | {/* Read ESD tracks */ |
afd25725 |
399 | Double_t pimass = TDatabasePDG::Instance()->GetParticle(211)->Mass(); |
e43c066c |
400 | Int_t nentr=event->GetNumberOfTracks(); |
401 | Info("Clusters2Tracks", "Number of ESD tracks: %d\n", nentr); |
402 | while (nentr--) { |
403 | AliESDtrack *esd=event->GetTrack(nentr); |
404 | |
405 | if ((esd->GetStatus()&AliESDtrack::kTPCin)==0) continue; |
406 | if (esd->GetStatus()&AliESDtrack::kTPCout) continue; |
407 | if (esd->GetStatus()&AliESDtrack::kITSin) continue; |
51ad6848 |
408 | if (esd->GetKinkIndex(0)>0) continue; //kink daughter |
15dd636f |
409 | AliITStrackMI *t=0; |
e43c066c |
410 | try { |
15dd636f |
411 | t=new AliITStrackMI(*esd); |
e43c066c |
412 | } catch (const Char_t *msg) { |
628e7bb0 |
413 | //Warning("Clusters2Tracks",msg); |
e43c066c |
414 | delete t; |
415 | continue; |
416 | } |
b9671574 |
417 | t->GetDZ(GetX(),GetY(),GetZ(),t->GetDP()); //I.B. |
418 | Double_t vdist = TMath::Sqrt(t->GetD(0)*t->GetD(0)+t->GetD(1)*t->GetD(1)); |
6518a6c5 |
419 | |
420 | |
afd25725 |
421 | // look at the ESD mass hypothesys ! |
422 | if (t->GetMass()<0.9*pimass) t->SetMass(pimass); |
e43c066c |
423 | // write expected q |
b9671574 |
424 | t->SetExpQ(TMath::Max(0.8*t->GetESDtrack()->GetTPCsignal(),30.)); |
e43c066c |
425 | |
afd25725 |
426 | if (esd->GetV0Index(0)>0 && t->GetD(0)<AliITSReconstructor::GetRecoParam()->GetMaxDforV0dghtrForProlongation()){ |
81e97e0d |
427 | //track - can be V0 according to TPC |
afd25725 |
428 | } else { |
429 | if (TMath::Abs(t->GetD(0))>AliITSReconstructor::GetRecoParam()->GetMaxDForProlongation()) { |
81e97e0d |
430 | delete t; |
431 | continue; |
e50912db |
432 | } |
afd25725 |
433 | if (TMath::Abs(vdist)>AliITSReconstructor::GetRecoParam()->GetMaxDZForProlongation()) { |
81e97e0d |
434 | delete t; |
435 | continue; |
436 | } |
6c23ffed |
437 | if (t->Pt()<AliITSReconstructor::GetRecoParam()->GetMinPtForProlongation()) { |
81e97e0d |
438 | delete t; |
439 | continue; |
440 | } |
e50912db |
441 | if (!CorrectForTPCtoITSDeadZoneMaterial(t)) { |
81e97e0d |
442 | delete t; |
443 | continue; |
444 | } |
e43c066c |
445 | } |
b9671574 |
446 | t->SetReconstructed(kFALSE); |
e43c066c |
447 | itsTracks.AddLast(t); |
628e7bb0 |
448 | fOriginal.AddLast(t); |
e43c066c |
449 | } |
450 | } /* End Read ESD tracks */ |
451 | |
452 | itsTracks.Sort(); |
628e7bb0 |
453 | fOriginal.Sort(); |
e43c066c |
454 | Int_t nentr=itsTracks.GetEntriesFast(); |
455 | fTrackHypothesys.Expand(nentr); |
81e97e0d |
456 | fBestHypothesys.Expand(nentr); |
afd25725 |
457 | MakeCoefficients(nentr); |
e50912db |
458 | if(fUseTGeo==3 || fUseTGeo==4) MakeTrksMaterialLUT(nentr); |
e43c066c |
459 | Int_t ntrk=0; |
afd25725 |
460 | // THE TWO TRACKING PASSES |
e43c066c |
461 | for (fPass=0; fPass<2; fPass++) { |
462 | Int_t &constraint=fConstraint[fPass]; if (constraint<0) continue; |
e50912db |
463 | for (fCurrentEsdTrack=0; fCurrentEsdTrack<nentr; fCurrentEsdTrack++) { |
2755f080 |
464 | //cerr<<fPass<<" "<<fCurrentEsdTrack<<'\n'; |
e50912db |
465 | AliITStrackMI *t=(AliITStrackMI*)itsTracks.UncheckedAt(fCurrentEsdTrack); |
e43c066c |
466 | if (t==0) continue; //this track has been already tracked |
b9671574 |
467 | if (t->GetReconstructed()&&(t->GetNUsed()<1.5)) continue; //this track was already "succesfully" reconstructed |
791f9a2a |
468 | Float_t dz[2]; t->GetDZ(GetX(),GetY(),GetZ(),dz); //I.B. |
afd25725 |
469 | if (fConstraint[fPass]) { |
470 | if (TMath::Abs(dz[0])>AliITSReconstructor::GetRecoParam()->GetMaxDZToUseConstraint() || |
471 | TMath::Abs(dz[1])>AliITSReconstructor::GetRecoParam()->GetMaxDZToUseConstraint()) continue; |
472 | } |
e43c066c |
473 | |
474 | Int_t tpcLabel=t->GetLabel(); //save the TPC track label |
475 | fI = 6; |
476 | ResetTrackToFollow(*t); |
477 | ResetBestTrack(); |
6518a6c5 |
478 | |
e50912db |
479 | FollowProlongationTree(t,fCurrentEsdTrack,fConstraint[fPass]); |
e43c066c |
480 | |
481 | SortTrackHypothesys(fCurrentEsdTrack,20,0); //MI change |
482 | // |
15dd636f |
483 | AliITStrackMI * besttrack = GetBestHypothesys(fCurrentEsdTrack,t,15); |
e43c066c |
484 | if (!besttrack) continue; |
485 | besttrack->SetLabel(tpcLabel); |
486 | // besttrack->CookdEdx(); |
487 | CookdEdx(besttrack); |
b9671574 |
488 | besttrack->SetFakeRatio(1.); |
e43c066c |
489 | CookLabel(besttrack,0.); //For comparison only |
e43c066c |
490 | UpdateESDtrack(besttrack,AliESDtrack::kITSin); |
628e7bb0 |
491 | |
628e7bb0 |
492 | if (fConstraint[fPass]&&(!besttrack->IsGoldPrimary())) continue; //to be tracked also without vertex constrain |
493 | |
b9671574 |
494 | t->SetReconstructed(kTRUE); |
e43c066c |
495 | ntrk++; |
496 | } |
497 | GetBestHypothesysMIP(itsTracks); |
afd25725 |
498 | } // end loop on the two tracking passes |
e43c066c |
499 | |
500 | //GetBestHypothesysMIP(itsTracks); |
afd25725 |
501 | if(event->GetNumberOfV0s()>0) UpdateTPCV0(event); |
502 | if(AliITSReconstructor::GetRecoParam()->GetFindV0s()) FindV02(event); |
628e7bb0 |
503 | fAfterV0 = kTRUE; |
504 | //GetBestHypothesysMIP(itsTracks); |
505 | // |
e43c066c |
506 | itsTracks.Delete(); |
507 | // |
508 | Int_t entries = fTrackHypothesys.GetEntriesFast(); |
e50912db |
509 | for (Int_t ientry=0; ientry<entries; ientry++) { |
e43c066c |
510 | TObjArray * array =(TObjArray*)fTrackHypothesys.UncheckedAt(ientry); |
511 | if (array) array->Delete(); |
512 | delete fTrackHypothesys.RemoveAt(ientry); |
513 | } |
514 | |
515 | fTrackHypothesys.Delete(); |
81e97e0d |
516 | fBestHypothesys.Delete(); |
628e7bb0 |
517 | fOriginal.Clear(); |
afd25725 |
518 | delete [] fCoefficients; |
519 | fCoefficients=0; |
e50912db |
520 | DeleteTrksMaterialLUT(); |
521 | |
e43c066c |
522 | Info("Clusters2Tracks","Number of prolonged tracks: %d\n",ntrk); |
e50912db |
523 | |
524 | fTrackingPhase="Default"; |
628e7bb0 |
525 | |
e43c066c |
526 | return 0; |
527 | } |
44347160 |
528 | //------------------------------------------------------------------------ |
af885e0f |
529 | Int_t AliITStrackerMI::PropagateBack(AliESDEvent *event) { |
e43c066c |
530 | //-------------------------------------------------------------------- |
531 | // This functions propagates reconstructed ITS tracks back |
532 | // The clusters must be loaded ! |
533 | //-------------------------------------------------------------------- |
e50912db |
534 | fTrackingPhase="PropagateBack"; |
e43c066c |
535 | Int_t nentr=event->GetNumberOfTracks(); |
536 | Info("PropagateBack", "Number of ESD tracks: %d\n", nentr); |
537 | |
538 | Int_t ntrk=0; |
539 | for (Int_t i=0; i<nentr; i++) { |
540 | AliESDtrack *esd=event->GetTrack(i); |
541 | |
542 | if ((esd->GetStatus()&AliESDtrack::kITSin)==0) continue; |
543 | if (esd->GetStatus()&AliESDtrack::kITSout) continue; |
544 | |
15dd636f |
545 | AliITStrackMI *t=0; |
e43c066c |
546 | try { |
15dd636f |
547 | t=new AliITStrackMI(*esd); |
e43c066c |
548 | } catch (const Char_t *msg) { |
628e7bb0 |
549 | //Warning("PropagateBack",msg); |
e43c066c |
550 | delete t; |
551 | continue; |
552 | } |
b9671574 |
553 | t->SetExpQ(TMath::Max(0.8*t->GetESDtrack()->GetTPCsignal(),30.)); |
e43c066c |
554 | |
555 | ResetTrackToFollow(*t); |
556 | |
9a5326b1 |
557 | // propagate to vertex [SR, GSI 17.02.2003] |
e43c066c |
558 | // Start Time measurement [SR, GSI 17.02.2003], corrected by I.Belikov |
e50912db |
559 | if (CorrectForPipeMaterial(&fTrackToFollow,"inward")) { |
560 | if (fTrackToFollow.PropagateToVertex(event->GetVertex())) |
561 | fTrackToFollow.StartTimeIntegral(); |
562 | // from vertex to outside pipe |
563 | CorrectForPipeMaterial(&fTrackToFollow,"outward"); |
e43c066c |
564 | } |
565 | |
6c94f330 |
566 | fTrackToFollow.ResetCovariance(10.); fTrackToFollow.ResetClusters(); |
e50912db |
567 | if (RefitAt(AliITSRecoParam::GetrInsideITSscreen(),&fTrackToFollow,t)) { |
568 | if (!CorrectForTPCtoITSDeadZoneMaterial(&fTrackToFollow)) { |
e43c066c |
569 | delete t; |
570 | continue; |
571 | } |
572 | fTrackToFollow.SetLabel(t->GetLabel()); |
573 | //fTrackToFollow.CookdEdx(); |
574 | CookLabel(&fTrackToFollow,0.); //For comparison only |
575 | fTrackToFollow.UpdateESDtrack(AliESDtrack::kITSout); |
576 | //UseClusters(&fTrackToFollow); |
577 | ntrk++; |
578 | } |
579 | delete t; |
580 | } |
581 | |
582 | Info("PropagateBack","Number of back propagated ITS tracks: %d\n",ntrk); |
583 | |
e50912db |
584 | fTrackingPhase="Default"; |
585 | |
e43c066c |
586 | return 0; |
587 | } |
44347160 |
588 | //------------------------------------------------------------------------ |
af885e0f |
589 | Int_t AliITStrackerMI::RefitInward(AliESDEvent *event) { |
e43c066c |
590 | //-------------------------------------------------------------------- |
591 | // This functions refits ITS tracks using the |
592 | // "inward propagated" TPC tracks |
593 | // The clusters must be loaded ! |
594 | //-------------------------------------------------------------------- |
e50912db |
595 | fTrackingPhase="RefitInward"; |
afd25725 |
596 | if(AliITSReconstructor::GetRecoParam()->GetFindV0s()) RefitV02(event); |
e43c066c |
597 | Int_t nentr=event->GetNumberOfTracks(); |
598 | Info("RefitInward", "Number of ESD tracks: %d\n", nentr); |
599 | |
600 | Int_t ntrk=0; |
601 | for (Int_t i=0; i<nentr; i++) { |
602 | AliESDtrack *esd=event->GetTrack(i); |
603 | |
604 | if ((esd->GetStatus()&AliESDtrack::kITSout) == 0) continue; |
605 | if (esd->GetStatus()&AliESDtrack::kITSrefit) continue; |
606 | if (esd->GetStatus()&AliESDtrack::kTPCout) |
607 | if ((esd->GetStatus()&AliESDtrack::kTPCrefit)==0) continue; |
608 | |
15dd636f |
609 | AliITStrackMI *t=0; |
e43c066c |
610 | try { |
15dd636f |
611 | t=new AliITStrackMI(*esd); |
e43c066c |
612 | } catch (const Char_t *msg) { |
628e7bb0 |
613 | //Warning("RefitInward",msg); |
e43c066c |
614 | delete t; |
615 | continue; |
616 | } |
b9671574 |
617 | t->SetExpQ(TMath::Max(0.8*t->GetESDtrack()->GetTPCsignal(),30.)); |
e50912db |
618 | if (!CorrectForTPCtoITSDeadZoneMaterial(t)) { |
e43c066c |
619 | delete t; |
620 | continue; |
621 | } |
622 | |
623 | ResetTrackToFollow(*t); |
624 | fTrackToFollow.ResetClusters(); |
625 | |
626 | if ((esd->GetStatus()&AliESDtrack::kTPCin)==0) |
6c94f330 |
627 | fTrackToFollow.ResetCovariance(10.); |
e43c066c |
628 | |
629 | //Refitting... |
e50912db |
630 | if (RefitAt(AliITSRecoParam::GetrInsideSPD1(), &fTrackToFollow, t,kTRUE)) { |
e43c066c |
631 | fTrackToFollow.SetLabel(t->GetLabel()); |
632 | // fTrackToFollow.CookdEdx(); |
633 | CookdEdx(&fTrackToFollow); |
634 | |
635 | CookLabel(&fTrackToFollow,0.0); //For comparison only |
636 | |
9a5326b1 |
637 | //The beam pipe |
e50912db |
638 | if (CorrectForPipeMaterial(&fTrackToFollow,"inward")) { |
9a5326b1 |
639 | AliESDtrack *esdTrack =fTrackToFollow.GetESDtrack(); |
640 | esdTrack->UpdateTrackParams(&fTrackToFollow,AliESDtrack::kITSrefit); |
641 | Float_t r[3]={0.,0.,0.}; |
642 | Double_t maxD=3.; |
643 | esdTrack->RelateToVertex(event->GetVertex(),GetBz(r),maxD); |
644 | ntrk++; |
e43c066c |
645 | } |
646 | } |
647 | delete t; |
648 | } |
649 | |
650 | Info("RefitInward","Number of refitted tracks: %d\n",ntrk); |
651 | |
e50912db |
652 | fTrackingPhase="Default"; |
653 | |
e43c066c |
654 | return 0; |
655 | } |
44347160 |
656 | //------------------------------------------------------------------------ |
e43c066c |
657 | AliCluster *AliITStrackerMI::GetCluster(Int_t index) const { |
658 | //-------------------------------------------------------------------- |
659 | // Return pointer to a given cluster |
660 | //-------------------------------------------------------------------- |
661 | Int_t l=(index & 0xf0000000) >> 28; |
662 | Int_t c=(index & 0x0fffffff) >> 00; |
663 | return fgLayers[l].GetCluster(c); |
664 | } |
9a5326b1 |
665 | //------------------------------------------------------------------------ |
df29e9a4 |
666 | Bool_t AliITStrackerMI::GetTrackPoint(Int_t index, AliTrackPoint& p) const { |
9a5326b1 |
667 | //-------------------------------------------------------------------- |
df29e9a4 |
668 | // Get track space point with index i |
9a5326b1 |
669 | //-------------------------------------------------------------------- |
60066577 |
670 | |
78b03929 |
671 | Int_t l=(index & 0xf0000000) >> 28; |
672 | Int_t c=(index & 0x0fffffff) >> 00; |
00a7cc50 |
673 | AliITSRecPoint *cl = fgLayers[l].GetCluster(c); |
df29e9a4 |
674 | Int_t idet = cl->GetDetectorIndex(); |
4e65ff9e |
675 | |
60066577 |
676 | Float_t xyz[3]; |
677 | Float_t cov[6]; |
678 | cl->GetGlobalXYZ(xyz); |
679 | cl->GetGlobalCov(cov); |
680 | p.SetXYZ(xyz, cov); |
4e65ff9e |
681 | |
ae079791 |
682 | AliGeomManager::ELayerID iLayer = AliGeomManager::kInvalidLayer; |
df29e9a4 |
683 | switch (l) { |
684 | case 0: |
ae079791 |
685 | iLayer = AliGeomManager::kSPD1; |
df29e9a4 |
686 | break; |
687 | case 1: |
ae079791 |
688 | iLayer = AliGeomManager::kSPD2; |
df29e9a4 |
689 | break; |
690 | case 2: |
ae079791 |
691 | iLayer = AliGeomManager::kSDD1; |
df29e9a4 |
692 | break; |
693 | case 3: |
ae079791 |
694 | iLayer = AliGeomManager::kSDD2; |
9a5326b1 |
695 | break; |
696 | case 4: |
697 | iLayer = AliGeomManager::kSSD1; |
698 | break; |
699 | case 5: |
700 | iLayer = AliGeomManager::kSSD2; |
701 | break; |
702 | default: |
703 | AliWarning(Form("Wrong layer index in ITS (%d) !",l)); |
704 | break; |
705 | }; |
706 | UShort_t volid = AliGeomManager::LayerToVolUID(iLayer,idet); |
707 | p.SetVolumeID((UShort_t)volid); |
708 | return kTRUE; |
709 | } |
710 | //------------------------------------------------------------------------ |
711 | Bool_t AliITStrackerMI::GetTrackPointTrackingError(Int_t index, |
712 | AliTrackPoint& p, const AliESDtrack *t) { |
713 | //-------------------------------------------------------------------- |
714 | // Get track space point with index i |
715 | // (assign error estimated during the tracking) |
716 | //-------------------------------------------------------------------- |
717 | |
718 | Int_t l=(index & 0xf0000000) >> 28; |
719 | Int_t c=(index & 0x0fffffff) >> 00; |
720 | const AliITSRecPoint *cl = fgLayers[l].GetCluster(c); |
721 | Int_t idet = cl->GetDetectorIndex(); |
722 | const AliITSdetector &det=fgLayers[l].GetDetector(idet); |
723 | |
724 | // tgphi and tglambda of the track in tracking frame with alpha=det.GetPhi |
725 | Float_t detxy[2]; |
726 | detxy[0] = det.GetR()*TMath::Cos(det.GetPhi()); |
727 | detxy[1] = det.GetR()*TMath::Sin(det.GetPhi()); |
728 | Double_t alpha = t->GetAlpha(); |
729 | Double_t xdetintrackframe = detxy[0]*TMath::Cos(alpha)+detxy[1]*TMath::Sin(alpha); |
730 | Float_t phi = TMath::ASin(t->GetSnpAt(xdetintrackframe,AliTracker::GetBz())); |
731 | phi += alpha-det.GetPhi(); |
732 | Float_t tgphi = TMath::Tan(phi); |
733 | |
734 | Float_t tgl = t->GetTgl(); // tgl about const along track |
735 | Float_t expQ = TMath::Max(0.8*t->GetTPCsignal(),30.); |
736 | |
737 | Float_t errlocalx,errlocalz; |
e50912db |
738 | AliITSClusterParam::GetError(l,cl,tgl,tgphi,expQ,errlocalx,errlocalz); |
9a5326b1 |
739 | |
740 | Float_t xyz[3]; |
741 | Float_t cov[6]; |
742 | cl->GetGlobalXYZ(xyz); |
743 | // cl->GetGlobalCov(cov); |
744 | Float_t pos[3] = {0.,0.,0.}; |
745 | AliCluster tmpcl((UShort_t)cl->GetVolumeId(),pos[0],pos[1],pos[2],errlocalx*errlocalx,errlocalz*errlocalz,0); |
746 | tmpcl.GetGlobalCov(cov); |
747 | |
748 | p.SetXYZ(xyz, cov); |
749 | |
750 | AliGeomManager::ELayerID iLayer = AliGeomManager::kInvalidLayer; |
751 | switch (l) { |
752 | case 0: |
753 | iLayer = AliGeomManager::kSPD1; |
754 | break; |
755 | case 1: |
756 | iLayer = AliGeomManager::kSPD2; |
757 | break; |
758 | case 2: |
759 | iLayer = AliGeomManager::kSDD1; |
760 | break; |
761 | case 3: |
762 | iLayer = AliGeomManager::kSDD2; |
df29e9a4 |
763 | break; |
764 | case 4: |
ae079791 |
765 | iLayer = AliGeomManager::kSSD1; |
df29e9a4 |
766 | break; |
767 | case 5: |
ae079791 |
768 | iLayer = AliGeomManager::kSSD2; |
df29e9a4 |
769 | break; |
770 | default: |
771 | AliWarning(Form("Wrong layer index in ITS (%d) !",l)); |
772 | break; |
773 | }; |
ae079791 |
774 | UShort_t volid = AliGeomManager::LayerToVolUID(iLayer,idet); |
df29e9a4 |
775 | p.SetVolumeID((UShort_t)volid); |
776 | return kTRUE; |
777 | } |
44347160 |
778 | //------------------------------------------------------------------------ |
81e97e0d |
779 | void AliITStrackerMI::FollowProlongationTree(AliITStrackMI * otrack, Int_t esdindex, Bool_t constrain) |
e43c066c |
780 | { |
781 | //-------------------------------------------------------------------- |
782 | // Follow prolongation tree |
783 | //-------------------------------------------------------------------- |
81e97e0d |
784 | // |
afd25725 |
785 | Double_t xyzVtx[]={GetX(),GetY(),GetZ()}; |
786 | Double_t ersVtx[]={GetSigmaX(),GetSigmaY(),GetSigmaZ()}; |
787 | |
2755f080 |
788 | |
b9671574 |
789 | AliESDtrack * esd = otrack->GetESDtrack(); |
afd25725 |
790 | if (esd->GetV0Index(0)>0) { |
81e97e0d |
791 | // TEMPORARY SOLLUTION: map V0 indexes to point to proper track |
afd25725 |
792 | // mapping of ESD track is different as ITS track in Containers |
81e97e0d |
793 | // Need something more stable |
44347160 |
794 | // Indexes are set back again to the ESD track indexes in UpdateTPCV0 |
81e97e0d |
795 | for (Int_t i=0;i<3;i++){ |
796 | Int_t index = esd->GetV0Index(i); |
797 | if (index==0) break; |
d6a49f20 |
798 | AliESDv0 * vertex = fEsd->GetV0(index); |
81e97e0d |
799 | if (vertex->GetStatus()<0) continue; // rejected V0 |
800 | // |
afd25725 |
801 | if (esd->GetSign()>0) { |
802 | vertex->SetIndex(0,esdindex); |
803 | } else { |
804 | vertex->SetIndex(1,esdindex); |
805 | } |
81e97e0d |
806 | } |
807 | } |
808 | TObjArray *bestarray = (TObjArray*)fBestHypothesys.At(esdindex); |
809 | if (!bestarray){ |
810 | bestarray = new TObjArray(5); |
811 | fBestHypothesys.AddAt(bestarray,esdindex); |
812 | } |
e43c066c |
813 | |
81e97e0d |
814 | // |
e43c066c |
815 | //setup tree of the prolongations |
816 | // |
15dd636f |
817 | static AliITStrackMI tracks[7][100]; |
818 | AliITStrackMI *currenttrack; |
819 | static AliITStrackMI currenttrack1; |
820 | static AliITStrackMI currenttrack2; |
821 | static AliITStrackMI backuptrack; |
e43c066c |
822 | Int_t ntracks[7]; |
823 | Int_t nindexes[7][100]; |
824 | Float_t normalizedchi2[100]; |
825 | for (Int_t ilayer=0;ilayer<6;ilayer++) ntracks[ilayer]=0; |
b9671574 |
826 | otrack->SetNSkipped(0); |
15dd636f |
827 | new (&(tracks[6][0])) AliITStrackMI(*otrack); |
e43c066c |
828 | ntracks[6]=1; |
81e97e0d |
829 | for (Int_t i=0;i<7;i++) nindexes[i][0]=0; |
e43c066c |
830 | // |
831 | // |
832 | // follow prolongations |
e50912db |
833 | for (Int_t ilayer=5; ilayer>=0; ilayer--) { |
2755f080 |
834 | fI = ilayer; |
e43c066c |
835 | // |
2755f080 |
836 | AliITSlayer &layer=fgLayers[ilayer]; |
837 | Double_t r = layer.GetR(); |
e43c066c |
838 | ntracks[ilayer]=0; |
839 | // |
840 | // |
2755f080 |
841 | Int_t nskipped=0; |
e43c066c |
842 | Float_t nused =0; |
e50912db |
843 | for (Int_t itrack =0; itrack<ntracks[ilayer+1]; itrack++) { |
e43c066c |
844 | //set current track |
845 | if (ntracks[ilayer]>=100) break; |
b9671574 |
846 | if (tracks[ilayer+1][nindexes[ilayer+1][itrack]].GetNSkipped()>0) nskipped++; |
847 | if (tracks[ilayer+1][nindexes[ilayer+1][itrack]].GetNUsed()>2.) nused++; |
e43c066c |
848 | if (ntracks[ilayer]>15+ilayer){ |
b9671574 |
849 | if (itrack>1&&tracks[ilayer+1][nindexes[ilayer+1][itrack]].GetNSkipped()>0 && nskipped>4+ilayer) continue; |
850 | if (itrack>1&&tracks[ilayer+1][nindexes[ilayer+1][itrack]].GetNUsed()>2. && nused>3) continue; |
e43c066c |
851 | } |
852 | |
15dd636f |
853 | new(¤ttrack1) AliITStrackMI(tracks[ilayer+1][nindexes[ilayer+1][itrack]]); |
44347160 |
854 | |
afd25725 |
855 | // material between SSD and SDD, SDD and SPD |
e50912db |
856 | if (ilayer==3) |
857 | if(!CorrectForShieldMaterial(¤ttrack1,"SDD","inward")) continue; |
858 | if (ilayer==1) |
859 | if(!CorrectForShieldMaterial(¤ttrack1,"SPD","inward")) continue; |
8602c008 |
860 | |
2755f080 |
861 | // detector number |
8602c008 |
862 | Double_t phi,z; |
863 | if (!currenttrack1.GetPhiZat(r,phi,z)) continue; |
e43c066c |
864 | Int_t idet=layer.FindDetectorIndex(phi,z); |
e50912db |
865 | |
866 | Double_t trackGlobXYZ1[3]; |
867 | currenttrack1.GetXYZ(trackGlobXYZ1); |
868 | |
2755f080 |
869 | // Get the budget to the primary vertex for the current track being prolonged |
870 | Double_t budgetToPrimVertex = GetEffectiveThickness(); |
871 | |
872 | // check if we allow a prolongation without point |
6518a6c5 |
873 | Int_t skip = CheckSkipLayer(¤ttrack1,ilayer,idet); |
2755f080 |
874 | if (skip) { |
875 | AliITStrackMI* vtrack = new (&tracks[ilayer][ntracks[ilayer]]) AliITStrackMI(currenttrack1); |
6518a6c5 |
876 | // propagate to the layer radius |
877 | Double_t xToGo; vtrack->GetLocalXat(r,xToGo); |
878 | vtrack->AliExternalTrackParam::PropagateTo(xToGo,GetBz()); |
2755f080 |
879 | // apply correction for material of the current layer |
880 | CorrectForLayerMaterial(vtrack,ilayer,trackGlobXYZ1,"inward"); |
881 | vtrack->SetNDeadZone(vtrack->GetNDeadZone()+1); |
882 | vtrack->SetClIndex(ilayer,0); |
883 | if(constrain) vtrack->Improve(budgetToPrimVertex,xyzVtx,ersVtx); |
884 | ntracks[ilayer]++; |
6518a6c5 |
885 | continue; |
2755f080 |
886 | } |
887 | |
888 | // track outside layer acceptance in z |
889 | if (idet<0) continue; |
890 | |
891 | //propagate to the intersection with the detector plane |
892 | const AliITSdetector &det=layer.GetDetector(idet); |
893 | new(¤ttrack2) AliITStrackMI(currenttrack1); |
44347160 |
894 | if (!currenttrack1.Propagate(det.GetPhi(),det.GetR())) continue; |
895 | currenttrack2.Propagate(det.GetPhi(),det.GetR()); |
e43c066c |
896 | currenttrack1.SetDetectorIndex(idet); |
897 | currenttrack2.SetDetectorIndex(idet); |
6518a6c5 |
898 | |
afd25725 |
899 | //*************** |
900 | // DEFINITION OF SEARCH ROAD FOR CLUSTERS SELECTION |
e43c066c |
901 | // |
44347160 |
902 | Double_t dz=AliITSReconstructor::GetRecoParam()->GetNSigmaRoadZ()* |
903 | TMath::Sqrt(currenttrack1.GetSigmaZ2() + |
904 | AliITSReconstructor::GetRecoParam()->GetNSigmaZLayerForRoadZ()* |
905 | AliITSReconstructor::GetRecoParam()->GetNSigmaZLayerForRoadZ()* |
906 | AliITSReconstructor::GetRecoParam()->GetSigmaZ2(ilayer)); |
907 | Double_t dy=AliITSReconstructor::GetRecoParam()->GetNSigmaRoadY()* |
908 | TMath::Sqrt(currenttrack1.GetSigmaY2() + |
909 | AliITSReconstructor::GetRecoParam()->GetNSigmaYLayerForRoadY()* |
910 | AliITSReconstructor::GetRecoParam()->GetNSigmaYLayerForRoadY()* |
911 | AliITSReconstructor::GetRecoParam()->GetSigmaY2(ilayer)); |
afd25725 |
912 | |
44347160 |
913 | // track at boundary between detectors, enlarge road |
e50912db |
914 | Double_t boundaryWidth=AliITSRecoParam::GetBoundaryWidth(); |
915 | if ( (currenttrack1.GetY()-dy < det.GetYmin()+boundaryWidth) || |
916 | (currenttrack1.GetY()+dy > det.GetYmax()-boundaryWidth) || |
917 | (currenttrack1.GetZ()-dz < det.GetZmin()+boundaryWidth) || |
918 | (currenttrack1.GetZ()+dz > det.GetZmax()-boundaryWidth) ) { |
afd25725 |
919 | Float_t tgl = TMath::Abs(currenttrack1.GetTgl()); |
920 | if (tgl > 1.) tgl=1.; |
e50912db |
921 | Double_t deltaXNeighbDets=AliITSRecoParam::GetDeltaXNeighbDets(); |
922 | dz = TMath::Sqrt(dz*dz+deltaXNeighbDets*deltaXNeighbDets*tgl*tgl); |
afd25725 |
923 | Float_t snp = TMath::Abs(currenttrack1.GetSnp()); |
924 | if (snp > AliITSReconstructor::GetRecoParam()->GetMaxSnp()) continue; |
e50912db |
925 | dy = TMath::Sqrt(dy*dy+deltaXNeighbDets*deltaXNeighbDets*snp*snp); |
44347160 |
926 | } // boundary |
e43c066c |
927 | |
2755f080 |
928 | // road in global (rphi,z) [i.e. in tracking ref. system] |
44347160 |
929 | Double_t zmin = currenttrack1.GetZ() - dz; |
930 | Double_t zmax = currenttrack1.GetZ() + dz; |
931 | Double_t ymin = currenttrack1.GetY() + r*det.GetPhi() - dy; |
932 | Double_t ymax = currenttrack1.GetY() + r*det.GetPhi() + dy; |
2755f080 |
933 | |
afd25725 |
934 | // select clusters in road |
e43c066c |
935 | layer.SelectClusters(zmin,zmax,ymin,ymax); |
afd25725 |
936 | //******************** |
44347160 |
937 | |
afd25725 |
938 | // Define criteria for track-cluster association |
44347160 |
939 | Double_t msz = currenttrack1.GetSigmaZ2() + |
940 | AliITSReconstructor::GetRecoParam()->GetNSigmaZLayerForRoadZ()* |
941 | AliITSReconstructor::GetRecoParam()->GetNSigmaZLayerForRoadZ()* |
942 | AliITSReconstructor::GetRecoParam()->GetSigmaZ2(ilayer); |
943 | Double_t msy = currenttrack1.GetSigmaY2() + |
944 | AliITSReconstructor::GetRecoParam()->GetNSigmaYLayerForRoadY()* |
945 | AliITSReconstructor::GetRecoParam()->GetNSigmaYLayerForRoadY()* |
946 | AliITSReconstructor::GetRecoParam()->GetSigmaY2(ilayer); |
947 | if (constrain) { |
948 | msz *= AliITSReconstructor::GetRecoParam()->GetNSigma2RoadZC(); |
949 | msy *= AliITSReconstructor::GetRecoParam()->GetNSigma2RoadYC(); |
950 | } else { |
951 | msz *= AliITSReconstructor::GetRecoParam()->GetNSigma2RoadZNonC(); |
952 | msy *= AliITSReconstructor::GetRecoParam()->GetNSigma2RoadYNonC(); |
953 | } |
954 | msz = 1./msz; // 1/RoadZ^2 |
955 | msy = 1./msy; // 1/RoadY^2 |
e43c066c |
956 | // |
e43c066c |
957 | // |
afd25725 |
958 | // LOOP OVER ALL POSSIBLE TRACK PROLONGATIONS ON THIS LAYER |
e43c066c |
959 | // |
afd25725 |
960 | const AliITSRecPoint *cl=0; |
961 | Int_t clidx=-1; |
962 | Double_t chi2trkcl=AliITSReconstructor::GetRecoParam()->GetMaxChi2(); // init with big value |
6518a6c5 |
963 | Bool_t deadzoneSPD=kFALSE; |
e43c066c |
964 | currenttrack = ¤ttrack1; |
6518a6c5 |
965 | |
966 | // check if the road contains a dead zone and create a prolongation |
967 | Int_t dead = CheckDeadZone(/*currenttrack,*/ilayer,/*idet,*/zmin,zmax/*,ymin,ymax*/); |
968 | if (dead) { |
969 | AliITStrackMI * updatetrack = new (&tracks[ilayer][ntracks[ilayer]]) AliITStrackMI(*currenttrack); |
970 | updatetrack->SetClIndex(ilayer,0); |
971 | // apply correction for material of the current layer |
972 | CorrectForLayerMaterial(updatetrack,ilayer,trackGlobXYZ1,"inward"); |
973 | if (constrain) { // apply vertex constrain |
974 | updatetrack->SetConstrain(constrain); |
975 | Bool_t isPrim = kTRUE; |
976 | if (ilayer<4) { // check that it's close to the vertex |
977 | updatetrack->GetDZ(GetX(),GetY(),GetZ(),updatetrack->GetDP()); //I.B. |
978 | if (TMath::Abs(updatetrack->GetD(0)/(1.+ilayer)) > // y |
979 | AliITSReconstructor::GetRecoParam()->GetMaxDZforPrimTrk() || |
980 | TMath::Abs(updatetrack->GetD(1)/(1.+ilayer)) > // z |
981 | AliITSReconstructor::GetRecoParam()->GetMaxDZforPrimTrk()) isPrim=kFALSE; |
982 | } |
983 | if (isPrim) updatetrack->Improve(budgetToPrimVertex,xyzVtx,ersVtx); |
984 | } |
985 | updatetrack->SetNDeadZone(updatetrack->GetNDeadZone()+1); |
986 | if (dead==1) { // dead zone at z=0,+-7cm in SPD |
987 | updatetrack->SetDeadZoneProbability(GetSPDDeadZoneProbability(updatetrack->GetZ(),TMath::Sqrt(updatetrack->GetSigmaZ2()))); |
988 | deadzoneSPD=kTRUE; |
989 | } |
990 | ntracks[ilayer]++; |
991 | } |
992 | |
993 | // loop over clusters in the road |
afd25725 |
994 | while ((cl=layer.GetNextCluster(clidx))!=0) { |
e43c066c |
995 | if (ntracks[ilayer]>95) break; //space for skipped clusters |
afd25725 |
996 | Bool_t changedet =kFALSE; |
6518a6c5 |
997 | if (cl->GetQ()==0 && deadzoneSPD==kTRUE) continue; |
afd25725 |
998 | Int_t idet=cl->GetDetectorIndex(); |
999 | |
1000 | if (currenttrack->GetDetectorIndex()==idet) { // track already on the cluster's detector |
1001 | // a first cut on track-cluster distance |
1002 | if ( (currenttrack->GetZ()-cl->GetZ())*(currenttrack->GetZ()-cl->GetZ())*msz + |
1003 | (currenttrack->GetY()-cl->GetY())*(currenttrack->GetY()-cl->GetY())*msy > 1. ) |
1004 | continue; // cluster not associated to track |
1005 | } else { // have to move track to cluster's detector |
e43c066c |
1006 | const AliITSdetector &det=layer.GetDetector(idet); |
afd25725 |
1007 | // a first cut on track-cluster distance |
e43c066c |
1008 | Double_t y,z; |
1009 | if (!currenttrack2.GetProlongationFast(det.GetPhi(),det.GetR(),y,z)) continue; |
afd25725 |
1010 | if ( (z-cl->GetZ())*(z-cl->GetZ())*msz + |
1011 | (y-cl->GetY())*(y-cl->GetY())*msy > 1. ) |
44347160 |
1012 | continue; // cluster not associated to track |
e43c066c |
1013 | // |
15dd636f |
1014 | new (&backuptrack) AliITStrackMI(currenttrack2); |
afd25725 |
1015 | changedet = kTRUE; |
e43c066c |
1016 | currenttrack =¤ttrack2; |
1017 | if (!currenttrack->Propagate(det.GetPhi(),det.GetR())) { |
15dd636f |
1018 | new (currenttrack) AliITStrackMI(backuptrack); |
afd25725 |
1019 | changedet = kFALSE; |
e43c066c |
1020 | continue; |
1021 | } |
1022 | currenttrack->SetDetectorIndex(idet); |
e50912db |
1023 | // Get again the budget to the primary vertex |
1024 | // for the current track being prolonged, if had to change detector |
1025 | //budgetToPrimVertex = GetEffectiveThickness();// not needed at the moment because anyway we take a mean material for this correction |
e43c066c |
1026 | } |
1027 | |
afd25725 |
1028 | // calculate track-clusters chi2 |
1029 | chi2trkcl = GetPredictedChi2MI(currenttrack,cl,ilayer); |
1030 | // chi2 cut |
1031 | if (chi2trkcl < AliITSReconstructor::GetRecoParam()->GetMaxChi2s(ilayer)) { |
6518a6c5 |
1032 | if (cl->GetQ()==0) deadzoneSPD=kTRUE; // only 1 prolongation with virtual cluster |
e43c066c |
1033 | if (ntracks[ilayer]>=100) continue; |
15dd636f |
1034 | AliITStrackMI * updatetrack = new (&tracks[ilayer][ntracks[ilayer]]) AliITStrackMI(*currenttrack); |
b9671574 |
1035 | updatetrack->SetClIndex(ilayer,0); |
afd25725 |
1036 | if (changedet) new (¤ttrack2) AliITStrackMI(backuptrack); |
1037 | |
6518a6c5 |
1038 | if (cl->GetQ()!=0) { // real cluster |
afd25725 |
1039 | if (!UpdateMI(updatetrack,cl,chi2trkcl,(ilayer<<28)+clidx)) continue; |
1040 | updatetrack->SetSampledEdx(cl->GetQ(),updatetrack->GetNumberOfClusters()-1); //b.b. |
6518a6c5 |
1041 | } else { // virtual cluster in dead zone |
b9671574 |
1042 | updatetrack->SetNDeadZone(updatetrack->GetNDeadZone()+1); |
6518a6c5 |
1043 | updatetrack->SetDeadZoneProbability(GetSPDDeadZoneProbability(updatetrack->GetZ(),TMath::Sqrt(updatetrack->GetSigmaZ2()))); |
e43c066c |
1044 | } |
afd25725 |
1045 | if (cl->IsUsed()) updatetrack->IncrementNUsed(); |
1046 | |
1047 | // apply correction for material of the current layer |
e50912db |
1048 | CorrectForLayerMaterial(updatetrack,ilayer,trackGlobXYZ1,"inward"); |
1049 | |
afd25725 |
1050 | if (constrain) { // apply vertex constrain |
b9671574 |
1051 | updatetrack->SetConstrain(constrain); |
e43c066c |
1052 | Bool_t isPrim = kTRUE; |
afd25725 |
1053 | if (ilayer<4) { // check that it's close to the vertex |
b9671574 |
1054 | updatetrack->GetDZ(GetX(),GetY(),GetZ(),updatetrack->GetDP()); //I.B. |
afd25725 |
1055 | if (TMath::Abs(updatetrack->GetD(0)/(1.+ilayer)) > // y |
1056 | AliITSReconstructor::GetRecoParam()->GetMaxDZforPrimTrk() || |
1057 | TMath::Abs(updatetrack->GetD(1)/(1.+ilayer)) > // z |
1058 | AliITSReconstructor::GetRecoParam()->GetMaxDZforPrimTrk()) isPrim=kFALSE; |
e43c066c |
1059 | } |
afd25725 |
1060 | if (isPrim) updatetrack->Improve(budgetToPrimVertex,xyzVtx,ersVtx); |
e43c066c |
1061 | } //apply vertex constrain |
1062 | ntracks[ilayer]++; |
afd25725 |
1063 | } // create new hypothesis |
2755f080 |
1064 | } // loop over possible prolongations |
1065 | |
1066 | // allow one prolongation without clusters |
6518a6c5 |
1067 | if (constrain && itrack<=1 && currenttrack1.GetNSkipped()==0 && deadzoneSPD==kFALSE && ntracks[ilayer]<100) { |
15dd636f |
1068 | AliITStrackMI* vtrack = new (&tracks[ilayer][ntracks[ilayer]]) AliITStrackMI(currenttrack1); |
2755f080 |
1069 | // apply correction for material of the current layer |
1070 | CorrectForLayerMaterial(vtrack,ilayer,trackGlobXYZ1,"inward"); |
b9671574 |
1071 | vtrack->SetClIndex(ilayer,0); |
afd25725 |
1072 | vtrack->Improve(budgetToPrimVertex,xyzVtx,ersVtx); |
b9671574 |
1073 | vtrack->IncrementNSkipped(); |
e43c066c |
1074 | ntracks[ilayer]++; |
1075 | } |
628e7bb0 |
1076 | |
2755f080 |
1077 | // allow one prolongation without clusters for tracks with |tgl|>1.1 |
1078 | if (constrain && itrack==0 && TMath::Abs(currenttrack1.GetTgl())>1.1) { //big theta - for low flux |
628e7bb0 |
1079 | AliITStrackMI* vtrack = new (&tracks[ilayer][ntracks[ilayer]]) AliITStrackMI(currenttrack1); |
2755f080 |
1080 | // apply correction for material of the current layer |
1081 | CorrectForLayerMaterial(vtrack,ilayer,trackGlobXYZ1,"inward"); |
b9671574 |
1082 | vtrack->SetClIndex(ilayer,0); |
afd25725 |
1083 | vtrack->Improve(budgetToPrimVertex,xyzVtx,ersVtx); |
b9671574 |
1084 | vtrack->SetNDeadZone(vtrack->GetNDeadZone()+1); |
628e7bb0 |
1085 | ntracks[ilayer]++; |
1086 | } |
1087 | |
e43c066c |
1088 | |
e50912db |
1089 | } // loop over tracks in layer ilayer+1 |
afd25725 |
1090 | |
1091 | //loop over track candidates for the current layer |
e43c066c |
1092 | // |
1093 | // |
1094 | Int_t accepted=0; |
1095 | |
afd25725 |
1096 | Int_t golden=0; |
e43c066c |
1097 | for (Int_t itrack=0;itrack<ntracks[ilayer];itrack++){ |
1098 | normalizedchi2[itrack] = NormalizedChi2(&tracks[ilayer][itrack],ilayer); |
afd25725 |
1099 | if (normalizedchi2[itrack] < |
1100 | AliITSReconstructor::GetRecoParam()->GetMaxNormChi2ForGolden(ilayer)) golden++; |
44347160 |
1101 | if (ilayer>4) { |
1102 | accepted++; |
1103 | } else { |
1104 | if (constrain) { // constrain |
afd25725 |
1105 | if (normalizedchi2[itrack]<AliITSReconstructor::GetRecoParam()->GetMaxNormChi2C(ilayer)+1) |
1106 | accepted++; |
44347160 |
1107 | } else { // !constrain |
afd25725 |
1108 | if (normalizedchi2[itrack]<AliITSReconstructor::GetRecoParam()->GetMaxNormChi2NonC(ilayer)+1) |
1109 | accepted++; |
44347160 |
1110 | } |
e43c066c |
1111 | } |
1112 | } |
afd25725 |
1113 | // sort tracks by increasing normalized chi2 |
1114 | TMath::Sort(ntracks[ilayer],normalizedchi2,nindexes[ilayer],kFALSE); |
e43c066c |
1115 | ntracks[ilayer] = TMath::Min(accepted,7+2*ilayer); |
afd25725 |
1116 | if (ntracks[ilayer]<golden+2+ilayer) ntracks[ilayer]=TMath::Min(golden+2+ilayer,accepted); |
e43c066c |
1117 | if (ntracks[ilayer]>90) ntracks[ilayer]=90; |
afd25725 |
1118 | } // end loop over layers |
1119 | |
afd25725 |
1120 | |
1121 | // |
1122 | // Now select tracks to be kept |
1123 | // |
44347160 |
1124 | Int_t max = constrain ? 20 : 5; |
e43c066c |
1125 | |
afd25725 |
1126 | // tracks that reach layer 0 (SPD inner) |
44347160 |
1127 | for (Int_t i=0; i<TMath::Min(max,ntracks[0]); i++) { |
15dd636f |
1128 | AliITStrackMI & track= tracks[0][nindexes[0][i]]; |
628e7bb0 |
1129 | if (track.GetNumberOfClusters()<2) continue; |
afd25725 |
1130 | if (!constrain && track.GetNormChi2(0) > |
6518a6c5 |
1131 | AliITSReconstructor::GetRecoParam()->GetMaxNormChi2NonCForHypothesis()) { |
1132 | continue; |
1133 | } |
15dd636f |
1134 | AddTrackHypothesys(new AliITStrackMI(track), esdindex); |
e43c066c |
1135 | } |
afd25725 |
1136 | |
1137 | // tracks that reach layer 1 (SPD outer) |
628e7bb0 |
1138 | for (Int_t i=0;i<TMath::Min(2,ntracks[1]);i++) { |
15dd636f |
1139 | AliITStrackMI & track= tracks[1][nindexes[1][i]]; |
e43c066c |
1140 | if (track.GetNumberOfClusters()<4) continue; |
afd25725 |
1141 | if (!constrain && track.GetNormChi2(1) > |
1142 | AliITSReconstructor::GetRecoParam()->GetMaxNormChi2NonCForHypothesis()) continue; |
b9671574 |
1143 | if (constrain) track.IncrementNSkipped(); |
81e97e0d |
1144 | if (!constrain) { |
b9671574 |
1145 | track.SetD(0,track.GetD(GetX(),GetY())); |
afd25725 |
1146 | track.SetNSkipped(track.GetNSkipped()+4./(4.+8.*TMath::Abs(track.GetD(0)))); |
b9671574 |
1147 | if (track.GetNumberOfClusters()+track.GetNDeadZone()+track.GetNSkipped()>6) { |
1148 | track.SetNSkipped(6-track.GetNumberOfClusters()+track.GetNDeadZone()); |
e43c066c |
1149 | } |
1150 | } |
15dd636f |
1151 | AddTrackHypothesys(new AliITStrackMI(track), esdindex); |
e43c066c |
1152 | } |
afd25725 |
1153 | |
6518a6c5 |
1154 | // tracks that reach layer 2 (SDD inner), only during non-constrained pass |
81e97e0d |
1155 | if (!constrain){ |
628e7bb0 |
1156 | for (Int_t i=0;i<TMath::Min(2,ntracks[2]);i++) { |
15dd636f |
1157 | AliITStrackMI & track= tracks[2][nindexes[2][i]]; |
628e7bb0 |
1158 | if (track.GetNumberOfClusters()<3) continue; |
afd25725 |
1159 | if (!constrain && track.GetNormChi2(2) > |
1160 | AliITSReconstructor::GetRecoParam()->GetMaxNormChi2NonCForHypothesis()) continue; |
b9671574 |
1161 | if (constrain) track.SetNSkipped(track.GetNSkipped()+2); |
81e97e0d |
1162 | if (!constrain){ |
b9671574 |
1163 | track.SetD(0,track.GetD(GetX(),GetY())); |
afd25725 |
1164 | track.SetNSkipped(track.GetNSkipped()+7./(7.+8.*TMath::Abs(track.GetD(0)))); |
b9671574 |
1165 | if (track.GetNumberOfClusters()+track.GetNDeadZone()+track.GetNSkipped()>6) { |
1166 | track.SetNSkipped(6-track.GetNumberOfClusters()+track.GetNDeadZone()); |
e43c066c |
1167 | } |
1168 | } |
15dd636f |
1169 | AddTrackHypothesys(new AliITStrackMI(track), esdindex); |
e43c066c |
1170 | } |
1171 | } |
81e97e0d |
1172 | |
afd25725 |
1173 | if (!constrain) { |
81e97e0d |
1174 | // |
afd25725 |
1175 | // register best track of each layer - important for V0 finder |
81e97e0d |
1176 | // |
1177 | for (Int_t ilayer=0;ilayer<5;ilayer++){ |
1178 | if (ntracks[ilayer]==0) continue; |
1179 | AliITStrackMI & track= tracks[ilayer][nindexes[ilayer][0]]; |
1180 | if (track.GetNumberOfClusters()<1) continue; |
1181 | CookLabel(&track,0); |
1182 | bestarray->AddAt(new AliITStrackMI(track),ilayer); |
1183 | } |
1184 | } |
1185 | // |
1186 | // update TPC V0 information |
1187 | // |
b9671574 |
1188 | if (otrack->GetESDtrack()->GetV0Index(0)>0){ |
81e97e0d |
1189 | Float_t fprimvertex[3]={GetX(),GetY(),GetZ()}; |
1190 | for (Int_t i=0;i<3;i++){ |
b9671574 |
1191 | Int_t index = otrack->GetESDtrack()->GetV0Index(i); |
81e97e0d |
1192 | if (index==0) break; |
44347160 |
1193 | AliV0 *vertex = (AliV0*)fEsd->GetV0(index); |
81e97e0d |
1194 | if (vertex->GetStatus()<0) continue; // rejected V0 |
1195 | // |
6c94f330 |
1196 | if (otrack->GetSign()>0) { |
81e97e0d |
1197 | vertex->SetIndex(0,esdindex); |
1198 | } |
1199 | else{ |
1200 | vertex->SetIndex(1,esdindex); |
1201 | } |
1202 | //find nearest layer with track info |
b75d63a7 |
1203 | Double_t xrp[3]; vertex->GetXYZ(xrp[0],xrp[1],xrp[2]); //I.B. |
1204 | Int_t nearestold = GetNearestLayer(xrp); //I.B. |
81e97e0d |
1205 | Int_t nearest = nearestold; |
1206 | for (Int_t ilayer =nearest;ilayer<8;ilayer++){ |
1207 | if (ntracks[nearest]==0){ |
1208 | nearest = ilayer; |
1209 | } |
1210 | } |
1211 | // |
1212 | AliITStrackMI & track= tracks[nearest][nindexes[nearest][0]]; |
1213 | if (nearestold<5&&nearest<5){ |
b9671574 |
1214 | Bool_t accept = track.GetNormChi2(nearest)<10; |
81e97e0d |
1215 | if (accept){ |
6c94f330 |
1216 | if (track.GetSign()>0) { |
b75d63a7 |
1217 | vertex->SetParamP(track); |
81e97e0d |
1218 | vertex->Update(fprimvertex); |
44347160 |
1219 | //vertex->SetIndex(0,track.fESDtrack->GetID()); |
81e97e0d |
1220 | if (track.GetNumberOfClusters()>2) AddTrackHypothesys(new AliITStrackMI(track), esdindex); |
1221 | }else{ |
b75d63a7 |
1222 | vertex->SetParamN(track); |
81e97e0d |
1223 | vertex->Update(fprimvertex); |
1224 | //vertex->SetIndex(1,track.fESDtrack->GetID()); |
1225 | if (track.GetNumberOfClusters()>2) AddTrackHypothesys(new AliITStrackMI(track), esdindex); |
1226 | } |
1227 | vertex->SetStatus(vertex->GetStatus()+1); |
1228 | }else{ |
44347160 |
1229 | //vertex->SetStatus(-2); // reject V0 - not enough clusters |
81e97e0d |
1230 | } |
1231 | } |
81e97e0d |
1232 | } |
afd25725 |
1233 | } |
1234 | |
e43c066c |
1235 | } |
44347160 |
1236 | //------------------------------------------------------------------------ |
e43c066c |
1237 | AliITStrackerMI::AliITSlayer & AliITStrackerMI::GetLayer(Int_t layer) const |
1238 | { |
1239 | //-------------------------------------------------------------------- |
1240 | // |
1241 | // |
1242 | return fgLayers[layer]; |
1243 | } |
44347160 |
1244 | //------------------------------------------------------------------------ |
8221b41b |
1245 | AliITStrackerMI::AliITSlayer::AliITSlayer(): |
1246 | fR(0), |
1247 | fPhiOffset(0), |
1248 | fNladders(0), |
1249 | fZOffset(0), |
1250 | fNdetectors(0), |
1251 | fDetectors(0), |
1252 | fN(0), |
1253 | fDy5(0), |
1254 | fDy10(0), |
1255 | fDy20(0), |
1256 | fClustersCs(0), |
1257 | fClusterIndexCs(0), |
1258 | fYcs(0), |
1259 | fZcs(0), |
1260 | fNcs(0), |
1261 | fCurrentSlice(-1), |
1262 | fZmax(0), |
1263 | fYmin(0), |
1264 | fYmax(0), |
1265 | fI(0), |
1266 | fImax(0), |
1267 | fSkip(0), |
1268 | fAccepted(0), |
1269 | fRoad(0){ |
e43c066c |
1270 | //-------------------------------------------------------------------- |
1271 | //default AliITSlayer constructor |
1272 | //-------------------------------------------------------------------- |
e50912db |
1273 | for (Int_t i=0; i<AliITSRecoParam::GetMaxClusterPerLayer(); i++) { |
e43c066c |
1274 | fClusterWeight[i]=0; |
1275 | fClusterTracks[0][i]=-1; |
1276 | fClusterTracks[1][i]=-1; |
1277 | fClusterTracks[2][i]=-1; |
1278 | fClusterTracks[3][i]=-1; |
1279 | } |
1280 | } |
44347160 |
1281 | //------------------------------------------------------------------------ |
e43c066c |
1282 | AliITStrackerMI::AliITSlayer:: |
8221b41b |
1283 | AliITSlayer(Double_t r,Double_t p,Double_t z,Int_t nl,Int_t nd): |
1284 | fR(r), |
1285 | fPhiOffset(p), |
1286 | fNladders(nl), |
1287 | fZOffset(z), |
1288 | fNdetectors(nd), |
1289 | fDetectors(0), |
1290 | fN(0), |
1291 | fDy5(0), |
1292 | fDy10(0), |
1293 | fDy20(0), |
1294 | fClustersCs(0), |
1295 | fClusterIndexCs(0), |
1296 | fYcs(0), |
1297 | fZcs(0), |
1298 | fNcs(0), |
1299 | fCurrentSlice(-1), |
1300 | fZmax(0), |
1301 | fYmin(0), |
1302 | fYmax(0), |
1303 | fI(0), |
1304 | fImax(0), |
1305 | fSkip(0), |
1306 | fAccepted(0), |
1307 | fRoad(0) { |
e43c066c |
1308 | //-------------------------------------------------------------------- |
1309 | //main AliITSlayer constructor |
1310 | //-------------------------------------------------------------------- |
e43c066c |
1311 | fDetectors=new AliITSdetector[fNladders*fNdetectors]; |
afd25725 |
1312 | fRoad=2*fR*TMath::Sqrt(TMath::Pi()/1.);//assuming that there's only one cluster |
e43c066c |
1313 | } |
44347160 |
1314 | //------------------------------------------------------------------------ |
8221b41b |
1315 | AliITStrackerMI::AliITSlayer::AliITSlayer(const AliITSlayer& layer): |
1316 | fR(layer.fR), |
1317 | fPhiOffset(layer.fPhiOffset), |
1318 | fNladders(layer.fNladders), |
1319 | fZOffset(layer.fZOffset), |
1320 | fNdetectors(layer.fNdetectors), |
1321 | fDetectors(layer.fDetectors), |
1322 | fN(layer.fN), |
1323 | fDy5(layer.fDy5), |
1324 | fDy10(layer.fDy10), |
1325 | fDy20(layer.fDy20), |
1326 | fClustersCs(layer.fClustersCs), |
1327 | fClusterIndexCs(layer.fClusterIndexCs), |
1328 | fYcs(layer.fYcs), |
1329 | fZcs(layer.fZcs), |
1330 | fNcs(layer.fNcs), |
1331 | fCurrentSlice(layer.fCurrentSlice), |
1332 | fZmax(layer.fZmax), |
1333 | fYmin(layer.fYmin), |
1334 | fYmax(layer.fYmax), |
1335 | fI(layer.fI), |
1336 | fImax(layer.fImax), |
1337 | fSkip(layer.fSkip), |
1338 | fAccepted(layer.fAccepted), |
1339 | fRoad(layer.fRoad){ |
1340 | //Copy constructor |
1341 | } |
44347160 |
1342 | //------------------------------------------------------------------------ |
e43c066c |
1343 | AliITStrackerMI::AliITSlayer::~AliITSlayer() { |
1344 | //-------------------------------------------------------------------- |
1345 | // AliITSlayer destructor |
1346 | //-------------------------------------------------------------------- |
1347 | delete[] fDetectors; |
1348 | for (Int_t i=0; i<fN; i++) delete fClusters[i]; |
e50912db |
1349 | for (Int_t i=0; i<AliITSRecoParam::GetMaxClusterPerLayer(); i++) { |
e43c066c |
1350 | fClusterWeight[i]=0; |
1351 | fClusterTracks[0][i]=-1; |
1352 | fClusterTracks[1][i]=-1; |
1353 | fClusterTracks[2][i]=-1; |
1354 | fClusterTracks[3][i]=-1; |
1355 | } |
1356 | } |
44347160 |
1357 | //------------------------------------------------------------------------ |
e43c066c |
1358 | void AliITStrackerMI::AliITSlayer::ResetClusters() { |
1359 | //-------------------------------------------------------------------- |
1360 | // This function removes loaded clusters |
1361 | //-------------------------------------------------------------------- |
1362 | for (Int_t i=0; i<fN; i++) delete fClusters[i]; |
e50912db |
1363 | for (Int_t i=0; i<AliITSRecoParam::GetMaxClusterPerLayer(); i++){ |
e43c066c |
1364 | fClusterWeight[i]=0; |
1365 | fClusterTracks[0][i]=-1; |
1366 | fClusterTracks[1][i]=-1; |
1367 | fClusterTracks[2][i]=-1; |
1368 | fClusterTracks[3][i]=-1; |
1369 | } |
1370 | |
1371 | fN=0; |
1372 | fI=0; |
1373 | } |
44347160 |
1374 | //------------------------------------------------------------------------ |
e43c066c |
1375 | void AliITStrackerMI::AliITSlayer::ResetWeights() { |
1376 | //-------------------------------------------------------------------- |
1377 | // This function reset weights of the clusters |
1378 | //-------------------------------------------------------------------- |
e50912db |
1379 | for (Int_t i=0; i<AliITSRecoParam::GetMaxClusterPerLayer(); i++) { |
e43c066c |
1380 | fClusterWeight[i]=0; |
1381 | fClusterTracks[0][i]=-1; |
1382 | fClusterTracks[1][i]=-1; |
1383 | fClusterTracks[2][i]=-1; |
1384 | fClusterTracks[3][i]=-1; |
1385 | } |
1386 | for (Int_t i=0; i<fN;i++) { |
00a7cc50 |
1387 | AliITSRecPoint * cl = (AliITSRecPoint*)GetCluster(i); |
e43c066c |
1388 | if (cl&&cl->IsUsed()) cl->Use(); |
1389 | } |
1390 | |
1391 | } |
44347160 |
1392 | //------------------------------------------------------------------------ |
e43c066c |
1393 | void AliITStrackerMI::AliITSlayer::ResetRoad() { |
1394 | //-------------------------------------------------------------------- |
1395 | // This function calculates the road defined by the cluster density |
1396 | //-------------------------------------------------------------------- |
1397 | Int_t n=0; |
1398 | for (Int_t i=0; i<fN; i++) { |
1399 | if (TMath::Abs(fClusters[i]->GetZ())<fR) n++; |
1400 | } |
afd25725 |
1401 | if (n>1) fRoad=2*fR*TMath::Sqrt(TMath::Pi()/n); |
e43c066c |
1402 | } |
44347160 |
1403 | //------------------------------------------------------------------------ |
afd25725 |
1404 | Int_t AliITStrackerMI::AliITSlayer::InsertCluster(AliITSRecPoint *cl) { |
e43c066c |
1405 | //-------------------------------------------------------------------- |
1406 | //This function adds a cluster to this layer |
1407 | //-------------------------------------------------------------------- |
e50912db |
1408 | if (fN==AliITSRecoParam::GetMaxClusterPerLayer()) { |
e43c066c |
1409 | ::Error("InsertCluster","Too many clusters !\n"); |
1410 | return 1; |
1411 | } |
1412 | fCurrentSlice=-1; |
afd25725 |
1413 | fClusters[fN]=cl; |
1d4090b7 |
1414 | fN++; |
afd25725 |
1415 | AliITSdetector &det=GetDetector(cl->GetDetectorIndex()); |
1416 | if (cl->GetY()<det.GetYmin()) det.SetYmin(cl->GetY()); |
1417 | if (cl->GetY()>det.GetYmax()) det.SetYmax(cl->GetY()); |
1418 | if (cl->GetZ()<det.GetZmin()) det.SetZmin(cl->GetZ()); |
1419 | if (cl->GetZ()>det.GetZmax()) det.SetZmax(cl->GetZ()); |
e43c066c |
1420 | |
1421 | return 0; |
1422 | } |
44347160 |
1423 | //------------------------------------------------------------------------ |
e43c066c |
1424 | void AliITStrackerMI::AliITSlayer::SortClusters() |
1425 | { |
1426 | // |
1427 | //sort clusters |
1428 | // |
00a7cc50 |
1429 | AliITSRecPoint **clusters = new AliITSRecPoint*[fN]; |
1d4090b7 |
1430 | Float_t *z = new Float_t[fN]; |
1431 | Int_t * index = new Int_t[fN]; |
1432 | // |
1433 | for (Int_t i=0;i<fN;i++){ |
1434 | z[i] = fClusters[i]->GetZ(); |
1435 | } |
1436 | TMath::Sort(fN,z,index,kFALSE); |
1437 | for (Int_t i=0;i<fN;i++){ |
1438 | clusters[i] = fClusters[index[i]]; |
1439 | } |
1440 | // |
1441 | for (Int_t i=0;i<fN;i++){ |
1442 | fClusters[i] = clusters[i]; |
1443 | fZ[i] = fClusters[i]->GetZ(); |
1444 | AliITSdetector &det=GetDetector(fClusters[i]->GetDetectorIndex()); |
1445 | Double_t y=fR*det.GetPhi() + fClusters[i]->GetY(); |
1446 | if (y>2.*fR*TMath::Pi()) y -= 2.*fR*TMath::Pi(); |
1447 | fY[i] = y; |
1448 | } |
1449 | delete[] index; |
1450 | delete[] z; |
1451 | delete[] clusters; |
1452 | // |
1453 | |
e43c066c |
1454 | fYB[0]=10000000; |
1455 | fYB[1]=-10000000; |
1456 | for (Int_t i=0;i<fN;i++){ |
1457 | if (fY[i]<fYB[0]) fYB[0]=fY[i]; |
1458 | if (fY[i]>fYB[1]) fYB[1]=fY[i]; |
1459 | fClusterIndex[i] = i; |
1460 | } |
1461 | // |
1462 | // fill slices |
1463 | fDy5 = (fYB[1]-fYB[0])/5.; |
1464 | fDy10 = (fYB[1]-fYB[0])/10.; |
1465 | fDy20 = (fYB[1]-fYB[0])/20.; |
1466 | for (Int_t i=0;i<6;i++) fN5[i] =0; |
1467 | for (Int_t i=0;i<11;i++) fN10[i]=0; |
1468 | for (Int_t i=0;i<21;i++) fN20[i]=0; |
1469 | // |
1470 | 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;} |
1471 | 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;} |
1472 | 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;} |
1473 | // |
1474 | // |
1d4090b7 |
1475 | for (Int_t i=0;i<fN;i++) |
1476 | for (Int_t irot=-1;irot<=1;irot++){ |
1477 | Float_t curY = fY[i]+irot*TMath::TwoPi()*fR; |
1478 | // slice 5 |
1479 | for (Int_t slice=0; slice<6;slice++){ |
e50912db |
1480 | if (fBy5[slice][0]<curY && curY<fBy5[slice][1]&&fN5[slice]<AliITSRecoParam::GetMaxClusterPerLayer5()){ |
1d4090b7 |
1481 | fClusters5[slice][fN5[slice]] = fClusters[i]; |
1482 | fY5[slice][fN5[slice]] = curY; |
1483 | fZ5[slice][fN5[slice]] = fZ[i]; |
1484 | fClusterIndex5[slice][fN5[slice]]=i; |
1485 | fN5[slice]++; |
1486 | } |
e43c066c |
1487 | } |
1d4090b7 |
1488 | // slice 10 |
1489 | for (Int_t slice=0; slice<11;slice++){ |
e50912db |
1490 | if (fBy10[slice][0]<curY && curY<fBy10[slice][1]&&fN10[slice]<AliITSRecoParam::GetMaxClusterPerLayer10()){ |
1d4090b7 |
1491 | fClusters10[slice][fN10[slice]] = fClusters[i]; |
1492 | fY10[slice][fN10[slice]] = curY; |
1493 | fZ10[slice][fN10[slice]] = fZ[i]; |
1494 | fClusterIndex10[slice][fN10[slice]]=i; |
1495 | fN10[slice]++; |
1496 | } |
e43c066c |
1497 | } |
1d4090b7 |
1498 | // slice 20 |
1499 | for (Int_t slice=0; slice<21;slice++){ |
e50912db |
1500 | if (fBy20[slice][0]<curY && curY<fBy20[slice][1]&&fN20[slice]<AliITSRecoParam::GetMaxClusterPerLayer20()){ |
1d4090b7 |
1501 | fClusters20[slice][fN20[slice]] = fClusters[i]; |
1502 | fY20[slice][fN20[slice]] = curY; |
1503 | fZ20[slice][fN20[slice]] = fZ[i]; |
1504 | fClusterIndex20[slice][fN20[slice]]=i; |
1505 | fN20[slice]++; |
1506 | } |
1507 | } |
e43c066c |
1508 | } |
1d4090b7 |
1509 | |
1510 | // |
1511 | // consistency check |
1512 | // |
1513 | for (Int_t i=0;i<fN-1;i++){ |
1514 | if (fZ[i]>fZ[i+1]){ |
1515 | printf("Bugg\n"); |
e43c066c |
1516 | } |
1517 | } |
1d4090b7 |
1518 | // |
1519 | for (Int_t slice=0;slice<21;slice++) |
1520 | for (Int_t i=0;i<fN20[slice]-1;i++){ |
1521 | if (fZ20[slice][i]>fZ20[slice][i+1]){ |
1522 | printf("Bugg\n"); |
1523 | } |
1524 | } |
1525 | |
1526 | |
e43c066c |
1527 | } |
44347160 |
1528 | //------------------------------------------------------------------------ |
e43c066c |
1529 | Int_t AliITStrackerMI::AliITSlayer::FindClusterIndex(Float_t z) const { |
1530 | //-------------------------------------------------------------------- |
1531 | // This function returns the index of the nearest cluster |
1532 | //-------------------------------------------------------------------- |
1533 | Int_t ncl=0; |
1534 | const Float_t *zcl; |
1535 | if (fCurrentSlice<0) { |
1536 | ncl = fN; |
1537 | zcl = fZ; |
1538 | } |
1539 | else{ |
1540 | ncl = fNcs; |
1541 | zcl = fZcs;; |
1542 | } |
1543 | |
1544 | if (ncl==0) return 0; |
1545 | Int_t b=0, e=ncl-1, m=(b+e)/2; |
1546 | for (; b<e; m=(b+e)/2) { |
1547 | // if (z > fClusters[m]->GetZ()) b=m+1; |
1548 | if (z > zcl[m]) b=m+1; |
1549 | else e=m; |
1550 | } |
1551 | return m; |
1552 | } |
44347160 |
1553 | //------------------------------------------------------------------------ |
e43c066c |
1554 | void AliITStrackerMI::AliITSlayer:: |
1555 | SelectClusters(Double_t zmin,Double_t zmax,Double_t ymin, Double_t ymax) { |
1556 | //-------------------------------------------------------------------- |
1557 | // This function sets the "window" |
1558 | //-------------------------------------------------------------------- |
1559 | |
628e7bb0 |
1560 | Double_t circle=2*TMath::Pi()*fR; |
e43c066c |
1561 | fYmin = ymin; fYmax =ymax; |
1562 | Float_t ymiddle = (fYmin+fYmax)*0.5; |
1563 | if (ymiddle<fYB[0]) {fYmin+=circle; fYmax+=circle;ymiddle+=circle;} |
1564 | else{ |
1565 | if (ymiddle>fYB[1]) {fYmin-=circle; fYmax-=circle;ymiddle-=circle;} |
1566 | } |
1567 | // |
1568 | fCurrentSlice =-1; |
1569 | // defualt take all |
1570 | fClustersCs = fClusters; |
1571 | fClusterIndexCs = fClusterIndex; |
1572 | fYcs = fY; |
1573 | fZcs = fZ; |
1574 | fNcs = fN; |
628e7bb0 |
1575 | // |
e43c066c |
1576 | //is in 20 slice? |
1577 | if (fCurrentSlice<0&&TMath::Abs(fYmax-fYmin)<1.49*fDy20){ |
1578 | Int_t slice = int(0.5+(ymiddle-fYB[0])/fDy20); |
1579 | if (slice<0) slice=0; |
1580 | if (slice>20) slice=20; |
1581 | Bool_t isOK = (fYmin>fBy20[slice][0]&&fYmax<fBy20[slice][1]); |
1582 | if (isOK) { |
1583 | fCurrentSlice=slice; |
1584 | fClustersCs = fClusters20[fCurrentSlice]; |
1585 | fClusterIndexCs = fClusterIndex20[fCurrentSlice]; |
1586 | fYcs = fY20[fCurrentSlice]; |
1587 | fZcs = fZ20[fCurrentSlice]; |
1588 | fNcs = fN20[fCurrentSlice]; |
1589 | } |
1590 | } |
1591 | // |
1592 | //is in 10 slice? |
1593 | if (fCurrentSlice<0&&TMath::Abs(fYmax-fYmin)<1.49*fDy10){ |
1594 | Int_t slice = int(0.5+(ymiddle-fYB[0])/fDy10); |
1595 | if (slice<0) slice=0; |
1596 | if (slice>10) slice=10; |
1597 | Bool_t isOK = (fYmin>fBy10[slice][0]&&fYmax<fBy10[slice][1]); |
1598 | if (isOK) { |
1599 | fCurrentSlice=slice; |
1600 | fClustersCs = fClusters10[fCurrentSlice]; |
1601 | fClusterIndexCs = fClusterIndex10[fCurrentSlice]; |
1602 | fYcs = fY10[fCurrentSlice]; |
1603 | fZcs = fZ10[fCurrentSlice]; |
1604 | fNcs = fN10[fCurrentSlice]; |
1605 | } |
1606 | } |
1607 | // |
1608 | //is in 5 slice? |
1609 | if (fCurrentSlice<0&&TMath::Abs(fYmax-fYmin)<1.49*fDy5){ |
1610 | Int_t slice = int(0.5+(ymiddle-fYB[0])/fDy5); |
1611 | if (slice<0) slice=0; |
1612 | if (slice>5) slice=5; |
1613 | Bool_t isOK = (fYmin>fBy5[slice][0]&&fYmax<fBy5[slice][1]); |
1614 | if ( isOK){ |
1615 | fCurrentSlice=slice; |
1616 | fClustersCs = fClusters5[fCurrentSlice]; |
1617 | fClusterIndexCs = fClusterIndex5[fCurrentSlice]; |
1618 | fYcs = fY5[fCurrentSlice]; |
1619 | fZcs = fZ5[fCurrentSlice]; |
1620 | fNcs = fN5[fCurrentSlice]; |
1621 | } |
1622 | } |
628e7bb0 |
1623 | // |
e43c066c |
1624 | fI=FindClusterIndex(zmin); fZmax=zmax; |
1625 | fImax = TMath::Min(FindClusterIndex(zmax)+1,fNcs); |
1626 | fSkip = 0; |
1627 | fAccepted =0; |
6518a6c5 |
1628 | |
1629 | return; |
e43c066c |
1630 | } |
44347160 |
1631 | //------------------------------------------------------------------------ |
628e7bb0 |
1632 | Int_t AliITStrackerMI::AliITSlayer:: |
1633 | FindDetectorIndex(Double_t phi, Double_t z) const { |
1634 | //-------------------------------------------------------------------- |
1635 | //This function finds the detector crossed by the track |
1636 | //-------------------------------------------------------------------- |
31fb8575 |
1637 | Double_t dphi; |
1638 | if (fZOffset<0) // old geometry |
1639 | dphi = -(phi-fPhiOffset); |
1640 | else // new geometry |
1641 | dphi = phi-fPhiOffset; |
1642 | |
6518a6c5 |
1643 | |
628e7bb0 |
1644 | if (dphi < 0) dphi += 2*TMath::Pi(); |
1645 | else if (dphi >= 2*TMath::Pi()) dphi -= 2*TMath::Pi(); |
1646 | Int_t np=Int_t(dphi*fNladders*0.5/TMath::Pi()+0.5); |
1647 | if (np>=fNladders) np-=fNladders; |
1648 | if (np<0) np+=fNladders; |
1649 | |
6518a6c5 |
1650 | |
628e7bb0 |
1651 | Double_t dz=fZOffset-z; |
6518a6c5 |
1652 | Double_t nnz = dz*(fNdetectors-1)*0.5/fZOffset+0.5; |
1653 | Int_t nz = (nnz<0 ? -1 : (Int_t)nnz); |
628e7bb0 |
1654 | if (nz>=fNdetectors) return -1; |
1655 | if (nz<0) return -1; |
1656 | |
1657 | return np*fNdetectors + nz; |
1658 | } |
44347160 |
1659 | //------------------------------------------------------------------------ |
00a7cc50 |
1660 | const AliITSRecPoint *AliITStrackerMI::AliITSlayer::GetNextCluster(Int_t &ci){ |
e43c066c |
1661 | //-------------------------------------------------------------------- |
1662 | // This function returns clusters within the "window" |
1663 | //-------------------------------------------------------------------- |
1664 | |
1665 | if (fCurrentSlice<0){ |
1666 | Double_t rpi2 = 2.*fR*TMath::Pi(); |
1667 | for (Int_t i=fI; i<fImax; i++) { |
1668 | Double_t y = fY[i]; |
1669 | if (fYmax<y) y -= rpi2; |
1d4090b7 |
1670 | if (fYmin>y) y += rpi2; |
e43c066c |
1671 | if (y<fYmin) continue; |
1672 | if (y>fYmax) continue; |
1673 | if (fClusters[i]->GetQ()==0&&fSkip==2) continue; |
1674 | ci=i; |
1675 | fI=i+1; |
1676 | return fClusters[i]; |
1677 | } |
1678 | } |
1679 | else{ |
1680 | for (Int_t i=fI; i<fImax; i++) { |
1681 | if (fYcs[i]<fYmin) continue; |
1682 | if (fYcs[i]>fYmax) continue; |
1683 | if (fClustersCs[i]->GetQ()==0&&fSkip==2) continue; |
1684 | ci=fClusterIndexCs[i]; |
1685 | fI=i+1; |
1686 | return fClustersCs[i]; |
1687 | } |
1688 | } |
1689 | return 0; |
1690 | } |
44347160 |
1691 | //------------------------------------------------------------------------ |
e43c066c |
1692 | Double_t AliITStrackerMI::AliITSlayer::GetThickness(Double_t y,Double_t z,Double_t &x0) |
1693 | const { |
1694 | //-------------------------------------------------------------------- |
afd25725 |
1695 | // This function returns the layer thickness at this point (units X0) |
e43c066c |
1696 | //-------------------------------------------------------------------- |
1697 | Double_t d=0.0085; |
e50912db |
1698 | x0=AliITSRecoParam::GetX0Air(); |
e43c066c |
1699 | if (43<fR&&fR<45) { //SSD2 |
1700 | Double_t dd=0.0034; |
1701 | d=dd; |
1702 | if (TMath::Abs(y-0.00)>3.40) d+=dd; |
1703 | if (TMath::Abs(y-1.90)<0.45) {d+=(0.013-0.0034);} |
1704 | if (TMath::Abs(y+1.90)<0.45) {d+=(0.013-0.0034);} |
1705 | for (Int_t i=0; i<12; i++) { |
1706 | if (TMath::Abs(z-3.9*(i+0.5))<0.15) { |
1707 | if (TMath::Abs(y-0.00)>3.40) d+=dd; |
1708 | d+=0.0034; |
1709 | break; |
1710 | } |
1711 | if (TMath::Abs(z+3.9*(i+0.5))<0.15) { |
1712 | if (TMath::Abs(y-0.00)>3.40) d+=dd; |
1713 | d+=0.0034; |
1714 | break; |
1715 | } |
1716 | if (TMath::Abs(z-3.4-3.9*i)<0.50) {d+=(0.016-0.0034); break;} |
1717 | if (TMath::Abs(z+0.5+3.9*i)<0.50) {d+=(0.016-0.0034); break;} |
1718 | } |
1719 | } else |
1720 | if (37<fR&&fR<41) { //SSD1 |
1721 | Double_t dd=0.0034; |
1722 | d=dd; |
1723 | if (TMath::Abs(y-0.00)>3.40) d+=dd; |
1724 | if (TMath::Abs(y-1.90)<0.45) {d+=(0.013-0.0034);} |
1725 | if (TMath::Abs(y+1.90)<0.45) {d+=(0.013-0.0034);} |
1726 | for (Int_t i=0; i<11; i++) { |
1727 | if (TMath::Abs(z-3.9*i)<0.15) { |
1728 | if (TMath::Abs(y-0.00)>3.40) d+=dd; |
1729 | d+=dd; |
1730 | break; |
1731 | } |
1732 | if (TMath::Abs(z+3.9*i)<0.15) { |
1733 | if (TMath::Abs(y-0.00)>3.40) d+=dd; |
1734 | d+=dd; |
1735 | break; |
1736 | } |
1737 | if (TMath::Abs(z-1.85-3.9*i)<0.50) {d+=(0.016-0.0034); break;} |
1738 | if (TMath::Abs(z+2.05+3.9*i)<0.50) {d+=(0.016-0.0034); break;} |
1739 | } |
1740 | } else |
1741 | if (13<fR&&fR<26) { //SDD |
1742 | Double_t dd=0.0033; |
1743 | d=dd; |
1744 | if (TMath::Abs(y-0.00)>3.30) d+=dd; |
1745 | |
1746 | if (TMath::Abs(y-1.80)<0.55) { |
1747 | d+=0.016; |
1748 | for (Int_t j=0; j<20; j++) { |
1749 | if (TMath::Abs(z+0.7+1.47*j)<0.12) {d+=0.08; x0=9.; break;} |
1750 | if (TMath::Abs(z-0.7-1.47*j)<0.12) {d+=0.08; x0=9.; break;} |
1751 | } |
1752 | } |
1753 | if (TMath::Abs(y+1.80)<0.55) { |
1754 | d+=0.016; |
1755 | for (Int_t j=0; j<20; j++) { |
1756 | if (TMath::Abs(z-0.7-1.47*j)<0.12) {d+=0.08; x0=9.; break;} |
1757 | if (TMath::Abs(z+0.7+1.47*j)<0.12) {d+=0.08; x0=9.; break;} |
1758 | } |
1759 | } |
1760 | |
1761 | for (Int_t i=0; i<4; i++) { |
1762 | if (TMath::Abs(z-7.3*i)<0.60) { |
1763 | d+=dd; |
1764 | if (TMath::Abs(y-0.00)>3.30) d+=dd; |
1765 | break; |
1766 | } |
1767 | if (TMath::Abs(z+7.3*i)<0.60) { |
1768 | d+=dd; |
1769 | if (TMath::Abs(y-0.00)>3.30) d+=dd; |
1770 | break; |
1771 | } |
1772 | } |
1773 | } else |
1774 | if (6<fR&&fR<8) { //SPD2 |
1775 | Double_t dd=0.0063; x0=21.5; |
1776 | d=dd; |
1777 | if (TMath::Abs(y-3.08)>0.5) d+=dd; |
afd25725 |
1778 | if (TMath::Abs(y-3.03)<0.10) d+=0.014; |
e43c066c |
1779 | } else |
1780 | if (3<fR&&fR<5) { //SPD1 |
1781 | Double_t dd=0.0063; x0=21.5; |
1782 | d=dd; |
1783 | if (TMath::Abs(y+0.21)>0.6) d+=dd; |
afd25725 |
1784 | if (TMath::Abs(y+0.10)<0.10) d+=0.014; |
e43c066c |
1785 | } |
1786 | |
1787 | return d; |
1788 | } |
44347160 |
1789 | //------------------------------------------------------------------------ |
e50912db |
1790 | Double_t AliITStrackerMI::GetEffectiveThickness() |
e43c066c |
1791 | { |
1792 | //-------------------------------------------------------------------- |
afd25725 |
1793 | // Returns the thickness between the current layer and the vertex (units X0) |
e43c066c |
1794 | //-------------------------------------------------------------------- |
e43c066c |
1795 | |
e50912db |
1796 | if(fUseTGeo!=0) { |
1797 | if(fxOverX0Layer[0]<0) BuildMaterialLUT("Layers"); |
1798 | if(fxOverX0Shield[0]<0) BuildMaterialLUT("Shields"); |
1799 | if(fxOverX0Pipe<0) BuildMaterialLUT("Pipe"); |
1800 | } |
1801 | |
afd25725 |
1802 | // beam pipe |
e50912db |
1803 | Double_t dPipe = (fUseTGeo==0 ? AliITSRecoParam::GetdPipe() : fxOverX0Pipe); |
1804 | Double_t d=dPipe*AliITSRecoParam::GetrPipe()*AliITSRecoParam::GetrPipe(); |
afd25725 |
1805 | |
1806 | // layers |
1807 | Double_t x0=0; |
e43c066c |
1808 | Double_t xn=fgLayers[fI].GetR(); |
1809 | for (Int_t i=0; i<fI; i++) { |
1810 | Double_t xi=fgLayers[i].GetR(); |
e50912db |
1811 | Double_t dLayer = (fUseTGeo==0 ? fgLayers[i].GetThickness(0,0,x0) : fxOverX0Layer[i]); |
1812 | d+=dLayer*xi*xi; |
e43c066c |
1813 | } |
1814 | |
afd25725 |
1815 | // shields |
e43c066c |
1816 | if (fI>1) { |
e50912db |
1817 | Double_t dshieldSPD = (fUseTGeo==0 ? AliITSRecoParam::Getdshield(0) : fxOverX0Shield[0]); |
1818 | d+=dshieldSPD*AliITSRecoParam::GetrInsideShield(0)*AliITSRecoParam::GetrInsideShield(0); |
e43c066c |
1819 | } |
e43c066c |
1820 | if (fI>3) { |
e50912db |
1821 | Double_t dshieldSDD = (fUseTGeo==0 ? AliITSRecoParam::Getdshield(1) : fxOverX0Shield[1]); |
1822 | d+=dshieldSDD*AliITSRecoParam::GetrInsideShield(1)*AliITSRecoParam::GetrInsideShield(1); |
e43c066c |
1823 | } |
e43c066c |
1824 | return d/(xn*xn); |
1825 | } |
44347160 |
1826 | //------------------------------------------------------------------------ |
e43c066c |
1827 | Int_t AliITStrackerMI::AliITSlayer::InRoad() const { |
1828 | //-------------------------------------------------------------------- |
1829 | // This function returns number of clusters within the "window" |
1830 | //-------------------------------------------------------------------- |
1831 | Int_t ncl=0; |
1832 | for (Int_t i=fI; i<fN; i++) { |
00a7cc50 |
1833 | const AliITSRecPoint *c=fClusters[i]; |
e43c066c |
1834 | if (c->GetZ() > fZmax) break; |
1835 | if (c->IsUsed()) continue; |
1836 | const AliITSdetector &det=GetDetector(c->GetDetectorIndex()); |
1837 | Double_t y=fR*det.GetPhi() + c->GetY(); |
1838 | |
1839 | if (y>2.*fR*TMath::Pi()) y -= 2*fR*TMath::Pi(); |
1840 | if (y>1.*fR*TMath::Pi() && fYmax<y) y -= 2*fR*TMath::Pi(); |
1841 | |
1842 | if (y<fYmin) continue; |
1843 | if (y>fYmax) continue; |
1844 | ncl++; |
1845 | } |
1846 | return ncl; |
1847 | } |
44347160 |
1848 | //------------------------------------------------------------------------ |
ef7253ac |
1849 | Bool_t AliITStrackerMI::RefitAt(Double_t xx,AliITStrackMI *t, |
1850 | const AliITStrackMI *c, Bool_t extra) { |
e43c066c |
1851 | //-------------------------------------------------------------------- |
1852 | // This function refits the track "t" at the position "x" using |
1853 | // the clusters from "c" |
ef7253ac |
1854 | // If "extra"==kTRUE, |
1855 | // the clusters from overlapped modules get attached to "t" |
e43c066c |
1856 | //-------------------------------------------------------------------- |
6518a6c5 |
1857 | |
e50912db |
1858 | Int_t index[AliITSgeomTGeo::kNLayers]; |
e43c066c |
1859 | Int_t k; |
e50912db |
1860 | for (k=0; k<AliITSgeomTGeo::GetNLayers(); k++) index[k]=-1; |
e43c066c |
1861 | Int_t nc=c->GetNumberOfClusters(); |
1862 | for (k=0; k<nc; k++) { |
1863 | Int_t idx=c->GetClusterIndex(k),nl=(idx&0xf0000000)>>28; |
1864 | index[nl]=idx; |
1865 | } |
1866 | |
6518a6c5 |
1867 | // special for cosmics: check which is the innermost layer crossed |
afd25725 |
1868 | // by the track |
1869 | Int_t innermostlayer=5; |
1870 | Double_t d = TMath::Abs(t->GetD(0.,0.)); |
e50912db |
1871 | for(innermostlayer=0; innermostlayer<AliITSgeomTGeo::GetNLayers(); innermostlayer++) |
afd25725 |
1872 | if(d<fgLayers[innermostlayer].GetR()) break; |
1873 | //printf(" d %f innermost %d\n",d,innermostlayer); |
1874 | |
e43c066c |
1875 | Int_t from, to, step; |
1876 | if (xx > t->GetX()) { |
e50912db |
1877 | from=innermostlayer; to=AliITSgeomTGeo::GetNLayers(); |
e43c066c |
1878 | step=+1; |
1879 | } else { |
e50912db |
1880 | from=AliITSgeomTGeo::GetNLayers()-1; to=innermostlayer-1; |
e43c066c |
1881 | step=-1; |
1882 | } |
e50912db |
1883 | TString dir=(step>0 ? "outward" : "inward"); |
e43c066c |
1884 | |
afd25725 |
1885 | // loop on the layers |
6518a6c5 |
1886 | for (Int_t ilayer=from; ilayer != to; ilayer += step) { |
1887 | AliITSlayer &layer=fgLayers[ilayer]; |
e43c066c |
1888 | Double_t r=layer.GetR(); |
1889 | |
afd25725 |
1890 | // material between SSD and SDD, SDD and SPD |
6518a6c5 |
1891 | Double_t hI=ilayer-0.5*step; |
e50912db |
1892 | if (TMath::Abs(hI-3.5)<0.01) // SDDouter |
1893 | if(!CorrectForShieldMaterial(t,"SDD",dir)) return kFALSE; |
1894 | if (TMath::Abs(hI-1.5)<0.01) // SPDouter |
1895 | if(!CorrectForShieldMaterial(t,"SPD",dir)) return kFALSE; |
afd25725 |
1896 | |
e43c066c |
1897 | // remember old position [SR, GSI 18.02.2003] |
1898 | Double_t oldX=0., oldY=0., oldZ=0.; |
1899 | if (t->IsStartedTimeIntegral() && step==1) { |
1900 | t->GetGlobalXYZat(t->GetX(),oldX,oldY,oldZ); |
1901 | } |
1902 | // |
1903 | |
afd25725 |
1904 | Double_t oldGlobXYZ[3]; |
1905 | t->GetXYZ(oldGlobXYZ); |
1906 | |
8602c008 |
1907 | Double_t phi,z; |
1908 | if (!t->GetPhiZat(r,phi,z)) return kFALSE; |
1909 | |
e43c066c |
1910 | Int_t idet=layer.FindDetectorIndex(phi,z); |
6518a6c5 |
1911 | |
1912 | // check if we allow a prolongation without point for large-eta tracks |
1913 | Int_t skip = CheckSkipLayer(t,ilayer,idet); |
1914 | if (skip==2) { |
1915 | // propagate to the layer radius |
1916 | Double_t xToGo; t->GetLocalXat(r,xToGo); |
1917 | t->AliExternalTrackParam::PropagateTo(xToGo,GetBz()); |
1918 | // apply correction for material of the current layer |
1919 | CorrectForLayerMaterial(t,ilayer,oldGlobXYZ,dir); |
1920 | // track time update [SR, GSI 17.02.2003] |
1921 | if (t->IsStartedTimeIntegral() && step==1) { |
1922 | Double_t newX, newY, newZ; |
1923 | t->GetGlobalXYZat(t->GetX(),newX,newY,newZ); |
1924 | Double_t dL2 = (oldX-newX)*(oldX-newX) + (oldY-newY)*(oldY-newY) + |
1925 | (oldZ-newZ)*(oldZ-newZ); |
1926 | t->AddTimeStep(TMath::Sqrt(dL2)); |
1927 | } |
1928 | continue; |
1929 | } |
1930 | |
e50912db |
1931 | if (idet<0) return kFALSE; |
8602c008 |
1932 | |
e43c066c |
1933 | const AliITSdetector &det=layer.GetDetector(idet); |
1934 | phi=det.GetPhi(); |
e50912db |
1935 | if (!t->Propagate(phi,det.GetR())) return kFALSE; |
e43c066c |
1936 | t->SetDetectorIndex(idet); |
1937 | |
00a7cc50 |
1938 | const AliITSRecPoint *cl=0; |
44347160 |
1939 | Double_t maxchi2=1000.*AliITSReconstructor::GetRecoParam()->GetMaxChi2(); |
e43c066c |
1940 | |
6518a6c5 |
1941 | Int_t idx=index[ilayer]; |
0653282c |
1942 | if (idx>=0) { |
00a7cc50 |
1943 | const AliITSRecPoint *c=(AliITSRecPoint *)GetCluster(idx); |
6518a6c5 |
1944 | if (c) { |
67c1e979 |
1945 | if (idet != c->GetDetectorIndex()) { |
1946 | idet=c->GetDetectorIndex(); |
1947 | const AliITSdetector &det=layer.GetDetector(idet); |
1948 | if (!t->Propagate(det.GetPhi(),det.GetR())) { |
1949 | return kFALSE; |
1950 | } |
1951 | t->SetDetectorIndex(idet); |
1952 | } |
1953 | //Double_t chi2=t->GetPredictedChi2(c); |
1954 | Int_t layer = (idx & 0xf0000000) >> 28;; |
1955 | Double_t chi2=GetPredictedChi2MI(t,c,layer); |
1956 | if (chi2<maxchi2) { |
1957 | cl=c; |
1958 | maxchi2=chi2; |
1959 | } else { |
1960 | return kFALSE; |
1961 | } |
1962 | } |
1963 | } |
67c1e979 |
1964 | |
67c1e979 |
1965 | if (cl) { |
afd25725 |
1966 | if (!UpdateMI(t,cl,maxchi2,idx)) return kFALSE; |
67c1e979 |
1967 | t->SetSampledEdx(cl->GetQ(),t->GetNumberOfClusters()-1); |
1968 | } |
1969 | |
ef7253ac |
1970 | if (extra) { //search for extra clusters |
1971 | AliITStrackV2 tmp(*t); |
6518a6c5 |
1972 | Double_t dz=4*TMath::Sqrt(tmp.GetSigmaZ2()+AliITSReconstructor::GetRecoParam()->GetSigmaZ2(ilayer)); |
ef7253ac |
1973 | if (dz < 0.5*TMath::Abs(tmp.GetTgl())) dz=0.5*TMath::Abs(tmp.GetTgl()); |
6518a6c5 |
1974 | Double_t dy=4*TMath::Sqrt(t->GetSigmaY2()+AliITSReconstructor::GetRecoParam()->GetSigmaY2(ilayer)); |
ef7253ac |
1975 | if (dy < 0.5*TMath::Abs(tmp.GetSnp())) dy=0.5*TMath::Abs(tmp.GetSnp()); |
1976 | Double_t zmin=t->GetZ() - dz; |
1977 | Double_t zmax=t->GetZ() + dz; |
1978 | Double_t ymin=t->GetY() + phi*r - dy; |
1979 | Double_t ymax=t->GetY() + phi*r + dy; |
1980 | layer.SelectClusters(zmin,zmax,ymin,ymax); |
1981 | |
1982 | const AliITSRecPoint *c=0; Int_t ci=-1,cci=-1; |
44347160 |
1983 | Double_t maxchi2=1000.*AliITSReconstructor::GetRecoParam()->GetMaxChi2(), tolerance=0.1; |
ef7253ac |
1984 | while ((c=layer.GetNextCluster(ci))!=0) { |
1985 | if (idet == c->GetDetectorIndex()) continue; |
1986 | |
1987 | const AliITSdetector &det=layer.GetDetector(c->GetDetectorIndex()); |
1988 | |
1989 | if (!tmp.Propagate(det.GetPhi(),det.GetR())) continue; |
1990 | |
1991 | if (TMath::Abs(tmp.GetZ() - c->GetZ()) > tolerance) continue; |
1992 | if (TMath::Abs(tmp.GetY() - c->GetY()) > tolerance) continue; |
1993 | |
1994 | Double_t chi2=tmp.GetPredictedChi2(c); |
1995 | if (chi2<maxchi2) { maxchi2=chi2; cci=ci; } |
1996 | } |
6518a6c5 |
1997 | if (cci>=0) t->SetExtraCluster(ilayer,(ilayer<<28)+cci); |
ef7253ac |
1998 | } |
1999 | |
67c1e979 |
2000 | // track time update [SR, GSI 17.02.2003] |
2001 | if (t->IsStartedTimeIntegral() && step==1) { |
2002 | Double_t newX, newY, newZ; |
2003 | t->GetGlobalXYZat(t->GetX(),newX,newY,newZ); |
2004 | Double_t dL2 = (oldX-newX)*(oldX-newX) + (oldY-newY)*(oldY-newY) + |
2005 | (oldZ-newZ)*(oldZ-newZ); |
2006 | t->AddTimeStep(TMath::Sqrt(dL2)); |
2007 | } |
2008 | // |
2009 | |
e50912db |
2010 | // Correct for material of the current layer |
6518a6c5 |
2011 | if(!CorrectForLayerMaterial(t,ilayer,oldGlobXYZ,dir)) return kFALSE; |
e50912db |
2012 | |
afd25725 |
2013 | } // end loop on the layers |
67c1e979 |
2014 | |
2015 | if (!t->PropagateTo(xx,0.,0.)) return kFALSE; |
2016 | return kTRUE; |
2017 | } |
44347160 |
2018 | //------------------------------------------------------------------------ |
67c1e979 |
2019 | Bool_t |
2020 | AliITStrackerMI::RefitAt(Double_t xx,AliITStrackMI *t,const Int_t *clindex) { |
2021 | //-------------------------------------------------------------------- |
2022 | // This function refits the track "t" at the position "x" using |
2023 | // the clusters from array |
2024 | //-------------------------------------------------------------------- |
e50912db |
2025 | Int_t index[AliITSgeomTGeo::kNLayers]; |
67c1e979 |
2026 | Int_t k; |
e50912db |
2027 | for (k=0; k<AliITSgeomTGeo::GetNLayers(); k++) index[k]=-1; |
67c1e979 |
2028 | // |
e50912db |
2029 | for (k=0; k<AliITSgeomTGeo::GetNLayers(); k++) { |
67c1e979 |
2030 | index[k]=clindex[k]; |
2031 | } |
2032 | |
afd25725 |
2033 | // special for cosmics: check which the innermost layer crossed |
2034 | // by the track |
2035 | Int_t innermostlayer=5; |
2036 | Double_t d = TMath::Abs(t->GetD(0.,0.)); |
e50912db |
2037 | for(innermostlayer=0; innermostlayer<AliITSgeomTGeo::GetNLayers(); innermostlayer++) |
afd25725 |
2038 | if(d<fgLayers[innermostlayer].GetR()) break; |
2039 | //printf(" d %f innermost %d\n",d,innermostlayer); |
2040 | |
67c1e979 |
2041 | Int_t from, to, step; |
2042 | if (xx > t->GetX()) { |
e50912db |
2043 | from=innermostlayer; to=AliITSgeomTGeo::GetNLayers(); |
67c1e979 |
2044 | step=+1; |
2045 | } else { |
e50912db |
2046 | from=AliITSgeomTGeo::GetNLayers()-1; to=innermostlayer-1; |
67c1e979 |
2047 | step=-1; |
2048 | } |
e50912db |
2049 | TString dir=(step>0 ? "outward" : "inward"); |
67c1e979 |
2050 | |
6518a6c5 |
2051 | for (Int_t ilayer=from; ilayer != to; ilayer += step) { |
2052 | AliITSlayer &layer=fgLayers[ilayer]; |
67c1e979 |
2053 | Double_t r=layer.GetR(); |
afd25725 |
2054 | if (step<0 && xx>r) break; |
2055 | |
2056 | // material between SSD and SDD, SDD and SPD |
6518a6c5 |
2057 | Double_t hI=ilayer-0.5*step; |
e50912db |
2058 | if (TMath::Abs(hI-3.5)<0.01) // SDDouter |
2059 | if(!CorrectForShieldMaterial(t,"SDD",dir)) return kFALSE; |
2060 | if (TMath::Abs(hI-1.5)<0.01) // SPDouter |
2061 | if(!CorrectForShieldMaterial(t,"SPD",dir)) return kFALSE; |
67c1e979 |
2062 | |
2063 | // remember old position [SR, GSI 18.02.2003] |
2064 | Double_t oldX=0., oldY=0., oldZ=0.; |
2065 | if (t->IsStartedTimeIntegral() && step==1) { |
2066 | t->GetGlobalXYZat(t->GetX(),oldX,oldY,oldZ); |
2067 | } |
2068 | // |
afd25725 |
2069 | Double_t oldGlobXYZ[3]; |
2070 | t->GetXYZ(oldGlobXYZ); |
2071 | |
8602c008 |
2072 | Double_t phi,z; |
2073 | if (!t->GetPhiZat(r,phi,z)) return kFALSE; |
67c1e979 |
2074 | |
67c1e979 |
2075 | Int_t idet=layer.FindDetectorIndex(phi,z); |
6518a6c5 |
2076 | |
2077 | // check if we allow a prolongation without point for large-eta tracks |
2078 | Int_t skip = CheckSkipLayer(t,ilayer,idet); |
2079 | if (skip==2) { |
2080 | // propagate to the layer radius |
2081 | Double_t xToGo; t->GetLocalXat(r,xToGo); |
2082 | t->AliExternalTrackParam::PropagateTo(xToGo,GetBz()); |
2083 | // apply correction for material of the current layer |
2084 | CorrectForLayerMaterial(t,ilayer,oldGlobXYZ,dir); |
2085 | // track time update [SR, GSI 17.02.2003] |
2086 | if (t->IsStartedTimeIntegral() && step==1) { |
2087 | Double_t newX, newY, newZ; |
2088 | t->GetGlobalXYZat(t->GetX(),newX,newY,newZ); |
2089 | Double_t dL2 = (oldX-newX)*(oldX-newX) + (oldY-newY)*(oldY-newY) + |
2090 | (oldZ-newZ)*(oldZ-newZ); |
2091 | t->AddTimeStep(TMath::Sqrt(dL2)); |
2092 | } |
2093 | continue; |
2094 | } |
2095 | |
e50912db |
2096 | if (idet<0) return kFALSE; |
67c1e979 |
2097 | const AliITSdetector &det=layer.GetDetector(idet); |
2098 | phi=det.GetPhi(); |
e50912db |
2099 | if (!t->Propagate(phi,det.GetR())) return kFALSE; |
67c1e979 |
2100 | t->SetDetectorIndex(idet); |
2101 | |
00a7cc50 |
2102 | const AliITSRecPoint *cl=0; |
44347160 |
2103 | Double_t maxchi2=1000.*AliITSReconstructor::GetRecoParam()->GetMaxChi2(); |
67c1e979 |
2104 | |
6518a6c5 |
2105 | Int_t idx=index[ilayer]; |
0653282c |
2106 | if (idx>=0) { |
00a7cc50 |
2107 | const AliITSRecPoint *c=(AliITSRecPoint *)GetCluster(idx); |
67c1e979 |
2108 | if (c){ |
2109 | if (idet != c->GetDetectorIndex()) { |
2110 | idet=c->GetDetectorIndex(); |
2111 | const AliITSdetector &det=layer.GetDetector(idet); |
2112 | if (!t->Propagate(det.GetPhi(),det.GetR())) { |
2113 | return kFALSE; |
2114 | } |
2115 | t->SetDetectorIndex(idet); |
2116 | } |
2117 | //Double_t chi2=t->GetPredictedChi2(c); |
2118 | Int_t layer = (idx & 0xf0000000) >> 28;; |
2119 | Double_t chi2=GetPredictedChi2MI(t,c,layer); |
2120 | if (chi2<maxchi2) { |
2121 | cl=c; |
2122 | maxchi2=chi2; |
2123 | } else { |
2124 | return kFALSE; |
2125 | } |
e43c066c |
2126 | } |
2127 | } |
e43c066c |
2128 | |
e43c066c |
2129 | if (cl) { |
afd25725 |
2130 | if (!UpdateMI(t,cl,maxchi2,idx)) return kFALSE; |
e43c066c |
2131 | t->SetSampledEdx(cl->GetQ(),t->GetNumberOfClusters()-1); |
2132 | } |
2133 | |
afd25725 |
2134 | // Correct for material of the current layer |
6518a6c5 |
2135 | if(!CorrectForLayerMaterial(t,ilayer,oldGlobXYZ,dir)) return kFALSE; |
e43c066c |
2136 | |
2137 | // track time update [SR, GSI 17.02.2003] |
2138 | if (t->IsStartedTimeIntegral() && step==1) { |
2139 | Double_t newX, newY, newZ; |
2140 | t->GetGlobalXYZat(t->GetX(),newX,newY,newZ); |
2141 | Double_t dL2 = (oldX-newX)*(oldX-newX) + (oldY-newY)*(oldY-newY) + |
2142 | (oldZ-newZ)*(oldZ-newZ); |
2143 | t->AddTimeStep(TMath::Sqrt(dL2)); |
2144 | } |
2145 | // |
2146 | |
2147 | } |
2148 | |
2149 | if (!t->PropagateTo(xx,0.,0.)) return kFALSE; |
2150 | return kTRUE; |
2151 | } |
44347160 |
2152 | //------------------------------------------------------------------------ |
15dd636f |
2153 | Double_t AliITStrackerMI::GetNormalizedChi2(AliITStrackMI * track, Int_t mode) |
e43c066c |
2154 | { |
2155 | // |
2156 | // calculate normalized chi2 |
2157 | // return NormalizedChi2(track,0); |
2158 | Float_t chi2 = 0; |
2159 | Float_t sum=0; |
2160 | Float_t *erry = GetErrY(fCurrentEsdTrack), *errz = GetErrZ(fCurrentEsdTrack); |
2161 | // track->fdEdxMismatch=0; |
2162 | Float_t dedxmismatch =0; |
2163 | Float_t *ny = GetNy(fCurrentEsdTrack), *nz = GetNz(fCurrentEsdTrack); |
2164 | if (mode<100){ |
2165 | for (Int_t i = 0;i<6;i++){ |
b9671574 |
2166 | if (track->GetClIndex(i)>0){ |
e43c066c |
2167 | Float_t cerry, cerrz; |
2168 | if (ny[i]>0) {cerry = erry[i]; cerrz=errz[i];} |
2169 | else |
b9671574 |
2170 | { cerry= track->GetSigmaY(i); cerrz = track->GetSigmaZ(i);} |
e43c066c |
2171 | cerry*=cerry; |
2172 | cerrz*=cerrz; |
b9671574 |
2173 | Float_t cchi2 = (track->GetDy(i)*track->GetDy(i)/cerry)+(track->GetDz(i)*track->GetDz(i)/cerrz); |
572f41f9 |
2174 | if (i>1 && AliITSReconstructor::GetRecoParam()->GetUseAmplitudeInfo(i)) { |
b9671574 |
2175 | Float_t ratio = track->GetNormQ(i)/track->GetExpQ(); |
e43c066c |
2176 | if (ratio<0.5) { |
2177 | cchi2+=(0.5-ratio)*10.; |
2178 | //track->fdEdxMismatch+=(0.5-ratio)*10.; |
2179 | dedxmismatch+=(0.5-ratio)*10.; |
2180 | } |
2181 | } |
2182 | if (i<2 ||i>3){ |
b9671574 |
2183 | AliITSRecPoint * cl = (AliITSRecPoint*)GetCluster( track->GetClIndex(i)); |
e43c066c |
2184 | Double_t delta = cl->GetNy()+cl->GetNz()-ny[i]-nz[i]; |
2185 | if (delta>1) chi2 +=0.5*TMath::Min(delta/2,2.); |
2186 | if (i<2) chi2+=2*cl->GetDeltaProbability(); |
2187 | } |
2188 | chi2+=cchi2; |
2189 | sum++; |
2190 | } |
2191 | } |
b9671574 |
2192 | if (TMath::Abs(track->GetdEdxMismatch()-dedxmismatch)>0.0001){ |
2193 | track->SetdEdxMismatch(dedxmismatch); |
e43c066c |
2194 | } |
2195 | } |
2196 | else{ |
2197 | for (Int_t i = 0;i<4;i++){ |
b9671574 |
2198 | if (track->GetClIndex(i)>0){ |
e43c066c |
2199 | Float_t cerry, cerrz; |
2200 | if (ny[i]>0) {cerry = erry[i]; cerrz=errz[i];} |
b9671574 |
2201 | else { cerry= track->GetSigmaY(i); cerrz = track->GetSigmaZ(i);} |
e43c066c |
2202 | cerry*=cerry; |
2203 | cerrz*=cerrz; |
b9671574 |
2204 | chi2+= (track->GetDy(i)*track->GetDy(i)/cerry); |
2205 | chi2+= (track->GetDz(i)*track->GetDz(i)/cerrz); |
e43c066c |
2206 | sum++; |
2207 | } |
2208 | } |
2209 | for (Int_t i = 4;i<6;i++){ |
b9671574 |
2210 | if (track->GetClIndex(i)>0){ |
e43c066c |
2211 | Float_t cerry, cerrz; |
2212 | if (ny[i]>0) {cerry = erry[i]; cerrz=errz[i];} |
b9671574 |
2213 | else { cerry= track->GetSigmaY(i); cerrz = track->GetSigmaZ(i);} |
e43c066c |
2214 | cerry*=cerry; |
2215 | cerrz*=cerrz; |
2216 | Float_t cerryb, cerrzb; |
2217 | if (ny[i+6]>0) {cerryb = erry[i+6]; cerrzb=errz[i+6];} |
b9671574 |
2218 | else { cerryb= track->GetSigmaY(i+6); cerrzb = track->GetSigmaZ(i+6);} |
e43c066c |
2219 | cerryb*=cerryb; |
2220 | cerrzb*=cerrzb; |
b9671574 |
2221 | chi2+= TMath::Min((track->GetDy(i+6)*track->GetDy(i+6)/cerryb),track->GetDy(i)*track->GetDy(i)/cerry); |
2222 | chi2+= TMath::Min((track->GetDz(i+6)*track->GetDz(i+6)/cerrzb),track->GetDz(i)*track->GetDz(i)/cerrz); |
e43c066c |
2223 | sum++; |
2224 | } |
2225 | } |
2226 | } |
b9671574 |
2227 | if (track->GetESDtrack()->GetTPCsignal()>85){ |
2228 | Float_t ratio = track->GetdEdx()/track->GetESDtrack()->GetTPCsignal(); |
e43c066c |
2229 | if (ratio<0.5) { |
2230 | chi2+=(0.5-ratio)*5.; |
2231 | } |
2232 | if (ratio>2){ |
2233 | chi2+=(ratio-2.0)*3; |
2234 | } |
2235 | } |
2236 | // |
b9671574 |
2237 | Double_t match = TMath::Sqrt(track->GetChi22()); |
2238 | if (track->GetConstrain()) match/=track->GetNumberOfClusters(); |
2755f080 |
2239 | if (!track->GetConstrain()) { |
2240 | if (track->GetNumberOfClusters()>2) { |
2241 | match/=track->GetNumberOfClusters()-2.; |
2242 | } else { |
2243 | match=0; |
2244 | } |
2245 | } |
e43c066c |
2246 | if (match<0) match=0; |
b9671574 |
2247 | Float_t deadzonefactor = (track->GetNDeadZone()>0) ? 3*(1.1-track->GetDeadZoneProbability()):0.; |
2248 | Double_t normchi2 = 2*track->GetNSkipped()+match+deadzonefactor+(1+(2*track->GetNSkipped()+deadzonefactor)/track->GetNumberOfClusters())* |
2249 | (chi2)/TMath::Max(double(sum-track->GetNSkipped()), |
2250 | 1./(1.+track->GetNSkipped())); |
e43c066c |
2251 | |
2252 | return normchi2; |
2253 | } |
44347160 |
2254 | //------------------------------------------------------------------------ |
15dd636f |
2255 | Double_t AliITStrackerMI::GetMatchingChi2(AliITStrackMI * track1, AliITStrackMI * track2) |
e43c066c |
2256 | { |
2257 | // |
2258 | // return matching chi2 between two tracks |
15dd636f |
2259 | AliITStrackMI track3(*track2); |
e43c066c |
2260 | track3.Propagate(track1->GetAlpha(),track1->GetX()); |
2261 | TMatrixD vec(5,1); |
6c94f330 |
2262 | vec(0,0)=track1->GetY() - track3.GetY(); |
2263 | vec(1,0)=track1->GetZ() - track3.GetZ(); |
2264 | vec(2,0)=track1->GetSnp() - track3.GetSnp(); |
2265 | vec(3,0)=track1->GetTgl() - track3.GetTgl(); |
6c23ffed |
2266 | vec(4,0)=track1->GetSigned1Pt() - track3.GetSigned1Pt(); |
e43c066c |
2267 | // |
2268 | TMatrixD cov(5,5); |
6c94f330 |
2269 | cov(0,0) = track1->GetSigmaY2()+track3.GetSigmaY2(); |
2270 | cov(1,1) = track1->GetSigmaZ2()+track3.GetSigmaZ2(); |
2271 | cov(2,2) = track1->GetSigmaSnp2()+track3.GetSigmaSnp2(); |
2272 | cov(3,3) = track1->GetSigmaTgl2()+track3.GetSigmaTgl2(); |
2273 | cov(4,4) = track1->GetSigma1Pt2()+track3.GetSigma1Pt2(); |
e43c066c |
2274 | |
6c94f330 |
2275 | cov(0,1)=cov(1,0) = track1->GetSigmaZY()+track3.GetSigmaZY(); |
2276 | cov(0,2)=cov(2,0) = track1->GetSigmaSnpY()+track3.GetSigmaSnpY(); |
2277 | cov(0,3)=cov(3,0) = track1->GetSigmaTglY()+track3.GetSigmaTglY(); |
2278 | cov(0,4)=cov(4,0) = track1->GetSigma1PtY()+track3.GetSigma1PtY(); |
e43c066c |
2279 | // |
6c94f330 |
2280 | cov(1,2)=cov(2,1) = track1->GetSigmaSnpZ()+track3.GetSigmaSnpZ(); |
2281 | cov(1,3)=cov(3,1) = track1->GetSigmaTglZ()+track3.GetSigmaTglZ(); |
2282 | cov(1,4)=cov(4,1) = track1->GetSigma1PtZ()+track3.GetSigma1PtZ(); |
e43c066c |
2283 | // |
6c94f330 |
2284 | cov(2,3)=cov(3,2) = track1->GetSigmaTglSnp()+track3.GetSigmaTglSnp(); |
2285 | cov(2,4)=cov(4,2) = track1->GetSigma1PtSnp()+track3.GetSigma1PtSnp(); |
e43c066c |
2286 | // |
6c94f330 |
2287 | cov(3,4)=cov(4,3) = track1->GetSigma1PtTgl()+track3.GetSigma1PtTgl(); |
e43c066c |
2288 | |
2289 | cov.Invert(); |
2290 | TMatrixD vec2(cov,TMatrixD::kMult,vec); |
2291 | TMatrixD chi2(vec2,TMatrixD::kTransposeMult,vec); |
2292 | return chi2(0,0); |
2293 | } |
44347160 |
2294 | //------------------------------------------------------------------------ |
6518a6c5 |
2295 | Double_t AliITStrackerMI::GetSPDDeadZoneProbability(Double_t zpos, Double_t zerr) |
e43c066c |
2296 | { |
2297 | // |
afd25725 |
2298 | // return probability that given point (characterized by z position and error) |
2299 | // is in SPD dead zone |
e43c066c |
2300 | // |
afd25725 |
2301 | Double_t probability = 0.; |
e43c066c |
2302 | Double_t absz = TMath::Abs(zpos); |
afd25725 |
2303 | Double_t nearestz = (absz<2.) ? 0.5*(fSPDdetzcentre[1]+fSPDdetzcentre[2]) : |
2304 | 0.5*(fSPDdetzcentre[2]+fSPDdetzcentre[3]); |
2305 | if (TMath::Abs(absz-nearestz)>0.25+3.*zerr) return probability; |
2306 | Double_t zmin, zmax; |
2307 | if (zpos<-6.) { // dead zone at z = -7 |
e50912db |
2308 | zmin = fSPDdetzcentre[0] + 0.5*AliITSRecoParam::GetSPDdetzlength(); |
2309 | zmax = fSPDdetzcentre[1] - 0.5*AliITSRecoParam::GetSPDdetzlength(); |
afd25725 |
2310 | } else if (zpos>6.) { // dead zone at z = +7 |
e50912db |
2311 | zmin = fSPDdetzcentre[2] + 0.5*AliITSRecoParam::GetSPDdetzlength(); |
2312 | zmax = fSPDdetzcentre[3] - 0.5*AliITSRecoParam::GetSPDdetzlength(); |
afd25725 |
2313 | } else if (absz<2.) { // dead zone at z = 0 |
e50912db |
2314 | zmin = fSPDdetzcentre[1] + 0.5*AliITSRecoParam::GetSPDdetzlength(); |
2315 | zmax = fSPDdetzcentre[2] - 0.5*AliITSRecoParam::GetSPDdetzlength(); |
afd25725 |
2316 | } else { |
2317 | zmin = 0.; |
2318 | zmax = 0.; |
e43c066c |
2319 | } |
afd25725 |
2320 | // probability that the true z is in the range [zmin,zmax] (i.e. inside |
2321 | // dead zone) |
2322 | probability = 0.5*( TMath::Erf((zpos-zmin)/zerr/TMath::Sqrt(2.)) - |
2323 | TMath::Erf((zpos-zmax)/zerr/TMath::Sqrt(2.)) ); |
e43c066c |
2324 | return probability; |
2325 | } |
44347160 |
2326 | //------------------------------------------------------------------------ |
15dd636f |
2327 | Double_t AliITStrackerMI::GetTruncatedChi2(AliITStrackMI * track, Float_t fac) |
e43c066c |
2328 | { |
2329 | // |
2330 | // calculate normalized chi2 |
2331 | Float_t chi2[6]; |
2332 | Float_t *erry = GetErrY(fCurrentEsdTrack), *errz = GetErrZ(fCurrentEsdTrack); |
2333 | Float_t ncl = 0; |
2334 | for (Int_t i = 0;i<6;i++){ |
b9671574 |
2335 | if (TMath::Abs(track->GetDy(i))>0){ |
2336 | chi2[i]= (track->GetDy(i)/erry[i])*(track->GetDy(i)/erry[i]); |
2337 | chi2[i]+= (track->GetDz(i)/errz[i])*(track->GetDz(i)/errz[i]); |
e43c066c |
2338 | ncl++; |
2339 | } |
2340 | else{chi2[i]=10000;} |
2341 | } |
2342 | Int_t index[6]; |
2343 | TMath::Sort(6,chi2,index,kFALSE); |
2344 | Float_t max = float(ncl)*fac-1.; |
2345 | Float_t sumchi=0, sumweight=0; |
2346 | for (Int_t i=0;i<max+1;i++){ |
2347 | Float_t weight = (i<max)?1.:(max+1.-i); |
2348 | sumchi+=weight*chi2[index[i]]; |
2349 | sumweight+=weight; |
2350 | } |
2351 | Double_t normchi2 = sumchi/sumweight; |
2352 | return normchi2; |
2353 | } |
44347160 |
2354 | //------------------------------------------------------------------------ |
15dd636f |
2355 | Double_t AliITStrackerMI::GetInterpolatedChi2(AliITStrackMI * forwardtrack, AliITStrackMI * backtrack) |
e43c066c |
2356 | { |
2357 | // |
2358 | // calculate normalized chi2 |
2359 | // if (forwardtrack->fNUsed>0.3*float(forwardtrack->GetNumberOfClusters())) return 10000; |
2360 | Int_t npoints = 0; |
2361 | Double_t res =0; |
2362 | for (Int_t i=0;i<6;i++){ |
b9671574 |
2363 | if ( (backtrack->GetSigmaY(i)<0.000000001) || (forwardtrack->GetSigmaY(i)<0.000000001)) continue; |
2364 | Double_t sy1 = forwardtrack->GetSigmaY(i); |
2365 | Double_t sz1 = forwardtrack->GetSigmaZ(i); |
2366 | Double_t sy2 = backtrack->GetSigmaY(i); |
2367 | Double_t sz2 = backtrack->GetSigmaZ(i); |
e43c066c |
2368 | if (i<2){ sy2=1000.;sz2=1000;} |
2369 | // |
b9671574 |
2370 | Double_t dy0 = (forwardtrack->GetDy(i)/(sy1*sy1) +backtrack->GetDy(i)/(sy2*sy2))/(1./(sy1*sy1)+1./(sy2*sy2)); |
2371 | Double_t dz0 = (forwardtrack->GetDz(i)/(sz1*sz1) +backtrack->GetDz(i)/(sz2*sz2))/(1./(sz1*sz1)+1./(sz2*sz2)); |
e43c066c |
2372 | // |
2373 | Double_t nz0 = dz0*TMath::Sqrt((1./(sz1*sz1)+1./(sz2*sz2))); |
2374 | Double_t ny0 = dy0*TMath::Sqrt((1./(sy1*sy1)+1./(sy2*sy2))); |
2375 | // |
2376 | res+= nz0*nz0+ny0*ny0; |
2377 | npoints++; |
2378 | } |
2379 | if (npoints>1) return |
6c23ffed |
2380 | TMath::Max(0.3*forwardtrack->OneOverPt()-0.5,0.)+ |
e43c066c |
2381 | //2*forwardtrack->fNUsed+ |
b9671574 |
2382 | res/TMath::Max(double(npoints-forwardtrack->GetNSkipped()), |
2383 | 1./(1.+forwardtrack->GetNSkipped())); |
e43c066c |
2384 | return 1000; |
2385 | } |
44347160 |
2386 | //------------------------------------------------------------------------ |
e43c066c |
2387 | Float_t *AliITStrackerMI::GetWeight(Int_t index) { |
2388 | //-------------------------------------------------------------------- |
2389 | // Return pointer to a given cluster |
2390 | //-------------------------------------------------------------------- |
2391 | Int_t l=(index & 0xf0000000) >> 28; |
2392 | Int_t c=(index & 0x0fffffff) >> 00; |
2393 | return fgLayers[l].GetWeight(c); |
2394 | } |
44347160 |
2395 | //------------------------------------------------------------------------ |
15dd636f |
2396 | void AliITStrackerMI::RegisterClusterTracks(AliITStrackMI* track,Int_t id) |
e43c066c |
2397 | { |
2398 | //--------------------------------------------- |
2399 | // register track to the list |
628e7bb0 |
2400 | // |
b9671574 |
2401 | if (track->GetESDtrack()->GetKinkIndex(0)!=0) return; //don't register kink tracks |
628e7bb0 |
2402 | // |
2403 | // |
e43c066c |
2404 | for (Int_t icluster=0;icluster<track->GetNumberOfClusters();icluster++){ |
2405 | Int_t index = track->GetClusterIndex(icluster); |
2406 | Int_t l=(index & 0xf0000000) >> 28; |
2407 | Int_t c=(index & 0x0fffffff) >> 00; |
b9671574 |
2408 | if (c>fgLayers[l].GetNumberOfClusters()) continue; |
e43c066c |
2409 | for (Int_t itrack=0;itrack<4;itrack++){ |
b9671574 |
2410 | if (fgLayers[l].GetClusterTracks(itrack,c)<0){ |
2411 | fgLayers[l].SetClusterTracks(itrack,c,id); |
e43c066c |
2412 | break; |
2413 | } |
2414 | } |
2415 | } |
2416 | } |
44347160 |
2417 | //------------------------------------------------------------------------ |
15dd636f |
2418 | void AliITStrackerMI::UnRegisterClusterTracks(AliITStrackMI* track, Int_t id) |
e43c066c |
2419 | { |
2420 | //--------------------------------------------- |
2421 | // unregister track from the list |
2422 | for (Int_t icluster=0;icluster<track->GetNumberOfClusters();icluster++){ |
2423 | Int_t index = track->GetClusterIndex(icluster); |
2424 | Int_t l=(index & 0xf0000000) >> 28; |
2425 | Int_t c=(index & 0x0fffffff) >> 00; |
b9671574 |
2426 | if (c>fgLayers[l].GetNumberOfClusters()) continue; |
e43c066c |
2427 | for (Int_t itrack=0;itrack<4;itrack++){ |
b9671574 |
2428 | if (fgLayers[l].GetClusterTracks(itrack,c)==id){ |
2429 | fgLayers[l].SetClusterTracks(itrack,c,-1); |
e43c066c |
2430 | } |
2431 | } |
2432 | } |
2433 | } |
44347160 |
2434 | //------------------------------------------------------------------------ |
00a7cc50 |
2435 | Float_t AliITStrackerMI::GetNumberOfSharedClusters(AliITStrackMI* track,Int_t id, Int_t list[6], AliITSRecPoint *clist[6]) |
e43c066c |
2436 | { |
2437 | //------------------------------------------------------------- |
2438 | //get number of shared clusters |
2439 | //------------------------------------------------------------- |
2440 | Float_t shared=0; |
2441 | for (Int_t i=0;i<6;i++) { list[i]=-1, clist[i]=0;} |
2442 | // mean number of clusters |
2443 | Float_t *ny = GetNy(id), *nz = GetNz(id); |
2444 | |
2445 | |
2446 | for (Int_t icluster=0;icluster<track->GetNumberOfClusters();icluster++){ |
2447 | Int_t index = track->GetClusterIndex(icluster); |
2448 | Int_t l=(index & 0xf0000000) >> 28; |
2449 | Int_t c=(index & 0x0fffffff) >> 00; |
b9671574 |
2450 | if (c>fgLayers[l].GetNumberOfClusters()) continue; |
e43c066c |
2451 | if (ny[l]==0){ |
2452 | printf("problem\n"); |
2453 | } |
00a7cc50 |
2454 | AliITSRecPoint *cl = (AliITSRecPoint*)GetCluster(index); |
e43c066c |
2455 | Float_t weight=1; |
2456 | // |
2457 | Float_t deltan = 0; |
2458 | if (l>3&&cl->GetNy()+cl->GetNz()>6) continue; |
572f41f9 |
2459 | if (l>2&&AliITSReconstructor::GetRecoParam()->GetUseAmplitudeInfo(l)) |
2460 | if (track->GetNormQ(l)/track->GetExpQ()>3.5) continue; |
e43c066c |
2461 | if (l<2 || l>3){ |
2462 | deltan = (cl->GetNy()+cl->GetNz()-ny[l]-nz[l]); |
2463 | } |
2464 | else{ |
2465 | deltan = (cl->GetNz()-nz[l]); |
2466 | } |
2467 | if (deltan>2.0) continue; // extended - highly probable shared cluster |
2468 | weight = 2./TMath::Max(3.+deltan,2.); |
2469 | // |
2470 | for (Int_t itrack=0;itrack<4;itrack++){ |
b9671574 |
2471 | if (fgLayers[l].GetClusterTracks(itrack,c)>=0 && fgLayers[l].GetClusterTracks(itrack,c)!=id){ |
e43c066c |
2472 | list[l]=index; |
00a7cc50 |
2473 | clist[l] = (AliITSRecPoint*)GetCluster(index); |
e43c066c |
2474 | shared+=weight; |
2475 | break; |
2476 | } |
2477 | } |
2478 | } |
b9671574 |
2479 | track->SetNUsed(shared); |
e43c066c |
2480 | return shared; |
2481 | } |
44347160 |
2482 | //------------------------------------------------------------------------ |
15dd636f |
2483 | Int_t AliITStrackerMI::GetOverlapTrack(AliITStrackMI *track, Int_t trackID, Int_t &shared, Int_t clusterlist[6],Int_t overlist[6]) |
e43c066c |
2484 | { |
2485 | // |
2486 | // find first shared track |
2487 | // |
2488 | // mean number of clusters |
2489 | Float_t *ny = GetNy(trackID), *nz = GetNz(trackID); |
2490 | // |
2491 | for (Int_t i=0;i<6;i++) overlist[i]=-1; |
2492 | Int_t sharedtrack=100000; |
2493 | Int_t tracks[24],trackindex=0; |
2494 | for (Int_t i=0;i<24;i++) {tracks[i]=-1;} |
2495 | // |
2496 | for (Int_t icluster=0;icluster<6;icluster++){ |
2497 | if (clusterlist[icluster]<0) continue; |
2498 | Int_t index = clusterlist[icluster]; |
2499 | Int_t l=(index & 0xf0000000) >> 28; |
2500 | Int_t c=(index & 0x0fffffff) >> 00; |
2501 | if (ny[l]==0){ |
2502 | printf("problem\n"); |
2503 | } |
b9671574 |
2504 | if (c>fgLayers[l].GetNumberOfClusters()) continue; |
e43c066c |
2505 | //if (l>3) continue; |
00a7cc50 |
2506 | AliITSRecPoint *cl = (AliITSRecPoint*)GetCluster(index); |
e43c066c |
2507 | // |
2508 | Float_t deltan = 0; |
2509 | if (l>3&&cl->GetNy()+cl->GetNz()>6) continue; |
572f41f9 |
2510 | if (l>2&&AliITSReconstructor::GetRecoParam()->GetUseAmplitudeInfo(l)) |
2511 | if (track->GetNormQ(l)/track->GetExpQ()>3.5) continue; |
e43c066c |
2512 | if (l<2 || l>3){ |
2513 | deltan = (cl->GetNy()+cl->GetNz()-ny[l]-nz[l]); |
2514 | } |
2515 | else{ |
2516 | deltan = (cl->GetNz()-nz[l]); |
2517 | } |
2518 | if (deltan>2.0) continue; // extended - highly probable shared cluster |
2519 | // |
2520 | for (Int_t itrack=3;itrack>=0;itrack--){ |
b9671574 |
2521 | if (fgLayers[l].GetClusterTracks(itrack,c)<0) continue; |
2522 | if (fgLayers[l].GetClusterTracks(itrack,c)!=trackID){ |
2523 | tracks[trackindex] = fgLayers[l].GetClusterTracks(itrack,c); |
e43c066c |
2524 | trackindex++; |
2525 | } |
2526 | } |
2527 | } |
2528 | if (trackindex==0) return -1; |
2529 | if (trackindex==1){ |
2530 | sharedtrack = tracks[0]; |
2531 | }else{ |
2532 | if (trackindex==2) sharedtrack =TMath::Min(tracks[0],tracks[1]); |
2533 | else{ |
2534 | // |
2535 | Int_t track[24], cluster[24]; |
2536 | for (Int_t i=0;i<trackindex;i++){ track[i]=-1; cluster[i]=0;} |
2537 | Int_t index =0; |
2538 | // |
2539 | for (Int_t i=0;i<trackindex;i++){ |
2540 | if (tracks[i]<0) continue; |
2541 | track[index] = tracks[i]; |
2542 | cluster[index]++; |
2543 | for (Int_t j=i+1;j<trackindex;j++){ |
2544 | if (tracks[j]<0) continue; |
2545 | if (tracks[j]==tracks[i]){ |
2546 | cluster[index]++; |
2547 | tracks[j]=-1; |
2548 | } |
2549 | } |
2550 | index++; |
2551 | } |
2552 | Int_t max=0; |
2553 | for (Int_t i=0;i<index;i++){ |
2554 | if (cluster[index]>max) { |
2555 | sharedtrack=track[index]; |
2556 | max=cluster[index]; |
2557 | } |
2558 | } |
2559 | } |
2560 | } |
2561 | |
2562 | if (sharedtrack>=100000) return -1; |
2563 | // |
2564 | // make list of overlaps |
2565 | shared =0; |
2566 | for (Int_t icluster=0;icluster<6;icluster++){ |
2567 | if (clusterlist[icluster]<0) continue; |
2568 | Int_t index = clusterlist[icluster]; |
2569 | Int_t l=(index & 0xf0000000) >> 28; |
2570 | Int_t c=(index & 0x0fffffff) >> 00; |
b9671574 |
2571 | if (c>fgLayers[l].GetNumberOfClusters()) continue; |
00a7cc50 |
2572 | AliITSRecPoint *cl = (AliITSRecPoint*)GetCluster(index); |
e43c066c |
2573 | if (l==0 || l==1){ |
2574 | if (cl->GetNy()>2) continue; |
2575 | if (cl->GetNz()>2) continue; |
2576 | } |
2577 | if (l==4 || l==5){ |
2578 | if (cl->GetNy()>3) continue; |
2579 | if (cl->GetNz()>3) continue; |
2580 | } |
2581 | // |
2582 | for (Int_t itrack=3;itrack>=0;itrack--){ |
b9671574 |
2583 | if (fgLayers[l].GetClusterTracks(itrack,c)<0) continue; |
2584 | if (fgLayers[l].GetClusterTracks(itrack,c)==sharedtrack){ |
e43c066c |
2585 | overlist[l]=index; |
2586 | shared++; |
2587 | } |
2588 | } |
2589 | } |
2590 | return sharedtrack; |
2591 | } |
44347160 |
2592 | //------------------------------------------------------------------------ |
15dd636f |
2593 | AliITStrackMI * AliITStrackerMI::GetBest2Tracks(Int_t trackID1, Int_t trackID2, Float_t th0, Float_t th1){ |
e43c066c |
2594 | // |
2595 | // try to find track hypothesys without conflicts |
2596 | // with minimal chi2; |
2597 | TClonesArray *arr1 = (TClonesArray*)fTrackHypothesys.At(trackID1); |
2598 | Int_t entries1 = arr1->GetEntriesFast(); |
2599 | TClonesArray *arr2 = (TClonesArray*)fTrackHypothesys.At(trackID2); |
15dd636f |
2600 | if (!arr2) return (AliITStrackMI*) arr1->UncheckedAt(0); |
e43c066c |
2601 | Int_t entries2 = arr2->GetEntriesFast(); |
15dd636f |
2602 | if (entries2<=0) return (AliITStrackMI*) arr1->UncheckedAt(0); |
e43c066c |
2603 | // |
15dd636f |
2604 | AliITStrackMI * track10=(AliITStrackMI*) arr1->UncheckedAt(0); |
2605 | AliITStrackMI * track20=(AliITStrackMI*) arr2->UncheckedAt(0); |
6c23ffed |
2606 | if (track10->Pt()>0.5+track20->Pt()) return track10; |
e43c066c |
2607 | |
2608 | for (Int_t itrack=0;itrack<entries1;itrack++){ |
15dd636f |
2609 | AliITStrackMI * track=(AliITStrackMI*) arr1->UncheckedAt(itrack); |
e43c066c |
2610 | UnRegisterClusterTracks(track,trackID1); |
2611 | } |
2612 | // |
2613 | for (Int_t itrack=0;itrack<entries2;itrack++){ |
15dd636f |
2614 | AliITStrackMI * track=(AliITStrackMI*) arr2->UncheckedAt(itrack); |
e43c066c |
2615 | UnRegisterClusterTracks(track,trackID2); |
2616 | } |
2617 | Int_t index1=0; |
2618 | Int_t index2=0; |
2619 | Float_t maxconflicts=6; |
2620 | Double_t maxchi2 =1000.; |
2621 | // |
2622 | // get weight of hypothesys - using best hypothesy |
2623 | Double_t w1,w2; |
2624 | |
2625 | Int_t list1[6],list2[6]; |
00a7cc50 |
2626 | AliITSRecPoint *clist1[6], *clist2[6] ; |
e43c066c |
2627 | RegisterClusterTracks(track10,trackID1); |
2628 | RegisterClusterTracks(track20,trackID2); |
2629 | Float_t conflict1 = GetNumberOfSharedClusters(track10,trackID1,list1,clist1); |
2630 | Float_t conflict2 = GetNumberOfSharedClusters(track20,trackID2,list2,clist2); |
2631 | UnRegisterClusterTracks(track10,trackID1); |
2632 | UnRegisterClusterTracks(track20,trackID2); |
2633 | // |
2634 | // normalized chi2 |
2635 | Float_t chi21 =0,chi22=0,ncl1=0,ncl2=0; |
2636 | Float_t nerry[6],nerrz[6]; |
2637 | Float_t *erry1=GetErrY(trackID1),*errz1 = GetErrZ(trackID1); |
2638 | Float_t *erry2=GetErrY(trackID2),*errz2 = GetErrZ(trackID2); |
2639 | for (Int_t i=0;i<6;i++){ |
2640 | if ( (erry1[i]>0) && (erry2[i]>0)) { |
2641 | nerry[i] = TMath::Min(erry1[i],erry2[i]); |
2642 | nerrz[i] = TMath::Min(errz1[i],errz2[i]); |
2643 | }else{ |
2644 | nerry[i] = TMath::Max(erry1[i],erry2[i]); |
2645 | nerrz[i] = TMath::Max(errz1[i],errz2[i]); |
2646 | } |
b9671574 |
2647 | if (TMath::Abs(track10->GetDy(i))>0.000000000000001){ |
2648 | chi21 += track10->GetDy(i)*track10->GetDy(i)/(nerry[i]*nerry[i]); |
2649 | chi21 += track10->GetDz(i)*track10->GetDz(i)/(nerrz[i]*nerrz[i]); |
e43c066c |
2650 | ncl1++; |
2651 | } |
b9671574 |
2652 | if (TMath::Abs(track20->GetDy(i))>0.000000000000001){ |
2653 | chi22 += track20->GetDy(i)*track20->GetDy(i)/(nerry[i]*nerry[i]); |
2654 | chi22 += track20->GetDz(i)*track20->GetDz(i)/(nerrz[i]*nerrz[i]); |
e43c066c |
2655 | ncl2++; |
2656 | } |
2657 | } |
2658 | chi21/=ncl1; |
2659 | chi22/=ncl2; |
2660 | // |
2661 | // |
b9671574 |
2662 | Float_t d1 = TMath::Sqrt(track10->GetD(0)*track10->GetD(0)+track10->GetD(1)*track10->GetD(1))+0.1; |
2663 | Float_t d2 = TMath::Sqrt(track20->GetD(0)*track20->GetD(0)+track20->GetD(1)*track20->GetD(1))+0.1; |
e43c066c |
2664 | Float_t s1 = TMath::Sqrt(track10->GetSigmaY2()*track10->GetSigmaZ2()); |
2665 | Float_t s2 = TMath::Sqrt(track20->GetSigmaY2()*track20->GetSigmaZ2()); |
2666 | // |
2667 | w1 = (d2/(d1+d2)+ 2*s2/(s1+s2)+ |
2668 | +s2/(s1+s2)*0.5*(chi22+2.)/(chi21+chi22+4.) |
6c23ffed |
2669 | +1.*track10->Pt()/(track10->Pt()+track20->Pt()) |
e43c066c |
2670 | ); |
2671 | w2 = (d1/(d1+d2)+ 2*s1/(s1+s2)+ |
2672 | s1/(s1+s2)*0.5*(chi21+2.)/(chi21+chi22+4.) |
6c23ffed |
2673 | +1.*track20->Pt()/(track10->Pt()+track20->Pt()) |
e43c066c |
2674 | ); |
2675 | |
2676 | Double_t sumw = w1+w2; |
2677 | w1/=sumw; |
2678 | w2/=sumw; |
2679 | if (w1<w2*0.5) { |
2680 | w1 = (d2+0.5)/(d1+d2+1.); |
2681 | w2 = (d1+0.5)/(d1+d2+1.); |
2682 | } |
2683 | // Float_t maxmax = w1*track10->fChi2MIP[0]+w2*track20->fChi2MIP[0]+w1*conflict1+w2*conflict2+1.; |
2684 | //Float_t maxconflicts0 = w1*conflict1+w2*conflict2; |
2685 | // |
2686 | // get pair of "best" hypothesys |
2687 | // |
2688 | Float_t * ny1 = GetNy(trackID1), * nz1 = GetNz(trackID1); |
2689 | Float_t * ny2 = GetNy(trackID2), * nz2 = GetNz(trackID2); |
2690 | |
2691 | for (Int_t itrack1=0;itrack1<entries1;itrack1++){ |
15dd636f |
2692 | AliITStrackMI * track1=(AliITStrackMI*) arr1->UncheckedAt(itrack1); |
e43c066c |
2693 | //if (track1->fFakeRatio>0) continue; |
2694 | RegisterClusterTracks(track1,trackID1); |
2695 | for (Int_t itrack2=0;itrack2<entries2;itrack2++){ |
15dd636f |
2696 | AliITStrackMI * track2=(AliITStrackMI*) arr2->UncheckedAt(itrack2); |
e43c066c |
2697 | |
2698 | // Float_t current = w1*track1->fChi2MIP[0]+w2*track2->fChi2MIP[0]; |
2699 | //if (track2->fFakeRatio>0) continue; |
2700 | Float_t nskipped=0; |
2701 | RegisterClusterTracks(track2,trackID2); |
2702 | Int_t list1[6],list2[6]; |
00a7cc50 |
2703 | AliITSRecPoint *clist1[6], *clist2[6] ; |
e43c066c |
2704 | Float_t cconflict1 = GetNumberOfSharedClusters(track1,trackID1,list1,clist1); |
2705 | Float_t cconflict2 = GetNumberOfSharedClusters(track2,trackID2,list2,clist2); |
2706 | UnRegisterClusterTracks(track2,trackID2); |
2707 | // |
b9671574 |
2708 | if (track1->GetConstrain()) nskipped+=w1*track1->GetNSkipped(); |
2709 | if (track2->GetConstrain()) nskipped+=w2*track2->GetNSkipped(); |
e43c066c |
2710 | if (nskipped>0.5) continue; |
2711 | // |
2712 | //if ( w1*conflict1+w2*conflict2>maxconflicts0) continue; |
2713 | if (conflict1+1<cconflict1) continue; |
2714 | if (conflict2+1<cconflict2) continue; |
2715 | Float_t conflict=0; |
2716 | Float_t sumchi2=0; |
2717 | Float_t sum=0; |
2718 | for (Int_t i=0;i<6;i++){ |
2719 | // |
2720 | Float_t c1 =0.; // conflict coeficients |
2721 | Float_t c2 =0.; |
2722 | if (clist1[i]&&clist2[i]){ |
2723 | Float_t deltan = 0; |
2724 | if (i<2 || i>3){ |
2725 | deltan = (clist1[i]->GetNy()+clist1[i]->GetNz()-TMath::Max(ny1[i],ny2[i])-TMath::Max(nz1[i],nz2[i])); |
2726 | } |
2727 | else{ |
2728 | deltan = (clist1[i]->GetNz()-TMath::Max(nz1[i],nz2[i])); |
2729 | } |
2730 | c1 = 2./TMath::Max(3.+deltan,2.); |
2731 | c2 = 2./TMath::Max(3.+deltan,2.); |
2732 | } |
2733 | else{ |
2734 | if (clist1[i]){ |
2735 | Float_t deltan = 0; |
2736 | if (i<2 || i>3){ |
2737 | deltan = (clist1[i]->GetNy()+clist1[i]->GetNz()-ny1[i]-nz1[i]); |
2738 | } |
2739 | else{ |
2740 | deltan = (clist1[i]->GetNz()-nz1[i]); |
2741 | } |
2742 | c1 = 2./TMath::Max(3.+deltan,2.); |
2743 | c2 = 0; |
2744 | } |
2745 | |
2746 | if (clist2[i]){ |
2747 | Float_t deltan = 0; |
2748 | if (i<2 || i>3){ |
2749 | deltan = (clist2[i]->GetNy()+clist2[i]->GetNz()-ny2[i]-nz2[i]); |
2750 | } |
2751 | else{ |
2752 | deltan = (clist2[i]->GetNz()-nz2[i]); |
2753 | } |
2754 | c2 = 2./TMath::Max(3.+deltan,2.); |
2755 | c1 = 0; |
2756 | } |
2757 | } |
2758 | // |
2759 | Double_t chi21=0,chi22=0; |
b9671574 |
2760 | if (TMath::Abs(track1->GetDy(i))>0.) { |
2761 | chi21 = (track1->GetDy(i)/track1->GetSigmaY(i))*(track1->GetDy(i)/track1->GetSigmaY(i))+ |
2762 | (track1->GetDz(i)/track1->GetSigmaZ(i))*(track1->GetDz(i)/track1->GetSigmaZ(i)); |
e43c066c |
2763 | //chi21 = (track1->fDy[i]*track1->fDy[i])/(nerry[i]*nerry[i])+ |
b9671574 |
2764 | // (track1->GetDz(i)*track1->GetDz(i))/(nerrz[i]*nerrz[i]); |
e43c066c |
2765 | }else{ |
b9671574 |
2766 | if (TMath::Abs(track1->GetSigmaY(i)>0.)) c1=1; |
e43c066c |
2767 | } |
2768 | // |
b9671574 |
2769 | if (TMath::Abs(track2->GetDy(i))>0.) { |
2770 | chi22 = (track2->GetDy(i)/track2->GetSigmaY(i))*(track2->GetDy(i)/track2->GetSigmaY(i))+ |
2771 | (track2->GetDz(i)/track2->GetSigmaZ(i))*(track2->GetDz(i)/track2->GetSigmaZ(i)); |
e43c066c |
2772 | //chi22 = (track2->fDy[i]*track2->fDy[i])/(nerry[i]*nerry[i])+ |
2773 | // (track2->fDz[i]*track2->fDz[i])/(nerrz[i]*nerrz[i]); |
2774 | } |
2775 | else{ |
b9671574 |
2776 | if (TMath::Abs(track2->GetSigmaY(i)>0.)) c2=1; |
e43c066c |
2777 | } |
2778 | sumchi2+=w1*(1.+c1)*(1+c1)*(chi21+c1)+w2*(1.+c2)*(1+c2)*(chi22+c2); |
2779 | if (chi21>0) sum+=w1; |
2780 | if (chi22>0) sum+=w2; |
2781 | conflict+=(c1+c2); |
2782 | } |
b9671574 |
2783 | Double_t norm = sum-w1*track1->GetNSkipped()-w2*track2->GetNSkipped(); |
2784 | if (norm<0) norm =1/(w1*track1->GetNSkipped()+w2*track2->GetNSkipped()); |
e43c066c |
2785 | Double_t normchi2 = 2*conflict+sumchi2/sum; |
2786 | if ( normchi2 <maxchi2 ){ |
2787 | index1 = itrack1; |
2788 | index2 = itrack2; |
2789 | maxconflicts = conflict; |
2790 | maxchi2 = normchi2; |
2791 | } |
2792 | } |
2793 | UnRegisterClusterTracks(track1,trackID1); |
2794 | } |
2795 | // |
2796 | // if (maxconflicts<4 && maxchi2<th0){ |
2797 | if (maxchi2<th0*2.){ |
b9671574 |
2798 | Float_t orig = track10->GetFakeRatio()*track10->GetNumberOfClusters(); |
15dd636f |
2799 | AliITStrackMI* track1=(AliITStrackMI*) arr1->UncheckedAt(index1); |
b9671574 |
2800 | track1->SetChi2MIP(5,maxconflicts); |
2801 | track1->SetChi2MIP(6,maxchi2); |
2802 | track1->SetChi2MIP(7,0.01+orig-(track1->GetFakeRatio()*track1->GetNumberOfClusters())); |
e43c066c |
2803 | // track1->UpdateESDtrack(AliESDtrack::kITSin); |
b9671574 |
2804 | track1->SetChi2MIP(8,index1); |
e43c066c |
2805 | fBestTrackIndex[trackID1] =index1; |
2806 | UpdateESDtrack(track1, AliESDtrack::kITSin); |
2807 | } |
b9671574 |
2808 | else if (track10->GetChi2MIP(0)<th1){ |
2809 | track10->SetChi2MIP(5,maxconflicts); |
2810 | track10->SetChi2MIP(6,maxchi2); |
e43c066c |
2811 | // track10->UpdateESDtrack(AliESDtrack::kITSin); |
2812 | UpdateESDtrack(track10,AliESDtrack::kITSin); |
2813 | } |
2814 | |
2815 | for (Int_t itrack=0;itrack<entries1;itrack++){ |
15dd636f |
2816 | AliITStrackMI * track=(AliITStrackMI*) arr1->UncheckedAt(itrack); |
e43c066c |
2817 | UnRegisterClusterTracks(track,trackID1); |
2818 | } |
2819 | // |
2820 | for (Int_t itrack=0;itrack<entries2;itrack++){ |
15dd636f |
2821 | AliITStrackMI * track=(AliITStrackMI*) arr2->UncheckedAt(itrack); |
e43c066c |
2822 | UnRegisterClusterTracks(track,trackID2); |
2823 | } |
2824 | |
44347160 |
2825 | if (track10->GetConstrain()&&track10->GetChi2MIP(0)<AliITSReconstructor::GetRecoParam()->GetMaxChi2PerCluster(0)&&track10->GetChi2MIP(1)<AliITSReconstructor::GetRecoParam()->GetMaxChi2PerCluster(1) |
2826 | &&track10->GetChi2MIP(2)<AliITSReconstructor::GetRecoParam()->GetMaxChi2PerCluster(2)&&track10->GetChi2MIP(3)<AliITSReconstructor::GetRecoParam()->GetMaxChi2PerCluster(3)){ |
2827 | // if (track10->fChi2MIP[0]<AliITSReconstructor::GetRecoParam()->GetMaxChi2PerCluster(0)&&track10->fChi2MIP[1]<AliITSReconstructor::GetRecoParam()->GetMaxChi2PerCluster(1) |
2828 | // &&track10->fChi2MIP[2]<AliITSReconstructor::GetRecoParam()->GetMaxChi2PerCluster(2)&&track10->fChi2MIP[3]<AliITSReconstructor::GetRecoParam()->GetMaxChi2PerCluster(3)){ |
e43c066c |
2829 | RegisterClusterTracks(track10,trackID1); |
2830 | } |
44347160 |
2831 | if (track20->GetConstrain()&&track20->GetChi2MIP(0)<AliITSReconstructor::GetRecoParam()->GetMaxChi2PerCluster(0)&&track20->GetChi2MIP(1)<AliITSReconstructor::GetRecoParam()->GetMaxChi2PerCluster(1) |
2832 | &&track20->GetChi2MIP(2)<AliITSReconstructor::GetRecoParam()->GetMaxChi2PerCluster(2)&&track20->GetChi2MIP(3)<AliITSReconstructor::GetRecoParam()->GetMaxChi2PerCluster(3)){ |
2833 | //if (track20->fChi2MIP[0]<AliITSReconstructor::GetRecoParam()->GetMaxChi2PerCluster(0)&&track20->fChi2MIP[1]<AliITSReconstructor::GetRecoParam()->GetMaxChi2PerCluster(1) |
2834 | // &&track20->fChi2MIP[2]<AliITSReconstructor::GetRecoParam()->GetMaxChi2PerCluster(2)&&track20->fChi2MIP[3]<AliITSReconstructor::GetRecoParam()->GetMaxChi2PerCluster(3)){ |
e43c066c |
2835 | RegisterClusterTracks(track20,trackID2); |
2836 | } |
2837 | return track10; |
2838 | |
2839 | } |
44347160 |
2840 | //------------------------------------------------------------------------ |
e43c066c |
2841 | void AliITStrackerMI::UseClusters(const AliKalmanTrack *t, Int_t from) const { |
2842 | //-------------------------------------------------------------------- |
2843 | // This function marks clusters assigned to the track |
2844 | //-------------------------------------------------------------------- |
2845 | AliTracker::UseClusters(t,from); |
2846 | |
00a7cc50 |
2847 | AliITSRecPoint *c=(AliITSRecPoint *)GetCluster(t->GetClusterIndex(0)); |
e43c066c |
2848 | //if (c->GetQ()>2) c->Use(); |
2849 | if (c->GetSigmaZ2()>0.1) c->Use(); |
00a7cc50 |
2850 | c=(AliITSRecPoint *)GetCluster(t->GetClusterIndex(1)); |
e43c066c |
2851 | //if (c->GetQ()>2) c->Use(); |
2852 | if (c->GetSigmaZ2()>0.1) c->Use(); |
2853 | |
2854 | } |
44347160 |
2855 | //------------------------------------------------------------------------ |
15dd636f |
2856 | void AliITStrackerMI::AddTrackHypothesys(AliITStrackMI * track, Int_t esdindex) |
e43c066c |
2857 | { |
2858 | //------------------------------------------------------------------ |
2859 | // add track to the list of hypothesys |
2860 | //------------------------------------------------------------------ |
2861 | |
2862 | if (esdindex>=fTrackHypothesys.GetEntriesFast()) fTrackHypothesys.Expand(esdindex*2+10); |
2863 | // |
2864 | TObjArray * array = (TObjArray*) fTrackHypothesys.At(esdindex); |
2865 | if (!array) { |
2866 | array = new TObjArray(10); |
2867 | fTrackHypothesys.AddAt(array,esdindex); |
2868 | } |
2869 | array->AddLast(track); |
2870 | } |
44347160 |
2871 | //------------------------------------------------------------------------ |
e43c066c |
2872 | void AliITStrackerMI::SortTrackHypothesys(Int_t esdindex, Int_t maxcut, Int_t mode) |
2873 | { |
2874 | //------------------------------------------------------------------- |
2875 | // compress array of track hypothesys |
2876 | // keep only maxsize best hypothesys |
2877 | //------------------------------------------------------------------- |
2878 | if (esdindex>fTrackHypothesys.GetEntriesFast()) return; |
2879 | if (! (fTrackHypothesys.At(esdindex)) ) return; |
2880 | TObjArray * array = (TObjArray*) fTrackHypothesys.At(esdindex); |
2881 | Int_t entries = array->GetEntriesFast(); |
2882 | // |
2883 | //- find preliminary besttrack as a reference |
2884 | Float_t minchi2=10000; |
2885 | Int_t maxn=0; |
15dd636f |
2886 | AliITStrackMI * besttrack=0; |
e43c066c |
2887 | for (Int_t itrack=0;itrack<array->GetEntriesFast();itrack++){ |
15dd636f |
2888 | AliITStrackMI * track = (AliITStrackMI*)array->At(itrack); |
e43c066c |
2889 | if (!track) continue; |
2890 | Float_t chi2 = NormalizedChi2(track,0); |
2891 | // |
b9671574 |
2892 | Int_t tpcLabel=track->GetESDtrack()->GetTPCLabel(); |
e43c066c |
2893 | track->SetLabel(tpcLabel); |
2894 | CookdEdx(track); |
b9671574 |
2895 | track->SetFakeRatio(1.); |
e43c066c |
2896 | CookLabel(track,0.); //For comparison only |
2897 | // |
44347160 |
2898 | //if (chi2<AliITSReconstructor::GetRecoParam()->GetMaxChi2PerCluster(0)&&track->fFakeRatio==0){ |
2899 | if (chi2<AliITSReconstructor::GetRecoParam()->GetMaxChi2PerCluster(0)){ |
e43c066c |
2900 | if (track->GetNumberOfClusters()<maxn) continue; |
2901 | maxn = track->GetNumberOfClusters(); |
2902 | if (chi2<minchi2){ |
2903 | minchi2=chi2; |
2904 | besttrack=track; |
2905 | } |
2906 | } |
2907 | else{ |
b9671574 |
2908 | if (track->GetConstrain() || track->GetNumberOfClusters()>5){ //keep best short tracks - without vertex constrain |
628e7bb0 |
2909 | delete array->RemoveAt(itrack); |
2910 | } |
e43c066c |
2911 | } |
2912 | } |
2913 | if (!besttrack) return; |
2914 | // |
2915 | // |
2916 | //take errors of best track as a reference |
2917 | Float_t *erry = GetErrY(esdindex), *errz = GetErrZ(esdindex); |
2918 | Float_t *ny = GetNy(esdindex), *nz = GetNz(esdindex); |
2919 | for (Int_t i=0;i<6;i++) { |
b9671574 |
2920 | if (besttrack->GetClIndex(i)>0){ |
2921 | erry[i] = besttrack->GetSigmaY(i); erry[i+6] = besttrack->GetSigmaY(i+6); |
2922 | errz[i] = besttrack->GetSigmaZ(i); errz[i+6] = besttrack->GetSigmaZ(i+6); |
2923 | ny[i] = besttrack->GetNy(i); |
2924 | nz[i] = besttrack->GetNz(i); |
e43c066c |
2925 | } |
2926 | } |
2927 | // |
2928 | // calculate normalized chi2 |
2929 | // |
2930 | Float_t * chi2 = new Float_t[entries]; |
2931 | Int_t * index = new Int_t[entries]; |
2932 | for (Int_t i=0;i<entries;i++) chi2[i] =10000; |
2933 | for (Int_t itrack=0;itrack<entries;itrack++){ |
15dd636f |
2934 | AliITStrackMI * track = (AliITStrackMI*)array->At(itrack); |
e43c066c |
2935 | if (track){ |
b9671574 |
2936 | track->SetChi2MIP(0,GetNormalizedChi2(track, mode)); |
44347160 |
2937 | if (track->GetChi2MIP(0)<AliITSReconstructor::GetRecoParam()->GetMaxChi2PerCluster(0)) |
b9671574 |
2938 | chi2[itrack] = track->GetChi2MIP(0); |
628e7bb0 |
2939 | else{ |
b9671574 |
2940 | if (track->GetConstrain() || track->GetNumberOfClusters()>5){ //keep best short tracks - without vertex constrain |
628e7bb0 |
2941 | delete array->RemoveAt(itrack); |
2942 | } |
2943 | } |
e43c066c |
2944 | } |
2945 | } |
2946 | // |
2947 | TMath::Sort(entries,chi2,index,kFALSE); |
15dd636f |
2948 | besttrack = (AliITStrackMI*)array->At(index[0]); |
44347160 |
2949 | if (besttrack&&besttrack->GetChi2MIP(0)<AliITSReconstructor::GetRecoParam()->GetMaxChi2PerCluster(0)){ |
e43c066c |
2950 | for (Int_t i=0;i<6;i++){ |
b9671574 |
2951 | if (besttrack->GetClIndex(i)>0){ |
2952 | erry[i] = besttrack->GetSigmaY(i); erry[i+6] = besttrack->GetSigmaY(i+6); |
2953 | errz[i] = besttrack->GetSigmaZ(i); erry[i+6] = besttrack->GetSigmaY(i+6); |
2954 | ny[i] = besttrack->GetNy(i); |
2955 | nz[i] = besttrack->GetNz(i); |
e43c066c |
2956 | } |
2957 | } |
2958 | } |
2959 | // |
2960 | // calculate one more time with updated normalized errors |
2961 | for (Int_t i=0;i<entries;i++) chi2[i] =10000; |
2962 | for (Int_t itrack=0;itrack<entries;itrack++){ |
15dd636f |
2963 | AliITStrackMI * track = (AliITStrackMI*)array->At(itrack); |
e43c066c |
2964 | if (track){ |
b9671574 |
2965 | track->SetChi2MIP(0,GetNormalizedChi2(track,mode)); |
44347160 |
2966 | if (track->GetChi2MIP(0)<AliITSReconstructor::GetRecoParam()->GetMaxChi2PerCluster(0)) |
b9671574 |
2967 | chi2[itrack] = track->GetChi2MIP(0)-0*(track->GetNumberOfClusters()+track->GetNDeadZone()); |
628e7bb0 |
2968 | else |
2969 | { |
b9671574 |
2970 | if (track->GetConstrain() || track->GetNumberOfClusters()>5){ //keep best short tracks - without vertex constrain |
628e7bb0 |
2971 | delete array->RemoveAt(itrack); |
2972 | } |
2973 | } |
e43c066c |
2974 | } |
2975 | } |
2976 | entries = array->GetEntriesFast(); |
2977 | // |
628e7bb0 |
2978 | // |
e43c066c |
2979 | if (entries>0){ |
2980 | TObjArray * newarray = new TObjArray(); |
2981 | TMath::Sort(entries,chi2,index,kFALSE); |
15dd636f |
2982 | besttrack = (AliITStrackMI*)array->At(index[0]); |
e43c066c |
2983 | if (besttrack){ |
2984 | // |
2985 | for (Int_t i=0;i<6;i++){ |
b9671574 |
2986 | if (besttrack->GetNz(i)>0&&besttrack->GetNy(i)>0){ |
2987 | erry[i] = besttrack->GetSigmaY(i); erry[i+6] = besttrack->GetSigmaY(i+6); |
2988 | errz[i] = besttrack->GetSigmaZ(i); errz[i+6] = besttrack->GetSigmaZ(i+6); |
2989 | ny[i] = besttrack->GetNy(i); |
2990 | nz[i] = besttrack->GetNz(i); |
e43c066c |
2991 | } |
2992 | } |
b9671574 |
2993 | besttrack->SetChi2MIP(0,GetNormalizedChi2(besttrack,mode)); |
44347160 |
2994 | Float_t minchi2 = TMath::Min(besttrack->GetChi2MIP(0)+5.+besttrack->GetNUsed(), double(AliITSReconstructor::GetRecoParam()->GetMaxChi2PerCluster(0))); |
e43c066c |
2995 | Float_t minn = besttrack->GetNumberOfClusters()-3; |
2996 | Int_t accepted=0; |
2997 | for (Int_t i=0;i<entries;i++){ |
15dd636f |
2998 | AliITStrackMI * track = (AliITStrackMI*)array->At(index[i]); |
e43c066c |
2999 | if (!track) continue; |
3000 | if (accepted>maxcut) break; |
b9671574 |
3001 | track->SetChi2MIP(0,GetNormalizedChi2(track,mode)); |
3002 | if (track->GetConstrain() || track->GetNumberOfClusters()>5){ //keep best short tracks - without vertex constrain |
3003 | if (track->GetNumberOfClusters()<6 && (track->GetChi2MIP(0)+track->GetNUsed()>minchi2)){ |
628e7bb0 |
3004 | delete array->RemoveAt(index[i]); |
3005 | continue; |
3006 | } |
e43c066c |
3007 | } |
b9671574 |
3008 | Bool_t shortbest = !track->GetConstrain() && track->GetNumberOfClusters()<6; |
3009 | if ((track->GetChi2MIP(0)+track->GetNUsed()<minchi2 && track->GetNumberOfClusters()>=minn) ||shortbest){ |
628e7bb0 |
3010 | if (!shortbest) accepted++; |
e43c066c |
3011 | // |
3012 | newarray->AddLast(array->RemoveAt(index[i])); |
3013 | for (Int_t i=0;i<6;i++){ |
3014 | if (nz[i]==0){ |
b9671574 |
3015 | erry[i] = track->GetSigmaY(i); erry[i+6] = track->GetSigmaY(i+6); |
3016 | errz[i] = track->GetSigmaZ(i); errz[i] = track->GetSigmaZ(i+6); |
3017 | ny[i] = track->GetNy(i); |
3018 | nz[i] = track->GetNz(i); |
e43c066c |
3019 | } |
3020 | } |
3021 | } |
3022 | else{ |
3023 | delete array->RemoveAt(index[i]); |
3024 | } |
3025 | } |
3026 | array->Delete(); |
3027 | delete fTrackHypothesys.RemoveAt(esdindex); |
3028 | fTrackHypothesys.AddAt(newarray,esdindex); |
3029 | } |
3030 | else{ |
3031 | array->Delete(); |
3032 | delete fTrackHypothesys.RemoveAt(esdindex); |
3033 | } |
3034 | } |
3035 | delete [] chi2; |
3036 | delete [] index; |
3037 | } |
44347160 |
3038 | //------------------------------------------------------------------------ |
15dd636f |
3039 | AliITStrackMI * AliITStrackerMI::GetBestHypothesys(Int_t esdindex, AliITStrackMI * original, Int_t checkmax) |
e43c066c |
3040 | { |
3041 | //------------------------------------------------------------- |
3042 | // try to find best hypothesy |
3043 | // currently - minimal chi2 of track+backpropagated track+matching to the tpc track |
3044 | //------------------------------------------------------------- |
3045 | if (fTrackHypothesys.GetEntriesFast()<=esdindex) return 0; |
3046 | TObjArray * array = (TObjArray*) fTrackHypothesys.At(esdindex); |
3047 | if (!array) return 0; |
3048 | Int_t entries = array->GetEntriesFast(); |
3049 | if (!entries) return 0; |
3050 | Float_t minchi2 = 100000; |
15dd636f |
3051 | AliITStrackMI * besttrack=0; |
e43c066c |
3052 | // |
15dd636f |
|