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