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