]>
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" |
c85a4951 | 46 | #include "AliTRDcluster.h" |
f7336fa3 | 47 | |
56178ff4 | 48 | #include "Cal/AliTRDCalROC.h" |
49 | #include "Cal/AliTRDCalDet.h" | |
50 | ||
f7336fa3 | 51 | ClassImp(AliTRDclusterizerV1) |
52 | ||
53 | //_____________________________________________________________________________ | |
6d50f529 | 54 | AliTRDclusterizerV1::AliTRDclusterizerV1() |
55 | :AliTRDclusterizer() | |
56 | ,fDigitsManager(NULL) | |
f7336fa3 | 57 | { |
58 | // | |
59 | // AliTRDclusterizerV1 default constructor | |
60 | // | |
61 | ||
f7336fa3 | 62 | } |
63 | ||
64 | //_____________________________________________________________________________ | |
a6dd11e9 | 65 | AliTRDclusterizerV1::AliTRDclusterizerV1(const Text_t *name, const Text_t *title) |
6d50f529 | 66 | :AliTRDclusterizer(name,title) |
67 | ,fDigitsManager(new AliTRDdigitsManager()) | |
f7336fa3 | 68 | { |
69 | // | |
6d50f529 | 70 | // AliTRDclusterizerV1 constructor |
f7336fa3 | 71 | // |
72 | ||
17b26de4 | 73 | fDigitsManager->CreateArrays(); |
f7336fa3 | 74 | |
75 | } | |
76 | ||
8230f242 | 77 | //_____________________________________________________________________________ |
dd9a6ee3 | 78 | AliTRDclusterizerV1::AliTRDclusterizerV1(const AliTRDclusterizerV1 &c) |
6d50f529 | 79 | :AliTRDclusterizer(c) |
80 | ,fDigitsManager(NULL) | |
8230f242 | 81 | { |
82 | // | |
83 | // AliTRDclusterizerV1 copy constructor | |
84 | // | |
85 | ||
8230f242 | 86 | } |
87 | ||
f7336fa3 | 88 | //_____________________________________________________________________________ |
89 | AliTRDclusterizerV1::~AliTRDclusterizerV1() | |
90 | { | |
8230f242 | 91 | // |
92 | // AliTRDclusterizerV1 destructor | |
93 | // | |
f7336fa3 | 94 | |
6f1e466d | 95 | if (fDigitsManager) { |
96 | delete fDigitsManager; | |
abaf1f1d | 97 | fDigitsManager = NULL; |
f7336fa3 | 98 | } |
99 | ||
100 | } | |
101 | ||
dd9a6ee3 | 102 | //_____________________________________________________________________________ |
103 | AliTRDclusterizerV1 &AliTRDclusterizerV1::operator=(const AliTRDclusterizerV1 &c) | |
104 | { | |
105 | // | |
106 | // Assignment operator | |
107 | // | |
108 | ||
109 | if (this != &c) ((AliTRDclusterizerV1 &) c).Copy(*this); | |
110 | return *this; | |
111 | ||
112 | } | |
113 | ||
8230f242 | 114 | //_____________________________________________________________________________ |
e0d47c25 | 115 | void AliTRDclusterizerV1::Copy(TObject &c) const |
8230f242 | 116 | { |
117 | // | |
118 | // Copy function | |
119 | // | |
120 | ||
17b26de4 | 121 | ((AliTRDclusterizerV1 &) c).fDigitsManager = 0; |
8230f242 | 122 | |
123 | AliTRDclusterizer::Copy(c); | |
124 | ||
125 | } | |
126 | ||
f7336fa3 | 127 | //_____________________________________________________________________________ |
128 | Bool_t AliTRDclusterizerV1::ReadDigits() | |
129 | { | |
130 | // | |
131 | // Reads the digits arrays from the input aliroot file | |
132 | // | |
133 | ||
88cb7938 | 134 | if (!fRunLoader) { |
6d50f529 | 135 | AliError("No run loader available"); |
f7336fa3 | 136 | return kFALSE; |
137 | } | |
6d50f529 | 138 | |
88cb7938 | 139 | AliLoader* loader = fRunLoader->GetLoader("TRDLoader"); |
6d50f529 | 140 | if (!loader->TreeD()) { |
141 | loader->LoadDigits(); | |
142 | } | |
abaf1f1d | 143 | |
f7336fa3 | 144 | // Read in the digit arrays |
88cb7938 | 145 | return (fDigitsManager->ReadDigits(loader->TreeD())); |
f7336fa3 | 146 | |
147 | } | |
148 | ||
25ca55ce | 149 | //_____________________________________________________________________________ |
150 | Bool_t AliTRDclusterizerV1::ReadDigits(TTree *digitsTree) | |
151 | { | |
152 | // | |
153 | // Reads the digits arrays from the input tree | |
154 | // | |
155 | ||
156 | // Read in the digit arrays | |
157 | return (fDigitsManager->ReadDigits(digitsTree)); | |
158 | ||
159 | } | |
160 | ||
928e9fae | 161 | //_____________________________________________________________________________ |
a6dd11e9 | 162 | Bool_t AliTRDclusterizerV1::ReadDigits(AliRawReader *rawReader) |
928e9fae | 163 | { |
164 | // | |
165 | // Reads the digits arrays from the ddl file | |
166 | // | |
167 | ||
4ab68796 | 168 | AliTRDrawData raw; |
4ab68796 | 169 | fDigitsManager = raw.Raw2Digits(rawReader); |
928e9fae | 170 | |
171 | return kTRUE; | |
172 | ||
173 | } | |
174 | ||
f7336fa3 | 175 | //_____________________________________________________________________________ |
793ff80c | 176 | Bool_t AliTRDclusterizerV1::MakeClusters() |
f7336fa3 | 177 | { |
178 | // | |
179 | // Generates the cluster. | |
180 | // | |
181 | ||
6d50f529 | 182 | Int_t row = 0; |
183 | Int_t col = 0; | |
184 | Int_t time = 0; | |
185 | Int_t icham = 0; | |
186 | Int_t iplan = 0; | |
187 | Int_t isect = 0; | |
188 | Int_t iPad = 0; | |
189 | ||
190 | AliTRDdataArrayI *digitsIn; | |
a6dd11e9 | 191 | AliTRDdataArrayI *tracksIn; |
f7336fa3 | 192 | |
f162af62 | 193 | AliTRDgeometry geo; |
a6dd11e9 | 194 | |
6d50f529 | 195 | AliTRDcalibDB *calibration = AliTRDcalibDB::Instance(); |
196 | if (!calibration) { | |
4fad09c9 | 197 | AliFatal("No AliTRDcalibDB instance available\n"); |
3551db50 | 198 | return kFALSE; |
199 | } | |
200 | ||
6d50f529 | 201 | AliTRDSimParam *simParam = AliTRDSimParam::Instance(); |
202 | if (!simParam) { | |
203 | AliError("No AliTRDSimParam instance available\n"); | |
3becff3c | 204 | return kFALSE; |
205 | } | |
206 | ||
6d50f529 | 207 | AliTRDRecParam *recParam = AliTRDRecParam::Instance(); |
208 | if (!recParam) { | |
209 | AliError("No AliTRDRecParam instance available\n"); | |
3551db50 | 210 | return kFALSE; |
211 | } | |
f7336fa3 | 212 | |
8ec071c8 | 213 | // ADC thresholds |
a6dd11e9 | 214 | Float_t ADCthreshold = simParam->GetADCthreshold(); |
3e1a3ad8 | 215 | // Threshold value for the maximum |
a6dd11e9 | 216 | Float_t maxThresh = recParam->GetClusMaxThresh(); |
3e1a3ad8 | 217 | // Threshold value for the digit signal |
a6dd11e9 | 218 | Float_t sigThresh = recParam->GetClusSigThresh(); |
6d50f529 | 219 | |
56178ff4 | 220 | // Detector wise calibration object for t0 |
8ec071c8 | 221 | const AliTRDCalDet *calT0Det = calibration->GetT0Det(); |
222 | // Detector wise calibration object for the gain factors | |
223 | const AliTRDCalDet *calGainFactorDet = calibration->GetGainFactorDet(); | |
56178ff4 | 224 | |
f7336fa3 | 225 | // Iteration limit for unfolding procedure |
8230f242 | 226 | const Float_t kEpsilon = 0.01; |
8230f242 | 227 | const Int_t kNclus = 3; |
228 | const Int_t kNsig = 5; | |
a6dd11e9 | 229 | const Int_t kNdict = AliTRDdigitsManager::kNDict; |
230 | const Int_t kNtrack = kNdict * kNclus; | |
3e1a3ad8 | 231 | |
7ad19338 | 232 | Int_t iUnfold = 0; |
a5cadd36 | 233 | Double_t ratioLeft = 1.0; |
234 | Double_t ratioRight = 1.0; | |
db30bf0f | 235 | |
a6dd11e9 | 236 | Int_t iClusterROC = 0; |
237 | ||
a5cadd36 | 238 | Double_t padSignal[kNsig]; |
239 | Double_t clusterSignal[kNclus]; | |
240 | Double_t clusterPads[kNclus]; | |
f7336fa3 | 241 | |
6d50f529 | 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(); | |
f7336fa3 | 249 | |
6d50f529 | 250 | AliDebug(1,Form("Number of Time Bins = %d.\n",nTimeTotal)); |
3becff3c | 251 | |
3e1a3ad8 | 252 | // Start clustering in every chamber |
6d50f529 | 253 | for (icham = chamBeg; icham < chamEnd; icham++) { |
254 | for (iplan = planBeg; iplan < planEnd; iplan++) { | |
255 | for (isect = sectBeg; isect < sectEnd; isect++) { | |
f7336fa3 | 256 | |
f162af62 | 257 | Int_t idet = geo.GetDetector(iplan,icham,isect); |
d74f970b | 258 | Int_t ilayer = AliGeomManager::kTRD1 + iplan; |
259 | Int_t imodule = icham + chamEnd * isect; | |
260 | UShort_t volid = AliGeomManager::LayerToVolUID(ilayer,imodule); | |
a6dd11e9 | 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 | ||
f162af62 | 272 | Int_t nRowMax = geo.GetRowMax(iplan,icham,isect); |
273 | Int_t nColMax = geo.GetColMax(iplan); | |
f7336fa3 | 274 | |
f162af62 | 275 | AliTRDpadPlane *padPlane = geo.GetPadPlane(iplan,icham); |
6d50f529 | 276 | |
56178ff4 | 277 | // Calibration object with pad wise values for t0 |
8ec071c8 | 278 | AliTRDCalROC *calT0ROC = calibration->GetT0ROC(idet); |
279 | // Calibration object with pad wise values for the gain factors | |
280 | AliTRDCalROC *calGainFactorROC = calibration->GetGainFactorROC(idet); | |
56178ff4 | 281 | // Calibration value for chamber wise t0 |
8ec071c8 | 282 | Float_t calT0DetValue = calT0Det->GetValue(idet); |
283 | // Calibration value for chamber wise gain factor | |
284 | Float_t calGainFactorDetValue = calGainFactorDet->GetValue(idet); | |
56178ff4 | 285 | |
db30bf0f | 286 | Int_t nClusters = 0; |
3e1a3ad8 | 287 | |
a6dd11e9 | 288 | // Apply the gain and the tail cancelation via digital filter |
6d50f529 | 289 | AliTRDdataArrayF *digitsOut = new AliTRDdataArrayF(digitsIn->GetNrow() |
290 | ,digitsIn->GetNcol() | |
8ec071c8 | 291 | ,digitsIn->GetNtime()); |
292 | Transform(digitsIn | |
293 | ,digitsOut | |
294 | ,nRowMax,nColMax,nTimeTotal | |
295 | ,ADCthreshold | |
296 | ,calGainFactorROC | |
297 | ,calGainFactorDetValue); | |
a6dd11e9 | 298 | |
299 | // Input digits are not needed any more | |
300 | digitsIn->Compress(1,0); | |
6d50f529 | 301 | |
3e1a3ad8 | 302 | // Loop through the chamber and find the maxima |
303 | for ( row = 0; row < nRowMax; row++) { | |
de4b10e5 | 304 | for ( col = 2; col < nColMax; col++) { |
3e1a3ad8 | 305 | for (time = 0; time < nTimeTotal; time++) { |
306 | ||
11dc3a9e | 307 | Float_t signalM = TMath::Abs(digitsOut->GetDataUnchecked(row,col-1,time)); |
3e1a3ad8 | 308 | |
309 | // Look for the maximum | |
db30bf0f | 310 | if (signalM >= maxThresh) { |
6a242715 | 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 | ||
6d50f529 | 315 | if ((TMath::Abs(signalL) <= signalM) && |
21ee7de5 | 316 | (TMath::Abs(signalR) < signalM)) { |
6493a90f | 317 | if ((TMath::Abs(signalL) >= sigThresh) || |
318 | (TMath::Abs(signalR) >= sigThresh)) { | |
a6dd11e9 | 319 | // Maximum found, mark the position by a negative signal |
320 | digitsOut->SetDataUnchecked(row,col-1,time,-signalM); | |
321 | } | |
3e1a3ad8 | 322 | } |
6a242715 | 323 | |
3e1a3ad8 | 324 | } |
6d50f529 | 325 | |
326 | } | |
327 | } | |
328 | } | |
a6dd11e9 | 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; | |
3e1a3ad8 | 335 | |
336 | // Now check the maxima and calculate the cluster position | |
337 | for ( row = 0; row < nRowMax ; row++) { | |
db30bf0f | 338 | for (time = 0; time < nTimeTotal; time++) { |
339 | for ( col = 1; col < nColMax-1; col++) { | |
3e1a3ad8 | 340 | |
341 | // Maximum found ? | |
a6dd11e9 | 342 | if (digitsOut->GetDataUnchecked(row,col,time) < 0.0) { |
f7336fa3 | 343 | |
8230f242 | 344 | for (iPad = 0; iPad < kNclus; iPad++) { |
3e1a3ad8 | 345 | Int_t iPadCol = col - 1 + iPad; |
a6dd11e9 | 346 | clusterSignal[iPad] = |
347 | TMath::Abs(digitsOut->GetDataUnchecked(row,iPadCol,time)); | |
f7336fa3 | 348 | } |
349 | ||
db30bf0f | 350 | // Count the number of pads in the cluster |
351 | Int_t nPadCount = 0; | |
a6dd11e9 | 352 | Int_t ii; |
353 | // Look to the left | |
354 | ii = 0; | |
6d50f529 | 355 | while (TMath::Abs(digitsOut->GetDataUnchecked(row,col-ii ,time)) >= sigThresh) { |
db30bf0f | 356 | nPadCount++; |
357 | ii++; | |
358 | if (col-ii < 0) break; | |
359 | } | |
a6dd11e9 | 360 | // Look to the right |
db30bf0f | 361 | ii = 0; |
6d50f529 | 362 | while (TMath::Abs(digitsOut->GetDataUnchecked(row,col+ii+1,time)) >= sigThresh) { |
db30bf0f | 363 | nPadCount++; |
364 | ii++; | |
365 | if (col+ii+1 >= nColMax) break; | |
366 | } | |
db30bf0f | 367 | nClusters++; |
db30bf0f | 368 | |
6d50f529 | 369 | // Look for 5 pad cluster with minimum in the middle |
db30bf0f | 370 | Bool_t fivePadCluster = kFALSE; |
6d50f529 | 371 | if (col < (nColMax - 3)) { |
3becff3c | 372 | if (digitsOut->GetDataUnchecked(row,col+2,time) < 0) { |
db30bf0f | 373 | fivePadCluster = kTRUE; |
374 | } | |
6d50f529 | 375 | if ((fivePadCluster) && (col < (nColMax - 5))) { |
3becff3c | 376 | if (digitsOut->GetDataUnchecked(row,col+4,time) >= sigThresh) { |
db30bf0f | 377 | fivePadCluster = kFALSE; |
378 | } | |
379 | } | |
6d50f529 | 380 | if ((fivePadCluster) && (col > 1)) { |
3becff3c | 381 | if (digitsOut->GetDataUnchecked(row,col-2,time) >= sigThresh) { |
db30bf0f | 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; | |
db30bf0f | 392 | iUnfold = 0; |
393 | } | |
394 | ||
395 | // Unfold the 5 pad cluster | |
396 | if (fivePadCluster) { | |
397 | for (iPad = 0; iPad < kNsig; iPad++) { | |
3becff3c | 398 | padSignal[iPad] = TMath::Abs(digitsOut->GetDataUnchecked(row |
a6dd11e9 | 399 | ,col-1+iPad |
400 | ,time)); | |
f7336fa3 | 401 | } |
db30bf0f | 402 | // Unfold the two maxima and set the signal on |
403 | // the overlapping pad to the ratio | |
17b26de4 | 404 | ratioRight = Unfold(kEpsilon,iplan,padSignal); |
db30bf0f | 405 | ratioLeft = 1.0 - ratioRight; |
406 | clusterSignal[2] *= ratioRight; | |
db30bf0f | 407 | iUnfold = 1; |
f7336fa3 | 408 | } |
f7336fa3 | 409 | |
a5cadd36 | 410 | Double_t clusterCharge = clusterSignal[0] |
411 | + clusterSignal[1] | |
412 | + clusterSignal[2]; | |
3e1a3ad8 | 413 | |
db30bf0f | 414 | // The position of the cluster |
a6dd11e9 | 415 | clusterPads[0] = row + 0.5; |
3e1a3ad8 | 416 | // Take the shift of the additional time bins into account |
dde59437 | 417 | clusterPads[2] = time + 0.5; |
3e1a3ad8 | 418 | |
3551db50 | 419 | if (recParam->LUTOn()) { |
db30bf0f | 420 | // Calculate the position of the cluster by using the |
421 | // lookup table method | |
3becff3c | 422 | clusterPads[1] = recParam->LUTposition(iplan,clusterSignal[0] |
6d50f529 | 423 | ,clusterSignal[1] |
424 | ,clusterSignal[2]); | |
db30bf0f | 425 | } |
426 | else { | |
db30bf0f | 427 | // Calculate the position of the cluster by using the |
428 | // center of gravity method | |
a6dd11e9 | 429 | for (Int_t i = 0; i < kNsig; i++) { |
430 | padSignal[i] = 0.0; | |
6d50f529 | 431 | } |
a6dd11e9 | 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 | |
6d50f529 | 435 | if ((col > 2) && |
436 | (TMath::Abs(digitsOut->GetDataUnchecked(row,col-2,time)) < padSignal[1])) { | |
3becff3c | 437 | padSignal[0] = TMath::Abs(digitsOut->GetDataUnchecked(row,col-2,time)); |
7ad19338 | 438 | } |
6d50f529 | 439 | if ((col < nColMax - 3) && |
440 | (TMath::Abs(digitsOut->GetDataUnchecked(row,col+2,time)) < padSignal[3])) { | |
3becff3c | 441 | padSignal[4] = TMath::Abs(digitsOut->GetDataUnchecked(row,col+2,time)); |
7ad19338 | 442 | } |
6d50f529 | 443 | clusterPads[1] = GetCOG(padSignal); |
db30bf0f | 444 | } |
445 | ||
a5cadd36 | 446 | Double_t q0 = clusterSignal[0]; |
447 | Double_t q1 = clusterSignal[1]; | |
448 | Double_t q2 = clusterSignal[2]; | |
a6dd11e9 | 449 | Double_t clusterSigmaY2 = (q1 * (q0 + q2) + 4.0 * q0 * q2) |
450 | / (clusterCharge*clusterCharge); | |
a819a5f7 | 451 | |
6d50f529 | 452 | // |
3551db50 | 453 | // Calculate the position and the error |
6d50f529 | 454 | // |
455 | ||
56178ff4 | 456 | // Correct for t0 (sum of chamber and pad wise values !!!) |
457 | Float_t calT0ROCValue = calT0ROC->GetValue(col,row); | |
34eaaa7e | 458 | Char_t clusterTimeBin = ((Char_t) TMath::Nint(time - (calT0DetValue + calT0ROCValue))); |
6d50f529 | 459 | Double_t colSize = padPlane->GetColSize(col); |
460 | Double_t rowSize = padPlane->GetRowSize(row); | |
cb86ff6e | 461 | |
34eaaa7e | 462 | Float_t clusterPos[3]; |
a6dd11e9 | 463 | clusterPos[0] = padPlane->GetColPos(col) - (clusterPads[1] + 0.5) * colSize; |
464 | clusterPos[1] = padPlane->GetRowPos(row) - 0.5 * rowSize; | |
6d50f529 | 465 | clusterPos[2] = CalcXposFromTimebin(clusterPads[2],idet,col,row); |
34eaaa7e | 466 | Float_t clusterSig[2]; |
a6dd11e9 | 467 | clusterSig[0] = (clusterSigmaY2 + 1.0/12.0) * colSize*colSize; |
468 | clusterSig[1] = rowSize * rowSize / 12.0; | |
524fc8fa | 469 | |
a6dd11e9 | 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 }; | |
6d50f529 | 472 | for (Int_t jPad = col-3; jPad <= col+3; jPad++) { |
a6dd11e9 | 473 | if ((jPad < 0) || |
474 | (jPad >= nColMax-1)) { | |
6d50f529 | 475 | continue; |
476 | } | |
11dc3a9e | 477 | signals[jPad-col+3] = TMath::Nint(TMath::Abs(digitsOut->GetDataUnchecked(row,jPad,time))); |
c85a4951 | 478 | } |
6d50f529 | 479 | |
34eaaa7e | 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); | |
a6dd11e9 | 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); | |
34eaaa7e | 498 | RecPoints()->Add(cluster); |
6d50f529 | 499 | |
a6dd11e9 | 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 | |
11dc3a9e | 512 | |
513 | delete digitsOut; | |
f7336fa3 | 514 | |
a6dd11e9 | 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; | |
f7336fa3 | 566 | |
3e1a3ad8 | 567 | // Write the cluster and reset the array |
793ff80c | 568 | WriteClusters(idet); |
bdbb05bb | 569 | ResetRecPoints(); |
6d50f529 | 570 | |
a6dd11e9 | 571 | } // loop: Sectors |
572 | } // loop: Planes | |
573 | } // loop: Chambers | |
f7336fa3 | 574 | |
f7336fa3 | 575 | return kTRUE; |
576 | ||
577 | } | |
578 | ||
a305677e | 579 | //_____________________________________________________________________________ |
7ad19338 | 580 | Double_t AliTRDclusterizerV1::GetCOG(Double_t signal[5]) |
581 | { | |
582 | // | |
6d50f529 | 583 | // Get COG position |
584 | // Used for clusters with more than 3 pads - where LUT not applicable | |
585 | // | |
586 | ||
a6dd11e9 | 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; | |
6d50f529 | 595 | |
7ad19338 | 596 | return res; |
6d50f529 | 597 | |
7ad19338 | 598 | } |
599 | ||
f7336fa3 | 600 | //_____________________________________________________________________________ |
a6dd11e9 | 601 | Double_t AliTRDclusterizerV1::Unfold(Double_t eps, Int_t plane, Double_t *padSignal) |
f7336fa3 | 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 | ||
a6dd11e9 | 610 | AliTRDcalibDB *calibration = AliTRDcalibDB::Instance(); |
6d50f529 | 611 | if (!calibration) { |
612 | AliError("No AliTRDcalibDB instance available\n"); | |
6a739e92 | 613 | return kFALSE; |
3551db50 | 614 | } |
6a739e92 | 615 | |
a5cadd36 | 616 | Int_t irc = 0; |
a6dd11e9 | 617 | Int_t itStep = 0; // Count iteration steps |
f7336fa3 | 618 | |
a6dd11e9 | 619 | Double_t ratio = 0.5; // Start value for ratio |
620 | Double_t prevRatio = 0.0; // Store previous ratio | |
f7336fa3 | 621 | |
a6dd11e9 | 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 }; | |
f7336fa3 | 625 | |
3e1a3ad8 | 626 | // Start the iteration |
f7336fa3 | 627 | while ((TMath::Abs(prevRatio - ratio) > eps) && (itStep < 10)) { |
628 | ||
629 | itStep++; | |
630 | prevRatio = ratio; | |
631 | ||
3e1a3ad8 | 632 | // Cluster position according to charge ratio |
a5cadd36 | 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]) | |
a6dd11e9 | 636 | / ((1.0 - ratio)*padSignal[2] + padSignal[3] + padSignal[4]); |
f7336fa3 | 637 | |
3e1a3ad8 | 638 | // Set cluster charge ratio |
6a739e92 | 639 | irc = calibration->PadResponse(1.0,maxLeft ,plane,newSignal); |
a5cadd36 | 640 | Double_t ampLeft = padSignal[1] / newSignal[1]; |
6a739e92 | 641 | irc = calibration->PadResponse(1.0,maxRight,plane,newSignal); |
a5cadd36 | 642 | Double_t ampRight = padSignal[3] / newSignal[1]; |
f7336fa3 | 643 | |
3e1a3ad8 | 644 | // Apply pad response to parameters |
6a739e92 | 645 | irc = calibration->PadResponse(ampLeft ,maxLeft ,plane,newLeftSignal ); |
646 | irc = calibration->PadResponse(ampRight,maxRight,plane,newRightSignal); | |
f7336fa3 | 647 | |
3e1a3ad8 | 648 | // Calculate new overlapping ratio |
a5cadd36 | 649 | ratio = TMath::Min((Double_t)1.0,newLeftSignal[2] / |
a6dd11e9 | 650 | (newLeftSignal[2] + newRightSignal[0])); |
f7336fa3 | 651 | |
652 | } | |
653 | ||
654 | return ratio; | |
655 | ||
656 | } | |
657 | ||
3becff3c | 658 | //_____________________________________________________________________________ |
a6dd11e9 | 659 | void AliTRDclusterizerV1::Transform(AliTRDdataArrayI *digitsIn |
660 | , AliTRDdataArrayF *digitsOut | |
8ec071c8 | 661 | , Int_t nRowMax, Int_t nColMax, Int_t nTimeTotal |
662 | , Float_t ADCthreshold | |
663 | , AliTRDCalROC *calGainFactorROC | |
664 | , Float_t calGainFactorDetValue) | |
3becff3c | 665 | { |
3becff3c | 666 | // |
cb86ff6e | 667 | // Apply gain factor |
a6dd11e9 | 668 | // Apply tail cancelation: Transform digitsIn to digitsOut |
3becff3c | 669 | // |
670 | ||
6d50f529 | 671 | Int_t iRow = 0; |
672 | Int_t iCol = 0; | |
673 | Int_t iTime = 0; | |
3becff3c | 674 | |
a6dd11e9 | 675 | AliTRDRecParam *recParam = AliTRDRecParam::Instance(); |
6d50f529 | 676 | if (!recParam) { |
677 | AliError("No AliTRDRecParam instance available\n"); | |
3becff3c | 678 | return; |
679 | } | |
11dc3a9e | 680 | |
a6dd11e9 | 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 | |
3becff3c | 683 | |
6d50f529 | 684 | for (iRow = 0; iRow < nRowMax; iRow++ ) { |
685 | for (iCol = 0; iCol < nColMax; iCol++ ) { | |
a6dd11e9 | 686 | |
56178ff4 | 687 | Float_t calGainFactorROCValue = calGainFactorROC->GetValue(iCol,iRow); |
688 | Double_t gain = calGainFactorDetValue | |
689 | * calGainFactorROCValue; | |
690 | ||
6d50f529 | 691 | for (iTime = 0; iTime < nTimeTotal; iTime++) { |
3becff3c | 692 | |
cb86ff6e | 693 | // |
6d50f529 | 694 | // Add gain |
cb86ff6e | 695 | // |
a6dd11e9 | 696 | inADC[iTime] = digitsIn->GetDataUnchecked(iRow,iCol,iTime); |
697 | inADC[iTime] /= gain; | |
698 | outADC[iTime] = inADC[iTime]; | |
6d50f529 | 699 | |
3becff3c | 700 | } |
701 | ||
702 | // Apply the tail cancelation via the digital filter | |
6d50f529 | 703 | if (recParam->TCOn()) { |
a305677e | 704 | DeConvExp(inADC,outADC,nTimeTotal,recParam->GetTCnexp()); |
3becff3c | 705 | } |
706 | ||
6d50f529 | 707 | for (iTime = 0; iTime < nTimeTotal; iTime++) { |
708 | ||
3becff3c | 709 | // Store the amplitude of the digit if above threshold |
a305677e | 710 | if (outADC[iTime] > ADCthreshold) { |
11dc3a9e | 711 | digitsOut->SetDataUnchecked(iRow,iCol,iTime,outADC[iTime]); |
3becff3c | 712 | } |
713 | ||
714 | } | |
715 | ||
716 | } | |
3becff3c | 717 | } |
718 | ||
719 | delete [] inADC; | |
720 | delete [] outADC; | |
721 | ||
722 | return; | |
723 | ||
724 | } | |
725 | ||
3becff3c | 726 | //_____________________________________________________________________________ |
a6dd11e9 | 727 | void AliTRDclusterizerV1::DeConvExp(Double_t *source, Double_t *target |
728 | , Int_t n, Int_t nexp) | |
3becff3c | 729 | { |
730 | // | |
6d50f529 | 731 | // Tail cancellation by deconvolution for PASA v4 TRF |
3becff3c | 732 | // |
733 | ||
734 | Double_t rates[2]; | |
735 | Double_t coefficients[2]; | |
736 | ||
6d50f529 | 737 | // Initialization (coefficient = alpha, rates = lambda) |
3becff3c | 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 | ||
a6dd11e9 | 759 | Double_t Dt = 0.1; |
3becff3c | 760 | |
761 | rates[0] = TMath::Exp(-Dt/(R1)); | |
762 | rates[1] = TMath::Exp(-Dt/(R2)); | |
763 | ||
6d50f529 | 764 | Int_t i = 0; |
765 | Int_t k = 0; | |
3becff3c | 766 | |
6d50f529 | 767 | Double_t reminder[2]; |
768 | Double_t correction; | |
769 | Double_t result; | |
3becff3c | 770 | |
6d50f529 | 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++) { | |
a6dd11e9 | 777 | result = (source[i] - correction); // No rescaling |
3becff3c | 778 | target[i] = result; |
779 | ||
6d50f529 | 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 | } | |
3becff3c | 787 | } |
788 | ||
789 | } |