]>
Commit | Line | Data |
---|---|---|
e4f2f73d | 1 | /************************************************************************** |
972ef65e | 2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
e4f2f73d | 15 | |
16 | /* $Id$ */ | |
17 | ||
18 | /////////////////////////////////////////////////////////////////////////////// | |
19 | // // | |
20 | // Track finder // | |
21 | // // | |
22 | // Authors: // | |
23 | // Alex Bercuci <A.Bercuci@gsi.de> // | |
24 | // Markus Fasel <M.Fasel@gsi.de> // | |
25 | // // | |
26 | /////////////////////////////////////////////////////////////////////////////// | |
27 | ||
e4f2f73d | 28 | #include <TBranch.h> |
bb56afff | 29 | #include <TDirectory.h> |
e4f2f73d | 30 | #include <TLinearFitter.h> |
e4f2f73d | 31 | #include <TTree.h> |
32 | #include <TClonesArray.h> | |
e4f2f73d | 33 | #include <TTreeStream.h> |
eb2b4f91 | 34 | #include <TGeoMatrix.h> |
35 | #include <TGeoManager.h> | |
e4f2f73d | 36 | |
37 | #include "AliLog.h" | |
fac58f00 | 38 | #include "AliMathBase.h" |
e4f2f73d | 39 | #include "AliESDEvent.h" |
bb56afff | 40 | #include "AliGeomManager.h" |
e4f2f73d | 41 | #include "AliRieman.h" |
42 | #include "AliTrackPointArray.h" | |
43 | ||
e4f2f73d | 44 | #include "AliTRDgeometry.h" |
45 | #include "AliTRDpadPlane.h" | |
e4f2f73d | 46 | #include "AliTRDcalibDB.h" |
e4f2f73d | 47 | #include "AliTRDReconstructor.h" |
48 | #include "AliTRDCalibraFillHisto.h" | |
e4f2f73d | 49 | #include "AliTRDrecoParam.h" |
bb56afff | 50 | |
51 | #include "AliTRDcluster.h" | |
828c6f80 | 52 | #include "AliTRDdigitsParam.h" |
e4f2f73d | 53 | #include "AliTRDseedV1.h" |
0906e73e | 54 | #include "AliTRDtrackV1.h" |
bb56afff | 55 | #include "AliTRDtrackerV1.h" |
56 | #include "AliTRDtrackerDebug.h" | |
57 | #include "AliTRDtrackingChamber.h" | |
58 | #include "AliTRDchamberTimeBin.h" | |
59 | ||
e4f2f73d | 60 | ClassImp(AliTRDtrackerV1) |
eb38ed55 | 61 | |
eb38ed55 | 62 | const Float_t AliTRDtrackerV1::fgkMinClustersInTrack = 0.5; // |
63 | const Float_t AliTRDtrackerV1::fgkLabelFraction = 0.8; // | |
64 | const Double_t AliTRDtrackerV1::fgkMaxChi2 = 12.0; // | |
65 | const Double_t AliTRDtrackerV1::fgkMaxSnp = 0.95; // Maximum local sine of the azimuthal angle | |
66 | const Double_t AliTRDtrackerV1::fgkMaxStep = 2.0; // Maximal step size in propagation | |
d76231c8 | 67 | Double_t AliTRDtrackerV1::fgTopologicQA[kNConfigs] = { |
6e39bde4 | 68 | 0.5112, 0.5112, 0.5112, 0.0786, 0.0786, |
41702fec | 69 | 0.0786, 0.0786, 0.0579, 0.0579, 0.0474, |
70 | 0.0474, 0.0408, 0.0335, 0.0335, 0.0335 | |
e165b64b | 71 | }; |
72 | const Double_t AliTRDtrackerV1::fgkX0[kNPlanes] = { | |
73 | 300.2, 312.8, 325.4, 338.0, 350.6, 363.2}; | |
2985ffcb | 74 | Int_t AliTRDtrackerV1::fgNTimeBins = 0; |
4d6aee34 | 75 | AliRieman* AliTRDtrackerV1::fgRieman = NULL; |
76 | TLinearFitter* AliTRDtrackerV1::fgTiltedRieman = NULL; | |
77 | TLinearFitter* AliTRDtrackerV1::fgTiltedRiemanConstrained = NULL; | |
e4f2f73d | 78 | |
79 | //____________________________________________________________________ | |
3a039a31 | 80 | AliTRDtrackerV1::AliTRDtrackerV1(AliTRDReconstructor *rec) |
41702fec | 81 | :AliTracker() |
4d6aee34 | 82 | ,fkReconstructor(NULL) |
83 | ,fGeom(NULL) | |
84 | ,fClusters(NULL) | |
85 | ,fTracklets(NULL) | |
86 | ,fTracks(NULL) | |
41702fec | 87 | ,fSieveSeeding(0) |
e4f2f73d | 88 | { |
41702fec | 89 | // |
90 | // Default constructor. | |
91 | // | |
eb2b4f91 | 92 | |
93 | SetReconstructor(rec); // initialize reconstructor | |
94 | ||
95 | // initialize geometry | |
96 | if(!AliGeomManager::GetGeometry()){ | |
97 | AliFatal("Could not get geometry."); | |
98 | } | |
99 | fGeom = new AliTRDgeometry(); | |
100 | fGeom->CreateClusterMatrixArray(); | |
4d6aee34 | 101 | TGeoHMatrix *matrix = NULL; |
eb2b4f91 | 102 | Double_t loc[] = {0., 0., 0.}; |
103 | Double_t glb[] = {0., 0., 0.}; | |
104 | for(Int_t ily=kNPlanes; ily--;){ | |
e165b64b | 105 | Int_t ism = 0; |
106 | while(!(matrix = fGeom->GetClusterMatrix(AliTRDgeometry::GetDetector(ily, 2, ism)))) ism++; | |
107 | if(!matrix){ | |
108 | AliError(Form("Could not get transformation matrix for layer %d. Use default.", ily)); | |
109 | fR[ily] = fgkX0[ily]; | |
eb2b4f91 | 110 | continue; |
111 | } | |
112 | matrix->LocalToMaster(loc, glb); | |
113 | fR[ily] = glb[0]+ AliTRDgeometry::AnodePos()-.5*AliTRDgeometry::AmThick() - AliTRDgeometry::DrThick(); | |
114 | } | |
115 | ||
eb2b4f91 | 116 | // initialize cluster containers |
053767a4 | 117 | for (Int_t isector = 0; isector < AliTRDgeometry::kNsector; isector++) new(&fTrSec[isector]) AliTRDtrackingSector(fGeom, isector); |
3a039a31 | 118 | |
eb2b4f91 | 119 | // initialize arrays |
120 | memset(fTrackQuality, 0, kMaxTracksStack*sizeof(Double_t)); | |
121 | memset(fSeedLayer, 0, kMaxTracksStack*sizeof(Int_t)); | |
122 | memset(fSeedTB, 0, kNSeedPlanes*sizeof(AliTRDchamberTimeBin*)); | |
eb38ed55 | 123 | } |
124 | ||
e4f2f73d | 125 | //____________________________________________________________________ |
126 | AliTRDtrackerV1::~AliTRDtrackerV1() | |
127 | { | |
41702fec | 128 | // |
129 | // Destructor | |
130 | // | |
131 | ||
4d6aee34 | 132 | if(fgRieman) delete fgRieman; fgRieman = NULL; |
133 | if(fgTiltedRieman) delete fgTiltedRieman; fgTiltedRieman = NULL; | |
134 | if(fgTiltedRiemanConstrained) delete fgTiltedRiemanConstrained; fgTiltedRiemanConstrained = NULL; | |
d611c74f | 135 | for(Int_t isl =0; isl<kNSeedPlanes; isl++) if(fSeedTB[isl]) delete fSeedTB[isl]; |
41702fec | 136 | if(fTracks) {fTracks->Delete(); delete fTracks;} |
137 | if(fTracklets) {fTracklets->Delete(); delete fTracklets;} | |
48f8adf3 | 138 | if(fClusters) { |
139 | fClusters->Delete(); delete fClusters; | |
140 | } | |
41702fec | 141 | if(fGeom) delete fGeom; |
e4f2f73d | 142 | } |
143 | ||
144 | //____________________________________________________________________ | |
145 | Int_t AliTRDtrackerV1::Clusters2Tracks(AliESDEvent *esd) | |
146 | { | |
41702fec | 147 | // |
148 | // Steering stand alone tracking for full TRD detector | |
149 | // | |
150 | // Parameters : | |
151 | // esd : The ESD event. On output it contains | |
152 | // the ESD tracks found in TRD. | |
153 | // | |
154 | // Output : | |
155 | // Number of tracks found in the TRD detector. | |
156 | // | |
157 | // Detailed description | |
158 | // 1. Launch individual SM trackers. | |
159 | // See AliTRDtrackerV1::Clusters2TracksSM() for details. | |
160 | // | |
161 | ||
4d6aee34 | 162 | if(!fkReconstructor->GetRecoParam() ){ |
3a039a31 | 163 | AliError("Reconstruction configuration not initialized. Call first AliTRDReconstructor::SetRecoParam()."); |
41702fec | 164 | return 0; |
165 | } | |
166 | ||
167 | //AliInfo("Start Track Finder ..."); | |
168 | Int_t ntracks = 0; | |
053767a4 | 169 | for(int ism=0; ism<AliTRDgeometry::kNsector; ism++){ |
41702fec | 170 | // for(int ism=1; ism<2; ism++){ |
171 | //AliInfo(Form("Processing supermodule %i ...", ism)); | |
172 | ntracks += Clusters2TracksSM(ism, esd); | |
173 | } | |
980d5a2a | 174 | AliInfo(Form("Number of tracks: !TRDin[%d]", ntracks)); |
41702fec | 175 | return ntracks; |
e4f2f73d | 176 | } |
177 | ||
0906e73e | 178 | |
179 | //_____________________________________________________________________________ | |
eb38ed55 | 180 | Bool_t AliTRDtrackerV1::GetTrackPoint(Int_t index, AliTrackPoint &p) const |
0906e73e | 181 | { |
41702fec | 182 | //AliInfo(Form("Asking for tracklet %d", index)); |
183 | ||
84eab75a | 184 | // reset position of the point before using it |
185 | p.SetXYZ(0., 0., 0.); | |
2f7514a6 | 186 | AliTRDseedV1 *tracklet = GetTracklet(index); |
187 | if (!tracklet) return kFALSE; | |
84eab75a | 188 | |
41702fec | 189 | // get detector for this tracklet |
e165b64b | 190 | Int_t det = tracklet->GetDetector(); |
191 | Int_t sec = fGeom->GetSector(det); | |
192 | Double_t alpha = (sec+.5)*AliTRDgeometry::GetAlpha(), | |
193 | sinA = TMath::Sin(alpha), | |
194 | cosA = TMath::Cos(alpha); | |
41702fec | 195 | Double_t local[3]; |
e165b64b | 196 | local[0] = tracklet->GetX(); |
197 | local[1] = tracklet->GetY(); | |
198 | local[2] = tracklet->GetZ(); | |
41702fec | 199 | Double_t global[3]; |
e165b64b | 200 | fGeom->RotateBack(det, local, global); |
201 | ||
202 | Double_t cov2D[3]; Float_t cov[6]; | |
203 | tracklet->GetCovAt(local[0], cov2D); | |
204 | cov[0] = cov2D[0]*sinA*sinA; | |
205 | cov[1] =-cov2D[0]*sinA*cosA; | |
206 | cov[2] =-cov2D[1]*sinA; | |
207 | cov[3] = cov2D[0]*cosA*cosA; | |
208 | cov[4] = cov2D[1]*cosA; | |
209 | cov[5] = cov2D[2]; | |
210 | // store the global position of the tracklet and its covariance matrix in the track point | |
211 | p.SetXYZ(global[0],global[1],global[2], cov); | |
41702fec | 212 | |
213 | // setting volume id | |
e165b64b | 214 | AliGeomManager::ELayerID iLayer = AliGeomManager::ELayerID(AliGeomManager::kTRD1+fGeom->GetLayer(det)); |
215 | Int_t modId = fGeom->GetSector(det) * AliTRDgeometry::kNstack + fGeom->GetStack(det); | |
41702fec | 216 | UShort_t volid = AliGeomManager::LayerToVolUID(iLayer, modId); |
217 | p.SetVolumeID(volid); | |
218 | ||
219 | return kTRUE; | |
0906e73e | 220 | } |
221 | ||
eb38ed55 | 222 | //____________________________________________________________________ |
223 | TLinearFitter* AliTRDtrackerV1::GetTiltedRiemanFitter() | |
224 | { | |
41702fec | 225 | if(!fgTiltedRieman) fgTiltedRieman = new TLinearFitter(4, "hyp4"); |
226 | return fgTiltedRieman; | |
eb38ed55 | 227 | } |
0906e73e | 228 | |
eb38ed55 | 229 | //____________________________________________________________________ |
230 | TLinearFitter* AliTRDtrackerV1::GetTiltedRiemanFitterConstraint() | |
231 | { | |
41702fec | 232 | if(!fgTiltedRiemanConstrained) fgTiltedRiemanConstrained = new TLinearFitter(2, "hyp2"); |
233 | return fgTiltedRiemanConstrained; | |
eb38ed55 | 234 | } |
41702fec | 235 | |
eb38ed55 | 236 | //____________________________________________________________________ |
237 | AliRieman* AliTRDtrackerV1::GetRiemanFitter() | |
238 | { | |
fac58f00 | 239 | if(!fgRieman) fgRieman = new AliRieman(AliTRDseedV1::kNtb * AliTRDgeometry::kNlayer); |
41702fec | 240 | return fgRieman; |
eb38ed55 | 241 | } |
41702fec | 242 | |
0906e73e | 243 | //_____________________________________________________________________________ |
244 | Int_t AliTRDtrackerV1::PropagateBack(AliESDEvent *event) | |
245 | { | |
2a3191bb | 246 | // Propagation of ESD tracks from TPC to TOF detectors and building of the TRD track. For building |
247 | // a TRD track an ESD track is used as seed. The informations obtained on the TRD track (measured points, | |
248 | // covariance, PID, etc.) are than used to update the corresponding ESD track. | |
249 | // Each track seed is first propagated to the geometrical limit of the TRD detector. | |
250 | // Its prolongation is searched in the TRD and if corresponding clusters are found tracklets are | |
251 | // constructed out of them (see AliTRDseedV1::AttachClusters()) and the track is updated. | |
252 | // Otherwise the ESD track is left unchanged. | |
253 | // | |
254 | // The following steps are performed: | |
255 | // 1. Selection of tracks based on the variance in the y-z plane. | |
256 | // 2. Propagation to the geometrical limit of the TRD volume. If track propagation fails the AliESDtrack::kTRDStop is set. | |
257 | // 3. Prolongation inside the fiducial volume (see AliTRDtrackerV1::FollowBackProlongation()) and marking | |
258 | // the following status bits: | |
259 | // - AliESDtrack::kTRDin - if the tracks enters the TRD fiducial volume | |
260 | // - AliESDtrack::kTRDStop - if the tracks fails propagation | |
261 | // - AliESDtrack::kTRDbackup - if the tracks fulfills chi2 conditions and qualify for refitting | |
262 | // 4. Writting to friends, PID, MC label, quality etc. Setting status bit AliESDtrack::kTRDout. | |
263 | // 5. Propagation to TOF. If track propagation fails the AliESDtrack::kTRDStop is set. | |
264 | // | |
265 | ||
266 | AliTRDCalibraFillHisto *calibra = AliTRDCalibraFillHisto::Instance(); // Calibration monitor | |
41702fec | 267 | if (!calibra) AliInfo("Could not get Calibra instance\n"); |
828c6f80 | 268 | if(!fgNTimeBins) CookNTimeBins(); |
269 | ||
eb2b4f91 | 270 | // Define scalers |
271 | Int_t nFound = 0, // number of tracks found | |
272 | nSeeds = 0, // total number of ESD seeds | |
273 | nTRDseeds= 0, // number of seeds in the TRD acceptance | |
274 | nTPCseeds= 0; // number of TPC seeds | |
41702fec | 275 | Float_t foundMin = 20.0; |
276 | ||
4d6aee34 | 277 | Float_t *quality = NULL; |
278 | Int_t *index = NULL; | |
eb2b4f91 | 279 | nSeeds = event->GetNumberOfTracks(); |
280 | // Sort tracks according to quality | |
281 | // (covariance in the yz plane) | |
282 | if(nSeeds){ | |
283 | quality = new Float_t[nSeeds]; | |
284 | index = new Int_t[nSeeds]; | |
285 | for (Int_t iSeed = nSeeds; iSeed--;) { | |
d611c74f | 286 | AliESDtrack *seed = event->GetTrack(iSeed); |
287 | Double_t covariance[15]; | |
288 | seed->GetExternalCovariance(covariance); | |
289 | quality[iSeed] = covariance[0] + covariance[2]; | |
290 | } | |
eb2b4f91 | 291 | TMath::Sort(nSeeds, quality, index,kFALSE); |
41702fec | 292 | } |
41702fec | 293 | |
eb2b4f91 | 294 | // Propagate all seeds |
41702fec | 295 | Int_t expectedClr; |
296 | AliTRDtrackV1 track; | |
eb2b4f91 | 297 | for (Int_t iSeed = 0; iSeed < nSeeds; iSeed++) { |
41702fec | 298 | |
299 | // Get the seeds in sorted sequence | |
300 | AliESDtrack *seed = event->GetTrack(index[iSeed]); | |
eb2b4f91 | 301 | Float_t p4 = seed->GetC(seed->GetBz()); |
41702fec | 302 | |
303 | // Check the seed status | |
304 | ULong_t status = seed->GetStatus(); | |
305 | if ((status & AliESDtrack::kTPCout) == 0) continue; | |
306 | if ((status & AliESDtrack::kTRDout) != 0) continue; | |
eb2b4f91 | 307 | |
308 | // Propagate to the entrance in the TRD mother volume | |
41702fec | 309 | new(&track) AliTRDtrackV1(*seed); |
eb2b4f91 | 310 | if(AliTRDgeometry::GetXtrdBeg() > (fgkMaxStep + track.GetX()) && !PropagateToX(track, AliTRDgeometry::GetXtrdBeg(), fgkMaxStep)){ |
311 | seed->UpdateTrackParams(&track, AliESDtrack::kTRDStop); | |
312 | continue; | |
313 | } | |
314 | if(!AdjustSector(&track)){ | |
315 | seed->UpdateTrackParams(&track, AliESDtrack::kTRDStop); | |
316 | continue; | |
317 | } | |
318 | if(TMath::Abs(track.GetSnp()) > fgkMaxSnp) { | |
319 | seed->UpdateTrackParams(&track, AliESDtrack::kTRDStop); | |
320 | continue; | |
321 | } | |
322 | ||
323 | nTPCseeds++; | |
e4d4864b | 324 | |
eb2b4f91 | 325 | // store track status at TRD entrance |
76b60503 | 326 | seed->UpdateTrackParams(&track, AliESDtrack::kTRDbackup); |
ae3fbe1f | 327 | |
eb2b4f91 | 328 | // prepare track and do propagation in the TRD |
4d6aee34 | 329 | track.SetReconstructor(fkReconstructor); |
eb2b4f91 | 330 | track.SetKink(Bool_t(seed->GetKinkIndex(0))); |
331 | expectedClr = FollowBackProlongation(track); | |
332 | // check if track entered the TRD fiducial volume | |
333 | if(track.GetTrackLow()){ | |
334 | seed->UpdateTrackParams(&track, AliESDtrack::kTRDin); | |
335 | nTRDseeds++; | |
336 | } | |
337 | // check if track was stopped in the TRD | |
338 | if (expectedClr<0){ | |
339 | seed->UpdateTrackParams(&track, AliESDtrack::kTRDStop); | |
340 | continue; | |
341 | } | |
ae3fbe1f | 342 | |
343 | if(expectedClr){ | |
eb2b4f91 | 344 | nFound++; |
41702fec | 345 | // computes PID for track |
346 | track.CookPID(); | |
347 | // update calibration references using this track | |
348 | if(calibra->GetHisto2d()) calibra->UpdateHistogramsV1(&track); | |
349 | // save calibration object | |
a2fbb6ec | 350 | if (fkReconstructor->GetRecoParam()->GetStreamLevel(AliTRDrecoParam::kTracker) > 0){ |
224f357f | 351 | AliTRDtrackV1 *calibTrack = new AliTRDtrackV1(track); |
352 | calibTrack->SetOwner(); | |
353 | seed->AddCalibObject(calibTrack); | |
354 | } | |
355 | //update ESD track | |
41702fec | 356 | if ((track.GetNumberOfClusters() > 15) && (track.GetNumberOfClusters() > 0.5*expectedClr)) { |
2389e96f | 357 | seed->UpdateTrackParams(&track, AliESDtrack::kTRDout); |
41702fec | 358 | track.UpdateESDtrack(seed); |
41702fec | 359 | } |
360 | } | |
361 | ||
27fbeba8 | 362 | if ((TMath::Abs(track.GetC(track.GetBz()) - p4) / TMath::Abs(p4) < 0.2) ||(track.Pt() > 0.8)) { |
e3cf3d02 | 363 | |
41702fec | 364 | // Make backup for back propagation |
41702fec | 365 | Int_t foundClr = track.GetNumberOfClusters(); |
366 | if (foundClr >= foundMin) { | |
41702fec | 367 | track.CookLabel(1. - fgkLabelFraction); |
f29f13a6 | 368 | //if(track.GetBackupTrack()) UseClusters(track.GetBackupTrack()); |
41702fec | 369 | |
370 | // Sign only gold tracks | |
371 | if (track.GetChi2() / track.GetNumberOfClusters() < 4) { | |
f29f13a6 | 372 | //if ((seed->GetKinkIndex(0) == 0) && (track.Pt() < 1.5)) UseClusters(&track); |
41702fec | 373 | } |
374 | Bool_t isGold = kFALSE; | |
375 | ||
376 | // Full gold track | |
377 | if (track.GetChi2() / track.GetNumberOfClusters() < 5) { | |
378 | if (track.GetBackupTrack()) seed->UpdateTrackParams(track.GetBackupTrack(),AliESDtrack::kTRDbackup); | |
379 | ||
380 | isGold = kTRUE; | |
381 | } | |
382 | ||
383 | // Almost gold track | |
384 | if ((!isGold) && (track.GetNCross() == 0) && (track.GetChi2() / track.GetNumberOfClusters() < 7)) { | |
385 | //seed->UpdateTrackParams(track, AliESDtrack::kTRDbackup); | |
386 | if (track.GetBackupTrack()) seed->UpdateTrackParams(track.GetBackupTrack(),AliESDtrack::kTRDbackup); | |
387 | ||
388 | isGold = kTRUE; | |
389 | } | |
390 | ||
391 | if ((!isGold) && (track.GetBackupTrack())) { | |
392 | if ((track.GetBackupTrack()->GetNumberOfClusters() > foundMin) && ((track.GetBackupTrack()->GetChi2()/(track.GetBackupTrack()->GetNumberOfClusters()+1)) < 7)) { | |
393 | seed->UpdateTrackParams(track.GetBackupTrack(),AliESDtrack::kTRDbackup); | |
394 | isGold = kTRUE; | |
395 | } | |
396 | } | |
41702fec | 397 | } |
398 | } | |
399 | ||
eb2b4f91 | 400 | // Propagation to the TOF |
401 | if(!(seed->GetStatus()&AliESDtrack::kTRDStop)) { | |
402 | Int_t sm = track.GetSector(); | |
403 | // default value in case we have problems with the geometry. | |
404 | Double_t xtof = 371.; | |
405 | //Calculate radial position of the beginning of the TOF | |
406 | //mother volume. In order to avoid mixing of the TRD | |
407 | //and TOF modules some hard values are needed. This are: | |
408 | //1. The path to the TOF module. | |
409 | //2. The width of the TOF (29.05 cm) | |
410 | //(with the help of Annalisa de Caro Mar-17-2009) | |
411 | if(gGeoManager){ | |
412 | gGeoManager->cd(Form("/ALIC_1/B077_1/BSEGMO%d_1/BTOF%d_1", sm, sm)); | |
4d6aee34 | 413 | TGeoHMatrix *m = NULL; |
eb2b4f91 | 414 | Double_t loc[]={0., 0., -.5*29.05}, glob[3]; |
415 | ||
416 | if((m=gGeoManager->GetCurrentMatrix())){ | |
417 | m->LocalToMaster(loc, glob); | |
418 | xtof = TMath::Sqrt(glob[0]*glob[0]+glob[1]*glob[1]); | |
419 | } | |
41702fec | 420 | } |
672b48bd | 421 | if(xtof > (fgkMaxStep + track.GetX()) && !PropagateToX(track, xtof, fgkMaxStep)){ |
422 | seed->UpdateTrackParams(&track, AliESDtrack::kTRDStop); | |
423 | continue; | |
424 | } | |
425 | if(!AdjustSector(&track)){ | |
426 | seed->UpdateTrackParams(&track, AliESDtrack::kTRDStop); | |
427 | continue; | |
428 | } | |
429 | if(TMath::Abs(track.GetSnp()) > fgkMaxSnp){ | |
430 | seed->UpdateTrackParams(&track, AliESDtrack::kTRDStop); | |
431 | continue; | |
432 | } | |
eb2b4f91 | 433 | seed->UpdateTrackParams(&track, AliESDtrack::kTRDout); |
434 | // TODO obsolete - delete | |
435 | seed->SetTRDQuality(track.StatusForTOF()); | |
41702fec | 436 | } |
41702fec | 437 | seed->SetTRDBudget(track.GetBudget(0)); |
438 | } | |
d611c74f | 439 | if(index) delete [] index; |
440 | if(quality) delete [] quality; | |
41702fec | 441 | |
d4cf71ca | 442 | AliInfo(Form("Number of seeds: TPCout[%d] TRDin[%d]", nTPCseeds, nTRDseeds)); |
443 | AliInfo(Form("Number of tracks: TRDout[%d]", nFound)); | |
444 | ||
d611c74f | 445 | // run stand alone tracking |
4d6aee34 | 446 | if (fkReconstructor->IsSeeding()) Clusters2Tracks(event); |
41702fec | 447 | |
448 | return 0; | |
0906e73e | 449 | } |
450 | ||
451 | ||
452 | //____________________________________________________________________ | |
453 | Int_t AliTRDtrackerV1::RefitInward(AliESDEvent *event) | |
454 | { | |
41702fec | 455 | // |
456 | // Refits tracks within the TRD. The ESD event is expected to contain seeds | |
457 | // at the outer part of the TRD. | |
458 | // The tracks are propagated to the innermost time bin | |
459 | // of the TRD and the ESD event is updated | |
460 | // Origin: Thomas KUHR (Thomas.Kuhr@cern.ch) | |
461 | // | |
462 | ||
463 | Int_t nseed = 0; // contor for loaded seeds | |
464 | Int_t found = 0; // contor for updated TRD tracks | |
465 | ||
466 | ||
467 | AliTRDtrackV1 track; | |
468 | for (Int_t itrack = 0; itrack < event->GetNumberOfTracks(); itrack++) { | |
469 | AliESDtrack *seed = event->GetTrack(itrack); | |
470 | new(&track) AliTRDtrackV1(*seed); | |
471 | ||
472 | if (track.GetX() < 270.0) { | |
473 | seed->UpdateTrackParams(&track, AliESDtrack::kTRDbackup); | |
474 | continue; | |
475 | } | |
476 | ||
e3cf3d02 | 477 | // reject tracks which failed propagation in the TRD or |
478 | // are produced by the TRD stand alone tracker | |
41702fec | 479 | ULong_t status = seed->GetStatus(); |
e3cf3d02 | 480 | if(!(status & AliESDtrack::kTRDout)) continue; |
481 | if(!(status & AliESDtrack::kTRDin)) continue; | |
41702fec | 482 | nseed++; |
483 | ||
484 | track.ResetCovariance(50.0); | |
485 | ||
486 | // do the propagation and processing | |
487 | Bool_t kUPDATE = kFALSE; | |
488 | Double_t xTPC = 250.0; | |
489 | if(FollowProlongation(track)){ | |
490 | // Prolongate to TPC | |
491 | if (PropagateToX(track, xTPC, fgkMaxStep)) { // -with update | |
e3cf3d02 | 492 | seed->UpdateTrackParams(&track, AliESDtrack::kTRDrefit); |
493 | found++; | |
494 | kUPDATE = kTRUE; | |
495 | } | |
496 | ||
497 | // Update the friend track | |
a2fbb6ec | 498 | if (fkReconstructor->GetRecoParam()->GetStreamLevel(AliTRDrecoParam::kTracker) > 0){ |
4d6aee34 | 499 | TObject *o = NULL; Int_t ic = 0; |
500 | AliTRDtrackV1 *calibTrack = NULL; | |
e3cf3d02 | 501 | while((o = seed->GetCalibObject(ic++))){ |
502 | if(!(calibTrack = dynamic_cast<AliTRDtrackV1*>(o))) continue; | |
503 | calibTrack->SetTrackHigh(track.GetTrackHigh()); | |
504 | } | |
41702fec | 505 | } |
e3cf3d02 | 506 | } |
41702fec | 507 | |
508 | // Prolongate to TPC without update | |
509 | if(!kUPDATE) { | |
510 | AliTRDtrackV1 tt(*seed); | |
e3cf3d02 | 511 | if (PropagateToX(tt, xTPC, fgkMaxStep)) seed->UpdateTrackParams(&tt, AliESDtrack::kTRDbackup); |
41702fec | 512 | } |
513 | } | |
980d5a2a | 514 | AliInfo(Form("Number of seeds: TRDout[%d]", nseed)); |
515 | AliInfo(Form("Number of tracks: TRDrefit[%d]", found)); | |
41702fec | 516 | |
517 | return 0; | |
0906e73e | 518 | } |
519 | ||
0906e73e | 520 | //____________________________________________________________________ |
521 | Int_t AliTRDtrackerV1::FollowProlongation(AliTRDtrackV1 &t) | |
522 | { | |
41702fec | 523 | // Extrapolates the TRD track in the TPC direction. |
524 | // | |
525 | // Parameters | |
526 | // t : the TRD track which has to be extrapolated | |
527 | // | |
528 | // Output | |
529 | // number of clusters attached to the track | |
530 | // | |
531 | // Detailed description | |
532 | // | |
533 | // Starting from current radial position of track <t> this function | |
534 | // extrapolates the track through the 6 TRD layers. The following steps | |
535 | // are being performed for each plane: | |
536 | // 1. prepare track: | |
537 | // a. get plane limits in the local x direction | |
538 | // b. check crossing sectors | |
539 | // c. check track inclination | |
540 | // 2. search tracklet in the tracker list (see GetTracklet() for details) | |
541 | // 3. evaluate material budget using the geo manager | |
542 | // 4. propagate and update track using the tracklet information. | |
543 | // | |
544 | // Debug level 2 | |
545 | // | |
546 | ||
e3cf3d02 | 547 | Bool_t kStoreIn = kTRUE; |
41702fec | 548 | Int_t nClustersExpected = 0; |
e3cf3d02 | 549 | for (Int_t iplane = kNPlanes; iplane--;) { |
41702fec | 550 | Int_t index = 0; |
551 | AliTRDseedV1 *tracklet = GetTracklet(&t, iplane, index); | |
552 | if(!tracklet) continue; | |
980d5a2a | 553 | if(!tracklet->IsOK()){ |
554 | AliDebug(1, Form("Tracklet Det[%d] !OK", tracklet->GetDetector())); | |
555 | continue; | |
556 | } | |
e3cf3d02 | 557 | Double_t x = tracklet->GetX();//GetX0(); |
41702fec | 558 | // reject tracklets which are not considered for inward refit |
559 | if(x > t.GetX()+fgkMaxStep) continue; | |
560 | ||
561 | // append tracklet to track | |
562 | t.SetTracklet(tracklet, index); | |
563 | ||
564 | if (x < (t.GetX()-fgkMaxStep) && !PropagateToX(t, x+fgkMaxStep, fgkMaxStep)) break; | |
565 | if (!AdjustSector(&t)) break; | |
566 | ||
567 | // Start global position | |
568 | Double_t xyz0[3]; | |
569 | t.GetXYZ(xyz0); | |
570 | ||
571 | // End global position | |
572 | Double_t alpha = t.GetAlpha(), y, z; | |
573 | if (!t.GetProlongation(x,y,z)) break; | |
574 | Double_t xyz1[3]; | |
575 | xyz1[0] = x * TMath::Cos(alpha) - y * TMath::Sin(alpha); | |
576 | xyz1[1] = x * TMath::Sin(alpha) + y * TMath::Cos(alpha); | |
577 | xyz1[2] = z; | |
578 | ||
51a23065 | 579 | Double_t length = TMath::Sqrt( |
580 | (xyz0[0]-xyz1[0])*(xyz0[0]-xyz1[0]) + | |
581 | (xyz0[1]-xyz1[1])*(xyz0[1]-xyz1[1]) + | |
582 | (xyz0[2]-xyz1[2])*(xyz0[2]-xyz1[2]) | |
583 | ); | |
584 | if(length>0.){ | |
585 | // Get material budget | |
586 | Double_t param[7]; | |
587 | if(AliTracker::MeanMaterialBudget(xyz0, xyz1, param)<=0.) break; | |
588 | Double_t xrho= param[0]*param[4]; | |
589 | Double_t xx0 = param[1]; // Get mean propagation parameters | |
590 | ||
591 | // Propagate and update | |
592 | t.PropagateTo(x, xx0, xrho); | |
593 | if (!AdjustSector(&t)) break; | |
594 | } | |
e3cf3d02 | 595 | if(kStoreIn){ |
596 | t.SetTrackHigh(); | |
597 | kStoreIn = kFALSE; | |
598 | } | |
599 | ||
b72f4eaf | 600 | Double_t cov[3]; tracklet->GetCovAt(x, cov); |
601 | Double_t p[2] = { tracklet->GetY(), tracklet->GetZ()}; | |
602 | Double_t chi2 = ((AliExternalTrackParam)t).GetPredictedChi2(p, cov); | |
603 | if (chi2 < 1e+10 && t.Update(p, cov, chi2)){ | |
41702fec | 604 | nClustersExpected += tracklet->GetN(); |
605 | } | |
606 | } | |
607 | ||
a2fbb6ec | 608 | if(fkReconstructor->GetRecoParam()->GetStreamLevel(AliTRDrecoParam::kTracker) > 1){ |
41702fec | 609 | Int_t index; |
51a23065 | 610 | for(int iplane=0; iplane<AliTRDgeometry::kNlayer; iplane++){ |
41702fec | 611 | AliTRDseedV1 *tracklet = GetTracklet(&t, iplane, index); |
612 | if(!tracklet) continue; | |
613 | t.SetTracklet(tracklet, index); | |
614 | } | |
615 | ||
a2fbb6ec | 616 | if(fkReconstructor->IsDebugStreaming()){ |
617 | Int_t eventNumber = AliTRDtrackerDebug::GetEventNumber(); | |
618 | TTreeSRedirector &cstreamer = *fkReconstructor->GetDebugStream(AliTRDrecoParam::kTracker); | |
619 | AliTRDtrackV1 track(t); | |
620 | track.SetOwner(); | |
621 | cstreamer << "FollowProlongation" | |
622 | << "EventNumber=" << eventNumber | |
623 | << "ncl=" << nClustersExpected | |
624 | << "track.=" << &track | |
625 | << "\n"; | |
626 | } | |
41702fec | 627 | } |
41702fec | 628 | return nClustersExpected; |
0906e73e | 629 | |
630 | } | |
631 | ||
632 | //_____________________________________________________________________________ | |
633 | Int_t AliTRDtrackerV1::FollowBackProlongation(AliTRDtrackV1 &t) | |
634 | { | |
afa21247 | 635 | // Extrapolates/Build the TRD track in the TOF direction. |
636 | // | |
637 | // Parameters | |
638 | // t : the TRD track which has to be extrapolated | |
639 | // | |
640 | // Output | |
641 | // number of clusters attached to the track | |
642 | // | |
643 | // Starting from current radial position of track <t> this function | |
644 | // extrapolates the track through the 6 TRD layers. The following steps | |
645 | // are being performed for each plane: | |
646 | // 1. Propagate track to the entrance of the next chamber: | |
647 | // - get chamber limits in the radial direction | |
648 | // - check crossing sectors | |
649 | // - check track inclination | |
650 | // - check track prolongation against boundary conditions (see exclusion boundaries on AliTRDgeometry::IsOnBoundary()) | |
651 | // 2. Build tracklet (see AliTRDseed::AttachClusters() for details) for this layer if needed. If only | |
652 | // Kalman filter is needed and tracklets are already linked to the track this step is skipped. | |
653 | // 3. Fit tracklet using the information from the Kalman filter. | |
654 | // 4. Propagate and update track at reference radial position of the tracklet. | |
655 | // 5. Register tracklet with the tracker and track; update pulls monitoring. | |
656 | // | |
657 | // Observation | |
2a3191bb | 658 | // 1. During the propagation a bit map is filled detailing the status of the track in each TRD chamber. The following errors are being registered for each tracklet: |
659 | // - AliTRDtrackV1::kProlongation : track prolongation failed | |
660 | // - AliTRDtrackV1::kPropagation : track prolongation failed | |
661 | // - AliTRDtrackV1::kAdjustSector : failed during sector crossing | |
662 | // - AliTRDtrackV1::kSnp : too large bending | |
663 | // - AliTRDtrackV1::kTrackletInit : fail to initialize tracklet | |
664 | // - AliTRDtrackV1::kUpdate : fail to attach clusters or fit the tracklet | |
665 | // - AliTRDtrackV1::kUnknown : anything which is not covered before | |
afa21247 | 666 | // 2. By default the status of the track before first TRD update is saved. |
667 | // | |
668 | // Debug level 2 | |
669 | // | |
670 | // Author | |
671 | // Alexandru Bercuci <A.Bercuci@gsi.de> | |
672 | // | |
41702fec | 673 | |
eb2b4f91 | 674 | Int_t n = 0; |
675 | Double_t driftLength = .5*AliTRDgeometry::AmThick() + AliTRDgeometry::DrThick(); | |
4d6aee34 | 676 | AliTRDtrackingChamber *chamber = NULL; |
41702fec | 677 | |
7c3eecb8 | 678 | Int_t debugLevel = fkReconstructor->IsDebugStreaming() ? fkReconstructor->GetRecoParam()->GetStreamLevel(AliTRDrecoParam::kTracker) : 0; |
679 | TTreeSRedirector *cstreamer = fkReconstructor->IsDebugStreaming() ? fkReconstructor->GetDebugStream(AliTRDrecoParam::kTracker) : 0x0; | |
680 | ||
4d6aee34 | 681 | AliTRDseedV1 tracklet, *ptrTracklet = NULL; |
181d2c97 | 682 | // in case of stand alone tracking we store all the pointers to the tracklets in a temporary array |
683 | AliTRDseedV1 *tracklets[kNPlanes]; | |
684 | memset(tracklets, 0, sizeof(AliTRDseedV1 *) * kNPlanes); | |
685 | for(Int_t ip = 0; ip < kNPlanes; ip++){ | |
686 | tracklets[ip] = t.GetTracklet(ip); | |
687 | t.UnsetTracklet(ip); | |
688 | } | |
81a6494d | 689 | Bool_t kStoreIn = kTRUE, kPropagateIn = kTRUE; |
e3cf3d02 | 690 | |
053767a4 | 691 | // Loop through the TRD layers |
4d6aee34 | 692 | TGeoHMatrix *matrix = NULL; |
eb2b4f91 | 693 | Double_t x, y, z; |
694 | for (Int_t ily=0, sm=-1, stk=-1, det=-1; ily < AliTRDgeometry::kNlayer; ily++) { | |
695 | // rough estimate of the entry point | |
696 | if (!t.GetProlongation(fR[ily], y, z)){ | |
697 | n=-1; | |
698 | t.SetStatus(AliTRDtrackV1::kProlongation); | |
699 | break; | |
700 | } | |
41702fec | 701 | |
eb2b4f91 | 702 | // find sector / stack / detector |
703 | sm = t.GetSector(); | |
704 | // TODO cross check with y value ! | |
705 | stk = fGeom->GetStack(z, ily); | |
706 | det = stk>=0 ? AliTRDgeometry::GetDetector(ily, stk, sm) : -1; | |
4d6aee34 | 707 | matrix = det>=0 ? fGeom->GetClusterMatrix(det) : NULL; |
eb2b4f91 | 708 | |
709 | // check if supermodule/chamber is installed | |
710 | if( !fGeom->GetSMstatus(sm) || | |
711 | stk<0. || | |
712 | fGeom->IsHole(ily, stk, sm) || | |
713 | !matrix ){ | |
714 | // propagate to the default radial position | |
715 | if(fR[ily] > (fgkMaxStep + t.GetX()) && !PropagateToX(t, fR[ily], fgkMaxStep)){ | |
716 | n=-1; | |
717 | t.SetStatus(AliTRDtrackV1::kPropagation); | |
41702fec | 718 | break; |
719 | } | |
eb2b4f91 | 720 | if(!AdjustSector(&t)){ |
721 | n=-1; | |
722 | t.SetStatus(AliTRDtrackV1::kAdjustSector); | |
723 | break; | |
724 | } | |
725 | if(TMath::Abs(t.GetSnp()) > fgkMaxSnp){ | |
726 | n=-1; | |
727 | t.SetStatus(AliTRDtrackV1::kSnp); | |
728 | break; | |
729 | } | |
730 | t.SetStatus(AliTRDtrackV1::kGeometry, ily); | |
41702fec | 731 | continue; |
732 | } | |
e3cf3d02 | 733 | |
eb2b4f91 | 734 | // retrieve rotation matrix for the current chamber |
735 | Double_t loc[] = {AliTRDgeometry::AnodePos()- driftLength, 0., 0.}; | |
736 | Double_t glb[] = {0., 0., 0.}; | |
737 | matrix->LocalToMaster(loc, glb); | |
738 | ||
739 | // Propagate to the radial distance of the current layer | |
740 | x = glb[0] - fgkMaxStep; | |
741 | if(x > (fgkMaxStep + t.GetX()) && !PropagateToX(t, x, fgkMaxStep)){ | |
742 | n=-1; | |
743 | t.SetStatus(AliTRDtrackV1::kPropagation); | |
744 | break; | |
745 | } | |
746 | if(!AdjustSector(&t)){ | |
747 | n=-1; | |
748 | t.SetStatus(AliTRDtrackV1::kAdjustSector); | |
749 | break; | |
750 | } | |
751 | if(TMath::Abs(t.GetSnp()) > fgkMaxSnp) { | |
752 | n=-1; | |
753 | t.SetStatus(AliTRDtrackV1::kSnp); | |
754 | break; | |
755 | } | |
4d6aee34 | 756 | Bool_t doRecalculate = kFALSE; |
eb2b4f91 | 757 | if(sm != t.GetSector()){ |
758 | sm = t.GetSector(); | |
4d6aee34 | 759 | doRecalculate = kTRUE; |
eb2b4f91 | 760 | } |
761 | if(stk != fGeom->GetStack(z, ily)){ | |
762 | stk = fGeom->GetStack(z, ily); | |
4d6aee34 | 763 | doRecalculate = kTRUE; |
eb2b4f91 | 764 | } |
4d6aee34 | 765 | if(doRecalculate){ |
eb2b4f91 | 766 | det = AliTRDgeometry::GetDetector(ily, stk, sm); |
767 | if(!(matrix = fGeom->GetClusterMatrix(det))){ | |
768 | t.SetStatus(AliTRDtrackV1::kGeometry, ily); | |
769 | continue; | |
770 | } | |
771 | matrix->LocalToMaster(loc, glb); | |
772 | x = glb[0] - fgkMaxStep; | |
773 | } | |
774 | ||
775 | // check if track is well inside fiducial volume | |
776 | if (!t.GetProlongation(x+fgkMaxStep, y, z)) { | |
777 | n=-1; | |
778 | t.SetStatus(AliTRDtrackV1::kProlongation); | |
779 | break; | |
780 | } | |
781 | if(fGeom->IsOnBoundary(det, y, z, .5)){ | |
782 | t.SetStatus(AliTRDtrackV1::kBoundary, ily); | |
783 | continue; | |
784 | } | |
785 | // mark track as entering the FIDUCIAL volume of TRD | |
e3cf3d02 | 786 | if(kStoreIn){ |
787 | t.SetTrackLow(); | |
788 | kStoreIn = kFALSE; | |
789 | } | |
b1957d3c | 790 | |
eb2b4f91 | 791 | ptrTracklet = tracklets[ily]; |
792 | if(!ptrTracklet){ // BUILD TRACKLET | |
0217fcd0 | 793 | AliDebug(2, Form("Building tracklet ly[%d]", ily)); |
eb2b4f91 | 794 | // check data in supermodule |
795 | if(!fTrSec[sm].GetNChambers()){ | |
796 | t.SetStatus(AliTRDtrackV1::kNoClusters, ily); | |
797 | continue; | |
798 | } | |
799 | if(fTrSec[sm].GetX(ily) < 1.){ | |
800 | t.SetStatus(AliTRDtrackV1::kNoClusters, ily); | |
801 | continue; | |
802 | } | |
803 | ||
804 | // check data in chamber | |
805 | if(!(chamber = fTrSec[sm].GetChamber(stk, ily))){ | |
806 | t.SetStatus(AliTRDtrackV1::kNoClusters, ily); | |
807 | continue; | |
808 | } | |
4d6aee34 | 809 | if(chamber->GetNClusters() < fgNTimeBins*fkReconstructor->GetRecoParam() ->GetFindableClusters()){ |
eb2b4f91 | 810 | t.SetStatus(AliTRDtrackV1::kNoClusters, ily); |
811 | continue; | |
812 | } | |
813 | // build tracklet | |
814 | ptrTracklet = new(&tracklet) AliTRDseedV1(det); | |
4d6aee34 | 815 | ptrTracklet->SetReconstructor(fkReconstructor); |
eb2b4f91 | 816 | ptrTracklet->SetKink(t.IsKink()); |
817 | ptrTracklet->SetPadPlane(fGeom->GetPadPlane(ily, stk)); | |
818 | ptrTracklet->SetX0(glb[0]+driftLength); | |
819 | if(!tracklet.Init(&t)){ | |
820 | n=-1; | |
821 | t.SetStatus(AliTRDtrackV1::kTrackletInit); | |
822 | break; | |
823 | } | |
824 | if(!tracklet.AttachClusters(chamber, kTRUE)){ | |
825 | t.SetStatus(AliTRDtrackV1::kNoAttach, ily); | |
7c3eecb8 | 826 | if(debugLevel>3){ |
827 | AliTRDseedV1 trackletCp(*ptrTracklet); | |
828 | UChar_t status(t.GetStatusTRD(ily)); | |
829 | (*cstreamer) << "FollowBackProlongation2" | |
830 | <<"status=" << status | |
831 | <<"tracklet.=" << &trackletCp | |
832 | << "\n"; | |
833 | } | |
eb2b4f91 | 834 | continue; |
835 | } | |
4d6aee34 | 836 | if(tracklet.GetN() < fgNTimeBins*fkReconstructor->GetRecoParam() ->GetFindableClusters()){ |
eb2b4f91 | 837 | t.SetStatus(AliTRDtrackV1::kNoClustersTracklet, ily); |
7c3eecb8 | 838 | if(debugLevel>3){ |
839 | AliTRDseedV1 trackletCp(*ptrTracklet); | |
840 | UChar_t status(t.GetStatusTRD(ily)); | |
841 | (*cstreamer) << "FollowBackProlongation2" | |
842 | <<"status=" << status | |
843 | <<"tracklet.=" << &trackletCp | |
844 | << "\n"; | |
845 | } | |
eb2b4f91 | 846 | continue; |
847 | } | |
848 | ptrTracklet->UpdateUsed(); | |
0217fcd0 | 849 | } else AliDebug(2, Form("Use external tracklet ly[%d]", ily)); |
eb2b4f91 | 850 | // propagate track to the radial position of the tracklet |
851 | ptrTracklet->UseClusters(); // TODO ? do we need this here ? | |
852 | // fit tracklet no tilt correction | |
853 | if(!ptrTracklet->Fit(kFALSE)){ | |
854 | t.SetStatus(AliTRDtrackV1::kNoFit, ily); | |
855 | continue; | |
856 | } | |
857 | x = ptrTracklet->GetX(); //GetX0(); | |
858 | if(x > (fgkMaxStep + t.GetX()) && !PropagateToX(t, x, fgkMaxStep)) { | |
859 | n=-1; | |
860 | t.SetStatus(AliTRDtrackV1::kPropagation); | |
861 | break; | |
862 | } | |
863 | if(!AdjustSector(&t)) { | |
864 | n=-1; | |
865 | t.SetStatus(AliTRDtrackV1::kAdjustSector); | |
866 | break; | |
41702fec | 867 | } |
eb2b4f91 | 868 | if(TMath::Abs(t.GetSnp()) > fgkMaxSnp) { |
869 | n=-1; | |
870 | t.SetStatus(AliTRDtrackV1::kSnp); | |
871 | break; | |
872 | } | |
81a6494d | 873 | if(kPropagateIn){ |
874 | t.SetTrackLow(); | |
875 | kPropagateIn = kFALSE; | |
876 | } | |
b72f4eaf | 877 | Double_t cov[3]; ptrTracklet->GetCovAt(x, cov); |
878 | Double_t p[2] = { ptrTracklet->GetY(), ptrTracklet->GetZ()}; | |
879 | Double_t chi2 = ((AliExternalTrackParam)t).GetPredictedChi2(p, cov); | |
6e39bde4 | 880 | // update Kalman with the TRD measurement |
b72f4eaf | 881 | if(chi2>1e+10){ // TODO |
eb2b4f91 | 882 | t.SetStatus(AliTRDtrackV1::kChi2, ily); |
7c3eecb8 | 883 | if(debugLevel > 2){ |
884 | UChar_t status(t.GetStatusTRD()); | |
885 | AliTRDseedV1 trackletCp(*ptrTracklet); | |
886 | AliTRDtrackV1 trackCp(t); | |
887 | trackCp.SetOwner(); | |
888 | (*cstreamer) << "FollowBackProlongation1" | |
889 | << "status=" << status | |
890 | << "tracklet.=" << &trackletCp | |
891 | << "track.=" << &trackCp | |
892 | << "\n"; | |
893 | } | |
eb2b4f91 | 894 | continue; |
895 | } | |
b72f4eaf | 896 | if(!t.Update(p, cov, chi2)) { |
eb2b4f91 | 897 | n=-1; |
898 | t.SetStatus(AliTRDtrackV1::kUpdate); | |
7c3eecb8 | 899 | if(debugLevel > 2){ |
900 | UChar_t status(t.GetStatusTRD()); | |
901 | AliTRDseedV1 trackletCp(*ptrTracklet); | |
902 | AliTRDtrackV1 trackCp(t); | |
903 | trackCp.SetOwner(); | |
904 | (*cstreamer) << "FollowBackProlongation1" | |
905 | << "status=" << status | |
906 | << "tracklet.=" << &trackletCp | |
907 | << "track.=" << &trackCp | |
908 | << "\n"; | |
909 | } | |
eb2b4f91 | 910 | break; |
911 | } | |
b72f4eaf | 912 | // fill residuals ?! |
913 | AliTracker::FillResiduals(&t, p, cov, ptrTracklet->GetVolumeId()); | |
914 | ||
eb2b4f91 | 915 | |
916 | // load tracklet to the tracker | |
16cca13f | 917 | ptrTracklet->Update(&t); |
eb2b4f91 | 918 | ptrTracklet = SetTracklet(ptrTracklet); |
919 | t.SetTracklet(ptrTracklet, fTracklets->GetEntriesFast()-1); | |
920 | n += ptrTracklet->GetN(); | |
921 | ||
41702fec | 922 | // Reset material budget if 2 consecutive gold |
eb2b4f91 | 923 | // if(ilayer>0 && t.GetTracklet(ilayer-1) && ptrTracklet->GetN() + t.GetTracklet(ilayer-1)->GetN() > 20) t.SetBudget(2, 0.); |
41702fec | 924 | |
925 | // Make backup of the track until is gold | |
926 | // TO DO update quality check of the track. | |
927 | // consider comparison with fTimeBinsRange | |
928 | Float_t ratio0 = ptrTracklet->GetN() / Float_t(fgNTimeBins); | |
929 | //Float_t ratio1 = Float_t(t.GetNumberOfClusters()+1) / Float_t(t.GetNExpected()+1); | |
41702fec | 930 | |
eb2b4f91 | 931 | if( (chi2 < 18.0) && |
41702fec | 932 | (ratio0 > 0.8) && |
933 | //(ratio1 > 0.6) && | |
934 | //(ratio0+ratio1 > 1.5) && | |
935 | (t.GetNCross() == 0) && | |
936 | (TMath::Abs(t.GetSnp()) < 0.85) && | |
e3cf3d02 | 937 | (t.GetNumberOfClusters() > 20)){ |
938 | t.MakeBackupTrack(); | |
939 | } | |
053767a4 | 940 | } // end layers loop |
eb2b4f91 | 941 | //printf("clusters[%d] chi2[%f] x[%f] status[%d ", n, t.GetChi2(), t.GetX(), t.GetStatusTRD()); |
942 | //for(int i=0; i<6; i++) printf("%d ", t.GetStatusTRD(i)); printf("]\n"); | |
41702fec | 943 | |
7c3eecb8 | 944 | if(debugLevel > 1){ |
41702fec | 945 | Int_t eventNumber = AliTRDtrackerDebug::GetEventNumber(); |
eb2b4f91 | 946 | AliTRDtrackV1 track(t); |
947 | track.SetOwner(); | |
7c3eecb8 | 948 | (*cstreamer) << "FollowBackProlongation0" |
eb2b4f91 | 949 | << "EventNumber=" << eventNumber |
950 | << "ncl=" << n | |
951 | << "track.=" << &track | |
41702fec | 952 | << "\n"; |
953 | } | |
954 | ||
eb2b4f91 | 955 | return n; |
0906e73e | 956 | } |
957 | ||
eb38ed55 | 958 | //_________________________________________________________________________ |
4d6aee34 | 959 | Float_t AliTRDtrackerV1::FitRieman(AliTRDseedV1 *tracklets, Double_t *chi2, Int_t *const planes){ |
41702fec | 960 | // |
961 | // Fits a Riemann-circle to the given points without tilting pad correction. | |
962 | // The fit is performed using an instance of the class AliRieman (equations | |
963 | // and transformations see documentation of this class) | |
964 | // Afterwards all the tracklets are Updated | |
965 | // | |
966 | // Parameters: - Array of tracklets (AliTRDseedV1) | |
967 | // - Storage for the chi2 values (beginning with direction z) | |
968 | // - Seeding configuration | |
969 | // Output: - The curvature | |
970 | // | |
971 | AliRieman *fitter = AliTRDtrackerV1::GetRiemanFitter(); | |
972 | fitter->Reset(); | |
973 | Int_t allplanes[] = {0, 1, 2, 3, 4, 5}; | |
974 | Int_t *ppl = &allplanes[0]; | |
975 | Int_t maxLayers = 6; | |
976 | if(planes){ | |
977 | maxLayers = 4; | |
978 | ppl = planes; | |
979 | } | |
980 | for(Int_t il = 0; il < maxLayers; il++){ | |
981 | if(!tracklets[ppl[il]].IsOK()) continue; | |
e3cf3d02 | 982 | fitter->AddPoint(tracklets[ppl[il]].GetX0(), tracklets[ppl[il]].GetYfit(0), tracklets[ppl[il]].GetZfit(0),1,10); |
41702fec | 983 | } |
984 | fitter->Update(); | |
985 | // Set the reference position of the fit and calculate the chi2 values | |
986 | memset(chi2, 0, sizeof(Double_t) * 2); | |
987 | for(Int_t il = 0; il < maxLayers; il++){ | |
988 | // Reference positions | |
989 | tracklets[ppl[il]].Init(fitter); | |
990 | ||
991 | // chi2 | |
992 | if((!tracklets[ppl[il]].IsOK()) && (!planes)) continue; | |
993 | chi2[0] += tracklets[ppl[il]].GetChi2Y(); | |
994 | chi2[1] += tracklets[ppl[il]].GetChi2Z(); | |
995 | } | |
996 | return fitter->GetC(); | |
eb38ed55 | 997 | } |
998 | ||
999 | //_________________________________________________________________________ | |
1000 | void AliTRDtrackerV1::FitRieman(AliTRDcluster **seedcl, Double_t chi2[2]) | |
1001 | { | |
41702fec | 1002 | // |
1003 | // Performs a Riemann helix fit using the seedclusters as spacepoints | |
1004 | // Afterwards the chi2 values are calculated and the seeds are updated | |
1005 | // | |
1006 | // Parameters: - The four seedclusters | |
1007 | // - The tracklet array (AliTRDseedV1) | |
1008 | // - The seeding configuration | |
1009 | // - Chi2 array | |
1010 | // | |
1011 | // debug level 2 | |
1012 | // | |
1013 | AliRieman *fitter = AliTRDtrackerV1::GetRiemanFitter(); | |
1014 | fitter->Reset(); | |
a3743898 | 1015 | for(Int_t i = 0; i < 4; i++){ |
a3743898 | 1016 | fitter->AddPoint(seedcl[i]->GetX(), seedcl[i]->GetY(), seedcl[i]->GetZ(), 1., 10.); |
1017 | } | |
41702fec | 1018 | fitter->Update(); |
1019 | ||
1020 | ||
1021 | // Update the seed and calculated the chi2 value | |
1022 | chi2[0] = 0; chi2[1] = 0; | |
1023 | for(Int_t ipl = 0; ipl < kNSeedPlanes; ipl++){ | |
1024 | // chi2 | |
1025 | chi2[0] += (seedcl[ipl]->GetZ() - fitter->GetZat(seedcl[ipl]->GetX())) * (seedcl[ipl]->GetZ() - fitter->GetZat(seedcl[ipl]->GetX())); | |
1026 | chi2[1] += (seedcl[ipl]->GetY() - fitter->GetYat(seedcl[ipl]->GetX())) * (seedcl[ipl]->GetY() - fitter->GetYat(seedcl[ipl]->GetX())); | |
1027 | } | |
eb38ed55 | 1028 | } |
1029 | ||
1030 | ||
1031 | //_________________________________________________________________________ | |
1032 | Float_t AliTRDtrackerV1::FitTiltedRiemanConstraint(AliTRDseedV1 *tracklets, Double_t zVertex) | |
1033 | { | |
41702fec | 1034 | // |
1035 | // Fits a helix to the clusters. Pad tilting is considered. As constraint it is | |
1036 | // assumed that the vertex position is set to 0. | |
1037 | // This method is very usefull for high-pt particles | |
1038 | // Basis for the fit: (x - x0)^2 + (y - y0)^2 - R^2 = 0 | |
1039 | // x0, y0: Center of the circle | |
1040 | // Measured y-position: ymeas = y - tan(phiT)(zc - zt) | |
1041 | // zc: center of the pad row | |
1042 | // Equation which has to be fitted (after transformation): | |
1043 | // a + b * u + e * v + 2*(ymeas + tan(phiT)(z - zVertex))*t = 0 | |
1044 | // Transformation: | |
1045 | // t = 1/(x^2 + y^2) | |
1046 | // u = 2 * x * t | |
1047 | // v = 2 * x * tan(phiT) * t | |
1048 | // Parameters in the equation: | |
1049 | // a = -1/y0, b = x0/y0, e = dz/dx | |
1050 | // | |
1051 | // The Curvature is calculated by the following equation: | |
1052 | // - curv = a/Sqrt(b^2 + 1) = 1/R | |
1053 | // Parameters: - the 6 tracklets | |
1054 | // - the Vertex constraint | |
1055 | // Output: - the Chi2 value of the track | |
1056 | // | |
1057 | // debug level 5 | |
1058 | // | |
1059 | ||
1060 | TLinearFitter *fitter = GetTiltedRiemanFitterConstraint(); | |
1061 | fitter->StoreData(kTRUE); | |
1062 | fitter->ClearPoints(); | |
4d6aee34 | 1063 | AliTRDcluster *cl = NULL; |
41702fec | 1064 | |
1065 | Float_t x, y, z, w, t, error, tilt; | |
1066 | Double_t uvt[2]; | |
1067 | Int_t nPoints = 0; | |
053767a4 | 1068 | for(Int_t ilr = 0; ilr < AliTRDgeometry::kNlayer; ilr++){ |
1069 | if(!tracklets[ilr].IsOK()) continue; | |
8d2bec9e | 1070 | for(Int_t itb = 0; itb < AliTRDseedV1::kNclusters; itb++){ |
053767a4 | 1071 | if(!tracklets[ilr].IsUsable(itb)) continue; |
1072 | cl = tracklets[ilr].GetClusters(itb); | |
1742f24c | 1073 | if(!cl->IsInChamber()) continue; |
41702fec | 1074 | x = cl->GetX(); |
1075 | y = cl->GetY(); | |
1076 | z = cl->GetZ(); | |
053767a4 | 1077 | tilt = tracklets[ilr].GetTilt(); |
41702fec | 1078 | // Transformation |
1079 | t = 1./(x * x + y * y); | |
1080 | uvt[0] = 2. * x * t; | |
1081 | uvt[1] = 2. * x * t * tilt ; | |
1082 | w = 2. * (y + tilt * (z - zVertex)) * t; | |
78b7d24c | 1083 | error = 2. * TMath::Sqrt(cl->GetSigmaY2()+tilt*tilt*cl->GetSigmaZ2()) * t; |
41702fec | 1084 | fitter->AddPoint(uvt, w, error); |
1085 | nPoints++; | |
1086 | } | |
1087 | } | |
e17f4785 | 1088 | fitter->Eval(); |
41702fec | 1089 | |
1090 | // Calculate curvature | |
1091 | Double_t a = fitter->GetParameter(0); | |
1092 | Double_t b = fitter->GetParameter(1); | |
1093 | Double_t curvature = a/TMath::Sqrt(b*b + 1); | |
1094 | ||
1095 | Float_t chi2track = fitter->GetChisquare()/Double_t(nPoints); | |
1096 | for(Int_t ip = 0; ip < AliTRDtrackerV1::kNPlanes; ip++) | |
e3cf3d02 | 1097 | tracklets[ip].SetC(curvature); |
41702fec | 1098 | |
a2fbb6ec | 1099 | /* if(fkReconstructor->GetRecoParam()->GetStreamLevel(AliTRDrecoParam::kTracker()) >= 5){ |
41702fec | 1100 | //Linear Model on z-direction |
1101 | Double_t xref = CalculateReferenceX(tracklets); // Relative to the middle of the stack | |
1102 | Double_t slope = fitter->GetParameter(2); | |
1103 | Double_t zref = slope * xref; | |
1104 | Float_t chi2Z = CalculateChi2Z(tracklets, zref, slope, xref); | |
1105 | Int_t eventNumber = AliTRDtrackerDebug::GetEventNumber(); | |
1106 | Int_t candidateNumber = AliTRDtrackerDebug::GetCandidateNumber(); | |
4d6aee34 | 1107 | TTreeSRedirector &treeStreamer = *fkReconstructor->GetDebugStream(AliTRDReconstructor::kTracker); |
41702fec | 1108 | treeStreamer << "FitTiltedRiemanConstraint" |
1109 | << "EventNumber=" << eventNumber | |
1110 | << "CandidateNumber=" << candidateNumber | |
1111 | << "Curvature=" << curvature | |
1112 | << "Chi2Track=" << chi2track | |
1113 | << "Chi2Z=" << chi2Z | |
1114 | << "zref=" << zref | |
1115 | << "\n"; | |
3a039a31 | 1116 | }*/ |
41702fec | 1117 | return chi2track; |
eb38ed55 | 1118 | } |
1119 | ||
1120 | //_________________________________________________________________________ | |
1121 | Float_t AliTRDtrackerV1::FitTiltedRieman(AliTRDseedV1 *tracklets, Bool_t sigError) | |
1122 | { | |
41702fec | 1123 | // |
1124 | // Performs a Riemann fit taking tilting pad correction into account | |
1125 | // The equation of a Riemann circle, where the y position is substituted by the | |
1126 | // measured y-position taking pad tilting into account, has to be transformed | |
1127 | // into a 4-dimensional hyperplane equation | |
1128 | // Riemann circle: (x-x0)^2 + (y-y0)^2 -R^2 = 0 | |
1129 | // Measured y-Position: ymeas = y - tan(phiT)(zc - zt) | |
1130 | // zc: center of the pad row | |
1131 | // zt: z-position of the track | |
1132 | // The z-position of the track is assumed to be linear dependent on the x-position | |
1133 | // Transformed equation: a + b * u + c * t + d * v + e * w - 2 * (ymeas + tan(phiT) * zc) * t = 0 | |
1134 | // Transformation: u = 2 * x * t | |
1135 | // v = 2 * tan(phiT) * t | |
1136 | // w = 2 * tan(phiT) * (x - xref) * t | |
1137 | // t = 1 / (x^2 + ymeas^2) | |
1138 | // Parameters: a = -1/y0 | |
1139 | // b = x0/y0 | |
1140 | // c = (R^2 -x0^2 - y0^2)/y0 | |
1141 | // d = offset | |
1142 | // e = dz/dx | |
1143 | // If the offset respectively the slope in z-position is impossible, the parameters are fixed using | |
1144 | // results from the simple riemann fit. Afterwards the fit is redone. | |
1145 | // The curvature is calculated according to the formula: | |
1146 | // curv = a/(1 + b^2 + c*a) = 1/R | |
1147 | // | |
1148 | // Paramters: - Array of tracklets (connected to the track candidate) | |
1149 | // - Flag selecting the error definition | |
1150 | // Output: - Chi2 values of the track (in Parameter list) | |
1151 | // | |
1152 | TLinearFitter *fitter = GetTiltedRiemanFitter(); | |
1153 | fitter->StoreData(kTRUE); | |
1154 | fitter->ClearPoints(); | |
1155 | AliTRDLeastSquare zfitter; | |
4d6aee34 | 1156 | AliTRDcluster *cl = NULL; |
41702fec | 1157 | |
1158 | Double_t xref = CalculateReferenceX(tracklets); | |
6e39bde4 | 1159 | Double_t x, y, z, t, tilt, dx, w, we, erry, errz; |
1160 | Double_t uvt[4], sumPolY[5], sumPolZ[3]; | |
1161 | memset(sumPolY, 0, sizeof(Double_t) * 5); | |
1162 | memset(sumPolZ, 0, sizeof(Double_t) * 3); | |
41702fec | 1163 | Int_t nPoints = 0; |
1164 | // Containers for Least-square fitter | |
1165 | for(Int_t ipl = 0; ipl < kNPlanes; ipl++){ | |
1166 | if(!tracklets[ipl].IsOK()) continue; | |
ed15ef4f | 1167 | tilt = tracklets[ipl].GetTilt(); |
8d2bec9e | 1168 | for(Int_t itb = 0; itb < AliTRDseedV1::kNclusters; itb++){ |
41702fec | 1169 | if(!(cl = tracklets[ipl].GetClusters(itb))) continue; |
1742f24c | 1170 | if(!cl->IsInChamber()) continue; |
41702fec | 1171 | if (!tracklets[ipl].IsUsable(itb)) continue; |
1172 | x = cl->GetX(); | |
1173 | y = cl->GetY(); | |
1174 | z = cl->GetZ(); | |
41702fec | 1175 | dx = x - xref; |
1176 | // Transformation | |
1177 | t = 1./(x*x + y*y); | |
1178 | uvt[0] = 2. * x * t; | |
1179 | uvt[1] = t; | |
1180 | uvt[2] = 2. * tilt * t; | |
1181 | uvt[3] = 2. * tilt * dx * t; | |
1182 | w = 2. * (y + tilt*z) * t; | |
1183 | // error definition changes for the different calls | |
1184 | we = 2. * t; | |
78b7d24c | 1185 | we *= sigError ? TMath::Sqrt(cl->GetSigmaY2()+tilt*tilt*cl->GetSigmaZ2()) : 0.2; |
41702fec | 1186 | fitter->AddPoint(uvt, w, we); |
1187 | zfitter.AddPoint(&x, z, static_cast<Double_t>(TMath::Sqrt(cl->GetSigmaZ2()))); | |
6e39bde4 | 1188 | // adding points for covariance matrix estimation |
1189 | erry = 1./(TMath::Sqrt(cl->GetSigmaY2()) + 0.1); // 0.1 is a systematic error (due to misalignment and miscalibration) | |
1190 | erry *= erry; | |
1191 | errz = 1./cl->GetSigmaZ2(); | |
1192 | for(Int_t ipol = 0; ipol < 5; ipol++){ | |
1193 | sumPolY[ipol] += erry; | |
1194 | erry *= x; | |
1195 | if(ipol < 3){ | |
1196 | sumPolZ[ipol] += errz; | |
1197 | errz *= x; | |
1198 | } | |
1199 | } | |
41702fec | 1200 | nPoints++; |
1201 | } | |
1202 | } | |
e17f4785 | 1203 | fitter->Eval(); |
41702fec | 1204 | zfitter.Eval(); |
1205 | ||
1206 | Double_t offset = fitter->GetParameter(3); | |
1207 | Double_t slope = fitter->GetParameter(4); | |
1208 | ||
1209 | // Linear fitter - not possible to make boundaries | |
1210 | // Do not accept non possible z and dzdx combinations | |
1211 | Bool_t acceptablez = kTRUE; | |
1212 | Double_t zref = 0.0; | |
1213 | for (Int_t iLayer = 0; iLayer < kNPlanes; iLayer++) { | |
1214 | if(!tracklets[iLayer].IsOK()) continue; | |
1215 | zref = offset + slope * (tracklets[iLayer].GetX0() - xref); | |
e3cf3d02 | 1216 | if (TMath::Abs(tracklets[iLayer].GetZfit(0) - zref) > tracklets[iLayer].GetPadLength() * 0.5 + 1.0) |
41702fec | 1217 | acceptablez = kFALSE; |
1218 | } | |
1219 | if (!acceptablez) { | |
1220 | Double_t dzmf = zfitter.GetFunctionParameter(1); | |
1221 | Double_t zmf = zfitter.GetFunctionValue(&xref); | |
1222 | fgTiltedRieman->FixParameter(3, zmf); | |
1223 | fgTiltedRieman->FixParameter(4, dzmf); | |
e17f4785 | 1224 | fitter->Eval(); |
41702fec | 1225 | fitter->ReleaseParameter(3); |
1226 | fitter->ReleaseParameter(4); | |
1227 | offset = fitter->GetParameter(3); | |
1228 | slope = fitter->GetParameter(4); | |
1229 | } | |
1230 | ||
1231 | // Calculate Curvarture | |
1232 | Double_t a = fitter->GetParameter(0); | |
1233 | Double_t b = fitter->GetParameter(1); | |
1234 | Double_t c = fitter->GetParameter(2); | |
1235 | Double_t curvature = 1.0 + b*b - c*a; | |
1236 | if (curvature > 0.0) | |
1237 | curvature = a / TMath::Sqrt(curvature); | |
1238 | ||
1239 | Double_t chi2track = fitter->GetChisquare()/Double_t(nPoints); | |
1240 | ||
6e39bde4 | 1241 | // Prepare error calculation |
1242 | TMatrixD covarPolY(3,3); | |
1243 | covarPolY(0,0) = sumPolY[0]; covarPolY(1,1) = sumPolY[2]; covarPolY(2,2) = sumPolY[4]; | |
1244 | covarPolY(0,1) = covarPolY(1,0) = sumPolY[1]; | |
1245 | covarPolY(0,2) = covarPolY(2,0) = sumPolY[2]; | |
1246 | covarPolY(2,1) = covarPolY(1,2) = sumPolY[3]; | |
1247 | covarPolY.Invert(); | |
1248 | TMatrixD covarPolZ(2,2); | |
1249 | covarPolZ(0,0) = sumPolZ[0]; covarPolZ(1,1) = sumPolZ[2]; | |
1250 | covarPolZ(1,0) = covarPolZ(0,1) = sumPolZ[1]; | |
1251 | covarPolZ.Invert(); | |
1252 | ||
41702fec | 1253 | // Update the tracklets |
6e39bde4 | 1254 | Double_t x1, dy, dz; |
1255 | Double_t cov[15]; | |
1256 | memset(cov, 0, sizeof(Double_t) * 15); | |
41702fec | 1257 | for(Int_t iLayer = 0; iLayer < AliTRDtrackerV1::kNPlanes; iLayer++) { |
1258 | ||
1259 | x = tracklets[iLayer].GetX0(); | |
6e39bde4 | 1260 | x1 = x - xref; |
41702fec | 1261 | y = 0; |
1262 | z = 0; | |
1263 | dy = 0; | |
1264 | dz = 0; | |
6e39bde4 | 1265 | memset(cov, 0, sizeof(Double_t) * 3); |
1266 | TMatrixD transform(3,3); | |
1267 | transform(0,0) = 1; | |
1268 | transform(0,1) = x; | |
1269 | transform(0,2) = x*x; | |
1270 | transform(1,1) = 1; | |
1271 | transform(1,2) = x; | |
1272 | transform(2,2) = 1; | |
1273 | TMatrixD covariance(transform, TMatrixD::kMult, covarPolY); | |
1274 | covariance *= transform.T(); | |
1275 | TMatrixD transformZ(2,2); | |
1276 | transformZ(0,0) = transformZ(1,1) = 1; | |
1277 | transformZ(0,1) = x; | |
1278 | TMatrixD covarZ(transformZ, TMatrixD::kMult, covarPolZ); | |
1279 | covarZ *= transformZ.T(); | |
41702fec | 1280 | // y: R^2 = (x - x0)^2 + (y - y0)^2 |
1281 | // => y = y0 +/- Sqrt(R^2 - (x - x0)^2) | |
1282 | // R = Sqrt() = 1/Curvature | |
1283 | // => y = y0 +/- Sqrt(1/Curvature^2 - (x - x0)^2) | |
1284 | Double_t res = (x * a + b); // = (x - x0)/y0 | |
1285 | res *= res; | |
1286 | res = 1.0 - c * a + b * b - res; // = (R^2 - (x - x0)^2)/y0^2 | |
1287 | if (res >= 0) { | |
1288 | res = TMath::Sqrt(res); | |
1289 | y = (1.0 - res) / a; | |
1290 | } | |
6e39bde4 | 1291 | cov[0] = covariance(0,0); |
1292 | cov[2] = covarZ(0,0); | |
1293 | cov[1] = 0.; | |
41702fec | 1294 | |
1295 | // dy: R^2 = (x - x0)^2 + (y - y0)^2 | |
1296 | // => y = +/- Sqrt(R^2 - (x - x0)^2) + y0 | |
1297 | // => dy/dx = (x - x0)/Sqrt(R^2 - (x - x0)^2) | |
1298 | // Curvature: cr = 1/R = a/Sqrt(1 + b^2 - c*a) | |
1299 | // => dy/dx = (x - x0)/(1/(cr^2) - (x - x0)^2) | |
1300 | Double_t x0 = -b / a; | |
1301 | if (-c * a + b * b + 1 > 0) { | |
1302 | if (1.0/(curvature * curvature) - (x - x0) * (x - x0) > 0.0) { | |
6e39bde4 | 1303 | Double_t yderiv = (x - x0) / TMath::Sqrt(1.0/(curvature * curvature) - (x - x0) * (x - x0)); |
1304 | if (a < 0) yderiv *= -1.0; | |
1305 | dy = yderiv; | |
41702fec | 1306 | } |
1307 | } | |
1308 | z = offset + slope * (x - xref); | |
1309 | dz = slope; | |
1310 | tracklets[iLayer].SetYref(0, y); | |
1311 | tracklets[iLayer].SetYref(1, dy); | |
1312 | tracklets[iLayer].SetZref(0, z); | |
1313 | tracklets[iLayer].SetZref(1, dz); | |
1314 | tracklets[iLayer].SetC(curvature); | |
6e39bde4 | 1315 | tracklets[iLayer].SetCovRef(cov); |
41702fec | 1316 | tracklets[iLayer].SetChi2(chi2track); |
1317 | } | |
1318 | ||
a2fbb6ec | 1319 | /* if(fkReconstructor->GetRecoParam()->GetStreamLevel(AliTRDrecoParam::kTracker) >=5){ |
1320 | TTreeSRedirector &cstreamer = *fkReconstructor->GetDebugStream(AliTRDrecoParam::kTracker); | |
41702fec | 1321 | Int_t eventNumber = AliTRDtrackerDebug::GetEventNumber(); |
1322 | Int_t candidateNumber = AliTRDtrackerDebug::GetCandidateNumber(); | |
1323 | Double_t chi2z = CalculateChi2Z(tracklets, offset, slope, xref); | |
1324 | cstreamer << "FitTiltedRieman0" | |
1325 | << "EventNumber=" << eventNumber | |
1326 | << "CandidateNumber=" << candidateNumber | |
1327 | << "xref=" << xref | |
1328 | << "Chi2Z=" << chi2z | |
1329 | << "\n"; | |
3a039a31 | 1330 | }*/ |
41702fec | 1331 | return chi2track; |
eb38ed55 | 1332 | } |
1333 | ||
3b57a3f7 | 1334 | |
9e333711 | 1335 | //____________________________________________________________________ |
6e4d4425 | 1336 | Double_t AliTRDtrackerV1::FitLine(const AliTRDtrackV1 *track, AliTRDseedV1 *tracklets, Bool_t err, Int_t np, AliTrackPoint *points) |
9e333711 | 1337 | { |
4d6aee34 | 1338 | // |
1339 | // Fit track with a staight line | |
1340 | // Fills an AliTrackPoint array with np points | |
1341 | // Function should be used to refit tracks when no magnetic field was on | |
1342 | // | |
9e333711 | 1343 | AliTRDLeastSquare yfitter, zfitter; |
4d6aee34 | 1344 | AliTRDcluster *cl = NULL; |
9e333711 | 1345 | |
4d6aee34 | 1346 | AliTRDseedV1 work[kNPlanes], *tracklet = NULL; |
9e333711 | 1347 | if(!tracklets){ |
1348 | for(Int_t ipl = 0; ipl < kNPlanes; ipl++){ | |
1349 | if(!(tracklet = track->GetTracklet(ipl))) continue; | |
1350 | if(!tracklet->IsOK()) continue; | |
1351 | new(&work[ipl]) AliTRDseedV1(*tracklet); | |
1352 | } | |
1353 | tracklets = &work[0]; | |
1354 | } | |
1355 | ||
1356 | Double_t xref = CalculateReferenceX(tracklets); | |
1357 | Double_t x, y, z, dx, ye, yr, tilt; | |
1358 | for(Int_t ipl = 0; ipl < kNPlanes; ipl++){ | |
1359 | if(!tracklets[ipl].IsOK()) continue; | |
1360 | for(Int_t itb = 0; itb < fgNTimeBins; itb++){ | |
1361 | if(!(cl = tracklets[ipl].GetClusters(itb))) continue; | |
1362 | if (!tracklets[ipl].IsUsable(itb)) continue; | |
1363 | x = cl->GetX(); | |
1364 | z = cl->GetZ(); | |
1365 | dx = x - xref; | |
1366 | zfitter.AddPoint(&dx, z, static_cast<Double_t>(TMath::Sqrt(cl->GetSigmaZ2()))); | |
1367 | } | |
1368 | } | |
1369 | zfitter.Eval(); | |
1370 | Double_t z0 = zfitter.GetFunctionParameter(0); | |
1371 | Double_t dzdx = zfitter.GetFunctionParameter(1); | |
1372 | for(Int_t ipl = 0; ipl < kNPlanes; ipl++){ | |
1373 | if(!tracklets[ipl].IsOK()) continue; | |
1374 | for(Int_t itb = 0; itb < fgNTimeBins; itb++){ | |
1375 | if(!(cl = tracklets[ipl].GetClusters(itb))) continue; | |
1376 | if (!tracklets[ipl].IsUsable(itb)) continue; | |
1377 | x = cl->GetX(); | |
1378 | y = cl->GetY(); | |
1379 | z = cl->GetZ(); | |
1380 | tilt = tracklets[ipl].GetTilt(); | |
1381 | dx = x - xref; | |
1382 | yr = y + tilt*(z - z0 - dzdx*dx); | |
1383 | // error definition changes for the different calls | |
1384 | ye = tilt*TMath::Sqrt(cl->GetSigmaZ2()); | |
1385 | ye += err ? tracklets[ipl].GetSigmaY() : 0.2; | |
1386 | yfitter.AddPoint(&dx, yr, ye); | |
1387 | } | |
1388 | } | |
1389 | yfitter.Eval(); | |
1390 | Double_t y0 = yfitter.GetFunctionParameter(0); | |
1391 | Double_t dydx = yfitter.GetFunctionParameter(1); | |
1392 | Double_t chi2 = 0.;//yfitter.GetChisquare()/Double_t(nPoints); | |
1393 | ||
1394 | //update track points array | |
1395 | if(np && points){ | |
1396 | Float_t xyz[3]; | |
1397 | for(int ip=0; ip<np; ip++){ | |
1398 | points[ip].GetXYZ(xyz); | |
1399 | xyz[1] = y0 + dydx * (xyz[0] - xref); | |
1400 | xyz[2] = z0 + dzdx * (xyz[0] - xref); | |
1401 | points[ip].SetXYZ(xyz); | |
1402 | } | |
1403 | } | |
1404 | return chi2; | |
1405 | } | |
1406 | ||
1407 | ||
3b57a3f7 | 1408 | //_________________________________________________________________________ |
6e4d4425 | 1409 | Double_t AliTRDtrackerV1::FitRiemanTilt(const AliTRDtrackV1 *track, AliTRDseedV1 *tracklets, Bool_t sigError, Int_t np, AliTrackPoint *points) |
3b57a3f7 | 1410 | { |
0fa1a8ee | 1411 | // |
1412 | // Performs a Riemann fit taking tilting pad correction into account | |
1413 | // | |
1414 | // Paramters: - Array of tracklets (connected to the track candidate) | |
1415 | // - Flag selecting the error definition | |
1416 | // Output: - Chi2 values of the track (in Parameter list) | |
1417 | // | |
1418 | // The equations which has to be solved simultaneously are: | |
1419 | // BEGIN_LATEX | |
1420 | // R^{2} = (x-x_{0})^{2} + (y^{*}-y_{0})^{2} | |
1421 | // y^{*} = y - tg(h)(z - z_{t}) | |
1422 | // z_{t} = z_{0}+dzdx*(x-x_{r}) | |
1423 | // END_LATEX | |
1424 | // with (x, y, z) the coordinate of the cluster, (x_0, y_0, z_0) the coordinate of the center of the Riemann circle, | |
1425 | // R its radius, x_r a constant refrence radial position in the middle of the TRD stack and dzdx the slope of the | |
1426 | // track in the x-z plane. Using the following transformations | |
1427 | // BEGIN_LATEX | |
1428 | // t = 1 / (x^{2} + y^{2}) | |
1429 | // u = 2 * x * t | |
1430 | // v = 2 * tan(h) * t | |
1431 | // w = 2 * tan(h) * (x - x_{r}) * t | |
1432 | // END_LATEX | |
1433 | // One gets the following linear equation | |
1434 | // BEGIN_LATEX | |
1435 | // a + b * u + c * t + d * v + e * w = 2 * (y + tg(h) * z) * t | |
1436 | // END_LATEX | |
1437 | // where the coefficients have the following meaning | |
1438 | // BEGIN_LATEX | |
1439 | // a = -1/y_{0} | |
1440 | // b = x_{0}/y_{0} | |
1441 | // c = (R^{2} -x_{0}^{2} - y_{0}^{2})/y_{0} | |
1442 | // d = z_{0} | |
1443 | // e = dz/dx | |
1444 | // END_LATEX | |
1445 | // The error calculation for the free term is thus | |
1446 | // BEGIN_LATEX | |
1447 | // #sigma = 2 * #sqrt{#sigma^{2}_{y} + (tilt corr ...) + tg^{2}(h) * #sigma^{2}_{z}} * t | |
1448 | // END_LATEX | |
1449 | // | |
1450 | // From this simple model one can compute chi^2 estimates and a rough approximation of pt from the curvature according | |
1451 | // to the formula: | |
1452 | // BEGIN_LATEX | |
1453 | // C = 1/R = a/(1 + b^{2} + c*a) | |
1454 | // END_LATEX | |
1455 | // | |
1456 | // Authors | |
1457 | // M.Ivanov <M.Ivanov@gsi.de> | |
1458 | // A.Bercuci <A.Bercuci@gsi.de> | |
1459 | // M.Fasel <M.Fasel@gsi.de> | |
1460 | ||
41702fec | 1461 | TLinearFitter *fitter = GetTiltedRiemanFitter(); |
1462 | fitter->StoreData(kTRUE); | |
1463 | fitter->ClearPoints(); | |
1464 | AliTRDLeastSquare zfitter; | |
4d6aee34 | 1465 | AliTRDcluster *cl = NULL; |
3b57a3f7 | 1466 | |
4d6aee34 | 1467 | AliTRDseedV1 work[kNPlanes], *tracklet = NULL; |
3b57a3f7 | 1468 | if(!tracklets){ |
1469 | for(Int_t ipl = 0; ipl < kNPlanes; ipl++){ | |
1470 | if(!(tracklet = track->GetTracklet(ipl))) continue; | |
1471 | if(!tracklet->IsOK()) continue; | |
1472 | new(&work[ipl]) AliTRDseedV1(*tracklet); | |
1473 | } | |
1474 | tracklets = &work[0]; | |
1475 | } | |
1476 | ||
41702fec | 1477 | Double_t xref = CalculateReferenceX(tracklets); |
1478 | Double_t x, y, z, t, tilt, dx, w, we; | |
1479 | Double_t uvt[4]; | |
1480 | Int_t nPoints = 0; | |
1481 | // Containers for Least-square fitter | |
1482 | for(Int_t ipl = 0; ipl < kNPlanes; ipl++){ | |
1483 | if(!tracklets[ipl].IsOK()) continue; | |
8d2bec9e | 1484 | for(Int_t itb = 0; itb < AliTRDseedV1::kNclusters; itb++){ |
41702fec | 1485 | if(!(cl = tracklets[ipl].GetClusters(itb))) continue; |
1486 | if (!tracklets[ipl].IsUsable(itb)) continue; | |
1487 | x = cl->GetX(); | |
1488 | y = cl->GetY(); | |
1489 | z = cl->GetZ(); | |
1490 | tilt = tracklets[ipl].GetTilt(); | |
1491 | dx = x - xref; | |
1492 | // Transformation | |
1493 | t = 1./(x*x + y*y); | |
1494 | uvt[0] = 2. * x * t; | |
1495 | uvt[1] = t; | |
1496 | uvt[2] = 2. * tilt * t; | |
1497 | uvt[3] = 2. * tilt * dx * t; | |
1498 | w = 2. * (y + tilt*z) * t; | |
1499 | // error definition changes for the different calls | |
1500 | we = 2. * t; | |
f29f13a6 | 1501 | we *= sigError ? TMath::Sqrt(cl->GetSigmaY2()) : 0.2; |
41702fec | 1502 | fitter->AddPoint(uvt, w, we); |
1503 | zfitter.AddPoint(&x, z, static_cast<Double_t>(TMath::Sqrt(cl->GetSigmaZ2()))); | |
1504 | nPoints++; | |
1505 | } | |
1506 | } | |
aec26713 | 1507 | if(fitter->Eval()) return 1.E10; |
1508 | ||
41702fec | 1509 | Double_t z0 = fitter->GetParameter(3); |
1510 | Double_t dzdx = fitter->GetParameter(4); | |
3b57a3f7 | 1511 | |
1512 | ||
1513 | // Linear fitter - not possible to make boundaries | |
1514 | // Do not accept non possible z and dzdx combinations | |
1515 | Bool_t accept = kTRUE; | |
1516 | Double_t zref = 0.0; | |
1517 | for (Int_t iLayer = 0; iLayer < kNPlanes; iLayer++) { | |
1518 | if(!tracklets[iLayer].IsOK()) continue; | |
1519 | zref = z0 + dzdx * (tracklets[iLayer].GetX0() - xref); | |
e3cf3d02 | 1520 | if (TMath::Abs(tracklets[iLayer].GetZfit(0) - zref) > tracklets[iLayer].GetPadLength() * 0.5 + 1.0) |
3b57a3f7 | 1521 | accept = kFALSE; |
1522 | } | |
1523 | if (!accept) { | |
41702fec | 1524 | zfitter.Eval(); |
3b57a3f7 | 1525 | Double_t dzmf = zfitter.GetFunctionParameter(1); |
1526 | Double_t zmf = zfitter.GetFunctionValue(&xref); | |
1527 | fitter->FixParameter(3, zmf); | |
1528 | fitter->FixParameter(4, dzmf); | |
e17f4785 | 1529 | fitter->Eval(); |
3b57a3f7 | 1530 | fitter->ReleaseParameter(3); |
1531 | fitter->ReleaseParameter(4); | |
1532 | z0 = fitter->GetParameter(3); // = zmf ? | |
1533 | dzdx = fitter->GetParameter(4); // = dzmf ? | |
1534 | } | |
1535 | ||
1536 | // Calculate Curvature | |
1537 | Double_t a = fitter->GetParameter(0); | |
1538 | Double_t b = fitter->GetParameter(1); | |
1539 | Double_t c = fitter->GetParameter(2); | |
1540 | Double_t y0 = 1. / a; | |
1541 | Double_t x0 = -b * y0; | |
a015e406 | 1542 | Double_t tmp = y0*y0 + x0*x0 - c*y0; |
1543 | if(tmp<=0.) return 1.E10; | |
4d6aee34 | 1544 | Double_t radius = TMath::Sqrt(tmp); |
1545 | Double_t curvature = 1.0 + b*b - c*a; | |
1546 | if (curvature > 0.0) curvature = a / TMath::Sqrt(curvature); | |
3b57a3f7 | 1547 | |
1548 | // Calculate chi2 of the fit | |
1549 | Double_t chi2 = fitter->GetChisquare()/Double_t(nPoints); | |
1550 | ||
1551 | // Update the tracklets | |
1552 | if(!track){ | |
1553 | for(Int_t ip = 0; ip < kNPlanes; ip++) { | |
1554 | x = tracklets[ip].GetX0(); | |
4d6aee34 | 1555 | tmp = radius*radius-(x-x0)*(x-x0); |
a015e406 | 1556 | if(tmp <= 0.) continue; |
1557 | tmp = TMath::Sqrt(tmp); | |
3b57a3f7 | 1558 | |
1559 | // y: R^2 = (x - x0)^2 + (y - y0)^2 | |
1560 | // => y = y0 +/- Sqrt(R^2 - (x - x0)^2) | |
1561 | tracklets[ip].SetYref(0, y0 - (y0>0.?1.:-1)*tmp); | |
1562 | // => dy/dx = (x - x0)/Sqrt(R^2 - (x - x0)^2) | |
1563 | tracklets[ip].SetYref(1, (x - x0) / tmp); | |
1564 | tracklets[ip].SetZref(0, z0 + dzdx * (x - xref)); | |
1565 | tracklets[ip].SetZref(1, dzdx); | |
4d6aee34 | 1566 | tracklets[ip].SetC(curvature); |
3b57a3f7 | 1567 | tracklets[ip].SetChi2(chi2); |
1568 | } | |
1569 | } | |
3b57a3f7 | 1570 | //update track points array |
1571 | if(np && points){ | |
1572 | Float_t xyz[3]; | |
1573 | for(int ip=0; ip<np; ip++){ | |
1574 | points[ip].GetXYZ(xyz); | |
4d6aee34 | 1575 | xyz[1] = TMath::Abs(xyz[0] - x0) > radius ? 100. : y0 - (y0>0.?1.:-1.)*TMath::Sqrt((radius-(xyz[0]-x0))*(radius+(xyz[0]-x0))); |
3b57a3f7 | 1576 | xyz[2] = z0 + dzdx * (xyz[0] - xref); |
1577 | points[ip].SetXYZ(xyz); | |
1578 | } | |
1579 | } | |
1580 | ||
3b57a3f7 | 1581 | return chi2; |
1582 | } | |
1583 | ||
1584 | ||
1bf51039 | 1585 | //____________________________________________________________________ |
e17f4785 | 1586 | Double_t AliTRDtrackerV1::FitKalman(AliTRDtrackV1 *track, AliTRDseedV1 * const tracklets, Bool_t up, Int_t np, AliTrackPoint *points) |
1bf51039 | 1587 | { |
1588 | // Kalman filter implementation for the TRD. | |
1589 | // It returns the positions of the fit in the array "points" | |
1590 | // | |
1591 | // Author : A.Bercuci@gsi.de | |
1592 | ||
3cfaffa4 | 1593 | // printf("Start track @ x[%f]\n", track->GetX()); |
1bf51039 | 1594 | |
1595 | //prepare marker points along the track | |
1596 | Int_t ip = np ? 0 : 1; | |
1597 | while(ip<np){ | |
1598 | if((up?-1:1) * (track->GetX() - points[ip].GetX()) > 0.) break; | |
1599 | //printf("AliTRDtrackerV1::FitKalman() : Skip track marker x[%d] = %7.3f. Before track start ( %7.3f ).\n", ip, points[ip].GetX(), track->GetX()); | |
1600 | ip++; | |
1601 | } | |
1602 | //if(points) printf("First marker point @ x[%d] = %f\n", ip, points[ip].GetX()); | |
1603 | ||
1604 | ||
4d6aee34 | 1605 | AliTRDseedV1 tracklet, *ptrTracklet = NULL; |
1bf51039 | 1606 | |
1607 | //Loop through the TRD planes | |
1608 | for (Int_t jplane = 0; jplane < kNPlanes; jplane++) { | |
1609 | // GET TRACKLET OR BUILT IT | |
1610 | Int_t iplane = up ? jplane : kNPlanes - 1 - jplane; | |
1611 | if(tracklets){ | |
e17f4785 | 1612 | if(!(ptrTracklet = &tracklets[iplane])) continue; |
1bf51039 | 1613 | }else{ |
1614 | if(!(ptrTracklet = track->GetTracklet(iplane))){ | |
4d6aee34 | 1615 | /*AliTRDtrackerV1 *tracker = NULL; |
a2fbb6ec | 1616 | if(!(tracker = dynamic_cast<AliTRDtrackerV1*>( AliTRDrecoParam:Tracker()))) continue; |
1bf51039 | 1617 | ptrTracklet = new(&tracklet) AliTRDseedV1(iplane); |
1618 | if(!tracker->MakeTracklet(ptrTracklet, track)) */ | |
1619 | continue; | |
1620 | } | |
1621 | } | |
1622 | if(!ptrTracklet->IsOK()) continue; | |
1623 | ||
1624 | Double_t x = ptrTracklet->GetX0(); | |
1625 | ||
1626 | while(ip < np){ | |
1627 | //don't do anything if next marker is after next update point. | |
1628 | if((up?-1:1) * (points[ip].GetX() - x) - fgkMaxStep < 0) break; | |
1bf51039 | 1629 | if(((up?-1:1) * (points[ip].GetX() - track->GetX()) < 0) && !PropagateToX(*track, points[ip].GetX(), fgkMaxStep)) return -1.; |
1630 | ||
1631 | Double_t xyz[3]; // should also get the covariance | |
3cfaffa4 | 1632 | track->GetXYZ(xyz); |
1633 | track->Global2LocalPosition(xyz, track->GetAlpha()); | |
1634 | points[ip].SetXYZ(xyz[0], xyz[1], xyz[2]); | |
1bf51039 | 1635 | ip++; |
1636 | } | |
3cfaffa4 | 1637 | // printf("plane[%d] tracklet[%p] x[%f]\n", iplane, ptrTracklet, x); |
1bf51039 | 1638 | |
3cfaffa4 | 1639 | // Propagate closer to the next update point |
1bf51039 | 1640 | if(((up?-1:1) * (x - track->GetX()) + fgkMaxStep < 0) && !PropagateToX(*track, x + (up?-1:1)*fgkMaxStep, fgkMaxStep)) return -1.; |
1641 | ||
1642 | if(!AdjustSector(track)) return -1; | |
1643 | if(TMath::Abs(track->GetSnp()) > fgkMaxSnp) return -1; | |
1644 | ||
1645 | //load tracklet to the tracker and the track | |
1646 | /* Int_t index; | |
1647 | if((index = FindTracklet(ptrTracklet)) < 0){ | |
1648 | ptrTracklet = SetTracklet(&tracklet); | |
1649 | index = fTracklets->GetEntriesFast()-1; | |
1650 | } | |
1651 | track->SetTracklet(ptrTracklet, index);*/ | |
1652 | ||
1653 | ||
1654 | // register tracklet to track with tracklet creation !! | |
1655 | // PropagateBack : loaded tracklet to the tracker and update index | |
1656 | // RefitInward : update index | |
1657 | // MakeTrack : loaded tracklet to the tracker and update index | |
1658 | if(!tracklets) track->SetTracklet(ptrTracklet, -1); | |
1659 | ||
1660 | ||
1661 | //Calculate the mean material budget along the path inside the chamber | |
1662 | Double_t xyz0[3]; track->GetXYZ(xyz0); | |
1663 | Double_t alpha = track->GetAlpha(); | |
1664 | Double_t xyz1[3], y, z; | |
1665 | if(!track->GetProlongation(x, y, z)) return -1; | |
1666 | xyz1[0] = x * TMath::Cos(alpha) - y * TMath::Sin(alpha); | |
1667 | xyz1[1] = +x * TMath::Sin(alpha) + y * TMath::Cos(alpha); | |
1668 | xyz1[2] = z; | |
3cfaffa4 | 1669 | if((xyz0[0] - xyz1[9] < 1e-3) && (xyz0[0] - xyz1[9] < 1e-3)) continue; // check wheter we are at the same global x position |
1bf51039 | 1670 | Double_t param[7]; |
3cfaffa4 | 1671 | if(AliTracker::MeanMaterialBudget(xyz0, xyz1, param) <=0.) break; |
1bf51039 | 1672 | Double_t xrho = param[0]*param[4]; // density*length |
1673 | Double_t xx0 = param[1]; // radiation length | |
1674 | ||
1675 | //Propagate the track | |
1676 | track->PropagateTo(x, xx0, xrho); | |
1677 | if (!AdjustSector(track)) break; | |
1678 | ||
1679 | //Update track | |
b72f4eaf | 1680 | Double_t cov[3]; ptrTracklet->GetCovAt(x, cov); |
1681 | Double_t p[2] = { ptrTracklet->GetY(), ptrTracklet->GetZ()}; | |
1682 | Double_t chi2 = ((AliExternalTrackParam*)track)->GetPredictedChi2(p, cov); | |
1683 | if(chi2<1e+10) track->Update(p, cov, chi2); | |
1bf51039 | 1684 | if(!up) continue; |
1685 | ||
1686 | //Reset material budget if 2 consecutive gold | |
1687 | if(iplane>0 && track->GetTracklet(iplane-1) && ptrTracklet->GetN() + track->GetTracklet(iplane-1)->GetN() > 20) track->SetBudget(2, 0.); | |
1688 | } // end planes loop | |
1689 | ||
1690 | // extrapolation | |
1691 | while(ip < np){ | |
1692 | if(((up?-1:1) * (points[ip].GetX() - track->GetX()) < 0) && !PropagateToX(*track, points[ip].GetX(), fgkMaxStep)) return -1.; | |
1693 | ||
1694 | Double_t xyz[3]; // should also get the covariance | |
3cfaffa4 | 1695 | track->GetXYZ(xyz); |
1696 | track->Global2LocalPosition(xyz, track->GetAlpha()); | |
1697 | points[ip].SetXYZ(xyz[0], xyz[1], xyz[2]); | |
1bf51039 | 1698 | ip++; |
1699 | } | |
1700 | ||
1701 | return track->GetChi2(); | |
1702 | } | |
3b57a3f7 | 1703 | |
eb38ed55 | 1704 | //_________________________________________________________________________ |
bb56afff | 1705 | Float_t AliTRDtrackerV1::CalculateChi2Z(AliTRDseedV1 *tracklets, Double_t offset, Double_t slope, Double_t xref) |
eb38ed55 | 1706 | { |
41702fec | 1707 | // |
1708 | // Calculates the chi2-value of the track in z-Direction including tilting pad correction. | |
1709 | // A linear dependence on the x-value serves as a model. | |
1710 | // The parameters are related to the tilted Riemann fit. | |
1711 | // Parameters: - Array of tracklets (AliTRDseedV1) related to the track candidate | |
1712 | // - the offset for the reference x | |
1713 | // - the slope | |
1714 | // - the reference x position | |
1715 | // Output: - The Chi2 value of the track in z-Direction | |
1716 | // | |
1717 | Float_t chi2Z = 0, nLayers = 0; | |
053767a4 | 1718 | for (Int_t iLayer = 0; iLayer < AliTRDgeometry::kNlayer; iLayer++) { |
41702fec | 1719 | if(!tracklets[iLayer].IsOK()) continue; |
1720 | Double_t z = offset + slope * (tracklets[iLayer].GetX0() - xref); | |
e3cf3d02 | 1721 | chi2Z += TMath::Abs(tracklets[iLayer].GetZfit(0) - z); |
41702fec | 1722 | nLayers++; |
1723 | } | |
1724 | chi2Z /= TMath::Max((nLayers - 3.0),1.0); | |
1725 | return chi2Z; | |
eb38ed55 | 1726 | } |
1727 | ||
bccda319 | 1728 | //_____________________________________________________________________________ |
1729 | Int_t AliTRDtrackerV1::PropagateToX(AliTRDtrackV1 &t, Double_t xToGo, Double_t maxStep) | |
1730 | { | |
41702fec | 1731 | // |
1732 | // Starting from current X-position of track <t> this function | |
1733 | // extrapolates the track up to radial position <xToGo>. | |
1734 | // Returns 1 if track reaches the plane, and 0 otherwise | |
1735 | // | |
bccda319 | 1736 | |
41702fec | 1737 | const Double_t kEpsilon = 0.00001; |
bccda319 | 1738 | |
41702fec | 1739 | // Current track X-position |
1740 | Double_t xpos = t.GetX(); | |
bccda319 | 1741 | |
41702fec | 1742 | // Direction: inward or outward |
1743 | Double_t dir = (xpos < xToGo) ? 1.0 : -1.0; | |
bccda319 | 1744 | |
41702fec | 1745 | while (((xToGo - xpos) * dir) > kEpsilon) { |
bccda319 | 1746 | |
41702fec | 1747 | Double_t xyz0[3]; |
1748 | Double_t xyz1[3]; | |
1749 | Double_t param[7]; | |
1750 | Double_t x; | |
1751 | Double_t y; | |
1752 | Double_t z; | |
bccda319 | 1753 | |
41702fec | 1754 | // The next step size |
1755 | Double_t step = dir * TMath::Min(TMath::Abs(xToGo-xpos),maxStep); | |
bccda319 | 1756 | |
41702fec | 1757 | // Get the global position of the starting point |
1758 | t.GetXYZ(xyz0); | |
bccda319 | 1759 | |
41702fec | 1760 | // X-position after next step |
1761 | x = xpos + step; | |
bccda319 | 1762 | |
41702fec | 1763 | // Get local Y and Z at the X-position of the next step |
3352b455 | 1764 | if(t.GetProlongation(x,y,z)<0) return 0; // No prolongation possible |
bccda319 | 1765 | |
41702fec | 1766 | // The global position of the end point of this prolongation step |
1767 | xyz1[0] = x * TMath::Cos(t.GetAlpha()) - y * TMath::Sin(t.GetAlpha()); | |
1768 | xyz1[1] = +x * TMath::Sin(t.GetAlpha()) + y * TMath::Cos(t.GetAlpha()); | |
1769 | xyz1[2] = z; | |
bccda319 | 1770 | |
41702fec | 1771 | // Calculate the mean material budget between start and |
1772 | // end point of this prolongation step | |
83dea92e | 1773 | if(AliTracker::MeanMaterialBudget(xyz0, xyz1, param)<=0.) return 0; |
bccda319 | 1774 | |
41702fec | 1775 | // Propagate the track to the X-position after the next step |
9c87a076 | 1776 | if (!t.PropagateTo(x, param[1], param[0]*param[4])) return 0; |
bccda319 | 1777 | |
41702fec | 1778 | // Rotate the track if necessary |
1779 | AdjustSector(&t); | |
bccda319 | 1780 | |
41702fec | 1781 | // New track X-position |
1782 | xpos = t.GetX(); | |
bccda319 | 1783 | |
41702fec | 1784 | } |
bccda319 | 1785 | |
41702fec | 1786 | return 1; |
bccda319 | 1787 | |
1788 | } | |
1789 | ||
eb38ed55 | 1790 | |
1791 | //_____________________________________________________________________________ | |
1792 | Int_t AliTRDtrackerV1::ReadClusters(TClonesArray* &array, TTree *clusterTree) const | |
1793 | { | |
41702fec | 1794 | // |
1795 | // Reads AliTRDclusters from the file. | |
1796 | // The names of the cluster tree and branches | |
1797 | // should match the ones used in AliTRDclusterizer::WriteClusters() | |
1798 | // | |
1799 | ||
1800 | Int_t nsize = Int_t(clusterTree->GetTotBytes() / (sizeof(AliTRDcluster))); | |
1801 | TObjArray *clusterArray = new TObjArray(nsize+1000); | |
1802 | ||
1803 | TBranch *branch = clusterTree->GetBranch("TRDcluster"); | |
1804 | if (!branch) { | |
1805 | AliError("Can't get the branch !"); | |
1806 | return 1; | |
1807 | } | |
1808 | branch->SetAddress(&clusterArray); | |
1809 | ||
1810 | if(!fClusters){ | |
4d6aee34 | 1811 | Float_t nclusters = fkReconstructor->GetRecoParam()->GetNClusters(); |
1812 | if(fkReconstructor->IsHLT()) nclusters /= AliTRDgeometry::kNsector; | |
8ae98148 | 1813 | array = new TClonesArray("AliTRDcluster", Int_t(nclusters)); |
41702fec | 1814 | array->SetOwner(kTRUE); |
1815 | } | |
1816 | ||
1817 | // Loop through all entries in the tree | |
1818 | Int_t nEntries = (Int_t) clusterTree->GetEntries(); | |
1819 | Int_t nbytes = 0; | |
1820 | Int_t ncl = 0; | |
4d6aee34 | 1821 | AliTRDcluster *c = NULL; |
41702fec | 1822 | for (Int_t iEntry = 0; iEntry < nEntries; iEntry++) { |
1823 | // Import the tree | |
1824 | nbytes += clusterTree->GetEvent(iEntry); | |
1825 | ||
1826 | // Get the number of points in the detector | |
1827 | Int_t nCluster = clusterArray->GetEntriesFast(); | |
1828 | for (Int_t iCluster = 0; iCluster < nCluster; iCluster++) { | |
1829 | if(!(c = (AliTRDcluster *) clusterArray->UncheckedAt(iCluster))) continue; | |
41702fec | 1830 | new((*fClusters)[ncl++]) AliTRDcluster(*c); |
1831 | delete (clusterArray->RemoveAt(iCluster)); | |
1832 | } | |
1833 | ||
1834 | } | |
1835 | delete clusterArray; | |
1836 | ||
1837 | return 0; | |
eb38ed55 | 1838 | } |
1839 | ||
1840 | //_____________________________________________________________________________ | |
1841 | Int_t AliTRDtrackerV1::LoadClusters(TTree *cTree) | |
1842 | { | |
41702fec | 1843 | // |
66f6bfd9 | 1844 | // Fills clusters into TRD tracking sectors |
41702fec | 1845 | // |
41702fec | 1846 | |
4d6aee34 | 1847 | if(!fkReconstructor->IsWritingClusters()){ |
48f8adf3 | 1848 | fClusters = AliTRDReconstructor::GetClusters(); |
1849 | } else { | |
66f6bfd9 | 1850 | if (ReadClusters(fClusters, cTree)) { |
1851 | AliError("Problem with reading the clusters !"); | |
1852 | return 1; | |
1853 | } | |
1854 | } | |
1855 | SetClustersOwner(); | |
1856 | ||
48f8adf3 | 1857 | if(!fClusters || !fClusters->GetEntriesFast()){ |
66f6bfd9 | 1858 | AliInfo("No TRD clusters"); |
41702fec | 1859 | return 1; |
1860 | } | |
66f6bfd9 | 1861 | |
1862 | //Int_t nin = | |
1863 | BuildTrackingContainers(); | |
1864 | ||
1865 | //Int_t ncl = fClusters->GetEntriesFast(); | |
1866 | //AliInfo(Form("Clusters %d [%6.2f %% in the active volume]", ncl, 100.*float(nin)/ncl)); | |
1867 | ||
1868 | return 0; | |
1869 | } | |
1870 | ||
1871 | //_____________________________________________________________________________ | |
4d6aee34 | 1872 | Int_t AliTRDtrackerV1::LoadClusters(TClonesArray * const clusters) |
66f6bfd9 | 1873 | { |
1874 | // | |
1875 | // Fills clusters into TRD tracking sectors | |
1876 | // Function for use in the HLT | |
1877 | ||
1878 | if(!clusters || !clusters->GetEntriesFast()){ | |
1879 | AliInfo("No TRD clusters"); | |
41702fec | 1880 | return 1; |
1881 | } | |
1882 | ||
66f6bfd9 | 1883 | fClusters = clusters; |
1884 | SetClustersOwner(); | |
1885 | ||
1886 | //Int_t nin = | |
1887 | BuildTrackingContainers(); | |
1888 | ||
1889 | //Int_t ncl = fClusters->GetEntriesFast(); | |
1890 | //AliInfo(Form("Clusters %d [%6.2f %% in the active volume]", ncl, 100.*float(nin)/ncl)); | |
1891 | ||
1892 | return 0; | |
1893 | } | |
1894 | ||
1895 | ||
1896 | //____________________________________________________________________ | |
1897 | Int_t AliTRDtrackerV1::BuildTrackingContainers() | |
1898 | { | |
1899 | // Building tracking containers for clusters | |
1900 | ||
1901 | Int_t nin =0, icl = fClusters->GetEntriesFast(); | |
41702fec | 1902 | while (icl--) { |
1903 | AliTRDcluster *c = (AliTRDcluster *) fClusters->UncheckedAt(icl); | |
1904 | if(c->IsInChamber()) nin++; | |
1905 | Int_t detector = c->GetDetector(); | |
1906 | Int_t sector = fGeom->GetSector(detector); | |
053767a4 | 1907 | Int_t stack = fGeom->GetStack(detector); |
1908 | Int_t layer = fGeom->GetLayer(detector); | |
41702fec | 1909 | |
053767a4 | 1910 | fTrSec[sector].GetChamber(stack, layer, kTRUE)->InsertCluster(c, icl); |
41702fec | 1911 | } |
b0a48c4d | 1912 | |
1913 | const AliTRDCalDet *cal = AliTRDcalibDB::Instance()->GetT0Det(); | |
053767a4 | 1914 | for(int isector =0; isector<AliTRDgeometry::kNsector; isector++){ |
41702fec | 1915 | if(!fTrSec[isector].GetNChambers()) continue; |
4d6aee34 | 1916 | fTrSec[isector].Init(fkReconstructor, cal); |
41702fec | 1917 | } |
66f6bfd9 | 1918 | |
1919 | return nin; | |
eb38ed55 | 1920 | } |
1921 | ||
1922 | ||
66f6bfd9 | 1923 | |
0906e73e | 1924 | //____________________________________________________________________ |
172b6f82 | 1925 | void AliTRDtrackerV1::UnloadClusters() |
0906e73e | 1926 | { |
d4cf71ca | 1927 | // |
1928 | // Clears the arrays of clusters and tracks. Resets sectors and timebins | |
1929 | // If option "force" is also set the containers are also deleted. This is useful | |
1930 | // in case of HLT | |
1931 | ||
1932 | if(fTracks){ | |
1933 | fTracks->Delete(); | |
4d6aee34 | 1934 | if(HasRemoveContainers()){delete fTracks; fTracks = NULL;} |
d4cf71ca | 1935 | } |
1936 | if(fTracklets){ | |
1937 | fTracklets->Delete(); | |
4d6aee34 | 1938 | if(HasRemoveContainers()){delete fTracklets; fTracklets = NULL;} |
d4cf71ca | 1939 | } |
48f8adf3 | 1940 | if(fClusters){ |
1941 | if(IsClustersOwner()) fClusters->Delete(); | |
1942 | ||
1943 | // save clusters array in the reconstructor for further use. | |
4d6aee34 | 1944 | if(!fkReconstructor->IsWritingClusters()){ |
48f8adf3 | 1945 | AliTRDReconstructor::SetClusters(fClusters); |
1946 | SetClustersOwner(kFALSE); | |
4d6aee34 | 1947 | } else AliTRDReconstructor::SetClusters(NULL); |
48f8adf3 | 1948 | } |
0906e73e | 1949 | |
053767a4 | 1950 | for (int i = 0; i < AliTRDgeometry::kNsector; i++) fTrSec[i].Clear(); |
0906e73e | 1951 | |
41702fec | 1952 | // Increment the Event Number |
1953 | AliTRDtrackerDebug::SetEventNumber(AliTRDtrackerDebug::GetEventNumber() + 1); | |
eb38ed55 | 1954 | } |
0906e73e | 1955 | |
fac58f00 | 1956 | // //____________________________________________________________________ |
1957 | // void AliTRDtrackerV1::UseClusters(const AliKalmanTrack *t, Int_t) const | |
1958 | // { | |
1959 | // const AliTRDtrackV1 *track = dynamic_cast<const AliTRDtrackV1*>(t); | |
1960 | // if(!track) return; | |
1961 | // | |
4d6aee34 | 1962 | // AliTRDseedV1 *tracklet = NULL; |
fac58f00 | 1963 | // for(Int_t ily=AliTRDgeometry::kNlayer; ily--;){ |
1964 | // if(!(tracklet = track->GetTracklet(ily))) continue; | |
4d6aee34 | 1965 | // AliTRDcluster *c = NULL; |
8d2bec9e | 1966 | // for(Int_t ic=AliTRDseed::kNclusters; ic--;){ |
fac58f00 | 1967 | // if(!(c=tracklet->GetClusters(ic))) continue; |
1968 | // c->Use(); | |
1969 | // } | |
1970 | // } | |
1971 | // } | |
1972 | // | |
b1957d3c | 1973 | |
eb38ed55 | 1974 | //_____________________________________________________________________________ |
4d6aee34 | 1975 | Bool_t AliTRDtrackerV1::AdjustSector(AliTRDtrackV1 *const track) |
eb38ed55 | 1976 | { |
41702fec | 1977 | // |
1978 | // Rotates the track when necessary | |
1979 | // | |
1980 | ||
1981 | Double_t alpha = AliTRDgeometry::GetAlpha(); | |
1982 | Double_t y = track->GetY(); | |
1983 | Double_t ymax = track->GetX()*TMath::Tan(0.5*alpha); | |
3cfaffa4 | 1984 | |
41702fec | 1985 | if (y > ymax) { |
1986 | if (!track->Rotate( alpha)) { | |
1987 | return kFALSE; | |
1988 | } | |
1989 | } | |
1990 | else if (y < -ymax) { | |
1991 | if (!track->Rotate(-alpha)) { | |
1992 | return kFALSE; | |
1993 | } | |
1994 | } | |
1995 | ||
1996 | return kTRUE; | |
0906e73e | 1997 | |
1998 | } | |
1999 | ||
eb38ed55 | 2000 | |
0906e73e | 2001 | //____________________________________________________________________ |
4d6aee34 | 2002 | AliTRDseedV1* AliTRDtrackerV1::GetTracklet(AliTRDtrackV1 *const track, Int_t p, Int_t &idx) |
0906e73e | 2003 | { |
41702fec | 2004 | // Find tracklet for TRD track <track> |
2005 | // Parameters | |
2006 | // - track | |
2007 | // - sector | |
2008 | // - plane | |
2009 | // - index | |
2010 | // Output | |
2011 | // tracklet | |
2012 | // index | |
2013 | // Detailed description | |
2014 | // | |
2015 | idx = track->GetTrackletIndex(p); | |
4d6aee34 | 2016 | AliTRDseedV1 *tracklet = (idx==0xffff) ? NULL : (AliTRDseedV1*)fTracklets->UncheckedAt(idx); |
41702fec | 2017 | |
2018 | return tracklet; | |
0906e73e | 2019 | } |
2020 | ||
2021 | //____________________________________________________________________ | |
4d6aee34 | 2022 | AliTRDseedV1* AliTRDtrackerV1::SetTracklet(const AliTRDseedV1 * const tracklet) |
0906e73e | 2023 | { |
41702fec | 2024 | // Add this tracklet to the list of tracklets stored in the tracker |
2025 | // | |
2026 | // Parameters | |
2027 | // - tracklet : pointer to the tracklet to be added to the list | |
2028 | // | |
2029 | // Output | |
2030 | // - the index of the new tracklet in the tracker tracklets list | |
2031 | // | |
2032 | // Detailed description | |
2033 | // Build the tracklets list if it is not yet created (late initialization) | |
2034 | // and adds the new tracklet to the list. | |
2035 | // | |
2036 | if(!fTracklets){ | |
053767a4 | 2037 | fTracklets = new TClonesArray("AliTRDseedV1", AliTRDgeometry::Nsector()*kMaxTracksStack); |
41702fec | 2038 | fTracklets->SetOwner(kTRUE); |
2039 | } | |
2040 | Int_t nentries = fTracklets->GetEntriesFast(); | |
2041 | return new ((*fTracklets)[nentries]) AliTRDseedV1(*tracklet); | |
972ef65e | 2042 | } |
2043 | ||
828c6f80 | 2044 | //____________________________________________________________________ |
2045 | void AliTRDtrackerV1::CookNTimeBins() | |
2046 | { | |
2047 | // Initialize number of time bins | |
2048 | ||
2049 | if(fgNTimeBins){ | |
2050 | // first look if set by hand | |
2051 | AliDebug(2, Form("NTimeBins [%d] (set by user)", fgNTimeBins)); | |
2052 | } else if(fkReconstructor && fkReconstructor->HasDigitsParam()) { | |
2053 | // second look into digits param to avoid DB query | |
2054 | fgNTimeBins = fkReconstructor->GetDigitsParam()->GetNTimeBins(); | |
2055 | AliDebug(2, Form("NTimeBins [%d] (set from digits param)", fgNTimeBins)); | |
2056 | } else { // third query DB | |
2057 | AliTRDcalibDB *trd(NULL); | |
2058 | if((trd = AliTRDcalibDB::Instance())) { | |
2059 | if((fgNTimeBins = trd->GetNumberOfTimeBinsDCS()) <= 0){ | |
2060 | AliError("Corrupted DCS Object in OCDB"); | |
2061 | fgNTimeBins = 24; | |
2062 | AliDebug(2, Form("NTimeBins [%d] (set to default)", fgNTimeBins)); | |
2063 | } else AliDebug(2, Form("NTimeBins [%d] (set from DB)", fgNTimeBins)); | |
2064 | } else AliFatal("Could not get DB."); | |
2065 | } | |
2066 | if(fgNTimeBins<=0){ | |
2067 | AliFatal("Could not get number of time bins."); | |
2068 | } | |
2069 | } | |
2070 | ||
d20df6fc | 2071 | //____________________________________________________________________ |
4d6aee34 | 2072 | AliTRDtrackV1* AliTRDtrackerV1::SetTrack(const AliTRDtrackV1 * const track) |
d20df6fc | 2073 | { |
2074 | // Add this track to the list of tracks stored in the tracker | |
2075 | // | |
2076 | // Parameters | |
2077 | // - track : pointer to the track to be added to the list | |
2078 | // | |
2079 | // Output | |
2080 | // - the pointer added | |
2081 | // | |
2082 | // Detailed description | |
2083 | // Build the tracks list if it is not yet created (late initialization) | |
2084 | // and adds the new track to the list. | |
2085 | // | |
2086 | if(!fTracks){ | |
053767a4 | 2087 | fTracks = new TClonesArray("AliTRDtrackV1", AliTRDgeometry::Nsector()*kMaxTracksStack); |
d20df6fc | 2088 | fTracks->SetOwner(kTRUE); |
2089 | } | |
2090 | Int_t nentries = fTracks->GetEntriesFast(); | |
2091 | return new ((*fTracks)[nentries]) AliTRDtrackV1(*track); | |
2092 | } | |
2093 | ||
2094 | ||
0906e73e | 2095 | |
e4f2f73d | 2096 | //____________________________________________________________________ |
eb38ed55 | 2097 | Int_t AliTRDtrackerV1::Clusters2TracksSM(Int_t sector, AliESDEvent *esd) |
e4f2f73d | 2098 | { |
41702fec | 2099 | // |
2100 | // Steer tracking for one SM. | |
2101 | // | |
2102 | // Parameters : | |
2103 | // sector : Array of (SM) propagation layers containing clusters | |
2104 | // esd : The current ESD event. On output it contains the also | |
2105 | // the ESD (TRD) tracks found in this SM. | |
2106 | // | |
2107 | // Output : | |
2108 | // Number of tracks found in this TRD supermodule. | |
2109 | // | |
2110 | // Detailed description | |
2111 | // | |
2112 | // 1. Unpack AliTRDpropagationLayers objects for each stack. | |
2113 | // 2. Launch stack tracking. | |
2114 | // See AliTRDtrackerV1::Clusters2TracksStack() for details. | |
2115 | // 3. Pack results in the ESD event. | |
2116 | // | |
2117 | ||
2118 | // allocate space for esd tracks in this SM | |
2119 | TClonesArray esdTrackList("AliESDtrack", 2*kMaxTracksStack); | |
2120 | esdTrackList.SetOwner(); | |
2121 | ||
2122 | Int_t nTracks = 0; | |
2123 | Int_t nChambers = 0; | |
4d6aee34 | 2124 | AliTRDtrackingChamber **stack = NULL, *chamber = NULL; |
053767a4 | 2125 | for(int istack = 0; istack<AliTRDgeometry::kNstack; istack++){ |
41702fec | 2126 | if(!(stack = fTrSec[sector].GetStack(istack))) continue; |
2127 | nChambers = 0; | |
053767a4 | 2128 | for(int ilayer=0; ilayer<AliTRDgeometry::kNlayer; ilayer++){ |
2129 | if(!(chamber = stack[ilayer])) continue; | |
4d6aee34 | 2130 | if(chamber->GetNClusters() < fgNTimeBins * fkReconstructor->GetRecoParam() ->GetFindableClusters()) continue; |
41702fec | 2131 | nChambers++; |
053767a4 | 2132 | //AliInfo(Form("sector %d stack %d layer %d clusters %d", sector, istack, ilayer, chamber->GetNClusters())); |
41702fec | 2133 | } |
2134 | if(nChambers < 4) continue; | |
2135 | //AliInfo(Form("Doing stack %d", istack)); | |
2136 | nTracks += Clusters2TracksStack(stack, &esdTrackList); | |
2137 | } | |
2138 | //AliInfo(Form("Found %d tracks in SM %d [%d]\n", nTracks, sector, esd->GetNumberOfTracks())); | |
2139 | ||
2140 | for(int itrack=0; itrack<nTracks; itrack++) | |
2141 | esd->AddTrack((AliESDtrack*)esdTrackList[itrack]); | |
2142 | ||
2143 | // Reset Track and Candidate Number | |
2144 | AliTRDtrackerDebug::SetCandidateNumber(0); | |
2145 | AliTRDtrackerDebug::SetTrackNumber(0); | |
2146 | return nTracks; | |
e4f2f73d | 2147 | } |
2148 | ||
2149 | //____________________________________________________________________ | |
4d6aee34 | 2150 | Int_t AliTRDtrackerV1::Clusters2TracksStack(AliTRDtrackingChamber **stack, TClonesArray * const esdTrackList) |
e4f2f73d | 2151 | { |
41702fec | 2152 | // |
2153 | // Make tracks in one TRD stack. | |
2154 | // | |
2155 | // Parameters : | |
2156 | // layer : Array of stack propagation layers containing clusters | |
2157 | // esdTrackList : Array of ESD tracks found by the stand alone tracker. | |
2158 | // On exit the tracks found in this stack are appended. | |
2159 | // | |
2160 | // Output : | |
2161 | // Number of tracks found in this stack. | |
2162 | // | |
2163 | // Detailed description | |
2164 | // | |
2165 | // 1. Find the 3 most useful seeding chambers. See BuildSeedingConfigs() for details. | |
2166 | // 2. Steer AliTRDtrackerV1::MakeSeeds() for 3 seeding layer configurations. | |
2167 | // See AliTRDtrackerV1::MakeSeeds() for more details. | |
2168 | // 3. Arrange track candidates in decreasing order of their quality | |
2169 | // 4. Classify tracks in 5 categories according to: | |
2170 | // a) number of layers crossed | |
2171 | // b) track quality | |
2172 | // 5. Sign clusters by tracks in decreasing order of track quality | |
2173 | // 6. Build AliTRDtrack out of seeding tracklets | |
2174 | // 7. Cook MC label | |
2175 | // 8. Build ESD track and register it to the output list | |
2176 | // | |
2177 | ||
b0a48c4d | 2178 | const AliTRDCalDet *cal = AliTRDcalibDB::Instance()->GetT0Det(); |
4d6aee34 | 2179 | AliTRDtrackingChamber *chamber = NULL; |
2180 | AliTRDtrackingChamber **ci = NULL; | |
41702fec | 2181 | AliTRDseedV1 sseed[kMaxTracksStack*6]; // to be initialized |
2182 | Int_t pars[4]; // MakeSeeds parameters | |
2183 | ||
2184 | //Double_t alpha = AliTRDgeometry::GetAlpha(); | |
2185 | //Double_t shift = .5 * alpha; | |
2186 | Int_t configs[kNConfigs]; | |
2187 | ||
fac58f00 | 2188 | // Purge used clusters from the containers |
2189 | ci = &stack[0]; | |
2190 | for(Int_t ic = kNPlanes; ic--; ci++){ | |
2191 | if(!(*ci)) continue; | |
2192 | (*ci)->Update(); | |
2193 | } | |
2194 | ||
41702fec | 2195 | // Build initial seeding configurations |
2196 | Double_t quality = BuildSeedingConfigs(stack, configs); | |
a2fbb6ec | 2197 | if(fkReconstructor->GetRecoParam()->GetStreamLevel(AliTRDrecoParam::kTracker) > 10){ |
41702fec | 2198 | AliInfo(Form("Plane config %d %d %d Quality %f" |
2199 | , configs[0], configs[1], configs[2], quality)); | |
2200 | } | |
d931f2aa | 2201 | |
41702fec | 2202 | |
2203 | // Initialize contors | |
2204 | Int_t ntracks, // number of TRD track candidates | |
2205 | ntracks1, // number of registered TRD tracks/iter | |
2206 | ntracks2 = 0; // number of all registered TRD tracks in stack | |
2207 | fSieveSeeding = 0; | |
d931f2aa | 2208 | |
2209 | // Get stack index | |
fac58f00 | 2210 | Int_t ic = 0; ci = &stack[0]; |
2211 | while(ic<kNPlanes && !(*ci)){ic++; ci++;} | |
2212 | if(!(*ci)) return ntracks2; | |
2213 | Int_t istack = fGeom->GetStack((*ci)->GetDetector()); | |
d931f2aa | 2214 | |
41702fec | 2215 | do{ |
2216 | // Loop over seeding configurations | |
2217 | ntracks = 0; ntracks1 = 0; | |
2218 | for (Int_t iconf = 0; iconf<3; iconf++) { | |
2219 | pars[0] = configs[iconf]; | |
2220 | pars[1] = ntracks; | |
d931f2aa | 2221 | pars[2] = istack; |
41702fec | 2222 | ntracks = MakeSeeds(stack, &sseed[6*ntracks], pars); |
6e39bde4 | 2223 | //AliInfo(Form("Number of Tracks after iteration step %d: %d\n", iconf, ntracks)); |
41702fec | 2224 | if(ntracks == kMaxTracksStack) break; |
2225 | } | |
980d5a2a | 2226 | AliDebug(2, Form("Candidate TRD tracks %d in iteration %d.", ntracks, fSieveSeeding)); |
41702fec | 2227 | |
2228 | if(!ntracks) break; | |
2229 | ||
2230 | // Sort the seeds according to their quality | |
2231 | Int_t sort[kMaxTracksStack]; | |
2232 | TMath::Sort(ntracks, fTrackQuality, sort, kTRUE); | |
2233 | ||
2234 | // Initialize number of tracks so far and logic switches | |
2235 | Int_t ntracks0 = esdTrackList->GetEntriesFast(); | |
2236 | Bool_t signedTrack[kMaxTracksStack]; | |
2237 | Bool_t fakeTrack[kMaxTracksStack]; | |
2238 | for (Int_t i=0; i<ntracks; i++){ | |
2239 | signedTrack[i] = kFALSE; | |
2240 | fakeTrack[i] = kFALSE; | |
2241 | } | |
2242 | //AliInfo("Selecting track candidates ..."); | |
2243 | ||
2244 | // Sieve clusters in decreasing order of track quality | |
2245 | Double_t trackParams[7]; | |
4d6aee34 | 2246 | // AliTRDseedV1 *lseed = NULL; |
41702fec | 2247 | Int_t jSieve = 0, candidates; |
2248 | do{ | |
2249 | //AliInfo(Form("\t\tITER = %i ", jSieve)); | |
2250 | ||
2251 | // Check track candidates | |
2252 | candidates = 0; | |
2253 | for (Int_t itrack = 0; itrack < ntracks; itrack++) { | |
804bb02e | 2254 | Int_t trackIndex = sort[itrack]; |
2255 | if (signedTrack[trackIndex] || fakeTrack[trackIndex]) continue; | |
41702fec | 2256 | |
2257 | ||
804bb02e | 2258 | // Calculate track parameters from tracklets seeds |
804bb02e | 2259 | Int_t ncl = 0; |
2260 | Int_t nused = 0; | |
2261 | Int_t nlayers = 0; | |
2262 | Int_t findable = 0; | |
2263 | for (Int_t jLayer = 0; jLayer < kNPlanes; jLayer++) { | |
2264 | Int_t jseed = kNPlanes*trackIndex+jLayer; | |
2265 | if(!sseed[jseed].IsOK()) continue; | |
f29f13a6 | 2266 | if (TMath::Abs(sseed[jseed].GetYref(0) / sseed[jseed].GetX0()) < 0.158) findable++; |
eede7907 | 2267 | // TODO here we get a sig fault which should never happen ! |
804bb02e | 2268 | sseed[jseed].UpdateUsed(); |
2269 | ncl += sseed[jseed].GetN2(); | |
2270 | nused += sseed[jseed].GetNUsed(); | |
2271 | nlayers++; | |
804bb02e | 2272 | } |
2273 | ||
f29f13a6 | 2274 | // Filter duplicated tracks |
2275 | if (nused > 30){ | |
2276 | //printf("Skip %d nused %d\n", trackIndex, nused); | |
2277 | fakeTrack[trackIndex] = kTRUE; | |
2278 | continue; | |
2279 | } | |
2280 | if (Float_t(nused)/ncl >= .25){ | |
2281 | //printf("Skip %d nused/ncl >= .25\n", trackIndex); | |
2282 | fakeTrack[trackIndex] = kTRUE; | |
2283 | continue; | |
2284 | } | |
41702fec | 2285 | |
f29f13a6 | 2286 | // Classify tracks |
2287 | Bool_t skip = kFALSE; | |
2288 | switch(jSieve){ | |
2289 | case 0: | |
2290 | if(nlayers < 6) {skip = kTRUE; break;} | |
2291 | if(TMath::Log(1.E-9+fTrackQuality[trackIndex]) < -5.){skip = kTRUE; break;} | |
2292 | break; | |
2293 | ||
2294 | case 1: | |
2295 | if(nlayers < findable){skip = kTRUE; break;} | |
2296 | if(TMath::Log(1.E-9+fTrackQuality[trackIndex]) < -4.){skip = kTRUE; break;} | |
2297 | break; | |
2298 | ||
2299 | case 2: | |
2300 | if ((nlayers == findable) || (nlayers == 6)) { skip = kTRUE; break;} | |
2301 | if (TMath::Log(1.E-9+fTrackQuality[trackIndex]) < -6.0){skip = kTRUE; break;} | |
2302 | break; | |
2303 | ||
2304 | case 3: | |
2305 | if (TMath::Log(1.E-9+fTrackQuality[trackIndex]) < -5.){skip = kTRUE; break;} | |
2306 | break; | |
2307 | ||
2308 | case 4: | |
2309 | if (nlayers == 3){skip = kTRUE; break;} | |
2310 | //if (TMath::Log(1.E-9+fTrackQuality[trackIndex]) - nused/(nlayers-3.0) < -15.0){skip = kTRUE; break;} | |
2311 | break; | |
2312 | } | |
2313 | if(skip){ | |
2314 | candidates++; | |
2315 | //printf("REJECTED : %d [%d] nlayers %d trackQuality = %e nused %d\n", itrack, trackIndex, nlayers, fTrackQuality[trackIndex], nused); | |
2316 | continue; | |
2317 | } | |
2318 | signedTrack[trackIndex] = kTRUE; | |
2319 | ||
2320 | // Build track parameters | |
2321 | AliTRDseedV1 *lseed =&sseed[trackIndex*6]; | |
2322 | /* Int_t idx = 0; | |
2323 | while(idx<3 && !lseed->IsOK()) { | |
2324 | idx++; | |
2325 | lseed++; | |
2326 | }*/ | |
2327 | Double_t x = lseed->GetX0();// - 3.5; | |
2328 | trackParams[0] = x; //NEW AB | |
2329 | trackParams[1] = lseed->GetYref(0); // lseed->GetYat(x); | |
2330 | trackParams[2] = lseed->GetZref(0); // lseed->GetZat(x); | |
2331 | trackParams[3] = TMath::Sin(TMath::ATan(lseed->GetYref(1))); | |
2332 | trackParams[4] = lseed->GetZref(1) / TMath::Sqrt(1. + lseed->GetYref(1) * lseed->GetYref(1)); | |
2333 | trackParams[5] = lseed->GetC(); | |
2334 | Int_t ich = 0; while(!(chamber = stack[ich])) ich++; | |
2335 | trackParams[6] = fGeom->GetSector(chamber->GetDetector());/* *alpha+shift; // Supermodule*/ | |
2336 | ||
a2fbb6ec | 2337 | if(fkReconstructor->GetRecoParam()->GetStreamLevel(AliTRDrecoParam::kTracker) > 1 && fkReconstructor->IsDebugStreaming()){ |
eb2b4f91 | 2338 | //AliInfo(Form("Track %d [%d] nlayers %d trackQuality = %e nused %d, yref = %3.3f", itrack, trackIndex, nlayers, fTrackQuality[trackIndex], nused, trackParams[1])); |
f29f13a6 | 2339 | |
f29f13a6 | 2340 | AliTRDseedV1 *dseed[6]; |
b82b4de1 | 2341 | for(Int_t iseed = AliTRDgeometry::kNlayer; iseed--;) dseed[iseed] = new AliTRDseedV1(lseed[iseed]); |
f29f13a6 | 2342 | |
2343 | //Int_t eventNrInFile = esd->GetEventNumberInFile(); | |
f29f13a6 | 2344 | Int_t eventNumber = AliTRDtrackerDebug::GetEventNumber(); |
2345 | Int_t trackNumber = AliTRDtrackerDebug::GetTrackNumber(); | |
2346 | Int_t candidateNumber = AliTRDtrackerDebug::GetCandidateNumber(); | |
a2fbb6ec | 2347 | TTreeSRedirector &cstreamer = *fkReconstructor->GetDebugStream(AliTRDrecoParam::kTracker); |
f29f13a6 | 2348 | cstreamer << "Clusters2TracksStack" |
2349 | << "EventNumber=" << eventNumber | |
2350 | << "TrackNumber=" << trackNumber | |
2351 | << "CandidateNumber=" << candidateNumber | |
2352 | << "Iter=" << fSieveSeeding | |
2353 | << "Like=" << fTrackQuality[trackIndex] | |
2354 | << "S0.=" << dseed[0] | |
2355 | << "S1.=" << dseed[1] | |
2356 | << "S2.=" << dseed[2] | |
2357 | << "S3.=" << dseed[3] | |
2358 | << "S4.=" << dseed[4] | |
2359 | << "S5.=" << dseed[5] | |
2360 | << "p0=" << trackParams[0] | |
2361 | << "p1=" << trackParams[1] | |
2362 | << "p2=" << trackParams[2] | |
2363 | << "p3=" << trackParams[3] | |
2364 | << "p4=" << trackParams[4] | |
2365 | << "p5=" << trackParams[5] | |
2366 | << "p6=" << trackParams[6] | |
f29f13a6 | 2367 | << "Ncl=" << ncl |
2368 | << "NLayers=" << nlayers | |
2369 | << "Findable=" << findable | |
2370 | << "NUsed=" << nused | |
2371 | << "\n"; | |
2372 | } | |
d877f55f | 2373 | |
f29f13a6 | 2374 | AliTRDtrackV1 *track = MakeTrack(&sseed[trackIndex*kNPlanes], trackParams); |
2375 | if(!track){ | |
980d5a2a | 2376 | AliDebug(1, "Track building failed."); |
f29f13a6 | 2377 | continue; |
d877f55f | 2378 | } |
41702fec | 2379 | |
f29f13a6 | 2380 | //AliInfo("End of MakeTrack()"); |
2381 | AliESDtrack *esdTrack = new ((*esdTrackList)[ntracks0++]) AliESDtrack(); | |
2382 | esdTrack->UpdateTrackParams(track, AliESDtrack::kTRDout); | |
2383 | esdTrack->SetLabel(track->GetLabel()); | |
2384 | track->UpdateESDtrack(esdTrack); | |
2385 | // write ESD-friends if neccessary | |
a2fbb6ec | 2386 | if (fkReconstructor->GetRecoParam()->GetStreamLevel(AliTRDrecoParam::kTracker) > 0){ |
f29f13a6 | 2387 | AliTRDtrackV1 *calibTrack = new AliTRDtrackV1(*track); |
2388 | calibTrack->SetOwner(); | |
2389 | esdTrack->AddCalibObject(calibTrack); | |
2390 | } | |
2391 | ntracks1++; | |
2392 | AliTRDtrackerDebug::SetTrackNumber(AliTRDtrackerDebug::GetTrackNumber() + 1); | |
41702fec | 2393 | } |
2394 | ||
2395 | jSieve++; | |
2396 | } while(jSieve<5 && candidates); // end track candidates sieve | |
2397 | if(!ntracks1) break; | |
2398 | ||
2399 | // increment counters | |
2400 | ntracks2 += ntracks1; | |
4302c900 | 2401 | |
4d6aee34 | 2402 | if(fkReconstructor->IsHLT()) break; |
41702fec | 2403 | fSieveSeeding++; |
2404 | ||
2405 | // Rebuild plane configurations and indices taking only unused clusters into account | |
2406 | quality = BuildSeedingConfigs(stack, configs); | |
4d6aee34 | 2407 | if(quality < 1.E-7) break; //fkReconstructor->GetRecoParam() ->GetPlaneQualityThreshold()) break; |
41702fec | 2408 | |
2409 | for(Int_t ip = 0; ip < kNPlanes; ip++){ | |
2410 | if(!(chamber = stack[ip])) continue; | |
b0a48c4d | 2411 | chamber->Build(fGeom, cal);//Indices(fSieveSeeding); |
41702fec | 2412 | } |
2413 | ||
a2fbb6ec | 2414 | if(fkReconstructor->GetRecoParam()->GetStreamLevel(AliTRDrecoParam::kTracker) > 10){ |
41702fec | 2415 | AliInfo(Form("Sieve level %d Plane config %d %d %d Quality %f", fSieveSeeding, configs[0], configs[1], configs[2], quality)); |
2416 | } | |
2417 | } while(fSieveSeeding<10); // end stack clusters sieve | |
2418 | ||
2419 | ||
2420 | ||
2421 | //AliInfo(Form("Registered TRD tracks %d in stack %d.", ntracks2, pars[1])); | |
2422 | ||
2423 | return ntracks2; | |
e4f2f73d | 2424 | } |
2425 | ||
2426 | //___________________________________________________________________ | |
eb38ed55 | 2427 | Double_t AliTRDtrackerV1::BuildSeedingConfigs(AliTRDtrackingChamber **stack, Int_t *configs) |
e4f2f73d | 2428 | { |
41702fec | 2429 | // |
2430 | // Assign probabilities to chambers according to their | |
2431 | // capability of producing seeds. | |
2432 | // | |
2433 | // Parameters : | |
2434 | // | |
2435 | // layers : Array of stack propagation layers for all 6 chambers in one stack | |
2436 | // configs : On exit array of configuration indexes (see GetSeedingConfig() | |
2437 | // for details) in the decreasing order of their seeding probabilities. | |
2438 | // | |
2439 | // Output : | |
2440 | // | |
2441 | // Return top configuration quality | |
2442 | // | |
2443 | // Detailed description: | |
2444 | // | |
2445 | // To each chamber seeding configuration (see GetSeedingConfig() for | |
2446 | // the list of all configurations) one defines 2 quality factors: | |
2447 | // - an apriori topological quality (see GetSeedingConfig() for details) and | |
2448 | // - a data quality based on the uniformity of the distribution of | |
2449 | // clusters over the x range (time bins population). See CookChamberQA() for details. | |
2450 | // The overall chamber quality is given by the product of this 2 contributions. | |
2451 | // | |
2452 | ||
eb2b4f91 | 2453 | Double_t chamberQ[kNPlanes];memset(chamberQ, 0, kNPlanes*sizeof(Double_t)); |
4d6aee34 | 2454 | AliTRDtrackingChamber *chamber = NULL; |
41702fec | 2455 | for(int iplane=0; iplane<kNPlanes; iplane++){ |
2456 | if(!(chamber = stack[iplane])) continue; | |
2457 | chamberQ[iplane] = (chamber = stack[iplane]) ? chamber->GetQuality() : 0.; | |
2458 | } | |
2459 | ||
eb2b4f91 | 2460 | Double_t tconfig[kNConfigs];memset(tconfig, 0, kNConfigs*sizeof(Double_t)); |
2461 | Int_t planes[] = {0, 0, 0, 0}; | |
41702fec | 2462 | for(int iconf=0; iconf<kNConfigs; iconf++){ |
2463 | GetSeedingConfig(iconf, planes); | |
2464 | tconfig[iconf] = fgTopologicQA[iconf]; | |
2465 | for(int iplane=0; iplane<4; iplane++) tconfig[iconf] *= chamberQ[planes[iplane]]; | |
2466 | } | |
2467 | ||
2468 | TMath::Sort((Int_t)kNConfigs, tconfig, configs, kTRUE); | |
2469 | // AliInfo(Form("q[%d] = %f", configs[0], tconfig[configs[0]])); | |
2470 | // AliInfo(Form("q[%d] = %f", configs[1], tconfig[configs[1]])); | |
2471 | // AliInfo(Form("q[%d] = %f", configs[2], tconfig[configs[2]])); | |
2472 | ||
2473 | return tconfig[configs[0]]; | |
e4f2f73d | 2474 | } |
2475 | ||
2476 | //____________________________________________________________________ | |
e17f4785 | 2477 | Int_t AliTRDtrackerV1::MakeSeeds(AliTRDtrackingChamber **stack, AliTRDseedV1 * const sseed, const Int_t * const ipar) |
e4f2f73d | 2478 | { |
afa21247 | 2479 | // |
2a3191bb | 2480 | // Seed tracklets and build candidate TRD tracks. The procedure is used during barrel tracking to account for tracks which are |
2481 | // either missed by TPC prolongation or conversions inside the TRD volume. | |
2482 | // For stand alone tracking the procedure is used to estimate all tracks measured by TRD. | |
afa21247 | 2483 | // |
2484 | // Parameters : | |
2485 | // layers : Array of stack propagation layers containing clusters | |
2486 | // sseed : Array of empty tracklet seeds. On exit they are filled. | |
2487 | // ipar : Control parameters: | |
2488 | // ipar[0] -> seeding chambers configuration | |
2489 | // ipar[1] -> stack index | |
2490 | // ipar[2] -> number of track candidates found so far | |
2491 | // | |
2492 | // Output : | |
2493 | // Number of tracks candidates found. | |
2494 | // | |
2495 | // The following steps are performed: | |
2496 | // 1. Build seeding layers by collapsing all time bins from each of the four seeding chambers along the | |
2497 | // radial coordinate. See AliTRDtrackingChamber::GetSeedingLayer() for details. The chambers selection for seeding | |
2498 | // is described in AliTRDtrackerV1::Clusters2TracksStack(). | |
2499 | // 2. Using the seeding clusters from the seeding layer (step 1) build combinatorics using the following algorithm: | |
2500 | // - for each seeding cluster in the lower seeding layer find | |
2501 | // - all seeding clusters in the upper seeding layer inside a road defined by a given phi angle. The angle | |
2502 | // is calculated on the minimum pt of tracks from vertex accesible to the stand alone tracker. | |
2503 | // - for each pair of two extreme seeding clusters select middle upper cluster using roads defined externally by the | |
2504 | // reco params | |
2505 | // - select last seeding cluster as the nearest to the linear approximation of the track described by the first three | |
2506 | // seeding clusters. | |
2507 | // The implementation of road calculation and cluster selection can be found in the functions AliTRDchamberTimeBin::BuildCond() | |
2508 | // and AliTRDchamberTimeBin::GetClusters(). | |
2509 | // 3. Helix fit of the seeding clusters set. (see AliTRDtrackerFitter::FitRieman(AliTRDcluster**)). No tilt correction is | |
2510 | // performed at this level | |
2511 | // 4. Initialize seeding tracklets in the seeding chambers. | |
2512 | // 5. *Filter 0* Chi2 cut on the Y and Z directions. The threshold is set externally by the reco params. | |
2513 | // 6. Attach (true) clusters to seeding tracklets (see AliTRDseedV1::AttachClusters()) and fit tracklet (see | |
2514 | // AliTRDseedV1::Fit()). The number of used clusters used by current seeds should not exceed ... (25). | |
2515 | // 7. *Filter 1* Check if all 4 seeding tracklets are correctly constructed. | |
2516 | // 8. Helix fit of the clusters from the seeding tracklets with tilt correction. Refit tracklets using the new | |
2517 | // approximation of the track. | |
2518 | // 9. *Filter 2* Calculate likelihood of the track. (See AliTRDtrackerV1::CookLikelihood()). The following quantities are | |
2519 | // checked against the Riemann fit: | |
2520 | // - position resolution in y | |
2521 | // - angular resolution in the bending plane | |
2522 | // - likelihood of the number of clusters attached to the tracklet | |
2523 | // 10. Extrapolation of the helix fit to the other 2 chambers *non seeding* chambers: | |
2524 | // - Initialization of extrapolation tracklets with the fit parameters | |
2525 | // - Attach clusters to extrapolated tracklets | |
2526 | // - Helix fit of tracklets | |
2527 | // 11. Improve seeding tracklets quality by reassigning clusters based on the last parameters of the track | |
2528 | // See AliTRDtrackerV1::ImproveSeedQuality() for details. | |
2529 | // 12. Helix fit of all 6 seeding tracklets and chi2 calculation | |
2530 | // 13. Hyperplane fit and track quality calculation. See AliTRDtrackerFitter::FitHyperplane() for details. | |
2531 | // 14. Cooking labels for tracklets. Should be done only for MC | |
2532 | // 15. Register seeds. | |
2533 | // | |
2534 | // Authors: | |
2535 | // Marian Ivanov <M.Ivanov@gsi.de> | |
2536 | // Alexandru Bercuci <A.Bercuci@gsi.de> | |
2537 | // Markus Fasel <M.Fasel@gsi.de> | |
41702fec | 2538 | |
4d6aee34 | 2539 | AliTRDtrackingChamber *chamber = NULL; |
2540 | AliTRDcluster *c[kNSeedPlanes] = {NULL, NULL, NULL, NULL}; // initilize seeding clusters | |
e17f4785 | 2541 | AliTRDseedV1 *cseed = &sseed[0]; // initialize tracklets for first track |
41702fec | 2542 | Int_t ncl, mcl; // working variable for looping over clusters |
2543 | Int_t index[AliTRDchamberTimeBin::kMaxClustersLayer], jndex[AliTRDchamberTimeBin::kMaxClustersLayer]; | |
2544 | // chi2 storage | |
2545 | // chi2[0] = tracklet chi2 on the Z direction | |
2546 | // chi2[1] = tracklet chi2 on the R direction | |
2547 | Double_t chi2[4]; | |
2548 | ||
afa21247 | 2549 | // this should be data member of AliTRDtrack TODO |
41702fec | 2550 | Double_t seedQuality[kMaxTracksStack]; |
2551 | ||
2552 | // unpack control parameters | |
2553 | Int_t config = ipar[0]; | |
2554 | Int_t ntracks = ipar[1]; | |
d931f2aa | 2555 | Int_t istack = ipar[2]; |
41702fec | 2556 | Int_t planes[kNSeedPlanes]; GetSeedingConfig(config, planes); |
afa21247 | 2557 | Int_t planesExt[kNPlanes-kNSeedPlanes]; GetExtrapolationConfig(config, planesExt); |
be24510a | 2558 | |
2559 | ||
41702fec | 2560 | // Init chambers geometry |
41702fec | 2561 | Double_t hL[kNPlanes]; // Tilting angle |
2562 | Float_t padlength[kNPlanes]; // pad lenghts | |
dd8059a8 | 2563 | Float_t padwidth[kNPlanes]; // pad widths |
4d6aee34 | 2564 | AliTRDpadPlane *pp = NULL; |
41702fec | 2565 | for(int iplane=0; iplane<kNPlanes; iplane++){ |
2566 | pp = fGeom->GetPadPlane(iplane, istack); | |
bb79ccd5 | 2567 | hL[iplane] = TMath::Tan(TMath::DegToRad()*pp->GetTiltingAngle()); |
41702fec | 2568 | padlength[iplane] = pp->GetLengthIPad(); |
dd8059a8 | 2569 | padwidth[iplane] = pp->GetWidthIPad(); |
41702fec | 2570 | } |
2571 | ||
eb2b4f91 | 2572 | // Init anode wire position for chambers |
e165b64b | 2573 | Double_t x0[kNPlanes], // anode wire position |
eb2b4f91 | 2574 | driftLength = .5*AliTRDgeometry::AmThick() - AliTRDgeometry::DrThick(); // drift length |
4d6aee34 | 2575 | TGeoHMatrix *matrix = NULL; |
eb2b4f91 | 2576 | Double_t loc[] = {AliTRDgeometry::AnodePos(), 0., 0.}; |
2577 | Double_t glb[] = {0., 0., 0.}; | |
2578 | AliTRDtrackingChamber **cIter = &stack[0]; | |
a3743898 | 2579 | for(int iLayer=0; iLayer<kNPlanes; iLayer++,cIter++){ |
eb2b4f91 | 2580 | if(!(*cIter)) continue; |
e165b64b | 2581 | if(!(matrix = fGeom->GetClusterMatrix((*cIter)->GetDetector()))){ |
2582 | continue; | |
2583 | x0[iLayer] = fgkX0[iLayer]; | |
2584 | } | |
eb2b4f91 | 2585 | matrix->LocalToMaster(loc, glb); |
2586 | x0[iLayer] = glb[0]; | |
2587 | } | |
2588 | ||
980d5a2a | 2589 | AliDebug(2, Form("Making seeds Stack[%d] Config[%d] Tracks[%d]...", istack, config, ntracks)); |
41702fec | 2590 | |
d931f2aa | 2591 | // Build seeding layers |
d611c74f | 2592 | ResetSeedTB(); |
41702fec | 2593 | Int_t nlayers = 0; |
41702fec | 2594 | for(int isl=0; isl<kNSeedPlanes; isl++){ |
2595 | if(!(chamber = stack[planes[isl]])) continue; | |
4d6aee34 | 2596 | if(!chamber->GetSeedingLayer(fSeedTB[isl], fGeom, fkReconstructor)) continue; |
41702fec | 2597 | nlayers++; |
41702fec | 2598 | } |
eb2b4f91 | 2599 | if(nlayers < kNSeedPlanes) return ntracks; |
41702fec | 2600 | |
2601 | ||
2602 | // Start finding seeds | |
2603 | Double_t cond0[4], cond1[4], cond2[4]; | |
2604 | Int_t icl = 0; | |
d611c74f | 2605 | while((c[3] = (*fSeedTB[3])[icl++])){ |
41702fec | 2606 | if(!c[3]) continue; |
d611c74f | 2607 | fSeedTB[0]->BuildCond(c[3], cond0, 0); |
2608 | fSeedTB[0]->GetClusters(cond0, index, ncl); | |
41702fec | 2609 | //printf("Found c[3] candidates 0 %d\n", ncl); |
2610 | Int_t jcl = 0; | |
2611 | while(jcl<ncl) { | |
d611c74f | 2612 | c[0] = (*fSeedTB[0])[index[jcl++]]; |
41702fec | 2613 | if(!c[0]) continue; |
2614 | Double_t dx = c[3]->GetX() - c[0]->GetX(); | |
afa21247 | 2615 | Double_t dzdx = (c[3]->GetZ() - c[0]->GetZ())/dx; |
2616 | Double_t dydx = (c[3]->GetY() - c[0]->GetY())/dx; | |
2617 | fSeedTB[1]->BuildCond(c[0], cond1, 1, dzdx, dydx); | |
d611c74f | 2618 | fSeedTB[1]->GetClusters(cond1, jndex, mcl); |
41702fec | 2619 | //printf("Found c[0] candidates 1 %d\n", mcl); |
2620 | ||
2621 | Int_t kcl = 0; | |
2622 | while(kcl<mcl) { | |
d611c74f | 2623 | c[1] = (*fSeedTB[1])[jndex[kcl++]]; |
2624 | if(!c[1]) continue; | |
afa21247 | 2625 | fSeedTB[2]->BuildCond(c[1], cond2, 2, dzdx, dydx); |
d611c74f | 2626 | c[2] = fSeedTB[2]->GetNearestCluster(cond2); |
2627 | //printf("Found c[1] candidate 2 %p\n", c[2]); | |
2628 | if(!c[2]) continue; | |
980d5a2a | 2629 | |
2630 | AliDebug(3, Form("Seeding clusters\n 0[%6.3f %6.3f %6.3f]\n 1[%6.3f %6.3f %6.3f]\n 2[%6.3f %6.3f %6.3f]\n 3[%6.3f %6.3f %6.3f].", | |
2631 | c[0]->GetX(), c[0]->GetY(), c[0]->GetZ(), | |
2632 | c[1]->GetX(), c[1]->GetY(), c[1]->GetZ(), | |
2633 | c[2]->GetX(), c[2]->GetY(), c[2]->GetZ(), | |
2634 | c[3]->GetX(), c[3]->GetY(), c[3]->GetZ())); | |
d611c74f | 2635 | |
804bb02e | 2636 | for (Int_t il = 0; il < kNPlanes; il++) cseed[il].Reset(); |
41702fec | 2637 | |
d611c74f | 2638 | FitRieman(c, chi2); |
2639 | ||
d931f2aa | 2640 | AliTRDseedV1 *tseed = &cseed[0]; |
bb2db46c | 2641 | cIter = &stack[0]; |
2642 | for(int iLayer=0; iLayer<kNPlanes; iLayer++, tseed++, cIter++){ | |
2643 | Int_t det = (*cIter) ? (*cIter)->GetDetector() : -1; | |
eb2b4f91 | 2644 | tseed->SetDetector(det); |
43d6ad34 | 2645 | tseed->SetTilt(hL[iLayer]); |
2646 | tseed->SetPadLength(padlength[iLayer]); | |
dd8059a8 | 2647 | tseed->SetPadWidth(padwidth[iLayer]); |
4d6aee34 | 2648 | tseed->SetReconstructor(fkReconstructor); |
eb2b4f91 | 2649 | tseed->SetX0(det<0 ? fR[iLayer]+driftLength : x0[iLayer]); |
d611c74f | 2650 | tseed->Init(GetRiemanFitter()); |
f29f13a6 | 2651 | tseed->SetStandAlone(kTRUE); |
d611c74f | 2652 | } |
2653 | ||
2654 | Bool_t isFake = kFALSE; | |
a2fbb6ec | 2655 | if(fkReconstructor->GetRecoParam()->GetStreamLevel(AliTRDrecoParam::kTracker) >= 2 && fkReconstructor->IsDebugStreaming()){ |
d611c74f | 2656 | if (c[0]->GetLabel(0) != c[3]->GetLabel(0)) isFake = kTRUE; |
2657 | if (c[1]->GetLabel(0) != c[3]->GetLabel(0)) isFake = kTRUE; | |
2658 | if (c[2]->GetLabel(0) != c[3]->GetLabel(0)) isFake = kTRUE; | |
2659 | ||
2660 | Double_t xpos[4]; | |
2661 | for(Int_t l = 0; l < kNSeedPlanes; l++) xpos[l] = fSeedTB[l]->GetX(); | |
2662 | Float_t yref[4]; | |
2663 | for(int il=0; il<4; il++) yref[il] = cseed[planes[il]].GetYref(0); | |
2664 | Int_t ll = c[3]->GetLabel(0); | |
2665 | Int_t eventNumber = AliTRDtrackerDebug::GetEventNumber(); | |
2666 | Int_t candidateNumber = AliTRDtrackerDebug::GetCandidateNumber(); | |
2667 | AliRieman *rim = GetRiemanFitter(); | |
a2fbb6ec | 2668 | TTreeSRedirector &cs0 = *fkReconstructor->GetDebugStream(AliTRDrecoParam::kTracker); |
d611c74f | 2669 | cs0 << "MakeSeeds0" |
2670 | <<"EventNumber=" << eventNumber | |
2671 | <<"CandidateNumber=" << candidateNumber | |
2672 | <<"isFake=" << isFake | |
2673 | <<"config=" << config | |
2674 | <<"label=" << ll | |
2675 | <<"chi2z=" << chi2[0] | |
2676 | <<"chi2y=" << chi2[1] | |
2677 | <<"Y2exp=" << cond2[0] | |
2678 | <<"Z2exp=" << cond2[1] | |
2679 | <<"X0=" << xpos[0] //layer[sLayer]->GetX() | |
2680 | <<"X1=" << xpos[1] //layer[sLayer + 1]->GetX() | |
2681 | <<"X2=" << xpos[2] //layer[sLayer + 2]->GetX() | |
2682 | <<"X3=" << xpos[3] //layer[sLayer + 3]->GetX() | |
2683 | <<"yref0=" << yref[0] | |
2684 | <<"yref1=" << yref[1] | |
2685 | <<"yref2=" << yref[2] | |
2686 | <<"yref3=" << yref[3] | |
2687 | <<"c0.=" << c[0] | |
2688 | <<"c1.=" << c[1] | |
2689 | <<"c2.=" << c[2] | |
2690 | <<"c3.=" << c[3] | |
2691 | <<"Seed0.=" << &cseed[planes[0]] | |
2692 | <<"Seed1.=" << &cseed[planes[1]] | |
2693 | <<"Seed2.=" << &cseed[planes[2]] | |
2694 | <<"Seed3.=" << &cseed[planes[3]] | |
2695 | <<"RiemanFitter.=" << rim | |
2696 | <<"\n"; | |
2697 | } | |
4d6aee34 | 2698 | if(chi2[0] > fkReconstructor->GetRecoParam() ->GetChi2Z()/*7./(3. - sLayer)*//*iter*/){ |
980d5a2a | 2699 | AliDebug(3, Form("Filter on chi2Z [%f].", chi2[0])); |
d611c74f | 2700 | AliTRDtrackerDebug::SetCandidateNumber(AliTRDtrackerDebug::GetCandidateNumber() + 1); |
2701 | continue; | |
2702 | } | |
4d6aee34 | 2703 | if(chi2[1] > fkReconstructor->GetRecoParam() ->GetChi2Y()/*1./(3. - sLayer)*//*iter*/){ |
980d5a2a | 2704 | AliDebug(3, Form("Filter on chi2Y [%f].", chi2[1])); |
d611c74f | 2705 | AliTRDtrackerDebug::SetCandidateNumber(AliTRDtrackerDebug::GetCandidateNumber() + 1); |
2706 | continue; | |
2707 | } | |
2708 | //AliInfo("Passed chi2 filter."); | |
2709 | ||
2710 | // try attaching clusters to tracklets | |
6e39bde4 | 2711 | Int_t mlayers = 0; |
980d5a2a | 2712 | AliTRDcluster *cl = NULL; |
be24510a | 2713 | for(int iLayer=0; iLayer<kNSeedPlanes; iLayer++){ |
d611c74f | 2714 | Int_t jLayer = planes[iLayer]; |
980d5a2a | 2715 | Int_t nNotInChamber = 0; |
f29f13a6 | 2716 | if(!cseed[jLayer].AttachClusters(stack[jLayer], kTRUE)) continue; |
980d5a2a | 2717 | if(/*fkReconstructor->IsHLT()*/kFALSE){ |
2718 | cseed[jLayer].UpdateUsed(); | |
2719 | if(!cseed[jLayer].IsOK()) continue; | |
2720 | }else{ | |
2721 | cseed[jLayer].Fit(); | |
2722 | cseed[jLayer].UpdateUsed(); | |
2723 | cseed[jLayer].ResetClusterIter(); | |
2724 | while((cl = cseed[jLayer].NextCluster())){ | |
2725 | if(!cl->IsInChamber()) nNotInChamber++; | |
2726 | } | |
2727 | //printf("clusters[%d], used[%d], not in chamber[%d]\n", cseed[jLayer].GetN(), cseed[jLayer].GetNUsed(), nNotInChamber); | |
2728 | if(cseed[jLayer].GetN() - (cseed[jLayer].GetNUsed() + nNotInChamber) < 5) continue; // checking for Cluster which are not in chamber is a much stronger restriction on real data | |
2729 | } | |
d611c74f | 2730 | mlayers++; |
2731 | } | |
be24510a | 2732 | |
2733 | if(mlayers < kNSeedPlanes){ | |
980d5a2a | 2734 | AliDebug(2, Form("Found only %d tracklets out of %d. Skip.", mlayers, kNSeedPlanes)); |
be24510a | 2735 | AliTRDtrackerDebug::SetCandidateNumber(AliTRDtrackerDebug::GetCandidateNumber() + 1); |
2736 | continue; | |
2737 | } | |
2738 | ||
2739 | // temporary exit door for the HLT | |
4d6aee34 | 2740 | if(fkReconstructor->IsHLT()){ |
be24510a | 2741 | // attach clusters to extrapolation chambers |
2742 | for(int iLayer=0; iLayer<kNPlanes-kNSeedPlanes; iLayer++){ | |
2743 | Int_t jLayer = planesExt[iLayer]; | |
2744 | if(!(chamber = stack[jLayer])) continue; | |
980d5a2a | 2745 | if(!cseed[jLayer].AttachClusters(chamber, kTRUE)) continue; |
5f1ae1e7 | 2746 | cseed[jLayer].Fit(); |
be24510a | 2747 | } |
4302c900 | 2748 | fTrackQuality[ntracks] = 1.; // dummy value |
2749 | ntracks++; | |
218ba867 | 2750 | if(ntracks == kMaxTracksStack) return ntracks; |
4302c900 | 2751 | cseed += 6; |
2752 | continue; | |
2753 | } | |
2754 | ||
be24510a | 2755 | |
f29f13a6 | 2756 | // Update Seeds and calculate Likelihood |
d611c74f | 2757 | // fit tracklets and cook likelihood |
f29f13a6 | 2758 | FitTiltedRieman(&cseed[0], kTRUE); |
2759 | for(int iLayer=0; iLayer<kNSeedPlanes; iLayer++){ | |
2760 | Int_t jLayer = planes[iLayer]; | |
2761 | cseed[jLayer].Fit(kTRUE); | |
2762 | } | |
91834b8d | 2763 | Double_t like = CookLikelihood(&cseed[0], planes); // to be checked |
d611c74f | 2764 | |
4d6aee34 | 2765 | if (TMath::Log(1.E-9 + like) < fkReconstructor->GetRecoParam() ->GetTrackLikelihood()){ |
980d5a2a | 2766 | AliDebug(3, Form("Filter on likelihood %f[%e].", TMath::Log(1.E-9 + like), like)); |
d611c74f | 2767 | AliTRDtrackerDebug::SetCandidateNumber(AliTRDtrackerDebug::GetCandidateNumber() + 1); |
2768 | continue; | |
2769 | } | |
2770 | //AliInfo(Form("Passed likelihood %f[%e].", TMath::Log(1.E-9 + like), like)); | |
2771 | ||
2772 | // book preliminary results | |
2773 | seedQuality[ntracks] = like; | |
2774 | fSeedLayer[ntracks] = config;/*sLayer;*/ | |
2775 | ||
2776 | // attach clusters to the extrapolation seeds | |
980d5a2a | 2777 | Int_t elayers(0); |
be24510a | 2778 | for(int iLayer=0; iLayer<kNPlanes-kNSeedPlanes; iLayer++){ |
2779 | Int_t jLayer = planesExt[iLayer]; | |
d611c74f | 2780 | if(!(chamber = stack[jLayer])) continue; |
d611c74f | 2781 | |
2782 | // fit extrapolated seed | |
2783 | if ((jLayer == 0) && !(cseed[1].IsOK())) continue; | |
2784 | if ((jLayer == 5) && !(cseed[4].IsOK())) continue; | |
2785 | AliTRDseedV1 pseed = cseed[jLayer]; | |
f29f13a6 | 2786 | if(!pseed.AttachClusters(chamber, kTRUE)) continue; |
2787 | pseed.Fit(kTRUE); | |
d611c74f | 2788 | cseed[jLayer] = pseed; |
d611c74f | 2789 | FitTiltedRieman(cseed, kTRUE); |
f29f13a6 | 2790 | cseed[jLayer].Fit(kTRUE); |
980d5a2a | 2791 | elayers++; |
d611c74f | 2792 | } |
2793 | ||
2794 | // AliInfo("Extrapolation done."); | |
2795 | // Debug Stream containing all the 6 tracklets | |
a2fbb6ec | 2796 | if(fkReconstructor->GetRecoParam()->GetStreamLevel(AliTRDrecoParam::kTracker) >= 2 && fkReconstructor->IsDebugStreaming()){ |
2797 | TTreeSRedirector &cstreamer = *fkReconstructor->GetDebugStream(AliTRDrecoParam::kTracker); | |
d611c74f | 2798 | TLinearFitter *tiltedRieman = GetTiltedRiemanFitter(); |
2799 | Int_t eventNumber = AliTRDtrackerDebug::GetEventNumber(); | |
2800 | Int_t candidateNumber = AliTRDtrackerDebug::GetCandidateNumber(); | |
2801 | cstreamer << "MakeSeeds1" | |
2802 | << "EventNumber=" << eventNumber | |
2803 | << "CandidateNumber=" << candidateNumber | |
2804 | << "S0.=" << &cseed[0] | |
2805 | << "S1.=" << &cseed[1] | |
2806 | << "S2.=" << &cseed[2] | |
2807 | << "S3.=" << &cseed[3] | |
2808 | << "S4.=" << &cseed[4] | |
2809 | << "S5.=" << &cseed[5] | |
2810 | << "FitterT.=" << tiltedRieman | |
2811 | << "\n"; | |
2812 | } | |
2813 | ||
980d5a2a | 2814 | if(fkReconstructor->GetRecoParam()->HasImproveTracklets()){ |
2815 | AliTRDseedV1 bseed[AliTRDgeometry::kNlayer]; | |
2816 | for(Int_t jLayer=AliTRDgeometry::kNlayer; jLayer--;) bseed[jLayer] = cseed[jLayer]; | |
2817 | ||
2818 | if(ImproveSeedQuality(stack, cseed) < mlayers+elayers){ | |
2819 | AliTRDtrackerDebug::SetCandidateNumber(AliTRDtrackerDebug::GetCandidateNumber() + 1); | |
2820 | AliDebug(3, "Filter on improve seeds."); | |
2821 | } else { | |
2822 | // store results | |
2823 | for(Int_t jLayer=AliTRDgeometry::kNlayer; jLayer--;) cseed[jLayer] = bseed[jLayer]; | |
2824 | } | |
d611c74f | 2825 | } |
2826 | //AliInfo("Improve seed quality done."); | |
2827 | ||
2828 | // fit full track and cook likelihoods | |
2829 | // Double_t curv = FitRieman(&cseed[0], chi2); | |
2830 | // Double_t chi2ZF = chi2[0] / TMath::Max((mlayers - 3.), 1.); | |
2831 | // Double_t chi2RF = chi2[1] / TMath::Max((mlayers - 3.), 1.); | |
2832 | ||
2833 | // do the final track fitting (Once with vertex constraint and once without vertex constraint) | |
2834 | Double_t chi2Vals[3]; | |
6e39bde4 | 2835 | chi2Vals[0] = FitTiltedRieman(&cseed[0], kTRUE); |
a2fbb6ec | 2836 | if(fkReconstructor->GetRecoParam()->IsVertexConstrained()) |
d611c74f | 2837 | chi2Vals[1] = FitTiltedRiemanConstraint(&cseed[0], GetZ()); // Do Vertex Constrained fit if desired |
2838 | else | |
2839 | chi2Vals[1] = 1.; | |
2840 | chi2Vals[2] = GetChi2Z(&cseed[0]) / TMath::Max((mlayers - 3.), 1.); | |
2841 | // Chi2 definitions in testing stage | |
2842 | //chi2Vals[2] = GetChi2ZTest(&cseed[0]); | |
2843 | fTrackQuality[ntracks] = CalculateTrackLikelihood(&cseed[0], &chi2Vals[0]); | |
2844 | //AliInfo("Hyperplane fit done\n"); | |
fac58f00 | 2845 | |
a2fbb6ec | 2846 | if(fkReconstructor->GetRecoParam()->GetStreamLevel(AliTRDrecoParam::kTracker) >= 2 && fkReconstructor->IsDebugStreaming()){ |
2847 | TTreeSRedirector &cstreamer = *fkReconstructor->GetDebugStream(AliTRDrecoParam::kTracker); | |
d611c74f | 2848 | Int_t eventNumber = AliTRDtrackerDebug::GetEventNumber(); |
2849 | Int_t candidateNumber = AliTRDtrackerDebug::GetCandidateNumber(); | |
2850 | TLinearFitter *fitterTC = GetTiltedRiemanFitterConstraint(); | |
2851 | TLinearFitter *fitterT = GetTiltedRiemanFitter(); | |
91834b8d | 2852 | Int_t ncls = 0; |
2853 | for(Int_t iseed = 0; iseed < kNPlanes; iseed++){ | |
2854 | ncls += cseed[iseed].IsOK() ? cseed[iseed].GetN2() : 0; | |
2855 | } | |
d611c74f | 2856 | cstreamer << "MakeSeeds2" |
2857 | << "EventNumber=" << eventNumber | |
2858 | << "CandidateNumber=" << candidateNumber | |
2859 | << "Chi2TR=" << chi2Vals[0] | |
2860 | << "Chi2TC=" << chi2Vals[1] | |
2861 | << "Nlayers=" << mlayers | |
91834b8d | 2862 | << "NClusters=" << ncls |
d611c74f | 2863 | << "Like=" << like |
2864 | << "S0.=" << &cseed[0] | |
2865 | << "S1.=" << &cseed[1] | |
2866 | << "S2.=" << &cseed[2] | |
2867 | << "S3.=" << &cseed[3] | |
2868 | << "S4.=" << &cseed[4] | |
2869 | << "S5.=" << &cseed[5] | |
d611c74f | 2870 | << "FitterT.=" << fitterT |
2871 | << "FitterTC.=" << fitterTC | |
2872 | << "\n"; | |
2873 | } | |
2874 | ||
2875 | ntracks++; | |
2876 | AliTRDtrackerDebug::SetCandidateNumber(AliTRDtrackerDebug::GetCandidateNumber() + 1); | |
2877 | if(ntracks == kMaxTracksStack){ | |
2878 | AliWarning(Form("Number of seeds reached maximum allowed (%d) in stack.", kMaxTracksStack)); | |
2879 | return ntracks; | |
2880 | } | |
2881 | cseed += 6; | |
41702fec | 2882 | } |
2883 | } | |
2884 | } | |
41702fec | 2885 | |
2886 | return ntracks; | |
e4f2f73d | 2887 | } |
2888 | ||
2889 | //_____________________________________________________________________________ | |
e17f4785 | 2890 | AliTRDtrackV1* AliTRDtrackerV1::MakeTrack(AliTRDseedV1 * const seeds, Double_t *params) |
e4f2f73d | 2891 | { |
afa21247 | 2892 | // |
2893 | // Build a TRD track out of tracklet candidates | |
2894 | // | |
2895 | // Parameters : | |
2896 | // seeds : array of tracklets | |
2897 | // params : array of track parameters as they are estimated by stand alone tracker. 7 elements. | |
2898 | // [0] - radial position of the track at reference point | |
2899 | // [1] - y position of the fit at [0] | |
2900 | // [2] - z position of the fit at [0] | |
2901 | // [3] - snp of the first tracklet | |
2902 | // [4] - tgl of the first tracklet | |
2903 | // [5] - curvature of the Riemann fit - 1/pt | |
2904 | // [6] - sector rotation angle | |
2905 | // | |
2906 | // Output : | |
2907 | // The TRD track. | |
2908 | // | |
2909 | // Initialize the TRD track based on the parameters of the fit and a parametric covariance matrix | |
2910 | // (diagonal with constant variance terms TODO - correct parameterization) | |
2911 | // | |
2912 | // In case of HLT just register the tracklets in the tracker and return values of the Riemann fit. For the | |
2913 | // offline case perform a full Kalman filter on the already found tracklets (see AliTRDtrackerV1::FollowBackProlongation() | |
2914 | // for details). Do also MC label calculation and PID if propagation successfully. | |
41702fec | 2915 | |
afa21247 | 2916 | |
41702fec | 2917 | Double_t alpha = AliTRDgeometry::GetAlpha(); |
2918 | Double_t shift = AliTRDgeometry::GetAlpha()/2.0; | |
2919 | Double_t c[15]; | |
2920 | ||
afa21247 | 2921 | c[ 0] = 0.2; // s^2_y |
2922 | c[ 1] = 0.0; c[ 2] = 2.0; // s^2_z | |
2923 | c[ 3] = 0.0; c[ 4] = 0.0; c[ 5] = 0.02; // s^2_snp | |
2924 | c[ 6] = 0.0; c[ 7] = 0.0; c[ 8] = 0.0; c[ 9] = 0.1; // s^2_tgl | |
2925 | c[10] = 0.0; c[11] = 0.0; c[12] = 0.0; c[13] = 0.0; c[14] = params[5]*params[5]*0.01; // s^2_1/pt | |
41702fec | 2926 | |
d20df6fc | 2927 | AliTRDtrackV1 track(seeds, ¶ms[1], c, params[0], params[6]*alpha+shift); |
2928 | track.PropagateTo(params[0]-5.0); | |
4d6aee34 | 2929 | AliTRDseedV1 *ptrTracklet = NULL; |
9887cc9f | 2930 | |
2931 | // skip Kalman filter for HLT | |
5f1ae1e7 | 2932 | if(/*fkReconstructor->IsHLT()*/kFALSE){ |
9887cc9f | 2933 | for (Int_t jLayer = 0; jLayer < AliTRDgeometry::kNlayer; jLayer++) { |
2934 | track.UnsetTracklet(jLayer); | |
e17f4785 | 2935 | ptrTracklet = &seeds[jLayer]; |
9887cc9f | 2936 | if(!ptrTracklet->IsOK()) continue; |
5f1ae1e7 | 2937 | if(TMath::Abs(ptrTracklet->GetYref(1) - ptrTracklet->GetYfit(1)) >= .2) continue; // check this condition with Marian |
9887cc9f | 2938 | ptrTracklet = SetTracklet(ptrTracklet); |
f29f13a6 | 2939 | ptrTracklet->UseClusters(); |
91834b8d | 2940 | track.SetTracklet(ptrTracklet, fTracklets->GetEntriesFast()-1); |
2941 | } | |
d78d7df0 | 2942 | AliTRDtrackV1 *ptrTrack = SetTrack(&track); |
799e38d7 | 2943 | ptrTrack->CookPID(); |
5f1ae1e7 | 2944 | ptrTrack->CookLabel(.9); |
4d6aee34 | 2945 | ptrTrack->SetReconstructor(fkReconstructor); |
d78d7df0 | 2946 | return ptrTrack; |
91834b8d | 2947 | } |
393fda1c | 2948 | |
17e0e535 | 2949 | if(TMath::Abs(track.GetY())>1000) |
2950 | return NULL; | |
2951 | ||
d20df6fc | 2952 | track.ResetCovariance(1); |
e79f8eb0 | 2953 | Int_t nc = TMath::Abs(FollowBackProlongation(track)); |
a2fbb6ec | 2954 | if(fkReconstructor->GetRecoParam()->GetStreamLevel(AliTRDrecoParam::kTracker) > 5 && fkReconstructor->IsDebugStreaming()){ |
393fda1c | 2955 | Int_t eventNumber = AliTRDtrackerDebug::GetEventNumber(); |
2956 | Int_t candidateNumber = AliTRDtrackerDebug::GetCandidateNumber(); | |
2957 | Double_t p[5]; // Track Params for the Debug Stream | |
2958 | track.GetExternalParameters(params[0], p); | |
a2fbb6ec | 2959 | TTreeSRedirector &cs = *fkReconstructor->GetDebugStream(AliTRDrecoParam::kTracker); |
393fda1c | 2960 | cs << "MakeTrack" |
2961 | << "EventNumber=" << eventNumber | |
2962 | << "CandidateNumber=" << candidateNumber | |
2963 | << "nc=" << nc | |
2964 | << "X=" << params[0] | |
2965 | << "Y=" << p[0] | |
2966 | << "Z=" << p[1] | |
2967 | << "snp=" << p[2] | |
2968 | << "tnd=" << p[3] | |
2969 | << "crv=" << p[4] | |
2970 | << "Yin=" << params[1] | |
2971 | << "Zin=" << params[2] | |
2972 | << "snpin=" << params[3] | |
2973 | << "tndin=" << params[4] | |
2974 | << "crvin=" << params[5] | |
2975 | << "track.=" << &track | |
2976 | << "\n"; | |
2977 | } | |
4d6aee34 | 2978 | if (nc < 30) return NULL; |
d20df6fc | 2979 | |
2980 | AliTRDtrackV1 *ptrTrack = SetTrack(&track); | |
4d6aee34 | 2981 | ptrTrack->SetReconstructor(fkReconstructor); |
48f8adf3 | 2982 | ptrTrack->CookLabel(.9); |
24253b0a | 2983 | |
d20df6fc | 2984 | // computes PID for track |
2985 | ptrTrack->CookPID(); | |
2986 | // update calibration references using this track | |
48f8adf3 | 2987 | AliTRDCalibraFillHisto *calibra = AliTRDCalibraFillHisto::Instance(); |
2988 | if (!calibra){ | |
2989 | AliInfo("Could not get Calibra instance\n"); | |
2990 | if(calibra->GetHisto2d()) calibra->UpdateHistogramsV1(ptrTrack); | |
2991 | } | |
d20df6fc | 2992 | return ptrTrack; |
e4f2f73d | 2993 | } |
2994 | ||
0906e73e | 2995 | |
e4f2f73d | 2996 | //____________________________________________________________________ |
eb38ed55 | 2997 | Int_t AliTRDtrackerV1::ImproveSeedQuality(AliTRDtrackingChamber **stack, AliTRDseedV1 *cseed) |
e4f2f73d | 2998 | { |
41702fec | 2999 | // |
3000 | // Sort tracklets according to "quality" and try to "improve" the first 4 worst | |
3001 | // | |
3002 | // Parameters : | |
3003 | // layers : Array of propagation layers for a stack/supermodule | |
3004 | // cseed : Array of 6 seeding tracklets which has to be improved | |
3005 | // | |
f29f13a6 | 3006 | // Output : |
41702fec | 3007 | // cssed : Improved seeds |
3008 | // | |
3009 | // Detailed description | |
3010 | // | |
3011 | // Iterative procedure in which new clusters are searched for each | |
3012 | // tracklet seed such that the seed quality (see AliTRDseed::GetQuality()) | |
3013 | // can be maximized. If some optimization is found the old seeds are replaced. | |
3014 | // | |
3015 | // debug level: 7 | |
3016 | // | |
3017 | ||
3018 | // make a local working copy | |
4d6aee34 | 3019 | AliTRDtrackingChamber *chamber = NULL; |
980d5a2a | 3020 | AliTRDseedV1 bseed[AliTRDgeometry::kNlayer]; |
3021 | ||
3022 | Float_t quality(0.), | |
3023 | lQuality[] = {1.e3, 1.e3, 1.e3, 1.e3, 1.e3, 1.e3}; | |
3024 | Int_t rLayers(0); | |
3025 | for(Int_t jLayer=AliTRDgeometry::kNlayer; jLayer--;){ | |
3026 | bseed[jLayer] = cseed[jLayer]; | |
3027 | if(!bseed[jLayer].IsOK()) continue; | |
3028 | rLayers++; | |
3029 | lQuality[jLayer] = bseed[jLayer].GetQuality(kTRUE); | |
3030 | quality += lQuality[jLayer]; | |
3031 | } | |
3032 | Float_t chi2 = FitTiltedRieman(bseed, kTRUE); | |
41702fec | 3033 | |
3034 | for (Int_t iter = 0; iter < 4; iter++) { | |
560e5c05 | 3035 | AliDebug(2, Form("Iter[%d] Q[%f] chi2[%f]", iter, quality, chi2)); |
3036 | ||
980d5a2a | 3037 | // Try better cluster set |
3038 | Int_t nLayers(0); Float_t qualitynew(0.); | |
3039 | Int_t indexes[6]; | |
3040 | TMath::Sort(Int_t(AliTRDgeometry::kNlayer), lQuality, indexes, kFALSE); | |
3041 | for(Int_t jLayer=AliTRDgeometry::kNlayer; jLayer--;) { | |
3042 | Int_t bLayer = indexes[jLayer]; | |
3043 | bseed[bLayer].Reset("c"); | |
41702fec | 3044 | if(!(chamber = stack[bLayer])) continue; |
980d5a2a | 3045 | if(!bseed[bLayer].AttachClusters(chamber, kTRUE)) continue; |
f29f13a6 | 3046 | bseed[bLayer].Fit(kTRUE); |
980d5a2a | 3047 | if(!bseed[bLayer].IsOK()) continue; |
3048 | nLayers++; | |
3049 | lQuality[jLayer] = bseed[jLayer].GetQuality(kTRUE); | |
3050 | qualitynew += lQuality[jLayer]; | |
41702fec | 3051 | } |
980d5a2a | 3052 | if(rLayers > nLayers){ |
3053 | AliDebug(1, Form("Lost %d tracklets while improving.", rLayers-nLayers)); | |
3054 | break; | |
3055 | } else rLayers=nLayers; | |
3056 | ||
3057 | if(qualitynew >= quality){ | |
3058 | AliDebug(4, Form("Quality worsen in iter[%d].", iter)); | |
3059 | break; | |
3060 | } else quality = qualitynew; | |
3061 | ||
3062 | // try improve track parameters | |
3063 | AliTRDseedV1 tseed[AliTRDgeometry::kNlayer]; | |
3064 | for(Int_t jLayer=AliTRDgeometry::kNlayer; jLayer--;) tseed[jLayer]=bseed[jLayer]; | |
3065 | Float_t chi2new = FitTiltedRieman(tseed, kTRUE); | |
3066 | if(chi2new > chi2){ | |
3067 | AliDebug(4, Form("Chi2 worsen in iter[%d].", iter)); | |
3068 | break; | |
3069 | } else chi2 = chi2new; | |
3070 | ||
3071 | // store better tracklets | |
3072 | for(Int_t jLayer=AliTRDgeometry::kNlayer; jLayer--;) bseed[jLayer]=tseed[jLayer]; | |
3073 | ||
41702fec | 3074 | |
a2fbb6ec | 3075 | if(fkReconstructor->GetRecoParam()->GetStreamLevel(AliTRDrecoParam::kTracker) >= 7 && fkReconstructor->IsDebugStreaming()){ |
41702fec | 3076 | Int_t eventNumber = AliTRDtrackerDebug::GetEventNumber(); |
3077 | Int_t candidateNumber = AliTRDtrackerDebug::GetCandidateNumber(); | |
3078 | TLinearFitter *tiltedRieman = GetTiltedRiemanFitter(); | |
a2fbb6ec | 3079 | TTreeSRedirector &cstreamer = *fkReconstructor->GetDebugStream(AliTRDrecoParam::kTracker); |
41702fec | 3080 | cstreamer << "ImproveSeedQuality" |
980d5a2a | 3081 | << "EventNumber=" << eventNumber |
3082 | << "CandidateNumber=" << candidateNumber | |
3083 | << "Iteration=" << iter | |
3084 | << "S0.=" << &bseed[0] | |
3085 | << "S1.=" << &bseed[1] | |
3086 | << "S2.=" << &bseed[2] | |
3087 | << "S3.=" << &bseed[3] | |
3088 | << "S4.=" << &bseed[4] | |
3089 | << "S5.=" << &bseed[5] | |
3090 | << "FitterT.=" << tiltedRieman | |
3091 | << "\n"; | |
41702fec | 3092 | } |
3093 | } // Loop: iter | |
41702fec | 3094 | // we are sure that at least 2 tracklets are OK ! |
980d5a2a | 3095 | return rLayers; |
e4f2f73d | 3096 | } |
3097 | ||
eb38ed55 | 3098 | //_________________________________________________________________________ |
4d6aee34 | 3099 | Double_t AliTRDtrackerV1::CalculateTrackLikelihood(const AliTRDseedV1 *const tracklets, Double_t *chi2){ |
41702fec | 3100 | // |
3101 | // Calculates the Track Likelihood value. This parameter serves as main quality criterion for | |
3102 | // the track selection | |
3103 | // The likelihood value containes: | |
3104 | // - The chi2 values from the both fitters and the chi2 values in z-direction from a linear fit | |
3105 | // - The Sum of the Parameter |slope_ref - slope_fit|/Sigma of the tracklets | |
3106 | // For all Parameters an exponential dependency is used | |
3107 | // | |
3108 | // Parameters: - Array of tracklets (AliTRDseedV1) related to the track candidate | |
3109 | // - Array of chi2 values: | |
3110 | // * Non-Constrained Tilted Riemann fit | |
3111 | // * Vertex-Constrained Tilted Riemann fit | |
3112 | // * z-Direction from Linear fit | |
3113 | // Output: - The calculated track likelihood | |
3114 | // | |
3115 | // debug level 2 | |
3116 | // | |
3117 | ||
f29f13a6 | 3118 | Double_t chi2phi = 0, nLayers = 0; |
41702fec | 3119 | for (Int_t iLayer = 0; iLayer < kNPlanes; iLayer++) { |
3120 | if(!tracklets[iLayer].IsOK()) continue; | |
f29f13a6 | 3121 | chi2phi += tracklets[iLayer].GetChi2Phi(); |
41702fec | 3122 | nLayers++; |
3123 | } | |
f29f13a6 | 3124 | chi2phi /= Float_t (nLayers - 2.0); |
41702fec | 3125 | |
3126 | Double_t likeChi2Z = TMath::Exp(-chi2[2] * 0.14); // Chi2Z | |
a2fbb6ec | 3127 | Double_t likeChi2TC = (fkReconstructor->GetRecoParam()->IsVertexConstrained()) ? |
d20df6fc | 3128 | TMath::Exp(-chi2[1] * 0.677) : 1; // Constrained Tilted Riemann |
6e39bde4 | 3129 | Double_t likeChi2TR = TMath::Exp(-chi2[0] * 0.0078); // Non-constrained Tilted Riemann |
3130 | Double_t likeChi2Phi= TMath::Exp(-chi2phi * 3.23);//3.23 | |
f29f13a6 | 3131 | Double_t trackLikelihood = likeChi2Z * likeChi2TR * likeChi2Phi; |
41702fec | 3132 | |
a2fbb6ec | 3133 | if(fkReconstructor->GetRecoParam()->GetStreamLevel(AliTRDrecoParam::kTracker) >= 2 && fkReconstructor->IsDebugStreaming()){ |
41702fec | 3134 | Int_t eventNumber = AliTRDtrackerDebug::GetEventNumber(); |
3135 | Int_t candidateNumber = AliTRDtrackerDebug::GetCandidateNumber(); | |
a2fbb6ec | 3136 | TTreeSRedirector &cstreamer = *fkReconstructor->GetDebugStream(AliTRDrecoParam::kTracker); |
41702fec | 3137 | cstreamer << "CalculateTrackLikelihood0" |
3138 | << "EventNumber=" << eventNumber | |
3139 | << "CandidateNumber=" << candidateNumber | |
3140 | << "LikeChi2Z=" << likeChi2Z | |
3141 | << "LikeChi2TR=" << likeChi2TR | |
3142 | << "LikeChi2TC=" << likeChi2TC | |
f29f13a6 | 3143 | << "LikeChi2Phi=" << likeChi2Phi |
41702fec | 3144 | << "TrackLikelihood=" << trackLikelihood |
3145 | << "\n"; | |
3146 | } | |
6e39bde4 | 3147 | |
41702fec | 3148 | return trackLikelihood; |
e4f2f73d | 3149 | } |
3150 | ||
3151 | //____________________________________________________________________ | |
91834b8d | 3152 | Double_t AliTRDtrackerV1::CookLikelihood(AliTRDseedV1 *cseed, Int_t planes[4]) |
e4f2f73d | 3153 | { |
41702fec | 3154 | // |
3155 | // Calculate the probability of this track candidate. | |
3156 | // | |
3157 | // Parameters : | |
3158 | // cseeds : array of candidate tracklets | |
3159 | // planes : array of seeding planes (see seeding configuration) | |
3160 | // chi2 : chi2 values (on the Z and Y direction) from the rieman fit of the track. | |
3161 | // | |
3162 | // Output : | |
3163 | // likelihood value | |
3164 | // | |
3165 | // Detailed description | |
3166 | // | |
3167 | // The track quality is estimated based on the following 4 criteria: | |
3168 | // 1. precision of the rieman fit on the Y direction (likea) | |
3169 | // 2. chi2 on the Y direction (likechi2y) | |
3170 | // 3. chi2 on the Z direction (likechi2z) | |
3171 | // 4. number of attached clusters compared to a reference value | |
3172 | // (see AliTRDrecoParam::fkFindable) (likeN) | |
3173 | // | |
3174 | // The distributions for each type of probabilities are given below as of | |
3175 | // (date). They have to be checked to assure consistency of estimation. | |
3176 | // | |
3177 | ||
3178 | // ratio of the total number of clusters/track which are expected to be found by the tracker. | |
4d6aee34 | 3179 | const AliTRDrecoParam *fRecoPars = fkReconstructor->GetRecoParam(); |
41702fec | 3180 | |
91834b8d | 3181 | Double_t chi2y = GetChi2Y(&cseed[0]); |
3182 | Double_t chi2z = GetChi2Z(&cseed[0]); | |
3183 | ||
8ae98148 | 3184 | Float_t nclusters = 0.; |
41702fec | 3185 | Double_t sumda = 0.; |
3186 | for(UChar_t ilayer = 0; ilayer < 4; ilayer++){ | |
3187 | Int_t jlayer = planes[ilayer]; | |
3188 | nclusters += cseed[jlayer].GetN2(); | |
e3cf3d02 | 3189 | sumda += TMath::Abs(cseed[jlayer].GetYfit(1) - cseed[jlayer].GetYref(1)); |
41702fec | 3190 | } |
8ae98148 | 3191 | nclusters *= .25; |
3192 | ||
5a2e200c | 3193 | Double_t likea = TMath::Exp(-sumda * fRecoPars->GetPhiSlope()); |
41702fec | 3194 | Double_t likechi2y = 0.0000000001; |
4d6aee34 | 3195 | if (fkReconstructor->IsCosmic() || chi2y < fRecoPars->GetChi2YCut()) likechi2y += TMath::Exp(-TMath::Sqrt(chi2y) * fRecoPars->GetChi2YSlope()); |
5a2e200c | 3196 | Double_t likechi2z = TMath::Exp(-chi2z * fRecoPars->GetChi2ZSlope()); |
8ae98148 | 3197 | Double_t likeN = TMath::Exp(-(fRecoPars->GetNMeanClusters() - nclusters) / fRecoPars->GetNSigmaClusters()); |
41702fec | 3198 | Double_t like = likea * likechi2y * likechi2z * likeN; |
3199 | ||
a2fbb6ec | 3200 | if(fkReconstructor->GetRecoParam()->GetStreamLevel(AliTRDrecoParam::kTracker) >= 2 && fkReconstructor->IsDebugStreaming()){ |
41702fec | 3201 | Int_t eventNumber = AliTRDtrackerDebug::GetEventNumber(); |
3202 | Int_t candidateNumber = AliTRDtrackerDebug::GetCandidateNumber(); | |
4d6aee34 | 3203 | Int_t nTracklets = 0; Float_t meanNcls = 0; |
91834b8d | 3204 | for(Int_t iseed=0; iseed < kNPlanes; iseed++){ |
3205 | if(!cseed[iseed].IsOK()) continue; | |
3206 | nTracklets++; | |
4d6aee34 | 3207 | meanNcls += cseed[iseed].GetN2(); |
91834b8d | 3208 | } |
4d6aee34 | 3209 | if(nTracklets) meanNcls /= nTracklets; |
41702fec | 3210 | // The Debug Stream contains the seed |
a2fbb6ec | 3211 | TTreeSRedirector &cstreamer = *fkReconstructor->GetDebugStream(AliTRDrecoParam::kTracker); |
41702fec | 3212 | cstreamer << "CookLikelihood" |
3213 | << "EventNumber=" << eventNumber | |
3214 | << "CandidateNumber=" << candidateNumber | |
3215 | << "tracklet0.=" << &cseed[0] | |
3216 | << "tracklet1.=" << &cseed[1] | |
3217 | << "tracklet2.=" << &cseed[2] | |
3218 | << "tracklet3.=" << &cseed[3] | |
3219 | << "tracklet4.=" << &cseed[4] | |
3220 | << "tracklet5.=" << &cseed[5] | |
3221 | << "sumda=" << sumda | |
91834b8d | 3222 | << "chi2y=" << chi2y |
3223 | << "chi2z=" << chi2z | |
41702fec | 3224 | << "likea=" << likea |
3225 | << "likechi2y=" << likechi2y | |
3226 | << "likechi2z=" << likechi2z | |
3227 | << "nclusters=" << nclusters | |
3228 | << "likeN=" << likeN | |
3229 | << "like=" << like | |
4d6aee34 | 3230 | << "meanncls=" << meanNcls |
41702fec | 3231 | << "\n"; |
3232 | } | |
3233 | ||
3234 | return like; | |
e4f2f73d | 3235 | } |
3236 | ||
e4f2f73d | 3237 | //____________________________________________________________________ |
0906e73e | 3238 | void AliTRDtrackerV1::GetSeedingConfig(Int_t iconfig, Int_t planes[4]) |
e4f2f73d | 3239 | { |
41702fec | 3240 | // |
3241 | // Map seeding configurations to detector planes. | |
3242 | // | |
3243 | // Parameters : | |
3244 | // iconfig : configuration index | |
3245 | // planes : member planes of this configuration. On input empty. | |
3246 | // | |
3247 | // Output : | |
3248 | // planes : contains the planes which are defining the configuration | |
3249 | // | |
3250 | // Detailed description | |
3251 | // | |
3252 | // Here is the list of seeding planes configurations together with | |
3253 | // their topological classification: | |
3254 | // | |
3255 | // 0 - 5432 TQ 0 | |
3256 | // 1 - 4321 TQ 0 | |
3257 | // 2 - 3210 TQ 0 | |
3258 | // 3 - 5321 TQ 1 | |
3259 | // 4 - 4210 TQ 1 | |
3260 | // 5 - 5431 TQ 1 | |
3261 | // 6 - 4320 TQ 1 | |
3262 | // 7 - 5430 TQ 2 | |
3263 | // 8 - 5210 TQ 2 | |
3264 | // 9 - 5421 TQ 3 | |
3265 | // 10 - 4310 TQ 3 | |
3266 | // 11 - 5410 TQ 4 | |
3267 | // 12 - 5420 TQ 5 | |
3268 | // 13 - 5320 TQ 5 | |
3269 | // 14 - 5310 TQ 5 | |
3270 | // | |
3271 | // The topologic quality is modeled as follows: | |
3272 | // 1. The general model is define by the equation: | |
3273 | // p(conf) = exp(-conf/2) | |
3274 | // 2. According to the topologic classification, configurations from the same | |
3275 | // class are assigned the agerage value over the model values. | |
3276 | // 3. Quality values are normalized. | |
3277 | // | |
3278 | // The topologic quality distribution as function of configuration is given below: | |
3279 | //Begin_Html | |
3280 | // <img src="gif/topologicQA.gif"> | |
3281 | //End_Html | |
3282 | // | |
3283 | ||
3284 | switch(iconfig){ | |
3285 | case 0: // 5432 TQ 0 | |
3286 | planes[0] = 2; | |
3287 | planes[1] = 3; | |
3288 | planes[2] = 4; | |
3289 | planes[3] = 5; | |
3290 | break; | |
3291 | case 1: // 4321 TQ 0 | |
3292 | planes[0] = 1; | |
3293 | planes[1] = 2; | |
3294 | planes[2] = 3; | |
3295 | planes[3] = 4; | |
3296 | break; | |
3297 | case 2: // 3210 TQ 0 | |
3298 | planes[0] = 0; | |
3299 | planes[1] = 1; | |
3300 | planes[2] = 2; | |
3301 | planes[3] = 3; | |
3302 | break; | |
3303 | case 3: // 5321 TQ 1 | |
3304 | planes[0] = 1; | |
3305 | planes[1] = 2; | |
3306 | planes[2] = 3; | |
3307 | planes[3] = 5; | |
3308 | break; | |
3309 | case 4: // 4210 TQ 1 | |
3310 | planes[0] = 0; | |
3311 | planes[1] = 1; | |
3312 | planes[2] = 2; | |
3313 | planes[3] = 4; | |
3314 | break; | |
3315 | case 5: // 5431 TQ 1 | |
3316 | planes[0] = 1; | |
3317 | planes[1] = 3; | |
3318 | planes[2] = 4; | |
3319 | planes[3] = 5; | |
3320 | break; | |
3321 | case 6: // 4320 TQ 1 | |
3322 | planes[0] = 0; | |
3323 | planes[1] = 2; | |
3324 | planes[2] = 3; | |
3325 | planes[3] = 4; | |
3326 | break; | |
3327 | case 7: // 5430 TQ 2 | |
3328 | planes[0] = 0; | |
3329 | planes[1] = 3; | |
3330 | planes[2] = 4; | |
3331 | planes[3] = 5; | |
3332 | break; | |
3333 | case 8: // 5210 TQ 2 | |
3334 | planes[0] = 0; | |
3335 | planes[1] = 1; | |
3336 | planes[2] = 2; | |
3337 | planes[3] = 5; | |
3338 | break; | |
3339 | case 9: // 5421 TQ 3 | |
3340 | planes[0] = 1; | |
3341 | planes[1] = 2; | |
3342 | planes[2] = 4; | |
3343 | planes[3] = 5; | |
3344 | break; | |
3345 | case 10: // 4310 TQ 3 | |
3346 | planes[0] = 0; | |
3347 | planes[1] = 1; | |
3348 | planes[2] = 3; | |
3349 | planes[3] = 4; | |
3350 | break; | |
3351 | case 11: // 5410 TQ 4 | |
3352 | planes[0] = 0; | |
3353 | planes[1] = 1; | |
3354 | planes[2] = 4; | |
3355 | planes[3] = 5; | |
3356 | break; | |
3357 | case 12: // 5420 TQ 5 | |
3358 | planes[0] = 0; | |
3359 | planes[1] = 2; | |
3360 | planes[2] = 4; | |
3361 | planes[3] = 5; | |
3362 | break; | |
3363 | case 13: // 5320 TQ 5 | |
3364 | planes[0] = 0; | |
3365 | planes[1] = 2; | |
3366 | planes[2] = 3; | |
3367 | planes[3] = 5; | |
3368 | break; | |
3369 | case 14: // 5310 TQ 5 | |
3370 | planes[0] = 0; | |
3371 | planes[1] = 1; | |
3372 | planes[2] = 3; | |
3373 | planes[3] = 5; | |
3374 | break; | |
3375 | } | |
e4f2f73d | 3376 | } |
3377 | ||
3378 | //____________________________________________________________________ | |
0906e73e | 3379 | void AliTRDtrackerV1::GetExtrapolationConfig(Int_t iconfig, Int_t planes[2]) |
e4f2f73d | 3380 | { |
41702fec | 3381 | // |
3382 | // Returns the extrapolation planes for a seeding configuration. | |
3383 | // | |
3384 | // Parameters : | |
3385 | // iconfig : configuration index | |
3386 | // planes : planes which are not in this configuration. On input empty. | |
3387 | // | |
3388 | // Output : | |
3389 | // planes : contains the planes which are not in the configuration | |
3390 | // | |
3391 | // Detailed description | |
3392 | // | |
3393 | ||
3394 | switch(iconfig){ | |
3395 | case 0: // 5432 TQ 0 | |
3396 | planes[0] = 1; | |
3397 | planes[1] = 0; | |
3398 | break; | |
3399 | case 1: // 4321 TQ 0 | |
3400 | planes[0] = 5; | |
3401 | planes[1] = 0; | |
3402 | break; | |
3403 | case 2: // 3210 TQ 0 | |
3404 | planes[0] = 4; | |
3405 | planes[1] = 5; | |
3406 | break; | |
3407 | case 3: // 5321 TQ 1 | |
3408 | planes[0] = 4; | |
3409 | planes[1] = 0; | |
3410 | break; | |
3411 | case 4: // 4210 TQ 1 | |
3412 | planes[0] = 5; | |
3413 | planes[1] = 3; | |
3414 | break; | |
3415 | case 5: // 5431 TQ 1 | |
3416 | planes[0] = 2; | |
3417 | planes[1] = 0; | |
3418 | break; | |
3419 | case 6: // 4320 TQ 1 | |
3420 | planes[0] = 5; | |
3421 | planes[1] = 1; | |
3422 | break; | |
3423 | case 7: // 5430 TQ 2 | |
3424 | planes[0] = 2; | |
3425 | planes[1] = 1; | |
3426 | break; | |
3427 | case 8: // 5210 TQ 2 | |
3428 | planes[0] = 4; | |
3429 | planes[1] = 3; | |
3430 | break; | |
3431 | case 9: // 5421 TQ 3 | |
3432 | planes[0] = 3; | |
3433 | planes[1] = 0; | |
3434 | break; | |
3435 | case 10: // 4310 TQ 3 | |
3436 | planes[0] = 5; | |
3437 | planes[1] = 2; | |
3438 | break; | |
3439 | case 11: // 5410 TQ 4 | |
3440 | planes[0] = 3; | |
3441 | planes[1] = 2; | |
3442 | break; | |
3443 | case 12: // 5420 TQ 5 | |
3444 | planes[0] = 3; | |
3445 | planes[1] = 1; | |
3446 | break; | |
3447 | case 13: // 5320 TQ 5 | |
3448 | planes[0] = 4; | |
3449 | planes[1] = 1; | |
3450 | break; | |
3451 | case 14: // 5310 TQ 5 | |
3452 | planes[0] = 4; | |
3453 | planes[1] = 2; | |
3454 | break; | |
3455 | } | |
e4f2f73d | 3456 | } |
eb38ed55 | 3457 | |
3458 | //____________________________________________________________________ | |
3459 | AliCluster* AliTRDtrackerV1::GetCluster(Int_t idx) const | |
3460 | { | |
41702fec | 3461 | Int_t ncls = fClusters->GetEntriesFast(); |
4d6aee34 | 3462 | return idx >= 0 && idx < ncls ? (AliCluster*)fClusters->UncheckedAt(idx) : NULL; |
eb38ed55 | 3463 | } |
3464 | ||
3b57a3f7 | 3465 | //____________________________________________________________________ |
3466 | AliTRDseedV1* AliTRDtrackerV1::GetTracklet(Int_t idx) const | |
3467 | { | |
41702fec | 3468 | Int_t ntrklt = fTracklets->GetEntriesFast(); |
4d6aee34 | 3469 | return idx >= 0 && idx < ntrklt ? (AliTRDseedV1*)fTracklets->UncheckedAt(idx) : NULL; |
3b57a3f7 | 3470 | } |
3471 | ||
3472 | //____________________________________________________________________ | |
3473 | AliKalmanTrack* AliTRDtrackerV1::GetTrack(Int_t idx) const | |
3474 | { | |
41702fec | 3475 | Int_t ntrk = fTracks->GetEntriesFast(); |
4d6aee34 | 3476 | return idx >= 0 && idx < ntrk ? (AliKalmanTrack*)fTracks->UncheckedAt(idx) : NULL; |
3b57a3f7 | 3477 | } |
3478 | ||
6e39bde4 | 3479 | |
eb38ed55 | 3480 | |
fac58f00 | 3481 | // //_____________________________________________________________________________ |
3482 | // Int_t AliTRDtrackerV1::Freq(Int_t n, const Int_t *inlist | |
3483 | // , Int_t *outlist, Bool_t down) | |
3484 | // { | |
3485 | // // | |
3486 | // // Sort eleements according occurancy | |
3487 | // // The size of output array has is 2*n | |
3488 | // // | |
3489 | // | |
3490 | // if (n <= 0) { | |
3491 | // return 0; | |
3492 | // } | |
3493 | // | |
3494 | // Int_t *sindexS = new Int_t[n]; // Temporary array for sorting | |
3495 | // Int_t *sindexF = new Int_t[2*n]; | |
3496 | // for (Int_t i = 0; i < n; i++) { | |
3497 | // sindexF[i] = 0; | |
3498 | // } | |
3499 | // | |
3500 | // TMath::Sort(n,inlist,sindexS,down); | |
3501 | // | |
3502 | // Int_t last = inlist[sindexS[0]]; | |
3503 | // Int_t val = last; | |
3504 | // sindexF[0] = 1; | |
3505 | // sindexF[0+n] = last; | |
3506 | // Int_t countPos = 0; | |
3507 | // | |
3508 | // // Find frequency | |
3509 | // for (Int_t i = 1; i < n; i++) { | |
3510 | // val = inlist[sindexS[i]]; | |
3511 | // if (last == val) { | |
3512 | // sindexF[countPos]++; | |
3513 | // } | |
3514 | // else { | |
3515 | // countPos++; | |
3516 | // sindexF[countPos+n] = val; | |
3517 | // sindexF[countPos]++; | |
3518 | // last = val; | |
3519 | // } | |
3520 | // } | |
3521 | // if (last == val) { | |
3522 | // countPos++; | |
3523 | // } | |
3524 | // | |
3525 | // // Sort according frequency | |
3526 | // TMath::Sort(countPos,sindexF,sindexS,kTRUE); | |
3527 | // | |
3528 | // for (Int_t i = 0; i < countPos; i++) { | |
3529 | // outlist[2*i ] = sindexF[sindexS[i]+n]; | |
3530 | // outlist[2*i+1] = sindexF[sindexS[i]]; | |
3531 | // } | |
3532 | // | |
3533 | // delete [] sindexS; | |
3534 | // delete [] sindexF; | |
3535 | // | |
3536 | // return countPos; | |
3537 | // | |
3538 | // } | |
bb56afff | 3539 | |
06b32d95 | 3540 | |
d611c74f | 3541 | //____________________________________________________________________ |
3542 | void AliTRDtrackerV1::ResetSeedTB() | |
3543 | { | |
3544 | // reset buffer for seeding time bin layers. If the time bin | |
3545 | // layers are not allocated this function allocates them | |
3546 | ||
3547 | for(Int_t isl=0; isl<kNSeedPlanes; isl++){ | |
3548 | if(!fSeedTB[isl]) fSeedTB[isl] = new AliTRDchamberTimeBin(); | |
3549 | else fSeedTB[isl]->Clear(); | |
3550 | } | |
3551 | } | |
3552 | ||
e3cf3d02 | 3553 | |
3554 | //_____________________________________________________________________________ | |
4d6aee34 | 3555 | Float_t AliTRDtrackerV1::GetChi2Y(const AliTRDseedV1 * const tracklets) const |
e3cf3d02 | 3556 | { |
3557 | // Calculates normalized chi2 in y-direction | |
3558 | // chi2 = Sum chi2 / n_tracklets | |
3559 | ||
3560 | Double_t chi2 = 0.; Int_t n = 0; | |
3561 | for(Int_t ipl = kNPlanes; ipl--;){ | |
3562 | if(!tracklets[ipl].IsOK()) continue; | |
3563 | chi2 += tracklets[ipl].GetChi2Y(); | |
3564 | n++; | |
3565 | } | |
3566 | return n ? chi2/n : 0.; | |
3567 | } | |
3568 | ||
bb56afff | 3569 | //_____________________________________________________________________________ |
4d6aee34 | 3570 | Float_t AliTRDtrackerV1::GetChi2Z(const AliTRDseedV1 *const tracklets) const |
bb56afff | 3571 | { |
91834b8d | 3572 | // Calculates normalized chi2 in z-direction |
e3cf3d02 | 3573 | // chi2 = Sum chi2 / n_tracklets |
41702fec | 3574 | |
e3cf3d02 | 3575 | Double_t chi2 = 0; Int_t n = 0; |
3576 | for(Int_t ipl = kNPlanes; ipl--;){ | |
41702fec | 3577 | if(!tracklets[ipl].IsOK()) continue; |
e3cf3d02 | 3578 | chi2 += tracklets[ipl].GetChi2Z(); |
3579 | n++; | |
41702fec | 3580 | } |
e3cf3d02 | 3581 | return n ? chi2/n : 0.; |
bb56afff | 3582 | } |
8acca6a3 | 3583 | |
6e39bde4 | 3584 | //____________________________________________________________________ |
4d6aee34 | 3585 | Float_t AliTRDtrackerV1::CalculateReferenceX(const AliTRDseedV1 *const tracklets){ |
6e39bde4 | 3586 | // |
3587 | // Calculates the reference x-position for the tilted Rieman fit defined as middle | |
3588 | // of the stack (middle between layers 2 and 3). For the calculation all the tracklets | |
3589 | // are taken into account | |
3590 | // | |
3591 | // Parameters: - Array of tracklets(AliTRDseedV1) | |
3592 | // | |
3593 | // Output: - The reference x-position(Float_t) | |
3594 | // Only kept for compatibility with the old code | |
3595 | // | |
3596 | Int_t nDistances = 0; | |
3597 | Float_t meanDistance = 0.; | |
3598 | Int_t startIndex = 5; | |
3599 | for(Int_t il =5; il > 0; il--){ | |
3600 | if(tracklets[il].IsOK() && tracklets[il -1].IsOK()){ | |
3601 | Float_t xdiff = tracklets[il].GetX0() - tracklets[il -1].GetX0(); | |
3602 | meanDistance += xdiff; | |
3603 | nDistances++; | |
3604 | } | |
3605 | if(tracklets[il].IsOK()) startIndex = il; | |
3606 | } | |
3607 | if(tracklets[0].IsOK()) startIndex = 0; | |
3608 | if(!nDistances){ | |
3609 | // We should normally never get here | |
3610 | Float_t xpos[2]; memset(xpos, 0, sizeof(Float_t) * 2); | |
3611 | Int_t iok = 0, idiff = 0; | |
3612 | // This attempt is worse and should be avoided: | |
3613 | // check for two chambers which are OK and repeat this without taking the mean value | |
3614 | // Strategy avoids a division by 0; | |
3615 | for(Int_t il = 5; il >= 0; il--){ | |
3616 | if(tracklets[il].IsOK()){ | |
3617 | xpos[iok] = tracklets[il].GetX0(); | |
3618 | iok++; | |
3619 | startIndex = il; | |
3620 | } | |
3621 | if(iok) idiff++; // to get the right difference; | |
3622 | if(iok > 1) break; | |
3623 | } | |
3624 | if(iok > 1){ | |
3625 | meanDistance = (xpos[0] - xpos[1])/idiff; | |
3626 | } | |
3627 | else{ | |
3628 | // we have do not even have 2 layers which are OK? The we do not need to fit at all | |
3629 | return 331.; | |
3630 | } | |
3631 | } | |
3632 | else{ | |
3633 | meanDistance /= nDistances; | |
3634 | } | |
3635 | return tracklets[startIndex].GetX0() + (2.5 - startIndex) * meanDistance - 0.5 * (AliTRDgeometry::AmThick() + AliTRDgeometry::DrThick()); | |
3636 | } | |
3637 | ||
3638 | //_____________________________________________________________________________ | |
4d6aee34 | 3639 | Double_t AliTRDtrackerV1::FitTiltedRiemanV1(AliTRDseedV1 *const tracklets){ |
6e39bde4 | 3640 | // |
3641 | // Track Fitter Function using the new class implementation of | |
3642 | // the Rieman fit | |
3643 | // | |
3644 | AliTRDtrackFitterRieman fitter; | |
3645 | fitter.SetRiemanFitter(GetTiltedRiemanFitter()); | |
3646 | fitter.Reset(); | |
3647 | for(Int_t il = 0; il < AliTRDgeometry::kNlayer; il++) fitter.SetTracklet(il, &tracklets[il]); | |
3648 | Double_t chi2 = fitter.Eval(); | |
3649 | // Update the tracklets | |
3650 | Double_t cov[15]; Double_t x0; | |
3651 | memset(cov, 0, sizeof(Double_t) * 15); | |
3652 | for(Int_t il = 0; il < AliTRDgeometry::kNlayer; il++){ | |
3653 | x0 = tracklets[il].GetX0(); | |
3654 | tracklets[il].SetYref(0, fitter.GetYat(x0)); | |
3655 | tracklets[il].SetZref(0, fitter.GetZat(x0)); | |
3656 | tracklets[il].SetYref(1, fitter.GetDyDxAt(x0)); | |
3657 | tracklets[il].SetZref(1, fitter.GetDzDx()); | |
3658 | tracklets[il].SetC(fitter.GetCurvature()); | |
3659 | fitter.GetCovAt(x0, cov); | |
3660 | tracklets[il].SetCovRef(cov); | |
3661 | tracklets[il].SetChi2(chi2); | |
3662 | } | |
3663 | return chi2; | |
3664 | } | |
3665 | ||
8acca6a3 | 3666 | /////////////////////////////////////////////////////// |
3667 | // // | |
3668 | // Resources of class AliTRDLeastSquare // | |
3669 | // // | |
3670 | /////////////////////////////////////////////////////// | |
3671 | ||
3672 | //_____________________________________________________________________________ | |
3673 | AliTRDtrackerV1::AliTRDLeastSquare::AliTRDLeastSquare(){ | |
41702fec | 3674 | // |
3675 | // Constructor of the nested class AliTRDtrackFitterLeastSquare | |
3676 | // | |
3677 | memset(fParams, 0, sizeof(Double_t) * 2); | |
341512a4 | 3678 | memset(fSums, 0, sizeof(Double_t) * 6); |
41702fec | 3679 | memset(fCovarianceMatrix, 0, sizeof(Double_t) * 3); |
8acca6a3 | 3680 | |
3681 | } | |
3682 | ||
3683 | //_____________________________________________________________________________ | |
4d6aee34 | 3684 | void AliTRDtrackerV1::AliTRDLeastSquare::AddPoint(const Double_t *const x, Double_t y, Double_t sigmaY){ |
41702fec | 3685 | // |
3686 | // Adding Point to the fitter | |
3687 | // | |
5f1ae1e7 | 3688 | |
2ed81ab2 | 3689 | Double_t weight = 1/(sigmaY > 1e-9 ? sigmaY : 1e-9); |
3690 | weight *= weight; | |
4d6aee34 | 3691 | const Double_t &xpt = *x; |
41702fec | 3692 | // printf("Adding point x = %f, y = %f, sigma = %f\n", xpt, y, sigmaY); |
3693 | fSums[0] += weight; | |
3694 | fSums[1] += weight * xpt; | |
3695 | fSums[2] += weight * y; | |
3696 | fSums[3] += weight * xpt * y; | |
3697 | fSums[4] += weight * xpt * xpt; | |
3698 | fSums[5] += weight * y * y; | |
8acca6a3 | 3699 | } |
3700 | ||
3701 | //_____________________________________________________________________________ | |
4d6aee34 | 3702 | void AliTRDtrackerV1::AliTRDLeastSquare::RemovePoint(const Double_t *const x, Double_t y, Double_t sigmaY){ |
41702fec | 3703 | // |
3704 | // Remove Point from the sample | |
3705 | // | |
5f1ae1e7 | 3706 | |
2ed81ab2 | 3707 | Double_t weight = 1/(sigmaY > 1e-9 ? sigmaY : 1e-9); |
3708 | weight *= weight; | |
4d6aee34 | 3709 | const Double_t &xpt = *x; |
41702fec | 3710 | fSums[0] -= weight; |
3711 | fSums[1] -= weight * xpt; | |
3712 | fSums[2] -= weight * y; | |
3713 | fSums[3] -= weight * xpt * y; | |
3714 | fSums[4] -= weight * xpt * xpt; | |
3715 | fSums[5] -= weight * y * y; | |
8acca6a3 | 3716 | } |
3717 | ||
3718 | //_____________________________________________________________________________ | |
3719 | void AliTRDtrackerV1::AliTRDLeastSquare::Eval(){ | |
41702fec | 3720 | // |
3721 | // Evaluation of the fit: | |
3722 | // Calculation of the parameters | |
3723 | // Calculation of the covariance matrix | |
3724 | // | |
3725 | ||
3726 | Double_t denominator = fSums[0] * fSums[4] - fSums[1] *fSums[1]; | |
aec26713 | 3727 | if(denominator==0) return; |
3728 | ||
41702fec | 3729 | // for(Int_t isum = 0; isum < 5; isum++) |
3730 | // printf("fSums[%d] = %f\n", isum, fSums[isum]); | |
3731 | // printf("denominator = %f\n", denominator); | |
3732 | fParams[0] = (fSums[2] * fSums[4] - fSums[1] * fSums[3])/ denominator; | |
3733 | fParams[1] = (fSums[0] * fSums[3] - fSums[1] * fSums[2]) / denominator; | |
3734 | // printf("fParams[0] = %f, fParams[1] = %f\n", fParams[0], fParams[1]); | |
3735 | ||
3736 | // Covariance matrix | |
2ed81ab2 | 3737 | fCovarianceMatrix[0] = fSums[4] / fSums[0] - fSums[1] * fSums[1] / (fSums[0] * fSums[0]); |
3738 | fCovarianceMatrix[1] = fSums[5] / fSums[0] - fSums[2] * fSums[2] / (fSums[0] * fSums[0]); | |
3739 | fCovarianceMatrix[2] = fSums[3] / fSums[0] - fSums[1] * fSums[2] / (fSums[0] * fSums[0]); | |
8acca6a3 | 3740 | } |
3741 | ||
46b6abd7 | 3742 | //_____________________________________________________________________________ |
4d6aee34 | 3743 | Double_t AliTRDtrackerV1::AliTRDLeastSquare::GetFunctionValue(const Double_t *const xpos) const { |
41702fec | 3744 | // |
3745 | // Returns the Function value of the fitted function at a given x-position | |
3746 | // | |
3747 | return fParams[0] + fParams[1] * (*xpos); | |
46b6abd7 | 3748 | } |
3749 | ||
3750 | //_____________________________________________________________________________ | |
3751 | void AliTRDtrackerV1::AliTRDLeastSquare::GetCovarianceMatrix(Double_t *storage) const { | |
41702fec | 3752 | // |
3753 | // Copies the values of the covariance matrix into the storage | |
3754 | // | |
3755 | memcpy(storage, fCovarianceMatrix, sizeof(Double_t) * 3); | |
46b6abd7 | 3756 | } |
3757 | ||
6e39bde4 | 3758 | //_____________________________________________________________________________ |
3759 | void AliTRDtrackerV1::AliTRDLeastSquare::Reset(){ | |
3760 | // | |
3761 | // Reset the fitter | |
3762 | // | |
3763 | memset(fParams, 0, sizeof(Double_t) * 2); | |
3764 | memset(fCovarianceMatrix, 0, sizeof(Double_t) * 3); | |
3765 | memset(fSums, 0, sizeof(Double_t) * 6); | |
3766 | } | |
3767 | ||
3768 | /////////////////////////////////////////////////////// | |
3769 | // // | |
3770 | // Resources of class AliTRDtrackFitterRieman // | |
3771 | // // | |
3772 | /////////////////////////////////////////////////////// | |
3773 | ||
3774 | //_____________________________________________________________________________ | |
3775 | AliTRDtrackerV1::AliTRDtrackFitterRieman::AliTRDtrackFitterRieman(): | |
3776 | fTrackFitter(NULL), | |
3777 | fZfitter(NULL), | |
3778 | fCovarPolY(NULL), | |
3779 | fCovarPolZ(NULL), | |
3780 | fXref(0.), | |
3781 | fSysClusterError(0.) | |
3782 | { | |
3783 | // | |
3784 | // Default constructor | |
3785 | // | |
3786 | fZfitter = new AliTRDLeastSquare; | |
3787 | fCovarPolY = new TMatrixD(3,3); | |
3788 | fCovarPolZ = new TMatrixD(2,2); | |
3789 | memset(fTracklets, 0, sizeof(AliTRDseedV1 *) * 6); | |
3790 | memset(fParameters, 0, sizeof(Double_t) * 5); | |
3791 | memset(fSumPolY, 0, sizeof(Double_t) * 5); | |
3792 | memset(fSumPolZ, 0, sizeof(Double_t) * 2); | |
3793 | } | |
3794 | ||
3795 | //_____________________________________________________________________________ | |
3796 | AliTRDtrackerV1::AliTRDtrackFitterRieman::~AliTRDtrackFitterRieman(){ | |
3797 | // | |
3798 | // Destructor | |
3799 | // | |
3800 | if(fZfitter) delete fZfitter; | |
3801 | if(fCovarPolY) delete fCovarPolY; | |
3802 | if(fCovarPolZ) delete fCovarPolZ; | |
3803 | } | |
3804 | ||
3805 | //_____________________________________________________________________________ | |
3806 | void AliTRDtrackerV1::AliTRDtrackFitterRieman::Reset(){ | |
3807 | // | |
3808 | // Reset the Fitter | |
3809 | // | |
3810 | if(fTrackFitter){ | |
3811 | fTrackFitter->StoreData(kTRUE); | |
3812 | fTrackFitter->ClearPoints(); | |
3813 | } | |
3814 | if(fZfitter){ | |
3815 | fZfitter->Reset(); | |
3816 | } | |
3817 | fXref = 0.; | |
3818 | memset(fTracklets, 0, sizeof(AliTRDseedV1 *) * AliTRDgeometry::kNlayer); | |
3819 | memset(fParameters, 0, sizeof(Double_t) * 5); | |
3820 | memset(fSumPolY, 0, sizeof(Double_t) * 5); | |
3821 | memset(fSumPolZ, 0, sizeof(Double_t) * 2); | |
3822 | for(Int_t irow = 0; irow < fCovarPolY->GetNrows(); irow++) | |
3823 | for(Int_t icol = 0; icol < fCovarPolY->GetNcols(); icol++){ | |
3824 | (*fCovarPolY)(irow, icol) = 0.; | |
3825 | if(irow < 2 && icol < 2) | |
3826 | (*fCovarPolZ)(irow, icol) = 0.; | |
3827 | } | |
3828 | } | |
3829 | ||
3830 | //_____________________________________________________________________________ | |
3831 | void AliTRDtrackerV1::AliTRDtrackFitterRieman::SetTracklet(Int_t itr, AliTRDseedV1 *tracklet){ | |
3832 | // | |
3833 | // Add tracklet into the fitter | |
3834 | // | |
3835 | if(itr >= AliTRDgeometry::kNlayer) return; | |
3836 | fTracklets[itr] = tracklet; | |
3837 | } | |
3838 | ||
3839 | //_____________________________________________________________________________ | |
3840 | Double_t AliTRDtrackerV1::AliTRDtrackFitterRieman::Eval(){ | |
3841 | // | |
3842 | // Perform the fit | |
3843 | // 1. Apply linear transformation and store points in the fitter | |
3844 | // 2. Evaluate the fit | |
3845 | // 3. Check if the result of the fit in z-direction is reasonable | |
3846 | // if not | |
3847 | // 3a. Fix the parameters 3 and 4 with the results of a simple least | |
3848 | // square fit | |
3849 | // 3b. Redo the fit with the fixed parameters | |
3850 | // 4. Store fit results (parameters and errors) | |
3851 | // | |
3852 | if(!fTrackFitter){ | |
3853 | return 1e10; | |
3854 | } | |
3855 | fXref = CalculateReferenceX(); | |
3856 | for(Int_t il = 0; il < AliTRDgeometry::kNlayer; il++) UpdateFitters(fTracklets[il]); | |
3857 | if(!fTrackFitter->GetNpoints()) return 1e10; | |
3858 | // perform the fit | |
3859 | fTrackFitter->Eval(); | |
3860 | fZfitter->Eval(); | |
3861 | fParameters[3] = fTrackFitter->GetParameter(3); | |
3862 | fParameters[4] = fTrackFitter->GetParameter(4); | |
3863 | if(!CheckAcceptable(fParameters[3], fParameters[4])) { | |
3864 | fTrackFitter->FixParameter(3, fZfitter->GetFunctionValue(&fXref)); | |
3865 | fTrackFitter->FixParameter(4, fZfitter->GetFunctionParameter(1)); | |
3866 | fTrackFitter->Eval(); | |
3867 | fTrackFitter->ReleaseParameter(3); | |
3868 | fTrackFitter->ReleaseParameter(4); | |
3869 | fParameters[3] = fTrackFitter->GetParameter(3); | |
3870 | fParameters[4] = fTrackFitter->GetParameter(4); | |
3871 | } | |
3872 | // Update the Fit Parameters and the errors | |
3873 | fParameters[0] = fTrackFitter->GetParameter(0); | |
3874 | fParameters[1] = fTrackFitter->GetParameter(1); | |
3875 | fParameters[2] = fTrackFitter->GetParameter(2); | |
3876 | ||
3877 | // Prepare Covariance estimation | |
3878 | (*fCovarPolY)(0,0) = fSumPolY[0]; (*fCovarPolY)(1,1) = fSumPolY[2]; (*fCovarPolY)(2,2) = fSumPolY[4]; | |
3879 | (*fCovarPolY)(1,0) = (*fCovarPolY)(0,1) = fSumPolY[1]; | |
3880 | (*fCovarPolY)(2,0) = (*fCovarPolY)(0,2) = fSumPolY[2]; | |
3881 | (*fCovarPolY)(2,1) = (*fCovarPolY)(1,2) = fSumPolY[3]; | |
3882 | fCovarPolY->Invert(); | |
3883 | (*fCovarPolZ)(0,0) = fSumPolZ[0]; (*fCovarPolZ)(1,1) = fSumPolZ[2]; | |
3884 | (*fCovarPolZ)(1,0) = (*fCovarPolZ)(0,1) = fSumPolZ[1]; | |
3885 | fCovarPolZ->Invert(); | |
3886 | return fTrackFitter->GetChisquare() / fTrackFitter->GetNpoints(); | |
3887 | } | |
3888 | ||
3889 | //_____________________________________________________________________________ | |
4d6aee34 | 3890 | void AliTRDtrackerV1::AliTRDtrackFitterRieman::UpdateFitters(AliTRDseedV1 * const tracklet){ |
6e39bde4 | 3891 | // |
3892 | // Does the transformations and updates the fitters | |
3893 | // The following transformation is applied | |
3894 | // | |
3895 | AliTRDcluster *cl = NULL; | |
3896 | Double_t x, y, z, dx, t, w, we, yerr, zerr; | |
3897 | Double_t uvt[4]; | |
3898 | if(!tracklet || !tracklet->IsOK()) return; | |
3899 | Double_t tilt = tracklet->GetTilt(); | |
3900 | for(Int_t itb = 0; itb < AliTRDseedV1::kNclusters; itb++){ | |
3901 | if(!(cl = tracklet->GetClusters(itb))) continue; | |
3902 | if(!cl->IsInChamber()) continue; | |
3903 | if (!tracklet->IsUsable(itb)) continue; | |
3904 | x = cl->GetX(); | |
3905 | y = cl->GetY(); | |
3906 | z = cl->GetZ(); | |
3907 | dx = x - fXref; | |
3908 | // Transformation | |
3909 | t = 1./(x*x + y*y); | |
3910 | uvt[0] = 2. * x * t; | |
3911 | uvt[1] = t; | |
3912 | uvt[2] = 2. * tilt * t; | |
3913 | uvt[3] = 2. * tilt * dx * t; | |
3914 | w = 2. * (y + tilt*z) * t; | |
3915 | // error definition changes for the different calls | |
3916 | we = 2. * t; | |
3917 | we *= TMath::Sqrt(cl->GetSigmaY2()+tilt*tilt*cl->GetSigmaZ2()); | |
3918 | // Update sums for error calculation | |
3919 | yerr = 1./(TMath::Sqrt(cl->GetSigmaY2()) + fSysClusterError); | |
3920 | yerr *= yerr; | |
3921 | zerr = 1./cl->GetSigmaZ2(); | |
3922 | for(Int_t ipol = 0; ipol < 5; ipol++){ | |
3923 | fSumPolY[ipol] += yerr; | |
3924 | yerr *= x; | |
3925 | if(ipol < 3){ | |
3926 | fSumPolZ[ipol] += zerr; | |
3927 | zerr *= x; | |
3928 | } | |
3929 | } | |
3930 | fTrackFitter->AddPoint(uvt, w, we); | |
3931 | fZfitter->AddPoint(&x, z, static_cast<Double_t>(TMath::Sqrt(cl->GetSigmaZ2()))); | |
3932 | } | |
3933 | } | |
3934 | ||
3935 | //_____________________________________________________________________________ | |
3936 | Bool_t AliTRDtrackerV1::AliTRDtrackFitterRieman::CheckAcceptable(Double_t offset, Double_t slope){ | |
3937 | // | |
3938 | // Check whether z-results are acceptable | |
3939 | // Definition: Distance between tracklet fit and track fit has to be | |
3940 | // less then half a padlength | |
3941 | // Point of comparision is at the anode wire | |
3942 | // | |
3943 | Bool_t acceptablez = kTRUE; | |
3944 | Double_t zref = 0.0; | |
3945 | for (Int_t iLayer = 0; iLayer < kNPlanes; iLayer++) { | |
3946 | if(!fTracklets[iLayer]->IsOK()) continue; | |
3947 | zref = offset + slope * (fTracklets[iLayer]->GetX0() - fXref); | |
3948 | if (TMath::Abs(fTracklets[iLayer]->GetZfit(0) - zref) > fTracklets[iLayer]->GetPadLength() * 0.5 + 1.0) | |
3949 | acceptablez = kFALSE; | |
3950 | } | |
3951 | return acceptablez; | |
3952 | } | |
3953 | ||
3954 | //_____________________________________________________________________________ | |
3955 | Double_t AliTRDtrackerV1::AliTRDtrackFitterRieman::GetYat(Double_t x) const { | |
3956 | // | |
3957 | // Calculate y position out of the track parameters | |
3958 | // y: R^2 = (x - x0)^2 + (y - y0)^2 | |
3959 | // => y = y0 +/- Sqrt(R^2 - (x - x0)^2) | |
3960 | // R = Sqrt() = 1/Curvature | |
3961 | // => y = y0 +/- Sqrt(1/Curvature^2 - (x - x0)^2) | |
3962 | // | |
3963 | Double_t y = 0; | |
3964 | Double_t disc = (x * fParameters[0] + fParameters[1]); | |
3965 | disc = 1 - fParameters[0]*fParameters[2] + fParameters[1]*fParameters[1] - disc*disc; | |
3966 | if (disc >= 0) { | |
3967 | disc = TMath::Sqrt(disc); | |
3968 | y = (1.0 - disc) / fParameters[0]; | |
3969 | } | |
3970 | return y; | |
3971 | } | |
3972 | ||
3973 | //_____________________________________________________________________________ | |
3974 | Double_t AliTRDtrackerV1::AliTRDtrackFitterRieman::GetZat(Double_t x) const { | |
3975 | // | |
3976 | // Return z position for a given x position | |
3977 | // Simple linear function | |
3978 | // | |
3979 | return fParameters[3] + fParameters[4] * (x - fXref); | |
3980 | } | |
3981 | ||
3982 | //_____________________________________________________________________________ | |
3983 | Double_t AliTRDtrackerV1::AliTRDtrackFitterRieman::GetDyDxAt(Double_t x) const { | |
3984 | // | |
3985 | // Calculate dydx at a given radial position out of the track parameters | |
3986 | // dy: R^2 = (x - x0)^2 + (y - y0)^2 | |
3987 | // => y = +/- Sqrt(R^2 - (x - x0)^2) + y0 | |
3988 | // => dy/dx = (x - x0)/Sqrt(R^2 - (x - x0)^2) | |
3989 | // Curvature: cr = 1/R = a/Sqrt(1 + b^2 - c*a) | |
3990 | // => dy/dx = (x - x0)/(1/(cr^2) - (x - x0)^2) | |
3991 | // | |
3992 | Double_t x0 = -fParameters[1] / fParameters[0]; | |
3993 | Double_t curvature = GetCurvature(); | |
3994 | Double_t dy = 0; | |
3995 | if (-fParameters[2] * fParameters[0] + fParameters[1] * fParameters[1] + 1 > 0) { | |
3996 | if (1.0/(curvature * curvature) - (x - x0) * (x - x0) > 0.0) { | |
3997 | Double_t yderiv = (x - x0) / TMath::Sqrt(1.0/(curvature * curvature) - (x - x0) * (x - x0)); | |
3998 | if (fParameters[0] < 0) yderiv *= -1.0; | |
3999 | dy = yderiv; | |
4000 | } | |
4001 | } | |
4002 | return dy; | |
4003 | } | |
4004 | ||
4005 | //_____________________________________________________________________________ | |
4006 | Double_t AliTRDtrackerV1::AliTRDtrackFitterRieman::GetCurvature() const { | |
4007 | // | |
4008 | // Calculate track curvature | |
4009 | // | |
4010 | // | |
4011 | Double_t curvature = 1.0 + fParameters[1]*fParameters[1] - fParameters[2]*fParameters[0]; | |
4012 | if (curvature > 0.0) | |
4013 | curvature = fParameters[0] / TMath::Sqrt(curvature); | |
4014 | return curvature; | |
4015 | } | |
4016 | ||
4017 | //_____________________________________________________________________________ | |
4018 | void AliTRDtrackerV1::AliTRDtrackFitterRieman::GetCovAt(Double_t x, Double_t *cov) const { | |
4019 | // | |
4020 | // Error Definition according to gauss error propagation | |
4021 | // | |
4022 | TMatrixD transform(3,3); | |
4023 | transform(0,0) = transform(1,1) = transform(2,2) = 1; | |
4024 | transform(0,1) = transform(1,2) = x; | |
4025 | transform(0,2) = x*x; | |
4026 | TMatrixD covariance(transform, TMatrixD::kMult, *fCovarPolY); | |
4027 | covariance *= transform.T(); | |
4028 | cov[0] = covariance(0,0); | |
4029 | TMatrixD transformZ(2,2); | |
4030 | transformZ(0,0) = transformZ(1,1) = 1; | |
4031 | transformZ(0,1) = x; | |
4032 | TMatrixD covarZ(transformZ, TMatrixD::kMult, *fCovarPolZ); | |
4033 | covarZ *= transformZ.T(); | |
4034 | cov[1] = covarZ(0,0); | |
4035 | cov[2] = 0; | |
4036 | } | |
4037 | ||
4038 | //____________________________________________________________________ | |
4039 | Double_t AliTRDtrackerV1::AliTRDtrackFitterRieman::CalculateReferenceX(){ | |
4040 | // | |
4041 | // Calculates the reference x-position for the tilted Rieman fit defined as middle | |
4042 | // of the stack (middle between layers 2 and 3). For the calculation all the tracklets | |
4043 | // are taken into account | |
4044 | // | |
4045 | // Parameters: - Array of tracklets(AliTRDseedV1) | |
4046 | // | |
4047 | // Output: - The reference x-position(Float_t) | |
4048 | // | |
4049 | Int_t nDistances = 0; | |
4050 | Float_t meanDistance = 0.; | |
4051 | Int_t startIndex = 5; | |
4052 | for(Int_t il =5; il > 0; il--){ | |
4053 | if(fTracklets[il]->IsOK() && fTracklets[il -1]->IsOK()){ | |
4054 | Float_t xdiff = fTracklets[il]->GetX0() - fTracklets[il -1]->GetX0(); | |
4055 | meanDistance += xdiff; | |
4056 | nDistances++; | |
4057 | } | |
4058 | if(fTracklets[il]->IsOK()) startIndex = il; | |
4059 | } | |
4060 | if(fTracklets[0]->IsOK()) startIndex = 0; | |
4061 | if(!nDistances){ | |
4062 | // We should normally never get here | |
4063 | Float_t xpos[2]; memset(xpos, 0, sizeof(Float_t) * 2); | |
4064 | Int_t iok = 0, idiff = 0; | |
4065 | // This attempt is worse and should be avoided: | |
4066 | // check for two chambers which are OK and repeat this without taking the mean value | |
4067 | // Strategy avoids a division by 0; | |
4068 | for(Int_t il = 5; il >= 0; il--){ | |
4069 | if(fTracklets[il]->IsOK()){ | |
4070 | xpos[iok] = fTracklets[il]->GetX0(); | |
4071 | iok++; | |
4072 | startIndex = il; | |
4073 | } | |
4074 | if(iok) idiff++; // to get the right difference; | |
4075 | if(iok > 1) break; | |
4076 | } | |
4077 | if(iok > 1){ | |
4078 | meanDistance = (xpos[0] - xpos[1])/idiff; | |
4079 | } | |
4080 | else{ | |
4081 | // we have do not even have 2 layers which are OK? The we do not need to fit at all | |
4082 | return 331.; | |
4083 | } | |
4084 | } | |
4085 | else{ | |
4086 | meanDistance /= nDistances; | |
4087 | } | |
4088 | return fTracklets[startIndex]->GetX0() + (2.5 - startIndex) * meanDistance - 0.5 * (AliTRDgeometry::AmThick() + AliTRDgeometry::DrThick()); | |
4089 | } |