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 **************************************************************************/
17 #include "AliITSClusterFinderSPD.h"
19 #include "AliITSgeom.h"
20 #include "AliITSdigit.h"
21 #include "AliITSRawCluster.h"
22 #include "AliITSRecPoint.h"
23 #include "AliITSsegmentation.h"
24 #include "AliITSresponse.h"
30 ClassImp(AliITSClusterFinderSPD)
32 //----------------------------------------------------------
33 AliITSClusterFinderSPD::AliITSClusterFinderSPD
34 (AliITSsegmentation *seg, TClonesArray *digits, TClonesArray *recp)
40 fNclusters= fClusters->GetEntriesFast();
45 //_____________________________________________________________________________
46 AliITSClusterFinderSPD::AliITSClusterFinderSPD()
58 //__________________________________________________________________________
59 AliITSClusterFinderSPD::AliITSClusterFinderSPD(const
60 AliITSClusterFinderSPD &source){
62 if(&source == this) return;
63 this->fClusters = source.fClusters ;
64 this->fNclusters = source.fNclusters ;
65 this->fDz = source.fDz ;
66 this->fDx = source.fDx ;
70 //_________________________________________________________________________
71 AliITSClusterFinderSPD&
72 AliITSClusterFinderSPD::operator=(const AliITSClusterFinderSPD &source) {
73 // Assignment operator
74 if(&source == this) return *this;
75 this->fClusters = source.fClusters ;
76 this->fNclusters = source.fNclusters ;
77 this->fDz = source.fDz ;
78 this->fDx = source.fDx ;
82 //_____________________________________________________________________________
83 void AliITSClusterFinderSPD::FindRawClusters(Int_t module){
85 // input of Cluster Finder
88 Int_t *digx = new Int_t[numberd];
89 Int_t *digz = new Int_t[numberd];
90 Int_t *digtr1 = new Int_t[numberd];
91 Int_t *digtr2 = new Int_t[numberd];
92 Int_t *digtr3 = new Int_t[numberd];
93 Int_t *digtr4 = new Int_t[numberd];
95 // output of Cluster Finder
97 Float_t *xcenterl = new Float_t[numberc];
98 Float_t *zcenterl = new Float_t[numberc];
99 Float_t *errxcenter = new Float_t[numberc];
100 Float_t *errzcenter = new Float_t[numberc];
101 Int_t *tr1clus = new Int_t[numberc];
102 Int_t *tr2clus = new Int_t[numberc];
103 Int_t *tr3clus = new Int_t[numberc];
108 Int_t ndigits = fDigits->GetEntriesFast();
109 if (!ndigits) return;
113 AliITSdigitSPD *dig1;
115 for(ndig=0; ndig<ndigits; ndig++) {
116 dig= (AliITSdigit*)fDigits->UncheckedAt(ndig);
118 digx[digitcount] = dig->fCoord2+1; //starts at 1
119 digz[digitcount] = dig->fCoord1+1; //starts at 1
121 dig1= (AliITSdigitSPD*)fDigits->UncheckedAt(ndig);
123 digtr1[digitcount] = dig1->fTracks[0];
124 digtr2[digitcount] = dig1->fTracks[1];
125 digtr3[digitcount] = dig1->fTracks[2];
126 digtr4[digitcount] = dig1->fSignal;
132 ClusterFinder(digitcount,digx,digz,digtr1,digtr2,digtr3,digtr4,
133 nclus,xcenterl,zcenterl,errxcenter,errzcenter,
134 tr1clus, tr2clus, tr3clus);
136 DigitToPoint(nclus,xcenterl,zcenterl,errxcenter,errzcenter,
137 tr1clus, tr2clus, tr3clus);
148 delete[] errxcenter ;
149 delete[] errzcenter ;
155 //-----------------------------------------------------------------
156 void AliITSClusterFinderSPD::ClusterFinder(Int_t ndigits,
157 Int_t digx[],Int_t digz[],
158 Int_t digtr1[],Int_t digtr2[],Int_t digtr3[],Int_t digtr4[],
159 Int_t &nclus, Float_t xcenter[],Float_t zcenter[],
160 Float_t errxcenter[],Float_t errzcenter[],
161 Int_t tr1clus[], Int_t tr2clus[], Int_t tr3clus[]) {
163 // Search for clusters of fired pixels (digits). Two digits are linked
164 // inside a cluster if they are countiguous both in row or column
165 // direction. Diagonal digits are not linked.
166 // xcenter, ycenter, zcenter are the coordinates of the center
167 // of each found cluster, calculated from the averaging the corresponding
168 // coordinate of the center of the linked digits. The coordinates are
169 // given in the local reference sistem.
170 // errxcenter, errycenter, errzcenter are the errors associated to
171 // the corresponding average.
175 Int_t if1, min, max, nd;
176 Int_t x1, z1, t1, t2, t3, t4;
177 Int_t ndx, ndz, ndxmin, ndxmax, ndzmin, ndzmax;
182 Float_t deltax, deltaz;
186 Int_t *ifpad = new Int_t[numberd];
187 Int_t *xpad = new Int_t[numberd];
188 Int_t *zpad = new Int_t[numberd];
189 Int_t *tr1pad = new Int_t[numberd];
190 Int_t *tr2pad = new Int_t[numberd];
191 Int_t *tr3pad = new Int_t[numberd];
192 Int_t *tr4pad = new Int_t[numberd];
193 Int_t *iclus = new Int_t[numberd];
196 for (i=0; i < ndigits ; i++){
202 for (i=0; i < ndigits-1 ; i++) {
203 if ( ifpad[i] == -1 ) {
208 for (Int_t j=i+1 ; j < ndigits ; j++) {
209 if (ifpad[j]== -1 ) {
210 dx = TMath::Abs(digx[i]-digx[j]);
211 dz = TMath::Abs(digz[i]-digz[j]);
213 // if ( ( dx+dz )==1 ) //clusters are not diagonal
214 if ( ( dx+dz )==1 || (dx==1 && dz==1) ) { //diagonal clusters allowed
229 digtr1[j]=digtr1[ipos];
230 digtr2[j]=digtr2[ipos];
231 digtr3[j]=digtr3[ipos];
232 digtr4[j]=digtr4[ipos];
239 ifpad[j]=ifpad[ipos];
244 }//end loop on digits
246 if ( ifpad[ndigits-1] == -1 ) {
248 ifpad[ndigits-1]=nclus-1;
251 for (i=0 ; i < ndigits ; i++) iclus[ifpad[i]]++;
255 // loop on found clusters
256 for (i=0 ; i < nclus ; i++)
260 deltax = fSegmentation->Dpx(0);
263 //cluster with more than one digit
267 for (k=min;k<min+nd;k++)
269 xpad[count] = digx[k];
270 zpad[count] = digz[k];
272 tr1pad[count] = digtr1[k];
273 tr2pad[count] = digtr2[k];
274 tr3pad[count] = digtr3[k];
275 tr4pad[count] = digtr4[k];
279 ndxmin = xpad[TMath::LocMin(nd,xpad)];
280 ndxmax = xpad[TMath::LocMax(nd,xpad)];
281 ndzmin = zpad[TMath::LocMin(nd,zpad)];
282 ndzmax = zpad[TMath::LocMax(nd,zpad)];
283 ndx = ndxmax - ndxmin+1;
284 ndz = ndzmax - ndzmin+1;
287 // calculate x and z coordinates of the center of the cluster
288 fSegmentation->GetPadCxz(digx[min],digz[min]-1,xdum, zdum);
296 fSegmentation->GetPadCxz(xpad[k],zpad[k]-1,xdum,zdum);
297 xcenter[i] += (xdum / nd);
307 fSegmentation->GetPadCxz(xpad[k],zpad[k]-1,xdum,zdum);
308 zcenter[i] += (zdum / nd);
312 // error on points in x and z directions
315 errxcenter[i] = deltax / TMath::Sqrt(12.);
320 fSegmentation->GetPadCxz(xpad[k],zpad[k]-1,xdum,zdum);
321 errxcenter[i] += ((xdum-xcenter[i])*(xdum-xcenter[i]))/(nd*(nd-1));
323 errxcenter[i] = TMath::Sqrt(errxcenter[i]);
327 deltaz = fSegmentation->Dpz(digz[min]);
328 errzcenter[i] = deltaz / TMath::Sqrt(12.);
333 fSegmentation->GetPadCxz(xpad[k],zpad[k]-1,xdum,zdum);
334 errzcenter[i] += ((zdum-zcenter[i])*(zdum-zcenter[i]))/(nd*(nd-1));
336 errzcenter[i] = TMath::Sqrt(errzcenter[i]);
338 // take three track numbers for the cluster
339 // choose the track numbers of the digit with higher signal
343 if(tr4pad[k] > sigmax){
349 tr1clus[i]= tr1pad[kmax];
350 tr2clus[i]= tr2pad[kmax];
351 tr3clus[i]= tr3pad[kmax];
361 // cluster with single digit
365 fSegmentation->GetPadCxz(digx[min],digz[min]-1,xdum,zdum);
368 tr1clus[i]=digtr1[min];
369 tr2clus[i]=digtr2[min];
370 tr3clus[i]=digtr3[min];
371 deltaz = fSegmentation->Dpz(digz[min]);
372 errxcenter[i] = deltax / TMath::Sqrt(12.);
373 errzcenter[i] = deltaz / TMath::Sqrt(12.);
376 // store the cluster information to the AliITSRawCLusterSPD object
377 AliITS *iTS=(AliITS*)gAlice->GetModule("ITS");
379 //put the cluster center in local reference frame of the detector
381 xcenter[i] = xcenter[i] - fSegmentation->Dx()/2.;
382 zcenter[i] = zcenter[i] - fSegmentation->Dz()/2.;
385 AliITSRawClusterSPD *clust = new AliITSRawClusterSPD(zcenter[i], //f
392 iTS->AddCluster(0,clust);
394 }//end loop on clusters
404 //______________________________________________________
405 void AliITSClusterFinderSPD::DigitToPoint(Int_t nclus,
406 Float_t *xcenter, Float_t *zcenter,
407 Float_t *errxcenter,Float_t *errzcenter,
408 Int_t *tr1clus, Int_t *tr2clus, Int_t *tr3clus){
410 // A point is associated to each cluster of SPD digits. The points
411 // and their associated errors are stored in the file galiceSP.root.
416 const Float_t kconv = 1.0e-4; // micron -> cm
419 AliITS *iTS=(AliITS*)gAlice->GetModule("ITS");
421 for (Int_t i=0; i<nclus; i++)
423 l[0] = kconv*xcenter[i];
424 l[1] = kconv*fSegmentation->Dy()/2.;
425 l[2] = kconv*zcenter[i];
430 Float_t sigma2x = (kconv*errxcenter[i]) * (kconv*errxcenter[i]);
431 Float_t sigma2z = (kconv*errzcenter[i]) * (kconv*errzcenter[i]);
437 rnew.SetSigmaX2(sigma2x);
438 rnew.SetSigmaZ2(sigma2z);
439 rnew.fTracks[0]=tr1clus[i];
440 rnew.fTracks[1]=tr2clus[i];
441 rnew.fTracks[2]=tr3clus[i];
442 iTS->AddRecPoint(rnew);