]>
Commit | Line | Data |
---|---|---|
e4f2f73d | 1 | /************************************************************************** |
29b87567 | 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 | // The TRD track seed // | |
21 | // // | |
22 | // Authors: // | |
23 | // Alex Bercuci <A.Bercuci@gsi.de> // | |
24 | // Markus Fasel <M.Fasel@gsi.de> // | |
25 | // // | |
26 | //////////////////////////////////////////////////////////////////////////// | |
27 | ||
28 | #include "TMath.h" | |
29 | #include "TLinearFitter.h" | |
eb38ed55 | 30 | #include "TClonesArray.h" // tmp |
31 | #include <TTreeStream.h> | |
e4f2f73d | 32 | |
33 | #include "AliLog.h" | |
34 | #include "AliMathBase.h" | |
35 | ||
e4f2f73d | 36 | #include "AliTRDcluster.h" |
f3d3af1b | 37 | #include "AliTRDseedV1.h" |
38 | #include "AliTRDtrackV1.h" | |
e4f2f73d | 39 | #include "AliTRDcalibDB.h" |
eb38ed55 | 40 | #include "AliTRDchamberTimeBin.h" |
41 | #include "AliTRDtrackingChamber.h" | |
42 | #include "AliTRDtrackerV1.h" | |
43 | #include "AliTRDReconstructor.h" | |
e4f2f73d | 44 | #include "AliTRDrecoParam.h" |
0906e73e | 45 | #include "Cal/AliTRDCalPID.h" |
e4f2f73d | 46 | |
e4f2f73d | 47 | ClassImp(AliTRDseedV1) |
48 | ||
49 | //____________________________________________________________________ | |
ae4e8b84 | 50 | AliTRDseedV1::AliTRDseedV1(Int_t det) |
e4f2f73d | 51 | :AliTRDseed() |
3a039a31 | 52 | ,fReconstructor(0x0) |
ae4e8b84 | 53 | ,fClusterIter(0x0) |
54 | ,fClusterIdx(0) | |
55 | ,fDet(det) | |
0906e73e | 56 | ,fMom(0.) |
bcb6fb78 | 57 | ,fSnp(0.) |
58 | ,fTgl(0.) | |
59 | ,fdX(0.) | |
e4f2f73d | 60 | { |
61 | // | |
62 | // Constructor | |
63 | // | |
29b87567 | 64 | //printf("AliTRDseedV1::AliTRDseedV1()\n"); |
e44586fb | 65 | |
29b87567 | 66 | for(int islice=0; islice < knSlices; islice++) fdEdx[islice] = 0.; |
67 | for(int ispec=0; ispec<AliPID::kSPECIES; ispec++) fProb[ispec] = -1.; | |
e4f2f73d | 68 | } |
69 | ||
70 | //____________________________________________________________________ | |
0906e73e | 71 | AliTRDseedV1::AliTRDseedV1(const AliTRDseedV1 &ref) |
e4f2f73d | 72 | :AliTRDseed((AliTRDseed&)ref) |
43d6ad34 | 73 | ,fReconstructor(ref.fReconstructor) |
ae4e8b84 | 74 | ,fClusterIter(0x0) |
75 | ,fClusterIdx(0) | |
76 | ,fDet(ref.fDet) | |
0906e73e | 77 | ,fMom(ref.fMom) |
bcb6fb78 | 78 | ,fSnp(ref.fSnp) |
79 | ,fTgl(ref.fTgl) | |
80 | ,fdX(ref.fdX) | |
e4f2f73d | 81 | { |
82 | // | |
83 | // Copy Constructor performing a deep copy | |
84 | // | |
85 | ||
29b87567 | 86 | //printf("AliTRDseedV1::AliTRDseedV1(const AliTRDseedV1 &)\n"); |
87 | SetBit(kOwner, kFALSE); | |
88 | for(int islice=0; islice < knSlices; islice++) fdEdx[islice] = ref.fdEdx[islice]; | |
89 | for(int ispec=0; ispec<AliPID::kSPECIES; ispec++) fProb[ispec] = ref.fProb[ispec]; | |
fbb2ea06 | 90 | } |
d9950a5a | 91 | |
0906e73e | 92 | |
e4f2f73d | 93 | //____________________________________________________________________ |
94 | AliTRDseedV1& AliTRDseedV1::operator=(const AliTRDseedV1 &ref) | |
95 | { | |
96 | // | |
97 | // Assignment Operator using the copy function | |
98 | // | |
99 | ||
29b87567 | 100 | if(this != &ref){ |
101 | ref.Copy(*this); | |
102 | } | |
103 | return *this; | |
e4f2f73d | 104 | |
105 | } | |
106 | ||
107 | //____________________________________________________________________ | |
108 | AliTRDseedV1::~AliTRDseedV1() | |
109 | { | |
110 | // | |
111 | // Destructor. The RecoParam object belongs to the underlying tracker. | |
112 | // | |
113 | ||
29b87567 | 114 | //printf("I-AliTRDseedV1::~AliTRDseedV1() : Owner[%s]\n", IsOwner()?"YES":"NO"); |
e4f2f73d | 115 | |
29b87567 | 116 | if(IsOwner()) |
117 | for(int itb=0; itb<knTimebins; itb++){ | |
118 | if(!fClusters[itb]) continue; | |
119 | //AliInfo(Form("deleting c %p @ %d", fClusters[itb], itb)); | |
120 | delete fClusters[itb]; | |
121 | fClusters[itb] = 0x0; | |
122 | } | |
e4f2f73d | 123 | } |
124 | ||
125 | //____________________________________________________________________ | |
126 | void AliTRDseedV1::Copy(TObject &ref) const | |
127 | { | |
128 | // | |
129 | // Copy function | |
130 | // | |
131 | ||
29b87567 | 132 | //AliInfo(""); |
133 | AliTRDseedV1 &target = (AliTRDseedV1 &)ref; | |
134 | ||
ae4e8b84 | 135 | target.fClusterIter = 0x0; |
136 | target.fClusterIdx = 0; | |
137 | target.fDet = fDet; | |
29b87567 | 138 | target.fMom = fMom; |
139 | target.fSnp = fSnp; | |
140 | target.fTgl = fTgl; | |
141 | target.fdX = fdX; | |
142 | target.fReconstructor = fReconstructor; | |
143 | ||
144 | for(int islice=0; islice < knSlices; islice++) target.fdEdx[islice] = fdEdx[islice]; | |
145 | for(int ispec=0; ispec<AliPID::kSPECIES; ispec++) target.fProb[ispec] = fProb[ispec]; | |
146 | ||
147 | AliTRDseed::Copy(target); | |
e4f2f73d | 148 | } |
149 | ||
0906e73e | 150 | |
151 | //____________________________________________________________ | |
f3d3af1b | 152 | Bool_t AliTRDseedV1::Init(AliTRDtrackV1 *track) |
0906e73e | 153 | { |
154 | // Initialize this tracklet using the track information | |
155 | // | |
156 | // Parameters: | |
157 | // track - the TRD track used to initialize the tracklet | |
158 | // | |
159 | // Detailed description | |
160 | // The function sets the starting point and direction of the | |
161 | // tracklet according to the information from the TRD track. | |
162 | // | |
163 | // Caution | |
164 | // The TRD track has to be propagated to the beginning of the | |
165 | // chamber where the tracklet will be constructed | |
166 | // | |
167 | ||
29b87567 | 168 | Double_t y, z; |
169 | if(!track->GetProlongation(fX0, y, z)) return kFALSE; | |
170 | fYref[0] = y; | |
171 | fYref[1] = track->GetSnp()/(1. - track->GetSnp()*track->GetSnp()); | |
172 | fZref[0] = z; | |
173 | fZref[1] = track->GetTgl(); | |
0906e73e | 174 | |
29b87567 | 175 | //printf("Tracklet ref x[%7.3f] y[%7.3f] z[%7.3f], snp[%f] tgl[%f]\n", fX0, fYref[0], fZref[0], track->GetSnp(), track->GetTgl()); |
176 | return kTRUE; | |
0906e73e | 177 | } |
178 | ||
bcb6fb78 | 179 | |
180 | //____________________________________________________________________ | |
181 | void AliTRDseedV1::CookdEdx(Int_t nslices) | |
182 | { | |
183 | // Calculates average dE/dx for all slices and store them in the internal array fdEdx. | |
184 | // | |
185 | // Parameters: | |
186 | // nslices : number of slices for which dE/dx should be calculated | |
187 | // Output: | |
188 | // store results in the internal array fdEdx. This can be accessed with the method | |
189 | // AliTRDseedV1::GetdEdx() | |
190 | // | |
191 | // Detailed description | |
192 | // Calculates average dE/dx for all slices. Depending on the PID methode | |
193 | // the number of slices can be 3 (LQ) or 8(NN). | |
194 | // The calculation of dQ/dl are done using the tracklet fit results (see AliTRDseedV1::GetdQdl(Int_t)) i.e. | |
195 | // | |
196 | // dQ/dl = qc/(dx * sqrt(1 + dy/dx^2 + dz/dx^2)) | |
197 | // | |
198 | // The following effects are included in the calculation: | |
199 | // 1. calibration values for t0 and vdrift (using x coordinate to calculate slice) | |
200 | // 2. cluster sharing (optional see AliTRDrecoParam::SetClusterSharing()) | |
201 | // 3. cluster size | |
202 | // | |
203 | ||
29b87567 | 204 | Int_t nclusters[knSlices]; |
205 | for(int i=0; i<knSlices; i++){ | |
206 | fdEdx[i] = 0.; | |
207 | nclusters[i] = 0; | |
208 | } | |
209 | Float_t clength = (/*.5 * */AliTRDgeometry::AmThick() + AliTRDgeometry::DrThick()); | |
210 | ||
211 | AliTRDcluster *cluster = 0x0; | |
212 | for(int ic=0; ic<AliTRDtrackerV1::GetNTimeBins(); ic++){ | |
213 | if(!(cluster = fClusters[ic])) continue; | |
214 | Float_t x = cluster->GetX(); | |
215 | ||
216 | // Filter clusters for dE/dx calculation | |
217 | ||
218 | // 1.consider calibration effects for slice determination | |
219 | Int_t slice; | |
220 | if(cluster->IsInChamber()) slice = Int_t(TMath::Abs(fX0 - x) * nslices / clength); | |
221 | else slice = x < fX0 ? 0 : nslices-1; | |
222 | ||
223 | // 2. take sharing into account | |
224 | Float_t w = cluster->IsShared() ? .5 : 1.; | |
225 | ||
226 | // 3. take into account large clusters TODO | |
227 | //w *= c->GetNPads() > 3 ? .8 : 1.; | |
228 | ||
229 | //CHECK !!! | |
230 | fdEdx[slice] += w * GetdQdl(ic); //fdQdl[ic]; | |
231 | nclusters[slice]++; | |
232 | } // End of loop over clusters | |
233 | ||
cd40b287 | 234 | //if(fReconstructor->GetPIDMethod() == AliTRDReconstructor::kLQPID){ |
235 | if(nslices == AliTRDReconstructor::kLQslices){ | |
29b87567 | 236 | // calculate mean charge per slice (only LQ PID) |
237 | for(int is=0; is<nslices; is++){ | |
238 | if(nclusters[is]) fdEdx[is] /= nclusters[is]; | |
239 | } | |
240 | } | |
bcb6fb78 | 241 | } |
242 | ||
b83573da | 243 | |
bcb6fb78 | 244 | //____________________________________________________________________ |
245 | Float_t AliTRDseedV1::GetdQdl(Int_t ic) const | |
246 | { | |
29b87567 | 247 | return fClusters[ic] ? TMath::Abs(fClusters[ic]->GetQ()) /fdX / TMath::Sqrt(1. + fYfit[1]*fYfit[1] + fZref[1]*fZref[1]) : 0.; |
bcb6fb78 | 248 | } |
249 | ||
0906e73e | 250 | //____________________________________________________________________ |
251 | Double_t* AliTRDseedV1::GetProbability() | |
252 | { | |
253 | // Fill probability array for tracklet from the DB. | |
254 | // | |
255 | // Parameters | |
256 | // | |
257 | // Output | |
258 | // returns pointer to the probability array and 0x0 if missing DB access | |
259 | // | |
260 | // Detailed description | |
261 | ||
29b87567 | 262 | |
263 | // retrive calibration db | |
0906e73e | 264 | AliTRDcalibDB *calibration = AliTRDcalibDB::Instance(); |
265 | if (!calibration) { | |
266 | AliError("No access to calibration data"); | |
267 | return 0x0; | |
268 | } | |
269 | ||
3a039a31 | 270 | if (!fReconstructor) { |
271 | AliError("Reconstructor not set."); | |
4ba1d6ae | 272 | return 0x0; |
273 | } | |
274 | ||
0906e73e | 275 | // Retrieve the CDB container class with the parametric detector response |
3a039a31 | 276 | const AliTRDCalPID *pd = calibration->GetPIDObject(fReconstructor->GetPIDMethod()); |
0906e73e | 277 | if (!pd) { |
278 | AliError("No access to AliTRDCalPID object"); | |
279 | return 0x0; | |
280 | } | |
29b87567 | 281 | //AliInfo(Form("Method[%d] : %s", fReconstructor->GetRecoParam() ->GetPIDMethod(), pd->IsA()->GetName())); |
10f75631 | 282 | |
29b87567 | 283 | // calculate tracklet length TO DO |
0906e73e | 284 | Float_t length = (AliTRDgeometry::AmThick() + AliTRDgeometry::DrThick()); |
285 | /// TMath::Sqrt((1.0 - fSnp[iPlane]*fSnp[iPlane]) / (1.0 + fTgl[iPlane]*fTgl[iPlane])); | |
286 | ||
287 | //calculate dE/dx | |
3a039a31 | 288 | CookdEdx(fReconstructor->GetNdEdxSlices()); |
0906e73e | 289 | |
290 | // Sets the a priori probabilities | |
291 | for(int ispec=0; ispec<AliPID::kSPECIES; ispec++) { | |
ae4e8b84 | 292 | fProb[ispec] = pd->GetProbability(ispec, fMom, &fdEdx[0], length, GetPlane()); |
0906e73e | 293 | } |
294 | ||
29b87567 | 295 | return &fProb[0]; |
0906e73e | 296 | } |
297 | ||
e4f2f73d | 298 | //____________________________________________________________________ |
299 | Float_t AliTRDseedV1::GetQuality(Bool_t kZcorr) const | |
300 | { | |
301 | // | |
302 | // Returns a quality measurement of the current seed | |
303 | // | |
304 | ||
29b87567 | 305 | Float_t zcorr = kZcorr ? fTilt * (fZProb - fZref[0]) : 0.; |
306 | return | |
307 | .5 * TMath::Abs(18.0 - fN2) | |
308 | + 10.* TMath::Abs(fYfit[1] - fYref[1]) | |
309 | + 5. * TMath::Abs(fYfit[0] - fYref[0] + zcorr) | |
310 | + 2. * TMath::Abs(fMeanz - fZref[0]) / fPadLength; | |
e4f2f73d | 311 | } |
312 | ||
0906e73e | 313 | //____________________________________________________________________ |
314 | void AliTRDseedV1::GetCovAt(Double_t /*x*/, Double_t *cov) const | |
315 | { | |
316 | // Computes covariance in the y-z plane at radial point x | |
317 | ||
29b87567 | 318 | Int_t ic = 0; while (!fClusters[ic]) ic++; |
eb38ed55 | 319 | AliTRDcalibDB *fCalib = AliTRDcalibDB::Instance(); |
29b87567 | 320 | Double_t exB = fCalib->GetOmegaTau(fCalib->GetVdriftAverage(fClusters[ic]->GetDetector()), -AliTracker::GetBz()*0.1); |
eb38ed55 | 321 | |
29b87567 | 322 | Double_t sy2 = fSigmaY2*fSigmaY2 + .2*(fYfit[1]-exB)*(fYfit[1]-exB); |
323 | Double_t sz2 = fPadLength/12.; | |
0906e73e | 324 | |
eb38ed55 | 325 | |
29b87567 | 326 | //printf("Yfit[1] %f sy20 %f SigmaY2 %f\n", fYfit[1], sy20, fSigmaY2); |
0906e73e | 327 | |
29b87567 | 328 | cov[0] = sy2; |
329 | cov[1] = fTilt*(sy2-sz2); | |
330 | cov[2] = sz2; | |
3a039a31 | 331 | |
332 | // insert systematic uncertainties calibration and misalignment | |
333 | Double_t sys[15]; | |
334 | fReconstructor->GetRecoParam()->GetSysCovMatrix(sys); | |
335 | cov[0] += (sys[0]*sys[0]); | |
336 | cov[2] += (sys[1]*sys[1]); | |
0906e73e | 337 | } |
338 | ||
0906e73e | 339 | |
340 | //____________________________________________________________________ | |
29b87567 | 341 | void AliTRDseedV1::SetOwner() |
0906e73e | 342 | { |
29b87567 | 343 | //AliInfo(Form("own [%s] fOwner[%s]", own?"YES":"NO", fOwner?"YES":"NO")); |
344 | ||
345 | if(TestBit(kOwner)) return; | |
346 | for(int ic=0; ic<knTimebins; ic++){ | |
347 | if(!fClusters[ic]) continue; | |
348 | fClusters[ic] = new AliTRDcluster(*fClusters[ic]); | |
349 | } | |
350 | SetBit(kOwner); | |
0906e73e | 351 | } |
352 | ||
e4f2f73d | 353 | //____________________________________________________________________ |
eb38ed55 | 354 | Bool_t AliTRDseedV1::AttachClustersIter(AliTRDtrackingChamber *chamber, Float_t quality, Bool_t kZcorr, AliTRDcluster *c) |
e4f2f73d | 355 | { |
356 | // | |
357 | // Iterative process to register clusters to the seed. | |
358 | // In iteration 0 we try only one pad-row and if quality not | |
359 | // sufficient we try 2 pad-rows (about 5% of tracks cross 2 pad-rows) | |
360 | // | |
29b87567 | 361 | // debug level 7 |
362 | // | |
363 | ||
364 | if(!fReconstructor->GetRecoParam() ){ | |
365 | AliError("Seed can not be used without a valid RecoParam."); | |
366 | return kFALSE; | |
367 | } | |
368 | ||
369 | AliTRDchamberTimeBin *layer = 0x0; | |
370 | if(fReconstructor->GetStreamLevel(AliTRDReconstructor::kTracker)>=7 && c){ | |
371 | TClonesArray clusters("AliTRDcluster", 24); | |
372 | clusters.SetOwner(kTRUE); | |
373 | AliTRDcluster *cc = 0x0; | |
374 | Int_t det=-1, ncl, ncls = 0; | |
375 | for (Int_t iTime = 0; iTime < AliTRDtrackerV1::GetNTimeBins(); iTime++) { | |
376 | if(!(layer = chamber->GetTB(iTime))) continue; | |
377 | if(!(ncl = Int_t(*layer))) continue; | |
378 | for(int ic=0; ic<ncl; ic++){ | |
379 | cc = (*layer)[ic]; | |
380 | det = cc->GetDetector(); | |
381 | new(clusters[ncls++]) AliTRDcluster(*cc); | |
382 | } | |
383 | } | |
ae4e8b84 | 384 | AliInfo(Form("N clusters[%d] = %d", fDet, ncls)); |
29b87567 | 385 | |
386 | Int_t ref = c ? 1 : 0; | |
387 | TTreeSRedirector &cstreamer = *AliTRDtrackerV1::DebugStreamer(); | |
388 | cstreamer << "AttachClustersIter" | |
389 | << "det=" << det | |
390 | << "ref=" << ref | |
391 | << "clusters.=" << &clusters | |
392 | << "tracklet.=" << this | |
393 | << "cl.=" << c | |
394 | << "\n"; | |
395 | } | |
396 | ||
397 | Float_t tquality; | |
398 | Double_t kroady = fReconstructor->GetRecoParam() ->GetRoad1y(); | |
399 | Double_t kroadz = fPadLength * .5 + 1.; | |
400 | ||
401 | // initialize configuration parameters | |
402 | Float_t zcorr = kZcorr ? fTilt * (fZProb - fZref[0]) : 0.; | |
403 | Int_t niter = kZcorr ? 1 : 2; | |
404 | ||
405 | Double_t yexp, zexp; | |
406 | Int_t ncl = 0; | |
407 | // start seed update | |
408 | for (Int_t iter = 0; iter < niter; iter++) { | |
409 | ncl = 0; | |
410 | for (Int_t iTime = 0; iTime < AliTRDtrackerV1::GetNTimeBins(); iTime++) { | |
411 | if(!(layer = chamber->GetTB(iTime))) continue; | |
412 | if(!Int_t(*layer)) continue; | |
413 | ||
414 | // define searching configuration | |
415 | Double_t dxlayer = layer->GetX() - fX0; | |
416 | if(c){ | |
417 | zexp = c->GetZ(); | |
418 | //Try 2 pad-rows in second iteration | |
419 | if (iter > 0) { | |
420 | zexp = fZref[0] + fZref[1] * dxlayer - zcorr; | |
421 | if (zexp > c->GetZ()) zexp = c->GetZ() + fPadLength*0.5; | |
422 | if (zexp < c->GetZ()) zexp = c->GetZ() - fPadLength*0.5; | |
423 | } | |
424 | } else zexp = fZref[0] + (kZcorr ? fZref[1] * dxlayer : 0.); | |
425 | yexp = fYref[0] + fYref[1] * dxlayer - zcorr; | |
426 | ||
427 | // Get and register cluster | |
428 | Int_t index = layer->SearchNearestCluster(yexp, zexp, kroady, kroadz); | |
429 | if (index < 0) continue; | |
430 | AliTRDcluster *cl = (*layer)[index]; | |
431 | ||
432 | fIndexes[iTime] = layer->GetGlobalIndex(index); | |
433 | fClusters[iTime] = cl; | |
434 | fY[iTime] = cl->GetY(); | |
435 | fZ[iTime] = cl->GetZ(); | |
436 | ncl++; | |
437 | } | |
ae4e8b84 | 438 | if(fReconstructor->GetStreamLevel(AliTRDReconstructor::kTracker)>=7) AliInfo(Form("iter = %d ncl [%d] = %d", iter, fDet, ncl)); |
29b87567 | 439 | |
440 | if(ncl>1){ | |
441 | // calculate length of the time bin (calibration aware) | |
442 | Int_t irp = 0; Float_t x[2]; Int_t tb[2]; | |
443 | for (Int_t iTime = 0; iTime < AliTRDtrackerV1::GetNTimeBins(); iTime++) { | |
444 | if(!fClusters[iTime]) continue; | |
445 | x[irp] = fClusters[iTime]->GetX(); | |
446 | tb[irp] = iTime; | |
447 | irp++; | |
448 | if(irp==2) break; | |
449 | } | |
450 | fdX = (x[1] - x[0]) / (tb[0] - tb[1]); | |
451 | ||
452 | // update X0 from the clusters (calibration/alignment aware) | |
453 | for (Int_t iTime = 0; iTime < AliTRDtrackerV1::GetNTimeBins(); iTime++) { | |
454 | if(!(layer = chamber->GetTB(iTime))) continue; | |
455 | if(!layer->IsT0()) continue; | |
456 | if(fClusters[iTime]){ | |
457 | fX0 = fClusters[iTime]->GetX(); | |
458 | break; | |
459 | } else { // we have to infere the position of the anode wire from the other clusters | |
460 | for (Int_t jTime = iTime+1; jTime < AliTRDtrackerV1::GetNTimeBins(); jTime++) { | |
461 | if(!fClusters[jTime]) continue; | |
462 | fX0 = fClusters[jTime]->GetX() + fdX * (jTime - iTime); | |
463 | } | |
464 | break; | |
465 | } | |
466 | } | |
467 | ||
468 | // update YZ reference point | |
469 | // TODO | |
470 | ||
471 | // update x reference positions (calibration/alignment aware) | |
472 | for (Int_t iTime = 0; iTime < AliTRDtrackerV1::GetNTimeBins(); iTime++) { | |
473 | if(!fClusters[iTime]) continue; | |
474 | fX[iTime] = fClusters[iTime]->GetX() - fX0; | |
475 | } | |
476 | ||
477 | AliTRDseed::Update(); | |
478 | } | |
ae4e8b84 | 479 | if(fReconstructor->GetStreamLevel(AliTRDReconstructor::kTracker)>=7) AliInfo(Form("iter = %d nclFit [%d] = %d", iter, fDet, fN2)); |
29b87567 | 480 | |
481 | if(IsOK()){ | |
482 | tquality = GetQuality(kZcorr); | |
483 | if(tquality < quality) break; | |
484 | else quality = tquality; | |
485 | } | |
486 | kroadz *= 2.; | |
487 | } // Loop: iter | |
488 | if (!IsOK()) return kFALSE; | |
489 | ||
804bb02e | 490 | if(fReconstructor->GetStreamLevel(AliTRDReconstructor::kTracker)>=1) CookLabels(); |
29b87567 | 491 | UpdateUsed(); |
492 | return kTRUE; | |
e4f2f73d | 493 | } |
494 | ||
495 | //____________________________________________________________________ | |
eb38ed55 | 496 | Bool_t AliTRDseedV1::AttachClusters(AliTRDtrackingChamber *chamber |
29b87567 | 497 | ,Bool_t kZcorr) |
e4f2f73d | 498 | { |
499 | // | |
500 | // Projective algorithm to attach clusters to seeding tracklets | |
501 | // | |
502 | // Parameters | |
503 | // | |
504 | // Output | |
505 | // | |
506 | // Detailed description | |
507 | // 1. Collapse x coordinate for the full detector plane | |
508 | // 2. truncated mean on y (r-phi) direction | |
509 | // 3. purge clusters | |
510 | // 4. truncated mean on z direction | |
511 | // 5. purge clusters | |
512 | // 6. fit tracklet | |
513 | // | |
514 | ||
29b87567 | 515 | if(!fReconstructor->GetRecoParam() ){ |
516 | AliError("Seed can not be used without a valid RecoParam."); | |
517 | return kFALSE; | |
518 | } | |
519 | ||
520 | const Int_t kClusterCandidates = 2 * knTimebins; | |
521 | ||
522 | //define roads | |
523 | Double_t kroady = fReconstructor->GetRecoParam() ->GetRoad1y(); | |
524 | Double_t kroadz = fPadLength * 1.5 + 1.; | |
525 | // correction to y for the tilting angle | |
526 | Float_t zcorr = kZcorr ? fTilt * (fZProb - fZref[0]) : 0.; | |
527 | ||
528 | // working variables | |
529 | AliTRDcluster *clusters[kClusterCandidates]; | |
530 | Double_t cond[4], yexp[knTimebins], zexp[knTimebins], | |
531 | yres[kClusterCandidates], zres[kClusterCandidates]; | |
532 | Int_t ncl, *index = 0x0, tboundary[knTimebins]; | |
533 | ||
534 | // Do cluster projection | |
535 | AliTRDchamberTimeBin *layer = 0x0; | |
536 | Int_t nYclusters = 0; Bool_t kEXIT = kFALSE; | |
537 | for (Int_t iTime = 0; iTime < AliTRDtrackerV1::GetNTimeBins(); iTime++) { | |
538 | if(!(layer = chamber->GetTB(iTime))) continue; | |
539 | if(!Int_t(*layer)) continue; | |
540 | ||
541 | fX[iTime] = layer->GetX() - fX0; | |
542 | zexp[iTime] = fZref[0] + fZref[1] * fX[iTime]; | |
543 | yexp[iTime] = fYref[0] + fYref[1] * fX[iTime] - zcorr; | |
544 | ||
545 | // build condition and process clusters | |
546 | cond[0] = yexp[iTime] - kroady; cond[1] = yexp[iTime] + kroady; | |
547 | cond[2] = zexp[iTime] - kroadz; cond[3] = zexp[iTime] + kroadz; | |
548 | layer->GetClusters(cond, index, ncl); | |
549 | for(Int_t ic = 0; ic<ncl; ic++){ | |
550 | AliTRDcluster *c = layer->GetCluster(index[ic]); | |
551 | clusters[nYclusters] = c; | |
552 | yres[nYclusters++] = c->GetY() - yexp[iTime]; | |
553 | if(nYclusters >= kClusterCandidates) { | |
554 | AliWarning(Form("Cluster candidates reached limit %d. Some may be lost.", kClusterCandidates)); | |
555 | kEXIT = kTRUE; | |
556 | break; | |
557 | } | |
558 | } | |
559 | tboundary[iTime] = nYclusters; | |
560 | if(kEXIT) break; | |
561 | } | |
562 | ||
563 | // Evaluate truncated mean on the y direction | |
564 | Double_t mean, sigma; | |
565 | AliMathBase::EvaluateUni(nYclusters, yres, mean, sigma, Int_t(nYclusters*.8)-2); | |
566 | // purge cluster candidates | |
567 | Int_t nZclusters = 0; | |
568 | for(Int_t ic = 0; ic<nYclusters; ic++){ | |
569 | if(yres[ic] - mean > 4. * sigma){ | |
570 | clusters[ic] = 0x0; | |
571 | continue; | |
572 | } | |
573 | zres[nZclusters++] = clusters[ic]->GetZ() - zexp[clusters[ic]->GetLocalTimeBin()]; | |
574 | } | |
575 | ||
576 | // Evaluate truncated mean on the z direction | |
577 | AliMathBase::EvaluateUni(nZclusters, zres, mean, sigma, Int_t(nZclusters*.8)-2); | |
578 | // purge cluster candidates | |
579 | for(Int_t ic = 0; ic<nZclusters; ic++){ | |
580 | if(zres[ic] - mean > 4. * sigma){ | |
581 | clusters[ic] = 0x0; | |
582 | continue; | |
583 | } | |
584 | } | |
585 | ||
586 | ||
587 | // Select only one cluster/TimeBin | |
588 | Int_t lastCluster = 0; | |
589 | fN2 = 0; | |
590 | for (Int_t iTime = 0; iTime < AliTRDtrackerV1::GetNTimeBins(); iTime++) { | |
591 | ncl = tboundary[iTime] - lastCluster; | |
592 | if(!ncl) continue; | |
593 | Int_t iptr = lastCluster; | |
594 | if(ncl > 1){ | |
595 | Float_t dold = 9999.; | |
596 | for(int ic=lastCluster; ic<tboundary[iTime]; ic++){ | |
597 | if(!clusters[ic]) continue; | |
598 | Float_t y = yexp[iTime] - clusters[ic]->GetY(); | |
599 | Float_t z = zexp[iTime] - clusters[ic]->GetZ(); | |
600 | Float_t d = y * y + z * z; | |
601 | if(d > dold) continue; | |
602 | dold = d; | |
603 | iptr = ic; | |
604 | } | |
605 | } | |
606 | fIndexes[iTime] = chamber->GetTB(iTime)->GetGlobalIndex(iptr); | |
607 | fClusters[iTime] = clusters[iptr]; | |
608 | fY[iTime] = clusters[iptr]->GetY(); | |
609 | fZ[iTime] = clusters[iptr]->GetZ(); | |
610 | lastCluster = tboundary[iTime]; | |
611 | fN2++; | |
612 | } | |
613 | ||
614 | // number of minimum numbers of clusters expected for the tracklet | |
615 | Int_t kClmin = Int_t(fReconstructor->GetRecoParam() ->GetFindableClusters()*AliTRDtrackerV1::GetNTimeBins()); | |
e4f2f73d | 616 | if (fN2 < kClmin){ |
29b87567 | 617 | AliWarning(Form("Not enough clusters to fit the tracklet %d [%d].", fN2, kClmin)); |
e4f2f73d | 618 | fN2 = 0; |
619 | return kFALSE; | |
620 | } | |
0906e73e | 621 | |
29b87567 | 622 | // update used clusters |
623 | fNUsed = 0; | |
624 | for (Int_t iTime = 0; iTime < AliTRDtrackerV1::GetNTimeBins(); iTime++) { | |
625 | if(!fClusters[iTime]) continue; | |
626 | if((fClusters[iTime]->IsUsed())) fNUsed++; | |
627 | } | |
0906e73e | 628 | |
629 | if (fN2-fNUsed < kClmin){ | |
29b87567 | 630 | AliWarning(Form("Too many clusters already in use %d (from %d).", fNUsed, fN2)); |
0906e73e | 631 | fN2 = 0; |
632 | return kFALSE; | |
633 | } | |
29b87567 | 634 | |
635 | return kTRUE; | |
e4f2f73d | 636 | } |
637 | ||
638 | //____________________________________________________________________ | |
d2b9977a | 639 | Bool_t AliTRDseedV1::Fit(Bool_t tilt) |
e4f2f73d | 640 | { |
641 | // | |
642 | // Linear fit of the tracklet | |
643 | // | |
644 | // Parameters : | |
645 | // | |
646 | // Output : | |
647 | // True if successful | |
648 | // | |
649 | // Detailed description | |
650 | // 2. Check if tracklet crosses pad row boundary | |
651 | // 1. Calculate residuals in the y (r-phi) direction | |
652 | // 3. Do a Least Square Fit to the data | |
653 | // | |
654 | ||
29b87567 | 655 | const Int_t kClmin = 8; |
ae4e8b84 | 656 | const Float_t q0 = 100.; |
657 | const Float_t clSigma0 = 2.E-2; //[cm] | |
658 | const Float_t clSlopeQ = -1.19E-2; //[1/cm] | |
659 | ||
660 | ||
29b87567 | 661 | const Int_t kNtb = AliTRDtrackerV1::GetNTimeBins(); |
662 | AliTRDtrackerV1::AliTRDLeastSquare fitterY, fitterZ; | |
663 | ||
664 | // convertion factor from square to gauss distribution for sigma | |
665 | Double_t convert = 1./TMath::Sqrt(12.); | |
ae4e8b84 | 666 | |
29b87567 | 667 | // book cluster information |
668 | Double_t xc[knTimebins+1], yc[knTimebins], zc[knTimebins+1], sy[knTimebins], sz[knTimebins+1]; | |
669 | Int_t zRow[knTimebins]; | |
670 | AliTRDcluster *c = 0x0; | |
671 | Int_t nc = 0; | |
672 | for (Int_t ic=0; ic<kNtb; ic++) { | |
673 | zRow[ic] = -1; | |
674 | xc[ic] = -1.; | |
675 | yc[ic] = 999.; | |
676 | zc[ic] = 999.; | |
677 | sy[ic] = 0.; | |
678 | sz[ic] = 0.; | |
679 | if(!(c = fClusters[ic])) continue; | |
680 | if(!c->IsInChamber()) continue; | |
681 | Float_t w = 1.; | |
682 | if(c->GetNPads()>4) w = .5; | |
683 | if(c->GetNPads()>5) w = .2; | |
684 | zRow[nc] = c->GetPadRow(); | |
d2b9977a | 685 | xc[nc] = c->GetX() - fX0; |
29b87567 | 686 | yc[nc] = c->GetY(); |
687 | zc[nc] = c->GetZ(); | |
ae4e8b84 | 688 | Float_t qr = c->GetQ() - q0; |
689 | sy[nc] = qr < 0. ? clSigma0*TMath::Exp(clSlopeQ*qr) : clSigma0; | |
2eafa911 | 690 | sz[nc] = fPadLength*convert; |
691 | fitterZ.AddPoint(&xc[nc], zc[nc], sz[nc]); | |
29b87567 | 692 | nc++; |
693 | } | |
47d5d320 | 694 | // to few clusters |
29b87567 | 695 | if (nc < kClmin) return kFALSE; |
696 | ||
e4f2f73d | 697 | |
29b87567 | 698 | Int_t zN[2*35]; |
47d5d320 | 699 | Int_t nz = AliTRDtrackerV1::Freq(nc, zRow, zN, kFALSE); |
29b87567 | 700 | // more than one pad row crossing |
701 | if(nz>2) return kFALSE; | |
702 | ||
703 | // estimate reference parameter at average x | |
704 | Double_t y0 = fYref[0]; | |
705 | Double_t dydx = fYref[1]; | |
706 | Double_t dzdx = fZref[1]; | |
707 | zc[nc] = fZref[0]; | |
708 | ||
709 | // determine z offset of the fit | |
710 | Int_t nchanges = 0, nCross = 0; | |
711 | if(nz==2){ // tracklet is crossing pad row | |
712 | // Find the break time allowing one chage on pad-rows | |
713 | // with maximal number of accepted clusters | |
714 | Int_t padRef = zRow[0]; | |
715 | for (Int_t ic=1; ic<nc; ic++) { | |
716 | if(zRow[ic] == padRef) continue; | |
717 | ||
718 | // debug | |
719 | if(zRow[ic-1] == zRow[ic]){ | |
720 | printf("ERROR in pad row change!!!\n"); | |
721 | } | |
722 | ||
723 | // evaluate parameters of the crossing point | |
724 | Float_t sx = (xc[ic-1] - xc[ic])*convert; | |
725 | xc[nc] = .5 * (xc[ic-1] + xc[ic]); | |
726 | zc[nc] = .5 * (zc[ic-1] + zc[ic]); | |
727 | sz[nc] = TMath::Max(dzdx * sx, .01); | |
728 | dzdx = zc[ic-1] > zc[ic] ? 1. : -1.; | |
729 | padRef = zRow[ic]; | |
730 | nCross = ic; | |
731 | nchanges++; | |
732 | } | |
733 | } | |
734 | ||
735 | // condition on nCross and reset nchanges TODO | |
736 | ||
737 | if(nchanges==1){ | |
738 | if(dzdx * fZref[1] < 0.){ | |
739 | AliInfo("tracklet direction does not correspond to the track direction. TODO."); | |
740 | } | |
741 | SetBit(kRowCross, kTRUE); // mark pad row crossing | |
742 | fCross[0] = xc[nc]; fCross[2] = zc[nc]; fCross[3] = sz[nc]; | |
743 | fitterZ.AddPoint(&xc[nc], zc[nc], sz[nc]); | |
744 | fitterZ.Eval(); | |
745 | dzdx = fZref[1]; // we don't trust Parameter[1] ??; | |
746 | zc[nc] = fitterZ.GetFunctionParameter(0); | |
747 | } else if(nchanges > 1){ // debug | |
748 | AliInfo("ERROR in n changes!!!"); | |
749 | return kFALSE; | |
750 | } | |
751 | ||
752 | ||
753 | // estimate deviation from reference direction | |
754 | dzdx *= fTilt; | |
755 | for (Int_t ic=0; ic<nc; ic++) { | |
d2b9977a | 756 | yc[ic] -= (y0 + xc[ic]*dydx); |
757 | if(tilt) yc[ic] -= (xc[ic]*dzdx + fTilt * (zc[ic] - zc[nc])); | |
29b87567 | 758 | fitterY.AddPoint(&xc[ic], yc[ic], sy[ic]); |
759 | } | |
760 | fitterY.Eval(); | |
761 | fYfit[0] = y0+fitterY.GetFunctionParameter(0); | |
762 | fYfit[1] = dydx+fitterY.GetFunctionParameter(1); | |
d2b9977a | 763 | |
29b87567 | 764 | if(nchanges) fCross[1] = fYfit[0] + fCross[0] * fYfit[1]; |
e4f2f73d | 765 | |
47d5d320 | 766 | // printf("\nnz = %d\n", nz); |
767 | // for(int ic=0; ic<35; ic++) printf("%d row[%d]\n", ic, zRow[ic]); | |
768 | // | |
769 | // for(int ic=0; ic<nz; ic++) printf("%d n[%d]\n", ic, zN[ic]); | |
e4f2f73d | 770 | |
29b87567 | 771 | return kTRUE; |
e4f2f73d | 772 | } |
773 | ||
47d5d320 | 774 | //___________________________________________________________________ |
775 | void AliTRDseedV1::Draw(Option_t*) | |
776 | { | |
777 | } | |
e4f2f73d | 778 | |
779 | //___________________________________________________________________ | |
47d5d320 | 780 | void AliTRDseedV1::Print(Option_t*) const |
e4f2f73d | 781 | { |
782 | // | |
783 | // Printing the seedstatus | |
784 | // | |
785 | ||
29b87567 | 786 | printf("Seed status :\n"); |
787 | printf(" fTilt = %f\n", fTilt); | |
788 | printf(" fPadLength = %f\n", fPadLength); | |
789 | printf(" fX0 = %f\n", fX0); | |
790 | for(int ic=0; ic<AliTRDtrackerV1::GetNTimeBins(); ic++) { | |
e4f2f73d | 791 | const Char_t *isUsable = fUsable[ic]?"Yes":"No"; |
29b87567 | 792 | printf(" %d X[%f] Y[%f] Z[%f] Indexes[%d] clusters[%p] usable[%s]\n" |
e4f2f73d | 793 | , ic |
794 | , fX[ic] | |
795 | , fY[ic] | |
796 | , fZ[ic] | |
797 | , fIndexes[ic] | |
0906e73e | 798 | , ((void*) fClusters[ic]) |
e4f2f73d | 799 | , isUsable); |
800 | } | |
801 | ||
29b87567 | 802 | printf(" fYref[0] =%f fYref[1] =%f\n", fYref[0], fYref[1]); |
803 | printf(" fZref[0] =%f fZref[1] =%f\n", fZref[0], fZref[1]); | |
804 | printf(" fYfit[0] =%f fYfit[1] =%f\n", fYfit[0], fYfit[1]); | |
805 | printf(" fYfitR[0]=%f fYfitR[1]=%f\n", fYfitR[0], fYfitR[1]); | |
806 | printf(" fZfit[0] =%f fZfit[1] =%f\n", fZfit[0], fZfit[1]); | |
807 | printf(" fZfitR[0]=%f fZfitR[1]=%f\n", fZfitR[0], fZfitR[1]); | |
808 | printf(" fSigmaY =%f\n", fSigmaY); | |
809 | printf(" fSigmaY2=%f\n", fSigmaY2); | |
810 | printf(" fMeanz =%f\n", fMeanz); | |
811 | printf(" fZProb =%f\n", fZProb); | |
812 | printf(" fLabels[0]=%d fLabels[1]=%d\n", fLabels[0], fLabels[1]); | |
813 | printf(" fN =%d\n", fN); | |
814 | printf(" fN2 =%d (>8 isOK)\n",fN2); | |
815 | printf(" fNUsed =%d\n", fNUsed); | |
816 | printf(" fFreq =%d\n", fFreq); | |
817 | printf(" fNChange=%d\n", fNChange); | |
818 | printf(" fMPads =%f\n", fMPads); | |
819 | ||
820 | printf(" fC =%f\n", fC); | |
821 | printf(" fCC =%f\n",fCC); | |
822 | printf(" fChi2 =%f\n", fChi2); | |
823 | printf(" fChi2Z =%f\n", fChi2Z); | |
e4f2f73d | 824 | } |
47d5d320 | 825 |