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