]>
Commit | Line | Data |
---|---|---|
006b5f7f | 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 | // Implementation of the ITS tracker class | |
18 | // | |
19 | // Origin: Iouri Belikov, CERN, Jouri.Belikov@cern.ch | |
a9a2d814 | 20 | // dEdx analysis by: Boris Batyunya, JINR, Boris.Batiounia@cern.ch |
006b5f7f | 21 | //------------------------------------------------------------------------- |
1f9a65c4 | 22 | |
006b5f7f | 23 | #include <TFile.h> |
24 | #include <TTree.h> | |
25 | #include <TRandom.h> | |
006b5f7f | 26 | |
27 | #include "AliITSgeom.h" | |
28 | #include "AliITSRecPoint.h" | |
517b130f | 29 | #include "AliTPCtrack.h" |
83d73500 | 30 | #include "AliESD.h" |
006b5f7f | 31 | #include "AliITSclusterV2.h" |
32 | #include "AliITStrackerV2.h" | |
33 | ||
8676d691 | 34 | ClassImp(AliITStrackerV2) |
006b5f7f | 35 | |
006b5f7f | 36 | AliITStrackerV2::AliITSlayer AliITStrackerV2::fLayers[kMaxLayer]; // ITS layers |
37 | ||
61ab8ea8 | 38 | AliITStrackerV2::AliITStrackerV2(const AliITSgeom *geom) : AliTracker() { |
006b5f7f | 39 | //-------------------------------------------------------------------- |
61ab8ea8 | 40 | //This is the AliITStrackerV2 constructor |
006b5f7f | 41 | //-------------------------------------------------------------------- |
006b5f7f | 42 | AliITSgeom *g=(AliITSgeom*)geom; |
43 | ||
44 | Float_t x,y,z; | |
45 | Int_t i; | |
46 | for (i=1; i<kMaxLayer+1; i++) { | |
47 | Int_t nlad=g->GetNladders(i); | |
48 | Int_t ndet=g->GetNdetectors(i); | |
49 | ||
50 | g->GetTrans(i,1,1,x,y,z); | |
51 | Double_t r=TMath::Sqrt(x*x + y*y); | |
52 | Double_t poff=TMath::ATan2(y,x); | |
53 | Double_t zoff=z; | |
54 | ||
55 | g->GetTrans(i,1,2,x,y,z); | |
56 | r += TMath::Sqrt(x*x + y*y); | |
57 | g->GetTrans(i,2,1,x,y,z); | |
58 | r += TMath::Sqrt(x*x + y*y); | |
59 | g->GetTrans(i,2,2,x,y,z); | |
60 | r += TMath::Sqrt(x*x + y*y); | |
61 | r*=0.25; | |
62 | ||
63 | new (fLayers+i-1) AliITSlayer(r,poff,zoff,nlad,ndet); | |
64 | ||
65 | for (Int_t j=1; j<nlad+1; j++) { | |
66 | for (Int_t k=1; k<ndet+1; k++) { //Fill this layer with detectors | |
67 | Float_t x,y,zshift; g->GetTrans(i,j,k,x,y,zshift); | |
68 | Double_t rot[9]; g->GetRotMatrix(i,j,k,rot); | |
69 | ||
70 | Double_t r =-x*rot[1] + y*rot[0]; if (i==1) r=-r; | |
71 | Double_t phi=TMath::ATan2(rot[1],rot[0]); if (i==1) phi-=3.1415927; | |
61ab8ea8 | 72 | phi+=0.5*TMath::Pi(); if (phi<0) phi += 2*TMath::Pi(); |
006b5f7f | 73 | AliITSdetector &det=fLayers[i-1].GetDetector((j-1)*ndet + k-1); |
74 | ||
006b5f7f | 75 | new(&det) AliITSdetector(r,phi); |
76 | } | |
77 | } | |
78 | ||
79 | } | |
80 | ||
61ab8ea8 | 81 | fI=kMaxLayer; |
743a19f2 | 82 | |
61ab8ea8 | 83 | fPass=0; |
84 | fConstraint[0]=1; fConstraint[1]=0; | |
8676d691 | 85 | |
86 | Double_t xyz[]={kXV,kYV,kZV}, ers[]={kSigmaXV,kSigmaYV,kSigmaZV}; | |
87 | SetVertex(xyz,ers); | |
c0dd5278 | 88 | |
89 | for (Int_t i=0; i<kMaxLayer; i++) fLayersNotToSkip[i]=kLayersNotToSkip[i]; | |
90 | fLastLayerToTrackTo=kLastLayerToTrackTo; | |
91 | ||
92 | } | |
93 | ||
94 | void AliITStrackerV2::SetLayersNotToSkip(Int_t *l) { | |
95 | //-------------------------------------------------------------------- | |
96 | //This function set masks of the layers which must be not skipped | |
97 | //-------------------------------------------------------------------- | |
98 | for (Int_t i=0; i<kMaxLayer; i++) fLayersNotToSkip[i]=l[i]; | |
61ab8ea8 | 99 | } |
006b5f7f | 100 | |
8676d691 | 101 | Int_t AliITStrackerV2::LoadClusters() { |
83d73500 | 102 | return LoadClusters(gFile); |
103 | } | |
104 | ||
105 | Int_t AliITStrackerV2::LoadClusters(const TFile *cf) { | |
61ab8ea8 | 106 | //-------------------------------------------------------------------- |
107 | //This function loads ITS clusters | |
108 | //-------------------------------------------------------------------- | |
83d73500 | 109 | if (!((TFile *)cf)->IsOpen()) { |
110 | Error("LoadClusters","file with ITS clusters has not been open !\n"); | |
111 | return 1; | |
112 | } | |
113 | ||
61ab8ea8 | 114 | char cname[100]; |
115 | sprintf(cname,"TreeC_ITS_%d",GetEventNumber()); | |
83d73500 | 116 | TTree *cTree=(TTree*)((TFile *)cf)->Get(cname); |
61ab8ea8 | 117 | if (!cTree) { |
8676d691 | 118 | Error("LoadClusters"," can't get cTree !\n"); |
119 | return 1; | |
61ab8ea8 | 120 | } |
121 | TBranch *branch=cTree->GetBranch("Clusters"); | |
122 | if (!branch) { | |
8676d691 | 123 | Error("LoadClusters"," can't get Clusters branch !\n"); |
124 | return 1; | |
61ab8ea8 | 125 | } |
006b5f7f | 126 | |
61ab8ea8 | 127 | TClonesArray dummy("AliITSclusterV2",10000), *clusters=&dummy; |
128 | branch->SetAddress(&clusters); | |
006b5f7f | 129 | |
61ab8ea8 | 130 | Int_t j=0; |
131 | for (Int_t i=0; i<kMaxLayer; i++) { | |
b87bd7cd | 132 | Int_t ndet=fLayers[i].GetNdetectors(); |
133 | Int_t jmax = j + fLayers[i].GetNladders()*ndet; | |
61ab8ea8 | 134 | for (; j<jmax; j++) { |
135 | if (!cTree->GetEvent(j)) continue; | |
136 | Int_t ncl=clusters->GetEntriesFast(); | |
137 | while (ncl--) { | |
138 | AliITSclusterV2 *c=(AliITSclusterV2*)clusters->UncheckedAt(ncl); | |
61ab8ea8 | 139 | fLayers[i].InsertCluster(new AliITSclusterV2(*c)); |
140 | } | |
141 | clusters->Delete(); | |
142 | } | |
b87bd7cd | 143 | fLayers[i].ResetRoad(); //road defined by the cluster density |
006b5f7f | 144 | } |
61ab8ea8 | 145 | delete cTree; //Thanks to Mariana Bondila |
8676d691 | 146 | |
147 | return 0; | |
61ab8ea8 | 148 | } |
006b5f7f | 149 | |
61ab8ea8 | 150 | void AliITStrackerV2::UnloadClusters() { |
151 | //-------------------------------------------------------------------- | |
152 | //This function unloads ITS clusters | |
153 | //-------------------------------------------------------------------- | |
154 | for (Int_t i=0; i<kMaxLayer; i++) fLayers[i].ResetClusters(); | |
006b5f7f | 155 | } |
156 | ||
880f41b9 | 157 | static Int_t CorrectForDeadZoneMaterial(AliITStrackV2 *t) { |
158 | //-------------------------------------------------------------------- | |
159 | // Correction for the material between the TPC and the ITS | |
160 | // (should it belong to the TPC code ?) | |
161 | //-------------------------------------------------------------------- | |
162 | Double_t riw=80., diw=0.0053, x0iw=30; // TPC inner wall ? | |
163 | Double_t rcd=61., dcd=0.0053, x0cd=30; // TPC "central drum" ? | |
164 | Double_t yr=12.8, dr=0.03; // rods ? | |
165 | Double_t zm=0.2, dm=0.40; // membrane | |
166 | //Double_t rr=52., dr=0.19, x0r=24., yyr=7.77; //rails | |
167 | Double_t rs=50., ds=0.001; // something belonging to the ITS (screen ?) | |
168 | ||
169 | if (t->GetX() > riw) { | |
170 | if (!t->PropagateTo(riw,diw,x0iw)) return 1; | |
171 | if (TMath::Abs(t->GetY())>yr) t->CorrectForMaterial(dr); | |
172 | if (TMath::Abs(t->GetZ())<zm) t->CorrectForMaterial(dm); | |
173 | if (!t->PropagateTo(rcd,dcd,x0cd)) return 1; | |
174 | //Double_t x,y,z; t->GetGlobalXYZat(rr,x,y,z); | |
175 | //if (TMath::Abs(y)<yyr) t->PropagateTo(rr,dr,x0r); | |
176 | if (!t->PropagateTo(rs,ds)) return 1; | |
177 | } else if (t->GetX() < rs) { | |
178 | if (!t->PropagateTo(rs,-ds)) return 1; | |
179 | //Double_t x,y,z; t->GetGlobalXYZat(rr,x,y,z); | |
180 | //if (TMath::Abs(y)<yyr) t->PropagateTo(rr,-dr,x0r); | |
181 | if (!t->PropagateTo(rcd,-dcd,x0cd)) return 1; | |
182 | if (!t->PropagateTo(riw,-diw,x0iw)) return 1; | |
183 | } else { | |
184 | ::Error("CorrectForDeadZoneMaterial","track is already in the dead zone !"); | |
185 | return 1; | |
186 | } | |
187 | ||
188 | return 0; | |
189 | } | |
190 | ||
83d73500 | 191 | Int_t AliITStrackerV2::Clusters2Tracks(AliESD *event) { |
192 | //-------------------------------------------------------------------- | |
193 | // This functions reconstructs ITS tracks | |
194 | // The clusters must be already loaded ! | |
195 | //-------------------------------------------------------------------- | |
196 | TObjArray itsTracks(15000); | |
197 | ||
198 | {/* Read ESD tracks */ | |
199 | Int_t nentr=event->GetNumberOfTracks(); | |
200 | Info("Clusters2Tracks", "Number of ESD tracks: %d\n", nentr); | |
201 | while (nentr--) { | |
202 | AliESDtrack *esd=event->GetTrack(nentr); | |
203 | ||
204 | if (esd->GetStatus() != AliESDtrack::kTPCin) continue; | |
205 | ||
206 | AliITStrackV2 *t=0; | |
207 | try { | |
208 | t=new AliITStrackV2(*esd); | |
209 | } catch (const Char_t *msg) { | |
210 | Warning("Clusters2Tracks",msg); | |
211 | delete t; | |
212 | continue; | |
213 | } | |
214 | if (TMath::Abs(t->GetD())>4) continue; | |
215 | ||
216 | if (CorrectForDeadZoneMaterial(t)!=0) { | |
217 | Warning("Clusters2Tracks", | |
218 | "failed to correct for the material in the dead zone !\n"); | |
219 | delete t; | |
220 | continue; | |
221 | } | |
222 | itsTracks.AddLast(t); | |
223 | } | |
224 | } /* End Read ESD tracks */ | |
225 | ||
226 | itsTracks.Sort(); | |
227 | Int_t nentr=itsTracks.GetEntriesFast(); | |
228 | ||
229 | Int_t ntrk=0; | |
230 | for (fPass=0; fPass<2; fPass++) { | |
231 | Int_t &constraint=fConstraint[fPass]; if (constraint<0) continue; | |
232 | for (Int_t i=0; i<nentr; i++) { | |
233 | AliITStrackV2 *t=(AliITStrackV2*)itsTracks.UncheckedAt(i); | |
234 | if (t==0) continue; //this track has been already tracked | |
235 | Int_t tpcLabel=t->GetLabel(); //save the TPC track label | |
236 | ||
237 | ResetTrackToFollow(*t); | |
238 | ResetBestTrack(); | |
239 | ||
240 | for (FollowProlongation(); fI<kMaxLayer; fI++) { | |
241 | while (TakeNextProlongation()) FollowProlongation(); | |
242 | } | |
243 | ||
244 | if (fBestTrack.GetNumberOfClusters() == 0) continue; | |
245 | ||
246 | if (fConstraint[fPass]) { | |
247 | ResetTrackToFollow(*t); | |
248 | if (!RefitAt(3.7, &fTrackToFollow, &fBestTrack)) continue; | |
249 | ResetBestTrack(); | |
250 | } | |
251 | ||
252 | fBestTrack.SetLabel(tpcLabel); | |
253 | fBestTrack.CookdEdx(); | |
254 | CookLabel(&fBestTrack,0.); //For comparison only | |
255 | fBestTrack.UpdateESDtrack(AliESDtrack::kITSin); | |
256 | UseClusters(&fBestTrack); | |
257 | delete itsTracks.RemoveAt(i); | |
258 | ntrk++; | |
259 | } | |
260 | } | |
261 | ||
262 | itsTracks.Delete(); | |
263 | ||
264 | Info("Clusters2Tracks","Number of prolonged tracks: %d\n",ntrk); | |
265 | ||
266 | return 0; | |
267 | } | |
268 | ||
006b5f7f | 269 | Int_t AliITStrackerV2::Clusters2Tracks(const TFile *inp, TFile *out) { |
270 | //-------------------------------------------------------------------- | |
271 | //This functions reconstructs ITS tracks | |
272 | //-------------------------------------------------------------------- | |
273 | TFile *in=(TFile*)inp; | |
274 | TDirectory *savedir=gDirectory; | |
275 | ||
8676d691 | 276 | if (LoadClusters()!=0) return 1; |
61ab8ea8 | 277 | |
006b5f7f | 278 | if (!in->IsOpen()) { |
8676d691 | 279 | Error("Clusters2Tracks","file with TPC tracks is not open !\n"); |
280 | return 1; | |
006b5f7f | 281 | } |
282 | ||
283 | if (!out->IsOpen()) { | |
8676d691 | 284 | Error("Clusters2Tracks","file for ITS tracks is not open !\n"); |
285 | return 2; | |
006b5f7f | 286 | } |
287 | ||
7f6ddf58 | 288 | in->cd(); |
289 | ||
61ab8ea8 | 290 | Char_t tname[100]; |
a7554aa9 | 291 | Int_t nentr=0; TObjArray itsTracks(15000); |
7f6ddf58 | 292 | |
293 | {/* Read TPC tracks */ | |
61ab8ea8 | 294 | sprintf(tname,"TreeT_TPC_%d",GetEventNumber()); |
7f6ddf58 | 295 | TTree *tpcTree=(TTree*)in->Get(tname); |
296 | if (!tpcTree) { | |
8676d691 | 297 | Error("Clusters2Tracks","can't get a tree with TPC tracks !\n"); |
298 | return 3; | |
7f6ddf58 | 299 | } |
300 | AliTPCtrack *itrack=new AliTPCtrack; | |
301 | tpcTree->SetBranchAddress("tracks",&itrack); | |
302 | nentr=(Int_t)tpcTree->GetEntries(); | |
880f41b9 | 303 | |
304 | Info("Clusters2Tracks","Number of TPC tracks: %d\n",nentr); | |
305 | ||
7f6ddf58 | 306 | for (Int_t i=0; i<nentr; i++) { |
307 | tpcTree->GetEvent(i); | |
4ab260d6 | 308 | AliITStrackV2 *t=0; |
309 | try { | |
310 | t=new AliITStrackV2(*itrack); | |
311 | } catch (const Char_t *msg) { | |
8676d691 | 312 | Warning("Clusters2Tracks",msg); |
4ab260d6 | 313 | delete t; |
314 | continue; | |
315 | } | |
a9a2d814 | 316 | if (TMath::Abs(t->GetD())>4) continue; |
317 | ||
880f41b9 | 318 | if (CorrectForDeadZoneMaterial(t)!=0) { |
319 | Warning("Clusters2Tracks", | |
320 | "failed to correct for the material in the dead zone !\n"); | |
321 | continue; | |
322 | } | |
a9a2d814 | 323 | |
324 | itsTracks.AddLast(t); | |
7f6ddf58 | 325 | } |
326 | delete tpcTree; //Thanks to Mariana Bondila | |
327 | delete itrack; | |
006b5f7f | 328 | } |
7f6ddf58 | 329 | itsTracks.Sort(); |
880f41b9 | 330 | nentr=itsTracks.GetEntriesFast(); |
006b5f7f | 331 | |
332 | out->cd(); | |
7f6ddf58 | 333 | |
61ab8ea8 | 334 | sprintf(tname,"TreeT_ITS_%d",GetEventNumber()); |
7f6ddf58 | 335 | TTree itsTree(tname,"Tree with ITS tracks"); |
006b5f7f | 336 | AliITStrackV2 *otrack=&fBestTrack; |
337 | itsTree.Branch("tracks","AliITStrackV2",&otrack,32000,0); | |
338 | ||
7f6ddf58 | 339 | for (fPass=0; fPass<2; fPass++) { |
340 | Int_t &constraint=fConstraint[fPass]; if (constraint<0) continue; | |
341 | for (Int_t i=0; i<nentr; i++) { | |
7f6ddf58 | 342 | AliITStrackV2 *t=(AliITStrackV2*)itsTracks.UncheckedAt(i); |
343 | if (t==0) continue; //this track has been already tracked | |
344 | Int_t tpcLabel=t->GetLabel(); //save the TPC track label | |
a9a2d814 | 345 | |
4ab260d6 | 346 | ResetTrackToFollow(*t); |
7f6ddf58 | 347 | ResetBestTrack(); |
006b5f7f | 348 | |
7f6ddf58 | 349 | for (FollowProlongation(); fI<kMaxLayer; fI++) { |
350 | while (TakeNextProlongation()) FollowProlongation(); | |
351 | } | |
006b5f7f | 352 | |
c0dd5278 | 353 | if (fBestTrack.GetNumberOfClusters() == 0) continue; |
8676d691 | 354 | |
355 | if (fConstraint[fPass]) { | |
3a382e5c | 356 | ResetTrackToFollow(*t); |
357 | if (!RefitAt(3.7, &fTrackToFollow, &fBestTrack)) continue; | |
358 | ResetBestTrack(); | |
8676d691 | 359 | } |
4ab260d6 | 360 | |
8676d691 | 361 | fBestTrack.SetLabel(tpcLabel); |
362 | fBestTrack.CookdEdx(); | |
363 | CookLabel(&fBestTrack,0.); //For comparison only | |
364 | itsTree.Fill(); | |
365 | UseClusters(&fBestTrack); | |
366 | delete itsTracks.RemoveAt(i); | |
7f6ddf58 | 367 | } |
006b5f7f | 368 | } |
006b5f7f | 369 | |
880f41b9 | 370 | nentr=(Int_t)itsTree.GetEntries(); |
371 | Info("Clusters2Tracks","Number of prolonged tracks: %d\n",nentr); | |
8676d691 | 372 | |
7f6ddf58 | 373 | itsTree.Write(); |
c7ee21ca | 374 | |
7f6ddf58 | 375 | itsTracks.Delete(); |
61ab8ea8 | 376 | |
377 | UnloadClusters(); | |
378 | ||
7f6ddf58 | 379 | savedir->cd(); |
006b5f7f | 380 | return 0; |
381 | } | |
382 | ||
83d73500 | 383 | Int_t AliITStrackerV2::PropagateBack(AliESD *event) { |
384 | //-------------------------------------------------------------------- | |
385 | // This functions propagates reconstructed ITS tracks back | |
386 | // The clusters must be loaded ! | |
387 | //-------------------------------------------------------------------- | |
388 | Int_t nentr=event->GetNumberOfTracks(); | |
389 | Info("PropagateBack", "Number of ESD tracks: %d\n", nentr); | |
390 | ||
391 | Int_t ntrk=0; | |
392 | for (Int_t i=0; i<nentr; i++) { | |
393 | AliESDtrack *esd=event->GetTrack(i); | |
394 | ||
395 | if (esd->GetStatus()!=(AliESDtrack::kTPCin|AliESDtrack::kITSin)) continue; | |
396 | ||
397 | AliITStrackV2 *t=0; | |
398 | try { | |
399 | t=new AliITStrackV2(*esd); | |
400 | } catch (const Char_t *msg) { | |
401 | Warning("PropagateBack",msg); | |
402 | delete t; | |
403 | continue; | |
404 | } | |
405 | ||
406 | ResetTrackToFollow(*t); | |
407 | ||
408 | // propagete to vertex [SR, GSI 17.02.2003] | |
409 | fTrackToFollow.PropagateTo(3.,0.0028,65.19); | |
410 | fTrackToFollow.PropagateToVertex(); | |
411 | ||
412 | // Start Time measurement [SR, GSI 17.02.2003] | |
413 | fTrackToFollow.StartTimeIntegral(); | |
414 | fTrackToFollow.PropagateTo(3.,-0.0028,65.19); | |
415 | ||
416 | fTrackToFollow.ResetCovariance(); fTrackToFollow.ResetClusters(); | |
417 | if (RefitAt(49.,&fTrackToFollow,t)) { | |
418 | if (CorrectForDeadZoneMaterial(&fTrackToFollow)!=0) { | |
419 | Warning("PropagateBack", | |
420 | "failed to correct for the material in the dead zone !\n"); | |
421 | delete t; | |
422 | continue; | |
423 | } | |
424 | fTrackToFollow.SetLabel(t->GetLabel()); | |
425 | fTrackToFollow.CookdEdx(); | |
426 | CookLabel(&fTrackToFollow,0.); //For comparison only | |
427 | fTrackToFollow.UpdateESDtrack(AliESDtrack::kITSout); | |
428 | UseClusters(&fTrackToFollow); | |
429 | ntrk++; | |
430 | } | |
431 | delete t; | |
432 | } | |
433 | ||
434 | Info("PropagateBack","Number of back propagated ITS tracks: %d\n",ntrk); | |
435 | ||
436 | return 0; | |
437 | } | |
438 | ||
14825d5a | 439 | Int_t AliITStrackerV2::PropagateBack(const TFile *inp, TFile *out) { |
440 | //-------------------------------------------------------------------- | |
441 | //This functions propagates reconstructed ITS tracks back | |
442 | //-------------------------------------------------------------------- | |
443 | TFile *in=(TFile*)inp; | |
444 | TDirectory *savedir=gDirectory; | |
445 | ||
8676d691 | 446 | if (LoadClusters()!=0) return 1; |
61ab8ea8 | 447 | |
14825d5a | 448 | if (!in->IsOpen()) { |
8676d691 | 449 | Error("PropagateBack","file with ITS tracks is not open !\n"); |
450 | return 1; | |
14825d5a | 451 | } |
452 | ||
453 | if (!out->IsOpen()) { | |
8676d691 | 454 | Error("PropagateBack","file for back propagated ITS tracks is not open !\n"); |
455 | return 2; | |
14825d5a | 456 | } |
457 | ||
458 | in->cd(); | |
61ab8ea8 | 459 | |
460 | Char_t tname[100]; | |
461 | sprintf(tname,"TreeT_ITS_%d",GetEventNumber()); | |
462 | TTree *itsTree=(TTree*)in->Get(tname); | |
14825d5a | 463 | if (!itsTree) { |
8676d691 | 464 | Error("PropagateBack","can't get a tree with ITS tracks !\n"); |
465 | return 3; | |
14825d5a | 466 | } |
467 | AliITStrackV2 *itrack=new AliITStrackV2; | |
468 | itsTree->SetBranchAddress("tracks",&itrack); | |
469 | ||
470 | out->cd(); | |
61ab8ea8 | 471 | |
472 | sprintf(tname,"TreeT_ITSb_%d",GetEventNumber()); | |
473 | TTree backTree(tname,"Tree with back propagated ITS tracks"); | |
14825d5a | 474 | AliTPCtrack *otrack=0; |
f29dbb4b | 475 | backTree.Branch("tracks","AliTPCtrack",&otrack,32000,2); |
14825d5a | 476 | |
14825d5a | 477 | Int_t nentr=(Int_t)itsTree->GetEntries(); |
880f41b9 | 478 | Int_t i; |
479 | for (i=0; i<nentr; i++) { | |
14825d5a | 480 | itsTree->GetEvent(i); |
880f41b9 | 481 | Int_t itsLabel=itrack->GetLabel(); //save the ITS track label |
14825d5a | 482 | ResetTrackToFollow(*itrack); |
f29dbb4b | 483 | |
484 | // propagete to vertex [SR, GSI 17.02.2003] | |
485 | fTrackToFollow.PropagateTo(3.,0.0028,65.19); | |
486 | fTrackToFollow.PropagateToVertex(); | |
487 | ||
488 | // Start Time measurement [SR, GSI 17.02.2003] | |
489 | fTrackToFollow.StartTimeIntegral(); | |
490 | fTrackToFollow.PropagateTo(3.,-0.0028,65.19); | |
491 | // | |
492 | ||
3a382e5c | 493 | fTrackToFollow.ResetCovariance(); fTrackToFollow.ResetClusters(); |
494 | if (!RefitAt(49.,&fTrackToFollow,itrack)) continue; | |
f29dbb4b | 495 | |
880f41b9 | 496 | if (CorrectForDeadZoneMaterial(&fTrackToFollow)!=0) { |
497 | Warning("PropagateBack", | |
498 | "failed to correct for the material in the dead zone !\n"); | |
499 | continue; | |
500 | } | |
501 | ||
502 | fTrackToFollow.SetLabel(itsLabel); | |
503 | otrack=new AliTPCtrack(fTrackToFollow,fTrackToFollow.GetAlpha()); | |
504 | backTree.Fill(); delete otrack; | |
505 | UseClusters(&fTrackToFollow); | |
506 | } | |
507 | i=(Int_t)backTree.GetEntries(); | |
508 | backTree.Write(); | |
14825d5a | 509 | |
880f41b9 | 510 | Info("PropagateBack","Number of ITS tracks: %d\n",nentr); |
511 | Info("PropagateBack","Number of back propagated ITS tracks: %d\n",i); | |
f29dbb4b | 512 | |
880f41b9 | 513 | delete itrack; |
514 | delete itsTree; //Thanks to Mariana Bondila | |
515 | ||
516 | UnloadClusters(); | |
517 | ||
518 | savedir->cd(); | |
519 | ||
520 | return 0; | |
521 | } | |
522 | ||
83d73500 | 523 | Int_t AliITStrackerV2::RefitInward(AliESD *event) { |
524 | //-------------------------------------------------------------------- | |
525 | // This functions refits ITS tracks using the | |
526 | // "inward propagated" TPC tracks | |
527 | // The clusters must be loaded ! | |
528 | //-------------------------------------------------------------------- | |
529 | Int_t nentr=event->GetNumberOfTracks(); | |
530 | Info("RefitInward", "Number of ESD tracks: %d\n", nentr); | |
531 | ||
532 | Int_t ntrk=0; | |
533 | for (Int_t i=0; i<nentr; i++) { | |
534 | AliESDtrack *esd=event->GetTrack(i); | |
535 | ||
536 | ULong_t flags = AliESDtrack::kITSin | AliESDtrack::kTPCrefit; | |
537 | ||
538 | if ( (esd->GetStatus() & flags) != flags ) continue; | |
539 | if ( esd->GetStatus() & AliESDtrack::kITSrefit) continue; | |
540 | ||
541 | AliITStrackV2 *t=0; | |
542 | try { | |
543 | t=new AliITStrackV2(*esd); | |
544 | } catch (const Char_t *msg) { | |
545 | Warning("RefitInward",msg); | |
546 | delete t; | |
547 | continue; | |
548 | } | |
549 | ||
550 | if (CorrectForDeadZoneMaterial(t)!=0) { | |
551 | Warning("RefitInward", | |
552 | "failed to correct for the material in the dead zone !\n"); | |
553 | delete t; | |
554 | continue; | |
555 | } | |
556 | ||
557 | ResetTrackToFollow(*t); | |
558 | ||
559 | //Refitting... | |
560 | if (RefitAt(3.7, &fTrackToFollow, t)) { | |
561 | fTrackToFollow.SetLabel(t->GetLabel()); | |
562 | fTrackToFollow.CookdEdx(); | |
563 | CookLabel(&fTrackToFollow,0.); //For comparison only | |
564 | fTrackToFollow.UpdateESDtrack(AliESDtrack::kITSrefit); | |
565 | UseClusters(&fTrackToFollow); | |
566 | ntrk++; | |
567 | } | |
568 | delete t; | |
569 | } | |
570 | ||
571 | Info("RefitInward","Number of refitted tracks: %d\n",ntrk); | |
572 | ||
573 | return 0; | |
574 | } | |
575 | ||
880f41b9 | 576 | Int_t AliITStrackerV2::RefitInward(const TFile *inp, TFile *out) { |
577 | //-------------------------------------------------------------------- | |
578 | // This functions refits ITS tracks using the | |
579 | // "inward propagated" TPC tracks | |
580 | //-------------------------------------------------------------------- | |
581 | TFile *in=(TFile*)inp; | |
582 | TDirectory *savedir=gDirectory; | |
14825d5a | 583 | |
880f41b9 | 584 | if (LoadClusters()!=0) return 1; |
585 | ||
586 | if (!in->IsOpen()) { | |
587 | Error("RefitInward","file with inward TPC tracks is not open !\n"); | |
588 | return 2; | |
589 | } | |
590 | ||
591 | if (!out->IsOpen()) { | |
592 | Error("RefitInward","file for inward ITS tracks is not open !\n"); | |
593 | return 3; | |
594 | } | |
595 | ||
596 | Int_t i; | |
597 | ||
598 | //LUT used for the track matching (S.Radomski's idea) | |
599 | const Int_t nLab = 400000; // limit on the number of track labels | |
600 | Int_t lut[nLab]; | |
601 | for(i=0; i<nLab; i++) lut[i] = -1; | |
602 | ||
603 | Char_t tname[100]; | |
604 | ||
605 | TObjArray itsTracks(15000); | |
606 | {/* Read the ITS tracks */ | |
607 | sprintf(tname,"TreeT_ITS_%d",GetEventNumber()); | |
608 | TTree *itsTree=(TTree*)out->Get(tname); | |
609 | if (!itsTree) { | |
610 | Error("RefitInward","can't get a tree with ITS tracks !\n"); | |
611 | return 3; | |
14825d5a | 612 | } |
880f41b9 | 613 | AliITStrackV2 *itrack=new AliITStrackV2; |
614 | itsTree->SetBranchAddress("tracks",&itrack); | |
615 | Int_t nits=(Int_t)itsTree->GetEntries(); | |
616 | ||
617 | Info("RefitInward","Number of ITS tracks: %d\n",nits); | |
618 | ||
619 | for (Int_t i=0; i<nits; i++) { | |
620 | itsTree->GetEvent(i); | |
621 | Int_t lab=TMath::Abs(itrack->GetLabel()); | |
622 | if (lab < nLab) { | |
623 | if (lut[lab]>=0) Warning("RefitInward","double track %d\n",lab); | |
624 | lut[lab]=i; | |
625 | } else { | |
626 | Warning("RefitInward","Too big ITS track label: %d\n!",lab); | |
627 | continue; | |
628 | } | |
629 | itsTracks.AddLast(new AliITStrackV2(*itrack)); | |
14825d5a | 630 | } |
880f41b9 | 631 | delete itsTree; |
632 | delete itrack; | |
14825d5a | 633 | } |
634 | ||
880f41b9 | 635 | out->cd(); |
636 | ||
637 | //Create the output tree | |
638 | sprintf(tname,"TreeT_ITSinward_%d",GetEventNumber()); | |
639 | TTree outTree(tname,"Tree with inward refitted ITS tracks"); | |
640 | AliITStrackV2 *otrack=0; | |
641 | outTree.Branch("tracks","AliITStrackV2",&otrack,32000,0); | |
642 | ||
643 | //Get the input tree | |
644 | sprintf(tname,"tracksTPC_%d",GetEventNumber()); | |
645 | TTree *tpcTree=(TTree*)in->Get(tname); | |
646 | if (!tpcTree) { | |
647 | Error("RefitInward","can't get a tree with TPC tracks !\n"); | |
648 | return 3; | |
649 | } | |
650 | AliTPCtrack *itrack=new AliTPCtrack; | |
651 | tpcTree->SetBranchAddress("tracks",&itrack); | |
652 | Int_t ntpc=(Int_t)tpcTree->GetEntries(); | |
61ab8ea8 | 653 | |
880f41b9 | 654 | Info("RefitInward","Number of TPC tracks: %d\n",ntpc); |
14825d5a | 655 | |
880f41b9 | 656 | for (i=0; i<ntpc; i++) { |
657 | tpcTree->GetEvent(i); | |
880f41b9 | 658 | try { |
3a382e5c | 659 | otrack=new AliITStrackV2(*itrack); |
880f41b9 | 660 | } catch (const Char_t *msg) { |
661 | Warning("RefitInward",msg); | |
3a382e5c | 662 | delete otrack; |
880f41b9 | 663 | continue; |
664 | } | |
665 | //check if this track was reconstructed in the ITS | |
3a382e5c | 666 | Int_t lab=TMath::Abs(otrack->GetLabel()); |
880f41b9 | 667 | if (lab >= nLab) { |
668 | Warning("RefitInward","Too big TPC track label: %d\n!",lab); | |
669 | continue; | |
670 | } | |
671 | Int_t idx=lut[lab]; | |
672 | if (idx<0) continue; //no prolongation in the ITS for this track | |
673 | ||
3a382e5c | 674 | if (CorrectForDeadZoneMaterial(otrack)!=0) { |
880f41b9 | 675 | Warning("RefitInward", |
676 | "failed to correct for the material in the dead zone !\n"); | |
677 | continue; | |
678 | } | |
14825d5a | 679 | |
880f41b9 | 680 | //Refitting... |
3a382e5c | 681 | { |
682 | AliITStrackV2 *ctrack=(AliITStrackV2*)itsTracks.UncheckedAt(idx); | |
683 | if (!RefitAt(3.7, otrack, ctrack)) continue; | |
684 | } | |
880f41b9 | 685 | otrack->SetLabel(itrack->GetLabel()); //For comparison only |
686 | otrack->CookdEdx(); | |
687 | CookLabel(otrack,0.); //For comparison only | |
688 | outTree.Fill(); | |
3a382e5c | 689 | delete otrack; |
880f41b9 | 690 | } |
691 | i=(Int_t)outTree.GetEntries(); | |
692 | Info("RefitInward","Number of inward refitted ITS tracks: %d\n",i); | |
693 | outTree.Write(); | |
c7ee21ca | 694 | |
880f41b9 | 695 | delete tpcTree; |
696 | delete itrack; | |
83d73500 | 697 | UnloadClusters(); |
880f41b9 | 698 | itsTracks.Delete(); |
61ab8ea8 | 699 | |
700 | savedir->cd(); | |
701 | ||
14825d5a | 702 | return 0; |
703 | } | |
006b5f7f | 704 | |
705 | AliCluster *AliITStrackerV2::GetCluster(Int_t index) const { | |
706 | //-------------------------------------------------------------------- | |
707 | // Return pointer to a given cluster | |
708 | //-------------------------------------------------------------------- | |
709 | Int_t l=(index & 0xf0000000) >> 28; | |
710 | Int_t c=(index & 0x0fffffff) >> 00; | |
711 | return fLayers[l].GetCluster(c); | |
712 | } | |
713 | ||
714 | ||
715 | void AliITStrackerV2::FollowProlongation() { | |
716 | //-------------------------------------------------------------------- | |
717 | //This function finds a track prolongation | |
718 | //-------------------------------------------------------------------- | |
c0dd5278 | 719 | while (fI>fLastLayerToTrackTo) { |
a9a2d814 | 720 | Int_t i=fI-1; |
8676d691 | 721 | |
a9a2d814 | 722 | AliITSlayer &layer=fLayers[i]; |
723 | AliITStrackV2 &track=fTracks[i]; | |
006b5f7f | 724 | |
14825d5a | 725 | Double_t r=layer.GetR(); |
61ab8ea8 | 726 | |
a9a2d814 | 727 | if (i==3 || i==1) { |
728 | Double_t rs=0.5*(fLayers[i+1].GetR() + r); | |
61ab8ea8 | 729 | Double_t d=0.0034, x0=38.6; |
730 | if (i==1) {rs=9.; d=0.0097; x0=42;} | |
731 | if (!fTrackToFollow.PropagateTo(rs,d,x0)) { | |
8676d691 | 732 | //Warning("FollowProlongation","propagation failed !\n"); |
c0dd5278 | 733 | return; |
a9a2d814 | 734 | } |
006b5f7f | 735 | } |
736 | ||
737 | //find intersection | |
738 | Double_t x,y,z; | |
14825d5a | 739 | if (!fTrackToFollow.GetGlobalXYZat(r,x,y,z)) { |
8676d691 | 740 | //Warning("FollowProlongation","failed to estimate track !\n"); |
c0dd5278 | 741 | return; |
006b5f7f | 742 | } |
743 | Double_t phi=TMath::ATan2(y,x); | |
006b5f7f | 744 | Int_t idet=layer.FindDetectorIndex(phi,z); |
745 | if (idet<0) { | |
8676d691 | 746 | //Warning("FollowProlongation","failed to find a detector !\n"); |
c0dd5278 | 747 | return; |
006b5f7f | 748 | } |
749 | ||
750 | //propagate to the intersection | |
751 | const AliITSdetector &det=layer.GetDetector(idet); | |
14825d5a | 752 | phi=det.GetPhi(); |
a9a2d814 | 753 | if (!fTrackToFollow.Propagate(phi,det.GetR())) { |
8676d691 | 754 | //Warning("FollowProlongation","propagation failed !\n"); |
c0dd5278 | 755 | return; |
006b5f7f | 756 | } |
757 | fTrackToFollow.SetDetectorIndex(idet); | |
758 | ||
759 | //Select possible prolongations and store the current track estimation | |
760 | track.~AliITStrackV2(); new(&track) AliITStrackV2(fTrackToFollow); | |
8676d691 | 761 | Double_t dz=7*TMath::Sqrt(track.GetSigmaZ2() + kSigmaZ2[i]); |
762 | Double_t dy=7*TMath::Sqrt(track.GetSigmaY2() + kSigmaY2[i]); | |
763 | Double_t road=layer.GetRoad(); | |
764 | if (dz*dy>road*road) { | |
765 | Double_t dd=TMath::Sqrt(dz*dy), scz=dz/dd, scy=dy/dd; | |
766 | dz=road*scz; dy=road*scy; | |
767 | } | |
b87bd7cd | 768 | |
769 | //Double_t dz=4*TMath::Sqrt(track.GetSigmaZ2() + kSigmaZ2[i]); | |
14825d5a | 770 | if (dz < 0.5*TMath::Abs(track.GetTgl())) dz=0.5*TMath::Abs(track.GetTgl()); |
7f6ddf58 | 771 | if (dz > kMaxRoad) { |
8676d691 | 772 | //Warning("FollowProlongation","too broad road in Z !\n"); |
c0dd5278 | 773 | return; |
006b5f7f | 774 | } |
a9a2d814 | 775 | |
c0dd5278 | 776 | if (TMath::Abs(fTrackToFollow.GetZ()-GetZ()) > r+dz) return; |
a9a2d814 | 777 | |
b87bd7cd | 778 | //Double_t dy=4*TMath::Sqrt(track.GetSigmaY2() + kSigmaY2[i]); |
14825d5a | 779 | if (dy < 0.5*TMath::Abs(track.GetSnp())) dy=0.5*TMath::Abs(track.GetSnp()); |
7f6ddf58 | 780 | if (dy > kMaxRoad) { |
8676d691 | 781 | //Warning("FollowProlongation","too broad road in Y !\n"); |
c0dd5278 | 782 | return; |
006b5f7f | 783 | } |
a9a2d814 | 784 | |
7f6ddf58 | 785 | Double_t zmin=track.GetZ() - dz; |
006b5f7f | 786 | Double_t zmax=track.GetZ() + dz; |
14825d5a | 787 | Double_t ymin=track.GetY() + r*phi - dy; |
788 | Double_t ymax=track.GetY() + r*phi + dy; | |
a9a2d814 | 789 | layer.SelectClusters(zmin,zmax,ymin,ymax); |
790 | fI--; | |
006b5f7f | 791 | |
006b5f7f | 792 | //take another prolongation |
c0dd5278 | 793 | if (!TakeNextProlongation()) |
794 | if (fLayersNotToSkip[fI]) return; | |
006b5f7f | 795 | |
796 | } | |
797 | ||
798 | //deal with the best track | |
799 | Int_t ncl=fTrackToFollow.GetNumberOfClusters(); | |
800 | Int_t nclb=fBestTrack.GetNumberOfClusters(); | |
801 | if (ncl) | |
802 | if (ncl >= nclb) { | |
803 | Double_t chi2=fTrackToFollow.GetChi2(); | |
804 | if (chi2/ncl < kChi2PerCluster) { | |
805 | if (ncl > nclb || chi2 < fBestTrack.GetChi2()) { | |
806 | ResetBestTrack(); | |
807 | } | |
808 | } | |
809 | } | |
810 | ||
006b5f7f | 811 | } |
812 | ||
006b5f7f | 813 | Int_t AliITStrackerV2::TakeNextProlongation() { |
814 | //-------------------------------------------------------------------- | |
a9a2d814 | 815 | // This function takes another track prolongation |
816 | // | |
817 | // dEdx analysis by: Boris Batyunya, JINR, Boris.Batiounia@cern.ch | |
006b5f7f | 818 | //-------------------------------------------------------------------- |
006b5f7f | 819 | AliITSlayer &layer=fLayers[fI]; |
4ab260d6 | 820 | ResetTrackToFollow(fTracks[fI]); |
006b5f7f | 821 | |
b87bd7cd | 822 | Double_t dz=7*TMath::Sqrt(fTrackToFollow.GetSigmaZ2() + kSigmaZ2[fI]); |
823 | Double_t dy=7*TMath::Sqrt(fTrackToFollow.GetSigmaY2() + kSigmaY2[fI]); | |
8676d691 | 824 | Double_t road=layer.GetRoad(); |
825 | if (dz*dy>road*road) { | |
826 | Double_t dd=TMath::Sqrt(dz*dy), scz=dz/dd, scy=dy/dd; | |
827 | dz=road*scz; dy=road*scy; | |
828 | } | |
006b5f7f | 829 | |
830 | const AliITSclusterV2 *c=0; Int_t ci=-1; | |
831 | Double_t chi2=12345.; | |
832 | while ((c=layer.GetNextCluster(ci))!=0) { | |
006b5f7f | 833 | Int_t idet=c->GetDetectorIndex(); |
834 | ||
4ab260d6 | 835 | if (fTrackToFollow.GetDetectorIndex()!=idet) { |
006b5f7f | 836 | const AliITSdetector &det=layer.GetDetector(idet); |
4ab260d6 | 837 | ResetTrackToFollow(fTracks[fI]); |
838 | if (!fTrackToFollow.Propagate(det.GetPhi(),det.GetR())) { | |
8676d691 | 839 | //Warning("TakeNextProlongation","propagation failed !\n"); |
006b5f7f | 840 | continue; |
841 | } | |
4ab260d6 | 842 | fTrackToFollow.SetDetectorIndex(idet); |
843 | if (TMath::Abs(fTrackToFollow.GetZ()-GetZ())>layer.GetR()+dz) continue; | |
006b5f7f | 844 | } |
845 | ||
4ab260d6 | 846 | if (TMath::Abs(fTrackToFollow.GetZ() - c->GetZ()) > dz) continue; |
847 | if (TMath::Abs(fTrackToFollow.GetY() - c->GetY()) > dy) continue; | |
006b5f7f | 848 | |
4ab260d6 | 849 | chi2=fTrackToFollow.GetPredictedChi2(c); if (chi2<kMaxChi2) break; |
006b5f7f | 850 | } |
851 | ||
006b5f7f | 852 | if (chi2>=kMaxChi2) return 0; |
853 | if (!c) return 0; | |
854 | ||
006b5f7f | 855 | if (!fTrackToFollow.Update(c,chi2,(fI<<28)+ci)) { |
8676d691 | 856 | //Warning("TakeNextProlongation","filtering failed !\n"); |
006b5f7f | 857 | return 0; |
858 | } | |
23efe5f1 | 859 | |
4ab260d6 | 860 | if (fTrackToFollow.GetNumberOfClusters()>1) |
861 | if (TMath::Abs(fTrackToFollow.GetD())>4) return 0; | |
862 | ||
a9a2d814 | 863 | fTrackToFollow. |
864 | SetSampledEdx(c->GetQ(),fTrackToFollow.GetNumberOfClusters()-1); //b.b. | |
865 | ||
866 | { | |
880f41b9 | 867 | Double_t x0; |
61ab8ea8 | 868 | Double_t d=layer.GetThickness(fTrackToFollow.GetY(),fTrackToFollow.GetZ(),x0); |
880f41b9 | 869 | fTrackToFollow.CorrectForMaterial(d,x0); |
a9a2d814 | 870 | } |
4ab260d6 | 871 | |
a9a2d814 | 872 | if (fConstraint[fPass]) { |
4ab260d6 | 873 | Double_t d=GetEffectiveThickness(0,0); //Think of this !!!! |
8676d691 | 874 | Double_t xyz[]={GetX(),GetY(),GetZ()}; |
875 | Double_t ers[]={GetSigmaX(),GetSigmaY(),GetSigmaZ()}; | |
876 | fTrackToFollow.Improve(d,xyz,ers); | |
a9a2d814 | 877 | } |
006b5f7f | 878 | |
006b5f7f | 879 | return 1; |
880 | } | |
881 | ||
882 | ||
006b5f7f | 883 | AliITStrackerV2::AliITSlayer::AliITSlayer() { |
884 | //-------------------------------------------------------------------- | |
885 | //default AliITSlayer constructor | |
886 | //-------------------------------------------------------------------- | |
887 | fN=0; | |
888 | fDetectors=0; | |
889 | } | |
890 | ||
891 | AliITStrackerV2::AliITSlayer:: | |
892 | AliITSlayer(Double_t r,Double_t p,Double_t z,Int_t nl,Int_t nd) { | |
893 | //-------------------------------------------------------------------- | |
894 | //main AliITSlayer constructor | |
895 | //-------------------------------------------------------------------- | |
896 | fR=r; fPhiOffset=p; fZOffset=z; | |
897 | fNladders=nl; fNdetectors=nd; | |
898 | fDetectors=new AliITSdetector[fNladders*fNdetectors]; | |
899 | ||
900 | fN=0; | |
901 | fI=0; | |
b87bd7cd | 902 | |
903 | fRoad=2*fR*TMath::Sqrt(3.14/1.);//assuming that there's only one cluster | |
006b5f7f | 904 | } |
905 | ||
906 | AliITStrackerV2::AliITSlayer::~AliITSlayer() { | |
907 | //-------------------------------------------------------------------- | |
908 | // AliITSlayer destructor | |
909 | //-------------------------------------------------------------------- | |
910 | delete[] fDetectors; | |
911 | for (Int_t i=0; i<fN; i++) delete fClusters[i]; | |
912 | } | |
913 | ||
61ab8ea8 | 914 | void AliITStrackerV2::AliITSlayer::ResetClusters() { |
915 | //-------------------------------------------------------------------- | |
916 | // This function removes loaded clusters | |
917 | //-------------------------------------------------------------------- | |
918 | for (Int_t i=0; i<fN; i++) delete fClusters[i]; | |
919 | fN=0; | |
920 | fI=0; | |
921 | } | |
922 | ||
b87bd7cd | 923 | void AliITStrackerV2::AliITSlayer::ResetRoad() { |
924 | //-------------------------------------------------------------------- | |
925 | // This function calculates the road defined by the cluster density | |
926 | //-------------------------------------------------------------------- | |
927 | Int_t n=0; | |
928 | for (Int_t i=0; i<fN; i++) { | |
929 | if (TMath::Abs(fClusters[i]->GetZ())<fR) n++; | |
930 | } | |
931 | if (n>1) fRoad=2*fR*TMath::Sqrt(3.14/n); | |
932 | } | |
933 | ||
006b5f7f | 934 | Int_t AliITStrackerV2::AliITSlayer::InsertCluster(AliITSclusterV2 *c) { |
935 | //-------------------------------------------------------------------- | |
936 | //This function adds a cluster to this layer | |
937 | //-------------------------------------------------------------------- | |
938 | if (fN==kMaxClusterPerLayer) { | |
8676d691 | 939 | ::Error("InsertCluster","Too many clusters !\n"); |
940 | return 1; | |
006b5f7f | 941 | } |
942 | ||
943 | if (fN==0) {fClusters[fN++]=c; return 0;} | |
944 | Int_t i=FindClusterIndex(c->GetZ()); | |
945 | memmove(fClusters+i+1 ,fClusters+i,(fN-i)*sizeof(AliITSclusterV2*)); | |
946 | fClusters[i]=c; fN++; | |
947 | ||
948 | return 0; | |
949 | } | |
950 | ||
951 | Int_t AliITStrackerV2::AliITSlayer::FindClusterIndex(Double_t z) const { | |
952 | //-------------------------------------------------------------------- | |
953 | // This function returns the index of the nearest cluster | |
954 | //-------------------------------------------------------------------- | |
955 | if (fN==0) return 0; | |
956 | if (z <= fClusters[0]->GetZ()) return 0; | |
957 | if (z > fClusters[fN-1]->GetZ()) return fN; | |
958 | Int_t b=0, e=fN-1, m=(b+e)/2; | |
959 | for (; b<e; m=(b+e)/2) { | |
960 | if (z > fClusters[m]->GetZ()) b=m+1; | |
961 | else e=m; | |
962 | } | |
963 | return m; | |
964 | } | |
965 | ||
966 | void AliITStrackerV2::AliITSlayer:: | |
967 | SelectClusters(Double_t zmin,Double_t zmax,Double_t ymin, Double_t ymax) { | |
968 | //-------------------------------------------------------------------- | |
969 | // This function sets the "window" | |
970 | //-------------------------------------------------------------------- | |
971 | fI=FindClusterIndex(zmin); fZmax=zmax; | |
14825d5a | 972 | Double_t circle=2*TMath::Pi()*fR; |
973 | if (ymax>circle) { ymax-=circle; ymin-=circle; } | |
006b5f7f | 974 | fYmin=ymin; fYmax=ymax; |
975 | } | |
976 | ||
977 | const AliITSclusterV2 *AliITStrackerV2::AliITSlayer::GetNextCluster(Int_t &ci){ | |
978 | //-------------------------------------------------------------------- | |
979 | // This function returns clusters within the "window" | |
980 | //-------------------------------------------------------------------- | |
981 | const AliITSclusterV2 *cluster=0; | |
982 | for (Int_t i=fI; i<fN; i++) { | |
983 | const AliITSclusterV2 *c=fClusters[i]; | |
984 | if (c->GetZ() > fZmax) break; | |
985 | if (c->IsUsed()) continue; | |
986 | const AliITSdetector &det=GetDetector(c->GetDetectorIndex()); | |
987 | Double_t y=fR*det.GetPhi() + c->GetY(); | |
988 | ||
989 | if (y>2.*fR*TMath::Pi()) y -= 2*fR*TMath::Pi(); | |
990 | if (y>1.*fR*TMath::Pi() && fYmax<y) y -= 2*fR*TMath::Pi(); | |
991 | ||
992 | if (y<fYmin) continue; | |
993 | if (y>fYmax) continue; | |
994 | cluster=c; ci=i; | |
995 | fI=i+1; | |
996 | break; | |
997 | } | |
7f6ddf58 | 998 | |
006b5f7f | 999 | return cluster; |
1000 | } | |
1001 | ||
1002 | Int_t AliITStrackerV2::AliITSlayer:: | |
1003 | FindDetectorIndex(Double_t phi, Double_t z) const { | |
1004 | //-------------------------------------------------------------------- | |
1005 | //This function finds the detector crossed by the track | |
1006 | //-------------------------------------------------------------------- | |
1007 | Double_t dphi=phi-fPhiOffset; | |
1008 | if (dphi < 0) dphi += 2*TMath::Pi(); | |
1009 | else if (dphi >= 2*TMath::Pi()) dphi -= 2*TMath::Pi(); | |
1010 | Int_t np=Int_t(dphi*fNladders*0.5/TMath::Pi()+0.5); | |
3e3e8427 | 1011 | if (np>=fNladders) np-=fNladders; |
1012 | if (np<0) np+=fNladders; | |
006b5f7f | 1013 | |
1014 | Double_t dz=fZOffset-z; | |
1015 | Int_t nz=Int_t(dz*(fNdetectors-1)*0.5/fZOffset+0.5); | |
3e3e8427 | 1016 | if (nz>=fNdetectors) return -1; |
1017 | if (nz<0) return -1; | |
006b5f7f | 1018 | |
006b5f7f | 1019 | return np*fNdetectors + nz; |
1020 | } | |
1021 | ||
1022 | Double_t | |
61ab8ea8 | 1023 | AliITStrackerV2::AliITSlayer::GetThickness(Double_t y,Double_t z,Double_t &x0) |
1024 | const { | |
a9a2d814 | 1025 | //-------------------------------------------------------------------- |
1026 | //This function returns the layer thickness at this point (units X0) | |
1027 | //-------------------------------------------------------------------- | |
1028 | Double_t d=0.0085; | |
61ab8ea8 | 1029 | x0=21.82; |
a9a2d814 | 1030 | |
1031 | if (43<fR&&fR<45) { //SSD2 | |
61ab8ea8 | 1032 | Double_t dd=0.0034; |
1033 | d=dd; | |
1034 | if (TMath::Abs(y-0.00)>3.40) d+=dd; | |
1035 | if (TMath::Abs(y-1.90)<0.45) {d+=(0.013-0.0034);} | |
1036 | if (TMath::Abs(y+1.90)<0.45) {d+=(0.013-0.0034);} | |
a9a2d814 | 1037 | for (Int_t i=0; i<12; i++) { |
61ab8ea8 | 1038 | if (TMath::Abs(z-3.9*(i+0.5))<0.15) { |
1039 | if (TMath::Abs(y-0.00)>3.40) d+=dd; | |
1040 | d+=0.0034; | |
1041 | break; | |
1042 | } | |
1043 | if (TMath::Abs(z+3.9*(i+0.5))<0.15) { | |
1044 | if (TMath::Abs(y-0.00)>3.40) d+=dd; | |
1045 | d+=0.0034; | |
1046 | break; | |
1047 | } | |
1048 | if (TMath::Abs(z-3.4-3.9*i)<0.50) {d+=(0.016-0.0034); break;} | |
1049 | if (TMath::Abs(z+0.5+3.9*i)<0.50) {d+=(0.016-0.0034); break;} | |
a9a2d814 | 1050 | } |
1051 | } else | |
1052 | if (37<fR&&fR<41) { //SSD1 | |
61ab8ea8 | 1053 | Double_t dd=0.0034; |
1054 | d=dd; | |
1055 | if (TMath::Abs(y-0.00)>3.40) d+=dd; | |
1056 | if (TMath::Abs(y-1.90)<0.45) {d+=(0.013-0.0034);} | |
1057 | if (TMath::Abs(y+1.90)<0.45) {d+=(0.013-0.0034);} | |
a9a2d814 | 1058 | for (Int_t i=0; i<11; i++) { |
61ab8ea8 | 1059 | if (TMath::Abs(z-3.9*i)<0.15) { |
1060 | if (TMath::Abs(y-0.00)>3.40) d+=dd; | |
1061 | d+=dd; | |
1062 | break; | |
1063 | } | |
1064 | if (TMath::Abs(z+3.9*i)<0.15) { | |
1065 | if (TMath::Abs(y-0.00)>3.40) d+=dd; | |
1066 | d+=dd; | |
1067 | break; | |
1068 | } | |
1069 | if (TMath::Abs(z-1.85-3.9*i)<0.50) {d+=(0.016-0.0034); break;} | |
1070 | if (TMath::Abs(z+2.05+3.9*i)<0.50) {d+=(0.016-0.0034); break;} | |
a9a2d814 | 1071 | } |
1072 | } else | |
1073 | if (13<fR&&fR<26) { //SDD | |
61ab8ea8 | 1074 | Double_t dd=0.0033; |
1075 | d=dd; | |
1076 | if (TMath::Abs(y-0.00)>3.30) d+=dd; | |
1077 | ||
1078 | if (TMath::Abs(y-1.80)<0.55) { | |
1079 | d+=0.016; | |
1080 | for (Int_t j=0; j<20; j++) { | |
1081 | if (TMath::Abs(z+0.7+1.47*j)<0.12) {d+=0.08; x0=9.; break;} | |
1082 | if (TMath::Abs(z-0.7-1.47*j)<0.12) {d+=0.08; x0=9.; break;} | |
1083 | } | |
1084 | } | |
1085 | if (TMath::Abs(y+1.80)<0.55) { | |
1086 | d+=0.016; | |
1087 | for (Int_t j=0; j<20; j++) { | |
1088 | if (TMath::Abs(z-0.7-1.47*j)<0.12) {d+=0.08; x0=9.; break;} | |
1089 | if (TMath::Abs(z+0.7+1.47*j)<0.12) {d+=0.08; x0=9.; break;} | |
1090 | } | |
1091 | } | |
1092 | ||
1093 | for (Int_t i=0; i<4; i++) { | |
1094 | if (TMath::Abs(z-7.3*i)<0.60) { | |
1095 | d+=dd; | |
1096 | if (TMath::Abs(y-0.00)>3.30) d+=dd; | |
1097 | break; | |
1098 | } | |
1099 | if (TMath::Abs(z+7.3*i)<0.60) { | |
1100 | d+=dd; | |
1101 | if (TMath::Abs(y-0.00)>3.30) d+=dd; | |
1102 | break; | |
1103 | } | |
a9a2d814 | 1104 | } |
1105 | } else | |
1106 | if (6<fR&&fR<8) { //SPD2 | |
61ab8ea8 | 1107 | Double_t dd=0.0063; x0=21.5; |
1108 | d=dd; | |
1109 | if (TMath::Abs(y-3.08)>0.5) d+=dd; | |
1110 | //if (TMath::Abs(y-3.08)>0.45) d+=dd; | |
1111 | if (TMath::Abs(y-3.03)<0.10) {d+=0.014;} | |
a9a2d814 | 1112 | } else |
1113 | if (3<fR&&fR<5) { //SPD1 | |
61ab8ea8 | 1114 | Double_t dd=0.0063; x0=21.5; |
1115 | d=dd; | |
1116 | if (TMath::Abs(y+0.21)>0.6) d+=dd; | |
1117 | //if (TMath::Abs(y+0.21)>0.45) d+=dd; | |
1118 | if (TMath::Abs(y+0.10)<0.10) {d+=0.014;} | |
a9a2d814 | 1119 | } |
1120 | ||
a9a2d814 | 1121 | return d; |
1122 | } | |
006b5f7f | 1123 | |
a9a2d814 | 1124 | Double_t AliITStrackerV2::GetEffectiveThickness(Double_t y,Double_t z) const |
006b5f7f | 1125 | { |
1126 | //-------------------------------------------------------------------- | |
a9a2d814 | 1127 | //Returns the thickness between the current layer and the vertex (units X0) |
006b5f7f | 1128 | //-------------------------------------------------------------------- |
61ab8ea8 | 1129 | Double_t d=0.0028*3*3; //beam pipe |
1130 | Double_t x0=0; | |
006b5f7f | 1131 | |
1132 | Double_t xn=fLayers[fI].GetR(); | |
1133 | for (Int_t i=0; i<fI; i++) { | |
1134 | Double_t xi=fLayers[i].GetR(); | |
61ab8ea8 | 1135 | d+=fLayers[i].GetThickness(y,z,x0)*xi*xi; |
006b5f7f | 1136 | } |
1137 | ||
1138 | if (fI>1) { | |
61ab8ea8 | 1139 | Double_t xi=9.; |
1140 | d+=0.0097*xi*xi; | |
006b5f7f | 1141 | } |
1142 | ||
1143 | if (fI>3) { | |
1144 | Double_t xi=0.5*(fLayers[3].GetR()+fLayers[4].GetR()); | |
61ab8ea8 | 1145 | d+=0.0034*xi*xi; |
006b5f7f | 1146 | } |
61ab8ea8 | 1147 | |
006b5f7f | 1148 | return d/(xn*xn); |
1149 | } | |
1150 | ||
006b5f7f | 1151 | Int_t AliITStrackerV2::AliITSlayer::InRoad() const { |
1152 | //-------------------------------------------------------------------- | |
1153 | // This function returns number of clusters within the "window" | |
1154 | //-------------------------------------------------------------------- | |
1155 | Int_t ncl=0; | |
1156 | for (Int_t i=fI; i<fN; i++) { | |
1157 | const AliITSclusterV2 *c=fClusters[i]; | |
1158 | if (c->GetZ() > fZmax) break; | |
a9a2d814 | 1159 | if (c->IsUsed()) continue; |
006b5f7f | 1160 | const AliITSdetector &det=GetDetector(c->GetDetectorIndex()); |
1161 | Double_t y=fR*det.GetPhi() + c->GetY(); | |
1162 | ||
1163 | if (y>2.*fR*TMath::Pi()) y -= 2*fR*TMath::Pi(); | |
1164 | if (y>1.*fR*TMath::Pi() && fYmax<y) y -= 2*fR*TMath::Pi(); | |
1165 | ||
1166 | if (y<fYmin) continue; | |
1167 | if (y>fYmax) continue; | |
1168 | ncl++; | |
1169 | } | |
1170 | return ncl; | |
1171 | } | |
1172 | ||
880f41b9 | 1173 | Bool_t |
3a382e5c | 1174 | AliITStrackerV2::RefitAt(Double_t x,AliITStrackV2 *t,const AliITStrackV2 *c) { |
4ab260d6 | 1175 | //-------------------------------------------------------------------- |
3a382e5c | 1176 | // This function refits the track "t" at the position "x" using |
1177 | // the clusters from "c" | |
4ab260d6 | 1178 | //-------------------------------------------------------------------- |
880f41b9 | 1179 | Int_t index[kMaxLayer]; |
1180 | Int_t k; | |
1181 | for (k=0; k<kMaxLayer; k++) index[k]=-1; | |
3a382e5c | 1182 | Int_t nc=c->GetNumberOfClusters(); |
880f41b9 | 1183 | for (k=0; k<nc; k++) { |
3a382e5c | 1184 | Int_t idx=c->GetClusterIndex(k),nl=(idx&0xf0000000)>>28; |
880f41b9 | 1185 | index[nl]=idx; |
1186 | } | |
880f41b9 | 1187 | |
4ab260d6 | 1188 | Int_t from, to, step; |
1189 | if (x > t->GetX()) { | |
1190 | from=0; to=kMaxLayer; | |
1191 | step=+1; | |
1192 | } else { | |
1193 | from=kMaxLayer-1; to=-1; | |
1194 | step=-1; | |
1195 | } | |
1196 | ||
1197 | for (Int_t i=from; i != to; i += step) { | |
1198 | AliITSlayer &layer=fLayers[i]; | |
1199 | Double_t r=layer.GetR(); | |
1200 | ||
1201 | { | |
1202 | Double_t hI=i-0.5*step; | |
880f41b9 | 1203 | if (TMath::Abs(hI-1.5)<0.01 || TMath::Abs(hI-3.5)<0.01) { |
4ab260d6 | 1204 | Double_t rs=0.5*(fLayers[i-step].GetR() + r); |
61ab8ea8 | 1205 | Double_t d=0.0034, x0=38.6; |
880f41b9 | 1206 | if (TMath::Abs(hI-1.5)<0.01) {rs=9.; d=0.0097; x0=42;} |
1207 | if (!t->PropagateTo(rs,-step*d,x0)) { | |
4ab260d6 | 1208 | return kFALSE; |
1209 | } | |
1210 | } | |
1211 | } | |
1212 | ||
880f41b9 | 1213 | // remember old position [SR, GSI 18.02.2003] |
1214 | Double_t oldX=0., oldY=0., oldZ=0.; | |
1215 | if (t->IsStartedTimeIntegral() && step==1) { | |
1216 | t->GetGlobalXYZat(t->GetX(),oldX,oldY,oldZ); | |
1217 | } | |
1218 | // | |
1219 | ||
4ab260d6 | 1220 | Double_t x,y,z; |
1221 | if (!t->GetGlobalXYZat(r,x,y,z)) { | |
1222 | return kFALSE; | |
1223 | } | |
1224 | Double_t phi=TMath::ATan2(y,x); | |
1225 | Int_t idet=layer.FindDetectorIndex(phi,z); | |
1226 | if (idet<0) { | |
1227 | return kFALSE; | |
1228 | } | |
1229 | const AliITSdetector &det=layer.GetDetector(idet); | |
1230 | phi=det.GetPhi(); | |
1231 | if (!t->Propagate(phi,det.GetR())) { | |
1232 | return kFALSE; | |
1233 | } | |
1234 | t->SetDetectorIndex(idet); | |
1235 | ||
1236 | const AliITSclusterV2 *cl=0; | |
1237 | Double_t maxchi2=kMaxChi2; | |
1238 | ||
1239 | Int_t idx=index[i]; | |
1240 | if (idx>0) { | |
1241 | const AliITSclusterV2 *c=(AliITSclusterV2 *)GetCluster(idx); | |
1242 | if (idet != c->GetDetectorIndex()) { | |
1243 | idet=c->GetDetectorIndex(); | |
1244 | const AliITSdetector &det=layer.GetDetector(idet); | |
1245 | if (!t->Propagate(det.GetPhi(),det.GetR())) { | |
1246 | return kFALSE; | |
1247 | } | |
1248 | t->SetDetectorIndex(idet); | |
1249 | } | |
1250 | Double_t chi2=t->GetPredictedChi2(c); | |
1251 | if (chi2<maxchi2) { cl=c; maxchi2=chi2; } | |
1252 | else return kFALSE; | |
1253 | } | |
4ab260d6 | 1254 | /* |
1255 | if (cl==0) | |
1256 | if (t->GetNumberOfClusters()>2) { | |
1257 | Double_t dz=4*TMath::Sqrt(t->GetSigmaZ2()+kSigmaZ2[i]); | |
1258 | Double_t dy=4*TMath::Sqrt(t->GetSigmaY2()+kSigmaY2[i]); | |
1259 | Double_t zmin=t->GetZ() - dz; | |
1260 | Double_t zmax=t->GetZ() + dz; | |
1261 | Double_t ymin=t->GetY() + phi*r - dy; | |
1262 | Double_t ymax=t->GetY() + phi*r + dy; | |
1263 | layer.SelectClusters(zmin,zmax,ymin,ymax); | |
1264 | ||
1265 | const AliITSclusterV2 *c=0; Int_t ci=-1; | |
1266 | while ((c=layer.GetNextCluster(ci))!=0) { | |
1267 | if (idet != c->GetDetectorIndex()) continue; | |
1268 | Double_t chi2=t->GetPredictedChi2(c); | |
1269 | if (chi2<maxchi2) { cl=c; maxchi2=chi2; idx=ci; } | |
1270 | } | |
1271 | } | |
1272 | */ | |
4ab260d6 | 1273 | if (cl) { |
1274 | if (!t->Update(cl,maxchi2,idx)) { | |
1275 | return kFALSE; | |
1276 | } | |
880f41b9 | 1277 | t->SetSampledEdx(cl->GetQ(),t->GetNumberOfClusters()-1); |
4ab260d6 | 1278 | } |
1279 | ||
1280 | { | |
61ab8ea8 | 1281 | Double_t x0; |
1282 | Double_t d=layer.GetThickness(t->GetY(),t->GetZ(),x0); | |
1283 | t->CorrectForMaterial(-step*d,x0); | |
4ab260d6 | 1284 | } |
880f41b9 | 1285 | |
1286 | // track time update [SR, GSI 17.02.2003] | |
1287 | if (t->IsStartedTimeIntegral() && step==1) { | |
1288 | Double_t newX, newY, newZ; | |
1289 | t->GetGlobalXYZat(t->GetX(),newX,newY,newZ); | |
1290 | Double_t dL2 = (oldX-newX)*(oldX-newX) + (oldY-newY)*(oldY-newY) + | |
1291 | (oldZ-newZ)*(oldZ-newZ); | |
1292 | t->AddTimeStep(TMath::Sqrt(dL2)); | |
1293 | } | |
1294 | // | |
4ab260d6 | 1295 | |
1296 | } | |
1297 | ||
1298 | if (!t->PropagateTo(x,0.,0.)) return kFALSE; | |
1299 | return kTRUE; | |
1300 | } | |
1301 | ||
b87bd7cd | 1302 | void AliITStrackerV2::UseClusters(const AliKalmanTrack *t, Int_t from) const { |
1303 | //-------------------------------------------------------------------- | |
1304 | // This function marks clusters assigned to the track | |
1305 | //-------------------------------------------------------------------- | |
1306 | AliTracker::UseClusters(t,from); | |
880f41b9 | 1307 | |
b87bd7cd | 1308 | AliITSclusterV2 *c=(AliITSclusterV2 *)GetCluster(t->GetClusterIndex(0)); |
1309 | //if (c->GetQ()>2) c->Use(); | |
1310 | if (c->GetSigmaZ2()>0.1) c->Use(); | |
1311 | c=(AliITSclusterV2 *)GetCluster(t->GetClusterIndex(1)); | |
1312 | //if (c->GetQ()>2) c->Use(); | |
1313 | if (c->GetSigmaZ2()>0.1) c->Use(); | |
880f41b9 | 1314 | |
b87bd7cd | 1315 | } |