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 **************************************************************************/
20 #include "AliITSClusterFinderSPD.h"
22 #include "AliITSdigit.h"
23 #include "AliITSRawCluster.h"
24 #include "AliITSRecPoint.h"
25 #include "AliITSsegmentation.h"
30 ClassImp(AliITSClusterFinderSPD)
32 //----------------------------------------------------------
33 AliITSClusterFinderSPD::AliITSClusterFinderSPD(AliITSsegmentation *seg,
41 fNclusters = fClusters->GetEntriesFast();
45 //______________________________________________________________________
46 AliITSClusterFinderSPD::AliITSClusterFinderSPD(){
56 //_____________________________________________________________________
57 AliITSClusterFinderSPD::AliITSClusterFinderSPD(const AliITSClusterFinderSPD
61 if(&source == this) return;
62 this->fClusters = source.fClusters ;
63 this->fNclusters = source.fNclusters ;
64 this->fDz = source.fDz ;
65 this->fDx = source.fDx ;
68 //______________________________________________________________________
69 AliITSClusterFinderSPD& AliITSClusterFinderSPD::operator=(
70 const AliITSClusterFinderSPD &source) {
71 // Assignment operator
73 if(&source == this) return *this;
74 this->fClusters = source.fClusters ;
75 this->fNclusters = source.fNclusters ;
76 this->fDz = source.fDz ;
77 this->fDx = source.fDx ;
80 //______________________________________________________________________
81 void AliITSClusterFinderSPD::FindRawClusters(Int_t module){
82 // input of Cluster Finder
84 Int_t numberd = 100000;
85 Int_t *digx = new Int_t[numberd];
86 Int_t *digz = new Int_t[numberd];
87 Int_t *digtr1 = new Int_t[numberd];
88 Int_t *digtr2 = new Int_t[numberd];
89 Int_t *digtr3 = new Int_t[numberd];
90 Int_t *digtr4 = new Int_t[numberd];
91 // output of Cluster Finder
92 Int_t numberc = 10000;
93 Float_t *xcenterl = new Float_t[numberc];
94 Float_t *zcenterl = new Float_t[numberc];
95 Float_t *errxcenter = new Float_t[numberc];
96 Float_t *errzcenter = new Float_t[numberc];
97 Int_t *tr1clus = new Int_t[numberc];
98 Int_t *tr2clus = new Int_t[numberc];
99 Int_t *tr3clus = new Int_t[numberc];
103 Int_t ndigits = fDigits->GetEntriesFast();
104 if (!ndigits) return;
108 // cout << "FindRawcluters"<<endl;
110 for(ndig=0; ndig<ndigits; ndig++) {
111 dig= (AliITSdigitSPD*)fDigits->UncheckedAt(ndig);
112 digx[digitcount] = dig->fCoord2+1; //starts at 1
113 digz[digitcount] = dig->fCoord1+1; //starts at 1
114 digtr1[digitcount] = dig->fTracks[0];
115 digtr2[digitcount] = -3;
116 digtr3[digitcount] = -3;
117 //cout << "digtr1["<<digitcount <<"]="<<digtr1[digitcount];
118 //cout << " fTracks["<<0<<"]="<<dig->fTracks[0]<<": ";
120 while(digtr1[digitcount]==dig->fTracks[i] && i<dig->GetNTracks()) i++;
121 //cout << " fTracks["<<i<<"]="<<dig->fTracks[i];
122 if(i<dig->GetNTracks()){
123 digtr2[digitcount] = dig->fTracks[i];
124 //cout << "digtr2["<<digitcount <<"]="<<digtr2[digitcount]<<": ";
125 while((digtr1[digitcount]==dig->fTracks[i] ||
126 digtr2[digitcount]==dig->fTracks[i] )&&
127 i<=dig->GetNTracks()) i++;
128 if(i<dig->GetNTracks()) digtr3[digitcount] = dig->fTracks[i];
129 //cout << " fTracks["<<i<<"]=";
130 //if(i<dig->GetNTracks()) cout <<dig->fTracks[i];
131 //cout << "digtr3["<<digitcount <<"]="<<digtr3[digitcount];
134 digtr4[digitcount] = dig->fSignal;
137 ClusterFinder(digitcount,digx,digz,digtr1,digtr2,digtr3,digtr4,
138 nclus,xcenterl,zcenterl,errxcenter,errzcenter,
139 tr1clus, tr2clus, tr3clus,module);
140 DigitToPoint(nclus,xcenterl,zcenterl,errxcenter,errzcenter,
141 tr1clus, tr2clus, tr3clus);
156 //----------------------------------------------------------------------
157 void AliITSClusterFinderSPD::ClusterFinder(Int_t ndigits,Int_t digx[],
158 Int_t digz[],Int_t digtr1[],
159 Int_t digtr2[],Int_t digtr3[],
160 Int_t digtr4[],Int_t &nclus,
161 Float_t xcenter[],Float_t zcenter[],
162 Float_t errxcenter[],
163 Float_t errzcenter[],
164 Int_t tr1clus[],Int_t tr2clus[],
165 Int_t tr3clus[],Int_t module){
166 // Search for clusters of fired pixels (digits). Two digits are linked
167 // inside a cluster if they are countiguous both in row or column
168 // direction. Diagonal digits are not linked.
169 // xcenter, ycenter, zcenter are the coordinates of the center
170 // of each found cluster, calculated from the averaging the corresponding
171 // coordinate of the center of the linked digits. The coordinates are
172 // given in the local reference sistem.
173 // errxcenter, errycenter, errzcenter are the errors associated to
174 // 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=0, ndxmax=0, ndzmin=0, ndzmax=0;
182 Float_t deltax, deltaz;
184 Int_t numberd = 10000;
185 Int_t *ifpad = new Int_t[numberd];
186 Int_t *xpad = new Int_t[numberd];
187 Int_t *zpad = new Int_t[numberd];
188 Int_t *tr1pad = new Int_t[numberd];
189 Int_t *tr2pad = new Int_t[numberd];
190 Int_t *tr3pad = new Int_t[numberd];
191 Int_t *tr4pad = new Int_t[numberd];
192 Int_t *iclus = new Int_t[numberd];
195 for (i=0; i < ndigits ; i++){
201 for (i=0; i < ndigits-1 ; i++) {
202 if ( ifpad[i] == -1 ) {
207 for (Int_t j=i+1 ; j < ndigits ; j++) {
208 if (ifpad[j]== -1 ) {
209 dx = TMath::Abs(digx[i]-digx[j]);
210 dz = TMath::Abs(digz[i]-digz[j]);
211 // if ( ( dx+dz )==1 ) //clusters are not diagonal
212 if(( dx+dz )==1 || (dx==1 && dz==1)){
213 //diagonal clusters allowed
219 digx[j] = digx[ipos];
220 digz[j] = digz[ipos];
228 digtr1[j] = digtr1[ipos];
229 digtr2[j] = digtr2[ipos];
230 digtr3[j] = digtr3[ipos];
231 digtr4[j] = digtr4[ipos];
238 ifpad[j] = ifpad[ipos];
241 }// end if ifpad[j]== -1
243 }//end loop on digits
244 if ( ifpad[ndigits-1] == -1 ) {
246 ifpad[ndigits-1]=nclus-1;
247 } // end if ifpad[ndigits-1] == -1
249 for (i=0 ; i < ndigits ; i++) iclus[ifpad[i]]++;
253 // loop on found clusters
254 for (i=0 ; i < nclus ; i++){
257 deltax = fSegmentation->Dpx(0);
259 //cluster with more than one digit
263 for (k=min;k<min+nd;k++){
264 xpad[count] = digx[k];
265 zpad[count] = digz[k];
267 tr1pad[count] = digtr1[k];
268 tr2pad[count] = digtr2[k];
269 tr3pad[count] = digtr3[k];
270 tr4pad[count] = digtr4[k];
274 ndxmin = xpad[TMath::LocMin(nd,xpad)];
275 ndxmax = xpad[TMath::LocMax(nd,xpad)];
276 ndzmin = zpad[TMath::LocMin(nd,zpad)];
277 ndzmax = zpad[TMath::LocMax(nd,zpad)];
278 ndx = ndxmax - ndxmin+1;
279 ndz = ndzmax - ndzmin+1;
281 // calculate x and z coordinates of the center of the cluster
282 fSegmentation->GetPadCxz(digx[min],digz[min]-1,xdum, zdum);
289 fSegmentation->GetPadCxz(xpad[k],zpad[k]-1,xdum,zdum);
290 xcenter[i] += (xdum / nd);
299 fSegmentation->GetPadCxz(xpad[k],zpad[k]-1,xdum,zdum);
300 zcenter[i] += (zdum / nd);
304 // error on points in x and z directions
307 errxcenter[i] = deltax / TMath::Sqrt(12.);
311 fSegmentation->GetPadCxz(xpad[k],zpad[k]-1,xdum,zdum);
312 errxcenter[i] += ((xdum-xcenter[i])*(xdum-xcenter[i]))/
315 errxcenter[i] = TMath::Sqrt(errxcenter[i]);
318 deltaz = fSegmentation->Dpz(digz[min]);
319 errzcenter[i] = deltaz / TMath::Sqrt(12.);
323 fSegmentation->GetPadCxz(xpad[k],zpad[k]-1,xdum,zdum);
324 errzcenter[i] += ((zdum-zcenter[i])*(zdum-zcenter[i]))/
327 errzcenter[i] = TMath::Sqrt(errzcenter[i]);
329 // take three track numbers for the cluster
330 // choose the track numbers of the digit with higher signal
334 if(tr4pad[k] > sigmax){
337 } // end if tr4pad[k]
340 tr1clus[i]= tr1pad[kmax];
341 tr2clus[i]= tr2pad[kmax];
342 tr3clus[i]= tr3pad[kmax];
349 // cluster with single digit
353 fSegmentation->GetPadCxz(digx[min],digz[min]-1,xdum,zdum);
356 tr1clus[i]=digtr1[min];
357 tr2clus[i]=digtr2[min];
358 tr3clus[i]=digtr3[min];
359 deltaz = fSegmentation->Dpz(digz[min]);
360 errxcenter[i] = deltax / TMath::Sqrt(12.);
361 errzcenter[i] = deltaz / TMath::Sqrt(12.);
364 // store the cluster information to the AliITSRawCLusterSPD object
365 static AliITS *iTS=(AliITS*)gAlice->GetModule("ITS");
367 //put the cluster center in local reference frame of the detector
369 xcenter[i] = xcenter[i] - fSegmentation->Dx()/2.;
370 zcenter[i] = zcenter[i] - fSegmentation->Dz()/2.;
372 AliITSRawClusterSPD *clust = new AliITSRawClusterSPD(zcenter[i], //f
380 iTS->AddCluster(0,clust);
382 }//end loop on clusters
392 //______________________________________________________----------------
393 void AliITSClusterFinderSPD::DigitToPoint(Int_t nclus,
394 Float_t *xcenter,Float_t *zcenter,
397 Int_t *tr1clus, Int_t *tr2clus,
399 // A point is associated to each cluster of SPD digits. The points
400 // and their associated errors are stored in the file galiceSP.root.
402 const Float_t kconv = 1.0e-4; // micron -> cm
405 static AliITS *iTS=(AliITS*)gAlice->GetModule("ITS");
406 for (Int_t i=0; i<nclus; i++){
407 l[0] = kconv*xcenter[i];
408 l[1] = kconv*fSegmentation->Dy()/2.;
409 l[2] = kconv*zcenter[i];
414 Float_t sigma2x = (kconv*errxcenter[i]) * (kconv*errxcenter[i]);
415 Float_t sigma2z = (kconv*errzcenter[i]) * (kconv*errzcenter[i]);
421 rnew.SetSigmaX2(sigma2x);
422 rnew.SetSigmaZ2(sigma2z);
423 rnew.fTracks[0]=tr1clus[i];
424 rnew.fTracks[1]=tr2clus[i];
425 rnew.fTracks[2]=tr3clus[i];
426 iTS->AddRecPoint(rnew);