]>
Commit | Line | Data |
---|---|---|
cb86ff6e | 1 | |
f7336fa3 | 2 | /************************************************************************** |
3 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
4 | * * | |
5 | * Author: The ALICE Off-line Project. * | |
6 | * Contributors are mentioned in the code where appropriate. * | |
7 | * * | |
8 | * Permission to use, copy, modify and distribute this software and its * | |
9 | * documentation strictly for non-commercial purposes is hereby granted * | |
10 | * without fee, provided that the above copyright notice appears in all * | |
11 | * copies and that both the copyright notice and this permission notice * | |
12 | * appear in the supporting documentation. The authors make no claims * | |
13 | * about the suitability of this software for any purpose. It is * | |
14 | * provided "as is" without express or implied warranty. * | |
15 | **************************************************************************/ | |
16 | ||
88cb7938 | 17 | /* $Id$ */ |
f7336fa3 | 18 | |
19 | /////////////////////////////////////////////////////////////////////////////// | |
20 | // // | |
6d50f529 | 21 | // TRD cluster finder // |
f7336fa3 | 22 | // // |
23 | /////////////////////////////////////////////////////////////////////////////// | |
24 | ||
25 | #include <TF1.h> | |
94de3818 | 26 | #include <TTree.h> |
793ff80c | 27 | #include <TH1.h> |
a819a5f7 | 28 | #include <TFile.h> |
f7336fa3 | 29 | |
793ff80c | 30 | #include "AliRun.h" |
88cb7938 | 31 | #include "AliRunLoader.h" |
32 | #include "AliLoader.h" | |
928e9fae | 33 | #include "AliRawReader.h" |
6d50f529 | 34 | #include "AliLog.h" |
793ff80c | 35 | |
f7336fa3 | 36 | #include "AliTRDclusterizerV1.h" |
f7336fa3 | 37 | #include "AliTRDgeometry.h" |
6f1e466d | 38 | #include "AliTRDdataArrayF.h" |
793ff80c | 39 | #include "AliTRDdataArrayI.h" |
40 | #include "AliTRDdigitsManager.h" | |
a5cadd36 | 41 | #include "AliTRDpadPlane.h" |
928e9fae | 42 | #include "AliTRDrawData.h" |
3551db50 | 43 | #include "AliTRDcalibDB.h" |
3becff3c | 44 | #include "AliTRDSimParam.h" |
3551db50 | 45 | #include "AliTRDRecParam.h" |
46 | #include "AliTRDCommonParam.h" | |
c85a4951 | 47 | #include "AliTRDcluster.h" |
f7336fa3 | 48 | |
49 | ClassImp(AliTRDclusterizerV1) | |
50 | ||
51 | //_____________________________________________________________________________ | |
6d50f529 | 52 | AliTRDclusterizerV1::AliTRDclusterizerV1() |
53 | :AliTRDclusterizer() | |
54 | ,fDigitsManager(NULL) | |
f7336fa3 | 55 | { |
56 | // | |
57 | // AliTRDclusterizerV1 default constructor | |
58 | // | |
59 | ||
f7336fa3 | 60 | } |
61 | ||
62 | //_____________________________________________________________________________ | |
63 | AliTRDclusterizerV1::AliTRDclusterizerV1(const Text_t* name, const Text_t* title) | |
6d50f529 | 64 | :AliTRDclusterizer(name,title) |
65 | ,fDigitsManager(new AliTRDdigitsManager()) | |
f7336fa3 | 66 | { |
67 | // | |
6d50f529 | 68 | // AliTRDclusterizerV1 constructor |
f7336fa3 | 69 | // |
70 | ||
17b26de4 | 71 | fDigitsManager->CreateArrays(); |
f7336fa3 | 72 | |
73 | } | |
74 | ||
8230f242 | 75 | //_____________________________________________________________________________ |
dd9a6ee3 | 76 | AliTRDclusterizerV1::AliTRDclusterizerV1(const AliTRDclusterizerV1 &c) |
6d50f529 | 77 | :AliTRDclusterizer(c) |
78 | ,fDigitsManager(NULL) | |
8230f242 | 79 | { |
80 | // | |
81 | // AliTRDclusterizerV1 copy constructor | |
82 | // | |
83 | ||
8230f242 | 84 | } |
85 | ||
f7336fa3 | 86 | //_____________________________________________________________________________ |
87 | AliTRDclusterizerV1::~AliTRDclusterizerV1() | |
88 | { | |
8230f242 | 89 | // |
90 | // AliTRDclusterizerV1 destructor | |
91 | // | |
f7336fa3 | 92 | |
6f1e466d | 93 | if (fDigitsManager) { |
94 | delete fDigitsManager; | |
abaf1f1d | 95 | fDigitsManager = NULL; |
f7336fa3 | 96 | } |
97 | ||
98 | } | |
99 | ||
dd9a6ee3 | 100 | //_____________________________________________________________________________ |
101 | AliTRDclusterizerV1 &AliTRDclusterizerV1::operator=(const AliTRDclusterizerV1 &c) | |
102 | { | |
103 | // | |
104 | // Assignment operator | |
105 | // | |
106 | ||
107 | if (this != &c) ((AliTRDclusterizerV1 &) c).Copy(*this); | |
108 | return *this; | |
109 | ||
110 | } | |
111 | ||
8230f242 | 112 | //_____________________________________________________________________________ |
e0d47c25 | 113 | void AliTRDclusterizerV1::Copy(TObject &c) const |
8230f242 | 114 | { |
115 | // | |
116 | // Copy function | |
117 | // | |
118 | ||
17b26de4 | 119 | ((AliTRDclusterizerV1 &) c).fDigitsManager = 0; |
8230f242 | 120 | |
121 | AliTRDclusterizer::Copy(c); | |
122 | ||
123 | } | |
124 | ||
f7336fa3 | 125 | //_____________________________________________________________________________ |
126 | Bool_t AliTRDclusterizerV1::ReadDigits() | |
127 | { | |
128 | // | |
129 | // Reads the digits arrays from the input aliroot file | |
130 | // | |
131 | ||
88cb7938 | 132 | if (!fRunLoader) { |
6d50f529 | 133 | AliError("No run loader available"); |
f7336fa3 | 134 | return kFALSE; |
135 | } | |
6d50f529 | 136 | |
88cb7938 | 137 | AliLoader* loader = fRunLoader->GetLoader("TRDLoader"); |
6d50f529 | 138 | if (!loader->TreeD()) { |
139 | loader->LoadDigits(); | |
140 | } | |
abaf1f1d | 141 | |
f7336fa3 | 142 | // Read in the digit arrays |
88cb7938 | 143 | return (fDigitsManager->ReadDigits(loader->TreeD())); |
f7336fa3 | 144 | |
145 | } | |
146 | ||
928e9fae | 147 | //_____________________________________________________________________________ |
148 | Bool_t AliTRDclusterizerV1::ReadDigits(AliRawReader* rawReader) | |
149 | { | |
150 | // | |
151 | // Reads the digits arrays from the ddl file | |
152 | // | |
153 | ||
4ab68796 | 154 | AliTRDrawData raw; |
4ab68796 | 155 | fDigitsManager = raw.Raw2Digits(rawReader); |
928e9fae | 156 | |
157 | return kTRUE; | |
158 | ||
159 | } | |
160 | ||
f7336fa3 | 161 | //_____________________________________________________________________________ |
793ff80c | 162 | Bool_t AliTRDclusterizerV1::MakeClusters() |
f7336fa3 | 163 | { |
164 | // | |
165 | // Generates the cluster. | |
166 | // | |
167 | ||
6d50f529 | 168 | Int_t row = 0; |
169 | Int_t col = 0; | |
170 | Int_t time = 0; | |
171 | Int_t icham = 0; | |
172 | Int_t iplan = 0; | |
173 | Int_t isect = 0; | |
174 | Int_t iPad = 0; | |
175 | ||
176 | AliTRDdataArrayI *digitsIn; | |
177 | AliTRDdataArrayI *track0; | |
178 | AliTRDdataArrayI *track1; | |
179 | AliTRDdataArrayI *track2; | |
f7336fa3 | 180 | |
181 | // Get the geometry | |
6d50f529 | 182 | AliTRDgeometry *geo = AliTRDgeometry::GetGeometry(fRunLoader); |
183 | AliTRDcalibDB *calibration = AliTRDcalibDB::Instance(); | |
184 | if (!calibration) { | |
185 | AliError("No AliTRDcalibDB instance available\n"); | |
3551db50 | 186 | return kFALSE; |
187 | } | |
188 | ||
6d50f529 | 189 | AliTRDSimParam *simParam = AliTRDSimParam::Instance(); |
190 | if (!simParam) { | |
191 | AliError("No AliTRDSimParam instance available\n"); | |
3becff3c | 192 | return kFALSE; |
193 | } | |
194 | ||
6d50f529 | 195 | AliTRDRecParam *recParam = AliTRDRecParam::Instance(); |
196 | if (!recParam) { | |
197 | AliError("No AliTRDRecParam instance available\n"); | |
3551db50 | 198 | return kFALSE; |
199 | } | |
200 | ||
6d50f529 | 201 | AliTRDCommonParam *commonParam = AliTRDCommonParam::Instance(); |
202 | if (!commonParam) { | |
203 | AliError("Could not get common parameters\n"); | |
3551db50 | 204 | return kFALSE; |
205 | } | |
f7336fa3 | 206 | |
6d50f529 | 207 | // ADC threshols |
208 | Float_t ADCthreshold = simParam->GetADCthreshold(); | |
3e1a3ad8 | 209 | // Threshold value for the maximum |
6d50f529 | 210 | Float_t maxThresh = recParam->GetClusMaxThresh(); |
3e1a3ad8 | 211 | // Threshold value for the digit signal |
6d50f529 | 212 | Float_t sigThresh = recParam->GetClusSigThresh(); |
213 | ||
f7336fa3 | 214 | // Iteration limit for unfolding procedure |
8230f242 | 215 | const Float_t kEpsilon = 0.01; |
8230f242 | 216 | const Int_t kNclus = 3; |
217 | const Int_t kNsig = 5; | |
3e1a3ad8 | 218 | const Int_t kNtrack = 3 * kNclus; |
219 | ||
a5cadd36 | 220 | Int_t iType = 0; |
7ad19338 | 221 | Int_t iUnfold = 0; |
a5cadd36 | 222 | Double_t ratioLeft = 1.0; |
223 | Double_t ratioRight = 1.0; | |
db30bf0f | 224 | |
a5cadd36 | 225 | Double_t padSignal[kNsig]; |
226 | Double_t clusterSignal[kNclus]; | |
227 | Double_t clusterPads[kNclus]; | |
11dc3a9e | 228 | Int_t clusterTracks[kNtrack]; |
f7336fa3 | 229 | |
6d50f529 | 230 | Int_t chamBeg = 0; |
231 | Int_t chamEnd = AliTRDgeometry::Ncham(); | |
232 | Int_t planBeg = 0; | |
233 | Int_t planEnd = AliTRDgeometry::Nplan(); | |
234 | Int_t sectBeg = 0; | |
235 | Int_t sectEnd = AliTRDgeometry::Nsect(); | |
236 | Int_t nTimeTotal = calibration->GetNumberOfTimeBins(); | |
f7336fa3 | 237 | |
6d50f529 | 238 | AliDebug(1,Form("Number of Time Bins = %d.\n",nTimeTotal)); |
3becff3c | 239 | |
3e1a3ad8 | 240 | // Start clustering in every chamber |
6d50f529 | 241 | for (icham = chamBeg; icham < chamEnd; icham++) { |
242 | for (iplan = planBeg; iplan < planEnd; iplan++) { | |
243 | for (isect = sectBeg; isect < sectEnd; isect++) { | |
f7336fa3 | 244 | |
3becff3c | 245 | Int_t idet = geo->GetDetector(iplan,icham,isect); |
246 | ||
247 | Int_t nRowMax = commonParam->GetRowMax(iplan,icham,isect); | |
248 | Int_t nColMax = commonParam->GetColMax(iplan); | |
f7336fa3 | 249 | |
6d50f529 | 250 | AliTRDpadPlane *padPlane = commonParam->GetPadPlane(iplan,icham); |
251 | ||
db30bf0f | 252 | Int_t nClusters = 0; |
253 | Int_t nClusters2pad = 0; | |
254 | Int_t nClusters3pad = 0; | |
255 | Int_t nClusters4pad = 0; | |
256 | Int_t nClusters5pad = 0; | |
257 | Int_t nClustersLarge = 0; | |
3e1a3ad8 | 258 | |
6d50f529 | 259 | AliDebug(1,Form("Analyzing chamber %d, plane %d, sector %d.\n" |
260 | ,icham,iplan,isect)); | |
f7336fa3 | 261 | |
3e1a3ad8 | 262 | // Get the digits |
11dc3a9e | 263 | digitsIn = fDigitsManager->GetDigits(idet); |
3becff3c | 264 | digitsIn->Expand(); |
6d50f529 | 265 | track0 = fDigitsManager->GetDictionary(idet,0); |
3e1a3ad8 | 266 | track0->Expand(); |
6d50f529 | 267 | track1 = fDigitsManager->GetDictionary(idet,1); |
3e1a3ad8 | 268 | track1->Expand(); |
6d50f529 | 269 | track2 = fDigitsManager->GetDictionary(idet,2); |
3e1a3ad8 | 270 | track2->Expand(); |
271 | ||
6d50f529 | 272 | AliTRDdataArrayF *digitsOut = new AliTRDdataArrayF(digitsIn->GetNrow() |
273 | ,digitsIn->GetNcol() | |
274 | ,digitsIn->GetNtime()); | |
275 | Transform(digitsIn, digitsOut,idet,nRowMax,nColMax,nTimeTotal,ADCthreshold); | |
276 | ||
3e1a3ad8 | 277 | // Loop through the chamber and find the maxima |
278 | for ( row = 0; row < nRowMax; row++) { | |
de4b10e5 | 279 | for ( col = 2; col < nColMax; col++) { |
3e1a3ad8 | 280 | for (time = 0; time < nTimeTotal; time++) { |
281 | ||
11dc3a9e | 282 | Float_t signalL = TMath::Abs(digitsOut->GetDataUnchecked(row,col ,time)); |
283 | Float_t signalM = TMath::Abs(digitsOut->GetDataUnchecked(row,col-1,time)); | |
284 | Float_t signalR = TMath::Abs(digitsOut->GetDataUnchecked(row,col-2,time)); | |
3e1a3ad8 | 285 | |
286 | // Look for the maximum | |
db30bf0f | 287 | if (signalM >= maxThresh) { |
6d50f529 | 288 | if ((TMath::Abs(signalL) <= signalM) && |
289 | (TMath::Abs(signalR) <= signalM) && | |
290 | ((TMath::Abs(signalL) + TMath::Abs(signalR)) > sigThresh)) { | |
3e1a3ad8 | 291 | // Maximum found, mark the position by a negative signal |
3becff3c | 292 | digitsOut->SetDataUnchecked(row,col-1,time,-signalM); |
3e1a3ad8 | 293 | } |
294 | } | |
6d50f529 | 295 | |
296 | } | |
297 | } | |
298 | } | |
3e1a3ad8 | 299 | |
300 | // Now check the maxima and calculate the cluster position | |
301 | for ( row = 0; row < nRowMax ; row++) { | |
db30bf0f | 302 | for (time = 0; time < nTimeTotal; time++) { |
303 | for ( col = 1; col < nColMax-1; col++) { | |
3e1a3ad8 | 304 | |
305 | // Maximum found ? | |
3becff3c | 306 | if (digitsOut->GetDataUnchecked(row,col,time) < 0) { |
f7336fa3 | 307 | |
8230f242 | 308 | for (iPad = 0; iPad < kNclus; iPad++) { |
3e1a3ad8 | 309 | Int_t iPadCol = col - 1 + iPad; |
3becff3c | 310 | clusterSignal[iPad] = TMath::Abs(digitsOut->GetDataUnchecked(row |
6d50f529 | 311 | ,iPadCol |
312 | ,time)); | |
3e1a3ad8 | 313 | clusterTracks[3*iPad ] = track0->GetDataUnchecked(row,iPadCol,time) - 1; |
314 | clusterTracks[3*iPad+1] = track1->GetDataUnchecked(row,iPadCol,time) - 1; | |
315 | clusterTracks[3*iPad+2] = track2->GetDataUnchecked(row,iPadCol,time) - 1; | |
f7336fa3 | 316 | } |
317 | ||
db30bf0f | 318 | // Count the number of pads in the cluster |
319 | Int_t nPadCount = 0; | |
320 | Int_t ii = 0; | |
6d50f529 | 321 | while (TMath::Abs(digitsOut->GetDataUnchecked(row,col-ii ,time)) >= sigThresh) { |
db30bf0f | 322 | nPadCount++; |
323 | ii++; | |
324 | if (col-ii < 0) break; | |
325 | } | |
326 | ii = 0; | |
6d50f529 | 327 | while (TMath::Abs(digitsOut->GetDataUnchecked(row,col+ii+1,time)) >= sigThresh) { |
db30bf0f | 328 | nPadCount++; |
329 | ii++; | |
330 | if (col+ii+1 >= nColMax) break; | |
331 | } | |
332 | ||
333 | nClusters++; | |
334 | switch (nPadCount) { | |
335 | case 2: | |
336 | iType = 0; | |
337 | nClusters2pad++; | |
338 | break; | |
339 | case 3: | |
340 | iType = 1; | |
341 | nClusters3pad++; | |
342 | break; | |
343 | case 4: | |
344 | iType = 2; | |
345 | nClusters4pad++; | |
346 | break; | |
347 | case 5: | |
348 | iType = 3; | |
349 | nClusters5pad++; | |
350 | break; | |
351 | default: | |
352 | iType = 4; | |
353 | nClustersLarge++; | |
354 | break; | |
355 | }; | |
356 | ||
6d50f529 | 357 | // Look for 5 pad cluster with minimum in the middle |
db30bf0f | 358 | Bool_t fivePadCluster = kFALSE; |
6d50f529 | 359 | if (col < (nColMax - 3)) { |
3becff3c | 360 | if (digitsOut->GetDataUnchecked(row,col+2,time) < 0) { |
db30bf0f | 361 | fivePadCluster = kTRUE; |
362 | } | |
6d50f529 | 363 | if ((fivePadCluster) && (col < (nColMax - 5))) { |
3becff3c | 364 | if (digitsOut->GetDataUnchecked(row,col+4,time) >= sigThresh) { |
db30bf0f | 365 | fivePadCluster = kFALSE; |
366 | } | |
367 | } | |
6d50f529 | 368 | if ((fivePadCluster) && (col > 1)) { |
3becff3c | 369 | if (digitsOut->GetDataUnchecked(row,col-2,time) >= sigThresh) { |
db30bf0f | 370 | fivePadCluster = kFALSE; |
371 | } | |
372 | } | |
373 | } | |
374 | ||
375 | // 5 pad cluster | |
376 | // Modify the signal of the overlapping pad for the left part | |
377 | // of the cluster which remains from a previous unfolding | |
378 | if (iUnfold) { | |
379 | clusterSignal[0] *= ratioLeft; | |
7ad19338 | 380 | iType = 5; |
db30bf0f | 381 | iUnfold = 0; |
382 | } | |
383 | ||
384 | // Unfold the 5 pad cluster | |
385 | if (fivePadCluster) { | |
386 | for (iPad = 0; iPad < kNsig; iPad++) { | |
3becff3c | 387 | padSignal[iPad] = TMath::Abs(digitsOut->GetDataUnchecked(row |
388 | ,col-1+iPad | |
389 | ,time)); | |
f7336fa3 | 390 | } |
db30bf0f | 391 | // Unfold the two maxima and set the signal on |
392 | // the overlapping pad to the ratio | |
17b26de4 | 393 | ratioRight = Unfold(kEpsilon,iplan,padSignal); |
db30bf0f | 394 | ratioLeft = 1.0 - ratioRight; |
395 | clusterSignal[2] *= ratioRight; | |
7ad19338 | 396 | iType = 5; |
db30bf0f | 397 | iUnfold = 1; |
f7336fa3 | 398 | } |
f7336fa3 | 399 | |
a5cadd36 | 400 | Double_t clusterCharge = clusterSignal[0] |
401 | + clusterSignal[1] | |
402 | + clusterSignal[2]; | |
3e1a3ad8 | 403 | |
db30bf0f | 404 | // The position of the cluster |
3e1a3ad8 | 405 | clusterPads[0] = row + 0.5; |
3e1a3ad8 | 406 | // Take the shift of the additional time bins into account |
dde59437 | 407 | clusterPads[2] = time + 0.5; |
3e1a3ad8 | 408 | |
3551db50 | 409 | if (recParam->LUTOn()) { |
db30bf0f | 410 | // Calculate the position of the cluster by using the |
411 | // lookup table method | |
3becff3c | 412 | clusterPads[1] = recParam->LUTposition(iplan,clusterSignal[0] |
6d50f529 | 413 | ,clusterSignal[1] |
414 | ,clusterSignal[2]); | |
db30bf0f | 415 | } |
416 | else { | |
db30bf0f | 417 | // Calculate the position of the cluster by using the |
418 | // center of gravity method | |
6d50f529 | 419 | for (Int_t i = 0; i < 5; i++) { |
420 | padSignal[i] = 0; | |
421 | } | |
422 | padSignal[2] = TMath::Abs(digitsOut->GetDataUnchecked(row,col ,time)); // central pad | |
3becff3c | 423 | padSignal[1] = TMath::Abs(digitsOut->GetDataUnchecked(row,col-1,time)); // left pad |
424 | padSignal[3] = TMath::Abs(digitsOut->GetDataUnchecked(row,col+1,time)); // right pad | |
6d50f529 | 425 | if ((col > 2) && |
426 | (TMath::Abs(digitsOut->GetDataUnchecked(row,col-2,time)) < padSignal[1])) { | |
3becff3c | 427 | padSignal[0] = TMath::Abs(digitsOut->GetDataUnchecked(row,col-2,time)); |
7ad19338 | 428 | } |
6d50f529 | 429 | if ((col < nColMax - 3) && |
430 | (TMath::Abs(digitsOut->GetDataUnchecked(row,col+2,time)) < padSignal[3])) { | |
3becff3c | 431 | padSignal[4] = TMath::Abs(digitsOut->GetDataUnchecked(row,col+2,time)); |
7ad19338 | 432 | } |
6d50f529 | 433 | clusterPads[1] = GetCOG(padSignal); |
db30bf0f | 434 | } |
435 | ||
a5cadd36 | 436 | Double_t q0 = clusterSignal[0]; |
437 | Double_t q1 = clusterSignal[1]; | |
438 | Double_t q2 = clusterSignal[2]; | |
439 | Double_t clusterSigmaY2 = (q1*(q0+q2)+4*q0*q2) / | |
440 | (clusterCharge*clusterCharge); | |
a819a5f7 | 441 | |
6d50f529 | 442 | // |
3551db50 | 443 | // Calculate the position and the error |
6d50f529 | 444 | // |
445 | ||
446 | // Correct for t0 | |
447 | Int_t clusterTimeBin = TMath::Nint(time - calibration->GetT0(idet, col, row)); | |
448 | ||
449 | Double_t colSize = padPlane->GetColSize(col); | |
450 | Double_t rowSize = padPlane->GetRowSize(row); | |
cb86ff6e | 451 | |
a5cadd36 | 452 | Double_t clusterPos[3]; |
6d50f529 | 453 | clusterPos[0] = padPlane->GetColPos(col) - (clusterPads[1]+0.5)*colSize; |
454 | clusterPos[1] = padPlane->GetRowPos(row) - 0.5*rowSize; | |
455 | clusterPos[2] = CalcXposFromTimebin(clusterPads[2],idet,col,row); | |
a5cadd36 | 456 | Double_t clusterSig[2]; |
5443e65e | 457 | clusterSig[0] = (clusterSigmaY2 + 1./12.) * colSize*colSize; |
7ad19338 | 458 | clusterSig[1] = rowSize * rowSize / 12.; |
3551db50 | 459 | |
460 | ||
f7336fa3 | 461 | // Add the cluster to the output array |
c85a4951 | 462 | AliTRDcluster * cluster = AddCluster(clusterPos |
6d50f529 | 463 | ,clusterTimeBin |
464 | ,idet | |
465 | ,clusterCharge | |
466 | ,clusterTracks | |
467 | ,clusterSig | |
468 | ,iType | |
469 | ,clusterPads[1]); | |
470 | ||
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) || (jPad >= nColMax-1)) { | |
474 | continue; | |
475 | } | |
11dc3a9e | 476 | signals[jPad-col+3] = TMath::Nint(TMath::Abs(digitsOut->GetDataUnchecked(row,jPad,time))); |
c85a4951 | 477 | } |
478 | cluster->SetSignals(signals); | |
6d50f529 | 479 | |
f7336fa3 | 480 | } |
6d50f529 | 481 | |
3e1a3ad8 | 482 | } |
483 | } | |
11dc3a9e | 484 | } |
485 | ||
486 | delete digitsOut; | |
f7336fa3 | 487 | |
11dc3a9e | 488 | // Compress the arrays |
3e1a3ad8 | 489 | track0->Compress(1,0); |
7ad19338 | 490 | track1->Compress(1,0); |
3e1a3ad8 | 491 | track2->Compress(1,0); |
f7336fa3 | 492 | |
3e1a3ad8 | 493 | // Write the cluster and reset the array |
793ff80c | 494 | WriteClusters(idet); |
bdbb05bb | 495 | ResetRecPoints(); |
6d50f529 | 496 | |
3e1a3ad8 | 497 | } |
498 | } | |
499 | } | |
f7336fa3 | 500 | |
f7336fa3 | 501 | return kTRUE; |
502 | ||
503 | } | |
504 | ||
a305677e | 505 | //_____________________________________________________________________________ |
7ad19338 | 506 | Double_t AliTRDclusterizerV1::GetCOG(Double_t signal[5]) |
507 | { | |
508 | // | |
6d50f529 | 509 | // Get COG position |
510 | // Used for clusters with more than 3 pads - where LUT not applicable | |
511 | // | |
512 | ||
7ad19338 | 513 | Double_t sum = signal[0]+signal[1]+signal[2]+signal[3]+signal[4]; |
514 | Double_t res = (0.0*(-signal[0]+signal[4])+(-signal[1]+signal[3]))/sum; | |
6d50f529 | 515 | |
7ad19338 | 516 | return res; |
6d50f529 | 517 | |
7ad19338 | 518 | } |
519 | ||
f7336fa3 | 520 | //_____________________________________________________________________________ |
a5cadd36 | 521 | Double_t AliTRDclusterizerV1::Unfold(Double_t eps, Int_t plane, Double_t* padSignal) |
f7336fa3 | 522 | { |
523 | // | |
524 | // Method to unfold neighbouring maxima. | |
525 | // The charge ratio on the overlapping pad is calculated | |
526 | // until there is no more change within the range given by eps. | |
527 | // The resulting ratio is then returned to the calling method. | |
528 | // | |
529 | ||
6a739e92 | 530 | AliTRDcalibDB* calibration = AliTRDcalibDB::Instance(); |
6d50f529 | 531 | if (!calibration) { |
532 | AliError("No AliTRDcalibDB instance available\n"); | |
6a739e92 | 533 | return kFALSE; |
3551db50 | 534 | } |
6a739e92 | 535 | |
a5cadd36 | 536 | Int_t irc = 0; |
537 | Int_t itStep = 0; // Count iteration steps | |
f7336fa3 | 538 | |
a5cadd36 | 539 | Double_t ratio = 0.5; // Start value for ratio |
540 | Double_t prevRatio = 0; // Store previous ratio | |
f7336fa3 | 541 | |
a5cadd36 | 542 | Double_t newLeftSignal[3] = {0}; // Array to store left cluster signal |
543 | Double_t newRightSignal[3] = {0}; // Array to store right cluster signal | |
544 | Double_t newSignal[3] = {0}; | |
f7336fa3 | 545 | |
3e1a3ad8 | 546 | // Start the iteration |
f7336fa3 | 547 | while ((TMath::Abs(prevRatio - ratio) > eps) && (itStep < 10)) { |
548 | ||
549 | itStep++; | |
550 | prevRatio = ratio; | |
551 | ||
3e1a3ad8 | 552 | // Cluster position according to charge ratio |
a5cadd36 | 553 | Double_t maxLeft = (ratio*padSignal[2] - padSignal[0]) |
554 | / (padSignal[0] + padSignal[1] + ratio*padSignal[2]); | |
555 | Double_t maxRight = (padSignal[4] - (1-ratio)*padSignal[2]) | |
556 | / ((1-ratio)*padSignal[2] + padSignal[3] + padSignal[4]); | |
f7336fa3 | 557 | |
3e1a3ad8 | 558 | // Set cluster charge ratio |
6a739e92 | 559 | irc = calibration->PadResponse(1.0,maxLeft ,plane,newSignal); |
a5cadd36 | 560 | Double_t ampLeft = padSignal[1] / newSignal[1]; |
6a739e92 | 561 | irc = calibration->PadResponse(1.0,maxRight,plane,newSignal); |
a5cadd36 | 562 | Double_t ampRight = padSignal[3] / newSignal[1]; |
f7336fa3 | 563 | |
3e1a3ad8 | 564 | // Apply pad response to parameters |
6a739e92 | 565 | irc = calibration->PadResponse(ampLeft ,maxLeft ,plane,newLeftSignal ); |
566 | irc = calibration->PadResponse(ampRight,maxRight,plane,newRightSignal); | |
f7336fa3 | 567 | |
3e1a3ad8 | 568 | // Calculate new overlapping ratio |
a5cadd36 | 569 | ratio = TMath::Min((Double_t)1.0,newLeftSignal[2] / |
db30bf0f | 570 | (newLeftSignal[2] + newRightSignal[0])); |
f7336fa3 | 571 | |
572 | } | |
573 | ||
574 | return ratio; | |
575 | ||
576 | } | |
577 | ||
3becff3c | 578 | //_____________________________________________________________________________ |
579 | void AliTRDclusterizerV1::Transform(AliTRDdataArrayI* digitsIn, | |
11dc3a9e | 580 | AliTRDdataArrayF* digitsOut, |
3becff3c | 581 | Int_t idet, Int_t nRowMax, |
a305677e | 582 | Int_t nColMax, Int_t nTimeTotal, |
583 | Float_t ADCthreshold) | |
3becff3c | 584 | { |
3becff3c | 585 | // |
cb86ff6e | 586 | // Apply gain factor |
3becff3c | 587 | // Apply tail cancellation: Transform digitsIn to digitsOut |
588 | // | |
589 | ||
6d50f529 | 590 | Int_t iRow = 0; |
591 | Int_t iCol = 0; | |
592 | Int_t iTime = 0; | |
3becff3c | 593 | |
a305677e | 594 | AliTRDRecParam* recParam = AliTRDRecParam::Instance(); |
6d50f529 | 595 | if (!recParam) { |
596 | AliError("No AliTRDRecParam instance available\n"); | |
3becff3c | 597 | return; |
598 | } | |
cb86ff6e | 599 | AliTRDcalibDB* calibration = AliTRDcalibDB::Instance(); |
6d50f529 | 600 | if (!calibration) { |
601 | AliError("No AliTRDcalibDB instance available\n"); | |
602 | return; | |
603 | } | |
11dc3a9e | 604 | |
3becff3c | 605 | Double_t *inADC = new Double_t[nTimeTotal]; // adc data before tail cancellation |
606 | Double_t *outADC = new Double_t[nTimeTotal]; // adc data after tail cancellation | |
607 | ||
6d50f529 | 608 | AliDebug(1,Form("Tail cancellation (nExp = %d) for detector %d.\n" |
609 | ,recParam->GetTCnexp(),idet)); | |
610 | ||
611 | for (iRow = 0; iRow < nRowMax; iRow++ ) { | |
612 | for (iCol = 0; iCol < nColMax; iCol++ ) { | |
613 | for (iTime = 0; iTime < nTimeTotal; iTime++) { | |
3becff3c | 614 | |
cb86ff6e | 615 | // |
6d50f529 | 616 | // Add gain |
cb86ff6e | 617 | // |
6d50f529 | 618 | Double_t gain = calibration->GetGainFactor(idet,iCol,iRow); |
619 | if (gain == 0) { | |
cb86ff6e | 620 | AliError("Not a valid gain\n"); |
621 | } | |
6d50f529 | 622 | inADC[iTime] = digitsIn->GetDataUnchecked(iRow,iCol,iTime); |
11dc3a9e | 623 | inADC[iTime] /= gain; |
624 | outADC[iTime] = inADC[iTime]; | |
6d50f529 | 625 | |
3becff3c | 626 | } |
627 | ||
628 | // Apply the tail cancelation via the digital filter | |
6d50f529 | 629 | if (recParam->TCOn()) { |
a305677e | 630 | DeConvExp(inADC,outADC,nTimeTotal,recParam->GetTCnexp()); |
3becff3c | 631 | } |
632 | ||
6d50f529 | 633 | for (iTime = 0; iTime < nTimeTotal; iTime++) { |
634 | ||
3becff3c | 635 | // Store the amplitude of the digit if above threshold |
a305677e | 636 | if (outADC[iTime] > ADCthreshold) { |
6d50f529 | 637 | AliDebug(2,Form(" iRow = %d, iCol = %d, iTime = %d, adc = %f\n" |
638 | ,iRow,iCol,iTime,outADC[iTime])); | |
11dc3a9e | 639 | digitsOut->SetDataUnchecked(iRow,iCol,iTime,outADC[iTime]); |
3becff3c | 640 | } |
641 | ||
642 | } | |
643 | ||
644 | } | |
3becff3c | 645 | } |
646 | ||
647 | delete [] inADC; | |
648 | delete [] outADC; | |
649 | ||
650 | return; | |
651 | ||
652 | } | |
653 | ||
3becff3c | 654 | //_____________________________________________________________________________ |
655 | void AliTRDclusterizerV1::DeConvExp(Double_t *source, Double_t *target, | |
656 | Int_t n, Int_t nexp) | |
657 | { | |
658 | // | |
6d50f529 | 659 | // Tail cancellation by deconvolution for PASA v4 TRF |
3becff3c | 660 | // |
661 | ||
662 | Double_t rates[2]; | |
663 | Double_t coefficients[2]; | |
664 | ||
6d50f529 | 665 | // Initialization (coefficient = alpha, rates = lambda) |
3becff3c | 666 | Double_t R1 = 1.0; |
667 | Double_t R2 = 1.0; | |
668 | Double_t C1 = 0.5; | |
669 | Double_t C2 = 0.5; | |
670 | ||
671 | if (nexp == 1) { // 1 Exponentials | |
672 | R1 = 1.156; | |
673 | R2 = 0.130; | |
674 | C1 = 0.066; | |
675 | C2 = 0.000; | |
676 | } | |
677 | if (nexp == 2) { // 2 Exponentials | |
678 | R1 = 1.156; | |
679 | R2 = 0.130; | |
680 | C1 = 0.114; | |
681 | C2 = 0.624; | |
682 | } | |
683 | ||
684 | coefficients[0] = C1; | |
685 | coefficients[1] = C2; | |
686 | ||
687 | Double_t Dt = 0.100; | |
688 | ||
689 | rates[0] = TMath::Exp(-Dt/(R1)); | |
690 | rates[1] = TMath::Exp(-Dt/(R2)); | |
691 | ||
6d50f529 | 692 | Int_t i = 0; |
693 | Int_t k = 0; | |
3becff3c | 694 | |
6d50f529 | 695 | Double_t reminder[2]; |
696 | Double_t correction; | |
697 | Double_t result; | |
3becff3c | 698 | |
6d50f529 | 699 | // Attention: computation order is important |
700 | correction = 0.0; | |
701 | for (k = 0; k < nexp; k++) { | |
702 | reminder[k] = 0.0; | |
703 | } | |
704 | for (i = 0; i < n; i++) { | |
705 | result = (source[i] - correction); // no rescaling | |
3becff3c | 706 | target[i] = result; |
707 | ||
6d50f529 | 708 | for (k = 0; k < nexp; k++) { |
709 | reminder[k] = rates[k] * (reminder[k] + coefficients[k] * result); | |
710 | } | |
711 | correction = 0.0; | |
712 | for (k = 0; k < nexp; k++) { | |
713 | correction += reminder[k]; | |
714 | } | |
3becff3c | 715 | } |
716 | ||
717 | } |