]>
Commit | Line | Data |
---|---|---|
32d38de2 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
16 | /* | |
17 | TO CHECK | |
18 | GetBz usage | |
19 | ||
20 | */ | |
21 | ||
22 | //------------------------------------------------------------------------- | |
23 | // Implementation of the ITS Upgrade tracker mother class. | |
24 | //------------------------------------------------------------------------- | |
25 | #include <TTree.h> | |
26 | #include <Riostream.h> | |
27 | #include <TMath.h> | |
28 | ||
29 | #include "AliITSUTrackerGlo.h" | |
30 | #include "AliESDEvent.h" | |
31 | #include "AliESDtrack.h" | |
32 | #include "AliITSURecoDet.h" | |
33 | #include "AliITSURecoSens.h" | |
34 | #include "AliITSUReconstructor.h" | |
35 | #include "AliITSReconstructor.h" | |
36 | #include "AliITSUSeed.h" | |
37 | #include "AliITSUAux.h" | |
c61e50c3 | 38 | #include "AliITSUClusterPix.h" |
32d38de2 | 39 | using namespace AliITSUAux; |
40 | using namespace TMath; | |
41 | ||
42 | ||
c8d1f258 | 43 | //----------------- tmp stuff ----------------- |
c8d1f258 | 44 | |
32d38de2 | 45 | ClassImp(AliITSUTrackerGlo) |
46 | //_________________________________________________________________________ | |
47 | AliITSUTrackerGlo::AliITSUTrackerGlo(AliITSUReconstructor* rec) | |
48 | : fReconstructor(rec) | |
49 | ,fITS(0) | |
0091e9f0 | 50 | ,fCurrESDtrack(0) |
32d38de2 | 51 | ,fCurrMass(kPionMass) |
716ccba7 | 52 | ,fHypStore(100) |
53 | ,fCurrHyp(0) | |
c61e50c3 | 54 | ,fSeedsPool("AliITSUSeed",0) |
c8d1f258 | 55 | ,fTrCond() |
c51c3124 | 56 | ,fTrackPhase(-1) |
8b16dbae | 57 | ,fClInfo(0) |
32d38de2 | 58 | { |
59 | // Default constructor | |
60 | if (rec) Init(rec); | |
61 | } | |
62 | ||
63 | //_________________________________________________________________________ | |
64 | AliITSUTrackerGlo::~AliITSUTrackerGlo() | |
65 | { | |
66 | // Default destructor | |
67 | // | |
68 | delete fITS; | |
8b16dbae | 69 | delete[] fClInfo; |
32d38de2 | 70 | // |
71 | } | |
72 | ||
73 | //_________________________________________________________________________ | |
74 | void AliITSUTrackerGlo::Init(AliITSUReconstructor* rec) | |
75 | { | |
76 | // init with external reconstructor | |
c61e50c3 | 77 | // |
32d38de2 | 78 | fITS = new AliITSURecoDet(rec->GetGeom(),"ITSURecoInterface"); |
8b16dbae | 79 | int nLr = fITS->GetNLayersActive(); |
80 | fClInfo = new Int_t[nLr<<1]; | |
81 | for (int ilr=nLr;ilr--;) { | |
32d38de2 | 82 | fITS->GetLayerActive(ilr)->SetClusters(rec->GetClusters(ilr)); |
83 | } | |
c61e50c3 | 84 | // |
85 | fSeedsPool.ExpandCreateFast(1000); // RS TOCHECK | |
c61e50c3 | 86 | // |
c8d1f258 | 87 | fTrCond.SetNLayers(fITS->GetNLayersActive()); |
88 | fTrCond.AddNewCondition(5); | |
89 | fTrCond.AddGroupPattern( (0x1<<0)|(0x1<<1) ); | |
90 | fTrCond.AddGroupPattern( (0x1<<3)|(0x1<<4) ); | |
91 | fTrCond.AddGroupPattern( (0x1<<5)|(0x1<<6) ); | |
92 | // | |
93 | fTrCond.AddNewCondition(5); | |
94 | fTrCond.AddGroupPattern( (0x1<<0)|(0x1<<2) ); | |
95 | fTrCond.AddGroupPattern( (0x1<<3)|(0x1<<4) ); | |
96 | fTrCond.AddGroupPattern( (0x1<<5)|(0x1<<6) ); | |
97 | // | |
98 | fTrCond.AddNewCondition(5); | |
99 | fTrCond.AddGroupPattern( (0x1<<1)|(0x1<<2) ); | |
100 | fTrCond.AddGroupPattern( (0x1<<3)|(0x1<<4) ); | |
101 | fTrCond.AddGroupPattern( (0x1<<5)|(0x1<<6) ); | |
102 | // | |
103 | printf("Tracking Conditions: "); | |
104 | fTrCond.Print(); | |
32d38de2 | 105 | } |
106 | ||
107 | //_________________________________________________________________________ | |
108 | Int_t AliITSUTrackerGlo::Clusters2Tracks(AliESDEvent *esdEv) | |
109 | { | |
110 | // | |
111 | // | |
c51c3124 | 112 | fTrackPhase = kClus2Tracks; |
716ccba7 | 113 | int nTrESD = esdEv->GetNumberOfTracks(); |
c51c3124 | 114 | AliInfo(Form("Will try to find prolongations for %d tracks",nTrESD)); |
115 | AliITSUReconstructor::GetRecoParam()->Print(); | |
716ccba7 | 116 | fHypStore.Delete(); |
117 | if (fHypStore.GetSize()<nTrESD) fHypStore.Expand(nTrESD+100); | |
118 | // | |
32d38de2 | 119 | fITS->ProcessClusters(); |
120 | // select ESD tracks to propagate | |
32d38de2 | 121 | for (int itr=0;itr<nTrESD;itr++) { |
122 | AliESDtrack *esdTr = esdEv->GetTrack(itr); | |
0091e9f0 | 123 | AliInfo(Form("Processing track %d | MCLabel: %d",itr,esdTr->GetTPCLabel())); |
c51c3124 | 124 | if (!NeedToProlong(esdTr)) continue; // are we interested in this track? |
716ccba7 | 125 | FindTrack(esdTr, itr); |
32d38de2 | 126 | } |
716ccba7 | 127 | // |
128 | printf("Hypotheses for current event (N seeds in pool: %d, size: %d)\n",fSeedsPool.GetEntriesFast(),fSeedsPool.GetSize()); | |
129 | fHypStore.Print(); | |
3e4e3c23 | 130 | FinalizeHypotheses(); |
716ccba7 | 131 | // |
32d38de2 | 132 | return 0; |
133 | } | |
134 | ||
135 | //_________________________________________________________________________ | |
c51c3124 | 136 | Int_t AliITSUTrackerGlo::PropagateBack(AliESDEvent *esdEv) |
32d38de2 | 137 | { |
138 | // | |
c51c3124 | 139 | // Do outward fits in ITS |
140 | // | |
141 | fTrackPhase = kPropBack; | |
142 | int nTrESD = esdEv->GetNumberOfTracks(); | |
143 | AliInfo(Form("Will fit %d tracks",nTrESD)); | |
144 | // | |
145 | double bz0 = GetBz(); | |
146 | Double_t xyzTrk[3],xyzVtx[3]={GetX(),GetY(),GetZ()}; | |
147 | AliITSUTrackHyp dummyTr,*currTr=0; | |
148 | const double kWatchStep=10.; // for larger steps watch arc vs segment difference | |
149 | Double_t times[AliPID::kSPECIES]; | |
150 | // | |
151 | // | |
152 | for (int itr=0;itr<nTrESD;itr++) { | |
153 | AliESDtrack *esdTr = esdEv->GetTrack(itr); | |
154 | // Start time integral and add distance from current position to vertex | |
155 | if (esdTr->IsOn(AliESDtrack::kITSout)) continue; // already done | |
156 | // | |
157 | esdTr->GetXYZ(xyzTrk); | |
158 | Double_t dst = 0.; // set initial track lenght, tof | |
159 | { | |
160 | double dxs = xyzTrk[0] - xyzVtx[0]; | |
161 | double dys = xyzTrk[1] - xyzVtx[1]; | |
162 | double dzs = xyzTrk[2] - xyzVtx[2]; | |
163 | // RS: for large segment steps d use approximation of cicrular arc s by | |
164 | // s = 2R*asin(d/2R) = d/p asin(p) \approx d/p (p + 1/6 p^3) = d (1+1/6 p^2) | |
165 | // where R is the track radius, p = d/2R = 2C*d (C is the abs curvature) | |
166 | // Hence s^2/d^2 = (1+1/6 p^2)^2 | |
167 | dst = dxs*dxs + dys*dys; | |
168 | if (dst > kWatchStep*kWatchStep) { // correct circular part for arc/segment factor | |
169 | double crv = Abs(esdTr->GetC(bz0)); | |
170 | double fcarc = 1.+crv*crv*dst/6.; | |
171 | dst *= fcarc*fcarc; | |
172 | } | |
173 | dst += dzs*dzs; | |
174 | dst = Sqrt(dst); | |
175 | } | |
176 | // | |
177 | esdTr->SetStatus(AliESDtrack::kTIME); | |
178 | // | |
179 | if (!esdTr->IsOn(AliESDtrack::kITSin)) { // case of tracks w/o ITS prolongation: just set the time integration | |
180 | dummyTr.StartTimeIntegral(); | |
181 | dummyTr.AddTimeStep(TMath::Sqrt(dst)); | |
182 | dummyTr.GetIntegratedTimes(times); | |
183 | esdTr->SetIntegratedTimes(times); | |
184 | esdTr->SetIntegratedLength(dummyTr.GetIntegratedLength()); | |
185 | continue; | |
186 | } | |
187 | // | |
188 | currTr = GetTrackHyp(itr); | |
189 | currTr->StartTimeIntegral(); | |
190 | currTr->AddTimeStep(dst); | |
191 | currTr->ResetCovariance(10.); | |
192 | RefitTrack(currTr,fITS->GetRMax()); // propagate to exit from the ITS/TPC screen | |
193 | // | |
194 | } | |
32d38de2 | 195 | // |
32d38de2 | 196 | return 0; |
197 | } | |
198 | ||
199 | //_________________________________________________________________________ | |
200 | Int_t AliITSUTrackerGlo::RefitInward(AliESDEvent * /*event*/) | |
201 | { | |
202 | // | |
203 | // To be implemented | |
204 | // | |
205 | ||
206 | Info("RefitInward","To be implemented"); | |
207 | return 0; | |
208 | } | |
209 | ||
210 | //_________________________________________________________________________ | |
211 | Int_t AliITSUTrackerGlo::LoadClusters(TTree * treeRP) | |
212 | { | |
213 | // read from tree (if pointer provided) or directly from the ITS reco interface | |
214 | // | |
215 | return fReconstructor->LoadClusters(treeRP); | |
216 | } | |
217 | ||
218 | //_________________________________________________________________________ | |
219 | void AliITSUTrackerGlo::UnloadClusters() | |
220 | { | |
221 | // | |
222 | // To be implemented | |
223 | // | |
224 | ||
225 | Info("UnloadClusters","To be implemented"); | |
226 | } | |
227 | //_________________________________________________________________________ | |
228 | AliCluster * AliITSUTrackerGlo::GetCluster(Int_t /*index*/) const | |
229 | { | |
230 | // | |
231 | // To be implemented | |
232 | // | |
233 | ||
234 | Info("GetCluster","To be implemented"); | |
235 | return 0x0; | |
236 | } | |
237 | ||
238 | //_________________________________________________________________________ | |
239 | Bool_t AliITSUTrackerGlo::NeedToProlong(AliESDtrack* esdTr) | |
240 | { | |
241 | // do we need to match this track to ITS? | |
242 | // | |
243 | static double bz = GetBz(); | |
244 | if (!esdTr->IsOn(AliESDtrack::kTPCin) || | |
245 | esdTr->IsOn(AliESDtrack::kTPCout) || | |
246 | esdTr->IsOn(AliESDtrack::kITSin) || | |
247 | esdTr->GetKinkIndex(0)>0) return kFALSE; | |
248 | // | |
c61e50c3 | 249 | if (esdTr->Pt()<AliITSUReconstructor::GetRecoParam()->GetMinPtForProlongation()) return kFALSE; |
32d38de2 | 250 | // |
251 | float dtz[2]; | |
252 | esdTr->GetDZ(GetX(),GetY(),GetZ(),bz,dtz); | |
253 | // if track is not V0 candidata but has large offset wrt IP, reject it. RS TOCHECK | |
c61e50c3 | 254 | if ( !(esdTr->GetV0Index(0)>0 && dtz[0]>AliITSUReconstructor::GetRecoParam()->GetMaxDforV0dghtrForProlongation()) |
255 | && (Abs(dtz[0])>AliITSUReconstructor::GetRecoParam()->GetMaxDForProlongation() || | |
256 | Abs(dtz[1])>AliITSUReconstructor::GetRecoParam()->GetMaxDZForProlongation())) return kFALSE; | |
32d38de2 | 257 | // |
258 | return kTRUE; | |
259 | } | |
260 | ||
261 | //_________________________________________________________________________ | |
716ccba7 | 262 | void AliITSUTrackerGlo::FindTrack(AliESDtrack* esdTr, Int_t esdID) |
32d38de2 | 263 | { |
264 | // find prolongaion candidates finding for single seed | |
265 | // | |
3e4e3c23 | 266 | AliITSUSeed seedUC; // copy of the seed from the upper layer |
267 | AliITSUSeed seedT; // transient seed between the seedUC and new prolongation hypothesis | |
268 | // | |
3e4e3c23 | 269 | if (!InitHypothesis(esdTr,esdID)) return; // initialize prolongations hypotheses tree |
32d38de2 | 270 | // |
173b3073 | 271 | AliITSURecoSens *hitSens[AliITSURecoSens::kNNeighbors+1]; |
f8832015 | 272 | // |
c61e50c3 | 273 | TObjArray clArr; // container for transfer of clusters matching to seed |
32d38de2 | 274 | // |
3e4e3c23 | 275 | int nLrActive = fITS->GetNLayersActive(); |
276 | for (int ila=nLrActive;ila--;) { | |
32d38de2 | 277 | int ilaUp = ila+1; // prolong seeds from layer above |
3e4e3c23 | 278 | // |
279 | // for the outermost layer the seed is created from the ESD track | |
280 | int nSeedsUp = (ilaUp==nLrActive) ? 1 : fCurrHyp->GetNSeeds(ilaUp); | |
281 | // | |
32d38de2 | 282 | for (int isd=0;isd<nSeedsUp;isd++) { |
3e4e3c23 | 283 | AliITSUSeed* seedU; |
284 | if (ilaUp==nLrActive) { | |
285 | seedU = 0; | |
286 | seedUC.InitFromESDTrack(esdTr); | |
287 | } | |
288 | else { | |
289 | seedU = fCurrHyp->GetSeed(ilaUp,isd); // seed on prev.active layer to prolong | |
290 | seedUC = *seedU; // its copy will be prolonged | |
291 | seedUC.SetParent(seedU); | |
292 | } | |
943e1898 | 293 | seedUC.ResetFMatrix(); // reset the matrix for propagation to next layer |
32d38de2 | 294 | // go till next active layer |
c8d1f258 | 295 | AliInfo(Form("working on Lr:%d Seed:%d of %d",ila,isd,nSeedsUp)); |
f8832015 | 296 | if (!TransportToLayer(&seedUC, fITS->GetLrIDActive(ilaUp), fITS->GetLrIDActive(ila)) ) { |
32d38de2 | 297 | // |
0091e9f0 | 298 | AliInfo("Transport failed"); |
32d38de2 | 299 | // Check if the seed satisfies to track definition |
3e4e3c23 | 300 | if (NeedToKill(&seedUC,kTransportFailed) && seedU) seedU->Kill(); |
32d38de2 | 301 | continue; // RS TODO: decide what to do with tracks stopped on higher layers w/o killing |
302 | } | |
303 | AliITSURecoLayer* lrA = fITS->GetLayerActive(ila); | |
f8832015 | 304 | if (!GetRoadWidth(&seedUC, ila)) { // failed to find road width on the layer |
3e4e3c23 | 305 | if (NeedToKill(&seedUC,kRWCheckFailed) && seedU) seedU->Kill(); |
32d38de2 | 306 | continue; |
307 | } | |
173b3073 | 308 | int nsens = lrA->FindSensors(&fTrImpData[kTrPhi0], hitSens); // find detectors which may be hit by the track |
0091e9f0 | 309 | AliInfo(Form("Will check %d sensors on lr:%d ",nsens,ila)); |
32d38de2 | 310 | // |
943e1898 | 311 | double bz = GetBz(); |
32d38de2 | 312 | for (int isn=nsens;isn--;) { |
f8832015 | 313 | seedT = seedUC; |
c61e50c3 | 314 | AliITSURecoSens* sens = hitSens[isn]; |
f8832015 | 315 | // |
943e1898 | 316 | // We need to propagate the seed to sensor on lrA staying the frame of the sensor from prev.layer, |
317 | // since the transport matrix should be defined in this frame. | |
318 | double xs; // X in the TF of current seed, corresponding to intersection with sensor plane | |
319 | if (!seedT.GetTrackingXAtXAlpha(sens->GetXTF(),sens->GetPhiTF(),bz, xs)) continue; | |
8b16dbae | 320 | if (!PropagateSeed(&seedT,xs,fCurrMass)) continue; |
321 | // if (!seedT.PropagateToX(xs,bz)) continue; | |
716ccba7 | 322 | // if (!seedT.Rotate(sens->GetPhiTF())) continue; |
323 | if (!seedT.RotateToAlpha(sens->GetPhiTF())) continue; | |
943e1898 | 324 | // |
f8832015 | 325 | int clID0 = sens->GetFirstClusterId(); |
c61e50c3 | 326 | for (int icl=sens->GetNClusters();icl--;) { |
f8832015 | 327 | int res = CheckCluster(&seedT,ila,clID0+icl); |
328 | // | |
329 | if (res==kStopSearchOnSensor) break; // stop looking on this sensor | |
330 | if (res==kClusterNotMatching) continue; // cluster does not match | |
331 | // cluster is matching and it was added to the hypotheses tree | |
c61e50c3 | 332 | } |
32d38de2 | 333 | } |
f8832015 | 334 | // cluster search is done. Do we need ta have a version of this seed skipping current layer |
335 | seedT.SetLr(ila); | |
716ccba7 | 336 | if (!NeedToKill(&seedT,kMissingCluster)) { |
337 | AliITSUSeed* seedSkp = NewSeedFromPool(&seedT); | |
338 | double penalty = -AliITSUReconstructor::GetRecoParam()->GetMissPenalty(ila); | |
339 | // to do: make penalty to account for probability to miss the cluster for good reason | |
340 | seedSkp->SetChi2Cl(penalty); | |
341 | AddProlongationHypothesis(seedSkp,ila); | |
342 | } | |
32d38de2 | 343 | } |
716ccba7 | 344 | ((TObjArray*)fCurrHyp->GetLayerSeeds(ila))->Sort(); |
c8d1f258 | 345 | printf(">>> All hypotheses on lr %d: \n",ila); |
716ccba7 | 346 | for (int ih=0;ih<fCurrHyp->GetNSeeds(ila);ih++) { |
347 | printf(" #%3d ",ih); fCurrHyp->GetSeed(ila,ih)->Print(); | |
348 | // | |
349 | /* | |
350 | if (ila!=0) continue; | |
351 | double vecL[5] = {0}; | |
352 | double matL[15] = {0}; | |
353 | AliITSUSeed* sp = fCurrHyp->GetSeed(ila,ih); | |
354 | while(sp->GetParent()) { | |
355 | sp->Smooth(vecL,matL); | |
356 | if (sp->GetLayerID()>=fITS->GetNLayersActive()-1) break; | |
357 | sp = (AliITSUSeed*)sp->GetParent(); | |
358 | } | |
359 | */ | |
c8d1f258 | 360 | } |
32d38de2 | 361 | } |
362 | // | |
716ccba7 | 363 | SaveCurrentTrackHypotheses(); |
364 | // | |
32d38de2 | 365 | } |
366 | ||
367 | //_________________________________________________________________________ | |
3e4e3c23 | 368 | Bool_t AliITSUTrackerGlo::InitHypothesis(AliESDtrack *esdTr, Int_t esdID) |
32d38de2 | 369 | { |
c61e50c3 | 370 | // init prolongaion candidates finding for single seed |
716ccba7 | 371 | fCurrHyp = GetTrackHyp(esdID); |
372 | if (fCurrHyp) return kTRUE; | |
373 | // | |
32d38de2 | 374 | fCurrMass = esdTr->GetMass(); |
0091e9f0 | 375 | fCurrESDtrack = esdTr; |
32d38de2 | 376 | if (fCurrMass<kPionMass*0.9) fCurrMass = kPionMass; // don't trust to mu, e identification from TPCin |
c61e50c3 | 377 | // |
3e4e3c23 | 378 | fCurrHyp = new AliITSUTrackHyp(fITS->GetNLayersActive()); |
379 | fCurrHyp->SetESDTrack(esdTr); | |
716ccba7 | 380 | fCurrHyp->SetUniqueID(esdID); |
c51c3124 | 381 | fCurrHyp->SetMass(fCurrMass); |
716ccba7 | 382 | SetTrackHyp(fCurrHyp,esdID); |
3e4e3c23 | 383 | // |
32d38de2 | 384 | return kTRUE; |
385 | // TO DO | |
386 | } | |
387 | ||
388 | //_________________________________________________________________________ | |
389 | Bool_t AliITSUTrackerGlo::TransportToLayer(AliITSUSeed* seed, Int_t lFrom, Int_t lTo) | |
390 | { | |
391 | // transport seed from layerFrom to the entrance of layerTo | |
392 | // | |
393 | const double kToler = 1e-6; // tolerance for layer on-surface check | |
394 | // | |
8b16dbae | 395 | // |
396 | if (lTo==lFrom) AliFatal(Form("was called with lFrom=%d lTo=%d",lFrom,lTo)); | |
397 | // | |
32d38de2 | 398 | int dir = lTo > lFrom ? 1:-1; |
399 | AliITSURecoLayer* lrFr = fITS->GetLayer(lFrom); // this can be 0 when extrapolation from TPC to ITS is requested | |
400 | Bool_t checkFirst = kTRUE; | |
401 | while(lFrom!=lTo) { | |
402 | double curR2 = seed->GetX()*seed->GetX() + seed->GetY()*seed->GetY(); // current radius | |
403 | if (lrFr) { | |
404 | Bool_t doLayer = kTRUE; | |
8b16dbae | 405 | double xToGo = lrFr->GetR(dir); |
32d38de2 | 406 | if (checkFirst) { // do we need to track till the surface of the current layer ? |
407 | checkFirst = kFALSE; | |
408 | if (dir>0) { if (curR2-xToGo*xToGo>kToler) doLayer = kFALSE; } // on the surface or outside of the layer | |
409 | else if (dir<0) { if (xToGo*xToGo-curR2>kToler) doLayer = kFALSE; } // on the surface or outside of the layer | |
410 | } | |
411 | if (doLayer) { | |
412 | if (!seed->GetXatLabR(xToGo,xToGo,GetBz(),dir)) return kFALSE; | |
413 | // go via layer to its boundary, applying material correction. | |
44785f3e | 414 | if (!PropagateSeed(seed,xToGo,fCurrMass, lrFr->GetMaxStep())) return kFALSE; |
32d38de2 | 415 | } |
416 | } | |
417 | AliITSURecoLayer* lrTo = fITS->GetLayer( (lFrom+=dir) ); | |
418 | if (!lrTo) AliFatal(Form("Layer %d does not exist",lFrom)); | |
419 | // | |
420 | // go the entrance of the layer, assuming no materials in between | |
8b16dbae | 421 | double xToGo = lrTo->GetR(-dir); |
dde91d5d | 422 | if (!seed->GetXatLabR(xToGo,xToGo,GetBz(),dir)) return kFALSE; |
44785f3e | 423 | if (!PropagateSeed(seed,xToGo,fCurrMass,100, kFALSE )) return kFALSE; |
32d38de2 | 424 | lrFr = lrTo; |
425 | } | |
426 | return kTRUE; | |
427 | // | |
428 | } | |
429 | ||
3e4e3c23 | 430 | //_________________________________________________________________________ |
431 | Bool_t AliITSUTrackerGlo::TransportToLayer(AliExternalTrackParam* seed, Int_t lFrom, Int_t lTo) | |
432 | { | |
433 | // transport track from layerFrom to the entrance of layerTo | |
434 | // | |
435 | const double kToler = 1e-6; // tolerance for layer on-surface check | |
436 | // | |
8b16dbae | 437 | if (lTo==lFrom) AliFatal(Form("was called with lFrom=%d lTo=%d",lFrom,lTo)); |
438 | // | |
3e4e3c23 | 439 | int dir = lTo > lFrom ? 1:-1; |
440 | AliITSURecoLayer* lrFr = fITS->GetLayer(lFrom); // this can be 0 when extrapolation from TPC to ITS is requested | |
441 | Bool_t checkFirst = kTRUE; | |
442 | while(lFrom!=lTo) { | |
443 | double curR2 = seed->GetX()*seed->GetX() + seed->GetY()*seed->GetY(); // current radius | |
444 | if (lrFr) { | |
445 | Bool_t doLayer = kTRUE; | |
8b16dbae | 446 | double xToGo = lrFr->GetR(dir); |
3e4e3c23 | 447 | if (checkFirst) { // do we need to track till the surface of the current layer ? |
448 | checkFirst = kFALSE; | |
449 | if (dir>0) { if (curR2-xToGo*xToGo>kToler) doLayer = kFALSE; } // on the surface or outside of the layer | |
450 | else if (dir<0) { if (xToGo*xToGo-curR2>kToler) doLayer = kFALSE; } // on the surface or outside of the layer | |
451 | } | |
452 | if (doLayer) { | |
453 | if (!seed->GetXatLabR(xToGo,xToGo,GetBz(),dir)) return kFALSE; | |
454 | // go via layer to its boundary, applying material correction. | |
455 | if (!PropagateSeed(seed,xToGo,fCurrMass, lrFr->GetMaxStep())) return kFALSE; | |
456 | } | |
457 | } | |
458 | AliITSURecoLayer* lrTo = fITS->GetLayer( (lFrom+=dir) ); | |
459 | if (!lrTo) AliFatal(Form("Layer %d does not exist",lFrom)); | |
460 | // | |
461 | // go the entrance of the layer, assuming no materials in between | |
8b16dbae | 462 | double xToGo = lrTo->GetR(-dir); |
3e4e3c23 | 463 | if (!seed->GetXatLabR(xToGo,xToGo,GetBz(),dir)) return kFALSE; |
464 | if (!PropagateSeed(seed,xToGo,fCurrMass,100, kFALSE )) return kFALSE; | |
465 | lrFr = lrTo; | |
466 | } | |
467 | return kTRUE; | |
468 | // | |
469 | } | |
470 | ||
32d38de2 | 471 | //_________________________________________________________________________ |
c61e50c3 | 472 | Bool_t AliITSUTrackerGlo::GetRoadWidth(AliITSUSeed* seed, int ilrA) |
32d38de2 | 473 | { |
474 | // calculate road width in terms of phi and z for the track which MUST be on the external radius of the layer | |
475 | // as well as some aux info | |
476 | double bz = GetBz(); | |
477 | AliITSURecoLayer* lrA = fITS->GetLayerActive(ilrA); | |
c61e50c3 | 478 | seed->GetXYZ(&fTrImpData[kTrXIn]); // lab position at the entrance from above |
943e1898 | 479 | static AliExternalTrackParam sc; // seed copy for manipalitions |
480 | sc = *seed; | |
32d38de2 | 481 | // |
c61e50c3 | 482 | fTrImpData[kTrPhiIn] = ATan2(fTrImpData[kTrYIn],fTrImpData[kTrXIn]); |
943e1898 | 483 | if (!sc.Rotate(fTrImpData[kTrPhiIn])) return kFALSE; // go to the frame of the entry point into the layer |
c61e50c3 | 484 | double dr = lrA->GetDR(); // approximate X dist at the inner radius |
943e1898 | 485 | if (!sc.GetXYZAt(sc.GetX()-dr, bz, fTrImpData + kTrXOut)) { |
32d38de2 | 486 | // special case: track does not reach inner radius, might be tangential |
943e1898 | 487 | double r = sc.GetD(0,0,bz); |
32d38de2 | 488 | double x; |
943e1898 | 489 | if (!sc.GetXatLabR(r,x,bz,-1)) { |
490 | sc.Print(); | |
491 | AliFatal(Form("This should not happen: r=%f",r)); | |
32d38de2 | 492 | } |
943e1898 | 493 | dr = Abs(sc.GetX() - x); |
494 | if (!sc.GetXYZAt(x, bz, fTrImpData + kTrXOut)) { | |
495 | sc.Print(); | |
496 | AliFatal(Form("This should not happen: x=%f",x)); | |
32d38de2 | 497 | } |
498 | } | |
499 | // | |
c61e50c3 | 500 | fTrImpData[kTrPhiOut] = ATan2(fTrImpData[kTrYOut],fTrImpData[kTrXOut]); |
943e1898 | 501 | double sgy = sc.GetSigmaY2() + dr*dr*sc.GetSigmaSnp2() + AliITSUReconstructor::GetRecoParam()->GetSigmaY2(ilrA); |
502 | double sgz = sc.GetSigmaZ2() + dr*dr*sc.GetSigmaTgl2() + AliITSUReconstructor::GetRecoParam()->GetSigmaZ2(ilrA); | |
c61e50c3 | 503 | sgy = Sqrt(sgy)*AliITSUReconstructor::GetRecoParam()->GetNSigmaRoadY(); |
504 | sgz = Sqrt(sgz)*AliITSUReconstructor::GetRecoParam()->GetNSigmaRoadZ(); | |
505 | fTrImpData[kTrPhi0] = 0.5*(fTrImpData[kTrPhiOut]+fTrImpData[kTrPhiIn]); | |
173b3073 | 506 | fTrImpData[kTrZ0] = 0.5*(fTrImpData[kTrZOut]+fTrImpData[kTrZIn]); |
c61e50c3 | 507 | fTrImpData[kTrDPhi] = 0.5*Abs(fTrImpData[kTrPhiOut]-fTrImpData[kTrPhiIn]) + sgy/lrA->GetR(); |
173b3073 | 508 | fTrImpData[kTrDZ] = 0.5*Abs(fTrImpData[kTrZOut]-fTrImpData[kTrZIn]) + sgz; |
32d38de2 | 509 | // |
510 | return kTRUE; | |
511 | } | |
512 | ||
513 | //_________________________________________________________________________ | |
c61e50c3 | 514 | AliITSUSeed* AliITSUTrackerGlo::NewSeedFromPool(const AliITSUSeed* src) |
32d38de2 | 515 | { |
516 | // create new seed, optionally copying from the source | |
517 | return src ? | |
518 | new(fSeedsPool[fSeedsPool.GetEntriesFast()]) AliITSUSeed(*src) : | |
519 | new(fSeedsPool[fSeedsPool.GetEntriesFast()]) AliITSUSeed(); | |
520 | } | |
f8832015 | 521 | |
522 | //_________________________________________________________________________ | |
523 | Int_t AliITSUTrackerGlo::CheckCluster(AliITSUSeed* track, Int_t lr, Int_t clID) | |
524 | { | |
525 | // Check if the cluster (in tracking frame!) is matching to track. | |
526 | // The track must be already propagated to sensor tracking frame. | |
527 | // Returns: kStopSearchOnSensor if the search on given sensor should be stopped, | |
528 | // kClusterMatching if the cluster is matching | |
529 | // kClusterMatching otherwise | |
530 | // | |
f8832015 | 531 | const double kTolerX = 5e-4; |
532 | AliCluster *cl = fITS->GetLayerActive(lr)->GetCluster(clID); | |
533 | // | |
c8d1f258 | 534 | Bool_t goodCl = kFALSE; |
716ccba7 | 535 | int currLabel = Abs(fCurrESDtrack->GetTPCLabel()); |
536 | // | |
8b16dbae | 537 | if (cl->GetLabel(0)>=0) { |
538 | for (int i=0;i<3;i++) if (cl->GetLabel(i)>=0 && cl->GetLabel(i)==currLabel) {goodCl = kTRUE; break;} | |
539 | } | |
716ccba7 | 540 | else goodCl = kTRUE; |
c8d1f258 | 541 | // |
f8832015 | 542 | if (TMath::Abs(cl->GetX())>kTolerX) { // if due to the misalingment X is large, propagate track only |
c8d1f258 | 543 | if (!track->PropagateParamOnlyTo(track->GetX()+cl->GetX(),GetBz())) { |
3dd9c283 | 544 | if (goodCl) {printf("Loose good cl: Failed propagation. |"); cl->Print();} |
c8d1f258 | 545 | return kStopSearchOnSensor; // propagation failed, seedT is intact |
546 | } | |
f8832015 | 547 | } |
3dd9c283 | 548 | double dy = cl->GetY()-track->GetY(); |
c8d1f258 | 549 | double dz = cl->GetZ()-track->GetZ(); |
0091e9f0 | 550 | // |
f8832015 | 551 | double dy2 = dy*dy; |
552 | double tol2 = (track->GetSigmaY2() + AliITSUReconstructor::GetRecoParam()->GetSigmaY2(lr))* | |
553 | AliITSUReconstructor::GetRecoParam()->GetNSigmaRoadY()*AliITSUReconstructor::GetRecoParam()->GetNSigmaRoadY(); // RS TOOPTIMIZE | |
554 | if (dy2>tol2) { // the clusters are sorted in Z(col) then in Y(row). | |
3dd9c283 | 555 | if (goodCl) {printf("Loose good cl: dy2=%e > tol2=%e |",dy2,tol2); cl->Print();} |
f8832015 | 556 | if (dy>0) return kStopSearchOnSensor; // No chance that other cluster of this sensor will match (all Y's will be even larger) |
557 | else return kClusterNotMatching; // Other clusters may match | |
558 | } | |
c8d1f258 | 559 | double dz2 = dz*dz; |
f8832015 | 560 | tol2 = (track->GetSigmaZ2() + AliITSUReconstructor::GetRecoParam()->GetSigmaZ2(lr))* |
561 | AliITSUReconstructor::GetRecoParam()->GetNSigmaRoadZ()*AliITSUReconstructor::GetRecoParam()->GetNSigmaRoadZ(); // RS TOOPTIMIZE | |
c8d1f258 | 562 | if (dz2>tol2) { |
3dd9c283 | 563 | if (goodCl) {printf("Loose good cl: dz2=%e > tol2=%e |",dz2,tol2); cl->Print();} |
c8d1f258 | 564 | return kClusterNotMatching; // Other clusters may match |
565 | } | |
f8832015 | 566 | // |
567 | // check chi2 | |
568 | Double_t p[2]={cl->GetY(), cl->GetZ()}; | |
569 | Double_t cov[3]={cl->GetSigmaY2(), cl->GetSigmaYZ(), cl->GetSigmaZ2()}; | |
570 | double chi2 = track->GetPredictedChi2(p,cov); | |
c8d1f258 | 571 | if (chi2>AliITSUReconstructor::GetRecoParam()->GetMaxTr2ClChi2(lr)) { |
3dd9c283 | 572 | if (goodCl) { |
716ccba7 | 573 | printf("Loose good cl: Chi2=%e > Chi2Max=%e |dy: %+.3e dz: %+.3e\n", |
574 | chi2,AliITSUReconstructor::GetRecoParam()->GetMaxTr2ClChi2(lr),dy,dz); | |
3dd9c283 | 575 | track->Print("etp"); |
576 | cl->Print(""); | |
577 | } | |
c8d1f258 | 578 | return kClusterNotMatching; |
579 | } | |
f8832015 | 580 | // |
581 | track = NewSeedFromPool(track); // input track will be reused, use its clone for updates | |
943e1898 | 582 | if (!track->Update()) { |
3dd9c283 | 583 | if (goodCl) {printf("Loose good cl: Failed update |"); cl->Print();} |
c8d1f258 | 584 | return kClusterNotMatching; |
585 | } | |
f8832015 | 586 | track->SetChi2Cl(chi2); |
587 | track->SetLrClusterID(lr,clID); | |
588 | cl->IncreaseClusterUsage(); | |
589 | // | |
716ccba7 | 590 | track->SetFake(!goodCl); |
591 | // | |
592 | AliInfo(Form("AddCl(%d) Cl%d lr:%d: dY:%+8.4f dZ:%+8.4f (MC: %5d %5d %5d) |Chi2=%f(%c)", | |
593 | goodCl,clID,lr,dy,dz2,cl->GetLabel(0),cl->GetLabel(1),cl->GetLabel(2), chi2, track->IsFake() ? '-':'+')); | |
c8d1f258 | 594 | // |
f8832015 | 595 | AddProlongationHypothesis(track,lr); |
596 | // | |
597 | return kClusterMatching; | |
598 | } | |
c8d1f258 | 599 | |
600 | //_________________________________________________________________________ | |
601 | Bool_t AliITSUTrackerGlo::NeedToKill(AliITSUSeed *seed, Int_t flag) | |
602 | { | |
603 | // check if the seed should not be discarded | |
604 | const UShort_t kMask = 0xffff; | |
605 | if (flag==kMissingCluster) { | |
606 | int lastChecked = seed->GetLayerID(); | |
607 | UShort_t patt = seed->GetHitsPattern(); | |
608 | if (lastChecked) patt |= ~(kMask<<lastChecked); // not all layers were checked, complete unchecked once by potential hits | |
609 | Bool_t seedOK = fTrCond.CheckPattern(patt); | |
610 | return !seedOK; | |
611 | } | |
612 | return kTRUE; | |
613 | } | |
44785f3e | 614 | |
615 | //______________________________________________________________________________ | |
616 | Bool_t AliITSUTrackerGlo::PropagateSeed(AliITSUSeed *seed, Double_t xToGo, Double_t mass, Double_t maxStep, Bool_t matCorr) | |
617 | { | |
618 | // propagate seed to given x applying material correction if requested | |
619 | const Double_t kEpsilon = 1e-5; | |
620 | Double_t xpos = seed->GetX(); | |
621 | Int_t dir = (xpos<xToGo) ? 1:-1; | |
622 | Double_t xyz0[3],xyz1[3],param[7]; | |
623 | // | |
8b16dbae | 624 | Bool_t updTime = dir>0 && seed->IsStartedTimeIntegral(); |
44785f3e | 625 | if (matCorr) seed->GetXYZ(xyz1); //starting global position |
626 | while ( (xToGo-xpos)*dir > kEpsilon){ | |
627 | Double_t step = dir*TMath::Min(TMath::Abs(xToGo-xpos), maxStep); | |
628 | Double_t x = xpos+step; | |
629 | Double_t bz=GetBz(); // getting the local Bz | |
630 | if (!seed->PropagateToX(x,bz)) return kFALSE; | |
8b16dbae | 631 | double ds = 0; |
632 | if (matCorr || updTime) { | |
44785f3e | 633 | xyz0[0]=xyz1[0]; // global pos at the beginning of step |
634 | xyz0[1]=xyz1[1]; | |
635 | xyz0[2]=xyz1[2]; | |
636 | seed->GetXYZ(xyz1); // // global pos at the end of step | |
8b16dbae | 637 | if (matCorr) { |
638 | MeanMaterialBudget(xyz0,xyz1,param); | |
639 | Double_t xrho=param[0]*param[4], xx0=param[1]; | |
640 | if (dir>0) xrho = -xrho; // outward should be negative | |
641 | if (!seed->ApplyMaterialCorrection(xx0,xrho,mass,kFALSE)) return kFALSE; | |
642 | ds = param[4]; | |
643 | } | |
644 | else { // matCorr is not requested but time integral is | |
645 | double d0 = xyz1[0]-xyz0[0]; | |
646 | double d1 = xyz1[1]-xyz0[1]; | |
647 | double d2 = xyz1[2]-xyz0[2]; | |
648 | ds = TMath::Sqrt(d0*d0+d1*d1+d2*d2); | |
649 | } | |
44785f3e | 650 | } |
8b16dbae | 651 | if (updTime) seed->AddTimeStep(ds); |
44785f3e | 652 | xpos = seed->GetX(); |
653 | } | |
654 | return kTRUE; | |
655 | } | |
716ccba7 | 656 | |
3e4e3c23 | 657 | //______________________________________________________________________________ |
658 | Bool_t AliITSUTrackerGlo::PropagateSeed(AliExternalTrackParam *seed, Double_t xToGo, Double_t mass, Double_t maxStep, Bool_t matCorr) | |
659 | { | |
660 | // propagate seed to given x applying material correction if requested | |
661 | const Double_t kEpsilon = 1e-5; | |
662 | Double_t xpos = seed->GetX(); | |
663 | Int_t dir = (xpos<xToGo) ? 1:-1; | |
664 | Double_t xyz0[3],xyz1[3],param[7]; | |
665 | // | |
666 | Bool_t updTime = dir>0 && seed->IsStartedTimeIntegral(); | |
667 | if (matCorr || updTime) seed->GetXYZ(xyz1); //starting global position | |
668 | while ( (xToGo-xpos)*dir > kEpsilon){ | |
669 | Double_t step = dir*TMath::Min(TMath::Abs(xToGo-xpos), maxStep); | |
670 | Double_t x = xpos+step; | |
671 | Double_t bz=GetBz(); // getting the local Bz | |
672 | if (!seed->PropagateTo(x,bz)) return kFALSE; | |
673 | double ds = 0; | |
674 | if (matCorr || updTime) { | |
675 | xyz0[0]=xyz1[0]; // global pos at the beginning of step | |
676 | xyz0[1]=xyz1[1]; | |
677 | xyz0[2]=xyz1[2]; | |
678 | seed->GetXYZ(xyz1); // // global pos at the end of step | |
679 | // | |
680 | if (matCorr) { | |
681 | MeanMaterialBudget(xyz0,xyz1,param); | |
682 | Double_t xrho=param[0]*param[4], xx0=param[1]; | |
683 | if (dir>0) xrho = -xrho; // outward should be negative | |
684 | if (!seed->CorrectForMeanMaterial(xx0,xrho,mass)) return kFALSE; | |
685 | ds = param[4]; | |
686 | } | |
687 | else { // matCorr is not requested but time integral is | |
688 | double d0 = xyz1[0]-xyz0[0]; | |
689 | double d1 = xyz1[1]-xyz0[1]; | |
690 | double d2 = xyz1[2]-xyz0[2]; | |
691 | ds = TMath::Sqrt(d0*d0+d1*d1+d2*d2); | |
692 | } | |
693 | } | |
694 | if (updTime) seed->AddTimeStep(ds); | |
695 | // | |
696 | xpos = seed->GetX(); | |
697 | } | |
698 | return kTRUE; | |
699 | } | |
700 | ||
716ccba7 | 701 | //______________________________________________________________________________ |
702 | void AliITSUTrackerGlo::SaveCurrentTrackHypotheses() | |
703 | { | |
704 | // RS: shall we clean up killed seeds? | |
705 | fCurrHyp = 0; | |
706 | // TODO | |
707 | ||
708 | } | |
3e4e3c23 | 709 | |
710 | //______________________________________________________________________________ | |
711 | void AliITSUTrackerGlo::FinalizeHypotheses() | |
712 | { | |
713 | // select winner for each hypothesis, remove cl. sharing conflicts | |
714 | AliInfo("TODO"); | |
715 | // | |
716 | int nh = fHypStore.GetEntriesFast(); | |
717 | for (int ih=0;ih<nh;ih++) { | |
718 | AliITSUTrackHyp* hyp = (AliITSUTrackHyp*) fHypStore.UncheckedAt(ih); | |
719 | if (!hyp) continue; | |
c51c3124 | 720 | hyp->DefineWinner(); // TODO |
721 | UpdateESDTrack(hyp); | |
3e4e3c23 | 722 | } |
723 | ||
724 | } | |
c51c3124 | 725 | |
726 | //______________________________________________________________________________ | |
727 | void AliITSUTrackerGlo::UpdateESDTrack(AliITSUTrackHyp* hyp) | |
728 | { | |
729 | // update ESD track with current best hypothesis | |
730 | AliESDtrack* esdTr = hyp->GetESDTrack(); | |
731 | if (!esdTr) return; | |
732 | AliITSUSeed* win = hyp->GetWinner(); | |
733 | if (!win) return; | |
734 | esdTr->UpdateTrackParams(hyp,AliESDtrack::kITSin); | |
735 | // | |
736 | // transfer module indices | |
737 | // TODO | |
738 | } | |
739 | ||
740 | //______________________________________________________________________________ | |
741 | Bool_t AliITSUTrackerGlo::RefitTrack(AliITSUTrackHyp* trc, Double_t rDest) | |
742 | { | |
743 | // refit track till radius rDest | |
8b16dbae | 744 | AliITSUTrackHyp tmpTr; |
745 | // | |
c51c3124 | 746 | double rCurr = Sqrt(trc->GetX()*trc->GetX() + trc->GetY()*trc->GetY()); |
747 | int dir,lrStart,lrStop; | |
748 | // | |
8b16dbae | 749 | dir = rCurr<rDest ? 1 : -1; |
750 | lrStart = fITS->FindFirstLayerID(rCurr,dir); | |
751 | lrStop = fITS->FindLastLayerID(rDest,dir); | |
752 | if (lrStop<0 || lrStart<0) AliFatal(Form("Failed to find start(%d) or last(%d) layers. Track from %.3f to %.3f",lrStart,lrStop,rCurr,rDest)); | |
753 | // | |
754 | trc->FetchClusterInfo(fClInfo); | |
755 | fCurrMass = trc->GetMass(); | |
756 | tmpTr.AliKalmanTrack::operator=(*trc); | |
757 | tmpTr.SetChi2(0); | |
758 | int iclLr[2],nclLr; | |
c51c3124 | 759 | // |
760 | for (int ilr=lrStart;ilr!=lrStop;ilr+=dir) { | |
761 | AliITSURecoLayer* lr = fITS->GetLayer(ilr); | |
762 | if ( dir*(rCurr-lr->GetR(dir))>0) continue; // this layer is already passed | |
8b16dbae | 763 | int ilrA2,ilrA = lr->GetActiveID(); |
764 | // passive layer or active w/o hits will be traversed on the way to next cluster | |
765 | if (!lr->IsActive() || fClInfo[ilrA2=(ilrA<<1)]<0) continue; | |
766 | // | |
767 | if (!TransportToLayer(&tmpTr,lrStart,ilr)) return kFALSE; | |
768 | lrStart = ilr; | |
769 | // | |
770 | // select the order in which possible 2 clusters (in case of the overlap) will be traversed and fitted | |
771 | nclLr=0; | |
772 | if (dir>0) { // clusters are stored in increasing radius order | |
773 | iclLr[nclLr++]=fClInfo[ilrA2++]; | |
774 | if (fClInfo[ilrA2]>=0) iclLr[nclLr++]=fClInfo[ilrA2]; | |
775 | } | |
776 | else { | |
777 | if ( fClInfo[ilrA2+1]>=0 ) iclLr[nclLr++]=fClInfo[ilrA2+1]; | |
778 | iclLr[nclLr++]=fClInfo[ilrA2]; | |
779 | } | |
780 | // | |
781 | for (int icl=0;icl<nclLr;icl++) { | |
782 | AliITSUClusterPix* clus = (AliITSUClusterPix*)lr->GetCluster(iclLr[icl]); | |
783 | AliITSURecoSens* sens = lr->GetSensorFromID(clus->GetVolumeId()); | |
784 | if (!tmpTr.Rotate(sens->GetPhiTF())) return kFALSE; | |
785 | if (!PropagateSeed(&tmpTr,sens->GetXTF()+clus->GetX(),fCurrMass)) return kFALSE; | |
786 | if (!tmpTr.Update(clus)) return kFALSE; | |
787 | } | |
c51c3124 | 788 | // |
789 | } | |
8b16dbae | 790 | // All clusters were succesfully fitted. Even if the track does not reach rDest, this is enough to validate it. |
791 | // Still, try to go as close as possible to rDest. | |
792 | // | |
793 | if (lrStart!=lrStop) { | |
794 | if (!TransportToLayer(&tmpTr,lrStart,lrStop)) return kTRUE; | |
795 | // go to the exit from layer | |
796 | // TODO | |
797 | } | |
798 | trc->AliKalmanTrack::operator=(tmpTr); | |
799 | return kTRUE; | |
c51c3124 | 800 | } |