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 "AliITSdigitSPD.h"
23 #include "AliITSRawClusterSPD.h"
24 #include "AliITSRecPoint.h"
25 #include "AliITSresponseSPD.h"
26 #include "AliITSsegmentationSPD.h"
31 ClassImp(AliITSClusterFinderSPD)
33 //______________________________________________________________________
34 AliITSClusterFinderSPD::AliITSClusterFinderSPD():AliITSClusterFinder(),
40 //----------------------------------------------------------
41 AliITSClusterFinderSPD::AliITSClusterFinderSPD(AliITSsegmentation *seg,
43 AliITSClusterFinder(seg,res),
52 //----------------------------------------------------------
53 AliITSClusterFinderSPD::AliITSClusterFinderSPD(AliITSsegmentation *seg,
56 AliITSClusterFinder(seg,0),
67 //_____________________________________________________________________
68 AliITSClusterFinderSPD::AliITSClusterFinderSPD(
69 const AliITSClusterFinderSPD &source): AliITSClusterFinder(source){
72 if(&source == this) return;
73 this->fDz = source.fDz;
74 this->fDx = source.fDx;
75 this->fMinNCells = source.fMinNCells;
78 //______________________________________________________________________
79 AliITSClusterFinderSPD& AliITSClusterFinderSPD::operator=(
80 const AliITSClusterFinderSPD &source) {
81 // Assignment operator
83 if(&source == this) return *this;
84 this->fDz = source.fDz;
85 this->fDx = source.fDx;
86 this->fMinNCells = source.fMinNCells;
89 //______________________________________________________________________
90 void AliITSClusterFinderSPD::FindRawClusters(Int_t module){
91 // input of Cluster Finder
93 Int_t numberd = 100000;
94 Int_t *digx = new Int_t[numberd];
95 Int_t *digz = new Int_t[numberd];
96 Int_t *digtr1 = new Int_t[numberd];
97 Int_t *digtr2 = new Int_t[numberd];
98 Int_t *digtr3 = new Int_t[numberd];
99 Int_t *digtr4 = new Int_t[numberd];
100 // output of Cluster Finder
101 Int_t numberc = 10000;
102 Double_t *xcenterl = new Double_t[numberc];
103 Double_t *zcenterl = new Double_t[numberc];
104 Double_t *errxcenter = new Double_t[numberc];
105 Double_t *errzcenter = new Double_t[numberc];
106 Int_t *tr1clus = new Int_t[numberc];
107 Int_t *tr2clus = new Int_t[numberc];
108 Int_t *tr3clus = new Int_t[numberc];
113 Int_t ndigits = Digits()->GetEntriesFast();
114 if (!ndigits) return;
120 cout << "SPD - FindRawclusters"<<endl;
124 for(ndig=0; ndig<ndigits; ndig++) {
125 dig= (AliITSdigitSPD*)GetDigit(ndig);
126 digx[digitcount] = dig->GetCoord2()+1; //starts at 1
127 digz[digitcount] = dig->GetCoord1()+1; //starts at 1
128 digtr1[digitcount] = dig->GetTrack(0);
129 digtr2[digitcount] = -3;
130 digtr3[digitcount] = -3;
132 cout << "digtr1["<<digitcount <<"]="<<digtr1[digitcount];
133 cout << " fTracks["<<0<<"]="<<dig->GetTrack(0)<<": ";
136 while(digtr1[digitcount]==dig->GetTrack(i) && i<dig->GetNTracks()) i++;
137 if(GetDebug(5)) cout << " fTracks["<<i<<"]="<<dig->GetTrack(i);
138 if(i<dig->GetNTracks()){
139 digtr2[digitcount] = dig->GetTrack(i);
140 if(GetDebug(5)) cout<<"digtr2["<<digitcount <<"]="
141 <<digtr2[digitcount]<<": ";
142 while((digtr1[digitcount]==dig->GetTrack(i) ||
143 digtr2[digitcount]==dig->GetTrack(i))&&
144 i<=dig->GetNTracks()) i++;
145 if(i<dig->GetNTracks()) digtr3[digitcount] = dig->GetTrack(i);
147 cout << " fTracks["<<i<<"]=";
148 if(i<dig->GetNTracks()) cout <<dig->GetTrack(i);
149 cout << "digtr3["<<digitcount <<"]="<<digtr3[digitcount];
152 if(GetDebug(4)) cout<<endl;
153 digtr4[digitcount] = dig->GetSignal();
156 ClusterFinder(digitcount,digx,digz,digtr1,digtr2,digtr3,digtr4,
157 nclus,xcenterl,zcenterl,errxcenter,errzcenter,
158 tr1clus, tr2clus, tr3clus);
159 DigitToPoint(nclus,xcenterl,zcenterl,errxcenter,errzcenter,
160 tr1clus, tr2clus, tr3clus);
175 //----------------------------------------------------------------------
176 void AliITSClusterFinderSPD::ClusterFinder(Int_t ndigits,Int_t digx[],
177 Int_t digz[],Int_t digtr1[],
178 Int_t digtr2[],Int_t digtr3[],
179 Int_t digtr4[],Int_t &nclus,
180 Double_t xcenter[],Double_t zcenter[],
181 Double_t errxcenter[],
182 Double_t errzcenter[],
183 Int_t tr1clus[],Int_t tr2clus[],
185 // Search for clusters of fired pixels (digits). Two digits are linked
186 // inside a cluster if they are countiguous both in row or column
187 // direction. Diagonal digits are not linked.
188 // xcenter, ycenter, zcenter are the coordinates of the center
189 // of each found cluster, calculated from the averaging the corresponding
190 // coordinate of the center of the linked digits. The coordinates are
191 // given in the local reference sistem.
192 // errxcenter, errycenter, errzcenter are the errors associated to
193 // the corresponding average.
194 Int_t if1, min, max, nd;
195 Int_t x1, z1, t1, t2, t3, t4;
196 Int_t ndx, ndz, ndxmin=0, ndxmax=0, ndzmin=0, ndzmax=0;
201 Double_t deltax, deltaz;
203 Int_t numberd = 10000;
204 Int_t *ifpad = new Int_t[numberd];
205 Int_t *xpad = new Int_t[numberd];
206 Int_t *zpad = new Int_t[numberd];
207 Int_t *tr1pad = new Int_t[numberd];
208 Int_t *tr2pad = new Int_t[numberd];
209 Int_t *tr3pad = new Int_t[numberd];
210 Int_t *tr4pad = new Int_t[numberd];
211 Int_t *iclus = new Int_t[numberd];
214 for (i=0; i < ndigits ; i++){
220 for (i=0; i < ndigits-1 ; i++) {
221 if ( ifpad[i] == -1 ) {
226 for (Int_t j=i+1 ; j < ndigits ; j++) {
227 if (ifpad[j]== -1 ) {
228 dx = TMath::Abs(digx[i]-digx[j]);
229 dz = TMath::Abs(digz[i]-digz[j]);
230 // if ( ( dx+dz )==1 ) //clusters are not diagonal
231 if(( dx+dz )==1 || (dx==1 && dz==1)){
232 //diagonal clusters allowed
238 digx[j] = digx[ipos];
239 digz[j] = digz[ipos];
247 digtr1[j] = digtr1[ipos];
248 digtr2[j] = digtr2[ipos];
249 digtr3[j] = digtr3[ipos];
250 digtr4[j] = digtr4[ipos];
257 ifpad[j] = ifpad[ipos];
260 }// end if ifpad[j]== -1
262 }//end loop on digits
263 if ( ifpad[ndigits-1] == -1 ) {
265 ifpad[ndigits-1]=nclus-1;
266 } // end if ifpad[ndigits-1] == -1
268 for (i=0 ; i < ndigits ; i++) iclus[ifpad[i]]++;
272 // loop on found clusters
273 for (i=0 ; i < nclus ; i++){
276 deltax = GetSeg()->Dpx(0);
278 //cluster with more than one digit
282 for (k=min;k<min+nd;k++){
283 xpad[count] = digx[k];
284 zpad[count] = digz[k];
286 tr1pad[count] = digtr1[k];
287 tr2pad[count] = digtr2[k];
288 tr3pad[count] = digtr3[k];
289 tr4pad[count] = digtr4[k];
293 ndxmin = xpad[TMath::LocMin(nd,xpad)];
294 ndxmax = xpad[TMath::LocMax(nd,xpad)];
295 ndzmin = zpad[TMath::LocMin(nd,zpad)];
296 ndzmax = zpad[TMath::LocMax(nd,zpad)];
297 ndx = ndxmax - ndxmin+1;
298 ndz = ndzmax - ndzmin+1;
300 // calculate x and z coordinates of the center of the cluster
301 GetSeg()->GetPadCxz(digx[min],digz[min]-1,xdum, zdum);
308 GetSeg()->GetPadCxz(xpad[k],zpad[k]-1,xdum,zdum);
309 xcenter[i] += (xdum / nd);
318 GetSeg()->GetPadCxz(xpad[k],zpad[k]-1,xdum,zdum);
319 zcenter[i] += (zdum / nd);
323 // error on points in x and z directions
326 errxcenter[i] = deltax / TMath::Sqrt(12.);
330 GetSeg()->GetPadCxz(xpad[k],zpad[k]-1,xdum,zdum);
331 errxcenter[i] += ((xdum-xcenter[i])*(xdum-xcenter[i]))/
334 errxcenter[i] = TMath::Sqrt(errxcenter[i]);
337 deltaz = GetSeg()->Dpz(digz[min]);
338 errzcenter[i] = deltaz / TMath::Sqrt(12.);
342 GetSeg()->GetPadCxz(xpad[k],zpad[k]-1,xdum,zdum);
343 errzcenter[i] += ((zdum-zcenter[i])*(zdum-zcenter[i]))/
346 errzcenter[i] = TMath::Sqrt(errzcenter[i]);
348 // take three track numbers for the cluster
349 // choose the track numbers of the digit with higher signal
353 if(tr4pad[k] > sigmax){
356 } // end if tr4pad[k]
359 tr1clus[i]= tr1pad[kmax];
360 tr2clus[i]= tr2pad[kmax];
361 tr3clus[i]= tr3pad[kmax];
368 // cluster with single digit
372 GetSeg()->GetPadCxz(digx[min],digz[min]-1,xdum,zdum);
375 tr1clus[i]=digtr1[min];
376 tr2clus[i]=digtr2[min];
377 tr3clus[i]=digtr3[min];
378 deltaz = GetSeg()->Dpz(digz[min]);
379 errxcenter[i] = deltax / TMath::Sqrt(12.);
380 errzcenter[i] = deltaz / TMath::Sqrt(12.);
383 // store the cluster information to the AliITSRawCLusterSPD object
384 static AliITS *iTS=(AliITS*)gAlice->GetModule("ITS");
386 //put the cluster center in local reference frame of the detector
388 xcenter[i] = xcenter[i] - GetSeg()->Dx()/2.;
389 zcenter[i] = zcenter[i] - GetSeg()->Dz()/2.;
391 AliITSRawClusterSPD *clust = new AliITSRawClusterSPD(zcenter[i], //f
399 iTS->AddCluster(0,clust);
401 }//end loop on clusters
411 //______________________________________________________----------------
412 void AliITSClusterFinderSPD::DigitToPoint(Int_t nclus,
413 Double_t *xcenter,Double_t *zcenter,
414 Double_t *errxcenter,
415 Double_t *errzcenter,
416 Int_t *tr1clus, Int_t *tr2clus,
418 // A point is associated to each cluster of SPD digits. The points
419 // and their associated errors are stored in the file galiceSP.root.
421 const Double_t kconv = 1.0e-4; // micron -> cm
424 static AliITS *iTS=(AliITS*)gAlice->GetModule("ITS");
425 for (Int_t i=0; i<nclus; i++){
426 l[0] = kconv*xcenter[i];
427 l[1] = kconv*GetSeg()->Dy()/2.;
428 l[2] = kconv*zcenter[i];
433 Double_t sigma2x = (kconv*errxcenter[i]) * (kconv*errxcenter[i]);
434 Double_t sigma2z = (kconv*errzcenter[i]) * (kconv*errzcenter[i]);
440 rnew.SetSigmaX2(sigma2x);
441 rnew.SetSigmaZ2(sigma2z);
442 rnew.fTracks[0]=tr1clus[i];
443 rnew.fTracks[1]=tr2clus[i];
444 rnew.fTracks[2]=tr3clus[i];
445 iTS->AddRecPoint(rnew);