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 **************************************************************************/
21 // developed by the Dubna group
23 #include <Riostream.h>
24 #include "AliITSClusterFinderSPDdubna.h"
25 #include "AliITSMapA1.h"
27 #include "AliITSdigit.h"
28 #include "AliITSRawCluster.h"
29 #include "AliITSRecPoint.h"
30 #include "AliITSsegmentation.h"
35 ClassImp(AliITSClusterFinderSPDdubna)
37 //----------------------------------------------------------------------
38 AliITSClusterFinderSPDdubna::AliITSClusterFinderSPDdubna(
39 AliITSsegmentation *seg, TClonesArray *digits, TClonesArray *recp){
46 fMap = new AliITSMapA1(fSegmentation,fDigits);
51 //_______________________________________________________________________
52 AliITSClusterFinderSPDdubna::AliITSClusterFinderSPDdubna(){
64 //______________________________________________________________________
65 AliITSClusterFinderSPDdubna &AliITSClusterFinderSPDdubna::operator=(const
66 AliITSClusterFinderSPDdubna &s){
67 // The = operator for the class AliITSClusterFinderSPDdugna
69 // AliITSClusterFinderSPDdubna @s The AliITSClusterFinderSPDdubna
70 // class to be copy constructed.
74 // this, a copy of the class s.
76 this->fNclusters = s.fNclusters;
79 this->fMinNCells = s.fMinNCells;
80 this->fClusters = new TClonesArray(*(s.fClusters));
83 //______________________________________________________________________
84 AliITSClusterFinderSPDdubna::AliITSClusterFinderSPDdubna(
85 const AliITSClusterFinderSPDdubna &s): AliITSClusterFinder(s){
86 // The Copy constructortor the class AliITSClusterFinderSPDdugna
87 // It calles the = operator.
89 // AliITSClusterFinderSPDdubna @s The AliITSClusterFinderSPDdubna
90 // class to be copy constructed.
99 //______________________________________________________________________
100 AliITSClusterFinderSPDdubna::~AliITSClusterFinderSPDdubna(){
103 if (fMap) delete fMap;
105 //______________________________________________________________________
106 void AliITSClusterFinderSPDdubna::Find1DClusters(Int_t mod){
107 // Find one dimensional clusters, i.e.
108 // in r*phi(x) direction for each colunm in z direction
110 static AliITS *iTS=(AliITS*)gAlice->GetModule("ITS");
112 // retrieve the parameters
113 Int_t fNofPixels = fSegmentation->Npz();
114 Int_t fMaxNofSamples = fSegmentation->Npx();
116 // read in digits -> do not apply threshold
117 // signal in fired pixels is always 1
120 Int_t nofFoundClusters = 0;
123 for(k=0;k<fNofPixels;k++) {
124 Int_t mmax = 10; // a size of the window for the cluster finding
125 for(it=0;it<fMaxNofSamples;it++) {
131 for(m=0;m<mmax;m++) { // find the cluster inside the window
133 if(id >= fMaxNofSamples) break; // ! no possible for the fadc
134 if(fMap->TestHit(k,id) == kUnused) { // start of the cluster
136 if(lclx == 1) xstart = id;
138 if(lclx > 0 && fMap->TestHit(k,id) == kEmpty) {
139 // end of cluster if a gap exists
143 } // end if lclx >0 ...
145 if(lclx == 0 && ilcl == 0) it = id; // no cluster in the window,
146 // continue the "it" loop
147 if(id >= fMaxNofSamples && lclx == 0) break; // the x row finished
148 if(id < fMaxNofSamples && ilcl == 0 && lclx > 0) {
149 // cluster end is outside of the window,
150 mmax += 5; // increase mmax and repeat the cluster finding
153 if(id >= fMaxNofSamples && lclx > 0) { // the x row finished but
154 xstop = fMaxNofSamples - 1; // the end cluster exists
157 // --- Calculate z and x coordinates for one dimensional clusters
158 if(ilcl == 1) { // new cluster exists
162 Float_t clusterCharge = 0.;
163 Float_t zpitch = fSegmentation->Dpz(k+1);
165 Float_t clusterZ, dummyX;
166 fSegmentation->GetPadCxz(dummy,k,dummyX,clusterZ);
167 Float_t zstart = clusterZ - 0.5*zpitch;
168 Float_t zstop = clusterZ + 0.5*zpitch;
169 Float_t clusterX = 0.;
170 Int_t clusterSizeX = lclx;
171 Int_t clusterSizeZ = 1;
173 for(its=xstart; its<=xstop; its++) {
175 if (fMap->GetHitIndex(k,its)>=0) firedpixel=1;
176 clusterCharge += firedpixel;
177 clusterX += its + 0.5;
179 Float_t fRphiPitch = fSegmentation->Dpx(dummy);
180 clusterX /= (clusterSizeX/fRphiPitch); // center of gravity for x
181 // Write the points (coordinates and some cluster information)
182 // to the AliITSRawClusterSPD object
184 AliITSRawClusterSPD clust(clusterZ,clusterX,clusterCharge,
185 clusterSizeZ,clusterSizeX,
186 xstart,xstop,zstart,zstop,k,mod);
187 iTS->AddCluster(0,&clust);
188 } // new cluster (ilcl=1)
189 } // X direction loop (it)
190 } // Z direction loop (k)
194 //______________________________________________________________________
195 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).
198 // get number of clusters for this module
200 Int_t nofClusters = fClusters->GetEntriesFast();
201 nofClusters -= fNclusters;
202 AliITSRawClusterSPD *clusterI;
203 AliITSRawClusterSPD *clusterJ;
204 Int_t *label=new Int_t[nofClusters];
206 for(i=0; i<nofClusters; i++) label[i] = 0;
207 for(i=0; i<nofClusters; i++) {
208 if(label[i] != 0) continue;
209 for(j=i+1; j<nofClusters; j++) {
210 if(label[j] != 0) continue;
211 clusterI = (AliITSRawClusterSPD*) fClusters->At(i);
212 clusterJ = (AliITSRawClusterSPD*) fClusters->At(j);
213 Bool_t pair = clusterI->Brother(clusterJ,fDz,fDx);
216 cout << "clusters " << i << "," << j << " before grouping" << endl;
217 clusterI->PrintInfo();
218 clusterJ->PrintInfo();
220 clusterI->Add(clusterJ);
222 cout << "remove cluster " << j << endl;
225 fClusters->RemoveAt(j);
227 cout << "cluster " << i << " after grouping" << endl;
228 clusterI->PrintInfo();
234 fClusters->Compress();
236 Int_t totalNofClusters = fClusters->GetEntriesFast();
237 cout << " Nomber of clusters at the group end ="<< totalNofClusters<<endl;
242 //______________________________________________________________________
243 void AliITSClusterFinderSPDdubna::TracksInCluster(){
244 // Find tracks creating one cluster
245 // get number of clusters for this module
246 Int_t nofClusters = fClusters->GetEntriesFast();
247 Int_t i, ix, iz, jx, jz, xstart, xstop, zstart, zstop, nclx, nclz;
248 const Int_t kTrmax = 100;
249 Int_t cltracks[kTrmax], itr, tracki, ii, is, js, ie, ntr, tr0, tr1, tr2;
251 nofClusters -= fNclusters;
252 for(i=0; i<nofClusters; i++) {
254 memset(cltracks,-1,sizeof(int)*kTrmax);
256 AliITSRawClusterSPD *clusterI = (AliITSRawClusterSPD*) fClusters->At(i);
257 nclx = clusterI->NclX();
258 nclz = clusterI->NclZ();
259 xstart = clusterI->XStartf();
260 xstop = clusterI->XStopf();
261 zstart = clusterI->Zend()-nclz+1;
262 zstop = clusterI->Zend();
264 for(iz=0; iz<nclz; iz++) {
266 for(ix=0; ix<nclx; ix++) {
268 ind = fMap->GetHitIndex(jz,jx);
269 if(ind < 0) continue;
270 if(ind == 0 && iz >= 0 && ix > 0) continue;
271 if(ind == 0 && iz > 0 && ix >= 0) continue;
272 if(ind == 0 && iz == 0 && ix == 0 && i > 0) continue;
273 AliITSdigitSPD *dig = (AliITSdigitSPD*)fMap->GetHit(jz,jx);
274 for(itr=0; itr<3; itr++) {
275 tracki = dig->GetTrack(i);
278 if(ii < 99) cltracks[ii-1] = tracki;
279 } // end if tracki >-0
283 for(is=0; is<kTrmax; is++) {
284 if(cltracks[is]<0) continue;
285 for(js=is+1; js<kTrmax; js++) {
286 if(cltracks[js]<0) continue;
287 if(cltracks[js]==cltracks[is]) cltracks[js]=-5;
291 for(ie=0; ie<kTrmax; ie++) {
292 if(cltracks[ie] >= 0) {
294 if(ntr==1) tr0=cltracks[ie];
295 if(ntr==2) tr1=cltracks[ie];
296 if(ntr==3) tr2=cltracks[ie];
297 } // end if cltracks[ie] >-=
300 if(ntr == 0) ntr = 1;
301 clusterI->SetNTracks(ntr);
302 clusterI->SetTracks(tr0,tr1,tr2);
305 //______________________________________________________________________
306 void AliITSClusterFinderSPDdubna::GetRecPoints(){
308 static AliITS *iTS = (AliITS*)gAlice->GetModule("ITS");
309 // get number of clusters for this module
310 Int_t nofClusters = fClusters->GetEntriesFast();
311 const Float_t kconv = 1.0e-4;
312 const Float_t kRMSx = 12.0*kconv; // microns -> cm ITS TDR Table 1.3
313 const Float_t kRMSz = 70.0*kconv; // microns -> cm ITS TDR Table 1.3
314 Float_t spdLength = fSegmentation->Dz();
315 Float_t spdWidth = fSegmentation->Dx();
317 Float_t xpitch = fSegmentation->Dpx(dummy);
319 Int_t track0, track1, track2;
321 nofClusters -= fNclusters;
322 for(i=0; i<nofClusters; i++) {
323 AliITSRawClusterSPD *clusterI = (AliITSRawClusterSPD*) fClusters->At(i);
324 Int_t clustersizex = clusterI->NclX();
325 Int_t clustersizez = clusterI->NclZ();
326 Int_t xstart = clusterI->XStartf();
327 Float_t clusterx = 0;
328 Float_t clusterz = clusterI->Z();
329 for(Int_t ii=0; ii<clustersizex; ii++) clusterx += (xstart+0.5+ii)*xpitch;
330 clusterx /= clustersizex;
331 clusterz /= clustersizez;
332 clusterI->GetTracks(track0, track1, track2);
334 rnew.SetX((clusterx - spdWidth/2)*kconv);
335 rnew.SetZ((clusterz - spdLength/2)*kconv);
338 rnew.SetSigmaX2(kRMSx*kRMSx);
339 rnew.SetSigmaZ2(kRMSz*kRMSz);
340 rnew.fTracks[0]=track0;
341 rnew.fTracks[1]=track1;
342 rnew.fTracks[2]=track2;
343 iTS->AddRecPoint(rnew);
347 //______________________________________________________________________
348 void AliITSClusterFinderSPDdubna::FindRawClusters(Int_t mod){
352 cout<<"SPDdubna: module ="<<mod<<endl;