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