]>
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 | ||
43 | ClassImp(AliITSUTrackerGlo) | |
44 | //_________________________________________________________________________ | |
45 | AliITSUTrackerGlo::AliITSUTrackerGlo(AliITSUReconstructor* rec) | |
46 | : fReconstructor(rec) | |
47 | ,fITS(0) | |
0091e9f0 | 48 | ,fCurrESDtrack(0) |
32d38de2 | 49 | ,fCurrMass(kPionMass) |
c61e50c3 | 50 | ,fSeedsLr(0) |
51 | ,fSeedsPool("AliITSUSeed",0) | |
32d38de2 | 52 | { |
53 | // Default constructor | |
54 | if (rec) Init(rec); | |
55 | } | |
56 | ||
57 | //_________________________________________________________________________ | |
58 | AliITSUTrackerGlo::~AliITSUTrackerGlo() | |
59 | { | |
60 | // Default destructor | |
61 | // | |
62 | delete fITS; | |
c61e50c3 | 63 | delete[] fSeedsLr; |
32d38de2 | 64 | // |
65 | } | |
66 | ||
67 | //_________________________________________________________________________ | |
68 | void AliITSUTrackerGlo::Init(AliITSUReconstructor* rec) | |
69 | { | |
70 | // init with external reconstructor | |
c61e50c3 | 71 | // |
32d38de2 | 72 | fITS = new AliITSURecoDet(rec->GetGeom(),"ITSURecoInterface"); |
73 | for (int ilr=fITS->GetNLayersActive();ilr--;) { | |
74 | fITS->GetLayerActive(ilr)->SetClusters(rec->GetClusters(ilr)); | |
75 | } | |
c61e50c3 | 76 | // |
77 | fSeedsPool.ExpandCreateFast(1000); // RS TOCHECK | |
78 | int n = fITS->GetNLayersActive()+1; | |
79 | fSeedsLr = new TObjArray[n]; | |
80 | // | |
81 | ||
32d38de2 | 82 | } |
83 | ||
84 | //_________________________________________________________________________ | |
85 | Int_t AliITSUTrackerGlo::Clusters2Tracks(AliESDEvent *esdEv) | |
86 | { | |
87 | // | |
88 | // | |
dde91d5d | 89 | AliITSUReconstructor::GetRecoParam()->Print(); |
90 | ||
32d38de2 | 91 | fITS->ProcessClusters(); |
92 | // select ESD tracks to propagate | |
93 | int nTrESD = esdEv->GetNumberOfTracks(); | |
94 | for (int itr=0;itr<nTrESD;itr++) { | |
95 | AliESDtrack *esdTr = esdEv->GetTrack(itr); | |
0091e9f0 | 96 | AliInfo(Form("Processing track %d | MCLabel: %d",itr,esdTr->GetTPCLabel())); |
32d38de2 | 97 | FindTrack(esdTr); |
98 | } | |
99 | ||
100 | return 0; | |
101 | } | |
102 | ||
103 | //_________________________________________________________________________ | |
104 | Int_t AliITSUTrackerGlo::PropagateBack(AliESDEvent * /*event*/) | |
105 | { | |
106 | // | |
107 | // To be implemented | |
108 | // | |
109 | ||
110 | Info("PropagateBack","To be implemented"); | |
111 | return 0; | |
112 | } | |
113 | ||
114 | //_________________________________________________________________________ | |
115 | Int_t AliITSUTrackerGlo::RefitInward(AliESDEvent * /*event*/) | |
116 | { | |
117 | // | |
118 | // To be implemented | |
119 | // | |
120 | ||
121 | Info("RefitInward","To be implemented"); | |
122 | return 0; | |
123 | } | |
124 | ||
125 | //_________________________________________________________________________ | |
126 | Int_t AliITSUTrackerGlo::LoadClusters(TTree * treeRP) | |
127 | { | |
128 | // read from tree (if pointer provided) or directly from the ITS reco interface | |
129 | // | |
130 | return fReconstructor->LoadClusters(treeRP); | |
131 | } | |
132 | ||
133 | //_________________________________________________________________________ | |
134 | void AliITSUTrackerGlo::UnloadClusters() | |
135 | { | |
136 | // | |
137 | // To be implemented | |
138 | // | |
139 | ||
140 | Info("UnloadClusters","To be implemented"); | |
141 | } | |
142 | //_________________________________________________________________________ | |
143 | AliCluster * AliITSUTrackerGlo::GetCluster(Int_t /*index*/) const | |
144 | { | |
145 | // | |
146 | // To be implemented | |
147 | // | |
148 | ||
149 | Info("GetCluster","To be implemented"); | |
150 | return 0x0; | |
151 | } | |
152 | ||
153 | //_________________________________________________________________________ | |
154 | Bool_t AliITSUTrackerGlo::NeedToProlong(AliESDtrack* esdTr) | |
155 | { | |
156 | // do we need to match this track to ITS? | |
157 | // | |
158 | static double bz = GetBz(); | |
159 | if (!esdTr->IsOn(AliESDtrack::kTPCin) || | |
160 | esdTr->IsOn(AliESDtrack::kTPCout) || | |
161 | esdTr->IsOn(AliESDtrack::kITSin) || | |
162 | esdTr->GetKinkIndex(0)>0) return kFALSE; | |
163 | // | |
c61e50c3 | 164 | if (esdTr->Pt()<AliITSUReconstructor::GetRecoParam()->GetMinPtForProlongation()) return kFALSE; |
32d38de2 | 165 | // |
166 | float dtz[2]; | |
167 | esdTr->GetDZ(GetX(),GetY(),GetZ(),bz,dtz); | |
168 | // if track is not V0 candidata but has large offset wrt IP, reject it. RS TOCHECK | |
c61e50c3 | 169 | if ( !(esdTr->GetV0Index(0)>0 && dtz[0]>AliITSUReconstructor::GetRecoParam()->GetMaxDforV0dghtrForProlongation()) |
170 | && (Abs(dtz[0])>AliITSUReconstructor::GetRecoParam()->GetMaxDForProlongation() || | |
171 | Abs(dtz[1])>AliITSUReconstructor::GetRecoParam()->GetMaxDZForProlongation())) return kFALSE; | |
32d38de2 | 172 | // |
173 | return kTRUE; | |
174 | } | |
175 | ||
176 | //_________________________________________________________________________ | |
177 | void AliITSUTrackerGlo::FindTrack(AliESDtrack* esdTr) | |
178 | { | |
179 | // find prolongaion candidates finding for single seed | |
180 | // | |
181 | if (!NeedToProlong(esdTr)) return; // are we interested in this track? | |
c61e50c3 | 182 | if (!InitSeed(esdTr)) return; // initialize prolongations hypotheses tree |
32d38de2 | 183 | // |
173b3073 | 184 | AliITSURecoSens *hitSens[AliITSURecoSens::kNNeighbors+1]; |
f8832015 | 185 | AliITSUSeed seedUC; // copy of the seed from the upper layer |
186 | AliITSUSeed seedT; // transient seed between the seedUC and new prolongation hypothesis | |
187 | // | |
c61e50c3 | 188 | TObjArray clArr; // container for transfer of clusters matching to seed |
32d38de2 | 189 | // |
190 | for (int ila=fITS->GetNLayersActive();ila--;) { | |
191 | int ilaUp = ila+1; // prolong seeds from layer above | |
192 | int nSeedsUp = GetNSeeds(ilaUp); | |
193 | for (int isd=0;isd<nSeedsUp;isd++) { | |
c61e50c3 | 194 | AliITSUSeed* seedU = GetSeed(ilaUp,isd); // seed on prev.active layer to prolong |
f8832015 | 195 | seedUC = *seedU; |
196 | seedUC.SetParent(seedU); | |
32d38de2 | 197 | // go till next active layer |
0091e9f0 | 198 | AliInfo(Form("Lr:%d Seed:%d of %d",ila,isd,nSeedsUp)); |
f8832015 | 199 | if (!TransportToLayer(&seedUC, fITS->GetLrIDActive(ilaUp), fITS->GetLrIDActive(ila)) ) { |
32d38de2 | 200 | // |
0091e9f0 | 201 | AliInfo("Transport failed"); |
32d38de2 | 202 | // Check if the seed satisfies to track definition |
f8832015 | 203 | if (NeedToKill(&seedUC,kTransportFailed)) KillSeed(ilaUp,isd); |
32d38de2 | 204 | continue; // RS TODO: decide what to do with tracks stopped on higher layers w/o killing |
205 | } | |
206 | AliITSURecoLayer* lrA = fITS->GetLayerActive(ila); | |
f8832015 | 207 | if (!GetRoadWidth(&seedUC, ila)) { // failed to find road width on the layer |
208 | if (NeedToKill(&seedUC,kRWCheckFailed)) KillSeed(ilaUp,isd); | |
32d38de2 | 209 | continue; |
210 | } | |
173b3073 | 211 | int nsens = lrA->FindSensors(&fTrImpData[kTrPhi0], hitSens); // find detectors which may be hit by the track |
0091e9f0 | 212 | AliInfo(Form("Will check %d sensors on lr:%d ",nsens,ila)); |
32d38de2 | 213 | // |
214 | for (int isn=nsens;isn--;) { | |
f8832015 | 215 | seedT = seedUC; |
c61e50c3 | 216 | AliITSURecoSens* sens = hitSens[isn]; |
f8832015 | 217 | // |
218 | if (!seedT.Propagate(sens->GetPhiTF(),sens->GetXTF(),GetBz())) continue; // propagation failed, seedT is intact | |
219 | int clID0 = sens->GetFirstClusterId(); | |
c61e50c3 | 220 | for (int icl=sens->GetNClusters();icl--;) { |
f8832015 | 221 | int res = CheckCluster(&seedT,ila,clID0+icl); |
222 | // | |
223 | if (res==kStopSearchOnSensor) break; // stop looking on this sensor | |
224 | if (res==kClusterNotMatching) continue; // cluster does not match | |
225 | // cluster is matching and it was added to the hypotheses tree | |
c61e50c3 | 226 | } |
32d38de2 | 227 | } |
f8832015 | 228 | // cluster search is done. Do we need ta have a version of this seed skipping current layer |
229 | seedT.SetLr(ila); | |
230 | if (!NeedToKill(&seedT,kMissingCluster)) AddProlongationHypothesis(NewSeedFromPool(&seedT) ,ila); | |
32d38de2 | 231 | } |
232 | } | |
233 | // | |
c61e50c3 | 234 | ResetSeedTree(); |
32d38de2 | 235 | } |
236 | ||
237 | //_________________________________________________________________________ | |
238 | Bool_t AliITSUTrackerGlo::InitSeed(AliESDtrack *esdTr) | |
239 | { | |
c61e50c3 | 240 | // init prolongaion candidates finding for single seed |
32d38de2 | 241 | fCurrMass = esdTr->GetMass(); |
0091e9f0 | 242 | fCurrESDtrack = esdTr; |
32d38de2 | 243 | if (fCurrMass<kPionMass*0.9) fCurrMass = kPionMass; // don't trust to mu, e identification from TPCin |
c61e50c3 | 244 | // |
245 | AliITSUSeed* seed = NewSeedFromPool(); | |
dde91d5d | 246 | seed->SetLr(fITS->GetNLayersActive()); // fake layer |
c61e50c3 | 247 | seed->AliExternalTrackParam::operator=(*esdTr); |
248 | seed->SetParent(esdTr); | |
f8832015 | 249 | AddProlongationHypothesis(seed,fITS->GetNLayersActive()); |
32d38de2 | 250 | return kTRUE; |
251 | // TO DO | |
252 | } | |
253 | ||
c61e50c3 | 254 | //_________________________________________________________________________ |
255 | void AliITSUTrackerGlo::ResetSeedTree() | |
256 | { | |
257 | // reset current hypotheses tree | |
258 | for (int i=fITS->GetNLayersActive()+1;i--;) fSeedsLr[fITS->GetNLayersActive()].Clear(); | |
259 | } | |
260 | ||
32d38de2 | 261 | //_________________________________________________________________________ |
262 | Bool_t AliITSUTrackerGlo::TransportToLayer(AliITSUSeed* seed, Int_t lFrom, Int_t lTo) | |
263 | { | |
264 | // transport seed from layerFrom to the entrance of layerTo | |
265 | // | |
266 | const double kToler = 1e-6; // tolerance for layer on-surface check | |
267 | // | |
268 | int dir = lTo > lFrom ? 1:-1; | |
269 | AliITSURecoLayer* lrFr = fITS->GetLayer(lFrom); // this can be 0 when extrapolation from TPC to ITS is requested | |
270 | Bool_t checkFirst = kTRUE; | |
271 | while(lFrom!=lTo) { | |
272 | double curR2 = seed->GetX()*seed->GetX() + seed->GetY()*seed->GetY(); // current radius | |
273 | if (lrFr) { | |
274 | Bool_t doLayer = kTRUE; | |
275 | double xToGo = dir>0 ? lrFr->GetRMax() : lrFr->GetRMin(); | |
276 | if (checkFirst) { // do we need to track till the surface of the current layer ? | |
277 | checkFirst = kFALSE; | |
278 | if (dir>0) { if (curR2-xToGo*xToGo>kToler) doLayer = kFALSE; } // on the surface or outside of the layer | |
279 | else if (dir<0) { if (xToGo*xToGo-curR2>kToler) doLayer = kFALSE; } // on the surface or outside of the layer | |
280 | } | |
281 | if (doLayer) { | |
282 | if (!seed->GetXatLabR(xToGo,xToGo,GetBz(),dir)) return kFALSE; | |
283 | // go via layer to its boundary, applying material correction. | |
284 | if (!PropagateTrackTo(seed,xToGo,fCurrMass, lrFr->GetMaxStep(), kFALSE, -1, 0, kTRUE)) return kFALSE; | |
285 | } | |
286 | } | |
287 | AliITSURecoLayer* lrTo = fITS->GetLayer( (lFrom+=dir) ); | |
288 | if (!lrTo) AliFatal(Form("Layer %d does not exist",lFrom)); | |
289 | // | |
290 | // go the entrance of the layer, assuming no materials in between | |
291 | double xToGo = dir>0 ? lrTo->GetRMin() : lrTo->GetRMax(); | |
dde91d5d | 292 | if (!seed->GetXatLabR(xToGo,xToGo,GetBz(),dir)) return kFALSE; |
32d38de2 | 293 | if (!seed->PropagateTo(xToGo, GetBz())) return kFALSE; // RS: do we need BxByBz? |
294 | lrFr = lrTo; | |
295 | } | |
296 | return kTRUE; | |
297 | // | |
298 | } | |
299 | ||
300 | //_________________________________________________________________________ | |
c61e50c3 | 301 | Bool_t AliITSUTrackerGlo::GetRoadWidth(AliITSUSeed* seed, int ilrA) |
32d38de2 | 302 | { |
303 | // calculate road width in terms of phi and z for the track which MUST be on the external radius of the layer | |
304 | // as well as some aux info | |
305 | double bz = GetBz(); | |
306 | AliITSURecoLayer* lrA = fITS->GetLayerActive(ilrA); | |
c61e50c3 | 307 | seed->GetXYZ(&fTrImpData[kTrXIn]); // lab position at the entrance from above |
32d38de2 | 308 | // |
c61e50c3 | 309 | fTrImpData[kTrPhiIn] = ATan2(fTrImpData[kTrYIn],fTrImpData[kTrXIn]); |
310 | if (!seed->Rotate(fTrImpData[kTrPhiIn])) return kFALSE; // go to the frame of the entry point into the layer | |
311 | double dr = lrA->GetDR(); // approximate X dist at the inner radius | |
312 | if (!seed->GetXYZAt(seed->GetX()-dr, bz, fTrImpData + kTrXOut)) { | |
32d38de2 | 313 | // special case: track does not reach inner radius, might be tangential |
314 | double r = seed->GetD(0,0,bz); | |
315 | double x; | |
316 | if (!seed->GetXatLabR(r,x,bz,-1)) { | |
317 | AliError(Form("This should not happen: r=%f",r)); | |
318 | seed->Print(); | |
319 | return kFALSE; | |
320 | } | |
321 | dr = Abs(seed->GetX() - x); | |
c61e50c3 | 322 | if (!seed->GetXYZAt(x, bz, fTrImpData + kTrXOut)) { |
32d38de2 | 323 | AliError(Form("This should not happen: x=%f",x)); |
324 | seed->Print(); | |
325 | return kFALSE; | |
326 | } | |
327 | } | |
328 | // | |
c61e50c3 | 329 | fTrImpData[kTrPhiOut] = ATan2(fTrImpData[kTrYOut],fTrImpData[kTrXOut]); |
330 | double sgy = seed->GetSigmaY2() + dr*dr*seed->GetSigmaSnp2() + AliITSUReconstructor::GetRecoParam()->GetSigmaY2(ilrA); | |
331 | double sgz = seed->GetSigmaZ2() + dr*dr*seed->GetSigmaTgl2() + AliITSUReconstructor::GetRecoParam()->GetSigmaZ2(ilrA); | |
332 | sgy = Sqrt(sgy)*AliITSUReconstructor::GetRecoParam()->GetNSigmaRoadY(); | |
333 | sgz = Sqrt(sgz)*AliITSUReconstructor::GetRecoParam()->GetNSigmaRoadZ(); | |
334 | fTrImpData[kTrPhi0] = 0.5*(fTrImpData[kTrPhiOut]+fTrImpData[kTrPhiIn]); | |
173b3073 | 335 | fTrImpData[kTrZ0] = 0.5*(fTrImpData[kTrZOut]+fTrImpData[kTrZIn]); |
c61e50c3 | 336 | fTrImpData[kTrDPhi] = 0.5*Abs(fTrImpData[kTrPhiOut]-fTrImpData[kTrPhiIn]) + sgy/lrA->GetR(); |
173b3073 | 337 | fTrImpData[kTrDZ] = 0.5*Abs(fTrImpData[kTrZOut]-fTrImpData[kTrZIn]) + sgz; |
32d38de2 | 338 | // |
339 | return kTRUE; | |
340 | } | |
341 | ||
342 | //_________________________________________________________________________ | |
c61e50c3 | 343 | AliITSUSeed* AliITSUTrackerGlo::NewSeedFromPool(const AliITSUSeed* src) |
32d38de2 | 344 | { |
345 | // create new seed, optionally copying from the source | |
346 | return src ? | |
347 | new(fSeedsPool[fSeedsPool.GetEntriesFast()]) AliITSUSeed(*src) : | |
348 | new(fSeedsPool[fSeedsPool.GetEntriesFast()]) AliITSUSeed(); | |
349 | } | |
f8832015 | 350 | |
351 | //_________________________________________________________________________ | |
352 | Int_t AliITSUTrackerGlo::CheckCluster(AliITSUSeed* track, Int_t lr, Int_t clID) | |
353 | { | |
354 | // Check if the cluster (in tracking frame!) is matching to track. | |
355 | // The track must be already propagated to sensor tracking frame. | |
356 | // Returns: kStopSearchOnSensor if the search on given sensor should be stopped, | |
357 | // kClusterMatching if the cluster is matching | |
358 | // kClusterMatching otherwise | |
359 | // | |
360 | // The seed is already propagated to cluster | |
361 | const double kTolerX = 5e-4; | |
362 | AliCluster *cl = fITS->GetLayerActive(lr)->GetCluster(clID); | |
363 | // | |
364 | if (TMath::Abs(cl->GetX())>kTolerX) { // if due to the misalingment X is large, propagate track only | |
365 | if (!track->PropagateParamOnlyTo(track->GetX()+cl->GetX(),GetBz())) return kStopSearchOnSensor; // propagation failed, seedT is intact | |
366 | } | |
367 | double dy = cl->GetY() - track->GetY(); | |
0091e9f0 | 368 | double dz2 = cl->GetZ()-track->GetZ(); |
369 | // | |
370 | AliInfo(Form("Cl%d lr:%d: dY:%+8.4f dZ:%+8.4f (MC: %5d %5d %5d)",clID,lr,dy,dz2,cl->GetLabel(0),cl->GetLabel(1),cl->GetLabel(2))); | |
371 | // | |
f8832015 | 372 | double dy2 = dy*dy; |
373 | double tol2 = (track->GetSigmaY2() + AliITSUReconstructor::GetRecoParam()->GetSigmaY2(lr))* | |
374 | AliITSUReconstructor::GetRecoParam()->GetNSigmaRoadY()*AliITSUReconstructor::GetRecoParam()->GetNSigmaRoadY(); // RS TOOPTIMIZE | |
375 | if (dy2>tol2) { // the clusters are sorted in Z(col) then in Y(row). | |
376 | if (dy>0) return kStopSearchOnSensor; // No chance that other cluster of this sensor will match (all Y's will be even larger) | |
377 | else return kClusterNotMatching; // Other clusters may match | |
378 | } | |
f8832015 | 379 | dz2 *= dz2; |
380 | tol2 = (track->GetSigmaZ2() + AliITSUReconstructor::GetRecoParam()->GetSigmaZ2(lr))* | |
381 | AliITSUReconstructor::GetRecoParam()->GetNSigmaRoadZ()*AliITSUReconstructor::GetRecoParam()->GetNSigmaRoadZ(); // RS TOOPTIMIZE | |
382 | if (dz2>tol2) return kClusterNotMatching; // Other clusters may match | |
383 | // | |
384 | // check chi2 | |
385 | Double_t p[2]={cl->GetY(), cl->GetZ()}; | |
386 | Double_t cov[3]={cl->GetSigmaY2(), cl->GetSigmaYZ(), cl->GetSigmaZ2()}; | |
387 | double chi2 = track->GetPredictedChi2(p,cov); | |
0091e9f0 | 388 | AliInfo(Form("Chi2=%f",chi2)); |
f8832015 | 389 | if (chi2>AliITSUReconstructor::GetRecoParam()->GetMaxTr2ClChi2(lr)) return kClusterNotMatching; |
390 | // | |
391 | track = NewSeedFromPool(track); // input track will be reused, use its clone for updates | |
392 | if (!track->Update(p,cov)) return kClusterNotMatching; | |
393 | track->SetChi2Cl(chi2); | |
394 | track->SetLrClusterID(lr,clID); | |
395 | cl->IncreaseClusterUsage(); | |
396 | // | |
397 | AddProlongationHypothesis(track,lr); | |
398 | // | |
399 | return kClusterMatching; | |
400 | } |