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.16 2002/03/25 20:01:30 cblume
19 Introduce parameter class
21 Revision 1.15 2001/11/14 12:09:11 cblume
22 Use correct name for digitizer
24 Revision 1.14 2001/11/14 10:50:45 cblume
25 Changes in digits IO. Add merging of summable digits
27 Revision 1.13 2001/05/28 17:07:58 hristov
28 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)
30 Revision 1.12 2001/05/21 17:42:58 hristov
31 Constant casted to avoid the ambiguity
33 Revision 1.11 2001/05/21 16:45:47 hristov
34 Last minute changes (C.Blume)
36 Revision 1.10 2001/05/07 08:06:44 cblume
37 Speedup of the code. Create only AliTRDcluster
39 Revision 1.9 2000/11/01 14:53:20 cblume
40 Merge with TRD-develop
42 Revision 1.1.4.5 2000/10/15 23:40:01 cblume
45 Revision 1.1.4.4 2000/10/06 16:49:46 cblume
48 Revision 1.1.4.3 2000/10/04 16:34:58 cblume
49 Replace include files by forward declarations
51 Revision 1.1.4.2 2000/09/22 14:49:49 cblume
52 Adapted to tracking code
54 Revision 1.8 2000/10/02 21:28:19 fca
55 Removal of useless dependecies via forward declarations
57 Revision 1.7 2000/06/27 13:08:50 cblume
58 Changed to Copy(TObject &A) to appease the HP-compiler
60 Revision 1.6 2000/06/09 11:10:07 cblume
61 Compiler warnings and coding conventions, next round
63 Revision 1.5 2000/06/08 18:32:58 cblume
64 Make code compliant to coding conventions
66 Revision 1.4 2000/06/07 16:27:01 cblume
67 Try to remove compiler warnings on Sun and HP
69 Revision 1.3 2000/05/08 16:17:27 cblume
72 Revision 1.1.4.1 2000/05/08 15:09:01 cblume
73 Introduce AliTRDdigitsManager
75 Revision 1.1 2000/02/28 18:58:54 cblume
80 ///////////////////////////////////////////////////////////////////////////////
82 // TRD cluster finder for the slow simulator.
84 ///////////////////////////////////////////////////////////////////////////////
94 #include "AliTRDclusterizerV1.h"
95 #include "AliTRDmatrix.h"
96 #include "AliTRDgeometry.h"
97 #include "AliTRDdigitizer.h"
98 #include "AliTRDdataArrayF.h"
99 #include "AliTRDdataArrayI.h"
100 #include "AliTRDdigitsManager.h"
101 #include "AliTRDparameter.h"
103 ClassImp(AliTRDclusterizerV1)
105 //_____________________________________________________________________________
106 AliTRDclusterizerV1::AliTRDclusterizerV1():AliTRDclusterizer()
109 // AliTRDclusterizerV1 default constructor
116 //_____________________________________________________________________________
117 AliTRDclusterizerV1::AliTRDclusterizerV1(const Text_t* name, const Text_t* title)
118 :AliTRDclusterizer(name,title)
121 // AliTRDclusterizerV1 default constructor
124 fDigitsManager = new AliTRDdigitsManager();
125 fDigitsManager->CreateArrays();
129 //_____________________________________________________________________________
130 AliTRDclusterizerV1::AliTRDclusterizerV1(const AliTRDclusterizerV1 &c)
133 // AliTRDclusterizerV1 copy constructor
136 ((AliTRDclusterizerV1 &) c).Copy(*this);
140 //_____________________________________________________________________________
141 AliTRDclusterizerV1::~AliTRDclusterizerV1()
144 // AliTRDclusterizerV1 destructor
147 if (fDigitsManager) {
148 delete fDigitsManager;
149 fDigitsManager = NULL;
154 //_____________________________________________________________________________
155 AliTRDclusterizerV1 &AliTRDclusterizerV1::operator=(const AliTRDclusterizerV1 &c)
158 // Assignment operator
161 if (this != &c) ((AliTRDclusterizerV1 &) c).Copy(*this);
166 //_____________________________________________________________________________
167 void AliTRDclusterizerV1::Copy(TObject &c)
173 ((AliTRDclusterizerV1 &) c).fDigitsManager = 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");
220 printf("<AliTRDclusterizerV1::MakeCluster> ");
221 printf("Create the default parameter object.\n");
224 Float_t timeBinSize = fPar->GetTimeBinSize();
225 // Half of ampl.region
226 const Float_t kAmWidth = AliTRDgeometry::AmThick()/2.;
228 Float_t omegaTau = fPar->GetOmegaTau();
230 printf("<AliTRDclusterizerV1::MakeCluster> ");
231 printf("OmegaTau = %f \n",omegaTau);
232 printf("<AliTRDclusterizerV1::MakeCluster> ");
233 printf("Start creating clusters.\n");
236 AliTRDdataArrayI *digits;
237 AliTRDdataArrayI *track0;
238 AliTRDdataArrayI *track1;
239 AliTRDdataArrayI *track2;
241 // Threshold value for the maximum
242 Int_t maxThresh = fPar->GetClusMaxThresh();
243 // Threshold value for the digit signal
244 Int_t sigThresh = fPar->GetClusSigThresh();
246 // Iteration limit for unfolding procedure
247 const Float_t kEpsilon = 0.01;
249 const Int_t kNclus = 3;
250 const Int_t kNsig = 5;
251 const Int_t kNtrack = 3 * kNclus;
256 Float_t ratioLeft = 1.0;
257 Float_t ratioRight = 1.0;
259 Float_t padSignal[kNsig];
260 Float_t clusterSignal[kNclus];
261 Float_t clusterPads[kNclus];
262 Int_t clusterDigit[kNclus];
263 Int_t clusterTracks[kNtrack];
266 Int_t chamEnd = AliTRDgeometry::Ncham();
267 if (fTRD->GetSensChamber() >= 0) {
268 chamBeg = fTRD->GetSensChamber();
269 chamEnd = chamBeg + 1;
272 Int_t planEnd = AliTRDgeometry::Nplan();
273 if (fTRD->GetSensPlane() >= 0) {
274 planBeg = fTRD->GetSensPlane();
275 planEnd = planBeg + 1;
278 Int_t sectEnd = AliTRDgeometry::Nsect();
280 // Start clustering in every chamber
281 for (Int_t icham = chamBeg; icham < chamEnd; icham++) {
282 for (Int_t iplan = planBeg; iplan < planEnd; iplan++) {
283 for (Int_t isect = sectBeg; isect < sectEnd; isect++) {
285 if (fTRD->GetSensSector() >= 0) {
286 Int_t sens1 = fTRD->GetSensSector();
287 Int_t sens2 = sens1 + fTRD->GetSensSectorRange();
288 sens2 -= ((Int_t) (sens2 / AliTRDgeometry::Nsect()))
289 * AliTRDgeometry::Nsect();
291 if ((isect < sens1) || (isect >= sens2)) continue;
294 if ((isect < sens1) && (isect >= sens2)) continue;
298 Int_t idet = geo->GetDetector(iplan,icham,isect);
301 Int_t nClusters2pad = 0;
302 Int_t nClusters3pad = 0;
303 Int_t nClusters4pad = 0;
304 Int_t nClusters5pad = 0;
305 Int_t nClustersLarge = 0;
308 printf("<AliTRDclusterizerV1::MakeCluster> ");
309 printf("Analyzing chamber %d, plane %d, sector %d.\n"
313 Int_t nRowMax = fPar->GetRowMax(iplan,icham,isect);
314 Int_t nColMax = fPar->GetColMax(iplan);
315 Int_t nTimeBefore = fPar->GetTimeBefore();
316 Int_t nTimeTotal = fPar->GetTimeTotal();
318 Float_t row0 = fPar->GetRow0(iplan,icham,isect);
319 Float_t col0 = fPar->GetCol0(iplan);
320 Float_t rowSize = fPar->GetRowPadSize(iplan,icham,isect);
321 Float_t colSize = fPar->GetColPadSize(iplan);
324 digits = fDigitsManager->GetDigits(idet);
326 track0 = fDigitsManager->GetDictionary(idet,0);
328 track1 = fDigitsManager->GetDictionary(idet,1);
330 track2 = fDigitsManager->GetDictionary(idet,2);
333 // Loop through the chamber and find the maxima
334 for ( row = 0; row < nRowMax; row++) {
335 for ( col = 2; col < nColMax; col++) {
336 for (time = 0; time < nTimeTotal; time++) {
338 Int_t signalL = TMath::Abs(digits->GetDataUnchecked(row,col ,time));
339 Int_t signalM = TMath::Abs(digits->GetDataUnchecked(row,col-1,time));
340 Int_t signalR = TMath::Abs(digits->GetDataUnchecked(row,col-2,time));
342 // Look for the maximum
343 if (signalM >= maxThresh) {
344 if (((signalL >= sigThresh) &&
345 (signalL < signalM)) ||
346 ((signalR >= sigThresh) &&
347 (signalR < signalM))) {
348 // Maximum found, mark the position by a negative signal
349 digits->SetDataUnchecked(row,col-1,time,-signalM);
357 // Now check the maxima and calculate the cluster position
358 for ( row = 0; row < nRowMax ; row++) {
359 for (time = 0; time < nTimeTotal; time++) {
360 for ( col = 1; col < nColMax-1; col++) {
363 if (digits->GetDataUnchecked(row,col,time) < 0) {
366 for (iPad = 0; iPad < kNclus; iPad++) {
367 Int_t iPadCol = col - 1 + iPad;
368 clusterSignal[iPad] = TMath::Abs(digits->GetDataUnchecked(row
371 clusterDigit[iPad] = digits->GetIndexUnchecked(row,iPadCol,time);
372 clusterTracks[3*iPad ] = track0->GetDataUnchecked(row,iPadCol,time) - 1;
373 clusterTracks[3*iPad+1] = track1->GetDataUnchecked(row,iPadCol,time) - 1;
374 clusterTracks[3*iPad+2] = track2->GetDataUnchecked(row,iPadCol,time) - 1;
377 // Count the number of pads in the cluster
380 while (TMath::Abs(digits->GetDataUnchecked(row,col-ii ,time))
384 if (col-ii < 0) break;
387 while (TMath::Abs(digits->GetDataUnchecked(row,col+ii+1,time))
391 if (col+ii+1 >= nColMax) break;
418 // Don't analyze large clusters
419 //if (iType == 4) continue;
421 // Look for 5 pad cluster with minimum in the middle
422 Bool_t fivePadCluster = kFALSE;
423 if (col < nColMax-3) {
424 if (digits->GetDataUnchecked(row,col+2,time) < 0) {
425 fivePadCluster = kTRUE;
427 if ((fivePadCluster) && (col < nColMax-5)) {
428 if (digits->GetDataUnchecked(row,col+4,time) >= sigThresh) {
429 fivePadCluster = kFALSE;
432 if ((fivePadCluster) && (col > 1)) {
433 if (digits->GetDataUnchecked(row,col-2,time) >= sigThresh) {
434 fivePadCluster = kFALSE;
440 // Modify the signal of the overlapping pad for the left part
441 // of the cluster which remains from a previous unfolding
443 clusterSignal[0] *= ratioLeft;
448 // Unfold the 5 pad cluster
449 if (fivePadCluster) {
450 for (iPad = 0; iPad < kNsig; iPad++) {
451 padSignal[iPad] = TMath::Abs(digits->GetDataUnchecked(row
455 // Unfold the two maxima and set the signal on
456 // the overlapping pad to the ratio
457 ratioRight = Unfold(kEpsilon,iplan,padSignal);
458 ratioLeft = 1.0 - ratioRight;
459 clusterSignal[2] *= ratioRight;
464 Float_t clusterCharge = clusterSignal[0]
468 // The position of the cluster
469 clusterPads[0] = row + 0.5;
470 // Take the shift of the additional time bins into account
471 clusterPads[2] = time - nTimeBefore + 0.5;
475 // Calculate the position of the cluster by using the
476 // lookup table method
477 clusterPads[1] = col + 0.5
478 + fPar->LUTposition(iplan,clusterSignal[0]
485 // Calculate the position of the cluster by using the
486 // center of gravity method
487 clusterPads[1] = col + 0.5
488 + (clusterSignal[2] - clusterSignal[0])
493 Float_t q0 = clusterSignal[0];
494 Float_t q1 = clusterSignal[1];
495 Float_t q2 = clusterSignal[2];
496 Float_t clusterSigmaY2 = (q1*(q0+q2)+4*q0*q2) /
497 (clusterCharge*clusterCharge);
499 // Correct for ExB displacement
501 Int_t local_time_bin = (Int_t) clusterPads[2];
502 Float_t driftLength = local_time_bin * timeBinSize + kAmWidth;
503 Float_t colSize = fPar->GetColPadSize(iplan);
504 Float_t deltaY = omegaTau*driftLength/colSize;
505 clusterPads[1] = clusterPads[1] - deltaY;
509 printf("-----------------------------------------------------------\n");
510 printf("Create cluster no. %d\n",nClusters);
511 printf("Position: row = %f, col = %f, time = %f\n",clusterPads[0]
514 printf("Indices: %d, %d, %d\n",clusterDigit[0]
517 printf("Total charge = %f\n",clusterCharge);
518 printf("Tracks: pad0 %d, %d, %d\n",clusterTracks[0]
521 printf(" pad1 %d, %d, %d\n",clusterTracks[3]
524 printf(" pad2 %d, %d, %d\n",clusterTracks[6]
527 printf("Type = %d, Number of pads = %d\n",iType,nPadCount);
530 // Calculate the position and the error
531 Float_t clusterPos[3];
532 clusterPos[0] = clusterPads[1] * colSize + col0;
533 clusterPos[1] = clusterPads[0] * rowSize + row0;
534 clusterPos[2] = clusterPads[2];
535 Float_t clusterSig[2];
536 clusterSig[0] = (clusterSigmaY2 + 1./12.) * colSize*colSize;
537 clusterSig[1] = rowSize * rowSize / 12.;
539 // Add the cluster to the output array
540 fTRD->AddCluster(clusterPos
552 // Compress the arrays
553 digits->Compress(1,0);
554 track0->Compress(1,0);
555 track1->Compress(1,0);
556 track2->Compress(1,0);
558 // Write the cluster and reset the array
560 fTRD->ResetRecPoints();
563 printf("<AliTRDclusterizerV1::MakeCluster> ");
564 printf("Found %d clusters in total.\n"
566 printf(" 2pad: %d\n",nClusters2pad);
567 printf(" 3pad: %d\n",nClusters3pad);
568 printf(" 4pad: %d\n",nClusters4pad);
569 printf(" 5pad: %d\n",nClusters5pad);
570 printf(" Large: %d\n",nClustersLarge);
578 printf("<AliTRDclusterizerV1::MakeCluster> ");
586 //_____________________________________________________________________________
587 Float_t AliTRDclusterizerV1::Unfold(Float_t eps, Int_t plane, Float_t* padSignal)
590 // Method to unfold neighbouring maxima.
591 // The charge ratio on the overlapping pad is calculated
592 // until there is no more change within the range given by eps.
593 // The resulting ratio is then returned to the calling method.
597 Int_t itStep = 0; // Count iteration steps
599 Float_t ratio = 0.5; // Start value for ratio
600 Float_t prevRatio = 0; // Store previous ratio
602 Float_t newLeftSignal[3] = {0}; // Array to store left cluster signal
603 Float_t newRightSignal[3] = {0}; // Array to store right cluster signal
604 Float_t newSignal[3] = {0};
606 // Start the iteration
607 while ((TMath::Abs(prevRatio - ratio) > eps) && (itStep < 10)) {
612 // Cluster position according to charge ratio
613 Float_t maxLeft = (ratio*padSignal[2] - padSignal[0])
614 / (padSignal[0] + padSignal[1] + ratio*padSignal[2]);
615 Float_t maxRight = (padSignal[4] - (1-ratio)*padSignal[2])
616 / ((1-ratio)*padSignal[2] + padSignal[3] + padSignal[4]);
618 // Set cluster charge ratio
619 irc = fPar->PadResponse(1.0,maxLeft ,plane,newSignal);
620 Float_t ampLeft = padSignal[1] / newSignal[1];
621 irc = fPar->PadResponse(1.0,maxRight,plane,newSignal);
622 Float_t ampRight = padSignal[3] / newSignal[1];
624 // Apply pad response to parameters
625 irc = fPar->PadResponse(ampLeft ,maxLeft ,plane,newLeftSignal );
626 irc = fPar->PadResponse(ampRight,maxRight,plane,newRightSignal);
628 // Calculate new overlapping ratio
629 ratio = TMath::Min((Float_t)1.0,newLeftSignal[2] /
630 (newLeftSignal[2] + newRightSignal[0]));