1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
18 Revision 1.15 2001/11/14 12:09:11 cblume
19 Use correct name for digitizer
21 Revision 1.14 2001/11/14 10:50:45 cblume
22 Changes in digits IO. Add merging of summable digits
24 Revision 1.13 2001/05/28 17:07:58 hristov
25 Last minute changes; ExB correction in AliTRDclusterizerV1; taking into account of material in G10 TEC frames and material between TEC planes (C.Blume,S.Sedykh)
27 Revision 1.12 2001/05/21 17:42:58 hristov
28 Constant casted to avoid the ambiguity
30 Revision 1.11 2001/05/21 16:45:47 hristov
31 Last minute changes (C.Blume)
33 Revision 1.10 2001/05/07 08:06:44 cblume
34 Speedup of the code. Create only AliTRDcluster
36 Revision 1.9 2000/11/01 14:53:20 cblume
37 Merge with TRD-develop
39 Revision 1.1.4.5 2000/10/15 23:40:01 cblume
42 Revision 1.1.4.4 2000/10/06 16:49:46 cblume
45 Revision 1.1.4.3 2000/10/04 16:34:58 cblume
46 Replace include files by forward declarations
48 Revision 1.1.4.2 2000/09/22 14:49:49 cblume
49 Adapted to tracking code
51 Revision 1.8 2000/10/02 21:28:19 fca
52 Removal of useless dependecies via forward declarations
54 Revision 1.7 2000/06/27 13:08:50 cblume
55 Changed to Copy(TObject &A) to appease the HP-compiler
57 Revision 1.6 2000/06/09 11:10:07 cblume
58 Compiler warnings and coding conventions, next round
60 Revision 1.5 2000/06/08 18:32:58 cblume
61 Make code compliant to coding conventions
63 Revision 1.4 2000/06/07 16:27:01 cblume
64 Try to remove compiler warnings on Sun and HP
66 Revision 1.3 2000/05/08 16:17:27 cblume
69 Revision 1.1.4.1 2000/05/08 15:09:01 cblume
70 Introduce AliTRDdigitsManager
72 Revision 1.1 2000/02/28 18:58:54 cblume
77 ///////////////////////////////////////////////////////////////////////////////
79 // TRD cluster finder for the slow simulator.
81 ///////////////////////////////////////////////////////////////////////////////
91 #include "AliTRDclusterizerV1.h"
92 #include "AliTRDmatrix.h"
93 #include "AliTRDgeometry.h"
94 #include "AliTRDdigitizer.h"
95 #include "AliTRDdataArrayF.h"
96 #include "AliTRDdataArrayI.h"
97 #include "AliTRDdigitsManager.h"
98 #include "AliTRDparameter.h"
100 ClassImp(AliTRDclusterizerV1)
102 //_____________________________________________________________________________
103 AliTRDclusterizerV1::AliTRDclusterizerV1():AliTRDclusterizer()
106 // AliTRDclusterizerV1 default constructor
114 //_____________________________________________________________________________
115 AliTRDclusterizerV1::AliTRDclusterizerV1(const Text_t* name, const Text_t* title)
116 :AliTRDclusterizer(name,title)
119 // AliTRDclusterizerV1 default constructor
122 fDigitsManager = new AliTRDdigitsManager();
123 fDigitsManager->CreateArrays();
128 //_____________________________________________________________________________
129 AliTRDclusterizerV1::AliTRDclusterizerV1(const AliTRDclusterizerV1 &c)
132 // AliTRDclusterizerV1 copy constructor
135 ((AliTRDclusterizerV1 &) c).Copy(*this);
139 //_____________________________________________________________________________
140 AliTRDclusterizerV1::~AliTRDclusterizerV1()
143 // AliTRDclusterizerV1 destructor
146 if (fDigitsManager) {
147 delete fDigitsManager;
148 fDigitsManager = NULL;
153 //_____________________________________________________________________________
154 AliTRDclusterizerV1 &AliTRDclusterizerV1::operator=(const AliTRDclusterizerV1 &c)
157 // Assignment operator
160 if (this != &c) ((AliTRDclusterizerV1 &) c).Copy(*this);
165 //_____________________________________________________________________________
166 void AliTRDclusterizerV1::Copy(TObject &c)
172 ((AliTRDclusterizerV1 &) c).fDigitsManager = 0;
173 ((AliTRDclusterizerV1 &) c).fPar = 0;
175 AliTRDclusterizer::Copy(c);
179 //_____________________________________________________________________________
180 Bool_t AliTRDclusterizerV1::ReadDigits()
183 // Reads the digits arrays from the input aliroot file
187 printf("<AliTRDclusterizerV1::ReadDigits> ");
188 printf("No input file open\n");
192 fDigitsManager->Open(fInputFile->GetName());
194 // Read in the digit arrays
195 return (fDigitsManager->ReadDigits());
199 //_____________________________________________________________________________
200 Bool_t AliTRDclusterizerV1::MakeClusters()
203 // Generates the cluster.
206 Int_t row, col, time;
208 if (fTRD->IsVersion() != 1) {
209 printf("<AliTRDclusterizerV1::MakeCluster> ");
210 printf("TRD must be version 1 (slow simulator).\n");
215 AliTRDgeometry *geo = fTRD->GetGeometry();
217 // Create a default parameter class if none is defined
219 fPar = new AliTRDparameter("TRDparameter","Standard TRD parameter");
221 printf("<AliTRDclusterizerV1::MakeCluster> ");
222 printf("Create the default parameter object.\n");
226 Float_t timeBinSize = fPar->GetTimeBinSize();
227 // Half of ampl.region
228 const Float_t kAmWidth = AliTRDgeometry::AmThick()/2.;
230 Float_t omegaTau = fPar->GetOmegaTau();
232 printf("<AliTRDclusterizerV1::MakeCluster> ");
233 printf("OmegaTau = %f \n",omegaTau);
234 printf("<AliTRDclusterizerV1::MakeCluster> ");
235 printf("Start creating clusters.\n");
238 AliTRDdataArrayI *digits;
239 AliTRDdataArrayI *track0;
240 AliTRDdataArrayI *track1;
241 AliTRDdataArrayI *track2;
243 // Threshold value for the maximum
244 Int_t maxThresh = fPar->GetClusMaxThresh();
245 // Threshold value for the digit signal
246 Int_t sigThresh = fPar->GetClusSigThresh();
248 // Iteration limit for unfolding procedure
249 const Float_t kEpsilon = 0.01;
251 const Int_t kNclus = 3;
252 const Int_t kNsig = 5;
253 const Int_t kNtrack = 3 * kNclus;
258 Float_t ratioLeft = 1.0;
259 Float_t ratioRight = 1.0;
261 Float_t padSignal[kNsig];
262 Float_t clusterSignal[kNclus];
263 Float_t clusterPads[kNclus];
264 Int_t clusterDigit[kNclus];
265 Int_t clusterTracks[kNtrack];
268 Int_t chamEnd = AliTRDgeometry::Ncham();
269 if (fTRD->GetSensChamber() >= 0) {
270 chamBeg = fTRD->GetSensChamber();
271 chamEnd = chamBeg + 1;
274 Int_t planEnd = AliTRDgeometry::Nplan();
275 if (fTRD->GetSensPlane() >= 0) {
276 planBeg = fTRD->GetSensPlane();
277 planEnd = planBeg + 1;
280 Int_t sectEnd = AliTRDgeometry::Nsect();
282 // Start clustering in every chamber
283 for (Int_t icham = chamBeg; icham < chamEnd; icham++) {
284 for (Int_t iplan = planBeg; iplan < planEnd; iplan++) {
285 for (Int_t isect = sectBeg; isect < sectEnd; isect++) {
287 if (fTRD->GetSensSector() >= 0) {
288 Int_t sens1 = fTRD->GetSensSector();
289 Int_t sens2 = sens1 + fTRD->GetSensSectorRange();
290 sens2 -= ((Int_t) (sens2 / AliTRDgeometry::Nsect()))
291 * AliTRDgeometry::Nsect();
293 if ((isect < sens1) || (isect >= sens2)) continue;
296 if ((isect < sens1) && (isect >= sens2)) continue;
300 Int_t idet = geo->GetDetector(iplan,icham,isect);
303 Int_t nClusters2pad = 0;
304 Int_t nClusters3pad = 0;
305 Int_t nClusters4pad = 0;
306 Int_t nClusters5pad = 0;
307 Int_t nClustersLarge = 0;
310 printf("<AliTRDclusterizerV1::MakeCluster> ");
311 printf("Analyzing chamber %d, plane %d, sector %d.\n"
315 Int_t nRowMax = fPar->GetRowMax(iplan,icham,isect);
316 Int_t nColMax = fPar->GetColMax(iplan);
317 Int_t nTimeBefore = fPar->GetTimeBefore();
318 Int_t nTimeTotal = fPar->GetTimeTotal();
321 digits = fDigitsManager->GetDigits(idet);
323 track0 = fDigitsManager->GetDictionary(idet,0);
325 track1 = fDigitsManager->GetDictionary(idet,1);
327 track2 = fDigitsManager->GetDictionary(idet,2);
330 // Loop through the chamber and find the maxima
331 for ( row = 0; row < nRowMax; row++) {
332 for ( col = 2; col < nColMax; col++) {
333 for (time = 0; time < nTimeTotal; time++) {
335 Int_t signalL = TMath::Abs(digits->GetDataUnchecked(row,col ,time));
336 Int_t signalM = TMath::Abs(digits->GetDataUnchecked(row,col-1,time));
337 Int_t signalR = TMath::Abs(digits->GetDataUnchecked(row,col-2,time));
339 // Look for the maximum
340 if (signalM >= maxThresh) {
341 if (((signalL >= sigThresh) &&
342 (signalL < signalM)) ||
343 ((signalR >= sigThresh) &&
344 (signalR < signalM))) {
345 // Maximum found, mark the position by a negative signal
346 digits->SetDataUnchecked(row,col-1,time,-signalM);
354 // Now check the maxima and calculate the cluster position
355 for ( row = 0; row < nRowMax ; row++) {
356 for (time = 0; time < nTimeTotal; time++) {
357 for ( col = 1; col < nColMax-1; col++) {
360 if (digits->GetDataUnchecked(row,col,time) < 0) {
363 for (iPad = 0; iPad < kNclus; iPad++) {
364 Int_t iPadCol = col - 1 + iPad;
365 clusterSignal[iPad] = TMath::Abs(digits->GetDataUnchecked(row
368 clusterDigit[iPad] = digits->GetIndexUnchecked(row,iPadCol,time);
369 clusterTracks[3*iPad ] = track0->GetDataUnchecked(row,iPadCol,time) - 1;
370 clusterTracks[3*iPad+1] = track1->GetDataUnchecked(row,iPadCol,time) - 1;
371 clusterTracks[3*iPad+2] = track2->GetDataUnchecked(row,iPadCol,time) - 1;
374 // Count the number of pads in the cluster
377 while (TMath::Abs(digits->GetDataUnchecked(row,col-ii ,time))
381 if (col-ii < 0) break;
384 while (TMath::Abs(digits->GetDataUnchecked(row,col+ii+1,time))
388 if (col+ii+1 >= nColMax) break;
415 // Don't analyze large clusters
416 //if (iType == 4) continue;
418 // Look for 5 pad cluster with minimum in the middle
419 Bool_t fivePadCluster = kFALSE;
420 if (col < nColMax-3) {
421 if (digits->GetDataUnchecked(row,col+2,time) < 0) {
422 fivePadCluster = kTRUE;
424 if ((fivePadCluster) && (col < nColMax-5)) {
425 if (digits->GetDataUnchecked(row,col+4,time) >= sigThresh) {
426 fivePadCluster = kFALSE;
429 if ((fivePadCluster) && (col > 1)) {
430 if (digits->GetDataUnchecked(row,col-2,time) >= sigThresh) {
431 fivePadCluster = kFALSE;
437 // Modify the signal of the overlapping pad for the left part
438 // of the cluster which remains from a previous unfolding
440 clusterSignal[0] *= ratioLeft;
445 // Unfold the 5 pad cluster
446 if (fivePadCluster) {
447 for (iPad = 0; iPad < kNsig; iPad++) {
448 padSignal[iPad] = TMath::Abs(digits->GetDataUnchecked(row
452 // Unfold the two maxima and set the signal on
453 // the overlapping pad to the ratio
454 ratioRight = Unfold(kEpsilon,iplan,padSignal);
455 ratioLeft = 1.0 - ratioRight;
456 clusterSignal[2] *= ratioRight;
461 Float_t clusterCharge = clusterSignal[0]
465 // The position of the cluster
466 clusterPads[0] = row + 0.5;
467 // Take the shift of the additional time bins into account
468 clusterPads[2] = time - nTimeBefore + 0.5;
472 // Calculate the position of the cluster by using the
473 // lookup table method
474 clusterPads[1] = fPar->LUTposition(iplan,clusterSignal[0]
481 // Calculate the position of the cluster by using the
482 // center of gravity method
483 clusterPads[1] = col + 0.5
484 + (clusterSignal[2] - clusterSignal[0])
489 Float_t clusterSigmaY2 = (clusterSignal[2] + clusterSignal[0]) / clusterCharge
490 - (clusterPads[1]-col-0.5) * (clusterPads[1]-col-0.5);
492 // Correct for ExB displacement
494 Int_t local_time_bin = (Int_t) clusterPads[2];
495 Float_t driftLength = local_time_bin * timeBinSize + kAmWidth;
496 Float_t colSize = fPar->GetColPadSize(iplan);
497 Float_t deltaY = omegaTau*driftLength/colSize;
498 clusterPads[1] = clusterPads[1] - deltaY;
502 printf("-----------------------------------------------------------\n");
503 printf("Create cluster no. %d\n",nClusters);
504 printf("Position: row = %f, col = %f, time = %f\n",clusterPads[0]
507 printf("Indices: %d, %d, %d\n",clusterDigit[0]
510 printf("Total charge = %f\n",clusterCharge);
511 printf("Tracks: pad0 %d, %d, %d\n",clusterTracks[0]
514 printf(" pad1 %d, %d, %d\n",clusterTracks[3]
517 printf(" pad2 %d, %d, %d\n",clusterTracks[6]
520 printf("Type = %d, Number of pads = %d\n",iType,nPadCount);
523 // Add the cluster to the output array
524 fTRD->AddCluster(clusterPads
537 // Compress the arrays
538 digits->Compress(1,0);
539 track0->Compress(1,0);
540 track1->Compress(1,0);
541 track2->Compress(1,0);
543 // Write the cluster and reset the array
545 fTRD->ResetRecPoints();
548 printf("<AliTRDclusterizerV1::MakeCluster> ");
549 printf("Found %d clusters in total.\n"
551 printf(" 2pad: %d\n",nClusters2pad);
552 printf(" 3pad: %d\n",nClusters3pad);
553 printf(" 4pad: %d\n",nClusters4pad);
554 printf(" 5pad: %d\n",nClusters5pad);
555 printf(" Large: %d\n",nClustersLarge);
563 printf("<AliTRDclusterizerV1::MakeCluster> ");
571 //_____________________________________________________________________________
572 Float_t AliTRDclusterizerV1::Unfold(Float_t eps, Int_t plane, Float_t* padSignal)
575 // Method to unfold neighbouring maxima.
576 // The charge ratio on the overlapping pad is calculated
577 // until there is no more change within the range given by eps.
578 // The resulting ratio is then returned to the calling method.
582 Int_t itStep = 0; // Count iteration steps
584 Float_t ratio = 0.5; // Start value for ratio
585 Float_t prevRatio = 0; // Store previous ratio
587 Float_t newLeftSignal[3] = {0}; // Array to store left cluster signal
588 Float_t newRightSignal[3] = {0}; // Array to store right cluster signal
589 Float_t newSignal[3] = {0};
591 // Start the iteration
592 while ((TMath::Abs(prevRatio - ratio) > eps) && (itStep < 10)) {
597 // Cluster position according to charge ratio
598 Float_t maxLeft = (ratio*padSignal[2] - padSignal[0])
599 / (padSignal[0] + padSignal[1] + ratio*padSignal[2]);
600 Float_t maxRight = (padSignal[4] - (1-ratio)*padSignal[2])
601 / ((1-ratio)*padSignal[2] + padSignal[3] + padSignal[4]);
603 // Set cluster charge ratio
604 irc = fPar->PadResponse(1.0,maxLeft ,plane,newSignal);
605 Float_t ampLeft = padSignal[1] / newSignal[1];
606 irc = fPar->PadResponse(1.0,maxRight,plane,newSignal);
607 Float_t ampRight = padSignal[3] / newSignal[1];
609 // Apply pad response to parameters
610 irc = fPar->PadResponse(ampLeft ,maxLeft ,plane,newLeftSignal );
611 irc = fPar->PadResponse(ampRight,maxRight,plane,newRightSignal);
613 // Calculate new overlapping ratio
614 ratio = TMath::Min((Float_t)1.0,newLeftSignal[2] /
615 (newLeftSignal[2] + newRightSignal[0]));