]>
Commit | Line | Data |
---|---|---|
bcb6fb78 | 1 | |
e4f2f73d | 2 | /************************************************************************** |
972ef65e | 3 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * |
4 | * * | |
5 | * Author: The ALICE Off-line Project. * | |
6 | * Contributors are mentioned in the code where appropriate. * | |
7 | * * | |
8 | * Permission to use, copy, modify and distribute this software and its * | |
9 | * documentation strictly for non-commercial purposes is hereby granted * | |
10 | * without fee, provided that the above copyright notice appears in all * | |
11 | * copies and that both the copyright notice and this permission notice * | |
12 | * appear in the supporting documentation. The authors make no claims * | |
13 | * about the suitability of this software for any purpose. It is * | |
14 | * provided "as is" without express or implied warranty. * | |
15 | **************************************************************************/ | |
e4f2f73d | 16 | |
17 | /* $Id$ */ | |
18 | ||
19 | /////////////////////////////////////////////////////////////////////////////// | |
20 | // // | |
21 | // Track finder // | |
22 | // // | |
23 | // Authors: // | |
24 | // Alex Bercuci <A.Bercuci@gsi.de> // | |
25 | // Markus Fasel <M.Fasel@gsi.de> // | |
26 | // // | |
27 | /////////////////////////////////////////////////////////////////////////////// | |
28 | ||
bb56afff | 29 | // #include <Riostream.h> |
30 | // #include <stdio.h> | |
31 | // #include <string.h> | |
e4f2f73d | 32 | |
33 | #include <TBranch.h> | |
bb56afff | 34 | #include <TDirectory.h> |
e4f2f73d | 35 | #include <TLinearFitter.h> |
e4f2f73d | 36 | #include <TTree.h> |
37 | #include <TClonesArray.h> | |
e4f2f73d | 38 | #include <TTreeStream.h> |
39 | ||
40 | #include "AliLog.h" | |
41 | #include "AliESDEvent.h" | |
bb56afff | 42 | #include "AliGeomManager.h" |
e4f2f73d | 43 | #include "AliRieman.h" |
44 | #include "AliTrackPointArray.h" | |
45 | ||
e4f2f73d | 46 | #include "AliTRDgeometry.h" |
47 | #include "AliTRDpadPlane.h" | |
e4f2f73d | 48 | #include "AliTRDcalibDB.h" |
e4f2f73d | 49 | #include "AliTRDReconstructor.h" |
50 | #include "AliTRDCalibraFillHisto.h" | |
e4f2f73d | 51 | #include "AliTRDrecoParam.h" |
bb56afff | 52 | |
53 | #include "AliTRDcluster.h" | |
e4f2f73d | 54 | #include "AliTRDseedV1.h" |
0906e73e | 55 | #include "AliTRDtrackV1.h" |
bb56afff | 56 | #include "AliTRDtrackerV1.h" |
57 | #include "AliTRDtrackerDebug.h" | |
58 | #include "AliTRDtrackingChamber.h" | |
59 | #include "AliTRDchamberTimeBin.h" | |
60 | ||
e4f2f73d | 61 | |
e4f2f73d | 62 | |
63 | ClassImp(AliTRDtrackerV1) | |
eb38ed55 | 64 | |
65 | ||
66 | const Float_t AliTRDtrackerV1::fgkMinClustersInTrack = 0.5; // | |
67 | const Float_t AliTRDtrackerV1::fgkLabelFraction = 0.8; // | |
68 | const Double_t AliTRDtrackerV1::fgkMaxChi2 = 12.0; // | |
69 | const Double_t AliTRDtrackerV1::fgkMaxSnp = 0.95; // Maximum local sine of the azimuthal angle | |
70 | const Double_t AliTRDtrackerV1::fgkMaxStep = 2.0; // Maximal step size in propagation | |
d76231c8 | 71 | Double_t AliTRDtrackerV1::fgTopologicQA[kNConfigs] = { |
41702fec | 72 | 0.1112, 0.1112, 0.1112, 0.0786, 0.0786, |
73 | 0.0786, 0.0786, 0.0579, 0.0579, 0.0474, | |
74 | 0.0474, 0.0408, 0.0335, 0.0335, 0.0335 | |
e4f2f73d | 75 | }; |
2985ffcb | 76 | Int_t AliTRDtrackerV1::fgNTimeBins = 0; |
eb38ed55 | 77 | TTreeSRedirector *AliTRDtrackerV1::fgDebugStreamer = 0x0; |
78 | AliRieman* AliTRDtrackerV1::fgRieman = 0x0; | |
79 | TLinearFitter* AliTRDtrackerV1::fgTiltedRieman = 0x0; | |
80 | TLinearFitter* AliTRDtrackerV1::fgTiltedRiemanConstrained = 0x0; | |
e4f2f73d | 81 | |
82 | //____________________________________________________________________ | |
3a039a31 | 83 | AliTRDtrackerV1::AliTRDtrackerV1(AliTRDReconstructor *rec) |
41702fec | 84 | :AliTracker() |
06b32d95 | 85 | ,fReconstructor(0x0) |
41702fec | 86 | ,fGeom(new AliTRDgeometry()) |
87 | ,fClusters(0x0) | |
88 | ,fTracklets(0x0) | |
89 | ,fTracks(0x0) | |
90 | ,fSieveSeeding(0) | |
e4f2f73d | 91 | { |
41702fec | 92 | // |
93 | // Default constructor. | |
94 | // | |
a7ac01d2 | 95 | AliTRDcalibDB *trd = 0x0; |
96 | if (!(trd = AliTRDcalibDB::Instance())) { | |
41702fec | 97 | AliFatal("Could not get calibration object"); |
98 | } | |
a7ac01d2 | 99 | |
100 | if(!fgNTimeBins) fgNTimeBins = trd->GetNumberOfTimeBins(); | |
41702fec | 101 | |
053767a4 | 102 | for (Int_t isector = 0; isector < AliTRDgeometry::kNsector; isector++) new(&fTrSec[isector]) AliTRDtrackingSector(fGeom, isector); |
3a039a31 | 103 | |
d611c74f | 104 | for(Int_t isl =0; isl<kNSeedPlanes; isl++) fSeedTB[isl] = 0x0; |
d20df6fc | 105 | |
3a039a31 | 106 | // Initialize debug stream |
06b32d95 | 107 | if(rec) SetReconstructor(rec); |
eb38ed55 | 108 | } |
109 | ||
e4f2f73d | 110 | //____________________________________________________________________ |
111 | AliTRDtrackerV1::~AliTRDtrackerV1() | |
112 | { | |
41702fec | 113 | // |
114 | // Destructor | |
115 | // | |
116 | ||
117 | if(fgDebugStreamer) delete fgDebugStreamer; | |
118 | if(fgRieman) delete fgRieman; | |
119 | if(fgTiltedRieman) delete fgTiltedRieman; | |
120 | if(fgTiltedRiemanConstrained) delete fgTiltedRiemanConstrained; | |
d611c74f | 121 | for(Int_t isl =0; isl<kNSeedPlanes; isl++) if(fSeedTB[isl]) delete fSeedTB[isl]; |
41702fec | 122 | if(fTracks) {fTracks->Delete(); delete fTracks;} |
123 | if(fTracklets) {fTracklets->Delete(); delete fTracklets;} | |
124 | if(fClusters) {fClusters->Delete(); delete fClusters;} | |
125 | if(fGeom) delete fGeom; | |
e4f2f73d | 126 | } |
127 | ||
128 | //____________________________________________________________________ | |
129 | Int_t AliTRDtrackerV1::Clusters2Tracks(AliESDEvent *esd) | |
130 | { | |
41702fec | 131 | // |
132 | // Steering stand alone tracking for full TRD detector | |
133 | // | |
134 | // Parameters : | |
135 | // esd : The ESD event. On output it contains | |
136 | // the ESD tracks found in TRD. | |
137 | // | |
138 | // Output : | |
139 | // Number of tracks found in the TRD detector. | |
140 | // | |
141 | // Detailed description | |
142 | // 1. Launch individual SM trackers. | |
143 | // See AliTRDtrackerV1::Clusters2TracksSM() for details. | |
144 | // | |
145 | ||
3a039a31 | 146 | if(!fReconstructor->GetRecoParam() ){ |
147 | AliError("Reconstruction configuration not initialized. Call first AliTRDReconstructor::SetRecoParam()."); | |
41702fec | 148 | return 0; |
149 | } | |
150 | ||
151 | //AliInfo("Start Track Finder ..."); | |
152 | Int_t ntracks = 0; | |
053767a4 | 153 | for(int ism=0; ism<AliTRDgeometry::kNsector; ism++){ |
41702fec | 154 | // for(int ism=1; ism<2; ism++){ |
155 | //AliInfo(Form("Processing supermodule %i ...", ism)); | |
156 | ntracks += Clusters2TracksSM(ism, esd); | |
157 | } | |
158 | AliInfo(Form("Number of found tracks : %d", ntracks)); | |
159 | return ntracks; | |
e4f2f73d | 160 | } |
161 | ||
0906e73e | 162 | |
163 | //_____________________________________________________________________________ | |
eb38ed55 | 164 | Bool_t AliTRDtrackerV1::GetTrackPoint(Int_t index, AliTrackPoint &p) const |
0906e73e | 165 | { |
41702fec | 166 | //AliInfo(Form("Asking for tracklet %d", index)); |
167 | ||
2f7514a6 | 168 | AliTRDseedV1 *tracklet = GetTracklet(index); |
169 | if (!tracklet) return kFALSE; | |
41702fec | 170 | |
171 | // get detector for this tracklet | |
172 | AliTRDcluster *cl = 0x0; | |
173 | Int_t ic = 0; do; while(!(cl = tracklet->GetClusters(ic++))); | |
174 | Int_t idet = cl->GetDetector(); | |
175 | ||
176 | Double_t local[3]; | |
177 | local[0] = tracklet->GetX0(); | |
178 | local[1] = tracklet->GetYfit(0); | |
179 | local[2] = tracklet->GetZfit(0); | |
180 | Double_t global[3]; | |
181 | fGeom->RotateBack(idet, local, global); | |
182 | p.SetXYZ(global[0],global[1],global[2]); | |
183 | ||
184 | ||
185 | // setting volume id | |
186 | AliGeomManager::ELayerID iLayer = AliGeomManager::kTRD1; | |
053767a4 | 187 | switch (fGeom->GetLayer(idet)) { |
41702fec | 188 | case 0: |
189 | iLayer = AliGeomManager::kTRD1; | |
190 | break; | |
191 | case 1: | |
192 | iLayer = AliGeomManager::kTRD2; | |
193 | break; | |
194 | case 2: | |
195 | iLayer = AliGeomManager::kTRD3; | |
196 | break; | |
197 | case 3: | |
198 | iLayer = AliGeomManager::kTRD4; | |
199 | break; | |
200 | case 4: | |
201 | iLayer = AliGeomManager::kTRD5; | |
202 | break; | |
203 | case 5: | |
204 | iLayer = AliGeomManager::kTRD6; | |
205 | break; | |
206 | }; | |
053767a4 | 207 | Int_t modId = fGeom->GetSector(idet) * fGeom->Nstack() + fGeom->GetStack(idet); |
41702fec | 208 | UShort_t volid = AliGeomManager::LayerToVolUID(iLayer, modId); |
209 | p.SetVolumeID(volid); | |
210 | ||
211 | return kTRUE; | |
0906e73e | 212 | } |
213 | ||
eb38ed55 | 214 | //____________________________________________________________________ |
215 | TLinearFitter* AliTRDtrackerV1::GetTiltedRiemanFitter() | |
216 | { | |
41702fec | 217 | if(!fgTiltedRieman) fgTiltedRieman = new TLinearFitter(4, "hyp4"); |
218 | return fgTiltedRieman; | |
eb38ed55 | 219 | } |
0906e73e | 220 | |
eb38ed55 | 221 | //____________________________________________________________________ |
222 | TLinearFitter* AliTRDtrackerV1::GetTiltedRiemanFitterConstraint() | |
223 | { | |
41702fec | 224 | if(!fgTiltedRiemanConstrained) fgTiltedRiemanConstrained = new TLinearFitter(2, "hyp2"); |
225 | return fgTiltedRiemanConstrained; | |
eb38ed55 | 226 | } |
41702fec | 227 | |
eb38ed55 | 228 | //____________________________________________________________________ |
229 | AliRieman* AliTRDtrackerV1::GetRiemanFitter() | |
230 | { | |
053767a4 | 231 | if(!fgRieman) fgRieman = new AliRieman(AliTRDtrackingChamber::kNTimeBins * AliTRDgeometry::kNlayer); |
41702fec | 232 | return fgRieman; |
eb38ed55 | 233 | } |
41702fec | 234 | |
0906e73e | 235 | //_____________________________________________________________________________ |
236 | Int_t AliTRDtrackerV1::PropagateBack(AliESDEvent *event) | |
237 | { | |
41702fec | 238 | // |
239 | // Gets seeds from ESD event. The seeds are AliTPCtrack's found and | |
240 | // backpropagated by the TPC tracker. Each seed is first propagated | |
241 | // to the TRD, and then its prolongation is searched in the TRD. | |
242 | // If sufficiently long continuation of the track is found in the TRD | |
243 | // the track is updated, otherwise it's stored as originaly defined | |
244 | // by the TPC tracker. | |
245 | // | |
246 | ||
247 | // Calibration monitor | |
248 | AliTRDCalibraFillHisto *calibra = AliTRDCalibraFillHisto::Instance(); | |
249 | if (!calibra) AliInfo("Could not get Calibra instance\n"); | |
250 | ||
251 | Int_t found = 0; // number of tracks found | |
252 | Float_t foundMin = 20.0; | |
253 | ||
d611c74f | 254 | Float_t *quality = 0x0; |
255 | Int_t *index = 0x0; | |
41702fec | 256 | Int_t nSeed = event->GetNumberOfTracks(); |
d611c74f | 257 | if(nSeed){ |
258 | quality = new Float_t[nSeed]; | |
259 | index = new Int_t[nSeed]; | |
260 | for (Int_t iSeed = 0; iSeed < nSeed; iSeed++) { | |
261 | AliESDtrack *seed = event->GetTrack(iSeed); | |
262 | Double_t covariance[15]; | |
263 | seed->GetExternalCovariance(covariance); | |
264 | quality[iSeed] = covariance[0] + covariance[2]; | |
265 | } | |
266 | // Sort tracks according to covariance of local Y and Z | |
267 | TMath::Sort(nSeed,quality,index,kFALSE); | |
41702fec | 268 | } |
41702fec | 269 | |
270 | // Backpropagate all seeds | |
271 | Int_t expectedClr; | |
272 | AliTRDtrackV1 track; | |
273 | for (Int_t iSeed = 0; iSeed < nSeed; iSeed++) { | |
274 | ||
275 | // Get the seeds in sorted sequence | |
276 | AliESDtrack *seed = event->GetTrack(index[iSeed]); | |
277 | ||
278 | // Check the seed status | |
279 | ULong_t status = seed->GetStatus(); | |
280 | if ((status & AliESDtrack::kTPCout) == 0) continue; | |
281 | if ((status & AliESDtrack::kTRDout) != 0) continue; | |
282 | ||
283 | // Do the back prolongation | |
284 | new(&track) AliTRDtrackV1(*seed); | |
285 | //track->Print(); | |
286 | //Int_t lbl = seed->GetLabel(); | |
287 | //track.SetSeedLabel(lbl); | |
288 | seed->UpdateTrackParams(&track, AliESDtrack::kTRDbackup); // Make backup | |
289 | Float_t p4 = track.GetC(); | |
ae3fbe1f | 290 | expectedClr = FollowBackProlongation(track); |
291 | ||
292 | if (expectedClr<0) continue; // Back prolongation failed | |
293 | ||
294 | if(expectedClr){ | |
d611c74f | 295 | found++; |
41702fec | 296 | // computes PID for track |
297 | track.CookPID(); | |
298 | // update calibration references using this track | |
299 | if(calibra->GetHisto2d()) calibra->UpdateHistogramsV1(&track); | |
300 | // save calibration object | |
301 | if ((track.GetNumberOfClusters() > 15) && (track.GetNumberOfClusters() > 0.5*expectedClr)) { | |
302 | seed->UpdateTrackParams(&track, AliESDtrack::kTRDout); | |
303 | ||
304 | track.UpdateESDtrack(seed); | |
305 | ||
306 | // Add TRD track to ESDfriendTrack | |
3a039a31 | 307 | if (fReconstructor->GetStreamLevel(AliTRDReconstructor::kTracker) > 0 /*&& quality TODO*/){ |
41702fec | 308 | AliTRDtrackV1 *calibTrack = new AliTRDtrackV1(track); |
309 | calibTrack->SetOwner(); | |
310 | seed->AddCalibObject(calibTrack); | |
311 | } | |
312 | } | |
313 | } | |
314 | ||
315 | if ((TMath::Abs(track.GetC() - p4) / TMath::Abs(p4) < 0.2) ||(track.Pt() > 0.8)) { | |
316 | // | |
317 | // Make backup for back propagation | |
318 | // | |
319 | Int_t foundClr = track.GetNumberOfClusters(); | |
320 | if (foundClr >= foundMin) { | |
321 | //AliInfo(Form("Making backup track ncls [%d]...", foundClr)); | |
322 | //track.CookdEdx(); | |
323 | //track.CookdEdxTimBin(seed->GetID()); | |
324 | track.CookLabel(1. - fgkLabelFraction); | |
325 | if(track.GetBackupTrack()) UseClusters(track.GetBackupTrack()); | |
326 | ||
327 | ||
328 | // Sign only gold tracks | |
329 | if (track.GetChi2() / track.GetNumberOfClusters() < 4) { | |
330 | if ((seed->GetKinkIndex(0) == 0) && (track.Pt() < 1.5)) UseClusters(&track); | |
331 | } | |
332 | Bool_t isGold = kFALSE; | |
333 | ||
334 | // Full gold track | |
335 | if (track.GetChi2() / track.GetNumberOfClusters() < 5) { | |
336 | if (track.GetBackupTrack()) seed->UpdateTrackParams(track.GetBackupTrack(),AliESDtrack::kTRDbackup); | |
337 | ||
338 | isGold = kTRUE; | |
339 | } | |
340 | ||
341 | // Almost gold track | |
342 | if ((!isGold) && (track.GetNCross() == 0) && (track.GetChi2() / track.GetNumberOfClusters() < 7)) { | |
343 | //seed->UpdateTrackParams(track, AliESDtrack::kTRDbackup); | |
344 | if (track.GetBackupTrack()) seed->UpdateTrackParams(track.GetBackupTrack(),AliESDtrack::kTRDbackup); | |
345 | ||
346 | isGold = kTRUE; | |
347 | } | |
348 | ||
349 | if ((!isGold) && (track.GetBackupTrack())) { | |
350 | if ((track.GetBackupTrack()->GetNumberOfClusters() > foundMin) && ((track.GetBackupTrack()->GetChi2()/(track.GetBackupTrack()->GetNumberOfClusters()+1)) < 7)) { | |
351 | seed->UpdateTrackParams(track.GetBackupTrack(),AliESDtrack::kTRDbackup); | |
352 | isGold = kTRUE; | |
353 | } | |
354 | } | |
355 | ||
356 | //if ((track->StatusForTOF() > 0) && (track->GetNCross() == 0) && (Float_t(track->GetNumberOfClusters()) / Float_t(track->GetNExpected()) > 0.4)) { | |
357 | //seed->UpdateTrackParams(track->GetBackupTrack(), AliESDtrack::kTRDbackup); | |
358 | //} | |
359 | } | |
360 | } | |
361 | ||
362 | // Propagation to the TOF (I.Belikov) | |
363 | if (track.IsStopped() == kFALSE) { | |
364 | Double_t xtof = 371.0; | |
365 | Double_t xTOF0 = 370.0; | |
366 | ||
367 | Double_t c2 = track.GetSnp() + track.GetC() * (xtof - track.GetX()); | |
368 | if (TMath::Abs(c2) >= 0.99) continue; | |
369 | ||
ae3fbe1f | 370 | if (!PropagateToX(track, xTOF0, fgkMaxStep)) continue; |
41702fec | 371 | |
372 | // Energy losses taken to the account - check one more time | |
373 | c2 = track.GetSnp() + track.GetC() * (xtof - track.GetX()); | |
374 | if (TMath::Abs(c2) >= 0.99) continue; | |
375 | ||
376 | //if (!PropagateToX(*track,xTOF0,fgkMaxStep)) { | |
377 | // fHBackfit->Fill(7); | |
378 | //delete track; | |
379 | // continue; | |
380 | //} | |
381 | ||
382 | Double_t ymax = xtof * TMath::Tan(0.5 * AliTRDgeometry::GetAlpha()); | |
383 | Double_t y; | |
384 | track.GetYAt(xtof,GetBz(),y); | |
385 | if (y > ymax) { | |
386 | if (!track.Rotate( AliTRDgeometry::GetAlpha())) continue; | |
387 | }else if (y < -ymax) { | |
388 | if (!track.Rotate(-AliTRDgeometry::GetAlpha())) continue; | |
389 | } | |
390 | ||
391 | if (track.PropagateTo(xtof)) { | |
392 | seed->UpdateTrackParams(&track, AliESDtrack::kTRDout); | |
393 | track.UpdateESDtrack(seed); | |
41702fec | 394 | } |
395 | } else { | |
396 | if ((track.GetNumberOfClusters() > 15) && (track.GetNumberOfClusters() > 0.5*expectedClr)) { | |
397 | seed->UpdateTrackParams(&track, AliESDtrack::kTRDout); | |
398 | ||
399 | track.UpdateESDtrack(seed); | |
41702fec | 400 | } |
401 | } | |
402 | ||
403 | seed->SetTRDQuality(track.StatusForTOF()); | |
404 | seed->SetTRDBudget(track.GetBudget(0)); | |
405 | } | |
d611c74f | 406 | if(index) delete [] index; |
407 | if(quality) delete [] quality; | |
41702fec | 408 | |
409 | ||
410 | AliInfo(Form("Number of seeds: %d", nSeed)); | |
411 | AliInfo(Form("Number of back propagated TRD tracks: %d", found)); | |
412 | ||
d611c74f | 413 | // run stand alone tracking |
3a039a31 | 414 | if (fReconstructor->IsSeeding()) Clusters2Tracks(event); |
41702fec | 415 | |
416 | return 0; | |
0906e73e | 417 | } |
418 | ||
419 | ||
420 | //____________________________________________________________________ | |
421 | Int_t AliTRDtrackerV1::RefitInward(AliESDEvent *event) | |
422 | { | |
41702fec | 423 | // |
424 | // Refits tracks within the TRD. The ESD event is expected to contain seeds | |
425 | // at the outer part of the TRD. | |
426 | // The tracks are propagated to the innermost time bin | |
427 | // of the TRD and the ESD event is updated | |
428 | // Origin: Thomas KUHR (Thomas.Kuhr@cern.ch) | |
429 | // | |
430 | ||
431 | Int_t nseed = 0; // contor for loaded seeds | |
432 | Int_t found = 0; // contor for updated TRD tracks | |
433 | ||
434 | ||
435 | AliTRDtrackV1 track; | |
436 | for (Int_t itrack = 0; itrack < event->GetNumberOfTracks(); itrack++) { | |
437 | AliESDtrack *seed = event->GetTrack(itrack); | |
438 | new(&track) AliTRDtrackV1(*seed); | |
439 | ||
440 | if (track.GetX() < 270.0) { | |
441 | seed->UpdateTrackParams(&track, AliESDtrack::kTRDbackup); | |
442 | continue; | |
443 | } | |
444 | ||
445 | ULong_t status = seed->GetStatus(); | |
446 | if((status & AliESDtrack::kTRDout) == 0) continue; | |
447 | if((status & AliESDtrack::kTRDin) != 0) continue; | |
448 | nseed++; | |
449 | ||
450 | track.ResetCovariance(50.0); | |
451 | ||
452 | // do the propagation and processing | |
453 | Bool_t kUPDATE = kFALSE; | |
454 | Double_t xTPC = 250.0; | |
455 | if(FollowProlongation(track)){ | |
456 | // Prolongate to TPC | |
457 | if (PropagateToX(track, xTPC, fgkMaxStep)) { // -with update | |
458 | seed->UpdateTrackParams(&track, AliESDtrack::kTRDrefit); | |
459 | found++; | |
460 | kUPDATE = kTRUE; | |
461 | } | |
462 | } | |
463 | ||
464 | // Prolongate to TPC without update | |
465 | if(!kUPDATE) { | |
466 | AliTRDtrackV1 tt(*seed); | |
467 | if (PropagateToX(tt, xTPC, fgkMaxStep)) seed->UpdateTrackParams(&tt, AliESDtrack::kTRDrefit); | |
468 | } | |
469 | } | |
470 | AliInfo(Form("Number of loaded seeds: %d",nseed)); | |
471 | AliInfo(Form("Number of found tracks from loaded seeds: %d",found)); | |
472 | ||
473 | return 0; | |
0906e73e | 474 | } |
475 | ||
0906e73e | 476 | //____________________________________________________________________ |
477 | Int_t AliTRDtrackerV1::FollowProlongation(AliTRDtrackV1 &t) | |
478 | { | |
41702fec | 479 | // Extrapolates the TRD track in the TPC direction. |
480 | // | |
481 | // Parameters | |
482 | // t : the TRD track which has to be extrapolated | |
483 | // | |
484 | // Output | |
485 | // number of clusters attached to the track | |
486 | // | |
487 | // Detailed description | |
488 | // | |
489 | // Starting from current radial position of track <t> this function | |
490 | // extrapolates the track through the 6 TRD layers. The following steps | |
491 | // are being performed for each plane: | |
492 | // 1. prepare track: | |
493 | // a. get plane limits in the local x direction | |
494 | // b. check crossing sectors | |
495 | // c. check track inclination | |
496 | // 2. search tracklet in the tracker list (see GetTracklet() for details) | |
497 | // 3. evaluate material budget using the geo manager | |
498 | // 4. propagate and update track using the tracklet information. | |
499 | // | |
500 | // Debug level 2 | |
501 | // | |
502 | ||
503 | Int_t nClustersExpected = 0; | |
504 | Int_t lastplane = 5; //GetLastPlane(&t); | |
505 | for (Int_t iplane = lastplane; iplane >= 0; iplane--) { | |
506 | Int_t index = 0; | |
507 | AliTRDseedV1 *tracklet = GetTracklet(&t, iplane, index); | |
508 | if(!tracklet) continue; | |
509 | if(!tracklet->IsOK()) AliWarning("tracklet not OK"); | |
510 | ||
511 | Double_t x = tracklet->GetX0(); | |
512 | // reject tracklets which are not considered for inward refit | |
513 | if(x > t.GetX()+fgkMaxStep) continue; | |
514 | ||
515 | // append tracklet to track | |
516 | t.SetTracklet(tracklet, index); | |
517 | ||
518 | if (x < (t.GetX()-fgkMaxStep) && !PropagateToX(t, x+fgkMaxStep, fgkMaxStep)) break; | |
519 | if (!AdjustSector(&t)) break; | |
520 | ||
521 | // Start global position | |
522 | Double_t xyz0[3]; | |
523 | t.GetXYZ(xyz0); | |
524 | ||
525 | // End global position | |
526 | Double_t alpha = t.GetAlpha(), y, z; | |
527 | if (!t.GetProlongation(x,y,z)) break; | |
528 | Double_t xyz1[3]; | |
529 | xyz1[0] = x * TMath::Cos(alpha) - y * TMath::Sin(alpha); | |
530 | xyz1[1] = x * TMath::Sin(alpha) + y * TMath::Cos(alpha); | |
531 | xyz1[2] = z; | |
532 | ||
533 | // Get material budget | |
534 | Double_t param[7]; | |
535 | AliTracker::MeanMaterialBudget(xyz0, xyz1, param); | |
536 | Double_t xrho= param[0]*param[4]; | |
537 | Double_t xx0 = param[1]; // Get mean propagation parameters | |
538 | ||
539 | // Propagate and update | |
540 | t.PropagateTo(x, xx0, xrho); | |
541 | if (!AdjustSector(&t)) break; | |
542 | ||
543 | Double_t maxChi2 = t.GetPredictedChi2(tracklet); | |
544 | if (maxChi2 < 1e+10 && t.Update(tracklet, maxChi2)){ | |
545 | nClustersExpected += tracklet->GetN(); | |
546 | } | |
547 | } | |
548 | ||
3a039a31 | 549 | if(fReconstructor->GetStreamLevel(AliTRDReconstructor::kTracker) > 1){ |
41702fec | 550 | Int_t index; |
551 | for(int iplane=0; iplane<6; iplane++){ | |
552 | AliTRDseedV1 *tracklet = GetTracklet(&t, iplane, index); | |
553 | if(!tracklet) continue; | |
554 | t.SetTracklet(tracklet, index); | |
555 | } | |
556 | ||
557 | Int_t eventNumber = AliTRDtrackerDebug::GetEventNumber(); | |
558 | TTreeSRedirector &cstreamer = *fgDebugStreamer; | |
559 | cstreamer << "FollowProlongation" | |
560 | << "EventNumber=" << eventNumber | |
561 | << "ncl=" << nClustersExpected | |
562 | //<< "track.=" << &t | |
563 | << "\n"; | |
564 | } | |
565 | ||
566 | return nClustersExpected; | |
0906e73e | 567 | |
568 | } | |
569 | ||
570 | //_____________________________________________________________________________ | |
571 | Int_t AliTRDtrackerV1::FollowBackProlongation(AliTRDtrackV1 &t) | |
572 | { | |
41702fec | 573 | // Extrapolates the TRD track in the TOF direction. |
574 | // | |
575 | // Parameters | |
576 | // t : the TRD track which has to be extrapolated | |
577 | // | |
578 | // Output | |
579 | // number of clusters attached to the track | |
580 | // | |
581 | // Detailed description | |
582 | // | |
583 | // Starting from current radial position of track <t> this function | |
584 | // extrapolates the track through the 6 TRD layers. The following steps | |
585 | // are being performed for each plane: | |
586 | // 1. prepare track: | |
587 | // a. get plane limits in the local x direction | |
588 | // b. check crossing sectors | |
589 | // c. check track inclination | |
590 | // 2. build tracklet (see AliTRDseed::AttachClusters() for details) | |
591 | // 3. evaluate material budget using the geo manager | |
592 | // 4. propagate and update track using the tracklet information. | |
593 | // | |
594 | // Debug level 2 | |
595 | // | |
596 | ||
597 | Int_t nClustersExpected = 0; | |
598 | Double_t clength = AliTRDgeometry::AmThick() + AliTRDgeometry::DrThick(); | |
599 | AliTRDtrackingChamber *chamber = 0x0; | |
600 | ||
3b57a3f7 | 601 | AliTRDseedV1 tracklet, *ptrTracklet = 0x0; |
602 | ||
053767a4 | 603 | // Loop through the TRD layers |
604 | for (Int_t ilayer = 0; ilayer < AliTRDgeometry::Nlayer(); ilayer++) { | |
41702fec | 605 | // BUILD TRACKLET IF NOT ALREADY BUILT |
606 | Double_t x = 0., y, z, alpha; | |
053767a4 | 607 | ptrTracklet = t.GetTracklet(ilayer); |
41702fec | 608 | if(!ptrTracklet){ |
053767a4 | 609 | ptrTracklet = new(&tracklet) AliTRDseedV1(ilayer); |
43d6ad34 | 610 | ptrTracklet->SetReconstructor(fReconstructor); |
41702fec | 611 | alpha = t.GetAlpha(); |
053767a4 | 612 | Int_t sector = Int_t(alpha/AliTRDgeometry::GetAlpha() + (alpha>0. ? 0 : AliTRDgeometry::kNsector)); |
41702fec | 613 | |
614 | if(!fTrSec[sector].GetNChambers()) continue; | |
615 | ||
053767a4 | 616 | if((x = fTrSec[sector].GetX(ilayer)) < 1.) continue; |
41702fec | 617 | |
43d6ad34 | 618 | if (!t.GetProlongation(x, y, z)) return -nClustersExpected; |
053767a4 | 619 | Int_t stack = fGeom->GetStack(z, ilayer); |
41702fec | 620 | Int_t nCandidates = stack >= 0 ? 1 : 2; |
621 | z -= stack >= 0 ? 0. : 4.; | |
622 | ||
623 | for(int icham=0; icham<nCandidates; icham++, z+=8){ | |
053767a4 | 624 | if((stack = fGeom->GetStack(z, ilayer)) < 0) continue; |
41702fec | 625 | |
053767a4 | 626 | if(!(chamber = fTrSec[sector].GetChamber(stack, ilayer))) continue; |
41702fec | 627 | |
3a039a31 | 628 | if(chamber->GetNClusters() < fgNTimeBins*fReconstructor->GetRecoParam() ->GetFindableClusters()) continue; |
41702fec | 629 | |
630 | x = chamber->GetX(); | |
631 | ||
053767a4 | 632 | AliTRDpadPlane *pp = fGeom->GetPadPlane(ilayer, stack); |
aec26713 | 633 | tracklet.SetTilt(TMath::Tan(TMath::DegToRad()*pp->GetTiltingAngle())); |
41702fec | 634 | tracklet.SetPadLength(pp->GetLengthIPad()); |
053767a4 | 635 | tracklet.SetPlane(ilayer); |
41702fec | 636 | tracklet.SetX0(x); |
637 | if(!tracklet.Init(&t)){ | |
638 | t.SetStopped(kTRUE); | |
639 | return nClustersExpected; | |
640 | } | |
641 | if(!tracklet.AttachClustersIter(chamber, 1000.)) continue; | |
642 | tracklet.Init(&t); | |
643 | ||
3a039a31 | 644 | if(tracklet.GetN() < fgNTimeBins*fReconstructor->GetRecoParam() ->GetFindableClusters()) continue; |
41702fec | 645 | |
646 | break; | |
647 | } | |
648 | } | |
649 | if(!ptrTracklet->IsOK()){ | |
650 | if(x < 1.) continue; //temporary | |
43d6ad34 | 651 | if(!PropagateToX(t, x-fgkMaxStep, fgkMaxStep)) return -nClustersExpected; |
652 | if(!AdjustSector(&t)) return -nClustersExpected; | |
653 | if(TMath::Abs(t.GetSnp()) > fgkMaxSnp) return -nClustersExpected; | |
41702fec | 654 | continue; |
655 | } | |
656 | ||
657 | // Propagate closer to the current chamber if neccessary | |
658 | x -= clength; | |
43d6ad34 | 659 | if (x > (fgkMaxStep + t.GetX()) && !PropagateToX(t, x-fgkMaxStep, fgkMaxStep)) return -nClustersExpected; |
660 | if (!AdjustSector(&t)) return -nClustersExpected; | |
661 | if (TMath::Abs(t.GetSnp()) > fgkMaxSnp) return -nClustersExpected; | |
41702fec | 662 | |
663 | // load tracklet to the tracker and the track | |
664 | ptrTracklet = SetTracklet(ptrTracklet); | |
665 | t.SetTracklet(ptrTracklet, fTracklets->GetEntriesFast()-1); | |
666 | ||
667 | ||
668 | // Calculate the mean material budget along the path inside the chamber | |
669 | //Calculate global entry and exit positions of the track in chamber (only track prolongation) | |
670 | Double_t xyz0[3]; // entry point | |
671 | t.GetXYZ(xyz0); | |
672 | alpha = t.GetAlpha(); | |
673 | x = ptrTracklet->GetX0(); | |
43d6ad34 | 674 | if (!t.GetProlongation(x, y, z)) return -nClustersExpected; |
41702fec | 675 | Double_t xyz1[3]; // exit point |
676 | xyz1[0] = x * TMath::Cos(alpha) - y * TMath::Sin(alpha); | |
677 | xyz1[1] = +x * TMath::Sin(alpha) + y * TMath::Cos(alpha); | |
678 | xyz1[2] = z; | |
679 | Double_t param[7]; | |
680 | AliTracker::MeanMaterialBudget(xyz0, xyz1, param); | |
681 | // The mean propagation parameters | |
682 | Double_t xrho = param[0]*param[4]; // density*length | |
683 | Double_t xx0 = param[1]; // radiation length | |
684 | ||
685 | // Propagate and update track | |
43d6ad34 | 686 | if (!t.PropagateTo(x, xx0, xrho)) return -nClustersExpected; |
687 | if (!AdjustSector(&t)) return -nClustersExpected; | |
41702fec | 688 | Double_t maxChi2 = t.GetPredictedChi2(ptrTracklet); |
43d6ad34 | 689 | if (!t.Update(ptrTracklet, maxChi2)) return -nClustersExpected; |
ae3fbe1f | 690 | if (maxChi2<1e+10) { |
41702fec | 691 | nClustersExpected += ptrTracklet->GetN(); |
692 | //t.SetTracklet(&tracklet, index); | |
693 | } | |
694 | // Reset material budget if 2 consecutive gold | |
053767a4 | 695 | if(ilayer>0 && t.GetTracklet(ilayer-1) && ptrTracklet->GetN() + t.GetTracklet(ilayer-1)->GetN() > 20) t.SetBudget(2, 0.); |
41702fec | 696 | |
697 | // Make backup of the track until is gold | |
698 | // TO DO update quality check of the track. | |
699 | // consider comparison with fTimeBinsRange | |
700 | Float_t ratio0 = ptrTracklet->GetN() / Float_t(fgNTimeBins); | |
701 | //Float_t ratio1 = Float_t(t.GetNumberOfClusters()+1) / Float_t(t.GetNExpected()+1); | |
702 | //printf("tracklet.GetChi2() %f [< 18.0]\n", tracklet.GetChi2()); | |
703 | //printf("ratio0 %f [> 0.8]\n", ratio0); | |
704 | //printf("ratio1 %f [> 0.6]\n", ratio1); | |
705 | //printf("ratio0+ratio1 %f [> 1.5]\n", ratio0+ratio1); | |
706 | //printf("t.GetNCross() %d [== 0]\n", t.GetNCross()); | |
707 | //printf("TMath::Abs(t.GetSnp()) %f [< 0.85]\n", TMath::Abs(t.GetSnp())); | |
708 | //printf("t.GetNumberOfClusters() %d [> 20]\n", t.GetNumberOfClusters()); | |
709 | ||
710 | if (//(tracklet.GetChi2() < 18.0) && TO DO check with FindClusters and move it to AliTRDseed::Update | |
711 | (ratio0 > 0.8) && | |
712 | //(ratio1 > 0.6) && | |
713 | //(ratio0+ratio1 > 1.5) && | |
714 | (t.GetNCross() == 0) && | |
715 | (TMath::Abs(t.GetSnp()) < 0.85) && | |
716 | (t.GetNumberOfClusters() > 20)) t.MakeBackupTrack(); | |
717 | ||
053767a4 | 718 | } // end layers loop |
41702fec | 719 | |
3a039a31 | 720 | if(fReconstructor->GetStreamLevel(AliTRDReconstructor::kTracker) > 1){ |
41702fec | 721 | TTreeSRedirector &cstreamer = *fgDebugStreamer; |
722 | Int_t eventNumber = AliTRDtrackerDebug::GetEventNumber(); | |
723 | //AliTRDtrackV1 *debugTrack = new AliTRDtrackV1(t); | |
724 | //debugTrack->SetOwner(); | |
725 | cstreamer << "FollowBackProlongation" | |
726 | << "EventNumber=" << eventNumber | |
727 | << "ncl=" << nClustersExpected | |
728 | //<< "track.=" << debugTrack | |
729 | << "\n"; | |
730 | } | |
731 | ||
732 | return nClustersExpected; | |
0906e73e | 733 | } |
734 | ||
eb38ed55 | 735 | //_________________________________________________________________________ |
736 | Float_t AliTRDtrackerV1::FitRieman(AliTRDseedV1 *tracklets, Double_t *chi2, Int_t *planes){ | |
41702fec | 737 | // |
738 | // Fits a Riemann-circle to the given points without tilting pad correction. | |
739 | // The fit is performed using an instance of the class AliRieman (equations | |
740 | // and transformations see documentation of this class) | |
741 | // Afterwards all the tracklets are Updated | |
742 | // | |
743 | // Parameters: - Array of tracklets (AliTRDseedV1) | |
744 | // - Storage for the chi2 values (beginning with direction z) | |
745 | // - Seeding configuration | |
746 | // Output: - The curvature | |
747 | // | |
748 | AliRieman *fitter = AliTRDtrackerV1::GetRiemanFitter(); | |
749 | fitter->Reset(); | |
750 | Int_t allplanes[] = {0, 1, 2, 3, 4, 5}; | |
751 | Int_t *ppl = &allplanes[0]; | |
752 | Int_t maxLayers = 6; | |
753 | if(planes){ | |
754 | maxLayers = 4; | |
755 | ppl = planes; | |
756 | } | |
757 | for(Int_t il = 0; il < maxLayers; il++){ | |
758 | if(!tracklets[ppl[il]].IsOK()) continue; | |
759 | fitter->AddPoint(tracklets[ppl[il]].GetX0(), tracklets[ppl[il]].GetYfitR(0), tracklets[ppl[il]].GetZProb(),1,10); | |
760 | } | |
761 | fitter->Update(); | |
762 | // Set the reference position of the fit and calculate the chi2 values | |
763 | memset(chi2, 0, sizeof(Double_t) * 2); | |
764 | for(Int_t il = 0; il < maxLayers; il++){ | |
765 | // Reference positions | |
766 | tracklets[ppl[il]].Init(fitter); | |
767 | ||
768 | // chi2 | |
769 | if((!tracklets[ppl[il]].IsOK()) && (!planes)) continue; | |
770 | chi2[0] += tracklets[ppl[il]].GetChi2Y(); | |
771 | chi2[1] += tracklets[ppl[il]].GetChi2Z(); | |
772 | } | |
773 | return fitter->GetC(); | |
eb38ed55 | 774 | } |
775 | ||
776 | //_________________________________________________________________________ | |
777 | void AliTRDtrackerV1::FitRieman(AliTRDcluster **seedcl, Double_t chi2[2]) | |
778 | { | |
41702fec | 779 | // |
780 | // Performs a Riemann helix fit using the seedclusters as spacepoints | |
781 | // Afterwards the chi2 values are calculated and the seeds are updated | |
782 | // | |
783 | // Parameters: - The four seedclusters | |
784 | // - The tracklet array (AliTRDseedV1) | |
785 | // - The seeding configuration | |
786 | // - Chi2 array | |
787 | // | |
788 | // debug level 2 | |
789 | // | |
790 | AliRieman *fitter = AliTRDtrackerV1::GetRiemanFitter(); | |
791 | fitter->Reset(); | |
792 | for(Int_t i = 0; i < 4; i++) | |
793 | fitter->AddPoint(seedcl[i]->GetX(), seedcl[i]->GetY(), seedcl[i]->GetZ(), 1, 10); | |
794 | fitter->Update(); | |
795 | ||
796 | ||
797 | // Update the seed and calculated the chi2 value | |
798 | chi2[0] = 0; chi2[1] = 0; | |
799 | for(Int_t ipl = 0; ipl < kNSeedPlanes; ipl++){ | |
800 | // chi2 | |
801 | chi2[0] += (seedcl[ipl]->GetZ() - fitter->GetZat(seedcl[ipl]->GetX())) * (seedcl[ipl]->GetZ() - fitter->GetZat(seedcl[ipl]->GetX())); | |
802 | chi2[1] += (seedcl[ipl]->GetY() - fitter->GetYat(seedcl[ipl]->GetX())) * (seedcl[ipl]->GetY() - fitter->GetYat(seedcl[ipl]->GetX())); | |
803 | } | |
eb38ed55 | 804 | } |
805 | ||
806 | ||
807 | //_________________________________________________________________________ | |
808 | Float_t AliTRDtrackerV1::FitTiltedRiemanConstraint(AliTRDseedV1 *tracklets, Double_t zVertex) | |
809 | { | |
41702fec | 810 | // |
811 | // Fits a helix to the clusters. Pad tilting is considered. As constraint it is | |
812 | // assumed that the vertex position is set to 0. | |
813 | // This method is very usefull for high-pt particles | |
814 | // Basis for the fit: (x - x0)^2 + (y - y0)^2 - R^2 = 0 | |
815 | // x0, y0: Center of the circle | |
816 | // Measured y-position: ymeas = y - tan(phiT)(zc - zt) | |
817 | // zc: center of the pad row | |
818 | // Equation which has to be fitted (after transformation): | |
819 | // a + b * u + e * v + 2*(ymeas + tan(phiT)(z - zVertex))*t = 0 | |
820 | // Transformation: | |
821 | // t = 1/(x^2 + y^2) | |
822 | // u = 2 * x * t | |
823 | // v = 2 * x * tan(phiT) * t | |
824 | // Parameters in the equation: | |
825 | // a = -1/y0, b = x0/y0, e = dz/dx | |
826 | // | |
827 | // The Curvature is calculated by the following equation: | |
828 | // - curv = a/Sqrt(b^2 + 1) = 1/R | |
829 | // Parameters: - the 6 tracklets | |
830 | // - the Vertex constraint | |
831 | // Output: - the Chi2 value of the track | |
832 | // | |
833 | // debug level 5 | |
834 | // | |
835 | ||
836 | TLinearFitter *fitter = GetTiltedRiemanFitterConstraint(); | |
837 | fitter->StoreData(kTRUE); | |
838 | fitter->ClearPoints(); | |
839 | AliTRDcluster *cl = 0x0; | |
840 | ||
841 | Float_t x, y, z, w, t, error, tilt; | |
842 | Double_t uvt[2]; | |
843 | Int_t nPoints = 0; | |
053767a4 | 844 | for(Int_t ilr = 0; ilr < AliTRDgeometry::kNlayer; ilr++){ |
845 | if(!tracklets[ilr].IsOK()) continue; | |
41702fec | 846 | for(Int_t itb = 0; itb < fgNTimeBins; itb++){ |
053767a4 | 847 | if(!tracklets[ilr].IsUsable(itb)) continue; |
848 | cl = tracklets[ilr].GetClusters(itb); | |
41702fec | 849 | x = cl->GetX(); |
850 | y = cl->GetY(); | |
851 | z = cl->GetZ(); | |
053767a4 | 852 | tilt = tracklets[ilr].GetTilt(); |
41702fec | 853 | // Transformation |
854 | t = 1./(x * x + y * y); | |
855 | uvt[0] = 2. * x * t; | |
856 | uvt[1] = 2. * x * t * tilt ; | |
857 | w = 2. * (y + tilt * (z - zVertex)) * t; | |
858 | error = 2. * 0.2 * t; | |
859 | fitter->AddPoint(uvt, w, error); | |
860 | nPoints++; | |
861 | } | |
862 | } | |
863 | fitter->Eval(); | |
864 | ||
865 | // Calculate curvature | |
866 | Double_t a = fitter->GetParameter(0); | |
867 | Double_t b = fitter->GetParameter(1); | |
868 | Double_t curvature = a/TMath::Sqrt(b*b + 1); | |
869 | ||
870 | Float_t chi2track = fitter->GetChisquare()/Double_t(nPoints); | |
871 | for(Int_t ip = 0; ip < AliTRDtrackerV1::kNPlanes; ip++) | |
872 | tracklets[ip].SetCC(curvature); | |
873 | ||
3a039a31 | 874 | /* if(fReconstructor->GetStreamLevel() >= 5){ |
41702fec | 875 | //Linear Model on z-direction |
876 | Double_t xref = CalculateReferenceX(tracklets); // Relative to the middle of the stack | |
877 | Double_t slope = fitter->GetParameter(2); | |
878 | Double_t zref = slope * xref; | |
879 | Float_t chi2Z = CalculateChi2Z(tracklets, zref, slope, xref); | |
880 | Int_t eventNumber = AliTRDtrackerDebug::GetEventNumber(); | |
881 | Int_t candidateNumber = AliTRDtrackerDebug::GetCandidateNumber(); | |
882 | TTreeSRedirector &treeStreamer = *fgDebugStreamer; | |
883 | treeStreamer << "FitTiltedRiemanConstraint" | |
884 | << "EventNumber=" << eventNumber | |
885 | << "CandidateNumber=" << candidateNumber | |
886 | << "Curvature=" << curvature | |
887 | << "Chi2Track=" << chi2track | |
888 | << "Chi2Z=" << chi2Z | |
889 | << "zref=" << zref | |
890 | << "\n"; | |
3a039a31 | 891 | }*/ |
41702fec | 892 | return chi2track; |
eb38ed55 | 893 | } |
894 | ||
895 | //_________________________________________________________________________ | |
896 | Float_t AliTRDtrackerV1::FitTiltedRieman(AliTRDseedV1 *tracklets, Bool_t sigError) | |
897 | { | |
41702fec | 898 | // |
899 | // Performs a Riemann fit taking tilting pad correction into account | |
900 | // The equation of a Riemann circle, where the y position is substituted by the | |
901 | // measured y-position taking pad tilting into account, has to be transformed | |
902 | // into a 4-dimensional hyperplane equation | |
903 | // Riemann circle: (x-x0)^2 + (y-y0)^2 -R^2 = 0 | |
904 | // Measured y-Position: ymeas = y - tan(phiT)(zc - zt) | |
905 | // zc: center of the pad row | |
906 | // zt: z-position of the track | |
907 | // The z-position of the track is assumed to be linear dependent on the x-position | |
908 | // Transformed equation: a + b * u + c * t + d * v + e * w - 2 * (ymeas + tan(phiT) * zc) * t = 0 | |
909 | // Transformation: u = 2 * x * t | |
910 | // v = 2 * tan(phiT) * t | |
911 | // w = 2 * tan(phiT) * (x - xref) * t | |
912 | // t = 1 / (x^2 + ymeas^2) | |
913 | // Parameters: a = -1/y0 | |
914 | // b = x0/y0 | |
915 | // c = (R^2 -x0^2 - y0^2)/y0 | |
916 | // d = offset | |
917 | // e = dz/dx | |
918 | // If the offset respectively the slope in z-position is impossible, the parameters are fixed using | |
919 | // results from the simple riemann fit. Afterwards the fit is redone. | |
920 | // The curvature is calculated according to the formula: | |
921 | // curv = a/(1 + b^2 + c*a) = 1/R | |
922 | // | |
923 | // Paramters: - Array of tracklets (connected to the track candidate) | |
924 | // - Flag selecting the error definition | |
925 | // Output: - Chi2 values of the track (in Parameter list) | |
926 | // | |
927 | TLinearFitter *fitter = GetTiltedRiemanFitter(); | |
928 | fitter->StoreData(kTRUE); | |
929 | fitter->ClearPoints(); | |
930 | AliTRDLeastSquare zfitter; | |
931 | AliTRDcluster *cl = 0x0; | |
932 | ||
933 | Double_t xref = CalculateReferenceX(tracklets); | |
934 | Double_t x, y, z, t, tilt, dx, w, we; | |
935 | Double_t uvt[4]; | |
936 | Int_t nPoints = 0; | |
937 | // Containers for Least-square fitter | |
938 | for(Int_t ipl = 0; ipl < kNPlanes; ipl++){ | |
939 | if(!tracklets[ipl].IsOK()) continue; | |
940 | for(Int_t itb = 0; itb < fgNTimeBins; itb++){ | |
941 | if(!(cl = tracklets[ipl].GetClusters(itb))) continue; | |
942 | if (!tracklets[ipl].IsUsable(itb)) continue; | |
943 | x = cl->GetX(); | |
944 | y = cl->GetY(); | |
945 | z = cl->GetZ(); | |
946 | tilt = tracklets[ipl].GetTilt(); | |
947 | dx = x - xref; | |
948 | // Transformation | |
949 | t = 1./(x*x + y*y); | |
950 | uvt[0] = 2. * x * t; | |
951 | uvt[1] = t; | |
952 | uvt[2] = 2. * tilt * t; | |
953 | uvt[3] = 2. * tilt * dx * t; | |
954 | w = 2. * (y + tilt*z) * t; | |
955 | // error definition changes for the different calls | |
956 | we = 2. * t; | |
957 | we *= sigError ? tracklets[ipl].GetSigmaY() : 0.2; | |
958 | fitter->AddPoint(uvt, w, we); | |
959 | zfitter.AddPoint(&x, z, static_cast<Double_t>(TMath::Sqrt(cl->GetSigmaZ2()))); | |
960 | nPoints++; | |
961 | } | |
962 | } | |
963 | fitter->Eval(); | |
964 | zfitter.Eval(); | |
965 | ||
966 | Double_t offset = fitter->GetParameter(3); | |
967 | Double_t slope = fitter->GetParameter(4); | |
968 | ||
969 | // Linear fitter - not possible to make boundaries | |
970 | // Do not accept non possible z and dzdx combinations | |
971 | Bool_t acceptablez = kTRUE; | |
972 | Double_t zref = 0.0; | |
973 | for (Int_t iLayer = 0; iLayer < kNPlanes; iLayer++) { | |
974 | if(!tracklets[iLayer].IsOK()) continue; | |
975 | zref = offset + slope * (tracklets[iLayer].GetX0() - xref); | |
976 | if (TMath::Abs(tracklets[iLayer].GetZProb() - zref) > tracklets[iLayer].GetPadLength() * 0.5 + 1.0) | |
977 | acceptablez = kFALSE; | |
978 | } | |
979 | if (!acceptablez) { | |
980 | Double_t dzmf = zfitter.GetFunctionParameter(1); | |
981 | Double_t zmf = zfitter.GetFunctionValue(&xref); | |
982 | fgTiltedRieman->FixParameter(3, zmf); | |
983 | fgTiltedRieman->FixParameter(4, dzmf); | |
984 | fitter->Eval(); | |
985 | fitter->ReleaseParameter(3); | |
986 | fitter->ReleaseParameter(4); | |
987 | offset = fitter->GetParameter(3); | |
988 | slope = fitter->GetParameter(4); | |
989 | } | |
990 | ||
991 | // Calculate Curvarture | |
992 | Double_t a = fitter->GetParameter(0); | |
993 | Double_t b = fitter->GetParameter(1); | |
994 | Double_t c = fitter->GetParameter(2); | |
995 | Double_t curvature = 1.0 + b*b - c*a; | |
996 | if (curvature > 0.0) | |
997 | curvature = a / TMath::Sqrt(curvature); | |
998 | ||
999 | Double_t chi2track = fitter->GetChisquare()/Double_t(nPoints); | |
1000 | ||
1001 | // Update the tracklets | |
1002 | Double_t dy, dz; | |
1003 | for(Int_t iLayer = 0; iLayer < AliTRDtrackerV1::kNPlanes; iLayer++) { | |
1004 | ||
1005 | x = tracklets[iLayer].GetX0(); | |
1006 | y = 0; | |
1007 | z = 0; | |
1008 | dy = 0; | |
1009 | dz = 0; | |
1010 | ||
1011 | // y: R^2 = (x - x0)^2 + (y - y0)^2 | |
1012 | // => y = y0 +/- Sqrt(R^2 - (x - x0)^2) | |
1013 | // R = Sqrt() = 1/Curvature | |
1014 | // => y = y0 +/- Sqrt(1/Curvature^2 - (x - x0)^2) | |
1015 | Double_t res = (x * a + b); // = (x - x0)/y0 | |
1016 | res *= res; | |
1017 | res = 1.0 - c * a + b * b - res; // = (R^2 - (x - x0)^2)/y0^2 | |
1018 | if (res >= 0) { | |
1019 | res = TMath::Sqrt(res); | |
1020 | y = (1.0 - res) / a; | |
1021 | } | |
1022 | ||
1023 | // dy: R^2 = (x - x0)^2 + (y - y0)^2 | |
1024 | // => y = +/- Sqrt(R^2 - (x - x0)^2) + y0 | |
1025 | // => dy/dx = (x - x0)/Sqrt(R^2 - (x - x0)^2) | |
1026 | // Curvature: cr = 1/R = a/Sqrt(1 + b^2 - c*a) | |
1027 | // => dy/dx = (x - x0)/(1/(cr^2) - (x - x0)^2) | |
1028 | Double_t x0 = -b / a; | |
1029 | if (-c * a + b * b + 1 > 0) { | |
1030 | if (1.0/(curvature * curvature) - (x - x0) * (x - x0) > 0.0) { | |
1031 | Double_t yderiv = (x - x0) / TMath::Sqrt(1.0/(curvature * curvature) - (x - x0) * (x - x0)); | |
1032 | if (a < 0) yderiv *= -1.0; | |
1033 | dy = yderiv; | |
1034 | } | |
1035 | } | |
1036 | z = offset + slope * (x - xref); | |
1037 | dz = slope; | |
1038 | tracklets[iLayer].SetYref(0, y); | |
1039 | tracklets[iLayer].SetYref(1, dy); | |
1040 | tracklets[iLayer].SetZref(0, z); | |
1041 | tracklets[iLayer].SetZref(1, dz); | |
1042 | tracklets[iLayer].SetC(curvature); | |
1043 | tracklets[iLayer].SetChi2(chi2track); | |
1044 | } | |
1045 | ||
3a039a31 | 1046 | /* if(fReconstructor->GetStreamLevel() >=5){ |
41702fec | 1047 | TTreeSRedirector &cstreamer = *fgDebugStreamer; |
1048 | Int_t eventNumber = AliTRDtrackerDebug::GetEventNumber(); | |
1049 | Int_t candidateNumber = AliTRDtrackerDebug::GetCandidateNumber(); | |
1050 | Double_t chi2z = CalculateChi2Z(tracklets, offset, slope, xref); | |
1051 | cstreamer << "FitTiltedRieman0" | |
1052 | << "EventNumber=" << eventNumber | |
1053 | << "CandidateNumber=" << candidateNumber | |
1054 | << "xref=" << xref | |
1055 | << "Chi2Z=" << chi2z | |
1056 | << "\n"; | |
3a039a31 | 1057 | }*/ |
41702fec | 1058 | return chi2track; |
eb38ed55 | 1059 | } |
1060 | ||
3b57a3f7 | 1061 | |
9e333711 | 1062 | //____________________________________________________________________ |
1063 | Double_t AliTRDtrackerV1::FitLine(AliTRDtrackV1 *track, AliTRDseedV1 *tracklets, Bool_t err, Int_t np, AliTrackPoint *points) | |
1064 | { | |
1065 | AliTRDLeastSquare yfitter, zfitter; | |
1066 | AliTRDcluster *cl = 0x0; | |
1067 | ||
1068 | AliTRDseedV1 work[kNPlanes], *tracklet = 0x0; | |
1069 | if(!tracklets){ | |
1070 | for(Int_t ipl = 0; ipl < kNPlanes; ipl++){ | |
1071 | if(!(tracklet = track->GetTracklet(ipl))) continue; | |
1072 | if(!tracklet->IsOK()) continue; | |
1073 | new(&work[ipl]) AliTRDseedV1(*tracklet); | |
1074 | } | |
1075 | tracklets = &work[0]; | |
1076 | } | |
1077 | ||
1078 | Double_t xref = CalculateReferenceX(tracklets); | |
1079 | Double_t x, y, z, dx, ye, yr, tilt; | |
1080 | for(Int_t ipl = 0; ipl < kNPlanes; ipl++){ | |
1081 | if(!tracklets[ipl].IsOK()) continue; | |
1082 | for(Int_t itb = 0; itb < fgNTimeBins; itb++){ | |
1083 | if(!(cl = tracklets[ipl].GetClusters(itb))) continue; | |
1084 | if (!tracklets[ipl].IsUsable(itb)) continue; | |
1085 | x = cl->GetX(); | |
1086 | z = cl->GetZ(); | |
1087 | dx = x - xref; | |
1088 | zfitter.AddPoint(&dx, z, static_cast<Double_t>(TMath::Sqrt(cl->GetSigmaZ2()))); | |
1089 | } | |
1090 | } | |
1091 | zfitter.Eval(); | |
1092 | Double_t z0 = zfitter.GetFunctionParameter(0); | |
1093 | Double_t dzdx = zfitter.GetFunctionParameter(1); | |
1094 | for(Int_t ipl = 0; ipl < kNPlanes; ipl++){ | |
1095 | if(!tracklets[ipl].IsOK()) continue; | |
1096 | for(Int_t itb = 0; itb < fgNTimeBins; itb++){ | |
1097 | if(!(cl = tracklets[ipl].GetClusters(itb))) continue; | |
1098 | if (!tracklets[ipl].IsUsable(itb)) continue; | |
1099 | x = cl->GetX(); | |
1100 | y = cl->GetY(); | |
1101 | z = cl->GetZ(); | |
1102 | tilt = tracklets[ipl].GetTilt(); | |
1103 | dx = x - xref; | |
1104 | yr = y + tilt*(z - z0 - dzdx*dx); | |
1105 | // error definition changes for the different calls | |
1106 | ye = tilt*TMath::Sqrt(cl->GetSigmaZ2()); | |
1107 | ye += err ? tracklets[ipl].GetSigmaY() : 0.2; | |
1108 | yfitter.AddPoint(&dx, yr, ye); | |
1109 | } | |
1110 | } | |
1111 | yfitter.Eval(); | |
1112 | Double_t y0 = yfitter.GetFunctionParameter(0); | |
1113 | Double_t dydx = yfitter.GetFunctionParameter(1); | |
1114 | Double_t chi2 = 0.;//yfitter.GetChisquare()/Double_t(nPoints); | |
1115 | ||
1116 | //update track points array | |
1117 | if(np && points){ | |
1118 | Float_t xyz[3]; | |
1119 | for(int ip=0; ip<np; ip++){ | |
1120 | points[ip].GetXYZ(xyz); | |
1121 | xyz[1] = y0 + dydx * (xyz[0] - xref); | |
1122 | xyz[2] = z0 + dzdx * (xyz[0] - xref); | |
1123 | points[ip].SetXYZ(xyz); | |
1124 | } | |
1125 | } | |
1126 | return chi2; | |
1127 | } | |
1128 | ||
1129 | ||
3b57a3f7 | 1130 | //_________________________________________________________________________ |
1131 | Double_t AliTRDtrackerV1::FitRiemanTilt(AliTRDtrackV1 *track, AliTRDseedV1 *tracklets, Bool_t sigError, Int_t np, AliTrackPoint *points) | |
1132 | { | |
41702fec | 1133 | // |
1134 | // Performs a Riemann fit taking tilting pad correction into account | |
1135 | // The equation of a Riemann circle, where the y position is substituted by the | |
1136 | // measured y-position taking pad tilting into account, has to be transformed | |
1137 | // into a 4-dimensional hyperplane equation | |
1138 | // Riemann circle: (x-x0)^2 + (y-y0)^2 -R^2 = 0 | |
1139 | // Measured y-Position: ymeas = y - tan(phiT)(zc - zt) | |
1140 | // zc: center of the pad row | |
1141 | // zt: z-position of the track | |
1142 | // The z-position of the track is assumed to be linear dependent on the x-position | |
1143 | // Transformed equation: a + b * u + c * t + d * v + e * w - 2 * (ymeas + tan(phiT) * zc) * t = 0 | |
1144 | // Transformation: u = 2 * x * t | |
1145 | // v = 2 * tan(phiT) * t | |
1146 | // w = 2 * tan(phiT) * (x - xref) * t | |
1147 | // t = 1 / (x^2 + ymeas^2) | |
1148 | // Parameters: a = -1/y0 | |
1149 | // b = x0/y0 | |
1150 | // c = (R^2 -x0^2 - y0^2)/y0 | |
1151 | // d = offset | |
1152 | // e = dz/dx | |
1153 | // If the offset respectively the slope in z-position is impossible, the parameters are fixed using | |
1154 | // results from the simple riemann fit. Afterwards the fit is redone. | |
1155 | // The curvature is calculated according to the formula: | |
1156 | // curv = a/(1 + b^2 + c*a) = 1/R | |
1157 | // | |
1158 | // Paramters: - Array of tracklets (connected to the track candidate) | |
1159 | // - Flag selecting the error definition | |
1160 | // Output: - Chi2 values of the track (in Parameter list) | |
1161 | // | |
1162 | TLinearFitter *fitter = GetTiltedRiemanFitter(); | |
1163 | fitter->StoreData(kTRUE); | |
1164 | fitter->ClearPoints(); | |
1165 | AliTRDLeastSquare zfitter; | |
1166 | AliTRDcluster *cl = 0x0; | |
3b57a3f7 | 1167 | |
1168 | AliTRDseedV1 work[kNPlanes], *tracklet = 0x0; | |
1169 | if(!tracklets){ | |
1170 | for(Int_t ipl = 0; ipl < kNPlanes; ipl++){ | |
1171 | if(!(tracklet = track->GetTracklet(ipl))) continue; | |
1172 | if(!tracklet->IsOK()) continue; | |
1173 | new(&work[ipl]) AliTRDseedV1(*tracklet); | |
1174 | } | |
1175 | tracklets = &work[0]; | |
1176 | } | |
1177 | ||
41702fec | 1178 | Double_t xref = CalculateReferenceX(tracklets); |
1179 | Double_t x, y, z, t, tilt, dx, w, we; | |
1180 | Double_t uvt[4]; | |
1181 | Int_t nPoints = 0; | |
1182 | // Containers for Least-square fitter | |
1183 | for(Int_t ipl = 0; ipl < kNPlanes; ipl++){ | |
1184 | if(!tracklets[ipl].IsOK()) continue; | |
1185 | for(Int_t itb = 0; itb < fgNTimeBins; itb++){ | |
1186 | if(!(cl = tracklets[ipl].GetClusters(itb))) continue; | |
1187 | if (!tracklets[ipl].IsUsable(itb)) continue; | |
1188 | x = cl->GetX(); | |
1189 | y = cl->GetY(); | |
1190 | z = cl->GetZ(); | |
1191 | tilt = tracklets[ipl].GetTilt(); | |
1192 | dx = x - xref; | |
1193 | // Transformation | |
1194 | t = 1./(x*x + y*y); | |
1195 | uvt[0] = 2. * x * t; | |
1196 | uvt[1] = t; | |
1197 | uvt[2] = 2. * tilt * t; | |
1198 | uvt[3] = 2. * tilt * dx * t; | |
1199 | w = 2. * (y + tilt*z) * t; | |
1200 | // error definition changes for the different calls | |
1201 | we = 2. * t; | |
1202 | we *= sigError ? tracklets[ipl].GetSigmaY() : 0.2; | |
1203 | fitter->AddPoint(uvt, w, we); | |
1204 | zfitter.AddPoint(&x, z, static_cast<Double_t>(TMath::Sqrt(cl->GetSigmaZ2()))); | |
1205 | nPoints++; | |
1206 | } | |
1207 | } | |
aec26713 | 1208 | if(fitter->Eval()) return 1.E10; |
1209 | ||
41702fec | 1210 | Double_t z0 = fitter->GetParameter(3); |
1211 | Double_t dzdx = fitter->GetParameter(4); | |
3b57a3f7 | 1212 | |
1213 | ||
1214 | // Linear fitter - not possible to make boundaries | |
1215 | // Do not accept non possible z and dzdx combinations | |
1216 | Bool_t accept = kTRUE; | |
1217 | Double_t zref = 0.0; | |
1218 | for (Int_t iLayer = 0; iLayer < kNPlanes; iLayer++) { | |
1219 | if(!tracklets[iLayer].IsOK()) continue; | |
1220 | zref = z0 + dzdx * (tracklets[iLayer].GetX0() - xref); | |
1221 | if (TMath::Abs(tracklets[iLayer].GetZProb() - zref) > tracklets[iLayer].GetPadLength() * 0.5 + 1.0) | |
1222 | accept = kFALSE; | |
1223 | } | |
1224 | if (!accept) { | |
41702fec | 1225 | zfitter.Eval(); |
3b57a3f7 | 1226 | Double_t dzmf = zfitter.GetFunctionParameter(1); |
1227 | Double_t zmf = zfitter.GetFunctionValue(&xref); | |
1228 | fitter->FixParameter(3, zmf); | |
1229 | fitter->FixParameter(4, dzmf); | |
1230 | fitter->Eval(); | |
1231 | fitter->ReleaseParameter(3); | |
1232 | fitter->ReleaseParameter(4); | |
1233 | z0 = fitter->GetParameter(3); // = zmf ? | |
1234 | dzdx = fitter->GetParameter(4); // = dzmf ? | |
1235 | } | |
1236 | ||
1237 | // Calculate Curvature | |
1238 | Double_t a = fitter->GetParameter(0); | |
1239 | Double_t b = fitter->GetParameter(1); | |
1240 | Double_t c = fitter->GetParameter(2); | |
1241 | Double_t y0 = 1. / a; | |
1242 | Double_t x0 = -b * y0; | |
1243 | Double_t R = TMath::Sqrt(y0*y0 + x0*x0 - c*y0); | |
1244 | Double_t C = 1.0 + b*b - c*a; | |
1245 | if (C > 0.0) C = a / TMath::Sqrt(C); | |
1246 | ||
1247 | // Calculate chi2 of the fit | |
1248 | Double_t chi2 = fitter->GetChisquare()/Double_t(nPoints); | |
1249 | ||
1250 | // Update the tracklets | |
1251 | if(!track){ | |
1252 | for(Int_t ip = 0; ip < kNPlanes; ip++) { | |
1253 | x = tracklets[ip].GetX0(); | |
1254 | Double_t tmp = TMath::Sqrt(R*R-(x-x0)*(x-x0)); | |
1255 | ||
1256 | // y: R^2 = (x - x0)^2 + (y - y0)^2 | |
1257 | // => y = y0 +/- Sqrt(R^2 - (x - x0)^2) | |
1258 | tracklets[ip].SetYref(0, y0 - (y0>0.?1.:-1)*tmp); | |
1259 | // => dy/dx = (x - x0)/Sqrt(R^2 - (x - x0)^2) | |
1260 | tracklets[ip].SetYref(1, (x - x0) / tmp); | |
1261 | tracklets[ip].SetZref(0, z0 + dzdx * (x - xref)); | |
1262 | tracklets[ip].SetZref(1, dzdx); | |
1263 | tracklets[ip].SetC(C); | |
1264 | tracklets[ip].SetChi2(chi2); | |
1265 | } | |
1266 | } | |
1267 | ||
1268 | //update track points array | |
1269 | if(np && points){ | |
1270 | Float_t xyz[3]; | |
1271 | for(int ip=0; ip<np; ip++){ | |
1272 | points[ip].GetXYZ(xyz); | |
1273 | xyz[1] = y0 - (y0>0.?1.:-1)*TMath::Sqrt(R*R-(xyz[0]-x0)*(xyz[0]-x0)); | |
1274 | xyz[2] = z0 + dzdx * (xyz[0] - xref); | |
1275 | points[ip].SetXYZ(xyz); | |
1276 | } | |
1277 | } | |
1278 | ||
3a039a31 | 1279 | /* if(fReconstructor->GetStreamLevel() >=5){ |
3b57a3f7 | 1280 | TTreeSRedirector &cstreamer = *fgDebugStreamer; |
1281 | Int_t eventNumber = AliTRDtrackerDebug::GetEventNumber(); | |
1282 | Int_t candidateNumber = AliTRDtrackerDebug::GetCandidateNumber(); | |
1283 | Double_t chi2z = CalculateChi2Z(tracklets, z0, dzdx, xref); | |
1284 | cstreamer << "FitRiemanTilt" | |
1285 | << "EventNumber=" << eventNumber | |
1286 | << "CandidateNumber=" << candidateNumber | |
1287 | << "xref=" << xref | |
1288 | << "Chi2Z=" << chi2z | |
1289 | << "\n"; | |
3a039a31 | 1290 | }*/ |
3b57a3f7 | 1291 | return chi2; |
1292 | } | |
1293 | ||
1294 | ||
1bf51039 | 1295 | //____________________________________________________________________ |
1296 | Double_t AliTRDtrackerV1::FitKalman(AliTRDtrackV1 *track, AliTRDseedV1 *tracklets, Bool_t up, Int_t np, AliTrackPoint *points) | |
1297 | { | |
1298 | // Kalman filter implementation for the TRD. | |
1299 | // It returns the positions of the fit in the array "points" | |
1300 | // | |
1301 | // Author : A.Bercuci@gsi.de | |
1302 | ||
1303 | //printf("Start track @ x[%f]\n", track->GetX()); | |
1304 | ||
1305 | //prepare marker points along the track | |
1306 | Int_t ip = np ? 0 : 1; | |
1307 | while(ip<np){ | |
1308 | if((up?-1:1) * (track->GetX() - points[ip].GetX()) > 0.) break; | |
1309 | //printf("AliTRDtrackerV1::FitKalman() : Skip track marker x[%d] = %7.3f. Before track start ( %7.3f ).\n", ip, points[ip].GetX(), track->GetX()); | |
1310 | ip++; | |
1311 | } | |
1312 | //if(points) printf("First marker point @ x[%d] = %f\n", ip, points[ip].GetX()); | |
1313 | ||
1314 | ||
1315 | AliTRDseedV1 tracklet, *ptrTracklet = 0x0; | |
1316 | ||
1317 | //Loop through the TRD planes | |
1318 | for (Int_t jplane = 0; jplane < kNPlanes; jplane++) { | |
1319 | // GET TRACKLET OR BUILT IT | |
1320 | Int_t iplane = up ? jplane : kNPlanes - 1 - jplane; | |
1321 | if(tracklets){ | |
1322 | if(!(ptrTracklet = &tracklets[iplane])) continue; | |
1323 | }else{ | |
1324 | if(!(ptrTracklet = track->GetTracklet(iplane))){ | |
1325 | /*AliTRDtrackerV1 *tracker = 0x0; | |
1326 | if(!(tracker = dynamic_cast<AliTRDtrackerV1*>( AliTRDReconstructor::Tracker()))) continue; | |
1327 | ptrTracklet = new(&tracklet) AliTRDseedV1(iplane); | |
1328 | if(!tracker->MakeTracklet(ptrTracklet, track)) */ | |
1329 | continue; | |
1330 | } | |
1331 | } | |
1332 | if(!ptrTracklet->IsOK()) continue; | |
1333 | ||
1334 | Double_t x = ptrTracklet->GetX0(); | |
1335 | ||
1336 | while(ip < np){ | |
1337 | //don't do anything if next marker is after next update point. | |
1338 | if((up?-1:1) * (points[ip].GetX() - x) - fgkMaxStep < 0) break; | |
1339 | ||
1340 | //printf("Propagate to x[%d] = %f\n", ip, points[ip].GetX()); | |
1341 | ||
1342 | if(((up?-1:1) * (points[ip].GetX() - track->GetX()) < 0) && !PropagateToX(*track, points[ip].GetX(), fgkMaxStep)) return -1.; | |
1343 | ||
1344 | Double_t xyz[3]; // should also get the covariance | |
1345 | track->GetXYZ(xyz); points[ip].SetXYZ(xyz[0], xyz[1], xyz[2]); | |
1346 | ip++; | |
1347 | } | |
1348 | //printf("plane[%d] tracklet[%p] x[%f]\n", iplane, ptrTracklet, x); | |
1349 | ||
1350 | //Propagate closer to the next update point | |
1351 | if(((up?-1:1) * (x - track->GetX()) + fgkMaxStep < 0) && !PropagateToX(*track, x + (up?-1:1)*fgkMaxStep, fgkMaxStep)) return -1.; | |
1352 | ||
1353 | if(!AdjustSector(track)) return -1; | |
1354 | if(TMath::Abs(track->GetSnp()) > fgkMaxSnp) return -1; | |
1355 | ||
1356 | //load tracklet to the tracker and the track | |
1357 | /* Int_t index; | |
1358 | if((index = FindTracklet(ptrTracklet)) < 0){ | |
1359 | ptrTracklet = SetTracklet(&tracklet); | |
1360 | index = fTracklets->GetEntriesFast()-1; | |
1361 | } | |
1362 | track->SetTracklet(ptrTracklet, index);*/ | |
1363 | ||
1364 | ||
1365 | // register tracklet to track with tracklet creation !! | |
1366 | // PropagateBack : loaded tracklet to the tracker and update index | |
1367 | // RefitInward : update index | |
1368 | // MakeTrack : loaded tracklet to the tracker and update index | |
1369 | if(!tracklets) track->SetTracklet(ptrTracklet, -1); | |
1370 | ||
1371 | ||
1372 | //Calculate the mean material budget along the path inside the chamber | |
1373 | Double_t xyz0[3]; track->GetXYZ(xyz0); | |
1374 | Double_t alpha = track->GetAlpha(); | |
1375 | Double_t xyz1[3], y, z; | |
1376 | if(!track->GetProlongation(x, y, z)) return -1; | |
1377 | xyz1[0] = x * TMath::Cos(alpha) - y * TMath::Sin(alpha); | |
1378 | xyz1[1] = +x * TMath::Sin(alpha) + y * TMath::Cos(alpha); | |
1379 | xyz1[2] = z; | |
1380 | Double_t param[7]; | |
1381 | AliTracker::MeanMaterialBudget(xyz0, xyz1, param); | |
1382 | Double_t xrho = param[0]*param[4]; // density*length | |
1383 | Double_t xx0 = param[1]; // radiation length | |
1384 | ||
1385 | //Propagate the track | |
1386 | track->PropagateTo(x, xx0, xrho); | |
1387 | if (!AdjustSector(track)) break; | |
1388 | ||
1389 | //Update track | |
1390 | Double_t chi2 = track->GetPredictedChi2(ptrTracklet); | |
1391 | if(chi2<1e+10) track->Update(ptrTracklet, chi2); | |
1392 | ||
1393 | if(!up) continue; | |
1394 | ||
1395 | //Reset material budget if 2 consecutive gold | |
1396 | if(iplane>0 && track->GetTracklet(iplane-1) && ptrTracklet->GetN() + track->GetTracklet(iplane-1)->GetN() > 20) track->SetBudget(2, 0.); | |
1397 | } // end planes loop | |
1398 | ||
1399 | // extrapolation | |
1400 | while(ip < np){ | |
1401 | if(((up?-1:1) * (points[ip].GetX() - track->GetX()) < 0) && !PropagateToX(*track, points[ip].GetX(), fgkMaxStep)) return -1.; | |
1402 | ||
1403 | Double_t xyz[3]; // should also get the covariance | |
1404 | track->GetXYZ(xyz); points[ip].SetXYZ(xyz[0], xyz[1], xyz[2]); | |
1405 | ip++; | |
1406 | } | |
1407 | ||
1408 | return track->GetChi2(); | |
1409 | } | |
3b57a3f7 | 1410 | |
eb38ed55 | 1411 | //_________________________________________________________________________ |
bb56afff | 1412 | Float_t AliTRDtrackerV1::CalculateChi2Z(AliTRDseedV1 *tracklets, Double_t offset, Double_t slope, Double_t xref) |
eb38ed55 | 1413 | { |
41702fec | 1414 | // |
1415 | // Calculates the chi2-value of the track in z-Direction including tilting pad correction. | |
1416 | // A linear dependence on the x-value serves as a model. | |
1417 | // The parameters are related to the tilted Riemann fit. | |
1418 | // Parameters: - Array of tracklets (AliTRDseedV1) related to the track candidate | |
1419 | // - the offset for the reference x | |
1420 | // - the slope | |
1421 | // - the reference x position | |
1422 | // Output: - The Chi2 value of the track in z-Direction | |
1423 | // | |
1424 | Float_t chi2Z = 0, nLayers = 0; | |
053767a4 | 1425 | for (Int_t iLayer = 0; iLayer < AliTRDgeometry::kNlayer; iLayer++) { |
41702fec | 1426 | if(!tracklets[iLayer].IsOK()) continue; |
1427 | Double_t z = offset + slope * (tracklets[iLayer].GetX0() - xref); | |
1428 | chi2Z += TMath::Abs(tracklets[iLayer].GetMeanz() - z); | |
1429 | nLayers++; | |
1430 | } | |
1431 | chi2Z /= TMath::Max((nLayers - 3.0),1.0); | |
1432 | return chi2Z; | |
eb38ed55 | 1433 | } |
1434 | ||
bccda319 | 1435 | //_____________________________________________________________________________ |
1436 | Int_t AliTRDtrackerV1::PropagateToX(AliTRDtrackV1 &t, Double_t xToGo, Double_t maxStep) | |
1437 | { | |
41702fec | 1438 | // |
1439 | // Starting from current X-position of track <t> this function | |
1440 | // extrapolates the track up to radial position <xToGo>. | |
1441 | // Returns 1 if track reaches the plane, and 0 otherwise | |
1442 | // | |
bccda319 | 1443 | |
41702fec | 1444 | const Double_t kEpsilon = 0.00001; |
bccda319 | 1445 | |
41702fec | 1446 | // Current track X-position |
1447 | Double_t xpos = t.GetX(); | |
bccda319 | 1448 | |
41702fec | 1449 | // Direction: inward or outward |
1450 | Double_t dir = (xpos < xToGo) ? 1.0 : -1.0; | |
bccda319 | 1451 | |
41702fec | 1452 | while (((xToGo - xpos) * dir) > kEpsilon) { |
bccda319 | 1453 | |
41702fec | 1454 | Double_t xyz0[3]; |
1455 | Double_t xyz1[3]; | |
1456 | Double_t param[7]; | |
1457 | Double_t x; | |
1458 | Double_t y; | |
1459 | Double_t z; | |
bccda319 | 1460 | |
41702fec | 1461 | // The next step size |
1462 | Double_t step = dir * TMath::Min(TMath::Abs(xToGo-xpos),maxStep); | |
bccda319 | 1463 | |
41702fec | 1464 | // Get the global position of the starting point |
1465 | t.GetXYZ(xyz0); | |
bccda319 | 1466 | |
41702fec | 1467 | // X-position after next step |
1468 | x = xpos + step; | |
bccda319 | 1469 | |
41702fec | 1470 | // Get local Y and Z at the X-position of the next step |
1471 | if (!t.GetProlongation(x,y,z)) { | |
1472 | return 0; // No prolongation possible | |
1473 | } | |
bccda319 | 1474 | |
41702fec | 1475 | // The global position of the end point of this prolongation step |
1476 | xyz1[0] = x * TMath::Cos(t.GetAlpha()) - y * TMath::Sin(t.GetAlpha()); | |
1477 | xyz1[1] = +x * TMath::Sin(t.GetAlpha()) + y * TMath::Cos(t.GetAlpha()); | |
1478 | xyz1[2] = z; | |
bccda319 | 1479 | |
41702fec | 1480 | // Calculate the mean material budget between start and |
1481 | // end point of this prolongation step | |
1482 | AliTracker::MeanMaterialBudget(xyz0, xyz1, param); | |
bccda319 | 1483 | |
41702fec | 1484 | // Propagate the track to the X-position after the next step |
1485 | if (!t.PropagateTo(x,param[1],param[0]*param[4])) { | |
1486 | return 0; | |
1487 | } | |
bccda319 | 1488 | |
41702fec | 1489 | // Rotate the track if necessary |
1490 | AdjustSector(&t); | |
bccda319 | 1491 | |
41702fec | 1492 | // New track X-position |
1493 | xpos = t.GetX(); | |
bccda319 | 1494 | |
41702fec | 1495 | } |
bccda319 | 1496 | |
41702fec | 1497 | return 1; |
bccda319 | 1498 | |
1499 | } | |
1500 | ||
eb38ed55 | 1501 | |
1502 | //_____________________________________________________________________________ | |
1503 | Int_t AliTRDtrackerV1::ReadClusters(TClonesArray* &array, TTree *clusterTree) const | |
1504 | { | |
41702fec | 1505 | // |
1506 | // Reads AliTRDclusters from the file. | |
1507 | // The names of the cluster tree and branches | |
1508 | // should match the ones used in AliTRDclusterizer::WriteClusters() | |
1509 | // | |
1510 | ||
1511 | Int_t nsize = Int_t(clusterTree->GetTotBytes() / (sizeof(AliTRDcluster))); | |
1512 | TObjArray *clusterArray = new TObjArray(nsize+1000); | |
1513 | ||
1514 | TBranch *branch = clusterTree->GetBranch("TRDcluster"); | |
1515 | if (!branch) { | |
1516 | AliError("Can't get the branch !"); | |
1517 | return 1; | |
1518 | } | |
1519 | branch->SetAddress(&clusterArray); | |
1520 | ||
1521 | if(!fClusters){ | |
1522 | array = new TClonesArray("AliTRDcluster", nsize); | |
1523 | array->SetOwner(kTRUE); | |
1524 | } | |
1525 | ||
1526 | // Loop through all entries in the tree | |
1527 | Int_t nEntries = (Int_t) clusterTree->GetEntries(); | |
1528 | Int_t nbytes = 0; | |
1529 | Int_t ncl = 0; | |
1530 | AliTRDcluster *c = 0x0; | |
1531 | for (Int_t iEntry = 0; iEntry < nEntries; iEntry++) { | |
1532 | // Import the tree | |
1533 | nbytes += clusterTree->GetEvent(iEntry); | |
1534 | ||
1535 | // Get the number of points in the detector | |
1536 | Int_t nCluster = clusterArray->GetEntriesFast(); | |
1537 | for (Int_t iCluster = 0; iCluster < nCluster; iCluster++) { | |
1538 | if(!(c = (AliTRDcluster *) clusterArray->UncheckedAt(iCluster))) continue; | |
1539 | c->SetInChamber(); | |
1540 | new((*fClusters)[ncl++]) AliTRDcluster(*c); | |
1541 | delete (clusterArray->RemoveAt(iCluster)); | |
1542 | } | |
1543 | ||
1544 | } | |
1545 | delete clusterArray; | |
1546 | ||
1547 | return 0; | |
eb38ed55 | 1548 | } |
1549 | ||
1550 | //_____________________________________________________________________________ | |
1551 | Int_t AliTRDtrackerV1::LoadClusters(TTree *cTree) | |
1552 | { | |
41702fec | 1553 | // |
66f6bfd9 | 1554 | // Fills clusters into TRD tracking sectors |
41702fec | 1555 | // |
41702fec | 1556 | |
66f6bfd9 | 1557 | if(!(fClusters = AliTRDReconstructor::GetClusters())){ |
1558 | if (ReadClusters(fClusters, cTree)) { | |
1559 | AliError("Problem with reading the clusters !"); | |
1560 | return 1; | |
1561 | } | |
1562 | } | |
1563 | SetClustersOwner(); | |
1564 | ||
1565 | if(!fClusters->GetEntriesFast()){ | |
1566 | AliInfo("No TRD clusters"); | |
41702fec | 1567 | return 1; |
1568 | } | |
66f6bfd9 | 1569 | |
1570 | //Int_t nin = | |
1571 | BuildTrackingContainers(); | |
1572 | ||
1573 | //Int_t ncl = fClusters->GetEntriesFast(); | |
1574 | //AliInfo(Form("Clusters %d [%6.2f %% in the active volume]", ncl, 100.*float(nin)/ncl)); | |
1575 | ||
1576 | return 0; | |
1577 | } | |
1578 | ||
1579 | //_____________________________________________________________________________ | |
1580 | Int_t AliTRDtrackerV1::LoadClusters(TClonesArray *clusters) | |
1581 | { | |
1582 | // | |
1583 | // Fills clusters into TRD tracking sectors | |
1584 | // Function for use in the HLT | |
1585 | ||
1586 | if(!clusters || !clusters->GetEntriesFast()){ | |
1587 | AliInfo("No TRD clusters"); | |
41702fec | 1588 | return 1; |
1589 | } | |
1590 | ||
66f6bfd9 | 1591 | fClusters = clusters; |
1592 | SetClustersOwner(); | |
1593 | ||
1594 | //Int_t nin = | |
1595 | BuildTrackingContainers(); | |
1596 | ||
1597 | //Int_t ncl = fClusters->GetEntriesFast(); | |
1598 | //AliInfo(Form("Clusters %d [%6.2f %% in the active volume]", ncl, 100.*float(nin)/ncl)); | |
1599 | ||
1600 | return 0; | |
1601 | } | |
1602 | ||
1603 | ||
1604 | //____________________________________________________________________ | |
1605 | Int_t AliTRDtrackerV1::BuildTrackingContainers() | |
1606 | { | |
1607 | // Building tracking containers for clusters | |
1608 | ||
1609 | Int_t nin =0, icl = fClusters->GetEntriesFast(); | |
41702fec | 1610 | while (icl--) { |
1611 | AliTRDcluster *c = (AliTRDcluster *) fClusters->UncheckedAt(icl); | |
1612 | if(c->IsInChamber()) nin++; | |
1613 | Int_t detector = c->GetDetector(); | |
1614 | Int_t sector = fGeom->GetSector(detector); | |
053767a4 | 1615 | Int_t stack = fGeom->GetStack(detector); |
1616 | Int_t layer = fGeom->GetLayer(detector); | |
41702fec | 1617 | |
053767a4 | 1618 | fTrSec[sector].GetChamber(stack, layer, kTRUE)->InsertCluster(c, icl); |
41702fec | 1619 | } |
41702fec | 1620 | |
053767a4 | 1621 | for(int isector =0; isector<AliTRDgeometry::kNsector; isector++){ |
41702fec | 1622 | if(!fTrSec[isector].GetNChambers()) continue; |
3a039a31 | 1623 | fTrSec[isector].Init(fReconstructor); |
41702fec | 1624 | } |
66f6bfd9 | 1625 | |
1626 | return nin; | |
eb38ed55 | 1627 | } |
1628 | ||
1629 | ||
66f6bfd9 | 1630 | |
0906e73e | 1631 | //____________________________________________________________________ |
1632 | void AliTRDtrackerV1::UnloadClusters() | |
1633 | { | |
41702fec | 1634 | // |
1635 | // Clears the arrays of clusters and tracks. Resets sectors and timebins | |
1636 | // | |
0906e73e | 1637 | |
41702fec | 1638 | if(fTracks) fTracks->Delete(); |
1639 | if(fTracklets) fTracklets->Delete(); | |
66f6bfd9 | 1640 | if(fClusters && IsClustersOwner()) fClusters->Delete(); |
0906e73e | 1641 | |
053767a4 | 1642 | for (int i = 0; i < AliTRDgeometry::kNsector; i++) fTrSec[i].Clear(); |
0906e73e | 1643 | |
41702fec | 1644 | // Increment the Event Number |
1645 | AliTRDtrackerDebug::SetEventNumber(AliTRDtrackerDebug::GetEventNumber() + 1); | |
eb38ed55 | 1646 | } |
0906e73e | 1647 | |
eb38ed55 | 1648 | //_____________________________________________________________________________ |
1649 | Bool_t AliTRDtrackerV1::AdjustSector(AliTRDtrackV1 *track) | |
1650 | { | |
41702fec | 1651 | // |
1652 | // Rotates the track when necessary | |
1653 | // | |
1654 | ||
1655 | Double_t alpha = AliTRDgeometry::GetAlpha(); | |
1656 | Double_t y = track->GetY(); | |
1657 | Double_t ymax = track->GetX()*TMath::Tan(0.5*alpha); | |
1658 | ||
1659 | if (y > ymax) { | |
1660 | if (!track->Rotate( alpha)) { | |
1661 | return kFALSE; | |
1662 | } | |
1663 | } | |
1664 | else if (y < -ymax) { | |
1665 | if (!track->Rotate(-alpha)) { | |
1666 | return kFALSE; | |
1667 | } | |
1668 | } | |
1669 | ||
1670 | return kTRUE; | |
0906e73e | 1671 | |
1672 | } | |
1673 | ||
eb38ed55 | 1674 | |
0906e73e | 1675 | //____________________________________________________________________ |
1676 | AliTRDseedV1* AliTRDtrackerV1::GetTracklet(AliTRDtrackV1 *track, Int_t p, Int_t &idx) | |
1677 | { | |
41702fec | 1678 | // Find tracklet for TRD track <track> |
1679 | // Parameters | |
1680 | // - track | |
1681 | // - sector | |
1682 | // - plane | |
1683 | // - index | |
1684 | // Output | |
1685 | // tracklet | |
1686 | // index | |
1687 | // Detailed description | |
1688 | // | |
1689 | idx = track->GetTrackletIndex(p); | |
1690 | AliTRDseedV1 *tracklet = (idx==0xffff) ? 0x0 : (AliTRDseedV1*)fTracklets->UncheckedAt(idx); | |
1691 | ||
1692 | return tracklet; | |
0906e73e | 1693 | } |
1694 | ||
1695 | //____________________________________________________________________ | |
3b57a3f7 | 1696 | AliTRDseedV1* AliTRDtrackerV1::SetTracklet(AliTRDseedV1 *tracklet) |
0906e73e | 1697 | { |
41702fec | 1698 | // Add this tracklet to the list of tracklets stored in the tracker |
1699 | // | |
1700 | // Parameters | |
1701 | // - tracklet : pointer to the tracklet to be added to the list | |
1702 | // | |
1703 | // Output | |
1704 | // - the index of the new tracklet in the tracker tracklets list | |
1705 | // | |
1706 | // Detailed description | |
1707 | // Build the tracklets list if it is not yet created (late initialization) | |
1708 | // and adds the new tracklet to the list. | |
1709 | // | |
1710 | if(!fTracklets){ | |
053767a4 | 1711 | fTracklets = new TClonesArray("AliTRDseedV1", AliTRDgeometry::Nsector()*kMaxTracksStack); |
41702fec | 1712 | fTracklets->SetOwner(kTRUE); |
1713 | } | |
1714 | Int_t nentries = fTracklets->GetEntriesFast(); | |
1715 | return new ((*fTracklets)[nentries]) AliTRDseedV1(*tracklet); | |
972ef65e | 1716 | } |
1717 | ||
d20df6fc | 1718 | //____________________________________________________________________ |
1719 | AliTRDtrackV1* AliTRDtrackerV1::SetTrack(AliTRDtrackV1 *track) | |
1720 | { | |
1721 | // Add this track to the list of tracks stored in the tracker | |
1722 | // | |
1723 | // Parameters | |
1724 | // - track : pointer to the track to be added to the list | |
1725 | // | |
1726 | // Output | |
1727 | // - the pointer added | |
1728 | // | |
1729 | // Detailed description | |
1730 | // Build the tracks list if it is not yet created (late initialization) | |
1731 | // and adds the new track to the list. | |
1732 | // | |
1733 | if(!fTracks){ | |
053767a4 | 1734 | fTracks = new TClonesArray("AliTRDtrackV1", AliTRDgeometry::Nsector()*kMaxTracksStack); |
d20df6fc | 1735 | fTracks->SetOwner(kTRUE); |
1736 | } | |
1737 | Int_t nentries = fTracks->GetEntriesFast(); | |
1738 | return new ((*fTracks)[nentries]) AliTRDtrackV1(*track); | |
1739 | } | |
1740 | ||
1741 | ||
0906e73e | 1742 | |
e4f2f73d | 1743 | //____________________________________________________________________ |
eb38ed55 | 1744 | Int_t AliTRDtrackerV1::Clusters2TracksSM(Int_t sector, AliESDEvent *esd) |
e4f2f73d | 1745 | { |
41702fec | 1746 | // |
1747 | // Steer tracking for one SM. | |
1748 | // | |
1749 | // Parameters : | |
1750 | // sector : Array of (SM) propagation layers containing clusters | |
1751 | // esd : The current ESD event. On output it contains the also | |
1752 | // the ESD (TRD) tracks found in this SM. | |
1753 | // | |
1754 | // Output : | |
1755 | // Number of tracks found in this TRD supermodule. | |
1756 | // | |
1757 | // Detailed description | |
1758 | // | |
1759 | // 1. Unpack AliTRDpropagationLayers objects for each stack. | |
1760 | // 2. Launch stack tracking. | |
1761 | // See AliTRDtrackerV1::Clusters2TracksStack() for details. | |
1762 | // 3. Pack results in the ESD event. | |
1763 | // | |
1764 | ||
1765 | // allocate space for esd tracks in this SM | |
1766 | TClonesArray esdTrackList("AliESDtrack", 2*kMaxTracksStack); | |
1767 | esdTrackList.SetOwner(); | |
1768 | ||
1769 | Int_t nTracks = 0; | |
1770 | Int_t nChambers = 0; | |
1771 | AliTRDtrackingChamber **stack = 0x0, *chamber = 0x0; | |
053767a4 | 1772 | for(int istack = 0; istack<AliTRDgeometry::kNstack; istack++){ |
41702fec | 1773 | if(!(stack = fTrSec[sector].GetStack(istack))) continue; |
1774 | nChambers = 0; | |
053767a4 | 1775 | for(int ilayer=0; ilayer<AliTRDgeometry::kNlayer; ilayer++){ |
1776 | if(!(chamber = stack[ilayer])) continue; | |
3a039a31 | 1777 | if(chamber->GetNClusters() < fgNTimeBins * fReconstructor->GetRecoParam() ->GetFindableClusters()) continue; |
41702fec | 1778 | nChambers++; |
053767a4 | 1779 | //AliInfo(Form("sector %d stack %d layer %d clusters %d", sector, istack, ilayer, chamber->GetNClusters())); |
41702fec | 1780 | } |
1781 | if(nChambers < 4) continue; | |
1782 | //AliInfo(Form("Doing stack %d", istack)); | |
1783 | nTracks += Clusters2TracksStack(stack, &esdTrackList); | |
1784 | } | |
1785 | //AliInfo(Form("Found %d tracks in SM %d [%d]\n", nTracks, sector, esd->GetNumberOfTracks())); | |
1786 | ||
1787 | for(int itrack=0; itrack<nTracks; itrack++) | |
1788 | esd->AddTrack((AliESDtrack*)esdTrackList[itrack]); | |
1789 | ||
1790 | // Reset Track and Candidate Number | |
1791 | AliTRDtrackerDebug::SetCandidateNumber(0); | |
1792 | AliTRDtrackerDebug::SetTrackNumber(0); | |
1793 | return nTracks; | |
e4f2f73d | 1794 | } |
1795 | ||
1796 | //____________________________________________________________________ | |
eb38ed55 | 1797 | Int_t AliTRDtrackerV1::Clusters2TracksStack(AliTRDtrackingChamber **stack, TClonesArray *esdTrackList) |
e4f2f73d | 1798 | { |
41702fec | 1799 | // |
1800 | // Make tracks in one TRD stack. | |
1801 | // | |
1802 | // Parameters : | |
1803 | // layer : Array of stack propagation layers containing clusters | |
1804 | // esdTrackList : Array of ESD tracks found by the stand alone tracker. | |
1805 | // On exit the tracks found in this stack are appended. | |
1806 | // | |
1807 | // Output : | |
1808 | // Number of tracks found in this stack. | |
1809 | // | |
1810 | // Detailed description | |
1811 | // | |
1812 | // 1. Find the 3 most useful seeding chambers. See BuildSeedingConfigs() for details. | |
1813 | // 2. Steer AliTRDtrackerV1::MakeSeeds() for 3 seeding layer configurations. | |
1814 | // See AliTRDtrackerV1::MakeSeeds() for more details. | |
1815 | // 3. Arrange track candidates in decreasing order of their quality | |
1816 | // 4. Classify tracks in 5 categories according to: | |
1817 | // a) number of layers crossed | |
1818 | // b) track quality | |
1819 | // 5. Sign clusters by tracks in decreasing order of track quality | |
1820 | // 6. Build AliTRDtrack out of seeding tracklets | |
1821 | // 7. Cook MC label | |
1822 | // 8. Build ESD track and register it to the output list | |
1823 | // | |
1824 | ||
1825 | AliTRDtrackingChamber *chamber = 0x0; | |
1826 | AliTRDseedV1 sseed[kMaxTracksStack*6]; // to be initialized | |
1827 | Int_t pars[4]; // MakeSeeds parameters | |
1828 | ||
1829 | //Double_t alpha = AliTRDgeometry::GetAlpha(); | |
1830 | //Double_t shift = .5 * alpha; | |
1831 | Int_t configs[kNConfigs]; | |
1832 | ||
1833 | // Build initial seeding configurations | |
1834 | Double_t quality = BuildSeedingConfigs(stack, configs); | |
3a039a31 | 1835 | if(fReconstructor->GetStreamLevel(AliTRDReconstructor::kTracker) > 1){ |
41702fec | 1836 | AliInfo(Form("Plane config %d %d %d Quality %f" |
1837 | , configs[0], configs[1], configs[2], quality)); | |
1838 | } | |
1839 | ||
1840 | // Initialize contors | |
1841 | Int_t ntracks, // number of TRD track candidates | |
1842 | ntracks1, // number of registered TRD tracks/iter | |
1843 | ntracks2 = 0; // number of all registered TRD tracks in stack | |
1844 | fSieveSeeding = 0; | |
1845 | do{ | |
1846 | // Loop over seeding configurations | |
1847 | ntracks = 0; ntracks1 = 0; | |
1848 | for (Int_t iconf = 0; iconf<3; iconf++) { | |
1849 | pars[0] = configs[iconf]; | |
1850 | pars[1] = ntracks; | |
1851 | ntracks = MakeSeeds(stack, &sseed[6*ntracks], pars); | |
1852 | if(ntracks == kMaxTracksStack) break; | |
1853 | } | |
3a039a31 | 1854 | if(fReconstructor->GetStreamLevel(AliTRDReconstructor::kTracker) > 1) AliInfo(Form("Candidate TRD tracks %d in iteration %d.", ntracks, fSieveSeeding)); |
41702fec | 1855 | |
1856 | if(!ntracks) break; | |
1857 | ||
1858 | // Sort the seeds according to their quality | |
1859 | Int_t sort[kMaxTracksStack]; | |
1860 | TMath::Sort(ntracks, fTrackQuality, sort, kTRUE); | |
1861 | ||
1862 | // Initialize number of tracks so far and logic switches | |
1863 | Int_t ntracks0 = esdTrackList->GetEntriesFast(); | |
1864 | Bool_t signedTrack[kMaxTracksStack]; | |
1865 | Bool_t fakeTrack[kMaxTracksStack]; | |
1866 | for (Int_t i=0; i<ntracks; i++){ | |
1867 | signedTrack[i] = kFALSE; | |
1868 | fakeTrack[i] = kFALSE; | |
1869 | } | |
1870 | //AliInfo("Selecting track candidates ..."); | |
1871 | ||
1872 | // Sieve clusters in decreasing order of track quality | |
1873 | Double_t trackParams[7]; | |
1874 | // AliTRDseedV1 *lseed = 0x0; | |
1875 | Int_t jSieve = 0, candidates; | |
1876 | do{ | |
1877 | //AliInfo(Form("\t\tITER = %i ", jSieve)); | |
1878 | ||
1879 | // Check track candidates | |
1880 | candidates = 0; | |
1881 | for (Int_t itrack = 0; itrack < ntracks; itrack++) { | |
804bb02e | 1882 | Int_t trackIndex = sort[itrack]; |
1883 | if (signedTrack[trackIndex] || fakeTrack[trackIndex]) continue; | |
41702fec | 1884 | |
1885 | ||
804bb02e | 1886 | // Calculate track parameters from tracklets seeds |
1887 | Int_t labelsall[1000]; | |
1888 | Int_t nlabelsall = 0; | |
1889 | Int_t naccepted = 0; | |
1890 | Int_t ncl = 0; | |
1891 | Int_t nused = 0; | |
1892 | Int_t nlayers = 0; | |
1893 | Int_t findable = 0; | |
1894 | for (Int_t jLayer = 0; jLayer < kNPlanes; jLayer++) { | |
1895 | Int_t jseed = kNPlanes*trackIndex+jLayer; | |
1896 | if(!sseed[jseed].IsOK()) continue; | |
1897 | if (TMath::Abs(sseed[jseed].GetYref(0) / sseed[jseed].GetX0()) < 0.15) findable++; | |
1898 | ||
1899 | sseed[jseed].UpdateUsed(); | |
1900 | ncl += sseed[jseed].GetN2(); | |
1901 | nused += sseed[jseed].GetNUsed(); | |
1902 | nlayers++; | |
1903 | ||
1904 | // // Cooking label | |
1905 | // for (Int_t itime = 0; itime < fgNTimeBins; itime++) { | |
1906 | // if(!sseed[jseed].IsUsable(itime)) continue; | |
1907 | // naccepted++; | |
1908 | // Int_t tindex = 0, ilab = 0; | |
1909 | // while(ilab<3 && (tindex = sseed[jseed].GetClusters(itime)->GetLabel(ilab)) >= 0){ | |
1910 | // labelsall[nlabelsall++] = tindex; | |
1911 | // ilab++; | |
1912 | // } | |
1913 | // } | |
1914 | } | |
1915 | ||
41702fec | 1916 | // Filter duplicated tracks |
1917 | if (nused > 30){ | |
1918 | //printf("Skip %d nused %d\n", trackIndex, nused); | |
1919 | fakeTrack[trackIndex] = kTRUE; | |
1920 | continue; | |
1921 | } | |
1922 | if (Float_t(nused)/ncl >= .25){ | |
1923 | //printf("Skip %d nused/ncl >= .25\n", trackIndex); | |
1924 | fakeTrack[trackIndex] = kTRUE; | |
1925 | continue; | |
1926 | } | |
1927 | ||
1928 | // Classify tracks | |
1929 | Bool_t skip = kFALSE; | |
1930 | switch(jSieve){ | |
1931 | case 0: | |
1932 | if(nlayers < 6) {skip = kTRUE; break;} | |
1933 | if(TMath::Log(1.E-9+fTrackQuality[trackIndex]) < -5.){skip = kTRUE; break;} | |
1934 | break; | |
1935 | ||
1936 | case 1: | |
1937 | if(nlayers < findable){skip = kTRUE; break;} | |
1938 | if(TMath::Log(1.E-9+fTrackQuality[trackIndex]) < -4.){skip = kTRUE; break;} | |
1939 | break; | |
1940 | ||
1941 | case 2: | |
1942 | if ((nlayers == findable) || (nlayers == 6)) { skip = kTRUE; break;} | |
1943 | if (TMath::Log(1.E-9+fTrackQuality[trackIndex]) < -6.0){skip = kTRUE; break;} | |
1944 | break; | |
1945 | ||
1946 | case 3: | |
1947 | if (TMath::Log(1.E-9+fTrackQuality[trackIndex]) < -5.){skip = kTRUE; break;} | |
1948 | break; | |
1949 | ||
1950 | case 4: | |
1951 | if (nlayers == 3){skip = kTRUE; break;} | |
1952 | //if (TMath::Log(1.E-9+fTrackQuality[trackIndex]) - nused/(nlayers-3.0) < -15.0){skip = kTRUE; break;} | |
1953 | break; | |
1954 | } | |
1955 | if(skip){ | |
1956 | candidates++; | |
1957 | //printf("REJECTED : %d [%d] nlayers %d trackQuality = %e nused %d\n", itrack, trackIndex, nlayers, fTrackQuality[trackIndex], nused); | |
1958 | continue; | |
1959 | } | |
1960 | signedTrack[trackIndex] = kTRUE; | |
1961 | ||
41702fec | 1962 | |
1963 | // Sign clusters | |
1964 | AliTRDcluster *cl = 0x0; Int_t clusterIndex = -1; | |
be24510a | 1965 | for (Int_t jLayer = 0; jLayer < kNPlanes; jLayer++) { |
41702fec | 1966 | Int_t jseed = kNPlanes*trackIndex+jLayer; |
1967 | if(!sseed[jseed].IsOK()) continue; | |
1968 | if(TMath::Abs(sseed[jseed].GetYfit(1) - sseed[jseed].GetYfit(1)) >= .2) continue; // check this condition with Marian | |
1969 | sseed[jseed].UseClusters(); | |
1970 | if(!cl){ | |
1971 | Int_t ic = 0; | |
1972 | while(!(cl = sseed[jseed].GetClusters(ic))) ic++; | |
1973 | clusterIndex = sseed[jseed].GetIndexes(ic); | |
1974 | } | |
1975 | } | |
1976 | if(!cl) continue; | |
1977 | ||
1978 | ||
1979 | // Build track parameters | |
1980 | AliTRDseedV1 *lseed =&sseed[trackIndex*6]; | |
e79f8eb0 | 1981 | /* Int_t idx = 0; |
41702fec | 1982 | while(idx<3 && !lseed->IsOK()) { |
1983 | idx++; | |
1984 | lseed++; | |
e79f8eb0 | 1985 | }*/ |
e79f8eb0 | 1986 | Double_t x = lseed->GetX0();// - 3.5; |
41702fec | 1987 | trackParams[0] = x; //NEW AB |
e79f8eb0 | 1988 | trackParams[1] = lseed->GetYref(0); // lseed->GetYat(x); |
1989 | trackParams[2] = lseed->GetZref(0); // lseed->GetZat(x); | |
1990 | trackParams[3] = TMath::Sin(TMath::ATan(lseed->GetYref(1))); | |
41702fec | 1991 | trackParams[4] = lseed->GetZref(1) / TMath::Sqrt(1. + lseed->GetYref(1) * lseed->GetYref(1)); |
be24510a | 1992 | trackParams[5] = lseed->GetC(); |
41702fec | 1993 | Int_t ich = 0; while(!(chamber = stack[ich])) ich++; |
1994 | trackParams[6] = fGeom->GetSector(chamber->GetDetector());/* *alpha+shift; // Supermodule*/ | |
1995 | ||
3a039a31 | 1996 | if(fReconstructor->GetStreamLevel(AliTRDReconstructor::kTracker) > 1){ |
41702fec | 1997 | AliInfo(Form("Track %d [%d] nlayers %d trackQuality = %e nused %d, yref = %3.3f", itrack, trackIndex, nlayers, fTrackQuality[trackIndex], nused, trackParams[1])); |
1998 | ||
1999 | Int_t nclusters = 0; | |
2000 | AliTRDseedV1 *dseed[6]; | |
804bb02e | 2001 | |
2002 | // Build track label - what happens if measured data ??? | |
2003 | Int_t labels[1000]; | |
2004 | Int_t outlab[1000]; | |
2005 | Int_t nlab = 0; | |
2006 | for (Int_t iLayer = 0; iLayer < kNPlanes; iLayer++) { | |
2007 | Int_t jseed = kNPlanes*trackIndex+iLayer; | |
2008 | dseed[iLayer] = new AliTRDseedV1(sseed[jseed]); | |
2009 | dseed[iLayer]->SetOwner(); | |
2010 | nclusters += sseed[jseed].GetN2(); | |
2011 | if(!sseed[jseed].IsOK()) continue; | |
2012 | for(int ilab=0; ilab<2; ilab++){ | |
2013 | if(sseed[jseed].GetLabels(ilab) < 0) continue; | |
2014 | labels[nlab] = sseed[jseed].GetLabels(ilab); | |
2015 | nlab++; | |
2016 | } | |
41702fec | 2017 | } |
804bb02e | 2018 | Freq(nlab,labels,outlab,kFALSE); |
2019 | Int_t label = outlab[0]; | |
2020 | Int_t frequency = outlab[1]; | |
2021 | Freq(nlabelsall,labelsall,outlab,kFALSE); | |
2022 | Int_t label1 = outlab[0]; | |
2023 | Int_t label2 = outlab[2]; | |
2024 | Float_t fakeratio = (naccepted - outlab[1]) / Float_t(naccepted); | |
2025 | ||
41702fec | 2026 | //Int_t eventNrInFile = esd->GetEventNumberInFile(); |
2027 | //AliInfo(Form("Number of clusters %d.", nclusters)); | |
2028 | Int_t eventNumber = AliTRDtrackerDebug::GetEventNumber(); | |
2029 | Int_t trackNumber = AliTRDtrackerDebug::GetTrackNumber(); | |
2030 | Int_t candidateNumber = AliTRDtrackerDebug::GetCandidateNumber(); | |
2031 | TTreeSRedirector &cstreamer = *fgDebugStreamer; | |
2032 | cstreamer << "Clusters2TracksStack" | |
2033 | << "EventNumber=" << eventNumber | |
2034 | << "TrackNumber=" << trackNumber | |
2035 | << "CandidateNumber=" << candidateNumber | |
2036 | << "Iter=" << fSieveSeeding | |
2037 | << "Like=" << fTrackQuality[trackIndex] | |
2038 | << "S0.=" << dseed[0] | |
2039 | << "S1.=" << dseed[1] | |
2040 | << "S2.=" << dseed[2] | |
2041 | << "S3.=" << dseed[3] | |
2042 | << "S4.=" << dseed[4] | |
2043 | << "S5.=" << dseed[5] | |
2044 | << "p0=" << trackParams[0] | |
2045 | << "p1=" << trackParams[1] | |
2046 | << "p2=" << trackParams[2] | |
2047 | << "p3=" << trackParams[3] | |
2048 | << "p4=" << trackParams[4] | |
2049 | << "p5=" << trackParams[5] | |
2050 | << "p6=" << trackParams[6] | |
2051 | << "Label=" << label | |
2052 | << "Label1=" << label1 | |
2053 | << "Label2=" << label2 | |
2054 | << "FakeRatio=" << fakeratio | |
2055 | << "Freq=" << frequency | |
2056 | << "Ncl=" << ncl | |
2057 | << "NLayers=" << nlayers | |
2058 | << "Findable=" << findable | |
41702fec | 2059 | << "NUsed=" << nused |
2060 | << "\n"; | |
2061 | } | |
2062 | ||
2063 | AliTRDtrackV1 *track = MakeTrack(&sseed[trackIndex*kNPlanes], trackParams); | |
2064 | if(!track){ | |
2065 | AliWarning("Fail to build a TRD Track."); | |
2066 | continue; | |
2067 | } | |
2068 | //AliInfo("End of MakeTrack()"); | |
098c3c3d | 2069 | AliESDtrack *esdTrack = new ((*esdTrackList)[ntracks0++]) AliESDtrack(); |
2070 | esdTrack->UpdateTrackParams(track, AliESDtrack::kTRDout); | |
2071 | esdTrack->SetLabel(track->GetLabel()); | |
2072 | track->UpdateESDtrack(esdTrack); | |
41702fec | 2073 | // write ESD-friends if neccessary |
3a039a31 | 2074 | if (fReconstructor->GetStreamLevel(AliTRDReconstructor::kTracker) > 0){ |
41702fec | 2075 | AliTRDtrackV1 *calibTrack = new AliTRDtrackV1(*track); |
2076 | calibTrack->SetOwner(); | |
098c3c3d | 2077 | esdTrack->AddCalibObject(calibTrack); |
41702fec | 2078 | } |
41702fec | 2079 | ntracks1++; |
2080 | AliTRDtrackerDebug::SetTrackNumber(AliTRDtrackerDebug::GetTrackNumber() + 1); | |
2081 | } | |
2082 | ||
2083 | jSieve++; | |
2084 | } while(jSieve<5 && candidates); // end track candidates sieve | |
2085 | if(!ntracks1) break; | |
2086 | ||
2087 | // increment counters | |
2088 | ntracks2 += ntracks1; | |
4302c900 | 2089 | |
2090 | if(fReconstructor->IsHLT()) break; | |
41702fec | 2091 | fSieveSeeding++; |
2092 | ||
2093 | // Rebuild plane configurations and indices taking only unused clusters into account | |
2094 | quality = BuildSeedingConfigs(stack, configs); | |
3a039a31 | 2095 | if(quality < 1.E-7) break; //fReconstructor->GetRecoParam() ->GetPlaneQualityThreshold()) break; |
41702fec | 2096 | |
2097 | for(Int_t ip = 0; ip < kNPlanes; ip++){ | |
2098 | if(!(chamber = stack[ip])) continue; | |
2099 | chamber->Build(fGeom);//Indices(fSieveSeeding); | |
2100 | } | |
2101 | ||
3a039a31 | 2102 | if(fReconstructor->GetStreamLevel(AliTRDReconstructor::kTracker) > 1){ |
41702fec | 2103 | AliInfo(Form("Sieve level %d Plane config %d %d %d Quality %f", fSieveSeeding, configs[0], configs[1], configs[2], quality)); |
2104 | } | |
2105 | } while(fSieveSeeding<10); // end stack clusters sieve | |
2106 | ||
2107 | ||
2108 | ||
2109 | //AliInfo(Form("Registered TRD tracks %d in stack %d.", ntracks2, pars[1])); | |
2110 | ||
2111 | return ntracks2; | |
e4f2f73d | 2112 | } |
2113 | ||
2114 | //___________________________________________________________________ | |
eb38ed55 | 2115 | Double_t AliTRDtrackerV1::BuildSeedingConfigs(AliTRDtrackingChamber **stack, Int_t *configs) |
e4f2f73d | 2116 | { |
41702fec | 2117 | // |
2118 | // Assign probabilities to chambers according to their | |
2119 | // capability of producing seeds. | |
2120 | // | |
2121 | // Parameters : | |
2122 | // | |
2123 | // layers : Array of stack propagation layers for all 6 chambers in one stack | |
2124 | // configs : On exit array of configuration indexes (see GetSeedingConfig() | |
2125 | // for details) in the decreasing order of their seeding probabilities. | |
2126 | // | |
2127 | // Output : | |
2128 | // | |
2129 | // Return top configuration quality | |
2130 | // | |
2131 | // Detailed description: | |
2132 | // | |
2133 | // To each chamber seeding configuration (see GetSeedingConfig() for | |
2134 | // the list of all configurations) one defines 2 quality factors: | |
2135 | // - an apriori topological quality (see GetSeedingConfig() for details) and | |
2136 | // - a data quality based on the uniformity of the distribution of | |
2137 | // clusters over the x range (time bins population). See CookChamberQA() for details. | |
2138 | // The overall chamber quality is given by the product of this 2 contributions. | |
2139 | // | |
2140 | ||
2141 | Double_t chamberQ[kNPlanes]; | |
2142 | AliTRDtrackingChamber *chamber = 0x0; | |
2143 | for(int iplane=0; iplane<kNPlanes; iplane++){ | |
2144 | if(!(chamber = stack[iplane])) continue; | |
2145 | chamberQ[iplane] = (chamber = stack[iplane]) ? chamber->GetQuality() : 0.; | |
2146 | } | |
2147 | ||
2148 | Double_t tconfig[kNConfigs]; | |
2149 | Int_t planes[4]; | |
2150 | for(int iconf=0; iconf<kNConfigs; iconf++){ | |
2151 | GetSeedingConfig(iconf, planes); | |
2152 | tconfig[iconf] = fgTopologicQA[iconf]; | |
2153 | for(int iplane=0; iplane<4; iplane++) tconfig[iconf] *= chamberQ[planes[iplane]]; | |
2154 | } | |
2155 | ||
2156 | TMath::Sort((Int_t)kNConfigs, tconfig, configs, kTRUE); | |
2157 | // AliInfo(Form("q[%d] = %f", configs[0], tconfig[configs[0]])); | |
2158 | // AliInfo(Form("q[%d] = %f", configs[1], tconfig[configs[1]])); | |
2159 | // AliInfo(Form("q[%d] = %f", configs[2], tconfig[configs[2]])); | |
2160 | ||
2161 | return tconfig[configs[0]]; | |
e4f2f73d | 2162 | } |
2163 | ||
2164 | //____________________________________________________________________ | |
eb38ed55 | 2165 | Int_t AliTRDtrackerV1::MakeSeeds(AliTRDtrackingChamber **stack, AliTRDseedV1 *sseed, Int_t *ipar) |
e4f2f73d | 2166 | { |
41702fec | 2167 | // |
2168 | // Make tracklet seeds in the TRD stack. | |
2169 | // | |
2170 | // Parameters : | |
2171 | // layers : Array of stack propagation layers containing clusters | |
2172 | // sseed : Array of empty tracklet seeds. On exit they are filled. | |
2173 | // ipar : Control parameters: | |
2174 | // ipar[0] -> seeding chambers configuration | |
2175 | // ipar[1] -> stack index | |
2176 | // ipar[2] -> number of track candidates found so far | |
2177 | // | |
2178 | // Output : | |
2179 | // Number of tracks candidates found. | |
2180 | // | |
2181 | // Detailed description | |
2182 | // | |
2183 | // The following steps are performed: | |
2184 | // 1. Select seeding layers from seeding chambers | |
2185 | // 2. Select seeding clusters from the seeding AliTRDpropagationLayerStack. | |
2186 | // The clusters are taken from layer 3, layer 0, layer 1 and layer 2, in | |
2187 | // this order. The parameters controling the range of accepted clusters in | |
2188 | // layer 0, 1, and 2 are defined in AliTRDchamberTimeBin::BuildCond(). | |
2189 | // 3. Helix fit of the cluster set. (see AliTRDtrackerFitter::FitRieman(AliTRDcluster**)) | |
2190 | // 4. Initialize seeding tracklets in the seeding chambers. | |
2191 | // 5. Filter 0. | |
2192 | // Chi2 in the Y direction less than threshold ... (1./(3. - sLayer)) | |
2193 | // Chi2 in the Z direction less than threshold ... (1./(3. - sLayer)) | |
2194 | // 6. Attach clusters to seeding tracklets and find linear approximation of | |
2195 | // the tracklet (see AliTRDseedV1::AttachClustersIter()). The number of used | |
2196 | // clusters used by current seeds should not exceed ... (25). | |
2197 | // 7. Filter 1. | |
2198 | // All 4 seeding tracklets should be correctly constructed (see | |
2199 | // AliTRDseedV1::AttachClustersIter()) | |
2200 | // 8. Helix fit of the seeding tracklets | |
2201 | // 9. Filter 2. | |
2202 | // Likelihood calculation of the fit. (See AliTRDtrackerV1::CookLikelihood() for details) | |
2203 | // 10. Extrapolation of the helix fit to the other 2 chambers: | |
2204 | // a) Initialization of extrapolation tracklet with fit parameters | |
2205 | // b) Helix fit of tracklets | |
2206 | // c) Attach clusters and linear interpolation to extrapolated tracklets | |
2207 | // d) Helix fit of tracklets | |
2208 | // 11. Improve seeding tracklets quality by reassigning clusters. | |
2209 | // See AliTRDtrackerV1::ImproveSeedQuality() for details. | |
2210 | // 12. Helix fit of all 6 seeding tracklets and chi2 calculation | |
2211 | // 13. Hyperplane fit and track quality calculation. See AliTRDtrackerFitter::FitHyperplane() for details. | |
2212 | // 14. Cooking labels for tracklets. Should be done only for MC | |
2213 | // 15. Register seeds. | |
2214 | // | |
2215 | ||
2216 | AliTRDtrackingChamber *chamber = 0x0; | |
be24510a | 2217 | AliTRDcluster *c[kNSeedPlanes] = {0x0, 0x0, 0x0, 0x0}; // initilize seeding clusters |
41702fec | 2218 | AliTRDseedV1 *cseed = &sseed[0]; // initialize tracklets for first track |
2219 | Int_t ncl, mcl; // working variable for looping over clusters | |
2220 | Int_t index[AliTRDchamberTimeBin::kMaxClustersLayer], jndex[AliTRDchamberTimeBin::kMaxClustersLayer]; | |
2221 | // chi2 storage | |
2222 | // chi2[0] = tracklet chi2 on the Z direction | |
2223 | // chi2[1] = tracklet chi2 on the R direction | |
2224 | Double_t chi2[4]; | |
2225 | ||
e79f8eb0 | 2226 | // Default positions for the anode wire in all 6 Layers in case of a stack with missing clusters |
2227 | // Positions taken using cosmic data taken with SM3 after rebuild | |
2228 | Double_t x_def[kNPlanes] = {300.2, 312.8, 325.4, 338, 350.6, 363.2}; | |
41702fec | 2229 | |
2230 | // this should be data member of AliTRDtrack | |
2231 | Double_t seedQuality[kMaxTracksStack]; | |
2232 | ||
2233 | // unpack control parameters | |
2234 | Int_t config = ipar[0]; | |
2235 | Int_t ntracks = ipar[1]; | |
2236 | Int_t planes[kNSeedPlanes]; GetSeedingConfig(config, planes); | |
be24510a | 2237 | Int_t planesExt[kNPlanes-kNSeedPlanes]; GetExtrapolationConfig(config, planesExt); |
2238 | ||
2239 | ||
41702fec | 2240 | // Init chambers geometry |
2241 | Int_t ic = 0; while(!(chamber = stack[ic])) ic++; | |
053767a4 | 2242 | Int_t istack = fGeom->GetStack(chamber->GetDetector()); |
41702fec | 2243 | Double_t hL[kNPlanes]; // Tilting angle |
2244 | Float_t padlength[kNPlanes]; // pad lenghts | |
2245 | AliTRDpadPlane *pp = 0x0; | |
2246 | for(int iplane=0; iplane<kNPlanes; iplane++){ | |
2247 | pp = fGeom->GetPadPlane(iplane, istack); | |
bb79ccd5 | 2248 | hL[iplane] = TMath::Tan(TMath::DegToRad()*pp->GetTiltingAngle()); |
41702fec | 2249 | padlength[iplane] = pp->GetLengthIPad(); |
2250 | } | |
2251 | ||
3a039a31 | 2252 | if(fReconstructor->GetStreamLevel(AliTRDReconstructor::kTracker) > 1){ |
41702fec | 2253 | AliInfo(Form("Making seeds Stack[%d] Config[%d] Tracks[%d]...", istack, config, ntracks)); |
2254 | } | |
2255 | ||
d611c74f | 2256 | ResetSeedTB(); |
41702fec | 2257 | Int_t nlayers = 0; |
41702fec | 2258 | for(int isl=0; isl<kNSeedPlanes; isl++){ |
2259 | if(!(chamber = stack[planes[isl]])) continue; | |
3a039a31 | 2260 | if(!chamber->GetSeedingLayer(fSeedTB[isl], fGeom, fReconstructor)) continue; |
41702fec | 2261 | nlayers++; |
41702fec | 2262 | } |
2263 | if(nlayers < 4) return 0; | |
2264 | ||
2265 | ||
2266 | // Start finding seeds | |
2267 | Double_t cond0[4], cond1[4], cond2[4]; | |
2268 | Int_t icl = 0; | |
d611c74f | 2269 | while((c[3] = (*fSeedTB[3])[icl++])){ |
41702fec | 2270 | if(!c[3]) continue; |
d611c74f | 2271 | fSeedTB[0]->BuildCond(c[3], cond0, 0); |
2272 | fSeedTB[0]->GetClusters(cond0, index, ncl); | |
41702fec | 2273 | //printf("Found c[3] candidates 0 %d\n", ncl); |
2274 | Int_t jcl = 0; | |
2275 | while(jcl<ncl) { | |
d611c74f | 2276 | c[0] = (*fSeedTB[0])[index[jcl++]]; |
41702fec | 2277 | if(!c[0]) continue; |
2278 | Double_t dx = c[3]->GetX() - c[0]->GetX(); | |
2279 | Double_t theta = (c[3]->GetZ() - c[0]->GetZ())/dx; | |
2280 | Double_t phi = (c[3]->GetY() - c[0]->GetY())/dx; | |
d611c74f | 2281 | fSeedTB[1]->BuildCond(c[0], cond1, 1, theta, phi); |
2282 | fSeedTB[1]->GetClusters(cond1, jndex, mcl); | |
41702fec | 2283 | //printf("Found c[0] candidates 1 %d\n", mcl); |
2284 | ||
2285 | Int_t kcl = 0; | |
2286 | while(kcl<mcl) { | |
d611c74f | 2287 | c[1] = (*fSeedTB[1])[jndex[kcl++]]; |
2288 | if(!c[1]) continue; | |
2289 | fSeedTB[2]->BuildCond(c[1], cond2, 2, theta, phi); | |
2290 | c[2] = fSeedTB[2]->GetNearestCluster(cond2); | |
2291 | //printf("Found c[1] candidate 2 %p\n", c[2]); | |
2292 | if(!c[2]) continue; | |
2293 | ||
2294 | // AliInfo("Seeding clusters found. Building seeds ..."); | |
2295 | // for(Int_t i = 0; i < kNSeedPlanes; i++) printf("%i. coordinates: x = %6.3f, y = %6.3f, z = %6.3f\n", i, c[i]->GetX(), c[i]->GetY(), c[i]->GetZ()); | |
2296 | ||
804bb02e | 2297 | for (Int_t il = 0; il < kNPlanes; il++) cseed[il].Reset(); |
41702fec | 2298 | |
d611c74f | 2299 | FitRieman(c, chi2); |
2300 | ||
2301 | AliTRDseedV1 *tseed = 0x0; | |
3a039a31 | 2302 | for(int iLayer=0; iLayer<kNPlanes; iLayer++){ |
43d6ad34 | 2303 | tseed = &cseed[iLayer]; |
2304 | tseed->SetPlane(iLayer); | |
2305 | tseed->SetTilt(hL[iLayer]); | |
2306 | tseed->SetPadLength(padlength[iLayer]); | |
3a039a31 | 2307 | tseed->SetReconstructor(fReconstructor); |
e79f8eb0 | 2308 | Double_t x_anode = stack[iLayer] ? stack[iLayer]->GetX() : x_def[iLayer]; |
2309 | tseed->SetX0(x_anode); | |
d611c74f | 2310 | tseed->Init(GetRiemanFitter()); |
2311 | } | |
2312 | ||
2313 | Bool_t isFake = kFALSE; | |
3a039a31 | 2314 | if(fReconstructor->GetStreamLevel(AliTRDReconstructor::kTracker) >= 2){ |
d611c74f | 2315 | if (c[0]->GetLabel(0) != c[3]->GetLabel(0)) isFake = kTRUE; |
2316 | if (c[1]->GetLabel(0) != c[3]->GetLabel(0)) isFake = kTRUE; | |
2317 | if (c[2]->GetLabel(0) != c[3]->GetLabel(0)) isFake = kTRUE; | |
2318 | ||
2319 | Double_t xpos[4]; | |
2320 | for(Int_t l = 0; l < kNSeedPlanes; l++) xpos[l] = fSeedTB[l]->GetX(); | |
2321 | Float_t yref[4]; | |
2322 | for(int il=0; il<4; il++) yref[il] = cseed[planes[il]].GetYref(0); | |
2323 | Int_t ll = c[3]->GetLabel(0); | |
2324 | Int_t eventNumber = AliTRDtrackerDebug::GetEventNumber(); | |
2325 | Int_t candidateNumber = AliTRDtrackerDebug::GetCandidateNumber(); | |
2326 | AliRieman *rim = GetRiemanFitter(); | |
2327 | TTreeSRedirector &cs0 = *fgDebugStreamer; | |
2328 | cs0 << "MakeSeeds0" | |
2329 | <<"EventNumber=" << eventNumber | |
2330 | <<"CandidateNumber=" << candidateNumber | |
2331 | <<"isFake=" << isFake | |
2332 | <<"config=" << config | |
2333 | <<"label=" << ll | |
2334 | <<"chi2z=" << chi2[0] | |
2335 | <<"chi2y=" << chi2[1] | |
2336 | <<"Y2exp=" << cond2[0] | |
2337 | <<"Z2exp=" << cond2[1] | |
2338 | <<"X0=" << xpos[0] //layer[sLayer]->GetX() | |
2339 | <<"X1=" << xpos[1] //layer[sLayer + 1]->GetX() | |
2340 | <<"X2=" << xpos[2] //layer[sLayer + 2]->GetX() | |
2341 | <<"X3=" << xpos[3] //layer[sLayer + 3]->GetX() | |
2342 | <<"yref0=" << yref[0] | |
2343 | <<"yref1=" << yref[1] | |
2344 | <<"yref2=" << yref[2] | |
2345 | <<"yref3=" << yref[3] | |
2346 | <<"c0.=" << c[0] | |
2347 | <<"c1.=" << c[1] | |
2348 | <<"c2.=" << c[2] | |
2349 | <<"c3.=" << c[3] | |
2350 | <<"Seed0.=" << &cseed[planes[0]] | |
2351 | <<"Seed1.=" << &cseed[planes[1]] | |
2352 | <<"Seed2.=" << &cseed[planes[2]] | |
2353 | <<"Seed3.=" << &cseed[planes[3]] | |
2354 | <<"RiemanFitter.=" << rim | |
2355 | <<"\n"; | |
2356 | } | |
2357 | ||
3a039a31 | 2358 | if(chi2[0] > fReconstructor->GetRecoParam() ->GetChi2Z()/*7./(3. - sLayer)*//*iter*/){ |
d611c74f | 2359 | //AliInfo(Form("Failed chi2 filter on chi2Z [%f].", chi2[0])); |
2360 | AliTRDtrackerDebug::SetCandidateNumber(AliTRDtrackerDebug::GetCandidateNumber() + 1); | |
2361 | continue; | |
2362 | } | |
3a039a31 | 2363 | if(chi2[1] > fReconstructor->GetRecoParam() ->GetChi2Y()/*1./(3. - sLayer)*//*iter*/){ |
d611c74f | 2364 | //AliInfo(Form("Failed chi2 filter on chi2Y [%f].", chi2[1])); |
2365 | AliTRDtrackerDebug::SetCandidateNumber(AliTRDtrackerDebug::GetCandidateNumber() + 1); | |
2366 | continue; | |
2367 | } | |
2368 | //AliInfo("Passed chi2 filter."); | |
2369 | ||
2370 | // try attaching clusters to tracklets | |
2371 | Int_t nUsedCl = 0; | |
2372 | Int_t mlayers = 0; | |
be24510a | 2373 | for(int iLayer=0; iLayer<kNSeedPlanes; iLayer++){ |
d611c74f | 2374 | Int_t jLayer = planes[iLayer]; |
2375 | if(!cseed[jLayer].AttachClustersIter(stack[jLayer], 5., kFALSE, c[iLayer])) continue; | |
2376 | nUsedCl += cseed[jLayer].GetNUsed(); | |
2377 | if(nUsedCl > 25) break; | |
2378 | mlayers++; | |
2379 | } | |
be24510a | 2380 | |
2381 | if(mlayers < kNSeedPlanes){ | |
2382 | //AliInfo(Form("Failed updating all seeds %d [%d].", mlayers, kNSeedPlanes)); | |
2383 | AliTRDtrackerDebug::SetCandidateNumber(AliTRDtrackerDebug::GetCandidateNumber() + 1); | |
2384 | continue; | |
2385 | } | |
2386 | ||
2387 | // temporary exit door for the HLT | |
4302c900 | 2388 | if(fReconstructor->IsHLT()){ |
be24510a | 2389 | // attach clusters to extrapolation chambers |
2390 | for(int iLayer=0; iLayer<kNPlanes-kNSeedPlanes; iLayer++){ | |
2391 | Int_t jLayer = planesExt[iLayer]; | |
2392 | if(!(chamber = stack[jLayer])) continue; | |
2393 | cseed[jLayer].AttachClustersIter(chamber, 1000.); | |
2394 | } | |
4302c900 | 2395 | fTrackQuality[ntracks] = 1.; // dummy value |
2396 | ntracks++; | |
2397 | if(ntracks == kMaxTracksStack){ | |
2398 | AliWarning(Form("Number of seeds reached maximum allowed (%d) in stack.", kMaxTracksStack)); | |
2399 | return ntracks; | |
2400 | } | |
2401 | cseed += 6; | |
2402 | continue; | |
2403 | } | |
2404 | ||
be24510a | 2405 | |
d611c74f | 2406 | // fit tracklets and cook likelihood |
2407 | FitTiltedRieman(&cseed[0], kTRUE);// Update Seeds and calculate Likelihood | |
2408 | chi2[0] = GetChi2Y(&cseed[0]); | |
2409 | chi2[1] = GetChi2Z(&cseed[0]); | |
2410 | //Chi2 definitions in testing stage | |
2411 | //chi2[0] = GetChi2YTest(&cseed[0]); | |
2412 | //chi2[1] = GetChi2ZTest(&cseed[0]); | |
2413 | Double_t like = CookLikelihood(&cseed[0], planes, chi2); // to be checked | |
2414 | ||
3a039a31 | 2415 | if (TMath::Log(1.E-9 + like) < fReconstructor->GetRecoParam() ->GetTrackLikelihood()){ |
d611c74f | 2416 | //AliInfo(Form("Failed likelihood %f[%e].", TMath::Log(1.E-9 + like), like)); |
2417 | AliTRDtrackerDebug::SetCandidateNumber(AliTRDtrackerDebug::GetCandidateNumber() + 1); | |
2418 | continue; | |
2419 | } | |
2420 | //AliInfo(Form("Passed likelihood %f[%e].", TMath::Log(1.E-9 + like), like)); | |
2421 | ||
2422 | // book preliminary results | |
2423 | seedQuality[ntracks] = like; | |
2424 | fSeedLayer[ntracks] = config;/*sLayer;*/ | |
2425 | ||
2426 | // attach clusters to the extrapolation seeds | |
d611c74f | 2427 | Int_t nusedf = 0; // debug value |
be24510a | 2428 | for(int iLayer=0; iLayer<kNPlanes-kNSeedPlanes; iLayer++){ |
2429 | Int_t jLayer = planesExt[iLayer]; | |
d611c74f | 2430 | if(!(chamber = stack[jLayer])) continue; |
d611c74f | 2431 | |
2432 | // fit extrapolated seed | |
2433 | if ((jLayer == 0) && !(cseed[1].IsOK())) continue; | |
2434 | if ((jLayer == 5) && !(cseed[4].IsOK())) continue; | |
2435 | AliTRDseedV1 pseed = cseed[jLayer]; | |
2436 | if(!pseed.AttachClustersIter(chamber, 1000.)) continue; | |
2437 | cseed[jLayer] = pseed; | |
2438 | nusedf += cseed[jLayer].GetNUsed(); // debug value | |
2439 | FitTiltedRieman(cseed, kTRUE); | |
2440 | } | |
2441 | ||
2442 | // AliInfo("Extrapolation done."); | |
2443 | // Debug Stream containing all the 6 tracklets | |
3a039a31 | 2444 | if(fReconstructor->GetStreamLevel(AliTRDReconstructor::kTracker) >= 2){ |
d611c74f | 2445 | TTreeSRedirector &cstreamer = *fgDebugStreamer; |
2446 | TLinearFitter *tiltedRieman = GetTiltedRiemanFitter(); | |
2447 | Int_t eventNumber = AliTRDtrackerDebug::GetEventNumber(); | |
2448 | Int_t candidateNumber = AliTRDtrackerDebug::GetCandidateNumber(); | |
2449 | cstreamer << "MakeSeeds1" | |
2450 | << "EventNumber=" << eventNumber | |
2451 | << "CandidateNumber=" << candidateNumber | |
2452 | << "S0.=" << &cseed[0] | |
2453 | << "S1.=" << &cseed[1] | |
2454 | << "S2.=" << &cseed[2] | |
2455 | << "S3.=" << &cseed[3] | |
2456 | << "S4.=" << &cseed[4] | |
2457 | << "S5.=" << &cseed[5] | |
2458 | << "FitterT.=" << tiltedRieman | |
2459 | << "\n"; | |
2460 | } | |
2461 | ||
fb872574 | 2462 | if(fReconstructor->GetRecoParam()->HasImproveTracklets() && ImproveSeedQuality(stack, cseed) < 4){ |
d611c74f | 2463 | AliTRDtrackerDebug::SetCandidateNumber(AliTRDtrackerDebug::GetCandidateNumber() + 1); |
2464 | continue; | |
2465 | } | |
2466 | //AliInfo("Improve seed quality done."); | |
2467 | ||
2468 | // fit full track and cook likelihoods | |
2469 | // Double_t curv = FitRieman(&cseed[0], chi2); | |
2470 | // Double_t chi2ZF = chi2[0] / TMath::Max((mlayers - 3.), 1.); | |
2471 | // Double_t chi2RF = chi2[1] / TMath::Max((mlayers - 3.), 1.); | |
2472 | ||
2473 | // do the final track fitting (Once with vertex constraint and once without vertex constraint) | |
2474 | Double_t chi2Vals[3]; | |
2475 | chi2Vals[0] = FitTiltedRieman(&cseed[0], kFALSE); | |
3a039a31 | 2476 | if(fReconstructor->GetRecoParam() ->IsVertexConstrained()) |
d611c74f | 2477 | chi2Vals[1] = FitTiltedRiemanConstraint(&cseed[0], GetZ()); // Do Vertex Constrained fit if desired |
2478 | else | |
2479 | chi2Vals[1] = 1.; | |
2480 | chi2Vals[2] = GetChi2Z(&cseed[0]) / TMath::Max((mlayers - 3.), 1.); | |
2481 | // Chi2 definitions in testing stage | |
2482 | //chi2Vals[2] = GetChi2ZTest(&cseed[0]); | |
2483 | fTrackQuality[ntracks] = CalculateTrackLikelihood(&cseed[0], &chi2Vals[0]); | |
2484 | //AliInfo("Hyperplane fit done\n"); | |
2485 | ||
2486 | // finalize tracklets | |
2487 | Int_t labels[12]; | |
2488 | Int_t outlab[24]; | |
2489 | Int_t nlab = 0; | |
2490 | for (Int_t iLayer = 0; iLayer < 6; iLayer++) { | |
2491 | if (!cseed[iLayer].IsOK()) continue; | |
2492 | ||
2493 | if (cseed[iLayer].GetLabels(0) >= 0) { | |
2494 | labels[nlab] = cseed[iLayer].GetLabels(0); | |
2495 | nlab++; | |
2496 | } | |
2497 | ||
2498 | if (cseed[iLayer].GetLabels(1) >= 0) { | |
2499 | labels[nlab] = cseed[iLayer].GetLabels(1); | |
2500 | nlab++; | |
2501 | } | |
2502 | } | |
2503 | Freq(nlab,labels,outlab,kFALSE); | |
2504 | Int_t label = outlab[0]; | |
2505 | Int_t frequency = outlab[1]; | |
2506 | for (Int_t iLayer = 0; iLayer < 6; iLayer++) { | |
2507 | cseed[iLayer].SetFreq(frequency); | |
2508 | cseed[iLayer].SetChi2Z(chi2[1]); | |
2509 | } | |
2510 | ||
3a039a31 | 2511 | if(fReconstructor->GetStreamLevel(AliTRDReconstructor::kTracker) >= 2){ |
d611c74f | 2512 | TTreeSRedirector &cstreamer = *fgDebugStreamer; |
2513 | Int_t eventNumber = AliTRDtrackerDebug::GetEventNumber(); | |
2514 | Int_t candidateNumber = AliTRDtrackerDebug::GetCandidateNumber(); | |
2515 | TLinearFitter *fitterTC = GetTiltedRiemanFitterConstraint(); | |
2516 | TLinearFitter *fitterT = GetTiltedRiemanFitter(); | |
2517 | cstreamer << "MakeSeeds2" | |
2518 | << "EventNumber=" << eventNumber | |
2519 | << "CandidateNumber=" << candidateNumber | |
2520 | << "Chi2TR=" << chi2Vals[0] | |
2521 | << "Chi2TC=" << chi2Vals[1] | |
2522 | << "Nlayers=" << mlayers | |
2523 | << "NUsedS=" << nUsedCl | |
2524 | << "NUsed=" << nusedf | |
2525 | << "Like=" << like | |
2526 | << "S0.=" << &cseed[0] | |
2527 | << "S1.=" << &cseed[1] | |
2528 | << "S2.=" << &cseed[2] | |
2529 | << "S3.=" << &cseed[3] | |
2530 | << "S4.=" << &cseed[4] | |
2531 | << "S5.=" << &cseed[5] | |
2532 | << "Label=" << label | |
2533 | << "Freq=" << frequency | |
2534 | << "FitterT.=" << fitterT | |
2535 | << "FitterTC.=" << fitterTC | |
2536 | << "\n"; | |
2537 | } | |
2538 | ||
2539 | ntracks++; | |
2540 | AliTRDtrackerDebug::SetCandidateNumber(AliTRDtrackerDebug::GetCandidateNumber() + 1); | |
2541 | if(ntracks == kMaxTracksStack){ | |
2542 | AliWarning(Form("Number of seeds reached maximum allowed (%d) in stack.", kMaxTracksStack)); | |
2543 | return ntracks; | |
2544 | } | |
2545 | cseed += 6; | |
41702fec | 2546 | } |
2547 | } | |
2548 | } | |
41702fec | 2549 | |
2550 | return ntracks; | |
e4f2f73d | 2551 | } |
2552 | ||
2553 | //_____________________________________________________________________________ | |
0906e73e | 2554 | AliTRDtrackV1* AliTRDtrackerV1::MakeTrack(AliTRDseedV1 *seeds, Double_t *params) |
e4f2f73d | 2555 | { |
41702fec | 2556 | // |
2557 | // Build a TRD track out of tracklet candidates | |
2558 | // | |
2559 | // Parameters : | |
2560 | // seeds : array of tracklets | |
2561 | // params : track parameters (see MakeSeeds() function body for a detailed description) | |
2562 | // | |
2563 | // Output : | |
2564 | // The TRD track. | |
2565 | // | |
2566 | // Detailed description | |
2567 | // | |
2568 | // To be discussed with Marian !! | |
2569 | // | |
2570 | ||
2571 | AliTRDCalibraFillHisto *calibra = AliTRDCalibraFillHisto::Instance(); | |
2572 | if (!calibra) AliInfo("Could not get Calibra instance\n"); | |
2573 | ||
2574 | Double_t alpha = AliTRDgeometry::GetAlpha(); | |
2575 | Double_t shift = AliTRDgeometry::GetAlpha()/2.0; | |
2576 | Double_t c[15]; | |
2577 | ||
2578 | c[ 0] = 0.2; | |
2579 | c[ 1] = 0.0; c[ 2] = 2.0; | |
2580 | c[ 3] = 0.0; c[ 4] = 0.0; c[ 5] = 0.02; | |
2581 | c[ 6] = 0.0; c[ 7] = 0.0; c[ 8] = 0.0; c[ 9] = 0.1; | |
2582 | c[10] = 0.0; c[11] = 0.0; c[12] = 0.0; c[13] = 0.0; c[14] = params[5]*params[5]*0.01; | |
2583 | ||
d20df6fc | 2584 | AliTRDtrackV1 track(seeds, ¶ms[1], c, params[0], params[6]*alpha+shift); |
2585 | track.PropagateTo(params[0]-5.0); | |
2586 | track.ResetCovariance(1); | |
e79f8eb0 | 2587 | Int_t nc = TMath::Abs(FollowBackProlongation(track)); |
d20df6fc | 2588 | if (nc < 30) return 0x0; |
2589 | ||
2590 | AliTRDtrackV1 *ptrTrack = SetTrack(&track); | |
2591 | ptrTrack->CookLabel(.9); | |
2592 | // computes PID for track | |
2593 | ptrTrack->CookPID(); | |
2594 | // update calibration references using this track | |
2595 | if(calibra->GetHisto2d()) calibra->UpdateHistogramsV1(ptrTrack); | |
2596 | ||
2597 | return ptrTrack; | |
e4f2f73d | 2598 | } |
2599 | ||
0906e73e | 2600 | |
e4f2f73d | 2601 | //____________________________________________________________________ |
eb38ed55 | 2602 | Int_t AliTRDtrackerV1::ImproveSeedQuality(AliTRDtrackingChamber **stack, AliTRDseedV1 *cseed) |
e4f2f73d | 2603 | { |
41702fec | 2604 | // |
2605 | // Sort tracklets according to "quality" and try to "improve" the first 4 worst | |
2606 | // | |
2607 | // Parameters : | |
2608 | // layers : Array of propagation layers for a stack/supermodule | |
2609 | // cseed : Array of 6 seeding tracklets which has to be improved | |
2610 | // | |
2611 | // Output : | |
2612 | // cssed : Improved seeds | |
2613 | // | |
2614 | // Detailed description | |
2615 | // | |
2616 | // Iterative procedure in which new clusters are searched for each | |
2617 | // tracklet seed such that the seed quality (see AliTRDseed::GetQuality()) | |
2618 | // can be maximized. If some optimization is found the old seeds are replaced. | |
2619 | // | |
2620 | // debug level: 7 | |
2621 | // | |
2622 | ||
2623 | // make a local working copy | |
2624 | AliTRDtrackingChamber *chamber = 0x0; | |
2625 | AliTRDseedV1 bseed[6]; | |
2626 | Int_t nLayers = 0; | |
2627 | for (Int_t jLayer = 0; jLayer < 6; jLayer++) bseed[jLayer] = cseed[jLayer]; | |
2628 | ||
2629 | Float_t lastquality = 10000.0; | |
2630 | Float_t lastchi2 = 10000.0; | |
2631 | Float_t chi2 = 1000.0; | |
2632 | ||
2633 | for (Int_t iter = 0; iter < 4; iter++) { | |
2634 | Float_t sumquality = 0.0; | |
2635 | Float_t squality[6]; | |
2636 | Int_t sortindexes[6]; | |
2637 | ||
2638 | for (Int_t jLayer = 0; jLayer < 6; jLayer++) { | |
3a039a31 | 2639 | squality[jLayer] = bseed[jLayer].IsOK() ? bseed[jLayer].GetQuality(kTRUE) : 1000.; |
41702fec | 2640 | sumquality += squality[jLayer]; |
2641 | } | |
2642 | if ((sumquality >= lastquality) || (chi2 > lastchi2)) break; | |
2643 | ||
2644 | nLayers = 0; | |
2645 | lastquality = sumquality; | |
2646 | lastchi2 = chi2; | |
2647 | if (iter > 0) for (Int_t jLayer = 0; jLayer < 6; jLayer++) cseed[jLayer] = bseed[jLayer]; | |
2648 | ||
2649 | TMath::Sort(6, squality, sortindexes, kFALSE); | |
2650 | for (Int_t jLayer = 5; jLayer > 1; jLayer--) { | |
2651 | Int_t bLayer = sortindexes[jLayer]; | |
2652 | if(!(chamber = stack[bLayer])) continue; | |
2653 | bseed[bLayer].AttachClustersIter(chamber, squality[bLayer], kTRUE); | |
2654 | if(bseed[bLayer].IsOK()) nLayers++; | |
2655 | } | |
2656 | ||
2657 | chi2 = FitTiltedRieman(bseed, kTRUE); | |
3a039a31 | 2658 | if(fReconstructor->GetStreamLevel(AliTRDReconstructor::kTracker) >= 7){ |
41702fec | 2659 | Int_t eventNumber = AliTRDtrackerDebug::GetEventNumber(); |
2660 | Int_t candidateNumber = AliTRDtrackerDebug::GetCandidateNumber(); | |
2661 | TLinearFitter *tiltedRieman = GetTiltedRiemanFitter(); | |
2662 | TTreeSRedirector &cstreamer = *fgDebugStreamer; | |
2663 | cstreamer << "ImproveSeedQuality" | |
2664 | << "EventNumber=" << eventNumber | |
2665 | << "CandidateNumber=" << candidateNumber | |
2666 | << "Iteration=" << iter | |
2667 | << "S0.=" << &bseed[0] | |
2668 | << "S1.=" << &bseed[1] | |
2669 | << "S2.=" << &bseed[2] | |
2670 | << "S3.=" << &bseed[3] | |
2671 | << "S4.=" << &bseed[4] | |
2672 | << "S5.=" << &bseed[5] | |
2673 | << "FitterT.=" << tiltedRieman | |
2674 | << "\n"; | |
2675 | } | |
2676 | } // Loop: iter | |
2677 | ||
2678 | // we are sure that at least 2 tracklets are OK ! | |
2679 | return nLayers+2; | |
e4f2f73d | 2680 | } |
2681 | ||
eb38ed55 | 2682 | //_________________________________________________________________________ |
2683 | Double_t AliTRDtrackerV1::CalculateTrackLikelihood(AliTRDseedV1 *tracklets, Double_t *chi2){ | |
41702fec | 2684 | // |
2685 | // Calculates the Track Likelihood value. This parameter serves as main quality criterion for | |
2686 | // the track selection | |
2687 | // The likelihood value containes: | |
2688 | // - The chi2 values from the both fitters and the chi2 values in z-direction from a linear fit | |
2689 | // - The Sum of the Parameter |slope_ref - slope_fit|/Sigma of the tracklets | |
2690 | // For all Parameters an exponential dependency is used | |
2691 | // | |
2692 | // Parameters: - Array of tracklets (AliTRDseedV1) related to the track candidate | |
2693 | // - Array of chi2 values: | |
2694 | // * Non-Constrained Tilted Riemann fit | |
2695 | // * Vertex-Constrained Tilted Riemann fit | |
2696 | // * z-Direction from Linear fit | |
2697 | // Output: - The calculated track likelihood | |
2698 | // | |
2699 | // debug level 2 | |
2700 | // | |
2701 | ||
2702 | Double_t sumdaf = 0, nLayers = 0; | |
2703 | for (Int_t iLayer = 0; iLayer < kNPlanes; iLayer++) { | |
2704 | if(!tracklets[iLayer].IsOK()) continue; | |
2705 | sumdaf += TMath::Abs((tracklets[iLayer].GetYfit(1) - tracklets[iLayer].GetYref(1))/ tracklets[iLayer].GetSigmaY2()); | |
2706 | nLayers++; | |
2707 | } | |
2708 | sumdaf /= Float_t (nLayers - 2.0); | |
2709 | ||
2710 | Double_t likeChi2Z = TMath::Exp(-chi2[2] * 0.14); // Chi2Z | |
3a039a31 | 2711 | Double_t likeChi2TC = (fReconstructor->GetRecoParam() ->IsVertexConstrained()) ? |
d20df6fc | 2712 | TMath::Exp(-chi2[1] * 0.677) : 1; // Constrained Tilted Riemann |
41702fec | 2713 | Double_t likeChi2TR = TMath::Exp(-chi2[0] * 0.78); // Non-constrained Tilted Riemann |
2714 | Double_t likeAF = TMath::Exp(-sumdaf * 3.23); | |
2715 | Double_t trackLikelihood = likeChi2Z * likeChi2TR * likeAF; | |
2716 | ||
3a039a31 | 2717 | if(fReconstructor->GetStreamLevel(AliTRDReconstructor::kTracker) >= 2){ |
41702fec | 2718 | Int_t eventNumber = AliTRDtrackerDebug::GetEventNumber(); |
2719 | Int_t candidateNumber = AliTRDtrackerDebug::GetCandidateNumber(); | |
2720 | TTreeSRedirector &cstreamer = *fgDebugStreamer; | |
2721 | cstreamer << "CalculateTrackLikelihood0" | |
2722 | << "EventNumber=" << eventNumber | |
2723 | << "CandidateNumber=" << candidateNumber | |
2724 | << "LikeChi2Z=" << likeChi2Z | |
2725 | << "LikeChi2TR=" << likeChi2TR | |
2726 | << "LikeChi2TC=" << likeChi2TC | |
2727 | << "LikeAF=" << likeAF | |
2728 | << "TrackLikelihood=" << trackLikelihood | |
2729 | << "\n"; | |
2730 | } | |
2731 | ||
2732 | return trackLikelihood; | |
e4f2f73d | 2733 | } |
2734 | ||
2735 | //____________________________________________________________________ | |
eb38ed55 | 2736 | Double_t AliTRDtrackerV1::CookLikelihood(AliTRDseedV1 *cseed, Int_t planes[4] |
41702fec | 2737 | , Double_t *chi2) |
e4f2f73d | 2738 | { |
41702fec | 2739 | // |
2740 | // Calculate the probability of this track candidate. | |
2741 | // | |
2742 | // Parameters : | |
2743 | // cseeds : array of candidate tracklets | |
2744 | // planes : array of seeding planes (see seeding configuration) | |
2745 | // chi2 : chi2 values (on the Z and Y direction) from the rieman fit of the track. | |
2746 | // | |
2747 | // Output : | |
2748 | // likelihood value | |
2749 | // | |
2750 | // Detailed description | |
2751 | // | |
2752 | // The track quality is estimated based on the following 4 criteria: | |
2753 | // 1. precision of the rieman fit on the Y direction (likea) | |
2754 | // 2. chi2 on the Y direction (likechi2y) | |
2755 | // 3. chi2 on the Z direction (likechi2z) | |
2756 | // 4. number of attached clusters compared to a reference value | |
2757 | // (see AliTRDrecoParam::fkFindable) (likeN) | |
2758 | // | |
2759 | // The distributions for each type of probabilities are given below as of | |
2760 | // (date). They have to be checked to assure consistency of estimation. | |
2761 | // | |
2762 | ||
2763 | // ratio of the total number of clusters/track which are expected to be found by the tracker. | |
3a039a31 | 2764 | Float_t fgFindable = fReconstructor->GetRecoParam() ->GetFindableClusters(); |
41702fec | 2765 | |
2766 | ||
2767 | Int_t nclusters = 0; | |
2768 | Double_t sumda = 0.; | |
2769 | for(UChar_t ilayer = 0; ilayer < 4; ilayer++){ | |
2770 | Int_t jlayer = planes[ilayer]; | |
2771 | nclusters += cseed[jlayer].GetN2(); | |
2772 | sumda += TMath::Abs(cseed[jlayer].GetYfitR(1) - cseed[jlayer].GetYref(1)); | |
2773 | } | |
2774 | Double_t likea = TMath::Exp(-sumda*10.6); | |
2775 | Double_t likechi2y = 0.0000000001; | |
2776 | if (chi2[0] < 0.5) likechi2y += TMath::Exp(-TMath::Sqrt(chi2[0]) * 7.73); | |
2777 | Double_t likechi2z = TMath::Exp(-chi2[1] * 0.088) / TMath::Exp(-chi2[1] * 0.019); | |
2778 | Int_t enc = Int_t(fgFindable*4.*fgNTimeBins); // Expected Number Of Clusters, normally 72 | |
2779 | Double_t likeN = TMath::Exp(-(enc - nclusters) * 0.19); | |
2780 | ||
2781 | Double_t like = likea * likechi2y * likechi2z * likeN; | |
2782 | ||
2783 | // AliInfo(Form("sumda(%f) chi2[0](%f) chi2[1](%f) likea(%f) likechi2y(%f) likechi2z(%f) nclusters(%d) likeN(%f)", sumda, chi2[0], chi2[1], likea, likechi2y, likechi2z, nclusters, likeN)); | |
3a039a31 | 2784 | if(fReconstructor->GetStreamLevel(AliTRDReconstructor::kTracker) >= 2){ |
41702fec | 2785 | Int_t eventNumber = AliTRDtrackerDebug::GetEventNumber(); |
2786 | Int_t candidateNumber = AliTRDtrackerDebug::GetCandidateNumber(); | |
2787 | // The Debug Stream contains the seed | |
2788 | TTreeSRedirector &cstreamer = *fgDebugStreamer; | |
2789 | cstreamer << "CookLikelihood" | |
2790 | << "EventNumber=" << eventNumber | |
2791 | << "CandidateNumber=" << candidateNumber | |
2792 | << "tracklet0.=" << &cseed[0] | |
2793 | << "tracklet1.=" << &cseed[1] | |
2794 | << "tracklet2.=" << &cseed[2] | |
2795 | << "tracklet3.=" << &cseed[3] | |
2796 | << "tracklet4.=" << &cseed[4] | |
2797 | << "tracklet5.=" << &cseed[5] | |
2798 | << "sumda=" << sumda | |
2799 | << "chi0=" << chi2[0] | |
2800 | << "chi1=" << chi2[1] | |
2801 | << "likea=" << likea | |
2802 | << "likechi2y=" << likechi2y | |
2803 | << "likechi2z=" << likechi2z | |
2804 | << "nclusters=" << nclusters | |
2805 | << "likeN=" << likeN | |
2806 | << "like=" << like | |
2807 | << "\n"; | |
2808 | } | |
2809 | ||
2810 | return like; | |
e4f2f73d | 2811 | } |
2812 | ||
eb38ed55 | 2813 | |
e4f2f73d | 2814 | |
2815 | //____________________________________________________________________ | |
0906e73e | 2816 | void AliTRDtrackerV1::GetSeedingConfig(Int_t iconfig, Int_t planes[4]) |
e4f2f73d | 2817 | { |
41702fec | 2818 | // |
2819 | // Map seeding configurations to detector planes. | |
2820 | // | |
2821 | // Parameters : | |
2822 | // iconfig : configuration index | |
2823 | // planes : member planes of this configuration. On input empty. | |
2824 | // | |
2825 | // Output : | |
2826 | // planes : contains the planes which are defining the configuration | |
2827 | // | |
2828 | // Detailed description | |
2829 | // | |
2830 | // Here is the list of seeding planes configurations together with | |
2831 | // their topological classification: | |
2832 | // | |
2833 | // 0 - 5432 TQ 0 | |
2834 | // 1 - 4321 TQ 0 | |
2835 | // 2 - 3210 TQ 0 | |
2836 | // 3 - 5321 TQ 1 | |
2837 | // 4 - 4210 TQ 1 | |
2838 | // 5 - 5431 TQ 1 | |
2839 | // 6 - 4320 TQ 1 | |
2840 | // 7 - 5430 TQ 2 | |
2841 | // 8 - 5210 TQ 2 | |
2842 | // 9 - 5421 TQ 3 | |
2843 | // 10 - 4310 TQ 3 | |
2844 | // 11 - 5410 TQ 4 | |
2845 | // 12 - 5420 TQ 5 | |
2846 | // 13 - 5320 TQ 5 | |
2847 | // 14 - 5310 TQ 5 | |
2848 | // | |
2849 | // The topologic quality is modeled as follows: | |
2850 | // 1. The general model is define by the equation: | |
2851 | // p(conf) = exp(-conf/2) | |
2852 | // 2. According to the topologic classification, configurations from the same | |
2853 | // class are assigned the agerage value over the model values. | |
2854 | // 3. Quality values are normalized. | |
2855 | // | |
2856 | // The topologic quality distribution as function of configuration is given below: | |
2857 | //Begin_Html | |
2858 | // <img src="gif/topologicQA.gif"> | |
2859 | //End_Html | |
2860 | // | |
2861 | ||
2862 | switch(iconfig){ | |
2863 | case 0: // 5432 TQ 0 | |
2864 | planes[0] = 2; | |
2865 | planes[1] = 3; | |
2866 | planes[2] = 4; | |
2867 | planes[3] = 5; | |
2868 | break; | |
2869 | case 1: // 4321 TQ 0 | |
2870 | planes[0] = 1; | |
2871 | planes[1] = 2; | |
2872 | planes[2] = 3; | |
2873 | planes[3] = 4; | |
2874 | break; | |
2875 | case 2: // 3210 TQ 0 | |
2876 | planes[0] = 0; | |
2877 | planes[1] = 1; | |
2878 | planes[2] = 2; | |
2879 | planes[3] = 3; | |
2880 | break; | |
2881 | case 3: // 5321 TQ 1 | |
2882 | planes[0] = 1; | |
2883 | planes[1] = 2; | |
2884 | planes[2] = 3; | |
2885 | planes[3] = 5; | |
2886 | break; | |
2887 | case 4: // 4210 TQ 1 | |
2888 | planes[0] = 0; | |
2889 | planes[1] = 1; | |
2890 | planes[2] = 2; | |
2891 | planes[3] = 4; | |
2892 | break; | |
2893 | case 5: // 5431 TQ 1 | |
2894 | planes[0] = 1; | |
2895 | planes[1] = 3; | |
2896 | planes[2] = 4; | |
2897 | planes[3] = 5; | |
2898 | break; | |
2899 | case 6: // 4320 TQ 1 | |
2900 | planes[0] = 0; | |
2901 | planes[1] = 2; | |
2902 | planes[2] = 3; | |
2903 | planes[3] = 4; | |
2904 | break; | |
2905 | case 7: // 5430 TQ 2 | |
2906 | planes[0] = 0; | |
2907 | planes[1] = 3; | |
2908 | planes[2] = 4; | |
2909 | planes[3] = 5; | |
2910 | break; | |
2911 | case 8: // 5210 TQ 2 | |
2912 | planes[0] = 0; | |
2913 | planes[1] = 1; | |
2914 | planes[2] = 2; | |
2915 | planes[3] = 5; | |
2916 | break; | |
2917 | case 9: // 5421 TQ 3 | |
2918 | planes[0] = 1; | |
2919 | planes[1] = 2; | |
2920 | planes[2] = 4; | |
2921 | planes[3] = 5; | |
2922 | break; | |
2923 | case 10: // 4310 TQ 3 | |
2924 | planes[0] = 0; | |
2925 | planes[1] = 1; | |
2926 | planes[2] = 3; | |
2927 | planes[3] = 4; | |
2928 | break; | |
2929 | case 11: // 5410 TQ 4 | |
2930 | planes[0] = 0; | |
2931 | planes[1] = 1; | |
2932 | planes[2] = 4; | |
2933 | planes[3] = 5; | |
2934 | break; | |
2935 | case 12: // 5420 TQ 5 | |
2936 | planes[0] = 0; | |
2937 | planes[1] = 2; | |
2938 | planes[2] = 4; | |
2939 | planes[3] = 5; | |
2940 | break; | |
2941 | case 13: // 5320 TQ 5 | |
2942 | planes[0] = 0; | |
2943 | planes[1] = 2; | |
2944 | planes[2] = 3; | |
2945 | planes[3] = 5; | |
2946 | break; | |
2947 | case 14: // 5310 TQ 5 | |
2948 | planes[0] = 0; | |
2949 | planes[1] = 1; | |
2950 | planes[2] = 3; | |
2951 | planes[3] = 5; | |
2952 | break; | |
2953 | } | |
e4f2f73d | 2954 | } |
2955 | ||
2956 | //____________________________________________________________________ | |
0906e73e | 2957 | void AliTRDtrackerV1::GetExtrapolationConfig(Int_t iconfig, Int_t planes[2]) |
e4f2f73d | 2958 | { |
41702fec | 2959 | // |
2960 | // Returns the extrapolation planes for a seeding configuration. | |
2961 | // | |
2962 | // Parameters : | |
2963 | // iconfig : configuration index | |
2964 | // planes : planes which are not in this configuration. On input empty. | |
2965 | // | |
2966 | // Output : | |
2967 | // planes : contains the planes which are not in the configuration | |
2968 | // | |
2969 | // Detailed description | |
2970 | // | |
2971 | ||
2972 | switch(iconfig){ | |
2973 | case 0: // 5432 TQ 0 | |
2974 | planes[0] = 1; | |
2975 | planes[1] = 0; | |
2976 | break; | |
2977 | case 1: // 4321 TQ 0 | |
2978 | planes[0] = 5; | |
2979 | planes[1] = 0; | |
2980 | break; | |
2981 | case 2: // 3210 TQ 0 | |
2982 | planes[0] = 4; | |
2983 | planes[1] = 5; | |
2984 | break; | |
2985 | case 3: // 5321 TQ 1 | |
2986 | planes[0] = 4; | |
2987 | planes[1] = 0; | |
2988 | break; | |
2989 | case 4: // 4210 TQ 1 | |
2990 | planes[0] = 5; | |
2991 | planes[1] = 3; | |
2992 | break; | |
2993 | case 5: // 5431 TQ 1 | |
2994 | planes[0] = 2; | |
2995 | planes[1] = 0; | |
2996 | break; | |
2997 | case 6: // 4320 TQ 1 | |
2998 | planes[0] = 5; | |
2999 | planes[1] = 1; | |
3000 | break; | |
3001 | case 7: // 5430 TQ 2 | |
3002 | planes[0] = 2; | |
3003 | planes[1] = 1; | |
3004 | break; | |
3005 | case 8: // 5210 TQ 2 | |
3006 | planes[0] = 4; | |
3007 | planes[1] = 3; | |
3008 | break; | |
3009 | case 9: // 5421 TQ 3 | |
3010 | planes[0] = 3; | |
3011 | planes[1] = 0; | |
3012 | break; | |
3013 | case 10: // 4310 TQ 3 | |
3014 | planes[0] = 5; | |
3015 | planes[1] = 2; | |
3016 | break; | |
3017 | case 11: // 5410 TQ 4 | |
3018 | planes[0] = 3; | |
3019 | planes[1] = 2; | |
3020 | break; | |
3021 | case 12: // 5420 TQ 5 | |
3022 | planes[0] = 3; | |
3023 | planes[1] = 1; | |
3024 | break; | |
3025 | case 13: // 5320 TQ 5 | |
3026 | planes[0] = 4; | |
3027 | planes[1] = 1; | |
3028 | break; | |
3029 | case 14: // 5310 TQ 5 | |
3030 | planes[0] = 4; | |
3031 | planes[1] = 2; | |
3032 | break; | |
3033 | } | |
e4f2f73d | 3034 | } |
eb38ed55 | 3035 | |
3036 | //____________________________________________________________________ | |
3037 | AliCluster* AliTRDtrackerV1::GetCluster(Int_t idx) const | |
3038 | { | |
41702fec | 3039 | Int_t ncls = fClusters->GetEntriesFast(); |
2f7514a6 | 3040 | return idx >= 0 && idx < ncls ? (AliCluster*)fClusters->UncheckedAt(idx) : 0x0; |
eb38ed55 | 3041 | } |
3042 | ||
3b57a3f7 | 3043 | //____________________________________________________________________ |
3044 | AliTRDseedV1* AliTRDtrackerV1::GetTracklet(Int_t idx) const | |
3045 | { | |
41702fec | 3046 | Int_t ntrklt = fTracklets->GetEntriesFast(); |
2f7514a6 | 3047 | return idx >= 0 && idx < ntrklt ? (AliTRDseedV1*)fTracklets->UncheckedAt(idx) : 0x0; |
3b57a3f7 | 3048 | } |
3049 | ||
3050 | //____________________________________________________________________ | |
3051 | AliKalmanTrack* AliTRDtrackerV1::GetTrack(Int_t idx) const | |
3052 | { | |
41702fec | 3053 | Int_t ntrk = fTracks->GetEntriesFast(); |
2f7514a6 | 3054 | return idx >= 0 && idx < ntrk ? (AliKalmanTrack*)fTracks->UncheckedAt(idx) : 0x0; |
3b57a3f7 | 3055 | } |
3056 | ||
bb56afff | 3057 | //____________________________________________________________________ |
3058 | Float_t AliTRDtrackerV1::CalculateReferenceX(AliTRDseedV1 *tracklets){ | |
41702fec | 3059 | // |
3060 | // Calculates the reference x-position for the tilted Rieman fit defined as middle | |
3061 | // of the stack (middle between layers 2 and 3). For the calculation all the tracklets | |
3062 | // are taken into account | |
3063 | // | |
3064 | // Parameters: - Array of tracklets(AliTRDseedV1) | |
3065 | // | |
3066 | // Output: - The reference x-position(Float_t) | |
3067 | // | |
3068 | Int_t nDistances = 0; | |
3069 | Float_t meanDistance = 0.; | |
3070 | Int_t startIndex = 5; | |
3071 | for(Int_t il =5; il > 0; il--){ | |
3072 | if(tracklets[il].IsOK() && tracklets[il -1].IsOK()){ | |
3073 | Float_t xdiff = tracklets[il].GetX0() - tracklets[il -1].GetX0(); | |
3074 | meanDistance += xdiff; | |
3075 | nDistances++; | |
3076 | } | |
3077 | if(tracklets[il].IsOK()) startIndex = il; | |
3078 | } | |
3079 | if(tracklets[0].IsOK()) startIndex = 0; | |
3080 | if(!nDistances){ | |
3081 | // We should normally never get here | |
3082 | Float_t xpos[2]; memset(xpos, 0, sizeof(Float_t) * 2); | |
3083 | Int_t iok = 0, idiff = 0; | |
3084 | // This attempt is worse and should be avoided: | |
3085 | // check for two chambers which are OK and repeat this without taking the mean value | |
3086 | // Strategy avoids a division by 0; | |
3087 | for(Int_t il = 5; il >= 0; il--){ | |
3088 | if(tracklets[il].IsOK()){ | |
3089 | xpos[iok] = tracklets[il].GetX0(); | |
3090 | iok++; | |
3091 | startIndex = il; | |
3092 | } | |
3093 | if(iok) idiff++; // to get the right difference; | |
3094 | if(iok > 1) break; | |
3095 | } | |
3096 | if(iok > 1){ | |
3097 | meanDistance = (xpos[0] - xpos[1])/idiff; | |
3098 | } | |
3099 | else{ | |
3100 | // we have do not even have 2 layers which are OK? The we do not need to fit at all | |
3101 | return 331.; | |
3102 | } | |
3103 | } | |
3104 | else{ | |
3105 | meanDistance /= nDistances; | |
3106 | } | |
3107 | return tracklets[startIndex].GetX0() + (2.5 - startIndex) * meanDistance - 0.5 * (AliTRDgeometry::AmThick() + AliTRDgeometry::DrThick()); | |
bb56afff | 3108 | } |
eb38ed55 | 3109 | |
3110 | //_____________________________________________________________________________ | |
3111 | Int_t AliTRDtrackerV1::Freq(Int_t n, const Int_t *inlist | |
41702fec | 3112 | , Int_t *outlist, Bool_t down) |
eb38ed55 | 3113 | { |
41702fec | 3114 | // |
3115 | // Sort eleements according occurancy | |
3116 | // The size of output array has is 2*n | |
3117 | // | |
3118 | ||
3119 | if (n <= 0) { | |
3120 | return 0; | |
3121 | } | |
3122 | ||
3123 | Int_t *sindexS = new Int_t[n]; // Temporary array for sorting | |
3124 | Int_t *sindexF = new Int_t[2*n]; | |
3125 | for (Int_t i = 0; i < n; i++) { | |
3126 | sindexF[i] = 0; | |
3127 | } | |
3128 | ||
3129 | TMath::Sort(n,inlist,sindexS,down); | |
3130 | ||
3131 | Int_t last = inlist[sindexS[0]]; | |
3132 | Int_t val = last; | |
3133 | sindexF[0] = 1; | |
3134 | sindexF[0+n] = last; | |
3135 | Int_t countPos = 0; | |
3136 | ||
3137 | // Find frequency | |
3138 | for (Int_t i = 1; i < n; i++) { | |
3139 | val = inlist[sindexS[i]]; | |
3140 | if (last == val) { | |
3141 | sindexF[countPos]++; | |
3142 | } | |
3143 | else { | |
3144 | countPos++; | |
3145 | sindexF[countPos+n] = val; | |
3146 | sindexF[countPos]++; | |
3147 | last = val; | |
3148 | } | |
3149 | } | |
3150 | if (last == val) { | |
3151 | countPos++; | |
3152 | } | |
3153 | ||
3154 | // Sort according frequency | |
3155 | TMath::Sort(countPos,sindexF,sindexS,kTRUE); | |
3156 | ||
3157 | for (Int_t i = 0; i < countPos; i++) { | |
3158 | outlist[2*i ] = sindexF[sindexS[i]+n]; | |
3159 | outlist[2*i+1] = sindexF[sindexS[i]]; | |
3160 | } | |
3161 | ||
3162 | delete [] sindexS; | |
3163 | delete [] sindexF; | |
3164 | ||
3165 | return countPos; | |
eb38ed55 | 3166 | |
3167 | } | |
bb56afff | 3168 | |
06b32d95 | 3169 | |
3170 | //____________________________________________________________________ | |
3171 | void AliTRDtrackerV1::SetReconstructor(const AliTRDReconstructor *rec) | |
3172 | { | |
3173 | fReconstructor = rec; | |
3174 | if(fReconstructor->GetStreamLevel(AliTRDReconstructor::kTracker) > 1){ | |
3175 | if(!fgDebugStreamer){ | |
3176 | TDirectory *savedir = gDirectory; | |
3177 | fgDebugStreamer = new TTreeSRedirector("TRD.TrackerDebug.root"); | |
3178 | savedir->cd(); | |
3179 | } | |
3180 | } | |
acd241e9 | 3181 | } |
3182 | ||
bb56afff | 3183 | //_____________________________________________________________________________ |
3184 | Float_t AliTRDtrackerV1::GetChi2Y(AliTRDseedV1 *tracklets) const | |
3185 | { | |
41702fec | 3186 | // Chi2 definition on y-direction |
3187 | ||
3188 | Float_t chi2 = 0; | |
3189 | for(Int_t ipl = 0; ipl < kNPlanes; ipl++){ | |
3190 | if(!tracklets[ipl].IsOK()) continue; | |
3191 | Double_t distLayer = tracklets[ipl].GetYfit(0) - tracklets[ipl].GetYref(0); | |
3192 | chi2 += distLayer * distLayer; | |
3193 | } | |
3194 | return chi2; | |
bb56afff | 3195 | } |
3196 | ||
d611c74f | 3197 | //____________________________________________________________________ |
3198 | void AliTRDtrackerV1::ResetSeedTB() | |
3199 | { | |
3200 | // reset buffer for seeding time bin layers. If the time bin | |
3201 | // layers are not allocated this function allocates them | |
3202 | ||
3203 | for(Int_t isl=0; isl<kNSeedPlanes; isl++){ | |
3204 | if(!fSeedTB[isl]) fSeedTB[isl] = new AliTRDchamberTimeBin(); | |
3205 | else fSeedTB[isl]->Clear(); | |
3206 | } | |
3207 | } | |
3208 | ||
bb56afff | 3209 | //_____________________________________________________________________________ |
3210 | Float_t AliTRDtrackerV1::GetChi2Z(AliTRDseedV1 *tracklets) const | |
3211 | { | |
41702fec | 3212 | // Chi2 definition on z-direction |
3213 | ||
3214 | Float_t chi2 = 0; | |
3215 | for(Int_t ipl = 0; ipl < kNPlanes; ipl++){ | |
3216 | if(!tracklets[ipl].IsOK()) continue; | |
3217 | Double_t distLayer = tracklets[ipl].GetMeanz() - tracklets[ipl].GetZref(0); | |
3218 | chi2 += distLayer * distLayer; | |
3219 | } | |
3220 | return chi2; | |
bb56afff | 3221 | } |
8acca6a3 | 3222 | |
3223 | /////////////////////////////////////////////////////// | |
3224 | // // | |
3225 | // Resources of class AliTRDLeastSquare // | |
3226 | // // | |
3227 | /////////////////////////////////////////////////////// | |
3228 | ||
3229 | //_____________________________________________________________________________ | |
3230 | AliTRDtrackerV1::AliTRDLeastSquare::AliTRDLeastSquare(){ | |
41702fec | 3231 | // |
3232 | // Constructor of the nested class AliTRDtrackFitterLeastSquare | |
3233 | // | |
3234 | memset(fParams, 0, sizeof(Double_t) * 2); | |
3235 | memset(fSums, 0, sizeof(Double_t) * 5); | |
3236 | memset(fCovarianceMatrix, 0, sizeof(Double_t) * 3); | |
8acca6a3 | 3237 | |
3238 | } | |
3239 | ||
3240 | //_____________________________________________________________________________ | |
3241 | void AliTRDtrackerV1::AliTRDLeastSquare::AddPoint(Double_t *x, Double_t y, Double_t sigmaY){ | |
41702fec | 3242 | // |
3243 | // Adding Point to the fitter | |
3244 | // | |
3245 | Double_t weight = 1/(sigmaY * sigmaY); | |
3246 | Double_t &xpt = *x; | |
3247 | // printf("Adding point x = %f, y = %f, sigma = %f\n", xpt, y, sigmaY); | |
3248 | fSums[0] += weight; | |
3249 | fSums[1] += weight * xpt; | |
3250 | fSums[2] += weight * y; | |
3251 | fSums[3] += weight * xpt * y; | |
3252 | fSums[4] += weight * xpt * xpt; | |
3253 | fSums[5] += weight * y * y; | |
8acca6a3 | 3254 | } |
3255 | ||
3256 | //_____________________________________________________________________________ | |
3257 | void AliTRDtrackerV1::AliTRDLeastSquare::RemovePoint(Double_t *x, Double_t y, Double_t sigmaY){ | |
41702fec | 3258 | // |
3259 | // Remove Point from the sample | |
3260 | // | |
3261 | Double_t weight = 1/(sigmaY * sigmaY); | |
3262 | Double_t &xpt = *x; | |
3263 | fSums[0] -= weight; | |
3264 | fSums[1] -= weight * xpt; | |
3265 | fSums[2] -= weight * y; | |
3266 | fSums[3] -= weight * xpt * y; | |
3267 | fSums[4] -= weight * xpt * xpt; | |
3268 | fSums[5] -= weight * y * y; | |
8acca6a3 | 3269 | } |
3270 | ||
3271 | //_____________________________________________________________________________ | |
3272 | void AliTRDtrackerV1::AliTRDLeastSquare::Eval(){ | |
41702fec | 3273 | // |
3274 | // Evaluation of the fit: | |
3275 | // Calculation of the parameters | |
3276 | // Calculation of the covariance matrix | |
3277 | // | |
3278 | ||
3279 | Double_t denominator = fSums[0] * fSums[4] - fSums[1] *fSums[1]; | |
aec26713 | 3280 | if(denominator==0) return; |
3281 | ||
41702fec | 3282 | // for(Int_t isum = 0; isum < 5; isum++) |
3283 | // printf("fSums[%d] = %f\n", isum, fSums[isum]); | |
3284 | // printf("denominator = %f\n", denominator); | |
3285 | fParams[0] = (fSums[2] * fSums[4] - fSums[1] * fSums[3])/ denominator; | |
3286 | fParams[1] = (fSums[0] * fSums[3] - fSums[1] * fSums[2]) / denominator; | |
3287 | // printf("fParams[0] = %f, fParams[1] = %f\n", fParams[0], fParams[1]); | |
3288 | ||
3289 | // Covariance matrix | |
3290 | fCovarianceMatrix[0] = fSums[4] - fSums[1] * fSums[1] / fSums[0]; | |
3291 | fCovarianceMatrix[1] = fSums[5] - fSums[2] * fSums[2] / fSums[0]; | |
3292 | fCovarianceMatrix[2] = fSums[3] - fSums[1] * fSums[2] / fSums[0]; | |
8acca6a3 | 3293 | } |
3294 | ||
46b6abd7 | 3295 | //_____________________________________________________________________________ |
3296 | Double_t AliTRDtrackerV1::AliTRDLeastSquare::GetFunctionValue(Double_t *xpos) const { | |
41702fec | 3297 | // |
3298 | // Returns the Function value of the fitted function at a given x-position | |
3299 | // | |
3300 | return fParams[0] + fParams[1] * (*xpos); | |
46b6abd7 | 3301 | } |
3302 | ||
3303 | //_____________________________________________________________________________ | |
3304 | void AliTRDtrackerV1::AliTRDLeastSquare::GetCovarianceMatrix(Double_t *storage) const { | |
41702fec | 3305 | // |
3306 | // Copies the values of the covariance matrix into the storage | |
3307 | // | |
3308 | memcpy(storage, fCovarianceMatrix, sizeof(Double_t) * 3); | |
46b6abd7 | 3309 | } |
3310 |