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 "AliITSClusterFinderSPDbari.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(AliITSClusterFinderSPDbari)
32 //----------------------------------------------------------
33 AliITSClusterFinderSPDbari::AliITSClusterFinderSPDbari
34 (AliITSsegmentation *seg, TClonesArray *digits, TClonesArray *recp)
40 fNclusters= fClusters->GetEntriesFast();
45 //_____________________________________________________________________________
46 AliITSClusterFinderSPDbari::AliITSClusterFinderSPDbari()
58 //__________________________________________________________________________
59 AliITSClusterFinderSPDbari::AliITSClusterFinderSPDbari(const
60 AliITSClusterFinderSPDbari &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 AliITSClusterFinderSPDbari&
72 AliITSClusterFinderSPDbari::operator=(const AliITSClusterFinderSPDbari &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 AliITSClusterFinderSPDbari::FindRawClusters(){
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];
94 // output of Cluster Finder
96 Float_t *xcenterl = new Float_t[numberc];
97 Float_t *zcenterl = new Float_t[numberc];
98 Float_t *errxcenter = new Float_t[numberc];
99 Float_t *errzcenter = new Float_t[numberc];
100 Int_t *tr1clus = new Int_t[numberc];
101 Int_t *tr2clus = new Int_t[numberc];
102 Int_t *tr3clus = new Int_t[numberc];
107 Int_t ndigits = fDigits->GetEntriesFast();
108 if (!ndigits) return;
112 AliITSdigitSPD *dig1;
114 for(ndig=0; ndig<ndigits; ndig++) {
115 dig= (AliITSdigit*)fDigits->UncheckedAt(ndig);
117 digx[digitcount] = dig->fCoord2+1; //starts at 1
118 digz[digitcount] = dig->fCoord1+1; //starts at 1
120 dig1= (AliITSdigitSPD*)fDigits->UncheckedAt(ndig);
122 digtr1[digitcount] = dig1->fTracks[0];
123 digtr2[digitcount] = dig1->fTracks[1];
124 digtr3[digitcount] = dig1->fTracks[2];
130 ClusterFinder(digitcount,digx,digz,digtr1,digtr2,digtr3,
131 nclus,xcenterl,zcenterl,errxcenter,errzcenter,
132 tr1clus, tr2clus, tr3clus);
134 DigitToPoint(nclus,xcenterl,zcenterl,errxcenter,errzcenter,
135 tr1clus, tr2clus, tr3clus);
145 delete[] errxcenter ;
146 delete[] errzcenter ;
152 //-----------------------------------------------------------------
153 void AliITSClusterFinderSPDbari::ClusterFinder(Int_t ndigits,
154 Int_t digx[],Int_t digz[],
155 Int_t digtr1[],Int_t digtr2[],Int_t digtr3[],
156 Int_t &nclus, Float_t xcenter[],Float_t zcenter[],
157 Float_t errxcenter[],Float_t errzcenter[],
158 Int_t tr1clus[], Int_t tr2clus[], Int_t tr3clus[]) {
160 // Search for clusters of fired pixels (digits). Two digits are linked
161 // inside a cluster if they are countiguous both in row or column
162 // direction. Diagonal digits are not linked.
163 // xcenter, ycenter, zcenter are the coordinates of the center
164 // of each found cluster, calculated from the averaging the corresponding
165 // coordinate of the center of the linked digits. The coordinates are
166 // given in the local reference sistem.
167 // errxcenter, errycenter, errzcenter are the errors associated to
168 // the corresponding average.
172 Int_t if1, min, max, nd;
173 Int_t x1, z1, t1, t2, t3;
174 Int_t ndx, ndz, ndxmin, ndxmax, ndzmin, ndzmax;
180 Int_t *ifpad = new Int_t[numberd];
181 Int_t *xpad = new Int_t[numberd];
182 Int_t *zpad = new Int_t[numberd];
183 Int_t *tr1pad = new Int_t[numberd];
184 Int_t *tr2pad = new Int_t[numberd];
185 Int_t *tr3pad = new Int_t[numberd];
186 Int_t *iclus = new Int_t[numberd];
190 for (i=0; i < ndigits ; i++) ifpad[i] = -1;
193 for (i=0; i < ndigits-1 ; i++)
195 if ( ifpad[i] == -1 )
201 for (Int_t j=i+1 ; j < ndigits ; j++)
205 dx = TMath::Abs(digx[i]-digx[j]);
206 dz = TMath::Abs(digz[i]-digz[j]);
208 // if ( ( dx+dz )==1 ) // clusters are not diagonal
209 if ( ( dx+dz )==1 || (dx==1 && dz==1) ) // diagonal clusters allowed
224 digtr1[j]=digtr1[ipos];
225 digtr2[j]=digtr2[ipos];
226 digtr3[j]=digtr3[ipos];
232 ifpad[j]=ifpad[ipos];
238 if ( ifpad[ndigits-1] == -1 )
241 ifpad[ndigits-1]=nclus-1;
243 for (i=0 ; i < ndigits ; i++) iclus[ifpad[i]]++;
248 // loop on found clusters
250 for (i=0 ; i < nclus ; i++)
254 Float_t deltax = fSegmentation->Dpx(0);
257 //cluster with more than one digit
260 for (k=min;k<min+nd;k++)
262 xpad[count] = digx[k];
263 zpad[count] = digz[k];
265 tr1pad[count] = digtr1[k];
266 tr2pad[count] = digtr2[k];
267 tr3pad[count] = digtr3[k];
271 ndxmin = xpad[TMath::LocMin(nd,xpad)];
272 ndxmax = xpad[TMath::LocMax(nd,xpad)];
273 ndzmin = zpad[TMath::LocMin(nd,zpad)];
274 ndzmax = zpad[TMath::LocMax(nd,zpad)];
275 ndx = ndxmax - ndxmin+1;
276 ndz = ndzmax - ndzmin+1;
278 // calculate x and z coordinates of the center of the cluster
279 fSegmentation->GetPadCxz(digx[min],digz[min]-1,xdum, zdum);
288 fSegmentation->GetPadCxz(xpad[k],zpad[k]-1,xdum,zdum);
289 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.);
312 fSegmentation->GetPadCxz(xpad[k],zpad[k]-1,xdum,zdum);
313 errxcenter[i] += ((xdum-xcenter[i])*(xdum-xcenter[i]))/(nd*(nd-1));
315 errxcenter[i] = TMath::Sqrt(errxcenter[i]);
319 Float_t deltaz = fSegmentation->Dpz(digz[min]);
320 errzcenter[i] = deltaz / TMath::Sqrt(12.);
325 fSegmentation->GetPadCxz(xpad[k],zpad[k]-1,xdum,zdum);
326 errzcenter[i] += ((zdum-zcenter[i])*(zdum-zcenter[i]))/(nd*(nd-1));
328 errzcenter[i] = TMath::Sqrt(errzcenter[i]);
331 // take three track numbers for the cluster
333 if(tr1pad[k] != -2) tr1clus[i]=tr1pad[k];
334 if(tr2pad[k] != -2) tr2clus[i]=tr2pad[k];
335 if(tr3pad[k] != -2) tr3clus[i]=tr3pad[k];
337 if(tr1clus[i] == 0) tr1clus[i]= -2;
338 if(tr2clus[i] == 0) tr2clus[i]= -2;
339 if(tr3clus[i] == 0) tr3clus[i]= -2;
343 // cluster with single digit
346 fSegmentation->GetPadCxz(digx[min],digz[min]-1,xdum,zdum);
349 tr1clus[i]=digtr1[min];
350 tr2clus[i]=digtr2[min];
351 tr3clus[i]=digtr3[min];
352 Float_t deltaz = fSegmentation->Dpz(digz[min]);
353 errxcenter[i] = deltax / TMath::Sqrt(12.);
354 errzcenter[i] = deltaz / TMath::Sqrt(12.);
357 // store the cluster information to the AliITSRawCLusterSPD object
358 AliITS *iTS=(AliITS*)gAlice->GetModule("ITS");
360 //put the cluster center in local reference frame of the detector
362 xcenter[i] = xcenter[i] - fSegmentation->Dx()/2.;
363 zcenter[i] = zcenter[i] - fSegmentation->Dz()/2.;
365 AliITSRawClusterSPD *clust = new AliITSRawClusterSPD(zcenter[i],xcenter[i],1.,ndz,ndx,0.,0.,0.,0.,0.,0.,0.);
366 iTS->AddCluster(0,clust);
373 //______________________________________________________
374 void AliITSClusterFinderSPDbari::DigitToPoint(Int_t nclus,
375 Float_t *xcenter, Float_t *zcenter,
376 Float_t *errxcenter,Float_t *errzcenter,
377 Int_t *tr1clus, Int_t *tr2clus, Int_t *tr3clus){
379 // A point is associated to each cluster of SPD digits. The points
380 // and their associated errors are stored in the file galiceSP.root.
385 const Float_t kconv = 1.0e-4; // micron -> cm
388 AliITS *iTS=(AliITS*)gAlice->GetModule("ITS");
390 for (Int_t i=0; i<nclus; i++)
392 l[0] = kconv*xcenter[i];
393 l[1] = kconv*fSegmentation->Dy()/2.;
394 l[2] = kconv*zcenter[i];
399 Float_t sigma2x = (kconv*errxcenter[i]) * (kconv*errxcenter[i]);
400 Float_t sigma2z = (kconv*errzcenter[i]) * (kconv*errzcenter[i]);
406 rnew.SetSigmaX2(sigma2x);
407 rnew.SetSigmaZ2(sigma2z);
408 rnew.fTracks[0]=tr1clus[i];
409 rnew.fTracks[1]=tr2clus[i];
410 rnew.fTracks[2]=tr3clus[i];
411 iTS->AddRecPoint(rnew);