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.18 2002/10/14 14:57:43 hristov
19 Merging the VirtualMC branch to the main development branch (HEAD)
21 Revision 1.15.6.2 2002/07/24 10:09:30 alibrary
24 Revision 1.17 2002/06/12 09:54:35 cblume
25 Update of tracking code provided by Sergei
27 Revision 1.16 2002/03/25 20:01:30 cblume
28 Introduce parameter class
30 Revision 1.15 2001/11/14 12:09:11 cblume
31 Use correct name for digitizer
33 Revision 1.14 2001/11/14 10:50:45 cblume
34 Changes in digits IO. Add merging of summable digits
36 Revision 1.13 2001/05/28 17:07:58 hristov
37 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)
39 Revision 1.12 2001/05/21 17:42:58 hristov
40 Constant casted to avoid the ambiguity
42 Revision 1.11 2001/05/21 16:45:47 hristov
43 Last minute changes (C.Blume)
45 Revision 1.10 2001/05/07 08:06:44 cblume
46 Speedup of the code. Create only AliTRDcluster
48 Revision 1.9 2000/11/01 14:53:20 cblume
49 Merge with TRD-develop
51 Revision 1.1.4.5 2000/10/15 23:40:01 cblume
54 Revision 1.1.4.4 2000/10/06 16:49:46 cblume
57 Revision 1.1.4.3 2000/10/04 16:34:58 cblume
58 Replace include files by forward declarations
60 Revision 1.1.4.2 2000/09/22 14:49:49 cblume
61 Adapted to tracking code
63 Revision 1.8 2000/10/02 21:28:19 fca
64 Removal of useless dependecies via forward declarations
66 Revision 1.7 2000/06/27 13:08:50 cblume
67 Changed to Copy(TObject &A) to appease the HP-compiler
69 Revision 1.6 2000/06/09 11:10:07 cblume
70 Compiler warnings and coding conventions, next round
72 Revision 1.5 2000/06/08 18:32:58 cblume
73 Make code compliant to coding conventions
75 Revision 1.4 2000/06/07 16:27:01 cblume
76 Try to remove compiler warnings on Sun and HP
78 Revision 1.3 2000/05/08 16:17:27 cblume
81 Revision 1.1.4.1 2000/05/08 15:09:01 cblume
82 Introduce AliTRDdigitsManager
84 Revision 1.1 2000/02/28 18:58:54 cblume
89 ///////////////////////////////////////////////////////////////////////////////
91 // TRD cluster finder for the slow simulator.
93 ///////////////////////////////////////////////////////////////////////////////
103 #include "AliTRDclusterizerV1.h"
104 #include "AliTRDmatrix.h"
105 #include "AliTRDgeometry.h"
106 #include "AliTRDdigitizer.h"
107 #include "AliTRDdataArrayF.h"
108 #include "AliTRDdataArrayI.h"
109 #include "AliTRDdigitsManager.h"
110 #include "AliTRDparameter.h"
112 ClassImp(AliTRDclusterizerV1)
114 //_____________________________________________________________________________
115 AliTRDclusterizerV1::AliTRDclusterizerV1():AliTRDclusterizer()
118 // AliTRDclusterizerV1 default constructor
125 //_____________________________________________________________________________
126 AliTRDclusterizerV1::AliTRDclusterizerV1(const Text_t* name, const Text_t* title)
127 :AliTRDclusterizer(name,title)
130 // AliTRDclusterizerV1 default constructor
133 fDigitsManager = new AliTRDdigitsManager();
134 fDigitsManager->CreateArrays();
138 //_____________________________________________________________________________
139 AliTRDclusterizerV1::AliTRDclusterizerV1(const AliTRDclusterizerV1 &c)
142 // AliTRDclusterizerV1 copy constructor
145 ((AliTRDclusterizerV1 &) c).Copy(*this);
149 //_____________________________________________________________________________
150 AliTRDclusterizerV1::~AliTRDclusterizerV1()
153 // AliTRDclusterizerV1 destructor
156 if (fDigitsManager) {
157 delete fDigitsManager;
158 fDigitsManager = NULL;
163 //_____________________________________________________________________________
164 AliTRDclusterizerV1 &AliTRDclusterizerV1::operator=(const AliTRDclusterizerV1 &c)
167 // Assignment operator
170 if (this != &c) ((AliTRDclusterizerV1 &) c).Copy(*this);
175 //_____________________________________________________________________________
176 void AliTRDclusterizerV1::Copy(TObject &c)
182 ((AliTRDclusterizerV1 &) c).fDigitsManager = 0;
184 AliTRDclusterizer::Copy(c);
188 //_____________________________________________________________________________
189 Bool_t AliTRDclusterizerV1::ReadDigits()
192 // Reads the digits arrays from the input aliroot file
196 printf("<AliTRDclusterizerV1::ReadDigits> ");
197 printf("No input file open\n");
201 fDigitsManager->Open(fInputFile->GetName());
202 fDigitsManager->SetEvent(fEvent);
204 // Read in the digit arrays
205 return (fDigitsManager->ReadDigits());
209 //_____________________________________________________________________________
210 Bool_t AliTRDclusterizerV1::MakeClusters()
213 // Generates the cluster.
216 Int_t row, col, time;
218 if (fTRD->IsVersion() != 1) {
219 printf("<AliTRDclusterizerV1::MakeCluster> ");
220 printf("TRD must be version 1 (slow simulator).\n");
225 AliTRDgeometry *geo = fTRD->GetGeometry();
227 // Create a default parameter class if none is defined
229 fPar = new AliTRDparameter("TRDparameter","Standard TRD parameter");
230 printf("<AliTRDclusterizerV1::MakeCluster> ");
231 printf("Create the default parameter object.\n");
234 Float_t timeBinSize = fPar->GetTimeBinSize();
235 // Half of ampl.region
236 const Float_t kAmWidth = AliTRDgeometry::AmThick()/2.;
238 Float_t omegaTau = fPar->GetOmegaTau();
240 printf("<AliTRDclusterizerV1::MakeCluster> ");
241 printf("OmegaTau = %f \n",omegaTau);
242 printf("<AliTRDclusterizerV1::MakeCluster> ");
243 printf("Start creating clusters.\n");
246 AliTRDdataArrayI *digits;
247 AliTRDdataArrayI *track0;
248 AliTRDdataArrayI *track1;
249 AliTRDdataArrayI *track2;
251 // Threshold value for the maximum
252 Int_t maxThresh = fPar->GetClusMaxThresh();
253 // Threshold value for the digit signal
254 Int_t sigThresh = fPar->GetClusSigThresh();
256 // Iteration limit for unfolding procedure
257 const Float_t kEpsilon = 0.01;
259 const Int_t kNclus = 3;
260 const Int_t kNsig = 5;
261 const Int_t kNtrack = 3 * kNclus;
266 Float_t ratioLeft = 1.0;
267 Float_t ratioRight = 1.0;
269 Float_t padSignal[kNsig];
270 Float_t clusterSignal[kNclus];
271 Float_t clusterPads[kNclus];
272 Int_t clusterDigit[kNclus];
273 Int_t clusterTracks[kNtrack];
276 Int_t chamEnd = AliTRDgeometry::Ncham();
277 if (fTRD->GetSensChamber() >= 0) {
278 chamBeg = fTRD->GetSensChamber();
279 chamEnd = chamBeg + 1;
282 Int_t planEnd = AliTRDgeometry::Nplan();
283 if (fTRD->GetSensPlane() >= 0) {
284 planBeg = fTRD->GetSensPlane();
285 planEnd = planBeg + 1;
288 Int_t sectEnd = AliTRDgeometry::Nsect();
290 // Start clustering in every chamber
291 for (Int_t icham = chamBeg; icham < chamEnd; icham++) {
292 for (Int_t iplan = planBeg; iplan < planEnd; iplan++) {
293 for (Int_t isect = sectBeg; isect < sectEnd; isect++) {
295 if (fTRD->GetSensSector() >= 0) {
296 Int_t sens1 = fTRD->GetSensSector();
297 Int_t sens2 = sens1 + fTRD->GetSensSectorRange();
298 sens2 -= ((Int_t) (sens2 / AliTRDgeometry::Nsect()))
299 * AliTRDgeometry::Nsect();
301 if ((isect < sens1) || (isect >= sens2)) continue;
304 if ((isect < sens1) && (isect >= sens2)) continue;
308 Int_t idet = geo->GetDetector(iplan,icham,isect);
311 Int_t nClusters2pad = 0;
312 Int_t nClusters3pad = 0;
313 Int_t nClusters4pad = 0;
314 Int_t nClusters5pad = 0;
315 Int_t nClustersLarge = 0;
318 printf("<AliTRDclusterizerV1::MakeCluster> ");
319 printf("Analyzing chamber %d, plane %d, sector %d.\n"
323 Int_t nRowMax = fPar->GetRowMax(iplan,icham,isect);
324 Int_t nColMax = fPar->GetColMax(iplan);
325 Int_t nTimeBefore = fPar->GetTimeBefore();
326 Int_t nTimeTotal = fPar->GetTimeTotal();
328 Float_t row0 = fPar->GetRow0(iplan,icham,isect);
329 Float_t col0 = fPar->GetCol0(iplan);
330 Float_t rowSize = fPar->GetRowPadSize(iplan,icham,isect);
331 Float_t colSize = fPar->GetColPadSize(iplan);
334 digits = fDigitsManager->GetDigits(idet);
336 track0 = fDigitsManager->GetDictionary(idet,0);
338 track1 = fDigitsManager->GetDictionary(idet,1);
340 track2 = fDigitsManager->GetDictionary(idet,2);
343 // Loop through the chamber and find the maxima
344 for ( row = 0; row < nRowMax; row++) {
345 for ( col = 2; col < nColMax; col++) {
346 for (time = 0; time < nTimeTotal; time++) {
348 Int_t signalL = TMath::Abs(digits->GetDataUnchecked(row,col ,time));
349 Int_t signalM = TMath::Abs(digits->GetDataUnchecked(row,col-1,time));
350 Int_t signalR = TMath::Abs(digits->GetDataUnchecked(row,col-2,time));
352 // Look for the maximum
353 if (signalM >= maxThresh) {
354 if (((signalL >= sigThresh) &&
355 (signalL < signalM)) ||
356 ((signalR >= sigThresh) &&
357 (signalR < signalM))) {
358 // Maximum found, mark the position by a negative signal
359 digits->SetDataUnchecked(row,col-1,time,-signalM);
367 // Now check the maxima and calculate the cluster position
368 for ( row = 0; row < nRowMax ; row++) {
369 for (time = 0; time < nTimeTotal; time++) {
370 for ( col = 1; col < nColMax-1; col++) {
373 if (digits->GetDataUnchecked(row,col,time) < 0) {
376 for (iPad = 0; iPad < kNclus; iPad++) {
377 Int_t iPadCol = col - 1 + iPad;
378 clusterSignal[iPad] = TMath::Abs(digits->GetDataUnchecked(row
381 clusterDigit[iPad] = digits->GetIndexUnchecked(row,iPadCol,time);
382 clusterTracks[3*iPad ] = track0->GetDataUnchecked(row,iPadCol,time) - 1;
383 clusterTracks[3*iPad+1] = track1->GetDataUnchecked(row,iPadCol,time) - 1;
384 clusterTracks[3*iPad+2] = track2->GetDataUnchecked(row,iPadCol,time) - 1;
387 // Count the number of pads in the cluster
390 while (TMath::Abs(digits->GetDataUnchecked(row,col-ii ,time))
394 if (col-ii < 0) break;
397 while (TMath::Abs(digits->GetDataUnchecked(row,col+ii+1,time))
401 if (col+ii+1 >= nColMax) break;
428 // Don't analyze large clusters
429 //if (iType == 4) continue;
431 // Look for 5 pad cluster with minimum in the middle
432 Bool_t fivePadCluster = kFALSE;
433 if (col < nColMax-3) {
434 if (digits->GetDataUnchecked(row,col+2,time) < 0) {
435 fivePadCluster = kTRUE;
437 if ((fivePadCluster) && (col < nColMax-5)) {
438 if (digits->GetDataUnchecked(row,col+4,time) >= sigThresh) {
439 fivePadCluster = kFALSE;
442 if ((fivePadCluster) && (col > 1)) {
443 if (digits->GetDataUnchecked(row,col-2,time) >= sigThresh) {
444 fivePadCluster = kFALSE;
450 // Modify the signal of the overlapping pad for the left part
451 // of the cluster which remains from a previous unfolding
453 clusterSignal[0] *= ratioLeft;
458 // Unfold the 5 pad cluster
459 if (fivePadCluster) {
460 for (iPad = 0; iPad < kNsig; iPad++) {
461 padSignal[iPad] = TMath::Abs(digits->GetDataUnchecked(row
465 // Unfold the two maxima and set the signal on
466 // the overlapping pad to the ratio
467 ratioRight = Unfold(kEpsilon,iplan,padSignal);
468 ratioLeft = 1.0 - ratioRight;
469 clusterSignal[2] *= ratioRight;
474 Float_t clusterCharge = clusterSignal[0]
478 // The position of the cluster
479 clusterPads[0] = row + 0.5;
480 // Take the shift of the additional time bins into account
481 clusterPads[2] = time - nTimeBefore + 0.5;
485 // Calculate the position of the cluster by using the
486 // lookup table method
487 clusterPads[1] = col + 0.5
488 + fPar->LUTposition(iplan,clusterSignal[0]
495 // Calculate the position of the cluster by using the
496 // center of gravity method
497 clusterPads[1] = col + 0.5
498 + (clusterSignal[2] - clusterSignal[0])
503 Float_t q0 = clusterSignal[0];
504 Float_t q1 = clusterSignal[1];
505 Float_t q2 = clusterSignal[2];
506 Float_t clusterSigmaY2 = (q1*(q0+q2)+4*q0*q2) /
507 (clusterCharge*clusterCharge);
509 // Correct for ExB displacement
511 Int_t local_time_bin = (Int_t) clusterPads[2];
512 Float_t driftLength = local_time_bin * timeBinSize + kAmWidth;
513 Float_t colSize = fPar->GetColPadSize(iplan);
514 Float_t deltaY = omegaTau*driftLength/colSize;
515 clusterPads[1] = clusterPads[1] - deltaY;
519 printf("-----------------------------------------------------------\n");
520 printf("Create cluster no. %d\n",nClusters);
521 printf("Position: row = %f, col = %f, time = %f\n",clusterPads[0]
524 printf("Indices: %d, %d, %d\n",clusterDigit[0]
527 printf("Total charge = %f\n",clusterCharge);
528 printf("Tracks: pad0 %d, %d, %d\n",clusterTracks[0]
531 printf(" pad1 %d, %d, %d\n",clusterTracks[3]
534 printf(" pad2 %d, %d, %d\n",clusterTracks[6]
537 printf("Type = %d, Number of pads = %d\n",iType,nPadCount);
540 // Calculate the position and the error
541 Float_t clusterPos[3];
542 clusterPos[0] = clusterPads[1] * colSize + col0;
543 clusterPos[1] = clusterPads[0] * rowSize + row0;
544 clusterPos[2] = clusterPads[2];
545 Float_t clusterSig[2];
546 clusterSig[0] = (clusterSigmaY2 + 1./12.) * colSize*colSize;
547 clusterSig[1] = rowSize * rowSize / 12.;
549 // Add the cluster to the output array
550 fTRD->AddCluster(clusterPos
562 // Compress the arrays
563 digits->Compress(1,0);
564 track0->Compress(1,0);
565 track1->Compress(1,0);
566 track2->Compress(1,0);
568 // Write the cluster and reset the array
570 fTRD->ResetRecPoints();
573 printf("<AliTRDclusterizerV1::MakeCluster> ");
574 printf("Found %d clusters in total.\n"
576 printf(" 2pad: %d\n",nClusters2pad);
577 printf(" 3pad: %d\n",nClusters3pad);
578 printf(" 4pad: %d\n",nClusters4pad);
579 printf(" 5pad: %d\n",nClusters5pad);
580 printf(" Large: %d\n",nClustersLarge);
588 printf("<AliTRDclusterizerV1::MakeCluster> ");
596 //_____________________________________________________________________________
597 Float_t AliTRDclusterizerV1::Unfold(Float_t eps, Int_t plane, Float_t* padSignal)
600 // Method to unfold neighbouring maxima.
601 // The charge ratio on the overlapping pad is calculated
602 // until there is no more change within the range given by eps.
603 // The resulting ratio is then returned to the calling method.
607 Int_t itStep = 0; // Count iteration steps
609 Float_t ratio = 0.5; // Start value for ratio
610 Float_t prevRatio = 0; // Store previous ratio
612 Float_t newLeftSignal[3] = {0}; // Array to store left cluster signal
613 Float_t newRightSignal[3] = {0}; // Array to store right cluster signal
614 Float_t newSignal[3] = {0};
616 // Start the iteration
617 while ((TMath::Abs(prevRatio - ratio) > eps) && (itStep < 10)) {
622 // Cluster position according to charge ratio
623 Float_t maxLeft = (ratio*padSignal[2] - padSignal[0])
624 / (padSignal[0] + padSignal[1] + ratio*padSignal[2]);
625 Float_t maxRight = (padSignal[4] - (1-ratio)*padSignal[2])
626 / ((1-ratio)*padSignal[2] + padSignal[3] + padSignal[4]);
628 // Set cluster charge ratio
629 irc = fPar->PadResponse(1.0,maxLeft ,plane,newSignal);
630 Float_t ampLeft = padSignal[1] / newSignal[1];
631 irc = fPar->PadResponse(1.0,maxRight,plane,newSignal);
632 Float_t ampRight = padSignal[3] / newSignal[1];
634 // Apply pad response to parameters
635 irc = fPar->PadResponse(ampLeft ,maxLeft ,plane,newLeftSignal );
636 irc = fPar->PadResponse(ampRight,maxRight,plane,newRightSignal);
638 // Calculate new overlapping ratio
639 ratio = TMath::Min((Float_t)1.0,newLeftSignal[2] /
640 (newLeftSignal[2] + newRightSignal[0]));