]>
Commit | Line | Data |
---|---|---|
0ee00e25 | 1 | /************************************************************************** |
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 | **************************************************************************/ | |
15 | ||
16 | /////////////////////////////////////////////////////////////////////////////// | |
17 | // // | |
18 | // TRD trigger class // | |
19 | // // | |
20 | /////////////////////////////////////////////////////////////////////////////// | |
21 | ||
22 | #include <TTree.h> | |
23 | #include <TBranch.h> | |
24 | #include <TMatrixD.h> | |
25 | ||
26 | #include "AliLog.h" | |
27 | #include "AliRun.h" | |
28 | #include "AliRunLoader.h" | |
29 | #include "AliLoader.h" | |
30 | #include "AliHeader.h" | |
31 | #include "AliRawReader.h" | |
32 | ||
33 | #include "AliTRDdigitsManager.h" | |
34 | #include "AliTRDgeometry.h" | |
35 | #include "AliTRDdataArrayI.h" | |
36 | #include "AliTRDcalibDB.h" | |
37 | #include "AliTRDCommonParam.h" | |
38 | #include "Cal/AliTRDCalPIDLQ.h" | |
39 | #include "AliTRDrawData.h" | |
40 | ||
41 | #include "AliTRDtrigger.h" | |
42 | #include "AliTRDmcmTracklet.h" | |
43 | #include "AliTRDtrigParam.h" | |
44 | #include "AliTRDmcm.h" | |
45 | ||
46 | ClassImp(AliTRDtrigger) | |
47 | ClassImp(AliTRDltuTracklet) | |
48 | ClassImp(AliTRDgtuTrack) | |
49 | ClassImp(AliTRDmodule) | |
50 | ||
51 | //_____________________________________________________________________________ | |
52 | AliTRDltuTracklet::AliTRDltuTracklet(Int_t det, | |
53 | Int_t row, | |
54 | Float_t rowz, | |
55 | Float_t slope, | |
56 | Float_t offset, | |
57 | Float_t time, | |
58 | Int_t ncl, | |
59 | Int_t label, | |
60 | Float_t q) | |
61 | { | |
62 | // | |
63 | // AliTRDltuTracklet constructor | |
64 | // | |
65 | ||
66 | fDetector = det; | |
67 | fRow = row; | |
68 | fRowz = rowz; | |
69 | fSlope = slope; | |
70 | fX = time; | |
71 | fY = offset; | |
72 | fNclusters = ncl; | |
73 | fLabel = label; | |
74 | fQ = q; | |
75 | ||
76 | } | |
77 | ||
78 | //_____________________________________________________________________________ | |
79 | Float_t AliTRDltuTracklet::GetPt(Float_t field) | |
80 | { | |
81 | // transverse momentum calculation | |
82 | // curvature R = (fX*fX + fY*fY) / (2 * sin(alpha)) | |
83 | // alpha = angle deviation from "infinite momentum" | |
84 | // | |
85 | // consistent with AliTRDmcmTracklet::GetPt(...) | |
86 | ||
87 | Float_t InfSlope = TMath::ATan(fY/fX)/TMath::Pi()*180.0; | |
88 | Float_t alpha = fSlope - InfSlope; | |
89 | Float_t R = TMath::Sqrt(fX*fX + fY*fY)/(2.0*TMath::Sin(alpha/180.0*TMath::Pi())); | |
90 | ||
91 | Float_t Pt = 0.3 * field * 0.01 * R; | |
92 | ||
93 | return Pt; | |
94 | ||
95 | } | |
96 | ||
97 | //_____________________________________________________________________________ | |
98 | Int_t AliTRDltuTracklet::Compare(const TObject * o) const | |
99 | { | |
100 | // | |
101 | // compare two LTU tracklets according to the intercept point Y1 | |
102 | // | |
103 | ||
104 | AliTRDltuTracklet *ltutrk = (AliTRDltuTracklet*)o; | |
105 | ||
106 | if (fRow != ltutrk->fRow) return +1; | |
107 | if (fDetector != ltutrk->fDetector) return +1; | |
108 | ||
109 | if (fY < ltutrk->fY) return -1; | |
110 | if (fY == ltutrk->fY) return 0; | |
111 | ||
112 | return 1; | |
113 | ||
114 | } | |
115 | ||
116 | //_____________________________________________________________________________ | |
117 | Float_t AliTRDltuTracklet::GetYproj(Float_t xpl) | |
118 | { | |
119 | ||
120 | Float_t Yproj; | |
121 | ||
122 | Yproj = fY + TMath::Tan(fSlope/180.0*TMath::Pi()) * (xpl - fX); | |
123 | ||
124 | return Yproj; | |
125 | ||
126 | } | |
127 | ||
128 | //_____________________________________________________________________________ | |
129 | Float_t AliTRDltuTracklet::GetZproj(Float_t xpl) | |
130 | { | |
131 | ||
132 | Float_t Zproj; | |
133 | ||
134 | Zproj = fRowz * xpl / fX; | |
135 | ||
136 | return Zproj; | |
137 | ||
138 | } | |
139 | ||
140 | //_____________________________________________________________________________ | |
141 | AliTRDgtuTrack::AliTRDgtuTrack() | |
142 | { | |
143 | ||
144 | fYproj = 0.0; | |
145 | fZproj = 0.0; | |
146 | fSlope = 0.0; | |
147 | fDetector = -1; | |
148 | fNtracklets = 0; | |
149 | fNplanes = 0; | |
150 | fNclusters = 0; | |
151 | fPt = 0.0; | |
152 | fPhi = 0.0; | |
153 | fEta = 0.0; | |
154 | fLabel = -1; | |
155 | fPID = 0.0; | |
156 | fIsElectron = kFALSE; | |
157 | ||
158 | fTracklets = new TObjArray(400); | |
159 | ||
160 | } | |
161 | ||
162 | //_____________________________________________________________________________ | |
163 | AliTRDgtuTrack::AliTRDgtuTrack(const AliTRDgtuTrack& track): | |
164 | TObject(track), | |
165 | fYproj(track.fYproj), | |
166 | fZproj(track.fZproj), | |
167 | fSlope(track.fSlope), | |
168 | fDetector(track.fDetector), | |
169 | fNtracklets(track.fNtracklets), | |
170 | fNplanes(track.fNplanes), | |
171 | fNclusters(track.fNclusters), | |
172 | fPt(track.fPt), | |
173 | fPhi(track.fPhi), | |
174 | fEta(track.fEta), | |
175 | fLabel(track.fLabel), | |
176 | fPID(track.fPID), | |
177 | fIsElectron(track.fIsElectron) | |
178 | { | |
179 | // | |
180 | // copy contructor | |
181 | // | |
182 | ||
183 | fTracklets = NULL; | |
184 | ||
185 | } | |
186 | ||
187 | //_____________________________________________________________________________ | |
188 | void AliTRDgtuTrack::AddTracklet(AliTRDltuTracklet *trk) | |
189 | { | |
190 | ||
191 | Tracklets()->Add(trk); | |
192 | ||
193 | } | |
194 | ||
195 | //_____________________________________________________________________________ | |
196 | AliTRDltuTracklet* AliTRDgtuTrack::GetTracklet(Int_t pos) | |
197 | { | |
198 | ||
199 | if (fTracklets == 0) return 0; | |
200 | void * trk = fTracklets->UncheckedAt(pos); | |
201 | if (trk == 0) return 0; | |
202 | ||
203 | return (AliTRDltuTracklet*)trk; | |
204 | ||
205 | } | |
206 | ||
207 | //_____________________________________________________________________________ | |
208 | Int_t AliTRDgtuTrack::Compare(const TObject * o) const | |
209 | { | |
210 | ||
211 | AliTRDgtuTrack *gtutrack = (AliTRDgtuTrack*)o; | |
212 | ||
213 | if (fYproj < gtutrack->GetYproj()) return -1; | |
214 | if (fYproj == gtutrack->GetYproj()) return 0; | |
215 | ||
216 | return +1; | |
217 | ||
218 | } | |
219 | ||
220 | //_____________________________________________________________________________ | |
221 | void AliTRDgtuTrack::Reset() | |
222 | { | |
223 | ||
224 | fYproj = 0.0; | |
225 | fZproj = 0.0; | |
226 | fSlope = 0.0; | |
227 | fDetector = -1; | |
228 | fNtracklets = 0; | |
229 | fNplanes = 0; | |
230 | fNclusters = 0; | |
231 | fPt = 0.0; | |
232 | fPhi = 0.0; | |
233 | fEta = 0.0; | |
234 | fLabel = -1; | |
235 | fPID = 0.0; | |
236 | fIsElectron = kFALSE; | |
237 | ||
238 | } | |
239 | ||
240 | //_____________________________________________________________________________ | |
241 | void AliTRDgtuTrack::Track(Float_t xpl, Float_t field) | |
242 | { | |
243 | ||
244 | AliTRDltuTracklet *trk; | |
245 | Int_t nTracklets = GetNtracklets(); | |
246 | Float_t fC[kNmaxTrk][3]; // X, Y, Z coordinates of segments | |
247 | ||
248 | fYproj = 0.0; | |
249 | fZproj = 0.0; | |
250 | fSlope = 0.0; | |
251 | fNclusters = 0; | |
252 | fNplanes = 0; | |
253 | fNtracklets = GetNtracklets(); | |
254 | Int_t InDetector[kNplan]; | |
255 | for (Int_t i = 0; i < kNplan; i++) InDetector[i] = -1; | |
256 | Int_t iDet, nDet = 0; | |
257 | Bool_t NewDetector; | |
258 | for (Int_t i = 0; i < nTracklets; i++) { | |
259 | ||
260 | trk = GetTracklet(i); | |
261 | fYproj += trk->GetYproj(xpl); | |
262 | fZproj += trk->GetZproj(xpl); | |
263 | fSlope += trk->GetSlope(); | |
264 | fNclusters += trk->GetNclusters(); | |
265 | iDet = trk->GetDetector(); | |
266 | ||
267 | NewDetector = kTRUE; | |
268 | for (Int_t id = 0; id < nDet; id++) { | |
269 | if (iDet == InDetector[id]) { | |
270 | NewDetector = kFALSE; | |
271 | break; | |
272 | } | |
273 | } | |
274 | if (NewDetector) { | |
275 | InDetector[nDet++] = iDet; | |
276 | fNplanes++; | |
277 | } | |
278 | ||
279 | fC[i][0] = trk->GetTime0(); | |
280 | fC[i][1] = trk->GetOffset(); | |
281 | fC[i][2] = trk->GetRowz(); | |
282 | ||
283 | } | |
284 | fYproj /= (Float_t)nTracklets; | |
285 | fZproj /= (Float_t)nTracklets; | |
286 | fSlope /= (Float_t)nTracklets; | |
287 | ||
288 | Float_t X[kNmaxTrk+1], Y[kNmaxTrk+1], Z[kNmaxTrk+1]; | |
289 | Bool_t count[kNmaxTrk]; | |
290 | for (Int_t i = 0; i < kNmaxTrk; i++) count[i] = kFALSE; | |
291 | ||
292 | Int_t iXmin = -1; | |
293 | Int_t j = 0; | |
294 | X[0] = Y[0] = Z[0] = 0.0; | |
295 | while (j < nTracklets) { | |
296 | iXmin = -1; | |
297 | for (Int_t i = 0; i < nTracklets; i++) { | |
298 | if (count[i]) continue; | |
299 | if (iXmin == -1) { | |
300 | iXmin = i; | |
301 | continue; | |
302 | } | |
303 | if (fC[i][0] < fC[iXmin][0]) iXmin = i; | |
304 | } | |
305 | X[j+1] = fC[iXmin][0]; | |
306 | Y[j+1] = fC[iXmin][1]; | |
307 | Z[j+1] = fC[iXmin][2]; | |
308 | j++; | |
309 | count[iXmin] = kTRUE; | |
310 | } | |
311 | ||
312 | TMatrixD smatrix(2,2); | |
313 | TMatrixD sums(2,1); | |
314 | TMatrixD res(2,1); | |
315 | Double_t x, y; | |
316 | Float_t A, B; | |
317 | ||
318 | smatrix.Zero(); | |
319 | sums.Zero(); | |
320 | for (Int_t i = 0; i < nTracklets; i++) { | |
321 | x = (Double_t)X[i+1]; | |
322 | y = (Double_t)Y[i+1]; | |
323 | smatrix(0,0) += 1.0; | |
324 | smatrix(1,1) += x*x; | |
325 | smatrix(0,1) += x; | |
326 | smatrix(1,0) += x; | |
327 | sums(0,0) += y; | |
328 | sums(1,0) += x*y; | |
329 | } | |
330 | res = smatrix.Invert() * sums; | |
331 | A = res(0,0); | |
332 | B = res(1,0); | |
333 | ||
334 | Float_t dist = AliTRDgeometry::GetTime0(1) - AliTRDgeometry::GetTime0(0); | |
335 | ||
336 | Float_t fX1 = X[1] + dist * (Float_t)(nTracklets-1)/6.0; | |
337 | Float_t fY1 = A + B * fX1; | |
338 | Float_t fX2 = X[nTracklets] - dist * (Float_t)(nTracklets-1)/6.0; | |
339 | Float_t fY2 = A + B * fX2; | |
340 | Float_t D12 = TMath::Sqrt((fX2-fX1)*(fX2-fX1)+(fY2-fY1)*(fY2-fY1)); | |
341 | Float_t Alpha = TMath::ATan(fY2/fX2) - TMath::ATan(fY1/fX1); | |
342 | Float_t R = (D12/2.0)/TMath::Sin(Alpha); | |
343 | ||
344 | fPt = 0.3 * field * 0.01 * R; | |
345 | ||
346 | Float_t D1 = fX1*fX1+fY1*fY1; | |
347 | Float_t D2 = fX2*fX2+fY2*fY2; | |
348 | Float_t D = fX1*fY2-fX2*fY1; | |
349 | ||
350 | Float_t Xc = (D1*fY2-D2*fY1)/(2*D); | |
351 | Float_t Yc = (D2*fX1-D1*fX2)/(2*D); | |
352 | ||
353 | if (Yc != 0.0) { | |
354 | fPhi = TMath::ATan(Xc/Yc); | |
355 | } else { | |
356 | fPhi = TMath::PiOver2(); | |
357 | } | |
358 | ||
359 | fPhi *= 180.0/TMath::Pi(); | |
360 | ||
361 | smatrix.Zero(); | |
362 | sums.Zero(); | |
363 | for (Int_t i = 0; i < nTracklets+1; i++) { | |
364 | x = (Double_t)Z[i]; | |
365 | y = (Double_t)X[i]; | |
366 | smatrix(0,0) += 1.0; | |
367 | smatrix(1,1) += x*x; | |
368 | smatrix(0,1) += x; | |
369 | smatrix(1,0) += x; | |
370 | sums(0,0) += y; | |
371 | sums(1,0) += x*y; | |
372 | } | |
373 | res = smatrix.Invert() * sums; | |
374 | A = res(0,0); | |
375 | B = res(1,0); | |
376 | Float_t theta = TMath::ATan(B); | |
377 | ||
378 | if (theta < 0.0) theta = TMath::Pi() + theta; | |
379 | ||
380 | if (theta == 0.0) { | |
381 | fEta = 0.0; | |
382 | } else { | |
383 | fEta = -TMath::Log(TMath::Tan(theta/2.0)); | |
384 | } | |
385 | ||
386 | } | |
387 | ||
388 | //_____________________________________________________________________________ | |
389 | void AliTRDgtuTrack::MakePID() | |
390 | { | |
391 | ||
392 | // | |
393 | // Electron likelihood signal | |
394 | // | |
395 | ||
396 | AliTRDcalibDB* calibration = AliTRDcalibDB::Instance(); | |
397 | if (!calibration) | |
398 | { | |
399 | Error("MakePID","No instance of AliTRDcalibDB."); | |
400 | return; | |
401 | } | |
402 | const AliTRDCalPIDLQ *pd = calibration->GetPIDLQObject(); | |
403 | ||
404 | AliTRDltuTracklet *trk; | |
405 | Int_t nTracklets = GetNtracklets(); | |
406 | Int_t det, pla; | |
407 | Float_t sl, th, q, probPio = 1.0, probEle = 1.0; | |
408 | for (Int_t i = 0; i < nTracklets; i++) { | |
409 | ||
410 | trk = GetTracklet(i); | |
411 | ||
412 | sl = TMath::Abs(trk->GetSlope()); // tracklet inclination in X-y plane | |
413 | th = trk->GetRowz()/trk->GetTime0(); // tracklet inclination in X-z plane | |
414 | th = TMath::ATan(TMath::Abs(th)); | |
415 | ||
416 | q = trk->GetQ() | |
417 | * TMath::Cos(sl/180.0*TMath::Pi()) | |
418 | * TMath::Cos(th/180.0*TMath::Pi()); | |
419 | ||
420 | det = trk->GetDetector(); | |
421 | pla = trk->GetPlane(det); | |
422 | ||
423 | // unclear yet factor to match the PS distributions = 5.8 | |
424 | // not explained only by the tail filter ... | |
425 | ||
426 | // AliRoot v4-03-07 , v4-03-Release | |
427 | //q = q * 5.8; | |
428 | ||
429 | // Temporary (B. Vulpescu): | |
430 | // The charge distributions do not match the new changes in simulation (A. Bercuci), | |
431 | // which are nevertheless now in agreement with the beam tests. | |
432 | // Some tricks will be used to still have reasonable results | |
433 | // To match the existing charge distributions, the charge per layer has to be modified | |
434 | // as folows: | |
435 | /* | |
436 | if (k == 0) { | |
437 | // electrons | |
438 | q = 4.3 * q + 95.0; | |
439 | } else { | |
440 | // others | |
441 | q = 4.2 * q + 70.0; | |
442 | } | |
443 | */ | |
444 | // Since at tracking time we have no information on the particle type, we will modify | |
445 | // instead the charge distributions accordingly. This will slow down the sampling. | |
446 | // The modified distributions are in TRDdEdxHistogramsV1_BV.root and the CDB has | |
447 | // been regenerated with AliTRDCreateDummyCDB.C | |
448 | // The new PIDLQ data base has the version : | |
449 | // I-AliCDBLocal::Get: CDB object retrieved: path "TRD/Calib/PIDLQ"; run range [0,0]; | |
450 | // version v0_s1 | |
451 | ||
452 | probEle *= pd->GetProbability(0,TMath::Abs(fPt),q); | |
453 | probPio *= pd->GetProbability(2,TMath::Abs(fPt),q); | |
454 | ||
455 | } | |
456 | ||
457 | if ((probEle+probPio) > 0.0) { | |
458 | fPID = probEle/(probEle+probPio); | |
459 | } else { | |
460 | fPID = 0.0; | |
461 | } | |
462 | ||
463 | // Thresholds for LQ cut at 90% electron efficiency (from AliRoot v4-03-07) | |
464 | // P [GeV/c] fPIDcut (between 0 and 1) | |
465 | // 2 0.925 | |
466 | // 3 0.915 | |
467 | // 4 0.875 | |
468 | // 5 0.855 | |
469 | // 6 0.845 | |
470 | // 8 0.785 | |
471 | // 10 0.735 | |
472 | // | |
473 | // PIDcut = 0.978 - 0.024 * P[GeV/c] | |
474 | //Float_t PIDcut = 0.978 - 0.024 * TMath::Abs(fPt); | |
475 | ||
476 | // HEAD28Mar06 with modified distributions (A. Bercuci changes, P. Shukla distributions) | |
477 | Float_t PIDcut = 0.829 - 0.032 * TMath::Abs(fPt); | |
478 | ||
479 | fIsElectron = kFALSE; | |
480 | if (fPID >= PIDcut) { | |
481 | fIsElectron = kTRUE; | |
482 | } | |
483 | ||
484 | } | |
485 | ||
486 | //_____________________________________________________________________________ | |
487 | void AliTRDgtuTrack::CookLabel() | |
488 | { | |
489 | ||
490 | // | |
491 | // Cook the track label from tracklets labels | |
492 | // | |
493 | ||
494 | AliTRDltuTracklet *trk; | |
495 | ||
496 | const Int_t kMaxTracks = 10; | |
497 | Int_t trackLabel[kMaxTracks]; | |
498 | Int_t trackCount[kMaxTracks]; | |
499 | for (Int_t it = 0; it < kMaxTracks; it++) { | |
500 | trackLabel[it] = -1; | |
501 | trackCount[it] = 0; | |
502 | } | |
503 | ||
504 | Bool_t counted; | |
505 | Int_t label, nTracks = 0; | |
506 | for (Int_t itrk = 0; itrk < fNtracklets; itrk++) { | |
507 | ||
508 | trk = GetTracklet(itrk); | |
509 | ||
510 | if (trk->GetLabel() == -1) continue; | |
511 | ||
512 | label = trk->GetLabel(); | |
513 | ||
514 | counted = kFALSE; | |
515 | for (Int_t it = 0; it < nTracks; it++) { | |
516 | if (label == trackLabel[it]) { | |
517 | trackCount[it]++; | |
518 | counted = kTRUE; | |
519 | break; | |
520 | } | |
521 | } | |
522 | if (!counted) { | |
523 | trackLabel[nTracks] = label; | |
524 | trackCount[nTracks]++; | |
525 | nTracks++; | |
526 | if (nTracks == kMaxTracks) { | |
527 | Warning("CookLabel","Too many tracks for this tracklet."); | |
528 | nTracks--; | |
529 | break; | |
530 | } | |
531 | } | |
532 | ||
533 | } | |
534 | ||
535 | Float_t frac = 4.0/5.0; | |
536 | for (Int_t it = 0; it < kMaxTracks; it++) { | |
537 | if (trackCount[it] >= (Int_t)(frac*fNtracklets)) { | |
538 | fLabel = trackLabel[it]; | |
539 | break; | |
540 | } | |
541 | } | |
542 | ||
543 | } | |
544 | ||
545 | //_____________________________________________________________________________ | |
546 | AliTRDmodule::AliTRDmodule(AliTRDtrigParam *trigp) | |
547 | { | |
548 | ||
549 | // | |
550 | // AliTRDmodule default constructor | |
551 | // | |
552 | ||
553 | fDeltaY = trigp->GetDeltaY(); | |
554 | fDeltaS = trigp->GetDeltaS(); | |
555 | fXprojPlane = trigp->GetXprojPlane(); | |
556 | fField = trigp->GetField(); | |
557 | fLTUtrk = 0; | |
558 | fGTUtrk = 0; | |
559 | fTracklets = new TObjArray(400); | |
560 | fTracks = new TObjArray(400); | |
561 | ||
562 | } | |
563 | ||
564 | //_____________________________________________________________________________ | |
565 | void AliTRDmodule::Reset() | |
566 | { | |
567 | ||
568 | ResetTracklets(); | |
569 | ResetTracks(); | |
570 | ||
571 | fLTUtrk = 0; | |
572 | fGTUtrk = 0; | |
573 | fTracklets = new TObjArray(400); | |
574 | fTracks = new TObjArray(400); | |
575 | ||
576 | } | |
577 | ||
578 | //_____________________________________________________________________________ | |
579 | void AliTRDmodule::ResetTracks() | |
580 | { | |
581 | ||
582 | if (fTracks) { | |
583 | ||
584 | AliTRDgtuTrack *trk; | |
585 | for (Int_t i = 0; i < GetNtracks(); i++) { | |
586 | ||
587 | trk = GetTrack(i); | |
588 | trk->Reset(); | |
589 | ||
590 | } | |
591 | ||
592 | fTracks->Delete(); | |
593 | ||
594 | } | |
595 | ||
596 | } | |
597 | ||
598 | //_____________________________________________________________________________ | |
599 | AliTRDgtuTrack* AliTRDmodule::GetTrack(Int_t pos) | |
600 | { | |
601 | ||
602 | if (fTracks == 0) return 0; | |
603 | void * trk = fTracks->UncheckedAt(pos); | |
604 | if (trk == 0) return 0; | |
605 | ||
606 | return (AliTRDgtuTrack*)trk; | |
607 | ||
608 | } | |
609 | ||
610 | //_____________________________________________________________________________ | |
611 | void AliTRDmodule::RemoveTrack(Int_t pos) | |
612 | { | |
613 | ||
614 | if (fTracks == 0) return; | |
615 | fTracks->RemoveAt(pos); | |
616 | fTracks->Compress(); | |
617 | ||
618 | } | |
619 | ||
620 | //_____________________________________________________________________________ | |
621 | void AliTRDmodule::AddTracklet(Int_t det, | |
622 | Int_t row, | |
623 | Float_t rowz, | |
624 | Float_t slope, | |
625 | Float_t offset, | |
626 | Float_t time, | |
627 | Int_t ncl, | |
628 | Int_t label, | |
629 | Float_t q) | |
630 | { | |
631 | ||
632 | fLTUtrk = new AliTRDltuTracklet(det,row,rowz,slope,offset,time,ncl,label,q); | |
633 | ||
634 | Tracklets()->Add(fLTUtrk); | |
635 | ||
636 | } | |
637 | ||
638 | //_____________________________________________________________________________ | |
639 | AliTRDltuTracklet* AliTRDmodule::GetTracklet(Int_t pos) | |
640 | { | |
641 | ||
642 | if (fTracklets == 0) return 0; | |
643 | void * trk = fTracklets->UncheckedAt(pos); | |
644 | if (trk == 0) return 0; | |
645 | ||
646 | return (AliTRDltuTracklet*)trk; | |
647 | ||
648 | } | |
649 | ||
650 | //_____________________________________________________________________________ | |
651 | void AliTRDmodule::RemoveTracklet(Int_t pos) | |
652 | { | |
653 | ||
654 | if (fTracklets == 0) return; | |
655 | fTracklets->RemoveAt(pos); | |
656 | fTracklets->Compress(); | |
657 | ||
658 | } | |
659 | ||
660 | //_____________________________________________________________________________ | |
661 | void AliTRDmodule::RemoveMultipleTracklets() | |
662 | { | |
663 | ||
664 | Float_t OffDiffMin = 0.5; // [cm] | |
665 | ||
666 | AliTRDltuTracklet *trk; | |
667 | Int_t Det1, Det2, Row1, Row2, Ncl1, Ncl2, Label1, Label2; | |
668 | Float_t Off1, Off2; | |
669 | Int_t itrk = 0; | |
670 | while (itrk < (GetNtracklets()-1)) { | |
671 | ||
672 | trk = GetTracklet(itrk ); | |
673 | ||
674 | Det1 = trk->GetDetector(); | |
675 | Row1 = trk->GetRow(); | |
676 | Off1 = trk->GetOffset(); | |
677 | Ncl1 = trk->GetNclusters(); | |
678 | Label1 = trk->GetLabel(); | |
679 | ||
680 | trk = GetTracklet(itrk+1); | |
681 | ||
682 | Det2 = trk->GetDetector(); | |
683 | Row2 = trk->GetRow(); | |
684 | Off2 = trk->GetOffset(); | |
685 | Ncl2 = trk->GetNclusters(); | |
686 | Label2 = trk->GetLabel(); | |
687 | ||
688 | if (Det1 == Det2 && Row1 == Row2) { | |
689 | if ((Off2-Off1) < OffDiffMin) { | |
690 | if (Ncl1 < Ncl2) { | |
691 | RemoveTracklet(itrk ); | |
692 | } else { | |
693 | RemoveTracklet(itrk+1); | |
694 | } | |
695 | } | |
696 | } | |
697 | ||
698 | itrk++; | |
699 | ||
700 | } | |
701 | ||
702 | } | |
703 | ||
704 | //_____________________________________________________________________________ | |
705 | void AliTRDmodule::SortZ(Int_t cha) | |
706 | { | |
707 | ||
708 | InitZLUT(); | |
709 | ||
710 | AliTRDltuTracklet *trk; | |
711 | Int_t row, pla, det; | |
712 | for (Int_t iTrk = 0; iTrk < GetNtracklets(); iTrk++) { | |
713 | ||
714 | trk = GetTracklet(iTrk); | |
715 | ||
716 | row = trk->GetRow(); | |
717 | det = trk->GetDetector(); | |
718 | pla = trk->GetPlane(det); | |
719 | ||
720 | for (Int_t iZchan = 0; iZchan < kNsubZchan; iZchan++) { | |
721 | if (fZChannelMap[cha][iZchan][pla][row] == 1) { | |
722 | fZtrkid[pla][fZnchan[pla][iZchan]][iZchan] = iTrk; | |
723 | fZnchan[pla][iZchan]++; | |
724 | } | |
725 | } | |
726 | ||
727 | } | |
728 | ||
729 | } | |
730 | ||
731 | //_____________________________________________________________________________ | |
732 | void AliTRDmodule::InitZLUT() | |
733 | { | |
734 | ||
735 | for (Int_t iPlan = 0; iPlan < AliTRDgeometry::Nplan(); iPlan++) { | |
736 | for (Int_t i = 0; i < kNsubZchan; i++) { | |
737 | fZnchan[iPlan][i] = 0; | |
738 | for (Int_t j = 0; j < kNmaxZchan; j++) { | |
739 | fZtrkid[iPlan][j][i] = -1; | |
740 | } | |
741 | } | |
742 | } | |
743 | ||
744 | } | |
745 | ||
746 | //_____________________________________________________________________________ | |
747 | void AliTRDmodule::FindTracks() | |
748 | { | |
749 | ||
750 | for (Int_t iZchan = 0; iZchan < kNsubZchan; iZchan++) { | |
751 | FindTracksCombi(iZchan); | |
752 | } | |
753 | ||
754 | } | |
755 | ||
756 | //_____________________________________________________________________________ | |
757 | void AliTRDmodule::FindTracksCombi(Int_t zchan) | |
758 | { | |
759 | ||
760 | // | |
761 | // find tracks by pure combinatorics... | |
762 | // | |
763 | ||
764 | static Int_t TrkTrack[12]; | |
765 | ||
766 | Int_t nTracklets, nPlanes; | |
767 | Int_t Ntrk1, TrkId1, Ntrk2, TrkId2; | |
768 | Float_t Y1, Y1min, Y1max, S1, Z1, S1min, S1max, Y2, S2, Z2; | |
769 | AliTRDltuTracklet *Trk1; | |
770 | AliTRDltuTracklet *Trk2; | |
771 | AliTRDltuTracklet *Trk ; | |
772 | ||
773 | Bool_t IsPlane[kNplan]; | |
774 | ||
775 | for (Int_t iPlan1 = 0; iPlan1 < kNplan; iPlan1++) { | |
776 | ||
777 | Ntrk1 = fZnchan[iPlan1][zchan]; | |
778 | ||
779 | for (Int_t iTrk1 = 0; iTrk1 < Ntrk1; iTrk1++) { | |
780 | ||
781 | for (Int_t iPlan = 0; iPlan < kNplan; iPlan++) IsPlane[iPlan] = kFALSE; | |
782 | ||
783 | TrkId1 = fZtrkid[iPlan1][iTrk1][zchan]; | |
784 | ||
785 | nTracklets = 0; | |
786 | for (Int_t iList = 0; iList < kNmaxTrk; iList++) { | |
787 | TrkTrack[iList] = -1; | |
788 | } | |
789 | ||
790 | TrkTrack[nTracklets++] = TrkId1; | |
791 | ||
792 | IsPlane[iPlan1] = kTRUE; | |
793 | ||
794 | Trk1 = GetTracklet(TrkId1); | |
795 | ||
796 | Y1 = Trk1->GetYproj(fXprojPlane); | |
797 | Y1min = Y1 - fDeltaY; | |
798 | Y1max = Y1 + fDeltaY; | |
799 | S1 = Trk1->GetSlope(); | |
800 | S1min = S1 - fDeltaS; | |
801 | S1max = S1 + fDeltaS; | |
802 | Z1 = Trk1->GetZproj(fXprojPlane); | |
803 | ||
804 | for (Int_t iPlan2 = 0; iPlan2 < kNplan; iPlan2++) { | |
805 | ||
806 | if (iPlan2 == iPlan1) continue; | |
807 | ||
808 | Ntrk2 = fZnchan[iPlan2][zchan]; | |
809 | ||
810 | for (Int_t iTrk2 = 0; iTrk2 < Ntrk2; iTrk2++) { | |
811 | ||
812 | TrkId2 = fZtrkid[iPlan2][iTrk2][zchan]; | |
813 | ||
814 | if (TrkId2 == TrkId1) continue; | |
815 | ||
816 | Trk2 = GetTracklet(TrkId2); | |
817 | ||
818 | Y2 = Trk2->GetYproj(fXprojPlane); | |
819 | S2 = Trk2->GetSlope(); | |
820 | Z2 = Trk2->GetZproj(fXprojPlane); | |
821 | ||
822 | if ((Y1min < Y2 && Y2 < Y1max) && | |
823 | (S1min < S2 && S2 < S1max)) { | |
824 | ||
825 | if (nTracklets >= kNmaxTrk) { | |
826 | Warning("FindTracksCombi","Too many tracklets for this track."); | |
827 | } else { | |
828 | TrkTrack[nTracklets++] = TrkId2; | |
829 | IsPlane[iPlan2] = kTRUE; | |
830 | } | |
831 | ||
832 | } | |
833 | ||
834 | } // end trk 2 | |
835 | ||
836 | } // end plan 2 | |
837 | ||
838 | nPlanes = 0; | |
839 | for (Int_t iPlan = 0; iPlan < kNplan; iPlan++) { | |
840 | nPlanes += (Int_t)IsPlane[iPlan]; | |
841 | } | |
842 | ||
843 | if (nPlanes >= 4) { | |
844 | ||
845 | Int_t Cha1, Cha2, Npoints1, Npoints2; | |
846 | for (Int_t iList = 0; iList < (nTracklets-1); iList++) { | |
847 | ||
848 | if (TrkTrack[iList] == -1 || TrkTrack[iList+1] == -1) continue; | |
849 | Trk1 = GetTracklet(TrkTrack[iList ]); | |
850 | Trk2 = GetTracklet(TrkTrack[iList+1]); | |
851 | ||
852 | Cha1 = Trk1->GetDetector(); | |
853 | Cha2 = Trk2->GetDetector(); | |
854 | if (Cha1 != Cha2) continue; | |
855 | ||
856 | Npoints1 = Trk1->GetNclusters(); | |
857 | Npoints2 = Trk2->GetNclusters(); | |
858 | ||
859 | if (Npoints1 == Npoints2) { | |
860 | TrkTrack[iList] = -1; | |
861 | } else { | |
862 | if (Npoints1 > Npoints2) TrkTrack[iList+1] = -1; | |
863 | if (Npoints1 < Npoints2) TrkTrack[iList ] = -1; | |
864 | } | |
865 | ||
866 | } | |
867 | ||
868 | fGTUtrk = new AliTRDgtuTrack(); | |
869 | for (Int_t iList = 0; iList < nTracklets; iList++) { | |
870 | if (TrkTrack[iList] == -1) continue; | |
871 | Trk = GetTracklet(TrkTrack[iList]); | |
872 | fGTUtrk->AddTracklet(Trk); | |
873 | } | |
874 | fGTUtrk->Track(fXprojPlane,fField); | |
875 | AddTrack(); | |
876 | } | |
877 | ||
878 | } // end trk 1 | |
879 | ||
880 | } // end plan 1 | |
881 | ||
882 | } | |
883 | ||
884 | //_____________________________________________________________________________ | |
885 | void AliTRDmodule::AddTrack() | |
886 | { | |
887 | ||
888 | Tracks()->Add(fGTUtrk); | |
889 | ||
890 | } | |
891 | ||
892 | //_____________________________________________________________________________ | |
893 | void AliTRDmodule::RemoveMultipleTracks() | |
894 | { | |
895 | ||
896 | AliTRDgtuTrack *trk1; | |
897 | AliTRDgtuTrack *trk2; | |
898 | ||
899 | Float_t Yproj1, Yproj2, Alpha1, Alpha2; | |
900 | Int_t ntrk1, ntrk2; | |
901 | Int_t iTrack = 0; | |
902 | ||
903 | while (iTrack < (GetNtracks()-1)) { | |
904 | ||
905 | trk1 = GetTrack(iTrack ); | |
906 | trk2 = GetTrack(iTrack+1); | |
907 | ||
908 | ntrk1 = trk1->GetNtracklets(); | |
909 | Yproj1 = trk1->GetYproj(); | |
910 | Alpha1 = trk1->GetSlope(); | |
911 | ntrk2 = trk2->GetNtracklets(); | |
912 | Yproj2 = trk2->GetYproj(); | |
913 | Alpha2 = trk2->GetSlope(); | |
914 | ||
915 | if (TMath::Abs(Yproj1-Yproj2) < fDeltaY && TMath::Abs(Alpha1-Alpha2) < fDeltaS) { | |
916 | if (ntrk1 < ntrk2) { | |
917 | RemoveTrack(iTrack ); | |
918 | } else { | |
919 | RemoveTrack(iTrack+1); | |
920 | } | |
921 | } else { | |
922 | iTrack++; | |
923 | } | |
924 | ||
925 | } | |
926 | ||
927 | } | |
928 | ||
929 | //_____________________________________________________________________________ | |
930 | AliTRDtrigger::AliTRDtrigger(): | |
931 | TNamed(), | |
932 | fTracks("AliTRDgtuTrack",0) | |
933 | { | |
934 | // | |
935 | // AliTRDtrigger default constructor | |
936 | // | |
937 | ||
938 | fDigitsManager = NULL; | |
939 | fTrackletTree = NULL; | |
940 | fTracklets = NULL; | |
941 | ||
942 | fNROB = 0; | |
943 | fTrigParam = NULL; | |
944 | fMCM = NULL; | |
945 | fTrk = NULL; | |
946 | fGTUtrk = NULL; | |
947 | ||
948 | fNtracklets = 0; | |
949 | ||
950 | fDigits = NULL; | |
951 | fTrack0 = NULL; | |
952 | fTrack1 = NULL; | |
953 | fTrack2 = NULL; | |
954 | ||
955 | fModule = NULL; | |
956 | ||
957 | fNPrimary = 0; | |
958 | ||
959 | } | |
960 | ||
961 | //_____________________________________________________________________________ | |
962 | AliTRDtrigger::AliTRDtrigger(const Text_t *name, const Text_t *title): | |
963 | TNamed(name,title), | |
964 | fTracks("AliTRDgtuTrack",1000) | |
965 | { | |
966 | // | |
967 | // AliTRDtrigger constructor | |
968 | // | |
969 | ||
970 | fDigitsManager = new AliTRDdigitsManager(); | |
971 | fTrackletTree = NULL; | |
972 | fTracklets = new TObjArray(400); | |
973 | ||
974 | fNROB = 0; | |
975 | fTrigParam = NULL; | |
976 | fMCM = NULL; | |
977 | fTrk = NULL; | |
978 | fGTUtrk = NULL; | |
979 | ||
980 | fNtracklets = 0; | |
981 | ||
982 | fDigits = NULL; | |
983 | fTrack0 = NULL; | |
984 | fTrack1 = NULL; | |
985 | fTrack2 = NULL; | |
986 | ||
987 | fModule = NULL; | |
988 | ||
989 | fNPrimary = 0; | |
990 | ||
991 | } | |
992 | ||
993 | //_____________________________________________________________________________ | |
994 | AliTRDtrigger::AliTRDtrigger(const AliTRDtrigger &p):TNamed(p) | |
995 | { | |
996 | // | |
997 | // AliTRDtrigger copy constructor | |
998 | // | |
999 | ||
1000 | ((AliTRDtrigger &) p).Copy(*this); | |
1001 | ||
1002 | } | |
1003 | ||
1004 | ///_____________________________________________________________________________ | |
1005 | AliTRDtrigger::~AliTRDtrigger() | |
1006 | { | |
1007 | // | |
1008 | // AliTRDtrigger destructor | |
1009 | // | |
1010 | ||
1011 | if (fTracklets) { | |
1012 | fTracklets->Delete(); | |
1013 | delete fTracklets; | |
1014 | } | |
1015 | ||
1016 | fTracks.Delete(); | |
1017 | ||
1018 | } | |
1019 | ||
1020 | //_____________________________________________________________________________ | |
1021 | AliTRDtrigger &AliTRDtrigger::operator=(const AliTRDtrigger &p) | |
1022 | { | |
1023 | // | |
1024 | // Assignment operator | |
1025 | // | |
1026 | ||
1027 | if (this != &p) ((AliTRDtrigger &) p).Copy(*this); | |
1028 | return *this; | |
1029 | ||
1030 | } | |
1031 | ||
1032 | //_____________________________________________________________________________ | |
1033 | void AliTRDtrigger::Copy(TObject &) const | |
1034 | { | |
1035 | // | |
1036 | // Copy function | |
1037 | // | |
1038 | ||
1039 | AliFatal("Not implemented"); | |
1040 | ||
1041 | } | |
1042 | ||
1043 | //_____________________________________________________________________________ | |
1044 | void AliTRDtrigger::Init() | |
1045 | { | |
1046 | ||
1047 | fModule = new AliTRDmodule(fTrigParam); | |
1048 | /* | |
1049 | AliHeader *header = fRunLoader->GetHeader(); | |
1050 | fNPrimary = header->GetNprimary(); | |
1051 | */ | |
1052 | fTracks.Clear(); | |
1053 | ||
1054 | } | |
1055 | ||
1056 | //_____________________________________________________________________________ | |
1057 | Bool_t AliTRDtrigger::Open(const Char_t *name, Int_t nEvent) | |
1058 | { | |
1059 | // | |
1060 | // Opens the AliROOT file. | |
1061 | // | |
1062 | ||
1063 | TString evfoldname = AliConfig::GetDefaultEventFolderName(); | |
1064 | fRunLoader = AliRunLoader::GetRunLoader(evfoldname); | |
1065 | ||
1066 | if (!fRunLoader) | |
1067 | fRunLoader = AliRunLoader::Open(name); | |
1068 | ||
1069 | if (!fRunLoader) { | |
1070 | Error("Open","Can not open session for file %s.",name); | |
1071 | return kFALSE; | |
1072 | } | |
1073 | ||
1074 | // Open input | |
1075 | ||
1076 | if (fRunLoader->GetAliRun() == 0x0) fRunLoader->LoadgAlice(); | |
1077 | gAlice = fRunLoader->GetAliRun(); | |
1078 | ||
1079 | if (!(gAlice)) { | |
1080 | fRunLoader->LoadgAlice(); | |
1081 | gAlice = fRunLoader->GetAliRun(); | |
1082 | if (!(gAlice)) { | |
1083 | Error("Open","Could not find AliRun object."); | |
1084 | return kFALSE; | |
1085 | } | |
1086 | } | |
1087 | ||
1088 | // Import the Trees for the event nEvent in the file | |
1089 | fRunLoader->GetEvent(nEvent); | |
1090 | ||
1091 | // Open output | |
1092 | ||
1093 | TObjArray *ioArray = 0; | |
1094 | ||
1095 | AliLoader* loader = fRunLoader->GetLoader("TRDLoader"); | |
1096 | loader->MakeTree("T"); | |
1097 | fTrackletTree = loader->TreeT(); | |
1098 | fTrackletTree->Branch("TRDmcmTracklet","TObjArray",&ioArray,32000,0); | |
1099 | ||
1100 | fRunLoader->LoadHeader(); | |
1101 | ||
1102 | Init(); | |
1103 | ||
1104 | return kTRUE; | |
1105 | ||
1106 | } | |
1107 | ||
1108 | ||
1109 | //_____________________________________________________________________________ | |
1110 | Bool_t AliTRDtrigger::ReadDigits() | |
1111 | { | |
1112 | // | |
1113 | // Reads the digits arrays from the input aliroot file | |
1114 | // | |
1115 | ||
1116 | if (!fRunLoader) { | |
1117 | Error("ReadDigits","Can not find the Run Loader"); | |
1118 | return kFALSE; | |
1119 | } | |
1120 | ||
1121 | AliLoader* loader = fRunLoader->GetLoader("TRDLoader"); | |
1122 | if (!loader->TreeD()) loader->LoadDigits(); | |
1123 | ||
1124 | return (fDigitsManager->ReadDigits(loader->TreeD())); | |
1125 | ||
1126 | } | |
1127 | ||
1128 | //_____________________________________________________________________________ | |
1129 | Bool_t AliTRDtrigger::ReadDigits(AliRawReader* rawReader) | |
1130 | { | |
1131 | // | |
1132 | // Reads the digits arrays from the ddl file | |
1133 | // | |
1134 | ||
1135 | AliTRDrawData *raw = new AliTRDrawData(); | |
1136 | raw->SetDebug(1); | |
1137 | ||
1138 | fDigitsManager = raw->Raw2Digits(rawReader); | |
1139 | ||
1140 | return kTRUE; | |
1141 | ||
1142 | } | |
1143 | ||
1144 | //_____________________________________________________________________________ | |
1145 | Bool_t AliTRDtrigger::ReadTracklets(AliRunLoader *rl) | |
1146 | { | |
1147 | // | |
1148 | // Reads the tracklets find the tracks | |
1149 | // | |
1150 | ||
1151 | Int_t idet; | |
1152 | ||
1153 | AliLoader *loader = rl->GetLoader("TRDLoader"); | |
1154 | loader->LoadTracks(); | |
1155 | fTrackletTree = loader->TreeT(); | |
1156 | ||
1157 | TBranch *branch = fTrackletTree->GetBranch("TRDmcmTracklet"); | |
1158 | if (!branch) { | |
1159 | Error("ReadTracklets","Can't get the branch !"); | |
1160 | return kFALSE; | |
1161 | } | |
1162 | TObjArray *tracklets = new TObjArray(400); | |
1163 | branch->SetAddress(&tracklets); | |
1164 | ||
1165 | Int_t nEntries = (Int_t) fTrackletTree->GetEntries(); | |
1166 | Int_t iEntry, itrk; | |
1167 | Int_t iStack, iStackPrev = -1; | |
1168 | ||
1169 | for (iEntry = 0; iEntry < nEntries; iEntry++) { | |
1170 | fTrackletTree->GetEvent(iEntry); | |
1171 | ||
1172 | for (itrk = 0; itrk < tracklets->GetEntriesFast(); itrk++){ | |
1173 | ||
1174 | fTrk = (AliTRDmcmTracklet*)tracklets->UncheckedAt(itrk); | |
1175 | ||
1176 | idet = fTrk->GetDetector(); | |
1177 | ||
1178 | iStack = idet / (AliTRDgeometry::Nplan()); | |
1179 | if (iStackPrev != iStack) { | |
1180 | if (iStackPrev == -1) { | |
1181 | iStackPrev = iStack; | |
1182 | } else { | |
1183 | MakeTracks(idet-AliTRDgeometry::Nplan()); | |
1184 | ResetTracklets(); | |
1185 | iStackPrev = iStack; | |
1186 | } | |
1187 | } | |
1188 | ||
1189 | Tracklets()->Add(fTrk); | |
1190 | ||
1191 | if (iEntry == (nEntries-1) && itrk == (tracklets->GetEntriesFast()-1)) { | |
1192 | idet++; | |
1193 | MakeTracks(idet-AliTRDgeometry::Nplan()); | |
1194 | ResetTracklets(); | |
1195 | } | |
1196 | ||
1197 | } | |
1198 | ||
1199 | } | |
1200 | ||
1201 | loader->UnloadTracks(); | |
1202 | ||
1203 | return kTRUE; | |
1204 | ||
1205 | } | |
1206 | ||
1207 | //_____________________________________________________________________________ | |
1208 | Bool_t AliTRDtrigger::MakeTracklets() | |
1209 | { | |
1210 | ||
1211 | AliTRDcalibDB* calibration = AliTRDcalibDB::Instance(); | |
1212 | if (!calibration) | |
1213 | { | |
1214 | Error("MakeTracklets","No instance of AliTRDcalibDB."); | |
1215 | return kFALSE; | |
1216 | } | |
1217 | ||
1218 | AliTRDCommonParam* commonParam = AliTRDCommonParam::Instance(); | |
1219 | if (!commonParam) | |
1220 | { | |
1221 | Error("MakeTracklets","No common params."); | |
1222 | return kFALSE; | |
1223 | } | |
1224 | ||
1225 | AliTRDgeometry *geo = AliTRDgeometry::GetGeometry(fRunLoader); | |
1226 | ||
1227 | Int_t chamBeg = 0; | |
1228 | Int_t chamEnd = AliTRDgeometry::Ncham(); | |
1229 | Int_t planBeg = 0; | |
1230 | Int_t planEnd = AliTRDgeometry::Nplan(); | |
1231 | Int_t sectBeg = 0; | |
1232 | Int_t sectEnd = AliTRDgeometry::Nsect(); | |
1233 | ||
1234 | fMCM = new AliTRDmcm(fTrigParam,0); | |
1235 | ||
1236 | Int_t time, col, row, col1, col2; | |
1237 | Float_t amp; | |
1238 | Int_t idet, iStack, iStackPrev; | |
1239 | iStack = -1; | |
1240 | iStackPrev = -1; | |
1241 | for (Int_t isect = sectBeg; isect < sectEnd; isect++) { | |
1242 | ||
1243 | for (Int_t icham = chamBeg; icham < chamEnd; icham++) { | |
1244 | ||
1245 | // number of ROBs in the chamber | |
1246 | if( icham == 2 ) { | |
1247 | fNROB = 6; | |
1248 | } else { | |
1249 | fNROB = 8; | |
1250 | } | |
1251 | ||
1252 | for (Int_t iplan = planBeg; iplan < planEnd; iplan++) { | |
1253 | ||
1254 | idet = geo->GetDetector(iplan,icham,isect); | |
1255 | ResetTracklets(); | |
1256 | /* | |
1257 | iStack = idet / (AliTRDgeometry::Nplan()); | |
1258 | if (iStackPrev != iStack) { | |
1259 | if (iStackPrev == -1) { | |
1260 | iStackPrev = iStack; | |
1261 | } else { | |
1262 | MakeTracks(idet-AliTRDgeometry::Nplan()); | |
1263 | ResetTracklets(); | |
1264 | iStackPrev = iStack; | |
1265 | } | |
1266 | } | |
1267 | */ | |
1268 | Int_t nRowMax = commonParam->GetRowMax(iplan,icham,isect); | |
1269 | Int_t nColMax = commonParam->GetColMax(iplan); | |
1270 | Int_t nTimeTotal = calibration->GetNumberOfTimeBins(); | |
1271 | ||
1272 | // Get the digits | |
1273 | fDigits = fDigitsManager->GetDigits(idet); | |
1274 | fDigits->Expand(); | |
1275 | fTrack0 = fDigitsManager->GetDictionary(idet,0); | |
1276 | fTrack0->Expand(); | |
1277 | fTrack1 = fDigitsManager->GetDictionary(idet,1); | |
1278 | fTrack1->Expand(); | |
1279 | fTrack2 = fDigitsManager->GetDictionary(idet,2); | |
1280 | fTrack2->Expand(); | |
1281 | ||
1282 | ||
1283 | for (Int_t iRob = 0; iRob < fNROB; iRob++) { | |
1284 | ||
1285 | for (Int_t iMcm = 0; iMcm < kNMCM; iMcm++) { | |
1286 | ||
1287 | fMCM->Reset(); | |
1288 | ||
1289 | fMCM->SetRobId(iRob); | |
1290 | fMCM->SetChaId(idet); | |
1291 | ||
1292 | SetMCMcoordinates(iMcm); | |
1293 | ||
1294 | row = fMCM->GetRow(); | |
1295 | ||
1296 | if (row < 0 || row > nRowMax) { | |
1297 | Error("MakeTracklets","MCM row number out of range."); | |
1298 | } | |
1299 | ||
1300 | fMCM->GetColRange(col1,col2); | |
1301 | ||
1302 | for (time = 0; time < nTimeTotal; time++) { | |
1303 | for (col = col1; col < col2; col++) { | |
1304 | if (col >= 0 && col < nColMax) { | |
1305 | amp = TMath::Abs(fDigits->GetDataUnchecked(row,col,time)); | |
1306 | } else { | |
1307 | amp = 0.0; | |
1308 | } | |
1309 | fMCM->SetADC(col-col1,time,amp); | |
1310 | ||
1311 | } | |
1312 | } | |
1313 | ||
1314 | if (fTrigParam->GetTailCancelation()) { | |
1315 | fMCM->Filter(fTrigParam->GetNexponential(),fTrigParam->GetFilterType()); | |
1316 | } | |
1317 | ||
1318 | if (fMCM->Run()) { | |
1319 | ||
1320 | for (Int_t iSeed = 0; iSeed < kMaxTrackletsPerMCM; iSeed++) { | |
1321 | ||
1322 | if (fMCM->GetSeedCol()[iSeed] < 0) continue; | |
1323 | ||
1324 | if ( fTrigParam->GetDebugLevel() > 1 ) | |
1325 | printf("Add tracklet %d in col %02d \n",fNtracklets,fMCM->GetSeedCol()[iSeed]); | |
1326 | ||
1327 | if ( fTrigParam->GetDebugLevel() == -1 ) { | |
1328 | printf("Add tracklet %d in col %02d \n",fNtracklets,fMCM->GetSeedCol()[iSeed]); | |
1329 | for (time = 0; time < nTimeTotal; time++) { | |
1330 | for (col = 0; col < kMcmCol; col++) { | |
1331 | printf("%03.0f ",fMCM->GetADC(col,time)); | |
1332 | } | |
1333 | printf("\n"); | |
1334 | } | |
1335 | } | |
1336 | ||
1337 | AddTracklet(idet,row,iSeed,fNtracklets++); | |
1338 | ||
1339 | } | |
1340 | ||
1341 | } | |
1342 | ||
1343 | } | |
1344 | ||
1345 | ||
1346 | } | |
1347 | ||
1348 | // Compress the arrays | |
1349 | fDigits->Compress(1,0); | |
1350 | fTrack0->Compress(1,0); | |
1351 | fTrack1->Compress(1,0); | |
1352 | fTrack2->Compress(1,0); | |
1353 | ||
1354 | WriteTracklets(idet); | |
1355 | ||
1356 | } | |
1357 | } | |
1358 | } | |
1359 | /* | |
1360 | idet++; | |
1361 | MakeTracks(idet-AliTRDgeometry::Nplan()); | |
1362 | ResetTracklets(); | |
1363 | */ | |
1364 | return kTRUE; | |
1365 | ||
1366 | } | |
1367 | ||
1368 | //_____________________________________________________________________________ | |
1369 | void AliTRDtrigger::SetMCMcoordinates(Int_t imcm) | |
1370 | { | |
1371 | ||
1372 | Int_t robid = fMCM->GetRobId(); | |
1373 | ||
1374 | // setting the Row and Col range | |
1375 | ||
1376 | const Int_t kNcolRob = 2; // number of ROBs per chamber in column direction | |
1377 | const Int_t kNmcmRob = 4; // number of MCMs per ROB in column/row direction | |
1378 | ||
1379 | Int_t mcmid = imcm%(kNmcmRob*kNmcmRob); | |
1380 | ||
1381 | if (robid%kNcolRob == 0) { | |
1382 | ||
1383 | if ( mcmid%kNmcmRob == 0 ) { | |
1384 | fMCM->SetColRange(18*0-1,18*1-1+2+1); | |
1385 | } | |
1386 | if ( mcmid%kNmcmRob == 1 ) { | |
1387 | fMCM->SetColRange(18*1-1,18*2-1+2+1); | |
1388 | } | |
1389 | if ( mcmid%kNmcmRob == 2 ) { | |
1390 | fMCM->SetColRange(18*2-1,18*3-1+2+1); | |
1391 | } | |
1392 | if ( mcmid%kNmcmRob == 3 ) { | |
1393 | fMCM->SetColRange(18*3-1,18*4-1+2+1); | |
1394 | } | |
1395 | ||
1396 | } else { | |
1397 | ||
1398 | if ( mcmid%kNmcmRob == 0 ) { | |
1399 | fMCM->SetColRange(18*4-1,18*5-1+2+1); | |
1400 | } | |
1401 | if ( mcmid%kNmcmRob == 1 ) { | |
1402 | fMCM->SetColRange(18*5-1,18*6-1+2+1); | |
1403 | } | |
1404 | if ( mcmid%kNmcmRob == 2 ) { | |
1405 | fMCM->SetColRange(18*6-1,18*7-1+2+1); | |
1406 | } | |
1407 | if ( mcmid%kNmcmRob == 3 ) { | |
1408 | fMCM->SetColRange(18*7-1,18*8-1+2+1); | |
1409 | } | |
1410 | ||
1411 | } | |
1412 | ||
1413 | fMCM->SetRow(kNmcmRob*(robid/kNcolRob)+mcmid/kNmcmRob); | |
1414 | ||
1415 | } | |
1416 | ||
1417 | //_____________________________________________________________________________ | |
1418 | void AliTRDtrigger::AddTracklet(Int_t det, Int_t row, Int_t seed, Int_t n) | |
1419 | { | |
1420 | ||
1421 | Float_t field = fTrigParam->GetField(); | |
1422 | AliTRDgeometry *geo = (AliTRDgeometry*)AliTRDgeometry::GetGeometry(fRunLoader); | |
1423 | ||
1424 | AliTRDcalibDB* calibration = AliTRDcalibDB::Instance(); | |
1425 | if (!calibration) | |
1426 | { | |
1427 | Error("AddTracklets","No instance of AliTRDcalibDB."); | |
1428 | return; | |
1429 | } | |
1430 | ||
1431 | Int_t nTimeTotal = calibration->GetNumberOfTimeBins(); | |
1432 | ||
1433 | fTrk = new AliTRDmcmTracklet(det,row,n); | |
1434 | ||
1435 | Int_t iCol, iCol1, iCol2, track[3]; | |
1436 | iCol = fMCM->GetSeedCol()[seed]; // 0....20 (MCM) | |
1437 | fMCM->GetColRange(iCol1,iCol2); // range in the pad plane | |
1438 | ||
1439 | Float_t Amp[3]; | |
1440 | for (Int_t iTime = 0; iTime < nTimeTotal; iTime++) { | |
1441 | ||
1442 | Amp[0] = fMCM->GetADC(iCol-1,iTime); | |
1443 | Amp[1] = fMCM->GetADC(iCol ,iTime); | |
1444 | Amp[2] = fMCM->GetADC(iCol+1,iTime); | |
1445 | ||
1446 | // extract track contribution only from the central pad | |
1447 | track[0] = fTrack0->GetDataUnchecked(row,iCol+iCol1,iTime); | |
1448 | track[1] = fTrack1->GetDataUnchecked(row,iCol+iCol1,iTime); | |
1449 | track[2] = fTrack2->GetDataUnchecked(row,iCol+iCol1,iTime); | |
1450 | ||
1451 | if (fMCM->IsCluster(iCol,iTime)) { | |
1452 | ||
1453 | fTrk->AddCluster(iCol+iCol1,iTime,Amp,track); | |
1454 | ||
1455 | } else if ((iCol+1+1) < kMcmCol) { | |
1456 | ||
1457 | Amp[0] = fMCM->GetADC(iCol-1+1,iTime); | |
1458 | Amp[1] = fMCM->GetADC(iCol +1,iTime); | |
1459 | Amp[2] = fMCM->GetADC(iCol+1+1,iTime); | |
1460 | ||
1461 | if (fMCM->IsCluster(iCol+1,iTime)) { | |
1462 | ||
1463 | // extract track contribution only from the central pad | |
1464 | track[0] = fTrack0->GetDataUnchecked(row,iCol+1+iCol1,iTime); | |
1465 | track[1] = fTrack1->GetDataUnchecked(row,iCol+1+iCol1,iTime); | |
1466 | track[2] = fTrack2->GetDataUnchecked(row,iCol+1+iCol1,iTime); | |
1467 | ||
1468 | fTrk->AddCluster(iCol+1+iCol1,iTime,Amp,track); | |
1469 | ||
1470 | } | |
1471 | ||
1472 | } else { | |
1473 | } | |
1474 | ||
1475 | } | |
1476 | ||
1477 | fTrk->CookLabel(0.8); | |
1478 | /* | |
1479 | if (fTrk->GetLabel() >= fNPrimary) { | |
1480 | Info("AddTracklet","Only primaries are stored!"); | |
1481 | return; | |
1482 | } | |
1483 | */ | |
1484 | // LTU Pt cut | |
1485 | fTrk->MakeTrackletGraph(geo,field); | |
1486 | fTrk->MakeClusAmpGraph(); | |
1487 | if (TMath::Abs(fTrk->GetPt()) < fTrigParam->GetLtuPtCut()) return; | |
1488 | ||
1489 | Tracklets()->Add(fTrk); | |
1490 | ||
1491 | } | |
1492 | ||
1493 | //_____________________________________________________________________________ | |
1494 | Bool_t AliTRDtrigger::WriteTracklets(Int_t det) | |
1495 | { | |
1496 | // | |
1497 | // Fills TRDmcmTracklet branch in the tree with the Tracklets | |
1498 | // found in detector = det. For det=-1 writes the tree. | |
1499 | // | |
1500 | ||
1501 | if ((det < -1) || (det >= AliTRDgeometry::Ndet())) { | |
1502 | Error("WriteTracklets","Unexpected detector index %d.",det); | |
1503 | return kFALSE; | |
1504 | } | |
1505 | ||
1506 | TBranch *branch = fTrackletTree->GetBranch("TRDmcmTracklet"); | |
1507 | if (!branch) { | |
1508 | TObjArray *ioArray = 0; | |
1509 | branch = fTrackletTree->Branch("TRDmcmTracklet","TObjArray",&ioArray,32000,0); | |
1510 | } | |
1511 | ||
1512 | if ((det >= 0) && (det < AliTRDgeometry::Ndet())) { | |
1513 | ||
1514 | Int_t nTracklets = Tracklets()->GetEntriesFast(); | |
1515 | TObjArray *detTracklets = new TObjArray(400); | |
1516 | ||
1517 | for (Int_t i = 0; i < nTracklets; i++) { | |
1518 | AliTRDmcmTracklet *trk = (AliTRDmcmTracklet *) Tracklets()->UncheckedAt(i); | |
1519 | ||
1520 | if (det == trk->GetDetector()) { | |
1521 | detTracklets->AddLast(trk); | |
1522 | } | |
1523 | else { | |
1524 | } | |
1525 | } | |
1526 | ||
1527 | branch->SetAddress(&detTracklets); | |
1528 | fTrackletTree->Fill(); | |
1529 | ||
1530 | delete detTracklets; | |
1531 | ||
1532 | return kTRUE; | |
1533 | ||
1534 | } | |
1535 | ||
1536 | if (det == -1) { | |
1537 | ||
1538 | Info("WriteTracklets","Writing the Tracklet tree %s for event %d." | |
1539 | ,fTrackletTree->GetName(),fRunLoader->GetEventNumber()); | |
1540 | ||
1541 | AliLoader* loader = fRunLoader->GetLoader("TRDLoader"); | |
1542 | loader->WriteTracks("OVERWRITE"); | |
1543 | ||
1544 | return kTRUE; | |
1545 | ||
1546 | } | |
1547 | ||
1548 | return kFALSE; | |
1549 | ||
1550 | } | |
1551 | ||
1552 | //_____________________________________________________________________________ | |
1553 | void AliTRDtrigger::MakeTracks(Int_t det) | |
1554 | { | |
1555 | // | |
1556 | // Create GTU tracks per module (stack of 6 chambers) | |
1557 | // | |
1558 | ||
1559 | fModule->Reset(); | |
1560 | ||
1561 | AliTRDCommonParam* commonParam = AliTRDCommonParam::Instance(); | |
1562 | if (!commonParam) | |
1563 | { | |
1564 | Error("MakeTracks","No common params."); | |
1565 | return; | |
1566 | } | |
1567 | ||
1568 | Int_t nRowMax, iplan, icham, isect, row; | |
1569 | ||
1570 | AliTRDgeometry *geo = (AliTRDgeometry*)AliTRDgeometry::GetGeometry(fRunLoader); | |
1571 | ||
1572 | if ((det < 0) || (det >= AliTRDgeometry::Ndet())) { | |
1573 | Error("MakeTracks","Unexpected detector index %d.",det); | |
1574 | return; | |
1575 | } | |
1576 | ||
1577 | Int_t nTracklets = Tracklets()->GetEntriesFast(); | |
1578 | ||
1579 | AliTRDmcmTracklet *trk; | |
1580 | for (Int_t i = 0; i < nTracklets; i++) { | |
1581 | ||
1582 | trk = (AliTRDmcmTracklet *) Tracklets()->UncheckedAt(i); | |
1583 | ||
1584 | iplan = geo->GetPlane(trk->GetDetector()); | |
1585 | icham = geo->GetChamber(trk->GetDetector()); | |
1586 | isect = geo->GetSector(trk->GetDetector()); | |
1587 | ||
1588 | nRowMax = commonParam->GetRowMax(iplan,icham,isect); | |
1589 | row = trk->GetRow(); | |
1590 | ||
1591 | fModule->AddTracklet(trk->GetDetector(), | |
1592 | row, | |
1593 | trk->GetRowz(), | |
1594 | trk->GetSlope(), | |
1595 | trk->GetOffset(), | |
1596 | trk->GetTime0(), | |
1597 | trk->GetNclusters(), | |
1598 | trk->GetLabel(), | |
1599 | trk->GetdQdl()); | |
1600 | ||
1601 | } | |
1602 | ||
1603 | fModule->SortTracklets(); | |
1604 | fModule->RemoveMultipleTracklets(); | |
1605 | fModule->SortZ((Int_t)geo->GetChamber(det)); | |
1606 | fModule->FindTracks(); | |
1607 | fModule->SortTracks(); | |
1608 | fModule->RemoveMultipleTracks(); | |
1609 | ||
1610 | Int_t nModTracks = fModule->GetNtracks(); | |
1611 | AliTRDgtuTrack *gtutrk; | |
1612 | for (Int_t i = 0; i < nModTracks; i++) { | |
1613 | gtutrk = (AliTRDgtuTrack*)fModule->GetTrack(i); | |
1614 | if (TMath::Abs(gtutrk->GetPt()) < fTrigParam->GetGtuPtCut()) continue; | |
1615 | gtutrk->CookLabel(); | |
1616 | gtutrk->MakePID(); | |
1617 | AddTrack(gtutrk,det); | |
1618 | } | |
1619 | ||
1620 | } | |
1621 | ||
1622 |