]>
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 | ||
e2d2481c | 43 | |
c8d1f258 | 44 | //----------------- tmp stuff ----------------- |
c8d1f258 | 45 | |
32d38de2 | 46 | ClassImp(AliITSUTrackerGlo) |
e2d2481c | 47 | |
48 | const Double_t AliITSUTrackerGlo::fgkToler = 1e-6;// tolerance for layer on-surface check | |
49 | ||
50 | ||
32d38de2 | 51 | //_________________________________________________________________________ |
52 | AliITSUTrackerGlo::AliITSUTrackerGlo(AliITSUReconstructor* rec) | |
53 | : fReconstructor(rec) | |
54 | ,fITS(0) | |
0091e9f0 | 55 | ,fCurrESDtrack(0) |
32d38de2 | 56 | ,fCurrMass(kPionMass) |
716ccba7 | 57 | ,fHypStore(100) |
58 | ,fCurrHyp(0) | |
c61e50c3 | 59 | ,fSeedsPool("AliITSUSeed",0) |
b8b59e05 | 60 | ,fFreeSeedsID(0) |
61 | ,fNFreeSeeds(0) | |
62 | ,fLastSeedID(0) | |
c8d1f258 | 63 | ,fTrCond() |
c51c3124 | 64 | ,fTrackPhase(-1) |
8b16dbae | 65 | ,fClInfo(0) |
32d38de2 | 66 | { |
67 | // Default constructor | |
68 | if (rec) Init(rec); | |
69 | } | |
70 | ||
71 | //_________________________________________________________________________ | |
72 | AliITSUTrackerGlo::~AliITSUTrackerGlo() | |
73 | { | |
74 | // Default destructor | |
75 | // | |
76 | delete fITS; | |
8b16dbae | 77 | delete[] fClInfo; |
32d38de2 | 78 | // |
79 | } | |
80 | ||
81 | //_________________________________________________________________________ | |
82 | void AliITSUTrackerGlo::Init(AliITSUReconstructor* rec) | |
83 | { | |
84 | // init with external reconstructor | |
c61e50c3 | 85 | // |
32d38de2 | 86 | fITS = new AliITSURecoDet(rec->GetGeom(),"ITSURecoInterface"); |
8b16dbae | 87 | int nLr = fITS->GetNLayersActive(); |
88 | fClInfo = new Int_t[nLr<<1]; | |
89 | for (int ilr=nLr;ilr--;) { | |
32d38de2 | 90 | fITS->GetLayerActive(ilr)->SetClusters(rec->GetClusters(ilr)); |
91 | } | |
c61e50c3 | 92 | // |
93 | fSeedsPool.ExpandCreateFast(1000); // RS TOCHECK | |
b8b59e05 | 94 | fFreeSeedsID.Set(1000); |
c61e50c3 | 95 | // |
c8d1f258 | 96 | fTrCond.SetNLayers(fITS->GetNLayersActive()); |
97 | fTrCond.AddNewCondition(5); | |
98 | fTrCond.AddGroupPattern( (0x1<<0)|(0x1<<1) ); | |
99 | fTrCond.AddGroupPattern( (0x1<<3)|(0x1<<4) ); | |
100 | fTrCond.AddGroupPattern( (0x1<<5)|(0x1<<6) ); | |
101 | // | |
102 | fTrCond.AddNewCondition(5); | |
103 | fTrCond.AddGroupPattern( (0x1<<0)|(0x1<<2) ); | |
104 | fTrCond.AddGroupPattern( (0x1<<3)|(0x1<<4) ); | |
105 | fTrCond.AddGroupPattern( (0x1<<5)|(0x1<<6) ); | |
106 | // | |
107 | fTrCond.AddNewCondition(5); | |
108 | fTrCond.AddGroupPattern( (0x1<<1)|(0x1<<2) ); | |
109 | fTrCond.AddGroupPattern( (0x1<<3)|(0x1<<4) ); | |
110 | fTrCond.AddGroupPattern( (0x1<<5)|(0x1<<6) ); | |
111 | // | |
112 | printf("Tracking Conditions: "); | |
113 | fTrCond.Print(); | |
32d38de2 | 114 | } |
115 | ||
116 | //_________________________________________________________________________ | |
117 | Int_t AliITSUTrackerGlo::Clusters2Tracks(AliESDEvent *esdEv) | |
118 | { | |
119 | // | |
120 | // | |
e7d83d38 | 121 | SetTrackingPhase(kClus2Tracks); |
b8b59e05 | 122 | ResetSeedsPool(); |
716ccba7 | 123 | int nTrESD = esdEv->GetNumberOfTracks(); |
c51c3124 | 124 | AliInfo(Form("Will try to find prolongations for %d tracks",nTrESD)); |
125 | AliITSUReconstructor::GetRecoParam()->Print(); | |
716ccba7 | 126 | fHypStore.Delete(); |
127 | if (fHypStore.GetSize()<nTrESD) fHypStore.Expand(nTrESD+100); | |
128 | // | |
32d38de2 | 129 | fITS->ProcessClusters(); |
130 | // select ESD tracks to propagate | |
32d38de2 | 131 | for (int itr=0;itr<nTrESD;itr++) { |
132 | AliESDtrack *esdTr = esdEv->GetTrack(itr); | |
0091e9f0 | 133 | AliInfo(Form("Processing track %d | MCLabel: %d",itr,esdTr->GetTPCLabel())); |
c51c3124 | 134 | if (!NeedToProlong(esdTr)) continue; // are we interested in this track? |
716ccba7 | 135 | FindTrack(esdTr, itr); |
32d38de2 | 136 | } |
716ccba7 | 137 | // |
b8b59e05 | 138 | AliInfo(Form("SeedsPool: %d, BookedUpTo: %d, free: %d",fSeedsPool.GetSize(),fSeedsPool.GetEntriesFast(),fNFreeSeeds)); |
716ccba7 | 139 | fHypStore.Print(); |
3e4e3c23 | 140 | FinalizeHypotheses(); |
716ccba7 | 141 | // |
32d38de2 | 142 | return 0; |
143 | } | |
144 | ||
145 | //_________________________________________________________________________ | |
c51c3124 | 146 | Int_t AliITSUTrackerGlo::PropagateBack(AliESDEvent *esdEv) |
32d38de2 | 147 | { |
148 | // | |
c51c3124 | 149 | // Do outward fits in ITS |
150 | // | |
e7d83d38 | 151 | SetTrackingPhase(kPropBack); |
c51c3124 | 152 | int nTrESD = esdEv->GetNumberOfTracks(); |
e7d83d38 | 153 | AliInfo(Form("Will propagate back %d tracks",nTrESD)); |
c51c3124 | 154 | // |
155 | double bz0 = GetBz(); | |
156 | Double_t xyzTrk[3],xyzVtx[3]={GetX(),GetY(),GetZ()}; | |
157 | AliITSUTrackHyp dummyTr,*currTr=0; | |
158 | const double kWatchStep=10.; // for larger steps watch arc vs segment difference | |
159 | Double_t times[AliPID::kSPECIES]; | |
160 | // | |
161 | // | |
162 | for (int itr=0;itr<nTrESD;itr++) { | |
163 | AliESDtrack *esdTr = esdEv->GetTrack(itr); | |
164 | // Start time integral and add distance from current position to vertex | |
165 | if (esdTr->IsOn(AliESDtrack::kITSout)) continue; // already done | |
166 | // | |
167 | esdTr->GetXYZ(xyzTrk); | |
168 | Double_t dst = 0.; // set initial track lenght, tof | |
169 | { | |
170 | double dxs = xyzTrk[0] - xyzVtx[0]; | |
171 | double dys = xyzTrk[1] - xyzVtx[1]; | |
172 | double dzs = xyzTrk[2] - xyzVtx[2]; | |
173 | // RS: for large segment steps d use approximation of cicrular arc s by | |
174 | // s = 2R*asin(d/2R) = d/p asin(p) \approx d/p (p + 1/6 p^3) = d (1+1/6 p^2) | |
175 | // where R is the track radius, p = d/2R = 2C*d (C is the abs curvature) | |
176 | // Hence s^2/d^2 = (1+1/6 p^2)^2 | |
177 | dst = dxs*dxs + dys*dys; | |
178 | if (dst > kWatchStep*kWatchStep) { // correct circular part for arc/segment factor | |
179 | double crv = Abs(esdTr->GetC(bz0)); | |
180 | double fcarc = 1.+crv*crv*dst/6.; | |
181 | dst *= fcarc*fcarc; | |
182 | } | |
183 | dst += dzs*dzs; | |
184 | dst = Sqrt(dst); | |
185 | } | |
186 | // | |
187 | esdTr->SetStatus(AliESDtrack::kTIME); | |
188 | // | |
189 | if (!esdTr->IsOn(AliESDtrack::kITSin)) { // case of tracks w/o ITS prolongation: just set the time integration | |
e2d2481c | 190 | dummyTr.AliExternalTrackParam::operator=(*esdTr); |
c51c3124 | 191 | dummyTr.StartTimeIntegral(); |
e2d2481c | 192 | dummyTr.AddTimeStep(dst); |
c51c3124 | 193 | dummyTr.GetIntegratedTimes(times); |
194 | esdTr->SetIntegratedTimes(times); | |
195 | esdTr->SetIntegratedLength(dummyTr.GetIntegratedLength()); | |
196 | continue; | |
197 | } | |
198 | // | |
199 | currTr = GetTrackHyp(itr); | |
200 | currTr->StartTimeIntegral(); | |
201 | currTr->AddTimeStep(dst); | |
e2d2481c | 202 | printf("Before resetCov: "); currTr->AliExternalTrackParam::Print(); |
203 | currTr->ResetCovariance(10000); | |
68a0f687 | 204 | if (RefitTrack(currTr,fITS->GetRMax())) { // propagate to exit from the ITS/TPC screen |
205 | UpdateESDTrack(currTr,AliESDtrack::kITSout); | |
206 | } | |
e7d83d38 | 207 | else { |
208 | AliInfo(Form("Refit Failed for track %d",itr)); | |
209 | } | |
c51c3124 | 210 | // |
211 | } | |
32d38de2 | 212 | // |
32d38de2 | 213 | return 0; |
214 | } | |
215 | ||
216 | //_________________________________________________________________________ | |
e7d83d38 | 217 | Int_t AliITSUTrackerGlo::RefitInward(AliESDEvent *esdEv) |
32d38de2 | 218 | { |
219 | // | |
e7d83d38 | 220 | // refit the tracks inward, using current cov.matrix |
221 | // | |
222 | SetTrackingPhase(kRefitInw); | |
223 | Int_t nTrESD = esdEv->GetNumberOfTracks(); | |
224 | AliInfo(Form("Will refit inward %d tracks",nTrESD)); | |
225 | AliITSUTrackHyp *currTr=0; | |
226 | // | |
227 | for (int itr=0;itr<nTrESD;itr++) { | |
228 | AliESDtrack *esdTr = esdEv->GetTrack(itr); | |
229 | // Start time integral and add distance from current position to vertex | |
230 | UInt_t trStat = esdTr->GetStatus(); | |
231 | if ( !(trStat & AliESDtrack::kITSout) ) continue; | |
232 | if ( trStat & AliESDtrack::kITSrefit ) continue; // already done | |
233 | if ( (trStat & AliESDtrack::kTPCout) && !(trStat & AliESDtrack::kTPCrefit) ) continue; | |
234 | // | |
235 | currTr = GetTrackHyp(itr); | |
236 | currTr->AliExternalTrackParam::operator=(*esdTr); // fetch current ESDtrack kinematics | |
237 | if (RefitTrack(currTr,fITS->GetRMin())) { // propagate up to inside radius of the beam pipe | |
238 | UpdateESDTrack(currTr,AliESDtrack::kITSrefit); | |
239 | } | |
240 | else { | |
241 | AliInfo(Form("Refit Failed for track %d",itr)); | |
242 | } | |
243 | } | |
32d38de2 | 244 | // |
32d38de2 | 245 | return 0; |
246 | } | |
247 | ||
248 | //_________________________________________________________________________ | |
249 | Int_t AliITSUTrackerGlo::LoadClusters(TTree * treeRP) | |
250 | { | |
251 | // read from tree (if pointer provided) or directly from the ITS reco interface | |
252 | // | |
253 | return fReconstructor->LoadClusters(treeRP); | |
254 | } | |
255 | ||
256 | //_________________________________________________________________________ | |
257 | void AliITSUTrackerGlo::UnloadClusters() | |
258 | { | |
259 | // | |
260 | // To be implemented | |
261 | // | |
262 | ||
263 | Info("UnloadClusters","To be implemented"); | |
264 | } | |
265 | //_________________________________________________________________________ | |
266 | AliCluster * AliITSUTrackerGlo::GetCluster(Int_t /*index*/) const | |
267 | { | |
268 | // | |
269 | // To be implemented | |
270 | // | |
271 | ||
272 | Info("GetCluster","To be implemented"); | |
273 | return 0x0; | |
274 | } | |
275 | ||
276 | //_________________________________________________________________________ | |
277 | Bool_t AliITSUTrackerGlo::NeedToProlong(AliESDtrack* esdTr) | |
278 | { | |
279 | // do we need to match this track to ITS? | |
280 | // | |
281 | static double bz = GetBz(); | |
282 | if (!esdTr->IsOn(AliESDtrack::kTPCin) || | |
283 | esdTr->IsOn(AliESDtrack::kTPCout) || | |
284 | esdTr->IsOn(AliESDtrack::kITSin) || | |
285 | esdTr->GetKinkIndex(0)>0) return kFALSE; | |
286 | // | |
c61e50c3 | 287 | if (esdTr->Pt()<AliITSUReconstructor::GetRecoParam()->GetMinPtForProlongation()) return kFALSE; |
32d38de2 | 288 | // |
289 | float dtz[2]; | |
290 | esdTr->GetDZ(GetX(),GetY(),GetZ(),bz,dtz); | |
291 | // if track is not V0 candidata but has large offset wrt IP, reject it. RS TOCHECK | |
c61e50c3 | 292 | if ( !(esdTr->GetV0Index(0)>0 && dtz[0]>AliITSUReconstructor::GetRecoParam()->GetMaxDforV0dghtrForProlongation()) |
293 | && (Abs(dtz[0])>AliITSUReconstructor::GetRecoParam()->GetMaxDForProlongation() || | |
294 | Abs(dtz[1])>AliITSUReconstructor::GetRecoParam()->GetMaxDZForProlongation())) return kFALSE; | |
32d38de2 | 295 | // |
296 | return kTRUE; | |
297 | } | |
298 | ||
299 | //_________________________________________________________________________ | |
716ccba7 | 300 | void AliITSUTrackerGlo::FindTrack(AliESDtrack* esdTr, Int_t esdID) |
32d38de2 | 301 | { |
302 | // find prolongaion candidates finding for single seed | |
303 | // | |
3e4e3c23 | 304 | AliITSUSeed seedUC; // copy of the seed from the upper layer |
305 | AliITSUSeed seedT; // transient seed between the seedUC and new prolongation hypothesis | |
306 | // | |
3e4e3c23 | 307 | if (!InitHypothesis(esdTr,esdID)) return; // initialize prolongations hypotheses tree |
32d38de2 | 308 | // |
173b3073 | 309 | AliITSURecoSens *hitSens[AliITSURecoSens::kNNeighbors+1]; |
f8832015 | 310 | // |
c61e50c3 | 311 | TObjArray clArr; // container for transfer of clusters matching to seed |
32d38de2 | 312 | // |
3e4e3c23 | 313 | int nLrActive = fITS->GetNLayersActive(); |
314 | for (int ila=nLrActive;ila--;) { | |
32d38de2 | 315 | int ilaUp = ila+1; // prolong seeds from layer above |
3e4e3c23 | 316 | // |
317 | // for the outermost layer the seed is created from the ESD track | |
318 | int nSeedsUp = (ilaUp==nLrActive) ? 1 : fCurrHyp->GetNSeeds(ilaUp); | |
319 | // | |
32d38de2 | 320 | for (int isd=0;isd<nSeedsUp;isd++) { |
3e4e3c23 | 321 | AliITSUSeed* seedU; |
322 | if (ilaUp==nLrActive) { | |
323 | seedU = 0; | |
324 | seedUC.InitFromESDTrack(esdTr); | |
325 | } | |
326 | else { | |
327 | seedU = fCurrHyp->GetSeed(ilaUp,isd); // seed on prev.active layer to prolong | |
328 | seedUC = *seedU; // its copy will be prolonged | |
b8b59e05 | 329 | seedUC.SetParent(seedU); |
3e4e3c23 | 330 | } |
943e1898 | 331 | seedUC.ResetFMatrix(); // reset the matrix for propagation to next layer |
32d38de2 | 332 | // go till next active layer |
c8d1f258 | 333 | AliInfo(Form("working on Lr:%d Seed:%d of %d",ila,isd,nSeedsUp)); |
f8832015 | 334 | if (!TransportToLayer(&seedUC, fITS->GetLrIDActive(ilaUp), fITS->GetLrIDActive(ila)) ) { |
32d38de2 | 335 | // |
0091e9f0 | 336 | AliInfo("Transport failed"); |
32d38de2 | 337 | // Check if the seed satisfies to track definition |
b8b59e05 | 338 | if (NeedToKill(&seedUC,kTransportFailed) && seedU) KillSeed(seedU,kTRUE); |
32d38de2 | 339 | continue; // RS TODO: decide what to do with tracks stopped on higher layers w/o killing |
340 | } | |
341 | AliITSURecoLayer* lrA = fITS->GetLayerActive(ila); | |
f8832015 | 342 | if (!GetRoadWidth(&seedUC, ila)) { // failed to find road width on the layer |
b8b59e05 | 343 | if (NeedToKill(&seedUC,kRWCheckFailed) && seedU) KillSeed(seedU,kTRUE); |
32d38de2 | 344 | continue; |
345 | } | |
173b3073 | 346 | int nsens = lrA->FindSensors(&fTrImpData[kTrPhi0], hitSens); // find detectors which may be hit by the track |
0091e9f0 | 347 | AliInfo(Form("Will check %d sensors on lr:%d ",nsens,ila)); |
32d38de2 | 348 | // |
943e1898 | 349 | double bz = GetBz(); |
32d38de2 | 350 | for (int isn=nsens;isn--;) { |
f8832015 | 351 | seedT = seedUC; |
c61e50c3 | 352 | AliITSURecoSens* sens = hitSens[isn]; |
f8832015 | 353 | // |
943e1898 | 354 | // We need to propagate the seed to sensor on lrA staying the frame of the sensor from prev.layer, |
355 | // since the transport matrix should be defined in this frame. | |
356 | double xs; // X in the TF of current seed, corresponding to intersection with sensor plane | |
357 | if (!seedT.GetTrackingXAtXAlpha(sens->GetXTF(),sens->GetPhiTF(),bz, xs)) continue; | |
8b16dbae | 358 | if (!PropagateSeed(&seedT,xs,fCurrMass)) continue; |
359 | // if (!seedT.PropagateToX(xs,bz)) continue; | |
716ccba7 | 360 | // if (!seedT.Rotate(sens->GetPhiTF())) continue; |
361 | if (!seedT.RotateToAlpha(sens->GetPhiTF())) continue; | |
943e1898 | 362 | // |
f8832015 | 363 | int clID0 = sens->GetFirstClusterId(); |
c61e50c3 | 364 | for (int icl=sens->GetNClusters();icl--;) { |
f8832015 | 365 | int res = CheckCluster(&seedT,ila,clID0+icl); |
366 | // | |
367 | if (res==kStopSearchOnSensor) break; // stop looking on this sensor | |
368 | if (res==kClusterNotMatching) continue; // cluster does not match | |
369 | // cluster is matching and it was added to the hypotheses tree | |
c61e50c3 | 370 | } |
32d38de2 | 371 | } |
f8832015 | 372 | // cluster search is done. Do we need ta have a version of this seed skipping current layer |
373 | seedT.SetLr(ila); | |
716ccba7 | 374 | if (!NeedToKill(&seedT,kMissingCluster)) { |
375 | AliITSUSeed* seedSkp = NewSeedFromPool(&seedT); | |
376 | double penalty = -AliITSUReconstructor::GetRecoParam()->GetMissPenalty(ila); | |
377 | // to do: make penalty to account for probability to miss the cluster for good reason | |
378 | seedSkp->SetChi2Cl(penalty); | |
379 | AddProlongationHypothesis(seedSkp,ila); | |
380 | } | |
32d38de2 | 381 | } |
716ccba7 | 382 | ((TObjArray*)fCurrHyp->GetLayerSeeds(ila))->Sort(); |
c8d1f258 | 383 | printf(">>> All hypotheses on lr %d: \n",ila); |
716ccba7 | 384 | for (int ih=0;ih<fCurrHyp->GetNSeeds(ila);ih++) { |
385 | printf(" #%3d ",ih); fCurrHyp->GetSeed(ila,ih)->Print(); | |
386 | // | |
387 | /* | |
388 | if (ila!=0) continue; | |
389 | double vecL[5] = {0}; | |
390 | double matL[15] = {0}; | |
391 | AliITSUSeed* sp = fCurrHyp->GetSeed(ila,ih); | |
392 | while(sp->GetParent()) { | |
393 | sp->Smooth(vecL,matL); | |
394 | if (sp->GetLayerID()>=fITS->GetNLayersActive()-1) break; | |
395 | sp = (AliITSUSeed*)sp->GetParent(); | |
396 | } | |
397 | */ | |
c8d1f258 | 398 | } |
32d38de2 | 399 | } |
400 | // | |
716ccba7 | 401 | SaveCurrentTrackHypotheses(); |
402 | // | |
32d38de2 | 403 | } |
404 | ||
405 | //_________________________________________________________________________ | |
3e4e3c23 | 406 | Bool_t AliITSUTrackerGlo::InitHypothesis(AliESDtrack *esdTr, Int_t esdID) |
32d38de2 | 407 | { |
c61e50c3 | 408 | // init prolongaion candidates finding for single seed |
716ccba7 | 409 | fCurrHyp = GetTrackHyp(esdID); |
410 | if (fCurrHyp) return kTRUE; | |
411 | // | |
32d38de2 | 412 | fCurrMass = esdTr->GetMass(); |
0091e9f0 | 413 | fCurrESDtrack = esdTr; |
32d38de2 | 414 | if (fCurrMass<kPionMass*0.9) fCurrMass = kPionMass; // don't trust to mu, e identification from TPCin |
c61e50c3 | 415 | // |
3e4e3c23 | 416 | fCurrHyp = new AliITSUTrackHyp(fITS->GetNLayersActive()); |
417 | fCurrHyp->SetESDTrack(esdTr); | |
716ccba7 | 418 | fCurrHyp->SetUniqueID(esdID); |
c51c3124 | 419 | fCurrHyp->SetMass(fCurrMass); |
716ccba7 | 420 | SetTrackHyp(fCurrHyp,esdID); |
3e4e3c23 | 421 | // |
32d38de2 | 422 | return kTRUE; |
423 | // TO DO | |
424 | } | |
425 | ||
426 | //_________________________________________________________________________ | |
427 | Bool_t AliITSUTrackerGlo::TransportToLayer(AliITSUSeed* seed, Int_t lFrom, Int_t lTo) | |
428 | { | |
429 | // transport seed from layerFrom to the entrance of layerTo | |
430 | // | |
8b16dbae | 431 | // |
432 | if (lTo==lFrom) AliFatal(Form("was called with lFrom=%d lTo=%d",lFrom,lTo)); | |
433 | // | |
32d38de2 | 434 | int dir = lTo > lFrom ? 1:-1; |
435 | AliITSURecoLayer* lrFr = fITS->GetLayer(lFrom); // this can be 0 when extrapolation from TPC to ITS is requested | |
436 | Bool_t checkFirst = kTRUE; | |
437 | while(lFrom!=lTo) { | |
32d38de2 | 438 | if (lrFr) { |
e2d2481c | 439 | if (!GoToExitFromLayer(seed,lrFr,dir,checkFirst)) return kFALSE; // go till the end of current layer |
440 | checkFirst = kFALSE; | |
32d38de2 | 441 | } |
442 | AliITSURecoLayer* lrTo = fITS->GetLayer( (lFrom+=dir) ); | |
443 | if (!lrTo) AliFatal(Form("Layer %d does not exist",lFrom)); | |
444 | // | |
445 | // go the entrance of the layer, assuming no materials in between | |
8b16dbae | 446 | double xToGo = lrTo->GetR(-dir); |
dde91d5d | 447 | if (!seed->GetXatLabR(xToGo,xToGo,GetBz(),dir)) return kFALSE; |
44785f3e | 448 | if (!PropagateSeed(seed,xToGo,fCurrMass,100, kFALSE )) return kFALSE; |
32d38de2 | 449 | lrFr = lrTo; |
450 | } | |
451 | return kTRUE; | |
452 | // | |
453 | } | |
454 | ||
3e4e3c23 | 455 | //_________________________________________________________________________ |
456 | Bool_t AliITSUTrackerGlo::TransportToLayer(AliExternalTrackParam* seed, Int_t lFrom, Int_t lTo) | |
457 | { | |
458 | // transport track from layerFrom to the entrance of layerTo | |
459 | // | |
8b16dbae | 460 | if (lTo==lFrom) AliFatal(Form("was called with lFrom=%d lTo=%d",lFrom,lTo)); |
461 | // | |
3e4e3c23 | 462 | int dir = lTo > lFrom ? 1:-1; |
463 | AliITSURecoLayer* lrFr = fITS->GetLayer(lFrom); // this can be 0 when extrapolation from TPC to ITS is requested | |
464 | Bool_t checkFirst = kTRUE; | |
465 | while(lFrom!=lTo) { | |
3e4e3c23 | 466 | if (lrFr) { |
e2d2481c | 467 | if (!GoToExitFromLayer(seed,lrFr,dir,checkFirst)) return kFALSE; // go till the end of current layer |
468 | checkFirst = kFALSE; | |
3e4e3c23 | 469 | } |
470 | AliITSURecoLayer* lrTo = fITS->GetLayer( (lFrom+=dir) ); | |
471 | if (!lrTo) AliFatal(Form("Layer %d does not exist",lFrom)); | |
472 | // | |
e2d2481c | 473 | if (!GoToExitFromLayer(seed,lrTo,dir)) return kFALSE; // go the entrance of the layer, assuming no materials in between |
3e4e3c23 | 474 | lrFr = lrTo; |
475 | } | |
476 | return kTRUE; | |
477 | // | |
478 | } | |
479 | ||
e2d2481c | 480 | //_________________________________________________________________________ |
481 | Bool_t AliITSUTrackerGlo::GoToExitFromLayer(AliITSUSeed* seed, AliITSURecoLayer* lr, Int_t dir, Bool_t check) | |
482 | { | |
483 | // go to the exit from lr in direction dir, applying material corrections in steps specific for this layer | |
484 | // If check is requested, do this only provided the track has not exited the layer already | |
485 | double xToGo = lr->GetR(dir); | |
486 | if (check) { // do we need to track till the surface of the current layer ? | |
487 | double curR2 = seed->GetX()*seed->GetX() + seed->GetY()*seed->GetY(); // current radius | |
e7d83d38 | 488 | // AliInfo(Form(" dir:%d Cur: %e Tgt: %e",dir,Sqrt(curR2),xToGo)); |
e2d2481c | 489 | if (dir>0) { if (curR2-xToGo*xToGo>fgkToler) return kTRUE; } // on the surface or outside of the layer |
490 | else if (dir<0) { if (xToGo*xToGo-curR2>fgkToler) return kTRUE; } // on the surface or outside of the layer | |
491 | } | |
492 | if (!seed->GetXatLabR(xToGo,xToGo,GetBz(),dir)) return kFALSE; | |
493 | // go via layer to its boundary, applying material correction. | |
494 | if (!PropagateSeed(seed,xToGo,fCurrMass, lr->GetMaxStep())) return kFALSE; | |
e7d83d38 | 495 | // |
e2d2481c | 496 | return kTRUE; |
497 | // | |
498 | } | |
499 | ||
500 | //_________________________________________________________________________ | |
501 | Bool_t AliITSUTrackerGlo::GoToExitFromLayer(AliExternalTrackParam* seed, AliITSURecoLayer* lr, Int_t dir, Bool_t check) | |
502 | { | |
503 | // go to the exit from lr in direction dir, applying material corrections in steps specific for this layer | |
504 | // If check is requested, do this only provided the track has not exited the layer already | |
505 | double xToGo = lr->GetR(dir); | |
506 | if (check) { // do we need to track till the surface of the current layer ? | |
507 | double curR2 = seed->GetX()*seed->GetX() + seed->GetY()*seed->GetY(); // current radius | |
508 | if (dir>0) { if (curR2-xToGo*xToGo>fgkToler) return kTRUE; } // on the surface or outside of the layer | |
509 | else if (dir<0) { if (xToGo*xToGo-curR2>fgkToler) return kTRUE; } // on the surface or outside of the layer | |
510 | } | |
511 | if (!seed->GetXatLabR(xToGo,xToGo,GetBz(),dir)) return kFALSE; | |
512 | // go via layer to its boundary, applying material correction. | |
513 | if (!PropagateSeed(seed,xToGo,fCurrMass, lr->GetMaxStep())) return kFALSE; | |
e7d83d38 | 514 | // |
e2d2481c | 515 | return kTRUE; |
516 | // | |
517 | } | |
518 | ||
519 | ||
520 | //_________________________________________________________________________ | |
521 | Bool_t AliITSUTrackerGlo::GoToEntranceToLayer(AliITSUSeed* seed, AliITSURecoLayer* lr, Int_t dir, Bool_t check) | |
522 | { | |
523 | // go to the entrance of lr in direction dir, w/o applying material corrections. | |
524 | // If check is requested, do this only provided the track did not reach the layer already | |
525 | double xToGo = lr->GetR(-dir); | |
526 | if (check) { // do we need to track till the surface of the current layer ? | |
527 | double curR2 = seed->GetX()*seed->GetX() + seed->GetY()*seed->GetY(); // current radius | |
528 | if (dir>0) { if (curR2-xToGo*xToGo>fgkToler) return kTRUE; } // already passed | |
529 | else if (dir<0) { if (xToGo*xToGo-curR2>fgkToler) return kTRUE; } // already passed | |
530 | } | |
531 | if (!seed->GetXatLabR(xToGo,xToGo,GetBz(),dir)) return kFALSE; | |
532 | // go via layer to its boundary, applying material correction. | |
533 | if (!PropagateSeed(seed,xToGo,fCurrMass, 100, kFALSE)) return kFALSE; | |
534 | return kTRUE; | |
535 | // | |
536 | } | |
537 | ||
538 | //_________________________________________________________________________ | |
539 | Bool_t AliITSUTrackerGlo::GoToEntranceToLayer(AliExternalTrackParam* seed, AliITSURecoLayer* lr, Int_t dir, Bool_t check) | |
540 | { | |
541 | // go to the entrance of lr in direction dir, w/o applying material corrections. | |
542 | // If check is requested, do this only provided the track did not reach the layer already | |
543 | double xToGo = lr->GetR(-dir); | |
544 | if (check) { // do we need to track till the surface of the current layer ? | |
545 | double curR2 = seed->GetX()*seed->GetX() + seed->GetY()*seed->GetY(); // current radius | |
546 | if (dir>0) { if (curR2-xToGo*xToGo>fgkToler) return kTRUE; } // already passed | |
547 | else if (dir<0) { if (xToGo*xToGo-curR2>fgkToler) return kTRUE; } // already passed | |
548 | } | |
549 | if (!seed->GetXatLabR(xToGo,xToGo,GetBz(),dir)) return kFALSE; | |
550 | // go via layer to its boundary, applying material correction. | |
551 | if (!PropagateSeed(seed,xToGo,fCurrMass, 100, kFALSE)) return kFALSE; | |
552 | return kTRUE; | |
553 | // | |
554 | } | |
555 | ||
32d38de2 | 556 | //_________________________________________________________________________ |
c61e50c3 | 557 | Bool_t AliITSUTrackerGlo::GetRoadWidth(AliITSUSeed* seed, int ilrA) |
32d38de2 | 558 | { |
559 | // calculate road width in terms of phi and z for the track which MUST be on the external radius of the layer | |
560 | // as well as some aux info | |
561 | double bz = GetBz(); | |
562 | AliITSURecoLayer* lrA = fITS->GetLayerActive(ilrA); | |
c61e50c3 | 563 | seed->GetXYZ(&fTrImpData[kTrXIn]); // lab position at the entrance from above |
943e1898 | 564 | static AliExternalTrackParam sc; // seed copy for manipalitions |
565 | sc = *seed; | |
32d38de2 | 566 | // |
c61e50c3 | 567 | fTrImpData[kTrPhiIn] = ATan2(fTrImpData[kTrYIn],fTrImpData[kTrXIn]); |
943e1898 | 568 | if (!sc.Rotate(fTrImpData[kTrPhiIn])) return kFALSE; // go to the frame of the entry point into the layer |
c61e50c3 | 569 | double dr = lrA->GetDR(); // approximate X dist at the inner radius |
943e1898 | 570 | if (!sc.GetXYZAt(sc.GetX()-dr, bz, fTrImpData + kTrXOut)) { |
32d38de2 | 571 | // special case: track does not reach inner radius, might be tangential |
943e1898 | 572 | double r = sc.GetD(0,0,bz); |
32d38de2 | 573 | double x; |
943e1898 | 574 | if (!sc.GetXatLabR(r,x,bz,-1)) { |
575 | sc.Print(); | |
576 | AliFatal(Form("This should not happen: r=%f",r)); | |
32d38de2 | 577 | } |
943e1898 | 578 | dr = Abs(sc.GetX() - x); |
579 | if (!sc.GetXYZAt(x, bz, fTrImpData + kTrXOut)) { | |
580 | sc.Print(); | |
581 | AliFatal(Form("This should not happen: x=%f",x)); | |
32d38de2 | 582 | } |
583 | } | |
584 | // | |
c61e50c3 | 585 | fTrImpData[kTrPhiOut] = ATan2(fTrImpData[kTrYOut],fTrImpData[kTrXOut]); |
943e1898 | 586 | double sgy = sc.GetSigmaY2() + dr*dr*sc.GetSigmaSnp2() + AliITSUReconstructor::GetRecoParam()->GetSigmaY2(ilrA); |
587 | double sgz = sc.GetSigmaZ2() + dr*dr*sc.GetSigmaTgl2() + AliITSUReconstructor::GetRecoParam()->GetSigmaZ2(ilrA); | |
c61e50c3 | 588 | sgy = Sqrt(sgy)*AliITSUReconstructor::GetRecoParam()->GetNSigmaRoadY(); |
589 | sgz = Sqrt(sgz)*AliITSUReconstructor::GetRecoParam()->GetNSigmaRoadZ(); | |
590 | fTrImpData[kTrPhi0] = 0.5*(fTrImpData[kTrPhiOut]+fTrImpData[kTrPhiIn]); | |
173b3073 | 591 | fTrImpData[kTrZ0] = 0.5*(fTrImpData[kTrZOut]+fTrImpData[kTrZIn]); |
c61e50c3 | 592 | fTrImpData[kTrDPhi] = 0.5*Abs(fTrImpData[kTrPhiOut]-fTrImpData[kTrPhiIn]) + sgy/lrA->GetR(); |
173b3073 | 593 | fTrImpData[kTrDZ] = 0.5*Abs(fTrImpData[kTrZOut]-fTrImpData[kTrZIn]) + sgz; |
32d38de2 | 594 | // |
595 | return kTRUE; | |
596 | } | |
597 | ||
b8b59e05 | 598 | //________________________________________ |
599 | void AliITSUTrackerGlo::ResetSeedsPool() | |
600 | { | |
601 | // mark all seeds in the pool as unused | |
602 | AliInfo(Form("CurrentSize: %d, BookedUpTo: %d, free: %d",fSeedsPool.GetSize(),fSeedsPool.GetEntriesFast(),fNFreeSeeds)); | |
603 | fNFreeSeeds = 0; | |
604 | fSeedsPool.Clear(); // seeds don't allocate memory | |
605 | } | |
606 | ||
607 | ||
608 | //________________________________________ | |
609 | void AliITSUTrackerGlo::MarkSeedFree(AliITSUSeed *sd) | |
32d38de2 | 610 | { |
b8b59e05 | 611 | // account that this seed is "deleted" |
612 | int id = sd->GetPoolID(); | |
613 | if (id<0) { | |
614 | AliError(Form("Freeing of seed %p NOT from the pool is requested",sd)); | |
615 | return; | |
616 | } | |
617 | // AliInfo(Form("%d %p",id, seed)); | |
618 | fSeedsPool.RemoveAt(id); | |
619 | if (fFreeSeedsID.GetSize()<=fNFreeSeeds) fFreeSeedsID.Set( 2*fNFreeSeeds + 100 ); | |
620 | fFreeSeedsID.GetArray()[fNFreeSeeds++] = id; | |
32d38de2 | 621 | } |
f8832015 | 622 | |
623 | //_________________________________________________________________________ | |
624 | Int_t AliITSUTrackerGlo::CheckCluster(AliITSUSeed* track, Int_t lr, Int_t clID) | |
625 | { | |
626 | // Check if the cluster (in tracking frame!) is matching to track. | |
627 | // The track must be already propagated to sensor tracking frame. | |
628 | // Returns: kStopSearchOnSensor if the search on given sensor should be stopped, | |
629 | // kClusterMatching if the cluster is matching | |
630 | // kClusterMatching otherwise | |
631 | // | |
f8832015 | 632 | const double kTolerX = 5e-4; |
633 | AliCluster *cl = fITS->GetLayerActive(lr)->GetCluster(clID); | |
634 | // | |
c8d1f258 | 635 | Bool_t goodCl = kFALSE; |
716ccba7 | 636 | int currLabel = Abs(fCurrESDtrack->GetTPCLabel()); |
637 | // | |
8b16dbae | 638 | if (cl->GetLabel(0)>=0) { |
639 | for (int i=0;i<3;i++) if (cl->GetLabel(i)>=0 && cl->GetLabel(i)==currLabel) {goodCl = kTRUE; break;} | |
640 | } | |
716ccba7 | 641 | else goodCl = kTRUE; |
c8d1f258 | 642 | // |
f8832015 | 643 | if (TMath::Abs(cl->GetX())>kTolerX) { // if due to the misalingment X is large, propagate track only |
c8d1f258 | 644 | if (!track->PropagateParamOnlyTo(track->GetX()+cl->GetX(),GetBz())) { |
3dd9c283 | 645 | if (goodCl) {printf("Loose good cl: Failed propagation. |"); cl->Print();} |
c8d1f258 | 646 | return kStopSearchOnSensor; // propagation failed, seedT is intact |
647 | } | |
f8832015 | 648 | } |
3dd9c283 | 649 | double dy = cl->GetY()-track->GetY(); |
c8d1f258 | 650 | double dz = cl->GetZ()-track->GetZ(); |
0091e9f0 | 651 | // |
f8832015 | 652 | double dy2 = dy*dy; |
653 | double tol2 = (track->GetSigmaY2() + AliITSUReconstructor::GetRecoParam()->GetSigmaY2(lr))* | |
654 | AliITSUReconstructor::GetRecoParam()->GetNSigmaRoadY()*AliITSUReconstructor::GetRecoParam()->GetNSigmaRoadY(); // RS TOOPTIMIZE | |
655 | if (dy2>tol2) { // the clusters are sorted in Z(col) then in Y(row). | |
3dd9c283 | 656 | if (goodCl) {printf("Loose good cl: dy2=%e > tol2=%e |",dy2,tol2); cl->Print();} |
f8832015 | 657 | if (dy>0) return kStopSearchOnSensor; // No chance that other cluster of this sensor will match (all Y's will be even larger) |
658 | else return kClusterNotMatching; // Other clusters may match | |
659 | } | |
c8d1f258 | 660 | double dz2 = dz*dz; |
f8832015 | 661 | tol2 = (track->GetSigmaZ2() + AliITSUReconstructor::GetRecoParam()->GetSigmaZ2(lr))* |
662 | AliITSUReconstructor::GetRecoParam()->GetNSigmaRoadZ()*AliITSUReconstructor::GetRecoParam()->GetNSigmaRoadZ(); // RS TOOPTIMIZE | |
c8d1f258 | 663 | if (dz2>tol2) { |
3dd9c283 | 664 | if (goodCl) {printf("Loose good cl: dz2=%e > tol2=%e |",dz2,tol2); cl->Print();} |
c8d1f258 | 665 | return kClusterNotMatching; // Other clusters may match |
666 | } | |
f8832015 | 667 | // |
668 | // check chi2 | |
669 | Double_t p[2]={cl->GetY(), cl->GetZ()}; | |
670 | Double_t cov[3]={cl->GetSigmaY2(), cl->GetSigmaYZ(), cl->GetSigmaZ2()}; | |
671 | double chi2 = track->GetPredictedChi2(p,cov); | |
c8d1f258 | 672 | if (chi2>AliITSUReconstructor::GetRecoParam()->GetMaxTr2ClChi2(lr)) { |
3dd9c283 | 673 | if (goodCl) { |
716ccba7 | 674 | printf("Loose good cl: Chi2=%e > Chi2Max=%e |dy: %+.3e dz: %+.3e\n", |
675 | chi2,AliITSUReconstructor::GetRecoParam()->GetMaxTr2ClChi2(lr),dy,dz); | |
3dd9c283 | 676 | track->Print("etp"); |
677 | cl->Print(""); | |
678 | } | |
c8d1f258 | 679 | return kClusterNotMatching; |
680 | } | |
f8832015 | 681 | // |
682 | track = NewSeedFromPool(track); // input track will be reused, use its clone for updates | |
943e1898 | 683 | if (!track->Update()) { |
3dd9c283 | 684 | if (goodCl) {printf("Loose good cl: Failed update |"); cl->Print();} |
b8b59e05 | 685 | MarkSeedFree(track); |
c8d1f258 | 686 | return kClusterNotMatching; |
687 | } | |
f8832015 | 688 | track->SetChi2Cl(chi2); |
689 | track->SetLrClusterID(lr,clID); | |
690 | cl->IncreaseClusterUsage(); | |
691 | // | |
716ccba7 | 692 | track->SetFake(!goodCl); |
693 | // | |
694 | AliInfo(Form("AddCl(%d) Cl%d lr:%d: dY:%+8.4f dZ:%+8.4f (MC: %5d %5d %5d) |Chi2=%f(%c)", | |
695 | goodCl,clID,lr,dy,dz2,cl->GetLabel(0),cl->GetLabel(1),cl->GetLabel(2), chi2, track->IsFake() ? '-':'+')); | |
c8d1f258 | 696 | // |
f8832015 | 697 | AddProlongationHypothesis(track,lr); |
698 | // | |
699 | return kClusterMatching; | |
700 | } | |
c8d1f258 | 701 | |
702 | //_________________________________________________________________________ | |
703 | Bool_t AliITSUTrackerGlo::NeedToKill(AliITSUSeed *seed, Int_t flag) | |
704 | { | |
705 | // check if the seed should not be discarded | |
706 | const UShort_t kMask = 0xffff; | |
707 | if (flag==kMissingCluster) { | |
708 | int lastChecked = seed->GetLayerID(); | |
709 | UShort_t patt = seed->GetHitsPattern(); | |
710 | if (lastChecked) patt |= ~(kMask<<lastChecked); // not all layers were checked, complete unchecked once by potential hits | |
711 | Bool_t seedOK = fTrCond.CheckPattern(patt); | |
712 | return !seedOK; | |
713 | } | |
714 | return kTRUE; | |
715 | } | |
44785f3e | 716 | |
717 | //______________________________________________________________________________ | |
718 | Bool_t AliITSUTrackerGlo::PropagateSeed(AliITSUSeed *seed, Double_t xToGo, Double_t mass, Double_t maxStep, Bool_t matCorr) | |
719 | { | |
720 | // propagate seed to given x applying material correction if requested | |
721 | const Double_t kEpsilon = 1e-5; | |
722 | Double_t xpos = seed->GetX(); | |
723 | Int_t dir = (xpos<xToGo) ? 1:-1; | |
724 | Double_t xyz0[3],xyz1[3],param[7]; | |
725 | // | |
8b16dbae | 726 | Bool_t updTime = dir>0 && seed->IsStartedTimeIntegral(); |
f497470c | 727 | if (matCorr || updTime) seed->GetXYZ(xyz1); //starting global position |
44785f3e | 728 | while ( (xToGo-xpos)*dir > kEpsilon){ |
729 | Double_t step = dir*TMath::Min(TMath::Abs(xToGo-xpos), maxStep); | |
730 | Double_t x = xpos+step; | |
731 | Double_t bz=GetBz(); // getting the local Bz | |
732 | if (!seed->PropagateToX(x,bz)) return kFALSE; | |
8b16dbae | 733 | double ds = 0; |
734 | if (matCorr || updTime) { | |
44785f3e | 735 | xyz0[0]=xyz1[0]; // global pos at the beginning of step |
736 | xyz0[1]=xyz1[1]; | |
737 | xyz0[2]=xyz1[2]; | |
738 | seed->GetXYZ(xyz1); // // global pos at the end of step | |
8b16dbae | 739 | if (matCorr) { |
740 | MeanMaterialBudget(xyz0,xyz1,param); | |
741 | Double_t xrho=param[0]*param[4], xx0=param[1]; | |
742 | if (dir>0) xrho = -xrho; // outward should be negative | |
743 | if (!seed->ApplyMaterialCorrection(xx0,xrho,mass,kFALSE)) return kFALSE; | |
744 | ds = param[4]; | |
745 | } | |
746 | else { // matCorr is not requested but time integral is | |
747 | double d0 = xyz1[0]-xyz0[0]; | |
748 | double d1 = xyz1[1]-xyz0[1]; | |
749 | double d2 = xyz1[2]-xyz0[2]; | |
750 | ds = TMath::Sqrt(d0*d0+d1*d1+d2*d2); | |
751 | } | |
44785f3e | 752 | } |
8b16dbae | 753 | if (updTime) seed->AddTimeStep(ds); |
44785f3e | 754 | xpos = seed->GetX(); |
755 | } | |
756 | return kTRUE; | |
757 | } | |
716ccba7 | 758 | |
3e4e3c23 | 759 | //______________________________________________________________________________ |
760 | Bool_t AliITSUTrackerGlo::PropagateSeed(AliExternalTrackParam *seed, Double_t xToGo, Double_t mass, Double_t maxStep, Bool_t matCorr) | |
761 | { | |
762 | // propagate seed to given x applying material correction if requested | |
763 | const Double_t kEpsilon = 1e-5; | |
764 | Double_t xpos = seed->GetX(); | |
765 | Int_t dir = (xpos<xToGo) ? 1:-1; | |
766 | Double_t xyz0[3],xyz1[3],param[7]; | |
767 | // | |
768 | Bool_t updTime = dir>0 && seed->IsStartedTimeIntegral(); | |
769 | if (matCorr || updTime) seed->GetXYZ(xyz1); //starting global position | |
770 | while ( (xToGo-xpos)*dir > kEpsilon){ | |
771 | Double_t step = dir*TMath::Min(TMath::Abs(xToGo-xpos), maxStep); | |
772 | Double_t x = xpos+step; | |
773 | Double_t bz=GetBz(); // getting the local Bz | |
774 | if (!seed->PropagateTo(x,bz)) return kFALSE; | |
775 | double ds = 0; | |
776 | if (matCorr || updTime) { | |
777 | xyz0[0]=xyz1[0]; // global pos at the beginning of step | |
778 | xyz0[1]=xyz1[1]; | |
779 | xyz0[2]=xyz1[2]; | |
780 | seed->GetXYZ(xyz1); // // global pos at the end of step | |
781 | // | |
782 | if (matCorr) { | |
783 | MeanMaterialBudget(xyz0,xyz1,param); | |
784 | Double_t xrho=param[0]*param[4], xx0=param[1]; | |
785 | if (dir>0) xrho = -xrho; // outward should be negative | |
786 | if (!seed->CorrectForMeanMaterial(xx0,xrho,mass)) return kFALSE; | |
787 | ds = param[4]; | |
788 | } | |
789 | else { // matCorr is not requested but time integral is | |
790 | double d0 = xyz1[0]-xyz0[0]; | |
791 | double d1 = xyz1[1]-xyz0[1]; | |
792 | double d2 = xyz1[2]-xyz0[2]; | |
793 | ds = TMath::Sqrt(d0*d0+d1*d1+d2*d2); | |
794 | } | |
795 | } | |
796 | if (updTime) seed->AddTimeStep(ds); | |
797 | // | |
798 | xpos = seed->GetX(); | |
799 | } | |
800 | return kTRUE; | |
801 | } | |
802 | ||
716ccba7 | 803 | //______________________________________________________________________________ |
804 | void AliITSUTrackerGlo::SaveCurrentTrackHypotheses() | |
805 | { | |
806 | // RS: shall we clean up killed seeds? | |
807 | fCurrHyp = 0; | |
808 | // TODO | |
809 | ||
810 | } | |
3e4e3c23 | 811 | |
812 | //______________________________________________________________________________ | |
813 | void AliITSUTrackerGlo::FinalizeHypotheses() | |
814 | { | |
815 | // select winner for each hypothesis, remove cl. sharing conflicts | |
816 | AliInfo("TODO"); | |
817 | // | |
818 | int nh = fHypStore.GetEntriesFast(); | |
819 | for (int ih=0;ih<nh;ih++) { | |
820 | AliITSUTrackHyp* hyp = (AliITSUTrackHyp*) fHypStore.UncheckedAt(ih); | |
69e0f089 | 821 | if (!hyp || !hyp->DefineWinner()) continue; // TODO |
68a0f687 | 822 | CookMCLabel(hyp); |
823 | UpdateESDTrack(hyp,AliESDtrack::kITSin); | |
3e4e3c23 | 824 | } |
825 | ||
826 | } | |
c51c3124 | 827 | |
828 | //______________________________________________________________________________ | |
68a0f687 | 829 | void AliITSUTrackerGlo::UpdateESDTrack(AliITSUTrackHyp* hyp,Int_t flag) |
c51c3124 | 830 | { |
831 | // update ESD track with current best hypothesis | |
832 | AliESDtrack* esdTr = hyp->GetESDTrack(); | |
833 | if (!esdTr) return; | |
834 | AliITSUSeed* win = hyp->GetWinner(); | |
835 | if (!win) return; | |
68a0f687 | 836 | switch (flag) { |
837 | case AliESDtrack::kITSin: | |
838 | esdTr->UpdateTrackParams(hyp,flag); // update kinematics | |
839 | // TODO: set cluster info | |
840 | break; | |
841 | // | |
842 | case AliESDtrack::kITSout: | |
843 | esdTr->UpdateTrackParams(hyp,flag); // update kinematics | |
844 | // TODO: avoid setting friend | |
845 | break; | |
846 | // | |
847 | case AliESDtrack::kITSrefit: | |
848 | esdTr->UpdateTrackParams(hyp,flag); // update kinematics | |
849 | // TODO: avoid setting cluster info | |
850 | break; | |
851 | default: | |
852 | AliFatal(Form("Unknown flag %d",flag)); | |
853 | } | |
c51c3124 | 854 | // |
855 | // transfer module indices | |
856 | // TODO | |
857 | } | |
858 | ||
859 | //______________________________________________________________________________ | |
68a0f687 | 860 | Bool_t AliITSUTrackerGlo::RefitTrack(AliITSUTrackHyp* trc, Double_t rDest, Bool_t stopAtLastCl) |
c51c3124 | 861 | { |
862 | // refit track till radius rDest | |
8b16dbae | 863 | AliITSUTrackHyp tmpTr; |
864 | // | |
c51c3124 | 865 | double rCurr = Sqrt(trc->GetX()*trc->GetX() + trc->GetY()*trc->GetY()); |
866 | int dir,lrStart,lrStop; | |
867 | // | |
8b16dbae | 868 | dir = rCurr<rDest ? 1 : -1; |
869 | lrStart = fITS->FindFirstLayerID(rCurr,dir); | |
870 | lrStop = fITS->FindLastLayerID(rDest,dir); | |
e2d2481c | 871 | printf("Refit %d: Lr:%d (%f) -> Lr:%d (%f)\n",dir,lrStart,rCurr, lrStop,rDest); |
872 | printf("Before refit: "); trc->AliExternalTrackParam::Print(); | |
8b16dbae | 873 | 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)); |
874 | // | |
68a0f687 | 875 | int ncl = trc->FetchClusterInfo(fClInfo); |
8b16dbae | 876 | fCurrMass = trc->GetMass(); |
877 | tmpTr.AliKalmanTrack::operator=(*trc); | |
878 | tmpTr.SetChi2(0); | |
68a0f687 | 879 | int iclLr[2],nclLr,clCount=0; |
c51c3124 | 880 | // |
881 | for (int ilr=lrStart;ilr!=lrStop;ilr+=dir) { | |
882 | AliITSURecoLayer* lr = fITS->GetLayer(ilr); | |
883 | if ( dir*(rCurr-lr->GetR(dir))>0) continue; // this layer is already passed | |
8b16dbae | 884 | int ilrA2,ilrA = lr->GetActiveID(); |
885 | // passive layer or active w/o hits will be traversed on the way to next cluster | |
886 | if (!lr->IsActive() || fClInfo[ilrA2=(ilrA<<1)]<0) continue; | |
887 | // | |
e2d2481c | 888 | if (ilr!=lrStart && !TransportToLayer(&tmpTr,lrStart,ilr)) { |
e7d83d38 | 889 | AliInfo(Form("Failed to transport %d -> %d\n",lrStart,ilr)); |
e2d2481c | 890 | return kFALSE; // go to the entrance to the layer |
891 | } | |
8b16dbae | 892 | lrStart = ilr; |
893 | // | |
894 | // select the order in which possible 2 clusters (in case of the overlap) will be traversed and fitted | |
895 | nclLr=0; | |
896 | if (dir>0) { // clusters are stored in increasing radius order | |
897 | iclLr[nclLr++]=fClInfo[ilrA2++]; | |
898 | if (fClInfo[ilrA2]>=0) iclLr[nclLr++]=fClInfo[ilrA2]; | |
899 | } | |
900 | else { | |
901 | if ( fClInfo[ilrA2+1]>=0 ) iclLr[nclLr++]=fClInfo[ilrA2+1]; | |
902 | iclLr[nclLr++]=fClInfo[ilrA2]; | |
903 | } | |
904 | // | |
905 | for (int icl=0;icl<nclLr;icl++) { | |
906 | AliITSUClusterPix* clus = (AliITSUClusterPix*)lr->GetCluster(iclLr[icl]); | |
907 | AliITSURecoSens* sens = lr->GetSensorFromID(clus->GetVolumeId()); | |
e7d83d38 | 908 | if (!tmpTr.Rotate(sens->GetPhiTF())) { |
909 | AliInfo(Form("Failed on rotate to %f",sens->GetPhiTF())); | |
910 | return kFALSE; | |
911 | } | |
912 | //printf("Refit cl:%d on lr %d Need to go %.4f -> %.4f\n",icl,ilrA,tmpTr.GetX(),sens->GetXTF()+clus->GetX()); | |
913 | if (!PropagateSeed(&tmpTr,sens->GetXTF()+clus->GetX(),fCurrMass)) { | |
914 | AliInfo(Form("Failed on propagate to %f",sens->GetXTF()+clus->GetX())); | |
915 | return kFALSE; | |
916 | } | |
917 | if (!tmpTr.Update(clus)) { | |
918 | AliInfo(Form("Failed on Update")); | |
919 | return kFALSE; | |
920 | } | |
921 | //printf("AfterRefit: "); tmpTr.AliExternalTrackParam::Print(); | |
68a0f687 | 922 | if (stopAtLastCl && ++clCount==ncl) return kTRUE; // it was requested to not propagate after last update |
8b16dbae | 923 | } |
c51c3124 | 924 | // |
925 | } | |
8b16dbae | 926 | // All clusters were succesfully fitted. Even if the track does not reach rDest, this is enough to validate it. |
927 | // Still, try to go as close as possible to rDest. | |
928 | // | |
929 | if (lrStart!=lrStop) { | |
e7d83d38 | 930 | //printf("Going to last layer %d -> %d\n",lrStart,lrStop); |
931 | if (!TransportToLayer(&tmpTr,lrStart,lrStop)) { | |
932 | AliInfo(Form("Failed on TransportToLayer %d->%d",lrStart,lrStop)); | |
933 | return kTRUE; | |
934 | } | |
935 | if (!GoToExitFromLayer(&tmpTr,fITS->GetLayer(lrStop),dir)) { | |
936 | AliFatal(Form("Failed on GoToExitFromLayer %d",lrStop)); | |
937 | return kTRUE; // go till the exit from layer | |
938 | } | |
e2d2481c | 939 | // |
e7d83d38 | 940 | //printf("On exit from last layer\n"); |
e2d2481c | 941 | tmpTr.AliExternalTrackParam::Print(); |
942 | // go to the destination radius | |
943 | if (!tmpTr.GetXatLabR(rDest,rDest,GetBz(),dir)) return kTRUE; | |
944 | if (!PropagateSeed(&tmpTr,rDest,fCurrMass, 100, kFALSE)) return kTRUE; | |
8b16dbae | 945 | } |
946 | trc->AliKalmanTrack::operator=(tmpTr); | |
e2d2481c | 947 | printf("After refit (now at lr %d): ",lrStart); trc->AliExternalTrackParam::Print(); |
8b16dbae | 948 | return kTRUE; |
c51c3124 | 949 | } |
dd2117a2 | 950 | |
951 | //__________________________________________________________________ | |
952 | void AliITSUTrackerGlo::CookMCLabel(AliITSUTrackHyp* hyp) | |
953 | { | |
954 | // build MC label | |
955 | // | |
956 | const int kMaxLbPerCl = 3; | |
957 | int lbID[kMaxLayers*6],lbStat[kMaxLayers*6]; | |
958 | Int_t lr,nLab=0,nCl=0; | |
959 | AliITSUSeed *seed = hyp->GetWinner(); | |
960 | while(seed) { | |
961 | int clID = seed->GetLrCluster(lr); | |
962 | if (clID>=0) { | |
963 | AliCluster *cl = fITS->GetLayerActive(lr)->GetCluster(clID); | |
964 | nCl++; | |
965 | for (int imc=0;imc<kMaxLbPerCl;imc++) { // labels within single cluster | |
966 | int trLb = cl->GetLabel(imc); | |
704d9398 | 967 | if (trLb<0) break; |
dd2117a2 | 968 | // search this mc track in already accounted ones |
969 | int iLab; | |
970 | for (iLab=0;iLab<nLab;iLab++) if (lbID[iLab]==trLb) break; | |
971 | if (iLab<nLab) lbStat[iLab]++; | |
972 | else { | |
973 | lbID[nLab] = trLb; | |
974 | lbStat[nLab++] = 1; | |
975 | } | |
976 | } // loop over given cluster's labels | |
977 | } | |
978 | seed = (AliITSUSeed*)seed->GetParent(); | |
979 | } // loop over clusters | |
980 | // | |
41343470 | 981 | if (nCl && nLab) { |
dd2117a2 | 982 | int maxLab=0,nTPCok=0; |
983 | AliESDtrack* esdTr = hyp->GetESDTrack(); | |
984 | int tpcLab = esdTr ? Abs(esdTr->GetTPCLabel()) : -kDummyLabel; | |
985 | for (int ilb=nLab;ilb--;) { | |
986 | int st = lbStat[ilb]; | |
987 | if (lbStat[maxLab]<st) maxLab=ilb; | |
988 | if (tpcLab==lbID[ilb]) nTPCok += st; | |
989 | } | |
990 | hyp->SetFakeRatio(1.-float(nTPCok)/nCl); | |
991 | hyp->SetLabel( nTPCok==nCl ? tpcLab : -tpcLab); | |
992 | hyp->SetITSLabel( lbStat[maxLab]==nCl ? lbStat[maxLab] : -lbStat[maxLab]); // winner label | |
993 | return; | |
994 | } | |
995 | // | |
996 | hyp->SetFakeRatio(-1.); | |
997 | hyp->SetLabel( kDummyLabel ); | |
998 | hyp->SetITSLabel( kDummyLabel ); | |
999 | } |