]>
Commit | Line | Data |
---|---|---|
24b99a2e | 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 | /* $Id$ */ | |
17 | ||
18 | /////////////////////////////////////////////////////////////////////////////// | |
19 | // // | |
20 | // TRD cluster finder // | |
21 | // // | |
22 | /////////////////////////////////////////////////////////////////////////////// | |
23 | ||
24 | #include <TF1.h> | |
25 | #include <TTree.h> | |
26 | #include <TH1.h> | |
27 | #include <TFile.h> | |
28 | ||
29 | #include "AliRunLoader.h" | |
30 | #include "AliLoader.h" | |
31 | #include "AliRawReader.h" | |
32 | #include "AliLog.h" | |
33 | #include "AliAlignObj.h" | |
34 | ||
35 | #include "AliTRDclusterizerV1.h" | |
36 | #include "AliTRDgeometry.h" | |
37 | #include "AliTRDdataArrayF.h" | |
38 | #include "AliTRDdataArrayI.h" | |
39 | #include "AliTRDdigitsManager.h" | |
40 | #include "AliTRDpadPlane.h" | |
41 | #include "AliTRDrawData.h" | |
42 | #include "AliTRDcalibDB.h" | |
43 | #include "AliTRDSimParam.h" | |
44 | #include "AliTRDRecParam.h" | |
45 | #include "AliTRDcluster.h" | |
46 | ||
47 | #include "Cal/AliTRDCalROC.h" | |
48 | #include "Cal/AliTRDCalDet.h" | |
49 | ||
50 | ClassImp(AliTRDclusterizerV1) | |
51 | ||
52 | //_____________________________________________________________________________ | |
53 | AliTRDclusterizerV1::AliTRDclusterizerV1() | |
54 | :AliTRDclusterizer() | |
55 | ,fDigitsManager(NULL) | |
56 | { | |
57 | // | |
58 | // AliTRDclusterizerV1 default constructor | |
59 | // | |
60 | ||
61 | } | |
62 | ||
63 | //_____________________________________________________________________________ | |
64 | AliTRDclusterizerV1::AliTRDclusterizerV1(const Text_t *name, const Text_t *title) | |
65 | :AliTRDclusterizer(name,title) | |
66 | ,fDigitsManager(new AliTRDdigitsManager()) | |
67 | { | |
68 | // | |
69 | // AliTRDclusterizerV1 constructor | |
70 | // | |
71 | ||
72 | fDigitsManager->CreateArrays(); | |
73 | ||
74 | } | |
75 | ||
76 | //_____________________________________________________________________________ | |
77 | AliTRDclusterizerV1::AliTRDclusterizerV1(const AliTRDclusterizerV1 &c) | |
78 | :AliTRDclusterizer(c) | |
79 | ,fDigitsManager(NULL) | |
80 | { | |
81 | // | |
82 | // AliTRDclusterizerV1 copy constructor | |
83 | // | |
84 | ||
85 | } | |
86 | ||
87 | //_____________________________________________________________________________ | |
88 | AliTRDclusterizerV1::~AliTRDclusterizerV1() | |
89 | { | |
90 | // | |
91 | // AliTRDclusterizerV1 destructor | |
92 | // | |
93 | ||
94 | if (fDigitsManager) { | |
95 | delete fDigitsManager; | |
96 | fDigitsManager = NULL; | |
97 | } | |
98 | ||
99 | } | |
100 | ||
101 | //_____________________________________________________________________________ | |
102 | AliTRDclusterizerV1 &AliTRDclusterizerV1::operator=(const AliTRDclusterizerV1 &c) | |
103 | { | |
104 | // | |
105 | // Assignment operator | |
106 | // | |
107 | ||
108 | if (this != &c) ((AliTRDclusterizerV1 &) c).Copy(*this); | |
109 | return *this; | |
110 | ||
111 | } | |
112 | ||
113 | //_____________________________________________________________________________ | |
114 | void AliTRDclusterizerV1::Copy(TObject &c) const | |
115 | { | |
116 | // | |
117 | // Copy function | |
118 | // | |
119 | ||
120 | ((AliTRDclusterizerV1 &) c).fDigitsManager = 0; | |
121 | ||
122 | AliTRDclusterizer::Copy(c); | |
123 | ||
124 | } | |
125 | ||
126 | //_____________________________________________________________________________ | |
127 | Bool_t AliTRDclusterizerV1::ReadDigits() | |
128 | { | |
129 | // | |
130 | // Reads the digits arrays from the input aliroot file | |
131 | // | |
132 | ||
133 | if (!fRunLoader) { | |
134 | AliError("No run loader available"); | |
135 | return kFALSE; | |
136 | } | |
137 | ||
138 | AliLoader* loader = fRunLoader->GetLoader("TRDLoader"); | |
139 | if (!loader->TreeD()) { | |
140 | loader->LoadDigits(); | |
141 | } | |
142 | ||
143 | // Read in the digit arrays | |
144 | return (fDigitsManager->ReadDigits(loader->TreeD())); | |
145 | ||
146 | } | |
147 | ||
148 | //_____________________________________________________________________________ | |
149 | Bool_t AliTRDclusterizerV1::ReadDigits(TTree *digitsTree) | |
150 | { | |
151 | // | |
152 | // Reads the digits arrays from the input tree | |
153 | // | |
154 | ||
155 | // Read in the digit arrays | |
156 | return (fDigitsManager->ReadDigits(digitsTree)); | |
157 | ||
158 | } | |
159 | ||
160 | //_____________________________________________________________________________ | |
161 | Bool_t AliTRDclusterizerV1::ReadDigits(AliRawReader *rawReader) | |
162 | { | |
163 | // | |
164 | // Reads the digits arrays from the ddl file | |
165 | // | |
166 | ||
167 | AliTRDrawData raw; | |
168 | fDigitsManager = raw.Raw2Digits(rawReader); | |
169 | ||
170 | return kTRUE; | |
171 | ||
172 | } | |
173 | ||
174 | //_____________________________________________________________________________ | |
175 | Bool_t AliTRDclusterizerV1::MakeClusters() | |
176 | { | |
177 | // | |
178 | // Generates the cluster. | |
179 | // | |
180 | ||
181 | Int_t row = 0; | |
182 | Int_t col = 0; | |
183 | Int_t time = 0; | |
184 | Int_t icham = 0; | |
185 | Int_t iplan = 0; | |
186 | Int_t isect = 0; | |
187 | Int_t iPad = 0; | |
188 | ||
189 | AliTRDdataArrayI *digitsIn; | |
190 | AliTRDdataArrayI *tracksIn; | |
191 | ||
192 | AliTRDgeometry geo; | |
193 | ||
194 | AliTRDcalibDB *calibration = AliTRDcalibDB::Instance(); | |
195 | if (!calibration) { | |
196 | AliFatal("No AliTRDcalibDB instance available\n"); | |
197 | return kFALSE; | |
198 | } | |
199 | ||
200 | AliTRDSimParam *simParam = AliTRDSimParam::Instance(); | |
201 | if (!simParam) { | |
202 | AliError("No AliTRDSimParam instance available\n"); | |
203 | return kFALSE; | |
204 | } | |
205 | ||
206 | AliTRDRecParam *recParam = AliTRDRecParam::Instance(); | |
207 | if (!recParam) { | |
208 | AliError("No AliTRDRecParam instance available\n"); | |
209 | return kFALSE; | |
210 | } | |
211 | ||
212 | // ADC thresholds | |
213 | // Float_t ADCthreshold = simParam->GetADCthreshold(); | |
214 | Float_t ADCthreshold = 0; | |
215 | // Threshold value for the maximum | |
216 | Float_t maxThresh = recParam->GetClusMaxThresh(); | |
217 | // Threshold value for the digit signal | |
218 | Float_t sigThresh = recParam->GetClusSigThresh(); | |
219 | ||
220 | // Detector wise calibration object for t0 | |
221 | const AliTRDCalDet *calT0Det = calibration->GetT0Det(); | |
222 | // Detector wise calibration object for the gain factors | |
223 | const AliTRDCalDet *calGainFactorDet = calibration->GetGainFactorDet(); | |
224 | ||
225 | // Iteration limit for unfolding procedure | |
226 | const Float_t kEpsilon = 0.01; | |
227 | const Int_t kNclus = 3; | |
228 | const Int_t kNsig = 5; | |
229 | const Int_t kNdict = AliTRDdigitsManager::kNDict; | |
230 | const Int_t kNtrack = kNdict * kNclus; | |
231 | ||
232 | Int_t iUnfold = 0; | |
233 | Double_t ratioLeft = 1.0; | |
234 | Double_t ratioRight = 1.0; | |
235 | ||
236 | Int_t iClusterROC = 0; | |
237 | ||
238 | Double_t padSignal[kNsig]; | |
239 | Double_t clusterSignal[kNclus]; | |
240 | Double_t clusterPads[kNclus]; | |
241 | ||
242 | Int_t chamBeg = 0; | |
243 | Int_t chamEnd = AliTRDgeometry::Ncham(); | |
244 | Int_t planBeg = 0; | |
245 | Int_t planEnd = AliTRDgeometry::Nplan(); | |
246 | Int_t sectBeg = 0; | |
247 | Int_t sectEnd = AliTRDgeometry::Nsect(); | |
248 | Int_t nTimeTotal = calibration->GetNumberOfTimeBins(); | |
249 | ||
250 | AliDebug(1,Form("Number of Time Bins = %d.\n",nTimeTotal)); | |
251 | ||
252 | // Start clustering in every chamber | |
253 | for (icham = chamBeg; icham < chamEnd; icham++) { | |
254 | for (iplan = planBeg; iplan < planEnd; iplan++) { | |
255 | for (isect = sectBeg; isect < sectEnd; isect++) { | |
256 | ||
257 | Int_t idet = geo.GetDetector(iplan,icham,isect); | |
258 | Int_t ilayer = AliGeomManager::kTRD1 + iplan; | |
259 | Int_t imodule = icham + chamEnd * isect; | |
260 | UShort_t volid = AliGeomManager::LayerToVolUID(ilayer,imodule); | |
261 | ||
262 | // Get the digits | |
263 | digitsIn = fDigitsManager->GetDigits(idet); | |
264 | // This is to take care of switched off super modules | |
265 | if (digitsIn->GetNtime() == 0) { | |
266 | continue; | |
267 | } | |
268 | digitsIn->Expand(); | |
269 | AliTRDdataArrayI *tracksTmp = fDigitsManager->GetDictionary(idet,0); | |
270 | tracksTmp->Expand(); | |
271 | ||
272 | Int_t nRowMax = geo.GetRowMax(iplan,icham,isect); | |
273 | Int_t nColMax = geo.GetColMax(iplan); | |
274 | ||
275 | AliTRDpadPlane *padPlane = geo.GetPadPlane(iplan,icham); | |
276 | ||
277 | // Calibration object with pad wise values for t0 | |
278 | AliTRDCalROC *calT0ROC = calibration->GetT0ROC(idet); | |
279 | // Calibration object with pad wise values for the gain factors | |
280 | AliTRDCalROC *calGainFactorROC = calibration->GetGainFactorROC(idet); | |
281 | // Calibration value for chamber wise t0 | |
282 | Float_t calT0DetValue = calT0Det->GetValue(idet); | |
283 | // Calibration value for chamber wise gain factor | |
284 | Float_t calGainFactorDetValue = calGainFactorDet->GetValue(idet); | |
285 | ||
286 | Int_t nClusters = 0; | |
287 | ||
288 | // Apply the gain and the tail cancelation via digital filter | |
289 | AliTRDdataArrayF *digitsOut = new AliTRDdataArrayF(digitsIn->GetNrow() | |
290 | ,digitsIn->GetNcol() | |
291 | ,digitsIn->GetNtime()); | |
292 | Transform(digitsIn | |
293 | ,digitsOut | |
294 | ,nRowMax,nColMax,nTimeTotal | |
295 | ,ADCthreshold | |
296 | ,calGainFactorROC | |
297 | ,calGainFactorDetValue); | |
298 | ||
299 | // Input digits are not needed any more | |
300 | digitsIn->Compress(1,0); | |
301 | ||
302 | // Loop through the chamber and find the maxima | |
303 | for ( row = 0; row < nRowMax; row++) { | |
304 | for ( col = 2; col < nColMax; col++) { | |
305 | for (time = 0; time < nTimeTotal; time++) { | |
306 | ||
307 | Float_t signalM = TMath::Abs(digitsOut->GetDataUnchecked(row,col-1,time)); | |
308 | ||
309 | // Look for the maximum | |
310 | if (signalM >= maxThresh) { | |
311 | ||
312 | Float_t signalL = TMath::Abs(digitsOut->GetDataUnchecked(row,col ,time)); | |
313 | Float_t signalR = TMath::Abs(digitsOut->GetDataUnchecked(row,col-2,time)); | |
314 | ||
315 | if ((TMath::Abs(signalL) <= signalM) && | |
316 | (TMath::Abs(signalR) < signalM)) { | |
317 | if ((TMath::Abs(signalL) >= sigThresh) || | |
318 | (TMath::Abs(signalR) >= sigThresh)) { | |
319 | // Maximum found, mark the position by a negative signal | |
320 | digitsOut->SetDataUnchecked(row,col-1,time,-signalM); | |
321 | } | |
322 | } | |
323 | ||
324 | } | |
325 | ||
326 | } | |
327 | } | |
328 | } | |
329 | tracksTmp->Compress(1,0); | |
330 | ||
331 | // The index to the first cluster of a given ROC | |
332 | Int_t firstClusterROC = -1; | |
333 | // The number of cluster in a given ROC | |
334 | Int_t nClusterROC = 0; | |
335 | ||
336 | // Now check the maxima and calculate the cluster position | |
337 | for ( row = 0; row < nRowMax ; row++) { | |
338 | for (time = 0; time < nTimeTotal; time++) { | |
339 | for ( col = 1; col < nColMax-1; col++) { | |
340 | ||
341 | // Maximum found ? | |
342 | if (digitsOut->GetDataUnchecked(row,col,time) < 0.0) { | |
343 | ||
344 | for (iPad = 0; iPad < kNclus; iPad++) { | |
345 | Int_t iPadCol = col - 1 + iPad; | |
346 | clusterSignal[iPad] = | |
347 | TMath::Abs(digitsOut->GetDataUnchecked(row,iPadCol,time)); | |
348 | } | |
349 | ||
350 | // Count the number of pads in the cluster | |
351 | Int_t nPadCount = 0; | |
352 | Int_t ii; | |
353 | // Look to the left | |
354 | ii = 0; | |
355 | while (TMath::Abs(digitsOut->GetDataUnchecked(row,col-ii ,time)) >= sigThresh) { | |
356 | nPadCount++; | |
357 | ii++; | |
358 | if (col-ii < 0) break; | |
359 | } | |
360 | // Look to the right | |
361 | ii = 0; | |
362 | while (TMath::Abs(digitsOut->GetDataUnchecked(row,col+ii+1,time)) >= sigThresh) { | |
363 | nPadCount++; | |
364 | ii++; | |
365 | if (col+ii+1 >= nColMax) break; | |
366 | } | |
367 | nClusters++; | |
368 | ||
369 | // Look for 5 pad cluster with minimum in the middle | |
370 | Bool_t fivePadCluster = kFALSE; | |
371 | if (col < (nColMax - 3)) { | |
372 | if (digitsOut->GetDataUnchecked(row,col+2,time) < 0) { | |
373 | fivePadCluster = kTRUE; | |
374 | } | |
375 | if ((fivePadCluster) && (col < (nColMax - 5))) { | |
376 | if (digitsOut->GetDataUnchecked(row,col+4,time) >= sigThresh) { | |
377 | fivePadCluster = kFALSE; | |
378 | } | |
379 | } | |
380 | if ((fivePadCluster) && (col > 1)) { | |
381 | if (digitsOut->GetDataUnchecked(row,col-2,time) >= sigThresh) { | |
382 | fivePadCluster = kFALSE; | |
383 | } | |
384 | } | |
385 | } | |
386 | ||
387 | // 5 pad cluster | |
388 | // Modify the signal of the overlapping pad for the left part | |
389 | // of the cluster which remains from a previous unfolding | |
390 | if (iUnfold) { | |
391 | clusterSignal[0] *= ratioLeft; | |
392 | iUnfold = 0; | |
393 | } | |
394 | ||
395 | // Unfold the 5 pad cluster | |
396 | if (fivePadCluster) { | |
397 | for (iPad = 0; iPad < kNsig; iPad++) { | |
398 | padSignal[iPad] = TMath::Abs(digitsOut->GetDataUnchecked(row | |
399 | ,col-1+iPad | |
400 | ,time)); | |
401 | } | |
402 | // Unfold the two maxima and set the signal on | |
403 | // the overlapping pad to the ratio | |
404 | ratioRight = Unfold(kEpsilon,iplan,padSignal); | |
405 | ratioLeft = 1.0 - ratioRight; | |
406 | clusterSignal[2] *= ratioRight; | |
407 | iUnfold = 1; | |
408 | } | |
409 | ||
410 | Double_t clusterCharge = clusterSignal[0] | |
411 | + clusterSignal[1] | |
412 | + clusterSignal[2]; | |
413 | ||
414 | // The position of the cluster | |
415 | clusterPads[0] = row + 0.5; | |
416 | // Take the shift of the additional time bins into account | |
417 | clusterPads[2] = time + 0.5; | |
418 | ||
419 | if (recParam->LUTOn()) { | |
420 | // Calculate the position of the cluster by using the | |
421 | // lookup table method | |
422 | clusterPads[1] = recParam->LUTposition(iplan,clusterSignal[0] | |
423 | ,clusterSignal[1] | |
424 | ,clusterSignal[2]); | |
425 | } | |
426 | else { | |
427 | // Calculate the position of the cluster by using the | |
428 | // center of gravity method | |
429 | for (Int_t i = 0; i < kNsig; i++) { | |
430 | padSignal[i] = 0.0; | |
431 | } | |
432 | padSignal[2] = TMath::Abs(digitsOut->GetDataUnchecked(row,col ,time)); // Central pad | |
433 | padSignal[1] = TMath::Abs(digitsOut->GetDataUnchecked(row,col-1,time)); // Left pad | |
434 | padSignal[3] = TMath::Abs(digitsOut->GetDataUnchecked(row,col+1,time)); // Right pad | |
435 | if ((col > 2) && | |
436 | (TMath::Abs(digitsOut->GetDataUnchecked(row,col-2,time)) < padSignal[1])) { | |
437 | padSignal[0] = TMath::Abs(digitsOut->GetDataUnchecked(row,col-2,time)); | |
438 | } | |
439 | if ((col < nColMax - 3) && | |
440 | (TMath::Abs(digitsOut->GetDataUnchecked(row,col+2,time)) < padSignal[3])) { | |
441 | padSignal[4] = TMath::Abs(digitsOut->GetDataUnchecked(row,col+2,time)); | |
442 | } | |
443 | clusterPads[1] = GetCOG(padSignal); | |
444 | } | |
445 | ||
446 | Double_t q0 = clusterSignal[0]; | |
447 | Double_t q1 = clusterSignal[1]; | |
448 | Double_t q2 = clusterSignal[2]; | |
449 | Double_t clusterSigmaY2 = (q1 * (q0 + q2) + 4.0 * q0 * q2) | |
450 | / (clusterCharge*clusterCharge); | |
451 | ||
452 | // | |
453 | // Calculate the position and the error | |
454 | // | |
455 | ||
456 | // Correct for t0 (sum of chamber and pad wise values !!!) | |
457 | Float_t calT0ROCValue = calT0ROC->GetValue(col,row); | |
458 | Char_t clusterTimeBin = ((Char_t) TMath::Nint(time - (calT0DetValue + calT0ROCValue))); | |
459 | Double_t colSize = padPlane->GetColSize(col); | |
460 | Double_t rowSize = padPlane->GetRowSize(row); | |
461 | ||
462 | Float_t clusterPos[3]; | |
463 | clusterPos[0] = padPlane->GetColPos(col) - (clusterPads[1] + 0.5) * colSize; | |
464 | clusterPos[1] = padPlane->GetRowPos(row) - 0.5 * rowSize; | |
465 | clusterPos[2] = CalcXposFromTimebin(clusterPads[2],idet,col,row); | |
466 | Float_t clusterSig[2]; | |
467 | clusterSig[0] = (clusterSigmaY2 + 1.0/12.0) * colSize*colSize; | |
468 | clusterSig[1] = rowSize * rowSize / 12.0; | |
469 | ||
470 | // Store the amplitudes of the pads in the cluster for later analysis | |
471 | Short_t signals[7] = { 0, 0, 0, 0, 0, 0, 0 }; | |
472 | for (Int_t jPad = col-3; jPad <= col+3; jPad++) { | |
473 | if ((jPad < 0) || | |
474 | (jPad >= nColMax-1)) { | |
475 | continue; | |
476 | } | |
477 | signals[jPad-col+3] = TMath::Nint(TMath::Abs(digitsOut->GetDataUnchecked(row,jPad,time))); | |
478 | } | |
479 | ||
480 | // Add the cluster to the output array | |
481 | // The track indices will be stored later | |
482 | AliTRDcluster *cluster = new AliTRDcluster(idet | |
483 | ,clusterCharge | |
484 | ,clusterPos | |
485 | ,clusterSig | |
486 | ,0x0 | |
487 | ,((Char_t) nPadCount) | |
488 | ,signals | |
489 | ,((UChar_t) col) | |
490 | ,clusterTimeBin | |
491 | ,clusterPads[1] | |
492 | ,volid); | |
493 | // Temporarily store the row, column and time bin of the center pad | |
494 | // Used to later on assign the track indices | |
495 | cluster->SetLabel( row,0); | |
496 | cluster->SetLabel( col,1); | |
497 | cluster->SetLabel(time,2); | |
498 | RecPoints()->Add(cluster); | |
499 | ||
500 | // Store the index of the first cluster in the current ROC | |
501 | if (firstClusterROC < 0) { | |
502 | firstClusterROC = RecPoints()->GetEntriesFast() - 1; | |
503 | } | |
504 | // Count the number of cluster in the current ROC | |
505 | nClusterROC++; | |
506 | ||
507 | } // if: Maximum found ? | |
508 | ||
509 | } // loop: pad columns | |
510 | } // loop: time bins | |
511 | } // loop: pad rows | |
512 | ||
513 | delete digitsOut; | |
514 | ||
515 | // | |
516 | // Add the track indices to the found clusters | |
517 | // | |
518 | ||
519 | // Temporary array to collect the track indices | |
520 | Int_t *idxTracks = new Int_t[kNtrack*nClusterROC]; | |
521 | ||
522 | // Loop through the dictionary arrays one-by-one | |
523 | // to keep memory consumption low | |
524 | for (Int_t iDict = 0; iDict < kNdict; iDict++) { | |
525 | ||
526 | tracksIn = fDigitsManager->GetDictionary(idet,iDict); | |
527 | tracksIn->Expand(); | |
528 | ||
529 | // Loop though the clusters found in this ROC | |
530 | for (iClusterROC = 0; iClusterROC < nClusterROC; iClusterROC++) { | |
531 | ||
532 | AliTRDcluster *cluster = (AliTRDcluster *) | |
533 | RecPoints()->UncheckedAt(firstClusterROC+iClusterROC); | |
534 | row = cluster->GetLabel(0); | |
535 | col = cluster->GetLabel(1); | |
536 | time = cluster->GetLabel(2); | |
537 | ||
538 | for (iPad = 0; iPad < kNclus; iPad++) { | |
539 | Int_t iPadCol = col - 1 + iPad; | |
540 | Int_t index = tracksIn->GetDataUnchecked(row,iPadCol,time) - 1; | |
541 | idxTracks[3*iPad+iDict + iClusterROC*kNtrack] = index; | |
542 | } | |
543 | ||
544 | } | |
545 | ||
546 | // Compress the arrays | |
547 | tracksIn->Compress(1,0); | |
548 | ||
549 | } | |
550 | ||
551 | // Copy the track indices into the cluster | |
552 | // Loop though the clusters found in this ROC | |
553 | for (iClusterROC = 0; iClusterROC < nClusterROC; iClusterROC++) { | |
554 | ||
555 | AliTRDcluster *cluster = (AliTRDcluster *) | |
556 | RecPoints()->UncheckedAt(firstClusterROC+iClusterROC); | |
557 | cluster->SetLabel(-9999,0); | |
558 | cluster->SetLabel(-9999,1); | |
559 | cluster->SetLabel(-9999,2); | |
560 | ||
561 | cluster->AddTrackIndex(&idxTracks[iClusterROC*kNtrack]); | |
562 | ||
563 | } | |
564 | ||
565 | delete [] idxTracks; | |
566 | ||
567 | // Write the cluster and reset the array | |
568 | WriteClusters(idet); | |
569 | ResetRecPoints(); | |
570 | ||
571 | } // loop: Sectors | |
572 | } // loop: Planes | |
573 | } // loop: Chambers | |
574 | ||
575 | return kTRUE; | |
576 | ||
577 | } | |
578 | ||
579 | //_____________________________________________________________________________ | |
580 | Double_t AliTRDclusterizerV1::GetCOG(Double_t signal[5]) | |
581 | { | |
582 | // | |
583 | // Get COG position | |
584 | // Used for clusters with more than 3 pads - where LUT not applicable | |
585 | // | |
586 | ||
587 | Double_t sum = signal[0] | |
588 | + signal[1] | |
589 | + signal[2] | |
590 | + signal[3] | |
591 | + signal[4]; | |
592 | ||
593 | Double_t res = (0.0 * (-signal[0] + signal[4]) | |
594 | + (-signal[1] + signal[3])) / sum; | |
595 | ||
596 | return res; | |
597 | ||
598 | } | |
599 | ||
600 | //_____________________________________________________________________________ | |
601 | Double_t AliTRDclusterizerV1::Unfold(Double_t eps, Int_t plane, Double_t *padSignal) | |
602 | { | |
603 | // | |
604 | // Method to unfold neighbouring maxima. | |
605 | // The charge ratio on the overlapping pad is calculated | |
606 | // until there is no more change within the range given by eps. | |
607 | // The resulting ratio is then returned to the calling method. | |
608 | // | |
609 | ||
610 | AliTRDcalibDB *calibration = AliTRDcalibDB::Instance(); | |
611 | if (!calibration) { | |
612 | AliError("No AliTRDcalibDB instance available\n"); | |
613 | return kFALSE; | |
614 | } | |
615 | ||
616 | Int_t irc = 0; | |
617 | Int_t itStep = 0; // Count iteration steps | |
618 | ||
619 | Double_t ratio = 0.5; // Start value for ratio | |
620 | Double_t prevRatio = 0.0; // Store previous ratio | |
621 | ||
622 | Double_t newLeftSignal[3] = { 0.0, 0.0, 0.0 }; // Array to store left cluster signal | |
623 | Double_t newRightSignal[3] = { 0.0, 0.0, 0.0 }; // Array to store right cluster signal | |
624 | Double_t newSignal[3] = { 0.0, 0.0, 0.0 }; | |
625 | ||
626 | // Start the iteration | |
627 | while ((TMath::Abs(prevRatio - ratio) > eps) && (itStep < 10)) { | |
628 | ||
629 | itStep++; | |
630 | prevRatio = ratio; | |
631 | ||
632 | // Cluster position according to charge ratio | |
633 | Double_t maxLeft = (ratio*padSignal[2] - padSignal[0]) | |
634 | / (padSignal[0] + padSignal[1] + ratio*padSignal[2]); | |
635 | Double_t maxRight = (padSignal[4] - (1-ratio)*padSignal[2]) | |
636 | / ((1.0 - ratio)*padSignal[2] + padSignal[3] + padSignal[4]); | |
637 | ||
638 | // Set cluster charge ratio | |
639 | irc = calibration->PadResponse(1.0,maxLeft ,plane,newSignal); | |
640 | Double_t ampLeft = padSignal[1] / newSignal[1]; | |
641 | irc = calibration->PadResponse(1.0,maxRight,plane,newSignal); | |
642 | Double_t ampRight = padSignal[3] / newSignal[1]; | |
643 | ||
644 | // Apply pad response to parameters | |
645 | irc = calibration->PadResponse(ampLeft ,maxLeft ,plane,newLeftSignal ); | |
646 | irc = calibration->PadResponse(ampRight,maxRight,plane,newRightSignal); | |
647 | ||
648 | // Calculate new overlapping ratio | |
649 | ratio = TMath::Min((Double_t)1.0,newLeftSignal[2] / | |
650 | (newLeftSignal[2] + newRightSignal[0])); | |
651 | ||
652 | } | |
653 | ||
654 | return ratio; | |
655 | ||
656 | } | |
657 | ||
658 | //_____________________________________________________________________________ | |
659 | void AliTRDclusterizerV1::Transform(AliTRDdataArrayI *digitsIn | |
660 | , AliTRDdataArrayF *digitsOut | |
661 | , Int_t nRowMax, Int_t nColMax, Int_t nTimeTotal | |
662 | , Float_t ADCthreshold | |
663 | , AliTRDCalROC *calGainFactorROC | |
664 | , Float_t calGainFactorDetValue) | |
665 | { | |
666 | // | |
667 | // Apply gain factor | |
668 | // Apply tail cancelation: Transform digitsIn to digitsOut | |
669 | // | |
670 | ||
671 | Int_t iRow = 0; | |
672 | Int_t iCol = 0; | |
673 | Int_t iTime = 0; | |
674 | ||
675 | AliTRDRecParam *recParam = AliTRDRecParam::Instance(); | |
676 | if (!recParam) { | |
677 | AliError("No AliTRDRecParam instance available\n"); | |
678 | return; | |
679 | } | |
680 | ||
681 | Double_t *inADC = new Double_t[nTimeTotal]; // ADC data before tail cancellation | |
682 | Double_t *outADC = new Double_t[nTimeTotal]; // ADC data after tail cancellation | |
683 | ||
684 | for (iRow = 0; iRow < nRowMax; iRow++ ) { | |
685 | for (iCol = 0; iCol < nColMax; iCol++ ) { | |
686 | ||
687 | Float_t calGainFactorROCValue = calGainFactorROC->GetValue(iCol,iRow); | |
688 | Double_t gain = calGainFactorDetValue | |
689 | * calGainFactorROCValue; | |
690 | ||
691 | for (iTime = 0; iTime < nTimeTotal; iTime++) { | |
692 | ||
693 | // | |
694 | // Add gain | |
695 | // | |
696 | inADC[iTime] = digitsIn->GetDataUnchecked(iRow,iCol,iTime); | |
697 | inADC[iTime] /= gain; | |
698 | outADC[iTime] = inADC[iTime]; | |
699 | ||
700 | } | |
701 | ||
702 | // Apply the tail cancelation via the digital filter | |
703 | if (recParam->TCOn()) { | |
704 | DeConvExp(inADC,outADC,nTimeTotal,recParam->GetTCnexp()); | |
705 | } | |
706 | ||
707 | for (iTime = 0; iTime < nTimeTotal; iTime++) { | |
708 | ||
709 | // Store the amplitude of the digit if above threshold | |
710 | if (outADC[iTime] > ADCthreshold) { | |
711 | digitsOut->SetDataUnchecked(iRow,iCol,iTime,outADC[iTime]); | |
712 | } | |
713 | ||
714 | } | |
715 | ||
716 | } | |
717 | } | |
718 | ||
719 | delete [] inADC; | |
720 | delete [] outADC; | |
721 | ||
722 | return; | |
723 | ||
724 | } | |
725 | ||
726 | //_____________________________________________________________________________ | |
727 | void AliTRDclusterizerV1::DeConvExp(Double_t *source, Double_t *target | |
728 | , Int_t n, Int_t nexp) | |
729 | { | |
730 | // | |
731 | // Tail cancellation by deconvolution for PASA v4 TRF | |
732 | // | |
733 | ||
734 | Double_t rates[2]; | |
735 | Double_t coefficients[2]; | |
736 | ||
737 | // Initialization (coefficient = alpha, rates = lambda) | |
738 | Double_t R1 = 1.0; | |
739 | Double_t R2 = 1.0; | |
740 | Double_t C1 = 0.5; | |
741 | Double_t C2 = 0.5; | |
742 | ||
743 | if (nexp == 1) { // 1 Exponentials | |
744 | R1 = 1.156; | |
745 | R2 = 0.130; | |
746 | C1 = 0.066; | |
747 | C2 = 0.000; | |
748 | } | |
749 | if (nexp == 2) { // 2 Exponentials | |
750 | R1 = 1.156; | |
751 | R2 = 0.130; | |
752 | C1 = 0.114; | |
753 | C2 = 0.624; | |
754 | } | |
755 | ||
756 | coefficients[0] = C1; | |
757 | coefficients[1] = C2; | |
758 | ||
759 | Double_t Dt = 0.1; | |
760 | ||
761 | rates[0] = TMath::Exp(-Dt/(R1)); | |
762 | rates[1] = TMath::Exp(-Dt/(R2)); | |
763 | ||
764 | Int_t i = 0; | |
765 | Int_t k = 0; | |
766 | ||
767 | Double_t reminder[2]; | |
768 | Double_t correction; | |
769 | Double_t result; | |
770 | ||
771 | // Attention: computation order is important | |
772 | correction = 0.0; | |
773 | for (k = 0; k < nexp; k++) { | |
774 | reminder[k] = 0.0; | |
775 | } | |
776 | for (i = 0; i < n; i++) { | |
777 | result = (source[i] - correction); // No rescaling | |
778 | target[i] = result; | |
779 | ||
780 | for (k = 0; k < nexp; k++) { | |
781 | reminder[k] = rates[k] * (reminder[k] + coefficients[k] * result); | |
782 | } | |
783 | correction = 0.0; | |
784 | for (k = 0; k < nexp; k++) { | |
785 | correction += reminder[k]; | |
786 | } | |
787 | } | |
788 | ||
789 | } |