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 **************************************************************************/
15 ////////////////////////////////////////////////////////////////////////////
17 // for Silicon pixels //
19 ////////////////////////////////////////////////////////////////////////////
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),
68 //______________________________________________________________________
69 AliITSClusterFinderSPD::AliITSClusterFinderSPD(const AliITSClusterFinderSPD &source) : AliITSClusterFinder(source) {
71 // Copies are not allowed. The method is protected to avoid misuse.
72 Fatal("AliITSClusterFinderSPD","Copy constructor not allowed\n");
75 //______________________________________________________________________
76 AliITSClusterFinderSPD& AliITSClusterFinderSPD::operator=(const AliITSClusterFinderSPD& /* source */){
77 // Assignment operator
78 // Assignment is not allowed. The method is protected to avoid misuse.
79 Fatal("= operator","Assignment operator not allowed\n");
82 //______________________________________________________________________
83 void AliITSClusterFinderSPD::FindRawClusters(Int_t module){
84 // input of Cluster Finder
86 Int_t numberd = 100000;
87 Int_t *digx = new Int_t[numberd];
88 Int_t *digz = new Int_t[numberd];
89 Int_t *digtr1 = new Int_t[numberd];
90 Int_t *digtr2 = new Int_t[numberd];
91 Int_t *digtr3 = new Int_t[numberd];
92 Int_t *digtr4 = new Int_t[numberd];
93 // output of Cluster Finder
94 Int_t numberc = 10000;
95 Double_t *xcenterl = new Double_t[numberc];
96 Double_t *zcenterl = new Double_t[numberc];
97 Double_t *errxcenter = new Double_t[numberc];
98 Double_t *errzcenter = new Double_t[numberc];
99 Int_t *tr1clus = new Int_t[numberc];
100 Int_t *tr2clus = new Int_t[numberc];
101 Int_t *tr3clus = new Int_t[numberc];
106 Int_t ndigits = Digits()->GetEntriesFast();
107 if (!ndigits) return;
113 cout << "SPD - FindRawclusters"<<endl;
117 for(ndig=0; ndig<ndigits; ndig++) {
118 dig= (AliITSdigitSPD*)GetDigit(ndig);
119 digx[digitcount] = dig->GetCoord2()+1; //starts at 1
120 digz[digitcount] = dig->GetCoord1()+1; //starts at 1
121 digtr1[digitcount] = dig->GetTrack(0);
122 digtr2[digitcount] = -3;
123 digtr3[digitcount] = -3;
125 cout << "digtr1["<<digitcount <<"]="<<digtr1[digitcount];
126 cout << " fTracks["<<0<<"]="<<dig->GetTrack(0)<<": ";
129 while(digtr1[digitcount]==dig->GetTrack(i) && i<dig->GetNTracks()) i++;
130 if(GetDebug(5)) cout << " fTracks["<<i<<"]="<<dig->GetTrack(i);
131 if(i<dig->GetNTracks()){
132 digtr2[digitcount] = dig->GetTrack(i);
133 if(GetDebug(5)) cout<<"digtr2["<<digitcount <<"]="
134 <<digtr2[digitcount]<<": ";
135 while((digtr1[digitcount]==dig->GetTrack(i) ||
136 digtr2[digitcount]==dig->GetTrack(i))&&
137 i<=dig->GetNTracks()) i++;
138 if(i<dig->GetNTracks()) digtr3[digitcount] = dig->GetTrack(i);
140 cout << " fTracks["<<i<<"]=";
141 if(i<dig->GetNTracks()) cout <<dig->GetTrack(i);
142 cout << "digtr3["<<digitcount <<"]="<<digtr3[digitcount];
145 if(GetDebug(4)) cout<<endl;
146 digtr4[digitcount] = dig->GetSignal();
149 ClusterFinder(digitcount,digx,digz,digtr1,digtr2,digtr3,digtr4,
150 nclus,xcenterl,zcenterl,errxcenter,errzcenter,
151 tr1clus, tr2clus, tr3clus);
152 DigitToPoint(nclus,xcenterl,zcenterl,errxcenter,errzcenter,
153 tr1clus, tr2clus, tr3clus);
168 //----------------------------------------------------------------------
169 void AliITSClusterFinderSPD::ClusterFinder(Int_t ndigits,Int_t digx[],
170 Int_t digz[],Int_t digtr1[],
171 Int_t digtr2[],Int_t digtr3[],
172 Int_t digtr4[],Int_t &nclus,
173 Double_t xcenter[],Double_t zcenter[],
174 Double_t errxcenter[],
175 Double_t errzcenter[],
176 Int_t tr1clus[],Int_t tr2clus[],
178 // Search for clusters of fired pixels (digits). Two digits are linked
179 // inside a cluster if they are countiguous both in row or column
180 // direction. Diagonal digits are not linked.
181 // xcenter, ycenter, zcenter are the coordinates of the center
182 // of each found cluster, calculated from the averaging the corresponding
183 // coordinate of the center of the linked digits. The coordinates are
184 // given in the local reference sistem.
185 // errxcenter, errycenter, errzcenter are the errors associated to
186 // the corresponding average.
187 Int_t if1, min, max, nd;
188 Int_t x1, z1, t1, t2, t3, t4;
189 Int_t ndx, ndz, ndxmin=0, ndxmax=0, ndzmin=0, ndzmax=0;
194 Double_t deltax, deltaz;
196 Int_t numberd = 10000;
197 Int_t *ifpad = new Int_t[numberd];
198 Int_t *xpad = new Int_t[numberd];
199 Int_t *zpad = new Int_t[numberd];
200 Int_t *tr1pad = new Int_t[numberd];
201 Int_t *tr2pad = new Int_t[numberd];
202 Int_t *tr3pad = new Int_t[numberd];
203 Int_t *tr4pad = new Int_t[numberd];
204 Int_t *iclus = new Int_t[numberd];
207 for (i=0; i < ndigits ; i++){
213 for (i=0; i < ndigits-1 ; i++) {
214 if ( ifpad[i] == -1 ) {
219 for (Int_t j=i+1 ; j < ndigits ; j++) {
220 if (ifpad[j]== -1 ) {
221 dx = TMath::Abs(digx[i]-digx[j]);
222 dz = TMath::Abs(digz[i]-digz[j]);
223 // if ( ( dx+dz )==1 ) //clusters are not diagonal
224 if(( dx+dz )==1 || (dx==1 && dz==1)){
225 //diagonal clusters allowed
231 digx[j] = digx[ipos];
232 digz[j] = digz[ipos];
240 digtr1[j] = digtr1[ipos];
241 digtr2[j] = digtr2[ipos];
242 digtr3[j] = digtr3[ipos];
243 digtr4[j] = digtr4[ipos];
250 ifpad[j] = ifpad[ipos];
253 }// end if ifpad[j]== -1
255 }//end loop on digits
256 if ( ifpad[ndigits-1] == -1 ) {
258 ifpad[ndigits-1]=nclus-1;
259 } // end if ifpad[ndigits-1] == -1
261 for (i=0 ; i < ndigits ; i++) iclus[ifpad[i]]++;
265 // loop on found clusters
266 for (i=0 ; i < nclus ; i++){
269 deltax = GetSeg()->Dpx(0);
271 //cluster with more than one digit
275 for (k=min;k<min+nd;k++){
276 xpad[count] = digx[k];
277 zpad[count] = digz[k];
279 tr1pad[count] = digtr1[k];
280 tr2pad[count] = digtr2[k];
281 tr3pad[count] = digtr3[k];
282 tr4pad[count] = digtr4[k];
286 ndxmin = xpad[TMath::LocMin(nd,xpad)];
287 ndxmax = xpad[TMath::LocMax(nd,xpad)];
288 ndzmin = zpad[TMath::LocMin(nd,zpad)];
289 ndzmax = zpad[TMath::LocMax(nd,zpad)];
290 ndx = ndxmax - ndxmin+1;
291 ndz = ndzmax - ndzmin+1;
293 // calculate x and z coordinates of the center of the cluster
294 GetSeg()->GetPadCxz(digx[min],digz[min]-1,xdum, zdum);
301 GetSeg()->GetPadCxz(xpad[k],zpad[k]-1,xdum,zdum);
302 xcenter[i] += (xdum / nd);
311 GetSeg()->GetPadCxz(xpad[k],zpad[k]-1,xdum,zdum);
312 zcenter[i] += (zdum / nd);
316 // error on points in x and z directions
319 errxcenter[i] = deltax / TMath::Sqrt(12.);
323 GetSeg()->GetPadCxz(xpad[k],zpad[k]-1,xdum,zdum);
324 errxcenter[i] += ((xdum-xcenter[i])*(xdum-xcenter[i]))/
327 errxcenter[i] = TMath::Sqrt(errxcenter[i]);
330 deltaz = GetSeg()->Dpz(digz[min]);
331 errzcenter[i] = deltaz / TMath::Sqrt(12.);
335 GetSeg()->GetPadCxz(xpad[k],zpad[k]-1,xdum,zdum);
336 errzcenter[i] += ((zdum-zcenter[i])*(zdum-zcenter[i]))/
339 errzcenter[i] = TMath::Sqrt(errzcenter[i]);
341 // take three track numbers for the cluster
342 // choose the track numbers of the digit with higher signal
346 if(tr4pad[k] > sigmax){
349 } // end if tr4pad[k]
352 tr1clus[i]= tr1pad[kmax];
353 tr2clus[i]= tr2pad[kmax];
354 tr3clus[i]= tr3pad[kmax];
361 // cluster with single digit
365 GetSeg()->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 = GetSeg()->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
379 //put the cluster center in local reference frame of the detector
381 xcenter[i] = xcenter[i] - GetSeg()->Dx()/2.;
382 zcenter[i] = zcenter[i] - GetSeg()->Dz()/2.;
384 AliITSRawClusterSPD *clust = new AliITSRawClusterSPD(zcenter[i], //f
392 fITS->AddCluster(0,clust);
394 }//end loop on clusters
404 //______________________________________________________----------------
405 void AliITSClusterFinderSPD::DigitToPoint(Int_t nclus,
406 Double_t *xcenter,Double_t *zcenter,
407 Double_t *errxcenter,
408 Double_t *errzcenter,
409 Int_t *tr1clus, Int_t *tr2clus,
411 // A point is associated to each cluster of SPD digits. The points
412 // and their associated errors are stored in the file galiceSP.root.
414 const Double_t kconv = 1.0e-4; // micron -> cm
417 for (Int_t i=0; i<nclus; i++){
418 l[0] = kconv*xcenter[i];
419 l[1] = kconv*GetSeg()->Dy()/2.;
420 l[2] = kconv*zcenter[i];
425 Double_t sigma2x = (kconv*errxcenter[i]) * (kconv*errxcenter[i]);
426 Double_t sigma2z = (kconv*errzcenter[i]) * (kconv*errzcenter[i]);
432 rnew.SetSigmaX2(sigma2x);
433 rnew.SetSigmaZ2(sigma2z);
434 rnew.fTracks[0]=tr1clus[i];
435 rnew.fTracks[1]=tr2clus[i];
436 rnew.fTracks[2]=tr3clus[i];
437 fITS->AddRecPoint(rnew);