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 **************************************************************************/
18 Revision 1.15 2001/05/01 22:37:44 nilsen
19 Added a dummy argument to FindRawClusters. Argument used for SSD version.
21 Revision 1.14 2001/03/05 14:48:46 nilsen
22 Fixed a reoccuring bug. Array sizes must be declare const.
27 #include "AliITSClusterFinderSPDdubna.h"
28 #include "AliITSMapA1.h"
30 #include "AliITSdigit.h"
31 #include "AliITSRawCluster.h"
32 #include "AliITSRecPoint.h"
33 #include "AliITSsegmentation.h"
34 #include "AliITSresponse.h"
39 ClassImp(AliITSClusterFinderSPDdubna)
41 //----------------------------------------------------------
42 AliITSClusterFinderSPDdubna::AliITSClusterFinderSPDdubna
43 (AliITSsegmentation *seg, TClonesArray *digits, TClonesArray *recp)
50 fMap=new AliITSMapA1(fSegmentation,fDigits);
56 //_____________________________________________________________________________
57 AliITSClusterFinderSPDdubna::AliITSClusterFinderSPDdubna()
71 //_____________________________________________________________________________
72 AliITSClusterFinderSPDdubna::~AliITSClusterFinderSPDdubna()
75 if (fMap) delete fMap;
79 //_____________________________________________________________________________
81 void AliITSClusterFinderSPDdubna::Find1DClusters()
83 // Find one dimensional clusters, i.e.
84 // in r*phi(x) direction for each colunm in z direction
86 AliITS *iTS=(AliITS*)gAlice->GetModule("ITS");
88 // retrieve the parameters
89 Int_t fNofPixels = fSegmentation->Npz();
90 Int_t fMaxNofSamples = fSegmentation->Npx();
92 // read in digits -> do not apply threshold
93 // signal in fired pixels is always 1
97 Int_t nofFoundClusters = 0;
100 for(k=0;k<fNofPixels;k++) {
102 Int_t mmax = 10; // a size of the window for the cluster finding
104 for(it=0;it<fMaxNofSamples;it++) {
112 for(m=0;m<mmax;m++) { // find the cluster inside the window
114 if(id >= fMaxNofSamples) break; // ! no possible for the fadc
116 if(fMap->TestHit(k,id) == kUnused) { // start of the cluster
118 if(lclx == 1) xstart = id;
122 if(lclx > 0 && fMap->TestHit(k,id) == kEmpty) {
123 // end of cluster if a gap exists
131 if(lclx == 0 && ilcl == 0) it = id; // no cluster in the window,
132 // continue the "it" loop
134 if(id >= fMaxNofSamples && lclx == 0) break; // the x row finished
136 if(id < fMaxNofSamples && ilcl == 0 && lclx > 0) {
137 // cluster end is outside of the window,
138 mmax += 5; // increase mmax and repeat the cluster
143 if(id >= fMaxNofSamples && lclx > 0) { // the x row finished but
144 xstop = fMaxNofSamples - 1; // the end cluster exists
148 // --- Calculate z and x coordinates for one dimensional clusters
150 if(ilcl == 1) { // new cluster exists
154 Float_t clusterCharge = 0.;
155 Float_t zpitch = fSegmentation->Dpz(k+1);
156 Float_t clusterZ, dummyX;
158 fSegmentation->GetPadCxz(dummy,k,dummyX,clusterZ);
159 Float_t zstart = clusterZ - 0.5*zpitch;
160 Float_t zstop = clusterZ + 0.5*zpitch;
161 Float_t clusterX = 0.;
162 Int_t xstartfull = xstart;
163 Int_t xstopfull = xstop;
164 Int_t clusterSizeX = lclx;
165 Int_t clusterSizeZ = 1;
168 for(its=xstart; its<=xstop; its++) {
170 if (fMap->GetHitIndex(k,its)>=0) firedpixel=1;
171 clusterCharge += firedpixel;
172 clusterX +=its + 0.5;
174 Float_t fRphiPitch = fSegmentation->Dpx(dummy);
175 clusterX /= (clusterSizeX/fRphiPitch); // center of gravity for x
177 // Write the points (coordinates and some cluster information) to the
178 // AliITSRawClusterSPD object
180 AliITSRawClusterSPD clust(clusterZ,clusterX,clusterCharge,clusterSizeZ,clusterSizeX,xstart,xstop,xstartfull,xstopfull,zstart,zstop,k);
182 iTS->AddCluster(0,&clust);
184 } // new cluster (ilcl=1)
185 } // X direction loop (it)
186 } // Z direction loop (k)
193 //_____________________________________________________________________________
194 void AliITSClusterFinderSPDdubna::GroupClusters()
196 // Find two dimensional clusters, i.e. group one dimensional clusters
197 // into two dimensional ones (go both in x and z directions).
199 // get number of clusters for this module
200 Int_t nofClusters = fClusters->GetEntriesFast();
201 nofClusters -= fNclusters;
202 AliITSRawClusterSPD *clusterI;
203 AliITSRawClusterSPD *clusterJ;
205 Int_t *label=new Int_t[nofClusters];
207 for(i=0; i<nofClusters; i++) label[i] = 0;
208 for(i=0; i<nofClusters; i++) {
209 if(label[i] != 0) continue;
210 for(j=i+1; j<nofClusters; j++) {
211 if(label[j] != 0) continue;
212 clusterI = (AliITSRawClusterSPD*) fClusters->At(i);
213 clusterJ = (AliITSRawClusterSPD*) fClusters->At(j);
214 Bool_t pair = clusterI->Brother(clusterJ,fDz,fDx);
217 // if((clusterI->XStop() == clusterJ->XStart()-1)||(clusterI->XStart()==clusterJ->XStop()+1)) cout<<"!! Diagonal cluster"<<endl;
220 cout << "clusters " << i << "," << j << " before grouping" << endl;
221 clusterI->PrintInfo();
222 clusterJ->PrintInfo();
225 clusterI->Add(clusterJ);
226 // cout << "remove cluster " << j << endl;
228 fClusters->RemoveAt(j);
231 cout << "cluster " << i << " after grouping" << endl;
232 clusterI->PrintInfo();
239 fClusters->Compress();
243 Int_t totalNofClusters = fClusters->GetEntriesFast();
244 cout << " Nomber of clusters at the group end ="<< totalNofClusters<<endl;
253 //_____________________________________________________________________________
255 void AliITSClusterFinderSPDdubna::TracksInCluster()
258 // Find tracks creating one cluster
260 // get number of clusters for this module
261 Int_t nofClusters = fClusters->GetEntriesFast();
262 nofClusters -= fNclusters;
264 Int_t i, ix, iz, jx, jz, xstart, xstop, zstart, zstop, nclx, nclz;
265 const Int_t trmax = 100;
266 Int_t cltracks[trmax], itr, tracki, ii, is, js, ie, ntr, tr0, tr1, tr2;
268 for(i=0; i<nofClusters; i++) {
270 memset(cltracks,-1,sizeof(int)*trmax);
273 AliITSRawClusterSPD *clusterI = (AliITSRawClusterSPD*) fClusters->At(i);
275 nclx = clusterI->NclX();
276 nclz = clusterI->NclZ();
277 xstart = clusterI->XStartf();
278 xstop = clusterI->XStopf();
279 zstart = clusterI->Zend()-nclz+1;
280 zstop = clusterI->Zend();
283 for(iz=0; iz<nclz; iz++) {
285 for(ix=0; ix<nclx; ix++) {
287 ind = fMap->GetHitIndex(jz,jx);
291 if(ind == 0 && iz >= 0 && ix > 0) {
294 if(ind == 0 && iz > 0 && ix >= 0) {
297 if(ind == 0 && iz == 0 && ix == 0 && i > 0) {
301 AliITSdigitSPD *dig = (AliITSdigitSPD*)fMap->GetHit(jz,jx);
305 track0=dig->fTracks[0];
306 track1=dig->fTracks[1];
307 track2=dig->fTracks[2];
310 for(itr=0; itr<3; itr++) {
311 tracki = dig->fTracks[itr];
316 if(ii < 99) cltracks[ii-1] = tracki;
322 for(is=0; is<trmax; is++) {
323 if(cltracks[is]<0) continue;
324 for(js=is+1; js<trmax; js++) {
325 if(cltracks[js]<0) continue;
326 if(cltracks[js]==cltracks[is]) cltracks[js]=-5;
331 for(ie=0; ie<trmax; ie++) {
332 if(cltracks[ie] >= 0) {
334 if(ntr==1) tr0=cltracks[ie];
335 if(ntr==2) tr1=cltracks[ie];
336 if(ntr==3) tr2=cltracks[ie];
340 if(ntr == 0) ntr = 1;
342 clusterI->SetNTracks(ntr);
343 clusterI->SetTracks(tr0,tr1,tr2);
348 //_____________________________________________________________________________
350 void AliITSClusterFinderSPDdubna::GetRecPoints()
353 AliITS *iTS=(AliITS*)gAlice->GetModule("ITS");
355 // get number of clusters for this module
356 Int_t nofClusters = fClusters->GetEntriesFast();
357 nofClusters -= fNclusters;
358 const Float_t kconv = 1.0e-4;
359 const Float_t kRMSx = 12.0*kconv; // microns -> cm ITS TDR Table 1.3
360 const Float_t kRMSz = 70.0*kconv; // microns -> cm ITS TDR Table 1.3
362 Float_t spdLength = fSegmentation->Dz();
363 Float_t spdWidth = fSegmentation->Dx();
365 Float_t xpitch = fSegmentation->Dpx(dummy);
367 Int_t track0, track1, track2;
369 for(i=0; i<nofClusters; i++) {
371 AliITSRawClusterSPD *clusterI = (AliITSRawClusterSPD*) fClusters->At(i);
372 Int_t clustersizex = clusterI->NclX();
373 Int_t clustersizez = clusterI->NclZ();
374 Int_t xstart = clusterI->XStartf();
375 Float_t clusterx = 0;
376 Float_t clusterz = clusterI->Z();
378 for(Int_t ii=0; ii<clustersizex; ii++) {
379 clusterx += (xstart+0.5+ii)*xpitch;
381 clusterx /= clustersizex;
382 clusterz /= clustersizez;
383 clusterI->GetTracks(track0, track1, track2);
386 rnew.SetX((clusterx - spdWidth/2)*kconv);
387 rnew.SetZ((clusterz - spdLength/2)*kconv);
390 rnew.SetSigmaX2(kRMSx*kRMSx);
391 rnew.SetSigmaZ2(kRMSz*kRMSz);
392 rnew.fTracks[0]=track0;
393 rnew.fTracks[1]=track1;
394 rnew.fTracks[2]=track2;
395 iTS->AddRecPoint(rnew);
401 //_____________________________________________________________________________
403 void AliITSClusterFinderSPDdubna::FindRawClusters(Int_t mod)
406 cout<<"SPDdubna: module ="<<mod<<endl;